diff options
-rw-r--r-- | extras/vba.py | 216 | ||||
-rw-r--r-- | main.asm | 40 | ||||
-rw-r--r-- | scripting.asm | 1097 | ||||
-rw-r--r-- | wram.asm | 6 |
4 files changed, 905 insertions, 454 deletions
diff --git a/extras/vba.py b/extras/vba.py index 1d1e1e5c5..14c96e3f1 100644 --- a/extras/vba.py +++ b/extras/vba.py @@ -70,7 +70,11 @@ TOOD: import os import sys +import re from array import array +import string +from copy import copy +import unittest # for converting bytes to readable text from chars import chars @@ -432,6 +436,136 @@ def press(buttons, steplimit=1): for step_counter in range(0, steplimit): Gb.step(number) +class Registers: + order = [ + "pc", + "sp", + "af", + "bc", + "de", + "hl", + "iff", + "div", + "tima", + "tma", + "tac", + "if", + "lcdc", + "stat", + "scy", + "scx", + "ly", + "lyc", + "dma", + "wy", + "wx", + "vbk", + "hdma1", + "hdma2", + "hdma3", + "hdma4", + "hdma5", + "svbk", + "ie", + ] + + def __setitem__(self, key, value): + current_registers = get_registers() + current_registers[Registers.order.index(key)] = value + set_registers(current_registers) + + def __getitem__(self, key): + current_registers = get_registers() + return current_registers[Registers.order.index(key)] + + def __list__(self): + return get_registers() + + def _get_register(id): + def constructed_func(self, id=copy(id)): + return get_registers()[id] + return constructed_func + + def _set_register(id): + def constructed_func(self, value, id=copy(id)): + current_registers = get_registers() + current_registers[id] = value + set_registers(current_registers) + return constructed_func + + pc = property(fget=_get_register(0), fset=_set_register(0)) + sp = property(fget=_get_register(1), fset=_set_register(1)) + af = property(fget=_get_register(2), fset=_set_register(2)) + bc = property(fget=_get_register(3), fset=_set_register(3)) + de = property(fget=_get_register(4), fset=_set_register(4)) + hl = property(fget=_get_register(5), fset=_set_register(5)) + iff = property(fget=_get_register(6), fset=_set_register(6)) + div = property(fget=_get_register(7), fset=_set_register(7)) + tima = property(fget=_get_register(8), fset=_set_register(8)) + tma = property(fget=_get_register(9), fset=_set_register(9)) + tac = property(fget=_get_register(10), fset=_set_register(10)) + _if = property(fget=_get_register(11), fset=_set_register(11)) + lcdc = property(fget=_get_register(12), fset=_set_register(12)) + stat = property(fget=_get_register(13), fset=_set_register(13)) + scy = property(fget=_get_register(14), fset=_set_register(14)) + scx = property(fget=_get_register(15), fset=_set_register(15)) + ly = property(fget=_get_register(16), fset=_set_register(16)) + lyc = property(fget=_get_register(17), fset=_set_register(17)) + dma = property(fget=_get_register(18), fset=_set_register(18)) + wy = property(fget=_get_register(19), fset=_set_register(19)) + wx = property(fget=_get_register(20), fset=_set_register(20)) + vbk = property(fget=_get_register(21), fset=_set_register(21)) + hdma1 = property(fget=_get_register(22), fset=_set_register(22)) + hdma2 = property(fget=_get_register(23), fset=_set_register(23)) + hdma3 = property(fget=_get_register(24), fset=_set_register(24)) + hdma4 = property(fget=_get_register(25), fset=_set_register(25)) + hdma5 = property(fget=_get_register(26), fset=_set_register(26)) + svbk = property(fget=_get_register(27), fset=_set_register(27)) + ie = property(fget=_get_register(28), fset=_set_register(28)) + + def __repr__(self): + spacing = "\t" + output = "Registers:\n" + for (id, each) in enumerate(self.order): + output += spacing + each + " = " + hex(get_registers()[id]) + #hex(self[each]) + output += "\n" + return output + +registers = Registers() + +def call(bank, address): + """ + Jumps into a function at a certain address. + + Go into the start menu, pause the game and try call(1, 0x1078) to see a + string printed to the screen. + """ + push = [ + registers.pc, + registers.hl, + registers.de, + registers.bc, + registers.af, + 0x3bb7, + ] + + for value in push: + registers.sp -= 2 + set_memory_at(registers.sp + 1, value >> 8) + set_memory_at(registers.sp, value & 0xFF) + if get_memory_range(registers.sp, 2) != [value & 0xFF, value >> 8]: + print "desired memory values: " + str([value & 0xFF, value >> 8] ) + print "actual memory values: " + str(get_memory_range(registers.sp , 2)) + print "wrong value at " + hex(registers.sp) + " expected " + hex(value) + " but got " + hex(get_memory_at(registers.sp)) + + if bank != 0: + registers["af"] = (bank << 8) | (registers["af"] & 0xFF) + registers["hl"] = address + registers["pc"] = 0x2d63 # FarJump + else: + registers["pc"] = address + class crystal: """ Just a simple namespace to store a bunch of functions for Pokémon Crystal. @@ -459,6 +593,10 @@ class crystal: set_memory_at(0xC2FC, 0) set_memory_at(0xC2FD, 0) + #@staticmethod + #def set_enemy_level(level): + # set_memory_at(0xd213, level) + @staticmethod def nstep(steplimit=500): """ @@ -467,6 +605,7 @@ class crystal: """ for step_counter in range(0, steplimit): crystal.walk_through_walls() + #call(0x1, 0x1078) step() @staticmethod @@ -581,6 +720,55 @@ class crystal: set_memory_at(0xd434, 0 & 251) @staticmethod + def warp_pokecenter(): + crystal.warp(1, 1, 3, 3) + crystal.nstep(200) + + @staticmethod + def masterballs(): + # masterball + set_memory_at(0xd8d8, 1) + set_memory_at(0xd8d9, 99) + + # ultraball + set_memory_at(0xd8da, 2) + set_memory_at(0xd8db, 99) + + # pokeballs + set_memory_at(0xd8dc, 5) + set_memory_at(0xd8dd, 99) + + @staticmethod + def get_text(): + """ + Returns alphanumeric text on the screen. Other characters will not be + shown. + """ + output = "" + tiles = get_memory_range(0xc4a0, 1000) + for each in tiles: + if each in chars.keys(): + thing = chars[each] + acceptable = False + + if len(thing) == 2: + portion = thing[1:] + else: + portion = thing + + if portion in string.printable: + acceptable = True + + if acceptable: + output += thing + + # remove extra whitespace + output = re.sub(" +", " ", output) + output = output.strip() + + return output + + @staticmethod def set_partymon2(): """ This causes corruption, so it's not working yet. @@ -621,3 +809,31 @@ class crystal: set_memory(memory) +class TestEmulator(unittest.TestCase): + state = load_state("cheating-12") + + def setUp(self): + load_rom() + set_state(self.state) + + def tearDown(self): + shutdown() + + def test_PlaceString(self): + call(0, 0x1078) + + # where to draw the text + registers["hl"] = 0xc4a0 + + # what text to read from + registers["de"] = 0x1276 + + nstep(10) + + text = crystal.get_text() + + self.assertTrue("TRAINER" in text) + +if __name__ == "__main__": + unittest.main() + @@ -85,7 +85,6 @@ DelayFrames: ; 0x468 ret ; 0x46f - RTC: ; 46f ; update time and time-sensitive palettes @@ -2245,16 +2244,50 @@ PushScriptPointer: ; 261f ret ; 2631 -INCBIN "baserom.gbc",$2631,$26ef - $2631 +INCBIN "baserom.gbc",$2631,$26d4 - $2631 + +GetScriptByte: ; 0x26d4 +; Return byte at ScriptBank:ScriptPos in a. + + push hl + push bc + + ld a, [$ff9d] + push af + + ld a, [ScriptBank] + rst Bankswitch + + ld hl, ScriptPos + ld c, [hl] + inc hl + ld b, [hl] + + ld a, [bc] + + inc bc + ld [hl], b + dec hl + ld [hl], c + + ld b, a + pop af + rst Bankswitch + ld a, b + + pop bc + pop hl + ret +; 0x26ef ObjectEvent: ; 0x26ef jumptextfaceplayer ObjectEventText ; 0x26f2 - ObjectEventText: TX_FAR _ObjectEventText db "@" +; 0x26f7 INCBIN "baserom.gbc",$26f7,$2bed-$26f7 @@ -2289,6 +2322,7 @@ GetMapHeaderPointer: ; 0x2bed ld a, OlivineGym_MapHeader - OlivinePokeCenter1F_MapHeader call AddNTimes ret +; 0x2c04 GetMapHeaderMember: ; 0x2c04 ; Extract data from the current map's header. diff --git a/scripting.asm b/scripting.asm index dd4453bbf..b029b7865 100644 --- a/scripting.asm +++ b/scripting.asm @@ -1,188 +1,204 @@ ScriptCommandTable: ; 0x96cb1 - dw Script_2call - dw Script_3call - dw Script_2ptcall - dw Script_2jump - dw Script_3jump - dw Script_2ptjump - dw Script_if_equal - dw Script_if_not_equal - dw Script_iffalse - dw Script_iftrue - dw Script_if_less_than - dw Script_if_greater_than - dw Script_jumpstd - dw Script_callstd - dw Script_3callasm - dw Script_special - dw Script_2ptcallasm - dw Script_checkmaptriggers - dw Script_domaptrigger - dw Script_checktriggers - dw Script_dotrigger - dw Script_writebyte - dw Script_addvar - dw Script_random - dw Script_checkver - dw Script_copybytetovar - dw Script_copyvartobyte - dw Script_loadvar - dw Script_checkcode - dw Script_writevarcode - dw Script_writecode - dw Script_giveitem - dw Script_takeitem - dw Script_checkitem - dw Script_givemoney - dw Script_takemoney - dw Script_checkmoney - dw Script_givecoins - dw Script_takecoins - dw Script_checkcoins - dw Script_addcellnum - dw Script_delcellnum - dw Script_checkcellnum - dw Script_checktime - dw Script_checkpoke - dw Script_givepoke - dw Script_giveegg - dw Script_givepokeitem - dw Script_checkpokeitem - dw Script_checkbit1 - dw Script_clearbit1 - dw Script_setbit1 - dw Script_checkbit2 - dw Script_clearbit2 - dw Script_setbit2 - dw Script_wildoff - dw Script_wildon - dw Script_xycompare - dw Script_warpmod - dw Script_blackoutmod - dw Script_warp - dw Script_readmoney - dw Script_readcoins - dw Script_RAM2MEM - dw Script_pokenamemem - dw Script_itemtotext - dw Script_mapnametotext - dw Script_trainertotext - dw Script_stringtotext - dw Script_itemnotify - dw Script_pocketisfull - dw Script_loadfont - dw Script_refreshscreen - dw Script_loadmovesprites - dw Script_loadbytec1ce - dw Script_3writetext - dw Script_2writetext - dw Script_repeattext - dw Script_yesorno - dw Script_loadmenudata - dw Script_writebackup - dw Script_jumptextfaceplayer - dw Script_3jumptext - dw Script_jumptext - dw Script_closetext - dw Script_keeptextopen - dw Script_pokepic - dw Script_pokepicyesorno - dw Script_interpretmenu - dw Script_interpretmenu2 - dw Script_loadpikachudata - dw Script_battlecheck - dw Script_loadtrainerdata - dw Script_loadpokedata - dw Script_loadtrainer - dw Script_startbattle - dw Script_returnafterbattle - dw Script_catchtutorial - dw Script_trainertext - dw Script_trainerstatus - dw Script_winlosstext - dw Script_scripttalkafter - dw Script_talkaftercancel - dw Script_talkaftercheck - dw Script_setlasttalked - dw Script_applymovement - dw Script_applymovement2 - dw Script_faceplayer - dw Script_faceperson - dw Script_variablesprite - dw Script_disappear - dw Script_appear - dw Script_follow - dw Script_stopfollow - dw Script_moveperson - dw Script_writepersonxy - dw Script_loademote - dw Script_showemote - dw Script_spriteface - dw Script_follownotexact - dw Script_earthquake - dw Script_changemap - dw Script_changeblock - dw Script_reloadmap - dw Script_reloadmappart - dw Script_writecmdqueue - dw Script_delcmdqueue - dw Script_playmusic - dw Script_playrammusic - dw Script_musicfadeout - dw Script_playmapmusic - dw Script_reloadmapmusic - dw Script_cry - dw Script_playsound - dw Script_waitbutton - dw Script_warpsound - dw Script_specialsound - dw Script_passtoengine - dw Script_newloadmap - dw Script_pause - dw Script_deactivatefacing - dw Script_priorityjump - dw Script_warpcheck - dw Script_ptpriorityjump - dw Script_return - dw Script_end - dw Script_reloadandreturn - dw Script_resetfuncs - dw Script_pokemart - dw Script_elevator - dw Script_trade - dw Script_askforphonenumber - dw Script_phonecall - dw Script_hangup - dw Script_describedecoration - dw Script_fruittree - dw Script_specialphonecall - dw Script_checkphonecall - dw Script_verbosegiveitem - dw Script_verbosegiveitem2 - dw Script_loadwilddata - dw Script_halloffame - dw Script_credits - dw Script_warpfacing - dw Script_storetext - dw Script_displaylocation - dw Script_unknown0xa6 - dw Script_unknown0xa7 - dw Script_unknown0xa8 - dw Script_unknown0xa9 + dw Script_2call + dw Script_3call + dw Script_2ptcall + dw Script_2jump + dw Script_3jump + dw Script_2ptjump + dw Script_if_equal + dw Script_if_not_equal + dw Script_iffalse + dw Script_iftrue + dw Script_if_less_than + dw Script_if_greater_than + dw Script_jumpstd + dw Script_callstd + dw Script_3callasm + dw Script_special + dw Script_2ptcallasm + dw Script_checkmaptriggers + dw Script_domaptrigger + dw Script_checktriggers + dw Script_dotrigger + dw Script_writebyte + dw Script_addvar + dw Script_random + dw Script_checkver + dw Script_copybytetovar + dw Script_copyvartobyte + dw Script_loadvar + dw Script_checkcode + dw Script_writevarcode + dw Script_writecode + dw Script_giveitem + dw Script_takeitem + dw Script_checkitem + dw Script_givemoney + dw Script_takemoney + dw Script_checkmoney + dw Script_givecoins + dw Script_takecoins + dw Script_checkcoins + dw Script_addcellnum + dw Script_delcellnum + dw Script_checkcellnum + dw Script_checktime + dw Script_checkpoke + dw Script_givepoke + dw Script_giveegg + dw Script_givepokeitem + dw Script_checkpokeitem + dw Script_checkbit1 + dw Script_clearbit1 + dw Script_setbit1 + dw Script_checkbit2 + dw Script_clearbit2 + dw Script_setbit2 + dw Script_wildoff + dw Script_wildon + dw Script_xycompare + dw Script_warpmod + dw Script_blackoutmod + dw Script_warp + dw Script_readmoney + dw Script_readcoins + dw Script_RAM2MEM + dw Script_pokenamemem + dw Script_itemtotext + dw Script_mapnametotext + dw Script_trainertotext + dw Script_stringtotext + dw Script_itemnotify + dw Script_pocketisfull + dw Script_loadfont + dw Script_refreshscreen + dw Script_loadmovesprites + dw Script_loadbytec1ce + dw Script_3writetext + dw Script_2writetext + dw Script_repeattext + dw Script_yesorno + dw Script_loadmenudata + dw Script_writebackup + dw Script_jumptextfaceplayer + dw Script_3jumptext + dw Script_jumptext + dw Script_closetext + dw Script_keeptextopen + dw Script_pokepic + dw Script_pokepicyesorno + dw Script_interpretmenu + dw Script_interpretmenu2 + dw Script_loadpikachudata + dw Script_battlecheck + dw Script_loadtrainerdata + dw Script_loadpokedata + dw Script_loadtrainer + dw Script_startbattle + dw Script_returnafterbattle + dw Script_catchtutorial + dw Script_trainertext + dw Script_trainerstatus + dw Script_winlosstext + dw Script_scripttalkafter + dw Script_talkaftercancel + dw Script_talkaftercheck + dw Script_setlasttalked + dw Script_applymovement + dw Script_applymovement2 + dw Script_faceplayer + dw Script_faceperson + dw Script_variablesprite + dw Script_disappear + dw Script_appear + dw Script_follow + dw Script_stopfollow + dw Script_moveperson + dw Script_writepersonxy + dw Script_loademote + dw Script_showemote + dw Script_spriteface + dw Script_follownotexact + dw Script_earthquake + dw Script_changemap + dw Script_changeblock + dw Script_reloadmap + dw Script_reloadmappart + dw Script_writecmdqueue + dw Script_delcmdqueue + dw Script_playmusic + dw Script_playrammusic + dw Script_musicfadeout + dw Script_playmapmusic + dw Script_reloadmapmusic + dw Script_cry + dw Script_playsound + dw Script_waitbutton + dw Script_warpsound + dw Script_specialsound + dw Script_passtoengine + dw Script_newloadmap + dw Script_pause + dw Script_deactivatefacing + dw Script_priorityjump + dw Script_warpcheck + dw Script_ptpriorityjump + dw Script_return + dw Script_end + dw Script_reloadandreturn + dw Script_resetfuncs + dw Script_pokemart + dw Script_elevator + dw Script_trade + dw Script_askforphonenumber + dw Script_phonecall + dw Script_hangup + dw Script_describedecoration + dw Script_fruittree + dw Script_specialphonecall + dw Script_checkphonecall + dw Script_verbosegiveitem + dw Script_verbosegiveitem2 + dw Script_loadwilddata + dw Script_halloffame + dw Script_credits + dw Script_warpfacing + dw Script_storetext + dw Script_displaylocation + dw Script_unknown0xa6 + dw Script_unknown0xa7 + dw Script_unknown0xa8 + dw Script_unknown0xa9 ; 0x96e05 -INCBIN "baserom.gbc",$96e05,$96e17 - $96e05 +Unknown_0x96e05: ; 0x96e05 + ld hl, $d434 + set 2, [hl] + ret +; 0x96e0b + +Unknown_0x96e0b: ; 0x96e0b + ld hl, $d434 + bit 2, [hl] + ret +; 0x96e11 + +Unknown_0x96e11: ; 0x96e11 + ld hl, $d434 + res 2, [hl] + ret +; 0x96e17 Script_3callasm: ; 0x96e17 ; script command 0xe ; parameters: ; asm (AsmPointerParam) - call $26d4 + call GetScriptByte ld b, a - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a ld a, b rst $8 @@ -194,9 +210,9 @@ Script_special: ; 0x96e26 ; parameters: ; predefined_script (MultiByteParam) - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a ld a, $3 ld hl, $401b @@ -209,9 +225,9 @@ Script_2ptcallasm: ; 0x96e35 ; parameters: ; asm (PointerToAsmPointerParam) - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a ld b, [hl] inc hl @@ -228,11 +244,11 @@ Script_jumptextfaceplayer: ; 0x96e45 ; parameters: ; text_pointer (RawTextPointerLabelParam) - ld a, [$d439] + ld a, [ScriptBank] ld [$d44e], a - call $26d4 + call GetScriptByte ld [$d44f], a - call $26d4 + call GetScriptByte ld [$d450], a ld b, $25 ld hl, $6e79 @@ -244,11 +260,11 @@ Script_jumptext: ; 0x96e5f ; parameters: ; text_pointer (RawTextPointerLabelParam) - ld a, [$d439] + ld a, [ScriptBank] ld [$d44e], a - call $26d4 + call GetScriptByte ld [$d44f], a - call $26d4 + call GetScriptByte ld [$d450], a ld b, $25 ld hl, $6e7a @@ -262,11 +278,11 @@ Script_3jumptext: ; 0x96e81 ; parameters: ; text_pointer (PointerLabelBeforeBank) - call $26d4 + call GetScriptByte ld [$d44e], a - call $26d4 + call GetScriptByte ld [$d44f], a - call $26d4 + call GetScriptByte ld [$d450], a ld b, $25 ld hl, $6e7a @@ -278,11 +294,11 @@ Script_2writetext: ; 0x96e9b ; parameters: ; text_pointer (RawTextPointerLabelParam) - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a - ld a, [$d439] + ld a, [ScriptBank] ld b, a call $269a ret @@ -293,11 +309,11 @@ Script_3writetext: ; 0x96eab ; parameters: ; text_pointer (PointerLabelBeforeBank) - call $26d4 + call GetScriptByte ld b, a - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a call $269a ret @@ -309,9 +325,9 @@ Script_repeattext: ; 0x96ebb ; byte (SingleByteParam) ; byte (SingleByteParam) - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a cp $ff jr nz, .asm_96ed8 ; 0x96ec5 $11 @@ -367,12 +383,12 @@ Script_loadmenudata: ; 0x96efa ; parameters: ; data (MenuDataPointerParam) - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a ld de, $1d35 - ld a, [$d439] + ld a, [ScriptBank] call $26b7 call $1ad2 ret @@ -391,7 +407,7 @@ Script_pokepic: ; 0x96f16 ; parameters: ; pokemon (PokemonParam) - call $26d4 + call GetScriptByte and a jr nz, .asm_96f1f ; 0x96f1a $3 ld a, [$c2dd] @@ -415,7 +431,7 @@ Script_pokepicyesorno: ; 0x96f29 Script_interpretmenu2: ; 0x96f30 ; script command 0x59 - ld a, [$d439] + ld a, [ScriptBank] ld hl, $1d81 rst $8 ld a, [$cfa9] @@ -429,7 +445,7 @@ Script_interpretmenu2: ; 0x96f30 Script_interpretmenu: ; 0x96f41 ; script command 0x58 - ld a, [$d439] + ld a, [ScriptBank] ld hl, $202a rst $8 ld a, [$cf88] @@ -447,7 +463,7 @@ Script_storetext: ; 0x96f52 ; memory (SingleByteParam) call $106c - call $26d4 + call GetScriptByte ld c, a ld a, $47 ld hl, $4000 @@ -479,13 +495,13 @@ Script_verbosegiveitem2: ; 0x96f8e ; item (ItemLabelByte) ; var (SingleByteParam) - call $26d4 + call GetScriptByte cp $ff jr nz, .asm_96f98 ; 0x96f93 $3 ld a, [$c2dd] .asm_96f98 ld [$d106], a - call $26d4 + call GetScriptByte call $769e ld a, [de] ld [$d10c], a @@ -552,13 +568,13 @@ Script_pokemart: ; 0x97065 ; dialog_id (SingleByteParam) ; mart_id (MultiByteParam) - call $26d4 + call GetScriptByte ld c, a - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a - ld a, [$d439] + ld a, [ScriptBank] ld b, a ld a, $5 ld hl, $5a45 @@ -573,11 +589,11 @@ Script_elevator: ; 0x9707c xor a ld [$c2dd], a - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a - ld a, [$d439] + ld a, [ScriptBank] ld b, a ld a, $4 ld hl, $742d @@ -593,7 +609,7 @@ Script_trade: ; 0x97099 ; parameters: ; trade_id (SingleByteParam) - call $26d4 + call GetScriptByte ld e, a ld a, $3f ld hl, $4ba8 @@ -606,11 +622,11 @@ Script_phonecall: ; 0x970a4 ; parameters: ; caller_name (RawTextPointerLabelParam) - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a - ld a, [$d439] + ld a, [ScriptBank] ld b, a ld a, $24 ld hl, $429a @@ -634,7 +650,7 @@ Script_askforphonenumber: ; 0x970be call $1dcf jr c, .asm_970d6 ; 0x970c1 $13 - call $26d4 + call GetScriptByte ld c, a ld a, $24 ld hl, $4000 @@ -646,7 +662,7 @@ Script_askforphonenumber: ; 0x970be ld a, $1 jr .asm_970db ; 0x970d4 $5 .asm_970d6 - call $26d4 + call GetScriptByte ld a, $2 .asm_970db ld [$c2dd], a @@ -658,7 +674,7 @@ Script_describedecoration: ; 0x970df ; parameters: ; byte (SingleByteParam) - call $26d4 + call GetScriptByte ld b, a ld a, $9 ld hl, $6f59 @@ -673,7 +689,7 @@ Script_fruittree: ; 0x970ee ; parameters: ; tree_id (SingleByteParam) - call $26d4 + call GetScriptByte ld [$d03e], a ld b, $11 ld hl, $4000 @@ -686,11 +702,11 @@ Script_loadwilddata: ; 0x970fc ; map_group (MapGroupParam) ; map_id (MapIdParam) - call $26d4 + call GetScriptByte ld c, a - call $26d4 + call GetScriptByte ld d, a - call $26d4 + call GetScriptByte ld e, a ld a, $3 ld hl, $4403 @@ -703,7 +719,7 @@ Script_trainertext: ; 0x9710f ; parameters: ; which_text (SingleByteParam) - call $26d4 + call GetScriptByte ld c, a ld b, $0 ld hl, $d045 @@ -741,7 +757,7 @@ Script_trainerstatus: ; 0x97132 ld e, [hl] inc hl ld d, [hl] - call $26d4 + call GetScriptByte ld b, a call BitTable1Func ld a, c @@ -759,14 +775,14 @@ Script_winlosstext: ; 0x9714c ; loss_text_pointer (TextPointerLabelParam) ld hl, $d047 - call $26d4 + call GetScriptByte ld [hli], a - call $26d4 + call GetScriptByte ld [hli], a ld hl, $d049 - call $26d4 + call GetScriptByte ld [hli], a - call $26d4 + call GetScriptByte ld [hli], a ret ; 0x97163 @@ -821,9 +837,9 @@ Script_playmusic: ; 0x97189 xor a ld [$c2a7], a call MaxVolume - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a call StartMusic ret @@ -835,11 +851,11 @@ Script_musicfadeout: ; 0x971a2 ; music (MultiByteParam) ; fadetime (SingleByteParam) - call $26d4 + call GetScriptByte ld [$c2a9], a - call $26d4 + call GetScriptByte ld [$c2aa], a - call $26d4 + call GetScriptByte and $7f ld [$c2a7], a ret @@ -850,9 +866,9 @@ Script_playsound: ; 0x971b7 ; parameters: ; sound_pointer (MultiByteParam) - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a call StartSFX ret @@ -880,9 +896,9 @@ Script_cry: ; 0x971d1 ; parameters: ; cry_id (MultiByteParam) - call $26d4 + call GetScriptByte push af - call $26d4 + call GetScriptByte pop af and a jr nz, .asm_971df ; 0x971da $3 @@ -892,15 +908,22 @@ Script_cry: ; 0x971d1 ret ; 0x971e3 -INCBIN "baserom.gbc",$971e3,$971ea - $971e3 +Unknown_0x971e3: ; 0x971e3 + and a + ret z + cp $fe + ret z + dec a + ret +; 0x971ea Script_setlasttalked: ; 0x971ea ; script command 0x68 ; parameters: ; person (SingleByteParam) - call $26d4 - call $71e3 + call GetScriptByte + call Unknown_0x971e3 ld [$ffe0], a ret ; 0x971f3 @@ -911,8 +934,8 @@ Script_applymovement: ; 0x971f3 ; person (SingleByteParam) ; data (MovementPointerLabelParam) - call $26d4 - call $71e3 + call GetScriptByte + call Unknown_0x971e3 ld c, a push bc ld a, c @@ -923,21 +946,26 @@ Script_applymovement: ; 0x971f3 push bc call $7221 pop bc - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a - ld a, [$d439] + ld a, [ScriptBank] ld b, a call $26c7 ret c ld a, $2 ld [$d437], a - call $6e11 + call Unknown_0x96e11 ret ; 0x97221 -INCBIN "baserom.gbc",$97221,$97228 - $97221 +Unknown_0x97221: ; 0x97221 + ld a, $1 + ld hl, $5897 + rst $8 + ret +; 0x97228 Script_applymovement2: ; 0x97228 ; script command 0x6a @@ -977,15 +1005,15 @@ Script_faceperson: ; 0x97248 ; person1 (SingleByteParam) ; person2 (SingleByteParam) - call $26d4 - call $71e3 + call GetScriptByte + call Unknown_0x971e3 cp $fe jr c, .asm_97254 ; 0x97250 $2 ld a, [$ffe0] .asm_97254 ld e, a - call $26d4 - call $71e3 + call GetScriptByte + call Unknown_0x971e3 cp $fe jr nz, .asm_97261 ; 0x9725d $2 ld a, [$ffe0] @@ -1012,14 +1040,14 @@ Script_spriteface: ; 0x97274 ; person (SingleByteParam) ; facing (SingleByteParam) - call $26d4 - call $71e3 + call GetScriptByte + call Unknown_0x971e3 cp $fe jr nz, .asm_97280 ; 0x9727c $2 ld a, [$ffe0] .asm_97280 ld d, a - call $26d4 + call GetScriptByte add a add a ld e, a @@ -1027,7 +1055,51 @@ Script_spriteface: ; 0x97274 ret ; 0x9728b -INCBIN "baserom.gbc",$9728b,$972ce - $9728b +Unknown_0x9728b: ; 0x9728b + ld a, d + push de + call $18de + jr c, .asm_972b9 ; 0x97290 $27 + ld hl, $0000 + add hl, bc + ld a, [hl] + push bc + call $1836 + pop bc + jr c, .asm_972b9 ; 0x9729c $1b + ld hl, $0004 + add hl, bc + bit 2, [hl] + jr nz, .asm_972b9 ; 0x972a4 $13 + pop de + ld a, e + call $1af8 + ld hl, $d0ed + bit 6, [hl] + jr nz, .asm_972b5 ; 0x972b0 $3 + call $72bc +.asm_972b5 + call $1ad2 + ret +.asm_972b9 + pop de + scf + ret +; 0x972bc + +Unknown_0x972bc: ; 0x972bc + call $217a + ld hl, $c4a0 + ld bc, $0168 +.asm_972c5 + res 7, [hl] + inc hl + dec bc + ld a, b + or c + jr nz, .asm_972c5 ; 0x972cb $f8 + ret +; 0x972ce Script_variablesprite: ; 0x972ce ; script command 0x6d @@ -1035,12 +1107,12 @@ Script_variablesprite: ; 0x972ce ; byte (SingleByteParam) ; sprite (SingleByteParam) - call $26d4 + call GetScriptByte ld e, a ld d, $0 ld hl, $d82e add hl, de - call $26d4 + call GetScriptByte ld [hl], a ret ; 0x972dd @@ -1050,8 +1122,8 @@ Script_appear: ; 0x972dd ; parameters: ; person (SingleByteParam) - call $26d4 - call $71e3 + call GetScriptByte + call Unknown_0x971e3 call $1956 ld a, [$ffaf] ld b, $0 @@ -1064,8 +1136,8 @@ Script_disappear: ; 0x972ee ; parameters: ; person (SingleByteParam) - call $26d4 - call $71e3 + call GetScriptByte + call Unknown_0x971e3 cp $fe jr nz, .asm_972fa ; 0x972f6 $2 ld a, [$ffe0] @@ -1080,7 +1152,26 @@ Script_disappear: ; 0x972ee ret ; 0x9730b -INCBIN "baserom.gbc",$9730b,$97325 - $9730b +Unknown_0x9730b: ; 0x9730b + push bc + call $18d2 + ld hl, $000c + add hl, bc + pop bc + ld e, [hl] + inc hl + ld d, [hl] + ld a, $ff + cp e + jr nz, .asm_97321 ; 0x9731a $5 + cp d + jr nz, .asm_97321 ; 0x9731d $2 + xor a + ret +.asm_97321 + call BitTable1Func + ret +; 0x97325 Script_follow: ; 0x97325 ; script command 0x70 @@ -1088,11 +1179,11 @@ Script_follow: ; 0x97325 ; person2 (SingleByteParam) ; person1 (SingleByteParam) - call $26d4 - call $71e3 + call GetScriptByte + call Unknown_0x971e3 ld b, a - call $26d4 - call $71e3 + call GetScriptByte + call Unknown_0x971e3 ld c, a ld a, $1 ld hl, $5803 @@ -1116,13 +1207,13 @@ Script_moveperson: ; 0x97341 ; x (SingleByteParam) ; y (SingleByteParam) - call $26d4 - call $71e3 + call GetScriptByte + call Unknown_0x971e3 ld b, a - call $26d4 + call GetScriptByte add $4 ld d, a - call $26d4 + call GetScriptByte add $4 ld e, a ld a, $2 @@ -1136,8 +1227,8 @@ Script_writepersonxy: ; 0x9735b ; parameters: ; person (SingleByteParam) - call $26d4 - call $71e3 + call GetScriptByte + call Unknown_0x971e3 cp $fe jr nz, .asm_97367 ; 0x97363 $2 ld a, [$ffe0] @@ -1155,11 +1246,11 @@ Script_follownotexact: ; 0x9736f ; person2 (SingleByteParam) ; person1 (SingleByteParam) - call $26d4 - call $71e3 + call GetScriptByte + call Unknown_0x971e3 ld b, a - call $26d4 - call $71e3 + call GetScriptByte + call Unknown_0x971e3 ld c, a ld a, $2 ld hl, $439e @@ -1172,7 +1263,7 @@ Script_loademote: ; 0x97384 ; parameters: ; bubble (SingleByteParam) - call $26d4 + call GetScriptByte cp $ff jr nz, .asm_9738e ; 0x97389 $3 ld a, [$c2dd] @@ -1191,15 +1282,15 @@ Script_showemote: ; 0x97396 ; person (SingleByteParam) ; time (DecimalParam) - call $26d4 + call GetScriptByte ld [$c2dd], a - call $26d4 - call $71e3 + call GetScriptByte + call Unknown_0x971e3 cp $fe jr z, .asm_973a8 ; 0x973a4 $2 ld [$ffe0], a .asm_973a8 - call $26d4 + call GetScriptByte ld [$d44d], a ld b, $25 ld de, $73b6 @@ -1217,7 +1308,7 @@ Script_earthquake: ; 0x973c7 ld de, $d002 ld bc, $0005 call CopyBytes - call $26d4 + call GetScriptByte ld [$d003], a and $3f ld [$d005], a @@ -1266,9 +1357,9 @@ Script_loadpokedata: ; 0x97412 ld a, $80 ld [$d459], a - call $26d4 + call GetScriptByte ld [$d22e], a - call $26d4 + call GetScriptByte ld [$d143], a ret ; 0x97424 @@ -1281,9 +1372,9 @@ Script_loadtrainer: ; 0x97424 ld a, $81 ld [$d459], a - call $26d4 + call GetScriptByte ld [$d22f], a - call $26d4 + call GetScriptByte ld [$d231], a ret ; 0x97436 @@ -1305,7 +1396,7 @@ Script_catchtutorial: ; 0x97447 ; parameters: ; byte (SingleByteParam) - call $26d4 + call GetScriptByte ld [$d230], a call $2879 ld a, $13 @@ -1356,7 +1447,7 @@ Script_reloadmap: ; 0x97491 ld [$ff9f], a ld a, $1 call $261b - call $6e11 + call Unknown_0x96e11 ret ; 0x974a2 @@ -1365,11 +1456,11 @@ Script_2call: ; 0x974a2 ; parameters: ; pointer (ScriptPointerLabelParam) - ld a, [$d439] + ld a, [ScriptBank] ld b, a - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a jr ScriptCall ; 0x974b0 @@ -1379,11 +1470,11 @@ Script_3call: ; 0x974b0 ; parameters: ; pointer (ScriptPointerLabelBeforeBank) - call $26d4 + call GetScriptByte ld b, a - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a jr ScriptCall ; 0x974be @@ -1393,9 +1484,9 @@ Script_2ptcall: ; 0x974be ; parameters: ; pointer (PointerLabelToScriptPointer) - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a ld b, [hl] inc hl @@ -1415,33 +1506,38 @@ ScriptCall: ; 0x974cb add hl, de add hl, de pop de - ld a, [$d439] + ld a, [ScriptBank] ld [hli], a - ld a, [$d43a] + ld a, [ScriptPos] ld [hli], a ld a, [$d43b] ld [hl], a ld a, b - ld [$d439], a + ld [ScriptBank], a ld a, e - ld [$d43a], a + ld [ScriptPos], a ld a, d ld [$d43b], a ret ; 0x974f3 -INCBIN "baserom.gbc",$974f3,$974fe - $974f3 +Unknown_0x974f3: ; 0x974f3 + ld a, [ScriptBank] + or $80 + ld [ScriptBank], a + jp $74cb +; 0x974fe Script_2jump: ; 0x974fe ; script command 0x3 ; parameters: ; pointer (ScriptPointerLabelParam) - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a - ld a, [$d439] + ld a, [ScriptBank] ld b, a jp $759d ; 0x9750d @@ -1451,11 +1547,11 @@ Script_3jump: ; 0x9750d ; parameters: ; pointer (ScriptPointerLabelBeforeBank) - call $26d4 + call GetScriptByte ld b, a - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a jp $759d ; 0x9751c @@ -1465,9 +1561,9 @@ Script_2ptjump: ; 0x9751c ; parameters: ; pointer (PointerLabelToScriptPointer) - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a ld b, [hl] inc hl @@ -1505,7 +1601,7 @@ Script_if_equal: ; 0x97540 ; byte (SingleByteParam) ; pointer (ScriptPointerLabelParam) - call $26d4 + call GetScriptByte ld hl, $c2dd cp [hl] jr z, Script_2jump ; 0x97547 $b5 @@ -1518,7 +1614,7 @@ Script_if_not_equal: ; 0x9754b ; byte (SingleByteParam) ; pointer (ScriptPointerLabelParam) - call $26d4 + call GetScriptByte ld hl, $c2dd cp [hl] jr nz, Script_2jump ; 0x97552 $aa @@ -1533,7 +1629,7 @@ Script_if_less_than: ; 0x97556 ld a, [$c2dd] ld b, a - call $26d4 + call GetScriptByte cp b jr c, Script_2jump ; 0x9755e $9e jr Unknown_97596 ; 0x97560 $34 @@ -1545,7 +1641,7 @@ Script_if_greater_than: ; 0x97562 ; byte (SingleByteParam) ; pointer (ScriptPointerLabelParam) - call $26d4 + call GetScriptByte ld b, a ld a, [$c2dd] cp b @@ -1573,22 +1669,38 @@ Script_callstd: ; 0x97573 jp $74cb ; 0x9757b -INCBIN "baserom.gbc",$9757b,$97596 - $9757b +Unknown_0x9757b: ; 0x9757b + call GetScriptByte + ld e, a + call GetScriptByte + ld d, a + ld hl, $4000 + add hl, de + add hl, de + add hl, de + ld a, $2f + call GetFarByte + ld b, a + inc hl + ld a, $2f + call GetFarHalfword + ret +; 0x97596 Unknown_97596: ; 0x97596 - call $26d4 - call $26d4 - ret + call GetScriptByte + call GetScriptByte + ret ; 0x9759d Unknown_9759d: ; 0x9759d - ld a, b - ld [$d439], a - ld a, l - ld [$d43a], a - ld a, h - ld [$d43b], a - ret + ld a, b + ld [ScriptBank], a + ld a, l + ld [ScriptPos], a + ld a, h + ld [$d43b], a + ret ; 0x975aa Script_priorityjump: ; 0x975aa @@ -1596,11 +1708,11 @@ Script_priorityjump: ; 0x975aa ; parameters: ; pointer (ScriptPointerLabelParam) - ld a, [$d439] + ld a, [ScriptBank] ld [$d44e], a - call $26d4 + call GetScriptByte ld [$d44f], a - call $26d4 + call GetScriptByte ld [$d450], a ld hl, $d434 set 3, [hl] @@ -1626,9 +1738,9 @@ Script_checkmaptriggers: ; 0x975d1 ; map_group (SingleByteParam) ; map_id (SingleByteParam) - call $26d4 + call GetScriptByte ld b, a - call $26d4 + call GetScriptByte ld c, a call $2147 ld a, d @@ -1662,9 +1774,9 @@ Script_domaptrigger: ; 0x975f5 ; map_id (MapIdParam) ; trigger_id (SingleByteParam) - call $26d4 + call GetScriptByte ld b, a - call $26d4 + call GetScriptByte ld c, a ; fallthrough @@ -1673,7 +1785,7 @@ Unknown_975fd: ; 0x975fd ld a, d or e jr z, .asm_97608 ; 0x97602 $4 - call $26d4 + call GetScriptByte ld [de], a .asm_97608 ret @@ -1684,9 +1796,9 @@ Script_copybytetovar: ; 0x97609 ; parameters: ; address (RAMAddressParam) - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a ld a, [hl] ld [$c2dd], a @@ -1698,9 +1810,9 @@ Script_copyvartobyte: ; 0x97616 ; parameters: ; address (RAMAddressParam) - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a ld a, [$c2dd] ld [hl], a @@ -1713,11 +1825,11 @@ Script_loadvar: ; 0x97623 ; address (RAMAddressParam) ; value (SingleByteParam) - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a - call $26d4 + call GetScriptByte ld [hl], a ret ; 0x97630 @@ -1727,7 +1839,7 @@ Script_writebyte: ; 0x97630 ; parameters: ; value (SingleByteParam) - call $26d4 + call GetScriptByte ld [$c2dd], a ret ; 0x97637 @@ -1737,7 +1849,7 @@ Script_addvar: ; 0x97637 ; parameters: ; value (SingleByteParam) - call $26d4 + call GetScriptByte ld hl, $c2dd add [hl] ld [hl], a @@ -1749,7 +1861,7 @@ Script_random: ; 0x97640 ; parameters: ; input (SingleByteParam) - call $26d4 + call GetScriptByte ld [$c2dd], a and a ret z @@ -1784,14 +1896,25 @@ Script_random: ; 0x97640 ret ; 0x97673 -INCBIN "baserom.gbc",$97673,$9767d - $97673 +Unknown_0x97673: ; 0x97673 + xor a + ld b, a + sub c +.asm_97676 + inc b + sub c + jr nc, .asm_97676 ; 0x97678 $fc + dec b + add c + ret +; 0x9767d Script_checkcode: ; 0x9767d ; script command 0x1c ; parameters: ; variable_id (SingleByteParam) - call $26d4 + call GetScriptByte call $769e ld a, [de] ld [$c2dd], a @@ -1803,7 +1926,7 @@ Script_writevarcode: ; 0x97688 ; parameters: ; variable_id (SingleByteParam) - call $26d4 + call GetScriptByte call $769e ld a, [$c2dd] ld [de], a @@ -1816,14 +1939,20 @@ Script_writecode: ; 0x97693 ; variable_id (SingleByteParam) ; value (SingleByteParam) - call $26d4 + call GetScriptByte call $769e - call $26d4 + call GetScriptByte ld [de], a ret ; 0x9769e -INCBIN "baserom.gbc",$9769e,$976a6 - $9769e +Unknown_0x9769e: ; 0x9769e + ld c, a + ld a, $20 + ld hl, $4648 + rst $8 + ret +; 0x976a6 Script_checkver: ; 0x976a6 ; script command 0x18 @@ -1841,7 +1970,7 @@ Script_pokenamemem: ; 0x976ae ; pokemon (PokemonParam) ; memory (SingleByteParam) - call $26d4 + call GetScriptByte and a jr nz, .asm_976b7 ; 0x976b2 $3 ld a, [$c2dd] @@ -1851,7 +1980,7 @@ Script_pokenamemem: ; 0x976ae ld de, $d073 Unknown_976c0: ; 0x976c0 - call $26d4 + call GetScriptByte cp $3 jr c, .asm_976c8 ; 0x976c5 $1 xor a @@ -1869,7 +1998,7 @@ Script_itemtotext: ; 0x976d5 ; item (ItemLabelByte) ; memory (SingleByteParam) - call $26d4 + call GetScriptByte and a jr nz, .asm_976de ; 0x976d9 $3 ld a, [$c2dd] @@ -1905,7 +2034,7 @@ Script_displaylocation: ; 0x97701 ; parameters: ; id (SingleByteParam) - call $26d4 + call GetScriptByte jr Unknown_976f4 ; 0x97704 $ee ; 0x97706 @@ -1916,9 +2045,9 @@ Script_trainertotext: ; 0x97706 ; trainer_group (TrainerIdParam) ; memory (SingleByteParam) - call $26d4 + call GetScriptByte ld c, a - call $26d4 + call GetScriptByte ld b, a ld a, $e ld hl, $594c @@ -1929,11 +2058,11 @@ Script_trainertotext: ; 0x97706 Script_unknown0xa7: ; 0x97716 ; script command 0xa7 - call $26d4 + call GetScriptByte ld [$cf61], a Unknown_9771c: ; 0x9771c - call $26d4 + call GetScriptByte ld [$cf60], a call GetName ld de, $d073 @@ -1991,7 +2120,13 @@ Script_RAM2MEM: ; 0x9775c jp $76c0 ; 0x97771 -INCBIN "baserom.gbc",$97771,$9777d - $97771 +Unknown_0x97771: ; 0x97771 + ld hl, $d073 + ld bc, $000b + ld a, $50 + call ByteFill + ret +; 0x9777d Script_stringtotext: ; 0x9777d ; script command 0x44 @@ -1999,11 +2134,11 @@ Script_stringtotext: ; 0x9777d ; text_pointer (EncodedTextLabelParam) ; memory (SingleByteParam) - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a - ld a, [$d439] + ld a, [ScriptBank] ld hl, $30d6 rst $8 ld de, $d086 @@ -2015,18 +2150,18 @@ Script_givepokeitem: ; 0x97792 ; parameters: ; pointer (PointerParamToItemAndLetter) - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a - ld a, [$d439] + ld a, [ScriptBank] call GetFarByte ld b, a push bc inc hl ld bc, $0020 ld de, $d002 - ld a, [$d439] + ld a, [ScriptBank] call FarCopyBytes pop bc ld a, $11 @@ -2040,11 +2175,11 @@ Script_checkpokeitem: ; 0x977b7 ; parameters: ; pointer (PointerParamToItemAndLetter) - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a - ld a, [$d439] + ld a, [ScriptBank] ld b, a ld a, $11 ld hl, $4654 @@ -2058,13 +2193,13 @@ Script_giveitem: ; 0x977ca ; item (ItemLabelByte) ; quantity (SingleByteParam) - call $26d4 + call GetScriptByte cp $ff jr nz, .asm_977d4 ; 0x977cf $3 ld a, [$c2dd] .asm_977d4 ld [$d106], a - call $26d4 + call GetScriptByte ld [$d10c], a ld hl, $d892 call $2f66 @@ -2086,9 +2221,9 @@ Script_takeitem: ; 0x977f0 xor a ld [$c2dd], a - call $26d4 + call GetScriptByte ld [$d106], a - call $26d4 + call GetScriptByte ld [$d10c], a ld a, $ff ld [$d107], a @@ -2107,7 +2242,7 @@ Script_checkitem: ; 0x97812 xor a ld [$c2dd], a - call $26d4 + call GetScriptByte ld [$d106], a ld hl, $d892 call $2f79 @@ -2156,6 +2291,7 @@ Script_checkmoney: ; 0x97843 ld a, $5 ld hl, $600b rst $8 +; 0x9784f Unknown_9784f: ; 0x9784f jr c, .asm_9785b ; 0x9784f $a @@ -2172,7 +2308,29 @@ Unknown_9784f: ; 0x9784f ret ; 0x97861 -INCBIN "baserom.gbc",$97861,$97881 - $97861 +Unknown_0x97861: ; 0x97861 + call GetScriptByte + and a + ld de, $d84e + ret z + ld de, $d851 + ret +; 0x9786d + +Unknown_0x9786d: ; 0x9786d + ld bc, $ffc3 + push bc + call GetScriptByte + ld [bc], a + inc bc + call GetScriptByte + ld [bc], a + inc bc + call GetScriptByte + ld [bc], a + pop bc + ret +; 0x97881 Script_givecoins: ; 0x97881 ; script command 0x25 @@ -2208,9 +2366,9 @@ Script_checkcoins: ; 0x97895 ld hl, $60a1 rst $8 jr Unknown_9784f ; 0x9789e $af - call $26d4 + call GetScriptByte ld [$ffc4], a - call $26d4 + call GetScriptByte ld [$ffc3], a ld bc, $ffc3 ret @@ -2226,7 +2384,7 @@ Script_checktime: ; 0x978ae ld a, $3 ld hl, $4000 rst $8 - call $26d4 + call GetScriptByte and c ret z ld a, $1 @@ -2241,7 +2399,7 @@ Script_checkpoke: ; 0x978c3 xor a ld [$c2dd], a - call $26d4 + call GetScriptByte ld hl, $dcd8 ld de, $0001 call IsInArray @@ -2258,7 +2416,7 @@ Script_addcellnum: ; 0x978da xor a ld [$c2dd], a - call $26d4 + call GetScriptByte ld c, a ld a, $24 ld hl, $4000 @@ -2276,7 +2434,7 @@ Script_delcellnum: ; 0x978ef xor a ld [$c2dd], a - call $26d4 + call GetScriptByte ld c, a ld a, $24 ld hl, $400f @@ -2294,7 +2452,7 @@ Script_checkcellnum: ; 0x97904 xor a ld [$c2dd], a - call $26d4 + call GetScriptByte ld c, a ld a, $24 ld hl, $4019 @@ -2310,9 +2468,9 @@ Script_specialphonecall: ; 0x97919 ; parameters: ; call_id (MultiByteParam) - call $26d4 + call GetScriptByte ld [$dc31], a - call $26d4 + call GetScriptByte ld [$dc32], a ret ; 0x97926 @@ -2339,24 +2497,24 @@ Script_givepoke: ; 0x97932 ; trainer_name_pointer (MultiByteParam) ; pkmn_nickname (MultiByteParam) - call $26d4 + call GetScriptByte ld [$d108], a - call $26d4 + call GetScriptByte ld [$d143], a - call $26d4 + call GetScriptByte ld [$d106], a - call $26d4 + call GetScriptByte and a ld b, a jr z, .asm_9795d ; 0x97949 $12 - ld hl, $d43a + ld hl, ScriptPos ld e, [hl] inc hl ld d, [hl] - call $26d4 - call $26d4 - call $26d4 - call $26d4 + call GetScriptByte + call GetScriptByte + call GetScriptByte + call GetScriptByte .asm_9795d ld a, $3 ld hl, $6277 @@ -2375,9 +2533,9 @@ Script_giveegg: ; 0x97968 xor a ld [$c2dd], a ld [$cf5f], a - call $26d4 + call GetScriptByte ld [$d108], a - call $26d4 + call GetScriptByte ld [$d143], a ld a, $3 ld hl, $5f8c @@ -2393,9 +2551,9 @@ Script_setbit1: ; 0x97988 ; parameters: ; bit_number (MultiByteParam) - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a ld b, $1 call BitTable1Func @@ -2407,9 +2565,9 @@ Script_clearbit1: ; 0x97996 ; parameters: ; bit_number (MultiByteParam) - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a ld b, $0 call BitTable1Func @@ -2421,9 +2579,9 @@ Script_checkbit1: ; 0x979a4 ; parameters: ; bit_number (MultiByteParam) - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a ld b, $2 call BitTable1Func @@ -2441,9 +2599,9 @@ Script_setbit2: ; 0x979bb ; parameters: ; bit_number (MultiByteParam) - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a ld b, $1 call $79ee @@ -2455,9 +2613,9 @@ Script_clearbit2: ; 0x979c9 ; parameters: ; bit_number (MultiByteParam) - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a ld b, $0 call $79ee @@ -2469,9 +2627,9 @@ Script_checkbit2: ; 0x979d7 ; parameters: ; bit_number (MultiByteParam) - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a ld b, $2 call $79ee @@ -2484,7 +2642,12 @@ Script_checkbit2: ; 0x979d7 ret ; 0x979ee -INCBIN "baserom.gbc",$979ee,$979f5 - $979ee +Unknown_0x979ee: ; 0x979ee + ld a, $20 + ld hl, $4430 + rst $8 + ret +; 0x979f5 Script_wildon: ; 0x979f5 ; script command 0x38 @@ -2507,9 +2670,9 @@ Script_xycompare: ; 0x97a01 ; parameters: ; pointer (MultiByteParam) - call $26d4 + call GetScriptByte ld [$d453], a - call $26d4 + call GetScriptByte ld [$d454], a ret ; 0x97a0e @@ -2523,7 +2686,7 @@ Script_warpfacing: ; 0x97a0e ; x (SingleByteParam) ; y (SingleByteParam) - call $26d4 + call GetScriptByte and $3 ld c, a ld a, [$d45b] @@ -2540,15 +2703,15 @@ Script_warp: ; 0x97a1d ; x (SingleByteParam) ; y (SingleByteParam) - call $26d4 + call GetScriptByte and a jr z, .asm_97a4a ; 0x97a21 $27 ld [$dcb5], a - call $26d4 + call GetScriptByte ld [$dcb6], a - call $26d4 + call GetScriptByte ld [$dcb8], a - call $26d4 + call GetScriptByte ld [$dcb7], a ld a, $ff ld [$d001], a @@ -2556,19 +2719,19 @@ Script_warp: ; 0x97a1d ld [$ff9f], a ld a, $1 call $261b - call $6e11 + call Unknown_0x96e11 ret .asm_97a4a - call $26d4 - call $26d4 - call $26d4 + call GetScriptByte + call GetScriptByte + call GetScriptByte ld a, $ff ld [$d001], a ld a, $fb ld [$ff9f], a ld a, $1 call $261b - call $6e11 + call Unknown_0x96e11 ret ; 0x97a65 @@ -2579,11 +2742,11 @@ Script_warpmod: ; 0x97a65 ; map_group (MapGroupParam) ; map_id (MapIdParam) - call $26d4 + call GetScriptByte ld [$dcac], a - call $26d4 + call GetScriptByte ld [$dcad], a - call $26d4 + call GetScriptByte ld [$dcae], a ret ; 0x97a78 @@ -2594,9 +2757,9 @@ Script_blackoutmod: ; 0x97a78 ; map_group (MapGroupParam) ; map_id (MapIdParam) - call $26d4 + call GetScriptByte ld [$dcb2], a - call $26d4 + call GetScriptByte ld [$dcb3], a ret ; 0x97a85 @@ -2614,11 +2777,11 @@ Script_writecmdqueue: ; 0x97a8b ; parameters: ; queue_pointer (MultiByteParam) - call $26d4 + call GetScriptByte ld e, a - call $26d4 + call GetScriptByte ld d, a - ld a, [$d439] + ld a, [ScriptBank] ld b, a ld a, $25 ld hl, $7e31 @@ -2633,7 +2796,7 @@ Script_delcmdqueue: ; 0x97a9e xor a ld [$c2dd], a - call $26d4 + call GetScriptByte ld b, a ld a, $25 ld hl, $7e5c @@ -2649,11 +2812,11 @@ Script_changemap: ; 0x97ab3 ; parameters: ; map_data_pointer (MapDataPointerParam) - call $26d4 + call GetScriptByte ld [$d1a0], a - call $26d4 + call GetScriptByte ld [$d1a1], a - call $26d4 + call GetScriptByte ld [$d1a2], a call $24e4 call $2879 @@ -2667,14 +2830,14 @@ Script_changeblock: ; 0x97acc ; y (SingleByteParam) ; block (SingleByteParam) - call $26d4 + call GetScriptByte add $4 ld d, a - call $26d4 + call GetScriptByte add $4 ld e, a call $2a66 - call $26d4 + call GetScriptByte ld [hl], a call $2879 ret @@ -2705,18 +2868,23 @@ Script_warpcheck: ; 0x97af6 ret ; 0x97b01 -INCBIN "baserom.gbc",$97b01,$97b08 - $97b01 +Unknown_0x97b01: ; 0x97b01 + ld a, $25 + ld hl, $66d0 + rst $8 + ret +; 0x97b08 Script_newloadmap: ; 0x97b08 ; script command 0x8a ; parameters: ; which_method (SingleByteParam) - call $26d4 + call GetScriptByte ld [$ff9f], a ld a, $1 call $261b - call $6e11 + call Unknown_0x96e11 ret ; 0x97b16 @@ -2740,7 +2908,7 @@ Script_refreshscreen: ; 0x97b20 ; dummy (SingleByteParam) call $2dba - call $26d4 + call GetScriptByte ret ; 0x97b27 @@ -2749,7 +2917,7 @@ Script_loadbytec1ce: ; 0x97b27 ; parameters: ; byte (SingleByteParam) - call $26d4 + call GetScriptByte ld [$c2cf], a ret ; 0x97b2e @@ -2769,11 +2937,11 @@ Script_passtoengine: ; 0x97b36 ; parameters: ; data_pointer (PointerLabelBeforeBank) - call $26d4 + call GetScriptByte push af - call $26d4 + call GetScriptByte ld l, a - call $26d4 + call GetScriptByte ld h, a pop af call StartAutoInput @@ -2785,7 +2953,7 @@ Script_pause: ; 0x97b47 ; parameters: ; length (DecimalParam) - call $26d4 + call GetScriptByte and a jr z, .asm_97b50 ; 0x97b4b $3 ld [$d44d], a @@ -2803,14 +2971,14 @@ Script_deactivatefacing: ; 0x97b5c ; parameters: ; time (SingleByteParam) - call $26d4 + call GetScriptByte and a jr z, .asm_97b65 ; 0x97b60 $3 ld [$d44d], a .asm_97b65 ld a, $3 ld [$d437], a - call $6e11 + call Unknown_0x96e11 ret ; 0x97b6e @@ -2819,7 +2987,7 @@ Script_ptpriorityjump: ; 0x97b6e ; parameters: ; pointer (ScriptPointerLabelParam) - call $6e11 + call Unknown_0x96e11 jp Script_2jump ; 0x97b74 @@ -2836,7 +3004,7 @@ Script_end: ; 0x97b74 ld [$d437], a ld hl, $d434 res 0, [hl] - call $6e11 + call Unknown_0x96e11 ret ; 0x97b8c @@ -2848,11 +3016,38 @@ Script_return: ; 0x97b8c .asm_97b91 ld hl, $d434 res 0, [hl] - call $6e11 + call Unknown_0x96e11 ret ; 0x97b9a -INCBIN "baserom.gbc",$97b9a,$97bc0 - $97b9a +Unknown_0x97b9a: ; 0x97b9a + ld hl, $d43c + ld a, [hl] + and a + jr z, .asm_97bbe ; 0x97b9f $1d + dec [hl] + ld e, [hl] + ld d, $0 + ld hl, $d43d + add hl, de + add hl, de + add hl, de + ld a, [hli] + ld b, a + and $7f + ld [ScriptBank], a + ld a, [hli] + ld e, a + ld [ScriptPos], a + ld a, [hl] + ld d, a + ld [$d43b], a + and a + ret +.asm_97bbe + scf + ret +; 0x97bc0 Script_resetfuncs: ; 0x97bc0 ; script command 0x93 @@ -2864,7 +3059,7 @@ Script_resetfuncs: ; 0x97bc0 ld [$d437], a ld hl, $d434 res 0, [hl] - call $6e11 + call Unknown_0x96e11 ret ; 0x97bd5 @@ -2898,7 +3093,7 @@ DisplayCredits: call $7bc0 ld a, $3 call $261b - call $6e11 + call Unknown_0x96e11 ret ; 0x97c05 @@ -2908,7 +3103,7 @@ Script_unknown0xa8: ; 0x97c05 ; unknown (SingleByteParam) push bc - call $26d4 + call GetScriptByte .asm_97c09 push af ld c, $6 @@ -1115,6 +1115,12 @@ OTPartyMon5Nickname: ; d416 OTPartyMon6Nickname: ; d421 ds 11 +SECTION "Scripting",BSS[$d439] + +ScriptBank: ; d439 + ds 1 +ScriptPos: ; d43a + ds 2 SECTION "Player",BSS[$d472] PlayerGender: ; d472 |