UPDATE 13.0109:
That tune. It's. Stuck. In. My. Head...
A new update soon. I have a couple of bugs to squash.
UPDATE 12.1231:
I split out all of the NTSC stuff into it's own module - NTSC_Interface.INC and NTSC_Interface.ASM. Hopefully this makes for easier implementation of NTSC video in your projects. I also have ODD/EVEN fields implemented and the timings are _really_ tweaked to try to meet spec. The big LCD TV is working better (VSync locks now, data is clean, but there's a weird shifting of the line data), and everything else I have thrown at it works great, including my Sony LCD goggles.
RELEASE V4.04:
PONG.ASM (V4.04):
http://pastebin.com/Wbxbg94R
Common.INC (V1.10):
http://pastebin.com/rMJcnLqt
NTSC_Interface.ASM (V1.00):
http://pastebin.com/aPi9eKRJ
NTSC_Interface.INC (V1.00):
http://pastebin.com/nXCannBS
Enjoy - and Happy New Year!
UPDATE 12.1229:
In order to get the large LCD TV working, I've had to implement odd/even fields to the video generation. So - long story short - there's a lot of CRAP information out there on what the video signal is supposed to look like. I'm surprised I've had anything working, with the BAD information that I have been working from.
Happy ending? I'm close to getting absolutely correct video implemented, and it's all thanks to this webpage:
http://www.kolumbus.fi/pami1/video/pal_ntsc.html
Which has wonderful timing diagrams like this:
Who knew there were SIX pulses in the midst of the vertical synchronization phase for NTSC video, not FIVE as some as said. And who would have thought it would make such a difference to the video quality! One must NOT mix up the timings for PAL/SECAM and NTSC, or bad things will happen.
You're welcome. Merry Christmas.
UPDATE 12.1228:
Version 4.01 of PONG is now released. It has COMPUTER mode for player 2. Just press and hold the PLAYER 1 BUTTON while powering up. A large 'C' should be in the upper right corner of the screen.
Also note - the player 1 joystick handling has been modified for the Tandy joystick (see pics below). The original code is still in the source, just commented out.
RELEASE V4.01:
PONG.ASM (V4.01):
http://pastebin.com/ViHhnMG1
Common.INC (V1.10):
http://pastebin.com/rMJcnLqt
UPDATE 12.1228:
I crammed my second PONG board into an old Tandy joystick. Well, 'crammed' isn't really true, because there's plenty of room for the board, cables and Audio/Video jacks. Now the batteries? Those may post a problem. I'm just powering it from the PICKIT3 at the moment.
Top view. Looks like a normal Tandy joystick.
The front side, with the big red button that is original to the
Tandy joystick. Cheesy.
The right side, showing the ICSP header for programming
the PIC. I use this to power the device - at least until I figure
out what I am going to do for the batteries.
An upper view where you can see the joystick,
big red button, and the A/V connectors.
A view of the inside. The bottom is on the left, the top is on
the right. In the bottom, the A/V connectors are on the lower
left. The micro board is on the upper right. The top has the
original joystick and button that came with the device.
Another view of the inside.
The top is on the left, the bottom on the right.
Close up of the micro board. 1 PIC, 6 resistors.
I need to add a capacitor.
UPDATE 12.1228:
3 items:
- This PONG post has surpassed the Dual Die Emulator post in the number of views. Thank you all very much. And thanks again to Hack-A-Day for the link from their website.
- I've built another PONG board, one that is to be battery powered and self-contained in an old Tandy joystick. And after an hour of soldering, I programmed the part and - it works! So the first one wasn't a complete fluke. This should give hope to anyone else out there who is building this project.
- I'm programming in a mode for making player 2 a computer player. When I finish, I'll post the code for anyone who is interested.
UPDATE 12.1227:
I've been working on BREAK OUT and there's lots of lines with fixed, single pixels and I was having a heck of a time getting everything lined up and the video signal timings correct. I was tweaking my signal timing routine and adding NOPs all over the place and spending a LOT of time getting things right that would just break when I added code or changed the graphics.
So I finally broke down and started experimenting with using a interrupt service routine to control the video signal, with the timings based on TIMER0. It turned out great, so this morning a did a major overhaul of PONG and turned over control of all of the video signal timing to a TIMER0 ISR.
Oh my, I should have done this in the first place.
All of the 'Timing Fudge' comments with the associated NOPs are gone. You won't find stray NOPs anywhere except for placing pixels on a line - no more peppering the code with NOPs to get the sync width or line width correct. It is _so_ clean and rock solid now, and so easy to change and maintain, that it almost has me in tears to think of how much time I have spending pushing 250ns slices around in the code.
Since it's a major change, PONG has been bumped up to
V4.00.
RELEASE V4.00:
PONG.ASM (V4.00):
http://pastebin.com/WcR2DFfx
Common.INC (V1.10):
http://pastebin.com/rMJcnLqt
UPDATE 12.1225:
I've started a new game for the PIC12F1840 - BREAK OUT. The new post is
HERE if you are interested.
UPDATE 12.1224:
Ah, damn. There's always another bug.
While filming the V3.06 demo, I noticed that the ball would sometimes hit the upper sideline and not bounce off at an angle - it would just continue to follow the sideline until hit with a paddle, and then take off following the sideline to the other paddle, ad nauseum. Yeah, it bugged me, and I fixed it in my sleep last night. I was able to come into the lab this morning, go directly to the problem in the code and fix it. Nice. Weird, but nice.
Also, the _DEBUG_ option is set to FALSE, so there's no VSYNC flag pulse being generated on GPIO2.
And some timing fixes. And I added a blank and then two white lines after the Copyright, because it looks good.
RELEASE V3.07:
PONG.ASM (V3.07):
http://pastebin.com/gUpisB8L
Common.INC (V1.10):
http://pastebin.com/rMJcnLqt
Enjoy! And Merry Christmas!!!
UPDATE 12.1223:
Here's a semi-short movie of what you will get if you build this project:
If you do build it, I hope it's worth it :) Seriously, if you do build this project, I would enjoy and appreciate feedback and pics of your build.
Older updates and the orignal post after the break.