Begin implementation of base effect of regular spaces (#21)

This commit is contained in:
xCrystal
2023-10-14 19:28:35 +02:00
parent 917db30e98
commit 47422a1adb
11 changed files with 187 additions and 90 deletions

View File

@@ -14,6 +14,7 @@ BoardMenuScript::
callasm BoardMenu_Die
iffalse BoardMenuScript
callasm BoardMenu_BreakDieAnimation
callasm RestoreOverworldFontOverBoardMenuGFX
end
.Party:
@@ -203,7 +204,7 @@ DIE_MAX_NUMBER EQU 6
add DIE_MAX_NUMBER
add $1
ld [wDieRoll], a
farcall _UpdateSecondarySprites
call UpdateSecondarySprites
call GetJoypad
ldh a, [hJoyPressed]
bit B_BUTTON_F, a
@@ -323,6 +324,8 @@ BoardMenu_BreakDieAnimation:
ld a, [wDieRoll]
ld [wSpacesLeft], a
call UpdateSprites
ld a, BOARDEVENT_HANDLE_BOARD
ldh [hCurBoardEvent], a
ret
BoardMenu_Party:

35
engine/board/spaces.asm Executable file
View File

@@ -0,0 +1,35 @@
BoardSpaceScripts:: ; used only for BANK(BoardSpaceScripts)
BlueSpaceScript::
scall ArriveToRegularSpaceScript
iftrue .done
.done
end
RedSpaceScript::
scall ArriveToRegularSpaceScript
iftrue .done
.done
end
GreySpaceScript::
scall ArriveToRegularSpaceScript
iftrue .done
.done
end
ArriveToRegularSpaceScript:
playsound SFX_PRESENT
callasm ArriveToRegularSpace
end
ArriveToRegularSpace:
ld hl, wSpacesLeft
dec [hl]
ld a, [hl]
ld [hScriptVar], a
and a
jp nz, UpdateSecondarySprites
ld hl, wDisplaySecondarySprites
res SECONDARYSPRITES_DIE_ROLL_F, [hl]
ret

View File

@@ -35,11 +35,6 @@ EnableEvents::
ld [wScriptFlags2], a
ret
CheckBit5_ScriptFlags2: ; unreferenced
ld hl, wScriptFlags2
bit 5, [hl]
ret
DisableWarpsConnxns: ; unreferenced
ld hl, wScriptFlags2
res 2, [hl]
@@ -60,6 +55,11 @@ DisableWildEncounters: ; unreferenced
res 4, [hl]
ret
DisableSpaceEffects: ; unreferenced
ld hl, wScriptFlags2
res 5, [hl]
ret
EnableWarpsConnxns: ; unreferenced
ld hl, wScriptFlags2
set 2, [hl]
@@ -80,6 +80,11 @@ EnableWildEncounters:
set 4, [hl]
ret
EnableSpaceEffects: ; unreferenced
ld hl, wScriptFlags2
set 5, [hl]
ret
CheckWarpConnxnScriptFlag:
ld hl, wScriptFlags2
bit 2, [hl]
@@ -100,6 +105,11 @@ CheckWildEncountersScriptFlag:
bit 4, [hl]
ret
CheckSpaceEffects:
ld hl, wScriptFlags2
bit 5, [hl]
ret
StartMap:
xor a
ldh [hScriptVar], a
@@ -111,7 +121,7 @@ StartMap:
farcall InitCallReceiveDelay
call ClearJoypad
ld a, BOARDEVENT_DISPLAY_MENU
ld [hCurBoardEvent], a
ldh [hCurBoardEvent], a
EnterMap:
xor a
ld [wXYComparePointer], a
@@ -285,7 +295,8 @@ CheckBoardEvent:
.Jumptable:
table_width 2, .Jumptable
dw .none
dw .menu
dw .menu ; BOARDEVENT_DISPLAY_MENU
dw .board ; BOARDEVENT_HANDLE_BOARD
assert_table_length NUM_BOARD_EVENTS + 1
.none
@@ -296,11 +307,43 @@ CheckBoardEvent:
ld a, BANK(BoardMenuScript)
ld hl, BoardMenuScript
call CallScript
xor a
ld [hCurBoardEvent], a
scf
ret
.board
call CheckSpaceEffects
jr z, .no_space_effect
ld a, [wPlayerTile]
and $f0
cp HI_NYBBLE_SPACES
jr nz, .no_space_effect
ld a, [wPlayerTile]
and $0f
ld e, a
ld d, 0
ld hl, .SpaceScripts
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
ld a, BANK(BoardSpaceScripts)
call CallScript
scf
ret
.no_space_effect
; continue moving in board
xor a
ret
.SpaceScripts:
table_width 2, .SpaceScripts
dw BlueSpaceScript ; COLL_BLUE_SPACE
dw RedSpaceScript ; COLL_RED_SPACE
dw GreySpaceScript ; COLL_GREY_SPACE
assert_table_length NUM_COLL_SPACES
CheckTrainerBattle_GetPlayerEvent:
call CheckTrainerBattle
jr nc, .nope

View File

@@ -3078,7 +3078,7 @@ InitSprites:
dw wObject11Struct
dw wObject12Struct
_UpdateSecondarySprites:
_UpdateSecondarySprites::
; this is a shorter _UpdateSprites for when only secondary sprites have changed since the last sprites update,
; but NOT expanded, which would require to displace primary (NPC) sprites in OAM.
; if it is detected that the size of secondary sprites has increased in the end,
@@ -3145,15 +3145,17 @@ InitBoardMenuSprites:
InitRollDieSprites:
push af
ld hl, DieRollOAM
ld a, [wDieRoll]
and a
jr z, .zero_or_oam_full
dec a
ld hl, DieRollOAM
ld bc, DIE_SIZE * SPRITEOAMSTRUCT_LENGTH
call AddNTimes
; find the beginning of free space in OAM, and assure there's space for a DIE_SIZE object
ldh a, [hUsedSpriteIndex]
cp (NUM_SPRITE_OAM_STRUCTS * SPRITEOAMSTRUCT_LENGTH) - (DIE_SIZE * SPRITEOAMSTRUCT_LENGTH) + 1
jr nc, .oam_full
jr nc, .zero_or_oam_full
; copy the sprite data (DIE_SIZE objects) of that item to the available space in OAM
ld e, a
ld d, HIGH(wShadowOAM)
@@ -3164,7 +3166,7 @@ InitRollDieSprites:
add (DIE_SIZE * SPRITEOAMSTRUCT_LENGTH)
ldh [hUsedSpriteIndex], a
.oam_full
.zero_or_oam_full
pop af
ret