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

@ -114,6 +114,11 @@ DEF COLL_DOWN_RIGHT_BUOY EQU $c4 ; unused
DEF COLL_DOWN_LEFT_BUOY EQU $c5 ; unused
DEF COLL_UP_RIGHT_BUOY EQU $c6 ; unused
DEF COLL_UP_LEFT_BUOY EQU $c7 ; unused
const_def $d0
const COLL_BLUE_SPACE ; $d0
const COLL_RED_SPACE ; $d1
const COLL_GREY_SPACE ; $d2
DEF NUM_COLL_SPACES EQU const_value - $d0
DEF COLL_FF EQU $ff ; garbage
; collision data type nybbles
@ -127,3 +132,4 @@ DEF HI_NYBBLE_WARPS EQU $70
DEF HI_NYBBLE_LEDGES EQU $a0
DEF HI_NYBBLE_SIDE_WALLS EQU $b0
DEF HI_NYBBLE_SIDE_BUOYS EQU $c0
DEF HI_NYBBLE_SPACES EQU $d0

View File

@ -327,4 +327,5 @@ DEF NUM_UNOWN_PUZZLES EQU const_value
; board events (tracked by hCurBoardEvent)
const_def 1
const BOARDEVENT_DISPLAY_MENU ; 1
const BOARDEVENT_HANDLE_BOARD ; 2
DEF NUM_BOARD_EVENTS EQU const_value - 1

View File

@ -126,30 +126,30 @@
tilecoll WALL, WALL, WALL, WALL ; 7d
tilecoll WALL, WALL, WALL, WALL ; 7e
tilecoll WALL, WALL, WALL, WALL ; 7f
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 80
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 81
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 82
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 83
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 84
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 85
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 86
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 87
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 88
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 89
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 8a
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 8b
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 8c
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 8d
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 8e
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 8f
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 90
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 91
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 92
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 93
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 94
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 95
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 96
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 97
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 80
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 81
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 82
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 83
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 84
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 85
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 86
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 87
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 88
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 89
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 8a
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 8b
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 8c
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 8d
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 8e
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 8f
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 90
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 91
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 92
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 93
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 94
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 95
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 96
tilecoll BLUE_SPACE, FLOOR, FLOOR, FLOOR ; 97
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 98
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 99
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 9a
@ -158,18 +158,18 @@
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 9d
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 9e
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 9f
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a0
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a1
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a2
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a3
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a4
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a5
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a6
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a7
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a8
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; a9
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; aa
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; ab
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; a0
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; a1
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; a2
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; a3
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; a4
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; a5
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; a6
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; a7
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; a8
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; a9
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; aa
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; ab
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; ac
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; ad
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; ae
@ -186,10 +186,10 @@
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; b9
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; ba
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; bb
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; bc
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; bd
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; be
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; bf
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; bc
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; bd
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; be
tilecoll RED_SPACE, FLOOR, FLOOR, FLOOR ; bf
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; c0
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; c1
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; c2
@ -222,35 +222,35 @@
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; dd
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; de
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; df
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; e0
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; e1
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; e2
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; e3
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; e4
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; e5
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; e6
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; e7
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; e8
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; e9
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; ea
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; eb
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; ec
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; ed
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; ee
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; ef
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; f0
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; f1
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; f2
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; f3
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; f4
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; f5
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; f6
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; f7
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; f8
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; f9
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; fa
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; fb
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; fc
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; fd
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; fe
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; ff
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; e0
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; e1
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; e2
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; e3
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; e4
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; e5
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; e6
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; e7
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; e8
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; e9
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; ea
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; eb
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; ec
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; ed
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; ee
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; ef
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; f0
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; f1
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; f2
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; f3
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; f4
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; f5
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; f6
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; f7
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; f8
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; f9
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; fa
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; fb
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; fc
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; fd
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; fe
tilecoll GREY_SPACE, FLOOR, FLOOR, FLOOR ; ff

View File

@ -103,7 +103,7 @@ $~~~~$*Exit overworld loop*
wMapStatus == MAPSTATUS_HANDLE: <c>the remainder of the code goes at this level</c>
> hOverworldDelay <= 2 <c>2 is *MaxOverworldDelay*</c>\
> MapEventStatus == MAPEVENTS_ON:\
> wMapEventStatus == MAPEVENTS_ON:\
>$~~~~$*Get joypad* <c>update hJoyDown, hJoyReleased, hJoyPressed</c>\
>$~~~~$*Refresh pals*
@ -144,7 +144,7 @@ wMapStatus == MAPSTATUS_HANDLE: <c>the remainder of the code goes at this level<
>>>>> wWalkingIntoEdgeWarp <= FALSE
>>>>> <c>Tile collision checks below consist on reading the current tile *wPlayerTile* and comparing it to a *COLL_* constant or a range of *COLL_* constants.</c>\
>>>>> <c>Tile permission checks below on reading the permissions of the tile that the player is walking into: *wTilePermissions* (applies only to *COLL_WALL*s) and *wWalkingTile* (*LAND_TILE*, *WATER_TILE*, or *WALL_TILE* for the tile in the walking direction; *WALL_TILE* permission is not the same as a *COLL_WALL* collision).</c>\
>>>>> <c>Tile permission checks below consist on reading the permissions of the tile that the player is walking into: *wTilePermissions* (applies only to *COLL_WALL*s) and *wWalkingTile* (*LAND_TILE*, *WATER_TILE*, or *WALL_TILE* for the tile in the walking direction; *WALL_TILE* permission is not the same as a *COLL_WALL* collision).</c>\
>>>>> wPlayerState == PLAYER_NORMAL or wPlayerState = PLAYER_BIKE:\
>>>>> $~~~~$*if on ice tile and wPlayerTurningDirection != 0: wCurInput <= current direction button*\
>>>>> $~~~~$*update wWalkingDirection, wFacingDirection, wWalkingX, wWalkingY, wWalkingTile, based on wCurInput direction*\

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

View File

@ -544,11 +544,17 @@ UpdateSprites::
ld a, [wVramState]
bit 0, a
ret z
farcall UpdateAllObjectsFrozen
farcall _UpdateSprites
ret
UpdateSecondarySprites::
ld a, [wVramState]
bit 0, a
ret z
farcall _UpdateSecondarySprites
ret
GetObjectStruct::
ld bc, OBJECT_LENGTH
ld hl, wObjectStructs

View File

@ -243,6 +243,7 @@ INCLUDE "engine/menus/level_selection_menu.asm"
SECTION "Board 1", ROMX
INCLUDE "engine/board/menu.asm"
INCLUDE "engine/board/spaces.asm"
SECTION "bank20", ROMX

View File

@ -2190,7 +2190,7 @@ wScriptFlags2::
; bit 1: coord events
; bit 2: warps and connections
; bit 4: wild encounters
; bit 5: unknown
; bit 5: space effects
db
wScriptMode:: db