Split out pikachu engine functions; sprite state data macros

This commit is contained in:
pikalaxalt 2016-06-06 12:09:36 -04:00
parent aafed67874
commit 96a58ce52a
63 changed files with 3741 additions and 3516 deletions

View File

@ -47,12 +47,12 @@ pikaemotion_emotebubble: MACRO
db \1
ENDM
pikaemotion_4: MACRO
pikaemotion_movement: MACRO
db PIKAEMOTION_4
dw \1
ENDM
pikaemotion_5: MACRO
pikaemotion_pikapic: MACRO
db PIKAEMOTION_5
db \1
ENDM

View File

@ -85,6 +85,8 @@ const_value = 1
const SPRITE_CHANSEY ; $44
const SPRITE_JESSIE ; $45
const SPRITE_JAMES ; $46
; 4-tile sprites
const SPRITE_BALL ; $47
const SPRITE_OMANYTE ; $48
const SPRITE_BOULDER ; $49

View File

@ -1,158 +1,4 @@
PlayPikachuSoundClip:: ; f0000 (3c:4000)
ld a, e
ld e, a
ld d, $0
ld hl, PikachuCriesPointerTable
add hl, de
add hl, de
add hl, de
ld b, [hl] ; bank of pikachu cry data
inc hl
ld a, [hli] ; cry data pointer
ld h, [hl]
ld l, a
ld c, $4
.loop
dec c
jr z, .done_delay
call DelayFrame
jr .loop
.done_delay
di
push bc
push hl
ld a, $80
ld [rNR52], a
ld a, $77
ld [rNR50], a
xor a
ld [rNR30], a
ld hl, $ff30 ; wave data
ld de, wRedrawRowOrColumnSrcTiles
.saveWaveDataLoop
ld a, [hl]
ld [de], a
inc de
ld a, $ff
ld [hli], a
ld a, l
cp $40 ; end of wave data
jr nz, .saveWaveDataLoop
ld a, $80
ld [rNR30], a
ld a, [rNR51]
or $44
ld [rNR51], a
ld a, $ff
ld [rNR31], a
ld a, $20
ld [rNR32], a
ld a, $ff
ld [rNR33], a
ld a, $87
ld [rNR34], a
pop hl
pop bc
call PlayPikachuPCM
xor a
ld [wc0f3], a
ld [wc0f4], a
ld a, $80
ld [rNR52], a
xor a
ld [rNR30], a
ld hl, $ff30
ld de, wRedrawRowOrColumnSrcTiles
.reloadWaveDataLoop
ld a, [de]
inc de
ld [hli], a
ld a, l
cp $40 ; end of wave data
jr nz, .reloadWaveDataLoop
ld a, $80
ld [rNR30], a
ld a, [rNR51]
and $bb
ld [rNR51], a
xor a
ld [wChannelSoundIDs+CH4], a
ld [wChannelSoundIDs+CH5], a
ld [wChannelSoundIDs+CH6], a
ld [wChannelSoundIDs+CH7], a
ld a, [H_LOADEDROMBANK]
ei
ret
PikachuCriesPointerTable: ; f008e (3c:408e)
; format:
; db bank
; dw pointer to cry
; bank 21
pikacry_def PikachuCry1 ; 21:4000
pikacry_def PikachuCry2 ; 21:491a
pikacry_def PikachuCry3 ; 21:4fdc
pikacry_def PikachuCry4 ; 21:59ee
; bank 22
pikacry_def PikachuCry5 ; 22:4000
pikacry_def PikachuCry6 ; 22:5042
pikacry_def PikachuCry7 ; 22:6254
; bank 23
pikacry_def PikachuCry8 ; 23:4000
pikacry_def PikachuCry9 ; 23:50ca
pikacry_def PikachuCry10 ; 23:5e0c
; bank 24
pikacry_def PikachuCry11 ; 24:4000
pikacry_def PikachuCry12 ; 24:4722
pikacry_def PikachuCry13 ; 24:54a4
; bank 25
pikacry_def PikachuCry14 ; 25:4000
pikacry_def PikachuCry15 ; 25:589a
; banks 31-34, in no particular order
pikacry_def PikachuCry16 ; 31:4000
pikacry_def PikachuCry17 ; 34:4000
pikacry_def PikachuCry18 ; 31:549a
pikacry_def PikachuCry19 ; 33:4000
pikacry_def PikachuCry20 ; 32:4000
pikacry_def PikachuCry21 ; 32:6002
pikacry_def PikachuCry22 ; 31:63a4
pikacry_def PikachuCry23 ; 34:4862
pikacry_def PikachuCry24 ; 33:5632
pikacry_def PikachuCry25 ; 34:573c
pikacry_def PikachuCry26 ; 33:725c
; bank 35
pikacry_def PikachuCry27 ; 35:4000
pikacry_def PikachuCry28 ; 35:4b5a
pikacry_def PikachuCry29 ; 35:5da4
pikacry_def PikachuCry30 ; 35:69ce
pikacry_def PikachuCry31 ; 35:6e80
; bank 36
pikacry_def PikachuCry32 ; 36:4000
pikacry_def PikachuCry33 ; 36:458a
pikacry_def PikachuCry34 ; 36:523c
; bank 37
pikacry_def PikachuCry35 ; 37:4000
pikacry_def PikachuCry36 ; 37:522a
; banks 36-38
pikacry_def PikachuCry37 ; 38:4000
pikacry_def PikachuCry38 ; 38:4dfa
pikacry_def PikachuCry39 ; 37:6e0c
pikacry_def PikachuCry40 ; 38:5a64
pikacry_def PikachuCry41 ; 36:6746
pikacry_def PikachuCry42 ; 38:6976
INCLUDE "engine/pikachu_pcm.asm"
INCLUDE "engine/overworld/advance_player_sprite.asm"
ResetStatusAndHalveMoneyOnBlackout:: ; f0274 (3c:4274)
@ -169,30 +15,30 @@ ResetStatusAndHalveMoneyOnBlackout:: ; f0274 (3c:4274)
ld [wNPCMovementScriptPointerTableNum], a
ld [wFlags_0xcd60], a
ld [$ff9f], a
ld [$ff9f + 1], a
ld [$ff9f + 2], a
ld [hMoney], a
ld [hMoney + 1], a
ld [hMoney + 2], a
call HasEnoughMoney
jr c, .lostmoney ; never happens
; Halve the player's money.
ld a, [wPlayerMoney]
ld [$ff9f], a
ld [hMoney], a
ld a, [wPlayerMoney + 1]
ld [$ff9f + 1], a
ld [hMoney + 1], a
ld a, [wPlayerMoney + 2]
ld [$ff9f + 2], a
ld [hMoney + 2], a
xor a
ld [$ffa2], a
ld [$ffa3], a
ld [hDivideBCDDivisor], a
ld [hDivideBCDDivisor + 1], a
ld a, 2
ld [$ffa4], a
ld [hDivideBCDDivisor + 2], a
predef DivideBCDPredef3
ld a, [$ffa2]
ld a, [hDivideBCDQuotient]
ld [wPlayerMoney], a
ld a, [$ffa2 + 1]
ld a, [hDivideBCDQuotient + 1]
ld [wPlayerMoney + 1], a
ld a, [$ffa2 + 2]
ld a, [hDivideBCDQuotient + 2]
ld [wPlayerMoney + 2], a
.lostmoney
@ -217,10 +63,12 @@ Func_f02da:: ; f02da (3c:42da)
cp a, $ff
jr nz, .asm_f02e5
ret
.asm_f02ee
ld hl, wd126
set 6, [hl]
ret
.asm_f02f4
ld hl, wd126
set 5, [hl]
@ -301,7 +149,7 @@ Pointer_f0a7b:
db $ff
Pointer_f0a7bEnd:
Func_f0a82: ; f0a82
TryApplyPikachuMovementData: ; f0a82
ld a, [wd472]
bit 7, a
ret z
@ -325,8 +173,8 @@ Func_f0a82: ; f0a82
pop af
ld [wUpdateSpritesEnabled], a
pop hl
call Func_159b ; homecall Func_fd2a1 - pikachu movement script?
callab Func_fcba1
call ApplyPikachuMovementData
callab RefreshPikachuFollow
ret
Pic_f0abf: ; f0abf (3c:4abf)
@ -365,7 +213,7 @@ INCLUDE "scripts/pewterpokecenter2.asm"
Func_f1e22:
ld hl, PikachuMovementData_f1e2b
ld b, SPRITE_FACING_RIGHT
call Func_f0a82
call TryApplyPikachuMovementData
ret
PikachuMovementData_f1e2b:
@ -382,7 +230,7 @@ INCLUDE "scripts/celadonmansion3_2.asm"
Func_f1f23:
ld hl, PikachuMovementData_f1f2c
ld b, SPRITE_FACING_DOWN
call Func_f0a82
call TryApplyPikachuMovementData
ret
PikachuMovementData_f1f2c:
@ -444,10 +292,10 @@ Func_f2cee:
Func_f2cf4: ; should return to a, instead returns to b
call Random
swap a
cp $55
cp 1 * $ff / 3
ld b, 0
ret c
cp $aa
cp 2 * $ff / 3
ld b, 1
ret c
ld b, 2
@ -459,7 +307,7 @@ Func_f2d06:
ret
Func_f2d0c:
ld hl, GymTrashCans3a
ld hl, GymTrashCans3c
ld a, [wGymTrashCanIndex]
ld c, a
ld b, 0
@ -480,7 +328,7 @@ Func_f2d0c:
ld [wSecondLockTrashCanIndex + 1], a
ret
GymTrashCans3a: ; f2d31 (3c:6d31)
GymTrashCans3c: ; f2d31 (3c:6d31)
; First byte: number of trashcan entries
; Following four byte pairs: indices for the second trash can.
; BUG: Rows that have 3 trashcan entries are sampled incorrectly.

File diff suppressed because it is too large Load Diff

View File

@ -89,7 +89,7 @@ FightingDojoText: ; 5298a (14:698a)
db "@"
PrintIndigoPlateauHQText: ; 5298f (14:698f)
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_UP
ret nz
call EnableAutoTextBoxDrawing

View File

@ -14,7 +14,7 @@ RedBedroomPCText: ; 5db8e (17:5b8e)
db $fc ; FuncTX_ItemStoragePC
Route15GateLeftBinoculars: ; 5db8f (17:5b8f)
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_UP
ret nz
call EnableAutoTextBoxDrawing

View File

@ -3,7 +3,7 @@ GymStatues: ; 625e8 (18:65e8)
; if in a gym and dont have the corresponding badge, a = GymStatueText1_id and jp PrintPredefTextID
; else ret
call EnableAutoTextBoxDrawing
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_UP
ret nz
ld hl, .BadgeFlags
@ -64,7 +64,7 @@ PrintBenchGuyText: ; 6245d (18:645d)
.match
ld a, [hli]
ld b, a
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp b
jr nz, .loop ; player isn't facing left at the bench guy
ld a, [hl]
@ -192,7 +192,7 @@ BookcaseText: ; 62511 (18:6511)
db "@"
OpenPokemonCenterPC: ; 62516 (18:6516)
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_UP ; check to see if player is facing up
ret nz
call EnableAutoTextBoxDrawing

