diff --git a/include/data_script.h b/include/data_script.h index bc6285330..c39e495c8 100644 --- a/include/data_script.h +++ b/include/data_script.h @@ -103,7 +103,8 @@ #define SCENARIO_ADVANCE(v,a) { 0xAA, 0, v, a, 0, NULL } #define SET_DUNGEON_RES(r,e) { 0xAB, 0, r, e, 0, NULL } #define SET_PLAYER_KIND(k) { 0xAC, 0, k, 0, 0, NULL } -// ad..b2: opaque functions +#define UNLOCK_FRIEND_AREA(a) { 0xAD, TRUE, a, 0, 0, NULL } +// ae..b2: opaque functions #define JUMPIF_EQUAL(v,i,l) { 0xB3, l, v, i, 0, NULL } #define JUMPIF(o,v,i,l) { 0xB4, o, l, v, i, NULL } #define JUMPIF_2(o,a,b,l) { 0xB5, o, l, a, b, NULL } diff --git a/include/event_flag.h b/include/event_flag.h index 624835a95..c1b84ee7e 100644 --- a/include/event_flag.h +++ b/include/event_flag.h @@ -39,7 +39,7 @@ bool8 CheckQuest(s32 questID); u8 MapIdToFriendAreaId(s16 mapId_); // map -> friend area lookup s16 FriendAreaIdToMapId(u8 friendAreaId); // friend area -> map lookup bool8 sub_80026CC(s16 r0); -void sub_80026E8(s16 r0, bool8 r1); +void ScriptUnlockFriendArea(s16 r0, bool8 r1); bool8 SaveGlobalScriptVars(void *dest); bool8 RestoreGlobalScriptVars(u8 *src); diff --git a/src/data/ground/ground_event_data.h b/src/data/ground/ground_event_data.h index c7c453999..a07dcb575 100644 --- a/src/data/ground/ground_event_data.h +++ b/src/data/ground/ground_event_data.h @@ -3054,7 +3054,7 @@ static const struct ScriptCommand s_script_EVENT_S01E02A_START[] = { /* 0x812816 SCENARIO_CALC(SCENARIO_SUB1, 31, 1), { 0xae, 0x01, 0x000f, 0x00000000, 0x00000000, NULL }, { 0xb0, 0x01, 0x000e, 0x00000000, 0x00000000, NULL }, - { 0xad, 0x01, 0x0076, 0x00000000, 0x00000000, NULL }, + UNLOCK_FRIEND_AREA(MAP_FRIEND_AREA_SKY_BLUE_PLAINS), UPDATE_VARINT(CALC_SET, BASE_LEVEL, 2), RET_DIRECT, }; diff --git a/src/event_flag.c b/src/event_flag.c index 6e2486f64..415d958f3 100644 --- a/src/event_flag.c +++ b/src/event_flag.c @@ -922,7 +922,7 @@ bool8 sub_80026CC(s16 r0) } // arm9.bin::0200E568 -void sub_80026E8(s16 r0, bool8 r1) +void ScriptUnlockFriendArea(s16 r0, bool8 r1) { UnlockFriendArea(MapIdToFriendAreaId(r0)); } diff --git a/src/ground_main.c b/src/ground_main.c index d3e6e2fdd..4a5c87922 100644 --- a/src/ground_main.c +++ b/src/ground_main.c @@ -113,7 +113,7 @@ u32 xxx_script_related_8098468(s32 param_1) s32 local_1c; u32 auStack24; - GetScriptVarScenario(3,&local_1c,&auStack24); + GetScriptVarScenario(SCENARIO_MAIN,&local_1c,&auStack24); gUnknown_20398B8 = local_1c == 0; gUnknown_20398B9 = 1; break; diff --git a/src/ground_script.c b/src/ground_script.c index e850fbe6f..32a32ab7c 100644 --- a/src/ground_script.c +++ b/src/ground_script.c @@ -2552,31 +2552,31 @@ static s32 ExecuteScriptCommand(Action *action) UpdateScriptVarWithVar(scriptData->localVars.buf, curCmd.argShort, (s16)curCmd.arg1, curCmd.argByte); break; } - case 0xa8: { + case 0xA8: { // SET_ARRAYVAL SetScriptVarArrayValue(scriptData->localVars.buf, curCmd.argShort, (u16)curCmd.arg1, curCmd.arg2); break; } - case 0xa9: { + case 0xA9: { // SCENARIO_CALC ScenarioCalc(curCmd.argShort, curCmd.arg1, curCmd.arg2); break; } - case 0xaa: { + case 0xAA: { // SCENARIO_ADVANCE s32 a, b; GetScriptVarScenario(curCmd.argShort, &a, &b); - ScenarioCalc(curCmd.argShort, a, b+1); + ScenarioCalc(curCmd.argShort, a, b + 1); break; } - case 0xab: { + case 0xAB: { // SET_DUNGEON_RES SetScriptVarValue(NULL, DUNGEON_ENTER, curCmd.arg1); SetScriptVarValue(NULL, DUNGEON_RESULT, curCmd.argShort); break; } - case 0xac: { + case 0xAC: { // SET_PLAYER_KIND SetScriptVarValue(NULL, PLAYER_KIND, curCmd.argShort); break; } - case 0xad: { - sub_80026E8(curCmd.argShort, (u8)curCmd.argByte > 0); + case 0xAD: { // UNLOCK_FRIEND_AREA + ScriptUnlockFriendArea(curCmd.argShort, (u8)curCmd.argByte > 0); break; } case 0xae: { @@ -2641,13 +2641,13 @@ static s32 ExecuteScriptCommand(Action *action) } break; } - case 0xba: { // JUMPIF_SCENE_GT + case 0xBA: { // JUMPIF_SCENE_GT if (ScriptVarScenarioAfter(curCmd.argShort, curCmd.arg1, curCmd.arg2)) { scriptData->script.ptr = FindLabel(action, (u8)curCmd.argByte); } break; } - case 0xbb: { // JUMPIF_SCENARIOCHECK + case 0xBB: { // JUMPIF_SCENARIOCHECK if (CheckQuest(curCmd.argShort)) { scriptData->script.ptr = FindLabel(action, (u8)curCmd.argByte); } @@ -3267,7 +3267,7 @@ static s32 sub_80A14E8(Action *action, u8 idx, u32 r2, s32 r3) } break; case 0x20: - sub_80026E8(0x9E, 0x1); + ScriptUnlockFriendArea(MAP_FRIEND_AREA_LEGENDARY_ISLAND, TRUE); if (GetRecruitedMonBySpecies(MONSTER_ZAPDOS, 0) == NULL) { static const DungeonLocation zapdosLoc = {.id = DUNGEON_MT_THUNDER_PEAK, .floor = 99}; if (TryAddLevel1PokemonToRecruited(MONSTER_ZAPDOS, NULL, ITEM_NOTHING, &zapdosLoc, NULL))