player animations, emotion bubbles, etc.

This commit is contained in:
YamaArashi 2015-07-14 14:32:49 -07:00
parent b1cb378893
commit 01631a2e59
13 changed files with 166 additions and 110 deletions

View file

@ -104,12 +104,12 @@ GetBattleTransitionID_CompareLevels: ; 709ef (1c:49ef)
jr nc, .highLevelEnemy
res 1, c
ld a, $1
ld [wcd47], a
ld [wBattleTransitionSpiralDirection], a
ret
.highLevelEnemy
set 1, c
xor a
ld [wcd47], a
ld [wBattleTransitionSpiralDirection], a
ret
; fails to recognize VICTORY_ROAD_2, VICTORY_ROAD_3, all ROCKET_HIDEOUT maps,
@ -196,7 +196,7 @@ BattleTransition_BlackScreen: ; 70a69 (1c:4a69)
; outward spiral if enemy is at least 3 levels
; higher than player and does an inward spiral otherwise
BattleTransition_Spiral: ; 70a72 (1c:4a72)
ld a, [wcd47]
ld a, [wBattleTransitionSpiralDirection]
and a
jr z, .outwardSpiral
call BattleTransition_InwardSpiral

View file

@ -177,9 +177,9 @@ InGameTrade_PrepareTradeData: ; 71cc1 (1c:5cc1)
ld bc, $b
call InGameTrade_CopyData
ld hl, InGameTrade_TrainerString
ld de, wcd4e
ld de, wTradedEnemyMonOT
call InGameTrade_CopyData
ld de, W_GRASSRATE
ld de, wLinkEnemyTrainerName
call InGameTrade_CopyData
ld hl, wPartyMon1OTID
ld bc, wPartyMon2 - wPartyMon1

View file

@ -1783,7 +1783,7 @@ SuperRodCode: ; e283 (3:6283)
call ReadSuperRodData
ld a, e
RodResponse: ; e28d (3:628d)
ld [wWhichTrade], a
ld [wRodResponse], a
dec a ; is there a bite?
jr nz, .next
@ -1801,7 +1801,7 @@ RodResponse: ; e28d (3:628d)
push af
push hl
ld [hl], 0
callba Func_707b6
callba FishingAnim
pop hl
pop af
ld [hl], a

View file

@ -73,7 +73,7 @@ UsedCutText: ; eff2 (3:6ff2)
AnimateCutTree: ; eff7 (3:6ff7)
xor a
ld [wcd50], a
ld [wWhichAnimationOffsets], a
ld a, $e4
ld [rOBP1], a
ld a, [wcd4d]
@ -138,7 +138,7 @@ GetCutTreeBoulderDustAnimationOffsets: ; f068 (3:7068)
srl a
ld e, a
ld d, $0 ; de holds direction (00: down, 02: up, 04: left, 06: right)
ld a, [wcd50]
ld a, [wWhichAnimationOffsets]
and a
ld hl, CutTreeAnimationOffsets
jr z, .asm_f084

View file

@ -1,7 +1,7 @@
EmotionBubble: ; 17c47 (5:7c47)
ld a, [wcd50]
ld a, [wWhichEmotionBubble]
ld c, a
ld b, $0
ld b, 0
ld hl, EmotionBubblesPointerTable
add hl, bc
add hl, bc
@ -16,15 +16,18 @@ EmotionBubble: ; 17c47 (5:7c47)
ld a, $ff
ld [wUpdateSpritesEnabled], a
ld a, [wd736]
bit 6, a
bit 6, a ; are the last 4 OAM entries reserved for a shadow or fishing rod?
ld hl, wOAMBuffer + $8f
ld de, wOAMBuffer + $9f
jr z, .asm_17c7a
jr z, .next
ld hl, wOAMBuffer + $7f
ld de, wOAMBuffer + $8f
.asm_17c7a
; Copy OAM data 16 bytes forward to make room for emotion bubble OAM data at the
; start of the OAM buffer.
.next
ld bc, $90
.asm_17c7d
.loop
ld a, [hl]
ld [de], a
dec hl
@ -32,12 +35,14 @@ EmotionBubble: ; 17c47 (5:7c47)
dec bc
ld a, c
or b
jr nz, .asm_17c7d
jr nz, .loop
; get the screen coordinates of the sprite the bubble is to be displayed above
ld hl, wSpriteStateData1 + 4
ld a, [wcd4f]
ld a, [wEmotionBubbleSpriteIndex]
swap a
ld c, a
ld b, $0
ld b, 0
add hl, bc
ld a, [hli]
ld b, a
@ -45,6 +50,7 @@ EmotionBubble: ; 17c47 (5:7c47)
ld a, [hl]
add $8
ld c, a
ld de, EmotionBubblesOAM
xor a
call WriteOAMBlock

