diff --git a/config/rel_slices.yml b/config/rel_slices.yml index 9013c360..64ecbcf7 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -142,6 +142,9 @@ save_menu.c: .text: [0x8062CA5C, 0x8062D39C] .rodata: [0x8064D1F8, 0x8064D318] .data: [0x806D4B80, 0x806D4B98] +m_prenmi.c: + .text: [0x8062D8FC, 0x8062DC04] + .rodata: [0x8064D318, 0x8064D340] sys_dynamic.c: .bss: [0x813413F8, 0x81361820] # ac_aprilfool_control/aPC_actor_dt.c: common_data is pure bs, diff --git a/include/m_prenmi.h b/include/m_prenmi.h index 6678e8da..cd47a0ce 100644 --- a/include/m_prenmi.h +++ b/include/m_prenmi.h @@ -8,15 +8,17 @@ extern "C" { #endif +#define PRENMI_TIMER 30 + /* sizeof(struct game_prenmi_s) == 0xE8 */ typedef struct game_prenmi_s { GAME game; - u32 timer; - u32 pad; + int timer; + u32 unused_pad; } GAME_PRENMI; -extern void prenmi_init(GAME_PRENMI* prenmi); -extern void prenmi_cleanup(GAME_PRENMI* prenmi); +extern void prenmi_init(GAME* game); +extern void prenmi_cleanup(GAME* game); #ifdef __cplusplus }; diff --git a/rel/m_prenmi.c b/rel/m_prenmi.c new file mode 100644 index 00000000..9f785225 --- /dev/null +++ b/rel/m_prenmi.c @@ -0,0 +1,75 @@ +#include "m_prenmi.h" +#include "second_game.h" +#include "irqmgr.h" +#include "sys_vimgr.h" +#include "m_rcp.h" + +static void prenmi_move(GAME_PRENMI* prenmi) { + if (ResetStatus == IRQ_RESET_DELAY || prenmi->timer == 0) { + prenmi->game.disable_prenmi = FALSE; + ResetStatus = IRQ_RESET_NORMAL; + ResetTime = 0; + viBlack(TRUE); + GAME_GOTO_NEXT((GAME*)prenmi, second_game, SECOND); + } + else{ + prenmi->timer--; + } +} + +static void prenmi_draw(GAME_PRENMI* prenmi) { + GRAPH* graph; + Gfx* gfx; + f32 timer; + f32 y_pos; + + graph = prenmi->game.graph; + OPEN_DISP(graph); + + DisplayList_initialize(graph, 0, 0, 0, NULL); + gfx = NOW_POLY_OPA_DISP; + + gDPPipeSync(gfx++); + gDPSetOtherMode(gfx++, G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PRIM | G_RM_XLU_SURF | G_RM_XLU_SURF2); + gDPSetCombineMode(gfx++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + + timer = prenmi->timer; + + // set opacity + y_pos = (1.0f - (timer / (f32)PRENMI_TIMER)) * -240.0f + 250.0f; + gDPSetPrimColor(gfx++, 0, 0, 0xFF, 0xFF, 0xFF, (u8)y_pos); + + // adjust size + y_pos = (1.0f - (timer / (f32)PRENMI_TIMER)) * -15.0f + 127.0f; + gfx = gfx_gSPTextureRectangle1(gfx, 0, (y_pos * 4.0f), 0x500, ((y_pos + 1.0f) * 4.0f), 0, 0, 0, 0, 0); + + gDPPipeSync(gfx++); + SET_POLY_OPA_DISP(gfx); + + CLOSE_DISP(graph); +} + +static void prenmi_main(GAME* game) { + GRAPH* graph; + GAME_PRENMI* prenmi = (GAME_PRENMI*)game; + + prenmi->game.disable_prenmi = TRUE; + prenmi_move(prenmi); + prenmi_draw(prenmi); + graph = game->graph; + game_debug_draw_last(game, graph); + game_draw_last(graph); +} + +extern void prenmi_cleanup(GAME* game) { + SoftResetEnable = TRUE; +} + +extern void prenmi_init(GAME* game) { + GAME_PRENMI* prenmi = (GAME_PRENMI*)game; + + prenmi->game.exec = &prenmi_main; + prenmi->game.cleanup = &prenmi_cleanup; + prenmi->timer = PRENMI_TIMER; + SetGameFrame(1); +}