pokecrystal-board/engine/scripting.asm

3265 lines
52 KiB
NASM
Raw Normal View History

; Event scripting commands.
EnableScriptMode:: ; 96c56
push af
ld a, SCRIPT_READ
ld [ScriptMode], a
pop af
ret
; 96c5e
ScriptEvents:: ; 96c5e
call StartScript
.loop
ld a, [ScriptMode]
ld hl, .modes
rst JumpTable
call CheckScript
jr nz, .loop
ret
; 96c6e
.modes ; 96c6e
dw EndScript
dw RunScriptCommand
dw WaitScriptMovement
dw WaitScript
EndScript: ; 96c76
call StopScript
ret
; 96c7a
WaitScript: ; 96c7a
call StopScript
ld hl, ScriptDelay
dec [hl]
ret nz
callba Function58b9
ld a, SCRIPT_READ
ld [ScriptMode], a
call StartScript
ret
; 96c91
WaitScriptMovement: ; 96c91
call StopScript
ld hl, VramState
bit 7, [hl]
ret nz
callba Function58b9
ld a, SCRIPT_READ
ld [ScriptMode], a
call StartScript
ret
; 96ca9
RunScriptCommand: ; 96ca9
call GetScriptByte
ld hl, ScriptCommandTable
rst JumpTable
ret
; 96cb1
2015-11-16 09:49:42 -08:00
ScriptCommandTable: ; 96cb1
2015-12-09 08:38:40 -08:00
dw Script_scall ; 00
dw Script_farscall ; 01
dw Script_ptcall ; 02
dw Script_jump ; 03
dw Script_farjump ; 04
dw Script_ptjump ; 05
dw Script_if_equal ; 06
dw Script_if_not_equal ; 07
dw Script_iffalse ; 08
dw Script_iftrue ; 09
dw Script_if_greater_than ; 0a
dw Script_if_less_than ; 0b
dw Script_jumpstd ; 0c
dw Script_callstd ; 0d
dw Script_callasm ; 0e
dw Script_special ; 0f
dw Script_ptcallasm ; 10
dw Script_checkmaptriggers ; 11
dw Script_domaptrigger ; 12
dw Script_checktriggers ; 13
dw Script_dotrigger ; 14
dw Script_writebyte ; 15
dw Script_addvar ; 16
dw Script_random ; 17
dw Script_checkver ; 18
dw Script_copybytetovar ; 19
dw Script_copyvartobyte ; 1a
dw Script_loadvar ; 1b
dw Script_checkcode ; 1c
dw Script_writevarcode ; 1d
dw Script_writecode ; 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_givepokeitem ; 2f
dw Script_checkpokeitem ; 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_readmoney ; 3d
dw Script_readcoins ; 3e
dw Script_RAM2MEM ; 3f
dw Script_pokenamemem ; 40
dw Script_itemtotext ; 41
dw Script_mapnametotext ; 42
dw Script_trainertotext ; 43
dw Script_stringtotext ; 44
dw Script_itemnotify ; 45
dw Script_pocketisfull ; 46
2015-12-09 15:25:44 -08:00
dw Script_textbox ; 47
2015-12-09 08:38:40 -08:00
dw Script_refreshscreen ; 48
dw Script_closetext ; 49
dw Script_loadbytec2cf ; 4a
dw Script_farwritetext ; 4b
dw Script_writetext ; 4c
dw Script_repeattext ; 4d
dw Script_yesorno ; 4e
dw Script_loadmenudata ; 4f
dw Script_writebackup ; 50
dw Script_jumptextfaceplayer ; 51
IF _CRYSTAL
2015-12-09 08:38:40 -08:00
dw Script_farjumptext ; 52
ENDC
2015-12-09 08:38:40 -08:00
dw Script_jumptext ; 53
dw Script_waitbutton ; 54
dw Script_buttonsound ; 55
dw Script_pokepic ; 56
dw Script_closepokepic ; 57
dw Script_interpretmenu ; 58
dw Script_interpretmenu2 ; 59
dw Script_loadpikachudata ; 5a
dw Script_randomwildmon ; 5b
dw Script_loadmemtrainer ; 5c
dw Script_loadwildmon ; 5d
dw Script_loadtrainer ; 5e
dw Script_startbattle ; 5f
dw Script_returnafterbattle ; 60
dw Script_catchtutorial ; 61
dw Script_trainertext ; 62
dw Script_trainerflagaction ; 63
dw Script_winlosstext ; 64
dw Script_scripttalkafter ; 65
dw Script_end_if_just_battled ; 66
dw Script_check_just_battled ; 67
dw Script_setlasttalked ; 68
dw Script_applymovement ; 69
dw Script_applymovement2 ; 6a
dw Script_faceplayer ; 6b
dw Script_faceperson ; 6c
dw Script_variablesprite ; 6d
dw Script_disappear ; 6e
dw Script_appear ; 6f
dw Script_follow ; 70
dw Script_stopfollow ; 71
dw Script_moveperson ; 72
dw Script_writepersonxy ; 73
dw Script_loademote ; 74
dw Script_showemote ; 75
dw Script_spriteface ; 76
dw Script_follownotexact ; 77
dw Script_earthquake ; 78
dw Script_changemap ; 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_reloadmapmusic ; 83
dw Script_cry ; 84
dw Script_playsound ; 85
dw Script_waitsfx ; 86
dw Script_warpsound ; 87
dw Script_specialsound ; 88
dw Script_passtoengine ; 89
dw Script_newloadmap ; 8a
dw Script_pause ; 8b
dw Script_deactivatefacing ; 8c
dw Script_priorityjump ; 8d
dw Script_warpcheck ; 8e
dw Script_ptpriorityjump ; 8f
dw Script_return ; 90
dw Script_end ; 91
dw Script_reloadandreturn ; 92
dw Script_end_all ; 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_verbosegiveitem2 ; 9f
dw Script_swarm ; a0
dw Script_halloffame ; a1
dw Script_credits ; a2
dw Script_warpfacing ; a3
dw Script_battletowertext ; a4
dw Script_landmarktotext ; a5
dw Script_trainerclassname ; a6
dw Script_name ; a7
dw Script_wait ; a8
dw Script_check_save ; a9
2015-11-16 09:49:42 -08:00
; 96e05
2015-11-16 09:49:42 -08:00
StartScript: ; 96e05
2013-07-04 02:37:20 -07:00
ld hl, ScriptFlags
set SCRIPT_RUNNING, [hl]
ret
2015-11-16 09:49:42 -08:00
; 96e0b
2015-11-16 09:49:42 -08:00
CheckScript: ; 96e0b
2013-07-04 02:37:20 -07:00
ld hl, ScriptFlags
bit SCRIPT_RUNNING, [hl]
ret
2015-11-16 09:49:42 -08:00
; 96e11
2015-11-16 09:49:42 -08:00
StopScript: ; 96e11
2013-07-04 02:37:20 -07:00
ld hl, ScriptFlags
res SCRIPT_RUNNING, [hl]
ret
2015-11-16 09:49:42 -08:00
; 96e17
2015-11-16 09:49:42 -08:00
Script_callasm: ; 96e17
; script command 0xe
; parameters:
; asm (AsmPointerParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld b, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
ld a, b
2013-10-01 18:55:40 -07:00
rst FarCall
ret
2015-11-16 09:49:42 -08:00
; 96e26
2015-11-16 09:49:42 -08:00
Script_special: ; 96e26
; script command 0xf
; parameters:
; predefined_script (MultiByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
callba Special
ret
2015-11-16 09:49:42 -08:00
; 96e35
2015-11-16 09:49:42 -08:00
Script_ptcallasm: ; 96e35
; script command 0x10
; parameters:
; asm (PointerToAsmPointerParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
ld b, [hl]
inc hl
ld a, [hli]
ld h, [hl]
ld l, a
ld a, b
2013-10-01 18:55:40 -07:00
rst FarCall
ret
2015-11-16 09:49:42 -08:00
; 96e45
2015-11-16 09:49:42 -08:00
Script_jumptextfaceplayer: ; 96e45
; script command 0x51
; parameters:
; text_pointer (RawTextPointerLabelParam)
ld a, [ScriptBank]
ld [wScriptTextBank], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [wScriptTextAddr], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [wScriptTextAddr + 1], a
ld b, BANK(JumpTextFacePlayerScript)
ld hl, JumpTextFacePlayerScript
2013-05-03 11:27:24 -07:00
jp ScriptJump
2015-11-16 09:49:42 -08:00
; 96e5f
2015-11-16 09:49:42 -08:00
Script_jumptext: ; 96e5f
; script command 0x53
; parameters:
; text_pointer (RawTextPointerLabelParam)
ld a, [ScriptBank]
ld [wScriptTextBank], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [wScriptTextAddr], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [wScriptTextAddr + 1], a
ld b, BANK(JumpTextScript)
ld hl, JumpTextScript
2013-05-03 11:27:24 -07:00
jp ScriptJump
2015-11-16 09:49:42 -08:00
; 96e79
2015-11-16 09:49:42 -08:00
JumpTextFacePlayerScript: ; 96e79
faceplayer
2015-11-16 09:49:42 -08:00
JumpTextScript: ; 96e7a
2015-12-09 15:25:44 -08:00
opentext
repeattext -1, -1
2015-11-25 07:16:29 -08:00
waitbutton
closetext
end
2015-11-16 09:49:42 -08:00
; 96e81
IF _CRYSTAL
2015-11-16 09:49:42 -08:00
Script_farjumptext: ; 96e81
; script command 0x52
; parameters:
; text_pointer (PointerLabelBeforeBank)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [wScriptTextBank], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [wScriptTextAddr], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [wScriptTextAddr + 1], a
ld b, BANK(JumpTextScript)
ld hl, JumpTextScript
2013-05-03 11:27:24 -07:00
jp ScriptJump
2015-11-16 09:49:42 -08:00
; 96e9b
ENDC
2015-11-16 09:49:42 -08:00
Script_writetext: ; 96e9b
; script command 0x4c
; parameters:
; text_pointer (RawTextPointerLabelParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
ld a, [ScriptBank]
ld b, a
call MapTextbox
ret
2015-11-16 09:49:42 -08:00
; 96eab
2015-11-16 09:49:42 -08:00
Script_farwritetext: ; 96eab
; script command 0x4b
; parameters:
; text_pointer (PointerLabelBeforeBank)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld b, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
call MapTextbox
ret
2015-11-16 09:49:42 -08:00
; 96ebb
2015-11-16 09:49:42 -08:00
Script_repeattext: ; 96ebb
; script command 0x4d
; parameters:
; byte (SingleByteParam)
; byte (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
cp -1
2015-11-16 08:53:26 -08:00
jr nz, .done
ld a, l
cp -1
2015-11-16 08:53:26 -08:00
jr nz, .done
ld hl, wScriptTextBank
ld a, [hli]
ld b, a
ld a, [hli]
ld h, [hl]
ld l, a
call MapTextbox
ret
.done
ret
2015-11-16 09:49:42 -08:00
; 96ed9
2015-11-25 07:16:29 -08:00
Script_waitbutton: ; 96ed9
; script command 0x54
2015-11-25 07:16:29 -08:00
jp WaitButton
2015-11-16 09:49:42 -08:00
; 96edc
2015-11-29 19:29:45 -08:00
Script_buttonsound: ; 96edc
; script command 0x55
2015-11-09 13:41:09 -08:00
ld a, [hOAMUpdate]
push af
ld a, $1
2015-11-09 13:41:09 -08:00
ld [hOAMUpdate], a
call WaitBGMap
2015-11-29 19:29:45 -08:00
call ButtonSound
pop af
2015-11-09 13:41:09 -08:00
ld [hOAMUpdate], a
ret
2015-11-16 09:49:42 -08:00
; 96eed
2015-11-16 09:49:42 -08:00
Script_yesorno: ; 96eed
; script command 0x4e
2013-12-03 23:49:12 -08:00
call YesNoBox
2015-11-25 07:16:29 -08:00
ld a, FALSE
2015-11-16 08:53:26 -08:00
jr c, .no
2015-11-25 07:16:29 -08:00
ld a, TRUE
.no
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 96efa
2015-11-16 09:49:42 -08:00
Script_loadmenudata: ; 96efa
; script command 0x4f
; parameters:
; data (MenuDataPointerParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
2015-05-18 01:07:28 -07:00
ld de, LoadMenuDataHeader
ld a, [ScriptBank]
call Call_a_de
call UpdateSprites
ret
2015-11-16 09:49:42 -08:00
; 96f0f
2015-11-16 09:49:42 -08:00
Script_writebackup: ; 96f0f
; script command 0x50
call WriteBackup
call UpdateSprites
ret
2015-11-16 09:49:42 -08:00
; 96f16
2015-11-16 09:49:42 -08:00
Script_pokepic: ; 96f16
; script command 0x56
; parameters:
; pokemon (PokemonParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
and a
2014-05-21 13:21:46 -07:00
jr nz, .ok
ld a, [ScriptVar]
.ok
ld [CurPartySpecies], a
callba Pokepic
ret
2015-11-16 09:49:42 -08:00
; 96f29
2015-11-25 07:16:29 -08:00
Script_closepokepic: ; 96f29
; script command 0x57
2015-11-25 07:16:29 -08:00
callba ClosePokepic
ret
2015-11-16 09:49:42 -08:00
; 96f30
2015-11-16 09:49:42 -08:00
Script_interpretmenu2: ; 96f30
; script command 0x59
ld a, [ScriptBank]
ld hl, InterpretMenu2
2013-10-01 18:55:40 -07:00
rst FarCall
2015-11-04 11:02:11 -08:00
ld a, [MenuSelection2]
2014-05-21 13:21:46 -07:00
jr nc, .ok
xor a
2014-05-21 13:21:46 -07:00
.ok
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 96f41
2015-11-16 09:49:42 -08:00
Script_interpretmenu: ; 96f41
; script command 0x58
ld a, [ScriptBank]
ld hl, InterpretMenu
2013-10-01 18:55:40 -07:00
rst FarCall
2015-11-01 09:44:30 -08:00
ld a, [wMenuCursorBuffer]
2014-05-21 13:21:46 -07:00
jr nc, .ok
xor a
2014-05-21 13:21:46 -07:00
.ok
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 96f52
2015-11-16 09:49:42 -08:00
Script_battletowertext: ; 96f52
; script command 0xa4
; parameters:
; pointer (PointerLabelBeforeBank)
; memory (SingleByteParam)
call SetUpTextBox
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld c, a
2015-11-03 19:35:36 -08:00
callba BattleTowerText
ret
2015-11-16 09:49:42 -08:00
; 96f60
2015-11-16 09:49:42 -08:00
Script_verbosegiveitem: ; 96f60
; script command 0x9e
; parameters:
; item (ItemLabelByte)
; quantity (DecimalParam)
call Script_giveitem
call CurItemName
ld de, StringBuffer1
ld a, 1
call CopyConvertedText
ld b, BANK(GiveItemScript)
ld de, GiveItemScript
jp ScriptCall
2015-11-16 09:49:42 -08:00
; 96f76
2015-11-16 08:53:26 -08:00
ret_96f76: ; 96f76
ret
; 96f77
GiveItemScript: ; 96f77
2015-11-16 08:53:26 -08:00
callasm ret_96f76
2015-01-20 00:01:23 -08:00
writetext ReceivedItemText
iffalse .Full
2015-11-25 07:16:29 -08:00
waitsfx
specialsound
2015-11-25 07:16:29 -08:00
waitbutton
itemnotify
end
.Full
2015-11-29 19:29:45 -08:00
buttonsound
pocketisfull
end
; 96f89
ReceivedItemText: ; 96f89
2013-12-01 14:54:09 -08:00
text_jump UnknownText_0x1c4719
db "@"
; 96f8e
2015-11-16 09:49:42 -08:00
Script_verbosegiveitem2: ; 96f8e
; script command 0x9f
; parameters:
; item (ItemLabelByte)
; var (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
cp -1
2014-05-21 13:21:46 -07:00
jr nz, .ok
ld a, [ScriptVar]
.ok
ld [CurItem], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetVarAction
ld a, [de]
2015-11-01 15:13:31 -08:00
ld [wItemQuantityChangeBuffer], a
2014-05-21 13:21:46 -07:00
ld hl, NumItems
call ReceiveItem
2015-11-25 07:16:29 -08:00
ld a, TRUE
2014-05-21 13:21:46 -07:00
jr c, .ok2
xor a
2014-05-21 13:21:46 -07:00
.ok2
ld [ScriptVar], a
call CurItemName
ld de, StringBuffer1
ld a, 1
call CopyConvertedText
ld b, BANK(GiveItemScript)
ld de, GiveItemScript
jp ScriptCall
2015-11-16 09:49:42 -08:00
; 96fc6
2015-11-16 09:49:42 -08:00
Script_itemnotify: ; 96fc6
; script command 0x45
call GetPocketName
call CurItemName
ld b, BANK(PutItemInPocketText)
ld hl, PutItemInPocketText
call MapTextbox
ret
2015-11-16 09:49:42 -08:00
; 96fd5
2015-11-16 09:49:42 -08:00
Script_pocketisfull: ; 96fd5
; script command 0x46
call GetPocketName
call CurItemName
ld b, BANK(PocketIsFullText)
ld hl, PocketIsFullText
call MapTextbox
ret
2015-11-16 09:49:42 -08:00
; 96fe4
2015-11-16 09:49:42 -08:00
Script_specialsound: ; 96fe4
; script command 0x88
2013-10-01 18:20:48 -07:00
callba CheckItemPocket
2015-10-24 07:34:19 -07:00
ld a, [wItemAttributeParamBuffer]
2013-05-02 17:27:39 -07:00
cp TM_HM
ld de, SFX_GET_TM
jr z, .play
ld de, SFX_ITEM
.play
2013-10-08 10:10:36 -07:00
call PlaySFX
2013-05-02 17:27:39 -07:00
call WaitSFX
ret
2015-11-16 09:49:42 -08:00
; 96ffe
GetPocketName: ; 96ffe
callba CheckItemPocket
2015-10-24 07:34:19 -07:00
ld a, [wItemAttributeParamBuffer]
dec a
ld hl, .Pockets
and 3
add a
ld e, a
ld d, 0
add hl, de
ld a, [hli]
ld d, [hl]
ld e, a
ld hl, StringBuffer3
call CopyName2
ret
.Pockets
dw .Item
dw .Key
dw .Ball
dw .TM
.Item
db "ITEM POCKET@"
.Key
db "KEY POCKET@"
.Ball
db "BALL POCKET@"
.TM
db "TM POCKET@"
; 97051
CurItemName: ; 97051
ld a, [CurItem]
2015-02-10 15:14:21 -08:00
ld [wd265], a
call GetItemName
ret
; 9705b
PutItemInPocketText: ; 9705b
2013-12-01 14:54:09 -08:00
text_jump UnknownText_0x1c472c
db "@"
; 97060
PocketIsFullText: ; 97060
2013-12-01 14:54:09 -08:00
text_jump UnknownText_0x1c474b
db "@"
; 97065
2015-11-16 09:49:42 -08:00
Script_pokemart: ; 97065
; script command 0x94
; parameters:
; dialog_id (SingleByteParam)
; mart_id (MultiByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld c, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
ld a, [ScriptBank]
ld b, a
2013-10-01 18:20:48 -07:00
callba OpenMartDialog
ret
2015-11-16 09:49:42 -08:00
; 9707c
2015-11-16 09:49:42 -08:00
Script_elevator: ; 9707c
; script command 0x95
; parameters:
; floor_list_pointer (PointerLabelParam)
xor a
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
ld a, [ScriptBank]
ld b, a
callba Elevator
ret c
2015-11-25 07:16:29 -08:00
ld a, TRUE
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97099
2015-11-16 09:49:42 -08:00
Script_trade: ; 97099
; script command 0x96
; parameters:
; trade_id (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-12-27 19:20:24 -08:00
callba NPCTrade
ret
2015-11-16 09:49:42 -08:00
; 970a4
2015-11-16 09:49:42 -08:00
Script_phonecall: ; 970a4
; script command 0x98
; parameters:
; caller_name (RawTextPointerLabelParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
ld a, [ScriptBank]
ld b, a
callba PhoneCall
ret
2015-11-16 09:49:42 -08:00
; 970b7
2015-11-16 09:49:42 -08:00
Script_hangup: ; 970b7
; script command 0x99
callba HangUp
ret
2015-11-16 09:49:42 -08:00
; 970be
2015-11-16 09:49:42 -08:00
Script_askforphonenumber: ; 970be
; script command 0x97
; parameters:
; number (SingleByteParam)
2013-12-03 23:49:12 -08:00
call YesNoBox
2015-11-16 08:53:26 -08:00
jr c, .refused
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld c, a
callba AddPhoneNumber
2015-11-16 08:53:26 -08:00
jr c, .phonefull
xor a
2015-11-16 08:53:26 -08:00
jr .done
.phonefull
ld a, 1
2015-11-16 08:53:26 -08:00
jr .done
.refused
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld a, 2
.done
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 970df
2015-11-16 09:49:42 -08:00
Script_describedecoration: ; 970df
; script command 0x9a
; parameters:
; byte (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld b, a
callba DescribeDecoration
ld h, d
ld l, e
2013-05-03 11:27:24 -07:00
jp ScriptJump
2015-11-16 09:49:42 -08:00
; 970ee
2015-11-16 09:49:42 -08:00
Script_fruittree: ; 970ee
; script command 0x9b
; parameters:
; tree_id (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2013-05-03 12:40:45 -07:00
ld [CurFruitTree], a
ld b, BANK(FruitTreeScript)
ld hl, FruitTreeScript
2013-05-03 11:27:24 -07:00
jp ScriptJump
2015-11-16 09:49:42 -08:00
; 970fc
2015-12-09 08:38:40 -08:00
Script_swarm: ; 970fc
; script command 0xa0
; parameters:
; flag (SingleByteParam)
; map_group (MapGroupParam)
; map_id (MapIdParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld c, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2015-12-09 08:38:40 -08:00
callba StoreSwarmMapIndices
ret
2015-11-16 09:49:42 -08:00
; 9710f
2015-11-16 09:49:42 -08:00
Script_trainertext: ; 9710f
; script command 0x62
; parameters:
; which_text (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld c, a
ld b, 0
2015-02-10 15:14:21 -08:00
ld hl, WalkingX
2015-07-20 19:18:18 -07:00
rept 2
add hl, bc
2015-07-20 19:18:18 -07:00
endr
ld a, [hli]
ld h, [hl]
ld l, a
2015-02-10 15:14:21 -08:00
ld a, [EngineBuffer1]
ld b, a
call MapTextbox
ret
2015-11-16 09:49:42 -08:00
; 97125
2015-11-16 09:49:42 -08:00
Script_scripttalkafter: ; 97125
; script command 0x65
2015-02-10 15:14:21 -08:00
ld hl, wd04b
ld a, [hli]
ld h, [hl]
ld l, a
2015-02-10 15:14:21 -08:00
ld a, [EngineBuffer1]
ld b, a
2013-05-03 11:27:24 -07:00
jp ScriptJump
2015-11-16 09:49:42 -08:00
; 97132
2015-11-25 07:16:29 -08:00
Script_trainerflagaction: ; 97132
; script command 0x63
; parameters:
; action (SingleByteParam)
xor a
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
2015-02-10 15:14:21 -08:00
ld hl, wd041
ld e, [hl]
inc hl
ld d, [hl]
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld b, a
2013-08-23 12:48:26 -07:00
call EventFlagAction
ld a, c
and a
ret z
2015-11-25 07:16:29 -08:00
ld a, TRUE
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 9714c
2015-11-16 09:49:42 -08:00
Script_winlosstext: ; 9714c
; script command 0x64
; parameters:
; win_text_pointer (TextPointerLabelParam)
; loss_text_pointer (TextPointerLabelParam)
ld hl, wWinTextPointer ; d047
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [hli], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [hli], a
ld hl, wLossTextPointer ; d049; this is unnecessary
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [hli], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [hli], a
ret
2015-11-16 09:49:42 -08:00
; 97163
2015-11-25 07:16:29 -08:00
Script_end_if_just_battled: ; 97163
; script command 0x66
2015-11-25 07:16:29 -08:00
ld a, [wRunningTrainerBattleScript]
and a
ret z
2013-07-04 02:37:20 -07:00
jp Script_end
2015-11-16 09:49:42 -08:00
; 9716b
2015-11-25 07:16:29 -08:00
Script_check_just_battled: ; 9716b
; script command 0x67
2015-11-25 07:16:29 -08:00
ld a, TRUE
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
2015-11-25 07:16:29 -08:00
ld a, [wRunningTrainerBattleScript]
and a
ret nz
xor a
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 9717a
2015-11-25 07:16:29 -08:00
Script_encountermusic: ; 9717a
; script command 0x80
2015-02-10 15:14:21 -08:00
ld a, [OtherTrainerClass]
ld e, a
2013-10-01 18:20:48 -07:00
callba PlayTrainerEncounterMusic
ret
2015-11-16 09:49:42 -08:00
; 97185
2015-11-16 09:49:42 -08:00
Script_playmapmusic: ; 97185
; script command 0x82
2014-05-21 13:21:46 -07:00
call PlayMapMusic
ret
2015-11-16 09:49:42 -08:00
; 97189
2015-11-16 09:49:42 -08:00
Script_playmusic: ; 97189
; script command 0x7f
; parameters:
; music_pointer (MultiByteParam)
2014-05-21 13:21:46 -07:00
ld de, MUSIC_NONE
2013-10-08 10:21:15 -07:00
call PlayMusic
xor a
2015-02-10 15:14:21 -08:00
ld [MusicFade], a
call MaxVolume
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
2013-10-08 10:21:15 -07:00
call PlayMusic
ret
2015-11-16 09:49:42 -08:00
; 971a2
2015-11-16 09:49:42 -08:00
Script_musicfadeout: ; 971a2
; script command 0x81
; parameters:
; music (MultiByteParam)
; fadetime (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld [MusicFadeID], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld [MusicFadeID + 1], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
and $7f
2015-02-10 15:14:21 -08:00
ld [MusicFade], a
ret
2015-11-16 09:49:42 -08:00
; 971b7
2015-11-16 09:49:42 -08:00
Script_playsound: ; 971b7
; script command 0x85
; parameters:
; sound_pointer (MultiByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
2013-10-08 10:10:36 -07:00
call PlaySFX
ret
2015-11-16 09:49:42 -08:00
; 971c3
2015-11-25 07:16:29 -08:00
Script_waitsfx: ; 971c3
; script command 0x86
2013-05-02 17:27:39 -07:00
call WaitSFX
ret
2015-11-16 09:49:42 -08:00
; 971c7
2015-11-16 09:49:42 -08:00
Script_warpsound: ; 971c7
; script command 0x87
2013-10-01 18:20:48 -07:00
callba Function14a07
2013-10-08 10:10:36 -07:00
call PlaySFX
ret
2015-11-16 09:49:42 -08:00
; 971d1
2015-11-16 09:49:42 -08:00
Script_cry: ; 971d1
; script command 0x84
; parameters:
; cry_id (MultiByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
push af
2013-02-28 13:36:21 -08:00
call GetScriptByte
pop af
and a
2014-07-18 10:25:03 -07:00
jr nz, .ok
2014-05-21 13:21:46 -07:00
ld a, [ScriptVar]
2014-07-18 10:25:03 -07:00
.ok
call PlayCry
ret
2015-11-16 09:49:42 -08:00
; 971e3
2015-11-16 09:49:42 -08:00
GetScriptPerson: ; 971e3
and a
ret z
cp LAST_TALKED
ret z
dec a
ret
2015-11-16 09:49:42 -08:00
; 971ea
2015-11-16 09:49:42 -08:00
Script_setlasttalked: ; 971ea
; script command 0x68
; parameters:
; person (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptPerson
ld [hLastTalked], a
ret
2015-11-16 09:49:42 -08:00
; 971f3
2015-11-16 09:49:42 -08:00
Script_applymovement: ; 971f3
; script command 0x69
; parameters:
; person (SingleByteParam)
; data (MovementPointerLabelParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptPerson
ld c, a
; 971fa
ApplyMovement: ; 971fa
push bc
ld a, c
callba SetFlagsForMovement_1
pop bc
2015-11-11 20:38:57 -08:00
push bc
call SetFlagsForMovement_2
pop bc
2015-11-11 20:38:57 -08:00
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
ld a, [ScriptBank]
ld b, a
call GetMovementData
ret c
2015-11-11 20:38:57 -08:00
2013-07-04 02:37:20 -07:00
ld a, SCRIPT_WAIT_MOVEMENT
ld [ScriptMode], a
call StopScript
ret
2015-11-16 09:49:42 -08:00
; 97221
2015-11-16 09:49:42 -08:00
SetFlagsForMovement_2: ; 97221
callba _SetFlagsForMovement_2
ret
2015-11-16 09:49:42 -08:00
; 97228
2015-11-16 09:49:42 -08:00
Script_applymovement2: ; 97228
2015-11-11 20:38:57 -08:00
; apply movement to last talked
; script command 0x6a
; parameters:
; data (MovementPointerLabelParam)
ld a, [hLastTalked]
ld c, a
jp ApplyMovement
2015-11-16 09:49:42 -08:00
; 9722e
2015-11-16 09:49:42 -08:00
Script_faceplayer: ; 9722e
; script command 0x6b
ld a, [hLastTalked]
and a
ret z
ld d, $0
ld a, [hLastTalked]
ld e, a
callba GetRelativeFacing
ld a, d
2015-07-20 19:18:18 -07:00
rept 2
add a
2015-07-20 19:18:18 -07:00
endr
ld e, a
ld a, [hLastTalked]
ld d, a
call ApplyPersonFacing
ret
2015-11-16 09:49:42 -08:00
; 97248
2015-11-16 09:49:42 -08:00
Script_faceperson: ; 97248
; script command 0x6c
; parameters:
; person1 (SingleByteParam)
; person2 (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptPerson
cp LAST_TALKED
jr c, .ok
ld a, [hLastTalked]
.ok
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptPerson
cp LAST_TALKED
jr nz, .ok2
ld a, [hLastTalked]
.ok2
ld d, a
push de
callba GetRelativeFacing
pop bc
ret c
ld a, d
2015-07-20 19:18:18 -07:00
rept 2
add a
2015-07-20 19:18:18 -07:00
endr
ld e, a
ld d, c
call ApplyPersonFacing
ret
2015-11-16 09:49:42 -08:00
; 97274
2015-11-16 09:49:42 -08:00
Script_spriteface: ; 97274
; script command 0x76
; parameters:
; person (SingleByteParam)
; facing (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptPerson
cp LAST_TALKED
jr nz, .ok
ld a, [hLastTalked]
.ok
ld d, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-07-20 19:18:18 -07:00
rept 2
add a
2015-07-20 19:18:18 -07:00
endr
ld e, a
call ApplyPersonFacing
ret
2015-11-16 09:49:42 -08:00
; 9728b
2015-11-16 09:49:42 -08:00
ApplyPersonFacing: ; 9728b
ld a, d
push de
2015-11-02 08:15:32 -08:00
call CheckObjectVisibility
2015-11-16 08:53:26 -08:00
jr c, .not_visible
ld hl, OBJECT_SPRITE
add hl, bc
ld a, [hl]
push bc
2015-11-04 17:20:14 -08:00
call DoesSpriteHaveFacings
pop bc
2015-11-04 17:20:14 -08:00
jr c, .not_visible ; STILL_SPRITE
ld hl, OBJECT_FLAGS1
add hl, bc
bit 2, [hl]
2015-11-16 08:53:26 -08:00
jr nz, .not_visible
pop de
ld a, e
call SetSpriteDirection
2015-02-10 15:14:21 -08:00
ld hl, VramState
bit 6, [hl]
2015-11-16 08:53:26 -08:00
jr nz, .text_state
2015-11-02 09:54:27 -08:00
call .DisableTextTiles
.text_state
call UpdateSprites
ret
2015-11-02 09:54:27 -08:00
.not_visible
pop de
scf
ret
2015-11-16 09:49:42 -08:00
; 972bc
2015-11-16 09:49:42 -08:00
.DisableTextTiles: ; 972bc
2015-11-05 11:06:03 -08:00
call LoadMapPart
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
2015-11-02 09:54:27 -08:00
.loop
res 7, [hl]
inc hl
dec bc
ld a, b
or c
2015-11-16 08:53:26 -08:00
jr nz, .loop
ret
2015-11-16 09:49:42 -08:00
; 972ce
2015-11-16 09:49:42 -08:00
Script_variablesprite: ; 972ce
; script command 0x6d
; parameters:
; byte (SingleByteParam)
; sprite (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
ld d, $0
2015-02-10 15:14:21 -08:00
ld hl, VariableSprites
add hl, de
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [hl], a
ret
2015-11-16 09:49:42 -08:00
; 972dd
2015-11-16 09:49:42 -08:00
Script_appear: ; 972dd
; script command 0x6f
; parameters:
; person (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptPerson
call _CopyObjectStruct
2015-11-02 08:15:32 -08:00
ld a, [hMapObjectIndexBuffer]
ld b, 0 ; clear
call ApplyEventActionAppearDisappear
ret
2015-11-16 09:49:42 -08:00
; 972ee
2015-11-16 09:49:42 -08:00
Script_disappear: ; 972ee
; script command 0x6e
; parameters:
; person (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptPerson
cp LAST_TALKED
jr nz, .ok
ld a, [hLastTalked]
.ok
call DeleteObjectStruct
2015-11-02 08:15:32 -08:00
ld a, [hMapObjectIndexBuffer]
ld b, 1 ; set
call ApplyEventActionAppearDisappear
2015-11-15 18:28:15 -08:00
callba _UpdateSprites
ret
2015-11-16 09:49:42 -08:00
; 9730b
2015-11-16 09:49:42 -08:00
ApplyEventActionAppearDisappear: ; 9730b
push bc
call GetMapObject
ld hl, MAPOBJECT_EVENT_FLAG
add hl, bc
pop bc
ld e, [hl]
inc hl
ld d, [hl]
ld a, -1
cp e
2015-11-16 08:53:26 -08:00
jr nz, .okay
cp d
2015-11-16 08:53:26 -08:00
jr nz, .okay
xor a
ret
.okay
2013-08-23 12:48:26 -07:00
call EventFlagAction
ret
2015-11-16 09:49:42 -08:00
; 97325
2015-11-16 09:49:42 -08:00
Script_follow: ; 97325
; script command 0x70
; parameters:
; person2 (SingleByteParam)
; person1 (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptPerson
ld b, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptPerson
ld c, a
2015-11-02 08:15:32 -08:00
callba StartFollow
ret
2015-11-16 09:49:42 -08:00
; 9733a
2015-11-16 09:49:42 -08:00
Script_stopfollow: ; 9733a
; script command 0x71
2015-11-02 08:15:32 -08:00
callba StopFollow
ret
2015-11-16 09:49:42 -08:00
; 97341
2015-11-16 09:49:42 -08:00
Script_moveperson: ; 97341
; script command 0x72
; parameters:
; person (SingleByteParam)
; x (SingleByteParam)
; y (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptPerson
ld b, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-10-24 07:34:19 -07:00
add 4
ld d, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-10-24 07:34:19 -07:00
add 4
ld e, a
2015-10-24 07:34:19 -07:00
callba CopyDECoordsToMapObject
ret
2015-11-16 09:49:42 -08:00
; 9735b
2015-11-16 09:49:42 -08:00
Script_writepersonxy: ; 9735b
; script command 0x73
; parameters:
; person (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptPerson
cp LAST_TALKED
jr nz, .ok
ld a, [hLastTalked]
.ok
ld b, a
2015-11-08 10:27:26 -08:00
callba WritePersonXY
ret
2015-11-16 09:49:42 -08:00
; 9736f
2015-11-16 09:49:42 -08:00
Script_follownotexact: ; 9736f
; script command 0x77
; parameters:
; person2 (SingleByteParam)
; person1 (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptPerson
ld b, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptPerson
ld c, a
2015-11-08 10:27:26 -08:00
callba FollowNotExact
ret
2015-11-16 09:49:42 -08:00
; 97384
2015-11-16 09:49:42 -08:00
Script_loademote: ; 97384
; script command 0x74
; parameters:
; bubble (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-10-24 07:34:19 -07:00
cp -1
2015-11-16 08:53:26 -08:00
jr nz, .not_var_emote
2014-05-21 13:21:46 -07:00
ld a, [ScriptVar]
2015-10-24 07:34:19 -07:00
.not_var_emote
ld c, a
callba LoadEmote
ret
2015-11-16 09:49:42 -08:00
; 97396
2015-11-16 09:49:42 -08:00
Script_showemote: ; 97396
; script command 0x75
; parameters:
; bubble (SingleByteParam)
; person (SingleByteParam)
; time (DecimalParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptPerson
cp LAST_TALKED
jr z, .ok
ld [hLastTalked], a
.ok
2013-02-28 13:36:21 -08:00
call GetScriptByte
2013-07-04 02:37:20 -07:00
ld [ScriptDelay], a
ld b, BANK(ShowEmoteScript)
ld de, ShowEmoteScript
jp ScriptCall
2015-11-16 09:49:42 -08:00
; 973b6
ShowEmoteScript: ; 973b6
2015-10-31 18:05:02 -07:00
loademote EMOTE_MEM
applymovement2 .Show
pause 0
applymovement2 .Hide
end
.Show
show_emote
2015-11-11 20:38:57 -08:00
step_sleep_1
step_end
.Hide
hide_emote
2015-11-11 20:38:57 -08:00
step_sleep_1
step_end
; 973c7
2015-11-16 09:49:42 -08:00
Script_earthquake: ; 973c7
; script command 0x78
; parameters:
; param (DecimalParam)
ld hl, EarthquakeMovement
2015-02-10 15:14:21 -08:00
ld de, wd002
ld bc, EarthquakeMovementEnd - EarthquakeMovement
call CopyBytes
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-02-10 15:14:21 -08:00
ld [wd003], a
and (1 << 6) - 1
2015-02-10 15:14:21 -08:00
ld [wd005], a
2015-10-24 07:34:19 -07:00
ld b, BANK(.script)
ld de, .script
jp ScriptCall
2015-11-16 09:49:42 -08:00
; 973e6
2015-10-24 07:34:19 -07:00
.script: ; 973e6
applymovement PLAYER, wd002
end
; 973eb
EarthquakeMovement: ; 973eb
2015-11-11 20:38:57 -08:00
step_shake 16 ; the 16 gets overwritten with the script byte
step_sleep 16 ; the 16 gets overwritten with the lower 6 bits of the script byte
step_end
EarthquakeMovementEnd
; 973f0
2015-11-16 09:49:42 -08:00
Script_loadpikachudata: ; 973f0
; script command 0x5a
ld a, PIKACHU
ld [TempWildMonSpecies], a
ld a, 5
2014-05-21 13:21:46 -07:00
ld [CurPartyLevel], a
ret
2015-11-16 09:49:42 -08:00
; 973fb
Script_randomwildmon: ; 973fb
; script command 0x5b
xor a
2015-11-25 07:16:29 -08:00
ld [wBattleScriptFlags], a
ret
2015-11-16 09:49:42 -08:00
; 97400
Script_loadmemtrainer: ; 97400
; script command 0x5c
2015-10-24 07:34:19 -07:00
ld a, (1 << 7) | 1
2015-11-25 07:16:29 -08:00
ld [wBattleScriptFlags], a
ld a, [wTempTrainerClass]
2015-02-10 15:14:21 -08:00
ld [OtherTrainerClass], a
ld a, [wTempTrainerID]
2015-02-10 15:14:21 -08:00
ld [OtherTrainerID], a
ret
2015-11-16 09:49:42 -08:00
; 97412
Script_loadwildmon: ; 97412
; script command 0x5d
; parameters:
; pokemon (PokemonParam)
; level (DecimalParam)
2015-10-24 07:34:19 -07:00
ld a, (1 << 7)
2015-11-25 07:16:29 -08:00
ld [wBattleScriptFlags], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [TempWildMonSpecies], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld [CurPartyLevel], a
ret
2015-11-16 09:49:42 -08:00
; 97424
Script_loadtrainer: ; 97424
; script command 0x5e
; parameters:
; trainer_group (TrainerGroupParam)
; trainer_id (TrainerIdParam)
2015-10-24 07:34:19 -07:00
ld a, (1 << 7) | 1
2015-11-25 07:16:29 -08:00
ld [wBattleScriptFlags], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-02-10 15:14:21 -08:00
ld [OtherTrainerClass], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-02-10 15:14:21 -08:00
ld [OtherTrainerID], a
ret
2015-11-16 09:49:42 -08:00
; 97436
2015-11-16 09:49:42 -08:00
Script_startbattle: ; 97436
; script command 0x5f
call BufferScreen
predef StartBattle
2015-10-24 07:34:19 -07:00
ld a, [wBattleResult]
and $3f
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97447
2015-11-16 09:49:42 -08:00
Script_catchtutorial: ; 97447
; script command 0x61
; parameters:
; byte (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [BattleType], a
call BufferScreen
2015-11-08 10:27:26 -08:00
callba CatchTutorial
jp Script_reloadmap
2015-11-16 09:49:42 -08:00
; 97459
2015-11-16 09:49:42 -08:00
Script_returnafterbattle: ; 97459
; script command 0x60
2015-11-25 07:16:29 -08:00
ld hl, wBattleScriptFlags
ld d, [hl]
ld [hl], $0
2015-10-24 07:34:19 -07:00
ld a, [wBattleResult]
and $3f
cp $1
2015-11-16 08:53:26 -08:00
jr nz, .notblackedout
2015-11-11 13:11:08 -08:00
ld b, BANK(Script_BattleWhiteout)
ld hl, Script_BattleWhiteout
2013-05-03 11:27:24 -07:00
jp ScriptJump
2015-10-19 13:49:29 -07:00
.notblackedout
bit 0, d
2015-11-16 08:53:26 -08:00
jr z, .was_wild
2015-10-19 13:49:29 -07:00
callba MomTriesToBuySomething
2015-11-16 08:53:26 -08:00
jr .done
2015-10-19 13:49:29 -07:00
2015-10-24 07:34:19 -07:00
.was_wild
ld a, [wBattleResult]
bit 7, a
2015-11-16 08:53:26 -08:00
jr z, .done
2015-10-19 13:49:29 -07:00
ld b, BANK(Script_SpecialBillCall)
ld de, Script_SpecialBillCall
2015-10-24 07:34:19 -07:00
callba LoadScriptBDE
2015-10-19 13:49:29 -07:00
.done
jp Script_reloadmap
2015-11-16 09:49:42 -08:00
; 97491
2015-11-16 09:49:42 -08:00
Script_reloadmap: ; 97491
; script command 0x7b
xor a
2015-11-25 07:16:29 -08:00
ld [wBattleScriptFlags], a
2015-10-24 16:49:19 -07:00
ld a, MAPSETUP_RELOADMAP
ld [hMapEntryMethod], a
ld a, $1
call LoadMapStatus
2013-07-04 02:37:20 -07:00
call StopScript
ret
2015-11-16 09:49:42 -08:00
; 974a2
2015-11-16 09:49:42 -08:00
Script_scall: ; 974a2
; script command 0x0
; parameters:
; pointer (ScriptPointerLabelParam)
ld a, [ScriptBank]
ld b, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
jr ScriptCall
2015-11-16 09:49:42 -08:00
; 974b0
2015-11-16 09:49:42 -08:00
Script_farscall: ; 974b0
; script command 0x1
; parameters:
; pointer (ScriptPointerLabelBeforeBank)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld b, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
jr ScriptCall
2015-11-16 09:49:42 -08:00
; 974be
2015-11-16 09:49:42 -08:00
Script_ptcall: ; 974be
; script command 0x2
; parameters:
; pointer (PointerLabelToScriptPointer)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
ld b, [hl]
inc hl
ld e, [hl]
inc hl
ld d, [hl]
; fallthrough
2015-11-16 09:49:42 -08:00
ScriptCall: ; 974cb
2015-11-16 08:53:26 -08:00
; Bug: The script stack has a capacity of 5 scripts, yet there is
; nothing to stop you from pushing a sixth script. The high part
; of the script address can then be overwritten by modifications
; to ScriptDelay, causing the script to return to the rst/interrupt
; space.
push de
2015-11-16 08:53:26 -08:00
ld hl, wScriptStackSize
ld e, [hl]
inc [hl]
ld d, $0
ld hl, wScriptStack
2015-07-20 19:18:18 -07:00
rept 3
add hl, de
2015-07-20 19:18:18 -07:00
endr
pop de
ld a, [ScriptBank]
ld [hli], a
ld a, [ScriptPos]
ld [hli], a
2013-05-03 11:27:24 -07:00
ld a, [ScriptPos + 1]
ld [hl], a
ld a, b
ld [ScriptBank], a
ld a, e
ld [ScriptPos], a
ld a, d
2013-05-03 11:27:24 -07:00
ld [ScriptPos + 1], a
ret
2015-11-16 09:49:42 -08:00
; 974f3
2015-11-16 09:49:42 -08:00
CallCallback:: ; 974f3
ld a, [ScriptBank]
or $80
ld [ScriptBank], a
jp ScriptCall
2015-11-16 09:49:42 -08:00
; 974fe
2015-11-16 09:49:42 -08:00
Script_jump: ; 974fe
; script command 0x3
; parameters:
; pointer (ScriptPointerLabelParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
ld a, [ScriptBank]
ld b, a
2013-05-03 11:27:24 -07:00
jp ScriptJump
2015-11-16 09:49:42 -08:00
; 9750d
2015-11-16 09:49:42 -08:00
Script_farjump: ; 9750d
; script command 0x4
; parameters:
; pointer (ScriptPointerLabelBeforeBank)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld b, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
2013-05-03 11:27:24 -07:00
jp ScriptJump
2015-11-16 09:49:42 -08:00
; 9751c
2015-11-16 09:49:42 -08:00
Script_ptjump: ; 9751c
; script command 0x5
; parameters:
; pointer (PointerLabelToScriptPointer)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
ld b, [hl]
inc hl
ld a, [hli]
ld h, [hl]
ld l, a
2013-05-03 11:27:24 -07:00
jp ScriptJump
2015-11-16 09:49:42 -08:00
; 9752c
2015-11-16 09:49:42 -08:00
Script_iffalse: ; 9752c
; script command 0x8
; parameters:
; pointer (ScriptPointerLabelParam)
2014-05-21 13:21:46 -07:00
ld a, [ScriptVar]
and a
jp nz, SkipTwoScriptBytes
2015-11-16 09:49:42 -08:00
jp Script_jump
; 97536
2015-11-16 09:49:42 -08:00
Script_iftrue: ; 97536
; script command 0x9
; parameters:
; pointer (ScriptPointerLabelParam)
2014-05-21 13:21:46 -07:00
ld a, [ScriptVar]
and a
2015-11-16 09:49:42 -08:00
jp nz, Script_jump
jp SkipTwoScriptBytes
2015-11-16 09:49:42 -08:00
; 97540
2015-11-16 09:49:42 -08:00
Script_if_equal: ; 97540
; script command 0x6
; parameters:
; byte (SingleByteParam)
; pointer (ScriptPointerLabelParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld hl, ScriptVar
cp [hl]
2015-11-16 09:49:42 -08:00
jr z, Script_jump
2015-11-16 08:53:26 -08:00
jr SkipTwoScriptBytes
2015-11-16 09:49:42 -08:00
; 9754b
2015-11-16 09:49:42 -08:00
Script_if_not_equal: ; 9754b
; script command 0x7
; parameters:
; byte (SingleByteParam)
; pointer (ScriptPointerLabelParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld hl, ScriptVar
cp [hl]
2015-11-16 09:49:42 -08:00
jr nz, Script_jump
2015-11-16 08:53:26 -08:00
jr SkipTwoScriptBytes
2015-11-16 09:49:42 -08:00
; 97556
2015-11-16 09:49:42 -08:00
Script_if_greater_than: ; 97556
; script command 0xa
; parameters:
; byte (SingleByteParam)
; pointer (ScriptPointerLabelParam)
2014-05-21 13:21:46 -07:00
ld a, [ScriptVar]
ld b, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
cp b
2015-11-16 09:49:42 -08:00
jr c, Script_jump
2015-11-16 08:53:26 -08:00
jr SkipTwoScriptBytes
2015-11-16 09:49:42 -08:00
; 97562
2015-11-16 09:49:42 -08:00
Script_if_less_than: ; 97562
; script command 0xb
; parameters:
; byte (SingleByteParam)
; pointer (ScriptPointerLabelParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld b, a
2014-05-21 13:21:46 -07:00
ld a, [ScriptVar]
cp b
2015-11-16 09:49:42 -08:00
jr c, Script_jump
2015-11-16 08:53:26 -08:00
jr SkipTwoScriptBytes
2015-11-16 09:49:42 -08:00
; 9756e
2015-11-16 09:49:42 -08:00
Script_jumpstd: ; 9756e
; script command 0xc
; parameters:
; predefined_script (MultiByteParam)
call StdScript
2015-11-16 08:53:26 -08:00
jr ScriptJump
2015-11-16 09:49:42 -08:00
; 97573
2015-11-16 09:49:42 -08:00
Script_callstd: ; 97573
; script command 0xd
; parameters:
; predefined_script (MultiByteParam)
call StdScript
ld d, h
ld e, l
jp ScriptCall
2015-11-16 09:49:42 -08:00
; 9757b
2015-11-16 09:49:42 -08:00
StdScript: ; 9757b
call GetScriptByte
ld e, a
call GetScriptByte
ld d, a
ld hl, StdScripts
2015-07-20 19:18:18 -07:00
rept 3
add hl, de
2015-07-20 19:18:18 -07:00
endr
ld a, BANK(StdScripts)
call GetFarByte
ld b, a
inc hl
ld a, BANK(StdScripts)
call GetFarHalfword
ret
2015-11-16 09:49:42 -08:00
; 97596
2015-11-16 09:49:42 -08:00
SkipTwoScriptBytes: ; 97596
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptByte
2013-02-28 13:04:26 -08:00
ret
2015-11-16 09:49:42 -08:00
; 9759d
2015-11-16 09:49:42 -08:00
ScriptJump: ; 9759d
2013-02-28 13:04:26 -08:00
ld a, b
ld [ScriptBank], a
2013-02-28 13:04:26 -08:00
ld a, l
ld [ScriptPos], a
2013-02-28 13:04:26 -08:00
ld a, h
2013-05-03 11:27:24 -07:00
ld [ScriptPos + 1], a
2013-02-28 13:04:26 -08:00
ret
2015-11-16 09:49:42 -08:00
; 975aa
2015-11-16 09:49:42 -08:00
Script_priorityjump: ; 975aa
; script command 0x8d
; parameters:
; pointer (ScriptPointerLabelParam)
ld a, [ScriptBank]
ld [wPriorityScriptBank], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [wPriorityScriptAddr], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [wPriorityScriptAddr + 1], a
2013-07-04 02:37:20 -07:00
ld hl, ScriptFlags
set 3, [hl]
ret
2015-11-16 09:49:42 -08:00
; 975c2
2015-11-16 09:49:42 -08:00
Script_checktriggers: ; 975c2
; script command 0x13
call CheckTriggers
2015-11-16 09:49:42 -08:00
jr z, .no_triggers
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
.no_triggers
ld a, $ff
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 975d1
2015-11-16 09:49:42 -08:00
Script_checkmaptriggers: ; 975d1
; script command 0x11
; parameters:
; map_group (SingleByteParam)
; map_id (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld b, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld c, a
call GetMapTrigger
ld a, d
or e
2015-11-16 09:49:42 -08:00
jr z, .no_triggers
ld a, [de]
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
.no_triggers
ld a, $ff
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 975eb
2015-11-16 09:49:42 -08:00
Script_dotrigger: ; 975eb
; script command 0x14
; parameters:
; trigger_id (SingleByteParam)
2015-02-10 15:14:21 -08:00
ld a, [MapGroup]
ld b, a
2015-02-10 15:14:21 -08:00
ld a, [MapNumber]
ld c, a
2015-11-16 09:49:42 -08:00
jr DoTrigger
; 975f5
2015-11-16 09:49:42 -08:00
Script_domaptrigger: ; 975f5
; script command 0x12
; parameters:
; map_group (MapGroupParam)
; map_id (MapIdParam)
; trigger_id (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld b, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld c, a
2015-11-16 09:49:42 -08:00
DoTrigger: ; 975fd
call GetMapTrigger
ld a, d
or e
2015-11-16 09:49:42 -08:00
jr z, .no_trigger
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [de], a
2015-11-16 09:49:42 -08:00
.no_trigger
ret
2015-11-16 09:49:42 -08:00
; 97609
2015-11-16 09:49:42 -08:00
Script_copybytetovar: ; 97609
; script command 0x19
; parameters:
; address (RAMAddressParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
ld a, [hl]
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97616
2015-11-16 09:49:42 -08:00
Script_copyvartobyte: ; 97616
; script command 0x1a
; parameters:
; address (RAMAddressParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
2014-05-21 13:21:46 -07:00
ld a, [ScriptVar]
ld [hl], a
ret
2015-11-16 09:49:42 -08:00
; 97623
2015-11-16 09:49:42 -08:00
Script_loadvar: ; 97623
; script command 0x1b
; parameters:
; address (RAMAddressParam)
; value (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [hl], a
ret
2015-11-16 09:49:42 -08:00
; 97630
2015-11-16 09:49:42 -08:00
Script_writebyte: ; 97630
; script command 0x15
; parameters:
; value (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97637
2015-11-16 09:49:42 -08:00
Script_addvar: ; 97637
; script command 0x16
; parameters:
; value (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld hl, ScriptVar
add [hl]
ld [hl], a
ret
2015-11-16 09:49:42 -08:00
; 97640
2015-11-16 09:49:42 -08:00
Script_random: ; 97640
; script command 0x17
; parameters:
; input (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
and a
ret z
2015-11-16 08:53:26 -08:00
ld c, a
2015-11-16 08:53:26 -08:00
call .Divide256byC
and a
2015-11-16 08:53:26 -08:00
jr z, .no_restriction ; 256 % b == 0
ld b, a
xor a
sub b
ld b, a
2015-11-16 08:53:26 -08:00
.loop
push bc
call Random
pop bc
2015-11-16 08:53:26 -08:00
ld a, [hRandomAdd]
cp b
2015-11-16 08:53:26 -08:00
jr nc, .loop
jr .finish
.no_restriction
push bc
call Random
pop bc
2015-11-16 08:53:26 -08:00
ld a, [hRandomAdd]
.finish
push af
2014-05-21 13:21:46 -07:00
ld a, [ScriptVar]
ld c, a
pop af
call SimpleDivide
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97673
2015-11-16 09:49:42 -08:00
.Divide256byC: ; 97673
xor a
ld b, a
sub c
2015-11-16 08:53:26 -08:00
.mod_loop
inc b
sub c
2015-11-16 08:53:26 -08:00
jr nc, .mod_loop
dec b
add c
ret
2015-11-16 09:49:42 -08:00
; 9767d
2015-11-16 09:49:42 -08:00
Script_checkcode: ; 9767d
; script command 0x1c
; parameters:
; variable_id (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetVarAction
ld a, [de]
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97688
2015-11-16 09:49:42 -08:00
Script_writevarcode: ; 97688
; script command 0x1d
; parameters:
; variable_id (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetVarAction
2014-05-21 13:21:46 -07:00
ld a, [ScriptVar]
ld [de], a
ret
2015-11-16 09:49:42 -08:00
; 97693
2015-11-16 09:49:42 -08:00
Script_writecode: ; 97693
; script command 0x1e
; parameters:
; variable_id (SingleByteParam)
; value (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetVarAction
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [de], a
ret
2015-11-16 09:49:42 -08:00
; 9769e
2015-11-16 09:49:42 -08:00
GetVarAction: ; 9769e
ld c, a
callba _GetVarAction
ret
2015-11-16 09:49:42 -08:00
; 976a6
2015-11-16 09:49:42 -08:00
Script_checkver: ; 976a6
; script command 0x18
ld a, [Version]
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 976ad
Version: ; 976ad
db VERSION
; 976ae
2015-11-16 09:49:42 -08:00
Script_pokenamemem: ; 976ae
; script command 0x40
; parameters:
; pokemon (PokemonParam); leave $0 to draw from script var
; memory (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
and a
2015-11-16 08:53:26 -08:00
jr nz, .gotit
2014-05-21 13:21:46 -07:00
ld a, [ScriptVar]
.gotit
2015-02-10 15:14:21 -08:00
ld [wd265], a
call GetPokemonName
ld de, StringBuffer1
2015-11-16 09:49:42 -08:00
ConvertMemToText: ; 976c0
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-09-30 11:19:33 -07:00
cp 3
jr c, .ok
xor a
2014-09-30 11:19:33 -07:00
.ok
CopyConvertedText: ; 976c8
ld hl, StringBuffer3
ld bc, StringBuffer4 - StringBuffer3
call AddNTimes
call CopyName2
ret
2015-11-16 09:49:42 -08:00
; 976d5
2015-11-16 09:49:42 -08:00
Script_itemtotext: ; 976d5
; script command 0x41
; parameters:
2015-11-18 20:16:25 -08:00
; item (ItemLabelByte); use 0 to draw from ScriptVar
; memory (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
and a
2015-11-16 08:53:26 -08:00
jr nz, .ok
2014-05-21 13:21:46 -07:00
ld a, [ScriptVar]
.ok
2015-02-10 15:14:21 -08:00
ld [wd265], a
call GetItemName
ld de, StringBuffer1
2015-11-16 08:53:26 -08:00
jr ConvertMemToText
2015-11-16 09:49:42 -08:00
; 976e9
2015-11-16 09:49:42 -08:00
Script_mapnametotext: ; 976e9
; script command 0x42
; parameters:
; memory (SingleByteParam)
2015-02-10 15:14:21 -08:00
ld a, [MapGroup]
ld b, a
2015-02-10 15:14:21 -08:00
ld a, [MapNumber]
ld c, a
call GetWorldMapLocation
2015-11-16 09:49:42 -08:00
ConvertLandmarkToText: ; 976f4
ld e, a
2013-10-01 18:20:48 -07:00
callba GetLandmarkName
ld de, StringBuffer1
jp ConvertMemToText
2015-11-16 09:49:42 -08:00
; 97701
2015-12-09 08:38:40 -08:00
Script_landmarktotext: ; 97701
; script command 0xa5
; parameters:
; id (SingleByteParam)
; memory (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-11-16 08:53:26 -08:00
jr ConvertLandmarkToText
2015-11-16 09:49:42 -08:00
; 97706
2015-11-16 09:49:42 -08:00
Script_trainertotext: ; 97706
; script command 0x43
; parameters:
; trainer_id (TrainerGroupParam)
; trainer_group (TrainerIdParam)
; memory (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld c, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld b, a
callba GetTrainerName
2015-11-16 08:53:26 -08:00
jr ConvertMemToText
2015-11-16 09:49:42 -08:00
; 97716
2015-11-16 09:49:42 -08:00
Script_name: ; 97716
; script command 0xa7
; parameters:
; type (SingleByteParam)
; id (SingleByteParam)
; memory (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-10-17 14:18:52 -07:00
ld [wNamedObjectTypeBuffer], a
2015-11-16 09:49:42 -08:00
ContinueToGetName: ; 9771c
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-02-10 15:14:21 -08:00
ld [CurSpecies], a
call GetName
ld de, StringBuffer1
jp ConvertMemToText
2015-11-16 09:49:42 -08:00
; 9772b
2015-11-16 09:49:42 -08:00
Script_trainerclassname: ; 9772b
; script command 0xa6
; parameters:
; id (SingleByteParam)
; memory (SingleByteParam)
ld a, TRAINER_NAME
2015-10-17 14:18:52 -07:00
ld [wNamedObjectTypeBuffer], a
2015-11-16 08:53:26 -08:00
jr ContinueToGetName
2015-11-16 09:49:42 -08:00
; 97732
2015-11-16 09:49:42 -08:00
Script_readmoney: ; 97732
; script command 0x3d
; parameters:
; account (SingleByteParam)
; memory (SingleByteParam)
call ResetStringBuffer1
call GetMoneyAccount
ld hl, StringBuffer1
lb bc, PRINTNUM_RIGHTALIGN | 3, 6
call PrintNum
ld de, StringBuffer1
jp ConvertMemToText
2015-11-16 09:49:42 -08:00
; 97747
2015-11-16 09:49:42 -08:00
Script_readcoins: ; 97747
; script command 0x3e
; parameters:
; memory (SingleByteParam)
call ResetStringBuffer1
ld hl, StringBuffer1
2013-08-30 14:50:08 -07:00
ld de, Coins
lb bc, PRINTNUM_RIGHTALIGN | 2, 6
call PrintNum
ld de, StringBuffer1
jp ConvertMemToText
2015-11-16 09:49:42 -08:00
; 9775c
2015-11-16 09:49:42 -08:00
Script_RAM2MEM: ; 9775c
; script command 0x3f
; parameters:
; memory (SingleByteParam)
call ResetStringBuffer1
2014-05-21 13:21:46 -07:00
ld de, ScriptVar
ld hl, StringBuffer1
lb bc, PRINTNUM_RIGHTALIGN | 1, 3
call PrintNum
ld de, StringBuffer1
jp ConvertMemToText
2015-11-16 09:49:42 -08:00
; 97771
2015-11-16 09:49:42 -08:00
ResetStringBuffer1: ; 97771
ld hl, StringBuffer1
ld bc, NAME_LENGTH
ld a, "@"
call ByteFill
ret
2015-11-16 09:49:42 -08:00
; 9777d
2015-11-16 09:49:42 -08:00
Script_stringtotext: ; 9777d
; script command 0x44
; parameters:
; text_pointer (EncodedTextLabelParam)
; memory (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
ld a, [ScriptBank]
ld hl, CopyName1
2013-10-01 18:55:40 -07:00
rst FarCall
ld de, StringBuffer2
jp ConvertMemToText
2015-11-16 09:49:42 -08:00
; 97792
2015-11-16 09:49:42 -08:00
Script_givepokeitem: ; 97792
; script command 0x2f
; parameters:
; pointer (PointerParamToItemAndLetter)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
ld a, [ScriptBank]
call GetFarByte
ld b, a
push bc
inc hl
ld bc, MAIL_MAX_LENGTH
2015-02-10 15:14:21 -08:00
ld de, wd002
ld a, [ScriptBank]
call FarCopyBytes
pop bc
callba GivePokeItem
ret
2015-11-16 09:49:42 -08:00
; 977b7
2015-11-16 09:49:42 -08:00
Script_checkpokeitem: ; 977b7
; script command 0x30
; parameters:
; pointer (PointerParamToItemAndLetter)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
ld a, [ScriptBank]
ld b, a
2015-11-18 07:42:42 -08:00
callba CheckPokeItem
ret
2015-11-16 09:49:42 -08:00
; 977ca
2015-11-16 09:49:42 -08:00
Script_giveitem: ; 977ca
; script command 0x1f
; parameters:
; item (ItemLabelByte)
; quantity (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-11-03 12:05:19 -08:00
cp ITEM_FROM_MEM
2015-11-16 08:53:26 -08:00
jr nz, .ok
2014-05-21 13:21:46 -07:00
ld a, [ScriptVar]
.ok
2014-05-21 13:21:46 -07:00
ld [CurItem], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-11-01 15:13:31 -08:00
ld [wItemQuantityChangeBuffer], a
2014-05-21 13:21:46 -07:00
ld hl, NumItems
call ReceiveItem
2015-11-16 08:53:26 -08:00
jr nc, .full
2015-11-25 07:16:29 -08:00
ld a, TRUE
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
.full
xor a
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 977f0
2015-11-16 09:49:42 -08:00
Script_takeitem: ; 977f0
; script command 0x20
; parameters:
; item (ItemLabelByte)
; quantity (DecimalParam)
xor a
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld [CurItem], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-11-01 15:13:31 -08:00
ld [wItemQuantityChangeBuffer], a
2015-11-03 19:35:36 -08:00
ld a, -1
ld [ItemCountBuffer], a
2014-05-21 13:21:46 -07:00
ld hl, NumItems
call TossItem
ret nc
2015-11-25 07:16:29 -08:00
ld a, TRUE
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97812
2015-11-16 09:49:42 -08:00
Script_checkitem: ; 97812
; script command 0x21
; parameters:
; item (ItemLabelByte)
xor a
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld [CurItem], a
ld hl, NumItems
call CheckItem
ret nc
2015-11-25 07:16:29 -08:00
ld a, TRUE
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97829
2015-11-16 09:49:42 -08:00
Script_givemoney: ; 97829
; script command 0x22
; parameters:
; account (SingleByteParam)
; money (MoneyByteParam)
call GetMoneyAccount
call LoadMoneyAmountToMem
callba GiveMoney
ret
2015-11-16 09:49:42 -08:00
; 97836
2015-11-16 09:49:42 -08:00
Script_takemoney: ; 97836
; script command 0x23
; parameters:
; account (SingleByteParam)
; money (MoneyByteParam)
call GetMoneyAccount
call LoadMoneyAmountToMem
callba TakeMoney
ret
2015-11-16 09:49:42 -08:00
; 97843
2015-11-16 09:49:42 -08:00
Script_checkmoney: ; 97843
; script command 0x24
; parameters:
; account (SingleByteParam)
; money (MoneyByteParam)
call GetMoneyAccount
call LoadMoneyAmountToMem
callba CompareMoney
2015-11-16 09:49:42 -08:00
; 9784f
2015-11-16 09:49:42 -08:00
CompareMoneyAction: ; 9784f
2014-05-21 13:21:46 -07:00
jr c, .two
jr z, .one
ld a, 0
jr .done
.one
ld a, 1
jr .done
.two
ld a, 2
.done
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97861
2015-11-16 09:49:42 -08:00
GetMoneyAccount: ; 97861
call GetScriptByte
and a
2015-02-10 15:14:21 -08:00
ld de, Money
ret z
2015-02-10 15:14:21 -08:00
ld de, wMomsMoney
ret
2015-11-16 09:49:42 -08:00
; 9786d
2015-11-16 09:49:42 -08:00
LoadMoneyAmountToMem: ; 9786d
ld bc, hMoneyTemp
push bc
call GetScriptByte
ld [bc], a
inc bc
call GetScriptByte
ld [bc], a
inc bc
call GetScriptByte
ld [bc], a
pop bc
ret
2015-11-16 09:49:42 -08:00
; 97881
2015-11-16 09:49:42 -08:00
Script_givecoins: ; 97881
; script command 0x25
; parameters:
; coins (CoinByteParam)
call LoadCoinAmountToMem
callba GiveCoins
ret
2015-11-16 09:49:42 -08:00
; 9788b
2015-11-16 09:49:42 -08:00
Script_takecoins: ; 9788b
; script command 0x26
; parameters:
; coins (CoinByteParam)
call LoadCoinAmountToMem
callba TakeCoins
ret
2015-11-16 09:49:42 -08:00
; 97895
2015-11-16 09:49:42 -08:00
Script_checkcoins: ; 97895
; script command 0x27
; parameters:
; coins (CoinByteParam)
call LoadCoinAmountToMem
callba CheckCoins
jr CompareMoneyAction
; 978a0
LoadCoinAmountToMem: ; 978a0
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [hMoneyTemp + 1], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [hMoneyTemp], a
ld bc, hMoneyTemp
ret
2015-11-16 09:49:42 -08:00
; 978ae
2015-11-16 09:49:42 -08:00
Script_checktime: ; 978ae
; script command 0x2b
; parameters:
; time (SingleByteParam)
xor a
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
callba CheckTime
2013-02-28 13:36:21 -08:00
call GetScriptByte
and c
ret z
2015-11-25 07:16:29 -08:00
ld a, TRUE
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 978c3
2015-11-16 09:49:42 -08:00
Script_checkpoke: ; 978c3
; script command 0x2c
; parameters:
; pkmn (PokemonParam)
xor a
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld hl, PartySpecies
ld de, 1
call IsInArray
ret nc
2015-11-25 07:16:29 -08:00
ld a, TRUE
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 978da
2015-11-16 09:49:42 -08:00
Script_addcellnum: ; 978da
; script command 0x28
; parameters:
; person (SingleByteParam)
xor a
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld c, a
callba AddPhoneNumber
ret nc
2015-11-25 07:16:29 -08:00
ld a, TRUE
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 978ef
2015-11-16 09:49:42 -08:00
Script_delcellnum: ; 978ef
; script command 0x29
; parameters:
; person (SingleByteParam)
xor a
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld c, a
callba DelCellNum
ret nc
2015-11-25 07:16:29 -08:00
ld a, TRUE
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97904
2015-11-16 09:49:42 -08:00
Script_checkcellnum: ; 97904
; script command 0x2a
; parameters:
; person (SingleByteParam)
; returns false if the cell number is not in your phone
xor a
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld c, a
callba CheckCellNum
ret nc
2015-11-25 07:16:29 -08:00
ld a, TRUE
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97919
2015-11-16 09:49:42 -08:00
Script_specialphonecall: ; 97919
; script command 0x9c
; parameters:
; call_id (MultiByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [wSpecialPhoneCallID], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [wSpecialPhoneCallID + 1], a
ret
2015-11-16 09:49:42 -08:00
; 97926
2015-11-16 09:49:42 -08:00
Script_checkphonecall: ; 97926
; script command 0x9d
; returns false if no special phone call is stored
ld a, [wSpecialPhoneCallID]
and a
2014-05-21 13:21:46 -07:00
jr z, .ok
2015-11-25 07:16:29 -08:00
ld a, TRUE
2014-05-21 13:21:46 -07:00
.ok
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97932
2015-11-16 09:49:42 -08:00
Script_givepoke: ; 97932
; script command 0x2d
; parameters:
; pokemon (PokemonParam)
; level (DecimalParam)
; item (ItemLabelByte)
; trainer (DecimalParam)
; trainer_name_pointer (MultiByteParam)
; pkmn_nickname (MultiByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld [CurPartySpecies], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld [CurPartyLevel], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld [CurItem], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
and a
ld b, a
2014-05-21 13:21:46 -07:00
jr z, .ok
ld hl, ScriptPos
ld e, [hl]
inc hl
ld d, [hl]
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptByte
call GetScriptByte
call GetScriptByte
2014-05-21 13:21:46 -07:00
.ok
callba GivePoke
ld a, b
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97968
2015-11-16 09:49:42 -08:00
Script_giveegg: ; 97968
; script command 0x2e
; parameters:
; pkmn (PokemonParam)
; level (DecimalParam)
; if no room in the party, return 0 in ScriptVar; else, return 2
xor a ; PARTYMON
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
2015-02-10 15:14:21 -08:00
ld [MonType], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld [CurPartySpecies], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2014-05-21 13:21:46 -07:00
ld [CurPartyLevel], a
callba GiveEgg
ret nc
ld a, 2
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97988
2015-11-16 09:49:42 -08:00
Script_setevent: ; 97988
; script command 0x33
; parameters:
; bit_number (MultiByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
ld b, SET_FLAG
2013-08-23 12:48:26 -07:00
call EventFlagAction
ret
2015-11-16 09:49:42 -08:00
; 97996
2015-11-16 09:49:42 -08:00
Script_clearevent: ; 97996
; script command 0x32
; parameters:
; bit_number (MultiByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
ld b, RESET_FLAG
2013-08-23 12:48:26 -07:00
call EventFlagAction
ret
2015-11-16 09:49:42 -08:00
; 979a4
2015-11-16 09:49:42 -08:00
Script_checkevent: ; 979a4
; script command 0x31
; parameters:
; bit_number (MultiByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
ld b, CHECK_FLAG
2013-08-23 12:48:26 -07:00
call EventFlagAction
ld a, c
and a
2015-11-16 08:53:26 -08:00
jr z, .false
2015-11-25 07:16:29 -08:00
ld a, TRUE
.false
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 979bb
2015-11-16 09:49:42 -08:00
Script_setflag: ; 979bb
; script command 0x36
; parameters:
; bit_number (MultiByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
2015-11-25 07:16:29 -08:00
ld b, SET_FLAG
call _EngineFlagAction
ret
2015-11-16 09:49:42 -08:00
; 979c9
2015-11-16 09:49:42 -08:00
Script_clearflag: ; 979c9
; script command 0x35
; parameters:
; bit_number (MultiByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
2015-11-25 07:16:29 -08:00
ld b, RESET_FLAG
call _EngineFlagAction
ret
2015-11-16 09:49:42 -08:00
; 979d7
2015-11-16 09:49:42 -08:00
Script_checkflag: ; 979d7
; script command 0x34
; parameters:
; bit_number (MultiByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
ld b, 2 ; check
call _EngineFlagAction
ld a, c
and a
2015-11-16 08:53:26 -08:00
jr z, .false
2015-11-25 07:16:29 -08:00
ld a, TRUE
.false
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 979ee
2015-11-16 09:49:42 -08:00
_EngineFlagAction: ; 979ee
2013-10-01 18:20:48 -07:00
callba EngineFlagAction
ret
2015-11-16 09:49:42 -08:00
; 979f5
2015-11-16 09:49:42 -08:00
Script_wildoff: ; 979f5
; script command 0x38
ld hl, StatusFlags
set 5, [hl]
ret
2015-11-16 09:49:42 -08:00
; 979fb
2015-11-16 09:49:42 -08:00
Script_wildon: ; 979fb
; script command 0x37
ld hl, StatusFlags
res 5, [hl]
ret
2015-11-16 09:49:42 -08:00
; 97a01
2015-11-16 09:49:42 -08:00
Script_xycompare: ; 97a01
; script command 0x39
; parameters:
; pointer (MultiByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-02-10 15:14:21 -08:00
ld [wd453], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-02-10 15:14:21 -08:00
ld [wd454], a
ret
2015-11-16 09:49:42 -08:00
; 97a0e
2015-11-16 09:49:42 -08:00
Script_warpfacing: ; 97a0e
; script command 0xa3
; parameters:
; facing (SingleByteParam)
; map_group (MapGroupParam)
; map_id (MapIdParam)
; x (SingleByteParam)
; y (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
and $3
ld c, a
2015-10-24 07:34:19 -07:00
ld a, [wPlayerSpriteSetupFlags]
set 5, a
or c
2015-10-24 07:34:19 -07:00
ld [wPlayerSpriteSetupFlags], a
; fall through
2015-11-16 09:49:42 -08:00
Script_warp: ; 97a1d
; script command 0x3c
; parameters:
; map_group (MapGroupParam)
; map_id (MapIdParam)
; x (SingleByteParam)
; y (SingleByteParam)
; This seems to be some sort of error handling case.
2013-02-28 13:36:21 -08:00
call GetScriptByte
and a
2015-11-16 08:53:26 -08:00
jr z, .not_ok
2015-02-10 15:14:21 -08:00
ld [MapGroup], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-02-10 15:14:21 -08:00
ld [MapNumber], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-02-10 15:14:21 -08:00
ld [XCoord], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-02-10 15:14:21 -08:00
ld [YCoord], a
ld a, -1
2015-02-10 15:14:21 -08:00
ld [wd001], a
2015-10-24 16:49:19 -07:00
ld a, MAPSETUP_WARP
ld [hMapEntryMethod], a
ld a, 1
call LoadMapStatus
2013-07-04 02:37:20 -07:00
call StopScript
ret
2015-11-11 20:38:57 -08:00
.not_ok
2013-02-28 13:36:21 -08:00
call GetScriptByte
call GetScriptByte
call GetScriptByte
ld a, -1
2015-02-10 15:14:21 -08:00
ld [wd001], a
2015-10-24 16:49:19 -07:00
ld a, MAPSETUP_BADWARP
ld [hMapEntryMethod], a
ld a, 1
call LoadMapStatus
2013-07-04 02:37:20 -07:00
call StopScript
ret
2015-11-16 09:49:42 -08:00
; 97a65
2015-11-16 09:49:42 -08:00
Script_warpmod: ; 97a65
; script command 0x3a
; parameters:
; warp_id (SingleByteParam)
; map_group (MapGroupParam)
; map_id (MapIdParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-11-12 08:10:19 -08:00
ld [BackupWarpNumber], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-02-10 15:14:21 -08:00
ld [BackupMapGroup], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-02-10 15:14:21 -08:00
ld [BackupMapNumber], a
ret
2015-11-16 09:49:42 -08:00
; 97a78
2015-11-16 09:49:42 -08:00
Script_blackoutmod: ; 97a78
; script command 0x3b
; parameters:
; map_group (MapGroupParam)
; map_id (MapIdParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-11-11 13:11:08 -08:00
ld [wLastSpawnMapGroup], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-11-11 13:11:08 -08:00
ld [wLastSpawnMapNumber], a
ret
2015-11-16 09:49:42 -08:00
; 97a85
2015-11-16 09:49:42 -08:00
Script_reloadmapmusic: ; 97a85
; script command 0x83
ld a, 1
2015-02-10 15:14:21 -08:00
ld [wc2c1], a
ret
2015-11-16 09:49:42 -08:00
; 97a8b
2015-11-16 09:49:42 -08:00
Script_writecmdqueue: ; 97a8b
; script command 0x7d
; parameters:
; queue_pointer (MultiByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld e, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld d, a
ld a, [ScriptBank]
ld b, a
2015-11-18 20:16:25 -08:00
callba WriteCmdQueue ; no need to farcall
ret
2015-11-16 09:49:42 -08:00
; 97a9e
2015-11-16 09:49:42 -08:00
Script_delcmdqueue: ; 97a9e
; script command 0x7e
; parameters:
; byte (SingleByteParam)
xor a
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld b, a
2015-11-18 20:16:25 -08:00
callba DelCmdQueue ; no need to farcall
ret c
ld a, 1
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97ab3
2015-11-16 09:49:42 -08:00
Script_changemap: ; 97ab3
; script command 0x79
; parameters:
; map_data_pointer (MapDataPointerParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-02-10 15:14:21 -08:00
ld [MapBlockDataBank], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-02-10 15:14:21 -08:00
ld [MapBlockDataPointer], a
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-02-10 15:14:21 -08:00
ld [MapBlockDataPointer + 1], a
call ChangeMap
call BufferScreen
ret
2015-11-16 09:49:42 -08:00
; 97acc
2015-11-16 09:49:42 -08:00
Script_changeblock: ; 97acc
; script command 0x7a
; parameters:
; x (SingleByteParam)
; y (SingleByteParam)
; block (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
add 4
ld d, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
add 4
ld e, a
call GetBlockLocation
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [hl], a
call BufferScreen
ret
2015-11-16 09:49:42 -08:00
; 97ae3
2015-11-16 09:49:42 -08:00
Script_reloadmappart:: ; 97ae3
; script command 0x7c
xor a
2015-10-24 07:34:19 -07:00
ld [hBGMapMode], a
2015-11-11 11:12:46 -08:00
call OverworldTextModeSwitch
2015-11-19 15:07:20 -08:00
call GetMovementPermissions
callba ReloadMapPart
call UpdateSprites
ret
2015-11-16 09:49:42 -08:00
; 97af6
2015-11-16 09:49:42 -08:00
Script_warpcheck: ; 97af6
; script command 0x8e
2015-11-12 08:10:19 -08:00
call WarpCheck
ret nc
callba EnableEvents
ret
2015-11-16 09:49:42 -08:00
; 97b01
Script_enableevents: ; unreferenced
callba EnableEvents
ret
2015-11-16 09:49:42 -08:00
; 97b08
2015-11-16 09:49:42 -08:00
Script_newloadmap: ; 97b08
; script command 0x8a
; parameters:
; which_method (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld [hMapEntryMethod], a
ld a, 1
call LoadMapStatus
2013-07-04 02:37:20 -07:00
call StopScript
ret
2015-11-16 09:49:42 -08:00
; 97b16
2015-11-16 09:49:42 -08:00
Script_reloadandreturn: ; 97b16
; script command 0x92
call Script_newloadmap
2013-07-04 02:37:20 -07:00
jp Script_end
2015-11-16 09:49:42 -08:00
; 97b1c
2015-12-09 15:25:44 -08:00
Script_textbox: ; 97b1c
; script command 0x47
2015-12-09 15:25:44 -08:00
call OpenText
ret
2015-11-16 09:49:42 -08:00
; 97b20
2015-11-16 09:49:42 -08:00
Script_refreshscreen: ; 97b20
; script command 0x48
; parameters:
; dummy (SingleByteParam)
call ResetWindow
2013-02-28 13:36:21 -08:00
call GetScriptByte
ret
2015-11-16 09:49:42 -08:00
; 97b27
2015-11-16 09:49:42 -08:00
Script_loadbytec2cf: ; 97b27
; script command 0x4a
; parameters:
; byte (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
2015-02-10 15:14:21 -08:00
ld [wc2cf], a
ret
2015-11-16 09:49:42 -08:00
; 97b2e
2015-11-25 07:16:29 -08:00
CloseTextScript: ; 97b2e
closetext
; 97b2f
2015-11-25 07:16:29 -08:00
Script_closetext: ; 97b2f
; script command 0x49
call Function2e20
2015-11-25 07:16:29 -08:00
call CloseText
ret
2015-11-16 09:49:42 -08:00
; 97b36
2015-11-16 09:49:42 -08:00
Script_passtoengine: ; 97b36
; script command 0x89
; parameters:
; data_pointer (PointerLabelBeforeBank)
2013-02-28 13:36:21 -08:00
call GetScriptByte
push af
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld l, a
2013-02-28 13:36:21 -08:00
call GetScriptByte
ld h, a
pop af
call StartAutoInput
ret
2015-11-16 09:49:42 -08:00
; 97b47
2015-11-16 09:49:42 -08:00
Script_pause: ; 97b47
; script command 0x8b
; parameters:
; length (DecimalParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
and a
2015-11-16 08:53:26 -08:00
jr z, .loop
2013-07-04 02:37:20 -07:00
ld [ScriptDelay], a
.loop
2013-07-04 02:37:20 -07:00
ld c, 2
call DelayFrames
2013-07-04 02:37:20 -07:00
ld hl, ScriptDelay
dec [hl]
2015-11-16 08:53:26 -08:00
jr nz, .loop
ret
2015-11-16 09:49:42 -08:00
; 97b5c
2015-11-16 09:49:42 -08:00
Script_deactivatefacing: ; 97b5c
; script command 0x8c
; parameters:
; time (SingleByteParam)
2013-02-28 13:36:21 -08:00
call GetScriptByte
and a
2015-11-16 08:53:26 -08:00
jr z, .no_time
2013-07-04 02:37:20 -07:00
ld [ScriptDelay], a
.no_time
2013-07-04 02:37:20 -07:00
ld a, SCRIPT_WAIT
ld [ScriptMode], a
call StopScript
ret
2015-11-16 09:49:42 -08:00
; 97b6e
2015-11-16 09:49:42 -08:00
Script_ptpriorityjump: ; 97b6e
; script command 0x8f
; parameters:
; pointer (ScriptPointerLabelParam)
2013-07-04 02:37:20 -07:00
call StopScript
2015-11-16 09:49:42 -08:00
jp Script_jump
; 97b74
2015-11-16 09:49:42 -08:00
Script_end: ; 97b74
; script command 0x91
2013-07-04 02:37:20 -07:00
call ExitScriptSubroutine
jr c, .resume
ret
2015-11-11 20:38:57 -08:00
.resume
xor a
ld [ScriptRunning], a
2013-07-04 02:37:20 -07:00
ld a, SCRIPT_OFF
ld [ScriptMode], a
ld hl, ScriptFlags
res 0, [hl]
2013-07-04 02:37:20 -07:00
call StopScript
ret
2015-11-16 09:49:42 -08:00
; 97b8c
2015-11-16 09:49:42 -08:00
Script_return: ; 97b8c
; script command 0x90
2013-07-04 02:37:20 -07:00
call ExitScriptSubroutine
jr c, .dummy
.dummy
2013-07-04 02:37:20 -07:00
ld hl, ScriptFlags
res 0, [hl]
2013-07-04 02:37:20 -07:00
call StopScript
ret
2015-11-16 09:49:42 -08:00
; 97b9a
2015-11-16 09:49:42 -08:00
ExitScriptSubroutine: ; 97b9a
2013-07-04 02:37:20 -07:00
; Return carry if there's no parent to return to.
2015-11-16 08:53:26 -08:00
ld hl, wScriptStackSize
ld a, [hl]
and a
2015-11-16 08:53:26 -08:00
jr z, .done
dec [hl]
ld e, [hl]
ld d, $0
ld hl, wScriptStack
rept 3
add hl,de
endr
ld a, [hli]
ld b, a
and " "
ld [ScriptBank], a
ld a, [hli]
ld e, a
ld [ScriptPos], a
ld a, [hl]
ld d, a
ld [ScriptPos + 1], a
and a
ret
.done
scf
ret
2015-11-16 09:49:42 -08:00
; 97bc0
2015-12-09 08:38:40 -08:00
Script_end_all: ; 97bc0
; script command 0x93
xor a
2015-11-16 08:53:26 -08:00
ld [wScriptStackSize], a
ld [ScriptRunning], a
2013-07-04 02:37:20 -07:00
ld a, SCRIPT_OFF
ld [ScriptMode], a
ld hl, ScriptFlags
res 0, [hl]
2013-07-04 02:37:20 -07:00
call StopScript
ret
2015-11-16 09:49:42 -08:00
; 97bd5
2015-11-16 09:49:42 -08:00
Script_halloffame: ; 97bd5
; script command 0xa1
2015-02-10 15:14:21 -08:00
ld hl, GameTimerPause
res 0, [hl]
2013-09-15 16:07:38 -07:00
callba Mobile_HallOfFame
callba Mobile_HallOfFame2
callba HallOfFame
2015-02-10 15:14:21 -08:00
ld hl, GameTimerPause
set 0, [hl]
jr DisplayCredits
2015-11-16 09:49:42 -08:00
; 97bf3
2015-11-16 09:49:42 -08:00
Script_credits: ; 97bf3
; script command 0xa2
callba RedCredits
DisplayCredits:
2015-12-09 08:38:40 -08:00
call Script_end_all
ld a, $3
call LoadMapStatus
2013-07-04 02:37:20 -07:00
call StopScript
ret
2015-11-16 09:49:42 -08:00
; 97c051
2015-11-16 09:49:42 -08:00
Script_wait: ; 97c05
; script command 0xa8
; parameters:
; unknown (SingleByteParam)
push bc
2013-02-28 13:36:21 -08:00
call GetScriptByte
.loop
push af
2013-07-04 02:37:20 -07:00
ld c, 6
call DelayFrames
pop af
dec a
2015-11-16 08:53:26 -08:00
jr nz, .loop
pop bc
ret
2015-11-16 09:49:42 -08:00
; 97c15
2015-11-16 09:49:42 -08:00
Script_check_save: ; 97c15
; script command 0xa9
2015-11-16 08:53:26 -08:00
callba CheckSave
ld a, c
2014-05-21 13:21:46 -07:00
ld [ScriptVar], a
ret
2015-11-16 09:49:42 -08:00
; 97c20
2015-11-16 08:53:26 -08:00
; 97c20 unreferenced
ld a, [.byte]
ld [ScriptVar], a
ret
.byte
db 0
; 97c28