minecraft-pi-reborn/mods/src/compat/egl.cpp

41 lines
2.1 KiB
C++
Raw Normal View History

2021-06-17 21:32:24 +00:00
#include <EGL/egl.h>
#include <libreborn/libreborn.h>
2021-09-12 03:18:12 +00:00
#include <media-layer/core.h>
2024-02-12 05:44:38 +00:00
#include "compat-internal.h"
2021-06-17 21:32:24 +00:00
// Functions That Have Their Return Values Used
2021-06-19 23:07:09 +00:00
static EGLSurface eglCreateWindowSurface_injection(__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLConfig config, __attribute__((unused)) NativeWindowType native_window, __attribute__((unused)) EGLint const *attrib_list) {
2024-04-02 23:22:01 +00:00
return nullptr;
2021-06-17 21:32:24 +00:00
}
2021-06-19 23:07:09 +00:00
static EGLDisplay eglGetDisplay_injection(__attribute__((unused)) NativeDisplayType native_display) {
2024-04-02 23:22:01 +00:00
return nullptr;
2021-06-17 21:32:24 +00:00
}
2021-06-19 23:07:09 +00:00
static EGLContext eglCreateContext_injection(__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLConfig config, __attribute__((unused)) EGLContext share_context, __attribute__((unused)) EGLint const *attrib_list) {
2024-04-02 23:22:01 +00:00
return nullptr;
2021-06-17 21:32:24 +00:00
}
// Call media_swap_buffers()
2021-06-19 23:07:09 +00:00
static EGLBoolean eglSwapBuffers_injection(__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLSurface surface) {
2021-06-17 21:32:24 +00:00
media_swap_buffers();
return EGL_TRUE;
}
// Patch EGL Calls
2024-02-12 05:44:38 +00:00
void _patch_egl_calls() {
2021-06-17 21:32:24 +00:00
// Disable EGL Calls
unsigned char nop_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop"
patch((void *) 0x1250c, nop_patch); // eglTerminate
patch((void *) 0x12580, nop_patch); // eglBindAPI
2021-06-19 23:07:09 +00:00
overwrite_call((void *) 0x12638, (void *) eglCreateWindowSurface_injection); // eglCreateWindowSurface
2021-06-17 21:32:24 +00:00
patch((void *) 0x12578, nop_patch); // eglChooseConfig
patch((void *) 0x1255c, nop_patch); // eglInitialize
patch((void *) 0x124f0, nop_patch); // eglMakeCurrent #1
patch((void *) 0x12654, nop_patch); // eglMakeCurrent #2
2021-06-19 23:07:09 +00:00
overwrite_call((void *) 0x124dc, (void *) eglSwapBuffers_injection); // eglSwapBuffers #1
overwrite_call((void *) 0x14b6c, (void *) eglSwapBuffers_injection); // eglSwapBuffers #2
overwrite_call((void *) 0x1254c, (void *) eglGetDisplay_injection); // eglGetDisplay
2021-06-17 21:32:24 +00:00
patch((void *) 0x124fc, nop_patch); // eglDestroySurface #1
patch((void *) 0x12504, nop_patch); // eglDestroySurface #2
2021-06-19 23:07:09 +00:00
overwrite_call((void *) 0x12594, (void *) eglCreateContext_injection); // eglCreateContext
2021-06-17 21:32:24 +00:00
}