Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to physfs-libretro #430

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,8 @@
url = https://github.com/grumbel/SDL_tty.git
ignore = dirty
branch = master
[submodule "vendor/physfs-libretro"]
path = vendor/physfs-libretro
url = https://github.com/RobLoach/physfs.git
ignore = dirty
branch = libretro-support
74 changes: 39 additions & 35 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ SOURCES_CXX := $(wildcard \
$(CORE_DIR)/src/love/Types/Graphics/*.cpp \
$(CORE_DIR)/src/love/Types/Input/*.cpp \
)
SOURCES_C = $(CORE_DIR)/src/physfs_platform_libretro.c
SOURCES_S =
FLAGS += -Wfatal-errors

Expand All @@ -20,34 +19,36 @@ FLAGS += -I$(CORE_DIR)/vendor/libretro-common/include \
-DHAVE_RWAV=1
# Only compile libretro-common when not STATIC_LINKING
ifneq ($(STATIC_LINKING), 1)
SOURCES_C += $(wildcard \
$(CORE_DIR)/vendor/libretro-common/audio/audio_mix.c \
$(CORE_DIR)/vendor/libretro-common/audio/audio_mixer.c \
$(CORE_DIR)/vendor/libretro-common/audio/conversion/*.c \
$(CORE_DIR)/vendor/libretro-common/audio/resampler/audio_resampler.c \
$(CORE_DIR)/vendor/libretro-common/audio/resampler/drivers/nearest_resampler.c \
$(CORE_DIR)/vendor/libretro-common/audio/resampler/drivers/null_resampler.c \
$(CORE_DIR)/vendor/libretro-common/audio/resampler/drivers/sinc_resampler.c \
$(CORE_DIR)/vendor/libretro-common/compat/compat_posix_string.c \
$(CORE_DIR)/vendor/libretro-common/compat/compat_strcasestr.c \
$(CORE_DIR)/vendor/libretro-common/compat/compat_strl.c \
$(CORE_DIR)/vendor/libretro-common/compat/fopen_utf8.c \
$(CORE_DIR)/vendor/libretro-common/encodings/encoding_utf.c \
$(CORE_DIR)/vendor/libretro-common/features/features_cpu.c \
$(CORE_DIR)/vendor/libretro-common/file/config_file.c \
$(CORE_DIR)/vendor/libretro-common/file/config_file_userdata.c \
$(CORE_DIR)/vendor/libretro-common/file/file_path.c \
$(CORE_DIR)/vendor/libretro-common/file/file_path_io.c \
$(CORE_DIR)/vendor/libretro-common/file/retro_dirent.c \
$(CORE_DIR)/vendor/libretro-common/time/rtime.c \
$(CORE_DIR)/vendor/libretro-common/formats/wav/rwav.c \
$(CORE_DIR)/vendor/libretro-common/lists/string_list.c \
$(CORE_DIR)/vendor/libretro-common/memmap/memalign.c \
$(CORE_DIR)/vendor/libretro-common/rthreads/rthreads.c \
$(CORE_DIR)/vendor/libretro-common/streams/file_stream.c \
$(CORE_DIR)/vendor/libretro-common/string/stdstring.c \
$(CORE_DIR)/vendor/libretro-common/vfs/vfs_implementation.c \
)
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/audio/audio_mix.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/audio/audio_mixer.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/audio/conversion/float_to_s16.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/audio/conversion/float_to_s16_neon.c
#SOURCES_C += $(CORE_DIR)/vendor/libretro-common/audio/conversion/mono_to_stereo_float.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/audio/conversion/s16_to_float.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/audio/conversion/s16_to_float_neon.c
#SOURCES_C += $(CORE_DIR)/vendor/libretro-common/audio/conversion/stereo_to_mono_float.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/audio/resampler/audio_resampler.c
#SOURCES_C += $(CORE_DIR)/vendor/libretro-common/audio/resampler/drivers/nearest_resampler.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/audio/resampler/drivers/sinc_resampler.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/compat/compat_posix_string.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/compat/compat_strcasestr.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/compat/compat_strl.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/file/config_file.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/file/config_file_userdata.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/file/file_path.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/file/file_path_io.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/features/features_cpu.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/encodings/encoding_utf.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/formats/wav/rwav.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/lists/string_list.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/memmap/memalign.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/streams/file_stream.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/rthreads/rthreads.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/string/stdstring.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/time/rtime.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/vfs/vfs_implementation.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/compat/fopen_utf8.c

# Ensure the sinc_resampler_neon is available for ARM NEON devices.
SOURCES_S += $(CORE_DIR)/vendor/libretro-common/audio/resampler/drivers/sinc_resampler_neon.S

Expand Down Expand Up @@ -91,21 +92,24 @@ FLAGS += -I$(CORE_DIR)/vendor/libretro-common/compat
FLAGS += -DWANT_ZLIB

# PhysFS
FLAGS += -I$(CORE_DIR)/vendor/physfs/src
FLAGS += -I$(CORE_DIR)/vendor/physfs/extras
PHYSFS_DIR = $(CORE_DIR)/vendor/physfs-libretro
FLAGS += -I$(PHYSFS_DIR)/src
FLAGS += -I$(PHYSFS_DIR)/extras
FLAGS += -DPHYSFS_NO_CDROM_SUPPORT=1 \
-DPHYSFS_SUPPORTS_DEFAULT=0 \
-DPHYSFS_SUPPORTS_ZIP=1
-DPHYSFS_SUPPORTS_ZIP=1 \
-DPHYSFS_PLATFORM_LIBRETRO

SOURCES_C += $(wildcard \
$(CORE_DIR)/vendor/physfs/extras/physfsrwops.c \
$(CORE_DIR)/vendor/physfs/src/*.c \
$(PHYSFS_DIR)/extras/physfsrwops.c \
$(PHYSFS_DIR)/src/*.c \
)
ifeq ($(platform), osx)
# LDFLAGS += -mmacosx-version-min=10.2
LDFLAGS += -framework IOKit -framework Foundation
# FLAGS += -DMAC_OS_X_VERSION_MIN_REQUIRED=1020
FLAGS += -D__MACH__ -D__APPLE__ -DPHYSFS_PLATFORM_APPLE
# FLAGS += -D__MACH__ -D__APPLE__ -DPHYSFS_PLATFORM_APPLE
FLAGS += -D__MACH__ -D__APPLE__
endif

# SDL_tty
Expand Down
27 changes: 0 additions & 27 deletions src/libretro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#define __STDC_FORMAT_MACROS
#include "ChaiLove.h"
#include "LibretroLog.h"
#include <retro_dirent.h>
#include <streams/file_stream.h>

static void fallback_log(enum retro_log_level level,
const char *fmt, ...);
Expand All @@ -19,8 +17,6 @@ retro_log_printf_t log_cb = fallback_log;
// This is needed to allow SDL-libretro to compile.
// @see SDL_LIBRETROaudio.c:37
retro_audio_sample_t audio_cb;
char *home_directory;
struct retro_vfs_interface *vfs_interface;

void retro_set_video_refresh(retro_video_refresh_t cb) {
video_cb = cb;
Expand Down Expand Up @@ -86,15 +82,6 @@ void retro_set_environment(retro_environment_t cb) {
// Configure the core options.
libretro_set_core_options(cb);

struct retro_vfs_interface_info vfs_interface_info;
vfs_interface_info.required_interface_version = DIRENT_REQUIRED_VFS_VERSION;
vfs_interface_info.iface = NULL;
if (cb(RETRO_ENVIRONMENT_GET_VFS_INTERFACE, &vfs_interface_info)) {
vfs_interface = vfs_interface_info.iface;
filestream_vfs_init(&vfs_interface_info);
dirent_vfs_init(&vfs_interface_info);
}

struct retro_log_callback log;

if (cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log)) {
Expand Down Expand Up @@ -440,20 +427,6 @@ void retro_init(void) {
if (!ChaiLove::environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) {
LibretroLog::log(RETRO_LOG_INFO) << "[ChaiLove] Pixel format XRGB8888 not supported by platform, cannot use." << std::endl;
}

const char *content_dir = NULL;

ChaiLove::environ_cb(RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY, &content_dir);

if (!home_directory && !content_dir)
content_dir = "/";

if (content_dir) {
size_t l = strlen(content_dir);
home_directory = (char *) malloc(l + 1);
if (home_directory)
memcpy(home_directory, content_dir, l + 1);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/love/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "Types/Audio/SoundData.h"
#include "../ChaiLove.h"
#include "sound.h"
#include "audio/conversion/float_to_s16.h"
//#include "audio/conversion/float_to_s16.h"

using love::Types::Audio::SoundData;

Expand Down
2 changes: 1 addition & 1 deletion src/love/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace love {
bool filesystem::init(const std::string& file, const void* data) {
// Initialize PhysFS
if (PHYSFS_isInit() == 0) {
if (PHYSFS_init(NULL) == 0) {
if (PHYSFS_init((const char*)ChaiLove::getInstance()->environ_cb) == 0) {
LibretroLog::log(RETRO_LOG_ERROR) << "[ChaiLove] [filesystem] Error loading PhysFS - " << getLastError() << std::endl;
return false;
}
Expand Down
Loading
Loading