diff options
author | Daniel Harding <33dannye@gmail.com> | 2020-05-09 15:47:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-09 15:47:34 -0500 |
commit | f3019aa045a2caaff8fee39a81c0dc2f75233837 (patch) | |
tree | 87cff8607c4017080d979c8f1b566fdd1dc722f0 /src | |
parent | 86d8cfb0fd86326e4534fc33c7bb384d515bbe0e (diff) | |
parent | 53bab0a246719227b1558dfce636e7d0b21d6db0 (diff) |
Merge branch 'master' into master
Diffstat (limited to 'src')
-rw-r--r-- | src/constants.asm | 4 | ||||
-rw-r--r-- | src/constants/duel_constants.asm | 7 | ||||
-rw-r--r-- | src/constants/event_constants.asm | 3 | ||||
-rw-r--r-- | src/constants/map_constants.asm | 17 | ||||
-rw-r--r-- | src/constants/misc_constants.asm | 5 | ||||
-rw-r--r-- | src/constants/npc_constants.asm | 154 | ||||
-rw-r--r-- | src/constants/script_constants.asm | 147 | ||||
-rw-r--r-- | src/data/map_objects.asm | 610 | ||||
-rw-r--r-- | src/data/map_scripts.asm | 158 | ||||
-rw-r--r-- | src/data/npc_map_data.asm | 419 | ||||
-rw-r--r-- | src/data/npcs.asm | 1334 | ||||
-rw-r--r-- | src/engine/bank01.asm | 4 | ||||
-rw-r--r-- | src/engine/bank02.asm | 37 | ||||
-rw-r--r-- | src/engine/bank03.asm | 4956 | ||||
-rw-r--r-- | src/engine/bank04.asm | 331 | ||||
-rw-r--r-- | src/engine/bank07.asm | 309 | ||||
-rw-r--r-- | src/engine/bank1c.asm | 4 | ||||
-rw-r--r-- | src/engine/bank20.asm | 238 | ||||
-rw-r--r-- | src/engine/home.asm | 148 | ||||
-rw-r--r-- | src/macros/code.asm | 36 | ||||
-rw-r--r-- | src/macros/constants.asm | 5 | ||||
-rw-r--r-- | src/macros/scripts.asm | 116 | ||||
-rw-r--r-- | src/macros/wram.asm | 15 | ||||
-rw-r--r-- | src/sram.asm | 2 | ||||
-rw-r--r-- | src/wram.asm | 101 |
25 files changed, 7102 insertions, 2058 deletions
diff --git a/src/constants.asm b/src/constants.asm index 6e6f0b3..5049fa9 100644 --- a/src/constants.asm +++ b/src/constants.asm @@ -5,7 +5,6 @@ INCLUDE "constants/deck_ai_constants.asm" INCLUDE "constants/deck_constants.asm" INCLUDE "constants/duel_constants.asm" INCLUDE "constants/duel_interface_constants.asm" -INCLUDE "constants/event_constants.asm" INCLUDE "constants/gfx_constants.asm" INCLUDE "constants/hardware_constants.asm" INCLUDE "constants/map_constants.asm" @@ -13,9 +12,10 @@ INCLUDE "constants/misc_constants.asm" INCLUDE "constants/music_constants.asm" INCLUDE "constants/name_constants.asm" INCLUDE "constants/npc_constants.asm" +INCLUDE "constants/script_constants.asm" INCLUDE "constants/sgb_constants.asm" INCLUDE "constants/sfx_constants.asm" INCLUDE "constants/sprite_constants.asm" INCLUDE "constants/text_constants.asm" +INCLUDE "constants/animation_constants.asm" INCLUDE "constants/charmaps.asm" -INCLUDE "constants/animation_constants.asm"
\ No newline at end of file diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index d461d24..344cff1 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -226,3 +226,10 @@ EFFECT_FAILED_UNSUCCESSFUL EQU $02 ; wAnimationQueue length ANIMATION_QUEUE_LENGTH EQU 7 + +PRIZES_1 EQU $01 +PRIZES_2 EQU $02 +PRIZES_3 EQU $03 +PRIZES_4 EQU $04 +PRIZES_5 EQU $05 +PRIZES_6 EQU $06 diff --git a/src/constants/event_constants.asm b/src/constants/event_constants.asm deleted file mode 100644 index 496f5a3..0000000 --- a/src/constants/event_constants.asm +++ /dev/null @@ -1,3 +0,0 @@ -; Event Flags -EVENT_BEAT_SARA EQU $15 -EVENT_BEAT_AMANDA EQU $16 diff --git a/src/constants/map_constants.asm b/src/constants/map_constants.asm index 4b74a29..d8637d6 100644 --- a/src/constants/map_constants.asm +++ b/src/constants/map_constants.asm @@ -33,3 +33,20 @@ const POKEMON_DOME_ENTRANCE ; $1F const POKEMON_DOME ; $20 const HALL_OF_HONOR ; $21 + + +; Size of map data. See data/npc_map_data.asm and data/map_objects.asm +; for more info on what these represent +NPC_MAP_SIZE EQU $06 +MAP_OBJECT_SIZE EQU $09 + +; Most of these aren't fully understood so the names aren't great +MAP_SCRIPT_SIZE EQU $0f +MAP_SCRIPT_NPCS EQU $00 +MAP_SCRIPT_POST_NPC EQU $02 +MAP_SCRIPT_OBJECTS EQU $04 +MAP_SCRIPT_PRESSED_A EQU $06 +MAP_SCRIPT_LOAD_MAP EQU $08 +MAP_SCRIPT_AFTER_DUEL EQU $0a +MAP_SCRIPT_MOVED_PLAYER EQU $0c +MAP_SCRIPT_CLOSE_TEXTBOX EQU $0e diff --git a/src/constants/misc_constants.asm b/src/constants/misc_constants.asm index b31631a..47b9bf6 100644 --- a/src/constants/misc_constants.asm +++ b/src/constants/misc_constants.asm @@ -44,3 +44,8 @@ FLUSH_ALL_PALS_F EQU 6 const GAME_EVENT_CONTINUE_DUEL ; $5 const GAME_EVENT_CHALLENGE_MACHINE ; $6 NUM_GAME_EVENTS EQU const_value + +OWMODE_MAP EQU 0 +OWMODE_MOVE EQU 1 +OWMODE_START_SCRIPT EQU 2 +OWMODE_SCRIPT EQU 3 diff --git a/src/constants/npc_constants.asm b/src/constants/npc_constants.asm index f4972dc..eb7b75b 100644 --- a/src/constants/npc_constants.asm +++ b/src/constants/npc_constants.asm @@ -1,3 +1,38 @@ +LOADED_NPC_MAX EQU $08 + +; wLoadedNPCs structure + const_def + const LOADED_NPC_ID + const LOADED_NPC_SPRITE + const LOADED_NPC_COORD_X + const LOADED_NPC_COORD_Y + const LOADED_NPC_DIRECTION + const LOADED_NPC_FIELD_05 + const LOADED_NPC_FIELD_06 + const LOADED_NPC_FIELD_07 + const LOADED_NPC_FIELD_08 + const LOADED_NPC_FIELD_09 + const LOADED_NPC_FIELD_0A + const LOADED_NPC_FIELD_0B +LOADED_NPC_LENGTH EQU const_value + +; npc_struct constants + const_def + const NPC_TRAINER_ID + const NPC_DATA_FIELD_01 ; 01-03 Seem to relate to sprites + const NPC_DATA_FIELD_02 + const NPC_DATA_FIELD_03 + const NPC_DATA_FIELD_04 + const NPC_DATA_OWSEQUENCE_PTR +const_value = const_value+1 + const NPC_DATA_NAME_TEXT +const_value = const_value+1 + const NPC_DATA_BATTLE_PICTURE + const NPC_DATA_FIELD_0A + const NPC_DATA_FIELD_0B + const NPC_DATA_FIELD_0C +NPC_DATA_LENGTH EQU const_value + const_def 1 const PLAYER_PIC ; $01 const RONALD_PIC ; $02 @@ -41,5 +76,120 @@ const STEPHANIE_PIC ; $28 const AARON_PIC ; $29 -SARA EQU $1F -AMANDA EQU $20 + const_def 1 + const NPC_DRMASON ; $01 + const NPC_RONALD1 ; $02 + const NPC_ISHIHARA ; $03 + const NPC_IMAKUNI ; $04 +const_value = const_value+1 ; DRMASON duplicate +const_value = const_value+1 ; DRMASON duplicate + const NPC_SAM ; $07 + const NPC_TECH1 ; $08 + const NPC_TECH2 ; $09 + const NPC_TECH3 ; $0a + const NPC_TECH4 ; $0b + const NPC_TECH5 ; $0c + const NPC_TECH6 ; $0d + const NPC_CLERK1 ; $0e + const NPC_CLERK2 ; $0f + const NPC_CLERK3 ; $10 + const NPC_CLERK4 ; $11 + const NPC_CLERK5 ; $12 + const NPC_CLERK6 ; $13 + const NPC_CLERK7 ; $14 + const NPC_CLERK8 ; $15 + const NPC_CLERK9 ; $16 + const NPC_CHRIS ; $17 + const NPC_MICHAEL ; $18 + const NPC_JESSICA ; $19 + const NPC_MITCH ; $1a + const NPC_MATTHEW ; $1b + const NPC_RYAN ; $1c + const NPC_ANDREW ; $1d + const NPC_GENE ; $1e + const NPC_SARA ; $1f + const NPC_AMANDA ; $20 + const NPC_JOSHUA ; $21 + const NPC_AMY ; $22 + const NPC_JENNIFER ; $23 + const NPC_NICHOLAS ; $24 + const NPC_BRANDON ; $25 + const NPC_ISAAC ; $26 + const NPC_BRITTANY ; $27 + const NPC_KRISTIN ; $28 + const NPC_HEATHER ; $29 + const NPC_NIKKI ; $2a + const NPC_ROBERT ; $2b + const NPC_DANIEL ; $2c + const NPC_STEPHANIE ; $2d + const NPC_MURRAY1 ; $2e + const NPC_JOSEPH ; $2f + const NPC_DAVID ; $30 + const NPC_ERIK ; $31 + const NPC_RICK ; $32 + const NPC_JOHN ; $33 + const NPC_ADAM ; $34 + const NPC_JONATHAN ; $35 + const NPC_KEN ; $36 + const NPC_COURTNEY ; $37 + const NPC_STEVE ; $38 + const NPC_JACK ; $39 + const NPC_ROD ; $3a + const NPC_CLERK10 ; $3b + const NPC_GIFT_CENTER_CLERK ; $3c + const NPC_MAN1 ; $3d + const NPC_WOMAN1 ; $3e + const NPC_CHAP1 ; $3f + const NPC_GAL1 ; $40 + const NPC_LASS1 ; $41 + const NPC_CHAP2 ; $42 + const NPC_LASS2 ; $43 + const NPC_PAPPY1 ; $44 + const NPC_LAD1 ; $45 + const NPC_LAD2 ; $46 + const NPC_CHAP3 ; $47 + const NPC_CLERK12 ; $48 + const NPC_CLERK13 ; $49 + const NPC_HOST ; $4a + const NPC_SPECS1 ; $4b + const NPC_BUTCH ; $4c + const NPC_GRANNY1 ; $4d + const NPC_LASS3 ; $4e + const NPC_MAN2 ; $4f + const NPC_PAPPY2 ; $50 + const NPC_LASS4 ; $51 + const NPC_HOOD1 ; $52 + const NPC_GRANNY2 ; $53 + const NPC_GAL2 ; $54 + const NPC_LAD3 ; $55 + const NPC_GAL3 ; $56 + const NPC_CHAP4 ; $57 + const NPC_MAN3 ; $58 + const NPC_SPECS2 ; $59 + const NPC_SPECS3 ; $5a + const NPC_WOMAN2 ; $5b + const NPC_MANIA ; $5c + const NPC_PAPPY3 ; $5d + const NPC_GAL4 ; $5e + const NPC_CHAMP ; $5f + const NPC_HOOD2 ; $60 + const NPC_LASS5 ; $61 + const NPC_CHAP5 ; $62 + const NPC_AARON ; $63 + const NPC_GUIDE ; $64 + const NPC_TECH7 ; $65 + const NPC_TECH8 ; $66 + const NPC_TORCH ; $67 + const NPC_LEGENDARY_CARD_TOP_LEFT ; $68 + const NPC_LEGENDARY_CARD_TOP_RIGHT ; $69 + const NPC_LEGENDARY_CARD_LEFT_SPARK ; $6a + const NPC_LEGENDARY_CARD_BOTTOM_LEFT ; $6b + const NPC_LEGENDARY_CARD_BOTTOM_RIGHT ; $6c + const NPC_LEGENDARY_CARD_RIGHT_SPARK ; $6d + const NPC_11F49 ; $6e +const_value = const_value+1 ; NPC_11F49 duplicate + const NPC_MURRAY2 ; $70 + const NPC_RONALD2 ; $71 + const NPC_RONALD3 ; $72 +const_value = const_value+1 ; NPC_11f49 duplicate + diff --git a/src/constants/script_constants.asm b/src/constants/script_constants.asm new file mode 100644 index 0000000..9607ba0 --- /dev/null +++ b/src/constants/script_constants.asm @@ -0,0 +1,147 @@ + const_def + const EVENT_FLAG_00 ; $00 + const EVENT_FLAG_01 ; $01 + const EVENT_TEMP_TALKED_TO_IMAKUNI ; $02 + const EVENT_TEMP_BATTLED_IMAKUNI ; $03 + const EVENT_FLAG_04 ; $04 + const EVENT_FLAG_05 ; $05 + const EVENT_FLAG_06 ; $06 + const EVENT_FLAG_07 ; $07 + const EVENT_FLAG_08 ; $08 + const EVENT_FLAG_09 ; $09 + const EVENT_FLAG_0A ; $0a + const EVENT_BEAT_AMY ; $0b + const EVENT_FLAG_0C ; $0c + const EVENT_FLAG_0D ; $0d + const EVENT_FLAG_0E ; $0e + const EVENT_FLAG_0F ; $0f + const EVENT_FLAG_10 ; $10 + const EVENT_FLAG_11 ; $11 + const EVENT_FLAG_12 ; $12 + const EVENT_IMAKUNI_STATE ; $13 + const EVENT_FLAG_14 ; $14 + const EVENT_BEAT_SARA ; $15 + const EVENT_BEAT_AMANDA ; $16 + const EVENT_FLAG_17 ; $17 + const EVENT_FLAG_18 ; $18 + const EVENT_FLAG_19 ; $19 + const EVENT_FLAG_1A ; $1a + const EVENT_FLAG_1B ; $1b + const EVENT_FLAG_1C ; $1c + const EVENT_FLAG_1D ; $1d + const EVENT_FLAG_1E ; $1e + const EVENT_FLAG_1F ; $1f + const EVENT_FLAG_20 ; $20 + const EVENT_FLAG_21 ; $21 + const EVENT_RECEIVED_LEGENDARY_CARD ; $22 + const EVENT_FLAG_23 ; $23 + const EVENT_FLAG_24 ; $24 + const EVENT_FLAG_25 ; $25 + const EVENT_FLAG_26 ; $26 + const EVENT_FLAG_27 ; $27 + const EVENT_FLAG_28 ; $28 + const EVENT_FLAG_29 ; $29 + const EVENT_FLAG_2A ; $2a + const EVENT_FLAG_2B ; $2b + const EVENT_FLAG_2C ; $2c + const EVENT_FLAG_2D ; $2d + const EVENT_MEDAL_COUNT ; $2e + const EVENT_FLAG_2F ; $2f + const EVENT_FLAG_30 ; $30 + const EVENT_FLAG_31 ; $31 + const EVENT_FLAG_32 ; $32 + const EVENT_JOSHUA_STATE ; $33 + const EVENT_IMAKUNI_ROOM ; $34 + const EVENT_FLAG_35 ; $35 + const EVENT_IMAKUNI_WIN_COUNT ; $36 + const EVENT_FLAG_37 ; $37 + const EVENT_FLAG_38 ; $38 + const EVENT_FLAG_39 ; $39 + const EVENT_FLAG_3A ; $3a + const EVENT_FLAG_3B ; $3b + const FLAG_BEAT_BRITTANY ; $3c + const EVENT_FLAG_3D ; $3d + const EVENT_FLAG_3E ; $3e + const EVENT_FLAG_3F ; $3f + const EVENT_FLAG_40 ; $40 + const EVENT_FLAG_41 ; $41 + const EVENT_FLAG_42 ; $42 + const EVENT_FLAG_43 ; $43 + const EVENT_FLAG_44 ; $44 + const EVENT_FLAG_45 ; $45 + const EVENT_FLAG_46 ; $46 + const EVENT_FLAG_47 ; $47 + const EVENT_FLAG_48 ; $48 + const EVENT_FLAG_49 ; $49 + const EVENT_FLAG_4A ; $4a + const EVENT_FLAG_4B ; $4b + const EVENT_FLAG_4C ; $4c + const EVENT_FLAG_4D ; $4d + const EVENT_FLAG_4E ; $4e + const EVENT_FLAG_4F ; $4f + const EVENT_FLAG_50 ; $50 + const EVENT_FLAG_51 ; $51 + const EVENT_FLAG_52 ; $52 + const EVENT_FLAG_53 ; $53 + const EVENT_FLAG_54 ; $54 + const EVENT_FLAG_55 ; $55 + const EVENT_FLAG_56 ; $56 + const EVENT_FLAG_57 ; $57 + const EVENT_FLAG_58 ; $58 + const EVENT_FLAG_59 ; $59 + const EVENT_FLAG_5A ; $5a + const EVENT_FLAG_5B ; $5b + const EVENT_FLAG_5C ; $5c + const EVENT_FLAG_5D ; $5d + const EVENT_FLAG_5E ; $5e + const EVENT_FLAG_5F ; $5f + const EVENT_FLAG_60 ; $60 + const EVENT_FLAG_61 ; $61 + const EVENT_FLAG_62 ; $62 + const EVENT_FLAG_63 ; $63 + const EVENT_FLAG_64 ; $64 + const EVENT_FLAG_65 ; $65 + const EVENT_FLAG_66 ; $66 + const EVENT_FLAG_67 ; $67 + const EVENT_FLAG_68 ; $68 + const EVENT_FLAG_69 ; $69 + const EVENT_FLAG_6A ; $6a + const EVENT_FLAG_6B ; $6b + const EVENT_FLAG_6C ; $6c + const EVENT_FLAG_6D ; $6d + const EVENT_FLAG_6E ; $6e + const EVENT_FLAG_6F ; $6f + const EVENT_FLAG_70 ; $70 + const EVENT_FLAG_71 ; $71 + const EVENT_FLAG_72 ; $72 + const EVENT_FLAG_73 ; $73 + const EVENT_FLAG_74 ; $74 + const EVENT_FLAG_75 ; $75 + const EVENT_FLAG_76 ; $76 +EVENT_FLAG_AMOUNT EQU const_value + +EVENT_FLAG_BYTES EQU $40 + +; EVENT_IMAKUNI_STATE +; Starts at 0, Talking to lass moves it to MENTIONED (1), then +; talking to Imakuni at least once sets it to TALKED (2) +IMAKUNI_MENTIONED EQU 1 +IMAKUNI_TALKED EQU 2 + +; EVENT_JOSHUA_STATE +JOSHUA_TALKED EQU 1 +JOSHUA_BEATEN EQU 2 + +; EVENT_IMAKUNI_ROOM +IMAKUNI_FIGHTING_CLUB EQU 0 +IMAKUNI_SCIENCE_CLUB EQU 1 +IMAKUNI_LIGHTNING_CLUB EQU 2 +IMAKUNI_WATER_CLUB EQU 3 + +NO_JUMP EQU $0000 + +NORTH EQU $00 +EAST EQU $01 +SOUTH EQU $02 +WEST EQU $03 +NO_MOVE EQU %10000000 ; For rotations without movement diff --git a/src/data/map_objects.asm b/src/data/map_objects.asm new file mode 100644 index 0000000..1ac73fa --- /dev/null +++ b/src/data/map_objects.asm @@ -0,0 +1,610 @@ +; Objects around maps that can be interacted with but are not represented +; by NPCs. Things like Deck Machines and the PCs. +; Format: +; Direction you need to face, X coord, Y coord +; Routine that gets called when you hit A in front of it +; Object Name, and Object default Text +MasonLabObjects: ; 13b04 (3:7b04) + db NORTH, 18, 2 + dw PrintInteractableObjectText + tx Text04a0 + tx Text049f + + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04a2 + tx Text04a1 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04a4 + tx Text04a3 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04a6 + tx Text04a5 + + db NORTH, 20, 14 + dw PrintInteractableObjectText + tx Text04a8 + tx Text04a7 + + db NORTH, 22, 14 + dw PrintInteractableObjectText + tx Text04aa + tx Text04a9 + + db NORTH, 24, 14 + dw PrintInteractableObjectText + tx Text04ac + tx Text04ab + + db NORTH, 2, 2 + dw PC_c7ea + tx Text041b + tx Text041a + + db $ff + + +DeckMachineRoomObjects: ; 13b4d (3:7b4d) + db NORTH, 2, 2 + dw Script_d932 + tx Text041b + tx Text041a + + db NORTH, 4, 2 + dw Script_d932 + tx Text041b + tx Text041a + + db NORTH, 6, 2 + dw $593f + tx Text041b + tx Text041a + + db NORTH, 8, 2 + dw $593f + tx Text041b + tx Text041a + + db NORTH, 10, 2 + dw $5995 + tx Text041b + tx Text041a + + db NORTH, 12, 2 + dw $5995 + tx Text041b + tx Text041a + + db NORTH, 14, 2 + dw $59c2 + tx Text041b + tx Text041a + + db NORTH, 16, 2 + dw $59c2 + tx Text041b + tx Text041a + + db NORTH, 18, 2 + dw $59ef + tx Text041b + tx Text041a + + db NORTH, 20, 2 + dw $59ef + tx Text041b + tx Text041a + + db NORTH, 14, 10 + dw $5a1c + tx Text041b + tx Text041a + + db NORTH, 16, 10 + dw $5a1c + tx Text041b + tx Text041a + + db NORTH, 18, 10 + dw $5a49 + tx Text041b + tx Text041a + + db NORTH, 20, 10 + dw $5a49 + tx Text041b + tx Text041a + + db NORTH, 14, 18 + dw $5a76 + tx Text041b + tx Text041a + + db NORTH, 16, 18 + dw $5a76 + tx Text041b + tx Text041a + + db NORTH, 18, 18 + dw $5aa3 + tx Text041b + tx Text041a + + db NORTH, 20, 18 + dw $5aa3 + tx Text041b + tx Text041a + + db NORTH, 2, 18 + dw $5ad0 + tx Text041b + tx Text041a + + db NORTH, 4, 18 + dw $5ad0 + tx Text041b + tx Text041a + + db $ff + + +IshiharasHouseObjects: ; 13c02 (3:7c02) + db NORTH, 6, 2 + dw PrintInteractableObjectText + tx Text04ae + tx Text04ad + + db NORTH, 8, 2 + dw PrintInteractableObjectText + tx Text04b0 + tx Text04af + + db NORTH, 10, 2 + dw PrintInteractableObjectText + tx Text04b2 + tx Text04b1 + + db NORTH, 12, 2 + dw PrintInteractableObjectText + tx Text04b4 + tx Text04b3 + + db NORTH, 14, 2 + dw PrintInteractableObjectText + tx Text04b6 + tx Text04b5 + + db NORTH, 16, 2 + dw PrintInteractableObjectText + tx Text04b8 + tx Text04b7 + + db NORTH, 2, 12 + dw PrintInteractableObjectText + tx Text04ba + tx Text04b9 + + db NORTH, 4, 12 + dw PrintInteractableObjectText + tx Text04bc + tx Text04bb + + db NORTH, 6, 12 + dw PrintInteractableObjectText + tx Text04be + tx Text04bd + + db NORTH, 12, 12 + dw PrintInteractableObjectText + tx Text04c0 + tx Text04bf + + db NORTH, 14, 12 + dw PrintInteractableObjectText + tx Text04c2 + tx Text04c1 + + db NORTH, 16, 12 + dw PrintInteractableObjectText + tx Text04c4 + tx Text04c3 + + db $ff + + +FightingClubLobbyObjects: ; 13c6f (3:7c6f) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04c6 + tx Text04c5 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04c8 + tx Text04c7 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04ca + tx Text04c9 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw Script_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +RockClubLobbyObjects: ; 13ca6 (3:7ca6) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04cc + tx Text04cb + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04ce + tx Text04cd + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04d0 + tx Text04cf + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw Script_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +WaterClubLobbyObjects: ; 13cdd (3:7cdd) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04d2 + tx Text04d1 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04d4 + tx Text04d3 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04d6 + tx Text04d5 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw Script_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +LightningClubLobbyObjects: ; 13d14 (3:7d14) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04d8 + tx Text04d7 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04da + tx Text04d9 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04dc + tx Text04db + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw Script_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +GrassClubLobbyObjects: ; 13d4b (3:7d4b) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04de + tx Text04dd + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04e0 + tx Text04df + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04e2 + tx Text04e1 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw Script_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +PsychicClubLobbyObjects: ; 13d82 (3:7d82) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04e4 + tx Text04e3 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04e6 + tx Text04e5 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04e8 + tx Text04e7 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw Script_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +ScienceClubLobbyObjects: ; 13db9 (3:7db9) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04ea + tx Text04e9 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04ec + tx Text04eb + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04ee + tx Text04ed + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw Script_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +FireClubLobbyObjects: ; 13df0 (3:7df0) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04f0 + tx Text04ef + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04f2 + tx Text04f1 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04f4 + tx Text04f3 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw Script_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +ChallengeHallLobbyObjects: ; 13e27 (3:7e27) + db NORTH, 20, 2 + dw PrintInteractableObjectText + tx Text04f6 + tx Text04f5 + + db NORTH, 22, 2 + dw PrintInteractableObjectText + tx Text04f8 + tx Text04f7 + + db NORTH, 24, 2 + dw PrintInteractableObjectText + tx Text04fa + tx Text04f9 + + db NORTH, 2, 8 + dw PC_c7ea + tx Text041b + tx Text041a + + db NORTH, 6, 6 + dw Script_fc52 + tx Text041b + tx Text03b0 + + db NORTH, 10, 6 + dw Func_fc7a + tx Text041b + tx Text03b0 + + db $ff + + +PokemonDomeEntranceObjects: ; 13e5e (3:7e5e) + db NORTH, 2, 2 + dw PrintInteractableObjectText + tx Text04fc + tx Text04fb + + db NORTH, 4, 2 + dw PrintInteractableObjectText + tx Text04fe + tx Text04fd + + db NORTH, 6, 2 + dw PrintInteractableObjectText + tx Text0500 + tx Text04ff + + + db NORTH, 2, 8 + dw PrintInteractableObjectText + tx Text0502 + tx Text0501 + + db NORTH, 4, 8 + dw PrintInteractableObjectText + tx Text0504 + tx Text0503 + + db NORTH, 6, 8 + dw PrintInteractableObjectText + tx Text0506 + tx Text0505 + + db NORTH, 18, 0 + dw Script_f631 + tx Text0508 + tx Text0507 + + db NORTH, 20, 0 + dw Script_f631 + tx Text0508 + tx Text0507 + + db NORTH, 22, 0 + dw $76af + tx Text0558 + tx Text0509 + + db NORTH, 24, 0 + dw $76af + tx Text0558 + tx Text0509 + + db NORTH, 28, 2 + dw PC_c7ea + tx Text041b + tx Text041a + + db $ff + + +HallOfHonorObjects: ; 13ec2 (3:7ec2) + ; Legendary Cards + db NORTH, 10, 10 + dw Script_fbf1 + dw $0000 + dw $0000 + + ; Legendary Cards + db NORTH, 12, 10 + dw Script_fbf1 + dw $0000 + dw $0000 + + db NORTH, 10, 2 + dw $7be1 + tx Text041b + tx Text041a + + db NORTH, 12, 2 + dw $7be1 + tx Text041b + tx Text041a + + db $ff + + diff --git a/src/data/map_scripts.asm b/src/data/map_scripts.asm index ae4e355..f969d45 100644 --- a/src/data/map_scripts.asm +++ b/src/data/map_scripts.asm @@ -2,10 +2,10 @@ ; scripts are referenced with ids [0,2,4,6,8,a,c,e] ; each script id is used for a specific event ; if a script pointer is $0000, that map has no script for that event -; 0: load texts -; 2: unused -; 4: pressed A button -; 6: pressed A button +; 0: NPC data +; 2: Called after every NPC is loaded (unused) +; 4: Interactable Objects +; 6: pressed A button (if nothing interactable is found) ; 8: load map ; a: after duel ; c: moved player @@ -17,25 +17,25 @@ MapScripts: ; 1162a (4:562a) dw $0000 dw $0000 dw $0000 - dw $54ec + dw LoadOverworld dw $0000 dw $0000 dw $0000 ; MASON_LABORATORY - dw $772f + dw MasonLabNPCS dw $0000 - dw $7b04 - dw $5565 - dw $5549 - dw $553b + dw MasonLabObjects + dw MasonLabPressedA + dw MasonLabLoadMap + dw MasonLaboratoryAfterDuel dw $0000 - dw $555e + dw MasonLabCloseTextBox ; DECK_MACHINE_ROOM - dw $775a + dw DeckMachineRoomNPCS dw $0000 - dw $7b4d + dw DeckMachineRoomObjects dw $0000 dw $0000 dw $589f @@ -43,9 +43,9 @@ MapScripts: ; 1162a (4:562a) dw $58ad ; ISHIHARAS_HOUSE - dw $7773 + dw IshiharasHouseNPCS dw $0000 - dw $7c02 + dw IshiharasHouseObjects dw $0000 dw $0000 dw $0000 @@ -53,27 +53,27 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; FIGHTING_CLUB_ENTRANCE - dw $7786 + dw FightingClubEntranceNPCS dw $0000 dw $0000 dw $0000 - dw $6809 - dw $67f6 + dw LoadClubEntrance + dw ClubEntranceAfterDuel dw $0000 dw $0000 ; FIGHTING_CLUB_LOBBY - dw $779f + dw FightingClubLobbyNPCS dw $0000 - dw $7c6f + dw FightingClubLobbyObjects dw $0000 dw $0000 - dw $5c68 + dw FightingClubLobbyAfterDuel dw $0000 dw $0000 ; FIGHTING_CLUB - dw $77ca + dw FightingClubNPCS dw $0000 dw $0000 dw $0000 @@ -83,19 +83,19 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; ROCK_CLUB_ENTRANCE - dw $77e3 + dw RockClubEntranceNPCS dw $0000 dw $0000 dw $0000 - dw $6809 - dw $67f6 + dw LoadClubEntrance + dw ClubEntranceAfterDuel dw $0000 dw $0000 ; ROCK_CLUB_LOBBY - dw $77fc + dw RockClubLobbyNPCS dw $0000 - dw $7ca6 + dw RockClubLobbyObjects dw $0000 dw $0000 dw $5ed5 @@ -103,7 +103,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; ROCK_CLUB - dw $7827 + dw RockClubNPCS dw $0000 dw $0000 dw $0000 @@ -113,19 +113,19 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; WATER_CLUB_ENTRANCE - dw $783a + dw WaterClubEntranceNPCS dw $0000 dw $0000 dw $0000 - dw $6809 - dw $67f6 + dw LoadClubEntrance + dw ClubEntranceAfterDuel dw $0000 dw $0000 ; WATER_CLUB_LOBBY - dw $7853 + dw WaterClubLobbyNPCS dw $0000 - dw $7cdd + dw WaterClubLobbyObjects dw $0000 dw $0000 dw $60a2 @@ -133,7 +133,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; WATER_CLUB - dw $787e + dw WaterClubNPCS dw $0000 dw $0000 dw $0000 @@ -143,19 +143,19 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; LIGHTNING_CLUB_ENTRANCE - dw $7897 + dw LightningClubEntranceNPCS dw $0000 dw $0000 dw $0000 - dw $6809 - dw $67f6 + dw LoadClubEntrance + dw ClubEntranceAfterDuel dw $0000 dw $0000 ; LIGHTNING_CLUB_LOBBY - dw $78b0 + dw LightningClubLobbyNPCS dw $0000 - dw $7d14 + dw LightningClubLobbyObjects dw $0000 dw $0000 dw $636d @@ -163,7 +163,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; LIGHTNING_CLUB - dw $78d5 + dw LightningClubNPCS dw $0000 dw $0000 dw $0000 @@ -173,27 +173,27 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; GRASS_CLUB_ENTRANCE - dw $78ee + dw GrassClubEntranceNPCS dw $0000 dw $0000 dw $0000 - dw $6809 - dw $6525 + dw LoadClubEntrance + dw GrassClubEntranceAfterDuel dw $0000 dw $0000 ; GRASS_CLUB_LOBBY - dw $790d + dw GrassClubLobbyNPCS dw $0000 - dw $7d4b + dw GrassClubLobbyObjects dw $0000 dw $0000 - dw $65c4 + dw GrassClubLobbyAfterDuel dw $0000 dw $0000 ; GRASS_CLUB - dw $7932 + dw GrassClubNPCS dw $0000 dw $0000 dw $0000 @@ -203,19 +203,19 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; PSYCHIC_CLUB_ENTRANCE - dw $7945 + dw PsychicClubEntranceNPCS dw $0000 dw $0000 dw $0000 - dw $6809 - dw $67f6 + dw LoadClubEntrance + dw ClubEntranceAfterDuel dw $0000 dw $0000 ; PSYCHIC_CLUB_LOBBY - dw $7964 + dw PsychicClubLobbyNPCS dw $0000 - dw $7d82 + dw PsychicClubLobbyObjects dw $0000 dw $6971 dw $6963 @@ -223,7 +223,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; PSYCHIC_CLUB - dw $798f + dw PsychicClubNPCS dw $0000 dw $0000 dw $0000 @@ -233,19 +233,19 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; SCIENCE_CLUB_ENTRANCE - dw $79a8 + dw ScienceClubEntranceNPCS dw $0000 dw $0000 dw $0000 - dw $6809 - dw $67f6 + dw LoadClubEntrance + dw ClubEntranceAfterDuel dw $0000 dw $0000 ; SCIENCE_CLUB_LOBBY - dw $79c1 + dw ScienceClubLobbyNPCS dw $0000 - dw $7db9 + dw ScienceClubLobbyObjects dw $0000 dw $0000 dw $6b57 @@ -253,7 +253,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; SCIENCE_CLUB - dw $79ec + dw ScienceClubNPCS dw $0000 dw $0000 dw $0000 @@ -263,27 +263,27 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; FIRE_CLUB_ENTRANCE - dw $7a05 + dw FireClubEntranceNPCS dw $0000 dw $0000 dw $0000 - dw $6809 - dw $67f6 + dw LoadClubEntrance + dw ClubEntranceAfterDuel dw $0000 dw $0000 ; FIRE_CLUB_LOBBY - dw $7a1e + dw FireClubLobbyNPCS dw $0000 - dw $7df0 - dw $6d57 + dw FireClubLobbyObjects + dw FireClubPressedA dw $0000 dw $6d49 dw $0000 dw $0000 ; FIRE_CLUB - dw $7a43 + dw FireClubNPCS dw $0000 dw $0000 dw $0000 @@ -293,7 +293,7 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; CHALLENGE_HALL_ENTRANCE - dw $7a5c + dw ChallengeHallEntranceNPCS dw $0000 dw $0000 dw $0000 @@ -303,29 +303,29 @@ MapScripts: ; 1162a (4:562a) dw $0000 ; CHALLENGE_HALL_LOBBY - dw $7a63 + dw ChallengeHallLobbyNPCS dw $0000 - dw $7e27 + dw ChallengeHallLobbyObjects dw $0000 - dw $7088 + dw ChallengeHallLobbyLoadMap dw $0000 dw $0000 dw $0000 ; CHALLENGE_HALL - dw $7a9a + dw ChallengeHallNPCS dw $0000 dw $0000 dw $0000 - dw $7258 - dw $7239 + dw ChallengeHallLoadMap + dw ChallengeHallAfterDuel dw $0000 dw $0000 ; POKEMON_DOME_ENTRANCE - dw $7ab9 + dw PokemonDomeEntranceNPCS dw $0000 - dw $7e5e + dw PokemonDomeEntranceObjects dw $0000 dw $7607 dw $0000 @@ -333,7 +333,7 @@ MapScripts: ; 1162a (4:562a) dw $762a ; POKEMON_DOME - dw $7ac0 + dw PokemonDomeNPCS dw $0000 dw $0000 dw $0000 @@ -343,11 +343,11 @@ MapScripts: ; 1162a (4:562a) dw $7718 ; HALL_OF_HONOR - dw $7adf + dw HallOfHonorNPCS dw $0000 - dw $7ec2 + dw HallOfHonorObjects dw $0000 - dw $7bdb + dw HallOfHonorLoadMap dw $0000 dw $0000 dw $0000 diff --git a/src/data/npc_map_data.asm b/src/data/npc_map_data.asm new file mode 100644 index 0000000..bc09d07 --- /dev/null +++ b/src/data/npc_map_data.asm @@ -0,0 +1,419 @@ +; NPC Map data. Note: pre-load functions also run after battles +; Format: +; NPC, X position, Y Position, Direction, +; pre-load function. (Resets c flag if NPC should not be loaded) +MasonLabNPCS: ; 772f (4:1372f) + db NPC_DRMASON, $0e, $06, SOUTH + dw $5710 + db NPC_SAM, $04, $0e, EAST + dw $5604 + db NPC_TECH1, $16, $08, WEST + dw $0000 + db NPC_TECH2, $16, $14, SOUTH + dw $0000 + db NPC_TECH3, $16, $16, WEST + dw $0000 + db NPC_TECH4, $0a, $16, EAST + dw $0000 + db NPC_TECH5, $06, $04, SOUTH + dw $55eb + db $00 + +DeckMachineRoomNPCS: ; 775a (4:1375a) + db NPC_TECH6, $06, $08, SOUTH + dw $0000 + db NPC_TECH7, $06, $16, WEST + dw $0000 + db NPC_TECH8, $0a, $12, WEST + dw $0000 + db NPC_AARON, $0c, $0c, WEST + dw $0000 + db $00 + +IshiharasHouseNPCS: ; 7773 (4:13773) + db NPC_NIKKI, $04, $04, NORTH + dw Preload_NikkiInIshiharasHouse + db NPC_ISHIHARA, $08, $08, SOUTH + dw Preload_IshiharaInIshiharasHouse + db NPC_RONALD1, $02, $04, WEST + dw Preload_Ronald1InIshiharasHouse + db $00 + +FightingClubEntranceNPCS: ; 7786 (4:13786) + db NPC_CLERK1, $06, $02, SOUTH + dw $0000 + db NPC_RONALD1, $08, $fe, SOUTH + dw $685b + db NPC_RONALD2, $fe, $08, NORTH + dw $689a + db NPC_RONALD3, $fe, $08, NORTH + dw $6915 + db $00 + +FightingClubLobbyNPCS: ; 779f (4:1379f) + db NPC_MAN1, $0c, $0e, WEST + dw $0000 + db NPC_IMAKUNI, $12, $02, NORTH + dw $5ceb + db NPC_SPECS1, $12, $10, EAST + dw $0000 + db NPC_BUTCH, $14, $10, WEST + dw $0000 + db NPC_GRANNY1, $04, $10, WEST + dw $5d98 + db NPC_CLERK10, $06, $04, SOUTH + dw $0000 + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk + db $00 + +FightingClubNPCS: ; 77ca (4:137ca) + db NPC_CHRIS, $04, $08, SOUTH + dw $5e43 + db NPC_MICHAEL, $0e, $0a, SOUTH + dw $5e79 + db NPC_JESSICA, $12, $06, EAST + dw $5ea5 + db NPC_MITCH, $0a, $04, SOUTH + dw $0000 + db $00 + +RockClubEntranceNPCS: ; 77e3 (4:137e3) + db NPC_CLERK2, $06, $02, SOUTH + dw $0000 + db NPC_RONALD1, $08, $fe, SOUTH + dw $685b + db NPC_RONALD2, $fe, $08, NORTH + dw $689a + db NPC_RONALD3, $fe, $08, NORTH + dw $6915 + db $00 + +RockClubLobbyNPCS: ; 77fc (4:137fc) + db NPC_CHRIS, $12, $08, WEST + dw $5ee9 + db NPC_MATTHEW, $06, $0e, EAST + dw $0000 + db NPC_WOMAN1, $14, $12, NORTH + dw $0000 + db NPC_CHAP1, $0e, $10, EAST + dw $0000 + db NPC_LASS3, $10, $04, SOUTH + dw $5fcb + db NPC_CLERK10, $06, $04, SOUTH + dw $0000 + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk + db $00 + +RockClubNPCS: ; 7827 (4:13827) + db NPC_RYAN, $14, $0e, EAST + dw $0000 + db NPC_ANDREW, $06, $14, NORTH + dw $0000 + db NPC_GENE, $0c, $06, NORTH + dw $0000 + db $00 + +WaterClubEntranceNPCS: ; 783a (4:1383a) + db NPC_CLERK3, $06, $02, SOUTH + dw $0000 + db NPC_RONALD1, $08, $fe, SOUTH + dw $685b + db NPC_RONALD2, $fe, $08, NORTH + dw $689a + db NPC_RONALD3, $fe, $08, NORTH + dw $6915 + db $00 + +WaterClubLobbyNPCS: ; 7853 (4:13853) + db NPC_GAL1, $06, $0e, SOUTH + dw $0000 + db NPC_LASS1, $10, $0a, SOUTH + dw $0000 + db NPC_IMAKUNI, $12, $02, NORTH + dw Preload_ImakuniInWaterClubLobby + db NPC_MAN2, $04, $12, EAST + dw Preload_Man2InWaterClubLobby + db NPC_PAPPY2, $16, $10, NORTH + dw $0000 + db NPC_CLERK10, $06, $04, SOUTH + dw $0000 + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk + db $00 + +WaterClubNPCS: ; 787e (4:1387e) + db NPC_SARA, $06, $12, EAST + dw $0000 + db NPC_AMANDA, $16, $14, WEST + dw $0000 + db NPC_JOSHUA, $16, $08, SOUTH + dw $0000 + db NPC_AMY, $16, $04, SOUTH + dw Preload_Amy + db $00 + +LightningClubEntranceNPCS: ; 7897 (4:13897) + db NPC_CLERK4, $06, $02, SOUTH + dw $0000 + db NPC_RONALD1, $08, $fe, SOUTH + dw $685b + db NPC_RONALD2, $fe, $08, NORTH + dw $689a + db NPC_RONALD3, $fe, $08, NORTH + dw $6915 + db $00 + +LightningClubLobbyNPCS: ; 78b0 (4:138b0) + db NPC_CHAP2, $12, $10, WEST + dw $0000 + db NPC_IMAKUNI, $12, $02, NORTH + dw $637b + db NPC_LASS4, $08, $0c, SOUTH + dw $0000 + db NPC_HOOD1, $14, $08, SOUTH + dw $0000 + db NPC_CLERK10, $06, $04, SOUTH + dw $0000 + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk + db $00 + +LightningClubNPCS: ; 78d5 (4:138d5) + db NPC_JENNIFER, $0e, $12, SOUTH + dw $0000 + db NPC_NICHOLAS, $06, $0a, SOUTH + dw $0000 + db NPC_BRANDON, $16, $0c, NORTH + dw $0000 + db NPC_ISAAC, $0c, $04, NORTH + dw $6494 + db $00 + +GrassClubEntranceNPCS: ; 78ee (4:138ee) + db NPC_CLERK5, $06, $02, SOUTH + dw $0000 + db NPC_MICHAEL, $0e, $08, SOUTH + dw $656a + db NPC_RONALD1, $08, $fe, SOUTH + dw $685b + db NPC_RONALD2, $fe, $08, NORTH + dw $689a + db NPC_RONALD3, $fe, $08, NORTH + dw $6915 + db $00 + +GrassClubLobbyNPCS: ; 790d (4:1390d) + db NPC_BRITTANY, $0c, $0e, WEST + dw $0000 + db NPC_LASS2, $12, $08, SOUTH + dw $0000 + db NPC_GRANNY2, $04, $10, EAST + dw $0000 + db NPC_GAL2, $14, $10, NORTH + dw $66dc + db NPC_CLERK10, $06, $04, SOUTH + dw $0000 + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk + db $00 + +GrassClubNPCS: ; 7932 (4:13932) + db NPC_KRISTIN, $04, $0a, EAST + dw $0000 + db NPC_HEATHER, $0e, $10, SOUTH + dw $0000 + db NPC_NIKKI, $0c, $04, SOUTH + dw $6796 + db $00 + +PsychicClubEntranceNPCS: ; 7945 (4:13945) + db NPC_CLERK6, $06, $02, SOUTH + dw $0000 + db NPC_RONALD1, $08, $fe, SOUTH + dw $685b + db NPC_RONALD2, $fe, $08, NORTH + dw $689a + db NPC_RONALD3, $fe, $08, NORTH + dw $6915 + db NPC_LAD3, $0e, $04, SOUTH + dw $0000 + db $00 + +PsychicClubLobbyNPCS: ; 7964 (4:13964) + db NPC_ROBERT, $14, $08, NORTH + dw $0000 + db NPC_PAPPY1, $04, $10, EAST + dw $0000 + db NPC_RONALD1, $0c, $0a, EAST + dw $69f7 + db NPC_GAL3, $10, $0e, WEST + dw $0000 + db NPC_CHAP4, $18, $10, SOUTH + dw $0000 + db NPC_CLERK10, $06, $04, SOUTH + dw $0000 + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk + db $00 + +PsychicClubNPCS: ; 798f (4:1398f) + db NPC_DANIEL, $08, $08, NORTH + dw $0000 + db NPC_STEPHANIE, $16, $0c, EAST + dw $0000 + db NPC_MURRAY2, $02, $02, WEST + dw $6ad0 + db NPC_MURRAY1, $0c, $06, SOUTH + dw $6ada + db $00 + +ScienceClubEntranceNPCS: ; 79a8 (4:139a8) + db NPC_CLERK7, $06, $02, SOUTH + dw $0000 + db NPC_RONALD1, $08, $fe, SOUTH + dw $685b + db NPC_RONALD2, $fe, $08, NORTH + dw $689a + db NPC_RONALD3, $fe, $08, NORTH + dw $6915 + db $00 + +ScienceClubLobbyNPCS: ; 79c1 (4:139c1) + db NPC_LAD1, $12, $12, NORTH + dw $0000 + db NPC_IMAKUNI, $12, $02, NORTH + dw $6b65 + db NPC_MAN3, $04, $0e, WEST + dw $0000 + db NPC_SPECS2, $0c, $0e, WEST + dw $0000 + db NPC_SPECS3, $16, $08, SOUTH + dw $0000 + db NPC_CLERK10, $06, $04, SOUTH + dw $0000 + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk + db $00 + +ScienceClubNPCS: ; 79ec (4:139ec) + db NPC_JOSEPH, $08, $0a, SOUTH + dw $6cc4 + db NPC_DAVID, $14, $04, NORTH + dw $0000 + db NPC_ERIK, $06, $12, SOUTH + dw $0000 + db NPC_RICK, $04, $04, NORTH + dw $0000 + db $00 + +FireClubEntranceNPCS: ; 7a05 (4:13a05) + db NPC_CLERK8, $06, $02, SOUTH + dw $0000 + db NPC_RONALD1, $08, $fe, SOUTH + dw $685b + db NPC_RONALD2, $fe, $08, NORTH + dw $689a + db NPC_RONALD3, $fe, $08, NORTH + dw $6915 + db $00 + +FireClubLobbyNPCS: ; 7a1e (4:13a1e) + db NPC_JESSICA, $0c, $0e, WEST + dw $6d8d + db NPC_LAD2, $12, $06, EAST + dw $6e25 + db NPC_CHAP3, $06, $0a, NORTH + dw $0000 + db NPC_MANIA, $14, $12, NORTH + dw $0000 + db NPC_CLERK10, $06, $04, SOUTH + dw $0000 + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk + db $00 + +FireClubNPCS: ; 7a43 (4:13a43) + db NPC_JOHN, $0c, $12, SOUTH + dw $0000 + db NPC_ADAM, $08, $0e, SOUTH + dw $0000 + db NPC_JONATHAN, $12, $0a, SOUTH + dw $0000 + db NPC_KEN, $0e, $04, SOUTH + dw $0000 + db $00 + +ChallengeHallEntranceNPCS: ; 7a5c (4:13a5c) + db NPC_CLERK9, $06, $02, SOUTH + dw Preload_Clerk9 + db $00 + +ChallengeHallLobbyNPCS: ; 7a63 (4:13a63) + db NPC_PAPPY3, $06, $0e, EAST + dw Preload_ChallengeHallNPCs1 + db NPC_CHAMP, $10, $12, WEST + dw Preload_ChallengeHallNPCs1 + db NPC_HOOD2, $14, $08, SOUTH + dw Preload_ChallengeHallNPCs1 + db NPC_LASS5, $16, $10, WEST + dw Preload_ChallengeHallNPCs1 + db NPC_GAL4, $0c, $0e, EAST + dw Preload_ChallengeHallNPCs2 + db NPC_CHAP5, $10, $08, WEST + dw Preload_ChallengeHallNPCs2 + db NPC_RONALD1, $08, $0c, SOUTH + dw Preload_ChallengeHallLobbyRonald1 + db NPC_CLERK10, $06, $04, SOUTH + dw $0000 + db NPC_GIFT_CENTER_CLERK, $0a, $04, SOUTH + dw Preload_GiftCenterClerk + db $00 + +ChallengeHallNPCS: ; 7a9a (4:13a9a) + db NPC_CLERK12, $0a, $12, SOUTH + dw Preload_ChallengeHallNPCs1 + db NPC_CLERK13, $14, $12, SOUTH + dw Preload_ChallengeHallNPCs1 + db NPC_GUIDE, $0e, $14, SOUTH + dw Preload_Guide + db NPC_HOST, $0e, $04, SOUTH + dw Preload_ChallengeHallNPCs1 + db $ff, $12, $08, WEST ; pre-load function chooses NPC to load + dw Preload_ChallengeHallOpponent + db $00 + +PokemonDomeEntranceNPCS: ; 7ab9 (4:13ab9) + db NPC_RONALD1, $0e, $12, SOUTH + dw $0000 + db $00 + +PokemonDomeNPCS: ; 7ac0 (4:13ac0) + db NPC_COURTNEY, $12, $02, SOUTH + dw $774b + db NPC_STEVE, $16, $02, SOUTH + dw $778c + db NPC_JACK, $08, $02, SOUTH + dw $77a3 + db NPC_ROD, $0c, $02, SOUTH + dw $77ba + db NPC_RONALD1, $1e, $00, SOUTH + dw $77d6 + db $00 + +HallOfHonorNPCS: ; 7adf (4:13adf) + db NPC_LEGENDARY_CARD_TOP_LEFT, $0a, $08, SOUTH + dw $0000 + db NPC_LEGENDARY_CARD_TOP_RIGHT, $0c, $08, SOUTH + dw $0000 + db NPC_LEGENDARY_CARD_LEFT_SPARK, $08, $0a, SOUTH + dw $0000 + db NPC_LEGENDARY_CARD_BOTTOM_LEFT, $0a, $0a, SOUTH + dw $0000 + db NPC_LEGENDARY_CARD_BOTTOM_RIGHT, $0c, $0a, SOUTH + dw $0000 + db NPC_LEGENDARY_CARD_RIGHT_SPARK, $0e, $0a, SOUTH + dw $0000 + db $00 + diff --git a/src/data/npcs.asm b/src/data/npcs.asm index caa11af..99979ce 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -1,110 +1,111 @@ ; When you press the A button in front of something it will find a data entry somewhere on this list ; it will then jump to the pointer in the data item. All jumps lead to an RST20 operation. -PointerTable_118f5: - dw Data_119dd - dw Data_119dd - dw Data_119ea - dw Data_11a11 - dw Data_11a1e - dw Data_119dd - dw Data_119dd - dw Data_11a2b - dw Data_11a38 - dw Data_11a45 - dw Data_11a52 - dw Data_11a5f - dw Data_11a6c - dw Data_11a79 - dw Data_11a86 - dw Data_11a93 - dw Data_11aa0 - dw Data_11aad - dw Data_11aba - dw Data_11ac7 - dw Data_11ad4 - dw Data_11ae1 - dw Data_11aee - dw Data_11afb - dw Data_11b08 - dw Data_11b15 - dw Data_11b22 - dw Data_11b2f - dw Data_11b3c - dw Data_11b49 - dw Data_11b56 +; The Deck IDs are used for the challenge hall +NPCDataTable: + dw DrMasonData + dw DrMasonData + dw Ronald1Data + dw IshiharaData + dw ImakuniData + dw DrMasonData + dw DrMasonData + dw SamData + dw Tech1Data + dw Tech2Data + dw Tech3Data + dw Tech4Data + dw Tech5Data + dw Tech6Data + dw Clerk1Data + dw Clerk2Data + dw Clerk3Data + dw Clerk4Data + dw Clerk5Data + dw Clerk6Data + dw Clerk7Data + dw Clerk8Data + dw Clerk9Data + dw ChrisData + dw MichaelData + dw JessicaData + dw MitchData + dw MatthewData + dw RyanData + dw AndrewData + dw GeneData dw SaraData dw AmandaData - dw Data_11b7d - dw Data_11b8a - dw Data_11b97 - dw Data_11ba4 - dw Data_11bb1 - dw Data_11bbe - dw Data_11bcb - dw Data_11bd8 - dw Data_11be5 - dw Data_11bf2 - dw Data_11bff - dw Data_11c0c - dw Data_11c19 - dw Data_11c26 - dw Data_11c40 - dw Data_11c4d - dw Data_11c5a - dw Data_11c67 - dw Data_11c74 - dw Data_11c81 - dw Data_11c8e - dw Data_11c9b - dw Data_11ca8 - dw Data_11cb5 - dw Data_11cc2 - dw Data_11ccf - dw Data_11cdc - dw Data_11ce9 - dw Data_11cf6 - dw Data_11d03 - dw Data_11d10 - dw Data_11d1d - dw Data_11d2a - dw Data_11d37 - dw Data_11d44 - dw Data_11d51 - dw Data_11d5e - dw Data_11d6b - dw Data_11d78 - dw Data_11d85 - dw Data_11d92 - dw Data_11d9f - dw Data_11dac - dw Data_11db9 - dw Data_11dc6 - dw Data_11dd3 - dw Data_11de0 - dw Data_11ded - dw Data_11dfa - dw Data_11e07 - dw Data_11e14 - dw Data_11e21 - dw Data_11e2e - dw Data_11e3b - dw Data_11e48 - dw Data_11e55 - dw Data_11e62 - dw Data_11e6f - dw Data_11e7c - dw Data_11e89 - dw Data_11e96 - dw Data_11ea3 - dw Data_11eb0 - dw Data_11ebd - dw Data_11eca - dw Data_11ed7 - dw Data_11ee4 - dw Data_11ef1 - dw Data_11efe - dw Data_11f0b - dw Data_11f18 + dw JoshuaData + dw AmyData + dw JenniferData + dw NicholasData + dw BrandonData + dw IsaacData + dw BrittanyData + dw KristinData + dw HeatherData + dw NikkiData + dw RobertData + dw DanielData + dw StephanieData + dw Murray1Data + dw JosephData + dw DavidData + dw ErikData + dw RickData + dw JohnData + dw AdamData + dw JonathanData + dw KenData + dw CourtneyData + dw SteveData + dw JackData + dw RodData + dw Clerk10Data + dw GiftCenterClerkData + dw Man1Data + dw Woman1Data + dw Chap1Data + dw Gal1Data + dw Lass1Data + dw Chap2Data + dw Lass2Data + dw Pappy1Data + dw Lad1Data + dw Lad2Data + dw Chap3Data + dw Clerk12Data + dw Clerk13Data + dw HostData + dw Specs1Data + dw ButchData + dw Granny1Data + dw Lass3Data + dw Man2Data + dw Pappy2Data + dw Lass4Data + dw Hood1Data + dw Granny2Data + dw Gal2Data + dw Lad3Data + dw Gal3Data + dw Chap4Data + dw Man3Data + dw Specs2Data + dw Specs3Data + dw Woman2Data + dw ManiaData + dw Pappy3Data + dw Gal4Data + dw ChampData + dw Hood2Data + dw Lass5Data + dw Chap5Data + dw AaronData + dw GuideData + dw Tech7Data + dw Tech8Data + dw Data_11f18 ; these actually are used for the effects around the legendary cards dw Data_11f1f dw Data_11f26 dw Data_11f2d @@ -113,1398 +114,1295 @@ PointerTable_118f5: dw Data_11f42 dw Data_11f49 dw Data_11f49 - dw Data_11c33 - dw Data_119f7 - dw Data_11a04 + dw Murray2Data + dw Ronald2Data + dw Ronald3Data dw Data_11f49 -Data_119dd: - db $01 +DrMasonData: + db NPC_DRMASON db $02 db $00 db $26 db $00 - dw $5727 ; Pointer to NPC Data - db $ac - db $03 + dw $5727 ; Pointer to Script + tx Text03ac db $00 db $00 db $00 db $00 -Data_119ea: - db $02 +Ronald1Data: + db NPC_RONALD1 db $01 db $04 db $0e db $00 - dw $5c4b ; Pointer to NPC Data - db $ad - db $03 - db $02 - db $1a + dw Script_Ronald ; Pointer to Script + tx Text03ad + db RONALD_PIC + db INVINCIBLE_RONALD_DECK_ID db $0f db $16 -Data_119f7: - db $71 +Ronald2Data: + db NPC_RONALD2 db $01 db $04 db $0e db $00 - dw $5c4b ; Pointer to NPC Data - db $ad - db $03 - db $02 - db $1a + dw Script_Ronald ; Pointer to Script + tx Text03ad + db RONALD_PIC + db INVINCIBLE_RONALD_DECK_ID db $0f db $16 -Data_11a04: - db $72 +Ronald3Data: + db NPC_RONALD3 db $01 db $04 db $0e db $00 - dw $5c4b ; Pointer to NPC Data - db $ad - db $03 - db $02 - db $1a + dw Script_Ronald ; Pointer to Script + tx Text03ad + db RONALD_PIC + db INVINCIBLE_RONALD_DECK_ID db $0f db $16 -Data_11a11: - db $03 +IshiharaData: + db NPC_ISHIHARA db $03 db $04 db $22 db $00 - dw $5b4a ; Pointer to NPC Data - db $ae - db $03 + dw Script_Ishihara ; Pointer to Script + tx Text03ae db $00 db $00 db $00 db $00 -Data_11a1e: - db $04 +ImakuniData: + db NPC_IMAKUNI db $04 db $00 db $0e db $00 - dw $5d0d ; Pointer to NPC Data - db $af - db $03 - db $04 - db $34 + dw Script_Imakuni ; Pointer to Script + tx Text03af + db IMAKUNI_PIC + db IMAKUNI_DECK_ID db $10 db $15 -Data_11a2b: - db $07 +SamData: + db NPC_SAM db $18 db $00 db $0e db $00 - dw $561d ; Pointer to NPC Data - db $b1 - db $03 - db $03 - db $02 + dw $561d ; Pointer to Script + tx Text03b1 + db SAM_PIC + db SAMS_NORMAL_DECK_ID db $02 db $15 -Data_11a38: - db $08 +Tech1Data: + db NPC_TECH1 db $18 db $00 db $0e db $00 - dw $5583 ; Pointer to NPC Data - db $b2 - db $03 + dw $5583 ; Pointer to Script + tx Text03b2 db $00 db $00 db $00 db $00 -Data_11a45: - db $09 +Tech2Data: + db NPC_TECH2 db $18 db $00 db $0e db $00 - dw $55ca ; Pointer to NPC Data - db $b2 - db $03 + dw $55ca ; Pointer to Script + tx Text03b2 db $00 db $00 db $00 db $00 -Data_11a52: - db $0a +Tech3Data: + db NPC_TECH3 db $18 db $00 db $0e db $00 - dw $55d5 ; Pointer to NPC Data - db $b2 - db $03 + dw $55d5 ; Pointer to Script + tx Text03b2 db $00 db $00 db $00 db $00 -Data_11a5f: - db $0b +Tech4Data: + db NPC_TECH4 db $18 db $00 db $0e db $00 - dw $55e0 ; Pointer to NPC Data - db $b2 - db $03 + dw $55e0 ; Pointer to Script + tx Text03b2 db $00 db $00 db $00 db $00 -Data_11a6c: - db $0c +Tech5Data: + db NPC_TECH5 db $18 db $00 db $0e db $00 - dw $55f9 ; Pointer to NPC Data - db $b2 - db $03 + dw $55f9 ; Pointer to Script + tx Text03b2 db $00 db $00 db $00 db $00 -Data_11a79: - db $0d +Tech6Data: + db NPC_TECH6 db $18 db $00 db $0e db $00 - dw $58bb ; Pointer to NPC Data - db $b2 - db $03 + dw $58bb ; Pointer to Script + tx Text03b2 db $00 db $00 db $00 db $00 -Data_11a86: - db $0e +Clerk1Data: + db NPC_CLERK1 db $21 db $0a db $30 db $00 - dw $5c64 ; Pointer to NPC Data - db $b3 - db $03 + dw Script_Clerk1 ; Pointer to Script + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11a93: - db $0f +Clerk2Data: + db NPC_CLERK2 db $21 db $0a db $30 db $00 - dw $5ed1 ; Pointer to NPC Data - db $b3 - db $03 + dw $5ed1 ; Pointer to Script + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11aa0: - db $10 +Clerk3Data: + db NPC_CLERK3 db $21 db $0a db $30 db $00 - dw $609e ; Pointer to NPC Data - db $b3 - db $03 + dw $609e ; Pointer to Script + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11aad: - db $11 +Clerk4Data: + db NPC_CLERK4 db $21 db $0a db $30 db $00 - dw $6369 ; Pointer to NPC Data - db $b3 - db $03 + dw $6369 ; Pointer to Script + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11aba: - db $12 +Clerk5Data: + db NPC_CLERK5 db $21 db $0a db $30 db $00 - dw $6566 ; Pointer to NPC Data - db $b3 - db $03 + dw $6566 ; Pointer to Script + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11ac7: - db $13 +Clerk6Data: + db NPC_CLERK6 db $21 db $0a db $30 db $00 - dw $684c ; Pointer to NPC Data - db $b3 - db $03 + dw $684c ; Pointer to Script + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11ad4: - db $14 +Clerk7Data: + db NPC_CLERK7 db $21 db $0a db $30 db $00 - dw $6b53 ; Pointer to NPC Data - db $b3 - db $03 + dw $6b53 ; Pointer to Script + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11ae1: - db $15 +Clerk8Data: + db NPC_CLERK8 db $21 db $0a db $30 db $00 - dw $6d45 ; Pointer to NPC Data - db $b3 - db $03 + dw $6d45 ; Pointer to Script + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11aee: - db $16 +Clerk9Data: + db NPC_CLERK9 db $21 db $0a db $30 db $00 - dw $7025 ; Pointer to NPC Data - db $b3 - db $03 + dw Script_Clerk9 ; Pointer to Script + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11afb: - db $17 +ChrisData: + db NPC_CHRIS db $15 db $00 db $26 db $00 - dw $5ef2 ; Pointer to NPC Data - db $b4 - db $03 - db $1d - db $1c + dw $5ef2 ; Pointer to Script + tx Text03b4 + db CHRIS_PIC + db MUSCLES_FOR_BRAINS_DECK_ID db $03 db $15 -Data_11b08: - db $18 +MichaelData: + db NPC_MICHAEL db $15 db $00 db $26 db $00 - dw $6573 ; Pointer to NPC Data - db $b5 - db $03 - db $1e - db $1d + dw $6573 ; Pointer to Script + tx Text03b5 + db MICHAEL_PIC + db HEATED_BATTLE_DECK_ID db $03 db $15 -Data_11b15: - db $19 +JessicaData: + db NPC_JESSICA db $1f db $04 db $1a db $00 - dw $6d96 ; Pointer to NPC Data - db $b6 - db $03 - db $27 - db $1e + dw $6d96 ; Pointer to Script + tx Text03b6 + db JESSICA_PIC + db LOVE_TO_BATTLE_DECK_ID db $03 db $15 -Data_11b22: - db $1a +MitchData: + db NPC_MITCH db $0a db $00 db $0e db $00 - dw $5dc3 ; Pointer to NPC Data - db $b7 - db $03 - db $0a - db $10 + dw $5dc3 ; Pointer to Script + tx Text03b7 + db MITCH_PIC + db FIRST_STRIKE_DECK_ID db $03 db $16 -Data_11b2f: - db $1b +MatthewData: + db NPC_MATTHEW db $15 db $00 db $16 db $00 - dw $5f39 ; Pointer to NPC Data - db $b8 - db $03 - db $1a - db $21 + dw $5f39 ; Pointer to Script + tx Text03b8 + db MATTHEW_PIC + db HARD_POKEMON_DECK_ID db $03 db $15 -Data_11b3c: - db $1c +RyanData: + db NPC_RYAN db $11 db $00 db $26 db $00 - dw $5ff0 ; Pointer to NPC Data - db $b9 - db $03 - db $1b - db $1f + dw $5ff0 ; Pointer to Script + tx Text03b9 + db RYAN_PIC + db EXCAVATION_DECK_ID db $03 db $15 -Data_11b49: - db $1d +AndrewData: + db NPC_ANDREW db $1a db $00 db $16 db $00 - dw $6017 ; Pointer to NPC Data - db $ba - db $03 - db $1c - db $20 + dw $6017 ; Pointer to Script + tx Text03ba + db ANDREW_PIC + db BLISTERING_POKEMON_DECK_ID db $03 db $15 -Data_11b56: - db $1e +GeneData: + db NPC_GENE db $0b db $04 db $1e db $00 - dw $603e ; Pointer to NPC Data - db $bb - db $03 - db $0b - db $11 + dw $603e ; Pointer to Script + tx Text03bb + db GENE_PIC + db ROCK_CRUSHER_DECK_ID db $03 db $16 SaraData: - db SARA ; trainer id + db NPC_SARA db $20 db $00 db $0e db $00 - dw OWSequence_Sara ; Pointer to NPC Data - db $bc - db $03 - db SARA_PIC ; battle profile picture - db $22 + dw Script_Sara ; Pointer to Script + tx Text03bc + db SARA_PIC + db WATERFRONT_POKEMON_DECK_ID db $03 db $15 AmandaData: - db AMANDA + db NPC_AMANDA db $20 db $00 db $16 db $00 - dw OWSequence_Amanda ; Pointer to NPC Data - db $bd - db $03 + dw Script_Amanda ; Pointer to Script + tx Text03bd db AMANDA_PIC ; battle profile picture - db $23 + db LONELY_FRIENDS_DECK_ID db $03 db $15 -Data_11b7d: - db $21 +JoshuaData: + db NPC_JOSHUA db $16 db $00 db $26 db $00 - dw OWSequence_Joshua ; Pointer to NPC Data - db $be - db $03 - db $17 - db $24 + dw Script_Joshua ; Pointer to Script + tx Text03be + db JOSHUA_PIC + db SOUND_OF_THE_WAVES_DECK_ID db $03 db $15 -Data_11b8a: - db $22 +AmyData: + db NPC_AMY db $08 db $08 db $2e db $10 - dw $6304 ; Pointer to NPC Data - db $bf - db $03 - db $08 - db $12 + dw Script_Amy ; Pointer to Script + tx Text03bf + db AMY_PIC + db GO_GO_RAIN_DANCE_DECK_ID db $03 db $16 -Data_11b97: - db $23 +JenniferData: + db NPC_JENNIFER db $1c db $04 db $0e db $00 - dw $6408 ; Pointer to NPC Data - db $c0 - db $03 - db $26 - db $25 + dw $6408 ; Pointer to Script + tx Text03c0 + db JENNIFER_PIC + db PIKACHU_DECK_ID db $03 db $15 -Data_11ba4: - db $24 +NicholasData: + db NPC_NICHOLAS db $17 db $04 db $1e db $00 - dw $642f ; Pointer to NPC Data - db $c1 - db $03 - db $18 - db $26 + dw $642f ; Pointer to Script + tx Text03c1 + db NICHOLAS_PIC + db BOOM_BOOM_SELFDESTRUCT_DECK_ID db $03 db $15 -Data_11bb1: - db $25 +BrandonData: + db NPC_BRANDON db $17 db $04 db $1e db $00 - dw $6456 ; Pointer to NPC Data - db $c2 - db $03 - db $19 - db $27 + dw $6456 ; Pointer to Script + tx Text03c2 + db BRANDON_PIC + db POWER_GENERATOR_DECK_ID db $03 db $15 -Data_11bbe: - db $26 +IsaacData: + db NPC_ISAAC db $09 db $00 db $16 db $00 - dw $64ad ; Pointer to NPC Data - db $c3 - db $03 - db $09 - db $13 + dw $64ad ; Pointer to Script + tx Text03c3 + db ISAAC_PIC + db ZAPPING_SELFDESTRUCT_DECK_ID db $03 db $16 -Data_11bcb: - db $27 +BrittanyData: + db NPC_BRITTANY db $1c db $04 db $0e db $00 - dw $65d2 ; Pointer to NPC Data - db $c4 - db $03 - db $21 - db $28 + dw Script_Brittany ; Pointer to Script + tx Text03c4 + db BRITTANY_PIC + db ETCETERA_DECK_ID db $03 db $15 -Data_11bd8: - db $28 +KristinData: + db NPC_KRISTIN db $1e db $00 db $1e db $00 - dw $6701 ; Pointer to NPC Data - db $c5 - db $03 - db $22 - db $29 + dw $6701 ; Pointer to Script + tx Text03c5 + db KRISTIN_PIC + db FLOWER_GARDEN_DECK_ID db $03 db $15 -Data_11be5: - db $29 +HeatherData: + db NPC_HEATHER db $1d db $04 db $22 db $00 - dw $6745 ; Pointer to NPC Data - db $c6 - db $03 - db $23 - db $2a + dw $6745 ; Pointer to Script + tx Text03c6 + db HEATHER_PIC + db KALEIDOSCOPE_DECK_ID db $03 db $15 -Data_11bf2: - db $2a +NikkiData: + db NPC_NIKKI db $05 db $00 db $1a db $00 - dw $679e ; Pointer to NPC Data - db $c7 - db $03 - db $05 - db $14 + dw $679e ; Pointer to Script + tx Text03c7 + db NIKKI_PIC + db FLOWER_POWER_DECK_ID db $03 db $16 -Data_11bff: - db $2b +RobertData: + db NPC_ROBERT db $11 db $04 db $16 db $00 - dw $6980 ; Pointer to NPC Data - db $c8 - db $03 - db $20 - db $2b + dw $6980 ; Pointer to Script + tx Text03c8 + db ROBERT_PIC + db GHOST_DECK_ID db $03 db $15 -Data_11c0c: - db $2c +DanielData: + db NPC_DANIEL db $12 db $04 db $1a db $00 - dw $6a60 ; Pointer to NPC Data - db $c9 - db $03 - db $1f - db $2c + dw $6a60 ; Pointer to Script + tx Text03c9 + db DANIEL_PIC + db NAP_TIME_DECK_ID db $03 db $15 -Data_11c19: - db $2d +StephanieData: + db NPC_STEPHANIE db $1c db $04 db $0e db $00 - dw $6aa2 ; Pointer to NPC Data - db $ca - db $03 - db $28 - db $2d + dw $6aa2 ; Pointer to Script + tx Text03ca + db STEPHANIE_PIC + db STRANGE_POWER_DECK_ID db $03 db $15 -Data_11c26: - db $2e +Murray1Data: + db NPC_MURRAY1 db $0c db $00 db $12 db $00 - dw $6adf ; Pointer to NPC Data - db $cb - db $03 - db $0c - db $15 + dw $6adf ; Pointer to Script + tx Text03cb + db MURRAY_PIC + db STRANGE_PSYSHOCK_DECK_ID db $03 db $16 -Data_11c33: - db $70 +Murray2Data: + db NPC_MURRAY2 db $0c db $03 db $15 db $10 - dw $6adf ; Pointer to NPC Data - db $cb - db $03 - db $0c - db $15 + dw $6adf ; Pointer to Script + tx Text03cb + db MURRAY_PIC + db STRANGE_PSYSHOCK_DECK_ID db $03 db $16 -Data_11c40: - db $2f +JosephData: + db NPC_JOSEPH db $18 db $00 db $0e db $00 - dw $6cdb ; Pointer to NPC Data - db $cc - db $03 - db $11 - db $2e + dw $6cdb ; Pointer to Script + tx Text03cc + db JOSEPH_PIC + db FLYIN_POKEMON_DECK_ID db $03 db $15 -Data_11c4d: - db $30 +DavidData: + db NPC_DAVID db $18 db $00 db $0e db $00 - dw $6c11 ; Pointer to NPC Data - db $cd - db $03 - db $12 - db $2f + dw $6c11 ; Pointer to Script + tx Text03cd + db DAVID_PIC + db LOVELY_NIDORAN_DECK_ID db $03 db $15 -Data_11c5a: - db $31 +ErikData: + db NPC_ERIK db $18 db $00 db $0e db $00 - dw $6c42 ; Pointer to NPC Data - db $ce - db $03 - db $13 - db $30 + dw $6c42 ; Pointer to Script + tx Text03ce + db ERIK_PIC + db POISON_DECK_ID db $03 db $15 -Data_11c67: - db $32 +RickData: + db NPC_RICK db $06 db $00 db $0e db $00 - dw $6c67 ; Pointer to NPC Data - db $cf - db $03 - db $06 - db $16 + dw $6c67 ; Pointer to Script + tx Text03cf + db RICK_PIC + db WONDERS_OF_SCIENCE_DECK_ID db $03 db $16 -Data_11c74: - db $33 +JohnData: + db NPC_JOHN db $12 db $04 db $1a db $00 - dw $6eb3 ; Pointer to NPC Data - db $d0 - db $03 - db $14 - db $31 + dw $6eb3 ; Pointer to Script + tx Text03d0 + db JOHN_PIC + db ANGER_DECK_ID db $03 db $15 -Data_11c81: - db $34 +AdamData: + db NPC_ADAM db $13 db $00 db $22 db $00 - dw $6ed8 ; Pointer to NPC Data - db $d1 - db $03 - db $15 - db $32 + dw $6ed8 ; Pointer to Script + tx Text03d1 + db ADAM_PIC + db FLAMETHROWER_DECK_ID db $03 db $15 -Data_11c8e: - db $35 +JonathanData: + db NPC_JONATHAN db $11 db $04 db $16 db $00 - dw $6efd ; Pointer to NPC Data - db $d2 - db $03 - db $16 - db $33 + dw $6efd ; Pointer to Script + tx Text03d2 + db JONATHAN_PIC + db RESHUFFLE_DECK_ID db $03 db $15 -Data_11c9b: - db $36 +KenData: + db NPC_KEN db $07 db $04 db $1e db $00 - dw $6f22 ; Pointer to NPC Data - db $d3 - db $03 - db $07 - db $17 + dw $6f22 ; Pointer to Script + tx Text03d3 + db KEN_PIC + db FIRE_CHARGE_DECK_ID db $03 db $16 -Data_11ca8: - db $37 +CourtneyData: + db NPC_COURTNEY db $0d db $00 db $12 db $00 - dw $771f ; Pointer to NPC Data - db $d4 - db $03 - db $0d - db $0c + dw $771f ; Pointer to Script + tx Text03d4 + db COURTNEY_PIC + db LEGENDARY_MOLTRES_DECK_ID db $04 db $17 -Data_11cb5: - db $38 +SteveData: + db NPC_STEVE db $0e db $00 db $2a db $00 - dw $772a ; Pointer to NPC Data - db $d5 - db $03 - db $0e - db $0d + dw $772a ; Pointer to Script + tx Text03d5 + db STEVE_PIC + db LEGENDARY_ZAPDOS_DECK_ID db $04 db $17 -Data_11cc2: - db $39 +JackData: + db NPC_JACK db $0f db $00 db $26 db $00 - dw $7735 ; Pointer to NPC Data - db $d6 - db $03 - db $0f - db $0e + dw $7735 ; Pointer to Script + tx Text03d6 + db JACK_PIC + db LEGENDARY_ARTICUNO_DECK_ID db $04 db $17 -Data_11ccf: - db $3a +RodData: + db NPC_ROD db $10 db $00 db $0e db $00 - dw $7740 ; Pointer to NPC Data - db $d7 - db $03 - db $10 - db $0f + dw $7740 ; Pointer to Script + tx Text03d7 + db ROD_PIC + db LEGENDARY_DRAGONITE_DECK_ID db $04 db $17 -Data_11cdc: - db $3b +Clerk10Data: + db NPC_CLERK10 db $21 db $0a db $30 db $00 - dw $4c3e ; Pointer to NPC Data - db $b0 - db $03 + dw NoOverworldSequence ; Pointer to Script + tx Text03b0 db $00 db $00 db $00 db $00 -Data_11ce9: - db $3c +GiftCenterClerkData: + db NPC_GIFT_CENTER_CLERK db $21 db $0a db $30 db $00 - dw $4c3e ; Pointer to NPC Data - db $b0 - db $03 + dw NoOverworldSequence ; Pointer to Script + tx Text03b0 db $00 db $00 db $00 db $00 -Data_11cf6: - db $3d +Man1Data: + db NPC_MAN1 db $1a db $00 db $16 db $00 - dw $5c76 ; Pointer to NPC Data - db $d8 - db $03 + dw $5c76 ; Pointer to Script + tx Text03d8 db $00 db $00 db $00 db $00 -Data_11d03: - db $3e +Woman1Data: + db NPC_WOMAN1 db $23 db $04 db $1e db $00 - dw $5f83 ; Pointer to NPC Data - db $d9 - db $03 + dw $5f83 ; Pointer to Script + tx Text03d9 db $00 db $00 db $00 db $00 -Data_11d10: - db $3f +Chap1Data: + db NPC_CHAP1 db $19 db $00 db $1a db $00 - dw $5fc0 ; Pointer to NPC Data - db $da - db $03 + dw $5fc0 ; Pointer to Script + tx Text03da db $00 db $00 db $00 db $00 -Data_11d1d: - db $40 +Gal1Data: + db NPC_GAL1 db $22 db $00 db $16 db $00 - dw $60cf ; Pointer to NPC Data - db $db - db $03 + dw Script_Gal1 ; Pointer to Script + tx Text03db db $00 db $00 db $00 db $00 -Data_11d2a: - db $41 +Lass1Data: + db NPC_LASS1 db $1e db $00 db $1e db $00 - dw $6111 ; Pointer to NPC Data - db $dc - db $03 + dw Script_Lass1 ; Pointer to Script + tx Text03dc db $00 db $00 db $00 db $00 -Data_11d37: - db $42 +Chap2Data: + db NPC_CHAP2 db $19 db $00 db $1a db $00 - dw $639a ; Pointer to NPC Data - db $da - db $03 + dw $639a ; Pointer to Script + tx Text03da db $00 db $00 db $00 db $00 -Data_11d44: - db $43 +Lass2Data: + db NPC_LASS2 db $1e db $00 db $1e db $00 - dw $661f ; Pointer to NPC Data - db $dc - db $03 + dw Script_e61f ; Pointer to Script + tx Text03dc db $00 db $00 db $00 db $00 -Data_11d51: - db $44 +Pappy1Data: + db NPC_PAPPY1 db $1b db $00 db $22 db $00 - dw $69a5 ; Pointer to NPC Data - db $dd - db $03 + dw $69a5 ; Pointer to Script + tx Text03dd db $00 db $00 db $00 db $00 -Data_11d5e: - db $45 +Lad1Data: + db NPC_LAD1 db $12 db $04 db $1a db $00 - dw $6b84 ; Pointer to NPC Data - db $de - db $03 + dw $6b84 ; Pointer to Script + tx Text03de db $00 db $00 db $00 db $00 -Data_11d6b: - db $46 +Lad2Data: + db NPC_LAD2 db $11 db $04 db $16 db $00 - dw $6e2c ; Pointer to NPC Data - db $de - db $03 + dw $6e2c ; Pointer to Script + tx Text03de db $00 db $00 db $00 db $00 -Data_11d78: - db $47 +Chap3Data: + db NPC_CHAP3 db $19 db $00 db $1a db $00 - dw $6de8 ; Pointer to NPC Data - db $da - db $03 + dw $6de8 ; Pointer to Script + tx Text03da db $00 db $00 db $00 db $00 -Data_11d85: - db $48 +Clerk12Data: + db NPC_CLERK12 db $22 db $00 db $16 db $00 - dw $7295 ; Pointer to NPC Data - db $b3 - db $03 + dw Script_Clerk12 ; Pointer to Script + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11d92: - db $49 +Clerk13Data: + db NPC_CLERK13 db $22 db $00 db $16 db $00 - dw $726c ; Pointer to NPC Data - db $b3 - db $03 + dw Script_Clerk13 ; Pointer to Script + tx Text03b3 db $00 db $00 db $00 db $00 -Data_11d9f: - db $4a +HostData: + db NPC_HOST db $22 db $00 db $16 db $00 - dw $7352 ; Pointer to NPC Data - db $df - db $03 + dw Script_HostStubbed ; Pointer to Script + tx Text03df db $00 db $00 db $00 db $00 -Data_11dac: - db $4b +Specs1Data: + db NPC_SPECS1 db $13 db $00 db $22 db $00 - dw $5d82 ; Pointer to NPC Data - db $e0 - db $03 + dw $5d82 ; Pointer to Script + tx Text03e0 db $00 db $00 db $00 db $00 -Data_11db9: - db $4c +ButchData: + db NPC_BUTCH db $14 db $00 db $16 db $00 - dw $5d8d ; Pointer to NPC Data - db $e1 - db $03 + dw $5d8d ; Pointer to Script + tx Text03e1 db $00 db $00 db $00 db $00 -Data_11dc6: - db $4d +Granny1Data: + db NPC_GRANNY1 db $24 db $00 db $16 db $00 - dw $5d9f ; Pointer to NPC Data - db $e5 - db $03 + dw $5d9f ; Pointer to Script + tx Text03e5 db $00 db $00 db $00 db $00 -Data_11dd3: - db $4e +Lass3Data: + db NPC_LASS3 db $1d db $04 db $22 db $00 - dw $5fd2 ; Pointer to NPC Data - db $dc - db $03 + dw $5fd2 ; Pointer to Script + tx Text03dc db $00 db $00 db $00 db $00 -Data_11de0: - db $4f +Man2Data: + db NPC_MAN2 db $1a db $00 db $16 db $00 - dw $6137 ; Pointer to NPC Data - db $d8 - db $03 + dw Script_Man2 ; Pointer to Script + tx Text03d8 db $00 db $00 db $00 db $00 -Data_11ded: - db $50 +Pappy2Data: + db NPC_PAPPY2 db $1b db $00 db $22 db $00 - dw $613b ; Pointer to NPC Data - db $dd - db $03 + dw Script_Pappy2 ; Pointer to Script + tx Text03dd db $00 db $00 db $00 db $00 -Data_11dfa: - db $51 +Lass4Data: + db NPC_LASS4 db $1d db $04 db $22 db $00 - dw $63d9 ; Pointer to NPC Data - db $dc - db $03 + dw $63d9 ; Pointer to Script + tx Text03dc db $00 db $00 db $00 db $00 -Data_11e07: - db $52 +Hood1Data: + db NPC_HOOD1 db $17 db $04 db $1e db $00 - dw $63dd ; Pointer to NPC Data - db $e2 - db $03 + dw $63dd ; Pointer to Script + tx Text03e2 db $00 db $00 db $00 db $00 -Data_11e14: - db $53 +Granny2Data: + db NPC_GRANNY2 db $24 db $00 db $16 db $00 - dw $66d8 ; Pointer to NPC Data - db $e5 - db $03 + dw $66d8 ; Pointer to Script + tx Text03e5 db $00 db $00 db $00 db $00 -Data_11e21: - db $54 +Gal2Data: + db NPC_GAL2 db $22 db $00 db $16 db $00 - dw $66e3 ; Pointer to NPC Data - db $db - db $03 + dw $66e3 ; Pointer to Script + tx Text03db db $00 db $00 db $00 db $00 -Data_11e2e: - db $55 +Lad3Data: + db NPC_LAD3 db $12 db $04 db $1a db $00 - dw $6850 ; Pointer to NPC Data - db $de - db $03 + dw $6850 ; Pointer to Script + tx Text03de db $00 db $00 db $00 db $00 -Data_11e3b: - db $56 +Gal3Data: + db NPC_GAL3 db $22 db $00 db $16 db $00 - dw $6a30 ; Pointer to NPC Data - db $db - db $03 + dw $6a30 ; Pointer to Script + tx Text03db db $00 db $00 db $00 db $00 -Data_11e48: - db $57 +Chap4Data: + db NPC_CHAP4 db $19 db $00 db $1a db $00 - dw $6a3b ; Pointer to NPC Data - db $da - db $03 + dw $6a3b ; Pointer to Script + tx Text03da db $00 db $00 db $00 db $00 -Data_11e55: - db $58 +Man3Data: + db NPC_MAN3 db $1a db $00 db $16 db $00 - dw $6bc1 ; Pointer to NPC Data - db $d8 - db $03 + dw $6bc1 ; Pointer to Script + tx Text03d8 db $00 db $00 db $00 db $00 -Data_11e62: - db $59 +Specs2Data: + db NPC_SPECS2 db $18 db $00 db $0e db $00 - dw $6bc5 ; Pointer to NPC Data - db $e0 - db $03 + dw $6bc5 ; Pointer to Script + tx Text03e0 db $00 db $00 db $00 db $00 -Data_11e6f: - db $5a +Specs3Data: + db NPC_SPECS3 db $13 db $00 db $22 db $00 - dw $6bed ; Pointer to NPC Data - db $e0 - db $03 + dw $6bed ; Pointer to Script + tx Text03e0 db $00 db $00 db $00 db $00 -Data_11e7c: - db $5b +Woman2Data: + db NPC_WOMAN2 db $23 db $04 db $1e db $00 - dw $4c3e ; Pointer to NPC Data - db $d9 - db $03 + dw NoOverworldSequence ; Pointer to Script + tx Text03d9 db $00 db $00 db $00 db $00 -Data_11e89: - db $5c +ManiaData: + db NPC_MANIA db $15 db $00 db $26 db $00 - dw $6e88 ; Pointer to NPC Data - db $e4 - db $03 + dw $6e88 ; Pointer to Script + tx Text03e4 db $00 db $00 db $00 db $00 -Data_11e96: - db $5d +Pappy3Data: + db NPC_PAPPY3 db $1b db $00 db $22 db $00 - dw $709c ; Pointer to NPC Data - db $dd - db $03 + dw Script_Pappy3 ; Pointer to Script + tx Text03dd db $00 db $00 db $00 db $00 -Data_11ea3: - db $5e +Gal4Data: + db NPC_GAL4 db $22 db $00 db $16 db $00 - dw $70a0 ; Pointer to NPC Data - db $db - db $03 + dw Script_Gal4 ; Pointer to Script + tx Text03db db $00 db $00 db $00 db $00 -Data_11eb0: - db $5f +ChampData: + db NPC_CHAMP db $15 db $00 db $26 db $00 - dw $70a4 ; Pointer to NPC Data - db $e3 - db $03 + dw Script_Champ ; Pointer to Script + tx Text03e3 db $00 db $00 db $00 db $00 -Data_11ebd: - db $60 +Hood2Data: + db NPC_HOOD2 db $17 db $04 db $1e db $00 - dw $70a8 ; Pointer to NPC Data - db $e2 - db $03 + dw Script_Hood2 ; Pointer to Script + tx Text03e2 db $00 db $00 db $00 db $00 -Data_11eca: - db $61 +Lass5Data: + db NPC_LASS5 db $1f db $04 db $1a db $00 - dw $70ac ; Pointer to NPC Data - db $dc - db $03 + dw Script_Lass5 ; Pointer to Script + tx Text03dc db $00 db $00 db $00 db $00 -Data_11ed7: - db $62 +Chap5Data: + db NPC_CHAP5 db $19 db $00 db $1a db $00 - dw $70b0 ; Pointer to NPC Data - db $da - db $03 + dw Script_Chap5 ; Pointer to Script + tx Text03da db $00 db $00 db $00 db $00 -Data_11ee4: - db $63 +AaronData: + db NPC_AARON db $18 db $00 db $0e db $00 - dw $58dd ; Pointer to NPC Data - db $e7 - db $03 - db $29 - db $09 + dw $58dd ; Pointer to Script + tx Text03e7 + db AARON_PIC + db LIGHTNING_AND_FIRE_DECK_ID db $02 db $15 -Data_11ef1: - db $64 +GuideData: + db NPC_GUIDE db $1a db $00 db $16 db $00 - dw $7283 ; Pointer to NPC Data - db $e6 - db $03 + dw Script_Guide ; Pointer to Script + tx Text03e6 db $00 db $00 db $00 db $00 -Data_11efe: - db $65 +Tech7Data: + db NPC_TECH7 db $18 db $00 db $0e db $00 - dw $58c6 ; Pointer to NPC Data - db $b2 - db $03 + dw $58c6 ; Pointer to Script + tx Text03b2 db $00 db $00 db $00 db $00 -Data_11f0b: - db $66 +Tech8Data: + db NPC_TECH8 db $18 db $00 db $0e db $00 - dw $58d1 ; Pointer to NPC Data - db $b2 - db $03 + dw $58d1 ; Pointer to Script + tx Text03b2 db $00 db $00 db $00 db $00 Data_11f18: - db $67 + db NPC_TORCH db $26 db $3a db $3a db $10 - dw $4c3e ; Pointer to NPC Data + dw NoOverworldSequence ; Pointer to Script Data_11f1f: - db $68 + db NPC_LEGENDARY_CARD_TOP_LEFT db $27 db $3b db $41 db $50 - dw $4c3e ; Pointer to NPC Data + dw NoOverworldSequence ; Pointer to Script Data_11f26: - db $69 + db NPC_LEGENDARY_CARD_TOP_RIGHT db $27 db $3c db $42 db $50 - dw $4c3e ; Pointer to NPC Data + dw NoOverworldSequence ; Pointer to Script Data_11f2d: - db $6a + db NPC_LEGENDARY_CARD_LEFT_SPARK db $27 db $3d db $43 db $50 - dw $4c3e ; Pointer to NPC Data + dw NoOverworldSequence ; Pointer to Script Data_11f34: - db $6b + db NPC_LEGENDARY_CARD_BOTTOM_LEFT db $27 db $3e db $44 db $50 - dw $4c3e ; Pointer to NPC Data + dw NoOverworldSequence ; Pointer to Script Data_11f3b: - db $6c + db NPC_LEGENDARY_CARD_BOTTOM_RIGHT db $27 db $3f db $45 db $50 - dw $4c3e ; Pointer to NPC Data + dw NoOverworldSequence ; Pointer to Script Data_11f42: - db $6d + db NPC_LEGENDARY_CARD_RIGHT_SPARK db $27 db $40 db $46 db $50 - dw $4c3e ; Pointer to NPC Data + dw NoOverworldSequence ; Pointer to Script Data_11f49: db $00 db $00 diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index 8f780eb..090ecf0 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -6288,10 +6288,10 @@ DiscardSavedDuelData: ; 6785 (1:6785) ; 0x6793 ; loads a player deck (sDeck*Cards) from SRAM to wPlayerDeck -; s0b700 determines which sDeck*Cards source (0-3) +; sCurrentlySelectedDeck determines which sDeck*Cards source (0-3) LoadPlayerDeck: ; 6793 (1:6793) call EnableSRAM - ld a, [s0b700] + ld a, [sCurrentlySelectedDeck] ld l, a ld h, sDeck2Cards - sDeck1Cards call HtimesL diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index d48250f..5a7761e 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -2171,7 +2171,7 @@ Func_8f8a: ; 8f8a (2:4f8a) Func_8f9d: ; 8f9d (2:4f9d) call EnableSRAM - ld a, [s0b700] + ld a, [sCurrentlySelectedDeck] call DisableSRAM ld h, $3 ld l, a @@ -2185,7 +2185,7 @@ Func_8f9d: ; 8f9d (2:4f9d) call FillRectangle ld a, [wceb1] call EnableSRAM - ld [s0b700], a + ld [sCurrentlySelectedDeck], a call DisableSRAM call Func_9326 call GetPointerToDeckName @@ -2519,7 +2519,7 @@ Func_9168: ; 9168 (2:5168) ld [wceb5], a .asm_9214 call EnableSRAM - ld a, [s0b700] + ld a, [sCurrentlySelectedDeck] ld c, a ld b, $0 ld d, $2 @@ -2539,7 +2539,7 @@ Func_9168: ; 9168 (2:5168) jr .asm_921f .asm_9234 ld a, c - ld [s0b700], a + ld [sCurrentlySelectedDeck], a call DisableSRAM call Func_9326 call EnableLCD @@ -2628,7 +2628,7 @@ Func_9314: ; 9314 (2:5314) Func_9326: ; 9326 (2:5326) call EnableSRAM - ld a, [s0b700] + ld a, [sCurrentlySelectedDeck] call DisableSRAM ld h, 3 ld l, a @@ -2643,7 +2643,32 @@ Func_9326: ; 9326 (2:5326) ret Func_9345: ; 9345 (2:5345) - INCROM $9345, $9843 + INCROM $9345, $9649 + +; checks if selected deck has any basics +Func_9649: ; 9649 (2:5649) + ld hl, wcf17 +.asm_964c + ld a, [hli] + ld e, a + or a + jr z, .asm_9665 + call LoadCardDataToBuffer1_FromCardID + jr c, .asm_9665 + ld a, [wLoadedCard1Type] + and $08 + jr nz, .asm_964c + ld a, [wLoadedCard1Stage] + or a + jr nz, .asm_964c + scf + ret +.asm_9665 + or a + ret +; 0x9667 + + INCROM $9667, $9843 Func_9843: ; 9843 (2:5843) INCROM $9843, $98a6 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index b33fd35..07e903e 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -29,11 +29,11 @@ LoadMap: ; c000 (3:4000) ld a, PLAYER_TURN ldh [hWhoseTurn], a farcall Func_1c440 - ld a, [wd0bb] + ld a, [wTempMap] ld [wCurMap], a - ld a, [wd0bc] + ld a, [wTempPlayerXCoord] ld [wPlayerXCoord], a - ld a, [wd0bd] + ld a, [wTempPlayerYCoord] ld [wPlayerYCoord], a call Func_c36a call Func_c184 @@ -54,7 +54,7 @@ LoadMap: ; c000 (3:4000) .asm_c092 call DoFrameIfLCDEnabled call SetScreenScroll - call Func_c0ce + call HandleOverworldMode ld hl, wd0b4 ld a, [hl] and $d0 @@ -79,13 +79,13 @@ LoadMap: ; c000 (3:4000) call Func_c280 ret -Func_c0ce: ; c0ce (3:40ce) - ld a, [wd0bf] +HandleOverworldMode: ; c0ce (3:40ce) + ld a, [wOverworldMode] res 7, a rlca - add LOW(PointerTable_c0e0) + add LOW(OverworldModePointers) ld l, a - ld a, HIGH(PointerTable_c0e0) + ld a, HIGH(OverworldModePointers) adc $0 ld h, a ld a, [hli] @@ -93,58 +93,59 @@ Func_c0ce: ; c0ce (3:40ce) ld l, a jp hl -PointerTable_c0e0: ; c0e0 (3:40e0) - dw Func_c0e8 - dw Func_c0ed - dw Func_c0f1 - dw Func_c10a +OverworldModePointers: ; c0e0 (3:40e0) + dw Func_c0e8 ; on map + dw CallHandlePlayerMoveMode + dw SetScriptData + dw EnterScript Func_c0e8: ; c0e8 (3:40e8) farcall Func_10e55 ret -Func_c0ed: ; c0ed (3:40ed) - call Func_c510 +CallHandlePlayerMoveMode: ; c0ed (3:40ed) + call HandlePlayerMoveMode ret -Func_c0f1: ; c0f1 (3:40f1) - ld a, [wd3b6] - ld [wd3aa], a - farcall Func_1c768 +SetScriptData: ; c0f1 (3:40f1) + ld a, [wScriptNPC] + ld [wLoadedNPCTempIndex], a + farcall SetNewScriptNPC ld a, c - ld [wd0c6], a + ld [wNextScript], a ld a, b - ld [wd0c7], a + ld [wNextScript+1], a ld a, $3 - ld [wd0bf], a - jr Func_c10a + ld [wOverworldMode], a + jr EnterScript -Func_c10a: ; c10a (3:410a) - ld hl, wd0c6 +EnterScript: ; c10a (3:410a) + ld hl, wNextScript ld a, [hli] ld h, [hl] ld l, a jp hl ; closes dialogue window. seems to be for other things as well. -CloseDialogueBox: ; c111 (3:4111) +CloseAdvancedDialogueBox: ; c111 (3:4111) ld a, [wd0c1] bit 0, a - call nz, Func_c135 + call nz, CloseTextBox ld a, [wd0c1] bit 1, a jr z, .asm_c12a - ld a, [wd3b6] - ld [wd3aa], a + ld a, [wScriptNPC] + ld [wLoadedNPCTempIndex], a farcall Func_1c5e9 .asm_c12a xor a ld [wd0c1], a ld a, [wd0c0] - ld [wd0bf], a + ld [wOverworldMode], a ret -Func_c135: ; c135 (3:4135) +; redraws the background and removes textbox control +CloseTextBox: ; c135 (3:4135) push hl farcall Func_80028 ld hl, wd0c1 @@ -175,12 +176,12 @@ Func_c158: ; c158 (3:4158) cp $1 ret nz ld a, [wd0c4] - ld [wd3ab], a - call Func_39c3 + ld [wTempNPC], a + call FindLoadedNPC jr c, .asm_c179 - ld a, [wd3aa] - ld l, $4 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_DIRECTION + call GetItemInLoadedNPCIndex ld a, [wd0c5] ld [hl], a farcall Func_1c58e @@ -188,7 +189,7 @@ Func_c158: ; c158 (3:4158) ret Func_c17a: ; c17a (3:417a) - ld a, [wd0bf] + ld a, [wOverworldMode] cp $3 ret z call Func_c9b8 @@ -203,7 +204,7 @@ Func_c184: ; c184 (3:4184) ld c, $0 .asm_c190 ld a, c - ld [wd0bf], a + ld [wOverworldMode], a ld [wd0c0], a pop bc ret @@ -230,13 +231,13 @@ Func_c1b1: ; c1b1 (3:41b1) ld a, $c ld [wd32e], a ld a, $0 - ld [wd0bb], a + ld [wTempMap], a ld a, $c - ld [wd0bc], a + ld [wTempPlayerXCoord], a ld a, $c - ld [wd0bd], a + ld [wTempPlayerYCoord], a ld a, $2 - ld [wd0be], a + ld [wTempPlayerDirection], a call Func_c9cb call Func_c9dd farcall Func_80b7a @@ -277,13 +278,13 @@ Func_c1f8: ; c1f8 (3:41f8) Func_c228: ; c228 (3:4228) ld a, [wCurMap] - ld [wd0bb], a + ld [wTempMap], a ld a, [wPlayerXCoord] - ld [wd0bc], a + ld [wTempPlayerXCoord], a ld a, [wPlayerYCoord] - ld [wd0bd], a - ld a, [wd334] - ld [wd0be], a + ld [wTempPlayerYCoord], a + ld a, [wPlayerDirection] + ld [wTempPlayerDirection], a ret Func_c241: ; c241 (3:4241) @@ -579,24 +580,24 @@ Func_c4b9: ; c4b9 (3:44b9) ld a, b ld [wd337], a ld a, $0 - farcall Func_1299f + farcall CreateSpriteAndAnimBufferEntry ld a, [wWhichSprite] - ld [wd336], a + ld [wPlayerSpriteIndex], a ld b, $2 ld a, [wCurMap] cp OVERWORLD_MAP jr z, .asm_c4ee - ld a, [wd0be] + ld a, [wTempPlayerDirection] ld b, a .asm_c4ee ld a, b - ld [wd334], a - call Func_c5e9 + ld [wPlayerDirection], a + call UpdatePlayerSprite ld a, [wCurMap] cp OVERWORLD_MAP call nz, Func_c6f7 xor a - ld [wd335], a + ld [wPlayerCurrentlyMoving], a ld [wd338], a ld a, [wCurMap] cp OVERWORLD_MAP @@ -605,42 +606,42 @@ Func_c4b9: ; c4b9 (3:44b9) .asm_c50f ret -Func_c510: ; c510 (3:4510) - ld a, [wd336] +HandlePlayerMoveMode: ; c510 (3:4510) + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a - ld a, [wd335] + ld a, [wPlayerCurrentlyMoving] bit 4, a ret nz bit 0, a - call z, Func_c5ac - ld a, [wd335] + call z, HandlePlayerMoveModeInput + ld a, [wPlayerCurrentlyMoving] or a - jr z, .asm_c535 + jr z, .notMoving bit 0, a call nz, Func_c66c - ld a, [wd335] + ld a, [wPlayerCurrentlyMoving] bit 1, a call nz, Func_c6dc ret -.asm_c535 +.notMoving ldh a, [hKeysPressed] and START - call nz, Func_c74d + call nz, OpenStartMenu ret Func_c53d: ; c53d (3:453d) - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a - ld a, [wd335] + ld a, [wPlayerCurrentlyMoving] bit 0, a call nz, Func_c687 - ld a, [wd335] + ld a, [wPlayerCurrentlyMoving] bit 1, a call nz, Func_c6dc ret Func_c554: ; c554 (3:4554) - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld a, [wCurMap] cp OVERWORLD_MAP @@ -694,80 +695,81 @@ Func_c58b: ; c58b (3:458b) pop hl ret -Func_c5ac: ; c5ac (3:45ac) +HandlePlayerMoveModeInput: ; c5ac (3:45ac) ldh a, [hKeysHeld] and D_PAD - jr z, .asm_c5bf - call Func_c5cb - call Func_c5fe - ld a, [wd335] + jr z, .skipMoving + call UpdatePlayerDirectionFromDPad + call AttemptPlayerMovementFromDirection + ld a, [wPlayerCurrentlyMoving] and $1 - jr nz, .asm_c5ca -.asm_c5bf + jr nz, .done +.skipMoving ldh a, [hKeysPressed] and A_BUTTON - jr z, .asm_c5ca - call Func_c71e - jr .asm_c5ca -.asm_c5ca + jr z, .done + call FindNPCOrObject + jr .done +.done ret -Func_c5cb: ; c5cb (3:45cb) - call Func_c5d5 -Func_c5ce: ; c5ce (3:45ce) - ld [wd334], a - call Func_c5e9 +UpdatePlayerDirectionFromDPad: ; c5cb (3:45cb) + call GetDirectionFromDPad +UpdatePlayerDirection: ; c5ce (3:45ce) + ld [wPlayerDirection], a + call UpdatePlayerSprite ret -Func_c5d5: ; c5d5 (3:45d5) +GetDirectionFromDPad: ; c5d5 (3:45d5) push hl - ld hl, Unknown_c5e5 + ld hl, KeypadDirectionMap or a - jr z, .asm_c5e2 -.asm_c5dc + jr z, .loadDirectionMapping +.findDirectionMappingLoop rlca - jr c, .asm_c5e2 + jr c, .loadDirectionMapping inc hl - jr .asm_c5dc -.asm_c5e2 + jr .findDirectionMappingLoop +.loadDirectionMapping ld a, [hl] pop hl ret -Unknown_c5e5: ; c5e5 (3:45e5) - db $02,$00,$03,$01 +KeypadDirectionMap: ; c5e5 (3:45e5) + db SOUTH, NORTH, WEST, EAST -Func_c5e9: ; c5e9 (3:45e9) +; Updates sprite depending on direction +UpdatePlayerSprite: ; c5e9 (3:45e9) push bc - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld a, [wd337] ld b, a - ld a, [wd334] + ld a, [wPlayerDirection] add b farcall Func_12ab5 pop bc ret -Func_c5fe: ; c5fe (3:45fe) +AttemptPlayerMovementFromDirection: ; c5fe (3:45fe) push bc - call Func_c653 - call AttemptScriptedMovement + call FindPlayerMovementFromDirection + call AttemptPlayerMovement pop bc ret -StartScriptedMovement: ; c607 (3:4607) +StartScript_dMovement: ; c607 (3:4607) push bc - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld a, [wd339] - call FindScriptedMovementWithOffset - call AttemptScriptedMovement + call FindPlayerMovementWithOffset + call AttemptPlayerMovement pop bc ret ; bc is the location the player is being scripted to move towards. -AttemptScriptedMovement: ; c619 (3:4619) +AttemptPlayerMovement: ; c619 (3:4619) push hl push bc ld a, b @@ -783,9 +785,9 @@ AttemptScriptedMovement: ; c619 (3:4619) ld [wPlayerXCoord], a ld a, c ld [wPlayerYCoord], a - ld a, [wd335] ; I believe everything starting here is animation related. + ld a, [wPlayerCurrentlyMoving] ; I believe everything starting here is animation related. or $1 - ld [wd335], a + ld [wPlayerCurrentlyMoving], a ld a, $10 ld [wd338], a ld c, SPRITE_ANIM_FIELD_0F @@ -800,15 +802,15 @@ AttemptScriptedMovement: ; c619 (3:4619) pop hl ret -Func_c653: ; c653 (3:4653) - ld a, [wd334] +FindPlayerMovementFromDirection: ; c653 (3:4653) + ld a, [wPlayerDirection] -FindScriptedMovementWithOffset: ; c656 (3:4656) +FindPlayerMovementWithOffset: ; c656 (3:4656) rlca ld c, a ld b, $0 push hl - ld hl, ScriptedMovementOffsetTable + ld hl, PlayerMovementOffsetTable add hl, bc ld a, [wPlayerXCoord] add [hl] @@ -832,7 +834,7 @@ Func_c66c: ; c66c (3:466c) jr c, .asm_c67e inc c .asm_c67e - ld a, [wd334] + ld a, [wPlayerDirection] call Func_c694 pop bc pop hl @@ -876,7 +878,7 @@ Func_c694: ; c694 (3:4694) ld a, [wd338] or a jr nz, .asm_c6c3 - ld hl, wd335 + ld hl, wPlayerCurrentlyMoving set 1, [hl] .asm_c6c3 call Func_c41c @@ -903,20 +905,20 @@ Func_c6d4: ; c6d4 (3:46d4) Func_c6dc: ; c6dc (3:46dc) push hl - ld hl, wd335 + ld hl, wPlayerCurrentlyMoving res 0, [hl] res 1, [hl] call Func_c6f7 call Func_3997 call Func_c70d - ld a, [wd0bf] + ld a, [wOverworldMode] cp $1 call z, Func_c9c0 pop hl ret Func_c6f7: ; c6f7 (3:46f7) - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld c, SPRITE_ANIM_FIELD_0F call GetSpriteAnimBufferProperty @@ -929,7 +931,7 @@ Func_c6f7: ; c6f7 (3:46f7) Func_c70d: ; c70d (3:470d) push hl - ld hl, wd0bb + ld hl, wTempMap ld a, [wCurMap] cp [hl] jr z, .asm_c71c @@ -939,38 +941,40 @@ Func_c70d: ; c70d (3:470d) pop hl ret -Func_c71e: ; c71e (3:471e) +; Arrives here if A button is pressed when not moving + in map move state +FindNPCOrObject: ; c71e (3:471e) ld a, $ff - ld [wd3b6], a - call Func_c653 + ld [wScriptNPC], a + call FindPlayerMovementFromDirection call GetPermissionOfMapPosition and $40 - jr z, .asm_c73d - farcall Func_1c72e - jr c, .asm_c73d - ld a, [wd3aa] - ld [wd3b6], a - ld a, $2 - jr .asm_c748 -.asm_c73d - call Func_3a5e - jr nc, .asm_c746 - ld a, $3 - jr .asm_c748 -.asm_c746 + jr z, .noNPC + farcall FindNPCAtLocation + jr c, .noNPC + ld a, [wLoadedNPCTempIndex] + ld [wScriptNPC], a + ld a, OWMODE_START_SCRIPT + jr .changeStateExit + +.noNPC + call HandleMoveModeAPress + jr nc, .exit + ld a, OWMODE_SCRIPT + jr .changeStateExit +.exit or a ret -.asm_c748 - ld [wd0bf], a +.changeStateExit + ld [wOverworldMode], a scf ret -Func_c74d: ; c74d (3:474d) +OpenStartMenu: ; c74d (3:474d) push hl push bc push de call MainMenu_c75a - call CloseDialogueBox + call CloseAdvancedDialogueBox pop de pop bc pop hl @@ -1060,7 +1064,7 @@ PC_c7ea: ; c7ea (3:47ea) ld a, MUSIC_PC_MAIN_MENU call PlaySong call Func_c241 - call $4915 + call Func_c915 call DoFrameIfLCDEnabled ldtx hl, TurnedPCOnText call PrintScrollableText_NoTextBoxLabel @@ -1087,11 +1091,11 @@ PC_c7ea: ; c7ea (3:47ea) call Func_c32b jr .asm_c801 .asm_c82f - call Func_c135 + call CloseTextBox call DoFrameIfLCDEnabled ldtx hl, TurnedPCOffText call Func_c891 - call CloseDialogueBox + call CloseAdvancedDialogueBox xor a ld [wd112], a call Func_39fc @@ -1108,7 +1112,7 @@ Func_c891: ; c891 (3:4891) ld hl, wd3b9 ld a, [hli] or [hl] - call nz, Func_c135 + call nz, CloseTextBox .asm_c8a1 xor a @@ -1119,7 +1123,7 @@ Func_c891: ; c891 (3:4891) ld a, $1 call Func_c29b call Func_c241 - call $4915 + call Func_c915 call DoFrameIfLCDEnabled call PrintScrollableText_NoTextBoxLabel ret @@ -1141,7 +1145,7 @@ Func_c8ba: ; c8ba (3:48ba) jr z, .asm_c8d4 .asm_c8d1 - call Func_c135 + call CloseTextBox .asm_c8d4 ld hl, wd3b9 @@ -1152,20 +1156,20 @@ Func_c8ba: ; c8ba (3:48ba) ld a, $1 call Func_c29b call Func_c241 - call $4915 + call Func_c915 call DoFrameIfLCDEnabled call $2c62 ret ; 0xc8ed -Func_c8ed: ; c8ed (3:c8ed) +Func_c8ed: ; c8ed (3:48ed) push hl push bc push de push hl ld a, $1 call Func_c29b - call $4915 + call Func_c915 call DoFrameIfLCDEnabled pop hl ld a, l @@ -1200,22 +1204,23 @@ Func_c915: ; c915 (3:4915) pop bc ret -Func_c926: ; c926 (3:4926) +SetNextNPCAndScript: ; c926 (3:4926) push bc - call Func_39c3 - ld a, [wd3aa] - ld [wd3b6], a - farcall Func_1c768 + call FindLoadedNPC + ld a, [wLoadedNPCTempIndex] + ld [wScriptNPC], a + farcall SetNewScriptNPC pop bc +; fallthrough -Func_c935: ; c935 (3:4935) +SetNextScript: ; c935 (3:4935) push hl - ld hl, wd0c6 + ld hl, wNextScript ld [hl], c inc hl ld [hl], b ld a, $3 - ld [wd0bf], a + ld [wOverworldMode], a pop hl ret @@ -1223,51 +1228,51 @@ Func_c943: ; c943 (3:4943) push hl push bc push de - ld l, $0 - call Func_3abd - jr nc, .asm_c98f -.asm_c94d + ld l, MAP_SCRIPT_NPCS + call GetMapScriptPointer + jr nc, .quit +.loadNPCLoop ld a, l - ld [wd4c4], a + ld [wTempPointer], a ld a, h - ld [wd4c5], a - ld a, $4 - ld [wd4c6], a - ld de, wd3ab - ld bc, $0006 - call Func_3bf5 - ld a, [wd3ab] + ld [wTempPointer + 1], a + ld a, BANK(MapScripts) + ld [wTempPointerBank], a + ld de, wTempNPC + ld bc, NPC_MAP_SIZE + call CopyBankedDataToDE + ld a, [wTempNPC] or a - jr z, .asm_c98f + jr z, .quit push hl - ld a, [wd3af] + ld a, [wLoadNPCFunction] ld l, a - ld a, [wd3b0] + ld a, [wLoadNPCFunction+1] ld h, a or l - jr z, .asm_c97a + jr z, .noScript call CallHL2 - jr nc, .asm_c988 -.asm_c97a - ld a, [wd3ab] - farcall Func_11857 + jr nc, .nextNPC +.noScript + ld a, [wTempNPC] + farcall LoadNPCSpriteData call Func_c998 farcall Func_1c485 -.asm_c988 +.nextNPC pop hl - ld bc, $0006 + ld bc, NPC_MAP_SIZE add hl, bc - jr .asm_c94d -.asm_c98f - ld l, $2 - call Func_c9c2 + jr .loadNPCLoop +.quit + ld l, MAP_SCRIPT_POST_NPC + call CallMapScriptPointerIfExists pop de pop bc pop hl ret Func_c998: ; c998 (3:4998) - ld a, [wd3ab] + ld a, [wTempNPC] cp $22 ret nz ld a, [wd3d0] @@ -1286,24 +1291,24 @@ Func_c998: ; c998 (3:4998) ret Func_c9b8: ; c9b8 (3:49b8) - ld l, $8 - jr Func_c9c2 + ld l, MAP_SCRIPT_LOAD_MAP + jr CallMapScriptPointerIfExists Func_c9bc: ; c9bc (3:49bc) - ld l, $a - jr Func_c9c2 + ld l, MAP_SCRIPT_AFTER_DUEL + jr CallMapScriptPointerIfExists Func_c9c0: ; c9c0 (3:49c0) - ld l, $c + ld l, MAP_SCRIPT_MOVED_PLAYER -Func_c9c2: ; c9c2 (3:49c2) - call Func_3abd +CallMapScriptPointerIfExists: ; c9c2 (3:49c2) + call GetMapScriptPointer ret nc jp hl Func_c9c7: ; c9c7 (3:49c7) - ld l, $e - jr Func_c9c2 + ld l, MAP_SCRIPT_CLOSE_TEXTBOX + jr CallMapScriptPointerIfExists Func_c9cb: ; c9cb (3:49cb) push hl @@ -1321,48 +1326,50 @@ Func_c9cb: ; c9cb (3:49cb) pop hl ret +; Clears temporary flags before determining Imakuni Room Func_c9dd: ; c9dd (3:49dd) xor a - ld [wd411], a - call Func_c9e8 + ld [wEventFlags + EVENT_FLAG_BYTES - 1], a + call DetermineImakuniRoom call Func_ca0e ret -Func_c9e8: ; c9e8 (3:49e8) +; Determines what room Imakuni is in when you reset +; Skips current room and does not occur if you haven't talked to Imakuni +DetermineImakuniRoom: ; c9e8 (3:49e8) ld c, $0 - call Func_ca69 - db $13 - cp $2 - jr c, .asm_ca04 -.asm_c9f2 + get_flag_value EVENT_IMAKUNI_STATE + cp IMAKUNI_TALKED + jr c, .finish +.tryLoadImakuniLoop call UpdateRNGSources and $3 ld c, a ld b, $0 - ld hl, Unknown_ca0a + ld hl, ImakuniPossibleRooms add hl, bc - ld a, [wd0bb] + ld a, [wTempMap] cp [hl] - jr z, .asm_c9f2 -.asm_ca04 + jr z, .tryLoadImakuniLoop +.finish ld a, c - call Func_ca8f - db $34 + set_flag_value EVENT_IMAKUNI_ROOM ret -Unknown_ca0a: ; ca0a (3:4a04) - INCROM $ca0a, $ca0e +ImakuniPossibleRooms: ; ca0a (3:4a04) + db FIGHTING_CLUB_LOBBY + db SCIENCE_CLUB_LOBBY + db LIGHTNING_CLUB_LOBBY + db WATER_CLUB_LOBBY Func_ca0e: ; ca0e (3:4a0e) ld a, [wd32e] cp $b jr z, .asm_ca68 - call Func_ca69 - db $22 + get_flag_value EVENT_RECEIVED_LEGENDARY_CARD or a jr nz, .asm_ca4a - call Func_ca69 - db $40 + get_flag_value EVENT_FLAG_40 cp $7 jr z, .asm_ca68 or a @@ -1370,12 +1377,10 @@ Func_ca0e: ; ca0e (3:4a0e) cp $2 jr z, .asm_ca62 ld c, $1 - call Func_ca8f - db $40 + set_flag_value EVENT_FLAG_40 jr .asm_ca62 .asm_ca33 - call Func_ca69 - db $3f + get_flag_value EVENT_FLAG_3F cp $7 jr z, .asm_ca68 or a @@ -1383,8 +1388,7 @@ Func_ca0e: ; ca0e (3:4a0e) cp $2 jr z, .asm_ca68 ld c, $1 - call Func_ca8f - db $3f + set_flag_value EVENT_FLAG_3F jr .asm_ca68 .asm_ca4a call UpdateRNGSources @@ -1394,35 +1398,36 @@ Func_ca0e: ; ca0e (3:4a0e) jr z, .asm_ca56 ld c, $0 .asm_ca56 - call Func_ca8f - db $41 + set_flag_value EVENT_FLAG_41 jr .asm_ca5c .asm_ca5c ld c, $7 - call Func_ca8f - db $40 + set_flag_value EVENT_FLAG_40 .asm_ca62 ld c, $7 - call Func_ca8f - db $3f + set_flag_value EVENT_FLAG_3F .asm_ca68 ret -Func_ca69: ; ca69 (3:4a69) - call Func_cab3 -CheckIfEventFlagSet: ; ca6c (3:4a6c) +GetStackFlagValue: ; ca69 (3:4a69) + call GetByteAfterCall +; fallthrough + +; returns the event flag's value in a +; also ors it with itself before returning +GetEventFlagValue: ; ca6c (3:4a6c) push hl push bc - call GetEventFlagMod + call GetEventFlag ld c, [hl] - ld a, [wd3d1] -.asm_ca75 + ld a, [wLoadedFlagBits] +.shiftLoop bit 0, a - jr nz, .asm_ca7f + jr nz, .lsbReached srl a srl c - jr .asm_ca75 -.asm_ca7f + jr .shiftLoop +.lsbReached and c pop bc pop hl @@ -1430,17 +1435,27 @@ CheckIfEventFlagSet: ; ca6c (3:4a6c) ret ; 0xca84 - INCROM $ca84, $ca8f +ZeroStackFlagValue2: ; ca84 (3:4a84) + call GetByteAfterCall + push bc + ld c, $00 + call SetEventFlagValue + pop bc + ret -Func_ca8f: ; ca8f (3:4a8f) - call Func_cab3 +; Use macro set_flag_value. The byte db'd after this func is called +; is used at the flag argument for SetEventFlagValue +SetStackFlagValue: ; ca8f (3:4a8f) + call GetByteAfterCall +; fallthrough -; a - pointer on table for cb1d, c - set or reset control bit -ModifyEventFlags: ; ca92 (3:4a92) +; a - flag +; c - value - truncated to fit only the flag's bounds +SetEventFlagValue: ; ca92 (3:4a92) push hl push bc - call GetEventFlagMod - ld a, [wd3d1] + call GetEventFlag + ld a, [wLoadedFlagBits] .asm_ca9a bit 0, a jr nz, .asm_caa4 @@ -1448,10 +1463,10 @@ ModifyEventFlags: ; ca92 (3:4a92) sla c jr .asm_ca9a .asm_caa4 - ld a, [wd3d1] + ld a, [wLoadedFlagBits] and c ld c, a - ld a, [wd3d1] + ld a, [wLoadedFlagBits] cpl and [hl] or c @@ -1460,7 +1475,8 @@ ModifyEventFlags: ; ca92 (3:4a92) pop hl ret -Func_cab3: ; cab3 (3:4ab3) +; returns in a the byte db'd after the call to a function that calls this +GetByteAfterCall: ; cab3 (3:4ab3) push hl ld hl, sp+$4 push bc @@ -1477,73 +1493,86 @@ Func_cab3: ; cab3 (3:4ab3) ret ; 0xcac2 - INCROM $cac2, $cac5 +MaxStackFlagValue: ; cac2 (3:4ac2) + call GetByteAfterCall +; fallthrough -SetEventFlags: ; cac5 (3:4ac5) +MaxOutEventFlag: ; cac5 (3:4ac5) push bc ld c, $ff - call ModifyEventFlags + call SetEventFlagValue pop bc ret ; 0xcacd - INCROM $cacd, $cad0 +ZeroStackFlagValue: ; cacd (3:4acd) + call GetByteAfterCall +; fallthrough -Func_cad0: ; cad0 (3:4ad0) +ZeroOutEventFlag: ; cad0 (3:4ad0) push bc ld c, $0 - call ModifyEventFlags + call SetEventFlagValue pop bc ret -Func_cad8: ; cad8 (3:4ad8) +TryGiveMedalPCPacks: ; cad8 (3:4ad8) push hl push bc - ld hl, $4b15 + ld hl, MedalEventFlags ld bc, $0008 -.asm_cae0 +.countMedalsLoop ld a, [hli] - call CheckIfEventFlagSet - jr z, .asm_cae7 + call GetEventFlagValue + jr z, .noMedal inc b - -.asm_cae7 +.noMedal dec c - jr nz, .asm_cae0 + jr nz, .countMedalsLoop + ld c, b - call Func_ca8f - ld l, $79 + set_flag_value EVENT_MEDAL_COUNT + ld a, c push af cp $8 - jr nc, .asm_caff + jr nc, .givePacksForEightMedals cp $7 - jr nc, .asm_cb05 + jr nc, .givePacksForSevenMedals cp $3 - jr nc, .asm_cb0b - jr .asm_cb11 + jr nc, .givePacksForTwoMedals + jr .finish -.asm_caff +.givePacksForEightMedals ld a, $c - farcall $4, $4a70 + farcall TryGivePCPack -.asm_cb05 +.givePacksForSevenMedals ld a, $b - farcall $4, $4a70 + farcall TryGivePCPack -.asm_cb0b +.givePacksForTwoMedals ld a, $a - farcall $4, $4a70 + farcall TryGivePCPack -.asm_cb11 +.finish pop af pop bc pop hl ret ; 0xcb15 - INCROM $cb15, $cb1d - -GetEventFlagMod: ; cb1d (3:4b1d) +MedalEventFlags: ; cb15 (3:4b15) + db EVENT_FLAG_08 + db EVENT_FLAG_09 + db EVENT_FLAG_0A + db EVENT_BEAT_AMY + db EVENT_FLAG_0C + db EVENT_FLAG_0D + db EVENT_FLAG_0E + db EVENT_FLAG_0F + +; returns wEventFlags byte in hl, related bits in wLoadedFlagBits +GetEventFlag: ; cb1d (3:4b1d) push bc ld c, a ld b, $0 @@ -1554,7 +1583,7 @@ GetEventFlagMod: ; cb1d (3:4b1d) ld a, [hli] ld c, a ld a, [hl] - ld [wd3d1], a + ld [wLoadedFlagBits], a ld b, $0 ld hl, wEventFlags add hl, bc @@ -1563,76 +1592,207 @@ GetEventFlagMod: ; cb1d (3:4b1d) ; offset - bytes to set or reset EventFlagMods: ; cb37 (3:4b37) - INCROM $cb37, $cc32 + flag_def $3f, %10000000 ; EVENT_FLAG_00 ; 0-7 are reset when game resets + flag_def $3f, %01000000 ; EVENT_FLAG_01 + flag_def $3f, %00100000 ; EVENT_TEMP_TALKED_TO_IMAKUNI + flag_def $3f, %00010000 ; EVENT_TEMP_BATTLED_IMAKUNI + flag_def $3f, %00001000 ; EVENT_FLAG_04 + flag_def $3f, %00000100 ; EVENT_FLAG_05 + flag_def $3f, %00000010 ; EVENT_FLAG_06 + flag_def $3f, %00000001 ; EVENT_FLAG_07 + flag_def $00, %10000000 ; EVENT_FLAG_08 + flag_def $00, %01000000 ; EVENT_FLAG_09 + flag_def $00, %00100000 ; EVENT_FLAG_0A + flag_def $00, %00010000 ; EVENT_BEAT_AMY + flag_def $00, %00001000 ; EVENT_FLAG_0C + flag_def $00, %00000100 ; EVENT_FLAG_0D + flag_def $00, %00000010 ; EVENT_FLAG_0E + flag_def $00, %00000001 ; EVENT_FLAG_0F + flag_def $00, %11111111 ; EVENT_FLAG_10 + flag_def $01, %11110000 ; EVENT_FLAG_11 + flag_def $01, %00001111 ; EVENT_FLAG_12 + flag_def $02, %11000000 ; EVENT_IMAKUNI_STATE + flag_def $02, %00110000 ; EVENT_FLAG_14 + flag_def $02, %00001000 ; EVENT_BEAT_SARA + flag_def $02, %00000100 ; EVENT_BEAT_AMANDA + flag_def $03, %11110000 ; EVENT_FLAG_17 + flag_def $03, %00001111 ; EVENT_FLAG_18 + flag_def $04, %11110000 ; EVENT_FLAG_19 + flag_def $04, %00001111 ; EVENT_FLAG_1A + flag_def $05, %10000000 ; EVENT_FLAG_1B + flag_def $05, %01000000 ; EVENT_FLAG_1C + flag_def $05, %00100000 ; EVENT_FLAG_1D + flag_def $05, %00010000 ; EVENT_FLAG_1E + flag_def $05, %00001111 ; EVENT_FLAG_1F + flag_def $06, %11110000 ; EVENT_FLAG_20 + flag_def $06, %00001100 ; EVENT_FLAG_21 + flag_def $06, %00000010 ; EVENT_RECEIVED_LEGENDARY_CARD + flag_def $06, %00000001 ; EVENT_FLAG_23 + flag_def $07, %11000000 ; EVENT_FLAG_24 + flag_def $07, %00100000 ; EVENT_FLAG_25 + flag_def $07, %00010000 ; EVENT_FLAG_26 + flag_def $07, %00001000 ; EVENT_FLAG_27 + flag_def $07, %00000100 ; EVENT_FLAG_28 + flag_def $07, %00000010 ; EVENT_FLAG_29 + flag_def $07, %00000001 ; EVENT_FLAG_2A + flag_def $08, %11111111 ; EVENT_FLAG_2B + flag_def $09, %11100000 ; EVENT_FLAG_2C + flag_def $09, %00011111 ; EVENT_FLAG_2D + flag_def $0a, %11110000 ; EVENT_MEDAL_COUNT + flag_def $0a, %00001000 ; EVENT_FLAG_2F + flag_def $0a, %00000100 ; EVENT_FLAG_30 + flag_def $0a, %00000011 ; EVENT_FLAG_31 + flag_def $0b, %10000000 ; EVENT_FLAG_32 + flag_def $0b, %01110000 ; EVENT_JOSHUA_STATE + flag_def $0b, %00001100 ; EVENT_IMAKUNI_ROOM + flag_def $0b, %00000011 ; EVENT_FLAG_35 + flag_def $0c, %11100000 ; EVENT_IMAKUNI_WIN_COUNT + flag_def $0c, %00011100 ; EVENT_FLAG_37 + flag_def $0c, %00000010 ; EVENT_FLAG_38 + flag_def $0c, %00000001 ; EVENT_FLAG_39 + flag_def $0d, %10000000 ; EVENT_FLAG_3A + flag_def $0d, %01000000 ; EVENT_FLAG_3B + flag_def $0d, %00100000 ; FLAG_BEAT_BRITTANY + flag_def $0d, %00010000 ; EVENT_FLAG_3D + flag_def $0d, %00001110 ; EVENT_FLAG_3E + flag_def $0e, %11100000 ; EVENT_FLAG_3F + flag_def $0e, %00011100 ; EVENT_FLAG_40 + flag_def $0f, %11100000 ; EVENT_FLAG_41 + flag_def $10, %10000000 ; EVENT_FLAG_42 + flag_def $10, %01000000 ; EVENT_FLAG_43 + flag_def $10, %00110000 ; EVENT_FLAG_44 + flag_def $10, %00001100 ; EVENT_FLAG_45 + flag_def $10, %00000010 ; EVENT_FLAG_46 + flag_def $10, %00000001 ; EVENT_FLAG_47 + flag_def $11, %11100000 ; EVENT_FLAG_48 + flag_def $11, %00011100 ; EVENT_FLAG_49 + flag_def $12, %11100000 ; EVENT_FLAG_4A + flag_def $13, %10000000 ; EVENT_FLAG_4B + flag_def $13, %01100000 ; EVENT_FLAG_4C + flag_def $13, %00011000 ; EVENT_FLAG_4D + flag_def $13, %00000100 ; EVENT_FLAG_4E + flag_def $13, %00000010 ; EVENT_FLAG_4F + flag_def $14, %10000000 ; EVENT_FLAG_50 + flag_def $14, %01000000 ; EVENT_FLAG_51 + flag_def $14, %00100000 ; EVENT_FLAG_52 + flag_def $14, %00010000 ; EVENT_FLAG_53 + flag_def $14, %00001000 ; EVENT_FLAG_54 + flag_def $14, %00000100 ; EVENT_FLAG_55 + flag_def $14, %00000010 ; EVENT_FLAG_56 + flag_def $14, %00000001 ; EVENT_FLAG_57 + flag_def $15, %11110000 ; EVENT_FLAG_58 + flag_def $15, %00001000 ; EVENT_FLAG_59 + flag_def $16, %10000000 ; EVENT_FLAG_5A + flag_def $16, %01000000 ; EVENT_FLAG_5B + flag_def $16, %00100000 ; EVENT_FLAG_5C + flag_def $16, %00010000 ; EVENT_FLAG_5D + flag_def $16, %00001000 ; EVENT_FLAG_5E + flag_def $16, %00000100 ; EVENT_FLAG_5F + flag_def $16, %00000010 ; EVENT_FLAG_60 + flag_def $16, %00000001 ; EVENT_FLAG_61 + flag_def $16, %11111111 ; EVENT_FLAG_62 + flag_def $17, %10000000 ; EVENT_FLAG_63 + flag_def $17, %01000000 ; EVENT_FLAG_64 + flag_def $17, %00110000 ; EVENT_FLAG_65 + flag_def $17, %00001000 ; EVENT_FLAG_66 + flag_def $17, %00000100 ; EVENT_FLAG_67 + flag_def $18, %11000000 ; EVENT_FLAG_68 + flag_def $18, %00110000 ; EVENT_FLAG_69 + flag_def $18, %00001100 ; EVENT_FLAG_6A + flag_def $18, %00000011 ; EVENT_FLAG_6B + flag_def $19, %11000000 ; EVENT_FLAG_6C + flag_def $19, %00100000 ; EVENT_FLAG_6D + flag_def $19, %00010000 ; EVENT_FLAG_6E + flag_def $19, %00001000 ; EVENT_FLAG_6F + flag_def $19, %00000100 ; EVENT_FLAG_70 + flag_def $19, %00111100 ; EVENT_FLAG_71 + flag_def $1a, %11111100 ; EVENT_FLAG_72 + flag_def $1a, %00000011 ; EVENT_FLAG_73 + flag_def $1b, %11111111 ; EVENT_FLAG_74 + flag_def $1c, %11110000 ; EVENT_FLAG_75 + flag_def $1c, %00001111 ; EVENT_FLAG_76 + +; Used for basic level objects that just print text and quit +PrintInteractableObjectText: ; cc25 (3:4c25) + ld hl, wDefaultObjectText + ld a, [hli] + ld h, [hl] + ld l, a + call Func_cc32 + call CloseAdvancedDialogueBox + ret Func_cc32: ; cc32 (3:4c32) push hl - ld hl, wd0c8 + ld hl, wCurrentNPCNameTx ld e, [hl] inc hl ld d, [hl] pop hl call Func_c8ba ret -; 0xcc3e - INCROM $cc3e, $cc42 +; Used for things that are represented as NPCs but don't have a Script +; EX: Clerks and legendary cards that interact through Level Objects +NoOverworldSequence: ; cc3e (3:4c3e) + call CloseAdvancedDialogueBox + ret -; called when pressing a in front of an object. creates a pointer to the data right after an RST20 -; was called, then runs RunOverworldScript to handle that data +; Enters into the script loop, continuing until wBreakScriptLoop > 0 +; When the loop is broken, it resumes normal code execution where script ended +; Note: Some scripts "double return" and skip this. RST20: ; cc42 (3:4c42) pop hl ld a, l - ld [wOWScriptPointer], a + ld [wScriptPointer], a ld a, h - ld [wOWScriptPointer+1], a + ld [wScriptPointer+1], a xor a - ld [wBreakOWScriptLoop], a -.asm_cc4f + ld [wBreakScriptLoop], a +.continueScriptLoop call RunOverworldScript - ld a, [wBreakOWScriptLoop] ; if you break out, it jumps + ld a, [wBreakScriptLoop] ; if you break out, it jumps or a - jr z, .asm_cc4f - ld hl, wOWScriptPointer + jr z, .continueScriptLoop + ld hl, wScriptPointer ld a, [hli] ld c, a ld b, [hl] - push bc - ret + retbc -IncreaseOWScriptPointerBy1: ; cc60 (3:4c60) +IncreaseScriptPointerBy1: ; cc60 (3:4c60) ld a, 1 - jr IncreaseOWScriptPointer -IncreaseOWScriptPointerBy2: ; cc64 (3:4c64) + jr IncreaseScriptPointer +IncreaseScriptPointerBy2: ; cc64 (3:4c64) ld a, 2 - jr IncreaseOWScriptPointer -IncreaseOWScriptPointerBy4: ; cc68 (3:4c68) + jr IncreaseScriptPointer +IncreaseScriptPointerBy4: ; cc68 (3:4c68) ld a, 4 - jr IncreaseOWScriptPointer -IncreaseOWScriptPointerBy5: ; cc6c (3:4c6c) + jr IncreaseScriptPointer +IncreaseScriptPointerBy5: ; cc6c (3:4c6c) ld a, 5 - jr IncreaseOWScriptPointer -IncreaseOWScriptPointerBy6: ; cc70 (3:4c70) + jr IncreaseScriptPointer +IncreaseScriptPointerBy6: ; cc70 (3:4c70) ld a, 6 - jr IncreaseOWScriptPointer -IncreaseOWScriptPointerBy7: ; cc74 (3:4c74) + jr IncreaseScriptPointer +IncreaseScriptPointerBy7: ; cc74 (3:4c74) ld a, 7 - jr IncreaseOWScriptPointer -IncreaseOWScriptPointerBy3: ; cc78 (3:4c78) + jr IncreaseScriptPointer +IncreaseScriptPointerBy3: ; cc78 (3:4c78) ld a, 3 -IncreaseOWScriptPointer: ; cc7a (3:4c7a) +IncreaseScriptPointer: ; cc7a (3:4c7a) ld c, a - ld a, [wOWScriptPointer] + ld a, [wScriptPointer] add c - ld [wOWScriptPointer], a - ld a, [wOWScriptPointer+1] + ld [wScriptPointer], a + ld a, [wScriptPointer+1] adc 0 - ld [wOWScriptPointer+1], a + ld [wScriptPointer+1], a ret -SetOWScriptPointer: ; cc8b (3:4c8b) - ld hl, wOWScriptPointer +SetScriptPointer: ; cc8b (3:4c8b) + ld hl, wScriptPointer ld [hl], c inc hl ld [hl], b @@ -1641,23 +1801,23 @@ SetOWScriptPointer: ; cc8b (3:4c8b) INCROM $cc92, $cc96 -GetOWSArgs1AfterPointer: ; cc96 (3:4c96) +GetScriptArgs1AfterPointer: ; cc96 (3:4c96) ld a, $1 - jr GetOWSArgsAfterPointer + jr GetScriptArgsAfterPointer -GetOWSArgs2AfterPointer: ; cc9a (3:4c9a) +GetScriptArgs2AfterPointer: ; cc9a (3:4c9a) ld a, $2 - jr GetOWSArgsAfterPointer -GetOWSArgs3AfterPointer: ; cc9e (3:4c9e) + jr GetScriptArgsAfterPointer +GetScriptArgs3AfterPointer: ; cc9e (3:4c9e) ld a, $3 -GetOWSArgsAfterPointer: ; cca0 (3:4ca0) +GetScriptArgsAfterPointer: ; cca0 (3:4ca0) push hl ld l, a - ld a, [wOWScriptPointer] + ld a, [wScriptPointer] add l ld l, a - ld a, [wOWScriptPointer+1] + ld a, [wScriptPointer+1] adc $0 ld h, a ld a, [hli] @@ -1667,79 +1827,82 @@ GetOWSArgsAfterPointer: ; cca0 (3:4ca0) or b ret -Func_ccb3: ; ccb3 (3:4cb3) +SetScriptControlBytePass: ; ccb3 (3:4cb3) ld a, $ff - ld [wd415], a + ld [wScriptControlByte], a ret -Func_ccb9: ; ccb9 (3:4cb9) +SetScriptControlByteFail: ; ccb9 (3:4cb9) xor a - ld [wd415], a - ret - -OWScript_EndScriptLoop1: ; ccbe (3:4cbe) -OWScript_EndScriptLoop2: ; ccbe (3:4cbe) -OWScript_EndScriptLoop3: ; ccbe (3:4cbe) -OWScript_EndScriptLoop4: ; ccbe (3:4cbe) -OWScript_EndScriptLoop5: ; ccbe (3:4cbe) -OWScript_EndScriptLoop6: ; ccbe (3:4cbe) -OWScript_EndScriptLoop7: ; ccbe (3:4cbe) -OWScript_EndScriptLoop8: ; ccbe (3:4cbe) -OWScript_EndScriptLoop9: ; ccbe (3:4cbe) -OWScript_EndScriptLoop10: ; ccbe (3:4cbe) + ld [wScriptControlByte], a + ret + +; Exits Script mode and runs the next instruction like normal +ScriptCommand_EndScriptLoop1: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop2: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop3: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop4: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop5: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop6: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop7: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop8: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop9: ; ccbe (3:4cbe) +ScriptCommand_EndScriptLoop10: ; ccbe (3:4cbe) ld a, $01 - ld [wBreakOWScriptLoop], a - jp IncreaseOWScriptPointerBy1 + ld [wBreakScriptLoop], a + jp IncreaseScriptPointerBy1 -OWScript_CloseTextBox: ; ccc6 (3:4cc6) - call CloseDialogueBox - jp IncreaseOWScriptPointerBy1 +ScriptCommand_CloseAdvancedTextBox: ; ccc6 (3:4cc6) + call CloseAdvancedDialogueBox + jp IncreaseScriptPointerBy1 -OWScript_EndScriptCloseText: ; cccc (3:4ccc) - call OWScript_CloseTextBox - call OWScript_EndScriptLoop1 +ScriptCommand_QuitScriptFully: ; cccc (3:4ccc) + call ScriptCommand_CloseAdvancedTextBox + call ScriptCommand_EndScriptLoop1 pop hl ret ; args: 2-Text String Index -OWScript_PrintTextString: ; ccd4 (3:4cd4) +ScriptCommand_PrintTextString: ; ccd4 (3:4cd4) ld l, c ld h, b call Func_cc32 - jp IncreaseOWScriptPointerBy3 + jp IncreaseScriptPointerBy3 Func_ccdc: ; ccdc (3:4cdc) ld l, c ld h, b call Func_c891 - jp IncreaseOWScriptPointerBy3 + jp IncreaseScriptPointerBy3 -Func_cce4: ; cce4 (3:4ce4) +ScriptCommand_AskQuestionJumpDefaultYes: ; cce4 (3:4ce4) ld a, $1 ld [wDefaultYesOrNo], a +; fallthrough -; Asks the player a question then jumps if they answer yes -OWScript_AskQuestionJump: ; cce9 (3:4ce9) +; Asks the player a question then jumps if they answer yes. Seem to be able to +; take a text of 0000 to overwrite last with (yes no) prompt at the bottom +ScriptCommand_AskQuestionJump: ; cce9 (3:4ce9) ld l, c ld h, b call Func_c8ed ld a, [hCurMenuItem] - ld [wd415], a + ld [wScriptControlByte], a jr c, .asm_ccfe - call GetOWSArgs3AfterPointer + call GetScriptArgs3AfterPointer jr z, .asm_ccfe - jp SetOWScriptPointer + jp SetScriptPointer .asm_ccfe - jp IncreaseOWScriptPointerBy5 + jp IncreaseScriptPointerBy5 ; args - prize cards, deck id, duel theme index ; sets a battle up, doesn't start until we break out of the script system. -OWScript_StartBattle: ; cd01 (3:4d01) +ScriptCommand_StartBattle: ; cd01 (3:4d01) call Func_cd66 - ld a, [wd3b6] - ld l, $0 - call Func_39ad + ld a, [wScriptNPC] + ld l, LOADED_NPC_ID + call GetItemInLoadedNPCIndex ld a, [hl] farcall Func_118d3 ld a, [wcc19] @@ -1748,14 +1911,14 @@ OWScript_StartBattle: ; cd01 (3:4d01) ld a, [wd695] ld c, a ld b, $0 - ld hl, $4d63 + ld hl, AaronDeckIDs add hl, bc ld a, [hl] ld [wcc19], a .asm_cd26 - ld a, [wd3b6] - ld l, $0 - call Func_39ad + ld a, [wScriptNPC] + ld l, LOADED_NPC_ID + call GetItemInLoadedNPCIndex ld a, [hl] asm_cd2f ld [wd0c4], a @@ -1769,7 +1932,7 @@ asm_cd2f ld [wGameEvent], a ld hl, wd0b4 set 6, [hl] - jp IncreaseOWScriptPointerBy4 + jp IncreaseScriptPointerBy4 Func_cd4f: ; cd4f (3:4d4f) call Func_cd66 @@ -1780,15 +1943,17 @@ Func_cd4f: ; cd4f (3:4d4f) ld a, [wd696] jr asm_cd2f -Unknown_dd63: ; cd4f (3:4d4f) - INCROM $cd63, $cd66 +AaronDeckIDs: ; cd63 (3:4d63) + db LIGHTNING_AND_FIRE_DECK_ID + db WATER_AND_FIGHTING_DECK_ID + db GRASS_AND_PSYCHIC_DECK_ID Func_cd66: ; cd66 (3:4d66) ld a, c ld [wcc18], a ld a, b ld [wcc19], a - call GetOWSArgs3AfterPointer + call GetScriptArgs3AfterPointer ld a, c ld [wDuelTheme], a ret @@ -1798,103 +1963,106 @@ Func_cd76: ; cd76 (3:4d76) ld [wGameEvent], a ld hl, wd0b4 set 6, [hl] - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 -Func_cd83: ; cd83 (3:4d83) - ld a, [wd415] +; prints text arg 1 or arg 2 depending on wScriptControlByte. +ScriptCommand_PrintVariableText: ; cd83 (3:4d83) + ld a, [wScriptControlByte] or a - jr nz, .asm_cd8c - call GetOWSArgs3AfterPointer -.asm_cd8c + jr nz, .printText + call GetScriptArgs3AfterPointer +.printText ld l, c ld h, b call Func_cc32 - jp IncreaseOWScriptPointerBy5 + jp IncreaseScriptPointerBy5 Func_cd94: ; cd94 (3:4d94) - call Func_ca69 - ld b, h + get_flag_value EVENT_FLAG_44 Unknown_cd98: dec a and $3 add a inc a - call GetOWSArgsAfterPointer + call GetScriptArgsAfterPointer ld l, c ld h, b call Func_cc32 - jp IncreaseOWScriptPointerBy7 + jp IncreaseScriptPointerBy7 Func_cda8: ; cda8 (3:4da8) - ld a, [wd415] + ld a, [wScriptControlByte] or a jr nz, .asm_cdb1 - call GetOWSArgs3AfterPointer + call GetScriptArgs3AfterPointer .asm_cdb1 ld l, c ld h, b call Func_c891 - jp IncreaseOWScriptPointerBy5 + jp IncreaseScriptPointerBy5 -OWScript_PrintTextCloseBox: ; cdb9 (3:4db9) +; Does not return to RST20 - pops an extra time to skip that. +ScriptCommand_PrintTextQuitFully: ; cdb9 (3:4db9) ld l, c ld h, b call Func_cc32 - call CloseDialogueBox + call CloseAdvancedDialogueBox ld a, $1 - ld [wBreakOWScriptLoop], a - call IncreaseOWScriptPointerBy3 + ld [wBreakScriptLoop], a + call IncreaseScriptPointerBy3 pop hl ret Func_cdcb: ; cdcb (3:4dcb) - ld a, [wd3b6] - ld [wd3aa], a + ld a, [wScriptNPC] + ld [wLoadedNPCTempIndex], a Func_cdd1: ; cdd1 (3:4dd1) farcall Func_1c50a - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 Func_cdd8: ; cdd8 (3:4dd8) - ld a, [wd3aa] + ld a, [wLoadedNPCTempIndex] push af - ld a, [wd3ab] + ld a, [wTempNPC] push af ld a, [wd696] - ld [wd3ab], a - call Func_39c3 + ld [wTempNPC], a + call FindLoadedNPC call Func_cdd1 pop af - ld [wd3ab], a + ld [wTempNPC], a pop af - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a ret Func_cdf5: ; cdf5 (3:4df5) - ld a, [wd3aa] + ld a, [wLoadedNPCTempIndex] push af - ld a, [wd3ab] + ld a, [wTempNPC] push af ld a, [wd696] - ld [wd3ab], a + ld [wTempNPC], a ld a, c - ld [wd3ac], a + ld [wLoadNPCXPos], a ld a, b - ld [wd3ad], a + ld [wLoadNPCYPos], a ld a, $2 - ld [wd3ae], a - ld a, [wd3ab] - farcall Func_11857 + ld [wLoadNPCDirection], a + ld a, [wTempNPC] + farcall LoadNPCSpriteData farcall Func_1c485 pop af - ld [wd3ab], a + ld [wTempNPC], a pop af - ld [wd3aa], a - jp IncreaseOWScriptPointerBy3 - -Func_ce26: ; ce26 (3:4e26) - ld a, [wd3b6] - ld [wd3aa], a - farcall Func_1c455 + ld [wLoadedNPCTempIndex], a + jp IncreaseScriptPointerBy3 + +; Finds and executes an NPCMovement script in the table provided in bc +; based on the active NPC's current direction +ScriptCommand_MoveActiveNPCByDirection: ; ce26 (3:4e26) + ld a, [wScriptNPC] + ld [wLoadedNPCTempIndex], a + farcall GetNPCDirection rlca add c ld l, a @@ -1904,56 +2072,67 @@ Func_ce26: ; ce26 (3:4e26) ld c, [hl] inc hl ld b, [hl] +; fallthrough -Func_ce3a: ; ce3a (3:4e3a) +; Moves an NPC given the list of directions pointed to by bc +; set bit 7 to only rotate the NPC +ExecuteNPCMovement: ; ce3a (3:4e3a) farcall Func_1c78d .asm_ce3e call DoFrameIfLCDEnabled farcall Func_1c7de jr nz, .asm_ce3e - jp IncreaseOWScriptPointerBy3 - -Func_ce4a: ; ce4a (3:4e4a) - ld a, [wd3b6] - ld [wd3aa], a - jr Func_ce3a - -Func_ce52: ; ce52 (3:4e52) - ld a, [wd3aa] + jp IncreaseScriptPointerBy3 + +; Begin a series of NPC movements on the currently talking NPC +; based on the series of directions pointed to by bc +ScriptCommand_MoveActiveNPC: ; ce4a (3:4e4a) + ld a, [wScriptNPC] + ld [wLoadedNPCTempIndex], a + jr ExecuteNPCMovement + +; Begin a series of NPC movements on an arbitrary NPC +; based on the series of directions pointed to by bc +ScriptCommand_MoveWramNPC: ; ce52 (3:4e52) + ld a, [wLoadedNPCTempIndex] push af - ld a, [wd3ab] + ld a, [wTempNPC] push af ld a, [wd696] -asm_ce5d - ld [wd3ab], a - call Func_39c3 - call Func_ce3a +; fallthrough + +; Executes movement on an arbitrary NPC using values in a and on the stack +; Changes and fixes Temp NPC using stack values +ExecuteArbitraryNPCMovementFromStack + ld [wTempNPC], a + call FindLoadedNPC + call ExecuteNPCMovement pop af - ld [wd3ab], a + ld [wTempNPC], a pop af - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a ret -Func_ce6f: ; ce6f (3:4e6f) - ld a, [wd3aa] +ScriptCommand_MoveArbitraryNPC: ; ce6f (3:4e6f) + ld a, [wLoadedNPCTempIndex] push af - ld a, [wd3ab] + ld a, [wTempNPC] push af ld a, c push af - call GetOWSArgs2AfterPointer + call GetScriptArgs2AfterPointer push bc - call IncreaseOWScriptPointerBy1 + call IncreaseScriptPointerBy1 pop bc pop af - jr asm_ce5d + jr ExecuteArbitraryNPCMovementFromStack -Func_ce84: ; ce84 (3:4e84) - call Func_c135 - jp IncreaseOWScriptPointerBy1 +ScriptCommand_CloseTextBox: ; ce84 (3:4e84) + call CloseTextBox + jp IncreaseScriptPointerBy1 ; args: booster pack index, booster pack index, booster pack index -OWScript_GiveBoosterPacks: ; ce8a (3:4e8a) +ScriptCommand_GiveBoosterPacks: ; ce8a (3:4e8a) xor a ld [wd117], a push bc @@ -1966,42 +2145,48 @@ OWScript_GiveBoosterPacks: ; ce8a (3:4e8a) ld [wd117], a pop bc ld a, b - cp $ff + cp NO_BOOSTER jr z, .asm_ceb4 farcall BoosterPack_1031b - call GetOWSArgs3AfterPointer + call GetScriptArgs3AfterPointer ld a, c - cp $ff + cp NO_BOOSTER jr z, .asm_ceb4 farcall BoosterPack_1031b .asm_ceb4 call Func_c2d4 - jp IncreaseOWScriptPointerBy4 + jp IncreaseScriptPointerBy4 -Func_ceba: ; ceba (3:4eba) +ScriptCommand_GiveOneOfEachTrainerBooster: ; ceba (3:4eba) xor a ld [wd117], a call Func_c2a3 - ld hl, $4edd -.asm_cec4 + ld hl, .booster_type_table +.giveBoosterLoop ld a, [hl] - cp $ff - jr z, .asm_ced7 + cp NO_BOOSTER + jr z, .done push hl farcall BoosterPack_1031b ld a, $1 ld [wd117], a pop hl inc hl - jr .asm_cec4 -.asm_ced7 + jr .giveBoosterLoop +.done call Func_c2d4 - jp IncreaseOWScriptPointerBy1 -; 0xcedd - - INCROM $cedd, $cee2 - -Func_cee2: ; cee2 (3:4ee2) + jp IncreaseScriptPointerBy1 + +.booster_type_table + db BOOSTER_COLOSSEUM_TRAINER + db BOOSTER_EVOLUTION_TRAINER + db BOOSTER_MYSTERY_TRAINER_COLORLESS + db BOOSTER_LABORATORY_TRAINER + db NO_BOOSTER ; $ff + +; Shows the card received screen for a given promotional card +; arg can either be the card, $00 for a wram card, or $ff for the 4 legends +ScriptCommand_ShowCardReceivedScreen: ; cee2 (3:4ee2) call Func_c2a3 ld a, c cp $ff @@ -2019,7 +2204,7 @@ Func_cee2: ; cee2 (3:4ee2) call WhiteOutDMGPals call DoFrameIfLCDEnabled call Func_c2d4 - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 .asm_cf09 xor a @@ -2039,21 +2224,21 @@ asm_cf16 jr nz, asm_cf1f asm_cf19 - call Func_ccb9 - jp IncreaseOWScriptPointerBy4 + call SetScriptControlByteFail + jp IncreaseScriptPointerBy4 asm_cf1f - call Func_ccb3 - call GetOWSArgs2AfterPointer + call SetScriptControlBytePass + call GetScriptArgs2AfterPointer jr z, asm_cf2a - jp SetOWScriptPointer + jp SetScriptPointer asm_cf2a - jp IncreaseOWScriptPointerBy4 + jp IncreaseScriptPointerBy4 Func_cf2d: ; cf2d (3:4f2d) push bc - call IncreaseOWScriptPointerBy1 + call IncreaseScriptPointerBy1 pop bc call GetRawAmountOfCardsOwned ld a, h @@ -2066,20 +2251,21 @@ Func_cf2d: ; cf2d (3:4f2d) jr nc, asm_cf1f jr asm_cf19 -Func_cf3f: ; cf3f (3:4f3f) +; Gives the first arg as a card. If that's 0 pulls from wd697 +ScriptCommand_GiveCard: ; cf3f (3:4f3f) ld a, c or a - jr nz, .asm_cf46 + jr nz, .giveCard ld a, [wd697] -.asm_cf46 +.giveCard call AddCardToCollection - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 -Func_cf4c: ; cf4c (3:4f4c) +ScriptCommand_TakeCard: ; cf4c (3:4f4c) ld a, c call RemoveCardFromCollection - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_cf53: ; cf53 (3:4f53) ld c, $1 @@ -2097,17 +2283,17 @@ Func_cf53: ; cf53 (3:4f53) or a jr nz, Func_cf6d Func_cf67: ; cf67 (3:4f67) - call Func_ccb9 - jp IncreaseOWScriptPointerBy3 + call SetScriptControlByteFail + jp IncreaseScriptPointerBy3 Func_cf6d: ; cf6d (3:4f6d) - call Func_ccb3 - call GetOWSArgs1AfterPointer + call SetScriptControlBytePass + call GetScriptArgs1AfterPointer jr z, .asm_cf78 - jp SetOWScriptPointer + jp SetScriptPointer .asm_cf78 - jp IncreaseOWScriptPointerBy3 + jp IncreaseScriptPointerBy3 Func_cf7b: ; cf7b (3:4f7b) ld c, $1 @@ -2129,50 +2315,48 @@ Func_cf7b: ; cf7b (3:4f7b) ld a, c cp $8 jr c, .asm_cf7d - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 -; This function doesn't look like a valid function, but it's pointed to in the table. Func_cf96: ; cf96 (3:4f96) ld c, $0 - call Func_ca69 - ld de, $28b7 - ld hl, $08fe + get_flag_value EVENT_FLAG_11 + or a + jr z, Func_cfc0 + cp a, $08 jr c, .asm_cfa4 inc c .asm_cfa4 - call Func_ca69 - rla + get_flag_value EVENT_FLAG_17 cp $8 jr c, .asm_cfad inc c .asm_cfad - call Func_ca69 -.asm_cfb0 - jr nz, .asm_cfb0 - ld [$0138], sp + get_flag_value EVENT_FLAG_20 + cp a, $08 + jr c, .asm_cfb6 inc c +.asm_cfb6 ld a, c rlca add $3 - call GetOWSArgsAfterPointer - jp SetOWScriptPointer + call GetScriptArgsAfterPointer + jp SetScriptPointer Func_cfc0: ; cfc0 (3:4fc0) - call GetOWSArgs1AfterPointer - jp SetOWScriptPointer + call GetScriptArgs1AfterPointer + jp SetScriptPointer Func_cfc6: ; cfc6 (3:4fc6) - ld a, [wd3b6] - ld [wd3aa], a + ld a, [wScriptNPC] + ld [wLoadedNPCTempIndex], a ld a, c farcall Func_1c52e - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_cfd4: ; cfd4 (3:4fd4) - call Func_ca69 - dec l + get_flag_value EVENT_FLAG_2D ld b, a .asm_cfd9 ld a, $5 @@ -2196,17 +2380,16 @@ Func_cfd4: ; cfd4 (3:4fd4) or b push bc ld c, a - call Func_ca8f - dec l + set_flag_value EVENT_FLAG_2D pop bc ld b, $0 - ld hl, $5006 + ld hl, Data_d006 add hl, bc ld c, [hl] - call Func_ca8f - dec hl - jp IncreaseOWScriptPointerBy1 + set_flag_value EVENT_FLAG_2B + jp IncreaseScriptPointerBy1 +Data_d006: ; d006 (3:5006) INCROM $d006, $d00b Func_d00b: ; d00b (3:500b) @@ -2215,8 +2398,7 @@ Func_d00b: ; d00b (3:500b) ld hl, wTxRam2 add hl, bc push hl - call Func_ca69 - dec hl + get_flag_value EVENT_FLAG_2B ld e, a ld d, $0 call GetCardName @@ -2224,79 +2406,77 @@ Func_d00b: ; d00b (3:500b) ld [hl], e inc hl ld [hl], d - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d025: ; d025 (3:5025) - call Func_ca69 - dec hl + get_flag_value EVENT_FLAG_2B call GetCardCountInCollectionAndDecks jp c, Func_cf67 jp Func_cf6d Func_d032: ; d032 (3:5032) - call Func_ca69 - dec hl + get_flag_value EVENT_FLAG_2B call GetCardCountInCollection jp c, Func_cf67 jp Func_cf6d Func_d03f: ; d03f (3:503f) - call Func_ca69 - dec hl + get_flag_value EVENT_FLAG_2B call RemoveCardFromCollection - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 -OWScript_ScriptJump: ; d049 (3:5049) - call GetOWSArgs1AfterPointer - jp SetOWScriptPointer +ScriptCommand_Jump: ; d049 (3:5049) + call GetScriptArgs1AfterPointer + jp SetScriptPointer -Func_d04f: ; d04f (3:504f) - call Func_cad8 - jp IncreaseOWScriptPointerBy1 +ScriptCommand_TryGiveMedalPCPacks: ; d04f (3:504f) + call TryGiveMedalPCPacks + jp IncreaseScriptPointerBy1 -Func_d055: ; d055 (3:5055) +ScriptCommand_SetPlayerDirection: ; d055 (3:5055) ld a, c - call Func_c5ce - jp IncreaseOWScriptPointerBy2 + call UpdatePlayerDirection + jp IncreaseScriptPointerBy2 - -OWScript_MovePlayer: ; 505c (3:505c) +; arg1 - Direction (index in PlayerMovementOffsetTable) +; arg2 - Tiles Moves (Speed) +ScriptCommand_MovePlayer: ; 505c (3:505c) ld a, c ld [wd339], a ld a, b ld [wd33a], a - call StartScriptedMovement + call StartScript_dMovement .asm_d067 call DoFrameIfLCDEnabled call SetScreenScroll call Func_c53d - ld a, [wd335] + ld a, [wPlayerCurrentlyMoving] and $03 jr nz, .asm_d067 call DoFrameIfLCDEnabled call SetScreenScroll - jp IncreaseOWScriptPointerBy3 + jp IncreaseScriptPointerBy3 -Func_d080: ; d080 (3:5080) +ScriptCommand_SetDialogName: ; d080 (3:5080) ld a, c - farcall Func_11893 - jp IncreaseOWScriptPointerBy2 + farcall SetNPCDialogName + jp IncreaseScriptPointerBy2 -Func_d088: ; d088 (3:5088) +ScriptCommand_SetNextNPCandScript: ; d088 (3:5088) ld a, c - ld [wd3ab], a - call GetOWSArgs2AfterPointer - call Func_c926 - jp IncreaseOWScriptPointerBy4 + ld [wTempNPC], a + call GetScriptArgs2AfterPointer + call SetNextNPCAndScript + jp IncreaseScriptPointerBy4 Func_d095: ; d095 (3:5095) - ld a, [wd3b6] - ld [wd3aa], a + ld a, [wScriptNPC] + ld [wLoadedNPCTempIndex], a push bc - call GetOWSArgs3AfterPointer - ld a, [wd3b6] - ld l, $5 - call Func_39ad + call GetScriptArgs3AfterPointer + ld a, [wScriptNPC] + ld l, LOADED_NPC_FIELD_05 + call GetItemInLoadedNPCIndex res 4, [hl] ld a, [hl] or c @@ -2311,56 +2491,56 @@ Func_d095: ; d095 (3:5095) .asm_d0b6 ld a, e farcall Func_1c57b - jp IncreaseOWScriptPointerBy4 + jp IncreaseScriptPointerBy4 Func_d0be: ; d0be (3:50be) - ld a, [wd3b6] - ld [wd3aa], a + ld a, [wScriptNPC] + ld [wLoadedNPCTempIndex], a ld a, c ld c, b ld b, a farcall Func_1c461 - jp IncreaseOWScriptPointerBy3 + jp IncreaseScriptPointerBy3 -Func_d0ce: ; d0ce (3:50ce) +ScriptCommand_DoFrames: ; d0ce (3:50ce) push bc call DoFrameIfLCDEnabled pop bc dec c - jr nz, Func_d0ce - jp IncreaseOWScriptPointerBy2 + jr nz, ScriptCommand_DoFrames + jp IncreaseScriptPointerBy2 Func_d0d9: ; d0d9 (3:50d9) - ld a, [wd3b6] - ld [wd3aa], a + ld a, [wScriptNPC] + ld [wLoadedNPCTempIndex], a ld d, c ld e, b farcall Func_1c477 ld a, e cp c - jp nz, Func_d48a + jp nz, ScriptEventFailedNoJump ld a, d cp b - jp nz, Func_d48a - jp Func_d490 + jp nz, ScriptEventFailedNoJump + jp ScriptEventPassedTryJump -Func_d0f2: ; d0f2 (3:50f2) +ScriptCommand_JumpIfPlayerCoordMatches: ; d0f2 (3:50f2) ld a, [wPlayerXCoord] cp c - jp nz, Func_d48a + jp nz, ScriptEventFailedNoJump ld a, [wPlayerYCoord] cp b - jp nz, Func_d48a - jp Func_d490 + jp nz, ScriptEventFailedNoJump + jp ScriptEventPassedTryJump Func_d103: ; d103 (3:5103) - ld a, [wd3aa] + ld a, [wLoadedNPCTempIndex] push af - ld a, [wd3ab] + ld a, [wTempNPC] push af ld a, c - ld [wd3ab], a - call Func_39c3 + ld [wTempNPC], a + call FindLoadedNPC jr c, .asm_d119 call $54d1 jr .asm_d11c @@ -2370,9 +2550,9 @@ Func_d103: ; d103 (3:5103) .asm_d11c pop af - ld [wd3ab], a + ld [wTempNPC], a pop af - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a ret Func_d125: ; d125 (3:5125) @@ -2382,7 +2562,7 @@ Func_d125: ; d125 (3:5125) pop af farcall Medal_1029e call Func_c2d4 - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d135: ; d135 (3:5135) sla c @@ -2403,12 +2583,12 @@ Func_d135: ; d135 (3:5135) ld [hl], e inc hl ld [hl], d - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 INCROM $d153, $d16b Func_d16b: ; d16b (3:516b) - ld hl, wd0c8 + ld hl, wCurrentNPCNameTx ld e, [hl] inc hl ld d, [hl] @@ -2419,46 +2599,44 @@ Func_d16b: ; d16b (3:516b) add hl, bc push hl ld a, [wd696] - farcall Func_11893 + farcall SetNPCDialogName pop hl - ld a, [wd0c8] + ld a, [wCurrentNPCNameTx] ld [hli], a - ld a, [wd0c9] + ld a, [wCurrentNPCNameTx+1] ld [hl], a pop de - ld hl, wd0c8 + ld hl, wCurrentNPCNameTx ld [hl], e inc hl ld [hl], d - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d195: ; d195 (3:5195) - ld a, [wd3ab] + ld a, [wTempNPC] push af - call Func_ca69 - ld b, l + get_flag_value EVENT_FLAG_45 inc a ld c, a - call Func_ca8f - ld b, l + set_flag_value EVENT_FLAG_45 call Func_f580 pop af - ld [wd3ab], a - jp IncreaseOWScriptPointerBy1 + ld [wTempNPC], a + jp IncreaseScriptPointerBy1 Func_d1ad: ; d1ad (3:51ad) call MainMenu_c75a - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 Func_d1b3: ; d1b3 (3:51b3) - call Func_ca69 - ld b, h + get_flag_value EVENT_FLAG_44 dec a cp $2 jr c, .asm_d1c3 ld a, $d call Random add $2 +; fallthrough .asm_d1c3 ld hl, $51dc @@ -2475,13 +2653,12 @@ asm_d1c6 ld [wTxRam2], a ld a, [hl] ld [wTxRam2 + 1], a - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 INCROM $d1dc, $d209 Func_d209: ; d209 (3:5209) - call Func_ca69 - ld [hl], c + get_flag_value EVENT_FLAG_71 ld e, a .asm_d20e call UpdateRNGSources @@ -2501,21 +2678,35 @@ Func_d209: ; d209 (3:5209) jr nz, .asm_d20e push bc ld b, $0 - ld hl, $5240 + ld hl, Flags_d240 add hl, bc ld a, [hl] - call SetEventFlags + call MaxOutEventFlag pop bc - ld hl, $5234 + ld hl, LegendaryCards ld a, c jr asm_d1c6 - INCROM $d234, $d244 +LegendaryCards: ; d234 (3:5234) + db ZAPDOS3 + tx Text03f0 + db MOLTRES2 + tx Text03f1 + db ARTICUNO2 + tx Text03f2 + db DRAGONITE1 + tx Text03f3 + +Flags_d240: ; d240 (3:5240) + db EVENT_FLAG_6D + db EVENT_FLAG_6E + db EVENT_FLAG_6F + db EVENT_FLAG_70 Func_d244: ; d244 (3:5244) ld a, c farcall Func_80ba4 - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d24c: ; d24c (3:524c) ld hl, $525e @@ -2523,9 +2714,8 @@ Func_d24c: ; d24c (3:524c) call Func_d28c ld a, [wd695] ld c, a - call Func_ca8f - halt - jp IncreaseOWScriptPointerBy1 + set_flag_value EVENT_FLAG_76 + jp IncreaseScriptPointerBy1 INCROM $d25e, $d271 @@ -2533,7 +2723,7 @@ Func_d271: ; d271 (3:5271) ld hl, $527b xor a call Func_d28c - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 ; 0xd27b INCROM $d27b, $d28c @@ -2620,11 +2810,10 @@ Func_d2f6: ; d2f6 (3:52f6) call Func_d28c ld a, [wd694] ld c, a - call Func_ca8f - ld [hl], l + set_flag_value EVENT_FLAG_75 xor a ld [wd694], a - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 ; 0xd30c INCROM $d30c, $d317 @@ -2635,14 +2824,13 @@ Func_d317: ; d317 (3:5317) call Func_d28c ld a, [wd694] ld c, a - call Func_ca8f - ld [hl], l - jp IncreaseOWScriptPointerBy1 - + set_flag_value EVENT_FLAG_75 + jp IncreaseScriptPointerBy1 +Unknown_d32b: ; d32b (3:532b) INCROM $d32b, $d336 -OWScript_OpenDeckMachine: ; d336 (3:5336) +ScriptCommand_OpenDeckMachine: ; d336 (3:5336) push bc call Func_c2a3 call PauseSong @@ -2667,34 +2855,35 @@ OWScript_OpenDeckMachine: ; d336 (3:5336) .asm_d364 call ResumeSong call Func_c2d4 - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 -Func_d36d: ; d36d (3:536d) - ld a, [wOWScriptPointer] +; args: unused, room, new player x, new player y, new player direction +ScriptCommand_EnterMap: ; d36d (3:536d) + ld a, [wScriptPointer] ld l, a - ld a, [wOWScriptPointer+1] + ld a, [wScriptPointer+1] ld h, a inc hl ld a, [hli] ld a, [hli] - ld [wd0bb], a + ld [wTempMap], a ld a, [hli] - ld [wd0bc], a + ld [wTempPlayerXCoord], a ld a, [hli] - ld [wd0bd], a + ld [wTempPlayerYCoord], a ld a, [hli] - ld [wd0be], a + ld [wTempPlayerDirection], a ld hl, wd0b4 set 4, [hl] - jp IncreaseOWScriptPointerBy6 + jp IncreaseScriptPointerBy6 Func_d38f: ; d38f (3:538f) farcall Func_10c96 - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d396: ; d396 (3:5396) farcall Func_1157c - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d39d: ; d39d (3:539d) ld a, c @@ -2702,8 +2891,7 @@ Func_d39d: ; d39d (3:539d) jr nz, .asm_d3ac farcall Func_10dba ld c, a - call Func_ca8f - ld [hl], d + set_flag_value EVENT_FLAG_72 jr .asm_d3b6 .asm_d3ac @@ -2713,7 +2901,7 @@ Func_d39d: ; d39d (3:539d) set 6, [hl] .asm_d3b6 - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d3b9: ; d3b9 (3:53b9) call Func_3917 @@ -2721,20 +2909,20 @@ Func_d3b9: ; d3b9 (3:53b9) ld [wGameEvent], a ld hl, wd0b4 set 6, [hl] - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 -Func_d3c9: ; d3c9 (3:53c9) +ScriptCommand_TryGivePCPack: ; d3c9 (3:53c9) ld a, c - farcall Func_10a70 - jp IncreaseOWScriptPointerBy2 + farcall TryGivePCPack + jp IncreaseScriptPointerBy2 -Func_d3d1: ; d3d1 (3:53d1) - jp IncreaseOWScriptPointerBy1 +ScriptCommand_nop: ; d3d1 (3:53d1) + jp IncreaseScriptPointerBy1 Func_d3d4: ; d3d4 (3:53d4) ld a, [wd693] bank1call Func_7576 - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 INCROM $d3dd, $d3e0 @@ -2749,236 +2937,1096 @@ Func_d3e0: ; d3e0 (3:53e0) cp $2 jr nz, .asm_d3e9 farcall Func_10f2e - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 Func_d3fe: ; d3fe (3:53fe) ld a, c ld [wd112], a call PlaySong - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d408: ; d408 (3:5408) ld a, c ld [wd111], a - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d40f: ; d40f (3:540f) ld a, c - call Func_3c83 - jp IncreaseOWScriptPointerBy2 + call CallPlaySong + jp IncreaseScriptPointerBy2 -Func_d416: ; d416 (3:5416) +ScriptCommand_PlaySFX: ; d416 (3:5416) ld a, c call PlaySFX - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d41d: ; d41d (3:541d) call Func_39fc - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 -Func_d423: ; d423 (3:5423) +ScriptCommand_PauseSong: ; d423 (3:5423) call PauseSong - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 -Func_d429: ; d429 (3:5429) +ScriptCommand_ResumeSong: ; d429 (3:5429) call ResumeSong - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 -Func_d42f: ; d42f (3:542f) - call Func_3c96 - jp IncreaseOWScriptPointerBy1 +ScriptCommand_WaitForSongToFinish: ; d42f (3:542f) + call WaitForSongToFinish + jp IncreaseScriptPointerBy1 Func_d435: ; d435 (3:5435) ld a, c farcall Func_1c83d - jp IncreaseOWScriptPointerBy2 + jp IncreaseScriptPointerBy2 Func_d43d: ; d43d (3:543d) ld a, GAME_EVENT_CHALLENGE_MACHINE ld [wGameEvent], a ld hl, wd0b4 set 6, [hl] - jp IncreaseOWScriptPointerBy1 + jp IncreaseScriptPointerBy1 -OWScript_CustomModifyEventFlags: ; d44a (3:544a) +; sets the event flag in arg 1 to the value in arg 2 +ScriptCommand_SetFlagValue: ; d44a (3:544a) ld a, c ld c, b - call ModifyEventFlags - jp IncreaseOWScriptPointerBy3 + call SetEventFlagValue + jp IncreaseScriptPointerBy3 -Func_d452: ; d452 (3:5452) +ScriptCommand_IncrementFlagValue: ; d452 (3:5452) ld a, c push af - call CheckIfEventFlagSet + call GetEventFlagValue inc a ld c, a pop af - call ModifyEventFlags - jp IncreaseOWScriptPointerBy2 + call SetEventFlagValue + jp IncreaseScriptPointerBy2 -Func_d460: ; d460 (3:5460) +ScriptCommand_JumpIfFlagZero1: ; d460 (3:5460) ld a, c - call CheckIfEventFlagSet + call GetEventFlagValue or a - jr z, asm_d46d -asm_d467 - call Func_ccb9 - jp IncreaseOWScriptPointerBy4 + jr z, ScriptCommand_JumpIfFlagZero1.passTryJump -asm_d46d - call Func_ccb3 - call GetOWSArgs2AfterPointer - jr z, .asm_d478 - jp SetOWScriptPointer +.fail + call SetScriptControlByteFail + jp IncreaseScriptPointerBy4 -.asm_d478 - jp IncreaseOWScriptPointerBy4 +.passTryJump + call SetScriptControlBytePass + call GetScriptArgs2AfterPointer + jr z, .noJumpTarget + jp SetScriptPointer -OWScript_JumpIfFlagSet: ; d47b (3:547b) +.noJumpTarget + jp IncreaseScriptPointerBy4 + +ScriptCommand_JumpIfFlagNonzero1: ; d47b (3:547b) ld a, c - call CheckIfEventFlagSet + call GetEventFlagValue or a - jr nz, asm_d46d - jr asm_d467 + jr nz, ScriptCommand_JumpIfFlagZero1.passTryJump + jr ScriptCommand_JumpIfFlagZero1.fail -Func_d484: ; d484 (3:5484) - call Func_d4b6 +; args - event flag, value, jump address +ScriptCommand_JumpIfFlagEqual: ; d484 (3:5484) + call GetEventFlagValueBC cp c - jr z, Func_d490 + jr z, ScriptEventPassedTryJump -Func_d48a: ; d48a (3:548a) - call Func_ccb9 - jp IncreaseOWScriptPointerBy5 +ScriptEventFailedNoJump ; d48a (3:548a) + call SetScriptControlByteFail + jp IncreaseScriptPointerBy5 -Func_d490: ; d490 (3:5490) - call Func_ccb3 - call GetOWSArgs3AfterPointer - jr z, .asm_d49b - jp SetOWScriptPointer +ScriptEventPassedTryJump ; d490 (3:5490) + call SetScriptControlBytePass + call GetScriptArgs3AfterPointer + jr z, .noJumpAddress + jp SetScriptPointer -.asm_d49b - jp IncreaseOWScriptPointerBy5 +.noJumpAddress + jp IncreaseScriptPointerBy5 -Func_d49e: ; d49e (3:549e) - call Func_d4b6 +ScriptCommand_JumpIfFlagNotEqual: ; d49e (3:549e) + call GetEventFlagValueBC cp c - jr nz, Func_d490 - jr Func_d48a + jr nz, ScriptEventPassedTryJump + jr ScriptEventFailedNoJump -Func_d4a6: ; d4a6 (3:54a6) - call Func_d4b6 +ScriptCommand_JumpIfFlagNotLessThan: ; d4a6 (3:54a6) + call GetEventFlagValueBC cp c - jr nc, Func_d490 - jr Func_d48a + jr nc, ScriptEventPassedTryJump + jr ScriptEventFailedNoJump -Func_d4ae: ; d4ae (3:54ae) - call Func_d4b6 +ScriptCommand_JumpIfFlagLessThan: ; d4ae (3:54ae) + call GetEventFlagValueBC cp c - jr c, Func_d490 ; 0xd4b2 $dc - jr Func_d48a ; 0xd4b4 $d4 + jr c, ScriptEventPassedTryJump + jr ScriptEventFailedNoJump -Func_d4b6: ; d4b6 (3:54b6) +; Gets event flag at c (Script defaults) +; c takes on the value of b as a side effect +GetEventFlagValueBC: ; d4b6 (3:54b6) ld a, c ld c, b - call CheckIfEventFlagSet + call GetEventFlagValue ret -OWScript_SetEventFlags: ; d4bc (3:54bc) +ScriptCommand_MaxOutFlagValue: ; d4bc (3:54bc) ld a, c - call SetEventFlags - jp IncreaseOWScriptPointerBy2 + call MaxOutEventFlag + jp IncreaseScriptPointerBy2 -Func_d4c3: ; d4c3 (3:54c3) +ScriptCommand_ZeroOutFlagValue: ; d4c3 (3:54c3) ld a, c - call Func_cad0 - jp IncreaseOWScriptPointerBy2 + call ZeroOutEventFlag + jp IncreaseScriptPointerBy2 -Func_d4ca: ; d4ca (3:54ca) +ScriptCommand_JumpIfFlagNonzero2: ; d4ca (3:54ca) ld a, c - call CheckIfEventFlagSet + call GetEventFlagValue or a - jr z, asm_d4e6 -Func_d4d1: - call Func_ccb3 - call GetOWSArgs2AfterPointer - jr z, .asm_d4dc - jp SetOWScriptPointer -.asm_d4dc - jp IncreaseOWScriptPointerBy4 - -OWScript_JumpIfFlagNotSet: + jr z, ScriptCommand_JumpIfFlagZero2.fail + +.passTryJump: + call SetScriptControlBytePass + call GetScriptArgs2AfterPointer + jr z, .noJumpArgs + jp SetScriptPointer +.noJumpArgs + jp IncreaseScriptPointerBy4 + +ScriptCommand_JumpIfFlagZero2: ld a, c - call CheckIfEventFlagSet + call GetEventFlagValue or a - jr z, Func_d4d1 -asm_d4e6 - call Func_ccb9 - jp IncreaseOWScriptPointerBy4 + jr z, ScriptCommand_JumpIfFlagNonzero2.passTryJump + +.fail + call SetScriptControlByteFail + jp IncreaseScriptPointerBy4 ; 0xd4ec - INCROM $d4ec, $d753 +LoadOverworld: ; d4ec (3:54ec) + call Func_d4fb + get_flag_value EVENT_FLAG_3E + or a + ret nz + ld bc, Script_BeginGame + jp SetNextScript + +Func_d4fb: ; d4fb (3:54fb) + zero_flag_value EVENT_FLAG_59 + call Func_f602 + get_flag_value EVENT_FLAG_3F + cp $02 + jr z, .asm_d527 + get_flag_value EVENT_FLAG_40 + cp $02 + jr z, .asm_d521 + get_flag_value EVENT_FLAG_41 + cp $02 + jr z, .asm_d51b + ret +.asm_d51b + ld c, $07 + set_flag_value EVENT_FLAG_41 +.asm_d521 + ld c, $07 + set_flag_value EVENT_FLAG_40 +.asm_d527 + ld c, $07 + set_flag_value EVENT_FLAG_3F + ret -OWSequence_d753: ; d753 (3:5753) +Script_BeginGame: ; d52e (3:552e) start_script - run_script OWScript_MovePlayer - db $00 + run_command ScriptCommand_DoFrames + db $3c + run_command Func_d3e0 + run_command ScriptCommand_DoFrames + db $78 + run_command ScriptCommand_EnterMap db $02 - run_script OWScript_MovePlayer + db MASON_LABORATORY + db 14 + db 26 + db NORTH + run_command ScriptCommand_QuitScriptFully + +MasonLaboratoryAfterDuel: ; d53b (3:553b) + ld hl, .after_duel_table + call FindEndOfBattleScript + ret + +.after_duel_table + db NPC_SAM + db NPC_SAM + dw $568a + dw $569f db $00 - db $02 - run_script OWScript_MovePlayer + +MasonLabLoadMap: ; d549 (3:5549) + get_flag_value EVENT_FLAG_3E + cp $03 + ret nc + ld a, NPC_DRMASON + ld [wTempNPC], a + call FindLoadedNPC + ld bc, Script_EnterLabFirstTime + jp SetNextNPCAndScript + +MasonLabCloseTextBox: ; d55e (3:555e) + ld a, $0a + farcall Func_80b89 + ret + +; Lets you access the Challenge Machine if available +MasonLabPressedA: ; d565 (3:5565) + get_flag_value EVENT_RECEIVED_LEGENDARY_CARD + or a + ret z + ld hl, ChallengeMachineObjectTable + call FindExtraInteractableObjects + ret + +ChallengeMachineObjectTable: ; d572 (3:5572) + db 10, 4, NORTH + dw Script_ChallengeMachine + db 12, 4, NORTH + dw Script_ChallengeMachine db $00 + +Script_ChallengeMachine: ; d57d (3:557d) + start_script + run_command Func_ccdc + tx Text05bd + run_command Func_d43d + run_command ScriptCommand_QuitScriptFully + + INCROM $d583, $d753 + +Script_EnterLabFirstTime: ; d753 (3:5753) + start_script + run_command ScriptCommand_MovePlayer + db NORTH db $02 - run_script OWScript_MovePlayer - db $00 + run_command ScriptCommand_MovePlayer + db NORTH db $02 - run_script OWScript_MovePlayer - db $00 + run_command ScriptCommand_MovePlayer + db NORTH db $02 - run_script OWScript_MovePlayer - db $00 + run_command ScriptCommand_MovePlayer + db NORTH db $02 - run_script OWScript_MovePlayer - db $00 + run_command ScriptCommand_MovePlayer + db NORTH db $02 - run_script OWScript_MovePlayer - db $00 + run_command ScriptCommand_MovePlayer + db NORTH db $02 - run_script OWScript_MovePlayer - db $00 + run_command ScriptCommand_MovePlayer + db NORTH + db $02 + run_command ScriptCommand_MovePlayer + db NORTH db $02 - run_script OWScript_PrintTextString + run_command ScriptCommand_MovePlayer + db NORTH + db $02 + run_command ScriptCommand_PrintTextString tx Text05e3 - run_script OWScript_CloseTextBox - run_script Func_d088 + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript + db NPC_SAM + dw Script_d779 + run_command ScriptCommand_EndScriptLoop1 + ret + +Script_d779: ; d779 (03:5779) + start_script + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_d880 + run_command ScriptCommand_PrintTextString + tx Text05e4 + run_command ScriptCommand_SetDialogName + db NPC_DRMASON + run_command ScriptCommand_PrintTextString + tx Text05e5 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_d882 + run_command Func_cfc6 + db $01 + run_command ScriptCommand_SetPlayerDirection + db $03 + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript + db NPC_DRMASON + dw Script_d794 + run_command ScriptCommand_EndScriptLoop1 + ret + +Script_d794: ; d794 (3:5794) + start_script + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_d88b + run_command ScriptCommand_DoFrames + db 40 + run_command ScriptCommand_PrintTextString + tx Text05e6 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MovePlayer + db WEST + db $01 + run_command ScriptCommand_MovePlayer + db WEST + db $01 + run_command ScriptCommand_SetPlayerDirection + db SOUTH + run_command ScriptCommand_MovePlayer + db SOUTH + db $01 + run_command ScriptCommand_MovePlayer + db SOUTH + db $01 + run_command ScriptCommand_MovePlayer + db SOUTH + db $01 + run_command ScriptCommand_SetPlayerDirection + db WEST + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_d894 + run_command ScriptCommand_PrintTextString + tx Text05e7 + run_command ScriptCommand_SetDialogName + db $07 + run_command ScriptCommand_PrintTextString + tx Text05e8 + +.ows_d7bc + run_command ScriptCommand_CloseTextBox + run_command Func_d317 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_75 + db $07 + dw .ows_d80c + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_75 + db $01 + dw .ows_d7e8 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_75 + db $02 + dw .ows_d7ee + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_75 + db $03 + dw .ows_d7f4 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_75 + db $04 + dw .ows_d7fa + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_75 + db $05 + dw .ows_d800 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_75 + db $06 + dw .ows_d806 + run_command ScriptCommand_PrintTextString + tx Text05d6 + run_command ScriptCommand_Jump + dw .ows_d7bc + +.ows_d7e8 + run_command ScriptCommand_PrintTextString + tx Text05d7 + run_command ScriptCommand_Jump + dw .ows_d7bc + +.ows_d7ee + run_command ScriptCommand_PrintTextString + tx Text05d8 + run_command ScriptCommand_Jump + dw .ows_d7bc + +.ows_d7f4 + run_command ScriptCommand_PrintTextString + tx Text05d9 + run_command ScriptCommand_Jump + dw .ows_d7bc + +.ows_d7fa + run_command ScriptCommand_PrintTextString + tx Text05da + run_command ScriptCommand_Jump + dw .ows_d7bc + +.ows_d800 + run_command ScriptCommand_PrintTextString + tx Text05db + run_command ScriptCommand_Jump + dw .ows_d7bc + +.ows_d806 + run_command ScriptCommand_PrintTextString + tx Text05dc + run_command ScriptCommand_Jump + dw .ows_d7bc + +.ows_d80c + run_command ScriptCommand_PrintTextString + tx Text05e9 + run_command ScriptCommand_AskQuestionJumpDefaultYes + dw 0000 + dw .ows_d817 + run_command ScriptCommand_Jump + dw .ows_d7bc + +.ows_d817 + run_command ScriptCommand_SetDialogName + db $01 + run_command ScriptCommand_PrintTextString + tx Text05ea + run_command ScriptCommand_nop + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_3E + db $01 + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript + db NPC_SAM + dw Script_d827 + run_command ScriptCommand_EndScriptLoop1 + ret + +Script_d827: ; d827 (3:5827) + start_script + run_command ScriptCommand_StartBattle + db PRIZES_2 + db SAMS_PRACTICE_DECK_ID + db MUSIC_DUEL_THEME_1 + run_command ScriptCommand_QuitScriptFully +; 0xd82d + + INCROM $d82d, $d880 + +NPCMovement_d880: ; d880 (3:5880) + db EAST + db $ff + +NPCMovement_d882: ; d882 (3:5882) + db SOUTH + db SOUTH + db WEST + db WEST + db WEST + db WEST + db SOUTH + db EAST | NO_MOVE + db $ff + +NPCMovement_d88b: ; d88b (3:588b) + db WEST + db SOUTH + db SOUTH + db SOUTH + db WEST + db WEST + db WEST + db EAST | NO_MOVE + db $ff + +NPCMovement_d894: ; d894 (4:5894) + db SOUTH | NO_MOVE + db $ff + + INCROM $d896, $d932 + +Script_d932: ; d932 (3:5932) + start_script + run_command Func_ccdc + tx Text0605 + run_command ScriptCommand_AskQuestionJumpDefaultYes + tx Text0606 + dw .ows_d93c + run_command ScriptCommand_QuitScriptFully + +.ows_d93c + run_command ScriptCommand_OpenDeckMachine + db $09 + run_command ScriptCommand_QuitScriptFully +; 0xd93f + + INCROM $d93f, $dadd + +Preload_NikkiInIshiharasHouse: ; dadd (3:5add) + get_flag_value EVENT_FLAG_35 + cp $01 + jr nz, .dontLoadNikki + scf + ret +.dontLoadNikki + or a + ret +; 0xdae9 + + INCROM $dae9, $db3d + +Preload_IshiharaInIshiharasHouse: ; db3d (3:5b3d) + get_flag_value EVENT_FLAG_1C + or a + ret z + get_flag_value EVENT_FLAG_1F + cp $08 + ret + +Script_Ishihara: ; db4a (3:5b4a) + start_script + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_1D + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_1F + db $00 + dw .ows_db80 + run_command ScriptCommand_JumpIfFlagNonzero2 + db EVENT_FLAG_39 + dw .ows_db5a + run_command ScriptCommand_JumpIfFlagNonzero2 + db EVENT_RECEIVED_LEGENDARY_CARD + dw .ows_dc3e +.ows_db5a + run_command ScriptCommand_JumpIfFlagNonzero2 + db EVENT_FLAG_00 + dw .ows_db90 + run_command ScriptCommand_JumpIfFlagZero2 + db EVENT_FLAG_38 + dw .ows_db90 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_1F + db $01 + dw .ows_db93 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_1F + db $02 + dw .ows_db93 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_1F + db $03 + dw .ows_dbcc + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_1F + db $04 + dw .ows_dbcc + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_1F + db $05 + dw .ows_dc05 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_1F + db $06 + dw .ows_dc05 +.ows_db80 + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_00 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_1F + db $01 + run_command ScriptCommand_ZeroOutFlagValue + db EVENT_FLAG_38 + run_command ScriptCommand_JumpIfFlagZero2 + db EVENT_RECEIVED_LEGENDARY_CARD + dw .ows_db8d + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_39 +.ows_db8d + run_command ScriptCommand_PrintTextQuitFully + tx Text0727 + +.ows_db90 + run_command ScriptCommand_PrintTextQuitFully + tx Text0728 + +.ows_db93 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_1F + db $01 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text0729 + tx Text072a + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_1F + db $02 + run_command ScriptCommand_AskQuestionJump + tx Text072b + dw .ows_dba8 + run_command ScriptCommand_PrintTextQuitFully + tx Text072c + +.ows_dba8 + run_command Func_cf0c + db $ac + dw .ows_dbaf + run_command ScriptCommand_PrintTextQuitFully + tx Text072d + +.ows_dbaf + run_command Func_cf12 + db $ac + dw .ows_dbb6 + run_command ScriptCommand_PrintTextQuitFully + tx Text072e + +.ows_dbb6 + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_00 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_1F + db $03 + run_command ScriptCommand_ZeroOutFlagValue + db EVENT_FLAG_38 + run_command ScriptCommand_PrintTextString + tx Text072f + run_command Func_ccdc + tx Text0730 + run_command ScriptCommand_TakeCard + db CLEFABLE + run_command ScriptCommand_GiveCard + db SURFING_PIKACHU1 + run_command ScriptCommand_ShowCardReceivedScreen + db SURFING_PIKACHU1 + run_command ScriptCommand_PrintTextQuitFully + tx Text0731 + +.ows_dbcc + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_1F + db $03 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text0732 + tx Text0733 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_1F + db $04 + run_command ScriptCommand_AskQuestionJump + tx Text072b + dw .ows_dbe1 + run_command ScriptCommand_PrintTextQuitFully + tx Text072c + +.ows_dbe1 + run_command Func_cf0c + db $bb + dw .ows_dbe8 + run_command ScriptCommand_PrintTextQuitFully + tx Text0734 + +.ows_dbe8 + run_command Func_cf12 + db $bb + dw .ows_dbef + run_command ScriptCommand_PrintTextQuitFully + tx Text0735 + +.ows_dbef + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_00 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_1F + db $05 + run_command ScriptCommand_ZeroOutFlagValue + db EVENT_FLAG_38 + run_command ScriptCommand_PrintTextString + tx Text072f + run_command Func_ccdc + tx Text0736 + run_command ScriptCommand_TakeCard + db DITTO + run_command ScriptCommand_GiveCard + db FLYING_PIKACHU + run_command ScriptCommand_ShowCardReceivedScreen + db FLYING_PIKACHU + run_command ScriptCommand_PrintTextQuitFully + tx Text0737 + +.ows_dc05 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_1F + db $05 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text0738 + tx Text0739 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_1F + db $06 + run_command ScriptCommand_AskQuestionJump + tx Text072b + dw .ows_dc1a + run_command ScriptCommand_PrintTextQuitFully + tx Text072c + +.ows_dc1a + run_command Func_cf0c + db $b8 + dw .ows_dc21 + run_command ScriptCommand_PrintTextQuitFully + tx Text073a + +.ows_dc21 + run_command Func_cf12 + db $b8 + dw .ows_dc28 + run_command ScriptCommand_PrintTextQuitFully + tx Text073b + +.ows_dc28 + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_00 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_1F + db $07 + run_command ScriptCommand_ZeroOutFlagValue + db EVENT_FLAG_38 + run_command ScriptCommand_PrintTextString + tx Text072f + run_command Func_ccdc + tx Text073c + run_command ScriptCommand_TakeCard + db CHANSEY + run_command ScriptCommand_GiveCard + db SURFING_PIKACHU2 + run_command ScriptCommand_ShowCardReceivedScreen + db SURFING_PIKACHU2 + run_command ScriptCommand_PrintTextQuitFully + tx Text073d + +.ows_dc3e + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_39 + run_command ScriptCommand_PrintTextQuitFully + tx Text073e + +Preload_Ronald1InIshiharasHouse: ; dc43 (3:5c43) + get_flag_value EVENT_RECEIVED_LEGENDARY_CARD + cp $01 + ccf + ret + +Script_Ronald: ; dc4b (3:5c4b) + start_script + run_command ScriptCommand_JumpIfFlagNonzero2 + db EVENT_FLAG_4E + dw .ows_dc55 + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_4E + run_command ScriptCommand_PrintTextQuitFully + tx Text073f + +.ows_dc55 + run_command ScriptCommand_PrintTextString + tx Text0740 + run_command ScriptCommand_AskQuestionJump + tx Text0741 + dw .ows_dc60 + run_command ScriptCommand_PrintTextQuitFully + tx Text0742 + +.ows_dc60 + run_command ScriptCommand_PrintTextQuitFully + tx Text0743 +; 0xdc63 + + ; could be a commented function, or could be placed by mistake from + ; someone thinking that the Ronald script ended with more code execution + ret + +Script_Clerk1: ; dc64 (3:5c64) + start_script + run_command ScriptCommand_PrintTextQuitFully + tx Text045a + +FightingClubLobbyAfterDuel: ; dc68 (3:5c68) + ld hl, .after_duel_table + call FindEndOfBattleScript + ret +.after_duel_table + db NPC_IMAKUNI + db NPC_IMAKUNI + dw Script_BeatImakuni + dw Script_LostToImakuni + db $00 + + INCROM $dc76, $dd0d + +Script_Imakuni: ; dd0d (3:5d0d) + start_script + run_command ScriptCommand_SetFlagValue + db EVENT_IMAKUNI_STATE + db IMAKUNI_TALKED + run_command ScriptCommand_JumpIfFlagZero2 + db EVENT_TEMP_TALKED_TO_IMAKUNI + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text0467 + tx Text0468 + run_command ScriptCommand_MaxOutFlagValue + db EVENT_TEMP_TALKED_TO_IMAKUNI + run_command ScriptCommand_AskQuestionJump + tx Text0469 + dw .declineDuel + run_command ScriptCommand_PrintTextString + tx Text046a + run_command ScriptCommand_QuitScriptFully + +.declineDuel + run_command ScriptCommand_PrintTextString + tx Text046b + run_command ScriptCommand_StartBattle + db PRIZES_6 + db IMAKUNI_DECK_ID + db MUSIC_IMAKUNI + run_command ScriptCommand_QuitScriptFully +; 0xdd2d + +Script_BeatImakuni: ; dd2d (3:5d2d) + start_script + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_IMAKUNI_WIN_COUNT db $07 - db $79 - db $57 - run_script OWScript_EndScriptLoop1 + dw .giveBoosters + run_command ScriptCommand_IncrementFlagValue + db EVENT_IMAKUNI_WIN_COUNT + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_IMAKUNI_WIN_COUNT + db $03 + dw .threeWins + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_IMAKUNI_WIN_COUNT + db $06 + dw .sixWins +.giveBoosters + run_command ScriptCommand_PrintTextString + tx Text046c + run_command ScriptCommand_GiveOneOfEachTrainerBooster + run_command ScriptCommand_Jump + dw .done + +.threeWins + run_command ScriptCommand_PrintTextString + tx Text046d + run_command ScriptCommand_Jump + dw .giveImakuniCard + +.sixWins + run_command ScriptCommand_PrintTextString + tx Text046e +.giveImakuniCard + run_command ScriptCommand_PrintTextString + tx Text046f + run_command ScriptCommand_GiveCard + db IMAKUNI_CARD + run_command ScriptCommand_ShowCardReceivedScreen + db IMAKUNI_CARD +.done + run_command ScriptCommand_PrintTextString + tx Text0470 + run_command ScriptCommand_Jump + dw ScriptJump_ImakuniCommon + +Script_LostToImakuni: ; dd5c (3:5d5c) + start_script + run_command ScriptCommand_PrintTextString + tx Text0471 + +ScriptJump_ImakuniCommon: ; dd60 (3:5d60) + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_JumpIfPlayerCoordMatches + db 18 + db 4 + dw .ows_dd69 + run_command ScriptCommand_Jump + dw .ows_dd6e + +.ows_dd69 + run_command ScriptCommand_SetPlayerDirection + db EAST + run_command ScriptCommand_MovePlayer + db WEST + db $01 + +.ows_dd6e + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_dd78 + run_command Func_cdcb + run_command ScriptCommand_MaxOutFlagValue + db EVENT_TEMP_BATTLED_IMAKUNI + run_command Func_d408 + db $09 + run_command Func_d41d + run_command ScriptCommand_QuitScriptFully +; 0xdd78 + +NPCMovement_dd78 ; dd78 (3:5d78) + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db EAST + db EAST + db EAST + db EAST + db EAST + db $ff + + INCROM $dd82, $e0b0 + +Preload_ImakuniInWaterClubLobby: ; e0b0 (3:60b0) + get_flag_value EVENT_IMAKUNI_STATE + cp IMAKUNI_TALKED + jr c, .asm_e0c6 + get_flag_value EVENT_TEMP_BATTLED_IMAKUNI + jr nz, .asm_e0c6 + get_flag_value EVENT_IMAKUNI_ROOM + cp IMAKUNI_WATER_CLUB + jr z, .asm_e0c8 +.asm_e0c6 + or a ret +.asm_e0c8 + ld a, $10 + ld [wd111], a + scf + ret +; 0xe0cf +Script_Gal1: ; e0cf (3:60cf) start_script - run_script Func_ce4a - db $80 - db $58 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_12 + db $02 + dw .ows_e10e + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_12 + db $00 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text041d + tx Text041e + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_12 + db $01 + run_command ScriptCommand_AskQuestionJump + tx Text041f + dw .ows_e0eb + run_command ScriptCommand_PrintTextString + tx Text0420 + run_command ScriptCommand_QuitScriptFully + +.ows_e0eb + run_command Func_cf0c + db $59 + dw .ows_e0f3 + run_command ScriptCommand_PrintTextString + tx Text0421 + run_command ScriptCommand_QuitScriptFully + +.ows_e0f3 + run_command Func_cf12 + db $59 + dw .ows_e0fb + run_command ScriptCommand_PrintTextString + tx Text0422 + run_command ScriptCommand_QuitScriptFully + +.ows_e0fb + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_12 db $02 + run_command ScriptCommand_PrintTextString + tx Text0423 + run_command Func_ccdc + tx Text0424 + run_command ScriptCommand_TakeCard + db LAPRAS + run_command ScriptCommand_GiveCard + db ARCANINE1 + run_command ScriptCommand_ShowCardReceivedScreen + db ARCANINE1 + run_command ScriptCommand_PrintTextString + tx Text0425 + run_command ScriptCommand_QuitScriptFully + +.ows_e10e + run_command ScriptCommand_PrintTextQuitFully + tx Text0426 + +Script_Lass1: ; e111 (3:6111) + start_script + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_14 + db $01 + dw .ows_e121 + run_command ScriptCommand_PrintTextString + tx Text0427 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_14 + db $01 + run_command ScriptCommand_SetFlagValue + db EVENT_IMAKUNI_STATE + db IMAKUNI_MENTIONED + run_command ScriptCommand_QuitScriptFully + +.ows_e121 + run_command ScriptCommand_JumpIfFlagNotEqual + db EVENT_IMAKUNI_ROOM + db IMAKUNI_WATER_CLUB + dw .ows_e12d + run_command ScriptCommand_JumpIfFlagNonzero2 + db EVENT_TEMP_BATTLED_IMAKUNI + dw .ows_e12d + run_command ScriptCommand_PrintTextQuitFully + tx Text0428 + +.ows_e12d + run_command ScriptCommand_PrintTextQuitFully + tx Text0429 + +Preload_Man2InWaterClubLobby: ; e130 (3:6130) + get_flag_value EVENT_JOSHUA_STATE + cp JOSHUA_BEATEN + ret - ; there's more to this script but it hasn't been disassembled yet +Script_Man2: ; e137 (3:6137) + start_script + run_command ScriptCommand_PrintTextQuitFully + tx Text042a - INCROM $d77e, $e13f +Script_Pappy2: ; e13b (3:613b) + start_script + run_command ScriptCommand_PrintTextQuitFully + tx Text042b WaterClubMovePlayer: ; e13f (3:613f) ld a, [wPlayerYCoord] cp $8 ret nz - call Func_ca69 - inc sp + get_flag_value EVENT_JOSHUA_STATE cp $2 ret nc - ld a, $21 - ld [wd3ab], a - ld bc, OWSequence_NotReadyToSeeAmy - jp Func_c926 + ld a, NPC_JOSHUA + ld [wTempNPC], a + ld bc, Script_NotReadyToSeeAmy + jp SetNextNPCAndScript WaterClubAfterDuel: ;e157 (3:6157) ld hl, .after_duel_table @@ -2986,135 +4034,503 @@ WaterClubAfterDuel: ;e157 (3:6157) ret .after_duel_table - dw $1f1f - dw OWSequence_BeatSara - dw OWSequence_LostToSara - - dw $2020 - dw OWSequence_BeatAmanda - dw OWSequence_LostToAmanda - - dw $2121 - dw $626c - dw $6260 - - dw $2222 - dw $6322 - dw $6344 + db NPC_SARA + db NPC_SARA + dw Script_BeatSara + dw Script_LostToSara + + db NPC_AMANDA + db NPC_AMANDA + dw Script_BeatAmanda + dw Script_LostToAmanda + + db NPC_JOSHUA + db NPC_JOSHUA + dw Script_BeatJoshua + dw Script_LostToJoshua + + db NPC_AMY + db NPC_AMY + dw Script_BeatAmy + dw Script_LostToAmy db $00 -OWSequence_Sara: ; e177 (3:6177) +Script_Sara: ; e177 (3:6177) start_script - run_script OWScript_PrintTextString + run_command ScriptCommand_PrintTextString tx Text042c - run_script OWScript_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text042d dw .yes_duel - run_script OWScript_PrintTextString + run_command ScriptCommand_PrintTextString tx Text042e - run_script OWScript_EndScriptCloseText + run_command ScriptCommand_QuitScriptFully .yes_duel - run_script OWScript_PrintTextString + run_command ScriptCommand_PrintTextString tx Text042f - run_script OWScript_StartBattle - db 2 - db WATERFRONT_POKEMON_DECK_ID ; 6189 + run_command ScriptCommand_StartBattle + db PRIZES_2 + db WATERFRONT_POKEMON_DECK_ID db MUSIC_DUEL_THEME_1 - run_script OWScript_EndScriptCloseText + run_command ScriptCommand_QuitScriptFully -OWSequence_BeatSara: ; e18c (3:618c) +Script_BeatSara: ; e18c (3:618c) start_script - run_script OWScript_SetEventFlags + run_command ScriptCommand_MaxOutFlagValue db EVENT_BEAT_SARA - run_script OWScript_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0430 - run_script OWScript_GiveBoosterPacks + run_command ScriptCommand_GiveBoosterPacks db BOOSTER_COLOSSEUM_WATER db BOOSTER_COLOSSEUM_WATER db NO_BOOSTER - run_script OWScript_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0431 - run_script OWScript_EndScriptCloseText + run_command ScriptCommand_QuitScriptFully -OWSequence_LostToSara: ; e19a (03:619a) +Script_LostToSara: ; e19a (03:619a) start_script - run_script OWScript_PrintTextCloseBox + run_command ScriptCommand_PrintTextQuitFully tx Text0432 -OWSequence_Amanda: ; e19e (03:619e) +Script_Amanda: ; e19e (03:619e) start_script - run_script OWScript_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0433 - run_script OWScript_AskQuestionJump + run_command ScriptCommand_AskQuestionJump tx Text0434 dw .yes_duel - run_script OWScript_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0435 - run_script OWScript_EndScriptCloseText + run_command ScriptCommand_QuitScriptFully .yes_duel - run_script OWScript_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0436 - run_script OWScript_StartBattle - db 03 + run_command ScriptCommand_StartBattle + db PRIZES_3 db LONELY_FRIENDS_DECK_ID db MUSIC_DUEL_THEME_1 - run_script OWScript_EndScriptCloseText + run_command ScriptCommand_QuitScriptFully -OWSequence_BeatAmanda: ; e1b3 (03:61b3) +Script_BeatAmanda: ; e1b3 (03:61b3) start_script - run_script OWScript_SetEventFlags + run_command ScriptCommand_MaxOutFlagValue db EVENT_BEAT_AMANDA - run_script OWScript_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0437 - run_script OWScript_GiveBoosterPacks + run_command ScriptCommand_GiveBoosterPacks db BOOSTER_MYSTERY_LIGHTNING_COLORLESS db BOOSTER_MYSTERY_LIGHTNING_COLORLESS db NO_BOOSTER - run_script OWScript_PrintTextString + run_command ScriptCommand_PrintTextString tx Text0438 - run_script OWScript_EndScriptCloseText + run_command ScriptCommand_QuitScriptFully -OWSequence_LostToAmanda: ; e1c1 (03:61c1) +Script_LostToAmanda: ; e1c1 (03:61c1) start_script - run_script OWScript_PrintTextCloseBox + run_command ScriptCommand_PrintTextQuitFully tx Text0439 -OWSequence_NotReadyToSeeAmy: - INCROM $e1c5, $e21c - -OWSequence_Joshua: +Script_NotReadyToSeeAmy: ; e1c5 (03:61c5) start_script - run_script OWScript_JumpIfFlagNotSet + run_command ScriptCommand_JumpIfPlayerCoordMatches + db $12 + db $08 + dw .ows_e1ec + run_command ScriptCommand_JumpIfPlayerCoordMatches + db $14 + db $08 + dw .ows_e1f2 + run_command ScriptCommand_JumpIfPlayerCoordMatches + db $18 + db $08 + dw .ows_e1f8 +.ows_e1d5 + run_command ScriptCommand_MovePlayer + db SOUTH + db $04 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_e213 + run_command ScriptCommand_PrintTextString + tx Text043a + run_command ScriptCommand_JumpIfPlayerCoordMatches + db $12 + db $0a + dw .ows_e1fe + run_command ScriptCommand_JumpIfPlayerCoordMatches + db $14 + db $0a + dw .ows_e202 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_e215 + run_command ScriptCommand_QuitScriptFully + +.ows_e1ec + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_e206 + run_command ScriptCommand_Jump + dw .ows_e1d5 +.ows_e1f2 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_e20b + run_command ScriptCommand_Jump + dw .ows_e1d5 +.ows_e1f8 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_e20f + run_command ScriptCommand_Jump + dw .ows_e1d5 +.ows_e1fe + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_e218 + run_command ScriptCommand_QuitScriptFully + +.ows_e202 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_e219 + run_command ScriptCommand_QuitScriptFully + +NPCMovement_e206: ; e206 (3:6206) + db NORTH + db WEST + db WEST + db SOUTH | NO_MOVE + db $ff + +NPCMovement_e20b: ; e20b (3:620b) + db NORTH + db WEST + db SOUTH | NO_MOVE + db $ff + +NPCMovement_e20f: ; e20f (3:620f) + db NORTH + db EAST + db SOUTH | NO_MOVE + db $ff + +NPCMovement_e213: ; e213 (3:6213) + db SOUTH + db $ff + +NPCMovement_e215: ; e215 (3:6215) + db WEST + db SOUTH | NO_MOVE + db $ff + +NPCMovement_e218: ; e218 (3:6218) + db EAST +; fallthrough + +NPCMovement_e219: ; e219 (3:6219) + db EAST + db SOUTH | NO_MOVE + db $ff + +Script_Joshua: ; e21c (3:621c) + start_script + run_command ScriptCommand_JumpIfFlagZero2 db EVENT_BEAT_AMANDA dw .sara_and_amanda_not_beaten - run_script OWScript_JumpIfFlagNotSet + run_command ScriptCommand_JumpIfFlagZero2 db EVENT_BEAT_SARA dw .sara_and_amanda_not_beaten - run_script OWScript_ScriptJump + run_command ScriptCommand_Jump dw .beat_sara_and_amanda .sara_and_amanda_not_beaten - run_script OWScript_CustomModifyEventFlags - db $33 ; offset on flagmod table - db $01 ; the control bit - run_script OWScript_PrintTextString + run_command ScriptCommand_SetFlagValue + db EVENT_JOSHUA_STATE + db JOSHUA_TALKED + run_command ScriptCommand_PrintTextString tx Text043b - run_script OWScript_EndScriptCloseText + run_command ScriptCommand_QuitScriptFully + .beat_sara_and_amanda - run_script OWScript_JumpIfFlagSet - db $33 - dw $623c - run_script OWScript_CustomModifyEventFlags - db $33 - db $01 - run_script OWScript_PrintTextString + run_command ScriptCommand_JumpIfFlagNonzero1 + db EVENT_JOSHUA_STATE + dw .already_talked + run_command ScriptCommand_SetFlagValue + db EVENT_JOSHUA_STATE + db JOSHUA_TALKED + run_command ScriptCommand_PrintTextString tx Text043b - run_script OWScript_PrintTextString + run_command ScriptCommand_PrintTextString tx Text043c - run_script Func_d484 - db $33 - db $01 +.already_talked + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_JOSHUA_STATE + db JOSHUA_TALKED + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text043d + tx Text043e + run_command ScriptCommand_AskQuestionJump + tx Text043f + dw .startDuel + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_JOSHUA_STATE + db JOSHUA_TALKED + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text0440 + tx Text0441 + run_command ScriptCommand_QuitScriptFully + +.startDuel: + run_command ScriptCommand_PrintTextString + tx Text0442 + run_command ScriptCommand_TryGivePCPack + db $04 + run_command ScriptCommand_StartBattle + db PRIZES_4 + db SOUND_OF_THE_WAVES_DECK_ID + db MUSIC_DUEL_THEME_1 + run_command ScriptCommand_QuitScriptFully + +Script_LostToJoshua: ; e260 (3:6260) + start_script + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_JOSHUA_STATE + db JOSHUA_TALKED + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text0443 + tx Text0444 + run_command ScriptCommand_QuitScriptFully + +Script_BeatJoshua: ; e26c (3:626c) + start_script + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_JOSHUA_STATE + db JOSHUA_TALKED + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text0445 + tx Text0446 + run_command ScriptCommand_GiveBoosterPacks + db BOOSTER_MYSTERY_WATER_COLORLESS + db BOOSTER_MYSTERY_WATER_COLORLESS + db NO_BOOSTER + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_JOSHUA_STATE + db JOSHUA_TALKED + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text0447 + tx Text0448 + run_command ScriptCommand_JumpIfFlagNotEqual + db EVENT_JOSHUA_STATE + db JOSHUA_BEATEN + dw .firstJoshuaWin + run_command ScriptCommand_QuitScriptFully + +.firstJoshuaWin: + run_command ScriptCommand_SetFlagValue + db EVENT_JOSHUA_STATE + db JOSHUA_BEATEN + run_command ScriptCommand_PrintTextString + tx Text0449 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPCByDirection + dw NPCMovementTable_e2a1 + run_command ScriptCommand_PrintTextString + tx Text044a + run_command Func_cfc6 + db $00 + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript + db NPC_AMY + dw Script_MeetAmy + run_command ScriptCommand_EndScriptLoop1 + ret + +NPCMovementTable_e2a1: ; e2a1 (3:62a1) + dw NPCMovement_e2a9 + dw NPCMovement_e2a9 + dw NPCMovement_e2a9 + dw NPCMovement_e2a9 - INCROM $e23f, $e52c +NPCMovement_e2a9: ; e2a9 (3:62a9) + db NORTH + db $ff + +NPCMovement_e2ab: ; e2ab (3:62ab) + db SOUTH + db $ff + +Preload_Amy: ; e2ad (3:62ad) + xor a + ld [wd3d0], a + ld a, [wd0c2] + or a + jr z, .asm_e2cf + ld a, [wPlayerXCoord] + cp $14 + jr nz, .asm_e2cf + ld a, [wPlayerYCoord] + cp $06 + jr nz, .asm_e2cf + ld a, $14 + ld [wLoadNPCXPos], a + ld a, $01 + ld [wd3d0], a +.asm_e2cf + scf + ret + +Script_MeetAmy: ; e2d1 (3:62d1) + start_script + run_command ScriptCommand_PrintTextString + tx Text044b + run_command ScriptCommand_SetDialogName + db NPC_JOSHUA + run_command ScriptCommand_PrintTextString + tx Text044c + run_command ScriptCommand_SetDialogName + db NPC_AMY + run_command ScriptCommand_PrintTextString + tx Text044d + run_command ScriptCommand_CloseTextBox + run_command Func_d095 + db $09 + db $2f + db $10 + run_command ScriptCommand_DoFrames + db $20 + run_command Func_d095 + db $04 + db $0e + db $00 + run_command Func_d0be + db $14 + db $04 + run_command ScriptCommand_SetPlayerDirection + db $03 + run_command ScriptCommand_MovePlayer + db WEST + db $01 + run_command ScriptCommand_SetPlayerDirection + db $00 + run_command ScriptCommand_MovePlayer + db NORTH + db $01 + run_command ScriptCommand_MovePlayer + db NORTH + db $01 + run_command ScriptCommand_MoveArbitraryNPC + db NPC_JOSHUA + dw NPCMovement_e2ab + run_command ScriptCommand_PrintTextString + tx Text044e + run_command ScriptCommand_Jump + dw Script_Amy.askConfirmDuel + +Script_Amy: ; e304 (3:6304) + start_script + run_command ScriptCommand_JumpIfFlagNonzero2 + db EVENT_BEAT_AMY + dw ScriptJump_TalkToAmyAgain + run_command ScriptCommand_PrintTextString + tx Text044f +.askConfirmDuel + run_command ScriptCommand_AskQuestionJump + tx Text0450 + dw .startDuel + +.denyDuel + run_command ScriptCommand_PrintTextString + tx Text0451 + run_command Func_d0d9 + db $14 + db $04 + dw Script_LostToAmy.ows_e34e + run_command ScriptCommand_QuitScriptFully + +.startDuel + run_command ScriptCommand_PrintTextString + tx Text0452 + run_command ScriptCommand_StartBattle + db PRIZES_6 + db GO_GO_RAIN_DANCE_DECK_ID + db MUSIC_DUEL_THEME_2 + run_command ScriptCommand_QuitScriptFully + +Script_BeatAmy: ; e322 (3:6322) + start_script + run_command ScriptCommand_PrintTextString + tx Text0453 + run_command ScriptCommand_JumpIfFlagNonzero2 + db EVENT_BEAT_AMY + dw .beatAmyCommon + run_command ScriptCommand_PrintTextString + tx Text0454 + run_command ScriptCommand_MaxOutFlagValue + db EVENT_BEAT_AMY + run_command ScriptCommand_TryGiveMedalPCPacks + run_command Func_d125 + db EVENT_BEAT_AMY + run_command Func_d435 + db $03 + run_command ScriptCommand_PrintTextString + tx Text0455 +.beatAmyCommon + run_command ScriptCommand_GiveBoosterPacks + db BOOSTER_LABORATORY_WATER + db BOOSTER_LABORATORY_WATER + db NO_BOOSTER + run_command ScriptCommand_PrintTextString + tx Text0456 + run_command Func_d0d9 + db $14 + db $04 + dw Script_LostToAmy.ows_e34e + run_command ScriptCommand_QuitScriptFully + +Script_LostToAmy: ; e344 (3:6344) + start_script + run_command ScriptCommand_PrintTextString + tx Text0457 + run_command Func_d0d9 + db $14 + db $04 + dw .ows_e34e + run_command ScriptCommand_QuitScriptFully + +.ows_e34e + run_command Func_d095 + db $08 + db $2e + db $10 + run_command Func_d0be + db $16 + db $04 + run_command ScriptCommand_QuitScriptFully + +ScriptJump_TalkToAmyAgain: ; e356 (3:6356) + run_command ScriptCommand_PrintTextString + tx Text0458 + run_command ScriptCommand_AskQuestionJump + tx Text0450 + dw .startDuel + run_command ScriptCommand_Jump + dw Script_Amy.denyDuel + +.startDuel + run_command ScriptCommand_PrintTextString + tx Text0459 + run_command ScriptCommand_StartBattle + db PRIZES_6 + db GO_GO_RAIN_DANCE_DECK_ID + db MUSIC_DUEL_THEME_2 + run_command ScriptCommand_QuitScriptFully +; 0xe369 + + INCROM $e369, $e525 + +GrassClubEntranceAfterDuel: ; e525 (3:6525) + ld hl, GrassClubEntranceAfterDuelTable + call FindEndOfBattleScript + ret FindEndOfBattleScript: ; e52c (3:652c) ld c, $0 @@ -3138,24 +4554,1693 @@ FindEndOfBattleScript: ; e52c (3:652c) .found_enemy ld a, [hli] - ld [wd3ab], a + ld [wTempNPC], a ld b, $0 add hl, bc ld c, [hl] inc hl ld b, [hl] - jp Func_c926 + jp SetNextNPCAndScript ; 0xe553 - INCROM $e553, $f580 +GrassClubEntranceAfterDuelTable: ; e553 (3:6553) + db NPC_MICHAEL + db NPC_MICHAEL + dw $6597 + dw $65ab + + db NPC_RONALD2 + db NPC_RONALD2 + dw Script_BeatFirstRonaldFight + dw Script_LostToFirstRonaldFight + + db NPC_RONALD3 + db NPC_RONALD3 + dw Script_BeatSecondRonaldFight + dw Script_LostToSecondRonaldFight + db $00 + + INCROM $e566, $e5c4 + +GrassClubLobbyAfterDuel: ; e5c4 (3:65c4) + ld hl, .after_duel_table + call FindEndOfBattleScript + ret + +.after_duel_table + db NPC_BRITTANY + db NPC_BRITTANY + dw Script_BeatBrittany + dw Script_LostToBrittany + db $00 + +Script_Brittany: ; e5d2 (3:65d2) + start_script + run_command ScriptCommand_JumpIfFlagLessThan + db EVENT_FLAG_35 + db $01 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text06e0 + tx Text06e1 + run_command ScriptCommand_AskQuestionJump + tx Text06e2 + dw .wantToDuel + run_command ScriptCommand_PrintTextString + tx Text06e3 + run_command ScriptCommand_QuitScriptFully + +.wantToDuel + run_command ScriptCommand_PrintTextString + tx Text06e4 + run_command ScriptCommand_StartBattle + db PRIZES_4 + db ETCETERA_DECK_ID + db MUSIC_DUEL_THEME_1 + run_command ScriptCommand_QuitScriptFully + +Script_BeatBrittany: ; e5ee (3:65ee) + start_script + run_command ScriptCommand_PrintTextString + tx Text06e5 + run_command ScriptCommand_GiveBoosterPacks + db BOOSTER_MYSTERY_GRASS_COLORLESS + db BOOSTER_MYSTERY_GRASS_COLORLESS + db NO_BOOSTER + run_command ScriptCommand_JumpIfFlagLessThan + db EVENT_FLAG_35 + db $02 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text06e6 + tx Text06e7 + run_command ScriptCommand_MaxOutFlagValue + db FLAG_BEAT_BRITTANY + run_command ScriptCommand_JumpIfFlagNotLessThan + db EVENT_FLAG_35 + db $02 + dw .finishSequence + run_command ScriptCommand_JumpIfFlagZero2 + db EVENT_FLAG_3A + dw .finishSequence + run_command ScriptCommand_JumpIfFlagZero2 + db EVENT_FLAG_3B + dw .finishSequence + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_35 + db $01 + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_1E + run_command ScriptCommand_PrintTextString + tx Text06e8 +.finishSequence + run_command ScriptCommand_QuitScriptFully + +Script_LostToBrittany: ; e618 (3:6618) + start_script + run_command ScriptCommand_PrintTextQuitFully + tx Text06e9 +; 0xe61c + +Script_e61c: ; e61c (3:661c) + run_command ScriptCommand_PrintTextQuitFully + tx Text06ea + +Script_e61f: ; e61f (3:661f) + start_script + run_command ScriptCommand_JumpIfFlagNonzero2 + db EVENT_FLAG_04 + dw Script_e61c + run_command ScriptCommand_JumpIfFlagNotLessThan + db EVENT_FLAG_37 + db $06 + dw Script_e61c + run_command ScriptCommand_JumpIfFlagNotLessThan + db EVENT_FLAG_37 + db $04 + dw .ows_e6a1 + run_command ScriptCommand_JumpIfFlagNotLessThan + db EVENT_FLAG_37 + db $02 + dw .ows_e66a + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_37 + db $00 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text06eb + tx Text06ec + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_37 + db $01 + run_command ScriptCommand_AskQuestionJump + tx Text06ed + dw .ows_e648 + run_command ScriptCommand_PrintTextQuitFully + tx Text06ee + +.ows_e648 + run_command Func_cf0c + db $1c + dw .ows_e64f + run_command ScriptCommand_PrintTextQuitFully + tx Text06ef + +.ows_e64f + run_command Func_cf12 + db $1c + dw .ows_e656 + run_command ScriptCommand_PrintTextQuitFully + tx Text06f0 + +.ows_e656 + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_04 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_37 + db $02 + run_command ScriptCommand_PrintTextString + tx Text06f1 + run_command Func_ccdc + tx Text06f2 + run_command ScriptCommand_TakeCard + db ODDISH + run_command ScriptCommand_GiveCard + db VILEPLUME + run_command ScriptCommand_ShowCardReceivedScreen + db VILEPLUME + run_command ScriptCommand_PrintTextQuitFully + tx Text06f3 + +.ows_e66a + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_37 + db $02 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text06f4 + tx Text06f5 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_37 + db $03 + run_command ScriptCommand_AskQuestionJump + tx Text06ed + dw .ows_e67f + run_command ScriptCommand_PrintTextQuitFully + tx Text06f6 + +.ows_e67f + run_command Func_cf0c + db $ab + dw .ows_e686 + run_command ScriptCommand_PrintTextQuitFully + tx Text06f7 + +.ows_e686 + run_command Func_cf12 + db $ab + dw .ows_e68d + run_command ScriptCommand_PrintTextQuitFully + tx Text06f8 + +.ows_e68d + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_04 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_37 + db $04 + run_command ScriptCommand_PrintTextString + tx Text06f9 + run_command Func_ccdc + tx Text06fa + run_command ScriptCommand_TakeCard + db CLEFAIRY + run_command ScriptCommand_GiveCard + db PIKACHU3 + run_command ScriptCommand_ShowCardReceivedScreen + db PIKACHU3 + run_command ScriptCommand_PrintTextQuitFully + tx Text06f3 + +.ows_e6a1 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_37 + db $04 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text06fb + tx Text06fc + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_37 + db $05 + run_command ScriptCommand_AskQuestionJump + tx Text06ed + dw .ows_e6b6 + run_command ScriptCommand_PrintTextQuitFully + tx Text06fd + +.ows_e6b6 + run_command Func_cf0c + db $32 + dw .ows_e6bd + run_command ScriptCommand_PrintTextQuitFully + tx Text06fe + +.ows_e6bd + run_command Func_cf12 + db $32 + dw .ows_e6c4 + run_command ScriptCommand_PrintTextQuitFully + tx Text06ff + +.ows_e6c4 + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_04 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_37 + db $06 + run_command ScriptCommand_PrintTextString + tx Text0700 + run_command Func_ccdc + tx Text0701 + run_command ScriptCommand_TakeCard + db CHARIZARD + run_command ScriptCommand_GiveCard + db BLASTOISE + run_command ScriptCommand_ShowCardReceivedScreen + db BLASTOISE + run_command ScriptCommand_PrintTextQuitFully + tx Text06f3 +; 0xe6d8 + + INCROM $e6d8, $e7f6 + +ClubEntranceAfterDuel: ; e7f6 (3:67f6) + ld hl, .after_duel_table + jp FindEndOfBattleScript + +.after_duel_table + db NPC_RONALD2 + db NPC_RONALD2 + dw Script_BeatFirstRonaldFight + dw Script_LostToFirstRonaldFight + + db NPC_RONALD3 + db NPC_RONALD3 + dw Script_BeatSecondRonaldFight + dw Script_LostToSecondRonaldFight + db $00 + +; A Ronald is already loaded or not loaded depending on Pre-Load scripts +; in data/npc_map_data.asm. This just starts a sequence if possible. +LoadClubEntrance: ; e809 (3:6809) + call TryFirstRonaldFight + call TrySecondRonaldFight + call TryFirstRonaldEncounter + ret + +TryFirstRonaldEncounter: ; e813 (3:6813) + ld a, NPC_RONALD1 + ld [wTempNPC], a + call FindLoadedNPC + ret c + ld bc, Script_FirstRonaldEncounter + jp SetNextNPCAndScript + +TryFirstRonaldFight: ; e822 (3:6822) + ld a, NPC_RONALD2 + ld [$d3ab], a + call FindLoadedNPC + ret c + get_flag_value EVENT_FLAG_4C + or a + ret nz + ld bc, Script_FirstRonaldFight + jp SetNextNPCAndScript + +TrySecondRonaldFight: ; e837 (3:6837) + ld a, NPC_RONALD3 + ld [$d3ab], a + call FindLoadedNPC + ret c + get_flag_value EVENT_FLAG_4D + or a + ret nz + ld bc, ScriptSecondRonaldFight + jp SetNextNPCAndScript +; 0xe84c + + INCROM $e84c, $e862 + +Script_FirstRonaldEncounter: ; e862 (3:6862) + start_script + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_4B + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_e894 + run_command Func_d135 + db $00 + run_command ScriptCommand_PrintTextString + tx Text0645 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MovePlayer + db NORTH + db $01 + run_command ScriptCommand_MovePlayer + db NORTH + db $01 + run_command ScriptCommand_PrintTextString + tx Text0646 + run_command ScriptCommand_AskQuestionJumpDefaultYes + dw 0000 + dw .ows_e882 + run_command ScriptCommand_PrintTextString + tx Text0647 + run_command ScriptCommand_Jump + dw .ows_e885 + +.ows_e882 + run_command ScriptCommand_PrintTextString + tx Text0648 +.ows_e885 + run_command ScriptCommand_PrintTextString + tx Text0649 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_SetPlayerDirection + db $03 + run_command ScriptCommand_MovePlayer + db EAST + db $04 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_e894 + run_command Func_cdcb + run_command Func_d41d + run_command ScriptCommand_QuitScriptFully + +NPCMovement_e894: ; e894 (3:6894) + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db $ff +; e89a + + INCROM $e89a, $e8c0 + +Script_FirstRonaldFight: ; e8c0 (3:68c0) + start_script + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_e905 + run_command ScriptCommand_DoFrames + db $3c + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_e90d + run_command ScriptCommand_PrintTextString + tx Text064a + run_command ScriptCommand_JumpIfPlayerCoordMatches + db $08 + db $02 + dw $68d6 + run_command ScriptCommand_SetPlayerDirection + db WEST + run_command ScriptCommand_MovePlayer + db WEST + db $01 + run_command ScriptCommand_SetPlayerDirection + db SOUTH + run_command ScriptCommand_MovePlayer + db SOUTH + db $01 + run_command ScriptCommand_MovePlayer + db SOUTH + db $01 + run_command ScriptCommand_PrintTextString + tx Text064b + run_command ScriptCommand_SetFlagValue + db $4c + db $01 + run_command ScriptCommand_StartBattle + db PRIZES_6 + db IM_RONALD_DECK_ID + db MUSIC_RONALD + run_command ScriptCommand_QuitScriptFully + +Script_BeatFirstRonaldFight: ; e8e9 (3:68e9) + start_script + run_command ScriptCommand_PrintTextString + tx Text064c + run_command ScriptCommand_GiveCard + db JIGGLYPUFF1 + run_command ScriptCommand_ShowCardReceivedScreen + db JIGGLYPUFF1 + run_command ScriptCommand_PrintTextString + tx Text064d + run_command ScriptCommand_Jump + dw ScriptJump_FinishedFirstRonaldFight + +Script_LostToFirstRonaldFight: ; e8f7 (3:68f7) + start_script + run_command ScriptCommand_PrintTextString + tx Text064e + +ScriptJump_FinishedFirstRonaldFight + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_4C + db $02 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_e90f + run_command Func_cdcb + run_command Func_d41d + run_command ScriptCommand_QuitScriptFully + +NPCMovement_e905: ; e905 (3:6905) + db EAST + db EAST + db EAST + db EAST + db EAST + db SOUTH + db NORTH | NO_MOVE + db $ff + +NPCMovement_e90d: ; e90d (3:690d) + db NORTH + db $ff + +NPCMovement_e90f: ; e90f (3:690f) + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db $ff +; e915 + + INCROM $e915, $e91e + +ScriptSecondRonaldFight: ; e91e (3:691e) + start_script + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_e905 + run_command ScriptCommand_DoFrames + db 60 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_e90d + run_command ScriptCommand_PrintTextString + tx Text064f + run_command ScriptCommand_JumpIfPlayerCoordMatches + db $08 + db $02 + dw .ows_6934 + run_command ScriptCommand_SetPlayerDirection + db WEST + run_command ScriptCommand_MovePlayer + db WEST + db $01 +.ows_6934 + run_command ScriptCommand_SetPlayerDirection + db SOUTH + run_command ScriptCommand_MovePlayer + db SOUTH + db $01 + run_command ScriptCommand_MovePlayer + db SOUTH + db $01 + run_command ScriptCommand_PrintTextString + tx Text0650 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_4D + db $01 + run_command ScriptCommand_StartBattle + db PRIZES_6 + db POWERFUL_RONALD_DECK_ID + db MUSIC_RONALD + run_command ScriptCommand_QuitScriptFully + +Script_BeatSecondRonaldFight: ; e947 (3:6947) + start_script + run_command ScriptCommand_PrintTextString + tx Text0651 + run_command ScriptCommand_GiveCard + db SUPER_ENERGY_RETRIEVAL + run_command ScriptCommand_ShowCardReceivedScreen + db SUPER_ENERGY_RETRIEVAL + run_command ScriptCommand_PrintTextString + tx Text0652 + run_command ScriptCommand_Jump + dw ScriptJump_FinishedSecondRonaldFight + +Script_LostToSecondRonaldFight: ; e955 (3:6955) + start_script + run_command ScriptCommand_PrintTextString + tx Text0653 + +ScriptJump_FinishedSecondRonaldFight ; e959 (3:6959) + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_4D + db $02 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_e90f + run_command Func_cdcb + run_command Func_d41d + run_command ScriptCommand_QuitScriptFully +; 0xe963 + + INCROM $e963, $ed57 + +FireClubPressedA: ; ed57 (3:6d57) + ld hl, SlowpokePaintingObjectTable + call FindExtraInteractableObjects + ret + +SlowpokePaintingObjectTable: ; ed5e (3:6d5e) + db 16, 2, NORTH + dw Script_ee76 + db $00 + +; Given a table with data of the form: +; X, Y, Dir, Script +; Searches to try to find a match, and starts a Script if possible +FindExtraInteractableObjects: ; ed64 (3:6d64) + ld de, $5 +.findObjectMatchLoop + ld a, [hl] + or a + ret z + push hl + ld a, [wPlayerXCoord] + cp [hl] + jr nz, .didNotMatch + inc hl + ld a, [wPlayerYCoord] + cp [hl] + jr nz, .didNotMatch + inc hl + ld a, [wPlayerDirection] + cp [hl] + jr z, .foundObject +.didNotMatch + pop hl + add hl, de + jr .findObjectMatchLoop +.foundObject + inc hl + ld c, [hl] + inc hl + ld b, [hl] + pop hl + call SetNextScript + scf + ret +; 0xed8d + + INCROM $ed8d, $ee76 + +Script_ee76: ; ee76 (3:6e76) + start_script + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_21 + db $01 + dw .ows_ee7d + run_command ScriptCommand_QuitScriptFully + +.ows_ee7d + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_21 + db $02 + run_command Func_ccdc + tx Text06a2 + run_command ScriptCommand_GiveCard + db SLOWPOKE1 + run_command ScriptCommand_ShowCardReceivedScreen + db SLOWPOKE1 + run_command ScriptCommand_QuitScriptFully +; 0xee88 + + INCROM $ee88, $ef96 + +Preload_Clerk9: ; ef96 (3:6f96) + call TryGiveMedalPCPacks + get_flag_value EVENT_MEDAL_COUNT + ld hl, .jumpTable + cp $09 + jp c, JumpToFunctionInTable + debug_ret + jr .asm_efe4 + +.jumpTable + dw .asm_efe4 + dw .asm_efe4 + dw .asm_efe4 + dw .asm_efba + dw .asm_efde + dw .asm_efc9 + dw .asm_efd8 + dw .asm_efd8 + dw .asm_efd8 + +.asm_efba + get_flag_value EVENT_FLAG_3F + or a + jr nz, .asm_efe4 + ld c, $01 + set_flag_value EVENT_FLAG_3F + jr .asm_efe4 + +.asm_efc9 + get_flag_value EVENT_FLAG_40 + or a + jr nz, .asm_efde + ld c, $01 + set_flag_value EVENT_FLAG_40 + jr .asm_efde + +.asm_efd8 + ld c, $07 + set_flag_value EVENT_FLAG_40 +.asm_efde + ld c, $07 + set_flag_value EVENT_FLAG_3F +.asm_efe4 + zero_flag_value EVENT_FLAG_42 + get_flag_value EVENT_FLAG_3F + cp $00 + jr z, .asm_eff8 + cp $07 + jr z, .asm_eff8 + ld c, $01 + jr .asm_f016 + +.asm_eff8 + get_flag_value EVENT_FLAG_40 + cp $00 + jr z, .asm_f008 + cp $07 + jr z, .asm_f008 + ld c, $02 + jr .asm_f016 + +.asm_f008 + get_flag_value EVENT_FLAG_41 + cp $00 + jr z, .asm_f023 + cp $07 + jr z, .asm_f023 + ld c, $03 +.asm_f016 + set_flag_value EVENT_FLAG_44 + max_flag_value EVENT_FLAG_42 + ld a, $0b + ld [wd111], a +.asm_f023 + scf + ret + +Script_Clerk9: ; f025 (3:7025) + start_script + run_command ScriptCommand_JumpIfFlagZero1 + db EVENT_FLAG_3F + dw .ows_f066 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_41 + db $07 + dw .ows_f069 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_41 + db $03 + dw .ows_f06f + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_41 + db $02 + dw .ows_f072 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_41 + db $01 + dw .ows_f06c + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_40 + db $07 + dw .ows_f069 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_40 + db $03 + dw .ows_f06f + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_40 + db $02 + dw .ows_f072 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_40 + db $01 + dw .ows_f06c + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_3F + db $07 + dw .ows_f069 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_3F + db $03 + dw .ows_f06f + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_3F + db $02 + dw .ows_f072 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_3F + db $01 + dw .ows_f06c +.ows_f066 + run_command ScriptCommand_PrintTextQuitFully + tx Text050a + +.ows_f069 + run_command ScriptCommand_PrintTextQuitFully + tx Text050b + +.ows_f06c + run_command ScriptCommand_PrintTextQuitFully + tx Text050c + +.ows_f06f + run_command ScriptCommand_PrintTextQuitFully + tx Text050d + +.ows_f072 + run_command ScriptCommand_PrintTextQuitFully + tx Text050e + +Preload_ChallengeHallNPCs2: ; f075 (3:7075) + call Preload_ChallengeHallNPCs1 + ccf + ret + +Preload_ChallengeHallNPCs1: ; f07a (3:707a) + get_flag_value EVENT_FLAG_42 + or a + jr z, .quit + ld a, $0b + ld [wd111], a + scf +.quit + ret + +ChallengeHallLobbyLoadMap: ; f088 (3:7088) + get_flag_value EVENT_FLAG_58 + or a + ret z + ld a, $02 + ld [wTempNPC], a + call FindLoadedNPC + ld bc, $7166 + jp SetNextNPCAndScript + +Script_Pappy3: ; f09c (3:709c) + start_script + run_command ScriptCommand_PrintTextQuitFully + tx Text050f + +Script_Gal4: ; f0a0 (3:70a0) + start_script + run_command ScriptCommand_PrintTextQuitFully + tx Text0510 + +Script_Champ: ; f0a4 (3:70a4) + start_script + run_command ScriptCommand_PrintTextQuitFully + tx Text0511 + +Script_Hood2: ; f0a8 (3:70a8) + start_script + run_command ScriptCommand_PrintTextQuitFully + tx Text0512 + +Script_Lass5: ; f0ac (3:70ac) + start_script + run_command ScriptCommand_PrintTextQuitFully + tx Text0513 + +Script_Chap5: ; f0b0 (3:70b0) + start_script + run_command ScriptCommand_PrintTextQuitFully + tx Text0514 + +Preload_ChallengeHallLobbyRonald1: ; f0b4 (3:70b4) + zero_flag_value2 EVENT_FLAG_58 + get_flag_value EVENT_RECEIVED_LEGENDARY_CARD + or a + jr nz, .asm_f0ff + get_flag_value EVENT_FLAG_59 + or a + jr nz, .asm_f11f + get_flag_value EVENT_FLAG_40 + cp $00 + jr z, .asm_f0e5 + call .asm_710f + get_flag_value EVENT_FLAG_40 + ld e, a + get_flag_value EVENT_FLAG_49 + ld d, a + ld hl, Unknown_f156 + call Func_f121 + jr nc, .asm_f11f + jr .asm_f0f7 +.asm_f0e5 + get_flag_value EVENT_FLAG_3F + ld e, a + get_flag_value EVENT_FLAG_48 + ld d, a + ld hl, Unknown_f146 + call Func_f121 + jr nc, .asm_f11f +.asm_f0f7 + ld a, [wPlayerYCoord] + ld [wLoadNPCYPos], a + scf + ret +.asm_f0ff + max_flag_value EVENT_FLAG_54 + max_flag_value EVENT_FLAG_55 + max_flag_value EVENT_FLAG_56 + max_flag_value EVENT_FLAG_57 +.asm_710f + max_flag_value EVENT_FLAG_50 + max_flag_value EVENT_FLAG_51 + max_flag_value EVENT_FLAG_52 + max_flag_value EVENT_FLAG_53 +.asm_f11f + or a + ret + +Func_f121: ; f121 (3:7121) + ld c, $04 +.asm_f123 + ld a, [hli] + cp e + jr nz, .asm_f13e + ld a, [hli] + cp d + jr nz, .asm_f13f + ld a, [hl] + call GetEventFlagValue + or a + jr nz, .asm_f13f + ld a, [hl] + call MaxOutEventFlag + inc hl + ld c, [hl] + set_flag_value EVENT_FLAG_58 + scf + ret +.asm_f13e + inc hl +.asm_f13f + inc hl + inc hl + dec c + jr nz, .asm_f123 + or a + ret +; 0xf146 + +Unknown_f146: ; f146 (3:7146) + INCROM $f146, $f156 + +Unknown_f156: ; f156 (3:7156) + INCROM $f156, $f239 + +ChallengeHallAfterDuel: ; f239 (3:7239) + ld c, $00 + ld a, [wDuelResult] + or a + jr z, .won + ld c, $02 +.won + ld b, $00 + ld hl, ChallengeHallAfterDuelTable + add hl, bc + ld c, [hl] + inc hl + ld b, [hl] + ld a, NPC_HOST + ld [wTempNPC], a + jp SetNextNPCAndScript + +ChallengeHallAfterDuelTable: + dw WonAtChallengeHall + dw LostAtChallengeHall + +ChallengeHallLoadMap: ; f258 (3:7258) + get_flag_value EVENT_FLAG_47 + or a + ret z + ld a, NPC_HOST + ld [wTempNPC], a + call FindLoadedNPC + ld bc, Script_f433 + jp SetNextNPCAndScript + +Script_Clerk13: ; f26c (3:726c) + start_script + run_command ScriptCommand_PrintTextQuitFully + tx Text0525 + +Preload_Guide: ; f270 (3:7270) + get_flag_value EVENT_FLAG_42 + or a + jr z, .asm_f281 + ld a, $1c + ld [wLoadNPCXPos], a + ld a, $02 + ld [wLoadNPCYPos], a +.asm_f281 + scf + ret +; 0xf283 + +Script_Guide: ; f283 (3:7283) + start_script + run_command ScriptCommand_JumpIfFlagZero2 + db EVENT_FLAG_42 + dw .ows_f28b + run_command ScriptCommand_PrintTextQuitFully + tx Text0526 + +.ows_f28b + run_command ScriptCommand_JumpIfFlagZero1 + db $3f + dw .ows_f292 + run_command ScriptCommand_PrintTextQuitFully + tx Text0527 + +.ows_f292 + run_command ScriptCommand_PrintTextQuitFully + tx Text0528 + +Script_Clerk12: ; f295 (3:7295) + start_script + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_41 + db $03 + dw .ows_f2c4 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_41 + db $02 + dw .ows_f2c1 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_40 + db $03 + dw .ows_f2c4 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_40 + db $02 + dw .ows_f2c1 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_3F + db $03 + dw .ows_f2c4 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_3F + db $02 + dw .ows_f2c1 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_44 + db $02 + dw .ows_f2cd + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_44 + db $03 + dw .ows_f2d3 + run_command ScriptCommand_Jump + dw .ows_f2c7 + +.ows_f2c1 + run_command ScriptCommand_PrintTextQuitFully + tx Text0529 + +.ows_f2c4 + run_command ScriptCommand_PrintTextQuitFully + tx Text052a + +.ows_f2c7 + run_command ScriptCommand_PrintTextString + tx Text052b + run_command ScriptCommand_Jump + dw .ows_f2d6 + +.ows_f2cd + run_command ScriptCommand_PrintTextString + tx Text052c + run_command ScriptCommand_Jump + dw .ows_f2d6 + +.ows_f2d3 + run_command ScriptCommand_PrintTextString + tx Text052d +.ows_f2d6 + run_command ScriptCommand_PrintTextString + tx Text052e + run_command ScriptCommand_AskQuestionJump + tx Text052f + dw .ows_f2e1 + run_command ScriptCommand_PrintTextQuitFully + tx Text0530 + +.ows_f2e1 + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_59 + run_command ScriptCommand_PrintTextString + tx Text0531 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f349 + run_command ScriptCommand_JumpIfPlayerCoordMatches + db 8 + db 18 + dw .ows_f2fa + run_command ScriptCommand_JumpIfPlayerCoordMatches + db 12 + db 18 + dw .ows_f302 + run_command ScriptCommand_MovePlayer + db NORTH + db $02 + run_command ScriptCommand_Jump + dw .ows_f307 + +.ows_f2fa + run_command ScriptCommand_SetPlayerDirection + db EAST + run_command ScriptCommand_MovePlayer + db EAST + db $02 + run_command ScriptCommand_Jump + dw .ows_f307 + +.ows_f302 + run_command ScriptCommand_SetPlayerDirection + db WEST + run_command ScriptCommand_MovePlayer + db WEST + db $02 +.ows_f307 + run_command ScriptCommand_SetPlayerDirection + db NORTH + run_command ScriptCommand_MovePlayer + db NORTH + db $01 + run_command ScriptCommand_MovePlayer + db NORTH + db $01 + run_command ScriptCommand_MovePlayer + db NORTH + db $01 + run_command ScriptCommand_MovePlayer + db NORTH + db $01 + run_command ScriptCommand_MovePlayer + db NORTH + db $01 + run_command ScriptCommand_JumpIfFlagNonzero2 + db EVENT_FLAG_43 + dw .ows_f33a + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_43 + run_command ScriptCommand_MovePlayer + db NORTH + db $01 + run_command ScriptCommand_MovePlayer + db NORTH + db $01 + run_command ScriptCommand_SetPlayerDirection + db EAST + run_command ScriptCommand_DoFrames + db 30 + run_command ScriptCommand_SetPlayerDirection + db SOUTH + run_command ScriptCommand_DoFrames + db 20 + run_command ScriptCommand_SetPlayerDirection + db EAST + run_command ScriptCommand_DoFrames + db 20 + run_command ScriptCommand_SetPlayerDirection + db SOUTH + run_command ScriptCommand_DoFrames + db 30 + run_command ScriptCommand_MovePlayer + db SOUTH + db $01 + run_command ScriptCommand_MovePlayer + db SOUTH + db $01 +.ows_f33a + run_command ScriptCommand_SetPlayerDirection + db EAST + run_command ScriptCommand_MovePlayer + db EAST + db $01 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f34e + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript + db $4a + dw Script_f353 + run_command ScriptCommand_EndScriptLoop1 + ret +; f349 + +NPCMovement_f349: ; f349 (3:7349) + db NORTH + db NORTH + db EAST +; fallthrough + +NPCMovement_f34c: ; f34c (3:734c) + db WEST | NO_MOVE + db $ff + +NPCMovement_f34e: ; f34e (3:734e) + db WEST + db SOUTH + db SOUTH + db $ff + +Script_HostStubbed: ; f352 (3:7352) + ret + +Script_f353: ; f353 (3:7353) + start_script + run_command ScriptCommand_DoFrames + db 20 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f37d + run_command ScriptCommand_DoFrames + db 20 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f390 + run_command Func_d16b + db $00 + run_command ScriptCommand_PrintTextString + tx Text0532 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f37f + run_command ScriptCommand_PrintTextString + tx Text0533 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f388 + run_command ScriptCommand_PrintTextString + tx Text0534 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f38e + run_command ScriptCommand_PrintTextString + tx Text0535 + run_command Func_cd4f + db $04 + db $00 + db $00 + run_command ScriptCommand_QuitScriptFully + +NPCMovement_f37d: ; f37d (3:737d) + db EAST | NO_MOVE + db $ff + +NPCMovement_f37f: ; f37f (3:737f) + db EAST + db EAST + db SOUTH + db $ff + +NPCMovement_f383: ; f383 (3:7383) + db NORTH + db WEST + db WEST + db SOUTH | NO_MOVE + db $ff + +NPCMovement_f388: ; f388 (3:7388) + db NORTH + db WEST + db WEST +; fallthrough + +NPCMovement_f38b: ; f38b (3:738b) + db WEST + db SOUTH + db $ff + +NPCMovement_f38e: ; f38e (3:738e) + db NORTH + db EAST +; fallthrough + +NPCMovement_f390: ; f390 (3:7390) + db SOUTH | NO_MOVE + db $ff + +LostAtChallengeHall: ; f392 (3:7392) + start_script + run_command ScriptCommand_DoFrames + db 20 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f37d + run_command ScriptCommand_DoFrames + db 20 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f390 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_45 + db $02 + dw ScriptJump_f410 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_45 + db $03 + dw ScriptJump_f410.ows_f41a + run_command Func_d16b + db $00 + run_command Func_d16b + db $01 + run_command ScriptCommand_PrintTextString + tx Text0536 +.ows_f3ae + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f38b + run_command ScriptCommand_PrintTextString + tx Text0537 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f38e + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_44 + db $02 + dw .ows_f3ce + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_44 + db $03 + dw .ows_f3d9 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_3F + db $03 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_48 + db $03 + run_command ScriptCommand_ZeroOutFlagValue + db EVENT_FLAG_51 + run_command ScriptCommand_Jump + dw .ows_f3e2 +.ows_f3ce + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_40 + db $03 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_49 + db $03 + run_command ScriptCommand_ZeroOutFlagValue + db EVENT_FLAG_55 + run_command ScriptCommand_Jump + dw .ows_f3e2 +.ows_f3d9 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_41 + db $03 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_4A + db $03 + run_command ScriptCommand_Jump + dw .ows_f3e2 +.ows_f3e2 + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript + db NPC_CLERK12 + dw Script_f3e9 + run_command ScriptCommand_EndScriptLoop1 + ret + +Script_f3e9: ; f3e9 (3:73e9) + start_script + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f40a + run_command ScriptCommand_SetPlayerDirection + db WEST + run_command ScriptCommand_MovePlayer + db WEST + db $01 + run_command ScriptCommand_SetPlayerDirection + db SOUTH + run_command ScriptCommand_MovePlayer + db SOUTH + db $01 + run_command ScriptCommand_MovePlayer + db SOUTH + db $01 + run_command ScriptCommand_MovePlayer + db SOUTH + db $01 + run_command ScriptCommand_MovePlayer + db SOUTH + db $01 + run_command ScriptCommand_MovePlayer + db SOUTH + db $01 + run_command ScriptCommand_MovePlayer + db SOUTH + db $01 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f40d + run_command ScriptCommand_QuitScriptFully + +NPCMovement_f40a: ; f40a (3:740a) + db WEST + db EAST | NO_MOVE + db $ff + +NPCMovement_f40d: ; f40d (3:740d) + db EAST + db SOUTH | NO_MOVE + db $ff + +ScriptJump_f410: ; f410 (4:7410) + run_command Func_d16b + db $00 + run_command Func_d16b + db $01 + run_command ScriptCommand_PrintTextString + tx Text0538 + run_command ScriptCommand_Jump + dw LostAtChallengeHall.ows_f3ae + +.ows_f41a + run_command ScriptCommand_PrintTextString + tx Text0539 + run_command ScriptCommand_SetDialogName + db NPC_RONALD1 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_44 + db $03 + dw .ows_f42e + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_44 + db $01 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text053a + tx Text053b +.ows_f42e + run_command ScriptCommand_SetDialogName + db NPC_HOST + run_command ScriptCommand_Jump + dw LostAtChallengeHall.ows_f3ae + +Script_f433: ; f433 (3:7433) + start_script + run_command ScriptCommand_DoFrames + db 20 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f37d + run_command ScriptCommand_DoFrames + db 20 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f390 + run_command ScriptCommand_Jump + dw WonAtChallengeHall.ows_f4a4 + +WonAtChallengeHall; f441 (3:7441) + start_script + run_command ScriptCommand_DoFrames + db 20 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f37d + run_command ScriptCommand_DoFrames + db 20 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f390 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_45 + db $03 + dw ScriptJump_f4db + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_45 + db $02 + dw .ows_f456 +.ows_f456 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_45 + db $01 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text053c + tx Text053d + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f37f + run_command Func_d16b + db $00 + run_command ScriptCommand_PrintTextString + tx Text053e + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveWramNPC + dw NPCMovement_f4c8 + run_command Func_cdd8 + run_command ScriptCommand_PrintTextString + tx Text053f + run_command ScriptCommand_CloseTextBox + run_command Func_d195 + run_command Func_cdf5 + db $14 + db $14 + run_command ScriptCommand_MoveWramNPC + dw NPCMovement_f4d0 + run_command Func_d16b + db $00 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_45 + db $02 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text0540 + tx Text0541 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f383 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_45 + db $02 + dw .ows_f4a4 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_44 + db $03 + dw .ows_f4a1 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_SetDialogName + db $02 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_44 + db $01 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text0542 + tx Text0543 + run_command ScriptCommand_SetDialogName + db NPC_HOST + run_command ScriptCommand_CloseTextBox +.ows_f4a1 + run_command ScriptCommand_PrintTextString + tx Text0544 +.ows_f4a4 + run_command ScriptCommand_ZeroOutFlagValue + db EVENT_FLAG_47 + run_command ScriptCommand_PrintTextString + tx Text0545 + run_command ScriptCommand_AskQuestionJumpDefaultYes + tx Text0546 + dw .ows_f4bd + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_45 + db $02 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text0547 + tx Text0548 + run_command Func_cd4f + db $04 + db $00 + db $00 + run_command ScriptCommand_QuitScriptFully +.ows_f4bd + run_command ScriptCommand_PrintTextString + tx Text0549 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MaxOutFlagValue + db EVENT_FLAG_47 + run_command Func_d1ad + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_Jump + dw .ows_f4a4 + +NPCMovement_f4c8: ; f4c8 (3:74c8) + db EAST +NPCMovement_f4c9: ; f4c9 (3:74c9) + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db SOUTH + db $ff + +NPCMovement_f4d0: ; f4d0 (3:74d0) + db NORTH + db NORTH + db NORTH + db NORTH + db NORTH + db NORTH + db WEST + db $ff + +NPCMovement_f4d8: ; f4d8 (3:74d8) + db EAST + db SOUTH | NO_MOVE + db $ff + +ScriptJump_f4db: ; f4db (3:74db) + run_command ScriptCommand_PrintTextString + tx Text054a + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f37f + run_command Func_d16b + db $00 + run_command ScriptCommand_PrintTextString + tx Text054b + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_44 + db $03 + dw .ows_f513 + run_command ScriptCommand_SetDialogName + db $02 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_44 + db $01 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text054c + tx Text054d + run_command ScriptCommand_MoveWramNPC + dw NPCMovement_f4d8 + run_command ScriptCommand_DoFrames + db 40 + run_command ScriptCommand_MoveWramNPC + dw NPCMovement_f34c + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_44 + db $01 + dw NO_JUMP + run_command ScriptCommand_PrintVariableText + tx Text054e + tx Text054f + run_command ScriptCommand_SetDialogName + db NPC_HOST + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveWramNPC + dw NPCMovement_f4c9 + run_command ScriptCommand_Jump + dw .ows_f516 +.ows_f513 + run_command ScriptCommand_MoveWramNPC + dw NPCMovement_f4c8 +.ows_f516 + run_command Func_cdd8 + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f383 + run_command ScriptCommand_PrintTextString + tx Text0550 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_MoveActiveNPC + dw NPCMovement_f38b + run_command Func_d1b3 + run_command ScriptCommand_PrintTextString + tx Text0551 + run_command ScriptCommand_GiveCard + db $00 + run_command ScriptCommand_ShowCardReceivedScreen + db $00 + run_command ScriptCommand_PrintTextString + tx Text0552 + run_command ScriptCommand_CloseTextBox + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_44 + db $02 + dw .ows_f540 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_44 + db $03 + dw .ows_f549 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_3F + db $02 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_48 + db $02 + run_command ScriptCommand_Jump + dw .ows_f552 +.ows_f540 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_40 + db $02 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_49 + db $02 + run_command ScriptCommand_Jump + dw .ows_f552 +.ows_f549 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_41 + db $02 + run_command ScriptCommand_SetFlagValue + db EVENT_FLAG_4A + db $02 + run_command ScriptCommand_Jump + dw .ows_f552 +.ows_f552 + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript + db NPC_CLERK12 + dw Script_f3e9 + run_command ScriptCommand_EndScriptLoop1 + ret +; f559 + +; Loads the NPC to fight at the challenge hall +Preload_ChallengeHallOpponent: ; f559 (3:7559) + get_flag_value EVENT_FLAG_42 + or a + ret z + get_flag_value EVENT_FLAG_46 + or a + jr z, .asm_f56e + ld a, [wd696] + ld [wTempNPC], a + scf + ret +.asm_f56e + call Func_f5db + ld c, $01 + set_flag_value EVENT_FLAG_45 + call Func_f580 + max_flag_value EVENT_FLAG_46 + scf + ret Func_f580: ; f580 (3:7580) - call Func_ca69 - ld b, h + get_flag_value EVENT_FLAG_44 cp $3 jr z, .asm_f596 - call Func_ca69 - ld b, l + get_flag_value EVENT_FLAG_45 cp $3 ld d, $18 jr nz, .asm_f598 @@ -3178,12 +6263,106 @@ Func_f580: ; f580 (3:7580) ld a, [hl] .asm_f5ac - ld [wd3ab], a + ld [wTempNPC], a ld [wd696], a ret ; 0xf5b3 - INCROM $f5b3, $fc2b + INCROM $f5b3, $f5db + +Func_f5db: ; f5db (3:75db) + xor a + ld [$d698], a + ld [$d699], a + ld [$d69a], a + ld [$d69b], a + ret +; 0xf5e9 + + INCROM $f5e9, $f602 + +Func_f602: ; f602 (3:7602) + INCROM $f602, $f631 + +Script_f631: ; f631 (3:7631) + start_script + run_command ScriptCommand_PrintTextString + tx Text0508 + run_command ScriptCommand_CloseAdvancedTextBox + run_command ScriptCommand_SetNextNPCandScript + db $02 + dw $763c + run_command ScriptCommand_EndScriptLoop1 + + ret +; 0xf63c + + INCROM $f63c, $fbdb + +HallOfHonorLoadMap: ; fbdb (3:7bdb) + ld a, SFX_10 + call PlaySFX + ret +; 0xfbe1 + + INCROM $fbe1, $fbf1 + +Script_fbf1: ; fbf1 (3:7bf1) + start_script + run_command ScriptCommand_JumpIfFlagNonzero2 + db EVENT_RECEIVED_LEGENDARY_CARD + dw .ows_fc10 + run_command ScriptCommand_MaxOutFlagValue + db EVENT_RECEIVED_LEGENDARY_CARD + run_command Func_ccdc + tx Text05b8 + run_command ScriptCommand_GiveCard + db ZAPDOS3 + run_command ScriptCommand_GiveCard + db MOLTRES2 + run_command ScriptCommand_GiveCard + db ARTICUNO2 + run_command ScriptCommand_GiveCard + db DRAGONITE1 + run_command ScriptCommand_ShowCardReceivedScreen + db $ff +.ows_fc05 + run_command Func_d38f + db $00 + run_command Func_ccdc + tx Text05b9 +.ows_fc0a + run_command Func_d38f + db $01 + run_command Func_d396 + db $01 + run_command Func_d3b9 + run_command ScriptCommand_QuitScriptFully + +.ows_fc10 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_71 + db $0f + dw .ows_fc20 + run_command Func_d209 + run_command Func_ccdc + tx Text05ba + run_command ScriptCommand_GiveCard + db $00 + run_command ScriptCommand_ShowCardReceivedScreen + db $00 + run_command ScriptCommand_Jump + dw .ows_fc05 + +.ows_fc20 + run_command Func_ccdc + tx Text05bb + run_command Func_d38f + db $00 + run_command Func_ccdc + tx Text05bc + run_command ScriptCommand_Jump + dw .ows_fc0a Func_fc2b: ; fc2b (3:7c2b) ld a, [wDuelResult] @@ -3200,17 +6379,29 @@ Func_fc2b: ; fc2b (3:7c2b) inc hl ld b, [hl] ld a, $b0 - ld [wd0c8], a + ld [wCurrentNPCNameTx], a ld a, $3 - ld [wd0c9], a - jp Func_c935 + ld [wCurrentNPCNameTx+1], a + jp SetNextScript PointerTable_fc4c: ; fc4c (3:7c4c) dw Unknown_fc64 dw Unknown_fc68 dw Unknown_fc60 - INCROM $fc52, $fc60 +Script_fc52: ; fc52 (3:7c52) + start_script + run_command ScriptCommand_PrintTextString + tx Text06c8 + run_command ScriptCommand_AskQuestionJumpDefaultYes + dw $0000 + dw .ows_fc5e + run_command ScriptCommand_PrintTextQuitFully + tx Text06c9 + +.ows_fc5e + run_command Func_cd76 + run_command ScriptCommand_QuitScriptFully Unknown_fc60: ; fc60 (3:7c60) INCROM $fc60, $fc64 @@ -3219,7 +6410,120 @@ Unknown_fc64: ; fc64 (3:7c64) INCROM $fc64, $fc68 Unknown_fc68: ; fc68 (3:7c68) - INCROM $fc68, $fcad + INCROM $fc68, $fc6c + +; Clerk looks away from you if you can't use infrared +; This is one of the preloads that does not change whether or not they appear +Preload_GiftCenterClerk: ; fc6c (3:7c6c) + ld a, [wConsole] + cp CONSOLE_CGB + jr z, .notCGB + ld a, NORTH + ld [wLoadNPCDirection], a +.notCGB + scf + ret + +Func_fc7a: ; fc7a (3:7c7a) + ld a, [wConsole] + ld c, a + set_flag_value EVENT_FLAG_74 + + start_script + run_command ScriptCommand_JumpIfFlagNotEqual + db EVENT_FLAG_74 + db $02 + dw Func_fcad.ows_fcd5 + run_command ScriptCommand_PrintTextString + tx Text06cd + run_command Func_d39d + db $00 + run_command ScriptCommand_JumpIfFlagNotLessThan + db EVENT_FLAG_72 + db $04 + dw Func_fc7a.ows_fcaa + run_command ScriptCommand_PrintTextString + tx Text06ce + run_command ScriptCommand_AskQuestionJumpDefaultYes + tx Text06cf + dw .ows_fca0 + run_command ScriptCommand_PrintTextString + tx Text06d0 + run_command ScriptCommand_Jump + dw Func_fc7a.ows_fcaa + +.ows_fca0 + run_command Func_d396 + db $00 + run_command ScriptCommand_PlaySFX + db $56 + run_command Func_ccdc + tx Text06d1 + run_command Func_d39d + db $01 + run_command ScriptCommand_QuitScriptFully + +.ows_fcaa + run_command ScriptCommand_PrintTextQuitFully + tx Text06d2 Func_fcad: ; fcad (3:7cad) - INCROM $fcad, $10000 + ld a, [wd10e] + ld c, a + set_flag_value EVENT_FLAG_72 + + start_script + run_command ScriptCommand_PlaySFX + db $56 + run_command Func_d396 + db $00 + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_72 + db $00 + dw .ows_fccc + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_72 + db $02 + dw .ows_fccf + run_command ScriptCommand_JumpIfFlagEqual + db EVENT_FLAG_72 + db $03 + dw .ows_fcd2 + run_command ScriptCommand_Jump + dw Func_fc7a.ows_fcaa + +.ows_fccc + run_command ScriptCommand_PrintTextQuitFully + tx Text06d3 + +.ows_fccf + run_command ScriptCommand_PrintTextQuitFully + tx Text06d4 + +.ows_fcd2 + run_command ScriptCommand_PrintTextQuitFully + tx Text06d5 + +.ows_fcd5 + run_command ScriptCommand_MoveArbitraryNPC + db NPC_GIFT_CENTER_CLERK + dw NPCMovement_fce1 + run_command ScriptCommand_PrintTextString + tx Text06d6 + run_command ScriptCommand_MoveArbitraryNPC + db NPC_GIFT_CENTER_CLERK + dw NPCMovement_fce3 + run_command ScriptCommand_QuitScriptFully + +NPCMovement_fce1: ; fce1 (3:7ce1) + db SOUTH | NO_MOVE + db $ff + +NPCMovement_fce3: ; fce3 (3:7ce3) + db NORTH | NO_MOVE + db $ff +; fce5 + +rept $31b + db $ff +endr diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index e2ca66c..13df81b 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -92,7 +92,7 @@ Medal_1029e: ; 1029e (4:429e) jr nz, .asm_102e2 ldtx hl, WonTheMedalText call PrintScrollableText_NoTextBoxLabel - call Func_3c96 + call WaitForSongToFinish call ResumeSong pop af ld [wd291], a @@ -149,7 +149,7 @@ BoosterPack_1031b: ; 1031b (4:431b) ldtx hl, AndAnotherBoosterPackText .asm_10373 call PrintScrollableText_NoTextBoxLabel - call Func_3c96 + call WaitForSongToFinish call ResumeSong ldtx hl, CheckedCardsInBoosterPackText call PrintScrollableText_NoTextBoxLabel @@ -224,7 +224,7 @@ Duel_Init: ; 103d3 (4:43d3) lb de, 18, 17 ; x, y call SetCursorParametersForTextBox call WaitForButtonAorB - call Func_3c96 + call WaitForSongToFinish call Func_10ab4 ; fade out pop af ld [wd291], a @@ -239,38 +239,39 @@ Func_10548: ; 10548 (4:4548) Func_10756: ; 10756 (4:4756) INCROM $10756, $10a70 -Func_10a70: ; 10a70 (4:4a70) +; gives the pc pack described in a +TryGivePCPack: ; 10a70 (4:4a70) push hl push bc push de ld b, a - ld c, $f + ld c, $f ; number of packs possible ld hl, wPCPacks -.asm_10a79 +.searchLoop1 ld a, [hli] and $7f cp b - jr z, .asm_10a97 + jr z, .quit dec c - jr nz, .asm_10a79 + jr nz, .searchLoop1 ld c, $f ld hl, wPCPacks -.asm_10a87 +.findFreeSlotLoop ld a, [hl] and $7f - jr z, .asm_10a93 + jr z, .foundFreeSlot inc hl dec c - jr nz, .asm_10a87 + jr nz, .findFreeSlotLoop debug_ret - jr .asm_10a97 + jr .quit -.asm_10a93 +.foundFreeSlot ld a, b - or $80 + or $80 ; mark pack as unopened ld [hl], a -.asm_10a97 +.quit pop de pop bc pop hl @@ -332,7 +333,7 @@ Func_10dba: ; 10dba (4:4dba) push af ld hl, $4df0 call JumpToFunctionInTable - farcall Func_c135 + farcall CloseTextBox call DoFrameIfLCDEnabled pop af ret @@ -344,7 +345,7 @@ Func_10e28: ; 10e28 (4:4e28) INCROM $10e28, $10e55 Func_10e55: ; 10e55 (4:4e55) - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld a, [wd33e] or a @@ -364,8 +365,8 @@ Func_10e71: ; 10e71 (4:4e71) ldh a, [hKeysPressed] and D_PAD jr z, .asm_10e83 - farcall Func_c5d5 - ld [wd334], a + farcall GetDirectionFromDPad + ld [wPlayerDirection], a call Func_10e97 jr .asm_10e96 .asm_10e83 @@ -387,7 +388,7 @@ Func_10e97: ; 10e97 (4:4e97) rlca rlca ld c, a - ld a, [wd334] + ld a, [wPlayerDirection] add c ld c, a ld b, $0 @@ -457,7 +458,7 @@ Func_10f4a: ; 10f4a (4:4f4a) jr nz, .asm_10f5f ld c, a ld a, $1e - farcall CheckIfEventFlagSet + farcall GetEventFlagValue or a ld a, c jr nz, .asm_10f5f @@ -477,13 +478,13 @@ LoadOverworldMapSelection: ; 10f61 (4:4f61) ld hl, OverworldMapIndexes add hl, bc ld a, [hli] - ld [wd0bb], a + ld [wTempMap], a ld a, [hli] - ld [wd0bc], a + ld [wTempPlayerXCoord], a ld a, [hli] - ld [wd0bd], a + ld [wTempPlayerYCoord], a ld a, $0 - ld [wd0be], a + ld [wTempPlayerDirection], a ld hl, wd0b4 set 4, [hl] pop bc @@ -494,7 +495,7 @@ INCLUDE "data/overworld_indexes.asm" Func_10fbc: ; 10fbc (4:4fbc) ld a, $25 - farcall Func_1299f + farcall CreateSpriteAndAnimBufferEntry ld c, SPRITE_ANIM_COORD_X call GetSpriteAnimBufferProperty ld a, $80 @@ -517,7 +518,7 @@ Func_10fde: ; 10fde (4:4fde) xor a ld [wd33e], a ld a, $25 - call Func_1299f + call CreateSpriteAndAnimBufferEntry ld a, [wWhichSprite] ld [wd33b], a ld b, $35 @@ -530,7 +531,7 @@ Func_10fde: ; 10fde (4:4fde) ld [wd33c], a call Func_12ab5 ld a, $3e - farcall CheckIfEventFlagSet + farcall GetEventFlagValue or a jr nz, .asm_11015 ld c, SPRITE_ANIM_FIELD_0F @@ -550,7 +551,7 @@ Func_11016: ; 11016 (4:5016) Func_11024: ; 11024 (4:5024) ld a, SFX_57 call PlaySFX - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld c, SPRITE_ANIM_FIELD_0F call GetSpriteAnimBufferProperty @@ -582,7 +583,7 @@ Func_11024: ; 11024 (4:5024) ret Func_11060: ; 11060 (4:5060) - ld a, [wd336] + ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld a, [wd341] or a @@ -672,7 +673,7 @@ Func_110a6: ; 110a6 (4:50a6) xor a ld [wd347], a ld [wd348], a - farcall Func_c5e9 + farcall UpdatePlayerSprite pop hl ret @@ -710,7 +711,7 @@ Func_11102: ; 11102 (4:5102) jr z, .asm_1113a ld a, $3 .asm_1113a - ld [wd334], a + ld [wPlayerDirection], a ret Func_1113e: ; 1113e (4:513e) @@ -746,7 +747,7 @@ Func_1113e: ; 1113e (4:513e) jr z, .asm_11175 ld a, $0 .asm_11175 - ld [wd334], a + ld [wPlayerDirection], a ret Func_11179: ; 11179 (4:5179) @@ -818,13 +819,13 @@ Func_1157c: ; 1157c (4:557c) .asm_11586 ld a, $2 - ld [wd0bc], a + ld [wTempPlayerXCoord], a ld a, $4 - ld [wd0bd], a + ld [wTempPlayerYCoord], a ld a, $2 - ld [wd0be], a + ld [wTempPlayerDirection], a ld a, $1 - ld [wd0bb], a + ld [wTempMap], a ld a, $1 ld [wd32e], a @@ -838,13 +839,13 @@ Func_115a3: ; 115a3 (4:55a3) INCLUDE "data/map_scripts.asm" -; loads a pointer into hl found on PointerTable_118f5 -Func_1184a: ; 1184a (4:584a) +; loads a pointer into hl found on NPCDataTable +GetNPCDataPointer: ; 1184a (4:584a) ; this may have been a macro rlca - add LOW(PointerTable_118f5) + add LOW(NPCDataTable) ld l, a - ld a, HIGH(PointerTable_118f5) + ld a, HIGH(NPCDataTable) adc $00 ld h, a ld a, [hli] @@ -852,12 +853,12 @@ Func_1184a: ; 1184a (4:584a) ld l, a ret -Func_11857: ; 11857 (4:5857) +LoadNPCSpriteData: ; 11857 (4:5857) push hl push bc - call Func_1184a + call GetNPCDataPointer ld a, [hli] - ld [wd3ab], a + ld [wTempNPC], a ld a, [hli] ld [wd3b3], a ld a, [hli] @@ -868,7 +869,7 @@ Func_11857: ; 11857 (4:5857) ld [wd3b2], a pop bc ld a, [wConsole] - cp $2 + cp CONSOLE_CGB jr nz, .asm_1187a ld a, b ld [wd3b1], a @@ -877,33 +878,34 @@ Func_11857: ; 11857 (4:5857) pop hl ret -; this appears to find data about the NPC we're talking to -Func_1187d: ; 1187d (4:587d) +; Loads Name into wCurrentNPCNameTx and gets Script ptr into bc +GetNPCNameAndScript: ; 1187d (4:587d) push hl - call Func_1184a - ld bc, $5 + call GetNPCDataPointer + ld bc, NPC_DATA_OWSEQUENCE_PTR add hl, bc ld c, [hl] inc hl ld b, [hl] inc hl ld a, [hli] - ld [wd0c8], a + ld [wCurrentNPCNameTx], a ld a, [hli] - ld [wd0c9], a + ld [wCurrentNPCNameTx+1], a pop hl ret -Func_11893: ; 11893 (4:5893) +; Sets Dialog Box title to the name of the npc in 'a' +SetNPCDialogName: ; 11893 (4:5893) push hl push bc - call Func_1184a - ld bc, $0007 + call GetNPCDataPointer + ld bc, NPC_DATA_NAME_TEXT add hl, bc ld a, [hli] - ld [wd0c8], a + ld [wCurrentNPCNameTx], a ld a, [hli] - ld [wd0c9], a + ld [wCurrentNPCNameTx+1], a pop bc pop hl ret @@ -911,7 +913,7 @@ Func_11893: ; 11893 (4:5893) Func_118a7: ; 118a7 (4:58a7) push hl push bc - call Func_1184a + call GetNPCDataPointer ld bc, $0007 add hl, bc ld a, [hli] @@ -927,7 +929,7 @@ Func_118a7: ; 118a7 (4:58a7) Func_118bf: ; 118bf (4:58bf) push hl push bc - call Func_1184a + call GetNPCDataPointer ld bc, $000a add hl, bc ld a, [hli] @@ -942,7 +944,7 @@ Func_118d3: ; 118d3 (4:58d3) push hl push bc push af - call Func_1184a + call GetNPCDataPointer ld bc, $000c add hl, bc ld a, [hli] @@ -967,23 +969,23 @@ Func_11f4e: ; 11f4e (4:5f4e) INCROM $11f4e, $1217b OverworldScriptTable: ; 1217b (4:617b) - dw OWScript_EndScriptLoop1 - dw OWScript_CloseTextBox - dw OWScript_PrintTextString + dw ScriptCommand_EndScriptLoop1 + dw ScriptCommand_CloseAdvancedTextBox + dw ScriptCommand_PrintTextString dw Func_ccdc - dw OWScript_AskQuestionJump - dw OWScript_StartBattle - dw Func_cd83 + dw ScriptCommand_AskQuestionJump + dw ScriptCommand_StartBattle + dw ScriptCommand_PrintVariableText dw Func_cda8 - dw OWScript_PrintTextCloseBox + dw ScriptCommand_PrintTextQuitFully dw Func_cdcb - dw Func_ce26 - dw Func_ce84 - dw OWScript_GiveBoosterPacks + dw ScriptCommand_MoveActiveNPCByDirection + dw ScriptCommand_CloseTextBox + dw ScriptCommand_GiveBoosterPacks dw Func_cf0c dw Func_cf12 - dw Func_cf3f - dw Func_cf4c + dw ScriptCommand_GiveCard + dw ScriptCommand_TakeCard dw Func_cf53 dw Func_cf7b dw Func_cf2d @@ -994,83 +996,83 @@ OverworldScriptTable: ; 1217b (4:617b) dw Func_d025 dw Func_d032 dw Func_d03f - dw OWScript_ScriptJump - dw Func_d04f - dw Func_d055 - dw OWScript_MovePlayer - dw Func_cee2 - dw Func_d080 - dw Func_d088 + dw ScriptCommand_Jump + dw ScriptCommand_TryGiveMedalPCPacks + dw ScriptCommand_SetPlayerDirection + dw ScriptCommand_MovePlayer + dw ScriptCommand_ShowCardReceivedScreen + dw ScriptCommand_SetDialogName + dw ScriptCommand_SetNextNPCandScript dw Func_d095 dw Func_d0be - dw Func_d0ce + dw ScriptCommand_DoFrames dw Func_d0d9 - dw Func_d0f2 - dw Func_ce4a - dw Func_ceba + dw ScriptCommand_JumpIfPlayerCoordMatches + dw ScriptCommand_MoveActiveNPC + dw ScriptCommand_GiveOneOfEachTrainerBooster dw Func_d103 dw Func_d125 dw Func_d135 dw Func_d16b dw Func_cd4f dw Func_cd94 - dw Func_ce52 + dw ScriptCommand_MoveWramNPC dw Func_cdd8 dw Func_cdf5 dw Func_d195 dw Func_d1ad dw Func_d1b3 - dw OWScript_EndScriptCloseText + dw ScriptCommand_QuitScriptFully dw Func_d244 dw Func_d24c - dw OWScript_OpenDeckMachine + dw ScriptCommand_OpenDeckMachine dw Func_d271 - dw Func_d36d - dw Func_ce6f + dw ScriptCommand_EnterMap + dw ScriptCommand_MoveArbitraryNPC dw Func_d209 dw Func_d38f dw Func_d396 dw Func_cd76 dw Func_d39d dw Func_d3b9 - dw Func_d3c9 - dw Func_d3d1 + dw ScriptCommand_TryGivePCPack + dw ScriptCommand_nop dw Func_d3d4 dw Func_d3e0 dw Func_d3fe dw Func_d408 dw Func_d40f - dw Func_d416 - dw Func_d423 - dw Func_d429 + dw ScriptCommand_PlaySFX + dw ScriptCommand_PauseSong + dw ScriptCommand_ResumeSong dw Func_d41d - dw Func_d42f + dw ScriptCommand_WaitForSongToFinish dw Func_d435 - dw Func_cce4 + dw ScriptCommand_AskQuestionJumpDefaultYes dw Func_d2f6 dw Func_d317 dw Func_d43d - dw OWScript_EndScriptLoop2 - dw OWScript_EndScriptLoop3 - dw OWScript_EndScriptLoop4 - dw OWScript_EndScriptLoop5 - dw OWScript_EndScriptLoop6 - dw OWScript_CustomModifyEventFlags - dw Func_d460 - dw OWScript_JumpIfFlagSet - dw Func_d484 - dw Func_d49e - dw Func_d4a6 - dw Func_d4ae - dw OWScript_SetEventFlags - dw Func_d4c3 - dw Func_d4ca - dw OWScript_JumpIfFlagNotSet - dw Func_d452 - dw OWScript_EndScriptLoop7 - dw OWScript_EndScriptLoop8 - dw OWScript_EndScriptLoop9 - dw OWScript_EndScriptLoop10 + dw ScriptCommand_EndScriptLoop2 + dw ScriptCommand_EndScriptLoop3 + dw ScriptCommand_EndScriptLoop4 + dw ScriptCommand_EndScriptLoop5 + dw ScriptCommand_EndScriptLoop6 + dw ScriptCommand_SetFlagValue + dw ScriptCommand_JumpIfFlagZero1 + dw ScriptCommand_JumpIfFlagNonzero1 + dw ScriptCommand_JumpIfFlagEqual + dw ScriptCommand_JumpIfFlagNotEqual + dw ScriptCommand_JumpIfFlagNotLessThan + dw ScriptCommand_JumpIfFlagLessThan + dw ScriptCommand_MaxOutFlagValue + dw ScriptCommand_ZeroOutFlagValue + dw ScriptCommand_JumpIfFlagNonzero2 + dw ScriptCommand_JumpIfFlagZero2 + dw ScriptCommand_IncrementFlagValue + dw ScriptCommand_EndScriptLoop7 + dw ScriptCommand_EndScriptLoop8 + dw ScriptCommand_EndScriptLoop9 + dw ScriptCommand_EndScriptLoop10 INCROM $1224b, $1229f @@ -1229,14 +1231,15 @@ Unknown_128fb: ; 128fb Func_1296e: ; 1296e (4:696e) INCROM $1296e, $1299f -Func_1299f: ; 1299f (4:699f) +; creates a new entry in SpriteAnimBuffer, Alse loads the sprite if need be +CreateSpriteAndAnimBufferEntry: ; 1299f (4:699f) push af ld a, [wd5d7] or a - jr z, .asm_129a8 + jr z, .continue pop af ret -.asm_129a8 +.continue pop af push bc push hl @@ -1244,50 +1247,50 @@ Func_1299f: ; 1299f (4:699f) ld [wd5d3], a xor a ld [wWhichSprite], a - call Func_3db7 - ld bc, $0010 -.asm_129bb + call GetFirstSpriteAnimBufferProperty + ld bc, SPRITE_ANIM_LENGTH +.findFirstEmptyAnimField ld a, [hl] or a - jr z, .asm_129cf + jr z, .foundEmptyAnimField add hl, bc ld a, [wWhichSprite] inc a ld [wWhichSprite], a cp $10 - jr nz, .asm_129bb + jr nz, .findFirstEmptyAnimField debug_ret scf - jr .asm_129d6 -.asm_129cf + jr .quit +.foundEmptyAnimField ld a, $1 ld [hl], a - call Func_129d9 + call FillNewSpriteAnimBufferEntry or a -.asm_129d6 +.quit pop hl pop bc ret -Func_129d9: ; 129d9 (4:69d9) +FillNewSpriteAnimBufferEntry: ; 129d9 (4:69d9) push hl push bc push hl inc hl - ld c, $f + ld c, SPRITE_ANIM_LENGTH - 1 xor a -.asm_129e0 +.clearSpriteAnimBufferEntryLoop ld [hli], a dec c - jr nz, .asm_129e0 + jr nz, .clearSpriteAnimBufferEntryLoop pop hl - ld bc, $0004 + ld bc, SPRITE_ANIM_FIELD_05 - 1 add hl, bc ld a, [wd5d3] ld [hli], a ld a, $ff ld [hl], a - ld bc, $0009 + ld bc, SPRITE_ANIM_MOVEMENT_COUNTER - SPRITE_ANIM_FIELD_05 add hl, bc ld a, $ff ld [hl], a @@ -1322,7 +1325,7 @@ Func_12ab5: ; 12ab5 (4:6ab5) Func_12ae2: ; 12ae2 (4:6ae2) push bc push af - call Func_3db7 + call GetFirstSpriteAnimBufferProperty pop af push hl ld bc, $0005 @@ -1330,15 +1333,15 @@ Func_12ae2: ; 12ae2 (4:6ae2) ld [hli], a push hl ld l, $6 - farcall Func_8020f + farcall GetMapDataPointer farcall Func_80229 pop hl - ld a, [wd4c6] + ld a, [wTempPointerBank] ld [hli], a - ld a, [wd4c4] + ld a, [wTempPointer] ld [hli], a ld c, a - ld a, [wd4c5] + ld a, [wTempPointer + 1] ld [hli], a ld b, a ld a, $3 @@ -1360,20 +1363,20 @@ Func_12b13: ; 12b13 (4:6b13) ld bc, $0006 add hl, bc ld a, [hli] - ld [wd4c6], a + ld [wTempPointerBank], a inc hl inc hl ld a, [hl] - ld [wd4c4], a + ld [wTempPointer], a add $4 ld [hli], a ld a, [hl] - ld [wd4c5], a + ld [wTempPointer + 1], a adc $0 ld [hl], a ld de, wd23e ld bc, $0004 - call Func_3bf5 + call CopyBankedDataToDE pop hl ld de, wd23e ld a, [de] @@ -1421,11 +1424,11 @@ Func_12b6a: ; 12b6a (4:6b6a) ld bc, $0006 add hl, bc ld a, [hli] - ld [wd4c6], a + ld [wTempPointerBank], a ld a, [hli] - ld [wd4c4], a + ld [wTempPointer], a ld a, [hli] - ld [wd4c5], a + ld [wTempPointer + 1], a pop hl call Func_3d72 pop de @@ -1465,6 +1468,8 @@ Func_12ba7: ; 12ba7 (4:6ba7) Func_12bcd: ; 12bcd (4:6bcd) INCROM $12bcd, $12c05 +; gets some value based on the sprite in b and wd5d8 +; loads the sprites data if it doesn't already exist Func_12c05: ; 12c05 (4:6c05) push hl push bc @@ -1475,23 +1480,24 @@ Func_12c05: ; 12c05 (4:6c05) ld c, a ld hl, wd5d8 or a - jr z, .asm_12c22 -.asm_12c15 + jr z, .tryToAddSprite + +.findSpriteMatchLoop inc hl ld a, [hl] cp b - jr z, .asm_12c3a + jr z, .foundSpriteMatch inc hl ld a, [hli] add [hl] ld d, a inc hl dec c - jr nz, .asm_12c15 -.asm_12c22 + jr nz, .findSpriteMatchLoop +.tryToAddSprite ld a, [wd618] cp $10 - jr nc, .asm_12c48 + jr nc, .quitFail inc a ld [wd618], a inc hl @@ -1505,7 +1511,7 @@ Func_12c05: ; 12c05 (4:6c05) pop af ld [hl], a pop hl -.asm_12c3a +.foundSpriteMatch dec hl inc [hl] inc hl @@ -1513,15 +1519,15 @@ Func_12c05: ; 12c05 (4:6c05) ld a, [hli] add [hl] cp $81 - jr nc, .asm_12c48 + jr nc, .quitFail ld a, d or a - jr .asm_12c4b -.asm_12c48 + jr .quitSucceed +.quitFail debug_ret xor a scf -.asm_12c4b +.quitSucceed pop de pop bc pop hl @@ -1555,7 +1561,7 @@ Func_1344d: ; 1344d (4:744d) call PlaySong ldtx hl, DefeatedFiveOpponentsText call PrintScrollableText_NoTextBoxLabel - call Func_3c96 + call WaitForSongToFinish call ResumeSong ret ; 0x13462 @@ -1577,9 +1583,16 @@ Func_13485: ; 13485 (4:7485) call PlaySong ldtx hl, ConsecutiveWinRecordIncreasedText call PrintScrollableText_NoTextBoxLabel - call Func_3c96 + call WaitForSongToFinish call ResumeSong ret ; 0x134b1 - INCROM $134b1, $14000 + INCROM $134b1, $1372f + +INCLUDE "data/npc_map_data.asm" +INCLUDE "data/map_objects.asm" + +rept $119 + db $ff +endr diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 7a2d90a..45cc8b1 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -35,13 +35,13 @@ Func_1c056: ; 1c056 (7:4056) inc hl inc hl ld a, [hli] - ld [wd0bb], a + ld [wTempMap], a ld a, [hli] - ld [wd0bc], a + ld [wTempPlayerXCoord], a ld a, [hli] - ld [wd0bd], a - ld a, [wd334] - ld [wd0be], a + ld [wTempPlayerYCoord], a + ld a, [wPlayerDirection] + ld [wTempPlayerDirection], a .asm_1c095 pop de pop bc @@ -93,11 +93,11 @@ INCLUDE "data/map_headers.asm" Func_1c440: ; 1c440 (7:4440) INCROM $1c440, $1c455 -Func_1c455: ; 1c455 (7:4455) +GetNPCDirection: ; 1c455 (7:4455) push hl - ld a, [wd3aa] - ld l, $4 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_DIRECTION + call GetItemInLoadedNPCIndex ld a, [hl] pop hl ret @@ -106,9 +106,9 @@ Func_1c461: ; 1c461 (7:4461) push hl push bc call Func_1c719 - ld a, [wd3aa] - ld l, $2 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_COORD_X + call GetItemInLoadedNPCIndex ld a, b ld [hli], a ld [hl], c @@ -119,23 +119,98 @@ Func_1c461: ; 1c461 (7:4461) Func_1c477: ; 1c477 (7:4477) push hl - ld a, [wd3aa] - ld l, $2 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_COORD_X + call GetItemInLoadedNPCIndex ld a, [hli] ld b, a ld c, [hl] pop hl ret +; Loads NPC Sprite Data Func_1c485: ; 1c485 (7:4485) - INCROM $1c485, $1c50a + push hl + push bc + push de + xor a + ld [wLoadedNPCTempIndex], a + ld b, a + ld c, LOADED_NPC_MAX + ld hl, wLoadedNPCs + ld de, LOADED_NPC_LENGTH +.findEmptyIndexLoop + ld a, [hl] + or a + jr z, .foundEmptyIndex + add hl, de + inc b + dec c + jr nz, .findEmptyIndexLoop + ld hl, wLoadedNPCs + debug_ret + jr .exit +.foundEmptyIndex + ld a, b + ld [wLoadedNPCTempIndex], a + ld a, [wd3b3] + farcall CreateSpriteAndAnimBufferEntry + jr c, .exit + ld a, [wLoadedNPCTempIndex] + call GetLoadedNPCID + push hl + ld a, [wTempNPC] + ld [hli], a + ld a, [wWhichSprite] + ld [hli], a + ld a, [wLoadNPCXPos] + ld [hli], a + ld a, [wLoadNPCYPos] + ld [hli], a + ld a, [wLoadNPCDirection] + ld [hli], a + ld a, [wd3b2] + ld [hli], a + ld a, [wd3b1] + ld [hli], a + ld a, [wLoadNPCDirection] + ld [hli], a + call Func_1c58e + call Func_1c5b9 + ld hl, wd349 + inc [hl] + pop hl + call Func_1c665 + call Func_1c6e3 + ld a, [wTempNPC] + call Func_1c4fa + jr nc, .exit + ld a, $01 + ld [wd3b8], a +.exit + pop de + pop bc + pop hl + ret + +Func_1c4fa: ; 1c4fa (7:44fa) + cp NPC_RONALD1 + jr z, .asm_1c508 + cp NPC_RONALD2 + jr z, .asm_1c508 + cp NPC_RONALD3 + jr z, .asm_1c508 + or a + ret +.asm_1c508 + scf + ret Func_1c50a: ; 1c50a (7:450a) push hl call Func_1c719 - ld a, [wd3aa] - call Func_39a7 + ld a, [wLoadedNPCTempIndex] + call GetLoadedNPCID ld a, [hl] or a jr z, .asm_1c52c @@ -159,9 +234,9 @@ Func_1c50a: ; 1c50a (7:450a) Func_1c52e: ; 1c52e (7:452e) push hl push af - ld a, [wd3aa] - ld l, $7 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_FIELD_07 + call GetItemInLoadedNPCIndex pop af ld [hl], a call Func_1c5e9 @@ -171,9 +246,9 @@ Func_1c52e: ; 1c52e (7:452e) Func_1c53f: ; 1c53f (7:453f) push hl push bc - ld a, [wd3aa] - ld l, $4 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_DIRECTION + call GetItemInLoadedNPCIndex ld a, [hl] ld bc, $0003 add hl, bc @@ -188,23 +263,23 @@ Func_1c53f: ; 1c53f (7:453f) Func_1c557: ; 1c557 (7:4557) push bc ld c, a - ld a, [wd3aa] + ld a, [wLoadedNPCTempIndex] push af - ld a, [wd3ab] + ld a, [wTempNPC] push af ld a, c - ld [wd3ab], a + ld [wTempNPC], a ld c, $0 - call Func_39c3 + call FindLoadedNPC jr c, .asm_1c570 call Func_1c53f ld c, a .asm_1c570 pop af - ld [wd3ab], a + ld [wTempNPC], a pop af - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a ld a, c pop bc ret @@ -213,9 +288,9 @@ Func_1c57b: ; 1c57b (7:457b) push hl push bc push af - ld a, [wd3aa] - ld l, $6 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_FIELD_06 + call GetItemInLoadedNPCIndex pop af ld [hl], a call Func_1c58e @@ -224,13 +299,76 @@ Func_1c57b: ; 1c57b (7:457b) ret Func_1c58e: ; 1c58e (7:458e) - INCROM $1c58e, $1c5e9 + push hl + push bc + ld a, [wWhichSprite] + push af + ld a, [wLoadedNPCTempIndex] + call GetLoadedNPCID + ld a, [hli] + or a + jr z, .quit + ld a, [hl] + ld [wWhichSprite], a + ld bc, LOADED_NPC_FIELD_06 - LOADED_NPC_SPRITE + add hl, bc + ld a, [hld] + bit 4, [hl] + jr nz, .asm_1c5ae + dec hl + add [hl] + inc hl +.asm_1c5ae + farcall Func_12ab5 +.quit + pop af + ld [wWhichSprite], a + pop bc + pop hl + ret +; 0x1c5b9 + +Func_1c5b9: ; 1c5b9 (7:45b9) + INCROM $1c5b9, $1c5e9 Func_1c5e9: ; 1c5e9 (7:45e9) - INCROM $1c5e9, $1c610 + push hl + push bc + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_FIELD_07 + call GetItemInLoadedNPCIndex + ld a, [hl] + ld bc, $fffd + add hl, bc + ld [hl], a + call Func_1c58e + pop bc + pop hl + ret +; 0x1c5ff + + INCROM $1c5ff, $1c610 Func_1c610: ; 1c610 (7:4610) - INCROM $1c610, $1c6f8 + INCROM $1c610, $1c665 + +Func_1c665: ; 1c665 (7:4665) + INCROM $1c665, $1c6e3 + +Func_1c6e3: ; 1c6e3 (7:46e3) + push hl + push bc + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_COORD_X + call GetItemInLoadedNPCIndex + ld a, [hli] + ld b, a + ld c, [hl] + ld a, $40 + call SetPermissionOfMapPosition + pop bc + pop hl + ret Func_1c6f8: ; 1c6f8 (7:46f8) INCROM $1c6f8, $1c719 @@ -238,9 +376,9 @@ Func_1c6f8: ; 1c6f8 (7:46f8) Func_1c719: ; 1c719 (7:4719) push hl push bc - ld a, [wd3aa] - ld l, $2 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_COORD_X + call GetItemInLoadedNPCIndex ld a, [hli] ld b, a ld c, [hl] @@ -250,36 +388,85 @@ Func_1c719: ; 1c719 (7:4719) pop hl ret -Func_1c72e: ; 1c72e (7:472e) - INCROM $1c72e, $1c768 +; Find NPC at coords b (x) c (y) +FindNPCAtLocation: ; 1c72e (7:472e) + push hl + push bc + push de + ld d, $00 + ld e, LOADED_NPC_MAX + ld hl, wLoadedNPC1CoordX +.findValidNPCLoop + ld a, [hli] + cp b + jr nz, .noValidNPCHere + ld a, [hl] + cp c + jr nz, .noValidNPCHere + push hl + inc hl + inc hl + bit 6, [hl] + pop hl + jr nz, .noValidNPCHere + push hl + dec hl + dec hl + ld a, [hl] + or a + pop hl + jr nz, .foundNPCExit +.noValidNPCHere + ld a, LOADED_NPC_LENGTH - 1 + add l + ld l, a + ld a, h + adc $00 + ld h, a + inc d + dec e + jr nz, .findValidNPCLoop + scf + jr .exit +.foundNPCExit + ld a, d + ld [wLoadedNPCTempIndex], a + or a +.exit + pop de + pop bc + pop hl + ret -Func_1c768: ; 1c768 (7:4768) +; Probably needs a new name. Loads data for NPC that the next Script is for +; Sets direction, Loads Image data for it, loads name, and more +SetNewScriptNPC: ; 1c768 (7:4768) push hl - ld a, [wd3aa] - ld l, $04 - call Func_39ad - ld a, [wd334] + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_DIRECTION + call GetItemInLoadedNPCIndex + ld a, [wPlayerDirection] xor $02 ld [hl], a call Func_1c58e ld a, $02 farcall Func_c29b - ld a, [wd3aa] - call Func_39a7 + ld a, [wLoadedNPCTempIndex] + call GetLoadedNPCID ld a, [hl] - farcall Func_1187d + farcall GetNPCNameAndScript pop hl ret Func_1c78d: ; 1c78d (7:478d) push hl - ld a, [wd3aa] - ld l, $5 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_FIELD_05 + call GetItemInLoadedNPCIndex set 5, [hl] - ld a, [wd3aa] - ld l, $8 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_FIELD_08 + call GetItemInLoadedNPCIndex xor a ld [hli], a .asm_1c7a2 @@ -319,9 +506,9 @@ Func_1c78d: ; 1c78d (7:478d) jr .asm_1c7a2 .asm_1c7d2 - ld a, [wd3aa] - ld l, $5 - call Func_39ad + ld a, [wLoadedNPCTempIndex] + ld l, LOADED_NPC_FIELD_05 + call GetItemInLoadedNPCIndex res 5, [hl] .asm_1c7dc @@ -429,7 +616,7 @@ Func_1c8ef: ; 1c8ef (7:48ef) ld c, a pop hl - call PushBC_Ret ; call bc + call CallBC .return pop de pop bc @@ -451,7 +638,7 @@ Func_1c94a: dec c jr nz, .loop ld a, [hli] - farcall Func_1299f + farcall CreateSpriteAndAnimBufferEntry ld a, [wWhichSprite] ld [wAnimationQueue], a ; push an animation to the queue xor a @@ -887,7 +1074,7 @@ Credits_1d6ad: ; 1d6ad (7:56ad) ld a, [wd633] cp $ff jr nz, .asm_1d6c8 - call Func_3c96 + call WaitForSongToFinish ld a, $8 farcall $4, $6863 ld a, MUSIC_STOP diff --git a/src/engine/bank1c.asm b/src/engine/bank1c.asm index 7b5cbc5..7fa5bf4 100644 --- a/src/engine/bank1c.asm +++ b/src/engine/bank1c.asm @@ -4,7 +4,7 @@ Func_70000: ; 70000 (1c:4000) ret nz ld b, $1 ld a, $22 - farcall CheckIfEventFlagSet + farcall GetEventFlagValue or a jr z, .asm_70013 ld b, $2 @@ -294,7 +294,7 @@ Func_70214: ; 70214 (1c:4214) ret nz ld hl, Unknown_7024a ld a, $10 - farcall CheckIfEventFlagSet + farcall GetEventFlagValue ld c, $8 .asm_70227 push bc diff --git a/src/engine/bank20.asm b/src/engine/bank20.asm index d2acf6a..b656f90 100644 --- a/src/engine/bank20.asm +++ b/src/engine/bank20.asm @@ -30,12 +30,12 @@ Func_80077: ; 80077 (20:4077) ld [hl], e inc hl ld [hl], d - call $43b9 - ld a, [wd4c6] + call Func_803b9 + ld a, [wTempPointerBank] ld [wd23d], a ld de, wd23e ld bc, $0006 - call Func_3bf5 + call CopyBankedDataToDE ld l, e ld h, d ld a, [hli] @@ -48,14 +48,163 @@ Func_80077: ; 80077 (20:4077) ld [wd23b], a ld a, [hli] ld [wd23c], a - call $40bd + call Func_800bd pop de pop bc pop hl ret -; 0x800bd - INCROM $800bd, $801a1 +Func_800bd: ; 800bd (20:40bd) + push hl + push bc + push de + ld a, [wTempPointer] + add $05 + ld e, a + ld a, [wTempPointer + 1] + adc $00 + ld d, a + ld b, $c0 + call Func_08bf + ld a, [wd4c2] + ld e, a + ld a, [wd4c3] + ld d, a + call Func_800e0 + pop de + pop bc + pop hl + ret + +Func_800e0: ; 800e0 (20:40e0) + push hl + ld hl, $d28e + ld a, [wd12f] + ld [hl], a + ld a, [wd23c] + or a + jr z, .asm_800f0 + sla [hl] +.asm_800f0 + ld c, $40 + ld hl, wd23e + xor a +.asm_800f6 + ld [hli], a + dec c + jr nz, .asm_800f6 + ld a, [wd130] + ld c, a +.asm_800fe + push bc + push de + ld b, $00 + ld a, [$d28e] + ld c, a + ld de, wd23e + call Func_3be4 + ld a, [wd12f] + ld b, a + pop de + push de + ld hl, wd23e + call Func_8016e + ld a, [wConsole] + cp $02 + jr nz, .asm_8013b + call BankswitchVRAM1 + ld a, [wd12f] + ld c, a + ld b, $00 + ld hl, wd23e + add hl, bc + pop de + push de + ld a, [wd12f] + ld b, a + call Func_80148 + call Func_8016e + call BankswitchVRAM0 +.asm_8013b + pop de + ld hl, $20 + add hl, de + ld e, l + ld d, h + pop bc + dec c + jr nz, .asm_800fe + pop hl + ret +; 0x80148 + +Func_80148: ; 80148 (20:4148) + ld a, [$d291] + or a + ret z + ld a, [$d23c] + or a + jr z, .asm_80162 + push hl + push bc +.asm_80155 + push bc + ld a, [$d291] + add [hl] + ld [hli], a + pop bc + dec b + jr nz, .asm_80155 + pop bc + pop hl + ret +.asm_80162 + push hl + push bc + ld a, [$d291] +.asm_80167 + ld [hli], a + dec b + jr nz, .asm_80167 + pop bc + pop hl + ret + +Func_8016e: ; 8016e (20:416e) + ld a, [wd292] + or a + jp z, SafeCopyDataHLtoDE + push hl + push bc + push de + ldh a, [hBankSRAM] + push af + ld a, $01 + call BankswitchSRAM + push hl + ld hl, $800 + ldh a, [hBankVRAM] + or a + jr z, .asm_8018c + ld hl, $c00 +.asm_8018c + add hl, de + ld e, l + ld d, h + pop hl +.asm_80190 + ld a, [hli] + ld [de], a + inc de + dec b + jr nz, .asm_80190 + pop af + call BankswitchSRAM + call DisableSRAM + pop de + pop bc + pop hl + ret Func_801a1: ; 801a1 (20:41a1) push hl @@ -108,6 +257,7 @@ Func_801a1: ; 801a1 (20:41a1) pop hl ret +; Clears the first x800 bytes of S1:a000 Func_801f1: ; 801f1 (20:41f1) push hl push bc @@ -118,7 +268,7 @@ Func_801f1: ; 801f1 (20:41f1) ld hl, $a000 ld bc, $0800 xor a - call $3c10 + call FillMemoryWithA pop af call BankswitchSRAM call DisableSRAM @@ -126,7 +276,7 @@ Func_801f1: ; 801f1 (20:41f1) pop hl ret -Func_8020f: ; 8020f (20:420f) +GetMapDataPointer: ; 8020f (20:420f) push bc push af ld bc, MapDataPointers @@ -148,12 +298,12 @@ Func_8020f: ; 8020f (20:420f) Func_80229: ; 80229 (20:4229) ld a, [hli] - ld [wd4c4], a + ld [wTempPointer], a ld a, [hli] - ld [wd4c5], a + ld [wTempPointer + 1], a ld a, [hli] add $20 - ld [wd4c6], a + ld [wTempPointerBank], a ret ; 0x80238 @@ -162,7 +312,7 @@ Func_80229: ; 80229 (20:4229) Func_8025b: ; 8025b (20:425b) push hl ld l, $4 - call Func_8020f + call GetMapDataPointer call Func_80229 ld a, [hl] push af @@ -192,7 +342,7 @@ asm_8027c ld e, [hl] inc hl ld d, [hl] - ld hl, wd4c4 + ld hl, wTempPointer ld a, [hli] ld h, [hl] ld l, a @@ -234,7 +384,19 @@ Func_802bb: ; 802bb (20:42bb) ret ; 0x802d4 - INCROM $802d4, $80418 + INCROM $802d4, $803b9 + +Func_803b9: ; 803b9 (20:43b9) + ld l, $00 + ld a, [wd131] + call GetMapDataPointer + call Func_80229 + ld a, [hl] + ld [$d239], a + ret +; 0x803c9 + + INCROM $803c9, $80418 Func_80418: ; 80418 (20:4418) INCROM $80418, $80480 @@ -246,13 +408,37 @@ Func_804d8: ; 804d8 (20:44d8) INCROM $804d8, $80b7a Func_80b7a: ; 80b7a (20:4b7a) - INCROM $80b7a, $80ba4 + INCROM $80b7a, $80b89 + +Func_80b89: ; 80b89 (20:4b89) + push hl + push bc + push af + ld c, a + ld a, $01 + ld [$d292], a + ld b, $00 + ld hl, $d323 + add hl, bc + ld a, [hl] + or a + jr z, .asm_80ba0 + ld a, c + call Func_80baa +.asm_80ba0 + pop af + pop bc + pop hl + ret Func_80ba4: ; 80ba4 (20:4ba4) push af xor a ld [wd292], a pop af +; Fallthrough + +Func_80baa: ; 80baa (20:4baa) push hl push bc push de @@ -332,5 +518,25 @@ Func_80ba4: ; 80ba4 (20:4ba4) Unknown_80e5a: ; 80e5a (20:4e5a) INCROM $80e5a, $80e5d +; might be closer to "screen specific data" than map data MapDataPointers: ; 80e5d (20:4e5d) - INCROM $80e5d, $84000 + dw MapDataPointers_80e67 + dw MapDataPointers_8100f + dw MapDataPointers_8116b + dw MapDataPointers_81333 + dw MapDataPointers_81697 + +MapDataPointers_80e67: ; 80e67 (20:4e67) + INCROM $80e67, $8100f + +MapDataPointers_8100f: ; 8100f (20:500f) + INCROM $8100f, $8116b + +MapDataPointers_8116b: ; 8116b (20:516b) + INCROM $8116b, $81333 + +MapDataPointers_81333: ; 81333 (20:5333) + INCROM $81333, $81697 + +MapDataPointers_81697: ; 81697 (20:5697) + INCROM $81697, $84000 diff --git a/src/engine/home.asm b/src/engine/home.asm index a9d28d6..78e0bf1 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -1552,7 +1552,7 @@ Func_08bf: ; 08bf (0:08bf) ld [hli], a ld [hl], b inc hl - ld [hli], a + ld [hli], a ; 0 ld [hl], $ef ld h, b ld l, $0 @@ -10815,8 +10815,8 @@ GameEvent_Credits: ; 3911 (0:3911) ret Func_3917: ; 3917 (0:3917) - ld a, $22 - farcall CheckIfEventFlagSet + ld a, EVENT_RECEIVED_LEGENDARY_CARD + farcall GetEventFlagValue call EnableSRAM ld [s0a00a], a call DisableSRAM @@ -10880,7 +10880,7 @@ GetPermissionByteOfMapPosition: ; 3946 (0:3946) Func_395a: ; 395a (0:395a) ldh a, [hBankROM] push af - ld a, [wd4c6] + ld a, [wTempPointerBank] call BankswitchROM call CopyGfxData pop af @@ -10890,8 +10890,8 @@ Func_395a: ; 395a (0:395a) Unknown_396b: ; 396b (0:396b) db $00, -$01, $01, $00, $00, $01, -$01, $00 -; Movement offsets for scripted movements -ScriptedMovementOffsetTable: ; 3973 (0:3973) +; Movement offsets for player movements +PlayerMovementOffsetTable: ; 3973 (0:3973) db 0, -2 ; move 2 tiles up db 2, 0 ; move 2 tiles right db 0, 2 ; move 2 tiles down @@ -10923,15 +10923,16 @@ Func_3997: ; 3997 (0:3997) call BankswitchROM ret -Func_39a7: ; 39a7 (0:39a7) - ld l, $0 - call Func_39ad +; returns in hl a pointer to the first element for the a'th NPC +GetLoadedNPCID: ; 39a7 (0:39a7) + ld l, LOADED_NPC_ID + call GetItemInLoadedNPCIndex ret -; return hl = wd34a + a * $c + l, with a < $8 -Func_39ad: ; 39ad (0:39ad) +; return in hl a pointer to the a'th items element l +GetItemInLoadedNPCIndex: ; 39ad (0:39ad) push bc - cp $8 + cp LOADED_NPC_MAX jr c, .asm_39b4 debug_ret xor a @@ -10944,36 +10945,39 @@ Func_39ad: ; 39ad (0:39ad) add l ld l, a ld h, $0 - ld bc, wd34a + ld bc, wLoadedNPCs add hl, bc pop bc ret -Func_39c3: ; 39c3 (0:39c3) +; Finds the index on wLoadedNPCs table of the npc in wTempNPC +; returns it in a and puts it into wLoadedNPCTempIndex +; c flag set if no npc found +FindLoadedNPC: ; 39c3 (0:39c3) push hl push bc push de xor a - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a ld b, a - ld c, $8 - ld de, $000c - ld hl, wd34a - ld a, [wd3ab] -.asm_39d6 + ld c, LOADED_NPC_MAX + ld de, LOADED_NPC_LENGTH + ld hl, wLoadedNPCs + ld a, [wTempNPC] +.findNPCLoop cp [hl] - jr z, .asm_39e1 + jr z, .foundNPCMatch add hl, de inc b dec c - jr nz, .asm_39d6 + jr nz, .findNPCLoop scf - jr z, .asm_39e6 -.asm_39e1 + jr z, .exit +.foundNPCMatch ld a, b - ld [wd3aa], a + ld [wLoadedNPCTempIndex], a or a -.asm_39e6 +.exit pop de pop bc pop hl @@ -11070,65 +11074,68 @@ Func_3a4f: ; 3a4f (0:3a4f) ret ; 0x3a5e -Func_3a5e: ; 3a5e (0:3a5e) +HandleMoveModeAPress: ; 3a5e (0:3a5e) ldh a, [hBankROM] push af - ld l, $4 - call Func_3abd - jr nc, .asm_3ab3 - ld a, BANK(Func_c653) + ld l, MAP_SCRIPT_OBJECTS + call GetMapScriptPointer + jr nc, .handleSecondAPressScript + ld a, BANK(FindPlayerMovementFromDirection) call BankswitchROM - call Func_c653 - ld a, $4 + call FindPlayerMovementFromDirection + ld a, BANK(MapScripts) call BankswitchROM - ld a, [wd334] + ld a, [wPlayerDirection] ld d, a -.asm_3a79 +.findAPressMatchLoop ld a, [hli] bit 7, a - jr nz, .asm_3ab3 + jr nz, .handleSecondAPressScript push bc push hl cp d - jr nz, .asm_3aab + jr nz, .noMatch ld a, [hli] cp b - jr nz, .asm_3aab + jr nz, .noMatch ld a, [hli] cp c - jr nz, .asm_3aab + jr nz, .noMatch ld a, [hli] - ld [wd0c6], a + ld [wNextScript], a ld a, [hli] - ld [wd0c7], a + ld [wNextScript+1], a ld a, [hli] - ld [wd0ca], a + ld [wDefaultObjectText], a ld a, [hli] - ld [wd0cb], a + ld [wDefaultObjectText+1], a ld a, [hli] - ld [wd0c8], a + ld [wCurrentNPCNameTx], a ld a, [hli] - ld [wd0c9], a + ld [wCurrentNPCNameTx+1], a pop hl pop bc pop af call BankswitchROM scf ret -.asm_3aab +.noMatch pop hl - ld bc, $0008 + ld bc, MAP_OBJECT_SIZE - 1 add hl, bc pop bc - jr .asm_3a79 -.asm_3ab3 + jr .findAPressMatchLoop +.handleSecondAPressScript pop af call BankswitchROM - ld l, $6 - call $49c2 + ld l, MAP_SCRIPT_PRESSED_A + call CallMapScriptPointerIfExists ret -Func_3abd: ; 3abd (0:3abd) +; returns a map script pointer in hl given +; current map in wCurMap and which sub-script in l +; sets c if pointer is found +GetMapScriptPointer: ; 3abd (0:3abd) push bc push hl ld a, [wCurMap] @@ -11167,9 +11174,9 @@ Func_3ae8: ; 3ae8 (0:3ae8) ret ; 0x3aed -; finds an OWScript from the first byte and puts the next two bytes (usually arguments?) into cb +; finds a Script from the first byte and puts the next two bytes (usually arguments?) into cb RunOverworldScript: ; 3aed (0:3aed) - ld hl, wOWScriptPointer + ld hl, wScriptPointer ld a, [hli] ld h, [hl] ld l, a @@ -11336,7 +11343,7 @@ ResetDoFrameFunction: ; 3bdb (0:3bdb) Func_3be4: ; 3be4 (0:3be4) ldh a, [hBankROM] push af - ld a, [wd4c6] + ld a, [wTempPointerBank] call BankswitchROM call Func_08de pop af @@ -11344,15 +11351,16 @@ Func_3be4: ; 3be4 (0:3be4) ret ; 0x3bf5 -Func_3bf5: ; 3bf5 (0:3bf5) +; Copies bc bytes from [wTempPointer] to de +CopyBankedDataToDE: ; 3bf5 (0:3bf5) ldh a, [hBankROM] push af push hl - ld a, [wd4c6] + ld a, [wTempPointerBank] call BankswitchROM - ld a, [wd4c4] + ld a, [wTempPointer] ld l, a - ld a, [wd4c5] + ld a, [wTempPointer + 1] ld h, a call CopyDataHLtoDE_SaveRegisters pop hl @@ -11422,9 +11430,8 @@ CallHL2: ; 3c45 (0:3c45) jp hl ; 0x3c46 -PushBC_Ret: ; 3c46 (0:3c46) - push bc - ret +CallBC: ; 3c46 (0:3c46) + retbc ; 0x3c48 DoFrameIfLCDEnabled: ; 3c48 (0:3c48) @@ -11475,7 +11482,7 @@ DivideBCbyDE: ; 3c5a (0:3c5a) jr nz, .asm_3c63 ret -Func_3c83: ; 3c83 (0:3c83) +CallPlaySong: ; 3c83 (0:3c83) call PlaySong ret ; 0x3c87 @@ -11485,18 +11492,19 @@ Func_3c87: ; 3c87 (0:3c87) call PauseSong pop af call PlaySong - call Func_3c96 + call WaitForSongToFinish call ResumeSong ret ; 0x3c96 -Func_3c96: ; 3c96 (0:3c96) +WaitForSongToFinish: ; 3c96 (0:3c96) call DoFrameIfLCDEnabled call AssertSongFinished or a - jr nz, Func_3c96 + jr nz, WaitForSongToFinish ret +; clear [SOMETHING] - something relating to animations Func_3ca0: ; 3ca0 (0:3ca0) xor a ld [wd5d7], a @@ -11649,11 +11657,11 @@ Func_3d72: ; 3d72 (0:3d72) xor a jr .asm_3da1 .asm_3d84 - ld a, [wd4c4] + ld a, [wTempPointer] ld l, a - ld a, [wd4c5] + ld a, [wTempPointer + 1] ld h, a - ld a, [wd4c6] + ld a, [wTempPointerBank] call BankswitchROM ld a, [hli] push af @@ -11684,7 +11692,7 @@ Func_3d72: ; 3d72 (0:3d72) call BankswitchROM ret -Func_3db7: ; 3db7 (0:3db7) +GetFirstSpriteAnimBufferProperty: ; 3db7 (0:3db7) push bc ld c, SPRITE_ANIM_FIELD_00 call GetSpriteAnimBufferProperty diff --git a/src/macros/code.asm b/src/macros/code.asm index 55f4b63..8921a04 100644 --- a/src/macros/code.asm +++ b/src/macros/code.asm @@ -26,6 +26,42 @@ else endc ENDM +; runs SetEventFlagValue with the next value as the flag, c as the new value +set_flag_value: MACRO + call SetStackFlagValue + db \1 +ENDM + +; runs ZeroOutEventFlag with the next value as the flag +zero_flag_value: MACRO + call ZeroStackFlagValue + db \1 +ENDM + +; a second version of the above with no real differences +zero_flag_value2: MACRO + call ZeroStackFlagValue2 + db \1 +ENDM + +; runs MaxOutEventFlag with the next value as the flag +max_flag_value: MACRO + call MaxStackFlagValue + db \1 +ENDM + +; runs GetEventFlagValue with the next value as the flag. returns value in a +get_flag_value: MACRO + call GetStackFlagValue + db \1 +ENDM + ; the rst $38 handler is a single ret instruction ; probably used for testing purposes during development debug_ret EQUS "rst $38" + +; Returns to the pointer in bc instead of where the stack was. +retbc: MACRO + push bc + ret +ENDM diff --git a/src/macros/constants.asm b/src/macros/constants.asm index 177fcd6..264e3ed 100644 --- a/src/macros/constants.asm +++ b/src/macros/constants.asm @@ -10,3 +10,8 @@ const: MACRO \1 EQU const_value const_value = const_value + 1 ENDM + +flag_def: MACRO + db \1 + db \2 +ENDM diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm index b9ab4ec..bd1a58f 100644 --- a/src/macros/scripts.asm +++ b/src/macros/scripts.asm @@ -1,11 +1,11 @@ start_script EQUS "rst $20" -run_script: MACRO +run_command: MACRO db \1_index ENDM ; TODO: create macros for overworld scripts after their usage and arguments are figured out. -; For example (current OWScript_GiveBoosterPacks_index): +; For example (current ScriptCommand_GiveBoosterPacks_index): ; const SCRIPT_GIVE_BOOSTER_PACKS ; $0c ;give_booster_packs: MACRO @@ -14,23 +14,23 @@ ENDM ;ENDM const_def - const OWScript_EndScriptLoop1_index ; $00 - const OWScript_CloseTextBox_index ; $01 - const OWScript_PrintTextString_index ; $02 + const ScriptCommand_EndScriptLoop1_index ; $00 + const ScriptCommand_CloseAdvancedTextBox_index ; $01 + const ScriptCommand_PrintTextString_index ; $02 const Func_ccdc_index ; $03 - const OWScript_AskQuestionJump_index ; $04 - const OWScript_StartBattle_index ; $05 - const Func_cd83_index ; $06 + const ScriptCommand_AskQuestionJump_index ; $04 + const ScriptCommand_StartBattle_index ; $05 + const ScriptCommand_PrintVariableText_index ; $06 const Func_cda8_index ; $07 - const OWScript_PrintTextCloseBox_index ; $08 + const ScriptCommand_PrintTextQuitFully_index ; $08 const Func_cdcb_index ; $09 - const Func_ce26_index ; $0a - const Func_ce84_index ; $0b - const OWScript_GiveBoosterPacks_index ; $0c + const ScriptCommand_MoveActiveNPCByDirection_index ; $0a + const ScriptCommand_CloseTextBox_index ; $0b + const ScriptCommand_GiveBoosterPacks_index ; $0c const Func_cf0c_index ; $0d const Func_cf12_index ; $0e - const Func_cf3f_index ; $0f - const Func_cf4c_index ; $10 + const ScriptCommand_GiveCard_index ; $0f + const ScriptCommand_TakeCard_index ; $10 const Func_cf53_index ; $11 const Func_cf7b_index ; $12 const Func_cf2d_index ; $13 @@ -41,81 +41,81 @@ ENDM const Func_d025_index ; $18 const Func_d032_index ; $19 const Func_d03f_index ; $1a - const OWScript_ScriptJump_index ; $1b - const Func_d04f_index ; $1c - const Func_d055_index ; $1d - const OWScript_MovePlayer_index ; $1e - const Func_cee2_index ; $1f - const Func_d080_index ; $20 - const Func_d088_index ; $21 + const ScriptCommand_Jump_index ; $1b + const ScriptCommand_TryGiveMedalPCPacks_index ; $1c + const ScriptCommand_SetPlayerDirection_index ; $1d + const ScriptCommand_MovePlayer_index ; $1e + const ScriptCommand_ShowCardReceivedScreen_index ; $1f + const ScriptCommand_SetDialogName_index ; $20 + const ScriptCommand_SetNextNPCandScript_index ; $21 const Func_d095_index ; $22 const Func_d0be_index ; $23 - const Func_d0ce_index ; $24 + const ScriptCommand_DoFrames_index ; $24 const Func_d0d9_index ; $25 - const Func_d0f2_index ; $26 - const Func_ce4a_index ; $27 - const Func_ceba_index ; $28 + const ScriptCommand_JumpIfPlayerCoordMatches_index ; $26 + const ScriptCommand_MoveActiveNPC_index ; $27 + const ScriptCommand_GiveOneOfEachTrainerBooster_index ; $28 const Func_d103_index ; $29 const Func_d125_index ; $2a const Func_d135_index ; $2b const Func_d16b_index ; $2c const Func_cd4f_index ; $2d const Func_cd94_index ; $2e - const Func_ce52_index ; $2f + const ScriptCommand_MoveWramNPC_index ; $2f const Func_cdd8_index ; $30 const Func_cdf5_index ; $31 const Func_d195_index ; $32 const Func_d1ad_index ; $33 const Func_d1b3_index ; $34 - const OWScript_EndScriptCloseText_index ; $35 + const ScriptCommand_QuitScriptFully_index ; $35 const Func_d244_index ; $36 const Func_d24c_index ; $37 - const OWScript_OpenDeckMachine_index ; $38 + const ScriptCommand_OpenDeckMachine_index ; $38 const Func_d271_index ; $39 - const Func_d36d_index ; $3a - const Func_ce6f_index ; $3b + const ScriptCommand_EnterMap_index ; $3a + const ScriptCommand_MoveArbitraryNPC_index ; $3b const Func_d209_index ; $3c const Func_d38f_index ; $3d const Func_d396_index ; $3e const Func_cd76_index ; $3f const Func_d39d_index ; $40 const Func_d3b9_index ; $41 - const Func_d3c9_index ; $42 - const Func_d3d1_index ; $43 + const ScriptCommand_TryGivePCPack_index ; $42 + const ScriptCommand_nop_index ; $43 const Func_d3d4_index ; $44 const Func_d3e0_index ; $45 const Func_d3fe_index ; $46 const Func_d408_index ; $47 const Func_d40f_index ; $48 - const Func_d416_index ; $49 - const Func_d423_index ; $4a - const Func_d429_index ; $4b + const ScriptCommand_PlaySFX_index ; $49 + const ScriptCommand_PauseSong_index ; $4a + const ScriptCommand_ResumeSong_index ; $4b const Func_d41d_index ; $4c - const Func_d42f_index ; $4d + const ScriptCommand_WaitForSongToFinish_index ; $4d const Func_d435_index ; $4e - const Func_cce4_index ; $4f + const ScriptCommand_AskQuestionJumpDefaultYes_index ; $4f const Func_d2f6_index ; $50 const Func_d317_index ; $51 const Func_d43d_index ; $52 - const OWScript_EndScriptLoop2_index ; $53 - const OWScript_EndScriptLoop3_index ; $54 - const OWScript_EndScriptLoop4_index ; $55 - const OWScript_EndScriptLoop5_index ; $56 - const OWScript_EndScriptLoop6_index ; $57 - const OWScript_CustomModifyEventFlags_index ; $58 - const Func_d460_index ; $59 - const OWScript_JumpIfFlagSet_index ; $5a - const Func_d484_index ; $5b - const Func_d49e_index ; $5c - const Func_d4a6_index ; $5d - const Func_d4ae_index ; $5e - const OWScript_SetEventFlags_index ; $5f - const Func_d4c3_index ; $60 - const Func_d4ca_index ; $61 - const OWScript_JumpIfFlagNotSet_index ; $62 - const Func_d452_index ; $63 - const OWScript_EndScriptLoop7_index ; $64 - const OWScript_EndScriptLoop8_index ; $65 - const OWScript_EndScriptLoop9_index ; $66 - const OWScript_EndScriptLoop10_index ; $67 + const ScriptCommand_EndScriptLoop2_index ; $53 + const ScriptCommand_EndScriptLoop3_index ; $54 + const ScriptCommand_EndScriptLoop4_index ; $55 + const ScriptCommand_EndScriptLoop5_index ; $56 + const ScriptCommand_EndScriptLoop6_index ; $57 + const ScriptCommand_SetFlagValue_index ; $58 + const ScriptCommand_JumpIfFlagZero1_index ; $59 + const ScriptCommand_JumpIfFlagNonzero1_index ; $5a + const ScriptCommand_JumpIfFlagEqual_index ; $5b + const ScriptCommand_JumpIfFlagNotEqual_index ; $5c + const ScriptCommand_JumpIfFlagNotLessThan_index ; $5d + const ScriptCommand_JumpIfFlagLessThan_index ; $5e + const ScriptCommand_MaxOutFlagValue_index ; $5f + const ScriptCommand_ZeroOutFlagValue_index ; $60 + const ScriptCommand_JumpIfFlagNonzero2_index ; $61 + const ScriptCommand_JumpIfFlagZero2_index ; $62 + const ScriptCommand_IncrementFlagValue_index ; $63 + const ScriptCommand_EndScriptLoop7_index ; $64 + const ScriptCommand_EndScriptLoop8_index ; $65 + const ScriptCommand_EndScriptLoop9_index ; $66 + const ScriptCommand_EndScriptLoop10_index ; $67 diff --git a/src/macros/wram.asm b/src/macros/wram.asm index ef7d8b2..c8b9a88 100644 --- a/src/macros/wram.asm +++ b/src/macros/wram.asm @@ -65,3 +65,18 @@ sprite_anim_struct: MACRO \1MovementCounter:: ds 1 \1Field0x0f:: ds 1 ENDM + +loaded_npc_struct: MACRO +\1ID:: ds 1 +\1Sprite:: ds 1 +\1CoordX:: ds 1 +\1CoordY:: ds 1 +\1Direction:: ds 1 +\1Field0x05:: ds 1 +\1Field0x06:: ds 1 +\1Field0x07:: ds 1 +\1Field0x08:: ds 1 +\1Field0x09:: ds 1 +\1Field0x0a:: ds 1 +\1Field0x0b:: ds 1 +ENDM diff --git a/src/sram.asm b/src/sram.asm index 272fbfd..f9c1a9e 100644 --- a/src/sram.asm +++ b/src/sram.asm @@ -63,7 +63,7 @@ s0a3f8:: ; a3f8 ds $12b4 -s0b700:: ; b700 +sCurrentlySelectedDeck:: ; b700 ds $1 SECTION "SRAM1", SRAM diff --git a/src/wram.asm b/src/wram.asm index 71830dd..acd9638 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1909,19 +1909,20 @@ wd0b9:: ; d0b9 wd0ba:: ; d0ba ds $1 -wd0bb:: ; d0bb +wTempMap:: ; d0bb ds $1 -wd0bc:: ; d0bc +wTempPlayerXCoord:: ; d0bc ds $1 -wd0bd:: ; d0bd +wTempPlayerYCoord:: ; d0bd ds $1 -wd0be:: ; d0be +wTempPlayerDirection:: ; d0be ds $1 -wd0bf:: ; d0bf +; See constants/misc_constants.asm for OWMODE's +wOverworldMode:: ; d0bf ds $1 wd0c0:: ; d0c0 @@ -1944,23 +1945,15 @@ wd0c4:: ; d0c4 wd0c5:: ; d0c5 ds $1 -wd0c6:: ; d0c6 - ds $1 - -wd0c7:: ; d0c7 - ds $1 - -wd0c8:: ; d0c8 - ds $1 - -wd0c9:: ; d0c9 - ds $1 +; used to store the location of an overworld sequence, which is jumped to later +wNextScript:: ; d0c6 + ds $2 -wd0ca:: ; d0ca - ds $1 +wCurrentNPCNameTx:: ; d0c8 + ds $2 -wd0cb:: ; d0cb - ds $1 +wDefaultObjectText:: ; d0ca + ds $2 wd0cc:: ; d0cc ds 8 palettes @@ -2013,9 +2006,7 @@ wPCPackSelection:: ; d11d ; 7th bit of each pack corresponds to whether or not it's been read wPCPacks:: ; d11e - ds $c - - ds $3 + ds $f wPCLastDirectionPressed:: ; d12d ds $1 @@ -2128,13 +2119,14 @@ wd332:: ; d332 wd333:: ; d333 ds $1 -wd334:: ; d334 +wPlayerDirection:: ; d334 ds $1 -wd335:: ; d335 +; seems to be 1 if moving 0 otherwise +wPlayerCurrentlyMoving:: ; d335 ds $1 -wd336:: ; d336 +wPlayerSpriteIndex:: ; d336 ds $1 wd337:: ; d337 @@ -2193,29 +2185,33 @@ wd348:: ; d348 wd349:: ; d349 ds $1 -wd34a:: ; d34a - ds $60 - -wd3aa:: ; d3aa - ds $1 +wLoadedNPCs:: ; d34a + loaded_npc_struct wLoadedNPC1 + loaded_npc_struct wLoadedNPC2 + loaded_npc_struct wLoadedNPC3 + loaded_npc_struct wLoadedNPC4 + loaded_npc_struct wLoadedNPC5 + loaded_npc_struct wLoadedNPC6 + loaded_npc_struct wLoadedNPC7 + loaded_npc_struct wLoadedNPC8 -wd3ab:: ; d3ab +wLoadedNPCTempIndex:: ; d3aa ds $1 -wd3ac:: ; d3ac +wTempNPC:: ; d3ab ds $1 -wd3ad:: ; d3ad +wLoadNPCXPos:: ; d3ac ds $1 -wd3ae:: ; d3ae +wLoadNPCYPos:: ; d3ad ds $1 -wd3af:: ; d3af +wLoadNPCDirection:: ; d3ae ds $1 -wd3b0:: ; d3b0 - ds $1 +wLoadNPCFunction:: ; d3af + ds $2 wd3b1:: ; d3b1 ds $1 @@ -2228,7 +2224,8 @@ wd3b3:: ; d3b3 ds $2 -wd3b6:: ; d3b6 +; ID of the NPC being interacted with in Script +wScriptNPC:: ; d3b6 ds $1 wc3b7:: ; d3b7 @@ -2248,23 +2245,22 @@ wd3bb:: ; d3bb wd3d0:: ; d3d0 ds $1 -wd3d1:: ; d3d1 +; the bits relevant to the currently worked on flag, obtained from EventFlagMods +wLoadedFlagBits:: ; d3d1 ds $1 wEventFlags:: - ds $3f - -wd411:: ; d411 - ds $1 + ds $40 ; 0 keeps looping, other values break the loop in RST20 -wBreakOWScriptLoop:: ; d412 +wBreakScriptLoop:: ; d412 ds $1 -wOWScriptPointer:: ; d413 +wScriptPointer:: ; d413 ds $2 -wd415:: ; d415 +; generally set to ff when a flag check passes, 0 otherwise +wScriptControlByte:: ; d415 ds $1 wd416:: ; d416 @@ -2342,13 +2338,11 @@ wd4c2:: ; d4c2 wd4c3:: ; d4c3 ds $1 -wd4c4:: ; d4c4 - ds $1 - -wd4c5:: ; d4c5 - ds $1 +; these next 3 seem to be an address (bank @ end) for copying bg data +wTempPointer:: ; d4c4 + ds $2 -wd4c6:: ; d4c6 +wTempPointerBank:: ; d4c6 ds $1 wd4c7:: ; d4c7 @@ -2417,6 +2411,7 @@ wd5d7:: ; d5d7 wd5d8:: ; d5d8 ds $40 +; seems to be the amount of entries in wd5d8 wd618:: ; d618 ds $1 |