mirror of https://github.com/bsnes-emu/bsnes.git
More accurate CGB initial register values. Closes #80
This commit is contained in:
parent
6a7c084177
commit
30f13bd28c
|
@ -10,6 +10,8 @@ Start:
|
||||||
xor a
|
xor a
|
||||||
; Clear chosen input palette
|
; Clear chosen input palette
|
||||||
ldh [InputPalette], a
|
ldh [InputPalette], a
|
||||||
|
; Clear title checksum
|
||||||
|
ldh [TitleChecksum], a
|
||||||
; Clear memory VRAM
|
; Clear memory VRAM
|
||||||
ld hl, $8000
|
ld hl, $8000
|
||||||
call ClearMemoryPage
|
call ClearMemoryPage
|
||||||
|
@ -723,39 +725,38 @@ Preboot:
|
||||||
cpl
|
cpl
|
||||||
ldh [$00], a
|
ldh [$00], a
|
||||||
call ClearVRAMViaHDMA
|
call ClearVRAMViaHDMA
|
||||||
|
|
||||||
|
; Final values for CGB mode
|
||||||
|
ld de, $ff56
|
||||||
|
ld l, $0d
|
||||||
|
|
||||||
ld a, [$143]
|
ld a, [$143]
|
||||||
bit 7, a
|
bit 7, a
|
||||||
jr nz, .cgbGame
|
|
||||||
|
|
||||||
call EmulateDMG
|
call z, EmulateDMG
|
||||||
|
ldh a, [TitleChecksum]
|
||||||
.cgbGame
|
ld b, a
|
||||||
|
|
||||||
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
|
||||||
ldh a, [InputPalette]
|
ldh a, [InputPalette]
|
||||||
and a
|
and a
|
||||||
jr nz, .emulateDMGForCGBGame
|
jr nz, .emulateDMGForCGBGame
|
||||||
IF DEF(AGB)
|
IF DEF(AGB)
|
||||||
; Set registers to match the original AGB-CGB boot
|
; Set registers to match the original AGB-CGB boot
|
||||||
ld bc, $1100
|
; AF = $1100, C = 0
|
||||||
push bc
|
xor a
|
||||||
pop af
|
ld c, a
|
||||||
|
add a, $11
|
||||||
ld h, c
|
ld h, c
|
||||||
ld b, 1
|
ld b, 1
|
||||||
ld c, c
|
|
||||||
ld e, $08
|
|
||||||
ld l, $7c
|
|
||||||
ELSE
|
ELSE
|
||||||
; Set registers to match the original CGB boot
|
; Set registers to match the original CGB boot
|
||||||
ld bc, $1180
|
; AF = $1180, C = 0
|
||||||
push bc
|
xor a
|
||||||
pop af
|
ld c, a
|
||||||
ld c, 0
|
ld a, $11
|
||||||
ld h, c
|
ld h, c
|
||||||
ld b, c
|
; B is set to the title checksum
|
||||||
ld c, c
|
|
||||||
ld e, $08
|
|
||||||
ld l, $7c
|
|
||||||
ENDC
|
ENDC
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -788,25 +789,31 @@ EmulateDMG:
|
||||||
call WaitFrame
|
call WaitFrame
|
||||||
call LoadPalettesFromIndex
|
call LoadPalettesFromIndex
|
||||||
ld a, 4
|
ld a, 4
|
||||||
|
; Set the final values for DMG mode
|
||||||
|
ld d, 0
|
||||||
|
ld e, $8
|
||||||
|
ld l, $7c
|
||||||
ret
|
ret
|
||||||
|
|
||||||
GetPaletteIndex:
|
GetPaletteIndex:
|
||||||
ld a, [$14B] ; Old Licensee
|
ld hl, $14B
|
||||||
|
ld a, [hl] ; Old Licensee
|
||||||
cp $33
|
cp $33
|
||||||
jr z, .newLicensee
|
jr z, .newLicensee
|
||||||
cp 1 ; Nintendo
|
cp 1 ; Nintendo
|
||||||
jr nz, .notNintendo
|
jr nz, .notNintendo
|
||||||
jr .doChecksum
|
jr .doChecksum
|
||||||
.newLicensee
|
.newLicensee
|
||||||
ld a, [$144]
|
ld l, $44
|
||||||
|
ld a, [hli]
|
||||||
cp "0"
|
cp "0"
|
||||||
jr nz, .notNintendo
|
jr nz, .notNintendo
|
||||||
ld a, [$145]
|
ld a, [hl]
|
||||||
cp "1"
|
cp "1"
|
||||||
jr nz, .notNintendo
|
jr nz, .notNintendo
|
||||||
|
|
||||||
.doChecksum
|
.doChecksum
|
||||||
ld hl, $134
|
ld l, $34
|
||||||
ld c, $10
|
ld c, $10
|
||||||
ld b, 0
|
ld b, 0
|
||||||
|
|
||||||
|
@ -848,6 +855,8 @@ GetPaletteIndex:
|
||||||
ld a, l
|
ld a, l
|
||||||
add PalettePerChecksum - TitleChecksums - 1; -1 since hl was incremented
|
add PalettePerChecksum - TitleChecksums - 1; -1 since hl was incremented
|
||||||
ld l, a
|
ld l, a
|
||||||
|
ld a, b
|
||||||
|
ldh [TitleChecksum], a
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -1140,6 +1149,8 @@ SECTION "ROMMax", ROM0[$900]
|
||||||
ds 1
|
ds 1
|
||||||
|
|
||||||
SECTION "HRAM", HRAM[$FF80]
|
SECTION "HRAM", HRAM[$FF80]
|
||||||
|
TitleChecksum:
|
||||||
|
ds 1
|
||||||
BgPalettes:
|
BgPalettes:
|
||||||
ds 8 * 4 * 2
|
ds 8 * 4 * 2
|
||||||
InputPalette:
|
InputPalette:
|
||||||
|
|
Loading…
Reference in New Issue