View File

@ -1,6 +1,6 @@
; prints text for bookshelves in buildings without sign events
PrintBookshelfText: ; f9de (3:79de)
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
ld a, [wPlayerFacingDirection] ; player's sprite facing direction
cp SPRITE_FACING_UP
jr nz, .noMatch
; facing up

View File

@ -115,7 +115,7 @@ GameOverText: ; 1e3aa (7:63aa)
db "@"
PrintCinnabarQuiz: ; 1e3af (7:63af)
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_UP
ret nz
call EnableAutoTextBoxDrawing
@ -366,7 +366,7 @@ MagazinesText: ; 1e544 (7:6544)
BillsHousePC: ; 1e549 (7:6549)
call EnableAutoTextBoxDrawing
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_UP
ret nz
CheckEvent EVENT_LEFT_BILLS_HOUSE_AFTER_HELPING
@ -497,7 +497,7 @@ BillsHousePokemonListText2: ; 1e67f (7:667f)
db "@"
DisplayOakLabEmailText: ; 1e684 (7:6684)
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_UP
ret nz
call EnableAutoTextBoxDrawing

File diff suppressed because it is too large Load Diff

View File

@ -553,7 +553,7 @@ CableClubLeftGameboy:: ; 21867 (8:5867)
ld a, [hSerialConnectionStatus]
cp USING_EXTERNAL_CLOCK
ret z
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
ld a, [wPlayerFacingDirection] ; player's sprite facing direction
cp SPRITE_FACING_RIGHT
ret nz
ld a, [wCurMap]
@ -570,7 +570,7 @@ CableClubRightGameboy:: ; 21887 (8:5887)
ld a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK
ret z
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
ld a, [wPlayerFacingDirection] ; player's sprite facing direction
cp SPRITE_FACING_LEFT
ret nz
ld a, [wCurMap]
@ -587,7 +587,7 @@ JustAMomentText:: ; 218a7 (8:58a7)
TX_FAR _JustAMomentText
db "@"
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
ld a, [wPlayerFacingDirection] ; player's sprite facing direction
cp SPRITE_FACING_UP
ret nz
call EnableAutoTextBoxDrawing

View File

@ -89,7 +89,7 @@ GetCoordsInFrontOfPlayer: ; 5265f (14:665f)
ld d, a
ld a, [wXCoord]
ld e, a
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
ld a, [wPlayerFacingDirection] ; player's sprite facing direction
and a
jr nz, .notFacingDown
; facing down

View File

@ -90,7 +90,7 @@ IsPlayerFacingEdgeOfMap: ; c148 (3:4148)
push hl
push de
push bc
ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction
ld a, [wPlayerFacingDirection] ; player sprite's facing direction
srl a
ld c, a
ld b, $0
@ -160,7 +160,7 @@ IsWarpTileInFrontOfPlayer: ; c197 (3:4197)
ld a, [wCurMap]
cp SS_ANNE_5
jr z, .ssAnne5
ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction
ld a, [wPlayerFacingDirection] ; player sprite's facing direction
srl a
ld c, a
ld b, 0

View File

@ -188,7 +188,7 @@ ReplaceTreeTileBlock: ; ef1f (3:6f1f)
ld h, [hl]
ld l, a
add hl, bc
ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction
ld a, [wPlayerFacingDirection] ; player sprite's facing direction
and a
jr z, .down
cp SPRITE_FACING_UP

View File

@ -6,7 +6,7 @@ _GetTileAndCoordsInFrontOfPlayer: ; c2d4 (3:42d4)
ld d, a
ld a, [wXCoord]
ld e, a
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
ld a, [wPlayerFacingDirection] ; player's sprite facing direction
and a ; cp SPRITE_FACING_DOWN
jr nz, .notFacingDown
; facing down
@ -45,7 +45,7 @@ GetTileTwoStepsInFrontOfPlayer: ; c309 (3:4309)
ld a, [hli]
ld d, a
ld e, [hl]
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
ld a, [wPlayerFacingDirection] ; player's sprite facing direction
and a ; cp SPRITE_FACING_DOWN
jr nz, .notFacingDown
; facing down

View File

@ -61,7 +61,7 @@ CheckForHiddenObject: ; f25f8 (3c:65f8)
; checks if the coordinates in front of the player's sprite match Y in b and X in c
; [hCoordsInFrontOfPlayerMatch] = $00 if they match, $ff if they don't match
CheckIfCoordsInFrontOfPlayerMatch: ; 46a01 (11:6a01)
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
ld a, [wPlayerFacingDirection] ; player's sprite facing direction
cp SPRITE_FACING_UP
jr z, .facingUp
cp SPRITE_FACING_LEFT

View File

@ -6,7 +6,7 @@ HandleLedges: ; 1a7f4 (6:67f4)
and a ; OVERWORLD
ret nz
predef GetTileAndCoordsInFrontOfPlayer
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
ld b, a
aCoord 8, 9
ld c, a

View File

@ -28,7 +28,7 @@ _UpdateSprites: ; 4bb7 (1:4bb7)
and a
jp z, UpdatePlayerSprite
cp $f0 ; pikachu
jp z, Func_1552
jp z, SpawnPikachu
ld a, [hl]
UpdateNonPlayerSprite: ; 4be3 (1:4be3)

View File

@ -20,26 +20,26 @@ _InitMapSprites: ; 1401b (5:401b)
; Loads sprite set for outside maps (cities and routes) and sets VRAM slots.
; sets carry if the map is a city or route, unsets carry if not
InitOutsideMapSprites: ; 14029 (5:4029)
ld a,[wCurMap]
cp a,REDS_HOUSE_1F ; is the map a city or a route (map ID less than $25)?
ld a, [wCurMap]
cp a, REDS_HOUSE_1F ; is the map a city or a route (map ID less than $25)?
ret nc ; if not, return
call GetSplitMapSpriteSetID
; if so, choose the appropriate one
ld b,a ; b = spriteSetID
ld a,[wFontLoaded]
bit 0,a ; reloading upper half of tile patterns after displaying text?
jr nz,.loadSpriteSet ; if so, forcibly reload the sprite set
ld a,[wSpriteSetID]
ld b, a ; b = spriteSetID
ld a, [wFontLoaded]
bit 0, a ; reloading upper half of tile patterns after displaying text?
jr nz, .loadSpriteSet ; if so, forcibly reload the sprite set
ld a, [wSpriteSetID]
cp b ; has the sprite set ID changed?
jr z,.skipLoadingSpriteSet ; if not, don't load it again
jr z, .skipLoadingSpriteSet ; if not, don't load it again
.loadSpriteSet
ld a,b
ld [wSpriteSetID],a
ld a, b
ld [wSpriteSetID], a
dec a
ld c,a
ld b,0
ld c, a
ld b, 0
ld a, (wSpriteSetID - wSpriteSet)
ld hl,SpriteSets
ld hl, SpriteSets
call AddNTimes ; get sprite set offset
ld de, wSpriteSet
ld bc, (wSpriteSetID - wSpriteSet)
@ -64,8 +64,8 @@ LoadSpriteSetFromMapHeader: ; 14061 (5:4061)
call FillMemory
ld a, SPRITE_PIKACHU ; load Pikachu separately
ld [wSpriteSet], a
ld hl,wSpriteStateData1 + $10
ld a,$0e
ld hl, wSprite01SpriteStateData1
ld a, 14
.storeVRAMSlotsLoop
push af
ld a, [hl] ; $C1X0 (picture ID) (zero if sprite slot is not used)
@ -79,13 +79,14 @@ LoadSpriteSetFromMapHeader: ; 14061 (5:4061)
ld b, 2
call CheckIfPictureIDAlreadyLoaded
jr .continue
.isFourTileSprite
; loop through the space reserved for regular picture IDs
ld de, wSpriteSet
ld b, 9
call CheckIfPictureIDAlreadyLoaded
.continue
ld de, $10
ld de, wSprite02SpriteStateData1 - wSprite01SpriteStateData1
add hl, de
pop af
dec a
@ -96,6 +97,7 @@ CheckIfPictureIDAlreadyLoaded: ; 1409b (5:409b)
; Check if the current picture ID has already had its tile patterns loaded.
; This done by looping through the previous sprite slots and seeing if any of
; their picture ID's match that of the current sprite slot.
.loop
ld a, [de]
and a ; is sprite set slot not taken up yet?
jr z, .spriteSlotNotTaken ; if so, load it as it signifies we've reached
@ -106,7 +108,8 @@ CheckIfPictureIDAlreadyLoaded: ; 1409b (5:409b)
dec b ; have we reached the end of the sprite set?
jr z, .spriteNotAlreadyLoaded ; if so, we're done here
inc de
jr CheckIfPictureIDAlreadyLoaded
jr .loop
.spriteSlotNotTaken
ld a, c
ld [de], a
@ -127,6 +130,7 @@ CheckForFourTileSprite: ; 140ac (5:40ac)
; regular sprite
and a
ret
.notYellowSprite
scf
ret
@ -140,6 +144,7 @@ LoadMapSpriteTilePatterns: ; 140b7 (5:40b7)
call LoadStillTilePattern
call LoadWalkingTilePattern
jr .continue
.fourTileSprite
call LoadStillTilePattern
.continue
@ -202,7 +207,7 @@ GetSpriteVRAMAddress: ; 14018 (5:4108)
SpriteVRAMAddresses: ; 14118 (5:4118)
; Equivalent to multiplying $C0 (number of bytes in 12 tiles) times the VRAM
; slot and adding the result to $8000 (the VRAM base address).
dw vChars0 + $c0
dw vChars0 + $0c0
dw vChars0 + $180
dw vChars0 + $240
dw vChars0 + $300
@ -211,8 +216,8 @@ SpriteVRAMAddresses: ; 14118 (5:4118)
dw vChars0 + $540
dw vChars0 + $600
dw vChars0 + $6c0
dw vChars0 + $780
dw vChars0 + $7c0
dw vChars0 + $780 ; 4-tile sprites
dw vChars0 + $7c0 ; 4-tile sprites
ReadSpriteSheetData: ; 1412e (5:412e)
ld a, [hVRAMSlot]
@ -246,12 +251,12 @@ ReadSpriteSheetData: ; 1412e (5:412e)
Func_14150: ; 14150 (5:4150)
ld a, $1
ld [wSpriteStateData2 + $e], a ; vram slot for player
ld [wPlayerSpriteImageBaseOffset], a ; vram slot for player
ld a, $2
ld [wSpriteStateData2 + $fe], a ; vram slot for Pikachu
ld [wPikachuSpriteImageBaseOffset], a ; vram slot for Pikachu
ld a, $e
ld hl, wSpriteStateData1 + $10
ld hl, wSprite01SpriteStateData1
.loop
ld [hVRAMSlot], a ; store current sprite set slot as a counter
ld a, [hl] ; $c1x0 (picture ID)
@ -259,12 +264,12 @@ Func_14150: ; 14150 (5:4150)
jr z, .spriteUnused
call Func_14179
push hl
ld de, (wSpriteStateData2 + $e) - (wSpriteStateData1) ; $10e
ld de, (wPlayerSpriteImageBaseOffset) - (wSpriteStateData1) ; $10e
add hl, de ; get $c2xe (sprite image base offset)
ld [hl], a ; write offset
pop hl
.spriteUnused
ld de, $10
ld de, wSprite02SpriteStateData1 - wSprite01SpriteStateData1
add hl, de
ld a, [hVRAMSlot]
dec a
@ -297,67 +302,68 @@ Func_14179: ; 14179 (5:4179)
GetSplitMapSpriteSetID: ; 14193 (5:4193)
ld e, a
ld d, 0
ld hl,MapSpriteSets
ld hl, MapSpriteSets
add hl, de
ld a,[hl] ; a = spriteSetID
cp a,$f0 ; does the map have 2 sprite sets?
ld a, [hl] ; a = spriteSetID
cp a, $f0 ; does the map have 2 sprite sets?
ret c
; Chooses the correct sprite set ID depending on the player's position within
; the map for maps with two sprite sets.
cp a,$f8
jr z,.route20
ld hl,SplitMapSpriteSets
and a,$0f
cp a, $f8
jr z, .route20
ld hl, SplitMapSpriteSets
and a, $0f
dec a
add a
add a
add l
ld l,a
jr nc,.noCarry
ld l, a
jr nc, .noCarry
inc h
.noCarry
ld a,[hli] ; determines whether the map is split East/West or North/South
cp a,$01
ld a,[hli] ; position of dividing line
ld b,a
jr z,.eastWestDivide
ld a, [hli] ; determines whether the map is split East/West or North/South
cp a, $01
ld a, [hli] ; position of dividing line
ld b, a
jr z, .eastWestDivide
.northSouthDivide
ld a,[wYCoord]
ld a, [wYCoord]
jr .compareCoord
.eastWestDivide
ld a,[wXCoord]
ld a, [wXCoord]
.compareCoord
cp b
jr c,.loadSpriteSetID
jr c, .loadSpriteSetID
; if in the East side or South side
inc hl
.loadSpriteSetID
ld a,[hl]
ld a, [hl]
ret
; Uses sprite set $01 for West side and $0A for East side.
; Route 20 is a special case because the two map sections have a more complex
; shape instead of the map simply being split horizontally or vertically.
.route20
ld hl,wXCoord
ld a,[hl]
cp a,$2b
ld a,$01
ld hl, wXCoord
ld a, [hl]
cp a, $2b
ld a, $01
ret c
ld a,[hl]
cp a,$3e
ld a,$0a
ld a, [hl]
cp a, $3e
ld a, $0a
ret nc
ld a,[hl]
cp a,$37
ld b,$08
jr nc,.next
ld b,$0d
ld a, [hl]
cp a, $37
ld b, $08
jr nc, .next
ld b, $0d
.next
ld a,[wYCoord]
ld a, [wYCoord]
cp b
ld a,$0a
ld a, $0a
ret c
ld a,$01
ld a, $01
ret
INCLUDE "data/sprite_sets.asm"

