Skip to content

Releases

v0.0.2: Wolf 3D GBC: Improve performance, roughly 12.5 FPS from 7.5.

Choose a tag to compare

@haroldo-ok haroldo-ok released this 09 Nov 09:23

Full Changelog: v0.0.1...v0.0.2

Here is a clear, player-friendly summary of the v0.0.2 performance update for Wolfenstein 3D (Game Boy Color):

⚡ Massive Performance Boost: Jump from 7.5 to ~12.5 FPS!

The v0.0.2 optimization update for the Game Boy Color port achieves a massive 60% to 70% performance increase across all gameplay scenes, lifting frame rates from roughly 6.5--7.5 FPS up to 9--12.5 FPS (and drastically smoothing out heavy CPU-bound actions like walking up close to items).

Performance Benchmarks (Frames Drawn in 10 Seconds via SameBoy)

Scene / Test Case Previous Version v0.0.2 (Now) Performance Gain
Guard Room (Standing Still) 72 frames 125 frames +73%
Guard Room (Turning) 65 frames 107 frames +65%
Level Start (Standing Still) 64 frames 94 frames +47%
Level Start (Turning) 65 frames 107 frames +65%
Hallway (Turning) 65 frames 108 frames +66%
10 Views Close to Items 44 frames 74 frames +68%

🏎️ Key Architectural Optimizations

  • Double-Buffered Frames & Zero Idle Wait: Eliminated the idle CPU bottleneck where the game previously sat waiting up to 1.3 screen refreshes for VRAM copies. Frames are now double-buffered, allowing the CPU to draw the next frame while the previous one copies to video memory in the background.

  • Expanded VBlank Data Transfer: VRAM chunk copies were dynamically resized based on remaining blanking time. Transfer rates doubled from 48 blocks per refresh up to ~95 blocks (with smart runtime safety fallback checks for slower emulators like mGBA).

  • Assembly Hot Paths: Moved core ray casting, wall drawing loops, item/enemy on-screen positioning, and sprite projection routines into optimized hand-written assembly using fast multiplication lookup tables.

  • Smart Screen Clearing: Replaced the heavy full-buffer screen clear with a targeted clear that only wipes rows left uncovered by new wall placement. Sprite column loops were also updated with a new texel format that skips transparent top-row padding entirely.

  • HUD Flicker Fix: Resolved an infrequent 2--3% color corruption bug on the face and weapon icon.

  • Test Suite Improvements: Added a wait_ne command to the testing tool to stabilize frame-state read checks during enemy and combat tests.

v0.0.1: Wolf 3D GBC: perform initial port using Claude.

Choose a tag to compare

@haroldo-ok haroldo-ok released this 08 Nov 11:18

Full Changelog: https://github.com/haroldo-ok/wolf-3d-gbc/commits/v0.0.1

image image image image image

Here is a comprehensive summary of the Wolfenstein 3D (Game Boy Color) port project:

🎮 Wolfenstein 3D (Game Boy Color) --- Port Overview

This project is an unofficial port of id Software's Wolfenstein 3D (shareware Episode 1, spanning all 10 floors) to the Game Boy Color, building upon the preceding Sega Master System and Game Gear ports (haroldo-ok/wolf-3d-gg).

The port features full menu navigation, help pages, high score tables, 3 save slots, digitized voices, music, and sound effects.

Hardware Requirements & Architecture

  • Platform: CGB-only (Game Boy Color), requiring MBC5 banking, a 4 MB ROM footprint, and 128 KB of battery-backed save RAM.

  • CPU: Runs on the CGB's Double Speed Mode (2x CPU speed).

  • Language & Toolchain: Written in standard C using SDCC (sdcc -msm83) for the sm83 core, backed by hand-written Z80/sm83 assembly for performance-critical hot paths (wall/sprite columns, ray stepping, multiplications, VRAM copies via GDMAs, line interrupts, and sampled voice playback).

🕹️ Controls

Button In-Game Action Menu / UI Action
D-Pad

Up/Down: Walk forward/backward

