Legend OAM in branch space (#28), view map mode (#29), and talker events (#30)

This commit is contained in:
xCrystal
2023-12-23 14:44:36 +01:00
parent 2d8ccc53df
commit 05d925eeb4
15 changed files with 273 additions and 22 deletions

View File

@@ -3112,10 +3112,12 @@ InitSecondarySprites:
call nz, InitDieRollSprites
bit SECONDARYSPRITES_SPACES_LEFT_F, a
call nz, InitSpacesLeftNumberSprites
bit SECONDARYSPRITES_BRANCH_ARROWS_F, a
bit SECONDARYSPRITES_BRANCH_SPACE_F, a
call nz, InitBranchArrowsSprites
bit SECONDARYSPRITES_VIEW_MAP_MODE_F, a
call nz, InitViewMapModeSprites
bit SECONDARYSPRITES_TALKER_EVENT_F, a
call nz, InitTalkerEventSprites
ret
InitBoardMenuSprites:
@@ -3200,6 +3202,7 @@ InitSpacesLeftNumberSprites:
InitBranchArrowsSprites:
push af
;; arrows
; find the beginning of free space in OAM, and assure there's space for 4 objects
ldh a, [hUsedSpriteIndex]
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (NUM_DIRECTIONS * SPRITEOAMSTRUCT_LENGTH) + 1
@@ -3252,6 +3255,35 @@ InitBranchArrowsSprites:
dec c
jr nz, .loop
;; legend
; find the beginning of free space in OAM, and assure there's space for 8 objects
ldh a, [hUsedSpriteIndex]
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (8 * SPRITEOAMSTRUCT_LENGTH) + 1
jr nc, .oam_full
; copy the sprite data of the legend to the available space in OAM.
; the palette byte overrides that data as it matches the player's color palette.
ld e, a
ld d, HIGH(wShadowOAM)
gender_to_pal
ld b, a
ld c, 8 ; number of objects
ld hl, BranchLegendOAM
.loop2
push bc
ld bc, SPRITEOAMSTRUCT_LENGTH - 1
call CopyBytes
pop bc
ld a, b ; palette
ld [de], a
inc hl
inc de
dec c
jr nz, .loop2
ldh a, [hUsedSpriteIndex]
add (8 * SPRITEOAMSTRUCT_LENGTH)
ldh [hUsedSpriteIndex], a
.oam_full
pop af
ret
@@ -3259,6 +3291,7 @@ InitBranchArrowsSprites:
InitViewMapModeSprites:
push af
;; arrows
; find the beginning of free space in OAM, and assure there's space for 4 objects
ldh a, [hUsedSpriteIndex]
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (NUM_DIRECTIONS * SPRITEOAMSTRUCT_LENGTH) + 1
@@ -3307,6 +3340,68 @@ InitViewMapModeSprites:
dec c
jr nz, .loop
;; legend
; find the beginning of free space in OAM, and assure there's space for 8 objects
ldh a, [hUsedSpriteIndex]
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (8 * SPRITEOAMSTRUCT_LENGTH) + 1
jr nc, .oam_full
; copy the sprite data of the legend to the available space in OAM.
; the palette byte overrides that data as it matches the player's color palette.
ld e, a
ld d, HIGH(wShadowOAM)
gender_to_pal
ld b, a
ld c, 8 ; number of objects
ld hl, ViewMapModeLegendOAM
.loop2
push bc
ld bc, SPRITEOAMSTRUCT_LENGTH - 1
call CopyBytes
pop bc
ld a, b ; palette
ld [de], a
inc hl
inc de
dec c
jr nz, .loop2
ldh a, [hUsedSpriteIndex]
add (8 * SPRITEOAMSTRUCT_LENGTH)
ldh [hUsedSpriteIndex], a
.oam_full
pop af
ret
InitTalkerEventSprites:
; find the beginning of free space in OAM, and assure there's space for 8 objects
ldh a, [hUsedSpriteIndex]
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (8 * SPRITEOAMSTRUCT_LENGTH) + 1
jr nc, .oam_full
; copy the sprite data of the legend to the available space in OAM.
; the palette byte overrides that data as it matches the player's color palette.
ld e, a
ld d, HIGH(wShadowOAM)
gender_to_pal
ld b, a
ld c, 8 ; number of objects
ld hl, TalkerEventLegendOAM
.loop2
push bc
ld bc, SPRITEOAMSTRUCT_LENGTH - 1
call CopyBytes
pop bc
ld a, b ; palette
ld [de], a
inc hl
inc de
dec c
jr nz, .loop2
ldh a, [hUsedSpriteIndex]
add (8 * SPRITEOAMSTRUCT_LENGTH)
ldh [hUsedSpriteIndex], a
.oam_full
pop af
ret

View File

@@ -1241,9 +1241,15 @@ Script_reloadmapafterviewmapmode:
jr z, .in_board_menu
; .in_branch_space
; load branch space gfx (overwritten by view map mode gfx)
; refresh sprites first without view map mode objects to avoid visual glitch
ld hl, wDisplaySecondarySprites
res SECONDARYSPRITES_VIEW_MAP_MODE_F, [hl]
call UpdateActiveSprites
farcall LoadBranchSpaceGFX
ld hl, wDisplaySecondarySprites
set SECONDARYSPRITES_SPACES_LEFT_F, [hl]
set SECONDARYSPRITES_BRANCH_ARROWS_F, [hl]
set SECONDARYSPRITES_BRANCH_SPACE_F, [hl]
ld hl, wPlayerSpriteSetupFlags
; get the facing direction from the mocked object's facing direction
ld a, [wMapObject{d:LAST_OBJECT}Movement]