mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-06-24 17:53:29 -04:00
9cf1f9e1d7
* start add wasm integration * some test * some improvement * try more language * expend try with python * update * half working python * improve and extend test * get py2wasm work but not so well * convert to use in cpp * start prepare multimodule * improve a little by using cpp (but still not great) * Update wasm.cpp * try ocaml * add a working example of python with a not complete function * remove type to be even more curse * start add a proper mod loader * allow mod to communicate between * example of hook --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>
36 lines
829 B
C
36 lines
829 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#define IMPORT_FUNC(return_type, name) __attribute__((import_name(#name))) return_type name
|
|
|
|
IMPORT_FUNC(int, call_extern_function)(char* module, char* function_name, int argc, int* argv);
|
|
IMPORT_FUNC(void, hook_render)(void());
|
|
IMPORT_FUNC(void, load_debug_font)();
|
|
IMPORT_FUNC(void, post_debug_print)();
|
|
IMPORT_FUNC(void, debug_print_str2)(int x, int y, char*);
|
|
|
|
int fib(int n) {
|
|
call_extern_function("test", "testfunc", 0, NULL);
|
|
if (n <= 1) {
|
|
return n;
|
|
}
|
|
return fib(n - 1) + fib(n - 2);
|
|
}
|
|
|
|
void testfunc() {
|
|
printf("call testfunc with the function test\n");
|
|
}
|
|
|
|
void some_render() {
|
|
load_debug_font();
|
|
debug_print_str2(0, 0, "hello");
|
|
post_debug_print();
|
|
}
|
|
|
|
void init() {
|
|
printf("init test\n");
|
|
hook_render(some_render);
|
|
}
|
|
|
|
int main() {
|
|
} |