mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-09 11:41:35 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28c7ae5007 | ||
|
|
0a613c04a6 | ||
|
|
f12092a09f | ||
|
|
21aa1cdbe6 | ||
|
|
5e18a5513c | ||
|
|
1188650a3f | ||
|
|
f64a01c5d4 | ||
|
|
42e803435f | ||
|
|
5e1486d92a | ||
|
|
f03a0cedca | ||
|
|
75a134a578 | ||
|
|
a9b9435e0b | ||
|
|
b674457671 | ||
|
|
7752c73abc |
No files matched your search
@@ -1,6 +1,3 @@
|
||||
[submodule "deps/glslang/glslang"]
|
||||
path = deps/glslang/glslang
|
||||
url = git://github.com/KhronosGroup/glslang.git
|
||||
[submodule "deps/SPIRV-Cross"]
|
||||
path = deps/SPIRV-Cross
|
||||
url = git://github.com/KhronosGroup/SPIRV-Cross
|
||||
@@ -1,5 +1,4 @@
|
||||
HAVE_FILE_LOGGER=1
|
||||
NEED_CXX_LINKER=0
|
||||
MISSING_DECLS =0
|
||||
|
||||
ifneq ($(C90_BUILD),)
|
||||
@@ -34,7 +33,7 @@ endif
|
||||
HEADERS = $(wildcard */*/*.h) $(wildcard */*.h) $(wildcard *.h)
|
||||
|
||||
ifeq ($(MISSING_DECLS), 1)
|
||||
DEFINES += -Werror=missing-declarations
|
||||
DEFINES += -Werror=missing-declarations
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_DYLIB), 1)
|
||||
@@ -55,9 +54,9 @@ ifeq ($(DEBUG), 1)
|
||||
OPTIMIZE_FLAG = -O0 -g
|
||||
else
|
||||
OPTIMIZE_FLAG = -O3 -ffast-math
|
||||
ifneq ($(findstring Win32,$(OS)),)
|
||||
LDFLAGS += -mwindows
|
||||
endif
|
||||
ifneq ($(findstring Win32,$(OS)),)
|
||||
LDFLAGS += -mwindows
|
||||
endif
|
||||
endif
|
||||
|
||||
CFLAGS += -Wall $(OPTIMIZE_FLAG) $(INCLUDE_DIRS) $(DEBUG_FLAG) -I.
|
||||
@@ -68,13 +67,9 @@ OBJCFLAGS := $(CFLAGS) -D__STDC_CONSTANT_MACROS
|
||||
|
||||
ifeq ($(CXX_BUILD), 1)
|
||||
LINK = $(CXX)
|
||||
CFLAGS := $(CXXFLAGS) -xc++
|
||||
CFLAGS += -DCXX_BUILD
|
||||
CXXFLAGS += -DCXX_BUILD
|
||||
CFLAGS := $(CXXFLAGS) -xc++
|
||||
else
|
||||
ifeq ($(NEED_CXX_LINKER),1)
|
||||
LINK = $(CXX)
|
||||
else ifeq ($(findstring Win32,$(OS)),)
|
||||
ifeq ($(findstring Win32,$(OS)),)
|
||||
LINK = $(CC)
|
||||
else
|
||||
# directx-related code is c++
|
||||
@@ -120,14 +115,10 @@ endif
|
||||
|
||||
all: $(TARGET) config.mk
|
||||
|
||||
ifeq ($(MAKECMDGOALS),clean)
|
||||
config.mk:
|
||||
else
|
||||
-include $(RARCH_OBJ:.o=.d)
|
||||
config.mk: configure qb/*
|
||||
@echo "config.mk is outdated or non-existing. Run ./configure again."
|
||||
@exit 1
|
||||
endif
|
||||
|
||||
retroarch: $(RARCH_OBJ)
|
||||
@$(if $(Q), $(shell echo echo LD $@),)
|
||||
@@ -170,14 +161,14 @@ install: $(TARGET)
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/bin 2>/dev/null || /bin/true
|
||||
mkdir -p $(DESTDIR)$(GLOBAL_CONFIG_DIR) 2>/dev/null || /bin/true
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/share/applications 2>/dev/null || /bin/true
|
||||
mkdir -p $(DESTDIR)$(MAN_DIR)/man6 2>/dev/null || /bin/true
|
||||
mkdir -p $(DESTDIR)$(MAN_DIR) 2>/dev/null || /bin/true
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/share/pixmaps 2>/dev/null || /bin/true
|
||||
install -m755 $(TARGET) $(DESTDIR)$(PREFIX)/bin
|
||||
install -m755 tools/cg2glsl.py $(DESTDIR)$(PREFIX)/bin/retroarch-cg2glsl
|
||||
install -m644 retroarch.cfg $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg
|
||||
install -m644 retroarch.desktop $(DESTDIR)$(PREFIX)/share/applications
|
||||
install -m644 docs/retroarch.6 $(DESTDIR)$(MAN_DIR)/man6
|
||||
install -m644 docs/retroarch-cg2glsl.6 $(DESTDIR)$(MAN_DIR)/man6
|
||||
install -m644 docs/retroarch.1 $(DESTDIR)$(MAN_DIR)
|
||||
install -m644 docs/retroarch-cg2glsl.1 $(DESTDIR)$(MAN_DIR)
|
||||
install -m644 media/retroarch.svg $(DESTDIR)$(PREFIX)/share/pixmaps
|
||||
|
||||
uninstall:
|
||||
@@ -185,8 +176,8 @@ uninstall:
|
||||
rm -f $(DESTDIR)$(PREFIX)/bin/retroarch-cg2glsl
|
||||
rm -f $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg
|
||||
rm -f $(DESTDIR)$(PREFIX)/share/applications/retroarch.desktop
|
||||
rm -f $(DESTDIR)$(MAN_DIR)/man6/retroarch.6
|
||||
rm -f $(DESTDIR)$(MAN_DIR)/man6/retroarch-cg2glsl.6
|
||||
rm -f $(DESTDIR)$(MAN_DIR)/retroarch.1
|
||||
rm -f $(DESTDIR)$(MAN_DIR)/retroarch-cg2glsl.1
|
||||
rm -f $(DESTDIR)$(PREFIX)/share/pixmaps/retroarch.svg
|
||||
|
||||
clean:
|
||||
|
||||
+131
-238
@@ -18,10 +18,6 @@ ifeq ($(HAVE_LIBRETRODB),)
|
||||
HAVE_LIBRETRODB = 1
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_HID), 1)
|
||||
DEFINES += -DHAVE_HID
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_LIBRETRODB), 1)
|
||||
DEFINES += -DHAVE_LIBRETRODB
|
||||
endif
|
||||
@@ -48,11 +44,6 @@ ifeq ($(GL_DEBUG), 1)
|
||||
CXXFLAGS += -DGL_DEBUG
|
||||
endif
|
||||
|
||||
ifeq ($(VULKAN_DEBUG), 1)
|
||||
CFLAGS += -DVULKAN_DEBUG
|
||||
CXXFLAGS += -DVULKAN_DEBUG
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_HARD_FLOAT), 1)
|
||||
DEFINES += -mfloat-abi=hard
|
||||
endif
|
||||
@@ -65,10 +56,6 @@ ifeq ($(HAVE_FILE_LOGGER), 1)
|
||||
CFLAGS += -DHAVE_FILE_LOGGER
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_SHADERPIPELINE), 1)
|
||||
CFLAGS += -DHAVE_SHADERPIPELINE
|
||||
endif
|
||||
|
||||
CFLAGS += -I./libretro-common/include
|
||||
|
||||
# Switches
|
||||
@@ -78,7 +65,6 @@ CFLAGS += -I./libretro-common/include
|
||||
|
||||
ifneq ($(findstring BSD,$(OS)),)
|
||||
BSD_LOCAL_INC += -I/usr/local/include
|
||||
OBJ += frontend/drivers/platform_bsd.o
|
||||
endif
|
||||
|
||||
ifneq ($(findstring Darwin,$(OS)),)
|
||||
@@ -122,43 +108,44 @@ OBJ += frontend/frontend.o \
|
||||
frontend/drivers/platform_null.o \
|
||||
ui/ui_companion_driver.o \
|
||||
ui/drivers/ui_null.o \
|
||||
ui/drivers/null/ui_null_window.o \
|
||||
ui/drivers/null/ui_null_browser_window.o \
|
||||
ui/drivers/null/ui_null_msg_window.o \
|
||||
ui/drivers/null/ui_null_application.o \
|
||||
core_impl.o \
|
||||
libretro_version_1.o \
|
||||
retroarch.o \
|
||||
input/input_keyboard.o \
|
||||
command.o \
|
||||
command_event.o \
|
||||
msg_hash.o \
|
||||
intl/msg_hash_de.o \
|
||||
intl/msg_hash_eo.o \
|
||||
intl/msg_hash_es.o \
|
||||
intl/msg_hash_fr.o \
|
||||
intl/msg_hash_it.o \
|
||||
intl/msg_hash_nl.o \
|
||||
intl/msg_hash_pl.o \
|
||||
intl/msg_hash_pt.o \
|
||||
intl/msg_hash_us.o \
|
||||
runloop.o \
|
||||
libretro-common/algorithms/mismatch.o \
|
||||
libretro-common/queues/task_queue.o \
|
||||
tasks/tasks_internal.o \
|
||||
tasks/task_content.o \
|
||||
tasks/task_save_ram.o \
|
||||
tasks/task_save_state.o \
|
||||
tasks/task_file_transfer.o \
|
||||
tasks/task_image.o \
|
||||
content.o \
|
||||
libretro-common/encodings/encoding_utf.o \
|
||||
libretro-common/lists/file_list.o \
|
||||
libretro-common/lists/dir_list.o \
|
||||
libretro-common/file/file_list.o \
|
||||
libretro-common/file/dir_list.o \
|
||||
libretro-common/file/retro_dirent.o \
|
||||
libretro-common/streams/file_stream.o \
|
||||
libretro-common/streams/interface_stream.o \
|
||||
libretro-common/streams/memory_stream.o \
|
||||
libretro-common/file/retro_file.o \
|
||||
libretro-common/file/retro_stat.o \
|
||||
libretro-common/lists/string_list.o \
|
||||
libretro-common/string/string_list.o \
|
||||
libretro-common/string/stdstring.o \
|
||||
libretro-common/memmap/memalign.o \
|
||||
list_special.o \
|
||||
dir_list_special.o \
|
||||
string_list_special.o \
|
||||
libretro-common/file/nbio/nbio_stdio.o \
|
||||
libretro-common/file/file_path.o \
|
||||
file_path_special.o \
|
||||
file_path_str.o \
|
||||
libretro-common/hash/rhash.o \
|
||||
audio/audio_driver.o \
|
||||
input/input_driver.o \
|
||||
input/input_hid_driver.o \
|
||||
gfx/video_coord_array.o \
|
||||
gfx/video_driver.o \
|
||||
camera/camera_driver.o \
|
||||
@@ -169,7 +156,7 @@ OBJ += frontend/frontend.o \
|
||||
dynamic.o \
|
||||
cores/dynamic_dummy.o \
|
||||
libretro-common/queues/message_queue.o \
|
||||
managers/state_manager.o \
|
||||
rewind.o \
|
||||
gfx/drivers_font_renderer/bitmapfont.o \
|
||||
input/input_autodetect.o \
|
||||
input/input_joypad_driver.o \
|
||||
@@ -179,15 +166,15 @@ OBJ += frontend/frontend.o \
|
||||
tasks/task_overlay.o \
|
||||
input/input_overlay.o \
|
||||
patch.o \
|
||||
libretro-common/queues/fifo_queue.o \
|
||||
managers/core_option_manager.o \
|
||||
libretro-common/queues/fifo_buffer.o \
|
||||
core_options.o \
|
||||
libretro-common/compat/compat_fnmatch.o \
|
||||
libretro-common/compat/compat_posix_string.o \
|
||||
managers/cheat_manager.o \
|
||||
cheats.o \
|
||||
core_info.o \
|
||||
libretro-common/file/config_file.o \
|
||||
config_file_userdata.o \
|
||||
tasks/task_screenshot.o \
|
||||
libretro-common/file/config_file_userdata.o \
|
||||
screenshot.o \
|
||||
libretro-common/gfx/scaler/scaler.o \
|
||||
gfx/drivers_shader/shader_null.o \
|
||||
gfx/video_shader_driver.o \
|
||||
@@ -210,27 +197,14 @@ OBJ += frontend/frontend.o \
|
||||
input/drivers/nullinput.o \
|
||||
input/drivers_hid/null_hid.o \
|
||||
input/drivers_joypad/null_joypad.o \
|
||||
input/drivers_joypad/hid_joypad.o \
|
||||
playlist.o \
|
||||
movie.o \
|
||||
record/record_driver.o \
|
||||
record/drivers/record_null.o \
|
||||
libretro-common/features/features_cpu.o \
|
||||
performance_counters.o \
|
||||
performance.o \
|
||||
verbosity.o
|
||||
|
||||
ifeq ($(HAVE_LANGEXTRA), 1)
|
||||
DEFINES += -DHAVE_LANGEXTRA
|
||||
OBJ += intl/msg_hash_de.o \
|
||||
intl/msg_hash_eo.o \
|
||||
intl/msg_hash_es.o \
|
||||
intl/msg_hash_fr.o \
|
||||
intl/msg_hash_it.o \
|
||||
intl/msg_hash_nl.o \
|
||||
intl/msg_hash_pl.o \
|
||||
intl/msg_hash_pt.o
|
||||
|
||||
endif
|
||||
|
||||
ifneq ($(HAVE_GETOPT_LONG), 1)
|
||||
OBJ += libretro-common/compat/compat_getopt.o
|
||||
endif
|
||||
@@ -243,7 +217,7 @@ ifneq ($(HAVE_STRL), 1)
|
||||
OBJ += libretro-common/compat/compat_strl.o
|
||||
endif
|
||||
|
||||
OBJ += libretro-common/formats/image_texture.o
|
||||
OBJ += gfx/video_texture_image.o
|
||||
|
||||
ifeq ($(HAVE_IMAGEVIEWER), 1)
|
||||
DEFINES += -DHAVE_IMAGEVIEWER
|
||||
@@ -253,23 +227,9 @@ endif
|
||||
# Qt
|
||||
|
||||
ifeq ($(HAVE_QT), 1)
|
||||
HAVE_QT_WRAPPER=0
|
||||
OBJ += ui/drivers/ui_qt.o \
|
||||
ui/drivers/qt/ui_qt_application.o \
|
||||
ui/drivers/qt/ui_qt_window.o \
|
||||
ui/drivers/qt/ui_qt_browser_window.o \
|
||||
ui/drivers/qt/ui_qt_msg_window.o
|
||||
|
||||
ifneq ($(findstring Linux,$(OS)),)
|
||||
DEFINES += -I/usr/include/qt -fPIC
|
||||
endif
|
||||
|
||||
OBJ += ui/drivers/ui_qt.o
|
||||
# TODO/FIXME - figure out which libraries we need to link against
|
||||
LIBS += -lQt5Quick -lQt5Widgets -lQt5Gui -lQt5Qml -lQt5Network -lQt5Core -L./ui/drivers/qt/wrapper/build/release
|
||||
|
||||
ifeq ($(HAVE_QT_WRAPPER), 1)
|
||||
LIBS += -lwrapper
|
||||
endif
|
||||
LIBS += -lQt5Quick -lQt5Widgets -lQt5Gui -lQt5Qml -lQt5Network -lQt5Core -lglu32 -lopengl32 -L./ui/drivers/qt/wrapper/build/release -lwrapper
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_SSA),1)
|
||||
@@ -328,11 +288,8 @@ ifeq ($(HAVE_OSS_BSD), 1)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_ALSA), 1)
|
||||
OBJ += audio/drivers/alsa.o
|
||||
|
||||
ifeq ($(HAVE_THREADS), 1)
|
||||
OBJ += audio/drivers/alsathread.o
|
||||
endif
|
||||
OBJ += audio/drivers/alsa.o \
|
||||
audio/drivers/alsathread.o
|
||||
LIBS += $(ALSA_LIBS)
|
||||
DEFINES += $(ALSA_CFLAGS)
|
||||
endif
|
||||
@@ -405,26 +362,19 @@ ifeq ($(HAVE_NEON),1)
|
||||
DEFINES += -DSINC_LOWER_QUALITY
|
||||
endif
|
||||
|
||||
OBJ += libretro-common/conversion/s16_to_float.o \
|
||||
libretro-common/conversion/float_to_s16.o
|
||||
OBJ += audio/audio_utils.o
|
||||
ifeq ($(HAVE_NEON),1)
|
||||
OBJ += libretro-common/conversion/s16_to_float_neon.o \
|
||||
libretro-common/conversion/float_to_s16_neon.o
|
||||
endif
|
||||
|
||||
ifneq ($(findstring Win32,$(OS)),)
|
||||
HAVE_VULKAN=1
|
||||
DEFINES += -DHAVE_VULKAN
|
||||
OBJ += audio/audio_utils_neon.o
|
||||
endif
|
||||
|
||||
HW_CONTEXT_MENU_DRIVERS=$(HAVE_RGUI)
|
||||
|
||||
ifeq ($(HW_CONTEXT_MENU_DRIVERS),0)
|
||||
ifeq ($(HAVE_GL_CONTEXT),1)
|
||||
HW_CONTEXT_MENU_DRIVERS=1
|
||||
HW_CONTEXT_MENU_DRIVERS=1
|
||||
endif
|
||||
ifeq ($(HAVE_VULKAN),1)
|
||||
HW_CONTEXT_MENU_DRIVERS=1
|
||||
HW_CONTEXT_MENU_DRIVERS=1
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -438,8 +388,8 @@ ifeq ($(HW_CONTEXT_MENU_DRIVERS), 1)
|
||||
HAVE_MATERIALUI = 1
|
||||
endif
|
||||
|
||||
#ifeq ($(HAVE_NUKLEAR),)
|
||||
#HAVE_NUKLEAR = 1
|
||||
#ifeq ($(HAVE_ZAHNRAD),)
|
||||
#HAVE_ZAHNRAD = 1
|
||||
#endif
|
||||
|
||||
ifeq ($(HAVE_XMB),)
|
||||
@@ -448,7 +398,7 @@ ifeq ($(HW_CONTEXT_MENU_DRIVERS), 1)
|
||||
else
|
||||
HAVE_ZARCH = 0
|
||||
HAVE_MATERIALUI = 0
|
||||
#HAVE_NUKLEAR = 0
|
||||
#HAVE_ZAHNRAD = 0
|
||||
HAVE_XMB = 0
|
||||
endif
|
||||
|
||||
@@ -460,15 +410,12 @@ ifeq ($(HAVE_MATERIALUI), 1)
|
||||
OBJ += menu/drivers/materialui.o
|
||||
DEFINES += -DHAVE_MATERIALUI
|
||||
endif
|
||||
ifeq ($(HAVE_NUKLEAR), 1)
|
||||
OBJ += menu/drivers/nuklear/nk_common.o
|
||||
OBJ += menu/drivers/nuklear/nk_menu.o
|
||||
OBJ += menu/drivers/nuklear/nk_wnd_main.o
|
||||
OBJ += menu/drivers/nuklear/nk_wnd_file_picker.o
|
||||
OBJ += menu/drivers/nuklear/nk_wnd_shader_parameters.o
|
||||
OBJ += menu/drivers/nuklear/nk_wnd_settings.o
|
||||
OBJ += menu/drivers/nuklear.o
|
||||
DEFINES += -DHAVE_NUKLEAR
|
||||
ifeq ($(HAVE_ZAHNRAD), 1)
|
||||
OBJ += deps/zahnrad/zahnrad.o
|
||||
OBJ += menu/drivers/zr_common.o
|
||||
OBJ += menu/drivers/zr_menu.o
|
||||
OBJ += menu/drivers/zr.o
|
||||
DEFINES += -DHAVE_ZAHNRAD
|
||||
endif
|
||||
ifeq ($(HAVE_ZARCH), 1)
|
||||
OBJ += menu/drivers/zarch.o
|
||||
@@ -482,7 +429,6 @@ endif
|
||||
|
||||
ifeq ($(HAVE_LAKKA), 1)
|
||||
DEFINES += -DHAVE_LAKKA
|
||||
DEFINES += -DLAKKA_PROJECT=$(LAKKA_PROJECT)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_MENU_COMMON), 1)
|
||||
@@ -491,9 +437,18 @@ ifeq ($(HAVE_MENU_COMMON), 1)
|
||||
else
|
||||
PSEUDO_NS :=
|
||||
endif
|
||||
|
||||
OBJ += menu/menu_driver.o \
|
||||
OBJ += menu/menu_hash.o \
|
||||
menu/menu_driver.o \
|
||||
menu/menu_content.o \
|
||||
menu/intl/menu_hash_de.o \
|
||||
menu/intl/menu_hash_es.o \
|
||||
menu/intl/menu_hash_eo.o \
|
||||
menu/intl/menu_hash_fr.o \
|
||||
menu/intl/menu_hash_it.o \
|
||||
menu/intl/menu_hash_nl.o \
|
||||
menu/intl/menu_hash_pl.o \
|
||||
menu/intl/menu_hash_pt.o \
|
||||
menu/intl/menu_hash_us$(PSEUDO_NS).o \
|
||||
menu/menu_input.o \
|
||||
menu/menu_entry.o \
|
||||
menu/menu_entries.o \
|
||||
@@ -512,7 +467,6 @@ ifeq ($(HAVE_MENU_COMMON), 1)
|
||||
menu/cbs/menu_cbs_deferred_push.o \
|
||||
menu/cbs/menu_cbs_scan.o \
|
||||
menu/cbs/menu_cbs_get_value.o \
|
||||
menu/cbs/menu_cbs_label.o \
|
||||
menu/cbs/menu_cbs_title.o \
|
||||
menu/cbs/menu_cbs_up.o \
|
||||
menu/cbs/menu_cbs_down.o \
|
||||
@@ -527,8 +481,8 @@ endif
|
||||
|
||||
ifeq ($(UTF8), 1)
|
||||
DEFINES += -DHAVE_UTF8
|
||||
OBJ += intl/msg_hash_ru.o
|
||||
DEFINES += -finput-charset=UTF-8
|
||||
OBJ += intl/msg_hash_ru.o
|
||||
DEFINES += -finput-charset=UTF-8
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_STB_FONT), 1)
|
||||
@@ -542,8 +496,10 @@ ifeq ($(HAVE_FREETYPE), 1)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_THREADS), 1)
|
||||
OBJ += libretro-common/rthreads/rthreads.o \
|
||||
OBJ += autosave.o \
|
||||
libretro-common/rthreads/rthreads.o \
|
||||
libretro-common/rthreads/rsemaphore.o \
|
||||
libretro-common/rthreads/async_job.o \
|
||||
gfx/video_thread_wrapper.o \
|
||||
audio/audio_thread_wrapper.o
|
||||
DEFINES += -DHAVE_THREADS
|
||||
@@ -552,6 +508,10 @@ ifeq ($(HAVE_THREADS), 1)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_COMMAND), 1)
|
||||
OBJ += command.o
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_WAYLAND), 1)
|
||||
OBJ += gfx/drivers_context/wayland_ctx.o
|
||||
DEFINES += $(WAYLAND_CFLAGS)
|
||||
@@ -575,9 +535,9 @@ ifeq ($(HAVE_XINPUT), 1)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_OPENDINGUX_FBDEV), 1)
|
||||
OBJ += gfx/drivers_context/opendingux_fbdev_ctx.o
|
||||
DEFINES += $(EGL_CFLAGS)
|
||||
LIBS += $(EGL_LIBS)
|
||||
OBJ += gfx/drivers_context/opendingux_fbdev_ctx.o
|
||||
DEFINES += $(EGL_CFLAGS)
|
||||
LIBS += $(EGL_LIBS)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_X11), 1)
|
||||
@@ -589,16 +549,16 @@ ifeq ($(HAVE_X11), 1)
|
||||
LIBS += $(X11_LIBS) $(XEXT_LIBS) $(XF86VM_LIBS) $(XINERAMA_LIBS)
|
||||
DEFINES += $(X11_CFLAGS) $(XEXT_CFLAGS) $(XF86VM_CFLAGS) $(XINERAMA_CFLAGS)
|
||||
ifeq ($(HAVE_XCB),1)
|
||||
LIBS += -lX11-xcb
|
||||
LIBS += -lX11-xcb
|
||||
endif
|
||||
ifneq ($(HAVE_GLES), 1)
|
||||
OBJ += gfx/drivers_context/x_ctx.o
|
||||
OBJ += gfx/drivers_context/x_ctx.o
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_XCB),1)
|
||||
DEFINES += $(XCB_CFLAGS)
|
||||
LIBS += $(XCB_LIBS)
|
||||
DEFINES += $(XCB_CFLAGS)
|
||||
LIBS += $(XCB_LIBS)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_XKBCOMMON), 1)
|
||||
@@ -616,22 +576,18 @@ ifeq ($(HAVE_UDEV), 1)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_LIBUSB), 1)
|
||||
ifeq ($(HAVE_THREADS), 1)
|
||||
ifeq ($(HAVE_HID), 1)
|
||||
DEFINES += -DHAVE_LIBUSB
|
||||
OBJ += input/drivers_hid/libusb_hid.o
|
||||
LIBS += -lusb-1.0
|
||||
endif
|
||||
endif
|
||||
HAVE_HID = 1
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_IOHIDMANAGER), 1)
|
||||
ifeq ($(HAVE_HID), 1)
|
||||
DEFINES += -DHAVE_IOHIDMANAGER
|
||||
OBJ += input/drivers_hid/iohidmanager_hid.o
|
||||
HAVE_HID = 1
|
||||
LIBS += -framework IOKit
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_CORELOCATION), 1)
|
||||
DEFINES += -DHAVE_CORELOCATION
|
||||
@@ -640,10 +596,7 @@ endif
|
||||
|
||||
ifeq ($(HAVE_HID), 1)
|
||||
DEFINES += -DHAVE_HID
|
||||
OBJ += input/input_hid_driver.o \
|
||||
input/drivers_joypad/hid_joypad.o \
|
||||
input/connect/joypad_connection.o \
|
||||
input/connect/connect_ps2adapter.o \
|
||||
OBJ += input/connect/joypad_connection.o \
|
||||
input/connect/connect_ps3.o \
|
||||
input/connect/connect_ps4.o \
|
||||
input/connect/connect_wii.o \
|
||||
@@ -660,11 +613,7 @@ endif
|
||||
# Companion UI
|
||||
|
||||
ifneq ($(findstring Win32,$(OS)),)
|
||||
OBJ += ui/drivers/ui_win32.o \
|
||||
ui/drivers/win32/ui_win32_window.o \
|
||||
ui/drivers/win32/ui_win32_browser_window.o \
|
||||
ui/drivers/win32/ui_win32_msg_window.o \
|
||||
ui/drivers/win32/ui_win32_application.o
|
||||
OBJ += ui/drivers/ui_win32.o
|
||||
endif
|
||||
|
||||
# Video
|
||||
@@ -672,20 +621,14 @@ endif
|
||||
OBJ += gfx/video_context_driver.o \
|
||||
gfx/drivers_context/gfx_null_ctx.o \
|
||||
gfx/video_state_tracker.o \
|
||||
libretro-common/gfx/math/vector_2.o \
|
||||
libretro-common/gfx/math/vector_3.o \
|
||||
libretro-common/gfx/math/matrix_4x4.o \
|
||||
libretro-common/gfx/math/matrix_3x3.o
|
||||
|
||||
ifeq ($(HAVE_KMS), 1)
|
||||
HAVE_AND_WILL_USE_DRM = 1
|
||||
OBJ += gfx/drivers_context/drm_ctx.o
|
||||
DEFINES += $(GBM_CFLAGS) $(DRM_CFLAGS) $(EGL_CFLAGS)
|
||||
LIBS += $(GBM_LIBS) $(DRM_LIBS) $(EGL_LIBS)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_PLAIN_DRM), 1)
|
||||
OBJ += gfx/drivers/drm_gfx.o
|
||||
HAVE_AND_WILL_USE_DRM = 1
|
||||
OBJ += gfx/drivers_context/drm_ctx.o
|
||||
DEFINES += $(GBM_CFLAGS) $(DRM_CFLAGS) $(EGL_CFLAGS)
|
||||
LIBS += $(GBM_LIBS) $(DRM_LIBS) $(EGL_LIBS)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_GL_CONTEXT), 1)
|
||||
@@ -729,15 +672,6 @@ ifeq ($(HAVE_GL_CONTEXT), 1)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_FFMPEG), 1)
|
||||
ifneq ($(C89_BUILD), 1)
|
||||
ifneq ($(HAVE_GLES), 1)
|
||||
OBJ += cores/libretro-ffmpeg/fft/fft.o
|
||||
DEFINES += -Ideps -DHAVE_GL_FFT
|
||||
NEED_CXX_LINKER=1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_GLES), 1)
|
||||
LIBS += $(GLES_LIBS)
|
||||
@@ -802,61 +736,43 @@ ifeq ($(HAVE_SDL2), 1)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_VULKAN), 1)
|
||||
ifneq ($(findstring Win32,$(OS)),)
|
||||
GLSLANG_PLATFORM := Windows
|
||||
else
|
||||
GLSLANG_PLATFORM := Unix
|
||||
endif
|
||||
ifeq ($(platform), win)
|
||||
GLSLANG_PLATFORM := Windows
|
||||
else
|
||||
GLSLANG_PLATFORM := Unix
|
||||
endif
|
||||
GLSLANG_SOURCES := \
|
||||
$(wildcard deps/glslang/*.cpp) \
|
||||
$(wildcard deps/glslang/glslang/SPIRV/*.cpp) \
|
||||
$(wildcard deps/glslang/glslang/glslang/GenericCodeGen/*.cpp) \
|
||||
$(wildcard deps/glslang/glslang/OGLCompilersDLL/*.cpp) \
|
||||
$(wildcard deps/glslang/glslang/glslang/MachineIndependent/*.cpp) \
|
||||
$(wildcard deps/glslang/glslang/glslang/MachineIndependent/preprocessor/*.cpp) \
|
||||
$(wildcard deps/glslang/glslang/glslang/OSDependent/$(GLSLANG_PLATFORM)/*.cpp)
|
||||
|
||||
GLSLANG_SOURCES := \
|
||||
$(wildcard deps/glslang/*.cpp) \
|
||||
$(wildcard deps/glslang/glslang/SPIRV/*.cpp) \
|
||||
$(wildcard deps/glslang/glslang/glslang/GenericCodeGen/*.cpp) \
|
||||
$(wildcard deps/glslang/glslang/OGLCompilersDLL/*.cpp) \
|
||||
$(wildcard deps/glslang/glslang/glslang/MachineIndependent/*.cpp) \
|
||||
$(wildcard deps/glslang/glslang/glslang/MachineIndependent/preprocessor/*.cpp) \
|
||||
$(wildcard deps/glslang/glslang/hlsl/*.cpp) \
|
||||
$(wildcard deps/glslang/glslang/glslang/OSDependent/$(GLSLANG_PLATFORM)/*.cpp)
|
||||
DEFINES += \
|
||||
-Ideps/glslang/glslang/glslang/OSDependent/$(GLSLANG_PLATFORM) \
|
||||
-Ideps/glslang/glslang \
|
||||
-Ideps/glslang/glslang/glslang/MachineIndependent \
|
||||
-Ideps/glslang/glslang/glslang/Public \
|
||||
-Ideps/glslang/glslang/SPIRV \
|
||||
-Ideps/glslang
|
||||
|
||||
SPIRV_CROSS_SOURCES := deps/SPIRV-Cross/spirv_cross.cpp
|
||||
ifneq ($(findstring Win32,$(OS)),)
|
||||
# Trivial temporary workaround for MinGW and glslang.
|
||||
CXXFLAGS += -fpermissive
|
||||
endif
|
||||
CXXFLAGS += -Wno-switch -Wno-sign-compare -fno-strict-aliasing -Wno-maybe-uninitialized -Wno-reorder -I./gfx/include/vulkan
|
||||
CFLAGS += -I./gfx/include/vulkan
|
||||
|
||||
DEFINES += \
|
||||
-Ideps/glslang/glslang/glslang/OSDependent/$(GLSLANG_PLATFORM) \
|
||||
-Ideps/glslang/glslang/OGLCompilersDLL \
|
||||
-Ideps/glslang/glslang \
|
||||
-Ideps/glslang/glslang/glslang/MachineIndependent \
|
||||
-Ideps/glslang/glslang/glslang/Public \
|
||||
-Ideps/glslang/glslang/SPIRV \
|
||||
-Ideps/glslang \
|
||||
-Ideps/SPIRV-Cross
|
||||
GLSLANG_OBJ := $(GLSLANG_SOURCES:.cpp=.o)
|
||||
|
||||
CXXFLAGS += -Wno-switch -Wno-sign-compare -fno-strict-aliasing -Wno-maybe-uninitialized -Wno-reorder -Wno-parentheses -Igfx/include
|
||||
CFLAGS += -Igfx/include
|
||||
|
||||
GLSLANG_OBJ := $(GLSLANG_SOURCES:.cpp=.o)
|
||||
SPIRV_CROSS_OBJ := $(SPIRV_CROSS_SOURCES:.cpp=.o)
|
||||
|
||||
OBJ += gfx/drivers/vulkan.o \
|
||||
gfx/common/vulkan_common.o \
|
||||
libretro-common/vulkan/vulkan_symbol_wrapper.o \
|
||||
gfx/drivers_font/vulkan_raster_font.o \
|
||||
gfx/drivers_shader/shader_vulkan.o \
|
||||
gfx/drivers_shader/glslang_util.o \
|
||||
gfx/drivers_shader/slang_reflection.o \
|
||||
$(GLSLANG_OBJ) \
|
||||
$(SPIRV_CROSS_OBJ)
|
||||
|
||||
ifeq ($(HAVE_VULKAN_KHR_DISPLAY), 1)
|
||||
OBJ += gfx/drivers_context/khr_display_ctx.o
|
||||
endif
|
||||
ifeq ($(HAVE_MENU_COMMON), 1)
|
||||
OBJ += menu/drivers_display/menu_display_vulkan.o
|
||||
endif
|
||||
LIBS += -lstdc++
|
||||
OBJ += gfx/drivers/vulkan.o \
|
||||
gfx/common/vulkan_common.o \
|
||||
gfx/drivers_font/vulkan_raster_font.o \
|
||||
gfx/drivers_shader/shader_vulkan.o \
|
||||
gfx/drivers_shader/glslang_util.o \
|
||||
$(GLSLANG_OBJ)
|
||||
ifeq ($(HAVE_MENU_COMMON), 1)
|
||||
OBJ += menu/drivers_display/menu_display_vulkan.o
|
||||
endif
|
||||
LIBS += -lstdc++
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_OMAP), 1)
|
||||
@@ -958,11 +874,12 @@ endif
|
||||
|
||||
|
||||
ifeq ($(HAVE_ZLIB), 1)
|
||||
OBJ += libretro-common/file/archive_file.o \
|
||||
libretro-common/file/archive_file_zlib.o \
|
||||
OBJ += libretro-common/file/file_archive.o \
|
||||
libretro-common/file/file_archive_zlib.o \
|
||||
tasks/task_decompress.o
|
||||
OBJ += $(ZLIB_OBJS)
|
||||
DEFINES += -DHAVE_ZLIB
|
||||
HAVE_RPNG = 1
|
||||
HAVE_COMPRESSION = 1
|
||||
ifeq ($(WANT_ZLIB), 1)
|
||||
DEFINES += -DWANT_ZLIB
|
||||
@@ -972,30 +889,17 @@ ifeq ($(HAVE_ZLIB), 1)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_RTGA), 1)
|
||||
DEFINES += -DHAVE_RTGA
|
||||
OBJ += libretro-common/formats/tga/rtga.o
|
||||
ifdef HAVE_RPNG
|
||||
DEFINES += -DHAVE_RPNG
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_RPNG), 1)
|
||||
DEFINES += -DHAVE_RPNG
|
||||
OBJ += libretro-common/formats/png/rpng.o \
|
||||
libretro-common/formats/png/rpng_encode.o
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_RJPEG), 1)
|
||||
DEFINES += -DHAVE_RJPEG
|
||||
OBJ += libretro-common/formats/jpeg/rjpeg.o
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_RBMP), 1)
|
||||
DEFINES += -DHAVE_RBMP
|
||||
OBJ += libretro-common/formats/bmp/rbmp.o
|
||||
endif
|
||||
|
||||
OBJ += libretro-common/formats/bmp/rbmp_encode.o \
|
||||
libretro-common/formats/json/jsonsax.o \
|
||||
libretro-common/formats/image_transfer.o
|
||||
libretro-common/formats/tga/rtga.o \
|
||||
libretro-common/formats/json/jsonsax.o
|
||||
|
||||
ifdef HAVE_COMPRESSION
|
||||
DEFINES += -DHAVE_COMPRESSION
|
||||
@@ -1040,18 +944,17 @@ ifeq ($(HAVE_NETWORKING), 1)
|
||||
DEFINES += -DHAVE_NETWORKING
|
||||
OBJ += libretro-common/net/net_compat.o \
|
||||
libretro-common/net/net_http.o \
|
||||
libretro-common/net/net_socket.o \
|
||||
network/net_http_special.o \
|
||||
net_http_special.o \
|
||||
tasks/task_http.o
|
||||
|
||||
ifneq ($(HAVE_SOCKET_LEGACY),1)
|
||||
OBJ += libretro-common/net/net_ifinfo.o
|
||||
endif
|
||||
OBJ += libretro-common/net/net_ifinfo.o
|
||||
endif
|
||||
|
||||
ifeq ($(WANT_IFADDRS), 1)
|
||||
DEFINES += -DWANT_IFADDRS
|
||||
OBJ += libretro-common/compat/compat_ifaddrs.o
|
||||
endif
|
||||
DEFINES += -DWANT_IFADDRS
|
||||
OBJ += libretro-common/compat/compat_ifaddrs.o
|
||||
endif
|
||||
|
||||
ifneq ($(findstring Win32,$(OS)),)
|
||||
LIBS += -lws2_32 -liphlpapi
|
||||
@@ -1060,11 +963,8 @@ ifeq ($(HAVE_NETWORKING), 1)
|
||||
# Netplay
|
||||
|
||||
ifeq ($(HAVE_NETPLAY), 1)
|
||||
DEFINES += -DHAVE_NETPLAY -DHAVE_NETWORK_CMD
|
||||
OBJ += network/netplay/netplay_net.o \
|
||||
network/netplay/netplay_spectate.o \
|
||||
network/netplay/netplay_common.o \
|
||||
network/netplay/netplay.o
|
||||
DEFINES += -DHAVE_NETPLAY -DHAVE_NETWORK_CMD -DHAVE_NETWORK_GAMEPAD
|
||||
OBJ += netplay/netplay_net.o netplay/netplay_spectate.o netplay/netplay_common.o netplay/netplay.o
|
||||
endif
|
||||
|
||||
# Retro Achievements (also depends on threads)
|
||||
@@ -1076,9 +976,8 @@ ifeq ($(HAVE_NETWORKING), 1)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_NETWORKGAMEPAD), 1)
|
||||
OBJ += input/input_remote.o \
|
||||
cores/libretro-net-retropad/net_retropad_core.o
|
||||
ifeq ($(HAVE_NETWORK_GAMEPAD), 1)
|
||||
OBJ += remote.o
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -1103,11 +1002,9 @@ endif
|
||||
ifeq ($(HAVE_FFMPEG), 1)
|
||||
OBJ += record/drivers/record_ffmpeg.o \
|
||||
cores/libretro-ffmpeg/ffmpeg_core.o
|
||||
|
||||
|
||||
LIBS += $(AVCODEC_LIBS) $(AVFORMAT_LIBS) $(AVUTIL_LIBS) $(SWSCALE_LIBS) $(SWRESAMPLE_LIBS) $(FFMPEG_LIBS)
|
||||
DEFINES += $(AVCODEC_CFLAGS) $(AVFORMAT_CFLAGS) $(AVUTIL_CFLAGS) $(SWSCALE_CFLAGS) $(SWRESAMPLE_CFLAGS)
|
||||
DEFINES += -Wno-deprecated-declarations -DHAVE_FFMPEG -Iffmpeg
|
||||
DEFINES += -DHAVE_FFMPEG -Iffmpeg
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_COMPRESSION), 1)
|
||||
@@ -1123,10 +1020,6 @@ ifeq ($(HAVE_COCOA),1)
|
||||
OBJ += input/drivers/cocoa_input.o \
|
||||
input/drivers_keyboard/keyboard_event_apple.o \
|
||||
ui/drivers/ui_cocoa.o \
|
||||
ui/drivers/cocoa/ui_cocoa_window.o \
|
||||
ui/drivers/cocoa/ui_cocoa_browser_window.o \
|
||||
ui/drivers/cocoa/ui_cocoa_msg_window.o \
|
||||
ui/drivers/cocoa/ui_cocoa_application.o \
|
||||
ui/drivers/cocoa/cocoa_common.o \
|
||||
gfx/drivers_context/cocoa_gl_ctx.o
|
||||
endif
|
||||
+35
-42
@@ -21,32 +21,20 @@ APP_RSF = ctr/tools/template.rsf
|
||||
APP_SYSTEM_MODE = 64MB
|
||||
APP_SYSTEM_MODE_EXT = 124MB
|
||||
APP_BIG_TEXT_SECTION = 0
|
||||
APP_USE_SVCHAX = 0
|
||||
|
||||
include ctr/Makefile.cores
|
||||
|
||||
OBJS :=
|
||||
OBJS += gfx/drivers/ctr_shaders/ctr_sprite.o
|
||||
OBJS += gfx/drivers/ctr_sprite.o
|
||||
OBJS += ctr/ctr_system.o
|
||||
OBJS += ctr/ctr_memory.o
|
||||
OBJS += ctr/ctr_linear.o
|
||||
|
||||
ifeq ($(APP_BIG_TEXT_SECTION), 1)
|
||||
APP_USE_SVCHAX = 1
|
||||
LDFLAGS += -Wl,--defsym,__ctr_patch_services=__service_ptr
|
||||
endif
|
||||
|
||||
ifeq ($(APP_USE_SVCHAX), 1)
|
||||
OBJS += ctr/ctr_svchax.o
|
||||
endif
|
||||
OBJS += ctr/ctr_svchax.o
|
||||
|
||||
ifeq ($(GRIFFIN_BUILD), 1)
|
||||
OBJS += griffin/griffin.o
|
||||
else
|
||||
CFLAGS += -DHAVE_COMPRESSION
|
||||
OBJS += libretro-common/file/archive_file.o
|
||||
OBJS += libretro-common/file/archive_file_zlib.o
|
||||
OBJS += libretro-common/encodings/encoding_utf.o
|
||||
OBJS += libretro-common/file/file_extract.o
|
||||
OBJS += verbosity.o
|
||||
OBJS += performance.o
|
||||
OBJS += libretro-common/compat/compat_getopt.o
|
||||
@@ -55,13 +43,13 @@ else
|
||||
OBJS += libretro-common/compat/compat_fnmatch.o
|
||||
OBJS += libretro-common/memmap/memalign.o
|
||||
OBJS += libretro-common/file/config_file.o
|
||||
OBJS += config_file_userdata.o
|
||||
OBJS += libretro-common/file/config_file_userdata.o
|
||||
OBJS += core_options.o
|
||||
OBJS += cheats.o
|
||||
OBJS += libretro-common/hash/rhash.o
|
||||
OBJS += gfx/video_context_driver.o
|
||||
OBJS += gfx/drivers_context/gfx_null_ctx.o
|
||||
OBJS += libretro-common/formats/image_texture.o
|
||||
OBJS += gfx/image/image.o
|
||||
OBJS += libretro-common/formats/tga/rtga.o
|
||||
OBJS += libretro-common/formats/png/rpng.o
|
||||
OBJS += libretro-common/formats/png/rpng_encode.o
|
||||
@@ -87,11 +75,10 @@ else
|
||||
OBJS += input/drivers_joypad/hid_joypad.o
|
||||
OBJS += input/drivers_hid/null_hid.o
|
||||
OBJS += gfx/video_state_tracker.o
|
||||
OBJS += libretro-common/queues/fifo_queue.o
|
||||
OBJS += libretro-common/queues/fifo_buffer.o
|
||||
OBJS += audio/audio_resampler_driver.o
|
||||
OBJS += audio/drivers_resampler/sinc_resampler.o
|
||||
OBJS += audio/drivers_resampler/nearest_resampler.o
|
||||
OBJS += audio/drivers_resampler/null_resampler.o
|
||||
OBJS += audio/drivers_resampler/sinc.o
|
||||
OBJS += audio/drivers_resampler/nearest.o
|
||||
OBJS += audio/drivers_resampler/cc_resampler.o
|
||||
OBJS += camera/drivers/nullcamera.o
|
||||
OBJS += location/drivers/nulllocation.o
|
||||
@@ -99,7 +86,7 @@ else
|
||||
OBJS += audio/drivers/ctr_dsp_audio.o
|
||||
OBJS += audio/drivers/nullaudio.o
|
||||
OBJS += gfx/video_driver.o
|
||||
OBJS += gfx/video_coord_array.o
|
||||
OBJS += gfx/video_common.o
|
||||
OBJS += input/input_driver.o
|
||||
OBJS += audio/audio_driver.o
|
||||
OBJS += camera/camera_driver.o
|
||||
@@ -135,15 +122,17 @@ else
|
||||
OBJS += content.o
|
||||
OBJS += libretro-common/file/file_path.o
|
||||
OBJS += file_path_special.o
|
||||
OBJS += libretro-common/lists/dir_list.o
|
||||
OBJS += libretro-common/file/dir_list.o
|
||||
OBJS += libretro-common/file/retro_dirent.o
|
||||
OBJS += libretro-common/streams/file_stream.o
|
||||
OBJS += libretro-common/file/retro_file.o
|
||||
OBJS += libretro-common/file/retro_stat.o
|
||||
OBJS += list_special.o
|
||||
OBJS += libretro-common/lists/string_list.o
|
||||
OBJS += dir_list_special.o
|
||||
OBJS += string_list_special.o
|
||||
OBJS += libretro-common/string/string_list.o
|
||||
OBJS += libretro-common/string/stdstring.o
|
||||
OBJS += file_ops.o
|
||||
OBJS += libretro-common/file/nbio/nbio_stdio.o
|
||||
OBJS += libretro-common/lists/file_list.o
|
||||
OBJS += libretro-common/file/file_list.o
|
||||
OBJS += libretro-common/queues/message_queue.o
|
||||
OBJS += patch.o
|
||||
OBJS += configuration.o
|
||||
@@ -158,8 +147,7 @@ else
|
||||
OBJS += libretro_version_1.o
|
||||
OBJS += retroarch.o
|
||||
OBJS += runloop.o
|
||||
OBJS += libretro-common/queues/task_queue.o
|
||||
OBJS += tasks/tasks_internal.o
|
||||
OBJS += tasks/tasks.o
|
||||
OBJS += msg_hash.o
|
||||
OBJS += intl/msg_hash_de.o
|
||||
OBJS += intl/msg_hash_es.o
|
||||
@@ -173,9 +161,8 @@ else
|
||||
OBJS += movie.o
|
||||
OBJS += record/record_driver.o
|
||||
OBJS += record/drivers/record_null.o
|
||||
OBJS += tasks/task_content.o
|
||||
OBJS += tasks/task_file_transfer.o
|
||||
OBJS += tasks/task_decompress.o
|
||||
OBJS += tasks/task_file_transfer.o
|
||||
OBJS += screenshot.o
|
||||
OBJS += playlist.o
|
||||
OBJS += menu/menu_driver.o
|
||||
@@ -185,7 +172,6 @@ else
|
||||
OBJS += menu/menu_entries.o
|
||||
OBJS += menu/menu_setting.o
|
||||
OBJS += menu/menu_cbs.o
|
||||
OBJS += menu/menu_content.o
|
||||
OBJS += menu/cbs/menu_cbs_ok.o
|
||||
OBJS += menu/cbs/menu_cbs_cancel.o
|
||||
OBJS += menu/cbs/menu_cbs_select.o
|
||||
@@ -234,6 +220,8 @@ else
|
||||
OBJS += deps/zlib/trees.o
|
||||
OBJS += deps/zlib/uncompr.o
|
||||
OBJS += deps/zlib/zutil.o
|
||||
OBJS += deps/zlib/ioapi.o
|
||||
OBJS += deps/zlib/unzip.o
|
||||
OBJS += audio/audio_utils.o
|
||||
endif
|
||||
|
||||
@@ -292,12 +280,12 @@ CFLAGS += -I. -Ideps/zlib -Ideps/7zip -Ilibretro-common/include
|
||||
|
||||
CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE -DSINC_LOWEST_QUALITY
|
||||
CFLAGS += -DHAVE_GRIFFIN=1 -DHAVE_FILTERS_BUILTIN -DHAVE_MENU -DHAVE_RGUI
|
||||
CFLAGS += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DWANT_ZLIB -DHAVE_BUILTIN_AUTOCONFIG
|
||||
CFLAGS += -DHAVE_ZLIB -DHAVE_RPNG -DWANT_ZLIB -DHAVE_BUILTIN_AUTOCONFIG
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
ASFLAGS := -g $(ARCH) -O3
|
||||
LDFLAGS += -specs=ctr/3dsx_custom.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
LDFLAGS = -specs=ctr/3dsx_custom.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
CFLAGS += -std=gnu99 -ffast-math
|
||||
|
||||
@@ -325,6 +313,11 @@ $(TARGET): $(TARGET_3DSX) $(TARGET_3DS) $(TARGET_CIA)
|
||||
$(TARGET).3dsx: $(TARGET).elf
|
||||
$(TARGET).elf: $(OBJS) libretro_ctr.a
|
||||
|
||||
ctr_sprite_shader_shbin.h: gfx/drivers/ctr_sprite.o
|
||||
gfx/drivers/ctr_gfx.c: ctr_sprite_shader_shbin.h
|
||||
griffin/griffin.o: gfx/drivers/ctr_gfx.c
|
||||
|
||||
|
||||
PREFIX := $(DEVKITARM)/bin/arm-none-eabi-
|
||||
|
||||
CC := $(PREFIX)gcc
|
||||
@@ -347,15 +340,14 @@ else
|
||||
BANNERTOOL = ctr/tools/bannertool.exe
|
||||
endif
|
||||
|
||||
%.o: %.vsh %.gsh
|
||||
$(DEVKITARM)/bin/picasso $^ -o $*.shbin
|
||||
$(DEVKITARM)/bin/bin2s $*.shbin | $(PREFIX)as -o $@
|
||||
rm $*.shbin
|
||||
%.o: %.shader
|
||||
python $(AEMSTRO)/aemstro_as.py $< $(notdir $<).shbin
|
||||
$(DEVKITARM)/bin/bin2s $(notdir $<).shbin | $(PREFIX)as -o $@
|
||||
echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
rm $(notdir $<).shbin
|
||||
|
||||
%.o: %.vsh
|
||||
$(DEVKITARM)/bin/picasso $^ -o $*.shbin
|
||||
$(DEVKITARM)/bin/bin2s $*.shbin | $(PREFIX)as -o $@
|
||||
rm $*.shbin
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c -o $@ $< $(CXXFLAGS) $(INCDIRS)
|
||||
@@ -411,6 +403,7 @@ clean:
|
||||
rm -f $(TARGET).smdh
|
||||
rm -f $(TARGET).bnr
|
||||
rm -f $(TARGET).icn
|
||||
rm -f *_shader_shbin.h
|
||||
rm -f ctr/ctr_config_*.o
|
||||
rm -f ctr/3dsx_custom_crt0.o
|
||||
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ else
|
||||
CFLAGS += -O2
|
||||
endif
|
||||
|
||||
CFLAGS += -DHAVE_RPNG -DHAVE_RJPEG -Wall -Wno-unused-result -Wno-unused-variable -I. -Ilibretro-common/include -std=gnu99 -s USE_ZLIB=1 \
|
||||
CFLAGS += -DWANT_RPNG -Wall -Wno-unused-result -Wno-unused-variable -I. -Ilibretro-common/include -std=gnu99 -s USE_ZLIB=1 \
|
||||
-s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_take_screenshot']"
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
+4
-29
@@ -127,9 +127,6 @@ endif
|
||||
HAVE_FILTERS_BUILTIN := 1
|
||||
HAVE_THREADS := 1
|
||||
HAVE_RPNG := 1
|
||||
HAVE_RJPEG := 1
|
||||
HAVE_RBMP := 1
|
||||
HAVE_RTGA := 1
|
||||
HAVE_OVERLAY := 1
|
||||
HAVE_BUILTIN_AUTOCONFIG := 1
|
||||
HAVE_ZLIB := 1
|
||||
@@ -137,7 +134,6 @@ endif
|
||||
RARCH_CONSOLE = 1
|
||||
|
||||
ifeq ($(platform), wii)
|
||||
HAVE_LANGEXTRA := 1
|
||||
HAVE_WIIUSB_HID := 1
|
||||
HAVE_RARCH_EXEC := 1
|
||||
HAVE_RSOUND := 1
|
||||
@@ -189,11 +185,7 @@ else ifeq ($(platform), psp1)
|
||||
|
||||
BUILD_PRX = 1
|
||||
HAVE_RPNG := 1
|
||||
HAVE_RJPEG := 1
|
||||
HAVE_RBMP := 1
|
||||
HAVE_RTGA := 1
|
||||
HAVE_KERNEL_PRX := 1
|
||||
HAVE_LANGEXTRA := 1
|
||||
RARCH_CONSOLE = 1
|
||||
|
||||
ifeq ($(BUILD_PRX), 1)
|
||||
@@ -213,8 +205,7 @@ else ifeq ($(platform), vita)
|
||||
-lSceSysmodule_stub -lSceCtrl_stub -lSceAudio_stub -lUVLoader_stub \
|
||||
-lScePower_stub -lSceRtc_stub -lSceCommonDialog_stub -lfreetype -lz -lm -lc -lpng
|
||||
|
||||
PLATOBJS += libretro-common/conversion/s16_to_float_neon.o \
|
||||
audio/drivers_resampler/sinc_resampler_neon.o \
|
||||
PLATOBJS += audio/audio_utils_neon.o audio/drivers_resampler/sinc_resampler_neon.o \
|
||||
audio/drivers_resampler/cc_resampler_neon.o
|
||||
|
||||
LIBDIRS += -L.
|
||||
@@ -222,11 +213,7 @@ else ifeq ($(platform), vita)
|
||||
|
||||
HAVE_FILTERS_BUILTIN := 1
|
||||
HAVE_BUILTIN_AUTOCONFIG := 1
|
||||
HAVE_LANGEXTRA := 1
|
||||
HAVE_RPNG := 1
|
||||
HAVE_RJPEG := 1
|
||||
HAVE_RBMP := 1
|
||||
HAVE_RTGA := 1
|
||||
HAVE_ZLIB := 1
|
||||
HAVE_VITA2D := 1
|
||||
HAVE_NETWORKING := 1
|
||||
@@ -275,8 +262,8 @@ ifeq ($(BIG_STACK),1)
|
||||
CFLAGS += -DBIG_STACK
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_RJPEG), 1)
|
||||
CFLAGS += -DHAVE_RJPEG
|
||||
ifeq ($(HAVE_RPNG), 1)
|
||||
CFLAGS += -DWANT_RPNG
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_FILE_LOGGER), 1)
|
||||
@@ -295,14 +282,6 @@ ifeq ($(HAVE_RPNG), 1)
|
||||
CFLAGS += -DHAVE_RPNG
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_RBMP), 1)
|
||||
CFLAGS += -DHAVE_RBMP
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_RTGA), 1)
|
||||
CFLAGS += -DHAVE_RTGA
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_7ZIP), 1)
|
||||
CFLAGS += -DHAVE_7ZIP
|
||||
endif
|
||||
@@ -333,10 +312,6 @@ endif
|
||||
|
||||
CFLAGS += -std=gnu99 -DSINC_LOWER_QUALITY -DHAVE_RGUI -DHAVE_MENU -DHAVE_GRIFFIN=1 -Wno-char-subscripts -DRARCH_INTERNAL
|
||||
|
||||
ifeq ($(HAVE_LANGEXTRA), 1)
|
||||
CFLAGS += -DHAVE_LANGEXTRA
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_FILTERS_BUILTIN), 1)
|
||||
CFLAGS += -DHAVE_FILTERS_BUILTIN
|
||||
endif
|
||||
@@ -375,7 +350,7 @@ all: $(EXT_TARGET)
|
||||
|
||||
%.velf: %.elf
|
||||
arm-vita-eabi-strip -g $<
|
||||
vita-elf-create $< $@ $(VITASDK)/share/db.json $(VITASDK)/share/extra.json
|
||||
vita-elf-create $< $@ $(VITASDK)/bin/db.json $(VITASDK)/bin/extra.json
|
||||
|
||||
%.elf32: %.elf
|
||||
ifeq ($(platform), xenon360)
|
||||
|
||||
@@ -10,12 +10,12 @@ TARGET := retroarch-pandora
|
||||
LDDIRS = -L. -L$(PNDSDK)/usr/lib
|
||||
INCDIRS = -I. -I$(PNDSDK)/usr/include
|
||||
|
||||
OBJ = griffin/griffin.o audio/resamplers/sinc_resampler_neon.o libretro-common/conversion/s16_to_float_neon.o libretro-common/conversion/float_to_s16_neon.o
|
||||
OBJ = griffin/griffin.o audio/resamplers/sinc_resampler_neon.o audio/audio_utils_neon.o
|
||||
LDFLAGS = -L$(PNDSDK)/usr/lib -Wl,-rpath,$(PNDSDK)/usr/lib
|
||||
|
||||
LIBS = -lGLESv2 -lEGL -ldl -lm -lpthread -lrt -lasound
|
||||
DEFINES = -std=gnu99 -DHAVE_THREADS -DHAVE_GETOPT_LONG=1 -DHAVE_GRIFFIN -DRARCH_INTERNAL
|
||||
DEFINES += -D__ARM_ARCH_6__ -DSINC_LOWER_QUALITY -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DHAVE_GLSL -DHAVE_DYNAMIC -DHAVE_RPNG -DHAVE_RJPEG -DWANT_ZLIB -DHAVE_OVERLAY -DHAVE_ALSA -DHAVE_ZLIB -D__linux__
|
||||
DEFINES += -D__ARM_ARCH_6__ -DSINC_LOWER_QUALITY -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DHAVE_GLSL -DHAVE_DYNAMIC -DWANT_RPNG -DWANT_ZLIB -DHAVE_OVERLAY -DHAVE_ALSA -DHAVE_ZLIB -D__linux__
|
||||
DEFINES += $(INCDIRS)
|
||||
DEFINES += -D__OPENPANDORA__ -DPANDORA
|
||||
DEFINES += -marm -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize
|
||||
|
||||
+2
-2
@@ -68,7 +68,7 @@ ifeq ($(HAVE_RLAUNCH), 1)
|
||||
DEFINES += -DHAVE_RLAUNCH
|
||||
endif
|
||||
|
||||
DEFINES += -DHAVE_MENU -DHAVE_RGUI -DHAVE_XMB -DHAVE_MATERIALUI -DHAVE_SHADERPIPELINE -DRARCH_INTERNAL -DMSB_FIRST -DHAVE_OVERLAY
|
||||
DEFINES += -DHAVE_MENU -DHAVE_RGUI -DRARCH_INTERNAL -DMSB_FIRST -DHAVE_OVERLAY
|
||||
|
||||
ifeq ($(HAVE_GCMGL), 1)
|
||||
DEFINES += -DHAVE_GCMGL
|
||||
@@ -106,7 +106,7 @@ PPU_LDLIBS = $(FONT_LIBS) $(GL_LIBS) $(WHOLE_START) -lretro_ps3 $(WHOLE_END) -l
|
||||
|
||||
PPU_RANLIB = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ranlib.exe
|
||||
|
||||
DEFINES += -DHAVE_THREADS -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_HEADSET -DHAVE_LANGEXTRA -DHAVE_OPENGLES -DHAVE_OPENGLES1 -DHAVE_PSGL -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_FBO -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_RSOUND -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DHAVE_7Z -DWANT_ZLIB -DSINC_LOWER_QUALITY -D__CELLOS_LV2__ -DHAVE_NETPLAY=1 -DHAVE_NETWORKING=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_MOUSE -DHAVE_GRIFFIN=1 -DHAVE_MULTIMAN=1 -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) -DHAVE_FILTERS_BUILTIN -DHAVE_BUILTIN_AUTOCONFIG
|
||||
DEFINES += -DHAVE_THREADS -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_HEADSET -DHAVE_OPENGLES -DHAVE_OPENGLES1 -DHAVE_PSGL -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_FBO -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_RSOUND -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_7Z -DWANT_ZLIB -DSINC_LOWER_QUALITY -D__CELLOS_LV2__ -DHAVE_NETPLAY=1 -DHAVE_NETWORKING=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_MOUSE -DHAVE_GRIFFIN=1 -DHAVE_MULTIMAN=1 -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) -DHAVE_FILTERS_BUILTIN -DHAVE_BUILTIN_AUTOCONFIG
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
PPU_OPTIMIZE_LV := -O0 -g
|
||||
|
||||
@@ -24,23 +24,20 @@ PPU_SRCS = frontend/frontend_salamander.c \
|
||||
frontend/drivers/platform_ps3.c \
|
||||
frontend/drivers/platform_null.c \
|
||||
libretro-common/file/file_path.c \
|
||||
libretro-common/lists/dir_list.c \
|
||||
libretro-common/lists/string_list.c \
|
||||
libretro-common/file/dir_list.c \
|
||||
libretro-common/file/retro_dirent.c \
|
||||
libretro-common/file/retro_stat.c \
|
||||
libretro-common/hash/rhash.c \
|
||||
libretro-common/string/stdstring.c \
|
||||
libretro-common/string/string_list.c \
|
||||
libretro-common/compat/compat_strl.c \
|
||||
libretro-common/streams/file_stream.c \
|
||||
libretro-common/file/retro_file.c \
|
||||
libretro-common/file/config_file.c \
|
||||
file_path_str.c \
|
||||
verbosity.c
|
||||
|
||||
ifeq ($(HAVE_LOGGER), 1)
|
||||
PPU_CFLAGS += -DHAVE_LOGGER
|
||||
PPU_SRCS += network/net_logger.c \
|
||||
libretro-common/net/net_compat.c \
|
||||
libretro-common/net/net_socket.c
|
||||
PPU_SRCS += netlogger.c
|
||||
endif
|
||||
|
||||
PPU_TARGET = retroarch-salamander_ps3.elf
|
||||
|
||||
@@ -83,6 +83,7 @@ OBJ = griffin/griffin.o
|
||||
|
||||
ifeq ($(HAVE_LOGGER), 1)
|
||||
CFLAGS += -DHAVE_LOGGER
|
||||
CFLAGS += -Ilogger/netlogger
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_FILE_LOGGER), 1)
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ INCDIR = deps/zlib deps/7zip libretro-common/include
|
||||
CFLAGS = $(OPTIMIZE_LV) -G0 -std=gnu99 -ffast-math
|
||||
ASFLAGS = $(CFLAGS)
|
||||
|
||||
RARCH_DEFINES = -DPSP -D_MIPS_ARCH_ALLEGREX -DHAVE_LANGEXTRA -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DWANT_ZLIB -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_RGUI -DSINC_LOWEST_QUALITY -DHAVE_BUILTIN_AUTOCONFIG -DHAVE_FILTERS_BUILTIN -DHAVE_7ZIP
|
||||
RARCH_DEFINES = -DPSP -D_MIPS_ARCH_ALLEGREX -DHAVE_ZLIB -DHAVE_RPNG -DWANT_ZLIB -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_RGUI -DWANT_RPNG -DSINC_LOWEST_QUALITY -DHAVE_BUILTIN_AUTOCONFIG -DHAVE_FILTERS_BUILTIN -DHAVE_7ZIP
|
||||
|
||||
LIBDIR =
|
||||
LDFLAGS =
|
||||
|
||||
@@ -37,15 +37,14 @@ OBJS = frontend/frontend_salamander.o \
|
||||
frontend/drivers/platform_null.o \
|
||||
libretro-common/file/file_path.o \
|
||||
libretro-common/string/stdstring.o \
|
||||
libretro-common/lists/string_list.o \
|
||||
libretro-common/lists/dir_list.o \
|
||||
libretro-common/string/string_list.o \
|
||||
libretro-common/file/dir_list.o \
|
||||
libretro-common/file/retro_dirent.o \
|
||||
libretro-common/compat/compat_strl.o \
|
||||
libretro-common/file/config_file.o \
|
||||
libretro-common/streams/file_stream.o \
|
||||
libretro-common/file/retro_file.o \
|
||||
libretro-common/file/retro_stat.o \
|
||||
libretro-common/hash/rhash.o \
|
||||
file_path_str.o \
|
||||
verbosity.o \
|
||||
bootstrap/psp1/kernel_functions.o
|
||||
|
||||
|
||||
@@ -47,23 +47,20 @@ OBJ = frontend/frontend_salamander.o \
|
||||
libretro-common/file/file_path.o \
|
||||
libretro-common/hash/rhash.o \
|
||||
libretro-common/string/stdstring.o \
|
||||
libretro-common/lists/string_list.o \
|
||||
libretro-common/lists/dir_list.o \
|
||||
libretro-common/streams/file_stream.o \
|
||||
libretro-common/string/string_list.o \
|
||||
libretro-common/file/dir_list.o \
|
||||
libretro-common/file/retro_file.o \
|
||||
libretro-common/file/retro_dirent.o \
|
||||
libretro-common/file/retro_stat.o \
|
||||
libretro-common/compat/compat_strl.o \
|
||||
libretro-common/file/config_file.o \
|
||||
file_path_str.o \
|
||||
verbosity.o \
|
||||
$(APP_BOOTER_DIR)/app_booter.binobj
|
||||
|
||||
ifeq ($(HAVE_LOGGER), 1)
|
||||
CFLAGS += -DHAVE_LOGGER
|
||||
CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
|
||||
OBJ += network/net_logger.o \
|
||||
libretro-common/net/net_compat.o \
|
||||
libretro-common/net/net_socket.o
|
||||
OBJ += logger/netlogger.o
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_FILE_LOGGER), 1)
|
||||
|
||||
@@ -120,6 +120,7 @@ ifeq ($(DEBUG), 1)
|
||||
else
|
||||
CFLAGS += -O3 -ffast-math
|
||||
CXXFLAGS += -O3 -ffast-math
|
||||
LDCXXFLAGS += -s
|
||||
endif
|
||||
|
||||
CFLAGS += -Wall -Wno-unused-result -Wno-unused-variable -I.
|
||||
|
||||
@@ -14,7 +14,7 @@ A libretro core written in portable C or C++ can run seamlessly on many platform
|
||||
While RetroArch is the reference frontend for libretro, several other projects have used the libretro
|
||||
interface to include support for emulators and/or game engines. libretro is completely open and free for anyone to use.
|
||||
|
||||
[libretro API header](https://github.com/libretro/RetroArch/blob/master/libretro-common/include/libretro.h)
|
||||
[libretro API header](https://github.com/libretro/RetroArch/blob/master/libretro.h)
|
||||
|
||||
## Binaries
|
||||
|
||||
|
||||
+221
-304
@@ -18,28 +18,28 @@
|
||||
|
||||
#include <retro_assert.h>
|
||||
|
||||
#include <lists/string_list.h>
|
||||
#include <conversion/float_to_s16.h>
|
||||
#include <conversion/s16_to_float.h>
|
||||
|
||||
#include "audio_driver.h"
|
||||
#include "audio_resampler_driver.h"
|
||||
#include "../record/record_driver.h"
|
||||
#include "audio_utils.h"
|
||||
#include "audio_thread_wrapper.h"
|
||||
|
||||
#include "../command.h"
|
||||
#include "../command_event.h"
|
||||
#include "../configuration.h"
|
||||
#include "../retroarch.h"
|
||||
#include "../runloop.h"
|
||||
#include "../performance_counters.h"
|
||||
#include "../general.h"
|
||||
#include "../performance.h"
|
||||
#include "../verbosity.h"
|
||||
#include "../list_special.h"
|
||||
#include "../string_list_special.h"
|
||||
|
||||
#ifdef HAVE_NETPLAY
|
||||
#include "../netplay/netplay.h"
|
||||
#endif
|
||||
|
||||
#ifndef AUDIO_BUFFER_FREE_SAMPLES_COUNT
|
||||
#define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024)
|
||||
#endif
|
||||
|
||||
struct audio_driver_input_data
|
||||
typedef struct audio_driver_input_data
|
||||
{
|
||||
float *data;
|
||||
|
||||
@@ -89,12 +89,12 @@ struct audio_driver_input_data
|
||||
unsigned buf[AUDIO_BUFFER_FREE_SAMPLES_COUNT];
|
||||
uint64_t count;
|
||||
} free_samples;
|
||||
};
|
||||
} audio_driver_input_data_t;
|
||||
|
||||
static const audio_driver_t *audio_drivers[] = {
|
||||
#ifdef HAVE_ALSA
|
||||
&audio_alsa,
|
||||
#if !defined(__QNX__) && defined(HAVE_THREADS)
|
||||
#ifndef __QNX__
|
||||
&audio_alsathread,
|
||||
#endif
|
||||
#endif
|
||||
@@ -154,16 +154,9 @@ static const audio_driver_t *audio_drivers[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static struct audio_driver_input_data audio_driver_data;
|
||||
static struct retro_audio_callback audio_callback;
|
||||
static struct string_list *audio_driver_devices_list = NULL;
|
||||
static struct retro_perf_counter resampler_proc = {0};
|
||||
static const rarch_resampler_t *audio_driver_resampler = NULL;
|
||||
static void *audio_driver_resampler_data = NULL;
|
||||
static bool audio_driver_active = false;
|
||||
static bool audio_driver_data_own = false;
|
||||
static const audio_driver_t *current_audio = NULL;
|
||||
static void *audio_driver_context_audio_data = NULL;
|
||||
static audio_driver_input_data_t audio_driver_data;
|
||||
static const audio_driver_t *current_audio = NULL;
|
||||
static void *audio_driver_context_audio_data = NULL;
|
||||
|
||||
/**
|
||||
* compute_audio_buffer_statistics:
|
||||
@@ -261,6 +254,7 @@ const char *config_get_audio_driver_options(void)
|
||||
return char_list_new_special(STRING_LIST_AUDIO_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
|
||||
static bool uninit_audio(void)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
@@ -284,11 +278,11 @@ static bool uninit_audio(void)
|
||||
|
||||
if (!settings->audio.enable)
|
||||
{
|
||||
audio_driver_unset_active();
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
audio_driver_deinit_resampler();
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_RESAMPLER_DEINIT, NULL);
|
||||
|
||||
if (audio_driver_data.data)
|
||||
free(audio_driver_data.data);
|
||||
@@ -298,29 +292,27 @@ static bool uninit_audio(void)
|
||||
free(audio_driver_data.output_samples.buf);
|
||||
audio_driver_data.output_samples.buf = NULL;
|
||||
|
||||
command_event(CMD_EVENT_DSP_FILTER_DEINIT, NULL);
|
||||
event_cmd_ctl(EVENT_CMD_DSP_FILTER_DEINIT, NULL);
|
||||
|
||||
compute_audio_buffer_statistics();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool audio_driver_init_internal(bool audio_cb_inited)
|
||||
static bool init_audio(bool audio_cb_inited)
|
||||
{
|
||||
size_t outsamples_max, max_bufsamples = AUDIO_CHUNK_SIZE_NONBLOCKING * 2;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
convert_s16_to_float_init_simd();
|
||||
convert_float_to_s16_init_simd();
|
||||
audio_convert_init_simd();
|
||||
|
||||
/* Accomodate rewind since at some point we might have two full buffers. */
|
||||
outsamples_max = max_bufsamples * AUDIO_MAX_RATIO *
|
||||
settings->slowmotion_ratio;
|
||||
|
||||
audio_driver_data.output_samples.conv_buf =
|
||||
(int16_t*)malloc(outsamples_max * sizeof(int16_t));
|
||||
/* Used for recording even if audio isn't enabled. */
|
||||
retro_assert(audio_driver_data.output_samples.conv_buf != NULL);
|
||||
retro_assert(audio_driver_data.output_samples.conv_buf =
|
||||
(int16_t*)malloc(outsamples_max * sizeof(int16_t)));
|
||||
|
||||
if (!audio_driver_data.output_samples.conv_buf)
|
||||
goto error;
|
||||
@@ -331,9 +323,8 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
|
||||
|
||||
/* Needs to be able to hold full content of a full max_bufsamples
|
||||
* in addition to its own. */
|
||||
audio_driver_data.rewind.buf = (int16_t*)malloc
|
||||
(max_bufsamples * sizeof(int16_t));
|
||||
retro_assert(audio_driver_data.rewind.buf != NULL);
|
||||
retro_assert(audio_driver_data.rewind.buf = (int16_t*)
|
||||
malloc(max_bufsamples * sizeof(int16_t)));
|
||||
|
||||
if (!audio_driver_data.rewind.buf)
|
||||
goto error;
|
||||
@@ -342,16 +333,16 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
|
||||
|
||||
if (!settings->audio.enable)
|
||||
{
|
||||
audio_driver_unset_active();
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
audio_driver_find_driver();
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_FIND_DRIVER, NULL);
|
||||
#ifdef HAVE_THREADS
|
||||
if (audio_cb_inited)
|
||||
{
|
||||
RARCH_LOG("Starting threaded audio driver ...\n");
|
||||
if (!audio_init_thread(
|
||||
if (!rarch_threaded_audio_init(
|
||||
¤t_audio,
|
||||
&audio_driver_context_audio_data,
|
||||
*settings->audio.device ? settings->audio.device : NULL,
|
||||
@@ -359,7 +350,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
|
||||
current_audio))
|
||||
{
|
||||
RARCH_ERR("Cannot open threaded audio driver ... Exiting ...\n");
|
||||
retroarch_fail(1, "audio_driver_init_internal()");
|
||||
retro_fail(1, "init_audio()");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -374,17 +365,17 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
|
||||
if (!audio_driver_context_audio_data)
|
||||
{
|
||||
RARCH_ERR("Failed to initialize audio driver. Will continue without audio.\n");
|
||||
audio_driver_unset_active();
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL);
|
||||
}
|
||||
|
||||
audio_driver_data.use_float = false;
|
||||
if ( audio_driver_is_active()
|
||||
if ( audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL)
|
||||
&& current_audio->use_float(audio_driver_context_audio_data))
|
||||
audio_driver_data.use_float = true;
|
||||
|
||||
if (!settings->audio.sync && audio_driver_is_active())
|
||||
if (!settings->audio.sync && audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL))
|
||||
{
|
||||
command_event(CMD_EVENT_AUDIO_SET_NONBLOCKING_STATE, NULL);
|
||||
event_cmd_ctl(EVENT_CMD_AUDIO_SET_NONBLOCKING_STATE, NULL);
|
||||
audio_driver_data.chunk.size = audio_driver_data.chunk.nonblock_size;
|
||||
}
|
||||
|
||||
@@ -400,16 +391,15 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
|
||||
audio_driver_data.audio_rate.source_ratio.current =
|
||||
(double)settings->audio.out_rate / audio_driver_data.audio_rate.input;
|
||||
|
||||
if (!audio_driver_init_resampler())
|
||||
if (!audio_driver_ctl(RARCH_AUDIO_CTL_RESAMPLER_INIT, NULL))
|
||||
{
|
||||
RARCH_ERR("Failed to initialize resampler \"%s\".\n",
|
||||
settings->audio.resampler);
|
||||
audio_driver_unset_active();
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL);
|
||||
}
|
||||
|
||||
audio_driver_data.data = (float*)
|
||||
malloc(max_bufsamples * sizeof(float));
|
||||
retro_assert(audio_driver_data.data != NULL);
|
||||
retro_assert(audio_driver_data.data = (float*)
|
||||
malloc(max_bufsamples * sizeof(float)));
|
||||
|
||||
if (!audio_driver_data.data)
|
||||
goto error;
|
||||
@@ -418,10 +408,8 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
|
||||
|
||||
retro_assert(settings->audio.out_rate <
|
||||
audio_driver_data.audio_rate.input * AUDIO_MAX_RATIO);
|
||||
|
||||
audio_driver_data.output_samples.buf = (float*)
|
||||
malloc(outsamples_max * sizeof(float));
|
||||
retro_assert(audio_driver_data.output_samples.buf != NULL);
|
||||
retro_assert(audio_driver_data.output_samples.buf = (float*)
|
||||
malloc(outsamples_max * sizeof(float)));
|
||||
|
||||
if (!audio_driver_data.output_samples.buf)
|
||||
goto error;
|
||||
@@ -429,7 +417,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
|
||||
audio_driver_data.audio_rate.control = false;
|
||||
if (
|
||||
!audio_cb_inited
|
||||
&& audio_driver_is_active()
|
||||
&& audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL)
|
||||
&& settings->audio.rate_control
|
||||
)
|
||||
{
|
||||
@@ -445,22 +433,22 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
|
||||
RARCH_WARN("Audio rate control was desired, but driver does not support needed features.\n");
|
||||
}
|
||||
|
||||
command_event(CMD_EVENT_DSP_FILTER_INIT, NULL);
|
||||
event_cmd_ctl(EVENT_CMD_DSP_FILTER_INIT, NULL);
|
||||
|
||||
audio_driver_data.free_samples.count = 0;
|
||||
|
||||
/* Threaded driver is initially stopped. */
|
||||
if (
|
||||
audio_driver_is_active()
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL)
|
||||
&& !settings->audio.mute_enable
|
||||
&& audio_cb_inited
|
||||
)
|
||||
audio_driver_start();
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_START, NULL);
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
return audio_driver_deinit();
|
||||
return audio_driver_ctl(RARCH_AUDIO_CTL_DEINIT, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -500,7 +488,7 @@ void audio_driver_set_nonblocking_state(bool enable)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
if (
|
||||
audio_driver_is_active()
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL)
|
||||
&& audio_driver_context_audio_data
|
||||
)
|
||||
current_audio->set_nonblock_state(audio_driver_context_audio_data,
|
||||
@@ -538,16 +526,16 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
|
||||
|
||||
if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) || settings->audio.mute_enable)
|
||||
return true;
|
||||
if (!audio_driver_is_active())
|
||||
if (!audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL))
|
||||
return false;
|
||||
if (!audio_driver_data.data)
|
||||
return false;
|
||||
|
||||
performance_counter_init(&audio_convert_s16, "audio_convert_s16");
|
||||
performance_counter_start(&audio_convert_s16);
|
||||
convert_s16_to_float(audio_driver_data.data, data, samples,
|
||||
rarch_perf_init(&audio_convert_s16, "audio_convert_s16");
|
||||
retro_perf_start(&audio_convert_s16);
|
||||
audio_convert_s16_to_float(audio_driver_data.data, data, samples,
|
||||
audio_driver_data.volume_gain);
|
||||
performance_counter_stop(&audio_convert_s16);
|
||||
retro_perf_stop(&audio_convert_s16);
|
||||
|
||||
src_data.data_in = audio_driver_data.data;
|
||||
src_data.input_frames = samples >> 1;
|
||||
@@ -557,10 +545,10 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
|
||||
|
||||
if (audio_driver_data.dsp)
|
||||
{
|
||||
performance_counter_init(&audio_dsp, "audio_dsp");
|
||||
performance_counter_start(&audio_dsp);
|
||||
rarch_perf_init(&audio_dsp, "audio_dsp");
|
||||
retro_perf_start(&audio_dsp);
|
||||
rarch_dsp_filter_process(audio_driver_data.dsp, &dsp_data);
|
||||
performance_counter_stop(&audio_dsp);
|
||||
retro_perf_stop(&audio_dsp);
|
||||
|
||||
if (dsp_data.output)
|
||||
{
|
||||
@@ -579,18 +567,18 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
|
||||
if (runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL))
|
||||
src_data.ratio *= settings->slowmotion_ratio;
|
||||
|
||||
audio_driver_process_resampler(&src_data);
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_RESAMPLER_PROCESS, &src_data);
|
||||
|
||||
output_data = audio_driver_data.output_samples.buf;
|
||||
output_frames = src_data.output_frames;
|
||||
|
||||
if (!audio_driver_data.use_float)
|
||||
{
|
||||
performance_counter_init(&audio_convert_float, "audio_convert_float");
|
||||
performance_counter_start(&audio_convert_float);
|
||||
convert_float_to_s16(audio_driver_data.output_samples.conv_buf,
|
||||
rarch_perf_init(&audio_convert_float, "audio_convert_float");
|
||||
retro_perf_start(&audio_convert_float);
|
||||
audio_convert_float_to_s16(audio_driver_data.output_samples.conv_buf,
|
||||
(const float*)output_data, output_frames * 2);
|
||||
performance_counter_stop(&audio_convert_float);
|
||||
retro_perf_stop(&audio_convert_float);
|
||||
|
||||
output_data = audio_driver_data.output_samples.conv_buf;
|
||||
output_size = sizeof(int16_t);
|
||||
@@ -599,7 +587,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
|
||||
if (current_audio->write(audio_driver_context_audio_data,
|
||||
output_data, output_frames * output_size * 2) < 0)
|
||||
{
|
||||
audio_driver_unset_active();
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -712,7 +700,8 @@ void audio_driver_set_buffer_size(size_t bufsize)
|
||||
audio_driver_data.driver_buffer_size = bufsize;
|
||||
}
|
||||
|
||||
void audio_driver_monitor_adjust_system_rates(void)
|
||||
|
||||
static void audio_monitor_adjust_system_rates(void)
|
||||
{
|
||||
float timing_skew;
|
||||
settings_t *settings = config_get_ptr();
|
||||
@@ -735,7 +724,7 @@ void audio_driver_monitor_adjust_system_rates(void)
|
||||
audio_driver_data.audio_rate.input);
|
||||
}
|
||||
|
||||
void audio_driver_setup_rewind(void)
|
||||
static void audio_driver_setup_rewind(void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
@@ -754,7 +743,7 @@ void audio_driver_setup_rewind(void)
|
||||
audio_driver_data.data_ptr = 0;
|
||||
}
|
||||
|
||||
bool audio_driver_find_driver(void)
|
||||
static bool find_audio_driver(void)
|
||||
{
|
||||
int i;
|
||||
driver_ctx_info_t drv;
|
||||
@@ -782,244 +771,172 @@ bool audio_driver_find_driver(void)
|
||||
current_audio = (const audio_driver_t*)audio_driver_find_handle(0);
|
||||
|
||||
if (!current_audio)
|
||||
retroarch_fail(1, "audio_driver_find()");
|
||||
retro_fail(1, "find_audio_driver()");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void audio_driver_deinit_resampler(void)
|
||||
bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data)
|
||||
{
|
||||
rarch_resampler_freep(&audio_driver_resampler,
|
||||
&audio_driver_resampler_data);
|
||||
}
|
||||
static struct retro_audio_callback audio_callback;
|
||||
static struct retro_perf_counter resampler_proc = {0};
|
||||
static const rarch_resampler_t *audio_driver_resampler = NULL;
|
||||
static void *audio_driver_resampler_data = NULL;
|
||||
static bool audio_driver_active = false;
|
||||
static bool audio_driver_data_own = false;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
bool audio_driver_free_devices_list(void)
|
||||
{
|
||||
if (!current_audio || !current_audio->device_list_free
|
||||
|| !audio_driver_context_audio_data)
|
||||
return false;
|
||||
current_audio->device_list_free(audio_driver_context_audio_data,
|
||||
audio_driver_devices_list);
|
||||
audio_driver_devices_list = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool audio_driver_new_devices_list(void)
|
||||
{
|
||||
if (!current_audio || !current_audio->device_list_new
|
||||
|| !audio_driver_context_audio_data)
|
||||
return false;
|
||||
audio_driver_devices_list = (struct string_list*)
|
||||
current_audio->device_list_new(audio_driver_context_audio_data);
|
||||
if (!audio_driver_devices_list)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool audio_driver_init(void)
|
||||
{
|
||||
return audio_driver_init_internal(audio_callback.callback != NULL);
|
||||
}
|
||||
|
||||
bool audio_driver_get_devices_list(void **data)
|
||||
{
|
||||
struct string_list**ptr = (struct string_list**)data;
|
||||
if (!ptr)
|
||||
return false;
|
||||
*ptr = audio_driver_devices_list;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool audio_driver_init_resampler(void)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
return rarch_resampler_realloc(
|
||||
&audio_driver_resampler_data,
|
||||
&audio_driver_resampler,
|
||||
settings->audio.resampler,
|
||||
audio_driver_data.audio_rate.source_ratio.original);
|
||||
}
|
||||
|
||||
void audio_driver_process_resampler(struct resampler_data *data)
|
||||
{
|
||||
performance_counter_init(&resampler_proc, "resampler_proc");
|
||||
performance_counter_start(&resampler_proc);
|
||||
rarch_resampler_process(audio_driver_resampler,
|
||||
audio_driver_resampler_data, data);
|
||||
performance_counter_stop(&resampler_proc);
|
||||
}
|
||||
|
||||
bool audio_driver_deinit(void)
|
||||
{
|
||||
audio_driver_free_devices_list();
|
||||
if (!uninit_audio())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool audio_driver_set_callback(const void *data)
|
||||
{
|
||||
const struct retro_audio_callback *cb = (const struct retro_audio_callback*)data;
|
||||
#ifdef HAVE_NETPLAY
|
||||
global_t *global = global_get_ptr();
|
||||
#endif
|
||||
|
||||
if (recording_driver_get_data_ptr()) /* A/V sync is a must. */
|
||||
return false;
|
||||
|
||||
#ifdef HAVE_NETPLAY
|
||||
if (global->netplay.enable)
|
||||
return false;
|
||||
#endif
|
||||
if (cb)
|
||||
audio_callback = *cb;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool audio_driver_enable_callback(void)
|
||||
{
|
||||
if (!audio_driver_has_callback())
|
||||
return false;
|
||||
if (audio_callback.set_state)
|
||||
audio_callback.set_state(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool audio_driver_disable_callback(void)
|
||||
{
|
||||
if (!audio_driver_has_callback())
|
||||
return false;
|
||||
|
||||
if (audio_callback.set_state)
|
||||
audio_callback.set_state(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Sets audio monitor rate to new value. */
|
||||
void audio_driver_monitor_set_rate(void)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
double new_src_ratio = (double)settings->audio.out_rate /
|
||||
audio_driver_data.audio_rate.input;
|
||||
|
||||
audio_driver_data.audio_rate.source_ratio.original = new_src_ratio;
|
||||
audio_driver_data.audio_rate.source_ratio.current = new_src_ratio;
|
||||
}
|
||||
|
||||
bool audio_driver_callback(void)
|
||||
{
|
||||
if (!audio_driver_has_callback())
|
||||
return false;
|
||||
|
||||
if (audio_callback.callback)
|
||||
audio_callback.callback();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool audio_driver_has_callback(void)
|
||||
{
|
||||
return audio_callback.callback;
|
||||
}
|
||||
|
||||
bool audio_driver_toggle_mute(void)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
if (!audio_driver_context_audio_data)
|
||||
return false;
|
||||
if (!audio_driver_is_active())
|
||||
return false;
|
||||
|
||||
settings->audio.mute_enable = !settings->audio.mute_enable;
|
||||
|
||||
if (settings->audio.mute_enable)
|
||||
command_event(CMD_EVENT_AUDIO_STOP, NULL);
|
||||
else if (!command_event(CMD_EVENT_AUDIO_START, NULL))
|
||||
switch (state)
|
||||
{
|
||||
audio_driver_unset_active();
|
||||
return false;
|
||||
case RARCH_AUDIO_CTL_RESAMPLER_DEINIT:
|
||||
rarch_resampler_freep(&audio_driver_resampler,
|
||||
&audio_driver_resampler_data);
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_RESAMPLER_INIT:
|
||||
return rarch_resampler_realloc(
|
||||
&audio_driver_resampler_data,
|
||||
&audio_driver_resampler,
|
||||
settings->audio.resampler,
|
||||
audio_driver_data.audio_rate.source_ratio.original);
|
||||
case RARCH_AUDIO_CTL_RESAMPLER_PROCESS:
|
||||
rarch_perf_init(&resampler_proc, "resampler_proc");
|
||||
retro_perf_start(&resampler_proc);
|
||||
rarch_resampler_process(audio_driver_resampler,
|
||||
audio_driver_resampler_data,
|
||||
(struct resampler_data*)data);
|
||||
retro_perf_stop(&resampler_proc);
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_INIT:
|
||||
return init_audio(audio_callback.callback != NULL);
|
||||
case RARCH_AUDIO_CTL_DESTROY:
|
||||
audio_driver_active = false;
|
||||
audio_driver_data_own = false;
|
||||
current_audio = NULL;
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_DESTROY_DATA:
|
||||
audio_driver_context_audio_data = NULL;
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_DEINIT:
|
||||
if (!uninit_audio())
|
||||
return false;
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_SETUP_REWIND:
|
||||
audio_driver_setup_rewind();
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_SET_CALLBACK_ENABLE:
|
||||
if (!audio_driver_ctl(RARCH_AUDIO_CTL_HAS_CALLBACK, NULL))
|
||||
return false;
|
||||
if (audio_callback.set_state)
|
||||
audio_callback.set_state(true);
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_SET_CALLBACK_DISABLE:
|
||||
if (!audio_driver_ctl(RARCH_AUDIO_CTL_HAS_CALLBACK, NULL))
|
||||
return false;
|
||||
|
||||
if (audio_callback.set_state)
|
||||
audio_callback.set_state(false);
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_HAS_CALLBACK:
|
||||
return audio_callback.callback;
|
||||
case RARCH_AUDIO_CTL_CALLBACK:
|
||||
if (!audio_driver_ctl(RARCH_AUDIO_CTL_HAS_CALLBACK, NULL))
|
||||
return false;
|
||||
|
||||
if (audio_callback.callback)
|
||||
audio_callback.callback();
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_UNSET_CALLBACK:
|
||||
audio_callback.callback = NULL;
|
||||
audio_callback.set_state = NULL;
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_SET_CALLBACK:
|
||||
{
|
||||
const struct retro_audio_callback *cb =
|
||||
(const struct retro_audio_callback*)data;
|
||||
|
||||
if (recording_driver_get_data_ptr()) /* A/V sync is a must. */
|
||||
return false;
|
||||
|
||||
#ifdef HAVE_NETPLAY
|
||||
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
|
||||
return false;
|
||||
#endif
|
||||
if (cb)
|
||||
audio_callback = *cb;
|
||||
}
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES:
|
||||
audio_monitor_adjust_system_rates();
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_MONITOR_SET_REFRESH_RATE:
|
||||
{
|
||||
double new_src_ratio = (double)settings->audio.out_rate /
|
||||
audio_driver_data.audio_rate.input;
|
||||
|
||||
audio_driver_data.audio_rate.source_ratio.original = new_src_ratio;
|
||||
audio_driver_data.audio_rate.source_ratio.current = new_src_ratio;
|
||||
}
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_MUTE_TOGGLE:
|
||||
if (!audio_driver_context_audio_data)
|
||||
return false;
|
||||
if (!audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL))
|
||||
return false;
|
||||
|
||||
settings->audio.mute_enable = !settings->audio.mute_enable;
|
||||
|
||||
if (settings->audio.mute_enable)
|
||||
event_cmd_ctl(EVENT_CMD_AUDIO_STOP, NULL);
|
||||
else if (!event_cmd_ctl(EVENT_CMD_AUDIO_START, NULL))
|
||||
{
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_ALIVE:
|
||||
if (!current_audio || !current_audio->alive
|
||||
|| !audio_driver_context_audio_data)
|
||||
return false;
|
||||
return current_audio->alive(audio_driver_context_audio_data);
|
||||
case RARCH_AUDIO_CTL_START:
|
||||
if (!current_audio || !current_audio->start
|
||||
|| !audio_driver_context_audio_data)
|
||||
return false;
|
||||
return current_audio->start(audio_driver_context_audio_data);
|
||||
case RARCH_AUDIO_CTL_STOP:
|
||||
if (!current_audio || !current_audio->stop
|
||||
|| !audio_driver_context_audio_data)
|
||||
return false;
|
||||
return current_audio->stop(audio_driver_context_audio_data);
|
||||
case RARCH_AUDIO_CTL_FIND_DRIVER:
|
||||
return find_audio_driver();
|
||||
case RARCH_AUDIO_CTL_SET_OWN_DRIVER:
|
||||
audio_driver_data_own = true;
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_UNSET_OWN_DRIVER:
|
||||
audio_driver_data_own = false;
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_OWNS_DRIVER:
|
||||
return audio_driver_data_own;
|
||||
case RARCH_AUDIO_CTL_SET_ACTIVE:
|
||||
audio_driver_active = true;
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_UNSET_ACTIVE:
|
||||
audio_driver_active = false;
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_IS_ACTIVE:
|
||||
return audio_driver_active;
|
||||
case RARCH_AUDIO_CTL_FRAME_IS_REVERSE:
|
||||
/* We just rewound. Flush rewind audio buffer. */
|
||||
audio_driver_flush(
|
||||
audio_driver_data.rewind.buf + audio_driver_data.rewind.ptr,
|
||||
audio_driver_data.rewind.size - audio_driver_data.rewind.ptr);
|
||||
break;
|
||||
case RARCH_AUDIO_CTL_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool audio_driver_start(void)
|
||||
{
|
||||
if (!current_audio || !current_audio->start
|
||||
|| !audio_driver_context_audio_data)
|
||||
return false;
|
||||
return current_audio->start(audio_driver_context_audio_data);
|
||||
}
|
||||
|
||||
bool audio_driver_stop(void)
|
||||
{
|
||||
if (!current_audio || !current_audio->stop
|
||||
|| !audio_driver_context_audio_data)
|
||||
return false;
|
||||
return current_audio->stop(audio_driver_context_audio_data);
|
||||
}
|
||||
|
||||
void audio_driver_unset_callback(void)
|
||||
{
|
||||
audio_callback.callback = NULL;
|
||||
audio_callback.set_state = NULL;
|
||||
}
|
||||
|
||||
bool audio_driver_alive(void)
|
||||
{
|
||||
if (!current_audio || !current_audio->alive
|
||||
|| !audio_driver_context_audio_data)
|
||||
return false;
|
||||
return current_audio->alive(audio_driver_context_audio_data);
|
||||
}
|
||||
|
||||
void audio_driver_frame_is_reverse(void)
|
||||
{
|
||||
/* We just rewound. Flush rewind audio buffer. */
|
||||
audio_driver_flush(
|
||||
audio_driver_data.rewind.buf + audio_driver_data.rewind.ptr,
|
||||
audio_driver_data.rewind.size - audio_driver_data.rewind.ptr);
|
||||
}
|
||||
|
||||
void audio_driver_destroy_data(void)
|
||||
{
|
||||
audio_driver_context_audio_data = NULL;
|
||||
}
|
||||
|
||||
void audio_driver_set_own_driver(void)
|
||||
{
|
||||
audio_driver_data_own = true;
|
||||
}
|
||||
|
||||
void audio_driver_unset_own_driver(void)
|
||||
{
|
||||
audio_driver_data_own = false;
|
||||
}
|
||||
|
||||
bool audio_driver_owns_driver(void)
|
||||
{
|
||||
return audio_driver_data_own;
|
||||
}
|
||||
|
||||
void audio_driver_set_active(void)
|
||||
{
|
||||
audio_driver_active = true;
|
||||
}
|
||||
|
||||
void audio_driver_unset_active(void)
|
||||
{
|
||||
audio_driver_active = false;
|
||||
}
|
||||
|
||||
bool audio_driver_is_active(void)
|
||||
{
|
||||
return audio_driver_active;
|
||||
}
|
||||
|
||||
void audio_driver_destroy(void)
|
||||
{
|
||||
audio_driver_active = false;
|
||||
audio_driver_data_own = false;
|
||||
current_audio = NULL;
|
||||
}
|
||||
+40
-79
@@ -20,21 +20,46 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
|
||||
#include "audio_dsp_filter.h"
|
||||
#include "audio_resampler_driver.h"
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AUDIO_CHUNK_SIZE_BLOCKING 512
|
||||
|
||||
/* So we don't get complete line-noise when fast-forwarding audio. */
|
||||
#define AUDIO_CHUNK_SIZE_NONBLOCKING 2048
|
||||
|
||||
#define AUDIO_MAX_RATIO 16
|
||||
enum rarch_audio_ctl_state
|
||||
{
|
||||
RARCH_AUDIO_CTL_NONE = 0,
|
||||
RARCH_AUDIO_CTL_INIT,
|
||||
RARCH_AUDIO_CTL_DEINIT,
|
||||
RARCH_AUDIO_CTL_DESTROY,
|
||||
RARCH_AUDIO_CTL_DESTROY_DATA,
|
||||
RARCH_AUDIO_CTL_START,
|
||||
RARCH_AUDIO_CTL_STOP,
|
||||
RARCH_AUDIO_CTL_FIND_DRIVER,
|
||||
RARCH_AUDIO_CTL_SETUP_REWIND,
|
||||
/* Sets audio monitor refresh rate to new value. */
|
||||
RARCH_AUDIO_CTL_MONITOR_SET_REFRESH_RATE,
|
||||
RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES,
|
||||
RARCH_AUDIO_CTL_MUTE_TOGGLE,
|
||||
RARCH_AUDIO_CTL_SET_CALLBACK_ENABLE,
|
||||
RARCH_AUDIO_CTL_SET_CALLBACK_DISABLE,
|
||||
RARCH_AUDIO_CTL_SET_CALLBACK,
|
||||
RARCH_AUDIO_CTL_UNSET_CALLBACK,
|
||||
RARCH_AUDIO_CTL_CALLBACK,
|
||||
RARCH_AUDIO_CTL_HAS_CALLBACK,
|
||||
RARCH_AUDIO_CTL_ALIVE,
|
||||
RARCH_AUDIO_CTL_FRAME_IS_REVERSE,
|
||||
RARCH_AUDIO_CTL_SET_OWN_DRIVER,
|
||||
RARCH_AUDIO_CTL_UNSET_OWN_DRIVER,
|
||||
RARCH_AUDIO_CTL_OWNS_DRIVER,
|
||||
RARCH_AUDIO_CTL_SET_ACTIVE,
|
||||
RARCH_AUDIO_CTL_UNSET_ACTIVE,
|
||||
RARCH_AUDIO_CTL_IS_ACTIVE,
|
||||
RARCH_AUDIO_CTL_RESAMPLER_DEINIT,
|
||||
RARCH_AUDIO_CTL_RESAMPLER_INIT,
|
||||
RARCH_AUDIO_CTL_RESAMPLER_PROCESS
|
||||
};
|
||||
|
||||
typedef struct audio_driver
|
||||
{
|
||||
@@ -75,45 +100,14 @@ typedef struct audio_driver
|
||||
/* Human-readable identifier. */
|
||||
const char *ident;
|
||||
|
||||
/* Optional. Get audio device list (allocates, caller has to free this) */
|
||||
void *(*device_list_new)(void *data);
|
||||
|
||||
/* Optional. Frees audio device list */
|
||||
void (*device_list_free)(void *data, void *data2);
|
||||
|
||||
/* Optional. */
|
||||
size_t (*write_avail)(void *data);
|
||||
|
||||
size_t (*buffer_size)(void *data);
|
||||
} audio_driver_t;
|
||||
|
||||
void audio_driver_destroy_data(void);
|
||||
|
||||
void audio_driver_set_own_driver(void);
|
||||
|
||||
void audio_driver_unset_own_driver(void);
|
||||
|
||||
void audio_driver_set_active(void);
|
||||
|
||||
void audio_driver_unset_active(void);
|
||||
|
||||
bool audio_driver_is_active(void);
|
||||
|
||||
void audio_driver_destroy(void);
|
||||
|
||||
void audio_driver_deinit_resampler(void);
|
||||
|
||||
bool audio_driver_init_resampler(void);
|
||||
|
||||
void audio_driver_process_resampler(struct resampler_data *data);
|
||||
|
||||
bool audio_driver_free_devices_list(void);
|
||||
|
||||
bool audio_driver_new_devices_list(void);
|
||||
|
||||
bool audio_driver_enable_callback(void);
|
||||
|
||||
bool audio_driver_disable_callback(void);
|
||||
bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data);
|
||||
|
||||
/**
|
||||
* audio_driver_find_handle:
|
||||
@@ -160,41 +154,6 @@ void audio_driver_dsp_filter_init(const char *device);
|
||||
|
||||
void audio_driver_set_buffer_size(size_t bufsize);
|
||||
|
||||
bool audio_driver_get_devices_list(void **ptr);
|
||||
|
||||
void audio_driver_setup_rewind(void);
|
||||
|
||||
void audio_driver_monitor_adjust_system_rates(void);
|
||||
|
||||
bool audio_driver_set_callback(const void *data);
|
||||
|
||||
bool audio_driver_callback(void);
|
||||
|
||||
bool audio_driver_has_callback(void);
|
||||
|
||||
/* Sets audio monitor rate to new value. */
|
||||
void audio_driver_monitor_set_rate(void);
|
||||
|
||||
bool audio_driver_find_driver(void);
|
||||
|
||||
bool audio_driver_toggle_mute(void);
|
||||
|
||||
bool audio_driver_start(void);
|
||||
|
||||
bool audio_driver_stop(void);
|
||||
|
||||
bool audio_driver_owns_driver(void);
|
||||
|
||||
void audio_driver_unset_callback(void);
|
||||
|
||||
void audio_driver_frame_is_reverse(void);
|
||||
|
||||
bool audio_driver_alive(void);
|
||||
|
||||
bool audio_driver_deinit(void);
|
||||
|
||||
bool audio_driver_init(void);
|
||||
|
||||
extern audio_driver_t audio_rsound;
|
||||
extern audio_driver_t audio_oss;
|
||||
extern audio_driver_t audio_alsa;
|
||||
@@ -217,6 +176,8 @@ extern audio_driver_t audio_ctr_dsp;
|
||||
extern audio_driver_t audio_rwebaudio;
|
||||
extern audio_driver_t audio_null;
|
||||
|
||||
RETRO_END_DECLS
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -22,15 +22,14 @@
|
||||
#include <dynamic/dylib.h>
|
||||
|
||||
#include <file/file_path.h>
|
||||
#include <lists/dir_list.h>
|
||||
#include <features/features_cpu.h>
|
||||
#include <file/config_file_userdata.h>
|
||||
#include <file/dir_list.h>
|
||||
|
||||
#include "audio_dsp_filter.h"
|
||||
#include "audio_filters/dspfilter.h"
|
||||
|
||||
#include "../config_file_userdata.h"
|
||||
#include "../frontend/frontend_driver.h"
|
||||
#include "../performance_counters.h"
|
||||
#include "../performance.h"
|
||||
#include "../dynamic.h"
|
||||
|
||||
struct rarch_dsp_plug
|
||||
@@ -147,7 +146,7 @@ static const dspfilter_get_implementation_t dsp_plugs_builtin[] = {
|
||||
static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list)
|
||||
{
|
||||
unsigned i;
|
||||
dspfilter_simd_mask_t mask = cpu_features_get();
|
||||
dspfilter_simd_mask_t mask = retro_get_cpu_features();
|
||||
|
||||
(void)list;
|
||||
|
||||
@@ -171,7 +170,7 @@ static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list)
|
||||
static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list)
|
||||
{
|
||||
unsigned i;
|
||||
dspfilter_simd_mask_t mask = cpu_features_get();
|
||||
dspfilter_simd_mask_t mask = retro_get_cpu_features();
|
||||
|
||||
for (i = 0; i < list->size; i++)
|
||||
{
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
#ifndef __AUDIO_DSP_FILTER_H__
|
||||
#define __AUDIO_DSP_FILTER_H__
|
||||
|
||||
#include <retro_common_api.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct rarch_dsp_filter rarch_dsp_filter_t;
|
||||
|
||||
@@ -41,7 +41,9 @@ struct rarch_dsp_data
|
||||
void rarch_dsp_filter_process(rarch_dsp_filter_t *dsp,
|
||||
struct rarch_dsp_data *data);
|
||||
|
||||
RETRO_END_DECLS
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
#ifndef DSPFILTER_API_H__
|
||||
#define DSPFILTER_API_H__
|
||||
|
||||
#include <retro_common_api.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DSPFILTER_SIMD_SSE (1 << 0)
|
||||
#define DSPFILTER_SIMD_SSE2 (1 << 1)
|
||||
@@ -177,6 +177,8 @@ struct dspfilter_implementation
|
||||
const char *short_ident;
|
||||
};
|
||||
|
||||
RETRO_END_DECLS
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -17,10 +17,61 @@
|
||||
#define RARCH_FFT_H__
|
||||
|
||||
#include <retro_inline.h>
|
||||
#include <math/complex.h>
|
||||
|
||||
typedef struct fft fft_t;
|
||||
|
||||
// C99 <complex.h> would be nice.
|
||||
typedef struct
|
||||
{
|
||||
float real;
|
||||
float imag;
|
||||
} fft_complex_t;
|
||||
|
||||
static INLINE fft_complex_t fft_complex_mul(fft_complex_t a,
|
||||
fft_complex_t b)
|
||||
{
|
||||
fft_complex_t out = {
|
||||
a.real * b.real - a.imag * b.imag,
|
||||
a.imag * b.real + a.real * b.imag,
|
||||
};
|
||||
|
||||
return out;
|
||||
|
||||
}
|
||||
|
||||
static INLINE fft_complex_t fft_complex_add(fft_complex_t a,
|
||||
fft_complex_t b)
|
||||
{
|
||||
fft_complex_t out = {
|
||||
a.real + b.real,
|
||||
a.imag + b.imag,
|
||||
};
|
||||
|
||||
return out;
|
||||
|
||||
}
|
||||
|
||||
static INLINE fft_complex_t fft_complex_sub(fft_complex_t a,
|
||||
fft_complex_t b)
|
||||
{
|
||||
fft_complex_t out = {
|
||||
a.real - b.real,
|
||||
a.imag - b.imag,
|
||||
};
|
||||
|
||||
return out;
|
||||
|
||||
}
|
||||
|
||||
static INLINE fft_complex_t fft_complex_conj(fft_complex_t a)
|
||||
{
|
||||
fft_complex_t out = {
|
||||
a.real, -a.imag,
|
||||
};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
fft_t *fft_new(unsigned block_size_log2);
|
||||
|
||||
void fft_free(fft_t *fft);
|
||||
|
||||
@@ -16,15 +16,16 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <file/config_file_userdata.h>
|
||||
#include <string/stdstring.h>
|
||||
#include <features/features_cpu.h>
|
||||
|
||||
#include "audio_resampler_driver.h"
|
||||
#include "../config_file_userdata.h"
|
||||
#ifdef RARCH_INTERNAL
|
||||
#include "../performance_counters.h"
|
||||
#include "../performance.h"
|
||||
#endif
|
||||
#ifndef DONT_HAVE_STRING_LIST
|
||||
#include "../string_list_special.h"
|
||||
#endif
|
||||
#include "../list_special.h"
|
||||
|
||||
static const rarch_resampler_t *resampler_drivers[] = {
|
||||
&sinc_resampler,
|
||||
@@ -92,6 +93,7 @@ const char *audio_resampler_driver_find_ident(int idx)
|
||||
return drv->ident;
|
||||
}
|
||||
|
||||
#ifndef DONT_HAVE_STRING_LIST
|
||||
/**
|
||||
* config_get_audio_resampler_driver_options:
|
||||
*
|
||||
@@ -103,6 +105,7 @@ const char* config_get_audio_resampler_driver_options(void)
|
||||
{
|
||||
return char_list_new_special(STRING_LIST_AUDIO_RESAMPLER_DRIVERS, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* find_resampler_driver:
|
||||
@@ -123,9 +126,26 @@ static const rarch_resampler_t *find_resampler_driver(const char *ident)
|
||||
return resampler_drivers[0];
|
||||
}
|
||||
|
||||
#ifndef RARCH_INTERNAL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
retro_get_cpu_features_t perf_get_cpu_features_cb;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
static resampler_simd_mask_t resampler_get_cpu_features(void)
|
||||
{
|
||||
return cpu_features_get();
|
||||
#ifdef RARCH_INTERNAL
|
||||
return retro_get_cpu_features();
|
||||
#else
|
||||
return perf_get_cpu_features_cb();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,16 +18,16 @@
|
||||
#ifndef __AUDIO_RESAMPLER_DRIVER_H
|
||||
#define __AUDIO_RESAMPLER_DRIVER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
#include <libretro.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
#include <retro_miscellaneous.h>
|
||||
|
||||
#define RESAMPLER_SIMD_SSE (1 << 0)
|
||||
#define RESAMPLER_SIMD_SSE2 (1 << 1)
|
||||
@@ -200,6 +200,14 @@ bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend,
|
||||
(backend)->process(handle, data); \
|
||||
} while(0)
|
||||
|
||||
RETRO_END_DECLS
|
||||
#ifndef RARCH_INTERNAL
|
||||
#include "libretro.h"
|
||||
extern retro_get_cpu_features_t perf_get_cpu_features_cb;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <queues/fifo_queue.h>
|
||||
#include <queues/fifo_buffer.h>
|
||||
#include <rthreads/rthreads.h>
|
||||
|
||||
#include "audio_thread_wrapper.h"
|
||||
#include "../performance_counters.h"
|
||||
#include "../performance.h"
|
||||
#include "../verbosity.h"
|
||||
|
||||
typedef struct audio_thread
|
||||
@@ -81,8 +81,8 @@ static void audio_thread_loop(void *data)
|
||||
if (!thr->alive)
|
||||
{
|
||||
scond_signal(thr->cond);
|
||||
thr->stopped_ack = true;
|
||||
slock_unlock(thr->lock);
|
||||
thr->stopped_ack = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ static void audio_thread_loop(void *data)
|
||||
}
|
||||
|
||||
slock_unlock(thr->lock);
|
||||
audio_driver_callback();
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_CALLBACK, NULL);
|
||||
}
|
||||
|
||||
RARCH_LOG("[Audio Thread]: Tearing down driver.\n");
|
||||
@@ -190,7 +190,7 @@ static bool audio_thread_stop(void *data)
|
||||
audio_thread_block(thr);
|
||||
thr->is_paused = true;
|
||||
|
||||
audio_driver_disable_callback();
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_SET_CALLBACK_DISABLE, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -202,7 +202,7 @@ static bool audio_thread_start(void *data)
|
||||
if (!thr)
|
||||
return false;
|
||||
|
||||
audio_driver_enable_callback();
|
||||
audio_driver_ctl(RARCH_AUDIO_CTL_SET_CALLBACK_ENABLE, NULL);
|
||||
|
||||
thr->is_paused = false;
|
||||
audio_thread_unblock(thr);
|
||||
@@ -260,7 +260,7 @@ static const audio_driver_t audio_thread = {
|
||||
};
|
||||
|
||||
/**
|
||||
* audio_init_thread:
|
||||
* rarch_threaded_audio_init:
|
||||
* @out_driver : output driver
|
||||
* @out_data : output audio data
|
||||
* @device : audio device (optional)
|
||||
@@ -275,7 +275,7 @@ static const audio_driver_t audio_thread = {
|
||||
*
|
||||
* Returns: true (1) if successful, otherwise false (0).
|
||||
**/
|
||||
bool audio_init_thread(const audio_driver_t **out_driver,
|
||||
bool rarch_threaded_audio_init(const audio_driver_t **out_driver,
|
||||
void **out_data, const char *device, unsigned audio_out_rate,
|
||||
unsigned latency, const audio_driver_t *drv)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "audio_driver.h"
|
||||
|
||||
/**
|
||||
* audio_init_thread:
|
||||
* rarch_threaded_audio_init:
|
||||
* @out_driver : output driver
|
||||
* @out_data : output audio data
|
||||
* @device : audio device (optional)
|
||||
@@ -36,7 +36,7 @@
|
||||
*
|
||||
* Returns: true (1) if successful, otherwise false (0).
|
||||
**/
|
||||
bool audio_init_thread(const audio_driver_t **out_driver, void **out_data,
|
||||
bool rarch_threaded_audio_init(const audio_driver_t **out_driver, void **out_data,
|
||||
const char *device, unsigned out_rate, unsigned latency,
|
||||
const audio_driver_t *driver);
|
||||
|
||||
|
||||
@@ -0,0 +1,435 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2014-2016 - Ali Bouhlel ( [email protected] )
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <boolean.h>
|
||||
#include "audio_utils.h"
|
||||
|
||||
#if defined(__SSE2__)
|
||||
#include <emmintrin.h>
|
||||
#elif defined(__ALTIVEC__)
|
||||
#include <altivec.h>
|
||||
#endif
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
#include "../performance.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* audio_convert_s16_to_float_C:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* C implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_C(float *out,
|
||||
const int16_t *in, size_t samples, float gain)
|
||||
{
|
||||
size_t i;
|
||||
gain = gain / 0x8000;
|
||||
for (i = 0; i < samples; i++)
|
||||
out[i] = (float)in[i] * gain;
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_convert_float_to_s16_C:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
*
|
||||
* Converts audio samples from floating point
|
||||
* to signed integer 16-bit.
|
||||
*
|
||||
* C implementation callback function.
|
||||
**/
|
||||
void audio_convert_float_to_s16_C(int16_t *out,
|
||||
const float *in, size_t samples)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < samples; i++)
|
||||
{
|
||||
int32_t val = (int32_t)(in[i] * 0x8000);
|
||||
out[i] = (val > 0x7FFF) ? 0x7FFF :
|
||||
(val < -0x8000 ? -0x8000 : (int16_t)val);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__SSE2__)
|
||||
/**
|
||||
* audio_convert_s16_to_float_SSE2:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* SSE2 implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_SSE2(float *out,
|
||||
const int16_t *in, size_t samples, float gain)
|
||||
{
|
||||
size_t i;
|
||||
float fgain = gain / UINT32_C(0x80000000);
|
||||
__m128 factor = _mm_set1_ps(fgain);
|
||||
|
||||
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
|
||||
{
|
||||
__m128i input = _mm_loadu_si128((const __m128i *)in);
|
||||
__m128i regs_l = _mm_unpacklo_epi16(_mm_setzero_si128(), input);
|
||||
__m128i regs_r = _mm_unpackhi_epi16(_mm_setzero_si128(), input);
|
||||
__m128 output_l = _mm_mul_ps(_mm_cvtepi32_ps(regs_l), factor);
|
||||
__m128 output_r = _mm_mul_ps(_mm_cvtepi32_ps(regs_r), factor);
|
||||
|
||||
_mm_storeu_ps(out + 0, output_l);
|
||||
_mm_storeu_ps(out + 4, output_r);
|
||||
}
|
||||
|
||||
audio_convert_s16_to_float_C(out, in, samples - i, gain);
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_convert_float_to_s16_SSE2:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
*
|
||||
* Converts audio samples from floating point
|
||||
* to signed integer 16-bit.
|
||||
*
|
||||
* SSE2 implementation callback function.
|
||||
**/
|
||||
void audio_convert_float_to_s16_SSE2(int16_t *out,
|
||||
const float *in, size_t samples)
|
||||
{
|
||||
size_t i;
|
||||
__m128 factor = _mm_set1_ps((float)0x8000);
|
||||
|
||||
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
|
||||
{
|
||||
__m128 input_l = _mm_loadu_ps(in + 0);
|
||||
__m128 input_r = _mm_loadu_ps(in + 4);
|
||||
__m128 res_l = _mm_mul_ps(input_l, factor);
|
||||
__m128 res_r = _mm_mul_ps(input_r, factor);
|
||||
__m128i ints_l = _mm_cvtps_epi32(res_l);
|
||||
__m128i ints_r = _mm_cvtps_epi32(res_r);
|
||||
__m128i packed = _mm_packs_epi32(ints_l, ints_r);
|
||||
|
||||
_mm_storeu_si128((__m128i *)out, packed);
|
||||
}
|
||||
|
||||
audio_convert_float_to_s16_C(out, in, samples - i);
|
||||
}
|
||||
#elif defined(__ALTIVEC__)
|
||||
/**
|
||||
* audio_convert_s16_to_float_altivec:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* AltiVec implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_altivec(float *out,
|
||||
const int16_t *in, size_t samples, float gain)
|
||||
{
|
||||
size_t samples_in = samples;
|
||||
|
||||
/* Unaligned loads/store is a bit expensive, so we
|
||||
* optimize for the good path (very likely). */
|
||||
if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0)
|
||||
{
|
||||
size_t i;
|
||||
const vector float gain_vec = { gain, gain , gain, gain };
|
||||
const vector float zero_vec = { 0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
|
||||
{
|
||||
vector signed short input = vec_ld(0, in);
|
||||
vector signed int hi = vec_unpackh(input);
|
||||
vector signed int lo = vec_unpackl(input);
|
||||
vector float out_hi = vec_madd(vec_ctf(hi, 15), gain_vec, zero_vec);
|
||||
vector float out_lo = vec_madd(vec_ctf(lo, 15), gain_vec, zero_vec);
|
||||
|
||||
vec_st(out_hi, 0, out);
|
||||
vec_st(out_lo, 16, out);
|
||||
}
|
||||
|
||||
samples_in -= i;
|
||||
}
|
||||
audio_convert_s16_to_float_C(out, in, samples_in, gain);
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_convert_float_to_s16_altivec:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
*
|
||||
* Converts audio samples from floating point
|
||||
* to signed integer 16-bit.
|
||||
*
|
||||
* AltiVec implementation callback function.
|
||||
**/
|
||||
void audio_convert_float_to_s16_altivec(int16_t *out,
|
||||
const float *in, size_t samples)
|
||||
{
|
||||
int samples_in = samples;
|
||||
|
||||
/* Unaligned loads/store is a bit expensive,
|
||||
* so we optimize for the good path (very likely). */
|
||||
if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
|
||||
{
|
||||
vector float input0 = vec_ld( 0, in);
|
||||
vector float input1 = vec_ld(16, in);
|
||||
vector signed int result0 = vec_cts(input0, 15);
|
||||
vector signed int result1 = vec_cts(input1, 15);
|
||||
vec_st(vec_packs(result0, result1), 0, out);
|
||||
}
|
||||
|
||||
samples_in -= i;
|
||||
}
|
||||
audio_convert_float_to_s16_C(out, in, samples_in);
|
||||
}
|
||||
#elif defined(__ARM_NEON__) && !defined(VITA)
|
||||
/* Avoid potential hard-float/soft-float ABI issues. */
|
||||
void audio_convert_s16_float_asm(float *out, const int16_t *in,
|
||||
size_t samples, const float *gain);
|
||||
|
||||
/**
|
||||
* audio_convert_s16_to_float_neon:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* ARM NEON implementation callback function.
|
||||
**/
|
||||
static void audio_convert_s16_to_float_neon(float *out,
|
||||
const int16_t *in, size_t samples, float gain)
|
||||
{
|
||||
size_t aligned_samples = samples & ~7;
|
||||
if (aligned_samples)
|
||||
audio_convert_s16_float_asm(out, in, aligned_samples, &gain);
|
||||
|
||||
/* Could do all conversion in ASM, but keep it simple for now. */
|
||||
audio_convert_s16_to_float_C(out + aligned_samples, in + aligned_samples,
|
||||
samples - aligned_samples, gain);
|
||||
}
|
||||
|
||||
void audio_convert_float_s16_asm(int16_t *out, const float *in, size_t samples);
|
||||
|
||||
/**
|
||||
* audio_convert_float_to_s16_neon:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
*
|
||||
* Converts audio samples from floating point
|
||||
* to signed integer 16-bit.
|
||||
*
|
||||
* ARM NEON implementation callback function.
|
||||
**/
|
||||
static void audio_convert_float_to_s16_neon(int16_t *out,
|
||||
const float *in, size_t samples)
|
||||
{
|
||||
size_t aligned_samples = samples & ~7;
|
||||
if (aligned_samples)
|
||||
audio_convert_float_s16_asm(out, in, aligned_samples);
|
||||
|
||||
audio_convert_float_to_s16_C(out + aligned_samples, in + aligned_samples,
|
||||
samples - aligned_samples);
|
||||
}
|
||||
#elif defined(_MIPS_ARCH_ALLEGREX)
|
||||
|
||||
/**
|
||||
* audio_convert_s16_to_float_ALLEGREX:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* MIPS ALLEGREX implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_ALLEGREX(float *out,
|
||||
const int16_t *in, size_t samples, float gain)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
/* Make sure the buffer is 16 byte aligned, this should be the
|
||||
* default behaviour of malloc in the PSPSDK.
|
||||
* Only the output buffer can be assumed to be 16-byte aligned. */
|
||||
retro_assert(((uintptr_t)out & 0xf) == 0);
|
||||
#endif
|
||||
|
||||
size_t i;
|
||||
gain = gain / 0x8000;
|
||||
__asm__ (
|
||||
".set push \n"
|
||||
".set noreorder \n"
|
||||
"mtv %0, s200 \n"
|
||||
".set pop \n"
|
||||
::"r"(gain));
|
||||
|
||||
for (i = 0; i + 16 <= samples; i += 16)
|
||||
{
|
||||
__asm__ (
|
||||
".set push \n"
|
||||
".set noreorder \n"
|
||||
|
||||
"lv.s s100, 0(%0) \n"
|
||||
"lv.s s101, 4(%0) \n"
|
||||
"lv.s s110, 8(%0) \n"
|
||||
"lv.s s111, 12(%0) \n"
|
||||
"lv.s s120, 16(%0) \n"
|
||||
"lv.s s121, 20(%0) \n"
|
||||
"lv.s s130, 24(%0) \n"
|
||||
"lv.s s131, 28(%0) \n"
|
||||
|
||||
"vs2i.p c100, c100 \n"
|
||||
"vs2i.p c110, c110 \n"
|
||||
"vs2i.p c120, c120 \n"
|
||||
"vs2i.p c130, c130 \n"
|
||||
|
||||
"vi2f.q c100, c100, 16 \n"
|
||||
"vi2f.q c110, c110, 16 \n"
|
||||
"vi2f.q c120, c120, 16 \n"
|
||||
"vi2f.q c130, c130, 16 \n"
|
||||
|
||||
"vmscl.q e100, e100, s200 \n"
|
||||
|
||||
"sv.q c100, 0(%1) \n"
|
||||
"sv.q c110, 16(%1) \n"
|
||||
"sv.q c120, 32(%1) \n"
|
||||
"sv.q c130, 48(%1) \n"
|
||||
|
||||
".set pop \n"
|
||||
:: "r"(in + i), "r"(out + i));
|
||||
}
|
||||
|
||||
for (; i < samples; i++)
|
||||
out[i] = (float)in[i] * gain;
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_convert_float_to_s16_ALLEGREX:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
*
|
||||
* Converts audio samples from floating point
|
||||
* to signed integer 16-bit.
|
||||
*
|
||||
* MIPS ALLEGREX implementation callback function.
|
||||
**/
|
||||
void audio_convert_float_to_s16_ALLEGREX(int16_t *out,
|
||||
const float *in, size_t samples)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Make sure the buffers are 16 byte aligned, this should be
|
||||
* the default behaviour of malloc in the PSPSDK.
|
||||
* Both buffers are allocated by RetroArch, so can assume alignment. */
|
||||
retro_assert(((uintptr_t)in & 0xf) == 0);
|
||||
retro_assert(((uintptr_t)out & 0xf) == 0);
|
||||
#endif
|
||||
|
||||
for (i = 0; i + 8 <= samples; i += 8)
|
||||
{
|
||||
__asm__ (
|
||||
".set push \n"
|
||||
".set noreorder \n"
|
||||
|
||||
"lv.q c100, 0(%0) \n"
|
||||
"lv.q c110, 16(%0) \n"
|
||||
|
||||
"vf2in.q c100, c100, 31 \n"
|
||||
"vf2in.q c110, c110, 31 \n"
|
||||
"vi2s.q c100, c100 \n"
|
||||
"vi2s.q c102, c110 \n"
|
||||
|
||||
"sv.q c100, 0(%1) \n"
|
||||
|
||||
".set pop \n"
|
||||
:: "r"(in + i), "r"(out + i));
|
||||
}
|
||||
|
||||
for (; i < samples; i++)
|
||||
{
|
||||
int32_t val = (int32_t)(in[i] * 0x8000);
|
||||
out[i] = (val > 0x7FFF) ? 0x7FFF :
|
||||
(val < -0x8000 ? -0x8000 : (int16_t)val);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef RARCH_INTERNAL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
retro_get_cpu_features_t perf_get_cpu_features_cb;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
static unsigned audio_convert_get_cpu_features(void)
|
||||
{
|
||||
#ifdef RARCH_INTERNAL
|
||||
return retro_get_cpu_features();
|
||||
#else
|
||||
return perf_get_cpu_features_cb();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_convert_init_simd:
|
||||
*
|
||||
* Sets up function pointers for audio conversion
|
||||
* functions based on CPU features.
|
||||
**/
|
||||
void audio_convert_init_simd(void)
|
||||
{
|
||||
unsigned cpu = audio_convert_get_cpu_features();
|
||||
|
||||
(void)cpu;
|
||||
#if defined(__ARM_NEON__) && !defined(VITA)
|
||||
audio_convert_s16_to_float_arm = (cpu & RETRO_SIMD_NEON) ?
|
||||
audio_convert_s16_to_float_neon : audio_convert_s16_to_float_C;
|
||||
audio_convert_float_to_s16_arm = (cpu & RETRO_SIMD_NEON) ?
|
||||
audio_convert_float_to_s16_neon : audio_convert_float_to_s16_C;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef AUDIO_UTILS_H
|
||||
#define AUDIO_UTILS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
#if defined(__SSE2__)
|
||||
#define audio_convert_s16_to_float audio_convert_s16_to_float_SSE2
|
||||
#define audio_convert_float_to_s16 audio_convert_float_to_s16_SSE2
|
||||
|
||||
/**
|
||||
* audio_convert_s16_to_float_SSE2:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* SSE2 implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_SSE2(float *out,
|
||||
const int16_t *in, size_t samples, float gain);
|
||||
|
||||
/**
|
||||
* audio_convert_float_to_s16_SSE2:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
*
|
||||
* Converts audio samples from floating point
|
||||
* to signed integer 16-bit.
|
||||
*
|
||||
* SSE2 implementation callback function.
|
||||
**/
|
||||
void audio_convert_float_to_s16_SSE2(int16_t *out,
|
||||
const float *in, size_t samples);
|
||||
|
||||
#elif defined(__ALTIVEC__)
|
||||
#define audio_convert_s16_to_float audio_convert_s16_to_float_altivec
|
||||
#define audio_convert_float_to_s16 audio_convert_float_to_s16_altivec
|
||||
|
||||
/**
|
||||
* audio_convert_s16_to_float_altivec:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* AltiVec implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_altivec(float *out,
|
||||
const int16_t *in, size_t samples, float gain);
|
||||
|
||||
/**
|
||||
* audio_convert_float_to_s16_altivec:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
*
|
||||
* Converts audio samples from floating point
|
||||
* to signed integer 16-bit.
|
||||
*
|
||||
* AltiVec implementation callback function.
|
||||
**/
|
||||
void audio_convert_float_to_s16_altivec(int16_t *out,
|
||||
const float *in, size_t samples);
|
||||
|
||||
#elif defined(__ARM_NEON__) && !defined(VITA)
|
||||
#define audio_convert_s16_to_float audio_convert_s16_to_float_arm
|
||||
#define audio_convert_float_to_s16 audio_convert_float_to_s16_arm
|
||||
|
||||
void (*audio_convert_s16_to_float_arm)(float *out,
|
||||
const int16_t *in, size_t samples, float gain);
|
||||
|
||||
void (*audio_convert_float_to_s16_arm)(int16_t *out,
|
||||
const float *in, size_t samples);
|
||||
|
||||
#elif defined(_MIPS_ARCH_ALLEGREX)
|
||||
#define audio_convert_s16_to_float audio_convert_s16_to_float_ALLEGREX
|
||||
#define audio_convert_float_to_s16 audio_convert_float_to_s16_ALLEGREX
|
||||
|
||||
/**
|
||||
* audio_convert_s16_to_float_ALLEGREX:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* MIPS ALLEGREX implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_ALLEGREX(float *out,
|
||||
const int16_t *in, size_t samples, float gain);
|
||||
|
||||
/**
|
||||
* audio_convert_float_to_s16_ALLEGREX:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
*
|
||||
* Converts audio samples from floating point
|
||||
* to signed integer 16-bit.
|
||||
*
|
||||
* MIPS ALLEGREX implementation callback function.
|
||||
**/
|
||||
void audio_convert_float_to_s16_ALLEGREX(int16_t *out,
|
||||
const float *in, size_t samples);
|
||||
#else
|
||||
#define audio_convert_s16_to_float audio_convert_s16_to_float_C
|
||||
#define audio_convert_float_to_s16 audio_convert_float_to_s16_C
|
||||
#endif
|
||||
|
||||
/**
|
||||
* audio_convert_s16_to_float_C:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* C implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_C(float *out,
|
||||
const int16_t *in, size_t samples, float gain);
|
||||
|
||||
/**
|
||||
* audio_convert_float_to_s16_C:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
*
|
||||
* Converts audio samples from floating point
|
||||
* to signed integer 16-bit.
|
||||
*
|
||||
* C implementation callback function.
|
||||
**/
|
||||
void audio_convert_float_to_s16_C(int16_t *out,
|
||||
const float *in, size_t samples);
|
||||
|
||||
/**
|
||||
* audio_convert_init_simd:
|
||||
*
|
||||
* Sets up function pointers for audio conversion
|
||||
* functions based on CPU features.
|
||||
**/
|
||||
void audio_convert_init_simd(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -19,11 +19,11 @@
|
||||
#endif
|
||||
|
||||
.align 4
|
||||
.globl convert_s16_float_asm
|
||||
.globl _convert_s16_float_asm
|
||||
# convert_s16_float_asm(float *out, const int16_t *in, size_t samples, const float *gain)
|
||||
convert_s16_float_asm:
|
||||
_convert_s16_float_asm:
|
||||
.globl audio_convert_s16_float_asm
|
||||
.globl _audio_convert_s16_float_asm
|
||||
# audio_convert_s16_float_asm(float *out, const int16_t *in, size_t samples, const float *gain)
|
||||
audio_convert_s16_float_asm:
|
||||
_audio_convert_s16_float_asm:
|
||||
# Hacky way to get a constant of 2^-15.
|
||||
# Might be faster to just load a constant from memory.
|
||||
# It's just done once however ...
|
||||
@@ -60,4 +60,39 @@ _convert_s16_float_asm:
|
||||
|
||||
bx lr
|
||||
|
||||
.align 4
|
||||
.globl audio_convert_float_s16_asm
|
||||
.globl _audio_convert_float_s16_asm
|
||||
# audio_convert_float_s16_asm(int16_t *out, const float *in, size_t samples)
|
||||
audio_convert_float_s16_asm:
|
||||
_audio_convert_float_s16_asm:
|
||||
# Hacky way to get a constant of 2^15.
|
||||
# ((2^4)^2)^2 * 0.5 = 2^15
|
||||
vmov.f32 q8, #16.0
|
||||
vmov.f32 q9, #0.5
|
||||
vmul.f32 q8, q8, q8
|
||||
vmul.f32 q8, q8, q8
|
||||
vmul.f32 q8, q8, q9
|
||||
|
||||
1:
|
||||
# Preload here?
|
||||
vld1.f32 {q0-q1}, [r1]!
|
||||
|
||||
vmul.f32 q0, q0, q8
|
||||
vmul.f32 q1, q1, q8
|
||||
|
||||
vcvt.s32.f32 q0, q0
|
||||
vcvt.s32.f32 q1, q1
|
||||
|
||||
vqmovn.s32 d4, q0
|
||||
vqmovn.s32 d5, q1
|
||||
|
||||
vst1.f32 {d4-d5}, [r0]!
|
||||
|
||||
# Guaranteed to get samples in multiples of 8.
|
||||
subs r2, r2, #8
|
||||
bne 1b
|
||||
|
||||
bx lr
|
||||
|
||||
#endif
|
||||
@@ -15,8 +15,6 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <lists/string_list.h>
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
|
||||
#include "../audio_driver.h"
|
||||
@@ -156,10 +154,7 @@ error:
|
||||
if (alsa)
|
||||
{
|
||||
if (alsa->pcm)
|
||||
{
|
||||
snd_pcm_close(alsa->pcm);
|
||||
snd_config_update_free_global();
|
||||
}
|
||||
|
||||
free(alsa);
|
||||
}
|
||||
@@ -301,9 +296,7 @@ static void alsa_free(void *data)
|
||||
{
|
||||
snd_pcm_drop(alsa->pcm);
|
||||
snd_pcm_close(alsa->pcm);
|
||||
snd_config_update_free_global();
|
||||
}
|
||||
|
||||
free(alsa);
|
||||
}
|
||||
}
|
||||
@@ -331,64 +324,6 @@ static size_t alsa_buffer_size(void *data)
|
||||
return alsa->buffer_size;
|
||||
}
|
||||
|
||||
static void *alsa_device_list_new(void *data)
|
||||
{
|
||||
void **hints, **n;
|
||||
union string_list_elem_attr attr;
|
||||
struct string_list *s = string_list_new();
|
||||
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
attr.i = 0;
|
||||
|
||||
if (snd_device_name_hint(-1, "pcm", &hints) != 0)
|
||||
goto error;
|
||||
|
||||
n = hints;
|
||||
|
||||
while (*n != NULL)
|
||||
{
|
||||
char *name = snd_device_name_get_hint(*n, "NAME");
|
||||
char *io = snd_device_name_get_hint(*n, "IOID");
|
||||
char *desc = snd_device_name_get_hint(*n, "DESC");
|
||||
|
||||
/* description of device IOID - input / output identifcation
|
||||
* ("Input" or "Output"), NULL means both) */
|
||||
|
||||
if (!io || !strcmp(io,"Output"))
|
||||
string_list_append(s, name, attr);
|
||||
|
||||
if (name)
|
||||
free(name);
|
||||
if (io)
|
||||
free(io);
|
||||
if (desc)
|
||||
free(desc);
|
||||
|
||||
n++;
|
||||
}
|
||||
|
||||
/* free hint buffer too */
|
||||
snd_device_name_free_hint(hints);
|
||||
|
||||
return s;
|
||||
|
||||
error:
|
||||
string_list_free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void alsa_device_list_free(void *data, void *array_list_data)
|
||||
{
|
||||
struct string_list *s = (struct string_list*)array_list_data;
|
||||
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
string_list_free(s);
|
||||
}
|
||||
|
||||
audio_driver_t audio_alsa = {
|
||||
alsa_init,
|
||||
alsa_write,
|
||||
@@ -399,8 +334,6 @@ audio_driver_t audio_alsa = {
|
||||
alsa_free,
|
||||
alsa_use_float,
|
||||
"alsa",
|
||||
alsa_device_list_new,
|
||||
alsa_device_list_free,
|
||||
alsa_write_avail,
|
||||
alsa_buffer_size,
|
||||
};
|
||||
@@ -377,8 +377,6 @@ audio_driver_t audio_alsa = {
|
||||
alsa_qsa_free,
|
||||
alsa_qsa_use_float,
|
||||
"alsa",
|
||||
NULL,
|
||||
NULL,
|
||||
alsa_qsa_write_avail,
|
||||
alsa_qsa_buffer_size,
|
||||
};
|
||||
@@ -16,12 +16,10 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <lists/string_list.h>
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
|
||||
#include <rthreads/rthreads.h>
|
||||
#include <queues/fifo_queue.h>
|
||||
#include <queues/fifo_buffer.h>
|
||||
|
||||
#include "../audio_driver.h"
|
||||
#include "../../configuration.h"
|
||||
@@ -132,9 +130,7 @@ static void alsa_thread_free(void *data)
|
||||
{
|
||||
if (alsa->worker_thread)
|
||||
{
|
||||
slock_lock(alsa->cond_lock);
|
||||
alsa->thread_dead = true;
|
||||
slock_unlock(alsa->cond_lock);
|
||||
sthread_join(alsa->worker_thread);
|
||||
}
|
||||
if (alsa->buffer)
|
||||
@@ -346,64 +342,6 @@ static size_t alsa_thread_buffer_size(void *data)
|
||||
return alsa->buffer_size;
|
||||
}
|
||||
|
||||
static void *alsa_device_list_new(void *data)
|
||||
{
|
||||
void **hints, **n;
|
||||
union string_list_elem_attr attr;
|
||||
struct string_list *s = string_list_new();
|
||||
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
attr.i = 0;
|
||||
|
||||
if (snd_device_name_hint(-1, "pcm", &hints) != 0)
|
||||
goto error;
|
||||
|
||||
n = hints;
|
||||
|
||||
while (*n != NULL)
|
||||
{
|
||||
char *name = snd_device_name_get_hint(*n, "NAME");
|
||||
char *io = snd_device_name_get_hint(*n, "IOID");
|
||||
char *desc = snd_device_name_get_hint(*n, "DESC");
|
||||
|
||||
/* description of device IOID - input / output identifcation
|
||||
* ("Input" or "Output"), NULL means both) */
|
||||
|
||||
if (!io || !strcmp(io,"Output"))
|
||||
string_list_append(s, name, attr);
|
||||
|
||||
if (name)
|
||||
free(name);
|
||||
if (io)
|
||||
free(io);
|
||||
if (desc)
|
||||
free(desc);
|
||||
|
||||
n++;
|
||||
}
|
||||
|
||||
/* free hint buffer too */
|
||||
snd_device_name_free_hint(hints);
|
||||
|
||||
return s;
|
||||
|
||||
error:
|
||||
string_list_free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void alsa_device_list_free(void *data, void *array_list_data)
|
||||
{
|
||||
struct string_list *s = (struct string_list*)array_list_data;
|
||||
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
string_list_free(s);
|
||||
}
|
||||
|
||||
audio_driver_t audio_alsathread = {
|
||||
alsa_thread_init,
|
||||
alsa_thread_write,
|
||||
@@ -414,8 +352,6 @@ audio_driver_t audio_alsathread = {
|
||||
alsa_thread_free,
|
||||
alsa_thread_use_float,
|
||||
"alsathread",
|
||||
alsa_device_list_new,
|
||||
alsa_device_list_free,
|
||||
alsa_thread_write_avail,
|
||||
alsa_thread_buffer_size,
|
||||
};
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <AudioUnit/AUComponent.h>
|
||||
|
||||
#include <boolean.h>
|
||||
#include <queues/fifo_queue.h>
|
||||
#include <queues/fifo_buffer.h>
|
||||
#include <rthreads/rthreads.h>
|
||||
#include <retro_endianness.h>
|
||||
#include <string/stdstring.h>
|
||||
@@ -440,17 +440,6 @@ static size_t coreaudio_buffer_size(void *data)
|
||||
return dev->buffer_size;
|
||||
}
|
||||
|
||||
static void *coreaudio_device_list_new(void *data)
|
||||
{
|
||||
/* TODO/FIXME */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void coreaudio_device_list_free(void *data, void *array_list_data)
|
||||
{
|
||||
/* TODO/FIXME */
|
||||
}
|
||||
|
||||
audio_driver_t audio_coreaudio = {
|
||||
coreaudio_init,
|
||||
coreaudio_write,
|
||||
@@ -461,8 +450,6 @@ audio_driver_t audio_coreaudio = {
|
||||
coreaudio_free,
|
||||
coreaudio_use_float,
|
||||
"coreaudio",
|
||||
coreaudio_device_list_new,
|
||||
coreaudio_device_list_free,
|
||||
coreaudio_write_avail,
|
||||
coreaudio_buffer_size,
|
||||
};
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "../audio_driver.h"
|
||||
#include "../../configuration.h"
|
||||
#include "../../performance_counters.h"
|
||||
#include "../../performance.h"
|
||||
#include "../../runloop.h"
|
||||
|
||||
typedef struct
|
||||
@@ -169,8 +169,8 @@ static ssize_t ctr_csnd_audio_write(void *data, const void *buf, size_t size)
|
||||
(void)samples_played;
|
||||
(void)current_tick;
|
||||
|
||||
performance_counter_init(&ctraudio_f, "ctraudio_f");
|
||||
performance_counter_start(&ctraudio_f);
|
||||
rarch_perf_init(&ctraudio_f, "ctraudio_f");
|
||||
retro_perf_start(&ctraudio_f);
|
||||
|
||||
ctr_csnd_audio_update_playpos(ctr);
|
||||
|
||||
@@ -202,7 +202,7 @@ static ssize_t ctr_csnd_audio_write(void *data, const void *buf, size_t size)
|
||||
GSPGPU_FlushDataCache(ctr->l, CTR_CSND_AUDIO_SIZE);
|
||||
GSPGPU_FlushDataCache(ctr->r, CTR_CSND_AUDIO_SIZE);
|
||||
|
||||
performance_counter_stop(&ctraudio_f);
|
||||
retro_perf_stop(&ctraudio_f);
|
||||
|
||||
return size;
|
||||
}
|
||||
@@ -300,8 +300,6 @@ audio_driver_t audio_ctr_csnd = {
|
||||
ctr_csnd_audio_free,
|
||||
ctr_csnd_audio_use_float,
|
||||
"csnd",
|
||||
NULL,
|
||||
NULL,
|
||||
ctr_csnd_audio_write_avail,
|
||||
ctr_csnd_audio_buffer_size
|
||||
};
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "../audio_driver.h"
|
||||
#include "../../configuration.h"
|
||||
#include "../../performance_counters.h"
|
||||
#include "../../performance.h"
|
||||
#include "../../runloop.h"
|
||||
#include "../../ctr/ctr_debug.h"
|
||||
|
||||
@@ -116,8 +116,8 @@ static ssize_t ctr_dsp_audio_write(void *data, const void *buf, size_t size)
|
||||
}
|
||||
}
|
||||
|
||||
performance_counter_init(&ctraudio_dsp_f, "ctraudio_dsp_f");
|
||||
performance_counter_start(&ctraudio_dsp_f);
|
||||
rarch_perf_init(&ctraudio_dsp_f, "ctraudio_dsp_f");
|
||||
retro_perf_start(&ctraudio_dsp_f);
|
||||
|
||||
pos = ctr->pos << 2;
|
||||
|
||||
@@ -140,7 +140,7 @@ static ssize_t ctr_dsp_audio_write(void *data, const void *buf, size_t size)
|
||||
ctr->pos += size >> 2;
|
||||
ctr->pos &= CTR_DSP_AUDIO_COUNT_MASK;
|
||||
|
||||
performance_counter_stop(&ctraudio_dsp_f);
|
||||
retro_perf_stop(&ctraudio_dsp_f);
|
||||
|
||||
return size;
|
||||
}
|
||||
@@ -214,8 +214,6 @@ audio_driver_t audio_ctr_dsp = {
|
||||
ctr_dsp_audio_free,
|
||||
ctr_dsp_audio_use_float,
|
||||
"dsp",
|
||||
NULL,
|
||||
NULL,
|
||||
ctr_dsp_audio_write_avail,
|
||||
ctr_dsp_audio_buffer_size
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <retro_inline.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
#include <rthreads/rthreads.h>
|
||||
#include <queues/fifo_queue.h>
|
||||
#include <queues/fifo_buffer.h>
|
||||
|
||||
#include "../audio_driver.h"
|
||||
#include "../../configuration.h"
|
||||
@@ -489,8 +489,6 @@ audio_driver_t audio_dsound = {
|
||||
dsound_free,
|
||||
dsound_use_float,
|
||||
"dsound",
|
||||
NULL,
|
||||
NULL,
|
||||
dsound_write_avail,
|
||||
dsound_buffer_size,
|
||||
};
|
||||
@@ -241,8 +241,6 @@ audio_driver_t audio_gx = {
|
||||
gx_audio_free,
|
||||
gx_audio_use_float,
|
||||
"gx",
|
||||
NULL,
|
||||
NULL,
|
||||
gx_audio_write_avail,
|
||||
gx_audio_buffer_size,
|
||||
};
|
||||
@@ -41,10 +41,8 @@ typedef struct jack
|
||||
bool nonblock;
|
||||
bool is_paused;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
scond_t *cond;
|
||||
slock_t *cond_lock;
|
||||
#endif
|
||||
size_t buffer_size;
|
||||
} jack_t;
|
||||
|
||||
@@ -56,9 +54,7 @@ static int process_cb(jack_nframes_t nframes, void *data)
|
||||
|
||||
if (nframes <= 0)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
scond_signal(jd->cond);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -78,9 +74,7 @@ static int process_cb(jack_nframes_t nframes, void *data)
|
||||
for (f = min_avail; f < nframes; f++)
|
||||
out[f] = 0.0f;
|
||||
}
|
||||
#ifdef HAVE_THREADS
|
||||
scond_signal(jd->cond);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -92,9 +86,7 @@ static void shutdown_cb(void *data)
|
||||
return;
|
||||
|
||||
jd->shutdown = true;
|
||||
#ifdef HAVE_THREADS
|
||||
scond_signal(jd->cond);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int parse_ports(char **dest_ports, const char **jports)
|
||||
@@ -157,10 +149,8 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency)
|
||||
if (!jd)
|
||||
return NULL;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
jd->cond = scond_new();
|
||||
jd->cond_lock = slock_new();
|
||||
#endif
|
||||
|
||||
jd->client = jack_client_open("RetroArch", JackNullOption, NULL);
|
||||
if (jd->client == NULL)
|
||||
@@ -226,7 +216,6 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency)
|
||||
error:
|
||||
if (jports != NULL)
|
||||
jack_free(jports);
|
||||
free(jd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -269,14 +258,12 @@ static size_t write_buffer(jack_t *jd, const float *buf, size_t size)
|
||||
}
|
||||
written += write_frames;
|
||||
}
|
||||
#ifdef HAVE_THREADS
|
||||
else
|
||||
{
|
||||
slock_lock(jd->cond_lock);
|
||||
scond_wait(jd->cond, jd->cond_lock);
|
||||
slock_unlock(jd->cond_lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (jd->nonblock)
|
||||
break;
|
||||
@@ -340,12 +327,10 @@ static void ja_free(void *data)
|
||||
if (jd->buffer[i] != NULL)
|
||||
jack_ringbuffer_free(jd->buffer[i]);
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
if (jd->cond_lock)
|
||||
slock_free(jd->cond_lock);
|
||||
if (jd->cond)
|
||||
scond_free(jd->cond);
|
||||
#endif
|
||||
free(jd);
|
||||
}
|
||||
|
||||
@@ -377,8 +362,6 @@ audio_driver_t audio_jack = {
|
||||
ja_free,
|
||||
ja_use_float,
|
||||
"jack",
|
||||
NULL,
|
||||
NULL,
|
||||
ja_write_avail,
|
||||
ja_buffer_size,
|
||||
};
|
||||
@@ -85,8 +85,6 @@ audio_driver_t audio_null = {
|
||||
null_audio_free,
|
||||
null_audio_use_float,
|
||||
"null",
|
||||
NULL,
|
||||
NULL,
|
||||
null_audio_write_avail,
|
||||
NULL
|
||||
};
|
||||
@@ -267,8 +267,6 @@ audio_driver_t audio_openal = {
|
||||
al_free,
|
||||
al_use_float,
|
||||
"openal",
|
||||
NULL,
|
||||
NULL,
|
||||
al_write_avail,
|
||||
al_buffer_size,
|
||||
};
|
||||
@@ -313,8 +313,6 @@ audio_driver_t audio_opensl = {
|
||||
sl_free,
|
||||
sl_use_float,
|
||||
"opensl",
|
||||
NULL,
|
||||
NULL,
|
||||
sl_write_avail,
|
||||
sl_buffer_size,
|
||||
};
|
||||
@@ -212,8 +212,6 @@ audio_driver_t audio_oss = {
|
||||
oss_free,
|
||||
oss_use_float,
|
||||
"oss",
|
||||
NULL,
|
||||
NULL,
|
||||
oss_write_avail,
|
||||
oss_buffer_size,
|
||||
};
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <queues/fifo_queue.h>
|
||||
#include <queues/fifo_buffer.h>
|
||||
|
||||
#include "../audio_driver.h"
|
||||
#include "../../configuration.h"
|
||||
@@ -247,8 +247,6 @@ audio_driver_t audio_ps3 = {
|
||||
ps3_audio_free,
|
||||
ps3_audio_use_float,
|
||||
"ps3",
|
||||
NULL,
|
||||
NULL,
|
||||
ps3_audio_write_avail,
|
||||
NULL
|
||||
};
|
||||
@@ -49,7 +49,7 @@ typedef struct psp_audio
|
||||
#define AUDIO_BUFFER_SIZE_MASK (AUDIO_BUFFER_SIZE-1)
|
||||
|
||||
#ifdef VITA
|
||||
#define PSP_THREAD_STOPPED SCE_THREAD_STOPPED
|
||||
#define PSP_THREAD_STOPPED PSP2_THREAD_STOPPED
|
||||
#else
|
||||
#define SceKernelThreadInfo SceKernelThreadRunStatus
|
||||
#define sceKernelGetThreadInfo sceKernelReferThreadRunStatus
|
||||
@@ -60,8 +60,8 @@ static int audioMainLoop(SceSize args, void* argp)
|
||||
psp_audio_t* psp = *((psp_audio_t**)argp);
|
||||
|
||||
#ifdef VITA
|
||||
int port = sceAudioOutOpenPort(SCE_AUDIO_OUT_PORT_TYPE_MAIN, AUDIO_OUT_COUNT,
|
||||
psp->rate, SCE_AUDIO_OUT_MODE_STEREO);
|
||||
int port = sceAudioOutOpenPort(PSP2_AUDIO_OUT_PORT_TYPE_MAIN, AUDIO_OUT_COUNT,
|
||||
psp->rate, PSP2_AUDIO_OUT_MODE_STEREO);
|
||||
#else
|
||||
sceAudioSRCChReserve(AUDIO_OUT_COUNT, psp->rate, 2);
|
||||
#endif
|
||||
@@ -286,8 +286,6 @@ audio_driver_t audio_psp = {
|
||||
#else
|
||||
"psp",
|
||||
#endif
|
||||
NULL,
|
||||
NULL,
|
||||
psp_write_avail,
|
||||
psp_buffer_size,
|
||||
};
|
||||
@@ -343,8 +343,6 @@ audio_driver_t audio_pulse = {
|
||||
pulse_free,
|
||||
pulse_use_float,
|
||||
"pulse",
|
||||
NULL,
|
||||
NULL,
|
||||
pulse_write_avail,
|
||||
pulse_buffer_size,
|
||||
};
|
||||
@@ -24,13 +24,11 @@
|
||||
|
||||
#include "../audio_driver.h"
|
||||
#include "../../configuration.h"
|
||||
#include "../../verbosity.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
roar_vs_t *vss;
|
||||
bool nonblocking;
|
||||
bool is_paused;
|
||||
} roar_t;
|
||||
|
||||
static void *ra_init(const char *device, unsigned rate, unsigned latency)
|
||||
@@ -144,8 +142,6 @@ audio_driver_t audio_roar = {
|
||||
ra_free,
|
||||
ra_use_float,
|
||||
"roar",
|
||||
NULL,
|
||||
NULL,
|
||||
ra_write_avail,
|
||||
NULL
|
||||
};
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include <boolean.h>
|
||||
|
||||
#include <queues/fifo_queue.h>
|
||||
#include <queues/fifo_buffer.h>
|
||||
#include <rthreads/rthreads.h>
|
||||
|
||||
#include "../audio_driver.h"
|
||||
@@ -233,8 +233,6 @@ audio_driver_t audio_rsound = {
|
||||
rs_free,
|
||||
rs_use_float,
|
||||
"rsound",
|
||||
NULL,
|
||||
NULL,
|
||||
rs_write_avail,
|
||||
rs_buffer_size,
|
||||
};
|
||||
+12
-5
@@ -16,6 +16,14 @@
|
||||
#ifndef __RSOUND_H
|
||||
#define __RSOUND_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define STANDALONE
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <rthreads/rthreads.h>
|
||||
@@ -24,10 +32,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <retro_common_api.h>
|
||||
#include <queues/fifo_queue.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
#include <queues/fifo_buffer.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define RSD_DEFAULT_HOST "127.0.0.1" /* Stupid Windows. */
|
||||
@@ -318,6 +323,8 @@ int rsd_pause (rsound_t *rd, int enable);
|
||||
/* Frees an rsound_t struct. Make sure that the stream is properly closed down with rsd_stop() before calling rsd_free(). */
|
||||
int rsd_free (rsound_t *rd);
|
||||
|
||||
RETRO_END_DECLS
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -110,8 +110,6 @@ audio_driver_t audio_rwebaudio = {
|
||||
rwebaudio_free,
|
||||
rwebaudio_use_float,
|
||||
"rwebaudio",
|
||||
NULL,
|
||||
NULL,
|
||||
rwebaudio_write_avail,
|
||||
rwebaudio_buffer_size,
|
||||
};
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <boolean.h>
|
||||
#include <rthreads/rthreads.h>
|
||||
#include <queues/fifo_queue.h>
|
||||
#include <queues/fifo_buffer.h>
|
||||
#include <retro_inline.h>
|
||||
|
||||
#include "../audio_driver.h"
|
||||
@@ -35,10 +35,8 @@ typedef struct sdl_audio
|
||||
bool nonblock;
|
||||
bool is_paused;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
slock_t *lock;
|
||||
scond_t *cond;
|
||||
#endif
|
||||
fifo_buffer_t *buffer;
|
||||
} sdl_audio_t;
|
||||
|
||||
@@ -49,9 +47,7 @@ static void sdl_audio_cb(void *data, Uint8 *stream, int len)
|
||||
size_t write_size = len > (int)avail ? avail : len;
|
||||
|
||||
fifo_read(sdl->buffer, stream, write_size);
|
||||
#ifdef HAVE_THREADS
|
||||
scond_signal(sdl->cond);
|
||||
#endif
|
||||
|
||||
/* If underrun, fill rest with silence. */
|
||||
memset(stream + write_size, 0, len - write_size);
|
||||
@@ -113,10 +109,8 @@ static void *sdl_audio_init(const char *device,
|
||||
|
||||
settings->audio.out_rate = out.freq;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
sdl->lock = slock_new();
|
||||
sdl->cond = scond_new();
|
||||
#endif
|
||||
|
||||
RARCH_LOG("SDL audio: Requested %u ms latency, got %d ms\n",
|
||||
latency, (int)(out.samples * 4 * 1000 / settings->audio.out_rate));
|
||||
@@ -166,11 +160,9 @@ static ssize_t sdl_audio_write(void *data, const void *buf, size_t size)
|
||||
if (avail == 0)
|
||||
{
|
||||
SDL_UnlockAudio();
|
||||
#ifdef HAVE_THREADS
|
||||
slock_lock(sdl->lock);
|
||||
scond_wait(sdl->cond, sdl->lock);
|
||||
slock_unlock(sdl->lock);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -228,10 +220,8 @@ static void sdl_audio_free(void *data)
|
||||
if (sdl)
|
||||
{
|
||||
fifo_free(sdl->buffer);
|
||||
#ifdef HAVE_THREADS
|
||||
slock_free(sdl->lock);
|
||||
scond_free(sdl->cond);
|
||||
#endif
|
||||
}
|
||||
free(sdl);
|
||||
}
|
||||
@@ -263,8 +253,6 @@ audio_driver_t audio_sdl = {
|
||||
#else
|
||||
"sdl",
|
||||
#endif
|
||||
NULL,
|
||||
NULL,
|
||||
sdl_audio_write_avail,
|
||||
NULL
|
||||
};
|
||||
@@ -347,8 +347,6 @@ audio_driver_t audio_xa = {
|
||||
xa_free,
|
||||
xa_use_float,
|
||||
"xaudio",
|
||||
NULL,
|
||||
NULL,
|
||||
xa_write_avail,
|
||||
xa_buffer_size,
|
||||
};
|
||||
@@ -146,8 +146,6 @@ audio_driver_t audio_xenon360 = {
|
||||
xenon360_audio_free,
|
||||
xenon360_use_float,
|
||||
"xenon360",
|
||||
NULL,
|
||||
NULL,
|
||||
xenon360_write_avail,
|
||||
NULL
|
||||
};
|
||||
+26
-23
@@ -20,19 +20,22 @@ CFLAGS += -I$(LIBRETRO_COMM_DIR)/include -I../../
|
||||
LDFLAGS += -lm
|
||||
|
||||
SHAREDOBJ += $(LIBRETRO_COMM_DIR)/memmap/memalign.o \
|
||||
$(LIBRETRO_COMM_DIR)/lists/string_list.o \
|
||||
../..//config_file_userdata.o \
|
||||
../audio_resampler_driver.o \
|
||||
$(LIBRETRO_COMM_DIR)/string/string_list.o \
|
||||
$(LIBRETRO_COMM_DIR)/file/config_file_userdata.o \
|
||||
$(LIBRETRO_COMM_DIR)/file/config_file.o \
|
||||
$(LIBRETRO_COMM_DIR)/streams/file_stream.o \
|
||||
$(LIBRETRO_COMM_DIR)/string/stdstring.o \
|
||||
$(LIBRETRO_COMM_DIR)/file/retro_file.o \
|
||||
$(LIBRETRO_COMM_DIR)/file/file_path.o \
|
||||
$(LIBRETRO_COMM_DIR)/file/retro_stat.o \
|
||||
$(LIBRETRO_COMM_DIR)/compat/compat_strl.o \
|
||||
$(LIBRETRO_COMM_DIR)/compat/compat.o \
|
||||
$(LIBRETRO_COMM_DIR)/hash/rhash.o \
|
||||
|
||||
all: $(TESTS)
|
||||
|
||||
resampler-sinc.o: ../audio_resampler_driver.c $(SHAREDOBJ)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
resampler-cc.o: ../audio_resampler_driver.c $(SHAREDOBJ)
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -DRESAMPLER_IDENT='"CC"'
|
||||
|
||||
main-cc.o: main.c
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -DRESAMPLER_IDENT='"CC"'
|
||||
|
||||
@@ -42,16 +45,16 @@ snr-cc.o: snr.c
|
||||
cc-resampler.o: ../drivers_resampler/cc_resampler.c
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
sinc-lowest.o: ../drivers_resampler/sinc_resampler.c
|
||||
sinc-lowest.o: ../drivers_resampler/sinc.c
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -DSINC_LOWEST_QUALITY
|
||||
|
||||
sinc-lower.o: ../drivers_resampler/sinc_resampler.c
|
||||
sinc-lower.o: ../drivers_resampler/sinc.c
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -DSINC_LOWER_QUALITY
|
||||
|
||||
sinc.o: ../drivers_resampler/sinc_resampler.c
|
||||
sinc.o: ../drivers_resampler/sinc.c
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
nearest_resampler.o: ../drivers_resampler/nearest_resampler.c
|
||||
nearest.o: ../drivers_resampler/nearest.c
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
sinc-higher.o: ../drivers_resampler/sinc.c
|
||||
@@ -60,40 +63,40 @@ sinc-higher.o: ../drivers_resampler/sinc.c
|
||||
sinc-highest.o: ../drivers_resampler/sinc.c
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -DSINC_HIGHEST_QUALITY
|
||||
|
||||
test-sinc-lowest: sinc-lowest.o ../audio_utils.o main.o nearest_resampler.o $(SHAREDOBJ)
|
||||
test-sinc-lowest: sinc-lowest.o ../audio_utils.o main.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test-snr-sinc-lowest: sinc-lowest.o ../audio_utils.o snr.o nearest_resampler.o $(SHAREDOBJ)
|
||||
test-snr-sinc-lowest: sinc-lowest.o ../audio_utils.o snr.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test-sinc-lower: sinc-lower.o ../audio_utils.o main.o nearest_resampler.o $(SHAREDOBJ)
|
||||
test-sinc-lower: sinc-lower.o ../audio_utils.o main.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test-snr-sinc-lower: sinc-lower.o ../audio_utils.o snr.o nearest_resampler.o $(SHAREDOBJ)
|
||||
test-snr-sinc-lower: sinc-lower.o ../audio_utils.o snr.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test-sinc: sinc.o ../audio_utils.o main.o nearest_resampler.o $(SHAREDOBJ)
|
||||
test-sinc: sinc.o ../audio_utils.o main.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test-snr-sinc: sinc.o ../audio_utils.o snr.o nearest_resampler.o $(SHAREDOBJ)
|
||||
test-snr-sinc: sinc.o ../audio_utils.o snr.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test-sinc-higher: sinc-higher.o ../audio_utils.o main.o nearest_resampler.o $(SHAREDOBJ)
|
||||
test-sinc-higher: sinc-higher.o ../audio_utils.o main.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test-snr-sinc-higher: sinc-higher.o ../audio_utils.o snr.o nearest_resampler.o $(SHAREDOBJ)
|
||||
test-snr-sinc-higher: sinc-higher.o ../audio_utils.o snr.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test-sinc-highest: sinc-highest.o ../audio_utils.o main.o nearest_resampler.o $(SHAREDOBJ)
|
||||
test-sinc-highest: sinc-highest.o ../audio_utils.o main.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test-snr-sinc-highest: sinc-highest.o ../audio_utils.o snr.o nearest_resampler.o $(SHAREDOBJ)
|
||||
test-snr-sinc-highest: sinc-highest.o ../audio_utils.o snr.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test-cc: cc-resampler.o ../audio_utils.o main-cc.o resampler-cc.o sinc.o nearest_resampler.o $(SHAREDOBJ)
|
||||
test-cc: cc-resampler.o ../audio_utils.o main-cc.o resampler-cc.o resampler-cc.o sinc.o nearest.o $(SHAREDOBJ)
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test-snr-cc: cc-resampler.o ../audio_utils.o snr-cc.o resampler-cc.o sinc.o nearest_resampler.o $(SHAREDOBJ)
|
||||
test-snr-cc: cc-resampler.o ../audio_utils.o snr-cc.o resampler-cc.o sinc.o nearest.o $(SHAREDOBJ)
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
%.o: %.c
|
||||
|
||||
+2
-2
@@ -80,7 +80,7 @@ int main(int argc, char *argv[])
|
||||
uniform = (2.0 * rand()) / RAND_MAX - 1.0;
|
||||
rate_mod = 1.0 + ratio_max_deviation * uniform;
|
||||
|
||||
convert_s16_to_float(input_f, input_i, 1024, 1.0f);
|
||||
audio_convert_s16_to_float(input_f, input_i, 1024, 1.0f);
|
||||
|
||||
data.data_in = input_f;
|
||||
data.data_out = output_f;
|
||||
@@ -91,7 +91,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
output_samples = data.output_frames * 2;
|
||||
|
||||
convert_float_to_s16(output_i, output_f, output_samples);
|
||||
audio_convert_float_to_s16(output_i, output_f, output_samples);
|
||||
|
||||
if (fwrite(output_i, sizeof(int16_t), output_samples, stdout) != output_samples)
|
||||
break;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2016 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
@@ -12,38 +13,23 @@
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <boolean.h>
|
||||
#include <lists/string_list.h>
|
||||
#include <streams/file_stream.h>
|
||||
|
||||
#include <string/string_list.h>
|
||||
#include <rthreads/rthreads.h>
|
||||
|
||||
#include "../core.h"
|
||||
#include "../msg_hash.h"
|
||||
#include "../verbosity.h"
|
||||
#include "../autosave.h"
|
||||
#include "../configuration.h"
|
||||
#include "../msg_hash.h"
|
||||
#include "../runloop.h"
|
||||
#include "autosave.h"
|
||||
#include "configuration.h"
|
||||
#include "msg_hash.h"
|
||||
#include "runloop.h"
|
||||
#include "libretro_version_1.h"
|
||||
#include "verbosity.h"
|
||||
|
||||
#include "tasks_internal.h"
|
||||
|
||||
/* TODO/FIXME - turn this into actual task */
|
||||
|
||||
struct ram_type
|
||||
{
|
||||
const char *path;
|
||||
int type;
|
||||
};
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
/* Autosave support. */
|
||||
struct autosave_st
|
||||
{
|
||||
@@ -69,6 +55,28 @@ struct autosave
|
||||
|
||||
static struct autosave_st autosave_state;
|
||||
|
||||
/**
|
||||
* autosave_lock:
|
||||
* @handle : pointer to autosave object
|
||||
*
|
||||
* Locks autosave.
|
||||
**/
|
||||
static void autosave_lock(autosave_t *handle)
|
||||
{
|
||||
slock_lock(handle->lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* autosave_unlock:
|
||||
* @handle : pointer to autosave object
|
||||
*
|
||||
* Unlocks autosave.
|
||||
**/
|
||||
static void autosave_unlock(autosave_t *handle)
|
||||
{
|
||||
slock_unlock(handle->lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* autosave_thread:
|
||||
* @data : pointer to autosave object
|
||||
@@ -77,19 +85,19 @@ static struct autosave_st autosave_state;
|
||||
**/
|
||||
static void autosave_thread(void *data)
|
||||
{
|
||||
bool first_log = true;
|
||||
bool first_log = true;
|
||||
autosave_t *save = (autosave_t*)data;
|
||||
|
||||
while (!save->quit)
|
||||
{
|
||||
bool differ;
|
||||
|
||||
slock_lock(save->lock);
|
||||
autosave_lock(save);
|
||||
differ = memcmp(save->buffer, save->retro_buffer,
|
||||
save->bufsize) != 0;
|
||||
if (differ)
|
||||
memcpy(save->buffer, save->retro_buffer, save->bufsize);
|
||||
slock_unlock(save->lock);
|
||||
autosave_unlock(save);
|
||||
|
||||
if (differ)
|
||||
{
|
||||
@@ -141,13 +149,12 @@ static void autosave_thread(void *data)
|
||||
* Returns: pointer to new autosave_t object if successful, otherwise
|
||||
* NULL.
|
||||
**/
|
||||
static autosave_t *autosave_new(const char *path,
|
||||
const void *data, size_t size,
|
||||
autosave_t *autosave_new(const char *path, const void *data, size_t size,
|
||||
unsigned interval)
|
||||
{
|
||||
autosave_t *handle = (autosave_t*)calloc(1, sizeof(*handle));
|
||||
autosave_t *handle = (autosave_t*)calloc(1, sizeof(*handle));
|
||||
if (!handle)
|
||||
goto error;
|
||||
return NULL;
|
||||
|
||||
handle->bufsize = size;
|
||||
handle->interval = interval;
|
||||
@@ -156,8 +163,10 @@ static autosave_t *autosave_new(const char *path,
|
||||
handle->retro_buffer = data;
|
||||
|
||||
if (!handle->buffer)
|
||||
goto error;
|
||||
|
||||
{
|
||||
free(handle);
|
||||
return NULL;
|
||||
}
|
||||
memcpy(handle->buffer, handle->retro_buffer, handle->bufsize);
|
||||
|
||||
handle->lock = slock_new();
|
||||
@@ -167,11 +176,6 @@ static autosave_t *autosave_new(const char *path,
|
||||
handle->thread = sthread_create(autosave_thread, handle);
|
||||
|
||||
return handle;
|
||||
|
||||
error:
|
||||
if (handle)
|
||||
free(handle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,7 +184,7 @@ error:
|
||||
*
|
||||
* Frees autosave object.
|
||||
**/
|
||||
static void autosave_free(autosave_t *handle)
|
||||
void autosave_free(autosave_t *handle)
|
||||
{
|
||||
if (!handle)
|
||||
return;
|
||||
@@ -200,54 +204,51 @@ static void autosave_free(autosave_t *handle)
|
||||
}
|
||||
|
||||
/**
|
||||
* autosave_lock:
|
||||
* lock_autosave:
|
||||
*
|
||||
* Lock autosave.
|
||||
**/
|
||||
void autosave_lock(void)
|
||||
void lock_autosave(void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < autosave_state.num; i++)
|
||||
{
|
||||
if (autosave_state.list[i])
|
||||
slock_lock(autosave_state.list[i]->lock);
|
||||
autosave_lock(autosave_state.list[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* autosave_unlock:
|
||||
* unlock_autosave:
|
||||
*
|
||||
* Unlocks autosave.
|
||||
**/
|
||||
void autosave_unlock(void)
|
||||
void unlock_autosave(void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < autosave_state.num; i++)
|
||||
{
|
||||
if (autosave_state.list[i])
|
||||
slock_unlock(autosave_state.list[i]->lock);
|
||||
autosave_unlock(autosave_state.list[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void autosave_init(void)
|
||||
void autosave_event_init(void)
|
||||
{
|
||||
unsigned i;
|
||||
autosave_t **list = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (settings->autosave_interval < 1 || !global->savefiles)
|
||||
return;
|
||||
|
||||
list = (autosave_t**)calloc(global->savefiles->size,
|
||||
sizeof(*autosave_state.list));
|
||||
if (!list)
|
||||
if (!(autosave_state.list = (autosave_t**)calloc(global->savefiles->size,
|
||||
sizeof(*autosave_state.list))))
|
||||
return;
|
||||
|
||||
autosave_state.list = list;
|
||||
autosave_state.num = global->savefiles->size;
|
||||
autosave_state.num = global->savefiles->size;
|
||||
|
||||
for (i = 0; i < global->savefiles->size; i++)
|
||||
{
|
||||
@@ -257,7 +258,7 @@ void autosave_init(void)
|
||||
|
||||
mem_info.id = type;
|
||||
|
||||
core_get_memory(&mem_info);
|
||||
core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info);
|
||||
|
||||
if (mem_info.size <= 0)
|
||||
continue;
|
||||
@@ -272,7 +273,7 @@ void autosave_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
void autosave_deinit(void)
|
||||
void autosave_event_deinit(void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
@@ -285,109 +286,3 @@ void autosave_deinit(void)
|
||||
autosave_state.list = NULL;
|
||||
autosave_state.num = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* content_load_ram_file:
|
||||
* @path : path of RAM state that will be loaded from.
|
||||
* @type : type of memory
|
||||
*
|
||||
* Load a RAM state from disk to memory.
|
||||
*/
|
||||
bool content_load_ram_file(unsigned slot)
|
||||
{
|
||||
ssize_t rc;
|
||||
ram_type_t ram;
|
||||
retro_ctx_memory_info_t mem_info;
|
||||
global_t *global = global_get_ptr();
|
||||
void *buf = NULL;
|
||||
|
||||
ram.path = global->savefiles->elems[slot].data;
|
||||
ram.type = global->savefiles->elems[slot].attr.i;
|
||||
|
||||
mem_info.id = ram.type;
|
||||
|
||||
core_get_memory(&mem_info);
|
||||
|
||||
if (mem_info.size == 0 || !mem_info.data)
|
||||
return false;
|
||||
|
||||
if (!filestream_read_file(ram.path, &buf, &rc))
|
||||
return false;
|
||||
|
||||
if (rc > 0)
|
||||
{
|
||||
if (rc > (ssize_t)mem_info.size)
|
||||
{
|
||||
RARCH_WARN("SRAM is larger than implementation expects, "
|
||||
"doing partial load (truncating %u %s %s %u).\n",
|
||||
(unsigned)rc,
|
||||
msg_hash_to_str(MSG_BYTES),
|
||||
msg_hash_to_str(MSG_TO),
|
||||
(unsigned)mem_info.size);
|
||||
rc = mem_info.size;
|
||||
}
|
||||
memcpy(mem_info.data, buf, rc);
|
||||
}
|
||||
|
||||
if (buf)
|
||||
free(buf);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* content_save_ram_file:
|
||||
* @path : path of RAM state that shall be written to.
|
||||
* @type : type of memory
|
||||
*
|
||||
* Save a RAM state from memory to disk.
|
||||
*
|
||||
*/
|
||||
bool content_save_ram_file(unsigned slot)
|
||||
{
|
||||
ram_type_t ram;
|
||||
retro_ctx_memory_info_t mem_info;
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!global)
|
||||
return false;
|
||||
|
||||
ram.type = global->savefiles->elems[slot].attr.i;
|
||||
ram.path = global->savefiles->elems[slot].data;
|
||||
|
||||
mem_info.id = ram.type;
|
||||
|
||||
core_get_memory(&mem_info);
|
||||
|
||||
if (!mem_info.data || mem_info.size == 0)
|
||||
return false;
|
||||
|
||||
RARCH_LOG("%s #%u %s \"%s\".\n",
|
||||
msg_hash_to_str(MSG_SAVING_RAM_TYPE),
|
||||
ram.type,
|
||||
msg_hash_to_str(MSG_TO),
|
||||
ram.path);
|
||||
|
||||
if (!filestream_write_file(ram.path, mem_info.data, mem_info.size))
|
||||
{
|
||||
RARCH_ERR("%s.\n",
|
||||
msg_hash_to_str(MSG_FAILED_TO_SAVE_SRAM));
|
||||
RARCH_WARN("Attempting to recover ...\n");
|
||||
|
||||
/* In case the file could not be written to,
|
||||
* the fallback function 'dump_to_file_desperate'
|
||||
* will be called. */
|
||||
if (!dump_to_file_desperate(mem_info.data, mem_info.size, ram.type))
|
||||
{
|
||||
RARCH_WARN("Failed ... Cannot recover save file.\n");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
RARCH_LOG("%s \"%s\".\n",
|
||||
msg_hash_to_str(MSG_SAVED_SUCCESSFULLY_TO),
|
||||
ram.path);
|
||||
|
||||
return true;
|
||||
}
|
||||
+36
-11
@@ -17,32 +17,57 @@
|
||||
#ifndef __RARCH_AUTOSAVE_H
|
||||
#define __RARCH_AUTOSAVE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <retro_common_api.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
typedef struct autosave autosave_t;
|
||||
|
||||
/**
|
||||
* autosave_lock:
|
||||
* autosave_new:
|
||||
* @path : path to autosave file
|
||||
* @data : pointer to buffer
|
||||
* @size : size of @data buffer
|
||||
* @interval : interval at which saves should be performed.
|
||||
*
|
||||
* Create and initialize autosave object.
|
||||
*
|
||||
* Returns: pointer to new autosave_t object if successful, otherwise
|
||||
* NULL.
|
||||
**/
|
||||
autosave_t *autosave_new(const char *path, const void *data,
|
||||
size_t size, unsigned interval);
|
||||
|
||||
/**
|
||||
* autosave_free:
|
||||
* @handle : pointer to autosave object
|
||||
*
|
||||
* Frees autosave object.
|
||||
**/
|
||||
void autosave_free(autosave_t *handle);
|
||||
|
||||
/**
|
||||
* lock_autosave:
|
||||
*
|
||||
* Lock autosave.
|
||||
**/
|
||||
void autosave_lock(void);
|
||||
void lock_autosave(void);
|
||||
|
||||
/**
|
||||
* autosave_unlock:
|
||||
* unlock_autosave:
|
||||
*
|
||||
* Unlocks autosave.
|
||||
**/
|
||||
void autosave_unlock(void);
|
||||
void unlock_autosave(void);
|
||||
|
||||
void autosave_init(void);
|
||||
void autosave_event_init(void);
|
||||
|
||||
void autosave_deinit(void);
|
||||
void autosave_event_deinit(void);
|
||||
|
||||
RETRO_END_DECLS
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -18,10 +18,8 @@
|
||||
|
||||
#include "camera_driver.h"
|
||||
|
||||
#include "../configuration.h"
|
||||
#include "../retroarch.h"
|
||||
#include "../runloop.h"
|
||||
#include "../list_special.h"
|
||||
#include "../general.h"
|
||||
#include "../string_list_special.h"
|
||||
#include "../verbosity.h"
|
||||
|
||||
static const camera_driver_t *camera_drivers[] = {
|
||||
@@ -153,7 +151,7 @@ bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data)
|
||||
camera_driver = (const camera_driver_t*)camera_driver_find_handle(0);
|
||||
|
||||
if (!camera_driver)
|
||||
retroarch_fail(1, "find_camera_driver()");
|
||||
retro_fail(1, "find_camera_driver()");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
#define __CAMERA_DRIVER__H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
#include <libretro.h>
|
||||
#include "../libretro.h"
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum rarch_camera_ctl_state
|
||||
{
|
||||
@@ -107,6 +107,8 @@ bool driver_camera_start(void);
|
||||
|
||||
bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data);
|
||||
|
||||
RETRO_END_DECLS
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <compat/strl.h>
|
||||
|
||||
#include "../camera_driver.h"
|
||||
#include "../../performance_counters.h"
|
||||
#include "../../performance.h"
|
||||
#include "../../verbosity.h"
|
||||
|
||||
struct buffer
|
||||
@@ -70,10 +70,10 @@ static void process_image(video4linux_t *v4l, const uint8_t *buffer_yuv)
|
||||
{
|
||||
static struct retro_perf_counter yuv_convert_direct = {0};
|
||||
|
||||
performance_counter_init(&yuv_convert_direct, "yuv_convert_direct");
|
||||
performance_counter_start(&yuv_convert_direct);
|
||||
rarch_perf_init(&yuv_convert_direct, "yuv_convert_direct");
|
||||
retro_perf_start(&yuv_convert_direct);
|
||||
scaler_ctx_scale(&v4l->scaler, v4l->buffer_output, buffer_yuv);
|
||||
performance_counter_stop(&yuv_convert_direct);
|
||||
retro_perf_stop(&yuv_convert_direct);
|
||||
}
|
||||
|
||||
static int xioctl(int fd, int request, void *args)
|
||||
@@ -95,8 +95,8 @@ static bool init_mmap(void *data)
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
|
||||
req.count = 4;
|
||||
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
req.count = 4;
|
||||
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
req.memory = V4L2_MEMORY_MMAP;
|
||||
|
||||
if (xioctl(v4l->fd, (uint8_t)VIDIOC_REQBUFS, &req) == -1)
|
||||
@@ -249,9 +249,9 @@ static void v4l_stop(void *data)
|
||||
|
||||
static bool v4l_start(void *data)
|
||||
{
|
||||
video4linux_t *v4l = (video4linux_t*)data;
|
||||
unsigned i;
|
||||
enum v4l2_buf_type type;
|
||||
video4linux_t *v4l = (video4linux_t*)data;
|
||||
|
||||
for (i = 0; i < v4l->n_buffers; i++)
|
||||
{
|
||||
@@ -259,9 +259,9 @@ static bool v4l_start(void *data)
|
||||
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
|
||||
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
buf.memory = V4L2_MEMORY_MMAP;
|
||||
buf.index = i;
|
||||
buf.index = i;
|
||||
|
||||
if (xioctl(v4l->fd, (uint8_t)VIDIOC_QBUF, &buf) == -1)
|
||||
{
|
||||
|
||||
@@ -23,18 +23,18 @@
|
||||
#include <compat/strl.h>
|
||||
#include <compat/posix_string.h>
|
||||
|
||||
#include "cheat_manager.h"
|
||||
#include "../runloop.h"
|
||||
#include "../dynamic.h"
|
||||
#include "../core.h"
|
||||
#include "../verbosity.h"
|
||||
#include "cheats.h"
|
||||
#include "runloop.h"
|
||||
#include "dynamic.h"
|
||||
#include "libretro_version_1.h"
|
||||
#include "verbosity.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHEEVOS
|
||||
#include "../cheevos.h"
|
||||
#include "cheevos.h"
|
||||
#endif
|
||||
|
||||
struct item_cheat
|
||||
@@ -81,7 +81,7 @@ void cheat_manager_apply_cheats(void)
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
core_reset_cheat();
|
||||
core_ctl(CORE_CTL_RETRO_CHEAT_RESET, NULL);
|
||||
|
||||
for (i = 0; i < handle->size; i++)
|
||||
{
|
||||
@@ -93,13 +93,13 @@ void cheat_manager_apply_cheats(void)
|
||||
cheat_info.enabled = true;
|
||||
cheat_info.code = handle->cheats[i].code;
|
||||
|
||||
core_set_cheat(&cheat_info);
|
||||
core_ctl(CORE_CTL_RETRO_CHEAT_SET, &cheat_info);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHEEVOS
|
||||
data_bool = idx != 0;
|
||||
cheevos_apply_cheats(&data_bool);
|
||||
cheevos_ctl(CHEEVOS_CTL_APPLY_CHEATS, &data_bool);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ bool cheat_manager_save(const char *path)
|
||||
settings_t *settings = config_get_ptr();
|
||||
cheat_manager_t *handle = cheat_manager_state;
|
||||
|
||||
fill_pathname_join(buf, settings->path.cheat_database,
|
||||
fill_pathname_join(buf, settings->cheat_database,
|
||||
path, sizeof(buf));
|
||||
|
||||
fill_pathname_noext(cheats_file, buf, ".cht", sizeof(cheats_file));
|
||||
@@ -158,17 +158,17 @@ bool cheat_manager_save(const char *path)
|
||||
char code_key[256] = {0};
|
||||
char enable_key[256] = {0};
|
||||
|
||||
snprintf(key, sizeof(key), "cheat%u", i);
|
||||
snprintf(desc_key, sizeof(desc_key), "cheat%u_desc", i);
|
||||
snprintf(code_key, sizeof(code_key), "cheat%u_code", i);
|
||||
snprintf(key, sizeof(key), "cheat%u", i);
|
||||
snprintf(desc_key, sizeof(desc_key), "cheat%u_desc", i);
|
||||
snprintf(code_key, sizeof(code_key), "cheat%u_code", i);
|
||||
snprintf(enable_key, sizeof(enable_key), "cheat%u_enable", i);
|
||||
|
||||
if (handle->cheats[i].desc)
|
||||
config_set_string(conf, desc_key, handle->cheats[i].desc);
|
||||
config_set_string(conf, desc_key, handle->cheats[i].desc);
|
||||
else
|
||||
config_set_string(conf, desc_key, handle->cheats[i].code);
|
||||
config_set_string(conf, code_key, handle->cheats[i].code);
|
||||
config_set_bool(conf, enable_key, handle->cheats[i].state);
|
||||
config_set_string(conf, desc_key, handle->cheats[i].code);
|
||||
config_set_string(conf, code_key, handle->cheats[i].code);
|
||||
config_set_bool(conf, enable_key, handle->cheats[i].state);
|
||||
}
|
||||
|
||||
ret = config_file_write(conf, cheats_file);
|
||||
@@ -177,7 +177,60 @@ bool cheat_manager_save(const char *path)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static cheat_manager_t *cheat_manager_new(unsigned size)
|
||||
bool cheat_manager_load(const char *path)
|
||||
{
|
||||
unsigned cheats = 0, i;
|
||||
cheat_manager_t *cheat;
|
||||
config_file_t *conf = config_file_new(path);
|
||||
|
||||
if (!conf)
|
||||
return false;
|
||||
|
||||
config_get_uint(conf, "cheats", &cheats);
|
||||
|
||||
if (cheats == 0)
|
||||
return false;
|
||||
|
||||
cheat = cheat_manager_new(cheats);
|
||||
|
||||
if (!cheat)
|
||||
return false;
|
||||
|
||||
for (i = 0; i < cheats; i++)
|
||||
{
|
||||
char key[64] = {0};
|
||||
char desc_key[256] = {0};
|
||||
char code_key[256] = {0};
|
||||
char enable_key[256] = {0};
|
||||
char *tmp = NULL;
|
||||
bool tmp_bool = false;
|
||||
|
||||
snprintf(key, sizeof(key), "cheat%u", i);
|
||||
snprintf(desc_key, sizeof(desc_key), "cheat%u_desc", i);
|
||||
snprintf(code_key, sizeof(code_key), "cheat%u_code", i);
|
||||
snprintf(enable_key, sizeof(enable_key), "cheat%u_enable", i);
|
||||
|
||||
if (config_get_string(conf, desc_key, &tmp))
|
||||
cheat->cheats[i].desc = strdup(tmp);
|
||||
|
||||
if (config_get_string(conf, code_key, &tmp))
|
||||
cheat->cheats[i].code = strdup(tmp);
|
||||
|
||||
if (config_get_bool(conf, enable_key, &tmp_bool))
|
||||
cheat->cheats[i].state = tmp_bool;
|
||||
|
||||
if (tmp)
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
config_file_free(conf);
|
||||
|
||||
cheat_manager_state = cheat;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
cheat_manager_t *cheat_manager_new(unsigned size)
|
||||
{
|
||||
unsigned i;
|
||||
cheat_manager_t *handle = (cheat_manager_t*)
|
||||
@@ -209,64 +262,6 @@ static cheat_manager_t *cheat_manager_new(unsigned size)
|
||||
return handle;
|
||||
}
|
||||
|
||||
bool cheat_manager_load(const char *path)
|
||||
{
|
||||
unsigned cheats = 0, i;
|
||||
cheat_manager_t *cheat;
|
||||
config_file_t *conf = config_file_new(path);
|
||||
|
||||
if (!conf)
|
||||
return false;
|
||||
|
||||
config_get_uint(conf, "cheats", &cheats);
|
||||
|
||||
if (cheats == 0)
|
||||
goto error;
|
||||
|
||||
cheat = cheat_manager_new(cheats);
|
||||
|
||||
if (!cheat)
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < cheats; i++)
|
||||
{
|
||||
char key[64] = {0};
|
||||
char desc_key[256] = {0};
|
||||
char code_key[256] = {0};
|
||||
char enable_key[256] = {0};
|
||||
char *tmp = NULL;
|
||||
bool tmp_bool = false;
|
||||
|
||||
snprintf(key, sizeof(key), "cheat%u", i);
|
||||
snprintf(desc_key, sizeof(desc_key), "cheat%u_desc", i);
|
||||
snprintf(code_key, sizeof(code_key), "cheat%u_code", i);
|
||||
snprintf(enable_key, sizeof(enable_key), "cheat%u_enable", i);
|
||||
|
||||
if (config_get_string(conf, desc_key, &tmp))
|
||||
cheat->cheats[i].desc = strdup(tmp);
|
||||
|
||||
if (config_get_string(conf, code_key, &tmp))
|
||||
cheat->cheats[i].code = strdup(tmp);
|
||||
|
||||
if (config_get_bool(conf, enable_key, &tmp_bool))
|
||||
cheat->cheats[i].state = tmp_bool;
|
||||
|
||||
if (tmp)
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
config_file_free(conf);
|
||||
|
||||
cheat_manager_state = cheat;
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
config_file_free(conf);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool cheat_manager_realloc(unsigned new_size)
|
||||
{
|
||||
unsigned i;
|
||||
@@ -14,18 +14,21 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __CHEAT_MANAGER_H
|
||||
#define __CHEAT_MANAGER_H
|
||||
#ifndef __RARCH_CHEATS_H
|
||||
#define __RARCH_CHEATS_H
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct cheat_manager cheat_manager_t;
|
||||
|
||||
unsigned cheat_manager_get_size(void);
|
||||
|
||||
cheat_manager_t *cheat_manager_new(unsigned size);
|
||||
|
||||
bool cheat_manager_load(const char *path);
|
||||
|
||||
/**
|
||||
@@ -73,6 +76,8 @@ void cheat_manager_state_free(void);
|
||||
|
||||
bool cheat_manager_alloc_if_empty(void);
|
||||
|
||||
RETRO_END_DECLS
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -19,9 +19,28 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <retro_common_api.h>
|
||||
enum cheevos_ctl_state
|
||||
{
|
||||
CHEEVOS_CTL_NONE = 0,
|
||||
CHEEVOS_CTL_TEST,
|
||||
CHEEVOS_CTL_LOAD,
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
CHEEVOS_CTL_APPLY_CHEATS,
|
||||
|
||||
/* Unload the achievements from memory. */
|
||||
CHEEVOS_CTL_UNLOAD,
|
||||
|
||||
/* Toggle Hardcore Mode */
|
||||
CHEEVOS_CTL_TOGGLE_HARDCORE_MODE,
|
||||
|
||||
/* Load the achievements into memory if
|
||||
* the game has content. */
|
||||
CHEEVOS_CTL_SET_CHEATS,
|
||||
|
||||
CHEEVOS_CTL_GET_DESCRIPTION,
|
||||
|
||||
CHEEVOS_CTL_POPULATE_MENU
|
||||
};
|
||||
|
||||
typedef struct cheevos_ctx_desc
|
||||
{
|
||||
@@ -30,37 +49,6 @@ typedef struct cheevos_ctx_desc
|
||||
size_t len;
|
||||
} cheevos_ctx_desc_t;
|
||||
|
||||
bool cheevos_load(const void *data);
|
||||
|
||||
void cheevos_populate_menu(void *data);
|
||||
|
||||
bool cheevos_get_description(cheevos_ctx_desc_t *desc);
|
||||
|
||||
bool cheevos_apply_cheats(bool *data_bool);
|
||||
|
||||
bool cheevos_unload(void);
|
||||
|
||||
bool cheevos_toggle_hardcore_mode(void);
|
||||
|
||||
bool cheevos_test(void);
|
||||
|
||||
bool cheevos_set_cheats(void);
|
||||
|
||||
void cheevos_set_support_cheevos(bool state);
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned size;
|
||||
unsigned type;
|
||||
int bank_id;
|
||||
unsigned value;
|
||||
unsigned previous;
|
||||
} cheevos_var_t;
|
||||
|
||||
void cheevos_parse_guest_addr(cheevos_var_t *var, unsigned value);
|
||||
uint8_t *cheevos_get_memory(const cheevos_var_t *var);
|
||||
|
||||
RETRO_END_DECLS
|
||||
bool cheevos_ctl(enum cheevos_ctl_state state, void *data);
|
||||
|
||||
#endif /* __RARCH_CHEEVOS_H */
|
||||
@@ -23,230 +23,37 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct command command_t;
|
||||
|
||||
typedef struct command_handle
|
||||
enum rarch_cmd_ctl_state
|
||||
{
|
||||
command_t *handle;
|
||||
unsigned id;
|
||||
} command_handle_t;
|
||||
|
||||
enum event_command
|
||||
{
|
||||
CMD_EVENT_NONE = 0,
|
||||
/* Resets RetroArch. */
|
||||
CMD_EVENT_RESET,
|
||||
CMD_EVENT_SET_PER_GAME_RESOLUTION,
|
||||
CMD_EVENT_SET_FRAME_LIMIT,
|
||||
/* Loads core. */
|
||||
CMD_EVENT_LOAD_CORE_DEINIT,
|
||||
CMD_EVENT_LOAD_CORE,
|
||||
CMD_EVENT_LOAD_CORE_PERSIST,
|
||||
CMD_EVENT_UNLOAD_CORE,
|
||||
CMD_EVENT_LOAD_STATE,
|
||||
/* Swaps the current state with what's on the undo load buffer */
|
||||
CMD_EVENT_UNDO_LOAD_STATE,
|
||||
/* Rewrites a savestate on disk */
|
||||
CMD_EVENT_UNDO_SAVE_STATE,
|
||||
CMD_EVENT_SAVE_STATE,
|
||||
CMD_EVENT_SAVE_STATE_DECREMENT,
|
||||
CMD_EVENT_SAVE_STATE_INCREMENT,
|
||||
/* Takes screenshot. */
|
||||
CMD_EVENT_TAKE_SCREENSHOT,
|
||||
/* Quits RetroArch. */
|
||||
CMD_EVENT_QUIT,
|
||||
/* Reinitialize all drivers. */
|
||||
CMD_EVENT_REINIT,
|
||||
/* Toggles cheevos hardcore mode. */
|
||||
CMD_EVENT_CHEEVOS_HARDCORE_MODE_TOGGLE,
|
||||
/* Deinitialize rewind. */
|
||||
CMD_EVENT_REWIND_DEINIT,
|
||||
/* Initializes rewind. */
|
||||
CMD_EVENT_REWIND_INIT,
|
||||
/* Toggles rewind. */
|
||||
CMD_EVENT_REWIND_TOGGLE,
|
||||
/* Deinitializes autosave. */
|
||||
CMD_EVENT_AUTOSAVE_DEINIT,
|
||||
/* Initializes autosave. */
|
||||
CMD_EVENT_AUTOSAVE_INIT,
|
||||
CMD_EVENT_AUTOSAVE_STATE,
|
||||
/* Stops audio. */
|
||||
CMD_EVENT_AUDIO_STOP,
|
||||
/* Starts audio. */
|
||||
CMD_EVENT_AUDIO_START,
|
||||
/* Mutes audio. */
|
||||
CMD_EVENT_AUDIO_MUTE_TOGGLE,
|
||||
/* Initializes overlay. */
|
||||
CMD_EVENT_OVERLAY_INIT,
|
||||
/* Deinitializes overlay. */
|
||||
CMD_EVENT_OVERLAY_DEINIT,
|
||||
/* Sets current scale factor for overlay. */
|
||||
CMD_EVENT_OVERLAY_SET_SCALE_FACTOR,
|
||||
/* Sets current alpha modulation for overlay. */
|
||||
CMD_EVENT_OVERLAY_SET_ALPHA_MOD,
|
||||
/* Cycle to next overlay. */
|
||||
CMD_EVENT_OVERLAY_NEXT,
|
||||
/* Deinitializes overlay. */
|
||||
CMD_EVENT_DSP_FILTER_INIT,
|
||||
/* Deinitializes graphics filter. */
|
||||
CMD_EVENT_DSP_FILTER_DEINIT,
|
||||
/* Deinitializes GPU recoring. */
|
||||
CMD_EVENT_GPU_RECORD_DEINIT,
|
||||
/* Initializes recording system. */
|
||||
CMD_EVENT_RECORD_INIT,
|
||||
/* Deinitializes recording system. */
|
||||
CMD_EVENT_RECORD_DEINIT,
|
||||
/* Deinitializes history playlist. */
|
||||
CMD_EVENT_HISTORY_DEINIT,
|
||||
/* Initializes history playlist. */
|
||||
CMD_EVENT_HISTORY_INIT,
|
||||
/* Deinitializes core information. */
|
||||
CMD_EVENT_CORE_INFO_DEINIT,
|
||||
/* Initializes core information. */
|
||||
CMD_EVENT_CORE_INFO_INIT,
|
||||
/* Deinitializes core. */
|
||||
CMD_EVENT_CORE_DEINIT,
|
||||
/* Initializes core. */
|
||||
CMD_EVENT_CORE_INIT,
|
||||
/* Set audio blocking state. */
|
||||
CMD_EVENT_AUDIO_SET_BLOCKING_STATE,
|
||||
/* Set audio nonblocking state. */
|
||||
CMD_EVENT_AUDIO_SET_NONBLOCKING_STATE,
|
||||
/* Apply video state changes. */
|
||||
CMD_EVENT_VIDEO_APPLY_STATE_CHANGES,
|
||||
/* Set video blocking state. */
|
||||
CMD_EVENT_VIDEO_SET_BLOCKING_STATE,
|
||||
/* Set video nonblocking state. */
|
||||
CMD_EVENT_VIDEO_SET_NONBLOCKING_STATE,
|
||||
/* Sets current aspect ratio index. */
|
||||
CMD_EVENT_VIDEO_SET_ASPECT_RATIO,
|
||||
CMD_EVENT_RESET_CONTEXT,
|
||||
/* Restarts RetroArch. */
|
||||
CMD_EVENT_RESTART_RETROARCH,
|
||||
/* Shutdown the OS */
|
||||
CMD_EVENT_SHUTDOWN,
|
||||
/* Reboot the OS */
|
||||
CMD_EVENT_REBOOT,
|
||||
/* Resume RetroArch when in menu. */
|
||||
CMD_EVENT_RESUME,
|
||||
/* Toggles pause. */
|
||||
CMD_EVENT_PAUSE_TOGGLE,
|
||||
/* Pauses RetroArch. */
|
||||
CMD_EVENT_UNPAUSE,
|
||||
/* Unpauses retroArch. */
|
||||
CMD_EVENT_PAUSE,
|
||||
CMD_EVENT_PAUSE_CHECKS,
|
||||
CMD_EVENT_MENU_SAVE_CURRENT_CONFIG,
|
||||
CMD_EVENT_MENU_SAVE_CONFIG,
|
||||
CMD_EVENT_MENU_PAUSE_LIBRETRO,
|
||||
/* Toggles menu on/off. */
|
||||
CMD_EVENT_MENU_TOGGLE,
|
||||
CMD_EVENT_MENU_REFRESH,
|
||||
/* Applies shader changes. */
|
||||
CMD_EVENT_SHADERS_APPLY_CHANGES,
|
||||
/* Initializes shader directory. */
|
||||
CMD_EVENT_SHADER_DIR_INIT,
|
||||
/* Deinitializes shader directory. */
|
||||
CMD_EVENT_SHADER_DIR_DEINIT,
|
||||
/* Initializes controllers. */
|
||||
CMD_EVENT_CONTROLLERS_INIT,
|
||||
CMD_EVENT_SAVEFILES,
|
||||
/* Initializes savefiles. */
|
||||
CMD_EVENT_SAVEFILES_INIT,
|
||||
/* Deinitializes savefiles. */
|
||||
CMD_EVENT_SAVEFILES_DEINIT,
|
||||
/* Initializes cheats. */
|
||||
CMD_EVENT_CHEATS_INIT,
|
||||
/* Deinitializes cheats. */
|
||||
CMD_EVENT_CHEATS_DEINIT,
|
||||
/* Apply cheats. */
|
||||
CMD_EVENT_CHEATS_APPLY,
|
||||
/* Deinitializes network system. */
|
||||
CMD_EVENT_NETWORK_DEINIT,
|
||||
/* Initializes network system. */
|
||||
CMD_EVENT_NETWORK_INIT,
|
||||
/* Initializes netplay system. */
|
||||
CMD_EVENT_NETPLAY_INIT,
|
||||
/* Deinitializes netplay system. */
|
||||
CMD_EVENT_NETPLAY_DEINIT,
|
||||
/* Flip netplay players. */
|
||||
CMD_EVENT_NETPLAY_FLIP_PLAYERS,
|
||||
/* Initializes BSV movie. */
|
||||
CMD_EVENT_BSV_MOVIE_INIT,
|
||||
/* Deinitializes BSV movie. */
|
||||
CMD_EVENT_BSV_MOVIE_DEINIT,
|
||||
/* Initializes command interface. */
|
||||
CMD_EVENT_COMMAND_INIT,
|
||||
/* Deinitialize command interface. */
|
||||
CMD_EVENT_COMMAND_DEINIT,
|
||||
/* Initializes remote gamepad interface. */
|
||||
CMD_EVENT_REMOTE_INIT,
|
||||
/* Deinitializes remote gamepad interface. */
|
||||
CMD_EVENT_REMOTE_DEINIT,
|
||||
/* Reinitializes audio driver. */
|
||||
CMD_EVENT_AUDIO_REINIT,
|
||||
/* Resizes windowed scale. Will reinitialize video driver. */
|
||||
CMD_EVENT_RESIZE_WINDOWED_SCALE,
|
||||
/* Deinitializes temporary content. */
|
||||
CMD_EVENT_TEMPORARY_CONTENT_DEINIT,
|
||||
CMD_EVENT_SUBSYSTEM_FULLPATHS_DEINIT,
|
||||
CMD_EVENT_LOG_FILE_DEINIT,
|
||||
/* Toggles disk eject. */
|
||||
CMD_EVENT_DISK_EJECT_TOGGLE,
|
||||
/* Cycle to next disk. */
|
||||
CMD_EVENT_DISK_NEXT,
|
||||
/* Cycle to previous disk. */
|
||||
CMD_EVENT_DISK_PREV,
|
||||
/* Appends disk image to disk image list. */
|
||||
CMD_EVENT_DISK_APPEND_IMAGE,
|
||||
/* Stops rumbling. */
|
||||
CMD_EVENT_RUMBLE_STOP,
|
||||
/* Toggles mouse grab. */
|
||||
CMD_EVENT_GRAB_MOUSE_TOGGLE,
|
||||
/* Toggles fullscreen mode. */
|
||||
CMD_EVENT_FULLSCREEN_TOGGLE,
|
||||
CMD_EVENT_PERFCNT_REPORT_FRONTEND_LOG,
|
||||
CMD_EVENT_VOLUME_UP,
|
||||
CMD_EVENT_VOLUME_DOWN,
|
||||
CMD_EVENT_DISABLE_OVERRIDES
|
||||
RARCH_CMD_CTL_NONE = 0,
|
||||
RARCH_CMD_CTL_GET,
|
||||
RARCH_CMD_CTL_SET,
|
||||
RARCH_CMD_CTL_POLL,
|
||||
RARCH_CMD_CTL_NETWORK_SEND,
|
||||
RARCH_CMD_CTL_FREE
|
||||
};
|
||||
|
||||
#ifdef HAVE_COMMAND
|
||||
#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY)
|
||||
bool command_network_send(const char *cmd_);
|
||||
#endif
|
||||
typedef struct rarch_cmd rarch_cmd_t;
|
||||
|
||||
typedef struct rarch_cmd_handle
|
||||
{
|
||||
rarch_cmd_t *handle;
|
||||
unsigned id;
|
||||
} rarch_cmd_handle_t;
|
||||
|
||||
rarch_cmd_t *rarch_cmd_new(bool stdin_enable,
|
||||
bool network_enable, uint16_t port);
|
||||
|
||||
bool rarch_cmd_ctl(enum rarch_cmd_ctl_state state, void *data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
bool command_network_new(
|
||||
command_t *handle,
|
||||
bool stdin_enable,
|
||||
bool network_enable,
|
||||
uint16_t port);
|
||||
|
||||
command_t *command_new(bool local_enable);
|
||||
|
||||
bool command_poll(command_t *handle);
|
||||
|
||||
bool command_get(command_handle_t *handle);
|
||||
|
||||
bool command_set(command_handle_t *handle);
|
||||
|
||||
bool command_free(command_t *handle);
|
||||
|
||||
/**
|
||||
* command_event:
|
||||
* @cmd : Command index.
|
||||
*
|
||||
* Performs RetroArch command with index @cmd.
|
||||
*
|
||||
* Returns: true (1) on success, otherwise false (0).
|
||||
**/
|
||||
bool command_event(enum event_command action, void *data);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
+1711
File diff suppressed because it is too large.
Load diff
+225
@@ -0,0 +1,225 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2016 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_EVENT_H__
|
||||
#define COMMAND_EVENT_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <boolean.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum event_command
|
||||
{
|
||||
EVENT_CMD_NONE = 0,
|
||||
/* Resets RetroArch. */
|
||||
EVENT_CMD_RESET,
|
||||
/* Loads content file. */
|
||||
EVENT_CMD_LOAD_CONTENT,
|
||||
EVENT_CMD_LOAD_CONTENT_PERSIST,
|
||||
#ifdef HAVE_FFMPEG
|
||||
EVENT_CMD_LOAD_CONTENT_FFMPEG,
|
||||
#endif
|
||||
EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER,
|
||||
EVENT_CMD_SET_PER_GAME_RESOLUTION,
|
||||
EVENT_CMD_SET_FRAME_LIMIT,
|
||||
/* Loads core. */
|
||||
EVENT_CMD_LOAD_CORE_DEINIT,
|
||||
EVENT_CMD_LOAD_CORE,
|
||||
EVENT_CMD_LOAD_CORE_PERSIST,
|
||||
EVENT_CMD_UNLOAD_CORE,
|
||||
EVENT_CMD_LOAD_STATE,
|
||||
EVENT_CMD_SAVE_STATE,
|
||||
EVENT_CMD_SAVE_STATE_DECREMENT,
|
||||
EVENT_CMD_SAVE_STATE_INCREMENT,
|
||||
/* Takes screenshot. */
|
||||
EVENT_CMD_TAKE_SCREENSHOT,
|
||||
/* Quits RetroArch. */
|
||||
EVENT_CMD_QUIT,
|
||||
/* Reinitialize all drivers. */
|
||||
EVENT_CMD_REINIT,
|
||||
/* Toggles cheevos hardcore mode. */
|
||||
EVENT_CMD_CHEEVOS_HARDCORE_MODE_TOGGLE,
|
||||
/* Deinitialize rewind. */
|
||||
EVENT_CMD_REWIND_DEINIT,
|
||||
/* Initializes rewind. */
|
||||
EVENT_CMD_REWIND_INIT,
|
||||
/* Toggles rewind. */
|
||||
EVENT_CMD_REWIND_TOGGLE,
|
||||
/* Deinitializes autosave. */
|
||||
EVENT_CMD_AUTOSAVE_DEINIT,
|
||||
/* Initializes autosave. */
|
||||
EVENT_CMD_AUTOSAVE_INIT,
|
||||
EVENT_CMD_AUTOSAVE_STATE,
|
||||
/* Stops audio. */
|
||||
EVENT_CMD_AUDIO_STOP,
|
||||
/* Starts audio. */
|
||||
EVENT_CMD_AUDIO_START,
|
||||
/* Mutes audio. */
|
||||
EVENT_CMD_AUDIO_MUTE_TOGGLE,
|
||||
/* Initializes overlay. */
|
||||
EVENT_CMD_OVERLAY_INIT,
|
||||
/* Deinitializes overlay. */
|
||||
EVENT_CMD_OVERLAY_DEINIT,
|
||||
/* Sets current scale factor for overlay. */
|
||||
EVENT_CMD_OVERLAY_SET_SCALE_FACTOR,
|
||||
/* Sets current alpha modulation for overlay. */
|
||||
EVENT_CMD_OVERLAY_SET_ALPHA_MOD,
|
||||
/* Cycle to next overlay. */
|
||||
EVENT_CMD_OVERLAY_NEXT,
|
||||
/* Deinitializes overlay. */
|
||||
EVENT_CMD_DSP_FILTER_INIT,
|
||||
/* Deinitializes graphics filter. */
|
||||
EVENT_CMD_DSP_FILTER_DEINIT,
|
||||
/* Deinitializes GPU recoring. */
|
||||
EVENT_CMD_GPU_RECORD_DEINIT,
|
||||
/* Initializes recording system. */
|
||||
EVENT_CMD_RECORD_INIT,
|
||||
/* Deinitializes recording system. */
|
||||
EVENT_CMD_RECORD_DEINIT,
|
||||
/* Deinitializes history playlist. */
|
||||
EVENT_CMD_HISTORY_DEINIT,
|
||||
/* Initializes history playlist. */
|
||||
EVENT_CMD_HISTORY_INIT,
|
||||
/* Deinitializes core information. */
|
||||
EVENT_CMD_CORE_INFO_DEINIT,
|
||||
/* Initializes core information. */
|
||||
EVENT_CMD_CORE_INFO_INIT,
|
||||
/* Deinitializes core. */
|
||||
EVENT_CMD_CORE_DEINIT,
|
||||
/* Initializes core. */
|
||||
EVENT_CMD_CORE_INIT,
|
||||
/* Set audio blocking state. */
|
||||
EVENT_CMD_AUDIO_SET_BLOCKING_STATE,
|
||||
/* Set audio nonblocking state. */
|
||||
EVENT_CMD_AUDIO_SET_NONBLOCKING_STATE,
|
||||
/* Apply video state changes. */
|
||||
EVENT_CMD_VIDEO_APPLY_STATE_CHANGES,
|
||||
/* Set video blocking state. */
|
||||
EVENT_CMD_VIDEO_SET_BLOCKING_STATE,
|
||||
/* Set video nonblocking state. */
|
||||
EVENT_CMD_VIDEO_SET_NONBLOCKING_STATE,
|
||||
/* Sets current aspect ratio index. */
|
||||
EVENT_CMD_VIDEO_SET_ASPECT_RATIO,
|
||||
EVENT_CMD_RESET_CONTEXT,
|
||||
/* Restarts RetroArch. */
|
||||
EVENT_CMD_RESTART_RETROARCH,
|
||||
/* Force-quit RetroArch. */
|
||||
EVENT_CMD_QUIT_RETROARCH,
|
||||
/* Shutdown the OS */
|
||||
EVENT_CMD_SHUTDOWN,
|
||||
/* Reboot the OS */
|
||||
EVENT_CMD_REBOOT,
|
||||
/* Resume RetroArch when in menu. */
|
||||
EVENT_CMD_RESUME,
|
||||
/* Toggles pause. */
|
||||
EVENT_CMD_PAUSE_TOGGLE,
|
||||
/* Pauses RetroArch. */
|
||||
EVENT_CMD_UNPAUSE,
|
||||
/* Unpauses retroArch. */
|
||||
EVENT_CMD_PAUSE,
|
||||
EVENT_CMD_PAUSE_CHECKS,
|
||||
EVENT_CMD_MENU_SAVE_CURRENT_CONFIG,
|
||||
EVENT_CMD_MENU_SAVE_CONFIG,
|
||||
EVENT_CMD_MENU_PAUSE_LIBRETRO,
|
||||
/* Toggles menu on/off. */
|
||||
EVENT_CMD_MENU_TOGGLE,
|
||||
EVENT_CMD_MENU_REFRESH,
|
||||
/* Applies shader changes. */
|
||||
EVENT_CMD_SHADERS_APPLY_CHANGES,
|
||||
/* Initializes shader directory. */
|
||||
EVENT_CMD_SHADER_DIR_INIT,
|
||||
/* Deinitializes shader directory. */
|
||||
EVENT_CMD_SHADER_DIR_DEINIT,
|
||||
/* Initializes controllers. */
|
||||
EVENT_CMD_CONTROLLERS_INIT,
|
||||
EVENT_CMD_SAVEFILES,
|
||||
/* Initializes savefiles. */
|
||||
EVENT_CMD_SAVEFILES_INIT,
|
||||
/* Deinitializes savefiles. */
|
||||
EVENT_CMD_SAVEFILES_DEINIT,
|
||||
/* Initializes cheats. */
|
||||
EVENT_CMD_CHEATS_INIT,
|
||||
/* Deinitializes cheats. */
|
||||
EVENT_CMD_CHEATS_DEINIT,
|
||||
/* Apply cheats. */
|
||||
EVENT_CMD_CHEATS_APPLY,
|
||||
/* Deinitializes network system. */
|
||||
EVENT_CMD_NETWORK_DEINIT,
|
||||
/* Initializes network system. */
|
||||
EVENT_CMD_NETWORK_INIT,
|
||||
/* Initializes netplay system. */
|
||||
EVENT_CMD_NETPLAY_INIT,
|
||||
/* Deinitializes netplay system. */
|
||||
EVENT_CMD_NETPLAY_DEINIT,
|
||||
/* Flip netplay players. */
|
||||
EVENT_CMD_NETPLAY_FLIP_PLAYERS,
|
||||
/* Initializes BSV movie. */
|
||||
EVENT_CMD_BSV_MOVIE_INIT,
|
||||
/* Deinitializes BSV movie. */
|
||||
EVENT_CMD_BSV_MOVIE_DEINIT,
|
||||
/* Initializes command interface. */
|
||||
EVENT_CMD_COMMAND_INIT,
|
||||
/* Deinitialize command interface. */
|
||||
EVENT_CMD_COMMAND_DEINIT,
|
||||
/* Initializes remote gamepad interface. */
|
||||
EVENT_CMD_REMOTE_INIT,
|
||||
/* Deinitializes remote gamepad interface. */
|
||||
EVENT_CMD_REMOTE_DEINIT,
|
||||
/* Reinitializes audio driver. */
|
||||
EVENT_CMD_AUDIO_REINIT,
|
||||
/* Resizes windowed scale. Will reinitialize video driver. */
|
||||
EVENT_CMD_RESIZE_WINDOWED_SCALE,
|
||||
/* Deinitializes temporary content. */
|
||||
EVENT_CMD_TEMPORARY_CONTENT_DEINIT,
|
||||
EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT,
|
||||
EVENT_CMD_LOG_FILE_DEINIT,
|
||||
/* Toggles disk eject. */
|
||||
EVENT_CMD_DISK_EJECT_TOGGLE,
|
||||
/* Cycle to next disk. */
|
||||
EVENT_CMD_DISK_NEXT,
|
||||
/* Cycle to previous disk. */
|
||||
EVENT_CMD_DISK_PREV,
|
||||
/* Appends disk image to disk image list. */
|
||||
EVENT_CMD_DISK_APPEND_IMAGE,
|
||||
/* Stops rumbling. */
|
||||
EVENT_CMD_RUMBLE_STOP,
|
||||
/* Toggles mouse grab. */
|
||||
EVENT_CMD_GRAB_MOUSE_TOGGLE,
|
||||
/* Toggles fullscreen mode. */
|
||||
EVENT_CMD_FULLSCREEN_TOGGLE,
|
||||
EVENT_CMD_PERFCNT_REPORT_FRONTEND_LOG,
|
||||
EVENT_CMD_VOLUME_UP,
|
||||
EVENT_CMD_VOLUME_DOWN,
|
||||
EVENT_CMD_EXEC
|
||||
};
|
||||
|
||||
/**
|
||||
* event_command:
|
||||
* @cmd : Command index.
|
||||
*
|
||||
* Performs RetroArch command with index @cmd.
|
||||
*
|
||||
* Returns: true (1) on success, otherwise false (0).
|
||||
**/
|
||||
bool event_cmd_ctl(enum event_command action, void *data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+4
-40
@@ -18,6 +18,7 @@
|
||||
#define __CONFIG_DEF_H
|
||||
|
||||
#include <boolean.h>
|
||||
#include "libretro.h"
|
||||
#include "driver.h"
|
||||
#include "gfx/video_driver.h"
|
||||
|
||||
@@ -29,7 +30,6 @@ enum
|
||||
{
|
||||
VIDEO_GL = 0,
|
||||
VIDEO_VULKAN,
|
||||
VIDEO_DRM,
|
||||
VIDEO_XVIDEO,
|
||||
VIDEO_SDL,
|
||||
VIDEO_SDL2,
|
||||
@@ -126,15 +126,12 @@ enum
|
||||
MENU_XUI,
|
||||
MENU_MATERIALUI,
|
||||
MENU_XMB,
|
||||
MENU_NUKLEAR,
|
||||
|
||||
RECORD_FFMPEG,
|
||||
RECORD_NULL
|
||||
};
|
||||
|
||||
#if defined(HW_RVL)
|
||||
#define MAX_GAMMA_SETTING 30
|
||||
#elif defined(GEKKO)
|
||||
#ifdef GEKKO
|
||||
#define MAX_GAMMA_SETTING 2
|
||||
#else
|
||||
#define MAX_GAMMA_SETTING 1
|
||||
@@ -324,7 +321,7 @@ enum
|
||||
|
||||
#if defined(HAVE_XUI)
|
||||
#define MENU_DEFAULT_DRIVER MENU_XUI
|
||||
#elif defined(IOS) || defined(ANDROID) || defined(__QNX__)
|
||||
#elif defined(IOS) || defined(ANDROID)
|
||||
#define MENU_DEFAULT_DRIVER MENU_MATERIALUI
|
||||
#elif defined(__MACH__) && defined(HAVE_XMB) || defined(__CELLOS_LV2__)
|
||||
#define MENU_DEFAULT_DRIVER MENU_XMB
|
||||
@@ -362,7 +359,7 @@ static const bool def_history_list_enable = true;
|
||||
|
||||
static const unsigned int def_user_language = 0;
|
||||
|
||||
#if (defined(_WIN32) && !defined(_XBOX))
|
||||
#if (defined(__APPLE__) && defined(__MACH__) && defined(OSX)) || (defined(_WIN32) && !defined(_XBOX))
|
||||
static const bool def_mouse_enable = true;
|
||||
#else
|
||||
static const bool def_mouse_enable = false;
|
||||
@@ -412,8 +409,6 @@ static const bool disable_composition = false;
|
||||
/* Video VSYNC (recommended) */
|
||||
static const bool vsync = true;
|
||||
|
||||
static const unsigned max_swapchain_images = 3;
|
||||
|
||||
/* Attempts to hard-synchronize CPU and GPU.
|
||||
* Can reduce latency at cost of performance. */
|
||||
static const bool hard_sync = false;
|
||||
@@ -512,38 +507,11 @@ static const bool default_overlay_enable = false;
|
||||
static const bool overlay_hide_in_menu = true;
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
#include "menu/menu_display.h"
|
||||
|
||||
static bool default_block_config_read = true;
|
||||
|
||||
static unsigned xmb_scale_factor = 100;
|
||||
static unsigned xmb_alpha_factor = 75;
|
||||
|
||||
static unsigned xmb_icon_theme = XMB_ICON_THEME_MONOCHROME;
|
||||
static unsigned xmb_theme = XMB_THEME_ELECTRIC_BLUE;
|
||||
|
||||
#ifdef HAVE_LAKKA
|
||||
static bool xmb_shadows_enable = false;
|
||||
#else
|
||||
static bool xmb_shadows_enable = true;
|
||||
#endif
|
||||
|
||||
static float menu_wallpaper_opacity = 0.300;
|
||||
|
||||
static float menu_footer_opacity = 1.000;
|
||||
|
||||
static float menu_header_opacity = 1.000;
|
||||
|
||||
static unsigned menu_background_gradient = 4;
|
||||
|
||||
#if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL) || defined(HAVE_VULKAN)
|
||||
#if defined(HAVE_OPENGLES2) || defined(OSX_PPC)
|
||||
static unsigned menu_shader_pipeline = 1;
|
||||
#else
|
||||
static unsigned menu_shader_pipeline = 2;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static bool show_advanced_settings = true;
|
||||
static const uint32_t menu_entry_normal_color = 0xffffffff;
|
||||
static const uint32_t menu_entry_hover_color = 0xff64ff64;
|
||||
@@ -797,10 +765,6 @@ static const unsigned input_max_users = 5;
|
||||
|
||||
static const unsigned input_poll_type_behavior = 2;
|
||||
|
||||
static const unsigned input_bind_timeout = 5;
|
||||
|
||||
static const unsigned menu_thumbnails_default = 3;
|
||||
|
||||
#ifdef IOS
|
||||
static const bool ui_companion_start_on_boot = false;
|
||||
#else
|
||||
|
||||
+2
-20
@@ -32,7 +32,7 @@ static const bool _network_command_supp = true;
|
||||
static const bool _network_command_supp = false;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETWORKGAMEPAD
|
||||
#ifdef HAVE_NETWORK_GAMEPAD
|
||||
static const bool _network_gamepad_supp = true;
|
||||
#else
|
||||
static const bool _network_gamepad_supp = false;
|
||||
@@ -80,7 +80,7 @@ static const bool _vulkan_supp = true;
|
||||
static const bool _vulkan_supp = false;
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES2) || defined(HAVE_OPENGLES3) || defined(HAVE_OPENGLES_3_1) || defined(HAVE_OPENGLES_3_2)
|
||||
#if defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES2) || defined(HAVE_OPENGLES3)
|
||||
static const bool _opengles_supp = true;
|
||||
#else
|
||||
static const bool _opengles_supp = false;
|
||||
@@ -302,24 +302,6 @@ static const bool _rpng_supp = true;
|
||||
static const bool _rpng_supp = false;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RJPEG
|
||||
static const bool _rjpeg_supp = true;
|
||||
#else
|
||||
static const bool _rjpeg_supp = false;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RBMP
|
||||
static const bool _rbmp_supp = true;
|
||||
#else
|
||||
static const bool _rbmp_supp = false;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RTGA
|
||||
static const bool _rtga_supp = true;
|
||||
#else
|
||||
static const bool _rtga_supp = false;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CORETEXT
|
||||
static const bool _coretext_supp = true;
|
||||
#else
|
||||
|
||||
+671
-953
File diff suppressed because it is too large.
Load diff
+53
-100
@@ -20,7 +20,6 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
|
||||
#include "gfx/video_driver.h"
|
||||
#include "driver.h"
|
||||
@@ -29,7 +28,9 @@
|
||||
#define MAX_USERS 16
|
||||
#endif
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* All config related settings go here. */
|
||||
|
||||
@@ -55,7 +56,6 @@ typedef struct settings
|
||||
bool vsync;
|
||||
bool hard_sync;
|
||||
bool black_frame_insertion;
|
||||
unsigned max_swapchain_images;
|
||||
unsigned swap_interval;
|
||||
unsigned hard_sync_frames;
|
||||
unsigned frame_delay;
|
||||
@@ -72,12 +72,17 @@ typedef struct settings
|
||||
unsigned aspect_ratio_idx;
|
||||
unsigned rotation;
|
||||
|
||||
char shader_path[PATH_MAX_LENGTH];
|
||||
bool shader_enable;
|
||||
|
||||
char softfilter_plugin[PATH_MAX_LENGTH];
|
||||
float refresh_rate;
|
||||
bool threaded;
|
||||
|
||||
char filter_dir[PATH_MAX_LENGTH];
|
||||
char shader_dir[PATH_MAX_LENGTH];
|
||||
|
||||
char font_path[PATH_MAX_LENGTH];
|
||||
float font_size;
|
||||
bool font_enable;
|
||||
float msg_pos_x;
|
||||
@@ -118,23 +123,9 @@ typedef struct settings
|
||||
bool timedate_enable;
|
||||
bool core_enable;
|
||||
bool dynamic_wallpaper_enable;
|
||||
unsigned thumbnails;
|
||||
bool boxart_enable;
|
||||
bool throttle;
|
||||
|
||||
struct
|
||||
{
|
||||
float opacity;
|
||||
} wallpaper;
|
||||
|
||||
struct
|
||||
{
|
||||
float opacity;
|
||||
} footer;
|
||||
|
||||
struct
|
||||
{
|
||||
float opacity;
|
||||
} header;
|
||||
char wallpaper[PATH_MAX_LENGTH];
|
||||
|
||||
struct
|
||||
{
|
||||
@@ -173,24 +164,11 @@ typedef struct settings
|
||||
unsigned entry_normal_color;
|
||||
unsigned entry_hover_color;
|
||||
unsigned title_color;
|
||||
unsigned xmb_scale_factor;
|
||||
unsigned xmb_alpha_factor;
|
||||
char xmb_font[PATH_MAX_LENGTH];
|
||||
bool throttle_framerate;
|
||||
bool linear_filter;
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned shader_pipeline;
|
||||
char font[PATH_MAX_LENGTH];
|
||||
unsigned scale_factor;
|
||||
unsigned alpha_factor;
|
||||
unsigned theme;
|
||||
unsigned menu_color_theme;
|
||||
bool shadows_enable;
|
||||
} xmb;
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned menu_color_theme;
|
||||
} materialui;
|
||||
} menu;
|
||||
#endif
|
||||
|
||||
@@ -218,20 +196,22 @@ typedef struct settings
|
||||
struct
|
||||
{
|
||||
char driver[32];
|
||||
char resampler[32];
|
||||
char device[PATH_MAX_LENGTH];
|
||||
bool enable;
|
||||
bool mute_enable;
|
||||
unsigned out_rate;
|
||||
unsigned block_frames;
|
||||
char device[PATH_MAX_LENGTH];
|
||||
unsigned latency;
|
||||
bool sync;
|
||||
|
||||
char dsp_plugin[PATH_MAX_LENGTH];
|
||||
char filter_dir[PATH_MAX_LENGTH];
|
||||
|
||||
bool rate_control;
|
||||
float rate_control_delta;
|
||||
float max_timing_skew;
|
||||
float volume; /* dB scale. */
|
||||
char resampler[32];
|
||||
} audio;
|
||||
|
||||
struct
|
||||
@@ -239,7 +219,6 @@ typedef struct settings
|
||||
char driver[32];
|
||||
char joypad_driver[32];
|
||||
char keyboard_layout[64];
|
||||
char device_names[MAX_USERS][64];
|
||||
|
||||
unsigned remap_ids[MAX_USERS][RARCH_BIND_LIST_END];
|
||||
struct retro_keybind binds[MAX_USERS][RARCH_BIND_LIST_END];
|
||||
@@ -260,6 +239,7 @@ typedef struct settings
|
||||
float axis_threshold;
|
||||
unsigned joypad_map[MAX_USERS];
|
||||
unsigned device[MAX_USERS];
|
||||
char device_names[MAX_USERS][64];
|
||||
unsigned device_name_index[MAX_USERS];
|
||||
bool autodetect_enable;
|
||||
bool netplay_client_swap_input;
|
||||
@@ -270,10 +250,11 @@ typedef struct settings
|
||||
bool overlay_enable;
|
||||
bool overlay_enable_autopreferred;
|
||||
bool overlay_hide_in_menu;
|
||||
char overlay[PATH_MAX_LENGTH];
|
||||
float overlay_opacity;
|
||||
float overlay_scale;
|
||||
|
||||
unsigned bind_timeout;
|
||||
char autoconfig_dir[PATH_MAX_LENGTH];
|
||||
bool input_descriptor_label_show;
|
||||
bool input_descriptor_hide_unbound;
|
||||
|
||||
@@ -291,6 +272,7 @@ typedef struct settings
|
||||
struct
|
||||
{
|
||||
bool enable;
|
||||
char overlay[PATH_MAX_LENGTH];
|
||||
float opacity;
|
||||
float scale;
|
||||
} osk;
|
||||
@@ -331,58 +313,35 @@ typedef struct settings
|
||||
bool bundle_assets_extract_enable;
|
||||
unsigned bundle_assets_extract_version_current;
|
||||
unsigned bundle_assets_extract_last_version;
|
||||
char bundle_assets_src_path[PATH_MAX_LENGTH];
|
||||
char bundle_assets_dst_path[PATH_MAX_LENGTH];
|
||||
char bundle_assets_dst_path_subdir[PATH_MAX_LENGTH];
|
||||
|
||||
struct
|
||||
{
|
||||
char cheat_database[PATH_MAX_LENGTH];
|
||||
char content_database[PATH_MAX_LENGTH];
|
||||
char libretro[PATH_MAX_LENGTH];
|
||||
char osk_overlay[PATH_MAX_LENGTH];
|
||||
char overlay[PATH_MAX_LENGTH];
|
||||
char menu_wallpaper[PATH_MAX_LENGTH];
|
||||
char audio_dsp_plugin[PATH_MAX_LENGTH];
|
||||
char softfilter_plugin[PATH_MAX_LENGTH];
|
||||
char core_options[PATH_MAX_LENGTH];
|
||||
char content_history[PATH_MAX_LENGTH];
|
||||
char libretro_info[PATH_MAX_LENGTH];
|
||||
char cheat_settings[PATH_MAX_LENGTH];
|
||||
char bundle_assets_src[PATH_MAX_LENGTH];
|
||||
char bundle_assets_dst[PATH_MAX_LENGTH];
|
||||
char bundle_assets_dst_subdir[PATH_MAX_LENGTH];
|
||||
char shader[PATH_MAX_LENGTH];
|
||||
char font[PATH_MAX_LENGTH];
|
||||
} path;
|
||||
|
||||
struct
|
||||
{
|
||||
char audio_filter[PATH_MAX_LENGTH];
|
||||
char autoconfig[PATH_MAX_LENGTH];
|
||||
char video_filter[PATH_MAX_LENGTH];
|
||||
char video_shader[PATH_MAX_LENGTH];
|
||||
char content_history[PATH_MAX_LENGTH];
|
||||
char libretro[PATH_MAX_LENGTH];
|
||||
char cursor[PATH_MAX_LENGTH];
|
||||
char input_remapping[PATH_MAX_LENGTH];
|
||||
char overlay[PATH_MAX_LENGTH];
|
||||
char resampler[PATH_MAX_LENGTH];
|
||||
char screenshot[PATH_MAX_LENGTH];
|
||||
char system[PATH_MAX_LENGTH];
|
||||
char cache[PATH_MAX_LENGTH];
|
||||
char playlist[PATH_MAX_LENGTH];
|
||||
char core_assets[PATH_MAX_LENGTH];
|
||||
char assets[PATH_MAX_LENGTH];
|
||||
char dynamic_wallpapers[PATH_MAX_LENGTH];
|
||||
char thumbnails[PATH_MAX_LENGTH];
|
||||
char menu_config[PATH_MAX_LENGTH];
|
||||
char menu_content[PATH_MAX_LENGTH];
|
||||
} directory;
|
||||
|
||||
char core_options_path[PATH_MAX_LENGTH];
|
||||
char content_history_path[PATH_MAX_LENGTH];
|
||||
char content_history_directory[PATH_MAX_LENGTH];
|
||||
unsigned content_history_size;
|
||||
|
||||
char libretro[PATH_MAX_LENGTH];
|
||||
char libretro_directory[PATH_MAX_LENGTH];
|
||||
unsigned libretro_log_level;
|
||||
char libretro_info_path[PATH_MAX_LENGTH];
|
||||
char content_database[PATH_MAX_LENGTH];
|
||||
char cheat_database[PATH_MAX_LENGTH];
|
||||
char cursor_directory[PATH_MAX_LENGTH];
|
||||
char cheat_settings_path[PATH_MAX_LENGTH];
|
||||
char input_remapping_directory[PATH_MAX_LENGTH];
|
||||
|
||||
char overlay_directory[PATH_MAX_LENGTH];
|
||||
char resampler_directory[PATH_MAX_LENGTH];
|
||||
char screenshot_directory[PATH_MAX_LENGTH];
|
||||
char system_directory[PATH_MAX_LENGTH];
|
||||
|
||||
bool auto_screenshot_filename;
|
||||
|
||||
char cache_directory[PATH_MAX_LENGTH];
|
||||
char playlist_directory[PATH_MAX_LENGTH];
|
||||
|
||||
bool history_list_enable;
|
||||
bool rewind_enable;
|
||||
size_t rewind_buffer_size;
|
||||
@@ -407,7 +366,13 @@ typedef struct settings
|
||||
unsigned network_remote_base_port;
|
||||
bool debug_panel_enable;
|
||||
|
||||
char core_assets_directory[PATH_MAX_LENGTH];
|
||||
char assets_directory[PATH_MAX_LENGTH];
|
||||
char dynamic_wallpapers_directory[PATH_MAX_LENGTH];
|
||||
char boxarts_directory[PATH_MAX_LENGTH];
|
||||
char menu_config_directory[PATH_MAX_LENGTH];
|
||||
#if defined(HAVE_MENU)
|
||||
char menu_content_directory[PATH_MAX_LENGTH];
|
||||
bool menu_show_start_screen;
|
||||
#endif
|
||||
bool fps_show;
|
||||
@@ -430,18 +395,9 @@ typedef struct settings
|
||||
unsigned menu_scroll_up_btn;
|
||||
|
||||
char username[32];
|
||||
#ifdef HAVE_LANGEXTRA
|
||||
unsigned int user_language;
|
||||
#endif
|
||||
|
||||
bool config_save_on_exit;
|
||||
|
||||
#ifdef HAVE_SYSTEMD
|
||||
bool ssh_enable;
|
||||
bool samba_enable;
|
||||
bool bluetooth_enable;
|
||||
#endif
|
||||
|
||||
} settings_t;
|
||||
|
||||
/**
|
||||
@@ -587,17 +543,14 @@ bool config_save_autoconf_profile(const char *path, unsigned user);
|
||||
**/
|
||||
bool config_save_file(const char *path);
|
||||
|
||||
/* Replaces currently loaded configuration file with
|
||||
* another one. Will load a dummy core to flush state
|
||||
* properly. */
|
||||
bool config_replace(char *path);
|
||||
|
||||
bool config_init(void);
|
||||
bool config_realloc(void);
|
||||
|
||||
void config_free(void);
|
||||
|
||||
settings_t *config_get_ptr(void);
|
||||
|
||||
RETRO_END_DECLS
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -23,13 +23,71 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
|
||||
#include "frontend/frontend_driver.h"
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct ram_type ram_type_t;
|
||||
enum content_ctl_state
|
||||
{
|
||||
CONTENT_CTL_NONE = 0,
|
||||
|
||||
CONTENT_CTL_IS_INITED,
|
||||
|
||||
CONTENT_CTL_DOES_NOT_NEED_CONTENT,
|
||||
|
||||
CONTENT_CTL_SET_DOES_NOT_NEED_CONTENT,
|
||||
|
||||
CONTENT_CTL_UNSET_DOES_NOT_NEED_CONTENT,
|
||||
|
||||
/* Initializes and loads a content file for the currently
|
||||
* selected libretro core. */
|
||||
CONTENT_CTL_INIT,
|
||||
|
||||
CONTENT_CTL_DEINIT,
|
||||
|
||||
/* Loads content file and starts up RetroArch.
|
||||
* If no content file can be loaded, will start up RetroArch
|
||||
* as-is. */
|
||||
CONTENT_CTL_LOAD,
|
||||
|
||||
CONTENT_CTL_GET_CRC,
|
||||
|
||||
/* Load a RAM state from disk to memory. */
|
||||
CONTENT_CTL_LOAD_RAM_FILE,
|
||||
|
||||
/* Save a RAM state from memory to disk. */
|
||||
CONTENT_CTL_SAVE_RAM_FILE,
|
||||
|
||||
/* Load a state from disk to memory. */
|
||||
CONTENT_CTL_LOAD_STATE,
|
||||
|
||||
/* Save a state from memory to disk. */
|
||||
CONTENT_CTL_SAVE_STATE,
|
||||
|
||||
/* Frees temporary content handle. */
|
||||
CONTENT_CTL_TEMPORARY_FREE,
|
||||
|
||||
CONTENT_CTL_STREAM_INIT,
|
||||
|
||||
CONTENT_CTL_STREAM_CRC_CALCULATE
|
||||
};
|
||||
|
||||
typedef struct ram_type
|
||||
{
|
||||
const char *path;
|
||||
int type;
|
||||
} ram_type_t;
|
||||
|
||||
typedef struct content_stream
|
||||
{
|
||||
uint32_t a;
|
||||
const uint8_t *b;
|
||||
size_t c;
|
||||
uint32_t crc;
|
||||
} content_stream_t;
|
||||
|
||||
typedef struct content_ctx_info
|
||||
{
|
||||
@@ -39,50 +97,13 @@ typedef struct content_ctx_info
|
||||
environment_get_t environ_get; /* Function passed for environment_get function */
|
||||
} content_ctx_info_t;
|
||||
|
||||
/* Load a RAM state from disk to memory. */
|
||||
bool content_load_ram_file(unsigned slot);
|
||||
void content_push_to_history_playlist(bool do_push,
|
||||
const char *path, void *data);
|
||||
|
||||
/* Save a RAM state from memory to disk. */
|
||||
bool content_save_ram_file(unsigned slot);
|
||||
bool content_ctl(enum content_ctl_state state, void *data);
|
||||
|
||||
/* Load a state from disk to memory. */
|
||||
bool content_load_state(const char* path, bool load_to_backup_buffer);
|
||||
|
||||
/* Save a state from memory to disk. */
|
||||
bool content_save_state(const char *path, bool save_to_disk);
|
||||
|
||||
/* Copy a save state. */
|
||||
bool content_rename_state(const char *origin, const char *dest);
|
||||
|
||||
/* Undoes the last load state operation that was done */
|
||||
bool content_undo_load_state(void);
|
||||
|
||||
/* Restores the last savestate file which was overwritten */
|
||||
bool content_undo_save_state(void);
|
||||
|
||||
bool content_does_not_need_content(void);
|
||||
|
||||
void content_set_does_not_need_content(void);
|
||||
|
||||
void content_unset_does_not_need_content(void);
|
||||
|
||||
bool content_get_crc(uint32_t **content_crc_ptr);
|
||||
|
||||
bool content_is_inited(void);
|
||||
|
||||
void content_deinit(void);
|
||||
|
||||
/* Initializes and loads a content file for the currently
|
||||
* selected libretro core. */
|
||||
bool content_init(void);
|
||||
|
||||
/* Resets the state and savefile backup buffers */
|
||||
bool content_reset_savestate_backups(void);
|
||||
|
||||
/* Checks if the buffers are empty */
|
||||
bool content_undo_load_buf_is_empty(void);
|
||||
bool content_undo_save_buf_is_empty(void);
|
||||
|
||||
RETRO_END_DECLS
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
-409
@@ -1,409 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2016 - Daniel De Matteis
|
||||
* Copyright (C) 2012-2015 - Michael Lelli
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <retro_inline.h>
|
||||
#include <boolean.h>
|
||||
#include <lists/string_list.h>
|
||||
#include <libretro.h>
|
||||
|
||||
#include "dynamic.h"
|
||||
#include "core.h"
|
||||
#include "general.h"
|
||||
#include "msg_hash.h"
|
||||
#include "managers/state_manager.h"
|
||||
#include "system.h"
|
||||
#include "gfx/video_driver.h"
|
||||
#include "audio/audio_driver.h"
|
||||
|
||||
#ifdef HAVE_NETPLAY
|
||||
#include "network/netplay/netplay.h"
|
||||
#endif
|
||||
|
||||
static struct retro_core_t core;
|
||||
static unsigned core_poll_type;
|
||||
static bool core_input_polled;
|
||||
static bool core_has_set_input_descriptors = false;
|
||||
static struct retro_callbacks retro_ctx;
|
||||
|
||||
static void core_input_state_poll_maybe(void)
|
||||
{
|
||||
if (core_poll_type == POLL_TYPE_NORMAL)
|
||||
input_poll();
|
||||
}
|
||||
|
||||
static int16_t core_input_state_poll(unsigned port,
|
||||
unsigned device, unsigned idx, unsigned id)
|
||||
{
|
||||
if (core_poll_type == POLL_TYPE_LATE)
|
||||
{
|
||||
if (!core_input_polled)
|
||||
input_poll();
|
||||
|
||||
core_input_polled = true;
|
||||
}
|
||||
return input_state(port, device, idx, id);
|
||||
}
|
||||
|
||||
void core_set_input_state(retro_ctx_input_state_info_t *info)
|
||||
{
|
||||
core.retro_set_input_state(info->cb);
|
||||
}
|
||||
|
||||
/**
|
||||
* core_init_libretro_cbs:
|
||||
* @data : pointer to retro_callbacks object
|
||||
*
|
||||
* Initializes libretro callbacks, and binds the libretro callbacks
|
||||
* to default callback functions.
|
||||
**/
|
||||
static bool core_init_libretro_cbs(void *data)
|
||||
{
|
||||
struct retro_callbacks *cbs = (struct retro_callbacks*)data;
|
||||
#ifdef HAVE_NETPLAY
|
||||
global_t *global = global_get_ptr();
|
||||
#endif
|
||||
|
||||
if (!cbs)
|
||||
return false;
|
||||
|
||||
core.retro_set_video_refresh(video_driver_frame);
|
||||
core.retro_set_audio_sample(audio_driver_sample);
|
||||
core.retro_set_audio_sample_batch(audio_driver_sample_batch);
|
||||
core.retro_set_input_state(core_input_state_poll);
|
||||
core.retro_set_input_poll(core_input_state_poll_maybe);
|
||||
|
||||
core_set_default_callbacks(cbs);
|
||||
|
||||
#ifdef HAVE_NETPLAY
|
||||
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
|
||||
return true;
|
||||
|
||||
/* Force normal poll type for netplay. */
|
||||
core_poll_type = POLL_TYPE_NORMAL;
|
||||
|
||||
if (global->netplay.is_spectate)
|
||||
{
|
||||
core.retro_set_input_state(
|
||||
(global->netplay.is_client ?
|
||||
input_state_spectate_client : input_state_spectate)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
core.retro_set_video_refresh(video_frame_net);
|
||||
core.retro_set_audio_sample(audio_sample_net);
|
||||
core.retro_set_audio_sample_batch(audio_sample_batch_net);
|
||||
core.retro_set_input_state(input_state_net);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* core_set_default_callbacks:
|
||||
* @data : pointer to retro_callbacks object
|
||||
*
|
||||
* Binds the libretro callbacks to default callback functions.
|
||||
**/
|
||||
bool core_set_default_callbacks(void *data)
|
||||
{
|
||||
struct retro_callbacks *cbs = (struct retro_callbacks*)data;
|
||||
|
||||
if (!cbs)
|
||||
return false;
|
||||
|
||||
cbs->frame_cb = video_driver_frame;
|
||||
cbs->sample_cb = audio_driver_sample;
|
||||
cbs->sample_batch_cb = audio_driver_sample_batch;
|
||||
cbs->state_cb = core_input_state_poll;
|
||||
cbs->poll_cb = input_poll;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool core_deinit(void *data)
|
||||
{
|
||||
struct retro_callbacks *cbs = (struct retro_callbacks*)data;
|
||||
|
||||
if (!cbs)
|
||||
return false;
|
||||
|
||||
cbs->frame_cb = NULL;
|
||||
cbs->sample_cb = NULL;
|
||||
cbs->sample_batch_cb = NULL;
|
||||
cbs->state_cb = NULL;
|
||||
cbs->poll_cb = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_uninit_libretro_callbacks(void)
|
||||
{
|
||||
return core_deinit(&retro_ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* core_set_rewind_callbacks:
|
||||
*
|
||||
* Sets the audio sampling callbacks based on whether or not
|
||||
* rewinding is currently activated.
|
||||
**/
|
||||
bool core_set_rewind_callbacks(void)
|
||||
{
|
||||
if (state_manager_frame_is_reversed())
|
||||
{
|
||||
core.retro_set_audio_sample(audio_driver_sample_rewind);
|
||||
core.retro_set_audio_sample_batch(audio_driver_sample_batch_rewind);
|
||||
}
|
||||
else
|
||||
{
|
||||
core.retro_set_audio_sample(audio_driver_sample);
|
||||
core.retro_set_audio_sample_batch(audio_driver_sample_batch);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_set_cheat(retro_ctx_cheat_info_t *info)
|
||||
{
|
||||
core.retro_cheat_set(info->index, info->enabled, info->code);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_reset_cheat(void)
|
||||
{
|
||||
core.retro_cheat_reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_api_version(retro_ctx_api_info_t *api)
|
||||
{
|
||||
if (!api)
|
||||
return false;
|
||||
api->version = core.retro_api_version();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_set_poll_type(unsigned *type)
|
||||
{
|
||||
core_poll_type = *type;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_init_symbols(enum rarch_core_type *type)
|
||||
{
|
||||
if (!type)
|
||||
return false;
|
||||
init_libretro_sym(*type, &core);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_set_controller_port_device(retro_ctx_controller_info_t *pad)
|
||||
{
|
||||
if (!pad)
|
||||
return false;
|
||||
core.retro_set_controller_port_device(pad->port, pad->device);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_get_memory(retro_ctx_memory_info_t *info)
|
||||
{
|
||||
if (!info)
|
||||
return false;
|
||||
info->size = core.retro_get_memory_size(info->id);
|
||||
info->data = core.retro_get_memory_data(info->id);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_load_game(retro_ctx_load_content_info_t *load_info)
|
||||
{
|
||||
if (!load_info)
|
||||
return false;
|
||||
|
||||
if (load_info->special)
|
||||
return core.retro_load_game_special(load_info->special->id, load_info->info, load_info->content->size);
|
||||
return core.retro_load_game(*load_info->content->elems[0].data ? load_info->info : NULL);
|
||||
}
|
||||
|
||||
bool core_get_system_info(struct retro_system_info *system)
|
||||
{
|
||||
if (!system)
|
||||
return false;
|
||||
core.retro_get_system_info(system);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_unserialize(retro_ctx_serialize_info_t *info)
|
||||
{
|
||||
if (!info)
|
||||
return false;
|
||||
if (!core.retro_unserialize(info->data_const, info->size))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_serialize(retro_ctx_serialize_info_t *info)
|
||||
{
|
||||
if (!info)
|
||||
return false;
|
||||
if (!core.retro_serialize(info->data, info->size))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_serialize_size(retro_ctx_size_info_t *info)
|
||||
{
|
||||
if (!info)
|
||||
return false;
|
||||
info->size = core.retro_serialize_size();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_frame(retro_ctx_frame_info_t *info)
|
||||
{
|
||||
if (!info || !retro_ctx.frame_cb)
|
||||
return false;
|
||||
|
||||
retro_ctx.frame_cb(
|
||||
info->data, info->width, info->height, info->pitch);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_poll(void)
|
||||
{
|
||||
if (!retro_ctx.poll_cb)
|
||||
return false;
|
||||
retro_ctx.poll_cb();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_set_environment(retro_ctx_environ_info_t *info)
|
||||
{
|
||||
if (!info)
|
||||
return false;
|
||||
core.retro_set_environment(info->env);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_get_system_av_info(struct retro_system_av_info *av_info)
|
||||
{
|
||||
if (!av_info)
|
||||
return false;
|
||||
core.retro_get_system_av_info(av_info);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_reset(void)
|
||||
{
|
||||
core.retro_reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_init(void)
|
||||
{
|
||||
core.retro_init();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_unload(void)
|
||||
{
|
||||
core.retro_deinit();
|
||||
uninit_libretro_sym(&core);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_unload_game(void)
|
||||
{
|
||||
video_driver_deinit_hw_context();
|
||||
audio_driver_stop();
|
||||
core.retro_unload_game();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_run(void)
|
||||
{
|
||||
switch (core_poll_type)
|
||||
{
|
||||
case POLL_TYPE_EARLY:
|
||||
input_poll();
|
||||
break;
|
||||
case POLL_TYPE_LATE:
|
||||
core_input_polled = false;
|
||||
break;
|
||||
}
|
||||
if (core.retro_run)
|
||||
core.retro_run();
|
||||
if (core_poll_type == POLL_TYPE_LATE && !core_input_polled)
|
||||
input_poll();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_load(void)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
core_poll_type = settings->input.poll_type_behavior;
|
||||
|
||||
if (!core_verify_api_version())
|
||||
return false;
|
||||
if (!core_init_libretro_cbs(&retro_ctx))
|
||||
return false;
|
||||
|
||||
core_get_system_av_info(video_viewport_get_system_av_info());
|
||||
runloop_ctl(RUNLOOP_CTL_SET_FRAME_LIMIT, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_verify_api_version(void)
|
||||
{
|
||||
unsigned api_version = core.retro_api_version();
|
||||
RARCH_LOG("%s: %u\n",
|
||||
msg_hash_to_str(MSG_VERSION_OF_LIBRETRO_API),
|
||||
api_version);
|
||||
RARCH_LOG("%s: %u\n",
|
||||
msg_hash_to_str(MSG_COMPILED_AGAINST_API),
|
||||
RETRO_API_VERSION);
|
||||
|
||||
if (api_version != RETRO_API_VERSION)
|
||||
{
|
||||
RARCH_WARN("%s\n", msg_hash_to_str(MSG_LIBRETRO_ABI_BREAK));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_has_set_input_descriptor(void)
|
||||
{
|
||||
return core_has_set_input_descriptors;
|
||||
}
|
||||
|
||||
void core_set_input_descriptors(void)
|
||||
{
|
||||
core_has_set_input_descriptors = true;
|
||||
}
|
||||
|
||||
void core_unset_input_descriptors(void)
|
||||
{
|
||||
core_has_set_input_descriptors = false;
|
||||
}
|
||||
+295
-295
@@ -16,26 +16,23 @@
|
||||
*/
|
||||
|
||||
#include <file/file_path.h>
|
||||
#include <lists/dir_list.h>
|
||||
#include <file/archive_file.h>
|
||||
#include <file/dir_list.h>
|
||||
#include <file/file_archive.h>
|
||||
#include <compat/strl.h>
|
||||
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include "core_info.h"
|
||||
#include "configuration.h"
|
||||
#include "file_path_special.h"
|
||||
#include "list_special.h"
|
||||
#include "dir_list_special.h"
|
||||
#include "config.def.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
static const char *core_info_tmp_path = NULL;
|
||||
static const char *core_info_tmp_path = NULL;
|
||||
static const struct string_list *core_info_tmp_list = NULL;
|
||||
static core_info_t *core_info_current = NULL;
|
||||
static core_info_list_t *core_info_curr_list = NULL;
|
||||
|
||||
static void core_info_list_resolve_all_extensions(
|
||||
core_info_list_t *core_info_list)
|
||||
@@ -84,7 +81,7 @@ static void core_info_list_resolve_all_firmware(
|
||||
core_info_t *info = (core_info_t*)&core_info_list->list[i];
|
||||
config_file_t *config = (config_file_t*)info->config_data;
|
||||
|
||||
if (!config)
|
||||
if (!info || !config)
|
||||
continue;
|
||||
|
||||
if (!config_get_uint(config, "firmware_count", &count))
|
||||
@@ -104,7 +101,7 @@ static void core_info_list_resolve_all_firmware(
|
||||
|
||||
snprintf(path_key, sizeof(path_key), "firmware%u_path", c);
|
||||
snprintf(desc_key, sizeof(desc_key), "firmware%u_desc", c);
|
||||
snprintf(opt_key, sizeof(opt_key), "firmware%u_opt", c);
|
||||
snprintf(opt_key, sizeof(opt_key), "firmware%u_opt", c);
|
||||
|
||||
config_get_string(config, path_key, &info->firmware[c].path);
|
||||
config_get_string(config, desc_key, &info->firmware[c].desc);
|
||||
@@ -124,6 +121,9 @@ static void core_info_list_free(core_info_list_t *core_info_list)
|
||||
{
|
||||
core_info_t *info = (core_info_t*)&core_info_list->list[i];
|
||||
|
||||
if (!info)
|
||||
continue;
|
||||
|
||||
free(info->path);
|
||||
free(info->core_name);
|
||||
free(info->systemname);
|
||||
@@ -162,15 +162,16 @@ static void core_info_list_free(core_info_list_t *core_info_list)
|
||||
static config_file_t *core_info_list_iterate(
|
||||
struct string_list *contents, size_t i)
|
||||
{
|
||||
char info_path_base[PATH_MAX_LENGTH] = {0};
|
||||
char info_path[PATH_MAX_LENGTH] = {0};
|
||||
settings_t *settings = config_get_ptr();
|
||||
char info_path_base[PATH_MAX_LENGTH];
|
||||
char info_path[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!contents->elems[i].data)
|
||||
return NULL;
|
||||
|
||||
fill_pathname_base_noext(info_path_base, contents->elems[i].data,
|
||||
fill_pathname_base(info_path_base, contents->elems[i].data,
|
||||
sizeof(info_path_base));
|
||||
path_remove_extension(info_path_base);
|
||||
|
||||
#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP))
|
||||
char *substr = strrchr(info_path_base, '_');
|
||||
@@ -178,18 +179,66 @@ static config_file_t *core_info_list_iterate(
|
||||
*substr = '\0';
|
||||
#endif
|
||||
|
||||
strlcat(info_path_base,
|
||||
file_path_str(FILE_PATH_CORE_INFO_EXTENSION),
|
||||
sizeof(info_path_base));
|
||||
strlcat(info_path_base, ".info", sizeof(info_path_base));
|
||||
|
||||
fill_pathname_join(info_path,
|
||||
(!string_is_empty(settings->path.libretro_info)) ?
|
||||
settings->path.libretro_info : settings->directory.libretro,
|
||||
fill_pathname_join(info_path, (*settings->libretro_info_path) ?
|
||||
settings->libretro_info_path : settings->libretro_directory,
|
||||
info_path_base, sizeof(info_path));
|
||||
|
||||
return config_file_new(info_path);
|
||||
}
|
||||
|
||||
void core_info_get_name(const char *path, char *s, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
core_info_t *core_info = NULL;
|
||||
core_info_list_t *core_info_list = NULL;
|
||||
struct string_list *contents = dir_list_new_special(
|
||||
NULL, DIR_LIST_CORES, NULL);
|
||||
|
||||
if (!contents)
|
||||
return;
|
||||
|
||||
core_info_list = (core_info_list_t*)calloc(1, sizeof(*core_info_list));
|
||||
if (!core_info_list)
|
||||
goto error;
|
||||
|
||||
core_info = (core_info_t*)calloc(contents->size, sizeof(*core_info));
|
||||
if (!core_info)
|
||||
goto error;
|
||||
|
||||
core_info_list->list = core_info;
|
||||
core_info_list->count = contents->size;
|
||||
|
||||
for (i = 0; i < contents->size; i++)
|
||||
{
|
||||
config_file_t *conf = NULL;
|
||||
|
||||
if (!string_is_equal(contents->elems[i].data, path))
|
||||
continue;
|
||||
|
||||
conf = core_info_list_iterate(contents, i);
|
||||
|
||||
if (conf)
|
||||
{
|
||||
config_get_string(conf, "corename",
|
||||
&core_info[i].core_name);
|
||||
core_info[i].config_data = (void*)conf;
|
||||
}
|
||||
|
||||
core_info[i].path = strdup(contents->elems[i].data);
|
||||
|
||||
strlcpy(s, core_info[i].core_name, len);
|
||||
}
|
||||
|
||||
error:
|
||||
if (contents)
|
||||
dir_list_free(contents);
|
||||
contents = NULL;
|
||||
core_info_list_free(core_info_list);
|
||||
}
|
||||
|
||||
|
||||
static core_info_list_t *core_info_list_new(void)
|
||||
{
|
||||
size_t i;
|
||||
@@ -218,7 +267,6 @@ static core_info_list_t *core_info_list_new(void)
|
||||
|
||||
if (conf)
|
||||
{
|
||||
bool tmp_bool = false;
|
||||
unsigned count = 0;
|
||||
|
||||
config_get_string(conf, "display_name",
|
||||
@@ -272,9 +320,8 @@ static core_info_list_t *core_info_list_new(void)
|
||||
core_info[i].notes)
|
||||
core_info[i].note_list = string_split(core_info[i].notes, "|");
|
||||
|
||||
if (config_get_bool(conf, "supports_no_game",
|
||||
&tmp_bool))
|
||||
core_info[i].supports_no_game = tmp_bool;
|
||||
config_get_bool(conf, "supports_no_game",
|
||||
&core_info[i].supports_no_game);
|
||||
|
||||
core_info[i].config_data = conf;
|
||||
}
|
||||
@@ -299,6 +346,86 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
size_t core_info_list_num_info_files(core_info_list_t *core_info_list)
|
||||
{
|
||||
size_t i, num = 0;
|
||||
|
||||
if (!core_info_list)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < core_info_list->count; i++)
|
||||
{
|
||||
config_file_t *conf = (config_file_t*)
|
||||
core_info_list->list[i].config_data;
|
||||
num += !!conf;
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
bool core_info_list_get_display_name(core_info_list_t *core_info_list,
|
||||
const char *path, char *s, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!core_info_list)
|
||||
return false;
|
||||
|
||||
for (i = 0; i < core_info_list->count; i++)
|
||||
{
|
||||
const core_info_t *info = &core_info_list->list[i];
|
||||
if (string_is_equal(path_basename(info->path), path_basename(path))
|
||||
&& info->display_name)
|
||||
{
|
||||
strlcpy(s, info->display_name, len);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool core_info_get_display_name(const char *path, char *s, size_t len)
|
||||
{
|
||||
char *core_name = NULL;
|
||||
char *display_name = NULL;
|
||||
config_file_t *conf = NULL;
|
||||
|
||||
if (!path_file_exists(path))
|
||||
return false;
|
||||
|
||||
conf = config_file_new(path);
|
||||
|
||||
if (!conf)
|
||||
goto error;
|
||||
|
||||
config_get_string(conf, "corename",
|
||||
&core_name);
|
||||
|
||||
config_get_string(conf, "display_name",
|
||||
&display_name);
|
||||
|
||||
config_file_free(conf);
|
||||
|
||||
if (!core_name)
|
||||
goto error;
|
||||
if (!conf)
|
||||
goto error;
|
||||
|
||||
snprintf(s, len,"%s",display_name);
|
||||
|
||||
free(core_name);
|
||||
free(display_name);
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
if (core_name)
|
||||
free(core_name);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Shallow-copies internal state.
|
||||
*
|
||||
* Data in *info is invalidated when the
|
||||
@@ -368,8 +495,71 @@ static int core_info_qsort_cmp(const void *a_, const void *b_)
|
||||
return strcasecmp(a->display_name, b->display_name);
|
||||
}
|
||||
|
||||
static core_info_t *core_info_find_internal(
|
||||
core_info_list_t *list,
|
||||
void core_info_list_get_supported_cores(core_info_list_t *core_info_list,
|
||||
const char *path, const core_info_t **infos, size_t *num_infos)
|
||||
{
|
||||
#ifdef HAVE_ZLIB
|
||||
struct string_list *list = NULL;
|
||||
#endif
|
||||
size_t supported = 0, i;
|
||||
|
||||
if (!core_info_list)
|
||||
return;
|
||||
|
||||
core_info_tmp_path = path;
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
if (string_is_equal_noncase(path_get_extension(path), "zip"))
|
||||
list = file_archive_get_file_list(path, NULL);
|
||||
core_info_tmp_list = list;
|
||||
#endif
|
||||
|
||||
/* Let supported core come first in list so we can return
|
||||
* a pointer to them. */
|
||||
qsort(core_info_list->list, core_info_list->count,
|
||||
sizeof(core_info_t), core_info_qsort_cmp);
|
||||
|
||||
for (i = 0; i < core_info_list->count; i++, supported++)
|
||||
{
|
||||
const core_info_t *core = &core_info_list->list[i];
|
||||
|
||||
if (!core)
|
||||
continue;
|
||||
|
||||
if (core_info_does_support_file(core, path))
|
||||
continue;
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
if (core_info_does_support_any_file(core, list))
|
||||
continue;
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
if (list)
|
||||
string_list_free(list);
|
||||
#endif
|
||||
|
||||
*infos = core_info_list->list;
|
||||
*num_infos = supported;
|
||||
}
|
||||
|
||||
core_info_t *core_info_get(core_info_list_t *list, size_t i)
|
||||
{
|
||||
core_info_t *info = NULL;
|
||||
|
||||
if (!list)
|
||||
return NULL;
|
||||
info = (core_info_t*)&list->list[i];
|
||||
if (!info || !info->path)
|
||||
return NULL;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static core_info_t *core_info_find(core_info_list_t *list,
|
||||
const char *core)
|
||||
{
|
||||
size_t i;
|
||||
@@ -387,10 +577,10 @@ static core_info_t *core_info_find_internal(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool core_info_list_update_missing_firmware_internal(
|
||||
|
||||
static bool core_info_list_update_missing_firmware(
|
||||
core_info_list_t *core_info_list,
|
||||
const char *core,
|
||||
const char *systemdir)
|
||||
const char *core, const char *systemdir)
|
||||
{
|
||||
size_t i;
|
||||
char path[PATH_MAX_LENGTH] = {0};
|
||||
@@ -399,7 +589,7 @@ static bool core_info_list_update_missing_firmware_internal(
|
||||
if (!core_info_list || !core)
|
||||
return false;
|
||||
|
||||
info = core_info_find_internal(core_info_list, core);
|
||||
info = core_info_find(core_info_list, core);
|
||||
|
||||
if (!info)
|
||||
return false;
|
||||
@@ -446,7 +636,7 @@ static void core_info_list_get_missing_firmware(
|
||||
*firmware = NULL;
|
||||
*num_firmware = 0;
|
||||
|
||||
if (!(info = core_info_find_internal(core_info_list, core)))
|
||||
if (!(info = core_info_find(core_info_list, core)))
|
||||
return;
|
||||
|
||||
*firmware = info->firmware;
|
||||
@@ -464,278 +654,88 @@ static void core_info_list_get_missing_firmware(
|
||||
}
|
||||
#endif
|
||||
|
||||
void core_info_free_current_core(void)
|
||||
bool core_info_ctl(enum core_info_state state, void *data)
|
||||
{
|
||||
if (core_info_current)
|
||||
free(core_info_current);
|
||||
core_info_current = NULL;
|
||||
}
|
||||
static core_info_t *core_info_current = NULL;
|
||||
static core_info_list_t *core_info_curr_list = NULL;
|
||||
|
||||
bool core_info_init_current_core(void)
|
||||
{
|
||||
core_info_current = (core_info_t*)calloc(1, sizeof(core_info_t));
|
||||
if (!core_info_current)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_info_get_current_core(core_info_t **core)
|
||||
{
|
||||
if (!core)
|
||||
return false;
|
||||
*core = core_info_current;
|
||||
return true;
|
||||
}
|
||||
|
||||
void core_info_deinit_list(void)
|
||||
{
|
||||
if (core_info_curr_list)
|
||||
core_info_list_free(core_info_curr_list);
|
||||
core_info_curr_list = NULL;
|
||||
}
|
||||
|
||||
bool core_info_init_list(void)
|
||||
{
|
||||
core_info_curr_list = core_info_list_new();
|
||||
|
||||
if (!core_info_curr_list)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_info_get_list(core_info_list_t **core)
|
||||
{
|
||||
if (!core)
|
||||
return false;
|
||||
*core = core_info_curr_list;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_info_list_update_missing_firmware(core_info_ctx_firmware_t *info)
|
||||
{
|
||||
if (!info)
|
||||
return false;
|
||||
|
||||
return core_info_list_update_missing_firmware_internal(
|
||||
core_info_curr_list,
|
||||
info->path, info->directory.system);
|
||||
}
|
||||
|
||||
bool core_info_load(core_info_ctx_find_t *info)
|
||||
{
|
||||
core_info_t *core_info = NULL;
|
||||
|
||||
if (!info)
|
||||
return false;
|
||||
|
||||
core_info_get_current_core(&core_info);
|
||||
|
||||
if (!core_info_curr_list)
|
||||
return false;
|
||||
|
||||
if (!core_info_list_get_info(core_info_curr_list,
|
||||
core_info, info->path))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core_info_find(core_info_ctx_find_t *info, const char *core_path)
|
||||
{
|
||||
if (!info || !core_info_curr_list)
|
||||
return false;
|
||||
info->inf = core_info_find_internal(core_info_curr_list, core_path);
|
||||
if (!info->inf)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
core_info_t *core_info_get(core_info_list_t *list, size_t i)
|
||||
{
|
||||
core_info_t *info = NULL;
|
||||
|
||||
if (!list)
|
||||
return NULL;
|
||||
info = (core_info_t*)&list->list[i];
|
||||
if (!info || !info->path)
|
||||
return NULL;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
void core_info_list_get_supported_cores(core_info_list_t *core_info_list,
|
||||
const char *path, const core_info_t **infos, size_t *num_infos)
|
||||
{
|
||||
#ifdef HAVE_ZLIB
|
||||
struct string_list *list = NULL;
|
||||
#endif
|
||||
size_t supported = 0, i;
|
||||
|
||||
if (!core_info_list)
|
||||
return;
|
||||
|
||||
core_info_tmp_path = path;
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
if (string_is_equal_noncase(path_get_extension(path), "zip"))
|
||||
list = file_archive_get_file_list(path, NULL);
|
||||
core_info_tmp_list = list;
|
||||
#endif
|
||||
|
||||
/* Let supported core come first in list so we can return
|
||||
* a pointer to them. */
|
||||
qsort(core_info_list->list, core_info_list->count,
|
||||
sizeof(core_info_t), core_info_qsort_cmp);
|
||||
|
||||
for (i = 0; i < core_info_list->count; i++, supported++)
|
||||
switch (state)
|
||||
{
|
||||
const core_info_t *core = &core_info_list->list[i];
|
||||
case CORE_INFO_CTL_CURRENT_CORE_FREE:
|
||||
if (core_info_current)
|
||||
free(core_info_current);
|
||||
core_info_current = NULL;
|
||||
break;
|
||||
case CORE_INFO_CTL_CURRENT_CORE_INIT:
|
||||
core_info_current = (core_info_t*)calloc(1, sizeof(core_info_t));
|
||||
if (!core_info_current)
|
||||
return false;
|
||||
break;
|
||||
case CORE_INFO_CTL_CURRENT_CORE_GET:
|
||||
{
|
||||
core_info_t **core = (core_info_t**)data;
|
||||
if (!core)
|
||||
return false;
|
||||
*core = core_info_current;
|
||||
}
|
||||
break;
|
||||
case CORE_INFO_CTL_LIST_DEINIT:
|
||||
if (core_info_curr_list)
|
||||
core_info_list_free(core_info_curr_list);
|
||||
core_info_curr_list = NULL;
|
||||
break;
|
||||
case CORE_INFO_CTL_LIST_INIT:
|
||||
core_info_curr_list = core_info_list_new();
|
||||
break;
|
||||
case CORE_INFO_CTL_LIST_GET:
|
||||
{
|
||||
core_info_list_t **core = (core_info_list_t**)data;
|
||||
if (!core)
|
||||
return false;
|
||||
*core = core_info_curr_list;
|
||||
}
|
||||
break;
|
||||
case CORE_INFO_CTL_LIST_UPDATE_MISSING_FIRMWARE:
|
||||
{
|
||||
core_info_ctx_firmware_t *info = (core_info_ctx_firmware_t*)data;
|
||||
if (!info)
|
||||
return false;
|
||||
|
||||
if (core_info_does_support_file(core, path))
|
||||
continue;
|
||||
return core_info_list_update_missing_firmware(core_info_curr_list,
|
||||
info->path, info->system_directory);
|
||||
}
|
||||
case CORE_INFO_CTL_FIND:
|
||||
{
|
||||
core_info_ctx_find_t *info = (core_info_ctx_find_t*)data;
|
||||
if (!info || !core_info_curr_list)
|
||||
return false;
|
||||
info->inf = core_info_find(core_info_curr_list, info->path);
|
||||
if (!info->inf)
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case CORE_INFO_CTL_LOAD:
|
||||
{
|
||||
core_info_t *core_info = NULL;
|
||||
core_info_ctx_find_t *info = (core_info_ctx_find_t*)data;
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
if (core_info_does_support_any_file(core, list))
|
||||
continue;
|
||||
#endif
|
||||
if (!info)
|
||||
return false;
|
||||
|
||||
break;
|
||||
core_info_ctl(CORE_INFO_CTL_CURRENT_CORE_GET, &core_info);
|
||||
|
||||
if (!core_info_curr_list)
|
||||
return false;
|
||||
|
||||
if (!core_info_list_get_info(core_info_curr_list,
|
||||
core_info, info->path))
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case CORE_INFO_CTL_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
if (list)
|
||||
string_list_free(list);
|
||||
#endif
|
||||
|
||||
*infos = core_info_list->list;
|
||||
*num_infos = supported;
|
||||
}
|
||||
|
||||
void core_info_get_name(const char *path, char *s, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
core_info_t *core_info = NULL;
|
||||
core_info_list_t *core_info_list = NULL;
|
||||
struct string_list *contents = dir_list_new_special(
|
||||
NULL, DIR_LIST_CORES, NULL);
|
||||
|
||||
if (!contents)
|
||||
return;
|
||||
|
||||
core_info_list = (core_info_list_t*)calloc(1, sizeof(*core_info_list));
|
||||
if (!core_info_list)
|
||||
goto error;
|
||||
|
||||
core_info = (core_info_t*)calloc(contents->size, sizeof(*core_info));
|
||||
if (!core_info)
|
||||
goto error;
|
||||
|
||||
core_info_list->list = core_info;
|
||||
core_info_list->count = contents->size;
|
||||
|
||||
for (i = 0; i < contents->size; i++)
|
||||
{
|
||||
config_file_t *conf = NULL;
|
||||
|
||||
if (!string_is_equal(contents->elems[i].data, path))
|
||||
continue;
|
||||
|
||||
conf = core_info_list_iterate(contents, i);
|
||||
|
||||
if (conf)
|
||||
{
|
||||
config_get_string(conf, "corename",
|
||||
&core_info[i].core_name);
|
||||
core_info[i].config_data = (void*)conf;
|
||||
}
|
||||
|
||||
core_info[i].path = strdup(contents->elems[i].data);
|
||||
|
||||
strlcpy(s, core_info[i].core_name, len);
|
||||
}
|
||||
|
||||
error:
|
||||
if (contents)
|
||||
dir_list_free(contents);
|
||||
contents = NULL;
|
||||
core_info_list_free(core_info_list);
|
||||
}
|
||||
|
||||
size_t core_info_list_num_info_files(core_info_list_t *core_info_list)
|
||||
{
|
||||
size_t i, num = 0;
|
||||
|
||||
if (!core_info_list)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < core_info_list->count; i++)
|
||||
{
|
||||
config_file_t *conf = (config_file_t*)
|
||||
core_info_list->list[i].config_data;
|
||||
num += !!conf;
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
bool core_info_list_get_display_name(core_info_list_t *core_info_list,
|
||||
const char *path, char *s, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!core_info_list)
|
||||
return false;
|
||||
|
||||
for (i = 0; i < core_info_list->count; i++)
|
||||
{
|
||||
const core_info_t *info = &core_info_list->list[i];
|
||||
if (string_is_equal(path_basename(info->path), path_basename(path))
|
||||
&& info->display_name)
|
||||
{
|
||||
strlcpy(s, info->display_name, len);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool core_info_get_display_name(const char *path, char *s, size_t len)
|
||||
{
|
||||
char *core_name = NULL;
|
||||
char *display_name = NULL;
|
||||
config_file_t *conf = NULL;
|
||||
|
||||
if (!path_file_exists(path))
|
||||
return false;
|
||||
|
||||
conf = config_file_new(path);
|
||||
|
||||
if (!conf)
|
||||
return false;
|
||||
|
||||
config_get_string(conf, "corename",
|
||||
&core_name);
|
||||
config_get_string(conf, "display_name",
|
||||
&display_name);
|
||||
|
||||
if (!core_name || !display_name)
|
||||
goto error;
|
||||
|
||||
config_file_free(conf);
|
||||
|
||||
snprintf(s, len,"%s",display_name);
|
||||
|
||||
free(core_name);
|
||||
free(display_name);
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
config_file_free(conf);
|
||||
if (core_name)
|
||||
free(core_name);
|
||||
if (display_name)
|
||||
free(display_name);
|
||||
return false;
|
||||
}
|
||||
+21
-25
@@ -20,10 +20,23 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <lists/string_list.h>
|
||||
#include <retro_common_api.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
enum core_info_state
|
||||
{
|
||||
CORE_INFO_CTL_NONE = 0,
|
||||
CORE_INFO_CTL_LIST_DEINIT,
|
||||
CORE_INFO_CTL_LIST_INIT,
|
||||
CORE_INFO_CTL_LIST_GET,
|
||||
CORE_INFO_CTL_LIST_UPDATE_MISSING_FIRMWARE,
|
||||
CORE_INFO_CTL_CURRENT_CORE_FREE,
|
||||
CORE_INFO_CTL_CURRENT_CORE_INIT,
|
||||
CORE_INFO_CTL_CURRENT_CORE_GET,
|
||||
CORE_INFO_CTL_LOAD,
|
||||
CORE_INFO_CTL_FIND
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -74,10 +87,7 @@ typedef struct
|
||||
typedef struct core_info_ctx_firmware
|
||||
{
|
||||
const char *path;
|
||||
struct
|
||||
{
|
||||
const char *system;
|
||||
} directory;
|
||||
const char *system_directory;
|
||||
} core_info_ctx_firmware_t;
|
||||
|
||||
typedef struct core_info_ctx_find
|
||||
@@ -101,24 +111,10 @@ void core_info_get_name(const char *path, char *s, size_t len);
|
||||
|
||||
core_info_t *core_info_get(core_info_list_t *list, size_t i);
|
||||
|
||||
void core_info_free_current_core(void);
|
||||
bool core_info_ctl(enum core_info_state action, void *data);
|
||||
|
||||
bool core_info_init_current_core(void);
|
||||
|
||||
bool core_info_get_current_core(core_info_t **core);
|
||||
|
||||
void core_info_deinit_list(void);
|
||||
|
||||
bool core_info_init_list(void);
|
||||
|
||||
bool core_info_get_list(core_info_list_t **core);
|
||||
|
||||
bool core_info_list_update_missing_firmware(core_info_ctx_firmware_t *info);
|
||||
|
||||
bool core_info_find(core_info_ctx_find_t *info, const char *name);
|
||||
|
||||
bool core_info_load(core_info_ctx_find_t *info);
|
||||
|
||||
RETRO_END_DECLS
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CORE_INFO_H_ */
|
||||
@@ -17,16 +17,13 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <file/config_file.h>
|
||||
#include <lists/dir_list.h>
|
||||
#include <lists/string_list.h>
|
||||
#include <file/dir_list.h>
|
||||
#include <compat/posix_string.h>
|
||||
#include <compat/strl.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include <libretro.h>
|
||||
|
||||
#include "core_option_manager.h"
|
||||
#include "core_options.h"
|
||||
|
||||
struct core_option
|
||||
{
|
||||
@@ -46,8 +43,65 @@ struct core_option_manager
|
||||
bool updated;
|
||||
};
|
||||
|
||||
static bool core_option_manager_parse_variable(
|
||||
core_option_manager_t *opt, size_t idx,
|
||||
/**
|
||||
* core_option_free:
|
||||
* @opt : options manager handle
|
||||
*
|
||||
* Frees core option manager handle.
|
||||
**/
|
||||
void core_option_free(core_option_manager_t *opt)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!opt)
|
||||
return;
|
||||
|
||||
for (i = 0; i < opt->size; i++)
|
||||
{
|
||||
if (opt->opts[i].desc)
|
||||
free(opt->opts[i].desc);
|
||||
if (opt->opts[i].key)
|
||||
free(opt->opts[i].key);
|
||||
|
||||
if (opt->opts[i].vals)
|
||||
string_list_free(opt->opts[i].vals);
|
||||
|
||||
opt->opts[i].desc = NULL;
|
||||
opt->opts[i].key = NULL;
|
||||
opt->opts[i].vals = NULL;
|
||||
}
|
||||
|
||||
if (opt->conf)
|
||||
config_file_free(opt->conf);
|
||||
free(opt->opts);
|
||||
free(opt);
|
||||
}
|
||||
|
||||
void core_option_get(core_option_manager_t *opt, struct retro_variable *var)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!opt)
|
||||
return;
|
||||
|
||||
opt->updated = false;
|
||||
|
||||
for (i = 0; i < opt->size; i++)
|
||||
{
|
||||
if (string_is_empty(opt->opts[i].key))
|
||||
continue;
|
||||
|
||||
if (string_is_equal(opt->opts[i].key, var->key))
|
||||
{
|
||||
var->value = core_option_get_val(opt, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var->value = NULL;
|
||||
}
|
||||
|
||||
static bool parse_variable(core_option_manager_t *opt, size_t idx,
|
||||
const struct retro_variable *var)
|
||||
{
|
||||
const char *val_start = NULL;
|
||||
@@ -56,6 +110,9 @@ static bool core_option_manager_parse_variable(
|
||||
char *config_val = NULL;
|
||||
struct core_option *option = (struct core_option*)&opt->opts[idx];
|
||||
|
||||
if (!option)
|
||||
return false;
|
||||
|
||||
option->key = strdup(var->key);
|
||||
value = strdup(var->value);
|
||||
desc_end = strstr(value, "; ");
|
||||
@@ -100,67 +157,7 @@ static bool core_option_manager_parse_variable(
|
||||
}
|
||||
|
||||
/**
|
||||
* core_option_manager_free:
|
||||
* @opt : options manager handle
|
||||
*
|
||||
* Frees core option manager handle.
|
||||
**/
|
||||
void core_option_manager_free(core_option_manager_t *opt)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!opt)
|
||||
return;
|
||||
|
||||
for (i = 0; i < opt->size; i++)
|
||||
{
|
||||
if (opt->opts[i].desc)
|
||||
free(opt->opts[i].desc);
|
||||
if (opt->opts[i].key)
|
||||
free(opt->opts[i].key);
|
||||
|
||||
if (opt->opts[i].vals)
|
||||
string_list_free(opt->opts[i].vals);
|
||||
|
||||
opt->opts[i].desc = NULL;
|
||||
opt->opts[i].key = NULL;
|
||||
opt->opts[i].vals = NULL;
|
||||
}
|
||||
|
||||
if (opt->conf)
|
||||
config_file_free(opt->conf);
|
||||
free(opt->opts);
|
||||
free(opt);
|
||||
}
|
||||
|
||||
void core_option_manager_get(core_option_manager_t *opt, void *data)
|
||||
{
|
||||
size_t i;
|
||||
struct retro_variable *var = (struct retro_variable*)data;
|
||||
|
||||
if (!opt)
|
||||
return;
|
||||
|
||||
opt->updated = false;
|
||||
|
||||
for (i = 0; i < opt->size; i++)
|
||||
{
|
||||
if (string_is_empty(opt->opts[i].key))
|
||||
continue;
|
||||
|
||||
if (string_is_equal(opt->opts[i].key, var->key))
|
||||
{
|
||||
var->value = core_option_manager_get_val(opt, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var->value = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* core_option_manager_new:
|
||||
* core_option_new:
|
||||
* @conf_path : Filesystem path to write core option config file to.
|
||||
* @vars : Pointer to variable array handle.
|
||||
*
|
||||
@@ -168,13 +165,12 @@ void core_option_manager_get(core_option_manager_t *opt, void *data)
|
||||
*
|
||||
* Returns: handle to new core manager handle, otherwise NULL.
|
||||
**/
|
||||
core_option_manager_t *core_option_manager_new(const char *conf_path,
|
||||
const void *data)
|
||||
core_option_manager_t *core_option_new(const char *conf_path,
|
||||
const struct retro_variable *vars)
|
||||
{
|
||||
const struct retro_variable *var;
|
||||
const struct retro_variable *vars = (const struct retro_variable*)data;
|
||||
size_t size = 0;
|
||||
core_option_manager_t *opt = (core_option_manager_t*)
|
||||
size_t size = 0;
|
||||
core_option_manager_t *opt = (core_option_manager_t*)
|
||||
calloc(1, sizeof(*opt));
|
||||
|
||||
if (!opt)
|
||||
@@ -202,19 +198,19 @@ core_option_manager_t *core_option_manager_new(const char *conf_path,
|
||||
|
||||
for (var = vars; var->key && var->value; size++, var++)
|
||||
{
|
||||
if (!core_option_manager_parse_variable(opt, size, var))
|
||||
if (!parse_variable(opt, size, var))
|
||||
goto error;
|
||||
}
|
||||
|
||||
return opt;
|
||||
|
||||
error:
|
||||
core_option_manager_free(opt);
|
||||
core_option_free(opt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* core_option_manager_updated:
|
||||
* core_option_updated:
|
||||
* @opt : options manager handle
|
||||
*
|
||||
* Has a core option been updated?
|
||||
@@ -222,7 +218,7 @@ error:
|
||||
* Returns: true (1) if a core option has been updated,
|
||||
* otherwise false (0).
|
||||
**/
|
||||
bool core_option_manager_updated(core_option_manager_t *opt)
|
||||
bool core_option_updated(core_option_manager_t *opt)
|
||||
{
|
||||
if (!opt)
|
||||
return false;
|
||||
@@ -230,7 +226,7 @@ bool core_option_manager_updated(core_option_manager_t *opt)
|
||||
}
|
||||
|
||||
/**
|
||||
* core_option_manager_flush:
|
||||
* core_option_flush:
|
||||
* @opt : options manager handle
|
||||
*
|
||||
* Writes core option key-pair values to file.
|
||||
@@ -238,7 +234,7 @@ bool core_option_manager_updated(core_option_manager_t *opt)
|
||||
* Returns: true (1) if core option values could be
|
||||
* successfully saved to disk, otherwise false (0).
|
||||
**/
|
||||
bool core_option_manager_flush(core_option_manager_t *opt)
|
||||
bool core_option_flush(core_option_manager_t *opt)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@@ -247,15 +243,14 @@ bool core_option_manager_flush(core_option_manager_t *opt)
|
||||
struct core_option *option = (struct core_option*)&opt->opts[i];
|
||||
|
||||
if (option)
|
||||
config_set_string(opt->conf, option->key,
|
||||
core_option_manager_get_val(opt, i));
|
||||
config_set_string(opt->conf, option->key, core_option_get_val(opt, i));
|
||||
}
|
||||
|
||||
return config_file_write(opt->conf, opt->conf_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* core_option_manager_flush_game_specific:
|
||||
* core_option_flush_game_specific:
|
||||
* @opt : options manager handle
|
||||
* @path : path for the core options file
|
||||
*
|
||||
@@ -264,8 +259,7 @@ bool core_option_manager_flush(core_option_manager_t *opt)
|
||||
* Returns: true (1) if core option values could be
|
||||
* successfully saved to disk, otherwise false (0).
|
||||
**/
|
||||
bool core_option_manager_flush_game_specific(
|
||||
core_option_manager_t *opt, char* path)
|
||||
bool core_option_flush_game_specific(core_option_manager_t *opt, char* path)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < opt->size; i++)
|
||||
@@ -273,22 +267,21 @@ bool core_option_manager_flush_game_specific(
|
||||
struct core_option *option = (struct core_option*)&opt->opts[i];
|
||||
|
||||
if (option)
|
||||
config_set_string(opt->conf, option->key,
|
||||
core_option_manager_get_val(opt, i));
|
||||
config_set_string(opt->conf, option->key, core_option_get_val(opt, i));
|
||||
}
|
||||
|
||||
return config_file_write(opt->conf, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* core_option_manager_size:
|
||||
* core_option_size:
|
||||
* @opt : options manager handle
|
||||
*
|
||||
* Gets total number of options.
|
||||
*
|
||||
* Returns: Total number of options.
|
||||
**/
|
||||
size_t core_option_manager_size(core_option_manager_t *opt)
|
||||
size_t core_option_size(core_option_manager_t *opt)
|
||||
{
|
||||
if (!opt)
|
||||
return 0;
|
||||
@@ -296,7 +289,7 @@ size_t core_option_manager_size(core_option_manager_t *opt)
|
||||
}
|
||||
|
||||
/**
|
||||
* core_option_manager_get_desc:
|
||||
* core_option_get_desc:
|
||||
* @opt : options manager handle
|
||||
* @index : index identifier of the option
|
||||
*
|
||||
@@ -304,7 +297,7 @@ size_t core_option_manager_size(core_option_manager_t *opt)
|
||||
*
|
||||
* Returns: Description for an option.
|
||||
**/
|
||||
const char *core_option_manager_get_desc(core_option_manager_t *opt, size_t idx)
|
||||
const char *core_option_get_desc(core_option_manager_t *opt, size_t idx)
|
||||
{
|
||||
if (!opt)
|
||||
return NULL;
|
||||
@@ -312,7 +305,7 @@ const char *core_option_manager_get_desc(core_option_manager_t *opt, size_t idx)
|
||||
}
|
||||
|
||||
/**
|
||||
* core_option_manager_get_val:
|
||||
* core_option_get_val:
|
||||
* @opt : options manager handle
|
||||
* @index : index identifier of the option
|
||||
*
|
||||
@@ -320,16 +313,36 @@ const char *core_option_manager_get_desc(core_option_manager_t *opt, size_t idx)
|
||||
*
|
||||
* Returns: Value for an option.
|
||||
**/
|
||||
const char *core_option_manager_get_val(core_option_manager_t *opt, size_t idx)
|
||||
const char *core_option_get_val(core_option_manager_t *opt, size_t idx)
|
||||
{
|
||||
struct core_option *option = NULL;
|
||||
if (!opt)
|
||||
return NULL;
|
||||
option = (struct core_option*)&opt->opts[idx];
|
||||
if (!option)
|
||||
return NULL;
|
||||
return option->vals->elems[option->index].data;
|
||||
}
|
||||
|
||||
void core_option_manager_set_val(core_option_manager_t *opt,
|
||||
/**
|
||||
* core_option_get_vals:
|
||||
* @opt : pointer to core option manager object.
|
||||
* @idx : idx of core option.
|
||||
*
|
||||
* Gets list of core option values from core option at index @idx.
|
||||
*
|
||||
* Returns: string list of core option values if successful, otherwise
|
||||
* NULL.
|
||||
**/
|
||||
struct string_list *core_option_get_vals(
|
||||
core_option_manager_t *opt, size_t idx)
|
||||
{
|
||||
if (!opt)
|
||||
return NULL;
|
||||
return opt->opts[idx].vals;
|
||||
}
|
||||
|
||||
void core_option_set_val(core_option_manager_t *opt,
|
||||
size_t idx, size_t val_idx)
|
||||
{
|
||||
struct core_option *option= NULL;
|
||||
@@ -337,35 +350,41 @@ void core_option_manager_set_val(core_option_manager_t *opt,
|
||||
if (!opt)
|
||||
return;
|
||||
|
||||
option = (struct core_option*)&opt->opts[idx];
|
||||
option->index = val_idx % option->vals->size;
|
||||
option = (struct core_option*)&opt->opts[idx];
|
||||
|
||||
if (!option)
|
||||
return;
|
||||
|
||||
option->index = val_idx % option->vals->size;
|
||||
opt->updated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* core_option_manager_next:
|
||||
* core_option_next:
|
||||
* @opt : pointer to core option manager object.
|
||||
* @idx : index of core option to be reset to defaults.
|
||||
*
|
||||
* Get next value for core option specified by @idx.
|
||||
* Options wrap around.
|
||||
**/
|
||||
void core_option_manager_next(core_option_manager_t *opt, size_t idx)
|
||||
void core_option_next(core_option_manager_t *opt, size_t idx)
|
||||
{
|
||||
struct core_option *option = NULL;
|
||||
|
||||
if (!opt)
|
||||
return;
|
||||
|
||||
option = (struct core_option*)&opt->opts[idx];
|
||||
option = (struct core_option*)&opt->opts[idx];
|
||||
|
||||
if (!option)
|
||||
return;
|
||||
|
||||
option->index = (option->index + 1) % option->vals->size;
|
||||
opt->updated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* core_option_manager_prev:
|
||||
* core_option_prev:
|
||||
* @opt : pointer to core option manager object.
|
||||
* @idx : index of core option to be reset to defaults.
|
||||
* Options wrap around.
|
||||
@@ -373,28 +392,31 @@ void core_option_manager_next(core_option_manager_t *opt, size_t idx)
|
||||
* Get previous value for core option specified by @idx.
|
||||
* Options wrap around.
|
||||
**/
|
||||
void core_option_manager_prev(core_option_manager_t *opt, size_t idx)
|
||||
void core_option_prev(core_option_manager_t *opt, size_t idx)
|
||||
{
|
||||
struct core_option *option = NULL;
|
||||
|
||||
if (!opt)
|
||||
return;
|
||||
|
||||
option = (struct core_option*)&opt->opts[idx];
|
||||
option = (struct core_option*)&opt->opts[idx];
|
||||
|
||||
if (!option)
|
||||
return;
|
||||
|
||||
option->index = (option->index + option->vals->size - 1) %
|
||||
option->vals->size;
|
||||
|
||||
opt->updated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* core_option_manager_set_default:
|
||||
* core_option_set_default:
|
||||
* @opt : pointer to core option manager object.
|
||||
* @idx : index of core option to be reset to defaults.
|
||||
*
|
||||
* Reset core option specified by @idx and sets default value for option.
|
||||
**/
|
||||
void core_option_manager_set_default(core_option_manager_t *opt, size_t idx)
|
||||
void core_option_set_default(core_option_manager_t *opt, size_t idx)
|
||||
{
|
||||
if (!opt)
|
||||
return;
|
||||
@@ -14,20 +14,24 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CORE_OPTION_MANAGER_H__
|
||||
#define CORE_OPTION_MANAGER_H__
|
||||
#ifndef CORE_OPTIONS_H__
|
||||
#define CORE_OPTIONS_H__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
#include <string/string_list.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
#include "libretro.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct core_option_manager core_option_manager_t;
|
||||
|
||||
/**
|
||||
* core_option_manager_new:
|
||||
* core_option_new:
|
||||
* @conf_path : Filesystem path to write core option config file to.
|
||||
* @vars : Pointer to variable array handle.
|
||||
*
|
||||
@@ -35,11 +39,11 @@ typedef struct core_option_manager core_option_manager_t;
|
||||
*
|
||||
* Returns: handle to new core manager handle, otherwise NULL.
|
||||
**/
|
||||
core_option_manager_t *core_option_manager_new(const char *conf_path,
|
||||
const void *data);
|
||||
core_option_manager_t *core_option_new(const char *conf_path,
|
||||
const struct retro_variable *vars);
|
||||
|
||||
/**
|
||||
* core_option_manager_updated:
|
||||
* core_option_updated:
|
||||
* @opt : options manager handle
|
||||
*
|
||||
* Has a core option been updated?
|
||||
@@ -47,10 +51,10 @@ core_option_manager_t *core_option_manager_new(const char *conf_path,
|
||||
* Returns: true (1) if a core option has been updated,
|
||||
* otherwise false (0).
|
||||
**/
|
||||
bool core_option_manager_updated(core_option_manager_t *opt);
|
||||
bool core_option_updated(core_option_manager_t *opt);
|
||||
|
||||
/**
|
||||
* core_option_manager_flush:
|
||||
* core_option_flush:
|
||||
* @opt : options manager handle
|
||||
*
|
||||
* Writes core option key-pair values to file.
|
||||
@@ -58,10 +62,10 @@ bool core_option_manager_updated(core_option_manager_t *opt);
|
||||
* Returns: true (1) if core option values could be
|
||||
* successfully saved to disk, otherwise false (0).
|
||||
**/
|
||||
bool core_option_manager_flush(core_option_manager_t *opt);
|
||||
bool core_option_flush(core_option_manager_t *opt);
|
||||
|
||||
/**
|
||||
* core_option_manager_flush_game_specific:
|
||||
* core_option_flush_game_specific:
|
||||
* @opt : options manager handle
|
||||
* @path : path for the core options file
|
||||
*
|
||||
@@ -70,31 +74,32 @@ bool core_option_manager_flush(core_option_manager_t *opt);
|
||||
* Returns: true (1) if core option values could be
|
||||
* successfully saved to disk, otherwise false (0).
|
||||
**/
|
||||
bool core_option_manager_flush_game_specific(
|
||||
bool core_option_flush_game_specific(
|
||||
core_option_manager_t *opt, char* path);
|
||||
|
||||
/**
|
||||
* core_option_manager_free:
|
||||
* core_option_free:
|
||||
* @opt : options manager handle
|
||||
*
|
||||
* Frees core option manager handle.
|
||||
**/
|
||||
void core_option_manager_free(core_option_manager_t *opt);
|
||||
void core_option_free(core_option_manager_t *opt);
|
||||
|
||||
void core_option_manager_get(core_option_manager_t *opt, void *data);
|
||||
void core_option_get(core_option_manager_t *opt,
|
||||
struct retro_variable *var);
|
||||
|
||||
/**
|
||||
* core_option_manager_size:
|
||||
* core_option_size:
|
||||
* @opt : options manager handle
|
||||
*
|
||||
* Gets total number of options.
|
||||
*
|
||||
* Returns: Total number of options.
|
||||
**/
|
||||
size_t core_option_manager_size(core_option_manager_t *opt);
|
||||
size_t core_option_size(core_option_manager_t *opt);
|
||||
|
||||
/**
|
||||
* core_option_manager_get_desc:
|
||||
* core_option_get_desc:
|
||||
* @opt : options manager handle
|
||||
* @idx : idx identifier of the option
|
||||
*
|
||||
@@ -102,11 +107,11 @@ size_t core_option_manager_size(core_option_manager_t *opt);
|
||||
*
|
||||
* Returns: Description for an option.
|
||||
**/
|
||||
const char *core_option_manager_get_desc(core_option_manager_t *opt,
|
||||
const char *core_option_get_desc(core_option_manager_t *opt,
|
||||
size_t idx);
|
||||
|
||||
/**
|
||||
* core_option_manager_get_val:
|
||||
* core_option_get_val:
|
||||
* @opt : options manager handle
|
||||
* @idx : idx identifier of the option
|
||||
*
|
||||
@@ -114,24 +119,37 @@ const char *core_option_manager_get_desc(core_option_manager_t *opt,
|
||||
*
|
||||
* Returns: Value for an option.
|
||||
**/
|
||||
const char *core_option_manager_get_val(core_option_manager_t *opt,
|
||||
const char *core_option_get_val(core_option_manager_t *opt,
|
||||
size_t idx);
|
||||
|
||||
void core_option_manager_set_val(core_option_manager_t *opt,
|
||||
/**
|
||||
* core_option_get_vals:
|
||||
* @opt : pointer to core option manager object.
|
||||
* @idx : idx of core option.
|
||||
*
|
||||
* Gets list of core option values from core option at index @idx.
|
||||
*
|
||||
* Returns: string list of core option values if successful, otherwise
|
||||
* NULL.
|
||||
**/
|
||||
struct string_list *core_option_get_vals(
|
||||
core_option_manager_t *opt, size_t idx);
|
||||
|
||||
void core_option_set_val(core_option_manager_t *opt,
|
||||
size_t idx, size_t val_idx);
|
||||
|
||||
/**
|
||||
* core_option_manager_next:
|
||||
* core_option_next:
|
||||
* @opt : pointer to core option manager object.
|
||||
* @idx : idx of core option to be reset to defaults.
|
||||
*
|
||||
* Get next value for core option specified by @idx.
|
||||
* Options wrap around.
|
||||
**/
|
||||
void core_option_manager_next(core_option_manager_t *opt, size_t idx);
|
||||
void core_option_next(core_option_manager_t *opt, size_t idx);
|
||||
|
||||
/**
|
||||
* core_option_manager_prev:
|
||||
* core_option_prev:
|
||||
* @opt : pointer to core option manager object.
|
||||
* @idx : idx of core option to be reset to defaults.
|
||||
* Options wrap around.
|
||||
@@ -139,17 +157,20 @@ void core_option_manager_next(core_option_manager_t *opt, size_t idx);
|
||||
* Get previous value for core option specified by @idx.
|
||||
* Options wrap around.
|
||||
**/
|
||||
void core_option_manager_prev(core_option_manager_t *opt, size_t idx);
|
||||
void core_option_prev(core_option_manager_t *opt, size_t idx);
|
||||
|
||||
/**
|
||||
* core_option_manager_set_default:
|
||||
* core_option_set_default:
|
||||
* @opt : pointer to core option manager object.
|
||||
* @idx : idx of core option to be reset to defaults.
|
||||
*
|
||||
* Reset core option specified by @idx and sets default value for option.
|
||||
**/
|
||||
void core_option_manager_set_default(core_option_manager_t *opt, size_t idx);
|
||||
void core_option_set_default(core_option_manager_t *opt, size_t idx);
|
||||
|
||||
RETRO_END_DECLS
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,9 +19,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libretro.h>
|
||||
|
||||
#include "internal_cores.h"
|
||||
#include "../libretro.h"
|
||||
|
||||
static uint16_t *frame_buf;
|
||||
|
||||
|
||||
+1
-57
@@ -19,7 +19,7 @@
|
||||
#define INTERNAL_CORES_H__
|
||||
|
||||
#include <boolean.h>
|
||||
#include <libretro.h>
|
||||
#include "../libretro.h"
|
||||
|
||||
void libretro_dummy_retro_init(void);
|
||||
|
||||
@@ -184,60 +184,4 @@ size_t libretro_imageviewer_retro_get_memory_size(unsigned id);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_NETWORKGAMEPAD) && defined(HAVE_NETPLAY)
|
||||
/* Internal networked retropad core. */
|
||||
|
||||
void libretro_netretropad_retro_init(void);
|
||||
|
||||
void libretro_netretropad_retro_deinit(void);
|
||||
|
||||
unsigned libretro_netretropad_retro_api_version(void);
|
||||
|
||||
void libretro_netretropad_retro_get_system_info(struct retro_system_info *info);
|
||||
|
||||
void libretro_netretropad_retro_get_system_av_info(struct retro_system_av_info *info);
|
||||
|
||||
void libretro_netretropad_retro_set_environment(retro_environment_t cb);
|
||||
|
||||
void libretro_netretropad_retro_set_video_refresh(retro_video_refresh_t cb);
|
||||
|
||||
void libretro_netretropad_retro_set_audio_sample(retro_audio_sample_t cb);
|
||||
|
||||
void libretro_netretropad_retro_set_audio_sample_batch(retro_audio_sample_batch_t cb);
|
||||
|
||||
void libretro_netretropad_retro_set_input_poll(retro_input_poll_t cb);
|
||||
|
||||
void libretro_netretropad_retro_set_input_state(retro_input_state_t cb);
|
||||
|
||||
void libretro_netretropad_retro_set_controller_port_device(unsigned port, unsigned device);
|
||||
|
||||
void libretro_netretropad_retro_reset(void);
|
||||
|
||||
void libretro_netretropad_retro_run(void);
|
||||
|
||||
size_t libretro_netretropad_retro_serialize_size(void);
|
||||
|
||||
bool libretro_netretropad_retro_serialize(void *data, size_t size);
|
||||
|
||||
bool libretro_netretropad_retro_unserialize(const void *data, size_t size);
|
||||
|
||||
void libretro_netretropad_retro_cheat_reset(void);
|
||||
|
||||
void libretro_netretropad_retro_cheat_set(unsigned index, bool enabled, const char *code);
|
||||
|
||||
bool libretro_netretropad_retro_load_game(const struct retro_game_info *game);
|
||||
|
||||
bool libretro_netretropad_retro_load_game_special(unsigned game_type,
|
||||
const struct retro_game_info *info, size_t num_info);
|
||||
|
||||
void libretro_netretropad_retro_unload_game(void);
|
||||
|
||||
unsigned libretro_netretropad_retro_get_region(void);
|
||||
|
||||
void *libretro_netretropad_retro_get_memory_data(unsigned id);
|
||||
|
||||
size_t libretro_netretropad_retro_get_memory_size(unsigned id);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -232,13 +232,12 @@ ifeq ($(HAVE_SSA), 1)
|
||||
endif
|
||||
|
||||
LIBRETROCOMM_DIR := ../../libretro-common
|
||||
DEPS_DIR := ../../deps
|
||||
|
||||
LIBAVCODEC_SOURCE :=
|
||||
LIBAVFORMAT_SOURCE :=
|
||||
LIBAVUTIL_SOURCE :=
|
||||
LIBRETRO_SOURCE := ffmpeg_core.c \
|
||||
$(LIBRETROCOMM_DIR)/queues/fifo_queue.c \
|
||||
$(LIBRETROCOMM_DIR)/queues/fifo_buffer.c \
|
||||
$(LIBRETROCOMM_DIR)/rthreads/rthreads.c
|
||||
DEPS_SOURCE :=
|
||||
|
||||
@@ -2166,7 +2165,7 @@ else
|
||||
CFLAGS += -DHAVE_INTRINSICS_NEON=0
|
||||
endif
|
||||
|
||||
CFLAGS += -I$(LIBRETROCOMM_DIR)/include -I$(DEPS_DIR)
|
||||
CFLAGS += -Ilibretro-common/include
|
||||
|
||||
OBJECTS := $(DEPS_SOURCE:.c=.o) $(LIBRETRO_SOURCE:.c=.o) $(FFT_SOURCE:.cpp=.o) $(LIBAVUTIL_SOURCE:.c=.o) $(LIBAVFORMAT_SOURCE:.c=.o) $(LIBSWSCALE_SOURCE:.c=.o) $(LIBAVCODEC_SOURCE:.c=.o) $(LIBSWRESAMPLE_SOURCE:.c=.o)
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libswscale/swscale.h>
|
||||
#include <libavutil/imgutils.h>
|
||||
#include <libavutil/time.h>
|
||||
#include <libavutil/opt.h>
|
||||
#include <libavdevice/avdevice.h>
|
||||
@@ -40,9 +39,9 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rthreads/rthreads.h>
|
||||
#include <queues/fifo_queue.h>
|
||||
#include <queues/fifo_buffer.h>
|
||||
|
||||
#include <libretro.h>
|
||||
#include "libretro.h"
|
||||
#ifdef RARCH_INTERNAL
|
||||
#include "internal_cores.h"
|
||||
#define CORE_PREFIX(s) libretro_ffmpeg_##s
|
||||
@@ -181,14 +180,9 @@ static struct
|
||||
#ifdef HAVE_SSA
|
||||
static void ass_msg_cb(int level, const char *fmt, va_list args, void *data)
|
||||
{
|
||||
char buffer[4096];
|
||||
(void)data;
|
||||
|
||||
if (level < 6)
|
||||
{
|
||||
vsnprintf(buffer, sizeof(buffer), fmt, args);
|
||||
log_cb(RETRO_LOG_INFO, "%s\n", buffer);
|
||||
}
|
||||
log_cb(RETRO_LOG_INFO, fmt);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -905,7 +899,7 @@ static bool init_media_info(void)
|
||||
#ifdef HAVE_SSA
|
||||
if (sctx[0])
|
||||
{
|
||||
unsigned i;
|
||||
size_t i;
|
||||
|
||||
ass = ass_library_init();
|
||||
ass_set_message_cb(ass, ass_msg_cb, NULL);
|
||||
@@ -920,7 +914,7 @@ static bool init_media_info(void)
|
||||
ass_set_fonts(ass_render, NULL, NULL, 1, NULL, 1);
|
||||
ass_set_hinting(ass_render, ASS_HINTING_LIGHT);
|
||||
|
||||
for (i = 0; i < (unsigned)subtitle_streams_num; i++)
|
||||
for (i = 0; i < subtitle_streams_num; i++)
|
||||
{
|
||||
ass_track[i] = ass_new_track(ass);
|
||||
ass_process_codec_private(ass_track[i], (char*)ass_extra_data[i],
|
||||
@@ -1252,7 +1246,7 @@ static void decode_thread(void *data)
|
||||
decoded_size = frame_size + sizeof(pts);
|
||||
slock_lock(fifo_lock);
|
||||
|
||||
while (!decode_thread_dead && (video_decode_fifo != NULL)
|
||||
while (!decode_thread_dead
|
||||
&& fifo_write_avail(video_decode_fifo) < decoded_size)
|
||||
{
|
||||
if (!main_sleeping)
|
||||
|
||||
@@ -1,735 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <glsym/glsym.h>
|
||||
#include <libretro.h>
|
||||
|
||||
#include <retro_miscellaneous.h>
|
||||
#include <filters.h>
|
||||
#include <math/complex.h>
|
||||
|
||||
#define GLM_SWIZZLE
|
||||
#define GLM_FORCE_RADIANS
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
using namespace glm;
|
||||
|
||||
#define GL_DEBUG 0
|
||||
#if GL_DEBUG
|
||||
#define GL_CHECK_ERROR() do { \
|
||||
if (glGetError() != GL_NO_ERROR) \
|
||||
{ \
|
||||
log_cb(RETRO_LOG_ERROR, "GL error at line: %d\n", __LINE__); \
|
||||
abort(); \
|
||||
} \
|
||||
} while(0)
|
||||
#else
|
||||
#define GL_CHECK_ERROR()
|
||||
#endif
|
||||
|
||||
#ifndef M_HALF_PI
|
||||
#define M_HALF_PI 1.57079632679489661923132169163975144
|
||||
#endif
|
||||
|
||||
extern retro_log_printf_t log_cb;
|
||||
|
||||
struct target
|
||||
{
|
||||
GLuint tex;
|
||||
GLuint fbo;
|
||||
};
|
||||
|
||||
struct Pass
|
||||
{
|
||||
struct target target;
|
||||
GLuint parameter_tex;
|
||||
};
|
||||
|
||||
typedef struct GLFFT
|
||||
{
|
||||
GLuint ms_rb_color;
|
||||
GLuint ms_rb_ds;
|
||||
GLuint ms_fbo;
|
||||
|
||||
Pass *passes;
|
||||
unsigned passes_size;
|
||||
|
||||
GLuint input_tex;
|
||||
GLuint window_tex;
|
||||
GLuint prog_real;
|
||||
GLuint prog_complex;
|
||||
GLuint prog_resolve;
|
||||
GLuint prog_blur;
|
||||
|
||||
GLuint quad;
|
||||
GLuint vao;
|
||||
|
||||
unsigned output_ptr;
|
||||
|
||||
struct target output, resolve, blur;
|
||||
|
||||
struct Block
|
||||
{
|
||||
GLuint prog;
|
||||
GLuint vao;
|
||||
GLuint vbo;
|
||||
GLuint ibo;
|
||||
unsigned elems;
|
||||
} block;
|
||||
|
||||
GLuint pbo;
|
||||
GLshort *sliding;
|
||||
unsigned sliding_size;
|
||||
|
||||
unsigned steps;
|
||||
unsigned size;
|
||||
unsigned block_size;
|
||||
unsigned depth;
|
||||
} glfft_t;
|
||||
|
||||
#include "gl_shaders/fft_heightmap.glsl.vert.h"
|
||||
#include "gl_shaders/fft_heightmap.glsl.frag.h"
|
||||
#include "gl_shaders/fft_vertex_program.glsl.vert.h"
|
||||
#include "gl_shaders/fft_fragment_program_resolve.glsl.frag.h"
|
||||
#include "gl_shaders/fft_fragment_program_real.glsl.frag.h"
|
||||
#include "gl_shaders/fft_fragment_program_complex.glsl.frag.h"
|
||||
#include "gl_shaders/fft_fragment_program_blur.glsl.frag.h"
|
||||
|
||||
static GLuint fft_compile_shader(glfft_t *fft, GLenum type, const char *source)
|
||||
{
|
||||
GLint status = 0;
|
||||
GLuint shader = glCreateShader(type);
|
||||
|
||||
glShaderSource(shader, 1, (const GLchar**)&source, NULL);
|
||||
glCompileShader(shader);
|
||||
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
|
||||
|
||||
if (!status)
|
||||
{
|
||||
char log_info[8 * 1024];
|
||||
GLsizei log_len;
|
||||
|
||||
log_cb(RETRO_LOG_ERROR, "Failed to compile.\n");
|
||||
glGetShaderInfoLog(shader, sizeof(log_info), &log_len, log_info);
|
||||
log_cb(RETRO_LOG_ERROR, "ERROR: %s\n", log_info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
static GLuint fft_compile_program(glfft_t *fft,
|
||||
const char *vertex_source, const char *fragment_source)
|
||||
{
|
||||
GLint status = 0;
|
||||
GLuint prog = glCreateProgram();
|
||||
GLuint vert = fft_compile_shader(fft, GL_VERTEX_SHADER, vertex_source);
|
||||
GLuint frag = fft_compile_shader(fft, GL_FRAGMENT_SHADER, fragment_source);
|
||||
|
||||
glAttachShader(prog, vert);
|
||||
glAttachShader(prog, frag);
|
||||
glLinkProgram(prog);
|
||||
|
||||
glGetProgramiv(prog, GL_LINK_STATUS, &status);
|
||||
|
||||
if (!status)
|
||||
{
|
||||
char log_info[8 * 1024];
|
||||
GLsizei log_len;
|
||||
|
||||
log_cb(RETRO_LOG_ERROR, "Failed to link.\n");
|
||||
glGetProgramInfoLog(prog, sizeof(log_info), &log_len, log_info);
|
||||
log_cb(RETRO_LOG_ERROR, "ERROR: %s\n", log_info);
|
||||
}
|
||||
|
||||
glDeleteShader(vert);
|
||||
glDeleteShader(frag);
|
||||
return prog;
|
||||
}
|
||||
|
||||
static void fft_render(glfft_t *fft, GLuint backbuffer, unsigned width, unsigned height)
|
||||
{
|
||||
mat4 mvp;
|
||||
|
||||
/* Render scene. */
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fft->ms_fbo ? fft->ms_fbo : backbuffer);
|
||||
glViewport(0, 0, width, height);
|
||||
glClearColor(0.1f, 0.15f, 0.1f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
vec3 eye(0, 80, -60);
|
||||
mvp = perspective((float)M_HALF_PI, (float)width / height, 1.0f, 500.0f) *
|
||||
lookAt(eye, eye + vec3(0.0f, 0.0f, 1.0f), vec3(0.0f, 1.0f, 0.0f));
|
||||
|
||||
glUseProgram(fft->block.prog);
|
||||
glUniformMatrix4fv(glGetUniformLocation(fft->block.prog, "uMVP"),
|
||||
1, GL_FALSE, value_ptr(mvp));
|
||||
glUniform2i(glGetUniformLocation(fft->block.prog, "uOffset"),
|
||||
(-int(fft->block_size) + 1) / 2, fft->output_ptr);
|
||||
glUniform4f(glGetUniformLocation(fft->block.prog, "uHeightmapParams"),
|
||||
-(fft->block_size - 1.0f) / 2.0f, 0.0f, 3.0f, 2.0f);
|
||||
glUniform1f(glGetUniformLocation(fft->block.prog, "uAngleScale"),
|
||||
M_PI / ((fft->block_size - 1) / 2));
|
||||
|
||||
glBindVertexArray(fft->block.vao);
|
||||
glBindTexture(GL_TEXTURE_2D, fft->blur.tex);
|
||||
glDrawElements(GL_TRIANGLE_STRIP, fft->block.elems, GL_UNSIGNED_INT, NULL);
|
||||
glBindVertexArray(0);
|
||||
glUseProgram(0);
|
||||
|
||||
if (fft->ms_fbo)
|
||||
{
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, fft->ms_fbo);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, backbuffer);
|
||||
glBlitFramebuffer(0, 0, width, height, 0, 0, width, height,
|
||||
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
static const GLenum attachments[] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_STENCIL_ATTACHMENT };
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fft->ms_fbo);
|
||||
glInvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
|
||||
GL_CHECK_ERROR();
|
||||
}
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
GL_CHECK_ERROR();
|
||||
}
|
||||
|
||||
static void fft_step(glfft_t *fft,
|
||||
const GLshort *audio_buffer, unsigned frames)
|
||||
{
|
||||
unsigned i;
|
||||
GLshort *buffer = NULL;
|
||||
GLshort *slide = (GLshort*)&fft->sliding[0];
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glBindVertexArray(fft->vao);
|
||||
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, fft->window_tex);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, fft->input_tex);
|
||||
glUseProgram(fft->prog_real);
|
||||
|
||||
memmove(slide, slide + frames * 2,
|
||||
(fft->sliding_size - 2 * frames) * sizeof(GLshort));
|
||||
memcpy(slide + fft->sliding_size - frames * 2, audio_buffer,
|
||||
2 * frames * sizeof(GLshort));
|
||||
|
||||
/* Upload audio data to GPU. */
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, fft->pbo);
|
||||
|
||||
buffer = (GLshort*)(glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0,
|
||||
2 * fft->size * sizeof(GLshort),
|
||||
GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT));
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
memcpy(buffer, slide, fft->sliding_size * sizeof(GLshort));
|
||||
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
||||
}
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, fft->size, 1,
|
||||
GL_RG_INTEGER, GL_SHORT, NULL);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
|
||||
/* Perform FFT of new block. */
|
||||
glViewport(0, 0, fft->size, 1);
|
||||
|
||||
for (i = 0; i < fft->steps; i++)
|
||||
{
|
||||
if (i == fft->steps - 1)
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fft->output.fbo);
|
||||
glUniform1i(glGetUniformLocation(i == 0
|
||||
? fft->prog_real : fft->prog_complex, "uViewportOffset"),
|
||||
fft->output_ptr);
|
||||
glViewport(0, fft->output_ptr, fft->size, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
glUniform1i(glGetUniformLocation(i == 0
|
||||
? fft->prog_real : fft->prog_complex, "uViewportOffset"), 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fft->passes[i].target.fbo);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, fft->passes[i].parameter_tex);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, fft->passes[i].target.tex);
|
||||
|
||||
if (i == 0)
|
||||
glUseProgram(fft->prog_complex);
|
||||
}
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
/* Resolve new chunk to heightmap. */
|
||||
glViewport(0, fft->output_ptr, fft->size, 1);
|
||||
glUseProgram(fft->prog_resolve);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fft->resolve.fbo);
|
||||
const GLfloat resolve_offset[] = { 0.0f, float(fft->output_ptr) / fft->depth,
|
||||
1.0f, 1.0f / fft->depth };
|
||||
glUniform4fv(glGetUniformLocation(fft->prog_resolve, "uOffsetScale"),
|
||||
1, resolve_offset);
|
||||
glBindTexture(GL_TEXTURE_2D, fft->output.tex);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
/* Re-blur damaged regions of heightmap. */
|
||||
glUseProgram(fft->prog_blur);
|
||||
glBindTexture(GL_TEXTURE_2D, fft->resolve.tex);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fft->blur.fbo);
|
||||
glUniform4fv(glGetUniformLocation(fft->prog_blur, "uOffsetScale"),
|
||||
1, resolve_offset);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
/* Mipmap the heightmap. */
|
||||
glBindTexture(GL_TEXTURE_2D, fft->blur.tex);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
fft->output_ptr++;
|
||||
fft->output_ptr &= fft->depth - 1;
|
||||
|
||||
glBindVertexArray(0);
|
||||
glUseProgram(0);
|
||||
GL_CHECK_ERROR();
|
||||
}
|
||||
|
||||
static inline unsigned log2i(unsigned x)
|
||||
{
|
||||
if (x==0) return 0; // shouldn't happen
|
||||
|
||||
unsigned res;
|
||||
for (res = 0; x; x >>= 1)
|
||||
res++;
|
||||
return res - 1;
|
||||
}
|
||||
|
||||
static inline unsigned bitinverse(unsigned x, unsigned size)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned size_log2 = log2i(size);
|
||||
unsigned ret = 0;
|
||||
|
||||
for (i = 0; i < size_log2; i++)
|
||||
ret |= ((x >> i) & 0x1) << (size_log2 - 1 - i);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static fft_complex_t exp_imag(float phase)
|
||||
{
|
||||
fft_complex_t out = { cosf(phase), sinf(phase) };
|
||||
return out;
|
||||
}
|
||||
|
||||
void fft_build_params(glfft_t *fft, GLuint *buffer,
|
||||
unsigned step, unsigned size)
|
||||
{
|
||||
unsigned i, j;
|
||||
unsigned step_size = 1 << step;
|
||||
|
||||
for (i = 0; i < size; i += step_size << 1)
|
||||
{
|
||||
for (j = i; j < i + step_size; j++)
|
||||
{
|
||||
int s = j - i;
|
||||
float phase = -1.0f * (float)s / step_size;
|
||||
unsigned a = j;
|
||||
unsigned b = j + step_size;
|
||||
fft_complex_t twiddle = exp_imag(M_PI * phase);
|
||||
|
||||
unsigned read_a = (step == 0) ? bitinverse(a, size) : a;
|
||||
unsigned read_b = (step == 0) ? bitinverse(b, size) : b;
|
||||
vec2 tmp = vec2(twiddle.real, twiddle.imag);
|
||||
|
||||
buffer[2 * a + 0] = (read_a << 16) | read_b;
|
||||
buffer[2 * a + 1] = packHalf2x16(tmp);
|
||||
buffer[2 * b + 0] = (read_a << 16) | read_b;
|
||||
buffer[2 * b + 1] = packHalf2x16(-tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void fft_init_quad_vao(glfft_t *fft)
|
||||
{
|
||||
static const GLbyte quad_buffer[] = {
|
||||
-1, -1, 1, -1, -1, 1, 1, 1,
|
||||
0, 0, 1, 0, 0, 1, 1, 1,
|
||||
};
|
||||
glGenBuffers(1, &fft->quad);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, fft->quad);
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
sizeof(quad_buffer), quad_buffer, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
glGenVertexArrays(1, &fft->vao);
|
||||
glBindVertexArray(fft->vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, fft->quad);
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(0, 2, GL_BYTE, GL_FALSE, 0, 0);
|
||||
glVertexAttribPointer(1, 2, GL_BYTE, GL_FALSE, 0,
|
||||
reinterpret_cast<const GLvoid*>(uintptr_t(8)));
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
static void fft_init_texture(glfft_t *fft, GLuint *tex, GLenum format,
|
||||
unsigned width, unsigned height, unsigned levels, GLenum mag, GLenum min)
|
||||
{
|
||||
glGenTextures(1, tex);
|
||||
glBindTexture(GL_TEXTURE_2D, *tex);
|
||||
glTexStorage2D(GL_TEXTURE_2D, levels, format, width, height);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
static void fft_init_target(glfft_t *fft, struct target *target, GLenum format,
|
||||
unsigned width, unsigned height, unsigned levels, GLenum mag, GLenum min)
|
||||
{
|
||||
fft_init_texture(fft, &target->tex, format, width, height, levels, mag, min);
|
||||
glGenFramebuffers(1, &target->fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, target->fbo);
|
||||
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||
target->tex, 0);
|
||||
|
||||
if (format == GL_RGBA8)
|
||||
{
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
else if (format == GL_RG16I)
|
||||
{
|
||||
static const GLint v[] = { 0, 0, 0, 0 };
|
||||
glClearBufferiv(GL_COLOR, 0, v);
|
||||
}
|
||||
else
|
||||
{
|
||||
static const GLuint v[] = { 0, 0, 0, 0 };
|
||||
glClearBufferuiv(GL_COLOR, 0, v);
|
||||
}
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
#define KAISER_BETA 12.0
|
||||
|
||||
static void fft_init(glfft_t *fft)
|
||||
{
|
||||
unsigned i;
|
||||
double window_mod;
|
||||
GLushort *window;
|
||||
static const GLfloat unity[] = { 0.0f, 0.0f, 1.0f, 1.0f };
|
||||
|
||||
fft->prog_real = fft_compile_program(fft, fft_vertex_program, fft_fragment_program_real);
|
||||
fft->prog_complex = fft_compile_program(fft, fft_vertex_program, fft_fragment_program_complex);
|
||||
fft->prog_resolve = fft_compile_program(fft, fft_vertex_program, fft_fragment_program_resolve);
|
||||
fft->prog_blur = fft_compile_program(fft, fft_vertex_program, fft_fragment_program_blur);
|
||||
GL_CHECK_ERROR();
|
||||
|
||||
glUseProgram(fft->prog_real);
|
||||
glUniform1i(glGetUniformLocation(fft->prog_real, "sTexture"), 0);
|
||||
glUniform1i(glGetUniformLocation(fft->prog_real, "sParameterTexture"), 1);
|
||||
glUniform1i(glGetUniformLocation(fft->prog_real, "sWindow"), 2);
|
||||
glUniform4fv(glGetUniformLocation(fft->prog_real, "uOffsetScale"), 1, unity);
|
||||
|
||||
glUseProgram(fft->prog_complex);
|
||||
glUniform1i(glGetUniformLocation(fft->prog_complex, "sTexture"), 0);
|
||||
glUniform1i(glGetUniformLocation(fft->prog_complex, "sParameterTexture"), 1);
|
||||
glUniform4fv(glGetUniformLocation(fft->prog_complex, "uOffsetScale"), 1, unity);
|
||||
|
||||
glUseProgram(fft->prog_resolve);
|
||||
glUniform1i(glGetUniformLocation(fft->prog_resolve, "sFFT"), 0);
|
||||
glUniform4fv(glGetUniformLocation(fft->prog_resolve, "uOffsetScale"), 1, unity);
|
||||
|
||||
glUseProgram(fft->prog_blur);
|
||||
glUniform1i(glGetUniformLocation(fft->prog_blur, "sHeight"), 0);
|
||||
glUniform4fv(glGetUniformLocation(fft->prog_blur, "uOffsetScale"), 1, unity);
|
||||
|
||||
GL_CHECK_ERROR();
|
||||
|
||||
fft_init_texture(fft, &fft->window_tex, GL_R16UI,
|
||||
fft->size, 1, 1, GL_NEAREST, GL_NEAREST);
|
||||
GL_CHECK_ERROR();
|
||||
|
||||
window = (GLushort*)calloc(fft->size, sizeof(GLushort));
|
||||
|
||||
window_mod = 1.0 / kaiser_window_function(0.0, KAISER_BETA);
|
||||
|
||||
for (i = 0; i < fft->size; i++)
|
||||
{
|
||||
double phase = (double)(i - int(fft->size) / 2) / (int(fft->size) / 2);
|
||||
double w = kaiser_window_function(phase, KAISER_BETA);
|
||||
window[i] = round(0xffff * w * window_mod);
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_2D, fft->window_tex);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
|
||||
fft->size, 1, GL_RED_INTEGER, GL_UNSIGNED_SHORT, &window[0]);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
GL_CHECK_ERROR();
|
||||
fft_init_texture(fft, &fft->input_tex, GL_RG16I,
|
||||
fft->size, 1, 1, GL_NEAREST, GL_NEAREST);
|
||||
fft_init_target(fft, &fft->output, GL_RG32UI,
|
||||
fft->size, fft->depth, 1, GL_NEAREST, GL_NEAREST);
|
||||
fft_init_target(fft, &fft->resolve, GL_RGBA8,
|
||||
fft->size, fft->depth, 1, GL_NEAREST, GL_NEAREST);
|
||||
fft_init_target(fft, &fft->blur, GL_RGBA8,
|
||||
fft->size, fft->depth,
|
||||
log2i(MAX(fft->size, fft->depth)) + 1,
|
||||
GL_NEAREST, GL_LINEAR_MIPMAP_LINEAR);
|
||||
|
||||
GL_CHECK_ERROR();
|
||||
|
||||
for (i = 0; i < fft->steps; i++)
|
||||
{
|
||||
GLuint *param_buffer = NULL;
|
||||
fft_init_target(fft, &fft->passes[i].target,
|
||||
GL_RG32UI, fft->size, 1, 1, GL_NEAREST, GL_NEAREST);
|
||||
fft_init_texture(fft, &fft->passes[i].parameter_tex,
|
||||
GL_RG32UI, fft->size, 1, 1, GL_NEAREST, GL_NEAREST);
|
||||
|
||||
param_buffer = (GLuint*)calloc(2 * fft->size, sizeof(GLuint));
|
||||
|
||||
fft_build_params(fft, ¶m_buffer[0], i, fft->size);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, fft->passes[i].parameter_tex);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
|
||||
fft->size, 1, GL_RG_INTEGER, GL_UNSIGNED_INT, ¶m_buffer[0]);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
free(param_buffer);
|
||||
}
|
||||
|
||||
GL_CHECK_ERROR();
|
||||
glGenBuffers(1, &fft->pbo);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, fft->pbo);
|
||||
glBufferData(GL_PIXEL_UNPACK_BUFFER,
|
||||
fft->size * 2 * sizeof(GLshort), 0, GL_DYNAMIC_DRAW);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
|
||||
free(window);
|
||||
}
|
||||
|
||||
static void fft_init_block(glfft_t *fft)
|
||||
{
|
||||
unsigned x, y;
|
||||
GLuint *bp;
|
||||
GLushort *block_vertices;
|
||||
GLuint *block_indices;
|
||||
unsigned block_vertices_size;
|
||||
unsigned block_indices_size;
|
||||
int pos = 0;
|
||||
|
||||
fft->block.prog = fft_compile_program(fft,
|
||||
fft_vertex_program_heightmap, fft_fragment_program_heightmap);
|
||||
glUseProgram(fft->block.prog);
|
||||
glUniform1i(glGetUniformLocation(fft->block.prog, "sHeight"), 0);
|
||||
|
||||
block_vertices_size = 2 * fft->block_size * fft->depth;
|
||||
block_vertices = (GLushort*)calloc(block_vertices_size, sizeof(GLushort));
|
||||
|
||||
for (y = 0; y < fft->depth; y++)
|
||||
{
|
||||
for (x = 0; x < fft->block_size; x++)
|
||||
{
|
||||
block_vertices[2 * (y * fft->block_size + x) + 0] = x;
|
||||
block_vertices[2 * (y * fft->block_size + x) + 1] = y;
|
||||
}
|
||||
}
|
||||
glGenBuffers(1, &fft->block.vbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, fft->block.vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
block_vertices_size * sizeof(GLushort),
|
||||
&block_vertices[0], GL_STATIC_DRAW);
|
||||
|
||||
fft->block.elems = (2 * fft->block_size - 1) * (fft->depth - 1) + 1;
|
||||
|
||||
block_indices_size = fft->block.elems;
|
||||
block_indices = (GLuint*)calloc(block_indices_size, sizeof(GLuint));
|
||||
|
||||
bp = &block_indices[0];
|
||||
|
||||
for (y = 0; y < fft->depth - 1; y++)
|
||||
{
|
||||
int x;
|
||||
int step_odd = -int(fft->block_size) + ((y & 1) ? -1 : 1);
|
||||
int step_even = fft->block_size;
|
||||
|
||||
for (x = 0; x < 2 * int(fft->block_size) - 1; x++)
|
||||
{
|
||||
*bp++ = pos;
|
||||
pos += (x & 1) ? step_odd : step_even;
|
||||
}
|
||||
}
|
||||
*bp++ = pos;
|
||||
|
||||
glGenVertexArrays(1, &fft->block.vao);
|
||||
glBindVertexArray(fft->block.vao);
|
||||
|
||||
glGenBuffers(1, &fft->block.ibo);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, fft->block.ibo);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
|
||||
block_indices_size * sizeof(GLuint),
|
||||
&block_indices[0], GL_STATIC_DRAW);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_UNSIGNED_SHORT, GL_FALSE, 0, 0);
|
||||
glBindVertexArray(0);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
|
||||
free(block_vertices);
|
||||
free(block_indices);
|
||||
}
|
||||
|
||||
static bool fft_context_reset(glfft_t *fft, unsigned fft_steps,
|
||||
rglgen_proc_address_t proc, unsigned fft_depth)
|
||||
{
|
||||
rglgen_resolve_symbols(proc);
|
||||
|
||||
fft->steps = fft_steps;
|
||||
fft->depth = fft_depth;
|
||||
fft->size = 1 << fft_steps;
|
||||
fft->block_size = fft->size / 4 + 1;
|
||||
|
||||
fft->passes_size = fft_steps;
|
||||
fft->passes = (Pass*)calloc(fft->passes_size, sizeof(Pass));
|
||||
|
||||
if (!fft->passes)
|
||||
return false;
|
||||
|
||||
fft->sliding_size = 2 * fft->size;
|
||||
fft->sliding = (GLshort*)calloc(fft->sliding_size, sizeof(GLshort));
|
||||
|
||||
if (!fft->sliding)
|
||||
return false;
|
||||
|
||||
GL_CHECK_ERROR();
|
||||
fft_init_quad_vao(fft);
|
||||
GL_CHECK_ERROR();
|
||||
fft_init(fft);
|
||||
GL_CHECK_ERROR();
|
||||
fft_init_block(fft);
|
||||
GL_CHECK_ERROR();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* GLFFT requires either GLES3 or
|
||||
* desktop GL with ES3_compat (supported by MESA on Linux) extension. */
|
||||
extern "C" glfft_t *glfft_new(unsigned fft_steps, rglgen_proc_address_t proc)
|
||||
{
|
||||
#ifdef HAVE_OPENGLES3
|
||||
const char *ver = (const char*)(glGetString(GL_VERSION));
|
||||
if (ver)
|
||||
{
|
||||
unsigned major, minor;
|
||||
if (sscanf(ver, "OpenGL ES %u.%u", &major, &minor) != 2 || major < 3)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
#else
|
||||
const char *exts = (const char*)(glGetString(GL_EXTENSIONS));
|
||||
if (!exts || !strstr(exts, "ARB_ES3_compatibility"))
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
glfft_t *fft = (glfft_t*)calloc(1, sizeof(*fft));
|
||||
if (!fft)
|
||||
return NULL;
|
||||
|
||||
if (!fft_context_reset(fft, fft_steps, proc, 256))
|
||||
goto error;
|
||||
|
||||
return fft;
|
||||
|
||||
error:
|
||||
if (fft)
|
||||
free(fft);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern "C" void glfft_init_multisample(glfft_t *fft,
|
||||
unsigned width, unsigned height, unsigned samples)
|
||||
{
|
||||
if (fft->ms_rb_color)
|
||||
glDeleteRenderbuffers(1, &fft->ms_rb_color);
|
||||
fft->ms_rb_color = 0;
|
||||
if (fft->ms_rb_ds)
|
||||
glDeleteRenderbuffers(1, &fft->ms_rb_ds);
|
||||
fft->ms_rb_ds = 0;
|
||||
if (fft->ms_fbo)
|
||||
glDeleteFramebuffers(1, &fft->ms_fbo);
|
||||
fft->ms_fbo = 0;
|
||||
|
||||
if (samples > 1)
|
||||
{
|
||||
glGenRenderbuffers(1, &fft->ms_rb_color);
|
||||
glGenRenderbuffers(1, &fft->ms_rb_ds);
|
||||
glGenFramebuffers (1, &fft->ms_fbo);
|
||||
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, fft->ms_rb_color);
|
||||
glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples,
|
||||
GL_RGBA8, width, height);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, fft->ms_rb_ds);
|
||||
glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples,
|
||||
GL_DEPTH24_STENCIL8, width, height);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fft->ms_fbo);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
||||
GL_RENDERBUFFER, fft->ms_rb_color);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
|
||||
GL_RENDERBUFFER, fft->ms_rb_ds);
|
||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
glfft_init_multisample(fft, 0, 0, 0);
|
||||
}
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
static void fft_context_destroy(glfft_t *fft)
|
||||
{
|
||||
glfft_init_multisample(fft, 0, 0, 0);
|
||||
if (fft->passes)
|
||||
free(fft->passes);
|
||||
fft->passes = NULL;
|
||||
if (fft->sliding)
|
||||
free(fft->sliding);
|
||||
fft->sliding = NULL;
|
||||
}
|
||||
|
||||
extern "C" void glfft_free(glfft_t *fft)
|
||||
{
|
||||
if (!fft)
|
||||
return;
|
||||
|
||||
fft_context_destroy(fft);
|
||||
if (fft)
|
||||
free(fft);
|
||||
fft = NULL;
|
||||
}
|
||||
|
||||
extern "C" void glfft_step_fft(glfft_t *fft,
|
||||
const GLshort *buffer, unsigned frames)
|
||||
{
|
||||
fft_step(fft, buffer, frames);
|
||||
}
|
||||
|
||||
extern "C" void glfft_render(glfft_t *fft, GLuint backbuffer,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
fft_render(fft, backbuffer, width, height);
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#ifndef FFT_H__
|
||||
#define FFT_H__
|
||||
|
||||
#include <glsym/glsym.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct glfft glfft_t;
|
||||
|
||||
glfft_t *glfft_new(unsigned fft_steps, rglgen_proc_address_t proc);
|
||||
|
||||
void glfft_free(glfft_t *fft);
|
||||
|
||||
void glfft_init_multisample(glfft_t *fft, unsigned width, unsigned height, unsigned samples);
|
||||
|
||||
void glfft_step_fft(glfft_t *fft, const GLshort *buffer, unsigned frames);
|
||||
void glfft_render(glfft_t *fft, GLuint backbuffer, unsigned width, unsigned height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
#include "shaders_common.h"
|
||||
|
||||
static const char *fft_fragment_program_blur = GLSL_300(
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
precision highp usampler2D;
|
||||
precision highp isampler2D;
|
||||
in vec2 vTex;
|
||||
out vec4 FragColor;
|
||||
uniform sampler2D sHeight;
|
||||
|
||||
void main() {
|
||||
float k = 0.0;
|
||||
float t;
|
||||
vec4 res = vec4(0.0);
|
||||
\n#define kernel(x, y) t = exp(-0.35 * float((x) * (x) + (y) * (y))); k += t; res += t * textureLodOffset(sHeight, vTex, 0.0, ivec2(x, y))\n
|
||||
kernel(-1, -2);
|
||||
kernel(-1, -1);
|
||||
kernel(-1, 0);
|
||||
kernel( 0, -2);
|
||||
kernel( 0, -1);
|
||||
kernel( 0, 0);
|
||||
kernel( 1, -2);
|
||||
kernel( 1, -1);
|
||||
kernel( 1, 0);
|
||||
FragColor = res / k;
|
||||
}
|
||||
);
|
||||
@@ -1,33 +0,0 @@
|
||||
#include "shaders_common.h"
|
||||
|
||||
static const char *fft_fragment_program_complex = GLSL_300(
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
precision highp usampler2D;
|
||||
precision highp isampler2D;
|
||||
|
||||
in vec2 vTex;
|
||||
uniform usampler2D sTexture;
|
||||
uniform usampler2D sParameterTexture;
|
||||
uniform int uViewportOffset;
|
||||
out uvec2 FragColor;
|
||||
|
||||
vec2 compMul(vec2 a, vec2 b) { return vec2(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); }
|
||||
|
||||
void main() {
|
||||
uvec2 params = texture(sParameterTexture, vec2(vTex.x, 0.5)).rg;
|
||||
uvec2 coord = uvec2((params.x >> 16u) & 0xffffu, params.x & 0xffffu);
|
||||
int ycoord = int(gl_FragCoord.y) - uViewportOffset;
|
||||
vec2 twiddle = unpackHalf2x16(params.y);
|
||||
|
||||
uvec2 x = texelFetch(sTexture, ivec2(int(coord.x), ycoord), 0).rg;
|
||||
uvec2 y = texelFetch(sTexture, ivec2(int(coord.y), ycoord), 0).rg;
|
||||
vec4 a = vec4(unpackHalf2x16(x.x), unpackHalf2x16(x.y));
|
||||
vec4 b = vec4(unpackHalf2x16(y.x), unpackHalf2x16(y.y));
|
||||
b.xy = compMul(b.xy, twiddle);
|
||||
b.zw = compMul(b.zw, twiddle);
|
||||
|
||||
vec4 res = a + b;
|
||||
FragColor = uvec2(packHalf2x16(res.xy), packHalf2x16(res.zw));
|
||||
}
|
||||
);
|
||||
@@ -1,40 +0,0 @@
|
||||
#include "shaders_common.h"
|
||||
|
||||
static const char *fft_fragment_program_real = GLSL_300(
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
precision highp usampler2D;
|
||||
precision highp isampler2D;
|
||||
|
||||
in vec2 vTex;
|
||||
uniform isampler2D sTexture;
|
||||
uniform usampler2D sParameterTexture;
|
||||
uniform usampler2D sWindow;
|
||||
uniform int uViewportOffset;
|
||||
out uvec2 FragColor;
|
||||
|
||||
vec2 compMul(vec2 a, vec2 b) { return vec2(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); }
|
||||
|
||||
void main() {
|
||||
uvec2 params = texture(sParameterTexture, vec2(vTex.x, 0.5)).rg;
|
||||
uvec2 coord = uvec2((params.x >> 16u) & 0xffffu, params.x & 0xffffu);
|
||||
int ycoord = int(gl_FragCoord.y) - uViewportOffset;
|
||||
vec2 twiddle = unpackHalf2x16(params.y);
|
||||
|
||||
float window_a = float(texelFetch(sWindow, ivec2(coord.x, 0), 0).r) / float(0x10000);
|
||||
float window_b = float(texelFetch(sWindow, ivec2(coord.y, 0), 0).r) / float(0x10000);
|
||||
|
||||
vec2 a = window_a * vec2(texelFetch(sTexture, ivec2(int(coord.x), ycoord), 0).rg) / vec2(0x8000);
|
||||
vec2 a_l = vec2(a.x, 0.0);
|
||||
vec2 a_r = vec2(a.y, 0.0);
|
||||
vec2 b = window_b * vec2(texelFetch(sTexture, ivec2(int(coord.y), ycoord), 0).rg) / vec2(0x8000);
|
||||
vec2 b_l = vec2(b.x, 0.0);
|
||||
vec2 b_r = vec2(b.y, 0.0);
|
||||
b_l = compMul(b_l, twiddle);
|
||||
b_r = compMul(b_r, twiddle);
|
||||
|
||||
vec2 res_l = a_l + b_l;
|
||||
vec2 res_r = a_r + b_r;
|
||||
FragColor = uvec2(packHalf2x16(res_l), packHalf2x16(res_r));
|
||||
}
|
||||
);
|
||||
@@ -1,30 +0,0 @@
|
||||
#include "shaders_common.h"
|
||||
|
||||
static const char *fft_fragment_program_resolve = GLSL_300(
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
precision highp usampler2D;
|
||||
precision highp isampler2D;
|
||||
in vec2 vTex;
|
||||
out vec4 FragColor;
|
||||
uniform usampler2D sFFT;
|
||||
|
||||
vec4 get_heights(highp uvec2 h) {
|
||||
vec2 l = unpackHalf2x16(h.x);
|
||||
vec2 r = unpackHalf2x16(h.y);
|
||||
vec2 channels[4] = vec2[4](
|
||||
l, 0.5 * (l + r), r, 0.5 * (l - r));
|
||||
vec4 amps;
|
||||
for (int i = 0; i < 4; i++)
|
||||
amps[i] = dot(channels[i], channels[i]);
|
||||
|
||||
return 9.0 * log(amps + 0.0001) - 22.0;
|
||||
}
|
||||
|
||||
void main() {
|
||||
uvec2 h = textureLod(sFFT, vTex, 0.0).rg;
|
||||
vec4 height = get_heights(h);
|
||||
height = (height + 40.0) / 80.0;
|
||||
FragColor = height;
|
||||
}
|
||||
);
|
||||
@@ -1,18 +0,0 @@
|
||||
#include "shaders_common.h"
|
||||
|
||||
static const char *fft_fragment_program_heightmap = GLSL_300(
|
||||
precision mediump float;
|
||||
out vec4 FragColor;
|
||||
in vec3 vWorldPos;
|
||||
in vec3 vHeight;
|
||||
|
||||
vec3 colormap(vec3 height) {
|
||||
return 1.0 / (1.0 + exp(-0.08 * height));
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec3 color = mix(vec3(1.0, 0.7, 0.7) * colormap(vHeight), vec3(0.1, 0.15, 0.1), clamp(vWorldPos.z / 400.0, 0.0, 1.0));
|
||||
color = mix(color, vec3(0.1, 0.15, 0.1), clamp(1.0 - vWorldPos.z / 2.0, 0.0, 1.0));
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
);
|
||||
@@ -1,43 +0,0 @@
|
||||
#include "shaders_common.h"
|
||||
|
||||
static const char *fft_vertex_program_heightmap = GLSL_300(
|
||||
layout(location = 0) in vec2 aVertex;
|
||||
uniform sampler2D sHeight;
|
||||
uniform mat4 uMVP;
|
||||
uniform ivec2 uOffset;
|
||||
uniform vec4 uHeightmapParams;
|
||||
uniform float uAngleScale;
|
||||
out vec3 vWorldPos;
|
||||
out vec3 vHeight;
|
||||
|
||||
void main() {
|
||||
vec2 tex_coord = vec2(aVertex.x + float(uOffset.x) + 0.5, -aVertex.y + float(uOffset.y) + 0.5) / vec2(textureSize(sHeight, 0));
|
||||
|
||||
vec3 world_pos = vec3(aVertex.x, 0.0, aVertex.y);
|
||||
world_pos.xz += uHeightmapParams.xy;
|
||||
|
||||
float angle = world_pos.x * uAngleScale;
|
||||
world_pos.xz *= uHeightmapParams.zw;
|
||||
|
||||
float lod = log2(world_pos.z + 1.0) - 6.0;
|
||||
vec4 heights = textureLod(sHeight, tex_coord, lod);
|
||||
|
||||
float cangle = cos(angle);
|
||||
float sangle = sin(angle);
|
||||
|
||||
int c = int(-sign(world_pos.x) + 1.0);
|
||||
float height = mix(heights[c], heights[1], abs(angle) / 3.141592653);
|
||||
height = height * 80.0 - 40.0;
|
||||
|
||||
vec3 up = vec3(-sangle, cangle, 0.0);
|
||||
|
||||
float base_y = 80.0 - 80.0 * cangle;
|
||||
float base_x = 80.0 * sangle;
|
||||
world_pos.xy = vec2(base_x, base_y);
|
||||
world_pos += up * height;
|
||||
|
||||
vWorldPos = world_pos;
|
||||
vHeight = vec3(height, heights.yw * 80.0 - 40.0);
|
||||
gl_Position = uMVP * vec4(world_pos, 1.0);
|
||||
}
|
||||
);
|
||||
@@ -1,13 +0,0 @@
|
||||
#include "shaders_common.h"
|
||||
|
||||
static const char *fft_vertex_program = GLSL_300(
|
||||
precision mediump float;
|
||||
layout(location = 0) in vec2 aVertex;
|
||||
layout(location = 1) in vec2 aTexCoord;
|
||||
uniform vec4 uOffsetScale;
|
||||
out vec2 vTex;
|
||||
void main() {
|
||||
vTex = uOffsetScale.xy + aTexCoord * uOffsetScale.zw;
|
||||
gl_Position = vec4(aVertex, 0.0, 1.0);
|
||||
}
|
||||
);
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef _SHADERS_COMMON
|
||||
#define _SHADERS_COMMON
|
||||
|
||||
#if defined(HAVE_OPENGLES)
|
||||
#define CG(src) "" #src
|
||||
#define GLSL(src) "precision mediump float;\n" #src
|
||||
#define GLSL_300(src) "#version 300 es\n" #src
|
||||
#else
|
||||
#define CG(src) "" #src
|
||||
#define GLSL(src) "" #src
|
||||
#define GLSL_300(src) "#version 300 es\n" #src
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../libretro.h"
|
||||
@@ -5,41 +5,29 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include <boolean.h>
|
||||
#include <lists/dir_list.h>
|
||||
#include <file/dir_list.h>
|
||||
#include <file/file_path.h>
|
||||
#include <compat/strl.h>
|
||||
|
||||
#if 0
|
||||
#define HAVE_STB_IMAGE
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STB_IMAGE
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
|
||||
#if 0
|
||||
#ifdef RARCH_INTERNAL
|
||||
#define STBI_NO_PSD
|
||||
#define STBI_NO_GIF
|
||||
#define STBI_NO_HDR
|
||||
#define STBI_NO_PIC
|
||||
#define STBI_NO_PNM
|
||||
#endif
|
||||
#define STBI_SUPPORT_ZLIB
|
||||
#endif
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
#include "../../deps/stb/stb_image.h"
|
||||
#else
|
||||
#include <stb_image.h>
|
||||
#endif
|
||||
#else
|
||||
#include <formats/image.h>
|
||||
#endif
|
||||
|
||||
#include <libretro.h>
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
#include "internal_cores.h"
|
||||
#include "../../libretro.h"
|
||||
#define IMAGE_CORE_PREFIX(s) libretro_imageviewer_##s
|
||||
#else
|
||||
#include "libretro.h"
|
||||
#define IMAGE_CORE_PREFIX(s) s
|
||||
#endif
|
||||
|
||||
@@ -52,9 +40,6 @@ static retro_environment_t IMAGE_CORE_PREFIX(environ_cb);
|
||||
|
||||
static bool process_new_image;
|
||||
static uint32_t* image_buffer;
|
||||
#ifndef HAVE_STB_IMAGE
|
||||
static struct texture_image image_texture;
|
||||
#endif
|
||||
static int image_width;
|
||||
static int image_height;
|
||||
static bool image_uploaded;
|
||||
@@ -65,10 +50,10 @@ struct string_list *file_list;
|
||||
#define DUPE_TEST
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STB_IMAGE
|
||||
static const char* IMAGE_CORE_PREFIX(valid_extensions) = "jpg|jpeg|png|bmp|psd|tga|gif|hdr|pic|ppm|pgm";
|
||||
#else
|
||||
#ifdef RARCH_INTERNAL
|
||||
static const char* IMAGE_CORE_PREFIX(valid_extensions) = "jpg|jpeg|png|bmp|tga";
|
||||
#else
|
||||
static const char* IMAGE_CORE_PREFIX(valid_extensions) = "jpg|jpeg|png|bmp|psd|tga|gif|hdr|pic|ppm|pgm";
|
||||
#endif
|
||||
|
||||
void IMAGE_CORE_PREFIX(retro_get_system_info)(struct retro_system_info *info)
|
||||
@@ -91,13 +76,6 @@ void IMAGE_CORE_PREFIX(retro_get_system_av_info)(struct retro_system_av_info *in
|
||||
info->timing.sample_rate = 44100.0;
|
||||
}
|
||||
|
||||
static void imageviewer_reset(void)
|
||||
{
|
||||
image_buffer = NULL;
|
||||
image_width = 0;
|
||||
image_height = 0;
|
||||
}
|
||||
|
||||
void IMAGE_CORE_PREFIX(retro_init)(void)
|
||||
{
|
||||
struct retro_log_callback log;
|
||||
@@ -107,25 +85,19 @@ void IMAGE_CORE_PREFIX(retro_init)(void)
|
||||
else
|
||||
IMAGE_CORE_PREFIX(log_cb) = NULL;
|
||||
|
||||
imageviewer_reset();
|
||||
|
||||
}
|
||||
|
||||
static void imageviewer_free_image(void)
|
||||
{
|
||||
#ifdef HAVE_STB_IMAGE
|
||||
if (image_buffer)
|
||||
free(image_buffer);
|
||||
#else
|
||||
image_texture_free(&image_texture);
|
||||
#endif
|
||||
image_buffer = NULL;
|
||||
image_width = 0;
|
||||
image_height = 0;
|
||||
|
||||
}
|
||||
|
||||
void IMAGE_CORE_PREFIX(retro_deinit)(void)
|
||||
{
|
||||
imageviewer_free_image();
|
||||
imageviewer_reset();
|
||||
if (image_buffer)
|
||||
free(image_buffer);
|
||||
image_buffer = NULL;
|
||||
image_width = 0;
|
||||
image_height = 0;
|
||||
}
|
||||
|
||||
void IMAGE_CORE_PREFIX(retro_set_environment)(retro_environment_t cb)
|
||||
@@ -202,24 +174,16 @@ void IMAGE_CORE_PREFIX(retro_cheat_set)(unsigned a, bool b, const char * c)
|
||||
static bool imageviewer_load(const char *path, int image_index)
|
||||
{
|
||||
int comp;
|
||||
|
||||
imageviewer_free_image();
|
||||
|
||||
(void)comp;
|
||||
#ifdef HAVE_STB_IMAGE
|
||||
if (image_buffer)
|
||||
free(image_buffer);
|
||||
|
||||
image_buffer = (uint32_t*)stbi_load(
|
||||
path,
|
||||
&image_width,
|
||||
&image_height,
|
||||
&comp,
|
||||
4);
|
||||
#else
|
||||
if (!image_texture_load(&image_texture, path))
|
||||
return false;
|
||||
image_buffer = (uint32_t*)image_texture.pixels;
|
||||
image_width = image_texture.width;
|
||||
image_height = image_texture.height;
|
||||
#endif
|
||||
|
||||
if (!image_buffer)
|
||||
return false;
|
||||
|
||||
@@ -262,10 +226,11 @@ bool IMAGE_CORE_PREFIX(retro_load_game_special)(unsigned a, const struct retro_g
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void IMAGE_CORE_PREFIX(retro_unload_game)(void)
|
||||
{
|
||||
imageviewer_free_image();
|
||||
if (image_buffer)
|
||||
free(image_buffer);
|
||||
image_buffer = NULL;
|
||||
image_width = 0;
|
||||
image_height = 0;
|
||||
}
|
||||
@@ -395,36 +360,15 @@ void IMAGE_CORE_PREFIX(retro_run)(void)
|
||||
{
|
||||
/* RGBA > XRGB8888 */
|
||||
struct retro_system_av_info info;
|
||||
|
||||
#ifdef HAVE_STB_IMAGE
|
||||
int x, y;
|
||||
uint32_t *buf = &image_buffer[0];
|
||||
uint32_t *end = buf + (image_width*image_height*sizeof(uint32_t))/4;
|
||||
|
||||
for (y = 0; y < image_height; y++)
|
||||
while(buf < end)
|
||||
{
|
||||
for (x = 0; x < image_width; x++, buf++)
|
||||
{
|
||||
uint32_t pixel = *buf;
|
||||
uint32_t a = pixel >> 24;
|
||||
|
||||
if (a == 255)
|
||||
*buf = (pixel & 0x0000ff00) | ((pixel << 16) & 0x00ff0000) | ((pixel >> 16) & 0x000000ff);
|
||||
else
|
||||
{
|
||||
uint32_t r = pixel & 0x0000ff;
|
||||
uint32_t g = (pixel & 0x00ff00) >> 8;
|
||||
uint32_t b = (pixel & 0xff0000) >> 16;
|
||||
uint32_t bg = ((x & 8) ^ (y & 8)) ? 0x66 : 0x99;
|
||||
|
||||
r = a * r / 255 + (255 - a) * bg / 255;
|
||||
g = a * g / 255 + (255 - a) * bg / 255;
|
||||
b = a * b / 255 + (255 - a) * bg / 255;
|
||||
|
||||
*buf = r << 16 | g << 8 | b;
|
||||
}
|
||||
}
|
||||
uint32_t pixel = *buf;
|
||||
*buf = (pixel & 0xff00ff00) | ((pixel << 16) & 0x00ff0000) | ((pixel >> 16) & 0xff);
|
||||
buf++;
|
||||
}
|
||||
#endif
|
||||
|
||||
IMAGE_CORE_PREFIX(retro_get_system_av_info)(&info);
|
||||
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
STATIC_LINKING := 0
|
||||
AR := ar
|
||||
|
||||
ifeq ($(platform),)
|
||||
platform = unix
|
||||
ifeq ($(shell uname -a),)
|
||||
platform = win
|
||||
else ifneq ($(findstring MINGW,$(shell uname -a)),)
|
||||
platform = win
|
||||
else ifneq ($(findstring Darwin,$(shell uname -a)),)
|
||||
platform = osx
|
||||
else ifneq ($(findstring win,$(shell uname -a)),)
|
||||
platform = win
|
||||
endif
|
||||
endif
|
||||
|
||||
# system platform
|
||||
system_platform = unix
|
||||
ifeq ($(shell uname -a),)
|
||||
EXE_EXT = .exe
|
||||
system_platform = win
|
||||
else ifneq ($(findstring Darwin,$(shell uname -a)),)
|
||||
system_platform = osx
|
||||
arch = intel
|
||||
ifeq ($(shell uname -p),powerpc)
|
||||
arch = ppc
|
||||
endif
|
||||
else ifneq ($(findstring MINGW,$(shell uname -a)),)
|
||||
system_platform = win
|
||||
endif
|
||||
|
||||
TARGET_NAME := retropad
|
||||
LIBM = -lm
|
||||
|
||||
ifeq ($(ARCHFLAGS),)
|
||||
ifeq ($(archs),ppc)
|
||||
ARCHFLAGS = -arch ppc -arch ppc64
|
||||
else
|
||||
ARCHFLAGS = -arch i386 -arch x86_64
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(platform), osx)
|
||||
ifndef ($(NOUNIVERSAL))
|
||||
CFLAGS += $(ARCHFLAGS)
|
||||
LFLAGS += $(ARCHFLAGS)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(STATIC_LINKING), 1)
|
||||
EXT := a
|
||||
endif
|
||||
|
||||
ifeq ($(platform), unix)
|
||||
EXT ?= so
|
||||
TARGET := $(TARGET_NAME)_libretro.$(EXT)
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
else ifeq ($(platform), linux-portable)
|
||||
TARGET := $(TARGET_NAME)_libretro.$(EXT)
|
||||
fpic := -fPIC -nostdlib
|
||||
SHARED := -shared -Wl,--version-script=link.T
|
||||
LIBM :=
|
||||
else ifneq (,$(findstring osx,$(platform)))
|
||||
TARGET := $(TARGET_NAME)_libretro.dylib
|
||||
fpic := -fPIC
|
||||
SHARED := -dynamiclib
|
||||
else ifneq (,$(findstring ios,$(platform)))
|
||||
TARGET := $(TARGET_NAME)_libretro_ios.dylib
|
||||
fpic := -fPIC
|
||||
SHARED := -dynamiclib
|
||||
|
||||
ifeq ($(IOSSDK),)
|
||||
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
|
||||
endif
|
||||
|
||||
DEFINES := -DIOS
|
||||
CC = cc -arch armv7 -isysroot $(IOSSDK)
|
||||
ifeq ($(platform),ios9)
|
||||
CC += -miphoneos-version-min=8.0
|
||||
CFLAGS += -miphoneos-version-min=8.0
|
||||
else
|
||||
CC += -miphoneos-version-min=5.0
|
||||
CFLAGS += -miphoneos-version-min=5.0
|
||||
endif
|
||||
else ifneq (,$(findstring qnx,$(platform)))
|
||||
TARGET := $(TARGET_NAME)_libretro_qnx.so
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
else ifeq ($(platform), emscripten)
|
||||
TARGET := $(TARGET_NAME)_libretro_emscripten.bc
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
else ifeq ($(platform), vita)
|
||||
TARGET := $(TARGET_NAME)_vita.a
|
||||
CC = arm-vita-eabi-gcc
|
||||
AR = arm-vita-eabi-ar
|
||||
CFLAGS += -Wl,-q -Wall -O3
|
||||
STATIC_LINKING = 1
|
||||
else
|
||||
CC = gcc
|
||||
TARGET := $(TARGET_NAME)_libretro.dll
|
||||
SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
endif
|
||||
|
||||
|
||||
LDFLAGS += $(LIBM)
|
||||
|
||||
ifeq ($(platform), win)
|
||||
LDFLAGS += -lws2_32
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -O0 -g
|
||||
else
|
||||
CFLAGS += -O3
|
||||
endif
|
||||
|
||||
OBJECTS := ../../libretro-common/net/net_compat.o \
|
||||
../../libretro-common/net/net_socket.o \
|
||||
net_retropad_core.o
|
||||
|
||||
CFLAGS += -I../../libretro-common/include -Wall -pedantic $(fpic)
|
||||
|
||||
ifneq (,$(findstring qnx,$(platform)))
|
||||
CFLAGS += -Wc,-std=c99
|
||||
else
|
||||
CFLAGS += -std=gnu99
|
||||
endif
|
||||
|
||||
CFLAGS += -I../../libretro-common/include
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
ifeq ($(STATIC_LINKING), 1)
|
||||
$(AR) rcs $@ $(OBJECTS)
|
||||
else
|
||||
$(CC) $(fpic) $(SHARED) $(INCLUDES) -o $@ $(OBJECTS) $(LDFLAGS)
|
||||
endif
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f $(OBJECTS) $(TARGET)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
#include "../internal_cores.h"
|
||||
@@ -1,25 +0,0 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
APP_DIR := ../../src
|
||||
|
||||
LOCAL_MODULE := retro
|
||||
|
||||
ifeq ($(TARGET_ARCH),arm)
|
||||
LOCAL_CFLAGS += -DANDROID_ARM
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),x86)
|
||||
LOCAL_CFLAGS += -DANDROID_X86
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),mips)
|
||||
LOCAL_CFLAGS += -DANDROID_MIPS -D__mips__ -D__MIPSEL__
|
||||
endif
|
||||
|
||||
LOCAL_SRC_FILES += ../libretro-test.c
|
||||
LOCAL_CFLAGS += -O3 -std=gnu99 -ffast-math -funroll-loops
|
||||
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
@@ -1 +0,0 @@
|
||||
APP_ABI := all
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
global: retro_*;
|
||||
local: *;
|
||||
};
|
||||
|
||||
@@ -1,323 +0,0 @@
|
||||
/*
|
||||
* To-do:
|
||||
* - Analog support
|
||||
* - Some sort of connection control, it only sends packets
|
||||
* but there is no acknoledgement of a connection o keepalives
|
||||
* - Send player name
|
||||
* - Render something on-screen maybe a gui to configure IP and port
|
||||
instead of the ridiculously long strings we're using now
|
||||
* - Allow changing IP address and port in runtime
|
||||
* - Support other platforms
|
||||
* - Input recording / Combos
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <net/net_compat.h>
|
||||
#include <net/net_socket.h>
|
||||
|
||||
#include <retro_miscellaneous.h>
|
||||
|
||||
#include <libretro.h>
|
||||
|
||||
#ifndef SOCKET_ERROR
|
||||
#define SOCKET_ERROR -1
|
||||
#endif
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
#include "internal_cores.h"
|
||||
#define NETRETROPAD_CORE_PREFIX(s) libretro_netretropad_##s
|
||||
#else
|
||||
#define NETRETROPAD_CORE_PREFIX(s) s
|
||||
#endif
|
||||
|
||||
static int s;
|
||||
static int port;
|
||||
static char server[64];
|
||||
static struct sockaddr_in si_other;
|
||||
|
||||
static struct retro_log_callback logger;
|
||||
|
||||
static retro_log_printf_t NETRETROPAD_CORE_PREFIX(log_cb);
|
||||
static retro_video_refresh_t NETRETROPAD_CORE_PREFIX(video_cb);
|
||||
static retro_audio_sample_t NETRETROPAD_CORE_PREFIX(audio_cb);
|
||||
static retro_audio_sample_batch_t NETRETROPAD_CORE_PREFIX(audio_batch_cb);
|
||||
static retro_environment_t NETRETROPAD_CORE_PREFIX(environ_cb);
|
||||
static retro_input_poll_t NETRETROPAD_CORE_PREFIX(input_poll_cb);
|
||||
static retro_input_state_t NETRETROPAD_CORE_PREFIX(input_state_cb);
|
||||
|
||||
static uint16_t *frame_buf;
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_init)(void)
|
||||
{
|
||||
frame_buf = (uint16_t*)calloc(320 * 240, sizeof(uint16_t));
|
||||
|
||||
NETRETROPAD_CORE_PREFIX(log_cb)(RETRO_LOG_INFO, "Initialising sockets...\n");
|
||||
network_init();
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_deinit)(void)
|
||||
{
|
||||
if (frame_buf)
|
||||
free(frame_buf);
|
||||
frame_buf = NULL;
|
||||
}
|
||||
|
||||
unsigned NETRETROPAD_CORE_PREFIX(retro_api_version)(void)
|
||||
{
|
||||
return RETRO_API_VERSION;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_set_controller_port_device)(
|
||||
unsigned port, unsigned device)
|
||||
{
|
||||
(void)port;
|
||||
(void)device;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_get_system_info)(
|
||||
struct retro_system_info *info)
|
||||
{
|
||||
memset(info, 0, sizeof(*info));
|
||||
info->library_name = "RetroPad Remote";
|
||||
info->library_version = "0.01";
|
||||
info->need_fullpath = false;
|
||||
info->valid_extensions = ""; /* Nothing. */
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_get_system_av_info)(
|
||||
struct retro_system_av_info *info)
|
||||
{
|
||||
info->timing.fps = 60.0;
|
||||
info->timing.sample_rate = 30000.0;
|
||||
|
||||
info->geometry.base_width = 320;
|
||||
info->geometry.base_height = 240;
|
||||
info->geometry.max_width = 320;
|
||||
info->geometry.max_height = 240;
|
||||
info->geometry.aspect_ratio = 4.0 / 3.0;
|
||||
}
|
||||
|
||||
|
||||
static unsigned retropad_update_input(void)
|
||||
{
|
||||
unsigned value = 0;
|
||||
NETRETROPAD_CORE_PREFIX(input_poll_cb)();
|
||||
|
||||
if (NETRETROPAD_CORE_PREFIX(input_state_cb)(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B))
|
||||
value += 1;
|
||||
if (NETRETROPAD_CORE_PREFIX(input_state_cb)(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y))
|
||||
value += 2;
|
||||
if (NETRETROPAD_CORE_PREFIX(input_state_cb)(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT))
|
||||
value += pow(2, 2);
|
||||
if (NETRETROPAD_CORE_PREFIX(input_state_cb)(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START))
|
||||
value += pow(2, 3);
|
||||
if (NETRETROPAD_CORE_PREFIX(input_state_cb)(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP))
|
||||
value += pow(2, 4);
|
||||
if (NETRETROPAD_CORE_PREFIX(input_state_cb)(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN))
|
||||
value += pow(2, 5);
|
||||
if (NETRETROPAD_CORE_PREFIX(input_state_cb)(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT))
|
||||
value += pow(2, 6);
|
||||
if (NETRETROPAD_CORE_PREFIX(input_state_cb)(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT))
|
||||
value += pow(2, 7);
|
||||
if (NETRETROPAD_CORE_PREFIX(input_state_cb)(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A))
|
||||
value += pow(2, 8);
|
||||
if (NETRETROPAD_CORE_PREFIX(input_state_cb)(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X))
|
||||
value += pow(2, 9);
|
||||
if (NETRETROPAD_CORE_PREFIX(input_state_cb)(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L))
|
||||
value += pow(2, 10);
|
||||
if (NETRETROPAD_CORE_PREFIX(input_state_cb)(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R))
|
||||
value += pow(2, 11);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_set_environment)(retro_environment_t cb)
|
||||
{
|
||||
static const struct retro_variable vars[] = {
|
||||
{ "net_retropad_port", "Port; 55400|55401|55402|55403|55404|55405|55406|55407|55408|55409|55410|55411|55412|55413|55414|55415|55416|55417|55418|55419|55420" },
|
||||
{ "net_retropad_ip_octet1", "IP address part 1; 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|134|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|234|235|236|237|238|239|240|241|242|243|244|245|246|247|248|249|250|251|252|253|254|255" },
|
||||
{ "net_retropad_ip_octet2", "IP address part 2; 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|134|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|234|235|236|237|238|239|240|241|242|243|244|245|246|247|248|249|250|251|252|253|254|255" },
|
||||
{ "net_retropad_ip_octet3", "IP address part 3; 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|134|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|234|235|236|237|238|239|240|241|242|243|244|245|246|247|248|249|250|251|252|253|254|255" },
|
||||
{ "net_retropad_ip_octet4", "IP address part 4; 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|134|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|234|235|236|237|238|239|240|241|242|243|244|245|246|247|248|249|250|251|252|253|254|255" },
|
||||
|
||||
{ NULL, NULL },
|
||||
};
|
||||
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
|
||||
cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars);
|
||||
|
||||
|
||||
NETRETROPAD_CORE_PREFIX(environ_cb) = cb;
|
||||
bool no_content = true;
|
||||
cb(RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME, &no_content);
|
||||
|
||||
NETRETROPAD_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt);
|
||||
|
||||
if (cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &logger))
|
||||
NETRETROPAD_CORE_PREFIX(log_cb) = logger.log;
|
||||
}
|
||||
|
||||
static void netretropad_check_variables(void)
|
||||
{
|
||||
struct retro_variable var, var2, var3, var4, port_var;
|
||||
var.key = "net_retropad_ip_octet1";
|
||||
var2.key = "net_retropad_ip_octet2";
|
||||
var3.key = "net_retropad_ip_octet3";
|
||||
var4.key = "net_retropad_ip_octet4";
|
||||
port_var.key = "net_retropad_port";
|
||||
|
||||
NETRETROPAD_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
|
||||
NETRETROPAD_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &var2);
|
||||
NETRETROPAD_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &var3);
|
||||
NETRETROPAD_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &var4);
|
||||
NETRETROPAD_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &port_var);
|
||||
|
||||
snprintf(server, sizeof(server), "%s.%s.%s.%s", var.value, var2.value, var3.value, var4.value);
|
||||
port = atoi(port_var.value);
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_set_audio_sample)(retro_audio_sample_t cb)
|
||||
{
|
||||
NETRETROPAD_CORE_PREFIX(audio_cb) = cb;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_set_audio_sample_batch)(
|
||||
retro_audio_sample_batch_t cb)
|
||||
{
|
||||
NETRETROPAD_CORE_PREFIX(audio_batch_cb) = cb;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_set_input_poll)(retro_input_poll_t cb)
|
||||
{
|
||||
NETRETROPAD_CORE_PREFIX(input_poll_cb) = cb;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_set_input_state)(retro_input_state_t cb)
|
||||
{
|
||||
NETRETROPAD_CORE_PREFIX(input_state_cb) = cb;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_set_video_refresh)(retro_video_refresh_t cb)
|
||||
{
|
||||
NETRETROPAD_CORE_PREFIX(video_cb) = cb;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_reset)(void)
|
||||
{}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_run)(void)
|
||||
{
|
||||
unsigned i;
|
||||
char message[64];
|
||||
unsigned input_state = retropad_update_input();
|
||||
|
||||
if (input_state > 0)
|
||||
{
|
||||
snprintf(message, sizeof(message), "%d", input_state);
|
||||
|
||||
/* send the message */
|
||||
if (sendto(s, message, strlen(message) , 0 , (struct sockaddr *) &si_other, sizeof(si_other))==-1)
|
||||
NETRETROPAD_CORE_PREFIX(log_cb)(RETRO_LOG_INFO, "Error sending data\n");
|
||||
}
|
||||
for (i = 0; i < 320 * 240; i++)
|
||||
frame_buf[i] = 4 << 5;
|
||||
NETRETROPAD_CORE_PREFIX(video_cb)(frame_buf, 320, 240, 640);
|
||||
|
||||
retro_sleep(4);
|
||||
}
|
||||
|
||||
bool NETRETROPAD_CORE_PREFIX(retro_load_game)(const struct retro_game_info *info)
|
||||
{
|
||||
socket_target_t in_target;
|
||||
|
||||
netretropad_check_variables();
|
||||
|
||||
s = socket_create(
|
||||
"retropad",
|
||||
SOCKET_DOMAIN_INET,
|
||||
SOCKET_TYPE_DATAGRAM,
|
||||
SOCKET_PROTOCOL_UDP);
|
||||
|
||||
if (s == SOCKET_ERROR)
|
||||
NETRETROPAD_CORE_PREFIX(log_cb)(RETRO_LOG_INFO, "socket failed");
|
||||
|
||||
/* setup address structure */
|
||||
memset((char *) &si_other, 0, sizeof(si_other));
|
||||
|
||||
in_target.port = port;
|
||||
in_target.server = server;
|
||||
in_target.domain = SOCKET_DOMAIN_INET;
|
||||
|
||||
socket_set_target(&si_other, &in_target);
|
||||
|
||||
NETRETROPAD_CORE_PREFIX(log_cb)(RETRO_LOG_INFO, "Server IP Address: %s\n" , server);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_unload_game)(void)
|
||||
{}
|
||||
|
||||
unsigned NETRETROPAD_CORE_PREFIX(retro_get_region)(void)
|
||||
{
|
||||
return RETRO_REGION_NTSC;
|
||||
}
|
||||
|
||||
bool NETRETROPAD_CORE_PREFIX(retro_load_game_special)(unsigned type,
|
||||
const struct retro_game_info *info, size_t num)
|
||||
{
|
||||
(void)type;
|
||||
(void)info;
|
||||
(void)num;
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t NETRETROPAD_CORE_PREFIX(retro_serialize_size)(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool NETRETROPAD_CORE_PREFIX(retro_serialize)(void *data, size_t size)
|
||||
{
|
||||
(void)data;
|
||||
(void)size;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NETRETROPAD_CORE_PREFIX(retro_unserialize)(const void *data,
|
||||
size_t size)
|
||||
{
|
||||
(void)data;
|
||||
(void)size;
|
||||
return false;
|
||||
}
|
||||
|
||||
void *NETRETROPAD_CORE_PREFIX(retro_get_memory_data)(unsigned id)
|
||||
{
|
||||
(void)id;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t NETRETROPAD_CORE_PREFIX(retro_get_memory_size)(unsigned id)
|
||||
{
|
||||
(void)id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_cheat_reset)(void)
|
||||
{}
|
||||
|
||||
void NETRETROPAD_CORE_PREFIX(retro_cheat_set)(unsigned idx,
|
||||
bool enabled, const char *code)
|
||||
{
|
||||
(void)idx;
|
||||
(void)enabled;
|
||||
(void)code;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <glsym/glsym.h>
|
||||
|
||||
#include <libretro.h>
|
||||
#include "../../libretro.h"
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
static struct retro_hw_render_callback hw_render;
|
||||
|
||||
Loaded 100 of 1002 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user