ref: 64cfbcce7a71e6e75553575490fd60cbd61a5665
parent: 43fddc803f95b3a798c4f6c5f0ed741590aeeb4c
author: YamaArashi <shadow962@live.com>
date: Tue Aug 11 22:16:56 EDT 2015
commented SGB palette stuff
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -159,6 +159,11 @@
LEFT_ALIGN EQU (1 << BIT_LEFT_ALIGN)
LEADING_ZEROES EQU (1 << BIT_LEADING_ZEROES)
+; HP bar
+HP_BAR_GREEN EQU 0
+HP_BAR_YELLOW EQU 1
+HP_BAR_RED EQU 2
+
; serial
ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK EQU $01
--- a/constants/palette_constants.asm
+++ b/constants/palette_constants.asm
@@ -1,3 +1,19 @@
+SET_PAL_BATTLE_BLACK EQU $00
+SET_PAL_BATTLE EQU $01
+SET_PAL_TOWN_MAP EQU $02
+SET_PAL_STATUS_SCREEN EQU $03
+SET_PAL_POKEDEX EQU $04
+SET_PAL_SLOTS EQU $05
+SET_PAL_TITLE_SCREEN EQU $06
+SET_PAL_NIDORINO_INTRO EQU $07
+SET_PAL_GENERIC EQU $08
+SET_PAL_OVERWORLD EQU $09
+SET_PAL_PARTY_MENU EQU $0A
+SET_PAL_POKEMON_WHOLE_SCREEN EQU $0B
+SET_PAL_GAME_FREAK_INTRO EQU $0C
+SET_PAL_TRAINER_CARD EQU $0D
+UPDATE_PARTY_MENU_BLK_PACKET EQU $FC
+
; super game boy palettes
const_value = 0
--- a/data/sgb_packets.asm
+++ b/data/sgb_packets.asm
@@ -60,11 +60,11 @@
BlkPacket_Battle: ; 721b5 (1c:61b5)
ATTR_BLK 5
- ATTR_BLK_DATA %111, 2,2,0, 00,12, 19,17
- ATTR_BLK_DATA %011, 1,1,0, 01,00, 10,03
- ATTR_BLK_DATA %011, 0,0,0, 10,07, 19,10
- ATTR_BLK_DATA %011, 2,2,0, 00,04, 08,11
- ATTR_BLK_DATA %011, 3,3,0, 11,00, 19,06
+ ATTR_BLK_DATA %111, 2,2,0, 00,12, 19,17 ; message box: pal 2
+ ATTR_BLK_DATA %011, 1,1,0, 01,00, 10,03 ; enemy HP bar: pal 1
+ ATTR_BLK_DATA %011, 0,0,0, 10,07, 19,10 ; player HP bar: pal 0
+ ATTR_BLK_DATA %011, 2,2,0, 00,04, 08,11 ; player mon: pal 2
+ ATTR_BLK_DATA %011, 3,3,0, 11,00, 19,06 ; enemy mon : pal 3
db $03,$00,$00,$13,$0b,$00
db $03,$00,$0c,$13,$11,$02
@@ -76,7 +76,7 @@
BlkPacket_StatusScreen: ; 721fa (1c:61fa)
ATTR_BLK 1
- ATTR_BLK_DATA %111, 1,1,0, 01,00, 07,06
+ ATTR_BLK_DATA %111, 1,1,0, 01,00, 07,06 ; mon: pal 1, HP bar: pal 0
ds 8
db $02,$00,$00,$11,$00,$03
@@ -86,7 +86,7 @@
BlkPacket_Pokedex: ; 72222 (1c:6222)
ATTR_BLK 1
- ATTR_BLK_DATA %111, 1,1,0, 01,01, 08,08
+ ATTR_BLK_DATA %111, 1,1,0, 01,01, 08,08 ; mon: pal 1, everything else: pal 0
ds 8
db $02,$00,$00,$11,$00,$01
@@ -97,11 +97,11 @@
BlkPacket_Slots: ; 7224f (1c:624f)
ATTR_BLK 5
- ATTR_BLK_DATA %011, 1,1,0, 00,00, 19,11
- ATTR_BLK_DATA %011, 2,2,0, 00,04, 19,09
- ATTR_BLK_DATA %010, 3,3,0, 00,06, 19,07
- ATTR_BLK_DATA %011, 0,0,0, 04,04, 15,09
- ATTR_BLK_DATA %011, 0,0,0, 00,12, 19,17
+ ATTR_BLK_DATA %011, 1,1,0, 00,00, 19,11 ; "3" rows and top of screen: pal 1
+ ATTR_BLK_DATA %011, 2,2,0, 00,04, 19,09 ; "2" rows: pal 2
+ ATTR_BLK_DATA %010, 3,3,0, 00,06, 19,07 ; "1" row: pal 3
+ ATTR_BLK_DATA %011, 0,0,0, 04,04, 15,09 ; slot reels: pal 0
+ ATTR_BLK_DATA %011, 0,0,0, 00,12, 19,17 ; message box: pal 0
db $03,$00,$00,$13,$0b,$01
db $03,$00,$04,$13,$09,$02
@@ -112,9 +112,9 @@
BlkPacket_Titlescreen: ; 7228e (1c:628e)
ATTR_BLK 3
- ATTR_BLK_DATA %011, 0,0,0, 00,00, 19,07
- ATTR_BLK_DATA %010, 1,1,0, 00,08, 19,09
- ATTR_BLK_DATA %011, 2,2,0, 00,10, 19,17
+ ATTR_BLK_DATA %011, 0,0,0, 00,00, 19,07 ; pokemon logo: pal 0
+ ATTR_BLK_DATA %010, 1,1,0, 00,08, 19,09 ; version text: pal 1
+ ATTR_BLK_DATA %011, 2,2,0, 00,10, 19,17 ; player, mon, copyright text: pal 2
ds 12
db $03,$00,$00,$13,$07,$00
@@ -124,9 +124,9 @@
BlkPacket_NidorinoIntro: ; 722c1 (1c:62c1)
ATTR_BLK 3
- ATTR_BLK_DATA %011, 1,1,0, 00,00, 19,03
- ATTR_BLK_DATA %011, 0,0,0, 00,04, 19,13
- ATTR_BLK_DATA %011, 1,1,0, 00,14, 19,17
+ ATTR_BLK_DATA %011, 1,1,0, 00,00, 19,03 ; upper black bar: pal 1
+ ATTR_BLK_DATA %011, 0,0,0, 00,04, 19,13 ; letterbox: pal 0
+ ATTR_BLK_DATA %011, 1,1,0, 00,14, 19,17 ; lower black bar: pal 1
ds 12
db $03,$00,$00,$13,$03,$01
@@ -136,13 +136,13 @@
BlkPacket_PartyMenu: ; 722f4 (1c:62f4)
ATTR_BLK 7
- ATTR_BLK_DATA %110, 0,0,1, 01,00, 02,12
- ATTR_BLK_DATA %010, 0,0,0, 05,01, 11,01
- ATTR_BLK_DATA %010, 0,0,0, 05,03, 11,03
- ATTR_BLK_DATA %010, 0,0,0, 05,05, 11,05
- ATTR_BLK_DATA %010, 0,0,0, 05,07, 11,07
- ATTR_BLK_DATA %010, 0,0,0, 05,09, 11,09
- ATTR_BLK_DATA %010, 0,0,0, 05,11, 11,11
+ ATTR_BLK_DATA %110, 0,0,1, 01,00, 02,12 ; mon sprites: pal 0, everything else: pal 1
+ ATTR_BLK_DATA %010, 0,0,0, 05,01, 11,01 ; HP bar 0: pal set dynamically
+ ATTR_BLK_DATA %010, 0,0,0, 05,03, 11,03 ; HP bar 1: pal set dynamically
+ ATTR_BLK_DATA %010, 0,0,0, 05,05, 11,05 ; HP bar 2: pal set dynamically
+ ATTR_BLK_DATA %010, 0,0,0, 05,07, 11,07 ; HP bar 3: pal set dynamically
+ ATTR_BLK_DATA %010, 0,0,0, 05,09, 11,09 ; HP bar 4: pal set dynamically
+ ATTR_BLK_DATA %010, 0,0,0, 05,11, 11,11 ; HP bar 5: pal set dynamically
ds 4
db $02,$00,$00,$11,$01,$03
@@ -158,16 +158,16 @@
BlkPacket_TrainerCard: ; 72360 (1c:6360)
ATTR_BLK 10
- ATTR_BLK_DATA %010, 0,0,0, 03,12, 04,13
- ATTR_BLK_DATA %010, 1,1,0, 07,12, 08,13
- ATTR_BLK_DATA %010, 3,3,0, 11,12, 12,13
- ATTR_BLK_DATA %010, 2,2,0, 16,11, 17,12
- ATTR_BLK_DATA %010, 1,1,0, 14,13, 15,14
- ATTR_BLK_DATA %010, 3,3,0, 16,13, 17,14
- ATTR_BLK_DATA %010, 2,2,0, 03,15, 04,16
- ATTR_BLK_DATA %010, 3,3,0, 07,15, 08,16
- ATTR_BLK_DATA %010, 2,2,0, 11,15, 12,16
- ATTR_BLK_DATA %010, 1,1,0, 15,15, 16,16
+ ATTR_BLK_DATA %010, 0,0,0, 03,12, 04,13 ; Boulder Badge
+ ATTR_BLK_DATA %010, 1,1,0, 07,12, 08,13 ; Cascade Badge
+ ATTR_BLK_DATA %010, 3,3,0, 11,12, 12,13 ; Thunder Badge
+ ATTR_BLK_DATA %010, 2,2,0, 16,11, 17,12 ; Rainbow Badge
+ ATTR_BLK_DATA %010, 1,1,0, 14,13, 15,14 ; Rainbow Badge
+ ATTR_BLK_DATA %010, 3,3,0, 16,13, 17,14 ; Rainbow Badge
+ ATTR_BLK_DATA %010, 2,2,0, 03,15, 04,16 ; Soul Badge
+ ATTR_BLK_DATA %010, 3,3,0, 07,15, 08,16 ; Marsh Badge
+ ATTR_BLK_DATA %010, 2,2,0, 11,15, 12,16 ; Volcano Badge
+ ATTR_BLK_DATA %010, 1,1,0, 15,15, 16,16 ; Earth Badge
ds 2
db $03,$03,$0c,$04,$0d,$00
@@ -184,9 +184,9 @@
BlkPacket_GameFreakIntro: ; 723dd (1c:63dd)
ATTR_BLK 3
- ATTR_BLK_DATA %111, 1,1,0, 05,11, 07,13
- ATTR_BLK_DATA %010, 2,2,0, 08,11, 09,13
- ATTR_BLK_DATA %011, 3,3,0, 12,11, 14,13
+ ATTR_BLK_DATA %111, 1,1,0, 05,11, 07,13 ; falling stars (left): pal 1, GameFreak logo: pal 0
+ ATTR_BLK_DATA %010, 2,2,0, 08,11, 09,13 ; falling stars (middle): pal 2
+ ATTR_BLK_DATA %011, 3,3,0, 12,11, 14,13 ; falling stars (right): pal 3
ds 12
db $03,$00,$00,$13,$0a,$00
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -2170,8 +2170,8 @@
pop af
ld [wBattleMonSpecies2], a
.done
- ld b, $1
- jp GoPAL_SET
+ ld b, SET_PAL_BATTLE
+ jp RunPaletteCommand
AnimationHideEnemyMonPic: ; 797d8 (1e:57d8)
; Hides the enemy mon's sprite
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -184,8 +184,8 @@
inc a
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
- ld b, $1
- call GoPAL_SET
+ ld b, SET_PAL_BATTLE
+ call RunPaletteCommand
call HideSprites
jpab PrintBeginningBattleText
@@ -976,7 +976,7 @@
; stores whether enemy ran in Z flag
ReplaceFaintedEnemyMon: ; 3c664 (f:4664)
- ld hl, wcf1e
+ ld hl, wEnemyHPBarColor
ld e, $30
call GetBattleHealthBarColor
callab DrawEnemyPokeballs
@@ -1199,7 +1199,7 @@
call GBPalWhiteOut
call LoadHudTilePatterns
call LoadScreenTilesFromBuffer1
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call GBPalNormal
call SendOutMon
ld hl, wEnemyMonHP
@@ -1228,8 +1228,8 @@
cp OAKS_LAB
ret z ; starter battle in oak's lab: don't black out
.notSony1Battle
- ld b, $0
- call GoPAL_SET
+ ld b, SET_PAL_BATTLE_BLACK
+ call RunPaletteCommand
ld hl, PlayerBlackedOutText2
ld a, [wLinkState]
cp LINK_STATE_BATTLING
@@ -1494,8 +1494,8 @@
coord hl, 0, 0
lb bc, 4, 11
call ClearScreenArea
- ld b,1
- call GoPAL_SET
+ ld b, SET_PAL_BATTLE
+ call RunPaletteCommand
call GBPalNormal
ld hl,TrainerSentOutText
call PrintText
@@ -1829,8 +1829,8 @@
ld [W_PLAYERDISABLEDMOVE], a
ld [wPlayerDisabledMoveNumber], a
ld [wPlayerMonMinimized], a
- ld b, $1
- call GoPAL_SET
+ ld b, SET_PAL_BATTLE
+ call RunPaletteCommand
ld hl, W_ENEMYBATTSTATUS1
res UsingTrappingMove, [hl]
ld a, $1
@@ -1926,7 +1926,7 @@
predef DrawHP
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
- ld hl, wcf1d
+ ld hl, wPlayerHPBarColor
call GetBattleHealthBarColor
ld hl, wBattleMonHP
ld a, [hli]
@@ -1935,8 +1935,8 @@
ld a, [wccf6]
and a
ret nz
- ld a, [wcf1d]
- cp $2
+ ld a, [wPlayerHPBarColor]
+ cp HP_BAR_RED
jr z, .asm_3cde6
.asm_3cdd9
ld hl, wLowHealthAlarm
@@ -2039,7 +2039,7 @@
call DrawHPBar
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
- ld hl, wcf1e
+ ld hl, wEnemyHPBarColor
GetBattleHealthBarColor: ; 3ce90 (f:4e90)
ld b, [hl]
@@ -2047,8 +2047,8 @@
ld a, [hl]
cp b
ret z
- ld b, $1
- jp GoPAL_SET
+ ld b, SET_PAL_BATTLE
+ jp RunPaletteCommand
; center's mon's name on the battle screen
; if the name is 1 or 2 letters long, it is printed 2 spaces more to the right than usual
@@ -2397,7 +2397,7 @@
call GBPalWhiteOut
call LoadHudTilePatterns
call LoadScreenTilesFromBuffer2
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call GBPalNormal
jp DisplayBattleMenu
.partyMonDeselected
@@ -2486,7 +2486,7 @@
call ClearSprites
call LoadHudTilePatterns
call LoadScreenTilesFromBuffer1
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call GBPalNormal
; fall through to SwitchPlayerMon
@@ -6932,8 +6932,8 @@
; common code that executes after init battle code specific to trainer or wild battles
InitBattle_Common: ; 3efeb (f:6feb)
- ld b, $0
- call GoPAL_SET
+ ld b, SET_PAL_BATTLE_BLACK
+ call RunPaletteCommand
call SlidePlayerAndEnemySilhouettesOnScreen
xor a
ld [H_AUTOBGTRANSFERENABLED], a
--- a/engine/battle/init_battle_variables.asm
+++ b/engine/battle/init_battle_variables.asm
@@ -16,9 +16,9 @@
ld [wPlayerMonNumber], a
ld [wEscapedFromBattle], a
ld [wMapPalOffset], a
- ld hl, wcf1d
- ld [hli], a
- ld [hl], a
+ ld hl, wPlayerHPBarColor
+ ld [hli], a ; wPlayerHPBarColor
+ ld [hl], a ; wEnemyHPBarColor
ld hl, wCanEvolveFlags
ld b, $3c
.loop
--- a/engine/battle/scroll_draw_trainer_pic.asm
+++ b/engine/battle/scroll_draw_trainer_pic.asm
@@ -3,8 +3,8 @@
; the screen from the right.
xor a
ld [wEnemyMonSpecies2], a
- ld b, $1
- call GoPAL_SET
+ ld b, SET_PAL_BATTLE
+ call RunPaletteCommand
callab _LoadTrainerPic
coord hl, 19, 0
ld c, $0
--- a/engine/clear_save.asm
+++ b/engine/clear_save.asm
@@ -1,6 +1,6 @@
DoClearSaveDialogue: ; 1c98a (7:498a)
call ClearScreen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call LoadFontTilePatterns
call LoadTextBoxTilePatterns
ld hl, ClearSaveDataText
--- a/engine/evolution.asm
+++ b/engine/evolution.asm
@@ -21,8 +21,8 @@
ld [H_AUTOBGTRANSFERENABLED], a
ld [hTilesetType], a
ld a, [wEvoOldSpecies]
- ld [wcf1d], a
- ld c, $0
+ ld [wWholeScreenPaletteMonSpecies], a
+ ld c, 0
call EvolutionSetWholeScreenPalette
ld a, [wEvoNewSpecies]
ld [wcf91], a
@@ -46,7 +46,7 @@
call PlayMusic
ld c, 80
call DelayFrames
- ld c, $1
+ ld c, 1 ; set PAL_BLACK instead of mon palette
call EvolutionSetWholeScreenPalette
lb bc, $1, $10
.animLoop
@@ -66,13 +66,13 @@
call Evolution_ChangeMonPic ; show the new species pic
ld a, [wEvoNewSpecies]
.done
- ld [wcf1d], a
+ ld [wWholeScreenPaletteMonSpecies], a
ld a, $ff
ld [wNewSoundID], a
call PlaySound
- ld a, [wcf1d]
+ ld a, [wWholeScreenPaletteMonSpecies]
call PlayCry
- ld c, $0
+ ld c, 0
call EvolutionSetWholeScreenPalette
pop af
ld [wd0b5], a
@@ -94,8 +94,8 @@
jr .done
EvolutionSetWholeScreenPalette: ; 7beb4 (1e:7eb4)
- ld b, $b
- jp GoPAL_SET
+ ld b, SET_PAL_POKEMON_WHOLE_SCREEN
+ jp RunPaletteCommand
Evolution_LoadPic: ; 7beb9 (1e:7eb9)
call GetMonHeader
--- a/engine/hall_of_fame.asm
+++ b/engine/hall_of_fame.asm
@@ -104,7 +104,7 @@
ld [wcf91], a
ld [wd0b5], a
ld [wBattleMonSpecies2], a
- ld [wcf1d], a
+ ld [wWholeScreenPaletteMonSpecies], a
ld a, [wHoFMonOrPlayer]
and a
jr z, .showMon
@@ -117,9 +117,9 @@
call LoadFrontSpriteByMonIndex
predef LoadMonBackPic
.next1
- ld b, $b
- ld c, $0
- call GoPAL_SET
+ ld b, SET_PAL_POKEMON_WHOLE_SCREEN
+ ld c, 0
+ call RunPaletteCommand
ld a, %11100100
ld [rBGP], a
ld c, $31 ; back pic
--- a/engine/intro.asm
+++ b/engine/intro.asm
@@ -18,8 +18,8 @@
ret
PlayIntroScene: ; 4169d (10:569d)
- ld b, $7
- call GoPAL_SET
+ ld b, SET_PAL_NIDORINO_INTRO
+ call RunPaletteCommand
ld a, %11100100
ld [rBGP], a
ld [rOBP0], a
@@ -302,8 +302,8 @@
jp FarCopyData2
PlayShootingStar: ; 4188a (10:588a)
- ld b, $c
- call GoPAL_SET
+ ld b, SET_PAL_GAME_FREAK_INTRO
+ call RunPaletteCommand
callba LoadCopyrightAndTextBoxTiles
ld a, $e4
ld [rBGP], a
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -127,7 +127,7 @@
ld hl,W_NUMSAFARIBALLS
dec [hl]
.skipSafariZoneCode
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
ld a,$43
ld [wd11e],a
call LoadScreenTilesFromBuffer1 ;restore screenBuffer from Backup
@@ -1111,7 +1111,7 @@
and a ; using Softboiled?
ret nz ; if so, return
call GBPalWhiteOut
- call z,GoPAL_SET_CF1C
+ call z,RunDefaultPaletteCommand
ld a,[W_ISINBATTLE]
and a
ret nz
@@ -1928,7 +1928,7 @@
pop af
ld [wWhichPokemon],a
call GBPalWhiteOut
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
jp RemoveUsedItem
.afterRestoringPP ; after using a (Max) Ether/Elixir
ld a,[wWhichPokemon]
@@ -2032,7 +2032,7 @@
call ItemUseNoEffect
.itemNotUsed
call GBPalWhiteOut
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
pop af
xor a
ld [wActionResultOrTookBattleTurn],a ; item use failed
@@ -2125,7 +2125,7 @@
pop af
call GBPalWhiteOutWithDelay3
call ClearSprites
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
jp LoadScreenTilesFromBuffer1 ; restore saved screen
.checkIfAbleToLearnMove
predef CanLearnTM ; check if the pokemon can learn the move
@@ -2201,7 +2201,7 @@
jr ItemUseFailed
ThrowBallAtTrainerMon: ; e58b (3:658b)
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call LoadScreenTilesFromBuffer1 ; restore saved screen
call Delay3
ld a,TOSS_ANIM
--- a/engine/menu/bills_pc.asm
+++ b/engine/menu/bills_pc.asm
@@ -450,7 +450,7 @@
predef StatusScreen2
call LoadScreenTilesFromBuffer1
call ReloadTilesetTilePatterns
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call LoadGBPal
jr .loop
--- a/engine/menu/diploma.asm
+++ b/engine/menu/diploma.asm
@@ -55,8 +55,8 @@
call EnableLCD
callba LoadTrainerInfoTextBoxTiles
- ld b, $8
- call GoPAL_SET
+ ld b, SET_PAL_GENERIC
+ call RunPaletteCommand
call Delay3
call GBPalNormal
ld a, $90
--- a/engine/menu/league_pc.asm
+++ b/engine/menu/league_pc.asm
@@ -47,7 +47,7 @@
res 6, [hl]
call GBPalWhiteOutWithDelay3
call ClearScreen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
jp GBPalNormal
LeaguePCShowTeam: ; 765e5 (1d:65e5)
@@ -86,15 +86,15 @@
ld [wcf91], a
ld [wd0b5], a
ld [wBattleMonSpecies2], a
- ld [wcf1d], a
+ ld [wWholeScreenPaletteMonSpecies], a
ld a, [hli]
ld [wHoFMonLevel], a
ld de, wcd6d
ld bc, NAME_LENGTH
call CopyData
- ld b, $0B
+ ld b, SET_PAL_POKEMON_WHOLE_SCREEN
ld c, 0
- call GoPAL_SET
+ call RunPaletteCommand
coord hl, 12, 5
call GetMonHeader
call LoadFrontSpriteByMonIndex
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -24,7 +24,7 @@
ld hl,wd72e
res 6,[hl]
call ClearScreen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call LoadTextBoxTilePatterns
call LoadFontTilePatterns
ld hl,wd730
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -88,8 +88,8 @@
call GBPalWhiteOutWithDelay3
call ClearScreen
call UpdateSprites
- ld b, $8
- call GoPAL_SET
+ ld b, SET_PAL_GENERIC
+ call RunPaletteCommand
call LoadHpBarAndStatusTilePatterns
call LoadEDTile
callba LoadMonPartySpriteGfx
@@ -163,7 +163,7 @@
call GBPalWhiteOutWithDelay3
call ClearScreen
call ClearSprites
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call GBPalNormal
xor a
ld [W_SUBANIMTRANSFORM], a
--- a/engine/menu/party_menu.asm
+++ b/engine/menu/party_menu.asm
@@ -29,13 +29,13 @@
cp a,SWAP_MONS_PARTY_MENU
jp z,.printMessage
call ErasePartyMenuCursors
- callba SendBlkPacket_PartyMenu
+ callba InitPartyMenuBlkPacket
coord hl, 3, 0
ld de,wPartySpecies
xor a
ld c,a
ld [hPartyMonIndex],a
- ld [wcf2d],a
+ ld [wWhichPartyMenuHPBar],a
.loop
ld a,[de]
cp a,$FF ; reached the terminator?
@@ -96,7 +96,7 @@
ld a,[hFlags_0xFFF6]
res 0,a
ld [hFlags_0xFFF6],a
- call SetPartyMenuHealthBarColor ; color the HP bar (on SGB)
+ call SetPartyMenuHPBarColor ; color the HP bar (on SGB)
pop hl
jr .printLevel
.teachMoveMenu
@@ -188,8 +188,8 @@
.notAbleToEvolveText
db "NOT ABLE@"
.afterDrawingMonEntries
- ld b,$0A
- call GoPAL_SET
+ ld b, SET_PAL_PARTY_MENU
+ call RunPaletteCommand
.printMessage
ld hl,wd730
ld a,[hl]
@@ -311,15 +311,15 @@
db $06
db "@"
-SetPartyMenuHealthBarColor: ; 12ec7 (4:6ec7)
- ld hl, wcf1f
- ld a, [wcf2d]
+SetPartyMenuHPBarColor: ; 12ec7 (4:6ec7)
+ ld hl, wPartyMenuHPBarColors
+ ld a, [wWhichPartyMenuHPBar]
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
call GetHealthBarColor
- ld b, $fc
- call GoPAL_SET
- ld hl, wcf2d
+ ld b, UPDATE_PARTY_MENU_BLK_PACKET
+ call RunPaletteCommand
+ ld hl, wWhichPartyMenuHPBar
inc [hl]
ret
--- a/engine/menu/pokedex.asm
+++ b/engine/menu/pokedex.asm
@@ -12,8 +12,8 @@
ld [wd11e],a
ld [hJoy7],a
.setUpGraphics
- ld b,$08
- call GoPAL_SET
+ ld b, SET_PAL_GENERIC
+ call RunPaletteCommand
callab LoadPokedexTilePatterns
.doPokemonListMenu
ld hl,wTopMenuItemY
@@ -41,7 +41,7 @@
pop af
ld [wListScrollOffset],a
call GBPalWhiteOutWithDelay3
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
jp ReloadMapData
.goToSideMenu
call HandlePokedexSideMenu
@@ -404,8 +404,8 @@
ld a,[wd11e] ; pokemon ID
ld [wcf91],a
push af
- ld b,04
- call GoPAL_SET
+ ld b, SET_PAL_POKEDEX
+ call RunPaletteCommand
pop af
ld [wd11e],a
ld a,[hTilesetType]
@@ -561,7 +561,7 @@
ld [hTilesetType],a
call GBPalWhiteOut
call ClearScreen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call LoadTextBoxTilePatterns
call GBPalNormal
ld hl,wd72c
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -297,7 +297,7 @@
ItemMenuLoop: ; 132fc (4:72fc)
call LoadScreenTilesFromBuffer2DisableBGTransfer ; restore saved screen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
StartMenu_Item: ; 13302 (4:7302)
ld a,[wLinkState]
@@ -506,14 +506,14 @@
ld [hTilesetType],a
call DrawTrainerInfo
predef DrawBadges ; draw badges
- ld b,$0d
- call GoPAL_SET
+ ld b, SET_PAL_TRAINER_CARD
+ call RunPaletteCommand
call GBPalNormal
call WaitForTextScrollButtonPress ; wait for button press
call GBPalWhiteOut
call LoadFontTilePatterns
call LoadScreenTilesFromBuffer2 ; restore saved screen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call ReloadMapData
call LoadGBPal
pop af
--- a/engine/menu/status_screen.asm
+++ b/engine/menu/status_screen.asm
@@ -121,10 +121,10 @@
call PlaceString ; "TYPE1/"
coord hl, 11, 3
predef DrawHP
- ld hl, wcf25
+ ld hl, wStatusScreenHPBarColor
call GetHealthBarColor
- ld b, $3
- call GoPAL_SET ; SGB palette
+ ld b, SET_PAL_STATUS_SCREEN
+ call RunPaletteCommand
coord hl, 16, 6
ld de, wLoadedMonStatus
call PrintStatusCondition
--- a/engine/mon_party_sprites.asm
+++ b/engine/mon_party_sprites.asm
@@ -5,12 +5,12 @@
inc a
jr GetAnimationSpeed
-; wcf1f contains the party mon's health bar colors
+; wPartyMenuHPBarColors contains the party mon's health bar colors
; 0: green
; 1: yellow
; 2: red
AnimatePartyMon: ; 716ff (1c:56ff)
- ld hl, wcf1f
+ ld hl, wPartyMenuHPBarColors
ld a, [wCurrentMenuItem]
ld c, a
ld b, $0
--- a/engine/palettes.asm
+++ b/engine/palettes.asm
@@ -1,33 +1,33 @@
-Func_71ddf: ; 71ddf (1c:5ddf)
+_RunPaletteCommand: ; 71ddf (1c:5ddf)
call GetPredefRegisters
ld a, b
cp $ff
- jr nz, .asm_71dea
- ld a, [wcf1c]
-.asm_71dea
- cp $fc
- jp z, Func_71fc2
+ jr nz, .next
+ ld a, [wDefaultPaletteCommand] ; use default command if command ID is $ff
+.next
+ cp UPDATE_PARTY_MENU_BLK_PACKET
+ jp z, UpdatePartyMenuBlkPacket
ld l, a
- ld h, $0
+ ld h, 0
add hl, hl
- ld de, PointerTable_71f73
+ ld de, SetPalFunctions
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
- ld de, Func_72156
+ ld de, SendSGBPackets
push de
jp [hl]
-SendPalPacket_Black: ; 71dff (1c:5dff)
+SetPal_BattleBlack: ; 71dff (1c:5dff)
ld hl, PalPacket_Black
ld de, BlkPacket_Battle
ret
; uses PalPacket_Empty to build a packet based on mon IDs and health color
-BuildBattlePalPacket: ; 71e06 (1c:5e06)
+SetPal_Battle: ; 71e06 (1c:5e06)
ld hl, PalPacket_Empty
- ld de, wcf2d
+ ld de, wPalPacket
ld bc, $10
call CopyData
ld a, [W_PLAYERBATTSTATUS3]
@@ -38,12 +38,12 @@
ld hl, wEnemyMonSpecies2
call DeterminePaletteID
ld c, a
- ld hl, wcf2e
- ld a, [wcf1d]
+ ld hl, wPalPacket + 1
+ ld a, [wPlayerHPBarColor]
add PAL_GREENBAR
ld [hli], a
inc hl
- ld a, [wcf1e]
+ ld a, [wEnemyHPBarColor]
add PAL_GREENBAR
ld [hli], a
inc hl
@@ -52,21 +52,21 @@
inc hl
ld a, c
ld [hl], a
- ld hl, wcf2d
+ ld hl, wPalPacket
ld de, BlkPacket_Battle
- ld a, $1
- ld [wcf1c], a
+ ld a, SET_PAL_BATTLE
+ ld [wDefaultPaletteCommand], a
ret
-SendPalPacket_TownMap: ; 71e48 (1c:5e48)
+SetPal_TownMap: ; 71e48 (1c:5e48)
ld hl, PalPacket_TownMap
ld de, BlkPacket_WholeScreen
ret
; uses PalPacket_Empty to build a packet based the mon ID
-BuildStatusScreenPalPacket: ; 71e4f (1c:5e4f)
+SetPal_StatusScreen: ; 71e4f (1c:5e4f)
ld hl, PalPacket_Empty
- ld de, wcf2d
+ ld de, wPalPacket
ld bc, $10
call CopyData
ld a, [wcf91]
@@ -76,67 +76,67 @@
.pokemon
call DeterminePaletteIDOutOfBattle
push af
- ld hl, wcf2e
- ld a, [wcf25]
+ ld hl, wPalPacket + 1
+ ld a, [wStatusScreenHPBarColor]
add PAL_GREENBAR
ld [hli], a
inc hl
pop af
ld [hl], a
- ld hl, wcf2d
+ ld hl, wPalPacket
ld de, BlkPacket_StatusScreen
ret
-SendPalPacket_PartyMenu: ; 71e7b (1c:5e7b)
+SetPal_PartyMenu: ; 71e7b (1c:5e7b)
ld hl, PalPacket_PartyMenu
- ld de, wcf2e
+ ld de, wPartyMenuBlkPacket
ret
-SendPalPacket_Pokedex: ; 71e82 (1c:5e82)
+SetPal_Pokedex: ; 71e82 (1c:5e82)
ld hl, PalPacket_Pokedex
- ld de, wcf2d
+ ld de, wPalPacket
ld bc, $10
call CopyData
ld a, [wcf91]
call DeterminePaletteIDOutOfBattle
- ld hl, wcf30
+ ld hl, wPalPacket + 3
ld [hl], a
- ld hl, wcf2d
+ ld hl, wPalPacket
ld de, BlkPacket_Pokedex
ret
-SendPalPacket_Slots: ; 71e9f (1c:5e9f)
+SetPal_Slots: ; 71e9f (1c:5e9f)
ld hl, PalPacket_Slots
ld de, BlkPacket_Slots
ret
-SendPalPacket_Titlescreen: ; 71ea6 (1c:5ea6)
+SetPal_TitleScreen: ; 71ea6 (1c:5ea6)
ld hl, PalPacket_Titlescreen
ld de, BlkPacket_Titlescreen
ret
; used mostly for menus and the Oak intro
-SendPalPacket_Generic: ; 71ead (1c:5ead)
+SetPal_Generic: ; 71ead (1c:5ead)
ld hl, PalPacket_Generic
ld de, BlkPacket_WholeScreen
ret
-SendPalPacket_NidorinoIntro: ; 71eb4 (1c:5eb4)
+SetPal_NidorinoIntro: ; 71eb4 (1c:5eb4)
ld hl, PalPacket_NidorinoIntro
ld de, BlkPacket_NidorinoIntro
ret
-SendPalPacket_GameFreakIntro: ; 71ebb (1c:5ebb)
+SetPal_GameFreakIntro: ; 71ebb (1c:5ebb)
ld hl, PalPacket_GameFreakIntro
ld de, BlkPacket_GameFreakIntro
- ld a, $8
- ld [wcf1c], a
+ ld a, SET_PAL_GENERIC
+ ld [wDefaultPaletteCommand], a
ret
; uses PalPacket_Empty to build a packet based on the current map
-BuildOverworldPalPacket: ; 71ec7 (1c:5ec7)
+SetPal_Overworld: ; 71ec7 (1c:5ec7)
ld hl, PalPacket_Empty
- ld de, wcf2d
+ ld de, wPalPacket
ld bc, $10
call CopyData
ld a, [W_CURMAPTILESET]
@@ -162,12 +162,12 @@
jr c, .town
ld a, PAL_ROUTE - 1
.town
- inc a ; a town's pallete ID is its map ID + 1
- ld hl, wcf2e
+ inc a ; a town's palette ID is its map ID + 1
+ ld hl, wPalPacket + 1
ld [hld], a
ld de, BlkPacket_WholeScreen
- ld a, $9
- ld [wcf1c], a
+ ld a, SET_PAL_OVERWORLD
+ ld [wDefaultPaletteCommand], a
ret
.PokemonTowerOrAgatha
ld a, PAL_GREYMON - 1
@@ -181,131 +181,143 @@
; used when a Pokemon is the only thing on the screen
; such as evolution, trading and the Hall of Fame
-SendPokemonPalette_WholeScreen: ; 71f17 (1c:5f17)
+SetPal_PokemonWholeScreen: ; 71f17 (1c:5f17)
push bc
ld hl, PalPacket_Empty
- ld de, wcf2d
+ ld de, wPalPacket
ld bc, $10
call CopyData
pop bc
ld a, c
and a
- ld a, $1e
- jr nz, .asm_71f31
- ld a, [wcf1d]
+ ld a, PAL_BLACK
+ jr nz, .next
+ ld a, [wWholeScreenPaletteMonSpecies]
call DeterminePaletteIDOutOfBattle
-.asm_71f31
- ld [wcf2e], a
- ld hl, wcf2d
+.next
+ ld [wPalPacket + 1], a
+ ld hl, wPalPacket
ld de, BlkPacket_WholeScreen
ret
-BuildTrainerCardPalPacket: ; 71f3b (1c:5f3b)
+SetPal_TrainerCard: ; 71f3b (1c:5f3b)
ld hl, BlkPacket_TrainerCard
- ld de, wcc5b
+ ld de, wTrainerCardBlkPacket
ld bc, $40
call CopyData
- ld de, LoopCounts_71f8f
- ld hl, wcc5d
+ ld de, BadgeBlkDataLengths
+ ld hl, wTrainerCardBlkPacket + 2
ld a, [W_OBTAINEDBADGES]
- ld c, $8
-.asm_71f52
+ ld c, 8
+.badgeLoop
srl a
push af
- jr c, .asm_71f62
+ jr c, .haveBadge
+; The player doens't have the badge, so zero the badge's blk data.
push bc
ld a, [de]
ld c, a
xor a
-.asm_71f5b
+.zeroBadgeDataLoop
ld [hli], a
dec c
- jr nz, .asm_71f5b
+ jr nz, .zeroBadgeDataLoop
pop bc
- jr .asm_71f67
-.asm_71f62
+ jr .nextBadge
+.haveBadge
+; The player does have the badge, so skip past the badge's blk data.
ld a, [de]
-.asm_71f63
+.skipBadgeDataLoop
inc hl
dec a
- jr nz, .asm_71f63
-.asm_71f67
+ jr nz, .skipBadgeDataLoop
+.nextBadge
pop af
inc de
dec c
- jr nz, .asm_71f52
+ jr nz, .badgeLoop
ld hl, PalPacket_TrainerCard
- ld de, wcc5b
+ ld de, wTrainerCardBlkPacket
ret
-PointerTable_71f73: ; 71f73 (1c:5f73)
- dw SendPalPacket_Black
- dw BuildBattlePalPacket
- dw SendPalPacket_TownMap
- dw BuildStatusScreenPalPacket
- dw SendPalPacket_Pokedex
- dw SendPalPacket_Slots
- dw SendPalPacket_Titlescreen
- dw SendPalPacket_NidorinoIntro
- dw SendPalPacket_Generic
- dw BuildOverworldPalPacket
- dw SendPalPacket_PartyMenu
- dw SendPokemonPalette_WholeScreen
- dw SendPalPacket_GameFreakIntro
- dw BuildTrainerCardPalPacket
+SetPalFunctions: ; 71f73 (1c:5f73)
+ dw SetPal_BattleBlack
+ dw SetPal_Battle
+ dw SetPal_TownMap
+ dw SetPal_StatusScreen
+ dw SetPal_Pokedex
+ dw SetPal_Slots
+ dw SetPal_TitleScreen
+ dw SetPal_NidorinoIntro
+ dw SetPal_Generic
+ dw SetPal_Overworld
+ dw SetPal_PartyMenu
+ dw SetPal_PokemonWholeScreen
+ dw SetPal_GameFreakIntro
+ dw SetPal_TrainerCard
-; each byte is the number of loops to make in .asm_71f5b for each badge
-LoopCounts_71f8f: ; 71f8f (1c:5f8f)
- db $06,$06,$06,$12,$06,$06,$06,$06
+; The length of the blk data of each badge on the Trainer Card.
+; The Rainbow Badge has 3 entries because of its many colors.
+BadgeBlkDataLengths: ; 71f8f (1c:5f8f)
+ db 6 ; Boulder Badge
+ db 6 ; Cascade Badge
+ db 6 ; Thunder Badge
+ db 6 * 3 ; Rainbow Badge
+ db 6 ; Soul Badge
+ db 6 ; Marsh Badge
+ db 6 ; Volcano Badge
+ db 6 ; Earth Badge
DeterminePaletteID: ; 71f97 (1c:5f97)
- bit 3, a ; bit 3 of battle status 3, set if current Pokemon is transformed
- ld a, PAL_GREYMON ; if yes, use Ditto's palette
+ bit Transformed, a ; a is battle status 3
+ ld a, PAL_GREYMON ; if the mon has used Transform, use Ditto's palette
ret nz
ld a, [hl]
DeterminePaletteIDOutOfBattle: ; 71f9d (1c:5f9d)
ld [wd11e], a
- and a
- jr z, .idZero
+ and a ; is the mon index 0?
+ jr z, .skipDexNumConversion
push bc
- predef IndexToPokedex ; turn Pokemon ID number into Pokedex number
+ predef IndexToPokedex
pop bc
ld a, [wd11e]
-.idZero
+.skipDexNumConversion
ld e, a
- ld d, $00
- ld hl, MonsterPalettes ; not just for Pokemon, Trainers use it too
+ ld d, 0
+ ld hl, MonsterPalettes ; not just for Pokemon, Trainers use it too
add hl, de
ld a, [hl]
ret
-SendBlkPacket_PartyMenu: ; 71fb6 (1c:5fb6)
+InitPartyMenuBlkPacket: ; 71fb6 (1c:5fb6)
ld hl, BlkPacket_PartyMenu
- ld de, wcf2e
+ ld de, wPartyMenuBlkPacket
ld bc, $30
jp CopyData
-Func_71fc2: ; 71fc2 (1c:5fc2)
- ld hl, wcf1f
- ld a, [wcf2d]
+UpdatePartyMenuBlkPacket: ; 71fc2 (1c:5fc2)
+; Update the blk packet with the palette of the HP bar that is
+; specified in [wWhichPartyMenuHPBar].
+ ld hl, wPartyMenuHPBarColors
+ ld a, [wWhichPartyMenuHPBar]
ld e, a
- ld d, $0
+ ld d, 0
add hl, de
ld e, l
ld d, h
ld a, [de]
and a
- ld e, $5
- jr z, .asm_71fdb
+ ld e, (1 << 2) | 1 ; green
+ jr z, .next
dec a
- ld e, $a
- jr z, .asm_71fdb
- ld e, $f
-.asm_71fdb
+ ld e, (2 << 2) | 2 ; yellow
+ jr z, .next
+ ld e, (3 << 2) | 3 ; red
+.next
push de
- ld hl, wcf37
- ld bc, $6
- ld a, [wcf2d]
+ ld hl, wPartyMenuBlkPacket + 8 + 1
+ ld bc, 6
+ ld a, [wWhichPartyMenuHPBar]
call AddNTimes
pop de
ld [hl], e
@@ -321,11 +333,9 @@
.loop2
; save B for later use
push bc
-; load a non-zero value in $fff9 to disable the routine that checks actual
-; joypad input (said routine, located at $15f, does nothing if $fff9 is not
-; zero)
- ld a,$01
- ld [$fff9],a
+; disable ReadJoypad to prevent it from interfering with sending the packet
+ ld a, 1
+ ld [hDisableJoypadPolling], a
; send RESET signal (P14=LOW, P15=LOW)
xor a
ld [rJOYP],a
@@ -367,7 +377,7 @@
ld a,$30
ld [rJOYP],a
xor a
- ld [$fff9],a
+ ld [hDisableJoypadPolling],a
; wait for about 70000 cycles
call Wait7000
; restore (previously pushed) number of packets
@@ -383,39 +393,39 @@
ld [wOnSGB], a
call CheckSGB
ret nc
- ld a, $1
+ ld a, 1
ld [wOnSGB], a
ld a, [wGBC]
and a
- jr z, .asm_7203f
+ jr z, .notGBC
ret
-.asm_7203f
+.notGBC
di
- call Func_72075
+ call PrepareSuperNintendoVRAMTransfer
ei
- ld a, $1
- ld [wcf2d], a
+ ld a, 1
+ ld [wCopyingSGBTileData], a
ld de, ChrTrnPacket
ld hl, SGBBorderGraphics
- call Func_7210b
+ call CopyGfxToSuperNintendoVRAM
xor a
- ld [wcf2d], a
+ ld [wCopyingSGBTileData], a
ld de, PctTrnPacket
ld hl, BorderPalettes
- call Func_7210b
+ call CopyGfxToSuperNintendoVRAM
xor a
- ld [wcf2d], a
+ ld [wCopyingSGBTileData], a
ld de, PalTrnPacket
ld hl, SuperPalettes
- call Func_7210b
+ call CopyGfxToSuperNintendoVRAM
call ClearVram
ld hl, MaskEnCancelPacket
jp SendSGBPacket
-Func_72075: ; 72075 (1c:6075)
- ld hl, PointerTable_72089
- ld c, $9
-.asm_7207a
+PrepareSuperNintendoVRAMTransfer: ; 72075 (1c:6075)
+ ld hl, .packetPointers
+ ld c, 9
+.loop
push bc
ld a, [hli]
push hl
@@ -426,10 +436,11 @@
inc hl
pop bc
dec c
- jr nz, .asm_7207a
+ jr nz, .loop
ret
-PointerTable_72089: ; 72089 (1c:6089)
+.packetPointers
+; Only the first packet is needed.
dw MaskEnFreezePacket
dw DataSnd_72548
dw DataSnd_72558
@@ -441,17 +452,18 @@
dw DataSnd_725b8
CheckSGB: ; 7209b (1c:609b)
+; Returns whether the game is running on an SGB in carry.
ld hl, MltReq2Packet
di
call SendSGBPacket
- ld a, $1
- ld [$fff9], a
+ ld a, 1
+ ld [hDisableJoypadPolling], a
ei
call Wait7000
ld a, [rJOYP]
and $3
cp $3
- jr nz, .asm_720fd
+ jr nz, .isSGB
ld a, $20
ld [rJOYP], a
ld a, [rJOYP]
@@ -482,21 +494,21 @@
ld a, [rJOYP]
and $3
cp $3
- jr nz, .asm_720fd
- call Func_72102
+ jr nz, .isSGB
+ call SendMltReq1Packet
and a
ret
-.asm_720fd
- call Func_72102
+.isSGB
+ call SendMltReq1Packet
scf
ret
-Func_72102: ; 72102 (1c:6102)
+SendMltReq1Packet: ; 72102 (1c:6102)
ld hl, MltReq1Packet
call SendSGBPacket
jp Wait7000
-Func_7210b: ; 7210b (1c:610b)
+CopyGfxToSuperNintendoVRAM: ; 7210b (1c:610b)
di
push de
call DisableLCD
@@ -503,29 +515,29 @@
ld a, $e4
ld [rBGP], a
ld de, vChars1
- ld a, [wcf2d]
+ ld a, [wCopyingSGBTileData]
and a
- jr z, .asm_72122
- call Func_72188
- jr .asm_72128
-.asm_72122
+ jr z, .notCopyingTileData
+ call CopySGBBorderTiles
+ jr .next
+.notCopyingTileData
ld bc, $1000
call CopyData
-.asm_72128
+.next
ld hl, vBGMap0
ld de, $c
ld a, $80
ld c, $d
-.asm_72132
+.loop
ld b, $14
-.asm_72134
+.innerLoop
ld [hli], a
inc a
dec b
- jr nz, .asm_72134
+ jr nz, .innerLoop
add hl, de
dec c
- jr nz, .asm_72132
+ jr nz, .loop
ld a, $e3
ld [rLCDC], a
pop hl
@@ -548,27 +560,27 @@
jr nz, .loop
ret
-Func_72156: ; 72156 (1c:6156)
+SendSGBPackets: ; 72156 (1c:6156)
ld a, [wGBC]
and a
- jr z, .asm_72165
+ jr z, .notGBC
push de
- call Func_7216d
+ call InitGBCPalettes
pop hl
- call Func_72187
+ call EmptyFunc5
ret
-.asm_72165
+.notGBC
push de
call SendSGBPacket
pop hl
jp SendSGBPacket
-Func_7216d: ; 7216d (1c:616d)
- ld a, $80
- ld [$ff68], a
+InitGBCPalettes: ; 7216d (1c:616d)
+ ld a, $80 ; index 0 with auto-increment
+ ld [rBGPI], a
inc hl
ld c, $20
-.asm_72174
+.loop
ld a, [hli]
inc hl
add a
@@ -576,37 +588,48 @@
add a
ld de, SuperPalettes
add e
- jr nc, .asm_72180
+ jr nc, .noCarry
inc d
-.asm_72180
+.noCarry
ld a, [de]
- ld [$ff69], a
+ ld [rBGPD], a
dec c
- jr nz, .asm_72174
+ jr nz, .loop
ret
-Func_72187: ; 72187 (1c:6187)
+EmptyFunc5: ; 72187 (1c:6187)
ret
-Func_72188: ; 72188 (1c:6188)
- ld b, $80
-.asm_7218a
- ld c, $10
-.asm_7218c
+CopySGBBorderTiles: ; 72188 (1c:6188)
+; SGB tile data is stored in a 4BPP planar format.
+; Each tile is 32 bytes. The first 16 bytes contain bit planes 1 and 2, while
+; the second 16 bytes contain bit planes 3 and 4.
+; This function converts 2BPP planar data into this format by mapping
+; 2BPP colors 0-3 to 4BPP colors 0-3. 4BPP colors 4-15 are not used.
+ ld b, 128
+
+.tileLoop
+
+; Copy bit planes 1 and 2 of the tile data.
+ ld c, 16
+.copyLoop
ld a, [hli]
ld [de], a
inc de
dec c
- jr nz, .asm_7218c
- ld c, $10
+ jr nz, .copyLoop
+
+; Zero bit planes 3 and 4.
+ ld c, 16
xor a
-.asm_72195
+.zeroLoop
ld [de], a
inc de
dec c
- jr nz, .asm_72195
+ jr nz, .zeroLoop
+
dec b
- jr nz, .asm_7218a
+ jr nz, .tileLoop
ret
INCLUDE "data/sgb_packets.asm"
--- a/engine/predefs.asm
+++ b/engine/predefs.asm
@@ -121,7 +121,7 @@
add_predef SetPartyMonTypes
add_predef CanLearnTM
add_predef TMToMove
- add_predef Func_71ddf
+ add_predef _RunPaletteCommand
add_predef StarterDex ; 46
add_predef _AddPartyMon
add_predef UpdateHPBar2
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -21,8 +21,8 @@
call GBPalWhiteOutWithDelay3
call LoadSlotMachineTiles
call LoadFontTilePatterns
- ld b, $5
- call GoPAL_SET
+ ld b, SET_PAL_SLOTS
+ call RunPaletteCommand
call GBPalNormal
ld a, $e4
ld [rOBP0], a
@@ -41,7 +41,7 @@
call GBPalWhiteOutWithDelay3
ld a, $1
ld [wUpdateSpritesEnabled], a
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call ReloadMapSpriteTilePatterns
call ReloadTilesetTilePatterns
.done
--- a/engine/titlescreen.asm
+++ b/engine/titlescreen.asm
@@ -134,8 +134,8 @@
call LoadScreenTilesFromBuffer2
ld a, vBGMap0 / $100
call TitleScreenCopyTileMapToVRAM
- ld b, $6
- call GoPAL_SET
+ ld b, SET_PAL_TITLE_SCREEN
+ call RunPaletteCommand
call GBPalNormal
ld a, %11100100
ld [rOBP0], a
--- a/engine/town_map.asm
+++ b/engine/town_map.asm
@@ -314,8 +314,8 @@
jr .nextTile
.done
call EnableLCD
- ld b, $2
- call GoPAL_SET
+ ld b, SET_PAL_TOWN_MAP
+ call RunPaletteCommand
call Delay3
call GBPalNormal
xor a
@@ -338,7 +338,7 @@
call LoadPlayerSpriteGraphics
call LoadFontTilePatterns
call UpdateSprites
- jp GoPAL_SET_CF1C
+ jp RunDefaultPaletteCommand
DrawPlayerOrBirdSprite: ; 711c4 (1c:51c4)
; a = map number
--- a/engine/trade.asm
+++ b/engine/trade.asm
@@ -268,8 +268,8 @@
call Trade_ClearTileMap
ld b, vBGMap0 / $100
call CopyScreenTileBufferToVRAM
- ld b, $8
- call GoPAL_SET
+ ld b, SET_PAL_GENERIC
+ call RunPaletteCommand
; This function call is pointless. It just copies blank tiles to VRAM that was
; already filled with blank tiles.
@@ -727,10 +727,10 @@
Trade_LoadMonSprite: ; 415a4 (10:55a4)
ld [wcf91], a
ld [wd0b5], a
- ld [wcf1d], a
- ld b, $b
- ld c, $0
- call GoPAL_SET
+ ld [wWholeScreenPaletteMonSpecies], a
+ ld b, SET_PAL_POKEMON_WHOLE_SCREEN
+ ld c, 0
+ call RunPaletteCommand
ld a, [H_AUTOBGTRANSFERENABLED]
xor $1
ld [H_AUTOBGTRANSFERENABLED], a
--- a/home.asm
+++ b/home.asm
@@ -4469,7 +4469,7 @@
call ReloadMapSpriteTilePatterns
call LoadScreenTilesFromBuffer2
call LoadTextBoxTilePatterns
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
jr Delay3
@@ -4499,13 +4499,13 @@
ret
-GoPAL_SET_CF1C:: ; 3ded (0:3ded)
+RunDefaultPaletteCommand:: ; 3ded (0:3ded)
ld b,$ff
-GoPAL_SET:: ; 3def (0:3def)
+RunPaletteCommand:: ; 3def (0:3def)
ld a,[wOnSGB]
and a
ret z
- predef_jump Func_71ddf
+ predef_jump _RunPaletteCommand
GetHealthBarColor::
; Return at hl the palette of
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -659,8 +659,8 @@
.loadNewMap ; load the connected map that was entered
call LoadMapHeader
call PlayDefaultMusicFadeOutCurrent
- ld b,$09
- call GoPAL_SET
+ ld b, SET_PAL_OVERWORLD
+ call RunPaletteCommand
; Since the sprite set shouldn't change, this will just update VRAM slots at
; $C2XE without loading any tile patterns.
callba InitMapSprites
@@ -2343,8 +2343,8 @@
ld a,$01
ld [wUpdateSpritesEnabled],a
call EnableLCD
- ld b,$09
- call GoPAL_SET
+ ld b, SET_PAL_OVERWORLD
+ call RunPaletteCommand
call LoadPlayerSpriteGraphics
ld a,[wd732]
and a,1 << 4 | 1 << 3 ; fly warp or dungeon warp
--- a/home/vblank.asm
+++ b/home/vblank.asm
@@ -74,7 +74,7 @@
callba TrackPlayTime ; keep track of time played
- ld a, [$fff9]
+ ld a, [hDisableJoypadPolling]
and a
call z, ReadJoypad
--- a/hram.asm
+++ b/hram.asm
@@ -317,5 +317,7 @@
hFieldMoveMonMenuTopMenuItemX EQU $FFF7
+hDisableJoypadPolling EQU $FFF9
+
hJoyInput EQU $FFF8
--- a/main.asm
+++ b/main.asm
@@ -3156,7 +3156,7 @@
ld [H_AUTOBGTRANSFERENABLED], a
ld [hTilesetType], a ; no flower/water BG tile animations
call LoadCurrentMapView
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
ld hl, wMapViewVRAMPointer
ld a, [hli]
ld h, [hl]
--- a/wram.asm
+++ b/wram.asm
@@ -477,6 +477,9 @@
ds 2
+wTrainerCardBlkPacket:: ; cc5b
+; $40 bytes
+
wSlotMachineSevenAndBarModeChance:: ; cc5b
; If a random number greater than this value is generated, then the player is
; allowed to have three 7 symbols or bar symbols line up.
@@ -1283,15 +1286,40 @@
; if running on SGB, it's 1, else it's 0
ds 1
-wcf1c:: ds 1 ; used with sgb palettes
-wcf1d:: ds 1 ; used when displaying palettes for Pokemon
-wcf1e:: ds 1 ; used to display palettes for HP bar
-wcf1f:: ds 6 ; used to display HP bars in Pokemon Menu (probably palettes)
-wcf25:: ds 8 ; used to display HP bar for Pokemon Status Screen (probably palettes too)
-wcf2d:: ds 1 ; also used to display HP bar for Pokemon Menu (something about HP colour)
-wcf2e:: ds 2 ; more HP bar palette stuff.
-wcf30:: ds 7 ; used with palettes (apparently for Pokedex)
-wcf37:: ds 20 ; used with palletes too (used for Party Menu)
+wDefaultPaletteCommand:: ; cf1c
+ ds 1
+
+wPlayerHPBarColor:: ; cf1d
+
+wWholeScreenPaletteMonSpecies:: ; cf1d
+; species of the mon whose palette is used for the whole screen
+ ds 1
+
+wEnemyHPBarColor:: ; cf1e
+ ds 1
+
+; 0: green
+; 1: yellow
+; 2: red
+wPartyMenuHPBarColors:: ; cf1f
+ ds 6
+
+wStatusScreenHPBarColor:: ; cf25
+ ds 1
+
+ ds 7
+
+wCopyingSGBTileData:: ; c2fd
+
+wWhichPartyMenuHPBar:: ; cf2d
+
+wPalPacket:: ; cf2d
+ ds 1
+
+wPartyMenuBlkPacket:: ; cf2e
+; $30 bytes
+ ds 29
+
wcf4b:: ds 1 ; storage buffer for various strings
wcf4c:: ds 1 ; used with displaying EXP value, probably also overflowed with wcf4b
wGainBoostedExp:: ; cf4d