use B and C registers for line and tile counters in rendering

This commit is contained in:
2019-01-03 01:09:44 +01:00
parent c21a794db9
commit b7b00de3a5

View File

@@ -489,9 +489,13 @@ Render:
ld h, [hl] ld h, [hl]
ld l, a ld l, a
; set c to point to tiles left to render ; init tile counter in C
.nextline ldh a, [TilesLeft]
ld c, LOW(TilesLeft) ld c, a
; init line counter in B
ldh a, [LinesLeft]
ld b, a
.loop .loop
; check we can still render ; check we can still render
@@ -505,9 +509,7 @@ Render:
inc de inc de
; loop while there are tiles to render ; loop while there are tiles to render
ld a, [$FF00+c] dec c
dec a
ld [$FF00+c], a
jr nz, .loop jr nz, .loop
; go to next line ; go to next line
@@ -519,20 +521,21 @@ Render:
.nocarry .nocarry
; loop while there are lines to render ; loop while there are lines to render
ld c, LOW(LinesLeft) dec b
ld a, [$FF00+c]
dec a
ld [$FF00+c], a
jr z, .finish jr z, .finish
ld a, 20 ld c, 20 ; reset tile counter
ldh [TilesLeft], a
ld c, a
jr .nextline jr .loop
; save incremented video and buffer pointers
.finish .finish
; save counters
ld a, c
ldh [TilesLeft], a
ld a, b
ldh [LinesLeft], a
; save incremented video pointer and buffer pointer
ld a, l ld a, l
ldh [Video], a ldh [Video], a
ld a, h ld a, h