summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/constants/gfx_constants.asm1
-rw-r--r--src/engine/bank1.asm101
-rw-r--r--src/engine/bank2.asm2
-rw-r--r--src/engine/bank3.asm4
-rw-r--r--src/engine/home.asm10
-rw-r--r--src/wram.asm11
6 files changed, 109 insertions, 20 deletions
diff --git a/src/constants/gfx_constants.asm b/src/constants/gfx_constants.asm
index 7ff205c..f5915d3 100644
--- a/src/constants/gfx_constants.asm
+++ b/src/constants/gfx_constants.asm
@@ -8,6 +8,7 @@ BG_MAP_HEIGHT EQU 32 ; tiles
; cgb palette size
CGB_PAL_SIZE EQU 8 ; bytes
+palettes EQUS "* CGB_PAL_SIZE"
; tile size
TILE_SIZE EQU 16 ; bytes
diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm
index 6c9cd9a..7933fc4 100644
--- a/src/engine/bank1.asm
+++ b/src/engine/bank1.asm
@@ -46,7 +46,7 @@ Func_405a: ; 405a (1:405a)
ld [wTileMapFill], a
call DisableLCD
call LoadDuelHUDTiles
- call Func_5aeb
+ call SetDefaultPalettes
ld de, $387f
call Func_2275
ret
@@ -281,7 +281,7 @@ Func_420b: ; 420b (1:420b)
call ZeroObjectPositionsAndToggleOAMCopy
call EmptyScreen
call LoadDuelHUDTiles
- call Func_5aeb
+ call SetDefaultPalettes
ld de, $389f
call Func_2275
call EnableLCD
@@ -2719,7 +2719,7 @@ CopyCGBCardPalette: ; 5a1e (1:5a1e)
add a ; a *= CGB_PAL_SIZE
ld e, a
ld d, $00
- ld hl, wBackgroundPalettesCGB ; wObjectPalettesCGB - 8 * CGB_PAL_SIZE
+ ld hl, wBackgroundPalettesCGB ; wObjectPalettesCGB - 8 palettes
add hl, de
ld de, wCardPalette
ld b, CGB_PAL_SIZE
@@ -2867,8 +2867,97 @@ ApplyCardCGBAttributes: ; 5adb (1:5adb)
ret
; 0x5aeb
-Func_5aeb: ; 5aeb (1:5aeb)
- INCROM $5aeb, $5b7a
+; set the default game palettes for all three systems
+; BGP and OBP0 on DMG
+; SGB0 and SGB1 on SGB
+; BGP0 to BGP5 and OBP1 on CGB
+SetDefaultPalettes: ; 5aeb (1:5aeb)
+ ld a, [wConsole]
+ cp CONSOLE_SGB
+ jr z, .sgb
+ cp CONSOLE_CGB
+ jr z, .cgb
+ ld a, $e4
+ ld [wOBP0], a
+ ld [wBGP], a
+ ld a, $01 ; equivalent to FLUSH_ONE
+ ld [wFlushPaletteFlags], a
+ ret
+.cgb
+ ld a, $04
+ ld [wTextBoxFrameType], a
+ ld de, CGBDefaultPalettes
+ ld hl, wBackgroundPalettesCGB
+ ld c, 5 palettes
+ call .copy_de_to_hl
+ ld de, CGBDefaultPalettes
+ ld hl, wObjectPalettesCGB
+ ld c, CGB_PAL_SIZE
+ call .copy_de_to_hl
+ call SetFlushAllPalettes
+ ret
+.sgb
+ ld a, $04
+ ld [wTextBoxFrameType], a
+ ld a, PAL01 << 3 + 1
+ ld hl, wTempSGBPacket
+ push hl
+ ld [hli], a
+ ld de, Pal01Packet_Default
+ ld c, $0e
+ call .copy_de_to_hl
+ ld [hl], c
+ pop hl
+ call SendSGB
+ ret
+
+.copy_de_to_hl
+ ld a, [de]
+ inc de
+ ld [hli], a
+ dec c
+ jr nz, .copy_de_to_hl
+ ret
+; 0x5b44
+
+CGBDefaultPalettes:
+; BGP0 and OBP0
+ rgb 28, 28, 24
+ rgb 21, 21, 16
+ rgb 10, 10, 8
+ rgb 0, 0, 0
+; BGP1
+ rgb 28, 28, 24
+ rgb 30, 29, 0
+ rgb 30, 3, 0
+ rgb 0, 0, 0
+; BGP2
+ rgb 28, 28, 24
+ rgb 0, 18, 0
+ rgb 12, 11, 20
+ rgb 0, 0, 0
+; BGP3
+ rgb 28, 28, 24
+ rgb 22, 0 ,22
+ rgb 27, 7, 3
+ rgb 0, 0, 0
+; BGP4
+ rgb 28, 28, 24
+ rgb 26, 10, 0
+ rgb 28, 0, 0
+ rgb 0, 0, 0
+
+; first and last byte of the packet not contained here (see SetDefaultPalettes.sgb)
+Pal01Packet_Default:
+; SGB0
+ rgb 28, 28, 24
+ rgb 21, 21, 16
+ rgb 10, 10, 8
+ rgb 0, 0, 0
+; SGB1
+ rgb 26, 10, 0
+ rgb 28, 0, 0
+ rgb 0, 0, 0
JPWriteByteToBGMap0: ; 5b7a (1:5b7a)
jp WriteByteToBGMap0
@@ -2897,7 +2986,7 @@ DrawLargePictureOfCard: ; 5e75 (1:5e75)
call ZeroObjectPositionsAndToggleOAMCopy
call EmptyScreen
call LoadDuelHUDTiles
- call Func_5aeb
+ call SetDefaultPalettes
ld a, $08
ld [wcac2], a
call LoadCardOrDuelMenuBorderTiles
diff --git a/src/engine/bank2.asm b/src/engine/bank2.asm
index 33594c2..e9f2868 100644
--- a/src/engine/bank2.asm
+++ b/src/engine/bank2.asm
@@ -49,7 +49,7 @@ Func_8d56: ; 8d56 (2:4d56)
call LoadDuelHUDTiles
call LoadDuelCardSymbolTiles
call Func_8d0b
- bank1call Func_5aeb
+ bank1call SetDefaultPalettes
ld de, $3cbf
call Func_2275
ret
diff --git a/src/engine/bank3.asm b/src/engine/bank3.asm
index 5458ce9..1df0b19 100644
--- a/src/engine/bank3.asm
+++ b/src/engine/bank3.asm
@@ -439,7 +439,7 @@ Func_c335: ; c335 (3:4335)
ld [wd10d], a
ld hl, wObjectPalettesCGB
ld de, wd0cc
- ld bc, 8 * CGB_PAL_SIZE
+ ld bc, 8 palettes
call CopyDataHLtoDE_SaveRegisters
ret
@@ -450,7 +450,7 @@ Func_c34e: ; c34e (3:434e)
ld [wOBP1], a
ld hl, wd0cc
ld de, wObjectPalettesCGB
- ld bc, 8 * CGB_PAL_SIZE
+ ld bc, 8 palettes
call CopyDataHLtoDE_SaveRegisters
call SetFlushAllPalettes
ret
diff --git a/src/engine/home.asm b/src/engine/home.asm
index 73b5a3b..c416abe 100644
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -558,16 +558,16 @@ FlushPalettes: ; 042d (0:042d)
FlushAllCGBPalettes: ; 0458 (0:0458)
; flush 8 BGP palettes
xor a
- ld b, 8 * CGB_PAL_SIZE
+ ld b, 8 palettes
call CopyCGBPalettes
; flush 8 OBP palettes
ld a, CGB_PAL_SIZE
- ld b, 8 * CGB_PAL_SIZE
+ ld b, 8 palettes
call CopyCGBPalettes
jr FlushPalettes.done
; copy b bytes of CGB palette data starting at
-; wBackgroundPalettesCGB + a * CGB_PAL_SIZE into rBGPD or rOGPD.
+; wBackgroundPalettesCGB + a palettes into rBGPD or rOGPD.
CopyCGBPalettes: ; 0467 (0:0467)
add a
add a
@@ -5370,7 +5370,7 @@ DrawLabeledTextBox: ; 1e00 (0:1e00)
or a
jr z, .draw_top_border
; Console is SGB and frame type is != 0.
-; The text box will be colorized so a SGB command needs to be transferred
+; The text box will be colorized so a SGB command needs to be sent
push de
push bc
call .draw_top_border ; this falls through to drawing the whole box
@@ -5540,7 +5540,7 @@ ContinueDrawingTextBoxCGB:
call CopyLine
pop hl
call BankswitchVRAM1
- ld a, [wTextBoxFrameType]
+ ld a, [wTextBoxFrameType] ; on CGB, wTextBoxFrameType determines the palette and the other attributes
ld e, a
ld d, a
xor a
diff --git a/src/wram.asm b/src/wram.asm
index 736faa4..d957273 100644
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -507,10 +507,10 @@ wTempSGBPacket:: ; cae0
; temporal CGB palette data buffer to eventually save into BGPD or OBPD registers.
wBackgroundPalettesCGB:: ; caf0
- ds 8 * CGB_PAL_SIZE
+ ds 8 palettes
wObjectPalettesCGB:: ; cb30
- ds 8 * CGB_PAL_SIZE
+ ds 8 palettes
ds $4
@@ -880,9 +880,8 @@ wccf2:: ; ccf2
SECTION "WRAM Engine 2", WRAM0
-; color/pattern of the text box border. Values between 0-7?. Interpreted differently depending on console type
-; Note that this doesn't appear to be a selectable option, just changes with the situation.
-; For example the value 4 seems to be used a lot during duels.
+; on CGB, attributes of the text box borders. (values 0-7? so only affects palette?)
+; on SGB, colorize text box border with SGB1 if non-0
wTextBoxFrameType:: ; ccf3
ds $1
@@ -1372,7 +1371,7 @@ wd0cb:: ; d0cb
ds $1
wd0cc:: ; d0cc
- ds 8 * CGB_PAL_SIZE
+ ds 8 palettes
wd10c:: ; d10c
ds $1