{"id":87,"date":"2011-05-27T00:30:09","date_gmt":"2011-05-27T05:30:09","guid":{"rendered":"http:\/\/trillworks.com\/nick\/?p=87"},"modified":"2012-04-10T23:47:18","modified_gmt":"2012-04-11T04:47:18","slug":"pong-on-the-mc9s12c32","status":"publish","type":"post","link":"https:\/\/trillworks.com\/nick\/2011\/05\/27\/pong-on-the-mc9s12c32\/","title":{"rendered":"Pong on the mc9s12c32"},"content":{"rendered":"
At the conclusion of UT’s embedded systems lab,\u00a0EE445L<\/a>,\u00a0all student teams produce a final project of their own choosing. My partner (Tim) and I built a game system for playing Pong.<\/p>\n I designed the circuit schematic and wrote most of the software. Tim designed the PCB and assembled most of the hardware. Everything that could go wrong did, but we managed to build a fun little game.<\/p>\n The interface is extremely intuitive. The potentiometers on either side of the screen control the paddles for each player. The code for the C32 is almost entirely C and was developed in Freescale’s CodeWarrior IDE.<\/p>\n The screen is an AGM1264 128×64 monochrome LCD. Professor Jonathan Valvano provides a useful driver<\/a> for the c32 on his website. While the driver supports writing whole bitmaps, the memory layout of the LCD makes it very tricky to draw 2D shapes at arbitrary coordinates. I ended up using a 1-pixel ball because a 2×2 ball could require writes to 4 memory locations, a can of worms that I did not want to open.<\/p>\n But, if you’re interested in improving the game, you can draw to arbitrary pixels using the modulus arithmetic in drawBall(). It could easily be a jumping off point for a 2D graphics library supporting more interesting shapes. A word of warning: you will get a\u00a0noticeable\u00a0flicker when writing bitmaps quickly (we did 20 fps). Edit: I had a conversation with another student who attributed the flicker to a call to LCD_Clear(0) in Valvano’s LCD_DrawImage routine. It’s there in LCD.c on line 383. I no longer have the hardware, but that would have been an easy fix to make.<\/p>\n Things that went wrong<\/p>\n <\/p>\n Check out the hastily written source<\/a>.<\/p>\n This project wouldn’t have been possible without the technical guidance of Darryl Goodnight, Paul Landers, and Justin Capogna.<\/p>\n<\/a>
The screen really isn’t built to draw every location continuously<\/del>.<\/p>\n\n
<\/a><\/p>\n
<\/a><\/p>\n