a (try) version of pong and solved video driver issue
Reinhard
Posts: 489
I have never read an implementation of Pong and have wanted to work on it for a long time.
In principle, it works the way I thought it would. At times strange effects occur, but on the whole it is stable.
After the weekend, I can continue to take care of it.
At this version of pong the propeller plays against itself. The paddle position is calculated to hit the ball.
An expansion to several cogs is planned.
nice weekend
Reinhard
In principle, it works the way I thought it would. At times strange effects occur, but on the whole it is stable.
After the weekend, I can continue to take care of it.
At this version of pong the propeller plays against itself. The paddle position is calculated to hit the ball.
An expansion to several cogs is planned.
nice weekend
Reinhard
zip
272K
Comments
but I have not a long time observed.
I've modified your pong code to speed it up and it runs smoother now. Not so much flicker.
You can use the fillCircle routine I included to draw circles of any colour and size, as well as
syncing up to the blanking period to avoid tearing etc. Clearing the entire screen
is slow, so you can erase just the ball and paddle. Take a look at what I changed.
By the way, no need to distribute the entire video folder, just p2videodrv.spin2 is enough.
Cheers,
Roger.
Thanks for the many tips. I am currently out of my home and will only have my hardware again on Monday. I can't wait to try your version!
Your improvements are great. I now have 2 players. Is it an advantage if I split that over 2 cogs (?).
A sound output during ping would also be interesting.
cheers
Reinhard
You might like to figure out a way to slide your paddles up and down on each side more smoothly too (interpolate) when they figure out the final position instead of jumping, although the jumping effect still looks okay.
This sort of makes a good screensaver.
Hello,
I tried to complle this sourcecode, without changes in the c-file(s), but with the newest version of flexspin.
It is unsuccessful, I get Error in the spin part.
reinhard@reinhard-TUXEDO:~/Schreibtisch/Propeller2/testbench2/pong$ /home/reinhard/Schreibtisch/Propeller2/spin2cpp-5.9.24/build/flexspin -2b -Wall pingpong.c graphictools.c
Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2023 Total Spectrum Software Inc. and contributors
Version 5.9.24-- Compiled on: Jan 13 2023
pingpong.c
|-p2videodrv.spin2
home/reinhard/Schreibtisch/Propeller2/testbench2/pong/video/p2videodrv.spin2:363: error: assignment to constant `GRAPHICS_MODE'
With the old version of fastspin I can compile:
reinhard@reinhard-TUXEDO:~/Schreibtisch/Propeller2/testbench2/pong$ /home/reinhard/Schreibtisch/Propeller2/spin2cpp-4.2.6/build/fastspin -2b -Wall pingpong.c graphictools.c
Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2020 Total Spectrum Software Inc.
Version 4.2.6 Compiled on: Jul 30 2020
pingpong.c
|-p2videodrv.spin2
graphictools.c
|-p2videodrv.spin2
memset.c
pingpong.p2asm
Done.
Program size is 347248 bytes
and download:
reinhard@reinhard-TUXEDO:~/Schreibtisch/Propeller2/testbench2/pong$ /home/reinhard/Schreibtisch/Propeller2/p2gcc-master/bin/loadp2 -b 230400 -p /dev/ttyUSB0 -t pingpong.binary
Is this a issue from flexspin or a bug in the spin - graphic driver and the new flexspin in not so tolerant like the old one?
Regards Reinhard
In all the versions of p2videodrv.spin2 that I've seen, GRAPHICS_MODE is a constant (defined in the CON section) and so if the code in line 363 really is modifying it that's an error and flexspin should never have accepted it. The p2videodrv.spin2 that comes with FlexProp (in the Multi-Language/video folder; admittedly it's an old version!) does not have any such assignment. Could you share your code?
Thank you for the fast answer.
Here is the zip file with all sources.
It is the same as I posted above.
The p2videodrv.spin2 is in the subfolder video.
Line 363 of your p2videodrv.spin2 currently reads:
it should read
The
~
operator modifies its argument. In fact~
isn't even legal in Spin2, but flexspin accepts it as a hold-over from Spin1. I think older versions of flexspin incorrectly did not modifyx
in~x
, which may be why your code worked with the old flexspin.I remember the whole thing about incorrect
~
operator behaviours ;P@ersmith
Cool, this is the solution. My skill in SPIN is not so great. I didn't find it out by myself.
Thank you
Reinhard
Must have been an old version as ersmith mentioned. Versions of my P2 video driver since v0.92 had that issue fixed. Versions are posted here in the first post...
https://forums.parallax.com/discussion/170676/p2-dvi-vga-driver