A89: Re: conditional return


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

A89: Re: conditional return






>
>How can you work a conditional return in 68k?  I tried branching to a label
>before a rts instruction, but that gave me an invalid instruction error.
>Does it have something to do with the differences in the way jsr and bsr
>push?
>
>thanks
>

This is what's going on, if you can help me to get this working, I would
appreciate it.  Everything I've tried has crashed the calc.
It clips the top fine, except that it shouldn't display the sprite at all
when the sprite is completely off the screen instead of resetting to the
first byte of the screen.  I also needed to clip the left of the screen
because FindPixel can't handle negative numbers.

PutSprite:
 movem.l d0-d3/a0-a3,-(a7)
 tst.w d1
 bmi clipTop
 tst.w d0
 bmi clipLeft
 jsr FindPixel
 moveq #15,d0
 lea 64(a0),a2
psLoop:
 clr.l d2
 move.l (a1),d3
 move.l d3,(a2)+
 clr.l d3
 move.w 32(a0),d3
 rol.l d1,d3
 not.l d3
 and.l d3,(a1)
 move.w (a0)+,d2
 lsl.l d1,d2
 or.l d2,(a1)
 add.l #30,a1
 dbra d0,psLoop
 movem.l (a7)+,d0-d3/a0-a3
 rts

clipTop:
 cmp.w #-16,d1
                                        ;should return here if <= -16
 neg.w d1
 and.w #15,d1
 move.b d1,d3
 ext.l d1
 lsl.b #1,d1
 add.l d1,a0
 clr.w d1
 jsr FindPixel
 lea 64(a0),a2
 move.b d3,d0
 eor.b #15,d0
 bra psLoop

clipLeft:
 neg.w d0
 move.w d0,d3
 clr.w d0
 jsr FindPixel
 add.w d3,d1
 moveq #15,d0
 lea 64(a0),a2
 bra psLoop



Follow-Ups: