Welcome to the Doodle Jump clone built entirely in C for the Altera DE1-SoC board!
Ever wanted to play a casual platformer on a piece of serious FPGA hardware (or a simulator of one)? Now's your chance! This project uses direct memory-mapped I/O to draw graphics, read switches, and update 7-segment displays.
Your goal is simple: Keep jumping up and don't fall! The platforms will scroll downwards, and you need to navigate your character from platform to platform.
The game uses the SW (Sliders) on the DE1-SoC board for input. Since it's edge-triggered, you flip the switch to perform the action.
- SW[0] (Rightmost switch): Move Right โก๏ธ
- SW[1]: Move Left โฌ ๏ธ
- SW[2]: Start Game / Resume from Pause
โถ๏ธ - SW[3]: Pause Game โธ๏ธ
- VGA Monitor: The main game screen! Features custom drawn pixels and fonts.
- HEX Displays (HEX5-HEX0): Shows your current live SCORE.
- Red LEDs (LEDR): Shows how many LIVES you have left (you start with 5).
You don't need a physical DE1-SoC board to play this. We can use the awesome CPUlator web simulator.
- Open CPUlator: Head over to the Nios II DE1-SoC simulator here: ๐ https://cpulator.01xz.net/?sys=nios-de1soc
- Paste the Code: Clear whatever code is in the main "Editor" window on the site, and copy-paste the entire contents of
game.cinto it. - Compile: Click the Compile and Load button (or hit
F5). If it compiles successfully, it will jump to the "Debugger" tab. - Run the Game: Click the Continue button (or hit
F3). - Set up the View:
- Scroll down to the VGA Pixel Buffer section to see the game screen.
- Find the Switches section to use the controls.
- Play: Flip SW[2] UP (click the switch so it goes up) to start your adventure!
Pro-tip: If the game feels a bit too slow or too fast, you can change the SPEED_STEP or the frame_delay loop count in the code and recompile!
For the nerds out there (we love you), here's how this ticks under the hood:
- Language: C (C11 standard)
- Target: Nios II soft-core processor.
- Graphics:
- Direct writes to the VGA Pixel Buffer (
0x08000000) for drawing platforms, backgrounds, and the character. - Writes to the VGA Character Buffer (
0x09000000) for the HUD overlay (Score & Lives text).
- Direct writes to the VGA Pixel Buffer (
- I/O:
- Switches mapped to
0xFF200040. - LEDs mapped to
0xFF200000. - HEX Displays mapped to
0xFF200020&0xFF200030.
- Switches mapped to
- Timing: Uses an inline assembly barrier
__asm__ __volatile__("")in a loop to create a predictable frame delay without the Nios II compiler optimizing it away or triggering simulator cache warnings.
Have fun jumping! ๐