## Re: [stella] Another day, another problem...

 Subject: Re: [stella] Another day, another problem... From: Manuel Polik Date: Fri, 09 Mar 2001 13:39:33 +0100
```Andrew Davie wrote:

Mornin' Andrew!

> Its a bit hard to figure exactly the context in which you need this.

Phew... thanks for typing in all that heap of information!
(You could've ask for the context first, eh? :-))

Ok, I tell you what I'm doing.

In my bulletData byte, there's two Bits distinguishing if the bullet is
moving up/down or left/right.

First I move it, then I check if it went out of bounds, in case I turn
the direction. The vertical solution that does it for me is very simple:

LDA bulletData,X     ; Load data bits
LDY bulletVerPos,X	 ; Load vertical position
BPL BulletDownOK     ; Bullet < 0?
ORA #%00000010	 ; Y: Change direction
BulletDownOK
CPY #UP              ;
BMI BulletUpOK       ; Bullet > \$60?
(2LK!)
AND #%11111101       ; Y: Change direction
BulletUpOK

Now, when comming to the horizontal position, any values from \$80-\$A0
would be in valid range, but already negative!

In my demo, I tricked around this in a way, that my bullets are only
moving one pixel steps horizontally, so I just continue:

LDY bulletHorPos,X
BNE BulletLeftOK   	; value matches exactly?
ORA #%00001000      ; Y: Change direction
BulletLeftOK
CPY #RIGHT
BNE BulletRightOK	; value matches exactly?
AND #%11110111      ; Y: Change direction
BulletRightOK
STA bulletData,X

Now, I think either Thomas' idea would be a possible solution for a
faster than 1 pixel horizontal movement, or I get my other Joker going:

A bullet can either move 1 or 2 pixels in each direction, but I'd always
horizontally start it on even numbers.

Now, I'd catch both the 1 Pixel & the 2 Pixel moving bullets on any
desired bound by comparing with even numbers, right?

Greetings,
Manuel

P.S.: Now I continue studying your article -> every method is useful :-)
Thanks again for submitting it...

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

```