Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Screen handling
#3
You know, looking at this, I'm particularly impressed with this bit:

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.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)