Player management [Commit 2] (#38)

This commit is contained in:
xCrystal 2024-03-09 16:40:21 +01:00
parent dbb340515f
commit ff35ce6d6b
29 changed files with 138 additions and 275 deletions

View File

@ -97,7 +97,7 @@ endc
const ENGINE_GOLDENROD_DEPT_STORE_SALE_IS_ON const ENGINE_GOLDENROD_DEPT_STORE_SALE_IS_ON
; wGameTimer ; wGameTimer
const ENGINE_62 const ENGINE_62
; wPlayerGender ; wPlayerCharacter
const ENGINE_PLAYER_IS_FEMALE const ENGINE_PLAYER_IS_FEMALE
; wCelebiEvent ; wCelebiEvent
const ENGINE_FOREST_IS_RESTLESS const ENGINE_FOREST_IS_RESTLESS

View File

@ -9,10 +9,11 @@ DEF NUM_PLAYER_CHARACTERS EQU const_value
; field ids in the Players table ; field ids in the Players table
rsreset rsreset
DEF PLAYERDATA_STATE_SPRITES rw DEF PLAYERDATA_STATE_SPRITES rw
DEF PLAYERDATA_NPC_PAL rb DEF PLAYERDATA_OW_PAL rb
DEF PLAYERDATA_DEFAULT_SPRITE rw
DEF PLAYERDATA_FISHING_SPRITE rw DEF PLAYERDATA_FISHING_SPRITE rw
DEF PLAYERDATA_FRONTPIC rw DEF PLAYERDATA_FRONTPIC rw
DEF PLAYERDATA_BACKPIC rw DEF PLAYERDATA_BACKPIC rw
DEF PLAYERDATA_PIC_PAL rw DEF PLAYERDATA_PIC_PAL rw
DEF PLAYERDATA_LENGTH EQU _RS DEF PLAYERDATA_LENGTH EQU _RS

View File

@ -27,6 +27,7 @@ DEF NUM_SPRITEDATA_FIELDS EQU _RS
; object_events set bit 3 so as not to use the sprite's default palette ; object_events set bit 3 so as not to use the sprite's default palette
; MapObjectPals indexes (see gfx/overworld/npc_sprites.pal) ; MapObjectPals indexes (see gfx/overworld/npc_sprites.pal)
const_def 1 << 3 const_def 1 << 3
DEF PAL_NPC EQU const_value
const PAL_NPC_RED ; 8 const PAL_NPC_RED ; 8
const PAL_NPC_BLUE ; 9 const PAL_NPC_BLUE ; 9
const PAL_NPC_GREEN ; a const PAL_NPC_GREEN ; a

View File

@ -161,7 +161,7 @@ DEF PLAYERSPRITESETUP_CUSTOM_FACING_F EQU 5
DEF PLAYERSPRITESETUP_SKIP_RELOAD_GFX_F EQU 6 DEF PLAYERSPRITESETUP_SKIP_RELOAD_GFX_F EQU 6
DEF PLAYERSPRITESETUP_RESET_ACTION_F EQU 7 DEF PLAYERSPRITESETUP_RESET_ACTION_F EQU 7
; wPlayerGender:: ; wPlayerCharacter::
DEF PLAYERGENDER_FEMALE_F EQU 0 DEF PLAYERGENDER_FEMALE_F EQU 0
; wMapStatus:: ; wMapStatus::

View File

@ -108,7 +108,7 @@ endc
engine_flag wGameTimer, 7 ; unused engine_flag wGameTimer, 7 ; unused
engine_flag wPlayerGender, PLAYERGENDER_FEMALE_F engine_flag wPlayerCharacter, PLAYERGENDER_FEMALE_F
engine_flag wCelebiEvent, CELEBIEVENT_FOREST_IS_RESTLESS_F engine_flag wCelebiEvent, CELEBIEVENT_FOREST_IS_RESTLESS_F

View File

@ -1,13 +1,14 @@
MACRO player MACRO player
dw \1 ; ptr to ow state sprites dw \1 ; ptr to ow state sprites
db \2 ; ow sprite palette db \2 ; ow sprite palette
dw \3 ; ptr to ow fishing gfx dw \3 ; ptr to ow default gfx
dw \4, \5 ; ptr to (uncompressed) frontpic, ptr to (compressed) backpic dw \4 ; ptr to ow fishing gfx
dw \6 ; ptr to pic pallete dw \5, \6 ; ptr to (uncompressed) frontpic, ptr to (compressed) backpic
dw \7 ; ptr to pic palette
ENDM ENDM
Players:: Players::
player ChrisStateSprites, PAL_NPC_RED, FishingGFX, ChrisPic, ChrisBackpic, PlayerPalette ; PLAYER_CHRIS ; for each argument number across different players, all arguments that are pointers must point to something in the same bank
player KrisStateSprites, PAL_NPC_BLUE, KrisFishingGFX, KrisPic, KrisBackpic, KrisPalette ; PLAYER_KRIS player ChrisStateSprites, PAL_OW_RED, ChrisSpriteGFX, FishingGFX, ChrisPic, ChrisBackpic, PlayerPalette ; PLAYER_CHRIS
player GreenStateSprites, PAL_NPC_GREEN, FishingGFX, ChrisPic, ChrisBackpic, PlayerPalette ; PLAYER_GREEN player KrisStateSprites, PAL_OW_BLUE, KrisSpriteGFX, KrisFishingGFX, KrisPic, KrisBackpic, KrisPalette ; PLAYER_KRIS
db $ff player GreenStateSprites, PAL_OW_GREEN, RivalSpriteGFX, FishingGFX, ChrisPic, ChrisBackpic, PlayerPalette ; PLAYER_GREEN

BIN
docs/usage/img/players.bmp Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
docs/usage/img/talker.bmp Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

View File

@ -28,6 +28,7 @@ This documentation covers a mix of topics that include aspects ranging from how
- [Map identifiers](#map-identifiers) - [Map identifiers](#map-identifiers)
- [Map environments](#map-environments) - [Map environments](#map-environments)
- [OAM management](#oam-management) - [OAM management](#oam-management)
- [Player characters](#player-characters)
- [Gameplay design aspects](#gameplay-design-aspects) - [Gameplay design aspects](#gameplay-design-aspects)
- [Game currency](#game-currency) - [Game currency](#game-currency)
- [Time counting](#time-counting) - [Time counting](#time-counting)
@ -37,7 +38,7 @@ This documentation covers a mix of topics that include aspects ranging from how
The level selection menu is essentially a world map that the player navigates to select a level to play. The player can move through landmarks that correspond to unlocked levels in the level selection menu. The level seleciton menu can have multiple map pages each with their own landmarks. When the player moves from a landmark in one page to a landmark in another page, the new page is loaded during the transition. The level selection menu is essentially a world map that the player navigates to select a level to play. The player can move through landmarks that correspond to unlocked levels in the level selection menu. The level seleciton menu can have multiple map pages each with their own landmarks. When the player moves from a landmark in one page to a landmark in another page, the new page is loaded during the transition.
[Level selection menu](img/level_selection_menu.bmp) ![Level selection menu](img/level_selection_menu.bmp)
The usual level:landmark relation is expected to be 1:1, but 1:n is also supported, for levels that may have alternative starting points. The usual level:landmark relation is expected to be 1:1, but 1:n is also supported, for levels that may have alternative starting points.
@ -65,7 +66,7 @@ In addition to what is covered in this section, you can find more low level stuf
The board menu is shown to the player at the beginning of each turn. In allows for several choices. The only ones that are specific to the pokecrystal-board engine are "roll die", "view map", and "exit level". The other three choices point to the party menu, bag menu, and pokegear, and are placeholders from pokecrystal. The board menu can be navigated horizontally. All menu options are accessed by selecting the corresponding icon of the menu, except for "view map" which is accessible via the Select button. All menu options except for "roll die" and "exit level" eventually return back to the board menu. The board menu is shown to the player at the beginning of each turn. In allows for several choices. The only ones that are specific to the pokecrystal-board engine are "roll die", "view map", and "exit level". The other three choices point to the party menu, bag menu, and pokegear, and are placeholders from pokecrystal. The board menu can be navigated horizontally. All menu options are accessed by selecting the corresponding icon of the menu, except for "view map" which is accessible via the Select button. All menu options except for "roll die" and "exit level" eventually return back to the board menu.
[Board menu](img/board_menu.bmp) ![Board menu](img/board_menu.bmp)
The implementation is located in [engine/board/menu.asm](engine/board/menu.asm). Icon tiles are drawn over the background of the textbox as if they were font characters. The current menu item is highlighted with a colored overlay using objects. This file includes also the animation logic for rolling a die when the "roll die" option is selected. These animations leverage the overworld sprite animation engine from pokecrystal. Finally, [gfx/board](gfx/board) contains GFX assets. The implementation is located in [engine/board/menu.asm](engine/board/menu.asm). Icon tiles are drawn over the background of the textbox as if they were font characters. The current menu item is highlighted with a colored overlay using objects. This file includes also the animation logic for rolling a die when the "roll die" option is selected. These animations leverage the overworld sprite animation engine from pokecrystal. Finally, [gfx/board](gfx/board) contains GFX assets.
@ -204,6 +205,8 @@ Unlike trainer events, talker events are meant to be used for NPCs that interact
The script pointer of a talker NPC points to an struct that uses the *talker* macro. Its arguments are flag, OPTIONAL/MANDATORY, TEXT/SCRIPT, 2-byte pointer to text or script. *OPTIONAL* means that the player will receive a prompt to skip this NPC's event. *SCRIPT* means that the 2-byte pointer points to an arbitrary script to be executed, while *TEXT* is a shortcut to merely make the NPC display text (it just executes a simple script enclosed in opentext/closetext). The script pointer of a talker NPC points to an struct that uses the *talker* macro. Its arguments are flag, OPTIONAL/MANDATORY, TEXT/SCRIPT, 2-byte pointer to text or script. *OPTIONAL* means that the player will receive a prompt to skip this NPC's event. *SCRIPT* means that the 2-byte pointer points to an arbitrary script to be executed, while *TEXT* is a shortcut to merely make the NPC display text (it just executes a simple script enclosed in opentext/closetext).
![Talker](img/talker.bmp)
Talkers can use turn-scoped flags that are cleared at the beginning of each turn, but like level-scoped trainer flags, this is just a predefined design choice. Talkers can use turn-scoped flags that are cleared at the beginning of each turn, but like level-scoped trainer flags, this is just a predefined design choice.
For example: For example:
@ -311,7 +314,7 @@ Note that the map name sign feature is not used in pokecrystal-board, and, in fa
This fading engine is used in the level selection menu and in the transition from overworld to post-level screen. When designing the timing your own fading functions, be aware of the latency introduced by the engine itself: each color takes around 3.2 scanlines to fade (in normal speed mode), so up to around 10-11 palettes can be faded in a whole frame. This fading engine is used in the level selection menu and in the transition from overworld to post-level screen. When designing the timing your own fading functions, be aware of the latency introduced by the engine itself: each color takes around 3.2 scanlines to fade (in normal speed mode), so up to around 10-11 palettes can be faded in a whole frame.
In addition to this engine, for manual fading you can automate the derivation of the RGB values of intermediate steps using the *rgbpals_\** macros available in [gfx/macros.asm](gfx/macros.asm), as done for example in [gfx/level_selection_menu/background_female.pal](gfx/level_selection_menu/background_female.pal). In addition to this engine, for manual fading you can automate the derivation of the RGB values of intermediate steps using the *rgbpals_\** macros available in [gfx/macros.asm](gfx/macros.asm), as done for example in [gfx/level_selection_menu/background.pal](gfx/level_selection_menu/background.pal).
# Internal design aspects # Internal design aspects
@ -371,6 +374,24 @@ To update just secondary sprites without processing NPC sprites, you can use *Up
The tiles reserved for secondary sprites in the overworld are 0x20 through 0x7e in VRAM bank 0. Tiles from 0x00 through 0x1f are reserved for NPC sprites. You may want to adjust the separation point according to your needs. [charmap.asm](charmap.asm) defines the placement of secondary sprite tiles for different use cases. The start tile of 0x20 is denoted by *SECONDARY_SPRITES_FIRST_TILE*. From there, it's a matter of managing which sprites may or may not overlap to place their tiles in VRAM in the way that most optimizes the available space. The tiles reserved for secondary sprites in the overworld are 0x20 through 0x7e in VRAM bank 0. Tiles from 0x00 through 0x1f are reserved for NPC sprites. You may want to adjust the separation point according to your needs. [charmap.asm](charmap.asm) defines the placement of secondary sprite tiles for different use cases. The start tile of 0x20 is denoted by *SECONDARY_SPRITES_FIRST_TILE*. From there, it's a matter of managing which sprites may or may not overlap to place their tiles in VRAM in the way that most optimizes the available space.
## Player characters
Player data has been centralized into the *Players* table from [data/players/players.asm](data/players/players.asm), including overworld sprites and their states, player pictures, and their palettes. Player constants are defined in [constants/player_constants.asm](constants/player_constants.asm). When you define pointers in a *player* entry in the *Players* table, you must ensure the equivalent argument in all entries points to something in the same bank.
For example, in:
```
Players::
player ChrisStateSprites, PAL_OW_RED, ChrisSpriteGFX, FishingGFX, ChrisPic, ChrisBackpic, PlayerPalette ; PLAYER_CHRIS
player KrisStateSprites, PAL_OW_BLUE, KrisSpriteGFX, KrisFishingGFX, KrisPic, KrisBackpic, KrisPalette ; PLAYER_KRIS
player GreenStateSprites, PAL_OW_GREEN, RivalSpriteGFX, FishingGFX, ChrisPic, ChrisBackpic, PlayerPalette ; PLAYER_GREEN
```
*ChrisSpriteGFX*, *KrisSpriteGFX*, and *RivalSpriteGFX* must point to graphics located in the same bank as each other, and so on.
Note that for many pokecrystal features that are considered placeholder or discontinued in pokecrystal-board (e.g. player selection/naming screen, Pokegear, pack, trainer card, Magnet Train, etc.), pokecrystal-board still uses legacy *PLAYERGENDER_FEMALE_F* flag. The concept of gender is otherwise deprecated.
![Player](img/player.bmp)
# Gameplay design aspects # Gameplay design aspects
This section covers miscellaneous gameplay design aspects not yet fully covered in other sections. This section covers miscellaneous gameplay design aspects not yet fully covered in other sections.

View File

@ -8761,7 +8761,7 @@ GetTrainerBackpic:
jr z, .Decompress jr z, .Decompress
; What gender are we? ; What gender are we?
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
ld e, PLAYERDATA_BACKPIC ld e, PLAYERDATA_BACKPIC
call GetPlayerField call GetPlayerField
.Decompress .Decompress

View File

@ -417,10 +417,10 @@ DebugRoom_PrintBattleSkip:
DebugRoomMenu_ChangeSex: DebugRoomMenu_ChangeSex:
ld a, BANK(sGameData) ld a, BANK(sGameData)
call OpenSRAM call OpenSRAM
ld a, [sGameData + (wPlayerGender - wGameData)] ld a, [sGameData + (wPlayerCharacter - wGameData)]
inc a inc a
and 1 and 1
ld [sGameData + (wPlayerGender - wGameData)], a ld [sGameData + (wPlayerCharacter - wGameData)], a
call CloseSRAM call CloseSRAM
ret ret
@ -430,7 +430,7 @@ DebugRoom_PrintGender:
call PlaceString call PlaceString
ld a, BANK(sGameData) ld a, BANK(sGameData)
call OpenSRAM call OpenSRAM
ld a, [sGameData + (wPlayerGender - wGameData)] ld a, [sGameData + (wPlayerCharacter - wGameData)]
call CloseSRAM call CloseSRAM
or a or a
ld a, "♂" ld a, "♂"

View File

@ -4,7 +4,7 @@ LoadFishingGFX:
ld a, $1 ld a, $1
ldh [rVBK], a ldh [rVBK], a
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
ld e, PLAYERDATA_FISHING_SPRITE ld e, PLAYERDATA_FISHING_SPRITE
call GetPlayerField call GetPlayerField
ld d, h ld d, h

View File

@ -131,7 +131,7 @@ MagnetTrain_LoadGFX_PlayMusic:
; Load the player sprite's standing frames ; Load the player sprite's standing frames
ldh a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wPlayerGender) ld a, BANK(wPlayerCharacter)
ldh [rSVBK], a ldh [rSVBK], a
farcall GetPlayerIcon farcall GetPlayerIcon
pop af pop af
@ -295,9 +295,9 @@ MagnetTrain_Jumptable:
ld b, SPRITE_ANIM_OBJ_MAGNET_TRAIN_RED ld b, SPRITE_ANIM_OBJ_MAGNET_TRAIN_RED
ldh a, [rSVBK] ldh a, [rSVBK]
push af push af
ld a, BANK(wPlayerGender) ld a, BANK(wPlayerCharacter)
ldh [rSVBK], a ldh [rSVBK], a
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
bit PLAYERGENDER_FEMALE_F, a bit PLAYERGENDER_FEMALE_F, a
jr z, .got_gender jr z, .got_gender
ld b, SPRITE_ANIM_OBJ_MAGNET_TRAIN_BLUE ld b, SPRITE_ANIM_OBJ_MAGNET_TRAIN_BLUE

View File

@ -162,7 +162,7 @@ InitPartyMenuBGPal0:
ret ret
_CGB_PokegearPals: _CGB_PokegearPals:
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
bit PLAYERGENDER_FEMALE_F, a bit PLAYERGENDER_FEMALE_F, a
jr z, .male jr z, .male
ld hl, FemalePokegearPals ld hl, FemalePokegearPals
@ -556,7 +556,11 @@ _CGB_LevelSelectionMenu:
ld bc, 8 palettes ld bc, 8 palettes
ld hl, MapObjectPals ld hl, MapObjectPals
call AddNTimes call AddNTimes
gender_to_pal ld a, [wPlayerCharacter]
ld e, PLAYERDATA_OW_PAL
push hl
call GetPlayerField
pop hl
ld bc, 1 palettes ld bc, 1 palettes
call AddNTimes call AddNTimes
ld de, wOBPals1 ld de, wOBPals1
@ -578,15 +582,8 @@ _CGB_LevelSelectionMenu:
ld a, BANK(wOBPals1) ld a, BANK(wOBPals1)
call FarCopyWRAM call FarCopyWRAM
; load daytime and gender-based background pals ; load daytime background pals
ld a, [wPlayerGender] ld hl, LevelSelectionMenuPals
bit PLAYERGENDER_FEMALE_F, a
jr z, .male
ld hl, LevelSelectionMenuFemalePals
jr .got_pals
.male
ld hl, LevelSelectionMenuMalePals
.got_pals
ld a, [wTimeOfDay] ld a, [wTimeOfDay]
maskbits NUM_DAYTIMES maskbits NUM_DAYTIMES
ld bc, 6 palettes ld bc, 6 palettes
@ -638,16 +635,8 @@ _CGB_LevelSelectionMenuToDChange:
jr .loop jr .loop
.match .match
ld e, [hl] ld a, [hl]
ld a, [wPlayerGender] ld hl, LevelSelectionMenuPals
bit PLAYERGENDER_FEMALE_F, a
jr z, .male
ld hl, LevelSelectionMenuFemalePals
jr .got_pals
.male
ld hl, LevelSelectionMenuMalePals
.got_pals
ld a, e
ld bc, 6 palettes ld bc, 6 palettes
call AddNTimes call AddNTimes
ld de, wBGPals1 ld de, wBGPals1
@ -737,7 +726,7 @@ _CGB_TrainerCard:
; fill screen with opposite-gender palette for the card border ; fill screen with opposite-gender palette for the card border
hlcoord 0, 0, wAttrmap hlcoord 0, 0, wAttrmap
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
and a and a
ld a, $1 ; kris ld a, $1 ; kris
jr z, .got_gender jr z, .got_gender
@ -747,7 +736,7 @@ _CGB_TrainerCard:
; fill trainer sprite area with same-gender palette ; fill trainer sprite area with same-gender palette
hlcoord 14, 1, wAttrmap hlcoord 14, 1, wAttrmap
lb bc, 7, 5 lb bc, 7, 5
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
and a and a
ld a, $0 ; chris ld a, $0 ; chris
jr z, .got_gender2 jr z, .got_gender2
@ -786,7 +775,7 @@ _CGB_TrainerCard:
ld a, $7 ; pryce ld a, $7 ; pryce
call FillBoxCGB call FillBoxCGB
; clair uses kris's palette ; clair uses kris's palette
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
and a and a
push af push af
jr z, .got_gender3 jr z, .got_gender3
@ -861,7 +850,7 @@ _CGB_PackPals:
cp BATTLETYPE_TUTORIAL cp BATTLETYPE_TUTORIAL
jr z, .tutorial_male jr z, .tutorial_male
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
bit PLAYERGENDER_FEMALE_F, a bit PLAYERGENDER_FEMALE_F, a
jr z, .tutorial_male jr z, .tutorial_male

View File

@ -503,7 +503,7 @@ GetEnemyFrontpicPalettePointer:
GetPlayerOrMonPalettePointer: GetPlayerOrMonPalettePointer:
and a and a
jp nz, GetMonNormalOrShinyPalettePointer jp nz, GetMonNormalOrShinyPalettePointer
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
ld e, PLAYERDATA_PIC_PAL ld e, PLAYERDATA_PIC_PAL
call GetPlayerField call GetPlayerField
ret ret
@ -862,14 +862,9 @@ INCLUDE "gfx/beta_poker/beta_poker.pal"
SlotMachinePals: SlotMachinePals:
INCLUDE "gfx/slots/slots.pal" INCLUDE "gfx/slots/slots.pal"
LevelSelectionMenuMalePals: LevelSelectionMenuPals:
table_width PAL_COLOR_SIZE * 4 * 6, LevelSelectionMenuMalePals table_width PAL_COLOR_SIZE * 4 * 6, LevelSelectionMenuPals
INCLUDE "gfx/level_selection_menu/background_male.pal" INCLUDE "gfx/level_selection_menu/background.pal"
assert_table_length (NUM_DAYTIMES + NUM_DAYTIMES * 2)
LevelSelectionMenuFemalePals:
table_width PAL_COLOR_SIZE * 4 * 6, LevelSelectionMenuFemalePals
INCLUDE "gfx/level_selection_menu/background_female.pal"
assert_table_length (NUM_DAYTIMES + NUM_DAYTIMES * 2) assert_table_length (NUM_DAYTIMES + NUM_DAYTIMES * 2)
LevelSelectionMenuStageTrophiesPals: LevelSelectionMenuStageTrophiesPals:

View File

@ -45,7 +45,7 @@ MovePlayerPic:
ShowPlayerNamingChoices: ShowPlayerNamingChoices:
ld hl, ChrisNameMenuHeader ld hl, ChrisNameMenuHeader
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
bit PLAYERGENDER_FEMALE_F, a bit PLAYERGENDER_FEMALE_F, a
jr z, .got_header jr z, .got_header
ld hl, KrisNameMenuHeader ld hl, KrisNameMenuHeader
@ -61,19 +61,17 @@ ShowPlayerNamingChoices:
INCLUDE "data/players/names.asm" INCLUDE "data/players/names.asm"
GetPlayerIcon: GetPlayerIcon:
ld de, ChrisSpriteGFX ld a, [wPlayerCharacter]
ld e, PLAYERDATA_DEFAULT_SPRITE
call GetPlayerField
ld d, h
ld e, l
ld b, BANK(ChrisSpriteGFX) ld b, BANK(ChrisSpriteGFX)
ld a, [wPlayerGender]
bit PLAYERGENDER_FEMALE_F, a
jr z, .got_gfx
ld de, KrisSpriteGFX
ld b, BANK(KrisSpriteGFX)
.got_gfx
ret ret
GetCardPic: GetCardPic:
ld hl, ChrisCardPic ld hl, ChrisCardPic
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
bit PLAYERGENDER_FEMALE_F, a bit PLAYERGENDER_FEMALE_F, a
jr z, .got_pic jr z, .got_pic
ld hl, KrisCardPic ld hl, KrisCardPic
@ -99,7 +97,7 @@ TrainerCardGFX:
INCBIN "gfx/trainer_card/trainer_card.2bpp" INCBIN "gfx/trainer_card/trainer_card.2bpp"
GetPlayerBackpic: GetPlayerBackpic:
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
ld e, PLAYERDATA_BACKPIC ld e, PLAYERDATA_BACKPIC
call GetPlayerField call GetPlayerField
ld de, vTiles2 tile $31 ld de, vTiles2 tile $31
@ -115,7 +113,7 @@ HOF_LoadTrainerFrontpic:
; Get class ; Get class
ld e, CHRIS ld e, CHRIS
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
bit PLAYERGENDER_FEMALE_F, a bit PLAYERGENDER_FEMALE_F, a
jr z, .got_class jr z, .got_class
ld e, KRIS ld e, KRIS
@ -125,7 +123,7 @@ HOF_LoadTrainerFrontpic:
; Load pic ; Load pic
ld de, ChrisPic ld de, ChrisPic
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
bit PLAYERGENDER_FEMALE_F, a bit PLAYERGENDER_FEMALE_F, a
jr z, .got_pic jr z, .got_pic
ld de, KrisPic ld de, KrisPic
@ -145,7 +143,7 @@ DrawIntroPlayerPic:
; Get class ; Get class
ld e, CHRIS ld e, CHRIS
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
bit PLAYERGENDER_FEMALE_F, a bit PLAYERGENDER_FEMALE_F, a
jr z, .got_class jr z, .got_class
ld e, KRIS ld e, KRIS
@ -155,7 +153,7 @@ DrawIntroPlayerPic:
; Load pic ; Load pic
ld de, ChrisPic ld de, ChrisPic
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
bit PLAYERGENDER_FEMALE_F, a bit PLAYERGENDER_FEMALE_F, a
jr z, .got_pic jr z, .got_pic
ld de, KrisPic ld de, KrisPic

View File

@ -1215,7 +1215,7 @@ DrawPackGFX:
ld a, [wBattleType] ld a, [wBattleType]
cp BATTLETYPE_TUTORIAL cp BATTLETYPE_TUTORIAL
jr z, .male_dude jr z, .male_dude
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
bit PLAYERGENDER_FEMALE_F, a bit PLAYERGENDER_FEMALE_F, a
jr nz, .female jr nz, .female
.male_dude .male_dude

View File

@ -13,7 +13,7 @@ InitGender:
call CloseWindow call CloseWindow
ld a, [wMenuCursorY] ld a, [wMenuCursorY]
dec a dec a
ld [wPlayerGender], a ld [wPlayerCharacter], a
ld c, 10 ld c, 10
call DelayFrames call DelayFrames
ret ret

View File

@ -527,7 +527,7 @@ NamePlayer:
ld hl, wPlayerName ld hl, wPlayerName
ld de, .Chris ld de, .Chris
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
bit PLAYERGENDER_FEMALE_F, a bit PLAYERGENDER_FEMALE_F, a
jr z, .Male jr z, .Male
ld de, .Kris ld de, .Kris
@ -682,13 +682,15 @@ Intro_PlacePlayerSprite:
inc de inc de
ld [hli], a ; tile id ld [hli], a ; tile id
ld b, PAL_OW_RED ld a, [wPlayerCharacter]
ld a, [wPlayerGender] ld e, PLAYERDATA_OW_PAL
bit PLAYERGENDER_FEMALE_F, a push hl
jr z, .male push de
ld b, PAL_OW_BLUE push bc
.male call GetPlayerField
ld a, b pop bc
pop de
pop hl
ld [hli], a ; attributes ld [hli], a ; attributes
dec c dec c

View File

@ -3233,12 +3233,12 @@ InitBranchArrowsSprites:
cp BRANCH_DIRECTION_INVALID cp BRANCH_DIRECTION_INVALID
jr z, .next1 ; skip this arrow if this direction is not valid jr z, .next1 ; skip this arrow if this direction is not valid
cp BRANCH_DIRECTION_UNAVAILABLE cp BRANCH_DIRECTION_UNAVAILABLE
gender_to_pal
ld b, a
jr nz, .available
ld b, PAL_OW_GREY ; draw grey arrow if this direction is unavailable ld b, PAL_OW_GREY ; draw grey arrow if this direction is unavailable
jr z, .got_pal
call GetSecondarySpritesPal
ld b, a
.available .got_pal
; 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
@ -3281,7 +3281,7 @@ InitBranchArrowsSprites:
; the palette byte overrides that data as it matches the player's color palette. ; the palette byte overrides that data as it matches the player's color palette.
ld e, a ld e, a
ld d, HIGH(wShadowOAM) ld d, HIGH(wShadowOAM)
gender_to_pal call GetSecondarySpritesPal
ld b, a ld b, a
ld c, 8 ; number of objects ld c, 8 ; number of objects
ld hl, BranchLegendOAM ld hl, BranchLegendOAM
@ -3322,7 +3322,7 @@ InitViewMapModeSprites:
ld a, [de] ld a, [de]
cp $ff cp $ff
jr z, .next1 ; skip this arrow if this direction is not valid jr z, .next1 ; skip this arrow if this direction is not valid
gender_to_pal call GetSecondarySpritesPal
ld b, a ld b, a
; draw this arrow and advance hUsedSpriteIndex ; draw this arrow and advance hUsedSpriteIndex
; preserve loop variables d, e, c ; preserve loop variables d, e, c
@ -3366,7 +3366,7 @@ InitViewMapModeSprites:
; the palette byte overrides that data as it matches the player's color palette. ; the palette byte overrides that data as it matches the player's color palette.
ld e, a ld e, a
ld d, HIGH(wShadowOAM) ld d, HIGH(wShadowOAM)
gender_to_pal call GetSecondarySpritesPal
ld b, a ld b, a
ld c, 8 ; number of objects ld c, 8 ; number of objects
ld hl, ViewMapModeLegendOAM ld hl, ViewMapModeLegendOAM
@ -3401,7 +3401,7 @@ InitTalkerEventSprites:
; the palette byte overrides that data as it matches the player's color palette. ; the palette byte overrides that data as it matches the player's color palette.
ld e, a ld e, a
ld d, HIGH(wShadowOAM) ld d, HIGH(wShadowOAM)
gender_to_pal call GetSecondarySpritesPal
ld b, a ld b, a
ld c, 8 ; number of objects ld c, 8 ; number of objects
ld hl, TalkerEventLegendOAM ld hl, TalkerEventLegendOAM
@ -3495,4 +3495,16 @@ InitGainOrLoseCoinsSprites:
pop af pop af
ret ret
GetSecondarySpritesPal:
push hl
push de
push bc
ld a, [wPlayerCharacter]
ld e, PLAYERDATA_OW_PAL
call GetPlayerField
pop bc
pop de
pop hl
ret
INCLUDE "data/sprites/secondary_sprites.asm" INCLUDE "data/sprites/secondary_sprites.asm"

View File

@ -54,7 +54,7 @@ RefreshSprites::
DeterminePlayerSprite: DeterminePlayerSprite:
; Return player's sprite in c and a. ; Return player's sprite in c and a.
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
ld e, PLAYERDATA_STATE_SPRITES ld e, PLAYERDATA_STATE_SPRITES
call GetPlayerField call GetPlayerField
ld a, [wPlayerState] ld a, [wPlayerState]

View File

@ -29,14 +29,15 @@ SpawnPlayer:
call GetMapObject call GetMapObject
ld hl, MAPOBJECT_PALETTE ld hl, MAPOBJECT_PALETTE
add hl, bc add hl, bc
ln e, PAL_NPC_RED, OBJECTTYPE_SCRIPT push hl
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
bit PLAYERGENDER_FEMALE_F, a ld e, PLAYERDATA_OW_PAL
jr z, .ok call GetPlayerField
ln e, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT add PAL_NPC ; convert from PAL_OW to PAL_NPC
swap a
.ok or OBJECTTYPE_SCRIPT
ld [hl], e pop hl
ld [hl], a
ld a, PLAYER_OBJECT ld a, PLAYER_OBJECT
ldh [hMapObjectIndex], a ldh [hMapObjectIndex], a
ld bc, wMapObjects ld bc, wMapObjects
@ -945,9 +946,10 @@ MockPlayerObject::
call CopyBytes call CopyBytes
; adjust palette number ; adjust palette number
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
ld e, PLAYERDATA_NPC_PAL ld e, PLAYERDATA_OW_PAL
call GetPlayerField call GetPlayerField
add PAL_NPC ; convert from PAL_OW to PAL_NPC
swap a swap a
or OBJECTTYPE_SCRIPT or OBJECTTYPE_SCRIPT
ld [wMapObject{d:LAST_OBJECT}Palette], a ; also wMapObject{d:LAST_OBJECT}Type ld [wMapObject{d:LAST_OBJECT}Palette], a ; also wMapObject{d:LAST_OBJECT}Type

View File

@ -561,7 +561,7 @@ PokegearMap_InitPlayerIcon:
push af push af
depixel 0, 0 depixel 0, 0
ld b, SPRITE_ANIM_OBJ_RED_WALK ld b, SPRITE_ANIM_OBJ_RED_WALK
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
bit PLAYERGENDER_FEMALE_F, a bit PLAYERGENDER_FEMALE_F, a
jr z, .got_gender jr z, .got_gender
ld b, SPRITE_ANIM_OBJ_BLUE_WALK ld b, SPRITE_ANIM_OBJ_BLUE_WALK
@ -2283,7 +2283,7 @@ Pokedex_GetArea:
inc de inc de
push bc push bc
ld c, PAL_OW_RED ld c, PAL_OW_RED
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
bit PLAYERGENDER_FEMALE_F, a bit PLAYERGENDER_FEMALE_F, a
jr z, .male jr z, .male
inc c ; PAL_OW_BLUE inc c ; PAL_OW_BLUE
@ -2459,7 +2459,7 @@ TownMapPlayerIcon:
; Animation/palette ; Animation/palette
depixel 0, 0 depixel 0, 0
ld b, SPRITE_ANIM_OBJ_RED_WALK ; Male ld b, SPRITE_ANIM_OBJ_RED_WALK ; Male
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
bit PLAYERGENDER_FEMALE_F, a bit PLAYERGENDER_FEMALE_F, a
jr z, .got_gender jr z, .got_gender
ld b, SPRITE_ANIM_OBJ_BLUE_WALK ; Female ld b, SPRITE_ANIM_OBJ_BLUE_WALK ; Female

View File

@ -177,7 +177,7 @@ SetBoxmonOrEggmonCaughtData:
ld c, a ld c, a
call GetWorldMapLocation call GetWorldMapLocation
ld b, a ld b, a
ld a, [wPlayerGender] ld a, [wPlayerCharacter]
rrca ; shift bit 0 (PLAYERGENDER_FEMALE_F) to bit 7 (CAUGHT_GENDER_MASK) rrca ; shift bit 0 (PLAYERGENDER_FEMALE_F) to bit 7 (CAUGHT_GENDER_MASK)
or b or b
ld [hl], a ld [hl], a

View File

@ -17,7 +17,7 @@
RGB 07, 31, 03 RGB 07, 31, 03
RGB 19, 11, 00 RGB 19, 11, 00
RGB 00, 00, 00 RGB 00, 00, 00
; city (boy) ; city
RGB 28, 31, 20 RGB 28, 31, 20
RGB 31, 15, 00 RGB 31, 15, 00
RGB 15, 07, 00 RGB 15, 07, 00
@ -54,7 +54,7 @@
RGB 00, 31, 00 RGB 00, 31, 00
RGB 15, 07, 00 RGB 15, 07, 00
RGB 00, 00, 00 RGB 00, 00, 00
; city (boy) ; city
RGB 28, 31, 20 RGB 28, 31, 20
RGB 31, 15, 00 RGB 31, 15, 00
RGB 15, 07, 00 RGB 15, 07, 00
@ -91,7 +91,7 @@
RGB 00, 15, 00 RGB 00, 15, 00
RGB 09, 05, 00 RGB 09, 05, 00
RGB 00, 00, 00 RGB 00, 00, 00
; city (boy) ; city
RGB 28, 31, 20 RGB 28, 31, 20
RGB 31, 15, 00 RGB 31, 15, 00
RGB 15, 07, 00 RGB 15, 07, 00
@ -128,7 +128,7 @@
RGB 04, 22, 00 RGB 04, 22, 00
RGB 13, 05, 00 RGB 13, 05, 00
RGB 00, 00, 00 RGB 00, 00, 00
; city (boy) ; city
RGB 28, 31, 20 RGB 28, 31, 20
RGB 31, 15, 00 RGB 31, 15, 00
RGB 15, 07, 00 RGB 15, 07, 00

View File

@ -1,152 +0,0 @@
; morn
rgbpals_fade_src "lsm_f_morn"
; border
RGB 28, 31, 20
RGB 21, 21, 21
RGB 13, 13, 13
RGB 00, 00, 00
; earth
RGB 28, 31, 20
RGB 07, 31, 03
RGB 05, 05, 31
RGB 00, 00, 00
; mountain
RGB 28, 31, 20
RGB 07, 31, 03
RGB 19, 11, 00
RGB 00, 00, 00
; city (girl)
RGB 28, 31, 20
RGB 10, 18, 31
RGB 13, 06, 31
RGB 00, 00, 00
; point of interest
RGB 28, 31, 20
RGB 07, 31, 03
RGB 05, 05, 31
RGB 31, 00, 00
; mountain point of interest
RGB 28, 31, 20
RGB 07, 31, 03
RGB 19, 11, 00
RGB 31, 00, 00
rgbpals_fade_src_end
; day (original)
rgbpals_fade_src "lsm_f_day"
; border
RGB 28, 31, 20
RGB 21, 21, 21
RGB 13, 13, 13
RGB 00, 00, 00
; earth
RGB 28, 31, 20
RGB 00, 31, 00
RGB 00, 00, 31
RGB 00, 00, 00
; mountain
RGB 28, 31, 20
RGB 00, 31, 00
RGB 15, 07, 00
RGB 00, 00, 00
; city (girl)
RGB 28, 31, 20
RGB 10, 18, 31
RGB 13, 06, 31
RGB 00, 00, 00
; point of interest
RGB 28, 31, 20
RGB 00, 31, 00
RGB 00, 00, 31
RGB 31, 00, 00
; mountain point of interest
RGB 28, 31, 20
RGB 00, 31, 00
RGB 15, 07, 00
RGB 31, 00, 00
rgbpals_fade_src_end
; nite
rgbpals_fade_src "lsm_f_nite"
; border
RGB 28, 31, 20
RGB 21, 21, 21
RGB 13, 13, 13
RGB 00, 00, 00
; earth
RGB 28, 31, 20
RGB 00, 15, 00
RGB 00, 00, 15
RGB 00, 00, 00
; mountain
RGB 28, 31, 20
RGB 00, 15, 00
RGB 09, 05, 00
RGB 00, 00, 00
; city (girl)
RGB 28, 31, 20
RGB 10, 18, 31
RGB 13, 06, 31
RGB 00, 00, 00
; point of interest
RGB 28, 31, 20
RGB 00, 15, 00
RGB 00, 00, 15
RGB 31, 00, 00
; mountain point of interest
RGB 28, 31, 20
RGB 00, 15, 00
RGB 09, 05, 00
RGB 31, 00, 00
rgbpals_fade_src_end
; eve
rgbpals_fade_src "lsm_f_eve"
; border
RGB 28, 31, 20
RGB 21, 21, 21
RGB 13, 13, 13
RGB 00, 00, 00
; earth
RGB 28, 31, 20
RGB 04, 22, 00
RGB 04, 00, 22
RGB 00, 00, 00
; mountain
RGB 28, 31, 20
RGB 04, 22, 00
RGB 13, 05, 00
RGB 00, 00, 00
; city (girl)
RGB 28, 31, 20
RGB 10, 18, 31
RGB 13, 06, 31
RGB 00, 00, 00
; point of interest
RGB 28, 31, 20
RGB 04, 22, 00
RGB 04, 00, 22
RGB 31, 00, 00
; mountain point of interest
RGB 28, 31, 20
RGB 04, 22, 00
RGB 13, 05, 00
RGB 31, 00, 00
rgbpals_fade_src_end
rgbpals_fade_apply "lsm_f_morn", "lsm_f_day", 2
rgbpals_fade_apply "lsm_f_day", "lsm_f_eve", 2
rgbpals_fade_apply "lsm_f_eve", "lsm_f_nite", 2
rgbpals_fade_apply "lsm_f_nite", "lsm_f_morn", 2

View File

@ -2,6 +2,8 @@ SECTION "Sprites 1", ROMX
ChrisSpriteGFX:: INCBIN "gfx/sprites/chris.2bpp" ChrisSpriteGFX:: INCBIN "gfx/sprites/chris.2bpp"
ChrisBikeSpriteGFX:: INCBIN "gfx/sprites/chris_bike.2bpp" ChrisBikeSpriteGFX:: INCBIN "gfx/sprites/chris_bike.2bpp"
KrisSpriteGFX:: INCBIN "gfx/sprites/kris.2bpp"
KrisBikeSpriteGFX:: INCBIN "gfx/sprites/kris_bike.2bpp"
GameboyKidSpriteGFX:: INCBIN "gfx/sprites/gameboy_kid.2bpp" GameboyKidSpriteGFX:: INCBIN "gfx/sprites/gameboy_kid.2bpp"
RivalSpriteGFX:: INCBIN "gfx/sprites/rival.2bpp" RivalSpriteGFX:: INCBIN "gfx/sprites/rival.2bpp"
OakSpriteGFX:: INCBIN "gfx/sprites/oak.2bpp" OakSpriteGFX:: INCBIN "gfx/sprites/oak.2bpp"
@ -42,12 +44,12 @@ YoungsterSpriteGFX:: INCBIN "gfx/sprites/youngster.2bpp"
LassSpriteGFX:: INCBIN "gfx/sprites/lass.2bpp" LassSpriteGFX:: INCBIN "gfx/sprites/lass.2bpp"
TeacherSpriteGFX:: INCBIN "gfx/sprites/teacher.2bpp" TeacherSpriteGFX:: INCBIN "gfx/sprites/teacher.2bpp"
BeautySpriteGFX:: INCBIN "gfx/sprites/beauty.2bpp" BeautySpriteGFX:: INCBIN "gfx/sprites/beauty.2bpp"
SuperNerdSpriteGFX:: INCBIN "gfx/sprites/super_nerd.2bpp"
RockerSpriteGFX:: INCBIN "gfx/sprites/rocker.2bpp"
SECTION "Sprites 2", ROMX SECTION "Sprites 2", ROMX
SuperNerdSpriteGFX:: INCBIN "gfx/sprites/super_nerd.2bpp"
RockerSpriteGFX:: INCBIN "gfx/sprites/rocker.2bpp"
PokefanMSpriteGFX:: INCBIN "gfx/sprites/pokefan_m.2bpp" PokefanMSpriteGFX:: INCBIN "gfx/sprites/pokefan_m.2bpp"
PokefanFSpriteGFX:: INCBIN "gfx/sprites/pokefan_f.2bpp" PokefanFSpriteGFX:: INCBIN "gfx/sprites/pokefan_f.2bpp"
GrampsSpriteGFX:: INCBIN "gfx/sprites/gramps.2bpp" GrampsSpriteGFX:: INCBIN "gfx/sprites/gramps.2bpp"
@ -99,8 +101,6 @@ FamicomSpriteGFX:: INCBIN "gfx/sprites/famicom.2bpp"
FruitTreeSpriteGFX:: INCBIN "gfx/sprites/fruit_tree.2bpp" FruitTreeSpriteGFX:: INCBIN "gfx/sprites/fruit_tree.2bpp"
GoldTrophySpriteGFX:: INCBIN "gfx/sprites/gold_trophy.2bpp" GoldTrophySpriteGFX:: INCBIN "gfx/sprites/gold_trophy.2bpp"
SilverTrophySpriteGFX:: INCBIN "gfx/sprites/silver_trophy.2bpp" SilverTrophySpriteGFX:: INCBIN "gfx/sprites/silver_trophy.2bpp"
KrisSpriteGFX:: INCBIN "gfx/sprites/kris.2bpp"
KrisBikeSpriteGFX:: INCBIN "gfx/sprites/kris_bike.2bpp"
KurtOutsideSpriteGFX:: INCBIN "gfx/sprites/kurt_outside.2bpp" KurtOutsideSpriteGFX:: INCBIN "gfx/sprites/kurt_outside.2bpp"
SuicuneSpriteGFX:: INCBIN "gfx/sprites/suicune.2bpp" SuicuneSpriteGFX:: INCBIN "gfx/sprites/suicune.2bpp"
EnteiSpriteGFX:: INCBIN "gfx/sprites/entei.2bpp" EnteiSpriteGFX:: INCBIN "gfx/sprites/entei.2bpp"

View File

@ -115,10 +115,3 @@ if _NARG == 0
sine_table 32 sine_table 32
endc endc
ENDM ENDM
; Abstractions
MACRO gender_to_pal
; preserve all registers but a
ld a, [wPlayerGender]
ENDM

View File

@ -2317,7 +2317,7 @@ wRivalName:: ds NAME_LENGTH
wRedsName:: ds NAME_LENGTH wRedsName:: ds NAME_LENGTH
wGreensName:: ds NAME_LENGTH wGreensName:: ds NAME_LENGTH
wPlayerGender:: wPlayerCharacter::
; bit 0: ; bit 0:
; 0 male ; 0 male
; 1 female ; 1 female