MKSC Neo

Architecture#

MKSC Neo is a native C11 program. The original game's rules (physics, collision, CPU drivers, items and scoring) were recovered from the decompilation and re-implemented as a deterministic simulation. SDL 3 provides windows, input, audio and graphics. All game content comes from the player's ROM at run time.

Source map#

Directory Contents
portable/core/ Fixed-tick simulation: kart physics, collision, terrain, camera, effects, and the 3D course physics.
portable/app/ Game flow: menus, race sessions, CPU drivers, items, scoring, ceremonies, replays.
portable/assets/ Pack reading, content composition and typed views over pack sections.
portable/import/ ROM importers: Super Circuit to a game pack, and Mario Kart DS / 64 to mods.
portable/audio/ Sequencers (GBA, DS and N64 songs), voices and mixing.
portable/platform/ SDL layer: entry point, shell, renderers, input, files, mods, Lua host, store.
portable/data/ Built-in rule profiles and menu data.
portable/tests/ C unit tests and executable smoke routes.
tools/portable/ Test runner, reference importer, mod kit, format compilers, packaging.
tools/site/ Project website generator.
mods/examples/ Example mods and generators.

core/, app/, assets/ and audio/ don't depend on SDL or the filesystem. The platform layer supplies clocks, input, files and presentation.

Simulation#

Content#

  1. Import. mksc --import (or the first-start screen) verifies the US ROM and converts it into a game pack. The Python importer tools/portable/import_rom.py produces the same bytes, and the tests check that they match. Packs carry an importer version, so the game can offer to re-import after an update.
  2. Packs. A pack is a list of typed, versioned sections identified by (kind, content_id): art, palettes, tracks, rules, music, text and so on. Readers validate every length, range and reference before use.
  3. Mods. Each enabled mod adds a layer. Later layers replace sections with the same key or add new ones, in the order the player chose. Mods are prepared and validated on a worker thread, then swapped in all at once, so a failed mod never leaves half-applied content. Lua runs in a sandbox per mod per race (platform/script_host.c, app/race_script_hooks.h).
  4. Saves. Settings, records, ghosts and GP progress live in the data folder. They use versioned formats and are written to a temporary file that then replaces the old one. Records are keyed by a content identity, which covers the mods, rule profiles and mirror mode, so different content never shares records.

Rendering#

Audio#

The simulation emits ordered sound commands. The audio session runs the original sequencer and voice priorities. The platform mixes engine and scene sound into an SDL audio stream. Imported DS and N64 courses bring their own sequencers and sound sets.

3D courses#

3D courses are a separate domain from the recovered 2D game. They have their own course IDs, records, ghosts and replay formats, and they never change 2D saves.

Other games#

Importing Mario Kart DS or Mario Kart 64 converts the player's ROM in the executable (import/nds/, import/n64/) into a local mod. The mod contains 3D courses, drivers, karts, items, music and sounds. Nothing derived from any ROM is committed or distributed.

Platforms#

Conventions#

Source: docs/ARCHITECTURE.md