View File

@ -53,7 +53,7 @@ UpdatePlayerSprite: ; 4da5 (1:4da5)
ld a, SPRITE_FACING_RIGHT
jr .next
.next
ld [wSpriteStateData1 + 9], a ; facing direction
ld [wPlayerFacingDirection], a ; facing direction
ld a, [wFontLoaded]
bit 0, a
jr z, .moving
@ -89,7 +89,7 @@ UpdatePlayerSprite: ; 4da5 (1:4da5)
Func_4e32: ; 4e32 (1:4e32)
ld a, [wSpriteStateData1 + 8]
ld b, a
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
add b
ld [wSpriteStateData1 + 2], a
ret

View File

@ -35,7 +35,7 @@ EnterMapAnim: ; 70567 (1c:4567)
ld hl, wFacingDirectionList
call PlayerSpinInPlace
ld a, $1
ld [wd431], a
ld [wPikachuSpawnState], a
.restoreDefaultMusic
call PlayDefaultMusic
.done
@ -46,7 +46,7 @@ EnterMapAnim: ; 70567 (1c:4567)
call DelayFrames
call PlayerSpinWhileMovingDown
ld a, $0
ld [wd431], a
ld [wPikachuSpawnState], a
jr .done
.flyAnimation
pop hl
@ -63,7 +63,7 @@ EnterMapAnim: ; 70567 (1c:4567)
call DoFlyAnimation
call LoadPlayerSpriteGraphics
ld a, $1
ld [wd431], a
ld [wPikachuSpawnState], a
jr .restoreDefaultMusic
FlyAnimationEnterScreenCoords: ; 705ed (1c:45ed)

View File

@ -63,7 +63,7 @@ DisplayPokemonCenterDialogue_: ; 6d97 (1:6d97)
callab IsStarterPikachuInOurParty
call c, Func_6eaa
ld a, $5
ld [wd431], a
ld [wPikachuSpawnState], a
call Func_1525
.doNotReturnPikachu
lb bc, 1, 0

View File

@ -32,7 +32,7 @@ AnimateBoulderDust: ; 7a0fb (1e:60fb)
jp LoadPlayerSpriteGraphics
GetMoveBoulderDustFunctionPointer: ; 7913f (1e:613f)
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
ld a, [wPlayerFacingDirection] ; player's sprite facing direction
ld hl, MoveBoulderDustFunctionPointerTable
ld c, a
ld b, $0

View File

@ -2,7 +2,7 @@ ApplyOutOfBattlePoisonDamage: ; c3de (3:43de)
ld a, [wd730]
add a
jp c, .noBlackOut ; no black out if joypad states are being simulated
ld a, [wPreventBlackout]
ld a, [wd492]
bit 7, a
jp nz, .noBlackOut
ld a, [wd72e]

View File

@ -38,7 +38,7 @@ Func_f0a7: ; f0a7 (3:70a7)
jp nz, ResetBoulderPushFlags
ld a, [hJoyHeld]
ld b, a
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
ld a, [wPlayerFacingDirection] ; player's sprite facing direction
cp SPRITE_FACING_UP
jr z, .pushBoulderUp
cp SPRITE_FACING_LEFT

674
engine/pikachu_emotions.asm Executable file
View File

