Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map change sign fix for goomba color #1

Open
wants to merge 1 commit into
base: goomba_color
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 58 additions & 2 deletions engine/gfx/dma_transfer.asm
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,45 @@ _continue_HDMATransfer:

ret

DoHBlankHDMATransfer:
; LY magic
ld b, $7f
ld a, h
ldh [rHDMA1], a
ld a, l
and $f0 ; high nybble
ldh [rHDMA2], a
ld a, d
and $1f ; lower 5 bits
ldh [rHDMA3], a
ld a, e
and $f0 ; high nybble
ldh [rHDMA4], a
dec c ; c = number of LYs needed
ld e, c
set 7, e ; hblank dma transfers
ldh a, [rLY]
add c ; calculate end LY
cp b ; is the end LY greater than the max LY
call nc, DI_DelayFrame ; if so, delay a frame to reset the LY

lb bc, %11, LOW(rSTAT)
.noHBlankWait
ldh a, [c]
and b
jr z, .noHBlankWait
.hBlankWaitLoop
ldh a, [c]
and b
jr nz, .hBlankWaitLoop
ld hl, rHDMA5
ld [hl], e
ld a, $ff
.waitForHDMA
cp [hl]
jr nz, .waitForHDMA
ret

_LoadHDMAParameters:
ld a, h
ldh [rHDMA1], a
Expand Down Expand Up @@ -574,13 +613,13 @@ HDMATransfer_OnlyTopFourRows:
ld c, $8
ld hl, wScratchTilemap + $80
debgcoord 0, 0, vBGMap1
call HDMATransfer_Wait127Scanlines
call DoHBlankHDMATransfer
ld a, $0
ldh [rVBK], a
ld c, $8
ld hl, wScratchTilemap
debgcoord 0, 0, vBGMap1
call HDMATransfer_Wait127Scanlines
call DoHBlankHDMATransfer
ret

.Copy:
Expand All @@ -602,3 +641,20 @@ HDMATransfer_OnlyTopFourRows:
dec b
jr nz, .outer_loop
ret

DI_DelayFrame:
; I have no idea of what's going on here, but this function is being called while not in di mode
; this is a duct-tape fix and should probably be replaced eventually
ldh a, [rLY]
push bc
ld b, a
.loop
ldh a, [rLY]
and a
jr z, .done
cp b
jr nc, .loop
.done
pop bc
ret