1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-10 23:24:06 +02:00

#15 NX custom directory support, relative time from game starts

This commit is contained in:
XProger
2019-01-13 03:46:21 +03:00
parent 641afa6517
commit 04e6bf198d
2 changed files with 35 additions and 12 deletions

View File

@@ -46,15 +46,15 @@ APP_VERSION := 1.0
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -mcpu=cortex-a57+crc+fp+simd
CFLAGS := -g -O -ffast-math -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections \
CFLAGS := -O3 -ffast-math -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections \
$(ARCH) $(DEFINES)
CFLAGS += $(INCLUDE) -D__SWITCH__
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
ASFLAGS := $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lEGL -lGLESv2 -lglapi -ldrm_nouveau -lnx -lm

View File

@@ -25,11 +25,11 @@ void osMutexUnlock(void *obj) {
}
// timing
unsigned int startTime;
u64 startTick;
int osGetTime() {
u64 tick = armGetSystemTick();
return (tick * 625 / 12) / 1000000;
return int(((tick - startTick) * 625 / 12) / 1000000);
}
// sound
@@ -286,6 +286,34 @@ void touchUpdate() {
}
}
void makeCacheDir(char *elfPath) {
char buf[255];
int len = strlen(elfPath);
int start = 0;
strcpy(buf, elfPath);
// skip volume id
for (int i = 0; i < len; i++) {
if (buf[i] == ':') {
start = i + 1;
break;
}
}
// skip executable name
for (int i = len - 1; i >= 0; i--) {
if (buf[i] == '/') {
buf[i] = 0;
break;
}
}
// make directory by full path
strcpy(cacheDir, buf + start);
strcat(cacheDir, "/cache/");
fsFsCreateDirectory(fsdevGetDefaultFileSystem(), cacheDir);
}
int main(int argc, char* argv[]) {
Core::width = 1280;
Core::height = 720;
@@ -296,14 +324,9 @@ int main(int argc, char* argv[]) {
}
cacheDir[0] = saveDir[0] = contentDir[0] = 0;
makeCacheDir(argv[0]);
strcat(contentDir, "/switch/OpenLara/");
strcat(cacheDir, "/switch/OpenLara/cache/");
strcat(saveDir, "/switch/OpenLara/");
fsFsCreateDirectory(fsdevGetDefaultFileSystem(), cacheDir);
startTime = osGetTime();
startTick = armGetSystemTick();
sndInit();
joyInit();