Fix HDMA usage in SameBoot

This commit is contained in:
Lior Halphon 2022-01-29 02:12:27 +02:00
parent 26656de44f
commit 9e3ad31df1

View File

@ -7,13 +7,6 @@ Start:
; Clear memory VRAM ; Clear memory VRAM
call ClearMemoryPage8000 call ClearMemoryPage8000
ld a, 2
ld c, $70
ld [c], a
; Clear RAM Bank 2 (Like the original boot ROM)
ld h, $D0
call ClearMemoryPage
ld [c], a
; Clear OAM ; Clear OAM
ld h, $fe ld h, $fe
@ -220,8 +213,11 @@ ENDC
IF DEF(AGB) IF DEF(AGB)
ld b, 1 ld b, 1
ENDC ENDC
jr BootGame
; Will be filled with NOPs HDMAData:
db $D0, $00, $98, $A0, $12
db $D0, $00, $80, $00, $40
SECTION "BootGame", ROM0[$fe] SECTION "BootGame", ROM0[$fe]
BootGame: BootGame:
@ -835,8 +831,6 @@ IF !DEF(FAST)
res 2, b res 2, b
.redNotMaxed .redNotMaxed
; add de, bc
; ld [hli], de
ld a, e ld a, e
add c add c
ld [hli], a ld [hli], a
@ -854,11 +848,18 @@ IF !DEF(FAST)
dec b dec b
jr nz, .fadeLoop jr nz, .fadeLoop
ENDC ENDC
ld a, 1 ld a, 2
ldh [$70], a
; Clear RAM Bank 2 (Like the original boot ROM)
ld hl, $D000
call ClearMemoryPage
inc a
call ClearVRAMViaHDMA call ClearVRAMViaHDMA
call _ClearVRAMViaHDMA call _ClearVRAMViaHDMA
call ClearVRAMViaHDMA ; A = $40, so it's bank 0 call ClearVRAMViaHDMA ; A = $40, so it's bank 0
ld a, $ff xor a
ldh [$70], a
cpl
ldh [$00], a ldh [$00], a
; Final values for CGB mode ; Final values for CGB mode
@ -1070,6 +1071,7 @@ ClearVRAMViaHDMA:
ldh [$4F], a ldh [$4F], a
ld hl, HDMAData ld hl, HDMAData
_ClearVRAMViaHDMA: _ClearVRAMViaHDMA:
call WaitFrame ; Wait for vblank
ld c, $51 ld c, $51
ld b, 5 ld b, 5
.loop .loop
@ -1223,10 +1225,6 @@ LoadDMGTilemap:
pop af pop af
ret ret
HDMAData:
db $88, $00, $98, $A0, $12
db $88, $00, $80, $00, $40
BootEnd: BootEnd:
IF BootEnd > $900 IF BootEnd > $900
FAIL "BootROM overflowed: {BootEnd}" FAIL "BootROM overflowed: {BootEnd}"