diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 680d9af831..0000000000 --- a/AUTHORS +++ /dev/null @@ -1,73 +0,0 @@ -Hans-Kristian Arntzen - - - Main code - - Initial Gamecube/Wii libogc port - -Daniel De Matteis - - - Maintainer - - Main code - -Devin J. Pohly - - - Joypad axis support - -Chris Moeller - - - CoreAudio audio driver - -Tobias Jakobi - - - OMAP graphics driver - -Jason Fetters - - - Phoenix Java frontend - - Android port patches - - iOS port - -CatalystG - - - Blackberry 10/Playbook input driver - - Blackberry 10/Playbook patches - -David Reichelt - - - XBox 1 port - -tukuyomi - - - Cleanups in quickbuild - -Michael Lelli - - - Gamecube/Wii libogc port - - Raspberry Pi video driver - - Linux Raw keyboard input driver - - Android port patches - -Ali Bouhlel - - - PSP port - - Convoluted Cosine resampler - -Darren Alton - - - OpenPandora port - -Fabian Knopf - - - WGL multi-monitor support - - D3D9 overlay, multi-monitor and menu support - -Gražvydas Ignotas - - - ARM Linux patches - -Saggi Mizrahi - - - RetroLaunch utility - -Alfred Agrell - - - Rewritten savestate manager - -Jean-André Santoni - - - Lakka menu driver - -Morgane Alonso - - - Lakka menu driver (graphic design) - -Timo Strunk - - - 7zip support - -Higor Euripedes - - - SDL2 drivers - -Jay McCarthy - - - CoreText font driver - - (Apple) CFRunLoop improvements diff --git a/Makefile b/Makefile index 87cf109705..5078e6bb3f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ HAVE_FILE_LOGGER=1 +MISSING_DECLS =0 include config.mk @@ -23,8 +24,16 @@ endif include Makefile.common +ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang"),1) + DEFINES += -Wno-invalid-source-encoding +endif + HEADERS = $(wildcard */*/*.h) $(wildcard */*.h) $(wildcard *.h) +ifeq ($(MISSING_DECLS), 1) + DEFINES += -Werror=missing-declarations +endif + ifeq ($(HAVE_DYLIB), 1) LIBS += $(DYLIB_LIB) endif @@ -46,7 +55,7 @@ else endif CFLAGS += -Wall $(OPTIMIZE_FLAG) $(INCLUDE_DIRS) $(DEBUG_FLAG) -I. -CXXFLAGS := $(CFLAGS) -std=c++0x -D__STDC_CONSTANT_MACROS +CXXFLAGS := $(CFLAGS) -std=c++98 -D__STDC_CONSTANT_MACROS OBJCFLAGS := $(CFLAGS) -D__STDC_CONSTANT_MACROS ifeq ($(CXX_BUILD), 1) @@ -158,16 +167,17 @@ install: $(TARGET) rm -f $(OBJDIR)/git_version.o 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/man/man1 2>/dev/null || /bin/true + mkdir -p $(DESTDIR)$(PREFIX)/share/applications 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 -m755 $(JTARGET) $(DESTDIR)$(PREFIX)/bin install -m644 retroarch.cfg $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg + install -m644 retroarch.desktop $(DESTDIR)$(PREFIX)/share/applications install -m644 docs/retroarch.1 $(DESTDIR)$(MAN_DIR) install -m644 docs/retroarch-cg2glsl.1 $(DESTDIR)$(MAN_DIR) install -m644 docs/retroarch-joyconfig.1 $(DESTDIR)$(MAN_DIR) - install -m644 media/retroarch.png $(DESTDIR)$(PREFIX)/share/pixmaps install -m644 media/retroarch.svg $(DESTDIR)$(PREFIX)/share/pixmaps uninstall: @@ -175,10 +185,10 @@ uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/retroarch-joyconfig rm -f $(DESTDIR)$(PREFIX)/bin/retroarch-cg2glsl rm -f $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg - rm -f $(DESTDIR)$(PREFIX)/share/man/man1/retroarch.1 - rm -f $(DESTDIR)$(PREFIX)/share/man/man1/retroarch-cg2glsl.1 - rm -f $(DESTDIR)$(PREFIX)/share/man/man1/retroarch-joyconfig.1 - rm -f $(DESTDIR)$(PREFIX)/share/pixmaps/retroarch.png + rm -f $(DESTDIR)$(PREFIX)/share/applications/retroarch.desktop + rm -f $(DESTDIR)$(MAN_DIR)/retroarch.1 + rm -f $(DESTDIR)$(MAN_DIR)/retroarch-cg2glsl.1 + rm -f $(DESTDIR)$(MAN_DIR)/retroarch-joyconfig.1 rm -f $(DESTDIR)$(PREFIX)/share/pixmaps/retroarch.svg clean: diff --git a/Makefile.common b/Makefile.common index 37f8920246..74bb2d092c 100644 --- a/Makefile.common +++ b/Makefile.common @@ -130,8 +130,10 @@ OBJ += frontend/frontend.o \ content.o \ libretro-common/file/file_list.o \ libretro-common/file/dir_list.o \ + libretro-common/file/retro_dirent.o \ libretro-common/string/string_list.o \ libretro-common/string/stdstring.o \ + libretro-common/memmap/memalign.o \ dir_list_special.o \ file_ops.o \ libretro-common/file/nbio/nbio_stdio.o \ @@ -209,19 +211,21 @@ OBJ += frontend/frontend.o \ OBJ += gfx/image/image.o ifneq ($(C89_BUILD), 1) -# stb_image is not a C89-compliant API. +ifneq ($(C90_BUILD), 1) +# stb_image is not a C89/C90-compliant API. ifeq ($(HAVE_IMAGEVIEWER), 1) DEFINES += -DHAVE_IMAGEVIEWER OBJ += cores/image_core.o endif endif +endif # Qt ifeq ($(HAVE_QT), 1) OBJ += ui/drivers/ui_qt.o # TODO/FIXME - figure out which libraries we need to link against -LIBS += -lQt5Quick -lQt5Widgets -lQt5Gui -lQt5Qml -lQt5Network -lQt5Core -lglu32 -lopengl32 -L./ui/drivers/qt/release -lwrapper +LIBS += -lQt5Quick -lQt5Widgets -lQt5Gui -lQt5Qml -lQt5Network -lQt5Core -lglu32 -lopengl32 -L./ui/drivers/qt/wrapper/build/release -lwrapper endif # LibretroDB @@ -243,16 +247,14 @@ ifeq ($(HAVE_STDIN_CMD), 1) endif ifneq ($(C89_BUILD), 1) -# Python 3.x bindings are not C89-compliant. +ifneq ($(C90_BUILD), 1) +# Python 3.x bindings are not C89/C90-compliant. ifeq ($(HAVE_PYTHON), 1) DEFINES += $(PYTHON_CFLAGS) -Wno-unused-parameter LIBS += $(PYTHON_LIBS) OBJ += gfx/video_state_python.o endif endif - -ifeq ($(OSX), 1) - DEFINES += -Wno-invalid-source-encoding endif ifeq ($(HAVE_EMSCRIPTEN), 1) @@ -314,13 +316,15 @@ ifeq ($(HAVE_JACK),1) endif ifneq ($(C89_BUILD), 1) -# PulseAudio is not a C89-compliant API. +ifneq ($(C90_BUILD), 1) +# PulseAudio is not a C89/C90-compliant API. ifeq ($(HAVE_PULSE), 1) OBJ += audio/drivers/pulse.o LIBS += $(PULSE_LIBS) DEFINES += $(PULSE_CFLAGS) endif endif +endif ifeq ($(HAVE_OSS_LIB), 1) LIBS += -lossaudio @@ -392,6 +396,11 @@ endif endif ifeq ($(HAVE_MENU_COMMON), 1) + ifeq ($(PSEUDOLOC), 1) + PSEUDO_NS := pseudo + else + PSEUDO_NS := + endif OBJ += menu/menu.o \ menu/menu_hash.o \ menu/intl/menu_hash_de.o \ @@ -402,7 +411,7 @@ ifeq ($(HAVE_MENU_COMMON), 1) menu/intl/menu_hash_nl.o \ menu/intl/menu_hash_pl.o \ menu/intl/menu_hash_pt.o \ - menu/intl/menu_hash_us.o \ + menu/intl/menu_hash_us$(PSEUDO_NS).o \ menu/menu_input.o \ menu/menu_entry.o \ menu/menu_entries.o \ @@ -422,7 +431,7 @@ 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_iterate.o \ + menu/menu_iterate.o \ menu/cbs/menu_cbs_title.o \ menu/cbs/menu_cbs_up.o \ menu/cbs/menu_cbs_down.o \ @@ -434,6 +443,10 @@ ifeq ($(HAVE_MENU_COMMON), 1) menu/drivers/null.o endif +ifeq ($(UTF8), 1) + DEFINES += -DHAVE_UTF8 +endif + ifeq ($(HAVE_STB_FONT), 1) OBJ += gfx/drivers_font_renderer/stb.o endif @@ -462,13 +475,15 @@ endif #Input ifneq ($(C89_BUILD), 1) -# Wayland is not a C89-compliant API. +ifneq ($(C90_BUILD), 1) +# Wayland is not a C89/C90-compliant API. ifeq ($(HAVE_WAYLAND), 1) #OBJ += input/drivers/wayland.o DEFINES += $(WAYLAND_CFLAGS) LIBS += $(WAYLAND_LIBS) endif endif +endif ifeq ($(HAVE_DINPUT), 1) LIBS += -ldinput8 -ldxguid -lole32 @@ -507,7 +522,8 @@ ifeq ($(HAVE_UDEV), 1) endif ifneq ($(C89_BUILD), 1) -# libusb is not a C89-compliant API. +ifneq ($(C90_BUILD), 1) +# libusb is not a C89/C90-compliant API. ifeq ($(HAVE_LIBUSB), 1) DEFINES += -DHAVE_LIBUSB OBJ += input/drivers_hid/libusb_hid.o @@ -516,6 +532,7 @@ ifeq ($(HAVE_LIBUSB), 1) HAVE_HID = 1 endif endif +endif ifeq ($(HAVE_IOHIDMANAGER), 1) DEFINES += -DHAVE_IOHIDMANAGER @@ -596,12 +613,14 @@ ifeq ($(HAVE_GL_CONTEXT), 1) endif ifneq ($(C89_BUILD), 1) - # Wayland is not a C89-compliant API. +ifneq ($(C90_BUILD), 1) + # Wayland is not a C89/C90-compliant API. ifeq ($(HAVE_WAYLAND), 1) ifeq ($(HAVE_EGL), 1) OBJ += gfx/drivers_context/wayland_ctx.o endif endif +endif endif ifeq ($(HAVE_GLES), 1) @@ -737,7 +756,6 @@ ifeq ($(HAVE_7ZIP),1) 7ZOBJ = deps/7zip/7zIn.o \ deps/7zip/7zAlloc.o \ deps/7zip/Bra86.o \ - deps/7zip/CpuArch.o \ deps/7zip/7zFile.o \ deps/7zip/7zStream.o \ deps/7zip/7zBuf2.o \ @@ -748,15 +766,13 @@ ifeq ($(HAVE_7ZIP),1) deps/7zip/Bcj2.o \ deps/7zip/7zCrc.o \ deps/7zip/Lzma2Dec.o \ - deps/7zip/7zBuf.o \ - decompress/7zip_support.o + deps/7zip/7zBuf.o OBJ += $(7ZOBJ) endif OBJ += libretro-common/formats/tga/tga_decode.o ifeq ($(HAVE_ZLIB), 1) - ZLIB_OBJS = decompress/zip_support.o OBJ += libretro-common/file/file_extract.o OBJ += $(ZLIB_OBJS) DEFINES += -DHAVE_ZLIB @@ -859,7 +875,8 @@ endif # Record ifneq ($(C89_BUILD), 1) -# ffmpeg and friends are not C89-compliant APIs. +ifneq ($(C90_BUILD), 1) +# ffmpeg and friends are not C89/C90-compliant APIs. ifeq ($(HAVE_FFMPEG), 1) OBJ += record/drivers/record_ffmpeg.o \ cores/ffmpeg_core.o @@ -868,6 +885,7 @@ ifeq ($(HAVE_FFMPEG), 1) DEFINES += -DHAVE_FFMPEG -Iffmpeg endif endif +endif ifeq ($(HAVE_COMPRESSION), 1) DEFINES += -DHAVE_COMPRESSION diff --git a/Makefile.ctr b/Makefile.ctr index 44cb99611f..7b20d89b29 100644 --- a/Makefile.ctr +++ b/Makefile.ctr @@ -1,8 +1,222 @@ TARGET := retroarch_3ds -OBJS := -OBJS += gfx/drivers/ctr_sprite.o griffin/griffin.o -#NO_SMDH = 1 +LIBRETRO = + DEBUG = 0 +GRIFFIN_BUILD = 1 +WHOLE_ARCHIVE_LINK = 0 +BUILD_3DSX = 1 +BUILD_CIA = 1 + +APP_TITLE = Retroarch 3DS +APP_DESCRIPTION = Retroarch 3DS +APP_AUTHOR = Team Libretro +APP_PRODUCT_CODE = RETROARCH-3DS +APP_UNIQUE_ID = 0xBAC00 +APP_ICON = ctr/default.png +APP_BANNER = ctr/libretro_banner.png +APP_AUDIO = ctr/silent.wav + +include ctr/Makefile.cores + + +OBJS := +OBJS += gfx/drivers/ctr_sprite.o + +ifeq ($(GRIFFIN_BUILD), 1) + OBJS += griffin/griffin.o +else + OBJS += libretro-common/file/file_extract.o + OBJS += performance.o + OBJS += libretro-common/compat/compat.o + OBJS += libretro-common/compat/compat_fnmatch.o + OBJS += libretro-common/memmap/memalign.o + OBJS += libretro-common/file/config_file.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 += gfx/image/image.o + OBJS += gfx/video_texture.o + OBJS += libretro-common/formats/tga/tga_decode.o + OBJS += libretro-common/formats/png/rpng_fbio.o + OBJS += libretro-common/formats/png/rpng_nbio.o + OBJS += libretro-common/formats/png/rpng_decode.o + OBJS += libretro-common/formats/png/rpng_encode.o + OBJS += gfx/drivers/ctr_gfx.o + OBJS += gfx/drivers/nullgfx.o + OBJS += gfx/font_renderer_driver.o + OBJS += gfx/drivers_font_renderer/bitmapfont.o + OBJS += gfx/font_driver.o + OBJS += input/input_autodetect.o + OBJS += input/input_joypad_driver.o + OBJS += input/input_joypad.o + OBJS += input/input_hid_driver.o + OBJS += input/input_common.o + OBJS += input/input_keymaps.o + OBJS += input/input_remapping.o + OBJS += input/input_sensor.o + OBJS += input/keyboard_line.o + OBJS += input/drivers/ctr_input.o + OBJS += input/drivers_joypad/ctr_joypad.o + OBJS += input/autoconf/builtin_ctr.o + OBJS += input/drivers/nullinput.o + OBJS += input/drivers_joypad/null_joypad.o + 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_buffer.o + OBJS += audio/audio_resampler_driver.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 + OBJS += audio/drivers/ctr_audio.o + OBJS += audio/drivers/nullaudio.o + OBJS += gfx/video_driver.o + OBJS += gfx/video_common.o + OBJS += gfx/video_pixel_converter.o + OBJS += gfx/video_viewport.o + OBJS += input/input_driver.o + OBJS += audio/audio_driver.o + OBJS += camera/camera_driver.o + OBJS += location/location_driver.o + OBJS += menu/menu_driver.o + OBJS += driver.o + OBJS += libretro-common/gfx/scaler/scaler_filter.o + OBJS += libretro-common/gfx/scaler/pixconv.o + OBJS += libretro-common/gfx/scaler/scaler.o + OBJS += libretro-common/gfx/scaler/scaler_int.o + OBJS += gfx/video_filters/2xsai.o + OBJS += gfx/video_filters/super2xsai.o + OBJS += gfx/video_filters/supereagle.o + OBJS += gfx/video_filters/2xbr.o + OBJS += gfx/video_filters/darken.o + OBJS += gfx/video_filters/epx.o + OBJS += gfx/video_filters/scale2x.o + OBJS += gfx/video_filters/blargg_ntsc_snes.o + OBJS += gfx/video_filters/lq2x.o + OBJS += gfx/video_filters/phosphor2x.o + OBJS += audio/audio_filters/echo.o + OBJS += audio/audio_filters/eq.o + OBJS += audio/audio_filters/chorus.o + OBJS += audio/audio_filters/iir.o + OBJS += audio/audio_filters/panning.o + OBJS += audio/audio_filters/phaser.o + OBJS += audio/audio_filters/reverb.o + OBJS += audio/audio_filters/wahwah.o + OBJS += libretro-common/dynamic/dylib.o + OBJS += dynamic.o + OBJS += gfx/video_filter.o + OBJS += audio/audio_dsp_filter.o + OBJS += cores/dynamic_dummy.o + OBJS += content.o + OBJS += libretro-common/file/file_path.o + OBJS += file_path_special.o + OBJS += libretro-common/file/dir_list.o + OBJS += libretro-common/file/retro_dirent.o + OBJS += dir_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/file/file_list.o + OBJS += libretro-common/queues/message_queue.o + OBJS += patch.o + OBJS += configuration.o + OBJS += rewind.o + OBJS += frontend/frontend_driver.o + OBJS += frontend/drivers/platform_ctr.o + OBJS += frontend/drivers/platform_null.o + OBJS += core_info.o + OBJS += ui/ui_companion_driver.o + OBJS += ui/drivers/ui_null.o + OBJS += frontend/frontend.o + OBJS += libretro_version_1.o + OBJS += retroarch.o + OBJS += retroarch_info.o + OBJS += runloop.o + OBJS += runloop_data.o + OBJS += runloop_msg.o + OBJS += system.o + OBJS += msg_hash.o + OBJS += intl/msg_hash_de.o + OBJS += intl/msg_hash_es.o + OBJS += intl/msg_hash_eo.o + OBJS += intl/msg_hash_fr.o + OBJS += intl/msg_hash_it.o + OBJS += intl/msg_hash_nl.o + OBJS += intl/msg_hash_pt.o + OBJS += intl/msg_hash_pl.o + OBJS += intl/msg_hash_us.o + OBJS += movie.o + OBJS += record/record_driver.o + OBJS += record/drivers/record_null.o + OBJS += tasks/task_file_transfer.o + OBJS += screenshot.o + OBJS += playlist.o + OBJS += menu/menu.o + OBJS += menu/menu_hash.o + OBJS += menu/menu_input.o + OBJS += menu/menu_entry.o + OBJS += menu/menu_entries.o + OBJS += menu/menu_setting.o + OBJS += menu/menu_list.o + OBJS += menu/menu_cbs.o + OBJS += menu/menu_video.o + OBJS += menu/cbs/menu_cbs_ok.o + OBJS += menu/cbs/menu_cbs_cancel.o + OBJS += menu/cbs/menu_cbs_select.o + OBJS += menu/cbs/menu_cbs_start.o + OBJS += menu/cbs/menu_cbs_info.o + OBJS += menu/cbs/menu_cbs_refresh.o + OBJS += menu/cbs/menu_cbs_left.o + OBJS += menu/cbs/menu_cbs_right.o + OBJS += menu/cbs/menu_cbs_title.o + OBJS += menu/cbs/menu_cbs_deferred_push.o + OBJS += menu/cbs/menu_cbs_scan.o + OBJS += menu/cbs/menu_cbs_get_value.o + OBJS += menu/menu_iterate.o + OBJS += menu/cbs/menu_cbs_up.o + OBJS += menu/cbs/menu_cbs_down.o + OBJS += menu/cbs/menu_cbs_contentlist_switch.o + OBJS += menu/menu_shader.o + OBJS += menu/menu_navigation.o + OBJS += menu/menu_display.o + OBJS += menu/menu_displaylist.o + OBJS += menu/menu_animation.o + OBJS += menu/intl/menu_hash_de.o + OBJS += menu/intl/menu_hash_es.o + OBJS += menu/intl/menu_hash_eo.o + OBJS += menu/intl/menu_hash_fr.o + OBJS += menu/intl/menu_hash_it.o + OBJS += menu/intl/menu_hash_nl.o + OBJS += menu/intl/menu_hash_pl.o + OBJS += menu/intl/menu_hash_pt.o + OBJS += menu/intl/menu_hash_us.o + OBJS += menu/drivers/null.o + OBJS += menu/drivers/rgui.o + OBJS += command_event.o + OBJS += deps/zlib/adler32.o + OBJS += deps/zlib/compress.o + OBJS += deps/zlib/crc32.o + OBJS += deps/zlib/deflate.o + OBJS += deps/zlib/gzclose.o + OBJS += deps/zlib/gzlib.o + OBJS += deps/zlib/gzread.o + OBJS += deps/zlib/gzwrite.o + OBJS += deps/zlib/inffast.o + OBJS += deps/zlib/inflate.o + OBJS += deps/zlib/inftrees.o + 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 ifeq ($(strip $(DEVKITARM)),) @@ -17,11 +231,20 @@ ifeq ($(strip $(AEMSTRO)),) $(error "Please set AEMSTRO in your environment. export AEMSTRO=aemstro") endif + + +APP_TITLE := $(shell echo "$(APP_TITLE)" | cut -c1-128) +APP_DESCRIPTION := $(shell echo "$(APP_DESCRIPTION)" | cut -c1-256) +APP_AUTHOR := $(shell echo "$(APP_AUTHOR)" | cut -c1-128) +APP_PRODUCT_CODE := $(shell echo $(APP_PRODUCT_CODE) | cut -c1-16) +APP_UNIQUE_ID := $(shell echo $(APP_UNIQUE_ID) | cut -c1-7) + + INCDIRS := -I$(CTRULIB)/include LIBDIRS := -L. -L$(CTRULIB)/lib -ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard +ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp CFLAGS += -mword-relocations \ -fomit-frame-pointer -ffast-math \ @@ -35,6 +258,12 @@ ifeq ($(DEBUG), 1) else CFLAGS += -O3 endif + +ifeq ($(WHOLE_ARCHIVE_LINK), 1) + WHOLE_START := -Wl,--whole-archive + WHOLE_END := -Wl,--no-whole-archive +endif + CFLAGS += -I. -Ideps/zlib -Ideps/7zip -Ilibretro-common/include CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE -DSINC_LOWEST_QUALITY @@ -45,45 +274,35 @@ CFLAGS += -DHAVE_ZLIB -DHAVE_RPNG -DWANT_ZLIB -DHAVE_BUILTIN_AUTOCONFIG CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 -ASFLAGS := -g $(ARCH) +ASFLAGS := -g $(ARCH) -O3 LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + CFLAGS += -std=gnu99 -ffast-math -LIBS := -lretro_ctr -lctru -lm +LIBS := $(WHOLE_START) -lretro_ctr $(WHOLE_END) -lctru -lm +ifeq ($(BUILD_3DSX), 1) +TARGET_3DSX := $(TARGET).3dsx $(TARGET).smdh +endif + +ifeq ($(BUILD_CIA), 1) +TARGET_CIA := $(TARGET).cia +endif .PHONY: $(BUILD) clean all -#--------------------------------------------------------------------------------- all: $(TARGET) -clean: - rm -f $(OBJS) - rm -f $(TARGET).3dsx - rm -f $(TARGET).elf +$(TARGET): $(TARGET_3DSX) $(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 -$(TARGET): $(TARGET).3dsx -$(TARGET).3dsx : $(TARGET).elf -$(TARGET).elf : $(OBJS) - -ifeq ($(strip $(APP_TITLE)),) -APP_TITLE := $(notdir $(TARGET)) -endif - -ifeq ($(strip $(APP_DESCRIPTION)),) -APP_DESCRIPTION := Built with devkitARM & libctru -endif - -ifeq ($(strip $(APP_AUTHOR)),) -APP_AUTHOR := Unspecified Author -endif - -ifeq ($(strip $(APP_ICON)),) -APP_ICON := $(CTRULIB)/default_icon.png -endif PREFIX := $(DEVKITARM)/bin/arm-none-eabi- @@ -96,12 +315,21 @@ STRIP := $(PREFIX)strip NM := $(PREFIX)nm LD := $(CXX) +ifneq ($(findstring Linux,$(shell uname -a)),) + MAKEROM = ctr/tools/makerom-linux + BANNERTOOL = ctr/tools/bannertool-linux +else ifneq ($(findstring Darwin,$(shell uname -a)),) + MAKEROM = ctr/tools/makerom-mac + BANNERTOOL = ctr/tools/bannertool-mac +else + MAKEROM = ctr/tools/makerom.exe + BANNERTOOL = ctr/tools/bannertool.exe +endif + %.o: %.shader -#--------------------------------------------------------------------------------- - @echo $(notdir $<) python $(AEMSTRO)/aemstro_as.py $< $(notdir $<).shbin - bin2s $(notdir $<).shbin | $(PREFIX)as -o $@ + $(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 @@ -125,22 +353,42 @@ LD := $(CXX) %.vsh: -#--------------------------------------------------------------------------------- -%.smdh: $(APP_ICON) $(MAKEFILE_LIST) - @echo building ... $(notdir $@) +%.smdh: $(APP_ICON) smdhtool --create "$(APP_TITLE)" "$(APP_DESCRIPTION)" "$(APP_AUTHOR)" $(APP_ICON) $@ -#--------------------------------------------------------------------------------- %.3dsx: %.elf - @echo building ... $(notdir $@) - 3dsxtool $< $@ $(_3DSXFLAGS) + -3dsxtool $< $@ $(_3DSXFLAGS) -#--------------------------------------------------------------------------------- -%.elf: .FORCE - @echo linking $(notdir $@) +%.elf: $(LD) $(LDFLAGS) $(OBJS) $(LIBDIRS) $(LIBS) -o $@ $(NM) -CSn $@ > $(notdir $*.lst) +$(TARGET).bnr: $(APP_BANNER) $(APP_AUDIO) + $(BANNERTOOL) makebanner -i "$(APP_BANNER)" -a "$(APP_AUDIO)" -o $@ -.PHONY: .FORCE +$(TARGET).icn: $(APP_ICON) + $(BANNERTOOL) makesmdh -s "$(APP_TITLE)" -l "$(APP_TITLE)" -p "$(APP_AUTHOR)" -i $(APP_ICON) -o $@ + +$(TARGET).rsf: ctr/tools/template-cia.rsf + cat ctr/tools/template-cia.rsf | sed 's/{APP_TITLE}/$(APP_TITLE)/' | sed 's/{APP_PRODUCT_CODE}/$(APP_PRODUCT_CODE)/' | sed 's/{APP_UNIQUE_ID}/$(APP_UNIQUE_ID)/' > $@ + +$(TARGET)_stripped.elf: $(TARGET).elf + cp $(TARGET).elf $@ + $(STRIP) $@ + +$(TARGET).cia: $(TARGET)_stripped.elf $(TARGET).bnr $(TARGET).icn $(TARGET).rsf + $(MAKEROM) -f cia -o $@ -rsf $(TARGET).rsf -target t -exefslogo -elf $(TARGET)_stripped.elf -icon $(TARGET).icn -banner $(TARGET).bnr + +clean: + rm -f $(OBJS) + rm -f $(TARGET).3dsx + rm -f $(TARGET).elf + rm -f $(TARGET)_stripped.elf + rm -f $(TARGET).cia + rm -f $(TARGET).bnr + rm -f $(TARGET).icn + rm -f $(TARGET).rsf + rm -f *_shader_shbin.h + +.PHONY: clean diff --git a/Makefile.emscripten b/Makefile.emscripten index 722434c84a..601083f433 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -23,7 +23,11 @@ ifneq ($(NATIVE_ZLIB),) endif LIBS := -LDFLAGS := -L. -s TOTAL_MEMORY=$(MEMORY) -s OUTLINING_LIMIT=50000 --js-library emscripten/library_rwebaudio.js --js-library emscripten/library_rwebinput.js --js-library emscripten/library_rwebcam.js --no-heap-copy +LDFLAGS := -L. --no-heap-copy -s USE_ZLIB=1 -s TOTAL_MEMORY=$(MEMORY) -s OUTLINING_LIMIT=50000 \ + -s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_load_state', '_cmd_take_screenshot']" \ + --js-library emscripten/library_rwebaudio.js \ + --js-library emscripten/library_rwebinput.js \ + --js-library emscripten/library_rwebcam.js include Makefile.common @@ -67,7 +71,8 @@ else CFLAGS += -O2 endif -CFLAGS += -Wall -Wno-unused-result -Wno-unused-variable -I. -Ilibretro-common/include -std=gnu99 +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) @@ -111,4 +116,3 @@ clean: rm -f *.d .PHONY: all clean - diff --git a/Makefile.griffin b/Makefile.griffin index a50ba349fe..ffdc147432 100644 --- a/Makefile.griffin +++ b/Makefile.griffin @@ -5,6 +5,7 @@ WHOLE_ARCHIVE_LINK = 0 BIG_STACK = 1 PC_DEVELOPMENT_IP_ADDRESS = 255.255.255.255 PC_DEVELOPMENT_UDP_PORT = 3490 +RARCH_CONSOLE = 0 ifneq ($(EMSCRIPTEN),) platform = emscripten @@ -34,110 +35,194 @@ else ifneq ($(findstring MINGW,$(shell uname -a)),) system_platform = win endif -TARGET_NAME := retroarch +TARGET_NAME := retroarch -INCLUDE := -LDFLAGS := -LIBDIRS := +INCLUDE := +LDFLAGS := +LIBDIRS := SHADER_CG_DIR := media/shaders_cg -OVERLAY_DIR := media/overlays -SHADER_GLSL_DIR := media/shaders_glsl +OVERLAY_DIR := media/overlays +SHADER_GLSL_DIR := media/shaders_glsl -PYTHON2 = python2$(EXE_EXT) -PYTHON3 = python3$(EXE_EXT) -GIT = git$(EXE_EXT) +PYTHON2 := python2$(EXE_EXT) +PYTHON3 := python3$(EXE_EXT) +GIT := git$(EXE_EXT) ifeq ($(WHOLE_ARCHIVE_LINK), 1) - WHOLE_START := -Wl,--whole-archive - WHOLE_END := -Wl,--no-whole-archive + WHOLE_START := -Wl,--whole-archive + WHOLE_END := -Wl,--no-whole-archive endif +LIBS := $(WHOLE_START) -lretro_$(platform) $(WHOLE_END) + +libogc_platform := + ifeq ($(platform), ngc) - CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) - CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT) - LD = $(DEVKITPPC)/bin/powerpc-eabi-ld$(EXE_EXT) - ELF2DOL = $(DEVKITPPC)/bin/elf2dol$(EXE_EXT) - EXT_TARGET := $(TARGET_NAME)_ngc.dol - EXT_INTER_TARGET := $(TARGET_NAME)_ngc.elf - INCLUDE += -I. -I$(DEVKITPRO)/libogc/include -Ideps/zlib - LIBDIRS += -L$(DEVKITPRO)/libogc/lib/cube -L. - MACHDEP := -DGEKKO -DHW_DOL -mogc -mcpu=750 -meabi -mhard-float -DMSB_FIRST - LDFLAGS += $(MACHDEP) -Wl,-Map,$(notdir $(EXT_INTER_TARGET)).map -ifeq ($(BIG_STACK), 1) - LDFLAGS += -T gx/ld/ogc.ld +libogc_platform := 1 +else ifeq ($(platform), wii) +libogc_platform := 1 endif - LIBS := -lfat $(WHOLE_START) -lretro_ngc $(WHOLE_END) -logc -ifeq ($(HAVE_LOGGER), 1) - LIBS += -lbba -endif - PLATCFLAGS := -DGEKKO - HAVE_FILTERS_BUILTIN := 1 - HAVE_THREADS := 1 - HAVE_ZLIB := 1 - HAVE_RPNG := 1 - HAVE_7ZIP := 1 - HAVE_RPNG := 1 - HAVE_OVERLAY := 1 - HAVE_BUILTIN_AUTOCONFIG := 1 -else ifeq ($(platform), ps3) +# PS3 +ifeq ($(platform), ps3) #TODO - MEDIA_SHADER_DIR := ps3/pkg/USRDIR/cores/shaders + MEDIA_SHADER_DIR := pkg/ps3/USRDIR/cores/shaders + RARCH_CONSOLE = 1 + +# PS3 - Cobra else ifeq ($(platform), ps3-cobra) #TODO MEDIA_SHADER_DIR := ps3/iso/PS3_GAME/USRDIR/cores/shaders -else ifeq ($(platform), wii) + RARCH_CONSOLE = 1 + +# NGC/Wii - libogc +else ifeq ($(libogc_platform), 1) CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT) LD = $(DEVKITPPC)/bin/powerpc-eabi-ld$(EXE_EXT) ELF2DOL = $(DEVKITPPC)/bin/elf2dol$(EXE_EXT) - EXT_TARGET := $(TARGET_NAME)_wii.dol - EXT_INTER_TARGET := $(TARGET_NAME)_wii.elf + EXT_TARGET := $(TARGET_NAME)_$(platform).dol + EXT_INTER_TARGET := $(TARGET_NAME)_$(platform).elf + INCLUDE += -I. -I$(DEVKITPRO)/libogc/include -Ideps/zlib - LIBDIRS += -L$(DEVKITPRO)/libogc/lib/wii -L. - MACHDEP := -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DMSB_FIRST - LDFLAGS += $(MACHDEP) -Wl,-Map,$(notdir $(EXT_INTER_TARGET)).map,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,strdup,-wrap,strndup,-wrap,malloc_usable_size + +ifeq ($(platform), ngc) + LIBDIRS += -L$(DEVKITPRO)/libogc/lib/cube + MACHDEP := -DHW_DOL -mogc +else ifeq ($(platform), wii) + LIBDIRS += -L$(DEVKITPRO)/libogc/lib/wii + MACHDEP := -DHW_RVL -mrvl +endif + LIBDIRS += -L. + MACHDEP += -DGEKKO -mcpu=750 -meabi -mhard-float -DMSB_FIRST + +ifeq ($(platform), ngc) + LDFLAGS += $(MACHDEP) -Wl,-Map,$(notdir $(EXT_INTER_TARGET)).map +ifeq ($(BIG_STACK), 1) + LDFLAGS += -T gx/ld/ogc.ld +endif +else ifeq ($(platform), wii) + LDFLAGS += $(MACHDEP) -Wl,-Map,$(notdir $(EXT_INTER_TARGET)).map,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,strdup,-wrap,strndup,-wrap,malloc_usable_size ifeq ($(BIG_STACK), 1) LDFLAGS += -T gx/ld/rvl.ld endif - LIBS := -lfat $(WHOLE_START) -lretro_wii $(WHOLE_END) -logc -lwiiuse -lbte +endif + LIBS += -lfat -logc + +ifeq ($(platform), wii) + LIBS += -lwiiuse -lbte ifeq ($(USBGECKO), 1) LIBS += -ldb endif +else ifeq ($(platform), ngc) +ifeq ($(HAVE_LOGGER), 1) + LIBS += -lbba +endif +endif + + CFLAGS += -DGEKKO + + HAVE_FILTERS_BUILTIN := 1 + HAVE_THREADS := 1 + HAVE_RPNG := 1 + HAVE_OVERLAY := 1 + HAVE_BUILTIN_AUTOCONFIG := 1 + HAVE_ZLIB := 1 + HAVE_7ZIP := 1 + RARCH_CONSOLE = 1 + +ifeq ($(platform), wii) + HAVE_WIIUSB_HID := 1 + HAVE_RARCH_EXEC := 1 + HAVE_RSOUND := 1 + HAVE_LIBRETRO_MANAGEMENT := 1 + HAVE_LIBSICKSAXIS := 1 + APP_BOOTER_DIR = wii/app_booter PLATOBJS := $(APP_BOOTER_DIR)/app_booter.binobj - CFLAGS += -DGEKKO ifeq ($(USBGECKO), 1) CFLAGS += -DUSBGECKO endif +endif - HAVE_FILTERS_BUILTIN := 1 - HAVE_RARCH_EXEC := 1 +# Libxenon (Xbox 360) +else ifeq ($(platform), xenon360) + CC = xenon-gcc$(EXE_EXT) + CXX = xenon-g++$(EXE_EXT) + OBJCOPY = xenon-objcopy$(EXE_EXT) + LD = xenon-ld$(EXE_EXT) + STRIP = xenon-strip$(EXE_EXT) + INCLUDE += -I$(DEVKITXENON)/usr/include + + EXT_TARGET := $(TARGET_NAME)_$(platform).elf32 + EXT_INTER_TARGET := $(TARGET_NAME)_$(platform).elf + + LIBS += -lxenon -lm -lc + + LIBDIRS += -L. -L$(DEVKITXENON)/usr/lib -L$(DEVKITXENON)/xenon/lib/32 + LDFLAGS += -Wl,-q -m32 -n -T$(DEVKITXENON)/app.lds + PLATCFLAGS := -DHAVE_GETOPT_LONG=1 + PLATCFLAGS += -maltivec -mhard-float -m32 -mpowerpc64 -mcpu=cell -mtune=cell -fno-pic -g -Wall -DXENON $(INCDIRS) -Wno-char-subscripts + PLATCFLAGS += -u read -u _start -u exc_base HAVE_THREADS := 1 - HAVE_RSOUND := 1 -HAVE_7ZIP := 1 - HAVE_LIBRETRO_MANAGEMENT := 1 - HAVE_ZLIB := 1 - HAVE_RPNG := 1 - HAVE_RPNG := 1 - HAVE_OVERLAY := 1 - HAVE_LIBSICKSAXIS := 1 - HAVE_BUILTIN_AUTOCONFIG := 1 + HAVE_GETOPT_LONG := 1 + RARCH_CONSOLE = 1 + +# PSP else ifeq ($(platform), psp1) CC = psp-gcc$(EXE_EXT) CXX = psp-g++$(EXE_EXT) LD = psp-ld$(EXE_EXT) INCLUDE += -I$(PSPSDK)/psp/sdk/include - EXT_TARGET := $(TARGET_NAME)_psp1.elf - EXT_INTER_TARGET := $(TARGET_NAME)_psp1.elf - PLATCFLAGS := -DPSP -D_PSP_FW_VERSION=150 -G0 + EXT_TARGET := $(TARGET_NAME)_$(platform).elf + EXT_INTER_TARGET := $(TARGET_NAME)_$(platform).elf + PLATCFLAGS := -DPSP -D_PSP_FW_VERSION=150 -G0 \ + -D_MIPS_ARCH_ALLEGREX + LIBS += -lpspgu -lpspgum -lm -lpspaudio -lpspfpu -lpsppower -lpsprtc -lpspkernel + LIBDIRS += -L. + LDFLAGS += -Wl,-q + + BUILD_PRX = 1 HAVE_LIBRETRO_MANAGEMENT := 1 HAVE_RPNG := 1 + HAVE_KERNEL_PRX := 1 + RARCH_CONSOLE = 1 + +ifeq ($(BUILD_PRX), 1) + LDFLAGS += $(addprefix -L,$(PSPSDK)/lib) -specs=$(PSPSDK)/lib/prxspecs -Wl,-q,-T$(PSPSDK)/lib/linkfile.prx $(LDFLAGS) endif -CFLAGS += -Wall -std=gnu99 $(MACHDEP) $(INCLUDE) +# Vita +else ifeq ($(platform), vita) + CC = arm-vita-eabi-gcc$(EXE_EXT) + CXX = arm-vita-eabi-g++$(EXE_EXT) + LD = arm-vita-eabi-ld$(EXE_EXT) + EXT_TARGET := $(TARGET_NAME)_$(platform).velf + EXT_INTER_TARGET := $(TARGET_NAME)_$(platform).elf + MACHDEP := -DVITA + PLATCFLAGS := -O3 -U__ARM_NEON__ + LIBS += -lSceKernel_stub -lSceDisplay_stub -lSceGxm_stub -lSceNet_stub \ + -lSceSysmodule_stub -lSceCtrl_stub -lSceAudio_stub \ + -lScePower_stub -lSceRtc_stub -lz -lm -lc + + PLATOBJS += audio/audio_utils_neon.o audio/drivers_resampler/sinc_neon.o \ + audio/drivers_resampler/cc_resampler_neon.o + + LIBDIRS += -L. + LDFLAGS += -Wl,-q + + HAVE_LIBRETRO_MANAGEMENT := 1 + HAVE_BUILTIN_AUTOCONFIG := 1 + HAVE_RPNG := 1 + HAVE_ZLIB := 1 + HAVE_VITA2D := 1 + RARCH_CONSOLE = 1 +endif + + +CFLAGS += -Wall -std=gnu99 $(MACHDEP) $(PLATCFLAGS) $(INCLUDE) OBJ = griffin/griffin.o $(PLATOBJS) @@ -149,18 +234,42 @@ CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC INCLUDE += -Ilogger/netlogger endif +ifeq ($(platform), wii) +CFLAGS += -DHAVE_SOCKET_LEGACY +endif + +ifeq ($(platform), vita) +CFLAGS += -DHAVE_SOCKET_LEGACY +endif + ifeq ($(HAVE_LIBRETRO_MANAGEMENT), 1) CFLAGS += -DHAVE_LIBRETRO_MANAGEMENT endif +ifeq ($(HAVE_KERNEL_PRX), 1) +CFLAGS += -DHAVE_KERNEL_PRX +endif + ifeq ($(HAVE_LIBSICKSAXIS), 1) CFLAGS += -DHAVE_LIBSICKSAXIS endif +ifeq ($(HAVE_WIIUSB_HID), 1) +CFLAGS += -DHAVE_WIIUSB_HID -DHAVE_HID +endif + +ifeq ($(HAVE_VITA2D), 1) +CFLAGS += -DHAVE_VITA2D +endif + ifeq ($(HAVE_LIBRETRODB), 1) CFLAGS += -DHAVE_LIBRETRODB endif +ifeq ($(BIG_STACK),1) +CFLAGS += -DBIG_STACK +endif + ifeq ($(HAVE_RPNG), 1) CFLAGS += -DWANT_RPNG endif @@ -202,7 +311,15 @@ ifeq ($(HAVE_NETPLAY), 1) CFLAGS += -DHAVE_NETPLAY endif -CFLAGS += -std=gnu99 -DSINC_LOWER_QUALITY -DHAVE_RGUI -DHAVE_MENU -DRARCH_CONSOLE -DHAVE_GRIFFIN=1 -Wno-char-subscripts -DRARCH_INTERNAL +ifeq ($(RARCH_CONSOLE), 1) +CFLAGS += -DRARCH_CONSOLE +endif + +ifeq ($(RARCH_MOBILE), 1) +CFLAGS += -DRARCH_MOBILE +endif + +CFLAGS += -std=gnu99 -DSINC_LOWER_QUALITY -DHAVE_RGUI -DHAVE_MENU -DHAVE_GRIFFIN=1 -Wno-char-subscripts -DRARCH_INTERNAL ifeq ($(HAVE_FILTERS_BUILTIN), 1) CFLAGS += -DHAVE_FILTERS_BUILTIN @@ -215,10 +332,18 @@ LIBS += -lpthread-psp endif endif +ifeq ($(HAVE_VITA2D), 1) +LIBS := -lvita2d $(LIBS) +endif + ifeq ($(HAVE_RSOUND), 1) CFLAGS += -DHAVE_RSOUND endif +ifeq ($(HAVE_GETOPT_LONG), 1) +CFLAGS += -DHAVE_GETOPT_LONG=1 +endif + ifeq ($(DEBUG), 1) CFLAGS += -O0 -g -DDEBUG else ifeq ($(platform), psp1) @@ -232,12 +357,29 @@ all: $(EXT_TARGET) %.dol: %.elf $(ELF2DOL) $< $@ +%.velf: %.elf + arm-vita-eabi-strip -g $< + vita-elf-create $< $@ $(VITASDK)/bin/db.json + +%.elf32: %.elf +ifeq ($(platform), xenon360) + $(OBJCOPY) -O elf32-powerpc --adjust-vma 0x80000000 $< $@ +endif + +%.prx: %.elf +ifeq ($(platform),psp1) + psp-prxgen $< $@ +endif + $(EXT_INTER_TARGET): $(OBJ) $(CXX) -o $@ $(LDFLAGS) $(LIBDIRS) $(OBJ) $(LIBS) %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< +%.o: %.S + $(CC) $(CFLAGS) -c -o $@ $< + %.bmpobj: %.bmp $(LD) -r -b binary -o $@ $< @@ -249,9 +391,9 @@ $(APP_BOOTER_DIR)/app_booter.bin: pkg: all ifeq ($(platform), wii) - cp -r $(EXT_TARGET) wii/pkg/CORE.dol + cp -r $(EXT_TARGET) pkg/wii/CORE.dol else ifeq ($(platform), ngc) - cp -r $(EXT_TARGET) ngc/pkg/CORE.dol + cp -r $(EXT_TARGET) pkg/ngc/CORE.dol else ifeq ($(platform), psp1) psp-fixup-imports$(EXT) $(EXT_TARGET) endif diff --git a/Makefile.ps3 b/Makefile.ps3 index 46ec3fb007..1e4c5e6e47 100644 --- a/Makefile.ps3 +++ b/Makefile.ps3 @@ -30,8 +30,8 @@ include $(CELL_MK_DIR)/sdk.makedef.mk PPU_TARGET = retroarch_ps3.elf SALAMANDER_TARGET = retroarch-salamander_ps3.elf -EBOOT_PATH = ps3/pkg/USRDIR/EBOOT.BIN -CORE_PATH = ps3/pkg/USRDIR/cores/CORE.SELF +EBOOT_PATH = pkg/ps3/USRDIR/EBOOT.BIN +CORE_PATH = pkg/ps3/USRDIR/cores/CORE.SELF LDDIRS = -L. -L$(CELL_SDK)/target/ppu/lib/PSGL/RSX/ultra-opt INCDIRS = -I. -Ips3 -Icommon -Ideps/zlib -Ilibretro-common/include @@ -157,28 +157,28 @@ create-salamander: $(MAKE_SELF) $(SALAMANDER_TARGET) $(EBOOT_PATH) $(CONTENT_ID_FULL) copy-media-files: - @cp -r $(RMENU_IMG_DIR)/*.png ps3/pkg/USRDIR/cores/borders/Menu/ + @cp -r $(RMENU_IMG_DIR)/*.png pkg/ps3/USRDIR/cores/borders/Menu/ create-shaders: make -f Makefile.shaders deploy-ps3 pkg: $(PPU_TARGET) create-shaders copy-media-files create-npdrm-salamander create-npdrm-core - $(MAKE_PACKAGE_NPDRM) ps3/pkg/package.conf ps3/pkg + $(MAKE_PACKAGE_NPDRM) pkg/ps3/package.conf pkg/ps3 pkg-signed: $(PPU_TARGET) create-shaders copy-media-files create-salamander create-core - $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) ps3/pkg/ retroarch-ps3-cfw-$(RARCH_VERSION).pkg + $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(RARCH_VERSION).pkg pkg-signed-standalone: $(PPU_TARGET) create-shaders copy-media-files create-core $(MAKE_SELF) $(PPU_TARGET) $(EBOOT_PATH) $(CONTENT_ID) - $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) ps3/pkg/ retroarch-ps3-cfw-$(RARCH_VERSION).pkg + $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(RARCH_VERSION).pkg pkg-signed-cfw: $(PPU_TARGET) create-shaders copy-media-files create-salamander create-core - $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) ps3/pkg/ retroarch-ps3-cfw-$(RARCH_VERSION)-kmeaw.pkg + $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(RARCH_VERSION)-kmeaw.pkg $(PKG_FINALIZE) retroarch-ps3-cfw-$(RARCH_VERSION)-kmeaw.pkg pkg-signed-cfw-standalone: $(PPU_TARGET) create-shaders copy-media-files create-core $(MAKE_SELF) $(PPU_TARGET) $(EBOOT_PATH) $(CONTENT_ID) - $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) ps3/pkg/ retroarch-ps3-cfw-$(RARCH_VERSION).pkg + $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(RARCH_VERSION).pkg $(PKG_FINALIZE) retroarch-ps3-cfw-$(RARCH_VERSION)-kmeaw.pkg clean-selfs: diff --git a/Makefile.ps3.cobra b/Makefile.ps3.cobra index c542425989..753b171666 100644 --- a/Makefile.ps3.cobra +++ b/Makefile.ps3.cobra @@ -30,8 +30,8 @@ include $(CELL_MK_DIR)/sdk.makedef.mk PPU_TARGET = retroarch_ps3.elf SALAMANDER_TARGET = retroarch-salamander_ps3.elf -EBOOT_PATH = ps3/pkg/USRDIR/EBOOT.BIN -CORE_PATH = ps3/pkg/USRDIR/cores/CORE.SELF +EBOOT_PATH = pkg/ps3/USRDIR/EBOOT.BIN +CORE_PATH = pkg/ps3/USRDIR/cores/CORE.SELF LDDIRS = -L. -L$(CELL_SDK)/target/ppu/lib/PSGL/RSX/ultra-opt INCDIRS = -I. -Ips3 -Icommon @@ -157,28 +157,28 @@ create-salamander: $(MAKE_SELF) $(SALAMANDER_TARGET) $(EBOOT_PATH) $(CONTENT_ID_FULL) copy-media-files: - @cp -r $(RMENU_IMG_DIR)/*.png ps3/pkg/USRDIR/cores/borders/Menu/ + @cp -r $(RMENU_IMG_DIR)/*.png pkg/ps3/USRDIR/cores/borders/Menu/ create-shaders: make -f Makefile.shaders deploy-ps3 pkg: $(PPU_TARGET) create-shaders copy-media-files create-npdrm-salamander create-npdrm-core - $(MAKE_PACKAGE_NPDRM) ps3/pkg/package.conf ps3/pkg + $(MAKE_PACKAGE_NPDRM) pkg/ps3/package.conf pkg/ps3 pkg-signed: $(PPU_TARGET) create-shaders copy-media-files create-salamander create-core - $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) ps3/pkg/ retroarch-ps3-cfw-$(RARCH_VERSION).pkg + $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(RARCH_VERSION).pkg pkg-signed-standalone: $(PPU_TARGET) create-shaders copy-media-files create-core $(MAKE_SELF) $(PPU_TARGET) $(EBOOT_PATH) $(CONTENT_ID) - $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) ps3/pkg/ retroarch-ps3-cfw-$(RARCH_VERSION).pkg + $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(RARCH_VERSION).pkg pkg-signed-cfw: $(PPU_TARGET) create-shaders copy-media-files create-salamander create-core - $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) ps3/pkg/ retroarch-ps3-cfw-$(RARCH_VERSION)-kmeaw.pkg + $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(RARCH_VERSION)-kmeaw.pkg $(PKG_FINALIZE) retroarch-ps3-cfw-$(RARCH_VERSION)-kmeaw.pkg pkg-signed-cfw-standalone: $(PPU_TARGET) create-shaders copy-media-files create-core $(MAKE_SELF) $(PPU_TARGET) $(EBOOT_PATH) $(CONTENT_ID) - $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) ps3/pkg/ retroarch-ps3-cfw-$(RARCH_VERSION).pkg + $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(RARCH_VERSION).pkg $(PKG_FINALIZE) retroarch-ps3-cfw-$(RARCH_VERSION)-kmeaw.pkg clean-selfs: diff --git a/Makefile.ps3.salamander b/Makefile.ps3.salamander index 81c02a5e43..2842f195c9 100644 --- a/Makefile.ps3.salamander +++ b/Makefile.ps3.salamander @@ -25,6 +25,7 @@ PPU_SRCS = frontend/frontend_salamander.c \ frontend/drivers/platform_null.c \ libretro-common/file/file_path.c \ libretro-common/file/dir_list.c \ + libretro-common/file/retro_dirent.c \ libretro-common/hash/rhash.c \ libretro-common/string/string_list.c \ libretro-common/compat/compat.c \ diff --git a/Makefile.psl1ght b/Makefile.psl1ght index 85ddec7938..2d36fb4638 100644 --- a/Makefile.psl1ght +++ b/Makefile.psl1ght @@ -14,8 +14,8 @@ LD = $(PS3DEV)/ppu/bin/ppu-ld CONTENT_ID_FULL = UP0001-SSNE10000_00-0000000000000001 ELF_TARGET := retroarch_psl1ght.elf -EBOOT_PATH = ps3/pkg/USRDIR/EBOOT.BIN -CORE_PATH = ps3/pkg/USRDIR/cores/CORE.SELF +EBOOT_PATH = pkg/ps3/USRDIR/EBOOT.BIN +CORE_PATH = pkg/ps3/USRDIR/cores/CORE.SELF INCLUDE := -I. -I$(PS3DEV)/ppu/include -Ideps/zlib -Ips3/gcmgl/include/export -Ips3/include LIBDIRS := -L$(PS3DEV)/ppu/lib -L$(PS3DEV)/portlibs/ppu/lib -L. @@ -119,10 +119,10 @@ create-core: $(MAKE_SELF_WC) $(ELF_TARGET) $(CORE_PATH) pkg: $(ELF_TARGET) create-npdrm-core - $(MAKE_PACKAGE_NPDRM) ps3/pkg/package.conf ps3/pkg + $(MAKE_PACKAGE_NPDRM) pkg/ps3/package.conf ps3/pkg pkg-signed: $(ELF_TARGET) create-core - $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) ps3/pkg/ retroarch-ps3-cfw-$(RARCH_VERSION).pkg + $(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(RARCH_VERSION).pkg clean: rm -f $(ELF_TARGET) diff --git a/Makefile.psp1.salamander b/Makefile.psp1.salamander index fa44cc85ff..28208574c1 100644 --- a/Makefile.psp1.salamander +++ b/Makefile.psp1.salamander @@ -38,6 +38,7 @@ OBJS = frontend/frontend_salamander.o \ libretro-common/file/file_path.o \ libretro-common/string/string_list.o \ libretro-common/file/dir_list.o \ + libretro-common/file/retro_dirent.o \ libretro-common/compat/compat.o \ libretro-common/file/config_file.o \ libretro-common/hash/rhash.o \ diff --git a/Makefile.wii.salamander b/Makefile.wii.salamander index 02eb182b56..af395708f5 100644 --- a/Makefile.wii.salamander +++ b/Makefile.wii.salamander @@ -39,7 +39,19 @@ LIBS := -lfat -lwiiuse -logc -lbte APP_BOOTER_DIR = wii/app_booter -OBJ = frontend/frontend_salamander.o frontend/frontend_driver.o frontend/drivers/platform_gx.o frontend/drivers/platform_wii.o frontend/drivers/platform_null.o libretro-common/file/file_path.o libretro-common/hash/rhash.o libretro-common/string/string_list.o libretro-common/file/dir_list.o libretro-common/compat/compat.o libretro-common/file/config_file.o $(APP_BOOTER_DIR)/app_booter.binobj +OBJ = frontend/frontend_salamander.o \ + frontend/frontend_driver.o \ + frontend/drivers/platform_gx.o \ + frontend/drivers/platform_wii.o \ + frontend/drivers/platform_null.o \ + libretro-common/file/file_path.o \ + libretro-common/hash/rhash.o \ + libretro-common/string/string_list.o \ + libretro-common/file/dir_list.o \ + libretro-common/file/retro_dirent.o \ + libretro-common/compat/compat.o \ + libretro-common/file/config_file.o \ + $(APP_BOOTER_DIR)/app_booter.binobj ifeq ($(HAVE_LOGGER), 1) CFLAGS += -DHAVE_LOGGER @@ -79,7 +91,7 @@ $(APP_BOOTER_DIR)/app_booter.bin: $(MAKE) -C $(APP_BOOTER_DIR) pkg: all - cp -r $(DOL_TARGET) wii/pkg/boot.dol + cp -r $(DOL_TARGET) pkg/wii/boot.dol clean: rm -f $(DOL_TARGET) diff --git a/Makefile.win b/Makefile.win index 5497ebbc37..a729510308 100644 --- a/Makefile.win +++ b/Makefile.win @@ -127,9 +127,9 @@ else endif CFLAGS += -Wall -Wno-unused-result -Wno-unused-variable -I. -CXXFLAGS += -Wall -Wno-unused-result -Wno-unused-variable -I. -std=c++0x -D__STDC_CONSTANT_MACROS +CXXFLAGS += -Wall -Wno-unused-result -Wno-unused-variable -I. -std=c++98 -D__STDC_CONSTANT_MACROS ifeq ($(CXX_BUILD), 1) - CFLAGS += -std=c++0x -xc++ -D__STDC_CONSTANT_MACROS + CFLAGS += -std=c++98 -xc++ -D__STDC_CONSTANT_MACROS else ifneq ($(GNU90_BUILD), 1) CFLAGS += -std=gnu99 @@ -147,25 +147,26 @@ $(TARGET): $(RARCH_OBJ) @$(if $(Q), $(shell echo echo LD $@),) $(Q)$(CXX) -o $@ $(RARCH_OBJ) $(LIBS) $(LDFLAGS) $(LDCXXFLAGS) +#those mkdir shenanigans are really ugly, but I can't find any better solution $(OBJDIR)/%.o: %.c - @mkdir -p $(dir $@) + @-mkdir -p $(dir $@) || mkdir $(subst /,\,$(dir $@)) || echo . @$(if $(Q), $(shell echo echo CC $<),) $(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -c -o $@ $< .FORCE: $(OBJDIR)/git_version.o: git_version.c .FORCE - @mkdir -p $(dir $@) + @-mkdir -p $(dir $@) || mkdir $(subst /,\,$(dir $@)) || echo . @$(if $(Q), $(shell echo echo CC $<),) $(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -c -o $@ $< -$(OBJDIR)/%.o: %.cpp - @mkdir -p $(dir $@) +$(OBJDIR)/%.o: %.cpp | $(dir $@) + @-mkdir -p $(dir $@) || mkdir $(subst /,\,$(dir $@)) || echo . @$(if $(Q), $(shell echo echo CXX $<),) $(Q)$(CXX) $(CXXFLAGS) $(DEFINES) -MMD -c -o $@ $< $(OBJDIR)/%.o: %.rc $(HEADERS) - @mkdir -p $(dir $@) + @-mkdir -p $(dir $@) || mkdir $(subst /,\,$(dir $@)) || echo . @$(if $(Q), $(shell echo echo WINDRES $<),) $(Q)$(WINDRES) -o $@ $< diff --git a/Makefile.xenon b/Makefile.xenon deleted file mode 100644 index 3de9ede7b0..0000000000 --- a/Makefile.xenon +++ /dev/null @@ -1,49 +0,0 @@ -RARCH_VERSION = "0.9.9.3" - -DEBUG = 0 - -CC = xenon-gcc -CXX = xenon-g++ -OBJCOPY = xenon-objcopy -STRIP = xenon-strip - -PPU_TARGET := retroarch-libxenon.elf -PPU_TARGET_ADJUSTED := retroarch-libxenon.elf32 - -LDDIRS = -L. -L$(DEVKITXENON)/usr/lib -L$(DEVKITXENON)/xenon/lib/32 -INCDIRS = -I. -I$(DEVKITXENON)/usr/include - -OBJ = griffin/griffin.o - -LIBS = -lretro_xenon360 -lxenon -lm -lc -DEFINES = -std=gnu99 -DRARCH_CONSOLE -DHAVE_THREADS -DHAVE_GETOPT_LONG=1 -DHAVE_GRIFFIN -DRARCH_INTERNAL -DEFINES += -maltivec -mhard-float -m32 -mpowerpc64 -mcpu=cell -mtune=cell -fno-pic -g -Wall -DXENON $(INCDIRS) -Wno-char-subscripts -DEFINES += -u read -u _start -u exc_base - -ifeq ($(DEBUG), 1) - OPTIMIZE_LV := -O0 -g -else - OPTIMIZE_LV := -O3 -endif - -all: $(PPU_TARGET_ADJUSTED) - -CFLAGS := $(OPTIMIZE_LV) $(DEFINES) - -LDFLAGS := -m32 -n -T $(DEVKITXENON)/app.lds - -$(PPU_TARGET_ADJUSTED): $(PPU_TARGET) - $(OBJCOPY) -O elf32-powerpc --adjust-vma 0x80000000 $< $@ - $(STRIP) $@ - -$(PPU_TARGET): $(OBJ) - $(CXX) -o $@ $(OBJ) $(LDFLAGS) $(LDDIRS) $(LIBS) - -%.o: %.c config.h - $(CC) $(CFLAGS) -c -o $@ $< - -clean: - rm -f $(PPU_TARGET) - rm -f $(OBJ) - -.PHONY: clean diff --git a/android/phoenix/AndroidManifest.xml b/android/phoenix/AndroidManifest.xml index cac745286d..3cc37ecd32 100644 --- a/android/phoenix/AndroidManifest.xml +++ b/android/phoenix/AndroidManifest.xml @@ -1,7 +1,7 @@ diff --git a/android/phoenix/jni/Android.mk b/android/phoenix/jni/Android.mk index a4d037d1f8..8fb288d01a 100644 --- a/android/phoenix/jni/Android.mk +++ b/android/phoenix/jni/Android.mk @@ -3,7 +3,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := retroarch-jni RARCH_DIR := ../../.. -LOCAL_CFLAGS += -std=gnu99 -Wall -DHAVE_LOGGER -DRARCH_DUMMY_LOG -DHAVE_ZLIB -DHAVE_MMAP -DRARCH_INTERNAL +LOCAL_CFLAGS += -std=gnu99 -Wall -DRARCH_DUMMY_LOG -DHAVE_ZLIB -DHAVE_MMAP -DRARCH_INTERNAL LOCAL_LDLIBS := -llog -lz LOCAL_SRC_FILES := apk-extract/apk-extract.c $(RARCH_DIR)/libretro-common/file/file_extract.c $(RARCH_DIR)/libretro-common/file/file_path.c $(RARCH_DIR)/file_ops.c $(RARCH_DIR)/libretro-common/string/string_list.c $(RARCH_DIR)/libretro-common/compat/compat.c @@ -11,8 +11,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(RARCH_DIR)/libretro-common/include/ include $(BUILD_SHARED_LIBRARY) -HAVE_NEON := 1 -HAVE_LOGGER := 1 +HAVE_NEON := 1 +HAVE_LOGGER := 0 include $(CLEAR_VARS) ifeq ($(TARGET_ARCH),arm) @@ -47,8 +47,8 @@ LOCAL_SRC_FILES += $(RARCH_DIR)/griffin/griffin.c ifeq ($(HAVE_LOGGER), 1) LOCAL_CFLAGS += -DHAVE_LOGGER - LOGGER_LDLIBS := -llog endif +LOGGER_LDLIBS := -llog ifeq ($(GLES),3) GLES_LIB := -lGLESv3 @@ -58,7 +58,7 @@ else endif -LOCAL_CFLAGS += -Wall -pthread -Wno-unused-function -fno-stack-protector -funroll-loops -DRARCH_MOBILE -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_DYLIB -DHAVE_GLSL -DHAVE_MENU -DHAVE_RGUI -DHAVE_ZLIB -DHAVE_RPNG -DINLINE=inline -DLSB_FIRST -DHAVE_THREADS -D__LIBRETRO__ -DHAVE_RSOUND -DHAVE_NETPLAY -DHAVE_NETWORKING -DRARCH_INTERNAL -DHAVE_FILTERS_BUILTIN -DHAVE_GLUI -DHAVE_XMB -std=gnu99 -DHAVE_LIBRETRODB -DHAVE_STB_FONT +LOCAL_CFLAGS += -Wall -pthread -Wno-unused-function -fno-stack-protector -funroll-loops -DRARCH_MOBILE -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_DYLIB -DHAVE_GLSL -DHAVE_MENU -DHAVE_RGUI -DHAVE_ZLIB -DHAVE_RPNG -DINLINE=inline -DHAVE_THREADS -D__LIBRETRO__ -DHAVE_RSOUND -DHAVE_NETPLAY -DHAVE_NETWORKING -DRARCH_INTERNAL -DHAVE_FILTERS_BUILTIN -DHAVE_GLUI -DHAVE_XMB -std=gnu99 -DHAVE_LIBRETRODB -DHAVE_STB_FONT LOCAL_CFLAGS += -DHAVE_7ZIP ifeq ($(NDK_DEBUG),1) diff --git a/android/phoenix/jni/apk-extract/apk-extract.c b/android/phoenix/jni/apk-extract/apk-extract.c index 630176b9cb..ffa0439f12 100644 --- a/android/phoenix/jni/apk-extract/apk-extract.c +++ b/android/phoenix/jni/apk-extract/apk-extract.c @@ -1,9 +1,12 @@ -#include -#include #include #include + +#include +#include +#include #include + #include "../native/com_retroarch_browser_NativeInterface.h" //#define VERBOSE_LOG diff --git a/android/phoenix/project.properties b/android/phoenix/project.properties index 610052c20f..64ab355f81 100644 --- a/android/phoenix/project.properties +++ b/android/phoenix/project.properties @@ -11,7 +11,7 @@ #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. -target=android-21 +target=android-22 android.library.reference.1=libs/appcompat android.library=false android.library.reference.2=libs/googleplay diff --git a/apple/BUILDING b/apple/BUILDING index aa1e6fb3d0..425322feeb 100644 --- a/apple/BUILDING +++ b/apple/BUILDING @@ -20,12 +20,10 @@ To build libretro cores: TARGET := vba_next_libretro.dylib fpic := -fPIC SHARED := -dynamiclib - ENDIANNESS_DEFINES = -DLSB_FIRST else ifeq ($(platform), ios) TARGET := vba_next_libretro.dylib fpic := -fPIC SHARED := -dynamiclib - ENDIANNESS_DEFINES = -DLSB_FIRST sysroot = -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/ CC = /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv7 $(sysroot) diff --git a/apple/OSX/RetroArch-Info.plist b/apple/OSX/RetroArch-Info.plist index 812e5ac793..8d5965839e 100644 --- a/apple/OSX/RetroArch-Info.plist +++ b/apple/OSX/RetroArch-Info.plist @@ -30,20 +30,20 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.1 + 1.2.2 CFBundleSignature ???? CFBundleVersion - 1.1 + 1.2.2 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} + NSHighResolutionCapable + NSHumanReadableCopyright Copyright © 2015 RetroArch. All rights reserved. NSMainNibFile MainMenu NSPrincipalClass RApplication - NSHighResolutionCapable - diff --git a/apple/OSX/en.lproj/MainMenu.xib b/apple/OSX/en.lproj/MainMenu.xib index 27a95fbd4d..a97d13e366 100644 --- a/apple/OSX/en.lproj/MainMenu.xib +++ b/apple/OSX/en.lproj/MainMenu.xib @@ -1,14 +1,22 @@ - + 1050 - 9L31a - 680 - 949.54 - 353.00 - + 12F45 + 3084 + 1187.40 + 626.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 3084 + + YES - + NSCustomObject + NSMenu + NSMenuItem + NSView + NSWindowTemplate YES @@ -16,7 +24,7 @@ PluginDependencyRecalculationVersion - + YES @@ -652,201 +660,49 @@ RetroArch NSWindow - {3.40282e+38, 3.40282e+38} + - + 256 {480, 360} + + {{0, 0}, {2560, 1418}} - {3.40282e+38, 3.40282e+38} + {10000000000000, 10000000000000} + YES RetroArch - - 31 - 2 - {{272, 172}, {276, 89}} - -1535638528 - Window - NSPanel - - {3.40282e+38, 3.40282e+38} - - - 256 - - YES - - - 268 - {{18, 72}, {240, 17}} - - - YES - - 68157504 - 138413056 - Select Core - - LucidaGrande - 1.300000e+01 - 1044 - - - YES - - 6 - System - controlColor - - 3 - MC42NjY2NjY2OQA - - - - 6 - System - controlTextColor - - 3 - MAA - - - - - - - 268 - {{21, 45}, {239, 26}} - - - 1 - YES - - 74448961 - 268436480 - - - - YES - - 6 - System - textBackgroundColor - - 3 - MQA - - - - 5 - YES - - - - 274 - {15, 0} - - - YES - - YES - - 1.200000e+01 - 1.000000e+01 - 1.000000e+03 - - 75497472 - 0 - - - LucidaGrande - 1.200000e+01 - 16 - - - 3 - MC4zMzMzMzI5OQA - - - - - 338690112 - 268436480 - - - YES - - 6 - System - controlBackgroundColor - - - - - 3 - YES - - - - 3.000000e+00 - 2.000000e+00 - - - 6 - System - gridColor - - 3 - MC41AA - - - 1.900000e+01 - tableViewAction: - -767524864 - - - - 1 - 15 - 0 - YES - - - - - - 268 - {{180, 13}, {82, 32}} - - YES - - 67108864 - 134217728 - OK - - - -2038284288 - 129 - - DQ - 200 - 25 - - - - {276, 89} - - - {{0, 0}, {2560, 1418}} - {3.40282e+38, 3.40282e+38} - YES + + + terminate: + + + + 449 + + + + orderFrontStandardAboutPanel: + + + + 142 + + + + delegate + + + + 495 + performMiniaturize: @@ -871,14 +727,6 @@ 127 - - - orderFrontStandardAboutPanel: - - - - 142 - performClose: @@ -919,14 +767,6 @@ 370 - - - terminate: - - - - 449 - showHelp: @@ -936,12 +776,20 @@ 493 - - delegate - - + + toggleFullScreen: + + - 495 + 593 + + + + openDocument: + + + + 657 @@ -975,14 +823,6 @@ 591 - - - toggleFullScreen: - - - - 593 - basicEvent: @@ -1127,14 +967,6 @@ 655 - - - openDocument: - - - - 657 - basicEvent: @@ -1151,6 +983,14 @@ 664 + + + openCore: + + + + 665 + @@ -1167,7 +1007,7 @@ -2 - RmlsZSdzIE93bmVyA + File's Owner -1 @@ -1227,11 +1067,11 @@ YES - + @@ -1411,68 +1251,6 @@ - - 557 - - - YES - - - - - - 558 - - - YES - - - - - - - - 559 - - - YES - - - - - - 560 - - - YES - - - - - - 567 - - - - - 568 - - - - - 570 - - - YES - - - - - - 571 - - - 585 @@ -1757,13 +1535,12 @@ YES - + YES -1.IBPluginDependency -2.IBPluginDependency -3.IBPluginDependency 124.IBPluginDependency - 125.IBEditorWindowLastContentRect 125.IBPluginDependency 126.IBPluginDependency 130.IBPluginDependency @@ -1778,50 +1555,34 @@ 23.IBPluginDependency 236.IBPluginDependency 239.IBPluginDependency - 24.IBEditorWindowLastContentRect 24.IBPluginDependency - 29.IBEditorWindowLastContentRect 29.IBPluginDependency - 371.IBEditorWindowLastContentRect 371.IBPluginDependency 371.IBWindowTemplateEditedContentRect 371.NSWindowTemplate.visibleAtLaunch 372.IBPluginDependency 490.IBPluginDependency - 491.IBEditorWindowLastContentRect 491.IBPluginDependency 492.IBPluginDependency 494.IBPluginDependency 5.IBPluginDependency 545.IBPluginDependency - 546.IBEditorWindowLastContentRect 546.IBPluginDependency 549.IBPluginDependency 551.IBPluginDependency - 557.IBEditorWindowLastContentRect - 557.IBPluginDependency - 557.IBWindowTemplateEditedContentRect - 557.NSWindowTemplate.visibleAtLaunch - 558.IBPluginDependency - 559.IBPluginDependency - 559.IBViewBoundsToFrameTransform 56.IBPluginDependency - 560.IBPluginDependency - 567.IBPluginDependency - 568.IBPluginDependency - 57.IBEditorWindowLastContentRect 57.IBPluginDependency - 570.IBPluginDependency - 571.IBPluginDependency 58.IBPluginDependency 585.IBPluginDependency - 586.IBEditorWindowLastContentRect 586.IBPluginDependency 587.IBPluginDependency 592.IBPluginDependency - 598.IBEditorWindowLastContentRect - 603.IBEditorWindowLastContentRect - 613.IBEditorWindowLastContentRect + 597.IBPluginDependency + 598.IBPluginDependency + 602.IBPluginDependency + 603.IBPluginDependency + 612.IBPluginDependency + 613.IBPluginDependency 614.IBPluginDependency 616.IBPluginDependency 618.IBPluginDependency @@ -1829,7 +1590,8 @@ 622.IBPluginDependency 624.IBPluginDependency 626.IBPluginDependency - 630.IBEditorWindowLastContentRect + 629.IBPluginDependency + 630.IBPluginDependency 633.IBPluginDependency 635.IBPluginDependency 637.IBPluginDependency @@ -1844,24 +1606,21 @@ 656.IBPluginDependency 658.IBPluginDependency 660.IBPluginDependency - 661.IBEditorWindowLastContentRect 661.IBPluginDependency 663.IBPluginDependency 72.IBPluginDependency 73.IBPluginDependency 79.IBPluginDependency - 81.IBEditorWindowLastContentRect 81.IBPluginDependency 83.IBPluginDependency 92.IBPluginDependency - + YES com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{782, 496}, {143, 23}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1876,52 +1635,36 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{785, 425}, {284, 133}} com.apple.InterfaceBuilder.CocoaPlugin - {{497, 558}, {420, 20}} com.apple.InterfaceBuilder.CocoaPlugin - {{507, 199}, {480, 360}} com.apple.InterfaceBuilder.CocoaPlugin - {{507, 199}, {480, 360}} - + {{438, 199}, {480, 360}} + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{856, 535}, {174, 23}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{642, 395}, {192, 163}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{329, 640}, {276, 89}} com.apple.InterfaceBuilder.CocoaPlugin - {{329, 640}, {276, 89}} - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - - P4AAAL+AAABBoAAAwooAAA - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{509, 405}, {206, 153}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{730, 535}, {151, 23}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{834, 455}, {144, 63}} - {{834, 495}, {185, 23}} - {{834, 455}, {123, 43}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1929,7 +1672,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{907, 316}, {79, 203}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1944,13 +1686,11 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{834, 535}, {137, 23}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{600, 465}, {182, 93}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1958,29 +1698,112 @@ YES - - YES - - - YES - + + YES - - YES - - - YES - + + - 664 + 665 + + + + YES + + RetroArch + NSObject + + YES + + YES + basicEvent: + openCore: + showCoresDirectory: + showPreferences: + + + YES + id + id + id + id + + + + YES + + YES + basicEvent: + openCore: + showCoresDirectory: + showPreferences: + + + YES + + basicEvent: + id + + + openCore: + id + + + showCoresDirectory: + id + + + showPreferences: + id + + + + + window + NSWindow + + + window + + window + NSWindow + + + + IBProjectSource + ./Classes/RetroArch.h + + + - 0 - ../RetroArch.xcodeproj + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES 3 + + YES + + YES + NSMenuCheckmark + NSMenuMixedState + + + YES + {11, 11} + {10, 3} + + diff --git a/apple/OSXPPC/RetroArch.xcodeproj/project.pbxproj b/apple/OSXPPC/RetroArch.xcodeproj/project.pbxproj index c8e0df352b..717dace7b3 100644 --- a/apple/OSXPPC/RetroArch.xcodeproj/project.pbxproj +++ b/apple/OSXPPC/RetroArch.xcodeproj/project.pbxproj @@ -282,7 +282,7 @@ ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ( "-DHAVE_GRIFFIN", - "-DHAVE_CORETEXT", + "-DHAVE_STB_FONT", "-DHAVE_IOHIDMANAGER", "-DHAVE_RGUI", "-DHAVE_MENU", @@ -348,6 +348,7 @@ "-DNS_BLOCK_ASSERTIONS=1", "-DNDEBUG", "-DHAVE_GRIFFIN", + "-DHAVE_STB_FONT", "-DHAVE_IOHIDMANAGER", "-DHAVE_RGUI", "-DHAVE_MENU", diff --git a/apple/RetroArch copy-Info.plist b/apple/RetroArch copy-Info.plist new file mode 100644 index 0000000000..8d5965839e --- /dev/null +++ b/apple/RetroArch copy-Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + * + + CFBundleTypeName + All Files + CFBundleTypeRole + Viewer + + + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + retroarch + CFBundleIdentifier + libretro.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.2.2 + CFBundleSignature + ???? + CFBundleVersion + 1.2.2 + LSMinimumSystemVersion + ${MACOSX_DEPLOYMENT_TARGET} + NSHighResolutionCapable + + NSHumanReadableCopyright + Copyright © 2015 RetroArch. All rights reserved. + NSMainNibFile + MainMenu + NSPrincipalClass + RApplication + + diff --git a/apple/RetroArch.xcodeproj/project.pbxproj b/apple/RetroArch.xcodeproj/project.pbxproj index d68077cf16..e64dc8dd2d 100644 --- a/apple/RetroArch.xcodeproj/project.pbxproj +++ b/apple/RetroArch.xcodeproj/project.pbxproj @@ -8,6 +8,20 @@ /* Begin PBXBuildFile section */ 1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58140DA1D0A300B32029 /* MainMenu.xib */; }; + 500845251B89300700CE6073 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; + 500845261B89300700CE6073 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58140DA1D0A300B32029 /* MainMenu.xib */; }; + 500845271B89300700CE6073 /* retroarch.icns in Resources */ = {isa = PBXBuildFile; fileRef = 84DD5EB71A89F1C7007336C1 /* retroarch.icns */; }; + 500845291B89300700CE6073 /* griffin_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = 509F0C9C1AA23AFC00619ECC /* griffin_objc.m */; }; + 5008452A1B89300700CE6073 /* griffin.c in Sources */ = {isa = PBXBuildFile; fileRef = 840222FB1A889EE2009AB261 /* griffin.c */; }; + 5008452C1B89300700CE6073 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5061C8A31AE47E510080AE14 /* libz.dylib */; }; + 5008452D1B89300700CE6073 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5EA81A89E4BE007336C1 /* CoreAudio.framework */; }; + 5008452E1B89300700CE6073 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5EB21A89E6C0007336C1 /* AudioUnit.framework */; }; + 5008452F1B89300700CE6073 /* Cg.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5EB01A89E664007336C1 /* Cg.framework */; settings = {ATTRIBUTES = (Required, ); }; }; + 500845301B89300700CE6073 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5EAC1A89E5B4007336C1 /* OpenGL.framework */; }; + 500845311B89300700CE6073 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5EA61A89E406007336C1 /* CoreLocation.framework */; }; + 500845321B89300700CE6073 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29B97324FDCFA39411CA2CEA /* AppKit.framework */; }; + 500845331B89300700CE6073 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5E9E1A88E45B007336C1 /* CoreVideo.framework */; }; + 500845341B89300700CE6073 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5EB41A89E737007336C1 /* IOKit.framework */; }; 5061C8A41AE47E510080AE14 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5061C8A31AE47E510080AE14 /* libz.dylib */; }; 509F0C9D1AA23AFC00619ECC /* griffin_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = 509F0C9C1AA23AFC00619ECC /* griffin_objc.m */; }; 840222FC1A889EE2009AB261 /* griffin.c in Sources */ = {isa = PBXBuildFile; fileRef = 840222FB1A889EE2009AB261 /* griffin.c */; }; @@ -18,12 +32,29 @@ 84DD5EAD1A89E5B4007336C1 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5EAC1A89E5B4007336C1 /* OpenGL.framework */; }; 84DD5EB31A89E6C0007336C1 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5EB21A89E6C0007336C1 /* AudioUnit.framework */; }; 84DD5EB51A89E737007336C1 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5EB41A89E737007336C1 /* IOKit.framework */; }; - 84DD5EB61A89E76C007336C1 /* Cg.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84DD5EB01A89E664007336C1 /* Cg.framework */; }; 84DD5EB81A89F1C7007336C1 /* retroarch.icns in Resources */ = {isa = PBXBuildFile; fileRef = 84DD5EB71A89F1C7007336C1 /* retroarch.icns */; }; 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ + 500845351B89300700CE6073 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 7; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 500845361B89300700CE6073 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 7; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 841CBB831A8A33B60066E9F1 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -48,6 +79,8 @@ 089C165DFE840E0CC02AAC07 /* InfoPlist.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = InfoPlist.strings; path = OSX/en.lproj/InfoPlist.strings; sourceTree = ""; }; 1DDD58150DA1D0A300B32029 /* MainMenu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = MainMenu.xib; path = OSX/en.lproj/MainMenu.xib; sourceTree = ""; }; 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; + 5008453A1B89300700CE6073 /* RetroArch copy.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "RetroArch copy.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 5008453B1B89300700CE6073 /* RetroArch copy-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "RetroArch copy-Info.plist"; path = "/Users/squarepusher/libretro-super/retroarch/apple/RetroArch copy-Info.plist"; sourceTree = ""; }; 5061C8A31AE47E510080AE14 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; 509F0C9C1AA23AFC00619ECC /* griffin_objc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = griffin_objc.m; path = ../griffin/griffin_objc.m; sourceTree = ""; }; 840222FB1A889EE2009AB261 /* griffin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = griffin.c; path = ../griffin/griffin.c; sourceTree = SOURCE_ROOT; }; @@ -64,6 +97,22 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 5008452B1B89300700CE6073 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 5008452C1B89300700CE6073 /* libz.dylib in Frameworks */, + 5008452D1B89300700CE6073 /* CoreAudio.framework in Frameworks */, + 5008452E1B89300700CE6073 /* AudioUnit.framework in Frameworks */, + 5008452F1B89300700CE6073 /* Cg.framework in Frameworks */, + 500845301B89300700CE6073 /* OpenGL.framework in Frameworks */, + 500845311B89300700CE6073 /* CoreLocation.framework in Frameworks */, + 500845321B89300700CE6073 /* AppKit.framework in Frameworks */, + 500845331B89300700CE6073 /* CoreVideo.framework in Frameworks */, + 500845341B89300700CE6073 /* IOKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 8D11072E0486CEB800E47090 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -71,7 +120,6 @@ 5061C8A41AE47E510080AE14 /* libz.dylib in Frameworks */, 84DD5EA91A89E4BE007336C1 /* CoreAudio.framework in Frameworks */, 84DD5EB31A89E6C0007336C1 /* AudioUnit.framework in Frameworks */, - 84DD5EB61A89E76C007336C1 /* Cg.framework in Frameworks */, 84DD5EAD1A89E5B4007336C1 /* OpenGL.framework in Frameworks */, 84DD5EA71A89E406007336C1 /* CoreLocation.framework in Frameworks */, 84DD5EA31A89E2AA007336C1 /* AppKit.framework in Frameworks */, @@ -116,6 +164,7 @@ isa = PBXGroup; children = ( 8D1107320486CEB800E47090 /* RetroArch.app */, + 5008453A1B89300700CE6073 /* RetroArch copy.app */, ); name = Products; sourceTree = ""; @@ -130,6 +179,7 @@ 29B97317FDCFA39411CA2CEA /* Resources */, 29B97323FDCFA39411CA2CEA /* Frameworks */, 19C28FACFE9D520D11CA2CBB /* Products */, + 5008453B1B89300700CE6073 /* RetroArch copy-Info.plist */, ); indentWidth = 3; name = RetroArch; @@ -184,6 +234,26 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 500845231B89300700CE6073 /* RetroArch Cg */ = { + isa = PBXNativeTarget; + buildConfigurationList = 500845371B89300700CE6073 /* Build configuration list for PBXNativeTarget "RetroArch Cg" */; + buildPhases = ( + 500845241B89300700CE6073 /* Resources */, + 500845281B89300700CE6073 /* Sources */, + 5008452B1B89300700CE6073 /* Frameworks */, + 500845351B89300700CE6073 /* CopyFiles */, + 500845361B89300700CE6073 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "RetroArch Cg"; + productInstallPath = "$(HOME)/Applications"; + productName = RetroArch; + productReference = 5008453A1B89300700CE6073 /* RetroArch copy.app */; + productType = "com.apple.product-type.application"; + }; 8D1107260486CEB800E47090 /* RetroArch */ = { isa = PBXNativeTarget; buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "RetroArch" */; @@ -223,12 +293,23 @@ projectDirPath = ""; projectRoot = ""; targets = ( + 500845231B89300700CE6073 /* RetroArch Cg */, 8D1107260486CEB800E47090 /* RetroArch */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 500845241B89300700CE6073 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 500845251B89300700CE6073 /* InfoPlist.strings in Resources */, + 500845261B89300700CE6073 /* MainMenu.xib in Resources */, + 500845271B89300700CE6073 /* retroarch.icns in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 8D1107290486CEB800E47090 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -242,6 +323,15 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 500845281B89300700CE6073 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 500845291B89300700CE6073 /* griffin_objc.m in Sources */, + 5008452A1B89300700CE6073 /* griffin.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 8D11072C0486CEB800E47090 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -273,6 +363,128 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 500845381B89300700CE6073 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COMBINE_HIDPI_IMAGES = YES; + COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(LOCAL_LIBRARY_DIR)/Frameworks", + ); + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + HEADER_SEARCH_PATHS = ( + "$(SRCROOT)/..", + "$(SRCROOT)/../gfx/inc", + "$(SRCROOT)/../libretro-common/include", + ); + INFOPLIST_FILE = "RetroArch copy-Info.plist"; + INSTALL_PATH = "$(HOME)/Applications"; + MACOSX_DEPLOYMENT_TARGET = 10.5; + OTHER_CFLAGS = ( + "-DHAVE_GRIFFIN", + "-DHAVE_IMAGEVIEWER", + "-DHAVE_CORETEXT", + "-DHAVE_IOHIDMANAGER", + "-DHAVE_CORELOCATION", + "-DHAVE_RGUI", + "-DHAVE_MENU", + "-DOSX", + "-DHAVE_OPENGL", + "-DHAVE_FBO", + "-DHAVE_GLSL", + "-DINLINE=inline", + "-D__LIBRETRO__", + "-DWANT_RPNG", + "-DHAVE_COREAUDIO", + "-DHAVE_DYNAMIC", + "-DHAVE_OVERLAY", + "-DHAVE_ZLIB", + "-DHAVE_RPNG", + "-DHAVE_COCOA", + "-DHAVE_MAIN", + "-DSINC_LOWER_QUALITY", + "-DHAVE_NETPLAY", + "-DHAVE_NETWORKING", + "-DRARCH_INTERNAL", + "-DHAVE_THREADS", + "-DHAVE_DYLIB", + "-DHAVE_CG", + "-DHAVE_7ZIP", + "-DHAVE_GLUI", + "-DHAVE_HID", + "-DHAVE_XMB", + "-DHAVE_LIBRETRODB", + ); + PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = YES; + PRODUCT_NAME = "RetroArch copy"; + }; + name = Debug; + }; + 500845391B89300700CE6073 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COMBINE_HIDPI_IMAGES = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(LOCAL_LIBRARY_DIR)/Frameworks", + ); + GCC_MODEL_TUNING = G5; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + HEADER_SEARCH_PATHS = ( + "$(SRCROOT)/..", + "$(SRCROOT)/../gfx/inc", + "$(SRCROOT)/../libretro-common/include", + ); + INFOPLIST_FILE = "RetroArch copy-Info.plist"; + INSTALL_PATH = "$(HOME)/Applications"; + MACOSX_DEPLOYMENT_TARGET = 10.5; + OTHER_CFLAGS = ( + "-DHAVE_GRIFFIN", + "-DHAVE_IMAGEVIEWER", + "-DHAVE_IOHIDMANAGER", + "-DHAVE_CORETEXT", + "-DHAVE_CORELOCATION", + "-DHAVE_RGUI", + "-DHAVE_MENU", + "-DOSX", + "-DHAVE_OPENGL", + "-DHAVE_FBO", + "-DHAVE_GLSL", + "-DINLINE=inline", + "-D__LIBRETRO__", + "-DWANT_RPNG", + "-DHAVE_COREAUDIO", + "-DHAVE_DYNAMIC", + "-DHAVE_OVERLAY", + "-DHAVE_ZLIB", + "-DHAVE_RPNG", + "-DHAVE_COCOA", + "-DHAVE_MAIN", + "-DSINC_LOWER_QUALITY", + "-DHAVE_NETPLAY", + "-DHAVE_NETWORKING", + "-DRARCH_INTERNAL", + "-DHAVE_THREADS", + "-DHAVE_DYLIB", + "-DHAVE_CG", + "-DHAVE_7ZIP", + "-DHAVE_GLUI", + "-DHAVE_HID", + "-DHAVE_XMB", + "-DHAVE_LIBRETRODB", + ); + PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = YES; + PRODUCT_NAME = "RetroArch copy"; + }; + name = Release; + }; C01FCF4B08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -323,7 +535,6 @@ "-DRARCH_INTERNAL", "-DHAVE_THREADS", "-DHAVE_DYLIB", - "-DHAVE_CG", "-DHAVE_7ZIP", "-DHAVE_GLUI", "-DHAVE_HID", @@ -383,7 +594,6 @@ "-DRARCH_INTERNAL", "-DHAVE_THREADS", "-DHAVE_DYLIB", - "-DHAVE_CG", "-DHAVE_7ZIP", "-DHAVE_GLUI", "-DHAVE_HID", @@ -424,6 +634,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 500845371B89300700CE6073 /* Build configuration list for PBXNativeTarget "RetroArch Cg" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 500845381B89300700CE6073 /* Debug */, + 500845391B89300700CE6073 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "RetroArch" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/apple/iOS/Makefile b/apple/iOS/Makefile index 9d10e9b6cf..11a2ce6782 100644 --- a/apple/iOS/Makefile +++ b/apple/iOS/Makefile @@ -17,7 +17,7 @@ ${APPLICATION_NAME}_FILES = $(SRC_DIR)/griffin/griffin.c \ $(SRC_DIR)/audio/drivers_resampler/sinc_neon.S \ $(SRC_DIR)/audio/drivers_resampler/cc_resampler_neon.S -COMMON_FLAGS := -DIOS -DHAVE_GRIFFIN -DHAVE_CORELOCATION -DHAVE_NETPLAY -DHAVE_RGUI -DHAVE_MENU -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DHAVE_GLSL -DINLINE=inline -DLSB_FIRST -DHAVE_THREADS -D__LIBRETRO__ -DRARCH_MOBILE -std=gnu99 -DHAVE_COREAUDIO -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_ZLIB -DWANT_ZLIB -DSINC_LOWER_QUALITY -DRARCH_INTERNAL -DHAVE_FILTERS_BUILTIN -DHAVE_XMB -D_LZMA_UINT32_IS_ULONG -DHAVE_STRL +COMMON_FLAGS := -DIOS -DHAVE_GRIFFIN -DHAVE_CORELOCATION -DHAVE_NETPLAY -DHAVE_RGUI -DHAVE_MENU -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DHAVE_GLSL -DINLINE=inline -DHAVE_THREADS -D__LIBRETRO__ -DRARCH_MOBILE -std=gnu99 -DHAVE_COREAUDIO -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_ZLIB -DWANT_ZLIB -DSINC_LOWER_QUALITY -DRARCH_INTERNAL -DHAVE_FILTERS_BUILTIN -DHAVE_XMB -D_LZMA_UINT32_IS_ULONG -DHAVE_STRL COMMON_FLAGS += -DHAVE_AVFOUNDATION COMMON_IOS_FLAGS := -Wno-deprecated-declarations -Wno-error COMMON_IOS_OBJCFLAGS := -fobjc-arc diff --git a/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj b/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj index 61f2ba142f..e8468fc025 100644 --- a/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj +++ b/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj @@ -496,6 +496,7 @@ ONLY_ACTIVE_ARCH = NO; OTHER_CFLAGS = ( "-DHAVE_NETPLAY", + "-DHAVE_CORETEXT", "-DHAVE_HID", "-DHAVE_NETWORKING", "-DHAVE_AVFOUNDATION", @@ -513,7 +514,6 @@ "-DHAVE_OPENGLES2", "-DHAVE_GLSL", "-DINLINE=inline", - "-DLSB_FIRST", "-D__LIBRETRO__", "-DRARCH_MOBILE", "-DHAVE_COREAUDIO", @@ -563,6 +563,7 @@ "-DNS_BLOCK_ASSERTIONS=1", "-DNDEBUG", "-DHAVE_NETPLAY", + "-DHAVE_CORETEXT", "-DHAVE_HID", "-DHAVE_NETWORKING", "-DHAVE_AVFOUNDATION", @@ -579,7 +580,6 @@ "-DHAVE_OPENGLES2", "-DHAVE_GLSL", "-DINLINE=inline", - "-DLSB_FIRST", "-D__LIBRETRO__", "-DRARCH_MOBILE", "-DHAVE_COREAUDIO", @@ -602,6 +602,7 @@ "-DNS_BLOCK_ASSERTIONS=1", "-DNDEBUG", "-DHAVE_NETPLAY", + "-DHAVE_CORETEXT", "-DHAVE_HID", "-DHAVE_NETWORKING", "-DHAVE_AVFOUNDATION", @@ -618,7 +619,6 @@ "-DHAVE_OPENGLES2", "-DHAVE_GLSL", "-DINLINE=inline", - "-DLSB_FIRST", "-D__LIBRETRO__", "-DRARCH_MOBILE", "-DHAVE_COREAUDIO", @@ -672,6 +672,7 @@ ONLY_ACTIVE_ARCH = NO; OTHER_CFLAGS = ( "-DHAVE_NETPLAY", + "-DHAVE_CORETEXT", "-DHAVE_HID", "-DHAVE_NETWORKING", "-DHAVE_AVFOUNDATION", @@ -689,7 +690,6 @@ "-DHAVE_OPENGLES2", "-DHAVE_GLSL", "-DINLINE=inline", - "-DLSB_FIRST", "-DHAVE_THREADS", "-D__LIBRETRO__", "-DRARCH_MOBILE", @@ -733,6 +733,7 @@ "-DNS_BLOCK_ASSERTIONS=1", "-DNDEBUG", "-DHAVE_NETPLAY", + "-DHAVE_CORETEXT", "-DHAVE_HID", "-DHAVE_NETWORKING", "-DHAVE_AVFOUNDATION", @@ -750,7 +751,6 @@ "-DHAVE_OPENGLES2", "-DHAVE_GLSL", "-DINLINE=inline", - "-DLSB_FIRST", "-DHAVE_THREADS", "-D__LIBRETRO__", "-DRARCH_MOBILE", @@ -796,6 +796,7 @@ ONLY_ACTIVE_ARCH = NO; OTHER_CFLAGS = ( "-DHAVE_NETPLAY", + "-DHAVE_CORETEXT", "-DHAVE_HID", "-DHAVE_NETWORKING", "-DHAVE_AVFOUNDATION", @@ -812,7 +813,6 @@ "-DHAVE_OPENGLES2", "-DHAVE_GLSL", "-DINLINE=inline", - "-DLSB_FIRST", "-D__LIBRETRO__", "-DRARCH_MOBILE", "-DHAVE_COREAUDIO", @@ -865,6 +865,7 @@ "-DNS_BLOCK_ASSERTIONS=1", "-DNDEBUG", "-DHAVE_NETPLAY", + "-DHAVE_CORETEXT", "-DHAVE_HID", "-DHAVE_NETWORKING", "-DHAVE_AVFOUNDATION", @@ -881,7 +882,6 @@ "-DHAVE_OPENGLES2", "-DHAVE_GLSL", "-DINLINE=inline", - "-DLSB_FIRST", "-D__LIBRETRO__", "-DRARCH_MOBILE", "-DHAVE_COREAUDIO", @@ -906,6 +906,7 @@ "-DNS_BLOCK_ASSERTIONS=1", "-DNDEBUG", "-DHAVE_NETPLAY", + "-DHAVE_CORETEXT", "-DHAVE_HID", "-DHAVE_NETWORKING", "-DHAVE_AVFOUNDATION", @@ -922,7 +923,6 @@ "-DHAVE_OPENGLES2", "-DHAVE_GLSL", "-DINLINE=inline", - "-DLSB_FIRST", "-D__LIBRETRO__", "-DRARCH_MOBILE", "-DHAVE_COREAUDIO", diff --git a/audio/audio_driver.c b/audio/audio_driver.c index eb26cb3a3d..1e20bb1e6b 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -15,16 +15,14 @@ */ #include + #include -#include "audio_driver.h" + #include "audio_monitor.h" +#include "audio_driver.h" #include "audio_utils.h" #include "audio_thread_wrapper.h" -#include "../driver.h" #include "../general.h" -#include "../retroarch.h" -#include "../runloop.h" -#include "../performance.h" #ifndef AUDIO_BUFFER_FREE_SAMPLES_COUNT #define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024) @@ -118,8 +116,8 @@ static const audio_driver_t *audio_drivers[] = { #ifdef EMSCRIPTEN &audio_rwebaudio, #endif -#ifdef PSP - &audio_psp1, +#if defined(PSP) || defined(VITA) + &audio_psp, #endif #ifdef _3DS &audio_ctr, @@ -601,7 +599,6 @@ bool audio_driver_flush(const int16_t *data, size_t samples) size_t output_size = sizeof(float); struct resampler_data src_data = {0}; struct rarch_dsp_data dsp_data = {0}; - runloop_t *runloop = rarch_main_get_ptr(); driver_t *driver = driver_get_ptr(); const audio_driver_t *audio = driver ? (const audio_driver_t*)driver->audio : NULL; @@ -617,7 +614,7 @@ bool audio_driver_flush(const int16_t *data, size_t samples) driver->recording->push_audio(driver->recording_data, &ffemu_data); } - if (runloop->is_paused || settings->audio.mute_enable) + if (rarch_main_is_paused() || settings->audio.mute_enable) return true; if (!driver->audio_active || !audio_data.data) return false; @@ -654,7 +651,7 @@ bool audio_driver_flush(const int16_t *data, size_t samples) audio_driver_readjust_input_rate(); src_data.ratio = audio_data.src_ratio; - if (runloop->is_slowmotion) + if (rarch_main_is_slowmotion()) src_data.ratio *= settings->slowmotion_ratio; RARCH_PERFORMANCE_INIT(resampler_proc); diff --git a/audio/audio_driver.h b/audio/audio_driver.h index f6ffd272d3..df5f265b71 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -88,7 +88,7 @@ extern audio_driver_t audio_coreaudio; extern audio_driver_t audio_xenon360; extern audio_driver_t audio_ps3; extern audio_driver_t audio_gx; -extern audio_driver_t audio_psp1; +extern audio_driver_t audio_psp; extern audio_driver_t audio_ctr; extern audio_driver_t audio_rwebaudio; extern audio_driver_t audio_null; diff --git a/audio/audio_dsp_filter.c b/audio/audio_dsp_filter.c index 2f1a4ca34f..c0b9d77d02 100644 --- a/audio/audio_dsp_filter.c +++ b/audio/audio_dsp_filter.c @@ -242,12 +242,15 @@ rarch_dsp_filter_t *rarch_dsp_filter_new( #if !defined(HAVE_FILTERS_BUILTIN) && defined(HAVE_DYLIB) fill_pathname_basedir(basedir, filter_config, sizeof(basedir)); - plugs = dir_list_new(basedir, EXT_EXECUTABLES, false); + plugs = dir_list_new(basedir, EXT_EXECUTABLES, false, false); if (!plugs) goto error; #endif + +#if defined(HAVE_DYLIB) || defined(HAVE_FILTERS_BUILTIN) if (!append_plugs(dsp, plugs)) goto error; +#endif if (plugs) string_list_free(plugs); diff --git a/audio/audio_filters/chorus.c b/audio/audio_filters/chorus.c index ec40a22f84..544d47340b 100644 --- a/audio/audio_filters/chorus.c +++ b/audio/audio_filters/chorus.c @@ -56,29 +56,32 @@ static void chorus_process(void *data, struct dspfilter_output *output, for (i = 0; i < input->frames; i++, out += 2) { + unsigned delay_int; + float delay_frac, l_a, l_b, r_a, r_b; + float chorus_l, chorus_r; float in[2] = { out[0], out[1] }; - float delay = ch->delay + ch->depth * sin((2.0 * M_PI * ch->lfo_ptr++) / ch->lfo_period); + delay *= ch->input_rate; if (ch->lfo_ptr >= ch->lfo_period) ch->lfo_ptr = 0; - unsigned delay_int = (unsigned)delay; + delay_int = (unsigned)delay; if (delay_int >= CHORUS_MAX_DELAY - 1) delay_int = CHORUS_MAX_DELAY - 2; - float delay_frac = delay - delay_int; + delay_frac = delay - delay_int; ch->old[0][ch->old_ptr] = in[0]; ch->old[1][ch->old_ptr] = in[1]; - float l_a = ch->old[0][(ch->old_ptr - delay_int - 0) & CHORUS_DELAY_MASK]; - float l_b = ch->old[0][(ch->old_ptr - delay_int - 1) & CHORUS_DELAY_MASK]; - float r_a = ch->old[1][(ch->old_ptr - delay_int - 0) & CHORUS_DELAY_MASK]; - float r_b = ch->old[1][(ch->old_ptr - delay_int - 1) & CHORUS_DELAY_MASK]; + l_a = ch->old[0][(ch->old_ptr - delay_int - 0) & CHORUS_DELAY_MASK]; + l_b = ch->old[0][(ch->old_ptr - delay_int - 1) & CHORUS_DELAY_MASK]; + r_a = ch->old[1][(ch->old_ptr - delay_int - 0) & CHORUS_DELAY_MASK]; + r_b = ch->old[1][(ch->old_ptr - delay_int - 1) & CHORUS_DELAY_MASK]; - // Lerp introduces aliasing of the chorus component, but doing full polyphase here is probably overkill. - float chorus_l = l_a * (1.0f - delay_frac) + l_b * delay_frac; - float chorus_r = r_a * (1.0f - delay_frac) + r_b * delay_frac; + /* Lerp introduces aliasing of the chorus component, but doing full polyphase here is probably overkill. */ + chorus_l = l_a * (1.0f - delay_frac) + l_b * delay_frac; + chorus_r = r_a * (1.0f - delay_frac) + r_b * delay_frac; out[0] = ch->mix_dry * in[0] + ch->mix_wet * chorus_l; out[1] = ch->mix_dry * in[1] + ch->mix_wet * chorus_r; @@ -90,11 +93,11 @@ static void chorus_process(void *data, struct dspfilter_output *output, static void *chorus_init(const struct dspfilter_info *info, const struct dspfilter_config *config, void *userdata) { + float delay, depth, lfo_freq, drywet; struct chorus_data *ch = (struct chorus_data*)calloc(1, sizeof(*ch)); if (!ch) return NULL; - float delay, depth, lfo_freq, drywet; config->get_float(userdata, "delay_ms", &delay, 25.0f); config->get_float(userdata, "depth_ms", &depth, 1.0f); config->get_float(userdata, "lfo_freq", &lfo_freq, 0.5f); diff --git a/audio/audio_filters/echo.c b/audio/audio_filters/echo.c index 4baf7f8fd5..14e6aabf4e 100644 --- a/audio/audio_filters/echo.c +++ b/audio/audio_filters/echo.c @@ -60,6 +60,7 @@ static void echo_process(void *data, struct dspfilter_output *output, for (i = 0; i < input->frames; i++, out += 2) { + float left, right; float echo_left = 0.0f; float echo_right = 0.0f; @@ -72,8 +73,8 @@ static void echo_process(void *data, struct dspfilter_output *output, echo_left *= echo->amp; echo_right *= echo->amp; - float left = out[0] + echo_left; - float right = out[1] + echo_right; + left = out[0] + echo_left; + right = out[1] + echo_right; for (c = 0; c < echo->num_channels; c++) { @@ -94,22 +95,21 @@ static void echo_process(void *data, struct dspfilter_output *output, static void *echo_init(const struct dspfilter_info *info, const struct dspfilter_config *config, void *userdata) { - unsigned i; - struct echo_data *echo = (struct echo_data*)calloc(1, sizeof(*echo)); - if (!echo) - return NULL; - + unsigned i, channels; float *delay = NULL, *feedback = NULL; unsigned num_delay = 0, num_feedback = 0; static const float default_delay[] = { 200.0f }; static const float default_feedback[] = { 0.5f }; + struct echo_data *echo = (struct echo_data*)calloc(1, sizeof(*echo)); + if (!echo) + return NULL; config->get_float_array(userdata, "delay", &delay, &num_delay, default_delay, 1); config->get_float_array(userdata, "feedback", &feedback, &num_feedback, default_feedback, 1); config->get_float(userdata, "amp", &echo->amp, 0.2f); - unsigned channels = num_feedback = num_delay = min(num_delay, num_feedback); + channels = num_feedback = num_delay = min(num_delay, num_feedback); echo->channels = (struct echo_channel*)calloc(channels, sizeof(*echo->channels)); if (!echo->channels) diff --git a/audio/audio_filters/eq.c b/audio/audio_filters/eq.c index f81161e365..5a9b17ba4c 100644 --- a/audio/audio_filters/eq.c +++ b/audio/audio_filters/eq.c @@ -12,12 +12,14 @@ * You should have received a copy of the GNU General Public License along with RetroArch. * If not, see . */ - -#include "dspfilter.h" +#include #include #include -#include + #include +#include + +#include "dspfilter.h" #include "fft/fft.c" @@ -45,7 +47,7 @@ struct eq_data struct eq_gain { float freq; - float gain; // Linear. + float gain; /* Linear. */ }; static void eq_free(void *data) @@ -65,18 +67,22 @@ static void eq_free(void *data) static void eq_process(void *data, struct dspfilter_output *output, const struct dspfilter_input *input) { + float *out; + const float *in; + unsigned input_frames; struct eq_data *eq = (struct eq_data*)data; - output->samples = eq->buffer; - output->frames = 0; + output->samples = eq->buffer; + output->frames = 0; - float *out = eq->buffer; - const float *in = input->samples; - unsigned input_frames = input->frames; + out = eq->buffer; + in = input->samples; + input_frames = input->frames; while (input_frames) { unsigned write_avail = eq->block_size - eq->block_ptr; + if (input_frames < write_avail) write_avail = input_frames; @@ -119,10 +125,9 @@ static int gains_cmp(const void *a_, const void *b_) const struct eq_gain *b = (const struct eq_gain*)b_; if (a->freq < b->freq) return -1; - else if (a->freq > b->freq) + if (a->freq > b->freq) return 1; - else - return 0; + return 0; } static void generate_response(fft_complex_t *response, @@ -133,8 +138,8 @@ static void generate_response(fft_complex_t *response, float start_freq = 0.0f; float start_gain = 1.0f; - float end_freq = 1.0f; - float end_gain = 1.0f; + float end_freq = 1.0f; + float end_gain = 1.0f; if (num_gains) { @@ -147,6 +152,8 @@ static void generate_response(fft_complex_t *response, // Create a response by linear interpolation between known frequency sample points. for (i = 0; i <= samples; i++) { + float gain; + float lerp = 0.5f; float freq = (float)i / samples; while (freq >= end_freq) @@ -171,11 +178,10 @@ static void generate_response(fft_complex_t *response, } } - float lerp = 0.5f; - // Edge case where i == samples. + /* Edge case where i == samples. */ if (end_freq > start_freq) lerp = (freq - start_freq) / (end_freq - start_freq); - float gain = (1.0f - lerp) * start_gain + lerp * end_gain; + gain = (1.0f - lerp) * start_gain + lerp * end_gain; response[i].real = gain; response[i].imag = 0.0f; @@ -184,58 +190,25 @@ static void generate_response(fft_complex_t *response, } } -// Modified Bessel function of first order. -// Check Wiki for mathematical definition ... -static INLINE double kaiser_besseli0(double x) -{ - unsigned i; - double sum = 0.0; - - double factorial = 1.0; - double factorial_mult = 0.0; - double x_pow = 1.0; - double two_div_pow = 1.0; - double x_sqr = x * x; - - // Approximate. This is an infinite sum. - // Luckily, it converges rather fast. - for (i = 0; i < 18; i++) - { - sum += x_pow * two_div_pow / (factorial * factorial); - - factorial_mult += 1.0; - x_pow *= x_sqr; - two_div_pow *= 0.25; - factorial *= factorial_mult; - } - - return sum; -} - -static INLINE double kaiser_window(double index, double beta) -{ - return kaiser_besseli0(beta * sqrt(1 - index * index)); -} - static void create_filter(struct eq_data *eq, unsigned size_log2, struct eq_gain *gains, unsigned num_gains, double beta, const char *filter_path) { int i; int half_block_size = eq->block_size >> 1; - double window_mod = 1.0 / kaiser_window(0.0, beta); + double window_mod = 1.0 / kaiser_window_function(0.0, beta); fft_t *fft = fft_new(size_log2); float *time_filter = (float*)calloc(eq->block_size * 2 + 1, sizeof(*time_filter)); if (!fft || !time_filter) goto end; - // Make sure bands are in correct order. + /* Make sure bands are in correct order. */ qsort(gains, num_gains, sizeof(*gains), gains_cmp); - // Compute desired filter response. + /* Compute desired filter response. */ generate_response(eq->filter, gains, num_gains, half_block_size); - // Get equivalent time-domain filter. + /* Get equivalent time-domain filter. */ fft_process_inverse(fft, time_filter, eq->filter, 1); // ifftshift() to create the correct linear phase filter. @@ -248,16 +221,16 @@ static void create_filter(struct eq_data *eq, unsigned size_log2, time_filter[i] = tmp; } - // Apply a window to smooth out the frequency repsonse. + /* Apply a window to smooth out the frequency repsonse. */ for (i = 0; i < (int)eq->block_size; i++) { - // Kaiser window. + /* Kaiser window. */ double phase = (double)i / eq->block_size; phase = 2.0 * (phase - 0.5); - time_filter[i] *= window_mod * kaiser_window(phase, beta); + time_filter[i] *= window_mod * kaiser_window_function(phase, beta); } - // Debugging. + /* Debugging. */ if (filter_path) { FILE *file = fopen(filter_path, "w"); @@ -269,9 +242,10 @@ static void create_filter(struct eq_data *eq, unsigned size_log2, } } - // Padded FFT to create our FFT filter. - // Make our even-length filter odd by discarding the first coefficient. - // For some interesting reason, this allows us to design an odd-length linear phase filter. + /* Padded FFT to create our FFT filter. + * Make our even-length filter odd by discarding the first coefficient. + * For some interesting reason, this allows us to design an odd-length linear phase filter. + */ fft_process_forward(eq->fft, eq->filter, time_filter + 1, 1); end: @@ -282,28 +256,27 @@ end: static void *eq_init(const struct dspfilter_info *info, const struct dspfilter_config *config, void *userdata) { - unsigned i; + float *frequencies, *gain; + unsigned num_freq, num_gain, i, size; + int size_log2; + float beta; + struct eq_gain *gains = NULL; + char *filter_path = NULL; + const float default_freq[] = { 0.0f, info->input_rate }; + const float default_gain[] = { 0.0f, 0.0f }; struct eq_data *eq = (struct eq_data*)calloc(1, sizeof(*eq)); if (!eq) return NULL; - const float default_freq[] = { 0.0f, info->input_rate }; - const float default_gain[] = { 0.0f, 0.0f }; - float beta; config->get_float(userdata, "window_beta", &beta, 4.0f); - int size_log2; config->get_int(userdata, "block_size_log2", &size_log2, 8); - unsigned size = 1 << size_log2; + size = 1 << size_log2; - struct eq_gain *gains = NULL; - float *frequencies, *gain; - unsigned num_freq, num_gain; config->get_float_array(userdata, "frequencies", &frequencies, &num_freq, default_freq, 2); config->get_float_array(userdata, "gains", &gain, &num_gain, default_gain, 2); - char *filter_path = NULL; if (!config->get_string(userdata, "impulse_response_output", &filter_path, "")) { config->free(filter_path); @@ -331,8 +304,9 @@ static void *eq_init(const struct dspfilter_info *info, eq->fftblock = (fft_complex_t*)calloc(2 * size, sizeof(*eq->fftblock)); eq->filter = (fft_complex_t*)calloc(2 * size, sizeof(*eq->filter)); - // Use an FFT which is twice the block size with zero-padding - // to make circular convolution => proper convolution. + /* Use an FFT which is twice the block size with zero-padding + * to make circular convolution => proper convolution. + */ eq->fft = fft_new(size_log2 + 1); if (!eq->fft || !eq->fftblock || !eq->save || !eq->block || !eq->filter) diff --git a/audio/audio_filters/iir.c b/audio/audio_filters/iir.c index 7f91e2bdd0..d2ea7f7264 100644 --- a/audio/audio_filters/iir.c +++ b/audio/audio_filters/iir.c @@ -61,30 +61,34 @@ static void iir_free(void *data) static void iir_process(void *data, struct dspfilter_output *output, const struct dspfilter_input *input) { + float b0, b1, b2, a0, a1, a2; + float xn1_l, xn2_l, yn1_l, yn2_l; + float xn1_r, xn2_r, yn1_r, yn2_r; unsigned i; + float *out; struct iir_data *iir = (struct iir_data*)data; output->samples = input->samples; output->frames = input->frames; - float *out = output->samples; + out = output->samples; - float b0 = iir->b0; - float b1 = iir->b1; - float b2 = iir->b2; - float a0 = iir->a0; - float a1 = iir->a1; - float a2 = iir->a2; + b0 = iir->b0; + b1 = iir->b1; + b2 = iir->b2; + a0 = iir->a0; + a1 = iir->a1; + a2 = iir->a2; - float xn1_l = iir->l.xn1; - float xn2_l = iir->l.xn2; - float yn1_l = iir->l.yn1; - float yn2_l = iir->l.yn2; + xn1_l = iir->l.xn1; + xn2_l = iir->l.xn2; + yn1_l = iir->l.yn1; + yn2_l = iir->l.yn2; - float xn1_r = iir->r.xn1; - float xn2_r = iir->r.xn2; - float yn1_r = iir->r.yn1; - float yn2_r = iir->r.yn2; + xn1_r = iir->r.xn1; + xn2_r = iir->r.xn2; + yn1_r = iir->r.yn1; + yn2_r = iir->r.yn2; for (i = 0; i < input->frames; i++, out += 2) { @@ -155,15 +159,15 @@ static void iir_filter_init(struct iir_data *iir, float sample_rate, float freq, float qual, float gain, enum IIRFilter filter_type) { double omega = 2.0 * M_PI * freq / sample_rate; - double cs = cos(omega); - double sn = sin(omega); + double cs = cos(omega); + double sn = sin(omega); double a1pha = sn / (2.0 * qual); - double A = exp(log(10.0) * gain / 40.0); - double beta = sqrt(A + A); + double A = exp(log(10.0) * gain / 40.0); + double beta = sqrt(A + A); - float b0 = 0.0, b1 = 0.0, b2 = 0.0, a0 = 0.0, a1 = 0.0, a2 = 0.0; + float b0 = 0.0, b1 = 0.0, b2 = 0.0, a0 = 0.0, a1 = 0.0, a2 = 0.0; - // Set up filter coefficients according to type + /* Set up filter coefficients according to type */ switch (filter_type) { case LPF: @@ -216,6 +220,7 @@ static void iir_filter_init(struct iir_data *iir, break; case RIAA_phono: /* http://www.dsprelated.com/showmessage/73300/3.php */ { + double y, b_re, a_re, b_im, a_im, g; float b[3], a[3]; if ((int)sample_rate == 44100) @@ -247,21 +252,22 @@ static void iir_filter_init(struct iir_data *iir, make_poly_from_roots(poles, 2, a); } - b0 = b[0]; - b1 = b[1]; - b2 = b[2]; - a0 = a[0]; - a1 = a[1]; - a2 = a[2]; + b0 = b[0]; + b1 = b[1]; + b2 = b[2]; + a0 = a[0]; + a1 = a[1]; + a2 = a[2]; + /* Normalise to 0dB at 1kHz (Thanks to Glenn Davis) */ - double y = 2.0 * M_PI * 1000.0 / sample_rate; - double b_re = b0 + b1 * cos(-y) + b2 * cos(-2.0 * y); - double a_re = a0 + a1 * cos(-y) + a2 * cos(-2.0 * y); - double b_im = b1 * sin(-y) + b2 * sin(-2.0 * y); - double a_im = a1 * sin(-y) + a2 * sin(-2.0 * y); - double g = 1.0 / sqrt((sqr(b_re) + sqr(b_im)) / (sqr(a_re) + sqr(a_im))); - b0 *= g; b1 *= g; b2 *= g; + y = 2.0 * M_PI * 1000.0 / sample_rate; + b_re = b0 + b1 * cos(-y) + b2 * cos(-2.0 * y); + a_re = a0 + a1 * cos(-y) + a2 * cos(-2.0 * y); + b_im = b1 * sin(-y) + b2 * sin(-2.0 * y); + a_im = a1 * sin(-y) + a2 * sin(-2.0 * y); + g = 1.0 / sqrt((sqr(b_re) + sqr(b_im)) / (sqr(a_re) + sqr(a_im))); + b0 *= g; b1 *= g; b2 *= g; break; } case PEQ: @@ -319,19 +325,20 @@ static void iir_filter_init(struct iir_data *iir, static void *iir_init(const struct dspfilter_info *info, const struct dspfilter_config *config, void *userdata) { + float freq, qual, gain; + enum IIRFilter filter; + char *type = NULL; struct iir_data *iir = (struct iir_data*)calloc(1, sizeof(*iir)); if (!iir) return NULL; - float freq, qual, gain; config->get_float(userdata, "frequency", &freq, 1024.0f); config->get_float(userdata, "quality", &qual, 0.707f); config->get_float(userdata, "gain", &gain, 0.0f); - char *type = NULL; config->get_string(userdata, "type", &type, "LPF"); - enum IIRFilter filter = str_to_type(type); + filter = str_to_type(type); config->free(type); iir_filter_init(iir, info->input_rate, freq, qual, gain, filter); diff --git a/audio/audio_filters/panning.c b/audio/audio_filters/panning.c index bf461089d4..e1118c7fa5 100644 --- a/audio/audio_filters/panning.c +++ b/audio/audio_filters/panning.c @@ -33,12 +33,12 @@ static void panning_process(void *data, struct dspfilter_output *output, const struct dspfilter_input *input) { unsigned i; + float *out; struct panning_data *pan = (struct panning_data*)data; - output->samples = input->samples; - output->frames = input->frames; - - float *out = output->samples; + output->samples = input->samples; + output->frames = input->frames; + out = output->samples; for (i = 0; i < input->frames; i++, out += 2) { @@ -52,28 +52,19 @@ static void panning_process(void *data, struct dspfilter_output *output, static void *panning_init(const struct dspfilter_info *info, const struct dspfilter_config *config, void *userdata) { + static const float default_left[] = { 1.0f, 0.0f }; + static const float default_right[] = { 0.0f, 1.0f }; + float *left = NULL, *right = NULL; + unsigned num_left = 0, num_right = 0; struct panning_data *pan = (struct panning_data*)calloc(1, sizeof(*pan)); if (!pan) return NULL; - float *left = NULL, *right = NULL; - unsigned num_left = 0, num_right = 0; - - static const float default_left[] = { 1.0f, 0.0f }; - static const float default_right[] = { 0.0f, 1.0f }; - config->get_float_array(userdata, "left_mix", &left, &num_left, default_left, 2); config->get_float_array(userdata, "right_mix", &right, &num_right, default_right, 2); - if (num_left == 2) - memcpy(pan->left, left, sizeof(pan->left)); - else - memcpy(pan->left, default_left, sizeof(pan->left)); - - if (num_right == 2) - memcpy(pan->right, right, sizeof(pan->right)); - else - memcpy(pan->right, default_right, sizeof(pan->right)); + memcpy(pan->left, (num_left == 2) ? left : default_left, sizeof(pan->left)); + memcpy(pan->right, (num_right == 2) ? right : default_right, sizeof(pan->right)); config->free(left); config->free(right); diff --git a/audio/audio_filters/phaser.c b/audio/audio_filters/phaser.c index d70b974613..284d43710b 100644 --- a/audio/audio_filters/phaser.c +++ b/audio/audio_filters/phaser.c @@ -53,12 +53,12 @@ static void phaser_process(void *data, struct dspfilter_output *output, { unsigned i, c; int s; - float m[2], tmp[2]; + float m[2], tmp[2], *out; struct phaser_data *ph = (struct phaser_data*)data; output->samples = input->samples; output->frames = input->frames; - float *out = output->samples; + out = output->samples; for (i = 0; i < input->frames; i++, out += 2) { @@ -95,12 +95,11 @@ static void phaser_process(void *data, struct dspfilter_output *output, static void *phaser_init(const struct dspfilter_info *info, const struct dspfilter_config *config, void *userdata) { + float lfo_freq, lfo_start_phase; struct phaser_data *ph = (struct phaser_data*)calloc(1, sizeof(*ph)); if (!ph) return NULL; - float lfo_freq, lfo_start_phase; - config->get_float(userdata, "lfo_freq", &lfo_freq, 0.4f); config->get_float(userdata, "lfo_start_phase", &lfo_start_phase, 0.0f); config->get_float(userdata, "feedback", &ph->fb, 0.0f); diff --git a/audio/audio_filters/reverb.c b/audio/audio_filters/reverb.c index 2b9eac4e81..66bc9e36f2 100644 --- a/audio/audio_filters/reverb.c +++ b/audio/audio_filters/reverb.c @@ -245,11 +245,12 @@ static void reverb_process(void *data, struct dspfilter_output *output, const struct dspfilter_input *input) { unsigned i; + float *out; struct reverb_data *rev = (struct reverb_data*)data; - output->samples = input->samples; - output->frames = input->frames; - float *out = output->samples; + output->samples = input->samples; + output->frames = input->frames; + out = output->samples; for (i = 0; i < input->frames; i++, out += 2) { @@ -263,11 +264,12 @@ static void reverb_process(void *data, struct dspfilter_output *output, static void *reverb_init(const struct dspfilter_info *info, const struct dspfilter_config *config, void *userdata) { - struct reverb_data *rev = (struct reverb_data*)calloc(1, sizeof(*rev)); + float drytime, wettime, damping, roomwidth, roomsize; + struct reverb_data *rev = (struct reverb_data*) + calloc(1, sizeof(*rev)); if (!rev) return NULL; - float drytime, wettime, damping, roomwidth, roomsize; config->get_float(userdata, "drytime", &drytime, 0.43f); config->get_float(userdata, "wettime", &wettime, 0.4f); config->get_float(userdata, "damping", &damping, 0.8f); diff --git a/audio/audio_filters/wahwah.c b/audio/audio_filters/wahwah.c index 27055ee3f3..bea58321ae 100644 --- a/audio/audio_filters/wahwah.c +++ b/audio/audio_filters/wahwah.c @@ -19,7 +19,7 @@ #include #include -#define wahwahlfoskipsamples 30 +#define WAHWAH_LFO_SKIP_SAMPLES 30 #ifndef M_PI #define M_PI 3.1415926535897932384626433832795 @@ -42,44 +42,49 @@ struct wahwah_data static void wahwah_free(void *data) { - free(data); + if (data) + free(data); } static void wahwah_process(void *data, struct dspfilter_output *output, const struct dspfilter_input *input) { unsigned i; + float *out; struct wahwah_data *wah = (struct wahwah_data*)data; - output->samples = input->samples; - output->frames = input->frames; - float *out = output->samples; + output->samples = input->samples; + output->frames = input->frames; + out = output->samples; for (i = 0; i < input->frames; i++, out += 2) { + float out_l, out_r; float in[2] = { out[0], out[1] }; - if ((wah->skipcount++ % wahwahlfoskipsamples) == 0) + if ((wah->skipcount++ % WAHWAH_LFO_SKIP_SAMPLES) == 0) { + float omega, sn, cs, alpha; float frequency = (1.0 + cos(wah->skipcount * wah->lfoskip + wah->phase)) / 2.0; + frequency = frequency * wah->depth * (1.0 - wah->freqofs) + wah->freqofs; frequency = exp((frequency - 1.0) * 6.0); - float omega = M_PI * frequency; - float sn = sin(omega); - float cs = cos(omega); - float alpha = sn / (2.0 * wah->res); + omega = M_PI * frequency; + sn = sin(omega); + cs = cos(omega); + alpha = sn / (2.0 * wah->res); - wah->b0 = (1.0 - cs) / 2.0; - wah->b1 = 1.0 - cs; - wah->b2 = (1.0 - cs) / 2.0; - wah->a0 = 1.0 + alpha; - wah->a1 = -2.0 * cs; - wah->a2 = 1.0 - alpha; + wah->b0 = (1.0 - cs) / 2.0; + wah->b1 = 1.0 - cs; + wah->b2 = (1.0 - cs) / 2.0; + wah->a0 = 1.0 + alpha; + wah->a1 = -2.0 * cs; + wah->a2 = 1.0 - alpha; } - float out_l = (wah->b0 * in[0] + wah->b1 * wah->l.xn1 + wah->b2 * wah->l.xn2 - wah->a1 * wah->l.yn1 - wah->a2 * wah->l.yn2) / wah->a0; - float out_r = (wah->b0 * in[1] + wah->b1 * wah->r.xn1 + wah->b2 * wah->r.xn2 - wah->a1 * wah->r.yn1 - wah->a2 * wah->r.yn2) / wah->a0; + out_l = (wah->b0 * in[0] + wah->b1 * wah->l.xn1 + wah->b2 * wah->l.xn2 - wah->a1 * wah->l.yn1 - wah->a2 * wah->l.yn2) / wah->a0; + out_r = (wah->b0 * in[1] + wah->b1 * wah->r.xn1 + wah->b2 * wah->r.xn2 - wah->a1 * wah->r.yn1 - wah->a2 * wah->r.yn2) / wah->a0; wah->l.xn2 = wah->l.xn1; wah->l.xn1 = in[0]; @@ -91,8 +96,8 @@ static void wahwah_process(void *data, struct dspfilter_output *output, wah->r.yn2 = wah->r.yn1; wah->r.yn1 = out_r; - out[0] = out_l; - out[1] = out_r; + out[0] = out_l; + out[1] = out_r; } } diff --git a/audio/drivers/alsa.c b/audio/drivers/alsa.c index fa98672166..c3ed0a207c 100644 --- a/audio/drivers/alsa.c +++ b/audio/drivers/alsa.c @@ -13,16 +13,13 @@ * If not, see . */ +#include + +#include #include "../../driver.h" -#include -#include #include "../../general.h" -#define TRY_ALSA(x) if (x < 0) { \ - goto error; \ - } - typedef struct alsa { snd_pcm_t *pcm; @@ -73,43 +70,72 @@ static void *alsa_init(const char *device, unsigned rate, unsigned latency) if (device) alsa_dev = device; - TRY_ALSA(snd_pcm_open( - &alsa->pcm, alsa_dev, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)); - TRY_ALSA(snd_pcm_hw_params_malloc(¶ms)); + if (snd_pcm_open( + &alsa->pcm, alsa_dev, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK) < 0) + goto error; + + if (snd_pcm_hw_params_malloc(¶ms) < 0) + goto error; + alsa->has_float = find_float_format(alsa->pcm, params); format = alsa->has_float ? SND_PCM_FORMAT_FLOAT : SND_PCM_FORMAT_S16; - TRY_ALSA(snd_pcm_hw_params_any(alsa->pcm, params)); - TRY_ALSA(snd_pcm_hw_params_set_access( - alsa->pcm, params, SND_PCM_ACCESS_RW_INTERLEAVED)); - TRY_ALSA(snd_pcm_hw_params_set_format(alsa->pcm, params, format)); - TRY_ALSA(snd_pcm_hw_params_set_channels(alsa->pcm, params, channels)); - TRY_ALSA(snd_pcm_hw_params_set_rate(alsa->pcm, params, rate, 0)); + if (snd_pcm_hw_params_any(alsa->pcm, params) < 0) + goto error; - TRY_ALSA(snd_pcm_hw_params_set_buffer_time_near( - alsa->pcm, params, &latency_usec, NULL)); - TRY_ALSA(snd_pcm_hw_params_set_periods_near( - alsa->pcm, params, &periods, NULL)); + if (snd_pcm_hw_params_set_access( + alsa->pcm, params, SND_PCM_ACCESS_RW_INTERLEAVED) < 0) + goto error; - TRY_ALSA(snd_pcm_hw_params(alsa->pcm, params)); + if (snd_pcm_hw_params_set_format(alsa->pcm, params, format) < 0) + goto error; + + if (snd_pcm_hw_params_set_channels(alsa->pcm, params, channels) < 0) + goto error; + + if (snd_pcm_hw_params_set_rate(alsa->pcm, params, rate, 0) < 0) + goto error; + + if (snd_pcm_hw_params_set_buffer_time_near( + alsa->pcm, params, &latency_usec, NULL) < 0) + goto error; + + if (snd_pcm_hw_params_set_periods_near( + alsa->pcm, params, &periods, NULL) < 0) + goto error; + + if (snd_pcm_hw_params(alsa->pcm, params) < 0) + goto error; /* Shouldn't have to bother with this, * but some drivers are apparently broken. */ if (snd_pcm_hw_params_get_period_size(params, &buffer_size, NULL)) snd_pcm_hw_params_get_period_size_min(params, &buffer_size, NULL); + RARCH_LOG("ALSA: Period size: %d frames\n", (int)buffer_size); + if (snd_pcm_hw_params_get_buffer_size(params, &buffer_size)) snd_pcm_hw_params_get_buffer_size_max(params, &buffer_size); + RARCH_LOG("ALSA: Buffer size: %d frames\n", (int)buffer_size); + alsa->buffer_size = snd_pcm_frames_to_bytes(alsa->pcm, buffer_size); alsa->can_pause = snd_pcm_hw_params_can_pause(params); + RARCH_LOG("ALSA: Can pause: %s.\n", alsa->can_pause ? "yes" : "no"); - TRY_ALSA(snd_pcm_sw_params_malloc(&sw_params)); - TRY_ALSA(snd_pcm_sw_params_current(alsa->pcm, sw_params)); - TRY_ALSA(snd_pcm_sw_params_set_start_threshold( - alsa->pcm, sw_params, buffer_size / 2)); - TRY_ALSA(snd_pcm_sw_params(alsa->pcm, sw_params)); + if (snd_pcm_sw_params_malloc(&sw_params) < 0) + goto error; + + if (snd_pcm_sw_params_current(alsa->pcm, sw_params) < 0) + goto error; + + if (snd_pcm_sw_params_set_start_threshold( + alsa->pcm, sw_params, buffer_size / 2) < 0) + goto error; + + if (snd_pcm_sw_params(alsa->pcm, sw_params) < 0) + goto error; snd_pcm_hw_params_free(params); snd_pcm_sw_params_free(sw_params); diff --git a/audio/drivers/alsa_qsa.c b/audio/drivers/alsa_qsa.c index e0e8f22ef7..a0aef4a1dd 100644 --- a/audio/drivers/alsa_qsa.c +++ b/audio/drivers/alsa_qsa.c @@ -14,13 +14,13 @@ * If not, see . */ -#include "../../general.h" -#include "../../driver.h" - #define ALSA_PCM_NEW_HW_PARAMS_API #define ALSA_PCM_NEW_SW_PARAMS_API #include +#include "../../general.h" +#include "../../driver.h" + #define MAX_FRAG_SIZE 3072 #define DEFAULT_RATE 48000 diff --git a/audio/drivers/alsathread.c b/audio/drivers/alsathread.c index fcddbae17e..d2ebb04ecf 100644 --- a/audio/drivers/alsathread.c +++ b/audio/drivers/alsathread.c @@ -14,14 +14,16 @@ * If not, see . */ - -#include "../../driver.h" #include + #include -#include "../../general.h" + #include #include +#include "../../driver.h" +#include "../../general.h" + #define TRY_ALSA(x) if (x < 0) { \ goto error; \ } diff --git a/audio/drivers/coreaudio.c b/audio/drivers/coreaudio.c index d07cb04ea4..5ec6ba8d4d 100644 --- a/audio/drivers/coreaudio.c +++ b/audio/drivers/coreaudio.c @@ -13,12 +13,8 @@ * You should have received a copy of the GNU General Public License along with RetroArch. * If not, see . */ - -#include "../../driver.h" -#include "../../general.h" -#include #include -#include + #include #if TARGET_OS_IPHONE @@ -31,6 +27,13 @@ #include #include +#include +#include +#include + +#include "../../driver.h" +#include "../../general.h" + #if defined(__powerpc__) || defined(__ppc__) || defined(__POWERPC__) #ifndef OSX_PPC diff --git a/audio/drivers/ctr_audio.c b/audio/drivers/ctr_audio.c index 8b4240462d..a4119ef6a9 100644 --- a/audio/drivers/ctr_audio.c +++ b/audio/drivers/ctr_audio.c @@ -17,7 +17,6 @@ #include "../../driver.h" #include "../../performance.h" - typedef struct { bool nonblocking; diff --git a/audio/drivers/dsound.c b/audio/drivers/dsound.c index 6026945210..aeb27713fd 100644 --- a/audio/drivers/dsound.c +++ b/audio/drivers/dsound.c @@ -14,14 +14,28 @@ * If not, see . */ -#if defined(_MSC_VER) && !defined(_XBOX) -#pragma comment(lib, "dsound") -#pragma comment(lib, "dxguid") +#include +#include +#include +#include + +#ifndef _XBOX +#include +#include +#include #endif +#include + +#include + #include #include #include +#include + +#include "../../driver.h" +#include "../../general.h" #ifdef _XBOX #define DSERR_BUFFERLOST MAKE_DSHRESULT(150) @@ -29,21 +43,11 @@ #define DSERR_PRIOLEVELNEEDED MAKE_DSHRESULT(70) #endif -#include "../../driver.h" -#include -#include -#include -#include -#include - -#ifndef _XBOX -// Need these includes in MinGW-w64 4.9 it seems ... -#include -#include +#if defined(_MSC_VER) && !defined(_XBOX) +#pragma comment(lib, "dsound") +#pragma comment(lib, "dxguid") #endif -#include -#include -#include "../../general.h" + typedef struct dsound { @@ -83,7 +87,7 @@ struct audio_lock DWORD size2; }; -static INLINE bool grab_region(dsound_t *ds, DWORD write_ptr, +static INLINE bool grab_region(dsound_t *ds, uint32_t write_ptr, struct audio_lock *region) { const char *err; @@ -118,16 +122,11 @@ static INLINE bool grab_region(dsound_t *ds, DWORD write_ptr, break; default: - err = NULL; + return true; } - if (err) - { - RARCH_WARN("[DirectSound error]: %s\n", err); - return false; - } - - return true; + RARCH_WARN("[DirectSound error]: %s\n", err); + return false; } static INLINE void release_region(dsound_t *ds, const struct audio_lock *region) diff --git a/audio/drivers/gx_audio.c b/audio/drivers/gx_audio.c index 35606cdbb3..df01e01d7d 100644 --- a/audio/drivers/gx_audio.c +++ b/audio/drivers/gx_audio.c @@ -14,12 +14,8 @@ * If not, see . */ -#include "../../driver.h" #include -#include -#include "../../general.h" #include -#include #ifdef GEKKO #include @@ -28,7 +24,12 @@ #include #endif -#include "../../gfx/drivers/gx_sdk_defines.h" +#include +#include + +#include "../../driver.h" +#include "../../general.h" +#include "../../defines/gx_defines.h" #define CHUNK_FRAMES 64 #define CHUNK_SIZE (CHUNK_FRAMES * sizeof(uint32_t)) diff --git a/audio/drivers/jack.c b/audio/drivers/jack.c index eadd5ce3c8..49cc67a06c 100644 --- a/audio/drivers/jack.c +++ b/audio/drivers/jack.c @@ -13,20 +13,22 @@ * If not, see . */ - -#include "../../driver.h" +#include #include -#include "../../general.h" +#include + +#include #include #include #include -#include + #include -#include -#include #include +#include "../../driver.h" +#include "../../general.h" + #define FRAMES(x) (x / (sizeof(float) * 2)) typedef struct jack diff --git a/audio/drivers/openal.c b/audio/drivers/openal.c index 2b51e819c1..1a746e5a6b 100644 --- a/audio/drivers/openal.c +++ b/audio/drivers/openal.c @@ -13,8 +13,8 @@ * If not, see . */ -#include "../../driver.h" -#include "../../general.h" +#include +#include #ifdef __APPLE__ #include @@ -24,13 +24,13 @@ #include #endif -#include -#include - #ifdef _WIN32 #include #endif +#include "../../driver.h" +#include "../../general.h" + #define BUFSIZE 1024 typedef struct al diff --git a/audio/drivers/opensl.c b/audio/drivers/opensl.c index 042006c730..08c396803d 100644 --- a/audio/drivers/opensl.c +++ b/audio/drivers/opensl.c @@ -14,15 +14,16 @@ * If not, see . */ -#include "../../driver.h" -#include "../../general.h" -#include - #include #ifdef ANDROID #include #endif +#include + +#include "../../driver.h" +#include "../../general.h" + /* Helper macros, COM-style. */ #define SLObjectItf_Realize(a, ...) ((*(a))->Realize(a, __VA_ARGS__)) #define SLObjectItf_GetInterface(a, ...) ((*(a))->GetInterface(a, __VA_ARGS__)) diff --git a/audio/drivers/oss.c b/audio/drivers/oss.c index c2b5feba92..8280a1ba16 100644 --- a/audio/drivers/oss.c +++ b/audio/drivers/oss.c @@ -12,14 +12,12 @@ * You should have received a copy of the GNU General Public License along with RetroArch. * If not, see . */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "../../driver.h" -#include "../../general.h" +#include #include +#include +#include +#include +#include #ifdef HAVE_OSS_BSD #include @@ -27,11 +25,14 @@ #include #endif -#include -#include -#include -#include -#include +#include + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "../../driver.h" +#include "../../general.h" #ifdef HAVE_OSS_BSD #define DEFAULT_OSS_DEV "/dev/audio" diff --git a/audio/drivers/ps3_audio.c b/audio/drivers/ps3_audio.c index f03dc08ad9..2775941931 100644 --- a/audio/drivers/ps3_audio.c +++ b/audio/drivers/ps3_audio.c @@ -14,14 +14,15 @@ * If not, see . */ -#include "../driver.h" -#include "../general.h" #include - #include + #include -#include "../ps3/sdk_defines.h" +#include "../driver.h" +#include "../general.h" + +#include "../../defines/ps3_defines.h" #define AUDIO_BLOCKS 8 #define AUDIO_CHANNELS 2 diff --git a/audio/drivers/psp1_audio.c b/audio/drivers/psp_audio.c similarity index 69% rename from audio/drivers/psp1_audio.c rename to audio/drivers/psp_audio.c index 6d42872452..b07d14903a 100644 --- a/audio/drivers/psp1_audio.c +++ b/audio/drivers/psp_audio.c @@ -15,14 +15,23 @@ * If not, see . */ +#include +#include + +#ifdef VITA +#include +#include +#include +#include +#else +#include +#include +#endif + #include "../../general.h" #include "../../driver.h" -#include -#include -#include - -typedef struct psp1_audio +typedef struct psp_audio { bool nonblocking; uint32_t* buffer; @@ -33,7 +42,7 @@ typedef struct psp1_audio volatile bool running; volatile uint16_t readPos; volatile uint16_t writePos; -} psp1_audio_t; +} psp_audio_t; #define AUDIO_OUT_COUNT 512u #define AUDIO_BUFFER_SIZE (1u<<13u) @@ -41,29 +50,43 @@ typedef struct psp1_audio static int audioMainLoop(SceSize args, void* argp) { - psp1_audio_t* psp = *((psp1_audio_t**)argp); + psp_audio_t* psp = *((psp_audio_t**)argp); +#ifdef VITA + 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 while (psp->running) { /* Get a non-volatile copy. */ uint16_t readPos = psp->readPos; + bool cond = ((uint16_t)(psp->writePos - readPos) & AUDIO_BUFFER_SIZE_MASK) + < (AUDIO_OUT_COUNT * 2); - if (((uint16_t)(psp->writePos - readPos) & AUDIO_BUFFER_SIZE_MASK) - < (AUDIO_OUT_COUNT * 2)) - sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, psp->zeroBuffer); - else +#ifdef VITA + sceAudioOutOutput(port, + cond ? psp->zeroBuffer : (psp->buffer + readPos)); +#else + sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, cond ? (psp->zeroBuffer) + : (psp->buffer + readPos)); +#endif + + if (!cond) { - sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, - psp->buffer + readPos); readPos += AUDIO_OUT_COUNT; readPos &= AUDIO_BUFFER_SIZE_MASK; psp->readPos = readPos; } } +#ifdef VITA + sceAudioOutReleasePort(port); +#else sceAudioSRCChRelease(); +#endif sceKernelExitThread(0); return 0; } @@ -71,7 +94,7 @@ static int audioMainLoop(SceSize args, void* argp) static void *psp_audio_init(const char *device, unsigned rate, unsigned latency) { - psp1_audio_t *psp = (psp1_audio_t*)calloc(1, sizeof(psp1_audio_t)); + psp_audio_t *psp = (psp_audio_t*)calloc(1, sizeof(psp_audio_t)); if (!psp) return NULL; @@ -91,12 +114,17 @@ static void *psp_audio_init(const char *device, psp->readPos = 0; psp->writePos = 0; psp->rate = rate; +#if defined(VITA) + psp->thread = sceKernelCreateThread + ("audioMainLoop", audioMainLoop, 0x10000100, 0x10000, 0, 0, NULL); +#else psp->thread = sceKernelCreateThread ("audioMainLoop", audioMainLoop, 0x08, 0x10000, 0, NULL); +#endif psp->nonblocking = false; psp->running = true; - sceKernelStartThread(psp->thread, sizeof(psp1_audio_t*), &psp); + sceKernelStartThread(psp->thread, sizeof(psp_audio_t*), &psp); return psp; } @@ -104,13 +132,16 @@ static void *psp_audio_init(const char *device, static void psp_audio_free(void *data) { SceUInt timeout = 100000; - psp1_audio_t* psp = (psp1_audio_t*)data; + psp_audio_t* psp = (psp_audio_t*)data; if(!psp) return; psp->running = false; - +#if defined(VITA) + sceKernelWaitThreadEnd(psp->thread, NULL, &timeout); +#else sceKernelWaitThreadEnd(psp->thread, &timeout); +#endif sceKernelDeleteThread(psp->thread); free(psp->buffer); @@ -121,7 +152,7 @@ static void psp_audio_free(void *data) static ssize_t psp_audio_write(void *data, const void *buf, size_t size) { uint16_t sampleCount; - psp1_audio_t* psp = (psp1_audio_t*)data; + psp_audio_t* psp = (psp_audio_t*)data; uint16_t writePos = psp->writePos; sampleCount= size / sizeof(uint32_t); @@ -153,7 +184,7 @@ static ssize_t psp_audio_write(void *data, const void *buf, size_t size) static bool psp_audio_alive(void *data) { - psp1_audio_t* psp = (psp1_audio_t*)data; + psp_audio_t* psp = (psp_audio_t*)data; if (!psp) return false; return psp->running; @@ -161,28 +192,63 @@ static bool psp_audio_alive(void *data) static bool psp_audio_stop(void *data) { - SceKernelThreadRunStatus runStatus; SceUInt timeout = 100000; - psp1_audio_t* psp = (psp1_audio_t*)data; + psp_audio_t* psp = (psp_audio_t*)data; + +#if defined(VITA) + SceKernelThreadInfo info; + + info.size = sizeof(SceKernelThreadInfo); + + if (sceKernelGetThreadInfo( + psp->thread, &info) < 0) /* Error */ + return false; + + if (info.status == PSP2_THREAD_STOPPED) + return false; + +#else + SceKernelThreadRunStatus runStatus; runStatus.size = sizeof(SceKernelThreadRunStatus); if (sceKernelReferThreadRunStatus( psp->thread, &runStatus) < 0) /* Error */ return false; + if (runStatus.status == PSP_THREAD_STOPPED) return false; +#endif + psp->running = false; +#if defined(VITA) + sceKernelWaitThreadEnd(psp->thread, NULL, &timeout); +#else sceKernelWaitThreadEnd(psp->thread, &timeout); +#endif return true; } static bool psp_audio_start(void *data) { + psp_audio_t* psp = (psp_audio_t*)data; + +#if defined(VITA) + SceKernelThreadInfo info; + + info.size = sizeof(SceKernelThreadInfo); + + if (sceKernelGetThreadInfo( + psp->thread, &info) < 0) /* Error */ + return false; + + if (info.status != PSP2_THREAD_STOPPED) + return false; + +#else SceKernelThreadRunStatus runStatus; - psp1_audio_t* psp = (psp1_audio_t*)data; runStatus.size = sizeof(SceKernelThreadRunStatus); @@ -192,16 +258,18 @@ static bool psp_audio_start(void *data) if (runStatus.status != PSP_THREAD_STOPPED) return false; +#endif + psp->running = true; - sceKernelStartThread(psp->thread, sizeof(psp1_audio_t*), &psp); + sceKernelStartThread(psp->thread, sizeof(psp_audio_t*), &psp); return true; } static void psp_audio_set_nonblock_state(void *data, bool toggle) { - psp1_audio_t* psp = (psp1_audio_t*)data; + psp_audio_t* psp = (psp_audio_t*)data; if (psp) psp->nonblocking = toggle; } @@ -215,7 +283,7 @@ static bool psp_audio_use_float(void *data) static size_t psp_write_avail(void *data) { /* TODO */ - psp1_audio_t* psp = (psp1_audio_t*)data; + psp_audio_t* psp = (psp_audio_t*)data; return AUDIO_BUFFER_SIZE - ((uint16_t) (psp->writePos - psp->readPos) & AUDIO_BUFFER_SIZE_MASK); } @@ -227,7 +295,7 @@ static size_t psp_buffer_size(void *data) } -audio_driver_t audio_psp1 = { +audio_driver_t audio_psp = { psp_audio_init, psp_audio_write, psp_audio_stop, @@ -236,7 +304,11 @@ audio_driver_t audio_psp1 = { psp_audio_set_nonblock_state, psp_audio_free, psp_audio_use_float, - "psp1", +#ifdef VITA + "vita", +#else + "psp", +#endif psp_write_avail, psp_buffer_size, }; diff --git a/audio/drivers/pulse.c b/audio/drivers/pulse.c index e0c2c08c31..8c2fb0f3a9 100644 --- a/audio/drivers/pulse.c +++ b/audio/drivers/pulse.c @@ -13,13 +13,16 @@ * If not, see . */ +#include +#include + +#include + +#include +#include #include "../../driver.h" #include "../../general.h" -#include -#include -#include -#include typedef struct { diff --git a/audio/drivers/roar.c b/audio/drivers/roar.c index 1ada97dc6d..02190232da 100644 --- a/audio/drivers/roar.c +++ b/audio/drivers/roar.c @@ -13,13 +13,16 @@ * If not, see . */ +#include +#include + +#include + +#include + +#include #include "../../driver.h" -#include -#include -#include -#include -#include #include "../../general.h" typedef struct diff --git a/audio/drivers/rsound.c b/audio/drivers/rsound.c index 1f13e5cf41..11a2dc901c 100644 --- a/audio/drivers/rsound.c +++ b/audio/drivers/rsound.c @@ -13,13 +13,15 @@ * If not, see . */ +#include + +#include + +#include +#include #include "../audio_driver.h" -#include #include "rsound.h" -#include -#include -#include typedef struct rsd { diff --git a/audio/drivers/sdl_audio.c b/audio/drivers/sdl_audio.c index 776dcb0a3b..bc43a5953a 100644 --- a/audio/drivers/sdl_audio.c +++ b/audio/drivers/sdl_audio.c @@ -13,22 +13,22 @@ * If not, see . */ - -#include "../../driver.h" -#include -#include -#include #include +#include +#include #include #include "SDL.h" #include "SDL_audio.h" -#include -#include "../../general.h" +#include +#include #include #include +#include "../../driver.h" +#include "../../general.h" + typedef struct sdl_audio { bool nonblock; diff --git a/audio/drivers/xaudio.cpp b/audio/drivers/xaudio.cpp index 3dd9173ffc..e8c715c891 100644 --- a/audio/drivers/xaudio.cpp +++ b/audio/drivers/xaudio.cpp @@ -14,14 +14,17 @@ * If not, see . */ -#include "../../driver.h" -#include #include +#include #include -#include -#include #include +#include + +#include + #include "xaudio.h" + +#include "../../driver.h" #include "../../general.h" typedef struct xaudio2 xaudio2_t; @@ -71,7 +74,7 @@ struct xaudio2 : public IXAudio2VoiceCallback IXAudio2SourceVoice *pSourceVoice; HANDLE hEvent; - volatile long buffers; + unsigned long volatile buffers; unsigned bufsize; unsigned bufptr; unsigned write_buffer; diff --git a/audio/drivers/xenon360_audio.c b/audio/drivers/xenon360_audio.c index 0ccdd941d2..51a4885f06 100644 --- a/audio/drivers/xenon360_audio.c +++ b/audio/drivers/xenon360_audio.c @@ -14,14 +14,16 @@ * If not, see . */ -#include "../../driver.h" #include #include -#include "../../general.h" -#include #include +#include + +#include "../../driver.h" +#include "../../general.h" + #define SOUND_FREQUENCY 48000 #define MAX_BUFFER 2048 diff --git a/audio/drivers_resampler/cc_resampler.c b/audio/drivers_resampler/cc_resampler.c index 7cdf7966a3..763fff04b9 100644 --- a/audio/drivers_resampler/cc_resampler.c +++ b/audio/drivers_resampler/cc_resampler.c @@ -15,7 +15,6 @@ /* Convoluted Cosine Resampler */ -#include "../audio_resampler_driver.h" #include #include #include @@ -23,6 +22,9 @@ #include #endif #include +#include + +#include "../audio_resampler_driver.h" /* Since SSE and NEON don't provide support for trigonometric functions * we approximate those with polynoms @@ -54,34 +56,6 @@ typedef struct rarch_CC_resampler void (*process)(void *re, struct resampler_data *data); } rarch_CC_resampler_t; -/* memalign() replacement functions - * copied from sinc.c and changed signature so no conflict - * happens when using griffin.c - * these functions should probably be moved to a common header - */ - -static void *memalign_alloc__(size_t boundary, size_t size) -{ - void **place; - uintptr_t addr = 0; - void *ptr = malloc(boundary + size + sizeof(uintptr_t)); - if (!ptr) - return NULL; - - addr = ((uintptr_t) - ptr + sizeof(uintptr_t) + boundary) - & ~(boundary - 1); - place = (void**)addr; - place[-1] = ptr; - - return (void*)addr; -} - -static void memalign_free__(void *ptr) -{ - void **p = (void**)ptr; - free(p[-1]); -} #ifdef _MIPS_ARCH_ALLEGREX static void resampler_CC_process(void *re_, struct resampler_data *data) @@ -177,12 +151,6 @@ done: data->output_frames = outp - (audio_frame_float_t*)data->data_out; } - -static void resampler_CC_free(void *re_) -{ - (void)re_; -} - static void *resampler_CC_init(const struct resampler_config *config, double bandwidth_mod, resampler_simd_mask_t mask) { @@ -206,25 +174,21 @@ static void *resampler_CC_init(const struct resampler_config *config, } #else - #if defined(__SSE__) #define CC_RESAMPLER_IDENT "SSE" static void resampler_CC_downsample(void *re_, struct resampler_data *data) { - __m128 vec_previous, vec_current; - float ratio, b; rarch_CC_resampler_t *re = (rarch_CC_resampler_t*)re_; audio_frame_float_t *inp = (audio_frame_float_t*)data->data_in; audio_frame_float_t *inp_max = (audio_frame_float_t*)(inp + data->input_frames); audio_frame_float_t *outp = (audio_frame_float_t*)data->data_out; + float ratio = 1.0 / data->ratio; + float b = data->ratio; /* cutoff frequency. */ - ratio = 1.0 / data->ratio; - b = data->ratio; /* cutoff frequency. */ - - vec_previous = _mm_loadu_ps((float*)&re->buffer[0]); - vec_current = _mm_loadu_ps((float*)&re->buffer[2]); + __m128 vec_previous = _mm_loadu_ps((float*)&re->buffer[0]); + __m128 vec_current = _mm_loadu_ps((float*)&re->buffer[2]); while (inp != inp_max) { @@ -527,27 +491,20 @@ static void resampler_CC_process(void *re_, struct resampler_data *data) re->process(re_, data); } -static void resampler_CC_free(void *re_) -{ - rarch_CC_resampler_t *re = (rarch_CC_resampler_t*)re_; - if (re) - memalign_free__(re); -} static void *resampler_CC_init(const struct resampler_config *config, double bandwidth_mod, resampler_simd_mask_t mask) { int i; rarch_CC_resampler_t *re = (rarch_CC_resampler_t*) - memalign_alloc__(32, sizeof(rarch_CC_resampler_t)); + memalign_alloc(32, sizeof(rarch_CC_resampler_t)); /* TODO: lookup if NEON support can be detected at * runtime and a funcptr set at runtime for either * C codepath or NEON codepath. This will help out * Android. */ (void)mask; - (void)config; - + (void)config; if (!re) return NULL; @@ -574,6 +531,16 @@ static void *resampler_CC_init(const struct resampler_config *config, } #endif +static void resampler_CC_free(void *re_) +{ +#ifndef _MIPS_ARCH_ALLEGREX + rarch_CC_resampler_t *re = (rarch_CC_resampler_t*)re_; + if (re) + memalign_free(re); +#endif + (void)re_; +} + rarch_resampler_t CC_resampler = { resampler_CC_init, resampler_CC_process, diff --git a/audio/drivers_resampler/sinc.c b/audio/drivers_resampler/sinc.c index a468c0ee8f..2ae4edf194 100644 --- a/audio/drivers_resampler/sinc.c +++ b/audio/drivers_resampler/sinc.c @@ -15,7 +15,6 @@ /* Bog-standard windowed SINC implementation. */ -#include "../audio_resampler_driver.h" #include #include #include @@ -24,7 +23,12 @@ #ifdef __SSE__ #include #endif + #include +#include +#include + +#include "../audio_resampler_driver.h" /* Rough SNR values for upsampling: * LOWEST: 40 dB @@ -113,44 +117,10 @@ typedef struct rarch_sinc_resampler float *main_buffer; } rarch_sinc_resampler_t; -static INLINE double sinc(double val) -{ - if (fabs(val) < 0.00001) - return 1.0; - return sin(val) / val; -} - #if defined(SINC_WINDOW_LANCZOS) -#define window_function(idx) (sinc(M_PI * (idx))) +#define window_function(idx) (lanzcos_window_function(idx)) #elif defined(SINC_WINDOW_KAISER) -/* Modified Bessel function of first order. - * Check Wiki for mathematical definition ... */ -static INLINE double besseli0(double x) -{ - unsigned i; - double sum = 0.0; - double factorial = 1.0; - double factorial_mult = 0.0; - double x_pow = 1.0; - double two_div_pow = 1.0; - double x_sqr = x * x; - - /* Approximate. This is an infinite sum. - * Luckily, it converges rather fast. */ - for (i = 0; i < 18; i++) - { - sum += x_pow * two_div_pow / (factorial * factorial); - - factorial_mult += 1.0; - x_pow *= x_sqr; - two_div_pow *= 0.25; - factorial *= factorial_mult; - } - - return sum; -} - -#define window_function(idx) (besseli0(SINC_WINDOW_KAISER_BETA * sqrt(1 - (idx) * (idx)))) +#define window_function(idx) (kaiser_window_function(idx, SINC_WINDOW_KAISER_BETA)) #else #error "No SINC window function defined." #endif @@ -212,30 +182,6 @@ static void init_sinc_table(rarch_sinc_resampler_t *resamp, double cutoff, } } -/* No memalign() for us on Win32 ... */ -static void *aligned_alloc__(size_t boundary, size_t size) -{ - void **place; - uintptr_t addr = 0; - void *ptr = malloc(boundary + size + sizeof(uintptr_t)); - - if (!ptr) - return NULL; - - addr = ((uintptr_t)ptr + sizeof(uintptr_t) + boundary) - & ~(boundary - 1); - place = (void**)addr; - place[-1] = ptr; - - return (void*)addr; -} - -static void aligned_free__(void *ptr) -{ - void **p = (void**)ptr; - free(p[-1]); -} - #if !(defined(__AVX__) && ENABLE_AVX) && !defined(__SSE__) static INLINE void process_sinc_C(rarch_sinc_resampler_t *resamp, float *out_buffer) @@ -462,7 +408,7 @@ static void resampler_sinc_free(void *re) { rarch_sinc_resampler_t *resampler = (rarch_sinc_resampler_t*)re; if (resampler) - aligned_free__(resampler->main_buffer); + memalign_free(resampler->main_buffer); free(resampler); } @@ -480,7 +426,7 @@ static void *resampler_sinc_new(const struct resampler_config *config, (void)config; re->taps = TAPS; - cutoff = CUTOFF; + cutoff = CUTOFF; /* Downsampling, must lower cutoff, and extend number of * taps accordingly to keep same stopband attenuation. */ @@ -503,8 +449,7 @@ static void *resampler_sinc_new(const struct resampler_config *config, #endif elems = phase_elems + 4 * re->taps; - re->main_buffer = (float*) - aligned_alloc__(128, sizeof(float) * elems); + re->main_buffer = (float*)memalign_alloc(128, sizeof(float) * elems); if (!re->main_buffer) goto error; diff --git a/audio/librsound.c b/audio/librsound.c index bf4abf3fcf..30f5e3d2bb 100644 --- a/audio/librsound.c +++ b/audio/librsound.c @@ -46,6 +46,7 @@ #define NETWORK_COMPAT_HEADERS 1 #endif + #ifdef NETWORK_COMPAT_HEADERS #include #include @@ -71,6 +72,7 @@ #include #include +#include /* **************************************************************************** @@ -748,22 +750,7 @@ static int64_t rsnd_get_time_usec(void) static void rsnd_sleep(int msec) { -#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) - sys_timer_usleep(1000 * msec); -#elif defined(PSP) - sceKernelDelayThread(1000 * msec); -#elif defined(_WIN32) - Sleep(msec); -#elif defined(XENON) - udelay(1000 * msec); -#elif defined(GEKKO) || defined(__PSL1GHT__) || defined(__QNX__) - usleep(1000 * msec); -#else - struct timespec tv = {0}; - tv.tv_sec = msec / 1000; - tv.tv_nsec = (msec % 1000) * 1000000; - nanosleep(&tv, NULL); -#endif + rarch_sleep(msec); } diff --git a/audio/test/Makefile b/audio/test/Makefile index f17af64da5..87db6b367e 100644 --- a/audio/test/Makefile +++ b/audio/test/Makefile @@ -11,18 +11,28 @@ TESTS := test-sinc-lowest \ test-cc \ test-snr-cc +LIBRETRO_COMM_DIR = ../../libretro-common + CFLAGS += -O3 -ffast-math -g -Wall -pedantic -march=native -std=gnu99 -CFLAGS += -DRESAMPLER_TEST -DRARCH_DUMMY_LOG -CFLAGS += -I../../libretro-common/include -I../../ +CFLAGS += -DRESAMPLER_TEST -DRARCH_DUMMY_LOG -DRARCH_INTERNAL +CFLAGS += -I$(LIBRETRO_COMM_DIR)/include -I../../ LDFLAGS += -lm +SHAREDOBJ += $(LIBRETRO_COMM_DIR)/memmap/memalign.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)/file/file_path.o \ + $(LIBRETRO_COMM_DIR)/compat/compat.o \ + $(LIBRETRO_COMM_DIR)/hash/rhash.o \ + all: $(TESTS) -resampler-sinc.o: ../audio_resampler_driver.c +resampler-sinc.o: ../audio_resampler_driver.c $(SHAREDOBJ) $(CC) -c -o $@ $< $(CFLAGS) -resampler-cc.o: ../audio_resampler_driver.c +resampler-cc.o: ../audio_resampler_driver.c $(SHAREDOBJ) $(CC) -c -o $@ $< $(CFLAGS) -DRESAMPLER_IDENT='"CC"' main-cc.o: main.c @@ -31,7 +41,7 @@ main-cc.o: main.c snr-cc.o: snr.c $(CC) -c -o $@ $< $(CFLAGS) -DRESAMPLER_IDENT='"CC"' -cc-resampler.o: ../resamplers/cc_resampler.c +cc-resampler.o: ../drivers_resampler/cc_resampler.c $(CC) -c -o $@ $< $(CFLAGS) sinc-lowest.o: ../drivers_resampler/sinc.c @@ -52,40 +62,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 resampler-sinc.o nearest.o +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 resampler-sinc.o nearest.o +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 resampler-sinc.o nearest.o +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 resampler-sinc.o nearest.o +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 resampler-sinc.o nearest.o +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 resampler-sinc.o nearest.o +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 resampler-sinc.o nearest.o +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 resampler-sinc.o nearest.o +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 resampler-sinc.o nearest.o +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 resampler-sinc.o nearest.o +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.o +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.o +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 diff --git a/audio/test/snr.c b/audio/test/snr.c index 01d91b16c3..8bc1c839f6 100644 --- a/audio/test/snr.c +++ b/audio/test/snr.c @@ -13,8 +13,6 @@ * If not, see . */ -#include "../resamplers/resampler.h" -#include "../audio_utils.h" #include #include #include @@ -23,6 +21,9 @@ #include #include +#include "../audio_resampler_driver.h" +#include "../audio_utils.h" + #ifndef RESAMPLER_IDENT #define RESAMPLER_IDENT "sinc" #endif diff --git a/autosave.c b/autosave.c index 7e2a599efb..1870788e61 100644 --- a/autosave.c +++ b/autosave.c @@ -14,12 +14,14 @@ * If not, see . */ -#include "autosave.h" -#include -#include -#include -#include #include +#include +#include + +#include + +#include + #include "general.h" struct autosave @@ -196,10 +198,10 @@ void lock_autosave(void) unsigned i; global_t *global = global_get_ptr(); - for (i = 0; i < global->num_autosave; i++) + for (i = 0; i < global->autosave.num; i++) { - if (global->autosave[i]) - autosave_lock(global->autosave[i]); + if (global->autosave.list[i]) + autosave_lock(global->autosave.list[i]); } } @@ -213,10 +215,10 @@ void unlock_autosave(void) unsigned i; global_t *global = global_get_ptr(); - for (i = 0; i < global->num_autosave; i++) + for (i = 0; i < global->autosave.num; i++) { - if (global->autosave[i]) - autosave_unlock(global->autosave[i]); + if (global->autosave.list[i]) + autosave_unlock(global->autosave.list[i]); } } diff --git a/camera/camera_driver.c b/camera/camera_driver.c index ed9ea5b1a4..11e015f11e 100644 --- a/camera/camera_driver.c +++ b/camera/camera_driver.c @@ -16,10 +16,9 @@ #include #include + #include "camera_driver.h" -#include "../driver.h" #include "../general.h" -#include "../system.h" static const camera_driver_t *camera_drivers[] = { #ifdef HAVE_V4L2 diff --git a/camera/drivers/video4linux2.c b/camera/drivers/video4linux2.c index 1f103f7a1e..aa8a837d75 100644 --- a/camera/drivers/video4linux2.c +++ b/camera/drivers/video4linux2.c @@ -27,12 +27,12 @@ #include #include #include -#include #include #include #include +#include #include #include diff --git a/cheats.c b/cheats.c index e34f360fa0..67adf333d6 100644 --- a/cheats.c +++ b/cheats.c @@ -14,22 +14,52 @@ * If not, see . */ -#include "cheats.h" -#include "general.h" -#include "runloop.h" -#include "dynamic.h" +#include +#include +#include + #include #include #include #include +#include "cheats.h" +#include "general.h" +#include "runloop.h" +#include "dynamic.h" + #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include +struct item_cheat +{ + char *desc; + bool state; + char *code; +}; + +struct cheat_manager +{ + struct item_cheat *cheats; + unsigned ptr; + unsigned size; + unsigned buf_size; +}; + +unsigned cheat_manager_get_buf_size(cheat_manager_t *handle) +{ + if (!handle) + return 0; + return handle->buf_size; +} + +unsigned cheat_manager_get_size(cheat_manager_t *handle) +{ + if (!handle) + return 0; + return handle->size; +} void cheat_manager_apply_cheats(cheat_manager_t *handle) { @@ -47,6 +77,14 @@ void cheat_manager_apply_cheats(cheat_manager_t *handle) } } +void cheat_manager_set_code(cheat_manager_t *handle, unsigned i, const char *str) +{ + if (!handle) + return; + handle->cheats[i].code = strdup(str); + handle->cheats[i].state = true; +} + /** * cheat_manager_save: * @path : Path to cheats file (relative path). @@ -264,6 +302,14 @@ void cheat_manager_update(cheat_manager_t *handle, unsigned handle_idx) RARCH_LOG("%s\n", msg); } +void cheat_manager_toggle_index(cheat_manager_t *handle, unsigned i) +{ + if (!handle) + return; + + handle->cheats[i].state = !handle->cheats[i].state; + cheat_manager_update(handle, i); +} void cheat_manager_toggle(cheat_manager_t *handle) { @@ -296,3 +342,24 @@ void cheat_manager_index_prev(cheat_manager_t *handle) cheat_manager_update(handle, handle->ptr); } + +const char *cheat_manager_get_code(cheat_manager_t *handle, unsigned i) +{ + if (!handle) + return NULL; + return handle->cheats[i].code; +} + +const char *cheat_manager_get_desc(cheat_manager_t *handle, unsigned i) +{ + if (!handle) + return NULL; + return handle->cheats[i].desc; +} + +bool cheat_manager_get_code_state(cheat_manager_t *handle, unsigned i) +{ + if (!handle) + return false; + return handle->cheats[i].state; +} diff --git a/cheats.h b/cheats.h index 51ae737174..e1d324fbdf 100644 --- a/cheats.h +++ b/cheats.h @@ -23,23 +23,10 @@ extern "C" { #endif -struct item_cheat -{ - char *desc; - bool state; - char *code; -}; - -struct cheat_manager -{ - struct item_cheat *cheats; - unsigned ptr; - unsigned size; - unsigned buf_size; -}; - typedef struct cheat_manager cheat_manager_t; +unsigned cheat_manager_get_size(cheat_manager_t *handle); + cheat_manager_t *cheat_manager_new(unsigned size); cheat_manager_t *cheat_manager_load(const char *path); @@ -56,6 +43,8 @@ bool cheat_manager_save(cheat_manager_t *handle, const char *path); bool cheat_manager_realloc(cheat_manager_t *handle, unsigned new_size); +void cheat_manager_set_code(cheat_manager_t *handle, unsigned index, const char *str); + void cheat_manager_free(cheat_manager_t *handle); void cheat_manager_index_next(cheat_manager_t *handle); @@ -68,6 +57,16 @@ void cheat_manager_apply_cheats(cheat_manager_t *handle); void cheat_manager_update(cheat_manager_t *handle, unsigned handle_idx); +void cheat_manager_toggle_index(cheat_manager_t *handle, unsigned i); + +unsigned cheat_manager_get_buf_size(cheat_manager_t *handle); + +const char *cheat_manager_get_desc(cheat_manager_t *handle, unsigned i); + +const char *cheat_manager_get_code(cheat_manager_t *handle, unsigned i); + +bool cheat_manager_get_code_state(cheat_manager_t *handle, unsigned i); + #ifdef __cplusplus } #endif diff --git a/command_event.c b/command_event.c index 5416538961..5c9efb1337 100644 --- a/command_event.c +++ b/command_event.c @@ -19,8 +19,6 @@ #include "general.h" #include "performance.h" -#include "runloop_data.h" -#include "runloop.h" #include "dynamic.h" #include "content.h" #include "screenshot.h" @@ -28,6 +26,7 @@ #include "retroarch.h" #include "dir_list_special.h" +#include "runloop_data.h" #include "configuration.h" #include "input/input_remapping.h" @@ -102,11 +101,11 @@ static void event_init_autosave(void) if (settings->autosave_interval < 1 || !global->savefiles) return; - if (!(global->autosave = (autosave_t**)calloc(global->savefiles->size, - sizeof(*global->autosave)))) + if (!(global->autosave.list = (autosave_t**)calloc(global->savefiles->size, + sizeof(*global->autosave.list)))) return; - global->num_autosave = global->savefiles->size; + global->autosave.num = global->savefiles->size; for (i = 0; i < global->savefiles->size; i++) { @@ -116,12 +115,12 @@ static void event_init_autosave(void) if (pretro_get_memory_size(type) <= 0) continue; - global->autosave[i] = autosave_new(path, + global->autosave.list[i] = autosave_new(path, pretro_get_memory_data(type), pretro_get_memory_size(type), settings->autosave_interval); - if (!global->autosave[i]) + if (!global->autosave.list[i]) RARCH_WARN("%s\n", msg_hash_to_str(MSG_AUTOSAVE_FAILED)); } } @@ -131,14 +130,14 @@ static void event_deinit_autosave(void) unsigned i; global_t *global = global_get_ptr(); - for (i = 0; i < global->num_autosave; i++) - autosave_free(global->autosave[i]); + for (i = 0; i < global->autosave.num; i++) + autosave_free(global->autosave.list[i]); - if (global->autosave) - free(global->autosave); - global->autosave = NULL; + if (global->autosave.list) + free(global->autosave.list); - global->num_autosave = 0; + global->autosave.list = NULL; + global->autosave.num = 0; } #endif @@ -147,7 +146,7 @@ static void event_save_files(void) unsigned i; global_t *global = global_get_ptr(); - if (!global->savefiles || !global->use_sram) + if (!global->savefiles || !global->sram.use) return; for (i = 0; i < global->savefiles->size; i++) @@ -256,60 +255,6 @@ static void event_disk_control_set_eject(bool new_state, bool print_log) } } -/** - * event_disk_control_append_image: - * @path : Path to disk image. - * - * Appends disk image to disk image list. - **/ -void event_disk_control_append_image(const char *path) -{ - unsigned new_idx; - char msg[PATH_MAX_LENGTH] = {0}; - struct retro_game_info info = {0}; - global_t *global = global_get_ptr(); - rarch_system_info_t *sysinfo = rarch_system_info_get_ptr(); - const struct retro_disk_control_callback *control = - sysinfo ? (const struct retro_disk_control_callback*)&sysinfo->disk_control - : NULL; - - if (!control) - return; - - event_disk_control_set_eject(true, false); - - control->add_image_index(); - new_idx = control->get_num_images(); - if (!new_idx) - return; - new_idx--; - - info.path = path; - control->replace_image_index(new_idx, &info); - - snprintf(msg, sizeof(msg), "%s: ", msg_hash_to_str(MSG_APPENDED_DISK)); - strlcat(msg, path, sizeof(msg)); - RARCH_LOG("%s\n", msg); - rarch_main_msg_queue_push(msg, 0, 180, true); - - event_command(EVENT_CMD_AUTOSAVE_DEINIT); - - /* TODO: Need to figure out what to do with subsystems case. */ - if (!*global->subsystem) - { - /* Update paths for our new image. - * If we actually use append_image, we assume that we - * started out in a single disk case, and that this way - * of doing it makes the most sense. */ - rarch_set_paths(path); - rarch_fill_pathnames(); - } - - event_command(EVENT_CMD_AUTOSAVE_INIT); - - event_disk_control_set_eject(false, false); -} - /** * event_check_disk_eject: * @control : Handle to disk control handle. @@ -377,6 +322,60 @@ static void event_disk_control_set_index(unsigned idx) } } +/** + * event_disk_control_append_image: + * @path : Path to disk image. + * + * Appends disk image to disk image list. + **/ +void event_disk_control_append_image(const char *path) +{ + unsigned new_idx; + char msg[PATH_MAX_LENGTH] = {0}; + struct retro_game_info info = {0}; + global_t *global = global_get_ptr(); + rarch_system_info_t *sysinfo = rarch_system_info_get_ptr(); + const struct retro_disk_control_callback *control = + sysinfo ? (const struct retro_disk_control_callback*)&sysinfo->disk_control + : NULL; + + if (!control) + return; + + event_disk_control_set_eject(true, false); + + control->add_image_index(); + new_idx = control->get_num_images(); + if (!new_idx) + return; + new_idx--; + + info.path = path; + control->replace_image_index(new_idx, &info); + + snprintf(msg, sizeof(msg), "%s: ", msg_hash_to_str(MSG_APPENDED_DISK)); + strlcat(msg, path, sizeof(msg)); + RARCH_LOG("%s\n", msg); + rarch_main_msg_queue_push(msg, 0, 180, true); + + event_command(EVENT_CMD_AUTOSAVE_DEINIT); + + /* TODO: Need to figure out what to do with subsystems case. */ + if (!*global->subsystem) + { + /* Update paths for our new image. + * If we actually use append_image, we assume that we + * started out in a single disk case, and that this way + * of doing it makes the most sense. */ + rarch_set_paths(path); + rarch_fill_pathnames(); + } + + event_command(EVENT_CMD_AUTOSAVE_INIT); + event_disk_control_set_index(new_idx); + event_disk_control_set_eject(false, false); +} + /** * event_check_disk_prev: * @control : Handle to disk control handle. @@ -534,7 +533,7 @@ static void event_deinit_core(bool reinit) { global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); - rarch_system_info_t *info = rarch_system_info_get_ptr(); + pretro_unload_game(); pretro_deinit(); @@ -543,14 +542,12 @@ static void event_deinit_core(bool reinit) /* per-core saves: restore the original path so the config is not affected */ if(settings->sort_savefiles_enable) - strlcpy(global->savefile_dir,orig_savefile_dir,sizeof(global->savefile_dir)); + strlcpy(global->dir.savefile, orig_savefile_dir, + sizeof(global->dir.savefile)); if(settings->sort_savestates_enable) - strlcpy(global->savestate_dir,orig_savestate_dir,sizeof(global->savestate_dir)); + strlcpy(global->dir.savestate, orig_savestate_dir, + sizeof(global->dir.savestate)); - /* restore system directory if it was set to */ - if(settings->system_in_content_dir && !strcmp(info->info.library_name,"No Core")) - settings->system_directory[0] = '\0'; - /* auto overrides: reload the original config */ if(global->overrides_active) { @@ -587,7 +584,7 @@ static bool event_load_save_files(void) if (!global) return false; - if (!global->savefiles || global->sram_load_disable) + if (!global->savefiles || global->sram.load_disable) return false; for (i = 0; i < global->savefiles->size; i++) @@ -606,14 +603,14 @@ static void event_load_auto_state(void) global_t *global = global_get_ptr(); #ifdef HAVE_NETPLAY - if (global->netplay_enable && !global->netplay_is_spectate) + if (global->netplay.enable && !global->netplay.is_spectate) return; #endif if (!settings->savestate_auto_load) return; - fill_pathname_noext(savestate_name_auto, global->savestate_name, + fill_pathname_noext(savestate_name_auto, global->name.savestate, ".auto", sizeof(savestate_name_auto)); if (!path_file_exists(savestate_name_auto)) @@ -649,9 +646,9 @@ static void event_set_savestate_auto_index(void) * /foo/path/content.state%d, where %d is the largest number available. */ - fill_pathname_basedir(state_dir, global->savestate_name, + fill_pathname_basedir(state_dir, global->name.savestate, sizeof(state_dir)); - fill_pathname_base(state_base, global->savestate_name, + fill_pathname_base(state_base, global->name.savestate, sizeof(state_base)); if (!(dir_list = dir_list_new_special(state_dir, DIR_LIST_PLAIN))) @@ -670,7 +667,7 @@ static void event_set_savestate_auto_index(void) continue; end = dir_elem + strlen(dir_elem); - while ((end > dir_elem) && isdigit(end[-1])) + while ((end > dir_elem) && isdigit((int)end[-1])) end--; idx = strtoul(end, NULL, 0); @@ -690,16 +687,16 @@ static bool event_init_content(void) /* No content to be loaded for dummy core, * just successfully exit. */ - if (global->core_type == CORE_TYPE_DUMMY) + if (global->inited.core.type == CORE_TYPE_DUMMY) return true; - if (!global->libretro_no_content) + if (!global->inited.core.no_content) rarch_fill_pathnames(); if (!init_content_file()) return false; - if (global->libretro_no_content) + if (global->inited.core.no_content) return true; event_set_savestate_auto_index(); @@ -723,9 +720,11 @@ static bool event_init_core(void) /* per-core saves: save the original path */ if(orig_savefile_dir[0] == '\0') - strlcpy(orig_savefile_dir,global->savefile_dir,sizeof(orig_savefile_dir)); + strlcpy(orig_savefile_dir, global->dir.savefile, + sizeof(orig_savefile_dir)); if(orig_savestate_dir[0] == '\0') - strlcpy(orig_savestate_dir,global->savestate_dir,sizeof(orig_savestate_dir)); + strlcpy(orig_savestate_dir, global->dir.savestate, + sizeof(orig_savestate_dir)); /* auto overrides: apply overrides */ if(settings->auto_overrides_enable) @@ -746,14 +745,14 @@ static bool event_init_core(void) config_load_remap(); /* per-core saves: reset redirection paths */ - if((settings->sort_savestates_enable || settings->sort_savefiles_enable) && !global->libretro_no_content) - set_paths_redirect(global->basename); + if((settings->sort_savestates_enable || settings->sort_savefiles_enable) && !global->inited.core.no_content) + set_paths_redirect(global->name.base); rarch_verify_api_version(); pretro_init(); - global->use_sram = (global->core_type == CORE_TYPE_PLAIN) && - !global->libretro_no_content; + global->sram.use = (global->inited.core.type == CORE_TYPE_PLAIN) && + !global->inited.core.no_content; if (!event_init_content()) return false; @@ -772,11 +771,11 @@ static bool event_save_auto_state(void) global_t *global = global_get_ptr(); if (!settings->savestate_auto_save || - (global->core_type == CORE_TYPE_DUMMY) || - global->libretro_no_content) + (global->inited.core.type == CORE_TYPE_DUMMY) || + global->inited.core.no_content) return false; - fill_pathname_noext(savestate_name_auto, global->savestate_name, + fill_pathname_noext(savestate_name_auto, global->name.savestate, ".auto", sizeof(savestate_name_auto)); ret = save_state(savestate_name_auto); @@ -821,8 +820,8 @@ static bool event_save_core_config(void) if (*settings->menu_config_directory) strlcpy(config_dir, settings->menu_config_directory, sizeof(config_dir)); - else if (*global->config_path) /* Fallback */ - fill_pathname_basedir(config_dir, global->config_path, + else if (*global->path.config) /* Fallback */ + fill_pathname_basedir(config_dir, global->path.config, sizeof(config_dir)); else { @@ -882,8 +881,8 @@ static bool event_save_core_config(void) if ((ret = config_save_file(config_path))) { - strlcpy(global->config_path, config_path, - sizeof(global->config_path)); + strlcpy(global->path.config, config_path, + sizeof(global->path.config)); snprintf(msg, sizeof(msg), "Saved new config to \"%s\".", config_path); RARCH_LOG("%s\n", msg); @@ -964,12 +963,12 @@ static void event_main_state(unsigned cmd) if (settings->state_slot > 0) snprintf(path, sizeof(path), "%s%d", - global->savestate_name, settings->state_slot); + global->name.savestate, settings->state_slot); else if (settings->state_slot < 0) fill_pathname_join_delim(path, - global->savestate_name, "auto", '.', sizeof(path)); + global->name.savestate, "auto", '.', sizeof(path)); else - strlcpy(path, global->savestate_name, sizeof(path)); + strlcpy(path, global->name.savestate, sizeof(path)); if (pretro_serialize_size()) { @@ -1003,11 +1002,11 @@ static bool event_update_system_info(struct retro_system_info *_info, libretro_get_system_info(settings->libretro, _info, load_no_content); #endif - if (!global->core_info) + if (!global->core_info.list) return false; - if (!core_info_list_get_info(global->core_info, - global->core_info_current, settings->libretro)) + if (!core_info_list_get_info(global->core_info.list, + global->core_info.current, settings->libretro)) return false; return true; @@ -1025,7 +1024,6 @@ bool event_command(enum event_command cmd) { unsigned i = 0; bool boolean = false; - runloop_t *runloop = rarch_main_get_ptr(); driver_t *driver = driver_get_ptr(); global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); @@ -1056,7 +1054,7 @@ bool event_command(enum event_command cmd) rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH, (void*)settings->libretro); rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, - (void*)global->fullpath); + (void*)global->path.fullpath); event_command(EVENT_CMD_QUIT); #endif break; @@ -1129,6 +1127,14 @@ bool event_command(enum event_command cmd) event_main_state(cmd); break; + case EVENT_CMD_SAVE_STATE_DECREMENT: + /* Slot -1 is (auto) slot. */ + if (settings->state_slot >= 0) + settings->state_slot--; + break; + case EVENT_CMD_SAVE_STATE_INCREMENT: + settings->state_slot++; + break; case EVENT_CMD_TAKE_SCREENSHOT: if (!take_screenshot()) return false; @@ -1142,7 +1148,7 @@ bool event_command(enum event_command cmd) #endif rarch_main_data_deinit(); - *global->fullpath = '\0'; + *global->path.fullpath = '\0'; rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT); } @@ -1189,6 +1195,12 @@ bool event_command(enum event_command cmd) event_command(EVENT_CMD_CHEATS_DEINIT); event_init_cheats(); break; + case EVENT_CMD_CHEATS_APPLY: + if (!global->cheat) + break; + + cheat_manager_apply_cheats(global->cheat); + break; case EVENT_CMD_REMAPPING_DEINIT: break; case EVENT_CMD_REMAPPING_INIT: @@ -1207,7 +1219,8 @@ bool event_command(enum event_command cmd) global->rewind.state = NULL; break; case EVENT_CMD_REWIND_INIT: - init_rewind(); + if (!driver->netplay_data) + init_rewind(); break; case EVENT_CMD_REWIND_TOGGLE: if (settings->rewind_enable) @@ -1334,9 +1347,9 @@ bool event_command(enum event_command cmd) if (!global) break; - if (global->core_info) - core_info_list_free(global->core_info); - global->core_info = NULL; + if (global->core_info.list) + core_info_list_free(global->core_info.list); + global->core_info.list = NULL; break; case EVENT_CMD_DATA_RUNLOOP_FREE: rarch_main_data_free(); @@ -1345,7 +1358,7 @@ bool event_command(enum event_command cmd) event_command(EVENT_CMD_CORE_INFO_DEINIT); if (*settings->libretro_directory) - global->core_info = core_info_list_new(); + global->core_info.list = core_info_list_new(); break; case EVENT_CMD_CORE_DEINIT: { @@ -1409,9 +1422,9 @@ bool event_command(enum event_command cmd) break; case EVENT_CMD_RESTART_RETROARCH: #if defined(GEKKO) && defined(HW_RVL) - fill_pathname_join(global->fullpath, g_defaults.core_dir, + fill_pathname_join(global->path.fullpath, g_defaults.dir.core, SALAMANDER_FILE, - sizeof(global->fullpath)); + sizeof(global->path.fullpath)); #endif if (driver->frontend_ctx && driver->frontend_ctx->set_fork) driver->frontend_ctx->set_fork(true, false); @@ -1426,7 +1439,7 @@ bool event_command(enum event_command cmd) #endif break; case EVENT_CMD_PAUSE_CHECKS: - if (runloop->is_paused) + if (rarch_main_is_paused()) { RARCH_LOG("%s\n", msg_hash_to_str(MSG_PAUSED)); event_command(EVENT_CMD_AUDIO_STOP); @@ -1441,15 +1454,15 @@ bool event_command(enum event_command cmd) } break; case EVENT_CMD_PAUSE_TOGGLE: - runloop->is_paused = !runloop->is_paused; + rarch_main_set_pause(!rarch_main_is_paused()); event_command(EVENT_CMD_PAUSE_CHECKS); break; case EVENT_CMD_UNPAUSE: - runloop->is_paused = false; + rarch_main_set_pause(false); event_command(EVENT_CMD_PAUSE_CHECKS); break; case EVENT_CMD_PAUSE: - runloop->is_paused = true; + rarch_main_set_pause(true); event_command(EVENT_CMD_PAUSE_CHECKS); break; case EVENT_CMD_MENU_PAUSE_LIBRETRO: @@ -1508,17 +1521,17 @@ bool event_command(enum event_command cmd) global->savefiles = NULL; break; case EVENT_CMD_SAVEFILES_INIT: - global->use_sram = global->use_sram && !global->sram_save_disable + global->sram.use = global->sram.use && !global->sram.save_disable #ifdef HAVE_NETPLAY - && (!driver->netplay_data || !global->netplay_is_client) + && (!driver->netplay_data || !global->netplay.is_client) #endif ; - if (!global->use_sram) + if (!global->sram.use) RARCH_LOG("%s\n", msg_hash_to_str(MSG_SRAM_WILL_NOT_BE_SAVED)); - if (global->use_sram) + if (global->sram.use) event_command(EVENT_CMD_AUTOSAVE_INIT); break; case EVENT_CMD_MSG_QUEUE_DEINIT: @@ -1707,6 +1720,9 @@ bool event_command(enum event_command cmd) case EVENT_CMD_VOLUME_DOWN: event_set_volume(-0.5f); break; + case EVENT_CMD_SET_FRAME_LIMIT: + rarch_main_set_frame_limit_last_time(); + break; case EVENT_CMD_NONE: default: return false; diff --git a/command_event.h b/command_event.h index 535746490b..ded995fb66 100644 --- a/command_event.h +++ b/command_event.h @@ -41,6 +41,8 @@ enum event_command 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, /* Initializes dummy core. */ @@ -149,6 +151,8 @@ enum event_command 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. */ @@ -196,6 +200,7 @@ enum event_command EVENT_CMD_REMAPPING_DEINIT, EVENT_CMD_VOLUME_UP, EVENT_CMD_VOLUME_DOWN, + EVENT_CMD_SET_FRAME_LIMIT, EVENT_CMD_DATA_RUNLOOP_FREE }; diff --git a/config.def.h b/config.def.h index 3566bb1e4f..a2cf0e87c7 100644 --- a/config.def.h +++ b/config.def.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2015 - 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. @@ -26,7 +26,7 @@ #include "config.h" #endif -enum +enum { VIDEO_GL = 0, VIDEO_XVIDEO, @@ -37,7 +37,7 @@ enum VIDEO_XENON360, VIDEO_XDK_D3D, VIDEO_PSP1, - VIDEO_VITA, + VIDEO_VITA2D, VIDEO_CTR, VIDEO_D3D9, VIDEO_VG, @@ -66,7 +66,7 @@ enum AUDIO_XENON360, AUDIO_WII, AUDIO_RWEBAUDIO, - AUDIO_PSP1, + AUDIO_PSP, AUDIO_CTR, AUDIO_NULL, @@ -143,8 +143,8 @@ enum #define VIDEO_DEFAULT_DRIVER VIDEO_D3D9 #elif defined(HAVE_VG) #define VIDEO_DEFAULT_DRIVER VIDEO_VG -#elif defined(SN_TARGET_PSP2) -#define VIDEO_DEFAULT_DRIVER VIDEO_VITA +#elif defined(HAVE_VITA2D) +#define VIDEO_DEFAULT_DRIVER VIDEO_VITA2D #elif defined(PSP) #define VIDEO_DEFAULT_DRIVER VIDEO_PSP1 #elif defined(_3DS) @@ -167,8 +167,8 @@ enum #define AUDIO_DEFAULT_DRIVER AUDIO_XENON360 #elif defined(GEKKO) #define AUDIO_DEFAULT_DRIVER AUDIO_WII -#elif defined(PSP) -#define AUDIO_DEFAULT_DRIVER AUDIO_PSP1 +#elif defined(PSP) || defined(VITA) +#define AUDIO_DEFAULT_DRIVER AUDIO_PSP #elif defined(_3DS) #define AUDIO_DEFAULT_DRIVER AUDIO_CTR #elif defined(HAVE_ALSA) && defined(HAVE_VIDEOCORE) @@ -231,7 +231,7 @@ enum #define INPUT_DEFAULT_DRIVER INPUT_DINPUT #elif defined(__CELLOS_LV2__) #define INPUT_DEFAULT_DRIVER INPUT_PS3 -#elif (defined(SN_TARGET_PSP2) || defined(PSP)) +#elif defined(PSP) || defined(VITA) #define INPUT_DEFAULT_DRIVER INPUT_PSP #elif defined(_3DS) #define INPUT_DEFAULT_DRIVER INPUT_CTR @@ -265,7 +265,7 @@ enum #define JOYPAD_DEFAULT_DRIVER JOYPAD_GX #elif defined(_XBOX) #define JOYPAD_DEFAULT_DRIVER JOYPAD_XDK -#elif defined(PSP) +#elif defined(PSP) || defined(VITA) #define JOYPAD_DEFAULT_DRIVER JOYPAD_PSP #elif defined(_3DS) #define JOYPAD_DEFAULT_DRIVER JOYPAD_CTR @@ -317,10 +317,10 @@ enum #define MENU_DEFAULT_DRIVER MENU_RMENU #elif defined(HAVE_RMENU_XUI) #define MENU_DEFAULT_DRIVER MENU_RMENU_XUI -#elif defined(MAC_OS_X_VERSION_10_6) -#define MENU_DEFAULT_DRIVER MENU_XMB #elif defined(IOS) || defined(ANDROID) || defined(__CELLOS_LV2__) #define MENU_DEFAULT_DRIVER MENU_GLUI +#elif defined(MAC_OS_X_VERSION_10_6) +#define MENU_DEFAULT_DRIVER MENU_XMB #else #define MENU_DEFAULT_DRIVER MENU_RGUI #endif @@ -373,7 +373,7 @@ static const float scale = 3.0; static const bool fullscreen = false; /* To use windowed mode or not when going fullscreen. */ -static const bool windowed_fullscreen = true; +static const bool windowed_fullscreen = true; /* Which monitor to prefer. 0 is any monitor, 1 and up selects * specific monitors, 1 being the first monitor. */ @@ -414,8 +414,8 @@ static const unsigned hard_sync_frames = 0; static const unsigned frame_delay = 0; /* Inserts a black frame inbetween frames. - * Useful for 120 Hz monitors who want to play 60 Hz material with eliminated - * ghosting. video_refresh_rate should still be configured as if it + * Useful for 120 Hz monitors who want to play 60 Hz material with eliminated + * ghosting. video_refresh_rate should still be configured as if it * is a 60 Hz monitor (divide refresh rate by 2). */ static bool black_frame_insertion = false; @@ -425,7 +425,7 @@ static bool black_frame_insertion = false; */ static unsigned swap_interval = 1; -/* Threaded video. Will possibly increase performance significantly +/* Threaded video. Will possibly increase performance significantly * at the cost of worse synchronization and latency. */ static const bool video_threaded = false; @@ -454,7 +454,7 @@ static const bool video_vfilter = true; static const bool video_smooth = true; /* On resize and fullscreen, rendering area will stay 4:3 */ -static const bool force_aspect = true; +static const bool force_aspect = true; /* Enable use of shaders. */ #ifdef RARCH_CONSOLE @@ -546,7 +546,7 @@ static const float font_size = 1.0f; static const float font_size = 32; #endif -/* Offset for where messages will be placed on-screen. +/* Offset for where messages will be placed on-screen. * Values are in range [0.0, 1.0]. */ static const float message_pos_offset_x = 0.05; #if defined(_XBOX1) @@ -574,21 +574,21 @@ static const bool font_enable = true; /* The accurate refresh rate of your monitor (Hz). * This is used to calculate audio input rate with the formula: - * audio_input_rate = game_input_rate * display_refresh_rate / + * audio_input_rate = game_input_rate * display_refresh_rate / * game_refresh_rate. * * If the implementation does not report any values, * NTSC defaults will be assumed for compatibility. * This value should stay close to 60Hz to avoid large pitch changes. - * If your monitor does not run at 60Hz, or something close to it, + * If your monitor does not run at 60Hz, or something close to it, * disable VSync, and leave this at its default. */ #if defined(RARCH_CONSOLE) -static const float refresh_rate = 60/1.001; +static const float refresh_rate = 60/1.001; #else -static const float refresh_rate = 59.95; +static const float refresh_rate = 59.95; #endif -/* Allow games to set rotation. If false, rotation requests are +/* Allow games to set rotation. If false, rotation requests are * honored, but ignored. * Used for setups where one manually rotates the monitor. */ static const bool allow_rotate = true; @@ -599,12 +599,16 @@ static const bool allow_rotate = true; static const bool audio_enable = true; /* Output samplerate. */ +#ifdef GEKKO +static const unsigned out_rate = 32000; +#else static const unsigned out_rate = 48000; +#endif /* Audio device (e.g. hw:0,0 or /dev/audio). If NULL, will use defaults. */ static const char *audio_device = NULL; -/* Desired audio latency in milliseconds. Might not be honored +/* Desired audio latency in milliseconds. Might not be honored * if driver can't provide given latency. */ static const int out_latency = 64; @@ -618,7 +622,7 @@ static const bool rate_control = true; static const bool rate_control = false; #endif -/* Rate control delta. Defines how much rate_control +/* Rate control delta. Defines how much rate_control * is allowed to adjust input rate. */ static const float rate_control_delta = 0.005; @@ -634,11 +638,11 @@ static const float audio_volume = 0.0; /* Enables displaying the current frames per second. */ static const bool fps_show = false; -/* Enables use of rewind. This will incur some memory footprint +/* Enables use of rewind. This will incur some memory footprint * depending on the save state buffer. */ static const bool rewind_enable = false; -/* The buffer size for the rewind buffer. This needs to be about +/* The buffer size for the rewind buffer. This needs to be about * 15-20MB per minute. Very game dependant. */ static const unsigned rewind_buffer_size = 20 << 20; /* 20MiB */ @@ -652,7 +656,7 @@ static const bool pause_nonactive = false; * It is measured in seconds. A value of 0 disables autosave. */ static const unsigned autosave_interval = 0; -/* When being client over netplay, use keybinds for +/* When being client over netplay, use keybinds for * user 1 rather than user 2. */ static const bool netplay_client_swap_input = true; @@ -660,15 +664,15 @@ static const bool netplay_client_swap_input = true; * This could potentially lead to buggy games. */ static const bool block_sram_overwrite = false; -/* When saving savestates, state index is automatically +/* When saving savestates, state index is automatically * incremented before saving. - * When the content is loaded, state index will be set + * When the content is loaded, state index will be set * to the highest existing value. */ static const bool savestate_auto_index = false; /* Automatically saves a savestate at the end of RetroArch's lifetime. * The path is $SRAM_PATH.auto. - * RetroArch will automatically load any savestate with this path on + * RetroArch will automatically load any savestate with this path on * startup if savestate_auto_load is set. */ static const bool savestate_auto_save = false; static const bool savestate_auto_load = false; @@ -677,10 +681,7 @@ static const bool savestate_auto_load = false; static const float slowmotion_ratio = 3.0; /* Maximum fast forward ratio. */ -static const float fastforward_ratio = 1.0; - -/* Throttle fast forward. */ -static const bool fastforward_ratio_throttle_enable = false; +static const float fastforward_ratio = 0.0; /* Enable stdin/network command interface. */ static const bool network_cmd_enable = false; @@ -726,7 +727,7 @@ static const unsigned turbo_duty_cycle = 3; * gamepads, plug-and-play style. */ static const bool input_autodetect_enable = true; -/* Show the input descriptors set by the core instead +/* Show the input descriptors set by the core instead * of the default ones. */ static const bool input_descriptor_label_show = true; diff --git a/configuration.c b/configuration.c index b03ff09d43..fe9f3a9ad2 100644 --- a/configuration.c +++ b/configuration.c @@ -25,7 +25,6 @@ #include "input/input_common.h" #include "input/input_keymaps.h" #include "input/input_remapping.h" -#include "configuration.h" #include "general.h" #include "system.h" @@ -114,8 +113,12 @@ const char *config_get_default_audio(void) return "ps3"; case AUDIO_WII: return "gx"; - case AUDIO_PSP1: - return "psp1"; + case AUDIO_PSP: +#ifdef VITA + return "vita"; +#else + return "psp"; +#endif case AUDIO_CTR: return "ctr"; case AUDIO_RWEBAUDIO: @@ -186,8 +189,8 @@ const char *config_get_default_video(void) return "d3d"; case VIDEO_PSP1: return "psp1"; - case VIDEO_VITA: - return "vita"; + case VIDEO_VITA2D: + return "vita2d"; case VIDEO_CTR: return "ctr"; case VIDEO_XVIDEO: @@ -231,7 +234,11 @@ const char *config_get_default_input(void) case INPUT_PS3: return "ps3"; case INPUT_PSP: +#ifdef VITA + return "vita"; +#else return "psp"; +#endif case INPUT_CTR: return "ctr"; case INPUT_SDL: @@ -287,7 +294,11 @@ const char *config_get_default_joypad(void) case JOYPAD_XDK: return "xdk"; case JOYPAD_PSP: +#ifdef VITA + return "vita"; +#else return "psp"; +#endif case JOYPAD_CTR: return "ctr"; case JOYPAD_DINPUT: @@ -455,7 +466,7 @@ static void config_set_defaults(void) #endif settings->multimedia.builtin_imageviewer_enable = true; settings->video.scale = scale; - settings->video.fullscreen = global->force_fullscreen + settings->video.fullscreen = global->force_fullscreen ? true : fullscreen; settings->video.windowed_fullscreen = windowed_fullscreen; settings->video.monitor_index = monitor_index; @@ -538,7 +549,6 @@ static void config_set_defaults(void) settings->rewind_granularity = rewind_granularity; settings->slowmotion_ratio = slowmotion_ratio; settings->fastforward_ratio = fastforward_ratio; - settings->fastforward_ratio_throttle_enable = fastforward_ratio_throttle_enable; settings->pause_nonactive = pause_nonactive; settings->autosave_interval = autosave_interval; @@ -641,11 +651,13 @@ static void config_set_defaults(void) settings->input.autodetect_enable = input_autodetect_enable; *settings->input.keyboard_layout = '\0'; + settings->osk.enable = true; + for (i = 0; i < MAX_USERS; i++) { settings->input.joypad_map[i] = i; settings->input.analog_dpad_mode[i] = ANALOG_DPAD_NONE; - if (!global->has_set_libretro_device[i]) + if (!global->has_set.libretro_device[i]) settings->input.libretro_device[i] = RETRO_DEVICE_JOYPAD; } @@ -655,21 +667,21 @@ static void config_set_defaults(void) /* Make sure settings from other configs carry over into defaults * for another config. */ - if (!global->has_set_save_path) - *global->savefile_dir = '\0'; - if (!global->has_set_state_path) - *global->savestate_dir = '\0'; + if (!global->has_set.save_path) + *global->dir.savefile = '\0'; + if (!global->has_set.state_path) + *global->dir.savestate = '\0'; *settings->libretro_info_path = '\0'; - if (!global->has_set_libretro_directory) + if (!global->has_set.libretro_directory) *settings->libretro_directory = '\0'; - if (!global->has_set_ups_pref) - global->ups_pref = false; - if (!global->has_set_bps_pref) - global->bps_pref = false; - if (!global->has_set_ips_pref) - global->ips_pref = false; + if (!global->has_set.ups_pref) + global->patch.ups_pref = false; + if (!global->has_set.bps_pref) + global->patch.bps_pref = false; + if (!global->has_set.ips_pref) + global->patch.ips_pref = false; *global->record.output_dir = '\0'; *global->record.config_dir = '\0'; @@ -728,117 +740,117 @@ static void config_set_defaults(void) global->console.sound.mode = SOUND_MODE_NORMAL; #endif - if (*g_defaults.wallpapers_dir) + if (*g_defaults.dir.wallpapers) strlcpy(settings->dynamic_wallpapers_directory, - g_defaults.wallpapers_dir, sizeof(settings->dynamic_wallpapers_directory)); - if (*g_defaults.remap_dir) + g_defaults.dir.wallpapers, sizeof(settings->dynamic_wallpapers_directory)); + if (*g_defaults.dir.remap) strlcpy(settings->input_remapping_directory, - g_defaults.remap_dir, sizeof(settings->input_remapping_directory)); - if (*g_defaults.extraction_dir) + g_defaults.dir.remap, sizeof(settings->input_remapping_directory)); + if (*g_defaults.dir.extraction) strlcpy(settings->extraction_directory, - g_defaults.extraction_dir, sizeof(settings->extraction_directory)); - if (*g_defaults.audio_filter_dir) + g_defaults.dir.extraction, sizeof(settings->extraction_directory)); + if (*g_defaults.dir.audio_filter) strlcpy(settings->audio.filter_dir, - g_defaults.audio_filter_dir, sizeof(settings->audio.filter_dir)); - if (*g_defaults.video_filter_dir) + g_defaults.dir.audio_filter, sizeof(settings->audio.filter_dir)); + if (*g_defaults.dir.video_filter) strlcpy(settings->video.filter_dir, - g_defaults.video_filter_dir, sizeof(settings->video.filter_dir)); - if (*g_defaults.assets_dir) + g_defaults.dir.video_filter, sizeof(settings->video.filter_dir)); + if (*g_defaults.dir.assets) strlcpy(settings->assets_directory, - g_defaults.assets_dir, sizeof(settings->assets_directory)); - if (*g_defaults.core_assets_dir) + g_defaults.dir.assets, sizeof(settings->assets_directory)); + if (*g_defaults.dir.core_assets) strlcpy(settings->core_assets_directory, - g_defaults.core_assets_dir, sizeof(settings->core_assets_directory)); - if (*g_defaults.playlist_dir) + g_defaults.dir.core_assets, sizeof(settings->core_assets_directory)); + if (*g_defaults.dir.playlist) strlcpy(settings->playlist_directory, - g_defaults.playlist_dir, sizeof(settings->playlist_directory)); - if (*g_defaults.core_dir) + g_defaults.dir.playlist, sizeof(settings->playlist_directory)); + if (*g_defaults.dir.core) fill_pathname_expand_special(settings->libretro_directory, - g_defaults.core_dir, sizeof(settings->libretro_directory)); - if (*g_defaults.core_path) - strlcpy(settings->libretro, g_defaults.core_path, + g_defaults.dir.core, sizeof(settings->libretro_directory)); + if (*g_defaults.path.core) + strlcpy(settings->libretro, g_defaults.path.core, sizeof(settings->libretro)); - if (*g_defaults.database_dir) - strlcpy(settings->content_database, g_defaults.database_dir, + if (*g_defaults.dir.database) + strlcpy(settings->content_database, g_defaults.dir.database, sizeof(settings->content_database)); - if (*g_defaults.cursor_dir) - strlcpy(settings->cursor_directory, g_defaults.cursor_dir, + if (*g_defaults.dir.cursor) + strlcpy(settings->cursor_directory, g_defaults.dir.cursor, sizeof(settings->cursor_directory)); - if (*g_defaults.cheats_dir) - strlcpy(settings->cheat_database, g_defaults.cheats_dir, + if (*g_defaults.dir.cheats) + strlcpy(settings->cheat_database, g_defaults.dir.cheats, sizeof(settings->cheat_database)); - if (*g_defaults.core_info_dir) + if (*g_defaults.dir.core_info) fill_pathname_expand_special(settings->libretro_info_path, - g_defaults.core_info_dir, sizeof(settings->libretro_info_path)); + g_defaults.dir.core_info, sizeof(settings->libretro_info_path)); #ifdef HAVE_OVERLAY - if (*g_defaults.overlay_dir) + if (*g_defaults.dir.overlay) { - fill_pathname_expand_special(global->overlay_dir, - g_defaults.overlay_dir, sizeof(global->overlay_dir)); + fill_pathname_expand_special(global->dir.overlay, + g_defaults.dir.overlay, sizeof(global->dir.overlay)); #ifdef RARCH_MOBILE if (!*settings->input.overlay) fill_pathname_join(settings->input.overlay, - global->overlay_dir, + global->dir.overlay, "gamepads/retropad/retropad.cfg", sizeof(settings->input.overlay)); #endif } - if (*g_defaults.osk_overlay_dir) + if (*g_defaults.dir.osk_overlay) { - fill_pathname_expand_special(global->osk_overlay_dir, - g_defaults.osk_overlay_dir, sizeof(global->osk_overlay_dir)); + fill_pathname_expand_special(global->dir.osk_overlay, + g_defaults.dir.osk_overlay, sizeof(global->dir.osk_overlay)); #ifdef RARCH_MOBILE - if (!*settings->input.overlay) + if (!*settings->osk.overlay) fill_pathname_join(settings->osk.overlay, - global->osk_overlay_dir, - "overlays/keyboards/US-101/US-101.cfg", + global->dir.osk_overlay, + "keyboards/modular-keyboard/opaque/big.cfg", sizeof(settings->osk.overlay)); #endif } else - strlcpy(global->osk_overlay_dir, - global->overlay_dir, sizeof(global->osk_overlay_dir)); + strlcpy(global->dir.osk_overlay, + global->dir.overlay, sizeof(global->dir.osk_overlay)); #endif #ifdef HAVE_MENU - if (*g_defaults.menu_config_dir) + if (*g_defaults.dir.menu_config) strlcpy(settings->menu_config_directory, - g_defaults.menu_config_dir, + g_defaults.dir.menu_config, sizeof(settings->menu_config_directory)); #endif - if (*g_defaults.shader_dir) + if (*g_defaults.dir.shader) fill_pathname_expand_special(settings->video.shader_dir, - g_defaults.shader_dir, sizeof(settings->video.shader_dir)); - if (*g_defaults.autoconfig_dir) + g_defaults.dir.shader, sizeof(settings->video.shader_dir)); + if (*g_defaults.dir.autoconfig) strlcpy(settings->input.autoconfig_dir, - g_defaults.autoconfig_dir, + g_defaults.dir.autoconfig, sizeof(settings->input.autoconfig_dir)); - if (!global->has_set_state_path && *g_defaults.savestate_dir) - strlcpy(global->savestate_dir, - g_defaults.savestate_dir, sizeof(global->savestate_dir)); - if (!global->has_set_save_path && *g_defaults.sram_dir) - strlcpy(global->savefile_dir, - g_defaults.sram_dir, sizeof(global->savefile_dir)); - if (*g_defaults.system_dir) + if (!global->has_set.state_path && *g_defaults.dir.savestate) + strlcpy(global->dir.savestate, + g_defaults.dir.savestate, sizeof(global->dir.savestate)); + if (!global->has_set.save_path && *g_defaults.dir.sram) + strlcpy(global->dir.savefile, + g_defaults.dir.sram, sizeof(global->dir.savefile)); + if (*g_defaults.dir.system) strlcpy(settings->system_directory, - g_defaults.system_dir, sizeof(settings->system_directory)); - if (*g_defaults.screenshot_dir) + g_defaults.dir.system, sizeof(settings->system_directory)); + if (*g_defaults.dir.screenshot) strlcpy(settings->screenshot_directory, - g_defaults.screenshot_dir, + g_defaults.dir.screenshot, sizeof(settings->screenshot_directory)); - if (*g_defaults.resampler_dir) + if (*g_defaults.dir.resampler) strlcpy(settings->resampler_directory, - g_defaults.resampler_dir, + g_defaults.dir.resampler, sizeof(settings->resampler_directory)); - if (*g_defaults.content_history_dir) + if (*g_defaults.dir.content_history) strlcpy(settings->content_history_directory, - g_defaults.content_history_dir, + g_defaults.dir.content_history, sizeof(settings->content_history_directory)); - if (*g_defaults.config_path) - fill_pathname_expand_special(global->config_path, - g_defaults.config_path, sizeof(global->config_path)); + if (*g_defaults.path.config) + fill_pathname_expand_special(global->path.config, + g_defaults.path.config, sizeof(global->path.config)); settings->config_save_on_exit = config_save_on_exit; @@ -1021,7 +1033,7 @@ static config_file_t *open_default_config_file(void) "retroarch.cfg", sizeof(skeleton_conf)); conf = config_file_new(skeleton_conf); if (conf) - RARCH_WARN("Using skeleton config \"%s\" as base for a new config file.\n", skeleton_conf); + RARCH_WARN("Config: using skeleton config \"%s\" as base for a new config file.\n", skeleton_conf); else conf = config_file_new(NULL); @@ -1041,7 +1053,7 @@ static config_file_t *open_default_config_file(void) return NULL; } - RARCH_WARN("Created new config file in: \"%s\".\n", conf_path); + RARCH_WARN("Config: Created new config file in: \"%s\".\n", conf_path); } } } @@ -1050,8 +1062,8 @@ static config_file_t *open_default_config_file(void) if (!conf) return NULL; - strlcpy(global->config_path, conf_path, - sizeof(global->config_path)); + strlcpy(global->path.config, conf_path, + sizeof(global->path.config)); return conf; } @@ -1176,7 +1188,7 @@ static bool config_load_file(const char *path, bool set_defaults) const char *extra_path = NULL; char tmp_str[PATH_MAX_LENGTH] = {0}; char tmp_append_path[PATH_MAX_LENGTH] = {0}; /* Don't destroy append_config_path. */ - int vp_width = 0, vp_height = 0, vp_x = 0, vp_y = 0; + int vp_width = 0, vp_height = 0, vp_x = 0, vp_y = 0; unsigned msg_color = 0; config_file_t *conf = NULL; settings_t *settings = config_get_ptr(); @@ -1199,17 +1211,17 @@ static bool config_load_file(const char *path, bool set_defaults) if (set_defaults) config_set_defaults(); - strlcpy(tmp_append_path, global->append_config_path, + strlcpy(tmp_append_path, global->path.append_config, sizeof(tmp_append_path)); extra_path = strtok_r(tmp_append_path, "|", &save); while (extra_path) { bool ret = false; - RARCH_LOG("Appending config \"%s\"\n", extra_path); + RARCH_LOG("Config: appending config \"%s\"\n", extra_path); ret = config_append_file(conf, extra_path); if (!ret) - RARCH_ERR("Failed to append config \"%s\"\n", extra_path); + RARCH_ERR("Config: failed to append config \"%s\"\n", extra_path); extra_path = strtok_r(NULL, "|", &save); } #if 0 @@ -1420,24 +1432,24 @@ static bool config_load_file(const char *path, bool set_defaults) snprintf(buf, sizeof(buf), "input_player%u_analog_dpad_mode", i + 1); CONFIG_GET_INT_BASE(conf, settings, input.analog_dpad_mode[i], buf); - if (!global->has_set_libretro_device[i]) + if (!global->has_set.libretro_device[i]) { snprintf(buf, sizeof(buf), "input_libretro_device_p%u", i + 1); CONFIG_GET_INT_BASE(conf, settings, input.libretro_device[i], buf); } } - if (!global->has_set_ups_pref) + if (!global->has_set.ups_pref) { - CONFIG_GET_BOOL_BASE(conf, global, ups_pref, "ups_pref"); + CONFIG_GET_BOOL_BASE(conf, global, patch.ups_pref, "ups_pref"); } - if (!global->has_set_bps_pref) + if (!global->has_set.bps_pref) { - CONFIG_GET_BOOL_BASE(conf, global, bps_pref, "bps_pref"); + CONFIG_GET_BOOL_BASE(conf, global, patch.bps_pref, "bps_pref"); } - if (!global->has_set_ips_pref) + if (!global->has_set.ips_pref) { - CONFIG_GET_BOOL_BASE(conf, global, ips_pref, "ips_pref"); + CONFIG_GET_BOOL_BASE(conf, global, patch.ips_pref, "ips_pref"); } /* Audio settings. */ @@ -1474,9 +1486,9 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_STRING_BASE(conf, settings, input.joypad_driver, "input_joypad_driver"); CONFIG_GET_STRING_BASE(conf, settings, input.keyboard_layout, "input_keyboard_layout"); - if (!global->has_set_libretro) + if (!global->has_set.libretro) config_get_path(conf, "libretro_path", settings->libretro, sizeof(settings->libretro)); - if (!global->has_set_libretro_directory) + if (!global->has_set.libretro_directory) config_get_path(conf, "libretro_directory", settings->libretro_directory, sizeof(settings->libretro_directory)); /* Safe-guard against older behavior. */ @@ -1551,7 +1563,7 @@ static bool config_load_file(const char *path, bool set_defaults) #endif CONFIG_GET_INT_BASE(conf, settings, libretro_log_level, "libretro_log_level"); - if (!global->has_set_verbosity) + if (!global->has_set.verbosity) CONFIG_GET_BOOL_BASE(conf, global, verbosity, "log_verbosity"); CONFIG_GET_BOOL_BASE(conf, global, perfcnt_enable, "perfcnt_enable"); @@ -1562,9 +1574,9 @@ static bool config_load_file(const char *path, bool set_defaults) sizeof(global->record.config_dir)); #ifdef HAVE_OVERLAY - config_get_path(conf, "overlay_directory", global->overlay_dir, sizeof(global->overlay_dir)); - if (!strcmp(global->overlay_dir, "default")) - *global->overlay_dir = '\0'; + config_get_path(conf, "overlay_directory", global->dir.overlay, sizeof(global->dir.overlay)); + if (!strcmp(global->dir.overlay, "default")) + *global->dir.overlay = '\0'; config_get_path(conf, "input_overlay", settings->input.overlay, sizeof(settings->input.overlay)); CONFIG_GET_BOOL_BASE(conf, settings, input.overlay_enable, "input_overlay_enable"); @@ -1573,9 +1585,9 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_FLOAT_BASE(conf, settings, input.overlay_opacity, "input_overlay_opacity"); CONFIG_GET_FLOAT_BASE(conf, settings, input.overlay_scale, "input_overlay_scale"); - config_get_path(conf, "osk_overlay_directory", global->osk_overlay_dir, sizeof(global->osk_overlay_dir)); - if (!strcmp(global->osk_overlay_dir, "default")) - *global->osk_overlay_dir = '\0'; + config_get_path(conf, "osk_overlay_directory", global->dir.osk_overlay, sizeof(global->dir.osk_overlay)); + if (!strcmp(global->dir.osk_overlay, "default")) + *global->dir.osk_overlay = '\0'; config_get_path(conf, "input_osk_overlay", settings->osk.overlay, sizeof(settings->osk.overlay)); CONFIG_GET_BOOL_BASE(conf, settings, osk.enable, "input_osk_overlay_enable"); @@ -1599,11 +1611,8 @@ static bool config_load_file(const char *path, bool set_defaults) /* Sanitize fastforward_ratio value - previously range was -1 * and up (with 0 being skipped) */ - if (settings->fastforward_ratio <= 0.0f) - settings->fastforward_ratio = 1.0f; - - CONFIG_GET_BOOL_BASE(conf, settings, fastforward_ratio_throttle_enable, - "fastforward_ratio_throttle_enable"); + if (settings->fastforward_ratio < 0.0f) + settings->fastforward_ratio = 0.0f; CONFIG_GET_BOOL_BASE(conf, settings, pause_nonactive, "pause_nonactive"); CONFIG_GET_INT_BASE(conf, settings, autosave_interval, "autosave_interval"); @@ -1635,58 +1644,58 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_BOOL_BASE(conf, settings, input.autodetect_enable, "input_autodetect_enable"); CONFIG_GET_PATH_BASE(conf, settings, input.autoconfig_dir, "joypad_autoconfig_dir"); - if (!global->has_set_username) + if (!global->has_set.username) CONFIG_GET_PATH_BASE(conf, settings, username, "netplay_nickname"); CONFIG_GET_INT_BASE(conf, settings, user_language, "user_language"); #ifdef HAVE_NETPLAY - if (!global->has_set_netplay_mode) - CONFIG_GET_BOOL_BASE(conf, global, netplay_is_spectate, + if (!global->has_set.netplay_mode) + CONFIG_GET_BOOL_BASE(conf, global, netplay.is_spectate, "netplay_spectator_mode_enable"); - if (!global->has_set_netplay_mode) - CONFIG_GET_BOOL_BASE(conf, global, netplay_is_client, "netplay_mode"); - if (!global->has_set_netplay_ip_address) - CONFIG_GET_PATH_BASE(conf, global, netplay_server, "netplay_ip_address"); - if (!global->has_set_netplay_delay_frames) - CONFIG_GET_INT_BASE(conf, global, netplay_sync_frames, "netplay_delay_frames"); - if (!global->has_set_netplay_ip_port) - CONFIG_GET_INT_BASE(conf, global, netplay_port, "netplay_ip_port"); + if (!global->has_set.netplay_mode) + CONFIG_GET_BOOL_BASE(conf, global, netplay.is_client, "netplay_mode"); + if (!global->has_set.netplay_ip_address) + CONFIG_GET_PATH_BASE(conf, global, netplay.server, "netplay_ip_address"); + if (!global->has_set.netplay_delay_frames) + CONFIG_GET_INT_BASE(conf, global, netplay.sync_frames, "netplay_delay_frames"); + if (!global->has_set.netplay_ip_port) + CONFIG_GET_INT_BASE(conf, global, netplay.port, "netplay_ip_port"); #endif CONFIG_GET_BOOL_BASE(conf, settings, config_save_on_exit, "config_save_on_exit"); - if (!global->has_set_save_path && + if (!global->has_set.save_path && config_get_path(conf, "savefile_directory", tmp_str, sizeof(tmp_str))) { if (!strcmp(tmp_str, "default")) - strlcpy(global->savefile_dir, g_defaults.sram_dir, - sizeof(global->savefile_dir)); + strlcpy(global->dir.savefile, g_defaults.dir.sram, + sizeof(global->dir.savefile)); else if (path_is_directory(tmp_str)) { - strlcpy(global->savefile_dir, tmp_str, - sizeof(global->savefile_dir)); - strlcpy(global->savefile_name, tmp_str, - sizeof(global->savefile_name)); - fill_pathname_dir(global->savefile_name, global->basename, - ".srm", sizeof(global->savefile_name)); + strlcpy(global->dir.savefile, tmp_str, + sizeof(global->dir.savefile)); + strlcpy(global->name.savefile, tmp_str, + sizeof(global->name.savefile)); + fill_pathname_dir(global->name.savefile, global->name.base, + ".srm", sizeof(global->name.savefile)); } else RARCH_WARN("savefile_directory is not a directory, ignoring ...\n"); } - if (!global->has_set_state_path && + if (!global->has_set.state_path && config_get_path(conf, "savestate_directory", tmp_str, sizeof(tmp_str))) { if (!strcmp(tmp_str, "default")) - strlcpy(global->savestate_dir, g_defaults.savestate_dir, - sizeof(global->savestate_dir)); + strlcpy(global->dir.savestate, g_defaults.dir.savestate, + sizeof(global->dir.savestate)); else if (path_is_directory(tmp_str)) { - strlcpy(global->savestate_dir, tmp_str, - sizeof(global->savestate_dir)); - strlcpy(global->savestate_name, tmp_str, - sizeof(global->savestate_name)); - fill_pathname_dir(global->savestate_name, global->basename, - ".state", sizeof(global->savestate_name)); + strlcpy(global->dir.savestate, tmp_str, + sizeof(global->dir.savestate)); + strlcpy(global->name.savestate, tmp_str, + sizeof(global->name.savestate)); + fill_pathname_dir(global->name.savestate, global->name.base, + ".state", sizeof(global->name.savestate)); } else RARCH_WARN("savestate_directory is not a directory, ignoring ...\n"); @@ -1704,7 +1713,7 @@ static bool config_load_file(const char *path, bool set_defaults) else { fill_pathname_resolve_relative(settings->content_history_path, - global->config_path, "content_history.lpl", + global->path.config, "content_history.lpl", sizeof(settings->content_history_path)); } } @@ -1712,17 +1721,14 @@ static bool config_load_file(const char *path, bool set_defaults) if (!config_get_path(conf, "system_directory", settings->system_directory, sizeof(settings->system_directory))) { - RARCH_WARN("system_directory is not set in config. Assuming system directory is same folder as game: \"%s\".\n", - settings->system_directory); - settings->system_in_content_dir = true; + RARCH_WARN("SYSTEM DIR is empty, assume CONTENT DIR\n"); + *settings->system_directory = '\0'; } if (!strcmp(settings->system_directory, "default")) { - RARCH_WARN("system_directory is not set in config. Assuming system directory is same folder as game: \"%s\".\n", - settings->system_directory); + RARCH_WARN("SYSTEM DIR is empty, assume CONTENT DIR\n"); *settings->system_directory = '\0'; - settings->system_in_content_dir = true; } config_read_keybinds_conf(conf); @@ -1752,12 +1758,12 @@ static void config_load_core_specific(void) settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - *global->core_specific_config_path = '\0'; + *global->path.core_specific_config = '\0'; if (!*settings->libretro) return; #ifdef HAVE_DYNAMIC - if (global->core_type == CORE_TYPE_DUMMY) + if (global->inited.core.type == CORE_TYPE_DUMMY) return; #endif @@ -1766,35 +1772,35 @@ static void config_load_core_specific(void) { path_resolve_realpath(settings->menu_config_directory, sizeof(settings->menu_config_directory)); - strlcpy(global->core_specific_config_path, + strlcpy(global->path.core_specific_config, settings->menu_config_directory, - sizeof(global->core_specific_config_path)); + sizeof(global->path.core_specific_config)); } else #endif { /* Use original config file's directory as a fallback. */ - fill_pathname_basedir(global->core_specific_config_path, - global->config_path, sizeof(global->core_specific_config_path)); + fill_pathname_basedir(global->path.core_specific_config, + global->path.config, sizeof(global->path.core_specific_config)); } - fill_pathname_dir(global->core_specific_config_path, settings->libretro, - ".cfg", sizeof(global->core_specific_config_path)); + fill_pathname_dir(global->path.core_specific_config, settings->libretro, + ".cfg", sizeof(global->path.core_specific_config)); if (settings->core_specific_config) { char tmp[PATH_MAX_LENGTH] = {0}; /* Toggle has_save_path to false so it resets */ - global->has_set_save_path = false; - global->has_set_state_path = false; + global->has_set.save_path = false; + global->has_set.state_path = false; strlcpy(tmp, settings->libretro, sizeof(tmp)); - RARCH_LOG("Loading core-specific config from: %s.\n", - global->core_specific_config_path); + RARCH_LOG("Config: loading core-specific config from: %s.\n", + global->path.core_specific_config); - if (!config_load_file(global->core_specific_config_path, true)) - RARCH_WARN("Core-specific config not found, reusing last config.\n"); + if (!config_load_file(global->path.core_specific_config, true)) + RARCH_WARN("Config: core-specific config not found, reusing last config.\n"); /* Force some parameters which are implied when using core specific configs. * Don't have the core config file overwrite the libretro path. */ @@ -1804,8 +1810,8 @@ static void config_load_core_specific(void) settings->core_specific_config = true; /* Reset save paths */ - global->has_set_save_path = true; - global->has_set_state_path = true; + global->has_set.save_path = true; + global->has_set.state_path = true; } } @@ -1842,8 +1848,8 @@ bool config_load_override(void) if (!info->info.library_name || !strcmp(info->info.library_name,"No Core")) return false; - RARCH_LOG("Game name: %s\n", global->basename); - RARCH_LOG("Core name: %s\n", info->info.library_name); + RARCH_LOG("Overrides: core name: %s\n", info->info.library_name); + RARCH_LOG("Overrides: game name: %s\n", global->name.base); if (!global || !settings ) { @@ -1852,22 +1858,22 @@ bool config_load_override(void) } /* Config directory: config_directory. - * Try config directory setting first, + * Try config directory setting first, * fallback to the location of the current configuration file. */ if (settings->menu_config_directory[0] != '\0') strlcpy(config_directory, settings->menu_config_directory, PATH_MAX_LENGTH); - else if (global->config_path[0] != '\0') - fill_pathname_basedir(config_directory, global->config_path, PATH_MAX_LENGTH); + else if (global->path.config[0] != '\0') + fill_pathname_basedir(config_directory, global->path.config, PATH_MAX_LENGTH); else { - RARCH_WARN("No config directory set under Settings > Path and retroarch.cfg not found.\n"); + RARCH_WARN("Overrides: no config directory set\n"); return false; } - RARCH_LOG("Config directory: %s\n", config_directory); + RARCH_LOG("Overrides: config directory: %s\n", config_directory); core_name = info->info.library_name; - game_name = path_basename(global->basename); + game_name = path_basename(global->name.base); /* Concatenate strings into full paths for core_path, game_path */ fill_pathname_join(core_path, config_directory, core_name, PATH_MAX_LENGTH); @@ -1886,15 +1892,15 @@ bool config_load_override(void) { if (settings->core_specific_config) { - RARCH_LOG("Can't use overrides in conjunction with per-core configs, disabling overrides\n"); + RARCH_LOG("Overrides: can't use overrides with with per-core configs, disabling overrides\n"); return false; } - RARCH_LOG("Core-specific overrides found at %s. Appending.\n", core_path); - strlcpy(global->append_config_path, core_path, sizeof(global->append_config_path)); + RARCH_LOG("Overrides: core-specific overrides found at %s\n", core_path); + strlcpy(global->path.append_config, core_path, sizeof(global->path.append_config)); should_append = true; } else - RARCH_LOG("No core-specific overrides found at %s.\n", core_path); + RARCH_LOG("Overrides: no core-specific overrides found at %s\n", core_path); /* Create a new config file from game_path */ new_conf = config_file_new(game_path); @@ -1902,19 +1908,19 @@ bool config_load_override(void) /* If a game override exists, add it's location to append_config_path */ if (new_conf) { - RARCH_LOG("Game-specific overrides found at %s. Appending.\n", game_path); + RARCH_LOG("Overrides: game-specific overrides found at %s\n", game_path); if (should_append) { - strlcat(global->append_config_path, "|", sizeof(global->append_config_path)); - strlcat(global->append_config_path, game_path, sizeof(global->append_config_path)); + strlcat(global->path.append_config, "|", sizeof(global->path.append_config)); + strlcat(global->path.append_config, game_path, sizeof(global->path.append_config)); } else - strlcpy(global->append_config_path, game_path, sizeof(global->append_config_path)); + strlcpy(global->path.append_config, game_path, sizeof(global->path.append_config)); should_append = true; } else - RARCH_LOG("No game-specific overrides found at %s.\n", game_path); + RARCH_LOG("Overrides: no game-specific overrides found at %s\n", game_path); /* Re-load the configuration with any overrides that might have been found */ if (should_append) @@ -1923,14 +1929,14 @@ bool config_load_override(void) if (settings->core_specific_config) { - RARCH_WARN("Can't use overrides in conjunction with per-core configs, disabling overrides\n"); + RARCH_LOG("Overrides: can't use overrides with with per-core configs, disabling overrides\n"); return false; } #ifdef HAVE_NETPLAY - if (global->netplay_enable) + if (global->netplay.enable) { - RARCH_WARN("Can't use overrides in conjunction with netplay, disabling overrides\n"); + RARCH_WARN("Overrides: can't use overrides in conjunction with netplay, disabling overrides\n"); return false; } #endif @@ -1939,19 +1945,19 @@ bool config_load_override(void) strlcpy(buf,settings->libretro,sizeof(buf)); /* Toggle has_save_path to false so it resets */ - global->has_set_save_path = false; - global->has_set_state_path = false; + global->has_set.save_path = false; + global->has_set.state_path = false; - if (config_load_file(global->config_path, false)) + if (config_load_file(global->path.config, false)) { - /* Restore the libretro_path we're using + /* Restore the libretro_path we're using * since it will be overwritten by the override when reloading. */ strlcpy(settings->libretro,buf,sizeof(settings->libretro)); rarch_main_msg_queue_push("Configuration override loaded", 1, 100, true); /* Reset save paths */ - global->has_set_save_path = true; - global->has_set_state_path = true; + global->has_set.save_path = true; + global->has_set.state_path = true; return true; } } @@ -1974,19 +1980,19 @@ bool config_load_override(void) if (!global) return false; - *global->append_config_path = '\0'; + *global->path.append_config = '\0'; /* Toggle has_save_path to false so it resets */ - global->has_set_save_path = false; - global->has_set_state_path = false; + global->has_set.save_path = false; + global->has_set.state_path = false; - if (config_load_file(global->config_path, false)) + if (config_load_file(global->path.config, false)) { - RARCH_LOG("Configuration overrides unloaded, original configuration reset\n"); + RARCH_LOG("Overrides: configuration overrides unloaded, original configuration restored\n"); /* Reset save paths */ - global->has_set_save_path = true; - global->has_set_state_path = true; + global->has_set.save_path = true; + global->has_set.state_path = true; return true; } @@ -2023,8 +2029,8 @@ bool config_load_remap(void) if (!info->info.library_name || !strcmp(info->info.library_name,"No Core")) return false; - RARCH_LOG("Game name: %s\n", global->basename); - RARCH_LOG("Core name: %s\n", info->info.library_name); + RARCH_LOG("Remaps: core name: %s\n", info->info.library_name); + RARCH_LOG("Remaps: game name: %s\n", global->name.base); /* Remap directory: remap_directory. * Try remap directory setting, no fallbacks defined */ @@ -2032,13 +2038,13 @@ bool config_load_remap(void) strlcpy(remap_directory, settings->input_remapping_directory, PATH_MAX_LENGTH); else { - RARCH_WARN("No remap directory set.\n"); + RARCH_WARN("Remaps: no remap directory set.\n"); return false; } - RARCH_LOG("Remap directory: %s\n", remap_directory); + RARCH_LOG("Remaps: remap directory: %s\n", remap_directory); core_name = info->info.library_name; - game_name = path_basename(global->basename); + game_name = path_basename(global->name.base); /* Concatenate strings into full paths for core_path, game_path */ fill_pathname_join(core_path, remap_directory, core_name, PATH_MAX_LENGTH); @@ -2055,7 +2061,7 @@ bool config_load_remap(void) /* If a game remap file exists, load it. */ if (new_conf) { - RARCH_LOG("Game-specific remap found at %s. Appending.\n", game_path); + RARCH_LOG("Remaps: game-specific remap found at %s\n", game_path); if (input_remapping_load_file(game_path)) { rarch_main_msg_queue_push("Game remap file loaded", 1, 100, true); @@ -2064,7 +2070,7 @@ bool config_load_remap(void) } else { - RARCH_LOG("No core-specific remap found at %s.\n", core_path); + RARCH_LOG("Remaps: no game-specific remap found at %s\n", game_path); *settings->input.remapping_path= '\0'; input_remapping_set_defaults(); } @@ -2077,7 +2083,7 @@ bool config_load_remap(void) /* If a core remap file exists, load it. */ if (new_conf) { - RARCH_LOG("Core-specific remap found at %s. Loading.\n", core_path); + RARCH_LOG("Remaps: core-specific remap found at %s\n", core_path); if (input_remapping_load_file(core_path)) { rarch_main_msg_queue_push("Core remap file loaded", 1, 100, true); @@ -2086,7 +2092,7 @@ bool config_load_remap(void) } else { - RARCH_LOG("No core-specific remap found at %s.\n", core_path); + RARCH_LOG("Remaps: no core-specific remap found at %s\n", core_path); *settings->input.remapping_path= '\0'; input_remapping_set_defaults(); } @@ -2099,25 +2105,25 @@ bool config_load_remap(void) static void parse_config_file(void) { global_t *global = global_get_ptr(); - bool ret = config_load_file((*global->config_path) - ? global->config_path : NULL, false); + bool ret = config_load_file((*global->path.config) + ? global->path.config : NULL, false); - if (*global->config_path) + if (*global->path.config) { - RARCH_LOG("Loading config from: %s.\n", global->config_path); + RARCH_LOG("Config: loading config from: %s.\n", global->path.config); } else { RARCH_LOG("Loading default config.\n"); - if (*global->config_path) - RARCH_LOG("Found default config: %s.\n", global->config_path); + if (*global->path.config) + RARCH_LOG("Config: found default config: %s.\n", global->path.config); } if (ret) return; - RARCH_ERR("Couldn't find config at path: \"%s\"\n", - global->config_path); + RARCH_ERR("Config: couldn't find config at path: \"%s\"\n", + global->path.config); } @@ -2290,12 +2296,12 @@ void config_load(void) global_t *global = global_get_ptr(); /* Flush out per-core configs before loading a new config. */ - if (*global->core_specific_config_path && + if (*global->path.core_specific_config && settings->config_save_on_exit && settings->core_specific_config) - config_save_file(global->core_specific_config_path); + config_save_file(global->path.core_specific_config); /* Flush out some states that could have been set by core environment variables */ - global->has_set_input_descriptors = false; + global->has_set.input_descriptors = false; if (!global->block_config_read) { @@ -2384,7 +2390,7 @@ bool config_save_autoconf_profile(const char *path, unsigned user) if(settings->input.vid[user] && settings->input.pid[user]) { config_set_int(conf, "input_vendor_id", settings->input.vid[user]); - config_set_int(conf, "input_product_id_id", settings->input.pid[user]); + config_set_int(conf, "input_product_id", settings->input.pid[user]); } for (i = 0; i < RARCH_FIRST_META_KEY; i++) @@ -2565,12 +2571,12 @@ bool config_save_file(const char *path) config_set_float(conf, "video_font_size", settings->video.font_size); config_set_bool(conf, "video_font_enable", settings->video.font_enable); - if (!global->has_set_ups_pref) - config_set_bool(conf, "ups_pref", global->ups_pref); - if (!global->has_set_bps_pref) - config_set_bool(conf, "bps_pref", global->bps_pref); - if (!global->has_set_ips_pref) - config_set_bool(conf, "ips_pref", global->ips_pref); + if (!global->has_set.ups_pref) + config_set_bool(conf, "ups_pref", global->patch.ups_pref); + if (!global->has_set.bps_pref) + config_set_bool(conf, "bps_pref", global->patch.bps_pref); + if (!global->has_set.ips_pref) + config_set_bool(conf, "ips_pref", global->patch.ips_pref); config_set_path(conf, "system_directory", *settings->system_directory ? @@ -2585,9 +2591,9 @@ bool config_save_file(const char *path) settings->resampler_directory); config_set_string(conf, "audio_resampler", settings->audio.resampler); config_set_path(conf, "savefile_directory", - *global->savefile_dir ? global->savefile_dir : "default"); + *global->dir.savefile ? global->dir.savefile : "default"); config_set_path(conf, "savestate_directory", - *global->savestate_dir ? global->savestate_dir : "default"); + *global->dir.savestate ? global->dir.savestate : "default"); config_set_path(conf, "video_shader_dir", *settings->video.shader_dir ? settings->video.shader_dir : "default"); @@ -2650,7 +2656,7 @@ bool config_save_file(const char *path) #ifdef HAVE_OVERLAY config_set_path(conf, "overlay_directory", - *global->overlay_dir ? global->overlay_dir : "default"); + *global->dir.overlay ? global->dir.overlay : "default"); config_set_path(conf, "input_overlay", settings->input.overlay); config_set_bool(conf, "input_overlay_enable", settings->input.overlay_enable); config_set_bool(conf, "input_overlay_enable_autopreferred", settings->input.overlay_enable_autopreferred); @@ -2661,7 +2667,7 @@ bool config_save_file(const char *path) settings->input.overlay_scale); config_set_path(conf, "osk_overlay_directory", - *global->osk_overlay_dir ? global->osk_overlay_dir : "default"); + *global->dir.osk_overlay ? global->dir.osk_overlay : "default"); config_set_path(conf, "input_osk_overlay", settings->osk.overlay); config_set_bool(conf, "input_osk_overlay_enable", settings->osk.enable); #endif @@ -2712,8 +2718,6 @@ bool config_save_file(const char *path) settings->history_list_enable); config_set_float(conf, "fastforward_ratio", settings->fastforward_ratio); - config_set_bool(conf, "fastforward_ratio_throttle_enable", - settings->fastforward_ratio_throttle_enable); config_set_float(conf, "slowmotion_ratio", settings->slowmotion_ratio); config_set_bool(conf, "config_save_on_exit", @@ -2723,11 +2727,11 @@ bool config_save_file(const char *path) #ifdef HAVE_NETPLAY config_set_bool(conf, "netplay_spectator_mode_enable", - global->netplay_is_spectate); - config_set_bool(conf, "netplay_mode", global->netplay_is_client); - config_set_string(conf, "netplay_ip_address", global->netplay_server); - config_set_int(conf, "netplay_ip_port", global->netplay_port); - config_set_int(conf, "netplay_delay_frames", global->netplay_sync_frames); + global->netplay.is_spectate); + config_set_bool(conf, "netplay_mode", global->netplay.is_client); + config_set_string(conf, "netplay_ip_address", global->netplay.server); + config_set_int(conf, "netplay_ip_port", global->netplay.port); + config_set_int(conf, "netplay_delay_frames", global->netplay.sync_frames); #endif config_set_string(conf, "netplay_nickname", settings->username); config_set_int(conf, "user_language", settings->user_language); diff --git a/configuration.h b/configuration.h index 08f14ddd06..895d9a7f3b 100644 --- a/configuration.h +++ b/configuration.h @@ -303,7 +303,6 @@ typedef struct settings char resampler_directory[PATH_MAX_LENGTH]; char screenshot_directory[PATH_MAX_LENGTH]; char system_directory[PATH_MAX_LENGTH]; - bool system_in_content_dir; char extraction_directory[PATH_MAX_LENGTH]; char playlist_directory[PATH_MAX_LENGTH]; @@ -315,7 +314,6 @@ typedef struct settings float slowmotion_ratio; float fastforward_ratio; - bool fastforward_ratio_throttle_enable; bool pause_nonactive; unsigned autosave_interval; diff --git a/content.c b/content.c index b1566d35fe..60c777be1b 100644 --- a/content.c +++ b/content.c @@ -73,7 +73,7 @@ static bool read_content_file(unsigned i, const char *path, void **buf, return true; /* Attempt to apply a patch. */ - if (!global->block_patch) + if (!global->patch.block_patch) patch_content(&ret_buf, length); #ifdef HAVE_ZLIB @@ -610,7 +610,7 @@ bool init_content_file(void) attr.i |= system->info.need_fullpath << 1; attr.i |= (!system->no_content) << 2; string_list_append(content, - (global->libretro_no_content && settings->core.set_supports_no_game_enable) ? "" : global->fullpath, attr); + (global->inited.core.no_content && settings->core.set_supports_no_game_enable) ? "" : global->path.fullpath, attr); } #ifdef HAVE_ZLIB @@ -655,7 +655,7 @@ bool init_content_file(void) ret = load_content(special, content); error: - global->content_is_init = (ret) ? true : false; + global->inited.content = (ret) ? true : false; if (content) string_list_free(content); diff --git a/core_info.c b/core_info.c index 5734936ff6..1f748ba46a 100644 --- a/core_info.c +++ b/core_info.c @@ -15,11 +15,10 @@ * If not, see . */ -#include "core_info.h" -#include "general.h" #include -#include "file_ext.h" #include + +#include "general.h" #include "dir_list_special.h" #include "config.def.h" diff --git a/core_options.c b/core_options.c index 8c22d67114..abf3a9c2e9 100644 --- a/core_options.c +++ b/core_options.c @@ -14,14 +14,16 @@ * If not, see . */ -#include "core_options.h" #include + #include #include #include #include #include +#include "core_options.h" + struct core_option { char *desc; diff --git a/cores/dynamic_dummy.c b/cores/dynamic_dummy.c index d0a691c96a..ffcdf493a0 100644 --- a/cores/dynamic_dummy.c +++ b/cores/dynamic_dummy.c @@ -15,11 +15,13 @@ * If not, see . */ -#include "../libretro.h" #include #include #include +#include "internal_cores.h" +#include "../libretro.h" + static uint16_t *frame_buf; void libretro_dummy_retro_init(void) diff --git a/cores/ffmpeg_core.c b/cores/ffmpeg_core.c index 590cd00065..89d5b9072c 100644 --- a/cores/ffmpeg_core.c +++ b/cores/ffmpeg_core.c @@ -36,6 +36,7 @@ extern "C" { #include #ifdef RARCH_INTERNAL +#include "internal_cores.h" #include "../libretro.h" #define CORE_PREFIX(s) libretro_ffmpeg_##s #else diff --git a/cores/image_core.c b/cores/image_core.c index 6c19c26740..cb7ef113b9 100644 --- a/cores/image_core.c +++ b/cores/image_core.c @@ -1,8 +1,9 @@ -#include #include +#include #include #include -#include +#include + #include #define STB_IMAGE_IMPLEMENTATION @@ -19,6 +20,7 @@ #include "stb_image.h" #ifdef RARCH_INTERNAL +#include "internal_cores.h" #include "../libretro.h" #define IMAGE_CORE_PREFIX(s) libretro_imageviewer_##s #else diff --git a/cores/libretro-test-gl/Makefile b/cores/libretro-test-gl/Makefile index b492df3a31..cf86540aa9 100644 --- a/cores/libretro-test-gl/Makefile +++ b/cores/libretro-test-gl/Makefile @@ -1,3 +1,6 @@ +ifneq ($(EMSCRIPTEN),) + platform = emscripten +endif ifeq ($(platform),) platform = unix @@ -38,7 +41,7 @@ ifeq ($(platform), unix) fpic := -fPIC SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined GL_LIB := -lGL -else ifeq ($(platform), osx) +else ifneq (,$(findstring osx,$(platform))) TARGET := $(TARGET_NAME)_libretro.dylib fpic := -fPIC SHARED := -dynamiclib @@ -49,9 +52,7 @@ else ifeq ($(platform), osx) endif OSXVER = `sw_vers -productVersion | cut -d. -f 2` OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"` - ifeq ($(OSX_LT_MAVERICKS),"YES") - fpic += -mmacosx-version-min=10.5 - endif + fpic += -mmacosx-version-min=10.1 else ifeq ($(platform), pi) TARGET := $(TARGET_NAME)_libretro.so fpic := -fPIC @@ -67,7 +68,7 @@ else ifeq ($(platform), ios) DEFINES := -DIOS CFLAGS += -DGLES $(DEFINES) CC = clang -arch armv7 -isysroot $(IOSSDK) -else ifeq ($(platform), qnx) +else ifneq (,$(findstring qnx,$(platform))) TARGET := $(TARGET_NAME)_libretro_qnx.so fpic := -fPIC SHARED := -shared -Wl,--version-script=link.T @@ -77,6 +78,7 @@ else ifeq ($(platform), qnx) AR = qcc -Vgcc_ntoarmv7le CFLAGS += -DGLES GL_LIB := -lGLESv2 + GLES := 1 else ifneq (,$(findstring armv,$(platform))) CC = gcc TARGET := $(TARGET_NAME)_libretro.so @@ -103,6 +105,9 @@ else ifneq (,$(findstring hardfloat,$(platform))) CFLAGS += -mfloat-abi=hard endif CFLAGS += -DARM +# emscripten +else ifeq ($(platform), emscripten) + TARGET := $(TARGET_NAME)_libretro_emscripten.bc else CC = gcc TARGET := $(TARGET_NAME)_libretro.dll @@ -117,10 +122,10 @@ else CFLAGS += -O3 endif -ifeq ($(platform), qnx) - CFLAGS += -Wc,-std=gnu99 +ifneq (,$(findstring qnx,$(platform))) + CFLAGS += -Wc,-std=c99 else - CFLAGS += -std=gnu99 + CFLAGS += -std=gnu99 endif OBJECTS := libretro-test.o ../../libretro-common/glsym/rglgen.o diff --git a/cores/libretro-test-gl/libretro-test.c b/cores/libretro-test-gl/libretro-test.c index 4d900ce6a5..1a9b158ff2 100644 --- a/cores/libretro-test-gl/libretro-test.c +++ b/cores/libretro-test-gl/libretro-test.c @@ -1,15 +1,16 @@ -#include "../../libretro.h" +#include #include +#include #include #include -#include -#include + +#include + +#include "../../libretro.h" #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) static struct retro_hw_render_callback hw_render; -#include - #if defined(HAVE_PSGL) #define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES #define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES @@ -50,16 +51,6 @@ static GLuint fbo; static GLuint rbo_color, rbo_depth_stencil; #endif -static const GLfloat vertex_data[] = { - -0.5, -0.5, - 0.5, -0.5, - -0.5, 0.5, - 0.5, 0.5, - 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 0.0, 1.0, - 0.0, 1.0, 1.0, 1.0, - 1.0, 0.0, 1.0, 1.0, -}; #ifdef CORE static const char *vertex_shader[] = { @@ -182,6 +173,17 @@ static void init_multisample(unsigned samples) static void setup_vao(void) { + static const GLfloat vertex_data[] = { + -0.5, -0.5, + 0.5, -0.5, + -0.5, 0.5, + 0.5, 0.5, + 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 0.0, 1.0, + 0.0, 1.0, 1.0, 1.0, + 1.0, 0.0, 1.0, 1.0, + }; + #ifdef CORE glGenVertexArrays(1, &vao); #endif diff --git a/cores/libretro-test/Makefile b/cores/libretro-test/Makefile index 25fbd88f5b..8fee362f91 100644 --- a/cores/libretro-test/Makefile +++ b/cores/libretro-test/Makefile @@ -1,8 +1,3 @@ - -ifneq ($(EMSCRIPTEN),) - platform = emscripten -endif - ifeq ($(platform),) platform = unix ifeq ($(shell uname -a),) @@ -16,6 +11,21 @@ else ifneq ($(findstring win,$(shell uname -a)),) 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 := test LIBM = -lm @@ -28,7 +38,7 @@ else ifeq ($(platform), linux-portable) fpic := -fPIC -nostdlib SHARED := -shared -Wl,--version-script=link.T LIBM := -else ifeq ($(platform), osx) +else ifneq (,$(findstring osx,$(platform))) TARGET := $(TARGET_NAME)_libretro.dylib fpic := -fPIC SHARED := -dynamiclib @@ -38,14 +48,20 @@ else ifeq ($(platform), ios) SHARED := -dynamiclib DEFINES := -DIOS CC = clang -arch armv7 -isysroot $(IOSSDK) -else ifeq ($(platform), qnx) +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.so + 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 @@ -63,8 +79,8 @@ endif OBJECTS := libretro-test.o CFLAGS += -Wall -pedantic $(fpic) -ifeq ($(platform), qnx) -CFLAGS += -Wc,-std=gnu99 +ifneq (,$(findstring qnx,$(platform))) +CFLAGS += -Wc,-std=c99 else CFLAGS += -std=gnu99 endif @@ -72,7 +88,11 @@ endif 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 $@ $< diff --git a/cores/libretro-test/libretro-test.c b/cores/libretro-test/libretro-test.c index 6e70d7d1d7..1b336a14dd 100644 --- a/cores/libretro-test/libretro-test.c +++ b/cores/libretro-test/libretro-test.c @@ -1,13 +1,19 @@ -#include "../../libretro.h" +#include #include +#include +#include #include #include -#include -#include -#include + +#include "../../libretro.h" + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif static uint16_t *frame_buf; static struct retro_log_callback logging; +static retro_log_printf_t log_cb; static bool use_audio_cb; static float last_aspect; static float last_sample_rate; @@ -39,7 +45,7 @@ unsigned retro_api_version(void) void retro_set_controller_port_device(unsigned port, unsigned device) { - logging.log(RETRO_LOG_INFO, "Plugging device %u into port %u.\n", device, port); + log_cb(RETRO_LOG_INFO, "Plugging device %u into port %u.\n", device, port); } void retro_get_system_info(struct retro_system_info *info) @@ -112,8 +118,10 @@ void retro_set_environment(retro_environment_t cb) bool no_content = true; cb(RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME, &no_content); - if (!cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &logging)) - logging.log = fallback_log; + if (cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &logging)) + log_cb = logging.log; + else + log_cb = fallback_log; static const struct retro_subsystem_memory_info mem1[] = {{ "ram1", 0x400 }, { "ram2", 0x401 }}; static const struct retro_subsystem_memory_info mem2[] = {{ "ram3", 0x402 }, { "ram4", 0x403 }}; @@ -197,10 +205,10 @@ static void update_input(void) dir_x++; if (input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0, RETROK_RETURN)) - logging.log(RETRO_LOG_INFO, "Return key is pressed!\n"); + log_cb(RETRO_LOG_INFO, "Return key is pressed!\n"); if (input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0, RETROK_x)) - logging.log(RETRO_LOG_INFO, "x key is pressed!\n"); + log_cb(RETRO_LOG_INFO, "x key is pressed!\n"); int16_t mouse_x = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X); int16_t mouse_y = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y); @@ -210,19 +218,19 @@ static void update_input(void) bool mouse_up = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELUP); bool mouse_middle = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_MIDDLE); if (mouse_x) - logging.log(RETRO_LOG_INFO, "Mouse X: %d\n", mouse_x); + log_cb(RETRO_LOG_INFO, "Mouse X: %d\n", mouse_x); if (mouse_y) - logging.log(RETRO_LOG_INFO, "Mouse Y: %d\n", mouse_y); + log_cb(RETRO_LOG_INFO, "Mouse Y: %d\n", mouse_y); if (mouse_l) - logging.log(RETRO_LOG_INFO, "Mouse L pressed.\n"); + log_cb(RETRO_LOG_INFO, "Mouse L pressed.\n"); if (mouse_r) - logging.log(RETRO_LOG_INFO, "Mouse R pressed.\n"); + log_cb(RETRO_LOG_INFO, "Mouse R pressed.\n"); if (mouse_down) - logging.log(RETRO_LOG_INFO, "Mouse wheeldown pressed.\n"); + log_cb(RETRO_LOG_INFO, "Mouse wheeldown pressed.\n"); if (mouse_up) - logging.log(RETRO_LOG_INFO, "Mouse wheelup pressed.\n"); + log_cb(RETRO_LOG_INFO, "Mouse wheelup pressed.\n"); if (mouse_middle) - logging.log(RETRO_LOG_INFO, "Mouse middle pressed.\n"); + log_cb(RETRO_LOG_INFO, "Mouse middle pressed.\n"); mouse_rel_x += mouse_x; mouse_rel_y += mouse_y; @@ -239,7 +247,7 @@ static void update_input(void) int16_t pointer_x = input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X); int16_t pointer_y = input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y); if (pointer_pressed) - logging.log(RETRO_LOG_INFO, "Pointer: (%6d, %6d).\n", pointer_x, pointer_y); + log_cb(RETRO_LOG_INFO, "Pointer: (%6d, %6d).\n", pointer_x, pointer_y); dir_x += input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 5000; dir_y += input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 5000; @@ -258,11 +266,11 @@ static void update_input(void) bool start = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START); bool select = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT); if (old_start != start) - logging.log(RETRO_LOG_INFO, "Strong rumble: %s.\n", start ? "ON": "OFF"); + log_cb(RETRO_LOG_INFO, "Strong rumble: %s.\n", start ? "ON": "OFF"); rumble.set_rumble_state(0, RETRO_RUMBLE_STRONG, start * strength_strong); if (old_select != select) - logging.log(RETRO_LOG_INFO, "Weak rumble: %s.\n", select ? "ON": "OFF"); + log_cb(RETRO_LOG_INFO, "Weak rumble: %s.\n", select ? "ON": "OFF"); rumble.set_rumble_state(0, RETRO_RUMBLE_WEAK, select * strength_weak); old_start = start; @@ -298,13 +306,13 @@ static void check_variables(void) struct retro_variable var = {0}; var.key = "test_opt0"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - logging.log(RETRO_LOG_INFO, "Key -> Val: %s -> %s.\n", var.key, var.value); + log_cb(RETRO_LOG_INFO, "Key -> Val: %s -> %s.\n", var.key, var.value); var.key = "test_opt1"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - logging.log(RETRO_LOG_INFO, "Key -> Val: %s -> %s.\n", var.key, var.value); + log_cb(RETRO_LOG_INFO, "Key -> Val: %s -> %s.\n", var.key, var.value); var.key = "test_opt2"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - logging.log(RETRO_LOG_INFO, "Key -> Val: %s -> %s.\n", var.key, var.value); + log_cb(RETRO_LOG_INFO, "Key -> Val: %s -> %s.\n", var.key, var.value); float last = last_aspect; float last_rate = last_sample_rate; @@ -323,7 +331,7 @@ static void check_variables(void) ret = environ_cb(RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO, &info); else // If only aspect changed, take the simpler path. ret = environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &info.geometry); - logging.log(RETRO_LOG_INFO, "SET_SYSTEM_AV_INFO/SET_GEOMETRY = %u.\n", ret); + log_cb(RETRO_LOG_INFO, "SET_SYSTEM_AV_INFO/SET_GEOMETRY = %u.\n", ret); } } @@ -358,7 +366,7 @@ void retro_run(void) static void keyboard_cb(bool down, unsigned keycode, uint32_t character, uint16_t mod) { - logging.log(RETRO_LOG_INFO, "Down: %s, Code: %d, Char: %u, Mod: %u.\n", + log_cb(RETRO_LOG_INFO, "Down: %s, Code: %d, Char: %u, Mod: %u.\n", down ? "yes" : "no", keycode, character, mod); } @@ -378,16 +386,16 @@ bool retro_load_game(const struct retro_game_info *info) enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) { - logging.log(RETRO_LOG_INFO, "RGB565 is not supported.\n"); + log_cb(RETRO_LOG_INFO, "RGB565 is not supported.\n"); return false; } struct retro_keyboard_callback cb = { keyboard_cb }; environ_cb(RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK, &cb); if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble)) - logging.log(RETRO_LOG_INFO, "Rumble environment supported.\n"); + log_cb(RETRO_LOG_INFO, "Rumble environment supported.\n"); else - logging.log(RETRO_LOG_INFO, "Rumble environment not supported.\n"); + log_cb(RETRO_LOG_INFO, "Rumble environment not supported.\n"); struct retro_audio_callback audio_cb = { audio_callback, audio_set_state }; use_audio_cb = environ_cb(RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK, &audio_cb); diff --git a/cores/stb_image.h b/cores/stb_image.h index f1ca600639..4afd0433a0 100644 --- a/cores/stb_image.h +++ b/cores/stb_image.h @@ -1179,6 +1179,10 @@ STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } #endif +/* forward declarations */ +STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); +STBIDEF void stbi_hdr_to_ldr_scale(float scale); + STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; } STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; } diff --git a/ctr/2048.png b/ctr/2048.png new file mode 100644 index 0000000000..d0e98e66dc Binary files /dev/null and b/ctr/2048.png differ diff --git a/ctr/Makefile.cores b/ctr/Makefile.cores new file mode 100644 index 0000000000..b973716d2b --- /dev/null +++ b/ctr/Makefile.cores @@ -0,0 +1,134 @@ + + +ifeq ($(LIBRETRO), gambatte) + APP_TITLE = Gambatte Libretro + #APP_DESCRIPTION = Retroarch 3DS + #APP_AUTHOR = Team Libretro + APP_PRODUCT_CODE = RARCH-GAMBATTE + APP_UNIQUE_ID = 0xBAC01 + APP_ICON = ctr/gambatte.png + #APP_BANNER = ctr/libretro_banner.png + #APP_AUDIO = ctr/silent.wav + +else ifeq ($(LIBRETRO), gpsp) + APP_TITLE = gpSP Libretro + #APP_DESCRIPTION = Retroarch 3DS + #APP_AUTHOR = Team Libretro + APP_PRODUCT_CODE = RARCH-GPSP + APP_UNIQUE_ID = 0xBAC02 + APP_ICON = ctr/gpsp.png + #APP_BANNER = ctr/libretro_banner.png + #APP_AUDIO = ctr/silent.wav + +else ifeq ($(LIBRETRO), fceumm) + APP_TITLE = FCeumm Libretro + #APP_DESCRIPTION = Retroarch 3DS + #APP_AUTHOR = Team Libretro + APP_PRODUCT_CODE = RARCH-FCEUMM + APP_UNIQUE_ID = 0xBAC03 + APP_ICON = ctr/fceumm.png + #APP_BANNER = ctr/libretro_banner.png + #APP_AUDIO = ctr/silent.wav + +else ifeq ($(LIBRETRO), nestopia) + APP_TITLE = Nestopia Libretro + #APP_DESCRIPTION = Retroarch 3DS + #APP_AUTHOR = Team Libretro + APP_PRODUCT_CODE = RARCH-NESTOPIA + APP_UNIQUE_ID = 0xBAC04 + APP_ICON = ctr/nestopia.png + #APP_BANNER = ctr/libretro_banner.png + #APP_AUDIO = ctr/silent.wav + BUILD_3DSX = 0 + +else ifeq ($(LIBRETRO), nxengine) + APP_TITLE = NXengine Libretro + #APP_DESCRIPTION = Retroarch 3DS + #APP_AUTHOR = Team Libretro + APP_PRODUCT_CODE = RARCH-NXENGINE + APP_UNIQUE_ID = 0xBAC05 + APP_ICON = ctr/nxengine.png + #APP_BANNER = ctr/libretro_banner.png + #APP_AUDIO = ctr/silent.wav + +else ifeq ($(LIBRETRO), genesis_plus_gx) + APP_TITLE = Genesis Plus GX Libretro + #APP_DESCRIPTION = Retroarch 3DS + #APP_AUTHOR = Team Libretro + APP_PRODUCT_CODE = RARCH-GENPLUSGX + APP_UNIQUE_ID = 0xBAC06 + APP_ICON = ctr/genesis_plus_gx.png + #APP_BANNER = ctr/libretro_banner.png + #APP_AUDIO = ctr/silent.wav + +else ifeq ($(LIBRETRO), catsfc) + APP_TITLE = CATSFC Libretro + #APP_DESCRIPTION = Retroarch 3DS + #APP_AUTHOR = Team Libretro + APP_PRODUCT_CODE = RARCH-CATSFC + APP_UNIQUE_ID = 0xBAC07 + APP_ICON = ctr/catsfc.png + #APP_BANNER = ctr/libretro_banner.png + #APP_AUDIO = ctr/silent.wav + +else ifeq ($(LIBRETRO), mednafen_wswan) + APP_TITLE = Mednafen wswan Libretro + #APP_DESCRIPTION = Retroarch 3DS + #APP_AUTHOR = Team Libretro + APP_PRODUCT_CODE = RARCH-M-WSWAN + APP_UNIQUE_ID = 0xBAC08 + APP_ICON = ctr/mednafen_wswan.png + #APP_BANNER = ctr/libretro_banner.png + #APP_AUDIO = ctr/silent.wav + +else ifeq ($(LIBRETRO), mednafen_vb) + APP_TITLE = Mednafen VB Libretro + #APP_DESCRIPTION = Retroarch 3DS + #APP_AUTHOR = Team Libretro + APP_PRODUCT_CODE = RARCH-M-VB + APP_UNIQUE_ID = 0xBAC09 + APP_ICON = ctr/mednafen_vb.png + #APP_BANNER = ctr/libretro_banner.png + #APP_AUDIO = ctr/silent.wav + +else ifeq ($(LIBRETRO), mednafen_ngp) + APP_TITLE = Mednafen NGP Libretro + #APP_DESCRIPTION = Retroarch 3DS + #APP_AUTHOR = Team Libretro + APP_PRODUCT_CODE = RARCH-M-NGP + APP_UNIQUE_ID = 0xBAC0A + APP_ICON = ctr/mednafen_ngp.png + #APP_BANNER = ctr/libretro_banner.png + #APP_AUDIO = ctr/silent.wav + +else ifeq ($(LIBRETRO), 2048) + APP_TITLE = 2048 Libretro + #APP_DESCRIPTION = Retroarch 3DS + #APP_AUTHOR = Team Libretro + APP_PRODUCT_CODE = RARCH-2048 + APP_UNIQUE_ID = 0xBAC0B + APP_ICON = ctr/2048.png + #APP_BANNER = ctr/libretro_banner.png + #APP_AUDIO = ctr/silent.wav + +else ifeq ($(LIBRETRO), picodrive) + APP_TITLE = Picodrive Libretro + #APP_DESCRIPTION = Retroarch 3DS + #APP_AUTHOR = Team Libretro + APP_PRODUCT_CODE = RARCH-PICODRIVE + APP_UNIQUE_ID = 0xBAC0C + APP_ICON = ctr/picodrive.png + #APP_BANNER = ctr/libretro_banner.png + #APP_AUDIO = ctr/silent.wav + +else ifeq ($(LIBRETRO), snes9x_next) + APP_TITLE = Snes9x Next Libretro + #APP_DESCRIPTION = Retroarch 3DS + #APP_AUTHOR = Team Libretro + APP_PRODUCT_CODE = RARCH-SNES9XNEXT + APP_UNIQUE_ID = 0xBAC0D + APP_ICON = ctr/snes9x_next.png + #APP_BANNER = ctr/libretro_banner.png + #APP_AUDIO = ctr/silent.wav + +endif diff --git a/ctr/catsfc.png b/ctr/catsfc.png new file mode 100644 index 0000000000..071967f690 Binary files /dev/null and b/ctr/catsfc.png differ diff --git a/ctr/default.png b/ctr/default.png new file mode 100644 index 0000000000..d0e98e66dc Binary files /dev/null and b/ctr/default.png differ diff --git a/ctr/fceumm.png b/ctr/fceumm.png new file mode 100644 index 0000000000..11b11e0743 Binary files /dev/null and b/ctr/fceumm.png differ diff --git a/ctr/gambatte.png b/ctr/gambatte.png new file mode 100644 index 0000000000..a2ad9b9415 Binary files /dev/null and b/ctr/gambatte.png differ diff --git a/ctr/genesis_plus_gx.png b/ctr/genesis_plus_gx.png new file mode 100644 index 0000000000..e5023eb499 Binary files /dev/null and b/ctr/genesis_plus_gx.png differ diff --git a/ctr/gpsp.png b/ctr/gpsp.png new file mode 100644 index 0000000000..2b39b53200 Binary files /dev/null and b/ctr/gpsp.png differ diff --git a/ctr/libretro_banner.png b/ctr/libretro_banner.png new file mode 100644 index 0000000000..284b6f91e3 Binary files /dev/null and b/ctr/libretro_banner.png differ diff --git a/ctr/mednafen_ngp.png b/ctr/mednafen_ngp.png new file mode 100644 index 0000000000..d0e98e66dc Binary files /dev/null and b/ctr/mednafen_ngp.png differ diff --git a/ctr/mednafen_vb.png b/ctr/mednafen_vb.png new file mode 100644 index 0000000000..d0e98e66dc Binary files /dev/null and b/ctr/mednafen_vb.png differ diff --git a/ctr/mednafen_wswan.png b/ctr/mednafen_wswan.png new file mode 100644 index 0000000000..d0e98e66dc Binary files /dev/null and b/ctr/mednafen_wswan.png differ diff --git a/ctr/mgba.png b/ctr/mgba.png new file mode 100644 index 0000000000..2b39b53200 Binary files /dev/null and b/ctr/mgba.png differ diff --git a/ctr/nestopia.png b/ctr/nestopia.png new file mode 100644 index 0000000000..11b11e0743 Binary files /dev/null and b/ctr/nestopia.png differ diff --git a/ctr/nxengine.png b/ctr/nxengine.png new file mode 100644 index 0000000000..d6c788a779 Binary files /dev/null and b/ctr/nxengine.png differ diff --git a/ctr/picodrive.png b/ctr/picodrive.png new file mode 100644 index 0000000000..d0e98e66dc Binary files /dev/null and b/ctr/picodrive.png differ diff --git a/ctr/silent.wav b/ctr/silent.wav new file mode 100644 index 0000000000..c8281ef298 Binary files /dev/null and b/ctr/silent.wav differ diff --git a/ctr/snes9x_next.png b/ctr/snes9x_next.png new file mode 100644 index 0000000000..d0e98e66dc Binary files /dev/null and b/ctr/snes9x_next.png differ diff --git a/ctr/tools/bannertool-linux b/ctr/tools/bannertool-linux new file mode 100755 index 0000000000..358764fe24 Binary files /dev/null and b/ctr/tools/bannertool-linux differ diff --git a/ctr/tools/bannertool-mac b/ctr/tools/bannertool-mac new file mode 100755 index 0000000000..1879cf7766 Binary files /dev/null and b/ctr/tools/bannertool-mac differ diff --git a/ctr/tools/bannertool.exe b/ctr/tools/bannertool.exe new file mode 100755 index 0000000000..8911f0863f Binary files /dev/null and b/ctr/tools/bannertool.exe differ diff --git a/ctr/tools/makerom-linux b/ctr/tools/makerom-linux new file mode 100755 index 0000000000..82c2f391a1 Binary files /dev/null and b/ctr/tools/makerom-linux differ diff --git a/ctr/tools/makerom-mac b/ctr/tools/makerom-mac new file mode 100755 index 0000000000..8d246131bd Binary files /dev/null and b/ctr/tools/makerom-mac differ diff --git a/ctr/tools/makerom.exe b/ctr/tools/makerom.exe new file mode 100755 index 0000000000..e98ef9a634 Binary files /dev/null and b/ctr/tools/makerom.exe differ diff --git a/ctr/tools/template-3ds.rsf b/ctr/tools/template-3ds.rsf new file mode 100644 index 0000000000..daae50c076 --- /dev/null +++ b/ctr/tools/template-3ds.rsf @@ -0,0 +1,235 @@ +BasicInfo: + Title : "{APP_TITLE}" + CompanyCode : "00" + ProductCode : "{APP_PRODUCT_CODE}" + ContentType : Application + Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem + +#Rom: + # Specifies the root path of the file system to include in the ROM. + # HostRoot : "romfs" + + +TitleInfo: + UniqueId : {APP_UNIQUE_ID} + Category : Application + +CardInfo: + MediaSize : 128MB # 128MB / 256MB / 512MB / 1GB / 2GB / 4GB / 8GB / 16GB / 32GB + MediaType : Card1 # Card1 / Card2 + CardDevice : None # NorFlash(Pick this if you use savedata) / None + + +Option: + FreeProductCode : true # Removes limitations on ProductCode + MediaFootPadding : false # If true CCI files are created with padding + EnableCrypt : true # Enables encryption for NCCH and CIA + EnableCompress : true # Compresses exefs code + + +ExeFs: # these are the program segments from the ELF, check your elf for the appropriate segment names + ReadOnly: + - .rodata + - RO + ReadWrite: + - .data + - RO + Text: + - .init + - .text + - STUP_ENTRY + +PlainRegion: # only used with SDK ELFs + - .module_id + +AccessControlInfo: + # UseExtSaveData : true + # ExtSaveDataId: 0xff3ff + # UseExtendedSaveDataAccessControl: true + # AccessibleSaveDataIds: [0x101, 0x202, 0x303, 0x404, 0x505, 0x606] + +SystemControlInfo: + SaveDataSize: 128KB + RemasterVersion: 0 + StackSize: 0x40000 + +# DO NOT EDIT BELOW HERE OR PROGRAMS WILL NOT LAUNCH (most likely) + +AccessControlInfo: + FileSystemAccess: + - Debug + - DirectSdmc + - DirectSdmcWrite + + IdealProcessor : 0 + AffinityMask : 1 + + Priority : 16 + + MaxCpu : 0x9E # Default + + CoreVersion : 2 + DescVersion : 2 + + ReleaseKernelMajor : "02" + ReleaseKernelMinor : "33" + MemoryType : Application + HandleTableSize: 512 + IORegisterMapping: + - 1ff50000-1ff57fff + - 1ff70000-1ff77fff + MemoryMapping: + - 1f000000-1f5fffff:r + SystemCallAccess: + ArbitrateAddress: 34 + Break: 60 + CancelTimer: 28 + ClearEvent: 25 + ClearTimer: 29 + CloseHandle: 35 + ConnectToPort: 45 + ControlMemory: 1 + CreateAddressArbiter: 33 + CreateEvent: 23 + CreateMemoryBlock: 30 + CreateMutex: 19 + CreateSemaphore: 21 + CreateThread: 8 + CreateTimer: 26 + DuplicateHandle: 39 + ExitProcess: 3 + ExitThread: 9 + GetCurrentProcessorNumber: 17 + GetHandleInfo: 41 + GetProcessId: 53 + GetProcessIdOfThread: 54 + GetProcessIdealProcessor: 6 + GetProcessInfo: 43 + GetResourceLimit: 56 + GetResourceLimitCurrentValues: 58 + GetResourceLimitLimitValues: 57 + GetSystemInfo: 42 + GetSystemTick: 40 + GetThreadContext: 59 + GetThreadId: 55 + GetThreadIdealProcessor: 15 + GetThreadInfo: 44 + GetThreadPriority: 11 + MapMemoryBlock: 31 + OutputDebugString: 61 + QueryMemory: 2 + ReleaseMutex: 20 + ReleaseSemaphore: 22 + SendSyncRequest1: 46 + SendSyncRequest2: 47 + SendSyncRequest3: 48 + SendSyncRequest4: 49 + SendSyncRequest: 50 + SetThreadPriority: 12 + SetTimer: 27 + SignalEvent: 24 + SleepThread: 10 + UnmapMemoryBlock: 32 + WaitSynchronization1: 36 + WaitSynchronizationN: 37 + InterruptNumbers: + ServiceAccessControl: + - APT:U + - $hioFIO + - $hostio0 + - $hostio1 + - ac:u + - boss:U + - cam:u + - cecd:u + - cfg:u + - dlp:FKCL + - dlp:SRVR + - dsp::DSP + - frd:u + - fs:USER + - gsp::Gpu + - hid:USER + - http:C + - mic:u + - ndm:u + - news:u + - nwm::UDS + - ptm:u + - pxi:dev + - soc:U + - ssl:C + - y2r:u + - ldr:ro + - ir:USER + + +SystemControlInfo: + Dependency: + ac: 0x0004013000002402L + am: 0x0004013000001502L + boss: 0x0004013000003402L + camera: 0x0004013000001602L + cecd: 0x0004013000002602L + cfg: 0x0004013000001702L + codec: 0x0004013000001802L + csnd: 0x0004013000002702L + dlp: 0x0004013000002802L + dsp: 0x0004013000001a02L + friends: 0x0004013000003202L + gpio: 0x0004013000001b02L + gsp: 0x0004013000001c02L + hid: 0x0004013000001d02L + http: 0x0004013000002902L + i2c: 0x0004013000001e02L + ir: 0x0004013000003302L + mcu: 0x0004013000001f02L + mic: 0x0004013000002002L + ndm: 0x0004013000002b02L + news: 0x0004013000003502L + nim: 0x0004013000002c02L + nwm: 0x0004013000002d02L + pdn: 0x0004013000002102L + ps: 0x0004013000003102L + ptm: 0x0004013000002202L + ro: 0x0004013000003702L + socket: 0x0004013000002e02L + spi: 0x0004013000002302L + ssl: 0x0004013000002f02L +CommonHeaderKey: + D: | + jL2yO86eUQnYbXIrzgFVMm7FVze0LglZ2f5g+c42hWoEdnb5BOotaMQPBfqt + aUyAEmzQPaoi/4l4V+hTJRXQfthVRqIEx27B84l8LA6Tl5Fy9PaQaQ+4yRfP + g6ylH2l0EikrIVjy2uMlFgl0QJCrG+QGKHftxhaGCifdAwFNmiZuyJ/TmktZ + 0RCb66lYcr2h/p2G7SnpKUliS9h9KnpmG+UEgVYQUK+4SCfByUa9PxYGpT0E + nw1UcRz0gsBmdOqcgzwnAd9vVqgb42hVn6uQZyAl+j1RKiMWywZarazIR/k5 + Lmr4+groimSEa+3ajyoIho9WaWTDmFU3mkhA2tUDIQ== + Exponent: | + AQAB + Modulus: | + zwCcsyCgMkdlieCgQMVXA6X2jmb1ICjup0Q+jk/AydPkOgsx7I/MjUymFEkU + vgXBtCKtzh3NKXtFFuW51tJ60GPOabLKuG0Qm5li+UXALrWhzWuvd5vv2FZI + dTQCbrq/MFS/M02xNtwqzWiBjE/LwqIdbrDAAvX4HGy0ydaQJ1DKYeQeph5D + lAGBw2nQ4izXhhuLaU3w8VQkIJHdhxIKI5gJY/20AGkG0vHD553Mh5kBINrWp + CRYmmJS8DCYbAiQtKbkeUfzHViGTZuj6PwaY8Mv39PGO47a++pt45IUyCEs4/ + LjMS72cyfo8tU4twRGp76SFGYejYj3wGC1f/POQw== + Signature: | + BOPR0jL0BOV5Zx502BuPbOvi/hvOq5ID8Dz1MQfOjkey6FKP/6cb4f9YXpm6c + ZCHAZLo0GduKdMepiKPUq1rsbbAxkRdQdjOOusEWoxNA58x3E4373tCAhlqM2 + DvuQERrIIQ/XnYLV9C3uw4efZwhFqog1jvVyoEHpuvs8xnYtGbsKQ8FrgLwXv + pOZYy9cSgq+jqLy2D9IxiowPcbq2cRlbW9d2xlUfpq0AohyuXQhpxn7d9RUor + 9veoARRAdxRJK12EpcSoEM1LhTRYdJnSRCY3x3p6YIV3c+l1sWvaQwKt0sZ/U + 8TTDx2gb9g7r/+U9icneu/zlqUpSkexCS009Q== + Descriptor: | + AP///wAABAACAAAAAAAFGJ4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAiIAAAAAAAABBUFQ6VQAAACRo + aW9GSU8AJGhvc3RpbzAkaG9zdGlvMWFjOnUAAAAAYm9zczpVAABjYW06dQAA + AGNlY2Q6dQAAY2ZnOnUAAABkbHA6RktDTGRscDpTUlZSZHNwOjpEU1BmcmQ6 + dQAAAGZzOlVTRVIAZ3NwOjpHcHVoaWQ6VVNFUmh0dHA6QwAAbWljOnUAAABu + ZG06dQAAAG5ld3M6dQAAbndtOjpVRFNwdG06dQAAAHB4aTpkZXYAc29jOlUA + AABzc2w6QwAAAHkycjp1AAAAbGRyOnJvAABpcjpVU0VSAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAABOn/rw/7//8ec/APIA8JH/APaR/1D/gf9Y/4H/cP+B/3j/gf8B + AQD/AAIA/iECAPz///////////////////////////////////////////// + ////////////////////////////////////////AAAAAAAAAAAAAAAAAAAA + AAADAAAAAAAAAAAAAAAAAAI= diff --git a/ctr/tools/template-cia.rsf b/ctr/tools/template-cia.rsf new file mode 100644 index 0000000000..e3cd2b9296 --- /dev/null +++ b/ctr/tools/template-cia.rsf @@ -0,0 +1,239 @@ +BasicInfo: + Title : "{APP_TITLE}" + CompanyCode : "00" + ProductCode : "{APP_PRODUCT_CODE}" + ContentType : Application + Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem + +#Rom: + # Specifies the root path of the file system to include in the ROM. + # HostRoot : "romfs" + +TitleInfo: + UniqueId : {APP_UNIQUE_ID} + Category : Application + +CardInfo: + MediaSize : 128MB # 128MB / 256MB / 512MB / 1GB / 2GB / 4GB / 8GB / 16GB / 32GB + MediaType : Card1 # Card1 / Card2 + CardDevice : None # NorFlash(Pick this if you use savedata) / None + + +Option: + UseOnSD : true # true if App is to be installed to SD + FreeProductCode : true # Removes limitations on ProductCode + MediaFootPadding : false # If true CCI files are created with padding + EnableCrypt : false # Enables encryption for NCCH and CIA + EnableCompress : true # Compresses exefs code + +ExeFs: # these are the program segments from the ELF, check your elf for the appropriate segment names + ReadOnly: + - .rodata + - RO + ReadWrite: + - .data + - RO + Text: + - .init + - .text + - STUP_ENTRY + +PlainRegion: # only used with SDK ELFs + # - .module_id + +AccessControlInfo: + # UseOtherVariationSaveData : true + # UseExtSaveData : true + # ExtSaveDataId: 0xffffffff + # SystemSaveDataId1: 0x220 + # SystemSaveDataId2: 0x00040010 + # OtherUserSaveDataId1: 0x220 + # OtherUserSaveDataId2: 0x330 + # OtherUserSaveDataId3: 0x440 + # UseExtendedSaveDataAccessControl: true + # AccessibleSaveDataIds: [0x101, 0x202, 0x303, 0x404, 0x505, 0x606] + FileSystemAccess: + # - CategorySystemApplication + # - CategoryHardwareCheck + # - CategoryFileSystemTool + - Debug + # - TwlCardBackup + # - TwlNandData + # - Boss + - DirectSdmc + # - Core + # - CtrNandRo + # - CtrNandRw + # - CtrNandRoWrite + # - CategorySystemSettings + # - CardBoard + # - ExportImportIvs + - DirectSdmcWrite + # - SwitchCleanup + # - SaveDataMove + # - Shop + # - Shell + # - CategoryHomeMenu + IoAccessControl: + # - FsMountNand + # - FsMountNandRoWrite + # - FsMountTwln + # - FsMountWnand + # - FsMountCardSpi + # - UseSdif3 + # - CreateSeed + # - UseCardSpi + + IdealProcessor : 0 + AffinityMask : 1 + + Priority : 16 + + MaxCpu : 0x9E # Default + + DisableDebug : false + EnableForceDebug : false + CanWriteSharedPage : true + CanUsePrivilegedPriority : false + CanUseNonAlphabetAndNumber : true + PermitMainFunctionArgument : true + CanShareDeviceMemory : true + RunnableOnSleep : false + SpecialMemoryArrange : true + + CoreVersion : 2 + DescVersion : 2 + + ReleaseKernelMajor : "02" + ReleaseKernelMinor : "33" + MemoryType : Application # Application / System / Base + HandleTableSize: 512 + IORegisterMapping: + - 1ff50000-1ff57fff + - 1ff70000-1ff77fff + MemoryMapping: + - 1f000000-1f5fffff:r + SystemCallAccess: + ArbitrateAddress: 34 + Break: 60 + CancelTimer: 28 + ClearEvent: 25 + ClearTimer: 29 + CloseHandle: 35 + ConnectToPort: 45 + ControlMemory: 1 + CreateAddressArbiter: 33 + CreateEvent: 23 + CreateMemoryBlock: 30 + CreateMutex: 19 + CreateSemaphore: 21 + CreateThread: 8 + CreateTimer: 26 + DuplicateHandle: 39 + ExitProcess: 3 + ExitThread: 9 + GetCurrentProcessorNumber: 17 + GetHandleInfo: 41 + GetProcessId: 53 + GetProcessIdOfThread: 54 + GetProcessIdealProcessor: 6 + GetProcessInfo: 43 + GetResourceLimit: 56 + GetResourceLimitCurrentValues: 58 + GetResourceLimitLimitValues: 57 + GetSystemInfo: 42 + GetSystemTick: 40 + GetThreadContext: 59 + GetThreadId: 55 + GetThreadIdealProcessor: 15 + GetThreadInfo: 44 + GetThreadPriority: 11 + MapMemoryBlock: 31 + OutputDebugString: 61 + QueryMemory: 2 + ReleaseMutex: 20 + ReleaseSemaphore: 22 + SendSyncRequest1: 46 + SendSyncRequest2: 47 + SendSyncRequest3: 48 + SendSyncRequest4: 49 + SendSyncRequest: 50 + SetThreadPriority: 12 + SetTimer: 27 + SignalEvent: 24 + SleepThread: 10 + UnmapMemoryBlock: 32 + WaitSynchronization1: 36 + WaitSynchronizationN: 37 + Backdoor: 123 + InterruptNumbers: + ServiceAccessControl: + - APT:U + - $hioFIO + - $hostio0 + - $hostio1 + - ac:u + - am:u + - boss:U + - cam:u + - cecd:u + - cfg:u + - dlp:FKCL + - dlp:SRVR + - dsp::DSP + - frd:u + - fs:USER + - gsp::Gpu + - hid:USER + - http:C + - mic:u + - ndm:u + - news:u + - nwm::UDS + - ptm:u + - pxi:dev + - soc:U + - ssl:C + - y2r:u + - ldr:ro + - ir:USER + - ir:u + - csnd:SND + + +SystemControlInfo: + SaveDataSize: 0KB # It doesn't use any save data. + RemasterVersion: 2 + StackSize: 0x40000 + # JumpId: 0 + Dependency: + ac: 0x0004013000002402L + am: 0x0004013000001502L + boss: 0x0004013000003402L + camera: 0x0004013000001602L + cecd: 0x0004013000002602L + cfg: 0x0004013000001702L + codec: 0x0004013000001802L + csnd: 0x0004013000002702L + dlp: 0x0004013000002802L + dsp: 0x0004013000001a02L + friends: 0x0004013000003202L + gpio: 0x0004013000001b02L + gsp: 0x0004013000001c02L + hid: 0x0004013000001d02L + http: 0x0004013000002902L + i2c: 0x0004013000001e02L + ir: 0x0004013000003302L + mcu: 0x0004013000001f02L + mic: 0x0004013000002002L + ndm: 0x0004013000002b02L + news: 0x0004013000003502L + nim: 0x0004013000002c02L + nwm: 0x0004013000002d02L + pdn: 0x0004013000002102L + ps: 0x0004013000003102L + ptm: 0x0004013000002202L + ro: 0x0004013000003702L + socket: 0x0004013000002e02L + spi: 0x0004013000002302L + ssl: 0x0004013000002f02L diff --git a/database_info.c b/database_info.c index 681de31123..61b4dd5421 100644 --- a/database_info.c +++ b/database_info.c @@ -15,23 +15,20 @@ * If not, see . */ +#include + #include +#include -#include "file_ext.h" #include "dir_list_special.h" - #include "database_info.h" -#include "file_ops.h" #include "msg_hash.h" #include "general.h" -#include "runloop.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include - #define DB_QUERY_ENTRY 0x1c310956U #define DB_QUERY_ENTRY_PUBLISHER 0x125e594dU #define DB_QUERY_ENTRY_DEVELOPER 0xcbd89be5U diff --git a/decompress/7zip_support.c b/decompress/7zip_support.c deleted file mode 100644 index 37c739b5e6..0000000000 --- a/decompress/7zip_support.c +++ /dev/null @@ -1,475 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2014-2015 - Timo Strunk - * Copyright (C) 2011-2015 - 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 . - */ - - - -#include -#include -#include - -#include -#include -#include -#include -#include "7zip_support.h" - -#include "../deps/7zip/7z.h" -#include "../deps/7zip/7zAlloc.h" -#include "../deps/7zip/7zCrc.h" -#include "../deps/7zip/7zFile.h" -#include "../deps/7zip/7zVersion.h" - -/* Undefined at the end of the file - * Don't use outside of this file - */ -#define RARCH_ZIP_SUPPORT_BUFFER_SIZE_MAX 16384 - -static ISzAlloc g_Alloc = { SzAlloc, SzFree }; - -static int Buf_EnsureSize(CBuf *dest, size_t size) -{ - if (dest->size >= size) - return 1; - Buf_Free(dest, &g_Alloc); - return Buf_Create(dest, size, &g_Alloc); -} - -#ifndef _WIN32 - -static uint8_t kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - -static Bool Utf16_To_Utf8(uint8_t *dest, size_t *destLen, - const uint16_t *src, size_t srcLen) -{ - size_t destPos = 0; - size_t srcPos = 0; - - for (;;) - { - unsigned numAdds; - uint32_t value; - - if (srcPos == srcLen) - { - *destLen = destPos; - return True; - } - value = src[srcPos++]; - if (value < 0x80) - { - if (dest) - dest[destPos] = (char)value; - destPos++; - continue; - } - if (value >= 0xD800 && value < 0xE000) - { - uint32_t c2; - - if (value >= 0xDC00 || srcPos == srcLen) - break; - c2 = src[srcPos++]; - if (c2 < 0xDC00 || c2 >= 0xE000) - break; - value = (((value - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000; - } - for (numAdds = 1; numAdds < 5; numAdds++) - if (value < (((uint32_t)1) << (numAdds * 5 + 6))) - break; - if (dest) - dest[destPos] = (char)(kUtf8Limits[numAdds - 1] - + (value >> (6 * numAdds))); - destPos++; - do - { - numAdds--; - if (dest) - dest[destPos] = (char)(0x80 - + ((value >> (6 * numAdds)) & 0x3F)); - destPos++; - }while (numAdds != 0); - } - *destLen = destPos; - return False; -} - -static SRes Utf16_To_Utf8Buf(CBuf *dest, - const uint16_t *src, size_t srcLen) -{ - Bool res; - size_t destLen = 0; - - Utf16_To_Utf8(NULL, &destLen, src, srcLen); - destLen += 1; - - if (!Buf_EnsureSize(dest, destLen)) - return SZ_ERROR_MEM; - - res = Utf16_To_Utf8(dest->data, &destLen, src, srcLen); - dest->data[destLen] = 0; - - return res ? SZ_OK : SZ_ERROR_FAIL; -} -#endif - -static SRes Utf16_To_Char(CBuf *buf, const uint16_t *s, int fileMode) -{ - int len = 0; - - for (len = 0; s[len] != '\0'; len++); - -#ifdef _WIN32 - { - int size = len * 3 + 100; - if (!Buf_EnsureSize(buf, size)) - return SZ_ERROR_MEM; - { - char defaultChar = '_'; - BOOL defUsed; - int numChars = WideCharToMultiByte(fileMode ? - ( -#ifdef UNDER_CE - CP_ACP -#else - AreFileApisANSI() ? CP_ACP : CP_OEMCP -#endif - ) : CP_OEMCP, - 0, (LPCWSTR)s, len, (char *)buf->data, - size, &defaultChar, &defUsed); - if (numChars == 0 || numChars >= size) - return SZ_ERROR_FAIL; - buf->data[numChars] = 0; - return SZ_OK; - } - } -#else - (void)fileMode; - return Utf16_To_Utf8Buf(buf, s, len); -#endif -} - - -static SRes ConvertUtf16toCharString(const uint16_t *s, char *outstring) -{ - CBuf buf; - SRes res; - - Buf_Init(&buf); - res = Utf16_To_Char(&buf, s, 0); - - if (res == SZ_OK) - strncpy(outstring, (const char*)buf.data, PATH_MAX_LENGTH); - - Buf_Free(&buf, &g_Alloc); - return res; -} - -/* Extract the relative path relative_path from a 7z archive - * archive_path and allocate a buf for it to write it in. - * If optional_outfile is set, extract to that instead and don't alloc buffer. - */ -int read_7zip_file( - const char *archive_path, - const char *relative_path, void **buf, - const char *optional_outfile) -{ - CFileInStream archiveStream; - CLookToRead lookStream; - CSzArEx db; - SRes res; - ISzAlloc allocImp; - ISzAlloc allocTempImp; - uint16_t *temp = NULL; - size_t tempSize = 0; - long outsize = -1; - bool file_found = false; - - /*These are the allocation routines. - * Currently using the non-standard 7zip choices. */ - allocImp.Alloc = SzAlloc; - allocImp.Free = SzFree; - allocTempImp.Alloc = SzAllocTemp; - allocTempImp.Free = SzFreeTemp; - - if (InFile_Open(&archiveStream.file, archive_path)) - { - RARCH_ERR("Could not open %s as 7z archive\n.",archive_path); - return -1; - } - else - { - RARCH_LOG_OUTPUT("Openend archive %s. Now trying to extract %s\n", - archive_path,relative_path); - } - - FileInStream_CreateVTable(&archiveStream); - LookToRead_CreateVTable(&lookStream, False); - lookStream.realStream = &archiveStream.s; - LookToRead_Init(&lookStream); - CrcGenerateTable(); - SzArEx_Init(&db); - res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp); - - if (res == SZ_OK) - { - uint32_t i; - uint32_t blockIndex = 0xFFFFFFFF; - uint8_t *outBuffer = 0; - size_t outBufferSize = 0; - - for (i = 0; i < db.db.NumFiles; i++) - { - size_t len; - char infile[PATH_MAX_LENGTH] = {0}; - size_t offset = 0; - size_t outSizeProcessed = 0; - const CSzFileItem *f = db.db.Files + i; - - if (f->IsDir) - { - /* We skip over everything which is not a directory. - * FIXME: Why continue then if f->IsDir is true?*/ - continue; - } - - len = SzArEx_GetFileNameUtf16(&db, i, NULL); - if (len > tempSize) - { - free(temp); - tempSize = len; - temp = (uint16_t *)malloc(tempSize * sizeof(temp[0])); - if (temp == 0) - { - res = SZ_ERROR_MEM; - break; - } - } - SzArEx_GetFileNameUtf16(&db, i, temp); - res = ConvertUtf16toCharString(temp,infile); - - if (!strcmp(infile, relative_path)) - { - /* C LZMA SDK does not support chunked extraction - see here: - * sourceforge.net/p/sevenzip/discussion/45798/thread/6fb59aaf/ - * */ - file_found = true; - res = SzArEx_Extract(&db, &lookStream.s, i,&blockIndex, - &outBuffer, &outBufferSize,&offset, &outSizeProcessed, - &allocImp, &allocTempImp); - if (res != SZ_OK) - { - break; /* This goes to the error section. */ - } - outsize = outSizeProcessed; - if (optional_outfile != NULL) - { - FILE* outsink = fopen(optional_outfile,"wb"); - if (outsink == NULL) - { - RARCH_ERR("Could not open outfilepath %s.\n", - optional_outfile); - IAlloc_Free(&allocImp, outBuffer); - SzArEx_Free(&db, &allocImp); - free(temp); - File_Close(&archiveStream.file); - return -1; - } - fwrite(outBuffer+offset,1,outsize,outsink); - fclose(outsink); - } - else - { - /*We could either use the 7Zip allocated buffer, - * or create our own and use it. - * We would however need to realloc anyways, because RetroArch - * expects a \0 at the end, therefore we allocate new, - * copy and free the old one. */ - *buf = malloc(outsize + 1); - ((char*)(*buf))[outsize] = '\0'; - memcpy(*buf,outBuffer+offset,outsize); - } - IAlloc_Free(&allocImp, outBuffer); - break; - } - } - } - SzArEx_Free(&db, &allocImp); - free(temp); - - File_Close(&archiveStream.file); - - if (res == SZ_OK && file_found == true) - return outsize; - - /* Error handling */ - if (!file_found) - RARCH_ERR("File %s not found in %s\n",relative_path,archive_path); - else if (res == SZ_ERROR_UNSUPPORTED) - RARCH_ERR("7Zip decoder doesn't support this archive\n"); - else if (res == SZ_ERROR_MEM) - RARCH_ERR("7Zip decoder could not allocate memory\n"); - else if (res == SZ_ERROR_CRC) - RARCH_ERR("7Zip decoder encountered a CRC error in the archive\n"); - else - RARCH_ERR("\nUnspecified error in 7-ZIP archive, error number was: #%d\n", res); - return -1; -} - -struct string_list *compressed_7zip_file_list_new(const char *path, - const char* ext) -{ - CFileInStream archiveStream; - CLookToRead lookStream; - CSzArEx db; - SRes res; - ISzAlloc allocImp; - ISzAlloc allocTempImp; - uint16_t *temp = NULL; - size_t tempSize = 0; - long outsize = -1; - - struct string_list *ext_list = NULL; - struct string_list *list = string_list_new(); - - if (!list) - return NULL; - - if (ext) - ext_list = string_split(ext, "|"); - - (void)outsize; - - /* These are the allocation routines - currently using - * the non-standard 7zip choices. */ - allocImp.Alloc = SzAlloc; - allocImp.Free = SzFree; - allocTempImp.Alloc = SzAllocTemp; - allocTempImp.Free = SzFreeTemp; - - if (InFile_Open(&archiveStream.file, path)) - { - RARCH_ERR("Could not open %s as 7z archive.\n",path); - goto error; - } - - FileInStream_CreateVTable(&archiveStream); - LookToRead_CreateVTable(&lookStream, False); - lookStream.realStream = &archiveStream.s; - LookToRead_Init(&lookStream); - CrcGenerateTable(); - SzArEx_Init(&db); - res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp); - - if (res == SZ_OK) - { - uint32_t i; - uint32_t blockIndex = 0xFFFFFFFF; - uint8_t *outBuffer = 0; - size_t outBufferSize = 0; - - (void)blockIndex; - (void)outBufferSize; - (void)outBuffer; - - for (i = 0; i < db.db.NumFiles; i++) - { - union string_list_elem_attr attr; - const char *file_ext = NULL; - char infile[PATH_MAX_LENGTH] = {0}; - size_t offset = 0; - size_t outSizeProcessed = 0; - size_t len = 0; - bool supported_by_core = false; - const CSzFileItem *f = db.db.Files + i; - - (void)offset; - (void)outSizeProcessed; - - if (f->IsDir) - { - /* we skip over everything, which is a directory. */ - continue; - } - len = SzArEx_GetFileNameUtf16(&db, i, NULL); - if (len > tempSize) - { - free(temp); - tempSize = len; - temp = (uint16_t *)malloc(tempSize * sizeof(temp[0])); - - if (temp == 0) - { - res = SZ_ERROR_MEM; - break; - } - } - SzArEx_GetFileNameUtf16(&db, i, temp); - res = ConvertUtf16toCharString(temp, infile); - file_ext = path_get_extension(infile); - - if (string_list_find_elem_prefix(ext_list, ".", file_ext)) - supported_by_core = true; - - /* - * Currently we only support files without subdirs in the archives. - * Folders are not supported (differences between win and lin. - * Archives within archives should imho never be supported. - */ - - if (!supported_by_core) - continue; - - attr.i = RARCH_COMPRESSED_FILE_IN_ARCHIVE; - - if (!string_list_append(list, infile, attr)) - goto error; - - } - } - SzArEx_Free(&db, &allocImp); - free(temp); - File_Close(&archiveStream.file); - - if (res != SZ_OK) - { - /* Error handling */ - if (res == SZ_ERROR_UNSUPPORTED) - RARCH_ERR("7Zip decoder doesn't support this archive. \n"); - else if (res == SZ_ERROR_MEM) - RARCH_ERR("7Zip decoder could not allocate memory. \n"); - else if (res == SZ_ERROR_CRC) - RARCH_ERR("7Zip decoder encountered a CRC error in the archive. \n"); - else - RARCH_ERR( - "\nUnspecified error in 7-ZIP archive, error number was: #%d. \n", - res); - goto error; - } - - string_list_free(ext_list); - return list; - -error: - RARCH_ERR("Failed to open compressed_file: \"%s\"\n", path); - SzArEx_Free(&db, &allocImp); - free(temp); - File_Close(&archiveStream.file); - string_list_free(list); - string_list_free(ext_list); - return NULL; -} - -#undef RARCH_ZIP_SUPPORT_BUFFER_SIZE_MAX diff --git a/decompress/7zip_support.h b/decompress/7zip_support.h deleted file mode 100644 index 475332f17e..0000000000 --- a/decompress/7zip_support.h +++ /dev/null @@ -1,34 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2014-2015 - Timo Strunk - * Copyright (C) 2011-2015 - 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 . - */ - -#ifndef __RARCH_7ZIP_SUPPORT_H -#define __RARCH_7ZIP_SUPPORT_H - -#ifdef __cplusplus -extern "C" { -#endif - -int read_7zip_file(const char * archive_path, - const char *relative_path, void **buf, char const* optional_outfileq); - -struct string_list *compressed_7zip_file_list_new(const char *path, - const char* ext); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/decompress/zip_support.c b/decompress/zip_support.c deleted file mode 100644 index f04d8fae16..0000000000 --- a/decompress/zip_support.c +++ /dev/null @@ -1,194 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2014-2015 - Timo Strunk - * Copyright (C) 2011-2015 - 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 . - */ - - - -#include -#include -#include -#include - -#include -#include - -#include "zip_support.h" - -#include "../deps/zlib/unzip.h" - -/* Undefined at the end of the file - * Don't use outside of this file - */ -#define RARCH_ZIP_SUPPORT_BUFFER_SIZE_MAX 16384 - -/* Extract the relative path relative_path from a - * zip archive archive_path and allocate a buf for it to write it in. */ -/* This code is inspired by: - * stackoverflow.com/questions/10440113/simple-way-to-unzip-a-zip-file-using-zlib - * - * optional_outfile if not NULL will be used to extract the file. buf will be 0 - * then. - */ - -int read_zip_file(const char *archive_path, - const char *relative_path, void **buf, - const char* optional_outfile) -{ - uLong i; - unz_global_info global_info; - ssize_t bytes_read = -1; - bool finished_reading = false; - unzFile *zipfile = (unzFile*)unzOpen(archive_path); - - if (!zipfile) - { - RARCH_ERR("Could not open ZIP file %s.\n",archive_path); - return -1; - } - - /* Get info about the zip file */ - if (unzGetGlobalInfo(zipfile, &global_info) != UNZ_OK) - { - RARCH_ERR("Could not get global ZIP file info of %s." - "Could be only a GZIP file without the ZIP part.\n", - archive_path); - goto error; - } - - for ( i = 0; i < global_info.number_entry; ++i ) - { - /* Get info about current file. */ - unz_file_info file_info; - char filename[PATH_MAX_LENGTH] = {0}; - char last_char = ' '; - - if (unzGetCurrentFileInfo( - zipfile, - &file_info, - filename, - PATH_MAX_LENGTH, - NULL, 0, NULL, 0 ) != UNZ_OK ) - { - RARCH_ERR("Could not read file info in ZIP %s.\n", - archive_path); - goto error; - } - - /* Check if this entry is a directory or file. */ - last_char = filename[strlen(filename)-1]; - - if ( last_char == '/' || last_char == '\\' ) - { - /* We skip directories */ - } - else if (!strcmp(filename, relative_path)) - { - /* We found the correct file in the zip, - * now extract it to *buf. */ - if (unzOpenCurrentFile(zipfile) != UNZ_OK ) - { - RARCH_ERR("The file %s in %s could not be read.\n", - relative_path, archive_path); - goto error; - } - - if (optional_outfile == 0) - { - /* Allocate outbuffer */ - *buf = malloc(file_info.uncompressed_size + 1 ); - bytes_read = unzReadCurrentFile(zipfile, *buf, file_info.uncompressed_size); - - if (bytes_read != (ssize_t)file_info.uncompressed_size) - { - RARCH_ERR( - "Tried to read %d bytes, but only got %d of file %s in ZIP %s.\n", - (unsigned int) file_info.uncompressed_size, (int)bytes_read, - relative_path, archive_path); - free(*buf); - goto close; - } - ((char*)(*buf))[file_info.uncompressed_size] = '\0'; - } - else - { - char read_buffer[RARCH_ZIP_SUPPORT_BUFFER_SIZE_MAX] = {0}; - FILE* outsink = fopen(optional_outfile,"wb"); - - if (outsink == NULL) - { - RARCH_ERR("Could not open outfilepath %s.\n", optional_outfile); - goto close; - } - - bytes_read = 0; - - do - { - ssize_t fwrite_bytes; - - bytes_read = unzReadCurrentFile(zipfile, read_buffer, - RARCH_ZIP_SUPPORT_BUFFER_SIZE_MAX ); - fwrite_bytes = fwrite(read_buffer,1,bytes_read,outsink); - - if (fwrite_bytes == bytes_read) - continue; - - /* couldn't write all bytes */ - RARCH_ERR("Error writing to %s.\n",optional_outfile); - fclose(outsink); - goto close; - } while(bytes_read > 0); - - fclose(outsink); - } - finished_reading = true; - } - - unzCloseCurrentFile(zipfile); - - if (finished_reading) - break; - - if ((i + 1) < global_info.number_entry) - { - if (unzGoToNextFile(zipfile) == UNZ_OK) - continue; - - RARCH_ERR( - "Could not iterate to next file in %s. ZIP file might be corrupt.\n", - archive_path ); - goto error; - } - } - - unzClose(zipfile); - - if(!finished_reading) - { - RARCH_ERR("File %s not found in %s\n", - relative_path, archive_path); - return -1; - } - - return bytes_read; - -close: - unzCloseCurrentFile(zipfile); -error: - unzClose(zipfile); - return -1; -} - -#undef RARCH_ZIP_SUPPORT_BUFFER_SIZE_MAX diff --git a/decompress/zip_support.h b/decompress/zip_support.h deleted file mode 100644 index dd3e5efedd..0000000000 --- a/decompress/zip_support.h +++ /dev/null @@ -1,31 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2014-2015 - Timo Strunk - * Copyright (C) 2011-2015 - 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 . - */ - -#ifndef __RARCH_ZIP_SUPPORT_H -#define __RARCH_ZIP_SUPPORT_H - -#ifdef __cplusplus -extern "C" { -#endif - -int read_zip_file(const char * archive_path, - const char *relative_path, void **buf, const char* optional_outfile); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/gfx/drivers/gx_sdk_defines.h b/defines/gx_defines.h similarity index 95% rename from gfx/drivers/gx_sdk_defines.h rename to defines/gx_defines.h index a87df74051..194b315c31 100644 --- a/gfx/drivers/gx_sdk_defines.h +++ b/defines/gx_defines.h @@ -1,5 +1,5 @@ -#ifndef _GX_SDK_DEFINES_H -#define _GX_SDK_DEFINES_H +#ifndef _GX_DEFINES_H +#define _GX_DEFINES_H #ifdef GEKKO diff --git a/ps3/sdk_defines.h b/defines/ps3_defines.h similarity index 99% rename from ps3/sdk_defines.h rename to defines/ps3_defines.h index 4e6ff9230c..2241709c2c 100644 --- a/ps3/sdk_defines.h +++ b/defines/ps3_defines.h @@ -14,8 +14,8 @@ * If not, see . */ -#ifndef _PS3_SDK_DEFINES_H -#define _PS3_SDK_DEFINES_H +#ifndef _PS3_DEFINES_H +#define _PS3_DEFINES_H #include @@ -323,12 +323,16 @@ extern int audioAddData(uint32_t portNum, float *data, uint32_t frames, float vo ============================================================ */ #ifdef __PSL1GHT__ +#include + /* define all the thread functions */ #define sys_ppu_thread_create sysThreadCreate #define sys_ppu_thread_join sysThreadJoin #define sys_ppu_thread_exit sysThreadExit #define SYS_PPU_THREAD_CREATE_JOINABLE 0 /* FIXME - not sure if this is correct */ +#elif defined(__CELLOS_LV2__) +#include #endif /*============================================================ diff --git a/gfx/drivers/psp_sdk_defines.h b/defines/psp_defines.h similarity index 79% rename from gfx/drivers/psp_sdk_defines.h rename to defines/psp_defines.h index 51759c0264..96c8910a62 100644 --- a/gfx/drivers/psp_sdk_defines.h +++ b/defines/psp_defines.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2015 - 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. @@ -14,14 +14,14 @@ * If not, see . */ -#ifndef _PSP_SDK_DEFINES_H -#define _PSP_SDK_DEFINES_H +#ifndef _PSP_DEFINES_H +#define _PSP_DEFINES_H /*============================================================ ERROR PROTOTYPES ============================================================ */ -#if defined(PSP) +#ifndef SCE_OK #define SCE_OK 0 #endif @@ -29,8 +29,13 @@ DISPLAY PROTOTYPES ============================================================ */ -#if defined(SN_TARGET_PSP2) +#if defined(SN_TARGET_PSP2) || defined(VITA) + +#ifdef VITA +#define PSP_DISPLAY_PIXEL_FORMAT_8888 (PSP2_DISPLAY_PIXELFORMAT_A8B8G8R8) +#else #define PSP_DISPLAY_PIXEL_FORMAT_8888 (SCE_DISPLAY_PIXELFORMAT_A8B8G8R8) +#endif #define DisplaySetFrameBuf(topaddr, bufferwidth, pixelformat, sync) sceDisplaySetFrameBuf(topaddr, sync) @@ -53,13 +58,30 @@ INPUT PROTOTYPES ============================================================ */ -#if defined(SN_TARGET_PSP2) +#if defined(SN_TARGET_PSP2) || defined(VITA) #define STATE_BUTTON(state) ((state).buttons) #define STATE_ANALOGLX(state) ((state).lx) #define STATE_ANALOGLY(state) ((state).ly) #define STATE_ANALOGRX(state) ((state).rx) #define STATE_ANALOGRY(state) ((state).ry) + +#if defined(VITA) +#define DEFAULT_SAMPLING_MODE (PSP2_CTRL_MODE_ANALOG) + +#define PSP_CTRL_LEFT PSP2_CTRL_LEFT +#define PSP_CTRL_DOWN PSP2_CTRL_DOWN +#define PSP_CTRL_RIGHT PSP2_CTRL_RIGHT +#define PSP_CTRL_UP PSP2_CTRL_UP +#define PSP_CTRL_START PSP2_CTRL_START +#define PSP_CTRL_SELECT PSP2_CTRL_SELECT +#define PSP_CTRL_TRIANGLE PSP2_CTRL_TRIANGLE +#define PSP_CTRL_SQUARE PSP2_CTRL_SQUARE +#define PSP_CTRL_CROSS PSP2_CTRL_CROSS +#define PSP_CTRL_CIRCLE PSP2_CTRL_CIRCLE +#define PSP_CTRL_L PSP2_CTRL_LTRIGGER +#define PSP_CTRL_R PSP2_CTRL_RTRIGGER +#else #define DEFAULT_SAMPLING_MODE (SCE_CTRL_MODE_DIGITALANALOG) #define PSP_CTRL_LEFT SCE_CTRL_LEFT @@ -74,6 +96,7 @@ #define PSP_CTRL_CIRCLE SCE_CTRL_CIRCLE #define PSP_CTRL_L SCE_CTRL_L #define PSP_CTRL_R SCE_CTRL_R +#endif #define CtrlPeekBufferPositive(port, pad_data, bufs) sceCtrlPeekBufferPositive(port, pad_data, bufs) diff --git a/deps/7zip/7z.h b/deps/7zip/7z.h index bde452da3a..4f2ee95d88 100644 --- a/deps/7zip/7z.h +++ b/deps/7zip/7z.h @@ -6,7 +6,9 @@ #include "7zBuf.h" -EXTERN_C_BEGIN +#ifdef __cplusplus +extern "C" { +#endif #define k7zStartHeaderSize 0x20 #define k7zSignatureSize 6 @@ -198,6 +200,8 @@ SZ_ERROR_FAIL SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp); -EXTERN_C_END +#ifdef __cplusplus +} +#endif #endif diff --git a/deps/7zip/7zAlloc.h b/deps/7zip/7zAlloc.h index 860f116ace..c8c77d19c5 100644 --- a/deps/7zip/7zAlloc.h +++ b/deps/7zip/7zAlloc.h @@ -6,10 +6,18 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + void *SzAlloc(void *p, size_t size); void SzFree(void *p, void *address); void *SzAllocTemp(void *p, size_t size); void SzFreeTemp(void *p, void *address); +#ifdef __cplusplus +} +#endif + #endif diff --git a/deps/7zip/7zCrc.c b/deps/7zip/7zCrc.c index 6b57e8bf59..4f081fbe77 100644 --- a/deps/7zip/7zCrc.c +++ b/deps/7zip/7zCrc.c @@ -47,7 +47,7 @@ uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size) return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL; } -void MY_FAST_CALL CrcGenerateTable() +void MY_FAST_CALL CrcGenerateTable(void) { uint32_t i; for (i = 0; i < 256; i++) @@ -68,8 +68,7 @@ void MY_FAST_CALL CrcGenerateTable() } g_CrcUpdate = CrcUpdateT4; #ifdef MY_CPU_X86_OR_AMD64 - if (!CPU_Is_InOrder()) - g_CrcUpdate = CrcUpdateT8; + g_CrcUpdate = CrcUpdateT8; #endif #endif } diff --git a/deps/7zip/7zCrc.h b/deps/7zip/7zCrc.h index 5062d642c1..9c11923500 100644 --- a/deps/7zip/7zCrc.h +++ b/deps/7zip/7zCrc.h @@ -6,7 +6,9 @@ #include "Types.h" -EXTERN_C_BEGIN +#ifdef __cplusplus +extern "C" { +#endif extern uint32_t g_CrcTable[]; @@ -20,6 +22,8 @@ void MY_FAST_CALL CrcGenerateTable(void); uint32_t MY_FAST_CALL CrcUpdate(uint32_t crc, const void *data, size_t size); uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size); -EXTERN_C_END +#ifdef __cplusplus +} +#endif #endif diff --git a/deps/7zip/7zFile.h b/deps/7zip/7zFile.h index 77018cc4c8..73d2ff0440 100644 --- a/deps/7zip/7zFile.h +++ b/deps/7zip/7zFile.h @@ -16,7 +16,9 @@ #include "Types.h" -EXTERN_C_BEGIN +#ifdef __cplusplus +extern "C" { +#endif /* ---------- File ---------- */ @@ -78,6 +80,8 @@ typedef struct void FileOutStream_CreateVTable(CFileOutStream *p); -EXTERN_C_END +#ifdef __cplusplus +} +#endif #endif diff --git a/deps/7zip/CpuArch.c b/deps/7zip/CpuArch.c deleted file mode 100644 index 36d5d6b48e..0000000000 --- a/deps/7zip/CpuArch.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include "CpuArch.h" - -Bool CPU_Is_InOrder(void); - -Bool CPU_Is_InOrder(void) -{ - return False; -} diff --git a/deps/7zip/CpuArch.h b/deps/7zip/CpuArch.h index cac72b818e..97dc50d1d7 100644 --- a/deps/7zip/CpuArch.h +++ b/deps/7zip/CpuArch.h @@ -6,7 +6,9 @@ #include "Types.h" -EXTERN_C_BEGIN +#ifdef __cplusplus +extern "C" { +#endif /* MY_CPU_LE means that CPU is LITTLE ENDIAN. @@ -118,8 +120,8 @@ Stop_Compiling_Bad_Endian #define GetBe16(p) (((uint16_t)((const uint8_t *)(p))[0] << 8) | ((const uint8_t *)(p))[1]) -Bool CPU_Is_InOrder(); - -EXTERN_C_END +#ifdef __cplusplus +} +#endif #endif diff --git a/deps/7zip/Types.h b/deps/7zip/Types.h index e29dd3eb42..5cbed1e18e 100644 --- a/deps/7zip/Types.h +++ b/deps/7zip/Types.h @@ -10,17 +10,9 @@ #include #endif -#ifndef EXTERN_C_BEGIN #ifdef __cplusplus -#define EXTERN_C_BEGIN extern "C" { -#define EXTERN_C_END } -#else -#define EXTERN_C_BEGIN -#define EXTERN_C_END +extern "C" { #endif -#endif - -EXTERN_C_BEGIN #define SZ_OK 0 @@ -221,6 +213,8 @@ typedef struct #endif -EXTERN_C_END +#ifdef __cplusplus +} +#endif #endif diff --git a/deps/stb/stb_truetype.h b/deps/stb/stb_truetype.h index 663aef4b60..13d4b9f58f 100644 --- a/deps/stb/stb_truetype.h +++ b/deps/stb/stb_truetype.h @@ -438,7 +438,6 @@ int main(int arg, char **argv) #endif #ifndef STBTT_memcpy - #include #define STBTT_memcpy memcpy #define STBTT_memset memset #endif diff --git a/deps/zlib/adler32.c b/deps/zlib/adler32.c index cccb3a2999..a7abb77725 100644 --- a/deps/zlib/adler32.c +++ b/deps/zlib/adler32.c @@ -8,7 +8,7 @@ #define ZLIB_INTERNAL #include #include -#include "zutil.h" +#include #define BASE 65521UL /* largest prime smaller than 65536 */ #define NMAX 5552 diff --git a/deps/zlib/compress.c b/deps/zlib/compress.c index 48465bd77a..b30cec47e9 100644 --- a/deps/zlib/compress.c +++ b/deps/zlib/compress.c @@ -6,7 +6,7 @@ /* @(#) $Id$ */ #define ZLIB_INTERNAL -#include "zlib.h" +#include /* =========================================================================== Compresses the source buffer into the destination buffer. The level diff --git a/deps/zlib/deflate.h b/deps/zlib/deflate.h index 82fe93e224..e284189775 100644 --- a/deps/zlib/deflate.h +++ b/deps/zlib/deflate.h @@ -13,7 +13,7 @@ #ifndef DEFLATE_H #define DEFLATE_H -#include "zutil.h" +#include /* define NO_GZIP when compiling if you want to disable gzip header and trailer creation by deflate(). NO_GZIP would be used to avoid linking in diff --git a/deps/zlib/gzguts.h b/deps/zlib/gzguts.h index 6068d41957..d0b51066bb 100644 --- a/deps/zlib/gzguts.h +++ b/deps/zlib/gzguts.h @@ -22,7 +22,7 @@ #endif #include -#include "zlib.h" +#include #ifdef STDC # include # include diff --git a/deps/zlib/gzlib.c b/deps/zlib/gzlib.c index 7443a75c19..12940e8578 100644 --- a/deps/zlib/gzlib.c +++ b/deps/zlib/gzlib.c @@ -264,19 +264,16 @@ local gzFile gz_open(const void *path, int fd, const char *mode) return (gzFile)state; } -/* -- see zlib.h -- */ gzFile ZEXPORT gzopen(const char *path, const char *mode) { return gz_open(path, -1, mode); } -/* -- see zlib.h -- */ gzFile ZEXPORT gzopen64(const char *path, const char *mode) { return gz_open(path, -1, mode); } -/* -- see zlib.h -- */ gzFile ZEXPORT gzdopen(int fd, const char *mode) { char *path; /* identifier for error messages */ @@ -294,7 +291,6 @@ gzFile ZEXPORT gzdopen(int fd, const char *mode) return gz; } -/* -- see zlib.h -- */ #ifdef _WIN32 gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) { @@ -302,7 +298,6 @@ gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) } #endif -/* -- see zlib.h -- */ int ZEXPORT gzbuffer(gzFile file, unsigned size) { gz_statep state; @@ -325,7 +320,6 @@ int ZEXPORT gzbuffer(gzFile file, unsigned size) return 0; } -/* -- see zlib.h -- */ int ZEXPORT gzrewind(gzFile file) { gz_statep state; @@ -347,7 +341,6 @@ int ZEXPORT gzrewind(gzFile file) return 0; } -/* -- see zlib.h -- */ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) { unsigned n; @@ -421,7 +414,6 @@ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) return state->x.pos + offset; } -/* -- see zlib.h -- */ z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) { z_off64_t ret; @@ -430,7 +422,6 @@ z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) return ret == (z_off_t)ret ? (z_off_t)ret : -1; } -/* -- see zlib.h -- */ z_off64_t ZEXPORT gztell64(gzFile file) { gz_statep state; @@ -446,7 +437,6 @@ z_off64_t ZEXPORT gztell64(gzFile file) return state->x.pos + (state->seek ? state->skip : 0); } -/* -- see zlib.h -- */ z_off_t ZEXPORT gztell(gzFile file) { z_off64_t ret; @@ -455,7 +445,6 @@ z_off_t ZEXPORT gztell(gzFile file) return ret == (z_off_t)ret ? (z_off_t)ret : -1; } -/* -- see zlib.h -- */ z_off64_t ZEXPORT gzoffset64(gzFile file) { z_off64_t offset; @@ -477,14 +466,12 @@ z_off64_t ZEXPORT gzoffset64(gzFile file) return offset; } -/* -- see zlib.h -- */ z_off_t ZEXPORT gzoffset(gzFile file) { z_off64_t ret = gzoffset64(file); return ret == (z_off_t)ret ? (z_off_t)ret : -1; } -/* -- see zlib.h -- */ int ZEXPORT gzeof(gzFile file) { gz_statep state; @@ -500,7 +487,6 @@ int ZEXPORT gzeof(gzFile file) return state->mode == GZ_READ ? state->past : 0; } -/* -- see zlib.h -- */ const char * ZEXPORT gzerror(gzFile file, int *errnum) { gz_statep state; @@ -519,7 +505,6 @@ const char * ZEXPORT gzerror(gzFile file, int *errnum) (state->msg == NULL ? "" : state->msg); } -/* -- see zlib.h -- */ void ZEXPORT gzclearerr(gzFile file) { gz_statep state; diff --git a/deps/zlib/gzread.c b/deps/zlib/gzread.c index 7f6ec7ed3d..b304b4eb15 100644 --- a/deps/zlib/gzread.c +++ b/deps/zlib/gzread.c @@ -276,7 +276,6 @@ local int gz_skip(gz_statep state, z_off64_t len) return 0; } -/* -- see zlib.h -- */ int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) { unsigned got, n; @@ -368,7 +367,6 @@ int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) return (int)got; } -/* -- see zlib.h -- */ #ifdef Z_PREFIX_SET # undef z_gzgetc #else @@ -407,7 +405,6 @@ int ZEXPORT gzgetc_(gzFile file) return gzgetc(file); } -/* -- see zlib.h -- */ int ZEXPORT gzungetc(int c, gzFile file) { gz_statep state; @@ -465,7 +462,6 @@ int ZEXPORT gzungetc(int c, gzFile file) return c; } -/* -- see zlib.h -- */ char * ZEXPORT gzgets(gzFile file, char *buf, int len) { unsigned left, n; @@ -526,7 +522,6 @@ char * ZEXPORT gzgets(gzFile file, char *buf, int len) return str; } -/* -- see zlib.h -- */ int ZEXPORT gzdirect(gzFile file) { gz_statep state; @@ -545,7 +540,6 @@ int ZEXPORT gzdirect(gzFile file) return state->direct; } -/* -- see zlib.h -- */ int gzclose_r(gzFile file) { int ret, err; diff --git a/deps/zlib/gzwrite.c b/deps/zlib/gzwrite.c index 61b217e23a..6c1c91bf0f 100644 --- a/deps/zlib/gzwrite.c +++ b/deps/zlib/gzwrite.c @@ -158,7 +158,6 @@ local int gz_zero(gz_statep state, z_off64_t len) return 0; } -/* -- see zlib.h -- */ int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) { unsigned put = len; @@ -235,7 +234,6 @@ int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) return (int)put; } -/* -- see zlib.h -- */ int ZEXPORT gzputc(gzFile file, int c) { unsigned have; @@ -281,7 +279,6 @@ int ZEXPORT gzputc(gzFile file, int c) return c & 0xff; } -/* -- see zlib.h -- */ int ZEXPORT gzputs(gzFile file, const char *str) { int ret; @@ -296,7 +293,6 @@ int ZEXPORT gzputs(gzFile file, const char *str) #if defined(STDC) || defined(Z_HAVE_STDARG_H) #include -/* -- see zlib.h -- */ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) { int size, len; @@ -372,7 +368,6 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) #else /* !STDC && !Z_HAVE_STDARG_H */ -/* -- see zlib.h -- */ int ZEXPORTVA gzprintf (gzFile file, const char *format, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14, int a15, int a16, int a17, int a18, int a19, int a20) { @@ -447,7 +442,6 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, int a1, int a2, int a3, #endif -/* -- see zlib.h -- */ int ZEXPORT gzflush(gzFile file, int flush) { gz_statep state; @@ -477,7 +471,6 @@ int ZEXPORT gzflush(gzFile file, int flush) return state->err; } -/* -- see zlib.h -- */ int ZEXPORT gzsetparams(gzFile file, int level, int strategy) { gz_statep state; @@ -516,7 +509,6 @@ int ZEXPORT gzsetparams(gzFile file, int level, int strategy) return Z_OK; } -/* -- see zlib.h -- */ int gzclose_w(gzFile file) { int ret = Z_OK; diff --git a/deps/zlib/infback.c b/deps/zlib/infback.c index 7206cde5c2..d8f91e3db5 100644 --- a/deps/zlib/infback.c +++ b/deps/zlib/infback.c @@ -10,7 +10,7 @@ inflate_fast() can be used with either inflate.c or infback.c. */ -#include "zutil.h" +#include #include "inftrees.h" #include "inflate.h" #include "inffast.h" diff --git a/deps/zlib/inffast.c b/deps/zlib/inffast.c index a88859f37d..01fe74a465 100644 --- a/deps/zlib/inffast.c +++ b/deps/zlib/inffast.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -#include "zutil.h" +#include #include "inftrees.h" #include "inflate.h" #include "inffast.h" diff --git a/deps/zlib/inflate.c b/deps/zlib/inflate.c index 0b4f0b7825..dfef06ecc1 100644 --- a/deps/zlib/inflate.c +++ b/deps/zlib/inflate.c @@ -80,7 +80,7 @@ * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. */ -#include "zutil.h" +#include #include "inftrees.h" #include "inflate.h" #include "inffast.h" diff --git a/deps/zlib/inftrees.c b/deps/zlib/inftrees.c index 8b8a9648f1..8ef80d6731 100644 --- a/deps/zlib/inftrees.c +++ b/deps/zlib/inftrees.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -#include "zutil.h" +#include #include "inftrees.h" #define MAXBITS 15 diff --git a/deps/zlib/ioapi.h b/deps/zlib/ioapi.h index a6332ed3d9..56637594db 100644 --- a/deps/zlib/ioapi.h +++ b/deps/zlib/ioapi.h @@ -42,7 +42,7 @@ #include #include -#include "zlib.h" +#include #if defined(USE_FILE32API) #define fopen64 fopen @@ -61,6 +61,16 @@ #endif #endif +#ifdef _Z_OF +#undef OF +#define OF _Z_OF +#else +#ifndef OF +#define _Z_OF(args) args +#define OF _Z_OF +#endif +#endif + /* #ifndef ZPOS64_T #ifdef _WIN32 diff --git a/deps/zlib/uncompr.c b/deps/zlib/uncompr.c index c7e30b3c7a..0697ed8dc1 100644 --- a/deps/zlib/uncompr.c +++ b/deps/zlib/uncompr.c @@ -6,7 +6,7 @@ /* @(#) $Id$ */ #define ZLIB_INTERNAL -#include "zlib.h" +#include /* =========================================================================== Decompresses the source buffer into the destination buffer. sourceLen is diff --git a/deps/zlib/unzip.c b/deps/zlib/unzip.c index 8f5730d25b..873cb4d855 100644 --- a/deps/zlib/unzip.c +++ b/deps/zlib/unzip.c @@ -72,7 +72,7 @@ #define NOUNCRYPT #endif -#include "zlib.h" +#include #include "unzip.h" #ifdef STDC diff --git a/deps/zlib/unzip.h b/deps/zlib/unzip.h index 3183968b77..1ceb5846b7 100644 --- a/deps/zlib/unzip.h +++ b/deps/zlib/unzip.h @@ -48,7 +48,7 @@ extern "C" { #endif #ifndef _ZLIB_H -#include "zlib.h" +#include #endif #ifndef _ZLIBIOAPI_H diff --git a/deps/zlib/zutil.c b/deps/zlib/zutil.c index c9353fe56d..97ad075ea6 100644 --- a/deps/zlib/zutil.c +++ b/deps/zlib/zutil.c @@ -5,12 +5,12 @@ /* @(#) $Id$ */ -#include "zutil.h" +#include #ifndef Z_SOLO # include "gzguts.h" #endif -char * const z_errmsg[10] = { +char z_errmsg[10][21] = { "need dictionary", /* Z_NEED_DICT 2 */ "stream end", /* Z_STREAM_END 1 */ "", /* Z_OK 0 */ diff --git a/dir_list_special.c b/dir_list_special.c index 9fdcb9c040..463359c43b 100644 --- a/dir_list_special.c +++ b/dir_list_special.c @@ -25,7 +25,7 @@ struct string_list *dir_list_new_special(const char *input_dir, enum dir_list_ty const char *exts = NULL; bool include_dirs = false; - global_t *global = global_get_ptr(); + global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); (void)input_dir; @@ -39,7 +39,7 @@ struct string_list *dir_list_new_special(const char *input_dir, enum dir_list_ty break; case DIR_LIST_CORE_INFO: dir = input_dir; - exts = (global->core_info) ? core_info_list_get_all_extensions(global->core_info) : NULL; + exts = (global->core_info.list) ? core_info_list_get_all_extensions(global->core_info.list) : NULL; break; case DIR_LIST_SHADERS: dir = settings->video.shader_dir; @@ -58,5 +58,5 @@ struct string_list *dir_list_new_special(const char *input_dir, enum dir_list_ty return NULL; } - return dir_list_new(dir, exts, include_dirs); + return dir_list_new(dir, exts, include_dirs, false); } diff --git a/dist-scripts/debian/retroarch.desktop b/dist-scripts/debian/retroarch.desktop deleted file mode 100644 index 29c921cb93..0000000000 --- a/dist-scripts/debian/retroarch.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Version=1.0 -Encoding=UTF-8 -Name=RetroArch -Type=Application -GenericName=RetroArch -Comment=RetroArch Multi-Engine Platform -Icon=/usr/share/pixmaps/retroarch.svg -Exec=retroarch -Terminal=false -StartupNotify=false -Categories=Game diff --git a/dist-scripts/debian/rules b/dist-scripts/debian/rules index 336f0af739..8ac765d0d0 100755 --- a/dist-scripts/debian/rules +++ b/dist-scripts/debian/rules @@ -46,7 +46,6 @@ override_dh_auto_build: override_dh_auto_install: # Add here commands to install the package into debian/retroarch. $(MAKE) DESTDIR=$(CURDIR)/debian/retroarch PREFIX=/usr install - cp $(CURDIR)/debian/retroarch.desktop $(CURDIR)/debian/retroarch/usr/share/applications/ cp $(CURDIR)/retroarch.cfg $(CURDIR)/debian/retroarch/etc/ ifeq ($(ARCH),armhf) rm -f $(CURDIR)/debian/retroarch/usr/bin/retroarch-cg2glsl diff --git a/dist-scripts/dist-cores.sh b/dist-scripts/dist-cores.sh new file mode 100755 index 0000000000..41d81019e6 --- /dev/null +++ b/dist-scripts/dist-cores.sh @@ -0,0 +1,234 @@ +#!/bin/sh + +RARCH_VERSION=1.2.2 +PLATFORM=$1 +SALAMANDER=no +MAKEFILE_GRIFFIN=no + +# PSP +if [ $PLATFORM = "psp1" ] ; then +platform=psp1 +SALAMANDER=yes +EXT=a + +mkdir -p ../pkg/${platform}/cores/ + +make -C ../${platform}/kernel_functions_prx/ clean || exit 1 +make -C ../${platform}/kernel_functions_prx/ || exit 1 +cp -f ../kernel_functions.prx ../pkg/${platform}/kernel_functions.prx + +# Vita +elif [ $PLATFORM = "vita" ] ; then +platform=vita +MAKEFILE_GRIFFIN=yes +EXT=a + +# CTR/3DS +elif [ $PLATFORM = "ctr" ] ; then +platform=ctr +EXT=a +mkdir -p ../pkg/3ds/elf +mkdir -p ../pkg/3ds/cia +mkdir -p ../pkg/3ds/3ds + +# Emscripten +elif [ $PLATFORM = "emscripten" ] ; then +platform=emscripten +EXT=bc + +if [ -z "$EMSCRIPTEN" ] ; then + echo "run this script with emmake. Ex: emmake $0" + exit 1 +fi + +# Wii +elif [ $PLATFORM = "wii" ] ; then +platform=wii +MAKEFILE_GRIFFIN=yes +SALAMANDER=yes +EXT=a + +# NGC +elif [ $PLATFORM = "ngc" ] ; then +platform=ngc +MAKEFILE_GRIFFIN=yes +EXT=a + +# DEX PS3 +elif [ $PLATFORM = "dex-ps3" ] ; then +platform=ps3 +SALAMANDER=yes +EXT=a + +EXE_PATH=/usr/local/cell/host-win32/bin +MAKE_FSELF_NPDRM=$EXE_PATH/make_fself_npdrm.exe +MAKE_PACKAGE_NPDRM=$EXE_PATH/make_package_npdrm.exe + +# CEX PS3 +elif [ $PLATFORM = "cex-ps3" ]; then +platform=ps3 +SALAMANDER=yes +EXT=a + +EXE_PATH=/usr/local/cell/host-win32/bin + +# ODE PS3 +elif [ $PLATFORM = "ode-ps3" ]; then +#For this script to work correctly, you must place the "data" folder containing your ps3 keys for scetool to use in the dist-scripts folder. +platform=ps3 +SALAMANDER=yes +EXT=a + +GENPS3ISO_PATH=/cygdrive/c/Cobra_ODE_GenPS3iso_v2.3/genps3iso.exe +SCETOOL_PATH=/cygdrive/c/Users/aaa801/ps3tools/ps3tools/tools/scetool/scetool.exe +SCETOOL_FLAGS="--sce-type SELF --compress-data FALSE --self-type APP --key-revision 0004 --self-fw-version 0003004100000000 --self-app-version 0001000000000000 --self-auth-id 1010000001000003 --self-vendor-id 01000002 --self-cap-flags 00000000000000000000000000000000000000000000003b0000000100040000" +fi + +# Cleanup Salamander core if it exists +if [ $SALAMANDER = "yes" ]; then +make -C ../ -f Makefile.${platform}.salamander clean || exit 1 +fi + +# Cleanup existing core if it exists +if [ $PLATFORM = "ode-ps3" ]; then + make -C ../ -f Makefile.${platform}.cobra clean || exit 1 +elif [ $MAKEFILE_GRIFFIN = "yes" ]; then + make -C ../ -f Makefile.griffin platform=${platform} clean || exit 1 +else + make -C ../ -f Makefile.${platform} clean || exit 1 +fi + +# Compile Salamander core +if [ $SALAMANDER = "yes" ]; then + make -C ../ -f Makefile.${platform}.salamander || exit 1 + if [ $PLATFORM = "psp1" ] ; then + mv -f ../EBOOT.PBP ../pkg/${platform}/EBOOT.PBP + fi +fi + +for f in *_${platform}.${EXT} ; do + name=`echo "$f" | sed "s/\(_libretro_${platform}\|\).${EXT}$//"` + lto=0 + whole_archive= + big_stack= + if [ $name = "nxengine" ] ; then + echo "Applying whole archive linking..." + whole_archive="WHOLE_ARCHIVE_LINK=1" + elif [ $name = "tyrquake" ] ; then + echo "Applying big stack..." + lto=0 + big_stack="BIG_STACK=1" + fi + echo "-- Building core: $name --" + cp -f "$f" ../libretro_${platform}.${EXT} + + # Do cleanup if this is a big stack core + if [ "$big_stack" = "BIG_STACK=1" ] ; then + if [ $MAKEFILE_GRIFFIN = "yes" ]; then + make -C ../ -f Makefile.griffin platform=${platform} clean || exit 1 + elif [ $PLATFORM = "emscripten" ]; then + make -C ../ -f Makefile.emscripten LTO=$lto -j7 clean || exit 1 + else + make -C ../ -f Makefile.${platform} clean || exit 1 + fi + fi + + # Compile core + if [ $PLATFORM = "ode-ps3" ] ; then + make -C ../ -f Makefile.${platform}.cobra $whole_archive -j3 || exit 1 + elif [ $MAKEFILE_GRIFFIN = "yes" ]; then + make -C ../ -f Makefile.griffin platform=${platform} $whole_archive $big_stack -j3 || exit 1 + elif [ $PLATFORM = "emscripten" ]; then + make -C ../ -f Makefile.emscripten LTO=$lto -j7 || exit 1 + elif [ $PLATFORM = "ctr" ]; then + make -C ../ -f Makefile.${platform} LIBRETRO=$name $whole_archive $big_stack -j3 || exit 1 + else + make -C ../ -f Makefile.${platform} $whole_archive $big_stack -j3 || exit 1 + fi + + # Do manual executable step + if [ $PLATFORM = "dex-ps3" ] ; then + $MAKE_FSELF_NPDRM ../retroarch_${platform}.elf ../CORE.SELF + elif [ $PLATFORM = "cex-ps3" ] ; then + make_self_wc ../retroarch_${platform}.elf ../CORE.SELF + elif [ $PLATFORM = "ode-ps3" ] ; then + $SCETOOL_PATH $SCETOOL_FLAGS --encrypt ../retroarch_${platform}.elf ../CORE.SELF + fi + + # Move executable files + if [ $platform = "ps3" ] ; then + if [ $PLATFORM = "ode-ps3" ] ; then + mv -f ../CORE.SELF ../${platform}/iso/PS3_GAME/USRDIR/cores/"${name}_libretro_${platform}.SELF" + else + mv -f ../CORE.SELF ../pkg/${platform}/USRDIR/cores/"${name}_libretro_${platform}.SELF" + fi + elif [ $PLATFORM = "psp1" ] ; then + mv -f ../EBOOT.PBP ../pkg/${platform}/cores/${name}_libretro.PBP + elif [ $PLATFORM = "vita" ] ; then + mv -f ../retroarch_${platform}.velf ../pkg/${platform}/${name}_libretro_${platform}.velf + elif [ $PLATFORM = "ctr" ] ; then + mv -f ../retroarch_3ds.cia ../pkg/3ds/cia/${name}_libretro.cia + mv -f ../retroarch_3ds.elf ../pkg/3ds/elf/${name}_libretro.elf + mkdir -p ../pkg/3ds/3ds/${name}_libretro + mv -f ../retroarch_3ds.3dsx ../pkg/3ds/3ds/${name}_libretro/${name}_libretro.3dsx + mv -f ../retroarch_3ds.smdh ../pkg/3ds/3ds/${name}_libretro/${name}_libretro.smdh + elif [ $PLATFORM = "ngc" ] ; then + mv -f ../retroarch_${platform}.dol ../pkg/${platform}/${name}_libretro_${platform}.dol + elif [ $PLATFORM = "wii" ] ; then + mv -f ../retroarch_${platform}.dol ../pkg/${platform}/${name}_libretro_${platform}.dol + elif [ $PLATFORM = "emscripten" ] ; then + mv -f ../retroarch.js ../emscripten/$name.js + fi + + # Remove executable files + if [ $platform = "ps3" ] ; then + rm -f ../retroarch_${platform}.elf ../retroarch_${platform}.self ../CORE.SELF + elif [ $PLATFORM = "psp1" ] ; then + rm -f ../retroarchpsp.elf + elif [ $PLATFORM = "vita" ] ; then + rm -f ../retroarch_${platform}.velf ../retroarch_${platform}.elf + elif [ $PLATFORM = "ctr" ] ; then + rm -f ../retroarch_3ds_stripped.elf + rm -f ../retroarch_3ds.rsf + rm -f ../retroarch_3ds.bnr + rm -f ../retroarch_3ds.icn + elif [ $PLATFORM = "ngc" ] ; then + rm -f ../retroarch_${platform}.dol ../retroarch_${platform}.elf ../retroarch_${platform}.elf.map + elif [ $PLATFORM = "wii" ] ; then + rm -f ../retroarch_${platform}.dol ../retroarch_${platform}.elf ../retroarch_${platform}.elf.map + elif [ $platform = "emscripten" ] ; then + rm -f ../retroarch.js + fi + + # Do cleanup if this is a big stack core + if [ "$big_stack" = "BIG_STACK=1" ] ; then + if [ $MAKEFILE_GRIFFIN = "yes" ]; then + make -C ../ -f Makefile.griffin platform=${platform} clean || exit 1 + elif [ $PLATFORM = "emscripten" ]; then + make -C ../ -f Makefile.emscripten LTO=$lto -j7 clean || exit 1 + else + make -C ../ -f Makefile.${platform} clean || exit 1 + fi + fi +done + +# Additional build step +if [ $PLATFORM = "ps3" ] ; then + make -C ../ -f Makefile.griffin platform=${platform} shaders-deploy +fi + +# Packaging +if [ $PLATFORM = "dex-ps3" ] ; then + $MAKE_FSELF_NPDRM ../retroarch-salamander_${platform}.elf ../pkg/${platform}/USRDIR/EBOOT.BIN + rm -rf ../retroarch-salamander_${platform}.elf + $MAKE_PACKAGE_NPDRM ../pkg/${platform}/package.conf ../pkg/${platform} +elif [ $PLATFORM = "cex-ps3" ] ; then + make_self_wc ../retroarch-salamander_${platform}.elf ../pkg/${platform}/USRDIR/EBOOT.BIN + rm -rf ../retroarch-salamander_${platform}.elf + python2 ../ps3/ps3py/pkg.py --contentid UP0001-SSNE10000_00-0000000000000001 ../pkg/${platform} retroarch-${platform}-cfw-$RARCH_VERSION.pkg +elif [ $PLATFORM = "ode-ps3" ] ; then + $SCETOOL_PATH $SCETOOL_FLAGS --encrypt ../retroarch-salamander_${platform}.elf ../${platform}/iso/PS3_GAME/USRDIR/EBOOT.BIN + rm -rf ../retroarch-salamander_${platform}.elf + + $GENPS3ISO_PATH ../${platform}/iso RetroArch-COBRA-ODE.iso +fi diff --git a/dist-scripts/emscripten-cores.sh b/dist-scripts/emscripten-cores.sh deleted file mode 100755 index 8b82b3d56b..0000000000 --- a/dist-scripts/emscripten-cores.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -if [ -z "$EMSCRIPTEN" ] ; then - echo "run this script with emmake. Ex: emmake $0" - exit 1 -fi - -make -C ../ -f Makefile.emscripten clean || exit 1 - -for f in *_emscripten.bc ; do - name=`echo "$f" | sed 's/\(_libretro_emscripten\|\).bc$//'` - lto=0 - echo "building $name" - if [ $name = "tyrquake" ] ; then - lto=0 - fi - cp -f "$f" ../libretro_emscripten.bc - make -C ../ -f Makefile.emscripten LTO=$lto -j7 || exit 1 - cp -fv ../retroarch.js ../emscripten/$name.js - rm -f ../retroarch.js -done diff --git a/dist-scripts/ngc-cores.sh b/dist-scripts/ngc-cores.sh deleted file mode 100755 index c9dc2d7686..0000000000 --- a/dist-scripts/ngc-cores.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -make -C ../ -f Makefile.griffin platform=ngc clean || exit 1 - -for f in *_ngc.a ; do - name=`echo "$f" | sed 's/\(_libretro_ngc\|\).a$//'` - whole_archive= - big_stack= - if [ $name = "nxengine" ] ; then - echo "NXEngine found, applying whole archive linking..." - whole_archive="WHOLE_ARCHIVE_LINK=1" - fi - if [ $name = "tyrquake" ] ; then - echo "Tyrquake found, applying big stack..." - big_stack="BIG_STACK=1" - fi - cp -f "$f" ../libretro_ngc.a - make -C ../ -f Makefile.griffin platform=ngc $whole_archive $big_stack -j3 || exit 1 - mv -f ../retroarch_ngc.dol ../ngc/pkg/${name}_libretro_ngc.dol - rm -f ../retroarch_ngc.dol ../retroarch_ngc.elf ../retroarch_ngc.elf.map -done diff --git a/dist-scripts/ps3-cores-cex-355.sh b/dist-scripts/ps3-cores-cex-355.sh deleted file mode 100755 index 7592a4f8e5..0000000000 --- a/dist-scripts/ps3-cores-cex-355.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -RARCH_VERSION=0.9.9 - -make -C ../ -f Makefile.ps3.salamander clean || exit 1 -make -C ../ -f Makefile.ps3 clean || exit 1 - -make -C ../ -f Makefile.ps3.salamander || exit 1 - -EXE_PATH=/usr/local/cell/host-win32/bin - -for f in *_ps3.a ; do - name=`echo "$f" | sed 's/\(_libretro_ps3\|\).a$//'` - whole_archive= - if [ $name = "nxengine" ] ; then - echo "NXEngine found, applying whole archive linking..." - whole_archive="WHOLE_ARCHIVE_LINK=1" - echo $name yes - fi - cp -f "$f" ../libretro_ps3.a - make -C ../ -f Makefile.ps3 $whole_archive -j3 || exit 1 - make_self_wc ../retroarch_ps3.elf ../CORE.SELF - mv -f ../CORE.SELF ../ps3/pkg/USRDIR/cores/"${name}_libretro_ps3.SELF" - rm -f ../retroarch_ps3.elf ../retroarch_ps3.self ../CORE.SELF -done - -cp -r ../media/rmenu/*.png ../ps3/pkg/USRDIR/cores/borders/Menu/ - -make -C ../ -f Makefile.shaders deploy-ps3 - -make_self_wc ../retroarch-salamander_ps3.elf ../ps3/pkg/USRDIR/EBOOT.BIN -rm -rf ../retroarch-salamander_ps3.elf -python2 ../ps3/ps3py/pkg.py --contentid UP0001-SSNE10000_00-0000000000000001 ../ps3/pkg/ retroarch-ps3-cfw-$RARCH_VERSION.pkg diff --git a/dist-scripts/ps3-cores-cobraode.sh b/dist-scripts/ps3-cores-cobraode.sh deleted file mode 100644 index 65346ea5a6..0000000000 --- a/dist-scripts/ps3-cores-cobraode.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -#For this script to work correctly, you must place the "data" folder containing your ps3 keys for scetool to use in the dist-scripts folder. - -make -C ../ -f Makefile.ps3.salamander clean || exit 1 -make -C ../ -f Makefile.ps3.cobra clean || exit 1 - -make -C ../ -f Makefile.ps3.salamander || exit 1 - -GENPS3ISO_PATH=/cygdrive/c/Cobra_ODE_GenPS3iso_v2.3/genps3iso.exe -SCETOOL_PATH=/cygdrive/c/Users/aaa801/ps3tools/ps3tools/tools/scetool/scetool.exe -SCETOOL_FLAGS="--sce-type SELF --compress-data FALSE --self-type APP --key-revision 0004 --self-fw-version 0003004100000000 --self-app-version 0001000000000000 --self-auth-id 1010000001000003 --self-vendor-id 01000002 --self-cap-flags 00000000000000000000000000000000000000000000003b0000000100040000" - -for f in *_ps3.a ; do - name=`echo "$f" | sed 's/\(_libretro_ps3\|\).a$//'` - whole_archive= - if [ $name = "nxengine" ] ; then - echo "NXEngine found, applying whole archive linking..." - whole_archive="WHOLE_ARCHIVE_LINK=1" - echo $name yes - fi - cp -f "$f" ../libretro_ps3.a - make -C ../ -f Makefile.ps3.cobra $whole_archive -j3 || exit 1 - $SCETOOL_PATH $SCETOOL_FLAGS --encrypt ../retroarch_ps3.elf ../CORE.SELF - mv -f ../CORE.SELF ../ps3/iso/PS3_GAME/USRDIR/cores/"${name}_libretro_ps3.SELF" - rm -f ../retroarch_ps3.elf ../retroarch_ps3.self ../CORE.SELF -done - -cp -r ../media/rmenu/*.png ../ps3/iso/PS3_GAME/USRDIR/cores/borders/Menu/ - -make -C ../ -f Makefile.griffin platform=ps3-cobra shaders-deploy - -$SCETOOL_PATH $SCETOOL_FLAGS --encrypt ../retroarch-salamander_ps3.elf ../ps3/iso/PS3_GAME/USRDIR/EBOOT.BIN -rm -rf ../retroarch-salamander_ps3.elf - -$GENPS3ISO_PATH ../ps3/iso RetroArch-COBRA-ODE.iso diff --git a/dist-scripts/ps3-cores-dex.sh b/dist-scripts/ps3-cores-dex.sh deleted file mode 100755 index 8900acb0d4..0000000000 --- a/dist-scripts/ps3-cores-dex.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -make -C ../ -f Makefile.ps3.salamander clean || exit 1 -make -C ../ -f Makefile.ps3 clean || exit 1 - -make -C ../ -f Makefile.ps3.salamander || exit 1 - -EXE_PATH=/usr/local/cell/host-win32/bin -MAKE_FSELF_NPDRM=$EXE_PATH/make_fself_npdrm.exe -MAKE_PACKAGE_NPDRM=$EXE_PATH/make_package_npdrm.exe - -for f in *_ps3.a ; do - name=`echo "$f" | sed 's/\(_libretro_ps3\|\).a$//'` - whole_archive= - if [ $name = "nxengine" ] ; then - echo "NXEngine found, applying whole archive linking..." - whole_archive="WHOLE_ARCHIVE_LINK=1" - echo $name yes - fi - if [ $name = "tyrquake" ] ; then - echo "Tyrquake found, applying big stack..." - big_stack="BIG_STACK=1" - fi - cp -f "$f" ../libretro_ps3.a - make -C ../ -f Makefile.ps3 $whole_archive $big_stack -j3 || exit 1 - $MAKE_FSELF_NPDRM ../retroarch_ps3.elf ../CORE.SELF - mv -f ../CORE.SELF ../ps3/pkg/USRDIR/cores/"${name}_libretro_ps3.SELF" - rm -f ../retroarch_ps3.elf ../retroarch_ps3.self ../CORE.SELF -done - -cp -r ../media/rmenu/*.png ../ps3/pkg/USRDIR/cores/borders/Menu/ - -make -C ../ -f Makefile.griffin platform=ps3 shaders-deploy - -$MAKE_FSELF_NPDRM ../retroarch-salamander_ps3.elf ../ps3/pkg/USRDIR/EBOOT.BIN -rm -rf ../retroarch-salamander_ps3.elf -$MAKE_PACKAGE_NPDRM ../ps3/pkg/package.conf ../ps3/pkg diff --git a/dist-scripts/psp1-cores.sh b/dist-scripts/psp1-cores.sh deleted file mode 100755 index 5d31400b2a..0000000000 --- a/dist-scripts/psp1-cores.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -mkdir -p ../psp1/pkg/cores/ - -make -C ../psp1/kernelFunctionsPrx/ clean || exit 1 -make -C ../psp1/kernelFunctionsPrx/ || exit 1 -cp -f ../kernel_functions.prx ../psp1/pkg/kernel_functions.prx - -make -C ../ -f Makefile.psp1.salamander clean || exit 1 -make -C ../ -f Makefile.psp1.salamander || exit 1 -mv -f ../EBOOT.PBP ../psp1/pkg/EBOOT.PBP - -make -C ../ -f Makefile.psp1 clean || exit 1 - -for f in *_psp1.a ; do - name=`echo "$f" | sed 's/\(_libretro_psp1\|\).a$//'` - whole_archive= - big_stack= - - if [ $name = "nxengine" ] ; then - echo "NXEngine found, applying whole archive linking..." - whole_archive="WHOLE_ARCHIVE_LINK=1" - fi - - if [ $name = "tyrquake" ] ; then - echo "Tyrquake found, applying big stack..." - big_stack="BIG_STACK=1" - fi - - if [ $big_stack="BIG_STACK=1" ] ; then - make -C ../ -f Makefile.psp1 clean || exit 1 - fi - - cp -f "$f" ../libretro_psp1.a - make -C ../ -f Makefile.psp1 $whole_archive $big_stack -j3 || exit 1 - mv -f ../EBOOT.PBP ../psp1/pkg/cores/${name}_libretro.PBP - rm -f ../retroarchpsp.elf - - if [ $big_stack="BIG_STACK=1" ] ; then - make -C ../ -f Makefile.psp1 clean || exit 1 - fi -done diff --git a/dist-scripts/wii-cores.sh b/dist-scripts/wii-cores.sh deleted file mode 100755 index 78d9d37d7d..0000000000 --- a/dist-scripts/wii-cores.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -make -C ../ -f Makefile.wii.salamander clean || exit 1 -make -C ../ -f Makefile.griffin platform=wii clean || exit 1 - -make -C ../ -f Makefile.wii.salamander || exit 1 -make -C ../ -f Makefile.wii.salamander pkg || exit 1 - -for f in *_wii.a ; do - name=`echo "$f" | sed 's/\(_libretro_wii\|\).a$//'` - whole_archive= - big_stack= - if [ $name = "nxengine" ] ; then - echo "NXEngine found, applying whole archive linking..." - whole_archive="WHOLE_ARCHIVE_LINK=1" - fi - if [ $name = "tyrquake" ] ; then - echo "Tyrquake found, applying big stack..." - big_stack="BIG_STACK=1" - fi - cp -f "$f" ../libretro_wii.a - make -C ../ -f Makefile.griffin platform=wii $whole_archive $big_stack -j3 || exit 1 - mv -f ../retroarch_wii.dol ../wii/pkg/${name}_libretro_wii.dol - rm -f ../retroarch_wii.dol ../retroarch_wii.elf ../retroarch_wii.elf.map -done diff --git a/dist-scripts/xdk1-cores.sh b/dist-scripts/xdk1-cores.sh index 3892a64b49..f47e0ab284 100644 --- a/dist-scripts/xdk1-cores.sh +++ b/dist-scripts/xdk1-cores.sh @@ -1,25 +1,22 @@ #!/bin/sh +platform=xdk + ip='192.168.1.10' -#make -C ../ -f Makefile.wii.salamander clean || exit 1 -#make -C ../ -f Makefile.wii clean || exit 1 - -#make -C ../ -f Makefile.wii.salamander || exit 1 -#make -C ../ -f Makefile.wii.salamander pkg || exit 1 mkdir -p ../msvc/RetroArch-Xbox1/Debug mkdir -p ../msvc/RetroArch-Xbox1/Release mkdir -p ../msvc/RetroArch-Xbox1/Release_LTCG -for f in *_xdk.lib ; do - name=`echo "$f" | sed 's/\(_libretro_xdk\|\).lib$//'` +for f in *_${platform}.lib ; do + name=`echo "$f" | sed "s/\(_libretro_${platform}\|\).lib$//"` echo $name if [ $name = "tyrquake" ] || [ $name = "genesis_plus_gx" ] ; then echo "Applying whole archive linking for this core..." - cp -f "$f" ../msvc/RetroArch-Xbox1/Release_LTCG_BigStack/libretro_xdk.lib + cp -f "$f" ../msvc/RetroArch-Xbox1/Release_LTCG_BigStack/libretro_${platform}.lib cmd.exe /k xdk1_env_bigstack.bat ${name}_libretro_xdk1 else - cp -f "$f" ../msvc/RetroArch-Xbox1/Release_LTCG/libretro_xdk.lib + cp -f "$f" ../msvc/RetroArch-Xbox1/Release_LTCG/libretro_${platform}.lib cmd.exe /k xdk1_env.bat ${name}_libretro_xdk1 fi done diff --git a/dist-scripts/xdk360-cores.sh b/dist-scripts/xdk360-cores.sh index cfd5e2dec1..7053bd6044 100644 --- a/dist-scripts/xdk360-cores.sh +++ b/dist-scripts/xdk360-cores.sh @@ -1,17 +1,14 @@ #!/bin/sh -#make -C ../ -f Makefile.wii.salamander clean || exit 1 -#make -C ../ -f Makefile.wii clean || exit 1 +platform=xdk360 -#make -C ../ -f Makefile.wii.salamander || exit 1 -#make -C ../ -f Makefile.wii.salamander pkg || exit 1 mkdir -p ../msvc/RetroArch-360/Debug mkdir -p ../msvc/RetroArch-360/Release mkdir -p ../msvc/RetroArch-360/Release_LTCG -for f in *_xdk360.lib ; do - name=`echo "$f" | sed 's/\(_libretro_xdk360\|\).lib$//'` +for f in *_${platform}.lib ; do + name=`echo "$f" | sed "s/\(_libretro_${platform}\|\).lib$//"` echo $name - cp -f "$f" ../msvc/RetroArch-360/Release_LTCG/libretro_xdk360.lib - cmd.exe /k xdk360_env.bat ${name}_libretro_xdk360 + cp -f "$f" ../msvc/RetroArch-360/Release_LTCG/libretro_${platform}.lib + cmd.exe /k ${platform}_env.bat ${name}_libretro_${platform} done diff --git a/driver.c b/driver.c index 99caba7330..27f35a2813 100644 --- a/driver.c +++ b/driver.c @@ -14,11 +14,10 @@ * If not, see . */ -#include "driver.h" +#include + #include "general.h" -#include "retroarch.h" #include "msg_hash.h" -#include "compat/posix_string.h" #include "gfx/video_monitor.h" #include "audio/audio_monitor.h" @@ -32,35 +31,21 @@ #include "config.h" #endif -static driver_t *g_driver = NULL; +static driver_t g_driver; void driver_free(void) { - if (g_driver) - free(g_driver); - - g_driver = NULL; -} - -static driver_t *driver_new(void) -{ - driver_t *driver = (driver_t*)calloc(1, sizeof(driver_t)); - - if (!driver) - return NULL; - - return driver; + memset(&g_driver, 0, sizeof(g_driver)); } void driver_clear_state(void) { driver_free(); - g_driver = driver_new(); } driver_t *driver_get_ptr(void) { - return g_driver; + return &g_driver; } #define HASH_LOCATION_DRIVER 0x09189689U diff --git a/driver.h b/driver.h index f77af8debf..83e4d3f185 100644 --- a/driver.h +++ b/driver.h @@ -194,7 +194,7 @@ enum typedef struct driver { - const frontend_ctx_driver_t *frontend_ctx; + frontend_ctx_driver_t *frontend_ctx; const ui_companion_driver_t *ui_companion; const audio_driver_t *audio; const video_driver_t *video; diff --git a/dynamic.c b/dynamic.c index cb1d3a9fbc..641d2672bf 100644 --- a/dynamic.c +++ b/dynamic.c @@ -17,14 +17,6 @@ #include #include -#ifdef NEED_DYNAMIC -#ifdef _WIN32 -#include -#else -#include -#endif -#endif - #include #include #include @@ -35,13 +27,11 @@ #include "config.h" #endif -#include "dynamic.h" #include "performance.h" #include "libretro_private.h" #include "cores/internal_cores.h" #include "retroarch.h" -#include "runloop.h" #include "configuration.h" #include "general.h" #include "msg_hash.h" @@ -337,6 +327,7 @@ static void load_symbols(enum rarch_core_type type) { RARCH_ERR("Failed to open libretro core: \"%s\"\n", settings->libretro); + RARCH_ERR("Error(s): %s\n", dylib_error()); rarch_fail(1, "load_dynamic()"); } #endif @@ -520,10 +511,10 @@ void libretro_get_current_core_pathname(char *name, size_t size) { char c = id[i]; - if (isspace(c) || isblank(c)) + if (isspace((int)c) || isblank((int)c)) name[i] = '_'; else - name[i] = tolower(c); + name[i] = tolower((int)c); } } @@ -703,9 +694,9 @@ bool rarch_environment_cb(unsigned cmd, void *data) char buf[PATH_MAX_LENGTH] = {0}; const char *options_path = settings->core_options_path; - if (!*options_path && *global->config_path) + if (!*options_path && *global->path.config) { - fill_pathname_resolve_relative(buf, global->config_path, + fill_pathname_resolve_relative(buf, global->path.config, "retroarch-core-options.cfg", sizeof(buf)); options_path = buf; } @@ -751,24 +742,30 @@ bool rarch_environment_cb(unsigned cmd, void *data) break; case RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY: - if (!settings->system_directory || settings->system_directory[0] == '\0') + if (settings->system_directory[0] == '\0') { - RARCH_WARN("SYSTEM DIR is empty, fill assume CONTENT DIR %s\n",global->fullpath); - fill_pathname_basedir(settings->system_directory, global->fullpath, - sizeof(settings->system_directory)); - } - *(const char**)data = *settings->system_directory ? - settings->system_directory : NULL; + RARCH_WARN("SYSTEM DIR is empty, assume CONTENT DIR %s\n",global->path.fullpath); + fill_pathname_basedir(global->dir.systemdir, global->path.fullpath, + sizeof(global->dir.systemdir)); - RARCH_LOG("Environ SYSTEM_DIRECTORY: \"%s\".\n", + *(const char**)data = global->dir.systemdir; + RARCH_LOG("Environ SYSTEM_DIRECTORY: \"%s\".\n", + global->dir.systemdir); + } + else + { + *(const char**)data = settings->system_directory; + RARCH_LOG("Environ SYSTEM_DIRECTORY: \"%s\".\n", settings->system_directory); + } + break; case RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY: - *(const char**)data = *global->savefile_dir ? - global->savefile_dir : NULL; + *(const char**)data = *global->dir.savefile ? + global->dir.savefile : NULL; RARCH_LOG("Environ SAVE_DIRECTORY: \"%s\".\n", - global->savefile_dir); + global->dir.savefile); break; case RETRO_ENVIRONMENT_GET_USERNAME: @@ -893,7 +890,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) } } - global->has_set_input_descriptors = true; + global->has_set.input_descriptors = true; break; } @@ -1020,7 +1017,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) return false; #ifdef HAVE_NETPLAY - if (global->netplay_enable) + if (global->netplay.enable) return false; #endif @@ -1039,7 +1036,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) #ifdef HAVE_NETPLAY /* retro_run() will be called in very strange and * mysterious ways, have to disable it. */ - if (global->netplay_enable) + if (global->netplay.enable) return false; #endif @@ -1258,12 +1255,13 @@ bool rarch_environment_cb(unsigned cmd, void *data) case RETRO_ENVIRONMENT_EXEC: case RETRO_ENVIRONMENT_EXEC_ESCAPE: - - if (data) - strlcpy(global->fullpath, (const char*)data, - sizeof(global->fullpath)); - else - *global->fullpath = '\0'; + if (global->path.fullpath != data) + { + *global->path.fullpath = '\0'; + if (data) + strlcpy(global->path.fullpath, (const char*)data, + sizeof(global->path.fullpath)); + } #if defined(RARCH_CONSOLE) if (driver->frontend_ctx && driver->frontend_ctx->set_fork) diff --git a/emscripten/library_rwebaudio.js b/emscripten/library_rwebaudio.js index 23142a6b17..a4debaba4f 100644 --- a/emscripten/library_rwebaudio.js +++ b/emscripten/library_rwebaudio.js @@ -1,4 +1,4 @@ -//"use strict"; +"use strict"; var LibraryRWebAudio = { $RA__deps: ['$Browser', 'usleep'], @@ -11,19 +11,33 @@ var LibraryRWebAudio = { bufIndex: 0, bufOffset: 0, startTime: 0, + performance: null, nonblock: false, - currentTimeWorkaround: false, + performanceSupported: false, setStartTime: function() { + RA.performance = window['performance'] || window['webkitPerformance'] || window['msPerformance'] || window['mozPerformance']; + if (RA.performance) { + RA.performanceSupported = true; + } else { + RA.performanceSupported = false; + } + if (RA.context.currentTime) { - RA.startTime = window['performance']['now']() - RA.context.currentTime * 1000; - Module["resumeMainLoop"](); - } else window['setTimeout'](RA.setStartTime, 0); + var now = RA.performanceSupported ? RA.performance.now() : Date.now(); + RA.startTime = now - RA.context.currentTime * 1000; + Module["resumeMainLoop"]; + } else { + window.setTimeout(RA.setStartTime, 0); + } }, getCurrentPerfTime: function() { - if (RA.startTime) return (window['performance']['now']() - RA.startTime) / 1000; - else throw 'getCurrentPerfTime() called before start time set'; + if (true === RA.performanceSupported) { + return (RA.performance.now() - RA.startTime) / 1000; + } else { + return (Date.now() - RA.startTime) / 1000; + } }, process: function(queueBuffers) { @@ -78,11 +92,14 @@ var LibraryRWebAudio = { }, RWebAudioInit: function(latency) { - var ac = window['AudioContext'] || window['webkitAudioContext']; - - if (!ac) return 0; - - RA.context = new ac(); + Module.pauseMainLoop(); + if (!RA.context) { + var ac = window['AudioContext'] || window['webkitAudioContext']; + if (!ac) { + return 0; + } + RA.context = new ac(); + } RA.numBuffers = ((latency * RA.context.sampleRate) / (1000 * RA.BUFFER_SIZE))|0; if (RA.numBuffers < 2) RA.numBuffers = 2; @@ -93,8 +110,8 @@ var LibraryRWebAudio = { RA.startTime = 0; // chrome hack to get currentTime running RA.context.createGain(); - window['setTimeout'](RA.setStartTime, 0); - Module["pauseMainLoop"](); + RA.setStartTime(); + return 1; }, diff --git a/emscripten/library_rwebinput.js b/emscripten/library_rwebinput.js index 7b02bbd834..5d818f7805 100644 --- a/emscripten/library_rwebinput.js +++ b/emscripten/library_rwebinput.js @@ -5,22 +5,13 @@ var LibraryRWebInput = { $RI: { temp: null, contexts: [], + stateX: 0, + stateY: 0, + currentX: 0, + currentY: 0, - eventHandler: function(event) { - var i; + canvasEventHandler: function(event) { switch (event.type) { - case 'mousemove': - var x = event['movementX'] || event['mozMovementX'] || event['webkitMovementX']; - var y = event['movementY'] || event['mozMovementY'] || event['webkitMovementY']; - for (i = 0; i < RI.contexts.length; i++) { - var oldX = {{{ makeGetValue('RI.contexts[i].state', '32', 'i32') }}}; - var oldY = {{{ makeGetValue('RI.contexts[i].state', '36', 'i32') }}}; - x += oldX; - y += oldY; - {{{ makeSetValue('RI.contexts[i].state', '32', 'x', 'i32') }}}; - {{{ makeSetValue('RI.contexts[i].state', '36', 'y', 'i32') }}}; - } - break; case 'mouseup': case 'mousedown': var value; @@ -30,10 +21,53 @@ var LibraryRWebInput = { else break; if (event.type === 'mouseup') value = 0; else value = 1; - for (i = 0; i < RI.contexts.length; i++) { + for (var i = 0; i < RI.contexts.length; i++) { {{{ makeSetValue('RI.contexts[i].state', 'offset', 'value', 'i8') }}}; } break; + } + }, + + eventHandler: function(event) { + var i; + switch (event.type) { + case 'mousemove': + var x = 0; + var y = 0; + + var newX = event['clientX'] - Module.canvas.offsetLeft; + var newY = event['clientY'] - Module.canvas.offsetTop; + + if (newX < 0) { + newX = 0; + x = -Module.canvas.offsetWidth; + } else if (newX > Module.canvas.offsetWidth) { + newX = Module.canvas.offsetWidth; + x = Module.canvas.offsetWidth; + } else { + x = newX - RI.currentX; + } + + if (newY < 0) { + newY = 0; + y = -Module.canvas.offsetHeight; + } else if (newY > Module.canvas.offsetHeight) { + newY = Module.canvas.offsetHeight; + y = Module.canvas.offsetHeight; + } else { + y = newY - RI.currentY; + } + + RI.currentX = newX; + RI.currentY = newY; + + for (i = 0; i < RI.contexts.length; i++) { + {{{ makeSetValue('RI.contexts[i].state', '32', 'x', 'i32') }}}; + {{{ makeSetValue('RI.contexts[i].state', '36', 'y', 'i32') }}}; + } + + break; + case 'keyup': case 'keydown': var key = event.keyCode; @@ -48,6 +82,7 @@ var LibraryRWebInput = { } event.preventDefault(); break; + case 'blur': case 'visibilitychange': for (i = 0; i < RI.contexts.length; i++) { @@ -63,8 +98,8 @@ var LibraryRWebInput = { document.addEventListener('keyup', RI.eventHandler, false); document.addEventListener('keydown', RI.eventHandler, false); document.addEventListener('mousemove', RI.eventHandler, false); - document.addEventListener('mouseup', RI.eventHandler, false); - document.addEventListener('mousedown', RI.eventHandler, false); + Module.canvas.addEventListener('mouseup', RI.canvasEventHandler, false); + Module.canvas.addEventListener('mousedown', RI.canvasEventHandler, false); document.addEventListener('blur', RI.eventHandler, false); document.addEventListener('onvisbilitychange', RI.eventHandler, false); } @@ -95,8 +130,8 @@ var LibraryRWebInput = { document.removeEventListener('keyup', RI.eventHandler, false); document.removeEventListener('keydown', RI.eventHandler, false); document.removeEventListener('mousemove', RI.eventHandler, false); - document.removeEventListener('mouseup', RI.eventHandler, false); - document.removeEventListener('mousedown', RI.eventHandler, false); + Module.canvas.removeEventListener('mouseup', RI.canvasEventHandler, false); + Module.canvas.removeEventListener('mousedown', RI.canvasEventHandler, false); document.removeEventListener('blur', RI.eventHandler, false); document.removeEventListener('onvisbilitychange', RI.eventHandler, false); } diff --git a/file_ext.h b/file_ext.h index 5616e68d7b..b1976bace2 100644 --- a/file_ext.h +++ b/file_ext.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2015 - 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. @@ -32,6 +32,9 @@ #elif defined(PSP) #define EXT_EXECUTABLES "pbp" #define SALAMANDER_FILE "EBOOT.PBP" +#elif defined(VITA) +#define EXT_EXECUTABLES "velf" +#define SALAMANDER_FILE "default.velf" #elif defined(_XBOX1) #define EXT_EXECUTABLES "xbe" #define SALAMANDER_FILE "default.xbe" diff --git a/file_ops.c b/file_ops.c index 090003c6e2..3fadbbaccf 100644 --- a/file_ops.c +++ b/file_ops.c @@ -1,6 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2015 - Daniel De Matteis + * Copyright (C) 2014-2015 - Timo Strunk * * 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- @@ -14,51 +15,608 @@ * If not, see . */ -#include "file_ops.h" -#include +#include +#include #include -#include +#include #include #include #include + +#include + #include #include +#include #include - +#include +#include #ifdef HAVE_COMPRESSION #include #endif +#include "file_ops.h" + +#ifdef HAVE_COMPRESSION #ifdef HAVE_7ZIP -#include "decompress/7zip_support.h" +#include "deps/7zip/7z.h" +#include "deps/7zip/7zAlloc.h" +#include "deps/7zip/7zCrc.h" +#include "deps/7zip/7zFile.h" +#include "deps/7zip/7zVersion.h" + +static ISzAlloc g_Alloc = { SzAlloc, SzFree }; + +static int Buf_EnsureSize(CBuf *dest, size_t size) +{ + if (dest->size >= size) + return 1; + Buf_Free(dest, &g_Alloc); + return Buf_Create(dest, size, &g_Alloc); +} + +#ifndef _WIN32 + +static uint8_t kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + +static Bool Utf16_To_Utf8(uint8_t *dest, size_t *destLen, + const uint16_t *src, size_t srcLen) +{ + size_t destPos = 0; + size_t srcPos = 0; + + for (;;) + { + unsigned numAdds; + uint32_t value; + + if (srcPos == srcLen) + { + *destLen = destPos; + return True; + } + value = src[srcPos++]; + if (value < 0x80) + { + if (dest) + dest[destPos] = (char)value; + destPos++; + continue; + } + if (value >= 0xD800 && value < 0xE000) + { + uint32_t c2; + + if (value >= 0xDC00 || srcPos == srcLen) + break; + c2 = src[srcPos++]; + if (c2 < 0xDC00 || c2 >= 0xE000) + break; + value = (((value - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000; + } + for (numAdds = 1; numAdds < 5; numAdds++) + if (value < (((uint32_t)1) << (numAdds * 5 + 6))) + break; + if (dest) + dest[destPos] = (char)(kUtf8Limits[numAdds - 1] + + (value >> (6 * numAdds))); + destPos++; + do + { + numAdds--; + if (dest) + dest[destPos] = (char)(0x80 + + ((value >> (6 * numAdds)) & 0x3F)); + destPos++; + }while (numAdds != 0); + } + *destLen = destPos; + return False; +} + +static SRes Utf16_To_Utf8Buf(CBuf *dest, + const uint16_t *src, size_t srcLen) +{ + Bool res; + size_t destLen = 0; + + Utf16_To_Utf8(NULL, &destLen, src, srcLen); + destLen += 1; + + if (!Buf_EnsureSize(dest, destLen)) + return SZ_ERROR_MEM; + + res = Utf16_To_Utf8(dest->data, &destLen, src, srcLen); + dest->data[destLen] = 0; + + return res ? SZ_OK : SZ_ERROR_FAIL; +} +#endif + +static SRes Utf16_To_Char(CBuf *buf, const uint16_t *s, int fileMode) +{ + int len = 0; + + for (len = 0; s[len] != '\0'; len++); + +#ifdef _WIN32 + { + int size = len * 3 + 100; + if (!Buf_EnsureSize(buf, size)) + return SZ_ERROR_MEM; + { + char defaultChar = '_'; + BOOL defUsed; + int numChars = WideCharToMultiByte(fileMode ? + ( +#ifdef UNDER_CE + CP_ACP +#else + AreFileApisANSI() ? CP_ACP : CP_OEMCP +#endif + ) : CP_OEMCP, + 0, (LPCWSTR)s, len, (char *)buf->data, + size, &defaultChar, &defUsed); + if (numChars == 0 || numChars >= size) + return SZ_ERROR_FAIL; + buf->data[numChars] = 0; + return SZ_OK; + } + } +#else + (void)fileMode; + return Utf16_To_Utf8Buf(buf, s, len); +#endif +} + + +static SRes ConvertUtf16toCharString(const uint16_t *s, char *outstring) +{ + CBuf buf; + SRes res; + + Buf_Init(&buf); + res = Utf16_To_Char(&buf, s, 0); + + if (res == SZ_OK) + strncpy(outstring, (const char*)buf.data, PATH_MAX_LENGTH); + + Buf_Free(&buf, &g_Alloc); + return res; +} + +/* Extract the relative path relative_path from a 7z archive + * archive_path and allocate a buf for it to write it in. + * If optional_outfile is set, extract to that instead and don't alloc buffer. + */ +static int read_7zip_file( + const char *archive_path, + const char *relative_path, void **buf, + const char *optional_outfile) +{ + CFileInStream archiveStream; + CLookToRead lookStream; + CSzArEx db; + SRes res; + ISzAlloc allocImp; + ISzAlloc allocTempImp; + uint16_t *temp = NULL; + size_t tempSize = 0; + long outsize = -1; + bool file_found = false; + + /*These are the allocation routines. + * Currently using the non-standard 7zip choices. */ + allocImp.Alloc = SzAlloc; + allocImp.Free = SzFree; + allocTempImp.Alloc = SzAllocTemp; + allocTempImp.Free = SzFreeTemp; + + if (InFile_Open(&archiveStream.file, archive_path)) + { + RARCH_ERR("Could not open %s as 7z archive\n.",archive_path); + return -1; + } + else + { + RARCH_LOG_OUTPUT("Openend archive %s. Now trying to extract %s\n", + archive_path,relative_path); + } + + FileInStream_CreateVTable(&archiveStream); + LookToRead_CreateVTable(&lookStream, False); + lookStream.realStream = &archiveStream.s; + LookToRead_Init(&lookStream); + CrcGenerateTable(); + SzArEx_Init(&db); + res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp); + + if (res == SZ_OK) + { + uint32_t i; + uint32_t blockIndex = 0xFFFFFFFF; + uint8_t *outBuffer = 0; + size_t outBufferSize = 0; + + for (i = 0; i < db.db.NumFiles; i++) + { + size_t len; + char infile[PATH_MAX_LENGTH] = {0}; + size_t offset = 0; + size_t outSizeProcessed = 0; + const CSzFileItem *f = db.db.Files + i; + + if (f->IsDir) + { + /* We skip over everything which is not a directory. + * FIXME: Why continue then if f->IsDir is true?*/ + continue; + } + + len = SzArEx_GetFileNameUtf16(&db, i, NULL); + if (len > tempSize) + { + free(temp); + tempSize = len; + temp = (uint16_t *)malloc(tempSize * sizeof(temp[0])); + if (temp == 0) + { + res = SZ_ERROR_MEM; + break; + } + } + SzArEx_GetFileNameUtf16(&db, i, temp); + res = ConvertUtf16toCharString(temp,infile); + + if (!strcmp(infile, relative_path)) + { + /* C LZMA SDK does not support chunked extraction - see here: + * sourceforge.net/p/sevenzip/discussion/45798/thread/6fb59aaf/ + * */ + file_found = true; + res = SzArEx_Extract(&db, &lookStream.s, i,&blockIndex, + &outBuffer, &outBufferSize,&offset, &outSizeProcessed, + &allocImp, &allocTempImp); + if (res != SZ_OK) + { + break; /* This goes to the error section. */ + } + outsize = outSizeProcessed; + if (optional_outfile != NULL) + { + FILE* outsink = fopen(optional_outfile,"wb"); + if (outsink == NULL) + { + RARCH_ERR("Could not open outfilepath %s.\n", + optional_outfile); + IAlloc_Free(&allocImp, outBuffer); + SzArEx_Free(&db, &allocImp); + free(temp); + File_Close(&archiveStream.file); + return -1; + } + fwrite(outBuffer+offset,1,outsize,outsink); + fclose(outsink); + } + else + { + /*We could either use the 7Zip allocated buffer, + * or create our own and use it. + * We would however need to realloc anyways, because RetroArch + * expects a \0 at the end, therefore we allocate new, + * copy and free the old one. */ + *buf = malloc(outsize + 1); + ((char*)(*buf))[outsize] = '\0'; + memcpy(*buf,outBuffer+offset,outsize); + } + IAlloc_Free(&allocImp, outBuffer); + break; + } + } + } + SzArEx_Free(&db, &allocImp); + free(temp); + + File_Close(&archiveStream.file); + + if (res == SZ_OK && file_found == true) + return outsize; + + /* Error handling */ + if (!file_found) + RARCH_ERR("File %s not found in %s\n",relative_path,archive_path); + else if (res == SZ_ERROR_UNSUPPORTED) + RARCH_ERR("7Zip decoder doesn't support this archive\n"); + else if (res == SZ_ERROR_MEM) + RARCH_ERR("7Zip decoder could not allocate memory\n"); + else if (res == SZ_ERROR_CRC) + RARCH_ERR("7Zip decoder encountered a CRC error in the archive\n"); + else + RARCH_ERR("\nUnspecified error in 7-ZIP archive, error number was: #%d\n", res); + return -1; +} + +static struct string_list *compressed_7zip_file_list_new( + const char *path, const char* ext) +{ + CFileInStream archiveStream; + CLookToRead lookStream; + CSzArEx db; + SRes res; + ISzAlloc allocImp; + ISzAlloc allocTempImp; + uint16_t *temp = NULL; + size_t tempSize = 0; + long outsize = -1; + + struct string_list *ext_list = NULL; + struct string_list *list = string_list_new(); + + if (!list) + return NULL; + + if (ext) + ext_list = string_split(ext, "|"); + + (void)outsize; + + /* These are the allocation routines - currently using + * the non-standard 7zip choices. */ + allocImp.Alloc = SzAlloc; + allocImp.Free = SzFree; + allocTempImp.Alloc = SzAllocTemp; + allocTempImp.Free = SzFreeTemp; + + if (InFile_Open(&archiveStream.file, path)) + { + RARCH_ERR("Could not open %s as 7z archive.\n",path); + goto error; + } + + FileInStream_CreateVTable(&archiveStream); + LookToRead_CreateVTable(&lookStream, False); + lookStream.realStream = &archiveStream.s; + LookToRead_Init(&lookStream); + CrcGenerateTable(); + SzArEx_Init(&db); + res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp); + + if (res == SZ_OK) + { + uint32_t i; + uint32_t blockIndex = 0xFFFFFFFF; + uint8_t *outBuffer = 0; + size_t outBufferSize = 0; + + (void)blockIndex; + (void)outBufferSize; + (void)outBuffer; + + for (i = 0; i < db.db.NumFiles; i++) + { + union string_list_elem_attr attr; + const char *file_ext = NULL; + char infile[PATH_MAX_LENGTH] = {0}; + size_t offset = 0; + size_t outSizeProcessed = 0; + size_t len = 0; + bool supported_by_core = false; + const CSzFileItem *f = db.db.Files + i; + + (void)offset; + (void)outSizeProcessed; + + /* we skip over everything, which is a directory. */ + if (f->IsDir) + continue; + + len = SzArEx_GetFileNameUtf16(&db, i, NULL); + + if (len > tempSize) + { + free(temp); + tempSize = len; + temp = (uint16_t *)malloc(tempSize * sizeof(temp[0])); + + if (temp == 0) + { + res = SZ_ERROR_MEM; + break; + } + } + SzArEx_GetFileNameUtf16(&db, i, temp); + res = ConvertUtf16toCharString(temp, infile); + file_ext = path_get_extension(infile); + + if (string_list_find_elem_prefix(ext_list, ".", file_ext)) + supported_by_core = true; + + /* + * Currently we only support files without subdirs in the archives. + * Folders are not supported (differences between win and lin. + * Archives within archives should imho never be supported. + */ + + if (!supported_by_core) + continue; + + attr.i = RARCH_COMPRESSED_FILE_IN_ARCHIVE; + + if (!string_list_append(list, infile, attr)) + goto error; + + } + } + SzArEx_Free(&db, &allocImp); + free(temp); + File_Close(&archiveStream.file); + + if (res != SZ_OK) + { + /* Error handling */ + if (res == SZ_ERROR_UNSUPPORTED) + RARCH_ERR("7Zip decoder doesn't support this archive. \n"); + else if (res == SZ_ERROR_MEM) + RARCH_ERR("7Zip decoder could not allocate memory. \n"); + else if (res == SZ_ERROR_CRC) + RARCH_ERR("7Zip decoder encountered a CRC error in the archive. \n"); + else + RARCH_ERR( + "\nUnspecified error in 7-ZIP archive, error number was: #%d. \n", + res); + goto error; + } + + string_list_free(ext_list); + return list; + +error: + RARCH_ERR("Failed to open compressed_file: \"%s\"\n", path); + SzArEx_Free(&db, &allocImp); + free(temp); + File_Close(&archiveStream.file); + string_list_free(list); + string_list_free(ext_list); + return NULL; +} #endif #ifdef HAVE_ZLIB -#include "decompress/zip_support.h" +#include "deps/zlib/unzip.h" + +#define RARCH_ZIP_SUPPORT_BUFFER_SIZE_MAX 16384 + +/* Extract the relative path relative_path from a + * zip archive archive_path and allocate a buf for it to write it in. */ +/* This code is inspired by: + * stackoverflow.com/questions/10440113/simple-way-to-unzip-a-zip-file-using-zlib + * + * optional_outfile if not NULL will be used to extract the file. buf will be 0 + * then. + */ + +static int read_zip_file(const char *archive_path, + const char *relative_path, void **buf, + const char* optional_outfile) +{ + uLong i; + unz_global_info global_info; + ssize_t bytes_read = -1; + bool finished_reading = false; + unzFile *zipfile = (unzFile*)unzOpen(archive_path); + + if (!zipfile) + return -1; + + /* Get info about the zip file */ + if (unzGetGlobalInfo(zipfile, &global_info) != UNZ_OK) + goto error; + + for ( i = 0; i < global_info.number_entry; ++i ) + { + /* Get info about current file. */ + unz_file_info file_info; + char filename[PATH_MAX_LENGTH] = {0}; + char last_char = ' '; + + if (unzGetCurrentFileInfo( + zipfile, + &file_info, + filename, + PATH_MAX_LENGTH, + NULL, 0, NULL, 0 ) != UNZ_OK ) + goto error; + + /* Check if this entry is a directory or file. */ + last_char = filename[strlen(filename)-1]; + + /* We skip directories */ + if ( last_char == '/' || last_char == '\\' ) { } + else if (!strcmp(filename, relative_path)) + { + /* We found the correct file in the zip, + * now extract it to *buf. */ + if (unzOpenCurrentFile(zipfile) != UNZ_OK ) + goto error; + + if (optional_outfile == 0) + { + /* Allocate outbuffer */ + *buf = malloc(file_info.uncompressed_size + 1 ); + bytes_read = unzReadCurrentFile(zipfile, *buf, file_info.uncompressed_size); + + if (bytes_read != (ssize_t)file_info.uncompressed_size) + { + RARCH_ERR( + "Tried to read %d bytes, but only got %d of file %s in ZIP %s.\n", + (unsigned int) file_info.uncompressed_size, (int)bytes_read, + relative_path, archive_path); + free(*buf); + goto close; + } + ((char*)(*buf))[file_info.uncompressed_size] = '\0'; + } + else + { + char read_buffer[RARCH_ZIP_SUPPORT_BUFFER_SIZE_MAX] = {0}; + FILE* outsink = fopen(optional_outfile,"wb"); + + if (outsink == NULL) + goto close; + + bytes_read = 0; + + do + { + ssize_t fwrite_bytes; + + bytes_read = unzReadCurrentFile(zipfile, read_buffer, + RARCH_ZIP_SUPPORT_BUFFER_SIZE_MAX ); + fwrite_bytes = fwrite(read_buffer, 1, bytes_read,outsink); + + if (fwrite_bytes == bytes_read) + continue; + + /* couldn't write all bytes */ + RARCH_ERR("Error writing to %s.\n",optional_outfile); + fclose(outsink); + goto close; + } while(bytes_read > 0); + + fclose(outsink); + } + finished_reading = true; + } + + unzCloseCurrentFile(zipfile); + + if (finished_reading) + break; + + if ((i + 1) < global_info.number_entry) + { + if (unzGoToNextFile(zipfile) == UNZ_OK) + continue; + + goto error; + } + } + + unzClose(zipfile); + + if(!finished_reading) + return -1; + + return bytes_read; + +close: + unzCloseCurrentFile(zipfile); +error: + unzClose(zipfile); + return -1; +} #endif -#ifdef __HAIKU__ -#include -#endif - -#if defined(_WIN32) -#ifdef _MSC_VER -#define setmode _setmode -#endif -#ifdef _XBOX -#include -#define INVALID_FILE_ATTRIBUTES -1 -#else -#include -#include -#include -#include -#endif -#else -#include -#include -#include -#include #endif /** @@ -95,8 +653,8 @@ bool write_file(const char *path, const void *data, ssize_t size) */ static int read_generic_file(const char *path, void **buf, ssize_t *len) { - long ret = 0; - ssize_t content_buf_size = 0; + size_t bytes_read = 0; + size_t content_buf_size = 0; void *content_buf = NULL; FILE *file = fopen(path, "rb"); @@ -117,7 +675,7 @@ static int read_generic_file(const char *path, void **buf, ssize_t *len) if (!content_buf) goto error; - if ((ret = fread(content_buf, 1, content_buf_size, file)) < content_buf_size) + if ((bytes_read = fread(content_buf, 1, content_buf_size, file)) < content_buf_size) RARCH_WARN("Didn't read whole file.\n"); *buf = content_buf; @@ -130,7 +688,7 @@ static int read_generic_file(const char *path, void **buf, ssize_t *len) RARCH_WARN("Failed to close file stream.\n"); if (len) - *len = ret; + *len = bytes_read; return 1; diff --git a/file_path_special.c b/file_path_special.c index bf7e732cc4..a4dcb29864 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -20,56 +20,38 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include #include #include #include #include #include -#include -#include -#include #ifdef __HAIKU__ #include #endif -#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP) -#include /* stat() is defined here */ -#endif - -#if defined(__CELLOS_LV2__) - -#ifndef S_ISDIR -#define S_ISDIR(x) (x & 0040000) -#endif - -#endif - -#if defined(_WIN32) -#ifdef _MSC_VER -#define setmode _setmode -#endif -#ifdef _XBOX -#include -#define INVALID_FILE_ATTRIBUTES -1 -#else -#include -#include +#ifdef _WIN32 #include -#include -#endif #else -#include -#include -#include -#include +#include /* stat() is defined here */ #endif #ifdef __APPLE__ #include #endif +#if defined(__CELLOS_LV2__) +#ifndef S_ISDIR +#define S_ISDIR(x) (x & 0040000) +#endif +#endif + +#include +#include +#include +#include +#include + void fill_pathname_expand_special(char *out_path, const char *in_path, size_t size) { diff --git a/frontend/drivers/platform_android.c b/frontend/drivers/platform_android.c index 822532f5cb..8f4b760429 100644 --- a/frontend/drivers/platform_android.c +++ b/frontend/drivers/platform_android.c @@ -22,13 +22,14 @@ #include #include +#include #include "platform_android.h" #include "../frontend.h" #include "../../general.h" #include "../../msg_hash.h" -#include +#include "../../runloop_data.h" #define SDCARD_ROOT_WRITABLE 1 #define SDCARD_EXT_DIR_WRITABLE 2 @@ -248,7 +249,11 @@ static void android_app_entry(void *data) #ifndef HAVE_MAIN do { - ret = rarch_main_iterate(); + unsigned sleep_ms = 0; + ret = rarch_main_iterate(&sleep_ms); + + if (ret == 1 && sleep_ms > 0) + rarch_sleep(sleep_ms); rarch_main_data_iterate(); }while (ret != -1); @@ -744,93 +749,93 @@ static void frontend_android_get_environment_settings(int *argc, RARCH_LOG("Application location: [%s].\n", app_dir); if (args && *app_dir) { - fill_pathname_join(g_defaults.assets_dir, app_dir, - "assets", sizeof(g_defaults.savestate_dir)); - fill_pathname_join(g_defaults.extraction_dir, app_dir, - "tmp", sizeof(g_defaults.extraction_dir)); - fill_pathname_join(g_defaults.shader_dir, app_dir, - "shaders", sizeof(g_defaults.shader_dir)); - fill_pathname_join(g_defaults.overlay_dir, app_dir, - "overlays", sizeof(g_defaults.overlay_dir)); - fill_pathname_join(g_defaults.core_dir, app_dir, - "cores", sizeof(g_defaults.core_dir)); - fill_pathname_join(g_defaults.core_info_dir, - app_dir, "info", sizeof(g_defaults.core_info_dir)); - fill_pathname_join(g_defaults.autoconfig_dir, - app_dir, "autoconfig", sizeof(g_defaults.autoconfig_dir)); - fill_pathname_join(g_defaults.audio_filter_dir, - app_dir, "audio_filters", sizeof(g_defaults.audio_filter_dir)); - fill_pathname_join(g_defaults.video_filter_dir, - app_dir, "video_filters", sizeof(g_defaults.video_filter_dir)); - strlcpy(g_defaults.content_history_dir, - app_dir, sizeof(g_defaults.content_history_dir)); - fill_pathname_join(g_defaults.database_dir, - app_dir, "database/rdb", sizeof(g_defaults.database_dir)); - fill_pathname_join(g_defaults.cursor_dir, - app_dir, "database/cursors", sizeof(g_defaults.cursor_dir)); - fill_pathname_join(g_defaults.cheats_dir, - app_dir, "cheats", sizeof(g_defaults.cheats_dir)); - fill_pathname_join(g_defaults.playlist_dir, - app_dir, "playlists", sizeof(g_defaults.playlist_dir)); - fill_pathname_join(g_defaults.remap_dir, - app_dir, "remaps", sizeof(g_defaults.remap_dir)); - fill_pathname_join(g_defaults.wallpapers_dir, - app_dir, "wallpapers", sizeof(g_defaults.wallpapers_dir)); + fill_pathname_join(g_defaults.dir.assets, app_dir, + "assets", sizeof(g_defaults.dir.assets)); + fill_pathname_join(g_defaults.dir.extraction, app_dir, + "tmp", sizeof(g_defaults.dir.extraction)); + fill_pathname_join(g_defaults.dir.shader, app_dir, + "shaders", sizeof(g_defaults.dir.shader)); + fill_pathname_join(g_defaults.dir.overlay, app_dir, + "overlays", sizeof(g_defaults.dir.overlay)); + fill_pathname_join(g_defaults.dir.osk_overlay, app_dir, + "overlays", sizeof(g_defaults.dir.osk_overlay)); + fill_pathname_join(g_defaults.dir.core, app_dir, + "cores", sizeof(g_defaults.dir.core)); + fill_pathname_join(g_defaults.dir.core_info, + app_dir, "info", sizeof(g_defaults.dir.core_info)); + fill_pathname_join(g_defaults.dir.autoconfig, + app_dir, "autoconfig", sizeof(g_defaults.dir.autoconfig)); + fill_pathname_join(g_defaults.dir.audio_filter, + app_dir, "audio_filters", sizeof(g_defaults.dir.audio_filter)); + fill_pathname_join(g_defaults.dir.video_filter, + app_dir, "video_filters", sizeof(g_defaults.dir.video_filter)); + strlcpy(g_defaults.dir.content_history, + app_dir, sizeof(g_defaults.dir.content_history)); + fill_pathname_join(g_defaults.dir.database, + app_dir, "database/rdb", sizeof(g_defaults.dir.database)); + fill_pathname_join(g_defaults.dir.cursor, + app_dir, "database/cursors", sizeof(g_defaults.dir.cursor)); + fill_pathname_join(g_defaults.dir.cheats, + app_dir, "cheats", sizeof(g_defaults.dir.cheats)); + fill_pathname_join(g_defaults.dir.playlist, + app_dir, "playlists", sizeof(g_defaults.dir.playlist)); + fill_pathname_join(g_defaults.dir.remap, + app_dir, "remaps", sizeof(g_defaults.dir.remap)); + fill_pathname_join(g_defaults.dir.wallpapers, + app_dir, "wallpapers", sizeof(g_defaults.dir.wallpapers)); if(*downloads_dir && test_permissions(downloads_dir)) { - fill_pathname_join(g_defaults.core_assets_dir, - downloads_dir, "", sizeof(g_defaults.core_assets_dir)); + fill_pathname_join(g_defaults.dir.core_assets, + downloads_dir, "", sizeof(g_defaults.dir.core_assets)); } else { - fill_pathname_join(g_defaults.core_assets_dir, - app_dir, "downloads", sizeof(g_defaults.core_assets_dir)); - path_mkdir(g_defaults.core_assets_dir); + fill_pathname_join(g_defaults.dir.core_assets, + app_dir, "downloads", sizeof(g_defaults.dir.core_assets)); + path_mkdir(g_defaults.dir.core_assets); } - RARCH_LOG("Default download folder: [%s]", g_defaults.core_assets_dir); + RARCH_LOG("Default download folder: [%s]", g_defaults.dir.core_assets); if(*screenshot_dir && test_permissions(screenshot_dir)) { - fill_pathname_join(g_defaults.screenshot_dir, - screenshot_dir, "", sizeof(g_defaults.screenshot_dir)); + fill_pathname_join(g_defaults.dir.screenshot, + screenshot_dir, "", sizeof(g_defaults.dir.screenshot)); } else { - fill_pathname_join(g_defaults.screenshot_dir, - app_dir, "screenshots", sizeof(g_defaults.screenshot_dir)); - path_mkdir(g_defaults.screenshot_dir); + fill_pathname_join(g_defaults.dir.screenshot, + app_dir, "screenshots", sizeof(g_defaults.dir.screenshot)); + path_mkdir(g_defaults.dir.screenshot); } - RARCH_LOG("Default screenshot folder: [%s]", g_defaults.screenshot_dir); + RARCH_LOG("Default screenshot folder: [%s]", g_defaults.dir.screenshot); switch (perms) { case SDCARD_EXT_DIR_WRITABLE: - fill_pathname_join(g_defaults.sram_dir, - ext_dir, "saves", sizeof(g_defaults.sram_dir)); - path_mkdir(g_defaults.sram_dir); + fill_pathname_join(g_defaults.dir.sram, + ext_dir, "saves", sizeof(g_defaults.dir.sram)); + path_mkdir(g_defaults.dir.sram); - fill_pathname_join(g_defaults.savestate_dir, - ext_dir, "states", sizeof(g_defaults.savestate_dir)); - path_mkdir(g_defaults.savestate_dir); + fill_pathname_join(g_defaults.dir.savestate, + ext_dir, "states", sizeof(g_defaults.dir.savestate)); + path_mkdir(g_defaults.dir.savestate); - fill_pathname_join(g_defaults.system_dir, - ext_dir, "system", sizeof(g_defaults.system_dir)); - path_mkdir(g_defaults.system_dir); + fill_pathname_join(g_defaults.dir.system, + ext_dir, "system", sizeof(g_defaults.dir.system)); + path_mkdir(g_defaults.dir.system); break; case SDCARD_NOT_WRITABLE: - fill_pathname_join(g_defaults.sram_dir, - app_dir, "saves", sizeof(g_defaults.sram_dir)); - path_mkdir(g_defaults.sram_dir); - - fill_pathname_join(g_defaults.savestate_dir, - app_dir, "states", sizeof(g_defaults.savestate_dir)); - path_mkdir(g_defaults.savestate_dir); - - fill_pathname_join(g_defaults.system_dir, - app_dir, "system", sizeof(g_defaults.system_dir)); - path_mkdir(g_defaults.system_dir); + fill_pathname_join(g_defaults.dir.sram, + app_dir, "saves", sizeof(g_defaults.dir.sram)); + path_mkdir(g_defaults.dir.sram); + fill_pathname_join(g_defaults.dir.savestate, + app_dir, "states", sizeof(g_defaults.dir.savestate)); + path_mkdir(g_defaults.dir.savestate); + fill_pathname_join(g_defaults.dir.system, + app_dir, "system", sizeof(g_defaults.dir.system)); + path_mkdir(g_defaults.dir.system); break; case SDCARD_ROOT_WRITABLE: default: @@ -864,9 +869,9 @@ static void frontend_android_get_environment_settings(int *argc, ext_dir, "system", sizeof(buf)); path_mkdir(buf); - RARCH_LOG("Default savefile folder: [%s]", g_defaults.sram_dir); - RARCH_LOG("Default savestate folder: [%s]", g_defaults.savestate_dir); - RARCH_LOG("Default system folder: [%s]", g_defaults.system_dir); + RARCH_LOG("Default savefile folder: [%s]", g_defaults.dir.sram); + RARCH_LOG("Default savestate folder: [%s]", g_defaults.dir.savestate); + RARCH_LOG("Default system folder: [%s]", g_defaults.dir.system); } } } @@ -1048,7 +1053,7 @@ static int frontend_android_parse_drive_list(void *data) return 0; } -const frontend_ctx_driver_t frontend_ctx_android = { +frontend_ctx_driver_t frontend_ctx_android = { frontend_android_get_environment_settings, frontend_android_init, frontend_android_deinit, diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 917b35c367..dc415f52bc 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -26,10 +26,12 @@ #endif #include "../../general.h" +#include "retroarch.h" #ifdef IS_SALAMANDER #include "../../file_ext.h" #else +#include "../../menu/menu.h" #include "../../menu/menu_list.h" #endif @@ -56,27 +58,27 @@ static void frontend_ctr_get_environment_settings(int *argc, char *argv[], #endif #endif - fill_pathname_basedir(g_defaults.port_dir, elf_path_cst, sizeof(g_defaults.port_dir)); - RARCH_LOG("port dir: [%s]\n", g_defaults.port_dir); + fill_pathname_basedir(g_defaults.dir.port, elf_path_cst, sizeof(g_defaults.dir.port)); + RARCH_LOG("port dir: [%s]\n", g_defaults.dir.port); - fill_pathname_join(g_defaults.core_assets_dir, g_defaults.port_dir, - "downloads", sizeof(g_defaults.core_assets_dir)); - fill_pathname_join(g_defaults.assets_dir, g_defaults.port_dir, - "media", sizeof(g_defaults.assets_dir)); - fill_pathname_join(g_defaults.core_dir, g_defaults.port_dir, - "cores", sizeof(g_defaults.core_dir)); - fill_pathname_join(g_defaults.core_info_dir, g_defaults.port_dir, - "cores", sizeof(g_defaults.core_info_dir)); - fill_pathname_join(g_defaults.savestate_dir, g_defaults.core_dir, - "savestates", sizeof(g_defaults.savestate_dir)); - fill_pathname_join(g_defaults.sram_dir, g_defaults.core_dir, - "savefiles", sizeof(g_defaults.sram_dir)); - fill_pathname_join(g_defaults.system_dir, g_defaults.core_dir, - "system", sizeof(g_defaults.system_dir)); - fill_pathname_join(g_defaults.playlist_dir, g_defaults.core_dir, - "playlists", sizeof(g_defaults.playlist_dir)); - fill_pathname_join(g_defaults.config_path, g_defaults.port_dir, - "retroarch.cfg", sizeof(g_defaults.config_path)); + fill_pathname_join(g_defaults.dir.core_assets, g_defaults.dir.port, + "downloads", sizeof(g_defaults.dir.core_assets)); + fill_pathname_join(g_defaults.dir.assets, g_defaults.dir.port, + "media", sizeof(g_defaults.dir.assets)); + fill_pathname_join(g_defaults.dir.core, g_defaults.dir.port, + "cores", sizeof(g_defaults.dir.core)); + fill_pathname_join(g_defaults.dir.core_info, g_defaults.dir.port, + "cores", sizeof(g_defaults.dir.core_info)); + fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.core, + "savestates", sizeof(g_defaults.dir.savestate)); + fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.core, + "savefiles", sizeof(g_defaults.dir.sram)); + fill_pathname_join(g_defaults.dir.system, g_defaults.dir.core, + "system", sizeof(g_defaults.dir.system)); + fill_pathname_join(g_defaults.dir.playlist, g_defaults.dir.core, + "playlists", sizeof(g_defaults.dir.playlist)); + fill_pathname_join(g_defaults.path.config, g_defaults.dir.port, + "retroarch.cfg", sizeof(g_defaults.path.config)); #ifndef IS_SALAMANDER #if 0 @@ -223,7 +225,7 @@ static int frontend_ctr_parse_drive_list(void *data) return 0; } -const frontend_ctx_driver_t frontend_ctx_ctr = { +frontend_ctx_driver_t frontend_ctx_ctr = { frontend_ctr_get_environment_settings, frontend_ctr_init, frontend_ctr_deinit, diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index 2b66e54282..45d9c90c61 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -51,6 +52,10 @@ #include "../../menu/menu.h" #endif +#if 0 +#define RELEASE_BUILD +#endif + typedef enum { CFApplicationDirectory = 1, /* Supported applications (Applications) */ @@ -332,34 +337,52 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], #ifdef OSX strlcat(home_dir_buf, "/RetroArch", sizeof(home_dir_buf)); #endif - - fill_pathname_join(g_defaults.core_dir, home_dir_buf, "modules", sizeof(g_defaults.core_dir)); - fill_pathname_join(g_defaults.core_info_dir, home_dir_buf, "info", sizeof(g_defaults.core_info_dir)); - fill_pathname_join(g_defaults.overlay_dir, home_dir_buf, "overlays", sizeof(g_defaults.overlay_dir)); - fill_pathname_join(g_defaults.autoconfig_dir, home_dir_buf, "autoconfig/hid", sizeof(g_defaults.autoconfig_dir)); - fill_pathname_join(g_defaults.core_assets_dir, home_dir_buf, "downloads", sizeof(g_defaults.core_assets_dir)); - fill_pathname_join(g_defaults.assets_dir, home_dir_buf, "assets", sizeof(g_defaults.assets_dir)); - fill_pathname_join(g_defaults.system_dir, home_dir_buf, "system", sizeof(g_defaults.system_dir)); - fill_pathname_join(g_defaults.menu_config_dir, home_dir_buf, "configs", sizeof(g_defaults.menu_config_dir)); - fill_pathname_join(g_defaults.config_path, g_defaults.menu_config_dir, "retroarch.cfg", sizeof(g_defaults.config_path)); - fill_pathname_join(g_defaults.database_dir, home_dir_buf, "rdb", sizeof(g_defaults.database_dir)); - fill_pathname_join(g_defaults.cursor_dir, home_dir_buf, "cursors", sizeof(g_defaults.cursor_dir)); - fill_pathname_join(g_defaults.cheats_dir, home_dir_buf, "cht", sizeof(g_defaults.cheats_dir)); - fill_pathname_join(g_defaults.sram_dir, home_dir_buf, "saves", sizeof(g_defaults.sram_dir)); - fill_pathname_join(g_defaults.savestate_dir, home_dir_buf, "states", sizeof(g_defaults.savestate_dir)); - - CFTemporaryDirectory(temp_dir, sizeof(temp_dir)); - strlcpy(g_defaults.extraction_dir, temp_dir, sizeof(g_defaults.extraction_dir)); - - fill_pathname_join(g_defaults.shader_dir, home_dir_buf, "shaders_glsl", sizeof(g_defaults.shader_dir)); - + fill_pathname_join(g_defaults.dir.shader, home_dir_buf, "shaders_glsl", sizeof(g_defaults.dir.shader)); + fill_pathname_join(g_defaults.dir.core, home_dir_buf, "cores", sizeof(g_defaults.dir.core)); + fill_pathname_join(g_defaults.dir.core_info, home_dir_buf, "info", sizeof(g_defaults.dir.core_info)); + fill_pathname_join(g_defaults.dir.overlay, home_dir_buf, "overlays", sizeof(g_defaults.dir.overlay)); + fill_pathname_join(g_defaults.dir.autoconfig, home_dir_buf, "autoconfig", sizeof(g_defaults.dir.autoconfig)); + fill_pathname_join(g_defaults.dir.core_assets, home_dir_buf, "downloads", sizeof(g_defaults.dir.core_assets)); + fill_pathname_join(g_defaults.dir.assets, home_dir_buf, "assets", sizeof(g_defaults.dir.assets)); + fill_pathname_join(g_defaults.dir.system, home_dir_buf, "system", sizeof(g_defaults.dir.system)); + fill_pathname_join(g_defaults.dir.menu_config, home_dir_buf, "configs", sizeof(g_defaults.dir.menu_config)); + fill_pathname_join(g_defaults.path.config, g_defaults.dir.menu_config, "retroarch.cfg", sizeof(g_defaults.path.config)); + fill_pathname_join(g_defaults.dir.database, home_dir_buf, "rdb", sizeof(g_defaults.dir.database)); + fill_pathname_join(g_defaults.dir.cursor, home_dir_buf, "cursors", sizeof(g_defaults.dir.cursor)); + fill_pathname_join(g_defaults.dir.cheats, home_dir_buf, "cht", sizeof(g_defaults.dir.cheats)); + fill_pathname_join(g_defaults.dir.sram, home_dir_buf, "saves", sizeof(g_defaults.dir.sram)); + fill_pathname_join(g_defaults.dir.savestate, home_dir_buf, "states", sizeof(g_defaults.dir.savestate)); + fill_pathname_join(g_defaults.dir.remap, home_dir_buf, "remaps", sizeof(g_defaults.dir.remap)); #if defined(OSX) #ifdef HAVE_CG - fill_pathname_join(g_defaults.shader_dir, home_dir_buf, "shaders_cg", sizeof(g_defaults.shader_dir)); + fill_pathname_join(g_defaults.dir.shader, home_dir_buf, "shaders_cg", sizeof(g_defaults.dir.shader)); #endif - fill_pathname_join(g_defaults.audio_filter_dir, home_dir_buf, "audio_filters", sizeof(g_defaults.audio_filter_dir)); - fill_pathname_join(g_defaults.video_filter_dir, home_dir_buf, "video_filters", sizeof(g_defaults.video_filter_dir)); + fill_pathname_join(g_defaults.dir.audio_filter, home_dir_buf, "audio_filters", sizeof(g_defaults.dir.audio_filter)); + fill_pathname_join(g_defaults.dir.video_filter, home_dir_buf, "video_filters", sizeof(g_defaults.dir.video_filter)); + fill_pathname_join(g_defaults.dir.playlist, home_dir_buf, "playlists", sizeof(g_defaults.dir.playlist)); #endif +#ifdef RELEASE_BUILD + fill_pathname_join(g_defaults.dir.remap, bundle_path_buf, "Contents/Resources/remaps", sizeof(g_defaults.dir.remap)); + fill_pathname_join(g_defaults.dir.playlist, bundle_path_buf, "Contents/Resources/playlists", sizeof(g_defaults.dir.playlist)); + fill_pathname_join(g_defaults.dir.shader, bundle_path_buf, "Contents/Resources/shaders", sizeof(g_defaults.dir.shader)); + fill_pathname_join(g_defaults.dir.core, bundle_path_buf, "Contents/Resources/cores", sizeof(g_defaults.dir.core)); + fill_pathname_join(g_defaults.dir.core_info, bundle_path_buf, "Contents/Resources/info", sizeof(g_defaults.dir.core_info)); + fill_pathname_join(g_defaults.dir.overlay, bundle_path_buf, "Contents/Resources/overlays", sizeof(g_defaults.dir.overlay)); + fill_pathname_join(g_defaults.dir.autoconfig, bundle_path_buf, "Contents/Resources/autoconfig", sizeof(g_defaults.dir.autoconfig)); + fill_pathname_join(g_defaults.dir.core_assets, bundle_path_buf, "Contents/Resources/downloads", sizeof(g_defaults.dir.core_assets)); + fill_pathname_join(g_defaults.dir.assets, bundle_path_buf, "Contents/Resources/assets", sizeof(g_defaults.dir.assets)); + fill_pathname_join(g_defaults.dir.system, bundle_path_buf, "Contents/Resources/system", sizeof(g_defaults.dir.system)); + fill_pathname_join(g_defaults.dir.menu_config, bundle_path_buf, "Contents/Resources/configs", sizeof(g_defaults.dir.menu_config)); + fill_pathname_join(g_defaults.path.config, g_defaults.dir.menu_config, "retroarch.cfg", sizeof(g_defaults.path.config)); + fill_pathname_join(g_defaults.dir.database, bundle_path_buf, "Contents/Resources/rdb", sizeof(g_defaults.dir.database)); + fill_pathname_join(g_defaults.dir.cursor, bundle_path_buf, "Contents/Resources/cursors", sizeof(g_defaults.dir.cursor)); + fill_pathname_join(g_defaults.dir.cheats, bundle_path_buf, "Contents/Resources/cht", sizeof(g_defaults.dir.cheats)); + fill_pathname_join(g_defaults.dir.sram, bundle_path_buf, "Contents/Resources/saves", sizeof(g_defaults.dir.sram)); + fill_pathname_join(g_defaults.dir.savestate, bundle_path_buf, "Contents/Resources/states", sizeof(g_defaults.dir.savestate)); +#endif + + CFTemporaryDirectory(temp_dir, sizeof(temp_dir)); + strlcpy(g_defaults.dir.extraction, temp_dir, sizeof(g_defaults.dir.extraction)); path_mkdir(bundle_path_buf); @@ -367,10 +390,10 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], RARCH_ERR("Failed to create or access base directory: %s\n", bundle_path_buf); else { - path_mkdir(g_defaults.system_dir); + path_mkdir(g_defaults.dir.system); - if (access(g_defaults.system_dir, 0755) != 0) - RARCH_ERR("Failed to create or access system directory: %s.\n", g_defaults.system_dir); + if (access(g_defaults.dir.system, 0755) != 0) + RARCH_ERR("Failed to create or access system directory: %s.\n", g_defaults.dir.system); } CFRelease(bundle_path); @@ -569,24 +592,36 @@ static int frontend_darwin_parse_drive_list(void *data) #if TARGET_OS_IPHONE #ifdef HAVE_MENU file_list_t *list = (file_list_t*)data; + CFURLRef bundle_url; + CFStringRef bundle_path; + char bundle_path_buf[PATH_MAX_LENGTH] = {0}; + char home_dir_buf[PATH_MAX_LENGTH] = {0}; + CFBundleRef bundle = CFBundleGetMainBundle(); + + bundle_url = CFBundleCopyBundleURL(bundle); + bundle_path = CFURLCopyPath(bundle_url); + + CFStringGetCString(bundle_path, bundle_path_buf, sizeof(bundle_path_buf), kCFStringEncodingUTF8); + (void)home_dir_buf; + + CFSearchPathForDirectoriesInDomains(CFDocumentDirectory, CFUserDomainMask, 1, home_dir_buf, sizeof(home_dir_buf)); menu_list_push(list, - "/var/mobile/Documents/", "", MENU_FILE_DIRECTORY, 0, 0); - menu_list_push(list, - "/var/mobile/", "", MENU_FILE_DIRECTORY, 0, 0); - menu_list_push(list, - g_defaults.core_dir, "", MENU_FILE_DIRECTORY, 0, 0); + home_dir_buf, "", MENU_FILE_DIRECTORY, 0, 0); menu_list_push(list, "/", "", MENU_FILE_DIRECTORY, 0, 0); ret = 0; + + CFRelease(bundle_path); + CFRelease(bundle_url); #endif #endif return ret; } -const frontend_ctx_driver_t frontend_ctx_darwin = { +frontend_ctx_driver_t frontend_ctx_darwin = { frontend_darwin_get_environment_settings, NULL, /* init */ NULL, /* deinit */ diff --git a/frontend/drivers/platform_emscripten.c b/frontend/drivers/platform_emscripten.c index 702c96c149..764f2ba715 100644 --- a/frontend/drivers/platform_emscripten.c +++ b/frontend/drivers/platform_emscripten.c @@ -20,12 +20,17 @@ #include #include "../../content.h" #include "../frontend.h" +#include "../../retroarch.h" +#include "../../runloop.h" +#include "../../runloop_data.h" #include "../frontend_driver.h" -#include "../runloop_data.h" static void emscripten_mainloop(void) { - int ret = rarch_main_iterate(); + unsigned sleep_ms = 0; + int ret = rarch_main_iterate(&sleep_ms); + if (ret == 1 && sleep_ms > 0) + rarch_sleep(sleep_ms); rarch_main_data_iterate(); if (ret != -1) return; @@ -34,6 +39,27 @@ static void emscripten_mainloop(void) exit(0); } +void cmd_savefiles(void) +{ + event_command(EVENT_CMD_SAVEFILES); +} + +void cmd_save_state(void) +{ + event_command(EVENT_CMD_SAVE_STATE); +} + +void cmd_load_state(void) +{ + event_command(EVENT_CMD_LOAD_STATE); +} + +void cmd_take_screenshot(void) +{ + event_command(EVENT_CMD_TAKE_SCREENSHOT); +} + + int main(int argc, char *argv[]) { settings_t *settings = config_get_ptr(); diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index d4b010639e..77abac8269 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2015 - 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. @@ -20,12 +20,6 @@ #include #include #include -#include -#ifndef _DIRENT_HAVE_D_TYPE -#include -#endif -#include -#include #if defined(HW_RVL) && !defined(IS_SALAMANDER) #include @@ -43,7 +37,7 @@ #include "../../driver.h" #include "../../general.h" #include "../../libretro_private.h" -#include "../../gfx/drivers/gx_sdk_defines.h" +#include "../../defines/gx_defines.h" #ifdef HW_RVL #include @@ -53,6 +47,7 @@ extern void system_exec_wii(const char *path, bool should_load_game); #endif #include #include +#include #ifdef USBGECKO #include @@ -108,24 +103,27 @@ static struct { static slock_t *gx_device_mutex; static slock_t *gx_device_cond_mutex; static scond_t *gx_device_cond; +static sthread_t *gx_device_thread; +static volatile bool gx_stop_dev_thread; -static void *gx_devthread(void *a) +static void gx_devthread(void *a) { - while (1) + while (!gx_stop_dev_thread) { unsigned i; slock_lock(gx_device_mutex); - for (i = 0; i < GX_DEVICE_END; i++) - { - if (gx_devices[i].mounted && - !gx_devices[i].interface->isInserted()) - { - gx_devices[i].mounted = false; - char n[8]; - snprintf(n, sizeof(n), "%s:", gx_devices[i].name); - fatUnmount(n); + for (i = 0; i < GX_DEVICE_END; i++) { + if (gx_devices[i].mounted) { + if (!gx_devices[i].interface->isInserted()) { + gx_devices[i].mounted = false; + char n[8]; + snprintf(n, sizeof(n), "%s:", gx_devices[i].name); + fatUnmount(n); + } + } else if (gx_devices[i].interface->startup() && gx_devices[i].interface->isInserted()) { + gx_devices[i].mounted = fatMountSimple(gx_devices[i].name, gx_devices[i].interface); } } @@ -135,17 +133,6 @@ static void *gx_devthread(void *a) scond_wait_timeout(gx_device_cond, gx_device_cond_mutex, 1000000); slock_unlock(gx_device_cond_mutex); } - - return NULL; -} - -static int gx_get_device_from_path(const char *path) -{ - if (strstr(path, "sd:") == path) - return GX_DEVICE_SD; - if (strstr(path, "usb:") == path) - return GX_DEVICE_USB; - return -1; } #endif @@ -153,7 +140,7 @@ static int gx_get_device_from_path(const char *path) int gx_logger_net(struct _reent *r, int fd, const char *ptr, size_t len) { static char temp[4000]; - size_t l = len >= 4000 ? 3999 : len; + size_t l = len >= 4000 ? 3999 : len - 1; memcpy(temp, ptr, l); temp[l] = 0; logger_send("%s", temp); @@ -190,30 +177,30 @@ static void frontend_gx_get_environment_settings(int *argc, char *argv[], #ifdef HW_DOL chdir("carda:/retroarch"); #endif - getcwd(g_defaults.core_dir, MAXPATHLEN); - char *last_slash = strrchr(g_defaults.core_dir, '/'); + getcwd(g_defaults.dir.core, MAXPATHLEN); + char *last_slash = strrchr(g_defaults.dir.core, '/'); if (last_slash) *last_slash = 0; - char *device_end = strchr(g_defaults.core_dir, '/'); + char *device_end = strchr(g_defaults.dir.core, '/'); if (device_end) - snprintf(g_defaults.port_dir, sizeof(g_defaults.port_dir), - "%.*s/retroarch", device_end - g_defaults.core_dir, - g_defaults.core_dir); + snprintf(g_defaults.dir.port, sizeof(g_defaults.dir.port), + "%.*s/retroarch", device_end - g_defaults.dir.core, + g_defaults.dir.core); else - fill_pathname_join(g_defaults.port_dir, g_defaults.port_dir, - "retroarch", sizeof(g_defaults.port_dir)); - fill_pathname_join(g_defaults.overlay_dir, g_defaults.core_dir, - "overlays", sizeof(g_defaults.overlay_dir)); - fill_pathname_join(g_defaults.config_path, g_defaults.port_dir, - "retroarch.cfg", sizeof(g_defaults.config_path)); - fill_pathname_join(g_defaults.system_dir, g_defaults.port_dir, - "system", sizeof(g_defaults.system_dir)); - fill_pathname_join(g_defaults.sram_dir, g_defaults.port_dir, - "savefiles", sizeof(g_defaults.sram_dir)); - fill_pathname_join(g_defaults.savestate_dir, g_defaults.port_dir, - "savefiles", sizeof(g_defaults.savestate_dir)); - fill_pathname_join(g_defaults.playlist_dir, g_defaults.port_dir, - "playlists", sizeof(g_defaults.playlist_dir)); + fill_pathname_join(g_defaults.dir.port, g_defaults.dir.port, + "retroarch", sizeof(g_defaults.dir.port)); + fill_pathname_join(g_defaults.dir.overlay, g_defaults.dir.core, + "overlays", sizeof(g_defaults.dir.overlay)); + fill_pathname_join(g_defaults.path.config, g_defaults.dir.port, + "retroarch.cfg", sizeof(g_defaults.path.config)); + fill_pathname_join(g_defaults.dir.system, g_defaults.dir.port, + "system", sizeof(g_defaults.dir.system)); + fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.port, + "savefiles", sizeof(g_defaults.dir.sram)); + fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.port, + "savefiles", sizeof(g_defaults.dir.savestate)); + fill_pathname_join(g_defaults.dir.playlist, g_defaults.dir.port, + "playlists", sizeof(g_defaults.dir.playlist)); #ifdef IS_SALAMANDER if (*argc > 2 && argv[1] != NULL && argv[2] != NULL) @@ -222,7 +209,7 @@ static void frontend_gx_get_environment_settings(int *argc, char *argv[], gx_rom_path[0] = '\0'; #else #ifdef HW_RVL - /* needed on Wii; loaders follow a dumb standard where the path and + /* needed on Wii; loaders follow a dumb standard where the path and * filename are separate in the argument list */ if (*argc > 2 && argv[1] != NULL && argv[2] != NULL) { @@ -297,7 +284,6 @@ static void frontend_gx_init(void *data) #endif #if defined(HW_RVL) && !defined(IS_SALAMANDER) - OSThread gx_device_thread; gx_devices[GX_DEVICE_SD].interface = &__io_wiisd; gx_devices[GX_DEVICE_SD].name = "sd"; gx_devices[GX_DEVICE_SD].mounted = fatMountSimple( @@ -312,7 +298,20 @@ static void frontend_gx_init(void *data) gx_device_cond_mutex = slock_new(); gx_device_cond = scond_new(); gx_device_mutex = slock_new(); - OSCreateThread(&gx_device_thread, gx_devthread, 0, NULL, NULL, 0, 66, 0); + gx_device_thread = sthread_create(gx_devthread, NULL); +#endif +} + +static void frontend_gx_deinit(void *data) +{ + (void)data; + +#if defined(HW_RVL) && !defined(IS_SALAMANDER) + slock_lock(gx_device_cond_mutex); + gx_stop_dev_thread = true; + slock_unlock(gx_device_cond_mutex); + scond_signal(gx_device_cond); + sthread_join(gx_device_thread); #endif } @@ -335,7 +334,7 @@ static void frontend_gx_exitspawn(char *s, size_t len) /* FIXME/TODO - hack * direct loading failed (out of memory), try to jump to Salamander, * then load the correct core */ - fill_pathname_join(s, g_defaults.core_dir, + fill_pathname_join(s, g_defaults.dir.core, "boot.dol", len); #endif frontend_gx_exec(s, should_load_game); @@ -346,7 +345,7 @@ static void frontend_gx_process_args(int *argc, char *argv[]) #ifndef IS_SALAMANDER settings_t *settings = config_get_ptr(); - /* A big hack: sometimes Salamander doesn't save the new core + /* A big hack: sometimes Salamander doesn't save the new core * it loads on first boot, so we make sure * settings->libretro is set here. */ if (!settings->libretro[0] && *argc >= 1 && strrchr(argv[0], '/')) @@ -404,10 +403,10 @@ static int frontend_gx_parse_drive_list(void *data) return 0; } -const frontend_ctx_driver_t frontend_ctx_gx = { +frontend_ctx_driver_t frontend_ctx_gx = { frontend_gx_get_environment_settings, frontend_gx_init, - NULL, /* deinit */ + frontend_gx_deinit, frontend_gx_exitspawn, frontend_gx_process_args, frontend_gx_exec, diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index fb23e6cb16..6f8188c332 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include @@ -31,26 +31,16 @@ #include "../frontend_driver.h" -static const char *proc_apm_path = "/proc/apm"; -static const char *proc_acpi_battery_path = "/proc/acpi/battery"; +static const char *proc_apm_path = "/proc/apm"; +static const char *proc_acpi_battery_path = "/proc/acpi/battery"; +static const char *proc_acpi_sys_ac_adapter_path= "/sys/class/power_supply/ACAD"; +static const char *proc_acpi_sys_battery_path= "/sys/class/power_supply"; static const char *proc_acpi_ac_adapter_path = "/proc/acpi/ac_adapter"; -static int open_acpi_file(const char *base, const char *node, const char *key) -{ - const size_t pathlen = strlen(base) + strlen(node) + strlen(key) + 3; - char *path = (char *)alloca(pathlen); - if (!path) - return -1; - - snprintf(path, pathlen, "%s/%s/%s", base, node, key); - return open(path, O_RDONLY); -} - -static bool load_acpi_file(const char *base, const char *node, const char *key, - char *buf, size_t buflen) +static bool load_power_file(const char *path, char *buf, size_t buflen) { ssize_t br = 0; - const int fd = open_acpi_file(base, node, key); + const int fd = open(path, O_RDONLY); if (fd == -1) return false; br = read(fd, buf, buflen-1); @@ -116,6 +106,7 @@ check_proc_acpi_battery(const char * node, bool * have_battery, bool * charging, int *seconds, int *percent) { const char *base = proc_acpi_battery_path; + char path[1024]; char info[1024] = {0}; char state[1024] = {0}; char *ptr = NULL; @@ -128,9 +119,13 @@ check_proc_acpi_battery(const char * node, bool * have_battery, int secs = -1; int pct = -1; - if (!load_acpi_file(base, node, "state", state, sizeof (state))) + snprintf(path, sizeof(path), "%s/%s/%s", base, node, "state"); + + if (!load_power_file(path, state, sizeof (state))) return; - else if (!load_acpi_file(base, node, "info", info, sizeof (info))) + + snprintf(path, sizeof(path), "%s/%s/%s", base, node, "info"); + if (!load_power_file(path, info, sizeof (info))) return; ptr = &state[0]; @@ -158,7 +153,7 @@ check_proc_acpi_battery(const char * node, bool * have_battery, case ACPI_KEY_REMAINING_CAPACITY: { char *endptr = NULL; - const int cvt = (int) strtol(val, &endptr, 10); + const int cvt = (int)strtol(val, &endptr, 10); if (*endptr == ' ') remaining = cvt; @@ -178,7 +173,7 @@ check_proc_acpi_battery(const char * node, bool * have_battery, case ACPI_KEY_DESIGN_CAPACITY: { char *endptr = NULL; - const int cvt = (int) strtol(val, &endptr, 10); + const int cvt = (int)strtol(val, &endptr, 10); if (*endptr == ' ') maximum = cvt; @@ -192,7 +187,7 @@ check_proc_acpi_battery(const char * node, bool * have_battery, pct = (int) ((((float) remaining) / ((float) maximum)) * 100.0f); if (pct < 0) pct = 0; - else if (pct > 100) + if (pct > 100) pct = 100; } @@ -220,29 +215,83 @@ check_proc_acpi_battery(const char * node, bool * have_battery, } } +static void +check_proc_acpi_sys_battery(const char * node, bool * have_battery, + bool * charging, int *seconds, int *percent) +{ + unsigned capacity; + char path[1024], info[1024], state[1024]; + const char *base = proc_acpi_sys_battery_path; + char *ptr = NULL; + char *key = NULL; + char *val = NULL; + bool charge = false; + bool choose = false; + int maximum = -1; + int remaining = -1; + int secs = -1; + int pct = -1; + + if (!strstr(node, "BAT")) + return; + + snprintf(path, sizeof(path), "%s/%s/%s", base, node, "status"); + if (!load_power_file(path, state, sizeof (state))) + return; + + if (strstr(state, "Discharging")) + *have_battery = true; + else if (strstr(state, "Full")) + *have_battery = true; + + snprintf(path, sizeof(path), "%s/%s/%s", base, node, "capacity"); + if (!load_power_file(path, state, sizeof (state))) + return; + + capacity = atoi(state); + + *percent = capacity; +} + static void check_proc_acpi_ac_adapter(const char * node, bool *have_ac) { - const char *base = proc_acpi_ac_adapter_path; - char state[256] = {0}; - char *ptr = NULL; - char *key = NULL; - char *val = NULL; + char path[1024]; + const char *base = proc_acpi_ac_adapter_path; + char state[256] = {0}; + char *ptr = NULL; + char *key = NULL; + char *val = NULL; - if (!load_acpi_file(base, node, "state", state, sizeof (state))) - return; + snprintf(path, sizeof(path), "%s/%s/%s", base, node, "state"); + if (!load_power_file(path, state, sizeof (state))) + return; - ptr = &state[0]; - while (make_proc_acpi_key_val(&ptr, &key, &val)) - { - uint32_t key_hash = djb2_calculate(key); - uint32_t val_hash = djb2_calculate(val); + ptr = &state[0]; + while (make_proc_acpi_key_val(&ptr, &key, &val)) + { + uint32_t key_hash = djb2_calculate(key); + uint32_t val_hash = djb2_calculate(val); - if (key_hash == ACPI_KEY_STATE && - val_hash == ACPI_VAL_ONLINE) - *have_ac = true; - } + if (key_hash == ACPI_KEY_STATE && + val_hash == ACPI_VAL_ONLINE) + *have_ac = true; + } +} + +static void +check_proc_acpi_sys_ac_adapter(const char * node, bool *have_ac) +{ + char state[256], path[1024]; + const char *base = proc_acpi_sys_ac_adapter_path; + + snprintf(path, sizeof(path), "%s/%s/%s", base, node, "online"); + if (!load_power_file(path, state, sizeof (state))) + return; + + if (strstr(state, "1")) + *have_ac = true; } static bool next_string(char **_ptr, char **_str) @@ -275,30 +324,23 @@ static bool int_string(char *str, int *val) return ((*str != '\0') && (*endptr == '\0')); } -bool frontend_linux_powerstate_check_apm(enum frontend_powerstate *state, +static bool frontend_linux_powerstate_check_apm( + enum frontend_powerstate *state, int *seconds, int *percent) { - ssize_t br; + char buf[128], *ptr; int ac_status = 0; int battery_status = 0; int battery_flag = 0; int battery_percent = 0; int battery_time = 0; - const int fd = open(proc_apm_path, O_RDONLY); - char buf[128] = {0}; - char *ptr = &buf[0]; char *str = NULL; - - if (fd == -1) - return false; /* can't use this interface. */ - - br = read(fd, buf, sizeof (buf) - 1); - close(fd); - - if (br < 0) + + if (!load_power_file(proc_apm_path, buf, sizeof(buf))) return false; - buf[br] = '\0'; /* null-terminate the string. */ + ptr = &buf[0]; + if (!next_string(&ptr, &str)) /* driver version */ return false; if (!next_string(&ptr, &str)) /* BIOS version */ @@ -356,40 +398,37 @@ bool frontend_linux_powerstate_check_apm(enum frontend_powerstate *state, return true; } -bool frontend_linux_powerstate_check_acpi(enum frontend_powerstate *state, +static bool frontend_linux_powerstate_check_acpi( + enum frontend_powerstate *state, int *seconds, int *percent) { - struct dirent *dent = NULL; - DIR *dirp = NULL; + bool ret = false; + struct RDIR *entry = NULL; bool have_battery = false; bool have_ac = false; bool charging = false; *state = FRONTEND_POWERSTATE_NONE; - dirp = opendir(proc_acpi_battery_path); - if (dirp == NULL) - return false; /* can't use this interface. */ + entry = retro_opendir(proc_acpi_battery_path); + if (!entry) + goto end; - while ((dent = readdir(dirp)) != NULL) - { - const char *node = dent->d_name; - check_proc_acpi_battery(node, &have_battery, &charging, - seconds, percent); - } - closedir(dirp); + if (retro_dirent_error(entry)) + goto end; - dirp = opendir(proc_acpi_ac_adapter_path); - if (dirp == NULL) - return false; /* can't use this interface. */ + while (retro_readdir(entry)) + check_proc_acpi_battery(retro_dirent_get_name(entry), + &have_battery, &charging, seconds, percent); - while ((dent = readdir(dirp)) != NULL) - { - const char *node = dent->d_name; + retro_closedir(entry); - check_proc_acpi_ac_adapter(node, &have_ac); - } - closedir(dirp); + entry = retro_opendir(proc_acpi_ac_adapter_path); + if (!entry) + goto end; + + while (retro_readdir(entry)) + check_proc_acpi_ac_adapter(retro_dirent_get_name(entry), &have_ac); if (!have_battery) *state = FRONTEND_POWERSTATE_NO_SOURCE; @@ -400,7 +439,65 @@ bool frontend_linux_powerstate_check_acpi(enum frontend_powerstate *state, else *state = FRONTEND_POWERSTATE_ON_POWER_SOURCE; - return true; /* definitive answer. */ + ret = true; + +end: + if (entry) + retro_closedir(entry); + + return ret; +} + +static bool frontend_linux_powerstate_check_acpi_sys( + enum frontend_powerstate *state, + int *seconds, int *percent) +{ + bool ret = false; + struct RDIR *entry = NULL; + bool have_battery = false; + bool have_ac = false; + bool charging = false; + + *state = FRONTEND_POWERSTATE_NONE; + + entry = retro_opendir(proc_acpi_sys_battery_path); + if (!entry) + goto error; + + if (retro_dirent_error(entry)) + goto error; + + while (retro_readdir(entry)) + check_proc_acpi_sys_battery(retro_dirent_get_name(entry), + &have_battery, &charging, seconds, percent); + + retro_closedir(entry); + + entry = retro_opendir(proc_acpi_sys_ac_adapter_path); + if (!entry) + goto error; + + while (retro_readdir(entry)) + check_proc_acpi_sys_ac_adapter(retro_dirent_get_name(entry), &have_ac); + + if (!have_battery) + { + *state = FRONTEND_POWERSTATE_NO_SOURCE; + } + else if (charging) + *state = FRONTEND_POWERSTATE_CHARGING; + else if (have_ac) + *state = FRONTEND_POWERSTATE_CHARGED; + else + *state = FRONTEND_POWERSTATE_ON_POWER_SOURCE; + + return true; + +error: + if (entry) + retro_closedir(entry); + + return false; } static enum frontend_powerstate @@ -414,6 +511,9 @@ frontend_linux_get_powerstate(int *seconds, int *percent) if (frontend_linux_powerstate_check_acpi(&ret, seconds, percent)) return ret; + if (frontend_linux_powerstate_check_acpi_sys(&ret, seconds, percent)) + return ret; + return FRONTEND_POWERSTATE_NONE; } @@ -424,7 +524,7 @@ frontend_linux_get_powerstate(int *seconds, int *percent) #define LINUX_ARCH_MIPS 0x7c9aa25eU #define LINUX_ARCH_TILE 0x7c9e7873U -enum frontend_architecture frontend_linux_get_architecture(void) +static enum frontend_architecture frontend_linux_get_architecture(void) { uint32_t buffer_hash; struct utsname buffer; @@ -465,7 +565,7 @@ static void frontend_linux_get_os(char *s, size_t len, int *major, int *minor) strlcpy(s, "Linux", len); } -const frontend_ctx_driver_t frontend_ctx_linux = { +frontend_ctx_driver_t frontend_ctx_linux = { NULL, /* environment_get */ NULL, /* init */ NULL, /* deinit */ diff --git a/frontend/drivers/platform_null.c b/frontend/drivers/platform_null.c index 8eefa693fa..df7f5f5626 100644 --- a/frontend/drivers/platform_null.c +++ b/frontend/drivers/platform_null.c @@ -17,11 +17,9 @@ #include "../frontend_driver.h" #include -#include -#include #include -const frontend_ctx_driver_t frontend_ctx_null = { +frontend_ctx_driver_t frontend_ctx_null = { NULL, /* environment_get */ NULL, /* init */ NULL, /* deinit */ diff --git a/frontend/drivers/platform_ps3.c b/frontend/drivers/platform_ps3.c index f7d7dc472d..3f933cf328 100644 --- a/frontend/drivers/platform_ps3.c +++ b/frontend/drivers/platform_ps3.c @@ -33,7 +33,7 @@ #include #endif -#include "../../ps3/sdk_defines.h" +#include "../../defines/ps3_defines.h" #include "../../general.h" #define EMULATOR_CONTENT_DIR "SSNE10000" @@ -54,9 +54,15 @@ SYS_PROCESS_PARAM(1001, 0x200000) static bool multiman_detected = false; #endif +#ifndef IS_SALAMANDER static bool exit_spawn = false; static bool exitspawn_start_game = false; +static void frontend_ps3_shutdown(bool unused) +{ + sys_process_exit(0); +} +#endif #ifdef HAVE_SYSUTILS static void callback_sysutil_exit(uint64_t status, @@ -73,10 +79,13 @@ static void callback_sysutil_exit(uint64_t status, { case CELL_SYSUTIL_REQUEST_EXITGAME: { + frontend_ctx_driver_t *frontend = frontend_get_ptr(); rarch_system_info_t *system = rarch_system_info_get_ptr(); if (system) system->shutdown = true; + if (frontend) + frontend->shutdown = frontend_ps3_shutdown; } break; } @@ -179,15 +188,15 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[], == CELL_GAME_ATTRIBUTE_APP_HOME) RARCH_LOG("RetroArch was launched from host machine (APP_HOME).\n"); - ret = cellGameContentPermit(contentInfoPath, g_defaults.port_dir); + ret = cellGameContentPermit(contentInfoPath, g_defaults.dir.port); #ifdef HAVE_MULTIMAN if (multiman_detected) { fill_pathname_join(contentInfoPath, "/dev_hdd0/game/", EMULATOR_CONTENT_DIR, sizeof(contentInfoPath)); - fill_pathname_join(g_defaults.port_dir, contentInfoPath, - "USRDIR", sizeof(g_defaults.port_dir)); + fill_pathname_join(g_defaults.dir.port, contentInfoPath, + "USRDIR", sizeof(g_defaults.dir.port)); } #endif @@ -197,29 +206,29 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[], { RARCH_LOG("cellGameContentPermit() OK.\n"); RARCH_LOG("contentInfoPath : [%s].\n", contentInfoPath); - RARCH_LOG("usrDirPath : [%s].\n", g_defaults.port_dir); + RARCH_LOG("usrDirPath : [%s].\n", g_defaults.dir.port); } - fill_pathname_join(g_defaults.core_dir, g_defaults.port_dir, - "cores", sizeof(g_defaults.core_dir)); - fill_pathname_join(g_defaults.core_info_dir, g_defaults.port_dir, - "cores", sizeof(g_defaults.core_info_dir)); - fill_pathname_join(g_defaults.savestate_dir, g_defaults.core_dir, - "savestates", sizeof(g_defaults.savestate_dir)); - fill_pathname_join(g_defaults.sram_dir, g_defaults.core_dir, - "savefiles", sizeof(g_defaults.sram_dir)); - fill_pathname_join(g_defaults.system_dir, g_defaults.core_dir, - "system", sizeof(g_defaults.system_dir)); - fill_pathname_join(g_defaults.shader_dir, g_defaults.core_dir, - "shaders_cg", sizeof(g_defaults.shader_dir)); - fill_pathname_join(g_defaults.config_path, g_defaults.port_dir, - "retroarch.cfg", sizeof(g_defaults.config_path)); - fill_pathname_join(g_defaults.overlay_dir, g_defaults.core_dir, - "overlays", sizeof(g_defaults.overlay_dir)); - fill_pathname_join(g_defaults.assets_dir, g_defaults.core_dir, - "media", sizeof(g_defaults.assets_dir)); - fill_pathname_join(g_defaults.playlist_dir, g_defaults.core_dir, - "playlists", sizeof(g_defaults.playlist_dir)); + fill_pathname_join(g_defaults.dir.core, g_defaults.dir.port, + "cores", sizeof(g_defaults.dir.core)); + fill_pathname_join(g_defaults.dir.core_info, g_defaults.dir.port, + "cores", sizeof(g_defaults.dir.core_info)); + fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.core, + "savestates", sizeof(g_defaults.dir.savestate)); + fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.core, + "savefiles", sizeof(g_defaults.dir.sram)); + fill_pathname_join(g_defaults.dir.system, g_defaults.dir.core, + "system", sizeof(g_defaults.dir.system)); + fill_pathname_join(g_defaults.dir.shader, g_defaults.dir.core, + "shaders_cg", sizeof(g_defaults.dir.shader)); + fill_pathname_join(g_defaults.path.config, g_defaults.dir.port, + "retroarch.cfg", sizeof(g_defaults.path.config)); + fill_pathname_join(g_defaults.dir.overlay, g_defaults.dir.core, + "overlays", sizeof(g_defaults.dir.overlay)); + fill_pathname_join(g_defaults.dir.assets, g_defaults.dir.core, + "media", sizeof(g_defaults.dir.assets)); + fill_pathname_join(g_defaults.dir.playlist, g_defaults.dir.core, + "playlists", sizeof(g_defaults.dir.playlist)); } #ifndef IS_SALAMANDER @@ -313,13 +322,85 @@ static void frontend_ps3_deinit(void *data) #endif } -static void frontend_ps3_exec(const char *path, bool should_load_game); - +#ifndef IS_SALAMANDER static void frontend_ps3_set_fork(bool exit, bool start_game) { exit_spawn = exitspawn; exitspawn_start_game = start_game; } +#endif + +static int frontend_ps3_exec_exitspawn(const char *path, + char const *argv[], char const *envp[]) +{ + int ret; + unsigned i; + char spawn_data[256]; + SceNpDrmKey *license_data = NULL; + + for(i = 0; i < sizeof(spawn_data); ++i) + spawn_data[i] = i & 0xff; + + ret = sceNpDrmProcessExitSpawn(license_data, path, + (const char** const)argv, envp, (sys_addr_t)spawn_data, + 256, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); + + if(ret < 0) + { + RARCH_WARN("SELF file is not of NPDRM type, trying another approach to boot it...\n"); + sys_game_process_exitspawn(path, (const char** const)argv, + envp, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); + } + + return ret; +} + +static void frontend_ps3_exec(const char *path, bool should_load_game) +{ + int ret = 0; + + (void)should_load_game; + (void)ret; + +#ifndef IS_SALAMANDER + global_t *global = global_get_ptr(); + bool original_verbose = global->verbosity; + + global->verbosity = true; +#endif + + RARCH_LOG("Attempt to load executable: [%s].\n", path); + +#ifndef IS_SALAMANDER + if (should_load_game && global->path.fullpath[0] != '\0') + { + char game_path[256]; + strlcpy(game_path, global->path.fullpath, sizeof(game_path)); + + const char * const spawn_argv[] = { + game_path, + NULL + }; + + ret = frontend_ps3_exec_exitspawn(path, + (const char** const)spawn_argv, NULL); + } + else +#endif + { + ret = frontend_ps3_exec_exitspawn(path, + NULL, NULL); + } + + sceNpTerm(); + sys_net_finalize_network(); + cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_NP); + cellSysmoduleUnloadModule(CELL_SYSMODULE_NET); + +#ifndef IS_SALAMANDER + global->verbosity = original_verbose; +#endif +} static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size) { @@ -334,7 +415,13 @@ static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size) should_load_game = exitspawn_start_game; if (!exit_spawn) + { + frontend_ctx_driver_t *frontend = frontend_get_ptr(); + + if (frontend) + frontend->shutdown = frontend_ps3_shutdown; return; + } #endif frontend_ps3_exec(core_path, should_load_game); @@ -343,8 +430,6 @@ static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size) cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME); cellSysmoduleLoadModule(CELL_SYSMODULE_FS); cellSysmoduleLoadModule(CELL_SYSMODULE_IO); -#else - #endif #ifndef IS_SALAMANDER @@ -353,92 +438,6 @@ static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size) #endif } - -static void frontend_ps3_exec(const char *path, bool should_load_game) -{ - unsigned i; - char spawn_data[256] = {0}; - - (void)should_load_game; - -#ifndef IS_SALAMANDER - global_t *global = global_get_ptr(); - bool original_verbose = global->verbosity; - char game_path[256] = {0}; - - global->verbosity = true; - - game_path[0] = '\0'; -#endif - - RARCH_LOG("Attempt to load executable: [%s].\n", path); - - for(i = 0; i < sizeof(spawn_data); ++i) - spawn_data[i] = i & 0xff; - - SceNpDrmKey * k_licensee = NULL; - int ret; -#ifdef IS_SALAMANDER - const char * const spawn_argv[] = { NULL}; - - ret = sceNpDrmProcessExitSpawn2(k_licensee, path, - (const char** const)spawn_argv, NULL, (sys_addr_t)spawn_data, - 256, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); - - if(ret < 0) - { - RARCH_WARN("SELF file is not of NPDRM type, trying another approach to boot it...\n"); - sys_game_process_exitspawn(path, (const char** const)spawn_argv, - NULL, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); - } -#else - if (should_load_game && global->fullpath[0] != '\0') - { - strlcpy(game_path, global->fullpath, sizeof(game_path)); - - const char * const spawn_argv[] = { - game_path, - NULL - }; - - ret = sceNpDrmProcessExitSpawn2(k_licensee, path, - (const char** const)spawn_argv, NULL, - (sys_addr_t)spawn_data, 256, 1000, - SYS_PROCESS_PRIMARY_STACK_SIZE_1M); - - if(ret < 0) - { - RARCH_WARN("SELF file is not of NPDRM type, trying another approach to boot it...\n"); - sys_game_process_exitspawn(path, (const char** const)spawn_argv, - NULL, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); - } - } - else - { - const char * const spawn_argv[] = {NULL}; - ret = sceNpDrmProcessExitSpawn2(k_licensee, path, - (const char** const)spawn_argv, NULL, (sys_addr_t)spawn_data, - 256, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); - - if(ret < 0) - { - RARCH_WARN("SELF file is not of NPDRM type, trying another approach to boot it...\n"); - sys_game_process_exitspawn(path, (const char** const)spawn_argv, - NULL, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); - } - } -#endif - - sceNpTerm(); - sys_net_finalize_network(); - cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_NP); - cellSysmoduleUnloadModule(CELL_SYSMODULE_NET); - -#ifndef IS_SALAMANDER - global->verbosity = original_verbose; -#endif -} - static int frontend_ps3_get_rating(void) { return 10; @@ -481,14 +480,18 @@ static int frontend_ps3_parse_drive_list(void *data) return 0; } -const frontend_ctx_driver_t frontend_ctx_ps3 = { +frontend_ctx_driver_t frontend_ctx_ps3 = { frontend_ps3_get_environment_settings, frontend_ps3_init, frontend_ps3_deinit, frontend_ps3_exitspawn, NULL, /* process_args */ frontend_ps3_exec, +#ifdef IS_SALAMANDER + NULL, +#else frontend_ps3_set_fork, +#endif NULL, /* shutdown */ NULL, /* get_name */ NULL, /* get_os */ diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index 453ddc9fe4..45eb218cb9 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -14,35 +14,49 @@ * If not, see . */ -#include -#include -#include -#include -#include - #include #include #include #include +#ifdef VITA +#include +#include + +int scePowerSetArmClockFrequency(int freq); +#else +#include +#include +#include +#include +#include +#endif + +#include #include #ifndef IS_SALAMANDER #include #endif -#include "../../gfx/drivers/psp_sdk_defines.h" +#include "../../defines/psp_defines.h" #include "../../general.h" #if defined(HAVE_KERNEL_PRX) || defined(IS_SALAMANDER) +#ifndef VITA #include "../../psp1/kernel_functions.h" #endif +#endif -PSP_MODULE_INFO("RetroArch PSP", 0, 1, 1); +#ifdef VITA +PSP2_MODULE_INFO(0, 0, "RetroArch"); +#else +PSP_MODULE_INFO("RetroArch", 0, 1, 1); PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER|THREAD_ATTR_VFPU); #ifdef BIG_STACK PSP_MAIN_THREAD_STACK_SIZE_KB(4*1024); #endif PSP_HEAP_SIZE_MAX(); +#endif char eboot_path[512]; @@ -56,41 +70,55 @@ static bool exitspawn_start_game = false; static void frontend_psp_get_environment_settings(int *argc, char *argv[], void *args, void *params_data) { + struct rarch_main_wrap *params = NULL; + (void)args; + #ifndef IS_SALAMANDER #if defined(HAVE_LOGGER) logger_init(); #elif defined(HAVE_FILE_LOGGER) +#ifndef VITA global_t *global = global_get_ptr(); global->log_file = fopen("ms0:/retroarch-log.txt", "w"); #endif #endif +#endif +#ifdef VITA + strlcpy(eboot_path, "cache0:/retroarch/", sizeof(eboot_path)); + strlcpy(g_defaults.dir.port, eboot_path, sizeof(g_defaults.dir.port)); +#else strlcpy(eboot_path, argv[0], sizeof(eboot_path)); + fill_pathname_basedir(g_defaults.dir.port, argv[0], sizeof(g_defaults.dir.port)); +#endif + RARCH_LOG("port dir: [%s]\n", g_defaults.dir.port); - fill_pathname_basedir(g_defaults.port_dir, argv[0], sizeof(g_defaults.port_dir)); - RARCH_LOG("port dir: [%s]\n", g_defaults.port_dir); + fill_pathname_join(g_defaults.dir.assets, g_defaults.dir.port, + "media", sizeof(g_defaults.dir.assets)); + fill_pathname_join(g_defaults.dir.core, g_defaults.dir.port, + "cores", sizeof(g_defaults.dir.core)); + fill_pathname_join(g_defaults.dir.core_info, g_defaults.dir.port, + "cores", sizeof(g_defaults.dir.core_info)); + fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.core, + "savestates", sizeof(g_defaults.dir.savestate)); + fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.core, + "savefiles", sizeof(g_defaults.dir.sram)); + fill_pathname_join(g_defaults.dir.system, g_defaults.dir.core, + "system", sizeof(g_defaults.dir.system)); + fill_pathname_join(g_defaults.dir.playlist, g_defaults.dir.core, + "playlists", sizeof(g_defaults.dir.playlist)); + fill_pathname_join(g_defaults.path.config, g_defaults.dir.port, + "retroarch.cfg", sizeof(g_defaults.path.config)); + fill_pathname_join(g_defaults.dir.cheats, g_defaults.dir.cheats, + "cheats", sizeof(g_defaults.dir.cheats)); + fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.remap, + "remaps", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.assets_dir, g_defaults.port_dir, - "media", sizeof(g_defaults.assets_dir)); - fill_pathname_join(g_defaults.core_dir, g_defaults.port_dir, - "cores", sizeof(g_defaults.core_dir)); - fill_pathname_join(g_defaults.core_info_dir, g_defaults.port_dir, - "cores", sizeof(g_defaults.core_info_dir)); - fill_pathname_join(g_defaults.savestate_dir, g_defaults.core_dir, - "savestates", sizeof(g_defaults.savestate_dir)); - fill_pathname_join(g_defaults.sram_dir, g_defaults.core_dir, - "savefiles", sizeof(g_defaults.sram_dir)); - fill_pathname_join(g_defaults.system_dir, g_defaults.core_dir, - "system", sizeof(g_defaults.system_dir)); - fill_pathname_join(g_defaults.playlist_dir, g_defaults.core_dir, - "playlists", sizeof(g_defaults.playlist_dir)); - fill_pathname_join(g_defaults.config_path, g_defaults.port_dir, - "retroarch.cfg", sizeof(g_defaults.config_path)); - fill_pathname_join(g_defaults.cheats_dir, g_defaults.cheats_dir, - "cheats", sizeof(g_defaults.cheats_dir)); - fill_pathname_join(g_defaults.remap_dir, g_defaults.remap_dir, - "remaps", sizeof(g_defaults.remap_dir)); +#ifdef VITA + params = (struct rarch_main_wrap*)params_data; + params->verbose = true; +#endif #ifndef IS_SALAMANDER if (argv[1] && (argv[1][0] != '\0')) @@ -143,9 +171,14 @@ static void frontend_psp_deinit(void *data) static void frontend_psp_shutdown(bool unused) { (void)unused; +#ifdef VITA + sceKernelExitProcess(0); +#else sceKernelExitGame(); +#endif } +#ifndef VITA static int exit_callback(int arg1, int arg2, void *common) { frontend_psp_deinit(NULL); @@ -172,24 +205,36 @@ static int setup_callback(void) return thread_id; } +#endif static void frontend_psp_init(void *data) { #ifndef IS_SALAMANDER +#ifndef VITA (void)data; - //initialize debug screen - pspDebugScreenInit(); + + /* TODO/FIXME - Err on the safe side for now and + * assume these aren't there with the PSP2/Vita SDKs. + */ + + /* initialize debug screen */ + pspDebugScreenInit(); pspDebugScreenClear(); - + setup_callback(); - - pspFpuSetEnable(0);//disable FPU exceptions + + pspFpuSetEnable(0); /* disable FPU exceptions */ scePowerSetClockFrequency(333,333,166); +#else + scePowerSetArmClockFrequency(444); +#endif #endif #if defined(HAVE_KERNEL_PRX) || defined(IS_SALAMANDER) +#ifndef VITA pspSdkLoadStartModule("kernel_functions.prx", PSP_MEMORY_PARTITION_KERNEL); #endif +#endif } static void frontend_psp_exec(const char *path, bool should_load_game) @@ -205,10 +250,10 @@ static void frontend_psp_exec(const char *path, bool should_load_game) #ifndef IS_SALAMANDER global_t *global = global_get_ptr(); - if (should_load_game && global->fullpath[0] != '\0') + if (should_load_game && global->path.fullpath[0] != '\0') { argp[args] = '\0'; - strlcat(argp + args, global->fullpath, sizeof(argp) - args); + strlcat(argp + args, global->path.fullpath, sizeof(argp) - args); args += strlen(argp + args) + 1; } #endif @@ -240,26 +285,35 @@ static void frontend_psp_exitspawn(char *s, size_t len) static int frontend_psp_get_rating(void) { +#ifdef VITA + return 6; /* Go with a conservative figure for now. */ +#else return 4; +#endif } static enum frontend_powerstate frontend_psp_get_powerstate(int *seconds, int *percent) { enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE; +#ifndef VITA int battery = scePowerIsBatteryExist(); +#endif int plugged = scePowerIsPowerOnline(); int charging = scePowerIsBatteryCharging(); *percent = scePowerGetBatteryLifePercent(); *seconds = scePowerGetBatteryLifeTime() * 60; +#ifndef VITA if (!battery) { ret = FRONTEND_POWERSTATE_NO_SOURCE; *seconds = -1; *percent = -1; } - else if (charging) + else +#endif + if (charging) ret = FRONTEND_POWERSTATE_CHARGING; else if (plugged) ret = FRONTEND_POWERSTATE_CHARGED; @@ -271,7 +325,11 @@ static enum frontend_powerstate frontend_psp_get_powerstate(int *seconds, int *p enum frontend_architecture frontend_psp_get_architecture(void) { +#ifdef VITA + return FRONTEND_ARCH_ARM; +#else return FRONTEND_ARCH_MIPS; +#endif } static int frontend_psp_parse_drive_list(void *data) @@ -279,18 +337,23 @@ static int frontend_psp_parse_drive_list(void *data) #ifndef IS_SALAMANDER file_list_t *list = (file_list_t*)data; +#ifdef VITA + menu_list_push(list, + "cache0:/", "", MENU_FILE_DIRECTORY, 0, 0); +#else menu_list_push(list, "ms0:/", "", MENU_FILE_DIRECTORY, 0, 0); menu_list_push(list, "ef0:/", "", MENU_FILE_DIRECTORY, 0, 0); menu_list_push(list, "host0:/", "", MENU_FILE_DIRECTORY, 0, 0); +#endif #endif return 0; } -const frontend_ctx_driver_t frontend_ctx_psp = { +frontend_ctx_driver_t frontend_ctx_psp = { frontend_psp_get_environment_settings, frontend_psp_init, frontend_psp_deinit, @@ -306,5 +369,9 @@ const frontend_ctx_driver_t frontend_ctx_psp = { frontend_psp_get_architecture, frontend_psp_get_powerstate, frontend_psp_parse_drive_list, +#ifdef VITA + "vita", +#else "psp", +#endif }; diff --git a/frontend/drivers/platform_qnx.c b/frontend/drivers/platform_qnx.c index e661d04521..fe48376906 100644 --- a/frontend/drivers/platform_qnx.c +++ b/frontend/drivers/platform_qnx.c @@ -45,18 +45,18 @@ static int frontend_qnx_get_rating(void) static void frontend_qnx_get_environment_settings(int *argc, char *argv[], void *data, void *params_data) { - fill_pathname_join(g_defaults.config_path, "app/native", - "retroarch.cfg", sizeof(g_defaults.config_path)); - fill_pathname_join(g_defaults.shader_dir, "app/native", - "shaders_glsl", sizeof(g_defaults.shader_dir)); - fill_pathname_join(g_defaults.overlay_dir, "app/native", - "overlays", sizeof(g_defaults.overlay_dir)); - fill_pathname_join(g_defaults.core_dir, "app/native", - "lib", sizeof(g_defaults.core_dir)); - fill_pathname_join(g_defaults.core_info_dir, "app/native", - "info", sizeof(g_defaults.core_info_dir)); - fill_pathname_join(g_defaults.playlist_dir, "app/native", - "playlists", sizeof(g_defaults.playlist_dir)); + fill_pathname_join(g_defaults.path.config, "app/native", + "retroarch.cfg", sizeof(g_defaults.path.config)); + fill_pathname_join(g_defaults.dir.shader, "app/native", + "shaders_glsl", sizeof(g_defaults.dir.shader)); + fill_pathname_join(g_defaults.dir.overlay, "app/native", + "overlays", sizeof(g_defaults.dir.overlay)); + fill_pathname_join(g_defaults.dir.core, "app/native", + "lib", sizeof(g_defaults.dir.core)); + fill_pathname_join(g_defaults.dir.core_info, "app/native", + "info", sizeof(g_defaults.dir.core_info)); + fill_pathname_join(g_defaults.dir.playlist, "app/native", + "playlists", sizeof(g_defaults.dir.playlist)); } enum frontend_architecture frontend_qnx_get_architecture(void) @@ -64,7 +64,7 @@ enum frontend_architecture frontend_qnx_get_architecture(void) return FRONTEND_ARCH_ARM; } -const frontend_ctx_driver_t frontend_ctx_qnx = { +frontend_ctx_driver_t frontend_ctx_qnx = { frontend_qnx_get_environment_settings, frontend_qnx_init, NULL, /* deinit */ diff --git a/frontend/drivers/platform_wii.c b/frontend/drivers/platform_wii.c index db83ac5455..609b6279ad 100644 --- a/frontend/drivers/platform_wii.c +++ b/frontend/drivers/platform_wii.c @@ -132,7 +132,7 @@ void system_exec_wii(const char *_path, bool should_load_game) #ifdef IS_SALAMANDER strlcpy(game_path, gx_rom_path, sizeof(game_path)); #else - strlcpy(game_path, global->fullpath, sizeof(game_path)); + strlcpy(game_path, global->path.fullpath, sizeof(game_path)); #endif } diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index ce1d59bcdc..c25459ae08 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -27,7 +27,6 @@ #include "../../general.h" #include "../../menu/menu.h" -#if defined(_WIN32) /* We only load this library once, so we let it be * unloaded at application shutdown, since unloading * it early seems to cause issues on some systems. @@ -95,7 +94,6 @@ static void gfx_set_dwm(void) RARCH_ERR("Failed to set composition state ...\n"); dwm_composition_disabled = settings->video.disable_composition; } -#endif static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor) { @@ -227,7 +225,7 @@ static int frontend_win32_parse_drive_list(void *data) return 0; } -const frontend_ctx_driver_t frontend_ctx_win32 = { +frontend_ctx_driver_t frontend_ctx_win32 = { NULL, /* environment_get */ frontend_win32_init, NULL, /* deinit */ diff --git a/frontend/drivers/platform_xdk.c b/frontend/drivers/platform_xdk.c index 5bfc2692cc..b13b81ccdc 100644 --- a/frontend/drivers/platform_xdk.c +++ b/frontend/drivers/platform_xdk.c @@ -176,34 +176,34 @@ static void frontend_xdk_get_environment_settings(int *argc, char *argv[], #endif #if defined(_XBOX1) - strlcpy(g_defaults.core_dir, "D:", sizeof(g_defaults.core_dir)); - strlcpy(g_defaults.core_info_dir, "D:", sizeof(g_defaults.core_info_dir)); - fill_pathname_join(g_defaults.config_path, g_defaults.core_dir, - "retroarch.cfg", sizeof(g_defaults.config_path)); - fill_pathname_join(g_defaults.savestate_dir, g_defaults.core_dir, - "savestates", sizeof(g_defaults.savestate_dir)); - fill_pathname_join(g_defaults.sram_dir, g_defaults.core_dir, - "savefiles", sizeof(g_defaults.sram_dir)); - fill_pathname_join(g_defaults.system_dir, g_defaults.core_dir, - "system", sizeof(g_defaults.system_dir)); - fill_pathname_join(g_defaults.screenshot_dir, g_defaults.core_dir, - "screenshots", sizeof(g_defaults.screenshot_dir)); + strlcpy(g_defaults.dir.core, "D:", sizeof(g_defaults.dir.core)); + strlcpy(g_defaults.dir.core_info, "D:", sizeof(g_defaults.dir.core_info)); + fill_pathname_join(g_defaults.path.config, g_defaults.dir.core, + "retroarch.cfg", sizeof(g_defaults.path.config)); + fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.core, + "savestates", sizeof(g_defaults.dir.savestate)); + fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.core, + "savefiles", sizeof(g_defaults.dir.sram)); + fill_pathname_join(g_defaults.dir.system, g_defaults.dir.core, + "system", sizeof(g_defaults.dir.system)); + fill_pathname_join(g_defaults.dir.screenshot, g_defaults.dir.core, + "screenshots", sizeof(g_defaults.dir.screenshot)); #elif defined(_XBOX360) - strlcpy(g_defaults.core_dir, "game:", sizeof(g_defaults.core_dir)); - strlcpy(g_defaults.core_info_dir, - "game:", sizeof(g_defaults.core_info_dir)); - strlcpy(g_defaults.config_path, - "game:\\retroarch.cfg", sizeof(g_defaults.config_path)); - strlcpy(g_defaults.screenshot_dir, - "game:", sizeof(g_defaults.screenshot_dir)); - strlcpy(g_defaults.savestate_dir, - "game:\\savestates", sizeof(g_defaults.savestate_dir)); - strlcpy(g_defaults.playlist_dir, - "game:\\playlists", sizeof(g_defaults.playlist_dir)); - strlcpy(g_defaults.sram_dir, - "game:\\savefiles", sizeof(g_defaults.sram_dir)); - strlcpy(g_defaults.system_dir, - "game:\\system", sizeof(g_defaults.system_dir)); + strlcpy(g_defaults.dir.core, "game:", sizeof(g_defaults.dir.core)); + strlcpy(g_defaults.dir.core_info, + "game:", sizeof(g_defaults.dir.core_info)); + strlcpy(g_defaults.path.config, + "game:\\retroarch.cfg", sizeof(g_defaults.path.config)); + strlcpy(g_defaults.dir.screenshot, + "game:", sizeof(g_defaults.dir.screenshot)); + strlcpy(g_defaults.dir.savestate, + "game:\\savestates", sizeof(g_defaults.dir.savestate)); + strlcpy(g_defaults.dir.playlist, + "game:\\playlists", sizeof(g_defaults.dir.playlist)); + strlcpy(g_defaults.dir.sram, + "game:\\savefiles", sizeof(g_defaults.dir.sram)); + strlcpy(g_defaults.dir.system, + "game:\\system", sizeof(g_defaults.dir.system)); #endif #ifndef IS_SALAMANDER @@ -407,7 +407,7 @@ static int frontend_xdk_parse_drive_list(void *data) return 0; } -const frontend_ctx_driver_t frontend_ctx_xdk = { +frontend_ctx_driver_t frontend_ctx_xdk = { frontend_xdk_get_environment_settings, frontend_xdk_init, NULL, /* deinit */ diff --git a/frontend/drivers/platform_xenon.c b/frontend/drivers/platform_xenon.c new file mode 100644 index 0000000000..21337841b6 --- /dev/null +++ b/frontend/drivers/platform_xenon.c @@ -0,0 +1,87 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2015 - 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 . + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include