diff --git a/include/functions.h b/include/functions.h index 8e819af55f..e15b2bcab0 100644 --- a/include/functions.h +++ b/include/functions.h @@ -576,9 +576,9 @@ void Graph_UpdateGame(GameState* gameState); void Graph_ExecuteAndDraw(GraphicsContext* gfxCtx, GameState* gameState); void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState); void Graph_ThreadEntry(void* arg); -Gfx* Graph_GfxPlusOne(Gfx* gfx); -Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst); -void* Graph_DlistAlloc(Gfx** gfx, size_t size); +Gfx* Gfx_Open(Gfx* gfx); +Gfx* Gfx_Close(Gfx* gfx, Gfx* dst); +void* Gfx_Alloc(Gfx** gfxP, size_t size); void Mtx_SetTranslateScaleMtx(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY, f32 translateZ); void Mtx_SetRotationMtx(Mtx* mtx, s32 angle, f32 axisX, f32 axisY, f32 axisZ); diff --git a/include/loadfragment.h b/include/loadfragment.h index dcf7490976..6e3f083f96 100644 --- a/include/loadfragment.h +++ b/include/loadfragment.h @@ -36,7 +36,7 @@ typedef struct OverlayRelocationSection { } OverlayRelocationSection; // size >= 0x18 // Fragment overlay load functions -size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, void* ramStart, void* ramEnd, void* allocatedRamAddr); +size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd, void* allocatedRamAddr); void* Overlay_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd); #endif diff --git a/spec b/spec index fe38ebac88..795a32387f 100644 --- a/spec +++ b/spec @@ -560,7 +560,7 @@ beginseg include "build/src/code/game.o" include "build/src/code/gamealloc.o" include "build/src/code/graph.o" - include "build/src/code/graphalloc.o" + include "build/src/code/gfxalloc.o" include "build/src/code/listalloc.o" include "build/src/code/main.o" include "build/src/code/padmgr.o" diff --git a/src/boot/O2/loadfragment.c b/src/boot/O2/loadfragment.c index c4831bbcb5..18f9a4c944 100644 --- a/src/boot/O2/loadfragment.c +++ b/src/boot/O2/loadfragment.c @@ -45,7 +45,7 @@ s32 gLoadLogSeverity = 2; * @param ovlRelocs Overlay relocation section containing overlay section layout and runtime relocations. * @param vramStart Virtual RAM address that the overlay was compiled at. */ -void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelocs, uintptr_t vramStart) { +void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelocs, void* vramStart) { u32 sections[RELOC_SECTION_MAX]; u32* relocDataP; u32 reloc; @@ -64,7 +64,9 @@ void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelo u32 luiVals[32]; u32 isLoNeg; - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // "DoRelocation(%08x, %08x, %08x)\n" + } sections[RELOC_SECTION_NULL] = 0; sections[RELOC_SECTION_TEXT] = allocu32; @@ -86,8 +88,10 @@ void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelo // Check address is valid for relocation if ((*relocDataP & 0x0F000000) == 0) { - *relocDataP = *relocDataP - vramStart + allocu32; + *relocDataP = *relocDataP - (uintptr_t)vramStart + allocu32; } else if (gLoadLogSeverity >= 3) { + // Segment pointer 32 %08x + // "セグメントポインタ32です %08x\n" } break; @@ -99,7 +103,11 @@ void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelo if (1) { *relocDataP = (*relocDataP & 0xFC000000) | - (((PHYS_TO_K0(MIPS_JUMP_TARGET(*relocDataP)) - vramStart + allocu32) & 0x0FFFFFFF) >> 2); + (((PHYS_TO_K0(MIPS_JUMP_TARGET(*relocDataP)) - (uintptr_t)vramStart + allocu32) & 0x0FFFFFFF) >> + 2); + } else if (gLoadLogSeverity >= 3) { + // Segment pointer 26 %08x + // "セグメントポインタ26です %08x\n" } break; @@ -124,11 +132,13 @@ void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelo // Check address is valid for relocation if ((((*luiInstRef << 0x10) + (s16)*relocDataP) & 0x0F000000) == 0) { - relocatedAddress = ((*regValP << 0x10) + (s16)*relocDataP) - vramStart + allocu32; + relocatedAddress = ((*regValP << 0x10) + (s16)*relocDataP) - (uintptr_t)vramStart + allocu32; isLoNeg = (relocatedAddress & 0x8000) ? 1 : 0; *luiInstRef = (*luiInstRef & 0xFFFF0000) | (((relocatedAddress >> 0x10) & 0xFFFF) + isLoNeg); *relocDataP = (*relocDataP & 0xFFFF0000) | (relocatedAddress & 0xFFFF); } else if (gLoadLogSeverity >= 3) { + // Segment pointer 16 %08x %08x %08x + // "セグメントポインタ16です %08x %08x %08x" } break; } @@ -142,36 +152,56 @@ size_t Fragment_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, vo s32 pad; OverlayRelocationSection* ovlRelocs; - if (gLoadLogSeverity >= 3) {} - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // Starting loading dynamic link function + // "\nダイナミックリンクファンクションのロードを開始します\n" + } + if (gLoadLogSeverity >= 3) { + // DMA transfer TEXT, DATA, RODATA+rel (%08x-%08x) + // "TEXT,DATA,RODATA+relをDMA転送します(%08x-%08x)\n" + } end = (uintptr_t)allocatedRamAddr + size; DmaMgr_RequestSync(allocatedRamAddr, vromStart, size); ovlRelocs = (OverlayRelocationSection*)(end - ((s32*)end)[-1]); - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // "TEXT(%08x), DATA(%08x), RODATA(%08x), BSS(%08x)\n" + } if (allocatedBytes < ovlRelocs->bssSize + size) { - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // ramSize is too small (ramSize=%08x, NeedRamSize=%08x) + // "ramSizeが小さすぎます(ramSize=%08x, NeedRamSize=%08x)\n" + } return 0; } allocatedBytes = ovlRelocs->bssSize + size; - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // I will relocate + // "リロケーションします\n" + } - Fragment_Relocate(allocatedRamAddr, ovlRelocs, (uintptr_t)vramStart); + Fragment_Relocate(allocatedRamAddr, ovlRelocs, vramStart); if (ovlRelocs->bssSize != 0) { - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // Clear BSS area (%08x-%08x) + // "BSS領域をクリアします(%08x-%08x)\n" + } bzero((void*)end, ovlRelocs->bssSize); } osWritebackDCache(allocatedRamAddr, allocatedBytes); osInvalICache(allocatedRamAddr, allocatedBytes); - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // Finish loading the dynamic link function + // "ダイナミックリンクファンクションのロードを終了します\n\n" + } return allocatedBytes; } @@ -184,48 +214,74 @@ void* Fragment_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vra OverlayRelocationSection* ovlRelocs; size_t allocatedBytes; - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // Start loading dynamic link function + // "\nダイナミックリンクファンクションのロードを開始します\n" + + // "LoadFragment(%08x, %08x, %08x)\n" + } allocatedRamAddr = malloc_r(size); end = (uintptr_t)allocatedRamAddr + size; - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // DMA transfer TEXT, DATA, RODATA+rel (%08x-%08x) + // "TEXT,DATA,RODATA+relをDMA転送します(%08x-%08x)\n" + } DmaMgr_RequestSync(allocatedRamAddr, vromStart, size); - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // "TEXT(%08x), DATA(%08x), RODATA(%08x), BSS(%08x)\n" + } ovlOffset = end - sizeof(s32); ovlRelocs = (OverlayRelocationSection*)(end - ((s32*)end)[-1]); + //! FAKE: if (1) {} allocatedBytes = ovlRelocs->bssSize + size; allocatedRamAddr = realloc(allocatedRamAddr, allocatedBytes); - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // No reallocation. + // "リアロケーションしません。\n" + } if (allocatedRamAddr == NULL) { - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // Reallocation failed. . + // "リアロケーションに失敗しました。" + } return allocatedRamAddr; } end = (uintptr_t)allocatedRamAddr + size; ovlRelocs = (OverlayRelocationSection*)(end - *(uintptr_t*)ovlOffset); - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // I will relocate + // "リロケーションします\n" + } - Fragment_Relocate(allocatedRamAddr, ovlRelocs, (uintptr_t)vramStart); + Fragment_Relocate(allocatedRamAddr, ovlRelocs, vramStart); if (ovlRelocs->bssSize != 0) { - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // Clear BSS area (%08x-%08x) + // "BSS領域をクリアします(%08x-%08x)\n" + } bzero((void*)end, ovlRelocs->bssSize); } osInvalICache(allocatedRamAddr, allocatedBytes); - if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) { + // Finish loading the dynamic link function + // "ダイナミックリンクファンクションのロードを終了します\n\n" + } return allocatedRamAddr; } diff --git a/src/boot/O2/loadfragment2.c b/src/boot/O2/loadfragment2.c index 460a7f43f1..ee798ac634 100644 --- a/src/boot/O2/loadfragment2.c +++ b/src/boot/O2/loadfragment2.c @@ -41,7 +41,7 @@ s32 gOverlayLogSeverity = 2; * @param ovlRelocs Overlay relocation section containing overlay section layout and runtime relocations. * @param vramStart Virtual RAM address that the overlay was compiled at. */ -void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelocs, uintptr_t vramStart) { +void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelocs, void* vramStart) { u32 sections[RELOC_SECTION_MAX]; u32* relocDataP; u32 reloc; @@ -60,7 +60,9 @@ void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlReloc u32 luiVals[32]; u32 isLoNeg; - if (gOverlayLogSeverity >= 3) {} + if (gOverlayLogSeverity >= 3) { + // "DoRelocation(%08x, %08x, %08x)\n" + } sections[RELOC_SECTION_NULL] = 0; sections[RELOC_SECTION_TEXT] = allocu32; @@ -82,8 +84,10 @@ void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlReloc // Check address is valid for relocation if ((*relocDataP & 0x0F000000) == 0) { - *relocDataP = *relocDataP - vramStart + allocu32; + *relocDataP = *relocDataP - (uintptr_t)vramStart + allocu32; } else if (gOverlayLogSeverity >= 3) { + // Segment pointer 32 %08x + // "セグメントポインタ32です %08x\n" } break; @@ -95,7 +99,11 @@ void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlReloc if (1) { *relocDataP = (*relocDataP & 0xFC000000) | - (((PHYS_TO_K0(MIPS_JUMP_TARGET(*relocDataP)) - vramStart + allocu32) & 0x0FFFFFFF) >> 2); + (((PHYS_TO_K0(MIPS_JUMP_TARGET(*relocDataP)) - (uintptr_t)vramStart + allocu32) & 0x0FFFFFFF) >> + 2); + } else if (gOverlayLogSeverity >= 3) { + // Segment pointer 26 %08x + // "セグメントポインタ26です %08x\n" } break; @@ -120,48 +128,72 @@ void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlReloc // Check address is valid for relocation if ((((*luiInstRef << 0x10) + (s16)*relocDataP) & 0x0F000000) == 0) { - relocatedAddress = ((*regValP << 0x10) + (s16)*relocDataP) - vramStart + allocu32; + relocatedAddress = ((*regValP << 0x10) + (s16)*relocDataP) - (uintptr_t)vramStart + allocu32; isLoNeg = (relocatedAddress & 0x8000) ? 1 : 0; *luiInstRef = (*luiInstRef & 0xFFFF0000) | (((relocatedAddress >> 0x10) & 0xFFFF) + isLoNeg); *relocDataP = (*relocDataP & 0xFFFF0000) | (relocatedAddress & 0xFFFF); } else if (gOverlayLogSeverity >= 3) { + // Segment pointer 16 %08x %08x %08x + // "セグメントポインタ16です %08x %08x %08x" } break; } } } -size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, void* ramStart, void* ramEnd, void* allocatedRamAddr) { - uintptr_t vramStart = (uintptr_t)ramStart; - uintptr_t vramEnd = (uintptr_t)ramEnd; +size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd, void* allocatedRamAddr) { + s32 pad[2]; s32 size = vromEnd - vromStart; uintptr_t end; OverlayRelocationSection* ovlRelocs; - if (gOverlayLogSeverity >= 3) {} - if (gOverlayLogSeverity >= 3) {} + if (gOverlayLogSeverity >= 3) { + // Start loading dynamic link function + // "\nダイナミックリンクファンクションのロードを開始します\n" + } + size = vromEnd - vromStart; end = (uintptr_t)allocatedRamAddr + size; + + if (gOverlayLogSeverity >= 3) { + // DMA transfer TEXT, DATA, RODATA+rel (%08x-%08x) + // "TEXT,DATA,RODATA+relをDMA転送します(%08x-%08x)\n" + } + DmaMgr_RequestSync(allocatedRamAddr, vromStart, size); + // The overlay file is expected to contain a 32-bit offset from the end of the file to the start of the + // relocation section. ovlRelocs = (OverlayRelocationSection*)(end - ((s32*)end)[-1]); - if (gOverlayLogSeverity >= 3) {} - if (gOverlayLogSeverity >= 3) {} + if (gOverlayLogSeverity >= 3) { + // "TEXT(%08x), DATA(%08x), RODATA(%08x), BSS(%08x)\n" + } + + if (gOverlayLogSeverity >= 3) { + // I will relocate + // "リロケーションします\n" + } Overlay_Relocate(allocatedRamAddr, ovlRelocs, vramStart); if (ovlRelocs->bssSize != 0) { - if (gOverlayLogSeverity >= 3) {} + if (gOverlayLogSeverity >= 3) { + // Clear BSS area (%08x-%08x) + // "BSS領域をクリアします(%08x-%08x)\n" + } bzero((void*)end, ovlRelocs->bssSize); } - size = vramEnd - vramStart; + size = (uintptr_t)vramEnd - (uintptr_t)vramStart; osWritebackDCache(allocatedRamAddr, size); osInvalICache(allocatedRamAddr, size); - if (gOverlayLogSeverity >= 3) {} + if (gOverlayLogSeverity >= 3) { + // Finish loading the dynamic link function + // "ダイナミックリンクファンクションのロードを終了します\n\n" + } return size; } diff --git a/src/code/PreRender.c b/src/code/PreRender.c index 6d4e52cf47..936efbcb2d 100644 --- a/src/code/PreRender.c +++ b/src/code/PreRender.c @@ -404,7 +404,7 @@ void PreRender_AntiAliasFilterPixel(PreRender* this, s32 x, s32 y) { s32 buffB[3 * 5]; s32 xi; s32 yi; - s32 temp; + s32 invCvg; s32 pmaxR; s32 pmaxG; s32 pmaxB; @@ -511,10 +511,10 @@ void PreRender_AntiAliasFilterPixel(PreRender* this, s32 x, s32 y) { // BackGround = (pMax + pMin) - (ForeGround) * 2 // OutputColor = cvg * ForeGround + (1.0 - cvg) * BackGround - temp = 7 - buffCvg[7]; - outR = buffR[7] + ((s32)(temp * (pmaxR + pminR - (buffR[7] * 2)) + 4) >> 3); - outG = buffG[7] + ((s32)(temp * (pmaxG + pminG - (buffG[7] * 2)) + 4) >> 3); - outB = buffB[7] + ((s32)(temp * (pmaxB + pminB - (buffB[7] * 2)) + 4) >> 3); + invCvg = 7 - buffCvg[7]; + outR = buffR[7] + ((s32)(invCvg * (pmaxR + pminR - (buffR[7] * 2)) + 4) >> 3); + outG = buffG[7] + ((s32)(invCvg * (pmaxG + pminG - (buffG[7] * 2)) + 4) >> 3); + outB = buffB[7] + ((s32)(invCvg * (pmaxB + pminB - (buffB[7] * 2)) + 4) >> 3); pxOut.r = outR >> 3; pxOut.g = outG >> 3; @@ -768,7 +768,7 @@ void Prerender_DrawBackground2DImpl(PreRenderBackground2DParams* bg2D, Gfx** gfx alphaCompare = (bg2D->flags & BG2D_FLAGS_AC_THRESHOLD) ? G_AC_THRESHOLD : G_AC_NONE; gfxTemp = *gfxp; - bg = Graph_DlistAlloc(&gfxTemp, sizeof(uObjBg)); + bg = Gfx_Alloc(&gfxTemp, sizeof(uObjBg)); gfx = gfxTemp; bg->b.imageX = 0; diff --git a/src/code/flg_set.c b/src/code/flg_set.c index 9929cbb476..138aa02541 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -277,7 +277,7 @@ void FlagSet_Draw(GameState* gameState) { s32 pad; polyOpa = POLY_OPA_DISP; - gfx = Graph_GfxPlusOne(polyOpa); + gfx = Gfx_Open(polyOpa); gSPDisplayList(OVERLAY_DISP++, gfx); GfxPrint_Init(&printer); @@ -313,7 +313,7 @@ void FlagSet_Draw(GameState* gameState) { GfxPrint_Destroy(&printer); gSPEndDisplayList(gfx++); - Graph_BranchDlist(polyOpa, gfx); + Gfx_Close(polyOpa, gfx); POLY_OPA_DISP = gfx; CLOSE_DISPS(gfxCtx); diff --git a/src/code/game.c b/src/code/game.c index 434337615b..90b9b106bb 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -83,7 +83,7 @@ void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx); - gfx = Graph_GfxPlusOne(gfxHead = POLY_OPA_DISP); + gfx = Gfx_Open(gfxHead = POLY_OPA_DISP); gSPDisplayList(OVERLAY_DISP++, gfx); if ((R_FB_FILTER_TYPE != 0) && (R_FB_FILTER_ENV_COLOR(3) == 0)) { @@ -95,7 +95,7 @@ void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) { } gSPEndDisplayList(gfx++); - Graph_BranchDlist(gfxHead, gfx); + Gfx_Close(gfxHead, gfx); POLY_OPA_DISP = gfx; CLOSE_DISPS(gfxCtx); @@ -127,10 +127,10 @@ void GameState_DrawEnd(GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx); - gfx = Graph_GfxPlusOne(gfxHead = POLY_OPA_DISP); + gfx = Gfx_Open(gfxHead = POLY_OPA_DISP); gSPDisplayList(OVERLAY_DISP++, gfx); gSPEndDisplayList(gfx++); - Graph_BranchDlist(gfxHead, gfx); + Gfx_Close(gfxHead, gfx); POLY_OPA_DISP = gfx; diff --git a/src/code/graphalloc.c b/src/code/gfxalloc.c similarity index 61% rename from src/code/graphalloc.c rename to src/code/gfxalloc.c index cbae8ebe48..07070e9643 100644 --- a/src/code/graphalloc.c +++ b/src/code/gfxalloc.c @@ -1,10 +1,10 @@ #include "global.h" -Gfx* Graph_GfxPlusOne(Gfx* gfx) { +Gfx* Gfx_Open(Gfx* gfx) { return &gfx[1]; } -Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst) { +Gfx* Gfx_Close(Gfx* gfx, Gfx* dst) { gSPBranchList(gfx, dst); return dst; } @@ -15,15 +15,15 @@ Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst) { * Since the alloc may not itself be display list commands, a BranchList * command is used to step over this region. */ -void* Graph_DlistAlloc(Gfx** gfx, size_t size) { +void* Gfx_Alloc(Gfx** gfxP, size_t size) { u8* start; - Gfx* end; + Gfx* gfx; size = ALIGN8(size); - start = (u8*)&(*gfx)[1]; - end = (Gfx*)(start + size); - gSPBranchList(*gfx, end); + start = (u8*)&(*gfxP)[1]; + gfx = (Gfx*)(start + size); + gSPBranchList(*gfxP, gfx); - *gfx = end; + *gfxP = gfx; return start; } diff --git a/src/code/z_debug_mode.c b/src/code/z_debug_mode.c index a40bd29bd5..9e9c2abba3 100644 --- a/src/code/z_debug_mode.c +++ b/src/code/z_debug_mode.c @@ -134,7 +134,7 @@ void Debug_DrawText(GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx); gfxHead = POLY_OPA_DISP; - gfx = Graph_GfxPlusOne(gfxHead); + gfx = Gfx_Open(gfxHead); gSPDisplayList(DEBUG_DISP++, gfx); GfxPrint_Open(&printer, gfx); @@ -150,7 +150,7 @@ void Debug_DrawText(GraphicsContext* gfxCtx) { gfx = GfxPrint_Close(&printer); gSPEndDisplayList(gfx++); - Graph_BranchDlist(gfxHead, gfx); + Gfx_Close(gfxHead, gfx); POLY_OPA_DISP = gfx; CLOSE_DISPS(gfxCtx); diff --git a/src/code/z_eff_ss_dead.c b/src/code/z_eff_ss_dead.c index b34c38a69e..57e2451fcb 100644 --- a/src/code/z_eff_ss_dead.c +++ b/src/code/z_eff_ss_dead.c @@ -3,44 +3,44 @@ void func_800AE2A0(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) { f32 cos; - Gfx* displayListHead; + Gfx* gfx; f32 absCos; OPEN_DISPS(play->state.gfxCtx); - displayListHead = POLY_OPA_DISP; + gfx = POLY_OPA_DISP; cos = Math_CosS((0x8000 / arg3) * arg2); absCos = fabsf(cos); - gDPPipeSync(displayListHead++); + gDPPipeSync(gfx++); if (color == NULL) { - gDPSetFogColor(displayListHead++, 255, 0, 0, 0); + gDPSetFogColor(gfx++, 255, 0, 0, 0); } else { - gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a); + gDPSetFogColor(gfx++, color->r, color->g, color->b, color->a); } - gSPFogPosition(displayListHead++, 0, TRUNCF_BINANG(absCos * 3000.0f) + 1500); + gSPFogPosition(gfx++, 0, TRUNCF_BINANG(absCos * 3000.0f) + 1500); - POLY_OPA_DISP = displayListHead; + POLY_OPA_DISP = gfx; CLOSE_DISPS(play->state.gfxCtx); } void func_800AE434(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) { - Gfx* displayListHead; + Gfx* gfx; f32 cos; OPEN_DISPS(play->state.gfxCtx); cos = Math_CosS((0x4000 / arg3) * arg2); - displayListHead = POLY_OPA_DISP; + gfx = POLY_OPA_DISP; - gDPPipeSync(displayListHead++); - gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a); - gSPFogPosition(displayListHead++, 0, TRUNCF_BINANG(2800.0f * fabsf(cos)) + 1700); + gDPPipeSync(gfx++); + gDPSetFogColor(gfx++, color->r, color->g, color->b, color->a); + gSPFogPosition(gfx++, 0, TRUNCF_BINANG(2800.0f * fabsf(cos)) + 1700); - POLY_OPA_DISP = displayListHead; + POLY_OPA_DISP = gfx; CLOSE_DISPS(play->state.gfxCtx); } @@ -58,44 +58,44 @@ void func_800AE5A0(PlayState* play) { void func_800AE5E4(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) { f32 cos; - Gfx* displayListHead; + Gfx* gfx; f32 absCos; OPEN_DISPS(play->state.gfxCtx); - displayListHead = POLY_XLU_DISP; + gfx = POLY_XLU_DISP; cos = Math_CosS((0x8000 / arg3) * arg2); absCos = fabsf(cos); - gDPPipeSync(displayListHead++); + gDPPipeSync(gfx++); if (color == NULL) { - gDPSetFogColor(displayListHead++, 255, 0, 0, 0); + gDPSetFogColor(gfx++, 255, 0, 0, 0); } else { - gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a); + gDPSetFogColor(gfx++, color->r, color->g, color->b, color->a); } - gSPFogPosition(displayListHead++, 0, TRUNCF_BINANG(absCos * 3000.0f) + 1500); + gSPFogPosition(gfx++, 0, TRUNCF_BINANG(absCos * 3000.0f) + 1500); - POLY_XLU_DISP = displayListHead; + POLY_XLU_DISP = gfx; CLOSE_DISPS(play->state.gfxCtx); } void func_800AE778(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) { f32 cos; - Gfx* displayListHead; + Gfx* gfx; OPEN_DISPS(play->state.gfxCtx); - displayListHead = POLY_XLU_DISP; + gfx = POLY_XLU_DISP; cos = Math_CosS((0x4000 / arg3) * arg2); - gDPPipeSync(displayListHead++); - gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a); - gSPFogPosition(displayListHead++, 0, TRUNCF_BINANG(2800.0f * fabsf(cos)) + 1700); + gDPPipeSync(gfx++); + gDPSetFogColor(gfx++, color->r, color->g, color->b, color->a); + gSPFogPosition(gfx++, 0, TRUNCF_BINANG(2800.0f * fabsf(cos)) + 1700); - POLY_XLU_DISP = displayListHead; + POLY_XLU_DISP = gfx; CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 4bb5afa5e0..45cb555869 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -3308,7 +3308,7 @@ void Environment_DrawSkyboxStars(PlayState* play) { OPEN_DISPS(play->state.gfxCtx); gfxHead = POLY_OPA_DISP; - gfx = Graph_GfxPlusOne(gfxHead); + gfx = Gfx_Open(gfxHead); gSPDisplayList(sSkyboxStarsDList, gfx); @@ -3316,7 +3316,7 @@ void Environment_DrawSkyboxStars(PlayState* play) { gSPEndDisplayList(gfx++); - Graph_BranchDlist(gfxHead, gfx); + Gfx_Close(gfxHead, gfx); POLY_OPA_DISP = gfx; sSkyboxStarsDList = NULL; diff --git a/src/code/z_message.c b/src/code/z_message.c index 1b59642737..3d75d53256 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -5117,7 +5117,7 @@ void Message_Draw(PlayState* play) { OPEN_DISPS(gfxCtx); gfxHead = POLY_OPA_DISP; - gfx = Graph_GfxPlusOne(gfxHead); + gfx = Gfx_Open(gfxHead); gSPDisplayList(OVERLAY_DISP++, gfx); if ((play->msgCtx.currentTextId != 0x5E6) || !Play_InCsMode(play)) { @@ -5125,7 +5125,7 @@ void Message_Draw(PlayState* play) { } gSPEndDisplayList(gfx++); - Graph_BranchDlist(gfxHead, gfx); + Gfx_Close(gfxHead, gfx); POLY_OPA_DISP = gfx; CLOSE_DISPS(gfxCtx); diff --git a/src/code/z_play.c b/src/code/z_play.c index 70b2417599..4824769c93 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -71,7 +71,7 @@ void Play_DrawMotionBlur(PlayState* this) { OPEN_DISPS(gfxCtx); gfxHead = POLY_OPA_DISP; - gfx = Graph_GfxPlusOne(gfxHead); + gfx = Gfx_Open(gfxHead); gSPDisplayList(OVERLAY_DISP++, gfx); @@ -88,7 +88,7 @@ void Play_DrawMotionBlur(PlayState* this) { gSPEndDisplayList(gfx++); - Graph_BranchDlist(gfxHead, gfx); + Gfx_Close(gfxHead, gfx); POLY_OPA_DISP = gfx; @@ -1113,13 +1113,13 @@ void Play_PostWorldDraw(PlayState* this) { OPEN_DISPS(gfxCtx); gfxHead = POLY_OPA_DISP; - gfx = Graph_GfxPlusOne(gfxHead); + gfx = Gfx_Open(gfxHead); gSPDisplayList(OVERLAY_DISP++, gfx); VisFbuf_Draw(sPlayVisFbufInstance, &gfx, this->unk_18E60); gSPEndDisplayList(gfx++); - Graph_BranchDlist(gfxHead, gfx); + Gfx_Close(gfxHead, gfx); POLY_OPA_DISP = gfx; CLOSE_DISPS(gfxCtx); @@ -1211,7 +1211,7 @@ void Play_DrawMain(PlayState* this) { Gfx* sp218; Gfx* sp214 = POLY_OPA_DISP; - sp218 = Graph_GfxPlusOne(sp214); + sp218 = Gfx_Open(sp214); gSPDisplayList(OVERLAY_DISP++, sp218); if (((this->transitionMode == TRANS_MODE_INSTANCE_RUNNING) || @@ -1236,7 +1236,7 @@ void Play_DrawMain(PlayState* this) { } gSPEndDisplayList(sp218++); - Graph_BranchDlist(sp214, sp218); + Gfx_Close(sp214, sp218); POLY_OPA_DISP = sp218; } @@ -1383,7 +1383,7 @@ void Play_DrawMain(PlayState* this) { Gfx* sp74; Gfx* sp70 = POLY_OPA_DISP; - sp74 = Graph_GfxPlusOne(sp70); + sp74 = Gfx_Open(sp70); gSPDisplayList(OVERLAY_DISP++, sp74); this->pauseBgPreRender.fbuf = gfxCtx->curFrameBuffer; @@ -1408,7 +1408,7 @@ void Play_DrawMain(PlayState* this) { } gSPEndDisplayList(sp74++); - Graph_BranchDlist(sp70, sp74); + Gfx_Close(sp70, sp74); POLY_OPA_DISP = sp74; this->unk_18B49 = 2; SREG(33) |= 1; diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index 11736a1760..31bc019422 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1357,7 +1357,7 @@ void Gfx_SetupDL59_Opa(GraphicsContext* gfxCtx) { } Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height) { - Gfx* gfx = Graph_DlistAlloc(gfxp, 3 * sizeof(Gfx)); + Gfx* gfx = Gfx_Alloc(gfxp, 3 * sizeof(Gfx)); gDPTileSync(&gfx[0]); gDPSetTileSize(&gfx[1], 0, x, y, (x + ((width - 1) << 2)), (y + ((height - 1) << 2))); diff --git a/src/code/z_skin_awb.c b/src/code/z_skin_awb.c index 8425d961ad..cd753fc8b3 100644 --- a/src/code/z_skin_awb.c +++ b/src/code/z_skin_awb.c @@ -31,12 +31,11 @@ void Skin_InitAnimatedLimb(GameState* gameState, Skin* skin, s32 limbIndex) { for (skinVtxEntry = skinVertices; skinVtxEntry < &skinVertices[modifEntry->vtxCount];) { Vtx* vtx = &vertices[skinVtxEntry->index]; - skinVtxEntry++; - vtx->n.flag = 0; - vtx->n.tc[0] = skinVtxEntry[-1].s; - vtx->n.tc[1] = skinVtxEntry[-1].t; - vtx->n.a = skinVtxEntry[-1].alpha; + vtx->n.tc[0] = skinVtxEntry->s; + vtx->n.tc[1] = skinVtxEntry->t; + vtx->n.a = skinVtxEntry->alpha; + skinVtxEntry++; } } } diff --git a/src/code/z_visfbuf.c b/src/code/z_visfbuf.c index 62242bcec5..63d2cd8c5d 100644 --- a/src/code/z_visfbuf.c +++ b/src/code/z_visfbuf.c @@ -84,7 +84,7 @@ void VisFbuf_SetBg(Gfx** gfxP, void* source, void* img, s32 width, s32 height, f // Allocate for BG gfxTemp = gfx; - bg = Graph_DlistAlloc(&gfxTemp, sizeof(uObjBg)); + bg = Gfx_Alloc(&gfxTemp, sizeof(uObjBg)); gfx = gfxTemp; // Set up BG diff --git a/src/code/z_vismono.c b/src/code/z_vismono.c index 5e4330786e..c898882b12 100644 --- a/src/code/z_vismono.c +++ b/src/code/z_vismono.c @@ -144,14 +144,14 @@ void VisMono_Draw(VisMono* this, Gfx** gfxP) { if (this->tlut) { tlut = this->tlut; } else { - tlut = Graph_DlistAlloc(&gfx, 256 * G_IM_SIZ_16b_BYTES); + tlut = Gfx_Alloc(&gfx, 256 * G_IM_SIZ_16b_BYTES); VisMono_DesaturateTLUT(tlut); } if (this->dList) { dList = this->dList; } else { - dList = Graph_DlistAlloc(&gfx, VISMONO_DLSIZE * sizeof(Gfx)); + dList = Gfx_Alloc(&gfx, VISMONO_DLSIZE * sizeof(Gfx)); dListEnd = VisMono_DesaturateDList(dList); } diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 447b704fac..9b2874521a 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -964,13 +964,13 @@ void EnMag_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); gfxRef = POLY_OPA_DISP; - gfx = Graph_GfxPlusOne(gfxRef); + gfx = Gfx_Open(gfxRef); gSPDisplayList(OVERLAY_DISP++, gfx); EnMag_DrawInner(thisx, play, &gfx); gSPEndDisplayList(gfx++); - Graph_BranchDlist(gfxRef, gfx); + Gfx_Close(gfxRef, gfx); POLY_OPA_DISP = gfx; CLOSE_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index 36dd20ed81..2b0571e48d 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -584,7 +584,7 @@ void func_80C1193C(EnThiefbird* this, PlayState* play) { this->collider.base.atFlags &= ~AT_HIT; Actor_PlaySfx(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); if (!(this->collider.base.atFlags & AT_BOUNCED)) { - if ((D_80C1392C != 0) && CUR_UPG_VALUE(UPG_QUIVER) && + if ((D_80C1392C != 0) && (CUR_UPG_VALUE(UPG_QUIVER) != 0) && ((STOLEN_ITEM_1 == STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 == STOLEN_ITEM_NONE)) && (Rand_ZeroOne() < 0.5f) && func_80C10B0C(this, play)) { func_80C1242C(this); diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c index 2a1e1dda6a..1a3449b2dd 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c @@ -356,13 +356,13 @@ void KaleidoScope_DrawInventoryEditor(PlayState* play) { PRIMITIVE, 0); gfxRef = POLY_OPA_DISP; - gfx = Graph_GfxPlusOne(gfxRef); + gfx = Gfx_Open(gfxRef); gSPDisplayList(OVERLAY_DISP++, gfx); KaleidoScope_DrawInventoryEditorText(&gfx); gSPEndDisplayList(gfx++); - Graph_BranchDlist(gfxRef, gfx); + Gfx_Close(gfxRef, gfx); POLY_OPA_DISP = gfx; gDPPipeSync(POLY_OPA_DISP++); diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index 8af0263056..c32ffbc870 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -461,7 +461,7 @@ 0x80173360 : "game", 0x80173BF0 : "gamealloc", 0x80173D30 : "graph", - 0x80174A40 : "graphalloc", + 0x80174A40 : "gfxalloc", 0x80174AA0 : "listalloc", 0x80174BF0 : "main", 0x80174F10 : "padmgr", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 661005c811..3b50554bae 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3156,9 +3156,9 @@ 0x801744F8:("Graph_ExecuteAndDraw",), 0x80174868:("Graph_Update",), 0x801748A0:("Graph_ThreadEntry",), - 0x80174A40:("Graph_GfxPlusOne",), - 0x80174A4C:("Graph_BranchDlist",), - 0x80174A64:("Graph_DlistAlloc",), + 0x80174A40:("Gfx_Open",), + 0x80174A4C:("Gfx_Close",), + 0x80174A64:("Gfx_Alloc",), 0x80174AA0:("ListAlloc_Init",), 0x80174AB4:("ListAlloc_Alloc",), 0x80174B20:("ListAlloc_Free",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index a65e3dcd1f..115329be18 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2670,9 +2670,9 @@ asm/non_matchings/code/graph/Graph_UpdateGame.s,Graph_UpdateGame,0x801744AC,0x13 asm/non_matchings/code/graph/Graph_ExecuteAndDraw.s,Graph_ExecuteAndDraw,0x801744F8,0xDC asm/non_matchings/code/graph/Graph_Update.s,Graph_Update,0x80174868,0xE asm/non_matchings/code/graph/Graph_ThreadEntry.s,Graph_ThreadEntry,0x801748A0,0x68 -asm/non_matchings/code/graphalloc/Graph_GfxPlusOne.s,Graph_GfxPlusOne,0x80174A40,0x3 -asm/non_matchings/code/graphalloc/Graph_BranchDlist.s,Graph_BranchDlist,0x80174A4C,0x6 -asm/non_matchings/code/graphalloc/Graph_DlistAlloc.s,Graph_DlistAlloc,0x80174A64,0xF +asm/non_matchings/code/gfxalloc/Gfx_Open.s,Gfx_Open,0x80174A40,0x3 +asm/non_matchings/code/gfxalloc/Gfx_Close.s,Gfx_Close,0x80174A4C,0x6 +asm/non_matchings/code/gfxalloc/Gfx_Alloc.s,Gfx_Alloc,0x80174A64,0xF asm/non_matchings/code/listalloc/func_80174AA0.s,func_80174AA0,0x80174AA0,0x5 asm/non_matchings/code/listalloc/func_80174AB4.s,func_80174AB4,0x80174AB4,0x1B asm/non_matchings/code/listalloc/func_80174B20.s,func_80174B20,0x80174B20,0x20