Merge branch 'master' of https://github.com/LIJI32/SameBoy
This commit is contained in:
commit
ca24f54bee
@ -14,12 +14,12 @@ Start:
|
|||||||
ld h, $D0
|
ld h, $D0
|
||||||
call ClearMemoryPage
|
call ClearMemoryPage
|
||||||
ld [c], a
|
ld [c], a
|
||||||
|
|
||||||
; Clear chosen input palette
|
; Clear chosen input palette
|
||||||
ldh [InputPalette], a
|
ldh [InputPalette], a
|
||||||
; Clear title checksum
|
; Clear title checksum
|
||||||
ldh [TitleChecksum], a
|
ldh [TitleChecksum], a
|
||||||
|
|
||||||
ld a, $80
|
ld a, $80
|
||||||
ldh [$26], a
|
ldh [$26], a
|
||||||
ldh [$11], a
|
ldh [$11], a
|
||||||
@ -36,7 +36,7 @@ Start:
|
|||||||
cpl
|
cpl
|
||||||
dec c
|
dec c
|
||||||
jr nz, .waveformLoop
|
jr nz, .waveformLoop
|
||||||
|
|
||||||
|
|
||||||
; Clear OAM
|
; Clear OAM
|
||||||
ld h, $fe
|
ld h, $fe
|
||||||
@ -45,7 +45,7 @@ Start:
|
|||||||
ldi [hl], a
|
ldi [hl], a
|
||||||
dec c
|
dec c
|
||||||
jr nz, .clearOAMLoop
|
jr nz, .clearOAMLoop
|
||||||
|
|
||||||
; Init BG palette
|
; Init BG palette
|
||||||
ld a, $fc
|
ld a, $fc
|
||||||
ldh [$47], a
|
ldh [$47], a
|
||||||
@ -148,13 +148,13 @@ ENDC
|
|||||||
; One white
|
; One white
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
|
|
||||||
; Mixed with white
|
; Mixed with white
|
||||||
ld a, [de]
|
ld a, [de]
|
||||||
inc e
|
inc e
|
||||||
or $20
|
or $20
|
||||||
ld b, a
|
ld b, a
|
||||||
|
|
||||||
ld a, [de]
|
ld a, [de]
|
||||||
dec e
|
dec e
|
||||||
or $84
|
or $84
|
||||||
@ -163,26 +163,25 @@ ENDC
|
|||||||
ld [hl], b
|
ld [hl], b
|
||||||
inc l
|
inc l
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
|
|
||||||
; One black
|
; One black
|
||||||
xor a
|
xor a
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
|
|
||||||
; One color
|
; One color
|
||||||
ld a, [de]
|
ld a, [de]
|
||||||
inc e
|
inc e
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
ld a, [de]
|
ld a, [de]
|
||||||
inc e
|
inc e
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
|
|
||||||
xor a
|
xor a
|
||||||
dec c
|
dec c
|
||||||
jr nz, .expandPalettesLoop
|
jr nz, .expandPalettesLoop
|
||||||
|
|
||||||
ld hl, BgPalettes
|
call LoadPalettesFromHRAM
|
||||||
call LoadBGPalettes64
|
|
||||||
|
|
||||||
; Turn on LCD
|
; Turn on LCD
|
||||||
ld a, $91
|
ld a, $91
|
||||||
@ -205,7 +204,7 @@ IF !DEF(FAST)
|
|||||||
; Play second sound
|
; Play second sound
|
||||||
ld a, $c1
|
ld a, $c1
|
||||||
call PlaySound
|
call PlaySound
|
||||||
|
|
||||||
.waitLoop
|
.waitLoop
|
||||||
call GetInputPaletteIndex
|
call GetInputPaletteIndex
|
||||||
call WaitFrame
|
call WaitFrame
|
||||||
@ -530,7 +529,7 @@ Palettes:
|
|||||||
dw $7FFF, $7FEA, $7D5F, $0000 ; CGA 1
|
dw $7FFF, $7FEA, $7D5F, $0000 ; CGA 1
|
||||||
dw $4778, $3290, $1D87, $0861 ; DMG LCD
|
dw $4778, $3290, $1D87, $0861 ; DMG LCD
|
||||||
|
|
||||||
KeyCombinationPalettes
|
KeyCombinationPalettes:
|
||||||
db 1 * 3 ; Right
|
db 1 * 3 ; Right
|
||||||
db 48 * 3 ; Left
|
db 48 * 3 ; Left
|
||||||
db 5 * 3 ; Up
|
db 5 * 3 ; Up
|
||||||
@ -548,7 +547,7 @@ KeyCombinationPalettes
|
|||||||
db 52 * 3 ; Left + A + B
|
db 52 * 3 ; Left + A + B
|
||||||
db 53 * 3 ; Up + A + B
|
db 53 * 3 ; Up + A + B
|
||||||
db 54 * 3 ; Down + A + B
|
db 54 * 3 ; Down + A + B
|
||||||
|
|
||||||
TrademarkSymbol:
|
TrademarkSymbol:
|
||||||
db $3c,$42,$b9,$a5,$b9,$a5,$42,$3c
|
db $3c,$42,$b9,$a5,$b9,$a5,$42,$3c
|
||||||
|
|
||||||
@ -795,10 +794,9 @@ IF !DEF(FAST)
|
|||||||
.fadeLoop
|
.fadeLoop
|
||||||
ld c, 32 ; 32 colors to fade
|
ld c, 32 ; 32 colors to fade
|
||||||
ld hl, BgPalettes
|
ld hl, BgPalettes
|
||||||
push hl
|
|
||||||
.frameLoop
|
.frameLoop
|
||||||
push bc
|
push bc
|
||||||
|
|
||||||
; Brighten Color
|
; Brighten Color
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld e, a
|
ld e, a
|
||||||
@ -843,13 +841,12 @@ IF !DEF(FAST)
|
|||||||
adc b
|
adc b
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
pop bc
|
pop bc
|
||||||
|
|
||||||
dec c
|
dec c
|
||||||
jr nz, .frameLoop
|
jr nz, .frameLoop
|
||||||
|
|
||||||
call WaitFrame
|
call WaitFrame
|
||||||
pop hl
|
call LoadPalettesFromHRAM
|
||||||
call LoadBGPalettes64
|
|
||||||
call WaitFrame
|
call WaitFrame
|
||||||
dec b
|
dec b
|
||||||
jr nz, .fadeLoop
|
jr nz, .fadeLoop
|
||||||
@ -860,21 +857,21 @@ ENDC
|
|||||||
call ClearVRAMViaHDMA ; A = $40, so it's bank 0
|
call ClearVRAMViaHDMA ; A = $40, so it's bank 0
|
||||||
ld a, $ff
|
ld a, $ff
|
||||||
ldh [$00], a
|
ldh [$00], a
|
||||||
|
|
||||||
; Final values for CGB mode
|
; Final values for CGB mode
|
||||||
ld d, a
|
ld d, a
|
||||||
ld e, c
|
ld e, c
|
||||||
ld l, $0d
|
ld l, $0d
|
||||||
|
|
||||||
ld a, [$143]
|
ld a, [$143]
|
||||||
bit 7, a
|
bit 7, a
|
||||||
call z, EmulateDMG
|
call z, EmulateDMG
|
||||||
bit 7, a
|
bit 7, a
|
||||||
|
|
||||||
ldh [$4C], a
|
ldh [$4C], a
|
||||||
ldh a, [TitleChecksum]
|
ldh a, [TitleChecksum]
|
||||||
ld b, a
|
ld b, a
|
||||||
|
|
||||||
jr z, .skipDMGForCGBCheck
|
jr z, .skipDMGForCGBCheck
|
||||||
ldh a, [InputPalette]
|
ldh a, [InputPalette]
|
||||||
and a
|
and a
|
||||||
@ -904,10 +901,10 @@ ENDC
|
|||||||
ldh [$4C], a
|
ldh [$4C], a
|
||||||
ld a, $1
|
ld a, $1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
GetKeyComboPalette:
|
GetKeyComboPalette:
|
||||||
ld hl, KeyCombinationPalettes - 1 ; Return value is 1-based, 0 means nothing down
|
ld hl, KeyCombinationPalettes - 1 ; Return value is 1-based, 0 means nothing down
|
||||||
ld c ,a
|
ld c, a
|
||||||
ld b, 0
|
ld b, 0
|
||||||
add hl, bc
|
add hl, bc
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
@ -1005,7 +1002,8 @@ GetPaletteIndex:
|
|||||||
.notNintendo
|
.notNintendo
|
||||||
xor a
|
xor a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; optimizations in callers rely on this returning with b = 0
|
||||||
GetPaletteCombo:
|
GetPaletteCombo:
|
||||||
ld hl, PaletteCombinations
|
ld hl, PaletteCombinations
|
||||||
ld b, 0
|
ld b, 0
|
||||||
@ -1022,7 +1020,7 @@ LoadPalettesFromIndex: ; a = index of combination
|
|||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
push hl
|
push hl
|
||||||
ld hl, Palettes
|
ld hl, Palettes
|
||||||
ld b, 0
|
; b is already 0
|
||||||
ld c, a
|
ld c, a
|
||||||
add hl, bc
|
add hl, bc
|
||||||
ld d, 8
|
ld d, 8
|
||||||
@ -1035,15 +1033,15 @@ LoadPalettesFromIndex: ; a = index of combination
|
|||||||
jr .loadObjPalette
|
jr .loadObjPalette
|
||||||
.loadBGPalette
|
.loadBGPalette
|
||||||
;BG Palette
|
;BG Palette
|
||||||
ld a, [hli]
|
ld c, [hl]
|
||||||
|
; b is already 0
|
||||||
ld hl, Palettes
|
ld hl, Palettes
|
||||||
ld b, 0
|
|
||||||
ld c, a
|
|
||||||
add hl, bc
|
add hl, bc
|
||||||
ld d, 8
|
ld d, 8
|
||||||
jr LoadBGPalettes
|
jr LoadBGPalettes
|
||||||
|
|
||||||
LoadBGPalettes64:
|
LoadPalettesFromHRAM:
|
||||||
|
ld hl, BgPalettes
|
||||||
ld d, 64
|
ld d, 64
|
||||||
|
|
||||||
LoadBGPalettes:
|
LoadBGPalettes:
|
||||||
@ -1076,6 +1074,7 @@ _ClearVRAMViaHDMA:
|
|||||||
jr nz, .loop
|
jr nz, .loop
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; clobbers AF and HL
|
||||||
GetInputPaletteIndex:
|
GetInputPaletteIndex:
|
||||||
ld a, $20 ; Select directions
|
ld a, $20 ; Select directions
|
||||||
ldh [$00], a
|
ldh [$00], a
|
||||||
@ -1083,11 +1082,10 @@ GetInputPaletteIndex:
|
|||||||
cpl
|
cpl
|
||||||
and $F
|
and $F
|
||||||
ret z ; No direction keys pressed, no palette
|
ret z ; No direction keys pressed, no palette
|
||||||
push bc
|
|
||||||
ld c, 0
|
|
||||||
|
|
||||||
|
ld l, 0
|
||||||
.directionLoop
|
.directionLoop
|
||||||
inc c
|
inc l
|
||||||
rra
|
rra
|
||||||
jr nc, .directionLoop
|
jr nc, .directionLoop
|
||||||
|
|
||||||
@ -1100,15 +1098,13 @@ GetInputPaletteIndex:
|
|||||||
rla
|
rla
|
||||||
rla
|
rla
|
||||||
and $C
|
and $C
|
||||||
add c
|
add l
|
||||||
ld b, a
|
ld l, a
|
||||||
ldh a, [InputPalette]
|
ldh a, [InputPalette]
|
||||||
ld c, a
|
cp l
|
||||||
ld a, b
|
|
||||||
ldh [InputPalette], a
|
|
||||||
cp c
|
|
||||||
pop bc
|
|
||||||
ret z ; No change, don't load
|
ret z ; No change, don't load
|
||||||
|
ld a, l
|
||||||
|
ldh [InputPalette], a
|
||||||
; Slide into change Animation Palette
|
; Slide into change Animation Palette
|
||||||
|
|
||||||
ChangeAnimationPalette:
|
ChangeAnimationPalette:
|
||||||
@ -1118,10 +1114,8 @@ ChangeAnimationPalette:
|
|||||||
call GetPaletteCombo
|
call GetPaletteCombo
|
||||||
inc l
|
inc l
|
||||||
inc l
|
inc l
|
||||||
ld a, [hl]
|
ld c, [hl]
|
||||||
ld hl, Palettes + 1
|
ld hl, Palettes + 1
|
||||||
ld b, 0
|
|
||||||
ld c, a
|
|
||||||
add hl, bc
|
add hl, bc
|
||||||
ld a, [hld]
|
ld a, [hld]
|
||||||
cp $7F ; Is white color?
|
cp $7F ; Is white color?
|
||||||
@ -1131,7 +1125,7 @@ ChangeAnimationPalette:
|
|||||||
.isWhite
|
.isWhite
|
||||||
push af
|
push af
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
|
|
||||||
push hl
|
push hl
|
||||||
ld hl, BgPalettes ; First color, all palettes
|
ld hl, BgPalettes ; First color, all palettes
|
||||||
call ReplaceColorInAllPalettes
|
call ReplaceColorInAllPalettes
|
||||||
@ -1148,7 +1142,7 @@ ChangeAnimationPalette:
|
|||||||
call ReplaceColorInAllPalettes
|
call ReplaceColorInAllPalettes
|
||||||
pop hl
|
pop hl
|
||||||
ldh [BgPalettes + 7], a ; Fourth color, first palette
|
ldh [BgPalettes + 7], a ; Fourth color, first palette
|
||||||
|
|
||||||
pop af
|
pop af
|
||||||
jr z, .isNotWhite
|
jr z, .isNotWhite
|
||||||
inc hl
|
inc hl
|
||||||
@ -1173,12 +1167,12 @@ ChangeAnimationPalette:
|
|||||||
rra
|
rra
|
||||||
ld [BgPalettes + 7 * 8 + 2], a
|
ld [BgPalettes + 7 * 8 + 2], a
|
||||||
dec l
|
dec l
|
||||||
|
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ldh [BgPalettes + 7 * 8 + 6], a ; Fourth color, 7th palette
|
ldh [BgPalettes + 7 * 8 + 6], a ; Fourth color, 7th palette
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ldh [BgPalettes + 7 * 8 + 7], a ; Fourth color, 7th palette
|
ldh [BgPalettes + 7 * 8 + 7], a ; Fourth color, 7th palette
|
||||||
|
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ldh [BgPalettes + 4], a ; Third color, first palette
|
ldh [BgPalettes + 4], a ; Third color, first palette
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
@ -1186,8 +1180,7 @@ ChangeAnimationPalette:
|
|||||||
|
|
||||||
|
|
||||||
call WaitFrame
|
call WaitFrame
|
||||||
ld hl, BgPalettes
|
call LoadPalettesFromHRAM
|
||||||
call LoadBGPalettes64
|
|
||||||
; Delay the wait loop while the user is selecting a palette
|
; Delay the wait loop while the user is selecting a palette
|
||||||
ld a, 45
|
ld a, 45
|
||||||
ldh [WaitLoopCounter], a
|
ldh [WaitLoopCounter], a
|
||||||
@ -1223,11 +1216,11 @@ LoadDMGTilemap:
|
|||||||
.tilemapDone
|
.tilemapDone
|
||||||
pop af
|
pop af
|
||||||
ret
|
ret
|
||||||
|
|
||||||
HDMAData:
|
HDMAData:
|
||||||
db $88, $00, $98, $A0, $12
|
db $88, $00, $98, $A0, $12
|
||||||
db $88, $00, $80, $00, $40
|
db $88, $00, $80, $00, $40
|
||||||
|
|
||||||
BootEnd:
|
BootEnd:
|
||||||
IF BootEnd > $900
|
IF BootEnd > $900
|
||||||
FAIL "BootROM overflowed: {BootEnd}"
|
FAIL "BootROM overflowed: {BootEnd}"
|
||||||
|
Loading…
Reference in New Issue
Block a user