Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6404,7 +6404,7 @@ LoadEnemyMon:

ld hl, wEnemyMonStats
ld de, wEnemyStats
ld bc, NUM_EXP_STATS * 2
ld bc, NUM_BATTLE_STATS * 2
call CopyBytes

; BUG: PRZ and BRN stat reductions don't apply to switched Pokémon (see docs/bugs_and_glitches.md)
Expand Down
40 changes: 20 additions & 20 deletions engine/battle_anims/bg_effects.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2076,28 +2076,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 @@ -2507,7 +2507,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 @@ -2518,7 +2518,7 @@ BGEffect_RapidCyclePals:

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

Expand All @@ -2538,7 +2538,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 @@ -2549,11 +2549,11 @@ BGEffect_RapidCyclePals:

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

BGEffects_LoadBGPal0_OBPal1:
BGEffects_LoadPlayerPals:
ld h, a
ldh a, [rSVBK]
push af
Expand All @@ -2562,13 +2562,13 @@ BGEffects_LoadBGPal0_OBPal1:
ld a, h
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
Idain marked this conversation as resolved.
Show resolved Hide resolved
ld de, wOBPals1 palette PAL_BATTLE_OB_PLAYER
pop af
ld b, a
ld c, $1
Expand All @@ -2580,7 +2580,7 @@ BGEffects_LoadBGPal0_OBPal1:
ldh [hCGBPalUpdate], a
ret

BGEffects_LoadBGPal1_OBPal0:
BGEffects_LoadEnemyPals:
ld h, a
ldh a, [rSVBK]
push af
Expand All @@ -2589,13 +2589,13 @@ BGEffects_LoadBGPal1_OBPal0:
ld a, h
push bc
push af
ld hl, wBGPals2 palette 1
ld de, wBGPals1 palette 1
ld hl, wBGPals2 palette PAL_BATTLE_BG_ENEMY
Idain marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -729,7 +729,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
ld a, BANK(wOBPals1)
call FarCopyWRAM
Expand Down
2 changes: 1 addition & 1 deletion engine/gfx/crystal_layouts.asm
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Palette_TextBG7:
INCLUDE "gfx/font/bg_text.pal"

Function49420::
ld hl, MansionPalette1 + 8 palettes
ld hl, MansionPalette1 palette 8
ld de, wBGPals1 palette PAL_BG_ROOF
ld bc, 1 palettes
ld a, BANK(wBGPals1)
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 @@ -168,14 +168,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
8 changes: 4 additions & 4 deletions mobile/mobile_22.asm
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ Function894dc:
ld bc, 3 palettes
call CopyBytes
ld hl, .Pals345
ld de, wBGPals1 + 3 palettes
ld de, wBGPals1 palette 3
ld bc, 3 palettes
call CopyBytes

Expand Down Expand Up @@ -2056,7 +2056,7 @@ Function89d0d:
jr nz, .loop

ld hl, .Palette2
ld de, wBGPals1 + 2 palettes
ld de, wBGPals1 palette 2
ld bc, 1 palettes
call CopyBytes

Expand Down Expand Up @@ -3232,15 +3232,15 @@ Function8a5b6:
ld a, $5
ldh [rSVBK], a
ld hl, Palette_8a5e5
ld de, wBGPals1 + 4 palettes
ld de, wBGPals1 palette 4
ld bc, 3 palettes
call CopyBytes
ld hl, Palette_8a5fd
ld de, wOBPals1
ld bc, 1 palettes
call CopyBytes
ld hl, Palette_8a605
ld de, wOBPals1 + 1 palettes
ld de, wOBPals1 palette 1
ld bc, 1 palettes
call CopyBytes
pop af
Expand Down
16 changes: 8 additions & 8 deletions mobile/mobile_42.asm
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ MobileTradeAnim_GiveTrademon1:

MobileTradeAnim_GiveTrademon2:
ld c, 40
ld hl, wBGPals2 + 1 palettes
ld hl, wBGPals2 palette 1
call Function1082f0
call Function108af4
call Function108b5a
Expand Down Expand Up @@ -1069,12 +1069,12 @@ MobileTradeAnim_GetTrademon1:

MobileTradeAnim_GetTrademon2:
ld c, 20
ld hl, wBGPals2 + 1 palettes
ld hl, wBGPals2 palette 1
call Function1082fa
ld de, SFX_GIVE_TRADEMON
call PlaySFX
ld c, 20
ld hl, wBGPals2 + 1 palettes
ld hl, wBGPals2 palette 1
call Function1082fa
call Function108af4
.asm_1088ad
Expand Down Expand Up @@ -1439,8 +1439,8 @@ Function108b5a:
ld a, $5
ldh [rSVBK], a
ld de, palred 18 + palgreen 31 + palblue 15
ld hl, wBGPals2 + 4 palettes
ld c, $10
ld hl, wBGPals2 palette 4
ld c, 2 palettes
.loop
ld a, e
ld [hli], a
Expand Down Expand Up @@ -1491,13 +1491,13 @@ Function108b98:
and $1
xor d
jr z, .asm_108bad
ld hl, Palette_108b98 + 1 palettes
ld hl, Palette_108b98 palette 1
jr .asm_108bb0

.asm_108bad
ld hl, Palette_108b98
.asm_108bb0
ld de, wBGPals1 + 7 palettes
ld de, wBGPals1 palette 7
ld bc, 8 palettes
call CopyBytes
pop af
Expand Down Expand Up @@ -1724,7 +1724,7 @@ LoadMobileAdapterPalette:
ld hl, MobileAdapterPalettes
call AddNTimes
ld a, BANK(wBGPals1)
ld de, wBGPals1 + 4 palettes
ld de, wBGPals1 palette 4
ld bc, 1 palettes
call FarCopyWRAM
ret
Expand Down
2 changes: 1 addition & 1 deletion mobile/mobile_45_sprite_engine.asm
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ Function1162cb:
ld a, $5
ldh [rSVBK], a
ld hl, PichuBorderMobileOBPalettes
ld de, wOBPals1 + 2 palettes
ld de, wOBPals1 palette 2
ld bc, 6 palettes
call CopyBytes
call SetPalettes
Expand Down
4 changes: 2 additions & 2 deletions mobile/mobile_5b.asm
Original file line number Diff line number Diff line change
Expand Up @@ -676,13 +676,13 @@ Function16cc18:

Function16cc25:
ld hl, Unknown_16cfa9
ld de, wBGPals1 + 1 palettes
ld de, wBGPals1 palette 1
call .CopyPal
ld hl, Unknown_16cfb1
ld de, wOBPals1
call .CopyPal
ld hl, Unknown_16cfb9
ld de, wOBPals1 + 1 palettes
ld de, wOBPals1 palette 1
call .CopyPal
ret

Expand Down