How xpost2000/legends-jrpg works
Project Type & Purpose
• This is a full-featured game engine and game, specifically a tactical JRPG reminiscent of late SNES titles.
• The engine handles software rendering (with custom SIMD optimizations), multithreaded job scheduling, audio (with SDL2_mixer and SoLoud), and custom systems for scripting, editing, and file packaging.
• The README emphasizes features like the entirely self-made engine, custom scripting language (lisp based), a variety of development tools (level and world map editors), and custom resource formats.
File Structure
• Top-Level Directories:
• "src": Contains all the engine/game source code, subdivided into modules for graphics, audio, UI, battle, cutscenes, script, input, and file serialization.
• "areas", "scenes", "shops", "worldmaps", "dlg", "res": These directories hold game-specific data files, level definitions, dialogues, UI assets, and media art. They are loaded at runtime through the game’s virtual file system.
• "bigfilemaker": Tools for building the custom bigfile archive used by the virtual filesystem.
• "dependencies": Contains third-party libraries (SDL2, stb) and also assets related to SDL2 linking under various platforms.
• "media": Contains code samples and additional documentation; useful for understanding how subsystems (like input, jobs, serialization) are constructed.
• Build scripts & Makefile:
• The Makefile indicates targets for running the game (release and debug), packaging the distribution with “run-tree”, and specialized web builds (using emscripten) and Windows builds. This suggests a modular build process with clearly differentiated build targets.
Main Components
a. Core Engine Subsystems:
• Game Loop & Main Module (src/main.c, src/game.c, etc.)
• Multithreaded Job System: Represent the custom job queue (note references in README regarding SIMD and multithreading).
b. Rendering System:
• SDL2 & Platform Abstraction: Note the usage of SDL2 in "dependencies" and specialized audio modules (src/audio_sdl2_mixer.c, src/audio_soloud.c).
c. Audio Subsystem:
• SDL2_Mixer module and SoLoud variant – indicating the abstraction layer over audio.
d. UI & Input Handling:
• Several UI modules (pause_menu_ui.c, options_menu_ui.c, inventory and equipment UI) and input mapping (src/input.c, src/input_mapper.c).
e. Scripting Engine & Custom Formats:
• Custom scripting language and dialogue system (src/dialogue_script_parse.c, src/game_script.c, etc.) along with serialization and binary file packing (bigfilemaker, custom save system with delta compression).
f. Development Tools / Editors:
• Level Editor (src/editor.c) and World Map Editor (src/world_editor.c). It’s important to indicate that these tools output custom binary files which are also read by the game.
g. Data/Resource Management:
• Virtual Filesystem using bigfile archives, areas, scenes, and resource files stored in res/, dlg/, shops/, and worldmaps directories.
Relationships and Interactions
• How the core game loop orchestrates the various subsystems – graphics, audio, UI, and scripting.
• Data flow from resource directories through the custom file loader (bigfilemaker output) to runtime engine components.
• Relationship between the editors and the runtime engine (editors create files that are subsequently loaded by the game).
Architectural Patterns & Design Principles
• Layered architecture: hardware/platform abstraction layer (SDL2, dependencies), core engine (game loop, memory management), and domain-specific modules (combat, UI, scripting).
• Separation between development tools vs. runtime engine components.
• The use of components like memory arenas and a job system hints at an architecture designed for high performance with a fixed memory footprint.