Skip to content

Commit

Permalink
Improve use of palette macro and use PAL_* constants (pret/pokecrysta…
Browse files Browse the repository at this point in the history
…l#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>
  • Loading branch information
Idain and vulcandth committed Nov 17, 2023
1 parent 7266ac4 commit 859b45a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
40 changes: 20 additions & 20 deletions engine/battle_anims/bg_effects.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2037,28 +2037,28 @@ BattleBGEffect_FadeMonsToBlackRepeating:
add hl, de
ld a, [hli]
push hl
call BGEffects_LoadBGPal1_OBPal0
call BGEffects_LoadEnemyPals
pop hl
ld a, [hl]
call BGEffects_LoadBGPal0_OBPal1
call BGEffects_LoadPlayerPals
ret

.player_2
ld hl, .CGB_DMGEnemyData
add hl, de
ld a, [hli]
push hl
call BGEffects_LoadBGPal0_OBPal1
call BGEffects_LoadPlayerPals
pop hl
ld a, [hl]
call BGEffects_LoadBGPal1_OBPal0
call BGEffects_LoadEnemyPals
ret

.cgb_two
ld a, $e4
call BGEffects_LoadBGPal0_OBPal1
call BGEffects_LoadPlayerPals
ld a, $e4
call BGEffects_LoadBGPal1_OBPal0
call BGEffects_LoadEnemyPals
call EndBattleBGEffect
ret

Expand Down Expand Up @@ -2468,7 +2468,7 @@ BGEffect_RapidCyclePals:
ld [hl], a
call BattleBGEffect_GetFirstDMGPal
jr c, .okay_2_cgb
call BGEffects_LoadBGPal0_OBPal1
call BGEffects_LoadPlayerPals
ret

.okay_2_cgb
Expand All @@ -2479,7 +2479,7 @@ BGEffect_RapidCyclePals:

.two_cgb
ld a, $e4
call BGEffects_LoadBGPal0_OBPal1
call BGEffects_LoadPlayerPals
call EndBattleBGEffect
ret

Expand All @@ -2499,7 +2499,7 @@ BGEffect_RapidCyclePals:
ld [hl], a
call BattleBGEffect_GetFirstDMGPal
jr c, .okay_4_cgb
call BGEffects_LoadBGPal1_OBPal0
call BGEffects_LoadEnemyPals
ret

.okay_4_cgb
Expand All @@ -2510,20 +2510,20 @@ BGEffect_RapidCyclePals:

.four_cgb
ld a, $e4
call BGEffects_LoadBGPal1_OBPal0
call BGEffects_LoadEnemyPals
call EndBattleBGEffect
ret

BGEffects_LoadBGPal0_OBPal1:
BGEffects_LoadPlayerPals:
push bc
push af
ld hl, wBGPals2
ld de, wBGPals1
ld hl, wBGPals2 palette PAL_BATTLE_BG_PLAYER
ld de, wBGPals1 palette PAL_BATTLE_BG_PLAYER
ld b, a
ld c, $1
call CopyPals
ld hl, wOBPals2 palette 1
ld de, wOBPals1 palette 1
ld hl, wOBPals2 palette PAL_BATTLE_OB_PLAYER
ld de, wOBPals1 palette PAL_BATTLE_OB_PLAYER
pop af
ld b, a
ld c, $1
Expand All @@ -2533,16 +2533,16 @@ BGEffects_LoadBGPal0_OBPal1:
ldh [hCGBPalUpdate], a
ret

BGEffects_LoadBGPal1_OBPal0:
BGEffects_LoadEnemyPals:
push bc
push af
ld hl, wBGPals2 palette 1
ld de, wBGPals1 palette 1
ld hl, wBGPals2 palette PAL_BATTLE_BG_ENEMY
ld de, wBGPals1 palette PAL_BATTLE_BG_ENEMY
ld b, a
ld c, $1
call CopyPals
ld hl, wOBPals2
ld de, wOBPals1
ld hl, wOBPals2 palette PAL_BATTLE_OB_ENEMY
ld de, wOBPals1 palette PAL_BATTLE_OB_ENEMY
pop af
ld b, a
ld c, $1
Expand Down
2 changes: 1 addition & 1 deletion engine/gfx/color.asm
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ CGBCopyBattleObjectPals: ; unreferenced
dec c
jr nz, .loop
ld hl, BattleObjectPals
ld de, wOBPals1 palette 2
ld de, wOBPals1 palette PAL_BATTLE_OB_GRAY
ld bc, 2 palettes
call CopyBytes
ret
Expand Down
4 changes: 2 additions & 2 deletions engine/tilesets/timeofday_pals.asm
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ FillWhiteBGColor:
ld e, a
ld a, [hli]
ld d, a
ld hl, wBGPals1 + 1 palettes
ld hl, wBGPals1 palette 1 color 0
ld c, 6
.loop
ld a, e
ld [hli], a
ld a, d
ld [hli], a
rept 6
rept 3 colors
inc hl
endr
dec c
Expand Down
1 change: 1 addition & 0 deletions macros/gfx.asm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ DEF palblue EQUS "(1 << 10) *"
DEF palettes EQUS "* PALETTE_SIZE"
DEF palette EQUS "+ PALETTE_SIZE *"
DEF color EQUS "+ PAL_COLOR_SIZE *"
DEF colors EQUS "* PAL_COLOR_SIZE"

DEF tiles EQUS "* LEN_2BPP_TILE"
DEF tile EQUS "+ LEN_2BPP_TILE *"
Expand Down

0 comments on commit 859b45a

Please sign in to comment.