PolygonGBA - Interactive Album Experience
A unique Game Boy Advance homebrew project that transforms King Gizzard & the Lizard Wizard's album "Polygondwanaland" into an interactive audiovisual experience. This project pushes the boundaries of retro gaming hardware by implementing advanced audio compression, real-time visualizations, and optimized playback systems that showcase the intersection of music and low-level programming.
Released under Creative Commons, Polygondwanaland was specifically designed to encourage fan creativity and remixing.
Demo Video
What I Learned
Through building this retro gaming audio experience, I gained hands-on experience with:
- Low-Level Audio Programming: Implementing real-time audio processing with custom codec integration, sample rate conversion, and hardware-accelerated playback using DMA transfers and FIFO buffers
- Hardware Optimization: Managing memory constraints and CPU performance on a 16.78 MHz ARM processor, optimizing critical functions for IWRAM execution, and achieving 6% CPU usage for audio decoding
- Retro Game Development: Understanding GBA architecture including display modes, sprite management, VBlank synchronization, and the intricacies of developing for constrained embedded systems
- Audio Compression Techniques: Comparing and implementing different codecs (GSM vs 8AD ADPCM), understanding the trade-offs between compression ratio and CPU usage, and optimizing for real-time performance
Technical Architecture
Audio System
- Codec: 8AD (Pin Eight ADPCM) for efficient compression (~6% CPU usage)
- Sample Rate: 18,157 Hz mono optimized for GBA hardware
- Compression: 4:1 ratio (525MB original → 26MB total ROM size)
- Playback: Hardware-accelerated Direct Sound with double buffering
- Pipeline: WAV → Sox Resampling → 8AD Encoding → GBFS Packaging → ROM Integration
Graphics System
- Display Mode: MODE_0 tiled backgrounds with hardware sprites
- Visualizations:
- Real-time spectrum analyzer using Fast Fourier Transform (16 frequency bands)
- Live waveform display with amplitude analysis and smooth scrolling
- Static album cover display (128×128 optimized bitmap)
- Color Palette: Authentic Game Boy green with hidden full-color mode
- Performance: 60 FPS synchronized with VBlank timing
Memory Management
- VRAM: Optimized tile and sprite allocation with dedicated memory regions
- IWRAM: Critical audio decoding functions placed in fast internal RAM
- ROM: GBFS embedded filesystem containing compressed audio data
- Buffers: Double-buffered audio system with 608-byte aligned buffers
File System Architecture
- GBFS Integration: Game Boy File System for embedded audio data
- ROM Structure: Separate Side A and Side B builds for size optimization
- Asset Pipeline: Automated build scripts for audio processing and ROM generation
- Memory Mapping: Efficient data access patterns for real-time playback
Key Implementation Details
Audio Processing Pipeline
The audio system represents a carefully optimized chain from source material to hardware playback:
- Source Processing: Original 44.1kHz WAV files resampled to 18,157Hz using Sox
- 8AD Encoding: ADPCM compression achieving 4:1 ratio while maintaining audio quality
- GBFS Integration: Embedded filesystem packaging for ROM inclusion
- Real-Time Decoding: Hardware-accelerated playback with minimal CPU overhead
Performance Optimization Achievements
CPU Usage Reduction: Achieved dramatic performance improvement from 70% CPU usage (GSM codec) to just 6% (8AD codec), leaving substantial headroom for visualizations and user interface
Memory Architecture: Implemented sophisticated double-buffering system where Buffer A feeds the FIFO while Buffer B fills with decoded audio, swapping roles every VBlank interrupt for seamless playback
DMA Integration: Hardware Direct Memory Access transfers eliminate CPU involvement in sample feeding, allowing the audio system to operate independently while the processor handles visualizations
Challenges Overcome
Codec Selection Evolution
Initial Approach: Started with a custom format but quickly discovered the complexity was prohibitive for the project scope and timeline constraints.
GSM Implementation: Moved to industry-standard GSM codec which provided excellent 10:1 compression ratio, reducing Side A to ~4.5MB. However, the Linear Predictive Coding algorithms consumed 70% of the CPU, leaving insufficient resources for visualizations and smooth user interface.
8AD Solution: Adopted Pin Eight's 8AD ADPCM codec, trading compression efficiency (4:1 vs 10:1) for dramatic performance gains. The simpler delta encoding approach reduced CPU usage to just 6%, enabling real-time FFT analysis and smooth graphics.
Performance Bottleneck Resolution
Memory Access Optimization: Moved critical audio decoding functions from ROM to IWRAM (fast internal RAM) to eliminate the 16-bit bus bottleneck that was causing performance issues with ARM 32-bit instructions.
VBlank Synchronization: Solved audio stuttering by implementing precise timing synchronization with the display refresh cycle, ensuring buffer swaps occur during vertical blank intervals when the display hardware is idle.
FIFO Buffer Management: Debugged audio dropout issues by implementing proper FIFO status monitoring and DMA request handling, ensuring the 32-sample hardware buffer never underruns during playback.
ROM Size and Memory Constraints
Strategic Album Division: Addressed the GBA's ROM size limitations by splitting the 40-minute album across two separate ROM files, allowing each side to fit within practical cartridge constraints while maintaining full audio quality.
GBFS Integration: Overcame the lack of traditional file systems on GBA by implementing the Game Boy File System, enabling efficient embedded storage and retrieval of compressed audio data within the ROM structure.
Sprite Allocation Management: Resolved VRAM overflow issues in the visualization system by implementing careful sprite memory management and optimizing tile usage across the spectrum analyzer and waveform displays.
Project Impact
This project represents a unique intersection of music, retro gaming, and low-level programming. By transforming a modern psychedelic rock album into an interactive GBA experience, PolygonGBA demonstrates how creative constraints can drive technical innovation. The project showcases advanced embedded systems programming while honoring both the Creative Commons spirit of Polygondwanaland and the vibrant GBA homebrew community.
Acknowledgements
This project would not have been possible without the incredible open source technologies created by the GBA homebrew community:
- Damien Yerrick (Pin Eight): Game Boy File System and 8AD codec were crucial building blocks for this project
- DevkitPro: Making GBA development accessible with comprehensive toolchains and libraries
- GSM-Player-GBA: Served as an invaluable reference for audio pipeline design
- TONC (Tonc Online): Incredibly detailed GBA architecture documentation that made understanding the hardware possible
And of course, endless gratitude to King Gizzard & the Lizard Wizard for their incredible music and for releasing Polygondwanaland under Creative Commons, encouraging fans to create their own interpretations and copies.
This was my final project as part of Fractal Bootcamp, and it was by far the most difficult and most rewarding.