Shop OBEX P1 Docs P2 Docs Learn Events
pong game for C3 — Parallax Forums

pong game for C3

ersmithersmith Posts: 6,099
edited 2011-12-10 18:22 in Propeller 1
In honor of the new PropGCC alpha release, here's a simple version of "pong". It's rather trivial -- you just have to hook buttons up to pins 4, 5, 6, 7 (selectable in the code). Pin 7 controls left paddle up, pin 6 is left paddle down, similarly pins 5 and 4 control the right paddle. Output is to a VGA at 640x480 (the bitmap is 160x120 and scaled up). The source code is currently set up for the C3 board, but it should be easy to adapt to other boards.

The game itself isn't much, but it only takes up one COG (all game logic and video output code fit in the same COG's internal memory). I do admit to having "cheated" a bit by putting 64 bytes of character data (for the score digits) in hub memory, and of course the frame buffer is in hub memory too.

Oh, and it's all written in C. There's a Makefile, but you really don't need it. To compile just do:
propeller-elf-gcc -mcog -Os -o pong.elf pong.c
with the most recent PropGCC alpha release.

There's now an alternative to PASM for writing COG drivers.

Eric

Comments

  • mindrobotsmindrobots Posts: 6,506
    edited 2011-12-09 20:31
    Seriously? If I understand, a VGA pong game in one COG and less than 2k bytes (except for the 64 byte cheat)!!
    Awesome!

    Looks like I'm having Pong with my coffee tomorrow morning!
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-12-09 21:24
    Wow.. two game posts in 1 week! (and one in C no less!)

    I know what I'll be playing with this weekend.

    OBC
  • KyeKye Posts: 2,200
    edited 2011-12-10 07:10
    That's really impressive.
  • ersmithersmith Posts: 6,099
    edited 2011-12-10 12:13
    Kye wrote: »
    That's really impressive.

    Thanks, Kye, but I owe much of the game to your PIX demo video driver. It was very nicely written, and easy to port from PASM to C. Once I had C code it was pretty straightforward to add in more features (like pong :-)).

    Eric
  • jazzedjazzed Posts: 11,803
    edited 2011-12-10 15:05
    It sure is amazing what GCC can usefully pack into a single COG.

    Since VGA was declared impossible and was achieved within just
    a few days, maybe we should declare some other things impossible.

    TV anyone?
  • KyeKye Posts: 2,200
    edited 2011-12-10 18:22
    That's easier than VGA.
Sign In or Register to comment.