[A89] Quite in here... let's discuss something!


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

[A89] Quite in here... let's discuss something!




Hi people!

I think it's too quite in this mailing list... but still there are many
people doing 68k asm for the TI, aren't they? There can be learned much from
mailing lists.. I want to discuss a sprite routine made by Joe
Wingbermuehle, coz i saw the code and saw so many things that could be
better (i think). Maybe I say some things wrong then you can correct me
maybe...
The code can be found at http://joewing.calc.org/program/asm/m68kcode.shtml
So here it is with my comments:

;---------= PutSprite =---------
; Sprite routine for the TI-92
; by Joe Wingbermuehle
; XOR a sprite to the display.
; Input: a0->sprite
;  d0.w, d1.w = x,y
;  d2.w = size
; Destroyed: a0,a1,d0,d1,d2,d3,d4
PutSprite:
 movea.l #tios::main_lcd,a1
 mulu.w #30,d1

Ok this is the first thing. Mulu #30,d1 costs 38+4*2=46 clocks. Faster is(28
ticks):

move.w   d1,d2
lsl.w    #5,d1
sub.w    d2,d1
sub.w    d2,d1

Ok let's continue...

 ext.l d1
 adda.l d1,a1

Whow what's this? I thought adda automatically sign-extends source operands?
Faster is:

adda.w    d1,a1

----

 ext.l d0
 move.l d0,d3
 andi.l #15,d3

d3 is being used as a shift-count register. But the programmers manual says
the count is register modulo 64, that means only the first 7 bits are used.
So, andi.b #15,d3 is also enough

 andi.l #$FFFFFFF0,d0
 lsr.l #3,d0
 adda.l d0,a1

This is a bit the same. EXT's and Longs are used, while words work also. The
last 6 lines can better be:

move.l    d0,d3
andi.b    #15,d3
andi.b    #$F0,d0
lsr.l     #3,d0
adda.w    d0,a1

----

putSprite_loop1:
 clr.l d4

Clear long on register operands cost 6 ticks. MOVEQ #0,Dn costs 4 ticks and
does the same.

 move.w (a0)+,d4
 swap d4
 lsr.l d3,d4
 eor.l d4,(a1)
 lea 30(a1),a1

Ah, here it was right too choose LEA and not ADDA, LEA is faster. ADDA.W
with immediate source operand should never be used.

 dbra d2,putSprite_loop1
 rts

----


Maybe I helped some people with this, maybe you can help me.

Bye bye

Cheiz



Follow-Ups: