summaryrefslogtreecommitdiff
path: root/engine/overworld
diff options
context:
space:
mode:
authorpikalaxalt <PikalaxALT@gmail.com>2016-05-21 22:45:53 -0400
committerpikalaxalt <PikalaxALT@gmail.com>2016-05-21 22:45:53 -0400
commiteeb058a23137bff0a7c046506cd448066500b608 (patch)
tree60d5fd526d1ad2c864ef2a385a4ab0302d90df93 /engine/overworld
parent983bac5fe990383d77a4f2fa552546cb7f6f04b7 (diff)
Some work on disassembling npc movement scripts (aka informed copy/paste from red)
Diffstat (limited to 'engine/overworld')
-rwxr-xr-xengine/overworld/npc_movement.asm176
1 files changed, 29 insertions, 147 deletions
diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm
index 719c8835..5c86d94f 100755
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -27,7 +27,7 @@ PlayerStepOutFromDoor: ; 1a3e0 (6:63e0)
res 7, [hl]
ret
-_EndNPCMovementScript: ; 1a41d (6:641d)
+_EndNPCMovementScript: ; 1a527 (6:6527)
ld hl, wd730
res 7, [hl]
ld hl, wd72e
@@ -37,21 +37,21 @@ _EndNPCMovementScript: ; 1a41d (6:641d)
res 1, [hl]
xor a
ld [wNPCMovementScriptSpriteOffset], a
- ld [wNPCMovementScriptPointerTableNum], a
ld [wNPCMovementScriptFunctionNum], a
+ ld [wNPCMovementScriptPointerTableNum], a
ld [wWastedByteCD3A], a
ld [wSimulatedJoypadStatesIndex], a
ld [wSimulatedJoypadStatesEnd], a
ret
-PalletMovementScriptPointerTable: ; 1a442 (6:6442)
+PalletMovementScriptPointerTable: ; 1a54c (6:654c)
dw PalletMovementScript_OakMoveLeft
dw PalletMovementScript_PlayerMoveLeft
dw PalletMovementScript_WaitAndWalkToLab
dw PalletMovementScript_WalkToLab
dw PalletMovementScript_Done
-PalletMovementScript_OakMoveLeft: ; 1a44c (6:644c)
+PalletMovementScript_OakMoveLeft: ; 1a556 (6:6556)
ld a, [wXCoord]
sub $a
ld [wNumStepsToTake], a
@@ -79,31 +79,37 @@ PalletMovementScript_OakMoveLeft: ; 1a44c (6:644c)
ld a, $3
ld [wNPCMovementScriptFunctionNum], a
.done
+ ld a, $2
+ ld c, a
+ ld a, SFX_BATTLE_34
+ call PlayMusic
ld hl, wFlags_D733
set 1, [hl]
ld a, $fc
ld [wJoyIgnore], a
ret
-PalletMovementScript_PlayerMoveLeft: ; 1a485 (6:6485)
+PalletMovementScript_PlayerMoveLeft: ; 1a597 (6:6597)
ld a, [wd730]
bit 0, a ; is an NPC being moved by a script?
ret nz ; return if Oak is still moving
ld a, [wNumStepsToTake]
ld [wSimulatedJoypadStatesIndex], a
ld [hNPCMovementDirections2Index], a
- predef ConvertNPCMovementDirectionsToJoypadMasks
+ ; predef ConvertNPCMovementDirectionsToJoypadMasks
+ ld a, $23
+ call Predef
call StartSimulatingJoypadStates
ld a, $2
ld [wNPCMovementScriptFunctionNum], a
ret
-PalletMovementScript_WaitAndWalkToLab: ; 1a4a1 (6:64a1)
+PalletMovementScript_WaitAndWalkToLab: ; 1a5b3 (6:65b3)
ld a, [wSimulatedJoypadStatesIndex]
and a ; is the player done moving left yet?
ret nz
-PalletMovementScript_WalkToLab: ; 1a4a6 (6:64a6)
+PalletMovementScript_WalkToLab: ; 1a5b8 (6:65b8)
xor a
ld [wOverrideSimulatedJoypadStatesMask], a
ld a, [wSpriteIndex]
@@ -127,8 +133,9 @@ PalletMovementScript_WalkToLab: ; 1a4a6 (6:64a6)
ld [wNPCMovementScriptFunctionNum], a
ret
-RLEList_ProfOakWalkToLab: ; 1a4dc (6:64dc)
- db NPC_MOVEMENT_DOWN, $05
+
+RLEList_ProfOakWalkToLab: ; 1a5ee (6:65ee)
+ db NPC_MOVEMENT_DOWN, $06 ; differs from red
db NPC_MOVEMENT_LEFT, $01
db NPC_MOVEMENT_DOWN, $05
db NPC_MOVEMENT_RIGHT, $03
@@ -136,157 +143,32 @@ RLEList_ProfOakWalkToLab: ; 1a4dc (6:64dc)
db $E0, $01 ; stand still
db $FF
-RLEList_PlayerWalkToLab: ; 1a4e9 (6:64e9)
+RLEList_PlayerWalkToLab: ; 1a5fb (6:65fb)
db D_UP, $02
db D_RIGHT, $03
db D_DOWN, $05
db D_LEFT, $01
- db D_DOWN, $06
+ db D_DOWN, $07 ; differs from red
db $FF
-PalletMovementScript_Done: ; 1a4f4 (6:64f4)
+PalletMovementScript_Done: ; 1a606 (6:6606)
ld a, [wSimulatedJoypadStatesIndex]
and a
ret nz
ld a, $0
ld [wMissableObjectIndex], a
- predef HideObject
- ld hl, wd730
- res 7, [hl]
- ld hl, wd72e
- res 7, [hl]
- jp EndNPCMovementScript
-
-PewterMuseumGuyMovementScriptPointerTable: ; 1a510 (6:6510)
- dw PewterMovementScript_WalkToMuseum
- dw PewterMovementScript_Done
-
-PewterMovementScript_WalkToMuseum: ; 1a514 (6:6514)
- ld a, BANK(Music_MuseumGuy)
- ld [wAudioROMBank], a
- ld [wAudioSavedROMBank], a
- ld a, MUSIC_MUSEUM_GUY
- ld [wNewSoundID], a
- call PlaySound
- ld a, [wSpriteIndex]
- swap a
- ld [wNPCMovementScriptSpriteOffset], a
- call StartSimulatingJoypadStates
- ld hl, wSimulatedJoypadStatesEnd
- ld de, RLEList_PewterMuseumPlayer
- call DecodeRLEList
- dec a
- ld [wSimulatedJoypadStatesIndex], a
- xor a
- ld [wWhichPewterGuy], a
- predef PewterGuys
- ld hl, wNPCMovementDirections2
- ld de, RLEList_PewterMuseumGuy
- call DecodeRLEList
- ld hl, wd72e
- res 7, [hl]
- ld a, $1
- ld [wNPCMovementScriptFunctionNum], a
- ret
-
-RLEList_PewterMuseumPlayer: ; 1a559 (6:6559)
- db 0, $01
- db D_UP, $03
- db D_LEFT, $0D
- db D_UP, $06
- db $FF
-
-RLEList_PewterMuseumGuy: ; 1a562 (6:6562)
- db NPC_MOVEMENT_UP, $06
- db NPC_MOVEMENT_LEFT, $0D
- db NPC_MOVEMENT_UP, $03
- db NPC_MOVEMENT_LEFT, $01
- db $FF
-
-PewterMovementScript_Done: ; 1a56b (6:656b)
- ld a, [wSimulatedJoypadStatesIndex]
- and a
- ret nz
+ ; predef HideObject
+ ld a, $11
+ call Predef
ld hl, wd730
res 7, [hl]
ld hl, wd72e
res 7, [hl]
jp EndNPCMovementScript
-PewterGymGuyMovementScriptPointerTable: ; 1a57d (6:657d)
- dw PewterMovementScript_WalkToGym
- dw PewterMovementScript_Done
-
-PewterMovementScript_WalkToGym: ; 1a581 (6:6581)
- ld a, BANK(Music_MuseumGuy)
- ld [wAudioROMBank], a
- ld [wAudioSavedROMBank], a
- ld a, MUSIC_MUSEUM_GUY
- ld [wNewSoundID], a
- call PlaySound
- ld a, [wSpriteIndex]
- swap a
- ld [wNPCMovementScriptSpriteOffset], a
- xor a
- ld [wSpriteStateData2 + $06], a
- ld hl, wSimulatedJoypadStatesEnd
- ld de, RLEList_PewterGymPlayer
- call DecodeRLEList
- dec a
- ld [wSimulatedJoypadStatesIndex], a
- ld a, 1
- ld [wWhichPewterGuy], a
- predef PewterGuys
- ld hl, wNPCMovementDirections2
- ld de, RLEList_PewterGymGuy
- call DecodeRLEList
- ld hl, wd72e
- res 7, [hl]
- ld hl, wd730
- set 7, [hl]
- ld a, $1
- ld [wNPCMovementScriptFunctionNum], a
- ret
-
-RLEList_PewterGymPlayer: ; 1a5cd (6:65cd)
- db 0, $01
- db D_RIGHT, $02
- db D_DOWN, $05
- db D_LEFT, $0B
- db D_UP, $05
- db D_LEFT, $0F
- db $FF
-
-RLEList_PewterGymGuy: ; 1a5da (6:65da)
- db NPC_MOVEMENT_DOWN, $02
- db NPC_MOVEMENT_LEFT, $0F
- db NPC_MOVEMENT_UP, $05
- db NPC_MOVEMENT_LEFT, $0B
- db NPC_MOVEMENT_DOWN, $05
- db NPC_MOVEMENT_RIGHT, $03
- db $FF
-
-FreezeEnemyTrainerSprite: ; 1a5e7 (6:65e7)
- ld a, [wCurMap]
- cp POKEMONTOWER_7
- ret z ; the Rockets on Pokemon Tower 7F leave after battling, so don't freeze them
- ld hl, RivalIDs
- ld a, [wEngagedTrainerClass]
- ld b, a
-.loop
- ld a, [hli]
- cp $ff
- jr z, .notRival
- cp b
- ret z ; the rival leaves after battling, so don't freeze him
- jr .loop
-.notRival
- ld a, [wSpriteIndex]
- ld [H_SPRITEINDEX], a
- jp SetSpriteMovementBytesToFF
-
-RivalIDs: ; 1a605 (6:6605)
- db OPP_SONY1
- db OPP_SONY2
- db OPP_SONY3
- db $ff
+PewterMuseumGuyMovementScriptPointerTable: ; 1a622 (6:6622)
+ dr $1a622,$1a685
+PewterGymGuyMovementScriptPointerTable: ; 1a685 (6:6685)
+ dr $1a685,$1a785
+IsPlayerStandingOnDoorTile: ; 1a785 (6:6785)
+ dr $1a785,$1a7f4