From 449b2247fdbe3cd3c424637ec7d6973caa697f0f Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Thu, 30 Jul 2020 15:50:18 -0400 Subject: [PATCH] Math Sizes (#297) * Math Sizes Added sizes to most variable types * Removed sizes and fixed pads Removed sizes from base types and cleaned up pads * PR fixes --- include/ultra64/types.h | 4 +-- include/z64math.h | 26 +++++++++---------- src/boot/z_std_dma.c | 2 +- src/code/code_800FC620.c | 2 +- src/code/fault.c | 4 +-- src/code/flg_set.c | 2 +- src/code/mempak.c | 10 +++---- src/code/speed_meter.c | 4 +-- src/code/z_debug.c | 2 +- src/code/z_draw.c | 2 +- src/code/z_jpeg.c | 2 +- src/code/z_kaleido_scope_call.c | 2 +- src/code/z_msgevent.c | 2 +- src/code/z_quake.c | 4 +-- src/overlays/actors/ovl_En_Guest/z_en_guest.c | 4 +-- src/overlays/actors/ovl_En_Hata/z_en_hata.c | 2 +- .../actors/ovl_En_Insect/z_en_insect.c | 2 +- .../actors/ovl_Oceff_Spot/z_oceff_spot.c | 6 ++--- src/overlays/gamestates/ovl_title/z_title.c | 4 +-- 19 files changed, 43 insertions(+), 43 deletions(-) diff --git a/include/ultra64/types.h b/include/ultra64/types.h index ae8cecd6f1..9a34f3dd93 100644 --- a/include/ultra64/types.h +++ b/include/ultra64/types.h @@ -10,11 +10,11 @@ typedef unsigned int u32; typedef signed long long int s64; typedef unsigned long long int u64; -typedef volatile u8 vu8; +typedef volatile u8 vu8; typedef volatile u16 vu16; typedef volatile u32 vu32; typedef volatile u64 vu64; -typedef volatile s8 vs8; +typedef volatile s8 vs8; typedef volatile s16 vs16; typedef volatile s32 vs32; typedef volatile s64 vs64; diff --git a/include/z64math.h b/include/z64math.h index 1b7d424a05..1aa535b723 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -7,69 +7,69 @@ typedef struct { f32 x, y; -} Vec2f; +} Vec2f; // size = 0x08 typedef struct { f32 x, y, z; -} Vec3f; +} Vec3f; // size = 0x0C typedef struct { u16 x, y, z; -} Vec3us; +} Vec3us; // size = 0x06 typedef struct { s16 x, y, z; -} Vec3s; +} Vec3s; // size = 0x06 typedef struct { s32 x, y, z; -} Vec3i; +} Vec3i; // size = 0x0C typedef struct { Vec3s center; s16 radius; -} Sphere16; +} Sphere16; // size = 0x08 typedef struct { Vec3f center; f32 radius; -} Spheref; +} Spheref; // size = 0x10 typedef struct { Vec3f normal; f32 originDist; -} Plane; +} Plane; // size = 0x10 typedef struct { Vec3f vtx[3]; Plane plane; -} TriNorm; //size = 0x34 +} TriNorm; // size = 0x34 typedef struct { s16 radius; s16 height; s16 yShift; Vec3s pos; -} Cylinder16; +} Cylinder16; // size = 0x0C typedef struct { f32 radius; f32 height; f32 yShift; Vec3f pos; -} Cylinderf; +} Cylinderf; // size = 0x18 typedef struct { Vec3f a; Vec3f b; -} Linef; +} Linef; // size = 0x18 // Defines a point in the spherical coordinate system typedef struct { f32 r; // radius s16 phi; // polar (zenith) angle s16 theta; // azimuthal angle -} VecSph; +} VecSph; // size = 0x08 #endif diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c index 7a0e0a31e1..aec911a3d4 100644 --- a/src/boot/z_std_dma.c +++ b/src/boot/z_std_dma.c @@ -1575,7 +1575,7 @@ s32 DmaMgr_DMARomToRam(u32 rom, u32 ram, u32 size) { OSMesg msg; s32 ret; u32 buffSize; - u32 pad[2]; + s32 pad[2]; buffSize = gDmaMgrDmaBuffSize; if (buffSize == 0) { diff --git a/src/code/code_800FC620.c b/src/code/code_800FC620.c index c75135cd70..1b62a7770a 100644 --- a/src/code/code_800FC620.c +++ b/src/code/code_800FC620.c @@ -21,7 +21,7 @@ char D_80134488[0x18] = { }; s32 Overlay_Load(u32 vRomStart, u32 vRomEnd, void* vRamStart, void* vRamEnd, void* allocatedVRamAddr) { - u32 pad; + s32 pad; u32 end; u32 bssSize; OverlayRelocationSection* ovl; diff --git a/src/code/fault.c b/src/code/fault.c index 892e110c9c..c5972c3a3d 100644 --- a/src/code/fault.c +++ b/src/code/fault.c @@ -882,7 +882,7 @@ void Fault_LogStackTrace(OSThread* thread, s32 height) { u32 ra = thread->context.ra; u32 pc = thread->context.pc; u32 addr; - u32 pad; + s32 pad; osSyncPrintf("STACK TRACE\nSP PC (VPC)\n"); for (line = 1; line < height && (ra != 0 || sp != 0) && pc != (u32)__osCleanupThread; line++) { @@ -955,7 +955,7 @@ void Fault_UpdatePad() { void Fault_ThreadEntry(void* arg) { OSMesg msg; OSThread* faultedThread; - u32 pad; + s32 pad; osSetEventMesg(OS_EVENT_CPU_BREAK, &sFaultStructPtr->queue, 1); osSetEventMesg(OS_EVENT_FAULT, &sFaultStructPtr->queue, 2); diff --git a/src/code/flg_set.c b/src/code/flg_set.c index b49c10947e..9f277f3ebe 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -37,7 +37,7 @@ void FlagSet_Update(GlobalContext* globalCtx) { }; GraphicsContext* gfxCtx; - u32 pad; + s32 pad; Gfx* gfx; Gfx* polyOpa; Gfx* dispRefs[5]; diff --git a/src/code/mempak.c b/src/code/mempak.c index b81a50125a..6478bb7256 100644 --- a/src/code/mempak.c +++ b/src/code/mempak.c @@ -14,7 +14,7 @@ u8 sMempakExtName[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; s32 Mempak_Init(s32 controllerNb) { OSMesgQueue* mq; - u32 pad; + s32 pad; s32 ret; ret = false; @@ -71,7 +71,7 @@ s32 Mempak_Write(s32 controllerNb, char idx, void* buffer, s32 offset, s32 size) OSMesgQueue* mq; s32 error; s32 ret; - u32 pad; + s32 pad; ret = false; mq = PadMgr_LockSerialMesgQueue(&gPadMgr); @@ -90,7 +90,7 @@ s32 Mempak_Read(s32 controllerNb, char idx, void* buffer, s32 offset, s32 size) OSMesgQueue* mq; s32 error; s32 ret; - u32 pad; + s32 pad; ret = false; mq = PadMgr_LockSerialMesgQueue(&gPadMgr); @@ -110,7 +110,7 @@ s32 Mempak_Alloc(s32 controllerNb, char* idx, s32 size) { s32 error; s32 ret; s32 i; - u32 pad; + s32 pad; ret = 0; mq = PadMgr_LockSerialMesgQueue(&gPadMgr); @@ -177,7 +177,7 @@ s32 Mempak_GetFileSize(s32 controllerNb, char idx) { OSMesgQueue* mq; OSPfsState state; s32 error; - u32 pad; + s32 pad; mq = PadMgr_LockSerialMesgQueue(&gPadMgr); error = osPfsFileState(&sMempakPfsHandle, sMempakFiles[idx - 'A'], &state); diff --git a/src/code/speed_meter.c b/src/code/speed_meter.c index b7cbc412e6..18672eb77b 100644 --- a/src/code/speed_meter.c +++ b/src/code/speed_meter.c @@ -43,7 +43,7 @@ void SpeedMeter_Destroy(SpeedMeter* this) { } void SpeedMeter_DrawTimeEntries(SpeedMeter* this, GraphicsContext* gfxCtx) { - u32 pad[2]; + s32 pad[2]; u32 baseX = 32; s32 temp; s32 i; @@ -153,7 +153,7 @@ void SpeedMeter_DrawAllocEntry(SpeedMeterAllocEntry* this, GraphicsContext* gfxC } void SpeedMeter_DrawAllocEntries(SpeedMeter* meter, GraphicsContext* gfxCtx, GameState* state) { - u32 pad[2]; + s32 pad[2]; u32 ulx = 30; u32 lrx = 290; SpeedMeterAllocEntry entry; diff --git a/src/code/z_debug.c b/src/code/z_debug.c index 658f641442..48caa825dd 100644 --- a/src/code/z_debug.c +++ b/src/code/z_debug.c @@ -220,7 +220,7 @@ void func_80063D7C(GraphicsContext* gfxCtx) { Gfx* sp78; GfxPrint gfxPrint; Gfx* tempRet; - u32 pad; + s32 pad; Gfx* dispRefs[4]; // stores state of GfxCtx next ptrs Graph_OpenDisps(dispRefs, gfxCtx, "../z_debug.c", 628); diff --git a/src/code/z_draw.c b/src/code/z_draw.c index 4806dfa98e..12a04eeb33 100644 --- a/src/code/z_draw.c +++ b/src/code/z_draw.c @@ -671,7 +671,7 @@ void func_8006B6E4(GlobalContext* globalCtx, s16 drawId) { } void func_8006B870(GlobalContext* globalCtx, s16 drawId) { - u32 pad; + s32 pad; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; Gfx* dispRefs[4]; diff --git a/src/code/z_jpeg.c b/src/code/z_jpeg.c index 70cf1e70e6..ee92e02cf9 100644 --- a/src/code/z_jpeg.c +++ b/src/code/z_jpeg.c @@ -37,7 +37,7 @@ u32 Jpeg_SendTask(JpegContext* ctx) { // clang-format on JpegWork* workBuf = ctx->workBuf; - u32 pad[2]; + s32 pad[2]; workBuf->taskData.address = PHYSICAL_TO_VIRTUAL(&workBuf->unk_6C0); workBuf->taskData.mode = ctx->mode; diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index 0baf2654b3..d7f42b7246 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -47,7 +47,7 @@ void KaleidoScopeCall_Destroy(GlobalContext* globalCtx) { // regalloc #ifdef NON_MATCHING void KaleidoScopeCall_Update(GlobalContext* globalCtx) { - u32 pad; + s32 pad; PauseContext* pauseCtx; pauseCtx = &globalCtx->pauseCtx; diff --git a/src/code/z_msgevent.c b/src/code/z_msgevent.c index 9e61a9181b..652d498994 100644 --- a/src/code/z_msgevent.c +++ b/src/code/z_msgevent.c @@ -2,7 +2,7 @@ #include void MsgEvent_SendNullTask() { - u32 pad[4]; + s32 pad[4]; OSScTask task; OSMesgQueue queue; OSMesg msg; diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 379fa03e78..c844ae3e3e 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -62,7 +62,7 @@ void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 y, f32 x) { } s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake) { - u32 pad; + s32 pad; if (req->countdown > 0) { f32 a = Math_Sins(req->speed * req->countdown); Quake_UpdateShakeInfo(req, shake, a, Math_Rand_ZeroOne() * a); @@ -81,7 +81,7 @@ s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake) { } s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake) { - u32 pad; + s32 pad; f32 a; req->countdown--; diff --git a/src/overlays/actors/ovl_En_Guest/z_en_guest.c b/src/overlays/actors/ovl_En_Guest/z_en_guest.c index 700221781a..ca2004c83c 100644 --- a/src/overlays/actors/ovl_En_Guest/z_en_guest.c +++ b/src/overlays/actors/ovl_En_Guest/z_en_guest.c @@ -78,7 +78,7 @@ void EnGuest_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnGuest_Update(Actor* thisx, GlobalContext* globalCtx) { EnGuest* this = THIS; - u32 pad; + s32 pad; if (Object_IsLoaded(&globalCtx->objectCtx, this->osAnimeBankIndex) != 0) { this->actor.flags &= ~0x10; @@ -147,7 +147,7 @@ void func_80A5057C(EnGuest* this, GlobalContext* globalCtx) { void func_80A505CC(Actor* thisx, GlobalContext* globalCtx) { EnGuest* this = THIS; - u32 pad; + s32 pad; Player* player; player = PLAYER; diff --git a/src/overlays/actors/ovl_En_Hata/z_en_hata.c b/src/overlays/actors/ovl_En_Hata/z_en_hata.c index 4dcec91d9d..e6a7360b3a 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.c +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.c @@ -40,7 +40,7 @@ extern UNK_TYPE D_060000C0; void EnHata_Init(Actor* thisx, GlobalContext* globalCtx) { EnHata* this = THIS; - u32 pad; + s32 pad; u32 temp; f32 frameCount; diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.c b/src/overlays/actors/ovl_En_Insect/z_en_insect.c index 8183b42c97..1d8a41537c 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.c @@ -78,7 +78,7 @@ f32 EnInsect_XZDistanceSquared(Vec3f* v1, Vec3f* v2) { } s32 func_80A7BE6C(EnInsect* this, GlobalContext* globalCtx) { - u32 pad; + s32 pad; Player* player = PLAYER; Vec3f pos; diff --git a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c index 381edcb6e4..32b6c03250 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c @@ -42,7 +42,7 @@ void OceffSpot_SetupAction(OceffSpot* this, OceffSpotActionFunc actionFunc) { } void OceffSpot_Init(Actor* thisx, GlobalContext* globalCtx) { - u32 pad; + s32 pad; OceffSpot* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); @@ -65,7 +65,7 @@ void OceffSpot_Init(Actor* thisx, GlobalContext* globalCtx) { } void OceffSpot_Destroy(Actor* thisx, GlobalContext* globalCtx) { - u32 pad; + s32 pad; OceffSpot* this = THIS; Player* player = PLAYER; @@ -119,7 +119,7 @@ void OceffSpot_GrowCylinder(OceffSpot* this, GlobalContext* globalCtx) { void OceffSpot_Update(Actor* thisx, GlobalContext* globalCtx) { OceffSpot* this = THIS; - u32 pad; + s32 pad; Player* player = PLAYER; f32 temp; diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 456c87fd1f..1b5b3f6b10 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -130,7 +130,7 @@ void Title_Draw(TitleContext* this) { void Title_Main(TitleContext* this) { GraphicsContext* gfxCtx = this->state.gfxCtx; Gfx* dispRefs[5]; - u32 pad[2]; + s32 pad[2]; Gfx* gfx; Graph_OpenDisps(dispRefs, this->state.gfxCtx, "../z_title.c", 494); @@ -162,7 +162,7 @@ void Title_Destroy(TitleContext* this) { void Title_Init(TitleContext* this) { u32 size = (u32)_nintendo_rogo_staticSegmentRomEnd - (u32)_nintendo_rogo_staticSegmentRomStart; - u32 pad; + s32 pad; this->staticSegment = GameState_Alloc(&this->state, size, "../z_title.c", 611); osSyncPrintf("z_title.c\n");