@ -0,0 +1,674 @@
IsPlayerTalkingToPikachu:: ; fcf0c (3f:4f0c)
ld a, [wd436]
and a
ret z
ld a, [hSpriteIndexOrTextID]
cp $f
ret nz
call InitializePikachuTextID
xor a
ld [hSpriteIndexOrTextID], a
ld [wd436], a
ret
InitializePikachuTextID: ; fcf20 (3f:4f20)
ld a, $d4 ; display
ld [hSpriteIndexOrTextID], a
xor a
ld [wPlayerMovingDirection], a
ld a, $1
ld [wAutoTextBoxDrawingControl], a
call DisplayTextID
xor a
ld [wAutoTextBoxDrawingControl], a
ret
DoStarterPikachuEmotions: ; fcf35 (3f:4f35)
ld e, a
ld d, $0
add hl, de
add hl, de
ld e, [hl]
inc hl
ld d, [hl]
.loop
ld a, [de]
inc de
cp $ff
jr z, .done
ld c, a
ld b, $0
ld hl, StarterPikachuEmotionsJumptable
add hl, bc
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
call JumpToAddress
jr .loop
.done
ret
StarterPikachuEmotionsJumptable: ; fcf54 (3f:4f54)
dw StarterPikachuEmotionCommand_nop ; 0
dw StarterPikachuEmotionCommand_text ; 1
dw StarterPikachuEmotionCommand_pcm ; 2
dw StarterPikachuEmotionCommand_emote ; 3
dw StarterPikachuEmotionCommand_movement ; 4
dw StarterPikachuEmotionCommand_pikapic ; 5
dw StarterPikachuEmotionCommand_subcmd ; 6
dw StarterPikachuEmotionCommand_delay ; 7
dw StarterPikachuEmotionCommand_nop2 ; 8
dw StarterPikachuEmotionCommand_9 ; 9
dw StarterPikachuEmotionCommand_nop3 ; a
StarterPikachuEmotionCommand_nop: ; fcf6a (3f:4f6a)
StarterPikachuEmotionCommand_nop3: ; fcf6a (3f:4f6a)
ret
StarterPikachuEmotionCommand_text: ; fcf6b (3f:4f6b)
ld a, [de]
ld l, a
inc de
ld a, [de]
ld h, a
inc de
push de
call PrintText
pop de
ret
StarterPikachuEmotionCommand_pcm: ; fcf77 (3f:4f77)
ld a, [de]
inc de
push de
ld e, a
nop
call PlayPikachuSoundClip_
pop de
ret
PlayPikachuSoundClip_: ; fcf81 (3f:4f81)
cp $ff
ret z
callab PlayPikachuSoundClip
ret
StarterPikachuEmotionCommand_emote: ; fcf8d (3f:4f8d)
ld a, [wUpdateSpritesEnabled]
push af
ld a, $ff
ld [wUpdateSpritesEnabled], a
ld a, [de]
inc de
push de
call ShowPikachuEmoteBubble
pop de
pop af
ld [wUpdateSpritesEnabled], a
ret
ShowPikachuEmoteBubble: ; fcfa2 (3f:4fa2)
ld [wWhichEmotionBubble], a
ld a, $f
ld [wEmotionBubbleSpriteIndex], a
predef EmotionBubble
ret
StarterPikachuEmotionCommand_movement: ; fcfb0 (3f:4fb0)
ld a, [de]
inc de
ld l, a
ld a, [de]
inc de
ld h, a
push de
ld b, BANK(DoStarterPikachuEmotions)
call ApplyPikachuMovementData_
pop de
ret
StarterPikachuEmotionCommand_delay: ; fcfbe (3f:4fbe)
ld a, [de]
inc de
push de
ld c, a
call DelayFrames
pop de
ret
StarterPikachuEmotionCommand_subcmd: ; fcfc7 (3f:4fc7)
ld a, [de]
inc de
push de
ld e, a
ld d, $0
ld hl, Jumptable_fcfda
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
call JumpToAddress
pop de
ret
Jumptable_fcfda:
dw LoadPikachuSpriteIntoVRAM
dw LoadFontTilePatterns
dw Pikachu_LoadCurrentMapViewUpdateSpritesAndDelay3
dw WaitForTextScrollButtonPress
dw PikachuPewterPokecenterCheck
dw PikachuFanClubCheck
dw PikachuBillsHouseCheck
StarterPikachuEmotionCommand_nop2: ; fcfe8 (3f:4fe8)
ret
StarterPikachuEmotionCommand_9: ; fcfe9 (3f:4fe9)
push de
call StarterPikachuEmotionCommand_turnawayfromplayer
call UpdateSprites
pop de
ret
StarterPikachuEmotionCommand_turnawayfromplayer: ; fcff2 (3f:4ff2)
ld a, [wPlayerFacingDirection]
xor $4
ld [wPikachuFacingDirection], a
ret
DeletedFunction_fcffb: ; fcffb (3f:4ffb)
; Inexplicably empty.
rept 5
nop
endr
ret
Func_fd001:: ; fd001 (3f:5001)
ld a, e
jr load_expression
Func_fd004:: ; fd004 (3f:5004)
call MapSpecificPikachuExpression
jr c, load_expression
call GetPikaPicAnimationScriptIndex
call DeletedFunction_fcffb
load_expression: ; fd00f (3f:500f)
ld [wExpressionNumber], a
ld hl, PikachuEmotionTable
call DoStarterPikachuEmotions
ret
PikachuEmotionTable: ; fd019 (3f:4019)
dw PikachuEmotion0_fd115
dw PikachuEmotion1_fd141
dw PikachuEmotion2_fd116
dw PikachuEmotion3_fd160
dw PikachuEmotion4_fd136
dw PikachuEmotion5_fd14d
dw PikachuEmotion6_fd153
dw PikachuEmotion7_fd128
dw PikachuEmotion8_fd147
dw PikachuEmotion9_fd166
dw PikachuEmotion10_fd11e
dw PikachuEmotion11_fd173
dw PikachuEmotion12_fd17a
dw PikachuEmotion13_fd180
dw PikachuEmotion14_fd189
dw PikachuEmotion15_fd191
dw PikachuEmotion16_fd197
dw PikachuEmotion17_fd19d
dw PikachuEmotion18_fd1a3
dw PikachuEmotion19_fd1a9
dw PikachuEmotion20_fd1b1
dw PikachuEmotion21_fd1b9 ; used a fishing rod
dw PikachuEmotion22_fd1c1
dw PikachuEmotion23_fd1c7
dw PikachuEmotion24_fd1cf
dw PikachuEmotion25_fd1d7
dw PikachuEmotion26_fd1df ; wake up pikachu in pewter pokemon center
dw PikachuEmotion27_fd1eb
dw PikachuEmotion28_fd1f1
dw PikachuEmotion29_fd1f7
dw PikachuEmotion30_fd1fc
dw PikachuEmotion31_fd20a
dw PikachuEmotion32_fd213
dw PikachuEmotion33_fd05d
PikachuEmotion33_fd05d: ; fd05d (3f:505d)
db $ff
MapSpecificPikachuExpression: ; fd05e (3f:505e)
ld a, [wCurMap]
cp POKEMON_FAN_CLUB
jr nz, .notFanClub
ld hl, wd492
bit 7, [hl]
ld a, $1d
jr z, .set_carry
call CheckPikachuFollowingPlayer
ld a, $1e
jr nz, .set_carry
jr .asm_fd096
.notFanClub
ld a, [wCurMap]
cp PEWTER_POKECENTER
jr nz, .notPewterPokecenter
call CheckPikachuFollowingPlayer
ld a, $1a
jr nz, .set_carry
jr .asm_fd096
.notPewterPokecenter
callab Func_f24ae
ld a, e
cp $ff
jr nz, .set_carry
jr .asm_fd096
.asm_fd096
call IsPlayerPikachuAsleepInParty
ld a, $b
jr c, .set_carry
callab Func_fce73 ; same bank
ld a, $1c
jr c, .set_carry
ld a, [wCurMap]
cp POKEMONTOWER_1
jr c, .notInLavenderTower
cp POKEMONTOWER_7 + 1
ld a, $16
jr c, .set_carry
.notInLavenderTower
ld a, [wd49c]
and a
jr z, .no_carry
dec a
ld c, a
ld b, $0
ld hl, Pointer_fd0cb
add hl, bc
ld a, [hl]
jr .set_carry
.no_carry
and a
ret
.set_carry
scf
ret
Pointer_fd0cb:
db $12, $15, $17, $18, $19
IsPlayerPikachuAsleepInParty:: ; fd0d0 (3f:50d0)
xor a
ld [wWhichPokemon], a
.loop
ld a, [wWhichPokemon]
ld c, a
ld b, $0
ld hl, wPartySpecies
add hl, bc
ld a, [hl]
cp $ff
jr z, .done
cp PIKACHU
jr nz, .curMonNotStarterPikachu
callab IsThisPartymonStarterPikachu
jr nc, .curMonNotStarterPikachu
ld a, [wWhichPokemon]
ld hl, wPartyMon1Status
ld bc, wPartyMon2 - wPartyMon1
call AddNTimes
ld a, [hl]
and SLP
jr z, .done
jr .curMonSleepingPikachu
.curMonNotStarterPikachu
ld a, [wWhichPokemon]
cp PARTY_LENGTH - 1
jr z, .done
inc a
ld [wWhichPokemon], a
jr .loop
.curMonSleepingPikachu
scf
ret
.done
and a
ret
PikachuEmotion0_fd115: ; fd115 (3f:5115)
db $ff
PikachuEmotion2_fd116: ; fd116 (3f:5116)
pikaemotion_dummy2
pikaemotion_emotebubble SMILE_BUBBLE
pikaemotion_pcm PikachuCry35
pikaemotion_pikapic $2
db $ff
PikachuEmotion10_fd11e: ; fd11e (3f:511e)
pikaemotion_dummy2
pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES
pikaemotion_emotebubble HEART_BUBBLE
pikaemotion_pcm PikachuCry5
pikaemotion_pikapic $a
db $ff
PikachuEmotion7_fd128: ; fd128 (3f:5128)
pikaemotion_dummy2
pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES
pikaemotion_movement Pointer_fd224
pikaemotion_pcm PikachuCry1
pikaemotion_movement Pointer_fd224
pikaemotion_pikapic $7
db $ff
PikachuEmotion4_fd136: ; fd136 (3f:5136)
pikaemotion_dummy2
pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES
pikaemotion_movement Pointer_fd230
pikaemotion_pcm PikachuCry29
pikaemotion_pikapic $4
db $ff
PikachuEmotion1_fd141: ; fd141 (3f:5141)
pikaemotion_dummy2
pikaemotion_pcm
pikaemotion_pikapic $1
db $ff
PikachuEmotion8_fd147: ; fd147 (3f:5147)
pikaemotion_dummy2
pikaemotion_pcm PikachuCry39
pikaemotion_pikapic $8
db $ff
PikachuEmotion5_fd14d: ; fd14d (3f:514d)
pikaemotion_dummy2
pikaemotion_pcm PikachuCry31
pikaemotion_pikapic $5
db $ff
PikachuEmotion6_fd153: ; fd153 (3f:5153)
pikaemotion_dummy2
pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES
pikaemotion_pcm
pikaemotion_movement Pointer_fd21e
pikaemotion_emotebubble SKULL_BUBBLE
pikaemotion_pikapic $6
db $ff
PikachuEmotion3_fd160: ; fd160 (3f:5160)
pikaemotion_dummy2
pikaemotion_pcm PikachuCry40
pikaemotion_pikapic $3
db $ff
PikachuEmotion9_fd166: ; fd166 (3f:5166)
pikaemotion_dummy2
pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES
pikaemotion_pcm PikachuCry6
pikaemotion_movement Pointer_fd218
pikaemotion_emotebubble SKULL_BUBBLE
pikaemotion_pikapic $9
db $ff
PikachuEmotion11_fd173: ; fd173 (3f:5173)
pikaemotion_emotebubble ZZZ_BUBBLE
pikaemotion_pcm PikachuCry37
pikaemotion_pikapic $b
db $ff
PikachuEmotion12_fd17a: ; fd17a (3f:517a)
pikaemotion_dummy2
pikaemotion_pcm
pikaemotion_pikapic $c
db $ff
PikachuEmotion13_fd180: ; fd180 (3f:5180)
pikaemotion_dummy2
pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES
pikaemotion_movement Pointer_fd21e
pikaemotion_pikapic $d
db $ff
PikachuEmotion14_fd189: ; fd189 (3f:5189)
pikaemotion_dummy2
pikaemotion_emotebubble BOLT_BUBBLE
pikaemotion_pcm PikachuCry10
pikaemotion_pikapic $e
db $ff
PikachuEmotion15_fd191: ; fd191 (3f:5191)
pikaemotion_dummy2
pikaemotion_pcm PikachuCry34
pikaemotion_pikapic $f
db $ff
PikachuEmotion16_fd197: ; fd197 (3f:5197)
pikaemotion_dummy2
pikaemotion_pcm PikachuCry33
pikaemotion_pikapic $10
db $ff
PikachuEmotion17_fd19d: ; fd19d (3f:519d)
pikaemotion_dummy2
pikaemotion_pcm PikachuCry13
pikaemotion_pikapic $11
db $ff
PikachuEmotion18_fd1a3: ; fd1a3 (3f:51a3)
pikaemotion_dummy2
pikaemotion_pcm
pikaemotion_pikapic $12
db $ff
PikachuEmotion19_fd1a9: ; fd1a9 (3f:51a9)
pikaemotion_dummy2
pikaemotion_emotebubble HEART_BUBBLE
pikaemotion_pcm PikachuCry33
pikaemotion_pikapic $13
db $ff
PikachuEmotion20_fd1b1: ; fd1b1 (3f:51b1)
pikaemotion_dummy2
pikaemotion_emotebubble HEART_BUBBLE
pikaemotion_pcm PikachuCry5
pikaemotion_pikapic $14
db $ff
PikachuEmotion21_fd1b9: ; fd1b9 (3f:51b9)
pikaemotion_dummy2
pikaemotion_emotebubble FISH_BUBBLE
pikaemotion_pcm
pikaemotion_pikapic $15
db $ff
PikachuEmotion22_fd1c1: ; fd1c1 (3f:51c1)
pikaemotion_dummy2
pikaemotion_pcm PikachuCry4
pikaemotion_pikapic $16
db $ff
PikachuEmotion23_fd1c7: ; fd1c7 (3f:51c7)
pikaemotion_dummy2
pikaemotion_pcm PikachuCry19
pikaemotion_pikapic $17
pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW
db $ff
PikachuEmotion24_fd1cf: ; fd1cf (3f:51cf)
pikaemotion_dummy2
pikaemotion_emotebubble EXCLAMATION_BUBBLE
pikaemotion_pcm
pikaemotion_pikapic $18
db $ff
PikachuEmotion25_fd1d7: ; fd1d7 (3f:51d7)
pikaemotion_dummy2
pikaemotion_emotebubble BOLT_BUBBLE
pikaemotion_pcm PikachuCry35
pikaemotion_pikapic $19
db $ff
PikachuEmotion26_fd1df: ; fd1df (3f:51df)
pikaemotion_dummy2
pikaemotion_emotebubble ZZZ_BUBBLE
pikaemotion_pcm PikachuCry37
pikaemotion_pikapic $1a
pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW
pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKPEWTERCENTER
db $ff
PikachuEmotion27_fd1eb: ; fd1eb (3f:51eb)
pikaemotion_dummy2
pikaemotion_pcm PikachuCry9
pikaemotion_pikapic $1b
db $ff
PikachuEmotion28_fd1f1: ; fd1f1 (3f:51f1)
pikaemotion_dummy2
pikaemotion_pcm PikachuCry15
pikaemotion_pikapic $1c
db $ff
PikachuEmotion29_fd1f7: ; fd1f7 (3f:51f7)
pikaemotion_pcm PikachuCry5
pikaemotion_pikapic $a
db $ff
PikachuEmotion30_fd1fc: ; fd1fc (3f:51fc)
pikaemotion_9
pikaemotion_emotebubble HEART_BUBBLE
pikaemotion_pcm PikachuCry5
pikaemotion_pikapic $14
pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW
pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADFONT
pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKLAVENDERTOWER
db $ff
PikachuEmotion31_fd20a: ; fd20a (3f:520a)
pikaemotion_pcm PikachuCry19
pikaemotion_pikapic $17
pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW
pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKBILLSHOUSE
db $ff
PikachuEmotion32_fd213: ; fd213 (3f:5213)
pikaemotion_pcm PikachuCry26
pikaemotion_pikapic $17
db $ff
Pointer_fd218: ; fd218 (3f:5218)
db $00
db $39, $01
db $3e, $1e
db $3f
Pointer_fd21e: ; fd21e (3f:521e)
db $00
db $39, $00
db $3e, $1e
db $3f
Pointer_fd224: ; fd224 (3f:5224)
db $00
db $3c, $07, $2f
db $3c, $07, $2f
db $3f
Pointer_fd22c: ; fd22c (3f:522c)
db $3b, $1f, $03
db $3f
Pointer_fd230: ; fd230 (3f:5230)
db $00
db $3c, $0f, $1f
db $3c, $0f, $1f
db $3f
Pointer_fd238: ; fd238 (3f:5238)
db $00
db $05, $07
db $39, $00
db $05, $07
db $06, $07
db $39, $00
db $06, $07
db $08, $07
db $39, $00
db $08, $07
db $07, $07
db $39, $00
db $07, $07
db $3f
Func_fd252: ; fd252 (3f:5252)
ld a, $40
ld [h_0xFFFC], a
call LoadPikachuSpriteIntoVRAM
call Func_fd266
and a
jr z, .asm_fd262
call ApplyPikachuMovementData
.asm_fd262
xor a
ld [h_0xFFFC], a
ret
Func_fd266:
ld a, [wSpriteStateData2 + 15 * 16 + 4]
ld e, a
ld a, [wSpriteStateData2 + 15 * 16 + 5]
ld d, a
ld a, [wYCoord]
add 4
cp e
jr z, .asm_fd280
jr nc, .asm_fd27e
ld hl, Data_fd294
ld a, 1
ret
.asm_fd27e
xor a
ret
.asm_fd280
ld a, [wXCoord]
add 4
cp d
jr c, .asm_fd28e
ld hl, Data_fd299
ld a, 2
ret
.asm_fd28e
ld hl, Data_fd29d
ld a, 3
ret
Data_fd294:
db $00
db $36
db $2b
db $34
db $3f
Data_fd299:
db $00
db $36
db $34
db $3f
Data_fd29d:
db $00
db $36
db $33
db $3f

