Skip to content

Commit

Permalink
LCDGeneric switches to BANK(wLYOverrides)
Browse files Browse the repository at this point in the history
Used to assume we were already in that bank, but since interrupts can occur during VBlank (and VBlank can change wram banks), it won't do so any more. Worst-case the write to rSCX will take 49 cycles, well below the 76 cycles in doublespeed in the worst-case timing window from STAT interrupt to mode 3.
  • Loading branch information
itsdarsh committed Feb 18, 2025
1 parent 044ff94 commit dc95437
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion home/lcd.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
LCDGeneric::
; At this point it's assumed we're in WRAM bank 5!
; Unlike vanilla, it's *not* assume we're in BANK(wLYOverrides),
; since interrupts can now occur during VBlank
ldh a, [rLY]
cp SCREEN_HEIGHT_PX
jr c, .continue
Expand All @@ -8,12 +9,18 @@ LCDGeneric::
push bc
ld c, a
ld b, HIGH(wLYOverrides)
ldh a, [rSVBK]
push af
ld a, BANK(wLYOverrides)
ldh [rSVBK], a
ld a, [bc]
ld b, a
ldh a, [hLCDCPointer]
ld c, a
ld a, b
ldh [c], a
pop af
ldh [rSVBK], a
pop bc
pop af
reti
Expand Down

0 comments on commit dc95437

Please sign in to comment.