Save 16 bytes in the CGB boot ROM
This commit is contained in:
parent
ccc7d2e887
commit
24220defd6
@ -181,8 +181,7 @@ ENDC
|
||||
dec c
|
||||
jr nz, .expandPalettesLoop
|
||||
|
||||
ld hl, BgPalettes
|
||||
call LoadBGPalettes64
|
||||
call LoadPalettesFromHRAM
|
||||
|
||||
; Turn on LCD
|
||||
ld a, $91
|
||||
@ -530,7 +529,7 @@ Palettes:
|
||||
dw $7FFF, $7FEA, $7D5F, $0000 ; CGA 1
|
||||
dw $4778, $3290, $1D87, $0861 ; DMG LCD
|
||||
|
||||
KeyCombinationPalettes
|
||||
KeyCombinationPalettes:
|
||||
db 1 * 3 ; Right
|
||||
db 48 * 3 ; Left
|
||||
db 5 * 3 ; Up
|
||||
@ -795,7 +794,6 @@ IF !DEF(FAST)
|
||||
.fadeLoop
|
||||
ld c, 32 ; 32 colors to fade
|
||||
ld hl, BgPalettes
|
||||
push hl
|
||||
.frameLoop
|
||||
push bc
|
||||
|
||||
@ -848,8 +846,7 @@ IF !DEF(FAST)
|
||||
jr nz, .frameLoop
|
||||
|
||||
call WaitFrame
|
||||
pop hl
|
||||
call LoadBGPalettes64
|
||||
call LoadPalettesFromHRAM
|
||||
call WaitFrame
|
||||
dec b
|
||||
jr nz, .fadeLoop
|
||||
@ -907,7 +904,7 @@ ENDC
|
||||
|
||||
GetKeyComboPalette:
|
||||
ld hl, KeyCombinationPalettes - 1 ; Return value is 1-based, 0 means nothing down
|
||||
ld c ,a
|
||||
ld c, a
|
||||
ld b, 0
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
@ -1006,6 +1003,7 @@ GetPaletteIndex:
|
||||
xor a
|
||||
ret
|
||||
|
||||
; optimizations in callers rely on this returning with b = 0
|
||||
GetPaletteCombo:
|
||||
ld hl, PaletteCombinations
|
||||
ld b, 0
|
||||
@ -1022,7 +1020,7 @@ LoadPalettesFromIndex: ; a = index of combination
|
||||
ld a, [hli]
|
||||
push hl
|
||||
ld hl, Palettes
|
||||
ld b, 0
|
||||
; b is already 0
|
||||
ld c, a
|
||||
add hl, bc
|
||||
ld d, 8
|
||||
@ -1035,15 +1033,15 @@ LoadPalettesFromIndex: ; a = index of combination
|
||||
jr .loadObjPalette
|
||||
.loadBGPalette
|
||||
;BG Palette
|
||||
ld a, [hli]
|
||||
ld c, [hl]
|
||||
; b is already 0
|
||||
ld hl, Palettes
|
||||
ld b, 0
|
||||
ld c, a
|
||||
add hl, bc
|
||||
ld d, 8
|
||||
jr LoadBGPalettes
|
||||
|
||||
LoadBGPalettes64:
|
||||
LoadPalettesFromHRAM:
|
||||
ld hl, BgPalettes
|
||||
ld d, 64
|
||||
|
||||
LoadBGPalettes:
|
||||
@ -1076,6 +1074,7 @@ _ClearVRAMViaHDMA:
|
||||
jr nz, .loop
|
||||
ret
|
||||
|
||||
; clobbers AF and HL
|
||||
GetInputPaletteIndex:
|
||||
ld a, $20 ; Select directions
|
||||
ldh [$00], a
|
||||
@ -1083,11 +1082,10 @@ GetInputPaletteIndex:
|
||||
cpl
|
||||
and $F
|
||||
ret z ; No direction keys pressed, no palette
|
||||
push bc
|
||||
ld c, 0
|
||||
|
||||
ld l, 0
|
||||
.directionLoop
|
||||
inc c
|
||||
inc l
|
||||
rra
|
||||
jr nc, .directionLoop
|
||||
|
||||
@ -1100,15 +1098,13 @@ GetInputPaletteIndex:
|
||||
rla
|
||||
rla
|
||||
and $C
|
||||
add c
|
||||
ld b, a
|
||||
add l
|
||||
ld l, a
|
||||
ldh a, [InputPalette]
|
||||
ld c, a
|
||||
ld a, b
|
||||
ldh [InputPalette], a
|
||||
cp c
|
||||
pop bc
|
||||
cp l
|
||||
ret z ; No change, don't load
|
||||
ld a, l
|
||||
ldh [InputPalette], a
|
||||
; Slide into change Animation Palette
|
||||
|
||||
ChangeAnimationPalette:
|
||||
@ -1118,10 +1114,8 @@ ChangeAnimationPalette:
|
||||
call GetPaletteCombo
|
||||
inc l
|
||||
inc l
|
||||
ld a, [hl]
|
||||
ld c, [hl]
|
||||
ld hl, Palettes + 1
|
||||
ld b, 0
|
||||
ld c, a
|
||||
add hl, bc
|
||||
ld a, [hld]
|
||||
cp $7F ; Is white color?
|
||||
@ -1186,8 +1180,7 @@ ChangeAnimationPalette:
|
||||
|
||||
|
||||
call WaitFrame
|
||||
ld hl, BgPalettes
|
||||
call LoadBGPalettes64
|
||||
call LoadPalettesFromHRAM
|
||||
; Delay the wait loop while the user is selecting a palette
|
||||
ld a, 45
|
||||
ldh [WaitLoopCounter], a
|
||||
|
Loading…
Reference in New Issue
Block a user