diff --git a/include/common.h b/include/common.h index ec064a2c..f345f771 100644 --- a/include/common.h +++ b/include/common.h @@ -3031,7 +3031,7 @@ struct StageSpritePrimitive { struct GameThread { u16 state; - u16 timer; + s16 timer; u32 unk4; u32 handle; u32 unkC; @@ -4489,8 +4489,12 @@ extern s16 D_8016DEA4; #endif #ifdef MMX4_WIN32 #define D_801F8300 (*(struct GameThread**)(win32_main_ram + 0x1F8300)) +#define GAME_THREADS ((struct GameThread*)(win32_main_ram + 0x1F8100)) +#define CUR_GAME_THREAD (*(struct GameThread**)(win32_main_ram + 0x1F8300)) #else extern struct GameThread* D_801F8300; +#define GAME_THREADS ((struct GameThread*)0x801F8100) +#define CUR_GAME_THREAD (*(struct GameThread**)0x801F8300) #endif extern void (*g_MegamanInBriefingRoomUpdateFuncs[2])(); extern void (*g_TitleUpdateFuncs[])(); diff --git a/src/main/2824.c b/src/main/2824.c index 8e9860fe..782faa67 100644 --- a/src/main/2824.c +++ b/src/main/2824.c @@ -192,9 +192,6 @@ void func_80012560(void) } #endif -#ifdef VERSION_EU -INCLUDE_ASM("main/nonmatchings/2824", func_80012600); -#else void func_80012600(void) { #ifdef MMX4_PC @@ -209,45 +206,32 @@ void func_80012600(void) mmx4_pc_thread_run(slot); } #else - u16 temp_v0_2; - u16 temp_v1; - void* temp_v0; - struct GameThread* temp_v0_3; - struct GameThread* temp_v0_4; - - D_801F8300 = (void*)0x801F8100; + CUR_GAME_THREAD = GAME_THREADS; do { - temp_v1 = ((struct GameThread*)D_801F8300)->state; - switch (temp_v1) { - case 0x1: - temp_v0_2 = ((struct GameThread*)D_801F8300)->timer - 1; - ((struct GameThread*)D_801F8300)->timer = temp_v0_2; - if ((temp_v0_2 << 0x10) == 0) { - case 0x2: - case 0x4: + switch (CUR_GAME_THREAD->state) { + case 1: + CUR_GAME_THREAD->timer--; + if (CUR_GAME_THREAD->timer == 0) { + case 2: + case 4: case 0x7F: - temp_v0_3 = *(struct GameThread**)0x801F8300; - temp_v0_3->state = 0x7F; - ChangeTh(temp_v0_3->handle); + CUR_GAME_THREAD->state = 0x7F; + ChangeTh(CUR_GAME_THREAD->handle); if (D_800EE458 != 0) { D_800EE458 = 0; EnterCriticalSection(); - CloseTh((*(struct GameThread**)0x801F8300)->handle); - temp_v0_4 = *(struct GameThread**)0x801F8300; - (*(struct GameThread**)0x801F8300)->handle = OpenTh( - (long (*)())D_8012F490, temp_v0_4->stack, - temp_v0_4->global_pointer); + CloseTh(CUR_GAME_THREAD->handle); + CUR_GAME_THREAD->handle = OpenTh((long (*)())D_8012F490, + CUR_GAME_THREAD->stack, CUR_GAME_THREAD->global_pointer); ExitCriticalSection(); } } break; } - temp_v0 = (u8*)*(void**)0x801F8300 + 0x80; - *(void**)0x801F8300 = temp_v0; - } while ((u32)temp_v0 <= 0x801F82FFU); + CUR_GAME_THREAD++; + } while (CUR_GAME_THREAD < &GAME_THREADS[4]); #endif } -#endif #ifdef VERSION_EU INCLUDE_ASM("main/nonmatchings/2824", func_80012740); diff --git a/src/pc/threads.c b/src/pc/threads.c index 44335afc..17acf0c3 100644 --- a/src/pc/threads.c +++ b/src/pc/threads.c @@ -141,7 +141,7 @@ void mmx4_pc_thread_yield(void) if (slot < 0) abort(); if (thread_debug_enabled()) - fprintf(stderr, "MMX4 PC: thread %d yield state=%u timer=%u\n", slot, + fprintf(stderr, "MMX4 PC: thread %d yield state=%u timer=%d\n", slot, game_threads[slot].state, game_threads[slot].timer); #ifdef MMX4_PC_ASAN __sanitizer_start_switch_fiber(