mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-09-09 09:51:34 -07:00
OAM animation of gaining or losing coins during blue/red space effect (#22)
This commit is contained in:
parent
28bd777632
commit
b530cf90f4
@ -35,11 +35,12 @@ DEF NOON_HOUR EQU 12 ; 12 PM
|
|||||||
DEF MAX_DAYS EQU 36 * 7 ; 252
|
DEF MAX_DAYS EQU 36 * 7 ; 252
|
||||||
|
|
||||||
; significant coins values
|
; significant coins values
|
||||||
DEF START_COINS EQU 100
|
DEF START_COINS EQU 100
|
||||||
DEF MOM_COINS EQU 2300
|
DEF MOM_COINS EQU 2300
|
||||||
DEF MAX_COINS EQU 999999
|
DEF MAX_COINS EQU 999999
|
||||||
DEF MAX_LEVEL_COINS EQU 99999
|
DEF MAX_LEVEL_COINS EQU 99999
|
||||||
DEF MAX_CHIPS EQU 9999
|
DEF MAX_DELTA_COINS_DIGITS EQU 5
|
||||||
|
DEF MAX_CHIPS EQU 9999
|
||||||
|
|
||||||
; link record
|
; link record
|
||||||
DEF MAX_LINK_RECORD EQU 9999
|
DEF MAX_LINK_RECORD EQU 9999
|
||||||
|
@ -8,12 +8,13 @@ DEF AUTO_INPUT EQU $ff
|
|||||||
|
|
||||||
; wDisplaySecondarySprites
|
; wDisplaySecondarySprites
|
||||||
const_def
|
const_def
|
||||||
const SECONDARYSPRITES_BOARD_MENU_F ; 0
|
const SECONDARYSPRITES_BOARD_MENU_F ; 0
|
||||||
const SECONDARYSPRITES_DIE_ROLL_F ; 1
|
const SECONDARYSPRITES_DIE_ROLL_F ; 1
|
||||||
const SECONDARYSPRITES_SPACES_LEFT_F ; 2
|
const SECONDARYSPRITES_SPACES_LEFT_F ; 2
|
||||||
const SECONDARYSPRITES_BRANCH_SPACE_F ; 3
|
const SECONDARYSPRITES_BRANCH_SPACE_F ; 3
|
||||||
const SECONDARYSPRITES_VIEW_MAP_MODE_F ; 4
|
const SECONDARYSPRITES_VIEW_MAP_MODE_F ; 4
|
||||||
const SECONDARYSPRITES_TALKER_EVENT_F ; 5
|
const SECONDARYSPRITES_TALKER_EVENT_F ; 5
|
||||||
|
const SECONDARYSPRITES_GAIN_OR_LOSE_COINS_F ; 6
|
||||||
|
|
||||||
; wCurDexMode::
|
; wCurDexMode::
|
||||||
const_def
|
const_def
|
||||||
|
@ -113,6 +113,8 @@ SpecialsPointers::
|
|||||||
add_special FadeOutMusic
|
add_special FadeOutMusic
|
||||||
add_special Diploma
|
add_special Diploma
|
||||||
add_special PrintDiploma
|
add_special PrintDiploma
|
||||||
|
add_special PrintGainCoins
|
||||||
|
add_special PrintLoseCoins
|
||||||
|
|
||||||
; Crystal only
|
; Crystal only
|
||||||
add_special Reset ; bank 0
|
add_special Reset ; bank 0
|
||||||
|
@ -6,6 +6,7 @@ BlueSpaceScript::
|
|||||||
scall LandedInRegularSpaceScript_BeforeSpaceEffect
|
scall LandedInRegularSpaceScript_BeforeSpaceEffect
|
||||||
givecoins CUR_LEVEL_COINS, BLUE_RED_SPACE_COINS
|
givecoins CUR_LEVEL_COINS, BLUE_RED_SPACE_COINS
|
||||||
playsound SFX_TRANSACTION
|
playsound SFX_TRANSACTION
|
||||||
|
special PrintGainCoins
|
||||||
scall LandedInRegularSpaceScript_AfterSpaceEffect
|
scall LandedInRegularSpaceScript_AfterSpaceEffect
|
||||||
.not_landed
|
.not_landed
|
||||||
end
|
end
|
||||||
@ -16,6 +17,7 @@ RedSpaceScript::
|
|||||||
scall LandedInRegularSpaceScript_BeforeSpaceEffect
|
scall LandedInRegularSpaceScript_BeforeSpaceEffect
|
||||||
takecoins CUR_LEVEL_COINS, BLUE_RED_SPACE_COINS
|
takecoins CUR_LEVEL_COINS, BLUE_RED_SPACE_COINS
|
||||||
playsound SFX_TRANSACTION
|
playsound SFX_TRANSACTION
|
||||||
|
special PrintLoseCoins
|
||||||
scall LandedInRegularSpaceScript_AfterSpaceEffect
|
scall LandedInRegularSpaceScript_AfterSpaceEffect
|
||||||
.not_landed
|
.not_landed
|
||||||
end
|
end
|
||||||
@ -315,4 +317,43 @@ UnionSpaceScript::
|
|||||||
call LoadCurSpaceData
|
call LoadCurSpaceData
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
PrintGainCoins:
|
||||||
|
ld hl, wStringBuffer1
|
||||||
|
ld a, "<COIN>"
|
||||||
|
ld [hli], a
|
||||||
|
ld a, "<PLUS>"
|
||||||
|
ld [hli], a
|
||||||
|
jr PrintGainOrLoseCoins
|
||||||
|
|
||||||
|
PrintLoseCoins:
|
||||||
|
ld hl, wStringBuffer1
|
||||||
|
ld a, "<COIN>"
|
||||||
|
ld [hli], a
|
||||||
|
ld a, "<MINUS>"
|
||||||
|
ld [hli], a
|
||||||
|
; fallthrough
|
||||||
|
|
||||||
|
PrintGainOrLoseCoins:
|
||||||
|
push hl
|
||||||
|
; fill string space with "@" to ensure that it is terminated with at least one "@"
|
||||||
|
ld a, "@"
|
||||||
|
ld c, MAX_DELTA_COINS_DIGITS + 1
|
||||||
|
.loop
|
||||||
|
ld [hli], a
|
||||||
|
dec c
|
||||||
|
jr nz, .loop
|
||||||
|
pop hl
|
||||||
|
; copy coins amount string to wStringBuffer1 + $2
|
||||||
|
ld de, hCoinsTemp
|
||||||
|
lb bc, 3 | 1 << 6, MAX_DELTA_COINS_DIGITS ; 3 bytes, left aligned, no leading zeros, 5 digits
|
||||||
|
call PrintNum
|
||||||
|
ld hl, wDisplaySecondarySprites
|
||||||
|
set SECONDARYSPRITES_GAIN_OR_LOSE_COINS_F, [hl]
|
||||||
|
call UpdateActiveSprites
|
||||||
|
ld c, 45 ; 750 ms
|
||||||
|
call DelayFrames
|
||||||
|
ld hl, wDisplaySecondarySprites
|
||||||
|
res SECONDARYSPRITES_GAIN_OR_LOSE_COINS_F, [hl]
|
||||||
|
ret
|
||||||
|
|
||||||
INCLUDE "engine/board/disabled_spaces.asm"
|
INCLUDE "engine/board/disabled_spaces.asm"
|
||||||
|
@ -3118,6 +3118,8 @@ InitSecondarySprites:
|
|||||||
call nz, InitViewMapModeSprites
|
call nz, InitViewMapModeSprites
|
||||||
bit SECONDARYSPRITES_TALKER_EVENT_F, a
|
bit SECONDARYSPRITES_TALKER_EVENT_F, a
|
||||||
call nz, InitTalkerEventSprites
|
call nz, InitTalkerEventSprites
|
||||||
|
bit SECONDARYSPRITES_GAIN_OR_LOSE_COINS_F, a
|
||||||
|
call nz, InitGainOrLoseCoinsSprites
|
||||||
ret
|
ret
|
||||||
|
|
||||||
InitBoardMenuSprites:
|
InitBoardMenuSprites:
|
||||||
@ -3374,6 +3376,8 @@ InitViewMapModeSprites:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
InitTalkerEventSprites:
|
InitTalkerEventSprites:
|
||||||
|
push af
|
||||||
|
|
||||||
; find the beginning of free space in OAM, and assure there's space for 8 objects
|
; find the beginning of free space in OAM, and assure there's space for 8 objects
|
||||||
ldh a, [hUsedSpriteIndex]
|
ldh a, [hUsedSpriteIndex]
|
||||||
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (8 * SPRITEOAMSTRUCT_LENGTH) + 1
|
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (8 * SPRITEOAMSTRUCT_LENGTH) + 1
|
||||||
@ -3406,4 +3410,74 @@ InitTalkerEventSprites:
|
|||||||
pop af
|
pop af
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
InitGainOrLoseCoinsSprites:
|
||||||
|
push af
|
||||||
|
|
||||||
|
; print string at wStringBuffer1 as OAM
|
||||||
|
; get string length
|
||||||
|
ld hl, wStringBuffer1
|
||||||
|
ld c, 0
|
||||||
|
.get_length_loop
|
||||||
|
ld a, [hli]
|
||||||
|
cp "@"
|
||||||
|
jr z, .got_length
|
||||||
|
inc c
|
||||||
|
ld a, c
|
||||||
|
cp $2 + MAX_DELTA_COINS_DIGITS + 1
|
||||||
|
jr nz, .get_length_loop
|
||||||
|
|
||||||
|
.got_length
|
||||||
|
ld e, c
|
||||||
|
; find the beginning of free space in OAM, and assure there's space for c objects
|
||||||
|
ld a, (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) + 1
|
||||||
|
sla c ;
|
||||||
|
sla c ; c *= SPRITEOAMSTRUCT_LENGTH
|
||||||
|
sub c
|
||||||
|
ld b, a ; b = (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (c * SPRITEOAMSTRUCT_LENGTH) + 1
|
||||||
|
ldh a, [hUsedSpriteIndex]
|
||||||
|
cp b
|
||||||
|
jr nc, .oam_full
|
||||||
|
|
||||||
|
; align OAM in the X axis according to the string length (e)
|
||||||
|
ld a, 10 * TILE_WIDTH
|
||||||
|
ld c, TILE_WIDTH / 2
|
||||||
|
.x_coord_loop
|
||||||
|
sub c
|
||||||
|
dec e
|
||||||
|
jr nz, .x_coord_loop
|
||||||
|
; b = SPRITEOAMSTRUCT_XCOORD
|
||||||
|
ld b, a
|
||||||
|
; c = SPRITEOAMSTRUCT_YCOORD
|
||||||
|
ld c, 8 * TILE_WIDTH
|
||||||
|
; de = address within wShadowOAM
|
||||||
|
ld a, [hUsedSpriteIndex]
|
||||||
|
ld e, a
|
||||||
|
ld d, HIGH(wShadowOAM)
|
||||||
|
ld hl, wStringBuffer1
|
||||||
|
.print_oam_loop
|
||||||
|
ld a, c
|
||||||
|
ld [de], a ; SPRITEOAMSTRUCT_YCOORD
|
||||||
|
inc de
|
||||||
|
ld a, b
|
||||||
|
ld [de], a ; SPRITEOAMSTRUCT_XCOORD
|
||||||
|
inc de
|
||||||
|
add 1 * TILE_WIDTH
|
||||||
|
ld b, a
|
||||||
|
ld a, [hli]
|
||||||
|
ld [de], a ; SPRITEOAMSTRUCT_TILE_ID
|
||||||
|
inc de
|
||||||
|
ld a, PAL_OW_MISC
|
||||||
|
ld [de], a ; SPRITEOAMSTRUCT_ATTRIBUTES
|
||||||
|
inc de
|
||||||
|
ld a, [hl]
|
||||||
|
cp "@"
|
||||||
|
jr nz, .print_oam_loop
|
||||||
|
|
||||||
|
ld a, e
|
||||||
|
ld [hUsedSpriteIndex], a
|
||||||
|
|
||||||
|
.oam_full
|
||||||
|
pop af
|
||||||
|
ret
|
||||||
|
|
||||||
INCLUDE "data/sprites/secondary_sprites.asm"
|
INCLUDE "data/sprites/secondary_sprites.asm"
|
||||||
|
Loading…
Reference in New Issue
Block a user