Skip to content

Commit

Permalink
Improve the event initialization system
Browse files Browse the repository at this point in the history
  • Loading branch information
lwelyk committed Jan 12, 2024
1 parent 0a06d04 commit eff5518
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 146 deletions.
148 changes: 148 additions & 0 deletions data/events/init_events.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
InitialEvents:
dw EVENT_EARLS_ACADEMY_EARL
dw EVENT_RADIO_TOWER_ROCKET_TAKEOVER
dw EVENT_GOLDENROD_CITY_ROCKET_TAKEOVER
dw EVENT_RADIO_TOWER_CIVILIANS_AFTER
dw EVENT_ILEX_FOREST_APPRENTICE
dw EVENT_ILEX_FOREST_FARFETCHD
dw EVENT_ILEX_FOREST_CHARCOAL_MASTER
dw EVENT_MAHOGANY_MART_LANCE_AND_DRAGONITE
dw EVENT_TEAM_ROCKET_BASE_B2F_GRUNT_WITH_EXECUTIVE
dw EVENT_TEAM_ROCKET_BASE_B2F_EXECUTIVE
dw EVENT_TEAM_ROCKET_BASE_B2F_DRAGONITE
dw EVENT_RIVAL_TEAM_ROCKET_BASE
dw EVENT_BLACKTHORN_CITY_SUPER_NERD_DOES_NOT_BLOCK_GYM
dw EVENT_USED_THE_CARD_KEY_IN_THE_RADIO_TOWER
dw EVENT_RIVAL_CHERRYGROVE_CITY
dw EVENT_RIVAL_AZALEA_TOWN
dw EVENT_RIVAL_GOLDENROD_UNDERGROUND
dw EVENT_AZALEA_TOWN_SLOWPOKES
dw EVENT_KURTS_HOUSE_SLOWPOKE
dw EVENT_GUIDE_GENT_VISIBLE_IN_CHERRYGROVE
dw EVENT_ELMS_AIDE_IN_VIOLET_POKEMON_CENTER
dw EVENT_COP_IN_ELMS_LAB
dw EVENT_RUINS_OF_ALPH_OUTSIDE_SCIENTIST
dw EVENT_RUINS_OF_ALPH_RESEARCH_CENTER_SCIENTIST
dw EVENT_BOULDER_IN_ICE_PATH_1A
dw EVENT_BOULDER_IN_ICE_PATH_2A
dw EVENT_BOULDER_IN_ICE_PATH_3A
dw EVENT_BOULDER_IN_ICE_PATH_4A
dw EVENT_ROUTE_30_YOUNGSTER_JOEY
dw EVENT_BUG_CATCHING_CONTESTANT_1A
dw EVENT_BUG_CATCHING_CONTESTANT_2A
dw EVENT_BUG_CATCHING_CONTESTANT_3A
dw EVENT_BUG_CATCHING_CONTESTANT_4A
dw EVENT_BUG_CATCHING_CONTESTANT_5A
dw EVENT_BUG_CATCHING_CONTESTANT_6A
dw EVENT_BUG_CATCHING_CONTESTANT_7A
dw EVENT_BUG_CATCHING_CONTESTANT_8A
dw EVENT_BUG_CATCHING_CONTESTANT_9A
dw EVENT_BUG_CATCHING_CONTESTANT_10A
dw EVENT_BUG_CATCHING_CONTESTANT_1B
dw EVENT_BUG_CATCHING_CONTESTANT_2B
dw EVENT_BUG_CATCHING_CONTESTANT_3B
dw EVENT_BUG_CATCHING_CONTESTANT_4B
dw EVENT_BUG_CATCHING_CONTESTANT_5B
dw EVENT_BUG_CATCHING_CONTESTANT_6B
dw EVENT_BUG_CATCHING_CONTESTANT_7B
dw EVENT_BUG_CATCHING_CONTESTANT_8B
dw EVENT_BUG_CATCHING_CONTESTANT_9B
dw EVENT_BUG_CATCHING_CONTESTANT_10B
dw EVENT_FAST_SHIP_1F_GENTLEMAN
dw EVENT_FAST_SHIP_B1F_SAILOR_RIGHT
dw EVENT_FAST_SHIP_CABINS_NNW_NNE_NE_SAILOR
dw EVENT_LAKE_OF_RAGE_CIVILIANS
dw EVENT_MAHOGANY_MART_OWNERS
dw EVENT_TIN_TOWER_ROOF_HO_OH
dw EVENT_WHIRL_ISLAND_LUGIA_CHAMBER_LUGIA
dw EVENT_PLAYERS_HOUSE_2F_CONSOLE
dw EVENT_PLAYERS_HOUSE_2F_DOLL_1
dw EVENT_PLAYERS_HOUSE_2F_DOLL_2
dw EVENT_PLAYERS_HOUSE_2F_BIG_DOLL
dw EVENT_DECO_BED_1
dw EVENT_DECO_POSTER_1
dw EVENT_GOLDENROD_TRAIN_STATION_GENTLEMAN
dw EVENT_OLIVINE_GYM_JASMINE
dw EVENT_BLACKTHORN_CITY_GRAMPS_NOT_BLOCKING_DRAGONS_DEN
dw EVENT_MET_BILL
dw EVENT_ECRUTEAK_POKE_CENTER_BILL
dw EVENT_MYSTERY_GIFT_DELIVERY_GUY
dw EVENT_LAKE_OF_RAGE_LANCE
dw EVENT_GOLDENROD_DEPT_STORE_B1F_LAYOUT_1
dw EVENT_GOLDENROD_UNDERGROUND_WAREHOUSE_BLOCKED_OFF
dw EVENT_DRAGONS_DEN_CLAIR
dw EVENT_RIVAL_OLIVINE_CITY
dw EVENT_RIVAL_VICTORY_ROAD
dw EVENT_RIVAL_DRAGONS_DEN
dw EVENT_LANCES_ROOM_OAK_AND_MARY
dw EVENT_FAST_SHIP_CABINS_SE_SSE_CAPTAINS_CABIN_TWIN_1
dw EVENT_BURNED_TOWER_B1F_BEASTS_1
dw EVENT_RED_IN_MT_SILVER
dw EVENT_OLIVINE_PORT_SPRITES_AFTER_HALL_OF_FAME
dw EVENT_FAST_SHIP_PASSENGERS_EASTBOUND
dw EVENT_FAST_SHIP_PASSENGERS_WESTBOUND
dw EVENT_OLIVINE_PORT_PASSAGE_POKEFAN_M
dw EVENT_KURTS_HOUSE_KURT_2
dw EVENT_KURTS_HOUSE_GRANDDAUGHTER_2
dw EVENT_RANG_CLEAR_BELL_1
dw EVENT_FLORIA_AT_FLOWER_SHOP
dw EVENT_FLORIA_AT_SUDOWOODO
dw EVENT_GOLDENROD_CITY_MOVE_TUTOR
dw EVENT_RUINS_OF_ALPH_OUTSIDE_TOURIST_FISHER
dw EVENT_RUINS_OF_ALPH_OUTSIDE_TOURIST_YOUNGSTERS
dw EVENT_DRAGON_SHRINE_CLAIR
dw EVENT_BATTLE_TOWER_BATTLE_ROOM_YOUNGSTER
dw EVENT_PLAYERS_NEIGHBORS_HOUSE_NEIGHBOR
dw EVENT_AZALEA_TOWN_KURT
dw EVENT_AZALEA_TOWN_KURT
dw EVENT_ILEX_FOREST_KURT
dw EVENT_ROUTE_34_ILEX_FOREST_GATE_TEACHER_IN_WALKWAY
dw EVENT_ILEX_FOREST_LASS
dw EVENT_GOLDENROD_SALE_OFF
dw EVENT_ECRUTEAK_CITY_GRAMPS
dw EVENT_EUSINE_IN_BURNED_TOWER
dw EVENT_PLAYERS_HOUSE_MOM_2
dw EVENT_WISE_TRIOS_ROOM_WISE_TRIO_2
dw EVENT_CIANWOOD_CITY_EUSINE
dw EVENT_TIN_TOWER_1F_EUSINE
dw EVENT_TIN_TOWER_1F_WISE_TRIO_1
dw EVENT_TIN_TOWER_1F_WISE_TRIO_2
dw EVENT_SET_WHEN_FOUGHT_HO_OH
dw EVENT_SAW_SUICUNE_ON_ROUTE_36
dw EVENT_SAW_SUICUNE_ON_ROUTE_42
dw EVENT_SAW_SUICUNE_AT_CIANWOOD_CITY
dw EVENT_BATTLE_TOWER_OPEN_CIVILIANS
dw EVENT_FOUND_MACHINE_PART_IN_CERULEAN_GYM
dw EVENT_CERULEAN_GYM_ROCKET
dw EVENT_ROUTE_24_ROCKET
dw EVENT_ROUTE_25_MISTY_BOYFRIEND
dw EVENT_TRAINERS_IN_CERULEAN_GYM
dw EVENT_COPYCATS_HOUSE_2F_DOLL
dw EVENT_VIRIDIAN_GYM_BLUE
dw EVENT_SEAFOAM_GYM_GYM_GUIDE
dw EVENT_MT_MOON_SQUARE_CLEFAIRY
dw EVENT_SAFFRON_TRAIN_STATION_POPULATION
dw EVENT_INDIGO_PLATEAU_POKECENTER_RIVAL
dw EVENT_INITIALIZED_EVENTS
dw -1 ; end

