summaryrefslogtreecommitdiff
path: root/kon/konrmplugin.h
diff options
context:
space:
mode:
Diffstat (limited to 'kon/konrmplugin.h')
-rw-r--r--kon/konrmplugin.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/kon/konrmplugin.h b/kon/konrmplugin.h
new file mode 100644
index 0000000..4b0c3a3
--- /dev/null
+++ b/kon/konrmplugin.h
@@ -0,0 +1,77 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * konrmplugin.h
+ *
+ * Copyright (c) 2026 KonAki
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef KONRMPLUGIN_H
+#define KONRMPLUGIN_H
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*** definition ***/
+
+/* plugin commands of RPG Maker games (356 in MV, 357 in MZ), the way mzscript writes them. what a plugin does is its own JavaScript,
+ which is never run, so each command a game uses is something you answer yourself, by name. you hand over a table of names and
+ functions. a name with a NULL function is known and does nothing, for the ones that only dress up the original. a command that
+ is not in the table does nothing too, but is counted, so you can see what a game still needs */
+
+#define KON_RM_PLUGIN_ARGS 16
+#define KON_RM_PLUGIN_MISSED 64
+
+/* argv[0] is the command and argc counts it, the rest are what came after, apart by spaces in MV and by tabs in MZ (where the
+ command is the plugin, a dot, then the command). they are only good while the function runs. return 1 when the script is to wait */
+typedef int (*kon_rmPluginFn)(int argc, const char *const *argv, void *user);
+
+typedef struct kon_rmPluginEntry {
+ const char *name;
+ kon_rmPluginFn fn;
+} kon_rmPluginEntry_t;
+
+typedef struct kon_rmPlugins {
+ const kon_rmPluginEntry_t *entries;
+ int count;
+ void *user;
+ struct {
+ char name[48];
+ int count;
+ } missed[KON_RM_PLUGIN_MISSED];
+ int missedCount; /* kinds written down in missed */
+ int missedTotal; /* all of the commands that were not in the table */
+} kon_rmPlugins_t;
+
+void kon_rmPluginsInit(kon_rmPlugins_t *plugins, const kon_rmPluginEntry_t *entries, int count, void *user);
+
+/* returns -1 when the code is not 356 or 357, else what the command's function said, or 0 */
+int kon_rmPluginHost(kon_rmPlugins_t *plugins, int code, const char *text);
+
+/* the commands that were not in the table, in the order they first came, 1 and the name and how often, or 0 past the last */
+int kon_rmPluginMissed(const kon_rmPlugins_t *plugins, int index, const char **name, int *count);
+
+#ifdef __cplusplus
+}
+#endif
+#endif