Add support for more than 8 techniques (#34) (#28)

This commit is contained in:
xCrystal 2024-02-19 17:10:33 +01:00
parent 2f8ffccd54
commit 2f1608576a
10 changed files with 103 additions and 43 deletions

View File

@ -37,6 +37,6 @@ Compared to pokecrystal and the Pokemon Crystal ROM, the ROM built by pokecrysta
pokecrystal-board requires RGBDS 0.7.0 to build. It has two build targets: *crystal*, and *crystal_debug*. The former builds a ROM with the *_DEBUG* symbol undefined, and the latter builds a ROM with the *_DEBUG* symbol defined. *crystal_debug* is meant to include additional content and configurations to facilitate testing during development, while *crystal* builds the ROM meant to be hypothetically released to the public. Other than that, refer to the [install docs from pokecrystal](INSTALL.md) for detailed instructions on how to setup and build pokecrystal-board. pokecrystal-board requires RGBDS 0.7.0 to build. It has two build targets: *crystal*, and *crystal_debug*. The former builds a ROM with the *_DEBUG* symbol undefined, and the latter builds a ROM with the *_DEBUG* symbol defined. *crystal_debug* is meant to include additional content and configurations to facilitate testing during development, while *crystal* builds the ROM meant to be hypothetically released to the public. Other than that, refer to the [install docs from pokecrystal](INSTALL.md) for detailed instructions on how to setup and build pokecrystal-board.
If you have specific questions about the usage of pokecrystal-board or how to contribute to it, feel free to open an issue or to contact me on Discord. But please, do not do this for questions that are rather in the domain of pokecrystal. If you have specific questions about the usage of pokecrystal-board or how to contribute to it, or to report a bug, feel free to open an issue or to contact me on Discord. But please, do not do this for questions that are rather in the domain of pokecrystal.
If you are interested on developing on top of pokecrystal-board, [docs/usage/index.md](docs/usage/index.md) details the different features. For generic changes made in pokecrystal-board (adaptations, cleaning up, etc.) refer to issues #1, #2, #7, #8. You can also navigate issues tagged with a "Feature" label to see commits pertaining specific features. Additionally, a rough list of new RAM addresses can be found in [docs/develop/ram_addresses.md](docs/develop/ram_addresses.md). If you are interested on developing on top of pokecrystal-board, [docs/usage/index.md](docs/usage/index.md) details the different features. For generic changes made in pokecrystal-board (adaptations, cleaning up, etc.) refer to issues #1, #2, #7, #8. You can also navigate issues tagged with a "Feature" label to see commits pertaining specific features. Additionally, a rough list of new RAM addresses can be found in [docs/develop/ram_addresses.md](docs/develop/ram_addresses.md).

View File

@ -1,14 +1,19 @@
MACRO technique
const \1_B
DEF \1_F EQU \1_B % 8
DEF \1 EQU 1 << \1_F
ENDM
; technique constants ; technique constants
const_def const_def
const TECHNIQUE_CUT_F technique TECHNIQUE_CUT
const TECHNIQUE_FLASH_F technique TECHNIQUE_FLASH
const TECHNIQUE_SURF_F technique TECHNIQUE_SURF
const TECHNIQUE_ROCK_SMASH_F technique TECHNIQUE_ROCK_SMASH
const TECHNIQUE_WATERFALL_F technique TECHNIQUE_WATERFALL
technique TECHNIQUE_DUMMY_5
technique TECHNIQUE_DUMMY_6
technique TECHNIQUE_DUMMY_7
technique TECHNIQUE_DUMMY_8
technique TECHNIQUE_DUMMY_9
DEF NUM_TECHNIQUES EQU const_value DEF NUM_TECHNIQUES EQU const_value
DEF TECHNIQUE_CUT EQU 1 << TECHNIQUE_CUT_F
DEF TECHNIQUE_FLASH EQU 1 << TECHNIQUE_FLASH_F
DEF TECHNIQUE_SURF EQU 1 << TECHNIQUE_SURF_F
DEF TECHNIQUE_ROCK_SMASH EQU 1 << TECHNIQUE_ROCK_SMASH_F
DEF TECHNIQUE_WATERFALL EQU 1 << TECHNIQUE_WATERFALL_F

View File

@ -39,6 +39,6 @@ if DEF(_DEBUG)
; level_unlock_req LEVELS_CLEARED, DEBUGLEVEL_3, STAGE_1_F ; DEBUGLEVEL_4 ; level_unlock_req LEVELS_CLEARED, DEBUGLEVEL_3, STAGE_1_F ; DEBUGLEVEL_4
; level_unlock_req LEVELS_CLEARED, DEBUGLEVEL_4, STAGE_1_F ; DEBUGLEVEL_5 ; level_unlock_req LEVELS_CLEARED, DEBUGLEVEL_4, STAGE_1_F ; DEBUGLEVEL_5
level_unlock_req NUMBER_OF_LEVELS_CLEARED, 3 ; DEBUGLEVEL_4 level_unlock_req NUMBER_OF_LEVELS_CLEARED, 3 ; DEBUGLEVEL_4
level_unlock_req TECHNIQUES_CLEARED, TECHNIQUE_FLASH | TECHNIQUE_WATERFALL ; DEBUGLEVEL_5 level_unlock_req TECHNIQUES_CLEARED, TECHNIQUE_FLASH | TECHNIQUE_WATERFALL, 0 ; DEBUGLEVEL_5
endc endc
assert x == NUM_LEVELS assert x == NUM_LEVELS

View File

@ -19,7 +19,7 @@
- Addresses within *wPlayerData* ~ *wPlayerDataEnd*: preserved on save. Includes: - Addresses within *wPlayerData* ~ *wPlayerDataEnd*: preserved on save. Includes:
- **wUnlockedLevels**: flag array that tracks progression regarding which levels have been unlocked. - **wUnlockedLevels**: flag array that tracks progression regarding which levels have been unlocked.
- **wClearedLevelsStage<N>**: flag array that tracks progression regarding which levels have been cleared. Each level can have up to four clearable endings (N). - **wClearedLevelsStage\<N\>**: flag array that tracks progression regarding which levels have been cleared. Each level can have up to four stages (clearable endings).
- **wUnlockedTechniques**: flag array that tracks progression regarding which techniques have been unlocked. - **wUnlockedTechniques**: flag array that tracks progression regarding which techniques have been unlocked.
- **wCurLevel**: initialized in LevelSelectionMenu (where it is also used), and stays static during the level. - **wCurLevel**: initialized in LevelSelectionMenu (where it is also used), and stays static during the level.
- **wDefaultLevelSelectionMenuLandmark**: used to know in which landmark to place the player when entering level selection menu. - **wDefaultLevelSelectionMenuLandmark**: used to know in which landmark to place the player when entering level selection menu.
@ -28,7 +28,7 @@
- These addresses share memory region with string buffers from *wStringBuffer3* onwards. They are placed in memory in the following order. - These addresses share memory region with string buffers from *wStringBuffer3* onwards. They are placed in memory in the following order.
- **wTempSpaceStruct**: Temporary scope. Same structure as *wCurSpaceStruct* - **wTempSpaceStruct**: Temporary scope. Same structure as *wCurSpaceStruct*
- **wTempSpaceBranchStruct**: Temporary scope. The structure is four bytes for next space for each direction (R/L/U/D; -1 if unavailable direction) followed by four bytes for required techniques for each direction (R/L/U/D) - **wTempSpaceBranchStruct**: Temporary scope. The structure is four bytes for next space for each direction (R/L/U/D; -1 if unavailable direction) followed by at least four bytes (depending on *NUM_TECHNIQUES*) for required techniques for each direction (R/L/U/D)
- **wViewMapModeRange**, **wViewMapModeDisplacementY**, **wViewMapModeDisplacementX**: Temporary scope during a Vew Map mode session. - **wViewMapModeRange**, **wViewMapModeDisplacementY**, **wViewMapModeDisplacementX**: Temporary scope during a Vew Map mode session.
- **wBeforeViewMapYCoord**, **wBeforeViewMapXCoord**, **wBeforeViewMapMapGroup**, **wBeforeViewMapMapNumber**, **wBeforeViewMapDirection**: Temporary scope during a Vew Map mode session. Used to preserve player state before entering View Map mode. - **wBeforeViewMapYCoord**, **wBeforeViewMapXCoord**, **wBeforeViewMapMapGroup**, **wBeforeViewMapMapNumber**, **wBeforeViewMapDirection**: Temporary scope during a Vew Map mode session. Used to preserve player state before entering View Map mode.

View File

@ -79,7 +79,7 @@ In a branch space, the last two bytes of the *space* macro are repurposed as a p
endbranch endbranch
``` ```
Each *branchdir* entry includes: direction, next space id, techniques required. The order of entries is irrelevant, but do not put the same direction more than once in the same branch struct (all but the last entry using that direction will be ignored). Each *branchdir* entry includes: direction, next space id, required techniques. The order of entries is irrelevant, but do not put the same direction more than once in the same branch struct (all but the last entry using that direction will be ignored). The number of arguments occupied by required techniques in each *branchdir* entry is equal to the number of techniques you have defined divided by eight.
### End space ### End space

View File

@ -195,19 +195,24 @@ ArriveToBranchSpaceScript:
.DisableDirectionsRequiringLockedTechniques: .DisableDirectionsRequiringLockedTechniques:
; set to BRANCH_DIRECTION_UNAVAILABLE each next space byte of the branch struct ; 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. ; that has an unavailable direction due to required techniques not yet unlocked.
ld hl, wTempSpaceBranchStruct + NUM_DIRECTIONS for curdir, 0, NUM_DIRECTIONS
ld de, wTempSpaceBranchStruct ld e, (NUM_TECHNIQUES + 7) / 8
ld hl, wTempSpaceBranchStruct + NUM_DIRECTIONS + curdir * (NUM_TECHNIQUES + 7) / 8
ld bc, wUnlockedTechniques ld bc, wUnlockedTechniques
rept NUM_DIRECTIONS .loop\@
ld a, [bc] ld a, [bc]
and [hl] and [hl]
cp [hl] cp [hl]
jr z, .next\@ jr nz, .unavailable_next\@
ld a, BRANCH_DIRECTION_UNAVAILABLE dec e
ld [de], a jr z, .available_next\@
.next\@ inc bc
inc hl inc hl
inc de jr .loop\@
.unavailable_next\@
ld a, BRANCH_DIRECTION_UNAVAILABLE
ld [wTempSpaceBranchStruct + curdir], a
.available_next\@
endr endr
ret ret

View File

@ -163,18 +163,40 @@ endc
ENDM ENDM
MACRO branchdir MACRO branchdir
assert (_NARG - 2) == (NUM_TECHNIQUES + 7) / 8
DEF techniques_byte = 0
if !STRCMP("\1", "RIGHT") if !STRCMP("\1", "RIGHT")
DEF _NEXT_SPACE_RIGHT = \2 DEF _NEXT_SPACE_RIGHT = \2
DEF _TECHNIQUES_RIGHT = \3 DEF _TECHNIQUES_RIGHT = TRUE
rept _NARG - 2
DEF _TECHNIQUES_RIGHT_{d:techniques_byte} = \3
shift
DEF techniques_byte += 1
endr
elif !STRCMP("\1", "LEFT") elif !STRCMP("\1", "LEFT")
DEF _NEXT_SPACE_LEFT = \2 DEF _NEXT_SPACE_LEFT = \2
DEF _TECHNIQUES_LEFT = \3 DEF _TECHNIQUES_LEFT = TRUE
rept _NARG - 2
DEF _TECHNIQUES_LEFT_{d:techniques_byte} = \3
shift
DEF techniques_byte += 1
endr
elif !STRCMP("\1", "UP") elif !STRCMP("\1", "UP")
DEF _NEXT_SPACE_UP = \2 DEF _NEXT_SPACE_UP = \2
DEF _TECHNIQUES_UP = \3 DEF _TECHNIQUES_UP = TRUE
rept _NARG - 2
DEF _TECHNIQUES_UP_{d:techniques_byte} = \3
shift
DEF techniques_byte += 1
endr
elif !STRCMP("\1", "DOWN") elif !STRCMP("\1", "DOWN")
DEF _NEXT_SPACE_DOWN = \2 DEF _NEXT_SPACE_DOWN = \2
DEF _TECHNIQUES_DOWN = \3 DEF _TECHNIQUES_DOWN = TRUE
rept _NARG - 2
DEF _TECHNIQUES_DOWN_{d:techniques_byte} = \3
shift
DEF techniques_byte += 1
endr
endc endc
ENDM ENDM
@ -204,28 +226,56 @@ else
db -1 db -1
endc endc
if DEF(_TECHNIQUES_RIGHT) if DEF(_TECHNIQUES_RIGHT)
db {_TECHNIQUES_RIGHT} DEF techniques_byte = 0
rept (NUM_TECHNIQUES + 7) / 8
db {_TECHNIQUES_RIGHT_{d:techniques_byte}}
PURGE _TECHNIQUES_RIGHT_{d:techniques_byte}
DEF techniques_byte += 1
endr
PURGE _TECHNIQUES_RIGHT PURGE _TECHNIQUES_RIGHT
else else
rept (NUM_TECHNIQUES + 7) / 8
db 0 db 0
endr
endc endc
if DEF(_TECHNIQUES_LEFT) if DEF(_TECHNIQUES_LEFT)
db {_TECHNIQUES_LEFT} DEF techniques_byte = 0
rept (NUM_TECHNIQUES + 7) / 8
db {_TECHNIQUES_LEFT_{d:techniques_byte}}
PURGE _TECHNIQUES_LEFT_{d:techniques_byte}
DEF techniques_byte += 1
endr
PURGE _TECHNIQUES_LEFT PURGE _TECHNIQUES_LEFT
else else
rept (NUM_TECHNIQUES + 7) / 8
db 0 db 0
endr
endc endc
if DEF(_TECHNIQUES_UP) if DEF(_TECHNIQUES_UP)
db {_TECHNIQUES_UP} DEF techniques_byte = 0
rept (NUM_TECHNIQUES + 7) / 8
db {_TECHNIQUES_UP_{d:techniques_byte}}
PURGE _TECHNIQUES_UP_{d:techniques_byte}
DEF techniques_byte += 1
endr
PURGE _TECHNIQUES_UP PURGE _TECHNIQUES_UP
else else
rept (NUM_TECHNIQUES + 7) / 8
db 0 db 0
endr
endc endc
if DEF(_TECHNIQUES_DOWN) if DEF(_TECHNIQUES_DOWN)
db {_TECHNIQUES_DOWN} DEF techniques_byte = 0
rept (NUM_TECHNIQUES + 7) / 8
db {_TECHNIQUES_DOWN_{d:techniques_byte}}
PURGE _TECHNIQUES_DOWN_{d:techniques_byte}
DEF techniques_byte += 1
endr
PURGE _TECHNIQUES_DOWN PURGE _TECHNIQUES_DOWN
else else
rept (NUM_TECHNIQUES + 7) / 8
db 0 db 0
endr
endc endc
ENDM ENDM

View File

@ -54,6 +54,6 @@ DebugLevel2_Map1_MapSpaces:
space 0, 12, $0, GO_LEFT ; 15 space 0, 12, $0, GO_LEFT ; 15
.BS1: .BS1:
branchdir LEFT, 13, 0 branchdir LEFT, 13, 0, 0
branchdir UP, 3, 0 branchdir UP, 3, 0, 0
endbranch endbranch

View File

@ -118,11 +118,11 @@ DebugLevel5_Map1_MapSpaces:
space 16, 4, $0, 8 ; 43 space 16, 4, $0, 8 ; 43
.BS2: .BS2:
branchdir RIGHT, 3, 0 branchdir RIGHT, 3, 0, 0
branchdir UP, 35, 0 branchdir UP, 35, 0, 0
endbranch endbranch
.BS36: .BS36:
branchdir RIGHT, 37, 0 branchdir RIGHT, 37, 0, 0
branchdir UP, GO_UP, 0 branchdir UP, GO_UP, 0, 0
endbranch endbranch

View File

@ -1715,7 +1715,7 @@ wStringBuffer5:: ds STRING_BUFFER_LENGTH
NEXTU NEXTU
wTempSpaceStruct:: space_struct wTempSpace wTempSpaceStruct:: space_struct wTempSpace
wTempSpaceStructEnd:: wTempSpaceStructEnd::
wTempSpaceBranchStruct:: ds NUM_DIRECTIONS * 2 wTempSpaceBranchStruct:: ds NUM_DIRECTIONS * (1 + ((NUM_TECHNIQUES) + 7) / 8)
wTempSpaceBranchStructEnd:: wTempSpaceBranchStructEnd::
wViewMapModeRange:: db wViewMapModeRange:: db