Factor out tables into data/overworld/

Fixes #749
This commit is contained in:
Rangi 2020-07-22 15:22:58 -04:00
parent 212846af57
commit b5a7e7de3e
21 changed files with 300 additions and 441 deletions

View File

@ -1,11 +1,11 @@
; collision permissions (see data/collision_permissions.asm)
; collision permissions (see data/overworld/collision_permissions.asm)
LAND_TILE EQU $00
WATER_TILE EQU $01
WALL_TILE EQU $0f
TALK EQU $10
; collision data types (see data/tilesets/*_collision.asm)
; TileCollisionTable indexes (see data/collision_permissions.asm)
; TileCollisionTable indexes (see data/overworld/collision_permissions.asm)
COLL_FLOOR EQU $00
COLL_01 EQU $01 ; garbage
COLL_03 EQU $03 ; garbage

View File

@ -1,4 +1,4 @@
; EngineFlags indexes (see data/engine_flags.asm)
; EngineFlags indexes (see data/events/engine_flags.asm)
const_def
; wPokegearFlags
const ENGINE_RADIO_CARD

View File

@ -41,7 +41,7 @@ NUM_STRING_BUFFERS EQU const_value
const TRAINERTEXT_LOSS
; readvar/writevar/loadvar arguments
; _GetVarAction.VarActionTable indexes (see engine/overworld/variables.asm)
; VarActionTable indexes (see data/overworld/variables.asm)
const_def
const VAR_STRINGBUFFER2 ; 00
const VAR_PARTYCOUNT ; 01

View File

@ -1,4 +1,4 @@
; Tilesets indexes (see data/tilesets.asm)
; Tilesets indexes (see data/overworld/tilesets.asm)
const_def 1
const TILESET_JOHTO ; 01
const TILESET_JOHTO_MODERN ; 02

View File

@ -0,0 +1,58 @@
add_stdscript: MACRO
\1StdScript::
dba \1
ENDM
StdScripts::
add_stdscript PokecenterNurseScript
add_stdscript DifficultBookshelfScript
add_stdscript PictureBookshelfScript
add_stdscript MagazineBookshelfScript
add_stdscript TeamRocketOathScript
add_stdscript IncenseBurnerScript
add_stdscript MerchandiseShelfScript
add_stdscript TownMapScript
add_stdscript WindowScript
add_stdscript TVScript
add_stdscript HomepageScript ; unused
add_stdscript Radio1Script
add_stdscript Radio2Script
add_stdscript TrashCanScript
add_stdscript StrengthBoulderScript
add_stdscript SmashRockScript
add_stdscript PokecenterSignScript
add_stdscript MartSignScript
add_stdscript GoldenrodRocketsScript
add_stdscript RadioTowerRocketsScript
add_stdscript ElevatorButtonScript
add_stdscript DayToTextScript
add_stdscript BugContestResultsWarpScript
add_stdscript BugContestResultsScript
add_stdscript InitializeEventsScript
add_stdscript AskNumber1MScript
add_stdscript AskNumber2MScript
add_stdscript RegisteredNumberMScript
add_stdscript NumberAcceptedMScript
add_stdscript NumberDeclinedMScript
add_stdscript PhoneFullMScript
add_stdscript RematchMScript
add_stdscript GiftMScript
add_stdscript PackFullMScript
add_stdscript RematchGiftMScript
add_stdscript AskNumber1FScript
add_stdscript AskNumber2FScript
add_stdscript RegisteredNumberFScript
add_stdscript NumberAcceptedFScript
add_stdscript NumberDeclinedFScript
add_stdscript PhoneFullFScript
add_stdscript RematchFScript
add_stdscript GiftFScript
add_stdscript PackFullFScript
add_stdscript RematchGiftFScript
add_stdscript GymStatue1Script
add_stdscript GymStatue2Script
add_stdscript ReceiveItemScript
add_stdscript ReceiveTogepiEggScript
add_stdscript PCScript
add_stdscript GameCornerCoinVendorScript
add_stdscript HappinessCheckScript

View File

@ -0,0 +1,172 @@
ScriptCommandTable:
; entries correspond to *_command constants (see macros/scripts/events.asm)
dw Script_scall ; 00
dw Script_farscall ; 01
dw Script_memcall ; 02
dw Script_sjump ; 03
dw Script_farsjump ; 04
dw Script_memjump ; 05
dw Script_ifequal ; 06
dw Script_ifnotequal ; 07
dw Script_iffalse ; 08
dw Script_iftrue ; 09
dw Script_ifgreater ; 0a
dw Script_ifless ; 0b
dw Script_jumpstd ; 0c
dw Script_callstd ; 0d
dw Script_callasm ; 0e
dw Script_special ; 0f
dw Script_memcallasm ; 10
dw Script_checkmapscene ; 11
dw Script_setmapscene ; 12
dw Script_checkscene ; 13
dw Script_setscene ; 14
dw Script_setval ; 15
dw Script_addval ; 16
dw Script_random ; 17
dw Script_checkver ; 18
dw Script_readmem ; 19
dw Script_writemem ; 1a
dw Script_loadmem ; 1b
dw Script_readvar ; 1c
dw Script_writevar ; 1d
dw Script_loadvar ; 1e
dw Script_giveitem ; 1f
dw Script_takeitem ; 20
dw Script_checkitem ; 21
dw Script_givemoney ; 22
dw Script_takemoney ; 23
dw Script_checkmoney ; 24
dw Script_givecoins ; 25
dw Script_takecoins ; 26
dw Script_checkcoins ; 27
dw Script_addcellnum ; 28
dw Script_delcellnum ; 29
dw Script_checkcellnum ; 2a
dw Script_checktime ; 2b
dw Script_checkpoke ; 2c
dw Script_givepoke ; 2d
dw Script_giveegg ; 2e
dw Script_givepokemail ; 2f
dw Script_checkpokemail ; 30
dw Script_checkevent ; 31
dw Script_clearevent ; 32
dw Script_setevent ; 33
dw Script_checkflag ; 34
dw Script_clearflag ; 35
dw Script_setflag ; 36
dw Script_wildon ; 37
dw Script_wildoff ; 38
dw Script_xycompare ; 39
dw Script_warpmod ; 3a
dw Script_blackoutmod ; 3b
dw Script_warp ; 3c
dw Script_getmoney ; 3d
dw Script_getcoins ; 3e
dw Script_getnum ; 3f
dw Script_getmonname ; 40
dw Script_getitemname ; 41
dw Script_getcurlandmarkname ; 42
dw Script_gettrainername ; 43
dw Script_getstring ; 44
dw Script_itemnotify ; 45
dw Script_pocketisfull ; 46
dw Script_opentext ; 47
dw Script_refreshscreen ; 48
dw Script_closetext ; 49
dw Script_writeunusedbytebuffer ; 4a
dw Script_farwritetext ; 4b
dw Script_writetext ; 4c
dw Script_repeattext ; 4d
dw Script_yesorno ; 4e
dw Script_loadmenu ; 4f
dw Script_closewindow ; 50
dw Script_jumptextfaceplayer ; 51
dw Script_farjumptext ; 52
dw Script_jumptext ; 53
dw Script_waitbutton ; 54
dw Script_promptbutton ; 55
dw Script_pokepic ; 56
dw Script_closepokepic ; 57
dw Script__2dmenu ; 58
dw Script_verticalmenu ; 59
dw Script_loadpikachudata ; 5a
dw Script_randomwildmon ; 5b
dw Script_loadtemptrainer ; 5c
dw Script_loadwildmon ; 5d
dw Script_loadtrainer ; 5e
dw Script_startbattle ; 5f
dw Script_reloadmapafterbattle ; 60
dw Script_catchtutorial ; 61
dw Script_trainertext ; 62
dw Script_trainerflagaction ; 63
dw Script_winlosstext ; 64
dw Script_scripttalkafter ; 65
dw Script_endifjustbattled ; 66
dw Script_checkjustbattled ; 67
dw Script_setlasttalked ; 68
dw Script_applymovement ; 69
dw Script_applymovementlasttalked ; 6a
dw Script_faceplayer ; 6b
dw Script_faceobject ; 6c
dw Script_variablesprite ; 6d
dw Script_disappear ; 6e
dw Script_appear ; 6f
dw Script_follow ; 70
dw Script_stopfollow ; 71
dw Script_moveobject ; 72
dw Script_writeobjectxy ; 73
dw Script_loademote ; 74
dw Script_showemote ; 75
dw Script_turnobject ; 76
dw Script_follownotexact ; 77
dw Script_earthquake ; 78
dw Script_changemapblocks ; 79
dw Script_changeblock ; 7a
dw Script_reloadmap ; 7b
dw Script_reloadmappart ; 7c
dw Script_writecmdqueue ; 7d
dw Script_delcmdqueue ; 7e
dw Script_playmusic ; 7f
dw Script_encountermusic ; 80
dw Script_musicfadeout ; 81
dw Script_playmapmusic ; 82
dw Script_dontrestartmapmusic ; 83
dw Script_cry ; 84
dw Script_playsound ; 85
dw Script_waitsfx ; 86
dw Script_warpsound ; 87
dw Script_specialsound ; 88
dw Script_autoinput ; 89
dw Script_newloadmap ; 8a
dw Script_pause ; 8b
dw Script_deactivatefacing ; 8c
dw Script_prioritysjump ; 8d
dw Script_warpcheck ; 8e
dw Script_stopandsjump ; 8f
dw Script_endcallback ; 90
dw Script_end ; 91
dw Script_reloadend ; 92
dw Script_endall ; 93
dw Script_pokemart ; 94
dw Script_elevator ; 95
dw Script_trade ; 96
dw Script_askforphonenumber ; 97
dw Script_phonecall ; 98
dw Script_hangup ; 99
dw Script_describedecoration ; 9a
dw Script_fruittree ; 9b
dw Script_specialphonecall ; 9c
dw Script_checkphonecall ; 9d
dw Script_verbosegiveitem ; 9e
dw Script_verbosegiveitemvar ; 9f
dw Script_swarm ; a0
dw Script_halloffame ; a1
dw Script_credits ; a2
dw Script_warpfacing ; a3
dw Script_battletowertext ; a4
dw Script_getlandmarkname ; a5
dw Script_gettrainerclassname ; a6
dw Script_getname ; a7
dw Script_wait ; a8
dw Script_checksave ; a9

View File

@ -0,0 +1,33 @@
VarActionTable:
; entries correspond to VAR_* constants
; RETVAR_STRBUF2: copy [de] to wStringBuffer2
; RETVAR_ADDR_DE: return address in de
; RETVAR_EXECUTE: call function
dwb wStringBuffer2, RETVAR_STRBUF2
dwb wPartyCount, RETVAR_STRBUF2
dwb Var_BattleResult, RETVAR_EXECUTE
dwb wBattleType, RETVAR_ADDR_DE
dwb wTimeOfDay, RETVAR_STRBUF2
dwb Var_CountCaughtMons, RETVAR_EXECUTE
dwb Var_CountSeenMons, RETVAR_EXECUTE
dwb Var_CountBadges, RETVAR_EXECUTE
dwb wPlayerState, RETVAR_ADDR_DE
dwb Var_PlayerFacing, RETVAR_EXECUTE
dwb hHours, RETVAR_STRBUF2
dwb Var_DayOfWeek, RETVAR_EXECUTE
dwb wMapGroup, RETVAR_STRBUF2
dwb wMapNumber, RETVAR_STRBUF2
dwb Var_UnownCaught, RETVAR_EXECUTE
dwb wEnvironment, RETVAR_STRBUF2
dwb Var_BoxFreeSpace, RETVAR_EXECUTE
dwb wBugContestMinsRemaining, RETVAR_STRBUF2
dwb wXCoord, RETVAR_STRBUF2
dwb wYCoord, RETVAR_STRBUF2
dwb wSpecialPhoneCallID, RETVAR_STRBUF2
dwb wNrOfBeatenBattleTowerTrainers, RETVAR_STRBUF2
dwb wKurtApricornQuantity, RETVAR_STRBUF2
dwb wCurCaller, RETVAR_ADDR_DE
dwb wBlueCardBalance, RETVAR_ADDR_DE
dwb wBuenasPassword, RETVAR_ADDR_DE
dwb wKenjiBreakTimer, RETVAR_STRBUF2
dwb NULL, RETVAR_STRBUF2

View File

@ -1,6 +1,6 @@
# Event Commands
Defined in [macros/scripts/events.asm](https://github.com/pret/pokecrystal/blob/master/macros/scripts/events.asm) and [engine/overworld/scripting.asm:ScriptCommandTable](https://github.com/pret/pokecrystal/blob/master/engine/overworld/scripting.asm).
Defined in [macros/scripts/events.asm](https://github.com/pret/pokecrystal/blob/master/macros/scripts/events.asm) and [data/overworld/scripting.asm:ScriptCommandTable](https://github.com/pret/pokecrystal/blob/master/data/overworld/scripting.asm).
Until this document is filled out, the [G/S Scripting Compendium](https://hax.iimarckus.org/files/scriptingcodes_eng.htm) has descriptions for most of these commands. It was written for G/S binary hacking and not Crystal assembly hacking, so it's not 100% accurate for pokecrystal.

View File

@ -13,7 +13,6 @@ These pages are for documenting pieces of the [pokecrystal](https://github.com/p
- [event_commands.md](event_commands.md)
- [movement_commands.md](movement_commands.md)
- [text_commands.md](text_commands.md)
- [map_setup_scripts.md](map_setup_scripts.md)
## Other types of scripts

View File

@ -1,144 +0,0 @@
# Map Setup Commands
Defined in [macros/scripts/map_setup.asm](https://github.com/pret/pokecrystal/blob/master/macros/scripts/map_setup.asm) and [data/maps/setup_script_pointers.asm:MapSetupCommands](https://github.com/pret/pokecrystal/blob/master/data/maps/setup_script_pointers.asm).
## `$00`: `map_enable_lcd`
## `$01`: `map_disable_lcd`
## `$02`: `map_init_sound`
## `$03`: `map_play_music`
## `$04`: `map_restart_music`
## `$05`: `map_fade_to_music`
## `$06`: `map_fade_music_and_palettes`
## `$07`: `map_play_music_bike`
## `$08`: `map_force_music`
## `$09`: `map_fade_in_to_music`
## `$0A`: `map_load_block_data`
## `$0B`: `map_load_connection_block_data`
## `$0C`: `map_save_screen`
## `$0D`: `map_buffer_screen`
## `$0E`: `map_load_graphics`
## `$0F`: `map_load_tileset`
## `$10`: `map_load_time_of_day`
## `$11`: `map_load_palettes`
## `$12`: `map_load_wild_mon_data`
## `$13`: `map_refresh_sprites`
## `$14`: `map_handle_new`
## `$15`: `map_handle_continue`
## `$16`: `map_load_objects`
## `$17`: `map_enter_spawn_point`
## `$18`: `map_enter_connection`
## `$19`: `map_enter_warp`
## `$1A`: `map_load_attributes`
## `$1B`: `map_load_attributes_no_objects`
## `$1C`: `map_clear_bg_palettes`
## `$1D`: `map_fade_out_palettes`
## `$1E`: `map_fade_in_palettes`
## `$1F`: `map_get_screen_coords`
## `$20`: `map_get_warp_dest_coords`
## `$21`: `map_spawn_in_facing_down`
## `$22`: `map_spawn_player`
## `$23`: `map_refresh_player_coords`
## `$24`: `map_reset_player_object_action`
## `$25`: `map_skip_update_sprites`
## `$26`: `map_update_roam_mons`
## `$27`: `map_jump_roam_mons`
## `$28`: `map_fade_out_music`
## `$29`: `map_activate_anims`
## `$2A`: `map_suspend_anims`
## `$2B`: `map_apply_palettes`
## `$2C`: `map_enable_text_acceleration`
## `$2D`: `map_init_name_sign`
## `$FF`: `map_end`

View File

@ -80,4 +80,4 @@ EngineFlagAction::
ld [de], a
ret
INCLUDE "data/engine_flags.asm"
INCLUDE "data/events/engine_flags.asm"

View File

@ -13,7 +13,7 @@ Special::
rst FarCall
ret
INCLUDE "data/special_pointers.asm"
INCLUDE "data/events/special_pointers.asm"
DummySpecial_c224:
ret

View File

@ -1,61 +1,4 @@
add_stdscript: MACRO
\1StdScript::
dba \1
ENDM
StdScripts::
add_stdscript PokecenterNurseScript
add_stdscript DifficultBookshelfScript
add_stdscript PictureBookshelfScript
add_stdscript MagazineBookshelfScript
add_stdscript TeamRocketOathScript
add_stdscript IncenseBurnerScript
add_stdscript MerchandiseShelfScript
add_stdscript TownMapScript
add_stdscript WindowScript
add_stdscript TVScript
add_stdscript HomepageScript ; unused
add_stdscript Radio1Script
add_stdscript Radio2Script
add_stdscript TrashCanScript
add_stdscript StrengthBoulderScript
add_stdscript SmashRockScript
add_stdscript PokecenterSignScript
add_stdscript MartSignScript
add_stdscript GoldenrodRocketsScript
add_stdscript RadioTowerRocketsScript
add_stdscript ElevatorButtonScript
add_stdscript DayToTextScript
add_stdscript BugContestResultsWarpScript
add_stdscript BugContestResultsScript
add_stdscript InitializeEventsScript
add_stdscript AskNumber1MScript
add_stdscript AskNumber2MScript
add_stdscript RegisteredNumberMScript
add_stdscript NumberAcceptedMScript
add_stdscript NumberDeclinedMScript
add_stdscript PhoneFullMScript
add_stdscript RematchMScript
add_stdscript GiftMScript
add_stdscript PackFullMScript
add_stdscript RematchGiftMScript
add_stdscript AskNumber1FScript
add_stdscript AskNumber2FScript
add_stdscript RegisteredNumberFScript
add_stdscript NumberAcceptedFScript
add_stdscript NumberDeclinedFScript
add_stdscript PhoneFullFScript
add_stdscript RematchFScript
add_stdscript GiftFScript
add_stdscript PackFullFScript
add_stdscript RematchGiftFScript
add_stdscript GymStatue1Script
add_stdscript GymStatue2Script
add_stdscript ReceiveItemScript
add_stdscript ReceiveTogepiEggScript
add_stdscript PCScript
add_stdscript GameCornerCoinVendorScript
add_stdscript HappinessCheckScript
INCLUDE "data/events/std_scripts.asm"
PokecenterNurseScript:
; EVENT_WELCOMED_TO_POKECOM_CENTER is never set

View File

@ -61,178 +61,7 @@ RunScriptCommand:
rst JumpTable
ret
ScriptCommandTable:
; entries correspond to *_command constants (see macros/scripts/events.asm)
dw Script_scall ; 00
dw Script_farscall ; 01
dw Script_memcall ; 02
dw Script_sjump ; 03
dw Script_farsjump ; 04
dw Script_memjump ; 05
dw Script_ifequal ; 06
dw Script_ifnotequal ; 07
dw Script_iffalse ; 08
dw Script_iftrue ; 09
dw Script_ifgreater ; 0a
dw Script_ifless ; 0b
dw Script_jumpstd ; 0c
dw Script_callstd ; 0d
dw Script_callasm ; 0e
dw Script_special ; 0f
dw Script_memcallasm ; 10
dw Script_checkmapscene ; 11
dw Script_setmapscene ; 12
dw Script_checkscene ; 13
dw Script_setscene ; 14
dw Script_setval ; 15
dw Script_addval ; 16
dw Script_random ; 17
dw Script_checkver ; 18
dw Script_readmem ; 19
dw Script_writemem ; 1a
dw Script_loadmem ; 1b
dw Script_readvar ; 1c
dw Script_writevar ; 1d
dw Script_loadvar ; 1e
dw Script_giveitem ; 1f
dw Script_takeitem ; 20
dw Script_checkitem ; 21
dw Script_givemoney ; 22
dw Script_takemoney ; 23
dw Script_checkmoney ; 24
dw Script_givecoins ; 25
dw Script_takecoins ; 26
dw Script_checkcoins ; 27
dw Script_addcellnum ; 28
dw Script_delcellnum ; 29
dw Script_checkcellnum ; 2a
dw Script_checktime ; 2b
dw Script_checkpoke ; 2c
dw Script_givepoke ; 2d
dw Script_giveegg ; 2e
dw Script_givepokemail ; 2f
dw Script_checkpokemail ; 30
dw Script_checkevent ; 31
dw Script_clearevent ; 32
dw Script_setevent ; 33
dw Script_checkflag ; 34
dw Script_clearflag ; 35
dw Script_setflag ; 36
dw Script_wildon ; 37
dw Script_wildoff ; 38
dw Script_xycompare ; 39
dw Script_warpmod ; 3a
dw Script_blackoutmod ; 3b
dw Script_warp ; 3c
dw Script_getmoney ; 3d
dw Script_getcoins ; 3e
dw Script_getnum ; 3f
dw Script_getmonname ; 40
dw Script_getitemname ; 41
dw Script_getcurlandmarkname ; 42
dw Script_gettrainername ; 43
dw Script_getstring ; 44
dw Script_itemnotify ; 45
dw Script_pocketisfull ; 46
dw Script_opentext ; 47
dw Script_refreshscreen ; 48
dw Script_closetext ; 49
dw Script_writeunusedbytebuffer ; 4a
dw Script_farwritetext ; 4b
dw Script_writetext ; 4c
dw Script_repeattext ; 4d
dw Script_yesorno ; 4e
dw Script_loadmenu ; 4f
dw Script_closewindow ; 50
dw Script_jumptextfaceplayer ; 51
dw Script_farjumptext ; 52
dw Script_jumptext ; 53
dw Script_waitbutton ; 54
dw Script_promptbutton ; 55
dw Script_pokepic ; 56
dw Script_closepokepic ; 57
dw Script__2dmenu ; 58
dw Script_verticalmenu ; 59
dw Script_loadpikachudata ; 5a
dw Script_randomwildmon ; 5b
dw Script_loadtemptrainer ; 5c
dw Script_loadwildmon ; 5d
dw Script_loadtrainer ; 5e
dw Script_startbattle ; 5f
dw Script_reloadmapafterbattle ; 60
dw Script_catchtutorial ; 61
dw Script_trainertext ; 62
dw Script_trainerflagaction ; 63
dw Script_winlosstext ; 64
dw Script_scripttalkafter ; 65
dw Script_endifjustbattled ; 66
dw Script_checkjustbattled ; 67
dw Script_setlasttalked ; 68
dw Script_applymovement ; 69
dw Script_applymovementlasttalked ; 6a
dw Script_faceplayer ; 6b
dw Script_faceobject ; 6c
dw Script_variablesprite ; 6d
dw Script_disappear ; 6e
dw Script_appear ; 6f
dw Script_follow ; 70
dw Script_stopfollow ; 71
dw Script_moveobject ; 72
dw Script_writeobjectxy ; 73
dw Script_loademote ; 74
dw Script_showemote ; 75
dw Script_turnobject ; 76
dw Script_follownotexact ; 77
dw Script_earthquake ; 78
dw Script_changemapblocks ; 79
dw Script_changeblock ; 7a
dw Script_reloadmap ; 7b
dw Script_reloadmappart ; 7c
dw Script_writecmdqueue ; 7d
dw Script_delcmdqueue ; 7e
dw Script_playmusic ; 7f
dw Script_encountermusic ; 80
dw Script_musicfadeout ; 81
dw Script_playmapmusic ; 82
dw Script_dontrestartmapmusic ; 83
dw Script_cry ; 84
dw Script_playsound ; 85
dw Script_waitsfx ; 86
dw Script_warpsound ; 87
dw Script_specialsound ; 88
dw Script_autoinput ; 89
dw Script_newloadmap ; 8a
dw Script_pause ; 8b
dw Script_deactivatefacing ; 8c
dw Script_prioritysjump ; 8d
dw Script_warpcheck ; 8e
dw Script_stopandsjump ; 8f
dw Script_endcallback ; 90
dw Script_end ; 91
dw Script_reloadend ; 92
dw Script_endall ; 93
dw Script_pokemart ; 94
dw Script_elevator ; 95
dw Script_trade ; 96
dw Script_askforphonenumber ; 97
dw Script_phonecall ; 98
dw Script_hangup ; 99
dw Script_describedecoration ; 9a
dw Script_fruittree ; 9b
dw Script_specialphonecall ; 9c
dw Script_checkphonecall ; 9d
dw Script_verbosegiveitem ; 9e
dw Script_verbosegiveitemvar ; 9f
dw Script_swarm ; a0
dw Script_halloffame ; a1
dw Script_credits ; a2
dw Script_warpfacing ; a3
dw Script_battletowertext ; a4
dw Script_getlandmarkname ; a5
dw Script_gettrainerclassname ; a6
dw Script_getname ; a7
dw Script_wait ; a8
dw Script_checksave ; a9
INCLUDE "data/overworld/scripting.asm"
StartScript:
ld hl, wScriptFlags

View File

@ -6,7 +6,7 @@ _GetVarAction::
.valid
ld c, a
ld b, 0
ld hl, .VarActionTable
ld hl, VarActionTable
add hl, bc
add hl, bc
add hl, bc
@ -17,100 +17,68 @@ _GetVarAction::
ld b, [hl]
ld a, b
and RETVAR_EXECUTE
jr nz, .call
jr nz, .call_de
ld a, b
and RETVAR_ADDR_DE
ret nz
ld a, [de]
jr .loadstringbuffer2
jr LoadStringBuffer2
.call
.call_de
call _de_
ret
.loadstringbuffer2
LoadStringBuffer2:
ld de, wStringBuffer2
ld [de], a
ret
.VarActionTable:
; entries correspond to VAR_* constants
; RETVAR_STRBUF2: copy [de] to wStringBuffer2
; RETVAR_ADDR_DE: return address in de
; RETVAR_EXECUTE: call function
dwb wStringBuffer2, RETVAR_STRBUF2
dwb wPartyCount, RETVAR_STRBUF2
dwb .BattleResult, RETVAR_EXECUTE
dwb wBattleType, RETVAR_ADDR_DE
dwb wTimeOfDay, RETVAR_STRBUF2
dwb .CountCaughtMons, RETVAR_EXECUTE
dwb .CountSeenMons, RETVAR_EXECUTE
dwb .CountBadges, RETVAR_EXECUTE
dwb wPlayerState, RETVAR_ADDR_DE
dwb .PlayerFacing, RETVAR_EXECUTE
dwb hHours, RETVAR_STRBUF2
dwb .DayOfWeek, RETVAR_EXECUTE
dwb wMapGroup, RETVAR_STRBUF2
dwb wMapNumber, RETVAR_STRBUF2
dwb .UnownCaught, RETVAR_EXECUTE
dwb wEnvironment, RETVAR_STRBUF2
dwb .BoxFreeSpace, RETVAR_EXECUTE
dwb wBugContestMinsRemaining, RETVAR_STRBUF2
dwb wXCoord, RETVAR_STRBUF2
dwb wYCoord, RETVAR_STRBUF2
dwb wSpecialPhoneCallID, RETVAR_STRBUF2
dwb wNrOfBeatenBattleTowerTrainers, RETVAR_STRBUF2
dwb wKurtApricornQuantity, RETVAR_STRBUF2
dwb wCurCaller, RETVAR_ADDR_DE
dwb wBlueCardBalance, RETVAR_ADDR_DE
dwb wBuenasPassword, RETVAR_ADDR_DE
dwb wKenjiBreakTimer, RETVAR_STRBUF2
dwb NULL, RETVAR_STRBUF2
INCLUDE "data/overworld/variables.asm"
.CountCaughtMons:
Var_CountCaughtMons:
; Caught mons.
ld hl, wPokedexCaught
ld b, wEndPokedexCaught - wPokedexCaught
call CountSetBits
ld a, [wNumSetBits]
jp .loadstringbuffer2
jp LoadStringBuffer2
.CountSeenMons:
Var_CountSeenMons:
; Seen mons.
ld hl, wPokedexSeen
ld b, wEndPokedexSeen - wPokedexSeen
call CountSetBits
ld a, [wNumSetBits]
jp .loadstringbuffer2
jp LoadStringBuffer2
.CountBadges:
Var_CountBadges:
; Number of owned badges.
ld hl, wBadges
ld b, 2
call CountSetBits
ld a, [wNumSetBits]
jp .loadstringbuffer2
jp LoadStringBuffer2
.PlayerFacing:
Var_PlayerFacing:
; The direction the player is facing.
ld a, [wPlayerDirection]
and $c
rrca
rrca
jp .loadstringbuffer2
jp LoadStringBuffer2
.DayOfWeek:
Var_DayOfWeek:
; The day of the week.
call GetWeekday
jp .loadstringbuffer2
jp LoadStringBuffer2
.UnownCaught:
Var_UnownCaught:
; Number of unique Unown caught.
call .count_unown
ld a, b
jp .loadstringbuffer2
jp LoadStringBuffer2
.count_unown
.count_unown:
ld hl, wUnownDex
ld b, 0
.loop
@ -123,7 +91,7 @@ _GetVarAction::
jr c, .loop
ret
.BoxFreeSpace:
Var_BoxFreeSpace:
; Remaining slots in the current box.
ld a, BANK(sBoxCount)
call OpenSRAM
@ -133,9 +101,10 @@ _GetVarAction::
ld b, a
call CloseSRAM
ld a, b
jp .loadstringbuffer2
jp LoadStringBuffer2
.BattleResult:
Var_BattleResult:
; Outcome of the last battle.
ld a, [wBattleResult]
and $ff ^ BATTLERESULT_BITMASK
jp .loadstringbuffer2
jp LoadStringBuffer2

View File

@ -1,4 +1,4 @@
; ScriptCommandTable indexes (see engine/overworld/scripting.asm)
; ScriptCommandTable indexes (see data/overworld/scripting.asm)
const_def
const scall_command ; $00

View File

@ -203,7 +203,7 @@ SECTION "bank13", ROMX
INCLUDE "engine/tilesets/map_palettes.asm"
INCLUDE "gfx/tileset_palette_maps.asm"
INCLUDE "data/collision_permissions.asm"
INCLUDE "data/overworld/collision_permissions.asm"
INCLUDE "engine/menus/empty_sram.asm"
INCLUDE "engine/menus/savemenu_copytilemapatonce.asm"
INCLUDE "engine/events/checksave.asm"
@ -220,7 +220,7 @@ INCBIN "gfx/new_game/shrink2.2bpp.lz"
INCLUDE "engine/link/link_2.asm"
INCLUDE "engine/rtc/reset_password.asm"
INCLUDE "engine/menus/delete_save.asm"
INCLUDE "data/tilesets.asm"
INCLUDE "data/overworld/tilesets.asm"
INCLUDE "engine/smallflag.asm"
INCLUDE "engine/gfx/trademon_frontpic.asm"
INCLUDE "engine/events/pokerus/check_pokerus.asm"