InitialEngineFlags:
dw ENGINE_ROCKET_SIGNAL_ON_CH20
dw ENGINE_ROCKETS_IN_MAHOGANY
dw -1 ; end

InitialVariableSprites:
MACRO initvarsprite
; variable sprite, appearance sprite
db \1 - SPRITE_VARS, \2
ENDM
initvarsprite SPRITE_WEIRD_TREE, SPRITE_SUDOWOODO
initvarsprite SPRITE_OLIVINE_RIVAL, SPRITE_RIVAL
initvarsprite SPRITE_AZALEA_ROCKET, SPRITE_ROCKET
initvarsprite SPRITE_FUCHSIA_GYM_1, SPRITE_JANINE
initvarsprite SPRITE_FUCHSIA_GYM_2, SPRITE_JANINE
initvarsprite SPRITE_FUCHSIA_GYM_3, SPRITE_JANINE
initvarsprite SPRITE_FUCHSIA_GYM_4, SPRITE_JANINE
initvarsprite SPRITE_COPYCAT, SPRITE_LASS
initvarsprite SPRITE_JANINE_IMPERSONATOR, SPRITE_LASS
db -1 ; end
52 changes: 52 additions & 0 deletions engine/events/init_events.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
InitializeEvents:
; initialize events
ld hl, InitialEvents
.events_loop
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
and e
cp -1
jr z, .events_done
ld b, SET_FLAG
push hl
call EventFlagAction
pop hl
jr .events_loop

