summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Make-Overhead-Tiles.md102
1 files changed, 102 insertions, 0 deletions
diff --git a/Make-Overhead-Tiles.md b/Make-Overhead-Tiles.md
new file mode 100644
index 0000000..569d40b
--- /dev/null
+++ b/Make-Overhead-Tiles.md
@@ -0,0 +1,102 @@
+Step 1: Add these definitions to constants/tilemap_constants.asm:
+
+ const_value SET $80
+ const PAL_BG_PRIORITY_GRAY ; 80
+ const PAL_BG_PRIORITY_RED ; 81
+ const PAL_BG_PRIORITY_GREEN ; 82
+ const PAL_BG_PRIORITY_WATER ; 83
+ const PAL_BG_PRIORITY_YELLOW ; 84
+ const PAL_BG_PRIORITY_BROWN ; 85
+ const PAL_BG_PRIORITY_ROOF ; 86
+ const PAL_BG_PRIORITY_TEXT ; 87
+
+Step 2: Edit macros/pals.asm.
+
+Replace this:
+
+ tilepal: MACRO
+ ; vram bank, pals
+ x = \1 << 3
+ rept (_NARG +- 1) / 2
+ dn (x | PAL_BG_\3), (x | PAL_BG_\2)
+ shift
+ shift
+ endr
+ endm
+
+with this:
+
+ tilepal: MACRO
+ ; vram bank, pals
+ x = \1 << 3
+ rept _NARG +- 1
+ db (x | PAL_BG_\2)
+ shift
+ endr
+ endm
+
+Now the tileset palette data will take up twice as much space—one byte per tile instead of half a byte—but you'll be able to use, for example, PRIORITY_GRAY instead of GRAY to define an overhead tile.
+
+Step 3: Edit main.asm's SwapTextboxPalettes and ScrollBGMapPalettes.
+
+These two routines read the tileset palette data, so they have to be updated to understand the new one-byte-per-tile format. While we're at it, we can also factor out a large chunk of identical code from both of them into its own subroutine.
+
+Replace all of this:
+
+ SwapTextboxPalettes:: ; 4c000
+ hlcoord 0, 0
+ decoord 0, 0, AttrMap
+ ...
+ ret
+
+ ScrollBGMapPalettes:: ; 4c03f
+ ld hl, BGMapBuffer
+ ld de, BGMapPalBuffer
+ ...
+ ret
+
+With this:
+
+ SwapTextboxPalettes:: ; 4c000
+ hlcoord 0, 0
+ decoord 0, 0, AttrMap
+ ld b, SCREEN_HEIGHT
+ .loop
+ push bc
+ ld c, SCREEN_WIDTH
+ call GetBGMapTilePalettes
+ pop bc
+ dec b
+ jr nz, .loop
+ ret
+
+ ScrollBGMapPalettes:: ; 4c03f
+ ld hl, BGMapBuffer
+ ld de, BGMapPalBuffer
+ ; don't call GetBGMapTilePalettes and ret, just fallthrough
+
+ GetBGMapTilePalettes:
+ .loop
+ ld a, [hl]
+ push hl
+ ld hl, TilesetPalettes
+ add [hl]
+ ld l, a
+ ld a, [TilesetPalettes + 1]
+ adc $0
+ ld h, a
+ ld a, [hl]
+ pop hl
+ ld [de], a
+ res 7, [hl]
+ inc hl
+ inc de
+ dec c
+ jr nz, .loop
+ ret
+
+(Notice how the common code has been moved into GetBGMapTilePalettes, and then the whole decision of which nybble to read is no longer necessary because the whole byte is needed.)
+
+Anyway—at this point you are done! Now when you edit a palette_map.asm file, you can use the names PRIORITY_GRAY, PRIORITY_BROWN, etc instead of just GRAY, BROWN, etc, and the tile will appear above any NPC. However, the lightest hue (that is, white when you're editing the monochrome tileset graphic) will be transparent. That's how tall grass works: you see only the parts of the player sprite that overlap "white" pixels (actually light green, using the standard outdoor color palette.) You'll notice in the Magnet Train example above, I designed the overhead tracks to use only the three darker hues.
+
+(See original thread this tutorial comes from [here](https://hax.iimarckus.org/topic/7268/).) \ No newline at end of file