Squeeze the analogue of Space Invaders to 1 kilobyte (original 1978 takes 8)
This game, heavily inspired by Space Invaders, was written from scratch for ATtiny2313 and sent to the recently held 1-kilobyte contest on Hackaday .
It is not easy to put such a game in 1024 bytes. But the author decided to get a fully functional game with scoring, sound and a VGA-video output with a resolution of 640x480 and a frequency of 60 Hz.
Of course, all the code is completely written in assembler, and for the generation of sound and video, it is programmed to obtain accurate time intervals.
The timer interrupt complies with the requirements for VGA horizontal synchronization, and since the frame rate is obtained by dividing the horizontal line by an integer, both types of synchronization can be placed in one interrupt processing procedure. To do this, the procedure accurately counts the cycles.
The line frequency of 31.5 kHz is taken in the same procedure as the basis for receiving sounds.
The interrupt processing procedure takes up 90% of the computer time, so all the game logic is calculated during the return beam. Several state machines control the movement of characters, determining the position of missiles, etc.
A small character generator is used to store both the font for displaying the score, as well as tiles and sprites.
Just a few hours before the end of the reception of materials, the code was ready and sent to the competition. Everything turned out to be realized in it. Generation of a standard VGA signal (although the actual resolution is much lower than 640x480 - “huge square pixels”), control from a gamepad for SNES or its clone with three Clock, Latch, Data signals, program sprites with smooth movement, rather than jumping from familiarity in familiarity, scoring, cyclical change of tiles as in the original ...
The same gamepad:
you can also make the same device and play a 1-kilobyte analogue of Space Invaders. Assemble the circuit (quartz at 20 MHz is not shown, connects to pins 4 and 5, the connector on the top right is for the programmer). The author claims that he drew this diagram on a smartphone at 4 a.m. immediately before sending it to the contest. Of course, the Parallax adapter is optional, you can just take the VGA-connector.
When using the adapter, the device looks like this:
Compile the source ( program and header file ) using AVR Studio or GCC, or just fill in the attached HEX file- it’s faster, but you can’t dig into the code. And you can see for yourself that the analogue of Space Invaders, which fits in one kilobyte, is a reality.