.events_done
; initialize engine flags
ld hl, InitialEngineFlags
.flags_loop
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
and e
cp -1
jr z, .flags_done
ld b, SET_FLAG
push hl
farcall EngineFlagAction
pop hl
jr .flags_loop

.flags_done
; initialize variable sprites
ld hl, InitialVariableSprites
.sprites_loop
ld a, [hli]
ld e, a
ld d, 0
cp -1
ret z
ld a, [hli]
push hl
ld hl, wVariableSprites
add hl, de
ld [hl], a
pop hl
jr .sprites_loop

INCLUDE "data/events/init_events.asm"
140 changes: 0 additions & 140 deletions engine/events/std_scripts.asm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ StdScripts::
add_stdscript DayToTextScript
add_stdscript BugContestResultsWarpScript
add_stdscript BugContestResultsScript
add_stdscript InitializeEventsScript
add_stdscript AskNumber1MScript
add_stdscript AskNumber2MScript
add_stdscript RegisteredNumberMScript
Expand Down Expand Up @@ -477,145 +476,6 @@ BugContestResults_CopyContestantsToResults:
.skip10
end

InitializeEventsScript:
setevent EVENT_EARLS_ACADEMY_EARL
setevent EVENT_RADIO_TOWER_ROCKET_TAKEOVER
setevent EVENT_GOLDENROD_CITY_ROCKET_TAKEOVER
setevent EVENT_RADIO_TOWER_CIVILIANS_AFTER
setevent EVENT_ILEX_FOREST_APPRENTICE
setevent EVENT_ILEX_FOREST_FARFETCHD
setevent EVENT_ILEX_FOREST_CHARCOAL_MASTER
setevent EVENT_MAHOGANY_MART_LANCE_AND_DRAGONITE
setevent EVENT_TEAM_ROCKET_BASE_B2F_GRUNT_WITH_EXECUTIVE
setevent EVENT_TEAM_ROCKET_BASE_B2F_EXECUTIVE
setevent EVENT_TEAM_ROCKET_BASE_B2F_DRAGONITE
setevent EVENT_RIVAL_TEAM_ROCKET_BASE
setevent EVENT_BLACKTHORN_CITY_SUPER_NERD_DOES_NOT_BLOCK_GYM
setevent EVENT_USED_THE_CARD_KEY_IN_THE_RADIO_TOWER
setevent EVENT_RIVAL_CHERRYGROVE_CITY
setevent EVENT_RIVAL_AZALEA_TOWN
setevent EVENT_RIVAL_GOLDENROD_UNDERGROUND
setevent EVENT_AZALEA_TOWN_SLOWPOKES
setevent EVENT_KURTS_HOUSE_SLOWPOKE
setevent EVENT_GUIDE_GENT_VISIBLE_IN_CHERRYGROVE
setevent EVENT_ELMS_AIDE_IN_VIOLET_POKEMON_CENTER
setevent EVENT_COP_IN_ELMS_LAB
setevent EVENT_RUINS_OF_ALPH_OUTSIDE_SCIENTIST
setevent EVENT_RUINS_OF_ALPH_RESEARCH_CENTER_SCIENTIST
setevent EVENT_BOULDER_IN_ICE_PATH_1A
setevent EVENT_BOULDER_IN_ICE_PATH_2A
setevent EVENT_BOULDER_IN_ICE_PATH_3A
setevent EVENT_BOULDER_IN_ICE_PATH_4A
setevent EVENT_ROUTE_30_YOUNGSTER_JOEY
setevent EVENT_BUG_CATCHING_CONTESTANT_1A
setevent EVENT_BUG_CATCHING_CONTESTANT_2A
setevent EVENT_BUG_CATCHING_CONTESTANT_3A
setevent EVENT_BUG_CATCHING_CONTESTANT_4A
setevent EVENT_BUG_CATCHING_CONTESTANT_5A
setevent EVENT_BUG_CATCHING_CONTESTANT_6A
setevent EVENT_BUG_CATCHING_CONTESTANT_7A
setevent EVENT_BUG_CATCHING_CONTESTANT_8A
setevent EVENT_BUG_CATCHING_CONTESTANT_9A
setevent EVENT_BUG_CATCHING_CONTESTANT_10A
setevent EVENT_BUG_CATCHING_CONTESTANT_1B
setevent EVENT_BUG_CATCHING_CONTESTANT_2B
setevent EVENT_BUG_CATCHING_CONTESTANT_3B
setevent EVENT_BUG_CATCHING_CONTESTANT_4B
setevent EVENT_BUG_CATCHING_CONTESTANT_5B
setevent EVENT_BUG_CATCHING_CONTESTANT_6B
setevent EVENT_BUG_CATCHING_CONTESTANT_7B
setevent EVENT_BUG_CATCHING_CONTESTANT_8B
setevent EVENT_BUG_CATCHING_CONTESTANT_9B
setevent EVENT_BUG_CATCHING_CONTESTANT_10B
setevent EVENT_FAST_SHIP_1F_GENTLEMAN
setevent EVENT_FAST_SHIP_B1F_SAILOR_RIGHT
setevent EVENT_FAST_SHIP_CABINS_NNW_NNE_NE_SAILOR
setevent EVENT_LAKE_OF_RAGE_CIVILIANS
setevent EVENT_MAHOGANY_MART_OWNERS
setevent EVENT_TIN_TOWER_ROOF_HO_OH
setevent EVENT_WHIRL_ISLAND_LUGIA_CHAMBER_LUGIA
setevent EVENT_PLAYERS_HOUSE_2F_CONSOLE
setevent EVENT_PLAYERS_HOUSE_2F_DOLL_1
setevent EVENT_PLAYERS_HOUSE_2F_DOLL_2
setevent EVENT_PLAYERS_HOUSE_2F_BIG_DOLL
setevent EVENT_DECO_BED_1
setevent EVENT_DECO_POSTER_1
setevent EVENT_GOLDENROD_TRAIN_STATION_GENTLEMAN
setevent EVENT_OLIVINE_GYM_JASMINE
setevent EVENT_BLACKTHORN_CITY_GRAMPS_NOT_BLOCKING_DRAGONS_DEN
setevent EVENT_MET_BILL
setevent EVENT_ECRUTEAK_POKE_CENTER_BILL
setevent EVENT_MYSTERY_GIFT_DELIVERY_GUY
setevent EVENT_LAKE_OF_RAGE_LANCE
setevent EVENT_GOLDENROD_DEPT_STORE_B1F_LAYOUT_1
setevent EVENT_GOLDENROD_UNDERGROUND_WAREHOUSE_BLOCKED_OFF
setevent EVENT_DRAGONS_DEN_CLAIR
setevent EVENT_RIVAL_OLIVINE_CITY
setevent EVENT_RIVAL_VICTORY_ROAD
setevent EVENT_RIVAL_DRAGONS_DEN
setevent EVENT_LANCES_ROOM_OAK_AND_MARY
setevent EVENT_FAST_SHIP_CABINS_SE_SSE_CAPTAINS_CABIN_TWIN_1
setevent EVENT_BURNED_TOWER_B1F_BEASTS_1
setevent EVENT_RED_IN_MT_SILVER
setevent EVENT_OLIVINE_PORT_SPRITES_AFTER_HALL_OF_FAME
setevent EVENT_FAST_SHIP_PASSENGERS_EASTBOUND
setevent EVENT_FAST_SHIP_PASSENGERS_WESTBOUND
setevent EVENT_OLIVINE_PORT_PASSAGE_POKEFAN_M
setevent EVENT_KURTS_HOUSE_KURT_2
setevent EVENT_KURTS_HOUSE_GRANDDAUGHTER_2
setevent EVENT_RANG_CLEAR_BELL_1
setevent EVENT_FLORIA_AT_FLOWER_SHOP
setevent EVENT_FLORIA_AT_SUDOWOODO
setevent EVENT_GOLDENROD_CITY_MOVE_TUTOR
setevent EVENT_RUINS_OF_ALPH_OUTSIDE_TOURIST_FISHER
setevent EVENT_RUINS_OF_ALPH_OUTSIDE_TOURIST_YOUNGSTERS
setevent EVENT_DRAGON_SHRINE_CLAIR
setevent EVENT_BATTLE_TOWER_BATTLE_ROOM_YOUNGSTER
setevent EVENT_PLAYERS_NEIGHBORS_HOUSE_NEIGHBOR
setevent EVENT_AZALEA_TOWN_KURT
setevent EVENT_AZALEA_TOWN_KURT
setevent EVENT_ILEX_FOREST_KURT
setevent EVENT_ROUTE_34_ILEX_FOREST_GATE_TEACHER_IN_WALKWAY
setevent EVENT_ILEX_FOREST_LASS
setevent EVENT_GOLDENROD_SALE_OFF
setevent EVENT_ECRUTEAK_CITY_GRAMPS
setevent EVENT_EUSINE_IN_BURNED_TOWER
setevent EVENT_PLAYERS_HOUSE_MOM_2
setevent EVENT_WISE_TRIOS_ROOM_WISE_TRIO_2
setevent EVENT_CIANWOOD_CITY_EUSINE
setevent EVENT_TIN_TOWER_1F_EUSINE
setevent EVENT_TIN_TOWER_1F_WISE_TRIO_1
setevent EVENT_TIN_TOWER_1F_WISE_TRIO_2
setevent EVENT_SET_WHEN_FOUGHT_HO_OH
setevent EVENT_SAW_SUICUNE_ON_ROUTE_36
setevent EVENT_SAW_SUICUNE_ON_ROUTE_42
setevent EVENT_SAW_SUICUNE_AT_CIANWOOD_CITY
setevent EVENT_BATTLE_TOWER_OPEN_CIVILIANS
setflag ENGINE_ROCKET_SIGNAL_ON_CH20
setflag ENGINE_ROCKETS_IN_MAHOGANY
variablesprite SPRITE_WEIRD_TREE, SPRITE_SUDOWOODO
variablesprite SPRITE_OLIVINE_RIVAL, SPRITE_RIVAL
variablesprite SPRITE_AZALEA_ROCKET, SPRITE_ROCKET
variablesprite SPRITE_FUCHSIA_GYM_1, SPRITE_JANINE
variablesprite SPRITE_FUCHSIA_GYM_2, SPRITE_JANINE
variablesprite SPRITE_FUCHSIA_GYM_3, SPRITE_JANINE
variablesprite SPRITE_FUCHSIA_GYM_4, SPRITE_JANINE
variablesprite SPRITE_COPYCAT, SPRITE_LASS
variablesprite SPRITE_JANINE_IMPERSONATOR, SPRITE_LASS
setevent EVENT_FOUND_MACHINE_PART_IN_CERULEAN_GYM
setevent EVENT_CERULEAN_GYM_ROCKET
setevent EVENT_ROUTE_24_ROCKET
setevent EVENT_ROUTE_25_MISTY_BOYFRIEND
setevent EVENT_TRAINERS_IN_CERULEAN_GYM
setevent EVENT_COPYCATS_HOUSE_2F_DOLL
setevent EVENT_VIRIDIAN_GYM_BLUE
setevent EVENT_SEAFOAM_GYM_GYM_GUIDE
setevent EVENT_MT_MOON_SQUARE_CLEFAIRY
setevent EVENT_SAFFRON_TRAIN_STATION_POPULATION
setevent EVENT_INDIGO_PLATEAU_POKECENTER_RIVAL
setevent EVENT_INITIALIZED_EVENTS
endcallback

