summaryrefslogtreecommitdiff
path: root/Allow-map-tiles-to-appear-above-sprites.md
diff options
context:
space:
mode:
Diffstat (limited to 'Allow-map-tiles-to-appear-above-sprites.md')
-rw-r--r--Allow-map-tiles-to-appear-above-sprites.md124
1 files changed, 62 insertions, 62 deletions
diff --git a/Allow-map-tiles-to-appear-above-sprites.md b/Allow-map-tiles-to-appear-above-sprites.md
index b190cf5..5217d6d 100644
--- a/Allow-map-tiles-to-appear-above-sprites.md
+++ b/Allow-map-tiles-to-appear-above-sprites.md
@@ -36,17 +36,17 @@ Every tile on the screen has an attribute byte. The lowest three bits define the
Edit [constants/tileset_constants.asm](../blob/master/constants/tileset_constants.asm):
```diff
-; bg palette values (see gfx/tilesets/*_palette_map.asm)
-; TilesetBGPalette indexes (see gfx/tilesets/bg_tiles.pal)
- const_def
- const PAL_BG_GRAY ; 0
- const PAL_BG_RED ; 1
- const PAL_BG_GREEN ; 2
- const PAL_BG_WATER ; 3
- const PAL_BG_YELLOW ; 4
- const PAL_BG_BROWN ; 5
- const PAL_BG_ROOF ; 6
- const PAL_BG_TEXT ; 7
+ ; bg palette values (see gfx/tilesets/*_palette_map.asm)
+ ; TilesetBGPalette indexes (see gfx/tilesets/bg_tiles.pal)
+ const_def
+ const PAL_BG_GRAY ; 0
+ const PAL_BG_RED ; 1
+ const PAL_BG_GREEN ; 2
+ const PAL_BG_WATER ; 3
+ const PAL_BG_YELLOW ; 4
+ const PAL_BG_BROWN ; 5
+ const PAL_BG_ROOF ; 6
+ const PAL_BG_TEXT ; 7
+const_value set $80
+ const PAL_BG_PRIORITY_GRAY ; 80
@@ -69,18 +69,18 @@ But we can't just start using colors like `PRIORITY_RED` in the tilesets' palett
Edit [gfx/tilesets/palette_maps.asm](../blob/master/gfx/tilesets/palette_maps.asm):
```diff
-tilepal: MACRO
-; used in gfx/tilesets/*_palette_map.asm
-; vram bank, pals
-x = \1 << OAM_TILE_BANK
+ tilepal: MACRO
+ ; used in gfx/tilesets/*_palette_map.asm
+ ; vram bank, pals
+ x = \1 << OAM_TILE_BANK
-rept (_NARG +- 1) / 2
+rept _NARG +- 1
- dn (x | PAL_BG_\3), (x | PAL_BG_\2)
+ db (x | PAL_BG_\2)
- shift
- shift
-endr
-ENDM
+ shift
+ endr
+ ENDM
```
@@ -93,8 +93,8 @@ Edit each \_palette\_map.asm file:
```diff
-rept 16
+rept 32
- db $ff
-endr
+ db $ff
+ endr
```
@@ -106,19 +106,19 @@ Now the tileset palette data will take up twice as much space—one byte per til
-SECTION "bank13", ROMX
+SECTION "Tileset Palettes", ROMX
-INCLUDE "engine/map_palettes.asm"
-INCLUDE "gfx/tilesets/palette_maps.asm"
+ INCLUDE "engine/map_palettes.asm"
+ INCLUDE "gfx/tilesets/palette_maps.asm"
+
+
+SECTION "bank13", ROMX
+
-INCLUDE "data/collision_permissions.asm"
-INCLUDE "engine/routines/emptyallsrambanks.asm"
-INCLUDE "engine/routines/savemenu_copytilemapatonce.asm"
-INCLUDE "engine/routines/checksave.asm"
-INCLUDE "data/maps/scenes.asm"
-INCLUDE "engine/routines/loadmappart.asm"
-INCLUDE "engine/routines/phonering_copytilemapatonce.asm"
+ INCLUDE "data/collision_permissions.asm"
+ INCLUDE "engine/routines/emptyallsrambanks.asm"
+ INCLUDE "engine/routines/savemenu_copytilemapatonce.asm"
+ INCLUDE "engine/routines/checksave.asm"
+ INCLUDE "data/maps/scenes.asm"
+ INCLUDE "engine/routines/loadmappart.asm"
+ INCLUDE "engine/routines/phonering_copytilemapatonce.asm"
```
Since we don't specify a bank for "Tileset Palettes" in [pokecrystal.link](../blob/master/pokecrystal.link), rgblink will place it in any bank that has enough room.
@@ -129,13 +129,13 @@ Since we don't specify a bank for "Tileset Palettes" in [pokecrystal.link](../bl
Edit [engine/map_palettes.asm](../blob/master/engine/map_palettes.asm):
```diff
-SwapTextboxPalettes:: ; 4c000
- hlcoord 0, 0
- decoord 0, 0, wAttrMap
- ld b, SCREEN_HEIGHT
-.loop
- push bc
- ld c, SCREEN_WIDTH
+ SwapTextboxPalettes:: ; 4c000
+ hlcoord 0, 0
+ decoord 0, 0, wAttrMap
+ ld b, SCREEN_HEIGHT
+ .loop
+ push bc
+ ld c, SCREEN_WIDTH
+ call GetBGMapTilePalettes
-.innerloop
- ld a, [hl]
@@ -171,30 +171,30 @@ SwapTextboxPalettes:: ; 4c000
- inc de
- dec c
- jr nz, .innerloop
- pop bc
- dec b
- jr nz, .loop
- ret
-
-ScrollBGMapPalettes:: ; 4c03f
- ld hl, wBGMapBuffer
- ld de, wBGMapPalBuffer
+ pop bc
+ dec b
+ jr nz, .loop
+ ret
+
+ ScrollBGMapPalettes:: ; 4c03f
+ ld hl, wBGMapBuffer
+ ld de, wBGMapPalBuffer
+ ; fallthrough
+GetBGMapTilePalettes:
-.loop
- ld a, [hl]
- push hl
+ .loop
+ ld a, [hl]
+ push hl
- srl a
- jr c, .UpperNybble
-
-; .LowerNybble
- ld hl, wTilesetPalettes
- add [hl]
- ld l, a
- ld a, [wTilesetPalettes + 1]
- adc 0
- ld h, a
- ld a, [hl]
+ ld hl, wTilesetPalettes
+ add [hl]
+ ld l, a
+ ld a, [wTilesetPalettes + 1]
+ adc 0
+ ld h, a
+ ld a, [hl]
- and $f
- jr .next
-
@@ -210,14 +210,14 @@ ScrollBGMapPalettes:: ; 4c03f
- and $f
-
-.next
- pop hl
- ld [de], a
- res 7, [hl]
- inc hl
- inc de
- dec c
- jr nz, .loop
- ret
+ pop hl
+ ld [de], a
+ res 7, [hl]
+ inc hl
+ inc de
+ dec c
+ jr nz, .loop
+ ret
```
Notice how `SwapTextboxPalettes` now reuses the loop it shares with `ScrollBGMapPalettes`, and then the whole decision of which nybble to read is no longer necessary because the whole byte defines one tile's attributes.