From a01f04e96794eeef6b7b4a87463034857dfe2647 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Wed, 4 Oct 2023 17:20:48 +0200 Subject: [PATCH] Implement common tileset portion at second half of vTiles5: palette maps (#19) --- constants/tileset_constants.asm | 6 +- data/tilesets/johto_metatiles.bin | Bin 2048 -> 2048 bytes engine/tilesets/map_palettes.asm | 102 ++++++++++++------ gfx/tileset_palette_maps.asm | 21 ++-- .../spaces/fixed_spaces_palette_map.asm | 4 + .../spaces/variable_spaces_1_palette_map.asm | 4 + .../spaces/variable_spaces_2_palette_map.asm | 4 + gfx/tilesets/unused_museum_palette_map.asm | 31 ------ home/map.asm | 10 +- maps/DebugLevel5_Map1.blk | 2 +- 10 files changed, 100 insertions(+), 84 deletions(-) create mode 100755 gfx/tilesets/spaces/fixed_spaces_palette_map.asm create mode 100755 gfx/tilesets/spaces/variable_spaces_1_palette_map.asm create mode 100755 gfx/tilesets/spaces/variable_spaces_2_palette_map.asm delete mode 100644 gfx/tilesets/unused_museum_palette_map.asm diff --git a/constants/tileset_constants.asm b/constants/tileset_constants.asm index cc56842b3..80c0418bd 100644 --- a/constants/tileset_constants.asm +++ b/constants/tileset_constants.asm @@ -62,6 +62,6 @@ DEF ROOF_LENGTH EQU 9 ; const TILESET_VARIABLE_SPACES_2 ; 1 DEF NUM_VARIABLE_SPACES_SETS EQU const_value -; size of the tileset occupied by space tiles (see LoadTilesetGFX) -DEF TILESET_FIXED_SPACES_SIZE EQU $20 tiles -DEF TILESET_VARIABLE_SPACES_SIZE EQU $20 tiles +; number of tiles of the tileset occupied by space tiles (see LoadTilesetGFX) +DEF TILESET_FIXED_SPACES_NUM_TILES EQU $20 +DEF TILESET_VARIABLE_SPACES_NUM_TILES EQU $20 diff --git a/data/tilesets/johto_metatiles.bin b/data/tilesets/johto_metatiles.bin index 9024f2ad6c761ca47759645ed12017236ed7e208..9aa5b1d4fbfee6edac4d580a3515bc8f5d296610 100644 GIT binary patch delta 19 bcmZn=Xb{-I#msi#U_``&hnoeMKd=A*MluJG delta 16 XcmZn=Xb{-I#XPx*S#7fc^92?FDZB*M diff --git a/engine/tilesets/map_palettes.asm b/engine/tilesets/map_palettes.asm index b45079749..8f9087ee6 100644 --- a/engine/tilesets/map_palettes.asm +++ b/engine/tilesets/map_palettes.asm @@ -5,40 +5,7 @@ _LoadScreenAttrmapPals:: .loop push bc ld c, SCREEN_WIDTH -.innerloop - ld a, [hl] - push hl - srl a - jr c, .UpperNybble - ld hl, wTilesetPalettes - add [hl] - ld l, a - ld a, [wTilesetPalettes + 1] - adc 0 - ld h, a - ld a, [hl] - and $f - jr .next - -.UpperNybble: - ld hl, wTilesetPalettes - add [hl] - ld l, a - ld a, [wTilesetPalettes + 1] - adc 0 - ld h, a - ld a, [hl] - swap a - and $f - -.next - pop hl - ld [de], a - res 7, [hl] - inc hl - inc de - dec c - jr nz, .innerloop + call LoadChunkPalettes pop bc dec b jr nz, .loop @@ -47,6 +14,10 @@ _LoadScreenAttrmapPals:: _ScrollBGMapPalettes:: ld hl, wBGMapBuffer ld de, wBGMapPalBuffer + call LoadChunkPalettes + ret + +LoadChunkPalettes: .loop ld a, [hl] push hl @@ -54,6 +25,36 @@ _ScrollBGMapPalettes:: jr c, .UpperNybble ; .LowerNybble + cp ($100 - (TILESET_FIXED_SPACES_NUM_TILES + TILESET_VARIABLE_SPACES_NUM_TILES)) / 2 + jr c, .lower_nybble_map_tileset + cp ($100 - TILESET_VARIABLE_SPACES_NUM_TILES) / 2 + ld hl, TilesetFixedSpacesPalMap - ($100 - (TILESET_FIXED_SPACES_NUM_TILES + TILESET_VARIABLE_SPACES_NUM_TILES)) / 2 + jr c, .lower_nybble_spaces_tileset + ld hl, TilesetVariableSpacesPalMaps + push af + ld a, [wTilesetVariableSpaces] + add a + add l + ld l, a + ld a, h + adc 0 + ld h, a + ld a, [hli] + ld h, [hl] + ld l, a + pop af + sub ($100 - TILESET_VARIABLE_SPACES_NUM_TILES) / 2 +.lower_nybble_spaces_tileset + add l + ld l, a + ld a, h + adc 0 + ld h, a + ld a, [hl] + and $f + jr .next + +.lower_nybble_map_tileset ld hl, wTilesetPalettes add [hl] ld l, a @@ -65,6 +66,37 @@ _ScrollBGMapPalettes:: jr .next .UpperNybble: + cp ($100 - (TILESET_FIXED_SPACES_NUM_TILES + TILESET_VARIABLE_SPACES_NUM_TILES)) / 2 + jr c, .upper_nybble_map_tileset + cp ($100 - TILESET_VARIABLE_SPACES_NUM_TILES) / 2 + ld hl, TilesetFixedSpacesPalMap - ($100 - (TILESET_FIXED_SPACES_NUM_TILES + TILESET_VARIABLE_SPACES_NUM_TILES)) / 2 + jr c, .upper_nybble_spaces_tileset + ld hl, TilesetVariableSpacesPalMaps + push af + ld a, [wTilesetVariableSpaces] + add a + add l + ld l, a + ld a, h + adc 0 + ld h, a + ld a, [hli] + ld h, [hl] + ld l, a + pop af + sub ($100 - TILESET_VARIABLE_SPACES_NUM_TILES) / 2 +.upper_nybble_spaces_tileset + add l + ld l, a + ld a, h + adc 0 + ld h, a + ld a, [hl] + swap a + and $f + jr .next + +.upper_nybble_map_tileset ld hl, wTilesetPalettes add [hl] ld l, a @@ -82,5 +114,5 @@ _ScrollBGMapPalettes:: inc hl inc de dec c - jr nz, .loop + jp nz, .loop ret diff --git a/gfx/tileset_palette_maps.asm b/gfx/tileset_palette_maps.asm index 678eb1837..6ae17f0c9 100644 --- a/gfx/tileset_palette_maps.asm +++ b/gfx/tileset_palette_maps.asm @@ -8,6 +8,18 @@ MACRO tilepal endr ENDM +TilesetVariableSpacesPalMaps:: +; entries correspond to TILESET_VARIABLE_SPACES_* constants (see constants/tileset_constants.asm) + table_width 2, TilesetVariableSpacesPalMaps + dw TilesetVariableSpaces1PalMap + assert_table_length NUM_VARIABLE_SPACES_SETS + +TilesetFixedSpacesPalMap: +INCLUDE "gfx/tilesets/spaces/fixed_spaces_palette_map.asm" + +TilesetVariableSpaces1PalMap: +INCLUDE "gfx/tilesets/spaces/variable_spaces_1_palette_map.asm" + TilesetKantoPalMap: INCLUDE "gfx/tilesets/kanto_palette_map.asm" @@ -90,9 +102,6 @@ INCLUDE "gfx/tilesets/lighthouse_palette_map.asm" TilesetPlayersRoomPalMap: INCLUDE "gfx/tilesets/players_room_palette_map.asm" -UnusedMuseumPalMap: ; unreferenced -INCLUDE "gfx/tilesets/unused_museum_palette_map.asm" - TilesetIcePathPalMap: INCLUDE "gfx/tilesets/ice_path_palette_map.asm" @@ -107,9 +116,3 @@ INCLUDE "gfx/tilesets/battle_tower_inside_palette_map.asm" TilesetBattleTowerOutsidePalMap: INCLUDE "gfx/tilesets/battle_tower_outside_palette_map.asm" - -MapGroupPalettes: ; unreferenced -; entries correspond to MAPGROUP_* constants -rept NUM_MAP_GROUPS - db PAL_BG_ROOF -endr diff --git a/gfx/tilesets/spaces/fixed_spaces_palette_map.asm b/gfx/tilesets/spaces/fixed_spaces_palette_map.asm new file mode 100755 index 000000000..8f83ac794 --- /dev/null +++ b/gfx/tilesets/spaces/fixed_spaces_palette_map.asm @@ -0,0 +1,4 @@ + tilepal 1, WATER, WATER, RED, RED, GREEN, GREEN, GRAY, GRAY + tilepal 1, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY + tilepal 1, WATER, WATER, RED, RED, GREEN, GREEN, GRAY, GRAY + tilepal 1, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY diff --git a/gfx/tilesets/spaces/variable_spaces_1_palette_map.asm b/gfx/tilesets/spaces/variable_spaces_1_palette_map.asm new file mode 100755 index 000000000..cd3d7f15a --- /dev/null +++ b/gfx/tilesets/spaces/variable_spaces_1_palette_map.asm @@ -0,0 +1,4 @@ + tilepal 1, YELLOW, YELLOW, GREEN, GREEN, BROWN, BROWN, GRAY, GRAY + tilepal 1, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY + tilepal 1, YELLOW, YELLOW, GREEN, GREEN, BROWN, BROWN, GRAY, GRAY + tilepal 1, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY diff --git a/gfx/tilesets/spaces/variable_spaces_2_palette_map.asm b/gfx/tilesets/spaces/variable_spaces_2_palette_map.asm new file mode 100755 index 000000000..8f83ac794 --- /dev/null +++ b/gfx/tilesets/spaces/variable_spaces_2_palette_map.asm @@ -0,0 +1,4 @@ + tilepal 1, WATER, WATER, RED, RED, GREEN, GREEN, GRAY, GRAY + tilepal 1, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY + tilepal 1, WATER, WATER, RED, RED, GREEN, GREEN, GRAY, GRAY + tilepal 1, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY diff --git a/gfx/tilesets/unused_museum_palette_map.asm b/gfx/tilesets/unused_museum_palette_map.asm deleted file mode 100644 index a5887b1ab..000000000 --- a/gfx/tilesets/unused_museum_palette_map.asm +++ /dev/null @@ -1,31 +0,0 @@ -; Matches pokered's "gate" tileset (notable for its Pewter Museum tiles) -; https://tcrf.net/Pok%C3%A9mon_Gold_and_Silver#Unused_Tile_Palette_Assignment_Data - - tilepal 0, WATER, RED, YELLOW, YELLOW, RED, GREEN, GREEN, BROWN - tilepal 0, BROWN, BROWN, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY - tilepal 0, GRAY, GRAY, YELLOW, YELLOW, RED, GREEN, GREEN, BROWN - tilepal 0, BROWN, ROOF, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY - tilepal 0, GRAY, GRAY, BROWN, BROWN, GRAY, BROWN, BROWN, ROOF - tilepal 0, ROOF, BROWN, BROWN, BROWN, ROOF, ROOF, ROOF, ROOF - tilepal 0, ROOF, ROOF, BROWN, BROWN, GRAY, BROWN, BROWN, ROOF - tilepal 0, ROOF, GRAY, ROOF, BROWN, ROOF, ROOF, GRAY, GRAY - tilepal 0, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, ROOF, ROOF - tilepal 0, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, RED, RED - tilepal 0, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY - tilepal 0, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY - tilepal 0, ROOF, ROOF, ROOF, ROOF, ROOF, ROOF, ROOF, ROOF - tilepal 0, ROOF, ROOF, ROOF, ROOF, ROOF, ROOF, ROOF, ROOF - tilepal 0, ROOF, ROOF, ROOF, ROOF, ROOF, ROOF, ROOF, ROOF - tilepal 0, ROOF, ROOF, ROOF, ROOF, ROOF, ROOF, ROOF, TEXT - tilepal 1, WATER, RED, YELLOW, YELLOW, RED, GREEN, GREEN, BROWN - tilepal 1, BROWN, BROWN, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY - tilepal 1, GRAY, GRAY, YELLOW, YELLOW, RED, GREEN, GREEN, BROWN - tilepal 1, BROWN, ROOF, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY - tilepal 1, GRAY, GRAY, BROWN, BROWN, GRAY, BROWN, BROWN, ROOF - tilepal 1, ROOF, BROWN, BROWN, BROWN, ROOF, ROOF, ROOF, ROOF - tilepal 1, ROOF, ROOF, BROWN, BROWN, GRAY, BROWN, BROWN, ROOF - tilepal 1, ROOF, GRAY, ROOF, BROWN, ROOF, ROOF, GRAY, GRAY - tilepal 1, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, ROOF, ROOF - tilepal 1, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, RED, RED - tilepal 1, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY - tilepal 1, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY, GRAY diff --git a/home/map.asm b/home/map.asm index 25a66312e..f508cff0a 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1342,7 +1342,7 @@ LoadTilesetGFX:: ld hl, wDecompressScratch + $80 tiles ld de, vTiles5 - ld bc, $80 tiles - (TILESET_FIXED_SPACES_SIZE + TILESET_VARIABLE_SPACES_SIZE) + ld bc, $80 tiles - (TILESET_FIXED_SPACES_NUM_TILES + TILESET_VARIABLE_SPACES_NUM_TILES) tiles call CopyBytes ldh a, [hROMBank] @@ -1356,8 +1356,8 @@ LoadTilesetGFX:: call Decompress ld hl, wDecompressScratch - ld de, vTiles5 + $80 tiles - (TILESET_FIXED_SPACES_SIZE + TILESET_VARIABLE_SPACES_SIZE) - ld bc, TILESET_FIXED_SPACES_SIZE + ld de, vTiles5 + $80 tiles - (TILESET_FIXED_SPACES_NUM_TILES + TILESET_VARIABLE_SPACES_NUM_TILES) tiles + ld bc, TILESET_FIXED_SPACES_NUM_TILES tiles call CopyBytes ld hl, TilesetVariableSpacesPointers @@ -1373,8 +1373,8 @@ LoadTilesetGFX:: call Decompress ld hl, wDecompressScratch - ld de, vTiles5 + $80 tiles - TILESET_VARIABLE_SPACES_SIZE - ld bc, TILESET_VARIABLE_SPACES_SIZE + ld de, vTiles5 + $80 tiles - TILESET_VARIABLE_SPACES_NUM_TILES tiles + ld bc, TILESET_VARIABLE_SPACES_NUM_TILES tiles call CopyBytes pop af diff --git a/maps/DebugLevel5_Map1.blk b/maps/DebugLevel5_Map1.blk index dc973931c..1ad8d9d99 100755 --- a/maps/DebugLevel5_Map1.blk +++ b/maps/DebugLevel5_Map1.blk @@ -1 +1 @@ - \ No newline at end of file +0$% \ No newline at end of file