Dolphin
This commit is contained in:
@@ -52,6 +52,7 @@ target_compile_definitions(${DUSK_BINARY_TARGET_NAME} PUBLIC
|
||||
DUSK_DISPLAY_WIDTH=480
|
||||
DUSK_DISPLAY_HEIGHT=272
|
||||
DUSK_THREAD_PTHREAD
|
||||
DUSK_TIME_DYNAMIC
|
||||
)
|
||||
|
||||
# Postbuild, create .pbp file for PSP.
|
||||
|
||||
@@ -35,6 +35,7 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
|
||||
errorChain(sceneInit());
|
||||
|
||||
consolePrint("Engine initialized");
|
||||
// sceneSet(SCENE_TYPE_SPINNINGBOX);
|
||||
sceneSet(SCENE_TYPE_SPINNINGBOX);
|
||||
|
||||
errorOk();
|
||||
|
||||
@@ -21,23 +21,23 @@ void timeInit(void) {
|
||||
TIME.delta = DUSK_TIME_STEP;
|
||||
|
||||
#ifdef DUSK_TIME_DYNAMIC
|
||||
TIME.dynamicTime = DUSK_TIME_STEP;
|
||||
TIME.dynamicDelta = DUSK_TIME_STEP;
|
||||
TIME.dynamicTime = 0.0f;
|
||||
TIME.dynamicDelta = 0.0f;
|
||||
TIME.dynamicUpdate = false;
|
||||
TIME.lastNonDynamic = TIME.dynamicTime;
|
||||
TIME.lastNonDynamic = 0.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
void timeUpdate(void) {
|
||||
#ifdef DUSK_TIME_DYNAMIC
|
||||
timeTickPlatform();
|
||||
TIME.dynamicDelta = fixedFromFloat(timeGetDeltaPlatform());
|
||||
TIME.dynamicTime = fixedAdd(TIME.dynamicTime, TIME.dynamicDelta);
|
||||
TIME.dynamicDelta = timeGetDeltaPlatform();
|
||||
TIME.dynamicTime += TIME.dynamicDelta;
|
||||
TIME.dynamicUpdate = true;
|
||||
|
||||
assertTrue(TIME.dynamicDelta >= 0, "Time delta is negative");
|
||||
assertTrue(TIME.dynamicDelta >= 0.0f, "Time delta is negative");
|
||||
|
||||
if(fixedSub(TIME.dynamicTime, TIME.lastNonDynamic) >= DUSK_TIME_STEP) {
|
||||
if((TIME.dynamicTime - TIME.lastNonDynamic) >= DUSK_TIME_STEP_F) {
|
||||
TIME.dynamicUpdate = false;
|
||||
TIME.lastNonDynamic = TIME.dynamicTime;
|
||||
TIME.delta = DUSK_TIME_STEP;
|
||||
|
||||
+12
-5
@@ -11,7 +11,13 @@
|
||||
#include "util/fixed.h"
|
||||
|
||||
#ifndef DUSK_TIME_STEP
|
||||
#define DUSK_TIME_STEP FIXED(16.0f / 1000.0f)
|
||||
#define DUSK_TIME_STEP FIXED(1.0f / 60.0f)
|
||||
#endif
|
||||
|
||||
/* Float-space step used by the dynamic accumulator to avoid fixed-point
|
||||
* truncation error in the trigger comparison. */
|
||||
#ifndef DUSK_TIME_STEP_F
|
||||
#define DUSK_TIME_STEP_F (1.0f / 60.0f)
|
||||
#endif
|
||||
|
||||
#ifdef DUSK_TIME_DYNAMIC
|
||||
@@ -28,10 +34,11 @@ typedef struct {
|
||||
fixed_t time;
|
||||
|
||||
#ifdef DUSK_TIME_DYNAMIC
|
||||
fixed_t lastNonDynamic;
|
||||
bool_t dynamicUpdate;
|
||||
fixed_t dynamicDelta;
|
||||
fixed_t dynamicTime;
|
||||
/* Float accumulator avoids fixed-point truncation drift. */
|
||||
float_t lastNonDynamic;
|
||||
bool_t dynamicUpdate;
|
||||
float_t dynamicDelta;
|
||||
float_t dynamicTime;
|
||||
#endif
|
||||
} dusktime_t;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "display/display.h"
|
||||
#include "display/render/renderdolphin.h"
|
||||
#include "display/screen.h"
|
||||
#include "util/memory.h"
|
||||
#include "engine/engine.h"
|
||||
#include "assert/assert.h"
|
||||
@@ -80,7 +81,9 @@ errorret_t displayInitDolphin(void) {
|
||||
GX_SetDispCopyGamma(GX_GM_1_0);
|
||||
GX_SetColorUpdate(GX_TRUE);
|
||||
|
||||
// Describe mesh vertex format.
|
||||
SCREEN.width = (int32_t)DISPLAY.screenMode->fbWidth;
|
||||
SCREEN.height = (int32_t)DISPLAY.screenMode->efbHeight;
|
||||
|
||||
/* Vertex format is configured per-draw by the render backend */
|
||||
GX_SetCullMode(GX_CULL_NONE);
|
||||
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
|
||||
|
||||
@@ -123,6 +123,27 @@ errorret_t renderDolphinInit(void) {
|
||||
guMtxIdentity(dolphinView);
|
||||
guPerspective(dolphinProj, 60.0f, 4.0f/3.0f, 0.1f, 100.0f);
|
||||
|
||||
/* Single color channel: no lighting, material color driven from register. */
|
||||
GX_SetNumChans(1);
|
||||
GX_SetChanCtrl(
|
||||
GX_COLOR0A0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG,
|
||||
GX_LIGHTNULL, GX_DF_NONE, GX_AF_NONE
|
||||
);
|
||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor){0, 0, 0, 0});
|
||||
GX_SetChanMatColor(GX_COLOR0A0, (GXColor){255, 255, 255, 255});
|
||||
|
||||
/* One texture coordinate fed straight from vertex TEX0 attribute. */
|
||||
GX_SetNumTexGens(1);
|
||||
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
|
||||
|
||||
/* One TEV stage: modulate texture by material (tint) color. */
|
||||
GX_SetNumTevStages(1);
|
||||
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
|
||||
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
|
||||
|
||||
/* Alpha test: always pass so blending handles transparency, not rejection. */
|
||||
GX_SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0);
|
||||
|
||||
errorOk();
|
||||
}
|
||||
|
||||
@@ -247,11 +268,7 @@ static void setup3D(void) {
|
||||
/* ---- Tint channel -------------------------------------------------------- */
|
||||
|
||||
static void setTintChannel(color_t tint) {
|
||||
GX_SetTevColor(GX_TEVREG0, (GXColor){tint.r, tint.g, tint.b, tint.a});
|
||||
GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_C0, GX_CC_ZERO);
|
||||
GX_SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_TEXA, GX_CA_A0, GX_CA_ZERO);
|
||||
GX_SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
|
||||
GX_SetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
|
||||
GX_SetChanMatColor(GX_COLOR0A0, (GXColor){tint.r, tint.g, tint.b, tint.a});
|
||||
}
|
||||
|
||||
/* ---- 2D sprite ----------------------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user