Login
Back to forumSee the full topicGo to last reply

Posted By

indi
on 2006-01-25
14:09:58
 Re: Xply routines...

Thought I'd post thew final routine.... To give you an idea of how important this was, my path system uses a "circle" command which allows complex paths from a single command. Each takes 2 xply's. 6 baddies*2 muls=36 scan lines spent in just the xply routine.

Now however, I've cut that by 12 scan lines... quite a saving... So here it is. You may notice I've added the "dec xplyc" to offset clearing the carry all the time, and I've removed the first "lsr a" since it was shifting nothing, and moved it to "lsr xplyd", which saved another 2.

For a non-table driver routine, its pretty good! Also, if you add a one over table, you can use this as a divide.


;*****************************************************************************
; XPLY routine
;
; enter : xplyc = xp 1 ; xplyd = xp 2
; exit : A = ans hi / xplyc = ans lo
;
; used : a
;
; Totals including RTS (not including jsr to here)
; 163 WORST case - OLD
; 131 BEST case - OLD
;
; 119 worst
; 101 best
;*****************************************************************************
XPLY:
LDA #$00 ; 2
dec xplyc ; 5 pre-decrement to offset a SET carry when adding "xplyc"

lsr xplyd ; 5
BCC !skip1 ; 2
ADC xplyc ; 3 =10
!skip1
ROR ; 2
ROR xplyd ; 5
BCC !skip2 ; 3 = 10 (*9=90 best)
ADC xplyc ;
!skip2
ROR ; 2
ROR xplyd ; 5
BCC !skip3 ; 2
ADC xplyc ; 3 = 12 (*8=96 worst)
!skip3
ROR
ROR xplyd
BCC !skip4
ADC xplyc
!skip4
ROR
ROR xplyd
BCC !skip5
ADC xplyc
!skip5
ROR
ROR xplyd
BCC !skip6
ADC xplyc
!skip6
ROR
ROR xplyd
BCC !skip7
ADC xplyc
!skip7
ROR
ROR xplyd
BCC !skip8
ADC xplyc
!skip8
ROR
ROR xplyd
BCC !skip9
ADC xplyc
!skip9
rts




Back to top


Copyright © Plus/4 World Team, 2001-2024