Re: [stella] Delightful horizontal position code...

Subject: Re: [stella] Delightful horizontal position code...
From: "Andrew Davie" <adavie@xxxxxxxxxxxxx>
Date: Mon, 12 Feb 2001 20:53:45 +1100
There's a small optimisation to be made to Thomas's version of the routine.
I think I saved 3 cycles.
New code below.


CalcXPos:

        tay                         ; 2
        lsr                         ; 2
        lsr                         ; 2
        lsr                         ; 2
        lsr                         ; 2
        sta     tmpVar              ; 3 = 13
        tya                         ; 2
        and     #$0f                ; 2
        clc                         ; 2
        adc     tmpVar              ; 3

        ldy     tmpVar              ; 3 << moved this to here

        cmp     #$0f                ; 2
        bcc     .nextPos            ; 2³
        sbc     #$0f                ; 2
        iny                         ; 2 << added this (+2 cycles)
;inc removed from here (-5 cycles)
.nextPos:                           ;   = 14/20

        eor     #%00000111          ; 2
        asl                         ; 2
        asl                         ; 2
        asl                         ; 2
        asl                         ; 2

;ldy removed from here

        rts                         ; 6 = 19


OK, so its a lousy three cycles better... but in the interest of efficency,
etc :)  I just removed the inc of tmpVar (5 cycles) and shifted the load up
to just before that.  Then you just "iny" instead of the costly inc.  Should
work :)

Cheers
A

--
 _  _  _| _ _        _| _    * _                               _  ,
(_|| )(_|( (/_\/\/  (_|(_|\/(_(/_                           ,~' L_|\
                                                         ,-'        \
see my Museum of Soviet Calculators at                  (            \
http://www.taswegian.com/MOSCOW/soviet.html              \    __     /
                                                          L,~'  "\__/
                                                              @--> v



-
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/

Current Thread