summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcadmic <cadmic24@gmail.com>2025-01-10 09:47:55 -0800
committerGitHub <noreply@github.com>2025-01-10 18:47:55 +0100
commite4ad4e5eeefd27fe67b7f29fbac884a7d8a986d2 (patch)
tree20579a049afeedd10a8a74f7e333798fa90c0835
parent26f91bd3bb51bcac0dc06f21f345beedfe663bcb (diff)
[iQue] Match remaining src/boot files (#2417)
* [iQue] Match remaining src/boot files * Fix debug ROM * Use -funsigned-char * Sort ique before gc in LNx macros
-rw-r--r--Makefile4
-rw-r--r--include/functions.h3
-rw-r--r--include/line_numbers.h16
-rw-r--r--spec4
-rw-r--r--src/boot/is_debug_ique.c8
-rw-r--r--src/boot/z_locale.c10
-rw-r--r--src/boot/z_std_dma.c91
-rw-r--r--src/code/graph.c6
-rw-r--r--src/code/padmgr.c2
-rw-r--r--src/code/sys_cfb.c2
-rw-r--r--src/code/z_play.c2
-rw-r--r--tools/disasm/ique-cn/files_boot.csv2
-rw-r--r--undefined_syms.txt1
13 files changed, 82 insertions, 69 deletions
diff --git a/Makefile b/Makefile
index 47f82a7c2..ace6cb0f2 100644
--- a/Makefile
+++ b/Makefile
@@ -569,7 +569,7 @@ ifeq ($(PLATFORM),IQUE)
# Some files are compiled with EGCS on iQue
EGCS_O_FILES += $(BUILD_DIR)/src/boot/boot_main.o
EGCS_O_FILES += $(BUILD_DIR)/src/boot/idle.o
-EGCS_O_FILES += $(BUILD_DIR)/src/boot/inflate.o
+EGCS_O_FILES += $(BUILD_DIR)/src/boot/is_debug_ique.o
EGCS_O_FILES += $(BUILD_DIR)/src/boot/z_locale.o
EGCS_O_FILES += $(BUILD_DIR)/src/boot/z_std_dma.o
# EGCS_O_FILES += $(BUILD_DIR)/src/code/z_actor.o
@@ -589,7 +589,7 @@ EGCS_O_FILES += $(BUILD_DIR)/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map.o
EGCS_O_FILES += $(BUILD_DIR)/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.o
$(EGCS_O_FILES): CC := $(EGCS_CC)
-$(EGCS_O_FILES): CFLAGS := $(EGCS_CFLAGS) -mno-abicalls
+$(EGCS_O_FILES): CFLAGS := $(EGCS_CFLAGS) -mno-abicalls -funsigned-char
$(EGCS_O_FILES): MIPS_VERSION :=
endif
diff --git a/include/functions.h b/include/functions.h
index 092616bce..f89ce3a0a 100644
--- a/include/functions.h
+++ b/include/functions.h
@@ -9,9 +9,6 @@ void Main_ThreadEntry(void* arg);
void Idle_ThreadEntry(void* arg);
void ViConfig_UpdateVi(u32 black);
void ViConfig_UpdateBlack(void);
-void* Yaz0_FirstDMA(void);
-void* Yaz0_NextDMA(u8* curSrcPos);
-void Yaz0_DecompressImpl(u8* src, u8* dst);
#if !PLATFORM_IQUE
void Yaz0_Decompress(uintptr_t romStart, u8* dst, size_t size);
#else
diff --git a/include/line_numbers.h b/include/line_numbers.h
index f0d0ae5fa..bc11d555d 100644
--- a/include/line_numbers.h
+++ b/include/line_numbers.h
@@ -52,16 +52,16 @@
#define LN2(ntsc_1_0, ntsc_1_1, other) \
LN(ntsc_1_0, ntsc_1_1, other, other, other, other, other, other, other, other, other, other, other, other)
-// NTSC 1.0, Gamecube, and all the other versions
-#define LN3(ntsc_1_0, other, gc) \
- LN(ntsc_1_0, other, other, other, other, gc, gc, gc, gc, gc, gc, gc, gc, gc)
+// NTSC 1.0, iQue, GameCube, and all the other versions
+#define LN3(ntsc_1_0, other, ique, gc) \
+ LN(ntsc_1_0, other, other, other, other, gc, gc, gc, gc, gc, gc, gc, gc, ique)
-// NTSC 1.0, NTSC 1.1, Gamecube, and all the other versions
-#define LN4(ntsc_1_0, ntsc_1_1, other, gc, ique) \
+// NTSC 1.0, NTSC 1.1, iQue, GameCube, and all the other versions
+#define LN4(ntsc_1_0, ntsc_1_1, other, ique, gc) \
LN(ntsc_1_0, ntsc_1_1, other, other, other, gc, gc, gc, gc, gc, gc, gc, gc, ique)
-// NTSC 1.0, NTSC 1.1, NTSC 1.2/PAL 1.0, Gamecube US/JP, Gamecube EU, and Gamecube CE
-#define LN5(ntsc_1_0, ntsc_1_1, other, pal_1_1, gc_ntsc, gc_eu, gc_jp_ce) \
- LN(ntsc_1_0, ntsc_1_1, other, other, pal_1_1, gc_ntsc, gc_ntsc, gc_ntsc, gc_ntsc, gc_eu, gc_eu, gc_eu, gc_jp_ce, gc_jp_ce)
+// NTSC 1.0, NTSC 1.1, NTSC 1.2/PAL 1.0, iQue, Gamecube US/JP, Gamecube EU, and Gamecube CE
+#define LN5(ntsc_1_0, ntsc_1_1, other, pal_1_1, ique, gc_ntsc, gc_eu, gc_jp_ce) \
+ LN(ntsc_1_0, ntsc_1_1, other, other, pal_1_1, gc_ntsc, gc_ntsc, gc_ntsc, gc_ntsc, gc_eu, gc_eu, gc_eu, gc_jp_ce, ique)
#endif
diff --git a/spec b/spec
index f68610d9e..1adb93992 100644
--- a/spec
+++ b/spec
@@ -35,7 +35,11 @@ beginseg
#if DEBUG_FEATURES
include "$(BUILD_DIR)/src/boot/assert.o"
#endif
+#if !PLATFORM_IQUE
include "$(BUILD_DIR)/src/boot/is_debug.o"
+#else
+ include "$(BUILD_DIR)/src/boot/is_debug_ique.o"
+#endif
include "$(BUILD_DIR)/src/boot/driverominit.o"
include "$(BUILD_DIR)/src/boot/mio0.o"
include "$(BUILD_DIR)/src/libu64/stackcheck.o"
diff --git a/src/boot/is_debug_ique.c b/src/boot/is_debug_ique.c
new file mode 100644
index 000000000..a78fef823
--- /dev/null
+++ b/src/boot/is_debug_ique.c
@@ -0,0 +1,8 @@
+void osSyncPrintfUnused() {
+}
+
+void osSyncPrintf() {
+}
+
+void rmonPrintf() {
+}
diff --git a/src/boot/z_locale.c b/src/boot/z_locale.c
index 35580e381..f320f1e0f 100644
--- a/src/boot/z_locale.c
+++ b/src/boot/z_locale.c
@@ -7,7 +7,7 @@
s32 gCurrentRegion = 0;
void Locale_Init(void) {
-#if PLATFORM_N64
+#if !PLATFORM_GC
ALIGNED(4) u8 regionInfo[4];
u8 countryCode;
@@ -24,6 +24,7 @@ void Locale_Init(void) {
countryCode = sCartInfo.countryCode;
#endif
+#if !PLATFORM_IQUE
switch (countryCode) {
case 'J': // "NTSC-J (Japan)"
gCurrentRegion = REGION_JP;
@@ -40,13 +41,16 @@ void Locale_Init(void) {
PRINTF_COLOR_ERROR();
PRINTF(T("z_locale_init: 日本用かアメリカ用か判別できません\n",
"z_locale_init: Can't tell if it's for Japan or America\n"));
- LogUtils_HungupThread("../z_locale.c", LN4(86, 92, 101, 118, UNK_LINE));
- PRINTF_RST();
+ LogUtils_HungupThread("../z_locale.c", LN4(86, 92, 101, UNK_LINE, 118));
+ PRINTF(VT_RST);
break;
}
PRINTF(T("z_locale_init:日本用かアメリカ用か3コンで判断させる\n",
"z_locale_init: Determine whether it is for Japan or America using 3 controls\n"));
+#else
+ gCurrentRegion = REGION_US;
+#endif
}
void Locale_ResetRegion(void) {
diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c
index ea934a497..0326a1cb6 100644
--- a/src/boot/z_std_dma.c
+++ b/src/boot/z_std_dma.c
@@ -53,11 +53,20 @@ const char* sDmaMgrFileNames[] = {
#include "tables/dmadata_table.h"
};
+#undef DEFINE_DMA_ENTRY
+
#endif
-#undef DEFINE_DMA_ENTRY
+#define SET_IOMSG(ioMsg, queue, rom, ram, buffSize) \
+ do { \
+ (ioMsg).hdr.pri = OS_MESG_PRI_NORMAL; \
+ (ioMsg).hdr.retQueue = (queue); \
+ (ioMsg).devAddr = (rom); \
+ (ioMsg).dramAddr = (ram); \
+ (ioMsg).size = (buffSize); \
+ } while (0)
-#if PLATFORM_N64 || DEBUG_FEATURES
+#if !PLATFORM_GC || DEBUG_FEATURES
/**
* Compares `str1` and `str2`.
*
@@ -103,6 +112,9 @@ s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size) {
OSMesg msg;
s32 ret;
size_t buffSize = gDmaMgrDmaBuffSize;
+#if DEBUG_FEATURES
+ UNUSED s32 pad;
+#endif
if (buffSize == 0) {
buffSize = DMAMGR_DEFAULT_BUFSIZE;
@@ -116,13 +128,7 @@ s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size) {
// The system avoids large DMAs as these would stall the PI for too long, potentially causing issues with
// audio. To allow audio to continue to DMA whenever it needs to, other DMAs are split into manageable chunks.
- if (1) {} // Necessary to match
-
- ioMsg.hdr.pri = OS_MESG_PRI_NORMAL;
- ioMsg.hdr.retQueue = &queue;
- ioMsg.devAddr = rom;
- ioMsg.dramAddr = ram;
- ioMsg.size = buffSize;
+ SET_IOMSG(ioMsg, &queue, rom, ram, buffSize);
if (gDmaMgrVerbose == 10) {
PRINTF(T("%10lld ノーマルDMA %08x %08x %08x (%d)\n", "%10lld Normal DMA %08x %08x %08x (%d)\n"),
@@ -151,15 +157,9 @@ s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size) {
ram = (u8*)ram + buffSize;
}
- if (1) { // Also necessary to match
- s32 pad[2];
- }
+ SET_IOMSG(ioMsg, &queue, rom, ram, size);
- ioMsg.hdr.pri = OS_MESG_PRI_NORMAL;
- ioMsg.hdr.retQueue = &queue;
- ioMsg.devAddr = rom;
- ioMsg.dramAddr = ram;
- ioMsg.size = size;
+ { UNUSED s32 pad2; }
if (gDmaMgrVerbose == 10) {
PRINTF(T("%10lld ノーマルDMA %08x %08x %08x (%d)\n", "%10lld Normal DMA %08x %08x %08x (%d)\n"),
@@ -242,11 +242,7 @@ void DmaMgr_DmaFromDriveRom(void* ram, uintptr_t rom, size_t size) {
osInvalDCache(ram, size);
osCreateMesgQueue(&queue, &msg, 1);
- ioMsg.hdr.retQueue = &queue;
- ioMsg.hdr.pri = OS_MESG_PRI_NORMAL;
- ioMsg.devAddr = rom;
- ioMsg.dramAddr = ram;
- ioMsg.size = size;
+ SET_IOMSG(ioMsg, &queue, rom, ram, size);
handle->transferInfo.cmdType = 2;
osEPiStartDma(handle, &ioMsg, OS_READ);
@@ -350,7 +346,7 @@ const char* DmaMgr_GetFileName(uintptr_t vrom) {
return ret;
#elif PLATFORM_GC
return "";
-#elif PLATFORM_N64
+#else
return "??";
#endif
}
@@ -380,19 +376,16 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
if (vrom >= iter->file.vromStart && vrom < iter->file.vromEnd) {
// Found the region this request falls into
-#if PLATFORM_N64
- // Based on the MM Debug ROM, these strings are part of the condition for the empty if statement below,
- // as `... && DmaMgr_StrCmp("", "kanji") != 0 && DmaMgr_StrCmp("", "link_animetion") != 0`
- (void)"";
- (void)"kanji";
- (void)"";
- (void)"link_animetion";
-#endif
-
if (0) {
- // The string is defined in .rodata of debug builds but not used, suggesting a debug print is here
- // but was optimized out in some way.
- PRINTF("DMA ROM:%08X RAM:%08X SIZE:%08X %s\n", vrom, ram, size, filename);
+#if !PLATFORM_GC
+ // Based on the MM Debug ROM, these strings are part of the condition for the empty if statement below
+ if (DmaMgr_StrCmp("", "kanji") != 0 && DmaMgr_StrCmp("", "link_animetion") != 0)
+#endif
+ {
+ // The string is defined in .rodata of debug builds but not used, suggesting a debug print is here
+ // but was optimized out in some way.
+ PRINTF("DMA ROM:%08X RAM:%08X SIZE:%08X %s\n", vrom, ram, size, filename);
+ }
}
if (iter->romEnd == 0) {
@@ -405,10 +398,10 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
DMA_ERROR(req, filename, "Segment Alignment Error",
T("セグメント境界をまたがってDMA転送することはできません",
"DMA transfers cannot cross segment boundaries"),
- "../z_std_dma.c", LN3(575, 578, 726));
+ "../z_std_dma.c", LN3(575, 578, 595, 726));
}
- DmaMgr_DmaRomToRam(iter->romStart + (vrom - iter->file.vromStart), ram, size);
+ DmaMgr_DmaRomToRam(iter->romStart + vrom - iter->file.vromStart, ram, size);
found = true;
if (0) {
@@ -417,16 +410,16 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
} else {
// File is compressed. Files that are stored compressed must be loaded into RAM all at once.
- romStart = iter->romStart;
romSize = iter->romEnd - iter->romStart;
+ romStart = iter->romStart;
- if (vrom != iter->file.vromStart) {
+ if (iter->file.vromStart != vrom) {
// Error, requested vrom is not the start of a file
DMA_ERROR(req, filename, "Can't Transfer Segment",
T("圧縮されたセグメントの途中からはDMA転送することはできません",
"DMA transfer cannot be performed from the middle of a compressed segment"),
- "../z_std_dma.c", LN3(595, 598, 746));
+ "../z_std_dma.c", LN3(595, 598, 615, 746));
}
if (size != iter->file.vromEnd - iter->file.vromStart) {
@@ -435,7 +428,7 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
DMA_ERROR(req, filename, "Can't Transfer Segment",
T("圧縮されたセグメントの一部だけをDMA転送することはできません",
"It is not possible to DMA only part of a compressed segment"),
- "../z_std_dma.c", LN3(601, 604, 752));
+ "../z_std_dma.c", LN3(601, 604, 621, 752));
}
// Reduce the thread priority and decompress the file, the decompression routine handles the DMA
@@ -458,7 +451,7 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
break;
}
-#if PLATFORM_N64
+#if !PLATFORM_GC
if (i != 0) {
i += 4;
}
@@ -475,11 +468,12 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
DMA_ERROR(req, NULL, "DATA DON'T EXIST",
T("該当するデータが存在しません", "Corresponding data does not exist"), "../z_std_dma.c",
- LN3(621, 624, 771));
+ LN3(621, 624, 641, 771));
return;
} else {
// ROM is uncompressed, allow arbitrary DMA even if the region is not marked in the filesystem
- DmaMgr_DmaRomToRam(vrom, ram, size);
+ romStart = vrom;
+ DmaMgr_DmaRomToRam(romStart, ram, size);
if (0) {
PRINTF(T("No Press ROM:%08X RAM:%08X SIZE:%08X (非公式)\n",
@@ -540,6 +534,10 @@ s32 DmaMgr_RequestAsync(DmaRequest* req, void* ram, uintptr_t vrom, size_t size,
OSMesg msg) {
static s32 sDmaMgrQueueFullLogged = 0;
+#if PLATFORM_IQUE
+ PRINTF("dmacopy_bg(%x, %x, %x, %x, %x, %x, %x)\n", req, ram, vrom, size, unk, queue, msg);
+#endif
+
#if DEBUG_FEATURES
if ((ram == NULL) || (osMemSize < OS_K0_TO_PHYSICAL(ram) + size) || (vrom & 1) || (vrom > 0x4000000) ||
(size == 0) || (size & 1)) {
@@ -614,9 +612,10 @@ void DmaMgr_Init(void) {
// DMA the dma data table to RAM
DmaMgr_DmaRomToRam((uintptr_t)_dmadataSegmentRomStart, _dmadataSegmentStart,
(u32)(_dmadataSegmentRomEnd - _dmadataSegmentRomStart));
- PRINTF("dma_rom_ad[]\n");
#if DEBUG_FEATURES
+ PRINTF("dma_rom_ad[]\n");
+
name = sDmaMgrFileNames;
iter = gDmaDataTable;
idx = 0;
@@ -647,7 +646,7 @@ void DmaMgr_Init(void) {
PRINTF("_bootSegmentRomStart(%08x) != dma_rom_ad[0].rom_b(%08x)\n", _bootSegmentRomStart,
gDmaDataTable[0].file.vromEnd);
//! @bug The main code file where fault.c resides is not yet loaded
- Fault_AddHungupAndCrash("../z_std_dma.c", LN3(837, 840, 1055));
+ Fault_AddHungupAndCrash("../z_std_dma.c", LN3(837, 840, 859, 1055));
}
// Start the DMA manager
diff --git a/src/code/graph.c b/src/code/graph.c
index 348fe4bf9..046e04d37 100644
--- a/src/code/graph.c
+++ b/src/code/graph.c
@@ -380,7 +380,7 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
PRINTF("%c", BEL);
PRINTF(VT_COL(RED, WHITE) T("ダイナミック領域先頭が破壊されています\n", "Dynamic area head is destroyed\n")
VT_RST);
- Fault_AddHungupAndCrash("../graph.c", LN4(937, 940, 951, 1070, 1067));
+ Fault_AddHungupAndCrash("../graph.c", LN4(937, 940, 951, 1067, 1070));
}
if (pool->tailMagic != GFXPOOL_TAIL_MAGIC) {
@@ -388,7 +388,7 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
PRINTF("%c", BEL);
PRINTF(VT_COL(RED, WHITE)
T("ダイナミック領域末尾が破壊されています\n", "Dynamic region tail is destroyed\n") VT_RST);
- Fault_AddHungupAndCrash("../graph.c", LN4(943, 946, 957, 1076, 1073));
+ Fault_AddHungupAndCrash("../graph.c", LN4(943, 946, 957, 1073, 1076));
}
}
@@ -481,7 +481,7 @@ void Graph_ThreadEntry(void* arg0) {
sprintf(faultMsg, "CLASS SIZE= %d bytes", size);
Fault_AddHungupAndCrashImpl("GAME CLASS MALLOC FAILED", faultMsg);
#else
- Fault_AddHungupAndCrash("../graph.c", LN4(1067, 1070, 1081, 1200, 1197));
+ Fault_AddHungupAndCrash("../graph.c", LN4(1067, 1070, 1081, 1197, 1200));
#endif
}
diff --git a/src/code/padmgr.c b/src/code/padmgr.c
index 373d4e905..b5f76b721 100644
--- a/src/code/padmgr.c
+++ b/src/code/padmgr.c
@@ -327,7 +327,7 @@ void PadMgr_UpdateInputs(PadMgr* padMgr) {
default:
// Unknown error response
LOG_HEX("padnow1->errno", pad->errno, "../padmgr.c", 396);
- Fault_AddHungupAndCrash("../padmgr.c", LN3(379, 382, 397));
+ Fault_AddHungupAndCrash("../padmgr.c", LN3(379, 382, 397, 397));
break;
}
diff --git a/src/code/sys_cfb.c b/src/code/sys_cfb.c
index e175ddf94..c3b29d7ac 100644
--- a/src/code/sys_cfb.c
+++ b/src/code/sys_cfb.c
@@ -34,7 +34,7 @@ void SysCfb_Init(s32 n64dd) {
PRINTF("RAM4M mode\n");
sSysCfbEnd = 0x80400000;
} else {
- LogUtils_HungupThread("../sys_cfb.c", LN4(305, 308, 322, 354, 341));
+ LogUtils_HungupThread("../sys_cfb.c", LN4(305, 308, 322, 341, 354));
}
screenSize = SCREEN_WIDTH * SCREEN_HEIGHT;
diff --git a/src/code/z_play.c b/src/code/z_play.c
index dc61e491c..d6fc0c660 100644
--- a/src/code/z_play.c
+++ b/src/code/z_play.c
@@ -177,7 +177,7 @@ void Play_SetupTransition(PlayState* this, s32 transitionType) {
break;
default:
- HUNGUP_AND_CRASH("../z_play.c", LN5(2263, 2266, 2269, 2272, 2287, 2290, 2293));
+ HUNGUP_AND_CRASH("../z_play.c", LN5(2263, 2266, 2269, 2272, 2282, 2287, 2290, 2293));
break;
}
}
diff --git a/tools/disasm/ique-cn/files_boot.csv b/tools/disasm/ique-cn/files_boot.csv
index e4d69b501..dfbbf225b 100644
--- a/tools/disasm/ique-cn/files_boot.csv
+++ b/tools/disasm/ique-cn/files_boot.csv
@@ -5,7 +5,7 @@ offset,vram,.text
4D0,80000920,src/boot/z_std_dma
B50,80000FA0,src/boot/inflate
2830,80002C80,src/boot/z_locale
-2870,80002CC0,src/boot/is_debug
+2870,80002CC0,src/boot/is_debug_ique
2890,80002CE0,src/boot/driverominit
2A70,80002EC0,src/boot/mio0
2B20,80002F70,src/libu64/stackcheck
diff --git a/undefined_syms.txt b/undefined_syms.txt
index 6f663eae8..4774fe414 100644
--- a/undefined_syms.txt
+++ b/undefined_syms.txt
@@ -11,6 +11,7 @@ D_0F000000 = 0x0F000000;
D_06000000 = 0x06000000;
#if PLATFORM_IQUE
+gzip_decompress = 0x80002C3C;
__divdi3 = 0x80008010;
__moddi3 = 0x800085F0;
__udivdi3 = 0x80008B80;