1039
engine/pikachu_movement.asm Executable file

File diff suppressed because it is too large Load Diff

154
engine/pikachu_pcm.asm Executable file
View File

@ -0,0 +1,154 @@
PlayPikachuSoundClip:: ; f0000 (3c:4000)
ld a, e
ld e, a
ld d, $0
ld hl, PikachuCriesPointerTable
add hl, de
add hl, de
add hl, de
ld b, [hl] ; bank of pikachu cry data
inc hl
ld a, [hli] ; cry data pointer
ld h, [hl]
ld l, a
ld c, $4
.loop
dec c
jr z, .done_delay
call DelayFrame
jr .loop
.done_delay
di
push bc
push hl
ld a, $80
ld [rNR52], a
ld a, $77
ld [rNR50], a
xor a
ld [rNR30], a
ld hl, $ff30 ; wave data
ld de, wRedrawRowOrColumnSrcTiles
.saveWaveDataLoop
ld a, [hl]
ld [de], a
inc de
ld a, $ff
ld [hli], a
ld a, l
cp $40 ; end of wave data
jr nz, .saveWaveDataLoop
ld a, $80
ld [rNR30], a
ld a, [rNR51]
or $44
ld [rNR51], a
ld a, $ff
ld [rNR31], a
ld a, $20
ld [rNR32], a
ld a, $ff
ld [rNR33], a
ld a, $87
ld [rNR34], a
pop hl
pop bc
call PlayPikachuPCM
xor a
ld [wc0f3], a
ld [wc0f4], a
ld a, $80
ld [rNR52], a
xor a
ld [rNR30], a
ld hl, $ff30
ld de, wRedrawRowOrColumnSrcTiles
.reloadWaveDataLoop
ld a, [de]
inc de
ld [hli], a
ld a, l
cp $40 ; end of wave data
jr nz, .reloadWaveDataLoop
ld a, $80
ld [rNR30], a
ld a, [rNR51]
and $bb
ld [rNR51], a
xor a
ld [wChannelSoundIDs+CH4], a
ld [wChannelSoundIDs+CH5], a
ld [wChannelSoundIDs+CH6], a
ld [wChannelSoundIDs+CH7], a
ld a, [H_LOADEDROMBANK]
ei
ret
PikachuCriesPointerTable: ; f008e (3c:408e)
; format:
; db bank
; dw pointer to cry
; bank 21
pikacry_def PikachuCry1 ; 21:4000
pikacry_def PikachuCry2 ; 21:491a
pikacry_def PikachuCry3 ; 21:4fdc
pikacry_def PikachuCry4 ; 21:59ee
; bank 22
pikacry_def PikachuCry5 ; 22:4000
pikacry_def PikachuCry6 ; 22:5042
pikacry_def PikachuCry7 ; 22:6254
; bank 23
pikacry_def PikachuCry8 ; 23:4000
pikacry_def PikachuCry9 ; 23:50ca
pikacry_def PikachuCry10 ; 23:5e0c
; bank 24
pikacry_def PikachuCry11 ; 24:4000
pikacry_def PikachuCry12 ; 24:4722
pikacry_def PikachuCry13 ; 24:54a4
; bank 25
pikacry_def PikachuCry14 ; 25:4000
pikacry_def PikachuCry15 ; 25:589a
; banks 31-34, in no particular order
pikacry_def PikachuCry16 ; 31:4000
pikacry_def PikachuCry17 ; 34:4000
pikacry_def PikachuCry18 ; 31:549a
pikacry_def PikachuCry19 ; 33:4000
pikacry_def PikachuCry20 ; 32:4000
pikacry_def PikachuCry21 ; 32:6002
pikacry_def PikachuCry22 ; 31:63a4
pikacry_def PikachuCry23 ; 34:4862
pikacry_def PikachuCry24 ; 33:5632
pikacry_def PikachuCry25 ; 34:573c
pikacry_def PikachuCry26 ; 33:725c
; bank 35
pikacry_def PikachuCry27 ; 35:4000
pikacry_def PikachuCry28 ; 35:4b5a
pikacry_def PikachuCry29 ; 35:5da4
pikacry_def PikachuCry30 ; 35:69ce
pikacry_def PikachuCry31 ; 35:6e80
; bank 36
pikacry_def PikachuCry32 ; 36:4000
pikacry_def PikachuCry33 ; 36:458a
pikacry_def PikachuCry34 ; 36:523c
; bank 37
pikacry_def PikachuCry35 ; 37:4000
pikacry_def PikachuCry36 ; 37:522a
; banks 36-38
pikacry_def PikachuCry37 ; 38:4000
pikacry_def PikachuCry38 ; 38:4dfa
pikacry_def PikachuCry39 ; 37:6e0c
pikacry_def PikachuCry40 ; 38:5a64
pikacry_def PikachuCry41 ; 36:6746
pikacry_def PikachuCry42 ; 38:6976

File diff suppressed because it is too large Load Diff

View File

@ -85,7 +85,7 @@ Func_f80a8:
ret
Func_f80ac:
ld hl, wPreventBlackout
ld hl, wd492
bit 1, [hl]
ret z
ld a, [hJoyPressed]

View File

