From 1f2be83ebc7eafbfe4ccb45467a63c6c0392a3e6 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Wed, 27 Sep 2023 19:25:47 +0200 Subject: [PATCH] Board menu: move die number animation (#11) --- constants/sprite_anim_constants.asm | 6 ++-- constants/wram_constants.asm | 5 ++-- data/sprite_anims/framesets.asm | 14 +++++---- data/sprite_anims/oam.asm | 4 +-- data/sprite_anims/objects.asm | 4 +-- data/sprites/secondary_sprites.asm | 38 ++++++++++++++++++++++-- engine/board/menu.asm | 40 ++++++++++++++++++++++--- engine/overworld/map_objects.asm | 28 ++++++++++++++++++ engine/sprite_anims/functions.asm | 44 +++++++++++++++++++++++----- gfx/board/die_roll.png | Bin 579 -> 571 bytes maps/Level1_Map1.asm | 4 +-- 11 files changed, 154 insertions(+), 33 deletions(-) diff --git a/constants/sprite_anim_constants.asm b/constants/sprite_anim_constants.asm index 904780b46..b2498b29a 100644 --- a/constants/sprite_anim_constants.asm +++ b/constants/sprite_anim_constants.asm @@ -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, \ diff --git a/constants/wram_constants.asm b/constants/wram_constants.asm index c1648ad1e..94a6462de 100644 --- a/constants/wram_constants.asm +++ b/constants/wram_constants.asm @@ -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 diff --git a/data/sprite_anims/framesets.asm b/data/sprite_anims/framesets.asm index ef72def54..b97dff6cb 100644 --- a/data/sprite_anims/framesets.asm +++ b/data/sprite_anims/framesets.asm @@ -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 diff --git a/data/sprite_anims/oam.asm b/data/sprite_anims/oam.asm index c0f9df109..d243ecb6b 100644 --- a/data/sprite_anims/oam.asm +++ b/data/sprite_anims/oam.asm @@ -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 diff --git a/data/sprite_anims/objects.asm b/data/sprite_anims/objects.asm index 9e762a64b..c4777ba98 100644 --- a/data/sprite_anims/objects.asm +++ b/data/sprite_anims/objects.asm @@ -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 diff --git a/data/sprites/secondary_sprites.asm b/data/sprites/secondary_sprites.asm index 5bc16a89c..21dd93171 100755 --- a/data/sprites/secondary_sprites.asm +++ b/data/sprites/secondary_sprites.asm @@ -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 diff --git a/engine/board/menu.asm b/engine/board/menu.asm index 7c433e515..88ee616a8 100755 --- a/engine/board/menu.asm +++ b/engine/board/menu.asm @@ -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: diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm index 301dff7c9..33139f778 100644 --- a/engine/overworld/map_objects.asm +++ b/engine/overworld/map_objects.asm @@ -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" diff --git a/engine/sprite_anims/functions.asm b/engine/sprite_anims/functions.asm index 8f18782d7..8504332a5 100644 --- a/engine/sprite_anims/functions.asm +++ b/engine/sprite_anims/functions.asm @@ -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: diff --git a/gfx/board/die_roll.png b/gfx/board/die_roll.png index 256ed21aaf767a4ea3b8bfab89d7212f8f5650c9..45bbf57d241f456ef62d5725df61f9fd720ffa9a 100755 GIT binary patch delta 495 zcmVsC1i0?IZv}3@cIRV1e|B_^SbtLY-7i7<&jyUi!!UH~ zV|qXPMi-&|caCE#*EQsP!s~R5l&{A?jSu8_ZT)BG2Q9wrnOGdYf7!l9&`C;xhh!*< zg`ucYw2z-5YJ6g?AL#mPct`zb=5O)koR`FjHlPgj7m+vL3S#ITpoUt%HQ!lSdIrBo zZ;#;64RaAgV}H7nV-v=rbetMLR71+wPAEpsmss*kYJG|2{(-E)QonRUHN<>*Ex*Uk zhYyt;qn~^Pw}ON~7ysMAWXV_SBh=!zz=gKvr-L|L!xj*aHEFI$WFhC}nlI(ESa>KN zU;<^FTz*bqjMDrua`|(V_^CRM&d+%Vp?R#$&vyAM+S lCHAj0CBSvxeJj&6bzgHS7^f`vI`04g002ovPDHLkV1mCx{%8OI delta 482 zcmV<80UiFk1j7W7R)5$@L_t(&L+zT~a)Lk%MuFkAyz{+;_wvpMqkasZP2>J%Me3L{ zV<|2t3A=G=JMEV{(=>G<=6PO^m&;{6YUsJ|euxr(?E8Mb;Cw!BZ$A?nyI!vyT;RU@ zR=>a9ZVOIA2pOC@ejL-=o(@aOj4)h@mmv$*~Dz zQ94eIAF3hcYbO*V=SwX4CAGf9a{oZqV5wg^p&DYoyq4c%=fj6ej?qs(f?GjCpo{OVwl+<(9SrvWwSSb&bU;J*7H