faster pointer increment while loading to hram + don't wait for rendering, update is too slow anyway

This commit is contained in:
2019-01-01 23:19:53 +01:00
parent 5d4a97c70d
commit dc3f21078c

View File

@@ -129,6 +129,17 @@ LoadCellToHRAM: MACRO
inc c inc c
ENDM ENDM
IncHL: MACRO
IF (\1) == 1
inc hl
ELIF (\1) == -1
dec hl
ELSE
ld de, (\1)
add hl, de
ENDC
ENDM
SECTION "Load cell group and 8 neighbors to HRAM, then compute", ROM0 SECTION "Load cell group and 8 neighbors to HRAM, then compute", ROM0
; \1..\8 offset to neighbors ; \1..\8 offset to neighbors
; destroys all registers ; destroys all registers
@@ -145,29 +156,21 @@ ConwayGroup: MACRO
; load current 2x2 cell then neighbor 2x2 cells to HRAM from old buffer ; load current 2x2 cell then neighbor 2x2 cells to HRAM from old buffer
LoadCellToHRAM LoadCellToHRAM
ld de, \1 IncHL \1
add hl, de
LoadCellToHRAM LoadCellToHRAM
ld de, \2 - \1 IncHL \2 - \1
add hl, de
LoadCellToHRAM LoadCellToHRAM
ld de, \3 - \2 IncHL \3 - \2
add hl, de
LoadCellToHRAM LoadCellToHRAM
ld de, \4 - \3 IncHL \4 - \3
add hl, de
LoadCellToHRAM LoadCellToHRAM
ld de, \5 - \4 IncHL \5 - \4
add hl, de
LoadCellToHRAM LoadCellToHRAM
ld de, \6 - \5 IncHL \6 - \5
add hl, de
LoadCellToHRAM LoadCellToHRAM
ld de, \7 - \6 IncHL \7 - \6
add hl, de
LoadCellToHRAM LoadCellToHRAM
ld de, \8 - \7 IncHL \8 - \7
add hl, de
LoadCellToHRAM LoadCellToHRAM
; reset result ; reset result
@@ -304,8 +307,14 @@ Start:
ld [rLCDC], a ld [rLCDC], a
.mainloop .mainloop
; start rendering
ld a, 20
ldh [TilesLeft], a
ld a, 18
ldh [LinesLeft], a
; enable v-blank and lcd stat interrupt for h-blank ; enable v-blank and lcd stat interrupt for h-blank
; rendering routine is too slow for lcdc right now so disabled
ld a, IEF_VBLANK; | IEF_LCDC ld a, IEF_VBLANK; | IEF_LCDC
ld [rIE], a ld [rIE], a
xor a xor a
@@ -440,24 +449,17 @@ Start:
ld hl, Old ld hl, Old
inc [hl] inc [hl]
; wait end of rendering ; wait end of rendering (not necessary, update is way slower than rendering...)
.waitLines ;.waitRender
; check high byte of TotalToRender ; ldh a, [LinesLeft]
ldh a, [LinesLeft] ; ld b, a
or a ; ldh a, [TilesLeft]
jr z, .waitTiles ; or a, b
halt ; jr z, .swap
jr .waitLines ; halt
; jr .waitRender
.waitTiles ;
; check low byte of TotalToRender ;.swap
ldh a, [TilesLeft]
or a
jr z, .swap
halt
jr .waitTiles
.swap
; enable only v-blank interrupt ; enable only v-blank interrupt
di di
ld a, IEF_VBLANK ld a, IEF_VBLANK
@@ -519,12 +521,6 @@ Start:
ldh [Rendered], a ldh [Rendered], a
ldh [Video], a ldh [Video], a
; set total to render to restart rendering
ld a, 20
ldh [TilesLeft], a
ld a, 18
ldh [LinesLeft], a
jp .mainloop jp .mainloop
SECTION "V-Blank Interrupt Handler", ROM0[$40] SECTION "V-Blank Interrupt Handler", ROM0[$40]