Re: A82: Zpong


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

Re: A82: Zpong



Woops! I forgot to include a couple of things:

Paddle should be defined in the top of your program as the length of the program. I
made anything referring to the length of the paddle use paddle, so if I wanted a
variable paddle, or a different size one, it'd be easy.

Paddle = 8

Also, I did not find it necessary to do a

ld a,7
call $7F3
out (10h),a

in the beginning. A note about optimizing: You can take out some call $7F3s if you
know it has been a while since you wrote to ports $10/11.

Also, to answer your original questions:

> So if you do this
> ld a,%11111111
> call $7F3
> out (11h),a
> you will write something that looks like this:
> |
> Is that correct?

No. It'll move the cursor down after each byte. There is no "eastern language" mode.

> 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
No. It will turn 1 on, and 7 off (If there is nothing there, or you refresh often,
its not a problem).

Matt Maurano wrote:

> 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


References: