How merryou6/onscripter-jh works
Project type and purpose
• This is ONScripter‑Jh, a native C++ visual‑novel engine that interprets NScripter scripts.
• It takes script files, loads assets (images, audio), executes commands (text, animation, sound), and renders frames via OpenGL ES2.
File structure
• Top‑level components:
• Core engine sources (ONScripter*.cpp/.h, ScriptParser*, ScriptHandler)
• File readers (DirectReader, SarReader, NsaReader)
• Renderer (renderer/gles_renderer.cpp, shaders)
• Effects (builtin_dll/*.cpp)
• Utilities (coding2utf16, conv_shared, resize_image, simd)
• Scripting extensions (LUAHandler)
• Wrappers (AVIWrapper for audio/video)
• Notice the “renderer” subdir implementing a GLES2 backend and shader pipeline, and “simd” for performance.
README for additional insights
• Confirms this is a direct port/repo migration of an existing NScripter interpreter.
Components
a. Core Script Engine
• ScriptParser (lexing & command nodes)
• ScriptHandler (dispatches commands at runtime)
• LUAHandler (optional Lua scripting)
b. Resource Loading Layer
• FileReaders (DirectReader, SarReader, NsaReader)
• Archive decoders & converters (nsadec, sardec, conv_shared)
c. Asset Managers / Utilities
• FontInfo / TextInfo (sjis2utf16, gbk2utf16)
• Image resizing & dirty‑rect tracker
• SIMD utilities for optimized loops
d. Renderer Subsystem
• GLES2 Renderer (gles_renderer, gles2funcs)
• Shader modules (post_cas.h, etc.)
• DirtyRect & AnimationInfo integration
e. Audio & Video Playback
• AVIWrapper (video/audio stream)
• Parallel threads for sound effects
f. Effects Modules
• Built‑in DLL effects (cascade, snow, oldmovie)
g. Host / Platform Integration
• Main entry (onscripter_main.cpp)
• Versioning & build scripts
Relationships & Data Flows
• Script files → ScriptParser → AST/command queue → ScriptHandler
• ScriptHandler → invokes Resource Loader for assets → feeds data to Renderer or AVIWrapper
• ScriptHandler → calls effect modules or push commands to Renderer
• Renderer → draws frames via GLES2, uses shaders & SIMDe optimizations
• Parallel threads handle audio and non‑blocking operations
Architectural patterns & principles
• Modular separation: parsing, handling, rendering, resource loading, effects
• Plugin‑style effects: builtin_dll folder loaded at runtime
• Platform abstraction: GLES2 under renderer, generic file readers
• Performance optimizations: SIMD layer
• Annotations for important technologies (OpenGL ES2, SIMD, Lua)
Final advice
• Be comprehensive: break the engine into all its modules (parsing, handling, rendering, I/O, utilities, plugins).
• How data moves from script files all the way to on‑screen output or audio playback.