How dogo/oslib works
Project Type and Purpose
• OSLib is a static C/C++ library for classic/retro game development, targeting PSP and other platforms.
• It exposes graphics, input, audio, file I/O, networking, font rendering, math, and utility functions.
• It ships as libosl.a plus headers; includes sample apps and conversion tools.
File Structure
• Top Level
– Build files: CMakeLists.txt, Makefile, install.{sh,bat}, release.{sh,bat}
– Output: libosl.a (static archive)
– Docs: Doc/ + README.md, Doxyfile, CHANGELOG.md
– CI: .github/workflows/Build.yml
• Source Modules (src/)
– Core: oslib.c/h, oslmath.h, stub.S
– Graphics: drawing.c/h, palette.c, image loaders (src/Special/), PNG/GIF libs
– Audio: src/audio/, bgm.c, mod.c, media.c
– Input/UI: dialog.c, messagebox.c, osk.c
– File/Virtual FS: vfile/, VirtualFile.h, save/load
– Network: net.c, adhoc/pspadhoc.c
– Math: libpspmath/, vfpu*.c/h
– Font: intraFont/, sfont.c
– Utility: keys.c, text.c, map.c, vram_mgr.c, mem/
• Samples (samples/)
– Demonstrations of each subsystem linking against libosl.a.
• Tools (tools/)
– Converters: font2osl.exe, wav2bgm.exe + their sources.
Extract Additional Insights from the README
• Features: Graphics, Input, Sound, Utilities, Cross-Platform support.
• Installation: copy libosl.a + headers into PSP-SDK paths.
• Contributing: tests, coding guidelines, CI.
a. Components
– Application / Sample Projects (e.g. samples/*)
– OSLib Static Library (libosl.a)
– OSLib Sub-Modules (Graphics, Audio, Input/UI, Virtual FS, Network, Math, Font, Utility)
– External Third-Party Libraries (zlib, GIF, PNG)
– Platform Abstraction Layer (Platform/PSP.cmake, any PSP-specific code)
– Build System (CMake, Makefiles, install/release scripts)
– Development Tools (font2osl, wav2bgm)
b. Relationships & Data Flows
– Samples & user apps link → libosl.a
– libosl.a comprises modules that call → External libs (PNG, GIF, zlib)
– Modules communicate through core utilities (VirtualFile, memory, VFPU)
– Build system orchestrates compilation of src/ into libosl.a, compiles tools, runs tests
– Platform layer adapts calls for PSP vs. generic OS
c. Architectural Patterns & Principles
– Modularization: each domain (audio, graphics, etc.) lives in its own directory
– Abstraction Layer: Virtual filesystem, platform-specific glue isolated
– Adapter Pattern: image-format loaders under src/Special act as adapters for GIF/PNG/JPG
– Static Linkage: everything consolidated into one archive for simplicity on embedded targets
d. Key Technologies & Frameworks
– Languages: C, C++ (for tools)
– Build: CMake, Make, PSP-SDK CMake wrapper, batch/shell scripts
– Documentation: Doxygen
– CI: GitHub Actions
Diagramming Recommendations
– Use rectangles for components (Modules, Library, Apps, Tools).
– Use parallelograms for data stores or resources (maps, fonts, audio assets).
• Library Core (blue)
• Sub-modules (green)
• External dependencies (orange)
• Samples/Apps (purple)
• Tools & Build (gray)