minecraft-pi-reborn/media-layer/trampoline/src/media-layer-core.cpp

185 lines
4.0 KiB
C++
Raw Normal View History

2024-06-04 22:29:13 +00:00
#include <cstdint>
2024-05-12 01:14:14 +00:00
#include <SDL/SDL.h>
#include <media-layer/core.h>
#include <media-layer/audio.h>
#include "common/common.h"
2024-06-04 22:29:13 +00:00
#include <libreborn/libreborn.h>
2024-05-12 01:14:14 +00:00
// SDL Functions
CALL(0, SDL_Init, int, (uint32_t flags))
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-05-12 01:14:14 +00:00
return trampoline(flags);
#else
2024-06-04 22:29:13 +00:00
uint32_t flags = args.next<uint32_t>();
return func(flags);
2024-05-12 01:14:14 +00:00
#endif
}
CALL(1, SDL_PollEvent, int, (SDL_Event *event))
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-06-04 22:29:13 +00:00
return trampoline(uint32_t(event));
2024-05-12 01:14:14 +00:00
#else
2024-06-04 22:29:13 +00:00
SDL_Event event;
const int ret = func(&event);
writer(args.next<uint32_t>(), &event, sizeof(SDL_Event));
return ret;
2024-05-12 01:14:14 +00:00
#endif
}
CALL(2, SDL_PushEvent, int, (SDL_Event *event))
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-06-04 22:29:13 +00:00
return trampoline(*event);
2024-05-12 01:14:14 +00:00
#else
2024-06-04 22:29:13 +00:00
SDL_Event event = args.next<SDL_Event>();
return func(&event);
2024-05-12 01:14:14 +00:00
#endif
}
CALL(3, SDL_WM_SetCaption, void, (const char *title, const char *icon))
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-06-04 22:29:13 +00:00
trampoline(copy_array(title), copy_array(icon));
2024-05-12 01:14:14 +00:00
#else
2024-06-04 22:29:13 +00:00
const char *title = args.next_arr<char>();
const char *icon = args.next_arr<char>();
2024-05-12 01:14:14 +00:00
func(title, icon);
2024-06-04 22:29:13 +00:00
return 0;
2024-05-12 01:14:14 +00:00
#endif
}
CALL(4, media_toggle_fullscreen, void, ())
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-05-12 01:14:14 +00:00
trampoline();
#else
func();
2024-06-04 22:29:13 +00:00
return 0;
2024-05-12 01:14:14 +00:00
#endif
}
CALL(5, SDL_WM_GrabInput, SDL_GrabMode, (SDL_GrabMode mode))
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-06-04 22:29:13 +00:00
return (SDL_GrabMode) trampoline(mode);
2024-05-12 01:14:14 +00:00
#else
2024-06-04 22:29:13 +00:00
return func(args.next<SDL_GrabMode>());
2024-05-12 01:14:14 +00:00
#endif
}
CALL(6, SDL_ShowCursor, int, (int32_t toggle))
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-05-12 01:14:14 +00:00
return trampoline(toggle);
#else
2024-06-04 22:29:13 +00:00
return func(args.next<int32_t>());
2024-05-12 01:14:14 +00:00
#endif
}
CALL(8, media_swap_buffers, void, ())
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-05-12 01:14:14 +00:00
trampoline();
#else
func();
2024-06-04 22:29:13 +00:00
return 0;
2024-05-12 01:14:14 +00:00
#endif
}
CALL(9, media_cleanup, void, ())
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-06-08 07:09:55 +00:00
trampoline(false);
2024-05-12 01:14:14 +00:00
#else
func();
2024-06-04 22:29:13 +00:00
return 0;
2024-05-12 01:14:14 +00:00
#endif
}
CALL(10, media_get_framebuffer_size, void, (int *width, int *height))
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-06-04 22:29:13 +00:00
trampoline(uint32_t(width), uint32_t(height));
2024-05-12 01:14:14 +00:00
#else
2024-06-04 22:29:13 +00:00
int width;
int height;
func(&width, &height);
writer(args.next<uint32_t>(), &width, sizeof(int));
writer(args.next<uint32_t>(), &height, sizeof(int));
return 0;
2024-05-12 01:14:14 +00:00
#endif
}
CALL(59, media_audio_update, void, (float volume, float x, float y, float z, float yaw))
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-06-04 22:29:13 +00:00
trampoline(volume, x, y, z, yaw);
2024-05-12 01:14:14 +00:00
#else
2024-06-04 22:29:13 +00:00
float volume = args.next<float>();
float x = args.next<float>();
float y = args.next<float>();
float z = args.next<float>();
float yaw = args.next<float>();
2024-05-12 01:14:14 +00:00
func(volume, x, y, z, yaw);
2024-06-04 22:29:13 +00:00
return 0;
2024-05-12 01:14:14 +00:00
#endif
}
CALL(60, media_audio_play, void, (const char *source, const char *name, float x, float y, float z, float pitch, float volume, int is_ui))
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-06-04 22:29:13 +00:00
trampoline(copy_array(source), copy_array(name), x, y, z, pitch, volume, is_ui);
#else
const char *source = args.next_arr<char>();
const char *name = args.next_arr<char>();
float x = args.next<float>();
float y = args.next<float>();
float z = args.next<float>();
float pitch = args.next<float>();
float volume = args.next<float>();
int is_ui = args.next<int>();
2024-05-12 01:14:14 +00:00
func(source, name, x, y, z, pitch, volume, is_ui);
2024-06-04 22:29:13 +00:00
return 0;
2024-05-12 01:14:14 +00:00
#endif
}
CALL(62, media_set_interactable, void, (int is_interactable))
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-05-12 01:14:14 +00:00
trampoline(is_interactable);
#else
2024-06-04 22:29:13 +00:00
func(args.next<int>());
return 0;
2024-05-12 01:14:14 +00:00
#endif
}
CALL(63, media_disable_vsync, void, ())
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-05-12 01:14:14 +00:00
trampoline();
#else
func();
2024-06-04 22:29:13 +00:00
return 0;
2024-05-12 01:14:14 +00:00
#endif
}
CALL(64, media_set_raw_mouse_motion_enabled, void, (int enabled))
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-05-12 01:14:14 +00:00
trampoline(enabled);
#else
2024-06-04 22:29:13 +00:00
func(args.next<int>());
return 0;
2024-05-12 01:14:14 +00:00
#endif
}
CALL(66, media_force_egl, void, ())
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-05-12 01:14:14 +00:00
trampoline();
#else
func();
2024-06-04 22:29:13 +00:00
return 0;
2024-05-12 01:14:14 +00:00
#endif
}
CALL(68, media_ensure_loaded, void, ())
2024-05-12 07:19:01 +00:00
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
2024-05-12 01:14:14 +00:00
trampoline();
#else
func();
2024-06-04 22:29:13 +00:00
return 0;
2024-05-12 01:14:14 +00:00
#endif
}