Merge remote-tracking branch 'refs/remotes/libretro/master'

This commit is contained in:
IlDucci 2015-10-27 21:50:13 +01:00
commit 4b8e002d98
937 changed files with 9919 additions and 10672 deletions

18
.gitignore vendored
View File

@ -23,7 +23,7 @@ Debug
Release
ipch
*.user
/wii/app_booter/app_booter.bin
/bootstrap/gx/wii/app_booter/app_booter.bin
*.zip
RetroArch-w32/
RetroArch-w64/
@ -62,12 +62,12 @@ apple/RetroArch_iOS.xcodeproj/project.xcworkspace/*
/obj-w32/
# Android
/android/phoenix/obj/
/android/phoenix/assets/
/android/phoenix/libs/
/android/phoenix/bin/
/android/phoenix/gen/
/android/phoenix/local.properties
/pkg/android/phoenix/obj/
/pkg/android/phoenix/assets/
/pkg/android/phoenix/libs/
/pkg/android/phoenix/bin/
/pkg/android/phoenix/gen/
/pkg/android/phoenix/local.properties
# Cloned by libretro-fetch.sh
/media/assets/
@ -76,8 +76,8 @@ apple/RetroArch_iOS.xcodeproj/project.xcworkspace/*
/media/shaders_cg/
/media/libretrodb/
apple/iOS/build/
apple/iOS/modules/
pkg/apple/iOS/build/
pkg/apple/iOS/modules/
obj-unix/
.vagrant/

View File

@ -1,6 +1,10 @@
HAVE_FILE_LOGGER=1
MISSING_DECLS =0
ifneq ($(C90_BUILD),)
C89_BUILD=1
endif
include config.mk
TARGET = retroarch
@ -77,9 +81,8 @@ else
endif
endif
ifneq ($(C89_BUILD)$(C90_BUILD),)
#looks kinda ugly, but it makes both C89_BUILD and C90_BUILD work and refer to the same thing
CFLAGS += -std=c89 -ansi -pedantic -Werror=pedantic
ifneq ($(C89_BUILD),)
CFLAGS += -std=c89 -ansi -pedantic -Werror=pedantic -Wno-long-long
endif
endif

View File

@ -54,7 +54,7 @@ ifeq ($(TDM_GCC),)
endif
ifeq ($(HAVE_FILE_LOGGER), 1)
CFLAGS += -DHAVE_FILE_LOGGER -Ilogger/netlogger
CFLAGS += -DHAVE_FILE_LOGGER
endif
CFLAGS += -I./libretro-common/include
@ -131,6 +131,8 @@ OBJ += frontend/frontend.o \
libretro-common/file/file_list.o \
libretro-common/file/dir_list.o \
libretro-common/file/retro_dirent.o \
libretro-common/file/retro_file.o \
libretro-common/file/retro_stat.o \
libretro-common/string/string_list.o \
libretro-common/string/stdstring.o \
libretro-common/memmap/memalign.o \
@ -210,15 +212,10 @@ OBJ += frontend/frontend.o \
OBJ += gfx/image/image.o
ifneq ($(C89_BUILD), 1)
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
@ -237,7 +234,8 @@ OBJ += libretro-db/bintree.o \
libretro-db/rmsgpack.o \
libretro-db/rmsgpack_dom.o \
database_info.o \
tasks/task_database.o
tasks/task_database.o \
tasks/task_database_cue.o
endif
# Miscellaneous
@ -246,16 +244,11 @@ ifeq ($(HAVE_STDIN_CMD), 1)
DEFINES += -DHAVE_COMMAND -DHAVE_STDIN_CMD
endif
ifneq ($(C89_BUILD), 1)
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
endif
ifeq ($(HAVE_EMSCRIPTEN), 1)
OBJ += frontend/drivers/platform_emscripten.o \
@ -315,16 +308,11 @@ ifeq ($(HAVE_JACK),1)
DEFINES += $(JACK_CFLAGS)
endif
ifneq ($(C89_BUILD), 1)
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
@ -474,16 +462,11 @@ endif
#Input
ifneq ($(C89_BUILD), 1)
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
@ -521,9 +504,6 @@ ifeq ($(HAVE_UDEV), 1)
input/drivers_joypad/udev_joypad.o
endif
ifneq ($(C89_BUILD), 1)
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
@ -531,8 +511,6 @@ ifeq ($(HAVE_LIBUSB), 1)
JOYCONFIG_LIBS += -lusb-1.0
HAVE_HID = 1
endif
endif
endif
ifeq ($(HAVE_IOHIDMANAGER), 1)
DEFINES += -DHAVE_IOHIDMANAGER
@ -612,16 +590,11 @@ ifeq ($(HAVE_GL_CONTEXT), 1)
endif
endif
ifneq ($(C89_BUILD), 1)
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)
LIBS += $(GLES_LIBS)
@ -689,7 +662,7 @@ endif
ifeq ($(HAVE_EXYNOS), 1)
OBJ += gfx/drivers/exynos_gfx.o \
mem/neon/memcpy-neon.o
memory/neon/memcpy-neon.o
LIBS += $(DRM_LIBS) $(EXYNOS_LIBS)
DEFINES += $(DRM_CFLAGS) $(EXYNOS_CFLAGS)
endif
@ -770,7 +743,6 @@ ifeq ($(HAVE_7ZIP),1)
OBJ += $(7ZOBJ)
endif
OBJ += libretro-common/formats/tga/tga_decode.o
ifeq ($(HAVE_ZLIB), 1)
OBJ += libretro-common/file/file_extract.o
@ -791,11 +763,11 @@ ifdef HAVE_RPNG
endif
ifeq ($(HAVE_RPNG), 1)
OBJ += libretro-common/formats/png/rpng_nbio.o \
libretro-common/formats/png/rpng_fbio.o \
libretro-common/formats/png/rpng_decode.o \
OBJ += libretro-common/formats/png/rpng.o \
libretro-common/formats/png/rpng_encode.o
endif
OBJ += libretro-common/formats/bmp/rbmp_encode.o \
libretro-common/formats/tga/rtga.o
ifdef HAVE_COMPRESSION
DEFINES += -DHAVE_COMPRESSION
@ -874,9 +846,6 @@ endif
# Record
ifneq ($(C89_BUILD), 1)
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
@ -884,8 +853,6 @@ ifeq ($(HAVE_FFMPEG), 1)
DEFINES += $(AVCODEC_CFLAGS) $(AVFORMAT_CFLAGS) $(AVUTIL_CFLAGS) $(SWSCALE_CFLAGS) $(SWRESAMPLE_CFLAGS)
DEFINES += -DHAVE_FFMPEG -Iffmpeg
endif
endif
endif
ifeq ($(HAVE_COMPRESSION), 1)
DEFINES += -DHAVE_COMPRESSION

View File

@ -4,6 +4,7 @@ LIBRETRO =
DEBUG = 0
GRIFFIN_BUILD = 1
WHOLE_ARCHIVE_LINK = 0
BIG_STACK = 0
BUILD_3DSX = 1
BUILD_CIA = 1
@ -15,6 +16,16 @@ APP_UNIQUE_ID = 0xBAC00
APP_ICON = ctr/default.png
APP_BANNER = ctr/libretro_banner.png
APP_AUDIO = ctr/silent.wav
APP_CIA_RSF = ctr/tools/template-cia.rsf
APP_3DS_RSF = ctr/tools/template-3ds.rsf
ifeq ($(BIG_STACK),1)
CTR_STACK_SIZE = 0x400000
else
CTR_STACK_SIZE = 0x100000
endif
CTR_LINEAR_HEAP_SIZE = 0x600000
include ctr/Makefile.cores
@ -39,11 +50,10 @@ else
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/tga/rtga.o
OBJS += libretro-common/formats/png/rpng.o
OBJS += libretro-common/formats/png/rpng_encode.o
OBJS += libretro-common/formats/bmp/rbmp_encode.o
OBJS += gfx/drivers/ctr_gfx.o
OBJS += gfx/drivers/nullgfx.o
OBJS += gfx/font_renderer_driver.o
@ -117,6 +127,7 @@ else
OBJS += file_path_special.o
OBJS += libretro-common/file/dir_list.o
OBJS += libretro-common/file/retro_dirent.o
OBJS += libretro-common/file/retro_file.o
OBJS += dir_list_special.o
OBJS += libretro-common/string/string_list.o
OBJS += libretro-common/string/stdstring.o
@ -264,6 +275,14 @@ ifeq ($(WHOLE_ARCHIVE_LINK), 1)
WHOLE_END := -Wl,--no-whole-archive
endif
ifneq ($(CTR_STACK_SIZE),)
CFLAGS += -DCTR_STACK_SIZE=$(CTR_STACK_SIZE)
endif
ifneq ($(CTR_LINEAR_HEAP_SIZE),)
CFLAGS += -DCTR_LINEAR_HEAP_SIZE=$(CTR_LINEAR_HEAP_SIZE)
endif
CFLAGS += -I. -Ideps/zlib -Ideps/7zip -Ilibretro-common/include
CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE -DSINC_LOWEST_QUALITY
@ -369,15 +388,12 @@ $(TARGET).bnr: $(APP_BANNER) $(APP_AUDIO)
$(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
$(TARGET).cia: $(TARGET)_stripped.elf $(TARGET).bnr $(TARGET).icn
$(MAKEROM) -f cia -o $@ -rsf $(APP_CIA_RSF) -target t -exefslogo -elf $(TARGET)_stripped.elf -icon $(TARGET).icn -banner $(TARGET).bnr -DAPP_TITLE="$(APP_TITLE)" -DAPP_PRODUCT_CODE="$(APP_PRODUCT_CODE)" -DAPP_UNIQUE_ID=$(APP_UNIQUE_ID)
clean:
rm -f $(OBJS)
@ -387,7 +403,6 @@ clean:
rm -f $(TARGET).cia
rm -f $(TARGET).bnr
rm -f $(TARGET).icn
rm -f $(TARGET).rsf
rm -f *_shader_shbin.h
.PHONY: clean

View File

@ -100,12 +100,12 @@ endif
ifeq ($(platform), ngc)
LDFLAGS += $(MACHDEP) -Wl,-Map,$(notdir $(EXT_INTER_TARGET)).map
ifeq ($(BIG_STACK), 1)
LDFLAGS += -T gx/ld/ogc.ld
LDFLAGS += -T bootstrap/gx/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
LDFLAGS += -T bootstrap/gx/rvl.ld
endif
endif
LIBS += -lfat -logc
@ -202,10 +202,10 @@ else ifeq ($(platform), vita)
EXT_TARGET := $(TARGET_NAME)_$(platform).velf
EXT_INTER_TARGET := $(TARGET_NAME)_$(platform).elf
MACHDEP := -DVITA
PLATCFLAGS := -O3 -U__ARM_NEON__
PLATCFLAGS := -O3 -mfloat-abi=hard -ffast-math -fsingle-precision-constant
LIBS += -lSceKernel_stub -lSceDisplay_stub -lSceGxm_stub -lSceNet_stub \
-lSceSysmodule_stub -lSceCtrl_stub -lSceAudio_stub \
-lScePower_stub -lSceRtc_stub -lz -lm -lc
-lSceSysmodule_stub -lSceCtrl_stub -lSceAudio_stub -lUVLoader_stub \
-lScePower_stub -lSceRtc_stub -lSceCommonDialog_stub -lz -lm -lc
PLATOBJS += audio/audio_utils_neon.o audio/drivers_resampler/sinc_neon.o \
audio/drivers_resampler/cc_resampler_neon.o
@ -213,6 +213,7 @@ else ifeq ($(platform), vita)
LIBDIRS += -L.
LDFLAGS += -Wl,-q
HAVE_FILTERS_BUILTIN := 1
HAVE_LIBRETRO_MANAGEMENT := 1
HAVE_BUILTIN_AUTOCONFIG := 1
HAVE_RPNG := 1
@ -231,7 +232,6 @@ INCLUDE += -I./libretro-common/include
ifeq ($(HAVE_LOGGER), 1)
CFLAGS += -DHAVE_LOGGER
CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
INCLUDE += -Ilogger/netlogger
endif
ifeq ($(platform), wii)
@ -276,7 +276,6 @@ endif
ifeq ($(HAVE_FILE_LOGGER), 1)
CFLAGS += -DHAVE_FILE_LOGGER
INCLUDE += -Ilogger/netlogger
endif
ifeq ($(HAVE_RARCH_EXEC), 1)
@ -359,7 +358,7 @@ all: $(EXT_TARGET)
%.velf: %.elf
arm-vita-eabi-strip -g $<
vita-elf-create $< $@ $(VITASDK)/bin/db.json
vita-elf-create $< $@ $(VITASDK)/bin/db.json $(VITASDK)/bin/extra.json
%.elf32: %.elf
ifeq ($(platform), xenon360)

View File

@ -2,7 +2,7 @@
# $ source /usr/local/angstrom/arm/environment-setup
# $ setprj retroarch
PNDDIR=./pandora
PNDDIR=./pkg/pandora
BINDIR=$(PNDDIR)/bin
all: $(BINDIR)/retroarch

View File

@ -34,7 +34,7 @@ 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
INCDIRS = -I. -Idefines -Ideps/zlib -Ilibretro-common/include
# system platform
system_platform = unix
@ -47,7 +47,7 @@ else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
PKG_SCRIPT = ps3/ps3py/pkg.py
PKG_SCRIPT = tools/ps3/ps3py/pkg.py
ifeq ($(shell uname), Linux)
PKG_FINALIZE = package_finalize
MAKE_SELF_WC = make_self_wc
@ -116,7 +116,6 @@ endif
ifeq ($(HAVE_LOGGER), 1)
DEFINES += -DHAVE_LOGGER
INCDIRS += -Ilogger/netlogger
endif
PPU_CFLAGS := $(PPU_OPTIMIZE_LV) $(INCDIRS) $(DEFINES)

View File

@ -34,7 +34,7 @@ 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
INCDIRS = -I. -Idefines
# system platform
system_platform = unix
@ -47,7 +47,7 @@ else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
PKG_SCRIPT = ps3/ps3py/pkg.py
PKG_SCRIPT = tools/ps3/ps3py/pkg.py
ifeq ($(shell uname), Linux)
PKG_FINALIZE = package_finalize
MAKE_SELF_WC = make_self_wc
@ -116,7 +116,6 @@ endif
ifeq ($(HAVE_LOGGER), 1)
DEFINES += -DHAVE_LOGGER
INCDIRS += -Ilogger/netlogger
endif
PPU_CFLAGS := $(PPU_OPTIMIZE_LV) $(INCDIRS) $(DEFINES)

View File

@ -26,14 +26,16 @@ PPU_SRCS = frontend/frontend_salamander.c \
libretro-common/file/file_path.c \
libretro-common/file/dir_list.c \
libretro-common/file/retro_dirent.c \
libretro-common/file/retro_stat.c \
libretro-common/hash/rhash.c \
libretro-common/string/string_list.c \
libretro-common/compat/compat.c \
libretro-common/file/retro_file.c \
libretro-common/file/config_file.c
ifeq ($(HAVE_LOGGER), 1)
PPU_CFLAGS += -DHAVE_LOGGER -Ilogger/netlogger
PPU_SRCS += logger/netlogger/logger.c
PPU_CFLAGS += -DHAVE_LOGGER
PPU_SRCS += netlogger.c
endif
PPU_TARGET = retroarch-salamander_ps3.elf

View File

@ -36,7 +36,7 @@ else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
PKG_SCRIPT = ps3/ps3py/pkg.py
PKG_SCRIPT = tools/ps3/ps3py/pkg.py
ifeq ($(shell uname), Linux)
PKG_FINALIZE = package_finalize
MAKE_SELF_WC = make_self_wc
@ -61,7 +61,7 @@ else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
PKG_SCRIPT = ps3/ps3py/pkg.py
PKG_SCRIPT = tools/ps3/ps3py/pkg.py
ifeq ($(shell uname), Linux)
PKG_FINALIZE = package_finalize
MAKE_SELF_WC = make_self_wc

View File

@ -51,7 +51,7 @@ CFLAGS += $(RARCH_DEFINES)
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = RetroArch PSP1
PSP_OBJECTS = griffin/griffin.o psp1/kernel_functions.o
PSP_OBJECTS = griffin/griffin.o bootstrap/psp1/kernel_functions.o
OBJS = $(PSP_OBJECTS)

View File

@ -28,8 +28,8 @@ CFLAGS += $(RARCH_DEFINES)
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = RetroArch
PSP_EBOOT_ICON = psp1/ICON0.PNG
PSP_EBOOT_PIC1 = psp1/PIC1.PNG
PSP_EBOOT_ICON = pkg/psp1/ICON0.PNG
PSP_EBOOT_PIC1 = pkg/psp1/PIC1.PNG
OBJS = frontend/frontend_salamander.o \
frontend/frontend_driver.o \
@ -41,8 +41,10 @@ OBJS = frontend/frontend_salamander.o \
libretro-common/file/retro_dirent.o \
libretro-common/compat/compat.o \
libretro-common/file/config_file.o \
libretro-common/file/retro_file.o \
libretro-common/file/retro_stat.o \
libretro-common/hash/rhash.o \
psp1/kernel_functions.o
bootstrap/psp1/kernel_functions.o
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

View File

@ -48,7 +48,9 @@ OBJ = frontend/frontend_salamander.o \
libretro-common/hash/rhash.o \
libretro-common/string/string_list.o \
libretro-common/file/dir_list.o \
libretro-common/file/retro_file.o \
libretro-common/file/retro_dirent.o \
libretro-common/file/retro_stat.o \
libretro-common/compat/compat.o \
libretro-common/file/config_file.o \
$(APP_BOOTER_DIR)/app_booter.binobj
@ -56,13 +58,11 @@ OBJ = frontend/frontend_salamander.o \
ifeq ($(HAVE_LOGGER), 1)
CFLAGS += -DHAVE_LOGGER
CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
CFLAGS += -Ilogger/netlogger
OBJ += logger/netlogger/logger.o
OBJ += logger/netlogger.o
endif
ifeq ($(HAVE_FILE_LOGGER), 1)
CFLAGS += -DHAVE_FILE_LOGGER
CFLAGS += -Ilogger/netlogger
endif
CFLAGS += -std=gnu99 -DIS_SALAMANDER -DRARCH_CONSOLE -DHAVE_RARCH_EXEC -DGEKKO -Wno-char-subscripts

View File

@ -123,20 +123,20 @@ make
<b>Mac</b><br/>
- Prerequisites: [XCode](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CB4QFjAA&url=https%3A%2F%2Fitunes.apple.com%2Fus%2Fapp%2Fxcode%2Fid497799835%3Fmt%3D12&ei=ZmfeVNPtIILVoASBnoCYBw&usg=AFQjCNGrxKmVtXUdvUU3MhqZhP4MHT6Gtg&sig2=RIXKsWQ79YTQBt_lK5fdKA&bvm=bv.85970519,d.cGU), [Cg](https://developer.nvidia.com/cg-toolkit-download).
- You can open the project (**apple/RetroArch.xcodeproj**) in the Xcode IDE and build (**&#8984;-B**) and run (**&#8984;-R**) it there. Or you can use the command line...
- You can open the project (**pkg/apple/RetroArch.xcodeproj**) in the Xcode IDE and build (**&#8984;-B**) and run (**&#8984;-R**) it there. Or you can use the command line...
- Debug:
```bash
# Build
xcodebuild -target RetroArch -configuration Debug -project apple/RetroArch.xcodeproj
xcodebuild -target RetroArch -configuration Debug -project pkg/apple/RetroArch.xcodeproj
# Run
open ./apple/build/Debug/RetroArch.app/
open ./pkg/apple/build/Debug/RetroArch.app/
```
- Release:
```bash
# Build
xcodebuild -target RetroArch -configuration Release -project apple/RetroArch.xcodeproj
xcodebuild -target RetroArch -configuration Release -project pkg/apple/RetroArch.xcodeproj
# Run
open ./apple/build/Release/RetroArch.app/
open ./pkg/apple/build/Release/RetroArch.app/
```
<b>PC</b><br/>
@ -186,9 +186,9 @@ You will need Microsoft Visual Studio 2010 installed (or higher) in order to com
The solution file can be found at the following location:
<tt>msvc-360/RetroArch-360.sln</tt>
<tt>pkg/msvc-360/RetroArch-360.sln</tt>
NOTE: A pre-existing libretro library needs to be present in the `msvc-360/RetroArch-360/Release` directory in order to link RetroArch 360. This file needs to be
NOTE: A pre-existing libretro library needs to be present in the `pkg/msvc-360/RetroArch-360/Release` directory in order to link RetroArch 360. This file needs to be
called <em><b>`libretro_xdk360.lib`</b></em>.
<b> Xbox 360 (Libxenon)</b><br />

View File

@ -594,11 +594,15 @@ void audio_driver_set_nonblocking_state(bool enable)
**/
bool audio_driver_flush(const int16_t *data, size_t samples)
{
static struct retro_perf_counter audio_convert_s16 = {0};
static struct retro_perf_counter audio_convert_float = {0};
static struct retro_perf_counter audio_dsp = {0};
static struct retro_perf_counter resampler_proc = {0};
struct resampler_data src_data = {0};
struct rarch_dsp_data dsp_data = {0};
const void *output_data = NULL;
unsigned output_frames = 0;
size_t output_size = sizeof(float);
struct resampler_data src_data = {0};
struct rarch_dsp_data dsp_data = {0};
driver_t *driver = driver_get_ptr();
const audio_driver_t *audio = driver ?
(const audio_driver_t*)driver->audio : NULL;
@ -619,11 +623,11 @@ bool audio_driver_flush(const int16_t *data, size_t samples)
if (!driver->audio_active || !audio_data.data)
return false;
RARCH_PERFORMANCE_INIT(audio_convert_s16);
RARCH_PERFORMANCE_START(audio_convert_s16);
rarch_perf_init(&audio_convert_s16, "audio_convert_s16");
retro_perf_start(&audio_convert_s16);
audio_convert_s16_to_float(audio_data.data, data, samples,
audio_data.volume_gain);
RARCH_PERFORMANCE_STOP(audio_convert_s16);
retro_perf_stop(&audio_convert_s16);
src_data.data_in = audio_data.data;
src_data.input_frames = samples >> 1;
@ -633,10 +637,10 @@ bool audio_driver_flush(const int16_t *data, size_t samples)
if (audio_data.dsp)
{
RARCH_PERFORMANCE_INIT(audio_dsp);
RARCH_PERFORMANCE_START(audio_dsp);
rarch_perf_init(&audio_dsp, "audio_dsp");
retro_perf_start(&audio_dsp);
rarch_dsp_filter_process(audio_data.dsp, &dsp_data);
RARCH_PERFORMANCE_STOP(audio_dsp);
retro_perf_stop(&audio_dsp);
if (dsp_data.output)
{
@ -654,22 +658,22 @@ bool audio_driver_flush(const int16_t *data, size_t samples)
if (rarch_main_is_slowmotion())
src_data.ratio *= settings->slowmotion_ratio;
RARCH_PERFORMANCE_INIT(resampler_proc);
RARCH_PERFORMANCE_START(resampler_proc);
rarch_perf_init(&resampler_proc, "resampler_proc");
retro_perf_start(&resampler_proc);
rarch_resampler_process(driver->resampler,
driver->resampler_data, &src_data);
RARCH_PERFORMANCE_STOP(resampler_proc);
retro_perf_stop(&resampler_proc);
output_data = audio_data.outsamples;
output_frames = src_data.output_frames;
if (!audio_data.use_float)
{
RARCH_PERFORMANCE_INIT(audio_convert_float);
RARCH_PERFORMANCE_START(audio_convert_float);
rarch_perf_init(&audio_convert_float, "audio_convert_float");
retro_perf_start(&audio_convert_float);
audio_convert_float_to_s16(audio_data.conv_outsamples,
(const float*)output_data, output_frames * 2);
RARCH_PERFORMANCE_STOP(audio_convert_float);
retro_perf_stop(&audio_convert_float);
output_data = audio_data.conv_outsamples;
output_size = sizeof(int16_t);

View File

@ -146,7 +146,7 @@ static const dspfilter_get_implementation_t dsp_plugs_builtin[] = {
static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list)
{
unsigned i;
dspfilter_simd_mask_t mask = rarch_get_cpu_features();
dspfilter_simd_mask_t mask = retro_get_cpu_features();
(void)list;
@ -170,7 +170,7 @@ static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list)
static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list)
{
unsigned i;
dspfilter_simd_mask_t mask = rarch_get_cpu_features();
dspfilter_simd_mask_t mask = retro_get_cpu_features();
for (i = 0; i < list->size; i++)
{

View File

@ -42,7 +42,7 @@ ifeq (debug,$(build))
extra_flags += -O0 -g
endif
ldflags := -shared -lm -Wl,--version-script=link.T
ldflags := $(LDFLAGS) -shared -lm -Wl,--version-script=link.T
ifeq ($(platform), unix)
DYLIB = so
@ -57,8 +57,8 @@ endif
CC := $(compiler) -Wall
CXX := $(subst CC,++,$(compiler)) -std=gnu++0x -Wall
flags := -fPIC $(extra_flags) -I../../libretro-common/include
asflags := -fPIC $(extra_flags)
flags := $(CFLAGS) -fPIC $(extra_flags) -I../../libretro-common/include
asflags := $(ASFLAGS) -fPIC $(extra_flags)
objects :=
ifeq (1,$(use_neon))

View File

@ -171,7 +171,7 @@ retro_get_cpu_features_t perf_get_cpu_features_cb;
static resampler_simd_mask_t resampler_get_cpu_features(void)
{
#ifdef RARCH_INTERNAL
return rarch_get_cpu_features();
return retro_get_cpu_features();
#else
return perf_get_cpu_features_cb();
#endif

View File

@ -215,7 +215,7 @@ void audio_convert_float_to_s16_altivec(int16_t *out,
}
audio_convert_float_to_s16_C(out, in, samples_in);
}
#elif defined(__ARM_NEON__)
#elif defined(__ARM_NEON__) && !defined(VITA)
/* Avoid potential hard-float/soft-float ABI issues. */
void audio_convert_s16_float_asm(float *out, const int16_t *in,
size_t samples, const float *gain);
@ -409,7 +409,7 @@ retro_get_cpu_features_t perf_get_cpu_features_cb;
static unsigned audio_convert_get_cpu_features(void)
{
#ifdef RARCH_INTERNAL
return rarch_get_cpu_features();
return retro_get_cpu_features();
#else
return perf_get_cpu_features_cb();
#endif
@ -426,7 +426,7 @@ void audio_convert_init_simd(void)
unsigned cpu = audio_convert_get_cpu_features();
(void)cpu;
#if defined(__ARM_NEON__)
#if defined(__ARM_NEON__) && !defined(VITA)
audio_convert_s16_to_float_arm = cpu & RETRO_SIMD_NEON ?
audio_convert_s16_to_float_neon : audio_convert_s16_to_float_C;
audio_convert_float_to_s16_arm = cpu & RETRO_SIMD_NEON ?

View File

@ -93,7 +93,7 @@ void audio_convert_s16_to_float_altivec(float *out,
void audio_convert_float_to_s16_altivec(int16_t *out,
const float *in, size_t samples);
#elif defined(__ARM_NEON__)
#elif defined(__ARM_NEON__) && !defined(VITA)
#define audio_convert_s16_to_float audio_convert_s16_to_float_arm
#define audio_convert_float_to_s16 audio_convert_float_to_s16_arm

View File

@ -15,7 +15,6 @@
*/
#include <stdlib.h>
#include <pthread.h>
#if TARGET_OS_IPHONE
#include <AudioToolbox/AudioToolbox.h>
@ -29,6 +28,7 @@
#include <boolean.h>
#include <queues/fifo_buffer.h>
#include <rthreads/rthreads.h>
#include <retro_endianness.h>
#include "../../driver.h"
@ -44,8 +44,8 @@
typedef struct coreaudio
{
pthread_mutex_t lock;
pthread_cond_t cond;
slock_t *lock;
scond_t *cond;
#ifdef OSX_PPC
ComponentInstance dev;
@ -82,8 +82,8 @@ static void coreaudio_free(void *data)
if (dev->buffer)
fifo_free(dev->buffer);
pthread_mutex_destroy(&dev->lock);
pthread_cond_destroy(&dev->cond);
slock_free(dev->lock);
scond_free(dev->cond);
free(dev);
}
@ -109,7 +109,7 @@ static OSStatus audio_write_cb(void *userdata,
write_avail = io_data->mBuffers[0].mDataByteSize;
outbuf = io_data->mBuffers[0].mData;
pthread_mutex_lock(&dev->lock);
slock_lock(dev->lock);
if (fifo_read_avail(dev->buffer) < write_avail)
{
@ -118,16 +118,16 @@ static OSStatus audio_write_cb(void *userdata,
/* Seems to be needed. */
memset(outbuf, 0, write_avail);
pthread_mutex_unlock(&dev->lock);
slock_unlock(dev->lock);
/* Technically possible to deadlock without. */
pthread_cond_signal(&dev->cond);
scond_signal(dev->cond);
return noErr;
}
fifo_read(dev->buffer, outbuf, write_avail);
pthread_mutex_unlock(&dev->lock);
pthread_cond_signal(&dev->cond);
slock_unlock(dev->lock);
scond_signal(dev->cond);
return noErr;
}
@ -218,8 +218,8 @@ static void *coreaudio_init(const char *device,
if (!dev)
return NULL;
pthread_mutex_init(&dev->lock, NULL);
pthread_cond_init(&dev->cond, NULL);
dev->lock = slock_new();
dev->cond = scond_new();
#if TARGET_OS_IPHONE
if (!session_initialized)
@ -343,22 +343,11 @@ static ssize_t coreaudio_write(void *data, const void *buf_, size_t size)
const uint8_t *buf = (const uint8_t*)buf_;
size_t written = 0;
#if TARGET_OS_IPHONE
struct timespec timeout;
struct timeval time;
gettimeofday(&time, 0);
memset(&timeout, 0, sizeof(timeout));
timeout.tv_sec = time.tv_sec + 3;
timeout.tv_nsec = time.tv_usec * 1000;
#endif
while (!g_interrupted && size > 0)
{
size_t write_avail;
pthread_mutex_lock(&dev->lock);
slock_lock(dev->lock);
write_avail = fifo_write_avail(dev->buffer);
if (write_avail > size)
@ -371,19 +360,19 @@ static ssize_t coreaudio_write(void *data, const void *buf_, size_t size)
if (dev->nonblock)
{
pthread_mutex_unlock(&dev->lock);
slock_unlock(dev->lock);
break;
}
#if TARGET_OS_IPHONE
if (write_avail == 0 && pthread_cond_timedwait(
&dev->cond, &dev->lock, &timeout) == ETIMEDOUT)
if (write_avail == 0 && !scond_wait_timeout(
dev->cond, dev->lock, 3000000))
g_interrupted = true;
#else
if (write_avail == 0)
pthread_cond_wait(&dev->cond, &dev->lock);
scond_wait(dev->cond, dev->lock);
#endif
pthread_mutex_unlock(&dev->lock);
slock_unlock(dev->lock);
}
return written;
@ -433,9 +422,9 @@ static size_t coreaudio_write_avail(void *data)
size_t avail;
coreaudio_t *dev = (coreaudio_t*)data;
pthread_mutex_lock(&dev->lock);
slock_lock(dev->lock);
avail = fifo_write_avail(dev->buffer);
pthread_mutex_unlock(&dev->lock);
slock_unlock(dev->lock);
return avail;
}

View File

@ -34,7 +34,6 @@ typedef struct
uint64_t cpu_ticks_last;
int rate;
} ctr_audio_t;
#define CTR_AUDIO_COUNT (1u << 11u)
@ -44,17 +43,15 @@ typedef struct
static void *ctr_audio_init(const char *device, unsigned rate, unsigned latency)
{
ctr_audio_t *ctr = (ctr_audio_t*)calloc(1, sizeof(ctr_audio_t));
if (!ctr)
return NULL;
(void)device;
(void)rate;
(void)latency;
// if(!csndInit())
// return NULL;
ctr_audio_t *ctr = (ctr_audio_t*)calloc(1, sizeof(ctr_audio_t));
ctr->l = linearAlloc(CTR_AUDIO_SIZE);
ctr->r = linearAlloc(CTR_AUDIO_SIZE);
@ -100,19 +97,21 @@ static void ctr_audio_free(void *data)
static ssize_t ctr_audio_write(void *data, const void *buf, size_t size)
{
int i;
uint32_t samples_played;
uint64_t current_tick;
static struct retro_perf_counter ctraudio_f = {0};
const uint16_t *src = buf;
ctr_audio_t *ctr = (ctr_audio_t*)data;
(void)data;
(void)buf;
ctr_audio_t* ctr = (ctr_audio_t*)data;
rarch_perf_init(&ctraudio_f, "ctraudio_f");
retro_perf_start(&ctraudio_f);
int i;
const uint16_t* src = buf;
RARCH_PERFORMANCE_INIT(ctraudio_f);
RARCH_PERFORMANCE_START(ctraudio_f);
uint64_t current_tick = svcGetSystemTick();
uint32_t samples_played = (current_tick - ctr->cpu_ticks_last) / ctr->cpu_ticks_per_sample;
current_tick = svcGetSystemTick();
samples_played = (current_tick - ctr->cpu_ticks_last) / ctr->cpu_ticks_per_sample;
ctr->playpos = (ctr->playpos + samples_played) & CTR_AUDIO_COUNT_MASK;
ctr->cpu_ticks_last += samples_played * ctr->cpu_ticks_per_sample;
@ -127,7 +126,7 @@ static ssize_t ctr_audio_write(void *data, const void *buf, size_t size)
{
do{
/* todo: compute the correct sleep period */
rarch_sleep(1);
retro_sleep(1);
current_tick = svcGetSystemTick();
samples_played = (current_tick - ctr->cpu_ticks_last) / ctr->cpu_ticks_per_sample;
ctr->playpos = (ctr->playpos + samples_played) & CTR_AUDIO_COUNT_MASK;
@ -144,11 +143,11 @@ static ssize_t ctr_audio_write(void *data, const void *buf, size_t size)
ctr->pos++;
ctr->pos &= CTR_AUDIO_COUNT_MASK;
}
GSPGPU_FlushDataCache(NULL, (u8*)ctr->l, CTR_AUDIO_SIZE);
GSPGPU_FlushDataCache(NULL, (u8*)ctr->r, CTR_AUDIO_SIZE);
RARCH_PERFORMANCE_STOP(ctraudio_f);
retro_perf_stop(&ctraudio_f);
return size;
}
@ -160,8 +159,10 @@ static bool ctr_audio_stop(void *data)
/* using SetPlayState would make tracking the playback
* position more difficult */
// CSND_SetPlayState(0x8, 0);
// CSND_SetPlayState(0x9, 0);
#if 0
CSND_SetPlayState(0x8, 0);
CSND_SetPlayState(0x9, 0);
#endif
/* setting the channel volume to 0 seems to make it
* impossible to set it back to full volume later */
@ -186,14 +187,16 @@ static bool ctr_audio_start(void *data)
ctr_audio_t* ctr = (ctr_audio_t*)data;
rarch_system_info_t *system = rarch_system_info_get_ptr();
/* prevents restarting audio when the menu
/* Prevents restarting audio when the menu
* is toggled off on shutdown */
if (system->shutdown)
return true;
// CSND_SetPlayState(0x8, 1);
// CSND_SetPlayState(0x9, 1);
#if 0
CSND_SetPlayState(0x8, 1);
CSND_SetPlayState(0x9, 1);
#endif
CSND_SetVol(0x8, 0x00008000, 0);
CSND_SetVol(0x9, 0x80000000, 0);

View File

@ -166,7 +166,7 @@ static void dsound_thread(void *data)
* but it is not guaranteed to work, so use high
* priority sleeping patterns.
*/
rarch_sleep(1);
retro_sleep(1);
continue;
}

View File

@ -151,7 +151,7 @@ static bool al_get_buffer(al_t *al, ALuint *buffer)
return false;
/* Must sleep as there is no proper blocking method. */
rarch_sleep(1);
retro_sleep(1);
}
}

View File

@ -48,6 +48,13 @@ typedef struct psp_audio
#define AUDIO_BUFFER_SIZE (1u<<13u)
#define AUDIO_BUFFER_SIZE_MASK (AUDIO_BUFFER_SIZE-1)
#ifdef VITA
#define PSP_THREAD_STOPPED PSP2_THREAD_STOPPED
#else
#define SceKernelThreadInfo SceKernelThreadRunStatus
#define sceKernelGetThreadInfo sceKernelReferThreadRunStatus
#endif
static int audioMainLoop(SceSize args, void* argp)
{
psp_audio_t* psp = *((psp_audio_t**)argp);
@ -190,37 +197,22 @@ static bool psp_audio_alive(void *data)
return psp->running;
}
static bool psp_audio_stop(void *data)
{
SceKernelThreadInfo info;
SceUInt timeout = 100000;
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)
if (info.status == PSP_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);
@ -233,10 +225,8 @@ static bool psp_audio_stop(void *data)
static bool psp_audio_start(void *data)
{
psp_audio_t* psp = (psp_audio_t*)data;
#if defined(VITA)
SceKernelThreadInfo info;
psp_audio_t* psp = (psp_audio_t*)data;
info.size = sizeof(SceKernelThreadInfo);
@ -244,22 +234,9 @@ static bool psp_audio_start(void *data)
psp->thread, &info) < 0) /* Error */
return false;
if (info.status != PSP2_THREAD_STOPPED)
if (info.status != PSP_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 = true;
sceKernelStartThread(psp->thread, sizeof(psp_audio_t*), &psp);

View File

@ -334,7 +334,7 @@ static void process_sinc(rarch_sinc_resampler_t *resamp, float *out_buffer)
/* movehl { X, R, X, L } == { X, R, X, R } */
_mm_store_ss(out_buffer + 1, _mm_movehl_ps(sum, sum));
}
#elif defined(__ARM_NEON__)
#elif defined(__ARM_NEON__) && !defined(VITA)
#if SINC_COEFF_LERP
#error "NEON asm does not support SINC lerp."
@ -437,7 +437,7 @@ static void *resampler_sinc_new(const struct resampler_config *config,
}
/* Be SIMD-friendly. */
#if (defined(__AVX__) && ENABLE_AVX) || defined(__ARM_NEON__)
#if (defined(__AVX__) && ENABLE_AVX) || (defined(__ARM_NEON__)&& !defined(VITA))
re->taps = (re->taps + 7) & ~7;
#else
re->taps = (re->taps + 3) & ~3;
@ -460,7 +460,7 @@ static void *resampler_sinc_new(const struct resampler_config *config,
init_sinc_table(re, cutoff, re->phase_table,
1 << PHASE_BITS, re->taps, SINC_COEFF_LERP);
#if defined(__ARM_NEON__)
#if defined(__ARM_NEON__) && !defined(VITA)
process_sinc_func = mask & RESAMPLER_SIMD_NEON
? process_sinc_neon : process_sinc_C;
#endif
@ -480,4 +480,3 @@ rarch_resampler_t sinc_resampler = {
"sinc",
"sinc"
};

View File

@ -153,7 +153,6 @@ static int rsnd_send_info_query(rsound_t *rd);
static int rsnd_update_server_info(rsound_t *rd);
static int rsnd_poll(struct pollfd *fd, int numfd, int timeout);
static void rsnd_sleep(int msec);
static void rsnd_cb_thread(void *thread_data);
static void rsnd_thread(void *thread_data);
@ -363,12 +362,12 @@ static int rsnd_send_header_info(rsound_t *rd)
#define LSB16(x) if ( !rsnd_is_little_endian() ) { rsnd_swap_endian_16(&(x)); }
#define LSB32(x) if ( !rsnd_is_little_endian() ) { rsnd_swap_endian_32(&(x)); }
// Here we embed in the rest of the WAV header for it to be somewhat valid
/* Here we embed in the rest of the WAV header for it to be somewhat valid */
strcpy(header, "RIFF");
strlcpy(header, "RIFF", sizeof(header));
SET32(header, 4, 0);
strcpy(header+8, "WAVE");
strcpy(header+12, "fmt ");
strlcpy(header+8, "WAVE", sizeof(header));
strlcpy(header+12, "fmt ", sizeof(header));
temp32 = 16;
LSB32(temp32);
@ -414,15 +413,15 @@ static int rsnd_send_header_info(rsound_t *rd)
LSB16(temp_bits);
SET16(header, FRAMESIZE, temp_bits);
strcpy(header+36, "data");
strlcpy(header+36, "data", sizeof(header));
// Do not care about cksize here (impossible to know beforehand). It is used by
// the server for format.
/* Do not care about cksize here (impossible to know beforehand).
* It is used by the server for format. */
LSB16(temp_format);
SET16(header, FORMAT, temp_format);
// End static header
/* End static header */
if ( rsnd_send_chunk(rd->conn.socket, header, HEADER_SIZE, 1) != HEADER_SIZE )
{
@ -748,12 +747,6 @@ static int64_t rsnd_get_time_usec(void)
#endif
}
static void rsnd_sleep(int msec)
{
rarch_sleep(msec);
}
/* Calculates how many bytes there are in total in the virtual buffer. This is calculated client side.
It should be accurate enough unless we have big problems with buffer underruns.
This function is called by rsd_delay() to determine the latency.
@ -1246,7 +1239,7 @@ static void rsnd_cb_thread(void *thread_data)
// The network might do things in large chunks, so it may request large amounts of data in short periods of time.
// This breaks when the caller cannot buffer up big buffers beforehand, so do short sleeps inbetween.
// This is somewhat dirty, but I cannot see a better solution
rsnd_sleep(1);
retro_sleep(1);
}
}
}
@ -1513,7 +1506,7 @@ void rsd_delay_wait(rsound_t *rd)
{
int64_t sleep_ms = latency_ms - rd->max_latency;
RSD_DEBUG("[RSound] Delay wait: %d ms.\n", (int)sleep_ms);
rsnd_sleep((int)sleep_ms);
retro_sleep((int)sleep_ms);
}
}
}

View File

@ -23,6 +23,7 @@ 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/retro_file.o \
$(LIBRETRO_COMM_DIR)/file/file_path.o \
$(LIBRETRO_COMM_DIR)/compat/compat.o \
$(LIBRETRO_COMM_DIR)/hash/rhash.o \

View File

@ -21,7 +21,7 @@ include $(PSPSDK)/lib/build.mak
all:
psp-build-exports -s $(PRX_EXPORTS)
cp $(TARGET).prx ../../$(TARGET).prx
cp $(TARGET).prx ../../../$(TARGET).prx
cp $(TARGET).S ../$(TARGET).S
cp $(TARGET).h ../$(TARGET).h
rm -f $(TARGET).prx

View File

@ -8,6 +8,7 @@ extern "C" {
#endif
unsigned int read_system_buttons(void);
void exitspawn_kernel( const char* fileName, SceSize args, void * argp);
#ifdef __cplusplus

View File

@ -1,16 +1,15 @@
#include <stdio.h>
#include <string.h>
#include <pspdebug.h>
#include <pspsdk.h>
#include <pspctrl.h>
#include <psploadexec_kernel.h>
#include <pspthreadman_kernel.h>
#include <string.h>
PSP_MODULE_INFO("kernel_functions", PSP_MODULE_KERNEL, 0, 0);
PSP_MAIN_THREAD_ATTR(0);
static volatile int thread_active;
static unsigned int buttons;
static SceUID main_thread_id;
@ -33,16 +32,17 @@ static int main_thread(SceSize args, void *argp)
return 0;
}
unsigned int read_system_buttons(void)
{
return buttons;
}
void exitspawn_kernel( const char* fileName, SceSize args, void * argp){
thread_active = 0;
void exitspawn_kernel(const char *fileName, SceSize args, void *argp)
{
struct SceKernelLoadExecVSHParam game_param;
thread_active = 0;
memset(&game_param,0,sizeof(game_param));
game_param.size = sizeof(game_param);
@ -75,7 +75,6 @@ int module_start(SceSize args, void *argp)
return 0;
}
int module_stop(void)
{
if (main_thread_id >= 0)

View File

@ -24,7 +24,6 @@
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
@ -35,6 +34,7 @@
#include <memmap.h>
#include <retro_miscellaneous.h>
#include <gfx/scaler/scaler.h>
#include <retro_stat.h>
#include <compat/strl.h>
@ -63,13 +63,14 @@ typedef struct video4linux
char dev_name[PATH_MAX_LENGTH];
} video4linux_t;
static void process_image(video4linux_t *v4l,
const uint8_t *buffer_yuv)
static void process_image(video4linux_t *v4l, const uint8_t *buffer_yuv)
{
RARCH_PERFORMANCE_INIT(yuv_convert_direct);
RARCH_PERFORMANCE_START(yuv_convert_direct);
static struct retro_perf_counter yuv_convert_direct = {0};
rarch_perf_init(&yuv_convert_direct, "yuv_convert_direct");
retro_perf_start(&yuv_convert_direct);
scaler_ctx_scale(&v4l->scaler, v4l->buffer_output, buffer_yuv);
RARCH_PERFORMANCE_STOP(yuv_convert_direct);
retro_perf_stop(&yuv_convert_direct);
}
static int xioctl(int fd, int request, void *args)
@ -95,7 +96,7 @@ static bool init_mmap(void *data)
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
req.memory = V4L2_MEMORY_MMAP;
if (xioctl(v4l->fd, VIDIOC_REQBUFS, &req) == -1)
if (xioctl(v4l->fd, (uint8_t)VIDIOC_REQBUFS, &req) == -1)
{
if (errno == EINVAL)
RARCH_ERR("%s does not support memory mapping.\n", v4l->dev_name);
@ -128,7 +129,7 @@ static bool init_mmap(void *data)
buf.memory = V4L2_MEMORY_MMAP;
buf.index = v4l->n_buffers;
if (xioctl(v4l->fd, VIDIOC_QUERYBUF, &buf) == -1)
if (xioctl(v4l->fd, (uint8_t)VIDIOC_QUERYBUF, &buf) == -1)
{
RARCH_ERR("Error - xioctl VIDIOC_QUERYBUF.\n");
return false;
@ -158,7 +159,7 @@ static bool init_device(void *data)
struct v4l2_format fmt;
video4linux_t *v4l = (video4linux_t*)data;
if (xioctl(v4l->fd, VIDIOC_QUERYCAP, &cap) < 0)
if (xioctl(v4l->fd, (uint8_t)VIDIOC_QUERYCAP, &cap) < 0)
{
if (errno == EINVAL)
RARCH_ERR("%s is no V4L2 device.\n", v4l->dev_name);
@ -183,7 +184,7 @@ static bool init_device(void *data)
memset(&cropcap, 0, sizeof(cropcap));
cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (xioctl(v4l->fd, VIDIOC_CROPCAP, &cropcap) == 0)
if (xioctl(v4l->fd, (uint8_t)VIDIOC_CROPCAP, &cropcap) == 0)
{
crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
crop.c = cropcap.defrect;
@ -199,7 +200,7 @@ static bool init_device(void *data)
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
fmt.fmt.pix.field = V4L2_FIELD_NONE;
if (xioctl(v4l->fd, VIDIOC_S_FMT, &fmt) < 0)
if (xioctl(v4l->fd, (uint8_t)VIDIOC_S_FMT, &fmt) < 0)
{
RARCH_ERR("Error - VIDIOC_S_FMT\n");
return false;
@ -259,7 +260,7 @@ static bool v4l_start(void *data)
buf.memory = V4L2_MEMORY_MMAP;
buf.index = i;
if (xioctl(v4l->fd, VIDIOC_QBUF, &buf) == -1)
if (xioctl(v4l->fd, (uint8_t)VIDIOC_QBUF, &buf) == -1)
{
RARCH_ERR("Error - VIDIOC_QBUF.\n");
return false;
@ -299,7 +300,6 @@ static void v4l_free(void *data)
static void *v4l_init(const char *device, uint64_t caps,
unsigned width, unsigned height)
{
struct stat st;
video4linux_t *v4l = NULL;
if ((caps & (UINT64_C(1) << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER)) == 0)
@ -319,14 +319,7 @@ static void *v4l_init(const char *device, uint64_t caps,
v4l->height = height;
v4l->ready = false;
if (stat(v4l->dev_name, &st) == -1)
{
RARCH_ERR("Cannot identify '%s' : %d, %s\n", v4l->dev_name,
errno, strerror(errno));
goto error;
}
if (!S_ISCHR(st.st_mode))
if (!path_is_character_special(v4l->dev_name))
{
RARCH_ERR("%s is no device.\n", v4l->dev_name);
goto error;
@ -384,7 +377,7 @@ static bool preprocess_image(void *data)
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
if (xioctl(v4l->fd, VIDIOC_DQBUF, &buf) == -1)
if (xioctl(v4l->fd, (uint8_t)VIDIOC_DQBUF, &buf) == -1)
{
switch (errno)
{
@ -400,7 +393,7 @@ static bool preprocess_image(void *data)
process_image(v4l, (const uint8_t*)v4l->buffers[buf.index].start);
if (xioctl(v4l->fd, VIDIOC_QBUF, &buf) == -1)
if (xioctl(v4l->fd, (uint8_t)VIDIOC_QBUF, &buf) == -1)
RARCH_ERR("VIDIOC_QBUF\n");
return true;

View File

@ -19,7 +19,6 @@
#include <string.h>
#ifndef _WIN32
#include <fcntl.h>
#include <unistd.h>
#endif

View File

@ -20,6 +20,7 @@
#include <file/file_path.h>
#include <compat/strl.h>
#include <compat/posix_string.h>
#include <retro_stat.h>
#include "config.def.h"
#include "input/input_common.h"
@ -1630,6 +1631,7 @@ static bool config_load_file(const char *path, bool set_defaults)
CONFIG_GET_BOOL_BASE(conf, settings, network_cmd_enable, "network_cmd_enable");
CONFIG_GET_INT_BASE(conf, settings, network_cmd_port, "network_cmd_port");
CONFIG_GET_BOOL_BASE(conf, settings, stdin_cmd_enable, "stdin_cmd_enable");
CONFIG_GET_BOOL_BASE(conf, settings, debug_panel_enable, "debug_panel_enable");
CONFIG_GET_PATH_BASE(conf, settings, content_history_directory, "content_history_dir");

View File

@ -326,6 +326,7 @@ typedef struct settings
bool network_cmd_enable;
unsigned network_cmd_port;
bool stdin_cmd_enable;
bool debug_panel_enable;
char core_assets_directory[PATH_MAX_LENGTH];
char assets_directory[PATH_MAX_LENGTH];

View File

@ -33,6 +33,8 @@
#include <compat/strl.h>
#include <file/file_path.h>
#include <file/file_extract.h>
#include <retro_file.h>
#include <retro_stat.h>
#include "msg_hash.h"
#include "content.h"
@ -118,7 +120,7 @@ static void dump_to_file_desperate(const void *data,
strftime(timebuf, sizeof(timebuf), "%Y-%m-%d-%H-%M-%S", localtime(&time_));
strlcat(path, timebuf, sizeof(path));
if (write_file(path, data, size))
if (retro_write_file(path, data, size))
RARCH_WARN("Succeeded in saving RAM data to \"%s\".\n", path);
else
goto error;
@ -169,7 +171,7 @@ bool save_state(const char *path)
ret = pretro_serialize(data, size);
if (ret)
ret = write_file(path, data, size);
ret = retro_write_file(path, data, size);
if (!ret)
RARCH_ERR("%s \"%s\".\n",
@ -332,7 +334,7 @@ void save_ram_file(const char *path, int type)
if (size <= 0)
return;
if (!write_file(path, data, size))
if (!retro_write_file(path, data, size))
{
RARCH_ERR("%s.\n",
msg_hash_to_str(MSG_FAILED_TO_SAVE_SRAM));

View File

@ -460,11 +460,13 @@ bool core_info_does_support_file(const core_info_t *core, const char *path)
core->supported_extensions_list, ".", path_get_extension(path));
}
const char *core_info_list_get_all_extensions(core_info_list_t *core_info_list)
const char *core_info_list_get_all_extensions(void)
{
if (!core_info_list)
return "";
return core_info_list->all_ext;
global_t *global = global_get_ptr();
core_info_list_t *list = (global->core_info.list) ? global->core_info.list : NULL;
if (!list)
return NULL;
return list->all_ext;
}
/* qsort_r() is not in standard C, sadly. */

View File

@ -99,7 +99,7 @@ void core_info_list_update_missing_firmware(core_info_list_t *list,
bool core_info_list_get_info(core_info_list_t *list,
core_info_t *info, const char *path);
const char *core_info_list_get_all_extensions(core_info_list_t *list);
const char *core_info_list_get_all_extensions(void);
bool core_info_list_get_display_name(core_info_list_t *list,
const char *path, char *buf, size_t size);

View File

@ -17,7 +17,7 @@
#define STBI_SUPPORT_ZLIB
#endif
#include "stb_image.h"
#include "../deps/stb/stb_image.h"
#ifdef RARCH_INTERNAL
#include "internal_cores.h"

View File

@ -131,4 +131,85 @@ else ifeq ($(LIBRETRO), snes9x_next)
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
else ifeq ($(LIBRETRO), mgba)
APP_TITLE = mGBA Libretro
#APP_DESCRIPTION = Retroarch 3DS
APP_AUTHOR = Jeffrey Pfau
APP_PRODUCT_CODE = RARCH-MGBA
APP_UNIQUE_ID = 0xBAC0E
APP_ICON = ctr/mgba.png
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
else ifeq ($(LIBRETRO), quicknes)
APP_TITLE = QuickNES Libretro
#APP_DESCRIPTION = Retroarch 3DS
APP_AUTHOR = blargg, kode54
APP_PRODUCT_CODE = RARCH-QUICKNES
APP_UNIQUE_ID = 0xBAC0F
APP_ICON = ctr/quicknes.png
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
else ifeq ($(LIBRETRO), fb_alpha_neo)
APP_TITLE = Neo Geo (FB Alpha)
#APP_DESCRIPTION = Retroarch 3DS
APP_AUTHOR = Team FB Alpha
APP_PRODUCT_CODE = RARCH-FBANEOGEO
APP_UNIQUE_ID = 0xBAC10
APP_ICON = ctr/fb_alpha_neo.png
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
else ifeq ($(LIBRETRO), fb_alpha_cps1)
APP_TITLE = Final Burn Alpha - CPS-1
#APP_DESCRIPTION = Retroarch 3DS
APP_AUTHOR = Team FB Alpha
APP_PRODUCT_CODE = RARCH-FBACPS1
APP_UNIQUE_ID = 0xBAC11
APP_ICON = ctr/fb_alpha_cps1.png
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
else ifeq ($(LIBRETRO), fb_alpha_cps2)
APP_TITLE = Final Burn Alpha - CPS-2
#APP_DESCRIPTION = Retroarch 3DS
APP_AUTHOR = Team FB Alpha
APP_PRODUCT_CODE = RARCH-FBACPS2
APP_UNIQUE_ID = 0xBAC12
APP_ICON = ctr/fb_alpha_cps2.png
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
else ifeq ($(LIBRETRO), catsfc_plus)
APP_TITLE = CATSFC Plus Libretro
#APP_DESCRIPTION = Retroarch 3DS
#APP_AUTHOR = Team Libretro
APP_PRODUCT_CODE = RARCH-CATSFCPLUS
APP_UNIQUE_ID = 0xBAC13
APP_ICON = ctr/catsfc_plus.png
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
else ifeq ($(LIBRETRO), mednafen_pce_fast)
APP_TITLE = Mednafen/Beetle PCE FAST
#APP_DESCRIPTION = Retroarch 3DS
APP_AUTHOR = Ryphecha
APP_PRODUCT_CODE = RARCH-M-PCE-FAST
APP_UNIQUE_ID = 0xBAC14
APP_ICON = ctr/mednafen_pce_fast.png
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
else ifeq ($(LIBRETRO), pcsx_rearmed)
APP_TITLE = PCSX ReARMed
#APP_DESCRIPTION = Retroarch 3DS
APP_AUTHOR = PCSX Team, notaz, Exophase
APP_PRODUCT_CODE = RARCH-PCSXRARMD
APP_UNIQUE_ID = 0xBAC15
APP_ICON = ctr/pcsx_rearmed.png
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
BUILD_3DSX = 0
endif

BIN
ctr/catsfc_plus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
ctr/fb_alpha_cps1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
ctr/fb_alpha_cps2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
ctr/fb_alpha_neo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
ctr/mednafen_pce_fast.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
ctr/pcsx_rearmed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 668 B

BIN
ctr/quicknes.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

View File

@ -1,7 +1,7 @@
BasicInfo:
Title : "{APP_TITLE}"
Title : "$(APP_TITLE)"
CompanyCode : "00"
ProductCode : "{APP_PRODUCT_CODE}"
ProductCode : "$(APP_PRODUCT_CODE)"
ContentType : Application
Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem
@ -9,9 +9,8 @@ BasicInfo:
# Specifies the root path of the file system to include in the ROM.
# HostRoot : "romfs"
TitleInfo:
UniqueId : {APP_UNIQUE_ID}
UniqueId : $(APP_UNIQUE_ID)
Category : Application
CardInfo:

View File

@ -1,7 +1,7 @@
BasicInfo:
Title : "{APP_TITLE}"
Title : "$(APP_TITLE)"
CompanyCode : "00"
ProductCode : "{APP_PRODUCT_CODE}"
ProductCode : "$(APP_PRODUCT_CODE)"
ContentType : Application
Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem
@ -10,7 +10,7 @@ BasicInfo:
# HostRoot : "romfs"
TitleInfo:
UniqueId : {APP_UNIQUE_ID}
UniqueId : $(APP_UNIQUE_ID)
Category : Application
CardInfo:
@ -90,6 +90,7 @@ AccessControlInfo:
Priority : 16
MaxCpu : 0x9E # Default
CpuSpeed : 804mhz
DisableDebug : false
EnableForceDebug : false

View File

@ -201,7 +201,7 @@ int database_info_build_query(char *s, size_t len,
return 0;
}
static char *bin_to_hex_alloc(const uint8_t *data, size_t len)
char *bin_to_hex_alloc(const uint8_t *data, size_t len)
{
size_t i;
char *ret = (char*)malloc(len * 2 + 1);
@ -447,15 +447,18 @@ void database_info_free(database_info_handle_t *db)
database_info_list_t *database_info_list_new(
const char *rdb_path, const char *query)
{
libretrodb_t db;
libretrodb_cursor_t cur;
int ret = 0;
unsigned k = 0;
database_info_t *database_info = NULL;
database_info_list_t *database_info_list = NULL;
libretrodb_t *db = libretrodb_new();
libretrodb_cursor_t *cur = libretrodb_cursor_new();
if ((database_cursor_open(&db, &cur, rdb_path, query) != 0))
return NULL;
if (!db || !cur)
goto end;
if ((database_cursor_open(db, cur, rdb_path, query) != 0))
goto end;
database_info_list = (database_info_list_t*)
calloc(1, sizeof(*database_info_list));
@ -466,7 +469,7 @@ database_info_list_t *database_info_list_new(
while (ret != -1)
{
database_info_t db_info = {0};
ret = database_cursor_iterate(&cur, &db_info);
ret = database_cursor_iterate(cur, &db_info);
if (ret == 0)
{
@ -496,7 +499,12 @@ database_info_list_t *database_info_list_new(
database_info_list->count = k;
end:
database_cursor_close(&db, &cur);
database_cursor_close(db, cur);
if (db)
libretrodb_free(db);
if (cur)
libretrodb_cursor_free(cur);
return database_info_list;
}

View File

@ -44,6 +44,7 @@ enum database_type
DATABASE_TYPE_NONE = 0,
DATABASE_TYPE_ITERATE,
DATABASE_TYPE_ITERATE_ZIP,
DATABASE_TYPE_SERIAL_LOOKUP,
DATABASE_TYPE_CRC_LOOKUP
};
@ -112,6 +113,8 @@ void database_info_free(database_info_handle_t *handle);
int database_info_build_query(
char *query, size_t len, const char *label, const char *path);
char *bin_to_hex_alloc(const uint8_t *data, size_t len);
#ifdef __cplusplus
}
#endif

View File

@ -386,14 +386,13 @@ License:
#ifndef STBI_NO_STDIO
#include <stdio.h>
#endif // STBI_NO_STDIO
#endif /* STBI_NO_STDIO */
#define STBI_VERSION 1
enum
{
STBI_default = 0, // only used for req_comp
STBI_default = 0, /* only used for req_comp */
STBI_grey = 1,
STBI_grey_alpha = 2,
STBI_rgb = 3,
@ -417,15 +416,13 @@ extern "C" {
// PRIMARY API - works on images of any type
//
//
// load image by filename, open file, or memory buffer
//
/* load image by filename, open file, or memory buffer */
typedef struct
{
int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read
void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative
int (*eof) (void *user); // returns nonzero if we are at end of file/data
int (*read) (void *user,char *data,int size); /* fill 'data' with 'size' bytes. return number of bytes actually read */
void (*skip) (void *user,int n); /* skip the next 'n' bytes, or 'unget' the last -n bytes if negative */
int (*eof) (void *user); /* returns nonzero if we are at end of file/data */
} stbi_io_callbacks;
STBIDEF stbi_uc *stbi_load (char const *filename, int *x, int *y, int *comp, int req_comp);
@ -434,7 +431,7 @@ STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk , void
#ifndef STBI_NO_STDIO
STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp);
// for stbi_load_from_file, file pointer is left pointing immediately after image
/* for stbi_load_from_file, file pointer is left pointing immediately after image */
#endif
#ifndef STBI_NO_LINEAR
@ -455,25 +452,25 @@ STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y,
#ifndef STBI_NO_LINEAR
STBIDEF void stbi_ldr_to_hdr_gamma(float gamma);
STBIDEF void stbi_ldr_to_hdr_scale(float scale);
#endif // STBI_NO_HDR
#endif /* STBI_NO_HDR */
// stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR
/* stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR */
STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user);
STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len);
#ifndef STBI_NO_STDIO
STBIDEF int stbi_is_hdr (char const *filename);
STBIDEF int stbi_is_hdr_from_file(FILE *f);
#endif // STBI_NO_STDIO
#endif /* STBI_NO_STDIO */
// get a VERY brief reason for failure
// NOT THREADSAFE
/* get a VERY brief reason for failure
* NOT THREADSAFE */
STBIDEF const char *stbi_failure_reason (void);
// free the loaded image -- this is just free()
/* free the loaded image -- this is just free() */
STBIDEF void stbi_image_free (void *retval_from_stbi_load);
// get image dimensions & components without fully decoding
/* get image dimensions & components without fully decoding */
STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp);
STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp);
@ -483,8 +480,6 @@ STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y,
#endif
// for image formats that explicitly notate that they have premultiplied alpha,
// we just return the colors as stored in the file. set this flag to force
// unpremultiplication. results are undefined if the unpremultiply overflow.
@ -494,10 +489,10 @@ STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultipl
// or just pass them through "as-is"
STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert);
// flip the image vertically, so the first pixel in the output array is the bottom left
/* flip the image vertically, so the first pixel in the output array is the bottom left */
STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip);
// ZLIB client - used by PNG, available for other purposes
/* ZLIB client - used by PNG, available for other purposes */
STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen);
STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header);
@ -512,10 +507,8 @@ STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const ch
}
#endif
//
//
//// end header file /////////////////////////////////////////////////////
#endif // STBI_INCLUDE_STB_IMAGE_H
#endif /* STBI_INCLUDE_STB_IMAGE_H */
#ifdef STB_IMAGE_IMPLEMENTATION
@ -558,12 +551,12 @@ STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const ch
#include <stdarg.h>
#include <stddef.h> // ptrdiff_t on osx
#include <stddef.h> /* ptrdiff_t on osx */
#include <stdlib.h>
#include <string.h>
#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR)
#include <math.h> // ldexp
#include <math.h> /* ldexp */
#endif
#ifndef STBI_NO_STDIO
@ -600,7 +593,7 @@ typedef uint32_t stbi__uint32;
typedef int32_t stbi__int32;
#endif
// should produce compiler error if size is wrong
/* should produce compiler error if size is wrong */
typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1];
#ifdef _MSC_VER
@ -641,26 +634,28 @@ typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1];
#endif
#if defined(__GNUC__) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) && !defined(__SSE2__) && !defined(STBI_NO_SIMD)
// NOTE: not clear do we actually need this for the 64-bit path?
// gcc doesn't support sse2 intrinsics unless you compile with -msse2,
// (but compiling with -msse2 allows the compiler to use SSE2 everywhere;
// this is just broken and gcc are jerks for not fixing it properly
// http://www.virtualdub.org/blog/pivot/entry.php?id=363 )
/* NOTE: not clear do we actually need this for the 64-bit path?
* gcc doesn't support sse2 intrinsics unless you compile with -msse2,
* (but compiling with -msse2 allows the compiler to use SSE2 everywhere;
* this is just broken and gcc are jerks for not fixing it properly
* http://www.virtualdub.org/blog/pivot/entry.php?id=363 )
*/
#define STBI_NO_SIMD
#endif
#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD)
// Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET
//
// 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the
// Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant.
// As a result, enabling SSE2 on 32-bit MinGW is dangerous when not
// simultaneously enabling "-mstackrealign".
//
// See https://github.com/nothings/stb/issues/81 for more information.
//
// So default to no SSE2 on 32-bit MinGW. If you've read this far and added
// -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2.
/* Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET
*
* 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the
* Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant.
* As a result, enabling SSE2 on 32-bit MinGW is dangerous when not
* simultaneously enabling "-mstackrealign".
*
* See https://github.com/nothings/stb/issues/81 for more information.
*
* So default to no SSE2 on 32-bit MinGW. If you've read this far and added
* -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2.
*/
#define STBI_NO_SIMD
#endif
@ -670,8 +665,8 @@ typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1];
#ifdef _MSC_VER
#if _MSC_VER >= 1400 // not VC6
#include <intrin.h> // __cpuid
#if _MSC_VER >= 1400 /* not VC6 */
#include <intrin.h> /* __cpuid */
static int stbi__cpuid3(void)
{
int info[4];
@ -698,31 +693,31 @@ static int stbi__sse2_available()
int info3 = stbi__cpuid3();
return ((info3 >> 26) & 1) != 0;
}
#else // assume GCC-style if not VC++
#else /* assume GCC-style if not VC++ */
#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16)))
static int stbi__sse2_available()
{
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 // GCC 4.8 or later
// GCC 4.8+ has a nice way to do this
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 /* GCC 4.8 or later */
/* GCC 4.8+ has a nice way to do this */
return __builtin_cpu_supports("sse2");
#else
// portable way to do this, preferably without using GCC inline ASM?
// just bail for now.
/* portable way to do this, preferably without using GCC inline ASM?
* just bail for now. */
return 0;
#endif
}
#endif
#endif
// ARM NEON
/* ARM NEON */
#if defined(STBI_NO_SIMD) && defined(STBI_NEON)
#undef STBI_NEON
#endif
#ifdef STBI_NEON
#include <arm_neon.h>
// assume GCC or Clang on ARM targets
/* assume GCC or Clang on ARM targets */
#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16)))
#endif
@ -804,15 +799,14 @@ static void stbi__start_file(stbi__context *s, FILE *f)
stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f);
}
//static void stop_file(stbi__context *s) { }
#endif // !STBI_NO_STDIO
#endif /* !STBI_NO_STDIO */
static void stbi__rewind(stbi__context *s)
{
// conceptually rewind SHOULD rewind to the beginning of the stream,
// but we just rewind to the beginning of the initial buffer, because
// we only use it after doing 'test', which only ever looks at at most 92 bytes
/* conceptually rewind SHOULD rewind to the beginning of the stream,
* but we just rewind to the beginning of the initial buffer, because
* we only use it after doing 'test', which only ever looks at at most 92 bytes
*/
s->img_buffer = s->img_buffer_original;
}
@ -1045,12 +1039,12 @@ STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req
stbi__start_file(&s,f);
result = stbi__load_flip(&s,x,y,comp,req_comp);
if (result) {
// need to 'unget' all the characters in the IO buffer
/* need to 'unget' all the characters in the IO buffer */
fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR);
}
return result;
}
#endif //!STBI_NO_STDIO
#endif /* !STBI_NO_STDIO */
STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp)
{
@ -2009,20 +2003,22 @@ static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64])
}
#ifdef STBI_SSE2
// sse2 integer IDCT. not the fastest possible implementation but it
// produces bit-identical results to the generic C version so it's
// fully "transparent".
/* sse2 integer IDCT. not the fastest possible implementation but it
* produces bit-identical results to the generic C version so it's
* fully "transparent".
*/
static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
{
// This is constructed to match our regular (generic) integer IDCT exactly.
/* This is constructed to match our regular (generic) integer IDCT exactly. */
__m128i row0, row1, row2, row3, row4, row5, row6, row7;
__m128i tmp;
// dot product constant: even elems=x, odd elems=y
/* dot product constant: even elems=x, odd elems=y */
#define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y))
// out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit)
// out(1) = c1[even]*x + c1[odd]*y
/* out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit)
* out(1) = c1[even]*x + c1[odd]*y
*/
#define dct_rot(out0,out1, x,y,c0,c1) \
__m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \
__m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \
@ -2031,22 +2027,22 @@ static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
__m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \
__m128i out1##_h = _mm_madd_epi16(c0##hi, c1)
// out = in << 12 (in 16-bit, out 32-bit)
/* out = in << 12 (in 16-bit, out 32-bit) */
#define dct_widen(out, in) \
__m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \
__m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4)
// wide add
/* wide add */
#define dct_wadd(out, a, b) \
__m128i out##_l = _mm_add_epi32(a##_l, b##_l); \
__m128i out##_h = _mm_add_epi32(a##_h, b##_h)
// wide sub
/* wide sub */
#define dct_wsub(out, a, b) \
__m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \
__m128i out##_h = _mm_sub_epi32(a##_h, b##_h)
// butterfly a/b, add bias, then shift by "s" and pack
/* butterfly a/b, add bias, then shift by "s" and pack */
#define dct_bfly32o(out0, out1, a,b,bias,s) \
{ \
__m128i abiased_l = _mm_add_epi32(a##_l, bias); \
@ -2057,13 +2053,13 @@ static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \
}
// 8-bit interleave step (for transposes)
/* 8-bit interleave step (for transposes) */
#define dct_interleave8(a, b) \
tmp = a; \
a = _mm_unpacklo_epi8(a, b); \
b = _mm_unpackhi_epi8(tmp, b)
// 16-bit interleave step (for transposes)
/* 16-bit interleave step (for transposes) */
#define dct_interleave16(a, b) \
tmp = a; \
a = _mm_unpacklo_epi16(a, b); \
@ -2106,11 +2102,11 @@ static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
__m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f));
__m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f));
// rounding biases in column/row passes, see stbi__idct_block for explanation.
/* rounding biases in column/row passes, see stbi__idct_block for explanation. */
__m128i bias_0 = _mm_set1_epi32(512);
__m128i bias_1 = _mm_set1_epi32(65536 + (128<<17));
// load
/* load */
row0 = _mm_load_si128((const __m128i *) (data + 0*8));
row1 = _mm_load_si128((const __m128i *) (data + 1*8));
row2 = _mm_load_si128((const __m128i *) (data + 2*8));
@ -2120,34 +2116,34 @@ static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
row6 = _mm_load_si128((const __m128i *) (data + 6*8));
row7 = _mm_load_si128((const __m128i *) (data + 7*8));
// column pass
/* column pass */
dct_pass(bias_0, 10);
{
// 16bit 8x8 transpose pass 1
/* 16bit 8x8 transpose pass 1 */
dct_interleave16(row0, row4);
dct_interleave16(row1, row5);
dct_interleave16(row2, row6);
dct_interleave16(row3, row7);
// transpose pass 2
/* transpose pass 2 */
dct_interleave16(row0, row2);
dct_interleave16(row1, row3);
dct_interleave16(row4, row6);
dct_interleave16(row5, row7);
// transpose pass 3
/* transpose pass 3 */
dct_interleave16(row0, row1);
dct_interleave16(row2, row3);
dct_interleave16(row4, row5);
dct_interleave16(row6, row7);
}
// row pass
/* row pass */
dct_pass(bias_1, 17);
{
// pack
/* pack */
__m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7
__m128i p1 = _mm_packus_epi16(row2, row3);
__m128i p2 = _mm_packus_epi16(row4, row5);
@ -2187,12 +2183,12 @@ static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
#undef dct_pass
}
#endif // STBI_SSE2
#endif /* STBI_SSE2 */
#ifdef STBI_NEON
// NEON integer IDCT. should produce bit-identical
// results to the generic C version.
/* NEON integer IDCT. should produce bit-identical
* results to the generic C version. */
static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
{
int16x8_t row0, row1, row2, row3, row4, row5, row6, row7;
@ -2222,12 +2218,12 @@ static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \
int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12)
// wide add
/* wide add */
#define dct_wadd(out, a, b) \
int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \
int32x4_t out##_h = vaddq_s32(a##_h, b##_h)
// wide sub
/* wide sub */
#define dct_wsub(out, a, b) \
int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \
int32x4_t out##_h = vsubq_s32(a##_h, b##_h)
@ -2335,7 +2331,7 @@ static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
dct_pass(vshrn_n_s32, 16);
{
// pack and round
/* pack and round */
uint8x8_t p0 = vqrshrun_n_s16(row0, 1);
uint8x8_t p1 = vqrshrun_n_s16(row1, 1);
uint8x8_t p2 = vqrshrun_n_s16(row2, 1);
@ -2345,33 +2341,33 @@ static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
uint8x8_t p6 = vqrshrun_n_s16(row6, 1);
uint8x8_t p7 = vqrshrun_n_s16(row7, 1);
// again, these can translate into one instruction, but often don't.
/* again, these can translate into one instruction, but often don't. */
#define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; }
#define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); }
#define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); }
// sadly can't use interleaved stores here since we only write
// 8 bytes to each scan line!
/* sadly can't use interleaved stores here since we only write
* 8 bytes to each scan line! */
// 8x8 8-bit transpose pass 1
/* 8x8 8-bit transpose pass 1 */
dct_trn8_8(p0, p1);
dct_trn8_8(p2, p3);
dct_trn8_8(p4, p5);
dct_trn8_8(p6, p7);
// pass 2
/* pass 2 */
dct_trn8_16(p0, p2);
dct_trn8_16(p1, p3);
dct_trn8_16(p4, p6);
dct_trn8_16(p5, p7);
// pass 3
/* pass 3 */
dct_trn8_32(p0, p4);
dct_trn8_32(p1, p5);
dct_trn8_32(p2, p6);
dct_trn8_32(p3, p7);
// store
/* store */
vst1_u8(out, p0); out += out_stride;
vst1_u8(out, p1); out += out_stride;
vst1_u8(out, p2); out += out_stride;
@ -2395,12 +2391,13 @@ static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
#undef dct_pass
}
#endif // STBI_NEON
#endif /* STBI_NEON */
#define STBI__MARKER_none 0xff
// if there's a pending marker from the entropy stream, return that
// otherwise, fetch from the stream and get a marker. if there's no
// marker, return 0xff, which is never a valid marker value
/* if there's a pending marker from the entropy stream, return that
* otherwise, fetch from the stream and get a marker. if there's no
* marker, return 0xff, which is never a valid marker value
*/
static stbi_uc stbi__get_marker(stbi__jpeg *j)
{
stbi_uc x;
@ -2412,12 +2409,14 @@ static stbi_uc stbi__get_marker(stbi__jpeg *j)
return x;
}
// in each scan, we'll have scan_n components, and the order
// of the components is specified by order[]
/* in each scan, we'll have scan_n components, and the order
* of the components is specified by order[]
*/
#define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7)
// after a restart interval, stbi__jpeg_reset the entropy decoder and
// the dc prediction
/* after a restart interval, stbi__jpeg_reset the entropy decoder and
* the dc prediction
*/
static void stbi__jpeg_reset(stbi__jpeg *j)
{
j->code_bits = 0;
@ -2918,7 +2917,7 @@ static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc
#if defined(STBI_SSE2) || defined(STBI_NEON)
static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
{
// need to generate 2x2 samples for every one in input
/* need to generate 2x2 samples for every one in input */
int i=0,t0,t1;
if (w == 1) {
@ -2927,13 +2926,15 @@ static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stb
}
t1 = 3*in_near[0] + in_far[0];
// process groups of 8 pixels for as long as we can.
// note we can't handle the last pixel in a row in this loop
// because we need to handle the filter boundary conditions.
for (; i < ((w-1) & ~7); i += 8) {
/* process groups of 8 pixels for as long as we can.
* note we can't handle the last pixel in a row in this loop
* because we need to handle the filter boundary conditions.
*/
for (; i < ((w-1) & ~7); i += 8)
{
#if defined(STBI_SSE2)
// load and perform the vertical filtering pass
// this uses 3*x + y = 4*x + (y - x)
/* load and perform the vertical filtering pass
* this uses 3*x + y = 4*x + (y - x) */
__m128i zero = _mm_setzero_si128();
__m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i));
__m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i));
@ -2941,22 +2942,23 @@ static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stb
__m128i nearw = _mm_unpacklo_epi8(nearb, zero);
__m128i diff = _mm_sub_epi16(farw, nearw);
__m128i nears = _mm_slli_epi16(nearw, 2);
__m128i curr = _mm_add_epi16(nears, diff); // current row
__m128i curr = _mm_add_epi16(nears, diff); /* current row */
// horizontal filter works the same based on shifted vers of current
// row. "prev" is current row shifted right by 1 pixel; we need to
// insert the previous pixel value (from t1).
// "next" is current row shifted left by 1 pixel, with first pixel
// of next block of 8 pixels added in.
/* horizontal filter works the same based on shifted vers of current
* row. "prev" is current row shifted right by 1 pixel; we need to
* insert the previous pixel value (from t1).
* "next" is current row shifted left by 1 pixel, with first pixel
* of next block of 8 pixels added in.
*/
__m128i prv0 = _mm_slli_si128(curr, 2);
__m128i nxt0 = _mm_srli_si128(curr, 2);
__m128i prev = _mm_insert_epi16(prv0, t1, 0);
__m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7);
// horizontal filter, polyphase implementation since it's convenient:
// even pixels = 3*cur + prev = cur*4 + (prev - cur)
// odd pixels = 3*cur + next = cur*4 + (next - cur)
// note the shared term.
/* horizontal filter, polyphase implementation since it's convenient:
* even pixels = 3*cur + prev = cur*4 + (prev - cur)
* odd pixels = 3*cur + next = cur*4 + (next - cur)
* note the shared term. */
__m128i bias = _mm_set1_epi16(8);
__m128i curs = _mm_slli_epi16(curr, 2);
__m128i prvd = _mm_sub_epi16(prev, curr);
@ -2965,13 +2967,13 @@ static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stb
__m128i even = _mm_add_epi16(prvd, curb);
__m128i odd = _mm_add_epi16(nxtd, curb);
// interleave even and odd pixels, then undo scaling.
/* interleave even and odd pixels, then undo scaling. */
__m128i int0 = _mm_unpacklo_epi16(even, odd);
__m128i int1 = _mm_unpackhi_epi16(even, odd);
__m128i de0 = _mm_srli_epi16(int0, 4);
__m128i de1 = _mm_srli_epi16(int1, 4);
// pack and write output
/* pack and write output */
__m128i outv = _mm_packus_epi16(de0, de1);
_mm_storeu_si128((__m128i *) (out + i*2), outv);
#elif defined(STBI_NEON)
@ -2993,24 +2995,25 @@ static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stb
int16x8_t prev = vsetq_lane_s16(t1, prv0, 0);
int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7);
// horizontal filter, polyphase implementation since it's convenient:
// even pixels = 3*cur + prev = cur*4 + (prev - cur)
// odd pixels = 3*cur + next = cur*4 + (next - cur)
// note the shared term.
/* horizontal filter, polyphase implementation since it's convenient:
* even pixels = 3*cur + prev = cur*4 + (prev - cur)
* odd pixels = 3*cur + next = cur*4 + (next - cur)
* note the shared term.
*/
int16x8_t curs = vshlq_n_s16(curr, 2);
int16x8_t prvd = vsubq_s16(prev, curr);
int16x8_t nxtd = vsubq_s16(next, curr);
int16x8_t even = vaddq_s16(curs, prvd);
int16x8_t odd = vaddq_s16(curs, nxtd);
// undo scaling and round, then store with even/odd phases interleaved
/* undo scaling and round, then store with even/odd phases interleaved */
uint8x8x2_t o;
o.val[0] = vqrshrun_n_s16(even, 4);
o.val[1] = vqrshrun_n_s16(odd, 4);
vst2_u8(out + i*2, o);
#endif
// "previous" value for next iter
/* "previous" value for next iteration */
t1 = 3*in_near[i+7] + in_far[i+7];
}
@ -3034,7 +3037,7 @@ static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stb
static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
{
// resample with nearest-neighbor
/* resample with nearest-neighbor */
int i,j;
STBI_NOTUSED(in_far);
for (i=0; i < w; ++i)
@ -3044,8 +3047,8 @@ static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_
}
#ifdef STBI_JPEG_OLD
// this is the same YCbCr-to-RGB calculation that stb_image has used
// historically before the algorithm changes in 1.49
/* this is the same YCbCr-to-RGB calculation that stb_image has used
* historically before the algorithm changes in 1.49 */
#define float2fixed(x) ((int) ((x) * 65536 + 0.5))
static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step)
{
@ -3072,14 +3075,14 @@ static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc
}
}
#else
// this is a reduced-precision calculation of YCbCr-to-RGB introduced
// to make sure the code produces the same results in both SIMD and scalar
/* this is a reduced-precision calculation of YCbCr-to-RGB introduced
* to make sure the code produces the same results in both SIMD and scalar */
#define float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8)
static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step)
{
int i;
for (i=0; i < count; ++i) {
int y_fixed = (y[i] << 20) + (1<<19); // rounding
int y_fixed = (y[i] << 20) + (1<<19); /* rounding */
int r,g,b;
int cr = pcr[i] - 128;
int cb = pcb[i] - 128;
@ -3107,20 +3110,23 @@ static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc cons
int i = 0;
#ifdef STBI_SSE2
// step == 3 is pretty ugly on the final interleave, and i'm not convinced
// it's useful in practice (you wouldn't use it for textures, for example).
// so just accelerate step == 4 case.
if (step == 4) {
// this is a fairly straightforward implementation and not super-optimized.
/* step == 3 is pretty ugly on the final interleave, and i'm not convinced
* it's useful in practice (you wouldn't use it for textures, for example).
* so just accelerate step == 4 case.
*/
if (step == 4)
{
/* this is a fairly straightforward implementation and not super-optimized. */
__m128i signflip = _mm_set1_epi8(-0x80);
__m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f));
__m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f));
__m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f));
__m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f));
__m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128);
__m128i xw = _mm_set1_epi16(255); // alpha channel
__m128i xw = _mm_set1_epi16(255); /* alpha channel */
for (; i+7 < count; i += 8) {
for (; i+7 < count; i += 8)
{
// load
__m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i));
__m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i));
@ -3236,7 +3242,7 @@ static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc cons
}
#endif
// set up the kernels
/* set up the kernels */
static void stbi__setup_jpeg(stbi__jpeg *j)
{
j->idct_block_kernel = stbi__idct_block;
@ -3262,7 +3268,7 @@ static void stbi__setup_jpeg(stbi__jpeg *j)
#endif
}
// clean up the temporary component buffers
/* clean up the temporary component buffers */
static void stbi__cleanup_jpeg(stbi__jpeg *j)
{
int i;
@ -5044,8 +5050,7 @@ static stbi_uc *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int
}
#endif
// *************************************************************************************************
// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB
/* Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB */
#ifndef STBI_NO_PSD
static int stbi__psd_test(stbi__context *s)
@ -5063,27 +5068,27 @@ static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int
int w,h;
stbi_uc *out;
// Check identifier
/* Check identifier */
if (stbi__get32be(s) != 0x38425053) // "8BPS"
return stbi__errpuc("not PSD", "Corrupt PSD image");
// Check file type version.
/* Check file type version. */
if (stbi__get16be(s) != 1)
return stbi__errpuc("wrong version", "Unsupported version of PSD image");
// Skip 6 reserved bytes.
/* Skip 6 reserved bytes. */
stbi__skip(s, 6 );
// Read the number of channels (R, G, B, A, etc).
/* Read the number of channels (R, G, B, A, etc). */
channelCount = stbi__get16be(s);
if (channelCount < 0 || channelCount > 16)
return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image");
// Read the rows and columns of the image.
/* Read the rows and columns of the image. */
h = stbi__get32be(s);
w = stbi__get32be(s);
// Make sure the depth is 8 bits.
/* Make sure the depth is 8 bits. */
if (stbi__get16be(s) != 8)
return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 bit");
@ -5100,13 +5105,13 @@ static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int
if (stbi__get16be(s) != 3)
return stbi__errpuc("wrong color format", "PSD is not in RGB color format");
// Skip the Mode Data. (It's the palette for indexed color; other info for other modes.)
/* Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) */
stbi__skip(s,stbi__get32be(s) );
// Skip the image resources. (resolution, pen tool paths, etc)
/* Skip the image resources. (resolution, pen tool paths, etc) */
stbi__skip(s, stbi__get32be(s) );
// Skip the reserved data.
/* Skip the reserved data. */
stbi__skip(s, stbi__get32be(s) );
// Find out if the data is compressed.
@ -5122,11 +5127,9 @@ static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int
if (!out) return stbi__errpuc("outofmem", "Out of memory");
pixelCount = w*h;
// Initialize the data to zero.
//memset( out, 0, pixelCount * 4 );
// Finally, the image data.
if (compression) {
/* Finally, the image data. */
if (compression)
{
// RLE as used by .PSD and .TIFF
// Loop until you get the number of unpacked bytes you are expecting:
// Read the next source byte into n.
@ -5135,8 +5138,8 @@ static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int
// Else if n is 128, noop.
// Endloop
// The RLE-compressed data is preceeded by a 2-byte data count for each row in the data,
// which we're going to just skip.
/* The RLE-compressed data is preceeded by a 2-byte data count
* for each row in the data, which we're going to just skip. */
stbi__skip(s, h * channelCount * 2 );
// Read the RLE data by channel.
@ -5216,12 +5219,13 @@ static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int
}
#endif
// *************************************************************************************************
// Softimage PIC loader
// by Tom Seddon
//
// See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format
// See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/
/* *************************************************************************************************
* Softimage PIC loader
* by Tom Seddon
*
* See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format
* See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/
*/
#ifndef STBI_NO_PIC
static int stbi__pic_is4(stbi__context *s,const char *str)
@ -5283,9 +5287,11 @@ static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *c
int act_comp=0,num_packets=0,y,chained;
stbi__pic_packet packets[10];
// this will (should...) cater for even some bizarre stuff like having data
// for the same channel in multiple packets.
do {
/* this will (should...) cater for even some bizarre stuff like having data
* for the same channel in multiple packets.
*/
do
{
stbi__pic_packet *packet;
if (num_packets==sizeof(packets)/sizeof(packets[0]))
@ -5304,7 +5310,7 @@ static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *c
if (packet->size != 8) return stbi__errpuc("bad format","packet isn't 8bpp");
} while (chained);
*comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel?
*comp = (act_comp & 0x10 ? 4 : 3); /* has alpha channel? */
for(y=0; y<height; ++y) {
int packet_idx;
@ -5402,15 +5408,16 @@ static stbi_uc *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int re
if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)");
if ((1 << 28) / x < y) return stbi__errpuc("too large", "Image too large to decode");
stbi__get32be(s); //skip `ratio'
stbi__get16be(s); //skip `fields'
stbi__get16be(s); //skip `pad'
stbi__get32be(s); /* skip `ratio' */
stbi__get16be(s); /* skip `fields' */
stbi__get16be(s); /* skip `pad' */
// intermediate buffer is RGBA
/* intermediate buffer is RGBA */
result = (stbi_uc *) stbi__malloc(x*y*4);
memset(result, 0xff, x*y*4);
if (!stbi__pic_load_core(s,x,y,comp, result)) {
if (!stbi__pic_load_core(s,x,y,comp, result))
{
STBI_FREE(result);
result=0;
}
@ -5430,8 +5437,9 @@ static int stbi__pic_test(stbi__context *s)
}
#endif
// *************************************************************************************************
// GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb
/* *************************************************************************************************
* GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb
*/
#ifndef STBI_NO_GIF
typedef struct
@ -5444,7 +5452,7 @@ typedef struct
typedef struct
{
int w,h;
stbi_uc *out; // output buffer (always 4 components)
stbi_uc *out; /* output buffer (always 4 components) */
int flags, bgindex, ratio, transparent, eflags;
stbi_uc pal[256][4];
stbi_uc lpal[256][4];
@ -5504,7 +5512,7 @@ static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_in
g->ratio = stbi__get8(s);
g->transparent = -1;
if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments
if (comp != 0) *comp = 4; /* can't actually tell whether it's 3 or 4 until we parse the comments */
if (is_info) return 1;
@ -5530,12 +5538,14 @@ static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code)
{
stbi_uc *p, *c;
// recurse to decode the prefixes, since the linked-list is backwards,
// and working backwards through an interleaved image would be nasty
/* recurse to decode the prefixes, since the linked-list is backwards,
* and working backwards through an interleaved image would be nasty
*/
if (g->codes[code].prefix >= 0)
stbi__out_gif_code(g, g->codes[code].prefix);
if (g->cur_y >= g->max_y) return;
if (g->cur_y >= g->max_y)
return;
p = &g->out[g->cur_x + g->cur_y];
c = &g->color_table[g->codes[code].suffix * 4];
@ -5582,7 +5592,7 @@ static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g)
g->codes[code].suffix = (stbi_uc) code;
}
// support no starting clear code
/* support no starting clear code */
avail = clear+2;
oldcode = -1;
@ -5590,7 +5600,7 @@ static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g)
for(;;) {
if (valid_bits < codesize) {
if (len == 0) {
len = stbi__get8(s); // start new block
len = stbi__get8(s); /* start new block */
if (len == 0)
return g->out;
}
@ -5644,8 +5654,9 @@ static void stbi__fill_gif_background(stbi__gif *g)
{
int i;
stbi_uc *c = g->pal[g->bgindex];
// @OPTIMIZE: write a dword at a time
for (i = 0; i < g->w * g->h * 4; i += 4) {
/* @OPTIMIZE: write a dword at a time */
for (i = 0; i < g->w * g->h * 4; i += 4)
{
stbi_uc *p = &g->out[i];
p[0] = c[2];
p[1] = c[1];
@ -5654,14 +5665,16 @@ static void stbi__fill_gif_background(stbi__gif *g)
}
}
// this function is designed to support animated gifs, although stb_image doesn't support it
/* this function is designed to support animated gifs, although stb_image doesn't support it */
static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp)
{
int i;
stbi_uc *old_out = 0;
if (g->out == 0) {
if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header
if (!stbi__gif_header(s, g, comp,0))
return 0;
g->out = (stbi_uc *) stbi__malloc(4 * g->w * g->h);
if (g->out == 0) return stbi__errpuc("outofmem", "Out of memory");
stbi__fill_gif_background(g);
@ -5907,7 +5920,7 @@ static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int re
}
}
} else {
// Read RLE-encoded data
/* Read RLE-encoded data */
scanline = NULL;
for (j = 0; j < height; ++j) {
@ -5915,8 +5928,10 @@ static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int re
c2 = stbi__get8(s);
len = stbi__get8(s);
if (c1 != 2 || c2 != 2 || (len & 0x80)) {
// not run-length encoded, so we have to actually use THIS data as a decoded
// pixel (note this can't be a valid pixel--one of RGB must be >= 128)
/* not run-length encoded, so we have to
* actually use THIS data as a decoded
* pixel (note this can't be a valid pixel
* --one of RGB must be >= 128) */
stbi_uc rgbe[4];
rgbe[0] = (stbi_uc) c1;
rgbe[1] = (stbi_uc) c2;
@ -5997,7 +6012,7 @@ static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp)
*comp = 3;
return 1;
}
#endif // STBI_NO_HDR
#endif /* STBI_NO_HDR */
#ifndef STBI_NO_BMP
static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp)
@ -6281,7 +6296,7 @@ STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp)
fseek(f,pos,SEEK_SET);
return r;
}
#endif // !STBI_NO_STDIO
#endif /* !STBI_NO_STDIO */
STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp)
{
@ -6297,7 +6312,7 @@ STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int
return stbi__info_main(&s,x,y,comp);
}
#endif // STB_IMAGE_IMPLEMENTATION
#endif /* STB_IMAGE_IMPLEMENTATION */
/*
revision history:

View File

@ -1,46 +1,43 @@
// stb_rect_pack.h - v0.06 - public domain - rectangle packing
// Sean Barrett 2014
//
// Useful for e.g. packing rectangular textures into an atlas.
// Does not do rotation.
//
// Not necessarily the awesomest packing method, but better than
// the totally naive one in stb_truetype (which is primarily what
// this is meant to replace).
//
// Has only had a few tests run, may have issues.
//
// More docs to come.
//
// No memory allocations; uses qsort() and assert() from stdlib.
// Can override those by defining STBRP_SORT and STBRP_ASSERT.
//
// This library currently uses the Skyline Bottom-Left algorithm.
//
// Please note: better rectangle packers are welcome! Please
// implement them to the same API, but with a different init
// function.
//
// Credits
//
// Library
// Sean Barrett
// Minor features
// Martins Mozeiko
// Bugfixes / warning fixes
// [your name could be here]
//
// Version history:
//
// 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort
// 0.05: added STBRP_ASSERT to allow replacing assert
// 0.04: fixed minor bug in STBRP_LARGE_RECTS support
// 0.01: initial release
//////////////////////////////////////////////////////////////////////////////
//
// INCLUDE SECTION
//
/*
* stb_rect_pack.h - v0.06 - public domain - rectangle packing
* Sean Barrett 2014
*
* Useful for e.g. packing rectangular textures into an atlas.
* Does not do rotation.
*
* Not necessarily the awesomest packing method, but better than
* the totally naive one in stb_truetype (which is primarily what
* this is meant to replace).
*
* Has only had a few tests run, may have issues.
*
* More docs to come.
*
* No memory allocations; uses qsort() and assert() from stdlib.
* Can override those by defining STBRP_SORT and STBRP_ASSERT.
*
* This library currently uses the Skyline Bottom-Left algorithm.
*
* Please note: better rectangle packers are welcome! Please
* implement them to the same API, but with a different init
* function.
*
* Credits
*
* Library
* Sean Barrett
* Minor features
* Martins Mozeiko
* Bugfixes / warning fixes
* [your name could be here]
*
* Version history:
*
* 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort
* 0.05: added STBRP_ASSERT to allow replacing assert
* 0.04: fixed minor bug in STBRP_LARGE_RECTS support
* 0.01: initial release
*/
#ifndef STB_INCLUDE_STB_RECT_PACK_H
#define STB_INCLUDE_STB_RECT_PACK_H
@ -67,87 +64,89 @@ typedef int stbrp_coord;
typedef unsigned short stbrp_coord;
#endif
STBRP_DEF void stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);
// Assign packed locations to rectangles. The rectangles are of type
// 'stbrp_rect' defined below, stored in the array 'rects', and there
// are 'num_rects' many of them.
//
// Rectangles which are successfully packed have the 'was_packed' flag
// set to a non-zero value and 'x' and 'y' store the minimum location
// on each axis (i.e. bottom-left in cartesian coordinates, top-left
// if you imagine y increasing downwards). Rectangles which do not fit
// have the 'was_packed' flag set to 0.
//
// You should not try to access the 'rects' array from another thread
// while this function is running, as the function temporarily reorders
// the array while it executes.
//
// To pack into another rectangle, you need to call stbrp_init_target
// again. To continue packing into the same rectangle, you can call
// this function again. Calling this multiple times with multiple rect
// arrays will probably produce worse packing results than calling it
// a single time with the full rectangle array, but the option is
// available.
STBRP_DEF void stbrp_pack_rects (stbrp_context *context,
stbrp_rect *rects, int num_rects);
/* Assign packed locations to rectangles. The rectangles are of type
* 'stbrp_rect' defined below, stored in the array 'rects', and there
* are 'num_rects' many of them.
*
* Rectangles which are successfully packed have the 'was_packed' flag
* set to a non-zero value and 'x' and 'y' store the minimum location
* on each axis (i.e. bottom-left in cartesian coordinates, top-left
* if you imagine y increasing downwards). Rectangles which do not fit
* have the 'was_packed' flag set to 0.
*
* You should not try to access the 'rects' array from another thread
* while this function is running, as the function temporarily reorders
* the array while it executes.
*
* To pack into another rectangle, you need to call stbrp_init_target
* again. To continue packing into the same rectangle, you can call
* this function again. Calling this multiple times with multiple rect
* arrays will probably produce worse packing results than calling it
* a single time with the full rectangle array, but the option is
* available.
*/
struct stbrp_rect
{
// reserved for your use:
int id;
// input:
stbrp_coord w, h;
// output:
stbrp_coord x, y;
int was_packed; // non-zero if valid packing
}; // 16 bytes, nominally
int id; /* reserved for your use: */
stbrp_coord w, h; /* input: */
stbrp_coord x, y; /* output: */
int was_packed; /* non-zero if valid packing */
}; /* 16 bytes, nominally */
STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes);
// Initialize a rectangle packer to:
// pack a rectangle that is 'width' by 'height' in dimensions
// using temporary storage provided by the array 'nodes', which is 'num_nodes' long
//
// You must call this function every time you start packing into a new target.
//
// There is no "shutdown" function. The 'nodes' memory must stay valid for
// the following stbrp_pack_rects() call (or calls), but can be freed after
// the call (or calls) finish.
//
// Note: to guarantee best results, either:
// 1. make sure 'num_nodes' >= 'width'
// or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1'
//
// If you don't do either of the above things, widths will be quantized to multiples
// of small integers to guarantee the algorithm doesn't run out of temporary storage.
//
// If you do #2, then the non-quantized algorithm will be used, but the algorithm
// may run out of temporary storage and be unable to pack some rectangles.
STBRP_DEF void stbrp_init_target (stbrp_context *context,
int width, int height, stbrp_node *nodes, int num_nodes);
/* Initialize a rectangle packer to:
* pack a rectangle that is 'width' by 'height' in dimensions
* using temporary storage provided by the array 'nodes', which is 'num_nodes' long
*
* You must call this function every time you start packing into a new target.
*
* There is no "shutdown" function. The 'nodes' memory must stay valid for
* the following stbrp_pack_rects() call (or calls), but can be freed after
* the call (or calls) finish.
*
* Note: to guarantee best results, either:
* 1. make sure 'num_nodes' >= 'width'
* or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1'
*
* If you don't do either of the above things, widths will be quantized to multiples
* of small integers to guarantee the algorithm doesn't run out of temporary storage.
*
* If you do #2, then the non-quantized algorithm will be used, but the algorithm
* may run out of temporary storage and be unable to pack some rectangles.
*/
STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem);
// Optionally call this function after init but before doing any packing to
// change the handling of the out-of-temp-memory scenario, described above.
// If you call init again, this will be reset to the default (false).
/* Optionally call this function after init but before doing any packing to
* change the handling of the out-of-temp-memory scenario, described above.
* If you call init again, this will be reset to the default (false).
*/
STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic);
// Optionally select which packing heuristic the library should use. Different
// heuristics will produce better/worse results for different data sets.
// If you call init again, this will be reset to the default.
/* Optionally select which packing heuristic the library should use. Different
* heuristics will produce better/worse results for different data sets.
* If you call init again, this will be reset to the default.
*/
enum
{
STBRP_HEURISTIC_Skyline_default=0,
STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default,
STBRP_HEURISTIC_Skyline_BF_sortHeight,
STBRP_HEURISTIC_Skyline_BF_sortHeight
};
//////////////////////////////////////////////////////////////////////////////
//
// the details of the following structures don't matter to you, but they must
// be visible so you can handle the memory allocations for them
/* the details of the following structures don't matter to you, but they must
* be visible so you can handle the memory allocations for them
*/
struct stbrp_node
{
@ -165,7 +164,7 @@ struct stbrp_context
int num_nodes;
stbrp_node *active_head;
stbrp_node *free_head;
stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2'
stbrp_node extra[2]; /* we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' */
};
#ifdef __cplusplus
@ -174,10 +173,7 @@ struct stbrp_context
#endif
//////////////////////////////////////////////////////////////////////////////
//
// IMPLEMENTATION SECTION
//
/* IMPLEMENTATION SECTION */
#ifdef STB_RECT_PACK_IMPLEMENTATION
#ifndef STBRP_SORT
@ -192,12 +188,13 @@ struct stbrp_context
enum
{
STBRP__INIT_skyline = 1,
STBRP__INIT_skyline = 1
};
STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
{
switch (context->init_mode) {
switch (context->init_mode)
{
case STBRP__INIT_skyline:
STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight);
context->heuristic = heuristic;
@ -209,20 +206,22 @@ STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem)
{
/* if it's ok to run out of memory, then don't bother aligning them;
* this gives better packing, but may fail due to OOM (even though
* the rectangles easily fit). @TODO a smarter approach would be to only
* quantize once we've hit OOM, then we could get rid of this parameter.
*/
if (allow_out_of_mem)
// if it's ok to run out of memory, then don't bother aligning them;
// this gives better packing, but may fail due to OOM (even though
// the rectangles easily fit). @TODO a smarter approach would be to only
// quantize once we've hit OOM, then we could get rid of this parameter.
context->align = 1;
else {
// if it's not ok to run out of memory, then quantize the widths
// so that num_nodes is always enough nodes.
//
// I.e. num_nodes * align >= width
// align >= width / num_nodes
// align = ceil(width/num_nodes)
else
{
/* if it's not ok to run out of memory, then quantize the widths
* so that num_nodes is always enough nodes.
*
* I.e. num_nodes * align >= width
* align >= width / num_nodes
* align = ceil(width/num_nodes)
*/
context->align = (context->width + context->num_nodes-1) / context->num_nodes;
}
}
@ -246,7 +245,8 @@ STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height,
context->num_nodes = num_nodes;
stbrp_setup_allow_out_of_mem(context, 0);
// node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly)
/* node 0 is the full width,
* node 1 is the sentinel (lets us not store width explicitly) */
context->extra[0].x = 0;
context->extra[0].y = 0;
context->extra[0].next = &context->extra[1];
@ -259,41 +259,41 @@ STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height,
context->extra[1].next = NULL;
}
// find minimum y position if it starts at x1
static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste)
/* Find minimum y position if it starts at x1 */
static int stbrp__skyline_find_min_y(stbrp_context *c,
stbrp_node *first, int x0, int width, int *pwaste)
{
int min_y, visited_width, waste_area;
stbrp_node *node = first;
int x1 = x0 + width;
int min_y, visited_width, waste_area;
STBRP_ASSERT(first->x <= x0);
#if 0
// skip in case we're past the node
while (node->next->x <= x0)
++node;
#else
STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency
#endif
STBRP_ASSERT(node->next->x > x0);
STBRP_ASSERT(node->x <= x0);
min_y = 0;
waste_area = 0;
visited_width = 0;
while (node->x < x1) {
if (node->y > min_y) {
// raise min_y higher.
// we've accounted for all waste up to min_y,
// but we'll now add more waste for everything we've visted
while (node->x < x1)
{
if (node->y > min_y)
{
/* raise min_y higher.
* we've accounted for all waste up to min_y,
* but we'll now add more waste for everything we've visted
*/
waste_area += visited_width * (node->y - min_y);
min_y = node->y;
// the first time through, visited_width might be reduced
/* the first time through, visited_width might be reduced */
if (node->x < x0)
visited_width += node->next->x - x0;
else
visited_width += node->next->x - node->x;
} else {
// add waste area
}
else
{
/* add waste area */
int under_width = node->next->x - node->x;
if (under_width + visited_width > width)
under_width = width - visited_width;
@ -319,27 +319,35 @@ static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int widt
stbrp__findresult fr;
stbrp_node **prev, *node, *tail, **best = NULL;
// align to multiple of c->align
/* align to multiple of c->align */
width = (width + c->align - 1);
width -= width % c->align;
STBRP_ASSERT(width % c->align == 0);
node = c->active_head;
prev = &c->active_head;
while (node->x + width <= c->width) {
int y,waste;
y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste);
if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL
// bottom left
if (y < best_y) {
while (node->x + width <= c->width)
{
int waste;
int y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste);
if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight)
{
/* actually just want to test BL bottom left */
if (y < best_y)
{
best_y = y;
best = prev;
}
} else {
// best-fit
if (y + height <= c->height) {
// can only use it if it first vertically
if (y < best_y || (y == best_y && waste < best_waste)) {
}
else
{
/* best-fit */
if (y + height <= c->height)
{
/* can only use it if it first vertically */
if (y < best_y || (y == best_y && waste < best_waste))
{
best_y = y;
best_waste = waste;
best = prev;
@ -352,44 +360,54 @@ static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int widt
best_x = (best == NULL) ? 0 : (*best)->x;
// if doing best-fit (BF), we also have to try aligning right edge to each node position
//
// e.g, if fitting
//
// ____________________
// |____________________|
//
// into
//
// | |
// | ____________|
// |____________|
//
// then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned
//
// This makes BF take about 2x the time
/* if doing best-fit (BF), we also have to try aligning right edge to each node position
*
* e.g, if fitting
*
* ____________________
* |____________________|
*
* into
*
* | |
* | ____________|
* |____________|
*
* then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned
*
* This makes BF take about 2x the time
*/
if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) {
if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight)
{
tail = c->active_head;
node = c->active_head;
prev = &c->active_head;
// find first node that's admissible
/* find first node that's admissible */
while (tail->x < width)
tail = tail->next;
while (tail) {
while (tail)
{
int xpos = tail->x - width;
int y,waste;
STBRP_ASSERT(xpos >= 0);
// find the left position that matches this
while (node->next->x <= xpos) {
/* find the left position that matches this */
while (node->next->x <= xpos)
{
prev = &node->next;
node = node->next;
}
STBRP_ASSERT(node->next->x > xpos && node->x <= xpos);
y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste);
if (y + height < c->height) {
if (y <= best_y) {
if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
if (y + height < c->height)
{
if (y <= best_y)
{
if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x))
{
best_x = xpos;
STBRP_ASSERT(y <= best_y);
best_y = y;
@ -410,83 +428,62 @@ static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int widt
static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height)
{
// find best position according to heuristic
stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height);
/* find best position according to heuristic */
stbrp_node *node, *cur;
stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height);
// bail if:
// 1. it failed
// 2. the best node doesn't fit (we don't always check this)
// 3. we're out of memory
if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) {
/* bail if:
* 1. it failed
* 2. the best node doesn't fit (we don't always check this)
* 3. we're out of memory
*/
if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL)
{
res.prev_link = NULL;
return res;
}
// on success, create new node
/* on success, create new node */
node = context->free_head;
node->x = (stbrp_coord) res.x;
node->y = (stbrp_coord) (res.y + height);
context->free_head = node->next;
// insert the new node into the right starting point, and
// let 'cur' point to the remaining nodes needing to be
// stiched back in
/* insert the new node into the right starting point, and
* let 'cur' point to the remaining nodes needing to be
* stiched back in
*/
cur = *res.prev_link;
if (cur->x < res.x) {
// preserve the existing one, so start testing with the next one
if (cur->x < res.x)
{
/* preserve the existing one, so start testing with the next one */
stbrp_node *next = cur->next;
cur->next = node;
cur = next;
} else {
*res.prev_link = node;
}
else
*res.prev_link = node;
// from here, traverse cur and free the nodes, until we get to one
// that shouldn't be freed
while (cur->next && cur->next->x <= res.x + width) {
/* from here, traverse cur and free the nodes, until we get to one
* that shouldn't be freed */
while (cur->next && cur->next->x <= res.x + width)
{
stbrp_node *next = cur->next;
// move the current node to the free list
/* move the current node to the free list */
cur->next = context->free_head;
context->free_head = cur;
cur = next;
}
// stitch the list back in
/* stitch the list back in */
node->next = cur;
if (cur->x < res.x + width)
cur->x = (stbrp_coord) (res.x + width);
#ifdef _DEBUG
cur = context->active_head;
while (cur->x < context->width) {
STBRP_ASSERT(cur->x < cur->next->x);
cur = cur->next;
}
STBRP_ASSERT(cur->next == NULL);
{
stbrp_node *L1 = NULL, *L2 = NULL;
int count=0;
cur = context->active_head;
while (cur) {
L1 = cur;
cur = cur->next;
++count;
}
cur = context->free_head;
while (cur) {
L2 = cur;
cur = cur->next;
++count;
}
STBRP_ASSERT(count == context->num_nodes+2);
}
#endif
return res;
}
@ -529,20 +526,23 @@ STBRP_DEF void stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int n
{
int i;
// we use the 'was_packed' field internally to allow sorting/unsorting
for (i=0; i < num_rects; ++i) {
/* we use the 'was_packed' field internally to allow sorting/unsorting */
for (i=0; i < num_rects; ++i)
{
rects[i].was_packed = i;
#ifndef STBRP_LARGE_RECTS
STBRP_ASSERT(rects[i].w <= 0xffff && rects[i].h <= 0xffff);
#endif
}
// sort according to heuristic
/* sort according to heuristic */
STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare);
for (i=0; i < num_rects; ++i) {
for (i=0; i < num_rects; ++i)
{
stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
if (fr.prev_link) {
if (fr.prev_link)
{
rects[i].x = (stbrp_coord) fr.x;
rects[i].y = (stbrp_coord) fr.y;
} else {
@ -550,10 +550,10 @@ STBRP_DEF void stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int n
}
}
// unsort
/* unsort */
STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);
// set was_packed flags
/* set was_packed flags */
for (i=0; i < num_rects; ++i)
rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL);
}

2389
deps/stb/stb_truetype.h vendored

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,6 @@ 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();
settings_t *settings = config_get_ptr();
(void)input_dir;
@ -39,7 +38,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.list) ? core_info_list_get_all_extensions(global->core_info.list) : NULL;
exts = core_info_list_get_all_extensions();
break;
case DIR_LIST_SHADERS:
dir = settings->video.shader_dir;

View File

@ -13,8 +13,8 @@ EXT=a
mkdir -p ../pkg/${platform}/cores/
make -C ../${platform}/kernel_functions_prx/ clean || exit 1
make -C ../${platform}/kernel_functions_prx/ || exit 1
make -C ../bootstrap/${platform}/kernel_functions_prx/ clean || exit 1
make -C ../bootstrap/${platform}/kernel_functions_prx/ || exit 1
cp -f ../kernel_functions.prx ../pkg/${platform}/kernel_functions.prx
# Vita
@ -158,7 +158,7 @@ for f in *_${platform}.${EXT} ; do
# 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"
mv -f ../CORE.SELF ../pkg/${platform}_iso/PS3_GAME/USRDIR/cores/"${name}_libretro_${platform}.SELF"
else
mv -f ../CORE.SELF ../pkg/${platform}/USRDIR/cores/"${name}_libretro_${platform}.SELF"
fi
@ -227,8 +227,8 @@ elif [ $PLATFORM = "cex-ps3" ] ; then
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
$SCETOOL_PATH $SCETOOL_FLAGS --encrypt ../retroarch-salamander_${platform}.elf ../pkg/${platform}_iso/PS3_GAME/USRDIR/EBOOT.BIN
rm -rf ../retroarch-salamander_${platform}.elf
$GENPS3ISO_PATH ../${platform}/iso RetroArch-COBRA-ODE.iso
$GENPS3ISO_PATH ../pkg/${platform}_iso/RetroArch-COBRA-ODE.iso
fi

224
dynamic.c
View File

@ -17,12 +17,13 @@
#include <string.h>
#include <ctype.h>
#include <boolean.h>
#include <file/file_path.h>
#include <retro_log.h>
#include <compat/strl.h>
#include <compat/posix_string.h>
#include <boolean.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -39,8 +40,7 @@
#include "input/input_sensor.h"
#ifdef HAVE_DYNAMIC
#undef SYM
#define SYM(x) do { \
#define SYMBOL(x) do { \
function_t func = dylib_proc(lib_handle, #x); \
memcpy(&p##x, &func, sizeof(func)); \
if (p##x == NULL) { RARCH_ERR("Failed to load symbol: \"%s\"\n", #x); rarch_fail(1, "init_libretro_sym()"); } \
@ -48,17 +48,17 @@
static dylib_t lib_handle;
#else
#define SYM(x) p##x = x
#define SYMBOL(x) p##x = x
#endif
#define SYM_DUMMY(x) p##x = libretro_dummy_##x
#define SYMBOL_DUMMY(x) p##x = libretro_dummy_##x
#ifdef HAVE_FFMPEG
#define SYM_FFMPEG(x) p##x = libretro_ffmpeg_##x
#define SYMBOL_FFMPEG(x) p##x = libretro_ffmpeg_##x
#endif
#ifdef HAVE_IMAGEVIEWER
#define SYM_IMAGEVIEWER(x) p##x = libretro_imageviewer_##x
#define SYMBOL_IMAGEVIEWER(x) p##x = libretro_imageviewer_##x
#endif
void (*pretro_init)(void);
@ -333,147 +333,147 @@ static void load_symbols(enum rarch_core_type type)
#endif
}
SYM(retro_init);
SYM(retro_deinit);
SYMBOL(retro_init);
SYMBOL(retro_deinit);
SYM(retro_api_version);
SYM(retro_get_system_info);
SYM(retro_get_system_av_info);
SYMBOL(retro_api_version);
SYMBOL(retro_get_system_info);
SYMBOL(retro_get_system_av_info);
SYM(retro_set_environment);
SYM(retro_set_video_refresh);
SYM(retro_set_audio_sample);
SYM(retro_set_audio_sample_batch);
SYM(retro_set_input_poll);
SYM(retro_set_input_state);
SYMBOL(retro_set_environment);
SYMBOL(retro_set_video_refresh);
SYMBOL(retro_set_audio_sample);
SYMBOL(retro_set_audio_sample_batch);
SYMBOL(retro_set_input_poll);
SYMBOL(retro_set_input_state);
SYM(retro_set_controller_port_device);
SYMBOL(retro_set_controller_port_device);
SYM(retro_reset);
SYM(retro_run);
SYMBOL(retro_reset);
SYMBOL(retro_run);
SYM(retro_serialize_size);
SYM(retro_serialize);
SYM(retro_unserialize);
SYMBOL(retro_serialize_size);
SYMBOL(retro_serialize);
SYMBOL(retro_unserialize);
SYM(retro_cheat_reset);
SYM(retro_cheat_set);
SYMBOL(retro_cheat_reset);
SYMBOL(retro_cheat_set);
SYM(retro_load_game);
SYM(retro_load_game_special);
SYMBOL(retro_load_game);
SYMBOL(retro_load_game_special);
SYM(retro_unload_game);
SYM(retro_get_region);
SYM(retro_get_memory_data);
SYM(retro_get_memory_size);
SYMBOL(retro_unload_game);
SYMBOL(retro_get_region);
SYMBOL(retro_get_memory_data);
SYMBOL(retro_get_memory_size);
break;
case CORE_TYPE_DUMMY:
SYM_DUMMY(retro_init);
SYM_DUMMY(retro_deinit);
SYMBOL_DUMMY(retro_init);
SYMBOL_DUMMY(retro_deinit);
SYM_DUMMY(retro_api_version);
SYM_DUMMY(retro_get_system_info);
SYM_DUMMY(retro_get_system_av_info);
SYMBOL_DUMMY(retro_api_version);
SYMBOL_DUMMY(retro_get_system_info);
SYMBOL_DUMMY(retro_get_system_av_info);
SYM_DUMMY(retro_set_environment);
SYM_DUMMY(retro_set_video_refresh);
SYM_DUMMY(retro_set_audio_sample);
SYM_DUMMY(retro_set_audio_sample_batch);
SYM_DUMMY(retro_set_input_poll);
SYM_DUMMY(retro_set_input_state);
SYMBOL_DUMMY(retro_set_environment);
SYMBOL_DUMMY(retro_set_video_refresh);
SYMBOL_DUMMY(retro_set_audio_sample);
SYMBOL_DUMMY(retro_set_audio_sample_batch);
SYMBOL_DUMMY(retro_set_input_poll);
SYMBOL_DUMMY(retro_set_input_state);
SYM_DUMMY(retro_set_controller_port_device);
SYMBOL_DUMMY(retro_set_controller_port_device);
SYM_DUMMY(retro_reset);
SYM_DUMMY(retro_run);
SYMBOL_DUMMY(retro_reset);
SYMBOL_DUMMY(retro_run);
SYM_DUMMY(retro_serialize_size);
SYM_DUMMY(retro_serialize);
SYM_DUMMY(retro_unserialize);
SYMBOL_DUMMY(retro_serialize_size);
SYMBOL_DUMMY(retro_serialize);
SYMBOL_DUMMY(retro_unserialize);
SYM_DUMMY(retro_cheat_reset);
SYM_DUMMY(retro_cheat_set);
SYMBOL_DUMMY(retro_cheat_reset);
SYMBOL_DUMMY(retro_cheat_set);
SYM_DUMMY(retro_load_game);
SYM_DUMMY(retro_load_game_special);
SYMBOL_DUMMY(retro_load_game);
SYMBOL_DUMMY(retro_load_game_special);
SYM_DUMMY(retro_unload_game);
SYM_DUMMY(retro_get_region);
SYM_DUMMY(retro_get_memory_data);
SYM_DUMMY(retro_get_memory_size);
SYMBOL_DUMMY(retro_unload_game);
SYMBOL_DUMMY(retro_get_region);
SYMBOL_DUMMY(retro_get_memory_data);
SYMBOL_DUMMY(retro_get_memory_size);
break;
#ifdef HAVE_FFMPEG
case CORE_TYPE_FFMPEG:
SYM_FFMPEG(retro_init);
SYM_FFMPEG(retro_deinit);
SYMBOL_FFMPEG(retro_init);
SYMBOL_FFMPEG(retro_deinit);
SYM_FFMPEG(retro_api_version);
SYM_FFMPEG(retro_get_system_info);
SYM_FFMPEG(retro_get_system_av_info);
SYMBOL_FFMPEG(retro_api_version);
SYMBOL_FFMPEG(retro_get_system_info);
SYMBOL_FFMPEG(retro_get_system_av_info);
SYM_FFMPEG(retro_set_environment);
SYM_FFMPEG(retro_set_video_refresh);
SYM_FFMPEG(retro_set_audio_sample);
SYM_FFMPEG(retro_set_audio_sample_batch);
SYM_FFMPEG(retro_set_input_poll);
SYM_FFMPEG(retro_set_input_state);
SYMBOL_FFMPEG(retro_set_environment);
SYMBOL_FFMPEG(retro_set_video_refresh);
SYMBOL_FFMPEG(retro_set_audio_sample);
SYMBOL_FFMPEG(retro_set_audio_sample_batch);
SYMBOL_FFMPEG(retro_set_input_poll);
SYMBOL_FFMPEG(retro_set_input_state);
SYM_FFMPEG(retro_set_controller_port_device);
SYMBOL_FFMPEG(retro_set_controller_port_device);
SYM_FFMPEG(retro_reset);
SYM_FFMPEG(retro_run);
SYMBOL_FFMPEG(retro_reset);
SYMBOL_FFMPEG(retro_run);
SYM_FFMPEG(retro_serialize_size);
SYM_FFMPEG(retro_serialize);
SYM_FFMPEG(retro_unserialize);
SYMBOL_FFMPEG(retro_serialize_size);
SYMBOL_FFMPEG(retro_serialize);
SYMBOL_FFMPEG(retro_unserialize);
SYM_FFMPEG(retro_cheat_reset);
SYM_FFMPEG(retro_cheat_set);
SYMBOL_FFMPEG(retro_cheat_reset);
SYMBOL_FFMPEG(retro_cheat_set);
SYM_FFMPEG(retro_load_game);
SYM_FFMPEG(retro_load_game_special);
SYMBOL_FFMPEG(retro_load_game);
SYMBOL_FFMPEG(retro_load_game_special);
SYM_FFMPEG(retro_unload_game);
SYM_FFMPEG(retro_get_region);
SYM_FFMPEG(retro_get_memory_data);
SYM_FFMPEG(retro_get_memory_size);
SYMBOL_FFMPEG(retro_unload_game);
SYMBOL_FFMPEG(retro_get_region);
SYMBOL_FFMPEG(retro_get_memory_data);
SYMBOL_FFMPEG(retro_get_memory_size);
break;
#endif
case CORE_TYPE_IMAGEVIEWER:
#ifdef HAVE_IMAGEVIEWER
SYM_IMAGEVIEWER(retro_init);
SYM_IMAGEVIEWER(retro_deinit);
SYMBOL_IMAGEVIEWER(retro_init);
SYMBOL_IMAGEVIEWER(retro_deinit);
SYM_IMAGEVIEWER(retro_api_version);
SYM_IMAGEVIEWER(retro_get_system_info);
SYM_IMAGEVIEWER(retro_get_system_av_info);
SYMBOL_IMAGEVIEWER(retro_api_version);
SYMBOL_IMAGEVIEWER(retro_get_system_info);
SYMBOL_IMAGEVIEWER(retro_get_system_av_info);
SYM_IMAGEVIEWER(retro_set_environment);
SYM_IMAGEVIEWER(retro_set_video_refresh);
SYM_IMAGEVIEWER(retro_set_audio_sample);
SYM_IMAGEVIEWER(retro_set_audio_sample_batch);
SYM_IMAGEVIEWER(retro_set_input_poll);
SYM_IMAGEVIEWER(retro_set_input_state);
SYMBOL_IMAGEVIEWER(retro_set_environment);
SYMBOL_IMAGEVIEWER(retro_set_video_refresh);
SYMBOL_IMAGEVIEWER(retro_set_audio_sample);
SYMBOL_IMAGEVIEWER(retro_set_audio_sample_batch);
SYMBOL_IMAGEVIEWER(retro_set_input_poll);
SYMBOL_IMAGEVIEWER(retro_set_input_state);
SYM_IMAGEVIEWER(retro_set_controller_port_device);
SYMBOL_IMAGEVIEWER(retro_set_controller_port_device);
SYM_IMAGEVIEWER(retro_reset);
SYM_IMAGEVIEWER(retro_run);
SYMBOL_IMAGEVIEWER(retro_reset);
SYMBOL_IMAGEVIEWER(retro_run);
SYM_IMAGEVIEWER(retro_serialize_size);
SYM_IMAGEVIEWER(retro_serialize);
SYM_IMAGEVIEWER(retro_unserialize);
SYMBOL_IMAGEVIEWER(retro_serialize_size);
SYMBOL_IMAGEVIEWER(retro_serialize);
SYMBOL_IMAGEVIEWER(retro_unserialize);
SYM_IMAGEVIEWER(retro_cheat_reset);
SYM_IMAGEVIEWER(retro_cheat_set);
SYMBOL_IMAGEVIEWER(retro_cheat_reset);
SYMBOL_IMAGEVIEWER(retro_cheat_set);
SYM_IMAGEVIEWER(retro_load_game);
SYM_IMAGEVIEWER(retro_load_game_special);
SYMBOL_IMAGEVIEWER(retro_load_game);
SYMBOL_IMAGEVIEWER(retro_load_game_special);
SYM_IMAGEVIEWER(retro_unload_game);
SYM_IMAGEVIEWER(retro_get_region);
SYM_IMAGEVIEWER(retro_get_memory_data);
SYM_IMAGEVIEWER(retro_get_memory_size);
SYMBOL_IMAGEVIEWER(retro_unload_game);
SYMBOL_IMAGEVIEWER(retro_get_region);
SYMBOL_IMAGEVIEWER(retro_get_memory_data);
SYMBOL_IMAGEVIEWER(retro_get_memory_size);
#endif
break;
}
@ -1120,12 +1120,12 @@ bool rarch_environment_cb(unsigned cmd, void *data)
struct retro_perf_callback *cb = (struct retro_perf_callback*)data;
RARCH_LOG("Environ GET_PERF_INTERFACE.\n");
cb->get_time_usec = rarch_get_time_usec;
cb->get_cpu_features = rarch_get_cpu_features;
cb->get_perf_counter = rarch_get_perf_counter;
cb->get_time_usec = retro_get_time_usec;
cb->get_cpu_features = retro_get_cpu_features;
cb->get_perf_counter = retro_get_perf_counter;
cb->perf_register = retro_perf_register; /* libretro specific path. */
cb->perf_start = rarch_perf_start;
cb->perf_stop = rarch_perf_stop;
cb->perf_start = retro_perf_start;
cb->perf_stop = retro_perf_stop;
cb->perf_log = retro_perf_log; /* libretro specific path. */
break;
}

View File

@ -30,6 +30,7 @@
#include <retro_assert.h>
#include <retro_miscellaneous.h>
#include <file/file_path.h>
#include <retro_file.h>
#include <string/string_list.h>
#ifdef HAVE_COMPRESSION
#include <file/file_extract.h>
@ -200,6 +201,8 @@ static int read_7zip_file(
SRes res;
ISzAlloc allocImp;
ISzAlloc allocTempImp;
uint8_t *outBuffer = 0;
size_t outBufferSize = 0;
uint16_t *temp = NULL;
size_t tempSize = 0;
long outsize = -1;
@ -235,8 +238,6 @@ static int read_7zip_file(
{
uint32_t i;
uint32_t blockIndex = 0xFFFFFFFF;
uint8_t *outBuffer = 0;
size_t outBufferSize = 0;
for (i = 0; i < db.db.NumFiles; i++)
{
@ -246,14 +247,13 @@ static int read_7zip_file(
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?*/
if (f->IsDir)
continue;
}
len = SzArEx_GetFileNameUtf16(&db, i, NULL);
if (len > tempSize)
{
free(temp);
@ -265,6 +265,7 @@ static int read_7zip_file(
break;
}
}
SzArEx_GetFileNameUtf16(&db, i, temp);
res = ConvertUtf16toCharString(temp,infile);
@ -277,26 +278,25 @@ static int read_7zip_file(
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)
const void *ptr = (const void*)(outBuffer + offset);
if (!retro_write_file(optional_outfile, ptr, outsize))
{
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;
res = SZ_OK;
file_found = true;
outsize = -1;
break;
}
fwrite(outBuffer+offset,1,outsize,outsink);
fclose(outsink);
}
else
{
@ -309,14 +309,14 @@ static int read_7zip_file(
((char*)(*buf))[outsize] = '\0';
memcpy(*buf,outBuffer+offset,outsize);
}
IAlloc_Free(&allocImp, outBuffer);
break;
}
}
}
IAlloc_Free(&allocImp, outBuffer);
SzArEx_Free(&db, &allocImp);
free(temp);
File_Close(&archiveStream.file);
if (res == SZ_OK && file_found == true)
@ -559,31 +559,27 @@ static int read_zip_file(const char *archive_path,
else
{
char read_buffer[RARCH_ZIP_SUPPORT_BUFFER_SIZE_MAX] = {0};
FILE* outsink = fopen(optional_outfile,"wb");
RFILE* outsink = retro_fopen(optional_outfile, RFILE_MODE_WRITE, -1);
if (outsink == NULL)
if (!outsink)
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)
if (retro_fwrite(outsink, read_buffer, bytes_read) == bytes_read)
continue;
/* couldn't write all bytes */
RARCH_ERR("Error writing to %s.\n",optional_outfile);
fclose(outsink);
RARCH_ERR("Error writing to %s.\n", optional_outfile);
retro_fclose(outsink);
goto close;
} while(bytes_read > 0);
fclose(outsink);
retro_fclose(outsink);
}
finished_reading = true;
}
@ -619,90 +615,6 @@ error:
#endif
/**
* write_file:
* @path : path to file.
* @data : contents to write to the file.
* @size : size of the contents.
*
* Writes data to a file.
*
* Returns: true (1) on success, false (0) otherwise.
*/
bool write_file(const char *path, const void *data, ssize_t size)
{
ssize_t ret = 0;
FILE *file = fopen(path, "wb");
if (!file)
return false;
ret = fwrite(data, 1, size, file);
fclose(file);
return (ret == size);
}
/**
* read_generic_file:
* @path : path to file.
* @buf : buffer to allocate and read the contents of the
* file into. Needs to be freed manually.
*
* Read the contents of a file into @buf.
*
* Returns: number of items read, -1 on error.
*/
static int read_generic_file(const char *path, void **buf, ssize_t *len)
{
size_t bytes_read = 0;
size_t content_buf_size = 0;
void *content_buf = NULL;
FILE *file = fopen(path, "rb");
if (!file)
goto error;
if (fseek(file, 0, SEEK_END) != 0)
goto error;
content_buf_size = ftell(file);
if (content_buf_size < 0)
goto error;
rewind(file);
content_buf = malloc(content_buf_size + 1);
if (!content_buf)
goto error;
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;
/* Allow for easy reading of strings to be safe.
* Will only work with sane character formatting (Unix). */
((char*)content_buf)[content_buf_size] = '\0';
if (fclose(file) != 0)
RARCH_WARN("Failed to close file stream.\n");
if (len)
*len = bytes_read;
return 1;
error:
if (file)
fclose(file);
if (content_buf)
free(content_buf);
if (len)
*len = -1;
*buf = NULL;
return 0;
}
#ifdef HAVE_COMPRESSION
/* Generic compressed file loader.
* Extracts to buf, unless optional_filename != 0
@ -783,7 +695,7 @@ int read_compressed_file(const char * path, void **buf,
* @length : Number of items read, -1 on error.
*
* Read the contents of a file into @buf. Will call read_compressed_file
* if path contains a compressed file, otherwise will call read_generic_file.
* if path contains a compressed file, otherwise will call retro_read_file().
*
* Returns: 1 if file read, 0 on error.
*/
@ -796,7 +708,7 @@ int read_file(const char *path, void **buf, ssize_t *length)
return 1;
}
#endif
return read_generic_file(path, buf, length);
return retro_read_file(path, buf, length);
}
struct string_list *compressed_file_list_new(const char *path,

View File

@ -26,26 +26,16 @@
#include <time.h>
#include <errno.h>
#ifdef __HAIKU__
#include <kernel/image.h>
#endif
#ifdef _WIN32
#include <direct.h>
#else
#include <unistd.h> /* stat() is defined here */
#include <unistd.h>
#endif
#ifdef __APPLE__
#include <CoreFoundation/CoreFoundation.h>
#endif
#if defined(__CELLOS_LV2__)
#ifndef S_ISDIR
#define S_ISDIR(x) (x & 0040000)
#endif
#endif
#include <file/file_path.h>
#include <compat/strl.h>
#include <compat/posix_string.h>
@ -203,6 +193,7 @@ void fill_pathname_application_path(char *buf, size_t size)
snprintf(link_path, sizeof(link_path), "/proc/%u/%s",
(unsigned)pid, exts[i]);
ret = readlink(link_path, buf, size - 1);
if (ret >= 0)
{
buf[ret] = '\0';

File diff suppressed because it is too large Load Diff

View File

@ -13,13 +13,14 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <3ds.h>
#include <stdint.h>
#include <boolean.h>
#include <stddef.h>
#include <string.h>
#include <boolean.h>
#include <3ds.h>
#include <file/file_path.h>
#ifndef IS_SALAMANDER
#include <file/file_list.h>
@ -35,15 +36,77 @@
#include "../../menu/menu_list.h"
#endif
int __stacksize__ = 1*1024*1024;
const char* elf_path_cst = "sdmc:/retroarch/test.3dsx";
void wait_for_input(void);
#define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0)
#ifndef CTR_STACK_SIZE
#define CTR_STACK_SIZE 0x100000
#endif
#ifndef CTR_LINEAR_HEAP_SIZE
#define CTR_LINEAR_HEAP_SIZE 0x600000
#endif
int __stacksize__ = CTR_STACK_SIZE;
extern char* fake_heap_start;
extern char* fake_heap_end;
u32 __linear_heap;
u32 __heapBase;
static u32 __heap_size_local, __linear_heap_size_local;
extern void (*__system_retAddr)(void);
void __destroy_handle_list(void);
void __appExit();
void __libc_fini_array(void);
void __system_allocateHeaps() {
u32 tmp=0;
int64_t mem_used;
svcGetSystemInfo(&mem_used, 0, 1);
__linear_heap_size_local = CTR_LINEAR_HEAP_SIZE;
__heap_size_local = (0x4000000 - mem_used - __linear_heap_size_local - 0x1000) & 0xFFFFF000;
// Allocate the application heap
__heapBase = 0x08000000;
svcControlMemory(&tmp, __heapBase, 0x0, __heap_size_local, MEMOP_ALLOC, MEMPERM_READ | MEMPERM_WRITE);
// Allocate the linear heap
svcControlMemory(&__linear_heap, 0x0, 0x0, __linear_heap_size_local, MEMOP_ALLOC_LINEAR, MEMPERM_READ | MEMPERM_WRITE);
// Set up newlib heap
fake_heap_start = (char*)__heapBase;
fake_heap_end = fake_heap_start + __heap_size_local;
}
void __attribute__((noreturn)) __libctru_exit(int rc)
{
u32 tmp=0;
// Unmap the linear heap
svcControlMemory(&tmp, __linear_heap, 0x0, __linear_heap_size_local, MEMOP_FREE, 0x0);
// Unmap the application heap
svcControlMemory(&tmp, __heapBase, 0x0, __heap_size_local, MEMOP_FREE, 0x0);
// Close some handles
__destroy_handle_list();
// Jump to the loader if it provided a callback
if (__system_retAddr)
__system_retAddr();
// Since above did not jump, end this process
svcExitProcess();
}
static void frontend_ctr_get_environment_settings(int *argc, char *argv[],
void *args, void *params_data)
{
@ -77,6 +140,8 @@ static void frontend_ctr_get_environment_settings(int *argc, char *argv[],
"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.dir.remap, g_defaults.dir.port,
"remaps", sizeof(g_defaults.dir.remap));
fill_pathname_join(g_defaults.path.config, g_defaults.dir.port,
"retroarch.cfg", sizeof(g_defaults.path.config));
@ -199,12 +264,32 @@ void wait_for_input(void)
break;
if (kDown & KEY_SELECT)
exit(0);
#if 0
select_pressed = true;
#endif
rarch_sleep(1);
retro_sleep(1);
}
}
int usleep (useconds_t us)
{
svcSleepThread((int64_t)us * 1000);
}
long sysconf(int name)
{
switch(name)
{
case _SC_NPROCESSORS_ONLN:
return 2;
}
return -1;
}
enum frontend_architecture frontend_ctr_get_architecture(void)
{
return FRONTEND_ARCH_ARM;

View File

@ -16,8 +16,10 @@
*/
#include <emscripten/emscripten.h>
#include "../../general.h"
#include <file/config_file.h>
#include "../../general.h"
#include "../../content.h"
#include "../frontend.h"
#include "../../retroarch.h"
@ -30,7 +32,7 @@ static void emscripten_mainloop(void)
unsigned sleep_ms = 0;
int ret = rarch_main_iterate(&sleep_ms);
if (ret == 1 && sleep_ms > 0)
rarch_sleep(sleep_ms);
retro_sleep(sleep_ms);
rarch_main_data_iterate();
if (ret != -1)
return;

View File

@ -24,7 +24,7 @@
#if defined(HW_RVL) && !defined(IS_SALAMANDER)
#include <ogc/mutex.h>
#include <ogc/cond.h>
#include "../../wii/mem2_manager.h"
#include "../../memory/wii/mem2_manager.h"
#endif
#include <boolean.h>

File diff suppressed because it is too large Load Diff

View File

@ -15,9 +15,44 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _PLATFORM_ANDROID_H
#define _PLATFORM_ANDROID_H
#ifndef _PLATFORM_LINUX_H
#define _PLATFORM_LINUX_H
#include <stdint.h>
#include <sys/cdefs.h>
typedef enum
{
CPU_FAMILY_UNKNOWN = 0,
CPU_FAMILY_ARM,
CPU_FAMILY_X86,
CPU_FAMILY_MIPS,
CPU_FAMILY_MAX /* do not remove */
} cpu_family;
enum
{
CPU_ARM_FEATURE_ARMv7 = (1 << 0),
CPU_ARM_FEATURE_VFPv3 = (1 << 1),
CPU_ARM_FEATURE_NEON = (1 << 2),
CPU_ARM_FEATURE_LDREX_STREX = (1 << 3)
};
enum
{
CPU_X86_FEATURE_SSSE3 = (1 << 0),
CPU_X86_FEATURE_POPCNT = (1 << 1),
CPU_X86_FEATURE_MOVBE = (1 << 2)
};
cpu_family linux_get_cpu_family(void);
uint64_t linux_get_cpu_features(void);
int linux_get_cpu_count(void);
#ifdef ANDROID
#include <jni.h>
#include <poll.h>
#include <sched.h>
@ -237,5 +272,7 @@ enum
extern JNIEnv *jni_thread_getenv(void);
extern struct android_app *g_android;
#else
#endif
#endif /* _PLATFORM_ANDROID_H */
#endif

View File

@ -15,7 +15,6 @@
*/
#include <stdint.h>
#include <boolean.h>
#include <stddef.h>
#include <string.h>
@ -32,6 +31,7 @@ int scePowerSetArmClockFrequency(int freq);
#include <pspsdk.h>
#endif
#include <boolean.h>
#include <retro_log.h>
#include <file/file_path.h>
#ifndef IS_SALAMANDER
@ -43,12 +43,13 @@ int scePowerSetArmClockFrequency(int freq);
#if defined(HAVE_KERNEL_PRX) || defined(IS_SALAMANDER)
#ifndef VITA
#include "../../psp1/kernel_functions.h"
#include "../../bootstrap/psp1/kernel_functions.h"
#endif
#endif
#ifdef VITA
PSP2_MODULE_INFO(0, 0, "RetroArch");
int _newlib_heap_size_user = 64 * 1024 * 1024;
#else
PSP_MODULE_INFO("RetroArch", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER|THREAD_ATTR_VFPU);
@ -71,6 +72,7 @@ static void frontend_psp_get_environment_settings(int *argc, char *argv[],
void *args, void *params_data)
{
struct rarch_main_wrap *params = NULL;
char buf[PATH_MAX_LENGTH] = {0};
(void)args;
@ -110,9 +112,9 @@ static void frontend_psp_get_environment_settings(int *argc, char *argv[],
"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,
fill_pathname_join(g_defaults.dir.cheats, g_defaults.dir.port,
"cheats", sizeof(g_defaults.dir.cheats));
fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.remap,
fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.port,
"remaps", sizeof(g_defaults.dir.remap));
#ifdef VITA

View File

@ -14,12 +14,14 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <bps/bps.h>
#include <stdint.h>
#include <boolean.h>
#include <stddef.h>
#include <string.h>
#include <bps/bps.h>
#include <boolean.h>
#include "../../dynamic.h"
#include "../../libretro_private.h"

View File

@ -18,18 +18,21 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fat.h>
#include <gctypes.h>
#include <ogc/cache.h>
#include "../../gfx/drivers/ppc_asm.h"
#include <ogc/system.h>
#include <ogc/usbstorage.h>
#include <sdcard/wiisd_io.h>
#include <retro_log.h>
#include <retro_file.h>
#include <file/file_path.h>
#include <retro_miscellaneous.h>
#include "../../gfx/drivers/ppc_asm.h"
#define EXECUTE_ADDR ((uint8_t *) 0x91800000)
#define BOOTER_ADDR ((uint8_t *) 0x93000000)
#define ARGS_ADDR ((uint8_t *) 0x93200000)
@ -46,10 +49,9 @@ char gx_rom_path[PATH_MAX_LENGTH];
static void dol_copy_argv_path(const char *dolpath, const char *argpath)
{
char tmp[PATH_MAX_LENGTH];
size_t t_len;
size_t t_len, len = 0;
struct __argv *argv = (struct __argv *)ARGS_ADDR;
char *cmdline = NULL;
size_t len = 0;
memset(ARGS_ADDR, 0, sizeof(struct __argv));
@ -113,11 +115,11 @@ static void dol_copy_argv_path(const char *dolpath, const char *argpath)
* heap memory and are restricted to the stack only. */
void system_exec_wii(const char *_path, bool should_load_game)
{
FILE *fp;
size_t size, booter_size;
void *dol;
size_t booter_size;
ssize_t length;
char path[PATH_MAX_LENGTH];
char game_path[PATH_MAX_LENGTH];
void *dol = NULL;
#ifndef IS_SALAMANDER
global_t *global = global_get_ptr();
bool original_verbose = global->verbosity;
@ -137,30 +139,12 @@ void system_exec_wii(const char *_path, bool should_load_game)
}
RARCH_LOG("Attempt to load executable: [%s]\n", path);
fp = fopen(path, "rb");
if (fp == NULL)
if (retro_read_file(path, dol, &length) != 1)
{
RARCH_ERR("Could not open DOL file %s.\n", path);
goto exit;
}
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
/* try to allocate a buffer for it. if we can't, fail. */
dol = malloc(size);
if (!dol)
{
RARCH_ERR("Could not execute DOL file %s.\n", path);
fclose(fp);
goto exit;
}
fread(dol, 1, size, fp);
fclose(fp);
fatUnmount("carda:");
fatUnmount("cardb:");
fatUnmount("sd:");
@ -169,8 +153,8 @@ void system_exec_wii(const char *_path, bool should_load_game)
__io_usbstorage.shutdown();
/* don't use memcpy, there might be an overlap. */
memmove(EXECUTE_ADDR, dol, size);
DCFlushRange(EXECUTE_ADDR, size);
memmove(EXECUTE_ADDR, dol, length);
DCFlushRange(EXECUTE_ADDR, length);
dol_copy_argv_path(path, should_load_game ? game_path : NULL);

View File

@ -13,12 +13,12 @@
*/
#include <stdint.h>
#include <boolean.h>
#include <stddef.h>
#include <string.h>
#include <windows.h>
#include <boolean.h>
#include <retro_miscellaneous.h>
#include <dynamic/dylib.h>
#include <file/file_list.h>

View File

@ -19,6 +19,7 @@
#include <xtl.h>
#include <xbdm.h>
#include <xgraphics.h>
#include <file/file_path.h>
#ifndef IS_SALAMANDER
@ -33,7 +34,6 @@ static bool exit_spawn;
static bool exitspawn_start_game;
#ifdef _XBOX360
typedef struct _STRING
{
USHORT Length;
@ -425,3 +425,264 @@ frontend_ctx_driver_t frontend_ctx_xdk = {
frontend_xdk_parse_drive_list,
"xdk",
};
#ifdef _XBOX360
struct XPR_HEADER
{
DWORD dwMagic;
DWORD dwHeaderSize;
DWORD dwDataSize;
};
#endif
#define XPR0_MAGIC_VALUE 0x30525058
#define XPR1_MAGIC_VALUE 0x31525058
#define XPR2_MAGIC_VALUE 0x58505232
PackedResource::PackedResource()
{
m_pSysMemData = NULL;
m_dwSysMemDataSize = 0L;
m_pVidMemData = NULL;
m_dwVidMemDataSize = 0L;
m_pResourceTags = NULL;
m_dwNumResourceTags = 0L;
m_bInitialized = FALSE;
}
PackedResource::~PackedResource()
{
Destroy();
}
void *PackedResource::GetData(const char *strName) const
{
if (m_pResourceTags == NULL || strName == NULL)
return NULL;
#if defined(_XBOX1)
for (DWORD i=0; m_pResourceTags[i].strName; i++)
#elif defined(_XBOX360)
for (DWORD i = 0; i < m_dwNumResourceTags; i++)
#endif
{
if (!strcasecmp(strName, m_pResourceTags[i].strName))
return &m_pSysMemData[m_pResourceTags[i].dwOffset];
}
return NULL;
}
static INLINE void* AllocateContiguousMemory(DWORD Size, DWORD Alignment)
{
#if defined(_XBOX1)
return D3D_AllocContiguousMemory(Size, Alignment);
#elif defined(_XBOX360)
return XMemAlloc(Size, MAKE_XALLOC_ATTRIBUTES(0, 0, 0, 0, eXALLOCAllocatorId_GameMax,
Alignment, XALLOC_MEMPROTECT_WRITECOMBINE, 0, XALLOC_MEMTYPE_PHYSICAL));
#endif
}
static INLINE void FreeContiguousMemory(void* pData)
{
#if defined(_XBOX1)
return D3D_FreeContiguousMemory(pData);
#elif defined(_XBOX360)
return XMemFree(pData, MAKE_XALLOC_ATTRIBUTES(0, 0, 0, 0, eXALLOCAllocatorId_GameMax,
0, 0, 0, XALLOC_MEMTYPE_PHYSICAL));
#endif
}
#ifdef _XBOX1
char g_strMediaPath[512] = "D:\\Media\\";
static HRESULT FindMediaFile(char *strPath, const char *strFilename, size_t strPathsize)
{
if(strFilename == NULL || strPath == NULL)
return E_INVALIDARG;
strlcpy(strPath, strFilename, strPathsize);
if(strFilename[1] != ':')
snprintf(strPath, strPathsize, "%s%s", g_strMediaPath, strFilename);
HANDLE hFile = CreateFile(strPath, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE)
return 0x82000004;
CloseHandle(hFile);
return S_OK;
}
#endif
#if defined(_XBOX1)
HRESULT PackedResource::Create(const char *strFilename,
DWORD dwNumResourceTags, XBRESOURCE* pResourceTags)
#elif defined(_XBOX360)
HRESULT PackedResource::Create(const char *strFilename)
#endif
{
HANDLE hFile;
DWORD dwNumBytesRead;
XPR_HEADER xprh;
bool retval;
#ifdef _XBOX1
BOOL bHasResourceOffsetsTable = FALSE;
char strResourcePath[512];
if (FAILED(FindMediaFile(strResourcePath, strFilename, sizeof(strResourcePath))))
return E_FAIL;
strFilename = strResourcePath;
#endif
hFile = CreateFile(strFilename, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
if (hFile == INVALID_HANDLE_VALUE)
return E_FAIL;
retval = ReadFile(hFile, &xprh, sizeof(XPR_HEADER), &dwNumBytesRead, NULL);
#if defined(_XBOX1)
if(xprh.dwMagic == XPR0_MAGIC_VALUE)
bHasResourceOffsetsTable = FALSE;
else if(xprh.dwMagic == XPR1_MAGIC_VALUE)
bHasResourceOffsetsTable = TRUE;
else
#elif defined(_XBOX360)
if(!retval)
{
CloseHandle(hFile);
return E_FAIL;
}
if (xprh.dwMagic != XPR2_MAGIC_VALUE)
#endif
{
CloseHandle(hFile);
return E_FAIL;
}
// Compute memory requirements
#if defined(_XBOX1)
m_dwSysMemDataSize = xprh.dwHeaderSize - sizeof(XPR_HEADER);
m_dwVidMemDataSize = xprh.dwTotalSize - xprh.dwHeaderSize;
#elif defined(_XBOX360)
m_dwSysMemDataSize = xprh.dwHeaderSize;
m_dwVidMemDataSize = xprh.dwDataSize;
#endif
// Allocate memory
m_pSysMemData = (BYTE*)malloc(m_dwSysMemDataSize);
if (m_pSysMemData == NULL)
{
m_dwSysMemDataSize = 0;
return E_FAIL;
}
m_pVidMemData = (BYTE*)AllocateContiguousMemory(m_dwVidMemDataSize,
#if defined(_XBOX1)
D3DTEXTURE_ALIGNMENT
#elif defined(_XBOX360)
XALLOC_PHYSICAL_ALIGNMENT_4K
#endif
);
if(m_pVidMemData == NULL)
{
m_dwSysMemDataSize = 0;
m_dwVidMemDataSize = 0;
free(m_pSysMemData);
m_pSysMemData = NULL;
return E_FAIL;
}
// Read in the data from the file
if( !ReadFile( hFile, m_pSysMemData, m_dwSysMemDataSize, &dwNumBytesRead, NULL) ||
!ReadFile( hFile, m_pVidMemData, m_dwVidMemDataSize, &dwNumBytesRead, NULL))
{
CloseHandle( hFile);
return E_FAIL;
}
// Done with the file
CloseHandle( hFile);
#ifdef _XBOX1
if (bHasResourceOffsetsTable)
{
#endif
// Extract resource table from the header data
m_dwNumResourceTags = *(DWORD*)(m_pSysMemData + 0);
m_pResourceTags = (XBRESOURCE*)(m_pSysMemData + 4);
// Patch up the resources
for(DWORD i = 0; i < m_dwNumResourceTags; i++)
{
m_pResourceTags[i].strName = (char*)(m_pSysMemData + (DWORD)m_pResourceTags[i].strName);
#ifdef _XBOX360
if((m_pResourceTags[i].dwType & 0xffff0000) == (RESOURCETYPE_TEXTURE & 0xffff0000))
{
D3DTexture *pTexture = (D3DTexture*)&m_pSysMemData[m_pResourceTags[i].dwOffset];
XGOffsetBaseTextureAddress(pTexture, m_pVidMemData, m_pVidMemData);
}
#endif
}
#ifdef _XBOX1
}
#endif
#ifdef _XBOX1
// Use user-supplied number of resources and the resource tags
if(dwNumResourceTags != 0 || pResourceTags != NULL)
{
m_pResourceTags = pResourceTags;
m_dwNumResourceTags = dwNumResourceTags;
}
#endif
m_bInitialized = TRUE;
return S_OK;
}
#ifdef _XBOX360
void PackedResource::GetResourceTags(DWORD* pdwNumResourceTags,
XBRESOURCE** ppResourceTags)
{
if (pdwNumResourceTags)
(*pdwNumResourceTags) = m_dwNumResourceTags;
if (ppResourceTags)
(*ppResourceTags) = m_pResourceTags;
}
#endif
void PackedResource::Destroy()
{
free(m_pSysMemData);
m_pSysMemData = NULL;
m_dwSysMemDataSize = 0L;
if (m_pVidMemData != NULL)
FreeContiguousMemory(m_pVidMemData);
m_pVidMemData = NULL;
m_dwVidMemDataSize = 0L;
m_pResourceTags = NULL;
m_dwNumResourceTags = 0L;
m_bInitialized = FALSE;
}
BOOL PackedResource::Initialized() const
{
return m_bInitialized;
}

View File

@ -988,4 +988,111 @@ extern "C"
#endif
DWORD XBResource_SizeOf( LPDIRECT3DRESOURCE pResource );
//structure member offsets matter
struct XBRESOURCE
{
#if defined(_XBOX1)
char *strName;
DWORD dwOffset;
#elif defined(_XBOX360)
DWORD dwType;
DWORD dwOffset;
DWORD dwSize;
char *strName;
#endif
};
enum
{
RESOURCETYPE_USERDATA = ( ( 'U' << 24 ) | ( 'S' << 16 ) | ( 'E' << 8 ) | ( 'R' ) ),
RESOURCETYPE_TEXTURE = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( '2' << 8 ) | ( 'D' ) ),
RESOURCETYPE_VERTEXBUFFER = ( ( 'V' << 24 ) | ( 'B' << 16 ) | ( 'U' << 8 ) | ( 'F' ) ),
RESOURCETYPE_INDEXBUFFER = ( ( 'I' << 24 ) | ( 'B' << 16 ) | ( 'U' << 8 ) | ( 'F' ) ),
RESOURCETYPE_EOF = 0xffffffff
};
class PackedResource
{
protected:
BYTE* m_pSysMemData; // Alloc'ed memory for resource headers etc.
DWORD m_dwSysMemDataSize;
BYTE* m_pVidMemData; // Alloc'ed memory for resource data, etc.
DWORD m_dwVidMemDataSize;
XBRESOURCE* m_pResourceTags; // Tags to associate names with the resources
DWORD m_dwNumResourceTags; // Number of resource tags
BOOL m_bInitialized; // Resource is fully initialized
public:
// Loads the resources out of the specified bundle
#if defined(_XBOX1)
HRESULT Create( const char *strFilename, DWORD dwNumResourceTags = 0L,
XBRESOURCE* pResourceTags = NULL );
#elif defined(_XBOX360)
HRESULT Create( const char * strFilename );
#endif
void Destroy();
BOOL Initialized() const;
#ifdef _XBOX360
// Retrieves the resource tags
void GetResourceTags( DWORD* pdwNumResourceTags, XBRESOURCE** ppResourceTags );
#endif
// Helper function to make sure a resource is registered
LPDIRECT3DRESOURCE RegisterResource( LPDIRECT3DRESOURCE pResource ) const
{
#ifdef _XBOX1
// Register the resource, if it has not yet been registered. We mark
// a resource as registered by upping it's reference count.
if( pResource && ( pResource->Common & D3DCOMMON_REFCOUNT_MASK ) == 1 )
{
// Special case CPU-copy push buffers (which live in system memory)
if( ( pResource->Common & D3DCOMMON_TYPE_PUSHBUFFER ) &&
( pResource->Common & D3DPUSHBUFFER_RUN_USING_CPU_COPY ) )
pResource->Data += (DWORD)m_pSysMemData;
else
pResource->Register( m_pVidMemData );
pResource->AddRef();
}
#endif
return pResource;
}
// Functions to retrieve resources by their offset
void *GetData( DWORD dwOffset ) const
{ return &m_pSysMemData[dwOffset]; }
LPDIRECT3DRESOURCE GetResource( DWORD dwOffset ) const
{ return RegisterResource( (LPDIRECT3DRESOURCE)GetData(dwOffset) ); }
LPDIRECT3DTEXTURE GetTexture( DWORD dwOffset ) const
{ return (LPDIRECT3DTEXTURE)GetResource( dwOffset ); }
LPDIRECT3DVERTEXBUFFER GetVertexBuffer( DWORD dwOffset ) const
{ return (LPDIRECT3DVERTEXBUFFER)GetResource( dwOffset ); }
// Functions to retrieve resources by their name
void *GetData( const char* strName ) const;
LPDIRECT3DRESOURCE GetResource( const char* strName ) const
{ return RegisterResource( (LPDIRECT3DRESOURCE)GetData( strName ) ); }
LPDIRECT3DTEXTURE GetTexture( const char* strName ) const
{ return (LPDIRECT3DTEXTURE)GetResource( strName ); }
LPDIRECT3DVERTEXBUFFER GetVertexBuffer( const char* strName ) const
{ return (LPDIRECT3DVERTEXBUFFER)GetResource( strName ); }
// Constructor/destructor
PackedResource();
~PackedResource();
};
#endif // __XBOX_INTERNAL_H__

View File

@ -15,21 +15,23 @@
*/
#include <stdint.h>
#include <boolean.h>
#include <stddef.h>
#include <string.h>
#include <time/time.h>
#include <debug.h>
#include <xenos/xenos.h>
#include <diskio/ata.h>
#include <input/input.h>
#include <console/console.h>
#include <usb/usbmain.h>
#include <time/time.h>
#include <ppc/timebase.h>
#include <xenon_soc/xenon_power.h>
#include <elf/elf.h>
#include <boolean.h>
#include "../../dynamic.h"
#include "../../libretro_private.h"

View File

@ -16,6 +16,7 @@
*/
#include <file/file_path.h>
#include <retro_stat.h>
#include "frontend.h"
#include "../system.h"
@ -345,7 +346,7 @@ int rarch_main(int argc, char *argv[], void *data)
ret = rarch_main_iterate(&sleep_ms);
if (ret == 1 && sleep_ms > 0)
rarch_sleep(sleep_ms);
retro_sleep(sleep_ms);
rarch_main_data_iterate();
}while(ret != -1);

View File

@ -38,10 +38,7 @@ static frontend_ctx_driver_t *frontend_ctx_drivers[] = {
#if defined(__APPLE__) && defined(__MACH__)
&frontend_ctx_darwin,
#endif
#if defined(ANDROID)
&frontend_ctx_android,
#endif
#if defined(__linux__) && !defined(ANDROID)
#if defined(__linux__)
&frontend_ctx_linux,
#endif
#if defined(PSP) || defined(VITA)

View File

@ -81,7 +81,6 @@ extern frontend_ctx_driver_t frontend_ctx_ps3;
extern frontend_ctx_driver_t frontend_ctx_xdk;
extern frontend_ctx_driver_t frontend_ctx_qnx;
extern frontend_ctx_driver_t frontend_ctx_darwin;
extern frontend_ctx_driver_t frontend_ctx_android;
extern frontend_ctx_driver_t frontend_ctx_linux;
extern frontend_ctx_driver_t frontend_ctx_psp;
extern frontend_ctx_driver_t frontend_ctx_ctr;

View File

@ -158,7 +158,7 @@ static INLINE void rarch_fail(int error_code, const char *error)
* just exit right away. */
rarch_assert(global->inited.error);
strcpy(global->error_string, error);
strlcpy(global->error_string, error, sizeof(global->error_string));
longjmp(global->error_sjlj_context, error_code);
}

View File

@ -17,6 +17,7 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <sys/types.h>
#include <sys/wait.h>

View File

@ -1628,6 +1628,7 @@ static bool d3d_frame(void *data, const void *frame,
{
unsigned width, height;
D3DVIEWPORT screen_vp;
static struct retro_perf_counter d3d_frame = {0};
unsigned i = 0;
d3d_video_t *d3d = (d3d_video_t*)data;
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
@ -1642,8 +1643,8 @@ static bool d3d_frame(void *data, const void *frame,
video_driver_get_size(&width, &height);
RARCH_PERFORMANCE_INIT(d3d_frame);
RARCH_PERFORMANCE_START(d3d_frame);
rarch_perf_init(&d3d_frame, "d3d_frame");
retro_perf_start(&d3d_frame);
#ifndef _XBOX
/* We cannot recover in fullscreen. */
@ -1746,7 +1747,7 @@ static bool d3d_frame(void *data, const void *frame,
#endif
#endif
RARCH_PERFORMANCE_STOP(d3d_frame);
retro_perf_stop(&d3d_frame);
gfx_ctx_update_window_title(d3d);
@ -1768,11 +1769,12 @@ static bool d3d_read_viewport(void *data, uint8_t *buffer)
bool ret = true;
d3d_video_t *d3d = (d3d_video_t*)data;
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
static struct retro_perf_counter d3d_read_viewport = {0};
video_driver_get_size(&width, &height);
RARCH_PERFORMANCE_INIT(d3d_read_viewport);
RARCH_PERFORMANCE_START(d3d_read_viewport);
rarch_perf_init(&d3d_read_viewport, "d3d_read_viewport");
retro_perf_start(&d3d_read_viewport);
(void)data;
(void)buffer;
@ -1827,7 +1829,7 @@ static bool d3d_read_viewport(void *data, uint8_t *buffer)
ret = false;
end:
RARCH_PERFORMANCE_STOP(d3d_read_viewport);
retro_perf_stop(&d3d_read_viewport);
if (target)
target->Release();
if (dest)

View File

@ -18,9 +18,13 @@
#include <string.h>
#include <string>
#include <vector>
#include <retro_inline.h>
#include <Cg/cg.h>
#include <Cg/cgD3D9.h>
#include <retro_inline.h>
#include <compat/strl.h>
#include "render_chain_driver.h"
#include "../video_driver.h"
#include "../../general.h"
@ -1166,7 +1170,7 @@ static bool cg_d3d9_renderchain_add_lut(void *data,
info.tex = lut;
info.smooth = smooth;
strcpy(info.id, id);
strlcpy(info.id, id, sizeof(info.id));
if (!lut)
return false;

View File

@ -349,13 +349,14 @@ static bool ctr_frame(void* data, const void* frame,
uint64_t frame_count,
unsigned pitch, const char* msg)
{
ctr_video_t* ctr = (ctr_video_t*)data;
settings_t* settings = config_get_ptr();
uint32_t diff;
static uint64_t currentTick,lastTick;
ctr_video_t *ctr = (ctr_video_t*)data;
settings_t *settings = config_get_ptr();
static float fps = 0.0;
static int total_frames = 0;
static int frames = 0;
static struct retro_perf_counter ctrframe_f = {0};
extern bool select_pressed;
@ -390,7 +391,7 @@ static bool ctr_frame(void* data, const void* frame,
svcClearEvent(gspEvents[GSPEVENT_VBlank0]);
currentTick = svcGetSystemTick();
uint32_t diff = currentTick - lastTick;
diff = currentTick - lastTick;
if(diff > CTR_CPU_TICKS_PER_SECOND)
{
fps = (float)frames * ((float) CTR_CPU_TICKS_PER_SECOND / (float) diff);
@ -401,14 +402,12 @@ static bool ctr_frame(void* data, const void* frame,
printf("fps: %8.4f frames: %i\r", fps, total_frames++);
fflush(stdout);
RARCH_PERFORMANCE_INIT(ctrframe_f);
RARCH_PERFORMANCE_START(ctrframe_f);
rarch_perf_init(&ctrframe_f, "ctrframe_f");
retro_perf_start(&ctrframe_f);
if (ctr->should_resize)
ctr_update_viewport(ctr);
ctrGuSetMemoryFill(true, (u32*)CTR_GPU_FRAMEBUFFER, 0x00000000,
(u32*)(CTR_GPU_FRAMEBUFFER + CTR_TOP_FRAMEBUFFER_WIDTH * CTR_TOP_FRAMEBUFFER_HEIGHT * sizeof(uint32_t)),
0x201, (u32*)CTR_GPU_DEPTHBUFFER, 0x00000000,
@ -435,8 +434,9 @@ static bool ctr_frame(void* data, const void* frame,
else
{
int i;
uint16_t* dst = (uint16_t*)ctr->texture_linear;
const uint8_t* src = frame;
uint16_t *dst = (uint16_t*)ctr->texture_linear;
const uint8_t *src = frame;
for (i = 0; i < height; i++)
{
memcpy(dst, src, width * sizeof(uint16_t));
@ -496,7 +496,7 @@ static bool ctr_frame(void* data, const void* frame,
gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), 240,400,CTRGU_RGB8, CTRGU_MULTISAMPLE_NONE);
gfxSwapBuffersGpu();
RARCH_PERFORMANCE_STOP(ctrframe_f);
retro_perf_stop(&ctrframe_f);
return true;
}

View File

@ -54,7 +54,7 @@ extern Handle gspEvents[GSPEVENT_MAX];
extern u32* gpuCmdBuf;
extern u32 gpuCmdBufOffset;
extern u32 __linear_heap_size;
extern u32* __linear_heap;
extern u32 __linear_heap;
__attribute__((always_inline))
static INLINE void ctrGuSetTexture(GPU_TEXUNIT unit, u32* data,
@ -119,7 +119,7 @@ __attribute__((always_inline))
static INLINE void ctrGuFlushAndRun(bool queued)
{
//take advantage of GX_SetCommandList_First to flush gsp heap
ctrGuSetCommandList_First(queued, gpuCmdBuf, gpuCmdBufOffset*4, __linear_heap, __linear_heap_size, NULL, 0);
ctrGuSetCommandList_First(queued, gpuCmdBuf, gpuCmdBufOffset*4, (u32*)__linear_heap, __linear_heap_size, NULL, 0);
ctrGuSetCommandList_Last(queued, gpuCmdBuf, gpuCmdBufOffset*4, 0x0);
}

View File

@ -1389,8 +1389,10 @@ static void gl_init_textures(gl_t *gl, const video_info_t *video)
static INLINE void gl_copy_frame(gl_t *gl, const void *frame,
unsigned width, unsigned height, unsigned pitch)
{
RARCH_PERFORMANCE_INIT(copy_frame);
RARCH_PERFORMANCE_START(copy_frame);
static struct retro_perf_counter copy_frame = {0};
rarch_perf_init(&copy_frame, "copy_frame");
retro_perf_start(&copy_frame);
#if defined(HAVE_OPENGLES2)
#if defined(HAVE_EGL)
@ -1500,7 +1502,7 @@ static INLINE void gl_copy_frame(gl_t *gl, const void *frame,
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
}
#endif
RARCH_PERFORMANCE_STOP(copy_frame);
retro_perf_stop(&copy_frame);
}
static INLINE void gl_set_prev_texture(gl_t *gl,
@ -1536,6 +1538,8 @@ static INLINE void gl_set_shader_viewport(gl_t *gl, unsigned shader)
#if defined(HAVE_GL_ASYNC_READBACK) && defined(HAVE_MENU)
static void gl_pbo_async_readback(gl_t *gl)
{
static struct retro_perf_counter async_readback = {0};
glBindBuffer(GL_PIXEL_PACK_BUFFER,
gl->pbo_readback[gl->pbo_readback_index++]);
gl->pbo_readback_index &= 3;
@ -1548,8 +1552,8 @@ static void gl_pbo_async_readback(gl_t *gl)
video_pixel_get_alignment(gl->vp.width * sizeof(uint32_t)));
/* Read asynchronously into PBO buffer. */
RARCH_PERFORMANCE_INIT(async_readback);
RARCH_PERFORMANCE_START(async_readback);
rarch_perf_init(&async_readback, "async_readback");
retro_perf_start(&async_readback);
glReadBuffer(GL_BACK);
#ifdef HAVE_OPENGLES3
glReadPixels(gl->vp.x, gl->vp.y,
@ -1560,7 +1564,7 @@ static void gl_pbo_async_readback(gl_t *gl)
gl->vp.width, gl->vp.height,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
#endif
RARCH_PERFORMANCE_STOP(async_readback);
retro_perf_stop(&async_readback);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
}
@ -1629,13 +1633,15 @@ static bool gl_frame(void *data, const void *frame,
unsigned pitch, const char *msg)
{
unsigned width, height;
struct gfx_tex_info feedback_info;
static struct retro_perf_counter frame_run = {0};
gl_t *gl = (gl_t*)data;
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
const struct font_renderer *font_driver = driver ? driver->font_osd_driver : NULL;
RARCH_PERFORMANCE_INIT(frame_run);
RARCH_PERFORMANCE_START(frame_run);
rarch_perf_init(&frame_run, "frame_run");
retro_perf_start(&frame_run);
video_driver_get_size(&width, &height);
@ -1737,7 +1743,8 @@ static bool gl_frame(void *data, const void *frame,
gl->tex_info.tex_size[0] = gl->tex_w;
gl->tex_info.tex_size[1] = gl->tex_h;
struct gfx_tex_info feedback_info = gl->tex_info;
feedback_info = gl->tex_info;
if (gl->fbo_feedback_enable)
{
const struct gfx_fbo_rect *rect = &gl->fbo_rect[gl->fbo_feedback_pass];
@ -1796,7 +1803,7 @@ static bool gl_frame(void *data, const void *frame,
gfx_ctx_update_window_title(gl);
RARCH_PERFORMANCE_STOP(frame_run);
retro_perf_stop(&frame_run);
#ifdef HAVE_FBO
/* Reset state which could easily mess up libretro core. */
@ -1846,8 +1853,10 @@ static bool gl_frame(void *data, const void *frame,
#ifdef HAVE_GL_SYNC
if (settings->video.hard_sync && gl->have_sync)
{
RARCH_PERFORMANCE_INIT(gl_fence);
RARCH_PERFORMANCE_START(gl_fence);
static struct retro_perf_counter gl_fence = {0};
rarch_perf_init(&gl_fence, "gl_fence");
retro_perf_start(&gl_fence);
glClear(GL_COLOR_BUFFER_BIT);
gl->fences[gl->fence_count++] =
glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
@ -1863,7 +1872,7 @@ static bool gl_frame(void *data, const void *frame,
gl->fence_count * sizeof(GLsync));
}
RARCH_PERFORMANCE_STOP(gl_fence);
retro_perf_stop(&gl_fence);
}
#endif
@ -2844,6 +2853,7 @@ static bool gl_read_viewport(void *data, uint8_t *buffer)
#else
static bool gl_read_viewport(void *data, uint8_t *buffer)
{
static struct retro_perf_counter read_viewport = {0};
unsigned num_pixels = 0;
gl_t *gl = (gl_t*)data;
@ -2852,8 +2862,8 @@ static bool gl_read_viewport(void *data, uint8_t *buffer)
context_bind_hw_render(gl, false);
RARCH_PERFORMANCE_INIT(read_viewport);
RARCH_PERFORMANCE_START(read_viewport);
rarch_perf_init(&read_viewport, "read_viewport");
retro_perf_start(&read_viewport);
#ifdef HAVE_GL_ASYNC_READBACK
if (gl->pbo_readback_enable)
@ -2927,7 +2937,7 @@ static bool gl_read_viewport(void *data, uint8_t *buffer)
gl->readback_buffer_screenshot = malloc(num_pixels * sizeof(uint32_t));
if (!gl->readback_buffer_screenshot)
{
RARCH_PERFORMANCE_STOP(read_viewport);
retro_perf_stop(&read_viewport);
goto error;
}
@ -2947,7 +2957,7 @@ static bool gl_read_viewport(void *data, uint8_t *buffer)
gl->readback_buffer_screenshot = NULL;
}
RARCH_PERFORMANCE_STOP(read_viewport);
retro_perf_stop(&read_viewport);
context_bind_hw_render(gl, true);
return true;

View File

@ -14,6 +14,14 @@
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#include <gccore.h>
#include <ogcsys.h>
#include <retro_file.h>
#include "../../driver.h"
#include "../../general.h"
@ -24,15 +32,9 @@
#include "../video_monitor.h"
#ifdef HW_RVL
#include "../../wii/mem2_manager.h"
#include "../../memory/wii/mem2_manager.h"
#endif
#include <gccore.h>
#include <ogcsys.h>
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#include "ppc_asm.h"
#include "gx_gfx_inl.h"
#include "../../defines/gx_defines.h"
@ -600,19 +602,19 @@ static void build_disp_list(void)
static void gx_efb_screenshot(void)
{
int x, y;
uint8_t tga_header[] = {0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0xE0, 0x01, 0x18, 0x00};
FILE *out = fopen("/screenshot.tga", "wb");
RFILE *out = retro_fopen("/screenshot.tga", RFILE_MODE_WRITE, -1);
if (!out)
return;
fwrite(tga_header, 1, sizeof(tga_header), out);
retro_fwrite(out, tga_header, sizeof(tga_header));
for (y = 479; y >= 0; --y)
{
uint8_t line[640 * 3];
unsigned i = 0;
for (x = 0; x < 640; x++)
{
GXColor color;
@ -621,10 +623,10 @@ static void gx_efb_screenshot(void)
line[i++] = color.g;
line[i++] = color.r;
}
fwrite(line, 1, sizeof(line), out);
retro_fwrite(out, line, sizeof(line));
}
fclose(out);
retro_fclose(out);
}
#endif
@ -1035,6 +1037,7 @@ static bool gx_frame(void *data, const void *frame,
uint64_t frame_count, unsigned pitch,
const char *msg)
{
static struct retro_perf_counter gx_frame = {0};
char fps_txt[128] = {0};
char fps_text_buf[128] = {0};
gx_video_t *gx = (gx_video_t*)data;
@ -1042,8 +1045,8 @@ static bool gx_frame(void *data, const void *frame,
u8 clear_efb = GX_FALSE;
settings_t *settings = config_get_ptr();
RARCH_PERFORMANCE_INIT(gx_frame);
RARCH_PERFORMANCE_START(gx_frame);
rarch_perf_init(&gx_frame, "gx_frame");
retro_perf_start(&gx_frame);
if(!gx || (!frame && !gx->menu_texture_enable))
return true;
@ -1076,8 +1079,10 @@ static bool gx_frame(void *data, const void *frame,
if (frame)
{
RARCH_PERFORMANCE_INIT(gx_frame_convert);
RARCH_PERFORMANCE_START(gx_frame_convert);
static struct retro_perf_counter gx_frame_convert = {0};
rarch_perf_init(&gx_frame_convert, "gx_frame_convert");
retro_perf_start(&gx_frame_convert);
if (gx->rgb32)
convert_texture32(frame, g_tex.data, width, height, pitch);
@ -1087,7 +1092,7 @@ static bool gx_frame(void *data, const void *frame,
convert_texture16(frame, g_tex.data, width, height, pitch);
DCFlushRange(g_tex.data, height * (width << (gx->rgb32 ? 2 : 1)));
RARCH_PERFORMANCE_STOP(gx_frame_convert);
retro_perf_stop(&gx_frame_convert);
}
if (gx->menu_texture_enable && gx->menu_data)
@ -1164,7 +1169,7 @@ static bool gx_frame(void *data, const void *frame,
VISetNextFrameBuffer(g_framebuf[g_current_framebuf]);
VIFlush();
RARCH_PERFORMANCE_STOP(gx_frame);
retro_perf_stop(&gx_frame);
return true;
}

View File

@ -37,11 +37,14 @@
*
****************************************************************************************/
#include <stdint.h>
#include <string.h>
#include <gccore.h>
#include <ogcsys.h>
#include "../gfx/drivers/ppc_asm.h"
#include <retro_inline.h>
#include <retro_miscellaneous.h>
#include "../../gfx/drivers/ppc_asm.h"
/****************************************************************************
* I2C driver by Hector Martin (marcan)
@ -61,21 +64,19 @@ static vu32* const _i2cReg = (u32*)0xCD800000;
static INLINE void __viOpenI2C(u32 channel)
{
u32 val = ((_i2cReg[49]&~0x8000)|0x4000);
val |= _SHIFTL(channel,15,1);
u32 val = ((_i2cReg[49]&~0x8000)|0x4000) | _SHIFTL(channel,15,1);
_i2cReg[49] = val;
}
static INLINE void __viSetSCL(u32 channel)
{
u32 val = (_i2cReg[48]&~0x4000);
val |= _SHIFTL(channel,14,1);
u32 val = (_i2cReg[48]&~0x4000) | _SHIFTL(channel,14,1);
_i2cReg[48] = val;
}
static INLINE void __viSetSDA(u32 channel)
{
u32 val = (_i2cReg[48]&~0x8000);
val |= _SHIFTL(channel,15,1);
u32 val = (_i2cReg[48]&~0x8000) | _SHIFTL(channel,15,1);
_i2cReg[48] = val;
}
@ -89,9 +90,12 @@ static u32 __sendSlaveAddress(u8 addr)
udelay(2);
__viSetSCL(0);
for(i=0;i<8;i++) {
if(addr&0x80) __viSetSDA(i2cIdentFlag);
else __viSetSDA(i2cIdentFlag^1);
for(i=0;i<8;i++)
{
if (addr&0x80)
__viSetSDA(i2cIdentFlag);
else
__viSetSDA(i2cIdentFlag^1);
udelay(2);
__viSetSCL(1);
@ -107,7 +111,8 @@ static u32 __sendSlaveAddress(u8 addr)
__viSetSCL(1);
udelay(2);
if(i2cIdentFlag==1 && __viGetSDA()!=0) return 0;
if(i2cIdentFlag==1 && __viGetSDA()!=0)
return 0;
__viSetSDA(i2cIdentFlag^1);
__viOpenI2C(1);
@ -118,25 +123,21 @@ static u32 __sendSlaveAddress(u8 addr)
void VIDEO_SetTrapFilter(bool enable)
{
u8 disable;
u8 data;
u8 reg;
void *val;
u8 buf[2];
s32 i,j;
u32 c, level, ret;
disable = !enable;
data = !disable;
reg = 0x03;
u8 disable = !enable;
u8 data = !disable;
u8 reg = 0x03;
u8 addr = 0xe0;
u32 len = 2;
buf[0] = reg;
buf[1] = data;
u8 addr = 0xe0;
void* val = buf;
u32 len = 2;
u8 c;
s32 i,j;
u32 level,ret;
val = buf;
if(i2cIdentFirst==0)
{
@ -165,9 +166,11 @@ void VIDEO_SetTrapFilter(bool enable)
}
__viOpenI2C(1);
for(i=0;i<len;i++) {
for(i=0;i<len;i++)
{
c = ((u8*)val)[i];
for(j=0;j<8;j++) {
for(j=0;j<8;j++)
{
u32 chan = i2cIdentFlag;
if(c&0x80) {}
else
@ -187,7 +190,8 @@ void VIDEO_SetTrapFilter(bool enable)
__viSetSCL(1);
udelay(2);
if(i2cIdentFlag==1 && __viGetSDA()!=0) {
if(i2cIdentFlag==1 && __viGetSDA()!=0)
{
_CPU_ISR_Restore(level);
goto end;
}

View File

@ -463,15 +463,17 @@ static bool psp_frame(void *data, const void *frame,
unsigned width, unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg)
{
#ifdef DISPLAY_FPS
uint32_t diff;
static uint64_t currentTick,lastTick;
static int frames;
static float fps = 0.0;
#endif
static struct retro_perf_counter psp_frame_run = {0};
static char fps_txt[128] = {0};
static char fps_text_buf[128] = {0};
psp1_video_t *psp = (psp1_video_t*)data;
settings_t *settings = config_get_ptr();
#ifdef DISPLAY_FPS
static uint64_t currentTick,lastTick;
static float fps=0.0;
static int frames;
#endif
if (!width || !height)
return false;
@ -510,7 +512,7 @@ static bool psp_frame(void *data, const void *frame,
#ifdef DISPLAY_FPS
frames++;
sceRtcGetCurrentTick(&currentTick);
uint32_t diff = currentTick - lastTick;
diff = currentTick - lastTick;
if(diff > 1000000)
{
fps = (float)frames * 1000000.0 / diff;
@ -524,8 +526,8 @@ static bool psp_frame(void *data, const void *frame,
psp->draw_buffer = FROM_GU_POINTER(sceGuSwapBuffers());
RARCH_PERFORMANCE_INIT(psp_frame_run);
RARCH_PERFORMANCE_START(psp_frame_run);
rarch_perf_init(&psp_frame_run, "psp_frame_run");
retro_perf_start(&psp_frame_run);
if (psp->should_resize)
psp_update_viewport(psp);
@ -558,7 +560,7 @@ static bool psp_frame(void *data, const void *frame,
sceGuFinish();
RARCH_PERFORMANCE_STOP(psp_frame_run);
retro_perf_stop(&psp_frame_run);
if(psp->menu.active)
{

View File

@ -340,11 +340,12 @@ static void sdl_refresh_input_size(sdl2_video_t *vid, bool menu, bool rgb32,
|| target->rgb32 != rgb32 || target->pitch != pitch)
{
unsigned format;
static struct retro_perf_counter sdl_create_texture = {0};
sdl_tex_zero(target);
RARCH_PERFORMANCE_INIT(sdl_create_texture);
RARCH_PERFORMANCE_START(sdl_create_texture);
rarch_perf_init(&sdl_create_texture, "sdl_create_texture");
retro_perf_start(&sdl_create_texture);
if (menu)
format = rgb32 ? SDL_PIXELFORMAT_ARGB8888 : SDL_PIXELFORMAT_RGBA4444;
@ -358,7 +359,7 @@ static void sdl_refresh_input_size(sdl2_video_t *vid, bool menu, bool rgb32,
target->tex = SDL_CreateTexture(vid->renderer, format,
SDL_TEXTUREACCESS_STREAMING, width, height);
RARCH_PERFORMANCE_STOP(sdl_create_texture);
retro_perf_stop(&sdl_create_texture);
if (!target->tex)
{
@ -502,14 +503,16 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width,
if (frame)
{
static struct retro_perf_counter sdl_copy_frame = {0};
sdl_refresh_input_size(vid, false, vid->video.rgb32, width, height, pitch);
RARCH_PERFORMANCE_INIT(sdl_copy_frame);
RARCH_PERFORMANCE_START(sdl_copy_frame);
rarch_perf_init(&sdl_copy_frame, "sdl_copy_frame");
retro_perf_start(&sdl_copy_frame);
SDL_UpdateTexture(vid->frame.tex, NULL, frame, pitch);
RARCH_PERFORMANCE_STOP(sdl_copy_frame);
retro_perf_stop(&sdl_copy_frame);
}
SDL_RenderCopyEx(vid->renderer, vid->frame.tex, NULL, NULL, vid->rotation, NULL, SDL_FLIP_NONE);
@ -620,9 +623,10 @@ static bool sdl2_gfx_read_viewport(void *data, uint8_t *buffer)
{
SDL_Surface *surf = NULL, *bgr24 = NULL;
sdl2_video_t *vid = (sdl2_video_t*)data;
static struct retro_perf_counter sdl2_gfx_read_viewport = {0};
RARCH_PERFORMANCE_INIT(sdl2_gfx_read_viewport);
RARCH_PERFORMANCE_START(sdl2_gfx_read_viewport);
rarch_perf_init(&sdl2_gfx_read_viewport, "sdl2_gfx_read_viewport");
retro_perf_start(&sdl2_gfx_read_viewport);
video_driver_cached_frame();
@ -637,7 +641,7 @@ static bool sdl2_gfx_read_viewport(void *data, uint8_t *buffer)
memcpy(buffer, bgr24->pixels, bgr24->h * bgr24->pitch);
RARCH_PERFORMANCE_STOP(sdl2_gfx_read_viewport);
retro_perf_stop(&sdl2_gfx_read_viewport);
return true;
}
@ -695,15 +699,17 @@ static void sdl2_poke_set_texture_frame(void *data, const void *frame, bool rgb3
if (frame)
{
static struct retro_perf_counter copy_texture_frame = {0};
sdl_refresh_input_size(vid, true, rgb32, width, height,
width * (rgb32 ? 4 : 2));
RARCH_PERFORMANCE_INIT(copy_texture_frame);
RARCH_PERFORMANCE_START(copy_texture_frame);
rarch_perf_init(&copy_texture_frame, "copy_texture_frame");
retro_perf_start(&copy_texture_frame);
SDL_UpdateTexture(vid->menu.tex, NULL, frame, vid->menu.pitch);
RARCH_PERFORMANCE_STOP(copy_texture_frame);
retro_perf_stop(&copy_texture_frame);
}
}

View File

@ -349,6 +349,7 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width,
unsigned pitch, const char *msg)
{
char buf[128] = {0};
static struct retro_perf_counter sdl_scale = {0};
sdl_video_t *vid = (sdl_video_t*)data;
if (!frame)
@ -359,10 +360,10 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width,
if (SDL_MUSTLOCK(vid->screen))
SDL_LockSurface(vid->screen);
RARCH_PERFORMANCE_INIT(sdl_scale);
RARCH_PERFORMANCE_START(sdl_scale);
rarch_perf_init(&sdl_scale, "sdl_scale");
retro_perf_start(&sdl_scale);
scaler_ctx_scale(&vid->scaler, vid->screen->pixels, frame);
RARCH_PERFORMANCE_STOP(sdl_scale);
retro_perf_stop(&sdl_scale);
if (vid->menu.active)
SDL_BlitSurface(vid->menu.frame, NULL, vid->screen, NULL);

View File

@ -315,9 +315,11 @@ static bool vg_frame(void *data, const void *frame,
{
unsigned width, height;
vg_t *vg = (vg_t*)data;
static struct retro_perf_counter vg_fr = {0};
static struct retro_perf_counter vg_image = {0};
RARCH_PERFORMANCE_INIT(vg_fr);
RARCH_PERFORMANCE_START(vg_fr);
rarch_perf_init(&vg_fr, "vg_fr");
retro_perf_start(&vg_fr);
video_driver_get_size(&width, &height);
@ -341,10 +343,10 @@ static bool vg_frame(void *data, const void *frame,
vgClear(0, 0, width, height);
vgSeti(VG_SCISSORING, VG_TRUE);
RARCH_PERFORMANCE_INIT(vg_image);
RARCH_PERFORMANCE_START(vg_image);
rarch_perf_init(&vg_image, "vg_image");
retro_perf_start(&vg_image);
vg_copy_frame(vg, frame, frame_width, frame_height, pitch);
RARCH_PERFORMANCE_STOP(vg_image);
retro_perf_stop(&vg_image);
vgDrawImage(vg->mImage);
@ -355,7 +357,7 @@ static bool vg_frame(void *data, const void *frame,
gfx_ctx_update_window_title(vg);
RARCH_PERFORMANCE_STOP(vg_fr);
retro_perf_stop(&vg_fr);
gfx_ctx_swap_buffers(vg);

View File

@ -71,7 +71,7 @@ static void *vita2d_gfx_init(const video_info_t *video,
RARCH_SCALE_BASE, video->input_scale, RARCH_SCALE_BASE * video->input_scale);
vita2d_init();
vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));
vita2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF));
vita2d_set_vblank_wait(video->vsync);
if (vita->rgb32)
@ -142,7 +142,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
vita->width = width;
vita->height = height;
vita->texture = vita2d_create_empty_texture_format(width, height, vita->format);
vita2d_texture_set_texture_filter(vita->texture,vita->tex_filter);
vita2d_texture_set_filters(vita->texture,vita->tex_filter,vita->tex_filter);
}
tex_p = vita2d_texture_get_datap(vita->texture);
stride = vita2d_texture_get_stride(vita->texture);
@ -424,7 +424,7 @@ static void vita_set_filtering(void *data, unsigned index, bool smooth)
if (vita)
{
vita->tex_filter = smooth? SCE_GXM_TEXTURE_FILTER_LINEAR : SCE_GXM_TEXTURE_FILTER_POINT;
vita2d_texture_set_texture_filter(vita->texture,vita->tex_filter);
vita2d_texture_set_filters(vita->texture,vita->tex_filter,vita->tex_filter);
}
}
@ -499,7 +499,7 @@ static void vita_set_texture_frame(void *data, const void *frame, bool rgb32,
vita->menu.width = width;
vita->menu.height = height;
}
vita2d_texture_set_texture_filter(vita->menu.texture,SCE_GXM_TEXTURE_FILTER_LINEAR);
vita2d_texture_set_filters(vita->menu.texture,SCE_GXM_TEXTURE_FILTER_LINEAR,SCE_GXM_TEXTURE_FILTER_LINEAR);
tex_p = vita2d_texture_get_datap(vita->menu.texture);
stride = vita2d_texture_get_stride(vita->menu.texture);

View File

@ -13,6 +13,12 @@
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <EGL/egl.h>
#include <sys/system_properties.h>
#include <formats/image.h>
#include "../../driver.h"
#include "../../general.h"
@ -20,12 +26,7 @@
#include "../video_monitor.h"
#include "../drivers/gl_common.h"
#include <EGL/egl.h>
#include "../../frontend/drivers/platform_android.h"
#include <formats/image.h>
#include <stdint.h>
#include "../../frontend/drivers/platform_linux.h"
/* forward declaration */
int system_property_get(const char *name, char *value);

View File

@ -14,24 +14,25 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include <bps/screen.h>
#include <bps/navigator.h>
#include <bps/event.h>
#include <screen/screen.h>
#include <sys/platform.h>
#include "../../driver.h"
#include "../../general.h"
#include "../../runloop.h"
#include "../video_monitor.h"
#include "../drivers/gl_common.h"
#include <EGL/egl.h>
#include <bps/screen.h>
#include <bps/navigator.h>
#include <bps/event.h>
#include <screen/screen.h>
#include <sys/platform.h>
#include <GLES2/gl2.h>
#include "../image/image.h"
#include <stdint.h>
#ifdef HAVE_GLSL
#include "../shader_glsl.h"
#endif

View File

@ -18,6 +18,10 @@
Based on http://fernlightning.com/doku.php?id=randd:xopengl.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <ApplicationServices/ApplicationServices.h>
#include <OpenGL/CGLTypes.h>
@ -25,10 +29,6 @@
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "../../driver.h"
#include "../../runloop.h"
#include "../../configuration.h"

Some files were not shown because too many files have changed in this diff Show More