2016-06-12 00:24:04 +00:00
|
|
|
PlayerStepOutFromDoor:
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd730
|
2014-05-22 22:13:20 +00:00
|
|
|
res 1, [hl]
|
2014-09-13 07:50:56 +00:00
|
|
|
call IsPlayerStandingOnDoorTile
|
2014-09-10 03:55:19 +00:00
|
|
|
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
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd736
|
2014-05-22 22:13:20 +00:00
|
|
|
set 1, [hl]
|
|
|
|
ld a, $1
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wSimulatedJoypadStatesIndex], a
|
|
|
|
ld a, D_DOWN
|
|
|
|
ld [wSimulatedJoypadStatesEnd], a
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wSpriteStateData1 + 2], a
|
2014-09-10 03:55:19 +00:00
|
|
|
call StartSimulatingJoypadStates
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
2014-09-10 03:55:19 +00:00
|
|
|
.notStandingOnDoor
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wWastedByteCD3A], a
|
|
|
|
ld [wSimulatedJoypadStatesIndex], a
|
|
|
|
ld [wSimulatedJoypadStatesEnd], a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd736
|
2014-05-22 22:13:20 +00:00
|
|
|
res 0, [hl]
|
|
|
|
res 1, [hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd730
|
2014-05-22 22:13:20 +00:00
|
|
|
res 7, [hl]
|
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
_EndNPCMovementScript:
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd730
|
2014-05-22 22:13:20 +00:00
|
|
|
res 7, [hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd72e
|
2014-05-22 22:13:20 +00:00
|
|
|
res 7, [hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd736
|
2014-05-22 22:13:20 +00:00
|
|
|
res 0, [hl]
|
|
|
|
res 1, [hl]
|
|
|
|
xor a
|
2014-09-10 03:55:19 +00:00
|
|
|
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
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PalletMovementScriptPointerTable:
|
2015-07-15 20:58:21 +00:00
|
|
|
dw PalletMovementScript_OakMoveLeft
|
|
|
|
dw PalletMovementScript_PlayerMoveLeft
|
|
|
|
dw PalletMovementScript_WaitAndWalkToLab
|
|
|
|
dw PalletMovementScript_WalkToLab
|
|
|
|
dw PalletMovementScript_Done
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PalletMovementScript_OakMoveLeft:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wXCoord]
|
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
|
2014-09-10 03:55:19 +00:00
|
|
|
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
|
2014-09-10 03:55:19 +00:00
|
|
|
ld de, wNPCMovementDirections2
|
2014-05-22 22:13:20 +00:00
|
|
|
call MoveSprite
|
|
|
|
ld a, $1
|
2014-09-10 03:55:19 +00:00
|
|
|
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
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wNPCMovementScriptFunctionNum], a
|
2015-07-15 20:58:21 +00:00
|
|
|
.done
|
2015-08-31 02:38:41 +00:00
|
|
|
ld hl, wFlags_D733
|
2014-05-22 22:13:20 +00:00
|
|
|
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
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PalletMovementScript_PlayerMoveLeft:
|
2014-05-26 21:04:56 +00:00
|
|
|
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]
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wSimulatedJoypadStatesIndex], a
|
2015-07-15 20:58:21 +00:00
|
|
|
ld [hNPCMovementDirections2Index], a
|
2014-09-10 03:55:19 +00:00
|
|
|
predef ConvertNPCMovementDirectionsToJoypadMasks
|
|
|
|
call StartSimulatingJoypadStates
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $2
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wNPCMovementScriptFunctionNum], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PalletMovementScript_WaitAndWalkToLab:
|
2014-09-10 03:55:19 +00:00
|
|
|
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
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PalletMovementScript_WalkToLab:
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wOverrideSimulatedJoypadStatesMask], a
|
2014-09-13 07:50:56 +00:00
|
|
|
ld a, [wSpriteIndex]
|
2014-05-22 22:13:20 +00:00
|
|
|
swap a
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wNPCMovementScriptSpriteOffset], a
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wSpriteStateData2 + $06], a
|
2014-09-10 03:55:19 +00:00
|
|
|
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
|
2014-09-10 03:55:19 +00:00
|
|
|
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
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd72e
|
2014-05-22 22:13:20 +00:00
|
|
|
res 7, [hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd730
|
2014-05-22 22:13:20 +00:00
|
|
|
set 7, [hl]
|
|
|
|
ld a, $4
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wNPCMovementScriptFunctionNum], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
RLEList_ProfOakWalkToLab:
|
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
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
RLEList_PlayerWalkToLab:
|
2014-09-10 03:55:19 +00:00
|
|
|
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
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PalletMovementScript_Done:
|
2014-09-10 03:55:19 +00:00
|
|
|
ld a, [wSimulatedJoypadStatesIndex]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
ret nz
|
2017-10-29 18:22:17 +00:00
|
|
|
ld a, HS_PALLET_TOWN_OAK
|
2015-07-25 03:27:59 +00:00
|
|
|
ld [wMissableObjectIndex], a
|
2014-06-16 20:57:26 +00:00
|
|
|
predef HideObject
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd730
|
2014-05-22 22:13:20 +00:00
|
|
|
res 7, [hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd72e
|
2014-05-22 22:13:20 +00:00
|
|
|
res 7, [hl]
|
2014-09-10 03:55:19 +00:00
|
|
|
jp EndNPCMovementScript
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PewterMuseumGuyMovementScriptPointerTable:
|
2015-07-15 20:58:21 +00:00
|
|
|
dw PewterMovementScript_WalkToMuseum
|
|
|
|
dw PewterMovementScript_Done
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PewterMovementScript_WalkToMuseum:
|
2014-06-09 20:18:29 +00:00
|
|
|
ld a, BANK(Music_MuseumGuy)
|
2015-08-09 05:32:44 +00:00
|
|
|
ld [wAudioROMBank], a
|
|
|
|
ld [wAudioSavedROMBank], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, MUSIC_MUSEUM_GUY
|
2015-08-09 05:32:44 +00:00
|
|
|
ld [wNewSoundID], 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
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wNPCMovementScriptSpriteOffset], a
|
|
|
|
call StartSimulatingJoypadStates
|
|
|
|
ld hl, wSimulatedJoypadStatesEnd
|
2014-05-22 22:13:20 +00:00
|
|
|
ld de, RLEList_PewterMuseumPlayer
|
|
|
|
call DecodeRLEList
|
|
|
|
dec a
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wSimulatedJoypadStatesIndex], a
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-07-26 02:26:54 +00:00
|
|
|
ld [wWhichPewterGuy], a
|
2014-06-16 20:57:26 +00:00
|
|
|
predef PewterGuys
|
2014-09-10 03:55:19 +00:00
|
|
|
ld hl, wNPCMovementDirections2
|
2014-05-22 22:13:20 +00:00
|
|
|
ld de, RLEList_PewterMuseumGuy
|
|
|
|
call DecodeRLEList
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd72e
|
2014-05-22 22:13:20 +00:00
|
|
|
res 7, [hl]
|
|
|
|
ld a, $1
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wNPCMovementScriptFunctionNum], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
RLEList_PewterMuseumPlayer:
|
2014-09-10 03:55:19 +00:00
|
|
|
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
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
RLEList_PewterMuseumGuy:
|
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
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PewterMovementScript_Done:
|
2014-09-10 03:55:19 +00:00
|
|
|
ld a, [wSimulatedJoypadStatesIndex]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
ret nz
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd730
|
2014-05-22 22:13:20 +00:00
|
|
|
res 7, [hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd72e
|
2014-05-22 22:13:20 +00:00
|
|
|
res 7, [hl]
|
2014-09-10 03:55:19 +00:00
|
|
|
jp EndNPCMovementScript
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PewterGymGuyMovementScriptPointerTable:
|
2015-07-15 20:58:21 +00:00
|
|
|
dw PewterMovementScript_WalkToGym
|
|
|
|
dw PewterMovementScript_Done
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PewterMovementScript_WalkToGym:
|
2014-06-09 20:18:29 +00:00
|
|
|
ld a, BANK(Music_MuseumGuy)
|
2015-08-09 05:32:44 +00:00
|
|
|
ld [wAudioROMBank], a
|
|
|
|
ld [wAudioSavedROMBank], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, MUSIC_MUSEUM_GUY
|
2015-08-09 05:32:44 +00:00
|
|
|
ld [wNewSoundID], 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
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wNPCMovementScriptSpriteOffset], a
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wSpriteStateData2 + $06], a
|
2014-09-10 03:55:19 +00:00
|
|
|
ld hl, wSimulatedJoypadStatesEnd
|
2014-05-22 22:13:20 +00:00
|
|
|
ld de, RLEList_PewterGymPlayer
|
|
|
|
call DecodeRLEList
|
|
|
|
dec a
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wSimulatedJoypadStatesIndex], a
|
2015-07-26 02:26:54 +00:00
|
|
|
ld a, 1
|
|
|
|
ld [wWhichPewterGuy], a
|
2014-06-16 20:57:26 +00:00
|
|
|
predef PewterGuys
|
2014-09-10 03:55:19 +00:00
|
|
|
ld hl, wNPCMovementDirections2
|
2014-05-22 22:13:20 +00:00
|
|
|
ld de, RLEList_PewterGymGuy
|
|
|
|
call DecodeRLEList
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd72e
|
2014-05-22 22:13:20 +00:00
|
|
|
res 7, [hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd730
|
2014-05-22 22:13:20 +00:00
|
|
|
set 7, [hl]
|
|
|
|
ld a, $1
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wNPCMovementScriptFunctionNum], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
RLEList_PewterGymPlayer:
|
2014-09-10 03:55:19 +00:00
|
|
|
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
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
RLEList_PewterGymGuy:
|
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
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
FreezeEnemyTrainerSprite:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wCurMap]
|
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
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
RivalIDs:
|
2015-08-10 16:09:16 +00:00
|
|
|
db OPP_SONY1
|
|
|
|
db OPP_SONY2
|
|
|
|
db OPP_SONY3
|
2014-05-22 22:13:20 +00:00
|
|
|
db $ff
|