pokered/engine/overworld/npc_movement.asm

293 lines
6.3 KiB
NASM
Raw Normal View History

PlayerStepOutFromDoor: ; 1a3e0 (6:63e0)
ld hl, wd730
2014-05-22 22:13:20 +00:00
res 1, [hl]
2014-09-13 07:50:56 +00:00
call IsPlayerStandingOnDoorTile
jr nc, .notStandingOnDoor
2014-05-22 22:13:20 +00:00
ld a, $fc
2014-05-25 17:51:53 +00:00
ld [wJoyIgnore], a
ld hl, wd736
2014-05-22 22:13:20 +00:00
set 1, [hl]
ld a, $1
ld [wSimulatedJoypadStatesIndex], a
ld a, D_DOWN
ld [wSimulatedJoypadStatesEnd], a
2014-05-22 22:13:20 +00:00
xor a
ld [wSpriteStateData1 + 2], a
call StartSimulatingJoypadStates
2014-05-22 22:13:20 +00:00
ret
.notStandingOnDoor
2014-05-22 22:13:20 +00:00
xor a
ld [wWastedByteCD3A], a
ld [wSimulatedJoypadStatesIndex], a
ld [wSimulatedJoypadStatesEnd], a
ld hl, wd736
2014-05-22 22:13:20 +00:00
res 0, [hl]
res 1, [hl]
ld hl, wd730
2014-05-22 22:13:20 +00:00
res 7, [hl]
ret
_EndNPCMovementScript: ; 1a41d (6:641d)
ld hl, wd730
2014-05-22 22:13:20 +00:00
res 7, [hl]
ld hl, wd72e
2014-05-22 22:13:20 +00:00
res 7, [hl]
ld hl, wd736
2014-05-22 22:13:20 +00:00
res 0, [hl]
res 1, [hl]
xor a
ld [wNPCMovementScriptSpriteOffset], a
ld [wNPCMovementScriptPointerTableNum], a
ld [wNPCMovementScriptFunctionNum], a
ld [wWastedByteCD3A], a
ld [wSimulatedJoypadStatesIndex], a
ld [wSimulatedJoypadStatesEnd], a
2014-05-22 22:13:20 +00:00
ret
2015-07-15 20:58:21 +00:00
PalletMovementScriptPointerTable: ; 1a442 (6:6442)
dw PalletMovementScript_OakMoveLeft
dw PalletMovementScript_PlayerMoveLeft
dw PalletMovementScript_WaitAndWalkToLab
dw PalletMovementScript_WalkToLab
dw PalletMovementScript_Done
2014-05-22 22:13:20 +00:00
2015-07-15 20:58:21 +00:00
PalletMovementScript_OakMoveLeft: ; 1a44c (6:644c)
ld a, [W_XCOORD]
2014-05-22 22:13:20 +00:00
sub $a
2015-07-15 20:58:21 +00:00
ld [wNumStepsToTake], a
jr z, .playerOnLeftTile
; The player is on the right tile of the northern path out of Pallet Town and
; Prof. Oak is below.
; Make Prof. Oak step to the left.
ld b, 0
2014-05-22 22:13:20 +00:00
ld c, a
ld hl, wNPCMovementDirections2
2015-07-15 20:58:21 +00:00
ld a, NPC_MOVEMENT_LEFT
2014-05-22 22:13:20 +00:00
call FillMemory
ld [hl], $ff
2014-09-13 07:50:56 +00:00
ld a, [wSpriteIndex]
2015-07-15 11:27:59 +00:00
ld [H_SPRITEINDEX], a
ld de, wNPCMovementDirections2
2014-05-22 22:13:20 +00:00
call MoveSprite
ld a, $1
ld [wNPCMovementScriptFunctionNum], a
2015-07-15 20:58:21 +00:00
jr .done
; The player is on the left tile of the northern path out of Pallet Town and
; Prof. Oak is below.
2015-07-17 05:08:34 +00:00
; Prof. Oak is already where he needs to be.
2015-07-15 20:58:21 +00:00
.playerOnLeftTile
2014-05-22 22:13:20 +00:00
ld a, $3
ld [wNPCMovementScriptFunctionNum], a
2015-07-15 20:58:21 +00:00
.done
2014-05-22 22:13:20 +00:00
ld hl, W_FLAGS_D733
set 1, [hl]
ld a, $fc
2014-05-25 17:51:53 +00:00
ld [wJoyIgnore], a
2014-05-22 22:13:20 +00:00
ret
2015-07-15 20:58:21 +00:00
PalletMovementScript_PlayerMoveLeft: ; 1a485 (6:6485)
ld a, [wd730]
2015-07-15 20:58:21 +00:00
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
2015-07-15 20:58:21 +00:00
ld [hNPCMovementDirections2Index], a
predef ConvertNPCMovementDirectionsToJoypadMasks
call StartSimulatingJoypadStates
2014-05-22 22:13:20 +00:00
ld a, $2
ld [wNPCMovementScriptFunctionNum], a
2014-05-22 22:13:20 +00:00
ret
2015-07-15 20:58:21 +00:00
PalletMovementScript_WaitAndWalkToLab: ; 1a4a1 (6:64a1)
ld a, [wSimulatedJoypadStatesIndex]
2015-07-15 20:58:21 +00:00
and a ; is the player done moving left yet?
2014-05-22 22:13:20 +00:00
ret nz
2015-07-15 20:58:21 +00:00
PalletMovementScript_WalkToLab: ; 1a4a6 (6:64a6)
2014-05-22 22:13:20 +00:00
xor a
ld [wOverrideSimulatedJoypadStatesMask], a
2014-09-13 07:50:56 +00:00
ld a, [wSpriteIndex]
2014-05-22 22:13:20 +00:00
swap a
ld [wNPCMovementScriptSpriteOffset], a
2014-05-22 22:13:20 +00:00
xor a
ld [wSpriteStateData2 + $06], a
ld hl, wSimulatedJoypadStatesEnd
2014-09-13 07:50:56 +00:00
ld de, RLEList_PlayerWalkToLab
2014-05-22 22:13:20 +00:00
call DecodeRLEList
dec a
ld [wSimulatedJoypadStatesIndex], a
ld hl, wNPCMovementDirections2
2014-09-13 07:50:56 +00:00
ld de, RLEList_ProfOakWalkToLab
2014-05-22 22:13:20 +00:00
call DecodeRLEList
ld hl, wd72e
2014-05-22 22:13:20 +00:00
res 7, [hl]
ld hl, wd730
2014-05-22 22:13:20 +00:00
set 7, [hl]
ld a, $4
ld [wNPCMovementScriptFunctionNum], a
2014-05-22 22:13:20 +00:00
ret
2014-09-13 07:50:56 +00:00
RLEList_ProfOakWalkToLab: ; 1a4dc (6:64dc)
2015-07-15 20:58:21 +00:00
db NPC_MOVEMENT_DOWN, $05
db NPC_MOVEMENT_LEFT, $01
db NPC_MOVEMENT_DOWN, $05
db NPC_MOVEMENT_RIGHT, $03
db NPC_MOVEMENT_UP, $01
db $E0, $01 ; stand still
2014-05-22 22:13:20 +00:00
db $FF
2014-09-13 07:50:56 +00:00
RLEList_PlayerWalkToLab: ; 1a4e9 (6:64e9)
db D_UP, $02
db D_RIGHT, $03
db D_DOWN, $05
db D_LEFT, $01
db D_DOWN, $06
2014-05-22 22:13:20 +00:00
db $FF
2015-07-15 20:58:21 +00:00
PalletMovementScript_Done: ; 1a4f4 (6:64f4)
ld a, [wSimulatedJoypadStatesIndex]
2014-05-22 22:13:20 +00:00
and a
ret nz
ld a, $0
2015-07-25 03:27:59 +00:00
ld [wMissableObjectIndex], a
predef HideObject
ld hl, wd730
2014-05-22 22:13:20 +00:00
res 7, [hl]
ld hl, wd72e
2014-05-22 22:13:20 +00:00
res 7, [hl]
jp EndNPCMovementScript
2014-05-22 22:13:20 +00:00
PewterMuseumGuyMovementScriptPointerTable: ; 1a510 (6:6510)
2015-07-15 20:58:21 +00:00
dw PewterMovementScript_WalkToMuseum
dw PewterMovementScript_Done
2014-05-22 22:13:20 +00:00
2015-07-15 20:58:21 +00:00
PewterMovementScript_WalkToMuseum: ; 1a514 (6:6514)
2014-06-09 20:18:29 +00:00
ld a, BANK(Music_MuseumGuy)
ld [wc0ef], a
ld [wc0f0], a
2014-05-22 22:13:20 +00:00
ld a, MUSIC_MUSEUM_GUY
ld [wc0ee], a
2014-05-22 22:13:20 +00:00
call PlaySound
2014-09-13 07:50:56 +00:00
ld a, [wSpriteIndex]
2014-05-22 22:13:20 +00:00
swap a
ld [wNPCMovementScriptSpriteOffset], a
call StartSimulatingJoypadStates
ld hl, wSimulatedJoypadStatesEnd
2014-05-22 22:13:20 +00:00
ld de, RLEList_PewterMuseumPlayer
call DecodeRLEList
dec a
ld [wSimulatedJoypadStatesIndex], a
2014-05-22 22:13:20 +00:00
xor a
ld [wd12f], a
predef PewterGuys
ld hl, wNPCMovementDirections2
2014-05-22 22:13:20 +00:00
ld de, RLEList_PewterMuseumGuy
call DecodeRLEList
ld hl, wd72e
2014-05-22 22:13:20 +00:00
res 7, [hl]
ld a, $1
ld [wNPCMovementScriptFunctionNum], a
2014-05-22 22:13:20 +00:00
ret
RLEList_PewterMuseumPlayer: ; 1a559 (6:6559)
db 0, $01
db D_UP, $03
db D_LEFT, $0D
db D_UP, $06
2014-05-22 22:13:20 +00:00
db $FF
RLEList_PewterMuseumGuy: ; 1a562 (6:6562)
2015-07-15 20:58:21 +00:00
db NPC_MOVEMENT_UP, $06
db NPC_MOVEMENT_LEFT, $0D
db NPC_MOVEMENT_UP, $03
db NPC_MOVEMENT_LEFT, $01
2014-05-22 22:13:20 +00:00
db $FF
2015-07-15 20:58:21 +00:00
PewterMovementScript_Done: ; 1a56b (6:656b)
ld a, [wSimulatedJoypadStatesIndex]
2014-05-22 22:13:20 +00:00
and a
ret nz
ld hl, wd730
2014-05-22 22:13:20 +00:00
res 7, [hl]
ld hl, wd72e
2014-05-22 22:13:20 +00:00
res 7, [hl]
jp EndNPCMovementScript
2014-05-22 22:13:20 +00:00
PewterGymGuyMovementScriptPointerTable: ; 1a57d (6:657d)
2015-07-15 20:58:21 +00:00
dw PewterMovementScript_WalkToGym
dw PewterMovementScript_Done
2014-05-22 22:13:20 +00:00
2015-07-15 20:58:21 +00:00
PewterMovementScript_WalkToGym: ; 1a581 (6:6581)
2014-06-09 20:18:29 +00:00
ld a, BANK(Music_MuseumGuy)
ld [wc0ef], a
ld [wc0f0], a
2014-05-22 22:13:20 +00:00
ld a, MUSIC_MUSEUM_GUY
ld [wc0ee], a
2014-05-22 22:13:20 +00:00
call PlaySound
2014-09-13 07:50:56 +00:00
ld a, [wSpriteIndex]
2014-05-22 22:13:20 +00:00
swap a
ld [wNPCMovementScriptSpriteOffset], a
2014-05-22 22:13:20 +00:00
xor a
ld [wSpriteStateData2 + $06], a
ld hl, wSimulatedJoypadStatesEnd
2014-05-22 22:13:20 +00:00
ld de, RLEList_PewterGymPlayer
call DecodeRLEList
dec a
ld [wSimulatedJoypadStatesIndex], a
2014-05-22 22:13:20 +00:00
ld a, $1
ld [wd12f], a
predef PewterGuys
ld hl, wNPCMovementDirections2
2014-05-22 22:13:20 +00:00
ld de, RLEList_PewterGymGuy
call DecodeRLEList
ld hl, wd72e
2014-05-22 22:13:20 +00:00
res 7, [hl]
ld hl, wd730
2014-05-22 22:13:20 +00:00
set 7, [hl]
ld a, $1
ld [wNPCMovementScriptFunctionNum], a
2014-05-22 22:13:20 +00:00
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
2014-05-22 22:13:20 +00:00
db $FF
RLEList_PewterGymGuy: ; 1a5da (6:65da)
2015-07-15 20:58:21 +00:00
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
2014-05-22 22:13:20 +00:00
db $FF
2014-09-14 18:29:18 +00:00
FreezeEnemyTrainerSprite: ; 1a5e7 (6:65e7)
ld a, [W_CURMAP]
2014-05-22 22:13:20 +00:00
cp POKEMONTOWER_7
2014-09-14 18:29:18 +00:00
ret z ; the Rockets on Pokemon Tower 7F leave after battling, so don't freeze them
ld hl, RivalIDs
2014-05-22 22:13:20 +00:00
ld a, [wEngagedTrainerClass]
ld b, a
.loop
ld a, [hli]
cp $ff
jr z, .notRival
cp b
2014-09-14 18:29:18 +00:00
ret z ; the rival leaves after battling, so don't freeze him
2014-05-22 22:13:20 +00:00
jr .loop
.notRival
2014-09-13 07:50:56 +00:00
ld a, [wSpriteIndex]
2014-09-14 18:29:18 +00:00
ld [H_SPRITEINDEX], a
2014-05-22 22:13:20 +00:00
jp SetSpriteMovementBytesToFF
RivalIDs: ; 1a605 (6:6605)
db SONY1 + $c8
db SONY2 + $c8
db SONY3 + $c8
db $ff