A custom-built and custom-programmed handheld gaming device.
A game console based on an Arduino Micro. Every component and circuit board was 3D modeled, as well as the case, using SolidWorks. The wiring is hand-soldered using 30AWG wire. The structure is a 3D printed case using wood/PLA filament. The console accepts input, has levels, plays music, and saves highscores!
The code initializes the TFT screen over a hardware SPI connection that is also shared by the SD reader and selected using a chip select pin. The spotredraw() function was entirely written by me and controls a selective redrawing of the TFT screen since a full refresh is too slow. The many named update functions also selectively redraw spots on the screen such as the score, highscore, and “tar” items. Since the Arduino Micro cannot generate random numbers effectively, the random number generator is fed raw input from the two joystick axes added to the current microsecond count every time the player moves. I used ~100% of the system’s flash memory.
The Game Logic:
What is displayed onscreen is mirrored as a character array of the same size and uses different symbols for each object. The ASCII table was replaced with a custom font, included in the header as “adam.h” which I created using the “binFontsTool” Excel sheet in which a custom font can be drawn pixel by pixel. The joystick and tact switch are held in an infinite while loop to check for input, along with a seconds counter to drop in the “cracks.” The cracks and holes are the grey symbols that prevent the player from moving through. The orange icon clears all cracks (but not the holes) from the board and allows the player to once again pass through freely. Once in a while the player will get stuck in which the tact switch can be pressed up to three times per game to clear the surrounding array positions [logic found in cleancircle();] The player is also checked every loop to see if it has become trapped [checktrapped();] Once the player is out of “tar” and checktrapped() returns true, the game is stopped and the screen inverts the colors and writes the score if it’s higher to the EEPROM of the Arduino as a long datatype by EEPROMWriteLong(); since each address of the EEPROM is only one byte, in order to store the highscore even while the console is turned off.
This tool is made within Excel and allows for loading, editing, and saving custom pixel-based fonts specifically for the Adafruit GFX font library on the Arduino. This tool auto-compresses the data into a header file which can be referenced by the main code for drawing glyphs to the screen. I used the unused glyphs for the sprites of the game.
Testing out drawing the game “minit” to the screen from a bitmap file (.bmp) via the SD reader. The SD reader overhead too up too much memory and had to be removed from the code. It remains in the case however.
The game gets quicker every 32 steps, starting with a 140bpm song and increasing up to a 260bpm song, all of which were written be me using a tool called “BeepBox.” The music is stored on a MicroSD card and played via a serial connection between the Arduino’s hardware serial pin and the RX pin of the SerialMP3 board.