Add file loading

This commit is contained in:
Rob Loach 2017-06-27 03:08:06 -04:00
parent 39c71abe0a
commit 3b20002ac2
No known key found for this signature in database
GPG Key ID: 627C60834A74A21A
5 changed files with 21 additions and 5 deletions

View File

@ -31,7 +31,7 @@ void Application::quit(void) {
SDL_Quit();
}
bool Application::load(std::string file = "main.chai") {
bool Application::load(std::string file = "") {
// Initialize SDL.
if (SDL_Init(SDL_INIT_EVERYTHING) == -1) {
return false;

View File

@ -29,7 +29,7 @@ ifeq ($(platform), unix)
else ifneq (,$(findstring android,$(platform)))
TARGET := $(TARGET_NAME)_libretro_android.so
fpic = -fPIC
SHARED := -lstdc++ -llog -lz -shared -Wl,--version-script=link.T -Wl,--no-undefined
SHARED := -lstdc++ -lstd++fs -llog -lz -shared -Wl,--version-script=link.T -Wl,--no-undefined
CFLAGS += -g -O2
CC = arm-linux-androideabi-gcc
CXX = arm-linux-androideabi-g++
@ -40,7 +40,7 @@ else ifeq ($(platform), wincross64)
CC = x86_64-w64-mingw32-gcc
CXX = x86_64-w64-mingw32-g++
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
LDFLAGS += -static-libgcc -static-libstdc++
LDFLAGS += -static-libgcc -static-libstdc++ -lstd++fs
ENDIANNESS_DEFINES := -DLSB_FIRST
FLAGS +=
EXTRA_LDF := -lwinmm -Wl,--export-all-symbols
@ -50,7 +50,7 @@ else
CC = gcc
CXX = g++
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
LDFLAGS += -static-libgcc -static-libstdc++
LDFLAGS += -static-libgcc -static-libstdc++ -lstd++fs
ENDIANNESS_DEFINES := -DLSB_FIRST
FLAGS +=
EXTRA_LDF = -lwinmm -Wl,--export-all-symbols

View File

@ -6,8 +6,22 @@
#include "../Application.h"
namespace chaigame {
bool filesystem::load() {
std::string file = "";
return load(file);
}
bool filesystem::load(std::string file) {
PHYSFS_init(NULL);
if (file.empty()) {
PHYSFS_mount("", NULL, 1);
}
else {
PHYSFS_mount(file.c_str(), NULL, 1);
// TODO: Mount the file's base directory.
}
}
bool filesystem::unload() {
PHYSFS_deinit();

View File

@ -8,6 +8,7 @@ namespace chaigame {
class filesystem {
public:
bool load(std::string file);
bool load();
bool unload();
};
}

View File

@ -81,6 +81,7 @@ void retro_get_system_info(struct retro_system_info *info) {
info->library_version = "0.0.2";
info->need_fullpath = false;
info->valid_extensions = "chai";
info->block_extract = true;
}
void retro_get_system_av_info(struct retro_system_av_info *info) {
@ -128,7 +129,7 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code) {
}
bool retro_load_game(const struct retro_game_info *info) {
std::string full = info ? info->path : "main.chai";
std::string full = info ? info->path : ".";
printf("LOAD FILE: %s\n", full.c_str());
return Application::getInstance()->load(full);
}