AskNumber1MScript:
special RandomPhoneMon
readvar VAR_CALLERID
Expand Down
1 change: 1 addition & 0 deletions engine/menus/intro_menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ InitializeWorld:
call ShrinkPlayer
farcall SpawnPlayer
farcall _InitializeStartDay
farcall InitializeEvents
ret

LoadOrRegenerateLuckyIDNumber:
Expand Down
1 change: 1 addition & 0 deletions main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ INCLUDE "engine/pokemon/mail_2.asm"
SECTION "Phone Scripts 2", ROMX

INCLUDE "engine/events/std_scripts.asm"
INCLUDE "engine/events/init_events.asm"
INCLUDE "engine/phone/scripts/unused.asm"
INCLUDE "engine/phone/scripts/mom.asm"
INCLUDE "engine/phone/scripts/bill.asm"
Expand Down
6 changes: 0 additions & 6 deletions maps/PlayersHouse2F.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ PlayersHouse2FNoopScene: ; unreferenced
PlayersHouse2FInitializeRoomCallback:
special ToggleDecorationsVisibility
setevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_8
checkevent EVENT_INITIALIZED_EVENTS
iftrue .SkipInitialization
jumpstd InitializeEventsScript
endcallback

.SkipInitialization:
endcallback

PlayersHouse2FSetUpTileDecorationsCallback:
Expand Down

0 comments on commit eff5518

Please sign in to comment.