diff --git a/include/core1/core1.h b/include/core1/core1.h index 5d4c95d8..60e0bd28 100644 --- a/include/core1/core1.h +++ b/include/core1/core1.h @@ -149,17 +149,17 @@ void core1_ce60_func_8024BD40(s32 arg0, s32 arg1); /* src/core1/depthbuffer.c */ -extern u8 D_8000E800; +extern u8 D_8000E800[]; -void func_80253190(Gfx **gfx); -void func_80253208(Gfx **gfx, s32 x, s32 y, s32 w, s32 h, void *color_buffer); -bool func_80253400(void); -bool depthBuffer_isPointerSet(void); -void depthBuffer_stub(void); -void func_80253428(int arg0); -void func_802534A8(int arg0); -void zBuffer_set(Gfx **gfx); -void *zBuffer_get(void); +void depthbuffer_clear(Gfx **gfx); +void depthbuffer_clearRegion(Gfx **gfx, s32 x, s32 y, s32 w, s32 h, void *color_buffer); +bool depthbuffer_getUnk4(void); +bool depthbuffer_isDataPtrSet(void); +void depthbuffer_stub(void); +void depthbuffer_enable(bool enable); +void depthbuffer_setUnk4(bool value); +void depthbuffer_set(Gfx **gfx); +void *depthbuffer_getDataPtr(void); @@ -189,9 +189,9 @@ extern u16 gFramebuffers[2][DEFAULT_FRAMEBUFFER_WIDTH * DEFAULT_FRAMEBUFFER_HEIG void core1_15B30_requestLockForTaskDataID(void); void core1_15B30_requestReleaseForTaskDataID(void); void core1_15B30_addAudioTaskData(Acmd *start, Acmd *end, OSMesgQueue *mesg_queue, OSMesg msg); -void func_80253640(Gfx ** gdl, void *arg1); -void scissorBox_SetForGameMode(Gfx **gdl, s32 framebuffer_idx); -void setupScissorBoxAndFramebuffer(Gfx **gfx, s32 framebuffer_address); +void setupFramebuffer(Gfx **gfx, void *color_buffer); +void setupFramebufferForGamemode(Gfx **gfx, s32 framebuffer_idx); +void setupScissorBoxAndFramebuffer(Gfx **gfx, void *color_buffer); void setupDefaultScissorBoxAndFramebuffer(Gfx **gfx, s32 framebuffer_idx); void core1_15B30_finishDList_renderThread(Gfx **gfx); void core1_15B30_finishDList(Gfx **gfx); @@ -211,8 +211,8 @@ void graphicsCache_init(void); void scissorBox_set(s32 left, s32 top, s32 right, s32 bottom); void scissorBox_setDefault(void); void core1_15B30_addTask7TaskData(s32 framebuffer_id); -void toggleTextureFilterPoint(void); -void getGraphicsStacks(Gfx **gfx, Mtx **mtx, Vtx **vtx); +void core1_15B30_toggleTexturePointFilter(void); +void graphicscache_swapAndGetStacks(Gfx **gfx, Mtx **mtx, Vtx **vtx); void dummy_func_80254464(void); /* src/core1/defragmanager.c */ diff --git a/include/core1/ml.h b/include/core1/ml.h index 65823c0e..04ef3810 100644 --- a/include/core1/ml.h +++ b/include/core1/ml.h @@ -23,7 +23,7 @@ void ml_vec3f_normalize(f32 vec[3]); void ml_vec2f_normalize(f32 vec[2]); void ml_3f_normalize(f32 *x, f32 *y, f32 *z); void ml_vec3f_set_length_copy(f32 dst[3], f32 src[3], f32 len); -void func_80256664(f32 ptr[3]); +void ml_vec3f_clamp_deg360(f32 ptr[3]); void func_80256740(f32 vec[3]); void ml_vec3f_pitch_rotate_copy(f32 dst[3], f32 src[3], f32 pitch); void ml_vec3f_yaw_rotate_copy(f32 dst[3], f32 src[3], f32 yaw); diff --git a/include/gc/gctransition.h b/include/gc/gctransition.h index a891672a..8dc44c08 100644 --- a/include/gc/gctransition.h +++ b/include/gc/gctransition.h @@ -2,7 +2,7 @@ #define __GC_TRANSITION__ void gctransition_defrag(void); -void gctransition_draw(Gfx **arg0, Mtx **arg1, Vtx **arg2); +void gctransition_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx); void gctransition_8030BD4C(void); f32 gctransition_8030BD88(void); int gctransition_done(void); diff --git a/include/math.h b/include/math.h index c0a10900..e33e34bb 100644 --- a/include/math.h +++ b/include/math.h @@ -9,6 +9,8 @@ out[2] = c;\ } +#define TUPLE_SET(dst, value) { dst[0] = dst[1] = dst[2] = value; } + #define TUPLE_COPY(dst, src) {\ dst[0] = src[0];\ dst[1] = src[1];\ diff --git a/include/prop.h b/include/prop.h index b53ef059..fa02e318 100644 --- a/include/prop.h +++ b/include/prop.h @@ -136,7 +136,7 @@ typedef struct actorMarker_s{ u32 unk40_22:1; u32 unk40_21:1; u32 unk40_20:1; - u32 unk40_19:1; + u32 unk40_19:1; // set for screen overlay sprites u32 pad40_18:19; Vec3fArray * unk44; BKModel * unk48; diff --git a/src/core1/code_0.c b/src/core1/code_0.c index af26adb2..1c514090 100644 --- a/src/core1/code_0.c +++ b/src/core1/code_0.c @@ -151,7 +151,7 @@ void mainLoop(void){ #if ANTI_TAMPER if(!mapSpecificFlags_validateCRC1()){ - eeprom_writeBlocks(0, 0, 0x80397AD0, 0x40); + eeprom_writeBlocks(0, 0, (void *) PHYS_TO_K0(0x00397AD0), EEPROM_MAXBLOCKS); } #endif @@ -164,7 +164,7 @@ void mainLoop(void){ func_80255ACC(); spawnQueue_func_802C3A18(); if(func_802E4424()) - game_draw(0); + game_draw(FALSE); spawnQueue_flush(); break; }//L8023DE34 diff --git a/src/core1/code_15B30.c b/src/core1/code_15B30.c index 611c5745..70eb75b6 100644 --- a/src/core1/code_15B30.c +++ b/src/core1/code_15B30.c @@ -8,7 +8,7 @@ s32 gFramebufferHeight = DEFAULT_FRAMEBUFFER_HEIGHT; static Mtx *sMtxStack[2]; static Vtx *sVtxStack[2]; static s32 sStackSelector; -s32 gTextureFilterPoint; +bool sUseTexturePointFilter; struct ucode_task_data_s sUcodeTaskData[20]; s32 sCurrentUcodeTaskDataID; OSMesgQueue sTaskDataListLockMesgQueue; @@ -17,7 +17,7 @@ u16 gScissorBoxLeft; u16 gScissorBoxRight; u16 gScissorBoxTop; u16 gScissorBoxBottom; -Gfx *D_80283214; +Gfx *D_80283214; // never used void core1_15B30_requestLockForTaskDataID(void) { osRecvMesg(&sTaskDataListLockMesgQueue, NULL, OS_MESG_BLOCK); @@ -44,47 +44,45 @@ void core1_15B30_addAudioTaskData(Acmd *start, Acmd *end, OSMesgQueue *mesg_queu thread5_sendTaskToQueue((OSMesg) task_data); } -void func_80253640(Gfx ** gdl, void *arg1){ - D_80283214 = *gdl; - gSPSegment((*gdl)++, 0x00, 0x00000000); - gDPSetRenderMode((*gdl)++, G_RM_NOOP, G_RM_NOOP2); - gSPClearGeometryMode((*gdl)++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH); - gDPPipeSync((*gdl)++); - gDPPipelineMode((*gdl)++, G_PM_NPRIMITIVE); - gDPSetAlphaCompare((*gdl)++, G_AC_NONE); - gDPSetColorDither((*gdl)++, G_CD_MAGICSQ); - gDPSetScissor((*gdl)++, G_SC_NON_INTERLACE, gScissorBoxLeft, gScissorBoxRight, gScissorBoxTop, gScissorBoxBottom); - func_80253208(gdl, 0, 0, gFramebufferWidth, gFramebufferHeight, arg1); - gDPSetColorImage((*gdl)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gFramebufferWidth, OS_K0_TO_PHYSICAL(arg1)); - gDPSetCycleType((*gdl)++, G_CYC_1CYCLE); - gDPSetTextureConvert((*gdl)++, G_TC_FILT); - gDPSetTextureDetail((*gdl)++, G_TD_CLAMP); - if(gTextureFilterPoint){ - gDPSetTextureFilter((*gdl)++, G_TF_POINT); - }else{ - gDPSetTextureFilter((*gdl)++, G_TF_BILERP); - } - gDPSetTextureLOD((*gdl)++, G_TL_TILE); - gDPSetTextureLUT((*gdl)++, G_TT_NONE); - gDPSetTexturePersp((*gdl)++, G_TP_PERSP); - zBuffer_set(gdl); -} - -void scissorBox_SetForGameMode(Gfx **gdl, s32 framebuffer_idx) { - if(getGameMode() == GAME_MODE_8_BOTTLES_BONUS || getGameMode() == GAME_MODE_A_SNS_PICTURE) - { - scissorBox_setSmall(); - func_80253640(gdl, func_8030C704()); - } - else{ - scissorBox_setDefault(); - func_80253640(gdl, gFramebuffers[framebuffer_idx]); - } -} - -void setupScissorBoxAndFramebuffer(Gfx **gfx, s32 framebuffer_address){ +void setupFramebuffer(Gfx **gfx, void *color_buffer) { + D_80283214 = *gfx; gSPSegment((*gfx)++, 0x00, 0x00000000); - gDPSetColorImage((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gFramebufferWidth, OS_PHYSICAL_TO_K0(framebuffer_address)); + gDPSetRenderMode((*gfx)++, G_RM_NOOP, G_RM_NOOP2); + gSPClearGeometryMode((*gfx)++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH); + gDPPipeSync((*gfx)++); + gDPPipelineMode((*gfx)++, G_PM_NPRIMITIVE); + gDPSetAlphaCompare((*gfx)++, G_AC_NONE); + gDPSetColorDither((*gfx)++, G_CD_MAGICSQ); + gDPSetScissor((*gfx)++, G_SC_NON_INTERLACE, gScissorBoxLeft, gScissorBoxRight, gScissorBoxTop, gScissorBoxBottom); + depthbuffer_clearRegion(gfx, 0, 0, gFramebufferWidth, gFramebufferHeight, color_buffer); + gDPSetColorImage((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gFramebufferWidth, OS_K0_TO_PHYSICAL(color_buffer)); + gDPSetCycleType((*gfx)++, G_CYC_1CYCLE); + gDPSetTextureConvert((*gfx)++, G_TC_FILT); + gDPSetTextureDetail((*gfx)++, G_TD_CLAMP); + if (sUseTexturePointFilter) { + gDPSetTextureFilter((*gfx)++, G_TF_POINT); + }else{ + gDPSetTextureFilter((*gfx)++, G_TF_BILERP); + } + gDPSetTextureLOD((*gfx)++, G_TL_TILE); + gDPSetTextureLUT((*gfx)++, G_TT_NONE); + gDPSetTexturePersp((*gfx)++, G_TP_PERSP); + depthbuffer_set(gfx); +} + +void setupFramebufferForGamemode(Gfx **gfx, s32 framebuffer_idx) { + if ((getGameMode() == GAME_MODE_8_BOTTLES_BONUS) || (getGameMode() == GAME_MODE_A_SNS_PICTURE)) { + picturebox_setScissorBox(); + setupFramebuffer(gfx, picturebox_getColorBuffer()); + } else { + scissorBox_setDefault(); + setupFramebuffer(gfx, gFramebuffers[framebuffer_idx]); + } +} + +void setupScissorBoxAndFramebuffer(Gfx **gfx, void *color_buffer) { + gSPSegment((*gfx)++, 0x00, 0x00000000); + gDPSetColorImage((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gFramebufferWidth, OS_PHYSICAL_TO_K0(color_buffer)); gSPClearGeometryMode((*gfx)++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH); gSPTexture((*gfx)++, 0, 0, 0, G_TX_RENDERTILE, G_OFF); gSPSetGeometryMode((*gfx)++, G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH); @@ -184,13 +182,13 @@ void core1_15B30_init(void) { scissorBox_setDefault(); } -void drawRectangle2D(Gfx **gfx, s32 x, s32 y, s32 w, s32 h, s32 r, s32 g, s32 b){ +void drawRectangle2D(Gfx **gfx, s32 x, s32 y, s32 w, s32 h, s32 r, s32 g, s32 b) { gDPPipeSync((*gfx)++); gDPPipelineMode((*gfx)++, G_PM_NPRIMITIVE); gDPSetCycleType((*gfx)++, G_CYC_FILL); gDPSetFillColor((*gfx)++, GPACK_RGBA5551(r, g, b, 1) << 16 | GPACK_RGBA5551(r, g, b, 1)); gDPSetRenderMode((*gfx)++, G_RM_NOOP, G_RM_NOOP2); - gDPScisFillRectangle((*gfx)++, x, y, x + w -1, y + h -1); + gDPScisFillRectangle((*gfx)++, x, y, x + w - 1, y + h - 1); } void graphicsCache_release(void) { @@ -205,8 +203,8 @@ void graphicsCache_release(void) { } } -void graphicsCache_init(void){ - if(sGfxStack[0] == NULL){ +void graphicsCache_init(void) { + if (sGfxStack[0] == NULL) { sGfxStack[0] = (Gfx *)malloc(29600); // 3700 dlist commands sGfxStack[1] = (Gfx *)malloc(29600); sMtxStack[0] = (Mtx *)malloc(44800); // 700 matrices @@ -215,8 +213,10 @@ void graphicsCache_init(void){ sVtxStack[1] = (Vtx *)malloc(6880); dummy_func_80254464(); } + + sStackSelector = 0; - gTextureFilterPoint = 0; + sUseTexturePointFilter = FALSE; } void scissorBox_set(s32 left, s32 top, s32 right, s32 bottom) { @@ -231,7 +231,7 @@ void scissorBox_set(s32 left, s32 top, s32 right, s32 bottom) { void scissorBox_setDefault(void){ - scissorBox_set(0, 292, 0, 216); + scissorBox_set(0, DEFAULT_FRAMEBUFFER_WIDTH, 0, DEFAULT_FRAMEBUFFER_HEIGHT); } void core1_15B30_addTask7TaskData(s32 framebuffer_id) { @@ -248,12 +248,11 @@ void core1_15B30_addTask7TaskData(s32 framebuffer_id) { thread5_sendTaskToQueue((OSMesg) task_data); } -void toggleTextureFilterPoint(void){ - u32 ret_val = gTextureFilterPoint; - gTextureFilterPoint = ret_val < 1; +void core1_15B30_toggleTexturePointFilter(void) { + sUseTexturePointFilter = !sUseTexturePointFilter; } -void getGraphicsStacks(Gfx **gfx, Mtx **mtx, Vtx **vtx){ +void graphicscache_swapAndGetStacks(Gfx **gfx, Mtx **mtx, Vtx **vtx) { sStackSelector = (1 - sStackSelector); *gfx = sGfxStack[sStackSelector]; *mtx = sMtxStack[sStackSelector]; diff --git a/src/core1/depthbuffer.c b/src/core1/depthbuffer.c index f2dba0ab..cdae5c80 100644 --- a/src/core1/depthbuffer.c +++ b/src/core1/depthbuffer.c @@ -4,67 +4,69 @@ #include "variables.h" struct { - void *data; - int unk4; + u16 *data; + bool unk4; } sDepthBuffer; -void func_80253190(Gfx **gfx) { - func_80253208(gfx, 0, 0, gFramebufferWidth, gFramebufferHeight, gFramebuffers[getActiveFramebuffer()]); +void depthbuffer_clear(Gfx **gfx) { + depthbuffer_clearRegion(gfx, 0, 0, gFramebufferWidth, gFramebufferHeight, gFramebuffers[getActiveFramebuffer()]); } -void func_80253208(Gfx **gfx, s32 x, s32 y, s32 w, s32 h, void *color_buffer){ - if( sDepthBuffer.data != NULL && (getGameMode() != GAME_MODE_4_PAUSED || gsworld_getEnableDraw())){ - //draw z_buffer +void depthbuffer_clearRegion(Gfx **gfx, s32 x, s32 y, s32 w, s32 h, void *color_buffer) { + if ((sDepthBuffer.data != NULL) && ((getGameMode() != GAME_MODE_4_PAUSED) || gsworld_getEnableDraw())) { gDPPipeSync((*gfx)++); gDPSetColorImage((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gFramebufferWidth, OS_K0_TO_PHYSICAL(sDepthBuffer.data)); gDPSetCycleType((*gfx)++, G_CYC_FILL); gDPSetRenderMode((*gfx)++, G_RM_NOOP, G_RM_NOOP2); - gDPSetFillColor((*gfx)++, 0xFFFCFFFC); + gDPSetFillColor((*gfx)++, (GPACK_ZDZ(G_MAXFBZ, 0) << 16) | GPACK_ZDZ(G_MAXFBZ, 0)); gDPScisFillRectangle((*gfx)++, x, y, x + w - 1, y + h - 1); - - //draw color_buffer + gDPPipeSync((*gfx)++); gDPSetColorImage((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gFramebufferWidth, OS_K0_TO_PHYSICAL(color_buffer)); } } -int func_80253400(void){ +bool depthbuffer_getUnk4(void) { return sDepthBuffer.unk4; } -bool depthBuffer_isPointerSet(void) { +bool depthbuffer_isDataPtrSet(void) { return sDepthBuffer.data != NULL; } -void depthBuffer_stub(void) {} +void depthbuffer_stub(void) {} -void func_80253428(int arg0) { +void depthbuffer_enable(bool enable) { u16 *var_v0; - int new_var; - if (arg0) { - var_v0 = (sDepthBuffer.data = &D_8000E800); - while (((s32) sDepthBuffer.data) % 0x40) { - var_v0 = (sDepthBuffer.data = var_v0 + 1); + + if (enable) { + sDepthBuffer.data = (u16 *) D_8000E800; + + var_v0 = sDepthBuffer.data; + while (((s32) sDepthBuffer.data) % 64) { + sDepthBuffer.data = var_v0 + 1; + var_v0 = sDepthBuffer.data; } - do { } while ((&D_8000E800 && 1) * 0); //remove this - }else{ + do { } while ((D_8000E800 && 1) * 0); //remove this + } else { sDepthBuffer.data = NULL; } + sDepthBuffer.unk4 = FALSE; } -void func_802534A8(int arg0) { - sDepthBuffer.unk4 = (sDepthBuffer.data != NULL && arg0); +void depthbuffer_setUnk4(bool value) { + sDepthBuffer.unk4 = sDepthBuffer.data && value; } -void zBuffer_set(Gfx **gfx) { +void depthbuffer_set(Gfx **gfx) { if (sDepthBuffer.data && getGameMode() != GAME_MODE_4_PAUSED) { gDPPipeSync((*gfx)++); gDPSetDepthImage((*gfx)++, sDepthBuffer.data); } } -void *zBuffer_get(void) { +void *depthbuffer_getDataPtr(void) { return sDepthBuffer.data; } diff --git a/src/core1/ml.c b/src/core1/ml.c index 454d32ff..be58719f 100644 --- a/src/core1/ml.c +++ b/src/core1/ml.c @@ -231,16 +231,14 @@ void ml_vec3f_set_length_copy(f32 dst[3], f32 src[3], f32 len) ml_vec3f_copy(dst, src); } -void func_80256664(f32 ptr[3]) -{ - u32 i; +void ml_vec3f_clamp_deg360(f32 ptr[3]) { + int i; - for (i = 0; i < 3; i++) - { + for (i = 0; i < 3; i++) { if (ptr[i] >= 0) - ptr[i] = (s32)ptr[i] % 360; + ptr[i] = (s32) ptr[i] % 360; else - ptr[i] += ((360 - (s32)ptr[i]) / 360) * 360; + ptr[i] += ((360 - (s32) ptr[i]) / 360) * 360; } } diff --git a/src/core1/viewport.c b/src/core1/viewport.c index 1e1bfbaf..054d7b87 100644 --- a/src/core1/viewport.c +++ b/src/core1/viewport.c @@ -93,10 +93,12 @@ void viewport_setRenderPerspectiveMatrix(Gfx **gfx, Mtx **mtx, f32 near, f32 far near = MAX(sViewportNear, near); far = MIN(sViewportFar, far); - if(*(u32*)OS_PHYSICAL_TO_K1(0x1D8) + 0x53D4FFF0) { // what's this? +#if ANTI_TAMPER + if ((*(u32*) OS_PHYSICAL_TO_K1(0x000001D8)) + 0x53D4FFF0) { near = 750.0f; far = 1250.0f; } +#endif guPerspective(*mtx, &perspNorm, sViewportFOVy, sViewportAspect, near, far, 0.5f); gSPPerspNormalize((*gfx)++, perspNorm); diff --git a/src/core2/ch/bottlesbonus.c b/src/core2/ch/bottlesbonus.c index 6f6a559a..8d2476cf 100644 --- a/src/core2/ch/bottlesbonus.c +++ b/src/core2/ch/bottlesbonus.c @@ -50,7 +50,7 @@ typedef struct{ extern void item_set(enum item_e, s32); extern void actor_postdrawMethod(ActorMarker *); extern void viewport_setNearAndFar(f32, f32); -extern s16 *func_8030C704(void); +extern s16 *picturebox_getColorBuffer(void); Actor *chBottlesBonus_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx); void chBottlesBonus_update(Actor *this); @@ -157,7 +157,7 @@ Actor *chBottlesBonus_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx) void *sp50; sp6C = marker_getActor(marker); - sp50 = func_8030C704(); //grabs frame as texture? + sp50 = picturebox_getColorBuffer(); //grabs frame as texture? if ((sp50 == NULL) || (getGameMode() != GAME_MODE_8_BOTTLES_BONUS)) return sp6C; @@ -171,7 +171,7 @@ Actor *chBottlesBonus_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx) gDPSetTextureFilter((*gfx)++, G_TF_POINT); gDPSetColorDither((*gfx)++, G_CD_DISABLE); func_802DF160(gfx, mtx, vtx); - func_80253190(gfx); + depthbuffer_clear(gfx); gDPSetTextureFilter((*gfx)++, G_TF_POINT); gSPSegment((*gfx)++, 0x04, osVirtualToPhysical(sp50)); diff --git a/src/core2/ch/bottlesbonuscursor.c b/src/core2/ch/bottlesbonuscursor.c index 4c2615b2..9ea57d1f 100644 --- a/src/core2/ch/bottlesbonuscursor.c +++ b/src/core2/ch/bottlesbonuscursor.c @@ -153,7 +153,7 @@ void chBottlesBonusCursor_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) { actor_setOpacity(this, 0xB9); viewport_func_8024E030(this->position, D_8037E5C0.unk18); sp3C = (this->scale * 650.0f); - func_80253208(gfx, + depthbuffer_clearRegion(gfx, (s32)(D_8037E5C0.unk18[0] - sp3C/2), (s32)(D_8037E5C0.unk18[1] - sp3C/2), (s32)sp3C, (s32)sp3C, gFramebuffers[getActiveFramebuffer()] diff --git a/src/core2/ch/mumboshandwithpicture.c b/src/core2/ch/mumboshandwithpicture.c index db15453e..b25dd03d 100644 --- a/src/core2/ch/mumboshandwithpicture.c +++ b/src/core2/ch/mumboshandwithpicture.c @@ -43,7 +43,7 @@ Actor *chMumbosHandWithPicture_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, V this = marker_getActor(marker); - sp48 = func_8030C704(); + sp48 = picturebox_getColorBuffer(); if ((sp48 == 0) || (getGameMode() != GAME_MODE_A_SNS_PICTURE)) return this; @@ -63,7 +63,7 @@ Actor *chMumbosHandWithPicture_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, V modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); modelRender_draw(gfx, mtx, sp58, NULL, 1.0f, sp4C, D_8037DFE8); gDPSetColorDither((*gfx)++, G_CD_DISABLE); - func_80253190(gfx); + depthbuffer_clear(gfx); gSPSegment((*gfx)++, 0x04, osVirtualToPhysical(sp48)); modelRender_setPreDrawCallback((GenFunction_1)actor_predrawMethod, (s32)this); modelRender_setPostDrawCallback((GenFunction_1)actor_postdrawMethod, (s32)marker); diff --git a/src/core2/code_34790.c b/src/core2/code_34790.c index e2b9b26d..b727e29d 100644 --- a/src/core2/code_34790.c +++ b/src/core2/code_34790.c @@ -180,9 +180,9 @@ void func_802BBD0C(Gfx **gdl, Mtx **mptr, Vtx **vptr){ func_802BEE2C(gdl, mptr, vptr); } -void func_802BBD2C(f32 *arg0, f32 *arg1){ - *arg0 = D_8037D8C8; - *arg1 = D_8037D8CC; +void core2_34790_getClipDistances(f32 *near, f32 *far) { + *near = D_8037D8C8; + *far = D_8037D8CC; } f32 func_802BBD48(void) { diff --git a/src/core2/code_581D0.c b/src/core2/code_581D0.c index 5c0fc499..2922c0bc 100644 --- a/src/core2/code_581D0.c +++ b/src/core2/code_581D0.c @@ -30,7 +30,7 @@ Actor *func_802DF160(Gfx **gfx, Mtx **mtx, Vtx **vtx) { void *sp38; this = marker_getActor(D_8037E000); - sp38 = func_8030C704(); + sp38 = picturebox_getColorBuffer(); modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); gDPSetTextureFilter((*gfx)++, G_TF_POINT); gSPSegment((*gfx)++, 0x04, osVirtualToPhysical(sp38)); diff --git a/src/core2/code_5C240.c b/src/core2/code_5C240.c index ef17ccf0..61b4a479 100644 --- a/src/core2/code_5C240.c +++ b/src/core2/code_5C240.c @@ -44,11 +44,11 @@ void func_802E329C(s32 arg0, Gfx **gfx_begin, Gfx **gfx_end) { Vtx *vtx; Vtx *vtx_start; - getGraphicsStacks(&gfx, &mtx, &vtx); + graphicscache_swapAndGetStacks(&gfx, &mtx, &vtx); gfx_start = gfx; mtx_start = mtx; vtx_start = vtx; - scissorBox_SetForGameMode(&gfx, arg0); + setupFramebufferForGamemode(&gfx, arg0); if (D_8037E8C0.unk14 == 2) { drawRectangle2D(&gfx, 0, 0, (s32) (f32) gFramebufferWidth, (s32) (f32) gFramebufferHeight, 0, 0, 0); } @@ -104,7 +104,7 @@ void func_802E3580(void) { func_802F1884(D_8037E8C0.unk10); func_802E5F68(); coMusicPlayer_free(); - depthBuffer_stub(); + depthbuffer_stub(); viMgr_func_8024BF94(2); } diff --git a/src/core2/code_5C870.c b/src/core2/code_5C870.c index 6acff0c3..7c14d0d3 100644 --- a/src/core2/code_5C870.c +++ b/src/core2/code_5C870.c @@ -12,7 +12,7 @@ extern void timedFuncQueue_update(void); extern void func_8025A2B0(void); extern void func_8025A430(s32, s32, s32); extern void func_8034BB90(void); -extern void func_8030C27C(void); +extern void picturebox_spawn(void); extern void func_80321C34(void); extern void func_8030ED0C(void); extern void coMusicPlayer_update(void); @@ -110,57 +110,54 @@ void func_802E398C(s32 arg0) { } } -void func_802E39D0(Gfx **gdl, Mtx **mptr, Vtx **vptr, s32 framebuffer_idx, s32 arg4){ - Mtx* m_start = *mptr; - Vtx* v_start = *vptr; +void func_802E39D0(Gfx **gfx, Mtx **mtx, Vtx **vtx, s32 framebuffer_idx, bool arg4) { + Mtx* mtx_start = *mtx; + Vtx* vtx_start = *vtx; - scissorBox_SetForGameMode(gdl, framebuffer_idx); + setupFramebufferForGamemode(gfx, framebuffer_idx); D_8037E8E0.unkC = FALSE; - gsworld_draw(gdl, mptr, vptr); - if(!arg4){ + gsworld_draw(gfx, mtx, vtx); + + if (!arg4) { // related to framebufferdraw_ functions func_802E67AC(); func_802E3BD0(getActiveFramebuffer()); func_802E67C4(); - func_802E5F10(gdl); + func_802E5F10(gfx); } - if( D_8037E8E0.game_mode == GAME_MODE_A_SNS_PICTURE - && D_8037E8E0.unk19 != 6 - && D_8037E8E0.unk19 != 5 - ){ - gctransition_draw(gdl, mptr, vptr); + + if ((D_8037E8E0.game_mode == GAME_MODE_A_SNS_PICTURE) && (D_8037E8E0.unk19 != 6) && (D_8037E8E0.unk19 != 5)) { + gctransition_draw(gfx, mtx, vtx); } - if( D_8037E8E0.game_mode == GAME_MODE_8_BOTTLES_BONUS - || D_8037E8E0.game_mode == GAME_MODE_A_SNS_PICTURE - ){ - func_8030C2D4(gdl, mptr, vptr); + if ((D_8037E8E0.game_mode == GAME_MODE_8_BOTTLES_BONUS) || (D_8037E8E0.game_mode == GAME_MODE_A_SNS_PICTURE)) { + picturebox_resetScissorBoxAndFramebuffer(gfx, mtx, vtx); } - if(!game_is_frozen() && gsworld_getEnableDraw()){ - func_8032D474(gdl, mptr, vptr); + if (!game_is_frozen() && gsworld_getEnableDraw()) { + core2_A5BC0_drawScreenOverlayMarkers(gfx, mtx, vtx); } - gcpausemenu_draw(gdl, mptr, vptr); - if(!game_is_frozen()){ - dummy_func_8025AFC0(gdl, mptr, vptr); + gcpausemenu_draw(gfx, mtx, vtx); + + if (!game_is_frozen()) { + dummy_func_8025AFC0(gfx, mtx, vtx); } - gcdialog_draw(gdl, mptr, vptr); - if(!game_is_frozen()){ - itemPrint_draw(gdl, mptr, vptr); + gcdialog_draw(gfx, mtx, vtx); + + if (!game_is_frozen()) { + itemPrint_draw(gfx, mtx, vtx); } - printbuffer_draw(gdl, mptr, vptr); + printbuffer_draw(gfx, mtx, vtx); - if( D_8037E8E0.game_mode != GAME_MODE_A_SNS_PICTURE - || D_8037E8E0.unk19 == 6 - || D_8037E8E0.unk19 == 5 - ){ - gctransition_draw(gdl, mptr, vptr); + if ((D_8037E8E0.game_mode != GAME_MODE_A_SNS_PICTURE) || (D_8037E8E0.unk19 == 6) || (D_8037E8E0.unk19 == 5)) { + gctransition_draw(gfx, mtx, vtx); } - core1_15B30_finishDList(gdl); - osWritebackDCache(m_start, sizeof(Mtx)*( *mptr - m_start)); - osWritebackDCache(v_start, sizeof(Vtx)*( *vptr - v_start)); + + core1_15B30_finishDList(gfx); + osWritebackDCache(mtx_start, sizeof(Mtx) * (*mtx - mtx_start)); + osWritebackDCache(vtx_start, sizeof(Vtx) * (*vtx - vtx_start)); } void func_802E3BD0(s32 frame_buffer_indx){ @@ -191,10 +188,10 @@ void game_setMode(enum game_mode_e next_mode, s32 arg1){ //L802E3C84 if(next_mode == GAME_MODE_8_BOTTLES_BONUS || next_mode == GAME_MODE_A_SNS_PICTURE){ - func_8030C1A0(); + picturebox_init(); } else{ - func_8030C204(); + picturebox_free(); }//L802E3CB4 D_8037E8E0.game_mode = next_mode; @@ -277,32 +274,30 @@ s32 func_802E3F80(void){ return D_8037E8E0.unk0; } -void game_draw(s32 arg0){ - Gfx *gfx; - Gfx *gfx_start; - Gfx *sp2C; +void game_draw(bool arg0) { + Gfx *gfx, *gfx_start, *gfx_end; Mtx *mtx; Vtx *vtx; - if(arg0) { + if (arg0) { scissorBox_setDefault(); } - getGraphicsStacks(&gfx, &mtx, &vtx); + graphicscache_swapAndGetStacks(&gfx, &mtx, &vtx); - if(D_8037E8E0.unkC == 1){ - getGraphicsStacks(&gfx, &mtx, &vtx); + if (D_8037E8E0.unkC == TRUE) { // BUG: Compares explicit for integral value of TRUE, instead for true-ness + graphicscache_swapAndGetStacks(&gfx, &mtx, &vtx); } gfx_start = gfx; func_802E39D0(&gfx, &mtx, &vtx, getActiveFramebuffer(), arg0); - if(D_8037E8E0.unkC == 0){ - sp2C = gfx; + if (!D_8037E8E0.unkC) { + gfx_end = gfx; viMgr_func_8024C1DC(); - core1_15B30_addF3DEXTaskData_40000000(gfx_start, sp2C); + core1_15B30_addF3DEXTaskData_40000000(gfx_start, gfx_end); - if(arg0) { + if (arg0) { scissorBox_setDefault(); } } @@ -363,7 +358,7 @@ void func_802E4170(void){ timedFuncQueue_free(); func_802F9C48(); modelRender_free(); - depthBuffer_stub(); + depthbuffer_stub(); func_802E398C(0); func_8030AFD8(0); func_80321854(); @@ -378,7 +373,7 @@ void func_802E4214(enum map_e map_id){ D_8037E8E0.unk19 = D_8037E8E0.unk18 = 0; D_8037E8E0.map = D_8037E8E0.exit = D_8037E8E0.unk17 = 0; D_8037E8E0.unk1B = D_8037E8E0.unk1A = 0; - D_8037E8E0.unkC = 0; + D_8037E8E0.unkC = FALSE; D_8037E8E0.unk1C = 0; savedata_init(); sns_save_and_update_global_data(); @@ -393,7 +388,7 @@ void func_802E4214(enum map_e map_id){ func_802E5F38(); defragManager_init(); modelRender_init(); - func_80253428(1); + depthbuffer_enable(TRUE); animCache_init(); viewport_reset(); viewport_setNearAndFar(1.0f, 10000.0f); @@ -520,7 +515,7 @@ bool func_802E4424(void) { switch (D_8037E8E0.game_mode) { case GAME_MODE_8_BOTTLES_BONUS: case GAME_MODE_A_SNS_PICTURE: - func_8030C27C(); + picturebox_spawn(); /* fallthrough */ case GAME_MODE_7_ATTRACT_DEMO: case GAME_MODE_9_BANJO_AND_KAZOOIE: diff --git a/src/core2/code_5DBC0.c b/src/core2/code_5DBC0.c index 66999553..8c4fd8ca 100644 --- a/src/core2/code_5DBC0.c +++ b/src/core2/code_5DBC0.c @@ -308,33 +308,33 @@ void func_802E57E0(struct5DBC0_1s *arg0, Gfx **gfx) { } } -void func_802E5C98(Gfx **gdl){ +void func_802E5C98(Gfx **gfx) { int i; - gDPPipeSync((*gdl)++); - gSPClearGeometryMode((*gdl)++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH); - gSPTexture((*gdl)++, 0, 0, 0, G_TX_RENDERTILE, G_OFF); - gSPSetGeometryMode((*gdl)++, G_TEXTURE_GEN_LINEAR); - gDPSetCycleType((*gdl)++, G_CYC_1CYCLE); - gDPPipelineMode((*gdl)++, G_PM_NPRIMITIVE); - gDPSetTextureLOD((*gdl)++, G_TL_TILE); - gDPSetTextureLUT((*gdl)++, G_TT_NONE); - gDPSetTextureDetail((*gdl)++, G_TD_CLAMP); - gDPSetTexturePersp((*gdl)++, G_TP_NONE); - gDPSetTextureFilter((*gdl)++, G_TF_BILERP); - gDPSetTextureConvert((*gdl)++, G_TC_FILT); - gDPSetAlphaCompare((*gdl)++, G_AC_NONE); - gDPSetRenderMode((*gdl)++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPPipeSync((*gfx)++); + gSPClearGeometryMode((*gfx)++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH); + gSPTexture((*gfx)++, 0, 0, 0, G_TX_RENDERTILE, G_OFF); + gSPSetGeometryMode((*gfx)++, G_TEXTURE_GEN_LINEAR); + gDPSetCycleType((*gfx)++, G_CYC_1CYCLE); + gDPPipelineMode((*gfx)++, G_PM_NPRIMITIVE); + gDPSetTextureLOD((*gfx)++, G_TL_TILE); + gDPSetTextureLUT((*gfx)++, G_TT_NONE); + gDPSetTextureDetail((*gfx)++, G_TD_CLAMP); + gDPSetTexturePersp((*gfx)++, G_TP_NONE); + gDPSetTextureFilter((*gfx)++, G_TF_BILERP); + gDPSetTextureConvert((*gfx)++, G_TC_FILT); + gDPSetAlphaCompare((*gfx)++, G_AC_NONE); + gDPSetRenderMode((*gfx)++, G_RM_XLU_SURF, G_RM_XLU_SURF2); for(i = 0; i < D_8037E900->unkC; i++){ D_8037E900->unk0[i].unk4 -= 0x10; - func_802E57E0(D_8037E900->unk0 + i, gdl); + func_802E57E0(D_8037E900->unk0 + i, gfx); D_8037E900->unk0[i].unk4 += 0x10; } - gDPSetTexturePersp((*gdl)++, G_TP_PERSP); + gDPSetTexturePersp((*gfx)++, G_TP_PERSP); } -void func_802E5F10(Gfx **gdl){ - func_802E5C98(gdl); +void func_802E5F10(Gfx **gfx) { + func_802E5C98(gfx); func_802E5188(); } diff --git a/src/core2/code_73640.c b/src/core2/code_73640.c index 83b8b1e2..543bf47c 100644 --- a/src/core2/code_73640.c +++ b/src/core2/code_73640.c @@ -182,13 +182,13 @@ void itemPrint_update(void) { } -void itemPrint_draw(Gfx **gdl, Mtx ** mptr, Vtx **vptr){ +void itemPrint_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) { s32 i; if(D_803810B0 && level_get() != LEVEL_D_CUTSCENE){ for(i = 0; i < 0x2C; i++){ if(!func_802E4A08() || i < 6){ if(func_802FB0D4(D_803692F8[i].unk14)){ - D_803692F8[i].unk8(i, D_803692F8[i].unk14, gdl, mptr, vptr); + D_803692F8[i].unk8(i, D_803692F8[i].unk14, gfx, mtx, vtx); } } } diff --git a/src/core2/code_851D0.c b/src/core2/code_851D0.c index 5a59723f..673d1ce2 100644 --- a/src/core2/code_851D0.c +++ b/src/core2/code_851D0.c @@ -3,7 +3,6 @@ #include "functions.h" #include "variables.h" - #define TILE_SIZE 32 #define TILE_COUNT_X 5 #define TILE_COUNT_Y 4 @@ -14,8 +13,7 @@ #define HORIZONTAL_MARGIN (((SCREEN_WIDTH) - IMAGE_WIDTH) / 2) #define VERTICAL_MARGIN (((SCREEN_HEIGHT) - IMAGE_HEIGHT) / 2) -/* .data */ -Gfx D_8036C450[] = { +Gfx sPictureBoxInitDL[] = { gsDPPipeSync(), gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH), gsSPSetGeometryMode(G_SHADE | G_TEXTURE_GEN_LINEAR | G_SHADING_SMOOTH), @@ -25,85 +23,85 @@ Gfx D_8036C450[] = { gsDPSetCombineLERP(TEXEL0, 0, PRIMITIVE_ALPHA, 0, 0, 0, 0, TEXEL0, TEXEL0, 0, PRIMITIVE_ALPHA, 0, 0, 0, 0, TEXEL0), gsDPSetTextureFilter(G_TF_POINT), gsDPSetTexturePersp(G_TP_NONE), - gsDPSetPrimColor(0, 0, 0x00, 0x00, 0x00, 0x78), + gsDPSetPrimColor(0, 0, 0, 0, 0, 120), gsSPEndDisplayList() }; -Gfx D_8036C4A8[] = { +Gfx sPictureBoxFinishDL[] = { gsDPPipeSync(), gsDPSetTextureFilter(G_TF_BILERP), gsDPSetTexturePersp(G_TP_PERSP), gsSPEndDisplayList() }; -/* .bss */ -s16 *D_80382450; -void *D_80382454; +s16 *sPictureBoxColorBuffer; +void *sPictureBoxColorBufferBase; - -/* .code */ -void func_8030C160(void){ +void picturebox_func_8030C160(void) { func_8024F150(); } -void func_8030C180(void){ +void picturebox_func_8030C180(void) { func_8024F180(); } -void func_8030C1A0(void){ - if(D_80382454 == NULL){ - D_80382454 = D_80382450 = malloc(IMAGE_WIDTH * IMAGE_HEIGHT * sizeof(u16) + 64); +void picturebox_init(void) { + if (sPictureBoxColorBufferBase == NULL) { + sPictureBoxColorBuffer = malloc(IMAGE_WIDTH * IMAGE_HEIGHT * sizeof(u16) + 64); + sPictureBoxColorBufferBase = sPictureBoxColorBuffer; - while((s32)D_80382450 & 0x3F){ - D_80382450++; + // Make sure that the color buffer is aligned on a 64-byte boundary + while ((s32)sPictureBoxColorBuffer & 0x3F) { + sPictureBoxColorBuffer++; } } } -void func_8030C204(void){ - if(D_80382454){ - free(D_80382454); - D_80382454 = NULL; +void picturebox_free(void) { + if (sPictureBoxColorBufferBase) { + free(sPictureBoxColorBufferBase); + sPictureBoxColorBufferBase = NULL; } - switch(getGameMode()){ + switch (getGameMode()) { case GAME_MODE_8_BOTTLES_BONUS: chBottlesBonus_func_802DEA8C(0, 0); break; + case GAME_MODE_A_SNS_PICTURE: func_802DF11C(0, 0); break; } } -void func_8030C27C(void){ - switch(getGameMode()){ +void picturebox_spawn(void) { + switch (getGameMode()) { case GAME_MODE_8_BOTTLES_BONUS: chBottlesBonus_spawn(0, 0); break; + case GAME_MODE_A_SNS_PICTURE: func_802DF090(0, 0); break; - } } -void func_8030C2D4(Gfx **gdl, Mtx **mptr, Vtx **vptr){ +void picturebox_resetScissorBoxAndFramebuffer(Gfx **gfx, Mtx **mtx, Vtx **vtx) { scissorBox_setDefault(); - func_80253640(gdl, gFramebuffers[getActiveFramebuffer()]); + setupFramebuffer(gfx, gFramebuffers[getActiveFramebuffer()]); } -// Draws a 160x128 image pointed to by D_80382450 into the center of the screen -void func_8030C33C(Gfx **gfx, Mtx **mtx, Vtx **vtx) { +// Draws a 160x128 image pointed to by sPictureBoxColorBuffer into the center of the screen +void picturebox_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) { s32 x, y; // Set up the rendering state to draw the image - gSPDisplayList((*gfx)++, D_8036C450); + gSPDisplayList((*gfx)++, sPictureBoxInitDL); // Iterate over every tile in the image for (y = 0; y < TILE_COUNT_Y; y++) { for(x = 0; x < TILE_COUNT_X; x++){ // Load the current tile from the image - gDPLoadTextureTile((*gfx)++, osVirtualToPhysical(D_80382450), G_IM_FMT_IA, G_IM_SIZ_16b, IMAGE_WIDTH, IMAGE_HEIGHT, + gDPLoadTextureTile((*gfx)++, osVirtualToPhysical(sPictureBoxColorBuffer), G_IM_FMT_IA, G_IM_SIZ_16b, IMAGE_WIDTH, IMAGE_HEIGHT, TILE_SIZE * x, TILE_SIZE * y, TILE_SIZE * (x + 1) - 1, TILE_SIZE * (y + 1) - 1, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, @@ -119,14 +117,14 @@ void func_8030C33C(Gfx **gfx, Mtx **mtx, Vtx **vtx) { } } // Reset the rendering state - gSPDisplayList((*gfx)++, D_8036C4A8); + gSPDisplayList((*gfx)++, sPictureBoxFinishDL); } -s16 *func_8030C704(void){ - return D_80382450; +s16 *picturebox_getColorBuffer(void) { + return sPictureBoxColorBuffer; } -void scissorBox_setSmall(void){ - scissorBox_set(0, 160, 0, 128); +void picturebox_setScissorBox(void) { + scissorBox_set(0, IMAGE_WIDTH, 0, IMAGE_HEIGHT); } diff --git a/src/core2/code_8DC20.c b/src/core2/code_8DC20.c index c37fddc2..0002b3f5 100644 --- a/src/core2/code_8DC20.c +++ b/src/core2/code_8DC20.c @@ -59,7 +59,7 @@ void func_80314BB0(Gfx **gfx, Mtx **mtx, Vtx **vtx, void * frame_buffer_1, void void func_80315084(Gfx **gfx, Mtx **mtx, Vtx **vtx){ gsworld_setEnableDraw(FALSE); D_803830A0 = 2; - func_80314BB0(gfx, mtx, vtx, zBuffer_get(), gFramebuffers[getActiveFramebuffer()]); + func_80314BB0(gfx, mtx, vtx, depthbuffer_getDataPtr(), gFramebuffers[getActiveFramebuffer()]); } void func_80315110(Gfx **gfx, Mtx **mtx, Vtx **vtx){ @@ -72,7 +72,7 @@ void func_80315110(Gfx **gfx, Mtx **mtx, Vtx **vtx){ else{ D_803830A0--; } - func_80314BB0(gfx, mtx, vtx, gFramebuffers[getActiveFramebuffer()], zBuffer_get()); + func_80314BB0(gfx, mtx, vtx, gFramebuffers[getActiveFramebuffer()], depthbuffer_getDataPtr()); } void func_803151D0(Gfx **gfx, Mtx **mtx, Vtx **vtx){ diff --git a/src/core2/code_A5BC0.c b/src/core2/code_A5BC0.c index 37f7d126..8c95f8dc 100644 --- a/src/core2/code_A5BC0.c +++ b/src/core2/code_A5BC0.c @@ -343,17 +343,19 @@ void func_8032D3A8(void){ vector_clear(D_80383554); } -void func_8032D3D8(Gfx **gdl, Mtx **mptr, Vtx **vptr){ +void core2_A5BC0_drawUnknownMarkers(Gfx **gfx, Mtx **mtx, Vtx **vtx) { // further investigation needed what's drawn here int i; - for(i = 0; i < vector_size(D_80383550); i++){ - __marker_draw(*(ActorMarker **) vector_at(D_80383550, i), gdl, mptr, vptr); + + for (i = 0; i < vector_size(D_80383550); i++) { + __marker_draw(*(ActorMarker **) vector_at(D_80383550, i), gfx, mtx, vtx); } } -void func_8032D474(Gfx **gdl, Mtx **mptr, Vtx **vptr){ +void core2_A5BC0_drawScreenOverlayMarkers(Gfx **gfx, Mtx **mtx, Vtx **vtx) { int i; - for(i = 0; i < vector_size(D_80383554); i++){ - __marker_draw(*(ActorMarker **) vector_at(D_80383554, i), gdl, mptr, vptr); + + for (i = 0; i < vector_size(D_80383554); i++) { + __marker_draw(*(ActorMarker **) vector_at(D_80383554, i), gfx, mtx, vtx); } } diff --git a/src/core2/fx/common3score.c b/src/core2/fx/common3score.c index 472c6a29..d6ac981d 100644 --- a/src/core2/fx/common3score.c +++ b/src/core2/fx/common3score.c @@ -5,7 +5,7 @@ -extern void func_80253208(Gfx **gdl, s32 x, s32 y, s32 w, s32 h, void *color_buffer); +extern void depthbuffer_clearRegion(Gfx **gdl, s32 x, s32 y, s32 w, s32 h, void *color_buffer); extern f32 func_802FB0E4(struct8s*); @@ -209,7 +209,7 @@ void fxcommon3score_draw(enum item_e item_id, void *arg1, Gfx **gfx, Mtx **mtx, if(a1->unk6C == 0.0f){ a1->unk6C = 1.1*(vtxList_getGlobalNorm(modelbin_getVtxList(a1->model)) * a1->unk3C); } - func_80253208(gfx, a1->unk30 - a1->unk6C, sp40 - a1->unk6C, 2*a1->unk6C, 2*a1->unk6C, gFramebuffers[getActiveFramebuffer()]); + depthbuffer_clearRegion(gfx, a1->unk30 - a1->unk6C, sp40 - a1->unk6C, 2*a1->unk6C, 2*a1->unk6C, gFramebuffers[getActiveFramebuffer()]); if(a1->anim_ctrl != NULL){ anctrl_drawSetup(a1->anim_ctrl, sp5C, 1); } diff --git a/src/core2/gc/sky.c b/src/core2/gc/sky.c index 5ed9e514..6b4fba2e 100644 --- a/src/core2/gc/sky.c +++ b/src/core2/gc/sky.c @@ -67,30 +67,30 @@ MapSkyInfo * sky_getMapSkyInfo(enum map_e map_id){ return v1; } -void sky_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx){ +void sky_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) { int i; f32 position[3]; f32 rotation[3]; - BKModelBin *iAsset; + BKModelBin *sky_model_bin; viewport_setNearAndFar(5.0f, 15000.0f); - if(gcSky.model_bins[0]){ - drawRectangle2D(gfx, 0, 0, (s32)(f32) gFramebufferWidth, (s32)(f32)gFramebufferHeight,0, 0, 0); //fill screen with black + + if (gcSky.model_bins[0]) { + drawRectangle2D(gfx, 0, 0, (f32) gFramebufferWidth, (f32) gFramebufferHeight, 0, 0, 0); viewport_setRenderViewportAndPerspectiveMatrix(gfx, mtx); viewport_getPosition_vec3f(position); - for(i = 0; i < 3; i++){ - iAsset = gcSky.model_bins[i]; - if(iAsset){ + for (i = 0; i < 3; i++) { + sky_model_bin = gcSky.model_bins[i]; + if (sky_model_bin) { rotation[0] = 0.0f; rotation[1] = gcSky.sky_info->sky_list[i].rotation_speed * gcSky.timer; rotation[2] = 0.0f; - modelRender_draw(gfx, mtx, position, rotation, gcSky.sky_info->sky_list[i].scale, NULL, iAsset); + modelRender_draw(gfx, mtx, position, rotation, gcSky.sky_info->sky_list[i].scale, NULL, sky_model_bin); } } + } else { + drawRectangle2D(gfx, 0, 0, (f32) gFramebufferWidth, (f32) gFramebufferHeight, 0, 0, 0); } - else{//L8030B200 - drawRectangle2D(gfx, 0, 0, (s32)(f32) gFramebufferWidth, (s32)(f32)gFramebufferHeight, 0, 0, 0); - }//L8030B254 } void sky_free(void){ diff --git a/src/core2/gc/transition.c b/src/core2/gc/transition.c index 86a25b9b..18845b1d 100644 --- a/src/core2/gc/transition.c +++ b/src/core2/gc/transition.c @@ -238,7 +238,7 @@ void gctransition_defrag(void){ s_current_transition.model_ptr = defrag_asset(s_current_transition.model_ptr); } -void gctransition_draw(Gfx **gdl, Mtx **mptr, Vtx **vptr){ +void gctransition_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) { f32 vp_position[3]; f32 vp_rotation[3]; f32 percentage; @@ -267,25 +267,25 @@ void gctransition_draw(Gfx **gdl, Mtx **mptr, Vtx **vptr){ viewport_setPosition_vec3f(vp_position); //viewport_getPosition_vec3f viewport_setRotation_vec3f(vp_rotation); //viewport_getRotation_vec3f viewport_update(); //camera_updateNormal - viewport_setRenderViewportAndPerspectiveMatrix(gdl, mptr); + viewport_setRenderViewportAndPerspectiveMatrix(gfx, mtx); sp58[0] = 0.0f; sp58[1] = 0.0f; sp58[2] = 0.0f; if(s_current_transition.anctrl != NULL){ - gDPSetTextureFilter((*gdl)++, G_TF_POINT); - gDPSetColorDither((*gdl)++, G_CD_DISABLE); + gDPSetTextureFilter((*gfx)++, G_TF_POINT); + gDPSetColorDither((*gfx)++, G_CD_DISABLE); anctrl_drawSetup(s_current_transition.anctrl, sp58, 1); modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); } //complex animation (from animation bin file) if(s_current_transition.state == 1 || s_current_transition.state == 6){ - modelRender_draw(gdl, mptr, sp58, vp_rotation, 1.0f, 0, s_current_transition.model_ptr); + modelRender_draw(gfx, mtx, sp58, vp_rotation, 1.0f, 0, s_current_transition.model_ptr); if(s_current_transition.anctrl != NULL){ - gDPSetTextureFilter((*gdl)++, G_TF_BILERP); - gDPSetColorDither((*gdl)++, G_CD_MAGICSQ); + gDPSetTextureFilter((*gfx)++, G_TF_BILERP); + gDPSetColorDither((*gfx)++, G_CD_MAGICSQ); } return; } @@ -302,7 +302,7 @@ void gctransition_draw(Gfx **gdl, Mtx **mptr, Vtx **vptr){ vp_rotation[2] = s_current_transition.rotation - 90.0f*percentage; scale = percentage*s_current_transition.transistion_info->scale + 0.1; } - modelRender_draw(gdl, mptr, sp58, vp_rotation, scale, 0, s_current_transition.model_ptr); + modelRender_draw(gfx, mtx, sp58, vp_rotation, scale, 0, s_current_transition.model_ptr); } else if(s_current_transition.state == TRANSITION_STATE_5_FADE_OUT){//L8030B9EC switch (s_current_transition.transistion_info->uid) @@ -323,7 +323,7 @@ void gctransition_draw(Gfx **gdl, Mtx **mptr, Vtx **vptr){ break; } if(!(s_current_transition.substate < 3) || s_current_transition.transistion_info->uid != 0x11){ - modelRender_draw(gdl, mptr, sp58, vp_rotation, scale, 0, s_current_transition.model_ptr); + modelRender_draw(gfx, mtx, sp58, vp_rotation, scale, 0, s_current_transition.model_ptr); } else{ modelRender_reset(); @@ -335,14 +335,14 @@ void gctransition_draw(Gfx **gdl, Mtx **mptr, Vtx **vptr){ gcbound_reset(); gcbound_alpha((1.0f - percentage)*255.0f + 0.5); gcbound_color(0,0,0); - gcbound_draw(gdl); + gcbound_draw(gfx); } else if(s_current_transition.state == TRANSITION_STATE_3_BLACK_OUT){//L8030BB6C //fade out black (i.e. get more black) gcbound_reset(); gcbound_alpha(percentage*255.0f + 0.5); gcbound_color(0,0,0); - gcbound_draw(gdl); + gcbound_draw(gfx); } else if(s_current_transition.state == TRANSITION_STATE_7_WHITE_IN){//L8030BBD8 //fade in white (i.e. get less white) @@ -350,23 +350,23 @@ void gctransition_draw(Gfx **gdl, Mtx **mptr, Vtx **vptr){ gcbound_reset(); gcbound_alpha(percentage*255.0f + 0.5); gcbound_color(0xff,0xff,0xff); - gcbound_draw(gdl); + gcbound_draw(gfx); } else if(s_current_transition.state == TRANSITION_STATE_8_WHITE_OUT){//L8030BC8C //fade out white (i.e. get more white) gcbound_reset(); gcbound_alpha(percentage*255.0f + 0.5); gcbound_color(0xff,0xff,0xff); - gcbound_draw(gdl); + gcbound_draw(gfx); }//L8030BD00 else{ } if(s_current_transition.anctrl != NULL){ - gDPSetTextureFilter((*gdl)++, G_TF_BILERP); + gDPSetTextureFilter((*gfx)++, G_TF_BILERP); } viewport_restoreState(); - viewport_setRenderViewportAndPerspectiveMatrix(gdl, mptr); + viewport_setRenderViewportAndPerspectiveMatrix(gfx, mtx); } @@ -405,7 +405,7 @@ void gctransition_8030BE3C(void){ void gctransition_8030BE60(void){ TransitionInfo *tmp_a1; tmp_a1 = _gctranstion_8030B400(_gctranstion_get_map_transition_info(gsworld_getMap())->out_index); - func_8030C180(); + picturebox_func_8030C180(); _gctranstion_changeState(tmp_a1->state, tmp_a1); } @@ -488,7 +488,7 @@ void gctransition_update(void){ }//L8030C104 _gctranstion_changeState(s_current_transition.transistion_info->next_state, 0); if(s_current_transition.state == TRANSITION_STATE_4_FADE_IN) - func_8030C180(); + picturebox_func_8030C180(); if(s_current_transition.anctrl != NULL) gsworld_update(); diff --git a/src/core2/gccube.c b/src/core2/gccube.c index ce4ab483..b8cafb6a 100644 --- a/src/core2/gccube.c +++ b/src/core2/gccube.c @@ -4,7 +4,7 @@ #include "variables.h" #include -#include +#include "math.h" #include "prop.h" extern void mapModel_getCubeBounds(s32 min[3], s32 max[3]); @@ -376,21 +376,19 @@ void func_80302C94(Gfx **gfx, Mtx **mtx, Vtx **vtx) { s32 sp38[3]; f32 temp_f18; - #if ANTI_TAMPER +#if ANTI_TAMPER if (!mapSpecificFlags_validateCRC1()) return; - #endif +#endif func_8032D3A8(); viewport_getPosition_vec3f(vp_position); viewport_getRotation_vec3f(vp_rotation); - func_80256664(vp_rotation); + ml_vec3f_clamp_deg360(vp_rotation); cube_positionToIndices(vp_cube_indices, vp_position); - vp_cube_indices[0] -= sCubeList.min[0];\ - vp_cube_indices[1] -= sCubeList.min[1];\ - vp_cube_indices[2] -= sCubeList.min[2]; + TUPLE_DIFF(vp_cube_indices, sCubeList.min) func_80308EC8(); - sp44[0] = sp44[1] = sp44[2] = 0; + TUPLE_SET(sp44, 0) sp38[0] = sCubeList.width[0] - 1;\ sp38[1] = sCubeList.width[1] - 1;\ sp38[2] = sCubeList.width[2] - 1; diff --git a/src/core2/gsworld.c b/src/core2/gsworld.c index b6efeb5d..dea6563a 100644 --- a/src/core2/gsworld.c +++ b/src/core2/gsworld.c @@ -31,19 +31,19 @@ void gsworld_draw(Gfx** gfx, Mtx **mtx, Vtx **vtx) { if (!sEnableDraw) { drawRectangle2D(gfx, 0, 0, gFramebufferWidth, gFramebufferHeight, 0, 0, 0); - func_802BBD2C(&near, &far); + core2_34790_getClipDistances(&near, &far); viewport_setNearAndFar(near, far); viewport_setRenderViewportAndPerspectiveMatrix(gfx, mtx); return; } if (!func_80320708()) { - eeprom_writeBlocks(0, 0, (void *) 0x80BC7230, EEPROM_MAXBLOCKS); + eeprom_writeBlocks(0, 0, (void *) PHYS_TO_K0(0x00BC7230), EEPROM_MAXBLOCKS); } spawnQueue_unlock(); sky_draw(gfx, mtx, vtx); - func_802BBD2C(&near, &far); + core2_34790_getClipDistances(&near, &far); viewport_setNearAndFar(near, far); viewport_setRenderViewportAndPerspectiveMatrix(gfx, mtx); @@ -74,7 +74,7 @@ void gsworld_draw(Gfx** gfx, Mtx **mtx, Vtx **vtx) { mapModel_xlu_draw(gfx, mtx, vtx); } if (!game_is_frozen()) { - func_8032D3D8(gfx, mtx, vtx); + core2_A5BC0_drawUnknownMarkers(gfx, mtx, vtx); } if (!game_is_frozen()) { partEmitMgr_drawPass1(gfx, mtx, vtx); @@ -89,7 +89,7 @@ void gsworld_draw(Gfx** gfx, Mtx **mtx, Vtx **vtx) { func_8034F6F0(gfx, mtx, vtx); player_draw(gfx, mtx, vtx); func_80302C94(gfx, mtx, vtx); - func_8032D3D8(gfx, mtx, vtx); + core2_A5BC0_drawUnknownMarkers(gfx, mtx, vtx); jiggylist_draw(gfx, mtx, vtx); func_803500D8(gfx, mtx, vtx); func_802F2ED0(func_8032994C(), gfx, mtx, vtx); diff --git a/src/core2/spawnqueue.c b/src/core2/spawnqueue.c index 34a33466..74c15217 100644 --- a/src/core2/spawnqueue.c +++ b/src/core2/spawnqueue.c @@ -422,7 +422,7 @@ void spawnQueue_free(void){ void spawnQueue_func_802C39D4(void){ func_803268B4(); if(!levelSpecificFlags_validateCRC2()){ - eeprom_writeBlocks(0, 0, (void*)0x80749530, EEPROM_MAXBLOCKS); + eeprom_writeBlocks(0, 0, (void *) PHYS_TO_K0(0x00749530), EEPROM_MAXBLOCKS); } } @@ -462,12 +462,12 @@ void spawnQueue_flush(void){ func_803283D4(); } -void spawnQueue_unlock(void){ - spawnQueueLock = 0; +void spawnQueue_unlock(void) { + spawnQueueLock = FALSE; } -void spawnQueue_lock(void){ - spawnQueueLock = 1; +void spawnQueue_lock(void) { + spawnQueueLock = TRUE; } void __spawnQueue_add_0(void (* arg0)(void)){