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

@@ -176,9 +176,9 @@ ArriveToBranchSpaceScript:
call LoadTempSpaceBranchData
call .DisableDirectionsRequiringLockedTechniques
; draw arrows for valid directions
farcall LoadBranchArrowsGFX
farcall LoadBranchSpaceGFX
ld hl, wDisplaySecondarySprites
set SECONDARYSPRITES_BRANCH_ARROWS_F, [hl]
set SECONDARYSPRITES_BRANCH_SPACE_F, [hl]
; update sprites
jp UpdateActiveSprites
@@ -260,7 +260,7 @@ PromptPlayerToChooseBranchDirection:
ld a, [hl]
ld [wCurSpaceNextSpace], a
ld hl, wDisplaySecondarySprites
res SECONDARYSPRITES_BRANCH_ARROWS_F, [hl]
res SECONDARYSPRITES_BRANCH_SPACE_F, [hl]
ld a, TRUE
ldh [hScriptVar], a
jp PlayClickSFX
@@ -292,7 +292,7 @@ PromptPlayerToChooseBranchDirection:
set INVISIBLE_F, [hl]
ld hl, wDisplaySecondarySprites
res SECONDARYSPRITES_SPACES_LEFT_F, [hl]
res SECONDARYSPRITES_BRANCH_ARROWS_F, [hl]
res SECONDARYSPRITES_BRANCH_SPACE_F, [hl]
farcall MockPlayerObject
call UpdateSprites
farcall LoadViewMapModeGFX

View File

@@ -63,9 +63,15 @@ SeenByTalkerScript::
and TALKEREVENTTYPE_MASK
cp TALKEREVENTTYPE_MANDATORY
jr z, .skip
farcall LoadTalkerEventLegendGFX
ld hl, wDisplaySecondarySprites
set SECONDARYSPRITES_TALKER_EVENT_F, [hl]
call UpdateActiveSprites
call JoyWaitAorB
call PlayClickSFX
call WaitSFX
ld hl, wDisplaySecondarySprites
res SECONDARYSPRITES_TALKER_EVENT_F, [hl]
ldh a, [hJoyPressed]
bit A_BUTTON_F, a
jr z, .skip ; jump if b was pressed

View File

@@ -39,11 +39,21 @@ LoadBoardMenuDieNumbersGFX::
.DieNumbersOAMGFX:
INCBIN "gfx/board/die_numbers.2bpp"
LoadBranchArrowsGFX::
LoadBranchSpaceGFX::
ld de, .BranchArrowsOAMGFX
ld hl, vTiles0 + BRANCH_ARROWS_OAM_FIRST_TILE * LEN_2BPP_TILE
lb bc, BANK(.BranchArrowsOAMGFX), NUM_DIRECTIONS
call Get2bppViaHDMA
ld hl, vTiles0 + BRANCH_LEGEND_OAM_FIRST_TILE * LEN_2BPP_TILE
call LoadLegendButtonsGFX
ld de, LegendChooseOAMGFX
ld hl, vTiles0 + (BRANCH_LEGEND_OAM_FIRST_TILE + 5) * LEN_2BPP_TILE
lb bc, BANK(LegendChooseOAMGFX), 3
call Get2bppViaHDMA
ld de, LegendViewOAMGFX
ld hl, vTiles0 + (BRANCH_LEGEND_OAM_FIRST_TILE + 8) * LEN_2BPP_TILE
lb bc, BANK(LegendViewOAMGFX), 3
call Get2bppViaHDMA
ret
.BranchArrowsOAMGFX:
@@ -51,10 +61,60 @@ INCBIN "gfx/board/branch_arrows.2bpp"
LoadViewMapModeGFX::
ld de, .ViewMapModeArrowsOAMGFX
ld hl, vTiles0 + VIEW_MAP_MODE_OAM_FIRST_TILE * LEN_2BPP_TILE
ld hl, vTiles0 + VIEW_MAP_MODE_ARROWS_OAM_FIRST_TILE * LEN_2BPP_TILE
lb bc, BANK(.ViewMapModeArrowsOAMGFX), NUM_DIRECTIONS
call Get2bppViaHDMA
ld hl, vTiles0 + VIEW_MAP_MODE_LEGEND_OAM_FIRST_FILE * LEN_2BPP_TILE
call LoadLegendButtonsGFX
ld de, LegendMoveOAMGFX
ld hl, vTiles0 + (VIEW_MAP_MODE_LEGEND_OAM_FIRST_FILE + 5) * LEN_2BPP_TILE
lb bc, BANK(LegendMoveOAMGFX), 3
call Get2bppViaHDMA
ld de, LegendBackOAMGFX
ld hl, vTiles0 + (VIEW_MAP_MODE_LEGEND_OAM_FIRST_FILE + 8) * LEN_2BPP_TILE
lb bc, BANK(LegendBackOAMGFX), 3
call Get2bppViaHDMA
ret
.ViewMapModeArrowsOAMGFX:
INCBIN "gfx/board/view_map_arrows.2bpp"
LoadTalkerEventLegendGFX::
ld hl, vTiles0 + TALKER_EVENT_LEGEND_OAM_FIRST_TILE * LEN_2BPP_TILE
call LoadLegendButtonsGFX
ld de, LegendTalkOAMGFX
ld hl, vTiles0 + (TALKER_EVENT_LEGEND_OAM_FIRST_TILE + 5) * LEN_2BPP_TILE
lb bc, BANK(LegendTalkOAMGFX), 3
call Get2bppViaHDMA
ld de, LegendSkipOAMGFX
ld hl, vTiles0 + (TALKER_EVENT_LEGEND_OAM_FIRST_TILE + 8) * LEN_2BPP_TILE
lb bc, BANK(LegendTalkOAMGFX), 3
call Get2bppViaHDMA
ret
LoadLegendButtonsGFX:
ld de, .LegendButtonsOAMGFX
lb bc, BANK(.LegendButtonsOAMGFX), 5
call Get2bppViaHDMA
ret
.LegendButtonsOAMGFX:
INCBIN "gfx/legend/buttons.2bpp"
LegendTalkOAMGFX:
INCBIN "gfx/legend/talk.2bpp"
LegendSkipOAMGFX:
INCBIN "gfx/legend/skip.2bpp"
LegendChooseOAMGFX:
INCBIN "gfx/legend/choose.2bpp"
LegendViewOAMGFX:
INCBIN "gfx/legend/view.2bpp"
LegendMoveOAMGFX:
INCBIN "gfx/legend/move.2bpp"
LegendBackOAMGFX:
INCBIN "gfx/legend/back.2bpp"

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]