From f796199bababd423d2f09dc9e18f41f6128294ae Mon Sep 17 00:00:00 2001 From: xCrystal Date: Tue, 5 Mar 2024 20:08:42 +0100 Subject: [PATCH] Adjust MAPSETUP_ENTERLEVEL (#4) and misc clean up --- README.md | 2 +- constants/engine_flags.asm | 2 -- constants/map_setup_constants.asm | 7 +++---- constants/wram_constants.asm | 1 - data/events/engine_flags.asm | 2 -- data/maps/setup_scripts.asm | 30 ---------------------------- data/player_names.asm | 2 -- docs/develop/ram_addresses.md | 19 +++++++++--------- engine/battle/core.asm | 3 --- engine/gfx/color.asm | 3 --- engine/gfx/player_gfx.asm | 11 ---------- engine/overworld/overworld.asm | 3 --- engine/overworld/player_object.asm | 3 --- engine/overworld/scripting.asm | 17 ---------------- engine/overworld/warp_connection.asm | 2 +- ram/wram.asm | 3 ++- 16 files changed, 17 insertions(+), 93 deletions(-) diff --git a/README.md b/README.md index 35668c6f0..0c296f622 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # pokecrystal-board -pokecrystal-board is a board game engine for the GBC based on [pokecrystal](https://github.com/pret/pokecrystal). +pokecrystal-board is a single-player RPG board game engine for the GBC based on [pokecrystal](https://github.com/pret/pokecrystal). In pokecrystal-board **you will find**: - Content with new built-in features diff --git a/constants/engine_flags.asm b/constants/engine_flags.asm index e1701946e..890eda787 100644 --- a/constants/engine_flags.asm +++ b/constants/engine_flags.asm @@ -110,8 +110,6 @@ endc ; wDailyPhoneTimeOfDayFlags ; const ENGINE_JACK_MONDAY_MORNING ; const ENGINE_HUEY_WEDNESDAY_NIGHT -; wPlayerSpriteSetupFlags - const ENGINE_KRIS_IN_CABLE_CLUB ; wSwarmFlags const ENGINE_DUNSPARCE_SWARM const ENGINE_YANMA_SWARM diff --git a/constants/map_setup_constants.asm b/constants/map_setup_constants.asm index 10a933820..ef779b48c 100644 --- a/constants/map_setup_constants.asm +++ b/constants/map_setup_constants.asm @@ -11,10 +11,9 @@ const MAPSETUP_LINKRETURN ; f8 const MAPSETUP_TRAIN ; f9 const MAPSETUP_SUBMENU ; fa - const MAPSETUP_BADWARP ; fb - const MAPSETUP_FLY ; fc - const MAPSETUP_ENTERLEVEL ; fd - const MAPSETUP_EXITVIEWMAP ; fe + const MAPSETUP_FLY ; fb + const MAPSETUP_ENTERLEVEL ; fc + const MAPSETUP_EXITVIEWMAP ; fd DEF NUM_MAPSETUP_SCRIPTS EQU const_value - $f1 ; callback types diff --git a/constants/wram_constants.asm b/constants/wram_constants.asm index 2e7eaaa03..d43b9670c 100644 --- a/constants/wram_constants.asm +++ b/constants/wram_constants.asm @@ -157,7 +157,6 @@ DEF DARKNESS_PALSET EQU $80 ; wPlayerSpriteSetupFlags:: DEF PLAYERSPRITESETUP_FACING_MASK EQU %11 -DEF PLAYERSPRITESETUP_FEMALE_TO_MALE_F EQU 2 DEF PLAYERSPRITESETUP_CUSTOM_FACING_F EQU 5 DEF PLAYERSPRITESETUP_SKIP_RELOAD_GFX_F EQU 6 DEF PLAYERSPRITESETUP_RESET_ACTION_F EQU 7 diff --git a/data/events/engine_flags.asm b/data/events/engine_flags.asm index f99fa5144..bbbb80e82 100644 --- a/data/events/engine_flags.asm +++ b/data/events/engine_flags.asm @@ -122,8 +122,6 @@ endc ; engine_flag wDailyPhoneTimeOfDayFlags, 0 ; jack ; engine_flag wDailyPhoneTimeOfDayFlags, 1 ; huey - engine_flag wPlayerSpriteSetupFlags, PLAYERSPRITESETUP_FEMALE_TO_MALE_F - engine_flag wSwarmFlags, SWARMFLAGS_DUNSPARCE_SWARM_F engine_flag wSwarmFlags, SWARMFLAGS_YANMA_SWARM_F diff --git a/data/maps/setup_scripts.asm b/data/maps/setup_scripts.asm index d83cfe719..7154e22b0 100644 --- a/data/maps/setup_scripts.asm +++ b/data/maps/setup_scripts.asm @@ -11,7 +11,6 @@ MapSetupScripts: dw MapSetupScript_LinkReturn dw MapSetupScript_Train dw MapSetupScript_Submenu - dw MapSetupScript_BadWarp dw MapSetupScript_Fly dw MapSetupScript_EnterLevel dw MapSetupScript_ExitViewMap @@ -43,7 +42,6 @@ MapSetupScript_EnterLevel: mapsetup SpawnInFacingDown mapsetup RefreshMapSprites mapsetup PlayMapMusicBike - mapsetup FadeInToMusic mapsetup FadeInFromWhite mapsetup ConstructAndEnableOverworldHUD mapsetup ActivateMapAnims @@ -85,34 +83,6 @@ MapSetupScript_Warp: mapsetup MapCallbackAtEndMapSetup db -1 ; end -MapSetupScript_BadWarp: - mapsetup BackupMapObjects - mapsetup EnterMapSpawnPoint - mapsetup LoadMapAttributes - mapsetup HandleNewMap - mapsetup SpawnPlayer - mapsetup RefreshPlayerCoords - mapsetup GetMapScreenCoords - mapsetup LoadBlockData - mapsetup LoadDisabledSpaces - mapsetup BufferScreen - mapsetup DisableLCD - mapsetup LoadMapGraphics - mapsetup LoadMapTimeOfDay - mapsetup FadeOutMapMusic - mapsetup EnableLCD - mapsetup LoadMapObjects - mapsetup LoadMapPalettes - mapsetup SpawnInFacingDown - mapsetup RefreshMapSprites - mapsetup FadeToMapMusic - mapsetup FadeInFromWhite - mapsetup ActivateMapAnims - mapsetup LoadWildMonData - mapsetup AnchorPointAfterWarp - mapsetup MapCallbackAtEndMapSetup - db -1 ; end - MapSetupScript_Connection: mapsetup SuspendMapAnims mapsetup BackupMapObjects diff --git a/data/player_names.asm b/data/player_names.asm index 0faadf1ab..71f9fba67 100644 --- a/data/player_names.asm +++ b/data/player_names.asm @@ -9,7 +9,6 @@ ChrisNameMenuHeader: db STATICMENU_CURSOR | STATICMENU_PLACE_TITLE | STATICMENU_DISABLE_B ; flags db 5 ; items db "NEW NAME@" -MalePlayerNameArray: db "CHRIS@" db "MAT@" db "ALLAN@" @@ -28,7 +27,6 @@ KrisNameMenuHeader: db STATICMENU_CURSOR | STATICMENU_PLACE_TITLE | STATICMENU_DISABLE_B ; flags db 5 ; items db "NEW NAME@" -FemalePlayerNameArray: db "KRIS@" db "AMANDA@" db "JUANA@" diff --git a/docs/develop/ram_addresses.md b/docs/develop/ram_addresses.md index e32e78864..92fb2e157 100755 --- a/docs/develop/ram_addresses.md +++ b/docs/develop/ram_addresses.md @@ -2,29 +2,30 @@ - **hCurBoardEvent**: holds a *BOARDEVENT_* value. -- **wTurnData** ~ **wTurnDataEnd**: not preserved on save, and cleared at the beginning of BoardMenuScript (i.e. on turn begin). It's part of *wMapStatus* ~ *wMapStatusEnd*, so it's also cleared by *StartMap*. Includes: +- **wTurnData** ~ **wTurnDataEnd**: turn-scoped, not preserved on save, and cleared at the beginning of BoardMenuScript (i.e. on turn begin). It's part of *wMapStatus* ~ *wMapStatusEnd*, so it's also cleared by *StartMap*. Includes: - **wDieRoll** - **wSpacesLeft** -- Addresses within *wCurMapData* ~ *wCurMapDataEnd*: preserved on save. Initialized when entering a level (in StartMap), and updated accordingly throughout the level. Includes: - - **wCurTurn** - - **wCurSpace** - - **wCurLevelCoins** - - **wCurLevelExp** +- Addresses within *wCurMapData* ~ *wCurMapDataEnd*: level-scoped or turn-scoped, preserved on save. Initialized when entering a level if required (in StartMap), and updated accordingly throughout the level. Includes: + - **wCurTurn**: initialized when entering a level (in StartMap) + - **wCurSpace**: initialized when entering a level (in StartMap) + - **wCurLevelCoins**: initialized when entering a level (in StartMap) + - **wCurLevelExp**: initialized when entering a level (in StartMap) - **wCurSpaceStruct**: - **wCurSpaceXCoord** - **wCurSpaceYCoord** - **wCurSpaceEffect** for non-branch spaces, or **wCurSpaceBranchStructPtr** (two bytes) for branch spaces - **wCurSpaceNextSpace** for non-branch spaces + - **wCurOverworldMiscPal** -- Addresses within *wPlayerData* ~ *wPlayerDataEnd*: preserved on save. Includes: +- Addresses within *wPlayerData* ~ *wPlayerDataEnd*: game-scoped (change between levels or on level start/end, but now within), preserved on save. Includes: - **wUnlockedLevels**: flag array that tracks progression regarding which levels have been unlocked. - **wClearedLevelsStage\**: 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. - **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. - - **wCurOverworldMiscPal** - **wLevelSelectionMenuEntryEventQueue**: which events have to be triggered the next time the player enters the level selection menu. + - **wLastUnlockedLevelsCount**, **wLastUnlockedLevels**: temporary list of unlocked levels during post-level screen - 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* @@ -44,7 +45,7 @@ - **wDisabledSpacesBackups**: preserved on save to **sDisabledSpacesBackups**. - **wMapObjectsBackups**: preserved on save to **sMapObjectsBackups**. -- **wLevelSelectionMenu\*** addresses, union under the *"Miscellaneous WRAM 1"* section. Temporary scope during level selection menu, except for *wLevelSelectionMenuEntryEventQueue*. +- **wLevelSelectionMenu\*** addresses, union under the *"Miscellaneous WRAM 1"* section. Temporary scope during level selection menu (not the case for *wLevelSelectionMenuEntryEventQueue*, which is in *wPlayerData* instead, as mentioned above). - Other WRAM 0 addresses (not preserved on save): - **wText2bpp** diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 04c4fdd8d..06ea09d69 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -8762,9 +8762,6 @@ GetTrainerBackpic: jr z, .Decompress ; What gender are we? - ld a, [wPlayerSpriteSetupFlags] - bit PLAYERSPRITESETUP_FEMALE_TO_MALE_F, a - jr nz, .Chris ld a, [wPlayerGender] bit PLAYERGENDER_FEMALE_F, a jr z, .Chris diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm index bc3de9ac2..2d303b992 100644 --- a/engine/gfx/color.asm +++ b/engine/gfx/color.asm @@ -503,9 +503,6 @@ GetEnemyFrontpicPalettePointer: GetPlayerOrMonPalettePointer: and a jp nz, GetMonNormalOrShinyPalettePointer - ld a, [wPlayerSpriteSetupFlags] - bit PLAYERSPRITESETUP_FEMALE_TO_MALE_F, a - jr nz, .male ld a, [wPlayerGender] and a jr z, .male diff --git a/engine/gfx/player_gfx.asm b/engine/gfx/player_gfx.asm index ca53a644c..be894c3dd 100644 --- a/engine/gfx/player_gfx.asm +++ b/engine/gfx/player_gfx.asm @@ -71,17 +71,6 @@ ShowPlayerNamingChoices: INCLUDE "data/player_names.asm" -GetPlayerNameArray: ; unreferenced - ld hl, wPlayerName - ld de, MalePlayerNameArray - ld a, [wPlayerGender] - bit PLAYERGENDER_FEMALE_F, a - jr z, .got_array - ld de, FemalePlayerNameArray -.got_array - call InitName - ret - GetPlayerIcon: ld de, ChrisSpriteGFX ld b, BANK(ChrisSpriteGFX) diff --git a/engine/overworld/overworld.asm b/engine/overworld/overworld.asm index bd1dbb4c5..ec7dfdee5 100644 --- a/engine/overworld/overworld.asm +++ b/engine/overworld/overworld.asm @@ -55,9 +55,6 @@ RefreshSprites:: GetPlayerSprite: ; Get Chris or Kris's sprite. ld hl, ChrisStateSprites - ld a, [wPlayerSpriteSetupFlags] - bit PLAYERSPRITESETUP_FEMALE_TO_MALE_F, a - jr nz, .go ld a, [wPlayerGender] bit PLAYERGENDER_FEMALE_F, a jr z, .go diff --git a/engine/overworld/player_object.asm b/engine/overworld/player_object.asm index 8a891e529..86f002de0 100644 --- a/engine/overworld/player_object.asm +++ b/engine/overworld/player_object.asm @@ -30,9 +30,6 @@ SpawnPlayer: ld hl, MAPOBJECT_PALETTE add hl, bc ln e, PAL_NPC_RED, OBJECTTYPE_SCRIPT - ld a, [wPlayerSpriteSetupFlags] - bit PLAYERSPRITESETUP_FEMALE_TO_MALE_F, a - jr nz, .ok ld a, [wPlayerGender] bit PLAYERGENDER_FEMALE_F, a jr z, .ok diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm index 67864847e..2a6aa2a56 100644 --- a/engine/overworld/scripting.asm +++ b/engine/overworld/scripting.asm @@ -2188,10 +2188,6 @@ Script_warpfacing: ; fallthrough Script_warp: -; This seems to be some sort of error handling case. - call GetScriptByte - and a - jr z, .not_ok ld [wMapGroup], a call GetScriptByte ld [wMapNumber], a @@ -2208,19 +2204,6 @@ Script_warp: call StopScript ret -.not_ok - call GetScriptByte - call GetScriptByte - call GetScriptByte - ld a, SPAWN_N_A - ld [wDefaultSpawnpoint], a - ld a, MAPSETUP_BADWARP - ldh [hMapEntryMethod], a - ld a, MAPSTATUS_ENTER - call LoadMapStatus - call StopScript - ret - Script_warpmod: call GetScriptByte ld [wBackupWarpNumber], a diff --git a/engine/overworld/warp_connection.asm b/engine/overworld/warp_connection.asm index 5fab1d552..443da6c79 100644 --- a/engine/overworld/warp_connection.asm +++ b/engine/overworld/warp_connection.asm @@ -305,7 +305,7 @@ RefreshMapSprites: call SafeUpdateSprites .skip ld a, [wPlayerSpriteSetupFlags] - and (1 << PLAYERSPRITESETUP_FEMALE_TO_MALE_F) | (1 << 3) | (1 << 4) + and (1 << 3) | (1 << 4) ld [wPlayerSpriteSetupFlags], a ret diff --git a/ram/wram.asm b/ram/wram.asm index 0944c90ff..61b4d1d5f 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -2545,7 +2545,6 @@ wKurtApricornQuantity:: db wCurLevel:: db wDefaultLevelSelectionMenuLandmark:: db -wCurOverworldMiscPal:: db wLevelSelectionMenuEntryEventQueue:: flag_array NUM_LSM_EVENTS ; list of unlocked levels during post-level screen @@ -2586,6 +2585,8 @@ wCurLevelExp:: ds 3 wCurSpaceStruct:: space_struct wCurSpace wCurSpaceStructEnd:: +wCurOverworldMiscPal:: db + wCurMapDataEnd::