use C register to store 2x2 updated cell, instead of HRAM byte

This commit is contained in:
2018-12-31 13:34:20 +01:00
parent ab06a7db5a
commit 6d3db56244

View File

@@ -401,6 +401,8 @@ Conway: MACRO
; \3 = mask for first useful neighbor 2x2 cell ; \3 = mask for first useful neighbor 2x2 cell
; \4 = mask for second useful neighbor 2x2 cell ; \4 = mask for second useful neighbor 2x2 cell
; \5 = mask for third useful neighbor 2x2 cell ; \5 = mask for third useful neighbor 2x2 cell
;
; C will store final 2x2 updated cell
; reset alive counter ; reset alive counter
ld h, 0 ld h, 0
@@ -433,9 +435,7 @@ Conway: MACRO
.writealive\@ .writealive\@
; add mask to result ; add mask to result
ldh a, [Result] inc c
or a, b
ldh [Result], a
jr .writedead\@ jr .writedead\@
.dead\@ .dead\@
@@ -517,7 +517,7 @@ ConwayGroup:
; reset result ; reset result
xor a xor a
ldh [Result], a ld c, a
; compute all 4 cells ; compute all 4 cells
Conway 14, 4, 10, 8, 12 Conway 14, 4, 10, 8, 12
@@ -531,11 +531,8 @@ ConwayGroup:
ld h, [hl] ld h, [hl]
ld l, a ld l, a
; load result
ldh a, [Result]
; save result to new buffer ; save result to new buffer
ld [hl], a ld [hl], c
ret ret
@@ -664,14 +661,13 @@ Old: ds 2 ; pointer to bufferX
New: ds 2 ; pointer to bufferX New: ds 2 ; pointer to bufferX
XLoop: ds 1 XLoop: ds 1
YLoop: ds 1 YLoop: ds 1
Cells: ds 9 Cells: ds 9 ; cells loaded from old buffer, order is: self then right, clockwise
Result: ds 1
SECTION "Render Memory", HRAM SECTION "Render Memory", HRAM
LinesLeft: ds 1 ; number of lines left to render LinesLeft: ds 1 ; number of lines left to render
TilesLeft: ds 1 ; number of tiles left to render in current line TilesLeft: ds 1 ; number of tiles left to render in current line
Video: ds 2 ; pointer to tilemap Video: ds 2 ; progressing pointer in tilemap (VRAM)
Rendered: ds 2 ; pointer to bufferX Rendered: ds 2 ; progressing pointer in old buffer
SECTION "Game of Life neighboring cells offset tables", ROM0 SECTION "Game of Life neighboring cells offset tables", ROM0
; for a looping grid of 20x18 cells ; for a looping grid of 20x18 cells