Skip to content

Commit de137d1

Browse files
committed
Big event pass
1 parent 5202070 commit de137d1

24 files changed

Lines changed: 1557 additions & 358 deletions

src/engine/behavior_script.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,8 @@ BhvCommandProc BehaviorCmdTable[] = {
910910
void cur_obj_update(void) {
911911
UNUSED u8 filler[4];
912912

913+
CALL_EVENT(BehaviorTick, gCurrentObject);
914+
913915
s16 objFlags = gCurrentObject->oFlags;
914916
f32 distanceFromMario;
915917
BhvCommandProc bhvCmdProc;

src/engine/geo_layout.c

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,13 @@ void geo_layout_cmd_node_perspective(void) {
268268
gGeoLayoutCommand += 4 << CMD_SIZE_SHIFT;
269269
}
270270

271-
graphNode = init_graph_node_perspective(gGraphNodePool, NULL, (f32) fov, near, far, frustumFunc, 0);
272-
273-
register_scene_graph_node(&graphNode->fnNode.node);
271+
{
272+
f32 fovF = (f32) fov;
273+
CALL_CANCELLABLE_EVENT(GeoLayoutNodePerspective, &fovF, &near, &far, &frustumFunc) {
274+
graphNode = init_graph_node_perspective(gGraphNodePool, NULL, fovF, near, far, frustumFunc, 0);
275+
register_scene_graph_node(&graphNode->fnNode.node);
276+
}
277+
}
274278

275279
gGeoLayoutCommand += 0x08 << CMD_SIZE_SHIFT;
276280
}
@@ -335,16 +339,14 @@ void geo_layout_cmd_node_level_of_detail(void) {
335339
Used for animating coins, blinking, color selection, etc.
336340
*/
337341
void geo_layout_cmd_node_switch_case(void) {
338-
struct GraphNodeSwitchCase *graphNode;
342+
s16 initialCase = cur_geo_cmd_s16(0x02);
343+
GraphNodeFunc func = (GraphNodeFunc) cur_geo_cmd_ptr(0x04);
339344

340-
graphNode =
341-
init_graph_node_switch_case(gGraphNodePool, NULL,
342-
cur_geo_cmd_s16(0x02), // case which is initially selected
343-
0,
344-
(GraphNodeFunc) cur_geo_cmd_ptr(0x04), // case update function
345-
0);
346-
347-
register_scene_graph_node(&graphNode->fnNode.node);
345+
CALL_CANCELLABLE_EVENT(GeoLayoutNodeSwitchCase, &initialCase, &func) {
346+
struct GraphNodeSwitchCase *graphNode =
347+
init_graph_node_switch_case(gGraphNodePool, NULL, initialCase, 0, func, 0);
348+
register_scene_graph_node(&graphNode->fnNode.node);
349+
}
348350

349351
gGeoLayoutCommand += 0x08 << CMD_SIZE_SHIFT;
350352
}
@@ -361,20 +363,21 @@ void geo_layout_cmd_node_switch_case(void) {
361363
cmd+0x10: GraphNodeFunc func
362364
*/
363365
void geo_layout_cmd_node_camera(void) {
364-
struct GraphNodeCamera *graphNode;
365-
s16 *cmdPos = (s16 *) &gGeoLayoutCommand[4];
366-
366+
s16 type = cur_geo_cmd_s16(0x02);
367367
Vec3f pos, focus;
368+
s16 *cmdPos = (s16 *) &gGeoLayoutCommand[4];
368369

369370
cmdPos = read_vec3s_to_vec3f(pos, cmdPos);
370371
cmdPos = read_vec3s_to_vec3f(focus, cmdPos);
371372

372-
graphNode = init_graph_node_camera(gGraphNodePool, NULL, pos, focus,
373-
(GraphNodeFunc) cur_geo_cmd_ptr(0x10), cur_geo_cmd_s16(0x02));
374-
375-
register_scene_graph_node(&graphNode->fnNode.node);
373+
GraphNodeFunc func = (GraphNodeFunc) cur_geo_cmd_ptr(0x10);
376374

377-
gGeoViews[0] = &graphNode->fnNode.node;
375+
CALL_CANCELLABLE_EVENT(GeoLayoutNodeCamera, &type, pos, focus, &func) {
376+
struct GraphNodeCamera *graphNode =
377+
init_graph_node_camera(gGraphNodePool, NULL, pos, focus, func, type);
378+
register_scene_graph_node(&graphNode->fnNode.node);
379+
gGeoViews[0] = &graphNode->fnNode.node;
380+
}
378381

379382
gGeoLayoutCommand += 0x14 << CMD_SIZE_SHIFT;
380383
}
@@ -537,8 +540,6 @@ void geo_layout_cmd_node_rotation(void) {
537540
[cmd+0x08: void *displayList]
538541
*/
539542
void geo_layout_cmd_node_scale(void) {
540-
struct GraphNodeScale *graphNode;
541-
542543
s16 drawingLayer = 0;
543544
s16 params = cur_geo_cmd_u8(0x01);
544545
f32 scale = cur_geo_cmd_u32(0x04) / 65536.0f;
@@ -550,9 +551,11 @@ void geo_layout_cmd_node_scale(void) {
550551
gGeoLayoutCommand += 4 << CMD_SIZE_SHIFT;
551552
}
552553

553-
graphNode = init_graph_node_scale(gGraphNodePool, NULL, drawingLayer, displayList, scale);
554-
555-
register_scene_graph_node(&graphNode->node);
554+
CALL_CANCELLABLE_EVENT(GeoLayoutNodeScale, &drawingLayer, &scale, &displayList) {
555+
struct GraphNodeScale *graphNode =
556+
init_graph_node_scale(gGraphNodePool, NULL, drawingLayer, displayList, scale);
557+
register_scene_graph_node(&graphNode->node);
558+
}
556559

557560
gGeoLayoutCommand += 0x08 << CMD_SIZE_SHIFT;
558561
}
@@ -626,13 +629,14 @@ void geo_layout_cmd_node_billboard(void) {
626629
cmd+0x04: void *displayList
627630
*/
628631
void geo_layout_cmd_node_display_list(void) {
629-
struct GraphNodeDisplayList *graphNode;
630632
s32 drawingLayer = cur_geo_cmd_u8(0x01);
631633
void *displayList = cur_geo_cmd_ptr(0x04);
632634

633-
graphNode = init_graph_node_display_list(gGraphNodePool, NULL, drawingLayer, displayList);
634-
635-
register_scene_graph_node(&graphNode->node);
635+
CALL_CANCELLABLE_EVENT(GeoLayoutNodeDisplayList, &drawingLayer, &displayList) {
636+
struct GraphNodeDisplayList *graphNode =
637+
init_graph_node_display_list(gGraphNodePool, NULL, drawingLayer, displayList);
638+
register_scene_graph_node(&graphNode->node);
639+
}
636640

637641
gGeoLayoutCommand += 0x08 << CMD_SIZE_SHIFT;
638642
}
@@ -644,14 +648,15 @@ void geo_layout_cmd_node_display_list(void) {
644648
cmd+0x06: s16 shadowScale
645649
*/
646650
void geo_layout_cmd_node_shadow(void) {
647-
struct GraphNodeShadow *graphNode;
648-
u8 shadowType = cur_geo_cmd_s16(0x02);
649-
u8 shadowSolidity = cur_geo_cmd_s16(0x04);
651+
u8 shadowType = (u8) cur_geo_cmd_s16(0x02);
652+
u8 shadowSolidity = (u8) cur_geo_cmd_s16(0x04);
650653
s16 shadowScale = cur_geo_cmd_s16(0x06);
651654

652-
graphNode = init_graph_node_shadow(gGraphNodePool, NULL, shadowScale, shadowSolidity, shadowType);
653-
654-
register_scene_graph_node(&graphNode->node);
655+
CALL_CANCELLABLE_EVENT(GeoLayoutNodeShadow, &shadowType, &shadowSolidity, &shadowScale) {
656+
struct GraphNodeShadow *graphNode =
657+
init_graph_node_shadow(gGraphNodePool, NULL, shadowScale, shadowSolidity, shadowType);
658+
register_scene_graph_node(&graphNode->node);
659+
}
655660

656661
gGeoLayoutCommand += 0x08 << CMD_SIZE_SHIFT;
657662
}
@@ -673,13 +678,13 @@ void geo_layout_cmd_node_object_parent(void) {
673678
cmd+0x04: GraphNodeFunc func
674679
*/
675680
void geo_layout_cmd_node_generated(void) {
676-
struct GraphNodeGenerated *graphNode;
681+
GraphNodeFunc func = (GraphNodeFunc) cur_geo_cmd_ptr(0x04);
682+
s16 param = cur_geo_cmd_s16(0x02);
677683

678-
graphNode = init_graph_node_generated(gGraphNodePool, NULL,
679-
(GraphNodeFunc) cur_geo_cmd_ptr(0x04), // asm function
680-
cur_geo_cmd_s16(0x02)); // parameter
681-
682-
register_scene_graph_node(&graphNode->fnNode.node);
684+
CALL_CANCELLABLE_EVENT(GeoLayoutCallASM, &func, &param) {
685+
struct GraphNodeGenerated *graphNode = init_graph_node_generated(gGraphNodePool, NULL, func, param);
686+
register_scene_graph_node(&graphNode->fnNode.node);
687+
}
683688

684689
gGeoLayoutCommand += 0x08 << CMD_SIZE_SHIFT;
685690
}
@@ -690,15 +695,14 @@ void geo_layout_cmd_node_generated(void) {
690695
cmd+0x04: GraphNodeFunc backgroundFunc
691696
*/
692697
void geo_layout_cmd_node_background(void) {
693-
struct GraphNodeBackground *graphNode;
694-
695-
graphNode = init_graph_node_background(
696-
gGraphNodePool, NULL,
697-
cur_geo_cmd_s16(0x02), // background ID, or RGBA5551 color if asm function is null
698-
(GraphNodeFunc) cur_geo_cmd_ptr(0x04), // asm function
699-
0);
698+
GraphNodeFunc func = (GraphNodeFunc) cur_geo_cmd_ptr(0x04);
699+
s16 param = cur_geo_cmd_s16(0x02);
700700

701-
register_scene_graph_node(&graphNode->fnNode.node);
701+
CALL_CANCELLABLE_EVENT(GeoLayoutCallASM, &func, &param) {
702+
struct GraphNodeBackground *graphNode = init_graph_node_background(
703+
gGraphNodePool, NULL, param, func, 0);
704+
register_scene_graph_node(&graphNode->fnNode.node);
705+
}
702706

703707
gGeoLayoutCommand += 0x08 << CMD_SIZE_SHIFT;
704708
}
@@ -787,6 +791,8 @@ struct GraphNode *process_geo_layout(struct AllocOnlyPool *pool, void *segptr) {
787791
gGeoLayoutStack[0] = 0;
788792
gGeoLayoutStack[1] = 0;
789793

794+
CALL_EVENT(GeoLayoutBegin, segptr);
795+
790796
if(GameEngine_OTRSigCheck(segptr) == 1){
791797
GeoLayoutExecute(segptr);
792798
} else {
@@ -798,5 +804,6 @@ struct GraphNode *process_geo_layout(struct AllocOnlyPool *pool, void *segptr) {
798804
}
799805
}
800806

807+
CALL_EVENT(GeoLayoutEnd, gCurRootGraphNode);
801808
return gCurRootGraphNode;
802809
}

src/engine/level_script.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,9 @@ struct LevelCommand *level_script_execute(struct LevelCommand *cmd) {
836836
sCurrentCmd = cmd;
837837

838838
while (sScriptStatus == SCRIPT_RUNNING) {
839-
LevelScriptJumpTable[sCurrentCmd->type]();
840-
CALL_EVENT(LevelScriptExecute, sCurrentCmd->type);
839+
CALL_CANCELLABLE_EVENT(LevelScriptExecute, &sCurrentCmd) {
840+
LevelScriptJumpTable[sCurrentCmd->type]();
841+
}
841842
}
842843

843844
profiler_log_thread5_time(LEVEL_SCRIPT_EXECUTE);

src/game/game_init.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,9 @@ void thread5_game_loop(void) {
700700
save_file_load_all();
701701

702702
// Point address to the entry point into the level script data.
703-
addr = segmented_to_virtual(level_script_entry);
703+
CALL_CANCELLABLE_EVENT(LevelScriptEntry, &addr) {
704+
addr = segmented_to_virtual(level_script_entry);
705+
}
704706

705707
play_music(SEQ_PLAYER_SFX, SEQUENCE_ARGS(0, SEQ_SOUND_PLAYER), 0);
706708
set_sound_mode(save_file_get_sound_mode());

src/game/hud.c

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -436,21 +436,27 @@ void render_hud(void) {
436436
}
437437

438438
if (hudDisplayFlags & HUD_DISPLAY_FLAG_LIVES) {
439-
FrameInterpolation_RecordOpenChild("render_hud_mario_lives", (uintptr_t)&gHudDisplay.lives);
440-
render_hud_mario_lives();
441-
FrameInterpolation_RecordCloseChild();
439+
CALL_CANCELLABLE_EVENT(RenderHudLives, gHudDisplay.lives) {
440+
FrameInterpolation_RecordOpenChild("render_hud_mario_lives", (uintptr_t)&gHudDisplay.lives);
441+
render_hud_mario_lives();
442+
FrameInterpolation_RecordCloseChild();
443+
}
442444
}
443445

444446
if (hudDisplayFlags & HUD_DISPLAY_FLAG_COIN_COUNT) {
445-
FrameInterpolation_RecordOpenChild("render_hud_coins", (uintptr_t)&gHudDisplay.coins);
446-
render_hud_coins();
447-
FrameInterpolation_RecordCloseChild();
447+
CALL_CANCELLABLE_EVENT(RenderHudCoins, gHudDisplay.coins) {
448+
FrameInterpolation_RecordOpenChild("render_hud_coins", (uintptr_t)&gHudDisplay.coins);
449+
render_hud_coins();
450+
FrameInterpolation_RecordCloseChild();
451+
}
448452
}
449453

450454
if (hudDisplayFlags & HUD_DISPLAY_FLAG_STAR_COUNT) {
451-
FrameInterpolation_RecordOpenChild("render_hud_stars", (uintptr_t)&gHudDisplay.stars);
452-
render_hud_stars();
453-
FrameInterpolation_RecordCloseChild();
455+
CALL_CANCELLABLE_EVENT(RenderHudStars, gHudDisplay.stars) {
456+
FrameInterpolation_RecordOpenChild("render_hud_stars", (uintptr_t)&gHudDisplay.stars);
457+
render_hud_stars();
458+
FrameInterpolation_RecordCloseChild();
459+
}
454460
}
455461

456462
if (hudDisplayFlags & HUD_DISPLAY_FLAG_KEYS) {
@@ -460,18 +466,24 @@ void render_hud(void) {
460466
}
461467

462468
if (hudDisplayFlags & HUD_DISPLAY_FLAG_CAMERA_AND_POWER) {
463-
FrameInterpolation_RecordOpenChild("render_hud_power_meter", (uintptr_t)&sPowerMeterHUD.animation);
464-
render_hud_power_meter();
465-
FrameInterpolation_RecordCloseChild();
466-
FrameInterpolation_RecordOpenChild("render_hud_camera_status", (uintptr_t)&sCameraHUD.status);
467-
render_hud_camera_status();
468-
FrameInterpolation_RecordCloseChild();
469+
CALL_CANCELLABLE_EVENT(RenderHudPowerMeter, gHudDisplay.wedges) {
470+
FrameInterpolation_RecordOpenChild("render_hud_power_meter", (uintptr_t)&sPowerMeterHUD.animation);
471+
render_hud_power_meter();
472+
FrameInterpolation_RecordCloseChild();
473+
}
474+
CALL_CANCELLABLE_EVENT(RenderHudCameraStatus, sCameraHUD.status) {
475+
FrameInterpolation_RecordOpenChild("render_hud_camera_status", (uintptr_t)&sCameraHUD.status);
476+
render_hud_camera_status();
477+
FrameInterpolation_RecordCloseChild();
478+
}
469479
}
470480

471481
if (hudDisplayFlags & HUD_DISPLAY_FLAG_TIMER) {
472-
FrameInterpolation_RecordOpenChild("render_hud_timer", (uintptr_t)&gHudDisplay.timer);
473-
render_hud_timer();
474-
FrameInterpolation_RecordCloseChild();
482+
CALL_CANCELLABLE_EVENT(RenderHudTimer, gHudDisplay.timer) {
483+
FrameInterpolation_RecordOpenChild("render_hud_timer", (uintptr_t)&gHudDisplay.timer);
484+
render_hud_timer();
485+
FrameInterpolation_RecordCloseChild();
486+
}
475487
}
476488
FrameInterpolation_RecordCloseChild();
477489
}

src/game/ingame_menu.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,11 @@ s8 gDialogCourseActNum = 1;
14711471
#define DIAG_VAL4 (ROM_JP ? 4 : 5)
14721472

14731473
void render_dialog_entries(void) {
1474+
CALL_CANCELLABLE_EVENT(DialogOverride, gDialogID) {}
1475+
if (DialogOverride_.Event.Cancelled) {
1476+
return;
1477+
}
1478+
14741479
#ifdef VERSION_EU
14751480
s8 lowerBound;
14761481
#endif
@@ -2290,6 +2295,11 @@ s8 gHudFlash = 0;
22902295
s16 render_pause_courses_and_castle(void) {
22912296
s16 index;
22922297

2298+
CALL_CANCELLABLE_EVENT(PauseMenuOverride, gMenuMode) {}
2299+
if (PauseMenuOverride_.Event.Cancelled) {
2300+
return MENU_OPT_NONE;
2301+
}
2302+
22932303
#ifdef VERSION_EU
22942304
gInGameLanguage = eu_get_language();
22952305
#endif
@@ -2643,6 +2653,12 @@ void render_save_confirmation(s16 x, s16 y, s8 *index, s16 yOffset)
26432653

26442654
s16 render_course_complete_screen(void) {
26452655
s16 index;
2656+
2657+
CALL_CANCELLABLE_EVENT(CourseCompleteOverride, gCurrCourseNum) {}
2658+
if (CourseCompleteOverride_.Event.Cancelled) {
2659+
return MENU_OPT_NONE;
2660+
}
2661+
26462662
#ifdef VERSION_EU
26472663
gInGameLanguage = eu_get_language();
26482664
#endif

0 commit comments

Comments
 (0)