04-18-2012, 01:04 PM
You know, looking at this, I'm particularly impressed with this bit:
As we know, the bit pattern for a screen address is 010LLrrr LLLCCCCC - where L = character line number (0-31), r=row in character. C=column.
This rotates in the 010, and slides over the two first line bits LL.
Then it does something really clever. It puts in the last 3 bits from the original, left in e. I'd have probably done something like:
Which is far more faffing. XOR/AND/XOR. How cool is that for three instructions to merge some bits of one register with another? New trick learned.
Code:
rra
scf
rra
and a
rra
xor e
and 248
xor e
As we know, the bit pattern for a screen address is 010LLrrr LLLCCCCC - where L = character line number (0-31), r=row in character. C=column.
This rotates in the 010, and slides over the two first line bits LL.
Then it does something really clever. It puts in the last 3 bits from the original, left in e. I'd have probably done something like:
Code:
RRCA
RRCA
RRCA
AND %010110000
ld d,a
ld a,e
and 7
or d
Which is far more faffing. XOR/AND/XOR. How cool is that for three instructions to merge some bits of one register with another? New trick learned.