Shop OBEX P1 Docs P2 Docs Learn Events
PROP2 Invaders - 1 Cog (Now with sound effects!) — Parallax Forums

PROP2 Invaders - 1 Cog (Now with sound effects!)

ozpropdevozpropdev Posts: 2,792
edited 2014-03-26 02:06 in Propeller 2
Hi Guys

Here is my demo program for the Propeller 2.
It is a implementation of the old Space Invaders game.
It was developed on a DE0-Nano FPGA board so it uses only 1 Cog!
It uses the multitasking feature to generate video, game byte-code interpreter and a full duplex(115200 baud) diagnostic terminal.
The terminal displays live game data as well as supporting some simple diagnostic functions.
Video is VGA 800x600
Sound effects are generated using a 4 bit resistor ladder. (P5-P8) P5 is LSB
Diagnostic monitor now runs @ 1M baud
Enjoy!

Cheers :)
Brian


Update: 31st October 2013 (Obsolete 27th Nov 2013 - New FPGA release)
Version 1.61 - Single game variants for DE0 and DE2
Version 1.62 for DE2 - 4 game variant



Update: 20th Jan 2014

See latest post #88
«134

Comments

  • ctwardellctwardell Posts: 1,716
    edited 2013-08-24 08:07
    Sweet! I need to try this out. What does it use as a game controller?

    C.W.
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-08-24 08:18
    Would it be possible to do higher resolution by adding more cogs?
  • ElectrodudeElectrodude Posts: 1,651
    edited 2013-08-24 08:32
    ctwardell wrote: »
    Sweet! I need to try this out. What does it use as a game controller?

    C.W.
    CON
    'IO definitions
    
        rx = 91
        tx = 90
    
        left_button = 26
        right_button = 27
        fire_button = 28
    
    rx and tx are for debug.

    That VGA driver looks suspiciously short... and all in 1 cog... I want a prop 2...
  • Bill HenningBill Henning Posts: 6,445
    edited 2013-08-24 08:39
    Looks good! I'll try it on my DE0-Nano and DE2-115 sometime this weekend.

    Very nice use of the hardware threads.
  • cgraceycgracey Posts: 14,134
    edited 2013-08-24 11:13
    This is great! I will try it out today. This makes good use of multitasking and the new bit instructions for flags.

    Did you max out the cog RAM? What's the total footprint in hub RAM? No need to respond. I will see these things when I run it.
  • GadgetmanGadgetman Posts: 2,436
    edited 2013-08-24 11:38
    If that wasn't so awesome, I'd be really jealous of you...
    (Don't have a Nano... *Sigh* )

    Do you have sound, also?
  • BaggersBaggers Posts: 3,019
    edited 2013-08-24 14:11
    That's awesome ozpropdev :) can't wait to finish my current work project ( in the next few days ) and get some good prop2 time in :) and also give this a test!
  • ozpropdevozpropdev Posts: 2,792
    edited 2013-08-24 17:20
    Hi Guys
    Thanks for all the feedback.
    I had planned in having sound as well but I was overloading Hub access already.
    The idea was to stream data to 1 of the Dac's.
    As I was experiencing a bit of pipeline stall I had to scrap sound.
    The question on the game controller, I am using the 3 buttons on the add-on board at the moment.
    I'm working on some additional notes on how it all works today. I'll post it ASAP.
    Chip,I'm going over the final resource usage today so all will be revealed soon.
    I suspect some of my pipeline issues will disappear on a real chip at full speed.
    I could go to a higher VGA resolution without using any more cogs.
    As I only have 1 cog in my emulator and 32k hub ram not 128k, I held back to allow for a larger program.
    I believe the real chip could do it easily on 1 Cog as well !

    Looks like I might have to do a version 2.0 later, but this will have to wait a while because I'm still
    seeing ALIENS in my sleep!

    Cheers
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-08-24 17:48
    Congratulations ozpropdev. And in 1 cog too.
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-08-24 18:04
    I feel a bunch of 1 cog challenges coming with the Prop 2. There be power in them COGs!!!
  • localrogerlocalroger Posts: 3,451
    edited 2013-08-25 15:16
    Just echoing the wow ... and in 1 cog!
  • Ym2413aYm2413a Posts: 630
    edited 2013-08-25 15:45
    Wonderful work! : D
    Very Impressive.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2013-08-25 16:12
    Fantastic work - look forward to the next installment!
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2013-08-25 18:18
    Looks really good Brian, what can you do with a DE2 board then?
  • ozpropdevozpropdev Posts: 2,792
    edited 2013-08-25 19:14
    Hi everyone
    I added an updated version today with some notes.
    Peter, I had a few sleepless nights dealing with 1 Cog!
    Having 5 cogs in a DE2 would be great... but 8 in a real device.... AWESOME!
    Cheers
    Brian
  • rjo__rjo__ Posts: 2,114
    edited 2013-08-25 20:26
    Brian,

    Seriously, write a book. Not a chapter in someone else's book... your own. Make the first couple of chapters an autobiography. Add in all the facts that you think are too basic to consider:)

    What you have needs to be shared.

    If you got into it, it would take you six weeks and be a best seller... at least on this particular forum:)

    You might even get Chip to proof read it... what a hoot!

    If you need a ghost writer, I'm guessing you could get some eager help from the writers at Parallax.

    Congratulations... quite a remarkable piece of work... not that I understand it (of course:)


    Rich
  • ozpropdevozpropdev Posts: 2,792
    edited 2013-08-25 23:21
    Interesting idea Rich.

    I guess my autobiography would read the same as most of the guys on this forum.
    Started in the late 70's, spent long hours hacking code while consuming huge quantities of caffeine and soda.
    Load music bouncing of the walls and all flat surfaces covered in paper,books,electronics and junk food!
    Good times....

    In my case the only 2 differences would be geography (Down Under) and that I have been legally blind for 25 years.
    The later hasn't stopped me from hacking code or drinking coffee,load music etc.
    It does make debugging code a little more interesting.
    At the end of the day a "bug" is the same whoever created it!

    As for a book, I had never really thought about that before. If there was enough interest shown I would be open to the idea.
    After all it's just more typing!

    Thanks for the encouragement.
    You've got me thinking

    Cheers
    Brian
  • rjo__rjo__ Posts: 2,114
    edited 2013-08-26 04:39
    Brian,

    I am retired now, but when I first began practicing ophthalmology, one of my legal duties was to inform patients that they could no longer drive, due to their poor vision.
    The first time I did this, the nice old man that I "informed" went home and shot himself. So, I didn't do that anymore.

    It would have been much better to tell the nice man to go home and read your book, while he still could.

    Rich
  • ozpropdevozpropdev Posts: 2,792
    edited 2013-08-26 06:12
    Has anyone run the code on a DE2 board yet?
  • TubularTubular Posts: 4,692
    edited 2013-08-26 16:07
    Running this is high on my priority list when I get back onto the Altera hardware (both DE0 and DE2)

    Very nice work by the look of it

    cheers
    Lachlan
  • pik33pik33 Posts: 2,366
    edited 2013-08-26 21:39
    I have access to DE2-115 board... i am using it to scientific work (digital filters etc) at my university. I didn't try Prop2 core yet on this board - is it possible to program this without a Propplug whih I don't have? I have a Prop1 Quickstart - is it possible to use it as some kind of Propplug?
  • ozpropdevozpropdev Posts: 2,792
    edited 2013-08-26 22:12
    pik33 wrote: »
    .... I didn't try Prop2 core yet on this board - is it possible to program this without a Propplug whih I don't have? I have a Prop1 Quickstart - is it possible to use it as some kind of Propplug?

    You would have to tap into the board to get TX,RX and RESN and GND signals. You would most likely have to cut the RESn signal to the Prop1 as well, to stop it responding to downloads.
    To generate the video signals you will have to duplicate the DAC circuitry of the Add-on boards.
    Refer to the DE0/DE2 post(sticky) at the top of the forum for more info.
    Hope this helps
    Cheers
  • potatoheadpotatohead Posts: 10,261
    edited 2013-08-27 16:28
    I'm going to run this tonight on a DE2 with add-on. Great work from what I can see so far. I really appreciate you contributing this because there is a lot of great learning to be had.
  • ozpropdevozpropdev Posts: 2,792
    edited 2013-08-27 16:37
    potatohead wrote: »
    ... I really appreciate you contributing this because there is a lot of great learning to be had.

    Thanks Potatohead.

    Hopefully Chip can run it on a real Prop2 soon.
    He mentioned today that they are due back from packaging soon.

    All fingers and toes crossed.

    Cheers
    Brian
  • ozpropdevozpropdev Posts: 2,792
    edited 2013-08-27 22:50
    Hi Guys
    I just updated to version 1.42.
    Fixed a few bugs and added a demo mode for the DE2 people without buttons on their add-on boards.

    Cheers
    Brian
  • ozpropdevozpropdev Posts: 2,792
    edited 2013-08-28 22:54
    Hi Guys

    I just tried the program on another screen than the 3 I tested on. (2 x LCD, 1 x CRT)
    The pixel noise is a lot worse on this LCD screen.
    How does it look on your screens?

    If you remove the following bytes (there's 7 of them) from the game program at the end of the code it
    will improve quality.
    	byte	g_comms
    

    This disables Serial Tx but Rx still functions.

    Cheers
    Brian
  • potatoheadpotatohead Posts: 10,261
    edited 2013-08-31 22:15
    Well, "tonight" ended up being a few days, lol. Hey, this runs great. I saw the org comment needed for the DE2, no worries there. The game did not pick up on the buttons. Maybe those are on different pins on the DE2. I've not used them much, but a program Jim (Baggers) did, does use them.

    I'm off to figure out the buttons and score you a picture of the display on my CRT VGA, which displayed it perfectly.

    :)

    You did a great job capturing the flavor of the original Invaders. Very nicely done. I particularly like the saucer appearing on screen even as the player is done. Nice touch.
  • potatoheadpotatohead Posts: 10,261
    edited 2013-08-31 22:29
    For DE2:
    	left_button = 31
    	right_button = 30
    	fire_button = 29
    

    :)
  • potatoheadpotatohead Posts: 10,261
    edited 2013-08-31 23:15
    Here are a couple of quick and arguably kind of crappy pictures:

    The only real artifact I see is the ship isn't always completely drawn each frame while in motion. Same for the saucer. There isn't any significant pixel noise on my CRT. If there is on other displays, it's highly likely to be timing related, where pixels are falling just inside of our outside of a quantized pixel boundary. That happens a lot on LCD displays. Rock solid on this one.
    1024 x 577 - 59K
    1024 x 577 - 42K
  • ozpropdevozpropdev Posts: 2,792
    edited 2013-09-01 05:19
    potatohead wrote: »
    The only real artifact I see is the ship isn't always completely drawn each frame while in motion. Same for the saucer.

    I was hoping no one would pick up on that before I fixed that!
    Oh well, I guess I have to fix it now.
    Glad to hear it runs on a DE2 board.
    I had mot heard from anyone to verify that.
    Good to hear it works Ok on your screen(s) too.
    Thanks for the I/O assignments as well.

    Cheers
    Brian
Sign In or Register to comment.