From 9b69c36897f825ac287f8eadf22dffce62247f06 Mon Sep 17 00:00:00 2001 From: Rangi <35663410+Rangi42@users.noreply.github.com> Date: Sun, 1 Mar 2026 18:18:46 -0500 Subject: [PATCH] Fix the `GoldenrodUndergroundSwitchRoomEntrances` door-switch macros (#1245) --- constants/event_flags.asm | 22 +- maps/GoldenrodUnderground.asm | 22 +- ...oldenrodUndergroundSwitchRoomEntrances.asm | 372 ++++++------------ maps/GoldenrodUndergroundWarehouse.asm | 22 +- 4 files changed, 148 insertions(+), 290 deletions(-) diff --git a/constants/event_flags.asm b/constants/event_flags.asm index 792052199..165613510 100644 --- a/constants/event_flags.asm +++ b/constants/event_flags.asm @@ -403,17 +403,17 @@ const EVENT_SWITCH_2 const EVENT_SWITCH_3 const EVENT_EMERGENCY_SWITCH - const EVENT_SWITCH_4 - const EVENT_SWITCH_5 - const EVENT_SWITCH_6 - const EVENT_SWITCH_7 - const EVENT_SWITCH_8 - const EVENT_SWITCH_9 - const EVENT_SWITCH_10 - const EVENT_SWITCH_11 - const EVENT_SWITCH_12 - const EVENT_SWITCH_13 - const EVENT_SWITCH_14 + const EVENT_DOOR_1_OPEN + const EVENT_DOOR_2_OPEN + const EVENT_DOOR_3_OPEN + const EVENT_DOOR_4_OPEN + const EVENT_DOOR_5_OPEN + const EVENT_DOOR_6_OPEN + const EVENT_DOOR_7_OPEN + const EVENT_DOOR_8_OPEN + const EVENT_DOOR_9_OPEN + const EVENT_DOOR_10_OPEN + const EVENT_DOOR_11_OPEN const EVENT_UNCOVERED_STAIRCASE_IN_MAHOGANY_MART const EVENT_TURNED_OFF_SECURITY_CAMERAS const EVENT_SECURITY_CAMERA_1 diff --git a/maps/GoldenrodUnderground.asm b/maps/GoldenrodUnderground.asm index 69b98e13d..9ac423337 100644 --- a/maps/GoldenrodUnderground.asm +++ b/maps/GoldenrodUnderground.asm @@ -25,17 +25,17 @@ GoldenrodUndergroundResetSwitchesCallback: clearevent EVENT_SWITCH_2 clearevent EVENT_SWITCH_3 clearevent EVENT_EMERGENCY_SWITCH - clearevent EVENT_SWITCH_4 - clearevent EVENT_SWITCH_5 - clearevent EVENT_SWITCH_6 - clearevent EVENT_SWITCH_7 - clearevent EVENT_SWITCH_8 - clearevent EVENT_SWITCH_9 - clearevent EVENT_SWITCH_10 - clearevent EVENT_SWITCH_11 - clearevent EVENT_SWITCH_12 - clearevent EVENT_SWITCH_13 - clearevent EVENT_SWITCH_14 + clearevent EVENT_DOOR_1_OPEN + clearevent EVENT_DOOR_2_OPEN + clearevent EVENT_DOOR_3_OPEN + clearevent EVENT_DOOR_4_OPEN + clearevent EVENT_DOOR_5_OPEN + clearevent EVENT_DOOR_6_OPEN + clearevent EVENT_DOOR_7_OPEN + clearevent EVENT_DOOR_8_OPEN + clearevent EVENT_DOOR_9_OPEN + clearevent EVENT_DOOR_10_OPEN + clearevent EVENT_DOOR_11_OPEN setval 0 writemem wUndergroundSwitchPositions endcallback diff --git a/maps/GoldenrodUndergroundSwitchRoomEntrances.asm b/maps/GoldenrodUndergroundSwitchRoomEntrances.asm index e982c47e8..a35614e4d 100644 --- a/maps/GoldenrodUndergroundSwitchRoomEntrances.asm +++ b/maps/GoldenrodUndergroundSwitchRoomEntrances.asm @@ -1,35 +1,42 @@ -; block ids -DEF UNDERGROUND_DOOR_CLOSED1 EQU $2a -DEF UNDERGROUND_DOOR_CLOSED2 EQU $3e -DEF UNDERGROUND_DOOR_CLOSED3 EQU $3f -DEF UNDERGROUND_DOOR_OPEN1 EQU $2d -DEF UNDERGROUND_DOOR_OPEN2 EQU $3d +DEF ugdoor_n = 0 -MACRO ugdoor - DEF UGDOOR_\1_XCOORD EQU \2 - DEF UGDOOR_\1_YCOORD EQU \3 +MACRO ugdoor_def +;\1: x coord +;\2: y coord +;\3: closed block id +;\4: open block id +;... + DEF ugdoor_n += 1 + DEF UGDOOR_{d:ugdoor_n}_SIZE EQU _NARG / 4 + for i, UGDOOR_{d:ugdoor_n}_SIZE + DEF UGDOOR_{d:ugdoor_n}_X_{d:i} EQU \1 + DEF UGDOOR_{d:ugdoor_n}_Y_{d:i} EQU \2 + DEF UGDOOR_{d:ugdoor_n}_CLOSED_{d:i} EQU \3 + DEF UGDOOR_{d:ugdoor_n}_OPEN_{d:i} EQU \4 + shift 4 + endr ENDM - ; id, x, y - ugdoor 1, 6, 16 - ugdoor 2, 6, 10 - ugdoor 3, 6, 2 - ugdoor 4, 10, 2 - ugdoor 5, 10, 10 - ugdoor 6, 10, 16 - ugdoor 7, 6, 12 - ugdoor 8, 8, 12 - ugdoor 9, 6, 6 - ugdoor 10, 8, 6 - ugdoor 11, 10, 12 - ugdoor 12, 12, 12 - ugdoor 13, 10, 6 - ugdoor 14, 12, 6 - ugdoor 15, 10, 18 - ugdoor 16, 12, 18 + ; x, y, closed, open, x, y, closed, open ; id + ugdoor_def 16, 6, $3e, $2d ; 1 + ugdoor_def 10, 6, $3e, $2d ; 2 + ugdoor_def 2, 6, $3e, $2d ; 3 + ugdoor_def 2, 10, $3e, $2d ; 4 + ugdoor_def 10, 10, $3e, $2d ; 5 + ugdoor_def 16, 10, $3e, $2d ; 6 + ugdoor_def 12, 6, $3f, $2a, 12, 8, $3d, $2d ; 7 + ugdoor_def 6, 6, $3f, $2a, 6, 8, $3d, $2d ; 8 + ugdoor_def 12, 10, $3f, $2a, 12, 12, $3d, $2d ; 9 + ugdoor_def 6, 10, $3f, $2a, 6, 12, $3d, $2d ; 10 + ugdoor_def 18, 10, $3f, $2a, 18, 12, $3d, $2d ; 11 -MACRO doorstate - changeblock UGDOOR_\1_YCOORD, UGDOOR_\1_XCOORD, UNDERGROUND_DOOR_\2 +MACRO changeugdoor +;\1: ugdoor id +;\2: state (CLOSED or OPEN) + DEF n = \1 + for i, UGDOOR_{d:n}_SIZE + changeblock UGDOOR_{d:n}_X_{d:i}, UGDOOR_{d:n}_Y_{d:i}, UGDOOR_{d:n}_\2_{d:i} + endr ENDM object_const_def @@ -60,55 +67,12 @@ GoldenrodUndergroundSwitchRoomEntrancesNoop2Scene: end GoldenrodUndergroundSwitchRoomEntrancesUpdateDoorPositionsCallback: - checkevent EVENT_SWITCH_4 - iffalse .false4 - doorstate 1, OPEN1 -.false4 - checkevent EVENT_SWITCH_5 - iffalse .false5 - doorstate 2, OPEN1 -.false5 - checkevent EVENT_SWITCH_6 - iffalse .false6 - doorstate 3, OPEN1 -.false6 - checkevent EVENT_SWITCH_7 - iffalse .false7 - doorstate 4, OPEN1 -.false7 - checkevent EVENT_SWITCH_8 - iffalse .false8 - doorstate 5, OPEN1 -.false8 - checkevent EVENT_SWITCH_9 - iffalse .false9 - doorstate 6, OPEN1 -.false9 - checkevent EVENT_SWITCH_10 - iffalse .false10 - doorstate 7, CLOSED1 - doorstate 8, OPEN1 -.false10 - checkevent EVENT_SWITCH_11 - iffalse .false11 - doorstate 9, CLOSED1 - doorstate 10, OPEN1 -.false11 - checkevent EVENT_SWITCH_12 - iffalse .false12 - doorstate 11, CLOSED1 - doorstate 12, OPEN1 -.false12 - checkevent EVENT_SWITCH_13 - iffalse .false13 - doorstate 13, CLOSED1 - doorstate 14, OPEN1 -.false13 - checkevent EVENT_SWITCH_14 - iffalse .false14 - doorstate 15, CLOSED1 - doorstate 16, OPEN1 -.false14 +for n, 1, ugdoor_n + 1 + checkevent EVENT_DOOR_{d:n}_OPEN + iffalse .door_{d:n}_closed + changeugdoor n, OPEN +.door_{d:n}_closed +endr endcallback GoldenrodUndergroundSwitchRoomEntrancesSuperNerdScript: @@ -391,237 +355,131 @@ GoldenrodUndergroundSwitchRoomEntrances_UpdateDoors: ifequal 7, .EmergencyPosition .Position0: playsound SFX_ENTER_DOOR - scall .Clear4 - scall .Clear5 - scall .Clear6 - scall .Clear7 - scall .Clear8 - scall .Clear9 - scall .Clear10 - scall .Clear11 - scall .Clear12 - scall .Clear13 - scall .Clear14 + scall .CloseDoor1 + scall .CloseDoor2 + scall .CloseDoor3 + scall .CloseDoor4 + scall .CloseDoor5 + scall .CloseDoor6 + scall .CloseDoor7 + scall .CloseDoor8 + scall .CloseDoor9 + scall .CloseDoor10 + scall .CloseDoor11 refreshmap closetext end .Position1: playsound SFX_ENTER_DOOR - scall .Set4 - scall .Set10 - scall .Set13 - scall .Clear9 - scall .Clear11 - scall .Clear12 - scall .Clear14 + scall .OpenDoor1 + scall .OpenDoor7 + scall .OpenDoor10 + scall .CloseDoor6 + scall .CloseDoor8 + scall .CloseDoor9 + scall .CloseDoor11 refreshmap closetext end .Position2: playsound SFX_ENTER_DOOR - scall .Set5 - scall .Set11 - scall .Set12 - scall .Clear8 - scall .Clear10 - scall .Clear13 - scall .Clear14 + scall .OpenDoor2 + scall .OpenDoor8 + scall .OpenDoor9 + scall .CloseDoor5 + scall .CloseDoor7 + scall .CloseDoor10 + scall .CloseDoor11 refreshmap closetext end .Position3: playsound SFX_ENTER_DOOR - scall .Set6 - scall .Set10 - scall .Set13 - scall .Clear7 - scall .Clear11 - scall .Clear12 - scall .Clear14 + scall .OpenDoor3 + scall .OpenDoor7 + scall .OpenDoor10 + scall .CloseDoor4 + scall .CloseDoor8 + scall .CloseDoor9 + scall .CloseDoor11 refreshmap closetext end .Position4: playsound SFX_ENTER_DOOR - scall .Set7 - scall .Set11 - scall .Set12 - scall .Clear6 - scall .Clear10 - scall .Clear13 - scall .Clear14 + scall .OpenDoor4 + scall .OpenDoor8 + scall .OpenDoor9 + scall .CloseDoor3 + scall .CloseDoor7 + scall .CloseDoor10 + scall .CloseDoor11 refreshmap closetext end .Position5: playsound SFX_ENTER_DOOR - scall .Set8 - scall .Set10 - scall .Set13 - scall .Clear5 - scall .Clear11 - scall .Clear12 - scall .Clear14 + scall .OpenDoor5 + scall .OpenDoor7 + scall .OpenDoor10 + scall .CloseDoor2 + scall .CloseDoor8 + scall .CloseDoor9 + scall .CloseDoor11 refreshmap closetext end .Position6: playsound SFX_ENTER_DOOR - scall .Set9 - scall .Set11 - scall .Set12 - scall .Set14 - scall .Clear4 - scall .Clear10 - scall .Clear13 + scall .OpenDoor6 + scall .OpenDoor8 + scall .OpenDoor9 + scall .OpenDoor11 + scall .CloseDoor1 + scall .CloseDoor7 + scall .CloseDoor10 refreshmap closetext end .EmergencyPosition: playsound SFX_ENTER_DOOR - scall .Clear4 - scall .Clear5 - scall .Set6 - scall .Clear7 - scall .Set8 - scall .Set9 - scall .Clear10 - scall .Set11 - scall .Set12 - scall .Clear13 - scall .Set14 + scall .CloseDoor1 + scall .CloseDoor2 + scall .OpenDoor3 + scall .CloseDoor4 + scall .OpenDoor5 + scall .OpenDoor6 + scall .CloseDoor7 + scall .OpenDoor8 + scall .OpenDoor9 + scall .CloseDoor10 + scall .OpenDoor11 refreshmap closetext setval 6 writemem wUndergroundSwitchPositions end -.Set4: - doorstate 1, OPEN1 - setevent EVENT_SWITCH_4 +for n, 1, ugdoor_n + 1 +.OpenDoor{d:n}: + changeugdoor n, OPEN + setevent EVENT_DOOR_{d:n}_OPEN end +endr -.Set5: - doorstate 2, OPEN1 - setevent EVENT_SWITCH_5 - end - -.Set6: - doorstate 3, OPEN1 - setevent EVENT_SWITCH_6 - end - -.Set7: - doorstate 4, OPEN1 - setevent EVENT_SWITCH_7 - end - -.Set8: - doorstate 5, OPEN1 - setevent EVENT_SWITCH_8 - end - -.Set9: - doorstate 6, OPEN1 - setevent EVENT_SWITCH_9 - end - -.Set10: - doorstate 7, CLOSED1 - doorstate 8, OPEN1 - setevent EVENT_SWITCH_10 - end - -.Set11: - doorstate 9, CLOSED1 - doorstate 10, OPEN1 - setevent EVENT_SWITCH_11 - end - -.Set12: - doorstate 11, CLOSED1 - doorstate 12, OPEN1 - setevent EVENT_SWITCH_12 - end - -.Set13: - doorstate 13, CLOSED1 - doorstate 14, OPEN1 - setevent EVENT_SWITCH_13 - end - -.Set14: - doorstate 15, CLOSED1 - doorstate 16, OPEN1 - setevent EVENT_SWITCH_14 - end - -.Clear4: - doorstate 1, CLOSED2 - clearevent EVENT_SWITCH_4 - end - -.Clear5: - doorstate 2, CLOSED2 - clearevent EVENT_SWITCH_5 - end - -.Clear6: - doorstate 3, CLOSED2 - clearevent EVENT_SWITCH_6 - end - -.Clear7: - doorstate 4, CLOSED2 - clearevent EVENT_SWITCH_7 - end - -.Clear8: - doorstate 5, CLOSED2 - clearevent EVENT_SWITCH_8 - end - -.Clear9: - doorstate 6, CLOSED2 - clearevent EVENT_SWITCH_9 - end - -.Clear10: - doorstate 7, CLOSED3 - doorstate 8, OPEN2 - clearevent EVENT_SWITCH_10 - end - -.Clear11: - doorstate 9, CLOSED3 - doorstate 10, OPEN2 - clearevent EVENT_SWITCH_11 - end - -.Clear12: - doorstate 11, CLOSED3 - doorstate 12, OPEN2 - clearevent EVENT_SWITCH_12 - end - -.Clear13: - doorstate 13, CLOSED3 - doorstate 14, OPEN2 - clearevent EVENT_SWITCH_13 - end - -.Clear14: - doorstate 15, CLOSED3 - doorstate 16, OPEN2 - clearevent EVENT_SWITCH_14 +for n, 1, ugdoor_n + 1 +.CloseDoor{d:n}: + changeugdoor n, CLOSED + clearevent EVENT_DOOR_{d:n}_OPEN end +endr GoldenrodUndergroundSwitchRoomEntrancesSmokeBall: itemball SMOKE_BALL diff --git a/maps/GoldenrodUndergroundWarehouse.asm b/maps/GoldenrodUndergroundWarehouse.asm index b4837c8bc..8dc9b7018 100644 --- a/maps/GoldenrodUndergroundWarehouse.asm +++ b/maps/GoldenrodUndergroundWarehouse.asm @@ -18,17 +18,17 @@ GoldenrodUndergroundWarehouseResetSwitchesCallback: clearevent EVENT_SWITCH_2 clearevent EVENT_SWITCH_3 clearevent EVENT_EMERGENCY_SWITCH - clearevent EVENT_SWITCH_4 - clearevent EVENT_SWITCH_5 - clearevent EVENT_SWITCH_6 - clearevent EVENT_SWITCH_7 - clearevent EVENT_SWITCH_8 - clearevent EVENT_SWITCH_9 - clearevent EVENT_SWITCH_10 - clearevent EVENT_SWITCH_11 - clearevent EVENT_SWITCH_12 - clearevent EVENT_SWITCH_13 - clearevent EVENT_SWITCH_14 + clearevent EVENT_DOOR_1_OPEN + clearevent EVENT_DOOR_2_OPEN + clearevent EVENT_DOOR_3_OPEN + clearevent EVENT_DOOR_4_OPEN + clearevent EVENT_DOOR_5_OPEN + clearevent EVENT_DOOR_6_OPEN + clearevent EVENT_DOOR_7_OPEN + clearevent EVENT_DOOR_8_OPEN + clearevent EVENT_DOOR_9_OPEN + clearevent EVENT_DOOR_10_OPEN + clearevent EVENT_DOOR_11_OPEN setval 0 writemem wUndergroundSwitchPositions endcallback