View file

@ -144,10 +144,14 @@ PrepareOAMData:
ld de, $4
ld b, $a0
ld a, [wd736]
bit 6, a
bit 6, a ; jumping down ledge or fishing animation?
ld a, $a0
jr z, .clear
; Don't clear the last 4 entries because they are used for the shadow in the
; jumping down ledge animation and the rod in the fishing animation.
ld a, $90
.clear
cp l
ret z

View file

@ -1,5 +1,5 @@
EnterMapAnim: ; 70510 (1c:4510)
call InitFacingDirectionBuffer
call InitFacingDirectionList
ld a, $ec
ld [wSpriteStateData1 + 4], a ; player's sprite Y screen position
call Delay3
@ -32,7 +32,7 @@ EnterMapAnim: ; 70510 (1c:4510)
ld a, $8
ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayEndValue
ld [hl], $ff ; wPlayerSpinInPlaceAnimSoundID
ld hl, wcd48
ld hl, wFacingDirectionList
call PlayerSpinInPlace
.restoreDefaultMusic
call PlayDefaultMusic
@ -91,7 +91,7 @@ PlayerSpinWhileMovingDown: ; 705aa (1c:45aa)
jp PlayerSpinWhileMovingUpOrDown
_LeaveMapAnim: ; 705ba (1c:45ba)
call InitFacingDirectionBuffer
call InitFacingDirectionList
call IsPlayerStandingOnWarpPadOrHole
ld a, b
and a
@ -134,7 +134,7 @@ _LeaveMapAnim: ; 705ba (1c:45ba)
xor a
ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayEndValue
ld [hl], (SFX_02_4d - SFX_Headers_02) / 3 ; wPlayerSpinInPlaceAnimSoundID
ld hl, wcd48
ld hl, wFacingDirectionList
call PlayerSpinInPlace
jr .spinWhileMovingUp
.flyAnimation
@ -214,7 +214,7 @@ LeaveMapThroughHoleAnim: ; 7067d (1c:467d)
ld [wOAMBuffer + 1 * 4], a
ld c, 2
call DelayFrames
; hide lower half of player's sprite
; hide upper half of player's sprite
ld a, $a0
ld [wOAMBuffer + 2 * 4], a
ld [wOAMBuffer + 3 * 4], a
@ -231,7 +231,7 @@ DoFlyAnimation: ; 706ae (1c:46ae)
call Delay3
ld a, [wFlyAnimUsingCoordList]
cp $ff
jr z, .asm_706cd
jr z, .skipCopyingCoords ; if the bird is flapping its wings in place
ld hl, wSpriteStateData1 + 4
ld a, [de]
inc de
@ -240,7 +240,7 @@ DoFlyAnimation: ; 706ae (1c:46ae)
ld a, [de]
inc de
ld [hl], a
.asm_706cd
.skipCopyingCoords
ld a, [wFlyAnimCounter]
dec a
ld [wFlyAnimCounter], a
@ -252,22 +252,23 @@ LoadBirdSpriteGraphics: ; 706d7 (1c:46d7)
ld hl, vNPCSprites
ld bc, (BANK(BirdSprite) << 8) + $0c
call CopyVideoData
ld de, BirdSprite + $c0 ; moving amination sprite
ld de, BirdSprite + $c0 ; moving animation sprite
ld hl, vNPCSprites2
ld bc, (BANK(BirdSprite) << 8) + $0c
jp CopyVideoData
InitFacingDirectionBuffer: ; 706ef (1c:46ef)
InitFacingDirectionList: ; 706ef (1c:46ef)
ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction (image index is locked to standing images)
ld [wcd50], a
ld [wSavedPlayerFacingDirection], a
ld a, [wSpriteStateData1 + 4] ; player's sprite Y screen position
ld [wcd4f], a
ld [wSavedPlayerScreenY], a
ld hl, PlayerSpinningFacingOrder
ld de, wcd48
ld bc, $4
ld de, wFacingDirectionList
ld bc, 4
call CopyData
ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction (image index is locked to standing images)
ld hl, wcd48
ld hl, wFacingDirectionList
; find the place in the list that matches the current facing direction
.loop
cp [hl]
inc hl
@ -281,15 +282,16 @@ PlayerSpinningFacingOrder: ; 70713 (1c:4713)
db SPRITE_FACING_DOWN, SPRITE_FACING_LEFT, SPRITE_FACING_UP, SPRITE_FACING_RIGHT
SpinPlayerSprite: ; 70717 (1c:4717)
; copy the current value from the list into the sprite data and rotate the list
ld a, [hl]
ld [wSpriteStateData1 + 2], a ; player's sprite facing direction (image index is locked to standing images)
push hl
ld hl, wcd48
ld de, wcd47
ld bc, $4
ld hl, wFacingDirectionList
ld de, wFacingDirectionList - 1
ld bc, 4
call CopyData
ld a, [wcd47]
ld [wcd4b], a
ld a, [wFacingDirectionList - 1]
ld [wFacingDirectionList + 3], a
pop hl
ret
@ -298,11 +300,12 @@ PlayerSpinInPlace: ; 70730 (1c:4730)
ld a, [wPlayerSpinInPlaceAnimFrameDelay]
ld c, a
and $3
jr nz, .asm_70743
jr nz, .skipPlayingSound
; when the last delay was a multiple of 4, play a sound if there is one
ld a, [wPlayerSpinInPlaceAnimSoundID]
cp $ff
call nz, PlaySound
.asm_70743
.skipPlayingSound
ld a, [wPlayerSpinInPlaceAnimFrameDelayDelta]
add c
ld [wPlayerSpinInPlaceAnimFrameDelay], a
@ -330,9 +333,9 @@ PlayerSpinWhileMovingUpOrDown: ; 70755 (1c:4755)
jr PlayerSpinWhileMovingUpOrDown
RestoreFacingDirectionAndYScreenPos: ; 70772 (1c:4772)
ld a, [wcd4f]
ld a, [wSavedPlayerScreenY]
ld [wSpriteStateData1 + 4], a
ld a, [wcd50]
ld a, [wSavedPlayerFacingDirection]
ld [wSpriteStateData1 + 2], a
ret
@ -378,11 +381,11 @@ IsPlayerStandingOnWarpPadOrHole: ; 70787 (1c:4787)
db INTERIOR, $55, 1 ; warp pad
db $FF
Func_707b6: ; 707b6 (1c:47b6)
FishingAnim: ; 707b6 (1c:47b6)
ld c, 10
call DelayFrames
ld hl, wd736
set 6, [hl]
set 6, [hl] ; reserve the last 4 OAM entries
ld de, RedSprite
ld hl, vNPCSprites
ld bc, (BANK(RedSprite) << 8) + $0c
@ -393,55 +396,67 @@ Func_707b6: ; 707b6 (1c:47b6)
ld a, [wSpriteStateData1 + 2]
ld c, a
ld b, $0
ld hl, FishingRodGfxProperties
ld hl, FishingRodOAM
add hl, bc
ld de, wOAMBuffer + $9c
ld bc, $4
call CopyData
ld c, 100
call DelayFrames
ld a, [wWhichTrade]
ld a, [wRodResponse]
and a
ld hl, NoNibbleText
jr z, .asm_70836
jr z, .done
cp $2
ld hl, NothingHereText
jr z, .asm_70836
ld b, $a
.asm_707fe
ld hl, wSpriteStateData1 + 4
call Func_70842
jr z, .done
; there was a bite
; shake the player's sprite vertically
ld b, 10
.loop
ld hl, wSpriteStateData1 + 4 ; player's sprite Y screen position
call .ShakePlayerSprite
ld hl, wOAMBuffer + $9c
call Func_70842
call .ShakePlayerSprite
call Delay3
dec b
jr nz, .asm_707fe
ld a, [wSpriteStateData1 + 2]
cp $4
jr nz, .asm_7081c
jr nz, .loop
; If the player is facing up, hide the fishing rod so it doesn't overlap with
; the exclamation bubble that will be shown next.
ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction
cp SPRITE_FACING_UP
jr nz, .skipHidingFishingRod
ld a, $a0
ld [wOAMBuffer + $9c], a
.asm_7081c
ld hl, wcd4f
.skipHidingFishingRod
ld hl, wEmotionBubbleSpriteIndex
xor a
ld [hli], a
ld [hl], a
ld [hli], a ; player's sprite
ld [hl], a ; EXCLAMATION_BUBBLE
predef EmotionBubble
ld a, [wSpriteStateData1 + 2]
cp $4
jr nz, .asm_70833
; If the player is facing up, unhide the fishing rod.
ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction
cp SPRITE_FACING_UP
jr nz, .skipUnhidingFishingRod
ld a, $44
ld [wOAMBuffer + $9c], a
.asm_70833
.skipUnhidingFishingRod
ld hl, ItsABiteText
.asm_70836
.done
call PrintText
ld hl, wd736
res 6, [hl]
res 6, [hl] ; unreserve the last 4 OAM entries
call LoadFontTilePatterns
ret
Func_70842: ; 70842 (1c:4842)
.ShakePlayerSprite
ld a, [hl]
xor $1
ld [hl], a
@ -459,7 +474,7 @@ ItsABiteText: ; 70851 (1c:4851)
TX_FAR _ItsABiteText
db "@"
FishingRodGfxProperties: ; 70856 (1c:4856)
FishingRodOAM: ; 70856 (1c:4856)
; specifies how the fishing rod should be drawn on the screen
; first byte = screen y coordinate
; second byte = screen x coordinate

