diff --git a/include/functions.h b/include/functions.h index 6984ea1634..758f94648d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -26,14 +26,6 @@ NORETURN void func_80002384(const char* exp, const char* file, int line); #endif OSPiHandle* osDriveRomInit(void); void Mio0_Decompress(u8* src, u8* dst); -#if DEBUG_FEATURES -void LogUtils_LogHexDump(void* ptr, s32 size0); -void LogUtils_CheckNullPointer(const char* exp, void* ptr, const char* file, int line); -void LogUtils_CheckValidPointer(const char* exp, void* ptr, const char* file, int line); -void LogUtils_LogThreadId(const char* name, int line); -#endif -void LogUtils_HungupThread(const char* name, int line); -void LogUtils_ResetHungup(void); EnItem00* Item_DropCollectible(PlayState* play, Vec3f* spawnPos, s16 params); EnItem00* Item_DropCollectible2(PlayState* play, Vec3f* spawnPos, s16 params); @@ -290,24 +282,6 @@ size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, voi // ? func_800FC83C(?); // ? func_800FCAB4(?); void SystemHeap_Init(void* start, u32 size); -void PadUtils_Init(Input* input); -void func_800FCB70(void); -void PadUtils_ResetPressRel(Input* input); -u32 PadUtils_CheckCurExact(Input* input, u16 value); -u32 PadUtils_CheckCur(Input* input, u16 key); -u32 PadUtils_CheckPressed(Input* input, u16 key); -u32 PadUtils_CheckReleased(Input* input, u16 key); -u16 PadUtils_GetCurButton(Input* input); -u16 PadUtils_GetPressButton(Input* input); -s8 PadUtils_GetCurX(Input* input); -s8 PadUtils_GetCurY(Input* input); -void PadUtils_SetRelXY(Input* input, s32 x, s32 y); -s8 PadUtils_GetRelXImpl(Input* input); -s8 PadUtils_GetRelYImpl(Input* input); -s8 PadUtils_GetRelX(Input* input); -s8 PadUtils_GetRelY(Input* input); -void PadUtils_UpdateRelXY(Input* input); -s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status); f32 absf(f32); diff --git a/include/libu64/debug.h b/include/libu64/debug.h new file mode 100644 index 0000000000..598c901957 --- /dev/null +++ b/include/libu64/debug.h @@ -0,0 +1,25 @@ +#ifndef LIBU64_DEBUG_H +#define LIBU64_DEBUG_H + +#include "ultra64.h" + +#if PLATFORM_N64 || DEBUG_FEATURES +f32 LogUtils_CheckFloatRange(const char* exp, int line, const char* valueName, f32 value, const char* minName, f32 min, + const char* maxName, f32 max); +#endif + +#if DEBUG_FEATURES +s32 LogUtils_CheckIntRange(const char* exp, int line, const char* valueName, s32 value, const char* minName, s32 min, + const char* maxName, s32 max); +void LogUtils_LogHexDump(void* ptr, s32 size0); +void LogUtils_LogPointer(s32 value, u32 max, void* ptr, const char* name, const char* file, int line); +void LogUtils_CheckBoundary(const char* name, s32 value, s32 unk, const char* file, int line); +void LogUtils_CheckNullPointer(const char* exp, void* ptr, const char* file, int line); +void LogUtils_CheckValidPointer(const char* exp, void* ptr, const char* file, int line); +void LogUtils_LogThreadId(const char* name, int line); +#endif + +void LogUtils_HungupThread(const char* name, int line); +void LogUtils_ResetHungup(void); + +#endif diff --git a/include/gfxprint.h b/include/libu64/gfxprint.h similarity index 96% rename from include/gfxprint.h rename to include/libu64/gfxprint.h index 039b564b4b..4106d9fd1c 100644 --- a/include/gfxprint.h +++ b/include/libu64/gfxprint.h @@ -1,5 +1,5 @@ -#ifndef GFXPRINT_H -#define GFXPRINT_H +#ifndef LIBU64_GFXPRINT_H +#define LIBU64_GFXPRINT_H #include "ultra64.h" #include "color.h" diff --git a/include/libu64/pad.h b/include/libu64/pad.h new file mode 100644 index 0000000000..f5ab44d8c4 --- /dev/null +++ b/include/libu64/pad.h @@ -0,0 +1,31 @@ +#ifndef LIBU64_PAD_H +#define LIBU64_PAD_H + +#include "ultra64.h" + +typedef struct Input { + /* 0x00 */ OSContPad cur; + /* 0x06 */ OSContPad prev; + /* 0x0C */ OSContPad press; // X/Y store delta from last frame + /* 0x12 */ OSContPad rel; // X/Y store adjusted +} Input; // size = 0x18 + +void PadUtils_Init(Input* input); +void func_800FCB70(void); +void PadUtils_ResetPressRel(Input* input); +u32 PadUtils_CheckCurExact(Input* input, u16 value); +u32 PadUtils_CheckCur(Input* input, u16 key); +u32 PadUtils_CheckPressed(Input* input, u16 key); +u32 PadUtils_CheckReleased(Input* input, u16 key); +u16 PadUtils_GetCurButton(Input* input); +u16 PadUtils_GetPressButton(Input* input); +s8 PadUtils_GetCurX(Input* input); +s8 PadUtils_GetCurY(Input* input); +void PadUtils_SetRelXY(Input* input, s32 x, s32 y); +s8 PadUtils_GetRelXImpl(Input* input); +s8 PadUtils_GetRelYImpl(Input* input); +s8 PadUtils_GetRelX(Input* input); +s8 PadUtils_GetRelY(Input* input); +void PadUtils_UpdateRelXY(Input* input); + +#endif diff --git a/include/libu64/padsetup.h b/include/libu64/padsetup.h new file mode 100644 index 0000000000..0aab4a729c --- /dev/null +++ b/include/libu64/padsetup.h @@ -0,0 +1,8 @@ +#ifndef LIBU64_PADSETUP_H +#define LIBU64_PADSETUP_H + +#include "ultra64.h" + +s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status); + +#endif diff --git a/include/padmgr.h b/include/padmgr.h index 5bfa98308d..4b9e6890cd 100644 --- a/include/padmgr.h +++ b/include/padmgr.h @@ -2,6 +2,7 @@ #define PADMGR_H #include "ultra64.h" +#include "libu64/pad.h" #include "irqmgr.h" #include "versions.h" @@ -11,13 +12,6 @@ typedef enum ControllerPakType { CONT_PAK_OTHER } ControllerPakType; -typedef struct Input { - /* 0x00 */ OSContPad cur; - /* 0x06 */ OSContPad prev; - /* 0x0C */ OSContPad press; // X/Y store delta from last frame - /* 0x12 */ OSContPad rel; // X/Y store adjusted -} Input; // size = 0x18 - typedef struct PadMgr { /* 0x0000 */ OSContStatus padStatus[MAXCONTROLLERS]; /* 0x0010 */ OSMesg serialMsg; diff --git a/include/z64.h b/include/z64.h index ecaa19715f..e7677a8eec 100644 --- a/include/z64.h +++ b/include/z64.h @@ -54,7 +54,7 @@ #include "sequence.h" #include "sfx.h" #include "color.h" -#include "gfxprint.h" +#include "libu64/gfxprint.h" #include "z_lib.h" #include "ichain.h" #include "regs.h" @@ -86,6 +86,7 @@ #include "libc64/malloc.h" #include "libc64/sleep.h" #include "libc64/sprintf.h" +#include "libu64/debug.h" #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c index b708a54dd0..c8183fc7c4 100644 --- a/src/boot/z_std_dma.c +++ b/src/boot/z_std_dma.c @@ -28,7 +28,7 @@ #endif #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.2:66 pal-1.0:64 pal-1.1:64" + "ntsc-1.2:64 pal-1.0:62 pal-1.1:62" StackEntry sDmaMgrStackInfo; OSMesgQueue sDmaMgrMsgQueue; diff --git a/src/code/main.c b/src/code/main.c index 6e6e3026c4..d4c54b6870 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -24,7 +24,7 @@ extern struct IrqMgr gIrqMgr; #endif #pragma increment_block_number "gc-eu:144 gc-eu-mq:144 gc-jp:144 gc-jp-ce:144 gc-jp-mq:144 gc-us:144 gc-us-mq:144" \ - "ntsc-1.0:127 ntsc-1.1:127 ntsc-1.2:127 pal-1.0:125 pal-1.1:125" + "ntsc-1.0:125 ntsc-1.1:125 ntsc-1.2:125 pal-1.0:123 pal-1.1:123" extern u8 _buffersSegmentEnd[]; diff --git a/src/code/padmgr.c b/src/code/padmgr.c index b5f76b7217..740f15b29a 100644 --- a/src/code/padmgr.c +++ b/src/code/padmgr.c @@ -28,7 +28,9 @@ * `osContStartReadData` to receiving the data. By running this on a separate thread to the game state, work can be * done while waiting for this operation to complete. */ -#include "global.h" +#include "libu64/debug.h" +#include "libu64/padsetup.h" +#include "macros.h" #include "fault.h" #include "terminal.h" #include "line_numbers.h" diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index 0a773bfb69..fc37a98c61 100644 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -5,7 +5,7 @@ #include "macros.h" #include "sys_math3d.h" -#pragma increment_block_number "gc-eu:98 gc-eu-mq:98 gc-jp:98 gc-jp-ce:98 gc-jp-mq:98 gc-us:98 gc-us-mq:98" \ +#pragma increment_block_number "gc-eu:97 gc-eu-mq:97 gc-jp:97 gc-jp-ce:97 gc-jp-mq:97 gc-us:97 gc-us-mq:97" \ "ntsc-1.0:80 ntsc-1.1:80 ntsc-1.2:79 pal-1.0:80 pal-1.1:80" s32 Math3D_LineVsLineClosestTwoPoints(Vec3f* lineAPointA, Vec3f* lineAPointB, Vec3f* lineBPointA, Vec3f* lineBPointB, diff --git a/src/code/z_camera.c b/src/code/z_camera.c index f36aba0d7d..e528431a20 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -3639,7 +3639,7 @@ s32 Camera_KeepOn3(Camera* camera) { } #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.0:129 ntsc-1.1:129 ntsc-1.2:129 pal-1.0:127 pal-1.1:127" + "ntsc-1.0:127 ntsc-1.1:127 ntsc-1.2:127 pal-1.0:125 pal-1.1:125" s32 Camera_KeepOn4(Camera* camera) { static Vec3f D_8015BD50; diff --git a/src/libu64/pad.c b/src/libu64/pad.c index 7a0407ef96..551cd495b9 100644 --- a/src/libu64/pad.c +++ b/src/libu64/pad.c @@ -1,4 +1,5 @@ -#include "global.h" +#include "ultra64.h" +#include "libu64/pad.h" void PadUtils_Init(Input* input) { bzero(input, sizeof(Input)); diff --git a/src/libu64/padsetup.c b/src/libu64/padsetup.c index 20a546ae3f..86f38c0adf 100644 --- a/src/libu64/padsetup.c +++ b/src/libu64/padsetup.c @@ -1,4 +1,4 @@ -#include "global.h" +#include "ultra64.h" s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status) { s32 ret; diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index 5f995aa721..2a3a592fc6 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -35,7 +35,7 @@ #include "cic6105.h" #endif -#pragma increment_block_number "gc-eu:163 gc-eu-mq:163 gc-jp:163 gc-jp-ce:163 gc-jp-mq:163 gc-us:163 gc-us-mq:163" \ +#pragma increment_block_number "gc-eu:162 gc-eu-mq:162 gc-jp:162 gc-jp-ce:162 gc-jp-mq:162 gc-us:162 gc-us-mq:162" \ "ntsc-1.0:121 ntsc-1.1:121 ntsc-1.2:121 pal-1.0:121 pal-1.1:121" #define FLAGS ACTOR_FLAG_UPDATE_CULLING_DISABLED diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index c1f3fe2c58..9b2c99848d 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -332,7 +332,7 @@ void Player_Action_CsAction(Player* this, PlayState* play); // .bss part 1 #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:128 pal-1.1:128" + "ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:64 pal-1.1:64" static s32 D_80858AA0;