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

@ -135,9 +135,7 @@ DEF NUM_SPRITE_ANIM_OBJS EQU const_value
const SPRITE_ANIM_FUNC_LEVEL_SELECTION_MENU_WALK_UP ; 24
const SPRITE_ANIM_FUNC_LEVEL_SELECTION_MENU_WALK_LEFT ; 25
const SPRITE_ANIM_FUNC_LEVEL_SELECTION_MENU_WALK_RIGHT ; 26
const SPRITE_ANIM_FUNC_BOARD_MENU_BREAK_DIE ; 27
const SPRITE_ANIM_FUNC_BOARD_MENU_APPEAR_DIE_NUMBER ; 28
const SPRITE_ANIM_FUNC_BOARD_MENU_MOVE_DIE_NUMBER ; 29
const SPRITE_ANIM_FUNC_BOARD_MENU_MOVE_DIE_NUMBER ; 27
DEF NUM_SPRITE_ANIM_FUNCS EQU const_value
; SpriteAnimFrameData indexes (see data/sprite_anims/framesets.asm)
@ -383,7 +381,7 @@ DEF NUM_SPRITE_ANIM_FRAMESETS EQU const_value
const SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_2 ; 9d
const SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_3 ; 9e
const SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_4 ; 9f
const SPRITE_ANIM_OAMSET_BOARD_MENU_APPEAR_DIE_NUMBER ; a0
const SPRITE_ANIM_OAMSET_BOARD_MENU_DIE_NUMBER ; a0
DEF NUM_SPRITE_ANIM_OAMSETS EQU const_value
assert NUM_SPRITE_ANIM_OAMSETS <= FIRST_OAM_CMD, \

View File

@ -8,8 +8,9 @@ DEF AUTO_INPUT EQU $ff
; wDisplaySecondarySprites
const_def
const SECONDARYSPRITES_BOARD_MENU_F ; 0
const SECONDARYSPRITES_DIE_ROLL_F ; 1
const SECONDARYSPRITES_BOARD_MENU_F ; 0
const SECONDARYSPRITES_DIE_ROLL_F ; 1
const SECONDARYSPRITES_SPACES_LEFT_F ; 2
; wCurDexMode::
const_def

View File

@ -566,21 +566,23 @@ SpriteAnimFrameData:
oamrestart
.Frameset_BoardMenuBreakDie:
oamframe SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_1, 2
oamframe SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_1, 9
oamframe SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_2, 6
oamframe SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_3, 6
oamframe SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_4, 6
oamframe SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_4, 5
oamwait 2
oamframe SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_4, 6
oamframe SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_4, 5
oamwait 2
oamframe SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_4, 6
oamframe SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_4, 5
oamwait 2
oamframe SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_4, 6
oamframe SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_4, 5
oamwait 3
oamdelete
.Frameset_BoardMenuAppearDieNumber:
oamframe SPRITE_ANIM_OAMSET_BOARD_MENU_APPEAR_DIE_NUMBER, 44
oamframe SPRITE_ANIM_OAMSET_BOARD_MENU_DIE_NUMBER, 60
oamdelete
.Frameset_BoardMenuMoveDieNumber:
oamframe SPRITE_ANIM_OAMSET_BOARD_MENU_DIE_NUMBER, 40
oamdelete

View File

@ -167,7 +167,7 @@ SpriteAnimOAMData:
spriteanimoam $00, .OAMData_BreakDie2 ; SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_2
spriteanimoam $00, .OAMData_BreakDie3 ; SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_3
spriteanimoam $00, .OAMData_BreakDie4 ; SPRITE_ANIM_OAMSET_BOARD_MENU_BREAK_DIE_4
spriteanimoam $00, .OAMData_AppearDieNumber ; SPRITE_ANIM_OAMSET_BOARD_MENU_APPEAR_DIE_NUMBER
spriteanimoam $00, .OAMData_DieNumber ; SPRITE_ANIM_OAMSET_BOARD_MENU_DIE_NUMBER
assert_table_length NUM_SPRITE_ANIM_OAMSETS
@ -664,7 +664,7 @@ SpriteAnimOAMData:
dbsprite -2, 0, 0, 0, $14, PAL_OW_MISC
dbsprite 1, 0, 0, 0, $15, PAL_OW_MISC
.OAMData_AppearDieNumber:
.OAMData_DieNumber:
db 4
dbsprite -1, -1, 0, 0, $00, PAL_OW_MISC
dbsprite 0, -1, 0, 0, $01, PAL_OW_MISC

