diff options
-rw-r--r-- | Expand-tilesets-from-192-to-255-tiles.md | 288 |
1 files changed, 144 insertions, 144 deletions
diff --git a/Expand-tilesets-from-192-to-255-tiles.md b/Expand-tilesets-from-192-to-255-tiles.md index 286964c..b6c625e 100644 --- a/Expand-tilesets-from-192-to-255-tiles.md +++ b/Expand-tilesets-from-192-to-255-tiles.md @@ -9,152 +9,18 @@ It's fairly simple to use $E0 to $FF for 32 more map tiles. We can also use $60 ## Contents -1. [Load tile graphics into $60–$7F and $E0–$FF](#1-load-tile-graphics-into-607f-and-e0ff) -2. [Update the tilesets' graphics to not skip $60–$7F](#2-update-the-tilesets-graphics-to-not-skip-607f) -3. [Update the tilesets' palette maps to not skip $60–$7F](#3-update-the-tilesets-palette-maps-to-not-skip-607f) -4. [Don't hide sprites behind $60–$7F or $E0–$FF](#4-dont-hide-sprites-behind-607f-or-e0ff) -5. [Move necessary text tiles to the main font graphics](#5-move-necessary-text-tiles-to-the-main-font-graphics) -6. [Delete the unused font graphics](#6-delete-the-unused-font-graphics) -7. [Update the character set](#7-update-the-character-set) +1. [Move necessary text tiles to the main font graphics](#1-move-necessary-text-tiles-to-the-main-font-graphics) +2. [Delete the unused font graphics](#2-delete-the-unused-font-graphics) +3. [Update the character set](#3-update-the-character-set) +4. [Load tile graphics into $60–$7F and $E0–$FF](#4-load-tile-graphics-into-607f-and-e0ff) +5. [Update the tilesets' graphics to not skip $60–$7F](#5-update-the-tilesets-graphics-to-not-skip-607f) +6. [Update the tilesets' palette maps to not skip $60–$7F](#6-update-the-tilesets-palette-maps-to-not-skip-607f) +7. [Don't hide sprites behind $60–$7F or $E0–$FF](#7-dont-hide-sprites-behind-607f-or-e0ff) 8. [Change some hard-coded tile placements](#8-change-some-hard-coded-tile-placements) 9. [Correct other implicit assumptions about tiles](#9-correct-other-implicit-assumptions-about-tiles) -## 1. Load tile graphics into $60–$7F and $E0–$FF - -Edit [home/map.asm](../blob/master/home/map.asm). - -```diff - LoadTilesetGFX:: ; 2821 - ... - - ld a, e - ld de, wDecompressScratch - call FarDecompress - - ld hl, wDecompressScratch - ld de, vTiles2 -- ld bc, $60 tiles -+ ld bc, $7f tiles - call CopyBytes - - ld a, [rVBK] - push af - ld a, $1 - ld [rVBK], a - - ... - - ld a, [rVBK] - push af - ld a, $1 - ld [rVBK], a - -- ld hl, wDecompressScratch + $60 tiles -+ ld hl, wDecompressScratch + $80 tiles - ld de, vTiles2 -- ld bc, $60 tiles -+ ld bc, $80 tiles - call CopyBytes - - pop af - ld [rVBK], a -``` - -Now instead of loading tileset graphics into tiles $00–$5F and $80–$DF, they'll be loaded into $00–$7E and $80–$FF. That's nearly four more rows, or 63 more tiles, usable for maps. (Note that only the first $7F tiles are loaded instead of the full $80; tile $7F, is not loaded because the space character goes there.) - - -## 2. Update the tilesets' graphics to not skip $60–$7F - -Edit all the [gfx/tilesets/\*.png](../tree/master/gfx/tilesets/) files with more than six rows of tiles. In each case, we need to add two rows of blank tiles for the $60–$7F range (that is, the seventh and eighth rows). Here's one example, [gfx/tilesets/johto_modern.png](../blob/master/gfx/tilesets/johto_modern.png): - - - - -## 3. Update the tilesets' palette maps to not skip $60–$7F - -Edit all 37 [gfx/tilesets/\*_palette_map.asm](../tree/master/gfx/tilesets/) files. In each case, we need to replace the 16 `$ff` bytes that were placeholders for $60–$7F to be four `tilepal` lines. - -Here's one example, [gfx/tilesets/johto_modern_palette_map.asm](../blob/master/gfx/tilesets/johto_modern_palette_map.asm): - -```diff - tilepal 0, GRAY, BROWN, BROWN, RED, GREEN, GREEN, GRAY, ROOF - tilepal 0, RED, RED, ROOF, ROOF, ROOF, ROOF, ROOF, ROOF - tilepal 0, ROOF, ROOF, ROOF, GREEN, WATER, GREEN, BROWN, BROWN - tilepal 0, RED, RED, BROWN, BROWN, BROWN, GRAY, GREEN, GREEN - tilepal 0, GRAY, GRAY, BROWN, RED, RED, GRAY, YELLOW, BROWN - tilepal 0, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, GRAY, RED - tilepal 0, GRAY, BROWN, BROWN, GRAY, BROWN, GRAY, GRAY, YELLOW - tilepal 0, YELLOW, BROWN, BROWN, BROWN, BROWN, BROWN, GREEN, GREEN - tilepal 0, RED, BROWN, GRAY, GRAY, BROWN, BROWN, BROWN, BROWN - tilepal 0, BROWN, WATER, GRAY, BROWN, BROWN, BROWN, GRAY, GRAY - tilepal 0, GRAY, BROWN, BROWN, GRAY, BROWN, GRAY, GRAY, GRAY - tilepal 0, WATER, GRAY, GRAY, GRAY, BROWN, BROWN, GRAY, GRAY -- --rept 16 -- db $ff --endr -- -+ 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, GRAY, BROWN, BROWN, RED, GREEN, GREEN, GRAY, ROOF - tilepal 1, RED, RED, ROOF, ROOF, ROOF, ROOF, ROOF, ROOF - tilepal 1, ROOF, ROOF, ROOF, GREEN, WATER, GREEN, BROWN, ROOF - tilepal 1, ROOF, ROOF, ROOF, BROWN, BROWN, GRAY, GREEN, GREEN - tilepal 1, GRAY, GRAY, BROWN, RED, RED, GRAY, YELLOW, BROWN - tilepal 1, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, GRAY, RED - tilepal 1, GRAY, BROWN, BROWN, GRAY, BROWN, GRAY, GRAY, YELLOW - tilepal 1, YELLOW, BROWN, BROWN, BROWN, BROWN, BROWN, GREEN, GREEN - tilepal 1, RED, BROWN, GRAY, GRAY, BROWN, BROWN, BROWN, BROWN - tilepal 1, BROWN, WATER, GRAY, BROWN, BROWN, BROWN, GRAY, GRAY - tilepal 1, GRAY, BROWN, BROWN, GRAY, RED, RED, GREEN, GREEN - tilepal 1, YELLOW, ROOF, ROOF, ROOF, ROOF, ROOF, RED, ROOF -``` - -The `ROOF` values are for tiles $60–$7E, which can be used for maps, and the `TEXT` value is for $7F, the space character. - - -## 4. Don't hide sprites behind $60–$7F or $E0–$FF - -By default, sprites will disappear when they're behind (on top of) tiles $60–$6F or $D0–$FF, as well as the regular font tiles. This is so they won't appear on top of textboxes. We need to change this to hide sprites behind *any* text tile, instead of assuming certain IDs are always for text. - -Edit [engine/overworld/map_objects.asm](../blob/master/engine/overworld/map_objects.asm): - -```diff - Function56cd: ; 56cd: - ... - ld a, [hUsedSpriteIndex] - add d - dec a - cp SCREEN_WIDTH - jr nc, .ok8 - ld c, a - push bc -- call Coord2Tile -+ call Coord2Attr - pop bc --; NPCs disappear if standing on tile $60-$7f (or $e0-$ff), --; since those IDs are for text characters and textbox frames. - ld a, [hl] -- cp FIRST_REGULAR_TEXT_CHAR -- jr nc, .nope -+ and PALETTE_MASK -+ cp PAL_BG_TEXT -+ jr z, .nope - .ok8 - dec d - jr nz, .next - .ok9 - dec e - jr nz, .loop - and a - ret -``` - - -## 5. Move necessary text tiles to the main font graphics +## 1. Move necessary text tiles to the main font graphics Of the 32 tiles in the $60–$7F range, only 18 are actually used: @@ -180,7 +46,7 @@ And [gfx/font/overworld.png](../blob/master/gfx/font/overworld.png): Note that the textbox frames aren't present in these graphics. That's because they would be overwritten by whichever frame is actually chosen, so it would waste space to replicate them here. -## 6. Delete the unused font graphics +## 2. Delete the unused font graphics Delete [gfx/font/font_extra.png](../blob/master/gfx/font/font_extra.png), [gfx/font/phone_icon.png](../blob/master/gfx/font/phone_icon.png), [gfx/font/black.png](../blob/master/gfx/font/black.png), and [gfx/font/up_arrow.png](../blob/master/gfx/font/up_arrow.png). @@ -335,7 +201,7 @@ And edit [mobile/mobile_41.asm](../blob/master/mobile/mobile_41.asm): ``` -## 7. Update the character set +## 3. Update the character set Edit [charmap.asm](../blob/master/charmap.asm): @@ -459,6 +325,140 @@ Edit [charmap.asm](../blob/master/charmap.asm): ``` +## 4. Load tile graphics into $60–$7F and $E0–$FF + +Edit [home/map.asm](../blob/master/home/map.asm). + +```diff + LoadTilesetGFX:: ; 2821 + ... + + ld a, e + ld de, wDecompressScratch + call FarDecompress + + ld hl, wDecompressScratch + ld de, vTiles2 +- ld bc, $60 tiles ++ ld bc, $7f tiles + call CopyBytes + + ld a, [rVBK] + push af + ld a, $1 + ld [rVBK], a + + ... + + ld a, [rVBK] + push af + ld a, $1 + ld [rVBK], a + +- ld hl, wDecompressScratch + $60 tiles ++ ld hl, wDecompressScratch + $80 tiles + ld de, vTiles2 +- ld bc, $60 tiles ++ ld bc, $80 tiles + call CopyBytes + + pop af + ld [rVBK], a +``` + +Now instead of loading tileset graphics into tiles $00–$5F and $80–$DF, they'll be loaded into $00–$7E and $80–$FF. That's nearly four more rows, or 63 more tiles, usable for maps. (Note that only the first $7F tiles are loaded instead of the full $80; tile $7F, is not loaded because the space character goes there.) + + +## 5. Update the tilesets' graphics to not skip $60–$7F + +Edit all the [gfx/tilesets/\*.png](../tree/master/gfx/tilesets/) files with more than six rows of tiles. In each case, we need to add two rows of blank tiles for the $60–$7F range (that is, the seventh and eighth rows). Here's one example, [gfx/tilesets/johto_modern.png](../blob/master/gfx/tilesets/johto_modern.png): + + + + +## 6. Update the tilesets' palette maps to not skip $60–$7F + +Edit all 37 [gfx/tilesets/\*_palette_map.asm](../tree/master/gfx/tilesets/) files. In each case, we need to replace the 16 `$ff` bytes that were placeholders for $60–$7F to be four `tilepal` lines. + +Here's one example, [gfx/tilesets/johto_modern_palette_map.asm](../blob/master/gfx/tilesets/johto_modern_palette_map.asm): + +```diff + tilepal 0, GRAY, BROWN, BROWN, RED, GREEN, GREEN, GRAY, ROOF + tilepal 0, RED, RED, ROOF, ROOF, ROOF, ROOF, ROOF, ROOF + tilepal 0, ROOF, ROOF, ROOF, GREEN, WATER, GREEN, BROWN, BROWN + tilepal 0, RED, RED, BROWN, BROWN, BROWN, GRAY, GREEN, GREEN + tilepal 0, GRAY, GRAY, BROWN, RED, RED, GRAY, YELLOW, BROWN + tilepal 0, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, GRAY, RED + tilepal 0, GRAY, BROWN, BROWN, GRAY, BROWN, GRAY, GRAY, YELLOW + tilepal 0, YELLOW, BROWN, BROWN, BROWN, BROWN, BROWN, GREEN, GREEN + tilepal 0, RED, BROWN, GRAY, GRAY, BROWN, BROWN, BROWN, BROWN + tilepal 0, BROWN, WATER, GRAY, BROWN, BROWN, BROWN, GRAY, GRAY + tilepal 0, GRAY, BROWN, BROWN, GRAY, BROWN, GRAY, GRAY, GRAY + tilepal 0, WATER, GRAY, GRAY, GRAY, BROWN, BROWN, GRAY, GRAY +- +-rept 16 +- db $ff +-endr +- ++ 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, GRAY, BROWN, BROWN, RED, GREEN, GREEN, GRAY, ROOF + tilepal 1, RED, RED, ROOF, ROOF, ROOF, ROOF, ROOF, ROOF + tilepal 1, ROOF, ROOF, ROOF, GREEN, WATER, GREEN, BROWN, ROOF + tilepal 1, ROOF, ROOF, ROOF, BROWN, BROWN, GRAY, GREEN, GREEN + tilepal 1, GRAY, GRAY, BROWN, RED, RED, GRAY, YELLOW, BROWN + tilepal 1, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, GRAY, RED + tilepal 1, GRAY, BROWN, BROWN, GRAY, BROWN, GRAY, GRAY, YELLOW + tilepal 1, YELLOW, BROWN, BROWN, BROWN, BROWN, BROWN, GREEN, GREEN + tilepal 1, RED, BROWN, GRAY, GRAY, BROWN, BROWN, BROWN, BROWN + tilepal 1, BROWN, WATER, GRAY, BROWN, BROWN, BROWN, GRAY, GRAY + tilepal 1, GRAY, BROWN, BROWN, GRAY, RED, RED, GREEN, GREEN + tilepal 1, YELLOW, ROOF, ROOF, ROOF, ROOF, ROOF, RED, ROOF +``` + +The `ROOF` values are for tiles $60–$7E, which can be used for maps, and the `TEXT` value is for $7F, the space character. + + +## 7. Don't hide sprites behind $60–$7F or $E0–$FF + +By default, sprites will disappear when they're behind (on top of) tiles $60–$6F or $D0–$FF, as well as the regular font tiles. This is so they won't appear on top of textboxes. We need to change this to hide sprites behind *any* text tile, instead of assuming certain IDs are always for text. + +Edit [engine/overworld/map_objects.asm](../blob/master/engine/overworld/map_objects.asm): + +```diff + Function56cd: ; 56cd: + ... + ld a, [hUsedSpriteIndex] + add d + dec a + cp SCREEN_WIDTH + jr nc, .ok8 + ld c, a + push bc +- call Coord2Tile ++ call Coord2Attr + pop bc +-; NPCs disappear if standing on tile $60-$7f (or $e0-$ff), +-; since those IDs are for text characters and textbox frames. + ld a, [hl] +- cp FIRST_REGULAR_TEXT_CHAR +- jr nc, .nope ++ and PALETTE_MASK ++ cp PAL_BG_TEXT ++ jr z, .nope + .ok8 + dec d + jr nz, .next + .ok9 + dec e + jr nz, .loop + and a + ret +``` + + ## 8. Change some hard-coded tile placements Some parts of the code use "<code>vTiles2 tile <i>N</i></code>" to hard-code the data for a tile from $00 to $7F. When such a tile is moved to the range $80–$FF, the offset is invalid, so it has to become "<code>vTiles0 tile <i>N</i></code>". (If it's unclear to you why, take a look at the VRAM screenshot again, noting that `Tiles0` is the top-left sixth, `vTiles1` is the middle-left, and `vTiles2` is the bottom-left, with all three being sequential in memory.) |