View file

@ -1,6 +1,6 @@
AnimateBoulderDust: ; 79f54 (1e:5f54)
ld a, $1
ld [wcd50], a ; select the boulder dust offsets
ld [wWhichAnimationOffsets], a ; select the boulder dust offsets
ld a, [wUpdateSpritesEnabled]
push af
ld a, $ff

View file

@ -2350,9 +2350,9 @@ CheckFightingMapTrainers:: ; 3219 (0:3219)
.trainerEngaging
ld hl, W_FLAGS_D733
set 3, [hl]
ld [wcd4f], a
xor a
ld [wcd50], a
ld [wEmotionBubbleSpriteIndex], a
xor a ; EXCLAMATION_BUBBLE
ld [wWhichEmotionBubble], a
predef EmotionBubble
ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN
ld [wJoyIgnore], a

View file

@ -2973,20 +2973,20 @@ DrawBadges: ; ea03 (3:6a03)
; Instead of removing relevant code, the name graphics were erased.
; Tile ids for face/badge graphics.
ld de, wTrainerFacingDirection
ld de, wBadgeOrFaceTiles
ld hl, .FaceBadgeTiles
ld bc, 8
call CopyData
; Booleans for each badge.
ld hl, wcd49
ld hl, wTempObtainedBadgesBooleans
ld bc, 8
xor a
call FillMemory
; Alter these based on owned badges.
ld de, wcd49
ld hl, wTrainerFacingDirection
ld de, wTempObtainedBadgesBooleans
ld hl, wBadgeOrFaceTiles
ld a, [W_OBTAINEDBADGES]
ld b, a
ld c, 8
@ -3005,17 +3005,17 @@ DrawBadges: ; ea03 (3:6a03)
jr nz, .CheckBadge
; Draw two rows of badges.
ld hl, wWhichTrade
ld hl, wBadgeNumberTile
ld a, $d8 ; [1]
ld [hli], a
ld [hl], $60 ; First name
hlCoord 2, 11
ld de, wcd49
ld de, wTempObtainedBadgesBooleans
call .DrawBadgeRow
hlCoord 2, 14
ld de, wcd49 + 4
ld de, wTempObtainedBadgesBooleans + 4
; call .DrawBadgeRow
; ret
@ -3028,15 +3028,15 @@ DrawBadges: ; ea03 (3:6a03)
push hl
; Badge no.
ld a, [wWhichTrade]
ld a, [wBadgeNumberTile]
ld [hli], a
inc a
ld [wWhichTrade], a
ld [wBadgeNumberTile], a
; Names aren't printed if the badge is owned.
ld a, [de]
and a
ld a, [wTrainerEngageDistance]
ld a, [wBadgeNameTile]
jr nz, .SkipName
call .PlaceTiles
jr .PlaceBadge
@ -3047,18 +3047,18 @@ DrawBadges: ; ea03 (3:6a03)
inc hl
.PlaceBadge
ld [wTrainerEngageDistance], a
ld de, 20 - 1
ld [wBadgeNameTile], a
ld de, SCREEN_WIDTH - 1
add hl, de
ld a, [wTrainerFacingDirection]
ld a, [wBadgeOrFaceTiles]
call .PlaceTiles
add hl, de
call .PlaceTiles
; Shift badge array back one byte.
push bc
ld hl, wTrainerFacingDirection + 1
ld de, wTrainerFacingDirection
ld hl, wBadgeOrFaceTiles + 1
ld de, wBadgeOrFaceTiles
ld bc, 8
call CopyData
pop bc

View file

@ -186,9 +186,9 @@ OakAppearsText: ; 18fb0 (6:4fb0)
ld c,10
call DelayFrames
xor a
ld [wcd4f],a
ld [wcd50],a
predef EmotionBubble ; display ! over head
ld [wEmotionBubbleSpriteIndex],a ; player's sprite
ld [wWhichEmotionBubble],a ; EXCLAMATION_BUBBLE
predef EmotionBubble
ld a,4
ld [wd528],a
jp TextScriptEnd

View file

@ -79,9 +79,9 @@ Route22Script0: ; 50f00 (14:4f00)
.firstRivalBattle
ld a, $1
ld [wcd4f], a
xor a
ld [wcd50], a
ld [wEmotionBubbleSpriteIndex], a
xor a ; EXCLAMATION_BUBBLE
ld [wWhichEmotionBubble], a
predef EmotionBubble
ld a, [wWalkBikeSurfState]
and a
@ -218,9 +218,9 @@ Route22Script3: ; 5102a (14:502a)
Route22Script_5104e: ; 5104e (14:504e)
ld a, $2
ld [wcd4f], a
xor a
ld [wcd50], a
ld [wEmotionBubbleSpriteIndex], a
xor a ; EXCLAMATION_BUBBLE
ld [wWhichEmotionBubble], a
predef EmotionBubble
ld a, [wWalkBikeSurfState]
and a