View File

@ -109,9 +109,9 @@ SpriteAnimObjects:
; SPRITE_ANIM_OBJ_LEVEL_SELECTION_MENU_FEMALE_WALK_RIGHT
db SPRITE_ANIM_FRAMESET_LEVEL_SELECTION_MENU_FEMALE_WALK_RIGHT, SPRITE_ANIM_FUNC_LEVEL_SELECTION_MENU_WALK_RIGHT, SPRITE_ANIM_DICT_DEFAULT
; SPRITE_ANIM_OBJ_BOARD_MENU_BREAK_DIE
db SPRITE_ANIM_FRAMESET_BOARD_MENU_BREAK_DIE, SPRITE_ANIM_FUNC_BOARD_MENU_BREAK_DIE, SPRITE_ANIM_DICT_BOARD_MENU
db SPRITE_ANIM_FRAMESET_BOARD_MENU_BREAK_DIE, SPRITE_ANIM_FUNC_NULL, SPRITE_ANIM_DICT_BOARD_MENU
; SPRITE_ANIM_OBJ_BOARD_MENU_APPEAR_DIE_NUMBER
db SPRITE_ANIM_FRAMESET_BOARD_MENU_APPEAR_DIE_NUMBER, SPRITE_ANIM_FUNC_BOARD_MENU_APPEAR_DIE_NUMBER, SPRITE_ANIM_DICT_DEFAULT
db SPRITE_ANIM_FRAMESET_BOARD_MENU_APPEAR_DIE_NUMBER, SPRITE_ANIM_FUNC_NULL, SPRITE_ANIM_DICT_DEFAULT
; SPRITE_ANIM_OBJ_BOARD_MENU_MOVE_DIE_NUMBER
db SPRITE_ANIM_FRAMESET_BOARD_MENU_MOVE_DIE_NUMBER, SPRITE_ANIM_FUNC_BOARD_MENU_MOVE_DIE_NUMBER, SPRITE_ANIM_DICT_DEFAULT

View File

@ -10,13 +10,13 @@ BoardMenuOAM:
dbsprite 3, 18, 4, 0, BOARD_MENU_OAM_FIRST_TILE + 7, PAL_OW_MISC
dbsprite 4, 18, 4, 0, BOARD_MENU_OAM_FIRST_TILE + 8, PAL_OW_MISC
; BOARDMENUITEM_PARTY
dbsprite 6, 16, 0, 0, BOARD_MENU_OAM_FIRST_TILE + 9, PAL_OW_MISC
dbsprite 3, 16, 0, 0, BOARD_MENU_OAM_FIRST_TILE + 9, PAL_OW_MISC
dbsprite 7, 16, 0, 0, BOARD_MENU_OAM_FIRST_TILE + 10, PAL_OW_MISC
dbsprite 8, 16, 0, 0, BOARD_MENU_OAM_FIRST_TILE + 11, PAL_OW_MISC
dbsprite 6, 17, 0, 0, BOARD_MENU_OAM_FIRST_TILE + 12, PAL_OW_MISC
dbsprite 3, 17, 0, 0, BOARD_MENU_OAM_FIRST_TILE + 12, PAL_OW_MISC
dbsprite 7, 17, 0, 0, BOARD_MENU_OAM_FIRST_TILE + 13, PAL_OW_MISC
dbsprite 8, 17, 0, 0, BOARD_MENU_OAM_FIRST_TILE + 14, PAL_OW_MISC
dbsprite 6, 18, 0, 0, BOARD_MENU_OAM_FIRST_TILE + 15, PAL_OW_MISC
dbsprite 3, 18, 0, 0, BOARD_MENU_OAM_FIRST_TILE + 15, PAL_OW_MISC
dbsprite 7, 18, 0, 0, BOARD_MENU_OAM_FIRST_TILE + 16, PAL_OW_MISC
dbsprite 8, 18, 0, 0, BOARD_MENU_OAM_FIRST_TILE + 17, PAL_OW_MISC
; BOARDMENUITEM_PACK
@ -81,3 +81,35 @@ DieRollOAM:
dbsprite 10, 7, 0, 0, DIE_ROLL_OAM_FIRST_TILE + 11, PAL_OW_MISC
dbsprite 9, 8, 0, 0, DIE_ROLL_OAM_FIRST_TILE + 30, PAL_OW_MISC
dbsprite 10, 8, 0, 0, DIE_ROLL_OAM_FIRST_TILE + 31, PAL_OW_MISC
SpacesLeftNumberOAM:
; 1
dbsprite 1, 3, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE, PAL_OW_MISC
dbsprite 2, 3, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 1, PAL_OW_MISC
dbsprite 1, 4, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 20, PAL_OW_MISC
dbsprite 2, 4, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 21, PAL_OW_MISC
; 2
dbsprite 1, 3, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 2, PAL_OW_MISC
dbsprite 2, 3, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 3, PAL_OW_MISC
dbsprite 1, 4, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 22, PAL_OW_MISC
dbsprite 2, 4, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 23, PAL_OW_MISC
; 3
dbsprite 1, 3, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 4, PAL_OW_MISC
dbsprite 2, 3, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 5, PAL_OW_MISC
dbsprite 1, 4, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 24, PAL_OW_MISC
dbsprite 2, 4, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 25, PAL_OW_MISC
; 4
dbsprite 1, 3, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 6, PAL_OW_MISC
dbsprite 2, 3, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 7, PAL_OW_MISC
dbsprite 1, 4, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 26, PAL_OW_MISC
dbsprite 2, 4, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 27, PAL_OW_MISC
; 5
dbsprite 1, 3, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 8, PAL_OW_MISC
dbsprite 2, 3, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 9, PAL_OW_MISC
dbsprite 1, 4, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 28, PAL_OW_MISC
dbsprite 2, 4, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 29, PAL_OW_MISC
; 6
dbsprite 1, 3, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 10, PAL_OW_MISC
dbsprite 2, 3, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 11, PAL_OW_MISC
dbsprite 1, 4, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 30, PAL_OW_MISC
dbsprite 2, 4, 4, 4, DIE_NUMBERS_OAM_FIRST_TILE + 31, PAL_OW_MISC

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:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 579 B

After

Width:  |  Height:  |  Size: 571 B

View File

@ -109,5 +109,5 @@ Level1_Map1_MapEvents:
object_event 4, 2, SPRITE_CONSOLE, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, Level1_Map1_GameConsoleScript, -1
object_event 4, 4, SPRITE_DOLL_1, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, Level1_Map1_Doll1Script, -1
object_event 5, 4, SPRITE_DOLL_2, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, Level1_Map1_Doll2Script, -1
object_event 0, 1, SPRITE_BIG_DOLL, SPRITEMOVEDATA_BIGDOLL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, Level1_Map1_BigDollScript, -1
object_event 6, 6, SPRITE_YOUNGSTER, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_TRAINER, 1, Level1_Map1_TrainerYoungsterMikey, -1
; object_event 0, 1, SPRITE_BIG_DOLL, SPRITEMOVEDATA_BIGDOLL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, Level1_Map1_BigDollScript, -1
; object_event 6, 6, SPRITE_YOUNGSTER, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_TRAINER, 1, Level1_Map1_TrainerYoungsterMikey, -1