From 6e38066c45fc3f1d47ecc085c6410b6aff4c3191 Mon Sep 17 00:00:00 2001 From: Cuyler36 Date: Sat, 25 Mar 2023 00:24:06 -0400 Subject: [PATCH] Get graph.c linked --- config/rel_disasm_overrides.yml | 3 +- config/rel_slices.yml | 17 ++-- config/symbols.yml | 3 + include/audio.h | 17 ++++ include/game.h | 10 +- include/graph.h | 9 +- include/libjsys/jsyswrapper.h | 17 ++++ include/m_bgm.h | 16 +++ include/m_vibctl.h | 16 +++ include/padmgr.h | 1 + include/sys_dynamic.h | 69 +++++++------ include/sys_ucode.h | 2 +- include/zurumode.h | 2 +- rel/graph.c | 175 +++++++++++++++++--------------- rel/sys_dynamic.c | 3 + 15 files changed, 223 insertions(+), 137 deletions(-) create mode 100644 include/audio.h create mode 100644 include/libjsys/jsyswrapper.h create mode 100644 include/m_bgm.h create mode 100644 include/m_vibctl.h create mode 100644 rel/sys_dynamic.c diff --git a/config/rel_disasm_overrides.yml b/config/rel_disasm_overrides.yml index b500327b..b59d4b45 100644 --- a/config/rel_disasm_overrides.yml +++ b/config/rel_disasm_overrides.yml @@ -2,4 +2,5 @@ trim_ctors: true trim_dtors: true symbol_aligns: 0x8064d500 : 0x20 - 0x8125a7c0 : 0x20 \ No newline at end of file + 0x8125a7c0 : 0x20 # construct_skip + 0x81361820 : 0x20 # S_back_title_timer \ No newline at end of file diff --git a/config/rel_slices.yml b/config/rel_slices.yml index 5cfc5647..07c22600 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -13,17 +13,10 @@ TwoHeadArena.c: .text: [0x80404B40, 0x80404C68] gfxalloc.c: .text: [0x804054b0, 0x80405518] -#zurumode/zerucheck_init.c: -# .text: [0x8040eb38, 0x8040EB50] -#zurumode/zerucheck_key_check.c: -# .text: [0x8040EB50, 0x8040EDA8] -#zurumode/zurumode_cleanup.c: -# .text: [0x8040efc4, 0x8040f008] -# zurumode/zurumode_init.c: - # .text: [0x8040ef58, 0x8040efc4] - # .bss: [0x812f9670, 0x812f9680] -#zurumode/zurumode_update.c: - #.text: [0x8040EDA8, 0x8040ee74] +graph.c: + .text: [0x80405518, 0x80405EC8] + .data: [0x8065ECA8, 0x8065ECB0] + .bss: [0x812F31E8, 0x812F3560] zurumode.c: .text: [0x8040eb38, 0x8040f008] .bss: [0x812f9670, 0x812f9680] @@ -32,6 +25,8 @@ m_random_field/mRF_MakePerfectBit.c: .text: [0x8050B1AC, 0x8050B1D4] m_random_field/mRF_GetRandomStepMode.c: .text: [0x8050B284, 0x8050B2C0] +sys_dynamic.c: + .bss: [0x813413F8, 0x81361820] # ac_aprilfool_control/aPC_actor_dt.c: common_data is pure bs, # .text: [0x805153f0, 0x8051542C] diff --git a/config/symbols.yml b/config/symbols.yml index 173a23eb..df674919 100644 --- a/config/symbols.yml +++ b/config/symbols.yml @@ -52509,6 +52509,9 @@ global: 0x812F31DC: game_GameFrame_2F 0x812F31E0: game_GameFrame__1F 0x812F31E4: game_class_p + 0x812F31E8: frame + 0x812F31EC: SoftResetEnable + 0x812F31F0: skip_frame 0x812F31F8: graph_class 0x812F3560: ResetStatus 0x812F3568: ResetTime diff --git a/include/audio.h b/include/audio.h new file mode 100644 index 00000000..7b9cab7b --- /dev/null +++ b/include/audio.h @@ -0,0 +1,17 @@ +#ifndef AUDIO_H +#define AUDIO_H + +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern void sAdo_GameFrame(); +extern void sAdo_SoftReset(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/game.h b/include/game.h index 9c90090d..d0e80f90 100644 --- a/include/game.h +++ b/include/game.h @@ -5,7 +5,7 @@ #include "TwoHeadArena.h" #include "graph.h" #include "gamealloc.h" -#include "pad.h" +#include "libu64/pad.h" #include "m_controller.h" #ifdef __cplusplus @@ -28,20 +28,20 @@ typedef struct game_s { /* 0x009E */ u8 disable_display; /* 0x009F */ u8 doing; /* 0x00A0 */ u32 frame_counter; - /* 0x00A4 */ u8 disable_prenmi; + /* 0x00A4 */ int disable_prenmi; /* 0x00A8 */ MCON mcon; } GAME; -extern void game_ct(GAME* game); +extern void game_ct(GAME*, void (*)(GAME*), GRAPH*); extern void game_dt(GAME* game); extern void game_main(GAME* game); -extern u8 game_is_doing(GAME* game); +extern int game_is_doing(GAME* game); extern void (*game_get_next_game_init(GAME* game))(GAME*); #define GAME_NEXT_GAME(game, init_name, class_name) \ do { \ GAME* g = (game); \ - g->next_game_init = init_name##_init; \ + g->next_game_init = (void (*)(struct game_s*))init_name##_init; \ g->next_game_class_size = sizeof(GAME_##class_name); \ } while (0) diff --git a/include/graph.h b/include/graph.h index 573b179e..3395576a 100644 --- a/include/graph.h +++ b/include/graph.h @@ -2,7 +2,7 @@ #define GRAPH_H #include "types.h" -#include "mbi.h" +#include "PR/mbi.h" #include "THA_GA.h" #include "dolphin/os/OSMessage.h" @@ -29,7 +29,7 @@ typedef enum { GRAPH_DOING_TASK_SET_FINISHED, GRAPH_DOING_AUDIO, GRAPH_DOING_AUDIO_FINISHED, - GRAPH_DOING_18, /* This is unused? Can't find it anywhere. Perhaps only used in DnM. */ + GRAPH_DOING_GAME_18, /* Not sure what this is, relevant code removed */ GRAPH_DOING_GAME_DT, GRAPH_DOING_GAME_DT_FINISHED, GRAPH_DOING_DT, @@ -77,14 +77,14 @@ typedef struct graph_s { /* 0x0349 */ u8 _unk349; /* 0x034A */ u8 need_viupdate; /* 0x034B */ u8 cfb_bank; - /* 0x034C */ void (*taskEndCallback)(GRAPH*, void*); + /* 0x034C */ void (*taskEndCallback)(struct graph_s*, void*); /* 0x0350 */ void* taskEndData; /* 0x0354 */ f32 vixscale; /* 0x0358 */ f32 viyscale; /* 0x035C */ Gfx* last_dl; /* 0x0360 */ Gfx* Gfx_list10; /* shadow */ /* 0x0364 */ Gfx* Gfx_list11; /* light */ -} GRAPH; +} GRAPH ATTRIBUTE_ALIGN(8); // one of the missing structs is likely aligned to 8 bytes. extern void graph_proc(void* arg); extern void graph_ct(GRAPH* this); @@ -128,6 +128,7 @@ extern void graph_dt(GRAPH* this); #define NOW_SHADOW_DISP (Gfx*)NOW_DISP(&__graph->shadow_thaga) #define NOW_LIGHT_DISP (Gfx*)NOW_DISP(&__graph->light_thaga) +extern u8 SoftResetEnable; extern GRAPH graph_class; #ifdef __cplusplus diff --git a/include/libjsys/jsyswrapper.h b/include/libjsys/jsyswrapper.h new file mode 100644 index 00000000..8c0ef1a1 --- /dev/null +++ b/include/libjsys/jsyswrapper.h @@ -0,0 +1,17 @@ +#ifndef JSYSWRAPPER_H +#define JSYSWRAPPER_H + +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern void JW_BeginFrame(); +extern void JW_EndFrame(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/m_bgm.h b/include/m_bgm.h new file mode 100644 index 00000000..3e7c98c5 --- /dev/null +++ b/include/m_bgm.h @@ -0,0 +1,16 @@ +#ifndef M_BGM_H +#define M_BGM_H + +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern void mBGM_reset(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/m_vibctl.h b/include/m_vibctl.h new file mode 100644 index 00000000..3f1b4325 --- /dev/null +++ b/include/m_vibctl.h @@ -0,0 +1,16 @@ +#ifndef M_VIBCTL_H +#define M_VIBCTL_H + +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern void mVibctl_reset(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/padmgr.h b/include/padmgr.h index 0c2e786a..1ecd87fa 100644 --- a/include/padmgr.h +++ b/include/padmgr.h @@ -4,6 +4,7 @@ #include "types.h" #include "irqmgr.h" #include "libu64/pad.h" +#include "dolphin/os/OSMessage.h" #ifdef __cplusplus extern "C" { diff --git a/include/sys_dynamic.h b/include/sys_dynamic.h index e533c011..8b657d98 100644 --- a/include/sys_dynamic.h +++ b/include/sys_dynamic.h @@ -2,6 +2,7 @@ #define SYS_DYNAMIC_H #include "types.h" +#include "PR/mbi.h" #ifdef __cplusplus extern "C" { @@ -10,43 +11,47 @@ extern "C" { #define SYSDYNAMIC_START_MAGIC 0x1234 #define SYSDYNAMIC_END_MAGIC 0x5678 -#define DYNAMIC_HEADER_SIZE 8 -#define DYNAMIC_EPILOG_SIZE 8 +#define SHADOW_SIZE 512 +#define LIGHT_SIZE 256 +#define LINE_XLU_SIZE 9952 +#define OVERLAY_SIZE 2048 +#define LINE_OPA_SIZE 1024 +#define WORK_SIZE 128 +#define UNK_BUF0_SIZE 32 +#define POLY_OPA_SIZE 1792 +#define POLY_XLU_SIZE 512 +#define FONT_SIZE 256 -#define SHADOW_SIZE 0x1000 -#define LIGHT_SIZE 0x800 -#define LINE_XLU_SIZE 0x13700 -#define OVERLAY_SIZE 0x4000 -#define LINE_OPA_SIZE 0x2000 -#define WORK_SIZE 0x400 -#define UNK_BUF0_SIZE 0x100 -#define POLY_OPA_SIZE 0x3800 -#define POLY_XLU_SIZE 0x1000 -#define FONT_SIZE 0x800 +typedef struct dynamic_s { + u16 start_magic; + + Gfx line_xlu[LINE_XLU_SIZE]; + Gfx overlay[OVERLAY_SIZE]; + Gfx line_opa[LINE_OPA_SIZE]; + Gfx work[WORK_SIZE]; + Gfx unused[UNK_BUF0_SIZE]; + Gfx poly_opa[POLY_OPA_SIZE]; + Gfx poly_xlu[POLY_XLU_SIZE]; + Gfx font[FONT_SIZE]; + Gfx shadow[SHADOW_SIZE]; + Gfx light[LIGHT_SIZE]; + u16 end_magic; + +} dynamic_t; -#define SYSDYNAMIC_START (0) -#define SYSDYNAMIC_HEADER_OFS (SYSDYNAMIC_START) -#define LINE_XLU_OFS (SYSDYNAMIC_HEADER_OFS + DYNAMIC_HEADER_SIZE) -#define OVERLAY_OFS (LINE_XLU_OFS + LINE_XLU_SIZE) -#define LINE_OPA_OFS (OVERLAY_OFS + OVERLAY_SIZE) -#define WORK_OFS (LINE_OPA_OFS + LINE_OPA_SIZE) -#define UNUSED_OFS (WORK_OFS + WORK_SIZE) -#define POLY_OPA_OFS (UNUSED_OFS + UNK_BUF0_SIZE) -#define POLY_XLU_OFS (POLY_OPA_OFS + POLY_OPA_SIZE) -#define FONT_OFS (POLY_XLU_OFS + POLY_XLU_SIZE) -#define SHADOW_OFS (FONT_OFS + FONT_SIZE) -#define LIGHT_OFS (SHADOW_OFS + SHADOW_SIZE) -#define SYSDYNAMIC_EPILOG_OFS (LIGHT_OFS + LIGHT_SIZE) -#define SYSDYNAMIC_END (SYSDYNAMIC_EPILOG_OFS + DYNAMIC_EPILOG_SIZE) +extern dynamic_t sys_dynamic; -/* 0x20410 bytes */ -#define DYNAMIC_SIZE \ - (DYNAMIC_HEADER_SIZE + SHADOW_SIZE + LIGHT_SIZE + LINE_XLU_SIZE + OVERLAY_SIZE + LINE_OPA_SIZE + \ - WORK_SIZE + UNK_BUF0_SIZE + POLY_OPA_SIZE + POLY_XLU_SIZE + FONT_SIZE + DYNAMIC_EPILOG_SIZE) +#define SYSDYNAMIC_OPEN() \ +do { \ + dynamic_t* __dyn = &sys_dynamic;\ +while (0) -static u8 sys_dynamic[DYNAMIC_SIZE]; +#define SYSDYNAMIC_CLOSE() \ + (void)__dyn; \ +} while (0) -#define GET_DYNAMIC_OFS(ofs) (&sys_dynamic[(ofs)]) +#define SYSDYNAMIC_CHECK_START() (__dyn->start_magic == SYSDYNAMIC_START_MAGIC) +#define SYSDYNAMIC_CHECK_END() (__dyn->end_magic == SYSDYNAMIC_END_MAGIC) #ifdef __cplusplus }; diff --git a/include/sys_ucode.h b/include/sys_ucode.h index 8006ca73..66603052 100644 --- a/include/sys_ucode.h +++ b/include/sys_ucode.h @@ -2,7 +2,7 @@ #define SYS_UCODE_H #include "types.h" -#include "mbi.h" +#include "PR/mbi.h" #ifdef __cplusplus extern "C" { diff --git a/include/zurumode.h b/include/zurumode.h index 3608c416..d10eaa53 100644 --- a/include/zurumode.h +++ b/include/zurumode.h @@ -67,4 +67,4 @@ enum zurumode_stage { } #endif -#endif \ No newline at end of file +#endif diff --git a/rel/graph.c b/rel/graph.c index 6e17e424..db353837 100644 --- a/rel/graph.c +++ b/rel/graph.c @@ -1,91 +1,90 @@ #include "graph.h" +#include "audio.h" #include "dvderr.h" +#include "famicom_emu.h" +#include "first_game.h" #include "game.h" #include "irqmgr.h" #include "libc64/malloc.h" +#include "libforest/emu64/emu64_wrapper.h" +#include "libjsys/jsyswrapper.h" #include "libu64/debug.h" #include "libultra/libultra.h" -#include "libforest/emu64/emu64_wrapper.h" +#include "m_bgm.h" #include "m_debug.h" #include "m_game_dlftbls.h" +#include "m_play.h" +#include "m_prenmi.h" +#include "m_select.h" +#include "m_trademark.h" +#include "m_vibctl.h" +#include "player_select.h" +#include "save_menu.h" +#include "second_game.h" #include "sys_dynamic.h" #include "sys_ucode.h" #include "zurumode.h" -#include "first_game.h" -#include "m_select.h" -#include "m_play.h" -#include "second_game.h" -#include "m_trademark.h" -#include "player_select.h" -#include "save_menu.h" -#include "famicom_emu.h" -#include "m_prenmi.h" +GRAPH graph_class; -static int frame; -static BOOL SoftResetEnable; -static int skip_frame; +static int skip_frame; // TODO: this is actually declared in graph_main +u8 SoftResetEnable; +static int frame; // TODO: this is actually declared in graph_task_set00 -#define CONSTRUCT_THA_GA(tha_ga, name) \ - (THA_GA_ct((tha_ga), (Gfx*)GET_DYNAMIC_OFS(##name##_OFS), ##name##_SIZE)) +#define CONSTRUCT_THA_GA(tha_ga, name, name2) \ + (THA_GA_ct((tha_ga), sys_dynamic.##name, ##name2##_SIZE * sizeof(Gfx))) static void graph_setup_double_buffer(GRAPH* this) { - bzero(sys_dynamic, DYNAMIC_SIZE); - *(u16*)GET_DYNAMIC_OFS(SYSDYNAMIC_HEADER_OFS) = SYSDYNAMIC_START_MAGIC; - *(u16*)GET_DYNAMIC_OFS(SYSDYNAMIC_EPILOG_OFS) = SYSDYNAMIC_END_MAGIC; + bzero(&sys_dynamic, sizeof(dynamic_t)); + sys_dynamic.start_magic = SYSDYNAMIC_START_MAGIC; + sys_dynamic.end_magic = SYSDYNAMIC_END_MAGIC; - CONSTRUCT_THA_GA(&this->shadow_thaga, SHADOW); - CONSTRUCT_THA_GA(&this->light_thaga, LIGHT); - CONSTRUCT_THA_GA(&this->line_translucent_thaga, LINE_XLU); - CONSTRUCT_THA_GA(&this->overlay_thaga, OVERLAY); - CONSTRUCT_THA_GA(&this->line_opaque_thaga, LINE_OPA); - CONSTRUCT_THA_GA(&this->work_thaga, WORK); - CONSTRUCT_THA_GA(&this->polygon_opaque_thaga, POLY_OPA); - CONSTRUCT_THA_GA(&this->polygon_translucent_thaga, POLY_XLU); - CONSTRUCT_THA_GA(&this->font_thaga, FONT); + CONSTRUCT_THA_GA(&this->shadow_thaga, shadow, SHADOW); + CONSTRUCT_THA_GA(&this->light_thaga, light, LIGHT); + CONSTRUCT_THA_GA(&this->line_translucent_thaga, line_xlu, LINE_XLU); + CONSTRUCT_THA_GA(&this->overlay_thaga, overlay, OVERLAY); + CONSTRUCT_THA_GA(&this->line_opaque_thaga, line_opa, LINE_OPA); + CONSTRUCT_THA_GA(&this->work_thaga, work, WORK); + CONSTRUCT_THA_GA(&this->polygon_opaque_thaga, poly_opa, POLY_OPA); + CONSTRUCT_THA_GA(&this->polygon_translucent_thaga, poly_xlu, POLY_XLU); + CONSTRUCT_THA_GA(&this->font_thaga, font, FONT); - this->Gfx_list10 = (Gfx*)GET_DYNAMIC_OFS(SHADOW_OFS); - this->Gfx_list11 = (Gfx*)GET_DYNAMIC_OFS(LIGHT_OFS); - this->Gfx_list00 = (Gfx*)GET_DYNAMIC_OFS(LINE_XLU_OFS); - this->Gfx_list01 = (Gfx*)GET_DYNAMIC_OFS(OVERLAY_OFS); - this->Gfx_list04 = (Gfx*)GET_DYNAMIC_OFS(LINE_OPA_OFS); - this->Gfx_list05 = (Gfx*)GET_DYNAMIC_OFS(WORK_OFS); - this->Gfx_list07 = (Gfx*)GET_DYNAMIC_OFS(POLY_OPA_OFS); - this->Gfx_list08 = (Gfx*)GET_DYNAMIC_OFS(POLY_XLU_OFS); - this->Gfx_list09 = (Gfx*)GET_DYNAMIC_OFS(FONT_OFS); + this->Gfx_list10 = sys_dynamic.shadow; + this->Gfx_list11 = sys_dynamic.light; + this->Gfx_list00 = sys_dynamic.line_xlu; + this->Gfx_list01 = sys_dynamic.overlay; + this->Gfx_list04 = sys_dynamic.line_opa; + this->Gfx_list05 = sys_dynamic.work; + this->Gfx_list07 = sys_dynamic.poly_opa; + this->Gfx_list08 = sys_dynamic.poly_xlu; + this->Gfx_list09 = sys_dynamic.font; this->gfxsave = NULL; } +#define ARE_INIT_PROCS_EQUAL(proc0, proc1) \ + (((void (*)(GAME*))proc0) == ((void (*)(GAME*))proc1)) static DLFTBL_GAME* game_get_next_game_dlftbl(GAME* game) { void (*next_game_init_proc)(GAME*) = game_get_next_game_init(game); - if (next_game_init_proc == first_game_init) { + if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, first_game_init)) { return &game_dlftbls[0]; - } - else if (next_game_init_proc == select_init) { + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, select_init)) { return &game_dlftbls[1]; - } - else if (next_game_init_proc == play_init) { + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, play_init)) { return &game_dlftbls[2]; - } - else if (next_game_init_proc == second_game_init) { + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, second_game_init)) { return &game_dlftbls[3]; - } - else if (next_game_init_proc == trademark_init) { + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, trademark_init)) { return &game_dlftbls[5]; - } - else if (next_game_init_proc == player_select_init) { + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, player_select_init)) { return &game_dlftbls[6]; - } - else if (next_game_init_proc == save_menu_init) { + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, save_menu_init)) { return &game_dlftbls[7]; - } - else if (next_game_init_proc == famicom_emu_init) { + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, famicom_emu_init)) { return &game_dlftbls[8]; - } - else if (next_game_init_proc == prenmi_init) { + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, prenmi_init)) { return &game_dlftbls[9]; } @@ -96,9 +95,9 @@ extern void graph_ct(GRAPH* this) { bzero(this, sizeof(GRAPH)); this->frame_counter = 0; this->cfb_bank = 0; - zurumode_init(); SETREG(SREG, 33, GETREG(SREG, 33) & ~2); SETREG(SREG, 33, GETREG(SREG, 33) & ~1); + zurumode_init(); GRAPH_SET_DOING_POINT(this, CT); } @@ -113,30 +112,37 @@ static void graph_task_set00(GRAPH* this) { GRAPH_SET_DOING_POINT(this, WAIT_TASK); GRAPH_SET_DOING_POINT(this, WAIT_TASK_FINISHED); if (ResetStatus < IRQ_RESET_DELAY) { - ucode[0].type = UCODE_TYPE_POLY_TEXT; - ucode[1].type = UCODE_TYPE_SPRITE_TEXT; - ucode[0].ucode_p = ucode_GetPolyTextStart(); - ucode[1].ucode_p = ucode_GetSpriteTextStart(); - // JW_BeginFrame(); - emu64_init(); - emu64_set_ucode_info(2, ucode); - emu64_set_first_ucode(ucode[0].ucode_p); - emu64_taskstart(this->Gfx_list05); /* work data */ - emu64_cleanup(); - // JW_EndFrame(); - frame++; + this->last_dl = this->Gfx_list05; + if (this->taskEndCallback != NULL) { + this->taskEndCallback(this, this->taskEndData); + } + + if (ResetStatus < IRQ_RESET_DELAY) { + ucode[0].type = UCODE_TYPE_POLY_TEXT; + ucode[1].type = UCODE_TYPE_SPRITE_TEXT; + ucode[0].ucode_p = ucode_GetPolyTextStart(); + ucode[1].ucode_p = ucode_GetSpriteTextStart(); + JW_BeginFrame(); + emu64_init(); + emu64_set_ucode_info(2, ucode); + emu64_set_first_ucode(ucode[0].ucode_p); + emu64_taskstart(this->Gfx_list05); /* work data */ + emu64_cleanup(); + JW_EndFrame(); + frame++; + } } } static int graph_draw_finish(GRAPH* this) { - int err = 0; + int err; OPEN_DISP(this); gSPBranchList(NOW_WORK_DISP++, this->Gfx_list10); gSPBranchList(NOW_SHADOW_DISP++, this->Gfx_list08); gSPBranchList(NOW_POLY_XLU_DISP++, this->Gfx_list11); gSPBranchList(NOW_LIGHT_DISP++, this->Gfx_list00); - gSPBranchList(NOW_LINE_OPA_DISP++, this->Gfx_list01); + gSPBranchList(NOW_LINE_XLU_DISP++, this->Gfx_list01); gSPBranchList(NOW_OVERLAY_DISP++, this->Gfx_list09); gSPBranchList(NOW_FONT_DISP++, this->Gfx_list07); gSPBranchList(NOW_POLY_OPA_DISP++, this->Gfx_list04); @@ -145,15 +151,18 @@ static int graph_draw_finish(GRAPH* this) { gSPEndDisplayList(NOW_LINE_OPA_DISP++); CLOSE_DISP(this); + err = FALSE; - if (*(u16*)GET_DYNAMIC_OFS(SYSDYNAMIC_HEADER_OFS) != SYSDYNAMIC_START_MAGIC) { + SYSDYNAMIC_OPEN(); + if (!SYSDYNAMIC_CHECK_START()) { _dbg_hungup(__FILE__, 417); } - if (*(u16*)GET_DYNAMIC_OFS(SYSDYNAMIC_EPILOG_OFS) != SYSDYNAMIC_END_MAGIC) { - _dbg_hungup(__FILE__, 425); + if (!SYSDYNAMIC_CHECK_END()) { err = TRUE; + _dbg_hungup(__FILE__, 425); } + SYSDYNAMIC_CLOSE(); if (THA_GA_isCrash(&this->line_translucent_thaga)) { err = TRUE; @@ -192,9 +201,9 @@ static int graph_draw_finish(GRAPH* this) { static void do_soft_reset(GAME* game) { SoftResetEnable = FALSE; - // mBGM_reset(); - // mVibctl_reset(); - // sAdo_SoftReset(); + mBGM_reset(); + mVibctl_reset(); + sAdo_SoftReset(); ResetTime = osGetTime(); ResetStatus = IRQ_RESET_PRENMI; } @@ -234,7 +243,7 @@ static void graph_main(GRAPH* this, GAME* game) { if (GETREG(SREG, 20) < 2) { GRAPH_SET_DOING_POINT(this, AUDIO); - // sAdo_GameFrame(); + sAdo_GameFrame(); GRAPH_SET_DOING_POINT(this, AUDIO_FINISHED); } @@ -246,6 +255,7 @@ static void graph_main(GRAPH* this, GAME* game) { } extern void graph_proc(void* arg) { + GRAPH* __graph = &graph_class; DLFTBL_GAME* dlftbl = &game_dlftbls[0]; graph_ct(&graph_class); @@ -254,24 +264,25 @@ extern void graph_proc(void* arg) { GAME* game = (GAME*)malloc(size); game_class_p = game; bzero(game, size); - GRAPH_SET_DOING_POINT(&graph_class, GAME_CT); - game_ct(game); + GRAPH_SET_DOING_POINT(__graph, GAME_CT); + game_ct(game, dlftbl->init, __graph); emu64_refresh(); - GRAPH_SET_DOING_POINT(&graph_class, GAME_CT_FINISHED); + GRAPH_SET_DOING_POINT(__graph, GAME_CT_FINISHED); while (game_is_doing(game)) { if (!dvderr_draw()) { - graph_main(&graph_class, game); + graph_main(__graph, game); } } dlftbl = game_get_next_game_dlftbl(game); - GRAPH_SET_DOING_POINT(&graph_class, GAME_DT); + GRAPH_SET_DOING_POINT(__graph, GAME_18); + GRAPH_SET_DOING_POINT(__graph, GAME_DT); game_dt(game); - GRAPH_SET_DOING_POINT(&graph_class, GAME_DT_FINISHED); + GRAPH_SET_DOING_POINT(__graph, GAME_DT_FINISHED); free(game); game_class_p = NULL; } - graph_dt(&graph_class); + graph_dt(__graph); } diff --git a/rel/sys_dynamic.c b/rel/sys_dynamic.c new file mode 100644 index 00000000..ef4001fc --- /dev/null +++ b/rel/sys_dynamic.c @@ -0,0 +1,3 @@ +#include "sys_dynamic.h" + +dynamic_t sys_dynamic;