Merge https://github.com/notaz/pcsx_rearmed
authortwinaphex <libretro@gmail.com>
Wed, 3 May 2017 01:55:32 +0000 (03:55 +0200)
committertwinaphex <libretro@gmail.com>
Wed, 3 May 2017 01:55:32 +0000 (03:55 +0200)
84 files changed:
.gitmodules [deleted file]
Makefile
Makefile.libretro
blackberry_qnx/.cproject [deleted file]
blackberry_qnx/.project [deleted file]
debian_maemo/buildpkg [deleted file]
debian_maemo/changelog [deleted file]
debian_maemo/compat [deleted file]
debian_maemo/control [deleted file]
debian_maemo/copyright [deleted file]
debian_maemo/dirs [deleted file]
debian_maemo/docs [deleted file]
debian_maemo/files [deleted file]
debian_maemo/install [deleted file]
debian_maemo/rules [deleted file]
frontend/320240/caanoo.gpe [deleted file]
frontend/320240/haptic_s.cfg [deleted file]
frontend/320240/haptic_w.cfg [deleted file]
frontend/320240/pcsx26.png [deleted file]
frontend/320240/pcsx_rearmed.ini [deleted file]
frontend/320240/pcsxb.png [deleted file]
frontend/320240/pollux_set.c [deleted file]
frontend/320240/skin/background.png [deleted file]
frontend/320240/skin/font.png [deleted file]
frontend/320240/skin/readme.txt [deleted file]
frontend/320240/skin/selector.png [deleted file]
frontend/320240/skin/skin.txt [deleted file]
frontend/320240/ui_gp2x.h [deleted file]
frontend/3ds/3ds_utils.h [new file with mode: 0644]
frontend/3ds/pthread.h [new file with mode: 0644]
frontend/3ds/sys/mman.h [new file with mode: 0644]
frontend/3ds/zconf.h [new file with mode: 0644]
frontend/3ds/zlib.h [new file with mode: 0644]
frontend/libpicofe [deleted submodule]
frontend/libretro.c
frontend/libretro.h
frontend/main.c
frontend/menu.c
frontend/pandora/pcsx.png [deleted file]
frontend/pandora/pcsx.pxml.templ [deleted file]
frontend/pandora/pcsx.sh [deleted file]
frontend/pandora/picorestore.c [deleted file]
frontend/pandora/skin/background.png [deleted file]
frontend/pandora/skin/font.png [deleted file]
frontend/pandora/skin/readme.txt [deleted file]
frontend/pandora/skin/selector.png [deleted file]
frontend/pandora/skin/skin.txt [deleted file]
frontend/pandora/ui_feat.h [deleted file]
frontend/plugin.c
frontend/plugin_lib.c
frontend/plugin_lib.h
frontend/vita/retro_inline.h [new file with mode: 0644]
frontend/vita/sys/mman.h [new file with mode: 0644]
frontend/warm [deleted submodule]
include/psemu_plugin_defs.h
jni/Android.mk
jni/Application.mk
libpcsxcore/cdriso.c
libpcsxcore/gte_neon.S
libpcsxcore/new_dynarec/arm/assem_arm.c [moved from libpcsxcore/new_dynarec/assem_arm.c with 99% similarity]
libpcsxcore/new_dynarec/arm/assem_arm.h [moved from libpcsxcore/new_dynarec/assem_arm.h with 100% similarity]
libpcsxcore/new_dynarec/arm/linkage_arm.S [moved from libpcsxcore/new_dynarec/linkage_arm.S with 99% similarity]
libpcsxcore/new_dynarec/arm/linkage_offsets.h [moved from libpcsxcore/new_dynarec/linkage_offsets.h with 100% similarity]
libpcsxcore/new_dynarec/backends/psx/emu_if.c [moved from libpcsxcore/new_dynarec/emu_if.c with 98% similarity]
libpcsxcore/new_dynarec/backends/psx/emu_if.h [moved from libpcsxcore/new_dynarec/emu_if.h with 96% similarity]
libpcsxcore/new_dynarec/backends/psx/pcsxmem.c [moved from libpcsxcore/new_dynarec/pcsxmem.c with 99% similarity]
libpcsxcore/new_dynarec/backends/psx/pcsxmem.h [moved from libpcsxcore/new_dynarec/pcsxmem.h with 100% similarity]
libpcsxcore/new_dynarec/backends/psx/pcsxmem_inline.c [moved from libpcsxcore/new_dynarec/pcsxmem_inline.c with 100% similarity]
libpcsxcore/new_dynarec/new_dynarec.c
libpcsxcore/new_dynarec/new_dynarec.h
libpcsxcore/new_dynarec/new_dynarec_config.h
libpcsxcore/plugins.c
libpcsxcore/psxbios.c
libpcsxcore/r3000a.c
libpcsxcore/sio.c
libpcsxcore/socket.c
maemo/hildon.c [deleted file]
maemo/maemo_common.h [deleted file]
maemo/maemo_xkb.c [deleted file]
maemo/main.c [deleted file]
plugins/cdrcimg/cdrcimg.c
plugins/dfinput/main.c
plugins/dfinput/pad.c
plugins/dfxvideo/gpulib_if.c

diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644 (file)
index f93599e..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-[submodule "libpicofe"]
-       path = frontend/libpicofe
-       url = git://notaz.gp2x.de/~notaz/libpicofe.git
-[submodule "warm"]
-       path = frontend/warm
-       url = git://notaz.gp2x.de/~notaz/warm.git
index 0a3b1fe..2a6be72 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,10 +2,16 @@
 
 # default stuff goes here, so that config can override
 TARGET ?= pcsx
-CFLAGS += -Wall -ggdb -Iinclude -ffast-math
-ifndef DEBUG
+CFLAGS += -Wall -Iinclude -ffast-math
+ifeq ($(DEBUG), 1)
+CFLAGS += -O0 -ggdb
+else
+ifeq ($(platform), vita)
+CFLAGS += -O3 -DNDEBUG
+else
 CFLAGS += -O2 -DNDEBUG
 endif
+endif
 CXXFLAGS += $(CFLAGS)
 #DRC_DBG = 1
 #PCNT = 1
@@ -56,21 +62,23 @@ libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
 
 # dynarec
 ifeq "$(USE_DYNAREC)" "1"
-OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/linkage_arm.o
-OBJS += libpcsxcore/new_dynarec/pcsxmem.o
+OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/arm/linkage_arm.o
+OBJS += libpcsxcore/new_dynarec/backends/psx/pcsxmem.o
 else
-libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -DDRC_DISABLE
+libpcsxcore/new_dynarec/backends/psx/emu_if.o: CFLAGS += -DDRC_DISABLE
 frontend/libretro.o: CFLAGS += -DDRC_DISABLE
 endif
-OBJS += libpcsxcore/new_dynarec/emu_if.o
-libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c \
-       libpcsxcore/new_dynarec/pcsxmem_inline.c
+OBJS += libpcsxcore/new_dynarec/backends/psx/emu_if.o
+libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/arm/assem_arm.c \
+       libpcsxcore/new_dynarec/backends/psx/pcsxmem_inline.c
 ifdef DRC_DBG
-libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
+libpcsxcore/new_dynarec/backends/psx/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
 CFLAGS += -DDRC_DBG
 endif
 ifeq "$(DRC_CACHE_BASE)" "1"
 libpcsxcore/new_dynarec/%.o: CFLAGS += -DBASE_ADDR_FIXED=1
+libpcsxcore/new_dynarec/backends/psx/%.o: CFLAGS += -DBASE_ADDR_FIXED=1
+libpcsxcore/new_dynarec/arm/%.o: CFLAGS += -DBASE_ADDR_FIXED=1
 endif
 
 # spu
@@ -194,6 +202,7 @@ endif
 ifeq "$(PLATFORM)" "libretro"
 OBJS += frontend/libretro.o
 CFLAGS += -DFRONTEND_SUPPORTS_RGB565
+CFLAGS += -DHAVE_LIBRETRO
 
 ifeq ($(MMAP_WIN32),1)
 OBJS += libpcsxcore/memmap_win32.o
@@ -246,11 +255,19 @@ frontend/revision.h: FORCE
 %.o: %.S
        $(CC_AS) $(CFLAGS) -c $^ -o $@
 
+%.o: %.cpp
+       $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+
 
 target_: $(TARGET)
 
 $(TARGET): $(OBJS)
+ifeq ($(STATIC_LINKING), 1)
+       $(AR) rcs $@ $(OBJS)
+else
        $(CC_LINK) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(EXTRA_LDFLAGS)
+endif
 
 clean: $(PLAT_CLEAN) clean_plugins
        $(RM) $(TARGET) $(OBJS) $(TARGET).map frontend/revision.h
index 223ba9f..88a48f4 100644 (file)
@@ -1,5 +1,7 @@
 # Makefile for PCSX ReARMed (libretro)
 
+DEBUG=0
+
 ifeq ($(platform),)
        platform = unix
        ifeq ($(shell uname -a),)
@@ -20,35 +22,49 @@ CC_AS ?= $(CC)
 CFLAGS ?=
 
 TARGET_NAME := pcsx_rearmed
-
+GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
+ifneq ($(GIT_VERSION)," unknown")
+       CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
+endif
+LIBZ := -lz
+LIBPTHREAD := -lpthread
+LIBDL := -ldl
 MMAP_WIN32=0
+EXTRA_LDFLAGS =
 
 # Unix
 ifeq ($(platform), unix)
        TARGET := $(TARGET_NAME)_libretro.so
        fpic := -fPIC
-       SHARED := -shared -Wl,--version-script=libretro/link.T
+
+else ifeq ($(platform), linux-portable)
+       TARGET := $(TARGET_NAME)_libretro.so
+       fpic := -fPIC -nostdlib
+       EXTRA_LDFLAGS += -fPIC -nostdlib
+       LIBZ :=
+       LIBPTHREAD :=
+       LIBDL :=
+       NO_UNDEF_CHECK = 1
 
 # OS X
 else ifeq ($(platform), osx)
        TARGET := $(TARGET_NAME)_libretro.dylib
        fpic := -fPIC
-       SHARED := -dynamiclib
-       OSXVER = `sw_vers -productVersion | cut -d. -f 2`
-       OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
-       ifeq ($(OSX_LT_MAVERICKS),"YES")
-               fpic += -mmacosx-version-min=10.5
-       endif
+       fpic += -mmacosx-version-min=10.1
 
 # iOS
-else ifeq ($(platform), ios)
+else ifneq (,$(findstring ios,$(platform)))
        ARCH := arm
+       USE_DYNAREC ?= 1
        TARGET := $(TARGET_NAME)_libretro_ios.dylib
+ifeq ($(USE_DYNAREC),0)
+       # Override
+       TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib
+endif
        fpic := -fPIC
-       SHARED := -dynamiclib
 
        ifeq ($(IOSSDK),)
-               IOSSDK := $(shell xcrun -sdk iphoneos -show-sdk-path)
+               IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
        endif
 
        CC = clang -arch armv7 -isysroot $(IOSSDK)
@@ -58,16 +74,18 @@ else ifeq ($(platform), ios)
        ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
        HAVE_NEON = 1
        BUILTIN_GPU = neon
-       USE_DYNAREC = 1
        CFLAGS += -DIOS
-       OSXVER = `sw_vers -productVersion | cut -d. -f 2`
-       OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
-       ifeq ($(OSX_LT_MAVERICKS),"YES")
-               CC +=  -miphoneos-version-min=5.0
-               CXX +=  -miphoneos-version-min=5.0
-               CC_AS +=  -miphoneos-version-min=5.0
-               CFLAGS += -miphoneos-version-min=5.0
-       endif
+ifeq ($(platform),ios9)
+       CC     += -miphoneos-version-min=8.0
+       CXX    += -miphoneos-version-min=8.0
+       CC_AS  += -miphoneos-version-min=8.0
+       CFLAGS += -miphoneos-version-min=8.0
+else
+       CC     += -miphoneos-version-min=5.0
+       CXX    += -miphoneos-version-min=5.0
+       CC_AS  += -miphoneos-version-min=5.0
+       CFLAGS += -miphoneos-version-min=5.0
+endif
 
 # PS3
 else ifeq ($(platform), ps3)
@@ -97,6 +115,52 @@ else ifeq ($(platform), psp1)
        AR = psp-ar$(EXE_EXT)
        CFLAGS += -DPSP -G0
 
+# Vita
+else ifeq ($(platform), vita)
+       TARGET := $(TARGET_NAME)_libretro_vita.a
+       CC = arm-vita-eabi-gcc$(EXE_EXT)
+       AR = arm-vita-eabi-ar$(EXE_EXT)
+       CFLAGS += -DVITA
+       CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
+       CFLAGS += -fsingle-precision-constant -mword-relocations -fno-unwind-tables 
+       CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops
+       CFLAGS +=  -fno-optimize-sibling-calls
+       CFLAGS += -I$(VITASDK)/include -Ifrontend/vita
+       CFLAGS += -DNO_SOCKET -DNO_OS -DNO_DYLIB
+       ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
+
+#      CFLAGS += -U__ARM_NEON__
+       HAVE_NEON = 1
+       BUILTIN_GPU = neon
+
+       USE_DYNAREC = 1
+       DRC_CACHE_BASE = 0
+
+       ARCH = arm
+       STATIC_LINKING = 1
+
+# CTR(3DS)
+else ifeq ($(platform), ctr)
+       TARGET := $(TARGET_NAME)_libretro_ctr.a
+       CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
+       CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
+       AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
+       CFLAGS += -DARM11 -D_3DS -DNO_OS -DNO_DYLIB -DNO_SOCKET
+       CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp -mtp=soft
+       CFLAGS += -Wall -mword-relocations
+       CFLAGS += -fomit-frame-pointer -ffast-math      
+       CFLAGS += -Ifrontend/3ds
+       CFLAGS += -Werror=implicit-function-declaration
+
+#      CFLAGS += -DPCSX
+#      BUILTIN_GPU = unai
+       USE_DYNAREC = 1
+       DRC_CACHE_BASE = 1
+       ARCH = arm
+       HAVE_NEON = 0
+
+       STATIC_LINKING = 1
+
 # Xbox 360
 else ifeq ($(platform), xenon)
        TARGET := $(TARGET_NAME)_libretro_xenon360.a
@@ -121,6 +185,7 @@ else ifeq ($(platform), wii)
 # QNX
 else ifeq ($(platform), qnx)
        TARGET := $(TARGET_NAME)_libretro_qnx.so
+       fpic := -fPIC
        CC = qcc -Vgcc_ntoarmv7le
        CC_AS = $(CC)
        HAVE_NEON = 1
@@ -130,11 +195,36 @@ else ifeq ($(platform), qnx)
        ARCH = arm
        CFLAGS += -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp
        ASFLAGS +=  -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
+       MAIN_LDLIBS += -lsocket
+       LIBPTHREAD :=
+       LIBDL :=
+
+#Raspberry Pi 2
+else ifeq ($(platform), rpi2)
+       TARGET := $(TARGET_NAME)_libretro.so
+       fpic := -fPIC
+       CFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
+       ASFLAGS += -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
+       HAVE_NEON = 1
+       ARCH = arm
+       BUILTIN_GPU = neon
+       USE_DYNAREC = 1
+       
+#Raspberry Pi 3
+else ifeq ($(platform), rpi3)
+       TARGET := $(TARGET_NAME)_libretro.so
+       fpic := -fPIC
+       CFLAGS += -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
+       ASFLAGS += -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
+       HAVE_NEON = 1
+       ARCH = arm
+       BUILTIN_GPU = neon
+       USE_DYNAREC = 1
 
 # ARM
 else ifneq (,$(findstring armv,$(platform)))
        TARGET := $(TARGET_NAME)_libretro.so
-       SHARED := -shared -Wl,--no-undefined
+       fpic := -fPIC
        DRC_CACHE_BASE = 0
        ifneq (,$(findstring cortexa8,$(platform)))
                CFLAGS += -marm -mcpu=cortex-a8
@@ -163,24 +253,28 @@ else ifneq (,$(findstring armv,$(platform)))
 # Windows
 else
        TARGET := $(TARGET_NAME)_libretro.dll
-       CC = gcc
-       fpic := -fPIC
-       LD_FLAGS := -fPIC
-       SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=libretro/link.T
-       CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__
+       MAIN_LDFLAGS += -static-libgcc -static-libstdc++ -s
+       CFLAGS += -D__WIN32__
        MMAP_WIN32=1
-endif
-
-CFLAGS += -fPIC
-ifeq ($(platform),win)
        MAIN_LDLIBS += -lws2_32
-else ifneq ($(platform),qnx)
-       LDLIBS += -lpthread
-       MAIN_LDLIBS += -ldl
+       LIBPTHREAD :=
+       LIBDL :=
 endif
+
+CFLAGS += $(fpic)
 MAIN_LDFLAGS += -shared
-MAIN_LDLIBS += -lm -lz
-EXTRA_LDFLAGS =
+MAIN_LDLIBS += $(LIBPTHREAD) $(LIBDL) $(LIBZ)
+
+# try to autodetect stuff for the lazy
+ifndef ARCH
+ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}')
+endif
+ifndef HAVE_NEON
+HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0)
+endif
+ifeq ($(NO_UNDEF_CHECK)$(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
+MAIN_LDFLAGS += -Wl,--no-undefined
+endif
 
 # try to autodetect stuff for the lazy
 ifndef ARCH
@@ -200,6 +294,14 @@ SOUND_DRIVERS = libretro
 PLUGINS =
 NO_CONFIG_MAK = yes
 
+libretro_all: all
+ifeq ($(platform),ios)
+ifeq ($(USE_DYNAREC),1)
+       make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform) clean
+       make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform)
+endif
+endif
+
 include Makefile
 
 # no special AS needed for gpu_neon
diff --git a/blackberry_qnx/.cproject b/blackberry_qnx/.cproject
deleted file mode 100644 (file)
index 565f4a9..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 4.0.0?>
-
-<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
-       <storageModule moduleId="org.eclipse.cdt.core.settings">
-               <cconfiguration id="com.qnx.qcc.toolChain.1762498539">
-                       <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.toolChain.1762498539" moduleId="org.eclipse.cdt.core.settings" name="Device-Debug">
-                               <externalSettings/>
-                               <extensions>
-                                       <extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
-                                       <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-                                       <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
-                                       <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-                               </extensions>
-                       </storageModule>
-                       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
-                               <configuration artifactName="${ProjName}" buildProperties="" description="" id="com.qnx.qcc.toolChain.1762498539" name="Device-Debug" parent="org.eclipse.cdt.build.core.emptycfg">
-                                       <folderInfo id="com.qnx.qcc.toolChain.1762498539.1561488424" name="/" resourcePath="">
-                                               <toolChain id="com.qnx.qcc.toolChain.682312592" name="com.qnx.qcc.toolChain" superClass="com.qnx.qcc.toolChain">
-                                                       <option id="com.qnx.qcc.option.os.1720929524" name="Target OS:" superClass="com.qnx.qcc.option.os"/>
-                                                       <option id="com.qnx.qcc.option.cpu.2107899725" name="Target CPU:" superClass="com.qnx.qcc.option.cpu" value="com.qnx.qcc.option.gen.cpu.armle-v7" valueType="enumerated"/>
-                                                       <option id="com.qnx.qcc.option.compiler.596535986" name="Compiler:" superClass="com.qnx.qcc.option.compiler"/>
-                                                       <option id="com.qnx.qcc.option.runtime.742171011" name="Runtime:" superClass="com.qnx.qcc.option.runtime"/>
-                                                       <targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.982231418" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
-                                                       <builder arguments="-C .. -f Makefile.libretro platform=qnx" command="make" id="com.qnx.qcc.toolChain.1762498539.480897078" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
-                                                       <tool id="com.qnx.qcc.tool.compiler.267897021" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
-                                                               <option id="com.qnx.qcc.option.compiler.optlevel.1293751119" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.0" valueType="enumerated"/>
-                                                               <option id="com.qnx.qcc.option.compiler.includePath.365274483" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
-                                                                       <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
-                                                                       <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
-                                                               </option>
-                                                               <inputType id="com.qnx.qcc.inputType.compiler.116424583" superClass="com.qnx.qcc.inputType.compiler"/>
-                                                       </tool>
-                                                       <tool id="com.qnx.qcc.tool.assembler.1307903249" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
-                                                               <inputType id="com.qnx.qcc.inputType.assembler.1838739065" superClass="com.qnx.qcc.inputType.assembler"/>
-                                                       </tool>
-                                                       <tool id="com.qnx.qcc.tool.linker.1852803277" name="QCC Linker" superClass="com.qnx.qcc.tool.linker"/>
-                                                       <tool id="com.qnx.qcc.tool.archiver.1682937256" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
-                                               </toolChain>
-                                       </folderInfo>
-                               </configuration>
-                       </storageModule>
-                       <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
-               </cconfiguration>
-               <cconfiguration id="com.qnx.qcc.toolChain.1815033502">
-                       <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.toolChain.1815033502" moduleId="org.eclipse.cdt.core.settings" name="Device-Release">
-                               <externalSettings/>
-                               <extensions>
-                                       <extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
-                                       <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-                                       <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
-                                       <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-                               </extensions>
-                       </storageModule>
-                       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
-                               <configuration artifactName="${ProjName}" buildProperties="" description="" id="com.qnx.qcc.toolChain.1815033502" name="Device-Release" parent="org.eclipse.cdt.build.core.emptycfg">
-                                       <folderInfo id="com.qnx.qcc.toolChain.1815033502.1093640979" name="/" resourcePath="">
-                                               <toolChain id="com.qnx.qcc.toolChain.1811843468" name="com.qnx.qcc.toolChain" superClass="com.qnx.qcc.toolChain">
-                                                       <option id="com.qnx.qcc.option.os.66936807" name="Target OS:" superClass="com.qnx.qcc.option.os"/>
-                                                       <option id="com.qnx.qcc.option.cpu.1884625209" name="Target CPU:" superClass="com.qnx.qcc.option.cpu" value="com.qnx.qcc.option.gen.cpu.armle-v7" valueType="enumerated"/>
-                                                       <option id="com.qnx.qcc.option.compiler.903071639" name="Compiler:" superClass="com.qnx.qcc.option.compiler"/>
-                                                       <option id="com.qnx.qcc.option.runtime.901433789" name="Runtime:" superClass="com.qnx.qcc.option.runtime"/>
-                                                       <targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.1169345860" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
-                                                       <builder id="com.qnx.qcc.toolChain.1815033502.1831895405" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
-                                                       <tool id="com.qnx.qcc.tool.compiler.401658009" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
-                                                               <option id="com.qnx.qcc.option.compiler.optlevel.20820451" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.0" valueType="enumerated"/>
-                                                               <option id="com.qnx.qcc.option.compiler.includePath.2022402746" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
-                                                                       <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
-                                                                       <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
-                                                               </option>
-                                                               <inputType id="com.qnx.qcc.inputType.compiler.1180700251" superClass="com.qnx.qcc.inputType.compiler"/>
-                                                       </tool>
-                                                       <tool id="com.qnx.qcc.tool.assembler.1403530230" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
-                                                               <inputType id="com.qnx.qcc.inputType.assembler.1360707586" superClass="com.qnx.qcc.inputType.assembler"/>
-                                                       </tool>
-                                                       <tool id="com.qnx.qcc.tool.linker.577346665" name="QCC Linker" superClass="com.qnx.qcc.tool.linker"/>
-                                                       <tool id="com.qnx.qcc.tool.archiver.637344581" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
-                                               </toolChain>
-                                       </folderInfo>
-                               </configuration>
-                       </storageModule>
-                       <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
-               </cconfiguration>
-               <cconfiguration id="com.qnx.qcc.toolChain.1271074456">
-                       <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.toolChain.1271074456" moduleId="org.eclipse.cdt.core.settings" name="Simulator-Debug">
-                               <externalSettings/>
-                               <extensions>
-                                       <extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
-                                       <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-                                       <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
-                                       <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-                               </extensions>
-                       </storageModule>
-                       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
-                               <configuration artifactName="${ProjName}" buildProperties="" description="" id="com.qnx.qcc.toolChain.1271074456" name="Simulator-Debug" parent="org.eclipse.cdt.build.core.emptycfg">
-                                       <folderInfo id="com.qnx.qcc.toolChain.1271074456.2095507025" name="/" resourcePath="">
-                                               <toolChain id="com.qnx.qcc.toolChain.563285451" name="com.qnx.qcc.toolChain" superClass="com.qnx.qcc.toolChain">
-                                                       <option id="com.qnx.qcc.option.os.2028959839" name="Target OS:" superClass="com.qnx.qcc.option.os"/>
-                                                       <option id="com.qnx.qcc.option.cpu.460119393" name="Target CPU:" superClass="com.qnx.qcc.option.cpu"/>
-                                                       <option id="com.qnx.qcc.option.compiler.318948553" name="Compiler:" superClass="com.qnx.qcc.option.compiler"/>
-                                                       <option id="com.qnx.qcc.option.runtime.1244314155" name="Runtime:" superClass="com.qnx.qcc.option.runtime"/>
-                                                       <targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.2005367550" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
-                                                       <builder id="com.qnx.qcc.toolChain.1271074456.325666051" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
-                                                       <tool id="com.qnx.qcc.tool.compiler.821983732" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
-                                                               <option id="com.qnx.qcc.option.compiler.optlevel.1701209030" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.0" valueType="enumerated"/>
-                                                               <option id="com.qnx.qcc.option.compiler.includePath.1616908655" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
-                                                                       <listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
-                                                                       <listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
-                                                               </option>
-                                                               <inputType id="com.qnx.qcc.inputType.compiler.1059435667" superClass="com.qnx.qcc.inputType.compiler"/>
-                                                       </tool>
-                                                       <tool id="com.qnx.qcc.tool.assembler.1920350417" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
-                                                               <inputType id="com.qnx.qcc.inputType.assembler.618235584" superClass="com.qnx.qcc.inputType.assembler"/>
-                                                       </tool>
-                                                       <tool id="com.qnx.qcc.tool.linker.1321150712" name="QCC Linker" superClass="com.qnx.qcc.tool.linker"/>
-                                                       <tool id="com.qnx.qcc.tool.archiver.1860233844" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
-                                               </toolChain>
-                                       </folderInfo>
-                               </configuration>
-                       </storageModule>
-                       <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
-               </cconfiguration>
-       </storageModule>
-       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
-               <project id="pcsx_rearmed.null.446260429" name="pcsx_rearmed"/>
-       </storageModule>
-       <storageModule moduleId="scannerConfiguration">
-               <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
-               <scannerConfigBuildInfo instanceId="com.qnx.qcc.toolChain.1815033502">
-                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
-               </scannerConfigBuildInfo>
-               <scannerConfigBuildInfo instanceId="com.qnx.qcc.toolChain.1762498539">
-                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
-               </scannerConfigBuildInfo>
-               <scannerConfigBuildInfo instanceId="com.qnx.qcc.toolChain.1271074456">
-                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
-               </scannerConfigBuildInfo>
-       </storageModule>
-       <storageModule moduleId="refreshScope" versionNumber="1">
-               <resource resourceType="PROJECT" workspacePath="/pcsx_rearmed"/>
-       </storageModule>
-</cproject>
diff --git a/blackberry_qnx/.project b/blackberry_qnx/.project
deleted file mode 100644 (file)
index c8e1e20..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>pcsx_rearmed</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
-                       <triggers>clean,full,incremental,</triggers>
-                       <arguments>
-                               <dictionary>
-                                       <key>?name?</key>
-                                       <value></value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.append_environment</key>
-                                       <value>true</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
-                                       <value>all</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.buildArguments</key>
-                                       <value>-C .. -f Makefile.libretro platform=qnx</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.buildCommand</key>
-                                       <value>make</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
-                                       <value>clean</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.contents</key>
-                                       <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
-                                       <value>false</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
-                                       <value>true</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.enableFullBuild</key>
-                                       <value>true</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
-                                       <value>all</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.stopOnError</key>
-                                       <value>true</value>
-                               </dictionary>
-                               <dictionary>
-                                       <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
-                                       <value>false</value>
-                               </dictionary>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
-                       <triggers>full,incremental,</triggers>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>com.qnx.tools.bbt.xml.core.bbtXMLValidationBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>org.eclipse.cdt.core.cnature</nature>
-               <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
-               <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
-               <nature>com.qnx.tools.ide.bbt.core.bbtnature</nature>
-       </natures>
-</projectDescription>
diff --git a/debian_maemo/buildpkg b/debian_maemo/buildpkg
deleted file mode 100644 (file)
index 4c34f94..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash -e
-
-NAME=`head debian/changelog -n1 | sed -n 's/^\(.*\) (\(.*\)) .*/\1-\2/p'`
-[[ -z $NAME ]] && { echo "Could not extract package name and version from debian/changelog" 2>&1; exit 1; }
-
-rm -rf ../$NAME
-cp -r ../`basename $PWD` ../$NAME
-cd ../$NAME
-rm -rf .git*
-find . -depth -name .svn -type d -exec rm -r {} \;
-find . -name '*~' -exec rm {} \;
-
-LD_LIBRARY_PATH=/usr/lib dpkg-buildpackage -rfakeroot $*
diff --git a/debian_maemo/changelog b/debian_maemo/changelog
deleted file mode 100644 (file)
index e3395de..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-pcsxrearmed (0.4.0.14.13) unstable; urgency=low
-
-   * Updated source to notaz git version
-
- -- sakya <sakya_tg@yahoo.it>  Fri,  15 Feb 2013 12:50:28 +0200
-
-pcsxrearmed (0.4.0.14.12) unstable; urgency=low
-
-   * Fixed a problem with controller and vibration (Gran Turismo 2, Wipeout 3)
-   * Added dependency to libts
-
- -- sakya <sakya_tg@yahoo.it>  Wed,  16 May 2012 17:09:33 +0200
-
-pcsxrearmed (0.4.0.14.11) unstable; urgency=low
-
-   * Added option -guncon and -gunnotrigger to activate guncon controller type
-
- -- sakya <sakya_tg@yahoo.it>  Wed,  16 May 2012 09:37:12 +0200
-
-pcsxrearmed (0.4.0.14.10) unstable; urgency=low
-
-   * Added option -corners to set action to execute when clicking on display corners
-   * Fixed problem with notification using gles plugin
-   * Fixed controller problem with game "Heart Of Darkness" (maybe others?)
-
- -- sakya <sakya_tg@yahoo.it>  Fri, 11 May 2012 16:38:29 +0200
-
-pcsxrearmed (0.4.0.14.9) unstable; urgency=low
-
-   * Added support to .mdf extension
-   * Added option -vibration to activate vibration
-
- -- sakya <sakya_tg@yahoo.it>  Tue,  1 May 2012 12:19:49 +0200
-
-pcsxrearmed (0.4.0.14.8) unstable; urgency=low
-
-  * Added option -disc to set the initial disc in multi discs images (used when loading a savestate with -load)
-  * Added option -autosave
-  * Fixed disc change for multi discs images (PBP)
-  * Merged commits from Notaz git
-    * drc: inv: fix ram ofset and mirror handling
-    * support emulated RAM mapped at offset
-
- -- sakya <sakya_tg@yahoo.it>  Fri,  20 Apr 2012 20:27:19 +0200
-
-pcsxrearmed (0.4.0.14.7) unstable; urgency=low
-
-  * Fixed -displayon
-
- -- sakya <sakya_tg@yahoo.it>  Sun,  15 Apr 2012 17:22:08 +0200
-
-pcsxrearmed (0.4.0.14.6) unstable; urgency=low
-
-  * Added option -keys to set the keys config file
-  * Fixed L1/L2/R1/R2
-  * Added autopause on incoming call
-
- -- sakya <sakya_tg@yahoo.it>  Wed,  13 Apr 2012 12:51:35 +0200
-
-pcsxrearmed (0.4.0.14.5) unstable; urgency=low
-
-  * Fixed accelerometer using gles
-  * Added -analog option to use the accelerometer as the analog pad
-  * Added options to set accelerometer sens, max value, y_def
-  * Added -displayon option to keep the display on (useful when playing using the accelerometer)
-
- -- sakya <sakya_tg@yahoo.it>  Tue,  10 Apr 2012 15:34:11 +0200
-
-pcsxrearmed (0.4.0.14.4) unstable; urgency=low
-
-  * Fixed -load option
-  * Added disc change (configured a new key)
-
- -- sakya <sakya_tg@yahoo.it>  Fri,  06 Apr 2012 13:54:56 +0200
-
-pcsxrearmed (0.4.0.14.3) unstable; urgency=low
-
-  * Added options to set various gles settings
-  * Fixed save state slot selection
-  * Added notification on save state slot change
-
- -- sakya <sakya_tg@yahoo.it>  Wed,  04 Apr 2012 10:20:18 +0200
-
-pcsxrearmed (0.4.0.14.2) unstable; urgency=low
-
-  * Fixed fullscreen using gpu-gles
-  * Fixed crash when saving savestate using gpu-gles
-  * Added options to set spu reverb and interpolation (disabled by default)
-
- -- sakya <sakya_tg@yahoo.it>  Sun,  01 Apr 2012 11:42:20 +0200
-
-pcsxrearmed (0.4.0.14.1) unstable; urgency=low
-
-  * Added option to set psx region (NTSC/PAL/Auto)
-  * Use PulseAudio (better audio)
-
- -- sakya <sakya_tg@yahoo.it>  Wed,  30 Mar 2012 09:44:51 +0200
-
-pcsxrearmed (0.4.0.14) unstable; urgency=low
-
-  * Updated to r14
-  * Added --help
-  * PCSX4All
-
- -- sakya <sakya_tg@yahoo.it>  Sun,  27 Dec 2011 00:02:27 +0200
-
-pcsxrearmed (0.4.0.12.2) unstable; urgency=low
-
-  * gpu-gles
-
-
- -- Bonapart <bonapart@programist.ru>  Sun,  27 Dec 2011 00:02:27 +0200
diff --git a/debian_maemo/compat b/debian_maemo/compat
deleted file mode 100644 (file)
index 7ed6ff8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian_maemo/control b/debian_maemo/control
deleted file mode 100644 (file)
index 4469ed8..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-Source: pcsxrearmed
-Section: user/games
-Priority: extra
-Maintainer: Bonapart <bonapart@programist.ru>
-Build-Depends: debhelper (>= 5), zlib1g-dev, libhildon1-dev,  libpulse-dev, libasound2-dev, libbz2-dev, libgles1-sgx-img-dev, opengles-sgx-img-common-dev, libosso-dev, libdbus-1-dev, libhildonfm2-dev, libts-dev
-Standards-Version: 3.7.3
-
-Package: pcsxrearmed
-Architecture: armel
-Depends: ${shlibs:Depends}, libts-0.0-0
-Description: Sony PlayStation emulator
-XSBC-Homepage: http://notaz.gp2x.de/pcsx_rearmed.php
-XSBC-Bugtracker: http://notaz.gp2x.de/pcsx_rearmed.php
-XB-Maemo-Display-Name: PCSX-ReArmed
-XB-Maemo-Icon-26:
- iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c
- 6QAAEStJREFUaN7Fmn+wXVV1xz9r733uufe+e9+DJIRESEICEQghAUQBI8Uo
- ik7jrxm1o+3ooB2RkWrtONqZlhn7Y8bRUVudqVZsoTjFH2CrSKsVEFIQIr8C
- JARC0CDkBwkkIcl7L7n3nLP36h97n3Pvo07/7c2cOfeenB9rr/Vd3/Vd6zxh
- 7DM52b9isj+5YcGC+a9bunTpOVNTU91WK5Msy1ECIgYRMGKxzmGtQQBrHSZ9
- R8C5DOcc1hiMtTjrsM4hAtZYWq1W/H9nyZzDZVk6x9LKWmSteH2rlZNlLhw/
- fnzXszt3fmHjxo13bH74oReBwbbtO6r0ODht5UpnfXXdytOXX+mswVcl1hqc
- swjgQ0BV8T7gfSCEQFBQFFQJqqhquptpHCJiMGIQKxhjsdZircMai8kczibj
- XUaWZdi0d1lGlrVwmdN2nsvypUtZvmwpw7LY8dSTT37yX264/sGgOrNl67ZS
- AFavPudTF5y76u9fOniQZ3/7PLPHjuG9Z8wSJO7QeAABVIW0DFAFBEVANF0j
- AGh9XBWV9L3eRFAx6dr6XFDiMWMNy049VS9Yu4o/et+7xBj78u5duz78lS9/
- 8U6UoZx59lnZ2StXbMP7lT+7cyNFUWCsbQwmyLhTo1EiydvpSFogIpiIMQST
- zhOMMSAmnmcMIhYxgogFYxBjEYnnYOIWn2OjA4IiRjhj+TL98uc/K5X3W7Zs
- 2fKBf/72Pz5tZmdmz5jodJZtfeppyqqK+LQx3EYtpm0wRChYazBWMCYaasRg
- TFwAUu/TsgyIiecytkAxBjG1sTZuzfe4GIwDk4GxqMmQLAdx7PjNs/KNG75H
- 3srWLFmy5E3P79rj7Omnr7is08o+8Otnn6MYFtGIErQCyZXsqxW6B3S3gQqw
- /I6PNgEZwSPmQAMVYxERVCSSQTI8et4iYtF6MckhcXECJuWSGPbvf1EvumCN
- nDA1taIoypuNr6pFg6JgMEjGe2Ch0vpmSXdnQeuqQPeeivZtBbI6oIWiKJqS
- WLU2vM6POh2SIZjEXpIMtglGdSTib9IxEsSoFy9mBFtjmTleyJ33bMIYOevQ
- oUMnuLIs5w+LkuCr+HAP+dcqWu8PFD8SZAEwA9kGxawuOXZeBjMGXJ0BNMk4
- gpIZYbr2ZvJ6hJBrftcLEGPTfVJ+EBcfUo6pgohQhMCBgwdB4fDhw5MG6JdV
- RQgKQZAO2IuVMIDB+xzhcWF4lWP4FUPYZJATf1dCp0ROxps69LXR1mGsTZtD
- TNrbWE/i9/jbmFEiRx6oCSCRRHJZURTMzMx0nUK7LD2KIgZ0CPoM2KWQf8tj
- TlPkZGX4GRdNdiTvzzW+Nrg2voaIqb1uHUYsYm2KRNxURnBSTfdB4k5r6q0x
- qogIIShFWVKWZWa8962y8g0eRGH4GYd/Usg/GsjerHQ2VnRuK7GvC6iXhjpH
- xo+MyPOcdruNsTZyughiXFxI42mHuAyswzgLNrGRNWANYg1gUCOoMQ2DYUZ5
- JgKqahxI5n0Y4cJBeMxw7LwM+6ZA62880o454C4rmb1U4AkLrXHjY6UNqpx6
- ymKm+n2qEBgUFUemZzk8PYsPinMxIsa6xDAR71rXjFj/CJo8WdNDXeQTY4iA
- tZHVnKo61VBfCW3FXqzoUCl/bnB/ECj+0uGurGj/bcBdESifcBGLKQIN5oFu
- p8OCBfPpdDp0u13yvI1X5fnd+9jx210cOjJDnmUY4yLOE9xACEmamHoRQZtF
- aar0oBgxOJfFBYgxTjXxeGVgnqdzd4nuh9mLshizFkieHDKcyzam5nNjICjt
- djS81+sxMTHB5OQkvV6P89euoZXn3Pfgo9y16RGKMiDWRu8bQVTQEEAiPQsh
- KoAwqjApDBgjZM5F54mIa5IwA31OKL5kMYthYkeJe2ege39Bfm3Ab4fqJy7i
- PVjEW/AGCel3sHTb0fh+v8/k5CQ+KEemZ+h0u8yfN48PvvddXPvpq5ma6qMK
- 1goGk2qdIKYmZlMrLiBE+ISAAkaELMswxohx1mZSaxgBnFD8hePYBx3V92PW
- hEeFwecyjr+lA7stsgDMUkWWhLidGpBXBWRxQPvKZH+yWcA9v9rMN2+8mWd2
- Pk+/36fX6/G615zHtZ++GucsqpIkR6obgJFXVPfa+QliYgwuy7DW4sQYGdFg
- UsMC1fct1Q8c+ZdKqq9lhBds1D3WYt8zwP3JMNFc/RTBiPLcXdtZ9/LFdHtd
- +v0+/ck+Yi0vHXyZXq9Ht9ul3W5z2bqLeNsb13HrHffQytvUVdSIRPyPVfna
- +HpJxiSpL4LTEDAxHFFC12IssUz51y2oBNOSVPqF8MMu1X90QWykR7EY46iq
- ite89VImzp6Ixvf7tLIW1rbodDtMTEzQ6XTI85w8z7nowvP54U/vJs9Hyanq
- myKpKKIpAppEsWqCXhRlTlUxSbvXJTtSlYyS1tTcnKrt0CKFbSqqcZHnfeVY
- 0DupMb7X65HlOVhD3mo33s/znCzLWLl8Ka08IxBtUA1NUBVFJeoukdg0ee+Z
- mZllMBwgCM45cSGEEPHX0OzcRqaWv4y+R/GVqmqSCJJ6iM5Ep2GeXq9H1soR
- sWSt1hzjsyxj3oknMJG3KGqmqTsmiaCvo1BWnmJYUJRDKu9HjZIqzhijseSb
- RlXW+zoqkSJMoyZreWDHKms8Bt1urzG+1+vhsgwjllaWkef5qB+2lsoHfEj8
- PoZ3QQjeU5QFRVFSlRUh+Oa8qIK1gVAwxozEWLpN3Tr6oIhRjIJY0yhHsbEB
- qQWaMRapPN1uh36/z8TEBN1ul8xliAHrsjnGG2PY88I+Zo4dZ6I3EVnHB4qy
- ZDgYUpYVGkJqbUO0SAEJqAYq72MEAG+SFtc6DwREU6+bIhCA4AMWgzhpEnek
- c2KE6iJWV+I4jbA4Z2vubqK96aHHokQuo5eHRYEGT0hDBG0wLU0VltRi+qqK
- CxARX+uKV+J/1HhHcRXVo+C9EvB4FWwAYwLz5p+IwZC1crrdLp1Oh3a7jRhD
- 5QODwSAZBoPhkLvv/RXfuP4mPIbS+5iA49t4m9QcjwUt+EBRFrV0I4y8ImOV
- Q5qOKiZzrUINKlBVnrzlWLFsCWefdQbr113CLx94BCNCp9Oh0+nQarWoqujZ
- m370U3bs3MWik+Zx5OhRfnHPJnrdLsOyZPr4MarKY63BGtMYKnXhIsKmXogP
- nqIogajuGwjVTKQyd+yROnQCUJYVJ05NsWb1Kt74hks4c+XpnPKqxfT7fZ58
- 5lmyVqsxPsuilsqtsPrMM7jktWs5/bRl9HtdrvnYh7HWMhgMefHAQR7c/Dg/
- u3Mjj27djnEWI6aJQNJ0zcd7T1EMI4RUtaqTamxWMoJOUoo+KKcsWsglF13I
- 773hEk6av4B+vzcnYV8+fKQpUs45nHMcPTrNT757Heede04zwfhfcAXeuv5S
- Pvepj3PHXffw2c9/kWd378Vg0DAXRqrgK89gMCSEMJbEafxBrVoZNS55nnP5
- G9dx+frLmgJVU+TR6Vnu+O/7+Pdb/4vHt2zjfe/ZEKdsaTRTVSWLTl6Ic5ay
- qjg2e4ytTz3NDf96C4889jjHBkP+/E+v5sMfeC/tPOcdb38LU/0+7//jT3J0
- enpsXDDKCx88xTAtQKFsIKRjA6t6WqZw9qvP4PL1lzE5OcnExATtdocHHn6M
- +x/azP0PPkorb7P23HO4MG8nre6oqdmK4cCBg+zavYc77v4lP7/rHrZse4oz
- Vqxg7bnn8o4r1vPmy9Y1zATw4oGDBO/RkPJRx1pKjRAaDCMpOIGqSWIZTdqU
- URIfPjpNnrdHnncZe/e/xAknnMDVH/0Q6y+9hFVnvZp/+s73CaqM15V+v8s1
- n72W5/fsY3Z2lt9/y3o+9fErOX/NOSxfthTnRoOmF/bt58bv3sz1N93CzOzs
- qJGRxEAoSCB4z3A4yoFiVAdovB6naQYV4bnd+/jCV7/BuzdcwaVvuJjTly/i
- z675GO12m06n00gDl2WNWhyfXBw9Ms2nr7qSd2+4gkUnL6Tdzkd5oPCrBx/m
- m9d/h433PcjR6RmGRTXWTupcFKnifcWwzgERKWMEatYZCdjxAe2uF/bxtW/d
- yNe/fSNrV69i1dmvZvHCRbSyDLGW/fv38/O77uX1//CVOcl5+MhRbv/xTSw6
- eWGjX7z3TE9P88Nbf8oNN93MY1ufjHoqiUljYncW6sSlrgFRRnhfMSzqHFAt
- jJFGsMXRRuR+bSZjMULORSmxdfuveXzbMzFlxiYS5XDI3n37eenAQebPOzFC
- CeLMCXjpwEGe3P4Mt/zoNv7z9l/w/J59KYKt6NwxxlFlrIAx+h0ghEAxLOIC
- gmpRj/5C7XV5xfiiRkRiVWcdtOq5T2z9xBjaeYu/+uLf8YN/u5ULzlvNhisu
- ZzAcsOnBh9m9dy+3/+JeNm95giNHZ8haGZNT/cjxGtvGKB9CQkpACQRCwkBI
- 8jouoCxLvPfqNIRBnQOicY6TXBvlrMaGew60dCT8JIUcBWMNBw4d5t5ND3Pf
- A4/wvVt+wuzsMbZt/zXT09MMyxJjLZ1Op1GUUmuexsPjsoH4m7lsFEKgrLXQ
- KInndIdzJs9xRhPHHLFKayrtBiQZks4REWxm0QAHXz4MCoNiCBiyzKVnNJiI
- 9wmRYXTMeG2eERKca4qJLBRqNaqqRZ7nWOua1q2REPWKAs1UTALxfVkawMYb
- +9F8RxQNZvz9B6iMTbLjTUMIc7yu9Z4wFoUR89T72ODXL0oEZ4yUcQFWVcbZ
- TZtmRhtRFXm4rtIRXqnZVghGRzYzPmtPhKraDK8aVtG52J/LOjp6hUVI3lVE
- RK2NswsHlK34llCa7BeNuKd2uU0tTkA1hiJG1qNqmh6C1F01EJyzklFyJspJ
- JBNSDigStDlWGz96AZGco4qNr31qOS1F1spod9ujKXP9Uq5OgWa0B0ZHN2s8
- Qz3XTBBibpvYxLSBgI4aljpx0Yb3m1eHiaHGtZ8I5O0cUMqy9KaqyuPe+4OL
- Fy4kc07rmzH2kDjqCOnBPr4F0YCGufuAJwSPBo+G6hVbOlc9IV2j9bWEdN8k
- F9SPYEZgjH5oOdHFCxcwHBb7q6oqzNGj00cOHjz05No1q1lw4qSoD801UlfC
- Bn5a3yfOMTUWn7gF8CkR/4+NEFknfq/vXz9z9LwRtBI0gxK8Z+H8E2XtmtXs
- 3bv38enp6VlzbHb25W3bnnhANQzeseFtKBWVL0bYk9jU61jySTP1Do2XGsrT
- MOa5sU1HXZXq+LFRtyK11yXMmciB4qsCoeRd73w7RVEc37x586YjR44ctsba
- 7NChQ3m73T7ltRe+Zumac1ax9Yltenx6RsSmF26M6aRxlkpo1zQASEgevQTU
- MRgSKTJomHMMJb7pb/7RRDbWBk91/DiTUxN6zVUfkWVLlnDvvffed//99/8Y
- +I0VkWCtMc/s2DHw3i9at+71C996+Xrp9Sd01/O7ZHD8GASP+gpClfbxt097
- rY/7ilAlvPt4bHwLVUmo4n1COten65rzqmL0PXgmum3eueEK/ciH/lBOmJrU
- 2267bevtt9/+XeBRYJ8Att3OT6oqf6b3/pJ58+a96ROf+MRFZ5115sTk5JTp
- 93vSzttYF//OwaU/2siyLPatiSqNiXI8TjhoeoIRe0gjr4MGqjI6oKoqyqKk
- KAqGxRBf+TQIGFKWJbMzszozOxt27tw5e9111z1w4MCBO4H7gKeBlwWg3c5b
- 3of5VVWtUNVzgfMvvvji80477bQFS5Ys6VprTd301IaNG2iMaWBR9wKNwa/Y
- 69j8sqoqQhpeeR8Nr+V22sKePXuO7969+6WHHnroseT1x4GdwCGgbFzU7XSy
- wXDYDyGcDKwAlgOLgUmgzf/PZwgcAV4Ank2G7wemgRLgfwDIFWZCNtkwCgAA
- AABJRU5ErkJggg==
diff --git a/debian_maemo/copyright b/debian_maemo/copyright
deleted file mode 100644 (file)
index 75a6b06..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-this package was maemonized by Roman Deninberg <bonapart@programist.ru>
-Mon, 10 Jan 2011 02:00:13 +0100
diff --git a/debian_maemo/dirs b/debian_maemo/dirs
deleted file mode 100644 (file)
index 33359b8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-usr/games
diff --git a/debian_maemo/docs b/debian_maemo/docs
deleted file mode 100644 (file)
index e845566..0000000
+++ /dev/null
@@ -1 +0,0 @@
-README
diff --git a/debian_maemo/files b/debian_maemo/files
deleted file mode 100644 (file)
index 0cc57dd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-pcsxrearmed_0.4.0.14.13_armel.deb user/games extra
diff --git a/debian_maemo/install b/debian_maemo/install
deleted file mode 100644 (file)
index a260186..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-pcsx opt/maemo/usr/games/
-plugins/spunull/spunull.so opt/maemo/usr/games/plugins
-plugins/gpu_unai/gpu_unai.so opt/maemo/usr/games/plugins
-#plugins/gpu_unai/gpuPCSX4ALL.so opt/maemo/usr/games/plugins
-plugins/dfxvideo/gpu_peops.so opt/maemo/usr/games/plugins
-plugins/gpu-gles/gpu_gles.so opt/maemo/usr/games/plugins
diff --git a/debian_maemo/rules b/debian_maemo/rules
deleted file mode 100644 (file)
index 5230bf7..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/make -f
-# -*- makefile -*-
-
-#export DH_VERBOSE=1
-
-DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
-DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
-DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
-
-#GAME_VERSION := $(shell head debian/changelog -n1 | sed -n 's/.* (\(.*\)) .*/\1/p')
-CFLAGS = -Wall -g
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
-       CFLAGS += -O0
-else
-       CFLAGS += -O2
-endif
-
-build: build-stamp
-
-build-stamp:
-       dh_testdir
-       ./configure --platform=maemo --gpu=neon --sound-drivers=pulseaudio --enable-neon
-       $(MAKE)
-       strip pcsx
-       strip plugins/gpu_unai/gpu_unai.so
-       strip plugins/gpu-gles/gpu_gles.so
-       strip plugins/spunull/spunull.so
-       touch build-stamp
-
-clean:
-       dh_testdir
-       dh_testroot
-       rm -f build-stamp
-       dh_clean
-       $(MAKE) clean clean_plugins
-
-install: build
-       dh_testdir
-       dh_testroot
-       dh_installdirs
-       mkdir -p "$(CURDIR)"/debian/pcsxrearmed/opt/maemo/usr/games/screenshots
-       chmod 777 "$(CURDIR)"/debian/pcsxrearmed/opt/maemo/usr/games/screenshots
-       chown user "$(CURDIR)"/debian/pcsxrearmed/opt/maemo/usr/games/screenshots
-       dh_install
-
-binary-indep: build install
-
-binary-arch: build install
-       dh_testdir
-       dh_testroot
-       dh_installchangelogs
-       dh_installdocs
-       #dh_installmenu
-       dh_link
-       dh_strip
-       dh_compress
-       dh_fixperms
-       dh_installdeb
-       dh_makeshlibs
-       dh_shlibdeps
-       dh_gencontrol
-       #maemo-optify
-       dh_md5sums
-       dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install
diff --git a/frontend/320240/caanoo.gpe b/frontend/320240/caanoo.gpe
deleted file mode 100755 (executable)
index 9d6154a..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-# Wiz's timings are already good, apply this for Caanoo
-if [ -e /dev/accel ]; then
-  ./pollux_set "ram_timings=3,9,4,1,1,1,1"
-fi
-
-# the sync mount causes problems when writing saves,
-# probably due to many write calls, so have to get rid of it
-if grep mmcblk /proc/mounts | grep -q '\<sync\>'; then
-  oldmount=`grep mmcblk /proc/mounts | grep '\<sync\>' | awk '{print $4}'`
-  mount /dev/mmcblk0p1 /mnt/sd/ -o remount,dirsync,noatime
-fi
-
-./pcsx "$@"
-sync
-
-if [ -n "$oldmount" ]; then
-  mount /dev/mmcblk0p1 /mnt/sd/ -o remount,$oldmount
-fi
-
-cd /usr/gp2x
-exec ./gp2xmenu
diff --git a/frontend/320240/haptic_s.cfg b/frontend/320240/haptic_s.cfg
deleted file mode 100644 (file)
index 624056d..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-0      126
-100    -126
-115    0
diff --git a/frontend/320240/haptic_w.cfg b/frontend/320240/haptic_w.cfg
deleted file mode 100644 (file)
index 3585a71..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-0       54
-100     -126
-105     0
diff --git a/frontend/320240/pcsx26.png b/frontend/320240/pcsx26.png
deleted file mode 100644 (file)
index ed220a0..0000000
Binary files a/frontend/320240/pcsx26.png and /dev/null differ
diff --git a/frontend/320240/pcsx_rearmed.ini b/frontend/320240/pcsx_rearmed.ini
deleted file mode 100644 (file)
index b15497f..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-[info]
-name="PCSX ReARMed"
-icon="/pcsx_rearmed/pcsx26.png"
-path="/pcsx_rearmed/pcsx.gpe"
-title="/pcsx_rearmed/pcsxb.png"
-group="GAMES"
diff --git a/frontend/320240/pcsxb.png b/frontend/320240/pcsxb.png
deleted file mode 100644 (file)
index ff5a48a..0000000
Binary files a/frontend/320240/pcsxb.png and /dev/null differ
diff --git a/frontend/320240/pollux_set.c b/frontend/320240/pollux_set.c
deleted file mode 100644 (file)
index f49e777..0000000
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * quick tool to set various timings for Wiz
- *
- * Copyright (c) Gražvydas "notaz" Ignotas, 2009
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the organization nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * HTOTAL:    X VTOTAL:  341
- * HSWIDTH:   1 VSWIDTH:   0
- * HASTART:  37 VASTART:  17
- * HAEND:   277 VAEND:   337
- *
- * 120Hz
- * pcd  8, 447: + 594us
- * pcd  9, 397: +  36us
- * pcd 10, 357: - 523us
- * pcd 11, 325: +1153us
- *
- * 'lcd_timings=397,1,37,277,341,0,17,337;dpc_clkdiv0=9'
- * 'ram_timings=2,9,4,1,1,1,1'
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-//#include "pollux_set.h"
-#define BINARY
-
-/* parse stuff */
-static int parse_lcd_timings(const char *str, void *data)
-{
-       int *lcd_timings = data;
-       const char *p = str;
-       int ret, c;
-       ret = sscanf(str, "%d,%d,%d,%d,%d,%d,%d,%d",
-                       &lcd_timings[0], &lcd_timings[1], &lcd_timings[2], &lcd_timings[3],
-                       &lcd_timings[4], &lcd_timings[5], &lcd_timings[6], &lcd_timings[7]);
-       if (ret != 8)
-               return -1;
-       /* skip seven commas */
-       for (c = 0; c < 7 && *p != 0; p++)
-               if (*p == ',')
-                       c++;
-       if (c != 7)
-               return -1;
-       /* skip last number */
-       while ('0' <= *p && *p <= '9')
-               p++;
-
-       return p - str;
-}
-
-static int parse_ram_timings(const char *str, void *data)
-{
-       int *ram_timings = data;
-       const char *p = str;
-       int ret, c;
-       float cas;
-
-       ret = sscanf(p, "%f,%d,%d,%d,%d,%d,%d",
-                       &cas, &ram_timings[1], &ram_timings[2], &ram_timings[3],
-                       &ram_timings[4], &ram_timings[5], &ram_timings[6]);
-       if (ret != 7)
-               return -1;
-       if (cas == 2)
-               ram_timings[0] = 1;
-       else if (cas == 2.5)
-               ram_timings[0] = 2;
-       else if (cas == 3)
-               ram_timings[0] = 3;
-       else
-               return -1;
-       for (c = 0; c < 6 && *p != 0; p++)
-               if (*p == ',')
-                       c++;
-       if (c != 6)
-               return -1;
-       while ('0' <= *p && *p <= '9')
-               p++;
-
-       return p - str;
-}
-
-static int parse_decimal(const char *str, void *data)
-{
-       char *ep;
-
-       *(int *)data = strtoul(str, &ep, 10);
-       if (ep == str)
-               return -1;
-
-       return ep - str;
-}
-
-/* validate and apply stuff */
-static int apply_lcd_timings(volatile unsigned short *memregs, void *data)
-{
-       int *lcd_timings = data;
-       int i;
-
-       for (i = 0; i < 8; i++) {
-               if (lcd_timings[i] & ~0xffff) {
-                       fprintf(stderr, "pollux_set: invalid lcd timing %d: %d\n", i, lcd_timings[i]);
-                       return -1;
-               }
-       }
-
-       for (i = 0; i < 8; i++)
-               memregs[(0x307c>>1) + i] = lcd_timings[i];
-
-       return 0;
-}
-
-static const struct {
-       signed char adj;        /* how to adjust value passed by user */
-       signed short min;       /* range of */
-       signed short max;       /* allowed values (inclusive) */
-}
-ram_ranges[] = {
-       {  0,  1,  3 }, /* cas (cl) */
-       { -2,  0, 15 }, /* trc */
-       { -2,  0, 15 }, /* tras */
-       {  0,  0, 15 }, /* twr */
-       {  0,  0, 15 }, /* tmrd */
-       {  0,  0, 15 }, /* trp */
-       {  0,  0, 15 }, /* trcd */
-};
-
-static int apply_ram_timings(volatile unsigned short *memregs, void *data)
-{
-       int *ram_timings = data;
-       int i, val;
-
-       for (i = 0; i < 7; i++)
-       {
-               ram_timings[i] += ram_ranges[i].adj;
-               if (ram_timings[i] < ram_ranges[i].min || ram_timings[i] > ram_ranges[i].max) {
-                       fprintf(stderr, "pollux_set: invalid RAM timing %d\n", i);
-                       return -1;
-               }
-       }
-
-       val = memregs[0x14802>>1] & 0x0f00;
-       val |= (ram_timings[4] << 12) | (ram_timings[5] << 4) | ram_timings[6];
-       memregs[0x14802>>1] = val;
-
-       val = memregs[0x14804>>1] & 0x4000;
-       val |= (ram_timings[0] << 12) | (ram_timings[1] << 8) |
-               (ram_timings[2] << 4) | ram_timings[3];
-       val |= 0x8000;
-       memregs[0x14804>>1] = val;
-
-       for (i = 0; i < 0x100000 && (memregs[0x14804>>1] & 0x8000); i++)
-               ;
-
-       return 0;
-}
-
-static int apply_dpc_clkdiv0(volatile unsigned short *memregs, void *data)
-{
-       int pcd = *(int *)data;
-       int tmp;
-
-       if ((pcd - 1) & ~0x3f) {
-               fprintf(stderr, "pollux_set: invalid lcd clkdiv0: %d\n", pcd);
-               return -1;
-       }
-
-       pcd = (pcd - 1) & 0x3f;
-       tmp = memregs[0x31c4>>1];
-       memregs[0x31c4>>1] = (tmp & ~0x3f0) | (pcd << 4);
-
-       return 0;
-}
-
-static int apply_cpuclk(volatile unsigned short *memregs, void *data)
-{
-       volatile unsigned int *memregl = (volatile void *)memregs;
-       int mhz = *(int *)data;
-       int adiv, mdiv, pdiv, sdiv = 0;
-       int i, vf000, vf004;
-
-       // m = MDIV, p = PDIV, s = SDIV
-       #define SYS_CLK_FREQ 27
-       pdiv = 9;
-       mdiv = (mhz * pdiv) / SYS_CLK_FREQ;
-       if (mdiv & ~0x3ff)
-               return -1;
-       vf004 = (pdiv<<18) | (mdiv<<8) | sdiv;
-
-       // attempt to keep AHB the divider close to 250, but not higher
-       for (adiv = 1; mhz / adiv > 250; adiv++)
-               ;
-
-       vf000 = memregl[0xf000>>2];
-       vf000 = (vf000 & ~0x3c0) | ((adiv - 1) << 6);
-       memregl[0xf000>>2] = vf000;
-       memregl[0xf004>>2] = vf004;
-       memregl[0xf07c>>2] |= 0x8000;
-       for (i = 0; (memregl[0xf07c>>2] & 0x8000) && i < 0x100000; i++)
-               ;
-
-       printf("clock set to %dMHz, AHB set to %dMHz\n", mhz, mhz / adiv);
-       return 0;
-}
-
-static int lcd_timings[8];
-static int ram_timings[7];
-static int dpc_clkdiv0;
-static int cpuclk;
-
-static const char lcd_t_help[] = "htotal,hswidth,hastart,haend,vtotal,vswidth,vastart,vaend";
-static const char ram_t_help[] = "CAS,tRC,tRAS,tWR,tMRD,tRP,tRCD";
-
-static const struct {
-       const char *name;
-       const char *help;
-       int (*parse)(const char *str, void *data);
-       int (*apply)(volatile unsigned short *memregs, void *data);
-       void *data;
-}
-all_params[] = {
-       { "lcd_timings", lcd_t_help, parse_lcd_timings, apply_lcd_timings, lcd_timings  },
-       { "ram_timings", ram_t_help, parse_ram_timings, apply_ram_timings, ram_timings  },
-       { "dpc_clkdiv0", "divider",  parse_decimal,     apply_dpc_clkdiv0, &dpc_clkdiv0 },
-       { "clkdiv0",     "divider",  parse_decimal,     apply_dpc_clkdiv0, &dpc_clkdiv0 }, /* alias */
-       { "cpuclk",      "MHZ",      parse_decimal,     apply_cpuclk,      &cpuclk      },
-};
-#define ALL_PARAM_COUNT (sizeof(all_params) / sizeof(all_params[0]))
-
-/*
- * set timings based on preformated string
- * returns 0 on success.
- */
-int pollux_set(volatile unsigned short *memregs, const char *str)
-{
-       int parsed_params[ALL_PARAM_COUNT];
-       int applied_params[ALL_PARAM_COUNT];
-       int applied_something = 0;
-       const char *p, *po;
-       int i, ret;
-
-       if (str == NULL)
-               return -1;
-
-       memset(parsed_params, 0, sizeof(parsed_params));
-       memset(applied_params, 0, sizeof(applied_params));
-
-       p = str;
-       while (1)
-       {
-again:
-               while (*p == ';' || *p == ' ')
-                       p++;
-               if (*p == 0)
-                       break;
-
-               for (i = 0; i < ALL_PARAM_COUNT; i++)
-               {
-                       int param_len = strlen(all_params[i].name);
-                       if (strncmp(p, all_params[i].name, param_len) == 0 && p[param_len] == '=')
-                       {
-                               p += param_len + 1;
-                               ret = all_params[i].parse(p, all_params[i].data);
-                               if (ret < 0) {
-                                       fprintf(stderr, "pollux_set parser: error at %-10s\n", p);
-                                       fprintf(stderr, "  valid format is: <%s>\n", all_params[i].help);
-                                       return -1;
-                               }
-                               parsed_params[i] = 1;
-                               p += ret;
-                               goto again;
-                       }
-               }
-
-               /* Unknown param. Attempt to be forward compatible and ignore it. */
-               for (po = p; *p != 0 && *p != ';'; p++)
-                       ;
-
-               fprintf(stderr, "unhandled param: ");
-               fwrite(po, 1, p - po, stderr);
-               fprintf(stderr, "\n");
-       }
-
-       /* validate and apply */
-       for (i = 0; i < ALL_PARAM_COUNT; i++)
-       {
-               if (!parsed_params[i])
-                       continue;
-
-               ret = all_params[i].apply(memregs, all_params[i].data);
-               if (ret < 0) {
-                       fprintf(stderr, "pollux_set: failed to apply %s (bad value?)\n",
-                               all_params[i].name);
-                       continue;
-               }
-
-               applied_something = 1;
-               applied_params[i] = 1;
-       }
-
-       if (applied_something)
-       {
-               int c;
-               printf("applied: ");
-               for (i = c = 0; i < ALL_PARAM_COUNT; i++)
-               {
-                       if (!applied_params[i])
-                               continue;
-                       if (c != 0)
-                               printf(", ");
-                       printf("%s", all_params[i].name);
-                       c++;
-               }
-               printf("\n");
-       }
-
-       return 0;
-}
-
-#ifdef BINARY
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <unistd.h>
-
-static void usage(const char *binary)
-{
-       int i;
-       printf("usage:\n%s <set_str[;set_str[;...]]>\n"
-               "set_str:\n", binary);
-       for (i = 0; i < ALL_PARAM_COUNT; i++)
-               printf("  %s=<%s>\n", all_params[i].name, all_params[i].help);
-}
-
-int main(int argc, char *argv[])
-{
-       volatile unsigned short *memregs;
-       int ret, memdev;
-
-       if (argc != 2) {
-               usage(argv[0]);
-               return 1;
-       }
-
-       memdev = open("/dev/mem", O_RDWR);
-       if (memdev == -1)
-       {
-               perror("open(/dev/mem) failed");
-               return 1;
-       }
-
-       memregs = mmap(0, 0x20000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0xc0000000);
-       if (memregs == MAP_FAILED)
-       {
-               perror("mmap(memregs) failed");
-               close(memdev);
-               return 1;
-       }
-
-       ret = pollux_set(memregs, argv[1]);
-
-       munmap((void *)memregs, 0x20000);
-       close(memdev);
-
-       return ret;
-}
-#endif
diff --git a/frontend/320240/skin/background.png b/frontend/320240/skin/background.png
deleted file mode 100644 (file)
index 0efdd18..0000000
Binary files a/frontend/320240/skin/background.png and /dev/null differ
diff --git a/frontend/320240/skin/font.png b/frontend/320240/skin/font.png
deleted file mode 100644 (file)
index c526a08..0000000
Binary files a/frontend/320240/skin/font.png and /dev/null differ
diff --git a/frontend/320240/skin/readme.txt b/frontend/320240/skin/readme.txt
deleted file mode 100644 (file)
index dd83963..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-The skin images can be customized, but there are several limitations:\r
-\r
-background.png - must be 320x240 image with 24bit RGB colors.\r
-font.png       - must be 128x160 8bit grayscale image.\r
-selector.png   - must be 8x10 8bit grayscale image.\r
-\r
-Font and selector colors can be changed by editing skin.txt.\r
-\r
diff --git a/frontend/320240/skin/selector.png b/frontend/320240/skin/selector.png
deleted file mode 100644 (file)
index 5062cc2..0000000
Binary files a/frontend/320240/skin/selector.png and /dev/null differ
diff --git a/frontend/320240/skin/skin.txt b/frontend/320240/skin/skin.txt
deleted file mode 100644 (file)
index 1d6979f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-// html-style hex color codes, ex. ff0000 is red, 0000ff is blue, etc.\r
-text_color=ffffc0\r
-selection_color=808010\r
-\r
diff --git a/frontend/320240/ui_gp2x.h b/frontend/320240/ui_gp2x.h
deleted file mode 100644 (file)
index a9c4413..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef UI_FEATURES_H
-#define UI_FEATURES_H
-
-#define MENU_BIOS_PATH "pcsx_rearmed/bios/"
-#define MENU_SHOW_VARSCALER 0
-#define MENU_SHOW_VOUTMODE 0
-#define MENU_SHOW_SCALER2 1
-#define MENU_SHOW_NUBS_BTNS 0
-#define MENU_SHOW_VIBRATION 1
-#define MENU_SHOW_DEADZONE 1
-#define MENU_SHOW_MINIMIZE 0
-#define MENU_SHOW_FULLSCREEN 0
-#define MENU_SHOW_VOLUME 1
-
-#endif // UI_FEATURES_H
diff --git a/frontend/3ds/3ds_utils.h b/frontend/3ds/3ds_utils.h
new file mode 100644 (file)
index 0000000..3d50a66
--- /dev/null
@@ -0,0 +1,66 @@
+#ifndef _3DS_UTILS_H
+#define _3DS_UTILS_H
+
+#include <stdio.h>
+
+#define MEMOP_PROT      6
+#define MEMOP_MAP       4
+#define MEMOP_UNMAP     5
+
+void* linearMemAlign(size_t size, size_t alignment);
+void linearFree(void* mem);
+
+int32_t svcDuplicateHandle(uint32_t* out, uint32_t original);
+int32_t svcCloseHandle(uint32_t handle);
+int32_t svcControlMemory(void* addr_out, void* addr0, void* addr1, uint32_t size, uint32_t op, uint32_t perm);
+int32_t svcControlProcessMemory(uint32_t process, void* addr0, void* addr1, uint32_t size, uint32_t op, uint32_t perm);
+
+int32_t svcCreateThread(int32_t* thread, void *(*entrypoint)(void*), void* arg, void* stack_top, int32_t thread_priority, int32_t processor_id);
+int32_t svcWaitSynchronization(int32_t handle, int64_t nanoseconds);
+void svcExitThread(void) __attribute__((noreturn));
+
+int32_t svcBackdoor(int32_t (*callback)(void));
+
+#define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0)
+
+void wait_for_input(void);
+
+extern __attribute__((weak)) int  __ctr_svchax;
+
+typedef int32_t (*ctr_callback_type)(void);
+
+static inline void ctr_invalidate_ICache_kernel(void)
+{
+   __asm__ volatile(
+      "cpsid aif\n\t"
+      "mov r0, #0\n\t"
+      "mcr p15, 0, r0, c7, c5, 0\n\t");
+}
+
+static inline void ctr_flush_DCache_kernel(void)
+{
+   __asm__ volatile(
+      "cpsid aif\n\t"
+      "mov r0, #0\n\t"
+      "mcr p15, 0, r0, c7, c10, 0\n\t");
+}
+
+static inline void ctr_invalidate_ICache(void)
+{
+   svcBackdoor((ctr_callback_type)ctr_invalidate_ICache_kernel);
+}
+
+static inline void ctr_flush_DCache(void)
+{
+   svcBackdoor((ctr_callback_type)ctr_flush_DCache_kernel);
+}
+
+
+static inline void ctr_flush_invalidate_cache(void)
+{
+   ctr_flush_DCache();
+   ctr_invalidate_ICache();
+}
+
+
+#endif // _3DS_UTILS_H
diff --git a/frontend/3ds/pthread.h b/frontend/3ds/pthread.h
new file mode 100644 (file)
index 0000000..2c2bf6b
--- /dev/null
@@ -0,0 +1,56 @@
+
+#ifndef _3DS_PTHREAD_WRAP__
+#define _3DS_PTHREAD_WRAP__
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "3ds_utils.h"
+
+#define CTR_PTHREAD_STACK_SIZE 0x10000
+
+typedef struct
+{
+   int32_t handle;
+   uint32_t* stack;
+}pthread_t;
+typedef int pthread_attr_t;
+
+static inline int pthread_create(pthread_t *thread,
+      const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg)
+{
+
+   thread->stack =  linearMemAlign(CTR_PTHREAD_STACK_SIZE, 8);
+
+   svcCreateThread(&thread->handle, start_routine, arg,
+                   (uint32_t*)((uint32_t)thread->stack + CTR_PTHREAD_STACK_SIZE),
+                   0x25, 1);
+
+   return 1;
+}
+
+
+static inline int pthread_join(pthread_t thread, void **retval)
+{
+   (void)retval;
+
+   if(svcWaitSynchronization(thread.handle, INT64_MAX))
+      return -1;
+
+   linearFree(thread.stack);
+
+   return 0;
+}
+
+
+static inline void pthread_exit(void *retval)
+{   
+   (void)retval;
+
+   svcExitThread();
+}
+
+
+#endif //_3DS_PTHREAD_WRAP__
+
diff --git a/frontend/3ds/sys/mman.h b/frontend/3ds/sys/mman.h
new file mode 100644 (file)
index 0000000..61dde6c
--- /dev/null
@@ -0,0 +1,107 @@
+#ifndef MMAN_H
+#define MMAN_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <malloc.h>
+
+#include "3ds_utils.h"
+
+#define PROT_READ       0b001
+#define PROT_WRITE      0b010
+#define PROT_EXEC       0b100
+#define MAP_PRIVATE     2
+#define MAP_FIXED       0x10
+#define MAP_ANONYMOUS   0x20
+
+#define MAP_FAILED      ((void *)-1)
+
+static void* dynarec_cache = NULL;
+static void* dynarec_cache_mapping = NULL;
+
+static inline void* mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
+{
+   (void)fd;
+   (void)offset;
+
+   void* addr_out;
+
+   if((prot == (PROT_READ | PROT_WRITE | PROT_EXEC)) &&
+      (flags == (MAP_PRIVATE | MAP_ANONYMOUS)))
+   {
+      if(__ctr_svchax)
+      {
+         /* this hack works only for pcsx_rearmed */
+         uint32_t currentHandle;
+
+         if(!dynarec_cache)
+            dynarec_cache = memalign(0x1000, len);
+
+         svcDuplicateHandle(&currentHandle, 0xFFFF8001);
+         svcControlProcessMemory(currentHandle, addr, dynarec_cache,
+                                 len, MEMOP_MAP, prot);
+         svcCloseHandle(currentHandle);
+         dynarec_cache_mapping = addr;
+         return addr;
+      }
+      else
+      {
+         printf("tried to mmap RWX pages without svcControlProcessMemory access !\n");
+         return MAP_FAILED;
+      }
+
+   }
+
+   addr_out = malloc(len);
+   if(!addr_out)
+      return MAP_FAILED;
+
+   return addr_out;
+}
+
+static inline int mprotect(void *addr, size_t len, int prot)
+{
+   if(__ctr_svchax)
+   {
+      uint32_t currentHandle;
+      svcDuplicateHandle(&currentHandle, 0xFFFF8001);
+      svcControlProcessMemory(currentHandle, addr, NULL,
+                              len, MEMOP_PROT, prot);
+      svcCloseHandle(currentHandle);
+      return 0;
+   }
+
+   printf("mprotect called without svcControlProcessMemory access !\n");
+   return -1;
+}
+
+static inline int munmap(void *addr, size_t len)
+{
+   if((addr == dynarec_cache_mapping) && __ctr_svchax)
+   {
+      uint32_t currentHandle;
+      svcDuplicateHandle(&currentHandle, 0xFFFF8001);
+      svcControlProcessMemory(currentHandle,
+                              dynarec_cache, dynarec_cache_mapping,
+                              len, MEMOP_UNMAP, 0b111);
+      svcCloseHandle(currentHandle);
+      dynarec_cache_mapping = NULL;
+
+   }
+   else
+      free(addr);
+
+   return 0;
+}
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif // MMAN_H
+
diff --git a/frontend/3ds/zconf.h b/frontend/3ds/zconf.h
new file mode 100644 (file)
index 0000000..996fff2
--- /dev/null
@@ -0,0 +1,511 @@
+/* zconf.h -- configuration of the zlib compression library
+ * Copyright (C) 1995-2013 Jean-loup Gailly.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* @(#) $Id$ */
+
+#ifndef ZCONF_H
+#define ZCONF_H
+
+/*
+ * If you *really* need a unique prefix for all types and library functions,
+ * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
+ * Even better than compiling with -DZ_PREFIX would be to use configure to set
+ * this permanently in zconf.h using "./configure --zprefix".
+ */
+#ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */
+#  define Z_PREFIX_SET
+
+/* all linked symbols */
+#  define _dist_code            z__dist_code
+#  define _length_code          z__length_code
+#  define _tr_align             z__tr_align
+#  define _tr_flush_bits        z__tr_flush_bits
+#  define _tr_flush_block       z__tr_flush_block
+#  define _tr_init              z__tr_init
+#  define _tr_stored_block      z__tr_stored_block
+#  define _tr_tally             z__tr_tally
+#  define adler32               z_adler32
+#  define adler32_combine       z_adler32_combine
+#  define adler32_combine64     z_adler32_combine64
+#  ifndef Z_SOLO
+#    define compress              z_compress
+#    define compress2             z_compress2
+#    define compressBound         z_compressBound
+#  endif
+#  define crc32                 z_crc32
+#  define crc32_combine         z_crc32_combine
+#  define crc32_combine64       z_crc32_combine64
+#  define deflate               z_deflate
+#  define deflateBound          z_deflateBound
+#  define deflateCopy           z_deflateCopy
+#  define deflateEnd            z_deflateEnd
+#  define deflateInit2_         z_deflateInit2_
+#  define deflateInit_          z_deflateInit_
+#  define deflateParams         z_deflateParams
+#  define deflatePending        z_deflatePending
+#  define deflatePrime          z_deflatePrime
+#  define deflateReset          z_deflateReset
+#  define deflateResetKeep      z_deflateResetKeep
+#  define deflateSetDictionary  z_deflateSetDictionary
+#  define deflateSetHeader      z_deflateSetHeader
+#  define deflateTune           z_deflateTune
+#  define deflate_copyright     z_deflate_copyright
+#  define get_crc_table         z_get_crc_table
+#  ifndef Z_SOLO
+#    define gz_error              z_gz_error
+#    define gz_intmax             z_gz_intmax
+#    define gz_strwinerror        z_gz_strwinerror
+#    define gzbuffer              z_gzbuffer
+#    define gzclearerr            z_gzclearerr
+#    define gzclose               z_gzclose
+#    define gzclose_r             z_gzclose_r
+#    define gzclose_w             z_gzclose_w
+#    define gzdirect              z_gzdirect
+#    define gzdopen               z_gzdopen
+#    define gzeof                 z_gzeof
+#    define gzerror               z_gzerror
+#    define gzflush               z_gzflush
+#    define gzgetc                z_gzgetc
+#    define gzgetc_               z_gzgetc_
+#    define gzgets                z_gzgets
+#    define gzoffset              z_gzoffset
+#    define gzoffset64            z_gzoffset64
+#    define gzopen                z_gzopen
+#    define gzopen64              z_gzopen64
+#    ifdef _WIN32
+#      define gzopen_w              z_gzopen_w
+#    endif
+#    define gzprintf              z_gzprintf
+#    define gzvprintf             z_gzvprintf
+#    define gzputc                z_gzputc
+#    define gzputs                z_gzputs
+#    define gzread                z_gzread
+#    define gzrewind              z_gzrewind
+#    define gzseek                z_gzseek
+#    define gzseek64              z_gzseek64
+#    define gzsetparams           z_gzsetparams
+#    define gztell                z_gztell
+#    define gztell64              z_gztell64
+#    define gzungetc              z_gzungetc
+#    define gzwrite               z_gzwrite
+#  endif
+#  define inflate               z_inflate
+#  define inflateBack           z_inflateBack
+#  define inflateBackEnd        z_inflateBackEnd
+#  define inflateBackInit_      z_inflateBackInit_
+#  define inflateCopy           z_inflateCopy
+#  define inflateEnd            z_inflateEnd
+#  define inflateGetHeader      z_inflateGetHeader
+#  define inflateInit2_         z_inflateInit2_
+#  define inflateInit_          z_inflateInit_
+#  define inflateMark           z_inflateMark
+#  define inflatePrime          z_inflatePrime
+#  define inflateReset          z_inflateReset
+#  define inflateReset2         z_inflateReset2
+#  define inflateSetDictionary  z_inflateSetDictionary
+#  define inflateGetDictionary  z_inflateGetDictionary
+#  define inflateSync           z_inflateSync
+#  define inflateSyncPoint      z_inflateSyncPoint
+#  define inflateUndermine      z_inflateUndermine
+#  define inflateResetKeep      z_inflateResetKeep
+#  define inflate_copyright     z_inflate_copyright
+#  define inflate_fast          z_inflate_fast
+#  define inflate_table         z_inflate_table
+#  ifndef Z_SOLO
+#    define uncompress            z_uncompress
+#  endif
+#  define zError                z_zError
+#  ifndef Z_SOLO
+#    define zcalloc               z_zcalloc
+#    define zcfree                z_zcfree
+#  endif
+#  define zlibCompileFlags      z_zlibCompileFlags
+#  define zlibVersion           z_zlibVersion
+
+/* all zlib typedefs in zlib.h and zconf.h */
+#  define Byte                  z_Byte
+#  define Bytef                 z_Bytef
+#  define alloc_func            z_alloc_func
+#  define charf                 z_charf
+#  define free_func             z_free_func
+#  ifndef Z_SOLO
+#    define gzFile                z_gzFile
+#  endif
+#  define gz_header             z_gz_header
+#  define gz_headerp            z_gz_headerp
+#  define in_func               z_in_func
+#  define intf                  z_intf
+#  define out_func              z_out_func
+#  define uInt                  z_uInt
+#  define uIntf                 z_uIntf
+#  define uLong                 z_uLong
+#  define uLongf                z_uLongf
+#  define voidp                 z_voidp
+#  define voidpc                z_voidpc
+#  define voidpf                z_voidpf
+
+/* all zlib structs in zlib.h and zconf.h */
+#  define gz_header_s           z_gz_header_s
+#  define internal_state        z_internal_state
+
+#endif
+
+#if defined(__MSDOS__) && !defined(MSDOS)
+#  define MSDOS
+#endif
+#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
+#  define OS2
+#endif
+#if defined(_WINDOWS) && !defined(WINDOWS)
+#  define WINDOWS
+#endif
+#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
+#  ifndef WIN32
+#    define WIN32
+#  endif
+#endif
+#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
+#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
+#    ifndef SYS16BIT
+#      define SYS16BIT
+#    endif
+#  endif
+#endif
+
+/*
+ * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
+ * than 64k bytes at a time (needed on systems with 16-bit int).
+ */
+#ifdef SYS16BIT
+#  define MAXSEG_64K
+#endif
+#ifdef MSDOS
+#  define UNALIGNED_OK
+#endif
+
+#ifdef __STDC_VERSION__
+#  ifndef STDC
+#    define STDC
+#  endif
+#  if __STDC_VERSION__ >= 199901L
+#    ifndef STDC99
+#      define STDC99
+#    endif
+#  endif
+#endif
+#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
+#  define STDC
+#endif
+#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
+#  define STDC
+#endif
+#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
+#  define STDC
+#endif
+#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
+#  define STDC
+#endif
+
+#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */
+#  define STDC
+#endif
+
+#ifndef STDC
+#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
+#    define const       /* note: need a more gentle solution here */
+#  endif
+#endif
+
+#if defined(ZLIB_CONST) && !defined(z_const)
+#  define z_const const
+#else
+#  define z_const
+#endif
+
+/* Some Mac compilers merge all .h files incorrectly: */
+#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
+#  define NO_DUMMY_DECL
+#endif
+
+/* Maximum value for memLevel in deflateInit2 */
+#ifndef MAX_MEM_LEVEL
+#  ifdef MAXSEG_64K
+#    define MAX_MEM_LEVEL 8
+#  else
+#    define MAX_MEM_LEVEL 9
+#  endif
+#endif
+
+/* Maximum value for windowBits in deflateInit2 and inflateInit2.
+ * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
+ * created by gzip. (Files created by minigzip can still be extracted by
+ * gzip.)
+ */
+#ifndef MAX_WBITS
+#  define MAX_WBITS   15 /* 32K LZ77 window */
+#endif
+
+/* The memory requirements for deflate are (in bytes):
+            (1 << (windowBits+2)) +  (1 << (memLevel+9))
+ that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
+ plus a few kilobytes for small objects. For example, if you want to reduce
+ the default memory requirements from 256K to 128K, compile with
+     make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
+ Of course this will generally degrade compression (there's no free lunch).
+
+   The memory requirements for inflate are (in bytes) 1 << windowBits
+ that is, 32K for windowBits=15 (default value) plus a few kilobytes
+ for small objects.
+*/
+
+                        /* Type declarations */
+
+#ifndef OF /* function prototypes */
+#  ifdef STDC
+#    define OF(args)  args
+#  else
+#    define OF(args)  ()
+#  endif
+#endif
+
+#ifndef Z_ARG /* function prototypes for stdarg */
+#  if defined(STDC) || defined(Z_HAVE_STDARG_H)
+#    define Z_ARG(args)  args
+#  else
+#    define Z_ARG(args)  ()
+#  endif
+#endif
+
+/* The following definitions for FAR are needed only for MSDOS mixed
+ * model programming (small or medium model with some far allocations).
+ * This was tested only with MSC; for other MSDOS compilers you may have
+ * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,
+ * just define FAR to be empty.
+ */
+#ifdef SYS16BIT
+#  if defined(M_I86SM) || defined(M_I86MM)
+     /* MSC small or medium model */
+#    define SMALL_MEDIUM
+#    ifdef _MSC_VER
+#      define FAR _far
+#    else
+#      define FAR far
+#    endif
+#  endif
+#  if (defined(__SMALL__) || defined(__MEDIUM__))
+     /* Turbo C small or medium model */
+#    define SMALL_MEDIUM
+#    ifdef __BORLANDC__
+#      define FAR _far
+#    else
+#      define FAR far
+#    endif
+#  endif
+#endif
+
+#if defined(WINDOWS) || defined(WIN32)
+   /* If building or using zlib as a DLL, define ZLIB_DLL.
+    * This is not mandatory, but it offers a little performance increase.
+    */
+#  ifdef ZLIB_DLL
+#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
+#      ifdef ZLIB_INTERNAL
+#        define ZEXTERN extern __declspec(dllexport)
+#      else
+#        define ZEXTERN extern __declspec(dllimport)
+#      endif
+#    endif
+#  endif  /* ZLIB_DLL */
+   /* If building or using zlib with the WINAPI/WINAPIV calling convention,
+    * define ZLIB_WINAPI.
+    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
+    */
+#  ifdef ZLIB_WINAPI
+#    ifdef FAR
+#      undef FAR
+#    endif
+#    include <windows.h>
+     /* No need for _export, use ZLIB.DEF instead. */
+     /* For complete Windows compatibility, use WINAPI, not __stdcall. */
+#    define ZEXPORT WINAPI
+#    ifdef WIN32
+#      define ZEXPORTVA WINAPIV
+#    else
+#      define ZEXPORTVA FAR CDECL
+#    endif
+#  endif
+#endif
+
+#if defined (__BEOS__)
+#  ifdef ZLIB_DLL
+#    ifdef ZLIB_INTERNAL
+#      define ZEXPORT   __declspec(dllexport)
+#      define ZEXPORTVA __declspec(dllexport)
+#    else
+#      define ZEXPORT   __declspec(dllimport)
+#      define ZEXPORTVA __declspec(dllimport)
+#    endif
+#  endif
+#endif
+
+#ifndef ZEXTERN
+#  define ZEXTERN extern
+#endif
+#ifndef ZEXPORT
+#  define ZEXPORT
+#endif
+#ifndef ZEXPORTVA
+#  define ZEXPORTVA
+#endif
+
+#ifndef FAR
+#  define FAR
+#endif
+
+#if !defined(__MACTYPES__)
+typedef unsigned char  Byte;  /* 8 bits */
+#endif
+typedef unsigned int   uInt;  /* 16 bits or more */
+typedef unsigned long  uLong; /* 32 bits or more */
+
+#ifdef SMALL_MEDIUM
+   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
+#  define Bytef Byte FAR
+#else
+   typedef Byte  FAR Bytef;
+#endif
+typedef char  FAR charf;
+typedef int   FAR intf;
+typedef uInt  FAR uIntf;
+typedef uLong FAR uLongf;
+
+#ifdef STDC
+   typedef void const *voidpc;
+   typedef void FAR   *voidpf;
+   typedef void       *voidp;
+#else
+   typedef Byte const *voidpc;
+   typedef Byte FAR   *voidpf;
+   typedef Byte       *voidp;
+#endif
+
+#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
+#  include <limits.h>
+#  if (UINT_MAX == 0xffffffffUL)
+#    define Z_U4 unsigned
+#  elif (ULONG_MAX == 0xffffffffUL)
+#    define Z_U4 unsigned long
+#  elif (USHRT_MAX == 0xffffffffUL)
+#    define Z_U4 unsigned short
+#  endif
+#endif
+
+#ifdef Z_U4
+   typedef Z_U4 z_crc_t;
+#else
+   typedef unsigned long z_crc_t;
+#endif
+
+#if 1    /* was set to #if 1 by ./configure */
+#  define Z_HAVE_UNISTD_H
+#endif
+
+#if 1    /* was set to #if 1 by ./configure */
+#  define Z_HAVE_STDARG_H
+#endif
+
+#ifdef STDC
+#  ifndef Z_SOLO
+#    include <sys/types.h>      /* for off_t */
+#  endif
+#endif
+
+#if defined(STDC) || defined(Z_HAVE_STDARG_H)
+#  ifndef Z_SOLO
+#    include <stdarg.h>         /* for va_list */
+#  endif
+#endif
+
+#ifdef _WIN32
+#  ifndef Z_SOLO
+#    include <stddef.h>         /* for wchar_t */
+#  endif
+#endif
+
+/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
+ * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
+ * though the former does not conform to the LFS document), but considering
+ * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
+ * equivalently requesting no 64-bit operations
+ */
+#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
+#  undef _LARGEFILE64_SOURCE
+#endif
+
+#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
+#  define Z_HAVE_UNISTD_H
+#endif
+#ifndef Z_SOLO
+#  if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
+#    include <unistd.h>         /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
+#    ifdef VMS
+#      include <unixio.h>       /* for off_t */
+#    endif
+#    ifndef z_off_t
+#      define z_off_t off_t
+#    endif
+#  endif
+#endif
+
+#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
+#  define Z_LFS64
+#endif
+
+#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
+#  define Z_LARGE64
+#endif
+
+#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
+#  define Z_WANT64
+#endif
+
+#if !defined(SEEK_SET) && !defined(Z_SOLO)
+#  define SEEK_SET        0       /* Seek from beginning of file.  */
+#  define SEEK_CUR        1       /* Seek from current position.  */
+#  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
+#endif
+
+#ifndef z_off_t
+#  define z_off_t long
+#endif
+
+#if !defined(_WIN32) && defined(Z_LARGE64)
+#  define z_off64_t off64_t
+#else
+#  if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
+#    define z_off64_t __int64
+#  else
+#    define z_off64_t z_off_t
+#  endif
+#endif
+
+/* MVS linker does not support external names larger than 8 bytes */
+#if defined(__MVS__)
+  #pragma map(deflateInit_,"DEIN")
+  #pragma map(deflateInit2_,"DEIN2")
+  #pragma map(deflateEnd,"DEEND")
+  #pragma map(deflateBound,"DEBND")
+  #pragma map(inflateInit_,"ININ")
+  #pragma map(inflateInit2_,"ININ2")
+  #pragma map(inflateEnd,"INEND")
+  #pragma map(inflateSync,"INSY")
+  #pragma map(inflateSetDictionary,"INSEDI")
+  #pragma map(compressBound,"CMBND")
+  #pragma map(inflate_table,"INTABL")
+  #pragma map(inflate_fast,"INFA")
+  #pragma map(inflate_copyright,"INCOPY")
+#endif
+
+#endif /* ZCONF_H */
diff --git a/frontend/3ds/zlib.h b/frontend/3ds/zlib.h
new file mode 100644 (file)
index 0000000..3e0c767
--- /dev/null
@@ -0,0 +1,1768 @@
+/* zlib.h -- interface of the 'zlib' general purpose compression library
+  version 1.2.8, April 28th, 2013
+
+  Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+  Jean-loup Gailly        Mark Adler
+  jloup@gzip.org          madler@alumni.caltech.edu
+
+
+  The data format used by the zlib library is described by RFCs (Request for
+  Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
+  (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
+*/
+
+#ifndef ZLIB_H
+#define ZLIB_H
+
+#include "zconf.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ZLIB_VERSION "1.2.8"
+#define ZLIB_VERNUM 0x1280
+#define ZLIB_VER_MAJOR 1
+#define ZLIB_VER_MINOR 2
+#define ZLIB_VER_REVISION 8
+#define ZLIB_VER_SUBREVISION 0
+
+/*
+    The 'zlib' compression library provides in-memory compression and
+  decompression functions, including integrity checks of the uncompressed data.
+  This version of the library supports only one compression method (deflation)
+  but other algorithms will be added later and will have the same stream
+  interface.
+
+    Compression can be done in a single step if the buffers are large enough,
+  or can be done by repeated calls of the compression function.  In the latter
+  case, the application must provide more input and/or consume the output
+  (providing more output space) before each call.
+
+    The compressed data format used by default by the in-memory functions is
+  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
+  around a deflate stream, which is itself documented in RFC 1951.
+
+    The library also supports reading and writing files in gzip (.gz) format
+  with an interface similar to that of stdio using the functions that start
+  with "gz".  The gzip format is different from the zlib format.  gzip is a
+  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
+
+    This library can optionally read and write gzip streams in memory as well.
+
+    The zlib format was designed to be compact and fast for use in memory
+  and on communications channels.  The gzip format was designed for single-
+  file compression on file systems, has a larger header than zlib to maintain
+  directory information, and uses a different, slower check method than zlib.
+
+    The library does not install any signal handler.  The decoder checks
+  the consistency of the compressed data, so the library should never crash
+  even in case of corrupted input.
+*/
+
+typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
+typedef void   (*free_func)  OF((voidpf opaque, voidpf address));
+
+struct internal_state;
+
+typedef struct z_stream_s {
+    z_const Bytef *next_in;     /* next input byte */
+    uInt     avail_in;  /* number of bytes available at next_in */
+    uLong    total_in;  /* total number of input bytes read so far */
+
+    Bytef    *next_out; /* next output byte should be put there */
+    uInt     avail_out; /* remaining free space at next_out */
+    uLong    total_out; /* total number of bytes output so far */
+
+    z_const char *msg;  /* last error message, NULL if no error */
+    struct internal_state FAR *state; /* not visible by applications */
+
+    alloc_func zalloc;  /* used to allocate the internal state */
+    free_func  zfree;   /* used to free the internal state */
+    voidpf     opaque;  /* private data object passed to zalloc and zfree */
+
+    int     data_type;  /* best guess about the data type: binary or text */
+    uLong   adler;      /* adler32 value of the uncompressed data */
+    uLong   reserved;   /* reserved for future use */
+} z_stream;
+
+typedef z_stream FAR *z_streamp;
+
+/*
+     gzip header information passed to and from zlib routines.  See RFC 1952
+  for more details on the meanings of these fields.
+*/
+typedef struct gz_header_s {
+    int     text;       /* true if compressed data believed to be text */
+    uLong   time;       /* modification time */
+    int     xflags;     /* extra flags (not used when writing a gzip file) */
+    int     os;         /* operating system */
+    Bytef   *extra;     /* pointer to extra field or Z_NULL if none */
+    uInt    extra_len;  /* extra field length (valid if extra != Z_NULL) */
+    uInt    extra_max;  /* space at extra (only when reading header) */
+    Bytef   *name;      /* pointer to zero-terminated file name or Z_NULL */
+    uInt    name_max;   /* space at name (only when reading header) */
+    Bytef   *comment;   /* pointer to zero-terminated comment or Z_NULL */
+    uInt    comm_max;   /* space at comment (only when reading header) */
+    int     hcrc;       /* true if there was or will be a header crc */
+    int     done;       /* true when done reading gzip header (not used
+                           when writing a gzip file) */
+} gz_header;
+
+typedef gz_header FAR *gz_headerp;
+
+/*
+     The application must update next_in and avail_in when avail_in has dropped
+   to zero.  It must update next_out and avail_out when avail_out has dropped
+   to zero.  The application must initialize zalloc, zfree and opaque before
+   calling the init function.  All other fields are set by the compression
+   library and must not be updated by the application.
+
+     The opaque value provided by the application will be passed as the first
+   parameter for calls of zalloc and zfree.  This can be useful for custom
+   memory management.  The compression library attaches no meaning to the
+   opaque value.
+
+     zalloc must return Z_NULL if there is not enough memory for the object.
+   If zlib is used in a multi-threaded application, zalloc and zfree must be
+   thread safe.
+
+     On 16-bit systems, the functions zalloc and zfree must be able to allocate
+   exactly 65536 bytes, but will not be required to allocate more than this if
+   the symbol MAXSEG_64K is defined (see zconf.h).  WARNING: On MSDOS, pointers
+   returned by zalloc for objects of exactly 65536 bytes *must* have their
+   offset normalized to zero.  The default allocation function provided by this
+   library ensures this (see zutil.c).  To reduce memory requirements and avoid
+   any allocation of 64K objects, at the expense of compression ratio, compile
+   the library with -DMAX_WBITS=14 (see zconf.h).
+
+     The fields total_in and total_out can be used for statistics or progress
+   reports.  After compression, total_in holds the total size of the
+   uncompressed data and may be saved for use in the decompressor (particularly
+   if the decompressor wants to decompress everything in a single step).
+*/
+
+                        /* constants */
+
+#define Z_NO_FLUSH      0
+#define Z_PARTIAL_FLUSH 1
+#define Z_SYNC_FLUSH    2
+#define Z_FULL_FLUSH    3
+#define Z_FINISH        4
+#define Z_BLOCK         5
+#define Z_TREES         6
+/* Allowed flush values; see deflate() and inflate() below for details */
+
+#define Z_OK            0
+#define Z_STREAM_END    1
+#define Z_NEED_DICT     2
+#define Z_ERRNO        (-1)
+#define Z_STREAM_ERROR (-2)
+#define Z_DATA_ERROR   (-3)
+#define Z_MEM_ERROR    (-4)
+#define Z_BUF_ERROR    (-5)
+#define Z_VERSION_ERROR (-6)
+/* Return codes for the compression/decompression functions. Negative values
+ * are errors, positive values are used for special but normal events.
+ */
+
+#define Z_NO_COMPRESSION         0
+#define Z_BEST_SPEED             1
+#define Z_BEST_COMPRESSION       9
+#define Z_DEFAULT_COMPRESSION  (-1)
+/* compression levels */
+
+#define Z_FILTERED            1
+#define Z_HUFFMAN_ONLY        2
+#define Z_RLE                 3
+#define Z_FIXED               4
+#define Z_DEFAULT_STRATEGY    0
+/* compression strategy; see deflateInit2() below for details */
+
+#define Z_BINARY   0
+#define Z_TEXT     1
+#define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */
+#define Z_UNKNOWN  2
+/* Possible values of the data_type field (though see inflate()) */
+
+#define Z_DEFLATED   8
+/* The deflate compression method (the only one supported in this version) */
+
+#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
+
+#define zlib_version zlibVersion()
+/* for compatibility with versions < 1.0.2 */
+
+
+                        /* basic functions */
+
+ZEXTERN const char * ZEXPORT zlibVersion OF((void));
+/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
+   If the first character differs, the library code actually used is not
+   compatible with the zlib.h header file used by the application.  This check
+   is automatically made by deflateInit and inflateInit.
+ */
+
+/*
+ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
+
+     Initializes the internal stream state for compression.  The fields
+   zalloc, zfree and opaque must be initialized before by the caller.  If
+   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default
+   allocation functions.
+
+     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
+   1 gives best speed, 9 gives best compression, 0 gives no compression at all
+   (the input data is simply copied a block at a time).  Z_DEFAULT_COMPRESSION
+   requests a default compromise between speed and compression (currently
+   equivalent to level 6).
+
+     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
+   memory, Z_STREAM_ERROR if level is not a valid compression level, or
+   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
+   with the version assumed by the caller (ZLIB_VERSION).  msg is set to null
+   if there is no error message.  deflateInit does not perform any compression:
+   this will be done by deflate().
+*/
+
+
+ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
+/*
+    deflate compresses as much data as possible, and stops when the input
+  buffer becomes empty or the output buffer becomes full.  It may introduce
+  some output latency (reading input without producing any output) except when
+  forced to flush.
+
+    The detailed semantics are as follows.  deflate performs one or both of the
+  following actions:
+
+  - Compress more input starting at next_in and update next_in and avail_in
+    accordingly.  If not all input can be processed (because there is not
+    enough room in the output buffer), next_in and avail_in are updated and
+    processing will resume at this point for the next call of deflate().
+
+  - Provide more output starting at next_out and update next_out and avail_out
+    accordingly.  This action is forced if the parameter flush is non zero.
+    Forcing flush frequently degrades the compression ratio, so this parameter
+    should be set only when necessary (in interactive applications).  Some
+    output may be provided even if flush is not set.
+
+    Before the call of deflate(), the application should ensure that at least
+  one of the actions is possible, by providing more input and/or consuming more
+  output, and updating avail_in or avail_out accordingly; avail_out should
+  never be zero before the call.  The application can consume the compressed
+  output when it wants, for example when the output buffer is full (avail_out
+  == 0), or after each call of deflate().  If deflate returns Z_OK and with
+  zero avail_out, it must be called again after making room in the output
+  buffer because there might be more output pending.
+
+    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
+  decide how much data to accumulate before producing output, in order to
+  maximize compression.
+
+    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
+  flushed to the output buffer and the output is aligned on a byte boundary, so
+  that the decompressor can get all input data available so far.  (In
+  particular avail_in is zero after the call if enough output space has been
+  provided before the call.) Flushing may degrade compression for some
+  compression algorithms and so it should be used only when necessary.  This
+  completes the current deflate block and follows it with an empty stored block
+  that is three bits plus filler bits to the next byte, followed by four bytes
+  (00 00 ff ff).
+
+    If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the
+  output buffer, but the output is not aligned to a byte boundary.  All of the
+  input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.
+  This completes the current deflate block and follows it with an empty fixed
+  codes block that is 10 bits long.  This assures that enough bytes are output
+  in order for the decompressor to finish the block before the empty fixed code
+  block.
+
+    If flush is set to Z_BLOCK, a deflate block is completed and emitted, as
+  for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to
+  seven bits of the current block are held to be written as the next byte after
+  the next deflate block is completed.  In this case, the decompressor may not
+  be provided enough bits at this point in order to complete decompression of
+  the data provided so far to the compressor.  It may need to wait for the next
+  block to be emitted.  This is for advanced applications that need to control
+  the emission of deflate blocks.
+
+    If flush is set to Z_FULL_FLUSH, all output is flushed as with
+  Z_SYNC_FLUSH, and the compression state is reset so that decompression can
+  restart from this point if previous compressed data has been damaged or if
+  random access is desired.  Using Z_FULL_FLUSH too often can seriously degrade
+  compression.
+
+    If deflate returns with avail_out == 0, this function must be called again
+  with the same value of the flush parameter and more output space (updated
+  avail_out), until the flush is complete (deflate returns with non-zero
+  avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
+  avail_out is greater than six to avoid repeated flush markers due to
+  avail_out == 0 on return.
+
+    If the parameter flush is set to Z_FINISH, pending input is processed,
+  pending output is flushed and deflate returns with Z_STREAM_END if there was
+  enough output space; if deflate returns with Z_OK, this function must be
+  called again with Z_FINISH and more output space (updated avail_out) but no
+  more input data, until it returns with Z_STREAM_END or an error.  After
+  deflate has returned Z_STREAM_END, the only possible operations on the stream
+  are deflateReset or deflateEnd.
+
+    Z_FINISH can be used immediately after deflateInit if all the compression
+  is to be done in a single step.  In this case, avail_out must be at least the
+  value returned by deflateBound (see below).  Then deflate is guaranteed to
+  return Z_STREAM_END.  If not enough output space is provided, deflate will
+  not return Z_STREAM_END, and it must be called again as described above.
+
+    deflate() sets strm->adler to the adler32 checksum of all input read
+  so far (that is, total_in bytes).
+
+    deflate() may update strm->data_type if it can make a good guess about
+  the input data type (Z_BINARY or Z_TEXT).  In doubt, the data is considered
+  binary.  This field is only for information purposes and does not affect the
+  compression algorithm in any manner.
+
+    deflate() returns Z_OK if some progress has been made (more input
+  processed or more output produced), Z_STREAM_END if all input has been
+  consumed and all output has been produced (only when flush is set to
+  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
+  if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible
+  (for example avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not
+  fatal, and deflate() can be called again with more input and more output
+  space to continue compressing.
+*/
+
+
+ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
+/*
+     All dynamically allocated data structures for this stream are freed.
+   This function discards any unprocessed input and does not flush any pending
+   output.
+
+     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
+   stream state was inconsistent, Z_DATA_ERROR if the stream was freed
+   prematurely (some input or output was discarded).  In the error case, msg
+   may be set but then points to a static string (which must not be
+   deallocated).
+*/
+
+
+/*
+ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
+
+     Initializes the internal stream state for decompression.  The fields
+   next_in, avail_in, zalloc, zfree and opaque must be initialized before by
+   the caller.  If next_in is not Z_NULL and avail_in is large enough (the
+   exact value depends on the compression method), inflateInit determines the
+   compression method from the zlib header and allocates all data structures
+   accordingly; otherwise the allocation will be deferred to the first call of
+   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to
+   use default allocation functions.
+
+     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
+   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
+   version assumed by the caller, or Z_STREAM_ERROR if the parameters are
+   invalid, such as a null pointer to the structure.  msg is set to null if
+   there is no error message.  inflateInit does not perform any decompression
+   apart from possibly reading the zlib header if present: actual decompression
+   will be done by inflate().  (So next_in and avail_in may be modified, but
+   next_out and avail_out are unused and unchanged.) The current implementation
+   of inflateInit() does not process any header information -- that is deferred
+   until inflate() is called.
+*/
+
+
+ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
+/*
+    inflate decompresses as much data as possible, and stops when the input
+  buffer becomes empty or the output buffer becomes full.  It may introduce
+  some output latency (reading input without producing any output) except when
+  forced to flush.
+
+  The detailed semantics are as follows.  inflate performs one or both of the
+  following actions:
+
+  - Decompress more input starting at next_in and update next_in and avail_in
+    accordingly.  If not all input can be processed (because there is not
+    enough room in the output buffer), next_in is updated and processing will
+    resume at this point for the next call of inflate().
+
+  - Provide more output starting at next_out and update next_out and avail_out
+    accordingly.  inflate() provides as much output as possible, until there is
+    no more input data or no more space in the output buffer (see below about
+    the flush parameter).
+
+    Before the call of inflate(), the application should ensure that at least
+  one of the actions is possible, by providing more input and/or consuming more
+  output, and updating the next_* and avail_* values accordingly.  The
+  application can consume the uncompressed output when it wants, for example
+  when the output buffer is full (avail_out == 0), or after each call of
+  inflate().  If inflate returns Z_OK and with zero avail_out, it must be
+  called again after making room in the output buffer because there might be
+  more output pending.
+
+    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,
+  Z_BLOCK, or Z_TREES.  Z_SYNC_FLUSH requests that inflate() flush as much
+  output as possible to the output buffer.  Z_BLOCK requests that inflate()
+  stop if and when it gets to the next deflate block boundary.  When decoding
+  the zlib or gzip format, this will cause inflate() to return immediately
+  after the header and before the first block.  When doing a raw inflate,
+  inflate() will go ahead and process the first block, and will return when it
+  gets to the end of that block, or when it runs out of data.
+
+    The Z_BLOCK option assists in appending to or combining deflate streams.
+  Also to assist in this, on return inflate() will set strm->data_type to the
+  number of unused bits in the last byte taken from strm->next_in, plus 64 if
+  inflate() is currently decoding the last block in the deflate stream, plus
+  128 if inflate() returned immediately after decoding an end-of-block code or
+  decoding the complete header up to just before the first byte of the deflate
+  stream.  The end-of-block will not be indicated until all of the uncompressed
+  data from that block has been written to strm->next_out.  The number of
+  unused bits may in general be greater than seven, except when bit 7 of
+  data_type is set, in which case the number of unused bits will be less than
+  eight.  data_type is set as noted here every time inflate() returns for all
+  flush options, and so can be used to determine the amount of currently
+  consumed input in bits.
+
+    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the
+  end of each deflate block header is reached, before any actual data in that
+  block is decoded.  This allows the caller to determine the length of the
+  deflate block header for later use in random access within a deflate block.
+  256 is added to the value of strm->data_type when inflate() returns
+  immediately after reaching the end of the deflate block header.
+
+    inflate() should normally be called until it returns Z_STREAM_END or an
+  error.  However if all decompression is to be performed in a single step (a
+  single call of inflate), the parameter flush should be set to Z_FINISH.  In
+  this case all pending input is processed and all pending output is flushed;
+  avail_out must be large enough to hold all of the uncompressed data for the
+  operation to complete.  (The size of the uncompressed data may have been
+  saved by the compressor for this purpose.) The use of Z_FINISH is not
+  required to perform an inflation in one step.  However it may be used to
+  inform inflate that a faster approach can be used for the single inflate()
+  call.  Z_FINISH also informs inflate to not maintain a sliding window if the
+  stream completes, which reduces inflate's memory footprint.  If the stream
+  does not complete, either because not all of the stream is provided or not
+  enough output space is provided, then a sliding window will be allocated and
+  inflate() can be called again to continue the operation as if Z_NO_FLUSH had
+  been used.
+
+     In this implementation, inflate() always flushes as much output as
+  possible to the output buffer, and always uses the faster approach on the
+  first call.  So the effects of the flush parameter in this implementation are
+  on the return value of inflate() as noted below, when inflate() returns early
+  when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of
+  memory for a sliding window when Z_FINISH is used.
+
+     If a preset dictionary is needed after this call (see inflateSetDictionary
+  below), inflate sets strm->adler to the Adler-32 checksum of the dictionary
+  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
+  strm->adler to the Adler-32 checksum of all output produced so far (that is,
+  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
+  below.  At the end of the stream, inflate() checks that its computed adler32
+  checksum is equal to that saved by the compressor and returns Z_STREAM_END
+  only if the checksum is correct.
+
+    inflate() can decompress and check either zlib-wrapped or gzip-wrapped
+  deflate data.  The header type is detected automatically, if requested when
+  initializing with inflateInit2().  Any information contained in the gzip
+  header is not retained, so applications that need that information should
+  instead use raw inflate, see inflateInit2() below, or inflateBack() and
+  perform their own processing of the gzip header and trailer.  When processing
+  gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
+  producted so far.  The CRC-32 is checked against the gzip trailer.
+
+    inflate() returns Z_OK if some progress has been made (more input processed
+  or more output produced), Z_STREAM_END if the end of the compressed data has
+  been reached and all uncompressed output has been produced, Z_NEED_DICT if a
+  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
+  corrupted (input stream not conforming to the zlib format or incorrect check
+  value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
+  next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,
+  Z_BUF_ERROR if no progress is possible or if there was not enough room in the
+  output buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and
+  inflate() can be called again with more input and more output space to
+  continue decompressing.  If Z_DATA_ERROR is returned, the application may
+  then call inflateSync() to look for a good compression block if a partial
+  recovery of the data is desired.
+*/
+
+
+ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
+/*
+     All dynamically allocated data structures for this stream are freed.
+   This function discards any unprocessed input and does not flush any pending
+   output.
+
+     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
+   was inconsistent.  In the error case, msg may be set but then points to a
+   static string (which must not be deallocated).
+*/
+
+
+                        /* Advanced functions */
+
+/*
+    The following functions are needed only in some special applications.
+*/
+
+/*
+ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
+                                     int  level,
+                                     int  method,
+                                     int  windowBits,
+                                     int  memLevel,
+                                     int  strategy));
+
+     This is another version of deflateInit with more compression options.  The
+   fields next_in, zalloc, zfree and opaque must be initialized before by the
+   caller.
+
+     The method parameter is the compression method.  It must be Z_DEFLATED in
+   this version of the library.
+
+     The windowBits parameter is the base two logarithm of the window size
+   (the size of the history buffer).  It should be in the range 8..15 for this
+   version of the library.  Larger values of this parameter result in better
+   compression at the expense of memory usage.  The default value is 15 if
+   deflateInit is used instead.
+
+     windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits
+   determines the window size.  deflate() will then generate raw deflate data
+   with no zlib header or trailer, and will not compute an adler32 check value.
+
+     windowBits can also be greater than 15 for optional gzip encoding.  Add
+   16 to windowBits to write a simple gzip header and trailer around the
+   compressed data instead of a zlib wrapper.  The gzip header will have no
+   file name, no extra data, no comment, no modification time (set to zero), no
+   header crc, and the operating system will be set to 255 (unknown).  If a
+   gzip stream is being written, strm->adler is a crc32 instead of an adler32.
+
+     The memLevel parameter specifies how much memory should be allocated
+   for the internal compression state.  memLevel=1 uses minimum memory but is
+   slow and reduces compression ratio; memLevel=9 uses maximum memory for
+   optimal speed.  The default value is 8.  See zconf.h for total memory usage
+   as a function of windowBits and memLevel.
+
+     The strategy parameter is used to tune the compression algorithm.  Use the
+   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
+   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
+   string match), or Z_RLE to limit match distances to one (run-length
+   encoding).  Filtered data consists mostly of small values with a somewhat
+   random distribution.  In this case, the compression algorithm is tuned to
+   compress them better.  The effect of Z_FILTERED is to force more Huffman
+   coding and less string matching; it is somewhat intermediate between
+   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as
+   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The
+   strategy parameter only affects the compression ratio but not the
+   correctness of the compressed output even if it is not set appropriately.
+   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler
+   decoder for special applications.
+
+     deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid
+   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is
+   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is
+   set to null if there is no error message.  deflateInit2 does not perform any
+   compression: this will be done by deflate().
+*/
+
+ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
+                                             const Bytef *dictionary,
+                                             uInt  dictLength));
+/*
+     Initializes the compression dictionary from the given byte sequence
+   without producing any compressed output.  When using the zlib format, this
+   function must be called immediately after deflateInit, deflateInit2 or
+   deflateReset, and before any call of deflate.  When doing raw deflate, this
+   function must be called either before any call of deflate, or immediately
+   after the completion of a deflate block, i.e. after all input has been
+   consumed and all output has been delivered when using any of the flush
+   options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH.  The
+   compressor and decompressor must use exactly the same dictionary (see
+   inflateSetDictionary).
+
+     The dictionary should consist of strings (byte sequences) that are likely
+   to be encountered later in the data to be compressed, with the most commonly
+   used strings preferably put towards the end of the dictionary.  Using a
+   dictionary is most useful when the data to be compressed is short and can be
+   predicted with good accuracy; the data can then be compressed better than
+   with the default empty dictionary.
+
+     Depending on the size of the compression data structures selected by
+   deflateInit or deflateInit2, a part of the dictionary may in effect be
+   discarded, for example if the dictionary is larger than the window size
+   provided in deflateInit or deflateInit2.  Thus the strings most likely to be
+   useful should be put at the end of the dictionary, not at the front.  In
+   addition, the current implementation of deflate will use at most the window
+   size minus 262 bytes of the provided dictionary.
+
+     Upon return of this function, strm->adler is set to the adler32 value
+   of the dictionary; the decompressor may later use this value to determine
+   which dictionary has been used by the compressor.  (The adler32 value
+   applies to the whole dictionary even if only a subset of the dictionary is
+   actually used by the compressor.) If a raw deflate was requested, then the
+   adler32 value is not computed and strm->adler is not set.
+
+     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
+   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
+   inconsistent (for example if deflate has already been called for this stream
+   or if not at a block boundary for raw deflate).  deflateSetDictionary does
+   not perform any compression: this will be done by deflate().
+*/
+
+ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
+                                    z_streamp source));
+/*
+     Sets the destination stream as a complete copy of the source stream.
+
+     This function can be useful when several compression strategies will be
+   tried, for example when there are several ways of pre-processing the input
+   data with a filter.  The streams that will be discarded should then be freed
+   by calling deflateEnd.  Note that deflateCopy duplicates the internal
+   compression state which can be quite large, so this strategy is slow and can
+   consume lots of memory.
+
+     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
+   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
+   (such as zalloc being Z_NULL).  msg is left unchanged in both source and
+   destination.
+*/
+
+ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
+/*
+     This function is equivalent to deflateEnd followed by deflateInit,
+   but does not free and reallocate all the internal compression state.  The
+   stream will keep the same compression level and any other attributes that
+   may have been set by deflateInit2.
+
+     deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent (such as zalloc or state being Z_NULL).
+*/
+
+ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
+                                      int level,
+                                      int strategy));
+/*
+     Dynamically update the compression level and compression strategy.  The
+   interpretation of level and strategy is as in deflateInit2.  This can be
+   used to switch between compression and straight copy of the input data, or
+   to switch to a different kind of input data requiring a different strategy.
+   If the compression level is changed, the input available so far is
+   compressed with the old level (and may be flushed); the new level will take
+   effect only at the next call of deflate().
+
+     Before the call of deflateParams, the stream state must be set as for
+   a call of deflate(), since the currently available input may have to be
+   compressed and flushed.  In particular, strm->avail_out must be non-zero.
+
+     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
+   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if
+   strm->avail_out was zero.
+*/
+
+ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
+                                    int good_length,
+                                    int max_lazy,
+                                    int nice_length,
+                                    int max_chain));
+/*
+     Fine tune deflate's internal compression parameters.  This should only be
+   used by someone who understands the algorithm used by zlib's deflate for
+   searching for the best matching string, and even then only by the most
+   fanatic optimizer trying to squeeze out the last compressed bit for their
+   specific input data.  Read the deflate.c source code for the meaning of the
+   max_lazy, good_length, nice_length, and max_chain parameters.
+
+     deflateTune() can be called after deflateInit() or deflateInit2(), and
+   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
+ */
+
+ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
+                                       uLong sourceLen));
+/*
+     deflateBound() returns an upper bound on the compressed size after
+   deflation of sourceLen bytes.  It must be called after deflateInit() or
+   deflateInit2(), and after deflateSetHeader(), if used.  This would be used
+   to allocate an output buffer for deflation in a single pass, and so would be
+   called before deflate().  If that first deflate() call is provided the
+   sourceLen input bytes, an output buffer allocated to the size returned by
+   deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
+   to return Z_STREAM_END.  Note that it is possible for the compressed size to
+   be larger than the value returned by deflateBound() if flush options other
+   than Z_FINISH or Z_NO_FLUSH are used.
+*/
+
+ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
+                                       unsigned *pending,
+                                       int *bits));
+/*
+     deflatePending() returns the number of bytes and bits of output that have
+   been generated, but not yet provided in the available output.  The bytes not
+   provided would be due to the available output space having being consumed.
+   The number of bits of output not provided are between 0 and 7, where they
+   await more bits to join them in order to fill out a full byte.  If pending
+   or bits are Z_NULL, then those values are not set.
+
+     deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent.
+ */
+
+ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
+                                     int bits,
+                                     int value));
+/*
+     deflatePrime() inserts bits in the deflate output stream.  The intent
+   is that this function is used to start off the deflate output with the bits
+   leftover from a previous deflate stream when appending to it.  As such, this
+   function can only be used for raw deflate, and must be used before the first
+   deflate() call after a deflateInit2() or deflateReset().  bits must be less
+   than or equal to 16, and that many of the least significant bits of value
+   will be inserted in the output.
+
+     deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough
+   room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the
+   source stream state was inconsistent.
+*/
+
+ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
+                                         gz_headerp head));
+/*
+     deflateSetHeader() provides gzip header information for when a gzip
+   stream is requested by deflateInit2().  deflateSetHeader() may be called
+   after deflateInit2() or deflateReset() and before the first call of
+   deflate().  The text, time, os, extra field, name, and comment information
+   in the provided gz_header structure are written to the gzip header (xflag is
+   ignored -- the extra flags are set according to the compression level).  The
+   caller must assure that, if not Z_NULL, name and comment are terminated with
+   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
+   available there.  If hcrc is true, a gzip header crc is included.  Note that
+   the current versions of the command-line version of gzip (up through version
+   1.3.x) do not support header crc's, and will report that it is a "multi-part
+   gzip file" and give up.
+
+     If deflateSetHeader is not used, the default gzip header has text false,
+   the time set to zero, and os set to 255, with no extra, name, or comment
+   fields.  The gzip header is returned to the default state by deflateReset().
+
+     deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent.
+*/
+
+/*
+ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
+                                     int  windowBits));
+
+     This is another version of inflateInit with an extra parameter.  The
+   fields next_in, avail_in, zalloc, zfree and opaque must be initialized
+   before by the caller.
+
+     The windowBits parameter is the base two logarithm of the maximum window
+   size (the size of the history buffer).  It should be in the range 8..15 for
+   this version of the library.  The default value is 15 if inflateInit is used
+   instead.  windowBits must be greater than or equal to the windowBits value
+   provided to deflateInit2() while compressing, or it must be equal to 15 if
+   deflateInit2() was not used.  If a compressed stream with a larger window
+   size is given as input, inflate() will return with the error code
+   Z_DATA_ERROR instead of trying to allocate a larger window.
+
+     windowBits can also be zero to request that inflate use the window size in
+   the zlib header of the compressed stream.
+
+     windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits
+   determines the window size.  inflate() will then process raw deflate data,
+   not looking for a zlib or gzip header, not generating a check value, and not
+   looking for any check values for comparison at the end of the stream.  This
+   is for use with other formats that use the deflate compressed data format
+   such as zip.  Those formats provide their own check values.  If a custom
+   format is developed using the raw deflate format for compressed data, it is
+   recommended that a check value such as an adler32 or a crc32 be applied to
+   the uncompressed data as is done in the zlib, gzip, and zip formats.  For
+   most applications, the zlib format should be used as is.  Note that comments
+   above on the use in deflateInit2() applies to the magnitude of windowBits.
+
+     windowBits can also be greater than 15 for optional gzip decoding.  Add
+   32 to windowBits to enable zlib and gzip decoding with automatic header
+   detection, or add 16 to decode only the gzip format (the zlib format will
+   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a
+   crc32 instead of an adler32.
+
+     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
+   version assumed by the caller, or Z_STREAM_ERROR if the parameters are
+   invalid, such as a null pointer to the structure.  msg is set to null if
+   there is no error message.  inflateInit2 does not perform any decompression
+   apart from possibly reading the zlib header if present: actual decompression
+   will be done by inflate().  (So next_in and avail_in may be modified, but
+   next_out and avail_out are unused and unchanged.) The current implementation
+   of inflateInit2() does not process any header information -- that is
+   deferred until inflate() is called.
+*/
+
+ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
+                                             const Bytef *dictionary,
+                                             uInt  dictLength));
+/*
+     Initializes the decompression dictionary from the given uncompressed byte
+   sequence.  This function must be called immediately after a call of inflate,
+   if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor
+   can be determined from the adler32 value returned by that call of inflate.
+   The compressor and decompressor must use exactly the same dictionary (see
+   deflateSetDictionary).  For raw inflate, this function can be called at any
+   time to set the dictionary.  If the provided dictionary is smaller than the
+   window and there is already data in the window, then the provided dictionary
+   will amend what's there.  The application must insure that the dictionary
+   that was used for compression is provided.
+
+     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
+   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
+   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
+   expected one (incorrect adler32 value).  inflateSetDictionary does not
+   perform any decompression: this will be done by subsequent calls of
+   inflate().
+*/
+
+ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
+                                             Bytef *dictionary,
+                                             uInt  *dictLength));
+/*
+     Returns the sliding dictionary being maintained by inflate.  dictLength is
+   set to the number of bytes in the dictionary, and that many bytes are copied
+   to dictionary.  dictionary must have enough space, where 32768 bytes is
+   always enough.  If inflateGetDictionary() is called with dictionary equal to
+   Z_NULL, then only the dictionary length is returned, and nothing is copied.
+   Similary, if dictLength is Z_NULL, then it is not set.
+
+     inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
+   stream state is inconsistent.
+*/
+
+ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
+/*
+     Skips invalid compressed data until a possible full flush point (see above
+   for the description of deflate with Z_FULL_FLUSH) can be found, or until all
+   available input is skipped.  No output is provided.
+
+     inflateSync searches for a 00 00 FF FF pattern in the compressed data.
+   All full flush points have this pattern, but not all occurrences of this
+   pattern are full flush points.
+
+     inflateSync returns Z_OK if a possible full flush point has been found,
+   Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
+   has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
+   In the success case, the application may save the current current value of
+   total_in which indicates where valid compressed data was found.  In the
+   error case, the application may repeatedly call inflateSync, providing more
+   input each time, until success or end of the input data.
+*/
+
+ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
+                                    z_streamp source));
+/*
+     Sets the destination stream as a complete copy of the source stream.
+
+     This function can be useful when randomly accessing a large stream.  The
+   first pass through the stream can periodically record the inflate state,
+   allowing restarting inflate at those points when randomly accessing the
+   stream.
+
+     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
+   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
+   (such as zalloc being Z_NULL).  msg is left unchanged in both source and
+   destination.
+*/
+
+ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
+/*
+     This function is equivalent to inflateEnd followed by inflateInit,
+   but does not free and reallocate all the internal decompression state.  The
+   stream will keep attributes that may have been set by inflateInit2.
+
+     inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent (such as zalloc or state being Z_NULL).
+*/
+
+ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
+                                      int windowBits));
+/*
+     This function is the same as inflateReset, but it also permits changing
+   the wrap and window size requests.  The windowBits parameter is interpreted
+   the same as it is for inflateInit2.
+
+     inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent (such as zalloc or state being Z_NULL), or if
+   the windowBits parameter is invalid.
+*/
+
+ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
+                                     int bits,
+                                     int value));
+/*
+     This function inserts bits in the inflate input stream.  The intent is
+   that this function is used to start inflating at a bit position in the
+   middle of a byte.  The provided bits will be used before any bytes are used
+   from next_in.  This function should only be used with raw inflate, and
+   should be used before the first inflate() call after inflateInit2() or
+   inflateReset().  bits must be less than or equal to 16, and that many of the
+   least significant bits of value will be inserted in the input.
+
+     If bits is negative, then the input stream bit buffer is emptied.  Then
+   inflatePrime() can be called again to put bits in the buffer.  This is used
+   to clear out bits leftover after feeding inflate a block description prior
+   to feeding inflate codes.
+
+     inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent.
+*/
+
+ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
+/*
+     This function returns two values, one in the lower 16 bits of the return
+   value, and the other in the remaining upper bits, obtained by shifting the
+   return value down 16 bits.  If the upper value is -1 and the lower value is
+   zero, then inflate() is currently decoding information outside of a block.
+   If the upper value is -1 and the lower value is non-zero, then inflate is in
+   the middle of a stored block, with the lower value equaling the number of
+   bytes from the input remaining to copy.  If the upper value is not -1, then
+   it is the number of bits back from the current bit position in the input of
+   the code (literal or length/distance pair) currently being processed.  In
+   that case the lower value is the number of bytes already emitted for that
+   code.
+
+     A code is being processed if inflate is waiting for more input to complete
+   decoding of the code, or if it has completed decoding but is waiting for
+   more output space to write the literal or match data.
+
+     inflateMark() is used to mark locations in the input data for random
+   access, which may be at bit positions, and to note those cases where the
+   output of a code may span boundaries of random access blocks.  The current
+   location in the input stream can be determined from avail_in and data_type
+   as noted in the description for the Z_BLOCK flush parameter for inflate.
+
+     inflateMark returns the value noted above or -1 << 16 if the provided
+   source stream state was inconsistent.
+*/
+
+ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
+                                         gz_headerp head));
+/*
+     inflateGetHeader() requests that gzip header information be stored in the
+   provided gz_header structure.  inflateGetHeader() may be called after
+   inflateInit2() or inflateReset(), and before the first call of inflate().
+   As inflate() processes the gzip stream, head->done is zero until the header
+   is completed, at which time head->done is set to one.  If a zlib stream is
+   being decoded, then head->done is set to -1 to indicate that there will be
+   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be
+   used to force inflate() to return immediately after header processing is
+   complete and before any actual data is decompressed.
+
+     The text, time, xflags, and os fields are filled in with the gzip header
+   contents.  hcrc is set to true if there is a header CRC.  (The header CRC
+   was valid if done is set to one.) If extra is not Z_NULL, then extra_max
+   contains the maximum number of bytes to write to extra.  Once done is true,
+   extra_len contains the actual extra field length, and extra contains the
+   extra field, or that field truncated if extra_max is less than extra_len.
+   If name is not Z_NULL, then up to name_max characters are written there,
+   terminated with a zero unless the length is greater than name_max.  If
+   comment is not Z_NULL, then up to comm_max characters are written there,
+   terminated with a zero unless the length is greater than comm_max.  When any
+   of extra, name, or comment are not Z_NULL and the respective field is not
+   present in the header, then that field is set to Z_NULL to signal its
+   absence.  This allows the use of deflateSetHeader() with the returned
+   structure to duplicate the header.  However if those fields are set to
+   allocated memory, then the application will need to save those pointers
+   elsewhere so that they can be eventually freed.
+
+     If inflateGetHeader is not used, then the header information is simply
+   discarded.  The header is always checked for validity, including the header
+   CRC if present.  inflateReset() will reset the process to discard the header
+   information.  The application would need to call inflateGetHeader() again to
+   retrieve the header from the next gzip stream.
+
+     inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent.
+*/
+
+/*
+ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
+                                        unsigned char FAR *window));
+
+     Initialize the internal stream state for decompression using inflateBack()
+   calls.  The fields zalloc, zfree and opaque in strm must be initialized
+   before the call.  If zalloc and zfree are Z_NULL, then the default library-
+   derived memory allocation routines are used.  windowBits is the base two
+   logarithm of the window size, in the range 8..15.  window is a caller
+   supplied buffer of that size.  Except for special applications where it is
+   assured that deflate was used with small window sizes, windowBits must be 15
+   and a 32K byte window must be supplied to be able to decompress general
+   deflate streams.
+
+     See inflateBack() for the usage of these routines.
+
+     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
+   the parameters are invalid, Z_MEM_ERROR if the internal state could not be
+   allocated, or Z_VERSION_ERROR if the version of the library does not match
+   the version of the header file.
+*/
+
+typedef unsigned (*in_func) OF((void FAR *,
+                                z_const unsigned char FAR * FAR *));
+typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
+
+ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
+                                    in_func in, void FAR *in_desc,
+                                    out_func out, void FAR *out_desc));
+/*
+     inflateBack() does a raw inflate with a single call using a call-back
+   interface for input and output.  This is potentially more efficient than
+   inflate() for file i/o applications, in that it avoids copying between the
+   output and the sliding window by simply making the window itself the output
+   buffer.  inflate() can be faster on modern CPUs when used with large
+   buffers.  inflateBack() trusts the application to not change the output
+   buffer passed by the output function, at least until inflateBack() returns.
+
+     inflateBackInit() must be called first to allocate the internal state
+   and to initialize the state with the user-provided window buffer.
+   inflateBack() may then be used multiple times to inflate a complete, raw
+   deflate stream with each call.  inflateBackEnd() is then called to free the
+   allocated state.
+
+     A raw deflate stream is one with no zlib or gzip header or trailer.
+   This routine would normally be used in a utility that reads zip or gzip
+   files and writes out uncompressed files.  The utility would decode the
+   header and process the trailer on its own, hence this routine expects only
+   the raw deflate stream to decompress.  This is different from the normal
+   behavior of inflate(), which expects either a zlib or gzip header and
+   trailer around the deflate stream.
+
+     inflateBack() uses two subroutines supplied by the caller that are then
+   called by inflateBack() for input and output.  inflateBack() calls those
+   routines until it reads a complete deflate stream and writes out all of the
+   uncompressed data, or until it encounters an error.  The function's
+   parameters and return types are defined above in the in_func and out_func
+   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the
+   number of bytes of provided input, and a pointer to that input in buf.  If
+   there is no input available, in() must return zero--buf is ignored in that
+   case--and inflateBack() will return a buffer error.  inflateBack() will call
+   out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].  out()
+   should return zero on success, or non-zero on failure.  If out() returns
+   non-zero, inflateBack() will return with an error.  Neither in() nor out()
+   are permitted to change the contents of the window provided to
+   inflateBackInit(), which is also the buffer that out() uses to write from.
+   The length written by out() will be at most the window size.  Any non-zero
+   amount of input may be provided by in().
+
+     For convenience, inflateBack() can be provided input on the first call by
+   setting strm->next_in and strm->avail_in.  If that input is exhausted, then
+   in() will be called.  Therefore strm->next_in must be initialized before
+   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called
+   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in
+   must also be initialized, and then if strm->avail_in is not zero, input will
+   initially be taken from strm->next_in[0 ..  strm->avail_in - 1].
+
+     The in_desc and out_desc parameters of inflateBack() is passed as the
+   first parameter of in() and out() respectively when they are called.  These
+   descriptors can be optionally used to pass any information that the caller-
+   supplied in() and out() functions need to do their job.
+
+     On return, inflateBack() will set strm->next_in and strm->avail_in to
+   pass back any unused input that was provided by the last in() call.  The
+   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
+   if in() or out() returned an error, Z_DATA_ERROR if there was a format error
+   in the deflate stream (in which case strm->msg is set to indicate the nature
+   of the error), or Z_STREAM_ERROR if the stream was not properly initialized.
+   In the case of Z_BUF_ERROR, an input or output error can be distinguished
+   using strm->next_in which will be Z_NULL only if in() returned an error.  If
+   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
+   non-zero.  (in() will always be called before out(), so strm->next_in is
+   assured to be defined if out() returns non-zero.) Note that inflateBack()
+   cannot return Z_OK.
+*/
+
+ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
+/*
+     All memory allocated by inflateBackInit() is freed.
+
+     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
+   state was inconsistent.
+*/
+
+ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
+/* Return flags indicating compile-time options.
+
+    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
+     1.0: size of uInt
+     3.2: size of uLong
+     5.4: size of voidpf (pointer)
+     7.6: size of z_off_t
+
+    Compiler, assembler, and debug options:
+     8: DEBUG
+     9: ASMV or ASMINF -- use ASM code
+     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
+     11: 0 (reserved)
+
+    One-time table building (smaller code, but not thread-safe if true):
+     12: BUILDFIXED -- build static block decoding tables when needed
+     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
+     14,15: 0 (reserved)
+
+    Library content (indicates missing functionality):
+     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
+                          deflate code when not needed)
+     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
+                    and decode gzip streams (to avoid linking crc code)
+     18-19: 0 (reserved)
+
+    Operation variations (changes in library functionality):
+     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
+     21: FASTEST -- deflate algorithm with only one, lowest compression level
+     22,23: 0 (reserved)
+
+    The sprintf variant used by gzprintf (zero is best):
+     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
+     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
+     26: 0 = returns value, 1 = void -- 1 means inferred string length returned
+
+    Remainder:
+     27-31: 0 (reserved)
+ */
+
+#ifndef Z_SOLO
+
+                        /* utility functions */
+
+/*
+     The following utility functions are implemented on top of the basic
+   stream-oriented functions.  To simplify the interface, some default options
+   are assumed (compression level and memory usage, standard memory allocation
+   functions).  The source code of these utility functions can be modified if
+   you need special options.
+*/
+
+ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
+                                 const Bytef *source, uLong sourceLen));
+/*
+     Compresses the source buffer into the destination buffer.  sourceLen is
+   the byte length of the source buffer.  Upon entry, destLen is the total size
+   of the destination buffer, which must be at least the value returned by
+   compressBound(sourceLen).  Upon exit, destLen is the actual size of the
+   compressed buffer.
+
+     compress returns Z_OK if success, Z_MEM_ERROR if there was not
+   enough memory, Z_BUF_ERROR if there was not enough room in the output
+   buffer.
+*/
+
+ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
+                                  const Bytef *source, uLong sourceLen,
+                                  int level));
+/*
+     Compresses the source buffer into the destination buffer.  The level
+   parameter has the same meaning as in deflateInit.  sourceLen is the byte
+   length of the source buffer.  Upon entry, destLen is the total size of the
+   destination buffer, which must be at least the value returned by
+   compressBound(sourceLen).  Upon exit, destLen is the actual size of the
+   compressed buffer.
+
+     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+   memory, Z_BUF_ERROR if there was not enough room in the output buffer,
+   Z_STREAM_ERROR if the level parameter is invalid.
+*/
+
+ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
+/*
+     compressBound() returns an upper bound on the compressed size after
+   compress() or compress2() on sourceLen bytes.  It would be used before a
+   compress() or compress2() call to allocate the destination buffer.
+*/
+
+ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
+                                   const Bytef *source, uLong sourceLen));
+/*
+     Decompresses the source buffer into the destination buffer.  sourceLen is
+   the byte length of the source buffer.  Upon entry, destLen is the total size
+   of the destination buffer, which must be large enough to hold the entire
+   uncompressed data.  (The size of the uncompressed data must have been saved
+   previously by the compressor and transmitted to the decompressor by some
+   mechanism outside the scope of this compression library.) Upon exit, destLen
+   is the actual size of the uncompressed buffer.
+
+     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
+   enough memory, Z_BUF_ERROR if there was not enough room in the output
+   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.  In
+   the case where there is not enough room, uncompress() will fill the output
+   buffer with the uncompressed data up to that point.
+*/
+
+                        /* gzip file access functions */
+
+/*
+     This library supports reading and writing files in gzip (.gz) format with
+   an interface similar to that of stdio, using the functions that start with
+   "gz".  The gzip format is different from the zlib format.  gzip is a gzip
+   wrapper, documented in RFC 1952, wrapped around a deflate stream.
+*/
+
+typedef struct gzFile_s *gzFile;    /* semi-opaque gzip file descriptor */
+
+/*
+ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
+
+     Opens a gzip (.gz) file for reading or writing.  The mode parameter is as
+   in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
+   a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
+   compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
+   for fixed code compression as in "wb9F".  (See the description of
+   deflateInit2 for more information about the strategy parameter.)  'T' will
+   request transparent writing or appending with no compression and not using
+   the gzip format.
+
+     "a" can be used instead of "w" to request that the gzip stream that will
+   be written be appended to the file.  "+" will result in an error, since
+   reading and writing to the same gzip file is not supported.  The addition of
+   "x" when writing will create the file exclusively, which fails if the file
+   already exists.  On systems that support it, the addition of "e" when
+   reading or writing will set the flag to close the file on an execve() call.
+
+     These functions, as well as gzip, will read and decode a sequence of gzip
+   streams in a file.  The append function of gzopen() can be used to create
+   such a file.  (Also see gzflush() for another way to do this.)  When
+   appending, gzopen does not test whether the file begins with a gzip stream,
+   nor does it look for the end of the gzip streams to begin appending.  gzopen
+   will simply append a gzip stream to the existing file.
+
+     gzopen can be used to read a file which is not in gzip format; in this
+   case gzread will directly read from the file without decompression.  When
+   reading, this will be detected automatically by looking for the magic two-
+   byte gzip header.
+
+     gzopen returns NULL if the file could not be opened, if there was
+   insufficient memory to allocate the gzFile state, or if an invalid mode was
+   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
+   errno can be checked to determine if the reason gzopen failed was that the
+   file could not be opened.
+*/
+
+ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
+/*
+     gzdopen associates a gzFile with the file descriptor fd.  File descriptors
+   are obtained from calls like open, dup, creat, pipe or fileno (if the file
+   has been previously opened with fopen).  The mode parameter is as in gzopen.
+
+     The next call of gzclose on the returned gzFile will also close the file
+   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
+   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
+   mode);.  The duplicated descriptor should be saved to avoid a leak, since
+   gzdopen does not close fd if it fails.  If you are using fileno() to get the
+   file descriptor from a FILE *, then you will have to use dup() to avoid
+   double-close()ing the file descriptor.  Both gzclose() and fclose() will
+   close the associated file descriptor, so they need to have different file
+   descriptors.
+
+     gzdopen returns NULL if there was insufficient memory to allocate the
+   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
+   provided, or '+' was provided), or if fd is -1.  The file descriptor is not
+   used until the next gz* read, write, seek, or close operation, so gzdopen
+   will not detect if fd is invalid (unless fd is -1).
+*/
+
+ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
+/*
+     Set the internal buffer size used by this library's functions.  The
+   default buffer size is 8192 bytes.  This function must be called after
+   gzopen() or gzdopen(), and before any other calls that read or write the
+   file.  The buffer memory allocation is always deferred to the first read or
+   write.  Two buffers are allocated, either both of the specified size when
+   writing, or one of the specified size and the other twice that size when
+   reading.  A larger buffer size of, for example, 64K or 128K bytes will
+   noticeably increase the speed of decompression (reading).
+
+     The new buffer size also affects the maximum length for gzprintf().
+
+     gzbuffer() returns 0 on success, or -1 on failure, such as being called
+   too late.
+*/
+
+ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
+/*
+     Dynamically update the compression level or strategy.  See the description
+   of deflateInit2 for the meaning of these parameters.
+
+     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
+   opened for writing.
+*/
+
+ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
+/*
+     Reads the given number of uncompressed bytes from the compressed file.  If
+   the input file is not in gzip format, gzread copies the given number of
+   bytes into the buffer directly from the file.
+
+     After reaching the end of a gzip stream in the input, gzread will continue
+   to read, looking for another gzip stream.  Any number of gzip streams may be
+   concatenated in the input file, and will all be decompressed by gzread().
+   If something other than a gzip stream is encountered after a gzip stream,
+   that remaining trailing garbage is ignored (and no error is returned).
+
+     gzread can be used to read a gzip file that is being concurrently written.
+   Upon reaching the end of the input, gzread will return with the available
+   data.  If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then
+   gzclearerr can be used to clear the end of file indicator in order to permit
+   gzread to be tried again.  Z_OK indicates that a gzip stream was completed
+   on the last gzread.  Z_BUF_ERROR indicates that the input file ended in the
+   middle of a gzip stream.  Note that gzread does not return -1 in the event
+   of an incomplete gzip stream.  This error is deferred until gzclose(), which
+   will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip
+   stream.  Alternatively, gzerror can be used before gzclose to detect this
+   case.
+
+     gzread returns the number of uncompressed bytes actually read, less than
+   len for end of file, or -1 for error.
+*/
+
+ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
+                                voidpc buf, unsigned len));
+/*
+     Writes the given number of uncompressed bytes into the compressed file.
+   gzwrite returns the number of uncompressed bytes written or 0 in case of
+   error.
+*/
+
+ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
+/*
+     Converts, formats, and writes the arguments to the compressed file under
+   control of the format string, as in fprintf.  gzprintf returns the number of
+   uncompressed bytes actually written, or 0 in case of error.  The number of
+   uncompressed bytes written is limited to 8191, or one less than the buffer
+   size given to gzbuffer().  The caller should assure that this limit is not
+   exceeded.  If it is exceeded, then gzprintf() will return an error (0) with
+   nothing written.  In this case, there may also be a buffer overflow with
+   unpredictable consequences, which is possible only if zlib was compiled with
+   the insecure functions sprintf() or vsprintf() because the secure snprintf()
+   or vsnprintf() functions were not available.  This can be determined using
+   zlibCompileFlags().
+*/
+
+ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
+/*
+     Writes the given null-terminated string to the compressed file, excluding
+   the terminating null character.
+
+     gzputs returns the number of characters written, or -1 in case of error.
+*/
+
+ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
+/*
+     Reads bytes from the compressed file until len-1 characters are read, or a
+   newline character is read and transferred to buf, or an end-of-file
+   condition is encountered.  If any characters are read or if len == 1, the
+   string is terminated with a null character.  If no characters are read due
+   to an end-of-file or len < 1, then the buffer is left untouched.
+
+     gzgets returns buf which is a null-terminated string, or it returns NULL
+   for end-of-file or in case of error.  If there was an error, the contents at
+   buf are indeterminate.
+*/
+
+ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
+/*
+     Writes c, converted to an unsigned char, into the compressed file.  gzputc
+   returns the value that was written, or -1 in case of error.
+*/
+
+ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
+/*
+     Reads one byte from the compressed file.  gzgetc returns this byte or -1
+   in case of end of file or error.  This is implemented as a macro for speed.
+   As such, it does not do all of the checking the other functions do.  I.e.
+   it does not check to see if file is NULL, nor whether the structure file
+   points to has been clobbered or not.
+*/
+
+ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
+/*
+     Push one character back onto the stream to be read as the first character
+   on the next read.  At least one character of push-back is allowed.
+   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will
+   fail if c is -1, and may fail if a character has been pushed but not read
+   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the
+   output buffer size of pushed characters is allowed.  (See gzbuffer above.)
+   The pushed character will be discarded if the stream is repositioned with
+   gzseek() or gzrewind().
+*/
+
+ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
+/*
+     Flushes all pending output into the compressed file.  The parameter flush
+   is as in the deflate() function.  The return value is the zlib error number
+   (see function gzerror below).  gzflush is only permitted when writing.
+
+     If the flush parameter is Z_FINISH, the remaining data is written and the
+   gzip stream is completed in the output.  If gzwrite() is called again, a new
+   gzip stream will be started in the output.  gzread() is able to read such
+   concatented gzip streams.
+
+     gzflush should be called only when strictly necessary because it will
+   degrade compression if called too often.
+*/
+
+/*
+ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
+                                   z_off_t offset, int whence));
+
+     Sets the starting position for the next gzread or gzwrite on the given
+   compressed file.  The offset represents a number of bytes in the
+   uncompressed data stream.  The whence parameter is defined as in lseek(2);
+   the value SEEK_END is not supported.
+
+     If the file is opened for reading, this function is emulated but can be
+   extremely slow.  If the file is opened for writing, only forward seeks are
+   supported; gzseek then compresses a sequence of zeroes up to the new
+   starting position.
+
+     gzseek returns the resulting offset location as measured in bytes from
+   the beginning of the uncompressed stream, or -1 in case of error, in
+   particular if the file is opened for writing and the new starting position
+   would be before the current position.
+*/
+
+ZEXTERN int ZEXPORT    gzrewind OF((gzFile file));
+/*
+     Rewinds the given file. This function is supported only for reading.
+
+     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
+*/
+
+/*
+ZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));
+
+     Returns the starting position for the next gzread or gzwrite on the given
+   compressed file.  This position represents a number of bytes in the
+   uncompressed data stream, and is zero when starting, even if appending or
+   reading a gzip stream from the middle of a file using gzdopen().
+
+     gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
+*/
+
+/*
+ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
+
+     Returns the current offset in the file being read or written.  This offset
+   includes the count of bytes that precede the gzip stream, for example when
+   appending or when using gzdopen() for reading.  When reading, the offset
+   does not include as yet unused buffered input.  This information can be used
+   for a progress indicator.  On error, gzoffset() returns -1.
+*/
+
+ZEXTERN int ZEXPORT gzeof OF((gzFile file));
+/*
+     Returns true (1) if the end-of-file indicator has been set while reading,
+   false (0) otherwise.  Note that the end-of-file indicator is set only if the
+   read tried to go past the end of the input, but came up short.  Therefore,
+   just like feof(), gzeof() may return false even if there is no more data to
+   read, in the event that the last read request was for the exact number of
+   bytes remaining in the input file.  This will happen if the input file size
+   is an exact multiple of the buffer size.
+
+     If gzeof() returns true, then the read functions will return no more data,
+   unless the end-of-file indicator is reset by gzclearerr() and the input file
+   has grown since the previous end of file was detected.
+*/
+
+ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
+/*
+     Returns true (1) if file is being copied directly while reading, or false
+   (0) if file is a gzip stream being decompressed.
+
+     If the input file is empty, gzdirect() will return true, since the input
+   does not contain a gzip stream.
+
+     If gzdirect() is used immediately after gzopen() or gzdopen() it will
+   cause buffers to be allocated to allow reading the file to determine if it
+   is a gzip file.  Therefore if gzbuffer() is used, it should be called before
+   gzdirect().
+
+     When writing, gzdirect() returns true (1) if transparent writing was
+   requested ("wT" for the gzopen() mode), or false (0) otherwise.  (Note:
+   gzdirect() is not needed when writing.  Transparent writing must be
+   explicitly requested, so the application already knows the answer.  When
+   linking statically, using gzdirect() will include all of the zlib code for
+   gzip file reading and decompression, which may not be desired.)
+*/
+
+ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
+/*
+     Flushes all pending output if necessary, closes the compressed file and
+   deallocates the (de)compression state.  Note that once file is closed, you
+   cannot call gzerror with file, since its structures have been deallocated.
+   gzclose must not be called more than once on the same file, just as free
+   must not be called more than once on the same allocation.
+
+     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
+   file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the
+   last read ended in the middle of a gzip stream, or Z_OK on success.
+*/
+
+ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
+ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
+/*
+     Same as gzclose(), but gzclose_r() is only for use when reading, and
+   gzclose_w() is only for use when writing or appending.  The advantage to
+   using these instead of gzclose() is that they avoid linking in zlib
+   compression or decompression code that is not used when only reading or only
+   writing respectively.  If gzclose() is used, then both compression and
+   decompression code will be included the application when linking to a static
+   zlib library.
+*/
+
+ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
+/*
+     Returns the error message for the last error which occurred on the given
+   compressed file.  errnum is set to zlib error number.  If an error occurred
+   in the file system and not in the compression library, errnum is set to
+   Z_ERRNO and the application may consult errno to get the exact error code.
+
+     The application must not modify the returned string.  Future calls to
+   this function may invalidate the previously returned string.  If file is
+   closed, then the string previously returned by gzerror will no longer be
+   available.
+
+     gzerror() should be used to distinguish errors from end-of-file for those
+   functions above that do not distinguish those cases in their return values.
+*/
+
+ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
+/*
+     Clears the error and end-of-file flags for file.  This is analogous to the
+   clearerr() function in stdio.  This is useful for continuing to read a gzip
+   file that is being written concurrently.
+*/
+
+#endif /* !Z_SOLO */
+
+                        /* checksum functions */
+
+/*
+     These functions are not related to compression but are exported
+   anyway because they might be useful in applications using the compression
+   library.
+*/
+
+ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
+/*
+     Update a running Adler-32 checksum with the bytes buf[0..len-1] and
+   return the updated checksum.  If buf is Z_NULL, this function returns the
+   required initial value for the checksum.
+
+     An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
+   much faster.
+
+   Usage example:
+
+     uLong adler = adler32(0L, Z_NULL, 0);
+
+     while (read_buffer(buffer, length) != EOF) {
+       adler = adler32(adler, buffer, length);
+     }
+     if (adler != original_adler) error();
+*/
+
+/*
+ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
+                                          z_off_t len2));
+
+     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1
+   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
+   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of
+   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.  Note
+   that the z_off_t type (like off_t) is a signed integer.  If len2 is
+   negative, the result has no meaning or utility.
+*/
+
+ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
+/*
+     Update a running CRC-32 with the bytes buf[0..len-1] and return the
+   updated CRC-32.  If buf is Z_NULL, this function returns the required
+   initial value for the crc.  Pre- and post-conditioning (one's complement) is
+   performed within this function so it shouldn't be done by the application.
+
+   Usage example:
+
+     uLong crc = crc32(0L, Z_NULL, 0);
+
+     while (read_buffer(buffer, length) != EOF) {
+       crc = crc32(crc, buffer, length);
+     }
+     if (crc != original_crc) error();
+*/
+
+/*
+ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
+
+     Combine two CRC-32 check values into one.  For two sequences of bytes,
+   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
+   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32
+   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
+   len2.
+*/
+
+
+                        /* various hacks, don't look :) */
+
+/* deflateInit and inflateInit are macros to allow checking the zlib version
+ * and the compiler's view of z_stream:
+ */
+ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
+                                     const char *version, int stream_size));
+ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
+                                     const char *version, int stream_size));
+ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
+                                      int windowBits, int memLevel,
+                                      int strategy, const char *version,
+                                      int stream_size));
+ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
+                                      const char *version, int stream_size));
+ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
+                                         unsigned char FAR *window,
+                                         const char *version,
+                                         int stream_size));
+#define deflateInit(strm, level) \
+        deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
+#define inflateInit(strm) \
+        inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
+#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
+        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
+                      (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
+#define inflateInit2(strm, windowBits) \
+        inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
+                      (int)sizeof(z_stream))
+#define inflateBackInit(strm, windowBits, window) \
+        inflateBackInit_((strm), (windowBits), (window), \
+                      ZLIB_VERSION, (int)sizeof(z_stream))
+
+#ifndef Z_SOLO
+
+/* gzgetc() macro and its supporting function and exposed data structure.  Note
+ * that the real internal state is much larger than the exposed structure.
+ * This abbreviated structure exposes just enough for the gzgetc() macro.  The
+ * user should not mess with these exposed elements, since their names or
+ * behavior could change in the future, perhaps even capriciously.  They can
+ * only be used by the gzgetc() macro.  You have been warned.
+ */
+struct gzFile_s {
+    unsigned have;
+    unsigned char *next;
+    z_off64_t pos;
+};
+ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));  /* backward compatibility */
+#ifdef Z_PREFIX_SET
+#  undef z_gzgetc
+#  define z_gzgetc(g) \
+          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
+#else
+#  define gzgetc(g) \
+          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
+#endif
+
+/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
+ * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
+ * both are true, the application gets the *64 functions, and the regular
+ * functions are changed to 64 bits) -- in case these are set on systems
+ * without large file support, _LFS64_LARGEFILE must also be true
+ */
+#ifdef Z_LARGE64
+   ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+   ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
+   ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
+   ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
+   ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
+   ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
+#endif
+
+#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
+#  ifdef Z_PREFIX_SET
+#    define z_gzopen z_gzopen64
+#    define z_gzseek z_gzseek64
+#    define z_gztell z_gztell64
+#    define z_gzoffset z_gzoffset64
+#    define z_adler32_combine z_adler32_combine64
+#    define z_crc32_combine z_crc32_combine64
+#  else
+#    define gzopen gzopen64
+#    define gzseek gzseek64
+#    define gztell gztell64
+#    define gzoffset gzoffset64
+#    define adler32_combine adler32_combine64
+#    define crc32_combine crc32_combine64
+#  endif
+#  ifndef Z_LARGE64
+     ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+     ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
+     ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
+     ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
+     ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
+     ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
+#  endif
+#else
+   ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
+   ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
+   ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
+   ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
+   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
+   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
+#endif
+
+#else /* Z_SOLO */
+
+   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
+   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
+
+#endif /* !Z_SOLO */
+
+/* hack for buggy compilers */
+#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
+    struct internal_state {int dummy;};
+#endif
+
+/* undocumented functions */
+ZEXTERN const char   * ZEXPORT zError           OF((int));
+ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));
+ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table    OF((void));
+ZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));
+ZEXTERN int            ZEXPORT inflateResetKeep OF((z_streamp));
+ZEXTERN int            ZEXPORT deflateResetKeep OF((z_streamp));
+#if defined(_WIN32) && !defined(Z_SOLO)
+ZEXTERN gzFile         ZEXPORT gzopen_w OF((const wchar_t *path,
+                                            const char *mode));
+#endif
+#if defined(STDC) || defined(Z_HAVE_STDARG_H)
+#  ifndef Z_SOLO
+ZEXTERN int            ZEXPORTVA gzvprintf Z_ARG((gzFile file,
+                                                  const char *format,
+                                                  va_list va));
+#  endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ZLIB_H */
diff --git a/frontend/libpicofe b/frontend/libpicofe
deleted file mode 160000 (submodule)
index 21604a0..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 21604a047941b8fe81d381ede0371c75da964afd
index 940ff05..35e37a0 100644 (file)
 #include "revision.h"
 #include "libretro.h"
 
+#ifdef _3DS
+#include "3ds/3ds_utils.h"
+#endif
+
+#define PORTS_NUMBER 8
+
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+#define ISHEXDEC ((buf[cursor]>='0') && (buf[cursor]<='9')) || ((buf[cursor]>='a') && (buf[cursor]<='f')) || ((buf[cursor]>='A') && (buf[cursor]<='F'))
+
+//hack to prevent retroarch freezing when reseting in the menu but not while running with the hot key
+static int rebootemu = 0;
+
 static retro_video_refresh_t video_cb;
 static retro_input_poll_t input_poll_cb;
 static retro_input_state_t input_state_cb;
@@ -41,28 +56,46 @@ static retro_audio_sample_batch_t audio_batch_cb;
 static struct retro_rumble_interface rumble;
 
 static void *vout_buf;
+static void * vout_buf_ptr;
 static int vout_width, vout_height;
 static int vout_doffs_old, vout_fb_dirty;
 static bool vout_can_dupe;
 static bool duping_enable;
+static bool found_bios;
 
 static int plugins_opened;
 static int is_pal_mode;
 
 /* memory card data */
 extern char Mcd1Data[MCD_SIZE];
+extern char Mcd2Data[MCD_SIZE];
 extern char McdDisable[2];
 
 /* PCSX ReARMed core calls and stuff */
-int in_type1, in_type2;
-int in_a1[2] = { 127, 127 }, in_a2[2] = { 127, 127 };
-int in_keystate;
+int in_type[8] =  { PSE_PAD_TYPE_NONE, PSE_PAD_TYPE_NONE,
+                  PSE_PAD_TYPE_NONE, PSE_PAD_TYPE_NONE,
+                  PSE_PAD_TYPE_NONE, PSE_PAD_TYPE_NONE,
+                  PSE_PAD_TYPE_NONE, PSE_PAD_TYPE_NONE };
+int in_analog_left[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }};
+int in_analog_right[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }};
+unsigned short in_keystate[PORTS_NUMBER];
+int multitap1 = 0;
+int multitap2 = 0;
 int in_enable_vibration = 1;
 
 /* PSX max resolution is 640x512, but with enhancement it's 1024x512 */
 #define VOUT_MAX_WIDTH 1024
 #define VOUT_MAX_HEIGHT 512
 
+//Dummy functions
+bool retro_load_game_special(unsigned game_type, const struct retro_game_info *info, size_t num_info){return false;}
+void retro_unload_game(void){}
+static int vout_open(void){return 0;}
+static void vout_close(void){}
+static int snd_init(void){return 0;}
+static void snd_finish(void){}
+static int snd_busy(void){return 0;}
+
 static void init_memcard(char *mcd_data)
 {
        unsigned off = 0;
@@ -96,15 +129,24 @@ static void init_memcard(char *mcd_data)
        }
 }
 
-static int vout_open(void)
-{
-       return 0;
-}
-
 static void vout_set_mode(int w, int h, int raw_w, int raw_h, int bpp)
 {
        vout_width = w;
        vout_height = h;
+
+  struct retro_framebuffer fb = {0};
+
+  fb.width           = vout_width;
+  fb.height          = vout_height;
+  fb.access_flags    = RETRO_MEMORY_ACCESS_WRITE;
+
+  vout_buf_ptr = vout_buf;
+
+  if (environ_cb(RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER, &fb) && fb.format == RETRO_PIXEL_FORMAT_RGB565)
+  {
+     vout_buf_ptr  = (uint16_t*)fb.data;
+  }
+
 }
 
 #ifndef FRONTEND_SUPPORTS_RGB565
@@ -121,14 +163,14 @@ static void convert(void *buf, size_t bytes)
 
 static void vout_flip(const void *vram, int stride, int bgr24, int w, int h)
 {
-       unsigned short *dest = vout_buf;
+       unsigned short *dest = vout_buf_ptr;
        const unsigned short *src = vram;
        int dstride = vout_width, h1 = h;
        int doffs;
 
        if (vram == NULL) {
                // blanking
-               memset(vout_buf, 0, dstride * h * 2);
+               memset(vout_buf_ptr, 0, dstride * h * 2);
                goto out;
        }
 
@@ -136,7 +178,7 @@ static void vout_flip(const void *vram, int stride, int bgr24, int w, int h)
        doffs += (dstride - w) / 2 & ~1;
        if (doffs != vout_doffs_old) {
                // clear borders
-               memset(vout_buf, 0, dstride * h * 2);
+               memset(vout_buf_ptr, 0, dstride * h * 2);
                vout_doffs_old = doffs;
        }
        dest += doffs;
@@ -159,15 +201,172 @@ static void vout_flip(const void *vram, int stride, int bgr24, int w, int h)
 
 out:
 #ifndef FRONTEND_SUPPORTS_RGB565
-       convert(vout_buf, vout_width * vout_height * 2);
+       convert(vout_buf_ptr, vout_width * vout_height * 2);
 #endif
        vout_fb_dirty = 1;
        pl_rearmed_cbs.flip_cnt++;
 }
 
-static void vout_close(void)
+#ifdef _3DS
+typedef struct
+{
+   void* buffer;
+   uint32_t target_map;
+   size_t size;
+   enum psxMapTag tag;
+}psx_map_t;
+
+psx_map_t custom_psx_maps[] = {
+   {NULL, 0x13000000, 0x210000, MAP_TAG_RAM},   // 0x80000000
+   {NULL, 0x12800000, 0x010000, MAP_TAG_OTHER}, // 0x1f800000
+   {NULL, 0x12c00000, 0x080000, MAP_TAG_OTHER}, // 0x1fc00000
+   {NULL, 0x11000000, 0x800000, MAP_TAG_LUTS},  // 0x08000000
+   {NULL, 0x12000000, 0x200000, MAP_TAG_VRAM},  // 0x00000000
+};
+
+void* pl_3ds_mmap(unsigned long addr, size_t size, int is_fixed,
+       enum psxMapTag tag)
+{
+   (void)is_fixed;
+   (void)addr;
+
+   if (__ctr_svchax)
+   {
+      psx_map_t* custom_map = custom_psx_maps;
+
+      for (; custom_map->size; custom_map++)
+      {
+         if ((custom_map->size == size) && (custom_map->tag == tag))
+         {
+            uint32_t ptr_aligned, tmp;
+
+            custom_map->buffer = malloc(size + 0x1000);
+            ptr_aligned = (((u32)custom_map->buffer) + 0xFFF) & ~0xFFF;
+
+            if(svcControlMemory(&tmp, (void*)custom_map->target_map, (void*)ptr_aligned, size, MEMOP_MAP, 0x3) < 0)
+            {
+               SysPrintf("could not map memory @0x%08X\n", custom_map->target_map);
+               exit(1);
+            }
+
+            return (void*)custom_map->target_map;
+         }
+      }
+   }
+
+   return malloc(size);
+}
+
+void pl_3ds_munmap(void *ptr, size_t size, enum psxMapTag tag)
+{
+   (void)tag;
+
+   if (__ctr_svchax)
+   {
+      psx_map_t* custom_map = custom_psx_maps;
+
+      for (; custom_map->size; custom_map++)
+      {
+         if ((custom_map->target_map == (uint32_t)ptr))
+         {
+            uint32_t ptr_aligned, tmp;
+
+            ptr_aligned = (((u32)custom_map->buffer) + 0xFFF) & ~0xFFF;
+
+            svcControlMemory(&tmp, (void*)custom_map->target_map, (void*)ptr_aligned, size, MEMOP_UNMAP, 0x3);
+
+            free(custom_map->buffer);
+            custom_map->buffer = NULL;
+            return;
+         }
+      }
+   }
+
+   free(ptr);
+}
+#endif
+
+#ifdef VITA
+typedef struct
+{
+   void* buffer;
+   uint32_t target_map;
+   size_t size;
+   enum psxMapTag tag;
+}psx_map_t;
+
+void* addr = NULL;
+
+psx_map_t custom_psx_maps[] = {
+   {NULL, NULL, 0x210000, MAP_TAG_RAM},   // 0x80000000
+   {NULL, NULL, 0x010000, MAP_TAG_OTHER}, // 0x1f800000
+   {NULL, NULL, 0x080000, MAP_TAG_OTHER}, // 0x1fc00000
+   {NULL, NULL, 0x800000, MAP_TAG_LUTS},  // 0x08000000
+   {NULL, NULL, 0x200000, MAP_TAG_VRAM},  // 0x00000000
+};
+
+int init_vita_mmap(){
+  int n;
+  void * tmpaddr;
+  addr = malloc(64*1024*1024);
+  if(addr==NULL)
+    return -1;
+  tmpaddr = ((u32)(addr+0xFFFFFF))&~0xFFFFFF;
+  custom_psx_maps[0].buffer=tmpaddr+0x2000000;
+  custom_psx_maps[1].buffer=tmpaddr+0x1800000;
+  custom_psx_maps[2].buffer=tmpaddr+0x1c00000;
+  custom_psx_maps[3].buffer=tmpaddr+0x0000000;
+  custom_psx_maps[4].buffer=tmpaddr+0x1000000;
+#if 0
+  for(n = 0; n < 5; n++){
+    sceClibPrintf("addr reserved %x\n",custom_psx_maps[n].buffer);
+  }
+#endif
+  return 0;
+}
+
+void deinit_vita_mmap(){
+  free(addr);
+}
+
+void* pl_vita_mmap(unsigned long addr, size_t size, int is_fixed,
+       enum psxMapTag tag)
+{
+   (void)is_fixed;
+   (void)addr;
+
+
+    psx_map_t* custom_map = custom_psx_maps;
+
+    for (; custom_map->size; custom_map++)
+    {
+       if ((custom_map->size == size) && (custom_map->tag == tag))
+       {
+          return custom_map->buffer;
+       }
+    }
+
+
+   return malloc(size);
+}
+
+void pl_vita_munmap(void *ptr, size_t size, enum psxMapTag tag)
 {
+   (void)tag;
+
+   psx_map_t* custom_map = custom_psx_maps;
+
+  for (; custom_map->size; custom_map++)
+  {
+     if ((custom_map->buffer == ptr))
+     {
+        return;
+     }
+  }
+
+   free(ptr);
 }
+#endif
 
 static void *pl_mmap(unsigned int size)
 {
@@ -204,8 +403,11 @@ void pl_timing_prepare(int is_pal)
 
 void plat_trigger_vibrate(int pad, int low, int high)
 {
-    rumble.set_rumble_state(pad, RETRO_RUMBLE_STRONG, high << 8);
-    rumble.set_rumble_state(pad, RETRO_RUMBLE_WEAK, low ? 0xffff : 0x0);
+       if(in_enable_vibration)
+       {
+       rumble.set_rumble_state(pad, RETRO_RUMBLE_STRONG, high << 8);
+       rumble.set_rumble_state(pad, RETRO_RUMBLE_WEAK, low ? 0xffff : 0x0);
+    }
 }
 
 void pl_update_gun(int *xn, int *yn, int *xres, int *yres, int *in)
@@ -213,20 +415,6 @@ void pl_update_gun(int *xn, int *yn, int *xres, int *yres, int *in)
 }
 
 /* sound calls */
-static int snd_init(void)
-{
-       return 0;
-}
-
-static void snd_finish(void)
-{
-}
-
-static int snd_busy(void)
-{
-       return 0;
-}
-
 static void snd_feed(void *buf, int bytes)
 {
        if (audio_batch_cb != NULL)
@@ -248,8 +436,17 @@ void retro_set_environment(retro_environment_t cb)
    static const struct retro_variable vars[] = {
       { "pcsx_rearmed_frameskip", "Frameskip; 0|1|2|3" },
       { "pcsx_rearmed_region", "Region; Auto|NTSC|PAL" },
-      { "pcsx_rearmed_pad1type", "Pad 1 Type; standard|analog" },
-      { "pcsx_rearmed_pad2type", "Pad 2 Type; standard|analog" },
+      { "pcsx_rearmed_pad1type", "Pad 1 Type; default|none|standard|analog|negcon" },
+      { "pcsx_rearmed_pad2type", "Pad 2 Type; default|none|standard|analog|negcon" },
+      { "pcsx_rearmed_pad3type", "Pad 3 Type; default|none|standard|analog|negcon" },
+      { "pcsx_rearmed_pad4type", "Pad 4 Type; default|none|standard|analog|negcon" },
+      { "pcsx_rearmed_pad5type", "Pad 5 Type; default|none|standard|analog|negcon" },
+      { "pcsx_rearmed_pad6type", "Pad 6 Type; default|none|standard|analog|negcon" },
+      { "pcsx_rearmed_pad7type", "Pad 7 Type; default|none|standard|analog|negcon" },
+      { "pcsx_rearmed_pad8type", "Pad 8 Type; default|none|standard|analog|negcon" },
+      { "pcsx_rearmed_multitap1", "Multitap 1; auto|disabled|enabled" },
+      { "pcsx_rearmed_multitap2", "Multitap 2; auto|disabled|enabled" },
+      { "pcsx_rearmed_vibration", "Enable Vibration; enabled|disabled" },
 #ifndef DRC_DISABLE
       { "pcsx_rearmed_drc", "Dynamic recompiler; enabled|disabled" },
 #endif
@@ -258,9 +455,12 @@ void retro_set_environment(retro_environment_t cb)
       { "pcsx_rearmed_neon_enhancement_enable", "Enhanced resolution (slow); disabled|enabled" },
       { "pcsx_rearmed_neon_enhancement_no_main", "Enhanced resolution speed hack; disabled|enabled" },
 #endif
-      { "pcsx_rearmed_duping_enable", "Frame duping; on|off" },
-      { "pcsx_rearmed_spu_reverb", "Sound: Reverb; on|off" },
+      { "pcsx_rearmed_duping_enable", "Frame duping; enabled|disabled" },
+      { "pcsx_rearmed_show_bios_bootlogo", "Show Bios Bootlogo(Breaks some games); disabled|enabled" },
+      { "pcsx_rearmed_spu_reverb", "Sound: Reverb; enabled|disabled" },
       { "pcsx_rearmed_spu_interpolation", "Sound: Interpolation; simple|gaussian|cubic|off" },
+      { "pcsx_rearmed_pe2_fix", "Parasite Eve 2/Vandal Hearts 1/2 Fix; disabled|enabled" },
+      { "pcsx_rearmed_inuyasha_fix", "InuYasha Sengoku Battle Fix; disabled|enabled" },
       { NULL, NULL },
    };
 
@@ -280,15 +480,170 @@ unsigned retro_api_version(void)
        return RETRO_API_VERSION;
 }
 
+static int controller_port_variable(unsigned port, struct retro_variable *var)
+{
+       if (port >= PORTS_NUMBER)
+               return 0;
+
+       if (!environ_cb)
+               return 0;
+
+       var->value = NULL;
+       switch (port) {
+       case 0:
+               var->key = "pcsx_rearmed_pad1type";
+               break;
+       case 1:
+               var->key = "pcsx_rearmed_pad2type";
+               break;
+       case 2:
+               var->key = "pcsx_rearmed_pad3type";
+               break;
+       case 3:
+               var->key = "pcsx_rearmed_pad4type";
+               break;
+       case 4:
+               var->key = "pcsx_rearmed_pad5type";
+               break;
+       case 5:
+               var->key = "pcsx_rearmed_pad6type";
+               break;
+       case 6:
+               var->key = "pcsx_rearmed_pad7type";
+               break;
+       case 7:
+               var->key = "pcsx_rearmed_pad8type";
+               break;
+       }
+
+       return environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, var) || var->value;
+}
+
+static void update_controller_port_variable(unsigned port)
+{
+       if (port >= PORTS_NUMBER)
+               return;
+
+       struct retro_variable var;
+
+       if (controller_port_variable(port, &var))
+       {
+               if (strcmp(var.value, "standard") == 0)
+                       in_type[port] = PSE_PAD_TYPE_STANDARD;
+               else if (strcmp(var.value, "analog") == 0)
+                       in_type[port] = PSE_PAD_TYPE_ANALOGPAD;
+               else if (strcmp(var.value, "negcon") == 0)
+                       in_type[port] = PSE_PAD_TYPE_NEGCON;
+               else if (strcmp(var.value, "none") == 0)
+                       in_type[port] = PSE_PAD_TYPE_NONE;
+               // else 'default' case, do nothing
+       }
+}
+
+static void update_controller_port_device(unsigned port, unsigned device)
+{
+       if (port >= PORTS_NUMBER)
+               return;
+
+       struct retro_variable var;
+
+       if (!controller_port_variable(port, &var))
+               return;
+
+       if (strcmp(var.value, "default") != 0)
+               return;
+
+       switch (device)
+       {
+       case RETRO_DEVICE_JOYPAD:
+               in_type[port] = PSE_PAD_TYPE_STANDARD;
+               break;
+       case RETRO_DEVICE_ANALOG:
+               in_type[port] = PSE_PAD_TYPE_ANALOGPAD;
+               break;
+       case RETRO_DEVICE_MOUSE:
+               in_type[port] = PSE_PAD_TYPE_MOUSE;
+               break;
+       case RETRO_DEVICE_LIGHTGUN:
+               in_type[port] = PSE_PAD_TYPE_GUN;
+               break;
+       case RETRO_DEVICE_NONE:
+       default:
+               in_type[port] = PSE_PAD_TYPE_NONE;
+       }
+}
+
+static void update_multitap()
+{
+       struct retro_variable var;
+       int auto_case, port;
+
+       var.value = NULL;
+       var.key = "pcsx_rearmed_multitap1";
+       auto_case = 0;
+       if (environ_cb && (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value))
+       {
+               if (strcmp(var.value, "enabled") == 0)
+                       multitap1 = 1;
+               else if (strcmp(var.value, "disabled") == 0)
+                       multitap1 = 0;
+               else // 'auto' case
+                       auto_case = 1;
+       }
+       else
+               auto_case = 1;
+
+       if (auto_case)
+       {
+               // If a gamepad is plugged after port 2, we need a first multitap.
+               multitap1 = 0;
+               for (port = 2; port < PORTS_NUMBER; port++)
+                       multitap1 |= in_type[port] != PSE_PAD_TYPE_NONE;
+       }
+
+       var.value = NULL;
+       var.key = "pcsx_rearmed_multitap2";
+       auto_case = 0;
+       if (environ_cb && (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value))
+       {
+               if (strcmp(var.value, "enabled") == 0)
+                       multitap2 = 1;
+               else if (strcmp(var.value, "disabled") == 0)
+                       multitap2 = 0;
+               else // 'auto' case
+                       auto_case = 1;
+       }
+       else
+               auto_case = 1;
+
+       if (auto_case)
+       {
+               // If a gamepad is plugged after port 4, we need a second multitap.
+               multitap2 = 0;
+               for (port = 4; port < PORTS_NUMBER; port++)
+                       multitap2 |= in_type[port] != PSE_PAD_TYPE_NONE;
+       }
+}
+
 void retro_set_controller_port_device(unsigned port, unsigned device)
 {
+       SysPrintf("port %u  device %u",port,device);
+
+       if (port >= PORTS_NUMBER)
+               return;
+
+       update_controller_port_device(port, device);
+       update_multitap();
 }
 
 void retro_get_system_info(struct retro_system_info *info)
 {
        memset(info, 0, sizeof(*info));
        info->library_name = "PCSX-ReARMed";
-       info->library_version = "r22";
+#ifndef GIT_VERSION
+#define GIT_VERSION ""
+#endif
+       info->library_version = "r22" GIT_VERSION;
        info->valid_extensions = "bin|cue|img|mdf|pbp|toc|cbn|m3u";
        info->need_fullpath = true;
 }
@@ -306,8 +661,8 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
 }
 
 /* savestates */
-size_t retro_serialize_size(void) 
-{ 
+size_t retro_serialize_size(void)
+{
        // it's currently 4380651-4397047 bytes,
        // but have some reserved for future
        return 0x440000;
@@ -393,7 +748,7 @@ static void save_close(void *file)
 }
 
 bool retro_serialize(void *data, size_t size)
-{ 
+{
        int ret = SaveState(data);
        return ret == 0 ? true : false;
 }
@@ -418,6 +773,21 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code)
        // cheat funcs are destructive, need a copy..
        strncpy(buf, code, sizeof(buf));
        buf[sizeof(buf) - 1] = 0;
+       
+       //Prepare buffered cheat for PCSX's AddCheat fucntion.
+       int cursor=0;
+       int nonhexdec=0;
+       while (buf[cursor]){
+               if (!(ISHEXDEC)){
+                       if (++nonhexdec%2){
+                               buf[cursor]=' ';
+                       } else {
+                               buf[cursor]='\n';
+                       }
+               }
+               cursor++;
+       }
+       
 
        if (index < NumCheats)
                ret = EditCheat(index, "", buf);
@@ -557,6 +927,10 @@ static struct retro_disk_control_callback disk_control = {
 #define SLASH '/'
 #endif
 
+#ifndef PATH_MAX
+#define PATH_MAX  4096
+#endif
+
 static char base_dir[PATH_MAX];
 
 static bool read_m3u(const char *file)
@@ -761,7 +1135,7 @@ bool retro_load_game(const struct retro_game_info *info)
       { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2,    "R2" },
       { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3,    "R3" },
       { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT,    "Select" },
-      { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START,    "Start" }, 
+      { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START,    "Start" },
       { 5, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" },
       { 5, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" },
       { 5, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" },
@@ -782,7 +1156,7 @@ bool retro_load_game(const struct retro_game_info *info)
       { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2,    "R2" },
       { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3,    "R3" },
       { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT,    "Select" },
-      { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START,    "Start" }, 
+      { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START,    "Start" },
       { 6, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" },
       { 6, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" },
       { 6, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" },
@@ -803,7 +1177,7 @@ bool retro_load_game(const struct retro_game_info *info)
       { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2,    "R2" },
       { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3,    "R3" },
       { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT,    "Select" },
-      { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START,    "Start" }, 
+      { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START,    "Start" },
       { 7, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" },
       { 7, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" },
       { 7, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" },
@@ -897,15 +1271,6 @@ bool retro_load_game(const struct retro_game_info *info)
        return true;
 }
 
-bool retro_load_game_special(unsigned game_type, const struct retro_game_info *info, size_t num_info)
-{
-       return false;
-}
-
-void retro_unload_game(void) 
-{
-}
-
 unsigned retro_get_region(void)
 {
        return is_pal_mode ? RETRO_REGION_PAL : RETRO_REGION_NTSC;
@@ -929,7 +1294,9 @@ size_t retro_get_memory_size(unsigned id)
 
 void retro_reset(void)
 {
-       SysReset();
+   //hack to prevent retroarch freezing when reseting in the menu but not while running with the hot key
+   rebootemu = 1;
+       //SysReset();
 }
 
 static const unsigned short retro_psx_map[] = {
@@ -955,16 +1322,15 @@ static const unsigned short retro_psx_map[] = {
 static void update_variables(bool in_flight)
 {
    struct retro_variable var;
-   
+   int i;
+
    var.value = NULL;
    var.key = "pcsx_rearmed_frameskip";
-
    if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
       pl_rearmed_cbs.frameskip = atoi(var.value);
 
    var.value = NULL;
    var.key = "pcsx_rearmed_region";
-
    if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
    {
       Config.PsxAuto = 0;
@@ -976,24 +1342,20 @@ static void update_variables(bool in_flight)
          Config.PsxType = 1;
    }
 
-   var.value = NULL;
-   var.key = "pcsx_rearmed_pad1type";
+   for (i = 0; i < PORTS_NUMBER; i++)
+      update_controller_port_variable(i);
 
-   if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
-   {
-      in_type1 = PSE_PAD_TYPE_STANDARD;
-      if (strcmp(var.value, "analog") == 0)
-         in_type1 = PSE_PAD_TYPE_ANALOGPAD;
-   }
+   update_multitap();
 
    var.value = NULL;
-   var.key = "pcsx_rearmed_pad2type";
+   var.key = "pcsx_rearmed_vibration";
 
    if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
    {
-      in_type2 = PSE_PAD_TYPE_STANDARD;
-      if (strcmp(var.value, "analog") == 0)
-         in_type2 = PSE_PAD_TYPE_ANALOGPAD;
+      if (strcmp(var.value, "disabled") == 0)
+         in_enable_vibration = 0;
+      else if (strcmp(var.value, "enabled") == 0)
+         in_enable_vibration = 1;
    }
 
 #ifdef __ARM_NEON__
@@ -1036,9 +1398,9 @@ static void update_variables(bool in_flight)
 
    if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
    {
-      if (strcmp(var.value, "off") == 0)
+      if (strcmp(var.value, "disabled") == 0)
          duping_enable = false;
-      else if (strcmp(var.value, "on") == 0)
+      else if (strcmp(var.value, "enabled") == 0)
          duping_enable = true;
    }
 
@@ -1050,6 +1412,11 @@ static void update_variables(bool in_flight)
    {
       R3000Acpu *prev_cpu = psxCpu;
 
+#ifdef _3DS
+      if(!__ctr_svchax)
+         Config.Cpu = CPU_INTERPRETER;
+      else
+#endif
       if (strcmp(var.value, "disabled") == 0)
          Config.Cpu = CPU_INTERPRETER;
       else if (strcmp(var.value, "enabled") == 0)
@@ -1069,9 +1436,9 @@ static void update_variables(bool in_flight)
 
    if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
    {
-      if (strcmp(var.value, "off") == 0)
+      if (strcmp(var.value, "disabled") == 0)
          spu_config.iUseReverb = false;
-      else if (strcmp(var.value, "on") == 0)
+      else if (strcmp(var.value, "enabled") == 0)
          spu_config.iUseReverb = true;
    }
 
@@ -1090,6 +1457,28 @@ static void update_variables(bool in_flight)
          spu_config.iUseInterpolation = 0;
    }
 
+   var.value = "NULL";
+   var.key = "pcsx_rearmed_pe2_fix";
+
+   if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
+   {
+      if (strcmp(var.value, "disabled") == 0)
+         Config.RCntFix = 0;
+      else if (strcmp(var.value, "enabled") == 0)
+         Config.RCntFix = 1;
+   }
+
+   var.value = "NULL";
+   var.key = "pcsx_rearmed_inuyasha_fix";
+
+   if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
+   {
+      if (strcmp(var.value, "disabled") == 0)
+         Config.VSyncWA = 0;
+      else if (strcmp(var.value, "enabled") == 0)
+         Config.VSyncWA = 1;
+   }
+
    if (in_flight) {
       // inform core things about possible config changes
       plugin_call_rearmed_cbs();
@@ -1101,11 +1490,30 @@ static void update_variables(bool in_flight)
 
       dfinput_activate();
    }
+   else{
+      //not yet running
+      
+      //bootlogo display hack
+      if (found_bios) {
+         var.value = "NULL";
+         var.key = "pcsx_rearmed_show_bios_bootlogo";
+         if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
+         {
+            if (strcmp(var.value, "enabled") == 0)
+               rebootemu = 1;
+         }
+      }
+   }
 }
 
-void retro_run(void) 
+void retro_run(void)
 {
-       int i;
+    int i;
+    //SysReset must be run while core is running,Not in menu (Locks up Retroarch)
+    if(rebootemu != 0){
+      rebootemu = 0;
+      SysReset();
+    }
 
        input_poll_cb();
 
@@ -1113,27 +1521,32 @@ void retro_run(void)
        if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
                update_variables(true);
 
-       in_keystate = 0;
-       for (i = 0; i < RETRO_PSX_MAP_LEN; i++)
-               if (input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i))
-                       in_keystate |= retro_psx_map[i];
-       in_keystate <<= 16;
-       for (i = 0; i < RETRO_PSX_MAP_LEN; i++)
-               if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i))
-                       in_keystate |= retro_psx_map[i];
+       // reset all keystate, query libretro for keystate
+       int j;
+       for(i = 0; i < PORTS_NUMBER; i++) {
+               in_keystate[i] = 0;
 
-       if (in_type1 == PSE_PAD_TYPE_ANALOGPAD)
-       {
-               in_a1[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
-               in_a1[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128;
-               in_a2[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
-               in_a2[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128;
+               if (in_type[i] == PSE_PAD_TYPE_NONE)
+                       continue;
+
+               // query libretro for keystate
+               for (j = 0; j < RETRO_PSX_MAP_LEN; j++)
+                       if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, j))
+                               in_keystate[i] |= retro_psx_map[j];
+
+               if (in_type[i] == PSE_PAD_TYPE_ANALOGPAD)
+               {
+                       in_analog_left[i][0] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255);
+                       in_analog_left[i][1] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255);
+                       in_analog_right[i][0] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255);
+                       in_analog_right[i][1] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255);
+               }
        }
 
        stop = 0;
        psxCpu->Execute();
 
-       video_cb((vout_fb_dirty || !vout_can_dupe || !duping_enable) ? vout_buf : NULL,
+       video_cb((vout_fb_dirty || !vout_can_dupe || !duping_enable) ? vout_buf_ptr : NULL,
                vout_width, vout_height, vout_width * 2);
        vout_fb_dirty = 0;
 }
@@ -1162,7 +1575,7 @@ static bool try_use_bios(const char *path)
        return true;
 }
 
-#if 1
+#ifndef VITA
 #include <sys/types.h>
 #include <dirent.h>
 
@@ -1200,33 +1613,54 @@ static void check_system_specs(void)
 
 void retro_init(void)
 {
-       const char *bios[] = { "scph1001", "scph5501", "scph7001" };
+       const char *bios[] = { "SCPH101", "SCPH7001", "SCPH5501", "SCPH1001" };
        const char *dir;
        char path[256];
        int i, ret;
-       bool found_bios = false;
+   
+   found_bios = false;
 
 #ifdef __MACH__
        // magic sauce to make the dynarec work on iOS
        syscall(SYS_ptrace, 0 /*PTRACE_TRACEME*/, 0, 0, 0);
 #endif
 
+#ifdef _3DS
+   psxMapHook = pl_3ds_mmap;
+   psxUnmapHook = pl_3ds_munmap;
+#endif
+#ifdef VITA
+   if(init_vita_mmap()<0)
+      abort();
+   psxMapHook = pl_vita_mmap;
+   psxUnmapHook = pl_vita_munmap;
+#endif
        ret = emu_core_preinit();
+#ifdef _3DS 
+   /* emu_core_preinit sets the cpu to dynarec */
+   if(!__ctr_svchax)
+      Config.Cpu = CPU_INTERPRETER;
+#endif
+
        ret |= emu_core_init();
        if (ret != 0) {
                SysPrintf("PCSX init failed.\n");
                exit(1);
        }
 
-#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L)
+#ifdef _3DS
+   vout_buf = linearMemAlign(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2, 0x80);
+#elif defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) && !defined(VITA)
        posix_memalign(&vout_buf, 16, VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2);
 #else
        vout_buf = malloc(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2);
 #endif
-
+  
+  vout_buf_ptr = vout_buf;
+  
        if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir)
        {
-               snprintf(Config.BiosDir, sizeof(Config.BiosDir), "%s/", dir);
+               snprintf(Config.BiosDir, sizeof(Config.BiosDir), "%s", dir);
 
                for (i = 0; i < sizeof(bios) / sizeof(bios[0]); i++) {
                        snprintf(path, sizeof(path), "%s/%s.bin", dir, bios[i]);
@@ -1244,9 +1678,9 @@ void retro_init(void)
        else
        {
                SysPrintf("no BIOS files found.\n");
-               struct retro_message msg = 
+               struct retro_message msg =
                {
-                       "no BIOS found, expect bugs!",
+                       "No BIOS file found - add for better compatibility",
                        180
                };
                environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, (void*)&msg);
@@ -1269,6 +1703,7 @@ void retro_init(void)
        McdDisable[0] = 0;
        McdDisable[1] = 1;
        init_memcard(Mcd1Data);
+   init_memcard(Mcd2Data);
 
        SaveFuncs.open = save_open;
        SaveFuncs.read = save_read;
@@ -1283,6 +1718,22 @@ void retro_init(void)
 void retro_deinit(void)
 {
        SysClose();
+#ifdef _3DS
+   linearFree(vout_buf);
+#else
        free(vout_buf);
+#endif
        vout_buf = NULL;
+
+#ifdef VITA
+  deinit_vita_mmap();
+#endif
+}
+
+#ifdef VITA
+#include <psp2/kernel/threadmgr.h>
+int usleep (unsigned long us)
+{
+   sceKernelDelayThread(us);
 }
+#endif
index 16c274a..a231548 100755 (executable)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2010-2014 The RetroArch team
+/* Copyright (C) 2010-2016 The RetroArch team
  *
  * ---------------------------------------------------------------------------------------
  * The following license statement only applies to this libretro API header (libretro.h).
@@ -43,6 +43,40 @@ extern "C" {
 #endif
 #endif
 
+#ifndef RETRO_CALLCONV
+#  if defined(__GNUC__) && defined(__i386__) && !defined(__x86_64__)
+#    define RETRO_CALLCONV __attribute__((cdecl))
+#  elif defined(_MSC_VER) && defined(_M_X86) && !defined(_M_X64)
+#    define RETRO_CALLCONV __cdecl
+#  else
+#    define RETRO_CALLCONV /* all other platforms only have one calling convention each */
+#  endif
+#endif
+
+#ifndef RETRO_API
+#  if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
+#    ifdef RETRO_IMPORT_SYMBOLS
+#      ifdef __GNUC__
+#        define RETRO_API RETRO_CALLCONV __attribute__((__dllimport__))
+#      else
+#        define RETRO_API RETRO_CALLCONV __declspec(dllimport)
+#      endif
+#    else
+#      ifdef __GNUC__
+#        define RETRO_API RETRO_CALLCONV __attribute__((__dllexport__))
+#      else
+#        define RETRO_API RETRO_CALLCONV __declspec(dllexport)
+#      endif
+#    endif
+#  else
+#      if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__CELLOS_LV2__)
+#        define RETRO_API RETRO_CALLCONV __attribute__((__visibility__("default")))
+#      else
+#        define RETRO_API RETRO_CALLCONV
+#      endif
+#  endif
+#endif
+
 /* Used for checking API/ABI mismatches that can break libretro 
  * implementations.
  * It is not incremented for compatible changes to the API.
@@ -165,13 +199,15 @@ extern "C" {
 #define RETRO_DEVICE_ID_ANALOG_Y         1
 
 /* Id values for MOUSE. */
-#define RETRO_DEVICE_ID_MOUSE_X          0
-#define RETRO_DEVICE_ID_MOUSE_Y          1
-#define RETRO_DEVICE_ID_MOUSE_LEFT       2
-#define RETRO_DEVICE_ID_MOUSE_RIGHT      3
-#define RETRO_DEVICE_ID_MOUSE_WHEELUP    4
-#define RETRO_DEVICE_ID_MOUSE_WHEELDOWN  5
-#define RETRO_DEVICE_ID_MOUSE_MIDDLE     6
+#define RETRO_DEVICE_ID_MOUSE_X                0
+#define RETRO_DEVICE_ID_MOUSE_Y                1
+#define RETRO_DEVICE_ID_MOUSE_LEFT             2
+#define RETRO_DEVICE_ID_MOUSE_RIGHT            3
+#define RETRO_DEVICE_ID_MOUSE_WHEELUP          4
+#define RETRO_DEVICE_ID_MOUSE_WHEELDOWN        5
+#define RETRO_DEVICE_ID_MOUSE_MIDDLE           6
+#define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP    7
+#define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN  8
 
 /* Id values for LIGHTGUN types. */
 #define RETRO_DEVICE_ID_LIGHTGUN_X        0
@@ -206,6 +242,8 @@ enum retro_language
    RETRO_LANGUAGE_KOREAN              =  9,
    RETRO_LANGUAGE_CHINESE_TRADITIONAL = 10,
    RETRO_LANGUAGE_CHINESE_SIMPLIFIED  = 11,
+   RETRO_LANGUAGE_ESPERANTO           = 12,
+   RETRO_LANGUAGE_POLISH              = 13,
    RETRO_LANGUAGE_LAST,
 
    /* Ensure sizeof(enum) == sizeof(int) */
@@ -693,9 +731,10 @@ enum retro_mod
                                             * location-based information from the host device,
                                             * such as current latitude / longitude.
                                             */
-#define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30
+#define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30 /* Old name, kept for compatibility. */
+#define RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY 30
                                            /* const char ** --
-                                            * Returns the "content" directory of the frontend.
+                                            * Returns the "core assets" directory of the frontend.
                                             * This directory can be used to store specific assets that the 
                                             * core relies upon, such as art assets,
                                             * input data, etc etc.
@@ -851,6 +890,61 @@ enum retro_mod
                                             * Returns the specified language of the frontend, if specified by the user.
                                             * It can be used by the core for localization purposes.
                                             */
+#define RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER (40 | RETRO_ENVIRONMENT_EXPERIMENTAL)
+                                           /* struct retro_framebuffer * --
+                                            * Returns a preallocated framebuffer which the core can use for rendering
+                                            * the frame into when not using SET_HW_RENDER.
+                                            * The framebuffer returned from this call must not be used
+                                            * after the current call to retro_run() returns.
+                                            *
+                                            * The goal of this call is to allow zero-copy behavior where a core
+                                            * can render directly into video memory, avoiding extra bandwidth cost by copying
+                                            * memory from core to video memory.
+                                            *
+                                            * If this call succeeds and the core renders into it,
+                                            * the framebuffer pointer and pitch can be passed to retro_video_refresh_t.
+                                            * If the buffer from GET_CURRENT_SOFTWARE_FRAMEBUFFER is to be used,
+                                            * the core must pass the exact
+                                            * same pointer as returned by GET_CURRENT_SOFTWARE_FRAMEBUFFER;
+                                            * i.e. passing a pointer which is offset from the
+                                            * buffer is undefined. The width, height and pitch parameters
+                                            * must also match exactly to the values obtained from GET_CURRENT_SOFTWARE_FRAMEBUFFER.
+                                            *
+                                            * It is possible for a frontend to return a different pixel format
+                                            * than the one used in SET_PIXEL_FORMAT. This can happen if the frontend
+                                            * needs to perform conversion.
+                                            *
+                                            * It is still valid for a core to render to a different buffer
+                                            * even if GET_CURRENT_SOFTWARE_FRAMEBUFFER succeeds.
+                                            *
+                                            * A frontend must make sure that the pointer obtained from this function is
+                                            * writeable (and readable).
+                                            */
+
+enum retro_hw_render_interface_type
+{
+   RETRO_HW_RENDER_INTERFACE_VULKAN = 0,
+   RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX
+};
+
+/* Base struct. All retro_hw_render_interface_* types
+ * contain at least these fields. */
+struct retro_hw_render_interface
+{
+   enum retro_hw_render_interface_type interface_type;
+   unsigned interface_version;
+};
+#define RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE (41 | RETRO_ENVIRONMENT_EXPERIMENTAL)
+                                           /* const struct retro_hw_render_interface ** --
+                                            * Returns an API specific rendering interface for accessing API specific data.
+                                            * Not all HW rendering APIs support or need this.
+                                            * The contents of the returned pointer is specific to the rendering API
+                                            * being used. See the various headers like libretro_vulkan.h, etc.
+                                            *
+                                            * GET_HW_RENDER_INTERFACE cannot be called before context_reset has been called.
+                                            * Similarly, after context_destroyed callback returns,
+                                            * the contents of the HW_RENDER_INTERFACE are invalidated.
+                                            */
 
 #define RETRO_MEMDESC_CONST     (1 << 0)   /* The frontend will never change this memory area once retro_load_game has returned. */
 #define RETRO_MEMDESC_BIGENDIAN (1 << 1)   /* The memory area contains big endian data. Default is little endian. */
@@ -1125,6 +1219,10 @@ struct retro_log_callback
 #define RETRO_SIMD_VFPU     (1 << 13)
 #define RETRO_SIMD_PS       (1 << 14)
 #define RETRO_SIMD_AES      (1 << 15)
+#define RETRO_SIMD_VFPV3    (1 << 16)
+#define RETRO_SIMD_VFPV4    (1 << 17)
+#define RETRO_SIMD_POPCNT   (1 << 18)
+#define RETRO_SIMD_MOVBE    (1 << 19)
 
 typedef uint64_t retro_perf_tick_t;
 typedef int64_t retro_time_t;
@@ -1464,6 +1562,9 @@ enum retro_hw_context_type
     * use the corresponding enums directly. */
    RETRO_HW_CONTEXT_OPENGLES_VERSION = 5,
 
+   /* Vulkan, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE. */
+   RETRO_HW_CONTEXT_VULKAN           = 6,
+
    RETRO_HW_CONTEXT_DUMMY = INT_MAX
 };
 
@@ -1486,23 +1587,28 @@ struct retro_hw_render_callback
     */
    retro_hw_context_reset_t context_reset;
 
-   /* Set by frontend. */
+   /* Set by frontend.
+    * TODO: This is rather obsolete. The frontend should not
+    * be providing preallocated framebuffers. */
    retro_hw_get_current_framebuffer_t get_current_framebuffer;
 
    /* Set by frontend. */
    retro_hw_get_proc_address_t get_proc_address;
 
-   /* Set if render buffers should have depth component attached. */
+   /* Set if render buffers should have depth component attached.
+    * TODO: Obsolete. */
    bool depth;
 
-   /* Set if stencil buffers should be attached. */
+   /* Set if stencil buffers should be attached.
+    * TODO: Obsolete. */
    bool stencil;
 
    /* If depth and stencil are true, a packed 24/8 buffer will be added. 
     * Only attaching stencil is invalid and will be ignored. */
 
    /* Use conventional bottom-left origin convention. If false, 
-    * standard libretro top-left origin semantics are used. */
+    * standard libretro top-left origin semantics are used.
+    * TODO: Move to GL specific interface. */
    bool bottom_left_origin;
    
    /* Major version number for core GL context or GLES 3.1+. */
@@ -1513,6 +1619,7 @@ struct retro_hw_render_callback
 
    /* If this is true, the frontend will go very far to avoid 
     * resetting context in scenarios like toggling fullscreen, etc.
+    * TODO: Obsolete? Maybe frontend should just always assume this ...
     */
    bool cache_context;
 
@@ -1779,6 +1886,36 @@ struct retro_game_info
    const char *meta;       /* String of implementation specific meta-data. */
 };
 
+#define RETRO_MEMORY_ACCESS_WRITE (1 << 0)
+   /* The core will write to the buffer provided by retro_framebuffer::data. */
+#define RETRO_MEMORY_ACCESS_READ (1 << 1)
+   /* The core will read from retro_framebuffer::data. */
+#define RETRO_MEMORY_TYPE_CACHED (1 << 0)
+   /* The memory in data is cached.
+    * If not cached, random writes and/or reading from the buffer is expected to be very slow. */
+struct retro_framebuffer
+{
+   void *data;                      /* The framebuffer which the core can render into.
+                                       Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER.
+                                       The initial contents of data are unspecified. */
+   unsigned width;                  /* The framebuffer width used by the core. Set by core. */
+   unsigned height;                 /* The framebuffer height used by the core. Set by core. */
+   size_t pitch;                    /* The number of bytes between the beginning of a scanline,
+                                       and beginning of the next scanline.
+                                       Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
+   enum retro_pixel_format format;  /* The pixel format the core must use to render into data.
+                                       This format could differ from the format used in
+                                       SET_PIXEL_FORMAT.
+                                       Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
+
+   unsigned access_flags;           /* How the core will access the memory in the framebuffer.
+                                       RETRO_MEMORY_ACCESS_* flags.
+                                       Set by core. */
+   unsigned memory_flags;           /* Flags telling core how the memory has been mapped.
+                                       RETRO_MEMORY_TYPE_* flags.
+                                       Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
+};
+
 /* Callbacks */
 
 /* Environment callback. Gives implementations a way of performing 
@@ -1832,25 +1969,25 @@ typedef int16_t (*retro_input_state_t)(unsigned port, unsigned device,
  *
  * The rest of the set_* functions are guaranteed to have been called 
  * before the first call to retro_run() is made. */
-void retro_set_environment(retro_environment_t);
-void retro_set_video_refresh(retro_video_refresh_t);
-void retro_set_audio_sample(retro_audio_sample_t);
-void retro_set_audio_sample_batch(retro_audio_sample_batch_t);
-void retro_set_input_poll(retro_input_poll_t);
-void retro_set_input_state(retro_input_state_t);
+RETRO_API void retro_set_environment(retro_environment_t);
+RETRO_API void retro_set_video_refresh(retro_video_refresh_t);
+RETRO_API void retro_set_audio_sample(retro_audio_sample_t);
+RETRO_API void retro_set_audio_sample_batch(retro_audio_sample_batch_t);
+RETRO_API void retro_set_input_poll(retro_input_poll_t);
+RETRO_API void retro_set_input_state(retro_input_state_t);
 
 /* Library global initialization/deinitialization. */
-void retro_init(void);
-void retro_deinit(void);
+RETRO_API void retro_init(void);
+RETRO_API void retro_deinit(void);
 
 /* Must return RETRO_API_VERSION. Used to validate ABI compatibility
  * when the API is revised. */
-unsigned retro_api_version(void);
+RETRO_API unsigned retro_api_version(void);
 
 /* Gets statically known system info. Pointers provided in *info 
  * must be statically allocated.
  * Can be called at any time, even before retro_init(). */
-void retro_get_system_info(struct retro_system_info *info);
+RETRO_API void retro_get_system_info(struct retro_system_info *info);
 
 /* Gets information about system audio/video timings and geometry.
  * Can be called only after retro_load_game() has successfully completed.
@@ -1858,7 +1995,7 @@ void retro_get_system_info(struct retro_system_info *info);
  * variable if needed.
  * E.g. geom.aspect_ratio might not be initialized if core doesn't 
  * desire a particular aspect ratio. */
-void retro_get_system_av_info(struct retro_system_av_info *info);
+RETRO_API void retro_get_system_av_info(struct retro_system_av_info *info);
 
 /* Sets device to be used for player 'port'.
  * By default, RETRO_DEVICE_JOYPAD is assumed to be plugged into all 
@@ -1868,10 +2005,10 @@ void retro_get_system_av_info(struct retro_system_av_info *info);
  * hint to the libretro core when a core cannot automatically detect the 
  * appropriate input device type on its own. It is also relevant when a 
  * core can change its behavior depending on device type. */
-void retro_set_controller_port_device(unsigned port, unsigned device);
+RETRO_API void retro_set_controller_port_device(unsigned port, unsigned device);
 
 /* Resets the current game. */
-void retro_reset(void);
+RETRO_API void retro_reset(void);
 
 /* Runs the game for one video frame.
  * During retro_run(), input_poll callback must be called at least once.
@@ -1881,7 +2018,7 @@ void retro_reset(void);
  * a frame if GET_CAN_DUPE returns true.
  * In this case, the video callback can take a NULL argument for data.
  */
-void retro_run(void);
+RETRO_API void retro_run(void);
 
 /* Returns the amount of data the implementation requires to serialize 
  * internal state (save states).
@@ -1889,35 +2026,35 @@ void retro_run(void);
  * returned size is never allowed to be larger than a previous returned 
  * value, to ensure that the frontend can allocate a save state buffer once.
  */
-size_t retro_serialize_size(void);
+RETRO_API size_t retro_serialize_size(void);
 
 /* Serializes internal state. If failed, or size is lower than
  * retro_serialize_size(), it should return false, true otherwise. */
-bool retro_serialize(void *data, size_t size);
-bool retro_unserialize(const void *data, size_t size);
+RETRO_API bool retro_serialize(void *data, size_t size);
+RETRO_API bool retro_unserialize(const void *data, size_t size);
 
-void retro_cheat_reset(void);
-void retro_cheat_set(unsigned index, bool enabled, const char *code);
+RETRO_API void retro_cheat_reset(void);
+RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char *code);
 
 /* Loads a game. */
-bool retro_load_game(const struct retro_game_info *game);
+RETRO_API bool retro_load_game(const struct retro_game_info *game);
 
 /* Loads a "special" kind of game. Should not be used,
  * except in extreme cases. */
-bool retro_load_game_special(
+RETRO_API bool retro_load_game_special(
   unsigned game_type,
   const struct retro_game_info *info, size_t num_info
 );
 
 /* Unloads a currently loaded game. */
-void retro_unload_game(void);
+RETRO_API void retro_unload_game(void);
 
 /* Gets region of game. */
-unsigned retro_get_region(void);
+RETRO_API unsigned retro_get_region(void);
 
 /* Gets region of memory. */
-void *retro_get_memory_data(unsigned id);
-size_t retro_get_memory_size(unsigned id);
+RETRO_API void *retro_get_memory_data(unsigned id);
+RETRO_API size_t retro_get_memory_size(unsigned id);
 
 #ifdef __cplusplus
 }
index a824fdc..2d438aa 100644 (file)
@@ -11,7 +11,7 @@
 #include <unistd.h>
 #include <signal.h>
 #include <time.h>
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(NO_DYLIB)
 #include <dlfcn.h>
 #endif
 
@@ -151,8 +151,8 @@ void emu_set_default_config(void)
        new_dynarec_hacks = 0;
        cycle_multiplier = 200;
 
-       in_type1 = PSE_PAD_TYPE_STANDARD;
-       in_type2 = PSE_PAD_TYPE_STANDARD;
+       in_type[0] = PSE_PAD_TYPE_STANDARD;
+       in_type[1] = PSE_PAD_TYPE_STANDARD;
 }
 
 void do_emu_action(void)
@@ -721,10 +721,10 @@ void SysReset() {
        // reset can run code, timing must be set
        pl_timing_prepare(Config.PsxType);
 
-       EmuReset();
-
-       // hmh core forgets this
+   // hmh core forgets this
        CDR_stop();
+   
+       EmuReset();
 
        GPU_updateLace = real_lace;
        g_emu_resetting = 0;
@@ -772,7 +772,7 @@ int emu_save_state(int slot)
                return ret;
 
        ret = SaveState(fname);
-#ifdef HAVE_PRE_ARMV7 /* XXX GPH hack */
+#if defined(HAVE_PRE_ARMV7) && !defined(_3DS) /* XXX GPH hack */
        sync();
 #endif
        SysPrintf("* %s \"%s\" [%d]\n",
@@ -986,7 +986,7 @@ void *SysLoadLibrary(const char *lib) {
                                return (void *)(long)(PLUGIN_DL_BASE + builtin_plugin_ids[i]);
        }
 
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(NO_DYLIB)
        ret = dlopen(lib, RTLD_NOW);
        if (ret == NULL)
                SysMessage("dlopen: %s", dlerror());
@@ -1003,7 +1003,7 @@ void *SysLoadSym(void *lib, const char *sym) {
        if (PLUGIN_DL_BASE <= plugid && plugid < PLUGIN_DL_BASE + ARRAY_SIZE(builtin_plugins))
                return plugin_link(plugid - PLUGIN_DL_BASE, sym);
 
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(NO_DYLIB)
        return dlsym(lib, sym);
 #else
        return NULL;
@@ -1011,7 +1011,9 @@ void *SysLoadSym(void *lib, const char *sym) {
 }
 
 const char *SysLibError() {
-#ifndef _WIN32
+#if defined(NO_DYLIB)
+   return NULL;
+#elif !defined(_WIN32)
        return dlerror();
 #else
        return "not supported";
@@ -1024,8 +1026,7 @@ void SysCloseLibrary(void *lib) {
        if (PLUGIN_DL_BASE <= plugid && plugid < PLUGIN_DL_BASE + ARRAY_SIZE(builtin_plugins))
                return;
 
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(NO_DYLIB)
        dlclose(lib);
 #endif
 }
-
index cf9382a..7e1fdd1 100644 (file)
@@ -309,12 +309,12 @@ static void menu_sync_config(void)
 
        switch (in_type_sel1) {
        case 1:  in_type1 = PSE_PAD_TYPE_ANALOGPAD; break;
-       case 2:  in_type1 = PSE_PAD_TYPE_GUNCON;    break;
+       case 2:  in_type1 = PSE_PAD_TYPE_NEGCON;    break;
        default: in_type1 = PSE_PAD_TYPE_STANDARD;
        }
        switch (in_type_sel2) {
        case 1:  in_type2 = PSE_PAD_TYPE_ANALOGPAD; break;
-       case 2:  in_type2 = PSE_PAD_TYPE_GUNCON;    break;
+       case 2:  in_type2 = PSE_PAD_TYPE_NEGCON;    break;
        default: in_type2 = PSE_PAD_TYPE_STANDARD;
        }
        if (in_evdev_allow_abs_only != allow_abs_only_old) {
diff --git a/frontend/pandora/pcsx.png b/frontend/pandora/pcsx.png
deleted file mode 100644 (file)
index 71f36d0..0000000
Binary files a/frontend/pandora/pcsx.png and /dev/null differ
diff --git a/frontend/pandora/pcsx.pxml.templ b/frontend/pandora/pcsx.pxml.templ
deleted file mode 100644 (file)
index f748065..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<PXML xmlns="http://openpandora.org/namespaces/PXML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PXML_schema.xsd">
-<package id="package.pcsx_rearmed.notaz">
-  <titles>
-    <title lang="en_US">PCSX ReARMed</title>
-  </titles>
-  <version major="1" minor="9" release="93" build="%PR%"/>
-  <author name="PCSX team/notaz" website="http://notaz.gp2x.de/"/>
-</package>
-<application id="pcsx_rearmed.notaz.%PR%" appdata="pcsx_rearmed">
-  <titles>
-    <title lang="en_US">PCSX ReARMed %PR%</title>
-  </titles>
-  <title lang="en_US">PCSX ReARMed %PR%</title>
-
-  <descriptions>
-    <description lang="en_US">PCSX ReARMed is heavily optimized PlayStation Emulator. It's a PCSX fork based on the PCSX-Reloaded project, which itself contains code from PCSX, PCSX-df and PCSX-Revolution.
-
-The emulator features MIPS->ARM recompiler by Ari64 and ARM NEON GPU by Exophase, that in many cases produces pixel perfect graphics at very high performance. There is also NEON-optimized GTE code, optimized P.E.Op.S. (Pete's) SPU; PCSX4ALL and traditional P.E.Op.S. GPUs are also available.</description>
-  </descriptions>
-
-  <exec command="pcsx.sh"/>
-
-  <icon src="pcsx.png"/>
-
-  <author name="PCSX team/notaz" website="http://notaz.gp2x.de/"/>
-
-  <version major="1" minor="9" release="93" build="%PR%"/>
-
-  <licenses>
-    <license name="GPLv2+" url="http://www.gnu.org/licenses/gpl-2.0.html" sourcecodeurl="http://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git"/>
-  </licenses>
-
-  <info name="PCSX ReARMed %PR% readme" type="text/plain" src="readme.txt"/>
-  <categories>
-    <category name="Game">
-    <subcategory name="Emulator"/>
-    </category>
-  </categories>
-</application>
-</PXML>
diff --git a/frontend/pandora/pcsx.sh b/frontend/pandora/pcsx.sh
deleted file mode 100755 (executable)
index 710f641..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-# stupid nub mode thing
-nub0mode=`cat /proc/pandora/nub0/mode`
-nub1mode=`cat /proc/pandora/nub1/mode`
-/usr/pandora/scripts/op_nubchange.sh absolute absolute
-
-# 4MB for RAM (2+align) + 2MB for vram (1+overdraw)
-#  + 10MB for gpu_neon (8+overdraw) + 8MB LUTs
-# no big deal if this fails, only performance loss
-sudo -n /usr/pandora/scripts/op_hugetlb.sh 24
-
-# C64x DSP for SPU
-sudo -n /usr/pandora/scripts/op_dsp_c64.sh
-
-./pcsx "$@"
-
-# restore stuff if pcsx crashes
-./picorestore
-sudo -n /usr/pandora/scripts/op_lcdrate.sh 60
-sudo -n /usr/pandora/scripts/op_gamma.sh 0
-sudo -n /usr/pandora/scripts/op_hugetlb.sh 0
-
-/usr/pandora/scripts/op_nubchange.sh $nub0mode $nub1mode
diff --git a/frontend/pandora/picorestore.c b/frontend/pandora/picorestore.c
deleted file mode 100644 (file)
index 77f5720..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * picorestore - clean up after an omapfb program crash
- *
- * Copyright (c) Gražvydas "notaz" Ignotas, 2010
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of the organization nor the
- *       names of its contributors may be used to endorse or promote products
- *       derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <linux/fb.h>
-#include <linux/omapfb.h>
-#include <linux/kd.h>
-
-int main()
-{
-       struct fb_var_screeninfo fbvar;
-       struct omapfb_plane_info pi;
-       struct omapfb_mem_info mi;
-       int ret, fbdev, kbdfd;
-
-       fbdev = open("/dev/fb0", O_RDWR);
-       if (fbdev == -1) {
-               perror("open fb0");
-               goto end_fb0;
-       }
-
-       ret = ioctl(fbdev, FBIOGET_VSCREENINFO, &fbvar);
-       if (ret == -1) {
-               perror("FBIOGET_VSCREENINFO ioctl");
-               goto end_fb0;
-       }
-
-       if (fbvar.yoffset != 0) {
-               printf("fixing yoffset.. ");
-               fbvar.yoffset = 0;
-               ret = ioctl(fbdev, FBIOPAN_DISPLAY, &fbvar);
-               if (ret < 0)
-                       perror("ioctl FBIOPAN_DISPLAY");
-               else
-                       printf("ok\n");
-       }
-
-end_fb0:
-       if (fbdev >= 0)
-               close(fbdev);
-
-       fbdev = open("/dev/fb1", O_RDWR);
-       if (fbdev == -1) {
-               perror("open fb1");
-               goto end_fb1;
-       }
-
-       ret  = ioctl(fbdev, OMAPFB_QUERY_PLANE, &pi);
-       ret |= ioctl(fbdev, OMAPFB_QUERY_MEM, &mi);
-       if (ret != 0)
-               perror("QUERY_*");
-
-       pi.enabled = 0;
-       ret = ioctl(fbdev, OMAPFB_SETUP_PLANE, &pi);
-       if (ret != 0)
-               perror("SETUP_PLANE");
-
-       mi.size = 0;
-       ret = ioctl(fbdev, OMAPFB_SETUP_MEM, &mi);
-       if (ret != 0)
-               perror("SETUP_MEM");
-
-end_fb1:
-       if (fbdev >= 0)
-               close(fbdev);
-
-       kbdfd = open("/dev/tty", O_RDWR);
-       if (kbdfd == -1) {
-               perror("open /dev/tty");
-               return 1;
-       }
-
-       if (ioctl(kbdfd, KDSETMODE, KD_TEXT) == -1)
-               perror("KDSETMODE KD_TEXT");
-
-       close(kbdfd);
-
-       return 0;
-}
diff --git a/frontend/pandora/skin/background.png b/frontend/pandora/skin/background.png
deleted file mode 100644 (file)
index f4b4523..0000000
Binary files a/frontend/pandora/skin/background.png and /dev/null differ
diff --git a/frontend/pandora/skin/font.png b/frontend/pandora/skin/font.png
deleted file mode 100644 (file)
index 707a5b4..0000000
Binary files a/frontend/pandora/skin/font.png and /dev/null differ
diff --git a/frontend/pandora/skin/readme.txt b/frontend/pandora/skin/readme.txt
deleted file mode 100644 (file)
index dd83963..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-The skin images can be customized, but there are several limitations:\r
-\r
-background.png - must be 320x240 image with 24bit RGB colors.\r
-font.png       - must be 128x160 8bit grayscale image.\r
-selector.png   - must be 8x10 8bit grayscale image.\r
-\r
-Font and selector colors can be changed by editing skin.txt.\r
-\r
diff --git a/frontend/pandora/skin/selector.png b/frontend/pandora/skin/selector.png
deleted file mode 100644 (file)
index a439169..0000000
Binary files a/frontend/pandora/skin/selector.png and /dev/null differ
diff --git a/frontend/pandora/skin/skin.txt b/frontend/pandora/skin/skin.txt
deleted file mode 100644 (file)
index 1d6979f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-// html-style hex color codes, ex. ff0000 is red, 0000ff is blue, etc.\r
-text_color=ffffc0\r
-selection_color=808010\r
-\r
diff --git a/frontend/pandora/ui_feat.h b/frontend/pandora/ui_feat.h
deleted file mode 100644 (file)
index 3bb808a..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef UI_FEATURES_H
-#define UI_FEATURES_H
-
-#define MENU_BIOS_PATH "<SD card>/pandora/appdata/pcsx_rearmed/bios/"
-#define BOOT_MSG "Booting up...  (press SPACE for menu)"
-#define MENU_SHOW_VARSCALER 1
-#define MENU_SHOW_VOUTMODE 0
-#define MENU_SHOW_SCALER2 0
-#define MENU_SHOW_NUBS_BTNS 1
-#define MENU_SHOW_VIBRATION 0
-#define MENU_SHOW_DEADZONE 0
-#define MENU_SHOW_MINIMIZE 1
-#define MENU_SHOW_FULLSCREEN 0
-#define MENU_SHOW_VOLUME 0
-
-#endif // UI_FEATURES_H
index d9eb04a..6bb9aa4 100644 (file)
@@ -49,24 +49,43 @@ extern void CALLBACK SPUasync(unsigned int, unsigned int);
 extern int  CALLBACK SPUplayCDDAchannel(short *, int);
 
 /* PAD */
-static long PADreadPort1(PadDataS *pad)
-{
-       pad->controllerType = in_type1;
-       pad->buttonStatus = ~in_keystate;
-       if (in_type1 == PSE_PAD_TYPE_ANALOGPAD) {
-               pad->leftJoyX = in_a1[0];
-               pad->leftJoyY = in_a1[1];
-               pad->rightJoyX = in_a2[0];
-               pad->rightJoyY = in_a2[1];
-       }
-       return 0;
+static long PADreadPort1(PadDataS *pad) {
+       int pad_index = pad->requestPadIndex;
+    pad->controllerType = in_type[pad_index];
+    pad->buttonStatus = ~in_keystate[pad_index];
+    if (multitap1 == 1)
+       pad->portMultitap = 1;
+    else
+       pad->portMultitap = 0;
+    
+    if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON)
+    {
+        pad->leftJoyX = in_analog_left[pad_index][0];
+        pad->leftJoyY = in_analog_left[pad_index][1];
+        pad->rightJoyX = in_analog_right[pad_index][0];
+        pad->rightJoyY = in_analog_right[pad_index][1];
+    }
+    return 0;
 }
 
-static long PADreadPort2(PadDataS *pad)
-{
-       pad->controllerType = in_type2;
-       pad->buttonStatus = ~in_keystate >> 16;
-       return 0;
+static long PADreadPort2(PadDataS *pad) {
+       int pad_index = pad->requestPadIndex;
+    
+    pad->controllerType = in_type[pad_index];
+    pad->buttonStatus = ~in_keystate[pad_index];
+    if (multitap2 == 1)
+       pad->portMultitap = 2;
+    else
+       pad->portMultitap = 0;
+    
+    if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON)
+    {
+        pad->leftJoyX = in_analog_left[pad_index][0];
+        pad->leftJoyY = in_analog_left[pad_index][1];
+        pad->rightJoyX = in_analog_right[pad_index][0];
+        pad->rightJoyY = in_analog_right[pad_index][1];
+    }
+    return 0;
 }
 
 /* GPU */
index ab4d415..c65bfeb 100644 (file)
 
 #define HUD_HEIGHT 10
 
-int in_type1, in_type2;
-int in_a1[2] = { 127, 127 }, in_a2[2] = { 127, 127 };
+int in_type[8];
+int multitap1;
+int multitap2;
+int in_analog_left[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }};
+int in_analog_right[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }};
 int in_adev[2] = { -1, -1 }, in_adev_axis[2][2] = {{ 0, 1 }, { 0, 1 }};
 int in_adev_is_nublike[2];
-int in_keystate, in_state_gun;
+unsigned short in_keystate[8];
+int in_state_gun;
 int in_enable_vibration;
 void *tsdev;
 void *pl_vout_buf;
@@ -560,7 +564,7 @@ static void update_analog_nub_adjust(int *x_, int *y_)
 
 static void update_analogs(void)
 {
-       int *nubp[2] = { in_a1, in_a2 };
+       int *nubp[2] = { in_analog_left[0], in_analog_right[0] };
        int vals[2];
        int i, a, v, ret;
 
@@ -597,7 +601,7 @@ static void update_input(void)
        unsigned int emu_act;
 
        in_update(actions);
-       if (in_type1 == PSE_PAD_TYPE_ANALOGPAD)
+       if (in_type[0] == PSE_PAD_TYPE_ANALOGPAD)
                update_analogs();
        emu_act = actions[IN_BINDTYPE_EMU];
        in_state_gun = (emu_act & SACTION_GUN_MASK) >> SACTION_GUN_TRIGGER;
@@ -611,7 +615,7 @@ static void update_input(void)
        }
        emu_set_action(emu_act);
 
-       in_keystate = actions[IN_BINDTYPE_PLAYER12];
+       in_keystate[0] = actions[IN_BINDTYPE_PLAYER12];
 }
 #else /* MAEMO */
 extern void update_input(void);
index 4a11002..83b2774 100644 (file)
@@ -17,8 +17,14 @@ enum {
        DKEY_CROSS,
        DKEY_SQUARE,
 };
-extern int in_type1, in_type2;
-extern int in_keystate, in_state_gun, in_a1[2], in_a2[2];
+extern int in_state_gun;
+extern int in_type[8];
+extern int multitap1;
+extern int multitap2;
+extern int in_analog_left[8][2];
+extern int in_analog_right[8][2];
+extern unsigned short in_keystate[8];
+
 extern int in_adev[2], in_adev_axis[2][2];
 extern int in_adev_is_nublike[2];
 extern int in_enable_vibration;
diff --git a/frontend/vita/retro_inline.h b/frontend/vita/retro_inline.h
new file mode 100644 (file)
index 0000000..8535d84
--- /dev/null
@@ -0,0 +1,39 @@
+/* Copyright  (C) 2010-2015 The RetroArch team
+ *
+ * ---------------------------------------------------------------------------------------
+ * The following license statement only applies to this file (retro_inline.h).
+ * ---------------------------------------------------------------------------------------
+ *
+ * Permission is hereby granted, free of charge,
+ * to any person obtaining a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __LIBRETRO_SDK_INLINE_H
+#define __LIBRETRO_SDK_INLINE_H
+
+#ifndef INLINE
+
+#if !defined(__cplusplus) && defined(_WIN32)
+#define INLINE _inline
+#elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
+#define INLINE inline
+#elif defined(__GNUC__)
+#define INLINE __inline__
+#else
+#define INLINE
+#endif
+
+#endif
+#endif
diff --git a/frontend/vita/sys/mman.h b/frontend/vita/sys/mman.h
new file mode 100644 (file)
index 0000000..89da513
--- /dev/null
@@ -0,0 +1,69 @@
+#ifndef MMAN_H
+#define MMAN_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "stdlib.h"
+#include "stdio.h"
+
+#define PROT_READ       0b001
+#define PROT_WRITE      0b010
+#define PROT_EXEC       0b100
+#define MAP_PRIVATE     2
+#define MAP_ANONYMOUS   0x20
+
+#define MAP_FAILED      ((void *)-1)
+
+static inline void* mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
+{
+   (void)prot;
+   (void)flags;
+   (void)fd;
+   (void)offset;
+
+   int block, ret;
+
+   block = sceKernelAllocMemBlockForVM("code", len);
+   if(block<=0){
+     sceClibPrintf("could not alloc mem block @0x%08X 0x%08X \n", block, len);
+     exit(1);
+   }
+
+   // get base address
+   ret = sceKernelGetMemBlockBase(block, &addr);
+   if (ret < 0)
+   {
+     sceClibPrintf("could get address @0x%08X 0x%08X  \n", block, addr);
+     exit(1);
+   }
+
+
+   if(!addr)
+      return MAP_FAILED;
+
+   return addr;
+}
+
+static inline int mprotect(void *addr, size_t len, int prot)
+{
+   (void)addr;
+   (void)len;
+   (void)prot;
+   return 0;
+}
+
+static inline int munmap(void *addr, size_t len)
+{
+  int uid = sceKernelFindMemBlockByAddr(addr, len);
+
+  return sceKernelFreeMemBlock(uid);
+
+}
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif // MMAN_H
diff --git a/frontend/warm b/frontend/warm
deleted file mode 160000 (submodule)
index a6f015d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit a6f015da3b10b82a476250793645c071340decbc
index 9986654..6fc59b7 100644 (file)
@@ -153,6 +153,8 @@ typedef struct
 
 
 
+// No controller
+#define PSE_PAD_TYPE_NONE                      0
 // MOUSE SCPH-1030
 #define PSE_PAD_TYPE_MOUSE                     1
 // NEGCON - 16 button analog controller SLPH-00001
@@ -191,9 +193,15 @@ typedef struct
 
 typedef struct
 {
-       // controler type - fill it withe predefined values above
+       // controller type - fill it withe predefined values above
        unsigned char controllerType;
 
+       //0 : no multitap between psx and pad
+       //1 : multitap between psx and pad on port 1
+       //2 : multitap between psx and pad on port 2
+       int portMultitap;
+       int requestPadIndex;
+
        // status of buttons - every controller fills this field
        unsigned short buttonStatus;
 
@@ -207,7 +215,9 @@ typedef struct
 
        unsigned char Vib[2];
        unsigned char VibF[2];
-
+       
+       //configuration mode Request 0x43
+       int configMode;
        unsigned char reserved[87];
 
 } PadDataS;
index 72c6738..9dd9e39 100644 (file)
@@ -2,8 +2,16 @@ LOCAL_PATH := $(call my-dir)
 
 include $(CLEAR_VARS)
 
+GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
+ifneq ($(GIT_VERSION)," unknown")
+       LOCAL_CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
+endif
+
 APP_DIR := ../../src
 
+#fix stupid change in ndk r11 that breaks compiling even when the exe would run fine
+LOCAL_DISABLE_FATAL_LINKER_WARNINGS := true
+
 ifneq ($(TARGET_ARCH_ABI),armeabi-v7a)
    NO_NEON_BUILD := 1
 else
@@ -24,7 +32,7 @@ ifeq ($(TARGET_ARCH),arm)
    LOCAL_SRC_FILES += ../libpcsxcore/gte_arm.S
 
    # dynarec
-   LOCAL_SRC_FILES += ../libpcsxcore/new_dynarec/new_dynarec.c ../libpcsxcore/new_dynarec/linkage_arm.S ../libpcsxcore/new_dynarec/emu_if.c ../libpcsxcore/new_dynarec/pcsxmem.c
+   LOCAL_SRC_FILES += ../libpcsxcore/new_dynarec/new_dynarec.c ../libpcsxcore/new_dynarec/arm/linkage_arm.S ../libpcsxcore/new_dynarec/backends/psx/emu_if.c ../libpcsxcore/new_dynarec/backends/psx/pcsxmem.c
 
    # spu
    LOCAL_SRC_FILES += ../plugins/dfsound/arm_utils.S
@@ -92,7 +100,7 @@ LOCAL_SRC_FILES += ../frontend/main.c ../frontend/plugin.c ../frontend/cspace.c
 # libretro
 LOCAL_SRC_FILES += ../frontend/libretro.c
 
-LOCAL_CFLAGS += -O3 -ffast-math -funroll-loops -DNDEBUG -D_FILE_OFFSET_BITS=64 -DHAVE_LIBRETRO -DNO_FRONTEND -DFRONTEND_SUPPORTS_RGB565
+LOCAL_CFLAGS += -O3 -ffast-math -funroll-loops -DNDEBUG -D_FILE_OFFSET_BITS=64 -DHAVE_LIBRETRO -DNO_FRONTEND -DFRONTEND_SUPPORTS_RGB565 -DANDROID
 LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include
 LOCAL_LDLIBS := -lz -llog
 
index f05229c..3e882e7 100644 (file)
@@ -1 +1,2 @@
 APP_ABI := armeabi armeabi-v7a
+APP_PLATFORM := android-9
index 515370f..169c945 100644 (file)
 #include "cdriso.h"
 #include "ppf.h"
 
+#include <errno.h>
+#include <zlib.h>
+
 #ifdef _WIN32
 #define WIN32_LEAN_AND_MEAN
 #include <process.h>
 #include <windows.h>
 #define strcasecmp _stricmp
-#define usleep(x) Sleep((x) / 1000)
+#define usleep(x) (Sleep((x) / 1000))
 #else
 #include <pthread.h>
 #include <sys/time.h>
 #include <unistd.h>
 #endif
-#include <errno.h>
-#include <zlib.h>
 
 #define OFF_T_MSB ((off_t)1 << (sizeof(off_t) * 8 - 1))
 
@@ -225,7 +226,9 @@ static void *playthread(void *param)
                        do {
                                ret = SPU_playCDDAchannel((short *)sndbuffer, s);
                                if (ret == 0x7761)
+            {
                                        usleep(6 * 1000);
+            }
                        } while (ret == 0x7761 && playing); // rearmed_wait
                }
 
@@ -236,7 +239,9 @@ static void *playthread(void *param)
                        // HACK: stop feeding data while emu is paused
                        extern int stop;
                        while (stop && playing)
+         {
                                usleep(10000);
+         }
 
                        now = GetTickCount();
                        osleep = t - now;
@@ -1089,7 +1094,7 @@ static int cdread_sub_mixed(FILE *f, unsigned int base, void *dest, int sector)
        return ret;
 }
 
-static int uncompress2(void *out, unsigned long *out_size, void *in, unsigned long in_size)
+static int uncomp2(void *out, unsigned long *out_size, void *in, unsigned long in_size)
 {
        static z_stream z;
        int ret = 0;
@@ -1169,7 +1174,7 @@ static int cdread_compressed(FILE *f, unsigned int base, void *dest, int sector)
        if (is_compressed) {
                cdbuffer_size_expect = sizeof(compr_img->buff_raw[0]) << compr_img->block_shift;
                cdbuffer_size = cdbuffer_size_expect;
-               ret = uncompress2(compr_img->buff_raw[0], &cdbuffer_size, compr_img->buff_compressed, size);
+               ret = uncomp2(compr_img->buff_raw[0], &cdbuffer_size, compr_img->buff_compressed, size);
                if (ret != 0) {
                        SysPrintf("uncompress failed with %d for block %d, sector %d\n",
                                        ret, block, sector);
index fe153e2..fbe0e59 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #include "arm_features.h"
-#include "new_dynarec/linkage_offsets.h"
+#include "new_dynarec/arm/linkage_offsets.h"
 
 .syntax unified
 .text
similarity index 99%
rename from libpcsxcore/new_dynarec/assem_arm.c
rename to libpcsxcore/new_dynarec/arm/assem_arm.c
index 21640f8..db1d2af 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
-#include "../gte.h"
+#include "../../gte.h"
 #define FLAGLESS
-#include "../gte.h"
+#include "../../gte.h"
 #undef FLAGLESS
-#include "../gte_arm.h"
-#include "../gte_neon.h"
+#include "../../gte_arm.h"
+#include "../../gte_neon.h"
 #include "pcnt.h"
 #include "arm_features.h"
 
@@ -2518,8 +2518,8 @@ static void mov_loadtype_adj(int type,int rs,int rt)
   }
 }
 
-#include "pcsxmem.h"
-#include "pcsxmem_inline.c"
+#include "../backends/psx/pcsxmem.h"
+#include "../backends/psx/pcsxmem_inline.c"
 
 static void do_readstub(int n)
 {
similarity index 99%
rename from libpcsxcore/new_dynarec/linkage_arm.S
rename to libpcsxcore/new_dynarec/arm/linkage_arm.S
index d32dc0b..269eb99 100644 (file)
@@ -20,7 +20,7 @@
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
 #include "arm_features.h"
-#include "new_dynarec_config.h"
+#include "../new_dynarec_config.h"
 #include "linkage_offsets.h"
 
 
similarity index 98%
rename from libpcsxcore/new_dynarec/emu_if.c
rename to libpcsxcore/new_dynarec/backends/psx/emu_if.c
index 22db5d1..6dc48e2 100644 (file)
@@ -9,15 +9,15 @@
 
 #include "emu_if.h"
 #include "pcsxmem.h"
-#include "../psxhle.h"
-#include "../r3000a.h"
-#include "../cdrom.h"
-#include "../psxdma.h"
-#include "../mdec.h"
-#include "../gte_arm.h"
-#include "../gte_neon.h"
+#include "../../../psxhle.h"
+#include "../../../r3000a.h"
+#include "../../../cdrom.h"
+#include "../../../psxdma.h"
+#include "../../../mdec.h"
+#include "../../../gte_arm.h"
+#include "../../../gte_neon.h"
 #define FLAGLESS
-#include "../gte.h"
+#include "../../../gte.h"
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
 
@@ -431,7 +431,7 @@ void do_insn_cmp() {}
 #ifdef DRC_DISABLE
 unsigned int address;
 int pending_exception, stop;
-unsigned int next_interupt;
+u32 next_interupt;
 int new_dynarec_did_compile;
 int cycle_multiplier;
 int new_dynarec_hacks;
similarity index 96%
rename from libpcsxcore/new_dynarec/emu_if.h
rename to libpcsxcore/new_dynarec/backends/psx/emu_if.h
index 3980490..d8c7990 100644 (file)
@@ -1,5 +1,5 @@
-#include "new_dynarec.h"
-#include "../r3000a.h"
+#include "../../new_dynarec.h"
+#include "../../../r3000a.h"
 
 extern char invalid_code[0x100000];
 
@@ -89,7 +89,7 @@ extern void *scratch_buf_ptr;
 extern u32 inv_code_start, inv_code_end;
 
 /* cycles/irqs */
-extern unsigned int next_interupt;
+extern u32 next_interupt;
 extern int pending_exception;
 
 /* called by drc */
similarity index 99%
rename from libpcsxcore/new_dynarec/pcsxmem.c
rename to libpcsxcore/new_dynarec/backends/psx/pcsxmem.c
index 9376ff4..647981e 100644 (file)
@@ -6,11 +6,11 @@
  */
 
 #include <stdio.h>
-#include "../psxhw.h"
-#include "../cdrom.h"
-#include "../mdec.h"
-#include "../gpu.h"
-#include "../psxmem_map.h"
+#include "../../../psxhw.h"
+#include "../../../cdrom.h"
+#include "../../../mdec.h"
+#include "../../../gpu.h"
+#include "../../../psxmem_map.h"
 #include "emu_if.h"
 #include "pcsxmem.h"
 
index cd63d2b..dfa17a7 100644 (file)
 #ifdef VITA
 #include <psp2/kernel/sysmem.h>
 static int sceBlock;
+int getVMBlock();
 #endif
 
 #include "new_dynarec_config.h"
-#include "emu_if.h" //emulator interface
+#include "backends/psx/emu_if.h" //emulator interface
 
 //#define DISASM
 //#define assem_debug printf
@@ -44,13 +45,17 @@ static int sceBlock;
 #define inv_debug(...)
 
 #ifdef __i386__
-#include "assem_x86.h"
+#include "x86/assem_x86.h"
 #endif
 #ifdef __x86_64__
-#include "assem_x64.h"
+#include "x64/assem_x64.h"
 #endif
 #ifdef __arm__
-#include "assem_arm.h"
+#include "arm/assem_arm.h"
+#endif
+
+#ifdef VITA
+int _newlib_vm_size_user = 1 << TARGET_SIZE_2;
 #endif
 
 #define MAXBLOCK 4096
@@ -361,14 +366,16 @@ static u_int get_vpage(u_int vaddr)
 // This is called from the recompiled JR/JALR instructions
 void *get_addr(u_int vaddr)
 {
-  u_int page=get_page(vaddr);
-  u_int vpage=get_vpage(vaddr);
-  struct ll_entry *head;
+  struct ll_entry *head = NULL;
+  u_int page            = get_page(vaddr);
+  u_int vpage           = get_vpage(vaddr);
   //printf("TRACE: count=%d next=%d (get_addr %x,page %d)\n",Count,next_interupt,vaddr,page);
   head=jump_in[page];
-  while(head!=NULL) {
-    if(head->vaddr==vaddr) {
-  //printf("TRACE: count=%d next=%d (get_addr match %x: %x)\n",Count,next_interupt,vaddr,(int)head->addr);
+  while(head!=NULL)
+  {
+    if(head->vaddr==vaddr)
+    {
+      //printf("TRACE: count=%d next=%d (get_addr match %x: %x)\n",Count,next_interupt,vaddr,(int)head->addr);
       u_int *ht_bin=hash_table[((vaddr>>16)^vaddr)&0xFFFF];
       ht_bin[3]=ht_bin[1];
       ht_bin[2]=ht_bin[0];
@@ -379,39 +386,47 @@ void *get_addr(u_int vaddr)
     head=head->next;
   }
   head=jump_dirty[vpage];
-  while(head!=NULL) {
-    if(head->vaddr==vaddr) {
+  while(head!=NULL)
+  {
+    if(head->vaddr==vaddr)
+    {
       //printf("TRACE: count=%d next=%d (get_addr match dirty %x: %x)\n",Count,next_interupt,vaddr,(int)head->addr);
       // Don't restore blocks which are about to expire from the cache
       if((((u_int)head->addr-(u_int)out)<<(32-TARGET_SIZE_2))>0x60000000+(MAX_OUTPUT_BLOCK_SIZE<<(32-TARGET_SIZE_2)))
-      if(verify_dirty(head->addr)) {
-        //printf("restore candidate: %x (%d) d=%d\n",vaddr,page,invalid_code[vaddr>>12]);
-        invalid_code[vaddr>>12]=0;
-        inv_code_start=inv_code_end=~0;
-        if(vpage<2048) {
-          restore_candidate[vpage>>3]|=1<<(vpage&7);
-        }
-        else restore_candidate[page>>3]|=1<<(page&7);
-        u_int *ht_bin=hash_table[((vaddr>>16)^vaddr)&0xFFFF];
-        if(ht_bin[0]==vaddr) {
-          ht_bin[1]=(u_int)head->addr; // Replace existing entry
-        }
-        else
+        if(verify_dirty(head->addr))
         {
-          ht_bin[3]=ht_bin[1];
-          ht_bin[2]=ht_bin[0];
-          ht_bin[1]=(int)head->addr;
-          ht_bin[0]=vaddr;
+          //printf("restore candidate: %x (%d) d=%d\n",vaddr,page,invalid_code[vaddr>>12]);
+          invalid_code[vaddr>>12]=0;
+          inv_code_start=inv_code_end=~0;
+          if(vpage<2048)
+          {
+            restore_candidate[vpage>>3]|=1<<(vpage&7);
+          }
+          else
+          {
+            restore_candidate[page>>3]|=1<<(page&7);
+          }
+          u_int *ht_bin=hash_table[((vaddr>>16)^vaddr)&0xFFFF];
+
+          if(ht_bin[0]==vaddr)
+            ht_bin[1]=(u_int)head->addr; // Replace existing entry
+          else
+          {
+            ht_bin[3]=ht_bin[1];
+            ht_bin[2]=ht_bin[0];
+            ht_bin[1]=(int)head->addr;
+            ht_bin[0]=vaddr;
+          }
+          return head->addr;
         }
-        return head->addr;
-      }
     }
     head=head->next;
   }
   //printf("TRACE: count=%d next=%d (get_addr no-match %x)\n",Count,next_interupt,vaddr);
   int r=new_recompile_block(vaddr);
-  if(r==0) return get_addr(vaddr);
-  // Execute in unmapped page, generate pagefault execption
+  if(r==0)
+    return get_addr(vaddr);
+  // Execute in unmapped page, generate pagefault exception
   Status|=2;
   Cause=(vaddr<<31)|0x8;
   EPC=(vaddr&1)?vaddr-5:vaddr;
@@ -420,6 +435,7 @@ void *get_addr(u_int vaddr)
   EntryHi=BadVAddr&0xFFFFE000;
   return get_addr_ht(0x80000000);
 }
+
 // Look up address in hash table first
 void *get_addr_ht(u_int vaddr)
 {
@@ -763,13 +779,13 @@ void alloc_all(struct regstat *cur,int i)
 }
 
 #ifdef __i386__
-#include "assem_x86.c"
+#include "x86/assem_x86.c"
 #endif
 #ifdef __x86_64__
-#include "assem_x64.c"
+#include "x64/assem_x64.c"
 #endif
 #ifdef __arm__
-#include "assem_arm.c"
+#include "arm/assem_arm.c"
 #endif
 
 // Add virtual address mapping to linked list
@@ -943,23 +959,26 @@ static void invalidate_block_range(u_int block, u_int first, u_int last)
   assert(first+5>page); // NB: this assumes MAXBLOCK<=4096 (4 pages)
   assert(last<page+5);
   // Invalidate the adjacent pages if a block crosses a 4K boundary
-  while(first<page) {
+  while(first<page)
+  {
     invalidate_page(first);
     first++;
   }
-  for(first=page+1;first<last;first++) {
+  for(first=page+1;first<last;first++)
+  {
     invalidate_page(first);
   }
-  #ifdef __arm__
-    do_clear_cache();
-  #endif
+
+#ifdef __arm__
+  do_clear_cache();
+#endif
 
   // Don't trap writes
   invalid_code[block]=1;
 
-  #ifdef USE_MINI_HT
+#ifdef USE_MINI_HT
   memset(mini_ht,-1,sizeof(mini_ht));
-  #endif
+#endif
 }
 
 void invalidate_block(u_int block)
@@ -967,19 +986,22 @@ void invalidate_block(u_int block)
   u_int page=get_page(block<<12);
   u_int vpage=get_vpage(block<<12);
   inv_debug("INVALIDATE: %x (%d)\n",block<<12,page);
-  //inv_debug("invalid_code[block]=%d\n",invalid_code[block]);
   u_int first,last;
   first=last=page;
   struct ll_entry *head;
   head=jump_dirty[vpage];
   //printf("page=%d vpage=%d\n",page,vpage);
-  while(head!=NULL) {
+  while(head!=NULL)
+  {
     u_int start,end;
-    if(vpage>2047||(head->vaddr>>12)==block) { // Ignore vaddr hash collision
+    if(vpage>2047||(head->vaddr>>12)==block)
+    { // Ignore vaddr hash collision
       get_bounds((int)head->addr,&start,&end);
       //printf("start: %x end: %x\n",start,end);
-      if(page<2048&&start>=(u_int)rdram&&end<(u_int)rdram+RAM_SIZE) {
-        if(((start-(u_int)rdram)>>12)<=page&&((end-1-(u_int)rdram)>>12)>=page) {
+      if(page<2048&&start>=(u_int)rdram&&end<(u_int)rdram+RAM_SIZE)
+      {
+        if(((start-(u_int)rdram)>>12)<=page&&((end-1-(u_int)rdram)>>12)>=page)
+        {
           if((((start-(u_int)rdram)>>12)&2047)<first) first=((start-(u_int)rdram)>>12)&2047;
           if((((end-1-(u_int)rdram)>>12)&2047)>last) last=((end-1-(u_int)rdram)>>12)&2047;
         }
@@ -1050,19 +1072,23 @@ void invalidate_addr(u_int addr)
 
 // This is called when loading a save state.
 // Anything could have changed, so invalidate everything.
-void invalidate_all_pages()
+void invalidate_all_pages(void)
 {
   u_int page;
   for(page=0;page<4096;page++)
     invalidate_page(page);
   for(page=0;page<1048576;page++)
-    if(!invalid_code[page]) {
+  {
+    if(!invalid_code[page])
+    {
       restore_candidate[(page&2047)>>3]|=1<<(page&7);
       restore_candidate[((page&2047)>>3)+256]|=1<<(page&7);
     }
-  #ifdef USE_MINI_HT
+  }
+
+#ifdef USE_MINI_HT
   memset(mini_ht,-1,sizeof(mini_ht));
-  #endif
+#endif
 }
 
 // Add an entry to jump_out after making a link
@@ -1087,37 +1113,48 @@ void clean_blocks(u_int page)
   struct ll_entry *head;
   inv_debug("INV: clean_blocks page=%d\n",page);
   head=jump_dirty[page];
-  while(head!=NULL) {
-    if(!invalid_code[head->vaddr>>12]) {
+  while(head!=NULL)
+  {
+    if(!invalid_code[head->vaddr>>12])
+    {
       // Don't restore blocks which are about to expire from the cache
-      if((((u_int)head->addr-(u_int)out)<<(32-TARGET_SIZE_2))>0x60000000+(MAX_OUTPUT_BLOCK_SIZE<<(32-TARGET_SIZE_2))) {
+      if((((u_int)head->addr-(u_int)out)<<(32-TARGET_SIZE_2))>0x60000000+(MAX_OUTPUT_BLOCK_SIZE<<(32-TARGET_SIZE_2)))
+      {
         u_int start,end;
-        if(verify_dirty(head->addr)) {
+        if(verify_dirty(head->addr))
+        {
           //printf("Possibly Restore %x (%x)\n",head->vaddr, (int)head->addr);
           u_int i;
           u_int inv=0;
           get_bounds((int)head->addr,&start,&end);
-          if(start-(u_int)rdram<RAM_SIZE) {
-            for(i=(start-(u_int)rdram+0x80000000)>>12;i<=(end-1-(u_int)rdram+0x80000000)>>12;i++) {
+          if(start-(u_int)rdram<RAM_SIZE)
+          {
+            for(i=(start-(u_int)rdram+0x80000000)>>12;i<=(end-1-(u_int)rdram+0x80000000)>>12;i++)
+            {
               inv|=invalid_code[i];
             }
           }
-          else if((signed int)head->vaddr>=(signed int)0x80000000+RAM_SIZE) {
+          else if((signed int)head->vaddr>=(signed int)0x80000000+RAM_SIZE)
+          {
             inv=1;
           }
-          if(!inv) {
+          if(!inv)
+          {
             void * clean_addr=(void *)get_clean_addr((int)head->addr);
-            if((((u_int)clean_addr-(u_int)out)<<(32-TARGET_SIZE_2))>0x60000000+(MAX_OUTPUT_BLOCK_SIZE<<(32-TARGET_SIZE_2))) {
+            if((((u_int)clean_addr-(u_int)out)<<(32-TARGET_SIZE_2))>0x60000000+(MAX_OUTPUT_BLOCK_SIZE<<(32-TARGET_SIZE_2)))
+            {
               u_int ppage=page;
               inv_debug("INV: Restored %x (%x/%x)\n",head->vaddr, (int)head->addr, (int)clean_addr);
               //printf("page=%x, addr=%x\n",page,head->vaddr);
               //assert(head->vaddr>>12==(page|0x80000));
               ll_add_flags(jump_in+ppage,head->vaddr,head->reg_sv_flags,clean_addr);
               u_int *ht_bin=hash_table[((head->vaddr>>16)^head->vaddr)&0xFFFF];
-              if(ht_bin[0]==head->vaddr) {
+              if(ht_bin[0]==head->vaddr)
+              {
                 ht_bin[1]=(u_int)clean_addr; // Replace existing entry
               }
-              if(ht_bin[2]==head->vaddr) {
+              if(ht_bin[2]==head->vaddr)
+              {
                 ht_bin[3]=(u_int)clean_addr; // Replace existing entry
               }
             }
@@ -1129,15 +1166,17 @@ void clean_blocks(u_int page)
   }
 }
 
-
-void mov_alloc(struct regstat *current,int i)
+static void mov_alloc(struct regstat *current,int i)
 {
   // Note: Don't need to actually alloc the source registers
-  if((~current->is32>>rs1[i])&1) {
+  if((~current->is32>>rs1[i])&1)
+  {
     //alloc_reg64(current,i,rs1[i]);
     alloc_reg64(current,i,rt1[i]);
     current->is32&=~(1LL<<rt1[i]);
-  } else {
+  }
+  else
+  {
     //alloc_reg(current,i,rs1[i]);
     alloc_reg(current,i,rt1[i]);
     current->is32|=(1LL<<rt1[i]);
@@ -1695,7 +1734,8 @@ void syscall_alloc(struct regstat *current,int i)
 
 void delayslot_alloc(struct regstat *current,int i)
 {
-  switch(itype[i]) {
+  switch(itype[i])
+  {
     case UJUMP:
     case CJUMP:
     case SJUMP:
@@ -1845,7 +1885,8 @@ void wb_register(signed char r,signed char regmap[],uint64_t dirty,uint64_t is32
   }
 }
 
-int mchecksum()
+#if 0
+static int mchecksum(void)
 {
   //if(!tracedebug) return 0;
   int i;
@@ -1858,7 +1899,8 @@ int mchecksum()
   }
   return sum;
 }
-int rchecksum()
+
+static int rchecksum(void)
 {
   int i;
   int sum=0;
@@ -1866,7 +1908,8 @@ int rchecksum()
     sum^=((u_int *)reg)[i];
   return sum;
 }
-void rlist()
+
+static void rlist(void)
 {
   int i;
   printf("TRACE: ");
@@ -1875,12 +1918,12 @@ void rlist()
   printf("\n");
 }
 
-void enabletrace()
+static void enabletrace(void)
 {
   tracedebug=1;
 }
 
-void memdebug(int i)
+static void memdebug(int i)
 {
   //printf("TRACE: count=%d next=%d (checksum %x) lo=%8x%8x\n",Count,next_interupt,mchecksum(),(int)(reg[LOREG]>>32),(int)reg[LOREG]);
   //printf("TRACE: count=%d next=%d (rchecksum %x)\n",Count,next_interupt,rchecksum());
@@ -1905,6 +1948,7 @@ void memdebug(int i)
   }
   //printf("TRACE: %x\n",(&i)[-1]);
 }
+#endif
 
 void alu_assemble(int i,struct regstat *i_regs)
 {
@@ -7016,7 +7060,7 @@ static int new_dynarec_test(void)
 
 // clear the state completely, instead of just marking
 // things invalid like invalidate_all_pages() does
-void new_dynarec_clear_full()
+void new_dynarec_clear_full(void)
 {
   int n;
   out=(u_char *)BASE_ADDR;
@@ -7037,7 +7081,7 @@ void new_dynarec_clear_full()
   for(n=0;n<4096;n++) ll_clear(jump_dirty+n);
 }
 
-void new_dynarec_init()
+void new_dynarec_init(void)
 {
   SysPrintf("Init new dynarec\n");
 
@@ -7045,37 +7089,45 @@ void new_dynarec_init()
   // see assem_arm.h for some explanation
 #if   defined(BASE_ADDR_FIXED)
   if (mmap (translation_cache, 1 << TARGET_SIZE_2,
-            PROT_READ | PROT_WRITE | PROT_EXEC,
-            MAP_PRIVATE | MAP_ANONYMOUS,
-            -1, 0) != translation_cache) {
+        PROT_READ | PROT_WRITE | PROT_EXEC,
+        MAP_PRIVATE | MAP_ANONYMOUS,
+        -1, 0) != translation_cache)
+  {
     SysPrintf("mmap() failed: %s\n", strerror(errno));
     SysPrintf("disable BASE_ADDR_FIXED and recompile\n");
     abort();
   }
 #elif defined(BASE_ADDR_DYNAMIC)
-  #ifdef VITA
-  sceBlock = sceKernelAllocMemBlockForVM("code", 1 << TARGET_SIZE_2);
+#ifdef VITA
+  sceBlock = getVMBlock();//sceKernelAllocMemBlockForVM("code", 1 << TARGET_SIZE_2);
   if (sceBlock < 0)
     SysPrintf("sceKernelAllocMemBlockForVM failed\n");
   int ret = sceKernelGetMemBlockBase(sceBlock, (void **)&translation_cache);
   if (ret < 0)
     SysPrintf("sceKernelGetMemBlockBase failed\n");
-  #else
+    
+  sceKernelOpenVMDomain();
+  sceClibPrintf("translation_cache = 0x%08X \n ", translation_cache);
+#elif defined(_MSC_VER)
+  base_addr = VirtualAlloc(NULL, 1<<TARGET_SIZE_2, MEM_COMMIT | MEM_RESERVE,
+      PAGE_EXECUTE_READWRITE);
+#else
   translation_cache = mmap (NULL, 1 << TARGET_SIZE_2,
-            PROT_READ | PROT_WRITE | PROT_EXEC,
-            MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+      PROT_READ | PROT_WRITE | PROT_EXEC,
+      MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   if (translation_cache == MAP_FAILED) {
     SysPrintf("mmap() failed: %s\n", strerror(errno));
     abort();
   }
-  #endif
+#endif
 #else
-  #ifndef NO_WRITE_EXEC
+#ifndef NO_WRITE_EXEC
   // not all systems allow execute in data segment by default
   if (mprotect((void *)BASE_ADDR, 1<<TARGET_SIZE_2, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
     SysPrintf("mprotect() failed: %s\n", strerror(errno));
-  #endif
 #endif
+#endif
+
   out=(u_char *)BASE_ADDR;
   cycle_multiplier=200;
   new_dynarec_clear_full();
@@ -7092,24 +7144,28 @@ void new_dynarec_init()
     SysPrintf("warning: RAM is not directly mapped, performance will suffer\n");
 }
 
-void new_dynarec_cleanup()
+void new_dynarec_cleanup(void)
 {
   int n;
 #if defined(BASE_ADDR_FIXED) || defined(BASE_ADDR_DYNAMIC)
-  #ifdef VITA
-  sceKernelFreeMemBlock(sceBlock);
-  sceBlock = -1;
-  #else
+#ifndef VITA
+#if defined(_MSC_VER)
+  VirtualFree(base_addr, 0, MEM_RELEASE);
+#else
   if (munmap ((void *)BASE_ADDR, 1<<TARGET_SIZE_2) < 0)
     SysPrintf("munmap() failed\n");
-  #endif
 #endif
-  for(n=0;n<4096;n++) ll_clear(jump_in+n);
-  for(n=0;n<4096;n++) ll_clear(jump_out+n);
-  for(n=0;n<4096;n++) ll_clear(jump_dirty+n);
-  #ifdef ROM_COPY
+#endif
+#endif
+  for(n=0;n<4096;n++)
+    ll_clear(jump_in+n);
+  for(n=0;n<4096;n++)
+    ll_clear(jump_out+n);
+  for(n=0;n<4096;n++)
+    ll_clear(jump_dirty+n);
+#ifdef ROM_COPY
   if (munmap (ROM_COPY, 67108864) < 0) {SysPrintf("munmap() failed\n");}
-  #endif
+#endif
 }
 
 static u_int *get_source_start(u_int addr, u_int *limit)
index ddc84a5..e7eb247 100644 (file)
@@ -11,12 +11,12 @@ extern int cycle_multiplier; // 100 for 1.0
 #define NDHACK_GTE_NO_FLAGS    (1<<2)
 extern int new_dynarec_hacks;
 
-void new_dynarec_init();
-void new_dynarec_cleanup();
-void new_dynarec_clear_full();
-void new_dyna_start();
+void new_dynarec_init(void);
+void new_dynarec_cleanup(void);
+void new_dynarec_clear_full(void);
+void new_dyna_start(void);
 int  new_dynarec_save_blocks(void *save, int size);
 void new_dynarec_load_blocks(const void *save, int size);
 
-void invalidate_all_pages();
+void invalidate_all_pages(void);
 void invalidate_block(unsigned int block);
index fbd08ac..d55f128 100644 (file)
@@ -4,7 +4,7 @@
 #define USE_MINI_HT 1
 //#define REG_PREFETCH 1
 
-#if defined(__MACH__) || defined(VITA)
+#if defined(__MACH__)
 #define NO_WRITE_EXEC 1
 #endif
 #ifdef VITA
index e6d8a11..afe3f3b 100644 (file)
-/***************************************************************************\r
- *   Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team              *\r
- *                                                                         *\r
- *   This program is free software; you can redistribute it and/or modify  *\r
- *   it under the terms of the GNU General Public License as published by  *\r
- *   the Free Software Foundation; either version 2 of the License, or     *\r
- *   (at your option) any later version.                                   *\r
- *                                                                         *\r
- *   This program is distributed in the hope that it will be useful,       *\r
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *\r
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *\r
- *   GNU General Public License for more details.                          *\r
- *                                                                         *\r
- *   You should have received a copy of the GNU General Public License     *\r
- *   along with this program; if not, write to the                         *\r
- *   Free Software Foundation, Inc.,                                       *\r
- *   51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA.           *\r
- ***************************************************************************/\r
-\r
-/*\r
-* Plugin library callback/access functions.\r
-*/\r
-\r
-#include "plugins.h"\r
-#include "cdriso.h"\r
-\r
-static char IsoFile[MAXPATHLEN] = "";\r
-static s64 cdOpenCaseTime = 0;\r
-\r
-GPUupdateLace         GPU_updateLace;\r
-GPUinit               GPU_init;\r
-GPUshutdown           GPU_shutdown; \r
-GPUconfigure          GPU_configure;\r
-GPUtest               GPU_test;\r
-GPUabout              GPU_about;\r
-GPUopen               GPU_open;\r
-GPUclose              GPU_close;\r
-GPUreadStatus         GPU_readStatus;\r
-GPUreadData           GPU_readData;\r
-GPUreadDataMem        GPU_readDataMem;\r
-GPUwriteStatus        GPU_writeStatus; \r
-GPUwriteData          GPU_writeData;\r
-GPUwriteDataMem       GPU_writeDataMem;\r
-GPUdmaChain           GPU_dmaChain;\r
-GPUkeypressed         GPU_keypressed;\r
-GPUdisplayText        GPU_displayText;\r
-GPUmakeSnapshot       GPU_makeSnapshot;\r
-GPUfreeze             GPU_freeze;\r
-GPUgetScreenPic       GPU_getScreenPic;\r
-GPUshowScreenPic      GPU_showScreenPic;\r
-GPUclearDynarec       GPU_clearDynarec;\r
-GPUvBlank             GPU_vBlank;\r
-\r
-CDRinit               CDR_init;\r
-CDRshutdown           CDR_shutdown;\r
-CDRopen               CDR_open;\r
-CDRclose              CDR_close; \r
-CDRtest               CDR_test;\r
-CDRgetTN              CDR_getTN;\r
-CDRgetTD              CDR_getTD;\r
-CDRreadTrack          CDR_readTrack;\r
-CDRgetBuffer          CDR_getBuffer;\r
-CDRplay               CDR_play;\r
-CDRstop               CDR_stop;\r
-CDRgetStatus          CDR_getStatus;\r
-CDRgetDriveLetter     CDR_getDriveLetter;\r
-CDRgetBufferSub       CDR_getBufferSub;\r
-CDRconfigure          CDR_configure;\r
-CDRabout              CDR_about;\r
-CDRsetfilename        CDR_setfilename;\r
-CDRreadCDDA           CDR_readCDDA;\r
-CDRgetTE              CDR_getTE;\r
-\r
-SPUconfigure          SPU_configure;\r
-SPUabout              SPU_about;\r
-SPUinit               SPU_init;\r
-SPUshutdown           SPU_shutdown;\r
-SPUtest               SPU_test;\r
-SPUopen               SPU_open;\r
-SPUclose              SPU_close;\r
-SPUplaySample         SPU_playSample;\r
-SPUwriteRegister      SPU_writeRegister;\r
-SPUreadRegister       SPU_readRegister;\r
-SPUwriteDMA           SPU_writeDMA;\r
-SPUreadDMA            SPU_readDMA;\r
-SPUwriteDMAMem        SPU_writeDMAMem;\r
-SPUreadDMAMem         SPU_readDMAMem;\r
-SPUplayADPCMchannel   SPU_playADPCMchannel;\r
-SPUfreeze             SPU_freeze;\r
-SPUregisterCallback   SPU_registerCallback;\r
-SPUregisterScheduleCb SPU_registerScheduleCb;\r
-SPUasync              SPU_async;\r
-SPUplayCDDAchannel    SPU_playCDDAchannel;\r
-\r
-PADconfigure          PAD1_configure;\r
-PADabout              PAD1_about;\r
-PADinit               PAD1_init;\r
-PADshutdown           PAD1_shutdown;\r
-PADtest               PAD1_test;\r
-PADopen               PAD1_open;\r
-PADclose              PAD1_close;\r
-PADquery              PAD1_query;\r
-PADreadPort1          PAD1_readPort1;\r
-PADkeypressed         PAD1_keypressed;\r
-PADstartPoll          PAD1_startPoll;\r
-PADpoll               PAD1_poll;\r
-PADsetSensitive       PAD1_setSensitive;\r
-\r
-PADconfigure          PAD2_configure;\r
-PADabout              PAD2_about;\r
-PADinit               PAD2_init;\r
-PADshutdown           PAD2_shutdown;\r
-PADtest               PAD2_test;\r
-PADopen               PAD2_open;\r
-PADclose              PAD2_close;\r
-PADquery              PAD2_query;\r
-PADreadPort2          PAD2_readPort2;\r
-PADkeypressed         PAD2_keypressed;\r
-PADstartPoll          PAD2_startPoll;\r
-PADpoll               PAD2_poll;\r
-PADsetSensitive       PAD2_setSensitive;\r
-\r
-NETinit               NET_init;\r
-NETshutdown           NET_shutdown;\r
-NETopen               NET_open;\r
-NETclose              NET_close; \r
-NETtest               NET_test;\r
-NETconfigure          NET_configure;\r
-NETabout              NET_about;\r
-NETpause              NET_pause;\r
-NETresume             NET_resume;\r
-NETqueryPlayer        NET_queryPlayer;\r
-NETsendData           NET_sendData;\r
-NETrecvData           NET_recvData;\r
-NETsendPadData        NET_sendPadData;\r
-NETrecvPadData        NET_recvPadData;\r
-NETsetInfo            NET_setInfo;\r
-NETkeypressed         NET_keypressed;\r
-\r
-#ifdef ENABLE_SIO1API\r
-\r
-SIO1init              SIO1_init;\r
-SIO1shutdown          SIO1_shutdown;\r
-SIO1open              SIO1_open;\r
-SIO1close             SIO1_close; \r
-SIO1test              SIO1_test;\r
-SIO1configure         SIO1_configure;\r
-SIO1about             SIO1_about;\r
-SIO1pause             SIO1_pause;\r
-SIO1resume            SIO1_resume;\r
-SIO1keypressed        SIO1_keypressed;\r
-SIO1writeData8        SIO1_writeData8;\r
-SIO1writeData16       SIO1_writeData16;\r
-SIO1writeData32       SIO1_writeData32;\r
-SIO1writeStat16       SIO1_writeStat16;\r
-SIO1writeStat32       SIO1_writeStat32;\r
-SIO1writeMode16       SIO1_writeMode16;\r
-SIO1writeMode32       SIO1_writeMode32;\r
-SIO1writeCtrl16       SIO1_writeCtrl16;\r
-SIO1writeCtrl32       SIO1_writeCtrl32;\r
-SIO1writeBaud16       SIO1_writeBaud16;\r
-SIO1writeBaud32       SIO1_writeBaud32;\r
-SIO1readData8         SIO1_readData8;\r
-SIO1readData16        SIO1_readData16;\r
-SIO1readData32        SIO1_readData32;\r
-SIO1readStat16        SIO1_readStat16;\r
-SIO1readStat32        SIO1_readStat32;\r
-SIO1readMode16        SIO1_readMode16;\r
-SIO1readMode32        SIO1_readMode32;\r
-SIO1readCtrl16        SIO1_readCtrl16;\r
-SIO1readCtrl32        SIO1_readCtrl32;\r
-SIO1readBaud16        SIO1_readBaud16;\r
-SIO1readBaud32        SIO1_readBaud32;\r
-SIO1registerCallback  SIO1_registerCallback;\r
-\r
-#endif\r
-\r
-static const char *err;\r
-\r
-#define CheckErr(func) { \\r
-       err = SysLibError(); \\r
-       if (err != NULL) { SysMessage(_("Error loading %s: %s"), func, err); return -1; } \\r
-}\r
-\r
-#define LoadSym(dest, src, name, checkerr) { \\r
-       dest = (src)SysLoadSym(drv, name); \\r
-       if (checkerr) { CheckErr(name); } else SysLibError(); \\r
-}\r
-\r
-void *hGPUDriver = NULL;\r
-\r
-void CALLBACK GPU__displayText(char *pText) {\r
-       SysPrintf("%s\n", pText);\r
-}\r
-\r
-long CALLBACK GPU__configure(void) { return 0; }\r
-long CALLBACK GPU__test(void) { return 0; }\r
-void CALLBACK GPU__about(void) {}\r
-void CALLBACK GPU__makeSnapshot(void) {}\r
-void CALLBACK GPU__keypressed(int key) {}\r
-long CALLBACK GPU__getScreenPic(unsigned char *pMem) { return -1; }\r
-long CALLBACK GPU__showScreenPic(unsigned char *pMem) { return -1; }\r
-void CALLBACK GPU__clearDynarec(void (CALLBACK *callback)(void)) {}\r
-void CALLBACK GPU__vBlank(int val) {}\r
-\r
-#define LoadGpuSym1(dest, name) \\r
-       LoadSym(GPU_##dest, GPU##dest, name, TRUE);\r
-\r
-#define LoadGpuSym0(dest, name) \\r
-       LoadSym(GPU_##dest, GPU##dest, name, FALSE); \\r
-       if (GPU_##dest == NULL) GPU_##dest = (GPU##dest) GPU__##dest;\r
-\r
-#define LoadGpuSymN(dest, name) \\r
-       LoadSym(GPU_##dest, GPU##dest, name, FALSE);\r
-\r
-static int LoadGPUplugin(const char *GPUdll) {\r
-       void *drv;\r
-\r
-       hGPUDriver = SysLoadLibrary(GPUdll);\r
-       if (hGPUDriver == NULL) { \r
-               GPU_configure = NULL;\r
-               SysMessage (_("Could not load GPU plugin %s!"), GPUdll); return -1; \r
-       }\r
-       drv = hGPUDriver;\r
-       LoadGpuSym1(init, "GPUinit");\r
-       LoadGpuSym1(shutdown, "GPUshutdown");\r
-       LoadGpuSym1(open, "GPUopen");\r
-       LoadGpuSym1(close, "GPUclose");\r
-       LoadGpuSym1(readData, "GPUreadData");\r
-       LoadGpuSym1(readDataMem, "GPUreadDataMem");\r
-       LoadGpuSym1(readStatus, "GPUreadStatus");\r
-       LoadGpuSym1(writeData, "GPUwriteData");\r
-       LoadGpuSym1(writeDataMem, "GPUwriteDataMem");\r
-       LoadGpuSym1(writeStatus, "GPUwriteStatus");\r
-       LoadGpuSym1(dmaChain, "GPUdmaChain");\r
-       LoadGpuSym1(updateLace, "GPUupdateLace");\r
-       LoadGpuSym0(keypressed, "GPUkeypressed");\r
-       LoadGpuSym0(displayText, "GPUdisplayText");\r
-       LoadGpuSym0(makeSnapshot, "GPUmakeSnapshot");\r
-       LoadGpuSym1(freeze, "GPUfreeze");\r
-       LoadGpuSym0(getScreenPic, "GPUgetScreenPic");\r
-       LoadGpuSym0(showScreenPic, "GPUshowScreenPic");\r
-       LoadGpuSym0(clearDynarec, "GPUclearDynarec");\r
-    LoadGpuSym0(vBlank, "GPUvBlank");\r
-       LoadGpuSym0(configure, "GPUconfigure");\r
-       LoadGpuSym0(test, "GPUtest");\r
-       LoadGpuSym0(about, "GPUabout");\r
-\r
-       return 0;\r
-}\r
-\r
-void *hCDRDriver = NULL;\r
-\r
-long CALLBACK CDR__play(unsigned char *sector) { return 0; }\r
-long CALLBACK CDR__stop(void) { return 0; }\r
-\r
-long CALLBACK CDR__getStatus(struct CdrStat *stat) {\r
-       if (cdOpenCaseTime < 0 || cdOpenCaseTime > (s64)time(NULL))\r
-               stat->Status = 0x10;\r
-       else\r
-               stat->Status = 0;\r
-\r
-       return 0;\r
-}\r
-\r
-char* CALLBACK CDR__getDriveLetter(void) { return NULL; }\r
-long CALLBACK CDR__configure(void) { return 0; }\r
-long CALLBACK CDR__test(void) { return 0; }\r
-void CALLBACK CDR__about(void) {}\r
-long CALLBACK CDR__setfilename(char*filename) { return 0; }\r
-\r
-#define LoadCdrSym1(dest, name) \\r
-       LoadSym(CDR_##dest, CDR##dest, name, TRUE);\r
-\r
-#define LoadCdrSym0(dest, name) \\r
-       LoadSym(CDR_##dest, CDR##dest, name, FALSE); \\r
-       if (CDR_##dest == NULL) CDR_##dest = (CDR##dest) CDR__##dest;\r
-\r
-#define LoadCdrSymN(dest, name) \\r
-       LoadSym(CDR_##dest, CDR##dest, name, FALSE);\r
-\r
-static int LoadCDRplugin(const char *CDRdll) {\r
-       void *drv;\r
-\r
-       if (CDRdll == NULL) {\r
-               cdrIsoInit();\r
-               return 0;\r
-       }\r
-\r
-       hCDRDriver = SysLoadLibrary(CDRdll);\r
-       if (hCDRDriver == NULL) {\r
-               CDR_configure = NULL;\r
-               SysMessage (_("Could not load CD-ROM plugin %s!"), CDRdll);  return -1;\r
-       }\r
-       drv = hCDRDriver;\r
-       LoadCdrSym1(init, "CDRinit");\r
-       LoadCdrSym1(shutdown, "CDRshutdown");\r
-       LoadCdrSym1(open, "CDRopen");\r
-       LoadCdrSym1(close, "CDRclose");\r
-       LoadCdrSym1(getTN, "CDRgetTN");\r
-       LoadCdrSym1(getTD, "CDRgetTD");\r
-       LoadCdrSym1(readTrack, "CDRreadTrack");\r
-       LoadCdrSym1(getBuffer, "CDRgetBuffer");\r
-       LoadCdrSym1(getBufferSub, "CDRgetBufferSub");\r
-       LoadCdrSym0(play, "CDRplay");\r
-       LoadCdrSym0(stop, "CDRstop");\r
-       LoadCdrSym0(getStatus, "CDRgetStatus");\r
-       LoadCdrSym0(getDriveLetter, "CDRgetDriveLetter");\r
-       LoadCdrSym0(configure, "CDRconfigure");\r
-       LoadCdrSym0(test, "CDRtest");\r
-       LoadCdrSym0(about, "CDRabout");\r
-       LoadCdrSym0(setfilename, "CDRsetfilename");\r
-       LoadCdrSymN(readCDDA, "CDRreadCDDA");\r
-       LoadCdrSymN(getTE, "CDRgetTE");\r
-\r
-       return 0;\r
-}\r
-\r
-void *hSPUDriver = NULL;\r
-\r
-long CALLBACK SPU__configure(void) { return 0; }\r
-void CALLBACK SPU__about(void) {}\r
-long CALLBACK SPU__test(void) { return 0; }\r
-void CALLBACK SPU__registerScheduleCb(void (CALLBACK *cb)(unsigned int)) {}\r
-\r
-#define LoadSpuSym1(dest, name) \\r
-       LoadSym(SPU_##dest, SPU##dest, name, TRUE);\r
-\r
-#define LoadSpuSym0(dest, name) \\r
-       LoadSym(SPU_##dest, SPU##dest, name, FALSE); \\r
-       if (SPU_##dest == NULL) SPU_##dest = (SPU##dest) SPU__##dest;\r
-\r
-#define LoadSpuSymN(dest, name) \\r
-       LoadSym(SPU_##dest, SPU##dest, name, FALSE);\r
-\r
-static int LoadSPUplugin(const char *SPUdll) {\r
-       void *drv;\r
-\r
-       hSPUDriver = SysLoadLibrary(SPUdll);\r
-       if (hSPUDriver == NULL) {\r
-               SPU_configure = NULL;\r
-               SysMessage (_("Could not load SPU plugin %s!"), SPUdll); return -1;\r
-       }\r
-       drv = hSPUDriver;\r
-       LoadSpuSym1(init, "SPUinit");\r
-       LoadSpuSym1(shutdown, "SPUshutdown");\r
-       LoadSpuSym1(open, "SPUopen");\r
-       LoadSpuSym1(close, "SPUclose");\r
-       LoadSpuSym0(configure, "SPUconfigure");\r
-       LoadSpuSym0(about, "SPUabout");\r
-       LoadSpuSym0(test, "SPUtest");\r
-       LoadSpuSym1(writeRegister, "SPUwriteRegister");\r
-       LoadSpuSym1(readRegister, "SPUreadRegister");           \r
-       LoadSpuSym1(writeDMA, "SPUwriteDMA");\r
-       LoadSpuSym1(readDMA, "SPUreadDMA");\r
-       LoadSpuSym1(writeDMAMem, "SPUwriteDMAMem");\r
-       LoadSpuSym1(readDMAMem, "SPUreadDMAMem");\r
-       LoadSpuSym1(playADPCMchannel, "SPUplayADPCMchannel");\r
-       LoadSpuSym1(freeze, "SPUfreeze");\r
-       LoadSpuSym1(registerCallback, "SPUregisterCallback");\r
-       LoadSpuSym0(registerScheduleCb, "SPUregisterScheduleCb");\r
-       LoadSpuSymN(async, "SPUasync");\r
-       LoadSpuSymN(playCDDAchannel, "SPUplayCDDAchannel");\r
-\r
-       return 0;\r
-}\r
-\r
-void *hPAD1Driver = NULL;\r
-void *hPAD2Driver = NULL;\r
-\r
-static unsigned char buf[256];\r
-unsigned char stdpar[10] = { 0x00, 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };\r
-unsigned char mousepar[8] = { 0x00, 0x12, 0x5a, 0xff, 0xff, 0xff, 0xff };\r
-unsigned char analogpar[9] = { 0x00, 0xff, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };\r
-\r
-static int bufcount, bufc;\r
-\r
-PadDataS padd1, padd2;\r
-\r
-unsigned char _PADstartPoll(PadDataS *pad) {\r
-    bufc = 0;\r
-\r
-    switch (pad->controllerType) {\r
-        case PSE_PAD_TYPE_MOUSE:\r
-            mousepar[3] = pad->buttonStatus & 0xff;\r
-            mousepar[4] = pad->buttonStatus >> 8;\r
-            mousepar[5] = pad->moveX;\r
-            mousepar[6] = pad->moveY;\r
-\r
-            memcpy(buf, mousepar, 7);\r
-            bufcount = 6;\r
-            break;\r
-        case PSE_PAD_TYPE_NEGCON: // npc101/npc104(slph00001/slph00069)\r
-            analogpar[1] = 0x23;\r
-            analogpar[3] = pad->buttonStatus & 0xff;\r
-            analogpar[4] = pad->buttonStatus >> 8;\r
-            analogpar[5] = pad->rightJoyX;\r
-            analogpar[6] = pad->rightJoyY;\r
-            analogpar[7] = pad->leftJoyX;\r
-            analogpar[8] = pad->leftJoyY;\r
-\r
-            memcpy(buf, analogpar, 9);\r
-            bufcount = 8;\r
-            break;\r
-        case PSE_PAD_TYPE_ANALOGPAD: // scph1150\r
-            analogpar[1] = 0x73;\r
-            analogpar[3] = pad->buttonStatus & 0xff;\r
-            analogpar[4] = pad->buttonStatus >> 8;\r
-            analogpar[5] = pad->rightJoyX;\r
-            analogpar[6] = pad->rightJoyY;\r
-            analogpar[7] = pad->leftJoyX;\r
-            analogpar[8] = pad->leftJoyY;\r
-\r
-            memcpy(buf, analogpar, 9);\r
-            bufcount = 8;\r
-            break;\r
-        case PSE_PAD_TYPE_ANALOGJOY: // scph1110\r
-            analogpar[1] = 0x53;\r
-            analogpar[3] = pad->buttonStatus & 0xff;\r
-            analogpar[4] = pad->buttonStatus >> 8;\r
-            analogpar[5] = pad->rightJoyX;\r
-            analogpar[6] = pad->rightJoyY;\r
-            analogpar[7] = pad->leftJoyX;\r
-            analogpar[8] = pad->leftJoyY;\r
-\r
-            memcpy(buf, analogpar, 9);\r
-            bufcount = 8;\r
-            break;\r
-        case PSE_PAD_TYPE_STANDARD:\r
-        default:\r
-            stdpar[3] = pad->buttonStatus & 0xff;\r
-            stdpar[4] = pad->buttonStatus >> 8;\r
-\r
-            memcpy(buf, stdpar, 5);\r
-            bufcount = 4;\r
-    }\r
-\r
-    return buf[bufc++];\r
-}\r
-\r
-unsigned char _PADpoll(unsigned char value) {\r
-    if (bufc > bufcount) return 0;\r
-    return buf[bufc++];\r
-}\r
-\r
-unsigned char CALLBACK PAD1__startPoll(int pad) {\r
-    PadDataS padd;\r
-\r
-    PAD1_readPort1(&padd);\r
-\r
-    return _PADstartPoll(&padd);\r
-}\r
-\r
-unsigned char CALLBACK PAD1__poll(unsigned char value) {\r
-    return _PADpoll(value);\r
-}\r
-\r
-long CALLBACK PAD1__configure(void) { return 0; }\r
-void CALLBACK PAD1__about(void) {}\r
-long CALLBACK PAD1__test(void) { return 0; }\r
-long CALLBACK PAD1__query(void) { return 3; }\r
-long CALLBACK PAD1__keypressed() { return 0; }\r
-\r
-#define LoadPad1Sym1(dest, name) \\r
-       LoadSym(PAD1_##dest, PAD##dest, name, TRUE);\r
-\r
-#define LoadPad1SymN(dest, name) \\r
-       LoadSym(PAD1_##dest, PAD##dest, name, FALSE);\r
-\r
-#define LoadPad1Sym0(dest, name) \\r
-       LoadSym(PAD1_##dest, PAD##dest, name, FALSE); \\r
-       if (PAD1_##dest == NULL) PAD1_##dest = (PAD##dest) PAD1__##dest;\r
-\r
-static int LoadPAD1plugin(const char *PAD1dll) {\r
-       void *drv;\r
-\r
-       hPAD1Driver = SysLoadLibrary(PAD1dll);\r
-       if (hPAD1Driver == NULL) {\r
-               PAD1_configure = NULL;\r
-               SysMessage (_("Could not load Controller 1 plugin %s!"), PAD1dll); return -1;\r
-       }\r
-       drv = hPAD1Driver;\r
-       LoadPad1Sym1(init, "PADinit");\r
-       LoadPad1Sym1(shutdown, "PADshutdown");\r
-       LoadPad1Sym1(open, "PADopen");\r
-       LoadPad1Sym1(close, "PADclose");\r
-       LoadPad1Sym0(query, "PADquery");\r
-       LoadPad1Sym1(readPort1, "PADreadPort1");\r
-       LoadPad1Sym0(configure, "PADconfigure");\r
-       LoadPad1Sym0(test, "PADtest");\r
-       LoadPad1Sym0(about, "PADabout");\r
-       LoadPad1Sym0(keypressed, "PADkeypressed");\r
-       LoadPad1Sym0(startPoll, "PADstartPoll");\r
-       LoadPad1Sym0(poll, "PADpoll");\r
-       LoadPad1SymN(setSensitive, "PADsetSensitive");\r
-\r
-       return 0;\r
-}\r
-\r
-unsigned char CALLBACK PAD2__startPoll(int pad) {\r
-       PadDataS padd;\r
-\r
-       PAD2_readPort2(&padd);\r
-    \r
-       return _PADstartPoll(&padd);\r
-}\r
-\r
-unsigned char CALLBACK PAD2__poll(unsigned char value) {\r
-       return _PADpoll(value);\r
-}\r
-\r
-long CALLBACK PAD2__configure(void) { return 0; }\r
-void CALLBACK PAD2__about(void) {}\r
-long CALLBACK PAD2__test(void) { return 0; }\r
-long CALLBACK PAD2__query(void) { return PSE_PAD_USE_PORT1 | PSE_PAD_USE_PORT2; }\r
-long CALLBACK PAD2__keypressed() { return 0; }\r
-\r
-#define LoadPad2Sym1(dest, name) \\r
-       LoadSym(PAD2_##dest, PAD##dest, name, TRUE);\r
-\r
-#define LoadPad2Sym0(dest, name) \\r
-       LoadSym(PAD2_##dest, PAD##dest, name, FALSE); \\r
-       if (PAD2_##dest == NULL) PAD2_##dest = (PAD##dest) PAD2__##dest;\r
-\r
-#define LoadPad2SymN(dest, name) \\r
-       LoadSym(PAD2_##dest, PAD##dest, name, FALSE);\r
-\r
-static int LoadPAD2plugin(const char *PAD2dll) {\r
-       void *drv;\r
-\r
-       hPAD2Driver = SysLoadLibrary(PAD2dll);\r
-       if (hPAD2Driver == NULL) {\r
-               PAD2_configure = NULL;\r
-               SysMessage (_("Could not load Controller 2 plugin %s!"), PAD2dll); return -1;\r
-       }\r
-       drv = hPAD2Driver;\r
-       LoadPad2Sym1(init, "PADinit");\r
-       LoadPad2Sym1(shutdown, "PADshutdown");\r
-       LoadPad2Sym1(open, "PADopen");\r
-       LoadPad2Sym1(close, "PADclose");\r
-       LoadPad2Sym0(query, "PADquery");\r
-       LoadPad2Sym1(readPort2, "PADreadPort2");\r
-       LoadPad2Sym0(configure, "PADconfigure");\r
-       LoadPad2Sym0(test, "PADtest");\r
-       LoadPad2Sym0(about, "PADabout");\r
-       LoadPad2Sym0(keypressed, "PADkeypressed");\r
-       LoadPad2Sym0(startPoll, "PADstartPoll");\r
-       LoadPad2Sym0(poll, "PADpoll");\r
-       LoadPad2SymN(setSensitive, "PADsetSensitive");\r
-\r
-       return 0;\r
-}\r
-\r
-void *hNETDriver = NULL;\r
-\r
-void CALLBACK NET__setInfo(netInfo *info) {}\r
-void CALLBACK NET__keypressed(int key) {}\r
-long CALLBACK NET__configure(void) { return 0; }\r
-long CALLBACK NET__test(void) { return 0; }\r
-void CALLBACK NET__about(void) {}\r
-\r
-#define LoadNetSym1(dest, name) \\r
-       LoadSym(NET_##dest, NET##dest, name, TRUE);\r
-\r
-#define LoadNetSymN(dest, name) \\r
-       LoadSym(NET_##dest, NET##dest, name, FALSE);\r
-\r
-#define LoadNetSym0(dest, name) \\r
-       LoadSym(NET_##dest, NET##dest, name, FALSE); \\r
-       if (NET_##dest == NULL) NET_##dest = (NET##dest) NET__##dest;\r
-\r
-static int LoadNETplugin(const char *NETdll) {\r
-       void *drv;\r
-\r
-       hNETDriver = SysLoadLibrary(NETdll);\r
-       if (hNETDriver == NULL) {\r
-               SysMessage (_("Could not load NetPlay plugin %s!"), NETdll); return -1;\r
-       }\r
-       drv = hNETDriver;\r
-       LoadNetSym1(init, "NETinit");\r
-       LoadNetSym1(shutdown, "NETshutdown");\r
-       LoadNetSym1(open, "NETopen");\r
-       LoadNetSym1(close, "NETclose");\r
-       LoadNetSymN(sendData, "NETsendData");\r
-       LoadNetSymN(recvData, "NETrecvData");\r
-       LoadNetSym1(sendPadData, "NETsendPadData");\r
-       LoadNetSym1(recvPadData, "NETrecvPadData");\r
-       LoadNetSym1(queryPlayer, "NETqueryPlayer");\r
-       LoadNetSym1(pause, "NETpause");\r
-       LoadNetSym1(resume, "NETresume");\r
-       LoadNetSym0(setInfo, "NETsetInfo");\r
-       LoadNetSym0(keypressed, "NETkeypressed");\r
-       LoadNetSym0(configure, "NETconfigure");\r
-       LoadNetSym0(test, "NETtest");\r
-       LoadNetSym0(about, "NETabout");\r
-\r
-       return 0;\r
-}\r
-\r
-#ifdef ENABLE_SIO1API\r
-\r
-void *hSIO1Driver = NULL;\r
-\r
-long CALLBACK SIO1__init(void) { return 0; }\r
-long CALLBACK SIO1__shutdown(void) { return 0; }\r
-long CALLBACK SIO1__open(void) { return 0; }\r
-long CALLBACK SIO1__close(void) { return 0; }\r
-long CALLBACK SIO1__configure(void) { return 0; }\r
-long CALLBACK SIO1__test(void) { return 0; }\r
-void CALLBACK SIO1__about(void) {}\r
-void CALLBACK SIO1__pause(void) {}\r
-void CALLBACK SIO1__resume(void) {}\r
-long CALLBACK SIO1__keypressed(int key) { return 0; }\r
-void CALLBACK SIO1__writeData8(unsigned char val) {}\r
-void CALLBACK SIO1__writeData16(unsigned short val) {}\r
-void CALLBACK SIO1__writeData32(unsigned long val) {}\r
-void CALLBACK SIO1__writeStat16(unsigned short val) {}\r
-void CALLBACK SIO1__writeStat32(unsigned long val) {}\r
-void CALLBACK SIO1__writeMode16(unsigned short val) {}\r
-void CALLBACK SIO1__writeMode32(unsigned long val) {}\r
-void CALLBACK SIO1__writeCtrl16(unsigned short val) {}\r
-void CALLBACK SIO1__writeCtrl32(unsigned long val) {}\r
-void CALLBACK SIO1__writeBaud16(unsigned short val) {}\r
-void CALLBACK SIO1__writeBaud32(unsigned long val) {}\r
-unsigned char CALLBACK SIO1__readData8(void) { return 0; }\r
-unsigned short CALLBACK SIO1__readData16(void) { return 0; }\r
-unsigned long CALLBACK SIO1__readData32(void) { return 0; }\r
-unsigned short CALLBACK SIO1__readStat16(void) { return 0; }\r
-unsigned long CALLBACK SIO1__readStat32(void) { return 0; }\r
-unsigned short CALLBACK SIO1__readMode16(void) { return 0; }\r
-unsigned long CALLBACK SIO1__readMode32(void) { return 0; }\r
-unsigned short CALLBACK SIO1__readCtrl16(void) { return 0; }\r
-unsigned long CALLBACK SIO1__readCtrl32(void) { return 0; }\r
-unsigned short CALLBACK SIO1__readBaud16(void) { return 0; }\r
-unsigned long CALLBACK SIO1__readBaud32(void) { return 0; }\r
-void CALLBACK SIO1__registerCallback(void (CALLBACK *callback)(void)) {};\r
-\r
-void CALLBACK SIO1irq(void) {\r
-    psxHu32ref(0x1070) |= SWAPu32(0x100);\r
-}\r
-\r
-#define LoadSio1Sym1(dest, name) \\r
-    LoadSym(SIO1_##dest, SIO1##dest, name, TRUE);\r
-\r
-#define LoadSio1SymN(dest, name) \\r
-    LoadSym(SIO1_##dest, SIO1##dest, name, FALSE);\r
-\r
-#define LoadSio1Sym0(dest, name) \\r
-    LoadSym(SIO1_##dest, SIO1##dest, name, FALSE); \\r
-    if (SIO1_##dest == NULL) SIO1_##dest = (SIO1##dest) SIO1__##dest;\r
-\r
-static int LoadSIO1plugin(const char *SIO1dll) {\r
-    void *drv;\r
-\r
-    hSIO1Driver = SysLoadLibrary(SIO1dll);\r
-    if (hSIO1Driver == NULL) {\r
-        SysMessage (_("Could not load SIO1 plugin %s!"), SIO1dll); return -1;\r
-    }\r
-    drv = hSIO1Driver;\r
-\r
-    LoadSio1Sym0(init, "SIO1init");\r
-    LoadSio1Sym0(shutdown, "SIO1shutdown");\r
-    LoadSio1Sym0(open, "SIO1open");\r
-    LoadSio1Sym0(close, "SIO1close");\r
-    LoadSio1Sym0(pause, "SIO1pause");\r
-    LoadSio1Sym0(resume, "SIO1resume");\r
-    LoadSio1Sym0(keypressed, "SIO1keypressed");\r
-    LoadSio1Sym0(configure, "SIO1configure");\r
-    LoadSio1Sym0(test, "SIO1test");\r
-    LoadSio1Sym0(about, "SIO1about");\r
-    LoadSio1Sym0(writeData8, "SIO1writeData8");\r
-    LoadSio1Sym0(writeData16, "SIO1writeData16");\r
-    LoadSio1Sym0(writeData32, "SIO1writeData32");\r
-    LoadSio1Sym0(writeStat16, "SIO1writeStat16");\r
-    LoadSio1Sym0(writeStat32, "SIO1writeStat32");\r
-    LoadSio1Sym0(writeMode16, "SIO1writeMode16");\r
-    LoadSio1Sym0(writeMode32, "SIO1writeMode32");\r
-    LoadSio1Sym0(writeCtrl16, "SIO1writeCtrl16");\r
-    LoadSio1Sym0(writeCtrl32, "SIO1writeCtrl32");\r
-    LoadSio1Sym0(writeBaud16, "SIO1writeBaud16");\r
-    LoadSio1Sym0(writeBaud32, "SIO1writeBaud32");\r
-    LoadSio1Sym0(readData16, "SIO1readData16");\r
-    LoadSio1Sym0(readData32, "SIO1readData32");\r
-    LoadSio1Sym0(readStat16, "SIO1readStat16");\r
-    LoadSio1Sym0(readStat32, "SIO1readStat32");\r
-    LoadSio1Sym0(readMode16, "SIO1readMode16");\r
-    LoadSio1Sym0(readMode32, "SIO1readMode32");\r
-    LoadSio1Sym0(readCtrl16, "SIO1readCtrl16");\r
-    LoadSio1Sym0(readCtrl32, "SIO1readCtrl32");\r
-    LoadSio1Sym0(readBaud16, "SIO1readBaud16");\r
-    LoadSio1Sym0(readBaud32, "SIO1readBaud32");\r
-    LoadSio1Sym0(registerCallback, "SIO1registerCallback");\r
-\r
-    return 0;\r
-}\r
-\r
-#endif\r
-\r
-void CALLBACK clearDynarec(void) {\r
-       psxCpu->Reset();\r
-}\r
-\r
-int LoadPlugins() {\r
-       int ret;\r
-       char Plugin[MAXPATHLEN];\r
-\r
-       ReleasePlugins();\r
-       SysLibError();\r
-\r
-       if (UsingIso()) {\r
-               LoadCDRplugin(NULL);\r
-       } else {\r
-               sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Cdr);\r
-               if (LoadCDRplugin(Plugin) == -1) return -1;\r
-       }\r
-\r
-       sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Gpu);\r
-       if (LoadGPUplugin(Plugin) == -1) return -1;\r
-\r
-       sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Spu);\r
-       if (LoadSPUplugin(Plugin) == -1) return -1;\r
-\r
-       sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Pad1);\r
-       if (LoadPAD1plugin(Plugin) == -1) return -1;\r
-\r
-       sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Pad2);\r
-       if (LoadPAD2plugin(Plugin) == -1) return -1;\r
-\r
-       if (strcmp("Disabled", Config.Net) == 0 || strcmp("", Config.Net) == 0)\r
-               Config.UseNet = FALSE;\r
-       else {\r
-               Config.UseNet = TRUE;\r
-               sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Net);\r
-               if (LoadNETplugin(Plugin) == -1) Config.UseNet = FALSE;\r
-       }\r
-\r
-#ifdef ENABLE_SIO1API\r
-       sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Sio1);\r
-       if (LoadSIO1plugin(Plugin) == -1) return -1;\r
-#endif\r
-\r
-       ret = CDR_init();\r
-       if (ret < 0) { SysMessage (_("Error initializing CD-ROM plugin: %d"), ret); return -1; }\r
-       ret = GPU_init();\r
-       if (ret < 0) { SysMessage (_("Error initializing GPU plugin: %d"), ret); return -1; }\r
-       ret = SPU_init();\r
-       if (ret < 0) { SysMessage (_("Error initializing SPU plugin: %d"), ret); return -1; }\r
-       ret = PAD1_init(1);\r
-       if (ret < 0) { SysMessage (_("Error initializing Controller 1 plugin: %d"), ret); return -1; }\r
-       ret = PAD2_init(2);\r
-       if (ret < 0) { SysMessage (_("Error initializing Controller 2 plugin: %d"), ret); return -1; }\r
-\r
-       if (Config.UseNet) {\r
-               ret = NET_init();\r
-               if (ret < 0) { SysMessage (_("Error initializing NetPlay plugin: %d"), ret); return -1; }\r
-       }\r
-\r
-#ifdef ENABLE_SIO1API\r
-       ret = SIO1_init();\r
-       if (ret < 0) { SysMessage (_("Error initializing SIO1 plugin: %d"), ret); return -1; }\r
-#endif\r
-\r
-       SysPrintf(_("Plugins loaded.\n"));\r
-       return 0;\r
-}\r
-\r
-void ReleasePlugins() {\r
-       if (Config.UseNet) {\r
-               int ret = NET_close();\r
-               if (ret < 0) Config.UseNet = FALSE;\r
-       }\r
-       NetOpened = FALSE;\r
-\r
-       if (hCDRDriver != NULL || cdrIsoActive()) CDR_shutdown();\r
-       if (hGPUDriver != NULL) GPU_shutdown();\r
-       if (hSPUDriver != NULL) SPU_shutdown();\r
-       if (hPAD1Driver != NULL) PAD1_shutdown();\r
-       if (hPAD2Driver != NULL) PAD2_shutdown();\r
-\r
-       if (Config.UseNet && hNETDriver != NULL) NET_shutdown(); \r
-\r
-       if (hCDRDriver != NULL) SysCloseLibrary(hCDRDriver); hCDRDriver = NULL;\r
-       if (hGPUDriver != NULL) SysCloseLibrary(hGPUDriver); hGPUDriver = NULL;\r
-       if (hSPUDriver != NULL) SysCloseLibrary(hSPUDriver); hSPUDriver = NULL;\r
-       if (hPAD1Driver != NULL) SysCloseLibrary(hPAD1Driver); hPAD1Driver = NULL;\r
-       if (hPAD2Driver != NULL) SysCloseLibrary(hPAD2Driver); hPAD2Driver = NULL;\r
-\r
-       if (Config.UseNet && hNETDriver != NULL) {\r
-               SysCloseLibrary(hNETDriver); hNETDriver = NULL;\r
-       }\r
-\r
-#ifdef ENABLE_SIO1API\r
-       if (hSIO1Driver != NULL) {\r
-               SIO1_shutdown();\r
-               SysCloseLibrary(hSIO1Driver);\r
-               hSIO1Driver = NULL;\r
-       }\r
-#endif\r
-}\r
-\r
-// for CD swap\r
-int ReloadCdromPlugin()\r
-{\r
-       if (hCDRDriver != NULL || cdrIsoActive()) CDR_shutdown();\r
-       if (hCDRDriver != NULL) SysCloseLibrary(hCDRDriver); hCDRDriver = NULL;\r
-\r
-       if (UsingIso()) {\r
-               LoadCDRplugin(NULL);\r
-       } else {\r
-               char Plugin[MAXPATHLEN];\r
-               sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Cdr);\r
-               if (LoadCDRplugin(Plugin) == -1) return -1;\r
-       }\r
-\r
-       return CDR_init();\r
-}\r
-\r
-void SetIsoFile(const char *filename) {\r
-       if (filename == NULL) {\r
-               IsoFile[0] = '\0';\r
-               return;\r
-       }\r
-       strncpy(IsoFile, filename, MAXPATHLEN);\r
-}\r
-\r
-const char *GetIsoFile(void) {\r
-       return IsoFile;\r
-}\r
-\r
-boolean UsingIso(void) {\r
-       return (IsoFile[0] != '\0');\r
-}\r
-\r
-void SetCdOpenCaseTime(s64 time) {\r
-       cdOpenCaseTime = time;\r
-}\r
+/***************************************************************************
+ *   Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team              *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA.           *
+ ***************************************************************************/
+
+/*
+* Plugin library callback/access functions.
+*/
+
+#include "plugins.h"
+#include "cdriso.h"
+#include "../plugins/dfinput/externals.h"
+
+static char IsoFile[MAXPATHLEN] = "";
+static s64 cdOpenCaseTime = 0;
+
+GPUupdateLace         GPU_updateLace;
+GPUinit               GPU_init;
+GPUshutdown           GPU_shutdown; 
+GPUconfigure          GPU_configure;
+GPUtest               GPU_test;
+GPUabout              GPU_about;
+GPUopen               GPU_open;
+GPUclose              GPU_close;
+GPUreadStatus         GPU_readStatus;
+GPUreadData           GPU_readData;
+GPUreadDataMem        GPU_readDataMem;
+GPUwriteStatus        GPU_writeStatus; 
+GPUwriteData          GPU_writeData;
+GPUwriteDataMem       GPU_writeDataMem;
+GPUdmaChain           GPU_dmaChain;
+GPUkeypressed         GPU_keypressed;
+GPUdisplayText        GPU_displayText;
+GPUmakeSnapshot       GPU_makeSnapshot;
+GPUfreeze             GPU_freeze;
+GPUgetScreenPic       GPU_getScreenPic;
+GPUshowScreenPic      GPU_showScreenPic;
+GPUclearDynarec       GPU_clearDynarec;
+GPUvBlank             GPU_vBlank;
+
+CDRinit               CDR_init;
+CDRshutdown           CDR_shutdown;
+CDRopen               CDR_open;
+CDRclose              CDR_close; 
+CDRtest               CDR_test;
+CDRgetTN              CDR_getTN;
+CDRgetTD              CDR_getTD;
+CDRreadTrack          CDR_readTrack;
+CDRgetBuffer          CDR_getBuffer;
+CDRplay               CDR_play;
+CDRstop               CDR_stop;
+CDRgetStatus          CDR_getStatus;
+CDRgetDriveLetter     CDR_getDriveLetter;
+CDRgetBufferSub       CDR_getBufferSub;
+CDRconfigure          CDR_configure;
+CDRabout              CDR_about;
+CDRsetfilename        CDR_setfilename;
+CDRreadCDDA           CDR_readCDDA;
+CDRgetTE              CDR_getTE;
+
+SPUconfigure          SPU_configure;
+SPUabout              SPU_about;
+SPUinit               SPU_init;
+SPUshutdown           SPU_shutdown;
+SPUtest               SPU_test;
+SPUopen               SPU_open;
+SPUclose              SPU_close;
+SPUplaySample         SPU_playSample;
+SPUwriteRegister      SPU_writeRegister;
+SPUreadRegister       SPU_readRegister;
+SPUwriteDMA           SPU_writeDMA;
+SPUreadDMA            SPU_readDMA;
+SPUwriteDMAMem        SPU_writeDMAMem;
+SPUreadDMAMem         SPU_readDMAMem;
+SPUplayADPCMchannel   SPU_playADPCMchannel;
+SPUfreeze             SPU_freeze;
+SPUregisterCallback   SPU_registerCallback;
+SPUregisterScheduleCb SPU_registerScheduleCb;
+SPUasync              SPU_async;
+SPUplayCDDAchannel    SPU_playCDDAchannel;
+
+PADconfigure          PAD1_configure;
+PADabout              PAD1_about;
+PADinit               PAD1_init;
+PADshutdown           PAD1_shutdown;
+PADtest               PAD1_test;
+PADopen               PAD1_open;
+PADclose              PAD1_close;
+PADquery              PAD1_query;
+PADreadPort1          PAD1_readPort1;
+PADkeypressed         PAD1_keypressed;
+PADstartPoll          PAD1_startPoll;
+PADpoll               PAD1_poll;
+PADsetSensitive       PAD1_setSensitive;
+
+PADconfigure          PAD2_configure;
+PADabout              PAD2_about;
+PADinit               PAD2_init;
+PADshutdown           PAD2_shutdown;
+PADtest               PAD2_test;
+PADopen               PAD2_open;
+PADclose              PAD2_close;
+PADquery              PAD2_query;
+PADreadPort2          PAD2_readPort2;
+PADkeypressed         PAD2_keypressed;
+PADstartPoll          PAD2_startPoll;
+PADpoll               PAD2_poll;
+PADsetSensitive       PAD2_setSensitive;
+
+NETinit               NET_init;
+NETshutdown           NET_shutdown;
+NETopen               NET_open;
+NETclose              NET_close; 
+NETtest               NET_test;
+NETconfigure          NET_configure;
+NETabout              NET_about;
+NETpause              NET_pause;
+NETresume             NET_resume;
+NETqueryPlayer        NET_queryPlayer;
+NETsendData           NET_sendData;
+NETrecvData           NET_recvData;
+NETsendPadData        NET_sendPadData;
+NETrecvPadData        NET_recvPadData;
+NETsetInfo            NET_setInfo;
+NETkeypressed         NET_keypressed;
+
+#ifdef ENABLE_SIO1API
+
+SIO1init              SIO1_init;
+SIO1shutdown          SIO1_shutdown;
+SIO1open              SIO1_open;
+SIO1close             SIO1_close; 
+SIO1test              SIO1_test;
+SIO1configure         SIO1_configure;
+SIO1about             SIO1_about;
+SIO1pause             SIO1_pause;
+SIO1resume            SIO1_resume;
+SIO1keypressed        SIO1_keypressed;
+SIO1writeData8        SIO1_writeData8;
+SIO1writeData16       SIO1_writeData16;
+SIO1writeData32       SIO1_writeData32;
+SIO1writeStat16       SIO1_writeStat16;
+SIO1writeStat32       SIO1_writeStat32;
+SIO1writeMode16       SIO1_writeMode16;
+SIO1writeMode32       SIO1_writeMode32;
+SIO1writeCtrl16       SIO1_writeCtrl16;
+SIO1writeCtrl32       SIO1_writeCtrl32;
+SIO1writeBaud16       SIO1_writeBaud16;
+SIO1writeBaud32       SIO1_writeBaud32;
+SIO1readData8         SIO1_readData8;
+SIO1readData16        SIO1_readData16;
+SIO1readData32        SIO1_readData32;
+SIO1readStat16        SIO1_readStat16;
+SIO1readStat32        SIO1_readStat32;
+SIO1readMode16        SIO1_readMode16;
+SIO1readMode32        SIO1_readMode32;
+SIO1readCtrl16        SIO1_readCtrl16;
+SIO1readCtrl32        SIO1_readCtrl32;
+SIO1readBaud16        SIO1_readBaud16;
+SIO1readBaud32        SIO1_readBaud32;
+SIO1registerCallback  SIO1_registerCallback;
+
+#endif
+
+static const char *err;
+
+#define CheckErr(func) { \
+       err = SysLibError(); \
+       if (err != NULL) { SysMessage(_("Error loading %s: %s"), func, err); return -1; } \
+}
+
+#define LoadSym(dest, src, name, checkerr) { \
+       dest = (src)SysLoadSym(drv, name); \
+       if (checkerr) { CheckErr(name); } else SysLibError(); \
+}
+
+void *hGPUDriver = NULL;
+
+void CALLBACK GPU__displayText(char *pText) {
+       SysPrintf("%s\n", pText);
+}
+
+long CALLBACK GPU__configure(void) { return 0; }
+long CALLBACK GPU__test(void) { return 0; }
+void CALLBACK GPU__about(void) {}
+void CALLBACK GPU__makeSnapshot(void) {}
+void CALLBACK GPU__keypressed(int key) {}
+long CALLBACK GPU__getScreenPic(unsigned char *pMem) { return -1; }
+long CALLBACK GPU__showScreenPic(unsigned char *pMem) { return -1; }
+void CALLBACK GPU__clearDynarec(void (CALLBACK *callback)(void)) {}
+void CALLBACK GPU__vBlank(int val) {}
+
+#define LoadGpuSym1(dest, name) \
+       LoadSym(GPU_##dest, GPU##dest, name, TRUE);
+
+#define LoadGpuSym0(dest, name) \
+       LoadSym(GPU_##dest, GPU##dest, name, FALSE); \
+       if (GPU_##dest == NULL) GPU_##dest = (GPU##dest) GPU__##dest;
+
+#define LoadGpuSymN(dest, name) \
+       LoadSym(GPU_##dest, GPU##dest, name, FALSE);
+
+static int LoadGPUplugin(const char *GPUdll) {
+       void *drv;
+
+       hGPUDriver = SysLoadLibrary(GPUdll);
+       if (hGPUDriver == NULL) { 
+               GPU_configure = NULL;
+               SysMessage (_("Could not load GPU plugin %s!"), GPUdll); return -1; 
+       }
+       drv = hGPUDriver;
+       LoadGpuSym1(init, "GPUinit");
+       LoadGpuSym1(shutdown, "GPUshutdown");
+       LoadGpuSym1(open, "GPUopen");
+       LoadGpuSym1(close, "GPUclose");
+       LoadGpuSym1(readData, "GPUreadData");
+       LoadGpuSym1(readDataMem, "GPUreadDataMem");
+       LoadGpuSym1(readStatus, "GPUreadStatus");
+       LoadGpuSym1(writeData, "GPUwriteData");
+       LoadGpuSym1(writeDataMem, "GPUwriteDataMem");
+       LoadGpuSym1(writeStatus, "GPUwriteStatus");
+       LoadGpuSym1(dmaChain, "GPUdmaChain");
+       LoadGpuSym1(updateLace, "GPUupdateLace");
+       LoadGpuSym0(keypressed, "GPUkeypressed");
+       LoadGpuSym0(displayText, "GPUdisplayText");
+       LoadGpuSym0(makeSnapshot, "GPUmakeSnapshot");
+       LoadGpuSym1(freeze, "GPUfreeze");
+       LoadGpuSym0(getScreenPic, "GPUgetScreenPic");
+       LoadGpuSym0(showScreenPic, "GPUshowScreenPic");
+       LoadGpuSym0(clearDynarec, "GPUclearDynarec");
+    LoadGpuSym0(vBlank, "GPUvBlank");
+       LoadGpuSym0(configure, "GPUconfigure");
+       LoadGpuSym0(test, "GPUtest");
+       LoadGpuSym0(about, "GPUabout");
+
+       return 0;
+}
+
+void *hCDRDriver = NULL;
+
+long CALLBACK CDR__play(unsigned char *sector) { return 0; }
+long CALLBACK CDR__stop(void) { return 0; }
+
+long CALLBACK CDR__getStatus(struct CdrStat *stat) {
+       if (cdOpenCaseTime < 0 || cdOpenCaseTime > (s64)time(NULL))
+               stat->Status = 0x10;
+       else
+               stat->Status = 0;
+
+       return 0;
+}
+
+char* CALLBACK CDR__getDriveLetter(void) { return NULL; }
+long CALLBACK CDR__configure(void) { return 0; }
+long CALLBACK CDR__test(void) { return 0; }
+void CALLBACK CDR__about(void) {}
+long CALLBACK CDR__setfilename(char*filename) { return 0; }
+
+#define LoadCdrSym1(dest, name) \
+       LoadSym(CDR_##dest, CDR##dest, name, TRUE);
+
+#define LoadCdrSym0(dest, name) \
+       LoadSym(CDR_##dest, CDR##dest, name, FALSE); \
+       if (CDR_##dest == NULL) CDR_##dest = (CDR##dest) CDR__##dest;
+
+#define LoadCdrSymN(dest, name) \
+       LoadSym(CDR_##dest, CDR##dest, name, FALSE);
+
+static int LoadCDRplugin(const char *CDRdll) {
+       void *drv;
+
+       if (CDRdll == NULL) {
+               cdrIsoInit();
+               return 0;
+       }
+
+       hCDRDriver = SysLoadLibrary(CDRdll);
+       if (hCDRDriver == NULL) {
+               CDR_configure = NULL;
+               SysMessage (_("Could not load CD-ROM plugin %s!"), CDRdll);  return -1;
+       }
+       drv = hCDRDriver;
+       LoadCdrSym1(init, "CDRinit");
+       LoadCdrSym1(shutdown, "CDRshutdown");
+       LoadCdrSym1(open, "CDRopen");
+       LoadCdrSym1(close, "CDRclose");
+       LoadCdrSym1(getTN, "CDRgetTN");
+       LoadCdrSym1(getTD, "CDRgetTD");
+       LoadCdrSym1(readTrack, "CDRreadTrack");
+       LoadCdrSym1(getBuffer, "CDRgetBuffer");
+       LoadCdrSym1(getBufferSub, "CDRgetBufferSub");
+       LoadCdrSym0(play, "CDRplay");
+       LoadCdrSym0(stop, "CDRstop");
+       LoadCdrSym0(getStatus, "CDRgetStatus");
+       LoadCdrSym0(getDriveLetter, "CDRgetDriveLetter");
+       LoadCdrSym0(configure, "CDRconfigure");
+       LoadCdrSym0(test, "CDRtest");
+       LoadCdrSym0(about, "CDRabout");
+       LoadCdrSym0(setfilename, "CDRsetfilename");
+       LoadCdrSymN(readCDDA, "CDRreadCDDA");
+       LoadCdrSymN(getTE, "CDRgetTE");
+
+       return 0;
+}
+
+void *hSPUDriver = NULL;
+
+long CALLBACK SPU__configure(void) { return 0; }
+void CALLBACK SPU__about(void) {}
+long CALLBACK SPU__test(void) { return 0; }
+void CALLBACK SPU__registerScheduleCb(void (CALLBACK *cb)(unsigned int)) {}
+
+#define LoadSpuSym1(dest, name) \
+       LoadSym(SPU_##dest, SPU##dest, name, TRUE);
+
+#define LoadSpuSym0(dest, name) \
+       LoadSym(SPU_##dest, SPU##dest, name, FALSE); \
+       if (SPU_##dest == NULL) SPU_##dest = (SPU##dest) SPU__##dest;
+
+#define LoadSpuSymN(dest, name) \
+       LoadSym(SPU_##dest, SPU##dest, name, FALSE);
+
+static int LoadSPUplugin(const char *SPUdll) {
+       void *drv;
+
+       hSPUDriver = SysLoadLibrary(SPUdll);
+       if (hSPUDriver == NULL) {
+               SPU_configure = NULL;
+               SysMessage (_("Could not load SPU plugin %s!"), SPUdll); return -1;
+       }
+       drv = hSPUDriver;
+       LoadSpuSym1(init, "SPUinit");
+       LoadSpuSym1(shutdown, "SPUshutdown");
+       LoadSpuSym1(open, "SPUopen");
+       LoadSpuSym1(close, "SPUclose");
+       LoadSpuSym0(configure, "SPUconfigure");
+       LoadSpuSym0(about, "SPUabout");
+       LoadSpuSym0(test, "SPUtest");
+       LoadSpuSym1(writeRegister, "SPUwriteRegister");
+       LoadSpuSym1(readRegister, "SPUreadRegister");           
+       LoadSpuSym1(writeDMA, "SPUwriteDMA");
+       LoadSpuSym1(readDMA, "SPUreadDMA");
+       LoadSpuSym1(writeDMAMem, "SPUwriteDMAMem");
+       LoadSpuSym1(readDMAMem, "SPUreadDMAMem");
+       LoadSpuSym1(playADPCMchannel, "SPUplayADPCMchannel");
+       LoadSpuSym1(freeze, "SPUfreeze");
+       LoadSpuSym1(registerCallback, "SPUregisterCallback");
+       LoadSpuSym0(registerScheduleCb, "SPUregisterScheduleCb");
+       LoadSpuSymN(async, "SPUasync");
+       LoadSpuSymN(playCDDAchannel, "SPUplayCDDAchannel");
+
+       return 0;
+}
+
+void *hPAD1Driver = NULL;
+void *hPAD2Driver = NULL;
+
+static int multitap1 = -1;
+static int multitap2 = -1;
+//Pad information, keystate, mode, config mode, vibration
+static PadDataS pad[8];
+
+static int reqPos, respSize, req;
+static int ledStateReq44[8];
+
+static unsigned char buf[256];
+static unsigned char bufMulti[34] = { 0x80, 0x5a, 
+                                                                       0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                                                                       0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                                                                       0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                                                                       0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+                                                                       
+unsigned char stdpar[8] = { 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+unsigned char multitappar[34] = { 0x80, 0x5a, 
+                                                                       0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                                                                       0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                                                                       0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                                                                       0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+                                                                       
+//response for request 44, 45, 46, 47, 4C, 4D
+static unsigned char resp45[8]    = {0xF3, 0x5A, 0x01, 0x02, 0x00, 0x02, 0x01, 0x00};
+static unsigned char resp46_00[8] = {0xF3, 0x5A, 0x00, 0x00, 0x01, 0x02, 0x00, 0x0A};
+static unsigned char resp46_01[8] = {0xF3, 0x5A, 0x00, 0x00, 0x01, 0x01, 0x01, 0x14};
+static unsigned char resp47[8]    = {0xF3, 0x5A, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00};
+static unsigned char resp4C_00[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00};
+static unsigned char resp4C_01[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00};
+static unsigned char resp4D[8]    = {0xF3, 0x5A, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF};
+
+//fixed reponse of request number 41, 48, 49, 4A, 4B, 4E, 4F
+static unsigned char resp40[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char resp41[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char resp43[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char resp44[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char resp49[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char resp4A[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char resp4B[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char resp4E[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char resp4F[8] = {0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+// Resquest of psx core
+enum {
+       // REQUEST
+       // first call of this request for the pad, the pad is configured as an digital pad.
+       // 0x0X, 0x42, 0x0Y, 0xZZ, 0xAA, 0x00, 0x00, 0x00, 0x00
+       // X pad number (used for the multitap, first request response 0x00, 0x80, 0x5A, (8 bytes pad A), (8 bytes pad B), (8 bytes pad C), (8 bytes pad D)
+       // Y if 1 : psx request the full length response for the multitap, 3 bytes header and 4 block of 8 bytes per pad
+       // Y if 0 : psx request a pad key state
+       // ZZ rumble small motor 00-> OFF, 01 -> ON
+       // AA rumble large motor speed 0x00 -> 0xFF
+       // RESPONSE
+       // header 3 Bytes
+       // 0x00 
+       // PadId -> 0x41 for digital pas, 0x73 for analog pad 
+       // 0x5A mode has not change (no press on analog button on the center of pad), 0x00 the analog button have been pressed and the mode switch
+       // 6 Bytes for keystates
+       CMD_READ_DATA_AND_VIBRATE = 0x42,
+       
+       // REQUEST
+       // Header
+       // 0x0N, 0x43, 0x00, XX, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+       // XX = 00 -> Normal mode : Seconde bytes of response = padId
+       // XX = 01 -> Configuration mode : Seconde bytes of response = 0xF3
+       // RESPONSE
+       // enter in config mode example : 
+       // req : 01 43 00 01 00 00 00 00 00 00
+       // res : 00 41 5A buttons state, analog states
+       // exit config mode : 
+       // req : 01 43 00 00 00 00 00 00 00 00
+       // res : 00 F3 5A buttons state, analog states
+       CMD_CONFIG_MODE = 0x43,
+       
+       // Set led State
+       // REQUEST
+       // 0x0N, 0x44, 0x00, VAL, SEL, 0x00, 0x00, 0x00, 0x00
+       // If sel = 2 then
+       // VAL = 00 -> OFF
+       // VAL = 01 -> ON
+       // RESPONSE
+       // 0x00, 0xF3, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+       CMD_SET_MODE_AND_LOCK = 0x44,
+       
+       // Get Analog Led state
+       // REQUEST
+       // 0x0N, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+       // RESPONSE
+       // 0x00, 0xF3, 0x5A, 0x01, 0x02, VAL, 0x02, 0x01, 0x00
+       // VAL = 00 Led OFF
+       // VAL = 01 Led ON
+       CMD_QUERY_MODEL_AND_MODE = 0x45,
+       
+       //Get Variable A
+       // REQUEST
+       // 0x0N, 0x46, 0x00, 0xXX, 0x00, 0x00, 0x00, 0x00, 0x00
+       // RESPONSE
+       // XX=00
+       // 0x00, 0xF3, 0x5A, 0x00, 0x00, 0x01, 0x02, 0x00, 0x0A
+       // XX=01
+       // 0x00, 0xF3, 0x5A, 0x00, 0x00, 0x01, 0x01, 0x01, 0x14
+       CMD_QUERY_ACT = 0x46,
+       
+       // REQUEST
+       // 0x0N, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+       // RESPONSE
+       // 0x00, 0xF3, 0x5A, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00
+       CMD_QUERY_COMB = 0x47,
+       
+       // REQUEST
+       // 0x0N, 0x4C, 0x00, 0xXX, 0x00, 0x00, 0x00, 0x00, 0x00
+       // RESPONSE
+       // XX = 0
+       // 0x00, 0xF3, 0x5A, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00
+       // XX = 1
+       // 0x00, 0xF3, 0x5A, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00
+       CMD_QUERY_MODE = 0x4C,
+       
+       // REQUEST
+       // 0x0N, 0x4D, 0x00, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
+       // RESPONSE
+       // 0x00, 0xF3, 0x5A, old value or
+       // AA = 01 unlock large motor (and swap VAL1 and VAL2)
+       // BB = 01 unlock large motor (default)
+       // CC, DD, EE, FF = all FF -> unlock small motor
+       //
+       // default repsonse for analog pad with 2 motor : 0x00 0xF3 0x5A 0x00 0x01 0xFF 0xFF 0xFF 0xFF
+       //
+       CMD_VIBRATION_TOGGLE = 0x4D,
+       REQ40 = 0x40,
+       REQ41 = 0x41,
+       REQ49 = 0x49,
+       REQ4A = 0x4A,
+       REQ4B = 0x4B,
+       REQ4E = 0x4E,
+       REQ4F = 0x4F
+};
+
+
+
+
+//NO MULTITAP
+
+void initBufForRequest(int padIndex, char value){
+       switch (value){
+               //Pad keystate already in buffer
+               //case CMD_READ_DATA_AND_VIBRATE :
+               //      break;
+               case CMD_CONFIG_MODE :
+                       if (pad[padIndex].configMode == 1) {
+                               memcpy(buf, resp43, 8);
+                               break;
+                       }
+                       //else, not in config mode, pad keystate return (already in the buffer)
+                       break;
+               case CMD_SET_MODE_AND_LOCK :
+                       memcpy(buf, resp44, 8);
+                       break;
+               case CMD_QUERY_MODEL_AND_MODE :
+                       memcpy(buf, resp45, 8);
+                       break;
+               case CMD_QUERY_ACT :
+                       memcpy(buf, resp46_00, 8);
+                       break;
+               case CMD_QUERY_COMB :
+                       memcpy(buf, resp47, 8);
+                       break;
+               case CMD_QUERY_MODE :
+                       memcpy(buf, resp4C_00, 8);
+                       break;
+               case CMD_VIBRATION_TOGGLE :
+                       memcpy(buf, resp4D, 8);
+                       break;
+               case REQ40 :
+                       memcpy(buf, resp40, 8);
+                       break;
+               case REQ41 :
+                       memcpy(buf, resp41, 8);
+                       break;
+               case REQ49 :
+                       memcpy(buf, resp49, 8);
+                       break;
+               case REQ4A :
+                       memcpy(buf, resp4A, 8);
+                       break;
+               case REQ4B :
+                       memcpy(buf, resp4B, 8);
+                       break;
+               case REQ4E :
+                       memcpy(buf, resp4E, 8);
+                       break;
+               case REQ4F :
+                       memcpy(buf, resp4F, 8);
+                       break;
+       }
+}
+
+
+
+
+void reqIndex2Treatment(int padIndex, char value){
+       switch (req){
+               case CMD_CONFIG_MODE :
+                       //0x43
+                       if (value == 0) {
+                               pad[padIndex].configMode = 0;
+                       } else {
+                               pad[padIndex].configMode = 1;
+                       }
+                       break;
+               case CMD_SET_MODE_AND_LOCK :
+                       //0x44 store the led state for change mode if the next value = 0x02
+                       //0x01 analog ON
+                       //0x00 analog OFF
+                       ledStateReq44[padIndex] = value;
+                       break;
+               case CMD_QUERY_ACT :
+                       //0x46
+                       if (value == 1) {
+                               memcpy(buf, resp46_01, 8);
+                       }
+                       break;
+               case CMD_QUERY_MODE :
+                       if (value == 1) {
+                               memcpy(buf, resp4C_01, 8);
+                       }
+                       break;
+               case CMD_VIBRATION_TOGGLE :
+                       //0x4D
+                       memcpy(buf, resp4D, 8);
+                       break;
+               case CMD_READ_DATA_AND_VIBRATE:
+                       //mem the vibration value for small motor;
+                       pad[padIndex].Vib[0] = value;
+                       break;
+       }
+}
+       
+void vibrate(int padIndex){
+       if (pad[padIndex].Vib[0] != pad[padIndex].VibF[0] || pad[padIndex].Vib[1] != pad[padIndex].VibF[1]) {
+               //value is different update Value and call libretro for vibration
+               pad[padIndex].VibF[0] = pad[padIndex].Vib[0];
+               pad[padIndex].VibF[1] = pad[padIndex].Vib[1];
+               plat_trigger_vibrate(padIndex, pad[padIndex].VibF[0], pad[padIndex].VibF[1]);
+               //printf("vibration pad %i", padIndex);
+       }
+}
+
+
+
+
+//Build response for 0x42 request Pad in port
+void _PADstartPoll(PadDataS *pad) {
+    switch (pad->controllerType) {
+        case PSE_PAD_TYPE_MOUSE:
+                       stdpar[0] = 0x12;
+            stdpar[2] = pad->buttonStatus & 0xff;
+            stdpar[3] = pad->buttonStatus >> 8;
+            stdpar[4] = pad->moveX;
+            stdpar[5] = pad->moveY;
+            memcpy(buf, stdpar, 6);
+            respSize = 6;
+            break;
+        case PSE_PAD_TYPE_NEGCON: // npc101/npc104(slph00001/slph00069)
+            stdpar[0] = 0x23;
+            stdpar[2] = pad->buttonStatus & 0xff;
+            stdpar[3] = pad->buttonStatus >> 8;
+            stdpar[4] = pad->rightJoyX;
+            stdpar[5] = pad->rightJoyY;
+            stdpar[6] = pad->leftJoyX;
+            stdpar[7] = pad->leftJoyY;
+            memcpy(buf, stdpar, 8);
+            respSize = 8;
+            break;
+        case PSE_PAD_TYPE_ANALOGPAD: // scph1150
+            stdpar[0] = 0x73;
+            stdpar[2] = pad->buttonStatus & 0xff;
+            stdpar[3] = pad->buttonStatus >> 8;
+            stdpar[4] = pad->rightJoyX;
+            stdpar[5] = pad->rightJoyY;
+            stdpar[6] = pad->leftJoyX;
+            stdpar[7] = pad->leftJoyY;
+            memcpy(buf, stdpar, 8);
+            respSize = 8;
+            break;
+        case PSE_PAD_TYPE_ANALOGJOY: // scph1110
+            stdpar[0] = 0x53;
+            stdpar[2] = pad->buttonStatus & 0xff;
+            stdpar[3] = pad->buttonStatus >> 8;
+            stdpar[4] = pad->rightJoyX;
+            stdpar[5] = pad->rightJoyY;
+            stdpar[6] = pad->leftJoyX;
+            stdpar[7] = pad->leftJoyY;
+            memcpy(buf, stdpar, 8);
+            respSize = 8;
+            break;
+        case PSE_PAD_TYPE_STANDARD:
+        default:
+               stdpar[0] = 0x41;
+            stdpar[2] = pad->buttonStatus & 0xff;
+            stdpar[3] = pad->buttonStatus >> 8;
+            //avoid analog value in multitap mode if change pad type in game.
+            stdpar[4] = 0xff;
+            stdpar[5] = 0xff;
+            stdpar[6] = 0xff;
+            stdpar[7] = 0xff;
+               memcpy(buf, stdpar, 8);
+               respSize = 8;
+    }
+}
+
+
+//Build response for 0x42 request Multitap in port
+//Response header for multitap : 0x80, 0x5A, (Pad information port 1-2A), (Pad information port 1-2B), (Pad information port 1-2C), (Pad information port 1-2D)
+void _PADstartPollMultitap(PadDataS* padd) {
+    int i, offset;
+    for(i = 0; i < 4; i++) {
+       offset = 2 + (i * 8);
+       _PADstartPoll(&padd[i]);
+       memcpy(multitappar+offset, stdpar, 8);
+    }
+    memcpy(bufMulti, multitappar, 34);
+    respSize = 34;
+}
+
+
+unsigned char _PADpoll(int port, unsigned char value) {
+       if (reqPos == 0) {
+               //mem the request number
+               req = value;
+               //copy the default value of request response in buffer instead of the keystate
+               initBufForRequest(port, value);
+       }
+       
+       //if no new request the pad return 0xff, for signaling connected
+       if (reqPos >= respSize) return 0xff;
+       
+       switch(reqPos){
+               case 2:
+                       reqIndex2Treatment(port, value);
+               break;
+               case 3:
+                       switch(req) {
+                               case CMD_SET_MODE_AND_LOCK :
+                                       //change mode on pad
+                               break;
+                               case CMD_READ_DATA_AND_VIBRATE:
+                               //mem the vibration value for Large motor;
+                               pad[port].Vib[1] = value;
+                               //vibration
+                               vibrate(port);
+                               break;
+                       }
+               break;
+       }
+       return buf[reqPos++];
+}
+
+
+unsigned char _PADpollMultitap(int port, unsigned char value) {
+       if (reqPos >= respSize) return 0xff;
+       return bufMulti[reqPos++];
+}
+
+
+// refresh the button state on port 1.
+// int pad is not needed.
+unsigned char CALLBACK PAD1__startPoll(int pad) {
+       reqPos = 0;
+       // first call the pad provide if a multitap is connected between the psx and himself
+       if (multitap1 == -1) {
+               PadDataS padd;
+               padd.requestPadIndex = 0;
+               PAD1_readPort1(&padd);
+               multitap1 = padd.portMultitap;
+       }
+       // just one pad is on port 1 : NO MULTITAP
+       if (multitap1 == 0) {
+               PadDataS padd;
+               padd.requestPadIndex = 0;
+               PAD1_readPort1(&padd);
+               _PADstartPoll(&padd);
+       } else {
+               // a multitap is plugged : refresh all pad.
+               int i;
+               PadDataS padd[4];
+               for(i = 0; i < 4; i++) {
+                       padd[i].requestPadIndex = i;
+                       PAD1_readPort1(&padd[i]);
+               }
+               _PADstartPollMultitap(padd);
+       }
+       //printf("\npad 1 : ");
+       return 0x00;
+}
+
+unsigned char CALLBACK PAD1__poll(unsigned char value) {
+       char tmp;
+       if (multitap1 == 1) {
+               tmp = _PADpollMultitap(0, value);
+       } else {
+               tmp = _PADpoll(0, value);
+       }
+       //printf("%2x:%2x, ",value,tmp);
+       return tmp;
+       
+}
+
+
+long CALLBACK PAD1__configure(void) { return 0; }
+void CALLBACK PAD1__about(void) {}
+long CALLBACK PAD1__test(void) { return 0; }
+long CALLBACK PAD1__query(void) { return 3; }
+long CALLBACK PAD1__keypressed() { return 0; }
+
+#define LoadPad1Sym1(dest, name) \
+       LoadSym(PAD1_##dest, PAD##dest, name, TRUE);
+
+#define LoadPad1SymN(dest, name) \
+       LoadSym(PAD1_##dest, PAD##dest, name, FALSE);
+
+#define LoadPad1Sym0(dest, name) \
+       LoadSym(PAD1_##dest, PAD##dest, name, FALSE); \
+       if (PAD1_##dest == NULL) PAD1_##dest = (PAD##dest) PAD1__##dest;
+
+static int LoadPAD1plugin(const char *PAD1dll) {
+       void *drv;
+
+       hPAD1Driver = SysLoadLibrary(PAD1dll);
+       if (hPAD1Driver == NULL) {
+               PAD1_configure = NULL;
+               SysMessage (_("Could not load Controller 1 plugin %s!"), PAD1dll); return -1;
+       }
+       drv = hPAD1Driver;
+       LoadPad1Sym1(init, "PADinit");
+       LoadPad1Sym1(shutdown, "PADshutdown");
+       LoadPad1Sym1(open, "PADopen");
+       LoadPad1Sym1(close, "PADclose");
+       LoadPad1Sym0(query, "PADquery");
+       LoadPad1Sym1(readPort1, "PADreadPort1");
+       LoadPad1Sym0(configure, "PADconfigure");
+       LoadPad1Sym0(test, "PADtest");
+       LoadPad1Sym0(about, "PADabout");
+       LoadPad1Sym0(keypressed, "PADkeypressed");
+       LoadPad1Sym0(startPoll, "PADstartPoll");
+       LoadPad1Sym0(poll, "PADpoll");
+       LoadPad1SymN(setSensitive, "PADsetSensitive");
+
+       return 0;
+}
+
+unsigned char CALLBACK PAD2__startPoll(int pad) {
+       int pad_index;
+
+       reqPos = 0;
+       if (multitap1 == 0 && (multitap2 == 0 || multitap2 == 2)) {
+               pad_index = 1;
+       } else if(multitap1 == 1 && (multitap2 == 0 || multitap2 == 2)) {
+               pad_index = 4;
+       } else {
+               pad_index = 0;
+       }
+
+       //first call the pad provide if a multitap is connected between the psx and himself
+       if (multitap2 == -1) {
+               PadDataS padd;
+               padd.requestPadIndex = pad_index;
+               PAD2_readPort2(&padd);
+               multitap2 = padd.portMultitap;
+       }
+       
+       // just one pad is on port 1 : NO MULTITAP
+       if (multitap2 == 0) {
+               PadDataS padd;
+               padd.requestPadIndex = pad_index;
+               PAD2_readPort2(&padd);
+               _PADstartPoll(&padd);
+       } else {
+               // a multitap is plugged : refresh all pad.
+               int i;
+               PadDataS padd[4];
+               for(i = 0; i < 4; i++) {
+                       padd[i].requestPadIndex = i+pad_index;
+                       PAD2_readPort2(&padd[i]);
+               }
+               _PADstartPollMultitap(padd);
+       }
+       //printf("\npad 2 : ");
+       return 0x00;
+}
+
+unsigned char CALLBACK PAD2__poll(unsigned char value) {
+       char tmp;
+       if (multitap2 == 2) {
+               tmp = _PADpollMultitap(1, value);
+       } else {
+               tmp = _PADpoll(1, value);
+       }
+       //printf("%2x:%2x, ",value,tmp);
+       return tmp;
+}
+
+long CALLBACK PAD2__configure(void) { return 0; }
+void CALLBACK PAD2__about(void) {}
+long CALLBACK PAD2__test(void) { return 0; }
+long CALLBACK PAD2__query(void) { return PSE_PAD_USE_PORT1 | PSE_PAD_USE_PORT2; }
+long CALLBACK PAD2__keypressed() { return 0; }
+
+#define LoadPad2Sym1(dest, name) \
+       LoadSym(PAD2_##dest, PAD##dest, name, TRUE);
+
+#define LoadPad2Sym0(dest, name) \
+       LoadSym(PAD2_##dest, PAD##dest, name, FALSE); \
+       if (PAD2_##dest == NULL) PAD2_##dest = (PAD##dest) PAD2__##dest;
+
+#define LoadPad2SymN(dest, name) \
+       LoadSym(PAD2_##dest, PAD##dest, name, FALSE);
+
+static int LoadPAD2plugin(const char *PAD2dll) {
+       void *drv;
+
+       hPAD2Driver = SysLoadLibrary(PAD2dll);
+       if (hPAD2Driver == NULL) {
+               PAD2_configure = NULL;
+               SysMessage (_("Could not load Controller 2 plugin %s!"), PAD2dll); return -1;
+       }
+       drv = hPAD2Driver;
+       LoadPad2Sym1(init, "PADinit");
+       LoadPad2Sym1(shutdown, "PADshutdown");
+       LoadPad2Sym1(open, "PADopen");
+       LoadPad2Sym1(close, "PADclose");
+       LoadPad2Sym0(query, "PADquery");
+       LoadPad2Sym1(readPort2, "PADreadPort2");
+       LoadPad2Sym0(configure, "PADconfigure");
+       LoadPad2Sym0(test, "PADtest");
+       LoadPad2Sym0(about, "PADabout");
+       LoadPad2Sym0(keypressed, "PADkeypressed");
+       LoadPad2Sym0(startPoll, "PADstartPoll");
+       LoadPad2Sym0(poll, "PADpoll");
+       LoadPad2SymN(setSensitive, "PADsetSensitive");
+
+       return 0;
+}
+
+void *hNETDriver = NULL;
+
+void CALLBACK NET__setInfo(netInfo *info) {}
+void CALLBACK NET__keypressed(int key) {}
+long CALLBACK NET__configure(void) { return 0; }
+long CALLBACK NET__test(void) { return 0; }
+void CALLBACK NET__about(void) {}
+
+#define LoadNetSym1(dest, name) \
+       LoadSym(NET_##dest, NET##dest, name, TRUE);
+
+#define LoadNetSymN(dest, name) \
+       LoadSym(NET_##dest, NET##dest, name, FALSE);
+
+#define LoadNetSym0(dest, name) \
+       LoadSym(NET_##dest, NET##dest, name, FALSE); \
+       if (NET_##dest == NULL) NET_##dest = (NET##dest) NET__##dest;
+
+static int LoadNETplugin(const char *NETdll) {
+       void *drv;
+
+       hNETDriver = SysLoadLibrary(NETdll);
+       if (hNETDriver == NULL) {
+               SysMessage (_("Could not load NetPlay plugin %s!"), NETdll); return -1;
+       }
+       drv = hNETDriver;
+       LoadNetSym1(init, "NETinit");
+       LoadNetSym1(shutdown, "NETshutdown");
+       LoadNetSym1(open, "NETopen");
+       LoadNetSym1(close, "NETclose");
+       LoadNetSymN(sendData, "NETsendData");
+       LoadNetSymN(recvData, "NETrecvData");
+       LoadNetSym1(sendPadData, "NETsendPadData");
+       LoadNetSym1(recvPadData, "NETrecvPadData");
+       LoadNetSym1(queryPlayer, "NETqueryPlayer");
+       LoadNetSym1(pause, "NETpause");
+       LoadNetSym1(resume, "NETresume");
+       LoadNetSym0(setInfo, "NETsetInfo");
+       LoadNetSym0(keypressed, "NETkeypressed");
+       LoadNetSym0(configure, "NETconfigure");
+       LoadNetSym0(test, "NETtest");
+       LoadNetSym0(about, "NETabout");
+
+       return 0;
+}
+
+#ifdef ENABLE_SIO1API
+
+void *hSIO1Driver = NULL;
+
+long CALLBACK SIO1__init(void) { return 0; }
+long CALLBACK SIO1__shutdown(void) { return 0; }
+long CALLBACK SIO1__open(void) { return 0; }
+long CALLBACK SIO1__close(void) { return 0; }
+long CALLBACK SIO1__configure(void) { return 0; }
+long CALLBACK SIO1__test(void) { return 0; }
+void CALLBACK SIO1__about(void) {}
+void CALLBACK SIO1__pause(void) {}
+void CALLBACK SIO1__resume(void) {}
+long CALLBACK SIO1__keypressed(int key) { return 0; }
+void CALLBACK SIO1__writeData8(unsigned char val) {}
+void CALLBACK SIO1__writeData16(unsigned short val) {}
+void CALLBACK SIO1__writeData32(unsigned long val) {}
+void CALLBACK SIO1__writeStat16(unsigned short val) {}
+void CALLBACK SIO1__writeStat32(unsigned long val) {}
+void CALLBACK SIO1__writeMode16(unsigned short val) {}
+void CALLBACK SIO1__writeMode32(unsigned long val) {}
+void CALLBACK SIO1__writeCtrl16(unsigned short val) {}
+void CALLBACK SIO1__writeCtrl32(unsigned long val) {}
+void CALLBACK SIO1__writeBaud16(unsigned short val) {}
+void CALLBACK SIO1__writeBaud32(unsigned long val) {}
+unsigned char CALLBACK SIO1__readData8(void) { return 0; }
+unsigned short CALLBACK SIO1__readData16(void) { return 0; }
+unsigned long CALLBACK SIO1__readData32(void) { return 0; }
+unsigned short CALLBACK SIO1__readStat16(void) { return 0; }
+unsigned long CALLBACK SIO1__readStat32(void) { return 0; }
+unsigned short CALLBACK SIO1__readMode16(void) { return 0; }
+unsigned long CALLBACK SIO1__readMode32(void) { return 0; }
+unsigned short CALLBACK SIO1__readCtrl16(void) { return 0; }
+unsigned long CALLBACK SIO1__readCtrl32(void) { return 0; }
+unsigned short CALLBACK SIO1__readBaud16(void) { return 0; }
+unsigned long CALLBACK SIO1__readBaud32(void) { return 0; }
+void CALLBACK SIO1__registerCallback(void (CALLBACK *callback)(void)) {};
+
+void CALLBACK SIO1irq(void) {
+    psxHu32ref(0x1070) |= SWAPu32(0x100);
+}
+
+#define LoadSio1Sym1(dest, name) \
+    LoadSym(SIO1_##dest, SIO1##dest, name, TRUE);
+
+#define LoadSio1SymN(dest, name) \
+    LoadSym(SIO1_##dest, SIO1##dest, name, FALSE);
+
+#define LoadSio1Sym0(dest, name) \
+    LoadSym(SIO1_##dest, SIO1##dest, name, FALSE); \
+    if (SIO1_##dest == NULL) SIO1_##dest = (SIO1##dest) SIO1__##dest;
+
+static int LoadSIO1plugin(const char *SIO1dll) {
+    void *drv;
+
+    hSIO1Driver = SysLoadLibrary(SIO1dll);
+    if (hSIO1Driver == NULL) {
+        SysMessage (_("Could not load SIO1 plugin %s!"), SIO1dll); return -1;
+    }
+    drv = hSIO1Driver;
+
+    LoadSio1Sym0(init, "SIO1init");
+    LoadSio1Sym0(shutdown, "SIO1shutdown");
+    LoadSio1Sym0(open, "SIO1open");
+    LoadSio1Sym0(close, "SIO1close");
+    LoadSio1Sym0(pause, "SIO1pause");
+    LoadSio1Sym0(resume, "SIO1resume");
+    LoadSio1Sym0(keypressed, "SIO1keypressed");
+    LoadSio1Sym0(configure, "SIO1configure");
+    LoadSio1Sym0(test, "SIO1test");
+    LoadSio1Sym0(about, "SIO1about");
+    LoadSio1Sym0(writeData8, "SIO1writeData8");
+    LoadSio1Sym0(writeData16, "SIO1writeData16");
+    LoadSio1Sym0(writeData32, "SIO1writeData32");
+    LoadSio1Sym0(writeStat16, "SIO1writeStat16");
+    LoadSio1Sym0(writeStat32, "SIO1writeStat32");
+    LoadSio1Sym0(writeMode16, "SIO1writeMode16");
+    LoadSio1Sym0(writeMode32, "SIO1writeMode32");
+    LoadSio1Sym0(writeCtrl16, "SIO1writeCtrl16");
+    LoadSio1Sym0(writeCtrl32, "SIO1writeCtrl32");
+    LoadSio1Sym0(writeBaud16, "SIO1writeBaud16");
+    LoadSio1Sym0(writeBaud32, "SIO1writeBaud32");
+    LoadSio1Sym0(readData16, "SIO1readData16");
+    LoadSio1Sym0(readData32, "SIO1readData32");
+    LoadSio1Sym0(readStat16, "SIO1readStat16");
+    LoadSio1Sym0(readStat32, "SIO1readStat32");
+    LoadSio1Sym0(readMode16, "SIO1readMode16");
+    LoadSio1Sym0(readMode32, "SIO1readMode32");
+    LoadSio1Sym0(readCtrl16, "SIO1readCtrl16");
+    LoadSio1Sym0(readCtrl32, "SIO1readCtrl32");
+    LoadSio1Sym0(readBaud16, "SIO1readBaud16");
+    LoadSio1Sym0(readBaud32, "SIO1readBaud32");
+    LoadSio1Sym0(registerCallback, "SIO1registerCallback");
+
+    return 0;
+}
+
+#endif
+
+void CALLBACK clearDynarec(void) {
+       psxCpu->Reset();
+}
+
+int LoadPlugins() {
+       int ret;
+       char Plugin[MAXPATHLEN];
+
+       ReleasePlugins();
+       SysLibError();
+
+       if (UsingIso()) {
+               LoadCDRplugin(NULL);
+       } else {
+               sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Cdr);
+               if (LoadCDRplugin(Plugin) == -1) return -1;
+       }
+
+       sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Gpu);
+       if (LoadGPUplugin(Plugin) == -1) return -1;
+
+       sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Spu);
+       if (LoadSPUplugin(Plugin) == -1) return -1;
+
+       sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Pad1);
+       if (LoadPAD1plugin(Plugin) == -1) return -1;
+
+       sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Pad2);
+       if (LoadPAD2plugin(Plugin) == -1) return -1;
+
+       if (strcmp("Disabled", Config.Net) == 0 || strcmp("", Config.Net) == 0)
+               Config.UseNet = FALSE;
+       else {
+               Config.UseNet = TRUE;
+               sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Net);
+               if (LoadNETplugin(Plugin) == -1) Config.UseNet = FALSE;
+       }
+
+#ifdef ENABLE_SIO1API
+       sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Sio1);
+       if (LoadSIO1plugin(Plugin) == -1) return -1;
+#endif
+
+       ret = CDR_init();
+       if (ret < 0) { SysMessage (_("Error initializing CD-ROM plugin: %d"), ret); return -1; }
+       ret = GPU_init();
+       if (ret < 0) { SysMessage (_("Error initializing GPU plugin: %d"), ret); return -1; }
+       ret = SPU_init();
+       if (ret < 0) { SysMessage (_("Error initializing SPU plugin: %d"), ret); return -1; }
+       ret = PAD1_init(1);
+       if (ret < 0) { SysMessage (_("Error initializing Controller 1 plugin: %d"), ret); return -1; }
+       ret = PAD2_init(2);
+       if (ret < 0) { SysMessage (_("Error initializing Controller 2 plugin: %d"), ret); return -1; }
+
+       if (Config.UseNet) {
+               ret = NET_init();
+               if (ret < 0) { SysMessage (_("Error initializing NetPlay plugin: %d"), ret); return -1; }
+       }
+
+#ifdef ENABLE_SIO1API
+       ret = SIO1_init();
+       if (ret < 0) { SysMessage (_("Error initializing SIO1 plugin: %d"), ret); return -1; }
+#endif
+
+       SysPrintf(_("Plugins loaded.\n"));
+       return 0;
+}
+
+void ReleasePlugins() {
+       if (Config.UseNet) {
+               int ret = NET_close();
+               if (ret < 0) Config.UseNet = FALSE;
+       }
+       NetOpened = FALSE;
+
+       if (hCDRDriver != NULL || cdrIsoActive()) CDR_shutdown();
+       if (hGPUDriver != NULL) GPU_shutdown();
+       if (hSPUDriver != NULL) SPU_shutdown();
+       if (hPAD1Driver != NULL) PAD1_shutdown();
+       if (hPAD2Driver != NULL) PAD2_shutdown();
+
+       if (Config.UseNet && hNETDriver != NULL) NET_shutdown(); 
+
+       if (hCDRDriver != NULL) SysCloseLibrary(hCDRDriver); hCDRDriver = NULL;
+       if (hGPUDriver != NULL) SysCloseLibrary(hGPUDriver); hGPUDriver = NULL;
+       if (hSPUDriver != NULL) SysCloseLibrary(hSPUDriver); hSPUDriver = NULL;
+       if (hPAD1Driver != NULL) SysCloseLibrary(hPAD1Driver); hPAD1Driver = NULL;
+       if (hPAD2Driver != NULL) SysCloseLibrary(hPAD2Driver); hPAD2Driver = NULL;
+
+       if (Config.UseNet && hNETDriver != NULL) {
+               SysCloseLibrary(hNETDriver); hNETDriver = NULL;
+       }
+
+#ifdef ENABLE_SIO1API
+       if (hSIO1Driver != NULL) {
+               SIO1_shutdown();
+               SysCloseLibrary(hSIO1Driver);
+               hSIO1Driver = NULL;
+       }
+#endif
+}
+
+// for CD swap
+int ReloadCdromPlugin()
+{
+       if (hCDRDriver != NULL || cdrIsoActive()) CDR_shutdown();
+       if (hCDRDriver != NULL) SysCloseLibrary(hCDRDriver); hCDRDriver = NULL;
+
+       if (UsingIso()) {
+               LoadCDRplugin(NULL);
+       } else {
+               char Plugin[MAXPATHLEN];
+               sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Cdr);
+               if (LoadCDRplugin(Plugin) == -1) return -1;
+       }
+
+       return CDR_init();
+}
+
+void SetIsoFile(const char *filename) {
+       if (filename == NULL) {
+               IsoFile[0] = '\0';
+               return;
+       }
+       strncpy(IsoFile, filename, MAXPATHLEN);
+}
+
+const char *GetIsoFile(void) {
+       return IsoFile;
+}
+
+boolean UsingIso(void) {
+       return (IsoFile[0] != '\0');
+}
+
+void SetCdOpenCaseTime(s64 time) {
+       cdOpenCaseTime = time;
+}
index 292d80d..d5ed725 100644 (file)
@@ -2216,6 +2216,15 @@ void psxBios_ChangeClearPad() { // 5b
        pc0 = ra;
 }
 
+void psxBios__card_status() { // 5c
+#ifdef PSXBIOS_LOG
+   PSXBIOS_LOG("psxBios_%s: %x\n", biosB0n[0x5c], a0);
+#endif
+
+   v0 = 1;
+   pc0 = ra;
+}
+
 /* System calls C0 */
 
 /*
@@ -2569,7 +2578,7 @@ void psxBiosInit() {
        //biosB0[0x59] = psxBios_sys_b0_59;
        //biosB0[0x5a] = psxBios_sys_b0_5a;
        biosB0[0x5b] = psxBios_ChangeClearPad;
-       //biosB0[0x5c] = psxBios__card_status;
+       biosB0[0x5c] = psxBios__card_status;
        //biosB0[0x5d] = psxBios__card_wait;
 //*******************C0 CALLS****************************
        //biosC0[0x00] = psxBios_InitRCnt;
index 82eb885..22341c5 100644 (file)
@@ -50,7 +50,7 @@ int psxInit() {
 void psxReset() {
        psxMemReset();
 
-       memset(&psxRegs, 0, sizeof(psxRegs));
+       memset(&psxRegs, 0x00, sizeof(psxRegs));
 
        psxRegs.pc = 0xbfc00000; // Start in bootstrap
 
index b3732d2..d251fa7 100644 (file)
@@ -117,6 +117,20 @@ void sioWrite8(unsigned char value) {
                                                        break;
                                        }
                                }
+                               // NegCon - Wipeout 3
+                               if( buf[parp] == 0x23 ) {
+                                       switch (value) {
+                                               // enter config mode
+                                               case 0x43:
+                                                       buf[1] = 0x79;
+                                                       break;
+
+                                               // get status
+                                               case 0x45:
+                                                       buf[1] = 0xf3;
+                                                       break;
+                                       }
+                               }
                        }
                        else padst = 0;
                        return;
index 31f82e2..c408bc3 100644 (file)
  *  along with this program; if not, see <http://www.gnu.org/licenses>.
  */
 
+#ifdef NO_SOCKET
+
+int StartServer() { return 0;}
+void StopServer() {}
+void GetClient() {}
+void CloseClient() {}
+int HasClient() { return 0;}
+int ReadSocket(char * buffer, int len) { return 0;}
+int RawReadSocket(char * buffer, int len) { return 0;}
+void WriteSocket(char * buffer, int len) {}
+
+void SetsBlock() {}
+void SetsNonblock() {}
+
+#else // NO_SOCKET
+
 #ifdef _WIN32
 #include <winsock2.h>
 #endif
@@ -252,3 +268,4 @@ void SetsNonblock() {
     fcntl(server_socket, F_SETFL, flags | O_NONBLOCK);
 #endif
 }
+#endif // NO_SOCKET
diff --git a/maemo/hildon.c b/maemo/hildon.c
deleted file mode 100644 (file)
index 7e9cd9f..0000000
+++ /dev/null
@@ -1,843 +0,0 @@
-#include <gtk/gtk.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <hildon/hildon.h>
-#include <string.h>
-#include <pthread.h>
-
-#include "../frontend/plugin_lib.h"
-#include "../frontend/main.h"
-#include "../libpcsxcore/misc.h"
-#include "../include/psemu_plugin_defs.h"
-#include "../libpcsxcore/cdrom.h"
-#include "../libpcsxcore/cdriso.h"
-#include "../plugins/dfinput/main.h"
-#include "../frontend/libpicofe/readpng.h"
-#include "maemo_common.h"
-#include <libosso.h>
-#include <dbus/dbus.h>
-
-#define X_RES           800
-#define Y_RES           480
-#define D_WIDTH                        640
-#define D_HEIGHT               480
-
-#define CALL_SIGNAL_IF "com.nokia.csd.Call"
-#define CALL_SIGNAL_PATH "/com/nokia/csd/call"
-#define CALL_INCOMING_SIG "Coming"
-
-#define DBUS_RULE_CALL_INCOMING "type='signal',interface='" CALL_SIGNAL_IF \
-                                "',path='" CALL_SIGNAL_PATH \
-                                "',member='" CALL_INCOMING_SIG "'"
-
-osso_context_t* osso = NULL;
-int bRunning = TRUE;
-extern int bKeepDisplayOn;
-extern int bAutosaveOnExit;
-extern int cornerActions[4];
-extern char keys_config_file[MAXPATHLEN];
-static pthread_t display_thread = (pthread_t)0;
-int g_layer_x = (X_RES - D_WIDTH) / 2;
-int g_layer_y = (Y_RES - D_HEIGHT) / 2;
-int g_layer_w = D_WIDTH, g_layer_h = D_HEIGHT;
-
-static GdkImage *image;
-static HildonAnimationActor *actor;
-static GtkWidget *window, *drawing = NULL;
-
-static int pl_buf_w, pl_buf_h;
-int keymap[65536];
-int direction_keys[4];
-
-// map psx4m compatible keymap to PSX keys
-static const unsigned char keymap2[14] = {
-       DKEY_LEFT,   // 0
-       DKEY_RIGHT,
-       DKEY_UP,
-       DKEY_DOWN,
-       DKEY_CIRCLE,
-       DKEY_CROSS,  // 5
-       DKEY_TRIANGLE,
-       DKEY_SQUARE,
-       DKEY_SELECT,
-       DKEY_START,
-       DKEY_L1,     // 10
-       DKEY_R1,
-       DKEY_L2,
-       DKEY_R2,
-};
-
-void hildon_quit()
-{
-       maemo_finish();
-       gtk_main_quit();
-       exit(0);
-}
-
-gdouble press_x = -1;
-gdouble press_y = -1;
-
-int maemo_x11_update_keys();
-void show_notification(char* text);
-
-void change_slot(int delta)
-{
-       state_slot += delta;
-       if (state_slot > 9)
-               state_slot = 0;
-       else if (state_slot < 0)
-               state_slot = 9;
-       char message[50];
-       sprintf(message,"Savestate slot: %i",state_slot + 1);
-       show_notification(message);
-}
-
-void save(int state_slot)
-{
-       emu_save_state(state_slot);
-       char buf[MAXPATHLEN];
-       if (image && image->mem){
-               sprintf (buf,"/opt/maemo/usr/games/screenshots%s.%3.3d",file_name,state_slot);
-               writepng(buf, image->mem, pl_buf_w,pl_buf_h);
-       }
-       char message[50];
-       sprintf(message,"Saved savestate slot: %i",state_slot + 1);
-       show_notification(message);
-}
-
-void quit()
-{
-       if (bAutosaveOnExit){
-               show_notification("Autosaving");
-               emu_save_state(99);
-               char buf[MAXPATHLEN];
-               if (image && image->mem){
-                       sprintf (buf,"/opt/maemo/usr/games/screenshots%s.%3.3d",file_name,99);
-                       writepng(buf, image->mem, pl_buf_w,pl_buf_h);
-               }
-       }
-       hildon_quit();
-}
-
-int show_confirmbox(char* text)
-{
-       if (!window)
-               return TRUE;
-
-       GtkWidget *dialog;
-       dialog = gtk_message_dialog_new (GTK_WINDOW(window),
-                                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                                        GTK_MESSAGE_QUESTION,
-                                                                        GTK_BUTTONS_YES_NO,
-                                                                        text);
-       gint result = gtk_dialog_run (GTK_DIALOG (dialog));
-       gtk_widget_destroy (dialog);
-       if (result == GTK_RESPONSE_YES)
-               return TRUE;
-       return FALSE;
-}
-
-static void
-window_button_proxy(GtkWidget *widget,
-                                   GdkEventButton *event,
-                                   gpointer user_data)
-{
-       int corner = -1;
-       int sens = 100;
-
-       switch (event->type){
-       case GDK_BUTTON_PRESS:
-               //printf("GDK_BUTTON_PRESS: x=%f y=%f\n", event->x, event->y);
-               press_x = event->x;
-               press_y = event->y;
-               break;
-       case GDK_BUTTON_RELEASE:
-               //printf("GDK_BUTTON_RELEASE: x=%f y=%f\n", event->x, event->y);
-               if (press_x < sens && press_y < sens && event->x < sens && event->y < sens)
-                       corner = 0;
-               else if (press_x > 800 - sens && press_y < sens && event->x > 800 - sens && event->y < sens)
-                       corner = 1;
-               else if (press_x > 800 - sens && press_y > 480 - sens && event->x > 800 - sens && event->y > 480 - sens)
-                       corner = 2;
-               else if (press_x < sens && press_y > 480 - sens && event->x < sens && event->y > 480 - sens)
-                       corner = 3;
-
-               press_x = -1;
-               press_y = -1;
-               break;
-       default:
-               break;
-       }
-
-       if (corner >= 0){
-               switch (cornerActions[corner]){
-                       case 1:
-                               if (show_confirmbox("Save savestate?"))
-                                       save(state_slot);
-                               break;
-                       case 2:
-                               if (show_confirmbox("Load savestate?"))
-                                       emu_load_state(state_slot);
-                               break;
-                       case 3:
-                               change_slot(1);
-                               break;
-                       case 4:
-                               change_slot(-1);
-                               break;
-                       case 5:
-                               if (show_confirmbox("Quit?"))
-                                       quit();
-                               break;
-               }
-       }
-}
-
-static void *displayThread(void *arg)
-{
-       DBusConnection* system_bus = (DBusConnection*)osso_get_sys_dbus_connection(osso);
-       DBusMessage* msg = dbus_message_new_method_call("com.nokia.mce",
-                                                                                                   "/com/nokia/mce/request",
-                                                                                                   "com.nokia.mce.request",
-                                                                                                   "req_display_blanking_pause");
-       if (msg && system_bus) {
-               bRunning = TRUE;
-               while (bRunning) {
-                       dbus_connection_send(system_bus, msg, NULL);
-                       dbus_connection_flush(system_bus);
-                       int i = 0;
-                       for (i=0; i<8; i++){
-                               usleep(500000);
-                               if (!bRunning)
-                                       break;
-                       }
-               }
-               dbus_message_unref(msg);
-       }
-
-       pthread_exit(0);
-       return NULL;
-}
-
-void show_notification(char* text)
-{
-       if (window){
-               GtkWidget* banner = hildon_banner_show_information(GTK_WIDGET(window), NULL, text);
-               hildon_banner_set_timeout(HILDON_BANNER(banner), 3000);
-       }else{
-               DBusConnection* session_bus = (DBusConnection*)osso_get_dbus_connection(osso);
-               DBusMessageIter args;
-               DBusMessage*msg = dbus_message_new_method_call("org.freedesktop.Notifications",
-                                                                                                          "/org/freedesktop/Notifications",
-                                                                                                          "org.freedesktop.Notifications",
-                                                                                                          "SystemNoteInfoprint");
-               if (msg) {
-                       dbus_message_iter_init_append(msg, &args);
-                       char* param = text;
-                       if (dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &param)) {
-                               dbus_connection_send(session_bus, msg, NULL);
-                               dbus_connection_flush(session_bus);
-                       }
-                       dbus_message_unref(msg);
-               }
-       }
-}
-
-void show_messagebox(char* text)
-{
-       if (!window)
-               return;
-
-       GtkWidget *dialog;
-       dialog = gtk_message_dialog_new (GTK_WINDOW(window),
-                                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                                        GTK_MESSAGE_INFO,
-                                                                        GTK_BUTTONS_OK,
-                                                                        text);
-       gtk_dialog_run (GTK_DIALOG (dialog));
-       gtk_widget_destroy (dialog);
-}
-
-#include <hildon/hildon-file-chooser-dialog.h>
-void change_disc()
-{
-       GtkWidget *dialog;
-       dialog = hildon_file_chooser_dialog_new (GTK_WINDOW(window), GTK_FILE_CHOOSER_ACTION_OPEN);
-    gtk_window_set_title (GTK_WINDOW (dialog), "Change disc");
-
-       char currentFile[MAXPATHLEN];
-       strcpy(currentFile, GetIsoFile());
-       if (strlen(currentFile))
-               gtk_file_chooser_set_filename (GTK_FILE_CHOOSER(dialog), currentFile);
-       else
-               gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(dialog), "/home/user/MyDocs/");
-
-       GtkFileFilter *filter=gtk_file_filter_new();
-       gtk_file_filter_add_pattern (filter,"*.bin");
-       gtk_file_filter_add_pattern (filter,"*.BIN");
-       gtk_file_filter_add_pattern (filter,"*.iso");
-       gtk_file_filter_add_pattern (filter,"*.ISO");
-       gtk_file_filter_add_pattern (filter,"*.img");
-       gtk_file_filter_add_pattern (filter,"*.IMG");
-       gtk_file_filter_add_pattern (filter,"*.z");
-       gtk_file_filter_add_pattern (filter,"*.Z");
-       gtk_file_filter_add_pattern (filter,"*.znx");
-       gtk_file_filter_add_pattern (filter,"*.ZNX");
-       gtk_file_filter_add_pattern (filter,"*.pbp");
-       gtk_file_filter_add_pattern (filter,"*.PBP");
-       gtk_file_filter_add_pattern (filter,"*.mdf");
-       gtk_file_filter_add_pattern (filter,"*.MDF");
-       gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog),filter);
-
-       if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
-               char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
-
-               //if (strcmp(filename, currentFile)) {
-                       CdromId[0] = '\0';
-                       CdromLabel[0] = '\0';
-
-                       set_cd_image(filename);
-                       if (ReloadCdromPlugin() < 0)
-                               printf("Failed to load cdr plugin\n");
-
-                       if (CDR_open() < 0)
-                               printf("Failed to open cdr plugin\n");
-
-                       strcpy(file_name, strrchr(filename,'/'));
-
-                       SetCdOpenCaseTime(time(NULL) + 3);
-                       LidInterrupt();
-               //}
-               g_free (filename);
-       }
-
-       gtk_widget_destroy (dialog);
-}
-
-void change_multi_disc()
-{
-    HildonDialog* window = HILDON_DIALOG(hildon_dialog_new());
-    gtk_window_set_title (GTK_WINDOW (window), "Change disc");
-    gtk_window_set_default_size(GTK_WINDOW (window), 480, 300);
-
-    GtkWidget* sw = hildon_pannable_area_new ();
-    gtk_box_pack_start (GTK_BOX(GTK_DIALOG(window)->vbox), sw, TRUE, TRUE, 0);
-
-    GtkWidget* tree_view = hildon_gtk_tree_view_new (HILDON_UI_MODE_EDIT);
-    gtk_widget_set_name (tree_view, "fremantle-widget");
-
-    gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
-
-    int i;
-    GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING);
-    for (i = 0; i < cdrIsoMultidiskCount; i++) {
-        gchar *str;
-
-        str = g_strdup_printf ("Disc %d", i+1);
-        gtk_list_store_insert_with_values (store, NULL, i, 0, str, -1);
-        g_free (str);
-    }
-    GtkTreeModel* model =  GTK_TREE_MODEL (store);
-
-    gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), model);
-    g_object_unref (model);
-
-    GtkTreeSelection* selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
-    gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
-
-    GtkCellRenderer* renderer = gtk_cell_renderer_text_new ();
-    g_object_set (renderer,
-                  "xalign", 0.5,
-                  "weight", PANGO_WEIGHT_NORMAL,
-                  NULL);
-
-    gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
-                                                 0, "Column 0",
-                                                 renderer,
-                                                 "text", 0,
-                                                 NULL);
-
-    char current[5];
-    sprintf(current, "%i", cdrIsoMultidiskSelect);
-    GtkTreePath* path = gtk_tree_path_new_from_string(current);
-    gtk_tree_selection_select_path (selection, path);
-    gtk_tree_path_free(path);
-
-    gtk_widget_set_size_request (tree_view, 480, 800);
-    gtk_container_add (GTK_CONTAINER (sw), tree_view);
-
-    hildon_dialog_add_button (HILDON_DIALOG(window), GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
-
-    gtk_widget_show_all (GTK_WIDGET(window));
-    gint result = gtk_dialog_run (GTK_DIALOG (window));
-    if (result == GTK_RESPONSE_ACCEPT) {
-      GtkTreeModel* model;
-      GtkTreeIter iter;
-      GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
-      if (gtk_tree_selection_get_selected(selection, &model, &iter)){
-           GtkTreePath* path = gtk_tree_model_get_path(model , &iter);
-               int* i = gtk_tree_path_get_indices(path) ;
-
-               cdrIsoMultidiskSelect = *i;
-               CdromId[0] = '\0';
-               CdromLabel[0] = '\0';
-
-               CDR_close();
-               if (CDR_open() < 0) {
-                       printf("Failed to load cdr plugin\n");
-                       return;
-               }
-
-               SetCdOpenCaseTime(time(NULL) + 3);
-               LidInterrupt();
-      }
-    }
-       gtk_widget_destroy(GTK_WIDGET(window));
-}
-
-static DBusHandlerResult on_msg_recieved(DBusConnection* connection G_GNUC_UNUSED, DBusMessage* message, void* data)
-{
-       const char* path = dbus_message_get_path(message);
-       if (path && g_str_equal(path, CALL_SIGNAL_PATH)){
-               const char* mbr = dbus_message_get_member(message);
-               if (mbr && g_str_equal(mbr, CALL_INCOMING_SIG))
-                       show_messagebox("Paused");
-       }
-
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-static void
-window_key_proxy(GtkWidget *widget,
-                    GdkEventKey *event,
-                    gpointer user_data)
-{
-       key_press_event(event->hardware_keycode, event->type == GDK_KEY_PRESS ? 1 : (event->type == GDK_KEY_RELEASE ? 2 : 0) );
-}
-
-int last_key_pressed = 0;
-inline void key_press_event(int key2,int type)
-{
-       int psxkey1 = -1, psxkey2 = -1;
-       int key=keymap[key2];
-
-       if (key < 0)
-               return;
-
-       if (type == 1 && key2 == last_key_pressed)
-               return;
-       last_key_pressed = type == 1 ? key2 : 0;
-
-       //printf("Key: %i %s\n", key2, type == 1 ? "Pressed" : (type == 2 ? "Released" : "Unknown"));
-       if (key < ARRAY_SIZE(keymap2)){
-               psxkey1 = keymap2[key];
-       }else switch (key) {
-               case 14:
-                       quit();
-                       break;
-               case 15:
-                       psxkey1 = DKEY_UP;
-                       psxkey2 = DKEY_LEFT;
-                       break;
-               case 16:
-                       psxkey1 = DKEY_UP;
-                       psxkey2 = DKEY_RIGHT;
-                       break;
-               case 17:
-                       psxkey1 = DKEY_DOWN;
-                       psxkey2 = DKEY_LEFT;
-                       break;
-               case 18:
-                       psxkey1 = DKEY_DOWN;
-                       psxkey2 = DKEY_RIGHT;
-                       break;
-               case 19:
-                       if (type == 1)
-                               save(state_slot);
-                       return;
-               case 20:
-                       if (type == 1)
-                               emu_load_state(state_slot);
-                       return;
-               case 21:
-                       if (type == 1)
-                               change_slot(1);
-                       return;
-               case 22:
-                       if (type == 1)
-                               change_slot(-1);
-                       return;
-               case 23:
-                       if (type == 1){
-                               if (cdrIsoMultidiskCount > 1)
-                                       change_multi_disc();
-                               else
-                                       change_disc();
-                       }
-                       return;
-       }
-
-       if (in_type1 == PSE_PAD_TYPE_GUNCON){
-               if (type == 1) {
-                       switch (psxkey1){
-                               case DKEY_CROSS:
-                                       in_state_gun |= SACTION_GUN_A;
-                                       break;          
-                               case DKEY_CIRCLE:
-                                       in_state_gun |= SACTION_GUN_B;
-                                       break;          
-                               case DKEY_TRIANGLE:
-                                       in_state_gun |= SACTION_GUN_TRIGGER2;
-                                       break;          
-                               case DKEY_SQUARE:
-                                       in_state_gun |= SACTION_GUN_TRIGGER;
-                                       break;          
-                       }
-               }else if (type == 2) {
-                       switch (psxkey1){
-                               case DKEY_CROSS:
-                                       in_state_gun &= ~SACTION_GUN_A;
-                                       break;          
-                               case DKEY_CIRCLE:
-                                       in_state_gun &= ~SACTION_GUN_B;
-                                       break;          
-                               case DKEY_TRIANGLE:
-                                       in_state_gun &= ~SACTION_GUN_TRIGGER2;
-                                       break;          
-                               case DKEY_SQUARE:
-                                       in_state_gun &= ~SACTION_GUN_TRIGGER;
-                                       break;          
-                       }
-               }
-       }else{
-               if (type == 1) {
-               if (psxkey1 >= 0)
-                       in_keystate |= 1 << psxkey1;
-               if (psxkey2 >= 0)
-                       in_keystate |= 1 << psxkey2;
-
-                       if (in_type1 == PSE_PAD_TYPE_ANALOGPAD){
-                               switch(psxkey1){
-                                       case DKEY_LEFT:
-                                               in_a1[0] = 0;
-                                               break;
-                                       case DKEY_RIGHT:
-                                               in_a1[0] = 255;
-                                               break;
-                                       case DKEY_UP:
-                                               in_a1[1] = 0;
-                                               break;
-                                       case DKEY_DOWN:
-                                               in_a1[1] = 255;
-                                               break;
-                               }
-       }
-               }
-               else if (type == 2) {
-               if (psxkey1 >= 0)
-                       in_keystate &= ~(1 << psxkey1);
-               if (psxkey2 >= 0)
-                       in_keystate &= ~(1 << psxkey2);
-
-                       if (in_type1 == PSE_PAD_TYPE_ANALOGPAD){
-                               switch(psxkey1){
-                                       case DKEY_LEFT:
-                                       case DKEY_RIGHT:
-                                               in_a1[0] = 127;
-                                               break;
-                                       case DKEY_UP:
-                                       case DKEY_DOWN:
-                                               in_a1[1] = 127;
-                                               break;
-                               }
-                       }
-               emu_set_action(SACTION_NONE);
-       }
-       }
-}
-
-void plat_finish()
-{
-       hildon_quit();
-}
-
-void set_accel_multipliers()
-{
-       accelOptions.xMultiplier = 255.0 / ( (accelOptions.maxValue - accelOptions.sens) * 2.0);
-       accelOptions.yMultiplier = 255.0 / ( (accelOptions.maxValue - accelOptions.sens) * 2.0);
-}
-
-#include <gdk/gdkx.h>
-int maemo_init(int *argc, char ***argv)
-{
-       osso = osso_initialize("pcsxrearmed", PACKAGE_VERSION, FALSE, NULL);
-
-       DBusConnection* system_bus = (DBusConnection*)osso_get_sys_dbus_connection(osso);
-    dbus_bus_add_match(system_bus, DBUS_RULE_CALL_INCOMING, NULL);
-       dbus_connection_add_filter(system_bus, on_msg_recieved, NULL, NULL);
-
-       FILE* pFile;
-       pFile = fopen(keys_config_file, "r");
-       if (pFile == NULL){
-               fprintf(stderr, "Error opening keys config file %s\n", keys_config_file);
-               return 1;
-       }
-       printf("Keys config read from %s\n", keys_config_file);
-
-       int ch;
-       int i=0;
-       for (i=0;i<65536;i++)
-               keymap[i]=-1;
-       if (NULL != pFile) {
-               for(i=0;i<24;i++){
-                       fscanf(pFile, "%i",&ch);
-                       keymap[ch]=i;
-                       if (i < 4)
-                               direction_keys[i] = ch;
-               }
-               fclose(pFile);
-       }
-       
-       switch (in_type1){
-               case PSE_PAD_TYPE_GUNCON:
-                       memset(cornerActions, 0, sizeof(cornerActions));
-                       printf("Controller set to GUNCON (SLPH-00034)\n");
-                       break;
-               case PSE_PAD_TYPE_STANDARD:
-                       printf("Controller set to standard (SCPH-1080)\n");
-                       break;
-               case PSE_PAD_TYPE_ANALOGPAD:
-                       printf("Controller set to analog (SCPH-1150)\n");
-                       break;  
-       }
-
-       if (in_enable_vibration)
-               printf("Vibration enabled\n");
-
-       if (!(g_maemo_opts&8)){
-       gtk_init (argc, argv);
-
-       window = hildon_stackable_window_new ();
-       gtk_widget_realize (window);
-       gtk_window_fullscreen (GTK_WINDOW(window));
-
-               if (cornerActions[0] + cornerActions[1] + cornerActions[2] + cornerActions[3] > 0){
-                       g_signal_connect (G_OBJECT (window), "button_release_event",
-                                               G_CALLBACK (window_button_proxy), NULL);
-                       g_signal_connect (G_OBJECT (window), "button_press_event",
-                                               G_CALLBACK (window_button_proxy), NULL);
-               }
-
-       g_signal_connect (G_OBJECT (window), "key-press-event",
-                               G_CALLBACK (window_key_proxy), NULL);
-       g_signal_connect (G_OBJECT (window), "key-release-event",
-                               G_CALLBACK (window_key_proxy), NULL);
-       g_signal_connect (G_OBJECT (window), "delete_event",
-                               G_CALLBACK (hildon_quit), NULL);
-       gtk_widget_add_events (window,
-                               GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
-
-       actor = HILDON_ANIMATION_ACTOR (hildon_animation_actor_new());
-       if (g_maemo_opts & 2)
-               hildon_animation_actor_set_position (actor, 0, 0 );
-       else
-               hildon_animation_actor_set_position (actor, (X_RES - D_WIDTH)/2, (Y_RES - D_HEIGHT)/2 );
-       hildon_animation_actor_set_parent (actor, GTK_WINDOW (window));
-
-       drawing = gtk_image_new ();
-
-       gtk_container_add (GTK_CONTAINER (actor), drawing);
-
-       gtk_widget_show_all (GTK_WIDGET (actor));
-       gtk_widget_show_all (GTK_WIDGET (window));
-       }else{
-               gtk_init (argc, argv);
-               /*GdkScreen* scr = gdk_screen_get_default();
-               window = GTK_WIDGET(gdk_screen_get_root_window(scr));
-               if (!window)
-                       window = GTK_WIDGET(gdk_get_default_root_window());*/
-       }
-
-       set_accel_multipliers();
-
-       if (bKeepDisplayOn){
-               if (pthread_create(&display_thread, NULL, displayThread, NULL))
-                       printf("Failed to create display thread.\n");           
-       }
-
-       pl_rearmed_cbs.only_16bpp = 1;
-       return 0;
-}
-
-void maemo_finish()
-{
-       if (display_thread > 0){
-               bRunning = FALSE;
-               pthread_join(display_thread, NULL);
-       }
-
-       if (osso){
-               osso_deinitialize(osso);
-               osso = NULL;
-       }
-       printf("Exiting\n");
-}
-
-void menu_loop(void)
-{
-}
-
-void *plat_gvideo_set_mode(int *w_, int *h_, int *bpp_)
-{
-       int w = *w_, h = *h_;
-
-       if (g_maemo_opts&8) return pl_vout_buf;
-       //printf("Setting video mode %ix%i\n", w, h);
-
-       if (w <= 0 || h <= 0)
-               return pl_vout_buf;
-
-       if (image) gdk_image_destroy(image);
-       image = gdk_image_new( GDK_IMAGE_FASTEST, gdk_visual_get_system(), w, h );
-
-       pl_vout_buf = (void *) image->mem;
-
-       gtk_image_set_from_image (GTK_IMAGE(drawing), image, NULL);
-
-       gtk_window_resize (GTK_WINDOW (actor), w, h);
-       if (g_maemo_opts & 2)
-               hildon_animation_actor_set_scale (actor,
-                               (gdouble)800 / (gdouble)w,
-                               (gdouble)480 / (gdouble)h
-                               );
-       else
-               hildon_animation_actor_set_scale (actor,
-                               (gdouble)D_WIDTH / (gdouble)w,
-                               (gdouble)D_HEIGHT / (gdouble)h
-                               );
-       pl_buf_w=w;pl_buf_h=h;
-       return pl_vout_buf;
-}
-
-void *plat_gvideo_flip(void)
-{
-       if (!(g_maemo_opts&8))
-               gtk_widget_queue_draw(drawing);
-
-       // process accelometer
-       if (g_maemo_opts & 4) {
-               float x, y, z;
-               FILE* f = fopen( "/sys/class/i2c-adapter/i2c-3/3-001d/coord", "r" );
-               if( !f ) {printf ("err in accel"); exit(1);}
-               fscanf( f, "%f %f %f", &x, &y, &z );
-               fclose( f );
-
-               if (in_type1 == PSE_PAD_TYPE_ANALOGPAD){
-                       if (x > accelOptions.maxValue) x = accelOptions.maxValue;
-                       else if (x < -accelOptions.maxValue) x = -accelOptions.maxValue;
-
-                       const int maxValue = accelOptions.maxValue - accelOptions.sens;
-                       if(x > accelOptions.sens){
-                               x -= accelOptions.sens;
-                               in_a1[0] = (-x + maxValue ) *  accelOptions.xMultiplier;
-                       }else if (x < -accelOptions.sens){
-                               x += accelOptions.sens;
-                               in_a1[0] = (-x + maxValue ) *  accelOptions.xMultiplier;
-                       }else in_a1[0] = 127;
-
-                       y += accelOptions.y_def;
-                       if (y > accelOptions.maxValue) y = accelOptions.maxValue;
-                       else if (y < -accelOptions.maxValue) y = -accelOptions.maxValue;
-
-                       if(y > accelOptions.sens){
-                               y -= accelOptions.sens;
-                               in_a1[1] = (-y + maxValue ) *  accelOptions.yMultiplier;
-                       }else if (y < -accelOptions.sens){
-                               y += accelOptions.sens;
-                               in_a1[1] = (-y + maxValue ) *  accelOptions.yMultiplier;
-                       }else in_a1[1] = 127;
-
-                       //printf("x: %i y: %i\n", in_a1[0], in_a1[1]);
-               }else{
-                       if( x > accelOptions.sens ) in_keystate |= 1 << DKEY_LEFT;
-                       else if( x < -accelOptions.sens ) in_keystate |= 1 << DKEY_RIGHT;
-               else {in_keystate &= ~(1 << DKEY_LEFT);in_keystate &= ~(1 << DKEY_RIGHT);}
-
-                       y += accelOptions.y_def;
-                       if( y > accelOptions.sens )in_keystate |= 1 << DKEY_UP;
-                       else if( y < -accelOptions.sens ) in_keystate |= 1 << DKEY_DOWN;
-               else {in_keystate &= ~(1 << DKEY_DOWN);in_keystate &= ~(1 << DKEY_UP);}
-               }
-       }
-
-       return pl_vout_buf;
-}
-
-// for frontend/plugin_lib.c
-void update_input(void)
-{
-       if (g_maemo_opts & 8)
-               maemo_x11_update_keys();
-       else {
-               /* process GTK+ events */
-               while (gtk_events_pending())
-                       gtk_main_iteration();
-       }
-}
-
-int omap_enable_layer(int enabled)
-{
-       return 0;
-}
-
-void menu_notify_mode_change(int w, int h, int bpp)
-{
-}
-
-void *plat_prepare_screenshot(int *w, int *h, int *bpp)
-{
-       return NULL;
-}
-
-void plat_step_volume(int is_up)
-{
-}
-
-void plat_trigger_vibrate(int pad, int low, int high)
-{
-       const int vDuration = 10;
-
-       DBusConnection* system_bus = (DBusConnection*)osso_get_sys_dbus_connection(osso);
-       DBusMessageIter args;
-       DBusMessage*msg = dbus_message_new_method_call("com.nokia.mce",
-                                                                                                  "/com/nokia/mce/request",
-                                                                                                  "com.nokia.mce.request",
-                                                                                                  "req_start_manual_vibration");
-       if (msg) {
-               dbus_message_iter_init_append(msg, &args);
-               // FIXME: somebody with hardware should tune this
-               int speed = high; // is_strong ? 200 : 150;
-               int duration = vDuration;
-               if (dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &speed)) {
-                       if (dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &duration)) {
-                               dbus_connection_send(system_bus, msg, NULL);
-                               //dbus_connection_flush(system_bus);
-                       }
-               }
-               dbus_message_unref(msg);
-       }
-}
-
-void plat_minimize(void)
-{
-}
-
-void plat_gvideo_close(void)
-{
-}
-
-void plat_gvideo_open(int is_pal)
-{
-}
diff --git a/maemo/maemo_common.h b/maemo/maemo_common.h
deleted file mode 100644 (file)
index ace0bfd..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-int maemo_init(int *argc, char ***argv);
-void maemo_finish();
-
-extern char file_name[MAXPATHLEN];
-extern int g_maemo_opts;
-
-extern inline void key_press_event(int key,int type);
-
-typedef struct
-{ 
-       int sens;
-       int y_def;
-       float maxValue;
-       float xMultiplier;
-       float yMultiplier;
-} accel_option;
-
-extern accel_option accelOptions;
diff --git a/maemo/maemo_xkb.c b/maemo/maemo_xkb.c
deleted file mode 100644 (file)
index 52af2ca..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/keysym.h>
-#include <X11/XKBlib.h>
-
-#include "../frontend/main.h"
-#include "../frontend/plugin_lib.h"
-
-static Atom wmprotocols, wmdelwindow;
-static int initialized;
-
-
-
-static void InitKeyboard(void) {
-       Display *disp = (Display *)gpuDisp;
-       if (disp){
-               wmprotocols = XInternAtom(disp, "WM_PROTOCOLS", 0);
-               wmdelwindow = XInternAtom(disp, "WM_DELETE_WINDOW", 0);
-               XkbSetDetectableAutoRepeat(disp, 1, NULL);
-       }
-}
-
-static void DestroyKeyboard(void) {
-       Display *disp = (Display *)gpuDisp;
-       if (disp)
-               XkbSetDetectableAutoRepeat(disp, 0, NULL);
-}
-#include "maemo_common.h"
-
-int maemo_x11_update_keys() {
-
-       XEvent                                  evt;
-       XClientMessageEvent             *xce;
-       int leave = 0;
-       Display *disp = (Display *)gpuDisp;
-       
-       if (!disp)
-               return 0;
-               
-       if (!initialized) {
-               initialized++;
-               InitKeyboard();
-       }
-
-       while (XPending(disp)>0) {
-               XNextEvent(disp, &evt);
-               switch (evt.type) {
-                       case KeyPress:
-                       case KeyRelease:
-                               key_press_event(evt.xkey.keycode, evt.type==KeyPress ? 1 : (evt.type==KeyRelease ? 2 : 0) );
-                               break;
-
-                       case ClientMessage:
-                               xce = (XClientMessageEvent *)&evt;
-                               if (xce->message_type == wmprotocols && (Atom)xce->data.l[0] == wmdelwindow)
-                                       leave = 1;
-                               break;
-               }
-       }
-
-       if (leave) {
-               DestroyKeyboard();
-               exit(1);
-       }
-
-       return 0;
-}
diff --git a/maemo/main.c b/maemo/main.c
deleted file mode 100644 (file)
index 85db400..0000000
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- * (C) notaz, 2010-2011
- *
- * This work is licensed under the terms of the GNU GPLv2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <unistd.h>
-
-#include "../frontend/main.h"
-#include "../frontend/menu.h"
-#include "../frontend/plugin.h"
-#include "../frontend/plugin_lib.h"
-#include "../libpcsxcore/misc.h"
-#include "../libpcsxcore/cdriso.h"
-#include "../libpcsxcore/new_dynarec/new_dynarec.h"
-#include "../plugins/dfinput/main.h"
-#include "../plugins/dfsound/spu_config.h"
-#include "maemo_common.h"
-
-extern int in_enable_vibration;
-extern int cycle_multiplier;
-extern int in_type1, in_type2;
-
-accel_option accelOptions;
-int ready_to_go, g_emu_want_quit, g_emu_resetting;
-int g_menuscreen_w, g_menuscreen_h;
-int g_scaler, soft_filter;
-int g_opts = 0;
-int g_maemo_opts;
-int cornerActions[4] = {0,0,0,0};
-int bKeepDisplayOn = FALSE;
-int bAutosaveOnExit = FALSE;
-char file_name[MAXPATHLEN];
-char keys_config_file[MAXPATHLEN] = "/opt/psx4m/keys";
-
-enum sched_action emu_action;
-void do_emu_action(void);
-
-static void ChangeWorkingDirectory(char *exe)
-{
-       char exepath[1024];
-       char *s;
-       snprintf(exepath, sizeof(exepath), "%s", exe);
-       s = strrchr(exepath, '/');
-       if (s != NULL) {
-               *s = '\0';
-               chdir(exepath);
-       }
-}
-
-void PrintHelp()
-{
-       printf("PCSX-ReARMed version %s for Maemo\n\n", PACKAGE_VERSION);
-
-       printf("Usage:\n");
-       printf("  pcsx [options] -cdfile FILE\n\n");
-
-       printf("Options:\n");
-       printf("  -help          : This help\n");
-       printf("  -disc VALUE    : Disc number for multi discs images\n");
-       printf("  -fullscreen    : Run fullscreen\n");
-       printf("  -frameskip     : Frameskip\n");
-       printf("                   -1=Auto (Default)\n");
-       printf("                    0=Disabled\n");
-       printf("                    1=Set to 1\n");
-       printf("                    ...\n");
-       printf("  -autosave      : Enable auto save on exit\n");
-       printf("  -accel         : Enable accelerometer\n");
-       printf("  -analog        : Use analog pad for accel\n");
-       printf("  -vibration     : Activate vibration\n");
-       printf("  -sens VALUE    : Set accelerometer sens [0-1000]\n");
-    printf("                   (Default 150)\n");
-       printf("  -ydef VALUE    : Set accelerometer y zero [0-1000]\n");
-    printf("                   (Default 500)\n");
-       printf("  -max VALUE     : Set accelerometer max value[0-1000]\n");
-    printf("                   (Default 500)\n");
-       printf("  -nosound       : No sound output\n");
-       printf("  -bdir PATH     : Set the bios path\n");
-       printf("  -pdir PATH     : Set the plugins path\n");
-       printf("  -bios          : Set the bios\n");
-       printf("  -cdda          : Disable CD Audio for a performance boost\n");
-       printf("  -xa            : Disables XA sound, which can sometimes\n");
-       printf("                   improve performance\n");
-       printf("  -sio           : SIO IRQ Always Enabled\n");
-       printf("  -spuirq        : SPU IRQ Always Enabled\n");
-       printf("  -fps           : Show fps\n");
-       printf("  -cpu           : Show CPU load\n");
-       printf("  -spu           : Show SPU channels\n");
-       printf("  -nofl          : Disable Frame Limiter\n");
-       printf("  -mcd1 FILE     : Set memory card 1 file\n");
-       printf("  -mcd2 FILE     : Set memory card 2 file\n");
-       printf("  -region VALUE  : Set PSX region\n");
-       printf("                   -1=Auto (Default)\n");
-       printf("                    0=NTSC\n");
-       printf("                    1=PAL\n");
-       printf("  -cpuclock VALUE: PSX CPU clock %% [1-500]\n");
-    printf("                   (Default 50)\n");
-       printf("  -displayon     : Prevent display from blanking\n");
-    printf("                   (Default disabled)\n");
-       printf("  -keys FILE     : File with keys configuration\n");
-    printf("                   (Default /opt/psx4m/keys)\n");
-       printf("  -corners VALUE : Define actions for click on the\n");
-    printf("                   display corners\n");
-    printf("                   VALUE is a four digit number, each number\n");
-    printf("                   represent a corner (topleft, topright,\n");
-    printf("                   bottomright and bottomleft\n");
-    printf("                   Actions:\n");
-    printf("                   0=No action\n");
-    printf("                   1=Save\n");
-    printf("                   2=Load\n");
-    printf("                   3=Change slot (+1)\n");
-    printf("                   4=Change slot (-1)\n");
-    printf("                   5=Quit\n");
-       printf("  -guncon        : Set the controller to guncon\n");
-       printf("  -gunnotrigger  : Don't trigger (shoot) when touching screen\n");
-    printf("                   0=Auto (Default)\n");
-    printf("                   1=On\n");
-    printf("                   2=Off\n");
-
-
-       printf("\nGPU Options:\n");
-       printf("  -gles          : Use the GLES plugin (gpu_gles.so)\n");
-       printf("  -oldgpu        : Use the peops plugin (gpu_peops.so)\n");
-       printf("  -unai          : Use the unai plugin (gpu_unai.so)\n");
-
-       printf("\nSound Options:\n");
-       printf("  -spu_reverb VALUE        : Enable/disable reverb [0/1]\n");
-    printf("                             (Default disabled)\n");
-       printf("  -spu_interpolation VALUE : Set interpolation mode\n");
-       printf("                             0=None (Default)\n");
-    printf("                             1=Simple\n");
-       printf("                             2=Gaussian\n");
-       printf("                             3=Cubic\n");
-
-       printf("\nNeon Options (default GPU):\n");
-       printf("  -enhance       : Enable graphic enhancement\n");
-
-       printf("\nGles Options:\n");
-       printf("  -gles_dithering VALUE : Enable/disable dithering [0/1]\n");
-    printf("                          (Default disabled)\n");
-       printf("  -gles_mask VALUE      : Enable/disable mask detect [0/1]\n");
-    printf("                          (Default disabled)\n");
-       printf("  -gles_filtering VALUE : Texture Filtering\n");
-       printf("                          0=None (Default)\n");
-       printf("                          1=Standard\n");
-       printf("                          2=Extended\n");
-       printf("                          3=Standard-sprites\n");
-       printf("                          4=Extended-sprites\n");
-       printf("                          5=Standard+sprites\n");
-       printf("                          6=Extended+sprites\n");
-       printf("  -gles_fbtex VALUE     : Framebuffer Textures\n");
-       printf("                          0=Emulated VRam (Default)\n");
-       printf("                          1=Black\n");
-       printf("                          2=Card\n");
-       printf("                          3=Card+soft\n");
-       printf("  -gles_vram VALUE      : Texture RAM size in MB [4-128]\n");
-    printf("                          (Default 64)\n");
-    printf("  -gles_fastmdec VALUE  : Enable/disable Fast Mdec [0/1]\n");
-    printf("                          (Default disabled)\n");
-    printf("  -gles_advblend VALUE  : Enable/disable Adv. Blend [0/1]\n");
-    printf("                          (Default disabled)\n");
-    printf("  -gles_opaque VALUE    : Enable/disable Opaque Pass [0/1]\n");
-    printf("                          (Default disabled)\n");
-}
-
-int main(int argc, char **argv)
-{
-       if (argc == 1 || (argc == 2 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-help") || !strcmp(argv[1], "-h")))) {
-               PrintHelp();
-               return 0;
-       }
-
-       emu_core_preinit();
-       ChangeWorkingDirectory("c");
-       char file[MAXPATHLEN] = "";
-       char path[MAXPATHLEN];
-       const char *cdfile = NULL;
-       int loadst = 0;
-       int i;
-       int getst = -1;
-       int discNumber = 0;
-
-       g_menuscreen_w = 800;
-       g_menuscreen_h = 480;
-
-       strcpy(Config.Gpu, "builtin_gpu");
-       strcpy(Config.Spu, "builtin_spu");
-       strcpy(Config.BiosDir, "/home/user/MyDocs");
-       strcpy(Config.PluginsDir, "/opt/maemo/usr/games/plugins");
-       snprintf(Config.PatchesDir, sizeof(Config.PatchesDir), "/opt/maemo/usr/games" PATCHES_DIR);
-       Config.PsxAuto = 1;
-       pl_rearmed_cbs.frameskip = -1;
-       strcpy(Config.Bios, "HLE");
-       spu_config.iUseReverb = 1;
-       spu_config.iUseInterpolation = 1;
-
-       in_type1 = PSE_PAD_TYPE_STANDARD;
-       in_type2 = PSE_PAD_TYPE_STANDARD;
-
-       accelOptions.sens     = 150;
-       accelOptions.y_def        = 500;
-       accelOptions.maxValue = 500.0;
-
-       // read command line options
-       for (i = 1; i < argc; i++) {
-                    if (!strcmp(argv[i], "-psxout")) Config.PsxOut = 1;
-               else if (!strcmp(argv[i], "-load")) loadst = atol(argv[++i]);
-               else if (!strcmp(argv[i], "-cdfile")) {
-                       char isofilename[MAXPATHLEN];
-                       if (i+1 >= argc) break;
-                       strncpy(isofilename, argv[++i], MAXPATHLEN);
-                       if (isofilename[0] != '/') {
-                               getcwd(path, MAXPATHLEN);
-                               if (strlen(path) + strlen(isofilename) + 1 < MAXPATHLEN) {
-                                       strcat(path, "/");
-                                       strcat(path, isofilename);
-                                       strcpy(isofilename, path);
-                               } else
-                                       isofilename[0] = 0;
-                       }
-                       cdfile = isofilename;
-               }
-               else if (!strcmp(argv[i],"-frameskip")) {
-                       int tv_reg = atol(argv[++i]);
-                       if (tv_reg < -1)
-                               pl_rearmed_cbs.frameskip = -1;
-                       else
-                               pl_rearmed_cbs.frameskip = tv_reg;
-               }
-               else if (!strcmp(argv[i],"-region")) {
-                       int psx_reg = atol(argv[++i]);
-                       if (psx_reg == 0 || psx_reg == 1){
-                               Config.PsxAuto = 0;
-                               Config.PsxType = psx_reg;
-                       }
-               }
-
-               else if (!strcmp(argv[i],"-get_sstatename")) getst = atol(argv[++i]);
-
-               else if (!strcmp(argv[i], "-fullscreen"))               g_maemo_opts |= 2;
-               else if (!strcmp(argv[i], "-accel"))                            g_maemo_opts |= 4;
-               else if (!strcmp(argv[i], "-nosound"))                  strcpy(Config.Spu, "spunull.so");
-               else if (!strcmp(argv[i], "-bdir"))                     sprintf(Config.BiosDir, "%s", argv[++i]);
-               else if (!strcmp(argv[i], "-pdir"))                             sprintf(Config.PluginsDir, "%s", argv[++i]);
-               else if (!strcmp(argv[i], "-bios"))                     sprintf(Config.Bios, "%s", argv[++i]);
-               else if (!strcmp(argv[i], "-gles"))                             { strcpy(Config.Gpu, "gpu_gles.so"); g_maemo_opts |= 8 ;}
-               else if (!strcmp(argv[i], "-oldgpu"))                   strcpy(Config.Gpu, "gpu_peops.so");
-               else if (!strcmp(argv[i], "-unai"))                         strcpy(Config.Gpu, "gpu_unai.so");
-               else if (!strcmp(argv[i], "-cdda"))             Config.Cdda = 1;
-               else if (!strcmp(argv[i], "-xa"))               Config.Xa = 1;
-               else if (!strcmp(argv[i], "-rcnt"))             Config.RCntFix = 1 ;
-               else if (!strcmp(argv[i], "-sio"))              Config.Sio = 1;
-               else if (!strcmp(argv[i], "-spuirq"))   Config.SpuIrq = 1;
-               else if (!strcmp(argv[i], "-vsync"))    Config.VSyncWA = 1;
-               else if (!strcmp(argv[i], "-fps"))                          g_opts |=OPT_SHOWFPS;
-               else if (!strcmp(argv[i], "-cpu"))                          g_opts |=OPT_SHOWCPU;
-               else if (!strcmp(argv[i], "-spu"))                          g_opts |=OPT_SHOWSPU;
-               else if (!strcmp(argv[i], "-nofl"))                     g_opts |=OPT_NO_FRAMELIM;
-               else if (!strcmp(argv[i], "-mcd1"))                 sprintf(Config.Mcd1, "%s", argv[++i]);
-               else if (!strcmp(argv[i], "-mcd2"))                 sprintf(Config.Mcd2, "%s", argv[++i]);
-
-               else if (!strcmp(argv[i], "-cpuclock"))                 cycle_multiplier = 10000 / atol(argv[++i]);
-               else if (!strcmp(argv[i], "-guncon"))               in_type1 = PSE_PAD_TYPE_GUNCON;
-               else if (!strcmp(argv[i], "-gunnotrigger"))             g_opts |= OPT_TSGUN_NOTRIGGER;
-               else if (!strcmp(argv[i], "-analog"))               in_type1 = PSE_PAD_TYPE_ANALOGPAD;
-               else if (!strcmp(argv[i], "-vibration"))                { in_type1 = PSE_PAD_TYPE_ANALOGPAD; in_enable_vibration = 1; }
-               else if (!strcmp(argv[i], "-sens"))                             accelOptions.sens = atol(argv[++i]);
-               else if (!strcmp(argv[i], "-ydef"))                             accelOptions.y_def = atol(argv[++i]);
-               else if (!strcmp(argv[i], "-max"))                                  accelOptions.maxValue = atol(argv[++i]);
-               else if (!strcmp(argv[i], "-displayon"))                    bKeepDisplayOn = TRUE;
-               else if (!strcmp(argv[i], "-keys"))                             sprintf(keys_config_file, "%s", argv[++i]);
-               else if (!strcmp(argv[i], "-autosave"))                     bAutosaveOnExit = TRUE;
-               else if (!strcmp(argv[i], "-disc"))                     discNumber = atol(argv[++i]);
-               else if (!strcmp(argv[i], "-corners")){
-                       int j = 0;
-                       i++;
-                       char num[2];
-                       for (j=0; j<strlen(argv[i]); j++){
-                               strncpy(num, argv[i] + j, 1);
-                               cornerActions[j] = atoi(num);
-                       }
-       }
-
-               else if (!strcmp(argv[i], "-spu_reverb"))               spu_config.iUseReverb = atol(argv[++i]);
-               else if (!strcmp(argv[i], "-spu_interpolation"))        spu_config.iUseInterpolation = atol(argv[++i]);
-
-               else if (!strcmp(argv[i], "-enhance"))                  pl_rearmed_cbs.gpu_neon.enhancement_enable = 1;
-               else if (!strcmp(argv[i], "-enhancehack"))              pl_rearmed_cbs.gpu_neon.enhancement_no_main = 1;
-
-               else if (!strcmp(argv[i], "-gles_dithering"))   pl_rearmed_cbs.gpu_peopsgl.bDrawDither = atol(argv[++i]);
-               else if (!strcmp(argv[i], "-gles_mask"))            pl_rearmed_cbs.gpu_peopsgl.iUseMask = atol(argv[++i]);
-               else if (!strcmp(argv[i], "-gles_filtering"))   pl_rearmed_cbs.gpu_peopsgl.iFilterType = atol(argv[++i]);
-               else if (!strcmp(argv[i], "-gles_fbtex"))           pl_rearmed_cbs.gpu_peopsgl.iFrameTexType = atol(argv[++i]);
-               else if (!strcmp(argv[i], "-gles_vram"))            pl_rearmed_cbs.gpu_peopsgl.iVRamSize = atol(argv[++i]);
-               else if (!strcmp(argv[i], "-gles_fastmdec"))    pl_rearmed_cbs.gpu_peopsgl.bUseFastMdec = atol(argv[++i]);
-        else if (!strcmp(argv[i], "-gles_advblend"))   pl_rearmed_cbs.gpu_peopsgl.bAdvancedBlend = atol(argv[++i]);
-        else if (!strcmp(argv[i], "-gles_opaque"))         pl_rearmed_cbs.gpu_peopsgl.bOpaquePass = atol(argv[++i]);
-
-               else {
-                       fprintf(stderr, "Unknown option: %s\n", argv[i]);
-                       return 1;
-               }
-       }
-       
-       pl_init();
-       if (emu_core_init() == -1)
-               return 1;
-       
-       if (cdfile) {
-               set_cd_image(cdfile);
-               strcpy(file_name, strrchr(cdfile,'/'));
-       }
-
-       if (LoadPlugins() == -1) {
-               SysMessage("Failed loading plugins!");
-               return 1;
-       }
-
-       if (discNumber > 0)
-               cdrIsoMultidiskSelect = discNumber - 1;
-
-       if (OpenPlugins() == -1) {
-               return 1;
-       }
-       plugin_call_rearmed_cbs();
-
-       CheckCdrom();
-
-       if (getst >= 0){
-               char fname[MAXPATHLEN];
-
-               get_state_filename(fname, sizeof(fname), getst);
-               printf("SAVESTATE: %s\n", fname);
-               if (cdrIsoMultidiskCount > 1){
-                       int i = 0;
-                       for (i=1; i<cdrIsoMultidiskCount; i++){
-                               cdrIsoMultidiskSelect = i;
-                               CdromId[0] = '\0';
-                               CdromLabel[0] = '\0';
-
-                               CDR_close();
-                               if (CDR_open() == 0){
-                                       CheckCdrom();
-                                       get_state_filename(fname, sizeof(fname), getst);
-                                       printf("SAVESTATE: %s\n", fname);
-                               }
-                       }
-               }
-               return 0;
-       }
-
-       SysReset();
-
-       if (file[0] != '\0') {
-               if (Load(file) != -1)
-                       ready_to_go = 1;
-       } else {
-               if (cdfile) {
-                       if (LoadCdrom() == -1) {
-                               ClosePlugins();
-                               printf(_("Could not load CD-ROM!\n"));
-                               return -1;
-                       }
-                       emu_on_new_cd(0);
-                       ready_to_go = 1;
-               }
-       }
-
-       if (!ready_to_go) {
-               printf ("something goes wrong, maybe you forgot -cdfile ? \n");
-               return 1;
-       }
-
-       if (cdrIsoMultidiskCount > 1)
-               printf ("Loaded a multidisc image: %i discs.\n", cdrIsoMultidiskCount);
-
-       // If a state has been specified, then load that
-       if (loadst) {
-               int ret = emu_load_state(loadst - 1);
-               printf("%s state %d\n", ret ? "Failed to load" : "Loaded", loadst);
-               state_slot = loadst - 1;
-       }
-
-       if (maemo_init(&argc, &argv))
-               return 1;
-
-       if (GPU_open != NULL) {
-               int ret = GPU_open(&gpuDisp, "PCSX", NULL);
-               if (ret){
-                       fprintf(stderr, "Warning: GPU_open returned %d\n", ret);
-                       gpuDisp=ret;
-               }
-       }
-
-       if (Config.HLE)
-               printf("Note: running without BIOS, expect compatibility problems\n");
-
-       dfinput_activate();
-       pl_timing_prepare(Config.PsxType);
-
-       while (1)
-       {
-               stop = 0;
-               emu_action = SACTION_NONE;
-
-               psxCpu->Execute();
-               if (emu_action != SACTION_NONE)
-                       do_emu_action();
-       }
-
-       maemo_finish();
-       return 0;
-}
-
index 76cdfba..45016bb 100644 (file)
@@ -14,7 +14,9 @@
 #include <zlib.h>
 #ifndef _WIN32
 #define CALLBACK
+#ifndef NO_DYLIB
 #include <dlfcn.h>
+#endif
 #else
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
@@ -98,7 +100,7 @@ static long CDRgetTD(unsigned char track, unsigned char *buffer)
        return 0;
 }
 
-int uncompress2(void *out, unsigned long *out_size, void *in, unsigned long in_size)
+int uncomp2(void *out, unsigned long *out_size, void *in, unsigned long in_size)
 {
        static z_stream z;
        int ret = 0;
@@ -199,7 +201,7 @@ static long CDRreadTrack(unsigned char *time)
                ret = uncompress(cdbuffer->raw[0], &cdbuffer_size, cdbuffer->compressed, size);
                break;
        case CDRC_ZLIB2:
-               ret = uncompress2(cdbuffer->raw[0], &cdbuffer_size, cdbuffer->compressed, size);
+               ret = uncomp2(cdbuffer->raw[0], &cdbuffer_size, cdbuffer->compressed, size);
                break;
        case CDRC_BZ:
                ret = pBZ2_bzBuffToBuffDecompress((char *)cdbuffer->raw, (unsigned int *)&cdbuffer_size,
@@ -285,7 +287,7 @@ static long CDRinit(void)
                        return -1;
                }
        }
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(NO_DYLIB)
        if (pBZ2_bzBuffToBuffDecompress == NULL) {
                void *h = dlopen("/usr/lib/libbz2.so.1", RTLD_LAZY);
                if (h == NULL)
index 475ea07..4204b86 100644 (file)
@@ -44,6 +44,7 @@ static int old_controller_type1 = -1, old_controller_type2 = -1;
                        PAD##n##_poll = PADpoll_guncon; \
                        guncon_init(); \
                        break; \
+                case PSE_PAD_TYPE_NEGCON: \
                case PSE_PAD_TYPE_GUN: \
                default: \
                        PAD##n##_startPoll = PAD##n##__startPoll; \
@@ -52,13 +53,19 @@ static int old_controller_type1 = -1, old_controller_type2 = -1;
                } \
        }
 
+
 void dfinput_activate(void)
 {
+       #ifndef HAVE_LIBRETRO
        PadDataS pad;
 
+       pad.portMultitap = -1;
+       pad.requestPadIndex = 0;
        PAD1_readPort1(&pad);
        select_pad(1);
 
+       pad.requestPadIndex = 1;
        PAD2_readPort2(&pad);
        select_pad(2);
+       #endif
 }
index 7e00a11..853c8c8 100644 (file)
@@ -254,6 +254,7 @@ unsigned char PADpoll(unsigned char value) {
 #define PADpoll PADpoll_
 #endif
 
+#ifndef HAVE_LIBRETRO
 unsigned char PADpoll_pad(unsigned char value) {
        if (CurByte == 0) {
                CurCmd = value;
@@ -302,3 +303,4 @@ void pad_init(void)
                padstate[i].PadMode = padstate[i].pad.controllerType == PSE_PAD_TYPE_ANALOGPAD;
        }
 }
+#endif
index 01b8dde..bb3ad56 100644 (file)
@@ -309,11 +309,11 @@ void renderer_notify_res_change(void)
 
 extern const unsigned char cmd_lengths[256];
 
-int do_cmd_list(unsigned int *list, int list_len, int *last_cmd)
+int do_cmd_list(uint32_t *list, int list_len, int *last_cmd)
 {
   unsigned int cmd = 0, len;
-  unsigned int *list_start = list;
-  unsigned int *list_end = list + list_len;
+  uint32_t *list_start = list;
+  uint32_t *list_end = list + list_len;
 
   for (; list < list_end; list += 1 + len)
   {