summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Martinek <andrewrmartinek@gmail.com>2019-10-24 17:45:50 -0400
committerAndrew Martinek <andrewrmartinek@gmail.com>2019-10-24 17:45:50 -0400
commit3ac91a513dc9351734927182e46b0acd010053cf (patch)
treef1ae669c0b6adaa77e0ed334542be18b2e72b6de /src
parent299f013b8b14184b9f06da3b89ba87ce2ba9e0f3 (diff)
Uncovered NPC Movement and named OWObjects
Diffstat (limited to 'src')
-rw-r--r--src/constants/map_constants.asm7
-rw-r--r--src/constants/misc_constants.asm5
-rw-r--r--src/constants/script_constants.asm3
-rw-r--r--src/data/level_objects.asm40
-rw-r--r--src/data/map_scripts.asm42
-rw-r--r--src/engine/bank03.asm546
-rw-r--r--src/engine/bank04.asm2
-rw-r--r--src/engine/bank20.asm26
-rw-r--r--src/engine/home.asm16
-rw-r--r--src/macros/scripts.asm2
-rw-r--r--src/wram.asm10
11 files changed, 512 insertions, 187 deletions
diff --git a/src/constants/map_constants.asm b/src/constants/map_constants.asm
index 5e01d0a..92eaf4c 100644
--- a/src/constants/map_constants.asm
+++ b/src/constants/map_constants.asm
@@ -35,14 +35,17 @@
const HALL_OF_HONOR ; $21
+; Size of map data. See data/npc_map_data.asm and data/level_objects.asm
+; for more info on what these represent
NPC_MAP_SIZE EQU $06
+LEVEL_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_PRESSED_A_1 EQU $04
-MAP_SCRIPT_PRESSED_A_2 EQU $06
+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
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/script_constants.asm b/src/constants/script_constants.asm
index 2ce9a54..05aaf57 100644
--- a/src/constants/script_constants.asm
+++ b/src/constants/script_constants.asm
@@ -33,7 +33,7 @@
const EVENT_FLAG_1F ; $1f
const EVENT_FLAG_20 ; $20
const EVENT_FLAG_21 ; $21
- const EVENT_FLAG_22 ; $22
+ const EVENT_RECEIVED_LEGEND_CARDS ; $22
const EVENT_FLAG_23 ; $23
const EVENT_FLAG_24 ; $24
const EVENT_FLAG_25 ; $25
@@ -144,3 +144,4 @@ 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/level_objects.asm b/src/data/level_objects.asm
index a0d51cc..0756f7f 100644
--- a/src/data/level_objects.asm
+++ b/src/data/level_objects.asm
@@ -1,4 +1,10 @@
-LevelObjects_13b04: ; 13b04 (3:7b04)
+; 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
@@ -42,7 +48,7 @@ LevelObjects_13b04: ; 13b04 (3:7b04)
db $ff
-LevelObjects_13b4d: ; 13b4d (3:7b4d)
+DeckMachineRoomObjects: ; 13b4d (3:7b4d)
db NORTH, 2, 2
dw OWSequence_d932
tx Text041b
@@ -146,7 +152,7 @@ LevelObjects_13b4d: ; 13b4d (3:7b4d)
db $ff
-LevelObjects_13c02: ; 13c02 (3:7c02)
+IshiharasHouseObjects: ; 13c02 (3:7c02)
db NORTH, 6, 2
dw PrintInteractableObjectText
tx Text04ae
@@ -210,7 +216,7 @@ LevelObjects_13c02: ; 13c02 (3:7c02)
db $ff
-LevelObjects_13c6f: ; 13c6f (3:7c6f)
+FightingClubLobbyObjects: ; 13c6f (3:7c6f)
db NORTH, 20, 2
dw PrintInteractableObjectText
tx Text04c6
@@ -244,7 +250,7 @@ LevelObjects_13c6f: ; 13c6f (3:7c6f)
db $ff
-LevelObjects_13ca6: ; 13ca6 (3:7ca6)
+RockClubLobbyObjects: ; 13ca6 (3:7ca6)
db NORTH, 20, 2
dw PrintInteractableObjectText
tx Text04cc
@@ -278,7 +284,7 @@ LevelObjects_13ca6: ; 13ca6 (3:7ca6)
db $ff
-LevelObjects_13cdd: ; 13cdd (3:7cdd)
+WaterClubLobbyObjects: ; 13cdd (3:7cdd)
db NORTH, 20, 2
dw PrintInteractableObjectText
tx Text04d2
@@ -312,7 +318,7 @@ LevelObjects_13cdd: ; 13cdd (3:7cdd)
db $ff
-LevelObjects_13d14: ; 13d14 (3:7d14)
+LightningClubLobbyObjects: ; 13d14 (3:7d14)
db NORTH, 20, 2
dw PrintInteractableObjectText
tx Text04d8
@@ -346,7 +352,7 @@ LevelObjects_13d14: ; 13d14 (3:7d14)
db $ff
-LevelObjects_13d4b: ; 13d4b (3:7d4b)
+GrassClubLobbyObjects: ; 13d4b (3:7d4b)
db NORTH, 20, 2
dw PrintInteractableObjectText
tx Text04de
@@ -380,7 +386,7 @@ LevelObjects_13d4b: ; 13d4b (3:7d4b)
db $ff
-LevelObjects_13d82: ; 13d82 (3:7d82)
+PsychicClubLobbyObjects: ; 13d82 (3:7d82)
db NORTH, 20, 2
dw PrintInteractableObjectText
tx Text04e4
@@ -414,7 +420,7 @@ LevelObjects_13d82: ; 13d82 (3:7d82)
db $ff
-LevelObjects_13db9: ; 13db9 (3:7db9)
+ScienceClubLobbyObjects: ; 13db9 (3:7db9)
db NORTH, 20, 2
dw PrintInteractableObjectText
tx Text04ea
@@ -448,7 +454,7 @@ LevelObjects_13db9: ; 13db9 (3:7db9)
db $ff
-LevelObjects_13df0: ; 13df0 (3:7df0)
+FireClubLobbyObjects: ; 13df0 (3:7df0)
db NORTH, 20, 2
dw PrintInteractableObjectText
tx Text04f0
@@ -482,7 +488,7 @@ LevelObjects_13df0: ; 13df0 (3:7df0)
db $ff
-LevelObjects_13e27: ; 13e27 (3:7e27)
+ChallengeHallLobbyObjects: ; 13e27 (3:7e27)
db NORTH, 20, 2
dw PrintInteractableObjectText
tx Text04f6
@@ -516,7 +522,7 @@ LevelObjects_13e27: ; 13e27 (3:7e27)
db $ff
-LevelObjects_13e5e: ; 13e5e (3:7e5e)
+PokemonDomeEntranceObjects: ; 13e5e (3:7e5e)
db NORTH, 2, 2
dw PrintInteractableObjectText
tx Text04fc
@@ -576,14 +582,16 @@ LevelObjects_13e5e: ; 13e5e (3:7e5e)
db $ff
-LevelObjects_13ec2: ; 13ec2 (3:7ec2)
+HallOfHonorObjects: ; 13ec2 (3:7ec2)
+ ; Legendary Cards
db NORTH, 10, 10
- dw $7bf1
+ dw OWSequence_fbf1
dw $0000
dw $0000
+ ; Legendary Cards
db NORTH, 12, 10
- dw $7bf1
+ dw OWSequence_fbf1
dw $0000
dw $0000
diff --git a/src/data/map_scripts.asm b/src/data/map_scripts.asm
index bd0229d..8a3dad7 100644
--- a/src/data/map_scripts.asm
+++ b/src/data/map_scripts.asm
@@ -4,8 +4,8 @@
; if a script pointer is $0000, that map has no script for that event
; 0: NPC data
; 2: Called after every NPC is loaded (unused)
-; 4: pressed A button
-; 6: pressed A button
+; 4: Interactable Objects
+; 6: pressed A button (if nothing interactable is found)
; 8: load map
; a: after duel
; c: moved player
@@ -25,17 +25,17 @@ MapScripts: ; 1162a (4:562a)
; MASON_LABORATORY
dw MasonLabNPCS
dw $0000
- dw $7b04
- dw $5565
- dw $5549
+ dw MasonLabObjects
+ dw MasonLabPressedA
+ dw MasonLabLoadMap
dw MasonLaboratoryAfterDuel
dw $0000
- dw $555e
+ dw MasonLabCloseTextBox
; DECK_MACHINE_ROOM
dw DeckMachineRoomNPCS
dw $0000
- dw $7b4d
+ dw DeckMachineRoomObjects
dw $0000
dw $0000
dw $589f
@@ -45,7 +45,7 @@ MapScripts: ; 1162a (4:562a)
; ISHIHARAS_HOUSE
dw IshiharasHouseNPCS
dw $0000
- dw $7c02
+ dw IshiharasHouseObjects
dw $0000
dw $0000
dw $0000
@@ -65,7 +65,7 @@ MapScripts: ; 1162a (4:562a)
; FIGHTING_CLUB_LOBBY
dw FightingClubLobbyNPCS
dw $0000
- dw $7c6f
+ dw FightingClubLobbyObjects
dw $0000
dw $0000
dw FightingClubLobbyAfterDuel
@@ -95,7 +95,7 @@ MapScripts: ; 1162a (4:562a)
; ROCK_CLUB_LOBBY
dw RockClubLobbyNPCS
dw $0000
- dw $7ca6
+ dw RockClubLobbyObjects
dw $0000
dw $0000
dw $5ed5
@@ -125,7 +125,7 @@ MapScripts: ; 1162a (4:562a)
; WATER_CLUB_LOBBY
dw WaterClubLobbyNPCS
dw $0000
- dw $7cdd
+ dw WaterClubLobbyObjects
dw $0000
dw $0000
dw $60a2
@@ -155,7 +155,7 @@ MapScripts: ; 1162a (4:562a)
; LIGHTNING_CLUB_LOBBY
dw LightningClubLobbyNPCS
dw $0000
- dw $7d14
+ dw LightningClubLobbyObjects
dw $0000
dw $0000
dw $636d
@@ -185,7 +185,7 @@ MapScripts: ; 1162a (4:562a)
; GRASS_CLUB_LOBBY
dw GrassClubLobbyNPCS
dw $0000
- dw $7d4b
+ dw GrassClubLobbyObjects
dw $0000
dw $0000
dw GrassClubLobbyAfterDuel
@@ -215,7 +215,7 @@ MapScripts: ; 1162a (4:562a)
; PSYCHIC_CLUB_LOBBY
dw PsychicClubLobbyNPCS
dw $0000
- dw $7d82
+ dw PsychicClubLobbyObjects
dw $0000
dw $6971
dw $6963
@@ -245,7 +245,7 @@ MapScripts: ; 1162a (4:562a)
; SCIENCE_CLUB_LOBBY
dw ScienceClubLobbyNPCS
dw $0000
- dw $7db9
+ dw ScienceClubLobbyObjects
dw $0000
dw $0000
dw $6b57
@@ -275,8 +275,8 @@ MapScripts: ; 1162a (4:562a)
; FIRE_CLUB_LOBBY
dw FireClubLobbyNPCS
dw $0000
- dw $7df0
- dw $6d57
+ dw FireClubLobbyObjects
+ dw FireClubPressedA
dw $0000
dw $6d49
dw $0000
@@ -305,7 +305,7 @@ MapScripts: ; 1162a (4:562a)
; CHALLENGE_HALL_LOBBY
dw ChallengeHallLobbyNPCS
dw $0000
- dw $7e27
+ dw ChallengeHallLobbyObjects
dw $0000
dw $7088
dw $0000
@@ -325,7 +325,7 @@ MapScripts: ; 1162a (4:562a)
; POKEMON_DOME_ENTRANCE
dw PokemonDomeEntranceNPCS
dw $0000
- dw $7e5e
+ dw PokemonDomeEntranceObjects
dw $0000
dw $7607
dw $0000
@@ -345,9 +345,9 @@ MapScripts: ; 1162a (4:562a)
; HALL_OF_HONOR
dw HallOfHonorNPCS
dw $0000
- dw $7ec2
+ dw HallOfHonorObjects
dw $0000
- dw $7bdb
+ dw HallOfHonorLoadMap
dw $0000
dw $0000
dw $0000
diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm
index b573956..651109d 100644
--- a/src/engine/bank03.asm
+++ b/src/engine/bank03.asm
@@ -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,18 +93,18 @@ Func_c0ce: ; c0ce (3:40ce)
ld l, a
jp hl
-PointerTable_c0e0: ; c0e0 (3:40e0)
+OverworldModePointers: ; c0e0 (3:40e0)
dw Func_c0e8 ; on map
- dw Func_c0ed ; walking around
- dw SetOWSequenceData ; beginning ows
- dw EnterOWSequence ; mid-ows
+ dw CallHandlePlayerMoveMode
+ dw SetOWSequenceData
+ dw EnterOWSequence
Func_c0e8: ; c0e8 (3:40e8)
farcall Func_10e55
ret
-Func_c0ed: ; c0ed (3:40ed)
- call Func_c510
+CallHandlePlayerMoveMode: ; c0ed (3:40ed)
+ call HandlePlayerMoveMode
ret
SetOWSequenceData: ; c0f1 (3:40f1)
@@ -116,7 +116,7 @@ SetOWSequenceData: ; c0f1 (3:40f1)
ld a, b
ld [wNextOWSequence+1], a
ld a, $3
- ld [wd0bf], a
+ ld [wOverworldMode], a
jr EnterOWSequence
EnterOWSequence: ; c10a (3:410a)
@@ -141,7 +141,7 @@ CloseAdvancedDialogueBox: ; c111 (3:4111)
xor a
ld [wd0c1], a
ld a, [wd0c0]
- ld [wd0bf], a
+ ld [wOverworldMode], a
ret
; redraws the background and removes textbox control
@@ -189,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
@@ -204,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
@@ -606,24 +606,24 @@ Func_c4b9: ; c4b9 (3:44b9)
.asm_c50f
ret
-Func_c510: ; c510 (3:4510)
+HandlePlayerMoveMode: ; c510 (3:4510)
ld a, [wPlayerSpriteIndex]
ld [wWhichSprite], a
ld a, [wPlayerCurrentlyMoving]
bit 4, a
ret nz
bit 0, a
- call z, Func_c5ac
+ call z, HandlePlayerMoveModeInput
ld a, [wPlayerCurrentlyMoving]
or a
- jr z, .asm_c535
+ jr z, .notMoving
bit 0, a
call nz, Func_c66c
ld a, [wPlayerCurrentlyMoving]
bit 1, a
call nz, Func_c6dc
ret
-.asm_c535
+.notMoving
ldh a, [hKeysPressed]
and START
call nz, OpenStartMenu
@@ -695,7 +695,7 @@ 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, .skipMoving
@@ -708,7 +708,7 @@ Func_c5ac: ; c5ac (3:45ac)
ldh a, [hKeysPressed]
and A_BUTTON
jr z, .done
- call Func_c71e
+ call FindNPCOrObject
jr .done
.done
ret
@@ -911,7 +911,7 @@ Func_c6dc: ; c6dc (3:46dc)
call Func_c6f7
call Func_3997
call Func_c70d
- ld a, [wd0bf]
+ ld a, [wOverworldMode]
cp $1
call z, Func_c9c0
pop hl
@@ -942,7 +942,7 @@ Func_c70d: ; c70d (3:470d)
ret
; Arrives here if A button is pressed when not moving + in map move state
-Func_c71e: ; c71e (3:471e)
+FindNPCOrObject: ; c71e (3:471e)
ld a, $ff
ld [wScriptNPC], a
call FindPlayerMovementFromDirection
@@ -953,19 +953,19 @@ Func_c71e: ; c71e (3:471e)
jr c, .noNPC
ld a, [wLoadedNPCTempIndex]
ld [wScriptNPC], a
- ld a, $2 ; start OWScript
- jr .asm_c748
+ ld a, OWMODE_START_SCRIPT
+ jr .changeStateExit
.noNPC
- call Func_3a5e
- jr nc, .asm_c746
- ld a, $3
- jr .asm_c748
-.asm_c746
+ 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
@@ -1220,7 +1220,7 @@ SetNextOWSequence: ; c935 (3:4935)
inc hl
ld [hl], b
ld a, $3
- ld [wd0bf], a
+ ld [wOverworldMode], a
pop hl
ret
@@ -1366,7 +1366,7 @@ Func_ca0e: ; ca0e (3:4a0e)
ld a, [wd32e]
cp $b
jr z, .asm_ca68
- get_flag_value EVENT_FLAG_22
+ get_flag_value EVENT_RECEIVED_LEGEND_CARDS
or a
jr nz, .asm_ca4a
get_flag_value EVENT_FLAG_40
@@ -1618,7 +1618,7 @@ EventFlagMods: ; cb37 (3:4b37)
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_FLAG_22
+ flag_def $06, %00000010 ; EVENT_RECEIVED_LEGEND_CARDS
flag_def $06, %00000001 ; EVENT_FLAG_23
flag_def $07, %11000000 ; EVENT_FLAG_24
flag_def $07, %00100000 ; EVENT_FLAG_25
@@ -1706,7 +1706,7 @@ EventFlagMods: ; cb37 (3:4b37)
; Used for basic level objects that just print text and quit
PrintInteractableObjectText: ; cc25 (3:4c25)
- ld hl, wd0ca
+ ld hl, wDefaultObjectText
ld a, [hli]
ld h, [hl]
ld l, a
@@ -2059,7 +2059,9 @@ Func_ce26: ; ce26 (3:4e26)
inc hl
ld b, [hl]
-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
@@ -2067,11 +2069,15 @@ Func_ce3a: ; ce3a (3:4e3a)
jr nz, .asm_ce3e
jp IncreaseOWScriptPointerBy3
-Func_ce4a: ; ce4a (3:4e4a)
+; Begin a series of NPC movements on the currently talking NPC
+; based on the series of directions pointed to by bc
+OWScript_MoveActiveNPC: ; ce4a (3:4e4a)
ld a, [wScriptNPC]
ld [wLoadedNPCTempIndex], a
- jr Func_ce3a
+ jr ExecuteNPCMovement
+; Begin a series of NPC movements on an arbitrary NPC
+; based on the series of directions pointed to by bc
Func_ce52: ; ce52 (3:4e52)
ld a, [wLoadedNPCTempIndex]
push af
@@ -2081,7 +2087,7 @@ Func_ce52: ; ce52 (3:4e52)
asm_ce5d
ld [wTempNPC], a
call FindLoadedNPC
- call Func_ce3a
+ call ExecuteNPCMovement
pop af
ld [wTempNPC], a
pop af
@@ -2652,16 +2658,30 @@ 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 MaxOutEventFlag
pop bc
- ld hl, $5234
+ ld hl, LegendCards
ld a, c
jr asm_d1c6
- INCROM $d234, $d244
+LegendCards: ; 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
@@ -3130,9 +3150,41 @@ MasonLaboratoryAfterDuel: ; d53b (3:553b)
dw $569f
db $00
- INCROM $d549, $d753
+MasonLabLoadMap: ; d549 (3:5549)
+ get_flag_value EVENT_FLAG_3E
+ cp $03
+ ret nc
+ ld a, DRMASON
+ ld [wTempNPC], a
+ call FindLoadedNPC
+ ld bc, OWSequence_EnterLabFirstTime
+ jp SetNextNPCAndOWSequence
+
+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_LEGEND_CARDS
+ or a
+ ret z
+ ld hl, ChallengeMachineObjectTable
+ call FindExtraInteractableObjects
+ ret
+
+ChallengeMachineObjectTable: ; d572 (3:5572)
+ db 10, 4, NORTH
+ dw OWSequence_d57d
+ db 12, 4, NORTH
+ dw OWSequence_d57d
+ db $00
+
+OWSequence_d57d: ; d57d (3:557d)
+ INCROM $d57d, $d753
-OWSequence_d753: ; d753 (3:5753)
+OWSequence_EnterLabFirstTime: ; d753 (3:5753)
start_script
run_script OWScript_MovePlayer
db NORTH
@@ -3172,9 +3224,8 @@ OWSequence_d753: ; d753 (3:5753)
OWSequence_d779: ; d779 (03:5779)
start_script
- run_script Func_ce4a ; handles some sort of npc movement, and rotation?
- db $80
- db $58
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_d880
run_script OWScript_PrintTextString
tx Text05e4
run_script OWScript_SetDialogName
@@ -3182,9 +3233,8 @@ OWSequence_d779: ; d779 (03:5779)
run_script OWScript_PrintTextString
tx Text05e5
run_script OWScript_CloseTextBox
- run_script Func_ce4a
- db $82
- db $58
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_d882
run_script Func_cfc6
db $01
run_script OWScript_SetPlayerDirection
@@ -3198,11 +3248,10 @@ OWSequence_d779: ; d779 (03:5779)
OWSequence_d794: ; d794 (3:5794)
start_script
- run_script Func_ce4a
- db $8b
- db $58
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_d88b
run_script OWScript_DoFrames
- db $28
+ db 40
run_script OWScript_PrintTextString
tx Text05e6
run_script OWScript_CloseTextBox
@@ -3225,9 +3274,8 @@ OWSequence_d794: ; d794 (3:5794)
db $01
run_script OWScript_SetPlayerDirection
db WEST
- run_script Func_ce4a
- db $94
- db $58
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_d894
run_script OWScript_PrintTextString
tx Text05e7
run_script OWScript_SetDialogName
@@ -3342,7 +3390,39 @@ OWSequence_d827: ; d827 (3:5827)
run_script OWScript_QuitScriptFully
; 0xd82d
- INCROM $d82d, $d932
+ 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
OWSequence_d932: ; d932 (3:5932)
start_script
@@ -3394,7 +3474,7 @@ OWSequence_Ishihara: ; db4a (3:5b4a)
db EVENT_FLAG_39
dw .ows_db5a
run_script OWScript_JumpIfFlagNonzero2
- db EVENT_FLAG_22
+ db EVENT_RECEIVED_LEGEND_CARDS
dw .ows_dc3e
.ows_db5a
run_script OWScript_JumpIfFlagNonzero2
@@ -3436,7 +3516,7 @@ OWSequence_Ishihara: ; db4a (3:5b4a)
run_script OWScript_ZeroOutFlagValue
db EVENT_FLAG_38
run_script OWScript_JumpIfFlagZero2
- db EVENT_FLAG_22
+ db EVENT_RECEIVED_LEGEND_CARDS
dw .ows_db8d
run_script OWScript_MaxOutFlagValue
db EVENT_FLAG_39
@@ -3611,7 +3691,7 @@ OWSequence_Ishihara: ; db4a (3:5b4a)
tx Text073e
Preload_Ronald1InIshiharasHouse: ; dc43 (3:5c43)
- get_flag_value EVENT_FLAG_22
+ get_flag_value EVENT_RECEIVED_LEGEND_CARDS
cp $01
ccf
ret
@@ -3759,9 +3839,8 @@ OWJump_ImakuniCommon: ; dd60 (3:5d60)
db $01
.ows_dd6e
- run_script Func_ce4a
- db $78
- db $5d
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_dd78
run_script Func_cdcb
run_script OWScript_MaxOutFlagValue
db EVENT_TEMP_BATTLED_IMAKUNI
@@ -3771,7 +3850,19 @@ OWJump_ImakuniCommon: ; dd60 (3:5d60)
run_script OWScript_QuitScriptFully
; 0xdd78
- INCROM $dd78, $e0b0
+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
@@ -4014,66 +4105,103 @@ OWSequence_LostToAmanda: ; e1c1 (03:61c1)
run_script OWScript_PrintTextQuitFully
tx Text0439
-OWSequence_NotReadyToSeeAmy: ; e15c (03:6153)
+OWSequence_NotReadyToSeeAmy: ; e1c5 (03:61c5)
start_script
run_script OWScript_JumpIfPlayerCoordMatches
db $12
db $08
- dw $61ec
+ dw .ows_e1ec
run_script OWScript_JumpIfPlayerCoordMatches
db $14
db $08
- dw $61f2
+ dw .ows_e1f2
run_script OWScript_JumpIfPlayerCoordMatches
db $18
db $08
- dw $61f8
+ dw .ows_e1f8
+.ows_e1d5
run_script OWScript_MovePlayer
db SOUTH
db $04
- run_script Func_ce4a
- db $13
- db $62
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_e213
run_script OWScript_PrintTextString
tx Text043a
run_script OWScript_JumpIfPlayerCoordMatches
db $12
db $0a
- dw $61fe
+ dw .ows_e1fe
run_script OWScript_JumpIfPlayerCoordMatches
db $14
db $0a
- dw $6202
- run_script Func_ce4a
- db $15
- db $62
+ dw .ows_e202
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_e215
run_script OWScript_QuitScriptFully
.ows_e1ec
- run_script Func_ce4a
- db $06
- db $62
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_e206
run_script OWScript_Jump
- dw $61d5
- run_script Func_ce4a
- db $0b
- db $62
+ dw .ows_e1d5
+.ows_e1f2
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_e20b
run_script OWScript_Jump
- dw $61d5
- run_script Func_ce4a
- db $0f
- db $62
+ dw .ows_e1d5
+.ows_e1f8
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_e20f
run_script OWScript_Jump
- dw $61d5
- run_script Func_ce4a
- db $18
- db $62
+ dw .ows_e1d5
+.ows_e1fe
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_e218
run_script OWScript_QuitScriptFully
-; 0xe202
- INCROM $e202, $e21c
+.ows_e202
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_e219
+ run_script OWScript_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
-OWSequence_Joshua:
+OWSequence_Joshua: ; e21c (3:621c)
start_script
run_script OWScript_JumpIfFlagZero2
db EVENT_BEAT_AMANDA
@@ -4539,9 +4667,8 @@ OWSequence_FirstRonaldEncounter: ; e862 (3:6862)
start_script
run_script OWScript_MaxOutFlagValue
db EVENT_FLAG_4B
- run_script Func_ce4a
- db $94
- db $68
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_e894
run_script Func_d135
db $00
run_script OWScript_PrintTextString
@@ -4575,26 +4702,31 @@ OWSequence_FirstRonaldEncounter: ; e862 (3:6862)
run_script OWScript_MovePlayer
db EAST
db $04
- run_script Func_ce4a
- db $94
- db $68
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_e894
run_script Func_cdcb
run_script Func_d41d
run_script OWScript_QuitScriptFully
-; 0xe894
- INCROM $e894, $e8c0
+NPCMovement_e894: ; e894 (3:6894)
+ db SOUTH
+ db SOUTH
+ db SOUTH
+ db SOUTH
+ db SOUTH
+ db $ff
+; e89a
+
+ INCROM $e89a, $e8c0
OWSequence_FirstRonaldFight: ; e8c0 (3:68c0)
start_script
- run_script Func_ce4a
- db $05
- db $69
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_e905
run_script OWScript_DoFrames
db $3c
- run_script Func_ce4a
- db $0d
- db $69
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_e90d
run_script OWScript_PrintTextString
tx Text064a
run_script OWScript_JumpIfPlayerCoordMatches
@@ -4602,12 +4734,12 @@ OWSequence_FirstRonaldFight: ; e8c0 (3:68c0)
db $02
dw $68d6
run_script OWScript_SetPlayerDirection
- db $03
+ db WEST
run_script OWScript_MovePlayer
db WEST
db $01
run_script OWScript_SetPlayerDirection
- db $02
+ db SOUTH
run_script OWScript_MovePlayer
db SOUTH
db $01
@@ -4648,26 +4780,45 @@ OWJump_FinishedFirstRonaldFight
db EVENT_FLAG_4C
db $02
run_script OWScript_CloseTextBox
- run_script Func_ce4a
- db $0f
- db $69
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_e90f
run_script Func_cdcb
run_script Func_d41d
run_script OWScript_QuitScriptFully
-; 0xe905
- INCROM $e905, $e91e
+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
OWSequenceSecondRonaldFight: ; e91e (3:691e)
start_script
- run_script Func_ce4a
- db $05
- db $69
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_e905
run_script OWScript_DoFrames
db 60
- run_script Func_ce4a
- db $0d
- db $69
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_e90d
run_script OWScript_PrintTextString
tx Text064f
run_script OWScript_JumpIfPlayerCoordMatches
@@ -4675,13 +4826,13 @@ OWSequenceSecondRonaldFight: ; e91e (3:691e)
db $02
dw .ows_6934
run_script OWScript_SetPlayerDirection
- db $03
+ db WEST
run_script OWScript_MovePlayer
db WEST
db $01
.ows_6934
run_script OWScript_SetPlayerDirection
- db $02
+ db SOUTH
run_script OWScript_MovePlayer
db SOUTH
db $01
@@ -4722,15 +4873,85 @@ OWJump_FinishedSecondRonaldFight ; e959 (3:6959)
db EVENT_FLAG_4D
db $02
run_script OWScript_CloseTextBox
- run_script Func_ce4a
- db $0f
- db $69
+ run_script OWScript_MoveActiveNPC
+ dw NPCMovement_e90f
run_script Func_cdcb
run_script Func_d41d
run_script OWScript_QuitScriptFully
; 0xe963
- INCROM $e963, $f580
+ INCROM $e963, $ed57
+
+FireClubPressedA: ; ed57 (3:6d57)
+ ld hl, SlowpokePaintingObjectTable
+ call FindExtraInteractableObjects
+ ret
+
+SlowpokePaintingObjectTable: ; ed5e (3:6d5e)
+ db 16, 2, NORTH
+ dw OWSequence_ee76
+ db $00
+
+; Given a table with data of the form:
+; X, Y, Dir, OWSequence
+; Searches to try to find a match, and starts an OWSequence 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 SetNextOWSequence
+ scf
+ ret
+; 0xed8d
+
+ INCROM $ed8d, $ee76
+
+OWSequence_ee76: ; ee76 (3:6e76)
+ start_script
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_21
+ db $01
+ dw .ows_ee7d
+ run_script OWScript_QuitScriptFully
+
+.ows_ee7d
+ run_script OWScript_SetFlagValue
+ db EVENT_FLAG_21
+ db $02
+ run_script Func_ccdc
+ tx Text06a2
+ run_script OWScript_GiveCard
+ db SLOWPOKE1
+ run_script OWScript_ShowCardReceivedScreen
+ db SLOWPOKE1
+ run_script OWScript_QuitScriptFully
+; 0xee88
+
+ INCROM $ee88, $f580
Func_f580: ; f580 (3:7580)
get_flag_value EVENT_FLAG_44
@@ -4782,7 +5003,72 @@ OWSequence_f631: ; f631 (3:7631)
ret
; 0xf63c
- INCROM $f63c, $fc2b
+ INCROM $f63c, $fbdb
+
+HallOfHonorLoadMap: ; fbdb (3:7bdb)
+ ld a, SFX_10
+ call PlaySFX
+ ret
+; 0xfbe1
+
+ INCROM $fbe1, $fbf1
+
+OWSequence_fbf1: ; fbf1 (3:7bf1)
+ start_script
+ run_script OWScript_JumpIfFlagNonzero2
+ db EVENT_RECEIVED_LEGEND_CARDS
+ dw .ows_fc10
+ run_script OWScript_MaxOutFlagValue
+ db EVENT_RECEIVED_LEGEND_CARDS
+ run_script Func_ccdc
+ tx Text05b8
+ run_script OWScript_GiveCard
+ db ZAPDOS3
+ run_script OWScript_GiveCard
+ db MOLTRES2
+ run_script OWScript_GiveCard
+ db ARTICUNO2
+ run_script OWScript_GiveCard
+ db DRAGONITE1
+ run_script OWScript_ShowCardReceivedScreen
+ db $ff
+.ows_fc05
+ run_script Func_d38f
+ db $00
+ run_script Func_ccdc
+ tx Text05b9
+.ows_fc0a
+ run_script Func_d38f
+ db $01
+ run_script Func_d396
+ db $01
+ run_script Func_d3b9
+ run_script OWScript_QuitScriptFully
+
+.ows_fc10
+ run_script OWScript_JumpIfFlagEqual
+ db EVENT_FLAG_71
+ db $0f
+ dw .ows_fc20
+ run_script Func_d209
+ run_script Func_ccdc
+ tx Text05ba
+ run_script OWScript_GiveCard
+ db $00
+ run_script OWScript_ShowCardReceivedScreen
+ db $00
+ run_script OWScript_Jump
+ dw .ows_fc05
+
+.ows_fc20
+ run_script Func_ccdc
+ tx Text05bb
+ run_script Func_d38f
+ db $00
+ run_script Func_ccdc
+ tx Text05bc
+ run_script OWScript_Jump
+ dw .ows_fc0a
Func_fc2b: ; fc2b (3:7c2b)
ld a, [wDuelResult]
diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm
index b01c51b..3f1d4f4 100644
--- a/src/engine/bank04.asm
+++ b/src/engine/bank04.asm
@@ -1008,7 +1008,7 @@ OverworldScriptTable: ; 1217b (4:617b)
dw OWScript_DoFrames
dw Func_d0d9
dw OWScript_JumpIfPlayerCoordMatches
- dw Func_ce4a
+ dw OWScript_MoveActiveNPC
dw OWScript_GiveOneOfEachTrainerBooster
dw Func_d103
dw Func_d125
diff --git a/src/engine/bank20.asm b/src/engine/bank20.asm
index 0086f96..b656f90 100644
--- a/src/engine/bank20.asm
+++ b/src/engine/bank20.asm
@@ -408,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
diff --git a/src/engine/home.asm b/src/engine/home.asm
index 681069d..ca0eb19 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, EVENT_FLAG_22
+ ld a, EVENT_RECEIVED_LEGEND_CARDS
farcall GetEventFlagValue
call EnableSRAM
ld [s0a00a], a
@@ -11059,16 +11059,16 @@ Func_3a4f: ; 3a4f (0:3a4f)
ret
; 0x3a5e
-Func_3a5e: ; 3a5e (0:3a5e)
+HandleMoveModeAPress: ; 3a5e (0:3a5e)
ldh a, [hBankROM]
push af
- ld l, MAP_SCRIPT_PRESSED_A_1
+ ld l, MAP_SCRIPT_OBJECTS
call GetMapScriptPointer
jr nc, .handleSecondAPressScript
ld a, BANK(FindPlayerMovementFromDirection)
call BankswitchROM
call FindPlayerMovementFromDirection
- ld a, $4
+ ld a, BANK(MapScripts)
call BankswitchROM
ld a, [wPlayerDirection]
ld d, a
@@ -11091,9 +11091,9 @@ Func_3a5e: ; 3a5e (0:3a5e)
ld a, [hli]
ld [wNextOWSequence+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 [wCurrentNPCNameTx], a
ld a, [hli]
@@ -11106,14 +11106,14 @@ Func_3a5e: ; 3a5e (0:3a5e)
ret
.noMatch
pop hl
- ld bc, $0008
+ ld bc, LEVEL_OBJECT_SIZE - 1
add hl, bc
pop bc
jr .findAPressMatchLoop
.handleSecondAPressScript
pop af
call BankswitchROM
- ld l, MAP_SCRIPT_PRESSED_A_2
+ ld l, MAP_SCRIPT_PRESSED_A
call CallMapScriptPointerIfExists
ret
diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm
index 42ff187..b7d07cb 100644
--- a/src/macros/scripts.asm
+++ b/src/macros/scripts.asm
@@ -53,7 +53,7 @@ ENDM
const OWScript_DoFrames_index ; $24
const Func_d0d9_index ; $25
const OWScript_JumpIfPlayerCoordMatches_index ; $26
- const Func_ce4a_index ; $27
+ const OWScript_MoveActiveNPC_index ; $27
const OWScript_GiveOneOfEachTrainerBooster_index ; $28
const Func_d103_index ; $29
const Func_d125_index ; $2a
diff --git a/src/wram.asm b/src/wram.asm
index eea0f04..382b8e1 100644
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -1796,7 +1796,8 @@ wTempPlayerYCoord:: ; d0bd
wTempPlayerDirection:: ; d0be
ds $1
-wd0bf:: ; d0bf
+; See constants/misc_constants.asm for OWMODE's
+wOverworldMode:: ; d0bf
ds $1
wd0c0:: ; d0c0
@@ -1826,11 +1827,8 @@ wNextOWSequence:: ; d0c6
wCurrentNPCNameTx:: ; d0c8
ds $2
-wd0ca:: ; d0ca
- ds $1
-
-wd0cb:: ; d0cb
- ds $1
+wDefaultObjectText:: ; d0ca
+ ds $2
wd0cc:: ; d0cc
ds 8 palettes