Left/Right: Turn
| Move cursor / navigate |
| A Button | Fire weapon | Select option / Next help page |
| B Button |

Open doors, push walls

(Hold Left/Right to strafe)
| Back out of menu |
| SELECT | Switch active weapon | Previous help page |
| START | Open in-game menu (Save, Load, Sound, Quit) | --- |

🛠️ Building & Compilation

Prerequisites

  • make, Python 3 with numpy and Pillow, SDCC 4.2 (sdcc -msm83), gcc (for the headless test harness), curl, unzip, and git.

Build Commands

  1. Fetch id Software Shareware Data & Source Release:

    Bash

    tools/fetch_data.sh
    
    

    (Pulls assets from Archive.org into ../work, which the converters read to generate gen/ over ~70 seconds).

  2. Build the Main Release ROM:

    Bash

    make
    
    

    (Outputs rom/wolfz3d.gbc / rom/wolf3d.gbc).

Other Make Targets

  • make direct --- Builds rom/direct.gbc (a test ROM that waits for test directives like dbg_startmap, dbg_go, dbg_god).

  • make prof --- Builds a profiling test ROM with full symbol tables (game.cdb).

  • make test --- Builds ROMs and automatically executes the test harness suite (tests/run_all.sh).

  • make clean --- Cleans build artifacts while preserving generated assets in gen/.

Note: tools/checkmap.py runs automatically on every link, failing the build if fixed bank 0 or any switchable bank overflows, or if working RAM (WRAM) stack headroom drops too low.

⚙️ Technical Highlights & Rendering

  • 3D Viewport: Renders at 160 × 96 pixels using 40 rays of 4 pixels width, drawn column-major into a WRAM Bank 3 frame buffer. It copies chunks to VRAM via General Purpose DMA (GDMA) during VBlank (while LY is 144--150) into off-screen tile/BG maps before flipping the halves. Each 8×8 tile holds a single palette, so wall families and sprites occupy dedicated tile columns.

  • Line Interrupts: Dynamically switch the ceiling color to the floor color at the horizon line, and load HUD tiles/palettes below the view area.

  • Hi-Colour Title Screen: Rewrites background (BG) palettes on every HBlank (hc_frame in src/hw_a.s---3 palettes per line), allowing sets of 4 colors to cover pairs of lines across tiles, rendering roughly 400 simultaneous colors on screen (converted via tools/gb_hicolor.py).

  • Audio System:

    • Game Gear SN76489 event streams map directly to the CGB APU (tone channels route to wave/pulse channels; noise routes to noise).

    • Digitized voices use 3-bit samples driven directly to the master volume by a timer interrupt operating at 8 kHz.

  • Input Polling: Sampled on every frame interrupt; turning and movement scale dynamically based on how long directions were held, ensuring quick button taps are never dropped.

  • Performance: Renders a new 3D frame every ~9 screen refreshes (6--7 FPS), bound heavily by CPU-side raycasting, wall columns, and sprite sorting.

🧪 Testing & Automated Verification

The test suite (tests/run_all.sh) drives ROMs inside SameBoy via tools/gbtest (a headless front-end built using SameBoy's static library).

  • Key Regression Tests:

    • t_boot_menu --- Boot sequence, PG-13 screen, hi-color title (>64 colors), audio, and options.

    • t_menu_screens --- Load Game, Read This! help pages, and High Scores.

    • t_newgame --- New Game sequence, Get Psyched, 3D view rendering, movement, and stack integrity.

    • t_pause_menu --- Pause functionality and game resumption.

    • t_controls --- D-pad navigation, turning angles (90/180/270 degrees).

    • t_enemies --- Guard rendering and combat logic.

    • t_walk --- Long random walks (tools/randwalk.py) to verify stable frame rendering.

    • t_intermission --- Floor completion stats screen and level transitions.

    • t_levels.sh --- Verifies successful boot, rendering, and navigation across all 10 individual floors.

  • Debugging Tools (tools/gbtest): Includes commands for profiling (prof, incl, hot, calls), hang detection (progress), memory watchpoints (watch, minsp), GDMA logs, VBlank tracing, and crash handlers.