Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -3031,7 +3031,7 @@ struct StageSpritePrimitive {

struct GameThread {
u16 state;
u16 timer;
s16 timer;
u32 unk4;
u32 handle;
u32 unkC;
Expand Down Expand Up @@ -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[])();
Expand Down
44 changes: 14 additions & 30 deletions src/main/2824.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/pc/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading