From beea0c599765d9e1a59cf8f70e73d4be6c1db6c5 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 19 Jun 2025 12:00:11 +0200 Subject: [PATCH] add new next dungeon script command --- include/data_script.h | 3 +++ include/textbox.h | 2 +- src/data/ground/ground_data_d01p01_station.h | 12 ++++----- src/data/ground/ground_data_d02p01_station.h | 12 ++++----- src/data/ground/ground_data_d04p01_station.h | 4 +-- src/data/ground/ground_data_d05p01_station.h | 2 +- src/data/ground/ground_data_d06p01_station.h | 4 +-- src/data/ground/ground_data_d06p02_station.h | 2 +- src/data/ground/ground_data_d07p01_station.h | 4 +-- src/data/ground/ground_data_d08p01_station.h | 2 +- src/data/ground/ground_data_d09p02_station.h | 2 +- src/data/ground/ground_data_d10p02_station.h | 2 +- src/data/ground/ground_data_d11p02_station.h | 4 +-- src/data/ground/ground_data_d12p01_station.h | 4 +-- src/data/ground/ground_data_d12p02_station.h | 2 +- src/data/ground/ground_data_d13p01_station.h | 4 +-- src/data/ground/ground_data_d13p02_station.h | 2 +- src/data/ground/ground_event_data.h | 18 +++++++------- src/ground_main.c | 26 +++++++++----------- src/ground_script.c | 12 ++++----- src/textbox.c | 14 +++++------ 21 files changed, 68 insertions(+), 69 deletions(-) diff --git a/include/data_script.h b/include/data_script.h index 3e0150882..ea038482d 100644 --- a/include/data_script.h +++ b/include/data_script.h @@ -1,6 +1,7 @@ #include "constants/event_flag.h" #include "constants/item.h" #include "constants/ground_map.h" +#include "constants/dungeon.h" #include "portrait_placement.h" #include "structs/str_ground_script.h" #define LPARRAY(x) (ARRAY_COUNT(x)), x @@ -9,6 +10,8 @@ #define CPOS_CURRENT 0x4 // 01..07: complex map/dungeon selection/check commands +#define NEXT_DUNGEON(u, d) { 0x02, 0, u, d, 0, NULL } // Seems to be a general command for setting up which dungeon to enter next. First argument is unknown. + #define SELECT_MAP(m) { 0x08, 0, 0, m, 0, NULL } #define SELECT_GROUND(m) { 0x09, 0, 0, m, 0, NULL } #define SELECT_DUNGEON(m,d,f,b) { 0x0A, b, f, d, m, NULL } diff --git a/include/textbox.h b/include/textbox.h index 7127f417b..20bae4349 100644 --- a/include/textbox.h +++ b/include/textbox.h @@ -25,6 +25,6 @@ bool8 ScriptSetPortraitPosDelta(s32 portraitId_, PixelPos *newPosDelta); bool8 ScriptPrintText(s32 scriptMsgType, s32 speakerId_, const char *text); bool8 ScriptPrintTextOnBg(const char *text); bool8 ScriptPrintTextOnBg2(const char *text); -bool8 sub_809AF6C(s32 unused, const char *text); +bool8 ScriptPrintTextOnBgAuto(s32 unused, const char *text); #endif // GUARD_WONDER_MAIL_H diff --git a/src/data/ground/ground_data_d01p01_station.h b/src/data/ground/ground_data_d01p01_station.h index f49fb8a1a..0f9bfefa5 100644 --- a/src/data/ground/ground_data_d01p01_station.h +++ b/src/data/ground/ground_data_d01p01_station.h @@ -26,7 +26,7 @@ static const struct ScriptCommand s_gs178_g0_s0_station_sref_script[] = { /* 0x822c248 */ DEBUGINFO, - SELECT_MAP(178), + SELECT_MAP(MAP_TINY_WOODS_ENTRY), BGM_STOP, JUMP_SCRIPT(COMMON_ENTER), }; @@ -39,7 +39,7 @@ static const struct ScriptCommand s_gs178_g1_s0_station_sref_script[] = { /* 0x8 BGM_STOP, { 0x23, 0x01, 0x0000, 0x00000000, 0x00000000, NULL }, { 0x26, 0x01, 0x0000, 0x00000000, 0x00000000, NULL }, - SELECT_MAP(178), + SELECT_MAP(MAP_TINY_WOODS_ENTRY), WAIT(100), MSG_ON_BG_AUTO(30, _("{CENTER_ALIGN}Where am I?")), MSG_ON_BG_AUTO(30, _("{CENTER_ALIGN}Am I dreaming this?")), @@ -64,7 +64,7 @@ static const struct ScriptCommand s_gs178_g1_s0_station_sref_script[] = { /* 0x8 { 0x3b, 0x39, 0x0004, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, BGM_FADEOUT(30), - { 0x02, 0x00, 0x001e, 0x00000000, 0x00000000, NULL }, + NEXT_DUNGEON(30, DUNGEON_TINY_WOODS), RET, }; @@ -360,7 +360,7 @@ static const struct ScriptCommand s_gs178_g2_s0_station_sref_script[] = { /* 0x8 { 0x3b, 0x39, 0x0001, 0x00000000, 0x00000000, NULL }, BGM_STOP, WAIT(60), - SELECT_MAP(178), + SELECT_MAP(MAP_TINY_WOODS_ENTRY), { 0x2d, 0x09, 0x0000, 0x00000035, 0x00000000, NULL }, { 0x2e, 0x0b, 0x0000, -0x00000002, 0x00000000, NULL }, MSG_NPC(0, _(" ...Hello?{WAIT_PRESS}\nHello!")), @@ -369,7 +369,7 @@ static const struct ScriptCommand s_gs178_g2_s0_station_sref_script[] = { /* 0x8 { 0x22, 0x01, 0x003c, 0x00000000, 0x00000000, NULL }, { 0x3b, 0x39, 0x0004, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, - { 0x02, 0x00, 0x001e, 0x00000000, 0x00000000, NULL }, + NEXT_DUNGEON(30, DUNGEON_TINY_WOODS), RET, }; @@ -517,7 +517,7 @@ static const struct ScriptCommand s_gs178_g2_s0_lives2_dlg0[] = { /* 0x822e89c - static const struct ScriptCommand s_gs178_g3_s0_station_sref_script[] = { /* 0x822e95c - PART 1 0:17:17-0:18:51 - Post-Tiny Woods cutscene */ DEBUGINFO, { 0x3b, 0x39, 0x0004, 0x00000000, 0x00000000, NULL }, - SELECT_MAP(178), + SELECT_MAP(MAP_TINY_WOODS_ENTRY), SELECT_ENTITIES(-1, 0), BGM_SWITCH(103), { 0x22, 0x01, 0x001e, 0x00000000, 0x00000000, NULL }, diff --git a/src/data/ground/ground_data_d02p01_station.h b/src/data/ground/ground_data_d02p01_station.h index 9aa2b0c16..486892989 100644 --- a/src/data/ground/ground_data_d02p01_station.h +++ b/src/data/ground/ground_data_d02p01_station.h @@ -12,7 +12,7 @@ static const struct ScriptCommand s_gs180_g0_s0_station_sref_script[] = { /* 0x82302f8 */ DEBUGINFO, - SELECT_MAP(180), + SELECT_MAP(MAP_THUNDERWAVE_CAVE_ENTRY), BGM_STOP, JUMP_SCRIPT(COMMON_ENTER), }; @@ -21,12 +21,12 @@ static const struct ScriptRef s_gs180_g0_s0_station_sref = { 404, 1, NULL /* ENT static const struct ScriptCommand s_gs180_g1_s0_station_sref_script[] = { /* 0x8230370 */ DEBUGINFO, - SELECT_MAP(180), + SELECT_MAP(MAP_THUNDERWAVE_CAVE_ENTRY), SELECT_ENTITIES(-1, 0), BGM_SWITCH(14), { 0x22, 0x01, 0x001e, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, - { 0x02, 0x00, 0x0000, 0x00000001, 0x00000000, NULL }, + NEXT_DUNGEON(0, DUNGEON_THUNDERWAVE_CAVE), RET, }; @@ -135,12 +135,12 @@ static const struct ScriptCommand s_gs180_g1_s0_lives3_dlg0[] = { /* 0x8230948 * static const struct ScriptCommand s_gs180_g2_s0_station_sref_script[] = { /* 0x82309d8 */ DEBUGINFO, - SELECT_MAP(180), + SELECT_MAP(MAP_THUNDERWAVE_CAVE_ENTRY), SELECT_ENTITIES(-1, 0), BGM_SWITCH(14), { 0x22, 0x01, 0x001e, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, - { 0x02, 0x00, 0x0000, 0x00000001, 0x00000000, NULL }, + NEXT_DUNGEON(0, DUNGEON_THUNDERWAVE_CAVE), RET, }; @@ -237,7 +237,7 @@ static const struct ScriptCommand s_gs180_g2_s0_lives3_dlg0[] = { /* 0x8230ef4 * static const struct ScriptCommand s_gs180_g3_s0_station_sref_script[] = { /* 0x8230f74 */ DEBUGINFO, - SELECT_MAP(180), + SELECT_MAP(MAP_THUNDERWAVE_CAVE_ENTRY), SELECT_ENTITIES(-1, 0), BGM_SWITCH(103), WAIT(30), diff --git a/src/data/ground/ground_data_d04p01_station.h b/src/data/ground/ground_data_d04p01_station.h index 5c06bfd5d..576f7b6c4 100644 --- a/src/data/ground/ground_data_d04p01_station.h +++ b/src/data/ground/ground_data_d04p01_station.h @@ -24,7 +24,7 @@ static const struct ScriptCommand s_gs184_g1_s0_station_sref_script[] = { /* 0x8 BGM_SWITCH(15), { 0x22, 0x01, 0x001e, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, - { 0x02, 0x00, 0x001e, 0x00000004, 0x00000000, NULL }, + NEXT_DUNGEON(30, 0x00000004), RET, }; @@ -81,7 +81,7 @@ static const struct ScriptCommand s_gs184_g2_s0_station_sref_script[] = { /* 0x8 BGM_SWITCH(15), { 0x22, 0x01, 0x001e, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, - { 0x02, 0x00, 0x001e, 0x00000004, 0x00000000, NULL }, + NEXT_DUNGEON(30, 0x00000004), RET, }; diff --git a/src/data/ground/ground_data_d05p01_station.h b/src/data/ground/ground_data_d05p01_station.h index 6ae3f5651..3de6651b2 100644 --- a/src/data/ground/ground_data_d05p01_station.h +++ b/src/data/ground/ground_data_d05p01_station.h @@ -26,7 +26,7 @@ static const struct ScriptCommand s_gs186_g1_s0_station_sref_script[] = { /* 0x8 { 0x22, 0x01, 0x001e, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, { 0x23, 0x01, 0x0001, 0x00000000, 0x00000000, NULL }, - { 0x02, 0x00, 0x0000, 0x00000006, 0x00000000, NULL }, + NEXT_DUNGEON(0, 0x00000006), RET, }; diff --git a/src/data/ground/ground_data_d06p01_station.h b/src/data/ground/ground_data_d06p01_station.h index a15778d00..6ff2cfdf2 100644 --- a/src/data/ground/ground_data_d06p01_station.h +++ b/src/data/ground/ground_data_d06p01_station.h @@ -26,7 +26,7 @@ static const struct ScriptCommand s_gs188_g1_s0_station_sref_script[] = { /* 0x8 { 0x22, 0x01, 0x001e, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, { 0x23, 0x01, 0x0001, 0x00000000, 0x00000000, NULL }, - { 0x02, 0x00, 0x0000, 0x00000007, 0x00000000, NULL }, + NEXT_DUNGEON(0, 0x00000007), RET, }; @@ -120,7 +120,7 @@ static const struct ScriptCommand s_gs188_g2_s0_station_sref_script[] = { /* 0x8 { 0x22, 0x01, 0x001e, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, { 0x23, 0x01, 0x0001, 0x00000000, 0x00000000, NULL }, - { 0x02, 0x00, 0x0000, 0x00000007, 0x00000000, NULL }, + NEXT_DUNGEON(0, 0x00000007), RET, }; diff --git a/src/data/ground/ground_data_d06p02_station.h b/src/data/ground/ground_data_d06p02_station.h index bf91ae70c..9f5ad61e8 100644 --- a/src/data/ground/ground_data_d06p02_station.h +++ b/src/data/ground/ground_data_d06p02_station.h @@ -52,7 +52,7 @@ static const struct ScriptCommand s_gs189_g0_s0_evt0_sref_script[] = { /* 0x823a LABEL(0), /* = 0x00 */ TEXTBOX_CLEAR, BGM_FADEOUT(60), - { 0x02, 0x00, 0x001e, 0x00000008, 0x00000000, NULL }, + NEXT_DUNGEON(30, 0x00000008), COND_EQUAL(-1, /* to label */ 1), HALT, }; diff --git a/src/data/ground/ground_data_d07p01_station.h b/src/data/ground/ground_data_d07p01_station.h index f771ccafb..21f397fc5 100644 --- a/src/data/ground/ground_data_d07p01_station.h +++ b/src/data/ground/ground_data_d07p01_station.h @@ -27,7 +27,7 @@ static const struct ScriptCommand s_gs191_g1_s0_station_sref_script[] = { /* 0x8 BGM_SWITCH(20), { 0x22, 0x01, 0x003c, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, - { 0x02, 0x00, 0x0000, 0x00000009, 0x00000000, NULL }, + NEXT_DUNGEON(0, 0x00000009), RET, }; @@ -94,7 +94,7 @@ static const struct ScriptCommand s_gs191_g2_s0_station_sref_script[] = { /* 0x8 BGM_SWITCH(20), { 0x22, 0x01, 0x001e, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, - { 0x02, 0x00, 0x0000, 0x00000009, 0x00000000, NULL }, + NEXT_DUNGEON(0, 0x00000009), RET, }; diff --git a/src/data/ground/ground_data_d08p01_station.h b/src/data/ground/ground_data_d08p01_station.h index 77e955931..636a11ea0 100644 --- a/src/data/ground/ground_data_d08p01_station.h +++ b/src/data/ground/ground_data_d08p01_station.h @@ -130,7 +130,7 @@ static const struct ScriptCommand s_gs193_g1_s0_station_sref_script[] = { /* 0x8 { 0x22, 0x01, 0x001e, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, { 0x23, 0x01, 0x001e, 0x00000000, 0x00000000, NULL }, - { 0x02, 0x00, 0x0000, 0x0000000a, 0x00000000, NULL }, + NEXT_DUNGEON(0, 0x0000000a), RET, }; diff --git a/src/data/ground/ground_data_d09p02_station.h b/src/data/ground/ground_data_d09p02_station.h index 7b54cb192..f617f2845 100644 --- a/src/data/ground/ground_data_d09p02_station.h +++ b/src/data/ground/ground_data_d09p02_station.h @@ -57,7 +57,7 @@ static const struct ScriptCommand s_gs196_g0_s0_evt0_sref_script[] = { /* 0x8248 LABEL(0), /* = 0x00 */ TEXTBOX_CLEAR, BGM_FADEOUT(60), - { 0x02, 0x00, 0x001e, 0x0000000c, 0x00000000, NULL }, + NEXT_DUNGEON(30, 0x0000000c), COND_EQUAL(-1, /* to label */ 1), HALT, }; diff --git a/src/data/ground/ground_data_d10p02_station.h b/src/data/ground/ground_data_d10p02_station.h index 4812c0380..7f9cced67 100644 --- a/src/data/ground/ground_data_d10p02_station.h +++ b/src/data/ground/ground_data_d10p02_station.h @@ -57,7 +57,7 @@ static const struct ScriptCommand s_gs199_g0_s0_evt0_sref_script[] = { /* 0x824e LABEL(0), /* = 0x00 */ TEXTBOX_CLEAR, BGM_FADEOUT(60), - { 0x02, 0x00, 0x001e, 0x0000000e, 0x00000000, NULL }, + NEXT_DUNGEON(30, 0x0000000e), COND_EQUAL(-1, /* to label */ 1), HALT, }; diff --git a/src/data/ground/ground_data_d11p02_station.h b/src/data/ground/ground_data_d11p02_station.h index 857b1d20e..2dcf1e074 100644 --- a/src/data/ground/ground_data_d11p02_station.h +++ b/src/data/ground/ground_data_d11p02_station.h @@ -60,11 +60,11 @@ static const struct ScriptCommand s_gs202_g0_s0_evt0_sref_script[] = { /* 0x8255 TEXTBOX_CLEAR, BGM_FADEOUT(60), JUMPIF_ARRAY(RESCUE_SCENARIO_JOB_LIST, 29, /* to label */ 2), - { 0x02, 0x00, 0x001e, 0x00000010, 0x00000000, NULL }, + NEXT_DUNGEON(30, 0x00000010), COND_EQUAL(-1, /* to label */ 1), HALT, LABEL(2), /* = 0x02 */ - { 0x02, 0x00, 0x001e, 0x00000026, 0x00000000, NULL }, + NEXT_DUNGEON(30, 0x00000026), COND_EQUAL(-1, /* to label */ 1), HALT, }; diff --git a/src/data/ground/ground_data_d12p01_station.h b/src/data/ground/ground_data_d12p01_station.h index 4444406d4..dc0f3fd14 100644 --- a/src/data/ground/ground_data_d12p01_station.h +++ b/src/data/ground/ground_data_d12p01_station.h @@ -91,7 +91,7 @@ static const struct ScriptCommand s_gs204_g1_s0_station_sref_script[] = { /* 0x8 BGM_SWITCH(108), { 0x22, 0x01, 0x001e, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, - { 0x02, 0x00, 0x001e, 0x00000011, 0x00000000, NULL }, + NEXT_DUNGEON(30, 0x00000011), RET, }; @@ -159,7 +159,7 @@ static const struct ScriptCommand s_gs204_g2_s0_station_sref_script[] = { /* 0x8 BGM_SWITCH(108), { 0x22, 0x01, 0x001e, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, - { 0x02, 0x00, 0x001e, 0x00000011, 0x00000000, NULL }, + NEXT_DUNGEON(30, 0x00000011), RET, }; diff --git a/src/data/ground/ground_data_d12p02_station.h b/src/data/ground/ground_data_d12p02_station.h index d7e8dbe8d..ad352fdfc 100644 --- a/src/data/ground/ground_data_d12p02_station.h +++ b/src/data/ground/ground_data_d12p02_station.h @@ -52,7 +52,7 @@ static const struct ScriptCommand s_gs205_g0_s0_evt0_sref_script[] = { /* 0x825d LABEL(0), /* = 0x00 */ TEXTBOX_CLEAR, BGM_FADEOUT(60), - { 0x02, 0x00, 0x001e, 0x00000012, 0x00000000, NULL }, + NEXT_DUNGEON(30, 0x00000012), COND_EQUAL(-1, /* to label */ 1), HALT, }; diff --git a/src/data/ground/ground_data_d13p01_station.h b/src/data/ground/ground_data_d13p01_station.h index d3033d2b0..c4164673d 100644 --- a/src/data/ground/ground_data_d13p01_station.h +++ b/src/data/ground/ground_data_d13p01_station.h @@ -169,7 +169,7 @@ static const struct ScriptCommand s_gs207_g2_s0_station_sref_script[] = { /* 0x8 BGM_SWITCH(22), { 0x22, 0x01, 0x001e, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, - { 0x02, 0x00, 0x001e, 0x00000013, 0x00000000, NULL }, + NEXT_DUNGEON(30, 0x00000013), RET, }; @@ -235,7 +235,7 @@ static const struct ScriptCommand s_gs207_g3_s0_station_sref_script[] = { /* 0x8 BGM_SWITCH(22), { 0x22, 0x01, 0x001e, 0x00000000, 0x00000000, NULL }, { 0xe3, 0x00, 0x0003, 0x00000000, 0x00000000, NULL }, - { 0x02, 0x00, 0x001e, 0x00000013, 0x00000000, NULL }, + NEXT_DUNGEON(30, 0x00000013), RET, }; diff --git a/src/data/ground/ground_data_d13p02_station.h b/src/data/ground/ground_data_d13p02_station.h index df68094d2..ff4c08c71 100644 --- a/src/data/ground/ground_data_d13p02_station.h +++ b/src/data/ground/ground_data_d13p02_station.h @@ -52,7 +52,7 @@ static const struct ScriptCommand s_gs208_g0_s0_evt0_sref_script[] = { /* 0x8261 LABEL(0), /* = 0x00 */ TEXTBOX_CLEAR, BGM_FADEOUT(60), - { 0x02, 0x00, 0x001e, 0x00000014, 0x00000000, NULL }, + NEXT_DUNGEON(30, 0x00000014), COND_EQUAL(-1, /* to label */ 1), HALT, }; diff --git a/src/data/ground/ground_event_data.h b/src/data/ground/ground_event_data.h index 9071112a3..8615a67b8 100644 --- a/src/data/ground/ground_event_data.h +++ b/src/data/ground/ground_event_data.h @@ -1995,7 +1995,7 @@ static const struct ScriptCommand s_script_EVENT_M01E02B_L004B[] = { /* 0x81256f static const struct ScriptCommand s_script_EVENT_M01E02B_L005[] = { /* 0x8125730 */ DEBUGINFO, EXECUTE_SUBSTATION(182, 1, 0), - { 0x02, 0x00, 0x0000, 0x00000002, 0x00000000, NULL }, + NEXT_DUNGEON(0, 0x00000002), RET, }; @@ -2008,7 +2008,7 @@ static const struct ScriptCommand s_script_EVENT_M01E02B_L006[] = { /* 0x8125770 static const struct ScriptCommand s_script_EVENT_M01E02B_L007[] = { /* 0x81257a0 */ DEBUGINFO, EXECUTE_SUBSTATION(182, 2, 0), - { 0x02, 0x00, 0x0000, 0x00000002, 0x00000000, NULL }, + NEXT_DUNGEON(0, 0x00000002), RET, }; @@ -2168,7 +2168,7 @@ static const struct ScriptCommand s_script_EVENT_M01E04A_L004[] = { /* 0x8125de0 static const struct ScriptCommand s_script_EVENT_M01E04A_L005[] = { /* 0x8125e20 */ DEBUGINFO, - { 0x02, 0x00, 0x001e, 0x00000006, 0x00000000, NULL }, + NEXT_DUNGEON(30, 0x00000006), RET, }; @@ -3842,7 +3842,7 @@ static const struct ScriptCommand s_script_EVENT_S09E01A_L004[] = { /* 0x812a2f4 static const struct ScriptCommand s_script_EVENT_S09E01A_L004B[] = { /* 0x812a344 */ DEBUGINFO, EXECUTE_SUBSTATION(201, 6, 0), - { 0x02, 0x00, 0x0000, 0x00000025, 0x00000000, NULL }, + NEXT_DUNGEON(0, 0x00000025), RET, }; @@ -3876,7 +3876,7 @@ static const struct ScriptCommand s_script_EVENT_S09E01B_L001[] = { /* 0x812a454 static const struct ScriptCommand s_script_EVENT_S09E01B_L001B[] = { /* 0x812a4a4 */ DEBUGINFO, EXECUTE_SUBSTATION(221, 1, 0), - { 0x02, 0x00, 0x0000, 0x00000027, 0x00000000, NULL }, + NEXT_DUNGEON(0, 0x00000027), RET, }; @@ -4026,7 +4026,7 @@ static const struct ScriptCommand s_script_GETOUT_M01E02B[] = { /* 0x812ab34 */ JUMPIF_EQUAL(START_MODE, 10, /* to label */ 3), JUMP_SCRIPT(EVENT_M01E02B_L006), LABEL(6), /* = 0x06 */ - { 0x02, 0x00, -0x0001, 0x00000003, 0x00000000, NULL }, + NEXT_DUNGEON(-1, 3), HALT, LABEL(1), /* = 0x01 */ JUMPIF_EQUAL(SCENARIO_MAIN, 4, /* to label */ 7), @@ -4050,7 +4050,7 @@ static const struct ScriptCommand s_script_GETOUT_M01E02B[] = { /* 0x812ab34 */ LABEL(11), /* = 0x0b */ JUMP_SCRIPT(GETOUT_R00E01A), LABEL(12), /* = 0x0c */ - { 0x02, 0x00, -0x0001, 0x00000003, 0x00000000, NULL }, + NEXT_DUNGEON(-1, 3), HALT, LABEL(3), /* = 0x03 */ JUMP_SCRIPT(EVENT_DIVIDE), @@ -4074,7 +4074,7 @@ static const struct ScriptCommand s_script_GETOUT_M01E03A[] = { /* 0x812ae04 */ JUMPIF_EQUAL(START_MODE, 10, /* to label */ 3), JUMP_SCRIPT(EVENT_M01E03A_L009), LABEL(6), /* = 0x06 */ - { 0x02, 0x00, -0x0001, 0x00000005, 0x00000000, NULL }, + NEXT_DUNGEON(-1, 5), HALT, LABEL(1), /* = 0x01 */ JUMPIF_EQUAL(SCENARIO_MAIN, 5, /* to label */ 7), @@ -4098,7 +4098,7 @@ static const struct ScriptCommand s_script_GETOUT_M01E03A[] = { /* 0x812ae04 */ LABEL(11), /* = 0x0b */ JUMP_SCRIPT(GETOUT_R00E01A), LABEL(12), /* = 0x0c */ - { 0x02, 0x00, -0x0001, 0x00000005, 0x00000000, NULL }, + NEXT_DUNGEON(-1, 5), HALT, LABEL(3), /* = 0x03 */ JUMP_SCRIPT(EVENT_DIVIDE), diff --git a/src/ground_main.c b/src/ground_main.c index 8ef8eef4e..ad8863f45 100644 --- a/src/ground_main.c +++ b/src/ground_main.c @@ -592,25 +592,21 @@ bool8 sub_8098DCC(u32 speed) return FALSE; } -bool8 GroundMainRescueRequest(s32 r0, s32 r1) +bool8 GroundMainRescueRequest(s32 dungeonId_, s32 r1) { - s32 r2 = (s16) r0; - s32 r5 = r2; - if(gUnknown_20398A8 == 0) - { - Log(0, "GroundMain recue request %3d %3d", r2, r1); - if(gUnknown_203B49D != 0) - { + // Needed to match + s32 dungeonId = (s16) dungeonId_; + s32 _dungeonId = dungeonId; + if (gUnknown_20398A8 == 0) { + Log(0, "GroundMain recue request %3d %3d", dungeonId, r1); + if (gUnknown_203B49D != 0) { gUnknown_20398A8 = 7; } - else - { - if(!gUnknown_203B49C) - { - gUnknown_20398C4 = r5; + else { + if (!gUnknown_203B49C) { + gUnknown_20398C4 = _dungeonId; } - switch(sub_80A2750(gUnknown_20398C4)) - { + switch (sub_80A2750(gUnknown_20398C4)) { case 4: gUnknown_20398A8 = 8; break; case 1: gUnknown_20398A8 = 5; break; case 2: gUnknown_20398A8 = 6; break; diff --git a/src/ground_script.c b/src/ground_script.c index ef64272e6..1aac2dc9d 100644 --- a/src/ground_script.c +++ b/src/ground_script.c @@ -1422,13 +1422,13 @@ s32 ExecuteScriptCommand(Action *action) break; } case 0x02: { - s32 arg = (s16)curCmd.arg1; - if (arg == -1) arg = (s16)GetScriptVarValue(NULL, DUNGEON_ENTER); + s32 dungeonId = (s16)curCmd.arg1; + if (dungeonId == -1) dungeonId = (s16)GetScriptVarValue(NULL, DUNGEON_ENTER); if (ScriptLoggingEnabled(TRUE)) { - Log(1, " dungeon select %3d", arg); + Log(1, " dungeon select %3d", dungeonId); } - if (arg != -1) { - GroundMainRescueRequest(arg, curCmd.argShort); + if (dungeonId != -1) { + GroundMainRescueRequest(dungeonId, curCmd.argShort); action->scriptData.script.ptr = ResolveJump(action, 1); } else { action->scriptData.script.ptr = ResolveJump(action, 0); @@ -1959,7 +1959,7 @@ s32 ExecuteScriptCommand(Action *action) break; } case 0x39: { - if ((s8)sub_809AF6C(curCmd.argShort, curCmd.argPtr) && curCmd.argShort >= 0) { + if ((s8)ScriptPrintTextOnBgAuto(curCmd.argShort, curCmd.argPtr) && curCmd.argShort >= 0) { sub_80A87AC(0, 10); if (GroundScriptCheckLockCondition(action, 0)) return 2; } diff --git a/src/textbox.c b/src/textbox.c index 7a6668da2..37274caa5 100644 --- a/src/textbox.c +++ b/src/textbox.c @@ -640,15 +640,15 @@ bool8 sub_809AB4C(s32 a0_, s32 a1_) } } -bool8 sub_809ABB4(s32 a0_, s32 a1_) +bool8 sub_809ABB4(s32 id_, s32 a1_) { - s32 a0 = (s16) a0_; + s32 id = (s16) id_; s32 a1 = (s16) a1_; - struct TextboxPortrait *portrait = &sTextbox->portraits[a0]; + struct TextboxPortrait *portrait = &sTextbox->portraits[id]; - if (sub_809A8B8(a0, a1)) { - CopyCyanMonsterNametoBuffer(gFormatBuffer_Monsters[a0], portrait->speciesID); - strcpy(gFormatBuffer_Names[a0], gFormatBuffer_Monsters[a0]); + if (sub_809A8B8(id, a1)) { + CopyCyanMonsterNametoBuffer(gFormatBuffer_Monsters[id], portrait->speciesID); + strcpy(gFormatBuffer_Names[id], gFormatBuffer_Monsters[id]); return TRUE; } else { @@ -837,7 +837,7 @@ bool8 ScriptPrintTextOnBg2(const char *text) } } -bool8 sub_809AF6C(s32 unused, const char *text) +bool8 ScriptPrintTextOnBgAuto(s32 unused, const char *text) { if (text == NULL) { return ScriptClearTextbox();