Use clock_gettime

This commit is contained in:
TheBrokenRail 2020-11-07 22:26:22 -05:00
parent 21c67a2339
commit 55feb34251
5 changed files with 14 additions and 23 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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);
}

View File

@ -5,13 +5,11 @@
#include <stdint.h>
#include <dirent.h>
#include <libcore/libcore.h>
// 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;

10
mods/src/time.c Normal file
View File

@ -0,0 +1,10 @@
#include <sys/time.h>
#include <time.h>
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;
}