Skip to content

v0.0.4: Flashback SMS: add support for music.

Choose a tag to compare

@haroldo-ok haroldo-ok released this 24 Sep 20:15
· 24 commits to main since this release

Full Changelog: v0.0.3...v0.0.4

This is a massive dual milestone for the project. Re-creating the audio architecture for the SN76489 PSG while simultaneously pushing script opcode coverage to 98--99% across all seven level parts brings this 4 MB Master System port remarkably close to a fully feature-complete conversion.

Key Technical Achievements in This Update

                   Dual-Engine Audio & Opcode Pipeline
                                     │
    ┌────────────────────────────────┼────────────────────────────────┐
    ▼                                ▼                                ▼
PSG Music Synthesizer           Analytic SFX Rebuilder           Script Opcode Expansion
- 3-Voice MIDI Downmix          - Noise/Pitch Envelope Matching  - 98--99% Opcodes Implemented
- Voice Pinning (Line Preservation)- Voice 3 & Noise Override     - Elevator Mechanics Supported
- 60 Hz Byte Streams (~0.5 KB/track)- Priority Channel Lockout    - Unported Steps Gracefully Skipped

1. SN76489 Audio Architecture

  • MIDI-to-PSG Dynamic Downmixing: Converting the DOS version's 27 MIDI tracks to the SMS PSG's 3 square wave channels and 1 noise channel uses a dynamic loudness allocation system. By pinning active notes to specific voices across frame transitions, melodic lines remain coherent without jumpy channel swapping.

  • Acoustic SFX Envelope Reconstruction: Rather than attempting raw PCM playback (which would destroy VBlank quotas and CPU time), 56 sampled effects were analyzed for noise ratio, pitch trajectory, and volume envelopes, then re-synthesized into native PSG tone and noise bursts.

  • Audio Channel Prioritization: Sound effects trigger on Tone Voice 3 and the Noise channel. When an SFX plays, music register writes to those specific channels are temporarily suppressed, avoiding register contention and audio garbage.

2. Elevator Mechanics & Opcode Expansion

  • Vertical Traversal Opcodes: Ported isBelowConrad and isAboveConrad, enabling lifts and platforms in Level 2 (New Washington) and Level 3 to evaluate Conrad's relative vertical positioning and trigger movement vectors.

  • Script Engine Coverage: Added direction-relative collision tests, addToCredits, setCollisionState2, and object/grid collision queries. Script execution across all seven level parts now operates at 98--99% native opcode coverage.

Master System Audio & Level 2 Script Matrix

System Component Execution Model Resource Footprint
ROM Space 4,096 KB / 4,096 KB (100% Full) Packed with the 11 reachable music tracks
PSG Music Tracks 11 active tracks (Title + Cutscenes + Levels) 60 Hz pre-rendered byte streams (~0.5 KB / track)
Synthesized SFX 56 active reconstructed effects Plays via Tone Channel 3 + Noise Channel
Level 2 Lifts & Elevator Scripts Driven by isBelowConrad / isAboveConrad Unported opcode rate dropped to 3 hits per 86 frames

Verification & Checksum Log

  • MD5 Build Checksum: cfb638952aca7d47942ba88e8d56a82a

  • Tick-for-Tick Oracle Test: 100% parity retained across the first 504 frames (~17s) of Level 1.

  • Audio Bus Validation: Verified via headless emulator register logging (Title Theme: 60 writes over 37 frames; SFX: 45 writes over 18 frames with expected volume decay and tone latching).