A video game is an electronic game that involves human interaction with a user interface to generate visual feedback on a video monitor. Electronic video games first appeared in the 1950s. In those days, video games were mostly hardware-based, requiring the use of complex logics to generate graphics on the screen (usually a cathode ray tube device). They employed keypads or joysticks as input devices. Since then we have seen many improvements in video games due to rapid developments in electronics and computer industries. Currently, video games have high-definition graphics, gesture recognition inputs and many other features.
Presented here is Space Invaders video game designed using ATmega16 microcontroller. Space Invaders is an arcade video game designed by Tomohiro Nishikado, released and sold in Japan in 1978. It was one of the forerunners of modern video gaming and helped expand the video game industry from a novelty to a global industry. This game used an Intel 8080 central processing unit as the main controller.
In addition to Atmel’s ATmega16 microcontroller, this hand video game uses components like a 128×64 graphic LCD (GLCD) based on KS0108 controller and a keypad. The screenshot of the author’s prototype is shown in Fig. 1.
Circuit and working
Effective coding skills, understanding of the logic of the game and matching capability of the microcontroller used are the prerequisites for making a video game.
The block diagram of Space Invaders video game is shown in Fig. 2. The circuit is shown in Fig. 3. The circuit is powered by a 9V/12V adaptor. This voltage supply is fed to a 7805 regulator (IC2), which outputs regulated 5V required for the microcontroller and GLCD. Glowing of LED1 indicates the presence of power in the circuit.
The circuit employs the GLCD as a visual unit for displaying the graphics on the screen. The code has been written based on the logic of generating or activating pixels on the screen. The 128×64 LCD is divided equally into two halves. Each half is controlled by KS0108 controller. That is, the GLCD is divided into 8 pages (8 rows in each page) and 64 columns, thus making two 64×64 parts. It uses parallel communication with the microcontroller.
The GLCD has eight pins (D0 through D7) for data inputs, chip-select pins (CS1 and CS2) for controlling the two halves of KS0108, and register-select (RS), read/write (R/W), enable (EN) and reset pins for GLCD command mode operation. Data pins D0 through D7 of the GLCD are connected to port pins PB0 through PB7 of the microcontroller (IC1), respectively. Control pins RS, R/W, EN, CS1 and CS2 are connected to port pins PD0 through PD4, respectively. Preset VR1 is connected to pin 3 for contrast control on the LCD. Switch S5 is used to enable the backlight of the LCD. An 82-ohm resistor controls the current through the backlight LED. Switches S2, S3 and S4 are used as control input keys. These three switches are connected to pins PA0 through PA2 of the microcontroller.
Switch S1 is a reset switch used to restart the game, especially when there is abnormal display on the LCD. Switch S2 is for left movement control, S3 for shooting and S4 for right movement control.