This shows you the differences between two versions of the page.
|
pm:prj2026:bianca.popa1106:cristian.stefan1712 [2026/05/18 16:33] cristian.stefan1712 [Implemented Sources and Functions] |
pm:prj2026:bianca.popa1106:cristian.stefan1712 [2026/05/18 17:00] (current) cristian.stefan1712 |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Project Name: Game Console (Game Boy Replica) ====== | + | ====== Game Console (Game Boy Replica) ====== |
| ===== Introduction ===== | ===== Introduction ===== | ||
| Line 32: | Line 32: | ||
| {{:pm:prj2026:bianca.popa1106:schema_bloc_stefan_cristian.png?600|}} | {{:pm:prj2026:bianca.popa1106:schema_bloc_stefan_cristian.png?600|}} | ||
| - | That is a perfect correction! The Arduino IDE is the absolute classic tool for this, and it actually makes managing libraries a lot easier for a project like this. | + | ===== Software Design (Firmware) ===== |
| - | Here is the updated documentation with the Development Environment section completely rewritten to reflect the Arduino IDE, how it handles files (like .ino), and how it manages dependencies. | + | ==== Development Environment ==== |
| - | + | ||
| - | You can copy and paste this directly into your documentation! | + | |
| - | + | ||
| - | ====== Software Design (Firmware) ====== | + | |
| - | + | ||
| - | ===== Development Environment ===== | + | |
| The firmware for this console is developed using the Arduino IDE. This environment was chosen for its high accessibility, integrated Library Manager, and straightforward compilation process for AVR microcontrollers. | The firmware for this console is developed using the Arduino IDE. This environment was chosen for its high accessibility, integrated Library Manager, and straightforward compilation process for AVR microcontrollers. | ||
| The project is structured around a primary ''.ino'' sketch file which contains the core state machine, the ''setup()'', and the ''loop()'' functions. By leveraging the Arduino IDE's automatic prototype generation and tab system, the codebase is kept organized without the need for complex makefiles or manual dependency linking, allowing for rapid iteration of game logic and hardware testing. | The project is structured around a primary ''.ino'' sketch file which contains the core state machine, the ''setup()'', and the ''loop()'' functions. By leveraging the Arduino IDE's automatic prototype generation and tab system, the codebase is kept organized without the need for complex makefiles or manual dependency linking, allowing for rapid iteration of game logic and hardware testing. | ||
| - | ===== 3rd-Party Libraries and Sources ===== | + | ==== 3rd-Party Libraries and Sources ==== |
| To avoid reinventing the wheel for low-level hardware protocols while maintaining performance, the following libraries (installed via the Arduino Library Manager) are utilized: | To avoid reinventing the wheel for low-level hardware protocols while maintaining performance, the following libraries (installed via the Arduino Library Manager) are utilized: | ||
| Line 54: | Line 48: | ||
| Adafruit_GFX.h & Adafruit_PCD8544.h: These libraries handle the low-level communication with the Nokia 5110 display. They provide primitive drawing functions (pixels, lines, rectangles) and text rendering, which saves significant development time on the graphical engine. | Adafruit_GFX.h & Adafruit_PCD8544.h: These libraries handle the low-level communication with the Nokia 5110 display. They provide primitive drawing functions (pixels, lines, rectangles) and text rendering, which saves significant development time on the graphical engine. | ||
| - | ===== Algorithms and Data Structures ===== | + | ==== Algorithms and Data Structures ==== |
| === 1. The Game Loop & State Machine === | === 1. The Game Loop & State Machine === | ||
| Line 79: | Line 73: | ||
| Matrix Overlay Checking: Used in Tetris to mathematically project the 4x4 array of a falling block onto the 10x20 boolean game board array. If any active bits in the piece array overlap with an active bit on the board array or cross the boundary limits, a collision is flagged. | Matrix Overlay Checking: Used in Tetris to mathematically project the 4x4 array of a falling block onto the 10x20 boolean game board array. If any active bits in the piece array overlap with an active bit on the board array or cross the boundary limits, a collision is flagged. | ||
| - | ===== Implemented Sources and Functions ===== | + | ==== Implemented Sources and Functions ==== |
| Below are the core functions that drive the hardware and the game engine: | Below are the core functions that drive the hardware and the game engine: | ||
| Line 87: | Line 81: | ||
| | ''void loop()'' | Contains the ''if/else'' logic that routes CPU execution to ''runMenu()'', ''runSnake()'', or ''runTetris()'' based on the active state. | | | ''void loop()'' | Contains the ''if/else'' logic that routes CPU execution to ''runMenu()'', ''runSnake()'', or ''runTetris()'' based on the active state. | | ||
| | ''void readInput()'' | Reads the analog values from the XY joystick via ''analogRead()'' and the digital states of the push buttons. Uses ''millis()'' to throttle input speed. | | | ''void readInput()'' | Reads the analog values from the XY joystick via ''analogRead()'' and the digital states of the push buttons. Uses ''millis()'' to throttle input speed. | | ||
| - | | ''void updateSnake()'' | + | | ''void runSnake()'' ''void runTetris()'' | Contains the pure math and physics of the active game. Shifts arrays (Snake tail), rotates matrices (Tetris pieces), executes collision checks, and updates the score. | |
| - | ''void runSnake()'' | + | |
| - | ''void runTetris()'' | Contains the pure math and physics of the active game. Shifts arrays (Snake tail), rotates matrices (Tetris pieces), executes collision checks, and updates the score. | | + | |
| | ''void drawGame()'' | Clears the 504-byte framebuffer array, calculates the new pixel positions for all sprites (using ''setPixel''), and sets the respective bits in the internal array. | | | ''void drawGame()'' | Clears the 504-byte framebuffer array, calculates the new pixel positions for all sprites (using ''setPixel''), and sets the respective bits in the internal array. | | ||
| | ''void renderScreen()'' | Selects the LCD via the CS pin and pushes the complete 504-byte framebuffer array over the SPI bus to physically update the glass. | | | ''void renderScreen()'' | Selects the LCD via the CS pin and pushes the complete 504-byte framebuffer array over the SPI bus to physically update the glass. | | ||
| | ''void tone()'' | Synthesizes retro audio using the Arduino's built-in hardware timer commands to generate a square wave PWM signal on the buzzer pin at specific frequencies. | | | ''void tone()'' | Synthesizes retro audio using the Arduino's built-in hardware timer commands to generate a square wave PWM signal on the buzzer pin at specific frequencies. | | ||
| | ''void checkTetrisLines()'' | Scans the 10x20 Tetris array for completed rows, shifts the above rows down in memory to simulate gravity, and increments the score multiplier. | | | ''void checkTetrisLines()'' | Scans the 10x20 Tetris array for completed rows, shifts the above rows down in memory to simulate gravity, and increments the score multiplier. | | ||