From 55feb34251f116aeb1fa7d681bfad7382e52061f Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Sat, 7 Nov 2020 22:26:22 -0500 Subject: [PATCH] Use clock_gettime --- core/src/stubs/bcm_host.c | 12 ------------ mods/CMakeLists.txt | 4 +++- mods/src/extra.c | 7 ------- mods/src/readdir.c | 4 +--- mods/src/time.c | 10 ++++++++++ 5 files changed, 14 insertions(+), 23 deletions(-) create mode 100644 mods/src/time.c diff --git a/core/src/stubs/bcm_host.c b/core/src/stubs/bcm_host.c index 9d4d735..2962d6e 100644 --- a/core/src/stubs/bcm_host.c +++ b/core/src/stubs/bcm_host.c @@ -10,18 +10,6 @@ int32_t graphics_get_display_size(__attribute__((unused)) const uint16_t display return -1; } -unsigned bcm_host_get_peripheral_address(void) { - return 0x20000000; -} - -unsigned bcm_host_get_peripheral_size(void) { - return 0x01000000; -} - -unsigned bcm_host_get_sdram_address(void) { - return 0x40000000; -} - uint32_t vc_dispmanx_display_open(__attribute__((unused)) uint32_t device) { return 0; } diff --git a/mods/CMakeLists.txt b/mods/CMakeLists.txt index 0b1d5f6..e81033c 100644 --- a/mods/CMakeLists.txt +++ b/mods/CMakeLists.txt @@ -27,4 +27,6 @@ target_link_libraries(compat core extra SDL GLESv1_CM GLESv2 X11 dl freeimage gl target_link_options(compat PRIVATE "-Wl,--no-as-needed") add_library(readdir SHARED src/readdir.c) -target_link_libraries(readdir core) + +add_library(time SHARED src/time.c) +target_link_libraries(time rt) diff --git a/mods/src/extra.c b/mods/src/extra.c index a5ae59b..8656856 100644 --- a/mods/src/extra.c +++ b/mods/src/extra.c @@ -176,10 +176,6 @@ int extra_get_mode() { } } -static int32_t Minecraft_getLicenseId_injection(__attribute__((unused)) unsigned char *minecraft) { - return 0; -} - __attribute__((constructor)) static void init() { is_server = extra_get_mode() == 2; if (is_server) { @@ -294,7 +290,4 @@ __attribute__((constructor)) static void init() { unsigned char outline_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; patch((void *) 0x4a214, outline_patch); } - - // Fix License - overwrite((void *) 0x16e8c, Minecraft_getLicenseId_injection); } diff --git a/mods/src/readdir.c b/mods/src/readdir.c index 79b033c..6052c03 100644 --- a/mods/src/readdir.c +++ b/mods/src/readdir.c @@ -5,13 +5,11 @@ #include #include -#include - // Minecraft: Pi Edition Was Not Compiled With 64-Bit Filesystem Support, So This Shims readdir() To Read Directories Properly #define FILENAME_SIZE 256 -HOOK(readdir, struct dirent *, (DIR *dirp)) { +struct dirent *readdir(DIR *dirp) { struct dirent64 *original = readdir64(dirp); if (original == NULL) { return NULL; diff --git a/mods/src/time.c b/mods/src/time.c new file mode 100644 index 0000000..d8fbbbd --- /dev/null +++ b/mods/src/time.c @@ -0,0 +1,10 @@ +#include +#include + +int gettimeofday(struct timeval *tv, __attribute__((unused)) void *tz) { + struct timespec tp; + int ret = clock_gettime(CLOCK_MONOTONIC, &tp); + tv->tv_sec = tp.tv_sec; + tv->tv_usec = tp.tv_nsec * 0.001; + return ret; +} \ No newline at end of file