Implement common tileset portion at second half of vTiles5: palette maps (#19)

This commit is contained in:
xCrystal 2023-10-04 17:20:48 +02:00
parent adfcd603dd
commit a01f04e967
10 changed files with 100 additions and 84 deletions

View File

@ -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

Binary file not shown.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1 +1 @@

0$%