Free API

Free API
Website https://freeapi.openeggbert.com
Programming language C++
C++ standard C++20
Reimplements Subset of Windows API (~1998 Win32 era)
Built on SDL 3
Licence MIT

Free API is an experimental C++ project that reimplements a minimal subset of the Windows API (WinAPI), roughly targeting functionality available around 1998 (Win32 era). It allows Free Eggbert (the decompiled Speedy Blupi) to run on non-Windows platforms without depending on Windows or compatibility layers like Wine.

Architecture

WinAPI (subset ~1998)
      ↓
  Free API
      ↓
    SDL 3

Implemented features

Application entry: - WinMain abstraction (mapping to main)

Windowing: - Window creation (CreateWindowEx), message loop (PeekMessage, DispatchMessage), window procedures (WNDPROC)

Input (SDL 3 → WinAPI message translation): - Mouse motion → WM_MOUSEMOVE - Mouse buttons → WM_LBUTTONDOWN/UP, WM_RBUTTONDOWN/UP, WM_MBUTTONDOWN/UP - Keyboard → WM_KEYDOWN / WM_KEYUP with VK_* codes (letters, digits, navigation, function keys F1–F12, control keys) - Text input → WM_CHAR - Window focus → WM_ACTIVATEAPP

MIDI music (mmsystem.h) — TinySoundFont + TinyMidiLoader: - MCI_OPEN/PLAY/CLOSE for MIDI sequencer files - Renders MIDI to stereo float PCM via TinySoundFont and feeds it to an SDL 3 audio stream - Requires a SoundFont 2 (.sf2) file for audio synthesis - Supports MIDI Type 0 and 1 files

Multimedia timer: - timeSetEvent / timeKillEvent implemented with SDL_AddTimer / SDL_RemoveTimer

System utilities: - GetTickCount, Sleep, OutputDebugString

Debug options

Environment variable Effect
FREE_API_DEBUG_INPUT=1 Log all translated input messages
FREE_API_DEBUG_MIDI=1 Log per-call MIDI debug info

SoundFont requirement

A SoundFont 2 (.sf2) file is required for MIDI music playback. Lookup order: 1. FREE_API_SOUNDFONT environment variable 2. assets/soundfont/default.sf2 3. soundfont/default.sf2

Free SoundFonts: GeneralUser GS, FluidR3_GM

Platform support

Platform Status
Linux Supported via SDL 3
Windows Supported via SDL 3
macOS Supported via SDL 3
Android Supported (SoundFont must be packaged in assets)
Web (Emscripten) Supported (may need user gesture for audio)

Build

cmake -B build
cmake --build build