diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2019-01-22 22:52:45 -0500 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2019-01-22 22:52:45 -0500 |
commit | fba04ace5663e40aa79e18ce35aaaa8766cae7cb (patch) | |
tree | cf993c37b7a4883e08c2596504767df8d0d2a4c5 | |
parent | c51172f4725924b2a822f5dc6cfc2087dea192ce (diff) |
★
-rw-r--r-- | Allow-tiles-to-have-different-attributes-in-different-blocks-(including-X-and-Y-flip).md | 61 | ||||
-rw-r--r-- | screenshots/extra-tiles.png | bin | 0 -> 2871 bytes | |||
-rw-r--r-- | screenshots/polished-map-plusplus-edit-block.png | bin | 7879 -> 7960 bytes | |||
-rw-r--r-- | screenshots/polished-map-plusplus-extra-tiles.png | bin | 0 -> 8060 bytes |
4 files changed, 27 insertions, 34 deletions
diff --git a/Allow-tiles-to-have-different-attributes-in-different-blocks-(including-X-and-Y-flip).md b/Allow-tiles-to-have-different-attributes-in-different-blocks-(including-X-and-Y-flip).md index d3be068..c7a1b3a 100644 --- a/Allow-tiles-to-have-different-attributes-in-different-blocks-(including-X-and-Y-flip).md +++ b/Allow-tiles-to-have-different-attributes-in-different-blocks-(including-X-and-Y-flip).md @@ -1,3 +1,5 @@ +**Note:** You should [expand your tilesets](Expand-tilesets-from-192-to-255-tiles) before following this tutorial! (It's required for convenient map editing.) You should *not* [implement `PRIORITY` colors](Allow-map-tiles-to-appear-above-sprites-\(so-NPCs-can-walk-behind-tiles\)-with-PRIORITY-colors). (It's harmless but redundant; this tutorial will undo that work.) + Maps in pokecrystal are designed with blocks, not tiles, where each block (aka "metatile") is a 4x4 square of tiles. Each 8x8-pixel tile always has the same appearance in every block. But the GameBoy hardware is capable of more. The same tile graphic can be reused with different attributes—not just color, but X and Y flip, as well as "priority" to appear above sprites. For example, here's the `kanto` tileset. The tiles highlighted in fuchsia are just flipped or recolored copies of the ones highlighted in cyan, so by following this tutorial, you can eliminate all those tiles. And with the priority attribute, you can (for instance) let NPCs walk behind the roof tiles highlighted in yellow. (Although if that's all you want to do, just follow [the `PRIORITY` color tutorial](Allow-map-tiles-to-appear-above-sprites-\(so-NPCs-can-walk-behind-tiles\)-with-PRIORITY-colors).) @@ -20,7 +22,7 @@ This tutorial will show you how to switch from per-tile \*_palette_map.asm files 7. [Continue changing how tile attributes are loaded](#7-continue-changing-how-tile-attributes-are-loaded) 8. [Finish changing how tile attributes are loaded](#8-finish-changing-how-tile-attributes-are-loaded) 9. [Rename \*.blk to \*.ablk](#9-rename-blk-to-ablk) -10. [Remove unreferenced code in home/ to make room](#10-remove-unreferenced-code-in-home-to-make-room) +10. [Use more than 256 tiles in a tileset](#10-use-more-than-256-tiles-in-a-tileset) ## 1. Review how tilesets and VRAM work @@ -696,43 +698,19 @@ The `_LoadMapPart` routine initializes `wSurroundingTiles` with the relevant are ## 9. Rename \*.blk to \*.ablk -This has no effect on the ROM itself; it's just for convenience when using Polished Map++, as we'll see later. +We're almost done, but when we try to open a .blk file in Polished Map, it complains that the palette_map.asm file is missing. It can't read the new attributes.bin files. Until 2019, that would have forced us to design maps and tilesets in a hex editor, like savages. But now there's [Polished Map++](https://github.com/Rangi42/polished-map/tree/plusplus), a fork of Polished Map designed for these new files. There's just one thing left to change in our project for more convenient editing. Edit [data/maps/blocks.asm](../blob/master/data/maps/blocks.asm), replacing each occurrence of ".blk" with ".ablk". Then run this command in the terminal: ```bash -for f in maps/*.blk; do git mv $f ${f%.blk}.ablk; done +for f in maps/*.blk maps/**/*.blk; do git mv $f ${f%.blk}.ablk; done ``` -It will rename every \*.blk file to \*.ablk. - -(If you're not using Git, then just use `mv` instead of `git mv`.) - +It will rename every \*.blk file to \*.ablk. (If you're not using Git, then just use `mv` instead of `git mv`.) -## 10. Remove unreferenced code in home/ to make room - -We're almost done, but if you run `make` now, it gives an error: - -``` -error: Unable to place 'Home' (ROM0 section) at $150 -``` - -Turns out that our additions to [home/map.asm](../blob/master/home/map.asm) were too large to fit in ROM0. We'll need to remove something else from that bank to make room. Luckily, Game Freak left some unused code here and there, and it's all been labeled as `Unreferenced`. - -- `Unreferenced_Function2816` in [home/map.asm](../blob/master/home/map.asm) (again) -- `Unreferenced_Function3d9f` in [home/audio.asm](../blob/master/home/audio.asm) -- `Unreferenced_Function48c` in [home/fade.asm](../blob/master/home/fade.asm) -- `Unreferenced_Function547` in [home/lcd.asm](../blob/master/home/lcd.asm) -- `Unreferenced_Function19b8` in [home/map_objects.asm](../blob/master/home/map_objects.asm) -- `Unreferenced_Function1f9e` in [home/menu.asm](../blob/master/home/menu.asm) -- `Unreferenced_Function3ed7` and `Unreferenced_Function3efd` in [home/mobile.asm](../blob/master/home/mobile.asm) -- `Unreferenced_GetNthMove` in [home/mon_data.asm](../blob/master/home/mon_data.asm) -- `Unreferenced_GetDexNumber` in [home/mon_data_2.asm](../blob/master/home/mon_data_2.asm) -- `Unreferenced_Function919` in [home/serial.asm](../blob/master/home/serial.asm) -- `Unreferenced_Function1522` in [home/text.asm](../blob/master/home/text.asm) -- `Unreferenced_CheckBPressedDebug` and `Unreferenced_CheckFieldDebug` in [home.asm](../blob/master/home.asm) +This has no effect on the ROM itself; it's just so that we can have a clean separation of .blk files associated with Polished Map, and .ablk associated with Polished Map++. *Now* we're done! `make` works, and all the maps look the same as before—but now they're capable of looking very different. @@ -746,14 +724,12 @@ The same tiles can appear in different colors, like lit `YELLOW` and unlit `BROW  -(By the way, notice that tile $7F is the space character, but is also used as a solid white tile in maps. The [tileset expansion tutorial](Expand-tilesets-from-192-to-255-tiles) emphasizes that you shouldn't use tile $7F in maps because it will always be `TEXT`-colored, but with this block attribute system, that's no longer the case. So you don't need an extra white tile just for mapping.) +(Notice that tile $7F is still the space character, but is also used as a solid white tile in maps. The [tileset expansion tutorial](Expand-tilesets-from-192-to-255-tiles) emphasizes that you shouldn't use tile $7F in maps because it will always be `TEXT`-colored, but with this block attribute system, that's no longer the case. So you don't need an extra white tile just for mapping.) -Before 2019, this system would have had a major downside: no map editor support for attributes.bin files. You would have had to edit them directly in a hex editor, which is a pain in the neck. However, [Polished Map++](https://github.com/Rangi42/polished-map/tree/plusplus) now exists: a fork of Polished Map specifically for this system. For example, here's how that Goldenrod City map looks in it: +And here's how that map looks in Polished Map++: [](screenshots/polished-map-plusplus-goldenrod-city.png) -That's the reason why we renamed the .blk files to .ablk. You can install Polished Map and Polished Map++ side by side, associating Polished Map with standard .blk files and Polished Map++ with attribute.bin-enabled .ablk files. - Now when you edit blocks, you can assign attributes to their individual tiles: [](screenshots/polished-map-plusplus-edit-block.png) @@ -764,4 +740,21 @@ And the tileset itself is a colorless image: Note that Polished Map++ assumes you have also [expanded the tilesets to 255 tiles](Expand-tilesets-from-192-to-255-tiles). If you don't apply that tutorial, your maps will look incorrect. -The "★" checkbox in the block editor will even let you use *more* than 256 tiles: it changes the actual tile IDs from $00–$7F to $80–$FF, i.e. it uses the "font" and "NPC sprite" tiles instead of the map tiles. (Remember our review of how VRAM works.) However, Polished Map++ can't display those extra graphics, so it shows a cyan border around the tile instead. + +## 10. Use more than 256 tiles in a tileset + +If you were paying attention during the review of how VRAM works, you'll have noticed that technically a map can use 512 different tiles. The tile ID goes from 0 to 255, and the bank bit is 0 or 1; 256 × 2 = 512. But even Polished Map++ can only load 256 tile graphics at once. So how can we go beyond this? + +That's what the "★" checkbox in the block editor is for. It basically lets you use the tiles in the "middle" two areas of VRAM instead of the "bottom" two areas. Polished Map++ can't show the actual graphics in those middle areas—unless you modify how pokecrystal works, they'll just contain font tiles and NPC sprites anyway—but it draws a cyan border around a tile to indicate that it's special. + +Keep in mind that pokecrystal and Polished Map++ show tile IDs that aren't quite the same as the internal hardware. They all agree about tile IDs $00 to $7F, which are in VRAM bank 0, but the tiles that Polished Map++ calls $80 to $FF are actually encoded as $00 to $7F in bank 1. + +For example, here's a block that uses tiles $0F, $0A, $0C, and $0D with the "★" attribute: + + + +Those are actually tiles $8F, $8A, $8C, and $8D in bank 0. And those values in [charmap.asm](../blob/master/charmap.asm) correspond to the letters "P", "K", "M", and "N". Which is exactly what we see in the game: + + + +There are plenty of ways to take advantage of some of that VRAM real estate for maps, instead of text and sprites. But that's beyond the scope of this tutorial. ;) diff --git a/screenshots/extra-tiles.png b/screenshots/extra-tiles.png Binary files differnew file mode 100644 index 0000000..f06c1ad --- /dev/null +++ b/screenshots/extra-tiles.png diff --git a/screenshots/polished-map-plusplus-edit-block.png b/screenshots/polished-map-plusplus-edit-block.png Binary files differindex 4037759..98620ed 100644 --- a/screenshots/polished-map-plusplus-edit-block.png +++ b/screenshots/polished-map-plusplus-edit-block.png diff --git a/screenshots/polished-map-plusplus-extra-tiles.png b/screenshots/polished-map-plusplus-extra-tiles.png Binary files differnew file mode 100644 index 0000000..65de84f --- /dev/null +++ b/screenshots/polished-map-plusplus-extra-tiles.png |