endif
ifeq "$(PLATFORM)" "libretro"
OBJS += platform/libretro/libretro.o
-ifeq "$(USE_LIBRETRO_VFS)" "1"
+ifneq ($(STATIC_LINKING), 1)
OBJS += platform/libretro/libretro-common/compat/compat_strcasestr.o
+ifeq "$(USE_LIBRETRO_VFS)" "1"
OBJS += platform/libretro/libretro-common/compat/compat_posix_string.o
OBJS += platform/libretro/libretro-common/compat/compat_strl.o
OBJS += platform/libretro/libretro-common/compat/fopen_utf8.o
-OBJS += platform/libretro/libretro-common/memmap/memmap.o
OBJS += platform/libretro/libretro-common/encodings/encoding_utf.o
OBJS += platform/libretro/libretro-common/string/stdstring.o
-OBJS += platform/libretro/libretro-common/file/file_path.o
+OBJS += platform/libretro/libretro-common/time/rtime.o
OBJS += platform/libretro/libretro-common/streams/file_stream.o
OBJS += platform/libretro/libretro-common/streams/file_stream_transforms.o
+OBJS += platform/libretro/libretro-common/file/file_path.o
OBJS += platform/libretro/libretro-common/vfs/vfs_implementation.o
endif
+endif
+ifeq "$(USE_LIBRETRO_VFS)" "1"
+OBJS += platform/libretro/libretro-common/memmap/memmap.o
+endif
+
PLATFORM_ZLIB ?= 1
endif
LZMA_OBJS += $(LZMA)/src/Delta.o
$(LZMA_OBJS): CFLAGS += -D_7ZIP_ST
-OBJS += $(CHDR_OBJS) $(LZMA_OBJS)
+OBJS += $(CHDR_OBJS)
+ifneq ($(STATIC_LINKING), 1)
+OBJS += $(LZMA_OBJS)
+endif
# ouf... prepend includes to overload headers available in the toolchain
CHDR_I = $(shell find $(CHDR) -name 'include')
CFLAGS := $(patsubst %, -I%, $(CHDR_I)) $(CFLAGS)
$(TARGET): $(OBJS)
-ifeq ($(STATIC_LINKING), 1)
+ifeq ($(STATIC_LINKING_LINK), 1)
$(AR) rcs $@ $^
else
$(LD) $(LINKOUT)$@ $^ $(CFLAGS) $(LDFLAGS) $(LDLIBS)
$(CC) $(CFLAGS) -O2 -ggdb -DPPROF -DPPROF_TOOL -I../../ -I. $^ -o $@ $(LDFLAGS) $(LDLIBS)
pico/pico_int_offs.h: tools/mkoffsets.sh
- make -C tools/ XCC="$(CC)" XCFLAGS="$(CFLAGS)" XPLATFORM="$(platform)"
+ make -C tools/ XCC="$(CC)" XCFLAGS="$(CFLAGS) -UUSE_LIBRETRO_VFS" XPLATFORM="$(platform)"
%.o: %.c
$(CC) -c $(OBJOUT)$@ $< $(CFLAGS)
CFLAGS += -I platform/libretro/libretro-common/include/vfs
USE_LIBRETRO_VFS := 1
-STATIC_LINKING := 0
+STATIC_LINKING:= 0
+STATIC_LINKING_LINK:= 0
+LOW_MEMORY := 0
TARGET_NAME := picodrive
LIBM := -lm
GIT_VERSION ?= $(shell git rev-parse --short HEAD || echo unknown)
CC=gcc
endif
+# x86/x86_64 generic
+else ifneq (,$(findstring x86,$(platform)))
+ TARGET := $(TARGET_NAME)_libretro.so
+ ARCH := 86
+ fpic := -fPIC
+ SHARED := -shared
+ DONT_COMPILE_IN_ZLIB = 1
+ CFLAGS += -DFAMEC_NO_GOTOS
+
+# AARCH64 generic
+else ifeq ($(platform), aarch64)
+ TARGET := $(TARGET_NAME)_libretro.so
+ ARCH = aarch64
+ fpic := -fPIC
+ SHARED := -shared
+ DONT_COMPILE_IN_ZLIB = 1
+ CFLAGS += -DFAMEC_NO_GOTOS
+
# Portable Linux
else ifeq ($(platform), linux-portable)
EXT ?= so
SHARED := -dynamiclib
fpic := -fPIC
APPLE := 1
- ifeq ($(shell uname -p),powerpc)
- CFLAGS += -DHAVE_NO_LANGEXTRA
- CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -DFAMEC_NO_GOTOS
- endif
- OSXVER = `sw_vers -productVersion | cut -d. -f 2`
- OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
- SHARED += -mmacosx-version-min=10.6
+
+ ifeq ($(CROSS_COMPILE),1)
+ TARGET_RULE = -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
+ CFLAGS += $(TARGET_RULE)
+ CPPFLAGS += $(TARGET_RULE)
+ CXXFLAGS += $(TARGET_RULE)
+ LDFLAGS += $(TARGET_RULE)
+ endif
+
+ ifndef ($(NOUNIVERSAL))
+ CFLAGS += $(ARCHFLAGS)
+ LDFLAGS += $(ARCHFLAGS)
+ endif
+ CFLAGS += -DUINT8=uint8_t -DUINT16=uint16_t -DUINT32=uint32_t -DINT8=int8_t -DINT16=int16_t -DINT32=int32_t
else ifeq ($(platform), staticios)
TARGET := $(TARGET_NAME)_libretro_ios.a
CFLAGS += -miphoneos-version-min=8.0
STATIC_LINKING = 1
+ STATIC_LINKING_LINK = 1
# iOS
else ifneq (,$(findstring ios,$(platform)))
- TARGET := $(TARGET_NAME)_libretro_ios.dylib
- SHARED := -dynamiclib
- fpic := -fPIC
- APPLE := 1
+ TARGET := $(TARGET_NAME)_libretro_ios.dylib
+ SHARED := -dynamiclib
+ fpic := -fPIC
+ APPLE := 1
+ MINVERSION :=
ifeq ($(IOSSDK),)
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
endif
CFLAGS += -DIOS
ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
- 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
+ MINVERSION = -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
+ MINVERSION = -miphoneos-version-min=5.0
endif
+ CC += $(MINVERSION)
+ CXX += $(MINVERSION)
+ CC_AS += $(MINVERSION)
+ CFLAGS += $(MINVERSION)
# tvOS
else ifeq ($(platform), tvos-arm64)
SHARED := -dynamiclib
fpic := -fPIC
APPLE := 1
- ifeq ($(IOSSDK),)
- IOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
- endif
- CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
- CC = clang -arch arm64 -isysroot $(IOSSDK)
- CXX = clang++ -arch arm64 -isysroot $(IOSSDK)
+ ifeq ($(IOSSDK),)
+ IOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
+ endif
+ CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
+ CC = cc -arch arm64 -isysroot $(IOSSDK)
+ CXX = c++ -arch arm64 -isysroot $(IOSSDK)
CFLAGS += -marm -DARM -D__aarch64__=1
CFLAGS += -DIOS
-# PS3
-else ifeq ($(platform), ps3)
- TARGET := $(TARGET_NAME)_libretro_$(platform).a
- CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
- AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
- CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -DFAMEC_NO_GOTOS
- STATIC_LINKING = 1
- # PS3 has memory mapped in a way not suitable for DRC
- use_sh2drc = 0
- use_svpdrc = 0
-
-# sncps3
-else ifeq ($(platform), sncps3)
- ARCH = powerpc
- TARGET := $(TARGET_NAME)_libretro_ps3.a
- CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
- AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
- CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -DFAMEC_NO_GOTOS
- STATIC_LINKING = 1
- # PS3 has memory mapped in a way not suitable for DRC
- use_sh2drc = 0
- use_svpdrc = 0
-
# Lightweight PS3 Homebrew SDK
-else ifeq ($(platform), psl1ght)
+else ifneq (,$(filter $(platform), ps3 psl1ght))
TARGET := $(TARGET_NAME)_libretro_$(platform).a
- CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
- AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
- CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -DFAMEC_NO_GOTOS
+ CC = $(PS3DEV)/ppu/bin/ppu-$(COMMONLV)gcc$(EXE_EXT)
+ AR = $(PS3DEV)/ppu/bin/ppu-$(COMMONLV)ar$(EXE_EXT)
+ CFLAGS += -DFAMEC_NO_GOTOS -D__PS3__
STATIC_LINKING = 1
+ STATIC_LINKING_LINK = 1
+ NO_MMAP = 1
+ ifeq ($(platform), psl1ght)
+ FLAGS += -D__PSL1GHT__
+ endif
# PS3 has memory mapped in a way not suitable for DRC
use_sh2drc = 0
use_svpdrc = 0
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = psp-gcc$(EXE_EXT)
AR = psp-ar$(EXE_EXT)
- CFLAGS += -G0 -ftracer
- CFLAGS += -DPSP
+ CFLAGS += -DPSP -G0 -ftracer
+ CFLAGS += -I$(shell psp-config --pspsdk-path)/include
STATIC_LINKING = 1
+ STATIC_LINKING_LINK = 1
# PS2
else ifeq ($(platform), ps2)
ARCH = mipsel
TARGET := $(TARGET_NAME)_libretro_$(platform).a
- CC = ee-gcc$(EXE_EXT)
- AR = ee-ar$(EXE_EXT)
- CFLAGS += -Wall -DPS2 -DUSE_BGR555 -DFAMEC_NO_GOTOS -DRENDER_GSKIT_PS2 -fsingle-precision-constant
+ CC = mips64r5900el-ps2-elf-gcc$(EXE_EXT)
+ AR = mips64r5900el-ps2-elf-ar$(EXE_EXT)
+ CFLAGS += -Wall -DPS2 -D_EE -DUSE_BGR555 -DFAMEC_NO_GOTOS -DRENDER_GSKIT_PS2 -fsingle-precision-constant
CFLAGS += -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include
- CFLAGS += -DHAVE_NO_LANGEXTRA
STATIC_LINKING = 1
+ STATIC_LINKING_LINK = 1
# CTR (3DS)
else ifeq ($(platform), ctr)
CFLAGS += -Wall -mword-relocations
CFLAGS += -fomit-frame-pointer -ffast-math
STATIC_LINKING = 1
+ STATIC_LINKING_LINK = 1
OBJS += platform/libretro/3ds/3ds_utils.o platform/libretro/3ds/utils.o
-# Raspberry Pi (original model) Raspbian
-else ifeq ($(platform), raspberrypi)
- CFLAGS += -marm -mfpu=vfp -mfloat-abi=hard -march=armv6j
+# Raspberry Pi
+else ifneq (,$(findstring rpi,$(platform)))
CFLAGS += -Wall -mword-relocations
CFLAGS += -fomit-frame-pointer -ffast-math
TARGET := $(TARGET_NAME)_libretro.so
SHARED := -shared
fpic := -fPIC
+
+ ifneq (,$(findstring rpi1,$(platform)))
+ CFLAGS += -marm -mfpu=vfp -mfloat-abi=hard -march=armv6j
+ else ifneq (,$(findstring rpi2,$(platform)))
+ CFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
+ else ifneq (,$(findstring rpi3,$(platform)))
+ CFLAGS += -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
+ endif
# Vita
else ifeq ($(platform), vita)
CFLAGS += -mword-relocations -fno-unwind-tables
CFLAGS += -fno-optimize-sibling-calls
STATIC_LINKING = 1
+ STATIC_LINKING_LINK = 1
# Xbox 360
else ifeq ($(platform), xenon)
TARGET := $(TARGET_NAME)_libretro_xenon360.a
CC = xenon-gcc$(EXE_EXT)
AR = xenon-ar$(EXE_EXT)
- CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
+ CFLAGS += -D__LIBXENON__ -m32
# Nintendo Game Cube
else ifeq ($(platform), ngc)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
- CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST
+ CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float
STATIC_LINKING = 1
+ STATIC_LINKING_LINK = 1
# Nintendo Wii
else ifeq ($(platform), wii)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
- CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST
+ CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float
STATIC_LINKING = 1
+ STATIC_LINKING_LINK = 1
# Nintendo Wii U
else ifeq ($(platform), wiiu)
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
- CFLAGS += -DGEKKO -DWIIU -DHW_RVL -DHW_WUP -mwup -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST
+ CFLAGS += -DGEKKO -DWIIU -DHW_RVL -DHW_WUP -mwup -mcpu=750 -meabi -mhard-float
STATIC_LINKING = 1
+ STATIC_LINKING_LINK = 1
# Nintendo Switch (libtransistor)
else ifeq ($(platform), switch)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
include $(LIBTRANSISTOR_HOME)/libtransistor.mk
STATIC_LINKING=1
+ STATIC_LINKING_LINK = 1
# Nintendo Switch (libnx)
else ifeq ($(platform), libnx)
CFLAGS += -DARM -D__aarch64__=1 -march=armv8-a -mtune=cortex-a57 -mtp=soft -ffast-math -mcpu=cortex-a57+crc+fp+simd -ffunction-sections
CFLAGS += -Ifrontend/switch -ftree-vectorize
STATIC_LINKING=1
+ STATIC_LINKING_LINK = 1
# QNX
else ifeq ($(platform), qnx)
TARGET := $(TARGET_NAME)_libretro_$(platform).bc
ARCH = unknown
+ STATIC_LINKING = 1
+
+# RS90
+else ifeq ($(platform), rs90)
+ TARGET := $(TARGET_NAME)_libretro.so
+ifeq (,$(shell command -v $(RS90_PREFIX)mipsel-rs90-linux-uclibc-gcc 2>/dev/null))
+ # locate the toolchain for buildbot if it isn't in path or prefix not set
+ RS90_PREFIX = /opt/rs90-toolchain/usr/bin/
+endif
+ CC = $(RS90_PREFIX)mipsel-linux-gcc
+ AR = $(RS90_PREFIX)mipsel-linux-ar
+ SHARED := -shared -nostdlib
+ fpic := -fPIC
+ LIBM :=
+ CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32 -D__GCW0__
+ # clear_cache uses SYNCI instead of a syscall
+ CFLAGS += -DMIPS_USE_SYNCI
+ LOW_MEMORY = 1
+
# GCW0
else ifeq ($(platform), gcw0)
TARGET := $(TARGET_NAME)_libretro.so
SHARED := -shared -nostdlib
fpic := -fPIC
LIBM :=
- CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float
+ CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float -D__GCW0__
+ # clear_cache uses SYNCI instead of a syscall
+ CFLAGS += -DMIPS_USE_SYNCI
+
+# RETROFW
+else ifeq ($(platform), retrofw)
+ TARGET := $(TARGET_NAME)_libretro.so
+ifeq (,$(shell command -v $(GCW0_PREFIX)mipsel-gcw0-linux-uclibc-gcc 2>/dev/null))
+ # locate the toolchain for buildbot if it isn't in path or prefix not set
+ GCW0_PREFIX = /opt/retrofw-toolchain/usr/bin/
+endif
+ CC = $(GCW0_PREFIX)mipsel-linux-gcc
+ AR = $(GCW0_PREFIX)mipsel-linux-ar
+ SHARED := -shared -nostdlib
+ fpic := -fPIC
+ LIBM :=
+ CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32 -mhard-float -D__GCW0__
+ # clear_cache uses SYNCI instead of a syscall
+ CFLAGS += -DMIPS_USE_SYNCI
+
+# MIYOO
+else ifeq ($(platform), miyoo)
+ TARGET := $(TARGET_NAME)_libretro.so
+ CC = /opt/miyoo/usr/bin/arm-linux-gcc
+ AR = /opt/miyoo/usr/bin/arm-linux-ar
+ SHARED := -shared -nostdlib
+ fpic := -fPIC
+ LIBM :=
+ DONT_COMPILE_IN_ZLIB = 1
+ CFLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s -D__GCW0__
+ HAVE_ARMv6 = 0
+ LOW_MEMORY = 1
# Windows MSVC 2017 all architectures
else ifneq (,$(findstring windows_msvc2017,$(platform)))
# Windows
else
TARGET := $(TARGET_NAME)_libretro.dll
- CC = gcc
+ CC ?= gcc
fpic := -fPIC
SHARED := -shared -static-libgcc -static-libstdc++
CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__
CFLAGS += -DUSE_LIBRETRO_VFS
endif
+ifeq ($(LOW_MEMORY), 1)
+ CFLAGS += -DLOW_MEMORY
+endif
+
ifeq ($(NO_ARM_ASM),1)
use_cyclone = 0
use_fame = 1
endif
include Makefile
+
+ifeq ($(platform), osx)
+pico/cd/libchdr/src/libchdr_chd.o: CFLAGS += -D__MACTYPES__=1
+endif
\ No newline at end of file
#include "../drc/emit_mips.c"
#elif defined(__riscv__) || defined(__riscv)
#include "../drc/emit_riscv.c"
-#elif defined(__powerpc__) || defined(__ppc__) || defined(_M_PPC)
+#elif defined(__powerpc__) || defined(__PPC__) || defined(__ppc__) || defined(_M_PPC)
#include "../drc/emit_ppc.c"
#elif defined(__i386__) || defined(_M_X86)
#include "../drc/emit_x86.c"
#elif defined(__riscv__) || defined(__riscv)
#define DRC_SR_REG "s11"
#define DRC_REG_LL 0 // no ABI for (__ILP32__ && __riscv_xlen != 32)
-#elif defined(__powerpc__) || defined(__ppc__)
+#elif defined(__powerpc__) || defined(__ppc__) || defined(__PPC__)
#define DRC_SR_REG "r28"
#define DRC_REG_LL 0 // no ABI for __ILP32__
#elif defined(__i386__)
include $(COMMON_DIR)/common.mak
SOURCES_C := $(LIBRETRO_DIR)/libretro.c \
+ $(LIBRETRO_COMM_DIR)/compat/compat_strcasestr.c \
$(COMMON_DIR)/mp3.c \
$(COMMON_DIR)/mp3_sync.c \
$(COMMON_DIR)/mp3_dummy.c \
- $(UNZIP_DIR)/unzip.c
-
-COREFLAGS := $(addprefix -D,$(DEFINES)) -fno-strict-aliasing
+ $(UNZIP_DIR)/unzip.c \
+ $(CORE_DIR)/pico/cd/libchdr/src/libchdr_bitstream.c \
+ $(CORE_DIR)/pico/cd/libchdr/src/libchdr_cdrom.c \
+ $(CORE_DIR)/pico/cd/libchdr/src/libchdr_chd.c \
+ $(CORE_DIR)/pico/cd/libchdr/src/libchdr_flac.c \
+ $(CORE_DIR)/pico/cd/libchdr/src/libchdr_huffman.c \
+ $(CORE_DIR)/pico/cd/libchdr/deps/lzma-19.00/src/LzFind.c \
+ $(CORE_DIR)/pico/cd/libchdr/deps/lzma-19.00/src/LzmaDec.c \
+ $(CORE_DIR)/pico/cd/libchdr/deps/lzma-19.00/src/LzmaEnc.c
+
+COREFLAGS := $(addprefix -D,$(DEFINES)) -fno-strict-aliasing -DUSE_LIBCHDR=1 -D_7ZIP_ST -I$(CORE_DIR)/pico/cd/libchdr/include -I$(CORE_DIR)/pico/cd/libchdr/deps/lzma-19.00/include
GIT_VERSION := $(shell git rev-parse --short HEAD || echo unknown)
ifneq ($(GIT_VERSION),"unknown")
return rom;\r
}\r
\r
-int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms)\r
+int PicoCartLoad(pm_file *f, const unsigned char *rom, unsigned int romsize,\r
+ unsigned char **prom, unsigned int *psize, int is_sms)\r
{\r
- unsigned char *rom;\r
+ unsigned char *rom_data = NULL;\r
int size, bytes_read;\r
\r
- if (f == NULL)\r
+ if (!f && !rom)\r
return 1;\r
\r
- size = f->size;\r
+ if (!rom)\r
+ size = f->size;\r
+ else\r
+ size = romsize;\r
+\r
if (size <= 0) return 1;\r
size = (size+3)&~3; // Round up to a multiple of 4\r
\r
// Allocate space for the rom plus padding\r
- rom = PicoCartAlloc(size, is_sms);\r
- if (rom == NULL) {\r
+ rom_data = PicoCartAlloc(size, is_sms);\r
+ if (rom_data == NULL) {\r
elprintf(EL_STATUS, "out of memory (wanted %i)", size);\r
return 2;\r
}\r
\r
- if (PicoCartLoadProgressCB != NULL)\r
- {\r
- // read ROM in blocks, just for fun\r
- int ret;\r
- unsigned char *p = rom;\r
- bytes_read=0;\r
- do\r
+ if (!rom) {\r
+ if (PicoCartLoadProgressCB != NULL)\r
{\r
- int todo = size - bytes_read;\r
- if (todo > 256*1024) todo = 256*1024;\r
- ret = pm_read(p,todo,f);\r
- bytes_read += ret;\r
- p += ret;\r
- PicoCartLoadProgressCB(bytes_read * 100LL / size);\r
+ // read ROM in blocks, just for fun\r
+ int ret;\r
+ unsigned char *p = rom_data;\r
+ bytes_read=0;\r
+ do\r
+ {\r
+ int todo = size - bytes_read;\r
+ if (todo > 256*1024) todo = 256*1024;\r
+ ret = pm_read(p,todo,f);\r
+ bytes_read += ret;\r
+ p += ret;\r
+ PicoCartLoadProgressCB(bytes_read * 100LL / size);\r
+ }\r
+ while (ret > 0);\r
+ }\r
+ else\r
+ bytes_read = pm_read(rom_data,size,f); // Load up the rom\r
+\r
+ if (bytes_read <= 0) {\r
+ elprintf(EL_STATUS, "read failed");\r
+ plat_munmap(rom_data, rom_alloc_size);\r
+ return 3;\r
}\r
- while (ret > 0);\r
}\r
else\r
- bytes_read = pm_read(rom,size,f); // Load up the rom\r
- if (bytes_read <= 0) {\r
- elprintf(EL_STATUS, "read failed");\r
- plat_munmap(rom, rom_alloc_size);\r
- return 3;\r
- }\r
+ memcpy(rom_data, rom, romsize);\r
\r
if (!is_sms)\r
{\r
// maybe we are loading MegaCD BIOS?\r
- if (!(PicoIn.AHW & PAHW_MCD) && size == 0x20000 && (!strncmp((char *)rom+0x124, "BOOT", 4) ||\r
- !strncmp((char *)rom+0x128, "BOOT", 4))) {\r
+ if (!(PicoIn.AHW & PAHW_MCD) && size == 0x20000 && (!strncmp((char *)rom_data+0x124, "BOOT", 4) ||\r
+ !strncmp((char *)rom_data+0x128, "BOOT", 4))) {\r
PicoIn.AHW |= PAHW_MCD;\r
}\r
\r
// Check for SMD:\r
if (size >= 0x4200 && (size&0x3fff) == 0x200 &&\r
- ((rom[0x2280] == 'S' && rom[0x280] == 'E') || (rom[0x280] == 'S' && rom[0x2281] == 'E'))) {\r
+ ((rom_data[0x2280] == 'S' && rom_data[0x280] == 'E') || (rom_data[0x280] == 'S' && rom_data[0x2281] == 'E'))) {\r
elprintf(EL_STATUS, "SMD format detected.");\r
- DecodeSmd(rom,size); size-=0x200; // Decode and byteswap SMD\r
+ DecodeSmd(rom_data,size); size-=0x200; // Decode and byteswap SMD\r
}\r
- else Byteswap(rom, rom, size); // Just byteswap\r
+ else Byteswap(rom_data, rom_data, size); // Just byteswap\r
}\r
else\r
{\r
elprintf(EL_STATUS, "SMD format detected.");\r
// at least here it's not interleaved\r
size -= 0x200;\r
- memmove(rom, rom + 0x200, size);\r
+ memmove(rom_data, rom_data + 0x200, size);\r
}\r
}\r
\r
- if (prom) *prom = rom;\r
+ if (prom) *prom = rom_data;\r
if (psize) *psize = size;\r
\r
return 0;\r
strlwr_(ext);
}
-static int detect_media(const char *fname)
+static int detect_media(const char *fname, const unsigned char *rom, unsigned int romsize)
{
static const short sms_offsets[] = { 0x7ff0, 0x3ff0, 0x1ff0 };
static const char *sms_exts[] = { "sms", "gg", "sg" };
static const char *md_exts[] = { "gen", "smd", "md" };
static const char *pico_exts[] = { "pco" };
char buff0[512], buff[32];
- unsigned short *d16;
- pm_file *pmf;
- char ext[5];
+ unsigned short *d16 = NULL;
+ pm_file *pmf = NULL;
+ const char *ext_ptr = NULL;
+ char ext[8];
int i;
- get_ext(fname, ext);
+ ext[0] = '\0';
+ if ((ext_ptr = strrchr(fname, '.'))) {
+ strncpy(ext, ext_ptr + 1, sizeof(ext));
+ ext[sizeof(ext) - 1] = '\0';
+ }
// detect wrong extensions
- if (!strcmp(ext, ".srm") || !strcmp(ext, "s.gz") || !strcmp(ext, ".mds")) // s.gz ~ .mds.gz
+ if (!strcmp(ext, "srm") || !strcmp(ext, "gz")) // s.gz ~ .mds.gz
return PM_BAD_DETECT;
- /* don't believe in extensions, except .cue */
- if (strcasecmp(ext, ".cue") == 0 || strcasecmp(ext, ".chd") == 0)
+ /* don't believe in extensions, except .cue and .chd */
+ if (strcasecmp(ext, "cue") == 0 || strcasecmp(ext, "chd") == 0)
return PM_CD;
- pmf = pm_open(fname);
- if (pmf == NULL)
- return PM_BAD_DETECT;
+ /* Open rom file, if required */
+ if (!rom) {
+ pmf = pm_open(fname);
+ if (pmf == NULL)
+ return PM_BAD_DETECT;
+ romsize = pmf->size;
+ }
- if (pm_read(buff0, 512, pmf) != 512) {
- pm_close(pmf);
- return PM_BAD_DETECT;
+ if (!rom) {
+ if (pm_read(buff0, 512, pmf) != 512) {
+ pm_close(pmf);
+ return PM_BAD_DETECT;
+ }
+ } else {
+ if (romsize < 512)
+ return PM_BAD_DETECT;
+ memcpy(buff0, rom, 512);
}
if (strncasecmp("SEGADISCSYSTEM", buff0 + 0x00, 14) == 0 ||
}
/* check for SMD evil */
- if (pmf->size >= 0x4200 && (pmf->size & 0x3fff) == 0x200) {
- if (pm_seek(pmf, sms_offsets[0] + 0x200, SEEK_SET) == sms_offsets[0] + 0x200 &&
- pm_read(buff, 16, pmf) == 16 &&
- strncmp("TMR SEGA", buff, 8) == 0)
+ if (romsize >= 0x4200 && (romsize & 0x3fff) == 0x200) {
+ buff[0] = '\0';
+
+ if (!rom) {
+ if (pm_seek(pmf, sms_offsets[0] + 0x200, SEEK_SET) == sms_offsets[0] + 0x200)
+ pm_read(buff, 16, pmf);
+ } else {
+ if (romsize >= sms_offsets[0] + 0x200 + 16)
+ memcpy(buff, rom + sms_offsets[0] + 0x200, 16);
+ }
+
+ if (strncmp("TMR SEGA", buff, 8) == 0)
goto looks_like_sms;
/* could parse further but don't bother */
goto extension_check;
}
- if (pm_seek(pmf, 0x100, SEEK_SET) == 0x100 && pm_read(buff, 16, pmf) == 16) {
- /* PICO header? Almost always appropriately marked */
- buff[16] = '\0';
- if (strstr(buff, " PICO "))
- goto looks_like_pico;
- /* MD header? Act as TMSS BIOS here */
- if (strncmp(buff, "SEGA", 4) == 0 || strncmp(buff, " SEG", 4) == 0)
- goto looks_like_md;
+ /* fetch header info */
+ memset(buff, '\0', 17);
+ if (!rom) {
+ if (pm_seek(pmf, 0x100, SEEK_SET) == 0x100)
+ pm_read(buff, 16, pmf);
+ } else {
+ if (romsize >= 0x100 + 16)
+ memcpy(buff, rom + 0x100, 16);
}
+ /* PICO header? Almost always appropriately marked */
+ if (strstr(buff, " PICO "))
+ goto looks_like_pico;
+ /* MD header? Act as TMSS BIOS here */
+ if (strncmp(buff, "SEGA", 4) == 0 || strncmp(buff, " SEG", 4) == 0)
+ goto looks_like_md;
for (i = 0; i < ARRAY_SIZE(sms_offsets); i++) {
- if (pm_seek(pmf, sms_offsets[i], SEEK_SET) != sms_offsets[i])
- continue;
+ if (!rom) {
+ if (pm_seek(pmf, sms_offsets[i], SEEK_SET) != sms_offsets[i])
+ continue;
+
+ if (pm_read(buff, 16, pmf) != 16)
+ continue;
+ } else {
+ if (romsize < sms_offsets[i] + 16)
+ continue;
- if (pm_read(buff, 16, pmf) != 16)
- continue;
+ memcpy(buff, rom + sms_offsets[i], 16);
+ }
if (strncmp("TMR SEGA", buff, 8) == 0)
goto looks_like_sms;
extension_check:
/* probably some headerless thing. Maybe check the extension after all. */
for (i = 0; i < ARRAY_SIZE(md_exts); i++)
- if (strcasecmp(pmf->ext, md_exts[i]) == 0)
+ if (strcasecmp(ext, md_exts[i]) == 0)
goto looks_like_md;
for (i = 0; i < ARRAY_SIZE(sms_exts); i++)
- if (strcasecmp(pmf->ext, sms_exts[i]) == 0)
+ if (strcasecmp(ext, sms_exts[i]) == 0)
goto looks_like_sms;
for (i = 0; i < ARRAY_SIZE(pico_exts); i++)
- if (strcasecmp(pmf->ext, pico_exts[i]) == 0)
+ if (strcasecmp(ext, pico_exts[i]) == 0)
goto looks_like_pico;
/* If everything else fails, make a guess on the reset vector */
d16 = (unsigned short *)(buff0 + 4);
- if ((((d16[0] << 16) | d16[1]) & 0xffffff) >= pmf->size) {
+ if ((((d16[0] << 16) | d16[1]) & 0xffffff) >= romsize) {
lprintf("bad MD reset vector, assuming SMS\n");
goto looks_like_sms;
}
}
enum media_type_e PicoLoadMedia(const char *filename,
+ const unsigned char *rom, unsigned int romsize,
const char *carthw_cfg_fname,
const char *(*get_bios_filename)(int *region, const char *cd_fname),
void (*do_region_override)(const char *media_filename))
const char *rom_fname = filename;
enum media_type_e media_type;
enum cd_track_type cd_img_type = CT_UNKNOWN;
+ pm_file *rom_file = NULL;
unsigned char *rom_data = NULL;
unsigned int rom_size = 0;
- pm_file *rom = NULL;
int cd_region = 0;
int ret;
- media_type = detect_media(filename);
+ media_type = detect_media(filename, rom, romsize);
if (media_type == PM_BAD_DETECT)
goto out;
PicoIn.AHW = PAHW_PICO;
}
- rom = pm_open(rom_fname);
- if (rom == NULL) {
- lprintf("Failed to open ROM\n");
- media_type = PM_ERROR;
- goto out;
+ if (!rom) {
+ rom_file = pm_open(rom_fname);
+ if (rom_file == NULL) {
+ lprintf("Failed to open ROM\n");
+ media_type = PM_ERROR;
+ goto out;
+ }
}
- ret = PicoCartLoad(rom, &rom_data, &rom_size, (PicoIn.AHW & PAHW_SMS) ? 1 : 0);
+ ret = PicoCartLoad(rom_file, rom, romsize, &rom_data, &rom_size, (PicoIn.AHW & PAHW_SMS) ? 1 : 0);
if (ret != 0) {
if (ret == 2) lprintf("Out of memory\n");
else if (ret == 3) lprintf("Read failed\n");
// simple test for GG. Do this here since m.hardware is nulled in Insert
if ((PicoIn.AHW & PAHW_SMS) && !PicoIn.hwSelect) {
- if (!strcmp(rom->ext,"gg")) {
+ const char *ext = NULL;
+ if (rom_file && rom_file->ext && (*rom_file->ext != '\0')) {
+ ext = rom_file->ext;
+ }
+ else if ((ext = strrchr(filename, '.'))) {
+ if (*(++ext) == '\0') {
+ ext = NULL;
+ }
+ }
+ if (ext && !strcmp(ext,"gg") && !PicoIn.hwSelect) {
Pico.m.hardware |= PMS_HW_GG;
lprintf("detected GG ROM\n");
- } else if (!strcmp(rom->ext,"sg")) {
+ } else if (ext && !strcmp(ext,"sg")) {
Pico.m.hardware |= PMS_HW_SG;
lprintf("detected SG-1000 ROM\n");
} else
PicoSetInputDevice(0, PICO_INPUT_PAD_6BTN);
out:
- if (rom)
- pm_close(rom);
+ if (rom_file)
+ pm_close(rom_file);
if (rom_data)
free(rom_data);
return media_type;
size_t pm_read_audio(void *ptr, size_t bytes, pm_file *stream);\r
int pm_seek(pm_file *stream, long offset, int whence);\r
int pm_close(pm_file *fp);\r
-int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms);\r
+int PicoCartLoad(pm_file *f, const unsigned char *rom, unsigned int romsize,\r
+ unsigned char **prom, unsigned int *psize, int is_sms);\r
int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_cfg);\r
void PicoCartUnload(void);\r
extern void (*PicoCartLoadProgressCB)(int percent);\r
\r
\r
enum media_type_e PicoLoadMedia(const char *filename,\r
+ const unsigned char *rom, unsigned int romsize,\r
const char *carthw_cfg_fname,\r
const char *(*get_bios_filename)(int *region, const char *cd_fname),\r
void (*do_region_override)(const char *media_filename));\r
\r
emu_make_path(carthw_path, "carthw.cfg", sizeof(carthw_path));\r
\r
- media_type = PicoLoadMedia(rom_fname, carthw_path,\r
+ media_type = PicoLoadMedia(rom_fname, NULL, 0, carthw_path,\r
find_bios, do_region_override);\r
\r
switch (media_type) {\r
#include <stdio.h>
#include <pico/pico_int.h>
+// Ugh, drmp3 tries to use wfopen on windows, which breaks libretro VFS...
+#define __acrt_iob_func __acrt_iob_func2
+#define _wfopen_s(p,m) NULL
+#define _wfopen(p,m) NULL
#define DR_MP3_IMPLEMENTATION
#include "dr_libs/dr_mp3.h"
#include "mp3.h"
# endif
# endif
# else
-# if defined(__GNUC__) && __GNUC__ >= 4
+# if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__PS3__)
# define RETRO_API RETRO_CALLCONV __attribute__((__visibility__("default")))
# else
# define RETRO_API RETRO_CALLCONV
--- /dev/null
+/* Copyright (C) 2010-2020 The RetroArch team
+ *
+ * ---------------------------------------------------------------------------------------
+ * The following license statement only applies to this file (retro_assert.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 __RETRO_ASSERT_H
+#define __RETRO_ASSERT_H
+
+#include <assert.h>
+
+#ifdef RARCH_INTERNAL
+#include <stdio.h>
+#define retro_assert(cond) ((void)( (cond) || (printf("Assertion failed at %s:%d.\n", __FILE__, __LINE__), abort(), 0) ))
+#else
+#define retro_assert(cond) assert(cond)
+#endif
+
+#endif
}
#ifndef PATH_MAX_LENGTH
-#if defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(PS2) || defined(GEKKO)|| defined(WIIU) || defined(ORBIS) || defined(__PSL1GHT__) || defined(__PS3__)
+#if defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(PS2) || defined(GEKKO)|| defined(WIIU) || defined(ORBIS)
#define PATH_MAX_LENGTH 512
+#elif defined(__PS3__)
+#define PATH_MAX_LENGTH 1024
#else
#define PATH_MAX_LENGTH 4096
#endif
--- /dev/null
+/* Copyright (C) 2010-2020 The RetroArch team
+ *
+ * ---------------------------------------------------------------------------------------
+ * The following license statement only applies to this file (rtime.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_RTIME_H__
+#define __LIBRETRO_SDK_RTIME_H__
+
+#include <retro_common_api.h>
+
+#include <stdint.h>
+#include <stddef.h>
+#include <time.h>
+
+RETRO_BEGIN_DECLS
+
+/* TODO/FIXME: Move all generic time handling functions
+ * to this file */
+
+/* Must be called before using rtime_localtime() */
+void rtime_init(void);
+
+/* Must be called upon program termination */
+void rtime_deinit(void);
+
+/* Thread-safe wrapper for localtime() */
+struct tm *rtime_localtime(const time_t *timep, struct tm *result);
+
+RETRO_END_DECLS
+
+#endif
--- /dev/null
+/* Copyright (C) 2010-2020 The RetroArch team
+ *
+ * ---------------------------------------------------------------------------------------
+ * The following license statement only applies to this file (rtime.c).
+ * ---------------------------------------------------------------------------------------
+ *
+ * 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.
+ */
+
+#ifdef HAVE_THREADS
+#include <rthreads/rthreads.h>
+#include <retro_assert.h>
+#include <stdlib.h>
+#endif
+
+#include <string.h>
+#include <time/rtime.h>
+
+#ifdef HAVE_THREADS
+/* TODO/FIXME - global */
+slock_t *rtime_localtime_lock = NULL;
+#endif
+
+/* Must be called before using rtime_localtime() */
+void rtime_init(void)
+{
+ rtime_deinit();
+#ifdef HAVE_THREADS
+ if (!rtime_localtime_lock)
+ rtime_localtime_lock = slock_new();
+
+ retro_assert(rtime_localtime_lock);
+#endif
+}
+
+/* Must be called upon program termination */
+void rtime_deinit(void)
+{
+#ifdef HAVE_THREADS
+ if (rtime_localtime_lock)
+ {
+ slock_free(rtime_localtime_lock);
+ rtime_localtime_lock = NULL;
+ }
+#endif
+}
+
+/* Thread-safe wrapper for localtime() */
+struct tm *rtime_localtime(const time_t *timep, struct tm *result)
+{
+ struct tm *time_info = NULL;
+
+ /* Lock mutex */
+#ifdef HAVE_THREADS
+ slock_lock(rtime_localtime_lock);
+#endif
+
+ time_info = localtime(timep);
+ if (time_info)
+ memcpy(result, time_info, sizeof(struct tm));
+
+ /* Unlock mutex */
+#ifdef HAVE_THREADS
+ slock_unlock(rtime_localtime_lock);
+#endif
+
+ return result;
+}
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
-#ifndef _WIN32
-#ifdef __SWITCH__
-#include "switch/mman.h"
-#else
-#include <sys/mman.h>
-#endif
-#else
-#include <io.h>
-#include <windows.h>
-#include <sys/types.h>
-#endif
#include <errno.h>
#ifdef __MACH__
#include <libkern/OSCacheControl.h>
#endif
+#include "libretro-common/include/memmap.h"
+/* Ouf, libretro-common defines replacement functions, but not the flags :-| */
+#ifndef PROT_READ
+#define PROT_READ 0x1
+#define PROT_WRITE 0x2
+#define PROT_READWRITE 0x3
+#define PROT_EXEC 0x4
+#define MAP_FAILED ((void *) -1)
+#define MAP_ANONYMOUS 0x1
+#define MAP_PRIVATE 0x2
+#endif
+
#if defined(RENDER_GSKIT_PS2)
#include <malloc.h>
#include "libretro-common/include/libretro_gskit_ps2.h"
#include "../common/input_pico.h"
#include "../common/version.h"
#include <libretro.h>
+#include <compat/strcasestr.h>
static retro_log_printf_t log_cb;
static retro_video_refresh_t video_cb;
#define SND_RATE_DEFAULT 44100
#define SND_RATE_MAX 53267
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
+
static const float VOUT_PAR = 0.0;
static const float VOUT_4_3 = (4.0f / 3.0f);
static const float VOUT_CRT = (1.29911f);
static unsigned audio_latency = 0;
static bool update_audio_latency = false;
+static uint16_t pico_events;
+int pico_inp_mode;
+int pico_pen_x = 320/2, pico_pen_y = 240/2;
static void retro_audio_buff_status_cb(
bool active, unsigned occupancy, bool underrun_likely)
}
#ifdef RENDER_GSKIT_PS2
-/* ee-gcc is version 3.2, where these aren't yet defined */
-void __builtin___clear_cache(void *b, void *e)
+/* In PS2 toolchain these aren't yet defined */
+void _flush_cache(void *b, void *e)
{
#if 0 /* which of these is overall faster for lots of small cache updates? */
SyncDCache(b, e);
v ^= v >> 4;
return (0x6996 >> (v&0xf)) & 1;
}
+#elif defined(PSP)
+int _flush_cache(char *addr, const int size, const int op)
+{
+ //sceKernelDcacheWritebackAll();
+ sceKernelDcacheWritebackRange(addr, size);
+ sceKernelIcacheInvalidateRange(addr, size);
+ return 0;
+}
#endif
#ifdef __MACH__
}
#endif
-#ifdef _WIN32
-/* mmap() replacement for Windows
- *
- * Author: Mike Frysinger <vapier@gentoo.org>
- * Placed into the public domain
- */
-
-/* References:
- * CreateFileMapping: http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx
- * CloseHandle: http://msdn.microsoft.com/en-us/library/ms724211(VS.85).aspx
- * MapViewOfFile: http://msdn.microsoft.com/en-us/library/aa366761(VS.85).aspx
- * UnmapViewOfFile: http://msdn.microsoft.com/en-us/library/aa366882(VS.85).aspx
- */
-
-#define PROT_READ 0x1
-#define PROT_WRITE 0x2
-/* This flag is only available in WinXP+ */
-#ifdef FILE_MAP_EXECUTE
-#define PROT_EXEC 0x4
-#else
-#define PROT_EXEC 0x0
-#define FILE_MAP_EXECUTE 0
-#endif
-
-#define MAP_SHARED 0x01
-#define MAP_PRIVATE 0x02
-#define MAP_ANONYMOUS 0x20
-#define MAP_ANON MAP_ANONYMOUS
-#define MAP_FAILED ((void *) -1)
-
-#ifdef __USE_FILE_OFFSET64
-# define DWORD_HI(x) (x >> 32)
-# define DWORD_LO(x) ((x) & 0xffffffff)
-#else
-# define DWORD_HI(x) (0)
-# define DWORD_LO(x) (x)
-#endif
-
-static void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
-{
- uint32_t flProtect, dwDesiredAccess;
- off_t end;
- HANDLE mmap_fd, h;
- void *ret;
-
- if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
- return MAP_FAILED;
- if (fd == -1) {
- if (!(flags & MAP_ANON) || offset)
- return MAP_FAILED;
- } else if (flags & MAP_ANON)
- return MAP_FAILED;
-
- if (prot & PROT_WRITE) {
- if (prot & PROT_EXEC)
- flProtect = PAGE_EXECUTE_READWRITE;
- else
- flProtect = PAGE_READWRITE;
- } else if (prot & PROT_EXEC) {
- if (prot & PROT_READ)
- flProtect = PAGE_EXECUTE_READ;
- else if (prot & PROT_EXEC)
- flProtect = PAGE_EXECUTE;
- } else
- flProtect = PAGE_READONLY;
-
- end = length + offset;
-
- if (fd == -1)
- mmap_fd = INVALID_HANDLE_VALUE;
- else
- mmap_fd = (HANDLE)_get_osfhandle(fd);
- h = CreateFileMapping(mmap_fd, NULL, flProtect, DWORD_HI(end), DWORD_LO(end), NULL);
- if (h == NULL)
- return MAP_FAILED;
-
- if (prot & PROT_WRITE)
- dwDesiredAccess = FILE_MAP_WRITE;
- else
- dwDesiredAccess = FILE_MAP_READ;
- if (prot & PROT_EXEC)
- dwDesiredAccess |= FILE_MAP_EXECUTE;
- if (flags & MAP_PRIVATE)
- dwDesiredAccess |= FILE_MAP_COPY;
- ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length);
- if (ret == NULL) {
- CloseHandle(h);
- ret = MAP_FAILED;
- }
- return ret;
-}
-
-static void munmap(void *addr, size_t length)
-{
- UnmapViewOfFile(addr);
- /* ruh-ro, we leaked handle from CreateFileMapping() ... */
-}
-#endif
-
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif
struct retro_vfs_interface_info vfs_iface_info;
#endif
+ static const struct retro_system_content_info_override content_overrides[] = {
+ {
+ "gen|smd|md|32x|sms|68k|sgd|pco", /* extensions */
+#if defined(LOW_MEMORY)
+ true, /* need_fullpath */
+#else
+ false, /* need_fullpath */
+#endif
+ false /* persistent_data */
+ },
+ { NULL, false, false }
+ };
+
environ_cb = cb;
libretro_set_core_options(environ_cb,
&option_categories_supported);
+ environ_cb(RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE,
+ (void*)content_overrides);
#ifdef USE_LIBRETRO_VFS
vfs_iface_info.required_interface_version = 1;
#define _GIT_VERSION "-" GIT_VERSION
#endif
info->library_version = VERSION _GIT_VERSION;
- info->valid_extensions = "bin|gen|smd|md|32x|cue|iso|chd|sms|gg|sg";
+ info->valid_extensions = "bin|gen|smd|md|32x|cue|iso|chd|sms|gg|m3u|68k|sgd|pco";
info->need_fullpath = true;
}
}
/* multidisk support */
+static unsigned int disk_initial_index;
static bool disk_ejected;
static unsigned int disk_current_index;
static unsigned int disk_count;
+static char disk_initial_path[PATH_MAX];
static struct disks_state {
char *fname;
+ char *flabel;
} disks[8];
+static void get_disk_label(char *disk_label, const char *disk_path, size_t len)
+{
+ const char *base = NULL;
+
+ if (!disk_path || (*disk_path == '\0'))
+ return;
+
+ base = strrchr(disk_path, SLASH);
+ if (!base)
+ base = disk_path;
+
+ if (*base == SLASH)
+ base++;
+
+ strncpy(disk_label, base, len - 1);
+ disk_label[len - 1] = '\0';
+
+ char *ext = strrchr(disk_label, '.');
+ if (ext)
+ *ext = '\0';
+}
+
+static void disk_init(void)
+{
+ size_t i;
+
+ disk_ejected = false;
+ disk_current_index = 0;
+ disk_count = 0;
+
+ for (i = 0; i < sizeof(disks) / sizeof(disks[0]); i++)
+ {
+ if (disks[i].fname != NULL)
+ {
+ free(disks[i].fname);
+ disks[i].fname = NULL;
+ }
+ if (disks[i].flabel != NULL)
+ {
+ free(disks[i].flabel);
+ disks[i].flabel = NULL;
+ }
+ }
+}
+
static bool disk_set_eject_state(bool ejected)
{
// TODO?
static bool disk_replace_image_index(unsigned index,
const struct retro_game_info *info)
{
- bool ret = true;
+ char *old_fname = NULL;
+ char *old_flabel = NULL;
+ bool ret = true;
if (index >= sizeof(disks) / sizeof(disks[0]))
return false;
+ old_fname = disks[index].fname;
+ old_flabel = disks[index].flabel;
+
if (disks[index].fname != NULL)
free(disks[index].fname);
disks[index].fname = NULL;
+ if (disks[index].flabel != NULL)
+ free(disks[index].flabel);
+ disks[index].flabel = NULL;
+
if (info != NULL) {
+ char disk_label[PATH_MAX];
+ disk_label[0] = '\0';
+
disks[index].fname = strdup(info->path);
+
+ get_disk_label(disk_label, info->path, PATH_MAX);
+ disks[index].flabel = strdup(disk_label);
+
if (index == disk_current_index)
ret = disk_set_image_index(index);
}
+ if (old_fname != NULL)
+ free(old_fname);
+
+ if (old_flabel != NULL)
+ free(old_flabel);
+
return ret;
}
return true;
}
+static bool disk_set_initial_image(unsigned index, const char *path)
+{
+ if (index >= sizeof(disks) / sizeof(disks[0]))
+ return false;
+
+ if (!path || (*path == '\0'))
+ return false;
+
+ disk_initial_index = index;
+
+ strncpy(disk_initial_path, path, sizeof(disk_initial_path) - 1);
+ disk_initial_path[sizeof(disk_initial_path) - 1] = '\0';
+
+ return true;
+}
+
+static bool disk_get_image_path(unsigned index, char *path, size_t len)
+{
+ const char *fname = NULL;
+
+ if (len < 1)
+ return false;
+
+ if (index >= sizeof(disks) / sizeof(disks[0]))
+ return false;
+
+ fname = disks[index].fname;
+
+ if (!fname || (*fname == '\0'))
+ return false;
+
+ strncpy(path, fname, len - 1);
+ path[len - 1] = '\0';
+
+ return true;
+}
+
+static bool disk_get_image_label(unsigned index, char *label, size_t len)
+{
+ const char *flabel = NULL;
+
+ if (len < 1)
+ return false;
+
+ if (index >= sizeof(disks) / sizeof(disks[0]))
+ return false;
+
+ flabel = disks[index].flabel;
+
+ if (!flabel || (*flabel == '\0'))
+ return false;
+
+ strncpy(label, flabel, len - 1);
+ label[len - 1] = '\0';
+
+ return true;
+}
+
static struct retro_disk_control_callback disk_control = {
disk_set_eject_state,
disk_get_eject_state,
disk_add_image_index,
};
+static struct retro_disk_control_ext_callback disk_control_ext = {
+ .set_eject_state = disk_set_eject_state,
+ .get_eject_state = disk_get_eject_state,
+ .get_image_index = disk_get_image_index,
+ .set_image_index = disk_set_image_index,
+ .get_num_images = disk_get_num_images,
+ .replace_image_index = disk_replace_image_index,
+ .add_image_index = disk_add_image_index,
+ .set_initial_image = disk_set_initial_image,
+ .get_image_path = disk_get_image_path,
+ .get_image_label = disk_get_image_label,
+};
+
static void disk_tray_open(void)
{
if (log_cb)
disk_ejected = 0;
}
+static char base_dir[1024];
+
+static void extract_directory(char *buf, const char *path, size_t size)
+{
+ char *base;
+ strncpy(buf, path, size - 1);
+ buf[size - 1] = '\0';
+
+ base = strrchr(buf, '/');
+ if (!base)
+ base = strrchr(buf, '\\');
+
+ if (base)
+ *base = '\0';
+ else
+ {
+ buf[0] = '.';
+ buf[1] = '\0';
+ }
+}
+
+static void extract_basename(char *buf, const char *path, size_t size)
+{
+ const char *base = strrchr(path, '/');
+ if (!base)
+ base = strrchr(path, '\\');
+ if (!base)
+ base = path;
+
+ if (*base == '\\' || *base == '/')
+ base++;
+
+ strncpy(buf, base, size - 1);
+ buf[size - 1] = '\0';
+
+ char *ext = strrchr(buf, '.');
+ if (ext)
+ *ext = '\0';
+}
+
+static bool read_m3u(const char *file)
+{
+ char line[1024];
+ char name[PATH_MAX];
+ FILE *f = fopen(file, "r");
+ if (!f)
+ return false;
+
+ while (fgets(line, sizeof(line), f) && disk_count < sizeof(disks) / sizeof(disks[0]))
+ {
+ if (line[0] == '#')
+ continue;
+ char *carrige_return = strchr(line, '\r');
+ if (carrige_return)
+ *carrige_return = '\0';
+ char *newline = strchr(line, '\n');
+ if (newline)
+ *newline = '\0';
+
+ if (line[0] != '\0')
+ {
+ char disk_label[PATH_MAX];
+ disk_label[0] = '\0';
+
+ snprintf(name, sizeof(name), "%s%c%s", base_dir, SLASH, line);
+ disks[disk_count].fname = strdup(name);
+
+ get_disk_label(disk_label, name, PATH_MAX);
+ disks[disk_count].flabel = strdup(disk_label);
+
+ disk_count++;
+ }
+ }
+
+ fclose(f);
+ return (disk_count != 0);
+}
+
+/* end of multi disk support */
static const char * const biosfiles_us[] = {
"us_scd2_9306", "SegaCDBIOS9303", "us_scd1_9210", "bios_CD_U"
bool retro_load_game(const struct retro_game_info *info)
{
+ const struct retro_game_info_ext *info_ext = NULL;
+ const unsigned char *content_data = NULL;
+ size_t content_size = 0;
+ char content_path[PATH_MAX];
+ char content_ext[8];
+ char carthw_path[PATH_MAX];
enum media_type_e media_type;
- static char carthw_path[256];
size_t i;
+#if defined(_WIN32)
+ char slash = '\\';
+#else
+ char slash = '/';
+#endif
+
+ content_path[0] = '\0';
+ content_ext[0] = '\0';
+ carthw_path[0] = '\0';
+
+ unsigned int cd_index = 0;
+ bool is_m3u = false;
+
struct retro_input_descriptor desc[] = {
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" },
{ 0 },
};
+ struct retro_input_descriptor desc_pico[] = {
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left (violet)" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up (white)" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down (orange)" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right (green)" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Red Button" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Pen Button" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT,"Switch input" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "Previous page" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Next page" },
+
+ { 0 },
+ };
+
+ /* Attempt to fetch extended game info */
+ if (environ_cb(RETRO_ENVIRONMENT_GET_GAME_INFO_EXT, &info_ext))
+ {
+#if !defined(LOW_MEMORY)
+ content_data = (const unsigned char *)info_ext->data;
+ content_size = info_ext->size;
+#endif
+ strncpy(base_dir, info_ext->dir, sizeof(base_dir));
+ base_dir[sizeof(base_dir) - 1] = '\0';
+
+ strncpy(content_ext, info_ext->ext, sizeof(content_ext));
+ content_ext[sizeof(content_ext) - 1] = '\0';
+
+ if (info_ext->file_in_archive)
+ {
+ /* We don't have a 'physical' file in this
+ * case, but the core still needs a filename
+ * in order to detect media type. We therefore
+ * fake it, using the content directory,
+ * canonical content name, and content file
+ * extension */
+ snprintf(content_path, sizeof(content_path), "%s%c%s.%s",
+ base_dir, slash, info_ext->name, content_ext);
+ }
+ else
+ {
+ strncpy(content_path, info_ext->full_path, sizeof(content_path));
+ content_path[sizeof(content_path) - 1] = '\0';
+ }
+ }
+ else
+ {
+ const char *ext = NULL;
+
+ if (!info || !info->path)
+ {
+ if (log_cb)
+ log_cb(RETRO_LOG_ERROR, "info->path required\n");
+ return false;
+ }
+
+ extract_directory(base_dir, info->path, sizeof(base_dir));
+
+ strncpy(content_path, info->path, sizeof(content_path));
+ content_path[sizeof(content_path) - 1] = '\0';
+
+ if ((ext = strrchr(info->path, '.')))
+ {
+ strncpy(content_ext, ext + 1, sizeof(content_ext));
+ content_ext[sizeof(content_ext) - 1] = '\0';
+ }
+ }
+
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) {
if (log_cb)
return false;
}
- if (info == NULL || info->path == NULL) {
- if (log_cb)
- log_cb(RETRO_LOG_ERROR, "info->path required\n");
- return false;
- }
+ disk_init();
- for (i = 0; i < sizeof(disks) / sizeof(disks[0]); i++) {
- if (disks[i].fname != NULL) {
- free(disks[i].fname);
- disks[i].fname = NULL;
+ is_m3u = (strcasestr(content_ext, "m3u") != NULL);
+ if (is_m3u)
+ {
+ if (!read_m3u(content_path))
+ {
+ log_cb(RETRO_LOG_INFO, "failed to read m3u file\n");
+ return false;
}
+
+ strncpy(content_path, disks[0].fname, sizeof(content_path));
+ content_path[sizeof(content_path) - 1] = '\0';
+ }
+ else
+ {
+ char disk_label[PATH_MAX];
+ disk_label[0] = '\0';
+
+ disk_current_index = 0;
+ disk_count = 1;
+ disks[0].fname = strdup(content_path);
+
+ get_disk_label(disk_label, content_path, PATH_MAX);
+ disks[0].flabel = strdup(disk_label);
}
- disk_current_index = 0;
- disk_count = 1;
- disks[0].fname = strdup(info->path);
+ /* If this is an M3U file, attempt to set the
+ * initial disk image */
+ if (is_m3u && (disk_initial_index > 0) && (disk_initial_index < disk_count))
+ {
+ const char *fname = disks[disk_initial_index].fname;
+
+ if (fname && (*fname != '\0'))
+ if (strcmp(disk_initial_path, fname) == 0)
+ cd_index = disk_initial_index;
+
+ /* If we are not loading the first disk in the
+ * M3U list, update the content_path string
+ * that will be passed to PicoLoadMedia() */
+ if (cd_index != 0)
+ {
+ strncpy(content_path, disks[cd_index].fname, sizeof(content_path));
+ content_path[sizeof(content_path) - 1] = '\0';
+ }
+ }
make_system_path(carthw_path, sizeof(carthw_path), "carthw", ".cfg");
- media_type = PicoLoadMedia(info->path, carthw_path,
- find_bios, NULL);
+ media_type = PicoLoadMedia(content_path, content_data, content_size,
+ carthw_path, find_bios, NULL);
+
+ disk_current_index = cd_index;
switch (media_type) {
case PM_BAD_DETECT:
break;
}
- if (media_type == PM_MARK3)
+ if (PicoIn.AHW & PAHW_PICO)
+ environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc_pico);
+ else if (PicoIn.AHW & PAHW_SMS)
environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc_sms);
else
environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc);
init_frameskip();
}
+void emu_status_msg(const char *format, ...)
+{
+ va_list vl;
+ int ret;
+ static char msg[512];
+
+ memset (msg, 0, sizeof(msg));
+
+ va_start(vl, format);
+ ret = vsnprintf(msg, sizeof(msg), format, vl);
+ va_end(vl);
+
+ static struct retro_message rmsg;
+ rmsg.msg = msg;
+ rmsg.frames = 600;
+ environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, &rmsg);
+}
+
+void run_events_pico(unsigned int events)
+{
+ int lim_x;
+
+ if (events & (1 << RETRO_DEVICE_ID_JOYPAD_SELECT)) {
+ pico_inp_mode++;
+ if (pico_inp_mode > 2)
+ pico_inp_mode = 0;
+ switch (pico_inp_mode) {
+ case 2: emu_status_msg("Input: Pen on Pad"); break;
+ case 1: emu_status_msg("Input: Pen on Storyware"); break;
+ case 0: emu_status_msg("Input: Joystick");
+ PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;
+ break;
+ }
+ }
+ if (events & (1 << RETRO_DEVICE_ID_JOYPAD_L)) {
+ PicoPicohw.page--;
+ if (PicoPicohw.page < 0)
+ PicoPicohw.page = 0;
+ emu_status_msg("Page %i", PicoPicohw.page);
+ }
+ if (events & (1 << RETRO_DEVICE_ID_JOYPAD_R)) {
+ PicoPicohw.page++;
+ if (PicoPicohw.page > 6)
+ PicoPicohw.page = 6;
+ emu_status_msg("Page %i", PicoPicohw.page);
+ }
+
+ if (pico_inp_mode == 0)
+ return;
+
+ /* handle other input modes */
+ if (PicoIn.pad[0] & 1) pico_pen_y--;
+ if (PicoIn.pad[0] & 2) pico_pen_y++;
+ if (PicoIn.pad[0] & 4) pico_pen_x--;
+ if (PicoIn.pad[0] & 8) pico_pen_x++;
+ PicoIn.pad[0] &= ~0x0f; // release UDLR
+
+ lim_x = (Pico.video.reg[12]&1) ? 319 : 255;
+ if (pico_pen_y < 8)
+ pico_pen_y = 8;
+ if (pico_pen_y > 224 - PICO_PEN_ADJUST_Y)
+ pico_pen_y = 224 - PICO_PEN_ADJUST_Y;
+ if (pico_pen_x < 0)
+ pico_pen_x = 0;
+ if (pico_pen_x > lim_x - PICO_PEN_ADJUST_X)
+ pico_pen_x = lim_x - PICO_PEN_ADJUST_X;
+
+ PicoPicohw.pen_pos[0] = pico_pen_x;
+ if (!(Pico.video.reg[12] & 1))
+ PicoPicohw.pen_pos[0] += pico_pen_x / 4;
+ PicoPicohw.pen_pos[0] += 0x3c;
+ PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y);
+}
+
void retro_run(void)
{
bool updated = false;
int pad, i, padcount;
static void *buff;
- int16_t input;
PicoIn.skipFrame = 0;
input_poll_cb();
PicoIn.pad[0] = PicoIn.pad[1] = PicoIn.pad[2] = PicoIn.pad[3] = 0;
- padcount = has_4_pads && !(PicoIn.AHW & (PAHW_SMS|PAHW_PICO)) ? 4 : 2;
- for (pad = 0; pad < padcount; pad++) {
- if (libretro_supports_bitmasks) {
- input = input_state_cb(pad, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_MASK);
- for (i = 0; i < RETRO_PICO_MAP_LEN; i++)
- if (input & (1 << i))
- PicoIn.pad[pad] |= retro_pico_map[i];
- } else {
+ if (PicoIn.AHW & PAHW_PICO)
+ padcount = 1;
+ else if (PicoIn.AHW & PAHW_SMS)
+ padcount = 2;
+ else
+ padcount = has_4_pads ? 4 : 2;
+
+ int16_t input[4] = {0, 0};
+
+ if (libretro_supports_bitmasks)
+ {
+ for (pad = 0; pad < padcount; pad++)
+ {
+ input[pad] = input_state_cb(
+ pad, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_MASK);
+ }
+ }
+ else
+ {
+ for (pad = 0; pad < padcount; pad++)
+ {
for (i = 0; i < RETRO_PICO_MAP_LEN; i++)
if (input_state_cb(pad, RETRO_DEVICE_JOYPAD, 0, i))
- PicoIn.pad[pad] |= retro_pico_map[i];
+ input[pad] |= 1 << i;
}
}
+ for (pad = 0; pad < padcount; pad++)
+ for (i = 0; i < RETRO_PICO_MAP_LEN; i++)
+ if (input[pad] & (1 << i))
+ PicoIn.pad[pad] |= retro_pico_map[i];
+
+ if (PicoIn.AHW == PAHW_PICO) {
+ uint16_t ev = input[0] & ((1 << RETRO_DEVICE_ID_JOYPAD_L) | (1 << RETRO_DEVICE_ID_JOYPAD_R) | (1 << RETRO_DEVICE_ID_JOYPAD_SELECT));
+ uint16_t new_ev = ev & ~pico_events;
+ pico_events = ev;
+ run_events_pico(new_ev);
+ }
+
if (PicoPatches)
PicoPatchApply();
buff = (char*)vout_buf + vout_offset;
#endif
- video_cb((short *)buff,
- vout_width, vout_height, vout_width * 2);
+ video_cb((short *)buff, vout_width, vout_height, vout_width * 2);
}
void retro_init(void)
{
+ unsigned dci_version = 0;
struct retro_log_callback log;
int level;
if (environ_cb(RETRO_ENVIRONMENT_GET_INPUT_BITMASKS, NULL))
libretro_supports_bitmasks = true;
+ disk_initial_index = 0;
+ disk_initial_path[0] = '\0';
+ if (environ_cb(RETRO_ENVIRONMENT_GET_DISK_CONTROL_INTERFACE_VERSION, &dci_version) && (dci_version >= 1))
+ environ_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE, &disk_control_ext);
+ else
+ environ_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE, &disk_control);
+
#ifdef _3DS
ctr_svchack_successful = ctr_svchack_init();
check_rosalina();
PicoExit();
- for (i = 0; i < sizeof(disks) / sizeof(disks[0]); i++) {
- if (disks[i].fname != NULL) {
- free(disks[i].fname);
- disks[i].fname = NULL;
- }
- }
+ disk_init();
libretro_supports_bitmasks = false;
}
"picodrive_audio_filter",
"Audio Filter",
NULL,
- "Enable a low pass audio filter to better simulate the characteristic sound of a Model 1 Mega Drive/Genesis. Note that although only the Genesis and its add-on hardware (Sega CD, 32X) employed a physical low pass filter, the filter setting is not restricted to that.",
+ "Enable a low pass audio filter to better simulate the characteristic sound of a Model 1 Mega Drive/Genesis. Note that only Model 1 and its add-ons (Sega CD, 32X) employed a physical low pass filter.",
NULL,
"audio",
{
\r
void pemu_validate_config(void)\r
{\r
-#if !defined(__arm__) && !defined(__aarch64__) && !defined(__mips__) && !defined(__riscv__) && !defined(__riscv) && !defined(__powerpc__) && !defined(__ppc__) && !defined(__i386__) && !defined(__x86_64__)\r
+#if !defined(__arm__) && !defined(__aarch64__) && !defined(__mips__) && !defined(__riscv__) && !defined(__riscv) && !defined(__powerpc__) && !defined(__ppc__) && !defined(__PPC__) && !defined(__i386__) && !defined(__x86_64__)\r
PicoIn.opt &= ~POPT_EN_DRC;\r
#endif\r
}\r
return (const char*)s->msg;
}
+#if 0
/* ===========================================================================
Clear the error and end-of-file flags, and do the same for the real file.
*/
s->z_eof = 0;
clearerr(s->file);
}
+#endif