avoid resetting D to HIGH(BitsSet) unnecessarily

This commit is contained in:
2018-12-31 14:23:56 +01:00
parent 69bba61dcf
commit 1c927caba1

View File

@@ -31,7 +31,8 @@ MemorySet:
AddLiveNeighbors: MACRO
; H register will be incremented with number of alive neighbors
; destroys A, B, C, D, E, does not touch L
; destroys A, B, C, E, does not touch L nor D
; D must be high byte of a BitsSet table (for 0..15)
; load current 2x2 cell and mask out bits that are not neighbors
ld c, LOW(Cells + \1)
@@ -40,7 +41,6 @@ AddLiveNeighbors: MACRO
and a, b
; count bits set
ld d, HIGH(BitsSet)
ld e, a
ld a, [de]
@@ -62,6 +62,9 @@ Conway: MACRO
; reset alive counter
ld h, 0
; set high byte of DE to BitsSet high address
ld d, HIGH(BitsSet)
; Check all neighbors
AddLiveNeighbors 0, \1
AddLiveNeighbors (1 + (\2 + 0) % 8), \3