diff --git a/constants/player_constants.asm b/constants/player_constants.asm new file mode 100755 index 000000000..f666d458b --- /dev/null +++ b/constants/player_constants.asm @@ -0,0 +1,18 @@ +; see GetPlayerField (home/player.asm) and Players (data/players/players.asm) + +; player characters + const_def + const PLAYER_CHRIS + const PLAYER_KRIS + const PLAYER_GREEN +DEF NUM_PLAYER_CHARACTERS EQU const_value + +; field ids in the Players table +rsreset +DEF PLAYERDATA_STATE_SPRITES rw +DEF PLAYERDATA_NPC_PAL rb +DEF PLAYERDATA_FISHING_SPRITE rw +DEF PLAYERDATA_FRONTPIC rw +DEF PLAYERDATA_BACKPIC rw +DEF PLAYERDATA_PIC_PAL rw +DEF PLAYERDATA_LENGTH EQU _RS diff --git a/data/player_names.asm b/data/players/names.asm old mode 100644 new mode 100755 similarity index 100% rename from data/player_names.asm rename to data/players/names.asm diff --git a/data/players/players.asm b/data/players/players.asm new file mode 100755 index 000000000..34bad4fee --- /dev/null +++ b/data/players/players.asm @@ -0,0 +1,13 @@ +MACRO player + dw \1 ; ptr to ow state sprites + db \2 ; ow sprite palette + dw \3 ; ptr to ow fishing gfx + dw \4, \5 ; ptr to (uncompressed) frontpic, ptr to (compressed) backpic + dw \6 ; ptr to pic pallete +ENDM + +Players:: + player ChrisStateSprites, PAL_NPC_RED, FishingGFX, ChrisPic, ChrisBackpic, PlayerPalette ; PLAYER_CHRIS + player KrisStateSprites, PAL_NPC_BLUE, KrisFishingGFX, KrisPic, KrisBackpic, KrisPalette ; PLAYER_KRIS + player GreenStateSprites, PAL_NPC_GREEN, FishingGFX, ChrisPic, ChrisBackpic, PlayerPalette ; PLAYER_GREEN + db $ff diff --git a/data/sprites/player_sprites.asm b/data/sprites/player_sprites.asm index 89eb6e831..819b1f3e3 100644 --- a/data/sprites/player_sprites.asm +++ b/data/sprites/player_sprites.asm @@ -11,3 +11,10 @@ KrisStateSprites: db PLAYER_SURF, SPRITE_SURF db PLAYER_SURF_PIKA, SPRITE_SURFING_PIKACHU db -1 ; end + +GreenStateSprites: + db PLAYER_NORMAL, SPRITE_RIVAL + db PLAYER_BIKE, SPRITE_CHRIS_BIKE + db PLAYER_SURF, SPRITE_SURF + db PLAYER_SURF_PIKA, SPRITE_SURFING_PIKACHU + db -1 ; end diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 06ea09d69..786610927 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -8755,7 +8755,6 @@ GetTrainerBackpic: ; Load the player character's backpic (6x6) into VRAM starting from vTiles2 tile $31. ; Special exception for Dude. - ld b, BANK(DudeBackpic) ld hl, DudeBackpic ld a, [wBattleType] cp BATTLETYPE_TUTORIAL @@ -8763,21 +8762,12 @@ GetTrainerBackpic: ; What gender are we? ld a, [wPlayerGender] - bit PLAYERGENDER_FEMALE_F, a - jr z, .Chris - -; It's a girl. - farcall GetKrisBackpic - ret - -.Chris: -; It's a boy. - ld b, BANK(ChrisBackpic) - ld hl, ChrisBackpic - -.Decompress: + ld e, PLAYERDATA_BACKPIC + call GetPlayerField +.Decompress ld de, vTiles2 tile $31 ld c, 7 * 7 + ld b, BANK(ChrisBackpic) predef DecompressGet2bpp ret diff --git a/engine/events/fishing_gfx.asm b/engine/events/fishing_gfx.asm index e8878b6f2..b4dfe727c 100644 --- a/engine/events/fishing_gfx.asm +++ b/engine/events/fishing_gfx.asm @@ -4,12 +4,11 @@ LoadFishingGFX: ld a, $1 ldh [rVBK], a - ld de, FishingGFX ld a, [wPlayerGender] - bit PLAYERGENDER_FEMALE_F, a - jr z, .got_gender - ld de, KrisFishingGFX -.got_gender + ld e, PLAYERDATA_FISHING_SPRITE + call GetPlayerField + ld d, h + ld e, l ld hl, vTiles0 tile $02 call .LoadGFX diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm index 2d303b992..1d519f362 100644 --- a/engine/gfx/color.asm +++ b/engine/gfx/color.asm @@ -504,13 +504,8 @@ GetPlayerOrMonPalettePointer: and a jp nz, GetMonNormalOrShinyPalettePointer ld a, [wPlayerGender] - and a - jr z, .male - ld hl, KrisPalette - ret - -.male - ld hl, PlayerPalette + ld e, PLAYERDATA_PIC_PAL + call GetPlayerField ret GetFrontpicPalettePointer: diff --git a/engine/gfx/load_pics.asm b/engine/gfx/load_pics.asm index c4b869783..f2ad86c99 100644 --- a/engine/gfx/load_pics.asm +++ b/engine/gfx/load_pics.asm @@ -288,25 +288,6 @@ EXPORT PICS_FIX db BANK("Pics 23") ; BANK("Pics 1") + 22 db BANK("Pics 24") ; BANK("Pics 1") + 23 -GSIntro_GetMonFrontpic: ; unreferenced - ld a, c - push de - ld hl, PokemonPicPointers - dec a - ld bc, 6 - call AddNTimes - ld a, BANK(PokemonPicPointers) - call GetFarByte - call FixPicBank - push af - inc hl - ld a, BANK(PokemonPicPointers) - call GetFarWord - pop af - pop de - call FarDecompress - ret - GetTrainerPic: ld a, [wTrainerClass] and a diff --git a/engine/gfx/player_gfx.asm b/engine/gfx/player_gfx.asm index 2bf698889..fbef541e5 100644 --- a/engine/gfx/player_gfx.asm +++ b/engine/gfx/player_gfx.asm @@ -58,7 +58,7 @@ ShowPlayerNamingChoices: call CloseWindow ret -INCLUDE "data/player_names.asm" +INCLUDE "data/players/names.asm" GetPlayerIcon: ld de, ChrisSpriteGFX @@ -100,16 +100,11 @@ INCBIN "gfx/trainer_card/trainer_card.2bpp" GetPlayerBackpic: ld a, [wPlayerGender] - bit PLAYERGENDER_FEMALE_F, a - jr z, GetChrisBackpic - call GetKrisBackpic - ret - -GetChrisBackpic: - ld hl, ChrisBackpic - ld b, BANK(ChrisBackpic) + ld e, PLAYERDATA_BACKPIC + call GetPlayerField ld de, vTiles2 tile $31 ld c, 7 * 7 + ld b, BANK(ChrisBackpic) predef DecompressGet2bpp ret @@ -177,20 +172,3 @@ DrawIntroPlayerPic: lb bc, 7, 7 predef PlaceGraphic ret - -ChrisPic: -INCBIN "gfx/player/chris.2bpp" - -KrisPic: -INCBIN "gfx/player/kris.2bpp" - -GetKrisBackpic: -; Kris's backpic is uncompressed. - ld de, KrisBackpic - ld hl, vTiles2 tile $31 - lb bc, BANK(KrisBackpic), 7 * 7 ; dimensions - call Get2bpp - ret - -KrisBackpic: -INCBIN "gfx/player/kris_back.2bpp" diff --git a/engine/overworld/overworld.asm b/engine/overworld/overworld.asm index ec7dfdee5..7828faf18 100644 --- a/engine/overworld/overworld.asm +++ b/engine/overworld/overworld.asm @@ -52,15 +52,11 @@ RefreshSprites:: call LoadAndSortSprites ret -GetPlayerSprite: -; Get Chris or Kris's sprite. - ld hl, ChrisStateSprites +DeterminePlayerSprite: +; Return player's sprite in c and a. ld a, [wPlayerGender] - bit PLAYERGENDER_FEMALE_F, a - jr z, .go - ld hl, KrisStateSprites - -.go + ld e, PLAYERDATA_STATE_SPRITES + call GetPlayerField ld a, [wPlayerState] ld c, a .loop @@ -75,12 +71,16 @@ GetPlayerSprite: xor a ; ld a, PLAYER_NORMAL ld [wPlayerState], a ld a, SPRITE_CHRIS - jr .finish + ret .good ld a, [hl] + ld c, a + ret -.finish +GetPlayerSprite: +; Get player's sprite in a. + call DeterminePlayerSprite ld [wUsedSprites + 0], a ld [wPlayerSprite], a ld [wPlayerObjectSprite], a diff --git a/engine/overworld/player_object.asm b/engine/overworld/player_object.asm index 86f002de0..d19d4fda8 100644 --- a/engine/overworld/player_object.asm +++ b/engine/overworld/player_object.asm @@ -944,33 +944,19 @@ MockPlayerObject:: ld bc, OBJECT_EVENT_SIZE + 1 call CopyBytes -; adjust sprite id and palette number - ld hl, .PlayerObjectFields -.loop +; adjust palette number ld a, [wPlayerGender] - cp [hl] - inc hl - jr nz, .next1 - ld a, [wPlayerState] - cp [hl] - inc hl - jr nz, .next2 -; found a match - ld a, [hli] ; sprite - ld [wMapObject{d:LAST_OBJECT}Sprite], a - ld a, [hl] ; palette | objecttype + ld e, PLAYERDATA_NPC_PAL + call GetPlayerField + swap a + or OBJECTTYPE_SCRIPT ld [wMapObject{d:LAST_OBJECT}Palette], a ; also wMapObject{d:LAST_OBJECT}Type - jr .copy_player_coords -.next1 - inc hl -.next2 - inc hl - inc hl - ld a, [hl] - cp -1 - jr nz, .loop -.copy_player_coords +; adjust sprite id + farcall DeterminePlayerSprite + ld a, c + ld [wMapObject{d:LAST_OBJECT}Sprite], a + ; copy player's coordinates ld hl, wPlayerMockYCoord ld de, wMapObject{d:LAST_OBJECT}YCoord @@ -1001,16 +987,6 @@ MockPlayerObject:: db -1 ; MAPOBJECT_OBJECT_STRUCT_ID object_event 0, 0, SPRITE_CHRIS, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, ObjectEvent, -1 -.PlayerObjectFields: -; [wPlayerGender], [wPlayerState], sprite id, palette - db 0, PLAYER_NORMAL, SPRITE_CHRIS, PAL_NPC_RED << 4 | OBJECTTYPE_SCRIPT - db 1 << PLAYERGENDER_FEMALE_F, PLAYER_NORMAL, SPRITE_KRIS, PAL_NPC_BLUE << 4 | OBJECTTYPE_SCRIPT - db 0, PLAYER_SURF, SPRITE_SURF, PAL_NPC_RED << 4 | OBJECTTYPE_SCRIPT - db 1 << PLAYERGENDER_FEMALE_F, PLAYER_SURF, SPRITE_SURF, PAL_NPC_BLUE << 4 | OBJECTTYPE_SCRIPT - db 0, PLAYER_BIKE, SPRITE_CHRIS_BIKE, PAL_NPC_RED << 4 | OBJECTTYPE_SCRIPT - db 1 << PLAYERGENDER_FEMALE_F, PLAYER_BIKE, SPRITE_KRIS_BIKE, PAL_NPC_BLUE << 4 | OBJECTTYPE_SCRIPT - db -1 - GetSouthConnectedSpriteCoords: ; ycoord / 2 <= 2 ld a, e diff --git a/gfx/misc.asm b/gfx/misc.asm index a22e7b643..c0a974064 100644 --- a/gfx/misc.asm +++ b/gfx/misc.asm @@ -1,19 +1,3 @@ -SECTION "Trainer Backpics", ROMX - -ChrisBackpic:: -INCBIN "gfx/player/chris_back.2bpp.lz" -DudeBackpic:: -INCBIN "gfx/battle/dude.2bpp.lz" - - -SECTION "Shrink Pics", ROMX - -Shrink1Pic:: -INCBIN "gfx/new_game/shrink1.2bpp.lz" -Shrink2Pic:: -INCBIN "gfx/new_game/shrink2.2bpp.lz" - - SECTION "Unused Egg Pic", ROMX UnusedEggPic:: diff --git a/gfx/pics.asm b/gfx/pics.asm index 9264e2dd3..b2197516d 100644 --- a/gfx/pics.asm +++ b/gfx/pics.asm @@ -17,6 +17,35 @@ SECTION "Trainer Pic Pointers", ROMX INCLUDE "data/trainers/pic_pointers.asm" +SECTION "Player Frontpics", ROMX + +ChrisPic:: +INCBIN "gfx/player/chris.2bpp" + +KrisPic:: +INCBIN "gfx/player/kris.2bpp" + + +SECTION "Player Backpics", ROMX + +ChrisBackpic:: +INCBIN "gfx/player/chris_back.2bpp.lz" + +KrisBackpic:: +INCBIN "gfx/player/kris_back.2bpp.lz" + +DudeBackpic:: +INCBIN "gfx/battle/dude.2bpp.lz" + + +SECTION "Shrink Pics", ROMX + +Shrink1Pic:: +INCBIN "gfx/new_game/shrink1.2bpp.lz" +Shrink2Pic:: +INCBIN "gfx/new_game/shrink2.2bpp.lz" + + SECTION "Pics 1", ROMX HoOhFrontpic: INCBIN "gfx/pokemon/ho_oh/front.animated.2bpp.lz" @@ -709,75 +738,11 @@ UnownIBackpic: INCBIN "gfx/pokemon/unown_i/back.2bpp.lz" UnownRBackpic: INCBIN "gfx/pokemon/unown_r/back.2bpp.lz" -SECTION "Pics 19", ROMX - -; Seems to be an accidental copy of the previous bank - -INCBIN "gfx/pokemon/spinarak/back.2bpp.lz" -INCBIN "gfx/pokemon/raikou/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_k/front.animated.2bpp.lz" -INCBIN "gfx/pokemon/houndour/back.2bpp.lz" -INCBIN "gfx/pokemon/poliwag/back.2bpp.lz" -INCBIN "gfx/pokemon/squirtle/back.2bpp.lz" -INCBIN "gfx/pokemon/shuckle/back.2bpp.lz" -INCBIN "gfx/pokemon/dewgong/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_b/front.animated.2bpp.lz" -INCBIN "gfx/pokemon/slowpoke/back.2bpp.lz" -INCBIN "gfx/pokemon/dunsparce/back.2bpp.lz" -INCBIN "gfx/pokemon/donphan/back.2bpp.lz" -INCBIN "gfx/pokemon/wooper/back.2bpp.lz" -INCBIN "gfx/pokemon/tauros/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_x/front.animated.2bpp.lz" -INCBIN "gfx/pokemon/unown_n/front.animated.2bpp.lz" -INCBIN "gfx/pokemon/tangela/back.2bpp.lz" -INCBIN "gfx/pokemon/voltorb/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_j/front.animated.2bpp.lz" -INCBIN "gfx/pokemon/mantine/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_l/front.animated.2bpp.lz" -INCBIN "gfx/pokemon/piloswine/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_m/front.animated.2bpp.lz" -INCBIN "gfx/pokemon/unown_f/front.animated.2bpp.lz" -INCBIN "gfx/pokemon/natu/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_a/front.animated.2bpp.lz" -INCBIN "gfx/pokemon/golem/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_u/front.animated.2bpp.lz" -INCBIN "gfx/pokemon/diglett/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_q/front.animated.2bpp.lz" -INCBIN "gfx/pokemon/unown_p/front.animated.2bpp.lz" -INCBIN "gfx/pokemon/unown_c/back.2bpp.lz" -INCBIN "gfx/pokemon/jynx/back.2bpp.lz" -INCBIN "gfx/pokemon/golbat/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_y/front.animated.2bpp.lz" -INCBIN "gfx/pokemon/unown_g/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_i/front.animated.2bpp.lz" -INCBIN "gfx/pokemon/unown_v/back.2bpp.lz" -INCBIN "gfx/pokemon/forretress/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_s/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_r/front.animated.2bpp.lz" -INCBIN "gfx/pokemon/unown_e/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_j/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_b/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_o/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_z/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_w/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_n/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_a/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_m/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_k/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_t/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_x/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_l/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_u/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_q/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_y/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_p/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_i/back.2bpp.lz" -INCBIN "gfx/pokemon/unown_r/back.2bpp.lz" - - -; Sections "Pics 20" to "Pics 24" are not used for any graphics, +; Sections "Pics 19" to "Pics 24" are not used for any graphics, ; but entries for their banks exist in FixPicBank (see engine/gfx/load_pics.asm). +SECTION "Pics 19", ROMX + SECTION "Pics 20", ROMX SECTION "Pics 21", ROMX diff --git a/home.asm b/home.asm index 205c09824..f8d776797 100644 --- a/home.asm +++ b/home.asm @@ -58,3 +58,4 @@ INCLUDE "home/print_bcd.asm" INCLUDE "home/battle.asm" INCLUDE "home/sprite_anims.asm" INCLUDE "home/audio.asm" +INCLUDE "home/player.asm" diff --git a/home/player.asm b/home/player.asm new file mode 100755 index 000000000..b877f98e2 --- /dev/null +++ b/home/player.asm @@ -0,0 +1,13 @@ +; return field e in player a +; for one-byte field: in a +; for two-byte field: in hl +GetPlayerField:: + ld hl, Players + ld bc, PLAYERDATA_LENGTH + call AddNTimes + ld d, 0 + add hl, de + ld a, BANK(Players) + call GetFarWord + ld a, l + ret diff --git a/includes.asm b/includes.asm index 6b258d283..ba6cfc92f 100644 --- a/includes.asm +++ b/includes.asm @@ -54,6 +54,7 @@ INCLUDE "constants/item_data_constants.asm" INCLUDE "constants/music_constants.asm" INCLUDE "constants/npc_trade_constants.asm" INCLUDE "constants/phone_constants.asm" +INCLUDE "constants/player_constants.asm" INCLUDE "constants/pokemon_constants.asm" INCLUDE "constants/pokemon_data_constants.asm" INCLUDE "constants/printer_constants.asm" diff --git a/layout.link b/layout.link index cfbdd433e..317b1421b 100644 --- a/layout.link +++ b/layout.link @@ -53,7 +53,6 @@ ROMX $09 "bank9" ROMX $0a "bankA" - "Trainer Backpics" ROMX $0b "bankB" ROMX $0c @@ -73,7 +72,6 @@ ROMX $12 "Crystal Features 1" ROMX $13 "bank13" - "Shrink Pics" "bank13_2" ROMX $14 "bank14" diff --git a/main.asm b/main.asm index b6c0cfdac..733886008 100644 --- a/main.asm +++ b/main.asm @@ -24,6 +24,7 @@ INCLUDE "engine/overworld/player_object.asm" INCLUDE "engine/math/sine.asm" INCLUDE "engine/predef.asm" INCLUDE "engine/gfx/color.asm" +INCLUDE "data/players/players.asm" SECTION "bank3", ROMX