diff --git a/include/functions.h b/include/functions.h index 68f0acdd97..95a23c49da 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2142,8 +2142,8 @@ s32 GfxPrint_Printf(GfxPrint*, const char*, ...); void func_800FBCE0(); void func_800FBFD8(void); void* Overlay_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, void* vRamStart, void* vRamEnd); -void MtxConv_F2L(MatrixInternal* m1, MtxF* m2); -void MtxConv_L2F(MtxF* m1, MatrixInternal* m2); +void MtxConv_F2L(Mtx* m1, MtxF* m2); +void MtxConv_L2F(MtxF* m1, Mtx* m2); void Overlay_Relocate(void* allocatedVRamAddress, OverlayRelocationSection* overlayInfo, void* vRamAddress); s32 Overlay_Load(u32 vRomStart, u32 vRomEnd, void* vRamStart, void* vRamEnd, void* allocatedVRamAddress); // ? func_800FC800(?); @@ -2206,9 +2206,9 @@ void Rand_Seed_Variable(u32* rndNum, u32 seed); u32 Rand_Next_Variable(u32* rndNum); f32 Rand_ZeroOne_Variable(u32* rndNum); f32 Rand_Centered_Variable(u32* rndNum); -bool ArenaImpl_GetFillAllocBlock(Arena* arena); -bool ArenaImpl_GetFillFreeBlock(Arena* arena); -bool ArenaImpl_GetCheckFreeBlock(Arena* arena); +u32 ArenaImpl_GetFillAllocBlock(Arena* arena); +u32 ArenaImpl_GetFillFreeBlock(Arena* arena); +u32 ArenaImpl_GetCheckFreeBlock(Arena* arena); void ArenaImpl_SetFillAllocBlock(Arena* arena); void ArenaImpl_SetFillFreeBlock(Arena* arena); void ArenaImpl_SetCheckFreeBlock(Arena* arena); diff --git a/include/macros.h b/include/macros.h index a47fd9a83b..013a820ade 100644 --- a/include/macros.h +++ b/include/macros.h @@ -56,9 +56,9 @@ #define CHECK_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.inventory.dungeonItems[dungeonIndex] & gBitFlags[item]) #define GET_GS_FLAGS(index) \ - ((gSaveContext.gsFlags[(index) >> 2] & gGsFlagsMask[(index) & 3]) >> gGsFlagsShift[(index) & 3]) + ((gSaveContext.gsFlags[(index) >> 2] & gGsFlagsMasks[(index) & 3]) >> gGsFlagsShifts[(index) & 3]) #define SET_GS_FLAGS(index, value) \ - (gSaveContext.gsFlags[(index) >> 2] |= (value) << gGsFlagsShift[(index) & 3]) + (gSaveContext.gsFlags[(index) >> 2] |= (value) << gGsFlagsShifts[(index) & 3]) #define HIGH_SCORE(score) (gSaveContext.highScores[score]) diff --git a/include/ultra64/types.h b/include/ultra64/types.h index 4545e98ba0..6874a5209a 100644 --- a/include/ultra64/types.h +++ b/include/ultra64/types.h @@ -26,6 +26,10 @@ typedef double f64; typedef long int Mtx_t[4][4]; typedef union { Mtx_t m; + struct { + u16 intPart[4][4]; + u16 fracPart[4][4]; + }; long long int forc_structure_alignment; } Mtx; diff --git a/include/variables.h b/include/variables.h index cbd37e4f36..889f91d682 100644 --- a/include/variables.h +++ b/include/variables.h @@ -187,8 +187,8 @@ extern u32 gUpgradeNegMasks[8]; extern u8 gEquipShifts[4]; extern u8 gUpgradeShifts[8]; extern u16 gUpgradeCapacities[8][4]; -extern u32 gGsFlagsMask[4]; -extern u32 gGsFlagsShift[4]; +extern u32 gGsFlagsMasks[4]; +extern u32 gGsFlagsShifts[4]; extern void* gItemIcons[0x82]; extern u8 gItemSlots[56]; extern void (*gSceneCmdHandlers[26])(GlobalContext*, SceneCmd*); diff --git a/include/z64.h b/include/z64.h index a53ac315a8..d8eb8551c8 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1968,11 +1968,6 @@ typedef struct { /* 0x06 */ u16 color; } SpeedMeterTimeEntry; // size = 0x08 -typedef struct { - /* 0x00 */ u16 intPart[4][4]; - /* 0x20 */ u16 fracPart[4][4]; -} MatrixInternal; // size = 0x40 - typedef struct { /* 0x00 */ u32 value; /* 0x04 */ const char* name; diff --git a/src/boot/stackcheck.c b/src/boot/stackcheck.c index f11e16b52b..51cbfd1e73 100644 --- a/src/boot/stackcheck.c +++ b/src/boot/stackcheck.c @@ -48,7 +48,7 @@ void StackCheck_Init(StackEntry* entry, void* stackTop, void* stackBottom, u32 i } void StackCheck_Cleanup(StackEntry* entry) { - bool inconsistency = false; + u32 inconsistency = false; if (!entry->prev) { if (entry == sStackInfoListStart) { diff --git a/src/boot/z_locale.c b/src/boot/z_locale.c index 0fdf0e2176..0fc68958e6 100644 --- a/src/boot/z_locale.c +++ b/src/boot/z_locale.c @@ -21,7 +21,7 @@ void Locale_Init(void) { default: osSyncPrintf(VT_COL(RED, WHITE)); osSyncPrintf("z_locale_init: 日本用かアメリカ用か判別できません\n"); - LogUtils_HungupThread("../z_locale.c", 0x76); + LogUtils_HungupThread("../z_locale.c", 118); osSyncPrintf(VT_RST); break; } diff --git a/src/code/__osMalloc.c b/src/code/__osMalloc.c index b27392753e..0b66eb3539 100644 --- a/src/code/__osMalloc.c +++ b/src/code/__osMalloc.c @@ -17,13 +17,13 @@ OSMesg sArenaLockMsg; u32 __osMalloc_FreeBlockTest_Enable; -bool ArenaImpl_GetFillAllocBlock(Arena* arena) { +u32 ArenaImpl_GetFillAllocBlock(Arena* arena) { return (arena->flag & FILL_ALLOCBLOCK) != 0; } -bool ArenaImpl_GetFillFreeBlock(Arena* arena) { +u32 ArenaImpl_GetFillFreeBlock(Arena* arena) { return (arena->flag & FILL_FREEBLOCK) != 0; } -bool ArenaImpl_GetCheckFreeBlock(Arena* arena) { +u32 ArenaImpl_GetCheckFreeBlock(Arena* arena) { return (arena->flag & CHECK_FREE_BLOCK) != 0; } diff --git a/src/code/code_80097A00.c b/src/code/code_80097A00.c index b60b986358..26f1cb9e99 100644 --- a/src/code/code_80097A00.c +++ b/src/code/code_80097A00.c @@ -33,8 +33,8 @@ u16 gUpgradeCapacities[][4] = { { 0, 20, 30, 40 }, // Deku Nut Upgrades }; -u32 gGsFlagsMask[] = { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 }; -u32 gGsFlagsShift[] = { 0, 8, 16, 24 }; +u32 gGsFlagsMasks[] = { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 }; +u32 gGsFlagsShifts[] = { 0, 8, 16, 24 }; void* gItemIcons[] = { gDekuStickIconTex, diff --git a/src/code/code_800EC960.c b/src/code/code_800EC960.c index 811e16447c..875b47d894 100644 --- a/src/code/code_800EC960.c +++ b/src/code/code_800EC960.c @@ -145,7 +145,7 @@ u8 D_80130658[0x70] = { s8 sSpecReverbs[20] = { 0, 0, 0, 0, 0, 0, 0, 40, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; D_801306DC_s D_801306DC[20] = { - { 0xC0FF, 0XC0FE, { 0, 2, 0, 0, 3, 0, 1, 2, 9, 1, 3, 64, 1, 4, 0, 1, 5, 32, 2, 2, 4, 2, 3, + { 0xC0FF, 0xC0FE, { 0, 2, 0, 0, 3, 0, 1, 2, 9, 1, 3, 64, 1, 4, 0, 1, 5, 32, 2, 2, 4, 2, 3, 0, 2, 4, 1, 2, 5, 16, 3, 2, 10, 3, 3, 112, 3, 4, 1, 3, 5, 48, 4, 2, 14, 4, 3, 127, 4, 4, 0, 4, 5, 16, 5, 2, 0, 5, 3, 127, 5, 4, 1, 5, 5, 16, 6, 2, 1, 6, 3, 127, 6, 4, 3, 6, 5, 16, 7, 2, 17, 7, 3, 127, 7, 4, 1, 7, 5, 16, 0xFF } }, diff --git a/src/code/main.c b/src/code/main.c index 7afc300816..fce3972d14 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -61,7 +61,7 @@ void Main(void* arg) { debugHeapSize = (s32)(0x80600000 - debugHeap); } else { debugHeapSize = 0x400; - debugHeap = SystemArena_MallocDebug(debugHeapSize, "../main.c", 0x235); + debugHeap = SystemArena_MallocDebug(debugHeapSize, "../main.c", 565); } osSyncPrintf("debug_InitArena(%08x, %08x)\n", debugHeap, debugHeapSize); DebugArena_Init(debugHeap, debugHeapSize); diff --git a/src/code/mtxuty-cvt.c b/src/code/mtxuty-cvt.c index ff030d9c39..78926efd06 100644 --- a/src/code/mtxuty-cvt.c +++ b/src/code/mtxuty-cvt.c @@ -1,6 +1,6 @@ #include "global.h" -void MtxConv_F2L(MatrixInternal* m1, MtxF* m2) { +void MtxConv_F2L(Mtx* m1, MtxF* m2) { s32 i; s32 j; @@ -16,8 +16,8 @@ void MtxConv_F2L(MatrixInternal* m1, MtxF* m2) { } } -void MtxConv_L2F(MtxF* m1, MatrixInternal* m2) { +void MtxConv_L2F(MtxF* m1, Mtx* m2) { LogUtils_CheckNullPointer("m1", m1, "../mtxuty-cvt.c", 55); LogUtils_CheckNullPointer("m2", m2, "../mtxuty-cvt.c", 56); - guMtxL2F(m1, (Mtx*)m2); + guMtxL2F(m1, m2); } diff --git a/src/code/ucode_disas.c b/src/code/ucode_disas.c index 4af0898b05..9d5278f30e 100644 --- a/src/code/ucode_disas.c +++ b/src/code/ucode_disas.c @@ -510,7 +510,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) { } break; case G_LOAD_UCODE: { - if (curGfx->dma.len == 0x7ff) { + if (curGfx->dma.len == 0x7FF) { DISAS_LOG("gsSPLoadUcode(0x%08x, 0x%08x),", curGfx->dma.addr, rdpHalf); } else { DISAS_LOG("gsSPLoadUcodeEx(0x%08x, 0x%08x, 0x%05x),", curGfx->dma.addr, rdpHalf, @@ -695,7 +695,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) { case G_RDPSETOTHERMODE: { DISAS_LOG("gsDPSetOtherMode(0x%08x, 0x%08x),", curGfx->words.w0 & 0xFFFFFF, curGfx->words.w1); - this->modeH = curGfx->words.w0 & 0xfff; + this->modeH = curGfx->words.w0 & 0xFFF; this->modeL = curGfx->words.w1; if (this->pipeSyncRequired) { @@ -734,8 +734,8 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) { } break; case G_SETCIMG: { - u32 fmt = ((curGfx->words.w0 & 0xE00000) >> 0x15) & 0xff; - u32 siz = ((curGfx->words.w0 & 0x180000) >> 0x13) & 0xff; + u32 fmt = ((curGfx->words.w0 & 0xE00000) >> 0x15) & 0xFF; + u32 siz = ((curGfx->words.w0 & 0x180000) >> 0x13) & 0xFF; DISAS_LOG("gsDPSetColorImage(G_IM_FMT_%s, G_IM_SIZ_%s, %d, 0x%08x(0x%08x) ),", (fmt == G_IM_FMT_RGBA) @@ -744,7 +744,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) { : (fmt == G_IM_FMT_CI) ? "CI" : (fmt == G_IM_FMT_IA) ? "IA" : "I", (siz == G_IM_SIZ_4b) ? "4b" : (siz == G_IM_SIZ_8b) ? "8b" : (siz == G_IM_SIZ_16b) ? "16b" : "32b", - (curGfx->dma.len & 0xfff) + 1, curGfx->setimg.dram, addr); + (curGfx->dma.len & 0xFFF) + 1, curGfx->setimg.dram, addr); if (this->pipeSyncRequired) { DISAS_LOG("### PipeSyncが必要です。\n"); @@ -762,8 +762,8 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) { } break; case G_SETTIMG: { - u32 fmt = ((curGfx->words.w0 & 0xE00000) >> 0x15) & 0xff; - u32 siz = ((curGfx->words.w0 & 0x180000) >> 0x13) & 0xff; + u32 fmt = ((curGfx->words.w0 & 0xE00000) >> 0x15) & 0xFF; + u32 siz = ((curGfx->words.w0 & 0x180000) >> 0x13) & 0xFF; DISAS_LOG("gsDPSetTextureImage(G_IM_FMT_%s, G_IM_SIZ_%s, %d, 0x%08x(0x%08x)),", (fmt == G_IM_FMT_RGBA) @@ -772,7 +772,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) { : (fmt == G_IM_FMT_CI) ? "CI" : (fmt == G_IM_FMT_IA) ? "IA" : "I", (siz == G_IM_SIZ_4b) ? "4b" : (siz == G_IM_SIZ_8b) ? "8b" : (siz == G_IM_SIZ_16b) ? "16b" : "32b", - (curGfx->dma.len & 0xfff) + 1, curGfx->setimg.dram, addr); + (curGfx->dma.len & 0xFFF) + 1, curGfx->setimg.dram, addr); } break; case G_SETENVCOLOR: { @@ -933,39 +933,37 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) { DISAS_LOG("),", gmtx.addr); /*! @bug gmtx.addr shouldn't be here*/ if (this->enableLog >= 2) { - MtxConv_L2F(&mtx, ((MatrixInternal*)addr)); + MtxConv_L2F(&mtx, (Mtx*)addr); DISAS_LOG("\n"); + /*! @bug %.04x.%04x is a typo, should be %04x.%04x */ + // clang-format off DISAS_LOG( - "/ %04x.%04x %04x.%04x %04x.%04x %.04x.%04x \\/ %12.6f %12.6f %12.6f %12.6f " - "\\\n" + "/ %04x.%04x %04x.%04x %04x.%04x %.04x.%04x \\/ %12.6f %12.6f %12.6f %12.6f \\\n" "| %04x.%04x %04x.%04x %04x.%04x %.04x.%04x || %12.6f %12.6f %12.6f %12.6f |\n" "| %04x.%04x %04x.%04x %04x.%04x %.04x.%04x || %12.6f %12.6f %12.6f %12.6f |\n" - "\\ %04x.%04x %04x.%04x %04x.%04x %.04x.%04x /\\ %12.6f %12.6f %12.6f %12.6f " - "/\n", - ((MatrixInternal*)addr)->intPart[0][0], ((MatrixInternal*)addr)->fracPart[0][0], - ((MatrixInternal*)addr)->intPart[1][0], ((MatrixInternal*)addr)->fracPart[1][0], - ((MatrixInternal*)addr)->intPart[2][0], ((MatrixInternal*)addr)->fracPart[2][0], - ((MatrixInternal*)addr)->intPart[3][0], ((MatrixInternal*)addr)->fracPart[3][0], + "\\ %04x.%04x %04x.%04x %04x.%04x %.04x.%04x /\\ %12.6f %12.6f %12.6f %12.6f /\n", + ((Mtx*)addr)->intPart[0][0], ((Mtx*)addr)->fracPart[0][0], + ((Mtx*)addr)->intPart[1][0], ((Mtx*)addr)->fracPart[1][0], + ((Mtx*)addr)->intPart[2][0], ((Mtx*)addr)->fracPart[2][0], + ((Mtx*)addr)->intPart[3][0], ((Mtx*)addr)->fracPart[3][0], mtx.mf[0][0], mtx.mf[1][0], mtx.mf[2][0], mtx.mf[3][0], - - ((MatrixInternal*)addr)->intPart[0][1], ((MatrixInternal*)addr)->fracPart[0][1], - ((MatrixInternal*)addr)->intPart[1][1], ((MatrixInternal*)addr)->fracPart[1][1], - ((MatrixInternal*)addr)->intPart[2][1], ((MatrixInternal*)addr)->fracPart[2][1], - ((MatrixInternal*)addr)->intPart[3][1], ((MatrixInternal*)addr)->fracPart[3][1], + ((Mtx*)addr)->intPart[0][1], ((Mtx*)addr)->fracPart[0][1], + ((Mtx*)addr)->intPart[1][1], ((Mtx*)addr)->fracPart[1][1], + ((Mtx*)addr)->intPart[2][1], ((Mtx*)addr)->fracPart[2][1], + ((Mtx*)addr)->intPart[3][1], ((Mtx*)addr)->fracPart[3][1], mtx.mf[0][1], mtx.mf[1][1], mtx.mf[2][1], mtx.mf[3][1], - - ((MatrixInternal*)addr)->intPart[0][2], ((MatrixInternal*)addr)->fracPart[0][2], - ((MatrixInternal*)addr)->intPart[1][2], ((MatrixInternal*)addr)->fracPart[1][2], - ((MatrixInternal*)addr)->intPart[2][2], ((MatrixInternal*)addr)->fracPart[2][2], - ((MatrixInternal*)addr)->intPart[3][2], ((MatrixInternal*)addr)->fracPart[3][2], + ((Mtx*)addr)->intPart[0][2], ((Mtx*)addr)->fracPart[0][2], + ((Mtx*)addr)->intPart[1][2], ((Mtx*)addr)->fracPart[1][2], + ((Mtx*)addr)->intPart[2][2], ((Mtx*)addr)->fracPart[2][2], + ((Mtx*)addr)->intPart[3][2], ((Mtx*)addr)->fracPart[3][2], mtx.mf[0][2], mtx.mf[1][2], mtx.mf[2][2], mtx.mf[3][2], - - ((MatrixInternal*)addr)->intPart[0][3], ((MatrixInternal*)addr)->fracPart[0][3], - ((MatrixInternal*)addr)->intPart[1][3], ((MatrixInternal*)addr)->fracPart[1][3], - ((MatrixInternal*)addr)->intPart[2][3], ((MatrixInternal*)addr)->fracPart[2][3], - ((MatrixInternal*)addr)->intPart[3][3], ((MatrixInternal*)addr)->fracPart[3][3], + ((Mtx*)addr)->intPart[0][3], ((Mtx*)addr)->fracPart[0][3], + ((Mtx*)addr)->intPart[1][3], ((Mtx*)addr)->fracPart[1][3], + ((Mtx*)addr)->intPart[2][3], ((Mtx*)addr)->fracPart[2][3], + ((Mtx*)addr)->intPart[3][3], ((Mtx*)addr)->fracPart[3][3], mtx.mf[0][3], mtx.mf[1][3], mtx.mf[2][3], mtx.mf[3][3]); + // clang-format on } } break; @@ -974,7 +972,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) { u32 vbidx; numv >>= 12; - numv &= 0xff; + numv &= 0xFF; vbidx = (curGfx->vtx.vbidx >> 1) - numv; DISAS_LOG("gsSPVertex(0x%08x(0x%08x), %d, %d),", curGfx->words.w1, addr, numv, vbidx); diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 7088730ae1..3170eb87a5 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -1077,14 +1077,14 @@ void CollisionCheck_ClearContext(GlobalContext* globalCtx, CollisionCheckContext * Enables SAC, an alternate collision check mode that allows direct management of collider lists. Unused. */ void CollisionCheck_EnableSAC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx) { - colChkCtx->sacFlags |= AC_ON; + colChkCtx->sacFlags |= 1; } /** * Disables SAC, an alternate collision check mode that allows direct management of collider lists. Unused. */ void CollisionCheck_DisableSAC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx) { - colChkCtx->sacFlags &= ~AC_ON; + colChkCtx->sacFlags &= ~1; } /** diff --git a/src/libultra_boot_O1/initialize.c b/src/libultra_boot_O1/initialize.c index 4827b8af1b..0489067b0a 100644 --- a/src/libultra_boot_O1/initialize.c +++ b/src/libultra_boot_O1/initialize.c @@ -2,7 +2,7 @@ typedef struct { u32 ins_00; // lui k0, 0x8000 - u32 ins_04; // addiu k0, k0, 0x39e0 + u32 ins_04; // addiu k0, k0, 0x39E0 u32 ins_08; // jr k0 ; __osException u32 ins_0C; // nop } struct_exceptionPreamble; @@ -76,8 +76,8 @@ void __osInitialize_common(void) { } HW_REG(AI_CONTROL_REG, u32) = 1; - HW_REG(AI_DACRATE_REG, u32) = 0x3fff; - HW_REG(AI_BITRATE_REG, u32) = 0xf; + HW_REG(AI_DACRATE_REG, u32) = 0x3FFF; + HW_REG(AI_BITRATE_REG, u32) = 0xF; } void __osInitialize_autodetect(void) { diff --git a/src/libultra_boot_O2/_Ldtob.c b/src/libultra_boot_O2/_Ldtob.c index f7a6d1208f..cc518a44b2 100644 --- a/src/libultra_boot_O2/_Ldtob.c +++ b/src/libultra_boot_O2/_Ldtob.c @@ -9,13 +9,13 @@ const f64 D_800122E0[] = { 10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L, 1 /* float properties */ #define _D0 0 -#define _DBIAS 0x3ff +#define _DBIAS 0x3FF #define _DLONG 1 #define _DOFF 4 -#define _FBIAS 0x7e +#define _FBIAS 0x7E #define _FOFF 7 #define _FRND 1 -#define _LBIAS 0x3ffe +#define _LBIAS 0x3FFE #define _LOFF 15 /* integer properties */ #define _C2 1 @@ -26,7 +26,7 @@ const f64 D_800122E0[] = { 10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L, 1 #define INF 1 #define FINITE -1 #define _DFRAC ((1 << _DOFF) - 1) -#define _DMASK (0x7fff & ~_DFRAC) +#define _DMASK (0x7FFF & ~_DFRAC) #define _DMAX ((1 << (15 - _DOFF)) - 1) #define _DNAN (0x8000 | _DMAX << _DOFF | 1 << (_DOFF - 1)) #define _DSIGN 0x8000 diff --git a/src/libultra_boot_O2/__osEPiRawStartDma.c b/src/libultra_boot_O2/__osEPiRawStartDma.c index 9246484486..5ae4d9c307 100644 --- a/src/libultra_boot_O2/__osEPiRawStartDma.c +++ b/src/libultra_boot_O2/__osEPiRawStartDma.c @@ -53,7 +53,7 @@ s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dr } HW_REG(PI_DRAM_ADDR_REG, void*) = (void*)osVirtualToPhysical(dramAddr); - HW_REG(PI_CART_ADDR_REG, void*) = (void*)((handle->baseAddress | cartAddr) & 0x1fffffff); + HW_REG(PI_CART_ADDR_REG, void*) = (void*)((handle->baseAddress | cartAddr) & 0x1FFFFFFF); switch (direction) { case OS_READ: diff --git a/src/libultra_boot_O2/__osPiRawStartDma.c b/src/libultra_boot_O2/__osPiRawStartDma.c index 8fda513516..f2c0a8488e 100644 --- a/src/libultra_boot_O2/__osPiRawStartDma.c +++ b/src/libultra_boot_O2/__osPiRawStartDma.c @@ -9,7 +9,7 @@ s32 __osPiRawStartDma(s32 dir, u32 cartAddr, void* dramAddr, size_t size) { HW_REG(PI_DRAM_ADDR_REG, void*) = (void*)osVirtualToPhysical(dramAddr); - HW_REG(PI_CART_ADDR_REG, void*) = (void*)((osRomBase | cartAddr) & 0x1fffffff); + HW_REG(PI_CART_ADDR_REG, void*) = (void*)((osRomBase | cartAddr) & 0x1FFFFFFF); switch (dir) { case OS_READ: diff --git a/src/libultra_boot_O2/__osViSwapContext.c b/src/libultra_boot_O2/__osViSwapContext.c index aeadb75af9..d82d5cce65 100644 --- a/src/libultra_boot_O2/__osViSwapContext.c +++ b/src/libultra_boot_O2/__osViSwapContext.c @@ -17,14 +17,14 @@ void __osViSwapContext(void) { s2 = osVirtualToPhysical(viNext->buffer); origin = (viMode->fldRegs[field].origin) + s2; if (viNext->state & 2) { - viNext->x.scale |= viMode->comRegs.xScale & ~0xfff; + viNext->x.scale |= viMode->comRegs.xScale & ~0xFFF; } else { viNext->x.scale = viMode->comRegs.xScale; } if (viNext->state & 4) { - sp34 = (u32)(viMode->fldRegs[field].yScale & 0xfff); + sp34 = (u32)(viMode->fldRegs[field].yScale & 0xFFF); viNext->y.scale = viNext->y.factor * sp34; - viNext->y.scale |= viMode->fldRegs[field].yScale & ~0xfff; + viNext->y.scale |= viMode->fldRegs[field].yScale & ~0xFFF; } else { viNext->y.scale = viMode->fldRegs[field].yScale; } @@ -40,7 +40,7 @@ void __osViSwapContext(void) { origin = osVirtualToPhysical(viNext->buffer); } if (viNext->state & 0x80) { - viNext->y.scale = (viNext->y.offset << 0x10) & 0x3ff0000; + viNext->y.scale = (viNext->y.offset << 0x10) & 0x3FF0000; origin = osVirtualToPhysical(viNext->buffer); } HW_REG(VI_ORIGIN_REG, u32) = origin; diff --git a/src/libultra_boot_O2/osCartRomInit.c b/src/libultra_boot_O2/osCartRomInit.c index ff5dc82928..f87d3bd051 100644 --- a/src/libultra_boot_O2/osCartRomInit.c +++ b/src/libultra_boot_O2/osCartRomInit.c @@ -22,7 +22,7 @@ OSPiHandle* osCartRomInit(void) { D_8000AF10 = 0; __CartRomHandle.type = DEVICE_TYPE_CART; - __CartRomHandle.baseAddress = 0xb0000000; + __CartRomHandle.baseAddress = 0xB0000000; __CartRomHandle.domain = 0; __CartRomHandle.speed = 0; bzero(&__CartRomHandle.transferInfo, sizeof(__OSTranxInfo)); @@ -36,10 +36,10 @@ OSPiHandle* osCartRomInit(void) { lastRelDuration = HW_REG(PI_BSD_DOM1_RLS_REG, u32); lastPulse = HW_REG(PI_BSD_DOM1_PWD_REG, u32); - HW_REG(PI_BSD_DOM1_LAT_REG, u32) = 0xff; + HW_REG(PI_BSD_DOM1_LAT_REG, u32) = 0xFF; HW_REG(PI_BSD_DOM1_PGS_REG, u32) = 0; HW_REG(PI_BSD_DOM1_RLS_REG, u32) = 3; - HW_REG(PI_BSD_DOM1_PWD_REG, u32) = 0xff; + HW_REG(PI_BSD_DOM1_PWD_REG, u32) = 0xFF; a = HW_REG(__CartRomHandle.baseAddress, u32); __CartRomHandle.latency = a & 0xFF; diff --git a/src/libultra_boot_O2/osDriveRomInit.c b/src/libultra_boot_O2/osDriveRomInit.c index af478f0e93..a9f2ea02b5 100644 --- a/src/libultra_boot_O2/osDriveRomInit.c +++ b/src/libultra_boot_O2/osDriveRomInit.c @@ -17,7 +17,7 @@ OSPiHandle* osDriveRomInit(void) { D_8000AC70 = 0; __DriveRomHandle.type = DEVICE_TYPE_BULK; - __DriveRomHandle.baseAddress = 0xa6000000; + __DriveRomHandle.baseAddress = 0xA6000000; __DriveRomHandle.domain = 0; __DriveRomHandle.speed = 0; bzero(&__DriveRomHandle.transferInfo, sizeof(__OSTranxInfo)); @@ -26,10 +26,10 @@ OSPiHandle* osDriveRomInit(void) { ; } - HW_REG(PI_BSD_DOM1_LAT_REG, u32) = 0xff; + HW_REG(PI_BSD_DOM1_LAT_REG, u32) = 0xFF; HW_REG(PI_BSD_DOM1_PGS_REG, u32) = 0; HW_REG(PI_BSD_DOM1_RLS_REG, u32) = 3; - HW_REG(PI_BSD_DOM1_PWD_REG, u32) = 0xff; + HW_REG(PI_BSD_DOM1_PWD_REG, u32) = 0xFF; a = HW_REG(__DriveRomHandle.baseAddress, u32); __DriveRomHandle.latency = a & 0xFF; diff --git a/src/libultra_boot_O2/osEPiStartDma.c b/src/libultra_boot_O2/osEPiStartDma.c index 7547fb6953..41b39caa9d 100644 --- a/src/libultra_boot_O2/osEPiStartDma.c +++ b/src/libultra_boot_O2/osEPiStartDma.c @@ -10,7 +10,7 @@ s32 osEPiStartDma(OSPiHandle* handle, OSIoMesg* mb, s32 direction) { mb->piHandle = handle; if (direction == OS_READ) { - mb->hdr.type = 0xf; + mb->hdr.type = 0xF; } else { mb->hdr.type = 0x10; } diff --git a/src/libultra_boot_O2/osViSetXScale.c b/src/libultra_boot_O2/osViSetXScale.c index 21b4f7aeaf..aeeb5e784f 100644 --- a/src/libultra_boot_O2/osViSetXScale.c +++ b/src/libultra_boot_O2/osViSetXScale.c @@ -7,7 +7,7 @@ void osViSetXScale(f32 value) { __osViNext->x.factor = value; __osViNext->state |= 0x2; - nomValue = __osViNext->modep->comRegs.xScale & 0xfff; + nomValue = __osViNext->modep->comRegs.xScale & 0xFFF; __osViNext->x.scale = (u32)(__osViNext->x.factor * nomValue) & 0xFFF; __osRestoreInt(prevInt); diff --git a/src/libultra_boot_O2/vimgr.c b/src/libultra_boot_O2/vimgr.c index c195bbf4c5..b57b48d3b4 100644 --- a/src/libultra_boot_O2/vimgr.c +++ b/src/libultra_boot_O2/vimgr.c @@ -5,7 +5,7 @@ typedef struct { u16 unk00; u8 unk02; u32 unk04; - u8 pad[0xc]; + u8 pad[0xC]; u16 unk14; u16 unk16; } viMesgStruct; diff --git a/src/libultra_code_O2/__osContAddressCrc.c b/src/libultra_code_O2/__osContAddressCrc.c index d22668d149..c1af0b12c5 100644 --- a/src/libultra_code_O2/__osContAddressCrc.c +++ b/src/libultra_code_O2/__osContAddressCrc.c @@ -28,7 +28,7 @@ u8 __osContAddressCrc(u16 addr) { } } - return ret & 0x1f; + return ret & 0x1F; } u8 __osContDataCrc(u8* data) { diff --git a/src/libultra_code_O2/__osContRamWrite.c b/src/libultra_code_O2/__osContRamWrite.c index d65f86a198..e27c032278 100644 --- a/src/libultra_code_O2/__osContRamWrite.c +++ b/src/libultra_code_O2/__osContRamWrite.c @@ -27,11 +27,11 @@ s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32 gPifMempakBuf.status = 1; - ((__OSContRamHeader*)ptr)->unk_00 = 0xff; + ((__OSContRamHeader*)ptr)->unk_00 = 0xFF; ((__OSContRamHeader*)ptr)->txsize = 35; ((__OSContRamHeader*)ptr)->rxsize = 1; ((__OSContRamHeader*)ptr)->poll = CONT_CMD_WRITE_MEMPACK; - ((__OSContRamHeader*)ptr)->datacrc = 0xff; + ((__OSContRamHeader*)ptr)->datacrc = 0xFF; ptr[sizeof(__OSContRamHeader)] = CONT_CMD_END; } else { diff --git a/src/libultra_code_O2/cosf.c b/src/libultra_code_O2/cosf.c index 1d9c7e83d3..cae7159ea8 100644 --- a/src/libultra_code_O2/cosf.c +++ b/src/libultra_code_O2/cosf.c @@ -3,7 +3,7 @@ static const du P[] = { { 0x3FF00000, 0x00000000 }, { 0xBFC55554, 0xBC83656D }, { 0x3F8110ED, 0x3804C2A0 }, - { 0xBF29f6FF, 0xEEA56814 }, { 0x3EC5DBDF, 0x0E314BFE }, + { 0xBF29F6FF, 0xEEA56814 }, { 0x3EC5DBDF, 0x0E314BFE }, }; static const du rpi = { 0x3FD45F30, 0x6DC9C883 }; diff --git a/src/libultra_code_O2/guLookAtHilite.c b/src/libultra_code_O2/guLookAtHilite.c index ebb9157244..d1070b579c 100644 --- a/src/libultra_code_O2/guLookAtHilite.c +++ b/src/libultra_code_O2/guLookAtHilite.c @@ -1,6 +1,6 @@ #include "global.h" -#define FTOFRAC8(x) ((s32)MIN(((x) * (128.0f)), 127.0f) & 0xff) +#define FTOFRAC8(x) ((s32)MIN(((x) * (128.0f)), 127.0f) & 0xFF) /** * guLookAtHiliteF diff --git a/src/overlays/actors/ovl_En_Ko/z_en_ko.h b/src/overlays/actors/ovl_En_Ko/z_en_ko.h index c4fa8a8162..b7a60dd056 100644 --- a/src/overlays/actors/ovl_En_Ko/z_en_ko.h +++ b/src/overlays/actors/ovl_En_Ko/z_en_ko.h @@ -19,7 +19,7 @@ typedef struct EnKo { /* 0x0198 */ ColliderCylinder collider; /* 0x01E4 */ Path* path; /* 0x01E8 */ struct_80034A14_arg1 unk_1E8; - /* 0X0210 */ u8 unk_210; // block trade quest sfx + /* 0x0210 */ u8 unk_210; // block trade quest sfx /* 0x0212 */ s16 forestQuestState; /* 0x0214 */ s16 blinkTimer; /* 0x0216 */ s16 eyeTextureIndex; diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index 89e54efe74..3be3ef2bad 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -759,7 +759,7 @@ void ObjSwitch_DrawCrystal(ObjSwitch* this, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1494); func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_switch.c", 0x5D9), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_switch.c", 1497), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, xluDLists[subType]); diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.c b/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.c index 4fc65deae7..a0895c5f74 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Magma2/z_eff_ss_g_magma2.c @@ -87,9 +87,9 @@ void EffectSsGMagma2_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (this->rDrawMode == 0) { - POLY_XLU_DISP = Gfx_CallSetupDL(gfxCtx->polyXlu.p, 0x3D); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x3D); } else { - POLY_XLU_DISP = Gfx_CallSetupDL(gfxCtx->polyXlu.p, 0); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, 0, this->rPrimColorA);