A86: FindPixl Wars


[Prev][Next][Index][Thread]

A86: FindPixl Wars



I only found one problem with Dan's routine: When you load a with d and 
do two RLCA operations, there's a problem.  If d is greater than 128, 
then hl will be one byte too high.  To fix it, change the second RLCA to 
Add a, a.  As is, Dan's is two cycles faster.  I know the other can be 
further optimized.  That's in the next eMail.  The point of this one is 
to accept standard input without using loops.

James Yopp
jYopp@pobox.com

;------------------------------------
FP:                             ;This is a VERY FAST, highly optimized
        push    bc              ;routine. 173 CYCLES CONSTANT!!!! 152 
without push/pop
        ld      a, b            ;and return.  Oh, well. It accepts 
standard input.
        cpl
        and     7
        RLCA
        RLCA
        RLCA
        or      $C7             ;Make our own opcode for the bitsetting.
        ld      (ChgBit), a
        ld      a, b
        and     $78             ;Use bits 3-6
        RRCA                    ;It' masked, so we can use RRCA instead 
of SRL A
        RRCA
        RRCA
        SLA     c               ;Saves time, not space. (2b/8t vs. 1b/11t 
for add hl, hl).
        SLA     c               ; Plus, this gets rid of high-order bits 
that'd ruin output
        ld      h, $3F          ;$FC moved 2 bits right. It'll get moved 
left when we add.
        ld      l, c
        add     hl, hl          ;We need the carry into the h reg. here.
        add     hl, hl
        or      l               ;Gotta move that horizontal coordinate in 
there.
        ld      l, a
        xor     a
        .db     $CB             ;Set X, a is $CBC7. bits 3-5 set which 
bit.
ChgBit: .db     $00             ;This value was loaded at the top of the 
routine.
        pop     bc
        ret
;-----------------------------------------------------


Follow-Ups: