From 3eb8137335555c432e5c403e7c1eff8d62a30e5a Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 18 Oct 2021 17:10:28 +1000 Subject: [PATCH] Tidy up sched.c and related functions --- docs/piracychecks.md | 8 +- include/PR/sched.h | 7 +- ld/libfiles.ntsc-beta.inc | 1 + ld/libfiles.ntsc-final.inc | 1 + ld/libfiles.pal-final.inc | 1 + src/game/cheats.c | 4 +- src/game/chr/chr.c | 4 +- src/game/chr/chraicommands.c | 2 +- src/game/credits.c | 8 +- src/game/endscreen.c | 8 +- src/game/game_01bea0.c | 64 ++++---- src/game/game_0b69d0.c | 2 +- src/game/game_0f09f0.c | 2 +- src/game/lv.c | 20 +-- src/game/mainmenu.c | 2 +- src/game/mplayer/mplayer.c | 2 +- src/game/pak/pak.c | 32 ++-- src/game/title.c | 4 +- src/include/bss.h | 6 +- src/include/constants.h | 18 +- src/include/data.h | 7 - src/include/lib/crash.h | 4 +- src/include/lib/main.h | 2 +- src/include/lib/sched.h | 8 +- src/include/lib/vi.h | 12 +- src/lib/audiomgr.c | 12 +- src/lib/boot.c | 6 +- src/lib/crash.c | 40 +++-- src/lib/joy.c | 50 +++--- src/lib/main.c | 97 +++++------ src/lib/pimgr.c | 4 +- src/lib/profile.c | 35 ++++ src/lib/rdp.c | 4 +- src/lib/sched.c | 299 ++++++++++++++++++++-------------- src/lib/ultra/io/gbpakinit.c | 8 +- src/lib/ultra/io/gbpakpower.c | 6 +- src/lib/vi.c | 30 ---- tools/asm_processor/build.py | 5 +- tools/patchpiracysums | 6 +- 39 files changed, 454 insertions(+), 377 deletions(-) create mode 100644 src/lib/profile.c diff --git a/docs/piracychecks.md b/docs/piracychecks.md index 56466a3fd..ec1e13ff3 100644 --- a/docs/piracychecks.md +++ b/docs/piracychecks.md @@ -16,7 +16,7 @@ The decomp project wraps all decompiled piracy checks in `#if PIRACYCHECKS` stat **Payload:** Goes into an infinite loop so the system never boots. -### __scHandleRetrace +### __scHandleTasks **When Called:** On every frame. @@ -28,9 +28,9 @@ The decomp project wraps all decompiled piracy checks in `#if PIRACYCHECKS` stat **When Called:** When the Cheats menu dialog is opened. -**What It Checks:** Checksums `__scHandleRetrace` to make sure it hasn't been modified. +**What It Checks:** Checksums `__scHandleTasks` to make sure it hasn't been modified. -**Payload:** Corrupts `__scHandleRetrace` by nopping the call to `__scAppendList` and some of the function arguments to `osRecvMesg`. Most likely results in a crash. +**Payload:** Corrupts `__scHandleTasks` by nopping the call to `__scAppendList` and some of the function arguments to `osRecvMesg`. Most likely results in a crash. --- @@ -64,7 +64,7 @@ The decomp project wraps all decompiled piracy checks in `#if PIRACYCHECKS` stat **When Called:** When a guard hears you. -**What It Checks:** Checksums `func00002078` to make sure it hasn't been modified. That function doesn't appear to have any piracy checks, however. +**What It Checks:** Checksums `__scHandleRetrace` to make sure it hasn't been modified. That function doesn't appear to have any piracy checks, however. **Payload:** Sets the Skedar King's body file number to zero, which causes the game to crash when loading Skedar Ruins or WAR. diff --git a/include/PR/sched.h b/include/PR/sched.h index a3e5c8182..166a81b73 100644 --- a/include/PR/sched.h +++ b/include/PR/sched.h @@ -38,8 +38,11 @@ #define OS_SC_RETRACE_MSG 1 #define OS_SC_DONE_MSG 2 #define OS_SC_RDP_DONE_MSG 3 -#define OS_SC_PRE_NMI_MSG 4 -#define OS_SC_LAST_MSG 4 /* this should have highest number */ +#define OS_SC_RSP_MSG 4 // custom - tells audiomgr it's time to do an audio frame +#define OS_SC_PRE_NMI_MSG 5 +#define OS_SC_QUIT_MSG 10 +#define OS_SC_LAST_MSG 10 /* this should have highest number */ + #define OS_SC_MAX_MESGS 8 typedef struct { diff --git a/ld/libfiles.ntsc-beta.inc b/ld/libfiles.ntsc-beta.inc index 410a9393f..54a7eca08 100644 --- a/ld/libfiles.ntsc-beta.inc +++ b/ld/libfiles.ntsc-beta.inc @@ -31,6 +31,7 @@ build/ROMID/lib/rzip.o (section); \ build/ROMID/lib/audiomgr.o (section); \ build/ROMID/lib/audiodma.o (section); \ + build/ROMID/lib/profile.o (section); \ build/ROMID/lib/vi.o (section); \ build/ROMID/lib/fault.o (section); \ build/ROMID/lib/crash.o (section); \ diff --git a/ld/libfiles.ntsc-final.inc b/ld/libfiles.ntsc-final.inc index 2fee2c30f..ea20c573c 100644 --- a/ld/libfiles.ntsc-final.inc +++ b/ld/libfiles.ntsc-final.inc @@ -30,6 +30,7 @@ build/ROMID/lib/rzip.o (section); \ build/ROMID/lib/audiomgr.o (section); \ build/ROMID/lib/audiodma.o (section); \ + build/ROMID/lib/profile.o (section); \ build/ROMID/lib/vi.o (section); \ build/ROMID/lib/fault.o (section); \ build/ROMID/lib/crash.o (section); \ diff --git a/ld/libfiles.pal-final.inc b/ld/libfiles.pal-final.inc index e1461de25..a995766d1 100644 --- a/ld/libfiles.pal-final.inc +++ b/ld/libfiles.pal-final.inc @@ -30,6 +30,7 @@ build/ROMID/lib/rzip.o (section); \ build/ROMID/lib/audiomgr.o (section); \ build/ROMID/lib/audiodma.o (section); \ + build/ROMID/lib/profile.o (section); \ build/ROMID/lib/vi.o (section); \ build/ROMID/lib/fault.o (section); \ build/ROMID/lib/crash.o (section); \ diff --git a/src/game/cheats.c b/src/game/cheats.c index ad657581a..946e16c08 100644 --- a/src/game/cheats.c +++ b/src/game/cheats.c @@ -473,7 +473,7 @@ s32 cheatMenuHandleDialog(s32 operation, struct menudialog *dialog, union handle #if PIRACYCHECKS { - u32 *ptr = (u32 *)&__scHandleRetrace; + u32 *ptr = (u32 *)&__scHandleTasks; u32 *end = (u32 *)&__scHandleRSP; u32 checksum = 0; @@ -483,7 +483,7 @@ s32 cheatMenuHandleDialog(s32 operation, struct menudialog *dialog, union handle } if (checksum != CHECKSUM_PLACEHOLDER) { - ptr = (u32 *)&__scHandleRetrace + 20; + ptr = (u32 *)&__scHandleTasks + 20; if (1); end = &ptr[4]; diff --git a/src/game/chr/chr.c b/src/game/chr/chr.c index 0b3ba41cc..5cc5902fe 100644 --- a/src/game/chr/chr.c +++ b/src/game/chr/chr.c @@ -15205,8 +15205,8 @@ void chrsCheckForNoise(f32 noiseradius) chrRecordLastHearTargetTime(&g_ChrSlots[i]); #if PIRACYCHECKS { - s32 *i = (s32 *)&func00002078; - s32 *end = (s32 *)&__scHandleRetrace; + s32 *i = (s32 *)&__scHandleRetrace; + s32 *end = (s32 *)&__scHandleTasks; u32 checksum = 0; while (i < end) { diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index 5488c47ec..26d85fe9e 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -5251,7 +5251,7 @@ bool aiEndLevel(void) { if (debugAllowEndLevel()) { if (var800624a4) { - mainSetStageNum(STAGE_TITLE); + mainChangeToStage(STAGE_TITLE); } else if (g_Vars.autocutplaying) { g_Vars.autocutfinished = true; } else { diff --git a/src/game/credits.c b/src/game/credits.c index f5da07def..7faaee5e4 100644 --- a/src/game/credits.c +++ b/src/game/credits.c @@ -5313,7 +5313,7 @@ glabel var7f1b5948 /* f13bfd4: 0fc0690e */ jal setNumPlayers /* f13bfd8: 24040001 */ li $a0,0x1 /* f13bfdc: 3c048006 */ lui $a0,0x8006 -/* f13bfe0: 0c0039af */ jal mainSetStageNum +/* f13bfe0: 0c0039af */ jal mainChangeToStage /* f13bfe4: 8c8421b4 */ lw $a0,0x21b4($a0) /* f13bfe8: 3c01800a */ lui $at,0x800a /* f13bfec: ac20a7a4 */ sw $zero,-0x585c($at) @@ -5622,7 +5622,7 @@ glabel var7f1b5948 /* f13b470: 0fc068d5 */ jal setNumPlayers /* f13b474: 24040001 */ addiu $a0,$zero,0x1 /* f13b478: 3c048006 */ lui $a0,%hi(g_TitleNextStage) -/* f13b47c: 0c003a57 */ jal mainSetStageNum +/* f13b47c: 0c003a57 */ jal mainChangeToStage /* f13b480: 8c8424e4 */ lw $a0,%lo(g_TitleNextStage)($a0) /* f13b484: 3c01800a */ lui $at,%hi(g_Vars+0x294) /* f13b488: ac20a254 */ sw $zero,%lo(g_Vars+0x294)($at) @@ -5931,7 +5931,7 @@ glabel var7f1b5948 /* 7f135f70: 0fc06821 */ jal setNumPlayers /* 7f135f74: 24040001 */ addiu $a0,$zero,0x1 /* 7f135f78: 3c048006 */ lui $a0,0x8006 -/* 7f135f7c: 0c003c56 */ jal mainSetStageNum +/* 7f135f7c: 0c003c56 */ jal mainChangeToStage /* 7f135f80: 8c8449f4 */ lw $a0,0x49f4($a0) /* 7f135f84: 3c01800a */ lui $at,0x800a /* 7f135f88: ac20e954 */ sw $zero,-0x16ac($at) @@ -6056,7 +6056,7 @@ glabel var7f1b5948 // g_TitleNextStage = STAGE_CITRAINING; // // setNumPlayers(1); -// mainSetStageNum(g_TitleNextStage); +// mainChangeToStage(g_TitleNextStage); // // g_Vars.bondplayernum = 0; // g_Vars.coopplayernum = -1; diff --git a/src/game/endscreen.c b/src/game/endscreen.c index ab083fbd2..ea217b8bd 100644 --- a/src/game/endscreen.c +++ b/src/game/endscreen.c @@ -382,7 +382,7 @@ glabel func0f10d730 /* f1087a8: 03002025 */ or $a0,$t8,$zero /* f1087ac: 0fc06945 */ jal titleSetNextMode /* f1087b0: 24040005 */ addiu $a0,$zero,0x5 -/* f1087b4: 0c003c56 */ jal mainSetStageNum +/* f1087b4: 0c003c56 */ jal mainChangeToStage /* f1087b8: 92040001 */ lbu $a0,0x1($s0) /* f1087bc: 1000000e */ beqz $zero,.NB0f1087f8 /* f1087c0: 00001025 */ or $v0,$zero,$zero @@ -567,7 +567,7 @@ void endscreenHandleContinue(s32 context) lvSetDifficulty(g_MissionConfig.difficulty); titleSetNextMode(TITLEMODE_SKIP); - mainSetStageNum(g_MissionConfig.stagenum); + mainChangeToStage(g_MissionConfig.stagenum); viBlack(true); } } else if (g_Vars.stagenum == STAGE_SKEDARRUINS) { @@ -576,7 +576,7 @@ void endscreenHandleContinue(s32 context) titleSetNextStage(g_MissionConfig.stagenum); lvSetDifficulty(g_MissionConfig.difficulty); titleSetNextMode(TITLEMODE_SKIP); - mainSetStageNum(g_MissionConfig.stagenum); + mainChangeToStage(g_MissionConfig.stagenum); viBlack(true); } } else { @@ -804,7 +804,7 @@ glabel menudialogSolo2PEndscreenCompleted /* f108b28: 24040005 */ addiu $a0,$zero,0x5 /* f108b2c: 3c03800a */ lui $v1,0x800a /* f108b30: 246327a8 */ addiu $v1,$v1,0x27a8 -/* f108b34: 0c003c56 */ jal mainSetStageNum +/* f108b34: 0c003c56 */ jal mainChangeToStage /* f108b38: 90640001 */ lbu $a0,0x1($v1) /* f108b3c: 1000004e */ beqz $zero,.NB0f108c78 /* f108b40: 8fb8001c */ lw $t8,0x1c($sp) diff --git a/src/game/game_01bea0.c b/src/game/game_01bea0.c index 2e22a1419..d7668519f 100644 --- a/src/game/game_01bea0.c +++ b/src/game/game_01bea0.c @@ -1139,7 +1139,7 @@ glabel var7f1a863c /* f01ce9c: 01e02025 */ move $a0,$t7 /* f01cea0: 0fc06a32 */ jal titleSetNextMode /* f01cea4: 24040005 */ li $a0,0x5 -/* f01cea8: 0c0039af */ jal mainSetStageNum +/* f01cea8: 0c0039af */ jal mainChangeToStage /* f01ceac: 92440001 */ lbu $a0,0x1($s2) /* f01ceb0: 1000002b */ b .PF0f01cf60 /* f01ceb4: 8fae0120 */ lw $t6,0x120($sp) @@ -1221,7 +1221,7 @@ glabel var7f1a863c /* f01cfcc: 10000001 */ b .PF0f01cfd4 /* f01cfd0: 2404005d */ li $a0,0x5d .PF0f01cfd4: -/* f01cfd4: 0c0039af */ jal mainSetStageNum +/* f01cfd4: 0c0039af */ jal mainChangeToStage /* f01cfd8: 00000000 */ nop /* f01cfdc: 0fc5b88c */ jal func0f16d3d0 /* f01cfe0: 00000000 */ nop @@ -1323,12 +1323,12 @@ glabel var7f1a863c /* f01d130: 00000000 */ nop /* f01d134: 0c0039b9 */ jal mainGetStageNum /* f01d138: 00000000 */ nop -/* f01d13c: 0c0039af */ jal mainSetStageNum +/* f01d13c: 0c0039af */ jal mainChangeToStage /* f01d140: 00402025 */ move $a0,$v0 /* f01d144: 100000c8 */ b .PF0f01d468 /* f01d148: 00000000 */ nop .PF0f01d14c: -/* f01d14c: 0c0039af */ jal mainSetStageNum +/* f01d14c: 0c0039af */ jal mainChangeToStage /* f01d150: 2404005a */ li $a0,0x5a /* f01d154: 100000c4 */ b .PF0f01d468 /* f01d158: 00000000 */ nop @@ -1480,7 +1480,7 @@ glabel var7f1a863c /* f01d36c: 00000000 */ nop /* f01d370: 0c0039b9 */ jal mainGetStageNum /* f01d374: 00000000 */ nop -/* f01d378: 0c0039af */ jal mainSetStageNum +/* f01d378: 0c0039af */ jal mainChangeToStage /* f01d37c: 00402025 */ move $a0,$v0 /* f01d380: 10000039 */ b .PF0f01d468 /* f01d384: 00000000 */ nop @@ -1507,7 +1507,7 @@ glabel var7f1a863c /* f01d3d0: 02c02025 */ move $a0,$s6 /* f01d3d4: 0fc06a32 */ jal titleSetNextMode /* f01d3d8: 24040005 */ li $a0,0x5 -/* f01d3dc: 0c0039af */ jal mainSetStageNum +/* f01d3dc: 0c0039af */ jal mainChangeToStage /* f01d3e0: 24040026 */ li $a0,0x26 /* f01d3e4: 10000020 */ b .PF0f01d468 /* f01d3e8: 00000000 */ nop @@ -1518,7 +1518,7 @@ glabel var7f1a863c /* f01d3f8: 02c02025 */ move $a0,$s6 /* f01d3fc: 0fc06a32 */ jal titleSetNextMode /* f01d400: 24040005 */ li $a0,0x5 -/* f01d404: 0c0039af */ jal mainSetStageNum +/* f01d404: 0c0039af */ jal mainChangeToStage /* f01d408: 2404005d */ li $a0,0x5d /* f01d40c: 10000016 */ b .PF0f01d468 /* f01d410: 00000000 */ nop @@ -1537,7 +1537,7 @@ glabel var7f1a863c /* f01d440: 02c02025 */ move $a0,$s6 /* f01d444: 0fc06a32 */ jal titleSetNextMode /* f01d448: 24040005 */ li $a0,0x5 -/* f01d44c: 0c0039af */ jal mainSetStageNum +/* f01d44c: 0c0039af */ jal mainChangeToStage /* f01d450: 24040026 */ li $a0,0x26 /* f01d454: 3c12800a */ lui $s2,0x800a /* f01d458: 2652e588 */ addiu $s2,$s2,-6776 @@ -2916,7 +2916,7 @@ glabel var7f1a863c /* f01cdcc: 03202025 */ or $a0,$t9,$zero /* f01cdd0: 0fc069f9 */ jal titleSetNextMode /* f01cdd4: 24040005 */ addiu $a0,$zero,0x5 -/* f01cdd8: 0c003a57 */ jal mainSetStageNum +/* f01cdd8: 0c003a57 */ jal mainChangeToStage /* f01cddc: 92440001 */ lbu $a0,0x1($s2) /* f01cde0: 1000002b */ b .L0f01ce90 /* f01cde4: 8fb80120 */ lw $t8,0x120($sp) @@ -2998,7 +2998,7 @@ glabel var7f1a863c /* f01cefc: 10000001 */ b .L0f01cf04 /* f01cf00: 2404005d */ addiu $a0,$zero,0x5d .L0f01cf04: -/* f01cf04: 0c003a57 */ jal mainSetStageNum +/* f01cf04: 0c003a57 */ jal mainChangeToStage /* f01cf08: 00000000 */ nop /* f01cf0c: 0fc5b4f4 */ jal func0f16d3d0 /* f01cf10: 00000000 */ nop @@ -3100,12 +3100,12 @@ glabel var7f1a863c /* f01d060: 00000000 */ nop /* f01d064: 0c003a61 */ jal mainGetStageNum /* f01d068: 00000000 */ nop -/* f01d06c: 0c003a57 */ jal mainSetStageNum +/* f01d06c: 0c003a57 */ jal mainChangeToStage /* f01d070: 00402025 */ or $a0,$v0,$zero /* f01d074: 100000c8 */ b .L0f01d398 /* f01d078: 00000000 */ nop .L0f01d07c: -/* f01d07c: 0c003a57 */ jal mainSetStageNum +/* f01d07c: 0c003a57 */ jal mainChangeToStage /* f01d080: 2404005a */ addiu $a0,$zero,0x5a /* f01d084: 100000c4 */ b .L0f01d398 /* f01d088: 00000000 */ nop @@ -3257,7 +3257,7 @@ glabel var7f1a863c /* f01d29c: 00000000 */ nop /* f01d2a0: 0c003a61 */ jal mainGetStageNum /* f01d2a4: 00000000 */ nop -/* f01d2a8: 0c003a57 */ jal mainSetStageNum +/* f01d2a8: 0c003a57 */ jal mainChangeToStage /* f01d2ac: 00402025 */ or $a0,$v0,$zero /* f01d2b0: 10000039 */ b .L0f01d398 /* f01d2b4: 00000000 */ nop @@ -3284,7 +3284,7 @@ glabel var7f1a863c /* f01d300: 02c02025 */ or $a0,$s6,$zero /* f01d304: 0fc069f9 */ jal titleSetNextMode /* f01d308: 24040005 */ addiu $a0,$zero,0x5 -/* f01d30c: 0c003a57 */ jal mainSetStageNum +/* f01d30c: 0c003a57 */ jal mainChangeToStage /* f01d310: 24040026 */ addiu $a0,$zero,0x26 /* f01d314: 10000020 */ b .L0f01d398 /* f01d318: 00000000 */ nop @@ -3295,7 +3295,7 @@ glabel var7f1a863c /* f01d328: 02c02025 */ or $a0,$s6,$zero /* f01d32c: 0fc069f9 */ jal titleSetNextMode /* f01d330: 24040005 */ addiu $a0,$zero,0x5 -/* f01d334: 0c003a57 */ jal mainSetStageNum +/* f01d334: 0c003a57 */ jal mainChangeToStage /* f01d338: 2404005d */ addiu $a0,$zero,0x5d /* f01d33c: 10000016 */ b .L0f01d398 /* f01d340: 00000000 */ nop @@ -3314,7 +3314,7 @@ glabel var7f1a863c /* f01d370: 02c02025 */ or $a0,$s6,$zero /* f01d374: 0fc069f9 */ jal titleSetNextMode /* f01d378: 24040005 */ addiu $a0,$zero,0x5 -/* f01d37c: 0c003a57 */ jal mainSetStageNum +/* f01d37c: 0c003a57 */ jal mainChangeToStage /* f01d380: 24040026 */ addiu $a0,$zero,0x26 /* f01d384: 3c12800a */ lui $s2,%hi(g_MissionConfig) /* f01d388: 2652dfe8 */ addiu $s2,$s2,%lo(g_MissionConfig) @@ -4684,7 +4684,7 @@ glabel var7f1a863c /* f01caac: 03202025 */ or $a0,$t9,$zero /* f01cab0: 0fc06945 */ jal titleSetNextMode /* f01cab4: 24040005 */ addiu $a0,$zero,0x5 -/* f01cab8: 0c003c56 */ jal mainSetStageNum +/* f01cab8: 0c003c56 */ jal mainChangeToStage /* f01cabc: 92440001 */ lbu $a0,0x1($s2) /* f01cac0: 1000002b */ beqz $zero,.NB0f01cb70 /* f01cac4: 8fb80120 */ lw $t8,0x120($sp) @@ -4766,7 +4766,7 @@ glabel var7f1a863c /* f01cbdc: 10000001 */ beqz $zero,.NB0f01cbe4 /* f01cbe0: 2404005d */ addiu $a0,$zero,0x5d .NB0f01cbe4: -/* f01cbe4: 0c003c56 */ jal mainSetStageNum +/* f01cbe4: 0c003c56 */ jal mainChangeToStage /* f01cbe8: 00000000 */ sll $zero,$zero,0x0 /* f01cbec: 0fc5a04d */ jal func0f16d3d0 /* f01cbf0: 00000000 */ sll $zero,$zero,0x0 @@ -4868,12 +4868,12 @@ glabel var7f1a863c /* f01cd40: 00000000 */ sll $zero,$zero,0x0 /* f01cd44: 0c003c59 */ jal mainGetStageNum /* f01cd48: 00000000 */ sll $zero,$zero,0x0 -/* f01cd4c: 0c003c56 */ jal mainSetStageNum +/* f01cd4c: 0c003c56 */ jal mainChangeToStage /* f01cd50: 00402025 */ or $a0,$v0,$zero /* f01cd54: 100000c8 */ beqz $zero,.NB0f01d078 /* f01cd58: 00000000 */ sll $zero,$zero,0x0 .NB0f01cd5c: -/* f01cd5c: 0c003c56 */ jal mainSetStageNum +/* f01cd5c: 0c003c56 */ jal mainChangeToStage /* f01cd60: 2404005a */ addiu $a0,$zero,0x5a /* f01cd64: 100000c4 */ beqz $zero,.NB0f01d078 /* f01cd68: 00000000 */ sll $zero,$zero,0x0 @@ -5025,7 +5025,7 @@ glabel var7f1a863c /* f01cf7c: 00000000 */ sll $zero,$zero,0x0 /* f01cf80: 0c003c59 */ jal mainGetStageNum /* f01cf84: 00000000 */ sll $zero,$zero,0x0 -/* f01cf88: 0c003c56 */ jal mainSetStageNum +/* f01cf88: 0c003c56 */ jal mainChangeToStage /* f01cf8c: 00402025 */ or $a0,$v0,$zero /* f01cf90: 10000039 */ beqz $zero,.NB0f01d078 /* f01cf94: 00000000 */ sll $zero,$zero,0x0 @@ -5052,7 +5052,7 @@ glabel var7f1a863c /* f01cfe0: 02c02025 */ or $a0,$s6,$zero /* f01cfe4: 0fc06945 */ jal titleSetNextMode /* f01cfe8: 24040005 */ addiu $a0,$zero,0x5 -/* f01cfec: 0c003c56 */ jal mainSetStageNum +/* f01cfec: 0c003c56 */ jal mainChangeToStage /* f01cff0: 24040026 */ addiu $a0,$zero,0x26 /* f01cff4: 10000020 */ beqz $zero,.NB0f01d078 /* f01cff8: 00000000 */ sll $zero,$zero,0x0 @@ -5063,7 +5063,7 @@ glabel var7f1a863c /* f01d008: 02c02025 */ or $a0,$s6,$zero /* f01d00c: 0fc06945 */ jal titleSetNextMode /* f01d010: 24040005 */ addiu $a0,$zero,0x5 -/* f01d014: 0c003c56 */ jal mainSetStageNum +/* f01d014: 0c003c56 */ jal mainChangeToStage /* f01d018: 2404005d */ addiu $a0,$zero,0x5d /* f01d01c: 10000016 */ beqz $zero,.NB0f01d078 /* f01d020: 00000000 */ sll $zero,$zero,0x0 @@ -5082,7 +5082,7 @@ glabel var7f1a863c /* f01d050: 02c02025 */ or $a0,$s6,$zero /* f01d054: 0fc06945 */ jal titleSetNextMode /* f01d058: 24040005 */ addiu $a0,$zero,0x5 -/* f01d05c: 0c003c56 */ jal mainSetStageNum +/* f01d05c: 0c003c56 */ jal mainChangeToStage /* f01d060: 24040026 */ addiu $a0,$zero,0x26 /* f01d064: 3c12800a */ lui $s2,0x800a /* f01d068: 265227a8 */ addiu $s2,$s2,0x27a8 @@ -5882,7 +5882,7 @@ glabel var7f1a863c // titleSetNextStage(g_MissionConfig.stagenum); // lvSetDifficulty(g_MissionConfig.difficulty); // titleSetNextMode(TITLEMODE_SKIP); -// mainSetStageNum(g_MissionConfig.stagenum); +// mainChangeToStage(g_MissionConfig.stagenum); // } else { // // cde8 // s32 prevplayernum = g_Vars.currentplayernum; @@ -5915,7 +5915,7 @@ glabel var7f1a863c // g_FileState = FILESTATE_CHANGINGAGENT; // gamefileLoadDefaults(&g_GameFile); // gamefileApplyOptions(&g_GameFile); -// mainSetStageNum(IS4MB() ? STAGE_4MBMENU : STAGE_CITRAINING); +// mainChangeToStage(IS4MB() ? STAGE_4MBMENU : STAGE_CITRAINING); // func0f16d3d0(); // } else { // // cf1c @@ -5956,9 +5956,9 @@ glabel var7f1a863c // switch (g_MenuData.root) { // case MENUROOT_ENDSCREEN: // d058 // if (g_Vars.restartlevel) { -// mainSetStageNum(mainGetStageNum()); +// mainChangeToStage(mainGetStageNum()); // } else { -// mainSetStageNum(STAGE_TITLE); +// mainChangeToStage(STAGE_TITLE); // } // break; // case MENUROOT_MPPAUSE: // d398 @@ -5987,7 +5987,7 @@ glabel var7f1a863c // && ((!g_CheatsActiveBank0 && !g_CheatsActiveBank1) || isStageDifficultyUnlocked(g_MissionConfig.stageindex + 1, g_MissionConfig.difficulty))) { // soloPushSoloModeEndscreen(); // } else if (g_Vars.restartlevel) { -// mainSetStageNum(mainGetStageNum()); +// mainChangeToStage(mainGetStageNum()); // } else { // mpSetPaused(MPPAUSEMODE_UNPAUSED); // g_Vars.mplayerisrunning = false; @@ -6003,12 +6003,12 @@ glabel var7f1a863c // titleSetNextStage(STAGE_CITRAINING); // setNumPlayers(1); // titleSetNextMode(TITLEMODE_SKIP); -// mainSetStageNum(STAGE_CITRAINING); +// mainChangeToStage(STAGE_CITRAINING); // } else { // titleSetNextStage(STAGE_4MBMENU); // setNumPlayers(1); // titleSetNextMode(TITLEMODE_SKIP); -// mainSetStageNum(STAGE_4MBMENU); +// mainChangeToStage(STAGE_4MBMENU); // } // } // break; @@ -6021,7 +6021,7 @@ glabel var7f1a863c // titleSetNextStage(STAGE_CITRAINING); // setNumPlayers(1); // titleSetNextMode(TITLEMODE_SKIP); -// mainSetStageNum(STAGE_CITRAINING); +// mainChangeToStage(STAGE_CITRAINING); // g_MissionConfig.iscoop = false; // } // break; diff --git a/src/game/game_0b69d0.c b/src/game/game_0b69d0.c index 7be23c342..a1c08c009 100644 --- a/src/game/game_0b69d0.c +++ b/src/game/game_0b69d0.c @@ -3084,7 +3084,7 @@ void func0f0b9a20(void) void currentPlayerEndCutscene(void) { if (var800624a4) { - mainSetStageNum(STAGE_TITLE); + mainChangeToStage(STAGE_TITLE); } else if (g_Vars.autocutplaying) { g_Vars.autocutfinished = true; } else { diff --git a/src/game/game_0f09f0.c b/src/game/game_0f09f0.c index f86a3b905..69b6d7dde 100644 --- a/src/game/game_0f09f0.c +++ b/src/game/game_0f09f0.c @@ -16285,7 +16285,7 @@ glabel func0f0f8040 .L0f0f8100: /* f0f8100: 54610004 */ bnel $v1,$at,.L0f0f8114 /* f0f8104: 8fbf0014 */ lw $ra,0x14($sp) -/* f0f8108: 0c003a57 */ jal mainSetStageNum +/* f0f8108: 0c003a57 */ jal mainChangeToStage /* f0f810c: 2404005a */ addiu $a0,$zero,0x5a /* f0f8110: 8fbf0014 */ lw $ra,0x14($sp) .L0f0f8114: diff --git a/src/game/lv.c b/src/game/lv.c index 25b41d5e7..788760ccf 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -573,7 +573,7 @@ void lvInit(s32 stagenum) buffer[1] = 0xffffffff; buffer[2] = 0x020f0100; buffer[3] = 0xcd31100b; - osEepromLongWrite(&var80099e78, address, (u8 *)&buffer, 0x10); + osEepromLongWrite(&g_PiMesgQueue, address, (u8 *)&buffer, 0x10); g_Paks[SAVEDEVICE_GAMEPAK].headercachecount = 0; } } @@ -3550,7 +3550,7 @@ glabel var7f1b8e7cpf /* f16bcb8: 824f04d5 */ lb $t7,0x4d5($s2) /* f16bcbc: 5de00004 */ bgtzl $t7,.PF0f16bcd0 /* f16bcc0: 824a04d3 */ lb $t2,0x4d3($s2) -/* f16bcc4: 0c0039af */ jal mainSetStageNum +/* f16bcc4: 0c0039af */ jal mainChangeToStage /* f16bcc8: 2404005a */ li $a0,0x5a .PF0f16bccc: /* f16bccc: 824a04d3 */ lb $t2,0x4d3($s2) @@ -3610,7 +3610,7 @@ glabel var7f1b8e7cpf /* f16bda0: 030ac023 */ subu $t8,$t8,$t2 /* f16bda4: 0018c080 */ sll $t8,$t8,0x2 /* f16bda8: 02386821 */ addu $t5,$s1,$t8 -/* f16bdac: 0c0039af */ jal mainSetStageNum +/* f16bdac: 0c0039af */ jal mainChangeToStage /* f16bdb0: 85a40000 */ lh $a0,0x0($t5) /* f16bdb4: 824b04d5 */ lb $t3,0x4d5($s2) /* f16bdb8: 256cffff */ addiu $t4,$t3,-1 @@ -4326,7 +4326,7 @@ Gfx *lvRender(Gfx *gdl) } if (g_Vars.autocutgroupcur < 0 && g_Vars.autocutgroupleft <= 0) { - mainSetStageNum(STAGE_TITLE); + mainChangeToStage(STAGE_TITLE); } } } @@ -4349,7 +4349,7 @@ Gfx *lvRender(Gfx *gdl) g_MissionConfig.stageindex = g_Cutscenes[g_Vars.autocutgroupcur].mission; g_MissionConfig.stagenum = g_Cutscenes[g_Vars.autocutgroupcur].stage; titleSetNextStage(g_Cutscenes[g_Vars.autocutgroupcur].stage); - mainSetStageNum(g_Cutscenes[g_Vars.autocutgroupcur].stage); + mainChangeToStage(g_Cutscenes[g_Vars.autocutgroupcur].stage); g_Vars.autocutgroupleft--; @@ -6348,7 +6348,7 @@ glabel var7f1b1fd4nb /* f165cd8: 824c04d5 */ lb $t4,0x4d5($s2) /* f165cdc: 5d800004 */ bgtzl $t4,.NB0f165cf0 /* f165ce0: 824b04d3 */ lb $t3,0x4d3($s2) -/* f165ce4: 0c003c56 */ jal mainSetStageNum +/* f165ce4: 0c003c56 */ jal mainChangeToStage /* f165ce8: 2404005a */ addiu $a0,$zero,0x5a .NB0f165cec: /* f165cec: 824b04d3 */ lb $t3,0x4d3($s2) @@ -6414,7 +6414,7 @@ glabel var7f1b1fd4nb /* f165dd8: 01d50019 */ multu $t6,$s5 /* f165ddc: 00007812 */ mflo $t7 /* f165de0: 022f6821 */ addu $t5,$s1,$t7 -/* f165de4: 0c003c56 */ jal mainSetStageNum +/* f165de4: 0c003c56 */ jal mainChangeToStage /* f165de8: 85a40000 */ lh $a0,0x0($t5) /* f165dec: 824c04d5 */ lb $t4,0x4d5($s2) .NB0f165df0: @@ -7521,7 +7521,7 @@ glabel var7f1b8ed0pf /* f16cf94: ae000000 */ sw $zero,0x0($s0) /* f16cf98: 0fc06a32 */ jal titleSetNextMode /* f16cf9c: 24040005 */ li $a0,0x5 -/* f16cfa0: 0c0039af */ jal mainSetStageNum +/* f16cfa0: 0c0039af */ jal mainChangeToStage /* f16cfa4: 2404005a */ li $a0,0x5a /* f16cfa8: ae000000 */ sw $zero,0x0($s0) .PF0f16cfac: @@ -8344,7 +8344,7 @@ void lvTick(void) || joyGetStickY(3) < -10) && var800624a4) { if (g_Vars.stagenum != STAGE_TITLE) { titleSetNextMode(TITLEMODE_SKIP); - mainSetStageNum(STAGE_TITLE); + mainChangeToStage(STAGE_TITLE); } var800624a4 = 0; @@ -9158,7 +9158,7 @@ glabel lvTick /* f166f94: ae000000 */ sw $zero,0x0($s0) /* f166f98: 0fc06945 */ jal titleSetNextMode /* f166f9c: 24040005 */ addiu $a0,$zero,0x5 -/* f166fa0: 0c003c56 */ jal mainSetStageNum +/* f166fa0: 0c003c56 */ jal mainChangeToStage /* f166fa4: 2404005a */ addiu $a0,$zero,0x5a /* f166fa8: ae000000 */ sw $zero,0x0($s0) .NB0f166fac: diff --git a/src/game/mainmenu.c b/src/game/mainmenu.c index fddd0a5a2..3b71ad76f 100644 --- a/src/game/mainmenu.c +++ b/src/game/mainmenu.c @@ -771,7 +771,7 @@ s32 menuhandlerAcceptMission(s32 operation, struct menuitem *item, union handler lvSetDifficulty(g_MissionConfig.difficulty); titleSetNextMode(TITLEMODE_SKIP); - mainSetStageNum(g_MissionConfig.stagenum); + mainChangeToStage(g_MissionConfig.stagenum); #if VERSION >= VERSION_NTSC_1_0 viBlack(true); diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index be90a5bf3..99bfdd6a9 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -162,7 +162,7 @@ void mpStartMatch(void) } titleSetNextStage(stagenum); - mainSetStageNum(stagenum); + mainChangeToStage(stagenum); setNumPlayers(numplayers); titleSetNextMode(TITLEMODE_SKIP); diff --git a/src/game/pak/pak.c b/src/game/pak/pak.c index 3e69e2132..1ca7fa82c 100644 --- a/src/game/pak/pak.c +++ b/src/game/pak/pak.c @@ -851,11 +851,11 @@ void pakDumpEeprom(void) #if VERSION >= VERSION_NTSC_1_0 joyDisableCyclicPolling(); - osEepromLongRead(&var80099e78, 0, buffer, 2048); + osEepromLongRead(&g_PiMesgQueue, 0, buffer, 2048); joyEnableCyclicPolling(); #else joyDisableCyclicPolling(1098, "pak.c"); - osEepromLongRead(&var80099e78, 0, buffer, 2048); + osEepromLongRead(&g_PiMesgQueue, 0, buffer, 2048); joyEnableCyclicPolling(1100, "pak.c"); #endif @@ -3433,7 +3433,7 @@ void pakCorrupt(void) address += 0x30; joyDisableCyclicPolling(); - osEepromLongWrite(&var80099e78, address, payload, sizeof(payload)); + osEepromLongWrite(&g_PiMesgQueue, address, payload, sizeof(payload)); joyEnableCyclicPolling(); } } @@ -4938,7 +4938,7 @@ bool pakProbe(s8 device) joyDisableCyclicPolling(); // Try memory pak - ret = pakInitPak(&var80099e78, PFS(device), device, NULL); + ret = pakInitPak(&g_PiMesgQueue, PFS(device), device, NULL); #if VERSION >= VERSION_PAL_FINAL if (pakHandleResult(ret, device, true, 3836)) @@ -4970,7 +4970,7 @@ bool pakProbe(s8 device) if (!done) { // Try rumble pak - ret = osMotorProbe(&var80099e78, PFS(device), device); + ret = osMotorProbe(&g_PiMesgQueue, PFS(device), device); #if VERSION >= VERSION_PAL_FINAL if (pakHandleResult(ret, device, false, 3872)) @@ -4994,7 +4994,7 @@ bool pakProbe(s8 device) if (!done) { // Try game boy pak - ret = osGbpakInit(&var80099e78, PFS(device), device); + ret = osGbpakInit(&g_PiMesgQueue, PFS(device), device); #if VERSION >= VERSION_PAL_FINAL if (pakHandleResult(ret, device, false, 3896)) @@ -5033,7 +5033,7 @@ bool pakProbe(s8 device) joyDisableCyclicPolling(3434, "pak.c"); // Try memory pak - ret = pakInitPak(&var80099e78, PFS(device), device); + ret = pakInitPak(&g_PiMesgQueue, PFS(device), device); if (pakHandleResult(ret, device, 1, 3437)) { joyEnableCyclicPolling(3439, "pak.c"); @@ -5041,7 +5041,7 @@ bool pakProbe(s8 device) } // Try rumble pak - ret = osMotorProbe(&var80099e78, PFS(device), device); + ret = osMotorProbe(&g_PiMesgQueue, PFS(device), device); if (pakHandleResult(ret, device, 0, 3446)) { joyEnableCyclicPolling(3448, "pak.c"); @@ -5049,7 +5049,7 @@ bool pakProbe(s8 device) } // Try game boy pak - ret = osGbpakInit(&var80099e78, PFS(device), device); + ret = osGbpakInit(&g_PiMesgQueue, PFS(device), device); if (pakHandleResult(ret, device, 0, 3455)) { joyEnableCyclicPolling(3457, "pak.c"); @@ -7015,7 +7015,7 @@ void pakExecuteDebugOperations(void) s32 device = g_PakDebugPakInit - 1; joyDisableCyclicPolling(); - pakInitPak(&var80099e78, PFS(device), device, 0); + pakInitPak(&g_PiMesgQueue, PFS(device), device, 0); joyEnableCyclicPolling(); g_PakDebugPakInit = false; @@ -9606,11 +9606,11 @@ void pakProbeEeprom(void) #if VERSION >= VERSION_NTSC_1_0 joyDisableCyclicPolling(); - type = osEepromProbe(&var80099e78); + type = osEepromProbe(&g_PiMesgQueue); joyEnableCyclicPolling(); #else joyDisableCyclicPolling(6199, "pak.c"); - type = osEepromProbe(&var80099e78); + type = osEepromProbe(&g_PiMesgQueue); joyEnableCyclicPolling(6201, "pak.c"); #endif @@ -9631,11 +9631,11 @@ PakErr1 pakReadEeprom(u8 address, u8 *buffer, u32 len) #if VERSION >= VERSION_NTSC_1_0 joyDisableCyclicPolling(); - result = osEepromLongRead(&var80099e78, address, buffer, len); + result = osEepromLongRead(&g_PiMesgQueue, address, buffer, len); joyEnableCyclicPolling(); #else joyDisableCyclicPolling(6234, "pak.c"); - result = osEepromLongRead(&var80099e78, address, buffer, len); + result = osEepromLongRead(&g_PiMesgQueue, address, buffer, len); joyEnableCyclicPolling(6236, "pak.c"); #endif @@ -9648,11 +9648,11 @@ PakErr1 pakWriteEeprom(u8 address, u8 *buffer, u32 len) #if VERSION >= VERSION_NTSC_1_0 joyDisableCyclicPolling(); - result = osEepromLongWrite(&var80099e78, address, buffer, len); + result = osEepromLongWrite(&g_PiMesgQueue, address, buffer, len); joyEnableCyclicPolling(); #else joyDisableCyclicPolling(6269, "pak.c"); - result = osEepromLongWrite(&var80099e78, address, buffer, len); + result = osEepromLongWrite(&g_PiMesgQueue, address, buffer, len); joyEnableCyclicPolling(6271, "pak.c"); #endif diff --git a/src/game/title.c b/src/game/title.c index 328bcc64f..aa099e293 100644 --- a/src/game/title.c +++ b/src/game/title.c @@ -1814,7 +1814,7 @@ void titleTickPdLogo(void) creditsRequestAltTitle(); g_TitleNextStage = STAGE_CREDITS; // for alt title screen setNumPlayers(1); - mainSetStageNum(g_TitleNextStage); + mainChangeToStage(g_TitleNextStage); g_Vars.bondplayernum = 0; g_Vars.coopplayernum = -1; @@ -7003,7 +7003,7 @@ void titleInitSkip(void) viSetViewSize(320, 220); } - mainSetStageNum(g_TitleNextStage); + mainChangeToStage(g_TitleNextStage); g_Vars.bondplayernum = 0; g_Vars.coopplayernum = -1; diff --git a/src/include/bss.h b/src/include/bss.h index 2e719be58..96ff24af9 100644 --- a/src/include/bss.h +++ b/src/include/bss.h @@ -10,7 +10,7 @@ extern u32 var8008ae28; extern u32 var8008ae2c; extern u32 var8008ae30; extern OSThread g_MainThread; -extern OSMesgQueue var8008db30; +extern OSMesgQueue g_SchedMesgQueue; extern OSSched g_Sched; extern OSViMode var8008dcc0[2]; extern OSViMode *var8008dd60[2]; @@ -22,7 +22,7 @@ extern s32 g_BootBufferIndex0; extern OSPiHandle CartRomHandle; extern OSPiHandle LeoDiskHandle; extern OSTimer var80090ab0; -extern OSMesgQueue var80090ad0; +extern OSMesgQueue g_GbpakMesgQueue; extern OSMesg var80090ae8; extern u8 g_Is4Mb; extern u32 var80090af4; @@ -38,7 +38,7 @@ extern struct var80094ed8 var80094ed8[3]; extern ALHeap g_SndHeap; extern u32 var80095200; extern struct var80095210 var80095210; -extern OSMesgQueue var80099e78; +extern OSMesgQueue g_PiMesgQueue; extern struct g_vars g_Vars; extern u32 var8009a874; extern u32 var8009a888; diff --git a/src/include/constants.h b/src/include/constants.h index 82b65124a..e282bc5f1 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -3191,6 +3191,16 @@ #define PORTALMODE_SHOW 0 #define PORTALMODE_HIDE 1 +#define PROFILE_MAINTICK_END 0x10000 +#define PROFILE_RSP_END 0x10001 +#define PROFILE_RDP_END 0x10002 +#define PROFILE_MAINTICK_START 0x20000 +#define PROFILE_RDP_START2 0x20002 +#define PROFILE_AUDIOFRAME_START 0x30000 +#define PROFILE_RSP_START 0x30001 +#define PROFILE_RDP_START1 0x40001 +#define PROFILE_AUDIOFRAME_END 0x60000 + #define PROJECTILEFLAG_00000001 0x00000001 #define PROJECTILEFLAG_00000002 0x00000002 #define PROJECTILEFLAG_00000004 0x00000004 @@ -3687,13 +3697,13 @@ #define THREAD_FAULT 5 #define THREAD_RESET 6 -#define THREADPRI_RMON 250 #define THREADPRI_IDLE 0 -#define THREADPRI_SCHED 30 #define THREADPRI_MAIN 10 -#define THREADPRI_AUDIO 20 -#define THREADPRI_FAULT 40 #define THREADPRI_RESET 11 +#define THREADPRI_AUDIO 20 +#define THREADPRI_SCHED 30 +#define THREADPRI_FAULT 40 +#define THREADPRI_RMON 250 #define TICKMODE_0 0 #define TICKMODE_NORMAL 1 diff --git a/src/include/data.h b/src/include/data.h index 52e64f53e..5b0813e26 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -10,11 +10,6 @@ extern u8 *g_StackStartAddrs[7]; extern u8 *g_StackEndAddrs[7]; extern u8 *g_StackAllocatedPos; -extern u32 var8005ce60; -extern u32 var8005ce64; -extern u32 var8005ce68; -extern u32 var8005ce6c; -extern u32 var8005ce70; extern s32 var8005ce74; extern f32 g_ViXScalesBySlot[2]; extern f32 g_ViYScalesBySlot[2]; @@ -23,8 +18,6 @@ extern s32 g_ViUnblackTimer; extern s32 g_ViShakeDirection; extern s32 g_ViShakeIntensity; extern s32 g_ViShakeTimer; -extern OSMesg var8005cea8; -extern u32 var8005cec8; extern s8 g_Resetting; extern OSDevMgr __osViDevMgr; extern u32 var8005cefc; diff --git a/src/include/lib/crash.h b/src/include/lib/crash.h index f8e8aa13f..cd0562515 100644 --- a/src/include/lib/crash.h +++ b/src/include/lib/crash.h @@ -99,8 +99,8 @@ void crashPrint3Floats(s32 index, f32 value1, f32 value2, f32 value3); void crashPutChar(s32 x, s32 y, char c); void crashAppendChar(char c); void crashScroll(s32 numlines); -void crash0000cdc8(s32 x, s32 y, char c); +void crashRenderChar(s32 x, s32 y, char c); void crashReset(void); -void crash0000cf54(u8 *fb); +void crashRenderFrame(u8 *fb); #endif diff --git a/src/include/lib/main.h b/src/include/lib/main.h index 3b22afdac..d9fa64cd5 100644 --- a/src/include/lib/main.h +++ b/src/include/lib/main.h @@ -12,7 +12,7 @@ void mainOverrideVariable(char *name, void *value); void mainLoop(void); void mainTick(void); void mainEndStage(void); -void mainSetStageNum(s32 stagenum); +void mainChangeToStage(s32 stagenum); void func0000e990(void); void func0000e9c0(void); s32 mainGetStageNum(void); diff --git a/src/include/lib/sched.h b/src/include/lib/sched.h index c397461d9..3b1d74d93 100644 --- a/src/include/lib/sched.h +++ b/src/include/lib/sched.h @@ -3,12 +3,12 @@ #include #include -void func00001b28(u32 arg0); -void __scHandleRetraceViaPri(OSSched *sc, OSScTask *t); -void func00002078(OSSched *sc); +void schedSetCrashEnable2(s32 enable); +void schedAppendTasks(OSSched *sc, OSScTask *t); +void __scHandleRetrace(OSSched *sc); void __scHandleRSP(OSSched *sc); void __scHandleRDP(OSSched *sc); -void __scHandleRetrace(OSSched *sc); +void __scHandleTasks(OSSched *sc); void __scAppendList(OSSched *sc, OSScTask *t); void __scExec(OSSched *sc, OSScTask *sp, OSScTask *dp); void __scMain(void *arg); diff --git a/src/include/lib/vi.h b/src/include/lib/vi.h index b1aa5db17..7c96d9432 100644 --- a/src/include/lib/vi.h +++ b/src/include/lib/vi.h @@ -4,12 +4,12 @@ #include "data.h" #include "types.h" -void vi00009a80(void); -void vi00009a88(void); -void vi00009a90(void); -void vi00009a98(void); -void vi00009aa0(u32 arg0); -Gfx *viRenderDebug(Gfx *gdl); +void profileInit(void); +void profileTick(void); +void profile00009a90(void); +void profile00009a98(void); +void profileSetMarker(u32 arg0); +Gfx *profileRender(Gfx *gdl); void viConfigureForLogos(void); void viConfigureForBanner(u8 *fb); void viConfigureForLegal(void); diff --git a/src/lib/audiomgr.c b/src/lib/audiomgr.c index ee9684fe5..66637f604 100644 --- a/src/lib/audiomgr.c +++ b/src/lib/audiomgr.c @@ -185,14 +185,14 @@ void amgrMain(void *arg) osRecvMesg(&g_AudioManager.audioFrameMsgQ, (OSMesg *) &msg, OS_MESG_BLOCK); switch (*msg) { - case 4: + case OS_SC_RSP_MSG: var80091588 = osGetTime(); - vi00009aa0(0x30000); + profileSetMarker(PROFILE_AUDIOFRAME_START); amgrHandleFrameMsg(g_AudioManager.audioInfo[g_AdmaCurFrame % 3], info); admaReceiveAll(); count++; - vi00009aa0(0x60000); + profileSetMarker(PROFILE_AUDIOFRAME_END); var80091590 = osGetTime(); var80091570 = var80091590 - var80091588; @@ -215,10 +215,10 @@ void amgrMain(void *arg) var8005d514 = 0; amgrHandleDoneMsg(info); break; - case 5: + case OS_SC_PRE_NMI_MSG: done = true; break; - case 10: + case OS_SC_QUIT_MSG: done = true; break; } @@ -240,7 +240,7 @@ void amgrHandleFrameMsg(AudioInfo *info, AudioInfo *previnfo) extern u8 aspDataStart; if (g_AmgrCurrentCmdList) { - __scHandleRetraceViaPri(&g_Sched, g_AmgrCurrentCmdList); + schedAppendTasks(&g_Sched, g_AmgrCurrentCmdList); } admaBeginFrame(); diff --git a/src/lib/boot.c b/src/lib/boot.c index a2e0ebcd6..310308690 100644 --- a/src/lib/boot.c +++ b/src/lib/boot.c @@ -22,7 +22,7 @@ OSThread g_RmonThread; OSThread g_IdleThread; OSThread g_MainThread; OSThread g_SchedThread; -OSMesgQueue var8008db30; +OSMesgQueue g_SchedMesgQueue; OSMesg var8008db48[32]; OSMesgQueue *g_SchedCmdQ; u32 var8008dbcc; @@ -586,7 +586,7 @@ void bootCreateRmonThread(void) void bootCreateSchedThread(void) { - osCreateMesgQueue(&var8008db30, var8008db48, ARRAYCOUNT(var8008db48)); + osCreateMesgQueue(&g_SchedMesgQueue, var8008db48, ARRAYCOUNT(var8008db48)); if (osTvType == OS_TV_MPAL) { osCreateScheduler(&g_Sched, &g_SchedThread, OS_VI_MPAL_LAN1, 1); @@ -594,7 +594,7 @@ void bootCreateSchedThread(void) osCreateScheduler(&g_Sched, &g_SchedThread, OS_VI_NTSC_LAN1, 1); } - osScAddClient(&g_Sched, &var8008dca8, &var8008db30, 0); + osScAddClient(&g_Sched, &var8008dca8, &g_SchedMesgQueue, 0); g_SchedCmdQ = osScGetCmdQ(&g_Sched); } diff --git a/src/lib/crash.c b/src/lib/crash.c index f756ac0e0..e0865c5e9 100644 --- a/src/lib/crash.c +++ b/src/lib/crash.c @@ -121,7 +121,7 @@ extern u32 _libSegmentStart; extern u32 _libSegmentEnd; void faultproc(void *arg0); -u32 crashRender(OSThread *thread, u32 *callstack, s32 *tracelen); +u32 crashGenerate(OSThread *thread, u32 *callstack, s32 *tracelen); void crashPrintDescription(u32 mask, char *label, struct crashdescription *descriptions); #if VERSION < VERSION_NTSC_1_0 @@ -172,8 +172,8 @@ void faultproc(void *arg0) osSetIntMask(mask); #if VERSION < VERSION_NTSC_1_0 - crashRender(thread, callstack, &tracelen); - func00001b1c(true); + crashGenerate(thread, callstack, &tracelen); + schedSetCrashedUnexpectedly(true); #endif } } @@ -643,7 +643,7 @@ void crashPrint3Floats(s32 index, f32 value1, f32 value2, f32 value3) } #if VERSION >= VERSION_NTSC_1_0 -u32 crashRender(OSThread *thread, u32 *callstack, s32 *tracelen) +u32 crashGenerate(OSThread *thread, u32 *callstack, s32 *tracelen) { s32 i; u32 ptr; @@ -794,7 +794,7 @@ const char crashrodata24[] = "\n"; const char crashrodata25[] = "\n"; GLOBAL_ASM( -glabel crashRender +glabel crashGenerate /* ca5c: 27bdff08 */ addiu $sp,$sp,-248 /* ca60: afa400f8 */ sw $a0,0xf8($sp) /* ca64: afbf003c */ sw $ra,0x3c($sp) @@ -1313,7 +1313,13 @@ void crashScroll(s32 numlines) } #if VERSION >= VERSION_NTSC_1_0 -void crash0000cdc8(s32 x, s32 y, char c) +/** + * Render a character to the crash buffer. + * + * It looks like the character rendering code has been removed however, + * so it's just borders that remain. + */ +void crashRenderChar(s32 x, s32 y, char c) { s32 i; s32 j; @@ -1345,20 +1351,20 @@ void crash0000cdc8(s32 x, s32 y, char c) for (i = 0; i < 7; i++) { for (j = 0; j < 4; j++) { - // "special" occurs every 32nd pixel - u32 special = a2 & 0x80000000; + // gray occurs every 32nd pixel + u32 gray = a2 & 0x80000000; - if (special) { - fbpos[0] = 0x7bdf; + if (gray) { + fbpos[0] = GPACK_RGBA5551(120, 120, 120, 1); } else { - fbpos[0] = 1; + fbpos[0] = GPACK_RGBA5551(0, 0, 0, 1); } if (hires) { - if (special) { - fbpos[1] = 0x7bdf; + if (gray) { + fbpos[1] = GPACK_RGBA5551(120, 120, 120, 1); } else { - fbpos[1] = 1; + fbpos[1] = GPACK_RGBA5551(0, 0, 0, 1); } } @@ -1382,7 +1388,7 @@ void crash0000cdc8(s32 x, s32 y, char c) } #else GLOBAL_ASM( -glabel crash0000cdc8 +glabel crashRenderChar /* d398: 27bdffe8 */ addiu $sp,$sp,-24 /* d39c: afbf0014 */ sw $ra,0x14($sp) /* d3a0: afa40018 */ sw $a0,0x18($sp) @@ -1526,7 +1532,7 @@ glabel crashReset ); #endif -void crash0000cf54(u8 *fb) +void crashRenderFrame(u8 *fb) { s32 width; s32 height; @@ -1541,7 +1547,7 @@ void crash0000cf54(u8 *fb) if (g_CrashCharBuffer != NULL) { for (y = 0; y < height && y < 29; y++) { for (x = 0; x < width - 5 && x < 71; x++) { - crash0000cdc8(20 + x * 4, 7 + y * 7, g_CrashCharBuffer[y][x]); + crashRenderChar(20 + x * 4, 7 + y * 7, g_CrashCharBuffer[y][x]); } } } diff --git a/src/lib/joy.c b/src/lib/joy.c index 36791d8d3..cef4020b5 100644 --- a/src/lib/joy.c +++ b/src/lib/joy.c @@ -8,13 +8,13 @@ #include "types.h" /** - * PD uses use a separate thread (than the main game) for controller polling. - * This thread polls the controllers as frequently as possible and stores its - * results inside g_JoyData->samples. This allows the main thread to access a - * history of controller states since the last rendered frame. For example, - * under laggy conditions the player might press and release a button between - * two frames and the main thread can tell that this has happened even if the - * button was unpressed during both the previous and current frame. + * PD polls the controllers from the scheduler's thread. The scheduler polls the + * controllers on each retrace and stores teh results inside g_JoyData->samples. + * This allows the main thread to access a history of controller states since + * the last rendered frame. For example, under laggy conditions the player might + * press and release a button between two frames and the main thread can tell + * that this has happened even if the button was unpressed during both the + * previous and current frame. * * The samples array contains 20 elements and is written to in a cyclic manner. * These samples are split into two partitions: cur and next. cur refers to @@ -22,18 +22,18 @@ * samples in next are samples which have been added since the start of the * current frame and will be made visible on the next frame. * - * At the start of a frame, the main thread informs the cont system that it's - * ready to consume more samples. The cont system then moves the partition + * At the start of a frame, the main thread informs the joy system that it's + * ready to consume more samples. The joy system then moves the partition * boundaries so that the old next partition becomes the new cur, and everything * else becomes available for next. * - * If all 20 samples are in use, the cont system will overwrite the most recent + * If all 20 samples are in use, the joy system will overwrite the most recent * sample in the next partition. */ struct joydata g_JoyData[2]; s32 g_JoyDisableCooldown[4]; -OSMesgQueue var80099e78; +OSMesgQueue g_PiMesgQueue; OSMesg var80099e90; u32 var80099e94; u32 var80099e98; @@ -238,7 +238,7 @@ void joyCheckPfs(s32 arg0) joyDisableCyclicPolling(); } - osPfsIsPlug(&var80099e78, &bitpattern); + osPfsIsPlug(&g_PiMesgQueue, &bitpattern); if (arg0) { joyEnableCyclicPolling(); @@ -303,9 +303,9 @@ void joySystemInit(void) osCreateMesgQueue(&g_JoyStopCyclicPollingDoneMesgQueue, &var80099ed8, 1); osCreateMesgQueue(&g_JoyStartCyclicPollingMesgQueue, &var80099ef8, 1); osCreateMesgQueue(&g_JoyStartCyclicPollingDoneMesgQueue, &var80099f18, 1); - osCreateMesgQueue(&var80099e78, &var80099e90, 10); + osCreateMesgQueue(&g_PiMesgQueue, &var80099e90, 10); - osSetEventMesg(OS_EVENT_SI, &var80099e78, NULL); + osSetEventMesg(OS_EVENT_SI, &g_PiMesgQueue, NULL); g_JoyQueuesCreated = true; @@ -376,7 +376,7 @@ void joy00013e84(void) if (g_JoyNeedsInit) { s32 i; g_JoyNeedsInit = false; - osContInit(&var80099e78, &g_JoyConnectedControllers, var80099f38); + osContInit(&g_PiMesgQueue, &g_JoyConnectedControllers, var80099f38); g_JoyInitDone = true; for (i = 0; i < 4; i++) { @@ -386,8 +386,8 @@ void joy00013e84(void) u32 slots = 0xf; s32 i; - osContStartQuery(&var80099e78); - osRecvMesg(&var80099e78, NULL, OS_MESG_BLOCK); + osContStartQuery(&g_PiMesgQueue); + osRecvMesg(&g_PiMesgQueue, NULL, OS_MESG_BLOCK); osContGetQuery(var80099f38); for (i = 0; i < 4; i++) { @@ -661,7 +661,7 @@ void joysTick(void) if (osRecvMesg(&g_JoyStopCyclicPollingMesgQueue, &msg, OS_MESG_NOBLOCK) == 0) { if (g_JoyBusy) { - osRecvMesg(&var80099e78, &msg, OS_MESG_BLOCK); + osRecvMesg(&g_PiMesgQueue, &msg, OS_MESG_BLOCK); g_JoyBusy = false; joyReadData(); @@ -688,7 +688,7 @@ void joysTick(void) var8005ee68--; if (var8005ee68 == 0) { - joyStartReadData(&var80099e78); + joyStartReadData(&g_PiMesgQueue); g_JoyBusy = true; } @@ -702,7 +702,7 @@ void joysTick(void) return; } - if (osRecvMesg(&var80099e78, &msg, OS_MESG_NOBLOCK) == 0) { + if (osRecvMesg(&g_PiMesgQueue, &msg, OS_MESG_NOBLOCK) == 0) { static s32 count = 0; g_JoyBusy = false; @@ -720,7 +720,7 @@ void joysTick(void) joy00014238(); joyCheckPfs(0); - joyStartReadData(&var80099e78); + joyStartReadData(&g_PiMesgQueue); g_JoyBusy = true; count++; @@ -1318,11 +1318,11 @@ void joyReset(void) { s32 i; - osCreateMesgQueue(&var80099e78, &var80099e90, 10); - osSetEventMesg(OS_EVENT_SI, &var80099e78, 0); + osCreateMesgQueue(&g_PiMesgQueue, &var80099e90, 10); + osSetEventMesg(OS_EVENT_SI, &g_PiMesgQueue, 0); for (i = 0; i < 4; i++) { - if (osMotorProbe(&var80099e78, PFS(i), i) == 0) { + if (osMotorProbe(&g_PiMesgQueue, PFS(i), i) == 0) { osMotorStop(PFS(i)); osMotorStop(PFS(i)); osMotorStop(PFS(i)); @@ -1361,7 +1361,7 @@ void joyStopRumble(s8 device, bool disablepolling) joyDisableCyclicPolling(); } - if (osMotorProbe(&var80099e78, PFS(device), device) == 0) { + if (osMotorProbe(&g_PiMesgQueue, PFS(device), device) == 0) { osMotorStop(PFS(device)); osMotorStop(PFS(device)); osMotorStop(PFS(device)); diff --git a/src/lib/main.c b/src/lib/main.c index 3c2846398..6036ebd8e 100644 --- a/src/lib/main.c +++ b/src/lib/main.c @@ -68,7 +68,7 @@ s32 var8005d9bc = 0; s32 var8005d9c0 = 0; s32 var8005d9c4 = 0; bool g_MainGameLogicEnabled = true; -u32 var8005d9cc = 0; +u32 g_MainNumGfxTasks = 0; bool g_MainIsEndscreen = false; s32 g_DoBootPakMenu = 0; @@ -638,7 +638,7 @@ glabel mainInit /* d758: 00000000 */ nop /* d75c: 0fc02c84 */ jal stub0f00b200 /* d760: 00000000 */ nop -/* d764: 0c00265c */ jal vi00009a80 +/* d764: 0c00265c */ jal profileInit /* d768: 00000000 */ nop /* d76c: 0fc0021c */ jal stub0f000870 /* d770: 00000000 */ nop @@ -926,19 +926,19 @@ glabel mainInit /* d86c: 02002025 */ or $a0,$s0,$zero /* d870: 8faa0048 */ lw $t2,0x48($sp) /* d874: 3c018006 */ lui $at,%hi(g_RdpOutBufferStart) -/* d878: 3c048009 */ lui $a0,%hi(var8008db30) +/* d878: 3c048009 */ lui $a0,%hi(g_SchedMesgQueue) /* d87c: ac2af044 */ sw $t2,%lo(g_RdpOutBufferStart)($at) /* d880: 3c018006 */ lui $at,%hi(g_RdpOutBufferEnd) /* d884: 254e0800 */ addiu $t6,$t2,0x800 /* d888: ac2ef040 */ sw $t6,%lo(g_RdpOutBufferEnd)($at) -/* d88c: 2484db30 */ addiu $a0,$a0,%lo(var8008db30) +/* d88c: 2484db30 */ addiu $a0,$a0,%lo(g_SchedMesgQueue) /* d890: 27a51470 */ addiu $a1,$sp,0x1470 /* d894: 0c0121bc */ jal osRecvMesg /* d898: 00003025 */ or $a2,$zero,$zero /* d89c: 14400007 */ bnez $v0,.L0000d8bc .L0000d8a0: -/* d8a0: 3c048009 */ lui $a0,%hi(var8008db30) -/* d8a4: 2484db30 */ addiu $a0,$a0,%lo(var8008db30) +/* d8a0: 3c048009 */ lui $a0,%hi(g_SchedMesgQueue) +/* d8a4: 2484db30 */ addiu $a0,$a0,%lo(g_SchedMesgQueue) /* d8a8: 27a51470 */ addiu $a1,$sp,0x1470 /* d8ac: 0c0121bc */ jal osRecvMesg /* d8b0: 00003025 */ or $a2,$zero,$zero @@ -947,8 +947,8 @@ glabel mainInit .L0000d8bc: /* d8bc: 00001825 */ or $v1,$zero,$zero .L0000d8c0: -/* d8c0: 3c048009 */ lui $a0,%hi(var8008db30) -/* d8c4: 2484db30 */ addiu $a0,$a0,%lo(var8008db30) +/* d8c0: 3c048009 */ lui $a0,%hi(g_SchedMesgQueue) +/* d8c4: 2484db30 */ addiu $a0,$a0,%lo(g_SchedMesgQueue) /* d8c8: 27a51470 */ addiu $a1,$sp,0x1470 /* d8cc: 24060001 */ addiu $a2,$zero,0x1 /* d8d0: 0c0121bc */ jal osRecvMesg @@ -1041,7 +1041,7 @@ glabel mainInit /* da1c: 00000000 */ nop /* da20: 0fc02c80 */ jal stub0f00b200 /* da24: 00000000 */ nop -/* da28: 0c0026a0 */ jal vi00009a80 +/* da28: 0c0026a0 */ jal profileInit /* da2c: 00000000 */ nop /* da30: 0fc0021c */ jal stub0f000870 /* da34: 00000000 */ nop @@ -1414,7 +1414,7 @@ glabel mainInit /* df2c: 00000000 */ sll $zero,$zero,0x0 /* df30: 0fc02bac */ jal stub0f00b200 /* df34: 00000000 */ sll $zero,$zero,0x0 -/* df38: 0c002708 */ jal vi00009a80 +/* df38: 0c002708 */ jal profileInit /* df3c: 00000000 */ sll $zero,$zero,0x0 /* df40: 0fc0021c */ jal stub0f000870 /* df44: 00000000 */ sll $zero,$zero,0x0 @@ -1594,7 +1594,7 @@ const char var70053aa0[] = " -ml0 -me0 -mgfx100 -mvtx50 -mt700 -ma400"; // g_RdpOutBufferStart = texture; // g_RdpOutBufferEnd = texture + 0x400; // 0x800 bytes, because texture is u16 // -// while (osRecvMesg(&var8008db30, &sp1470, OS_MESG_NOBLOCK) == 0) { +// while (osRecvMesg(&g_SchedMesgQueue, &sp1470, OS_MESG_NOBLOCK) == 0) { // // empty // } // @@ -1603,7 +1603,7 @@ const char var70053aa0[] = " -ml0 -me0 -mgfx100 -mvtx50 -mt700 -ma400"; // j = 0; // // while (j < 6) { -// osRecvMesg(&var8008db30, &sp1470, OS_MESG_BLOCK); +// osRecvMesg(&g_SchedMesgQueue, &sp1470, OS_MESG_BLOCK); // // if (*(s16 *)sp1470 == 1) { // viUpdateMode(); @@ -1654,7 +1654,7 @@ const char var70053aa0[] = " -ml0 -me0 -mgfx100 -mvtx50 -mt700 -ma400"; // func0f127910(); // frametimeInit(); // stub0f00b200(); -// vi00009a80(); +// profileInit(); // stub0f000870(); // func0f000880(); // stub0f0008e0(); @@ -1694,7 +1694,7 @@ u32 var8005dd44 = 0x00000000; u32 var8005dd48 = 0x00000000; u32 var8005dd4c = 0x00000000; u32 var8005dd50 = 0x00000000; -s32 g_MainStageNum = -1; +s32 g_MainChangeToStageNum = -1; u32 var8005dd58 = 0x00000000; #if VERSION < VERSION_NTSC_1_0 @@ -1753,7 +1753,7 @@ void mainOverrideVariable(char *name, void *value) void mainLoop(void) { s32 ending = false; - u32 array[] = {0x20000, 0, 0, 0, 0, 0, 0, 0}; + OSScMsg msg2 = {OS_SC_DONE_MSG}; OSMesg msg; s32 index; s32 numplayers; @@ -1788,7 +1788,7 @@ void mainLoop(void) // Outer loop - this is infinite because ending is never changed while (!ending) { - var8005d9cc = 0; + g_MainNumGfxTasks = 0; g_MainGameLogicEnabled = true; msg = NULL; g_MainIsEndscreen = false; @@ -1944,18 +1944,18 @@ void mainLoop(void) lvInit(g_StageNum); viAllocateFbs(g_StageNum); frametimeCalculate(); - vi00009a90(); + profile00009a90(); - while (osRecvMesg(&var8008db30, &msg, OS_MESG_NOBLOCK) != -1) { + while (osRecvMesg(&g_SchedMesgQueue, &msg, OS_MESG_NOBLOCK) != -1) { // empty } - while (g_MainStageNum < 0 || var8005d9cc != 0) { + while (g_MainChangeToStageNum < 0 || g_MainNumGfxTasks != 0) { s32 tmp; - osRecvMesg(&var8008db30, &msg, OS_MESG_BLOCK); + osRecvMesg(&g_SchedMesgQueue, &msg, OS_MESG_BLOCK); switch (*(s16 *)msg) { - case 1: + case OS_SC_RETRACE_MSG: tmp = osGetCount() - g_Vars.thisframetime; #if PAL if (tmp >= g_Vars.mininc60 * 937500 - 937500 / 2) { @@ -1967,11 +1967,13 @@ void mainLoop(void) } #endif break; - case 2: - var8005d9cc--; + case OS_SC_DONE_MSG: + g_MainNumGfxTasks--; break; - case 5: - var8005d9cc = 4; + case OS_SC_PRE_NMI_MSG: + // This seems to be a hack to get this loop to keep ticking... + // maybe graphics tasks stop being created after pre NMI? + g_MainNumGfxTasks = 4; break; } } @@ -1983,8 +1985,8 @@ void mainLoop(void) viBlack(true); pak0f116994(); - g_StageNum = g_MainStageNum; - g_MainStageNum = -1; + g_StageNum = g_MainChangeToStageNum; + g_MainChangeToStageNum = -1; } // Unreachable @@ -2482,7 +2484,7 @@ glabel mainLoop /* e740: 8c84f2d4 */ lw $a0,-0xd2c($a0) /* e744: 0fc59f11 */ jal frametimeCalculate /* e748: 00000000 */ sll $zero,$zero,0x0 -/* e74c: 0c00270c */ jal vi00009a90 +/* e74c: 0c00270c */ jal profile00009a90 /* e750: 00000000 */ sll $zero,$zero,0x0 /* e754: 02602025 */ or $a0,$s3,$zero /* e758: 02802825 */ or $a1,$s4,$zero @@ -2604,17 +2606,17 @@ void mainTick(void) { Gfx *gdl; Gfx *gdlstart; - u32 array[] = {0x20000, 0, 0, 0, 0, 0, 0, 0}; + OSScMsg msg = {OS_SC_DONE_MSG}; s32 i; - if (g_MainStageNum < 0 && var8005d9cc < 2) { + if (g_MainChangeToStageNum < 0 && g_MainNumGfxTasks < 2) { frametimeCalculate(); - vi00009a98(); - vi00009a90(); - vi00009aa0(0x20000); + profile00009a98(); + profile00009a90(); + profileSetMarker(PROFILE_MAINTICK_START); func000034d8(); joyDebugJoy(); - func00001b28(0); + schedSetCrashEnable2(false); if (g_MainGameLogicEnabled) { gdl = gdlstart = gfxGetMasterDisplayList(); @@ -2644,7 +2646,7 @@ void mainTick(void) func000034e0(&gdl); if (debug0f11ed70() >= 2) { - gdl = viRenderDebug(gdl); + gdl = profileRender(gdl); } gDPFullSync(gdl++); @@ -2656,11 +2658,11 @@ void mainTick(void) viUpdateMode(); } - rdpCreateTask(gdlstart, gdl, 0, array); - var8005d9cc++; + rdpCreateTask(gdlstart, gdl, 0, &msg); + g_MainNumGfxTasks++; func00012a8c(); func0f16cf94(); - vi00009aa0(0x10000); + profileSetMarker(PROFILE_MAINTICK_END); } } #else @@ -2700,17 +2702,17 @@ glabel mainTick /* e968: 8fbf001c */ lw $ra,0x1c($sp) /* e96c: 0fc59f11 */ jal frametimeCalculate /* e970: 00000000 */ sll $zero,$zero,0x0 -/* e974: 0c00270e */ jal vi00009a98 +/* e974: 0c00270e */ jal profile00009a98 /* e978: 00000000 */ sll $zero,$zero,0x0 -/* e97c: 0c00270c */ jal vi00009a90 +/* e97c: 0c00270c */ jal profile00009a90 /* e980: 00000000 */ sll $zero,$zero,0x0 -/* e984: 0c002710 */ jal vi00009aa0 +/* e984: 0c002710 */ jal profileSetMarker /* e988: 3c040002 */ lui $a0,0x2 /* e98c: 0c000dbe */ jal func000034d8 /* e990: 00000000 */ sll $zero,$zero,0x0 /* e994: 0c005477 */ jal joyDebugJoy /* e998: 00000000 */ sll $zero,$zero,0x0 -/* e99c: 0c00073e */ jal func00001b28 +/* e99c: 0c00073e */ jal schedSetCrashEnable2 /* e9a0: 00002025 */ or $a0,$zero,$zero /* e9a4: 3c048006 */ lui $a0,0x8006 /* e9a8: 8c84f2e8 */ lw $a0,-0xd18($a0) @@ -2990,7 +2992,7 @@ glabel mainTick /* edac: 28410002 */ slti $at,$v0,0x2 /* edb0: 14200004 */ bnez $at,.NB0000edc4 /* edb4: 00000000 */ sll $zero,$zero,0x0 -/* edb8: 0c002712 */ jal viRenderDebug +/* edb8: 0c002712 */ jal profileRender /* edbc: 8fa40094 */ lw $a0,0x94($sp) /* edc0: afa20094 */ sw $v0,0x94($sp) .NB0000edc4: @@ -3039,7 +3041,7 @@ glabel mainTick /* ee60: ac490000 */ sw $t1,0x0($v0) /* ee64: 0fc59f51 */ jal func0f16cf94 /* ee68: 00000000 */ sll $zero,$zero,0x0 -/* ee6c: 0c002710 */ jal vi00009aa0 +/* ee6c: 0c002710 */ jal profileSetMarker /* ee70: 3c040001 */ lui $a0,0x1 /* ee74: 8fbf001c */ lw $ra,0x1c($sp) .NB0000ee78: @@ -3093,13 +3095,16 @@ void mainEndStage(void) g_MainIsEndscreen = true; } -void mainSetStageNum(s32 stagenum) +/** + * Change to the given stage at the end of the current frame. + */ +void mainChangeToStage(s32 stagenum) { #if VERSION >= VERSION_NTSC_1_0 pak0f11c6d0(); #endif - g_MainStageNum = stagenum; + g_MainChangeToStageNum = stagenum; } s32 mainGetStageNum(void) diff --git a/src/lib/pimgr.c b/src/lib/pimgr.c index dfc015b06..242fd2737 100644 --- a/src/lib/pimgr.c +++ b/src/lib/pimgr.c @@ -6,9 +6,9 @@ #include "types.h" OSMesg var80099900[64]; -OSMesgQueue var80099a00; +OSMesgQueue g_PimgrMesgQueue; void pimgrCreate(void) { - osCreatePiManager(150, &var80099a00, var80099900, 64); + osCreatePiManager(150, &g_PimgrMesgQueue, var80099900, 64); } diff --git a/src/lib/profile.c b/src/lib/profile.c new file mode 100644 index 000000000..39e45a22c --- /dev/null +++ b/src/lib/profile.c @@ -0,0 +1,35 @@ +#include +#include "constants.h" +#include "bss.h" +#include "data.h" +#include "types.h" + +void profileInit(void) +{ + // empty +} + +void profileTick(void) +{ + // empty +} + +void profile00009a90(void) +{ + // empty +} + +void profile00009a98(void) +{ + // empty +} + +void profileSetMarker(u32 value) +{ + // empty +} + +Gfx *profileRender(Gfx *gdl) +{ + return gdl; +} diff --git a/src/lib/rdp.c b/src/lib/rdp.c index c97472f64..d7ae2920b 100644 --- a/src/lib/rdp.c +++ b/src/lib/rdp.c @@ -99,12 +99,12 @@ void rdpCreateTask(Gfx *gdlstart, Gfx *gdlend, u32 arg2, void *msg) sctask->next = NULL; sctask->flags = OS_SC_NEEDS_RSP | OS_SC_NEEDS_RDP | OS_SC_LAST_TASK | OS_SC_SWAPBUFFER; - sctask->msgQ = &var8008db30; + sctask->msgQ = &g_SchedMesgQueue; sctask->msg = msg; sctask->framebuffer = g_RdpCurTask->framebuffer; osWritebackDCacheAll(); - __scHandleRetraceViaPri(&g_Sched, sctask); + schedAppendTasks(&g_Sched, sctask); // Swap g_RdpCurTask g_RdpCurTask = (struct rdptask *)((u32)g_RdpCurTask ^ (u32) &g_RdpTaskA ^ (u32) &g_RdpTaskB); diff --git a/src/lib/sched.c b/src/lib/sched.c index c26346622..38ea1e9e0 100644 --- a/src/lib/sched.c +++ b/src/lib/sched.c @@ -47,15 +47,15 @@ * private functions */ void __scMain(void *arg); -void __scHandleRetrace(OSSched *s); +void __scHandleTasks(OSSched *s); void __scHandleRSP(OSSched *s); void __scHandleRDP(OSSched *s); void __scAppendList(OSSched *s, OSScTask *t); OSScTask *__scTaskReady(OSScTask *t); s32 __scTaskComplete(OSSched *s,OSScTask *t); void __scExec(OSSched *sc, OSScTask *sp, OSScTask *dp); -void __scYield(OSSched *s); -s32 __scSchedule(OSSched *sc, OSScTask **sp, OSScTask **dp, s32 availRCP); +void __scYield(OSSched *s); +s32 __scSchedule(OSSched *sc, OSScTask **sp, OSScTask **dp, s32 availRCP); OSViMode var8008dcc0[2]; OSViMode *var8008dd60[2]; @@ -64,22 +64,20 @@ u32 var8008de08; s32 var8008de0c; s32 var8008de10; u32 var8008de14; -OSTimer var8008de18; -u32 var8008de38; -u32 var8008de3c; -u32 var8008de40; -u32 var8008de44; +OSTimer g_SchedRspTimer; +u32 g_SchedDpCounters[4]; struct bootbufferthing g_BootBuffers[3]; u8 g_BootBufferDirtyIndexes[3]; s32 g_BootBufferIndex0; s32 g_BootBufferIndex1; s32 g_BootBufferIndex2; -u32 var8005ce60 = 0x00000000; -u32 var8005ce64 = 0x00000000; -u32 var8005ce68 = 0x00000000; -u32 var8005ce6c = 0x02aea540; -u32 var8005ce70 = 0x00000000; +bool g_SchedCrashedUnexpectedly = false; +bool g_SchedCrashEnable1 = false; +bool g_SchedCrashEnable2 = false; +u32 g_SchedCrashRenderInterval = 45000000; +u32 g_SchedCrashLastRendered = 0; + s32 var8005ce74 = 0; f32 g_ViXScalesBySlot[2] = {1, 1}; f32 g_ViYScalesBySlot[2] = {1, 1}; @@ -88,60 +86,52 @@ s32 g_ViUnblackTimer = 3; s32 g_ViShakeDirection = 1; s32 g_ViShakeIntensity = 0; s32 g_ViShakeTimer = 0; -u32 var8005cea0 = 0x00000000; -u32 var8005cea4 = 0x00000000; -OSMesg var8005cea8 = (OSMesg)0x00040000; -u32 var8005ceac = 0x00000000; -u32 var8005ceb0 = 0x00000000; -u32 var8005ceb4 = 0x00000000; -u32 var8005ceb8 = 0x00000000; -u32 var8005cebc = 0x00000000; -u32 var8005cec0 = 0x00000000; -u32 var8005cec4 = 0x00000000; -u32 var8005cec8 = 0x00000001; -u32 var8005cecc = 0x00000000; +u32 var8005cea0 = 0; +u32 var8005cea4 = 0; +OSScMsg g_SchedRspMsg = {OS_SC_RSP_MSG}; +bool g_SchedIsFirstTask = true; -void func00001b10(u32 value) +void schedSetCrashEnable1(bool enable) { - var8005ce64 = value; + g_SchedCrashEnable1 = enable; } -void func00001b1c(u32 value) +void schedSetCrashedUnexpectedly(bool enable) { - var8005ce60 = value; + g_SchedCrashedUnexpectedly = enable; } -void func00001b28(u32 value) +void schedSetCrashEnable2(bool enable) { - var8005ce68 = value; + g_SchedCrashEnable2 = enable; } -void func00001b34(u32 value) +void schedSetCrashRenderInterval(u32 cycles) { - var8005ce6c = value; + g_SchedCrashRenderInterval = cycles; } -void func00001b40(void *framebuffer) +void schedRenderCrashOnBuffer(void *framebuffer) { - if ((var8005ce68 && var8005ce64) || var8005ce60) { - crash0000cf54(framebuffer); - var8005ce70 = osGetCount(); + if ((g_SchedCrashEnable2 && g_SchedCrashEnable1) || g_SchedCrashedUnexpectedly) { + crashRenderFrame(framebuffer); + g_SchedCrashLastRendered = osGetCount(); } } -void func00001b98(u32 value) +void schedRenderCrashPeriodically(u32 framecount) { - if ((value & 0xf) == 0 && ((var8005ce68 && var8005ce64) || var8005ce60)) { - if (osGetCount() - var8005ce70 > var8005ce6c) { - crash0000cf54(g_FrameBuffers[0]); - crash0000cf54(g_FrameBuffers[1]); + if ((framecount & 0xf) == 0 && ((g_SchedCrashEnable2 && g_SchedCrashEnable1) || g_SchedCrashedUnexpectedly)) { + if (osGetCount() - g_SchedCrashLastRendered > g_SchedCrashRenderInterval) { + crashRenderFrame(g_FrameBuffers[0]); + crashRenderFrame(g_FrameBuffers[1]); } } } -void osCreateLog2(void) +void schedInitCrashLastRendered(void) { - var8005ce70 = osGetCount(); + g_SchedCrashLastRendered = osGetCount(); } void osCreateScheduler(OSSched *sc, OSThread *thread, u8 mode, u32 numFields) @@ -155,7 +145,7 @@ void osCreateScheduler(OSSched *sc, OSThread *thread, u8 mode, u32 numFields) sc->audioListTail = 0; sc->gfxListTail = 0; sc->retraceMsg.type = OS_SC_RETRACE_MSG; - sc->prenmiMsg.type = 5; //OS_SC_PRE_NMI_MSG; + sc->prenmiMsg.type = OS_SC_PRE_NMI_MSG; sc->thread = thread; resetThreadCreate(); @@ -179,7 +169,7 @@ void osCreateScheduler(OSSched *sc, OSThread *thread, u8 mode, u32 numFields) osSetEventMesg(OS_EVENT_DP, &sc->interruptQ, (OSMesg)RDP_DONE_MSG); osViSetEvent(&sc->interruptQ, (OSMesg)VIDEO_MSG, numFields); - osCreateLog2(); + schedInitCrashLastRendered(); osCreateThread(sc->thread, THREAD_SCHED, &__scMain, sc, bootAllocateStack(THREAD_SCHED, STACKSIZE_SCHED), THREADPRI_SCHED); osStartThread(sc->thread); } @@ -247,6 +237,12 @@ OSMesgQueue *osScGetCmdQ(OSSched *sc) return &sc->cmdQ; } +/** + * The scheduler's main loop. + * + * Most N64 games do the task scheduling on retrace (VIDEO_MSG), but PD does + * task scheduling both at retrace and when the RDP completes a task. + */ void __scMain(void *arg) { OSMesg msg = 0; @@ -261,32 +257,32 @@ void __scMain(void *arg) switch ((int) msg) { case VIDEO_MSG: if (osViGetCurrentFramebuffer() == osViGetNextFramebuffer()) { - osDpSetStatus(4); + osDpSetStatus(DPC_STATUS_FLUSH); } - func00002078(sc); __scHandleRetrace(sc); + __scHandleTasks(sc); break; case RSP_DONE_MSG: __scHandleRSP(sc); break; case RDP_DONE_MSG: - osDpSetStatus(8); + osDpSetStatus(DPC_STATUS_START_GCLK); __scHandleRDP(sc); - __scHandleRetrace(sc); + __scHandleTasks(sc); break; } } } -void __scHandleRetraceViaPri(OSSched *sc, OSScTask *t) +void schedAppendTasks(OSSched *sc, OSScTask *t) { s32 state; OSScTask *sp = 0; OSScTask *dp = 0; OSPri prevpri = osGetThreadPri(0); - osSetThreadPri(0, 31); + osSetThreadPri(0, THREADPRI_SCHED + 1); __scAppendList(sc, t); @@ -303,19 +299,33 @@ void __scHandleRetraceViaPri(OSSched *sc, OSScTask *t) osSetThreadPri(0, prevpri); } -void func00002078(OSSched *sc) +/** + * Handle a retrace (vsync) event. + * + * Audio tasks are scheduled based on retrace + a timer (approximately 6ms). + * On NTSC, this is done on every second frame if 8MB, or every second frame + * if 4MB. I guess less memory means the audio queue has to be kept smaller + * and processed more frequently. On PAL, it's every second frame regardless. + * + * Controller input is polled here. + * + * Lastly, if there's crash information available then it will be checked and + * rendered periodically (once every 16 retraces). I guess this makes it render + * if the RDP has hung. + */ +void __scHandleRetrace(OSSched *sc) { sc->frameCount++; #if VERSION >= VERSION_PAL_FINAL if (!g_Resetting && (sc->frameCount & 1)) { - osStopTimer(&var8008de18); - osSetTimer(&var8008de18, 280000, 0, amgrGetFrameMesgQueue(), &var8005cea8); + osStopTimer(&g_SchedRspTimer); + osSetTimer(&g_SchedRspTimer, 280000, 0, amgrGetFrameMesgQueue(), &g_SchedRspMsg); } #else if (!g_Resetting && ((sc->frameCount & 1) || IS4MB())) { - osStopTimer(&var8008de18); - osSetTimer(&var8008de18, 280000, 0, amgrGetFrameMesgQueue(), &var8005cea8); + osStopTimer(&g_SchedRspTimer); + osSetTimer(&g_SchedRspTimer, 280000, 0, amgrGetFrameMesgQueue(), &g_SchedRspMsg); } #endif @@ -325,10 +335,13 @@ void func00002078(OSSched *sc) joysTick(); snd0000fe18(); - func00001b98(sc->frameCount); + schedRenderCrashPeriodically(sc->frameCount); } -void __scHandleRetrace(OSSched *sc) +/** + * __scHandleTasks is called both on retrace and when the RDP completes a task. + */ +void __scHandleTasks(OSSched *sc) { s32 state; OSScTask *rspTask = 0; @@ -336,13 +349,23 @@ void __scHandleRetrace(OSSched *sc) OSScTask *sp = 0; OSScTask *dp = 0; - vi00009a88(); + profileTick(); + /** + * Read the task command queue and schedule tasks + */ while (osRecvMesg(&sc->cmdQ, (OSMesg*)&rspTask, OS_MESG_NOBLOCK) != -1) { __scAppendList(sc, rspTask); } if (sc->doAudio && sc->curRSPTask) { + /** + * Preempt the running gfx task. Note: if the RSP + * component of the graphics task has finished, but the + * RDP component is still running, we can start an audio + * task which will freeze the RDP (and save the RDP cmd + * FIFO) while the audio RSP code is running. + */ __scYield(sc); } else { state = ((sc->curRSPTask == 0) << 1) | (sc->curRDPTask == 0); @@ -352,6 +375,11 @@ void __scHandleRetrace(OSSched *sc) } } + /** + * Notify audio and graphics threads to start building the command + * lists for the next frame (client threads may choose not to + * build the list in overrun case) + */ for (client = sc->clientList; client != 0; client = client->next) { if ((*((s32*)client + 2) == 0) || ((sc->frameCount & 1) == 0)) { osSendMesg(client->msgQ, (OSMesg) &sc->retraceMsg, OS_MESG_NOBLOCK); @@ -381,6 +409,10 @@ void __scHandleRetrace(OSSched *sc) #endif } +/** + * __scHandleRSP is called when an RSP task signals that it has + * finished or yielded (at the hosts request). + */ void __scHandleRSP(OSSched *sc) { OSScTask *t, *sp = 0, *dp = 0; @@ -390,12 +422,13 @@ void __scHandleRSP(OSSched *sc) t = sc->curRSPTask; sc->curRSPTask = 0; - vi00009aa0(0x10001); + profileSetMarker(PROFILE_RSP_END); if ((t->state & OS_SC_YIELD) && osSpTaskYielded(&t->list)) { t->state |= OS_SC_YIELDED; if ((t->flags & OS_SC_TYPE_MASK) == OS_SC_XBUS) { + // Push the task back on the list t->next = sc->gfxListHead; sc->gfxListHead = t; @@ -416,9 +449,9 @@ void __scHandleRSP(OSSched *sc) } } -u32 *func000023f4(void) +u32 *schedGetDpCounters(void) { - return &var8008de38; + return g_SchedDpCounters; } void bbufResetBuffers(void) @@ -504,6 +537,9 @@ void bbufUpdateIndex2Buffer(void) bbufIncIndex2(); } +/** + * __scHandleRDP is called when an RDP task signals that it has finished. + */ void __scHandleRDP(OSSched *sc) { OSScTask *t, *sp = NULL, *dp = NULL; @@ -516,8 +552,8 @@ void __scHandleRDP(OSSched *sc) func00002d90(); } - vi00009aa0(0x10002); - osDpGetCounters(&var8008de38); + profileSetMarker(PROFILE_RDP_END); + osDpGetCounters(g_SchedDpCounters); t = sc->curRDPTask; sc->curRDPTask = NULL; @@ -533,6 +569,10 @@ void __scHandleRDP(OSSched *sc) } } +/** + * __scTaskReady checks to see if the graphics task is able to run + * based on the current state of the RCP. + */ OSScTask *__scTaskReady(OSScTask *t) { void *a; @@ -551,15 +591,20 @@ OSScTask *__scTaskReady(OSScTask *t) return 0; } +/* + * __scTaskComplete checks to see if the task is complete (all RCP + * operations have been performed) and sends the done message to the + * client if it is. + */ s32 __scTaskComplete(OSSched *sc, OSScTask *t) { if ((t->state & OS_SC_RCP_MASK) == 0) { if (t->list.t.type == 1 && (t->flags & OS_SC_SWAPBUFFER) && (t->flags & OS_SC_LAST_TASK)) { - if (var8005cec8) { + if (g_SchedIsFirstTask) { osViBlack(false); - var8005cec8 = 0; + g_SchedIsFirstTask = false; } var8005ce74 = (var8005ce74 + 1) % 2; @@ -591,7 +636,7 @@ s32 __scTaskComplete(OSSched *sc, OSScTask *t) g_ViUnblackTimer--; } - func00001b40(t->framebuffer); + schedRenderCrashOnBuffer(t->framebuffer); osViSwapBuffer(t->framebuffer); } @@ -603,6 +648,9 @@ s32 __scTaskComplete(OSSched *sc, OSScTask *t) return 0; } +/** + * Place task on either the audio or graphics queue. + */ void __scAppendList(OSSched *sc, OSScTask *t) { long type = t->list.t.type; @@ -638,14 +686,14 @@ void __scExec(OSSched *sc, OSScTask *sp, OSScTask *dp) } if (sp->list.t.type != M_AUDTASK && (sp->state & OS_SC_YIELD) == 0) { - osDpSetStatus(0x3c0); + osDpSetStatus(DPC_STATUS_CMD_BUSY | DPC_STATUS_CBUF_READY | DPC_STATUS_DMA_BUSY | DPC_STATUS_END_VALID); } if (sp->list.t.type == M_AUDTASK) { - vi00009aa0(0x30001); + profileSetMarker(PROFILE_RSP_START); } else { - vi00009aa0(0x40001); - vi00009aa0(0x20002); + profileSetMarker(PROFILE_RDP_START1); + profileSetMarker(PROFILE_RDP_START2); } sp->state &= ~(OS_SC_YIELD | OS_SC_YIELDED); @@ -688,6 +736,9 @@ void __scYield(OSSched *sc) } } +/* + * Schedules the tasks to be run on the RCP. + */ s32 __scSchedule(OSSched *sc, OSScTask **sp, OSScTask **dp, s32 availRCP) { s32 avail = availRCP; @@ -708,67 +759,65 @@ s32 __scSchedule(OSSched *sc, OSScTask **sp, OSScTask **dp, s32 availRCP) sc->audioListTail = NULL; } } - } else { - if (__scTaskReady(gfx)) { - switch (gfx->flags & OS_SC_TYPE_MASK) { - case OS_SC_XBUS: - if (gfx->state & OS_SC_YIELDED) { - if (avail & OS_SC_SP) { - *sp = gfx; - avail &= ~OS_SC_SP; + } else if (__scTaskReady(gfx)) { + switch (gfx->flags & OS_SC_TYPE_MASK) { + case OS_SC_XBUS: + if (gfx->state & OS_SC_YIELDED) { + if (avail & OS_SC_SP) { + *sp = gfx; + avail &= ~OS_SC_SP; - if (gfx->state & OS_SC_DP) { - *dp = gfx; - avail &= ~OS_SC_DP; - - if (avail & OS_SC_DP == 0) { - assert(sc->curRDPTask == gfx); - } - } - - sc->gfxListHead = sc->gfxListHead->next; - - if (sc->gfxListHead == NULL) { - sc->gfxListTail = NULL; - } - } - } else { - if (avail == (OS_SC_SP | OS_SC_DP)) { - *sp = *dp = gfx; - avail &= ~(OS_SC_SP | OS_SC_DP); - sc->gfxListHead = sc->gfxListHead->next; - - if (sc->gfxListHead == NULL) { - sc->gfxListTail = NULL; - } - } - } - break; - case OS_SC_DRAM: - case OS_SC_DP_DRAM: - case OS_SC_DP_XBUS: - if (gfx->state & OS_SC_SP) { - if (avail & OS_SC_SP) { - *sp = gfx; - avail &= ~OS_SC_SP; - } - } else if (gfx->state & OS_SC_DP) { - if (avail & OS_SC_DP) { + if (gfx->state & OS_SC_DP) { *dp = gfx; avail &= ~OS_SC_DP; - sc->gfxListHead = sc->gfxListHead->next; - if (sc->gfxListHead == NULL) { - sc->gfxListTail = NULL; + if (avail & OS_SC_DP == 0) { + assert(sc->curRDPTask == gfx); } } + + sc->gfxListHead = sc->gfxListHead->next; + + if (sc->gfxListHead == NULL) { + sc->gfxListTail = NULL; + } + } + } else { + if (avail == (OS_SC_SP | OS_SC_DP)) { + *sp = *dp = gfx; + avail &= ~(OS_SC_SP | OS_SC_DP); + sc->gfxListHead = sc->gfxListHead->next; + + if (sc->gfxListHead == NULL) { + sc->gfxListTail = NULL; + } } - break; - case OS_SC_SP_DRAM: - case OS_SC_SP_XBUS: - default: - break; } + break; + case OS_SC_DRAM: + case OS_SC_DP_DRAM: + case OS_SC_DP_XBUS: + if (gfx->state & OS_SC_SP) { + if (avail & OS_SC_SP) { + *sp = gfx; + avail &= ~OS_SC_SP; + } + } else if (gfx->state & OS_SC_DP) { + if (avail & OS_SC_DP) { + *dp = gfx; + avail &= ~OS_SC_DP; + sc->gfxListHead = sc->gfxListHead->next; + + if (sc->gfxListHead == NULL) { + sc->gfxListTail = NULL; + } + } + } + break; + case OS_SC_SP_DRAM: + case OS_SC_SP_XBUS: + default: + break; } } diff --git a/src/lib/ultra/io/gbpakinit.c b/src/lib/ultra/io/gbpakinit.c index bd89ce997..454ad8ef2 100644 --- a/src/lib/ultra/io/gbpakinit.c +++ b/src/lib/ultra/io/gbpakinit.c @@ -3,7 +3,7 @@ #include "siint.h" OSTimer var80090ab0; -OSMesgQueue var80090ad0; +OSMesgQueue g_GbpakMesgQueue; OSMesg var80090ae8; s32 osGbpakInit(OSMesgQueue *queue, OSPfs *pfs, int channel) @@ -76,9 +76,9 @@ s32 osGbpakInit(OSMesgQueue *queue, OSPfs *pfs, int channel) return ret; } - osCreateMesgQueue(&var80090ad0, &var80090ae8, 1); - osSetTimer(&var80090ab0, 937500, 0, &var80090ad0, &var80090ae8); - osRecvMesg(&var80090ad0, 0, OS_MESG_BLOCK); + osCreateMesgQueue(&g_GbpakMesgQueue, &var80090ae8, 1); + osSetTimer(&var80090ab0, 937500, 0, &g_GbpakMesgQueue, &var80090ae8); + osRecvMesg(&g_GbpakMesgQueue, 0, OS_MESG_BLOCK); pfs->queue = queue; pfs->status = 0x10; diff --git a/src/lib/ultra/io/gbpakpower.c b/src/lib/ultra/io/gbpakpower.c index 53f142aa9..3fdddac08 100644 --- a/src/lib/ultra/io/gbpakpower.c +++ b/src/lib/ultra/io/gbpakpower.c @@ -3,7 +3,7 @@ #include "siint.h" extern OSTimer var80090ab0; -extern OSMesgQueue var80090ad0; +extern OSMesgQueue g_GbpakMesgQueue; extern OSMesg var80090ae8; s32 osGbpakPower(OSPfs *pfs, s32 flag) @@ -31,8 +31,8 @@ s32 osGbpakPower(OSPfs *pfs, s32 flag) } if (flag != OS_GBPAK_POWER_OFF) { - osSetTimer(&var80090ab0, 937500, 0, &var80090ad0, &var80090ae8); - osRecvMesg(&var80090ad0, NULL, OS_MESG_BLOCK); + osSetTimer(&var80090ab0, 937500, 0, &g_GbpakMesgQueue, &var80090ae8); + osRecvMesg(&g_GbpakMesgQueue, NULL, OS_MESG_BLOCK); } return ret; diff --git a/src/lib/vi.c b/src/lib/vi.c index e51ad37bd..47346b504 100644 --- a/src/lib/vi.c +++ b/src/lib/vi.c @@ -63,36 +63,6 @@ bool g_ViIs16Bit = true; bool g_ViReconfigured = false; s32 g_ViSlot = 0; -void vi00009a80(void) -{ - // empty -} - -void vi00009a88(void) -{ - // empty -} - -void vi00009a90(void) -{ - // empty -} - -void vi00009a98(void) -{ - // empty -} - -void vi00009aa0(u32 value) -{ - // empty -} - -Gfx *viRenderDebug(Gfx *gdl) -{ - return gdl; -} - void viConfigureForLogos(void) { g_ViFrontIndex = 0; diff --git a/tools/asm_processor/build.py b/tools/asm_processor/build.py index 228dcb030..5d3c1194b 100644 --- a/tools/asm_processor/build.py +++ b/tools/asm_processor/build.py @@ -32,5 +32,8 @@ opt_flags = [x for x in compile_args if x in ['-g', '-O2', '-O1', '-framepointer preprocessed_file = tempfile.NamedTemporaryFile(prefix='preprocessed', suffix='.c') subprocess.check_call(asm_processor + opt_flags + [in_file], stdout=preprocessed_file) -subprocess.check_call(compiler + compile_args + ['-I', in_dir, '-o', out_file, preprocessed_file.name]) +try: + subprocess.check_call(compiler + compile_args + ['-I', in_dir, '-o', out_file, preprocessed_file.name]) +except subprocess.CalledProcessError: + exit(1) subprocess.check_call(asm_processor + opt_flags + [in_file, '--post-process', out_file, '--assembler', assembler_sh, '--asm-prelude', prelude]) diff --git a/tools/patchpiracysums b/tools/patchpiracysums index e691c7995..ef8a5e227 100755 --- a/tools/patchpiracysums +++ b/tools/patchpiracysums @@ -185,11 +185,11 @@ class Tool: self.fd = open(sys.argv[1], 'rb+') - self.patch(algo01, '__scHandleRetrace', 'bootPhase1') - self.patch(algo02, 'cheatMenuHandleDialog', '__scHandleRetrace') + self.patch(algo01, '__scHandleTasks', 'bootPhase1') + self.patch(algo02, 'cheatMenuHandleDialog', '__scHandleTasks') self.patch(algo03, 'propobjHandlePickupByAibot', 'func0f08e2ac') self.patch(algo04, 'chrUncloak', 'propobjHandlePickupByAibot') - self.patch(algo05, 'chrsCheckForNoise', 'func00002078') + self.patch(algo05, 'chrsCheckForNoise', '__scHandleRetrace') self.patch(algo06, 'lvInit', 'lvGetSlowMotionType') self.patch(algo07, 'propAllocateEyespy', 'lvInit') self.patch(algo08, 'chrConsiderGrenadeThrow', 'bgInit')