From 5ddb3e68b6f7a08d7c670402168d52969933dc5f Mon Sep 17 00:00:00 2001 From: fig02 Date: Sat, 22 Feb 2025 14:01:09 -0500 Subject: [PATCH] Clean out z64.h (#2484) * Clean out z64.h * fix version include * overlay.h * pr suggestion * try fixing main.c * add back forward declare * fix bss * header guard * prefix --- include/functions.h | 19 +-- include/libu64/overlay.h | 40 ++++++ include/prenmi_buff.h | 25 ++++ include/variables.h | 2 - include/vi_mode.h | 45 +++++++ include/z64.h | 118 +----------------- include/z64game.h | 17 +++ src/boot/is_debug.c | 9 ++ src/boot/yaz0.c | 7 ++ src/boot/z_locale.c | 13 ++ src/boot/z_std_dma.c | 2 +- src/code/fault_gc.c | 4 +- src/code/fault_n64.c | 2 +- src/code/game.c | 1 + src/code/graph.c | 5 +- src/code/main.c | 5 +- src/code/z_DLF.c | 2 + src/code/z_actor.c | 1 + src/code/z_bgcheck.c | 2 +- src/code/z_camera.c | 2 +- src/code/z_demo.c | 6 +- src/code/z_effect_soft_sprite.c | 1 + src/code/z_kaleido_manager.c | 2 + src/code/z_kaleido_scope_call.c | 4 +- src/code/z_kankyo.c | 2 +- src/code/z_map_mark.c | 1 + src/code/z_message.c | 2 +- src/code/z_play.c | 2 +- src/code/z_prenmi_buff.c | 1 + src/code/z_vimode.c | 2 + src/libu64/load_gc.c | 2 + src/libu64/loadfragment2_gc.c | 2 + src/libu64/loadfragment2_n64.c | 2 + src/libu64/relocation_gc.c | 2 + src/n64dd/z_n64dd.c | 2 +- .../misc/ovl_kaleido_scope/z_kaleido_scope.c | 2 +- 36 files changed, 199 insertions(+), 157 deletions(-) create mode 100644 include/libu64/overlay.h create mode 100644 include/prenmi_buff.h create mode 100644 include/vi_mode.h diff --git a/include/functions.h b/include/functions.h index 45b60ca292..0a8af7f550 100644 --- a/include/functions.h +++ b/include/functions.h @@ -42,20 +42,8 @@ void* MemCpy(void* dest, const void* src, s32 len); void MapMark_Init(PlayState* play); void MapMark_ClearPointers(PlayState* play); void MapMark_Draw(PlayState* play); -void PreNmiBuff_Init(PreNmiBuff* this); -void PreNmiBuff_SetReset(PreNmiBuff* this); -u32 PreNmiBuff_IsResetting(PreNmiBuff* this); void Sched_FlushTaskQueue(void); -void ViMode_LogPrint(OSViMode* osViMode); -void ViMode_Configure(ViMode* viMode, s32 type, s32 tvType, s32 loRes, s32 antialiasOff, s32 modeN, s32 fb16Bit, - s32 width, s32 height, s32 leftAdjust, s32 rightAdjust, s32 upperAdjust, s32 lowerAdjust); -void ViMode_Save(ViMode* viMode); -void ViMode_Load(ViMode* viMode); -void ViMode_Init(ViMode* viMode); -void ViMode_Destroy(ViMode* viMode); -void ViMode_ConfigureFeatures(ViMode* viMode, s32 viFeatures); -void ViMode_Update(ViMode* viMode, Input* input); void PlayerCall_InitFuncPtrs(void); void TransitionTile_Destroy(TransitionTile* this); TransitionTile* TransitionTile_Init(TransitionTile* this, s32 cols, s32 rows); @@ -137,12 +125,7 @@ void func_800D3210(void); void RcpUtils_PrintRegisterStatus(void); void RcpUtils_Reset(void); -void* Overlay_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd); -void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelocs, void* vramStart); -size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd, void* allocatedRamAddr); -// ? func_800FC800(?); -// ? func_800FC83C(?); -// ? func_800FCAB4(?); + void SystemHeap_Init(void* start, u32 size); f32 absf(f32); diff --git a/include/libu64/overlay.h b/include/libu64/overlay.h new file mode 100644 index 0000000000..258dfba772 --- /dev/null +++ b/include/libu64/overlay.h @@ -0,0 +1,40 @@ +#ifndef LIBU64_OVERLAY_H +#define LIBU64_OVERLAY_H + +#include "ultra64.h" + +/* Relocation entry field getters */ +#define RELOC_SECTION(reloc) ((reloc) >> 30) +#define RELOC_OFFSET(reloc) ((reloc) & 0xFFFFFF) +#define RELOC_TYPE_MASK(reloc) ((reloc) & 0x3F000000) +#define RELOC_TYPE_SHIFT 24 + +/* MIPS Relocation Types, matches the MIPS ELF spec */ +#define R_MIPS_32 2 +#define R_MIPS_26 4 +#define R_MIPS_HI16 5 +#define R_MIPS_LO16 6 + +/* Reloc section id, must fit in 2 bits otherwise the relocation format must be modified */ +typedef enum RelocSectionId { + /* 0 */ RELOC_SECTION_NULL, + /* 1 */ RELOC_SECTION_TEXT, + /* 2 */ RELOC_SECTION_DATA, + /* 3 */ RELOC_SECTION_RODATA, + /* 4 */ RELOC_SECTION_MAX +} RelocSectionId; + +typedef struct OverlayRelocationSection { + /* 0x00 */ u32 textSize; + /* 0x04 */ u32 dataSize; + /* 0x08 */ u32 rodataSize; + /* 0x0C */ u32 bssSize; + /* 0x10 */ u32 nRelocations; + /* 0x14 */ u32 relocations[1]; // size is nRelocations +} OverlayRelocationSection; // size >= 0x18 + +void* Overlay_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd); +void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelocs, void* vramStart); +size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd, void* allocatedRamAddr); + +#endif diff --git a/include/prenmi_buff.h b/include/prenmi_buff.h new file mode 100644 index 0000000000..b0a9e66f72 --- /dev/null +++ b/include/prenmi_buff.h @@ -0,0 +1,25 @@ +#ifndef PRENMI_BUFF_H +#define PRENMI_BUFF_H + +#include "ultra64.h" +#include "alignment.h" + +// This struct is used at osAppNMIBuffer which is not at an 8-byte aligned address. This causes an unaligned access +// crash if the OSTime variables use 64-bit load/store instructions, which is the case in any MIPS ABI other than O32 +// where 64-bit load/store instructions are emulated with 2x 32-bit load/store instructions. The alignment attribute +// conveys that this structure will not always be 8-bytes aligned, allowing a modern compiler to generate non-crashing +// code for accessing these. This is not an issue in the original compiler as it only output O32 ABI code. +ALIGNED(4) typedef struct PreNmiBuff { + /* 0x00 */ u32 resetting; + /* 0x04 */ u32 resetCount; + /* 0x08 */ OSTime duration; + /* 0x10 */ OSTime resetTime; +} PreNmiBuff; // size = 0x18 (actually osAppNMIBuffer is 0x40 bytes large but the rest is unused) + +extern PreNmiBuff* gAppNmiBufferPtr; + +void PreNmiBuff_Init(PreNmiBuff* this); +void PreNmiBuff_SetReset(PreNmiBuff* this); +u32 PreNmiBuff_IsResetting(PreNmiBuff* this); + +#endif diff --git a/include/variables.h b/include/variables.h index c6e70eb262..f4ecad468a 100644 --- a/include/variables.h +++ b/include/variables.h @@ -68,7 +68,6 @@ extern u32 __osTimerCounter; extern EffectSsOverlay gEffectSsOverlayTable[EFFECT_SS_TYPE_MAX]; extern ActorOverlay gActorOverlayTable[ACTOR_ID_MAX]; // original name: "actor_dlftbls" 801162A0 extern s32 gMaxActorId; // original name: "MaxProfile" -extern GameStateOverlay gGameStateOverlayTable[GAMESTATE_ID_MAX]; extern s32 gZeldaArenaLogSeverity; extern MapData gMapDataTable; extern s16 gSpoilingItems[3]; @@ -153,7 +152,6 @@ extern f32 gBossMarkScale; extern u32 D_8016139C; extern PauseMapMarksData* gLoadedPauseMarkDataTable; -extern PreNmiBuff* gAppNmiBufferPtr; extern Scheduler gScheduler; extern PadMgr gPadMgr; extern IrqMgr gIrqMgr; diff --git a/include/vi_mode.h b/include/vi_mode.h new file mode 100644 index 0000000000..89de610a88 --- /dev/null +++ b/include/vi_mode.h @@ -0,0 +1,45 @@ +#ifndef VI_MODE_H +#define VI_MODE_H + +#include "ultra64.h" +#include "libu64/pad.h" +#include "versions.h" + +typedef enum ViModeEditState { +#if OOT_VERSION < PAL_1_0 + /* -2 */ VI_MODE_EDIT_STATE_NEGATIVE_2 = -2, + /* -1 */ VI_MODE_EDIT_STATE_NEGATIVE_1, + /* 0 */ VI_MODE_EDIT_STATE_INACTIVE, + /* 1 */ VI_MODE_EDIT_STATE_2, // active, more adjustments + /* 2 */ VI_MODE_EDIT_STATE_3 // active, more adjustments, print comparison with NTSC LAN1 mode +#else + /* 0 */ VI_MODE_EDIT_STATE_INACTIVE, + /* 1 */ VI_MODE_EDIT_STATE_ACTIVE, + /* 2 */ VI_MODE_EDIT_STATE_2, // active, more adjustments + /* 3 */ VI_MODE_EDIT_STATE_3 // active, more adjustments, print comparison with NTSC LAN1 mode +#endif +} ViModeEditState; + +typedef struct ViMode { + /* 0x00 */ OSViMode customViMode; + /* 0x50 */ s32 viHeight; + /* 0x54 */ s32 viWidth; + /* 0x58 */ s32 rightAdjust; + /* 0x5C */ s32 leftAdjust; + /* 0x60 */ s32 lowerAdjust; + /* 0x64 */ s32 upperAdjust; + /* 0x68 */ s32 editState; + /* 0x6C */ s32 tvType; + /* 0x70 */ u32 loRes; + /* 0x74 */ u32 antialiasOff; + /* 0x78 */ u32 modeN; // Controls interlacing, the meaning of this mode is different based on choice of resolution + /* 0x7C */ u32 fb16Bit; + /* 0x80 */ u32 viFeatures; + /* 0x84 */ u32 unk_84; +} ViMode; // size = 0x88 + +void ViMode_Init(ViMode* viMode); +void ViMode_Destroy(ViMode* viMode); +void ViMode_Update(ViMode* viMode, Input* input); + +#endif diff --git a/include/z64.h b/include/z64.h index 5963e7d240..64bb5984ce 100644 --- a/include/z64.h +++ b/include/z64.h @@ -58,122 +58,6 @@ #include "libc64/sprintf.h" #include "libu64/debug.h" -typedef struct GameStateOverlay { - /* 0x00 */ void* loadedRamAddr; - /* 0x04 */ RomFile file; // if applicable - /* 0x0C */ void* vramStart; // if applicable - /* 0x10 */ void* vramEnd; // if applicable - /* 0x14 */ void* unk_14; - /* 0x18 */ void* init; // initializes and executes the given context - /* 0x1C */ void* destroy; // deconstructs the context, and sets the next context to load - /* 0x20 */ void* unk_20; - /* 0x24 */ void* unk_24; - /* 0x28 */ UNK_TYPE4 unk_28; - /* 0x2C */ u32 instanceSize; -} GameStateOverlay; // size = 0x30 - -typedef struct ISVDbg { - /* 0x00 */ u32 magic; // IS64 - /* 0x04 */ u32 get; - /* 0x08 */ u8 unk_08[0x14-0x08]; - /* 0x14 */ u32 put; - /* 0x18 */ u8 unk_18[0x20-0x18]; - /* 0x20 */ u8 data[0x10000-0x20]; -} ISVDbg; - -typedef struct LocaleCartInfo { - /* 0x00 */ char name[0x18]; - /* 0x18 */ u32 mediaFormat; - /* 0x1C */ union { - struct { - u16 cartId; - u8 countryCode; - u8 version; - }; - u32 regionInfo; - }; -} LocaleCartInfo; // size = 0x20 - -typedef struct Yaz0Header { - /* 0x00 */ char magic[4]; // Yaz0 - /* 0x04 */ u32 decSize; - /* 0x08 */ u32 compInfoOffset; // only used in mio0 - /* 0x0C */ u32 uncompDataOffset; // only used in mio0 -} Yaz0Header; // size = 0x10 - -/* Relocation entry field getters */ -#define RELOC_SECTION(reloc) ((reloc) >> 30) -#define RELOC_OFFSET(reloc) ((reloc) & 0xFFFFFF) -#define RELOC_TYPE_MASK(reloc) ((reloc) & 0x3F000000) -#define RELOC_TYPE_SHIFT 24 - -/* MIPS Relocation Types, matches the MIPS ELF spec */ -#define R_MIPS_32 2 -#define R_MIPS_26 4 -#define R_MIPS_HI16 5 -#define R_MIPS_LO16 6 - -/* Reloc section id, must fit in 2 bits otherwise the relocation format must be modified */ -typedef enum RelocSectionId { - /* 0 */ RELOC_SECTION_NULL, - /* 1 */ RELOC_SECTION_TEXT, - /* 2 */ RELOC_SECTION_DATA, - /* 3 */ RELOC_SECTION_RODATA, - /* 4 */ RELOC_SECTION_MAX -} RelocSectionId; - -typedef struct OverlayRelocationSection { - /* 0x00 */ u32 textSize; - /* 0x04 */ u32 dataSize; - /* 0x08 */ u32 rodataSize; - /* 0x0C */ u32 bssSize; - /* 0x10 */ u32 nRelocations; - /* 0x14 */ u32 relocations[1]; // size is nRelocations -} OverlayRelocationSection; // size >= 0x18 - -// This struct is used at osAppNMIBuffer which is not at an 8-byte aligned address. This causes an unaligned access -// crash if the OSTime variables use 64-bit load/store instructions, which is the case in any MIPS ABI other than O32 -// where 64-bit load/store instructions are emulated with 2x 32-bit load/store instructions. The alignment attribute -// conveys that this structure will not always be 8-bytes aligned, allowing a modern compiler to generate non-crashing -// code for accessing these. This is not an issue in the original compiler as it only output O32 ABI code. -ALIGNED(4) typedef struct PreNmiBuff { - /* 0x00 */ u32 resetting; - /* 0x04 */ u32 resetCount; - /* 0x08 */ OSTime duration; - /* 0x10 */ OSTime resetTime; -} PreNmiBuff; // size = 0x18 (actually osAppNMIBuffer is 0x40 bytes large but the rest is unused) - -typedef enum ViModeEditState { -#if OOT_VERSION < PAL_1_0 - /* -2 */ VI_MODE_EDIT_STATE_NEGATIVE_2 = -2, - /* -1 */ VI_MODE_EDIT_STATE_NEGATIVE_1, - /* 0 */ VI_MODE_EDIT_STATE_INACTIVE, - /* 1 */ VI_MODE_EDIT_STATE_2, // active, more adjustments - /* 2 */ VI_MODE_EDIT_STATE_3 // active, more adjustments, print comparison with NTSC LAN1 mode -#else - /* 0 */ VI_MODE_EDIT_STATE_INACTIVE, - /* 1 */ VI_MODE_EDIT_STATE_ACTIVE, - /* 2 */ VI_MODE_EDIT_STATE_2, // active, more adjustments - /* 3 */ VI_MODE_EDIT_STATE_3 // active, more adjustments, print comparison with NTSC LAN1 mode -#endif -} ViModeEditState; - -typedef struct ViMode { - /* 0x00 */ OSViMode customViMode; - /* 0x50 */ s32 viHeight; - /* 0x54 */ s32 viWidth; - /* 0x58 */ s32 rightAdjust; - /* 0x5C */ s32 leftAdjust; - /* 0x60 */ s32 lowerAdjust; - /* 0x64 */ s32 upperAdjust; - /* 0x68 */ s32 editState; - /* 0x6C */ s32 tvType; - /* 0x70 */ u32 loRes; - /* 0x74 */ u32 antialiasOff; - /* 0x78 */ u32 modeN; // Controls interlacing, the meaning of this mode is different based on choice of resolution - /* 0x7C */ u32 fb16Bit; - /* 0x80 */ u32 viFeatures; - /* 0x84 */ u32 unk_84; -} ViMode; // size = 0x88 +// TODO: include all files listed above into the right place, and then delete this file. #endif diff --git a/include/z64game.h b/include/z64game.h index 32961fb453..72a8f501eb 100644 --- a/include/z64game.h +++ b/include/z64game.h @@ -5,6 +5,7 @@ #include "ultra64/ultratypes.h" #include "libu64/pad.h" #include "gamealloc.h" +#include "romfile.h" #include "tha.h" struct GraphicsContext; @@ -19,6 +20,22 @@ typedef enum GameStateId { #undef DEFINE_GAMESTATE #undef DEFINE_GAMESTATE_INTERNAL +typedef struct GameStateOverlay { + /* 0x00 */ void* loadedRamAddr; + /* 0x04 */ RomFile file; // if applicable + /* 0x0C */ void* vramStart; // if applicable + /* 0x10 */ void* vramEnd; // if applicable + /* 0x14 */ void* unk_14; + /* 0x18 */ void* init; + /* 0x1C */ void* destroy; + /* 0x20 */ void* unk_20; + /* 0x24 */ void* unk_24; + /* 0x28 */ s32 unk_28; + /* 0x2C */ u32 instanceSize; +} GameStateOverlay; // size = 0x30 + +extern GameStateOverlay gGameStateOverlayTable[GAMESTATE_ID_MAX]; + struct GameState; typedef void (*GameStateFunc)(struct GameState* gameState); diff --git a/src/boot/is_debug.c b/src/boot/is_debug.c index 5415b8a7b3..1f8938f9de 100644 --- a/src/boot/is_debug.c +++ b/src/boot/is_debug.c @@ -1,5 +1,14 @@ #include "global.h" +typedef struct ISVDbg { + /* 0x00 */ u32 magic; // "IS64" + /* 0x04 */ u32 get; + /* 0x08 */ u8 unk_08[0xC]; + /* 0x14 */ u32 put; + /* 0x18 */ u8 unk_18[0x8]; + /* 0x20 */ u8 data[0xFFE0]; +} ISVDbg; // size = 0x10000 + #define gISVDbgPrnAdrs ((ISVDbg*)0xB3FF0000) #define ASCII_TO_U32(a, b, c, d) ((u32)((a << 24) | (b << 16) | (c << 8) | (d << 0))) diff --git a/src/boot/yaz0.c b/src/boot/yaz0.c index bb82d81734..2d6a4ec7c5 100644 --- a/src/boot/yaz0.c +++ b/src/boot/yaz0.c @@ -51,6 +51,13 @@ void* Yaz0_NextDMA(u8* curSrcPos) { return dst; } +typedef struct Yaz0Header { + /* 0x00 */ char magic[4]; // Yaz0 + /* 0x04 */ u32 decSize; + /* 0x08 */ u32 compInfoOffset; // only used in mio0 + /* 0x0C */ u32 uncompDataOffset; // only used in mio0 +} Yaz0Header; // size = 0x10 + void Yaz0_DecompressImpl(u8* src, u8* dst) { Yaz0Header* header = (Yaz0Header*)src; u32 bitIdx = 0; diff --git a/src/boot/z_locale.c b/src/boot/z_locale.c index f320f1e0f4..b6ce255c6a 100644 --- a/src/boot/z_locale.c +++ b/src/boot/z_locale.c @@ -6,6 +6,19 @@ s32 gCurrentRegion = 0; +typedef struct LocaleCartInfo { + /* 0x00 */ char name[0x18]; + /* 0x18 */ u32 mediaFormat; + /* 0x1C */ union { + struct { + u16 cartId; + u8 countryCode; + u8 version; + }; + u32 regionInfo; + }; +} LocaleCartInfo; // size = 0x20 + void Locale_Init(void) { #if !PLATFORM_GC ALIGNED(4) u8 regionInfo[4]; diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c index 8a11c1baf4..6d1d33cf69 100644 --- a/src/boot/z_std_dma.c +++ b/src/boot/z_std_dma.c @@ -33,7 +33,7 @@ #include "global.h" #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:46 pal-1.0:44 pal-1.1:44" + "ntsc-1.2:76 pal-1.0:74 pal-1.1:74" StackEntry sDmaMgrStackInfo; OSMesgQueue sDmaMgrMsgQueue; diff --git a/src/code/fault_gc.c b/src/code/fault_gc.c index 45d2d01b82..f1f1000715 100644 --- a/src/code/fault_gc.c +++ b/src/code/fault_gc.c @@ -40,8 +40,8 @@ * DPad-Up may be pressed to enable sending fault pages over osSyncPrintf as well as displaying them on-screen. * DPad-Down disables sending fault pages over osSyncPrintf. */ -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-eu-mq-dbg:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128" \ - "gc-us-mq:128 ique-cn:128" +#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-eu-mq-dbg:160 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160" \ + "gc-us-mq:160 ique-cn:160" #include "global.h" #include "libc64/sleep.h" diff --git a/src/code/fault_n64.c b/src/code/fault_n64.c index bb9559f128..feb884716e 100644 --- a/src/code/fault_n64.c +++ b/src/code/fault_n64.c @@ -13,7 +13,7 @@ #include "macros.h" #include "global.h" -#pragma increment_block_number "ntsc-1.0:160 ntsc-1.1:160 ntsc-1.2:160 pal-1.0:160 pal-1.1:160" +#pragma increment_block_number "ntsc-1.0:192 ntsc-1.1:192 ntsc-1.2:192 pal-1.0:192 pal-1.1:192" typedef struct FaultMgr { OSThread thread; diff --git a/src/code/game.c b/src/code/game.c index 2e9e9e2d5b..3f5dfb7ebb 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -18,6 +18,7 @@ #include "speed_meter.h" #include "terminal.h" #include "versions.h" +#include "vi_mode.h" #include "z64debug.h" #include "z64game.h" #include "z64vis.h" diff --git a/src/code/graph.c b/src/code/graph.c index 36749697f2..de9ecd9005 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -9,6 +9,7 @@ #include "file_select_state.h" #include "line_numbers.h" #include "map_select_state.h" +#include "prenmi_buff.h" #include "prenmi_state.h" #include "regs.h" #include "setup_state.h" @@ -26,8 +27,8 @@ #define GFXPOOL_HEAD_MAGIC 0x1234 #define GFXPOOL_TAIL_MAGIC 0x5678 -#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.0:192" \ - "ntsc-1.1:192 ntsc-1.2:192 pal-1.0:192 pal-1.1:192" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.0:224" \ + "ntsc-1.1:224 ntsc-1.2:224 pal-1.0:224 pal-1.1:224" /** * The time at which the previous `Graph_Update` ended. diff --git a/src/code/main.c b/src/code/main.c index cbc4677e7f..62cd22573e 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -14,6 +14,7 @@ extern struct IrqMgr gIrqMgr; #include "debug_arena.h" #include "fault.h" +#include "prenmi_buff.h" #include "segmented_address.h" #include "stack.h" #include "terminal.h" @@ -27,8 +28,8 @@ extern struct IrqMgr gIrqMgr; #include "global.h" -#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" \ - "ique-cn:128 ntsc-1.0:104 ntsc-1.1:104 ntsc-1.2:104 pal-1.0:102 pal-1.1:102" +#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" \ + "ique-cn:144 ntsc-1.0:129 ntsc-1.1:129 ntsc-1.2:129 pal-1.0:127 pal-1.1:127" extern u8 _buffersSegmentEnd[]; diff --git a/src/code/z_DLF.c b/src/code/z_DLF.c index f56fcc742b..7934b77456 100644 --- a/src/code/z_DLF.c +++ b/src/code/z_DLF.c @@ -1,3 +1,5 @@ +#include "libu64/overlay.h" + #include "global.h" #include "terminal.h" diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 155389b53f..7c62497590 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1,4 +1,5 @@ #include "libc64/math64.h" +#include "libu64/overlay.h" #include "fault.h" #include "gfx.h" #include "gfx_setupdl.h" diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index e0f8454f79..b54707fd6a 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -11,7 +11,7 @@ #include "z64player.h" #include "z64skin_matrix.h" -#pragma increment_block_number "ntsc-1.0:180 ntsc-1.1:180 ntsc-1.2:180" +#pragma increment_block_number "ntsc-1.0:176 ntsc-1.1:176 ntsc-1.2:176" u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* nodeList); void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector); diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 8b4b32762f..142d23aed6 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -3642,7 +3642,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" \ - "ique-cn:128 ntsc-1.0:79 ntsc-1.1:79 ntsc-1.2:79 pal-1.0:77 pal-1.1:77" + "ique-cn:128 ntsc-1.0:109 ntsc-1.1:109 ntsc-1.2:109 pal-1.0:107 pal-1.1:107" s32 Camera_KeepOn4(Camera* camera) { static Vec3f D_8015BD50; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 9db96e052d..50b049fc11 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,4 +1,4 @@ -#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \ +#pragma increment_block_number "gc-eu:0 gc-eu-mq:128 gc-jp:0 gc-jp-ce:0 gc-jp-mq:128 gc-us:0 gc-us-mq:128 ique-cn:0" \ "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" #include "global.h" #include "libu64/gfxprint.h" @@ -144,8 +144,8 @@ u16 gCamAtSplinePointsAppliedFrame; u16 gCamEyePointAppliedFrame; u16 gCamAtPointAppliedFrame; -#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" \ - "ique-cn:128 ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \ + "ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" // Cam ID to return to when a scripted cutscene is finished s16 sReturnToCamId; diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index 9a3df7eef3..d424191d29 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -1,3 +1,4 @@ +#include "libu64/overlay.h" #include "global.h" #include "terminal.h" diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.c index 42ec59fd0a..e1d7f55290 100644 --- a/src/code/z_kaleido_manager.c +++ b/src/code/z_kaleido_manager.c @@ -1,3 +1,5 @@ +#include "libu64/overlay.h" + #include "global.h" #include "terminal.h" diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index 50470ab02a..35e14433a1 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -1,5 +1,5 @@ -#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160 gc-us-mq:160" \ - "ique-cn:160 ntsc-1.0:192 ntsc-1.1:192 ntsc-1.2:192 pal-1.0:192 pal-1.1:192" +#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ + "ique-cn:192 ntsc-1.0:224 ntsc-1.1:224 ntsc-1.2:224 pal-1.0:224 pal-1.1:224" #include "libu64/debug.h" #include "kaleido_manager.h" diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 3656d71795..61285768ac 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -236,7 +236,7 @@ s16 sSunDepthTestX; s16 sSunDepthTestY; #pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:192 pal-1.1:192" + "ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:160 pal-1.1:160" LightNode* sNGameOverLightNode; LightInfo sNGameOverLightInfo; diff --git a/src/code/z_map_mark.c b/src/code/z_map_mark.c index 79e4f97ca3..d226d9e0ab 100644 --- a/src/code/z_map_mark.c +++ b/src/code/z_map_mark.c @@ -1,4 +1,5 @@ #include "libu64/debug.h" +#include "libu64/overlay.h" #include "regs.h" #include "romfile.h" #include "segment_symbols.h" diff --git a/src/code/z_message.c b/src/code/z_message.c index 5c5a513715..68d2086234 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -24,7 +24,7 @@ #include "assets/textures/parameter_static/parameter_static.h" #pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.0:160 ntsc-1.1:160 ntsc-1.2:160 pal-1.0:128 pal-1.1:128" + "ntsc-1.0:192 ntsc-1.1:192 ntsc-1.2:192 pal-1.0:128 pal-1.1:128" #if !PLATFORM_IQUE #define MSG_BUF_DECODED (msgCtx->msgBufDecoded) diff --git a/src/code/z_play.c b/src/code/z_play.c index 4657281a5f..095638be6b 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -36,7 +36,7 @@ #include "global.h" #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" \ - "ique-cn:192 ntsc-1.0:112 ntsc-1.1:112 ntsc-1.2:112 pal-1.0:112 pal-1.1:112" + "ique-cn:192 ntsc-1.0:144 ntsc-1.1:144 ntsc-1.2:144 pal-1.0:144 pal-1.1:144" TransitionTile gTransitionTile; s32 gTransitionTileState; diff --git a/src/code/z_prenmi_buff.c b/src/code/z_prenmi_buff.c index c00d0513c0..17ef0b78c9 100644 --- a/src/code/z_prenmi_buff.c +++ b/src/code/z_prenmi_buff.c @@ -1,3 +1,4 @@ +#include "prenmi_buff.h" #include "global.h" #define COLD_RESET 0 diff --git a/src/code/z_vimode.c b/src/code/z_vimode.c index 0d2f5716fa..668e9648e9 100644 --- a/src/code/z_vimode.c +++ b/src/code/z_vimode.c @@ -1,3 +1,5 @@ +#include "vi_mode.h" + #include "global.h" #include "ultra64/viint.h" #include "versions.h" diff --git a/src/libu64/load_gc.c b/src/libu64/load_gc.c index 39662cbcef..8d1ff315c5 100644 --- a/src/libu64/load_gc.c +++ b/src/libu64/load_gc.c @@ -1,3 +1,5 @@ +#include "libu64/overlay.h" + #include "global.h" size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd, void* allocatedRamAddr) { diff --git a/src/libu64/loadfragment2_gc.c b/src/libu64/loadfragment2_gc.c index 6befb8c9b9..477b7d1c28 100644 --- a/src/libu64/loadfragment2_gc.c +++ b/src/libu64/loadfragment2_gc.c @@ -1,3 +1,5 @@ +#include "libu64/overlay.h" + #include "global.h" void* Overlay_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd) { diff --git a/src/libu64/loadfragment2_n64.c b/src/libu64/loadfragment2_n64.c index 6a06b1ba09..b3d7751d8f 100644 --- a/src/libu64/loadfragment2_n64.c +++ b/src/libu64/loadfragment2_n64.c @@ -6,6 +6,8 @@ * * @see Overlay_Relocate */ +#include "libu64/overlay.h" + #include "global.h" s32 gOverlayLogSeverity = 2; diff --git a/src/libu64/relocation_gc.c b/src/libu64/relocation_gc.c index 1d2f3193da..a2961bcc51 100644 --- a/src/libu64/relocation_gc.c +++ b/src/libu64/relocation_gc.c @@ -6,6 +6,8 @@ * * @see Overlay_Relocate */ +#include "libu64/overlay.h" + #include "global.h" // Extract MIPS register rs from an instruction word diff --git a/src/n64dd/z_n64dd.c b/src/n64dd/z_n64dd.c index 864b67d822..1b6934f502 100644 --- a/src/n64dd/z_n64dd.c +++ b/src/n64dd/z_n64dd.c @@ -8,7 +8,7 @@ #include "line_numbers.h" #include "z64thread.h" -#pragma increment_block_number "ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:64 pal-1.1:64" +#pragma increment_block_number "ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" typedef struct struct_801D9C30 { /* 0x000 */ s32 unk_000; // disk start diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c index 6dee212069..634d7ed38b 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c @@ -20,7 +20,7 @@ #endif #include "assets/textures/icon_item_gameover_static/icon_item_gameover_static.h" -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" #if !PLATFORM_GC #define KALEIDO_PROMPT_CURSOR_R 100