Re: A82: Zpong


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

Re: A82: Zpong



Here are two routines:

Several notes:
1) I had some problems with this, never fixed them (Basically, when you called
drawpaddle or clearpaddle, the ball bounces back at about 80 instead of 95. Dunno
why), I just used Point_on instead. BTW: Point_On can draw a border around the
entire screen faster than the human eye can see. Shouldn't have any speed
problems with it. I'm now using it in my pong game, and it works fine. It makes
it a bit easier, since I was already using it for the ball. I would have had to
convert between the two coordinates to figure if the ball had hit the paddle or
not.
2) To use them, put the y position of the top of the paddle into a. Put the x
position into b, and for DrawPaddle only, put the paddle into c. (Ex: %10000000
for the left or %00000001 for the right)

ClearPaddle:   ; This will clear the 8x8 square with the upper-right corner at b,
a
 out ($10), a  ; a is already loaded with the Y value, and since we have not
written to the display controller in a while, no delay is needed. Tell the
display controller the Y coordinate

 ld a, b   ; Get the X coordinate from b into a
 call $7F3   ; Delay for the display controller
 out ($10), a  ; Tell the display controller the X coordinate

 ld b, Paddle  ; The paddle is as tall as the number in paddle, so we repeat the
loop 8 times. This is so it is easy to change the length. Just change the number
what paddle is
 ld a, %00000000  ; We are drawing a zero byte, to erase the paddle
ClrLoop:
 call $7F3   ; Delay for the display controller
 out ($11), a  ; Write a byte to the display controller
 djnz ClrLoop  ; Repeat until we have written 8
 ret    ; Return to where we left off

DrawPaddle:    ; This will will write an 8x8 square with the right side black and
an upper-right corner at b, a
 out ($10), a  ; a is already loaded with the Y value, and since we have not
written to the display controller in a while, no delay is needed. Tell the
display controller the Y coordinate

 ld a, b   ; Get the X coordinate from b into a
 call $7F3   ; Delay for the display controller
 out ($10), a  ; Tell the display controller the X coordinate

 ld b, Paddle  ; The paddle is as tall as the number in paddle, so we repeat the
loop 8 times
 ld a, c  ; Put either %10000000 or %00000001 into c, depending on which side
we're on
PrnLoop:
 call $7F3   ; Delay for the display controller
 out ($11), a  ; Write a byte to the display controller
 djnz PrnLoop  ; Repeat until we have written 8
 ret    ; Return to where we left off

GeradS711@aol.com wrote:

> I have decided to rewrite pong to make it more like zpong for the 85. In
> order to do this I have a couple of questions.
> First, According to 82ports.txt if you do this
> ld a,7
> call $7F3
> out (10h),a
> it will set the cursor to write bytes down.
> So if you do this
> ld a,%11111111
> call $7F3
> out (11h),a
> you will write something that looks like this:
> |
> Is that correct?
> Another question I have is
> If you write %0000000
> to the display port it will turn off all the pixels, how could you do this so
> it won't,
> so writing %10000000
> will turn a pixel on but none off
> Thanx
> Gerad




Follow-Ups: References: