Board menu: move die number animation (#11)

This commit is contained in:
xCrystal
2023-09-27 19:25:47 +02:00
parent 98d69d4e04
commit 1f2be83ebc
11 changed files with 154 additions and 33 deletions

View File

@@ -221,7 +221,6 @@ DIE_MAX_NUMBER EQU 6
ret
.confirm_roll
call PlayClickSFX
ld a, TRUE
ld [wScriptVar], a
ret
@@ -275,20 +274,53 @@ BoardMenu_BreakDieAnimation:
.go
farcall _UpdateSpritesAfterOffset
ld a, 44 ; total duration of SPRITE_ANIM_FRAMESET_BOARD_MENU_BREAK_DIE
ld de, SFX_STRENGTH
call PlaySFX
; play break die and appear die number animations
ld a, 61 ; total duration of SPRITE_ANIM_FRAMESET_BOARD_MENU_BREAK_DIE.
; the total duration is the sum of all durations in the frameset
; plus one for each oam* entry in the frameset.
ld [wFrameCounter], a
.loop
.loop1
farcall PlaySpriteAnimationsAndDelayFrame
ld hl, wFrameCounter
ld a, [hl]
and a
jr z, .next
dec [hl]
jr .loop1
.next
; initialize move die number animation
depixel 8, 10, 0, 0
ld a, SPRITE_ANIM_OBJ_BOARD_MENU_MOVE_DIE_NUMBER
call InitSpriteAnimStruct
ld a, $4 * SPRITEOAMSTRUCT_LENGTH
ldh [hUsedSpriteIndex], a
farcall _UpdateSpritesAfterOffset
; play move die number animation
ld a, 41 ; total duration of SPRITE_ANIM_FRAMESET_BOARD_MENU_MOVE_DIE_NUMBER
ld [wFrameCounter], a
.loop2
farcall PlaySpriteAnimationsAndDelayFrame
ld hl, wFrameCounter
ld a, [hl]
and a
jr z, .done
dec [hl]
jr .loop
jr .loop2
.done
ld hl, wVramState
res 2, [hl]
ld hl, wDisplaySecondarySprites
set SECONDARYSPRITES_SPACES_LEFT_F, [hl]
ld a, [wDieRoll]
ld [wSpacesLeft], a
call UpdateSprites
ret
BoardMenu_Party:

View File

@@ -3084,6 +3084,8 @@ InitSecondarySprites:
call nz, InitBoardMenuSprites
bit SECONDARYSPRITES_DIE_ROLL_F, a
call nz, InitRollDieSprites
bit SECONDARYSPRITES_SPACES_LEFT_F, a
call nz, InitSpacesLeftNumberSprites
ret
InitBoardMenuSprites:
@@ -3137,4 +3139,30 @@ InitRollDieSprites:
pop af
ret
InitSpacesLeftNumberSprites:
push af
ld hl, SpacesLeftNumberOAM
ld a, [wSpacesLeft]
dec a
ld bc, DIE_NUMBER_SIZE * SPRITEOAMSTRUCT_LENGTH
call AddNTimes
; find the beginning of free space in OAM, and assure there's space for a DIE_NUMBER_SIZE object
ldh a, [hUsedSpriteIndex]
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (DIE_NUMBER_SIZE * SPRITEOAMSTRUCT_LENGTH) + 1
jr nc, .oam_full
; copy the sprite data (DIE_NUMBER_SIZE objects) of that item to the available space in OAM
ld e, a
ld d, HIGH(wShadowOAM)
ld bc, DIE_NUMBER_SIZE * SPRITEOAMSTRUCT_LENGTH
call CopyBytes
ldh a, [hUsedSpriteIndex]
add (DIE_NUMBER_SIZE * SPRITEOAMSTRUCT_LENGTH)
ldh [hUsedSpriteIndex], a
.oam_full
pop af
ret
INCLUDE "data/sprites/secondary_sprites.asm"

View File

@@ -53,8 +53,6 @@ DoSpriteAnimFrame:
dw SpriteAnimFunc_LevelSelectionMenuWalkUp
dw SpriteAnimFunc_LevelSelectionMenuWalkLeft
dw SpriteAnimFunc_LevelSelectionMenuWalkRight
dw SpriteAnimFunc_BoardMenuBreakDie
dw SpriteAnimFunc_BoardMenuAppearDieNumber
dw SpriteAnimFunc_BoardMenuMoveDieNumber
assert_table_length NUM_SPRITE_ANIM_FUNCS
@@ -880,13 +878,43 @@ SpriteAnimFunc_LevelSelectionMenuWalkRight:
inc [hl]
ret
SpriteAnimFunc_BoardMenuBreakDie:
ret
SpriteAnimFunc_BoardMenuAppearDieNumber:
ret
SpriteAnimFunc_BoardMenuMoveDieNumber:
ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
ld a, [hl]
; 10 frames
ld e, 2
ld d, 0
cp 44 + 2
jr nc, .move
; 2 frames
ld e, 2
ld d, 1
cp 40 + 1
jr nc, .move
; 2 frames
ld e, 1
ld d, 1
cp 38 + 1
jr nc, .move
; 2 frames
ld e, 1
ld d, 2
cp 36 + 1
jr nc, .move
; 26 frames
ld e, 0
ld d, 2
.move
sub e
ld [hl], a
ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
ld a, [hl]
cp 20 + 1
ret c
sub d
ld [hl], a
ret
LevelSelectionMenuHandleTransition: