diff --git a/include/CIC6105.h b/include/CIC6105.h new file mode 100644 index 0000000000..09a363a4d5 --- /dev/null +++ b/include/CIC6105.h @@ -0,0 +1,21 @@ +#ifndef CIC6105_H +#define CIC6105_H + +#include "ultra64.h" + +// IPL3 puts values in those addresses as part of the anti-piracy checks +#define CIC_ADDRESS_1 0x002FB1F4 +#define CIC_ADDRESS_2 0x002FE1C0 + + +void CIC6105_Noop1(void); +void CIC6105_Noop2(void); +void CIC6105_PrintRomInfo(void); +void CIC6105_AddRomInfoFaultPage(void); +void CIC6105_Destroy(void); +void CIC6105_Init(void); + +extern s32 gCICAddr1Val; +extern s32 gCICAddr2Val; + +#endif diff --git a/include/build.h b/include/build.h new file mode 100644 index 0000000000..5099e5d3c5 --- /dev/null +++ b/include/build.h @@ -0,0 +1,8 @@ +#ifndef BUILD_H +#define BUILD_H + +extern char gBuildTeam[]; +extern char gBuildDate[]; +extern char gBuildMakeOption[]; + +#endif diff --git a/include/functions.h b/include/functions.h index 00e992e9e7..c24ab583d4 100644 --- a/include/functions.h +++ b/include/functions.h @@ -34,13 +34,9 @@ void IrqMgr_HandlePRENMI500(IrqMgr* irqmgr); void IrqMgr_HandleRetrace(IrqMgr* irqmgr); void IrqMgr_ThreadEntry(IrqMgr* irqmgr); void IrqMgr_Init(IrqMgr* irqmgr, void* stack, OSPri pri, u8 retraceCount); -void CIC6105_Nop80081820(void); -void CIC6105_Nop80081828(void); -void CIC6105_PrintRomInfo(void); -void CIC6105_AddRomInfoFaultPage(void); -void CIC6105_RemoveRomInfoFaultPage(void); -void func_800818F4(void); + void osSyncPrintfUnused(const char* fmt, ...); + void rmonPrintf(const char* fmt, ...); void RcpUtils_PrintRegisterStatus(void); diff --git a/include/variables.h b/include/variables.h index fdc9e91b0d..e071b20366 100644 --- a/include/variables.h +++ b/include/variables.h @@ -24,19 +24,12 @@ extern s32 sIrqMgrRetraceCount; // extern UNK_TYPE4 D_80097524; // extern u32 sRandInt; -extern char gBuildTeam[]; -extern char gBuildDate[]; -extern char gBuildMakeOption[]; - extern u8 sYaz0DataBuffer[0x400]; extern u8* sYaz0CurDataEnd; extern u32 sYaz0CurRomStart; extern u32 sYaz0CurSize; extern u8* sYaz0MaxPtr; extern void* gYaz0DecompressDstEnd; -// extern UNK_TYPE4 D_8009BE30; -// extern UNK_TYPE4 D_8009BE34; -// extern FaultClient romInfoFaultClient; // extern UNK_TYPE4 D_8009CD10; extern u32 sRandFloat; diff --git a/src/boot/CIC6105.c b/src/boot/CIC6105.c index e18223b034..f42edf656f 100644 --- a/src/boot/CIC6105.c +++ b/src/boot/CIC6105.c @@ -1,32 +1,33 @@ #include "prevent_bss_reordering.h" -#include "global.h" +#include "CIC6105.h" +#include "build.h" #include "fault.h" -UNK_TYPE4 D_8009BE30; -UNK_TYPE4 D_8009BE34; -FaultClient romInfoFaultClient; +s32 gCICAddr1Val; +s32 gCICAddr2Val; +FaultClient sRomInfoFaultClient; -void CIC6105_Nop80081820(void) { +void CIC6105_Noop1(void) { } -void CIC6105_Nop80081828(void) { +void CIC6105_Noop2(void) { } void CIC6105_PrintRomInfo(void) { - FaultDrawer_DrawText(80, 200, "SP_STATUS %08x", HW_REG(SP_STATUS_REG, u32)); + FaultDrawer_DrawText(80, 200, "SP_STATUS %08x", IO_READ(SP_STATUS_REG)); FaultDrawer_DrawText(40, 184, "ROM_F [Creator:%s]", gBuildTeam); FaultDrawer_DrawText(56, 192, "[Date:%s]", gBuildDate); } void CIC6105_AddRomInfoFaultPage(void) { - Fault_AddClient(&romInfoFaultClient, (void*)CIC6105_PrintRomInfo, NULL, NULL); + Fault_AddClient(&sRomInfoFaultClient, (void*)CIC6105_PrintRomInfo, NULL, NULL); } -void CIC6105_RemoveRomInfoFaultPage(void) { - Fault_RemoveClient(&romInfoFaultClient); +void CIC6105_Destroy(void) { + Fault_RemoveClient(&sRomInfoFaultClient); } -void func_800818F4(void) { - D_8009BE30 = *(u32*)0xA02FB1F4; - D_8009BE34 = *(u32*)0xA02FE1C0; +void CIC6105_Init(void) { + gCICAddr1Val = IO_READ(CIC_ADDRESS_1); + gCICAddr2Val = IO_READ(CIC_ADDRESS_2); } diff --git a/src/boot/boot_main.c b/src/boot/boot_main.c index dcb66fefd5..cc2097f0f6 100644 --- a/src/boot/boot_main.c +++ b/src/boot/boot_main.c @@ -3,6 +3,7 @@ #include "idle.h" #include "stack.h" #include "stackcheck.h" +#include "CIC6105.h" #include "z64thread.h" StackEntry sBootStackInfo; @@ -14,7 +15,7 @@ STACK(sBootStack, 0x400); void bootproc(void) { StackCheck_Init(&sBootStackInfo, sBootStack, STACK_TOP(sBootStack), 0, -1, "boot"); osMemSize = osGetMemSize(); - func_800818F4(); + CIC6105_Init(); osInitialize(); osUnmapTLBAll(); gCartHandle = osCartRomInit(); diff --git a/src/code/main.c b/src/code/main.c index 7fbb7ccb8f..d3840eca5e 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -4,6 +4,7 @@ #include "irqmgr.h" #include "padmgr.h" #include "scheduler.h" +#include "CIC6105.h" #include "stack.h" #include "stackcheck.h" diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index 4e9b7a162b..b8967e3292 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -4,6 +4,7 @@ * Description: Seahorse */ +#include "prevent_bss_reordering.h" #include "z_en_ot.h" #include "objects/object_ot/object_ot.h" #include "objects/gameplay_keep/gameplay_keep.h" diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 21f034e12e..c829e79a94 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -7,6 +7,7 @@ #include "z_title.h" #include "z64shrink_window.h" #include "z64view.h" +#include "CIC6105.h" #include "overlays/gamestates/ovl_opening/z_opening.h" #include "misc/nintendo_rogo_static/nintendo_rogo_static.h" @@ -146,7 +147,7 @@ void ConsoleLogo_Destroy(GameState* thisx) { Sram_InitSram(&this->state, &this->sramCtx); ShrinkWindow_Destroy(); - CIC6105_Nop80081828(); + CIC6105_Noop2(); } void ConsoleLogo_Init(GameState* thisx) { diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4ddf144d5b..c8330232d3 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -40,12 +40,12 @@ 0x800815CC:("IrqMgr_HandleRetrace",), 0x80081684:("IrqMgr_ThreadEntry",), 0x80081754:("IrqMgr_Init",), - 0x80081820:("CIC6105_Nop80081820",), - 0x80081828:("CIC6105_Nop80081828",), + 0x80081820:("CIC6105_Noop1",), + 0x80081828:("CIC6105_Noop2",), 0x80081830:("CIC6105_PrintRomInfo",), 0x8008189C:("CIC6105_AddRomInfoFaultPage",), - 0x800818D0:("CIC6105_RemoveRomInfoFaultPage",), - 0x800818F4:("func_800818F4",), + 0x800818D0:("CIC6105_Destroy",), + 0x800818F4:("CIC6105_Init",), 0x80081920:("osSyncPrintfUnused",), 0x8008193C:("osSyncPrintf",), 0x80081958:("rmonPrintf",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index d0ad05d818..4b224cf3fc 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -310,9 +310,9 @@ 0x8009BE18:("sYaz0CurSize","u32","",0x4), 0x8009BE1C:("sYaz0MaxPtr","u8*","",0x4), 0x8009BE20:("gYaz0DecompressDstEnd","void*","",0x4), - 0x8009BE30:("D_8009BE30","UNK_TYPE4","",0x4), - 0x8009BE34:("D_8009BE34","UNK_TYPE4","",0x4), - 0x8009BE38:("romInfoFaultClient","FaultClient","",0x10), + 0x8009BE30:("gCICAddr1Val","UNK_TYPE4","",0x4), + 0x8009BE34:("gCICAddr2Val","UNK_TYPE4","",0x4), + 0x8009BE38:("sRomInfoFaultClient","FaultClient","",0x10), 0x8009BE50:("sFaultInstance","FaultMgr*","",0x4), 0x8009BE54:("sFaultTimeTotal","f32","",0x4), 0x8009BE58:("faultCustomOptions","u32","",0x4), diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index 61a69fe7fc..47bc17b62a 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -37,12 +37,12 @@ asm/non_matchings/boot/irqmgr/IrqMgr_HandlePRENMI500.s,IrqMgr_HandlePRENMI500,0x asm/non_matchings/boot/irqmgr/IrqMgr_HandleRetrace.s,IrqMgr_HandleRetrace,0x800815CC,0x2E asm/non_matchings/boot/irqmgr/IrqMgr_ThreadEntry.s,IrqMgr_ThreadEntry,0x80081684,0x34 asm/non_matchings/boot/irqmgr/IrqMgr_Init.s,IrqMgr_Init,0x80081754,0x33 -asm/non_matchings/boot/CIC6105/CIC6105_Nop80081820.s,CIC6105_Nop80081820,0x80081820,0x2 -asm/non_matchings/boot/CIC6105/CIC6105_Nop80081828.s,CIC6105_Nop80081828,0x80081828,0x2 +asm/non_matchings/boot/CIC6105/CIC6105_Noop1.s,CIC6105_Noop1,0x80081820,0x2 +asm/non_matchings/boot/CIC6105/CIC6105_Noop2.s,CIC6105_Noop2,0x80081828,0x2 asm/non_matchings/boot/CIC6105/CIC6105_PrintRomInfo.s,CIC6105_PrintRomInfo,0x80081830,0x1B asm/non_matchings/boot/CIC6105/CIC6105_AddRomInfoFaultPage.s,CIC6105_AddRomInfoFaultPage,0x8008189C,0xD -asm/non_matchings/boot/CIC6105/CIC6105_RemoveRomInfoFaultPage.s,CIC6105_RemoveRomInfoFaultPage,0x800818D0,0x9 -asm/non_matchings/boot/CIC6105/func_800818F4.s,func_800818F4,0x800818F4,0xB +asm/non_matchings/boot/CIC6105/CIC6105_Destroy.s,CIC6105_Destroy,0x800818D0,0x9 +asm/non_matchings/boot/CIC6105/CIC6105_Init.s,CIC6105_Init,0x800818F4,0xB asm/non_matchings/boot/syncprintf/osSyncPrintfUnused.s,osSyncPrintfUnused,0x80081920,0x7 asm/non_matchings/boot/syncprintf/osSyncPrintf.s,osSyncPrintf,0x8008193C,0x7 asm/non_matchings/boot/syncprintf/rmonPrintf.s,rmonPrintf,0x80081958,0xA