mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-09-09 09:51:34 -07:00
Effects of branch space [Commit 3]: accounting for techniques (#28)
This commit is contained in:
parent
5362006c4d
commit
a8b5145236
8
constants/space_constants.asm
Executable file
8
constants/space_constants.asm
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
; metatile layout constants
|
||||||
|
DEF FIRST_SPACE_METATILE EQU $80
|
||||||
|
DEF FIRST_GREY_SPACE_METATILE EQU $e0
|
||||||
|
DEF UNIQUE_SPACE_METATILES_MASK EQU %11111
|
||||||
|
|
||||||
|
; Branch Space special direction values
|
||||||
|
DEF BRANCH_DIRECTION_INVALID EQU -1
|
||||||
|
DEF BRANCH_DIRECTION_UNAVAILABLE EQU -2
|
@ -68,8 +68,3 @@ DEF NUM_VARIABLE_SPACES_SETS EQU const_value
|
|||||||
; number of tiles of the tileset occupied by space tiles (see LoadTilesetGFX)
|
; number of tiles of the tileset occupied by space tiles (see LoadTilesetGFX)
|
||||||
DEF TILESET_FIXED_SPACES_NUM_TILES EQU $20
|
DEF TILESET_FIXED_SPACES_NUM_TILES EQU $20
|
||||||
DEF TILESET_VARIABLE_SPACES_NUM_TILES EQU $20
|
DEF TILESET_VARIABLE_SPACES_NUM_TILES EQU $20
|
||||||
|
|
||||||
; metatile layout constants
|
|
||||||
DEF FIRST_SPACE_METATILE EQU $80
|
|
||||||
DEF FIRST_GREY_SPACE_METATILE EQU $e0
|
|
||||||
DEF UNIQUE_SPACE_METATILES_MASK EQU %11111
|
|
||||||
|
@ -127,10 +127,24 @@ LandedInRegularSpace:
|
|||||||
|
|
||||||
BranchSpaceScript::
|
BranchSpaceScript::
|
||||||
scall .ArriveToBranchSpaceScript
|
scall .ArriveToBranchSpaceScript
|
||||||
|
.prompt_player
|
||||||
callasm .PromptPlayerToChooseDirection
|
callasm .PromptPlayerToChooseDirection
|
||||||
|
iffalse .print_technique_required
|
||||||
wait 200
|
wait 200
|
||||||
end
|
end
|
||||||
|
|
||||||
|
.print_technique_required
|
||||||
|
opentext
|
||||||
|
writetext .TechniqueRequiredText
|
||||||
|
waitbutton
|
||||||
|
closetext
|
||||||
|
sjump .prompt_player
|
||||||
|
|
||||||
|
.TechniqueRequiredText:
|
||||||
|
text "A new TECHNIQUE is"
|
||||||
|
line "required!"
|
||||||
|
done
|
||||||
|
|
||||||
.ArriveToBranchSpaceScript:
|
.ArriveToBranchSpaceScript:
|
||||||
playsound SFX_TWINKLE
|
playsound SFX_TWINKLE
|
||||||
wait 400
|
wait 400
|
||||||
@ -141,8 +155,11 @@ BranchSpaceScript::
|
|||||||
; load new space
|
; load new space
|
||||||
ld a, [wCurSpaceNextSpace]
|
ld a, [wCurSpaceNextSpace]
|
||||||
ld [wCurSpace], a
|
ld [wCurSpace], a
|
||||||
|
; unlike in other cases, wCurSpaceNextSpace will not yet
|
||||||
|
; contain the next space after calling LoadCurSpaceData.
|
||||||
|
; it will be defined after the player has chosen which direction to take.
|
||||||
call LoadCurSpaceData
|
call LoadCurSpaceData
|
||||||
; load its branch data
|
; load the space's branch data
|
||||||
call LoadTempSpaceBranchData
|
call LoadTempSpaceBranchData
|
||||||
call .DisableDirectionsRequiringLockedTechniques
|
call .DisableDirectionsRequiringLockedTechniques
|
||||||
; draw arrows for valid directions
|
; draw arrows for valid directions
|
||||||
@ -153,55 +170,86 @@ BranchSpaceScript::
|
|||||||
jp UpdateActiveSprites
|
jp UpdateActiveSprites
|
||||||
|
|
||||||
.DisableDirectionsRequiringLockedTechniques:
|
.DisableDirectionsRequiringLockedTechniques:
|
||||||
|
; set to BRANCH_DIRECTION_UNAVAILABLE each next space byte of the branch struct
|
||||||
|
; that has an unavailable direction due to required techniques not yet unlocked.
|
||||||
|
ld hl, wTempSpaceBranchStruct + NUM_DIRECTIONS
|
||||||
|
ld de, wTempSpaceBranchStruct
|
||||||
|
ld bc, wUnlockedTechniques
|
||||||
|
rept NUM_DIRECTIONS
|
||||||
|
ld a, [bc]
|
||||||
|
and [hl]
|
||||||
|
cp [hl]
|
||||||
|
jr z, .next\@
|
||||||
|
ld a, BRANCH_DIRECTION_UNAVAILABLE
|
||||||
|
ld [de], a
|
||||||
|
.next\@
|
||||||
|
inc hl
|
||||||
|
inc de
|
||||||
|
endr
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.PromptPlayerToChooseDirection:
|
.PromptPlayerToChooseDirection:
|
||||||
; compute available directions in b as joypad dpad flags
|
; sample a dpad press
|
||||||
ld hl, wTempSpaceBranchStruct
|
ld hl, wTempSpaceBranchStruct
|
||||||
ld b, 0
|
|
||||||
ld a, [hli]
|
|
||||||
cp -1
|
|
||||||
jr z, .not_right
|
|
||||||
set D_RIGHT_F, b
|
|
||||||
.not_right
|
|
||||||
ld a, [hli]
|
|
||||||
cp -1
|
|
||||||
jr z, .not_left
|
|
||||||
set D_LEFT_F, b
|
|
||||||
.not_left
|
|
||||||
ld a, [hli]
|
|
||||||
cp -1
|
|
||||||
jr z, .not_up
|
|
||||||
set D_UP_F, b
|
|
||||||
.not_up
|
|
||||||
ld a, [hli]
|
|
||||||
cp -1
|
|
||||||
jr z, .joypad_loop
|
|
||||||
set D_DOWN_F, b
|
|
||||||
|
|
||||||
; sample input of an available direction
|
|
||||||
.joypad_loop
|
|
||||||
call GetJoypad
|
call GetJoypad
|
||||||
ldh a, [hJoyPressed]
|
ldh a, [hJoyPressed]
|
||||||
and b
|
and D_PAD
|
||||||
jr z, .joypad_loop
|
jr z, .PromptPlayerToChooseDirection
|
||||||
|
|
||||||
; load the next space for the chosen direction
|
; determine the status (ok/invalid/unavailable) of the chosen direction
|
||||||
ld hl, wTempSpaceBranchStruct
|
|
||||||
bit D_RIGHT_F, a
|
bit D_RIGHT_F, a
|
||||||
jr nz, .ok
|
jr z, .not_right
|
||||||
|
ld a, [hl]
|
||||||
|
inc a ; cp BRANCH_DIRECTION_INVALID
|
||||||
|
jr z, .PromptPlayerToChooseDirection
|
||||||
|
inc a ; cp BRANCH_DIRECTION_UNAVAILABLE
|
||||||
|
jr z, .technique_required
|
||||||
|
jr .direction_chosen
|
||||||
|
.not_right
|
||||||
|
|
||||||
inc hl
|
inc hl
|
||||||
bit D_LEFT_F, a
|
bit D_LEFT_F, a
|
||||||
jr nz, .ok
|
jr z, .not_left
|
||||||
|
ld a, [hl]
|
||||||
|
inc a ; cp BRANCH_DIRECTION_INVALID
|
||||||
|
jr z, .PromptPlayerToChooseDirection
|
||||||
|
inc a ; cp BRANCH_DIRECTION_UNAVAILABLE
|
||||||
|
jr z, .technique_required
|
||||||
|
jr .direction_chosen
|
||||||
|
.not_left
|
||||||
|
|
||||||
inc hl
|
inc hl
|
||||||
bit D_UP_F, a
|
bit D_UP_F, a
|
||||||
jr nz, .ok
|
jr z, .not_up
|
||||||
|
ld a, [hl]
|
||||||
|
inc a ; cp BRANCH_DIRECTION_INVALID
|
||||||
|
jr z, .PromptPlayerToChooseDirection
|
||||||
|
inc a ; cp BRANCH_DIRECTION_UNAVAILABLE
|
||||||
|
jr z, .technique_required
|
||||||
|
jr .direction_chosen
|
||||||
|
.not_up
|
||||||
|
|
||||||
inc hl
|
inc hl
|
||||||
.ok
|
ld a, [hl]
|
||||||
|
inc a ; cp BRANCH_DIRECTION_INVALID
|
||||||
|
jr z, .PromptPlayerToChooseDirection
|
||||||
|
inc a ; cp BRANCH_DIRECTION_UNAVAILABLE
|
||||||
|
jr z, .technique_required
|
||||||
|
; fallthrough
|
||||||
|
|
||||||
|
.direction_chosen
|
||||||
|
; save the next space of the chosen direction to wCurSpaceNextSpace
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
ld [wCurSpaceNextSpace], a
|
ld [wCurSpaceNextSpace], a
|
||||||
ld hl, wDisplaySecondarySprites
|
ld hl, wDisplaySecondarySprites
|
||||||
res SECONDARYSPRITES_BRANCH_ARROWS_F, [hl]
|
res SECONDARYSPRITES_BRANCH_ARROWS_F, [hl]
|
||||||
|
ld a, TRUE
|
||||||
|
ldh [hScriptVar], a
|
||||||
|
jp PlayClickSFX
|
||||||
|
|
||||||
|
.technique_required
|
||||||
|
xor a ; FALSE
|
||||||
|
ldh [hScriptVar], a
|
||||||
jp PlayClickSFX
|
jp PlayClickSFX
|
||||||
|
|
||||||
UnionSpaceScript::
|
UnionSpaceScript::
|
||||||
|
@ -3212,9 +3212,15 @@ InitBranchArrowsSprites:
|
|||||||
ld c, NUM_DIRECTIONS
|
ld c, NUM_DIRECTIONS
|
||||||
.loop
|
.loop
|
||||||
ld a, [de]
|
ld a, [de]
|
||||||
cp -1 ;
|
cp BRANCH_DIRECTION_INVALID
|
||||||
jr z, .next1 ; skip this arrow if this direction is not available
|
jr z, .next1 ; skip this arrow if this direction is not valid
|
||||||
|
cp BRANCH_DIRECTION_UNAVAILABLE
|
||||||
|
gender_to_pal
|
||||||
|
ld b, a
|
||||||
|
jr nz, .available
|
||||||
|
ld b, PAL_OW_EMOTE ; draw grey arrow if this direction is unavailable
|
||||||
|
|
||||||
|
.available
|
||||||
; draw this arrow and advance hUsedSpriteIndex
|
; draw this arrow and advance hUsedSpriteIndex
|
||||||
; preserve loop variables d, e, c
|
; preserve loop variables d, e, c
|
||||||
push de
|
push de
|
||||||
@ -3222,11 +3228,13 @@ InitBranchArrowsSprites:
|
|||||||
ldh a, [hUsedSpriteIndex]
|
ldh a, [hUsedSpriteIndex]
|
||||||
ld e, a
|
ld e, a
|
||||||
ld d, HIGH(wShadowOAM)
|
ld d, HIGH(wShadowOAM)
|
||||||
; copy all bytes minus the attributes one
|
; copy all bytes minus the attributes one. the palette matches the
|
||||||
; the palette matches the player's color palette
|
; player's color palette, or is PAL_OW_EMOTE if direction is unavailable
|
||||||
|
push bc
|
||||||
ld bc, SPRITEOAMSTRUCT_LENGTH - 1
|
ld bc, SPRITEOAMSTRUCT_LENGTH - 1
|
||||||
call CopyBytes
|
call CopyBytes
|
||||||
gender_to_pal
|
pop bc
|
||||||
|
ld a, b ; palette
|
||||||
ld [de], a
|
ld [de], a
|
||||||
inc de
|
inc de
|
||||||
ld a, e
|
ld a, e
|
||||||
|
@ -60,6 +60,7 @@ INCLUDE "constants/radio_constants.asm"
|
|||||||
INCLUDE "constants/script_constants.asm"
|
INCLUDE "constants/script_constants.asm"
|
||||||
INCLUDE "constants/serial_constants.asm"
|
INCLUDE "constants/serial_constants.asm"
|
||||||
INCLUDE "constants/sfx_constants.asm"
|
INCLUDE "constants/sfx_constants.asm"
|
||||||
|
INCLUDE "constants/space_constants.asm"
|
||||||
INCLUDE "constants/sprite_anim_constants.asm"
|
INCLUDE "constants/sprite_anim_constants.asm"
|
||||||
INCLUDE "constants/sprite_constants.asm"
|
INCLUDE "constants/sprite_constants.asm"
|
||||||
INCLUDE "constants/sprite_data_constants.asm"
|
INCLUDE "constants/sprite_data_constants.asm"
|
||||||
|
@ -66,6 +66,6 @@ DebugLevel5_Map1_MapSpaces:
|
|||||||
space 16, 4, $0, 8 ; 43
|
space 16, 4, $0, 8 ; 43
|
||||||
|
|
||||||
.BS2:
|
.BS2:
|
||||||
branchdir RIGHT, 3, 0
|
branchdir RIGHT, 3, TECHNIQUE_SURF
|
||||||
branchdir UP, 35, 0
|
branchdir UP, 35, 0
|
||||||
endbranch
|
endbranch
|
||||||
|
Loading…
Reference in New Issue
Block a user