Fixed boot_hwio-C (for SameBoy’s boot). Closes #59

This commit is contained in:
Lior Halphon 2018-04-03 20:10:11 +03:00
parent 5d63892949
commit b1d65fd84f

View File

@ -9,7 +9,7 @@ Start:
xor a xor a
; Clear chosen input palette ; Clear chosen input palette
ld [InputPalette], a ldh [InputPalette], a
; Clear memory VRAM ; Clear memory VRAM
ld hl, $8000 ld hl, $8000
call ClearMemoryPage call ClearMemoryPage
@ -189,7 +189,7 @@ Start:
; Wait ~0.5 seconds ; Wait ~0.5 seconds
ld a, 30 ld a, 30
ld [WaitLoopCounter], a ldh [WaitLoopCounter], a
.waitLoop .waitLoop
call GetInputPaletteIndex call GetInputPaletteIndex
@ -714,11 +714,14 @@ DoIntroAnimation:
ret ret
Preboot: Preboot:
call FadeOut call FadeOut
call ClearVRAMViaHDMA call ClearVRAMViaHDMA
; Select the first bank ; Select the first bank
xor a xor a
ldh [$4F], a ldh [$4F], a
cpl
ldh [$00], a
call ClearVRAMViaHDMA call ClearVRAMViaHDMA
ld a, [$143] ld a, [$143]
@ -729,7 +732,7 @@ Preboot:
.cgbGame .cgbGame
ldh [$4C], a ; One day, I will know what this switch does and how it differs from FF6C ldh [$4C], a ; One day, I will know what this switch does and how it differs from FF6C
ld a, [InputPalette] ldh a, [InputPalette]
and a and a
jr nz, .emulateDMGForCGBGame jr nz, .emulateDMGForCGBGame
IF DEF(AGB) IF DEF(AGB)
@ -770,7 +773,7 @@ EmulateDMG:
call nz, LoadDMGTilemap call nz, LoadDMGTilemap
and $7F and $7F
ld b, a ld b, a
ld a, [InputPalette] ldh a, [InputPalette]
and a and a
jr z, .nothingDown jr z, .nothingDown
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
@ -1010,10 +1013,10 @@ GetInputPaletteIndex:
and $C and $C
add c add c
ld b, a ld b, a
ld a, [InputPalette] ldh a, [InputPalette]
ld c, a ld c, a
ld a, b ld a, b
ld [InputPalette], a ldh [InputPalette], a
cp c cp c
pop bc pop bc
ret z ; No change, don't load ret z ; No change, don't load
@ -1055,27 +1058,27 @@ ChangeAnimationPalette:
ld hl, BgPalettes ; First color, all palette ld hl, BgPalettes ; First color, all palette
call ReplaceColorInAllPalettes call ReplaceColorInAllPalettes
pop hl pop hl
ld [BgPalettes + 2], a ; Second color, first palette ldh [BgPalettes + 2], a ; Second color, first palette
ld a, [hli] ld a, [hli]
push hl push hl
ld hl, BgPalettes + 1 ; First color, all palette ld hl, BgPalettes + 1 ; First color, all palette
call ReplaceColorInAllPalettes call ReplaceColorInAllPalettes
pop hl pop hl
ld [BgPalettes + 3], a ; Second color, first palette ldh [BgPalettes + 3], a ; Second color, first palette
pop af pop af
jr z, .isNotWhite jr z, .isNotWhite
inc hl inc hl
inc hl inc hl
.isNotWhite .isNotWhite
ld a, [hli] ld a, [hli]
ld [BgPalettes + 7 * 8 + 2], a ; Second color, 7th palette ldh [BgPalettes + 7 * 8 + 2], a ; Second color, 7th palette
ld a, [hli] ld a, [hli]
ld [BgPalettes + 7 * 8 + 3], a ; Second color, 7th palette ldh [BgPalettes + 7 * 8 + 3], a ; Second color, 7th palette
ld a, [hli] ld a, [hli]
ld [BgPalettes + 4], a ; Third color, first palette ldh [BgPalettes + 4], a ; Third color, first palette
ld a, [hl] ld a, [hl]
ld [BgPalettes + 5], a ; Third color, first palette ldh [BgPalettes + 5], a ; Third color, first palette
call WaitFrame call WaitFrame
ld hl, BgPalettes ld hl, BgPalettes
@ -1084,7 +1087,7 @@ ChangeAnimationPalette:
call LoadBGPalettes call LoadBGPalettes
; Delay the wait loop while the user is selecting a palette ; Delay the wait loop while the user is selecting a palette
ld a, 30 ld a, 30
ld [WaitLoopCounter], a ldh [WaitLoopCounter], a
pop de pop de
pop bc pop bc
pop hl pop hl
@ -1136,7 +1139,7 @@ SECTION "ROMMax", ROM0[$900]
; Prevent us from overflowing ; Prevent us from overflowing
ds 1 ds 1
SECTION "RAM", WRAM0[$C000] SECTION "HRAM", HRAM[$FF80]
BgPalettes: BgPalettes:
ds 8 * 4 * 2 ds 8 * 4 * 2
InputPalette: InputPalette: