ref: a77999f7f151567a47dd69affe9a29378f298ff4
parent: 6137f5accb77db2d5d07df2f058e85115caf073c
author: Rangi <[email protected]>
date: Sun Jul 5 12:15:01 EDT 2020
Logical spacing in data/sgb/sgb_palettes.asm
--- a/constants/gfx_constants.asm
+++ b/constants/gfx_constants.asm
@@ -1,15 +1,20 @@
+TILE_WIDTH EQU 8 ; pixels
+LEN_1BPP_TILE EQU 1 * TILE_WIDTH ; bytes
+LEN_2BPP_TILE EQU 2 * TILE_WIDTH ; bytes
+
+NUM_PAL_COLORS EQU 4
+PAL_COLOR_SIZE EQU 2
+PALETTE_SIZE EQU NUM_PAL_COLORS * PAL_COLOR_SIZE
+
SCREEN_WIDTH EQU 20
SCREEN_HEIGHT EQU 18
+SCREEN_WIDTH_PX EQU SCREEN_WIDTH * TILE_WIDTH ; pixels
+SCREEN_HEIGHT_PX EQU SCREEN_HEIGHT * TILE_WIDTH ; pixels
-SCREEN_WIDTH_PIXELS EQU SCREEN_WIDTH * 8
-SCREEN_HEIGHT_PIXELS EQU SCREEN_HEIGHT * 8
+BG_MAP_WIDTH EQU 32 ; tiles
+BG_MAP_HEIGHT EQU 32 ; tiles
-BYTES_PER_TILE EQU 16
-
-BG_MAP_WIDTH EQU 32
-BG_MAP_HEIGHT EQU 32
-
-SPRITEBUFFERSIZE EQU 7*7 * 8 ; 7 * 7 (tiles) * 8 (bytes per tile)
+SPRITEBUFFERSIZE EQU 7 * 7 * LEN_1BPP_TILE
; HP bar
HP_BAR_GREEN EQU 0
--- a/data/sgb/sgb_palettes.asm
+++ b/data/sgb/sgb_palettes.asm
@@ -1,174 +1,50 @@
-; palettes for overworlds, title screen, monsters
SuperPalettes:
- RGB 31,29,31 ; PAL_ROUTE
- RGB 21,28,11
- RGB 20,26,31
- RGB 3,2,2
- RGB 31,29,31 ; PAL_PALLET
- RGB 25,28,27
- RGB 20,26,31
- RGB 3,2,2
- RGB 31,29,31 ; PAL_VIRIDIAN
- RGB 17,26,3
- RGB 20,26,31
- RGB 3,2,2
- RGB 31,29,31 ; PAL_PEWTER
- RGB 23,25,16
- RGB 20,26,31
- RGB 3,2,2
- RGB 31,29,31 ; PAL_CERULEAN
- RGB 17,20,30
- RGB 20,26,31
- RGB 3,2,2
- RGB 31,29,31 ; PAL_LAVENDER
- RGB 27,20,27
- RGB 20,26,31
- RGB 3,2,2
- RGB 31,29,31 ; PAL_VERMILION
- RGB 30,18,0
- RGB 20,26,31
- RGB 3,2,2
- RGB 31,29,31 ; PAL_CELADON
- RGB 16,30,22
- RGB 20,26,31
- RGB 3,2,2
- RGB 31,29,31 ; PAL_FUCHSIA
- RGB 31,15,22
- RGB 20,26,31
- RGB 3,2,2
- RGB 31,29,31 ; PAL_CINNABAR
- RGB 26,10,6
- RGB 20,26,31
- RGB 3,2,2
- RGB 31,29,31 ; PAL_INDIGO
- RGB 22,14,24
- RGB 20,26,31
- RGB 3,2,2
- RGB 31,29,31 ; PAL_SAFFRON
- RGB 27,27,3
- RGB 20,26,31
- RGB 3,2,2
- RGB 31,29,31 ; PAL_TOWNMAP
- RGB 20,26,31
- RGB 17,23,10
- RGB 3,2,2
+ RGB 31,29,31, 21,28,11, 20,26,31, 03,02,02 ; PAL_ROUTE
+ RGB 31,29,31, 25,28,27, 20,26,31, 03,02,02 ; PAL_PALLET
+ RGB 31,29,31, 17,26,03, 20,26,31, 03,02,02 ; PAL_VIRIDIAN
+ RGB 31,29,31, 23,25,16, 20,26,31, 03,02,02 ; PAL_PEWTER
+ RGB 31,29,31, 17,20,30, 20,26,31, 03,02,02 ; PAL_CERULEAN
+ RGB 31,29,31, 27,20,27, 20,26,31, 03,02,02 ; PAL_LAVENDER
+ RGB 31,29,31, 30,18,00, 20,26,31, 03,02,02 ; PAL_VERMILION
+ RGB 31,29,31, 16,30,22, 20,26,31, 03,02,02 ; PAL_CELADON
+ RGB 31,29,31, 31,15,22, 20,26,31, 03,02,02 ; PAL_FUCHSIA
+ RGB 31,29,31, 26,10,06, 20,26,31, 03,02,02 ; PAL_CINNABAR
+ RGB 31,29,31, 22,14,24, 20,26,31, 03,02,02 ; PAL_INDIGO
+ RGB 31,29,31, 27,27,03, 20,26,31, 03,02,02 ; PAL_SAFFRON
+ RGB 31,29,31, 20,26,31, 17,23,10, 03,02,02 ; PAL_TOWNMAP
IF DEF(_RED)
- RGB 31,29,31 ; PAL_LOGO1
- RGB 30,30,17
- RGB 17,23,10
- RGB 21,0,4
+ RGB 31,29,31, 30,30,17, 17,23,10, 21,00,04 ; PAL_LOGO1
ENDC
IF DEF(_BLUE)
- RGB 31,29,31 ; PAL_LOGO1
- RGB 30,30,17
- RGB 21,0,4
- RGB 14,19,29
+ RGB 31,29,31, 30,30,17, 21,00,04, 14,19,29 ; PAL_LOGO1
ENDC
- RGB 31,29,31 ; PAL_LOGO2
- RGB 30,30,17
- RGB 18,18,24
- RGB 7,7,16
- RGB 31,29,31 ; PAL_0F
- RGB 24,20,30
- RGB 11,20,30
- RGB 3,2,2
- RGB 31,29,31 ; PAL_MEWMON
- RGB 30,22,17
- RGB 16,14,19
- RGB 3,2,2
- RGB 31,29,31 ; PAL_BLUEMON
- RGB 18,20,27
- RGB 11,15,23
- RGB 3,2,2
- RGB 31,29,31 ; PAL_REDMON
- RGB 31,20,10
- RGB 26,10,6
- RGB 3,2,2
- RGB 31,29,31 ; PAL_CYANMON
- RGB 21,25,29
- RGB 14,19,25
- RGB 3,2,2
- RGB 31,29,31 ; PAL_PURPLEMON
- RGB 27,22,24
- RGB 21,15,23
- RGB 3,2,2
- RGB 31,29,31 ; PAL_BROWNMON
- RGB 28,20,15
- RGB 21,14,9
- RGB 3,2,2
- RGB 31,29,31 ; PAL_GREENMON
- RGB 20,26,16
- RGB 9,20,11
- RGB 3,2,2
- RGB 31,29,31 ; PAL_PINKMON
- RGB 30,22,24
- RGB 28,15,21
- RGB 3,2,2
- RGB 31,29,31 ; PAL_YELLOWMON
- RGB 31,28,14
- RGB 26,20,0
- RGB 3,2,2
- RGB 31,29,31 ; PAL_GREYMON
- RGB 26,21,22
- RGB 15,15,18
- RGB 3,2,2
- RGB 31,29,31 ; PAL_SLOTS1
- RGB 26,21,22
- RGB 27,20,6
- RGB 3,2,2
- RGB 31,29,31 ; PAL_SLOTS2
- RGB 31,31,17
+ RGB 31,29,31, 30,30,17, 18,18,24, 07,07,16 ; PAL_LOGO2
+ RGB 31,29,31, 24,20,30, 11,20,30, 03,02,02 ; PAL_0F
+ RGB 31,29,31, 30,22,17, 16,14,19, 03,02,02 ; PAL_MEWMON
+ RGB 31,29,31, 18,20,27, 11,15,23, 03,02,02 ; PAL_BLUEMON
+ RGB 31,29,31, 31,20,10, 26,10,06, 03,02,02 ; PAL_REDMON
+ RGB 31,29,31, 21,25,29, 14,19,25, 03,02,02 ; PAL_CYANMON
+ RGB 31,29,31, 27,22,24, 21,15,23, 03,02,02 ; PAL_PURPLEMON
+ RGB 31,29,31, 28,20,15, 21,14,09, 03,02,02 ; PAL_BROWNMON
+ RGB 31,29,31, 20,26,16, 09,20,11, 03,02,02 ; PAL_GREENMON
+ RGB 31,29,31, 30,22,24, 28,15,21, 03,02,02 ; PAL_PINKMON
+ RGB 31,29,31, 31,28,14, 26,20,00, 03,02,02 ; PAL_YELLOWMON
+ RGB 31,29,31, 26,21,22, 15,15,18, 03,02,02 ; PAL_GREYMON
+ RGB 31,29,31, 26,21,22, 27,20,06, 03,02,02 ; PAL_SLOTS1
IF DEF(_RED)
- RGB 25,17,21
+ RGB 31,29,31, 31,31,17, 25,17,21, 03,02,02 ; PAL_SLOTS2
+ RGB 31,29,31, 22,31,16, 25,17,21, 03,02,02 ; PAL_SLOTS3
+ RGB 31,29,31, 16,19,29, 25,17,21, 03,02,02 ; PAL_SLOTS4
ENDC
IF DEF(_BLUE)
- RGB 16,19,29
+ RGB 31,29,31, 31,31,17, 16,19,29, 03,02,02 ; PAL_SLOTS2
+ RGB 31,29,31, 22,31,16, 16,19,29, 03,02,02 ; PAL_SLOTS3
+ RGB 31,29,31, 25,17,21, 16,19,29, 03,02,02 ; PAL_SLOTS4
ENDC
- RGB 3,2,2
- RGB 31,29,31 ; PAL_SLOTS3
- RGB 22,31,16
-IF DEF(_RED)
- RGB 25,17,21
-ENDC
-IF DEF(_BLUE)
- RGB 16,19,29
-ENDC
- RGB 3,2,2
- RGB 31,29,31 ; PAL_SLOTS4
-IF DEF(_RED)
- RGB 16,19,29
- RGB 25,17,21
-ENDC
-IF DEF(_BLUE)
- RGB 25,17,21
- RGB 16,19,29
-ENDC
- RGB 3,2,2
- RGB 31,29,31 ; PAL_BLACK
- RGB 7,7,7
- RGB 2,3,3
- RGB 3,2,2
- RGB 31,29,31 ; PAL_GREENBAR
- RGB 30,26,15
- RGB 9,20,11
- RGB 3,2,2
- RGB 31,29,31 ; PAL_YELLOWBAR
- RGB 30,26,15
- RGB 26,20,0
- RGB 3,2,2
- RGB 31,29,31 ; PAL_REDBAR
- RGB 30,26,15
- RGB 26,10,6
- RGB 3,2,2
- RGB 31,29,31 ; PAL_BADGE
- RGB 30,22,17
- RGB 11,15,23
- RGB 3,2,2
- RGB 31,29,31 ; PAL_CAVE
- RGB 21,14,9
- RGB 18,24,22
- RGB 3,2,2
- RGB 31,29,31 ; PAL_GAMEFREAK
- RGB 31,28,14
- RGB 24,20,10
- RGB 3,2,2
+ RGB 31,29,31, 07,07,07, 02,03,03, 03,02,02 ; PAL_BLACK
+ RGB 31,29,31, 30,26,15, 09,20,11, 03,02,02 ; PAL_GREENBAR
+ RGB 31,29,31, 30,26,15, 26,20,00, 03,02,02 ; PAL_YELLOWBAR
+ RGB 31,29,31, 30,26,15, 26,10,06, 03,02,02 ; PAL_REDBAR
+ RGB 31,29,31, 30,22,17, 11,15,23, 03,02,02 ; PAL_BADGE
+ RGB 31,29,31, 21,14,09, 18,24,22, 03,02,02 ; PAL_CAVE
+ RGB 31,29,31, 31,28,14, 24,20,10, 03,02,02 ; PAL_GAMEFREAK
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -1838,10 +1838,10 @@
call Delay3
xor a
ld [hAutoBGTransferEnabled], a
- ld a, SCREEN_HEIGHT_PIXELS
+ ld a, SCREEN_HEIGHT_PX
ld [hWY], a
ld d, $80 ; terminator
- ld e, SCREEN_HEIGHT_PIXELS - 1
+ ld e, SCREEN_HEIGHT_PX - 1
ld c, $ff
ld hl, WavyScreenLineOffsets
.loop
@@ -2538,7 +2538,7 @@
; Now that the regular BG is showing the same thing the window was, move the
; window off the screen so that we can modify its contents below.
- ld a, SCREEN_HEIGHT_PIXELS
+ ld a, SCREEN_HEIGHT_PX
ld [hWY], a
; Copy wTileMap to VRAM such that the row below the enemy HUD (in wTileMap) is
@@ -2575,7 +2575,7 @@
; Restore the original graphics.
call AnimationShowMonPic
call ClearSprites
- ld a, SCREEN_HEIGHT_PIXELS
+ ld a, SCREEN_HEIGHT_PX
ld [hWY], a
ld hl, vBGMap1
call BattleAnimCopyTileMapToVRAM
--- a/engine/movie/intro.asm
+++ b/engine/movie/intro.asm
@@ -97,7 +97,7 @@
; hip
ld a, SFX_INTRO_HIP
call PlaySound
- ld a, (FightIntroFrontMon2 - FightIntroFrontMon) / BYTES_PER_TILE
+ ld a, (FightIntroFrontMon2 - FightIntroFrontMon) / LEN_2BPP_TILE
ld [wIntroNidorinoBaseTile], a
ld de, IntroNidorinoAnimation3
call AnimateIntroNidorino
@@ -129,7 +129,7 @@
call CheckForUserInterruption
ret c
- ld a, (FightIntroFrontMon2 - FightIntroFrontMon) / BYTES_PER_TILE
+ ld a, (FightIntroFrontMon2 - FightIntroFrontMon) / LEN_2BPP_TILE
ld [wIntroNidorinoBaseTile], a
ld de, IntroNidorinoAnimation6
call AnimateIntroNidorino
@@ -140,7 +140,7 @@
; lunge
ld a, SFX_INTRO_LUNGE
call PlaySound
- ld a, (FightIntroFrontMon3 - FightIntroFrontMon) / BYTES_PER_TILE
+ ld a, (FightIntroFrontMon3 - FightIntroFrontMon) / LEN_2BPP_TILE
ld [wIntroNidorinoBaseTile], a
ld de, IntroNidorinoAnimation7
jp AnimateIntroNidorino
--- a/engine/movie/title.asm
+++ b/engine/movie/title.asm
@@ -189,7 +189,7 @@
; scroll game version in from the right
call PrintGameVersionOnTitleScreen
- ld a, SCREEN_HEIGHT_PIXELS
+ ld a, SCREEN_HEIGHT_PX
ld [hWY], a
ld d, 144
.scrollTitleScreenGameVersionLoop
--- a/engine/overworld/clear_variables.asm
+++ b/engine/overworld/clear_variables.asm
@@ -1,5 +1,5 @@
ClearVariablesOnEnterMap::
- ld a, SCREEN_HEIGHT_PIXELS
+ ld a, SCREEN_HEIGHT_PX
ld [hWY], a
ld [rWY], a
xor a
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -37,7 +37,7 @@
call GBPalWhiteOutWithDelay3
call ClearSprites
call RestoreScreenTilesAndReloadTilePatterns
- ld a, SCREEN_HEIGHT_PIXELS
+ ld a, SCREEN_HEIGHT_PX
ld [hWY], a
call Delay3
call LoadGBPal
--- a/macros.asm
+++ b/macros.asm
@@ -3,6 +3,7 @@
INCLUDE "macros/farcall.asm"
INCLUDE "macros/data.asm"
INCLUDE "macros/code.asm"
+INCLUDE "macros/gfx.asm"
INCLUDE "macros/coords.asm"
INCLUDE "macros/scripts/audio.asm"
--- a/macros/data.asm
+++ b/macros/data.asm
@@ -16,10 +16,6 @@
coins equs "bcd2"
money equs "bcd3"
-RGB: MACRO
- dw (\3 << 10 | \2 << 5 | \1)
-ENDM
-
tmlearn: MACRO
x = 0
REPT _NARG
--- /dev/null
+++ b/macros/gfx.asm
@@ -1,0 +1,17 @@
+RGB: MACRO
+rept _NARG / 3
+ dw palred (\1) + palgreen (\2) + palblue (\3)
+ shift 3
+endr
+ENDM
+
+palred EQUS "(1 << 0) *"
+palgreen EQUS "(1 << 5) *"
+palblue EQUS "(1 << 10) *"
+
+palettes EQUS "* PALETTE_SIZE"
+palette EQUS "+ PALETTE_SIZE *"
+color EQUS "+ PAL_COLOR_SIZE *"
+
+tiles EQUS "* LEN_2BPP_TILE"
+tile EQUS "+ LEN_2BPP_TILE *"