A retro-inspired fantasy console emulator built with C# and .NET 8, featuring Lua scripting, sprite graphics, and chiptune audio synthesis.
YAFC is a virtual console platform that allows you to create and play retro-style games. It provides a pixel-art graphics API, input handling, and audio synthesis capabilities, all powered by Lua scripts packaged in .yafc cartridge files.
- Lua Scripting Engine – Games are written in Lua using the MoonSharp interpreter
- Graphics System – Sprite drawing, text rendering, and a classic 16-color palette
- Audio Synthesis – 4-channel chiptune audio generation (Pulse, Triangle, Noise waveforms)
- Input Management – Keyboard controls mapped to 6 buttons (arrow keys + Z/X)
- Cartridge Format – ZIP-based
.yafcfiles containing Lua code and sprite sheets - VRAM Management – Efficient sprite and resource management with tile-based rendering
- Retro Aesthetic – resizable window, classic gaming feel
ConsoleRuntime– Main runtime manager; handles window, audio, input, and Lua lifecycleCartridgeManager– Loads and extracts game cartridge files (ZIP archives)VirtualConsoleApi– Lua API bindings for graphics, input, and audioVramResourceManager– Sprite sheet management and tile renderingAudioSynthesizer– Waveform generation and audio playbackInputManager– Keyboard input polling and button state tracking
- Launch with a
.yafccartridge file or use menu mode - Load Lua code and sprite sheet from cartridge
- Call Lua functions:
init(),update(),draw()each frame - Render graphics and play audio through Raylib
- .NET 8 SDK or later
- Windows, macOS, or Linux
dotnet build YAFC.slnx
dotnet run --project YAFCdotnet run --project YAFC -- path/to/game.yafcOr launch menu mode:
dotnet run --project YAFCspr(id, x, y, scale, flipX, flipY) -- Draw sprite
cls(r, g, b) -- Clear screen
print(text, x, y, size, r, g, b) -- Draw textbtn(id) -- Check if button held (0-5: left/right/up/down/Z/X)
btnp(id) -- Check if button pressed this framesound(channel, frequency, volume, duty) -- Play tone on channel 1-4function init()
-- Called once at startup
end
function update()
-- Called every frame
end
function draw()
-- Called every frame after update
end.yafc files are ZIP archives containing:
game.lua– Main game codesprites.png– Sprite sheet (indexed PNG with 16-color palette)
- Start screen
- Implement DPCM (NES-style compressed audio) support
- Add support for multiple BIOS regions (2-3 regional variants)
- Raylib-cs – Graphics and audio rendering
- MoonSharp – Lua scripting
- NativeFileDialogSharp – File dialogs
See LICENSE.txt for details.