Skip to content

Commit de5216c

Browse files
committed
Implement loading from encrypted game archives in libretro builds
1 parent 4433296 commit de5216c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

binding-sandbox/wasm-rt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#define WASM_PAGE_SIZE ((uint64_t)65536U)
2929

30-
#define WASM_MIN_PAGES ((uint32_t)1280U)
30+
#define WASM_MIN_PAGES ((uint32_t)2048U)
3131

3232
extern "C" bool wasm_rt_is_initialized(void) {
3333
return true;

src/core.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ static LPALCLOOPBACKOPENDEVICESOFT alcLoopbackOpenDeviceSOFT = NULL;
8686
static int16_t *sound_buf;
8787
static bool retro_framebuffer_supported;
8888
static bool shared_state_initialized;
89+
static PHYSFS_File *rgssad = NULL;
8990

9091
static void fallback_log(enum retro_log_level level, const char *fmt, ...) {
9192
std::va_list va;
@@ -169,6 +170,10 @@ static void deinit_sandbox() {
169170
alcCloseDevice(al_device);
170171
al_device = NULL;
171172
}
173+
if (rgssad != NULL) {
174+
PHYSFS_close(rgssad);
175+
rgssad = NULL;
176+
}
172177
fs.reset();
173178
input.reset();
174179
}
@@ -204,6 +209,15 @@ static bool init_sandbox() {
204209
}
205210

206211
fs->addPath(parsed_game_path.c_str(), "/mkxp-retro-game");
212+
213+
// TODO: use execName from config instead of hardcoding "Game" as the filename
214+
if ((rgssad = PHYSFS_openRead("/mkxp-retro-game/Game.rgssad")) != NULL) {
215+
PHYSFS_mountHandle(rgssad, "Game.rgssad", "/mkxp-retro-game", 1);
216+
} else if ((rgssad = PHYSFS_openRead("/mkxp-retro-game/Game.rgss2a")) != NULL) {
217+
PHYSFS_mountHandle(rgssad, "Game.rgss2a", "/mkxp-retro-game", 1);
218+
} else if ((rgssad = PHYSFS_openRead("/mkxp-retro-game/Game.rgss3a")) != NULL) {
219+
PHYSFS_mountHandle(rgssad, "Game.rgss3a", "/mkxp-retro-game", 1);
220+
}
207221
}
208222

209223
fs->createPathCache();

0 commit comments

Comments
 (0)