View file

@ -601,6 +601,14 @@ wOverrideSimulatedJoypadStatesMask:: ; cd3b
ds 1
wBadgeNumberTile:: ; cd3d
; tile ID of the badge number being drawn
wRodResponse:: ; cd3d
; 0 = no bite
; 1 = bite
; 2 = no fish on map
wWhichTownMapLocation:: ; cd3d
wStoppingWhichSlotMachineWheel:: ; cd3d
@ -630,6 +638,9 @@ wWhichTrade:: ; cd3d
wTrainerSpriteOffset:: ; cd3d
ds 1
wBadgeNameTile:: ; cd3e
; first tile ID of the name being drawn
wFlyLocationsList:: ; cd3e
; 11 bytes plus $ff sentinel values at each end
@ -650,6 +661,11 @@ wHiddenObjectFunctionRomBank:: ; cd3e
wTrainerEngageDistance:: ; cd3e
ds 1
wBadgeOrFaceTiles:: ; cd3f
; 8 bytes
; a list of the first tile IDs of each badge or face (depending on whether the
; badge is owned) to be drawn on the trainer screen
wSlotMachineWheel2Offset:: ; cd3f
wNameOfPlayerMonToBeTraded:: ; cd3f
@ -709,17 +725,27 @@ wTempCoins1:: ; cd46
wSlotMachineWheel2TopTile:: ; cd46
ds 1
wSlotMachineWheel3BottomTile:: ; cd47
wBattleTransitionSpiralDirection:: ; cd47
; 0 = outward, 1 = inward
wcd47:: ds 1 ; used in slot machine and spinning player sprite
wSlotMachineWheel3BottomTile:: ; cd47
ds 1
wSlotMachineWheel3MiddleTile:: ; cd48
wcd48:: ds 1 ; same as above
wFacingDirectionList:: ; cd48
; 4 bytes (also, the byte before the start of the list (cd47) is used a temp
; variable when the list is rotated)
; used when spinning the player's sprite
ds 1
wSlotMachineWheel3TopTile:: ; cd49
wcd49:: ds 1 ; used in slot machine, displaying the gym leaders/badges on the trainer card, and displaying the town map
wTempObtainedBadgesBooleans::
; 8 bytes
; temporary list created when displaying the badges on the trainer screen
; one byte for each badge; 0 = not obtained, 1 = obtained
ds 1
wTempCoins2:: ; cd4a
; 2 bytes
@ -727,11 +753,7 @@ wTempCoins2:: ; cd4a
wPayoutCoins:: ; cd4a
; 2 bytes
ds 1
wcd4b:: ; cd4b
; used in player animations
ds 1
ds 2
wTradedPlayerMonOTID:: ; cd4c
@ -750,19 +772,28 @@ wSlotMachineWheel2SlipCounter:: ; cd4e
; wheel 2 can "slip" while this is non-zero
wTradedEnemyMonOT:: ; cd4e
ds 1
wcd4e:: ds 1 ; used with in-game trades and slot machine
wSavedPlayerScreenY:: ; cd4f
wSlotMachineRerollCounter:: ; cd4f
; The remaining number of times wheel 3 will roll down a symbol until a match is
; found, when winning is enabled. It's initialized to 4 each bet.
wcd4f:: ds 1 ; used with in-game trades, emotion bubbles, and player animations
wEmotionBubbleSpriteIndex:: ; cd4f
; the index of the sprite the emotion bubble is to be displayed above
ds 1
wWhichEmotionBubble:: ; cd50
wSlotMachineBet:: ; cd50
; how many coins the player bet on the slot machine (1 to 3)
wcd50:: ds 9 ; used with in-game trades, emotion bubbles, and player and miscellaneous sprite animations
wSavedPlayerFacingDirection:: ; cd50
wWhichAnimationOffsets:: ; cd50
; 0 = cut animation, 1 = boulder dust animation
ds 9
wTradedEnemyMonOTID:: ; cd59
ds 2
@ -2219,7 +2250,7 @@ wd736:: ; d736
; bit 0: check if the player is standing on a door and make him walk down a step if so
; bit 1: the player is currently stepping down from a door
; bit 2: standing on a warp
; bit 6: jumping down a ledge
; bit 6: jumping down a ledge / fishing animation
ds 1
wCompletedInGameTradeFlags:: ; d737