@ -70,6 +70,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
jr z, .notSimulating
ld a, [hJoyHeld]
jr .checkIfStartIsPressed
.notSimulating
ld a, [hJoyPressed]
.checkIfStartIsPressed
@ -79,6 +80,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
xor a
ld [hSpriteIndexOrTextID], a ; start menu text ID
jp .displayDialogue
.startButtonNotPressed
bit 0, a ; A button
jp z, .checkIfDownButtonIsPressed
@ -116,6 +118,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
xor a
ld [wLinkTimeoutCounter], a
jp EnterMap
; predef LoadSAV
; ld a, [wCurMap]
; ld [wDestinationMap], a
@ -129,6 +132,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
and a
jp nz, .newBattle
jp OverworldLoop
.noDirectionButtonsPressed
call UpdateSprites ; 231c
ld hl, wFlags_0xcd60
@ -146,6 +150,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
ld [wPlayerMovingDirection], a ; zero the direction
.overworldloop
jp OverworldLoop
.checkIfDownButtonIsPressed
ld a, [hJoyHeld] ; current joypad state
bit 7, a ; down button
@ -154,6 +159,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
ld [wSpriteStateData1 + 3], a ; delta Y
ld a, PLAYER_DIR_DOWN
jr .handleDirectionButtonPress
.checkIfUpButtonIsPressed
bit 6, a ; up button
jr z, .checkIfLeftButtonIsPressed
@ -161,6 +167,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
ld [wSpriteStateData1 + 3], a ; delta Y
ld a, PLAYER_DIR_UP
jr .handleDirectionButtonPress
.checkIfLeftButtonIsPressed
bit 5, a ; left button
jr z, .checkIfRightButtonIsPressed
@ -168,6 +175,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
ld [wSpriteStateData1 + 5], a ; delta X
ld a, PLAYER_DIR_LEFT
jr .handleDirectionButtonPress
.checkIfRightButtonIsPressed
bit 4, a ; right button
jr z, .noDirectionButtonsPressed
@ -199,6 +207,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
call NewBattle
jp c, .battleOccurred
jp OverworldLoop
.noDirectionChange
ld a, [wPlayerDirection] ; current direction
ld [wPlayerMovingDirection], a ; save direction
@ -221,6 +230,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
pop hl
jp c, CheckWarpsCollision
jp OverworldLoop
.surfing
call CollisionCheckOnWater
jp c, OverworldLoop
@ -229,6 +239,7 @@ OverworldLoopLessDelay:: ; 0245 (0:0245)
ld [wWalkCounter], a
callab Func_fcc08
jr .moveAhead2
.moveAhead
call IsSpinning
call UpdateSprites ; move sprites
@ -403,6 +414,7 @@ CheckWarpsNoCollisionLoop:: ; 04d5 (0:04d5)
jr z, CheckWarpsNoCollisionRetry2 ; if directional buttons aren't being pressed, do not pass through the warp
jr WarpFound1
CheckWarpsNoCollisionRetry1:: ; 050f (0:050f)
inc hl
CheckWarpsNoCollisionRetry2:: ; 0510 (0:0510)
@ -414,6 +426,7 @@ ContinueCheckWarpsNoCollisionLoop:: ; 0512 (0:0512)
jp nz, CheckWarpsNoCollisionLoop
jp CheckMapConnections
; check if the player has stepped onto a warp after having collided
CheckWarpsCollision:: ; 051a (0:051a)
ld a, [wNumberOfWarps]
@ -435,6 +448,7 @@ CheckWarpsCollision:: ; 051a (0:051a)
ld a, [hl]
ld [hWarpDestinationMap], a
jr WarpFound2
.retry1
inc hl
.retry2
@ -471,10 +485,12 @@ WarpFound2:: ; 054a (0:054a)
ld [wMapPalOffset], a
call GBFadeOutToBlack
.notRockTunnel
callab Func_fc5fa ; 3f:45fa
callab CalculatePikachuSpawnState1 ; 3f:45fa
call PlayMapChangeSound
jr .done
; for maps that can have the 0xFF destination map, which means to return to the outside map; not all these maps are necessarily indoors, though
; for maps that can have the 0xFF destination map, which means to return to the outside map
; not all these maps are necessarily indoors, though
.indoorMaps
ld a, [hWarpDestinationMap] ; destination map
cp $ff
@ -490,16 +506,18 @@ WarpFound2:: ; 054a (0:054a)
ld hl, wd732
set 3, [hl]
jr .skipMapChangeSound
.notWarpPad
call PlayMapChangeSound
.skipMapChangeSound
ld hl, wd736
res 0, [hl]
res 1, [hl]
callab Func_fc65b ; 3f:465b
callab CalculatePikachuSpawnState2 ; 3f:465b
jr .done
.goBackOutside
callab Func_fc69a ; 3f:469a
callab CalculatePikachuSpawnState3 ; 3f:469a
ld a, [wLastMap]
ld [wCurMap], a
call PlayMapChangeSound
@ -548,6 +566,7 @@ CheckMapConnections:: ; 05db (0:05db)
ld a, h
ld [wCurrentTileBlockMapViewPointer + 1], a
jp .loadNewMap
.checkEastMap
ld b, a
ld a, [wCurrentMapWidth2] ; map width
@ -584,6 +603,7 @@ CheckMapConnections:: ; 05db (0:05db)
ld a, h
ld [wCurrentTileBlockMapViewPointer + 1], a
jp .loadNewMap
.checkNorthMap
ld a, [wYCoord]
cp $ff
@ -610,6 +630,7 @@ CheckMapConnections:: ; 05db (0:05db)
ld a, h
ld [wCurrentTileBlockMapViewPointer + 1], a
jp .loadNewMap
.checkSouthMap
ld b, a
ld a, [wCurrentMapHeight2]
@ -641,7 +662,7 @@ CheckMapConnections:: ; 05db (0:05db)
ld hl, wPikachuOverworldStateFlags
set 4, [hl]
ld a, $2
ld [wd431], a
ld [wPikachuSpawnState], a
call LoadMapHeader ; 0dab (0:0dab)
call PlayDefaultMusicFadeOutCurrent ; music
ld b, SET_PAL_OVERWORLD
@ -651,6 +672,7 @@ CheckMapConnections:: ; 05db (0:05db)
call InitMapSprites
call LoadTileBlockMap
jp OverworldLoopLessDelay
.didNotEnterConnectedMap
jp OverworldLoop
@ -666,6 +688,7 @@ PlayMapChangeSound:: ; 06ef (0:06ef)
jr nz, .didNotGoThroughDoor
ld a, $ad ; SFX_GO_INSIDE
jr .playSound
.didNotGoThroughDoor
ld a, $b5 ; SFX_GO_OUTSIDE
.playSound
@ -713,6 +736,7 @@ ExtraWarpCheck:: ; 071a (0:071a)
.useFunction1
ld hl, IsPlayerFacingEdgeOfMap
jr .doBankswitch
.useFunction2
ld hl, IsWarpTileInFrontOfPlayer
.doBankswitch
@ -780,6 +804,7 @@ Func_07c4:: ; 07c4 (0:07c4)
call PlayDefaultMusic
ret
LoadPlayerSpriteGraphics:: ; 07d7 (0:07d7)
; Load sprite graphics based on whether the player is standing, biking, or surfing.
@ -1073,7 +1098,7 @@ IsSpriteInFrontOfPlayer:: ; 0983 (0:0983)
ld d, $10 ; talking range in pixels (normal range)
IsSpriteInFrontOfPlayer2:: ; 0985 (0:0985)
lb bc, $3c, $40 ; Y and X position of player sprite
ld a, [wSpriteStateData1 + 9] ; direction the player is facing
ld a, [wPlayerFacingDirection] ; direction the player is facing
.checkIfPlayerFacingUp
cp SPRITE_FACING_UP
jr nz, .checkIfPlayerFacingDown
@ -1083,6 +1108,7 @@ IsSpriteInFrontOfPlayer2:: ; 0985 (0:0985)
ld b, a
ld a, PLAYER_DIR_UP
jr .doneCheckingDirection
.checkIfPlayerFacingDown
cp SPRITE_FACING_DOWN
jr nz, .checkIfPlayerFacingRight
@ -1092,6 +1118,7 @@ IsSpriteInFrontOfPlayer2:: ; 0985 (0:0985)
ld b, a
ld a, PLAYER_DIR_DOWN
jr .doneCheckingDirection
.checkIfPlayerFacingRight
cp SPRITE_FACING_RIGHT
jr nz, .playerFacingLeft
@ -1101,6 +1128,7 @@ IsSpriteInFrontOfPlayer2:: ; 0985 (0:0985)
ld c, a
ld a, PLAYER_DIR_RIGHT
jr .doneCheckingDirection
.playerFacingLeft
; facing left
ld a, c
@ -1140,6 +1168,7 @@ IsSpriteInFrontOfPlayer2:: ; 0985 (0:0985)
jr nz, .spriteLoop
xor a
ret
.foundSpriteInFrontOfPlayer
pop hl
ld a, l
@ -1158,6 +1187,7 @@ IsSpriteInFrontOfPlayer2:: ; 0985 (0:0985)
scf
ret
SignLoop:: ; 09f2 (0:09f2)
; search if a player is facing a sign
ld hl, wSignCoords ; start of sign coordinates
@ -1171,6 +1201,7 @@ SignLoop:: ; 09f2 (0:09f2)
jr z, .yCoordMatched
inc hl
jr .retry
.yCoordMatched
ld a, [hli] ; sign X
cp e
@ -1189,6 +1220,7 @@ SignLoop:: ; 09f2 (0:09f2)
pop hl
scf
ret
.retry
dec b
jr nz, .signLoop
@ -1248,6 +1280,7 @@ CollisionCheckOnLand:: ; 0a1c (0:0a1c)
.setCarry
scf
ret
.noCollision
and a
ret
@ -1300,6 +1333,7 @@ CheckForTilePairCollisions:: ; 0aa6 (0:0aa6)
.retry
inc hl
jr .tilePairCollisionLoop
.tilesetMatches
ld a, [wTilePlayerStandingOn] ; tile the player is on
ld b, a
@ -1311,12 +1345,14 @@ CheckForTilePairCollisions:: ; 0aa6 (0:0aa6)
cp b
jr z, .currentTileMatchesSecondInPair
jr .retry
.currentTileMatchesFirstInPair
inc hl
ld a, [hl]
cp c
jr z, .foundMatch
jr .tilePairCollisionLoop
.currentTileMatchesSecondInPair
dec hl
ld a, [hli]
@ -1326,6 +1362,7 @@ CheckForTilePairCollisions:: ; 0aa6 (0:0aa6)
.foundMatch
scf
ret
.noMatch
and a
ret
@ -1481,6 +1518,7 @@ CopyToRedrawRowOrColumnSrcTiles:: ; 0baa (0:0baa)
jr nz, .loop
ret
ScheduleSouthRowRedraw:: ; 0bb6 (0:0bb6)
coord hl, 0, 16
call CopyToRedrawRowOrColumnSrcTiles
@ -1602,6 +1640,7 @@ JoypadOverworld:: ; 0c51 (0:0c51)
call AreInputsSimulated
ret
ForceBikeDown:: ; 0c65 (0:0c65)
ld a, [wFlags_D733]
bit 3, a ; check if a trainer wants a challenge
@ -1616,6 +1655,7 @@ ForceBikeDown:: ; 0c65 (0:0c65)
ld [hJoyHeld], a ; on the cycling road, if there isn't a trainer and the player isn't pressing buttons, simulate a down press
ret
AreInputsSimulated:: ; 0c7b (0:0c7b)
ld a, [wd730]
bit 7, a
@ -1635,6 +1675,7 @@ AreInputsSimulated:: ; 0c7b (0:0c7b)
ld [hJoyReleased], a
ret
; if done simulating button presses
.doneSimulating
xor a
@ -1651,6 +1692,7 @@ AreInputsSimulated:: ; 0c7b (0:0c7b)
res 7, [hl]
ret
GetSimulatedInput:: ; 0cb3 (0:0cb3)
ld hl, wSimulatedJoypadStatesIndex
dec [hl]
@ -1666,6 +1708,7 @@ GetSimulatedInput:: ; 0cb3 (0:0cb3)
pop de
scf
ret
.endofsimulatedinputs
and a
ret
@ -1708,6 +1751,7 @@ CollisionCheckOnWater:: ; 0cca (0:0cca)
.setCarry
scf
jr .done
.checkIfVermilionDockTileset
ld a, [wCurMapTileset] ; tileset
cp SHIP_PORT ; Vermilion Dock tileset
@ -1715,7 +1759,7 @@ CollisionCheckOnWater:: ; 0cca (0:0cca)
jr .stopSurfing ; if it is the boarding platform tile, stop surfing
.stopSurfing ; based game freak
ld a, $3
ld [wd431], a
ld [wPikachuSpawnState], a
ld hl, wPikachuOverworldStateFlags
set 5, [hl]
xor a
@ -1723,6 +1767,7 @@ CollisionCheckOnWater:: ; 0cca (0:0cca)
call LoadPlayerSpriteGraphics
call PlayDefaultMusic
jr .noCollision
.noCollision ; ...and they do the same mistake twice
and a
.done
@ -1763,6 +1808,7 @@ LoadWalkingPlayerSpriteGraphics:: ; 0d5e (0:0d5e)
ld de, RedSprite ; $4180
jr LoadPlayerSpriteGraphicsCommon
LoadSurfingPlayerSpriteGraphics2:: ; 0d69 (0:0d69)
ld a, [wd473]
and a
@ -1780,6 +1826,7 @@ LoadSurfingPlayerSpriteGraphics2:: ; 0d69 (0:0d69)
ld de, SurfingPikachuSprite ; 3f:6def
jr LoadPlayerSpriteGraphicsCommon
LoadSurfingPlayerSpriteGraphics:: ; 0d83 (0:0d83)
ld b, BANK(RedSprite) ; not sure, but probably same bank (5)
ld de, SeelSprite
@ -1971,6 +2018,7 @@ CopySignData:: ; 0eb3 (0:0eb3)
jr nz, .signcopyloop
ret
; function to load map data
LoadMapData:: ; 1241 (0:1241)
ld a, [H_LOADEDROMBANK]
@ -2218,6 +2266,7 @@ ZeroSpriteStateData:: ; 1050 (0:1050)
jr nz, .loop
ret
DisableRegularSprites:: ; 1060 (0:1060)
; initialize all C100-C1FF sprite entries to disabled (other than player's and pikachu)
ld hl, wSpriteStateData1 + 1 * $10 + 2
@ -2230,6 +2279,7 @@ DisableRegularSprites:: ; 1060 (0:1060)
jr nz, .loop
ret
LoadSprite:: ; 106f (0:106f)
push hl
ld b, $0
@ -2260,6 +2310,7 @@ LoadSprite:: ; 106f (0:106f)
pop hl
ret
.trainerSprite
ld a, [hli]
ld [$ff8d], a ; save trainer class
@ -2275,6 +2326,7 @@ LoadSprite:: ; 106f (0:106f)
pop hl
ret
.itemBallSprite
ld a, [hli]
ld [$ff8d], a ; save item number

View File

@ -2,7 +2,7 @@ Func_1510:: ; 1510 (0:1510)
push hl
ld hl, wPikachuOverworldStateFlags
set 7, [hl]
ld hl, wSpriteStateData1 + $f2 ; pikachu data?
ld hl, wPikachuSpriteImageIdx ; pikachu data?
ld [hl], $ff
pop hl
ret
@ -25,7 +25,7 @@ Func_152d:: ; 152d (0:152d)
push hl
ld hl, wPikachuOverworldStateFlags
set 3, [hl]
ld hl, wSpriteStateData1 + $f2 ; pikachu data?
ld hl, wPikachuSpriteImageIdx ; pikachu data?
ld [hl], $ff
pop hl
ret
@ -51,42 +51,43 @@ CheckPikachuFollowingPlayer:: ; 154a (0:154a)
pop hl
ret
Func_1552:: ; 1552 (0:1552)
SpawnPikachu:: ; 1552 (0:1552)
ld a, [hl]
dec a
swap a
ld [hTilePlayerStandingOn], a
homecall Func_fc6d5 ; 3f:46d5
homecall SpawnPikachu_ ; 3f:46d5
ret
Func_1568:: ; 1568 (0:1568)
Pikachu_IsInArray:: ; 1568 (0:1568)
ld b, $0
ld c, a
.asm_156b
.loop
inc b
ld a, [hli]
cp $ff
jr z, .asm_1578
jr z, .not_in_array
cp c
jr nz, .asm_156b
jr nz, .loop
dec b
dec hl
scf
ret
.asm_1578
.not_in_array
dec b
dec hl
and a
ret
Func_157c:: ; 157c (0:157c)
GetPikachuMovementScriptByte:: ; 157c (0:157c)
push hl
push bc
ld a, [H_LOADEDROMBANK]
push af
ld a, [wd44a]
ld a, [wPikachuMovementScriptBank]
call BankswitchCommon
ld hl, wd44b
ld hl, wPikachuMovementScriptAddress
ld c, [hl]
inc hl
ld b, [hl]
@ -103,11 +104,11 @@ Func_157c:: ; 157c (0:157c)
pop hl
ret
Func_159b:: ; 159b (0:159b)
ApplyPikachuMovementData:: ; 159b (0:159b)
ld a, [H_LOADEDROMBANK]
ld b, a
push af
callbs Func_fd2a1
callbs ApplyPikachuMovementData_
pop af
call BankswitchCommon
ret

View File

@ -689,7 +689,7 @@ Func_2fd6a: ; 2fd6a (b:7d6a)
callab IsThisPartymonStarterPikachu_Party
ret nc
ld a, $3
ld [wd431], a
ld [wPikachuSpawnState], a
ret
INCLUDE "engine/battle/scale_sprites.asm"
@ -1186,7 +1186,7 @@ MtMoon3Script_4a325: ; pikachu-related function?
pop af
ld [wUpdateSpritesEnabled], a
pop hl
call Func_159b
call ApplyPikachuMovementData
ret
INCLUDE "data/mapHeaders/safarizonewest.asm"

View File

@ -19,7 +19,7 @@ SurfinDudeText:
call PrintText
jr .done
.next
ld hl, wPreventBlackout
ld hl, wd492
bit 0, [hl]
set 0, [hl]
jr nz, .next2
@ -36,7 +36,7 @@ SurfinDudeText:
ld a, 1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
callba SurfingPikachuMinigame
ld hl, wPreventBlackout
ld hl, wd492
set 1, [hl]
jr .done
.asm_f226b
@ -133,7 +133,7 @@ BeachHouseSign4Text:
bit 6, a
jr z, .asm_f2369
ld hl, wPreventBlackout
ld hl, wd492
bit 1, [hl]
jr z, .next2
ld a, 0
@ -141,7 +141,7 @@ BeachHouseSign4Text:
.next2
ld hl, .BeachHousePrinterText2
call PrintText
ld a, [wPreventBlackout]
ld a, [wd492]
bit 1, a
jr z, .asm_f236f

View File

@ -19,7 +19,7 @@ BillsHouseScriptPointers: ; 1e776 (7:6776)
dw BillsHouseScript9
BillsHouseScript_1e09e:
ld hl, wPreventBlackout
ld hl, wd492
bit 7, [hl]
set 7, [hl]
ret nz
@ -58,7 +58,7 @@ BillsHouseScript1: ; 1e783 (7:6783)
BillsHouseScript2:
ld a, $ff
ld [wJoyIgnore], a
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
and a ; cp SPRITE_FACING_DOWN
ld de, MovementData_1e79c
jr nz, .notDown
@ -100,12 +100,12 @@ BillsHouseScript3: ; 1e7a6 (7:67a6)
call CheckPikachuFollowingPlayer
jr z, .asm_1e13e
ld hl, PikachuMovementData_1e14d
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
and a ; cp SPRITE_FACING_DOWN
jr nz, .asm_1e133
ld hl, PikachuMovementData_1e152
.asm_1e133
call Func_159b
call ApplyPikachuMovementData
callab InitializePikachuTextID
.asm_1e13e
xor a
@ -169,7 +169,7 @@ BillsHouseScript5:
ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay
ld hl, PikachuMovementData_1e1a9
call Func_159b
call ApplyPikachuMovementData
ld a, $f
ld [wEmotionBubbleSpriteIndex], a
ld a, $0
@ -212,7 +212,7 @@ BillsHouseScript7:
xor a
ld [wPlayerMovingDirection], a
ld a, SPRITE_FACING_UP
ld [wSpriteStateData1 + 9], a
ld [wPlayerFacingDirection], a
ld a, $FF ^ (A_BUTTON | B_BUTTON)
ld [wJoyIgnore], a
ld de, RLE_1e219
@ -236,7 +236,7 @@ BillsHouseScript8:
xor a
ld [wPlayerMovingDirection], a
ld a, SPRITE_FACING_UP
ld [wSpriteStateData1 + 9], a
ld [wPlayerFacingDirection], a
ld a, $2
ld [H_SPRITEINDEX], a
ld a, SPRITE_FACING_DOWN

View File

@ -114,7 +114,7 @@ Func_f24d5:
call UpdateSprites
call UpdateSprites
ld hl, Data_f2505
call Func_159b
call ApplyPikachuMovementData
ld a, $f ; pikachu
ld [wEmotionBubbleSpriteIndex], a
ld a, $1
@ -135,10 +135,10 @@ Data_f2505:
Func_f250b:
ld hl, Data_f251c
ld b, SPRITE_FACING_UP
call Func_f0a82
call TryApplyPikachuMovementData
ld hl, Data_f2521
ld b, SPRITE_FACING_RIGHT
call Func_f0a82
call TryApplyPikachuMovementData
ret
Data_f251c:

View File

@ -112,7 +112,7 @@ CinnabarGymScript_74fa3:
ld a, b
cp e
ret nz
call Func_159b
call ApplyPikachuMovementData
ret
CinnabarGymScript1: ; 757dc (1d:57dc)

View File

@ -35,7 +35,7 @@ CinnabarIslandScript0: ; 1ca38 (7:4a38)
ld [wSimulatedJoypadStatesEnd], a
call StartSimulatingJoypadStates
xor a
ld [wSpriteStateData1 + 9], a
ld [wPlayerFacingDirection], a
ld [wJoyIgnore], a
ld a, $1
ld [W_CINNABARISLANDCURSCRIPT], a

View File

@ -82,7 +82,7 @@ CopycatsHouse2FText6: ; 5ccfe (17:4cfe)
CopycatsHouse2FText7: ; 5cd03 (17:4d03)
TX_ASM
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_UP
ld hl, CopycatsHouse2FText_5cd1c
jr nz, .notUp

View File

@ -218,7 +218,7 @@ DayCareMText1: ; 56254 (15:6254)
.withdrewPikachuFromDayCare
ld a, $6
ld [wd431], a
ld [wPikachuSpawnState], a
; GameFreak... TriHard
ld hl, Func_fc4fa

View File

@ -10,18 +10,18 @@ FanClubScriptPointers:
dw FanClubScript2
FanClubScript1:
ld hl, wPreventBlackout
ld hl, wd492
bit 7, [hl]
call z, FanClubScript_59a44
ld hl, wPreventBlackout
ld hl, wd492
set 7, [hl]
ret
FanClubScript2:
ld hl, wPreventBlackout
ld hl, wd492
bit 7, [hl]
call z, FanClubScript_59a39
ld hl, wPreventBlackout
ld hl, wd492
set 7, [hl]
ret
@ -50,7 +50,7 @@ FanClubScript_59a44:
ld [wEmotionBubbleSpriteIndex], a
predef EmotionBubble
ld hl, PikachuMovementScript_59a8c
call Func_159b
call ApplyPikachuMovementData
ld a, $2
ld [wSpriteStateData1 + 3 * $10 + 1], a ; Seel
xor a ; SPRITE_FACING_DOWN

View File

@ -46,7 +46,7 @@ Mansion1ReplaceBlock: ; 44310 (11:4310)
ret
Mansion1Script_Switches: ; 44316 (11:4316)
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_UP
ret nz
xor a

View File

@ -42,7 +42,7 @@ Mansion2Script_5202f: ; 5202f (14:602f)
predef_jump ReplaceTileBlock
Mansion2Script_Switches: ; 52037 (14:6037)
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_UP
ret nz
xor a

View File

@ -73,7 +73,7 @@ Mansion3Script_5225b: ; 5225b (14:625b)
ret
Mansion3Script_Switches: ; 5227a (14:627a)
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_UP
ret nz
xor a

View File

@ -44,7 +44,7 @@ Mansion4Script_523cf: ; 523cf (14:63cf)
ret
Mansion4Script_Switches: ; 52420 (14:6420)
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_UP
ret nz
xor a

View File

@ -466,15 +466,15 @@ OaksLabScript16:
ret nz
xor a
.asm_1c707
ld [wSpriteStateData1 + 9], a
ld [wPlayerFacingDirection], a
ret
OaksLabScript17:
; Pikachu comes out
ld a, SPRITE_FACING_UP
ld [wSpriteStateData1 + 9], a
ld [wPlayerFacingDirection], a
ld a, $2
ld [wd431], a
ld [wPikachuSpawnState], a
callba Func_fc4fa
call Func_1525
ld a, $1a

View File

@ -4,13 +4,13 @@ Func_f1be0:
jr z, .asm_f1bf0
ld b, SPRITE_FACING_DOWN
ld hl, Data_f1bf9
call Func_f0a82
call TryApplyPikachuMovementData
ret
.asm_f1bf0
ld b, SPRITE_FACING_LEFT
ld hl, Data_f1bfe
call Func_f0a82
call TryApplyPikachuMovementData
ret
Data_f1bf9:

View File

@ -174,7 +174,7 @@ PalletTownScript5: ; 18f56 (6:4f56)
PalletTownScript6: ; 18f87 (6:4f87)
xor a
ld [wSpriteStateData1 + 9], a
ld [wPlayerFacingDirection], a
ld a, $1
ld [wSpriteIndex], a
xor a

View File

@ -1,6 +1,6 @@
PewterCityScript: ; 192f5 (6:52f5)
call EnableAutoTextBoxDrawing
ld hl, wPreventBlackout
ld hl, wd492
res 7, [hl]
ld hl, PewterCityScriptPointers
ld a, [W_PEWTERCITYCURSCRIPT]

View File

@ -1,5 +1,5 @@
PewterPokecenterScript: ; 5c587 (17:4587)
ld hl, wPreventBlackout
ld hl, wd492
set 7, [hl]
call Serial_TryEstablishingExternallyClockedConnection
call EnableAutoTextBoxDrawing

View File

@ -235,7 +235,7 @@ PokemonTower7Script11:
ld [wMissableObjectIndex], a
predef HideObject
ld a, SPRITE_FACING_UP
ld [wSpriteStateData1 + 9], a
ld [wPlayerFacingDirection], a
ld a, LAVENDER_HOUSE_1
ld [hWarpDestinationMap], a
ld a, $1

View File

@ -40,7 +40,7 @@ MomHealText2: ; 481c1 (12:41c1)
Func_f1bc4:
ld hl, TVWrongSideText
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_UP
jp nz, .notUp
ld hl, StandByMeText

View File

@ -47,7 +47,7 @@ Route11GateUpstairsText_494a3: ; 494a3 (12:54a3)
Route11GateUpstairsText3: ; 494a8 (12:54a8)
TX_ASM
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_UP
jp nz, GateUpstairsScript_PrintIfFacingUp
CheckEvent EVENT_BEAT_ROUTE12_SNORLAX

View File

@ -64,7 +64,7 @@ Route12GateUpstairsText_495c4: ; 495c4 (12:55c4)
db "@"
GateUpstairsScript_PrintIfFacingUp: ; 495c9 (12:55c9)
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_UP
jr z, .up
ld a, $1

View File

@ -153,7 +153,7 @@ Route22Script2: ; 50fb5 (14:4fb5)
ld a, $1
ld [W_RIVALSTARTER], a
.asm_50fc9
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
and a ; cp SPRITE_FACING_DOWN
jr nz, .notDown
ld a, SPRITE_FACING_UP

View File

@ -40,7 +40,7 @@ Route22GateScript_1e6ba: ; 1e6ba (7:66ba)
ld [wSimulatedJoypadStatesIndex], a
ld a, D_DOWN
ld [wSimulatedJoypadStatesEnd], a
ld [wSpriteStateData1 + 9], a
ld [wPlayerFacingDirection], a
ld [wJoyIgnore], a
jp StartSimulatingJoypadStates

View File

@ -118,7 +118,7 @@ Route23Script_512d8: ; 512d8 (14:52d8)
ld a, D_DOWN
ld [wSimulatedJoypadStatesEnd], a
xor a
ld [wSpriteStateData1 + 9], a
ld [wPlayerFacingDirection], a
ld [wJoyIgnore], a
jp StartSimulatingJoypadStates

View File

@ -9,7 +9,7 @@ Route25Script: ; 515cb (14:55cb)
ret
Route25Script_515e1: ; 515e1 (14:55e1)
ld hl, wPreventBlackout
ld hl, wd492
res 2, [hl]
res 3, [hl]
res 4, [hl]

View File

@ -26,7 +26,7 @@ SafariZoneEntranceScriptPointers: ; 751d9 (1d:51d9)
xor a
ld [hJoyHeld], a
ld a, SPRITE_FACING_RIGHT
ld [wSpriteStateData1 + 9], a
ld [wPlayerFacingDirection], a
ld a, [wCoordIndex]
cp $1
jr z, .asm_7520f
@ -160,7 +160,7 @@ SafariZoneEntranceTextPointers: ; 752b9 (1d:52b9)
ld hl, .SafariZoneEntranceText_753bb
call PrintText
xor a
ld [wSpriteStateData1 + 9], a
ld [wPlayerFacingDirection], a
ld a, D_DOWN
ld c, $3
call SafariZoneEntranceAutoWalk
@ -172,7 +172,7 @@ SafariZoneEntranceTextPointers: ; 752b9 (1d:52b9)
ld hl, .SafariZoneEntranceText_753c0
call PrintText
ld a, SPRITE_FACING_UP
ld [wSpriteStateData1 + 9], a
ld [wPlayerFacingDirection], a
ld a, D_UP
ld c, $1
call SafariZoneEntranceAutoWalk

View File

@ -1,6 +1,6 @@
VermilionCityScript: ; 197a1 (6:57a1)
call EnableAutoTextBoxDrawing
ld hl, wPreventBlackout
ld hl, wd492
res 7, [hl]
ld hl, wd126
bit 6, [hl]
@ -53,7 +53,7 @@ VermilionCityScriptPointers: ; 197dc (6:57dc)
dw VermilionCityScript4
VermilionCityScript0: ; 197e6 (6:57e6)
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
and a ; cp SPRITE_FACING_DOWN
jr nz, .asm_198de
ld hl, CoordsData_19823
@ -176,7 +176,7 @@ VermilionCityText3: ; 198b1 (6:58b1)
TX_ASM
CheckEvent EVENT_SS_ANNE_LEFT
jr nz, .asm_198f6
ld a, [wSpriteStateData1 + 9]
ld a, [wPlayerFacingDirection]
cp SPRITE_FACING_RIGHT
jr z, .asm_198c8
ld hl, VermilionCityCoords1

View File

@ -54,7 +54,7 @@ ViridianCityScript_1905b:
ld a, D_DOWN
ld [wSimulatedJoypadStatesEnd], a
xor a
ld [wSpriteStateData1 + 9], a
ld [wPlayerFacingDirection], a
ld [wJoyIgnore], a
ld [hJoyHeld], a
ld a, $6
@ -161,7 +161,7 @@ ViridianCityScript_1914d:
ld a, D_DOWN
ld [wSimulatedJoypadStatesEnd], a
xor a
ld [wSpriteStateData1 + 9], a
ld [wPlayerFacingDirection], a
ld [wJoyIgnore], a
ret
@ -180,7 +180,7 @@ ViridianCityScript_19162:
ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay
ld a, $8
ld [wSpriteStateData1 + 9], a
ld [wPlayerFacingDirection], a
ld a, $8
ld [hSpriteIndexOrTextID], a
call DisplayTextID

View File

@ -207,7 +207,7 @@ ViridianCityText_f19fc:
Func_f1a01:
ld hl, Data_f1a0a
ld b, SPRITE_FACING_RIGHT
call Func_f0a82
call TryApplyPikachuMovementData
ret
Data_f1a0a:

View File

@ -228,7 +228,39 @@ wSpriteStateData1:: ; c100
; C1xD
; C1xE
; C1xF
ds $10 * $10
spritestatedata1: MACRO
w\1SpriteStateData1::
w\1PictureID:: db
w\1MovementStatus:: db
w\1SpriteImageIdx:: db
w\1YStepVector:: db
w\1YPixels:: db
w\1XStepVector:: db
w\1XPixels:: db
w\1IntraAnimFrameCounter:: db
w\1AnimFrameCounter:: db
w\1FacingDirection:: db
ds 6
w\1SpriteStateData1End::
endm
spritestatedata1 Player
spritestatedata1 Sprite01
spritestatedata1 Sprite02
spritestatedata1 Sprite03
spritestatedata1 Sprite04
spritestatedata1 Sprite05
spritestatedata1 Sprite06
spritestatedata1 Sprite07
spritestatedata1 Sprite08
spritestatedata1 Sprite09
spritestatedata1 Sprite10
spritestatedata1 Sprite11
spritestatedata1 Sprite12
spritestatedata1 Sprite13
spritestatedata1 Sprite14
spritestatedata1 Pikachu
; ds $10 * $10
;SECTION "Sprite State Data 2", WRAM0[$c200]
@ -253,7 +285,40 @@ wSpriteStateData2:: ; c200
; C2xD
; C2xE: sprite image base offset (in video ram, player always has value 1, used to compute c1x2)
; C2xF
ds $10 * $10
spritestatedata2: MACRO
w\1SpriteStateData2::
w\1WalkAnimationCounter:: db
ds 1
w\1YDisplacement:: db
w\1XDisplacement:: db
w\1MapY:: db
w\1MapX:: db
w\1MovementByte1:: db
w\1GrassPriority:: db
w\1MovementDelay:: db
ds 5
w\1SpriteImageBaseOffset:: db
ds 1
w\1SpriteStateData2End::
endm
spritestatedata2 Player
spritestatedata2 Sprite01
spritestatedata2 Sprite02
spritestatedata2 Sprite03
spritestatedata2 Sprite04
spritestatedata2 Sprite05
spritestatedata2 Sprite06
spritestatedata2 Sprite07
spritestatedata2 Sprite08
spritestatedata2 Sprite09
spritestatedata2 Sprite10
spritestatedata2 Sprite11
spritestatedata2 Sprite12
spritestatedata2 Sprite13
spritestatedata2 Sprite14
spritestatedata2 Pikachu
; ds $10 * $10
wSpriteDataEnd::
@ -2735,7 +2800,7 @@ wDestinationWarpID:: ; d42f
ds 1
wPikachuOverworldStateFlags:: ds 1 ; d42f
wd431:: ds 1 ; d430
wPikachuSpawnState:: ds 1 ; d430
wd432:: ds 1 ; d431
wd433:: ds 1 ; d432
wd434:: ds 1
@ -2749,10 +2814,11 @@ wExpressionNumber:: ; d447
wExpressionNumber2::
ds 1
wd44a:: ds 1 ; d449
wd44b:: ds 1
wd44c:: ds 1
wd44d:: ds 1
wPikachuMovementScriptBank:: ds 1 ; d449
wPikachuMovementScriptAddress:: dw ; d44a
wd44d:: ds 1 ; d44c
wCurPikaMovementData:: ;
wPikaPicAnimPointer:: dw ; d44d
wPikaPicAnimPointerSetupFinished:: ds 1 ; d44f
wPikaPicAnimCurGraphicID:: ds 1
@ -2785,7 +2851,7 @@ wd47a:: ds 1
ds 24
wPreventBlackout:: ds 1 ; d492
wd492:: ds 1 ; d492
ds 1