Related lists

This project is submitted for

Description

A game heavily inspired by Space Invaders implemented in an Attiny 2313 for the 1024 byte challenge.

Details

Many shortcuts will be taken to fit this into the allowed 1024 bytes. I do however expect to create a fully functional, playable game in the end with scoring, sound and color VGA output in 640x480 60Hz mode.

The project will be coded in assembly, with the VGA and sound output being bit banged with precise timing control.

A timer interrupt will match the VGA Hsync requirements, and since the Vsync signals are multiples of Hsyncs they will be handled in the same ISR. Careful counting of cycles inside the ISR will be used to send the VGA active data.

The VGA line frequency of 31,5 kHz will be used for generating sound, also inside the ISR.

With most of the action happening in the ISR, approximately 90% of the CPU cycles will be spent here. The game logic and everything else will be executed during the Vertical retrace period, at 60Hz. With the Interrupt routine dictating most of the CPU action, several state machines will be implemented to handle the game logic like movement of the aliens, updating the position of the missiles and overall game state housekeeping.

A limited character set defined in Program memory will act as both a font (e.g. for displaying the score) as well as some simple "sprites" for the aliens, player and bunkers.

Project Logs

Just a quick update now that the dust has settled after the judges results are out. I´m still working on this even if the hope of a nifty 3D Printer or any other price is now officially crushed. No hard feelings, there was some serious competition, and I´m sure the judges had a hard time comparing apples to oranges and still arriving at the final decision. I loved the competition, and send my thanks to HaD for putting this on, and regards to all fellow competitors.

In the coming weeks I will bring back the shoe-horn and polish to get the last functionality included as space is made available by furter refining the code. In hindsight I also need to spend some more time updating the documentation both for quantity and quality.

Starting to count the hours now, rather than the days. Got a few more pieces of the puzzle in place, and with a little luck I might actually see this project finished in time. Got to hook up and test the game controller logic tomorrow, then tweak the alien move pattern some more and finally test the missile firing and collision detection. If all goes well I might even be able to put back in the bunker damage / shielding function that I took out for size reasons. Compiled code and data is currently sitting at 824 bytes., which on the Attiny 2313 and its 16 bit opcodes actually is less than 400 instructions + some data.

Currently I'm rewriting the sound routine to use the 8 bit timer in CTC mode rather than the VGA interrupt routine I used initially.

As the deadline is fast approaching I seem to run from problem to problem on this project. Having made a brave leap from AVR studio to the GNU toolchain on OSX (because of computer problems that I already try to forget), I have been on a constant and steep learning curve this last week.

Things are finally starting to behave they way that was intended, but documentation and examples on these tools are scarce, so I have been practising a lot of trial and error along the way, and probably hit the bigger part of the "gotchas" that are out there. Just to show that this project is still alive I decided to post a screen-shot.

The VGA routine is up and running, as is the initialisation and house-keeping logic. I still need to add the the other VGA colours (solder the Red and Green signals to the VGA connector) and include the rest of the game logic. I ended up stripping it all down to individual components to make it easier to troubleshoot when things got really strange the other night.

Code and data is currently at 618 bytes, but some of that goes away when I´m done debugging. If all continues according to plan, I should be wrapping up this project with 5 minutes to spare before the deadline on Thursday.

I started putting together the hardware for this project. As I will be on the road for most of December, I do not expect to create anything more fancy than the prototype circuit I have already built. After all I see this more as a software competition than a Hardware one. The prototying board I'm using is a "777" board from futurlec.

The circuit is centred around the Attiny 2313, with USB connector for Power, the ISP connector at the top, and a connector for the VGA / Kbd breakout module on the right side.

The VGA breakout board is from Parallax. It also contains PS-2 connector for keyboard and mouse, but I will not use them for this project.

The controller is a cheap one I got from eBay. I need to break it open and connect to the switches as I suspect that there is some kind of uController inside this one.

From the background in these pictures, you can see that christmas has already come to my house.

Update: After doing some research on the controller I found that it actually contains a 16 bit parallell load, serial out shift register, no code / firmware. The buttons are just making contact directly on the PCB surface, so it would not be straightforward to wire each switch to a digital input. I now plan on using the serial signal as input to the game rather than discrete switches, maybe using the USI peripheral in the attiny (like a SPI bus). If the code required for this is too much to fit, I will have to change plans to use discrete switches (left, right and fire) instead of the hand controller.

Discussions

Become a member

this sounds like a great project, I remember when I bought my first computer which was a Acorn Atom which came with all the parts in one plastic bag even the keyboard had to be built with each key having 4 separate parts which you had to solder yourself one of the first things I did was space invaders which I tried in basic to start with but soon moved to assembler it took several nights programming and cursing the cassette tape player which was how you had to store programs in the end I managed it all except for different colours which at the time I was very proud of good luck with this project.

I started off with a Sinclair ZX Spectrum, same deal with BASIC built in, and assembler for speed when needed. Casette tapes for storage and TV for display. I still have it stored in a box with some of the old favourite games. Nowadays a PC emulator is faster and more convenient for playing those old games.

Thanks. I was going to replace the "original" space invaders screenshot with my own, but as it was with most games back in the day, the picture on the box was always better than the graphics in the actual game :-)

Not much updates. My trusted MS based laptop died over X-mas, and I´m transferring the project to my Mac. I know this is last minute, but I had no access to an alternative computer. As for the prices, it might be more fair if the top ranked projects got to pick in order from the prices. Not to sound ungrateful, but it might not just be down to the actual sales price of the donated price, but the actual value that any lucky winner find in it. I hope to have the main VGA lSR up and running tomorrow, and will post a video. I have most of the code in place, but have not been able to test or simulate, so that will take the time between now and the deadline. I'm currently 200+ bytes over the 1024 limit, so might have to sacrifice some part of the game to make it fit, most likely the "bunkers" and how they take damage and shield the player......

I also had a random computer issue: The power supply in the old computer I use to flash my AVRs died. I still use the parallel port. I got it up and running again, but I did loose some time figuring out what the problem was. I'm under the limit, but there's no user interface yet: the bug segments just bump into mushrooms and work their way down. If I end up over limit, I'll just make it a screensaver.

Good question. VGA is actually achievable at 20MHz Attiny clock. Since I do not have enough memory for the entire 640x480 resolution (to display anything useful), each pixel will actually be "bigger". As long as the sync signals are fairly accurate (done with interrupt) the data transmitted for the visible line is quite forgiving. My actual resolution will be about 85 by 85, but monitor will sync and display this as 640x480 @ 60 Hz.