Improve use of palette macro and use PAL_* constants (#1087)

* Improve use of palette macro and use PAL_* constants

* Use proper constant for battle stats (#1088)

* Add suggestions about function names and variables

* Add colors macro

---------

Co-authored-by: vulcandth <vulcandth@gmail.com>
This commit is contained in:
Idain
2023-11-17 14:24:09 -04:00
committed by GitHub
parent 75f0ad3955
commit 2907d65a47
9 changed files with 40 additions and 39 deletions

View File

@@ -2076,10 +2076,10 @@ BattleBGEffect_FadeMonsToBlackRepeating:
add hl, de add hl, de
ld a, [hli] ld a, [hli]
push hl push hl
call BGEffects_LoadBGPal1_OBPal0 call BGEffects_LoadEnemyPals
pop hl pop hl
ld a, [hl] ld a, [hl]
call BGEffects_LoadBGPal0_OBPal1 call BGEffects_LoadPlayerPals
ret ret
.player_2 .player_2
@@ -2087,17 +2087,17 @@ BattleBGEffect_FadeMonsToBlackRepeating:
add hl, de add hl, de
ld a, [hli] ld a, [hli]
push hl push hl
call BGEffects_LoadBGPal0_OBPal1 call BGEffects_LoadPlayerPals
pop hl pop hl
ld a, [hl] ld a, [hl]
call BGEffects_LoadBGPal1_OBPal0 call BGEffects_LoadEnemyPals
ret ret
.cgb_two .cgb_two
ld a, $e4 ld a, $e4
call BGEffects_LoadBGPal0_OBPal1 call BGEffects_LoadPlayerPals
ld a, $e4 ld a, $e4
call BGEffects_LoadBGPal1_OBPal0 call BGEffects_LoadEnemyPals
call EndBattleBGEffect call EndBattleBGEffect
ret ret
@@ -2507,7 +2507,7 @@ BGEffect_RapidCyclePals:
ld [hl], a ld [hl], a
call BattleBGEffect_GetFirstDMGPal call BattleBGEffect_GetFirstDMGPal
jr c, .okay_2_cgb jr c, .okay_2_cgb
call BGEffects_LoadBGPal0_OBPal1 call BGEffects_LoadPlayerPals
ret ret
.okay_2_cgb .okay_2_cgb
@@ -2518,7 +2518,7 @@ BGEffect_RapidCyclePals:
.two_cgb .two_cgb
ld a, $e4 ld a, $e4
call BGEffects_LoadBGPal0_OBPal1 call BGEffects_LoadPlayerPals
call EndBattleBGEffect call EndBattleBGEffect
ret ret
@@ -2538,7 +2538,7 @@ BGEffect_RapidCyclePals:
ld [hl], a ld [hl], a
call BattleBGEffect_GetFirstDMGPal call BattleBGEffect_GetFirstDMGPal
jr c, .okay_4_cgb jr c, .okay_4_cgb
call BGEffects_LoadBGPal1_OBPal0 call BGEffects_LoadEnemyPals
ret ret
.okay_4_cgb .okay_4_cgb
@@ -2549,11 +2549,11 @@ BGEffect_RapidCyclePals:
.four_cgb .four_cgb
ld a, $e4 ld a, $e4
call BGEffects_LoadBGPal1_OBPal0 call BGEffects_LoadEnemyPals
call EndBattleBGEffect call EndBattleBGEffect
ret ret
BGEffects_LoadBGPal0_OBPal1: BGEffects_LoadPlayerPals:
ld h, a ld h, a
ldh a, [rSVBK] ldh a, [rSVBK]
push af push af
@@ -2562,13 +2562,13 @@ BGEffects_LoadBGPal0_OBPal1:
ld a, h ld a, h
push bc push bc
push af push af
ld hl, wBGPals2 ld hl, wBGPals2 palette PAL_BATTLE_BG_PLAYER
ld de, wBGPals1 ld de, wBGPals1 palette PAL_BATTLE_BG_PLAYER
ld b, a ld b, a
ld c, $1 ld c, $1
call CopyPals call CopyPals
ld hl, wOBPals2 palette 1 ld hl, wOBPals2 palette PAL_BATTLE_OB_PLAYER
ld de, wOBPals1 palette 1 ld de, wOBPals1 palette PAL_BATTLE_OB_PLAYER
pop af pop af
ld b, a ld b, a
ld c, $1 ld c, $1
@@ -2580,7 +2580,7 @@ BGEffects_LoadBGPal0_OBPal1:
ldh [hCGBPalUpdate], a ldh [hCGBPalUpdate], a
ret ret
BGEffects_LoadBGPal1_OBPal0: BGEffects_LoadEnemyPals:
ld h, a ld h, a
ldh a, [rSVBK] ldh a, [rSVBK]
push af push af
@@ -2589,13 +2589,13 @@ BGEffects_LoadBGPal1_OBPal0:
ld a, h ld a, h
push bc push bc
push af push af
ld hl, wBGPals2 palette 1 ld hl, wBGPals2 palette PAL_BATTLE_BG_ENEMY
ld de, wBGPals1 palette 1 ld de, wBGPals1 palette PAL_BATTLE_BG_ENEMY
ld b, a ld b, a
ld c, $1 ld c, $1
call CopyPals call CopyPals
ld hl, wOBPals2 ld hl, wOBPals2 palette PAL_BATTLE_OB_ENEMY
ld de, wOBPals1 ld de, wOBPals1 palette PAL_BATTLE_OB_ENEMY
pop af pop af
ld b, a ld b, a
ld c, $1 ld c, $1

View File

@@ -729,7 +729,7 @@ CGBCopyBattleObjectPals: ; unreferenced
dec c dec c
jr nz, .loop jr nz, .loop
ld hl, BattleObjectPals ld hl, BattleObjectPals
ld de, wOBPals1 palette 2 ld de, wOBPals1 palette PAL_BATTLE_OB_GRAY
ld bc, 2 palettes ld bc, 2 palettes
ld a, BANK(wOBPals1) ld a, BANK(wOBPals1)
call FarCopyWRAM call FarCopyWRAM

View File

@@ -124,7 +124,7 @@ Palette_TextBG7:
INCLUDE "gfx/font/bg_text.pal" INCLUDE "gfx/font/bg_text.pal"
Function49420:: Function49420::
ld hl, MansionPalette1 + 8 palettes ld hl, MansionPalette1 palette 8
ld de, wBGPals1 palette PAL_BG_ROOF ld de, wBGPals1 palette PAL_BG_ROOF
ld bc, 1 palettes ld bc, 1 palettes
ld a, BANK(wBGPals1) ld a, BANK(wBGPals1)

View File

@@ -168,14 +168,14 @@ FillWhiteBGColor:
ld e, a ld e, a
ld a, [hli] ld a, [hli]
ld d, a ld d, a
ld hl, wBGPals1 + 1 palettes ld hl, wBGPals1 palette 1 color 0
ld c, 6 ld c, 6
.loop .loop
ld a, e ld a, e
ld [hli], a ld [hli], a
ld a, d ld a, d
ld [hli], a ld [hli], a
rept 6 rept 3 colors
inc hl inc hl
endr endr
dec c dec c

View File

@@ -22,6 +22,7 @@ DEF palblue EQUS "(1 << 10) *"
DEF palettes EQUS "* PALETTE_SIZE" DEF palettes EQUS "* PALETTE_SIZE"
DEF palette EQUS "+ PALETTE_SIZE *" DEF palette EQUS "+ PALETTE_SIZE *"
DEF color EQUS "+ PAL_COLOR_SIZE *" DEF color EQUS "+ PAL_COLOR_SIZE *"
DEF colors EQUS "* PAL_COLOR_SIZE"
DEF tiles EQUS "* LEN_2BPP_TILE" DEF tiles EQUS "* LEN_2BPP_TILE"
DEF tile EQUS "+ LEN_2BPP_TILE *" DEF tile EQUS "+ LEN_2BPP_TILE *"

View File

@@ -641,7 +641,7 @@ Function894dc:
ld bc, 3 palettes ld bc, 3 palettes
call CopyBytes call CopyBytes
ld hl, .Pals345 ld hl, .Pals345
ld de, wBGPals1 + 3 palettes ld de, wBGPals1 palette 3
ld bc, 3 palettes ld bc, 3 palettes
call CopyBytes call CopyBytes
@@ -2056,7 +2056,7 @@ Function89d0d:
jr nz, .loop jr nz, .loop
ld hl, .Palette2 ld hl, .Palette2
ld de, wBGPals1 + 2 palettes ld de, wBGPals1 palette 2
ld bc, 1 palettes ld bc, 1 palettes
call CopyBytes call CopyBytes
@@ -3232,7 +3232,7 @@ Function8a5b6:
ld a, $5 ld a, $5
ldh [rSVBK], a ldh [rSVBK], a
ld hl, Palette_8a5e5 ld hl, Palette_8a5e5
ld de, wBGPals1 + 4 palettes ld de, wBGPals1 palette 4
ld bc, 3 palettes ld bc, 3 palettes
call CopyBytes call CopyBytes
ld hl, Palette_8a5fd ld hl, Palette_8a5fd
@@ -3240,7 +3240,7 @@ Function8a5b6:
ld bc, 1 palettes ld bc, 1 palettes
call CopyBytes call CopyBytes
ld hl, Palette_8a605 ld hl, Palette_8a605
ld de, wOBPals1 + 1 palettes ld de, wOBPals1 palette 1
ld bc, 1 palettes ld bc, 1 palettes
call CopyBytes call CopyBytes
pop af pop af

View File

@@ -975,7 +975,7 @@ MobileTradeAnim_GiveTrademon1:
MobileTradeAnim_GiveTrademon2: MobileTradeAnim_GiveTrademon2:
ld c, 40 ld c, 40
ld hl, wBGPals2 + 1 palettes ld hl, wBGPals2 palette 1
call Function1082f0 call Function1082f0
call Function108af4 call Function108af4
call Function108b5a call Function108b5a
@@ -1069,12 +1069,12 @@ MobileTradeAnim_GetTrademon1:
MobileTradeAnim_GetTrademon2: MobileTradeAnim_GetTrademon2:
ld c, 20 ld c, 20
ld hl, wBGPals2 + 1 palettes ld hl, wBGPals2 palette 1
call Function1082fa call Function1082fa
ld de, SFX_GIVE_TRADEMON ld de, SFX_GIVE_TRADEMON
call PlaySFX call PlaySFX
ld c, 20 ld c, 20
ld hl, wBGPals2 + 1 palettes ld hl, wBGPals2 palette 1
call Function1082fa call Function1082fa
call Function108af4 call Function108af4
.asm_1088ad .asm_1088ad
@@ -1439,8 +1439,8 @@ Function108b5a:
ld a, $5 ld a, $5
ldh [rSVBK], a ldh [rSVBK], a
ld de, palred 18 + palgreen 31 + palblue 15 ld de, palred 18 + palgreen 31 + palblue 15
ld hl, wBGPals2 + 4 palettes ld hl, wBGPals2 palette 4
ld c, $10 ld c, 2 palettes
.loop .loop
ld a, e ld a, e
ld [hli], a ld [hli], a
@@ -1491,13 +1491,13 @@ Function108b98:
and $1 and $1
xor d xor d
jr z, .asm_108bad jr z, .asm_108bad
ld hl, Palette_108b98 + 1 palettes ld hl, Palette_108b98 palette 1
jr .asm_108bb0 jr .asm_108bb0
.asm_108bad .asm_108bad
ld hl, Palette_108b98 ld hl, Palette_108b98
.asm_108bb0 .asm_108bb0
ld de, wBGPals1 + 7 palettes ld de, wBGPals1 palette 7
ld bc, 8 palettes ld bc, 8 palettes
call CopyBytes call CopyBytes
pop af pop af
@@ -1724,7 +1724,7 @@ LoadMobileAdapterPalette:
ld hl, MobileAdapterPalettes ld hl, MobileAdapterPalettes
call AddNTimes call AddNTimes
ld a, BANK(wBGPals1) ld a, BANK(wBGPals1)
ld de, wBGPals1 + 4 palettes ld de, wBGPals1 palette 4
ld bc, 1 palettes ld bc, 1 palettes
call FarCopyWRAM call FarCopyWRAM
ret ret

View File

@@ -515,7 +515,7 @@ Function1162cb:
ld a, $5 ld a, $5
ldh [rSVBK], a ldh [rSVBK], a
ld hl, PichuBorderMobileOBPalettes ld hl, PichuBorderMobileOBPalettes
ld de, wOBPals1 + 2 palettes ld de, wOBPals1 palette 2
ld bc, 6 palettes ld bc, 6 palettes
call CopyBytes call CopyBytes
call SetPalettes call SetPalettes

View File

@@ -676,13 +676,13 @@ Function16cc18:
Function16cc25: Function16cc25:
ld hl, Unknown_16cfa9 ld hl, Unknown_16cfa9
ld de, wBGPals1 + 1 palettes ld de, wBGPals1 palette 1
call .CopyPal call .CopyPal
ld hl, Unknown_16cfb1 ld hl, Unknown_16cfb1
ld de, wOBPals1 ld de, wOBPals1
call .CopyPal call .CopyPal
ld hl, Unknown_16cfb9 ld hl, Unknown_16cfb9
ld de, wOBPals1 + 1 palettes ld de, wOBPals1 palette 1
call .CopyPal call .CopyPal
ret ret