How simon-gardier/dance-dance-revolution-assembly works
Project type and purpose
• This is an embedded‐systems project: a Dance Dance Revolution–style game written entirely in PIC16F1789 assembly.
• It implements video signal generation (PAL-G), audio via the PSMC module, input polling, game logic, and a simple menu/high-score system—all on a single microcontroller.
High-level system components
a. Hardware
• PIC16F1789 microcontroller
– CPU core (fetch/execute assembly instructions)
– Program memory (flash) holding .s and .inc modules
– Data memory (RAM) for frame buffering and game state
– PSMC (Programmable Switch-Mode Controller) for sound output
– PORTC latch used as video shift-register
– GPIO ports for button inputs
• Composite video output (to TV/monitor)
• Audio amplifier/speaker
• Button matrix or individual inputs (dance pad)
• Power supply circuitry (L7805CV, MOSFETs, connectors)
• PCB traces/connector to external display and controls
b. Firmware modules (in /code)
• main.s — Initialization, main loop, frame synchronization
• video.inc / video.s — PAL-G sync pulses, pixel-by-pixel shifting via PORTC
• game_logic.inc / game_logic.s
— State machine: menu, in-game, scoring, lives
• inputs.inc / inputs.s — Polling of buttons, debouncing
• music.inc / music.s — Frame-synchronous music generation via PSMC
• ram.inc — Definitions for RAM usage (frame buffer, state)
• bits.inc, utils.inc — Shared macros and utility routines
c. Documentation & supporting files
• electrical_schematic.pdf — Full hardware electrical schematic
• report.pdf — Overall design rationale, performance trade-offs
• datasheets in documentation/— PIC16F1789, video standard, connectors
Interactions & data flows
• At power-on, main.s initializes I/O, PSMC, timer, and enters the vertical-blank–synchronized loop.
• Each video frame:
– music module checks whether to advance the audio waveform
– video module shifts out pixels one bit at a time via PORTC, generating sync and video signals
• Outputs:
– Video output → TV (composite PAL-G)
– Audio output → speaker
• Inputs:
– Button presses → GPIO → inputs.s → game_logic
Architectural patterns & design principles
• Single-threaded, frame-paced loop: ensures deterministic timing aligned with video’s 50 Hz refresh.
• Separation of concerns:
• Hardware interface (video.s, music.s, inputs.s)
• Core logic (game_logic.s)
• Resource-constrained optimization: bit-banging video on PORTC, minimal branching in tight loops, RAM usage carefully planned.