summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/constants.asm3
-rw-r--r--src/constants/event_constants.asm3
-rw-r--r--src/constants/npc_constants.asm222
-rw-r--r--src/constants/script_constants.asm256
-rw-r--r--src/data/level_objects.asm602
-rw-r--r--src/data/npc_map_data.asm58
-rw-r--r--src/data/npcs.asm24
-rw-r--r--src/engine/bank03.asm945
-rw-r--r--src/engine/bank04.asm41
-rw-r--r--src/engine/bank07.asm53
-rw-r--r--src/engine/home.asm48
-rw-r--r--src/macros/code.asm6
-rw-r--r--src/macros/scripts.asm14
-rw-r--r--src/wram.asm13
14 files changed, 1773 insertions, 515 deletions
diff --git a/src/constants.asm b/src/constants.asm
index 7ad156b..421c8ac 100644
--- a/src/constants.asm
+++ b/src/constants.asm
@@ -4,7 +4,6 @@ INCLUDE "constants/card_data_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"
@@ -12,9 +11,9 @@ 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/charmaps.asm"
-INCLUDE "constants/script_constants.asm"
diff --git a/src/constants/event_constants.asm b/src/constants/event_constants.asm
deleted file mode 100644
index f6ac803..0000000
--- a/src/constants/event_constants.asm
+++ /dev/null
@@ -1,3 +0,0 @@
-; EVENT_JOSHUA_STATE ; $33
-JOSHUA_TALKED EQU 1
-JOSHUA_BEATEN EQU 2
diff --git a/src/constants/npc_constants.asm b/src/constants/npc_constants.asm
index 9e3911c..5ae8f99 100644
--- a/src/constants/npc_constants.asm
+++ b/src/constants/npc_constants.asm
@@ -77,119 +77,119 @@ NPC_DATA_LENGTH EQU const_value
const AARON_PIC ; $29
const_def 1
- const DRMASON ; $01
- const RONALD1 ; $02
- const ISHIHARA ; $03
- const IMAKUNI ; $04
+ const DRMASON ; $01
+ const RONALD1 ; $02
+ const ISHIHARA ; $03
+ const IMAKUNI ; $04
const_value = const_value+1 ; DRMASON duplicate
const_value = const_value+1 ; DRMASON duplicate
- const SAM ; $07
- const TECH1 ; $08
- const TECH2 ; $09
- const TECH3 ; $0a
- const TECH4 ; $0b
- const TECH5 ; $0c
- const TECH6 ; $0d
- const CLERK1 ; $0e
- const CLERK2 ; $0f
- const CLERK3 ; $10
- const CLERK4 ; $11
- const CLERK5 ; $12
- const CLERK6 ; $13
- const CLERK7 ; $14
- const CLERK8 ; $15
- const CLERK9 ; $16
- const CHRIS ; $17
- const MICHAEL ; $18
- const JESSICA ; $19
- const MITCH ; $1a
- const MATTHEW ; $1b
- const RYAN ; $1c
- const ANDREW ; $1d
- const GENE ; $1e
- const SARA ; $1f
- const AMANDA ; $20
- const JOSHUA ; $21
- const AMY ; $22
- const JENNIFER ; $23
- const NICHOLAS ; $24
- const BRANDON ; $25
- const ISAAC ; $26
- const BRITTANY ; $27
- const KRISTIN ; $28
- const HEATHER ; $29
- const NIKKI ; $2a
- const ROBERT ; $2b
- const DANIEL ; $2c
- const STEPHANIE ; $2d
- const MURRAY1 ; $2e
- const JOSEPH ; $2f
- const DAVID ; $30
- const ERIK ; $31
- const RICK ; $32
- const JOHN ; $33
- const ADAM ; $34
- const JONATHAN ; $35
- const KEN ; $36
- const COURTNEY ; $37
- const STEVE ; $38
- const JACK ; $39
- const ROD ; $3a
- const CLERK10 ; $3b
- const CLERK11 ; $3c
- const MAN1 ; $3d
- const WOMAN1 ; $3e
- const CHAP1 ; $3f
- const GAL1 ; $40
- const LASS1 ; $41
- const CHAP2 ; $42
- const LASS2 ; $43
- const PAPPY1 ; $44
- const LAD1 ; $45
- const LAD2 ; $46
- const CHAP3 ; $47
- const CLERK12 ; $48
- const CLERK13 ; $49
- const HOST ; $4a
- const SPECS1 ; $4b
- const BUTCH ; $4c
- const GRANNY1 ; $4d
- const LASS3 ; $4e
- const MAN2 ; $4f
- const PAPPY2 ; $50
- const LASS4 ; $51
- const HOOD1 ; $52
- const GRANNY2 ; $53
- const GAL2 ; $54
- const LAD3 ; $55
- const GAL3 ; $56
- const CHAP4 ; $57
- const MAN3 ; $58
- const SPECS2 ; $59
- const SPECS3 ; $5a
- const WOMAN2 ; $5b
- const MANIA ; $5c
- const PAPPY3 ; $5d
- const GAL4 ; $5e
- const CHAMP ; $5f
- const HOOD2 ; $60
- const LASS5 ; $61
- const CHAP5 ; $62
- const AARON ; $63
- const GUIDE ; $64
- const TECH7 ; $65
- const TECH8 ; $66
- const _11F18 ; $67
- const _11F1F ; $68
- const _11F26 ; $69
- const _11F2D ; $6a
- const _11F34 ; $6b
- const _11F3B ; $6c
- const _11F42 ; $6d
- const _11F49 ; $6e
+ const SAM ; $07
+ const TECH1 ; $08
+ const TECH2 ; $09
+ const TECH3 ; $0a
+ const TECH4 ; $0b
+ const TECH5 ; $0c
+ const TECH6 ; $0d
+ const CLERK1 ; $0e
+ const CLERK2 ; $0f
+ const CLERK3 ; $10
+ const CLERK4 ; $11
+ const CLERK5 ; $12
+ const CLERK6 ; $13
+ const CLERK7 ; $14
+ const CLERK8 ; $15
+ const CLERK9 ; $16
+ const CHRIS ; $17
+ const MICHAEL ; $18
+ const JESSICA ; $19
+ const MITCH ; $1a
+ const MATTHEW ; $1b
+ const RYAN ; $1c
+ const ANDREW ; $1d
+ const GENE ; $1e
+ const SARA ; $1f
+ const AMANDA ; $20
+ const JOSHUA ; $21
+ const AMY ; $22
+ const JENNIFER ; $23
+ const NICHOLAS ; $24
+ const BRANDON ; $25
+ const ISAAC ; $26
+ const BRITTANY ; $27
+ const KRISTIN ; $28
+ const HEATHER ; $29
+ const NIKKI ; $2a
+ const ROBERT ; $2b
+ const DANIEL ; $2c
+ const STEPHANIE ; $2d
+ const MURRAY1 ; $2e
+ const JOSEPH ; $2f
+ const DAVID ; $30
+ const ERIK ; $31
+ const RICK ; $32
+ const JOHN ; $33
+ const ADAM ; $34
+ const JONATHAN ; $35
+ const KEN ; $36
+ const COURTNEY ; $37
+ const STEVE ; $38
+ const JACK ; $39
+ const ROD ; $3a
+ const CLERK10 ; $3b
+ const GIFT_CENTER_CLERK ; $3c
+ const MAN1 ; $3d
+ const WOMAN1 ; $3e
+ const CHAP1 ; $3f
+ const GAL1 ; $40
+ const LASS1 ; $41
+ const CHAP2 ; $42
+ const LASS2 ; $43
+ const PAPPY1 ; $44
+ const LAD1 ; $45
+ const LAD2 ; $46
+ const CHAP3 ; $47
+ const CLERK12 ; $48
+ const CLERK13 ; $49
+ const HOST ; $4a
+ const SPECS1 ; $4b
+ const BUTCH ; $4c
+ const GRANNY1 ; $4d
+ const LASS3 ; $4e
+ const MAN2 ; $4f
+ const PAPPY2 ; $50
+ const LASS4 ; $51
+ const HOOD1 ; $52
+ const GRANNY2 ; $53
+ const GAL2 ; $54
+ const LAD3 ; $55
+ const GAL3 ; $56
+ const CHAP4 ; $57
+ const MAN3 ; $58
+ const SPECS2 ; $59
+ const SPECS3 ; $5a
+ const WOMAN2 ; $5b
+ const MANIA ; $5c
+ const PAPPY3 ; $5d
+ const GAL4 ; $5e
+ const CHAMP ; $5f
+ const HOOD2 ; $60
+ const LASS5 ; $61
+ const CHAP5 ; $62
+ const AARON ; $63
+ const GUIDE ; $64
+ const TECH7 ; $65
+ const TECH8 ; $66
+ const _11F18 ; $67
+ const LEGEND_CARDS_TOP_LEFT ; $68
+ const LEGEND_CARDS_TOP_RIGHT ; $69
+ const LEGEND_CARDS_LEFT_SPARK ; $6a
+ const LEGEND_CARDS_BOTTOM_LEFT ; $6b
+ const LEGEND_CARDS_BOTTOM_RIGHT ; $6c
+ const LEGEND_CARDS_RIGHT_SPARK ; $6d
+ const _11F49 ; $6e
const_value = const_value+1 ; _11F49 duplicate
- const MURRAY2 ; $70
- const RONALD2 ; $71
- const RONALD3 ; $72
+ const MURRAY2 ; $70
+ const RONALD2 ; $71
+ const RONALD3 ; $72
const_value = const_value+1 ; _11f49 duplicate
diff --git a/src/constants/script_constants.asm b/src/constants/script_constants.asm
index 398eeb3..2ce9a54 100644
--- a/src/constants/script_constants.asm
+++ b/src/constants/script_constants.asm
@@ -1,125 +1,143 @@
const_def
- const EVENT_FLAG_00
- const EVENT_FLAG_01
- const EVENT_FLAG_02
- const EVENT_FLAG_03
- const EVENT_FLAG_04
- const EVENT_FLAG_05
- const EVENT_FLAG_06
- const EVENT_FLAG_07
- const EVENT_FLAG_08
- const EVENT_FLAG_09
- const EVENT_FLAG_0A
- const EVENT_BEAT_AMY
- const EVENT_FLAG_0C
- const EVENT_FLAG_0D
- const EVENT_FLAG_0E
- const EVENT_FLAG_0F
- const EVENT_FLAG_10
- const EVENT_FLAG_11
- const EVENT_FLAG_12
- const EVENT_FLAG_13
- const EVENT_FLAG_14
- const EVENT_BEAT_SARA
- const EVENT_BEAT_AMANDA
- const EVENT_FLAG_17
- const EVENT_FLAG_18
- const EVENT_FLAG_19
- const EVENT_FLAG_1A
- const EVENT_FLAG_1B
- const EVENT_FLAG_1C
- const EVENT_FLAG_1D
- const EVENT_FLAG_1E
- const EVENT_FLAG_1F
- const EVENT_FLAG_20
- const EVENT_FLAG_21
- const EVENT_FLAG_22
- const EVENT_FLAG_23
- const EVENT_FLAG_24
- const EVENT_FLAG_25
- const EVENT_FLAG_26
- const EVENT_FLAG_27
- const EVENT_FLAG_28
- const EVENT_FLAG_29
- const EVENT_FLAG_2A
- const EVENT_FLAG_2B
- const EVENT_FLAG_2C
- const EVENT_FLAG_2D
- const EVENT_FLAG_2E
- const EVENT_FLAG_2F
- const EVENT_FLAG_30
- const EVENT_FLAG_31
- const EVENT_FLAG_32
- const EVENT_JOSHUA_STATE
- const EVENT_FLAG_34
- const EVENT_FLAG_35
- const EVENT_FLAG_36
- const EVENT_FLAG_37
- const EVENT_FLAG_38
- const EVENT_FLAG_39
- const EVENT_FLAG_3A
- const EVENT_FLAG_3B
- const FLAG_BEAT_BRITTANY
- const EVENT_FLAG_3D
- const EVENT_FLAG_3E
- const EVENT_FLAG_3F
- const EVENT_FLAG_40
- const EVENT_FLAG_41
- const EVENT_FLAG_42
- const EVENT_FLAG_43
- const EVENT_FLAG_44
- const EVENT_FLAG_45
- const EVENT_FLAG_46
- const EVENT_FLAG_47
- const EVENT_FLAG_48
- const EVENT_FLAG_49
- const EVENT_FLAG_4A
- const EVENT_FLAG_4B
- const EVENT_FLAG_4C
- const EVENT_FLAG_4D
- const EVENT_FLAG_4E
- const EVENT_FLAG_4F
- const EVENT_FLAG_50
- const EVENT_FLAG_51
- const EVENT_FLAG_52
- const EVENT_FLAG_53
- const EVENT_FLAG_54
- const EVENT_FLAG_55
- const EVENT_FLAG_56
- const EVENT_FLAG_57
- const EVENT_FLAG_58
- const EVENT_FLAG_59
- const EVENT_FLAG_5A
- const EVENT_FLAG_5B
- const EVENT_FLAG_5C
- const EVENT_FLAG_5D
- const EVENT_FLAG_5E
- const EVENT_FLAG_5F
- const EVENT_FLAG_60
- const EVENT_FLAG_61
- const EVENT_FLAG_62
- const EVENT_FLAG_63
- const EVENT_FLAG_64
- const EVENT_FLAG_65
- const EVENT_FLAG_66
- const EVENT_FLAG_67
- const EVENT_FLAG_68
- const EVENT_FLAG_69
- const EVENT_FLAG_6A
- const EVENT_FLAG_6B
- const EVENT_FLAG_6C
- const EVENT_FLAG_6D
- const EVENT_FLAG_6E
- const EVENT_FLAG_6F
- const EVENT_FLAG_70
- const EVENT_FLAG_71
- const EVENT_FLAG_72
- const EVENT_FLAG_73
- const EVENT_FLAG_74
- const EVENT_FLAG_75
- const EVENT_FLAG_76
+ 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_FLAG_22 ; $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
diff --git a/src/data/level_objects.asm b/src/data/level_objects.asm
new file mode 100644
index 0000000..a0d51cc
--- /dev/null
+++ b/src/data/level_objects.asm
@@ -0,0 +1,602 @@
+LevelObjects_13b04: ; 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
+
+
+LevelObjects_13b4d: ; 13b4d (3:7b4d)
+ db NORTH, 2, 2
+ dw OWSequence_d932
+ tx Text041b
+ tx Text041a
+
+ db NORTH, 4, 2
+ dw OWSequence_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
+
+
+LevelObjects_13c02: ; 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
+
+
+LevelObjects_13c6f: ; 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 OWSequence_fc52
+ tx Text041b
+ tx Text03b0
+
+ db NORTH, 10, 6
+ dw Func_fc7a
+ tx Text041b
+ tx Text03b0
+
+ db $ff
+
+
+LevelObjects_13ca6: ; 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 OWSequence_fc52
+ tx Text041b
+ tx Text03b0
+
+ db NORTH, 10, 6
+ dw Func_fc7a
+ tx Text041b
+ tx Text03b0
+
+ db $ff
+
+
+LevelObjects_13cdd: ; 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 OWSequence_fc52
+ tx Text041b
+ tx Text03b0
+
+ db NORTH, 10, 6
+ dw Func_fc7a
+ tx Text041b
+ tx Text03b0
+
+ db $ff
+
+
+LevelObjects_13d14: ; 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 OWSequence_fc52
+ tx Text041b
+ tx Text03b0
+
+ db NORTH, 10, 6
+ dw Func_fc7a
+ tx Text041b
+ tx Text03b0
+
+ db $ff
+
+
+LevelObjects_13d4b: ; 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 OWSequence_fc52
+ tx Text041b
+ tx Text03b0
+
+ db NORTH, 10, 6
+ dw Func_fc7a
+ tx Text041b
+ tx Text03b0
+
+ db $ff
+
+
+LevelObjects_13d82: ; 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 OWSequence_fc52
+ tx Text041b
+ tx Text03b0
+
+ db NORTH, 10, 6
+ dw Func_fc7a
+ tx Text041b
+ tx Text03b0
+
+ db $ff
+
+
+LevelObjects_13db9: ; 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 OWSequence_fc52
+ tx Text041b
+ tx Text03b0
+
+ db NORTH, 10, 6
+ dw Func_fc7a
+ tx Text041b
+ tx Text03b0
+
+ db $ff
+
+
+LevelObjects_13df0: ; 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 OWSequence_fc52
+ tx Text041b
+ tx Text03b0
+
+ db NORTH, 10, 6
+ dw Func_fc7a
+ tx Text041b
+ tx Text03b0
+
+ db $ff
+
+
+LevelObjects_13e27: ; 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 OWSequence_fc52
+ tx Text041b
+ tx Text03b0
+
+ db NORTH, 10, 6
+ dw Func_fc7a
+ tx Text041b
+ tx Text03b0
+
+ db $ff
+
+
+LevelObjects_13e5e: ; 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 OWSequence_f631
+ tx Text0508
+ tx Text0507
+
+ db NORTH, 20, 0
+ dw OWSequence_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
+
+
+LevelObjects_13ec2: ; 13ec2 (3:7ec2)
+ db NORTH, 10, 10
+ dw $7bf1
+ dw $0000
+ dw $0000
+
+ db NORTH, 12, 10
+ dw $7bf1
+ 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/npc_map_data.asm b/src/data/npc_map_data.asm
index bae46d1..629eb91 100644
--- a/src/data/npc_map_data.asm
+++ b/src/data/npc_map_data.asm
@@ -31,11 +31,11 @@ DeckMachineRoomNPCS: ; 775a (4:1375a)
IshiharasHouseNPCS: ; 7773 (4:13773)
db NIKKI, $04, $04, NORTH
- dw $5add
+ dw Preload_NikkiInIshiharasHouse
db ISHIHARA, $08, $08, SOUTH
- dw $5b3d
+ dw Preload_IshiharaInIshiharasHouse
db RONALD1, $02, $04, WEST
- dw $5c43
+ dw Preload_Ronald1InIshiharasHouse
db $00
FightingClubEntranceNPCS: ; 7786 (4:13786)
@@ -62,8 +62,8 @@ FightingClubLobbyNPCS: ; 779f (4:1379f)
dw $5d98
db CLERK10, $06, $04, SOUTH
dw $0000
- db CLERK11, $0a, $04, SOUTH
- dw $7c6c
+ db GIFT_CENTER_CLERK, $0a, $04, SOUTH
+ dw Preload_GiftCenterClerk
db $00
FightingClubNPCS: ; 77ca (4:137ca)
@@ -101,8 +101,8 @@ RockClubLobbyNPCS: ; 77fc (4:137fc)
dw $5fcb
db CLERK10, $06, $04, SOUTH
dw $0000
- db CLERK11, $0a, $04, SOUTH
- dw $7c6c
+ db GIFT_CENTER_CLERK, $0a, $04, SOUTH
+ dw Preload_GiftCenterClerk
db $00
RockClubNPCS: ; 7827 (4:13827)
@@ -131,15 +131,15 @@ WaterClubLobbyNPCS: ; 7853 (4:13853)
db LASS1, $10, $0a, SOUTH
dw $0000
db IMAKUNI, $12, $02, NORTH
- dw $60b0
+ dw Preload_ImakuniInWaterClubLobby
db MAN2, $04, $12, EAST
- dw $6130
+ dw Preload_Man2InWaterClubLobby
db PAPPY2, $16, $10, NORTH
dw $0000
db CLERK10, $06, $04, SOUTH
dw $0000
- db CLERK11, $0a, $04, SOUTH
- dw $7c6c
+ db GIFT_CENTER_CLERK, $0a, $04, SOUTH
+ dw Preload_GiftCenterClerk
db $00
WaterClubNPCS: ; 787e (4:1387e)
@@ -175,8 +175,8 @@ LightningClubLobbyNPCS: ; 78b0 (4:138b0)
dw $0000
db CLERK10, $06, $04, SOUTH
dw $0000
- db CLERK11, $0a, $04, SOUTH
- dw $7c6c
+ db GIFT_CENTER_CLERK, $0a, $04, SOUTH
+ dw Preload_GiftCenterClerk
db $00
LightningClubNPCS: ; 78d5 (4:138d5)
@@ -214,8 +214,8 @@ GrassClubLobbyNPCS: ; 790d (4:1390d)
dw $66dc
db CLERK10, $06, $04, SOUTH
dw $0000
- db CLERK11, $0a, $04, SOUTH
- dw $7c6c
+ db GIFT_CENTER_CLERK, $0a, $04, SOUTH
+ dw Preload_GiftCenterClerk
db $00
GrassClubNPCS: ; 7932 (4:13932)
@@ -253,8 +253,8 @@ PsychicClubLobbyNPCS: ; 7964 (4:13964)
dw $0000
db CLERK10, $06, $04, SOUTH
dw $0000
- db CLERK11, $0a, $04, SOUTH
- dw $7c6c
+ db GIFT_CENTER_CLERK, $0a, $04, SOUTH
+ dw Preload_GiftCenterClerk
db $00
PsychicClubNPCS: ; 798f (4:1398f)
@@ -292,8 +292,8 @@ ScienceClubLobbyNPCS: ; 79c1 (4:139c1)
dw $0000
db CLERK10, $06, $04, SOUTH
dw $0000
- db CLERK11, $0a, $04, SOUTH
- dw $7c6c
+ db GIFT_CENTER_CLERK, $0a, $04, SOUTH
+ dw Preload_GiftCenterClerk
db $00
ScienceClubNPCS: ; 79ec (4:139ec)
@@ -329,8 +329,8 @@ FireClubLobbyNPCS: ; 7a1e (4:13a1e)
dw $0000
db CLERK10, $06, $04, SOUTH
dw $0000
- db CLERK11, $0a, $04, SOUTH
- dw $7c6c
+ db GIFT_CENTER_CLERK, $0a, $04, SOUTH
+ dw Preload_GiftCenterClerk
db $00
FireClubNPCS: ; 7a43 (4:13a43)
@@ -366,8 +366,8 @@ ChallengeHallLobbyNPCS: ; 7a63 (4:13a63)
dw $70b4
db CLERK10, $06, $04, SOUTH
dw $0000
- db CLERK11, $0a, $04, SOUTH
- dw $7c6c
+ db GIFT_CENTER_CLERK, $0a, $04, SOUTH
+ dw Preload_GiftCenterClerk
db $00
ChallengeHallNPCS: ; 7a9a (4:13a9a)
@@ -402,17 +402,17 @@ PokemonDomeNPCS: ; 7ac0 (4:13ac0)
db $00
HallOfHonorNPCS: ; 7adf (4:13adf)
- db _11F1F, $0a, $08, SOUTH
+ db LEGEND_CARDS_TOP_LEFT, $0a, $08, SOUTH
dw $0000
- db _11F26, $0c, $08, SOUTH
+ db LEGEND_CARDS_TOP_RIGHT, $0c, $08, SOUTH
dw $0000
- db _11F2D, $08, $0a, SOUTH
+ db LEGEND_CARDS_LEFT_SPARK, $08, $0a, SOUTH
dw $0000
- db _11F34, $0a, $0a, SOUTH
+ db LEGEND_CARDS_BOTTOM_LEFT, $0a, $0a, SOUTH
dw $0000
- db _11F3B, $0c, $0a, SOUTH
+ db LEGEND_CARDS_BOTTOM_RIGHT, $0c, $0a, SOUTH
dw $0000
- db _11F42, $0e, $0a, SOUTH
+ db LEGEND_CARDS_RIGHT_SPARK, $0e, $0a, SOUTH
dw $0000
db $00
diff --git a/src/data/npcs.asm b/src/data/npcs.asm
index 4ff42c8..8fb8773 100644
--- a/src/data/npcs.asm
+++ b/src/data/npcs.asm
@@ -61,7 +61,7 @@ NPCDataTable:
dw JackData
dw RodData
dw Clerk10Data
- dw Clerk11Data
+ dw GiftCenterClerkData
dw Man1Data
dw Woman1Data
dw Chap1Data
@@ -135,7 +135,7 @@ Ronald1Data:
db $04
db $0e
db $00
- dw $5c4b ; Pointer to OWScript
+ dw OWSequence_Ronald ; Pointer to OWScript
tx Text03ad
db RONALD_PIC
db $1a
@@ -147,7 +147,7 @@ Ronald2Data:
db $04
db $0e
db $00
- dw $5c4b ; Pointer to OWScript
+ dw OWSequence_Ronald ; Pointer to OWScript
tx Text03ad
db RONALD_PIC
db $1a
@@ -159,7 +159,7 @@ Ronald3Data:
db $04
db $0e
db $00
- dw $5c4b ; Pointer to OWScript
+ dw OWSequence_Ronald ; Pointer to OWScript
tx Text03ad
db RONALD_PIC
db $1a
@@ -171,7 +171,7 @@ IshiharaData:
db $04
db $22
db $00
- dw $5b4a ; Pointer to OWScript
+ dw OWSequence_Ishihara ; Pointer to OWScript
tx Text03ae
db $00
db $00
@@ -279,7 +279,7 @@ Clerk1Data:
db $0a
db $30
db $00
- dw $5c64 ; Pointer to OWScript
+ dw OWSequence_Clerk1 ; Pointer to OWScript
tx Text03b3
db $00
db $00
@@ -837,8 +837,8 @@ Clerk10Data:
db $00
db $00
db $00
-Clerk11Data:
- db CLERK11
+GiftCenterClerkData:
+ db GIFT_CENTER_CLERK
db $21
db $0a
db $30
@@ -891,7 +891,7 @@ Gal1Data:
db $00
db $16
db $00
- dw $60cf ; Pointer to OWScript
+ dw OWSequence_Gal1 ; Pointer to OWScript
tx Text03db
db $00
db $00
@@ -903,7 +903,7 @@ Lass1Data:
db $00
db $1e
db $00
- dw $6111 ; Pointer to OWScript
+ dw OWSequence_Lass1 ; Pointer to OWScript
tx Text03dc
db $00
db $00
@@ -1071,7 +1071,7 @@ Man2Data:
db $00
db $16
db $00
- dw $6137 ; Pointer to OWScript
+ dw OWSequence_Man2 ; Pointer to OWScript
tx Text03d8
db $00
db $00
@@ -1083,7 +1083,7 @@ Pappy2Data:
db $00
db $22
db $00
- dw $613b ; Pointer to OWScript
+ dw OWSequence_Pappy2 ; Pointer to OWScript
tx Text03dd
db $00
db $00
diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm
index 02ddc67..b573956 100644
--- a/src/engine/bank03.asm
+++ b/src/engine/bank03.asm
@@ -94,10 +94,10 @@ Func_c0ce: ; c0ce (3:40ce)
jp hl
PointerTable_c0e0: ; c0e0 (3:40e0)
- dw Func_c0e8
- dw Func_c0ed
- dw Func_c0f1
- dw Func_c10a
+ dw Func_c0e8 ; on map
+ dw Func_c0ed ; walking around
+ dw SetOWSequenceData ; beginning ows
+ dw EnterOWSequence ; mid-ows
Func_c0e8: ; c0e8 (3:40e8)
farcall Func_10e55
@@ -107,8 +107,8 @@ Func_c0ed: ; c0ed (3:40ed)
call Func_c510
ret
-Func_c0f1: ; c0f1 (3:40f1)
- ld a, [wd3b6]
+SetOWSequenceData: ; c0f1 (3:40f1)
+ ld a, [wScriptNPC]
ld [wLoadedNPCTempIndex], a
farcall SetNewOWSequenceNPC
ld a, c
@@ -117,9 +117,9 @@ Func_c0f1: ; c0f1 (3:40f1)
ld [wNextOWSequence+1], a
ld a, $3
ld [wd0bf], a
- jr Func_c10a
+ jr EnterOWSequence
-Func_c10a: ; c10a (3:410a)
+EnterOWSequence: ; c10a (3:410a)
ld hl, wNextOWSequence
ld a, [hli]
ld h, [hl]
@@ -134,7 +134,7 @@ CloseAdvancedDialogueBox: ; c111 (3:4111)
ld a, [wd0c1]
bit 1, a
jr z, .asm_c12a
- ld a, [wd3b6]
+ ld a, [wScriptNPC]
ld [wLoadedNPCTempIndex], a
farcall Func_1c5e9
.asm_c12a
@@ -582,7 +582,7 @@ Func_c4b9: ; c4b9 (3:44b9)
ld a, $0
farcall CreateSpriteAndAnimBufferEntry
ld a, [wWhichSprite]
- ld [wd336], a
+ ld [wPlayerSpriteIndex], a
ld b, $2
ld a, [wCurMap]
cp OVERWORLD_MAP
@@ -592,12 +592,12 @@ Func_c4b9: ; c4b9 (3:44b9)
.asm_c4ee
ld a, b
ld [wPlayerDirection], a
- call Func_c5e9
+ 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
@@ -607,41 +607,41 @@ Func_c4b9: ; c4b9 (3:44b9)
ret
Func_c510: ; c510 (3:4510)
- ld a, [wd336]
+ 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]
+ ld a, [wPlayerCurrentlyMoving]
or a
jr z, .asm_c535
bit 0, a
call nz, Func_c66c
- ld a, [wd335]
+ ld a, [wPlayerCurrentlyMoving]
bit 1, a
call nz, Func_c6dc
ret
.asm_c535
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
@@ -698,49 +698,50 @@ Func_c58b: ; c58b (3:458b)
Func_c5ac: ; 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
+ jr z, .done
call Func_c71e
- jr .asm_c5ca
-.asm_c5ca
+ jr .done
+.done
ret
-Func_c5cb: ; c5cb (3:45cb)
- call Func_c5d5
-Func_c5ce: ; c5ce (3:45ce)
+UpdatePlayerDirectionFromDPad: ; c5cb (3:45cb)
+ call GetDirectionFromDPad
+UpdatePlayerDirection: ; c5ce (3:45ce)
ld [wPlayerDirection], a
- call Func_c5e9
+ 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
@@ -750,25 +751,25 @@ Func_c5e9: ; c5e9 (3:45e9)
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)
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
@@ -784,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
@@ -801,15 +802,15 @@ AttemptScriptedMovement: ; c619 (3:4619)
pop hl
ret
-Func_c653: ; c653 (3:4653)
+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]
@@ -877,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
@@ -904,7 +905,7 @@ 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
@@ -917,7 +918,7 @@ Func_c6dc: ; c6dc (3:46dc)
ret
Func_c6f7: ; c6f7 (3:46f7)
- ld a, [wd336]
+ ld a, [wPlayerSpriteIndex]
ld [wWhichSprite], a
ld c, SPRITE_ANIM_FIELD_0F
call GetSpriteAnimBufferProperty
@@ -940,20 +941,22 @@ Func_c70d: ; c70d (3:470d)
pop hl
ret
+; Arrives here if A button is pressed when not moving + in map move state
Func_c71e: ; 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
+ jr z, .noNPC
+ farcall FindNPCAtLocation
+ jr c, .noNPC
ld a, [wLoadedNPCTempIndex]
- ld [wd3b6], a
- ld a, $2
+ ld [wScriptNPC], a
+ ld a, $2 ; start OWScript
jr .asm_c748
-.asm_c73d
+
+.noNPC
call Func_3a5e
jr nc, .asm_c746
ld a, $3
@@ -966,7 +969,7 @@ Func_c71e: ; c71e (3:471e)
scf
ret
-Func_c74d: ; c74d (3:474d)
+OpenStartMenu: ; c74d (3:474d)
push hl
push bc
push de
@@ -1061,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
@@ -1120,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
@@ -1153,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
@@ -1205,7 +1208,7 @@ SetNextNPCAndOWSequence: ; c926 (3:4926)
push bc
call FindLoadedNPC
ld a, [wLoadedNPCTempIndex]
- ld [wd3b6], a
+ ld [wScriptNPC], a
farcall SetNewOWSequenceNPC
pop bc
; fallthrough
@@ -1323,35 +1326,41 @@ 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
- get_flag_value EVENT_FLAG_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, [wTempMap]
cp [hl]
- jr z, .asm_c9f2
-.asm_ca04
+ jr z, .tryLoadImakuniLoop
+.finish
ld a, c
- set_flag_value EVENT_FLAG_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]
@@ -1499,52 +1508,60 @@ ZeroOutEventFlag: ; cad0 (3:4ad0)
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 GetEventFlagValue
- jr z, .asm_cae7
+ jr z, .noMedal
inc b
-
-.asm_cae7
+.noMedal
dec c
- jr nz, .asm_cae0
+ jr nz, .countMedalsLoop
+
ld c, b
- set_flag_value EVENT_FLAG_2E
+ 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
+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)
@@ -1567,10 +1584,10 @@ GetEventFlag: ; cb1d (3:4b1d)
; offset - bytes to set or reset
EventFlagMods: ; cb37 (3:4b37)
- flag_def $3f, %10000000 ; EVENT_FLAG_00
+ 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_FLAG_02
- flag_def $3f, %00010000 ; EVENT_FLAG_03
+ 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
@@ -1586,7 +1603,7 @@ EventFlagMods: ; cb37 (3:4b37)
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_FLAG_13
+ 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
@@ -1613,15 +1630,15 @@ EventFlagMods: ; cb37 (3:4b37)
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_FLAG_2E
+ 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_FLAG_34
+ flag_def $0b, %00001100 ; EVENT_IMAKUNI_ROOM
flag_def $0b, %00000011 ; EVENT_FLAG_35
- flag_def $0c, %11100000 ; EVENT_FLAG_36
+ 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
@@ -1687,7 +1704,8 @@ EventFlagMods: ; cb37 (3:4b37)
flag_def $1c, %11110000 ; EVENT_FLAG_75
flag_def $1c, %00001111 ; EVENT_FLAG_76
-Func_cc25: ; cc25 (3:4c25)
+; Used for basic level objects that just print text and quit
+PrintInteractableObjectText: ; cc25 (3:4c25)
ld hl, wd0ca
ld a, [hli]
ld h, [hl]
@@ -1705,12 +1723,14 @@ Func_cc32: ; cc32 (3:4c32)
pop hl
call Func_c8ba
ret
-; 0xcc3e
- INCROM $cc3e, $cc42
+Func_cc3e: ; 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 wBreakOWScriptLoop > 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
@@ -1728,8 +1748,7 @@ RST20: ; cc42 (3:4c42)
ld a, [hli]
ld c, a
ld b, [hl]
- push bc
- ret
+ retbc
IncreaseOWScriptPointerBy1: ; cc60 (3:4c60)
ld a, 1
@@ -1871,7 +1890,7 @@ OWScript_AskQuestionJump: ; cce9 (3:4ce9)
; sets a battle up, doesn't start until we break out of the script system.
OWScript_StartBattle: ; cd01 (3:4d01)
call Func_cd66
- ld a, [wd3b6]
+ ld a, [wScriptNPC]
ld l, LOADED_NPC_ID
call GetItemInLoadedNPCIndex
ld a, [hl]
@@ -1887,7 +1906,7 @@ OWScript_StartBattle: ; cd01 (3:4d01)
ld a, [hl]
ld [wcc19], a
.asm_cd26
- ld a, [wd3b6]
+ ld a, [wScriptNPC]
ld l, LOADED_NPC_ID
call GetItemInLoadedNPCIndex
ld a, [hl]
@@ -1970,7 +1989,8 @@ Func_cda8: ; cda8 (3:4da8)
call Func_c891
jp IncreaseOWScriptPointerBy5
-OWScript_PrintTextCloseBox: ; cdb9 (3:4db9)
+; Does not return to RST20 - pops an extra time to skip that.
+OWScript_PrintTextQuitFully: ; cdb9 (3:4db9)
ld l, c
ld h, b
call Func_cc32
@@ -1982,7 +2002,7 @@ OWScript_PrintTextCloseBox: ; cdb9 (3:4db9)
ret
Func_cdcb: ; cdcb (3:4dcb)
- ld a, [wd3b6]
+ ld a, [wScriptNPC]
ld [wLoadedNPCTempIndex], a
Func_cdd1: ; cdd1 (3:4dd1)
farcall Func_1c50a
@@ -2026,7 +2046,7 @@ Func_cdf5: ; cdf5 (3:4df5)
jp IncreaseOWScriptPointerBy3
Func_ce26: ; ce26 (3:4e26)
- ld a, [wd3b6]
+ ld a, [wScriptNPC]
ld [wLoadedNPCTempIndex], a
farcall Func_1c455
rlca
@@ -2048,7 +2068,7 @@ Func_ce3a: ; ce3a (3:4e3a)
jp IncreaseOWScriptPointerBy3
Func_ce4a: ; ce4a (3:4e4a)
- ld a, [wd3b6]
+ ld a, [wScriptNPC]
ld [wLoadedNPCTempIndex], a
jr Func_ce3a
@@ -2304,7 +2324,7 @@ Func_cfc0: ; cfc0 (3:4fc0)
jp SetOWScriptPointer
Func_cfc6: ; cfc6 (3:4fc6)
- ld a, [wd3b6]
+ ld a, [wScriptNPC]
ld [wLoadedNPCTempIndex], a
ld a, c
farcall Func_1c52e
@@ -2384,16 +2404,16 @@ OWScript_Jump: ; d049 (3:5049)
call GetOWSArgs1AfterPointer
jp SetOWScriptPointer
-Func_d04f: ; d04f (3:504f)
- call Func_cad8
+OWScript_TryGiveMedalPCPacks: ; d04f (3:504f)
+ call TryGiveMedalPCPacks
jp IncreaseOWScriptPointerBy1
OWScript_SetPlayerDirection: ; d055 (3:5055)
ld a, c
- call Func_c5ce
+ call UpdatePlayerDirection
jp IncreaseOWScriptPointerBy2
-; arg1 - Direction (index in ScriptedMovementOffsetTable)
+; arg1 - Direction (index in PlayerMovementOffsetTable)
; arg2 - Tiles Moves (Speed)
OWScript_MovePlayer: ; 505c (3:505c)
ld a, c
@@ -2405,7 +2425,7 @@ OWScript_MovePlayer: ; 505c (3:505c)
call DoFrameIfLCDEnabled
call SetScreenScroll
call Func_c53d
- ld a, [wd335]
+ ld a, [wPlayerCurrentlyMoving]
and $03
jr nz, .asm_d067
call DoFrameIfLCDEnabled
@@ -2425,11 +2445,11 @@ OWScript_SetNextNPCandOWSequence: ; d088 (3:5088)
jp IncreaseOWScriptPointerBy4
Func_d095: ; d095 (3:5095)
- ld a, [wd3b6]
+ ld a, [wScriptNPC]
ld [wLoadedNPCTempIndex], a
push bc
call GetOWSArgs3AfterPointer
- ld a, [wd3b6]
+ ld a, [wScriptNPC]
ld l, LOADED_NPC_FIELD_05
call GetItemInLoadedNPCIndex
res 4, [hl]
@@ -2449,7 +2469,7 @@ Func_d095: ; d095 (3:5095)
jp IncreaseOWScriptPointerBy4
Func_d0be: ; d0be (3:50be)
- ld a, [wd3b6]
+ ld a, [wScriptNPC]
ld [wLoadedNPCTempIndex], a
ld a, c
ld c, b
@@ -2466,7 +2486,7 @@ OWScript_DoFrames: ; d0ce (3:50ce)
jp IncreaseOWScriptPointerBy2
Func_d0d9: ; d0d9 (3:50d9)
- ld a, [wd3b6]
+ ld a, [wScriptNPC]
ld [wLoadedNPCTempIndex], a
ld d, c
ld e, b
@@ -2767,7 +2787,7 @@ Func_d317: ; d317 (3:5317)
set_flag_value EVENT_FLAG_75
jp IncreaseOWScriptPointerBy1
-
+Unknown_d32b: ; d32b (3:532b)
INCROM $d32b, $d336
OWScript_OpenDeckMachine: ; d336 (3:5336)
@@ -2851,9 +2871,9 @@ Func_d3b9: ; d3b9 (3:53b9)
set 6, [hl]
jp IncreaseOWScriptPointerBy1
-OWScript_GivePCPack: ; d3c9 (3:53c9)
+OWScript_TryGivePCPack: ; d3c9 (3:53c9)
ld a, c
- farcall GivePCPack
+ farcall TryGivePCPack
jp IncreaseOWScriptPointerBy2
OWScript_nop: ; d3d1 (3:53d1)
@@ -2892,10 +2912,10 @@ Func_d408: ; d408 (3:5408)
Func_d40f: ; d40f (3:540f)
ld a, c
- call Func_3c83
+ call CallPlaySong
jp IncreaseOWScriptPointerBy2
-Func_d416: ; d416 (3:5416)
+OWScript_PlaySFX: ; d416 (3:5416)
ld a, c
call PlaySFX
jp IncreaseOWScriptPointerBy2
@@ -2904,16 +2924,16 @@ Func_d41d: ; d41d (3:541d)
call Func_39fc
jp IncreaseOWScriptPointerBy1
-Func_d423: ; d423 (3:5423)
+OWScript_PauseSong: ; d423 (3:5423)
call PauseSong
jp IncreaseOWScriptPointerBy1
-Func_d429: ; d429 (3:5429)
+OWScript_ResumeSong: ; d429 (3:5429)
call ResumeSong
jp IncreaseOWScriptPointerBy1
-Func_d42f: ; d42f (3:542f)
- call Func_3c96
+OWScript_WaitForSongToFinish: ; d42f (3:542f)
+ call WaitForSongToFinish
jp IncreaseOWScriptPointerBy1
Func_d435: ; d435 (3:5435)
@@ -3322,7 +3342,312 @@ OWSequence_d827: ; d827 (3:5827)
run_script OWScript_QuitScriptFully
; 0xd82d
- INCROM $d82d, $dc68
+ INCROM $d82d, $d932
+
+OWSequence_d932: ; d932 (3:5932)
+ start_script
+ run_script Func_ccdc
+ tx Text0605
+ run_script OWScript_AskQuestionJumpDefaultYes
+ tx Text0606
+ dw .ows_d93c
+ run_script OWScript_QuitScriptFully
+
+.ows_d93c
+ run_script OWScript_OpenDeckMachine
+ db $09
+ run_script OWScript_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
+
+OWSequence_Ishihara: ; db4a (3:5b4a)
+ start_script
+ run_script OWScript_MaxOutFlagValue
+ db EVENT_FLAG_1D
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_1F
+ db $00
+ dw .ows_db80
+ run_script OWScript_JumpIfFlagNonzero2
+ db EVENT_FLAG_39
+ dw .ows_db5a
+ run_script OWScript_JumpIfFlagNonzero2
+ db EVENT_FLAG_22
+ dw .ows_dc3e
+.ows_db5a
+ run_script OWScript_JumpIfFlagNonzero2
+ db EVENT_FLAG_00
+ dw .ows_db90
+ run_script OWScript_JumpIfFlagZero2
+ db EVENT_FLAG_38
+ dw .ows_db90
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_1F
+ db $01
+ dw .ows_db93
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_1F
+ db $02
+ dw .ows_db93
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_1F
+ db $03
+ dw .ows_dbcc
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_1F
+ db $04
+ dw .ows_dbcc
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_1F
+ db $05
+ dw .ows_dc05
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_1F
+ db $06
+ dw .ows_dc05
+.ows_db80
+ run_script OWScript_MaxOutFlagValue
+ db EVENT_FLAG_00
+ run_script OWScript_SetFlagValue
+ db EVENT_FLAG_1F
+ db $01
+ run_script OWScript_ZeroOutFlagValue
+ db EVENT_FLAG_38
+ run_script OWScript_JumpIfFlagZero2
+ db EVENT_FLAG_22
+ dw .ows_db8d
+ run_script OWScript_MaxOutFlagValue
+ db EVENT_FLAG_39
+.ows_db8d
+ run_script OWScript_PrintTextQuitFully
+ tx Text0727
+
+.ows_db90
+ run_script OWScript_PrintTextQuitFully
+ tx Text0728
+
+.ows_db93
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_1F
+ db $01
+ dw NO_JUMP
+ run_script OWScript_PrintVariableText
+ tx Text0729
+ tx Text072a
+ run_script OWScript_SetFlagValue
+ db EVENT_FLAG_1F
+ db $02
+ run_script OWScript_AskQuestionJump
+ tx Text072b
+ dw .ows_dba8
+ run_script OWScript_PrintTextQuitFully
+ tx Text072c
+
+.ows_dba8
+ run_script Func_cf0c
+ db $ac
+ dw .ows_dbaf
+ run_script OWScript_PrintTextQuitFully
+ tx Text072d
+
+.ows_dbaf
+ run_script Func_cf12
+ db $ac
+ dw .ows_dbb6
+ run_script OWScript_PrintTextQuitFully
+ tx Text072e
+
+.ows_dbb6
+ run_script OWScript_MaxOutFlagValue
+ db EVENT_FLAG_00
+ run_script OWScript_SetFlagValue
+ db EVENT_FLAG_1F
+ db $03
+ run_script OWScript_ZeroOutFlagValue
+ db EVENT_FLAG_38
+ run_script OWScript_PrintTextString
+ tx Text072f
+ run_script Func_ccdc
+ tx Text0730
+ run_script OWScript_TakeCard
+ db CLEFABLE
+ run_script OWScript_GiveCard
+ db SURFING_PIKACHU1
+ run_script OWScript_ShowCardReceivedScreen
+ db SURFING_PIKACHU1
+ run_script OWScript_PrintTextQuitFully
+ tx Text0731
+
+.ows_dbcc
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_1F
+ db $03
+ dw NO_JUMP
+ run_script OWScript_PrintVariableText
+ tx Text0732
+ tx Text0733
+ run_script OWScript_SetFlagValue
+ db EVENT_FLAG_1F
+ db $04
+ run_script OWScript_AskQuestionJump
+ tx Text072b
+ dw .ows_dbe1
+ run_script OWScript_PrintTextQuitFully
+ tx Text072c
+
+.ows_dbe1
+ run_script Func_cf0c
+ db $bb
+ dw .ows_dbe8
+ run_script OWScript_PrintTextQuitFully
+ tx Text0734
+
+.ows_dbe8
+ run_script Func_cf12
+ db $bb
+ dw .ows_dbef
+ run_script OWScript_PrintTextQuitFully
+ tx Text0735
+
+.ows_dbef
+ run_script OWScript_MaxOutFlagValue
+ db EVENT_FLAG_00
+ run_script OWScript_SetFlagValue
+ db EVENT_FLAG_1F
+ db $05
+ run_script OWScript_ZeroOutFlagValue
+ db EVENT_FLAG_38
+ run_script OWScript_PrintTextString
+ tx Text072f
+ run_script Func_ccdc
+ tx Text0736
+ run_script OWScript_TakeCard
+ db DITTO
+ run_script OWScript_GiveCard
+ db FLYING_PIKACHU
+ run_script OWScript_ShowCardReceivedScreen
+ db FLYING_PIKACHU
+ run_script OWScript_PrintTextQuitFully
+ tx Text0737
+
+.ows_dc05
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_1F
+ db $05
+ dw NO_JUMP
+ run_script OWScript_PrintVariableText
+ tx Text0738
+ tx Text0739
+ run_script OWScript_SetFlagValue
+ db EVENT_FLAG_1F
+ db $06
+ run_script OWScript_AskQuestionJump
+ tx Text072b
+ dw .ows_dc1a
+ run_script OWScript_PrintTextQuitFully
+ tx Text072c
+
+.ows_dc1a
+ run_script Func_cf0c
+ db $b8
+ dw .ows_dc21
+ run_script OWScript_PrintTextQuitFully
+ tx Text073a
+
+.ows_dc21
+ run_script Func_cf12
+ db $b8
+ dw .ows_dc28
+ run_script OWScript_PrintTextQuitFully
+ tx Text073b
+
+.ows_dc28
+ run_script OWScript_MaxOutFlagValue
+ db EVENT_FLAG_00
+ run_script OWScript_SetFlagValue
+ db EVENT_FLAG_1F
+ db $07
+ run_script OWScript_ZeroOutFlagValue
+ db EVENT_FLAG_38
+ run_script OWScript_PrintTextString
+ tx Text072f
+ run_script Func_ccdc
+ tx Text073c
+ run_script OWScript_TakeCard
+ db CHANSEY
+ run_script OWScript_GiveCard
+ db SURFING_PIKACHU2
+ run_script OWScript_ShowCardReceivedScreen
+ db SURFING_PIKACHU2
+ run_script OWScript_PrintTextQuitFully
+ tx Text073d
+
+.ows_dc3e
+ run_script OWScript_MaxOutFlagValue
+ db EVENT_FLAG_39
+ run_script OWScript_PrintTextQuitFully
+ tx Text073e
+
+Preload_Ronald1InIshiharasHouse: ; dc43 (3:5c43)
+ get_flag_value EVENT_FLAG_22
+ cp $01
+ ccf
+ ret
+
+OWSequence_Ronald: ; dc4b (3:5c4b)
+ start_script
+ run_script OWScript_JumpIfFlagNonzero2
+ db EVENT_FLAG_4E
+ dw .ows_dc55
+ run_script OWScript_MaxOutFlagValue
+ db EVENT_FLAG_4E
+ run_script OWScript_PrintTextQuitFully
+ tx Text073f
+
+.ows_dc55
+ run_script OWScript_PrintTextString
+ tx Text0740
+ run_script OWScript_AskQuestionJump
+ tx Text0741
+ dw .ows_dc60
+ run_script OWScript_PrintTextQuitFully
+ tx Text0742
+
+.ows_dc60
+ run_script OWScript_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
+
+OWSequence_Clerk1: ; dc64 (3:5c64)
+ start_script
+ run_script OWScript_PrintTextQuitFully
+ tx Text045a
FightingClubLobbyAfterDuel: ; dc68 (3:5c68)
ld hl, .after_duel_table
@@ -3340,16 +3665,16 @@ FightingClubLobbyAfterDuel: ; dc68 (3:5c68)
OWSequence_Imakuni: ; dd0d (3:5d0d)
start_script
run_script OWScript_SetFlagValue
- db EVENT_FLAG_13
- db $02
+ db EVENT_IMAKUNI_STATE
+ db IMAKUNI_TALKED
run_script OWScript_JumpIfFlagZero2
- db EVENT_FLAG_02
+ db EVENT_TEMP_TALKED_TO_IMAKUNI
dw NO_JUMP
run_script OWScript_PrintVariableText
tx Text0467
tx Text0468
run_script OWScript_MaxOutFlagValue
- db EVENT_FLAG_02
+ db EVENT_TEMP_TALKED_TO_IMAKUNI
run_script OWScript_AskQuestionJump
tx Text0469
dw .declineDuel
@@ -3370,43 +3695,43 @@ OWSequence_Imakuni: ; dd0d (3:5d0d)
OWSequence_BeatImakuni: ; dd2d (3:5d2d)
start_script
run_script OWScript_JumpIfFlagEqual
- db EVENT_FLAG_36
+ db EVENT_IMAKUNI_WIN_COUNT
db $07
- dw .ows_dd3f
+ dw .giveBoosters
run_script OWScript_IncrementFlagValue
- db EVENT_FLAG_36
+ db EVENT_IMAKUNI_WIN_COUNT
run_script OWScript_JumpIfFlagEqual
- db EVENT_FLAG_36
+ db EVENT_IMAKUNI_WIN_COUNT
db $03
- dw .ows_dd46
+ dw .threeWins
run_script OWScript_JumpIfFlagEqual
- db EVENT_FLAG_36
+ db EVENT_IMAKUNI_WIN_COUNT
db $06
- dw .ows_dd4c
-.ows_dd3f
+ dw .sixWins
+.giveBoosters
run_script OWScript_PrintTextString
tx Text046c
run_script OWScript_GiveOneOfEachTrainerBooster
run_script OWScript_Jump
- dw .ows_dd56
+ dw .done
-.ows_dd46
+.threeWins
run_script OWScript_PrintTextString
tx Text046d
run_script OWScript_Jump
- dw .ows_dd4f
+ dw .giveImakuniCard
-.ows_dd4c
+.sixWins
run_script OWScript_PrintTextString
tx Text046e
-.ows_dd4f
+.giveImakuniCard
run_script OWScript_PrintTextString
tx Text046f
run_script OWScript_GiveCard
db IMAKUNI_CARD
run_script OWScript_ShowCardReceivedScreen
db IMAKUNI_CARD
-.ows_dd56
+.done
run_script OWScript_PrintTextString
tx Text0470
run_script OWScript_Jump
@@ -3439,14 +3764,140 @@ OWJump_ImakuniCommon: ; dd60 (3:5d60)
db $5d
run_script Func_cdcb
run_script OWScript_MaxOutFlagValue
- db EVENT_FLAG_03
+ db EVENT_TEMP_BATTLED_IMAKUNI
run_script Func_d408
db $09
run_script Func_d41d
run_script OWScript_QuitScriptFully
; 0xdd78
- INCROM $dd78, $e13f
+ INCROM $dd78, $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
+
+OWSequence_Gal1: ; e0cf (3:60cf)
+ start_script
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_12
+ db $02
+ dw .ows_e10e
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_12
+ db $00
+ dw NO_JUMP
+ run_script OWScript_PrintVariableText
+ tx Text041d
+ tx Text041e
+ run_script OWScript_SetFlagValue
+ db EVENT_FLAG_12
+ db $01
+ run_script OWScript_AskQuestionJump
+ tx Text041f
+ dw .ows_e0eb
+ run_script OWScript_PrintTextString
+ tx Text0420
+ run_script OWScript_QuitScriptFully
+
+.ows_e0eb
+ run_script Func_cf0c
+ db $59
+ dw .ows_e0f3
+ run_script OWScript_PrintTextString
+ tx Text0421
+ run_script OWScript_QuitScriptFully
+
+.ows_e0f3
+ run_script Func_cf12
+ db $59
+ dw .ows_e0fb
+ run_script OWScript_PrintTextString
+ tx Text0422
+ run_script OWScript_QuitScriptFully
+
+.ows_e0fb
+ run_script OWScript_SetFlagValue
+ db EVENT_FLAG_12
+ db $02
+ run_script OWScript_PrintTextString
+ tx Text0423
+ run_script Func_ccdc
+ tx Text0424
+ run_script OWScript_TakeCard
+ db LAPRAS
+ run_script OWScript_GiveCard
+ db ARCANINE1
+ run_script OWScript_ShowCardReceivedScreen
+ db ARCANINE1
+ run_script OWScript_PrintTextString
+ tx Text0425
+ run_script OWScript_QuitScriptFully
+
+.ows_e10e
+ run_script OWScript_PrintTextQuitFully
+ tx Text0426
+
+OWSequence_Lass1: ; e111 (3:6111)
+ start_script
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_14
+ db $01
+ dw .ows_e121
+ run_script OWScript_PrintTextString
+ tx Text0427
+ run_script OWScript_SetFlagValue
+ db EVENT_FLAG_14
+ db $01
+ run_script OWScript_SetFlagValue
+ db EVENT_IMAKUNI_STATE
+ db IMAKUNI_MENTIONED
+ run_script OWScript_QuitScriptFully
+
+.ows_e121
+ run_script OWScript_JumpIfFlagNotEqual
+ db EVENT_IMAKUNI_ROOM
+ db IMAKUNI_WATER_CLUB
+ dw .ows_e12d
+ run_script OWScript_JumpIfFlagNonzero2
+ db EVENT_TEMP_BATTLED_IMAKUNI
+ dw .ows_e12d
+ run_script OWScript_PrintTextQuitFully
+ tx Text0428
+
+.ows_e12d
+ run_script OWScript_PrintTextQuitFully
+ tx Text0429
+
+Preload_Man2InWaterClubLobby: ; e130 (3:6130)
+ get_flag_value EVENT_JOSHUA_STATE
+ cp JOSHUA_BEATEN
+ ret
+
+OWSequence_Man2: ; e137 (3:6137)
+ start_script
+ run_script OWScript_PrintTextQuitFully
+ tx Text042a
+
+OWSequence_Pappy2: ; e13b (3:613b)
+ start_script
+ run_script OWScript_PrintTextQuitFully
+ tx Text042b
WaterClubMovePlayer: ; e13f (3:613f)
ld a, [wPlayerYCoord]
@@ -3522,7 +3973,7 @@ OWSequence_BeatSara: ; e18c (3:618c)
OWSequence_LostToSara: ; e19a (03:619a)
start_script
- run_script OWScript_PrintTextCloseBox
+ run_script OWScript_PrintTextQuitFully
tx Text0432
OWSequence_Amanda: ; e19e (03:619e)
@@ -3560,7 +4011,7 @@ OWSequence_BeatAmanda: ; e1b3 (03:61b3)
OWSequence_LostToAmanda: ; e1c1 (03:61c1)
start_script
- run_script OWScript_PrintTextCloseBox
+ run_script OWScript_PrintTextQuitFully
tx Text0439
OWSequence_NotReadyToSeeAmy: ; e15c (03:6153)
@@ -3674,7 +4125,7 @@ OWSequence_Joshua:
.startDuel:
run_script OWScript_PrintTextString
tx Text0442
- run_script OWScript_GivePCPack
+ run_script OWScript_TryGivePCPack
db $04
run_script OWScript_StartBattle
db PRIZES_4
@@ -3782,8 +4233,7 @@ OWSequence_MeetAmy: ; e2d1 (3:62d1)
db $01
run_script Func_ce6f
db $21
- db $ab
- db $62
+ dw $62ab
run_script OWScript_PrintTextString
tx Text044e
run_script OWScript_Jump
@@ -3830,7 +4280,7 @@ OWSequence_BeatAmy: ; e322 (3:6322)
tx Text0454
run_script OWScript_MaxOutFlagValue
db EVENT_BEAT_AMY
- run_script Func_d04f
+ run_script OWScript_TryGiveMedalPCPacks
run_script Func_d125
db EVENT_BEAT_AMY
run_script Func_d435
@@ -4022,7 +4472,7 @@ OWSequence_BeatBrittany: ; e5ee (3:65ee)
OWSequence_LostToBrittany: ; e618 (3:6618)
start_script
- run_script OWScript_PrintTextCloseBox
+ run_script OWScript_PrintTextQuitFully
tx Text06e9
; 0xe61c
@@ -4317,7 +4767,22 @@ Func_f580: ; f580 (3:7580)
INCROM $f5b3, $f602
Func_f602: ; f602 (3:7602)
- INCROM $f602, $fc2b
+ INCROM $f602, $f631
+
+OWSequence_f631: ; f631 (3:7631)
+ start_script
+ run_script OWScript_PrintTextString
+ tx Text0508
+ run_script OWScript_CloseAdvancedTextBox
+ run_script OWScript_SetNextNPCandOWSequence
+ db $02
+ dw $763c
+ run_script OWScript_EndScriptLoop1
+
+ ret
+; 0xf63c
+
+ INCROM $f63c, $fc2b
Func_fc2b: ; fc2b (3:7c2b)
ld a, [wDuelResult]
@@ -4344,7 +4809,19 @@ PointerTable_fc4c: ; fc4c (3:7c4c)
dw Unknown_fc68
dw Unknown_fc60
- INCROM $fc52, $fc60
+OWSequence_fc52: ; fc52 (3:7c52)
+ start_script
+ run_script OWScript_PrintTextString
+ tx Text06c8
+ run_script OWScript_AskQuestionJumpDefaultYes
+ dw $0000
+ dw .ows_fc5e
+ run_script OWScript_PrintTextQuitFully
+ tx Text06c9
+
+.ows_fc5e
+ run_script Func_cd76
+ run_script OWScript_QuitScriptFully
Unknown_fc60: ; fc60 (3:7c60)
INCROM $fc60, $fc64
@@ -4353,7 +4830,117 @@ 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_script OWScript_JumpIfFlagNotEqual
+ db EVENT_FLAG_74
+ db $02
+ dw Func_fcad.ows_fcd5
+ run_script OWScript_PrintTextString
+ tx Text06cd
+ run_script Func_d39d
+ db $00
+ run_script OWScript_JumpIfFlagNotLessThan
+ db EVENT_FLAG_72
+ db $04
+ dw Func_fc7a.ows_fcaa
+ run_script OWScript_PrintTextString
+ tx Text06ce
+ run_script OWScript_AskQuestionJumpDefaultYes
+ tx Text06cf
+ dw .ows_fca0
+ run_script OWScript_PrintTextString
+ tx Text06d0
+ run_script OWScript_Jump
+ dw Func_fc7a.ows_fcaa
+
+.ows_fca0
+ run_script Func_d396
+ db $00
+ run_script OWScript_PlaySFX
+ db $56
+ run_script Func_ccdc
+ tx Text06d1
+ run_script Func_d39d
+ db $01
+ run_script OWScript_QuitScriptFully
+
+.ows_fcaa
+ run_script OWScript_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_script OWScript_PlaySFX
+ db $56
+ run_script Func_d396
+ db $00
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_72
+ db $00
+ dw .ows_fccc
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_72
+ db $02
+ dw .ows_fccf
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_72
+ db $03
+ dw .ows_fcd2
+ run_script OWScript_Jump
+ dw Func_fc7a.ows_fcaa
+
+.ows_fccc
+ run_script OWScript_PrintTextQuitFully
+ tx Text06d3
+
+.ows_fccf
+ run_script OWScript_PrintTextQuitFully
+ tx Text06d4
+
+.ows_fcd2
+ run_script OWScript_PrintTextQuitFully
+ tx Text06d5
+
+.ows_fcd5
+ run_script Func_ce6f
+ db $3c
+ dw Unknown_fce1
+ run_script OWScript_PrintTextString
+ tx Text06d6
+ run_script Func_ce6f
+ db $3c
+ dw Unknown_fce3
+ run_script OWScript_QuitScriptFully
+
+Unknown_fce1: ; fce1 (3:7ce1)
+ db $82, $ff
+
+Unknown_fce3: ; fce3 (3:7ce3)
+ db $80, $ff
+
+rept $31b
+ db $ff
+endr
diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm
index 1613204..b01c51b 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
@@ -240,7 +240,7 @@ Func_10756: ; 10756 (4:4756)
INCROM $10756, $10a70
; gives the pc pack described in a
-GivePCPack: ; 10a70 (4:4a70)
+TryGivePCPack: ; 10a70 (4:4a70)
push hl
push bc
push de
@@ -345,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
@@ -365,7 +365,7 @@ Func_10e71: ; 10e71 (4:4e71)
ldh a, [hKeysPressed]
and D_PAD
jr z, .asm_10e83
- farcall Func_c5d5
+ farcall GetDirectionFromDPad
ld [wPlayerDirection], a
call Func_10e97
jr .asm_10e96
@@ -551,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
@@ -583,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
@@ -673,7 +673,7 @@ Func_110a6: ; 110a6 (4:50a6)
xor a
ld [wd347], a
ld [wd348], a
- farcall Func_c5e9
+ farcall UpdatePlayerSprite
pop hl
ret
@@ -977,7 +977,7 @@ OverworldScriptTable: ; 1217b (4:617b)
dw OWScript_StartBattle
dw OWScript_PrintVariableText
dw Func_cda8
- dw OWScript_PrintTextCloseBox
+ dw OWScript_PrintTextQuitFully
dw Func_cdcb
dw Func_ce26
dw OWScript_CloseTextBox
@@ -997,7 +997,7 @@ OverworldScriptTable: ; 1217b (4:617b)
dw Func_d032
dw Func_d03f
dw OWScript_Jump
- dw Func_d04f
+ dw OWScript_TryGiveMedalPCPacks
dw OWScript_SetPlayerDirection
dw OWScript_MovePlayer
dw OWScript_ShowCardReceivedScreen
@@ -1035,18 +1035,18 @@ OverworldScriptTable: ; 1217b (4:617b)
dw Func_cd76
dw Func_d39d
dw Func_d3b9
- dw OWScript_GivePCPack
+ dw OWScript_TryGivePCPack
dw OWScript_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 OWScript_PlaySFX
+ dw OWScript_PauseSong
+ dw OWScript_ResumeSong
dw Func_d41d
- dw Func_d42f
+ dw OWScript_WaitForSongToFinish
dw Func_d435
dw OWScript_AskQuestionJumpDefaultYes
dw Func_d2f6
@@ -1561,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
@@ -1583,7 +1583,7 @@ Func_13485: ; 13485 (4:7485)
call PlaySong
ldtx hl, ConsecutiveWinRecordIncreasedText
call PrintScrollableText_NoTextBoxLabel
- call Func_3c96
+ call WaitForSongToFinish
call ResumeSong
ret
; 0x134b1
@@ -1591,5 +1591,8 @@ Func_13485: ; 13485 (4:7485)
INCROM $134b1, $1372f
INCLUDE "data/npc_map_data.asm"
+INCLUDE "data/level_objects.asm"
- INCROM $13b04, $14000
+rept $119
+ db $ff
+endr
diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm
index b5b9504..d655c42 100644
--- a/src/engine/bank07.asm
+++ b/src/engine/bank07.asm
@@ -388,8 +388,55 @@ 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
; Probably needs a new name. Loads data for NPC that the next OWSequence is for
; Sets direction, Loads Image data for it, loads name, and more
@@ -731,7 +778,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/home.asm b/src/engine/home.asm
index 4135afa..681069d 100644
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -10800,7 +10800,7 @@ GameEvent_Credits: ; 3911 (0:3911)
ret
Func_3917: ; 3917 (0:3917)
- ld a, $22
+ ld a, EVENT_FLAG_22
farcall GetEventFlagValue
call EnableSRAM
ld [s0a00a], a
@@ -10875,8 +10875,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
@@ -11062,30 +11062,30 @@ Func_3a4f: ; 3a4f (0:3a4f)
Func_3a5e: ; 3a5e (0:3a5e)
ldh a, [hBankROM]
push af
- ld l, $4
+ ld l, MAP_SCRIPT_PRESSED_A_1
call GetMapScriptPointer
- jr nc, .asm_3ab3
- ld a, BANK(Func_c653)
+ jr nc, .handleSecondAPressScript
+ ld a, BANK(FindPlayerMovementFromDirection)
call BankswitchROM
- call Func_c653
+ call FindPlayerMovementFromDirection
ld a, $4
call BankswitchROM
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 [wNextOWSequence], a
ld a, [hli]
@@ -11104,17 +11104,17 @@ Func_3a5e: ; 3a5e (0:3a5e)
call BankswitchROM
scf
ret
-.asm_3aab
+.noMatch
pop hl
ld bc, $0008
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_2
+ call CallMapScriptPointerIfExists
ret
; returns a map script pointer in hl given
@@ -11415,9 +11415,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)
@@ -11468,7 +11467,7 @@ DivideBCbyDE: ; 3c5a (0:3c5a)
jr nz, .asm_3c63
ret
-Func_3c83: ; 3c83 (0:3c83)
+CallPlaySong: ; 3c83 (0:3c83)
call PlaySong
ret
; 0x3c87
@@ -11478,18 +11477,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
diff --git a/src/macros/code.asm b/src/macros/code.asm
index 8f2bd0d..3441ec3 100644
--- a/src/macros/code.asm
+++ b/src/macros/code.asm
@@ -47,3 +47,9 @@ 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/scripts.asm b/src/macros/scripts.asm
index 942fb82..42ff187 100644
--- a/src/macros/scripts.asm
+++ b/src/macros/scripts.asm
@@ -22,7 +22,7 @@ ENDM
const OWScript_StartBattle_index ; $05
const OWScript_PrintVariableText_index ; $06
const Func_cda8_index ; $07
- const OWScript_PrintTextCloseBox_index ; $08
+ const OWScript_PrintTextQuitFully_index ; $08
const Func_cdcb_index ; $09
const Func_ce26_index ; $0a
const OWScript_CloseTextBox_index ; $0b
@@ -42,7 +42,7 @@ ENDM
const Func_d032_index ; $19
const Func_d03f_index ; $1a
const OWScript_Jump_index ; $1b
- const Func_d04f_index ; $1c
+ const OWScript_TryGiveMedalPCPacks_index ; $1c
const OWScript_SetPlayerDirection_index ; $1d
const OWScript_MovePlayer_index ; $1e
const OWScript_ShowCardReceivedScreen_index ; $1f
@@ -80,18 +80,18 @@ ENDM
const Func_cd76_index ; $3f
const Func_d39d_index ; $40
const Func_d3b9_index ; $41
- const OWScript_GivePCPack_index ; $42
+ const OWScript_TryGivePCPack_index ; $42
const OWScript_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 OWScript_PlaySFX_index ; $49
+ const OWScript_PauseSong_index ; $4a
+ const OWScript_ResumeSong_index ; $4b
const Func_d41d_index ; $4c
- const Func_d42f_index ; $4d
+ const OWScript_WaitForSongToFinish_index ; $4d
const Func_d435_index ; $4e
const OWScript_AskQuestionJumpDefaultYes_index ; $4f
const Func_d2f6_index ; $50
diff --git a/src/wram.asm b/src/wram.asm
index c3fb738..eea0f04 100644
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -1999,10 +1999,11 @@ wd333:: ; d333
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
@@ -2100,7 +2101,8 @@ wd3b3:: ; d3b3
ds $2
-wd3b6:: ; d3b6
+; ID of the NPC being interacted with in OWScript
+wScriptNPC:: ; d3b6
ds $1
wc3b7:: ; d3b7
@@ -2125,10 +2127,7 @@ 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