From b19b06a5314124824a01573c80addda3f82f7585 Mon Sep 17 00:00:00 2001 From: Tharo <17233964+Thar0@users.noreply.github.com> Date: Fri, 10 Jan 2025 23:54:02 +0000 Subject: [PATCH] [iQue] Match remaining libultra/os files (#2414) * Match remaining libultra/os files * Align box id macros * Fix bss, format * Fix BSS * Clarify some comments * More bug comment * Comment * Fix BSS --- Makefile | 6 +- include/ultra64/bcp.h | 72 +++++++++++++++++++ include/variables.h | 12 +++- src/boot/z_std_dma.c | 2 +- src/code/fault_gc.c | 4 +- src/code/main.c | 4 +- src/code/z_bgcheck.c | 2 +- src/code/z_camera.c | 4 +- src/code/z_common_data.c | 2 +- src/code/z_kaleido_scope_call.c | 2 +- src/code/z_kankyo.c | 4 +- src/code/z_message.c | 2 +- src/libultra/os/getmemsize.c | 4 ++ src/libultra/os/gettime.c | 2 +- src/libultra/os/initialize.c | 71 ++++++++++++++++-- src/libultra/os/recvmesg.c | 5 +- src/libultra/os/settimer.c | 12 +--- src/libultra/os/stopthread.c | 8 +-- src/libultra/os/thread.c | 16 ++--- src/libultra/os/timerintr.c | 10 ++- src/libultra/os/virtualtophysical.c | 8 +-- .../actors/ovl_player_actor/z_player.c | 4 +- .../misc/ovl_kaleido_scope/z_kaleido_scope.c | 2 +- 23 files changed, 197 insertions(+), 61 deletions(-) diff --git a/Makefile b/Makefile index 70105ac6d5..ebba84f850 100644 --- a/Makefile +++ b/Makefile @@ -214,7 +214,7 @@ else ifeq ($(PLATFORM),GC) LIBULTRA_VERSION := L LIBULTRA_PATCH := 0 else ifeq ($(PLATFORM),IQUE) - CPP_DEFINES += -DPLATFORM_N64=0 -DPLATFORM_GC=0 -DPLATFORM_IQUE=1 -DBBPLAYER + CPP_DEFINES += -DPLATFORM_N64=0 -DPLATFORM_GC=0 -DPLATFORM_IQUE=1 LIBULTRA_VERSION := L LIBULTRA_PATCH := 0 else @@ -702,8 +702,12 @@ else $(BUILD_DIR)/src/libultra/gu/%.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/libultra/io/%.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/libultra/libc/%.o: OPTFLAGS := -O2 +ifeq ($(PLATFORM),IQUE) +$(BUILD_DIR)/src/libultra/os/%.o: OPTFLAGS := -O0 +else $(BUILD_DIR)/src/libultra/os/%.o: OPTFLAGS := -O1 endif +endif $(BUILD_DIR)/src/libleo/%.o: CC := $(CC_OLD) $(BUILD_DIR)/src/libleo/%.o: OPTFLAGS := -O2 diff --git a/include/ultra64/bcp.h b/include/ultra64/bcp.h index 027fecf3f6..78c4584fe7 100644 --- a/include/ultra64/bcp.h +++ b/include/ultra64/bcp.h @@ -190,4 +190,76 @@ */ #define PI_NAND_CTRL_REG (PI_BASE_REG + 0x48) +/** + * [31:16] Box ID + * [31:30] Hardware Revision? (osInitialize checks this and sets __osBbIsBb to 2 if != 0) + * [29:27] ?? (not seen) + * [26:25] ?? (system clock speed identifier?) + * [24:22] ?? (bootrom, checked against MI_10_REG and copied there if mismatch) + * [21:16] ?? (not seen) + * [ 7: 4] GPIO direction control + * [7] RTC Data output enable + * [6] RTC Clock output enable + * [5] Error LED output enable + * [4] Power Control output enable + * [ 3: 0] GPIO in/out value + * [3] RTC Data output value (0=low, 1=high) + * [2] RTC Clock output value (0=low, 1=high) + * [1] Error LED (0=on, 1=off) + * [0] Power Control (0=off, 1=on) + */ +#define PI_GPIO_REG (PI_BASE_REG + 0x60) + +/* Box ID */ +#define PI_GPIO_GET_BOXID(reg) ((reg) >> 16) +#define PI_GPIO_IS_HW_V2(reg) ((reg) & (3 << 30)) + +/* GPIO: Input/Output enables */ +#define PI_GPIO_I_PWR ((0 << 0) << 4) +#define PI_GPIO_O_PWR ((1 << 0) << 4) +#define PI_GPIO_I_LED ((0 << 1) << 4) +#define PI_GPIO_O_LED ((1 << 1) << 4) +#define PI_GPIO_I_RTC_CLK ((0 << 2) << 4) +#define PI_GPIO_O_RTC_CLK ((1 << 2) << 4) +#define PI_GPIO_I_RTC_DAT ((0 << 3) << 4) +#define PI_GPIO_O_RTC_DAT ((1 << 3) << 4) + +/* GPIO: Output controls */ +/* Power */ +#define PI_GPIO_PWR_OFF (0 << 0) +#define PI_GPIO_PWR_ON (1 << 0) +/* LED */ +#define PI_GPIO_LED_ON (0 << 1) +#define PI_GPIO_LED_OFF (1 << 1) +/* RTC */ +#define PI_GPIO_RTC_CLK_LO (0 << 2) +#define PI_GPIO_RTC_CLK_HI (1 << 2) +#define PI_GPIO_RTC_DAT_LO (0 << 3) +#define PI_GPIO_RTC_DAT_HI (1 << 3) + +/* GPIO: Input getters */ +#define PI_GPIO_GET_PWR(reg) (((reg) >> 0) & 1) +#define PI_GPIO_GET_LED(reg) (((reg) >> 1) & 1) +#define PI_GPIO_GET_RTC_CLK(reg) (((reg) >> 2) & 1) +#define PI_GPIO_GET_RTC_DAT(reg) (((reg) >> 3) & 1) + +/** + * [31] ? + */ +#define PI_64_REG (PI_BASE_REG + 0x64) + +/****************************************************************************** + * Additional Serial Interface (SI) Registers + */ + +/** + * ? + */ +#define SI_0C_REG (SI_BASE_REG + 0x0C) + +/** + * ? + */ +#define SI_1C_REG (SI_BASE_REG + 0x1C) + #endif diff --git a/include/variables.h b/include/variables.h index 6ad4f7ee4d..f5f4599e7a 100644 --- a/include/variables.h +++ b/include/variables.h @@ -9,15 +9,23 @@ extern Mtx D_01000000; extern void* osRomBase; extern s32 osTvType; +extern u32 osRomType; +extern u32 osVersion; extern s32 osResetType; extern s32 osCicId; extern u32 osMemSize; extern u8 osAppNMIBuffer[0x40]; extern u32 __osBbIsBb; -extern u32 __osBbHackFlags; -extern u32 __osBbPakAddress[4]; +extern u32 __osBbEepromSize; extern u32 __osBbPakSize; +extern u32 __osBbFlashSize; +extern u32 __osBbEepromAddress; +extern u32 __osBbPakAddress[4]; +extern u32 __osBbFlashAddress; +extern u32 __osBbSramSize; +extern u32 __osBbSramAddress; +extern u32 __osBbHackFlags; extern s8 D_80009430; extern vu8 gViConfigBlack; diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c index 0326a1cb60..8fe2982e7b 100644 --- a/src/boot/z_std_dma.c +++ b/src/boot/z_std_dma.c @@ -28,7 +28,7 @@ #endif #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.2:78 pal-1.0:76 pal-1.1:76" + "ntsc-1.2:70 pal-1.0:68 pal-1.1:68" StackEntry sDmaMgrStackInfo; OSMesgQueue sDmaMgrMsgQueue; diff --git a/src/code/fault_gc.c b/src/code/fault_gc.c index 5e0ce4c905..059162c162 100644 --- a/src/code/fault_gc.c +++ b/src/code/fault_gc.c @@ -40,8 +40,8 @@ * DPad-Up may be pressed to enable sending fault pages over osSyncPrintf as well as displaying them on-screen. * DPad-Down disables sending fault pages over osSyncPrintf. */ -#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-eu-mq-dbg:160 gc-jp:176 gc-jp-ce:176 gc-jp-mq:176 gc-us:176" \ - "gc-us-mq:176" +#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-eu-mq-dbg:160 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160" \ + "gc-us-mq:160" #include "global.h" #include "alloca.h" diff --git a/src/code/main.c b/src/code/main.c index ae4eb3d8f1..d2c3c9f8bc 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -23,8 +23,8 @@ extern struct IrqMgr gIrqMgr; #include "n64dd.h" #endif -#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160 gc-us-mq:160" \ - "ntsc-1.0:138 ntsc-1.1:138 ntsc-1.2:138 pal-1.0:136 pal-1.1:136" +#pragma increment_block_number "gc-eu:144 gc-eu-mq:144 gc-jp:144 gc-jp-ce:144 gc-jp-mq:144 gc-us:144 gc-us-mq:144" \ + "ntsc-1.0:130 ntsc-1.1:130 ntsc-1.2:130 pal-1.0:128 pal-1.1:128" extern u8 _buffersSegmentEnd[]; diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 8caacb9405..57a2c80289 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -2,7 +2,7 @@ #include "terminal.h" #include "line_numbers.h" -#pragma increment_block_number "ntsc-1.0:120 ntsc-1.1:120 ntsc-1.2:120" +#pragma increment_block_number "ntsc-1.0:112 ntsc-1.1:112 ntsc-1.2:112" u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* nodeList); void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector); diff --git a/src/code/z_camera.c b/src/code/z_camera.c index d5aa8ad807..cb59ef55e9 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -4,7 +4,7 @@ #include "terminal.h" #include "overlays/actors/ovl_En_Horse/z_en_horse.h" -#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ +#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ "ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" s16 Camera_RequestSettingImpl(Camera* camera, s16 requestedSetting, s16 flags); @@ -3639,7 +3639,7 @@ s32 Camera_KeepOn3(Camera* camera) { } #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.0:141 ntsc-1.1:141 ntsc-1.2:141 pal-1.0:139 pal-1.1:139" + "ntsc-1.0:133 ntsc-1.1:133 ntsc-1.2:133 pal-1.0:131 pal-1.1:131" s32 Camera_KeepOn4(Camera* camera) { static Vec3f D_8015BD50; diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 448e387af3..e8c0a58a6e 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -3,7 +3,7 @@ #include "versions.h" #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.0:192 ntsc-1.1:192 ntsc-1.2:192 pal-1.0:192 pal-1.1:192" + "ntsc-1.0:176 ntsc-1.1:176 ntsc-1.2:176 pal-1.0:160 pal-1.1:160" ALIGNED(16) SaveContext gSaveContext; u32 D_8015FA88; diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index 5dd08566dd..10fff2bb07 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -1,4 +1,4 @@ -#pragma increment_block_number "gc-eu:224 gc-eu-mq:224 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224 gc-us-mq:224" \ +#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224 gc-us-mq:224" \ "ntsc-1.0:224 ntsc-1.1:224 ntsc-1.2:224 pal-1.0:224 pal-1.1:224" #include "global.h" diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index ee48b66f96..a113a73bff 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -1,5 +1,5 @@ -#pragma increment_block_number "gc-eu:228 gc-eu-mq:228 gc-jp:212 gc-jp-ce:212 gc-jp-mq:212 gc-us:212 gc-us-mq:212" \ - "ntsc-1.0:224 ntsc-1.1:224 ntsc-1.2:224 pal-1.0:236 pal-1.1:236" +#pragma increment_block_number "gc-eu:220 gc-eu-mq:220 gc-jp:212 gc-jp-ce:212 gc-jp-mq:212 gc-us:212 gc-us-mq:212" \ + "ntsc-1.0:224 ntsc-1.1:224 ntsc-1.2:224 pal-1.0:228 pal-1.1:228" #include "global.h" #include "ultra64.h" diff --git a/src/code/z_message.c b/src/code/z_message.c index bfef10aa58..f775929a64 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -8,7 +8,7 @@ #endif #pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.0:96 ntsc-1.1:96 ntsc-1.2:96 pal-1.0:128 pal-1.1:128" + "ntsc-1.0:80 ntsc-1.1:80 ntsc-1.2:80 pal-1.0:128 pal-1.1:128" #if !PLATFORM_GC #define OCARINA_BUTTON_A_PRIM_1_R 80 diff --git a/src/libultra/os/getmemsize.c b/src/libultra/os/getmemsize.c index 787346de63..1adbd66ff4 100644 --- a/src/libultra/os/getmemsize.c +++ b/src/libultra/os/getmemsize.c @@ -3,6 +3,7 @@ #define STEP 0x100000 u32 osGetMemSize(void) { +#ifndef BBPLAYER vu32* ptr; u32 size = 0x400000; u32 data0; @@ -28,4 +29,7 @@ u32 osGetMemSize(void) { } return size; +#else + return osMemSize; +#endif } diff --git a/src/libultra/os/gettime.c b/src/libultra/os/gettime.c index 2ca90b0df9..e8943cd9e0 100644 --- a/src/libultra/os/gettime.c +++ b/src/libultra/os/gettime.c @@ -11,5 +11,5 @@ OSTime osGetTime(void) { t = __osCurrentTime; __osRestoreInt(prevInt); - return base + t; + return t + base; } diff --git a/src/libultra/os/initialize.c b/src/libultra/os/initialize.c index 427a517710..300f2743dc 100644 --- a/src/libultra/os/initialize.c +++ b/src/libultra/os/initialize.c @@ -1,4 +1,5 @@ #include "global.h" +#include "ultra64/bcp.h" typedef struct __osExceptionVector { u32 inst1; // lui $k0, %hi(__osException) @@ -59,13 +60,50 @@ void OSINITIALIZE_FUNC(void) { __osSetWatchLo(0x04900000); #endif - while (__osSiRawReadIo((void*)(PIF_RAM_END - 3), &pifdata)) { - ; +#ifdef BBPLAYER + { + u32 x, y; + + // Check for iQue Player hardware by enabling and disabling FLASH and IDE interrupts and checking if the + // register gives the correct response. + IO_WRITE(MI_EX_INTR_MASK_REG, MI_EX_INTR_MASK_SET_FLASH | MI_EX_INTR_MASK_SET_IDE); + x = IO_READ(MI_EX_INTR_MASK_REG); + IO_WRITE(MI_EX_INTR_MASK_REG, MI_EX_INTR_MASK_CLR_FLASH | MI_EX_INTR_MASK_CLR_IDE); + y = IO_READ(MI_EX_INTR_MASK_REG); + + __osBbIsBb = + ((x & (MI_EX_INTR_MASK_FLASH | MI_EX_INTR_MASK_IDE)) == (MI_EX_INTR_MASK_FLASH | MI_EX_INTR_MASK_IDE)) && + ((y & (MI_EX_INTR_MASK_FLASH | MI_EX_INTR_MASK_IDE)) == 0); } - while (__osSiRawWriteIo((void*)(PIF_RAM_END - 3), pifdata | 8)) { - ; + + //! @bug Most games do not have permission to use GPIO, so they often cannot correctly tell if they are running on + //! HW V1 or V2. + if (__osBbIsBb && PI_GPIO_IS_HW_V2(IO_READ(PI_GPIO_REG))) { + __osBbIsBb = 2; } + if (__osBbIsBb) { + // Set IPL boot parameters + osTvType = OS_TV_NTSC; + osRomType = 0; + osResetType = 0; + osVersion = 1; + osMemSize = 0x400000; + } + + if (!__osBbIsBb) { + // The PIF doesn't exist on iQue, no need to enable NMI from PIF +#endif + while (__osSiRawReadIo((void*)(PIF_RAM_END - 3), &pifdata)) { + ; + } + while (__osSiRawWriteIo((void*)(PIF_RAM_END - 3), pifdata | 8)) { + ; + } +#ifdef BBPLAYER + } +#endif + *(__osExceptionVector*)UT_VEC = __osExceptionPreamble; // TLB miss *(__osExceptionVector*)XUT_VEC = __osExceptionPreamble; // XTLB miss *(__osExceptionVector*)ECC_VEC = __osExceptionPreamble; // cache errors @@ -102,6 +140,31 @@ void OSINITIALIZE_FUNC(void) { } #endif +#ifdef BBPLAYER + if (!__osBbIsBb) { + // In a real iQue Player environment (that is, real hardware + app launched from the system menu) + // these are set on app launch by the system menu based on the contents of the game's associated + // ticket. Set some dummy values if not running on iQue Player hardware. + __osBbEepromSize = 0x200; + __osBbPakSize = 0x8000; + __osBbFlashSize = 0x20000; + __osBbEepromAddress = 0x80400000 - 0x200; + __osBbPakAddress[0] = 0x80400000 - 0x8200; + __osBbPakAddress[1] = 0; + __osBbPakAddress[2] = 0; + __osBbPakAddress[3] = 0; + __osBbFlashAddress = 0x80400000 - 0x20000; + __osBbSramSize = __osBbFlashSize; + __osBbSramAddress = __osBbFlashAddress; + } + if (__osBbIsBb) { + IO_WRITE(PI_64_REG, IO_READ(PI_64_REG) & ~0x80000000); + IO_WRITE(MI_EX_INTR_MASK_REG, MI_EX_INTR_MASK_SET_IDE); + IO_WRITE(SI_0C_REG, 0); + IO_WRITE(SI_1C_REG, (IO_READ(SI_1C_REG) & ~0x7F000000) | 0x2F400000); + } +#endif + IO_WRITE(AI_CONTROL_REG, AI_CONTROL_DMA_ON); IO_WRITE(AI_DACRATE_REG, AI_MAX_DAC_RATE - 1); IO_WRITE(AI_BITRATE_REG, AI_MAX_BIT_RATE - 1); diff --git a/src/libultra/os/recvmesg.c b/src/libultra/os/recvmesg.c index f065188cd0..3254867cce 100644 --- a/src/libultra/os/recvmesg.c +++ b/src/libultra/os/recvmesg.c @@ -7,9 +7,10 @@ s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag) { if (flag == OS_MESG_NOBLOCK) { __osRestoreInt(prevInt); return -1; + } else { + __osRunningThread->state = OS_STATE_WAITING; + __osEnqueueAndYield(&mq->mtqueue); } - __osRunningThread->state = OS_STATE_WAITING; - __osEnqueueAndYield(&mq->mtqueue); } if (msg != NULL) { diff --git a/src/libultra/os/settimer.c b/src/libultra/os/settimer.c index a876641e88..c5632e82c2 100644 --- a/src/libultra/os/settimer.c +++ b/src/libultra/os/settimer.c @@ -12,20 +12,14 @@ s32 osSetTimer(OSTimer* timer, OSTime countdown, OSTime interval, OSMesgQueue* m timer->next = NULL; timer->prev = NULL; timer->interval = interval; - - if (countdown != 0) { - timer->value = countdown; - } else { - timer->value = interval; - } + timer->value = (countdown != 0) ? countdown : interval; timer->mq = mq; timer->msg = msg; #if LIBULTRA_VERSION >= LIBULTRA_VERSION_K prevInt = __osDisableInt(); - if (__osTimerList->next != __osTimerList) { - if (1) {} - + if (__osTimerList->next == __osTimerList) { + } else { next = __osTimerList->next; count = osGetCount(); value = count - __osTimerCounter; diff --git a/src/libultra/os/stopthread.c b/src/libultra/os/stopthread.c index 54a236b49b..53aecd940a 100644 --- a/src/libultra/os/stopthread.c +++ b/src/libultra/os/stopthread.c @@ -2,13 +2,7 @@ void osStopThread(OSThread* thread) { register u32 prevInt = __osDisableInt(); - register u32 state; - - if (thread == NULL) { - state = OS_STATE_RUNNING; - } else { - state = thread->state; - } + register u16 state = (thread == NULL) ? OS_STATE_RUNNING : thread->state; switch (state) { case OS_STATE_RUNNING: diff --git a/src/libultra/os/thread.c b/src/libultra/os/thread.c index c78a34e4ec..0263acb454 100644 --- a/src/libultra/os/thread.c +++ b/src/libultra/os/thread.c @@ -6,16 +6,16 @@ OSThread* __osActiveQueue = (OSThread*)&__osThreadTail; OSThread* __osRunningThread = NULL; OSThread* __osFaultedThread = NULL; -void __osDequeueThread(OSThread** queue, OSThread* thread) { - register OSThread** a2 = queue; - register OSThread* a3 = *a2; +void __osDequeueThread(register OSThread** queue, register OSThread* thread) { + register OSThread* pred = (OSThread*)queue; + register OSThread* succ = pred->next; - while (a3 != NULL) { - if (a3 == thread) { - *a2 = thread->next; + while (succ != NULL) { + if (succ == thread) { + pred->next = thread->next; return; } - a2 = &a3->next; - a3 = *a2; + pred = succ; + succ = pred->next; } } diff --git a/src/libultra/os/timerintr.c b/src/libultra/os/timerintr.c index ce5c12fc5f..3f94368b20 100644 --- a/src/libultra/os/timerintr.c +++ b/src/libultra/os/timerintr.c @@ -11,10 +11,8 @@ void __osTimerServicesInit(void) { __osCurrentTime = 0; __osBaseCounter = 0; __osViIntrCount = 0; - __osTimerList->prev = __osTimerList; - __osTimerList->next = __osTimerList->prev; - __osTimerList->value = 0; - __osTimerList->interval = __osTimerList->value; + __osTimerList->next = __osTimerList->prev = __osTimerList; + __osTimerList->interval = __osTimerList->value = 0; __osTimerList->mq = NULL; __osTimerList->msg = NULL; } @@ -28,7 +26,7 @@ void __osTimerInterrupt(void) { return; } - while (true) { + for (;;) { timer = __osTimerList->next; if (timer == __osTimerList) { __osSetCompare(0); @@ -72,7 +70,7 @@ void __osSetTimerIntr(OSTime time) { prevInt = __osDisableInt(); __osTimerCounter = osGetCount(); - newTime = time + __osTimerCounter; + newTime = __osTimerCounter + time; __osSetCompare((u32)newTime); __osRestoreInt(prevInt); } diff --git a/src/libultra/os/virtualtophysical.c b/src/libultra/os/virtualtophysical.c index 5f8f79d83c..0037572232 100644 --- a/src/libultra/os/virtualtophysical.c +++ b/src/libultra/os/virtualtophysical.c @@ -3,11 +3,9 @@ u32 osVirtualToPhysical(void* vaddr) { if (IS_KSEG0(vaddr)) { return K0_TO_PHYS(vaddr); - } - - if (IS_KSEG1(vaddr)) { + } else if (IS_KSEG1(vaddr)) { return K1_TO_PHYS(vaddr); + } else { + return __osProbeTLB(vaddr); } - - return __osProbeTLB(vaddr); } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index e7433105ae..c1f3fe2c58 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -338,14 +338,14 @@ static s32 D_80858AA0; // TODO: There's probably a way to match BSS ordering with less padding by spreading the variables out and moving // data around. It would be easier if we had more options for controlling BSS ordering in debug. -#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ +#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ "ntsc-1.0:192 ntsc-1.1:192 ntsc-1.2:192 pal-1.0:192 pal-1.1:192" static s32 sSavedCurrentMask; static Vec3f sInteractWallCheckResult; static Input* sControlInput; -#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160 gc-us-mq:160" \ +#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ "ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" // .data diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c index 23648dd085..7a6cff2334 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c @@ -16,7 +16,7 @@ #include "terminal.h" #include "versions.h" -#pragma increment_block_number "ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" +#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" #if !PLATFORM_GC #define KALEIDO_PROMPT_CURSOR_R 100