How jasoni111/pong works
Project Type and Purpose
• This is an embedded firmware project (no separate frontend/backend).
• Purpose: Run a two-player Pong game on Smart Car boards, synchronizing over Bluetooth.
File Structure
• Top-level build scripts:
• Makefile, MakeConfig.inc – orchestrate compilation & linking.
• build/*.ld – linker scripts for various MCUs (d10, f15, z4).
• inc/ – hardware abstraction & game module headers:
• config.h – board-specific pin/timer configs.
• comm.h – abstract Comm interface.
• bluetooth.h – concrete Bluetooth implementation of Comm.
• sprite.h – abstract rendering API for on-screen objects.
• ball.h, platform.h – game object classes.
• src/main.cpp – game loop, instantiates objects, handles game logic & event dispatch.
README Insights
• Uses libbase & libsc (board support libraries) to access timers, display, Bluetooth (JyMcuBt106).
• Communication protocol must be implemented in Bluetooth::SendBuffer and EnableTimer.
• Game objects (Ball, Platform) inherit from Sprite and use Comm to sync state.
Main Components
a. Hardware Layer
• MCU Core (Cortex-M or equivalent)
• Bluetooth Radio (JyMcuBt106 module)
• / Graphics Driver (LCD/TFT)
• Timers / PIT for periodic interrupts
• Input controls (buttons/joystick)
b. Software Layer
• HAL / Board Support (libbase/libsc)
• Comm Interface (abstract class)
• Bluetooth Module (Comm implementation)
• Sprite Framework (abstract rendering API)
• Game Objects: Ball, Platform
• Main Game Controller (in main.cpp)
• Build System (Makefile + Linker Scripts)
Relationships & Interactions
• Main Game Controller
→ Instantiates Ball & Platform
→ Reads Input → libsc GPIO APIs
→ Uses Comm.send()/recv() → Bluetooth Module
• Bluetooth Module
→ Uses PIT timer interrupts → sends/receives packets via UART to radio
• Sprite Framework
• Game Objects
→ Extend Sprite; maintain position/state
• Build System
→ Compiles src + libbase/libsc → final firmware → target MCU via linker scripts
Architectural Patterns & Principles
• Layered Architecture:
Hardware Abstraction → Comm/Sprite Interfaces → Game Logic
• Dependency Inversion: high-level game logic depends on abstract Comm & Sprite, not concrete Bluetooth or display code.
• Event-driven via interrupts/timers for synchronization and refresh.
Putting It All Together
Hardware on the far left → HAL → Interfaces → Game Logic → back to Hardware.
• Or stack layers vertically.
• Notes for key protocols (e.g., “Bluetooth UART @ 9600 bps, custom packet format”).