Skip to content

Instantly share code, notes, and snippets.

@uyjulian
Created December 31, 2023 21:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uyjulian/db3a2dd9f480c6df76084fdc71081c63 to your computer and use it in GitHub Desktop.
Save uyjulian/db3a2dd9f480c6df76084fdc71081c63 to your computer and use it in GitHub Desktop.

External plugin support for Kirikiri SDL2

Support for external plugins has been implemented in Kirikiri SDL2.

For Win32 platforms, in most cases, the plugins built for Kirikiri 2 and Kirikiri Z will work as-is without any modifications.

The source code for plugins ported to work with Kirikiri SDL2's other supported platforms can be found in the "krkrsdl2" branch, and releases/binaries in the "latest_krkrsdl2" tag:
https://github.com/krkrsdl2/KAGParser
https://github.com/krkrsdl2/SamplePlugin (basetest, exceptiontest, extrans, imagesaver, nativeclasstest, wutcwf, xp3dec)
https://github.com/krkrsdl2/fstat
https://github.com/krkrsdl2/json
https://github.com/krkrsdl2/krglhwebp
https://github.com/krkrsdl2/ncbind
https://github.com/krkrsdl2/varfile
https://github.com/krkrsdl2/wuvorbis

Plugin loading search method

The environment variable KRKRSDL2_PATH can be set to a colon-delimited list of paths to search for plugins.
If it is not set, it is set to ${ORIGIN}:${ORIGIN}/system:${ORIGIN}/plugin by default.
The command line parameter -krkrsdl2_pluginsearchpath will override the path search variable.
Each occurance of ${ORIGIN} and $ORIGIN will be replaced with the path of the directory where the executable is located.

The logic for this is in the file src/core/base/sdl2/StorageImpl.cpp in function TVPLocatePlugin.
If the path of the plugin has a ":" character in it, this is treated as an absolute path and used as is for the loading path.
Otherwise, it is treated as a relative path and the following steps take place:

  • (Win32 only) If file exists in auto search path, then it will be used
  • (Non-Win32 only) If file ends in .dll, it will be changed to .so
  • For each search path, if local file is found, then it will be used

To support feature checking for the existence of plugins, the TJS method Storages.isExistentPlugin has been added which uses the same logic as the above.

Currently missing features

(This information may be outdated.)

  • Automatic plugin loading (.tpm)
  • DrawDevice plugin interface
  • DirectSound/Direct3D interfaces for Win32 platforms
  • Susie image/archive plugin

Not planned to be implemented

(This information may be outdated.)

  • Win32 windowing/message handling functions for non-Win32 platforms (please use Wine with the Win32 build of Kirikiri SDL2)
  • DirectDraw/DirectSound/Direct3D interfaces for non-Win32 platforms
  • DirectDraw interface for Win32 platforms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment