From 901e74f2174d7cd997d6a5704cd1200d22bb562f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 31 Oct 2013 16:10:21 +0100 Subject: [PATCH 001/124] (Android JNI) Compile only armeabi-v7a binary for now --- jni/Application.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jni/Application.mk b/jni/Application.mk index a252a72d..850a82e2 100644 --- a/jni/Application.mk +++ b/jni/Application.mk @@ -1 +1 @@ -APP_ABI := all +APP_ABI := armeabi-v7a From a559cfae9c5388c9a791eced4117f83c0a417230 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 30 Nov 2013 02:31:42 +0100 Subject: [PATCH 002/124] (iOS) Add min SDK version flags --- Makefile.libretro | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index 87360482..e6229d51 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -39,12 +39,12 @@ else ifeq ($(platform), ios) TARGET := $(TARGET_NAME)_libretro_ios.dylib SHARED := -dynamiclib - CC = clang -arch armv7 -isysroot $(IOSSDK) - CXX = clang++ -arch armv7 -isysroot $(IOSSDK) - CC_AS = perl ./tools/gas-preprocessor.pl $(CC) - CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm + CC = clang -arch armv7 -isysroot $(IOSSDK) -miphoneos-version-min=5.0 + CXX = clang++ -arch armv7 -isysroot $(IOSSDK) -miphoneos-version-min=5.0 + CC_AS = perl ./tools/gas-preprocessor.pl $(CC) -miphoneos-version-min=5.0 + CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon - CFLAGS += -DIOS + CFLAGS += -DIOS -miphoneos-version-min=5.0 ARCH := arm From 0b45bd3e5c53ede3c5ea23ed7ce97e42c249f669 Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 7 Dec 2013 02:03:38 +0200 Subject: [PATCH 003/124] try to deal with some famec compiler issues --- cpu/fame/famec.c | 12 +++++++++++- jni/Android.mk | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cpu/fame/famec.c b/cpu/fame/famec.c index 2f10540d..9e9dc153 100644 --- a/cpu/fame/famec.c +++ b/cpu/fame/famec.c @@ -35,7 +35,17 @@ #define PICODRIVE_HACK // Options // - +#ifndef FAMEC_NO_GOTOS +// computed gotos is a GNU extension +#ifndef __GNUC__ +#define FAMEC_NO_GOTOS +#endif +// as of 3.3, clang takes over 3h to compile this in computed goto mode.. +#ifdef __clang__ +#define FAMEC_NO_GOTOS +#endif +#endif + #undef INLINE #ifdef _MSC_VER #define INLINE diff --git a/jni/Android.mk b/jni/Android.mk index 72a81634..122b18e8 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -73,8 +73,9 @@ LOCAL_SRC_FILES += $(R)unzip/unzip.c $(R)unzip/unzip_stream.c LOCAL_C_INCLUDES += $(R) +# note: don't use -O3, causes some NDKs run out of memory while compiling FAME +LOCAL_CFLAGS += -Wall -O2 -ffast-math -DNDEBUG LOCAL_CFLAGS += $(addprefix -D,$(DEFINES)) -LOCAL_CFLAGS += -Wall -O3 -ffast-math -DNDEBUG LOCAL_LDLIBS := -llog include $(BUILD_SHARED_LIBRARY) From ac9abd01bf28cc83187d7c2d5004716402d16e02 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Dec 2013 22:25:38 +0100 Subject: [PATCH 004/124] (Clang) Linker fix --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index c199b853..d31779cc 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,10 @@ CFLAGS += -Wall -ggdb -falign-functions=2 CFLAGS += -I. ifndef DEBUG CFLAGS += -O2 -DNDEBUG -ffunction-sections +ifeq ($(findstring clang,$(CC)),) LDFLAGS += -Wl,--gc-sections endif +endif #CFLAGS += -DEVT_LOG #CFLAGS += -DDRC_CMP #cpu_cmp = 1 From d543646d2ff7e6eb650984f9da1ed0727d0af33e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Dec 2013 02:41:42 +0100 Subject: [PATCH 005/124] (Android JNI) Have MIPS and x86 versions as well --- jni/Application.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jni/Application.mk b/jni/Application.mk index 850a82e2..222106ec 100644 --- a/jni/Application.mk +++ b/jni/Application.mk @@ -1 +1 @@ -APP_ABI := armeabi-v7a +APP_ABI := armeabi-v7a mips x86 From f5d4045b92e929e8d31ffa4fe426cbf6bf31624c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 17 Dec 2013 12:20:16 +0100 Subject: [PATCH 006/124] (libretro) Go through new logger interface --- platform/libretro.c | 110 +++++++++---------- platform/libretro.h | 251 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 295 insertions(+), 66 deletions(-) mode change 100644 => 100755 platform/libretro.h diff --git a/platform/libretro.c b/platform/libretro.c index 23f0694e..67b4369c 100644 --- a/platform/libretro.c +++ b/platform/libretro.c @@ -28,14 +28,13 @@ #include "common/version.h" #include "libretro.h" +static retro_log_printf_t log_cb; static retro_video_refresh_t video_cb; static retro_input_poll_t input_poll_cb; static retro_input_state_t input_state_cb; static retro_environment_t environ_cb; static retro_audio_sample_batch_t audio_batch_cb; -static FILE *emu_log; - #define VOUT_MAX_WIDTH 320 #define VOUT_MAX_HEIGHT 240 static void *vout_buf; @@ -176,13 +175,15 @@ void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed) req = (void *)addr; ret = mmap(req, size, PROT_READ | PROT_WRITE, flags, -1, 0); if (ret == MAP_FAILED) { - lprintf("mmap(%08lx, %zd) failed: %d\n", addr, size, errno); + if (log_cb) + log_cb(RETRO_LOG_ERROR, "mmap(%08lx, %zd) failed: %d\n", addr, size, errno); return NULL; } if (addr != 0 && ret != (void *)addr) { - lprintf("warning: wanted to map @%08lx, got %p\n", - addr, ret); + if (log_cb) + log_cb(RETRO_LOG_WARN, "warning: wanted to map @%08lx, got %p\n", + addr, ret); if (is_fixed) { munmap(ret, size); @@ -236,12 +237,12 @@ int plat_mem_set_exec(void *ptr, size_t size) { #ifdef _WIN32 int ret = VirtualProtect(ptr,size,PAGE_EXECUTE_READWRITE,0); - if (ret == 0) - lprintf("mprotect(%p, %zd) failed: %d\n", ptr, size, 0); + if (ret == 0 && log_cb) + log_cb(RETRO_LOG_ERROR, "mprotect(%p, %zd) failed: %d\n", ptr, size, 0); #else int ret = mprotect(ptr, size, PROT_READ | PROT_WRITE | PROT_EXEC); - if (ret != 0) - lprintf("mprotect(%p, %zd) failed: %d\n", ptr, size, errno); + if (ret != 0 && log_cb) + log_cb(RETRO_LOG_ERROR, "mprotect(%p, %zd) failed: %d\n", ptr, size, errno); #endif return ret; } @@ -260,34 +261,13 @@ void emu_32x_startup(void) { } -#ifndef ANDROID - void lprintf(const char *fmt, ...) { - va_list list; - - va_start(list, fmt); - fprintf(emu_log, "PicoDrive: "); - vfprintf(emu_log, fmt, list); - va_end(list); - fflush(emu_log); + /* TODO - add 'level' param for warning/error messages? */ + if (log_cb) + log_cb(RETRO_LOG_INFO, fmt); } -#else - -#include - -void lprintf(const char *fmt, ...) -{ - va_list list; - - va_start(list, fmt); - __android_log_vprint(ANDROID_LOG_INFO, "PicoDrive", fmt, list); - va_end(list); -} - -#endif - /* libretro */ void retro_set_environment(retro_environment_t cb) { @@ -358,8 +338,9 @@ size_t state_read(void *p, size_t size, size_t nmemb, void *file) size_t bsize = size * nmemb; if (state->pos + bsize > state->size) { - lprintf("savestate error: %u/%u\n", - state->pos + bsize, state->size); + if (log_cb) + log_cb(RETRO_LOG_ERROR, "savestate error: %u/%u\n", + state->pos + bsize, state->size); bsize = state->size - state->pos; if ((int)bsize <= 0) return 0; @@ -376,8 +357,9 @@ size_t state_write(void *p, size_t size, size_t nmemb, void *file) size_t bsize = size * nmemb; if (state->pos + bsize > state->size) { - lprintf("savestate error: %u/%u\n", - state->pos + bsize, state->size); + if (log_cb) + log_cb(RETRO_LOG_ERROR, "savestate error: %u/%u\n", + state->pos + bsize, state->size); bsize = state->size - state->pos; if ((int)bsize <= 0) return 0; @@ -507,7 +489,8 @@ static bool disk_set_image_index(unsigned int index) return false; if (disks[index].fname == NULL) { - lprintf("missing disk #%u\n", index); + if (log_cb) + log_cb(RETRO_LOG_ERROR, "missing disk #%u\n", index); // RetroArch specifies "no disk" with index == count, // so don't fail here.. @@ -515,15 +498,17 @@ static bool disk_set_image_index(unsigned int index) return true; } - lprintf("switching to disk %u: \"%s\"\n", index, - disks[index].fname); + if (log_cb) + log_cb(RETRO_LOG_INFO, "switching to disk %u: \"%s\"\n", index, + disks[index].fname); ret = -1; cd_type = PicoCdCheck(disks[index].fname, NULL); if (cd_type != CIT_NOT_CD) ret = cdd_load(disks[index].fname, cd_type); if (ret != 0) { - lprintf("Load failed, invalid CD image?\n"); + if (log_cb) + log_cb(RETRO_LOG_ERROR, "Load failed, invalid CD image?\n"); return 0; } @@ -578,13 +563,15 @@ static struct retro_disk_control_callback disk_control = { static void disk_tray_open(void) { - lprintf("cd tray open\n"); + if (log_cb) + log_cb(RETRO_LOG_INFO, "cd tray open\n"); disk_ejected = 1; } static void disk_tray_close(void) { - lprintf("cd tray close\n"); + if (log_cb) + log_cb(RETRO_LOG_INFO, "cd tray close\n"); disk_ejected = 0; } @@ -646,7 +633,8 @@ static const char *find_bios(int *region, const char *cd_fname) } if (f != NULL) { - lprintf("using bios: %s\n", path); + if (log_cb) + log_cb(RETRO_LOG_INFO, "using bios: %s\n", path); fclose(f); return path; } @@ -662,12 +650,14 @@ bool retro_load_game(const struct retro_game_info *info) enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) { - lprintf("RGB565 support required, sorry\n"); + if (log_cb) + log_cb(RETRO_LOG_ERROR, "RGB565 support required, sorry\n"); return false; } if (info == NULL || info->path == NULL) { - lprintf("info->path required\n"); + if (log_cb) + log_cb(RETRO_LOG_ERROR, "info->path required\n"); return false; } @@ -689,16 +679,20 @@ bool retro_load_game(const struct retro_game_info *info) switch (media_type) { case PM_BAD_DETECT: - lprintf("Failed to detect ROM/CD image type.\n"); + if (log_cb) + log_cb(RETRO_LOG_ERROR, "Failed to detect ROM/CD image type.\n"); return false; case PM_BAD_CD: - lprintf("Invalid CD image\n"); + if (log_cb) + log_cb(RETRO_LOG_ERROR, "Invalid CD image\n"); return false; case PM_BAD_CD_NO_BIOS: - lprintf("Missing BIOS\n"); + if (log_cb) + log_cb(RETRO_LOG_ERROR, "Missing BIOS\n"); return false; case PM_ERROR: - lprintf("Load error\n"); + if (log_cb) + log_cb(RETRO_LOG_ERROR, "Load error\n"); return false; default: break; @@ -797,7 +791,8 @@ static enum input_device input_name_to_val(const char *name) if (strcmp(name, "None") == 0) return PICO_INPUT_NOTHING; - lprintf("invalid picodrive_input: '%s'\n", name); + if (log_cb) + log_cb(RETRO_LOG_WARN, "invalid picodrive_input: '%s'\n", name); return PICO_INPUT_PAD_3BTN; } @@ -869,19 +864,16 @@ void retro_run(void) void retro_init(void) { + struct retro_log_callback log; int level; -#ifdef IOS - emu_log = fopen("/User/Documents/PicoDrive.log", "w"); - if (emu_log == NULL) - emu_log = fopen("PicoDrive.log", "w"); - if (emu_log == NULL) -#endif - emu_log = stdout; - level = 0; environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level); + environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log); + if (log.log) + log_cb = log.log; + environ_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE, &disk_control); PicoOpt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 diff --git a/platform/libretro.h b/platform/libretro.h old mode 100644 new mode 100755 index ff4f4fd9..aaff3484 --- a/platform/libretro.h +++ b/platform/libretro.h @@ -94,6 +94,9 @@ extern "C" { // Eventually _PRESSED will return false for an index. No further presses are registered at this point. #define RETRO_DEVICE_POINTER 6 +// FIXME: Document this. +#define RETRO_DEVICE_SENSOR_ACCELEROMETER 7 + // These device types are specializations of the base types above. // They should only be used in retro_set_controller_type() to inform libretro implementations // about use of a very specific device type. @@ -150,6 +153,11 @@ extern "C" { #define RETRO_DEVICE_ID_POINTER_Y 1 #define RETRO_DEVICE_ID_POINTER_PRESSED 2 +// Id values for SENSOR types. +#define RETRO_DEVICE_ID_SENSOR_ACCELEROMETER_X 0 +#define RETRO_DEVICE_ID_SENSOR_ACCELEROMETER_Y 1 +#define RETRO_DEVICE_ID_SENSOR_ACCELEROMETER_Z 2 + // Returned from retro_get_region(). #define RETRO_REGION_NTSC 0 #define RETRO_REGION_PAL 1 @@ -357,6 +365,8 @@ enum retro_mod // If set, this call is not part of the public libretro API yet. It can change or be removed at any time. #define RETRO_ENVIRONMENT_EXPERIMENTAL 0x10000 +// Environment callback to be used internally in frontend. +#define RETRO_ENVIRONMENT_PRIVATE 0x20000 // Environment commands. #define RETRO_ENVIRONMENT_SET_ROTATION 1 // const unsigned * -- @@ -434,10 +444,8 @@ enum retro_mod // Sets an interface which frontend can use to eject and insert disk images. // This is used for games which consist of multiple images and must be manually // swapped out by the user (e.g. PSX). -#define RETRO_ENVIRONMENT_SET_HW_RENDER (14 | RETRO_ENVIRONMENT_EXPERIMENTAL) +#define RETRO_ENVIRONMENT_SET_HW_RENDER 14 // struct retro_hw_render_callback * -- - // NOTE: This call is currently very experimental, and should not be considered part of the public API. - // The interface could be changed or removed at any time. // Sets an interface to let a libretro core render with hardware acceleration. // Should be called in retro_load_game(). // If successful, libretro cores will be able to render to a frontend-provided framebuffer. @@ -445,7 +453,7 @@ enum retro_mod // If HW rendering is used, pass only RETRO_HW_FRAME_BUFFER_VALID or NULL to retro_video_refresh_t. #define RETRO_ENVIRONMENT_GET_VARIABLE 15 // struct retro_variable * -- - // Interface to aquire user-defined information from environment + // Interface to acquire user-defined information from environment // that cannot feasibly be supported in a multi-system way. // 'key' should be set to a key which has already been set by SET_VARIABLES. // 'data' will be set to a value or NULL. @@ -480,13 +488,222 @@ enum retro_mod // If true, the libretro implementation supports calls to retro_load_game() with NULL as argument. // Used by cores which can run without particular game data. // This should be called within retro_set_environment() only. - + // +#define RETRO_ENVIRONMENT_GET_LIBRETRO_PATH 19 + // const char ** -- + // Retrieves the absolute path from where this libretro implementation was loaded. + // NULL is returned if the libretro was loaded statically (i.e. linked statically to frontend), or if the path cannot be determined. + // Mostly useful in cooperation with SET_SUPPORT_NO_GAME as assets can be loaded without ugly hacks. + // + // +// Environment 20 was an obsolete version of SET_AUDIO_CALLBACK. It was not used by any known core at the time, +// and was removed from the API. +#define RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK 22 + // const struct retro_audio_callback * -- + // Sets an interface which is used to notify a libretro core about audio being available for writing. + // The callback can be called from any thread, so a core using this must have a thread safe audio implementation. + // It is intended for games where audio and video are completely asynchronous and audio can be generated on the fly. + // This interface is not recommended for use with emulators which have highly synchronous audio. + // + // The callback only notifies about writability; the libretro core still has to call the normal audio callbacks + // to write audio. The audio callbacks must be called from within the notification callback. + // The amount of audio data to write is up to the implementation. + // Generally, the audio callback will be called continously in a loop. + // + // Due to thread safety guarantees and lack of sync between audio and video, a frontend + // can selectively disallow this interface based on internal configuration. A core using + // this interface must also implement the "normal" audio interface. + // + // A libretro core using SET_AUDIO_CALLBACK should also make use of SET_FRAME_TIME_CALLBACK. +#define RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK 21 + // const struct retro_frame_time_callback * -- + // Lets the core know how much time has passed since last invocation of retro_run(). + // The frontend can tamper with the timing to fake fast-forward, slow-motion, frame stepping, etc. + // In this case the delta time will use the reference value in frame_time_callback.. + // +#define RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE 23 + // struct retro_rumble_interface * -- + // Gets an interface which is used by a libretro core to set state of rumble motors in controllers. + // A strong and weak motor is supported, and they can be controlled indepedently. + // +#define RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES 24 + // uint64_t * -- + // Gets a bitmask telling which device type are expected to be handled properly in a call to retro_input_state_t. + // Devices which are not handled or recognized always return 0 in retro_input_state_t. + // Example bitmask: caps = (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG). + // Should only be called in retro_run(). + // +#define RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE (25 | RETRO_ENVIRONMENT_EXPERIMENTAL) + // struct retro_sensor_interface * -- + // Gets access to the sensor interface. + // The purpose of this interface is to allow + // setting state related to sensors such as polling rate, enabling/disable it entirely, etc. + // Reading sensor state is done via the normal input_state_callback API. + // +#define RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE (26 | RETRO_ENVIRONMENT_EXPERIMENTAL) + // struct retro_camera_callback * -- + // Gets an interface to a video camera driver. + // A libretro core can use this interface to get access to a video camera. + // New video frames are delivered in a callback in same thread as retro_run(). + // + // GET_CAMERA_INTERFACE should be called in retro_load_game(). + // + // Depending on the camera implementation used, camera frames will be delivered as a raw framebuffer, + // or as an OpenGL texture directly. + // + // The core has to tell the frontend here which types of buffers can be handled properly. + // An OpenGL texture can only be handled when using a libretro GL core (SET_HW_RENDER). + // It is recommended to use a libretro GL core when using camera interface. + // + // The camera is not started automatically. The retrieved start/stop functions must be used to explicitly + // start and stop the camera driver. + // +#define RETRO_ENVIRONMENT_GET_LOG_INTERFACE 27 + // struct retro_log_callback * -- + // Gets an interface for logging. This is useful for logging in a cross-platform way + // as certain platforms cannot use use stderr for logging. It also allows the frontend to + // show logging information in a more suitable way. + // If this interface is not used, libretro cores should log to stderr as desired. + +enum retro_log_level +{ + RETRO_LOG_DEBUG = 0, + RETRO_LOG_INFO, + RETRO_LOG_WARN, + RETRO_LOG_ERROR, + + RETRO_LOG_DUMMY = INT_MAX +}; + +// Logging function. Takes log level argument as well. +typedef void (*retro_log_printf_t)(enum retro_log_level level, const char *fmt, ...); + +struct retro_log_callback +{ + retro_log_printf_t log; +}; + +// FIXME: Document the sensor API and work out behavior. +// It will be marked as experimental until then. +enum retro_sensor_action +{ + RETRO_SENSOR_ACCELEROMETER_ENABLE = 0, + RETRO_SENSOR_ACCELEROMETER_DISABLE, + + RETRO_SENSOR_DUMMY = INT_MAX +}; + +typedef bool (*retro_set_sensor_state_t)(unsigned port, enum retro_sensor_action action, unsigned rate); +struct retro_sensor_interface +{ + retro_set_sensor_state_t set_sensor_state; +}; +//// + +enum retro_camera_buffer +{ + RETRO_CAMERA_BUFFER_OPENGL_TEXTURE = 0, + RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER, + + RETRO_CAMERA_BUFFER_DUMMY = INT_MAX +}; + +// Starts the camera driver. Can only be called in retro_run(). +typedef bool (*retro_camera_start_t)(void); +// Stops the camera driver. Can only be called in retro_run(). +typedef void (*retro_camera_stop_t)(void); +// Callback which signals when the camera driver is initialized and/or deinitialized. +// retro_camera_start_t can be called in initialized callback. +typedef void (*retro_camera_lifetime_status_t)(void); +// A callback for raw framebuffer data. buffer points to an XRGB8888 buffer. +// Width, height and pitch are similar to retro_video_refresh_t. +// First pixel is top-left origin. +typedef void (*retro_camera_frame_raw_framebuffer_t)(const uint32_t *buffer, unsigned width, unsigned height, size_t pitch); +// A callback for when OpenGL textures are used. +// +// texture_id is a texture owned by camera driver. +// Its state or content should be considered immutable, except for things like texture filtering and clamping. +// +// texture_target is the texture target for the GL texture. +// These can include e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, and possibly more depending on extensions. +// +// affine points to a packed 3x3 column-major matrix used to apply an affine transform to texture coordinates. (affine_matrix * vec3(coord_x, coord_y, 1.0)) +// After transform, normalized texture coord (0, 0) should be bottom-left and (1, 1) should be top-right (or (width, height) for RECTANGLE). +// +// GL-specific typedefs are avoided here to avoid relying on gl.h in the API definition. +typedef void (*retro_camera_frame_opengl_texture_t)(unsigned texture_id, unsigned texture_target, const float *affine); +struct retro_camera_callback +{ + uint64_t caps; // Set by libretro core. Example bitmask: caps = (1 << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE) | (1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER). + + unsigned width; // Desired resolution for camera. Is only used as a hint. + unsigned height; + retro_camera_start_t start; // Set by frontend. + retro_camera_stop_t stop; // Set by frontend. + + retro_camera_frame_raw_framebuffer_t frame_raw_framebuffer; // Set by libretro core if raw framebuffer callbacks will be used. + retro_camera_frame_opengl_texture_t frame_opengl_texture; // Set by libretro core if OpenGL texture callbacks will be used. + + // Set by libretro core. Called after camera driver is initialized and ready to be started. + // Can be NULL, in which this callback is not called. + retro_camera_lifetime_status_t initialized; + + // Set by libretro core. Called right before camera driver is deinitialized. + // Can be NULL, in which this callback is not called. + retro_camera_lifetime_status_t deinitialized; +}; + +enum retro_rumble_effect +{ + RETRO_RUMBLE_STRONG = 0, + RETRO_RUMBLE_WEAK = 1, + + RETRO_RUMBLE_DUMMY = INT_MAX +}; + +// Sets rumble state for joypad plugged in port 'port'. Rumble effects are controlled independently, +// and setting e.g. strong rumble does not override weak rumble. +// Strength has a range of [0, 0xffff]. +// +// Returns true if rumble state request was honored. Calling this before first retro_run() is likely to return false. +typedef bool (*retro_set_rumble_state_t)(unsigned port, enum retro_rumble_effect effect, uint16_t strength); +struct retro_rumble_interface +{ + retro_set_rumble_state_t set_rumble_state; +}; + +// Notifies libretro that audio data should be written. +typedef void (*retro_audio_callback_t)(void); + +// True: Audio driver in frontend is active, and callback is expected to be called regularily. +// False: Audio driver in frontend is paused or inactive. Audio callback will not be called until set_state has been called with true. +// Initial state is false (inactive). +typedef void (*retro_audio_set_state_callback_t)(bool enabled); +struct retro_audio_callback +{ + retro_audio_callback_t callback; + retro_audio_set_state_callback_t set_state; +}; + +// Notifies a libretro core of time spent since last invocation of retro_run() in microseconds. +// It will be called right before retro_run() every frame. +// The frontend can tamper with timing to support cases like fast-forward, slow-motion and framestepping. +// In those scenarios the reference frame time value will be used. +typedef int64_t retro_usec_t; +typedef void (*retro_frame_time_callback_t)(retro_usec_t usec); +struct retro_frame_time_callback +{ + retro_frame_time_callback_t callback; + retro_usec_t reference; // Represents the time of one frame. It is computed as 1000000 / fps, but the implementation will resolve the rounding to ensure that framestepping, etc is exact. +}; // Pass this to retro_video_refresh_t if rendering to hardware. // Passing NULL to retro_video_refresh_t is still a frame dupe as normal. #define RETRO_HW_FRAME_BUFFER_VALID ((void*)-1) // Invalidates the current HW context. +// Any GL state is lost, and must not be deinitialized explicitly. If explicit deinitialization is desired by the libretro core, +// it should implement context_destroy callback. // If called, all GPU resources must be reinitialized. // Usually called when frontend reinits video driver. // Also called first time video driver is initialized, allowing libretro core to init resources. @@ -501,8 +718,10 @@ typedef retro_proc_address_t (*retro_hw_get_proc_address_t)(const char *sym); enum retro_hw_context_type { RETRO_HW_CONTEXT_NONE = 0, - RETRO_HW_CONTEXT_OPENGL, // OpenGL 2.x. Latest version available before 3.x+. + RETRO_HW_CONTEXT_OPENGL, // OpenGL 2.x. Latest version available before 3.x+. Driver can choose to use latest compatibility context. RETRO_HW_CONTEXT_OPENGLES2, // GLES 2.0 + RETRO_HW_CONTEXT_OPENGL_CORE, // Modern desktop core GL context. Use major/minor fields to set GL version. + RETRO_HW_CONTEXT_OPENGLES3, // GLES 3.0 RETRO_HW_CONTEXT_DUMMY = INT_MAX }; @@ -510,10 +729,21 @@ enum retro_hw_context_type struct retro_hw_render_callback { enum retro_hw_context_type context_type; // Which API to use. Set by libretro core. - retro_hw_context_reset_t context_reset; // Set by libretro core. + retro_hw_context_reset_t context_reset; // Called when a context has been created or when it has been reset. retro_hw_get_current_framebuffer_t get_current_framebuffer; // Set by frontend. retro_hw_get_proc_address_t get_proc_address; // Set by frontend. bool depth; // Set if render buffers should have depth component attached. + bool stencil; // Set if stencil buffers should be attached. + // If depth and stencil are true, a packed 24/8 buffer will be added. Only attaching stencil is invalid and will be ignored. + bool bottom_left_origin; // Use conventional bottom-left origin convention. Is false, standard libretro top-left origin semantics are used. + unsigned version_major; // Major version number for core GL context. + unsigned version_minor; // Minor version number for core GL context. + + bool cache_context; // If this is true, the frontend will go very far to avoid resetting context in scenarios like toggling fullscreen, etc. + // The reset callback might still be called in extreme situations such as if the context is lost beyond recovery. + // For optimal stability, set this to false, and allow context to be reset at any time. + retro_hw_context_reset_t context_destroy; // A callback to be called before the context is destroyed. Resources can be deinitialized at this step. This can be set to NULL, in which resources will just be destroyed without any notification. + bool debug_context; // Creates a debug context. }; // Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK. Called by the frontend in response to keyboard events. @@ -521,6 +751,13 @@ struct retro_hw_render_callback // keycode is the RETROK value of the char. // character is the text character of the pressed key. (UTF-32). // key_modifiers is a set of RETROKMOD values or'ed together. +// +// The pressed/keycode state can be indepedent of the character. +// It is also possible that multiple characters are generated from a single keypress. +// Keycode events should be treated separately from character events. +// However, when possible, the frontend should try to synchronize these. +// If only a character is posted, keycode should be RETROK_UNKNOWN. +// Similarily if only a keycode event is generated with no corresponding character, character should be 0. typedef void (*retro_keyboard_event_t)(bool down, unsigned keycode, uint32_t character, uint16_t key_modifiers); struct retro_keyboard_callback From 033a505e6e897779f6ccdfaea7a2b4932521d7ef Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Dec 2013 20:41:37 +0100 Subject: [PATCH 007/124] Update libretro.h --- platform/libretro.h | 90 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/platform/libretro.h b/platform/libretro.h index aaff3484..ede60f04 100755 --- a/platform/libretro.h +++ b/platform/libretro.h @@ -564,6 +564,10 @@ enum retro_mod // as certain platforms cannot use use stderr for logging. It also allows the frontend to // show logging information in a more suitable way. // If this interface is not used, libretro cores should log to stderr as desired. +#define RETRO_ENVIRONMENT_GET_PERF_INTERFACE 28 + // struct retro_perf_callback * -- + // Gets an interface for performance counters. This is useful for performance logging in a + // cross-platform way and for detecting architecture-specific features, such as SIMD support. enum retro_log_level { @@ -583,6 +587,92 @@ struct retro_log_callback retro_log_printf_t log; }; +// Performance related functions +// +// ID values for SIMD CPU features +#define RETRO_SIMD_SSE (1 << 0) +#define RETRO_SIMD_SSE2 (1 << 1) +#define RETRO_SIMD_VMX (1 << 2) +#define RETRO_SIMD_VMX128 (1 << 3) +#define RETRO_SIMD_AVX (1 << 4) +#define RETRO_SIMD_NEON (1 << 5) +#define RETRO_SIMD_SSE3 (1 << 6) +#define RETRO_SIMD_SSSE3 (1 << 7) + +typedef uint64_t retro_perf_tick_t; +typedef int64_t retro_time_t; + +struct retro_perf_counter +{ + const char *ident; + retro_perf_tick_t start; + retro_perf_tick_t total; + retro_perf_tick_t call_cnt; + + bool registered; +}; + +// Returns current time in microseconds. Tries to use the most accurate timer available. +typedef retro_time_t (*retro_perf_get_time_usec_t)(void); +// A simple counter. Usually nanoseconds, but can also be CPU cycles. +// Can be used directly if desired (when creating a more sophisticated performance counter system). +typedef retro_perf_tick_t (*retro_perf_get_counter_t)(void); +// Returns a bit-mask of detected CPU features (RETRO_SIMD_*). +typedef uint64_t (*retro_get_cpu_features_t)(void); +// Asks frontend to log and/or display the state of performance counters. +// Performance counters can always be poked into manually as well. +typedef void (*retro_perf_log_t)(void); +// Register a performance counter. +// ident field must be set with a discrete value and other values in retro_perf_counter must be 0. +// Registering can be called multiple times. To avoid calling to frontend redundantly, you can check registered field first. +typedef void (*retro_perf_register_t)(struct retro_perf_counter *counter); +// Starts and stops a registered counter. +typedef void (*retro_perf_start_t)(struct retro_perf_counter *counter); +typedef void (*retro_perf_stop_t)(struct retro_perf_counter *counter); + +// For convenience it can be useful to wrap register, start and stop in macros. +// E.g.: +// #ifdef LOG_PERFORMANCE +// #define RETRO_PERFORMANCE_INIT(perf_cb, name) static struct retro_perf_counter name = {#name}; if (!name.registered) perf_cb.perf_register(&(name)) +// #define RETRO_PERFORMANCE_START(perf_cb, name) perf_cb.perf_start(&(name)) +// #define RETRO_PERFORMANCE_STOP(perf_cb, name) perf_cb.perf_stop(&(name)) +// #else +// ... Blank macros ... +// #endif +// These can then be used mid-functions around code snippets. +// +// extern struct retro_perf_callback perf_cb; // Somewhere in the core. +// +// void do_some_heavy_work(void) +// { +// RETRO_PERFORMANCE_INIT(cb, work_1); +// RETRO_PERFORMANCE_START(cb, work_1); +// heavy_work_1(); +// RETRO_PERFORMANCE_STOP(cb, work_1); +// +// RETRO_PERFORMANCE_INIT(cb, work_2); +// RETRO_PERFORMANCE_START(cb, work_2); +// heavy_work_2(); +// RETRO_PERFORMANCE_STOP(cb, work_2); +// } +// +// void retro_deinit(void) +// { +// perf_cb.perf_log(); // Log all perf counters here for example. +// } + +struct retro_perf_callback +{ + retro_perf_get_time_usec_t get_time_usec; + retro_get_cpu_features_t get_cpu_features; + + retro_perf_get_counter_t get_perf_counter; + retro_perf_register_t perf_register; + retro_perf_start_t perf_start; + retro_perf_stop_t perf_stop; + retro_perf_log_t perf_log; +}; + // FIXME: Document the sensor API and work out behavior. // It will be marked as experimental until then. enum retro_sensor_action From c681e48d2b4faa0821138fabf6966683c84d07d6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 2 Jan 2014 02:44:39 +0100 Subject: [PATCH 008/124] (Libretro) Fixup logging --- platform/libretro.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/platform/libretro.c b/platform/libretro.c index 67b4369c..9ce13c5d 100644 --- a/platform/libretro.c +++ b/platform/libretro.c @@ -263,9 +263,13 @@ void emu_32x_startup(void) void lprintf(const char *fmt, ...) { + char buffer[256]; + va_list ap; + va_start(ap, fmt); + vsprintf(buffer, fmt, ap); /* TODO - add 'level' param for warning/error messages? */ if (log_cb) - log_cb(RETRO_LOG_INFO, fmt); + log_cb(RETRO_LOG_INFO, "%s\n", fmt); } /* libretro */ @@ -870,9 +874,10 @@ void retro_init(void) level = 0; environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level); - environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log); - if (log.log) + if (environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log)) log_cb = log.log; + else + log_cb = NULL; environ_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE, &disk_control); From fd90b67a304236e68b856bb2ac5a4827b706fe8c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 3 Jan 2014 17:45:03 +0100 Subject: [PATCH 009/124] (OSX) Set min OS version to 10.6 --- Makefile.libretro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index e6229d51..ec165cd9 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -34,7 +34,7 @@ ifeq ($(platform), unix) SHARED := -shared else ifeq ($(platform), osx) TARGET := $(TARGET_NAME)_libretro.dylib - SHARED := -dynamiclib + SHARED := -dynamiclib -mmacosx-version-min=10.6 else ifeq ($(platform), ios) TARGET := $(TARGET_NAME)_libretro_ios.dylib SHARED := -dynamiclib From f18d0e083ce89df07ef7a0c0cf5dc200638ad5d2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 4 Mar 2014 05:26:59 +0100 Subject: [PATCH 010/124] (PSP) Add PSP target --- Makefile | 4 ++++ Makefile.libretro | 13 +++++++++++++ platform/libretro.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/Makefile b/Makefile index d31779cc..9201afb0 100644 --- a/Makefile +++ b/Makefile @@ -176,7 +176,11 @@ clean: $(RM) -r .opk_data $(TARGET): $(OBJS) +ifeq ($(STATIC_LINKING), 1) + $(AR) rcs $@ $(OBJS) +else $(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) $(LDLIBS) +endif pprof: platform/linux/pprof.c $(CC) -O2 -ggdb -DPPROF -DPPROF_TOOL -I../../ -I. $^ -o $@ diff --git a/Makefile.libretro b/Makefile.libretro index ec165cd9..a2a4dafc 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -75,6 +75,19 @@ else ifeq ($(platform), psp1) CC = psp-gcc$(EXE_EXT) AR = psp-ar$(EXE_EXT) CFLAGS += -DPSP -G0 + STATIC_LINKING = 1 + +asm_memory = 0 +asm_render = 0 +asm_ym2612 = 0 +asm_misc = 0 +asm_cdpico = 0 +asm_cdmemory = 0 +asm_mix = 0 + use_cyclone = 0 + use_fame = 1 + use_drz80 = 0 + use_cz80 = 1 else ifeq ($(platform), xenon) TARGET := $(TARGET_NAME)_libretro_xenon360.a CC = xenon-gcc$(EXE_EXT) diff --git a/platform/libretro.c b/platform/libretro.c index 9ce13c5d..72b7a1be 100644 --- a/platform/libretro.c +++ b/platform/libretro.c @@ -6,12 +6,18 @@ * See COPYING file in the top-level directory. */ +#ifdef PSP +#define NO_MMAP +#endif + #define _GNU_SOURCE 1 // mremap #include #include #include #ifndef _WIN32 +#ifndef NO_MMAP #include +#endif #else #include #include @@ -161,6 +167,30 @@ static void munmap(void *addr, size_t length) UnmapViewOfFile(addr); /* ruh-ro, we leaked handle from CreateFileMapping() ... */ } +#elif defined(NO_MMAP) +#define PROT_EXEC 0x04 +#define MAP_FAILED 0 +#define PROT_READ 0 +#define PROT_WRITE 0 +#define MAP_PRIVATE 0 +#define MAP_ANONYMOUS 0 + +void* mmap(void *desired_addr, size_t len, int mmap_prot, int mmap_flags, int fildes, size_t off) +{ + return malloc(len); +} + +void munmap(void *base_addr, size_t len) +{ + free(base_addr); +} + +int mprotect(void *addr, size_t len, int prot) +{ + /* stub - not really needed at this point since this codepath has no dynarecs */ + return 0; +} + #endif #ifndef MAP_ANONYMOUS From bee555aeac5dae1cd0567606eb6d42cd1ca0ddc4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 4 Mar 2014 06:13:46 +0100 Subject: [PATCH 011/124] (PSP/PS3) Resolve namespace conflict with memcpy16 for PS3 - Fix remaining PSP build problems --- Makefile | 2 ++ Makefile.libretro | 67 +++++++++++++++++++++++++++++++++++++++------ pico/misc.c | 2 +- pico/misc_arm.s | 4 +-- pico/pico_int.h | 2 +- pico/videoport.c | 2 +- platform/libretro.c | 4 --- 7 files changed, 66 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 9201afb0..633f0bc9 100644 --- a/Makefile +++ b/Makefile @@ -152,10 +152,12 @@ else OBJS += platform/common/mp3_dummy.o endif +ifneq "$(DONT_COMPILE_IN_ZLIB)" "1" # zlib OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \ zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o zlib/uncompr.o # unzip +endif OBJS += unzip/unzip.o unzip/unzip_stream.o diff --git a/Makefile.libretro b/Makefile.libretro index a2a4dafc..004aaa9d 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -60,30 +60,77 @@ else ifeq ($(platform), ps3) 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__ + STATIC_LINKING = 1 + NO_MMAP = 1 + DONT_COMPILE_IN_ZLIB = 1 + + asm_memory = 0 + asm_render = 0 + asm_ym2612 = 0 + asm_misc = 0 + asm_cdpico = 0 + asm_cdmemory = 0 + asm_mix = 0 + use_cyclone = 0 + use_fame = 1 + use_drz80 = 0 + use_cz80 = 1 else ifeq ($(platform), sncps3) 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__ + STATIC_LINKING = 1 + NO_MMAP = 1 + DONT_COMPILE_IN_ZLIB = 1 + + asm_memory = 0 + asm_render = 0 + asm_ym2612 = 0 + asm_misc = 0 + asm_cdpico = 0 + asm_cdmemory = 0 + asm_mix = 0 + use_cyclone = 0 + use_fame = 1 + use_drz80 = 0 + use_cz80 = 1 else ifeq ($(platform), psl1ght) TARGET := $(TARGET_NAME)_libretro_psl1ght.a CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT) AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT) CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ + STATIC_LINKING = 1 + NO_MMAP = 1 + DONT_COMPILE_IN_ZLIB = 1 + + asm_memory = 0 + asm_render = 0 + asm_ym2612 = 0 + asm_misc = 0 + asm_cdpico = 0 + asm_cdmemory = 0 + asm_mix = 0 + use_cyclone = 0 + use_fame = 1 + use_drz80 = 0 + use_cz80 = 1 else ifeq ($(platform), psp1) TARGET := $(TARGET_NAME)_libretro_psp1.a CC = psp-gcc$(EXE_EXT) AR = psp-ar$(EXE_EXT) - CFLAGS += -DPSP -G0 + CFLAGS += -G0 STATIC_LINKING = 1 + NO_MMAP = 1 + DONT_COMPILE_IN_ZLIB = 1 -asm_memory = 0 -asm_render = 0 -asm_ym2612 = 0 -asm_misc = 0 -asm_cdpico = 0 -asm_cdmemory = 0 -asm_mix = 0 + asm_memory = 0 + asm_render = 0 + asm_ym2612 = 0 + asm_misc = 0 + asm_cdpico = 0 + asm_cdmemory = 0 + asm_mix = 0 use_cyclone = 0 use_fame = 1 use_drz80 = 0 @@ -146,6 +193,10 @@ else CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__ endif +ifeq ($(NO_MMAP),1) +CFLAGS += -DNO_MMAP +endif + ifeq ($(ARM_ASM),1) asm_memory = 1 asm_render = 1 diff --git a/pico/misc.c b/pico/misc.c index f9e85cda..ba24f95f 100644 --- a/pico/misc.c +++ b/pico/misc.c @@ -99,7 +99,7 @@ typedef struct int b7; } intblock; -PICO_INTERNAL_ASM void memcpy16(unsigned short *dest, unsigned short *src, int count) +PICO_INTERNAL_ASM void pmemcpy16(unsigned short *dest, unsigned short *src, int count) { if ((((long)dest | (long)src) & 3) == 0) { diff --git a/pico/misc_arm.s b/pico/misc_arm.s index 15662a7b..260094ec 100644 --- a/pico/misc_arm.s +++ b/pico/misc_arm.s @@ -6,9 +6,9 @@ * See COPYING file in the top-level directory. */ -.global memcpy16 @ unsigned short *dest, unsigned short *src, int count +.global pmemcpy16 @ unsigned short *dest, unsigned short *src, int count -memcpy16: +pmemcpy16: eor r3, r0, r1 tst r3, #2 bne mcp16_cant_align diff --git a/pico/pico_int.h b/pico/pico_int.h index 7447db94..09fb6458 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -768,7 +768,7 @@ PICO_INTERNAL_ASM unsigned int PicoVideoRead8(unsigned int a); extern int (*PicoDmaHook)(unsigned int source, int len, unsigned short **srcp, unsigned short **limitp); // misc.c -PICO_INTERNAL_ASM void memcpy16(unsigned short *dest, unsigned short *src, int count); +PICO_INTERNAL_ASM void pmemcpy16(unsigned short *dest, unsigned short *src, int count); PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count); PICO_INTERNAL_ASM void memcpy32(int *dest, int *src, int count); // 32bit word count PICO_INTERNAL_ASM void memset32(int *dest, int c, int count); diff --git a/pico/videoport.c b/pico/videoport.c index 6c876aea..7f37e41d 100644 --- a/pico/videoport.c +++ b/pico/videoport.c @@ -156,7 +156,7 @@ static void DmaSlow(int len) if (inc == 2 && !(a&1) && a+len*2 < 0x10000) { // most used DMA mode - memcpy16(r + (a>>1), pd, len); + pmemcpy16(r + (a>>1), pd, len); a += len*2; } else diff --git a/platform/libretro.c b/platform/libretro.c index 72b7a1be..8cda278a 100644 --- a/platform/libretro.c +++ b/platform/libretro.c @@ -6,10 +6,6 @@ * See COPYING file in the top-level directory. */ -#ifdef PSP -#define NO_MMAP -#endif - #define _GNU_SOURCE 1 // mremap #include #include From 0877c7ddb63971f4344e392b14fbbb6f9371c290 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 4 Mar 2014 06:20:32 +0100 Subject: [PATCH 012/124] (PS3) Define FAMEC_NO_GOTOS for PS3 - runs out of memory with GCC for Famec otherwise --- Makefile.libretro | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index 004aaa9d..128e5f3e 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -59,7 +59,7 @@ else ifeq ($(platform), ps3) TARGET := $(TARGET_NAME)_libretro_ps3.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__ + CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -DFAMEC_NO_GOTOS STATIC_LINKING = 1 NO_MMAP = 1 DONT_COMPILE_IN_ZLIB = 1 @@ -79,7 +79,7 @@ else ifeq ($(platform), sncps3) 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__ + CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -DFAMEC_NO_GOTOS STATIC_LINKING = 1 NO_MMAP = 1 DONT_COMPILE_IN_ZLIB = 1 @@ -99,7 +99,7 @@ else ifeq ($(platform), psl1ght) TARGET := $(TARGET_NAME)_libretro_psl1ght.a CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT) AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT) - CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ + CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -DFAMEC_NO_GOTOS STATIC_LINKING = 1 NO_MMAP = 1 DONT_COMPILE_IN_ZLIB = 1 From 7eaf128fac9de00394c664f59f40bebae8b122b2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 4 Mar 2014 06:32:04 +0100 Subject: [PATCH 013/124] (PS3) We shouldn't compile in zlib code in a core period - compile out zlib parts with NO_ZLIB ifdef for PSP and PS3 --- Makefile | 2 +- Makefile.libretro | 4 ++++ pico/cart.c | 11 ++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 633f0bc9..f18d26e6 100644 --- a/Makefile +++ b/Makefile @@ -157,8 +157,8 @@ ifneq "$(DONT_COMPILE_IN_ZLIB)" "1" OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \ zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o zlib/uncompr.o # unzip -endif OBJS += unzip/unzip.o unzip/unzip_stream.o +endif include platform/common/common.mak diff --git a/Makefile.libretro b/Makefile.libretro index 128e5f3e..48182197 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -193,6 +193,10 @@ else CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__ endif +ifeq ($(DONT_COMPILE_IN_ZLIB),1) +CFLAGS += -DNO_ZLIB +endif + ifeq ($(NO_MMAP),1) CFLAGS += -DNO_MMAP endif diff --git a/pico/cart.c b/pico/cart.c index a5c563d6..d237fad9 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -100,6 +100,7 @@ pm_file *pm_open(const char *path) return NULL; ext = get_ext(path); +#ifndef NO_ZLIB if (strcasecmp(ext, "zip") == 0) { struct zipent *zipentry; @@ -149,7 +150,9 @@ zip_failed: return NULL; } } - else if (strcasecmp(ext, "cso") == 0) + else +#endif + if (strcasecmp(ext, "cso") == 0) { cso_struct *cso = NULL, *tmp = NULL; int size; @@ -244,6 +247,7 @@ size_t pm_read(void *ptr, size_t bytes, pm_file *stream) { ret = fread(ptr, 1, bytes, stream->file); } +#ifndef NO_ZLIB else if (stream->type == PMT_ZIP) { gzFile gf = stream->param; @@ -254,6 +258,7 @@ size_t pm_read(void *ptr, size_t bytes, pm_file *stream) /* we must reset stream pointer or else next seek/read fails */ gzrewind(gf); } +#endif else if (stream->type == PMT_CSO) { cso_struct *cso = stream->param; @@ -329,6 +334,7 @@ int pm_seek(pm_file *stream, long offset, int whence) fseek(stream->file, offset, whence); return ftell(stream->file); } +#ifndef NO_ZLIB else if (stream->type == PMT_ZIP) { if (PicoMessage != NULL && offset > 6*1024*1024) { @@ -338,6 +344,7 @@ int pm_seek(pm_file *stream, long offset, int whence) } return gzseek((gzFile) stream->param, offset, whence); } +#endif else if (stream->type == PMT_CSO) { cso_struct *cso = stream->param; @@ -363,6 +370,7 @@ int pm_close(pm_file *fp) { fclose(fp->file); } +#ifndef NO_ZLIB else if (fp->type == PMT_ZIP) { ZIP *zipfile = fp->file; @@ -370,6 +378,7 @@ int pm_close(pm_file *fp) zipfile->fp = NULL; // gzclose() closed it closezip(zipfile); } +#endif else if (fp->type == PMT_CSO) { free(fp->param); From 5345c2b9bc9b5f8a2d423482358e63af87b9219a Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 17 Mar 2014 17:29:31 +0100 Subject: [PATCH 014/124] (MSVC) Add skeleton MSVC 2010 solution --- Makefile | 2 +- jni/Android.mk | 2 +- platform/{ => libretro}/libretro.c | 6 +- platform/{ => libretro}/libretro.h | 0 platform/libretro/msvc/msvc-2003-xbox1.bat | 47 +++++++ platform/libretro/msvc/msvc-2010-360.bat | 124 ++++++++++++++++++ platform/libretro/msvc/msvc-2010.bat | 124 ++++++++++++++++++ platform/libretro/msvc/msvc-2010.sln | 20 +++ platform/libretro/msvc/msvc-2010/libretro.def | 27 ++++ .../libretro/msvc/msvc-2010/msvc-2010.suo | Bin 0 -> 8704 bytes .../libretro/msvc/msvc-2010/msvc-2010.vcxproj | 86 ++++++++++++ .../msvc/msvc-2010/msvc-2010.vcxproj.filters | 28 ++++ 12 files changed, 461 insertions(+), 5 deletions(-) rename platform/{ => libretro}/libretro.c (99%) rename platform/{ => libretro}/libretro.h (100%) mode change 100755 => 100644 create mode 100644 platform/libretro/msvc/msvc-2003-xbox1.bat create mode 100644 platform/libretro/msvc/msvc-2010-360.bat create mode 100644 platform/libretro/msvc/msvc-2010.bat create mode 100644 platform/libretro/msvc/msvc-2010.sln create mode 100644 platform/libretro/msvc/msvc-2010/libretro.def create mode 100644 platform/libretro/msvc/msvc-2010/msvc-2010.suo create mode 100644 platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj create mode 100644 platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters diff --git a/Makefile b/Makefile index f18d26e6..7ebb8781 100644 --- a/Makefile +++ b/Makefile @@ -109,7 +109,7 @@ USE_FRONTEND = 1 PLATFORM_MP3 = 1 endif ifeq "$(PLATFORM)" "libretro" -OBJS += platform/libretro.o +OBJS += platform/libretro/libretro.o endif ifeq "$(USE_FRONTEND)" "1" diff --git a/jni/Android.mk b/jni/Android.mk index 122b18e8..cf96faa7 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -59,7 +59,7 @@ ARCH := $(TARGET_ARCH) include $(R)platform/common/common.mak LOCAL_SRC_FILES += $(SRCS_COMMON) -LOCAL_SRC_FILES += $(R)platform/libretro.c +LOCAL_SRC_FILES += $(R)platform/libretro/libretro.c LOCAL_SRC_FILES += $(R)platform/common/mp3.c LOCAL_SRC_FILES += $(R)platform/common/mp3_dummy.c diff --git a/platform/libretro.c b/platform/libretro/libretro.c similarity index 99% rename from platform/libretro.c rename to platform/libretro/libretro.c index 8cda278a..7b35c870 100644 --- a/platform/libretro.c +++ b/platform/libretro/libretro.c @@ -26,8 +26,8 @@ #include #include -#include "common/input_pico.h" -#include "common/version.h" +#include "../common/input_pico.h" +#include "../common/version.h" #include "libretro.h" static retro_log_printf_t log_cb; @@ -164,7 +164,7 @@ static void munmap(void *addr, size_t length) /* ruh-ro, we leaked handle from CreateFileMapping() ... */ } #elif defined(NO_MMAP) -#define PROT_EXEC 0x04 +#define PROT_EXEC 0x04 #define MAP_FAILED 0 #define PROT_READ 0 #define PROT_WRITE 0 diff --git a/platform/libretro.h b/platform/libretro/libretro.h old mode 100755 new mode 100644 similarity index 100% rename from platform/libretro.h rename to platform/libretro/libretro.h diff --git a/platform/libretro/msvc/msvc-2003-xbox1.bat b/platform/libretro/msvc/msvc-2003-xbox1.bat new file mode 100644 index 00000000..91d69ff5 --- /dev/null +++ b/platform/libretro/msvc/msvc-2003-xbox1.bat @@ -0,0 +1,47 @@ +@SET VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE +@SET VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio .NET 2003 +@SET FrameworkDir=C:\WINDOWS\Microsoft.NET\Framework +@SET FrameworkVersion=v1.1.4322 +@SET FrameworkSDKDir=C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1 +@rem Root of Visual Studio common files. + +@if "%VSINSTALLDIR%"=="" goto Usage +@if "%VCINSTALLDIR%"=="" set VCINSTALLDIR=%VSINSTALLDIR% + +@rem +@rem Root of Visual Studio ide installed files. +@rem +@set DevEnvDir=%VSINSTALLDIR% + +@rem +@rem Root of Visual C++ installed files. +@rem +@set MSVCDir=%VCINSTALLDIR%\VC7 + +@rem +@echo Setting environment for using Microsoft Visual Studio .NET 2003 tools. +@echo (If you have another version of Visual Studio or Visual C++ installed and wish +@echo to use its tools from the command line, run vcvars32.bat for that version.) +@rem + +@REM %VCINSTALLDIR%\Common7\Tools dir is added only for real setup. + +@set PATH=%DevEnvDir%;%MSVCDir%\BIN;%VCINSTALLDIR%\Common7\Tools;%VCINSTALLDIR%\Common7\Tools\bin\prerelease;%VCINSTALLDIR%\Common7\Tools\bin;%FrameworkSDKDir%\bin;%FrameworkDir%\%FrameworkVersion%;%PATH%; +@set INCLUDE=%MSVCDir%\ATLMFC\INCLUDE;%MSVCDir%\INCLUDE;%FrameworkSDKDir%\include;%INCLUDE%;%XDK%\xbox\include +@set LIB=%MSVCDir%\ATLMFC\LIB;%MSVCDir%\LIB;%MSVCDir%\PlatformSDK\lib;%XDK%\lib;%XDK%\xbox\lib;%LIB% + +@goto end + +:Usage + +@echo. VSINSTALLDIR variable is not set. +@echo. +@echo SYNTAX: %0 + +@goto end + +:end + +devenv /clean Release_LTCG msvc-2003-xbox1.sln +devenv /build Release_LTCG msvc-2003-xbox1.sln +exit diff --git a/platform/libretro/msvc/msvc-2010-360.bat b/platform/libretro/msvc/msvc-2010-360.bat new file mode 100644 index 00000000..3ca14052 --- /dev/null +++ b/platform/libretro/msvc/msvc-2010-360.bat @@ -0,0 +1,124 @@ +@echo off + +@echo Setting environment for using Microsoft Visual Studio 2010 x86 tools. + +@call :GetVSCommonToolsDir +@if "%VS100COMNTOOLS%"=="" goto error_no_VS100COMNTOOLSDIR + +@call "%VS100COMNTOOLS%VCVarsQueryRegistry.bat" 32bit No64bit + +@if "%VSINSTALLDIR%"=="" goto error_no_VSINSTALLDIR +@if "%FrameworkDir32%"=="" goto error_no_FrameworkDIR32 +@if "%FrameworkVersion32%"=="" goto error_no_FrameworkVer32 +@if "%Framework35Version%"=="" goto error_no_Framework35Version + +@set FrameworkDir=%FrameworkDir32% +@set FrameworkVersion=%FrameworkVersion32% + +@if not "%WindowsSdkDir%" == "" ( + @set "PATH=%WindowsSdkDir%bin\NETFX 4.0 Tools;%WindowsSdkDir%bin;%PATH%" + @set "INCLUDE=%WindowsSdkDir%include;%INCLUDE%" + @set "LIB=%WindowsSdkDir%lib;%LIB%" +) + +@rem +@rem Root of Visual Studio IDE installed files. +@rem +@set DevEnvDir=%VSINSTALLDIR%Common7\IDE\ + +@rem PATH +@rem ---- +@if exist "%VSINSTALLDIR%Team Tools\Performance Tools" ( + @set "PATH=%VSINSTALLDIR%Team Tools\Performance Tools;%PATH%" +) +@if exist "%ProgramFiles%\HTML Help Workshop" set PATH=%ProgramFiles%\HTML Help Workshop;%PATH% +@if exist "%ProgramFiles(x86)%\HTML Help Workshop" set PATH=%ProgramFiles(x86)%\HTML Help Workshop;%PATH% +@if exist "%VCINSTALLDIR%VCPackages" set PATH=%VCINSTALLDIR%VCPackages;%PATH% +@set PATH=%FrameworkDir%%Framework35Version%;%PATH% +@set PATH=%FrameworkDir%%FrameworkVersion%;%PATH% +@set PATH=%VSINSTALLDIR%Common7\Tools;%PATH% +@if exist "%VCINSTALLDIR%BIN" set PATH=%VCINSTALLDIR%BIN;%PATH% +@set PATH=%DevEnvDir%;%PATH% + +@if exist "%VSINSTALLDIR%VSTSDB\Deploy" ( + @set "PATH=%VSINSTALLDIR%VSTSDB\Deploy;%PATH%" +) + +@if not "%FSHARPINSTALLDIR%" == "" ( + @set "PATH=%FSHARPINSTALLDIR%;%PATH%" +) + +@rem INCLUDE +@rem ------- +@if exist "%VCINSTALLDIR%ATLMFC\INCLUDE" set INCLUDE=%VCINSTALLDIR%ATLMFC\INCLUDE;%INCLUDE% +@if exist "%VCINSTALLDIR%INCLUDE" set INCLUDE=%VCINSTALLDIR%INCLUDE;%INCLUDE% + +@rem LIB +@rem --- +@if exist "%VCINSTALLDIR%ATLMFC\LIB" set LIB=%VCINSTALLDIR%ATLMFC\LIB;%LIB% +@if exist "%VCINSTALLDIR%LIB" set LIB=%VCINSTALLDIR%LIB;%LIB% + +@rem LIBPATH +@rem ------- +@if exist "%VCINSTALLDIR%ATLMFC\LIB" set LIBPATH=%VCINSTALLDIR%ATLMFC\LIB;%LIBPATH% +@if exist "%VCINSTALLDIR%LIB" set LIBPATH=%VCINSTALLDIR%LIB;%LIBPATH% +@set LIBPATH=%FrameworkDir%%Framework35Version%;%LIBPATH% +@set LIBPATH=%FrameworkDir%%FrameworkVersion%;%LIBPATH% + +@goto end + +@REM ----------------------------------------------------------------------- +:GetVSCommonToolsDir +@set VS100COMNTOOLS= +@call :GetVSCommonToolsDirHelper32 HKLM > nul 2>&1 +@if errorlevel 1 call :GetVSCommonToolsDirHelper32 HKCU > nul 2>&1 +@if errorlevel 1 call :GetVSCommonToolsDirHelper64 HKLM > nul 2>&1 +@if errorlevel 1 call :GetVSCommonToolsDirHelper64 HKCU > nul 2>&1 +@exit /B 0 + +:GetVSCommonToolsDirHelper32 +@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v "10.0"') DO ( + @if "%%i"=="10.0" ( + @SET "VS100COMNTOOLS=%%k" + ) +) +@if "%VS100COMNTOOLS%"=="" exit /B 1 +@SET "VS100COMNTOOLS=%VS100COMNTOOLS%Common7\Tools\" +@exit /B 0 + +:GetVSCommonToolsDirHelper64 +@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7" /v "10.0"') DO ( + @if "%%i"=="10.0" ( + @SET "VS100COMNTOOLS=%%k" + ) +) +@if "%VS100COMNTOOLS%"=="" exit /B 1 +@SET "VS100COMNTOOLS=%VS100COMNTOOLS%Common7\Tools\" +@exit /B 0 + +@REM ----------------------------------------------------------------------- +:error_no_VS100COMNTOOLSDIR +@echo ERROR: Cannot determine the location of the VS Common Tools folder. +@goto end + +:error_no_VSINSTALLDIR +@echo ERROR: Cannot determine the location of the VS installation. +@goto end + +:error_no_FrameworkDIR32 +@echo ERROR: Cannot determine the location of the .NET Framework 32bit installation. +@goto end + +:error_no_FrameworkVer32 +@echo ERROR: Cannot determine the version of the .NET Framework 32bit installation. +@goto end + +:error_no_Framework35Version +@echo ERROR: Cannot determine the .NET Framework 3.5 version. +@goto end + +:end + +msbuild msvc-2010-360.sln /p:Configuration=Release_LTCG /target:clean +msbuild msvc-2010-360.sln /p:Configuration=Release_LTCG +exit diff --git a/platform/libretro/msvc/msvc-2010.bat b/platform/libretro/msvc/msvc-2010.bat new file mode 100644 index 00000000..a4b08228 --- /dev/null +++ b/platform/libretro/msvc/msvc-2010.bat @@ -0,0 +1,124 @@ +@echo off + +@echo Setting environment for using Microsoft Visual Studio 2010 x86 tools. + +@call :GetVSCommonToolsDir +@if "%VS100COMNTOOLS%"=="" goto error_no_VS100COMNTOOLSDIR + +@call "%VS100COMNTOOLS%VCVarsQueryRegistry.bat" 32bit No64bit + +@if "%VSINSTALLDIR%"=="" goto error_no_VSINSTALLDIR +@if "%FrameworkDir32%"=="" goto error_no_FrameworkDIR32 +@if "%FrameworkVersion32%"=="" goto error_no_FrameworkVer32 +@if "%Framework35Version%"=="" goto error_no_Framework35Version + +@set FrameworkDir=%FrameworkDir32% +@set FrameworkVersion=%FrameworkVersion32% + +@if not "%WindowsSdkDir%" == "" ( + @set "PATH=%WindowsSdkDir%bin\NETFX 4.0 Tools;%WindowsSdkDir%bin;%PATH%" + @set "INCLUDE=%WindowsSdkDir%include;%INCLUDE%" + @set "LIB=%WindowsSdkDir%lib;%LIB%" +) + +@rem +@rem Root of Visual Studio IDE installed files. +@rem +@set DevEnvDir=%VSINSTALLDIR%Common7\IDE\ + +@rem PATH +@rem ---- +@if exist "%VSINSTALLDIR%Team Tools\Performance Tools" ( + @set "PATH=%VSINSTALLDIR%Team Tools\Performance Tools;%PATH%" +) +@if exist "%ProgramFiles%\HTML Help Workshop" set PATH=%ProgramFiles%\HTML Help Workshop;%PATH% +@if exist "%ProgramFiles(x86)%\HTML Help Workshop" set PATH=%ProgramFiles(x86)%\HTML Help Workshop;%PATH% +@if exist "%VCINSTALLDIR%VCPackages" set PATH=%VCINSTALLDIR%VCPackages;%PATH% +@set PATH=%FrameworkDir%%Framework35Version%;%PATH% +@set PATH=%FrameworkDir%%FrameworkVersion%;%PATH% +@set PATH=%VSINSTALLDIR%Common7\Tools;%PATH% +@if exist "%VCINSTALLDIR%BIN" set PATH=%VCINSTALLDIR%BIN;%PATH% +@set PATH=%DevEnvDir%;%PATH% + +@if exist "%VSINSTALLDIR%VSTSDB\Deploy" ( + @set "PATH=%VSINSTALLDIR%VSTSDB\Deploy;%PATH%" +) + +@if not "%FSHARPINSTALLDIR%" == "" ( + @set "PATH=%FSHARPINSTALLDIR%;%PATH%" +) + +@rem INCLUDE +@rem ------- +@if exist "%VCINSTALLDIR%ATLMFC\INCLUDE" set INCLUDE=%VCINSTALLDIR%ATLMFC\INCLUDE;%INCLUDE% +@if exist "%VCINSTALLDIR%INCLUDE" set INCLUDE=%VCINSTALLDIR%INCLUDE;%INCLUDE% + +@rem LIB +@rem --- +@if exist "%VCINSTALLDIR%ATLMFC\LIB" set LIB=%VCINSTALLDIR%ATLMFC\LIB;%LIB% +@if exist "%VCINSTALLDIR%LIB" set LIB=%VCINSTALLDIR%LIB;%LIB% + +@rem LIBPATH +@rem ------- +@if exist "%VCINSTALLDIR%ATLMFC\LIB" set LIBPATH=%VCINSTALLDIR%ATLMFC\LIB;%LIBPATH% +@if exist "%VCINSTALLDIR%LIB" set LIBPATH=%VCINSTALLDIR%LIB;%LIBPATH% +@set LIBPATH=%FrameworkDir%%Framework35Version%;%LIBPATH% +@set LIBPATH=%FrameworkDir%%FrameworkVersion%;%LIBPATH% + +@goto end + +@REM ----------------------------------------------------------------------- +:GetVSCommonToolsDir +@set VS100COMNTOOLS= +@call :GetVSCommonToolsDirHelper32 HKLM > nul 2>&1 +@if errorlevel 1 call :GetVSCommonToolsDirHelper32 HKCU > nul 2>&1 +@if errorlevel 1 call :GetVSCommonToolsDirHelper64 HKLM > nul 2>&1 +@if errorlevel 1 call :GetVSCommonToolsDirHelper64 HKCU > nul 2>&1 +@exit /B 0 + +:GetVSCommonToolsDirHelper32 +@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v "10.0"') DO ( + @if "%%i"=="10.0" ( + @SET "VS100COMNTOOLS=%%k" + ) +) +@if "%VS100COMNTOOLS%"=="" exit /B 1 +@SET "VS100COMNTOOLS=%VS100COMNTOOLS%Common7\Tools\" +@exit /B 0 + +:GetVSCommonToolsDirHelper64 +@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7" /v "10.0"') DO ( + @if "%%i"=="10.0" ( + @SET "VS100COMNTOOLS=%%k" + ) +) +@if "%VS100COMNTOOLS%"=="" exit /B 1 +@SET "VS100COMNTOOLS=%VS100COMNTOOLS%Common7\Tools\" +@exit /B 0 + +@REM ----------------------------------------------------------------------- +:error_no_VS100COMNTOOLSDIR +@echo ERROR: Cannot determine the location of the VS Common Tools folder. +@goto end + +:error_no_VSINSTALLDIR +@echo ERROR: Cannot determine the location of the VS installation. +@goto end + +:error_no_FrameworkDIR32 +@echo ERROR: Cannot determine the location of the .NET Framework 32bit installation. +@goto end + +:error_no_FrameworkVer32 +@echo ERROR: Cannot determine the version of the .NET Framework 32bit installation. +@goto end + +:error_no_Framework35Version +@echo ERROR: Cannot determine the .NET Framework 3.5 version. +@goto end + +:end + +msbuild msvc-2010.sln /p:Configuration=Release /target:clean +msbuild msvc-2010.sln /p:Configuration=Release +exit diff --git a/platform/libretro/msvc/msvc-2010.sln b/platform/libretro/msvc/msvc-2010.sln new file mode 100644 index 00000000..e2db4a95 --- /dev/null +++ b/platform/libretro/msvc/msvc-2010.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msvc-2010", "msvc-2010\msvc-2010.vcxproj", "{D4156C25-0E30-4407-9198-1F51EF74AA84}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D4156C25-0E30-4407-9198-1F51EF74AA84}.Debug|Win32.ActiveCfg = Debug|Win32 + {D4156C25-0E30-4407-9198-1F51EF74AA84}.Debug|Win32.Build.0 = Debug|Win32 + {D4156C25-0E30-4407-9198-1F51EF74AA84}.Release|Win32.ActiveCfg = Release|Win32 + {D4156C25-0E30-4407-9198-1F51EF74AA84}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/platform/libretro/msvc/msvc-2010/libretro.def b/platform/libretro/msvc/msvc-2010/libretro.def new file mode 100644 index 00000000..70f6699a --- /dev/null +++ b/platform/libretro/msvc/msvc-2010/libretro.def @@ -0,0 +1,27 @@ +LIBRARY "msvc-2010" +EXPORTS +retro_set_environment +retro_set_video_refresh +retro_set_audio_sample +retro_set_audio_sample_batch +retro_set_input_poll +retro_set_input_state +retro_init +retro_deinit +retro_api_version +retro_get_system_info +retro_get_system_av_info +retro_set_controller_port_device +retro_reset +retro_run +retro_serialize_size +retro_serialize +retro_unserialize +retro_cheat_reset +retro_cheat_set +retro_load_game +retro_load_game_special +retro_unload_game +retro_get_region +retro_get_memory_data +retro_get_memory_size diff --git a/platform/libretro/msvc/msvc-2010/msvc-2010.suo b/platform/libretro/msvc/msvc-2010/msvc-2010.suo new file mode 100644 index 0000000000000000000000000000000000000000..e2d4612898ceea2a74f7edb61a0efb4e60bf5eac GIT binary patch literal 8704 zcmeHMUvm>x6h8$jP!K@{1rZ_wg0wNAt^6%cN!rnoN}!?m&~avyY~s>ox0BsSJL(J% zK0E4@d$sU2L;^OB^N~XlYxh~6?-Q=`K23OZSOkMu&%G!@yq1ya=WpYly4I#7wR+QW1I=F$&b_g*KQNi!xf0&;jV*13|9c zr22{5gFJxrI_8|P56&Smfa{+&a{Utrv>d06IH2!$;re;-3t*1HZZPe63H&mcV?)_j z!n1zwAnsG(*T9FsuY(VRkARPY-vDdbH*tLeJPaNIr@?Q5_4AXFYu(1NcuEOIz|8-2 z;rFkme)(~x_|5qxLVH(qH^&I+gSZ%ICeNhp49t(_yu4Xz)CzUeGacXXE!Qa+L@u_8WC`!Z90u-LQvKg+|G?%I}-YMR&n;CQ6yn>Ui~3HJh!B zXN*x}vr?utZfeX}<+|&+RX;svc@4v!^&1t-O)C>>W_|Ud=(_fG%c;1xyma31jiR;a zr3;qh7$w_OH&aW#>3CMjvMql(U7)2NTFT~$OX|X`^SxQ$t()|7o7z7;YWD}}xwC#w zN8HpdhXayxZQCq!_Na0bhe!d>R>I9r9!T6<^h$aX`+5IMygVgmWnOF`a0y6ks!Zqt zZ9HiJpNY<`o-RVZjI33`b4xyf+&rXhQvKZfd=Tb;TqItX@UHRv}Gp(&wNwu*?99K#5mmbc|N zB6SAsWk|UgB^MFTedHY4xM~c%k%AvSt}AGBamV;hs~Deyrg``k zT{9R-Tj32?i-EPkHN&bPsEtG>@HK{XPR4Nj6sR?ZwKR@Zm_yzeN1nhty6k+RiNA8hPkwr(f6Nd5jF#MJr18=|A%OTfqjjw5}uUjfhH*x2( z+WkaPhqKihn}X=1>=sqGuO~L0lXswZJ$p>cRm3@WGW_ae%4Z?Qi~>c|*a2Kr^UdAw zMMzbky@|XN>uyUEd%CfMUt=Z}CIl5n4tCd+rCU@b)wuLso1QCrX@Pz|AzsF62EmP)t`lI zJ?#Cm+I#T3lcTs6iTpfTv|K3uzzOl+b^MK@7tR+6whtY#cmJ8$u{rjs&5sXt@iZc9Y)@h zOL6a$;;#01e-H7;8kT!dlK!7f|Nl0Ny%%$Uud0G*r4z`Po?z!$Y P_40nd?`YjTciY#$*w3hE literal 0 HcmV?d00001 diff --git a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj new file mode 100644 index 00000000..81e23ae1 --- /dev/null +++ b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj @@ -0,0 +1,86 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {D4156C25-0E30-4407-9198-1F51EF74AA84} + Win32Proj + msvc2010 + + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)\..\..\..\;$(SolutionDIr)\..\..\..\pico;%(AdditionalIncludeDirectories) + + + Windows + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)\..\..\..\;$(SolutionDIr)\..\..\..\pico;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters new file mode 100644 index 00000000..851d90e9 --- /dev/null +++ b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters @@ -0,0 +1,28 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {13ad8d51-3614-47ce-9d0d-8eb47a4cfabe} + + + {56e5d1cc-a749-46f0-9c75-e26037b4e2b3} + + + + + Source Files\platform\libretro + + + \ No newline at end of file From 4835077e00c2cf7e3dba7bf7801c6aafd9d00dbe Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 17 Mar 2014 17:37:20 +0100 Subject: [PATCH 015/124] C89 MSVC doesn't support 'inline' - will have to make define for INLINE that can be redefined by MSVC --- Makefile | 2 +- Makefile.libretro | 2 -- cpu/cz80/cz80.c | 2 +- cpu/debug.h | 2 +- cpu/sh2/compiler.c | 2 +- cpu/sh2/mame/sh2.c | 1 + cpu/sh2/mame/sh2pico.c | 4 ++-- cpu/sh2/sh2.h | 2 +- pico/32x/32x.c | 2 +- pico/pico_cmn.c | 2 +- pico/pico_int.h | 2 +- pico/videoport.c | 2 +- 12 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 7ebb8781..d8dbcb5e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ TARGET ?= PicoDrive CFLAGS += -Wall -ggdb -falign-functions=2 -CFLAGS += -I. +CFLAGS += -I. -DINLINE=inline ifndef DEBUG CFLAGS += -O2 -DNDEBUG -ffunction-sections ifeq ($(findstring clang,$(CC)),) diff --git a/Makefile.libretro b/Makefile.libretro index 48182197..76795050 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -193,9 +193,7 @@ else CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__ endif -ifeq ($(DONT_COMPILE_IN_ZLIB),1) CFLAGS += -DNO_ZLIB -endif ifeq ($(NO_MMAP),1) CFLAGS += -DNO_MMAP diff --git a/cpu/cz80/cz80.c b/cpu/cz80/cz80.c index 61ca5f84..28d762ce 100644 --- a/cpu/cz80/cz80.c +++ b/cpu/cz80/cz80.c @@ -216,7 +216,7 @@ void Cz80_Reset(cz80_struc *CPU) /* */ #if PICODRIVE_HACKS -static inline unsigned char picodrive_read(unsigned short a) +static INLINE unsigned char picodrive_read(unsigned short a) { uptr v = z80_read_map[a >> Z80_MEM_SHIFT]; if (map_flag_set(v)) diff --git a/cpu/debug.h b/cpu/debug.h index 5aaa60ee..4ad618d5 100644 --- a/cpu/debug.h +++ b/cpu/debug.h @@ -26,6 +26,6 @@ int pdb_net_connect(const char *host, const char *port); #else -static inline int pdb_net_connect(const char *host, const char *port) {return 0;} +static INLINE int pdb_net_connect(const char *host, const char *port) {return 0;} #endif diff --git a/cpu/sh2/compiler.c b/cpu/sh2/compiler.c index 25ba9d2f..2dd3430c 100644 --- a/cpu/sh2/compiler.c +++ b/cpu/sh2/compiler.c @@ -1017,7 +1017,7 @@ static void rcache_unlock_all(void) reg_temp[i].flags &= ~HRF_LOCKED; } -static inline u32 rcache_used_hreg_mask(void) +static INLINE u32 rcache_used_hreg_mask(void) { u32 mask = 0; int i; diff --git a/cpu/sh2/mame/sh2.c b/cpu/sh2/mame/sh2.c index 81203e7b..2fb964b6 100644 --- a/cpu/sh2/mame/sh2.c +++ b/cpu/sh2/mame/sh2.c @@ -108,6 +108,7 @@ //#include "debugger.h" //#include "sh2.h" //#include "sh2comn.h" +#undef INLINE #define INLINE static //CPU_DISASSEMBLE( sh2 ); diff --git a/cpu/sh2/mame/sh2pico.c b/cpu/sh2/mame/sh2pico.c index a3ad9f47..78998785 100644 --- a/cpu/sh2/mame/sh2pico.c +++ b/cpu/sh2/mame/sh2pico.c @@ -21,7 +21,7 @@ typedef unsigned char UINT8; // this nasty conversion is needed for drc-expecting memhandlers #define MAKE_READFUNC(name, cname) \ -static inline unsigned int name(SH2 *sh2, unsigned int a) \ +static INLINE unsigned int name(SH2 *sh2, unsigned int a) \ { \ unsigned int ret; \ sh2->sr |= sh2->icount << 12; \ @@ -32,7 +32,7 @@ static inline unsigned int name(SH2 *sh2, unsigned int a) \ } #define MAKE_WRITEFUNC(name, cname) \ -static inline void name(SH2 *sh2, unsigned int a, unsigned int d) \ +static INLINE void name(SH2 *sh2, unsigned int a, unsigned int d) \ { \ sh2->sr |= sh2->icount << 12; \ cname(a, d, sh2); \ diff --git a/cpu/sh2/sh2.h b/cpu/sh2/sh2.h index 1394f94a..8c37f43c 100644 --- a/cpu/sh2/sh2.h +++ b/cpu/sh2/sh2.h @@ -92,7 +92,7 @@ void sh2_unpack(SH2 *sh2, const unsigned char *buff); int sh2_execute_drc(SH2 *sh2c, int cycles); int sh2_execute_interpreter(SH2 *sh2c, int cycles); -static inline int sh2_execute(SH2 *sh2, int cycles, int use_drc) +static INLINE int sh2_execute(SH2 *sh2, int cycles, int use_drc) { int ret; diff --git a/pico/32x/32x.c b/pico/32x/32x.c index 26162e49..ddb95eca 100644 --- a/pico/32x/32x.c +++ b/pico/32x/32x.c @@ -363,7 +363,7 @@ static void p32x_run_events(unsigned int until) oldest, event_time_next); } -static inline void run_sh2(SH2 *sh2, int m68k_cycles) +static INLINE void run_sh2(SH2 *sh2, int m68k_cycles) { int cycles, done; diff --git a/pico/pico_cmn.c b/pico/pico_cmn.c index 341255a8..e8ad78d4 100644 --- a/pico/pico_cmn.c +++ b/pico/pico_cmn.c @@ -50,7 +50,7 @@ static void SekSyncM68k(void) pprof_end(m68k); } -static inline void SekRunM68k(int cyc) +static INLINE void SekRunM68k(int cyc) { SekCycleAim += cyc; SekSyncM68k(); diff --git a/pico/pico_int.h b/pico/pico_int.h index 09fb6458..f53250aa 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -907,7 +907,7 @@ void REGPARM(3) sh2_peripheral_write32(unsigned int a, unsigned int d, SH2 *sh2) #endif /* avoid dependency on newer glibc */ -static __inline int isspace_(int c) +static INLINE int isspace_(int c) { return (0x09 <= c && c <= 0x0d) || c == ' '; } diff --git a/pico/videoport.c b/pico/videoport.c index 7f37e41d..61f7f18e 100644 --- a/pico/videoport.c +++ b/pico/videoport.c @@ -22,7 +22,7 @@ typedef unsigned int u32; int (*PicoDmaHook)(unsigned int source, int len, unsigned short **srcp, unsigned short **limitp) = NULL; -static __inline void AutoIncrement(void) +static INLINE void AutoIncrement(void) { Pico.video.addr=(unsigned short)(Pico.video.addr+Pico.video.reg[0xf]); } From ed06ffd3391ff81fa1f34455f1311ba060a41cac Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 17 Mar 2014 18:15:55 +0100 Subject: [PATCH 016/124] (MSVC) Compatibility fixes --- cpu/drc/cmn.c | 4 + pico/32x/32x.c | 6 +- pico/32x/draw.c | 2 +- pico/cd/mcd.c | 11 +- pico/draw.c | 2 +- platform/libretro/libretro.c | 55 ++-- .../libretro/msvc/msvc-2010/msvc-2010.vcxproj | 68 ++++- .../msvc/msvc-2010/msvc-2010.vcxproj.filters | 237 ++++++++++++++++++ 8 files changed, 349 insertions(+), 36 deletions(-) diff --git a/cpu/drc/cmn.c b/cpu/drc/cmn.c index 37f17ce9..a07dcbdd 100644 --- a/cpu/drc/cmn.c +++ b/cpu/drc/cmn.c @@ -10,7 +10,11 @@ #include #include "cmn.h" +#ifdef _MSC_VER +u8 tcache[DRC_TCACHE_SIZE]; +#else u8 __attribute__((aligned(4096))) tcache[DRC_TCACHE_SIZE]; +#endif void drc_cmn_init(void) diff --git a/pico/32x/32x.c b/pico/32x/32x.c index ddb95eca..14d1c847 100644 --- a/pico/32x/32x.c +++ b/pico/32x/32x.c @@ -294,9 +294,9 @@ typedef void (event_cb)(unsigned int now); unsigned int p32x_event_times[P32X_EVENT_COUNT]; static unsigned int event_time_next; static event_cb *p32x_event_cbs[P32X_EVENT_COUNT] = { - [P32X_EVENT_PWM] = p32x_pwm_irq_event, - [P32X_EVENT_FILLEND] = fillend_event, - [P32X_EVENT_HINT] = hint_event, + p32x_pwm_irq_event, + fillend_event, + hint_event, }; // schedule event at some time 'after', in m68k clocks diff --git a/pico/32x/draw.c b/pico/32x/draw.c index 66f67a7e..ff07ef2a 100644 --- a/pico/32x/draw.c +++ b/pico/32x/draw.c @@ -292,7 +292,7 @@ void PicoDraw32xLayerMdOnly(int offs, int lines) for (l = 0; l < lines; l++) { if (have_scan) { PicoScan32xBegin(l + offs); - dst = DrawLineDest + poffs; + dst = (unsigned short*)DrawLineDest + poffs; } for (p = 0; p < plen; p += 4) { dst[p + 0] = pal[*pmd++]; diff --git a/pico/cd/mcd.c b/pico/cd/mcd.c index 687dfc3c..73502b28 100644 --- a/pico/cd/mcd.c +++ b/pico/cd/mcd.c @@ -30,9 +30,10 @@ PICO_INTERNAL void PicoExitMCD(void) PICO_INTERNAL void PicoPowerMCD(void) { + int fmt_size; SekCycleCntS68k = SekCycleAimS68k = 0; - int fmt_size = sizeof(formatted_bram); + fmt_size = sizeof(formatted_bram); memset(Pico_mcd->prg_ram, 0, sizeof(Pico_mcd->prg_ram)); memset(Pico_mcd->word_ram2M, 0, sizeof(Pico_mcd->word_ram2M)); memset(Pico_mcd->pcm_ram, 0, sizeof(Pico_mcd->pcm_ram)); @@ -200,10 +201,10 @@ typedef void (event_cb)(unsigned int now); unsigned int pcd_event_times[PCD_EVENT_COUNT]; static unsigned int event_time_next; static event_cb *pcd_event_cbs[PCD_EVENT_COUNT] = { - [PCD_EVENT_CDC] = pcd_cdc_event, - [PCD_EVENT_TIMER3] = pcd_int3_timer_event, - [PCD_EVENT_GFX] = gfx_update, - [PCD_EVENT_DMA] = pcd_dma_event, + pcd_cdc_event, + pcd_int3_timer_event, + gfx_update, + pcd_dma_event, }; void pcd_event_schedule(unsigned int now, enum pcd_event event, int after) diff --git a/pico/draw.c b/pico/draw.c index a03d8873..dbd63631 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -1568,7 +1568,7 @@ void PicoDrawSetOutBuf(void *dest, int increment) { DrawLineDestBase = dest; DrawLineDestIncrement = increment; - DrawLineDest = DrawLineDestBase + DrawScanline * increment; + DrawLineDest = (unsigned char*)DrawLineDestBase + DrawScanline * increment; } void PicoDrawSetInternalBuf(void *dest, int increment) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 7b35c870..662254e2 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -42,7 +42,11 @@ static retro_audio_sample_batch_t audio_batch_cb; static void *vout_buf; static int vout_width, vout_height, vout_offset; +#ifdef _MSC_VER +static short sndBuffer[2*44100/50]; +#else static short __attribute__((aligned(4))) sndBuffer[2*44100/50]; +#endif static void snd_write(int len); @@ -109,6 +113,11 @@ void cache_flush_d_inval_i(void *start, void *end) 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) { @@ -117,7 +126,6 @@ static void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t } else if (flags & MAP_ANON) return MAP_FAILED; - DWORD flProtect; if (prot & PROT_WRITE) { if (prot & PROT_EXEC) flProtect = PAGE_EXECUTE_READWRITE; @@ -131,8 +139,8 @@ static void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t } else flProtect = PAGE_READONLY; - off_t end = length + offset; - HANDLE mmap_fd, h; + end = length + offset; + if (fd == -1) mmap_fd = INVALID_HANDLE_VALUE; else @@ -141,7 +149,6 @@ static void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t if (h == NULL) return MAP_FAILED; - DWORD dwDesiredAccess; if (prot & PROT_WRITE) dwDesiredAccess = FILE_MAP_WRITE; else @@ -150,7 +157,7 @@ static void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t dwDesiredAccess |= FILE_MAP_EXECUTE; if (flags & MAP_PRIVATE) dwDesiredAccess |= FILE_MAP_COPY; - void *ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length); + ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length); if (ret == NULL) { CloseHandle(h); ret = MAP_FAILED; @@ -582,13 +589,13 @@ static bool disk_add_image_index(void) } static struct retro_disk_control_callback disk_control = { - .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, + disk_set_eject_state, + disk_get_eject_state, + disk_get_image_index, + disk_set_image_index, + disk_get_num_images, + disk_replace_image_index, + disk_add_image_index, }; static void disk_tray_open(void) @@ -792,18 +799,18 @@ void retro_reset(void) } static const unsigned short retro_pico_map[] = { - [RETRO_DEVICE_ID_JOYPAD_B] = 1 << GBTN_B, - [RETRO_DEVICE_ID_JOYPAD_Y] = 1 << GBTN_A, - [RETRO_DEVICE_ID_JOYPAD_SELECT] = 1 << GBTN_MODE, - [RETRO_DEVICE_ID_JOYPAD_START] = 1 << GBTN_START, - [RETRO_DEVICE_ID_JOYPAD_UP] = 1 << GBTN_UP, - [RETRO_DEVICE_ID_JOYPAD_DOWN] = 1 << GBTN_DOWN, - [RETRO_DEVICE_ID_JOYPAD_LEFT] = 1 << GBTN_LEFT, - [RETRO_DEVICE_ID_JOYPAD_RIGHT] = 1 << GBTN_RIGHT, - [RETRO_DEVICE_ID_JOYPAD_A] = 1 << GBTN_C, - [RETRO_DEVICE_ID_JOYPAD_X] = 1 << GBTN_Y, - [RETRO_DEVICE_ID_JOYPAD_L] = 1 << GBTN_X, - [RETRO_DEVICE_ID_JOYPAD_R] = 1 << GBTN_Z, + 1 << GBTN_B, + 1 << GBTN_A, + 1 << GBTN_MODE, + 1 << GBTN_START, + 1 << GBTN_UP, + 1 << GBTN_DOWN, + 1 << GBTN_LEFT, + 1 << GBTN_RIGHT, + 1 << GBTN_C, + 1 << GBTN_Y, + 1 << GBTN_X, + 1 << GBTN_Z, }; #define RETRO_PICO_MAP_LEN (sizeof(retro_pico_map) / sizeof(retro_pico_map[0])) diff --git a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj index 81e23ae1..8d3ac9ce 100644 --- a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj +++ b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj @@ -49,7 +49,7 @@ Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;%(PreprocessorDefinitions);INLINE=_inline;_CRT_SECURE_NO_WARNINGS;EMU_F68K;_USE_CZ80;NO_ZLIB CompileAsC $(SolutionDir)\..\..\..\;$(SolutionDIr)\..\..\..\pico;%(AdditionalIncludeDirectories) @@ -66,7 +66,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;%(PreprocessorDefinitions);INLINE=_inline;_CRT_SECURE_NO_WARNINGS;EMU_F68K;_USE_CZ80;NO_ZLIB CompileAsC $(SolutionDir)\..\..\..\;$(SolutionDIr)\..\..\..\pico;%(AdditionalIncludeDirectories) @@ -78,6 +78,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters index 851d90e9..e4a0ccff 100644 --- a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters +++ b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters @@ -19,10 +19,247 @@ {56e5d1cc-a749-46f0-9c75-e26037b4e2b3} + + {ab1e9796-fcf3-49c2-92f2-cbce4ad50f7f} + + + {d7cd40e2-d074-4967-84ad-89488a9eed11} + + + {76c63342-13b7-413c-b44b-52ef07b4dccc} + + + {04bd626c-6833-49c7-8256-dc94935efe03} + + + {3b94bd08-c15d-46a4-9672-094f4cafbc06} + + + {403b507e-7278-436e-b8a5-5a0deb70dfae} + + + {27323686-5607-4502-9488-ac65c90e6969} + + + {2e0a2f96-c25d-473e-9456-5e25b6eb8036} + + + {a208ee7f-75c1-4ff9-9ed5-ea2d42832fc6} + + + {04862576-b191-4769-a0f8-bb6400cfa861} + + + {337acc4a-3fe4-4547-b655-058d31318ffc} + + + {63c3bec2-54b1-4831-a420-5e1aa120738b} + + + {85be1810-42b8-4ec7-bbd5-6c7d1dc5b763} + + + {055bac11-1f11-4fe7-be7b-09ebaeab74d5} + + + {dd1911b8-6d08-42aa-ab21-0ba1154613e1} + Source Files\platform\libretro + + Source Files\platform\common + + + Source Files\platform\common + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\zlib + + + Source Files\unzip + + + Source Files\unzip + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico + + + Source Files\pico\cd + + + Source Files\pico\cd + + + Source Files\pico\cd + + + Source Files\pico\cd + + + Source Files\pico\cd + + + Source Files\pico\cd + + + Source Files\pico\cd + + + Source Files\pico\cd + + + Source Files\pico\cd + + + Source Files\pico\cd + + + Source Files\pico\cd + + + Source Files\pico\cd + + + Source Files\pico\32x + + + Source Files\pico\32x + + + Source Files\pico\32x + + + Source Files\pico\32x + + + Source Files\pico\32x + + + Source Files\pico\carthw + + + Source Files\pico\carthw\svp + + + Source Files\pico\carthw\svp + + + Source Files\pico\carthw\svp + + + Source Files\pico\sound + + + Source Files\pico\sound + + + Source Files\pico\sound + + + Source Files\pico\sound + + + Source Files\cpu\famec + + + Source Files\cpu\cz80 + + + Source Files\cpu\drc + + + Source Files\cpu\sh2 + + + Source Files\cpu\sh2\mame + \ No newline at end of file From 3124638fac4b5bf200cfb70ddb0cd5a7d896f144 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 17 Mar 2014 18:24:10 +0100 Subject: [PATCH 017/124] Uniquely name files for MSVC --- Makefile | 4 ++-- pico/32x/{draw.c => 32x_draw.c} | 0 pico/32x/{memory.c => 32x_memory.c} | 0 pico/carthw/svp/{memory.c => svp_memory.c} | 0 pico/cd/{memory.c => cd_memory.c} | 0 pico/cd/{misc.c => cd_misc.c} | 0 pico/cd/{sek.c => cd_sek.c} | 0 platform/common/common.mak | 8 ++++---- 8 files changed, 6 insertions(+), 6 deletions(-) rename pico/32x/{draw.c => 32x_draw.c} (100%) rename pico/32x/{memory.c => 32x_memory.c} (100%) rename pico/carthw/svp/{memory.c => svp_memory.c} (100%) rename pico/cd/{memory.c => cd_memory.c} (100%) rename pico/cd/{misc.c => cd_misc.c} (100%) rename pico/cd/{sek.c => cd_sek.c} (100%) diff --git a/Makefile b/Makefile index d8dbcb5e..d7a01dfe 100644 --- a/Makefile +++ b/Makefile @@ -197,7 +197,7 @@ tools/textfilter: tools/textfilter.c pico/draw.o: CFLAGS += -fno-strict-aliasing pico/draw2.o: CFLAGS += -fno-strict-aliasing pico/mode4.o: CFLAGS += -fno-strict-aliasing -pico/cd/memory.o: CFLAGS += -fno-strict-aliasing +pico/cd/cd_memory.o: CFLAGS += -fno-strict-aliasing pico/cd/cd_file.o: CFLAGS += -fno-strict-aliasing pico/cd/pcm.o: CFLAGS += -fno-strict-aliasing pico/cd/LC89510.o: CFLAGS += -fno-strict-aliasing @@ -208,5 +208,5 @@ pico/carthw/svp/compiler.o : cpu/drc/emit_$(ARCH).c cpu/sh2/compiler.o : cpu/drc/emit_$(ARCH).c cpu/sh2/mame/sh2pico.o : cpu/sh2/mame/sh2.c pico/pico.o pico/cd/mcd.o pico/32x/32x.o : pico/pico_cmn.c pico/pico_int.h -pico/memory.o pico/cd/memory.o pico/32x/memory.o : pico/pico_int.h pico/memory.h +pico/memory.o pico/cd/cd_memory.o pico/32x/32x_memory.o : pico/pico_int.h pico/memory.h cpu/fame/famec.o: cpu/fame/famec.c cpu/fame/famec_opcodes.h diff --git a/pico/32x/draw.c b/pico/32x/32x_draw.c similarity index 100% rename from pico/32x/draw.c rename to pico/32x/32x_draw.c diff --git a/pico/32x/memory.c b/pico/32x/32x_memory.c similarity index 100% rename from pico/32x/memory.c rename to pico/32x/32x_memory.c diff --git a/pico/carthw/svp/memory.c b/pico/carthw/svp/svp_memory.c similarity index 100% rename from pico/carthw/svp/memory.c rename to pico/carthw/svp/svp_memory.c diff --git a/pico/cd/memory.c b/pico/cd/cd_memory.c similarity index 100% rename from pico/cd/memory.c rename to pico/cd/cd_memory.c diff --git a/pico/cd/misc.c b/pico/cd/cd_misc.c similarity index 100% rename from pico/cd/misc.c rename to pico/cd/cd_misc.c diff --git a/pico/cd/sek.c b/pico/cd/cd_sek.c similarity index 100% rename from pico/cd/sek.c rename to pico/cd/cd_sek.c diff --git a/platform/common/common.mak b/platform/common/common.mak index fb59ecf3..d19f16ac 100644 --- a/platform/common/common.mak +++ b/platform/common/common.mak @@ -92,13 +92,13 @@ else DEFINES += NO_SMS endif # CD -SRCS_COMMON += $(R)pico/cd/mcd.c $(R)pico/cd/memory.c $(R)pico/cd/sek.c \ +SRCS_COMMON += $(R)pico/cd/mcd.c $(R)pico/cd/cd_memory.c $(R)pico/cd/cd_sek.c \ $(R)pico/cd/cdc.c $(R)pico/cd/cdd.c $(R)pico/cd/cd_image.c \ $(R)pico/cd/cue.c $(R)pico/cd/gfx.c $(R)pico/cd/gfx_dma.c \ - $(R)pico/cd/misc.c $(R)pico/cd/pcm.c + $(R)pico/cd/cd_misc.c $(R)pico/cd/pcm.c # 32X ifneq "$(no_32x)" "1" -SRCS_COMMON += $(R)pico/32x/32x.c $(R)pico/32x/memory.c $(R)pico/32x/draw.c \ +SRCS_COMMON += $(R)pico/32x/32x.c $(R)pico/32x/32x_memory.c $(R)pico/32x/32x_draw.c \ $(R)pico/32x/sh2soc.c $(R)pico/32x/pwm.c else DEFINES += NO_32X @@ -108,7 +108,7 @@ SRCS_COMMON += $(R)pico/pico/pico.c $(R)pico/pico/memory.c $(R)pico/pico/xpcm.c # carthw SRCS_COMMON += $(R)pico/carthw/carthw.c # SVP -SRCS_COMMON += $(R)pico/carthw/svp/svp.c $(R)pico/carthw/svp/memory.c \ +SRCS_COMMON += $(R)pico/carthw/svp/svp.c $(R)pico/carthw/svp/svp_memory.c \ $(R)pico/carthw/svp/ssp16.c ifeq "$(use_svpdrc)" "1" DEFINES += _SVP_DRC From 18d52d134ece892c7d427e185169b79d3e409271 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 17 Mar 2014 18:26:11 +0100 Subject: [PATCH 018/124] (MSVC) Update MSVC solution --- platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj | 14 +++++++------- .../msvc/msvc-2010/msvc-2010.vcxproj.filters | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj index 8d3ac9ce..b792e1af 100644 --- a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj +++ b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj @@ -84,13 +84,13 @@ - - + + - + @@ -102,10 +102,10 @@ - - + + - + @@ -147,4 +147,4 @@ - \ No newline at end of file + diff --git a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters index e4a0ccff..b9fd7053 100644 --- a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters +++ b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters @@ -195,16 +195,16 @@ Source Files\pico\cd - + Source Files\pico\cd - + Source Files\pico\cd Source Files\pico\cd - + Source Files\pico\cd @@ -213,7 +213,7 @@ Source Files\pico\32x - + Source Files\pico\32x @@ -225,7 +225,7 @@ Source Files\pico\carthw - + Source Files\pico\carthw\svp @@ -262,4 +262,4 @@ Source Files\cpu\sh2\mame - \ No newline at end of file + From 6732b5aa452171d58778bb3dfe62232b0fd73866 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 17 Mar 2014 18:28:30 +0100 Subject: [PATCH 019/124] (MSVC) Build fixes --- pico/cd/cd_memory.c | 2 +- pico/z80if.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pico/cd/cd_memory.c b/pico/cd/cd_memory.c index e660e35b..60701612 100644 --- a/pico/cd/cd_memory.c +++ b/pico/cd/cd_memory.c @@ -1044,6 +1044,7 @@ static void remap_prg_window(u32 r1, u32 r3) static void remap_word_ram(u32 r3) { void *bank; + int i; // WORD RAM if (!(r3 & 4)) { @@ -1074,7 +1075,6 @@ static void remap_word_ram(u32 r3) #ifdef EMU_F68K // update fetchmap.. - int i; if (!(r3 & 4)) { for (i = M68K_FETCHBANK1*2/16; (i<<(24-FAMEC_FETCHBITS)) < 0x240000; i++) diff --git a/pico/z80if.c b/pico/z80if.c index 8db4aa5c..5efeff89 100644 --- a/pico/z80if.c +++ b/pico/z80if.c @@ -121,8 +121,8 @@ static int z80_unpack_legacy(const void *data) } #elif defined(_USE_CZ80) if (*(int *)data == 0x00007a43) { // "Cz" save? - memcpy(&CZ80, data+8, offsetof(cz80_struc, BasePC)); - Cz80_Set_Reg(&CZ80, CZ80_PC, *(int *)(data+4)); + memcpy(&CZ80, (int*)data+8, offsetof(cz80_struc, BasePC)); + Cz80_Set_Reg(&CZ80, CZ80_PC, *(int *)((int*)data+4)); return 0; } #endif From 59da664524da9eeaf8a6b04b2f8710b5b35d9035 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 17 Mar 2014 18:32:28 +0100 Subject: [PATCH 020/124] (MSVC) Rename pico/pico/pico.c and pico/pico/memory.c --- pico/pico/{memory.c => pico_memory.c} | 0 pico/pico/{pico.c => pico_pico.c} | 0 platform/common/common.mak | 2 +- .../libretro/msvc/msvc-2010/msvc-2010.vcxproj | 5 ++++- .../msvc/msvc-2010/msvc-2010.vcxproj.filters | 20 +++++++++++++++---- 5 files changed, 21 insertions(+), 6 deletions(-) rename pico/pico/{memory.c => pico_memory.c} (100%) rename pico/pico/{pico.c => pico_pico.c} (100%) diff --git a/pico/pico/memory.c b/pico/pico/pico_memory.c similarity index 100% rename from pico/pico/memory.c rename to pico/pico/pico_memory.c diff --git a/pico/pico/pico.c b/pico/pico/pico_pico.c similarity index 100% rename from pico/pico/pico.c rename to pico/pico/pico_pico.c diff --git a/platform/common/common.mak b/platform/common/common.mak index d19f16ac..3c0a5127 100644 --- a/platform/common/common.mak +++ b/platform/common/common.mak @@ -104,7 +104,7 @@ else DEFINES += NO_32X endif # Pico -SRCS_COMMON += $(R)pico/pico/pico.c $(R)pico/pico/memory.c $(R)pico/pico/xpcm.c +SRCS_COMMON += $(R)pico/pico/pico_pico.c $(R)pico/pico/pico_memory.c $(R)pico/pico/xpcm.c # carthw SRCS_COMMON += $(R)pico/carthw/carthw.c # SVP diff --git a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj index b792e1af..35e309d8 100644 --- a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj +++ b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj @@ -116,6 +116,9 @@ + + + @@ -147,4 +150,4 @@ - + \ No newline at end of file diff --git a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters index b9fd7053..44573abc 100644 --- a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters +++ b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters @@ -64,6 +64,9 @@ {dd1911b8-6d08-42aa-ab21-0ba1154613e1} + + {a635c355-0290-4923-84c6-8290ea8b0065} + @@ -210,9 +213,6 @@ Source Files\pico\32x - - Source Files\pico\32x - Source Files\pico\32x @@ -261,5 +261,17 @@ Source Files\cpu\sh2\mame + + Source Files + + + Source Files\pico\pico + + + Source Files\pico\pico + + + Source Files\pico\pico + - + \ No newline at end of file From 5e2c5b93a09dce5661799d995544665b31d4ca6f Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 17 Mar 2014 18:44:20 +0100 Subject: [PATCH 021/124] (MSVC) Build fixes --- pico/pico_int.h | 5 +++++ platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pico/pico_int.h b/pico/pico_int.h index f53250aa..e7f530fe 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -32,6 +32,11 @@ extern "C" { #endif +#ifdef _MSC_VER +#define snprintf _snprintf +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#endif // ----------------------- 68000 CPU ----------------------- #ifdef EMU_C68K diff --git a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj index 35e309d8..d5b081e0 100644 --- a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj +++ b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj @@ -49,7 +49,7 @@ Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;%(PreprocessorDefinitions);INLINE=_inline;_CRT_SECURE_NO_WARNINGS;EMU_F68K;_USE_CZ80;NO_ZLIB + WIN32;_DEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;%(PreprocessorDefinitions);INLINE=_inline;_CRT_SECURE_NO_WARNINGS;EMU_F68K;_USE_CZ80;NO_ZLIB;FAMEC_NO_GOTOS CompileAsC $(SolutionDir)\..\..\..\;$(SolutionDIr)\..\..\..\pico;%(AdditionalIncludeDirectories) @@ -66,7 +66,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;%(PreprocessorDefinitions);INLINE=_inline;_CRT_SECURE_NO_WARNINGS;EMU_F68K;_USE_CZ80;NO_ZLIB + WIN32;NDEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;%(PreprocessorDefinitions);INLINE=_inline;_CRT_SECURE_NO_WARNINGS;EMU_F68K;_USE_CZ80;NO_ZLIB;FAMEC_NO_GOTOS CompileAsC $(SolutionDir)\..\..\..\;$(SolutionDIr)\..\..\..\pico;%(AdditionalIncludeDirectories) From e8b82e7b2be020d749505d6ee88c4a8f1d7547fa Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 17 Mar 2014 20:04:57 +0100 Subject: [PATCH 022/124] (MSVC 2010) Make use of module definition file --- platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj index d5b081e0..b6a76116 100644 --- a/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj +++ b/platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj @@ -39,9 +39,11 @@ true + $(SolutionDir)msvc-2010\$(Configuration)\ false + $(SolutionDir)msvc-2010\$(Configuration)\ @@ -56,6 +58,7 @@ Windows true + libretro.def @@ -75,6 +78,7 @@ true true true + libretro.def From d053448171c8de783da013c2642a7ee7d2482c63 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 8 Apr 2014 02:37:16 +0200 Subject: [PATCH 023/124] Build fix --- jni/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jni/Android.mk b/jni/Android.mk index cf96faa7..3a5a1fe7 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -74,7 +74,7 @@ LOCAL_SRC_FILES += $(R)unzip/unzip.c $(R)unzip/unzip_stream.c LOCAL_C_INCLUDES += $(R) # note: don't use -O3, causes some NDKs run out of memory while compiling FAME -LOCAL_CFLAGS += -Wall -O2 -ffast-math -DNDEBUG +LOCAL_CFLAGS += -Wall -O2 -ffast-math -DNDEBUG -DINLINE=inline LOCAL_CFLAGS += $(addprefix -D,$(DEFINES)) LOCAL_LDLIBS := -llog From 5cd97263ce3d2fe446fa2d5856c4401326094714 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 14 Apr 2014 07:24:58 +0200 Subject: [PATCH 024/124] (OSX PPC) Improve upon some build rules --- Makefile | 2 +- Makefile.libretro | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d7a01dfe..7a4e1301 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ CFLAGS += -Wall -ggdb -falign-functions=2 CFLAGS += -I. -DINLINE=inline ifndef DEBUG CFLAGS += -O2 -DNDEBUG -ffunction-sections -ifeq ($(findstring clang,$(CC)),) +ifneq ($(APPLE),1) LDFLAGS += -Wl,--gc-sections endif endif diff --git a/Makefile.libretro b/Makefile.libretro index 76795050..fdb268bc 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -8,6 +8,10 @@ else ifneq ($(findstring MINGW,$(shell uname -a)),) platform = win else ifneq ($(findstring Darwin,$(shell uname -a)),) platform = osx + arch = intel +ifeq ($(shell uname -p),powerpc) + arch = ppc +endif else ifneq ($(findstring win,$(shell uname -a)),) platform = win endif @@ -34,10 +38,22 @@ ifeq ($(platform), unix) SHARED := -shared else ifeq ($(platform), osx) TARGET := $(TARGET_NAME)_libretro.dylib - SHARED := -dynamiclib -mmacosx-version-min=10.6 + SHARED := -dynamiclib + APPLE := 1 + + arch = intel +ifeq ($(shell uname -p),powerpc) + arch = ppc +endif + +ifeq ($(arch),ppc) +else + SHARED += -mmacosx-version-min=10.6 +endif else ifeq ($(platform), ios) TARGET := $(TARGET_NAME)_libretro_ios.dylib SHARED := -dynamiclib + APPLE := 1 CC = clang -arch armv7 -isysroot $(IOSSDK) -miphoneos-version-min=5.0 CXX = clang++ -arch armv7 -isysroot $(IOSSDK) -miphoneos-version-min=5.0 From 2a7cbfdfd0cea083d9038ba4c4d2faf5427ed1ec Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 14 Apr 2014 15:55:28 +0200 Subject: [PATCH 025/124] Clang fix build --- pico/sound/ym2612.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pico/sound/ym2612.c b/pico/sound/ym2612.c index efe5054e..55234f64 100644 --- a/pico/sound/ym2612.c +++ b/pico/sound/ym2612.c @@ -742,7 +742,7 @@ INLINE int advance_lfo(int lfo_ampm, UINT32 lfo_cnt_old, UINT32 lfo_cnt) #define EG_INC_VAL() \ ((1 << ((pack >> ((eg_cnt>>shift)&7)*3)&7)) >> 1) -INLINE UINT32 update_eg_phase(FM_SLOT *SLOT, UINT32 eg_cnt) +UINT32 update_eg_phase(FM_SLOT *SLOT, UINT32 eg_cnt) { INT32 volume = SLOT->volume; @@ -1201,7 +1201,7 @@ static int chan_render(int *buffer, int length, int c, UINT32 flags) // flags: s } /* update phase increment and envelope generator */ -INLINE void refresh_fc_eg_slot(FM_SLOT *SLOT, int fc, int kc) +void refresh_fc_eg_slot(FM_SLOT *SLOT, int fc, int kc) { int ksr, fdt; From 5a13b150c5886f41f6c58db66a20f264249e120e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 14 Apr 2014 16:00:06 +0200 Subject: [PATCH 026/124] Add -DFAMEC_NO_GOTOS for OSX PPC GCC build --- Makefile.libretro | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.libretro b/Makefile.libretro index fdb268bc..361ae159 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -47,6 +47,7 @@ ifeq ($(shell uname -p),powerpc) endif ifeq ($(arch),ppc) + CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -DFAMEC_NO_GOTOS else SHARED += -mmacosx-version-min=10.6 endif From 34964a8b8e7b0f219ab18bd13d574d5b35b30bca Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 14 Apr 2014 20:58:27 +0200 Subject: [PATCH 027/124] Cleaner build fix for pedantic LLVM Clang issue - http://stackoverflow.com/questions/12844729/linking-error-for-inline-functions --- pico/sound/ym2612.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pico/sound/ym2612.c b/pico/sound/ym2612.c index 55234f64..f7a073fb 100644 --- a/pico/sound/ym2612.c +++ b/pico/sound/ym2612.c @@ -139,6 +139,10 @@ void memset32(int *dest, int c, int count); #define INLINE static __inline #endif +#ifndef STRICTINLINE +#define STRICTINLINE static inline +#endif + #ifndef M_PI #define M_PI 3.14159265358979323846 #endif @@ -742,7 +746,7 @@ INLINE int advance_lfo(int lfo_ampm, UINT32 lfo_cnt_old, UINT32 lfo_cnt) #define EG_INC_VAL() \ ((1 << ((pack >> ((eg_cnt>>shift)&7)*3)&7)) >> 1) -UINT32 update_eg_phase(FM_SLOT *SLOT, UINT32 eg_cnt) +STRICTINLINE UINT32 update_eg_phase(FM_SLOT *SLOT, UINT32 eg_cnt) { INT32 volume = SLOT->volume; @@ -1201,7 +1205,7 @@ static int chan_render(int *buffer, int length, int c, UINT32 flags) // flags: s } /* update phase increment and envelope generator */ -void refresh_fc_eg_slot(FM_SLOT *SLOT, int fc, int kc) +STRICTINLINE void refresh_fc_eg_slot(FM_SLOT *SLOT, int fc, int kc) { int ksr, fdt; From 05689b390bad4c5739500dd74e4d4c0c7388eb0c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 26 Apr 2014 04:30:13 +0200 Subject: [PATCH 028/124] Add OSX version minor detection to Makefile --- Makefile.libretro | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index 361ae159..87d82723 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -48,20 +48,29 @@ endif ifeq ($(arch),ppc) CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -DFAMEC_NO_GOTOS -else - SHARED += -mmacosx-version-min=10.6 +endif +OSXVER = `sw_vers -productVersion | cut -c 4` +ifneq ($(OSXVER),9) + SHARED += -mmacosx-version-min=10.5 endif else ifeq ($(platform), ios) TARGET := $(TARGET_NAME)_libretro_ios.dylib SHARED := -dynamiclib APPLE := 1 - CC = clang -arch armv7 -isysroot $(IOSSDK) -miphoneos-version-min=5.0 - CXX = clang++ -arch armv7 -isysroot $(IOSSDK) -miphoneos-version-min=5.0 - CC_AS = perl ./tools/gas-preprocessor.pl $(CC) -miphoneos-version-min=5.0 + CC = clang -arch armv7 -isysroot $(IOSSDK) + CXX = clang++ -arch armv7 -isysroot $(IOSSDK) + CC_AS = perl ./tools/gas-preprocessor.pl $(CC) CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon - CFLAGS += -DIOS -miphoneos-version-min=5.0 + CFLAGS += -DIOS +OSXVER = `sw_vers -productVersion | cut -c 4` +ifneq ($(OSXVER),9) + 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 ARCH := arm From 2f832b7f195349e339d5db14d7ba43002a753b60 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 23 Jun 2014 15:07:47 +0200 Subject: [PATCH 029/124] Add performance level --- platform/libretro/libretro.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 662254e2..3179c091 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -899,6 +899,13 @@ void retro_run(void) vout_width, vout_height, vout_width * 2); } +static void check_system_specs(void) +{ + /* TODO - set different performance level for 32X - 6 for ARM dynarec, higher for interpreter core */ + unsigned level = 5; + environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level); +} + void retro_init(void) { struct retro_log_callback log; From f3652f885d66fe76f69ec16e38af85c2fcfa851c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Su=C3=A1rez?= Date: Wed, 30 Jul 2014 09:30:52 -0500 Subject: [PATCH 030/124] fix libretro-super build --- Makefile.libretro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index 87d82723..6e43abcf 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -212,7 +212,7 @@ ifneq (,$(findstring armasm,$(platform))) endif ARCH = arm else - TARGET := $(TARGET_NAME)_retro.dll + TARGET := $(TARGET_NAME)_libretro.dll CC = gcc LD_FLAGS := -fPIC SHARED := -shared -static-libgcc -static-libstdc++ From 9a883d9533c9f494b5fc3a2be8c275cb4f4426a5 Mon Sep 17 00:00:00 2001 From: sergiobenrocha2 Date: Mon, 4 Aug 2014 21:04:36 -0300 Subject: [PATCH 031/124] Libretro core should use zlib from the system, in linux build. --- Makefile.libretro | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.libretro b/Makefile.libretro index 6e43abcf..640fecf5 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -36,6 +36,7 @@ asm_mix = 0 ifeq ($(platform), unix) TARGET := $(TARGET_NAME)_libretro.so SHARED := -shared + DONT_COMPILE_IN_ZLIB = 1 else ifeq ($(platform), osx) TARGET := $(TARGET_NAME)_libretro.dylib SHARED := -dynamiclib From 48c9441c68602f0486beea033b572beef9eefe90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Higor=20Eur=C3=ADpedes?= Date: Thu, 28 Aug 2014 12:52:34 -0300 Subject: [PATCH 032/124] (Haiku) Fix build --- Makefile.libretro | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index 640fecf5..271d6045 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -237,7 +237,9 @@ asm_mix = 1 endif CFLAGS += -fPIC -LDLIBS += -lm +ifeq ($(findstring Haiku,$(shell uname -a)),) + LDLIBS += -lm +endif SHARED ?= -shared LDFLAGS += $(SHARED) From 3f4b091194d29dd90a3cb88fd6520f677ffece65 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 22 Sep 2014 22:20:46 +0000 Subject: [PATCH 033/124] Update libretro.h --- platform/libretro/libretro.h | 1900 ++++++++++++++++++++++++---------- 1 file changed, 1356 insertions(+), 544 deletions(-) diff --git a/platform/libretro/libretro.h b/platform/libretro/libretro.h index ede60f04..16c274a1 100644 --- a/platform/libretro/libretro.h +++ b/platform/libretro/libretro.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2013 The RetroArch team +/* Copyright (C) 2010-2014 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this libretro API header (libretro.h). @@ -27,11 +27,14 @@ #include #include -// Hack applied for MSVC when compiling in C89 mode as it isn't C99 compliant. #ifdef __cplusplus extern "C" { -#else -#if defined(_MSC_VER) && !defined(SN_TARGET_PS3) && !defined(__cplusplus) +#endif + +#ifndef __cplusplus +#if defined(_MSC_VER) && !defined(SN_TARGET_PS3) +/* Hack applied for MSVC when compiling in C89 mode + * as it isn't C99-compliant. */ #define bool unsigned char #define true 1 #define false 0 @@ -40,76 +43,104 @@ extern "C" { #endif #endif -// Used for checking API/ABI mismatches that can break libretro implementations. -// It is not incremented for compatible changes to the API. +/* Used for checking API/ABI mismatches that can break libretro + * implementations. + * It is not incremented for compatible changes to the API. + */ #define RETRO_API_VERSION 1 -// Libretro's fundamental device abstractions. -#define RETRO_DEVICE_MASK 0xff +/* + * Libretro's fundamental device abstractions. + * + * Libretro's input system consists of some standardized device types, + * such as a joypad (with/without analog), mouse, keyboard, lightgun + * and a pointer. + * + * The functionality of these devices are fixed, and individual cores + * map their own concept of a controller to libretro's abstractions. + * This makes it possible for frontends to map the abstract types to a + * real input device, and not having to worry about binding input + * correctly to arbitrary controller layouts. + */ + +#define RETRO_DEVICE_TYPE_SHIFT 8 +#define RETRO_DEVICE_MASK ((1 << RETRO_DEVICE_TYPE_SHIFT) - 1) +#define RETRO_DEVICE_SUBCLASS(base, id) (((id + 1) << RETRO_DEVICE_TYPE_SHIFT) | base) + +/* Input disabled. */ #define RETRO_DEVICE_NONE 0 -// The JOYPAD is called RetroPad. It is essentially a Super Nintendo controller, -// but with additional L2/R2/L3/R3 buttons, similar to a PS1 DualShock. +/* The JOYPAD is called RetroPad. It is essentially a Super Nintendo + * controller, but with additional L2/R2/L3/R3 buttons, similar to a + * PS1 DualShock. */ #define RETRO_DEVICE_JOYPAD 1 -// The mouse is a simple mouse, similar to Super Nintendo's mouse. -// X and Y coordinates are reported relatively to last poll (poll callback). -// It is up to the libretro implementation to keep track of where the mouse pointer is supposed to be on the screen. -// The frontend must make sure not to interfere with its own hardware mouse pointer. +/* The mouse is a simple mouse, similar to Super Nintendo's mouse. + * X and Y coordinates are reported relatively to last poll (poll callback). + * It is up to the libretro implementation to keep track of where the mouse + * pointer is supposed to be on the screen. + * The frontend must make sure not to interfere with its own hardware + * mouse pointer. + */ #define RETRO_DEVICE_MOUSE 2 -// KEYBOARD device lets one poll for raw key pressed. -// It is poll based, so input callback will return with the current pressed state. +/* KEYBOARD device lets one poll for raw key pressed. + * It is poll based, so input callback will return with the current + * pressed state. + * For event/text based keyboard input, see + * RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK. + */ #define RETRO_DEVICE_KEYBOARD 3 -// Lightgun X/Y coordinates are reported relatively to last poll, similar to mouse. +/* Lightgun X/Y coordinates are reported relatively to last poll, + * similar to mouse. */ #define RETRO_DEVICE_LIGHTGUN 4 -// The ANALOG device is an extension to JOYPAD (RetroPad). -// Similar to DualShock it adds two analog sticks. -// This is treated as a separate device type as it returns values in the full analog range -// of [-0x8000, 0x7fff]. Positive X axis is right. Positive Y axis is down. -// Only use ANALOG type when polling for analog values of the axes. +/* The ANALOG device is an extension to JOYPAD (RetroPad). + * Similar to DualShock it adds two analog sticks. + * This is treated as a separate device type as it returns values in the + * full analog range of [-0x8000, 0x7fff]. Positive X axis is right. + * Positive Y axis is down. + * Only use ANALOG type when polling for analog values of the axes. + */ #define RETRO_DEVICE_ANALOG 5 -// Abstracts the concept of a pointing mechanism, e.g. touch. -// This allows libretro to query in absolute coordinates where on the screen a mouse (or something similar) is being placed. -// For a touch centric device, coordinates reported are the coordinates of the press. -// -// Coordinates in X and Y are reported as: -// [-0x7fff, 0x7fff]: -0x7fff corresponds to the far left/top of the screen, -// and 0x7fff corresponds to the far right/bottom of the screen. -// The "screen" is here defined as area that is passed to the frontend and later displayed on the monitor. -// The frontend is free to scale/resize this screen as it sees fit, however, -// (X, Y) = (-0x7fff, -0x7fff) will correspond to the top-left pixel of the game image, etc. -// -// To check if the pointer coordinates are valid (e.g. a touch display actually being touched), -// PRESSED returns 1 or 0. -// If using a mouse, PRESSED will usually correspond to the left mouse button. -// PRESSED will only return 1 if the pointer is inside the game screen. -// -// For multi-touch, the index variable can be used to successively query more presses. -// If index = 0 returns true for _PRESSED, coordinates can be extracted -// with _X, _Y for index = 0. One can then query _PRESSED, _X, _Y with index = 1, and so on. -// Eventually _PRESSED will return false for an index. No further presses are registered at this point. +/* Abstracts the concept of a pointing mechanism, e.g. touch. + * This allows libretro to query in absolute coordinates where on the + * screen a mouse (or something similar) is being placed. + * For a touch centric device, coordinates reported are the coordinates + * of the press. + * + * Coordinates in X and Y are reported as: + * [-0x7fff, 0x7fff]: -0x7fff corresponds to the far left/top of the screen, + * and 0x7fff corresponds to the far right/bottom of the screen. + * The "screen" is here defined as area that is passed to the frontend and + * later displayed on the monitor. + * + * The frontend is free to scale/resize this screen as it sees fit, however, + * (X, Y) = (-0x7fff, -0x7fff) will correspond to the top-left pixel of the + * game image, etc. + * + * To check if the pointer coordinates are valid (e.g. a touch display + * actually being touched), PRESSED returns 1 or 0. + * + * If using a mouse on a desktop, PRESSED will usually correspond to the + * left mouse button, but this is a frontend decision. + * PRESSED will only return 1 if the pointer is inside the game screen. + * + * For multi-touch, the index variable can be used to successively query + * more presses. + * If index = 0 returns true for _PRESSED, coordinates can be extracted + * with _X, _Y for index = 0. One can then query _PRESSED, _X, _Y with + * index = 1, and so on. + * Eventually _PRESSED will return false for an index. No further presses + * are registered at this point. */ #define RETRO_DEVICE_POINTER 6 -// FIXME: Document this. -#define RETRO_DEVICE_SENSOR_ACCELEROMETER 7 - -// These device types are specializations of the base types above. -// They should only be used in retro_set_controller_type() to inform libretro implementations -// about use of a very specific device type. -// -// In input state callback, however, only the base type should be used in the 'device' field. -#define RETRO_DEVICE_JOYPAD_MULTITAP ((1 << 8) | RETRO_DEVICE_JOYPAD) -#define RETRO_DEVICE_LIGHTGUN_SUPER_SCOPE ((1 << 8) | RETRO_DEVICE_LIGHTGUN) -#define RETRO_DEVICE_LIGHTGUN_JUSTIFIER ((2 << 8) | RETRO_DEVICE_LIGHTGUN) -#define RETRO_DEVICE_LIGHTGUN_JUSTIFIERS ((3 << 8) | RETRO_DEVICE_LIGHTGUN) - -// Buttons for the RetroPad (JOYPAD). -// The placement of these is equivalent to placements on the Super Nintendo controller. -// L2/R2/L3/R3 buttons correspond to the PS1 DualShock. +/* Buttons for the RetroPad (JOYPAD). + * The placement of these is equivalent to placements on the + * Super Nintendo controller. + * L2/R2/L3/R3 buttons correspond to the PS1 DualShock. */ #define RETRO_DEVICE_ID_JOYPAD_B 0 #define RETRO_DEVICE_ID_JOYPAD_Y 1 #define RETRO_DEVICE_ID_JOYPAD_SELECT 2 @@ -127,19 +158,22 @@ extern "C" { #define RETRO_DEVICE_ID_JOYPAD_L3 14 #define RETRO_DEVICE_ID_JOYPAD_R3 15 -// Index / Id values for ANALOG device. +/* Index / Id values for ANALOG device. */ #define RETRO_DEVICE_INDEX_ANALOG_LEFT 0 #define RETRO_DEVICE_INDEX_ANALOG_RIGHT 1 #define RETRO_DEVICE_ID_ANALOG_X 0 #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 +/* 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 -// Id values for LIGHTGUN types. +/* Id values for LIGHTGUN types. */ #define RETRO_DEVICE_ID_LIGHTGUN_X 0 #define RETRO_DEVICE_ID_LIGHTGUN_Y 1 #define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER 2 @@ -148,55 +182,61 @@ extern "C" { #define RETRO_DEVICE_ID_LIGHTGUN_PAUSE 5 #define RETRO_DEVICE_ID_LIGHTGUN_START 6 -// Id values for POINTER. +/* Id values for POINTER. */ #define RETRO_DEVICE_ID_POINTER_X 0 #define RETRO_DEVICE_ID_POINTER_Y 1 #define RETRO_DEVICE_ID_POINTER_PRESSED 2 -// Id values for SENSOR types. -#define RETRO_DEVICE_ID_SENSOR_ACCELEROMETER_X 0 -#define RETRO_DEVICE_ID_SENSOR_ACCELEROMETER_Y 1 -#define RETRO_DEVICE_ID_SENSOR_ACCELEROMETER_Z 2 - -// Returned from retro_get_region(). +/* Returned from retro_get_region(). */ #define RETRO_REGION_NTSC 0 #define RETRO_REGION_PAL 1 -// Passed to retro_get_memory_data/size(). -// If the memory type doesn't apply to the implementation NULL/0 can be returned. +/* Id values for LANGUAGE */ +enum retro_language +{ + RETRO_LANGUAGE_ENGLISH = 0, + RETRO_LANGUAGE_JAPANESE = 1, + RETRO_LANGUAGE_FRENCH = 2, + RETRO_LANGUAGE_SPANISH = 3, + RETRO_LANGUAGE_GERMAN = 4, + RETRO_LANGUAGE_ITALIAN = 5, + RETRO_LANGUAGE_DUTCH = 6, + RETRO_LANGUAGE_PORTUGUESE = 7, + RETRO_LANGUAGE_RUSSIAN = 8, + RETRO_LANGUAGE_KOREAN = 9, + RETRO_LANGUAGE_CHINESE_TRADITIONAL = 10, + RETRO_LANGUAGE_CHINESE_SIMPLIFIED = 11, + RETRO_LANGUAGE_LAST, + + /* Ensure sizeof(enum) == sizeof(int) */ + RETRO_LANGUAGE_DUMMY = INT_MAX +}; + +/* Passed to retro_get_memory_data/size(). + * If the memory type doesn't apply to the + * implementation NULL/0 can be returned. + */ #define RETRO_MEMORY_MASK 0xff -// Regular save ram. This ram is usually found on a game cartridge, backed up by a battery. -// If save game data is too complex for a single memory buffer, -// the SYSTEM_DIRECTORY environment callback can be used. +/* Regular save RAM. This RAM is usually found on a game cartridge, + * backed up by a battery. + * If save game data is too complex for a single memory buffer, + * the SAVE_DIRECTORY (preferably) or SYSTEM_DIRECTORY environment + * callback can be used. */ #define RETRO_MEMORY_SAVE_RAM 0 -// Some games have a built-in clock to keep track of time. -// This memory is usually just a couple of bytes to keep track of time. +/* Some games have a built-in clock to keep track of time. + * This memory is usually just a couple of bytes to keep track of time. + */ #define RETRO_MEMORY_RTC 1 -// System ram lets a frontend peek into a game systems main RAM. +/* System ram lets a frontend peek into a game systems main RAM. */ #define RETRO_MEMORY_SYSTEM_RAM 2 -// Video ram lets a frontend peek into a game systems video RAM (VRAM). +/* Video ram lets a frontend peek into a game systems video RAM (VRAM). */ #define RETRO_MEMORY_VIDEO_RAM 3 -// Special memory types. -#define RETRO_MEMORY_SNES_BSX_RAM ((1 << 8) | RETRO_MEMORY_SAVE_RAM) -#define RETRO_MEMORY_SNES_BSX_PRAM ((2 << 8) | RETRO_MEMORY_SAVE_RAM) -#define RETRO_MEMORY_SNES_SUFAMI_TURBO_A_RAM ((3 << 8) | RETRO_MEMORY_SAVE_RAM) -#define RETRO_MEMORY_SNES_SUFAMI_TURBO_B_RAM ((4 << 8) | RETRO_MEMORY_SAVE_RAM) -#define RETRO_MEMORY_SNES_GAME_BOY_RAM ((5 << 8) | RETRO_MEMORY_SAVE_RAM) -#define RETRO_MEMORY_SNES_GAME_BOY_RTC ((6 << 8) | RETRO_MEMORY_RTC) - -// Special game types passed into retro_load_game_special(). -// Only used when multiple ROMs are required. -#define RETRO_GAME_TYPE_BSX 0x101 -#define RETRO_GAME_TYPE_BSX_SLOTTED 0x102 -#define RETRO_GAME_TYPE_SUFAMI_TURBO 0x103 -#define RETRO_GAME_TYPE_SUPER_GAME_BOY 0x104 - -// Keysyms used for ID in input state callback when polling RETRO_KEYBOARD. +/* Keysyms used for ID in input state callback when polling RETRO_KEYBOARD. */ enum retro_key { RETROK_UNKNOWN = 0, @@ -344,7 +384,7 @@ enum retro_key RETROK_LAST, - RETROK_DUMMY = INT_MAX // Ensure sizeof(enum) == sizeof(int) + RETROK_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */ }; enum retro_mod @@ -360,214 +400,692 @@ enum retro_mod RETROKMOD_CAPSLOCK = 0x20, RETROKMOD_SCROLLOCK = 0x40, - RETROKMOD_DUMMY = INT_MAX // Ensure sizeof(enum) == sizeof(int) + RETROKMOD_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */ }; -// If set, this call is not part of the public libretro API yet. It can change or be removed at any time. +/* If set, this call is not part of the public libretro API yet. It can + * change or be removed at any time. */ #define RETRO_ENVIRONMENT_EXPERIMENTAL 0x10000 -// Environment callback to be used internally in frontend. +/* Environment callback to be used internally in frontend. */ #define RETRO_ENVIRONMENT_PRIVATE 0x20000 -// Environment commands. -#define RETRO_ENVIRONMENT_SET_ROTATION 1 // const unsigned * -- - // Sets screen rotation of graphics. - // Is only implemented if rotation can be accelerated by hardware. - // Valid values are 0, 1, 2, 3, which rotates screen by 0, 90, 180, 270 degrees - // counter-clockwise respectively. - // -#define RETRO_ENVIRONMENT_GET_OVERSCAN 2 // bool * -- - // Boolean value whether or not the implementation should use overscan, or crop away overscan. - // -#define RETRO_ENVIRONMENT_GET_CAN_DUPE 3 // bool * -- - // Boolean value whether or not frontend supports frame duping, - // passing NULL to video frame callback. - // -// Environ 4, 5 are no longer supported (GET_VARIABLE / SET_VARIABLES), and reserved to avoid possible ABI clash. -#define RETRO_ENVIRONMENT_SET_MESSAGE 6 // const struct retro_message * -- - // Sets a message to be displayed in implementation-specific manner for a certain amount of 'frames'. - // Should not be used for trivial messages, which should simply be logged to stderr. -#define RETRO_ENVIRONMENT_SHUTDOWN 7 // N/A (NULL) -- - // Requests the frontend to shutdown. - // Should only be used if game has a specific - // way to shutdown the game from a menu item or similar. - // +/* Environment commands. */ +#define RETRO_ENVIRONMENT_SET_ROTATION 1 /* const unsigned * -- + * Sets screen rotation of graphics. + * Is only implemented if rotation can be accelerated by hardware. + * Valid values are 0, 1, 2, 3, which rotates screen by 0, 90, 180, + * 270 degrees counter-clockwise respectively. + */ +#define RETRO_ENVIRONMENT_GET_OVERSCAN 2 /* bool * -- + * Boolean value whether or not the implementation should use overscan, + * or crop away overscan. + */ +#define RETRO_ENVIRONMENT_GET_CAN_DUPE 3 /* bool * -- + * Boolean value whether or not frontend supports frame duping, + * passing NULL to video frame callback. + */ + + /* Environ 4, 5 are no longer supported (GET_VARIABLE / SET_VARIABLES), + * and reserved to avoid possible ABI clash. + */ + +#define RETRO_ENVIRONMENT_SET_MESSAGE 6 /* const struct retro_message * -- + * Sets a message to be displayed in implementation-specific manner + * for a certain amount of 'frames'. + * Should not be used for trivial messages, which should simply be + * logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a + * fallback, stderr). + */ +#define RETRO_ENVIRONMENT_SHUTDOWN 7 /* N/A (NULL) -- + * Requests the frontend to shutdown. + * Should only be used if game has a specific + * way to shutdown the game from a menu item or similar. + */ #define RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL 8 - // const unsigned * -- - // Gives a hint to the frontend how demanding this implementation - // is on a system. E.g. reporting a level of 2 means - // this implementation should run decently on all frontends - // of level 2 and up. - // - // It can be used by the frontend to potentially warn - // about too demanding implementations. - // - // The levels are "floating", but roughly defined as: - // 0: Low-powered embedded devices such as Raspberry Pi - // 1: 6th generation consoles, such as Wii/Xbox 1, and phones, tablets, etc. - // 2: 7th generation consoles, such as PS3/360, with sub-par CPUs. - // 3: Modern desktop/laptops with reasonably powerful CPUs. - // 4: High-end desktops with very powerful CPUs. - // - // This function can be called on a per-game basis, - // as certain games an implementation can play might be - // particularily demanding. - // If called, it should be called in retro_load_game(). - // + /* const unsigned * -- + * Gives a hint to the frontend how demanding this implementation + * is on a system. E.g. reporting a level of 2 means + * this implementation should run decently on all frontends + * of level 2 and up. + * + * It can be used by the frontend to potentially warn + * about too demanding implementations. + * + * The levels are "floating". + * + * This function can be called on a per-game basis, + * as certain games an implementation can play might be + * particularly demanding. + * If called, it should be called in retro_load_game(). + */ #define RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY 9 - // const char ** -- - // Returns the "system" directory of the frontend. - // This directory can be used to store system specific ROMs such as BIOSes, configuration data, etc. - // The returned value can be NULL. - // If so, no such directory is defined, - // and it's up to the implementation to find a suitable directory. - // + /* const char ** -- + * Returns the "system" directory of the frontend. + * This directory can be used to store system specific + * content such as BIOSes, configuration data, etc. + * The returned value can be NULL. + * If so, no such directory is defined, + * and it's up to the implementation to find a suitable directory. + * + * NOTE: Some cores used this folder also for "save" data such as + * memory cards, etc, for lack of a better place to put it. + * This is now discouraged, and if possible, cores should try to + * use the new GET_SAVE_DIRECTORY. + */ #define RETRO_ENVIRONMENT_SET_PIXEL_FORMAT 10 - // const enum retro_pixel_format * -- - // Sets the internal pixel format used by the implementation. - // The default pixel format is RETRO_PIXEL_FORMAT_0RGB1555. - // This pixel format however, is deprecated (see enum retro_pixel_format). - // If the call returns false, the frontend does not support this pixel format. - // This function should be called inside retro_load_game() or retro_get_system_av_info(). - // + /* const enum retro_pixel_format * -- + * Sets the internal pixel format used by the implementation. + * The default pixel format is RETRO_PIXEL_FORMAT_0RGB1555. + * This pixel format however, is deprecated (see enum retro_pixel_format). + * If the call returns false, the frontend does not support this pixel + * format. + * + * This function should be called inside retro_load_game() or + * retro_get_system_av_info(). + */ #define RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS 11 - // const struct retro_input_descriptor * -- - // Sets an array of retro_input_descriptors. - // It is up to the frontend to present this in a usable way. - // The array is terminated by retro_input_descriptor::description being set to NULL. - // This function can be called at any time, but it is recommended to call it as early as possible. + /* const struct retro_input_descriptor * -- + * Sets an array of retro_input_descriptors. + * It is up to the frontend to present this in a usable way. + * The array is terminated by retro_input_descriptor::description + * being set to NULL. + * This function can be called at any time, but it is recommended + * to call it as early as possible. + */ #define RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK 12 - // const struct retro_keyboard_callback * -- - // Sets a callback function used to notify core about keyboard events. - // + /* const struct retro_keyboard_callback * -- + * Sets a callback function used to notify core about keyboard events. + */ #define RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE 13 - // const struct retro_disk_control_callback * -- - // Sets an interface which frontend can use to eject and insert disk images. - // This is used for games which consist of multiple images and must be manually - // swapped out by the user (e.g. PSX). + /* const struct retro_disk_control_callback * -- + * Sets an interface which frontend can use to eject and insert + * disk images. + * This is used for games which consist of multiple images and + * must be manually swapped out by the user (e.g. PSX). + */ #define RETRO_ENVIRONMENT_SET_HW_RENDER 14 - // struct retro_hw_render_callback * -- - // Sets an interface to let a libretro core render with hardware acceleration. - // Should be called in retro_load_game(). - // If successful, libretro cores will be able to render to a frontend-provided framebuffer. - // The size of this framebuffer will be at least as large as max_width/max_height provided in get_av_info(). - // If HW rendering is used, pass only RETRO_HW_FRAME_BUFFER_VALID or NULL to retro_video_refresh_t. + /* struct retro_hw_render_callback * -- + * Sets an interface to let a libretro core render with + * hardware acceleration. + * Should be called in retro_load_game(). + * If successful, libretro cores will be able to render to a + * frontend-provided framebuffer. + * The size of this framebuffer will be at least as large as + * max_width/max_height provided in get_av_info(). + * If HW rendering is used, pass only RETRO_HW_FRAME_BUFFER_VALID or + * NULL to retro_video_refresh_t. + */ #define RETRO_ENVIRONMENT_GET_VARIABLE 15 - // struct retro_variable * -- - // Interface to acquire user-defined information from environment - // that cannot feasibly be supported in a multi-system way. - // 'key' should be set to a key which has already been set by SET_VARIABLES. - // 'data' will be set to a value or NULL. - // + /* struct retro_variable * -- + * Interface to acquire user-defined information from environment + * that cannot feasibly be supported in a multi-system way. + * 'key' should be set to a key which has already been set by + * SET_VARIABLES. + * 'data' will be set to a value or NULL. + */ #define RETRO_ENVIRONMENT_SET_VARIABLES 16 - // const struct retro_variable * -- - // Allows an implementation to signal the environment - // which variables it might want to check for later using GET_VARIABLE. - // This allows the frontend to present these variables to a user dynamically. - // This should be called as early as possible (ideally in retro_set_environment). - // - // 'data' points to an array of retro_variable structs terminated by a { NULL, NULL } element. - // retro_variable::key should be namespaced to not collide with other implementations' keys. E.g. A core called 'foo' should use keys named as 'foo_option'. - // retro_variable::value should contain a human readable description of the key as well as a '|' delimited list of expected values. - // The number of possible options should be very limited, i.e. it should be feasible to cycle through options without a keyboard. - // First entry should be treated as a default. - // - // Example entry: - // { "foo_option", "Speed hack coprocessor X; false|true" } - // - // Text before first ';' is description. This ';' must be followed by a space, and followed by a list of possible values split up with '|'. - // Only strings are operated on. The possible values will generally be displayed and stored as-is by the frontend. - // + /* const struct retro_variable * -- + * Allows an implementation to signal the environment + * which variables it might want to check for later using + * GET_VARIABLE. + * This allows the frontend to present these variables to + * a user dynamically. + * This should be called as early as possible (ideally in + * retro_set_environment). + * + * 'data' points to an array of retro_variable structs + * terminated by a { NULL, NULL } element. + * retro_variable::key should be namespaced to not collide + * with other implementations' keys. E.g. A core called + * 'foo' should use keys named as 'foo_option'. + * retro_variable::value should contain a human readable + * description of the key as well as a '|' delimited list + * of expected values. + * + * The number of possible options should be very limited, + * i.e. it should be feasible to cycle through options + * without a keyboard. + * + * First entry should be treated as a default. + * + * Example entry: + * { "foo_option", "Speed hack coprocessor X; false|true" } + * + * Text before first ';' is description. This ';' must be + * followed by a space, and followed by a list of possible + * values split up with '|'. + * + * Only strings are operated on. The possible values will + * generally be displayed and stored as-is by the frontend. + */ #define RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE 17 - // bool * -- - // Result is set to true if some variables are updated by - // frontend since last call to RETRO_ENVIRONMENT_GET_VARIABLE. - // Variables should be queried with GET_VARIABLE. - // + /* bool * -- + * Result is set to true if some variables are updated by + * frontend since last call to RETRO_ENVIRONMENT_GET_VARIABLE. + * Variables should be queried with GET_VARIABLE. + */ #define RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME 18 - // const bool * -- - // If true, the libretro implementation supports calls to retro_load_game() with NULL as argument. - // Used by cores which can run without particular game data. - // This should be called within retro_set_environment() only. - // + /* const bool * -- + * If true, the libretro implementation supports calls to + * retro_load_game() with NULL as argument. + * Used by cores which can run without particular game data. + * This should be called within retro_set_environment() only. + */ #define RETRO_ENVIRONMENT_GET_LIBRETRO_PATH 19 - // const char ** -- - // Retrieves the absolute path from where this libretro implementation was loaded. - // NULL is returned if the libretro was loaded statically (i.e. linked statically to frontend), or if the path cannot be determined. - // Mostly useful in cooperation with SET_SUPPORT_NO_GAME as assets can be loaded without ugly hacks. - // - // -// Environment 20 was an obsolete version of SET_AUDIO_CALLBACK. It was not used by any known core at the time, -// and was removed from the API. + /* const char ** -- + * Retrieves the absolute path from where this libretro + * implementation was loaded. + * NULL is returned if the libretro was loaded statically + * (i.e. linked statically to frontend), or if the path cannot be + * determined. + * Mostly useful in cooperation with SET_SUPPORT_NO_GAME as assets can + * be loaded without ugly hacks. + */ + + /* Environment 20 was an obsolete version of SET_AUDIO_CALLBACK. + * It was not used by any known core at the time, + * and was removed from the API. */ #define RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK 22 - // const struct retro_audio_callback * -- - // Sets an interface which is used to notify a libretro core about audio being available for writing. - // The callback can be called from any thread, so a core using this must have a thread safe audio implementation. - // It is intended for games where audio and video are completely asynchronous and audio can be generated on the fly. - // This interface is not recommended for use with emulators which have highly synchronous audio. - // - // The callback only notifies about writability; the libretro core still has to call the normal audio callbacks - // to write audio. The audio callbacks must be called from within the notification callback. - // The amount of audio data to write is up to the implementation. - // Generally, the audio callback will be called continously in a loop. - // - // Due to thread safety guarantees and lack of sync between audio and video, a frontend - // can selectively disallow this interface based on internal configuration. A core using - // this interface must also implement the "normal" audio interface. - // - // A libretro core using SET_AUDIO_CALLBACK should also make use of SET_FRAME_TIME_CALLBACK. + /* const struct retro_audio_callback * -- + * Sets an interface which is used to notify a libretro core about audio + * being available for writing. + * The callback can be called from any thread, so a core using this must + * have a thread safe audio implementation. + * It is intended for games where audio and video are completely + * asynchronous and audio can be generated on the fly. + * This interface is not recommended for use with emulators which have + * highly synchronous audio. + * + * The callback only notifies about writability; the libretro core still + * has to call the normal audio callbacks + * to write audio. The audio callbacks must be called from within the + * notification callback. + * The amount of audio data to write is up to the implementation. + * Generally, the audio callback will be called continously in a loop. + * + * Due to thread safety guarantees and lack of sync between audio and + * video, a frontend can selectively disallow this interface based on + * internal configuration. A core using this interface must also + * implement the "normal" audio interface. + * + * A libretro core using SET_AUDIO_CALLBACK should also make use of + * SET_FRAME_TIME_CALLBACK. + */ #define RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK 21 - // const struct retro_frame_time_callback * -- - // Lets the core know how much time has passed since last invocation of retro_run(). - // The frontend can tamper with the timing to fake fast-forward, slow-motion, frame stepping, etc. - // In this case the delta time will use the reference value in frame_time_callback.. - // + /* const struct retro_frame_time_callback * -- + * Lets the core know how much time has passed since last + * invocation of retro_run(). + * The frontend can tamper with the timing to fake fast-forward, + * slow-motion, frame stepping, etc. + * In this case the delta time will use the reference value + * in frame_time_callback.. + */ #define RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE 23 - // struct retro_rumble_interface * -- - // Gets an interface which is used by a libretro core to set state of rumble motors in controllers. - // A strong and weak motor is supported, and they can be controlled indepedently. - // + /* struct retro_rumble_interface * -- + * Gets an interface which is used by a libretro core to set + * state of rumble motors in controllers. + * A strong and weak motor is supported, and they can be + * controlled indepedently. + */ #define RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES 24 - // uint64_t * -- - // Gets a bitmask telling which device type are expected to be handled properly in a call to retro_input_state_t. - // Devices which are not handled or recognized always return 0 in retro_input_state_t. - // Example bitmask: caps = (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG). - // Should only be called in retro_run(). - // + /* uint64_t * -- + * Gets a bitmask telling which device type are expected to be + * handled properly in a call to retro_input_state_t. + * Devices which are not handled or recognized always return + * 0 in retro_input_state_t. + * Example bitmask: caps = (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG). + * Should only be called in retro_run(). + */ #define RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE (25 | RETRO_ENVIRONMENT_EXPERIMENTAL) - // struct retro_sensor_interface * -- - // Gets access to the sensor interface. - // The purpose of this interface is to allow - // setting state related to sensors such as polling rate, enabling/disable it entirely, etc. - // Reading sensor state is done via the normal input_state_callback API. - // + /* struct retro_sensor_interface * -- + * Gets access to the sensor interface. + * The purpose of this interface is to allow + * setting state related to sensors such as polling rate, + * enabling/disable it entirely, etc. + * Reading sensor state is done via the normal + * input_state_callback API. + */ #define RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE (26 | RETRO_ENVIRONMENT_EXPERIMENTAL) - // struct retro_camera_callback * -- - // Gets an interface to a video camera driver. - // A libretro core can use this interface to get access to a video camera. - // New video frames are delivered in a callback in same thread as retro_run(). - // - // GET_CAMERA_INTERFACE should be called in retro_load_game(). - // - // Depending on the camera implementation used, camera frames will be delivered as a raw framebuffer, - // or as an OpenGL texture directly. - // - // The core has to tell the frontend here which types of buffers can be handled properly. - // An OpenGL texture can only be handled when using a libretro GL core (SET_HW_RENDER). - // It is recommended to use a libretro GL core when using camera interface. - // - // The camera is not started automatically. The retrieved start/stop functions must be used to explicitly - // start and stop the camera driver. - // + /* struct retro_camera_callback * -- + * Gets an interface to a video camera driver. + * A libretro core can use this interface to get access to a + * video camera. + * New video frames are delivered in a callback in same + * thread as retro_run(). + * + * GET_CAMERA_INTERFACE should be called in retro_load_game(). + * + * Depending on the camera implementation used, camera frames + * will be delivered as a raw framebuffer, + * or as an OpenGL texture directly. + * + * The core has to tell the frontend here which types of + * buffers can be handled properly. + * An OpenGL texture can only be handled when using a + * libretro GL core (SET_HW_RENDER). + * It is recommended to use a libretro GL core when + * using camera interface. + * + * The camera is not started automatically. The retrieved start/stop + * functions must be used to explicitly + * start and stop the camera driver. + */ #define RETRO_ENVIRONMENT_GET_LOG_INTERFACE 27 - // struct retro_log_callback * -- - // Gets an interface for logging. This is useful for logging in a cross-platform way - // as certain platforms cannot use use stderr for logging. It also allows the frontend to - // show logging information in a more suitable way. - // If this interface is not used, libretro cores should log to stderr as desired. + /* struct retro_log_callback * -- + * Gets an interface for logging. This is useful for + * logging in a cross-platform way + * as certain platforms cannot use use stderr for logging. + * It also allows the frontend to + * show logging information in a more suitable way. + * If this interface is not used, libretro cores should + * log to stderr as desired. + */ #define RETRO_ENVIRONMENT_GET_PERF_INTERFACE 28 - // struct retro_perf_callback * -- - // Gets an interface for performance counters. This is useful for performance logging in a - // cross-platform way and for detecting architecture-specific features, such as SIMD support. + /* struct retro_perf_callback * -- + * Gets an interface for performance counters. This is useful + * for performance logging in a cross-platform way and for detecting + * architecture-specific features, such as SIMD support. + */ +#define RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE 29 + /* struct retro_location_callback * -- + * Gets access to the location interface. + * The purpose of this interface is to be able to retrieve + * location-based information from the host device, + * such as current latitude / longitude. + */ +#define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30 + /* const char ** -- + * Returns the "content" 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. + * The returned value can be NULL. + * If so, no such directory is defined, + * and it's up to the implementation to find a suitable directory. + */ +#define RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY 31 + /* const char ** -- + * Returns the "save" directory of the frontend. + * This directory can be used to store SRAM, memory cards, + * high scores, etc, if the libretro core + * cannot use the regular memory interface (retro_get_memory_data()). + * + * NOTE: libretro cores used to check GET_SYSTEM_DIRECTORY for + * similar things before. + * They should still check GET_SYSTEM_DIRECTORY if they want to + * be backwards compatible. + * The path here can be NULL. It should only be non-NULL if the + * frontend user has set a specific save path. + */ +#define RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO 32 + /* const struct retro_system_av_info * -- + * Sets a new av_info structure. This can only be called from + * within retro_run(). + * This should *only* be used if the core is completely altering the + * internal resolutions, aspect ratios, timings, sampling rate, etc. + * Calling this can require a full reinitialization of video/audio + * drivers in the frontend, + * + * so it is important to call it very sparingly, and usually only with + * the users explicit consent. + * An eventual driver reinitialize will happen so that video and + * audio callbacks + * happening after this call within the same retro_run() call will + * target the newly initialized driver. + * + * This callback makes it possible to support configurable resolutions + * in games, which can be useful to + * avoid setting the "worst case" in max_width/max_height. + * + * ***HIGHLY RECOMMENDED*** Do not call this callback every time + * resolution changes in an emulator core if it's + * expected to be a temporary change, for the reasons of possible + * driver reinitialization. + * This call is not a free pass for not trying to provide + * correct values in retro_get_system_av_info(). If you need to change + * things like aspect ratio or nominal width/height, + * use RETRO_ENVIRONMENT_SET_GEOMETRY, which is a softer variant + * of SET_SYSTEM_AV_INFO. + * + * If this returns false, the frontend does not acknowledge a + * changed av_info struct. + */ +#define RETRO_ENVIRONMENT_SET_PROC_ADDRESS_CALLBACK 33 + /* const struct retro_get_proc_address_interface * -- + * Allows a libretro core to announce support for the + * get_proc_address() interface. + * This interface allows for a standard way to extend libretro where + * use of environment calls are too indirect, + * e.g. for cases where the frontend wants to call directly into the core. + * + * If a core wants to expose this interface, SET_PROC_ADDRESS_CALLBACK + * **MUST** be called from within retro_set_environment(). + */ +#define RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO 34 + /* const struct retro_subsystem_info * -- + * This environment call introduces the concept of libretro "subsystems". + * A subsystem is a variant of a libretro core which supports + * different kinds of games. + * The purpose of this is to support e.g. emulators which might + * have special needs, e.g. Super Nintendo's Super GameBoy, Sufami Turbo. + * It can also be used to pick among subsystems in an explicit way + * if the libretro implementation is a multi-system emulator itself. + * + * Loading a game via a subsystem is done with retro_load_game_special(), + * and this environment call allows a libretro core to expose which + * subsystems are supported for use with retro_load_game_special(). + * A core passes an array of retro_game_special_info which is terminated + * with a zeroed out retro_game_special_info struct. + * + * If a core wants to use this functionality, SET_SUBSYSTEM_INFO + * **MUST** be called from within retro_set_environment(). + */ +#define RETRO_ENVIRONMENT_SET_CONTROLLER_INFO 35 + /* const struct retro_controller_info * -- + * This environment call lets a libretro core tell the frontend + * which controller types are recognized in calls to + * retro_set_controller_port_device(). + * + * Some emulators such as Super Nintendo + * support multiple lightgun types which must be specifically + * selected from. + * It is therefore sometimes necessary for a frontend to be able + * to tell the core about a special kind of input device which is + * not covered by the libretro input API. + * + * In order for a frontend to understand the workings of an input device, + * it must be a specialized type + * of the generic device types already defined in the libretro API. + * + * Which devices are supported can vary per input port. + * The core must pass an array of const struct retro_controller_info which + * is terminated with a blanked out struct. Each element of the struct + * corresponds to an ascending port index to + * retro_set_controller_port_device(). + * Even if special device types are set in the libretro core, + * libretro should only poll input based on the base input device types. + */ +#define RETRO_ENVIRONMENT_SET_MEMORY_MAPS (36 | RETRO_ENVIRONMENT_EXPERIMENTAL) + /* const struct retro_memory_map * -- + * This environment call lets a libretro core tell the frontend + * about the memory maps this core emulates. + * This can be used to implement, for example, cheats in a core-agnostic way. + * + * Should only be used by emulators; it doesn't make much sense for + * anything else. + * It is recommended to expose all relevant pointers through + * retro_get_memory_* as well. + * + * Can be called from retro_init and retro_load_game. + */ +#define RETRO_ENVIRONMENT_SET_GEOMETRY 37 + /* const struct retro_game_geometry * -- + * This environment call is similar to SET_SYSTEM_AV_INFO for changing + * video parameters, but provides a guarantee that drivers will not be + * reinitialized. + * This can only be called from within retro_run(). + * + * The purpose of this call is to allow a core to alter nominal + * width/heights as well as aspect ratios on-the-fly, which can be + * useful for some emulators to change in run-time. + * + * max_width/max_height arguments are ignored and cannot be changed + * with this call as this could potentially require a reinitialization or a + * non-constant time operation. + * If max_width/max_height are to be changed, SET_SYSTEM_AV_INFO is required. + * + * A frontend must guarantee that this environment call completes in + * constant time. + */ +#define RETRO_ENVIRONMENT_GET_USERNAME 38 + /* const char ** + * Returns the specified username of the frontend, if specified by the user. + * This username can be used as a nickname for a core that has online facilities + * or any other mode where personalization of the user is desirable. + * The returned value can be NULL. + * If this environ callback is used by a core that requires a valid username, + * a default username should be specified by the core. + */ +#define RETRO_ENVIRONMENT_GET_LANGUAGE 39 + /* unsigned * -- + * Returns the specified language of the frontend, if specified by the user. + * It can be used by the core for localization purposes. + */ + +#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. */ +#define RETRO_MEMDESC_ALIGN_2 (1 << 16) /* All memory access in this area is aligned to their own size, or 2, whichever is smaller. */ +#define RETRO_MEMDESC_ALIGN_4 (2 << 16) +#define RETRO_MEMDESC_ALIGN_8 (3 << 16) +#define RETRO_MEMDESC_MINSIZE_2 (1 << 24) /* All memory in this region is accessed at least 2 bytes at the time. */ +#define RETRO_MEMDESC_MINSIZE_4 (2 << 24) +#define RETRO_MEMDESC_MINSIZE_8 (3 << 24) +struct retro_memory_descriptor +{ + uint64_t flags; + + /* Pointer to the start of the relevant ROM or RAM chip. + * It's strongly recommended to use 'offset' if possible, rather than + * doing math on the pointer. + * + * If the same byte is mapped my multiple descriptors, their descriptors + * must have the same pointer. + * If 'start' does not point to the first byte in the pointer, put the + * difference in 'offset' instead. + * + * May be NULL if there's nothing usable here (e.g. hardware registers and + * open bus). No flags should be set if the pointer is NULL. + * It's recommended to minimize the number of descriptors if possible, + * but not mandatory. */ + void *ptr; + size_t offset; + + /* This is the location in the emulated address space + * where the mapping starts. */ + size_t start; + + /* Which bits must be same as in 'start' for this mapping to apply. + * The first memory descriptor to claim a certain byte is the one + * that applies. + * A bit which is set in 'start' must also be set in this. + * Can be zero, in which case each byte is assumed mapped exactly once. + * In this case, 'len' must be a power of two. */ + size_t select; + + /* If this is nonzero, the set bits are assumed not connected to the + * memory chip's address pins. */ + size_t disconnect; + + /* This one tells the size of the current memory area. + * If, after start+disconnect are applied, the address is higher than + * this, the highest bit of the address is cleared. + * + * If the address is still too high, the next highest bit is cleared. + * Can be zero, in which case it's assumed to be infinite (as limited + * by 'select' and 'disconnect'). */ + size_t len; + + /* To go from emulated address to physical address, the following + * order applies: + * Subtract 'start', pick off 'disconnect', apply 'len', add 'offset'. + * + * The address space name must consist of only a-zA-Z0-9_-, + * should be as short as feasible (maximum length is 8 plus the NUL), + * and may not be any other address space plus one or more 0-9A-F + * at the end. + * However, multiple memory descriptors for the same address space is + * allowed, and the address space name can be empty. NULL is treated + * as empty. + * + * Address space names are case sensitive, but avoid lowercase if possible. + * The same pointer may exist in multiple address spaces. + * + * Examples: + * blank+blank - valid (multiple things may be mapped in the same namespace) + * 'Sp'+'Sp' - valid (multiple things may be mapped in the same namespace) + * 'A'+'B' - valid (neither is a prefix of each other) + * 'S'+blank - valid ('S' is not in 0-9A-F) + * 'a'+blank - valid ('a' is not in 0-9A-F) + * 'a'+'A' - valid (neither is a prefix of each other) + * 'AR'+blank - valid ('R' is not in 0-9A-F) + * 'ARB'+blank - valid (the B can't be part of the address either, because + * there is no namespace 'AR') + * blank+'B' - not valid, because it's ambigous which address space B1234 + * would refer to. + * The length can't be used for that purpose; the frontend may want + * to append arbitrary data to an address, without a separator. */ + const char *addrspace; +}; + +/* The frontend may use the largest value of 'start'+'select' in a + * certain namespace to infer the size of the address space. + * + * If the address space is larger than that, a mapping with .ptr=NULL + * should be at the end of the array, with .select set to all ones for + * as long as the address space is big. + * + * Sample descriptors (minus .ptr, and RETRO_MEMFLAG_ on the flags): + * SNES WRAM: + * .start=0x7E0000, .len=0x20000 + * (Note that this must be mapped before the ROM in most cases; some of the + * ROM mappers + * try to claim $7E0000, or at least $7E8000.) + * SNES SPC700 RAM: + * .addrspace="S", .len=0x10000 + * SNES WRAM mirrors: + * .flags=MIRROR, .start=0x000000, .select=0xC0E000, .len=0x2000 + * .flags=MIRROR, .start=0x800000, .select=0xC0E000, .len=0x2000 + * SNES WRAM mirrors, alternate equivalent descriptor: + * .flags=MIRROR, .select=0x40E000, .disconnect=~0x1FFF + * (Various similar constructions can be created by combining parts of + * the above two.) + * SNES LoROM (512KB, mirrored a couple of times): + * .flags=CONST, .start=0x008000, .select=0x408000, .disconnect=0x8000, .len=512*1024 + * .flags=CONST, .start=0x400000, .select=0x400000, .disconnect=0x8000, .len=512*1024 + * SNES HiROM (4MB): + * .flags=CONST, .start=0x400000, .select=0x400000, .len=4*1024*1024 + * .flags=CONST, .offset=0x8000, .start=0x008000, .select=0x408000, .len=4*1024*1024 + * SNES ExHiROM (8MB): + * .flags=CONST, .offset=0, .start=0xC00000, .select=0xC00000, .len=4*1024*1024 + * .flags=CONST, .offset=4*1024*1024, .start=0x400000, .select=0xC00000, .len=4*1024*1024 + * .flags=CONST, .offset=0x8000, .start=0x808000, .select=0xC08000, .len=4*1024*1024 + * .flags=CONST, .offset=4*1024*1024+0x8000, .start=0x008000, .select=0xC08000, .len=4*1024*1024 + * Clarify the size of the address space: + * .ptr=NULL, .select=0xFFFFFF + * .len can be implied by .select in many of them, but was included for clarity. + */ + +struct retro_memory_map +{ + const struct retro_memory_descriptor *descriptors; + unsigned num_descriptors; +}; + +struct retro_controller_description +{ + /* Human-readable description of the controller. Even if using a generic + * input device type, this can be set to the particular device type the + * core uses. */ + const char *desc; + + /* Device type passed to retro_set_controller_port_device(). If the device + * type is a sub-class of a generic input device type, use the + * RETRO_DEVICE_SUBCLASS macro to create an ID. + * + * E.g. RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1). */ + unsigned id; +}; + +struct retro_controller_info +{ + const struct retro_controller_description *types; + unsigned num_types; +}; + +struct retro_subsystem_memory_info +{ + /* The extension associated with a memory type, e.g. "psram". */ + const char *extension; + + /* The memory type for retro_get_memory(). This should be at + * least 0x100 to avoid conflict with standardized + * libretro memory types. */ + unsigned type; +}; + +struct retro_subsystem_rom_info +{ + /* Describes what the content is (SGB BIOS, GB ROM, etc). */ + const char *desc; + + /* Same definition as retro_get_system_info(). */ + const char *valid_extensions; + + /* Same definition as retro_get_system_info(). */ + bool need_fullpath; + + /* Same definition as retro_get_system_info(). */ + bool block_extract; + + /* This is set if the content is required to load a game. + * If this is set to false, a zeroed-out retro_game_info can be passed. */ + bool required; + + /* Content can have multiple associated persistent + * memory types (retro_get_memory()). */ + const struct retro_subsystem_memory_info *memory; + unsigned num_memory; +}; + +struct retro_subsystem_info +{ + /* Human-readable string of the subsystem type, e.g. "Super GameBoy" */ + const char *desc; + + /* A computer friendly short string identifier for the subsystem type. + * This name must be [a-z]. + * E.g. if desc is "Super GameBoy", this can be "sgb". + * This identifier can be used for command-line interfaces, etc. + */ + const char *ident; + + /* Infos for each content file. The first entry is assumed to be the + * "most significant" content for frontend purposes. + * E.g. with Super GameBoy, the first content should be the GameBoy ROM, + * as it is the most "significant" content to a user. + * If a frontend creates new file paths based on the content used + * (e.g. savestates), it should use the path for the first ROM to do so. */ + const struct retro_subsystem_rom_info *roms; + + /* Number of content files associated with a subsystem. */ + unsigned num_roms; + + /* The type passed to retro_load_game_special(). */ + unsigned id; +}; + +typedef void (*retro_proc_address_t)(void); + +/* libretro API extension functions: + * (None here so far). + * + * Get a symbol from a libretro core. + * Cores should only return symbols which are actual + * extensions to the libretro API. + * + * Frontends should not use this to obtain symbols to standard + * libretro entry points (static linking or dlsym). + * + * The symbol name must be equal to the function name, + * e.g. if void retro_foo(void); exists, the symbol must be called "retro_foo". + * The returned function pointer must be cast to the corresponding type. + */ +typedef retro_proc_address_t (*retro_get_proc_address_t)(const char *sym); + +struct retro_get_proc_address_interface +{ + retro_get_proc_address_t get_proc_address; +}; enum retro_log_level { @@ -579,17 +1097,18 @@ enum retro_log_level RETRO_LOG_DUMMY = INT_MAX }; -// Logging function. Takes log level argument as well. -typedef void (*retro_log_printf_t)(enum retro_log_level level, const char *fmt, ...); +/* Logging function. Takes log level argument as well. */ +typedef void (*retro_log_printf_t)(enum retro_log_level level, + const char *fmt, ...); struct retro_log_callback { retro_log_printf_t log; }; -// Performance related functions -// -// ID values for SIMD CPU features +/* Performance related functions */ + +/* ID values for SIMD CPU features */ #define RETRO_SIMD_SSE (1 << 0) #define RETRO_SIMD_SSE2 (1 << 1) #define RETRO_SIMD_VMX (1 << 2) @@ -598,6 +1117,14 @@ struct retro_log_callback #define RETRO_SIMD_NEON (1 << 5) #define RETRO_SIMD_SSE3 (1 << 6) #define RETRO_SIMD_SSSE3 (1 << 7) +#define RETRO_SIMD_MMX (1 << 8) +#define RETRO_SIMD_MMXEXT (1 << 9) +#define RETRO_SIMD_SSE4 (1 << 10) +#define RETRO_SIMD_SSE42 (1 << 11) +#define RETRO_SIMD_AVX2 (1 << 12) +#define RETRO_SIMD_VFPU (1 << 13) +#define RETRO_SIMD_PS (1 << 14) +#define RETRO_SIMD_AES (1 << 15) typedef uint64_t retro_perf_tick_t; typedef int64_t retro_time_t; @@ -612,54 +1139,70 @@ struct retro_perf_counter bool registered; }; -// Returns current time in microseconds. Tries to use the most accurate timer available. +/* Returns current time in microseconds. + * Tries to use the most accurate timer available. + */ typedef retro_time_t (*retro_perf_get_time_usec_t)(void); -// A simple counter. Usually nanoseconds, but can also be CPU cycles. -// Can be used directly if desired (when creating a more sophisticated performance counter system). + +/* A simple counter. Usually nanoseconds, but can also be CPU cycles. + * Can be used directly if desired (when creating a more sophisticated + * performance counter system). + * */ typedef retro_perf_tick_t (*retro_perf_get_counter_t)(void); -// Returns a bit-mask of detected CPU features (RETRO_SIMD_*). + +/* Returns a bit-mask of detected CPU features (RETRO_SIMD_*). */ typedef uint64_t (*retro_get_cpu_features_t)(void); -// Asks frontend to log and/or display the state of performance counters. -// Performance counters can always be poked into manually as well. + +/* Asks frontend to log and/or display the state of performance counters. + * Performance counters can always be poked into manually as well. + */ typedef void (*retro_perf_log_t)(void); -// Register a performance counter. -// ident field must be set with a discrete value and other values in retro_perf_counter must be 0. -// Registering can be called multiple times. To avoid calling to frontend redundantly, you can check registered field first. + +/* Register a performance counter. + * ident field must be set with a discrete value and other values in + * retro_perf_counter must be 0. + * Registering can be called multiple times. To avoid calling to + * frontend redundantly, you can check registered field first. */ typedef void (*retro_perf_register_t)(struct retro_perf_counter *counter); -// Starts and stops a registered counter. + +/* Starts a registered counter. */ typedef void (*retro_perf_start_t)(struct retro_perf_counter *counter); + +/* Stops a registered counter. */ typedef void (*retro_perf_stop_t)(struct retro_perf_counter *counter); -// For convenience it can be useful to wrap register, start and stop in macros. -// E.g.: -// #ifdef LOG_PERFORMANCE -// #define RETRO_PERFORMANCE_INIT(perf_cb, name) static struct retro_perf_counter name = {#name}; if (!name.registered) perf_cb.perf_register(&(name)) -// #define RETRO_PERFORMANCE_START(perf_cb, name) perf_cb.perf_start(&(name)) -// #define RETRO_PERFORMANCE_STOP(perf_cb, name) perf_cb.perf_stop(&(name)) -// #else -// ... Blank macros ... -// #endif -// These can then be used mid-functions around code snippets. -// -// extern struct retro_perf_callback perf_cb; // Somewhere in the core. -// -// void do_some_heavy_work(void) -// { -// RETRO_PERFORMANCE_INIT(cb, work_1); -// RETRO_PERFORMANCE_START(cb, work_1); -// heavy_work_1(); -// RETRO_PERFORMANCE_STOP(cb, work_1); -// -// RETRO_PERFORMANCE_INIT(cb, work_2); -// RETRO_PERFORMANCE_START(cb, work_2); -// heavy_work_2(); -// RETRO_PERFORMANCE_STOP(cb, work_2); -// } -// -// void retro_deinit(void) -// { -// perf_cb.perf_log(); // Log all perf counters here for example. -// } +/* For convenience it can be useful to wrap register, start and stop in macros. + * E.g.: + * #ifdef LOG_PERFORMANCE + * #define RETRO_PERFORMANCE_INIT(perf_cb, name) static struct retro_perf_counter name = {#name}; if (!name.registered) perf_cb.perf_register(&(name)) + * #define RETRO_PERFORMANCE_START(perf_cb, name) perf_cb.perf_start(&(name)) + * #define RETRO_PERFORMANCE_STOP(perf_cb, name) perf_cb.perf_stop(&(name)) + * #else + * ... Blank macros ... + * #endif + * + * These can then be used mid-functions around code snippets. + * + * extern struct retro_perf_callback perf_cb; * Somewhere in the core. + * + * void do_some_heavy_work(void) + * { + * RETRO_PERFORMANCE_INIT(cb, work_1; + * RETRO_PERFORMANCE_START(cb, work_1); + * heavy_work_1(); + * RETRO_PERFORMANCE_STOP(cb, work_1); + * + * RETRO_PERFORMANCE_INIT(cb, work_2); + * RETRO_PERFORMANCE_START(cb, work_2); + * heavy_work_2(); + * RETRO_PERFORMANCE_STOP(cb, work_2); + * } + * + * void retro_deinit(void) + * { + * perf_cb.perf_log(); * Log all perf counters here for example. + * } + */ struct retro_perf_callback { @@ -673,8 +1216,9 @@ struct retro_perf_callback retro_perf_log_t perf_log; }; -// FIXME: Document the sensor API and work out behavior. -// It will be marked as experimental until then. +/* FIXME: Document the sensor API and work out behavior. + * It will be marked as experimental until then. + */ enum retro_sensor_action { RETRO_SENSOR_ACCELEROMETER_ENABLE = 0, @@ -683,12 +1227,21 @@ enum retro_sensor_action RETRO_SENSOR_DUMMY = INT_MAX }; -typedef bool (*retro_set_sensor_state_t)(unsigned port, enum retro_sensor_action action, unsigned rate); +/* Id values for SENSOR types. */ +#define RETRO_SENSOR_ACCELEROMETER_X 0 +#define RETRO_SENSOR_ACCELEROMETER_Y 1 +#define RETRO_SENSOR_ACCELEROMETER_Z 2 + +typedef bool (*retro_set_sensor_state_t)(unsigned port, + enum retro_sensor_action action, unsigned rate); + +typedef float (*retro_sensor_get_input_t)(unsigned port, unsigned id); + struct retro_sensor_interface { retro_set_sensor_state_t set_sensor_state; + retro_sensor_get_input_t get_sensor_input; }; -//// enum retro_camera_buffer { @@ -698,51 +1251,119 @@ enum retro_camera_buffer RETRO_CAMERA_BUFFER_DUMMY = INT_MAX }; -// Starts the camera driver. Can only be called in retro_run(). +/* Starts the camera driver. Can only be called in retro_run(). */ typedef bool (*retro_camera_start_t)(void); -// Stops the camera driver. Can only be called in retro_run(). + +/* Stops the camera driver. Can only be called in retro_run(). */ typedef void (*retro_camera_stop_t)(void); -// Callback which signals when the camera driver is initialized and/or deinitialized. -// retro_camera_start_t can be called in initialized callback. + +/* Callback which signals when the camera driver is initialized + * and/or deinitialized. + * retro_camera_start_t can be called in initialized callback. + */ typedef void (*retro_camera_lifetime_status_t)(void); -// A callback for raw framebuffer data. buffer points to an XRGB8888 buffer. -// Width, height and pitch are similar to retro_video_refresh_t. -// First pixel is top-left origin. -typedef void (*retro_camera_frame_raw_framebuffer_t)(const uint32_t *buffer, unsigned width, unsigned height, size_t pitch); -// A callback for when OpenGL textures are used. -// -// texture_id is a texture owned by camera driver. -// Its state or content should be considered immutable, except for things like texture filtering and clamping. -// -// texture_target is the texture target for the GL texture. -// These can include e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, and possibly more depending on extensions. -// -// affine points to a packed 3x3 column-major matrix used to apply an affine transform to texture coordinates. (affine_matrix * vec3(coord_x, coord_y, 1.0)) -// After transform, normalized texture coord (0, 0) should be bottom-left and (1, 1) should be top-right (or (width, height) for RECTANGLE). -// -// GL-specific typedefs are avoided here to avoid relying on gl.h in the API definition. -typedef void (*retro_camera_frame_opengl_texture_t)(unsigned texture_id, unsigned texture_target, const float *affine); + +/* A callback for raw framebuffer data. buffer points to an XRGB8888 buffer. + * Width, height and pitch are similar to retro_video_refresh_t. + * First pixel is top-left origin. + */ +typedef void (*retro_camera_frame_raw_framebuffer_t)(const uint32_t *buffer, + unsigned width, unsigned height, size_t pitch); + +/* A callback for when OpenGL textures are used. + * + * texture_id is a texture owned by camera driver. + * Its state or content should be considered immutable, except for things like + * texture filtering and clamping. + * + * texture_target is the texture target for the GL texture. + * These can include e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, and possibly + * more depending on extensions. + * + * affine points to a packed 3x3 column-major matrix used to apply an affine + * transform to texture coordinates. (affine_matrix * vec3(coord_x, coord_y, 1.0)) + * After transform, normalized texture coord (0, 0) should be bottom-left + * and (1, 1) should be top-right (or (width, height) for RECTANGLE). + * + * GL-specific typedefs are avoided here to avoid relying on gl.h in + * the API definition. + */ +typedef void (*retro_camera_frame_opengl_texture_t)(unsigned texture_id, + unsigned texture_target, const float *affine); + struct retro_camera_callback { - uint64_t caps; // Set by libretro core. Example bitmask: caps = (1 << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE) | (1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER). + /* Set by libretro core. + * Example bitmask: caps = (1 << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE) | (1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER). + */ + uint64_t caps; - unsigned width; // Desired resolution for camera. Is only used as a hint. + unsigned width; /* Desired resolution for camera. Is only used as a hint. */ unsigned height; - retro_camera_start_t start; // Set by frontend. - retro_camera_stop_t stop; // Set by frontend. + retro_camera_start_t start; /* Set by frontend. */ + retro_camera_stop_t stop; /* Set by frontend. */ - retro_camera_frame_raw_framebuffer_t frame_raw_framebuffer; // Set by libretro core if raw framebuffer callbacks will be used. - retro_camera_frame_opengl_texture_t frame_opengl_texture; // Set by libretro core if OpenGL texture callbacks will be used. + /* Set by libretro core if raw framebuffer callbacks will be used. */ + retro_camera_frame_raw_framebuffer_t frame_raw_framebuffer; + /* Set by libretro core if OpenGL texture callbacks will be used. */ + retro_camera_frame_opengl_texture_t frame_opengl_texture; - // Set by libretro core. Called after camera driver is initialized and ready to be started. - // Can be NULL, in which this callback is not called. + /* Set by libretro core. Called after camera driver is initialized and + * ready to be started. + * Can be NULL, in which this callback is not called. + */ retro_camera_lifetime_status_t initialized; - // Set by libretro core. Called right before camera driver is deinitialized. - // Can be NULL, in which this callback is not called. + /* Set by libretro core. Called right before camera driver is + * deinitialized. + * Can be NULL, in which this callback is not called. + */ retro_camera_lifetime_status_t deinitialized; }; +/* Sets the interval of time and/or distance at which to update/poll + * location-based data. + * + * To ensure compatibility with all location-based implementations, + * values for both interval_ms and interval_distance should be provided. + * + * interval_ms is the interval expressed in milliseconds. + * interval_distance is the distance interval expressed in meters. + */ +typedef void (*retro_location_set_interval_t)(unsigned interval_ms, + unsigned interval_distance); + +/* Start location services. The device will start listening for changes to the + * current location at regular intervals (which are defined with + * retro_location_set_interval_t). */ +typedef bool (*retro_location_start_t)(void); + +/* Stop location services. The device will stop listening for changes + * to the current location. */ +typedef void (*retro_location_stop_t)(void); + +/* Get the position of the current location. Will set parameters to + * 0 if no new location update has happened since the last time. */ +typedef bool (*retro_location_get_position_t)(double *lat, double *lon, + double *horiz_accuracy, double *vert_accuracy); + +/* Callback which signals when the location driver is initialized + * and/or deinitialized. + * retro_location_start_t can be called in initialized callback. + */ +typedef void (*retro_location_lifetime_status_t)(void); + +struct retro_location_callback +{ + retro_location_start_t start; + retro_location_stop_t stop; + retro_location_get_position_t get_position; + retro_location_set_interval_t set_interval; + + retro_location_lifetime_status_t initialized; + retro_location_lifetime_status_t deinitialized; +}; + enum retro_rumble_effect { RETRO_RUMBLE_STRONG = 0, @@ -751,145 +1372,260 @@ enum retro_rumble_effect RETRO_RUMBLE_DUMMY = INT_MAX }; -// Sets rumble state for joypad plugged in port 'port'. Rumble effects are controlled independently, -// and setting e.g. strong rumble does not override weak rumble. -// Strength has a range of [0, 0xffff]. -// -// Returns true if rumble state request was honored. Calling this before first retro_run() is likely to return false. -typedef bool (*retro_set_rumble_state_t)(unsigned port, enum retro_rumble_effect effect, uint16_t strength); +/* Sets rumble state for joypad plugged in port 'port'. + * Rumble effects are controlled independently, + * and setting e.g. strong rumble does not override weak rumble. + * Strength has a range of [0, 0xffff]. + * + * Returns true if rumble state request was honored. + * Calling this before first retro_run() is likely to return false. */ +typedef bool (*retro_set_rumble_state_t)(unsigned port, + enum retro_rumble_effect effect, uint16_t strength); + struct retro_rumble_interface { retro_set_rumble_state_t set_rumble_state; }; -// Notifies libretro that audio data should be written. +/* Notifies libretro that audio data should be written. */ typedef void (*retro_audio_callback_t)(void); -// True: Audio driver in frontend is active, and callback is expected to be called regularily. -// False: Audio driver in frontend is paused or inactive. Audio callback will not be called until set_state has been called with true. -// Initial state is false (inactive). +/* True: Audio driver in frontend is active, and callback is + * expected to be called regularily. + * False: Audio driver in frontend is paused or inactive. + * Audio callback will not be called until set_state has been + * called with true. + * Initial state is false (inactive). + */ typedef void (*retro_audio_set_state_callback_t)(bool enabled); + struct retro_audio_callback { retro_audio_callback_t callback; retro_audio_set_state_callback_t set_state; }; -// Notifies a libretro core of time spent since last invocation of retro_run() in microseconds. -// It will be called right before retro_run() every frame. -// The frontend can tamper with timing to support cases like fast-forward, slow-motion and framestepping. -// In those scenarios the reference frame time value will be used. +/* Notifies a libretro core of time spent since last invocation + * of retro_run() in microseconds. + * + * It will be called right before retro_run() every frame. + * The frontend can tamper with timing to support cases like + * fast-forward, slow-motion and framestepping. + * + * In those scenarios the reference frame time value will be used. */ typedef int64_t retro_usec_t; typedef void (*retro_frame_time_callback_t)(retro_usec_t usec); struct retro_frame_time_callback { retro_frame_time_callback_t callback; - retro_usec_t reference; // Represents the time of one frame. It is computed as 1000000 / fps, but the implementation will resolve the rounding to ensure that framestepping, etc is exact. + /* Represents the time of one frame. It is computed as + * 1000000 / fps, but the implementation will resolve the + * rounding to ensure that framestepping, etc is exact. */ + retro_usec_t reference; }; -// Pass this to retro_video_refresh_t if rendering to hardware. -// Passing NULL to retro_video_refresh_t is still a frame dupe as normal. +/* Pass this to retro_video_refresh_t if rendering to hardware. + * Passing NULL to retro_video_refresh_t is still a frame dupe as normal. + * */ #define RETRO_HW_FRAME_BUFFER_VALID ((void*)-1) -// Invalidates the current HW context. -// Any GL state is lost, and must not be deinitialized explicitly. If explicit deinitialization is desired by the libretro core, -// it should implement context_destroy callback. -// If called, all GPU resources must be reinitialized. -// Usually called when frontend reinits video driver. -// Also called first time video driver is initialized, allowing libretro core to init resources. +/* Invalidates the current HW context. + * Any GL state is lost, and must not be deinitialized explicitly. + * If explicit deinitialization is desired by the libretro core, + * it should implement context_destroy callback. + * If called, all GPU resources must be reinitialized. + * Usually called when frontend reinits video driver. + * Also called first time video driver is initialized, + * allowing libretro core to initialize resources. + */ typedef void (*retro_hw_context_reset_t)(void); -// Gets current framebuffer which is to be rendered to. Could change every frame potentially. + +/* Gets current framebuffer which is to be rendered to. + * Could change every frame potentially. + */ typedef uintptr_t (*retro_hw_get_current_framebuffer_t)(void); -// Get a symbol from HW context. -typedef void (*retro_proc_address_t)(void); +/* Get a symbol from HW context. */ typedef retro_proc_address_t (*retro_hw_get_proc_address_t)(const char *sym); enum retro_hw_context_type { - RETRO_HW_CONTEXT_NONE = 0, - RETRO_HW_CONTEXT_OPENGL, // OpenGL 2.x. Latest version available before 3.x+. Driver can choose to use latest compatibility context. - RETRO_HW_CONTEXT_OPENGLES2, // GLES 2.0 - RETRO_HW_CONTEXT_OPENGL_CORE, // Modern desktop core GL context. Use major/minor fields to set GL version. - RETRO_HW_CONTEXT_OPENGLES3, // GLES 3.0 + RETRO_HW_CONTEXT_NONE = 0, + /* OpenGL 2.x. Driver can choose to use latest compatibility context. */ + RETRO_HW_CONTEXT_OPENGL = 1, + /* OpenGL ES 2.0. */ + RETRO_HW_CONTEXT_OPENGLES2 = 2, + /* Modern desktop core GL context. Use version_major/ + * version_minor fields to set GL version. */ + RETRO_HW_CONTEXT_OPENGL_CORE = 3, + /* OpenGL ES 3.0 */ + RETRO_HW_CONTEXT_OPENGLES3 = 4, + /* OpenGL ES 3.1+. Set version_major/version_minor. For GLES2 and GLES3, + * use the corresponding enums directly. */ + RETRO_HW_CONTEXT_OPENGLES_VERSION = 5, RETRO_HW_CONTEXT_DUMMY = INT_MAX }; struct retro_hw_render_callback { - enum retro_hw_context_type context_type; // Which API to use. Set by libretro core. - retro_hw_context_reset_t context_reset; // Called when a context has been created or when it has been reset. - retro_hw_get_current_framebuffer_t get_current_framebuffer; // Set by frontend. - retro_hw_get_proc_address_t get_proc_address; // Set by frontend. - bool depth; // Set if render buffers should have depth component attached. - bool stencil; // Set if stencil buffers should be attached. - // If depth and stencil are true, a packed 24/8 buffer will be added. Only attaching stencil is invalid and will be ignored. - bool bottom_left_origin; // Use conventional bottom-left origin convention. Is false, standard libretro top-left origin semantics are used. - unsigned version_major; // Major version number for core GL context. - unsigned version_minor; // Minor version number for core GL context. + /* Which API to use. Set by libretro core. */ + enum retro_hw_context_type context_type; - bool cache_context; // If this is true, the frontend will go very far to avoid resetting context in scenarios like toggling fullscreen, etc. - // The reset callback might still be called in extreme situations such as if the context is lost beyond recovery. - // For optimal stability, set this to false, and allow context to be reset at any time. - retro_hw_context_reset_t context_destroy; // A callback to be called before the context is destroyed. Resources can be deinitialized at this step. This can be set to NULL, in which resources will just be destroyed without any notification. - bool debug_context; // Creates a debug context. + /* Called when a context has been created or when it has been reset. + * An OpenGL context is only valid after context_reset() has been called. + * + * When context_reset is called, OpenGL resources in the libretro + * implementation are guaranteed to be invalid. + * + * It is possible that context_reset is called multiple times during an + * application lifecycle. + * If context_reset is called without any notification (context_destroy), + * the OpenGL context was lost and resources should just be recreated + * without any attempt to "free" old resources. + */ + retro_hw_context_reset_t context_reset; + + /* Set by frontend. */ + 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. */ + bool depth; + + /* Set if stencil buffers should be attached. */ + 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. */ + bool bottom_left_origin; + + /* Major version number for core GL context or GLES 3.1+. */ + unsigned version_major; + + /* Minor version number for core GL context or GLES 3.1+. */ + unsigned version_minor; + + /* If this is true, the frontend will go very far to avoid + * resetting context in scenarios like toggling fullscreen, etc. + */ + bool cache_context; + + /* The reset callback might still be called in extreme situations + * such as if the context is lost beyond recovery. + * + * For optimal stability, set this to false, and allow context to be + * reset at any time. + */ + + /* A callback to be called before the context is destroyed in a + * controlled way by the frontend. */ + retro_hw_context_reset_t context_destroy; + + /* OpenGL resources can be deinitialized cleanly at this step. + * context_destroy can be set to NULL, in which resources will + * just be destroyed without any notification. + * + * Even when context_destroy is non-NULL, it is possible that + * context_reset is called without any destroy notification. + * This happens if context is lost by external factors (such as + * notified by GL_ARB_robustness). + * + * In this case, the context is assumed to be already dead, + * and the libretro implementation must not try to free any OpenGL + * resources in the subsequent context_reset. + */ + + /* Creates a debug context. */ + bool debug_context; }; -// Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK. Called by the frontend in response to keyboard events. -// down is set if the key is being pressed, or false if it is being released. -// keycode is the RETROK value of the char. -// character is the text character of the pressed key. (UTF-32). -// key_modifiers is a set of RETROKMOD values or'ed together. -// -// The pressed/keycode state can be indepedent of the character. -// It is also possible that multiple characters are generated from a single keypress. -// Keycode events should be treated separately from character events. -// However, when possible, the frontend should try to synchronize these. -// If only a character is posted, keycode should be RETROK_UNKNOWN. -// Similarily if only a keycode event is generated with no corresponding character, character should be 0. -typedef void (*retro_keyboard_event_t)(bool down, unsigned keycode, uint32_t character, uint16_t key_modifiers); +/* Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK. + * Called by the frontend in response to keyboard events. + * down is set if the key is being pressed, or false if it is being released. + * keycode is the RETROK value of the char. + * character is the text character of the pressed key. (UTF-32). + * key_modifiers is a set of RETROKMOD values or'ed together. + * + * The pressed/keycode state can be indepedent of the character. + * It is also possible that multiple characters are generated from a + * single keypress. + * Keycode events should be treated separately from character events. + * However, when possible, the frontend should try to synchronize these. + * If only a character is posted, keycode should be RETROK_UNKNOWN. + * + * Similarily if only a keycode event is generated with no corresponding + * character, character should be 0. + */ +typedef void (*retro_keyboard_event_t)(bool down, unsigned keycode, + uint32_t character, uint16_t key_modifiers); struct retro_keyboard_callback { retro_keyboard_event_t callback; }; -// Callbacks for RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE. -// Should be set for implementations which can swap out multiple disk images in runtime. -// If the implementation can do this automatically, it should strive to do so. -// However, there are cases where the user must manually do so. -// -// Overview: To swap a disk image, eject the disk image with set_eject_state(true). -// Set the disk index with set_image_index(index). Insert the disk again with set_eject_state(false). +/* Callbacks for RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE. + * Should be set for implementations which can swap out multiple disk + * images in runtime. + * + * If the implementation can do this automatically, it should strive to do so. + * However, there are cases where the user must manually do so. + * + * Overview: To swap a disk image, eject the disk image with + * set_eject_state(true). + * Set the disk index with set_image_index(index). Insert the disk again + * with set_eject_state(false). + */ -// If ejected is true, "ejects" the virtual disk tray. -// When ejected, the disk image index can be set. +/* If ejected is true, "ejects" the virtual disk tray. + * When ejected, the disk image index can be set. + */ typedef bool (*retro_set_eject_state_t)(bool ejected); -// Gets current eject state. The initial state is 'not ejected'. + +/* Gets current eject state. The initial state is 'not ejected'. */ typedef bool (*retro_get_eject_state_t)(void); -// Gets current disk index. First disk is index 0. -// If return value is >= get_num_images(), no disk is currently inserted. + +/* Gets current disk index. First disk is index 0. + * If return value is >= get_num_images(), no disk is currently inserted. + */ typedef unsigned (*retro_get_image_index_t)(void); -// Sets image index. Can only be called when disk is ejected. -// The implementation supports setting "no disk" by using an index >= get_num_images(). + +/* Sets image index. Can only be called when disk is ejected. + * The implementation supports setting "no disk" by using an + * index >= get_num_images(). + */ typedef bool (*retro_set_image_index_t)(unsigned index); -// Gets total number of images which are available to use. + +/* Gets total number of images which are available to use. */ typedef unsigned (*retro_get_num_images_t)(void); -// -// Replaces the disk image associated with index. -// Arguments to pass in info have same requirements as retro_load_game(). -// Virtual disk tray must be ejected when calling this. -// Replacing a disk image with info = NULL will remove the disk image from the internal list. -// As a result, calls to get_image_index() can change. -// -// E.g. replace_image_index(1, NULL), and previous get_image_index() returned 4 before. -// Index 1 will be removed, and the new index is 3. + struct retro_game_info; -typedef bool (*retro_replace_image_index_t)(unsigned index, const struct retro_game_info *info); -// Adds a new valid index (get_num_images()) to the internal disk list. -// This will increment subsequent return values from get_num_images() by 1. -// This image index cannot be used until a disk image has been set with replace_image_index. + +/* Replaces the disk image associated with index. + * Arguments to pass in info have same requirements as retro_load_game(). + * Virtual disk tray must be ejected when calling this. + * + * Replacing a disk image with info = NULL will remove the disk image + * from the internal list. + * As a result, calls to get_image_index() can change. + * + * E.g. replace_image_index(1, NULL), and previous get_image_index() + * returned 4 before. + * Index 1 will be removed, and the new index is 3. + */ +typedef bool (*retro_replace_image_index_t)(unsigned index, + const struct retro_game_info *info); + +/* Adds a new valid index (get_num_images()) to the internal disk list. + * This will increment subsequent return values from get_num_images() by 1. + * This image index cannot be used until a disk image has been set + * with replace_image_index. */ typedef bool (*retro_add_image_index_t)(void); struct retro_disk_control_callback @@ -907,81 +1643,105 @@ struct retro_disk_control_callback enum retro_pixel_format { - // 0RGB1555, native endian. 0 bit must be set to 0. - // This pixel format is default for compatibility concerns only. - // If a 15/16-bit pixel format is desired, consider using RGB565. + /* 0RGB1555, native endian. + * 0 bit must be set to 0. + * This pixel format is default for compatibility concerns only. + * If a 15/16-bit pixel format is desired, consider using RGB565. */ RETRO_PIXEL_FORMAT_0RGB1555 = 0, - // XRGB8888, native endian. X bits are ignored. + /* XRGB8888, native endian. + * X bits are ignored. */ RETRO_PIXEL_FORMAT_XRGB8888 = 1, - // RGB565, native endian. This pixel format is the recommended format to use if a 15/16-bit format is desired - // as it is the pixel format that is typically available on a wide range of low-power devices. - // It is also natively supported in APIs like OpenGL ES. + /* RGB565, native endian. + * This pixel format is the recommended format to use if a 15/16-bit + * format is desired as it is the pixel format that is typically + * available on a wide range of low-power devices. + * + * It is also natively supported in APIs like OpenGL ES. */ RETRO_PIXEL_FORMAT_RGB565 = 2, - // Ensure sizeof() == sizeof(int). + /* Ensure sizeof() == sizeof(int). */ RETRO_PIXEL_FORMAT_UNKNOWN = INT_MAX }; struct retro_message { - const char *msg; // Message to be displayed. - unsigned frames; // Duration in frames of message. + const char *msg; /* Message to be displayed. */ + unsigned frames; /* Duration in frames of message. */ }; -// Describes how the libretro implementation maps a libretro input bind -// to its internal input system through a human readable string. -// This string can be used to better let a user configure input. +/* Describes how the libretro implementation maps a libretro input bind + * to its internal input system through a human readable string. + * This string can be used to better let a user configure input. */ struct retro_input_descriptor { - // Associates given parameters with a description. + /* Associates given parameters with a description. */ unsigned port; unsigned device; unsigned index; unsigned id; - const char *description; // Human readable description for parameters. - // The pointer must remain valid until retro_unload_game() is called. + /* Human readable description for parameters. + * The pointer must remain valid until + * retro_unload_game() is called. */ + const char *description; }; struct retro_system_info { - // All pointers are owned by libretro implementation, and pointers must remain valid until retro_deinit() is called. + /* All pointers are owned by libretro implementation, and pointers must + * remain valid until retro_deinit() is called. */ - const char *library_name; // Descriptive name of library. Should not contain any version numbers, etc. - const char *library_version; // Descriptive version of core. + const char *library_name; /* Descriptive name of library. Should not + * contain any version numbers, etc. */ + const char *library_version; /* Descriptive version of core. */ - const char *valid_extensions; // A string listing probably rom extensions the core will be able to load, separated with pipe. - // I.e. "bin|rom|iso". - // Typically used for a GUI to filter out extensions. + const char *valid_extensions; /* A string listing probably content + * extensions the core will be able to + * load, separated with pipe. + * I.e. "bin|rom|iso". + * Typically used for a GUI to filter + * out extensions. */ - bool need_fullpath; // If true, retro_load_game() is guaranteed to provide a valid pathname in retro_game_info::path. - // ::data and ::size are both invalid. - // If false, ::data and ::size are guaranteed to be valid, but ::path might not be valid. - // This is typically set to true for libretro implementations that must load from file. - // Implementations should strive for setting this to false, as it allows the frontend to perform patching, etc. + /* If true, retro_load_game() is guaranteed to provide a valid pathname + * in retro_game_info::path. + * ::data and ::size are both invalid. + * + * If false, ::data and ::size are guaranteed to be valid, but ::path + * might not be valid. + * + * This is typically set to true for libretro implementations that must + * load from file. + * Implementations should strive for setting this to false, as it allows + * the frontend to perform patching, etc. */ + bool need_fullpath; - bool block_extract; // If true, the frontend is not allowed to extract any archives before loading the real ROM. - // Necessary for certain libretro implementations that load games from zipped archives. + /* If true, the frontend is not allowed to extract any archives before + * loading the real content. + * Necessary for certain libretro implementations that load games + * from zipped archives. */ + bool block_extract; }; struct retro_game_geometry { - unsigned base_width; // Nominal video width of game. - unsigned base_height; // Nominal video height of game. - unsigned max_width; // Maximum possible width of game. - unsigned max_height; // Maximum possible height of game. + unsigned base_width; /* Nominal video width of game. */ + unsigned base_height; /* Nominal video height of game. */ + unsigned max_width; /* Maximum possible width of game. */ + unsigned max_height; /* Maximum possible height of game. */ - float aspect_ratio; // Nominal aspect ratio of game. If aspect_ratio is <= 0.0, - // an aspect ratio of base_width / base_height is assumed. - // A frontend could override this setting if desired. + float aspect_ratio; /* Nominal aspect ratio of game. If + * aspect_ratio is <= 0.0, an aspect ratio + * of base_width / base_height is assumed. + * A frontend could override this setting, + * if desired. */ }; struct retro_system_timing { - double fps; // FPS of video content. - double sample_rate; // Sampling rate of audio. + double fps; /* FPS of video content. */ + double sample_rate; /* Sampling rate of audio. */ }; struct retro_system_av_info @@ -992,52 +1752,86 @@ struct retro_system_av_info struct retro_variable { - const char *key; // Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE. - // If NULL, obtains the complete environment string if more complex parsing is necessary. - // The environment string is formatted as key-value pairs delimited by semicolons as so: - // "key1=value1;key2=value2;..." - const char *value; // Value to be obtained. If key does not exist, it is set to NULL. + /* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE. + * If NULL, obtains the complete environment string if more + * complex parsing is necessary. + * The environment string is formatted as key-value pairs + * delimited by semicolons as so: + * "key1=value1;key2=value2;..." + */ + const char *key; + + /* Value to be obtained. If key does not exist, it is set to NULL. */ + const char *value; }; struct retro_game_info { - const char *path; // Path to game, UTF-8 encoded. Usually used as a reference. - // May be NULL if rom was loaded from stdin or similar. - // retro_system_info::need_fullpath guaranteed that this path is valid. - const void *data; // Memory buffer of loaded game. Will be NULL if need_fullpath was set. - size_t size; // Size of memory buffer. - const char *meta; // String of implementation specific meta-data. + const char *path; /* Path to game, UTF-8 encoded. + * Usually used as a reference. + * May be NULL if rom was loaded from stdin + * or similar. + * retro_system_info::need_fullpath guaranteed + * that this path is valid. */ + const void *data; /* Memory buffer of loaded game. Will be NULL + * if need_fullpath was set. */ + size_t size; /* Size of memory buffer. */ + const char *meta; /* String of implementation specific meta-data. */ }; -// Callbacks -// -// Environment callback. Gives implementations a way of performing uncommon tasks. Extensible. +/* Callbacks */ + +/* Environment callback. Gives implementations a way of performing + * uncommon tasks. Extensible. */ typedef bool (*retro_environment_t)(unsigned cmd, void *data); -// Render a frame. Pixel format is 15-bit 0RGB1555 native endian unless changed (see RETRO_ENVIRONMENT_SET_PIXEL_FORMAT). -// Width and height specify dimensions of buffer. -// Pitch specifices length in bytes between two lines in buffer. -// For performance reasons, it is highly recommended to have a frame that is packed in memory, i.e. pitch == width * byte_per_pixel. -// Certain graphic APIs, such as OpenGL ES, do not like textures that are not packed in memory. -typedef void (*retro_video_refresh_t)(const void *data, unsigned width, unsigned height, size_t pitch); +/* Render a frame. Pixel format is 15-bit 0RGB1555 native endian + * unless changed (see RETRO_ENVIRONMENT_SET_PIXEL_FORMAT). + * + * Width and height specify dimensions of buffer. + * Pitch specifices length in bytes between two lines in buffer. + * + * For performance reasons, it is highly recommended to have a frame + * that is packed in memory, i.e. pitch == width * byte_per_pixel. + * Certain graphic APIs, such as OpenGL ES, do not like textures + * that are not packed in memory. + */ +typedef void (*retro_video_refresh_t)(const void *data, unsigned width, + unsigned height, size_t pitch); -// Renders a single audio frame. Should only be used if implementation generates a single sample at a time. -// Format is signed 16-bit native endian. +/* Renders a single audio frame. Should only be used if implementation + * generates a single sample at a time. + * Format is signed 16-bit native endian. + */ typedef void (*retro_audio_sample_t)(int16_t left, int16_t right); -// Renders multiple audio frames in one go. One frame is defined as a sample of left and right channels, interleaved. -// I.e. int16_t buf[4] = { l, r, l, r }; would be 2 frames. -// Only one of the audio callbacks must ever be used. -typedef size_t (*retro_audio_sample_batch_t)(const int16_t *data, size_t frames); -// Polls input. +/* Renders multiple audio frames in one go. + * + * One frame is defined as a sample of left and right channels, interleaved. + * I.e. int16_t buf[4] = { l, r, l, r }; would be 2 frames. + * Only one of the audio callbacks must ever be used. + */ +typedef size_t (*retro_audio_sample_batch_t)(const int16_t *data, + size_t frames); + +/* Polls input. */ typedef void (*retro_input_poll_t)(void); -// Queries for input for player 'port'. device will be masked with RETRO_DEVICE_MASK. -// Specialization of devices such as RETRO_DEVICE_JOYPAD_MULTITAP that have been set with retro_set_controller_port_device() -// will still use the higher level RETRO_DEVICE_JOYPAD to request input. -typedef int16_t (*retro_input_state_t)(unsigned port, unsigned device, unsigned index, unsigned id); -// Sets callbacks. retro_set_environment() is guaranteed to be called before retro_init(). -// The rest of the set_* functions are guaranteed to have been called before the first call to retro_run() is made. +/* Queries for input for player 'port'. device will be masked with + * RETRO_DEVICE_MASK. + * + * Specialization of devices such as RETRO_DEVICE_JOYPAD_MULTITAP that + * have been set with retro_set_controller_port_device() + * will still use the higher level RETRO_DEVICE_JOYPAD to request input. + */ +typedef int16_t (*retro_input_state_t)(unsigned port, unsigned device, + unsigned index, unsigned id); + +/* Sets callbacks. retro_set_environment() is guaranteed to be called + * before retro_init(). + * + * 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); @@ -1045,65 +1839,83 @@ 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); -// Library global initialization/deinitialization. +/* Library global initialization/deinitialization. */ void retro_init(void); void retro_deinit(void); -// Must return RETRO_API_VERSION. Used to validate ABI compatibility when the API is revised. +/* Must return RETRO_API_VERSION. Used to validate ABI compatibility + * when the API is revised. */ 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(). +/* 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); -// Gets information about system audio/video timings and geometry. -// Can be called only after retro_load_game() has successfully completed. -// NOTE: The implementation of this function might not initialize every variable if needed. -// E.g. geom.aspect_ratio might not be initialized if core doesn't desire a particular aspect ratio. +/* Gets information about system audio/video timings and geometry. + * Can be called only after retro_load_game() has successfully completed. + * NOTE: The implementation of this function might not initialize every + * 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); -// Sets device to be used for player 'port'. +/* Sets device to be used for player 'port'. + * By default, RETRO_DEVICE_JOYPAD is assumed to be plugged into all + * available ports. + * Setting a particular device type is not a guarantee that libretro cores + * will only poll input based on that particular device type. It is only a + * 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); -// Resets the current game. +/* Resets the current game. */ void retro_reset(void); -// Runs the game for one video frame. -// During retro_run(), input_poll callback must be called at least once. -// -// If a frame is not rendered for reasons where a game "dropped" a frame, -// this still counts as a frame, and retro_run() should explicitly dupe a frame if GET_CAN_DUPE returns true. -// In this case, the video callback can take a NULL argument for data. +/* Runs the game for one video frame. + * During retro_run(), input_poll callback must be called at least once. + * + * If a frame is not rendered for reasons where a game "dropped" a frame, + * this still counts as a frame, and retro_run() should explicitly dupe + * 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); -// Returns the amount of data the implementation requires to serialize internal state (save states). -// Beetween calls to retro_load_game() and retro_unload_game(), the 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. +/* Returns the amount of data the implementation requires to serialize + * internal state (save states). + * Between calls to retro_load_game() and retro_unload_game(), the + * 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); -// Serializes internal state. If failed, or size is lower than retro_serialize_size(), it should return false, true otherwise. +/* 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); void retro_cheat_reset(void); void retro_cheat_set(unsigned index, bool enabled, const char *code); -// Loads a game. +/* Loads a game. */ bool retro_load_game(const struct retro_game_info *game); -// Loads a "special" kind of game. Should not be used except in extreme cases. +/* Loads a "special" kind of game. Should not be used, + * except in extreme cases. */ bool retro_load_game_special( unsigned game_type, const struct retro_game_info *info, size_t num_info ); -// Unloads a currently loaded game. +/* Unloads a currently loaded game. */ void retro_unload_game(void); -// Gets region of game. +/* Gets region of game. */ unsigned retro_get_region(void); -// Gets region of memory. +/* Gets region of memory. */ void *retro_get_memory_data(unsigned id); size_t retro_get_memory_size(unsigned id); From 54c1a1e8c284ede3e0da887ec4ce088f78f7fc30 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 23 Oct 2014 09:35:23 +0200 Subject: [PATCH 034/124] Update Makefile --- Makefile.libretro | 14 ++++++++++---- cpu/cyclone | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index 271d6045..8a4d57a5 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -50,8 +50,9 @@ endif ifeq ($(arch),ppc) CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -DFAMEC_NO_GOTOS endif -OSXVER = `sw_vers -productVersion | cut -c 4` -ifneq ($(OSXVER),9) + OSXVER = `sw_vers -productVersion | cut -d. -f 2` + OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"` +ifeq ($(OSX_LT_MAVERICKS),"YES") SHARED += -mmacosx-version-min=10.5 endif else ifeq ($(platform), ios) @@ -59,14 +60,19 @@ else ifeq ($(platform), ios) SHARED := -dynamiclib APPLE := 1 +ifeq ($(IOSSDK),) + IOSSDK := $(shell xcrun -sdk iphoneos -show-sdk-path) +endif + CC = clang -arch armv7 -isysroot $(IOSSDK) CXX = clang++ -arch armv7 -isysroot $(IOSSDK) CC_AS = perl ./tools/gas-preprocessor.pl $(CC) CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon CFLAGS += -DIOS -OSXVER = `sw_vers -productVersion | cut -c 4` -ifneq ($(OSXVER),9) + 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 diff --git a/cpu/cyclone b/cpu/cyclone index 590d780f..355815eb 160000 --- a/cpu/cyclone +++ b/cpu/cyclone @@ -1 +1 @@ -Subproject commit 590d780f20871b29fdc803bd2c74b046fd2d0f28 +Subproject commit 355815ebb5b1c60916f66d043a43f3af7839589f From a1f2e1b1537146ec7b72b1e9d5d5cd4d8dd6f06e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 4 Dec 2014 14:29:32 +0100 Subject: [PATCH 035/124] Add input descriptors --- platform/libpicofe | 2 +- platform/libretro/libretro.c | 110 +++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) diff --git a/platform/libpicofe b/platform/libpicofe index 8b4363e3..d1453cf7 160000 --- a/platform/libpicofe +++ b/platform/libpicofe @@ -1 +1 @@ -Subproject commit 8b4363e302e6bbcf41321ec70f8c033efed5840d +Subproject commit d1453cf7e6d5d6758cc5d72c6d3af7d37156bf72 diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 3179c091..057cd525 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -685,6 +685,116 @@ bool retro_load_game(const struct retro_game_info *info) static char carthw_path[256]; size_t i; + 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, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "C" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, + + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "C" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, + + { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, + { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, + { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, + { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, + { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" }, + { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "C" }, + { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" }, + { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, + { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, + { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, + { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, + { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, + + { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, + { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, + { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, + { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, + { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" }, + { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "C" }, + { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" }, + { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, + { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, + { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, + { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, + { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, + + { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, + { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, + { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, + { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, + { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" }, + { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "C" }, + { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" }, + { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, + { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, + { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, + { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, + { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, + + { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, + { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, + { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, + { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, + { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" }, + { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "C" }, + { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" }, + { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, + { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, + { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, + { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, + { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, + + { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, + { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, + { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, + { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, + { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" }, + { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "C" }, + { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" }, + { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, + { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, + { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, + { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, + { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, + + { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, + { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, + { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, + { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, + { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" }, + { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "C" }, + { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" }, + { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, + { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, + { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, + { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, + { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, + + { 0 }, + }; + + environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc); + enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) { if (log_cb) From 2babf3518e258cc3d6649f6e34a267e83dffd7d9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 19 Dec 2014 00:38:28 +0100 Subject: [PATCH 036/124] (Android) Buildfix --- jni/Android.mk | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/jni/Android.mk b/jni/Android.mk index 3a5a1fe7..a59144ac 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -2,11 +2,7 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -ifeq ($(NEON_BUILD)$(TARGET_ARCH_ABI),1armeabi-v7a) - LOCAL_MODULE := retro_picodrive-neon -else - LOCAL_MODULE := retro_picodrive -endif +LOCAL_MODULE := retro R := ../ FR := $(LOCAL_PATH)/$(R) From 8a601d66cb7d71bcd7c8f018da11aa7c42fe3fe8 Mon Sep 17 00:00:00 2001 From: vobe Date: Thu, 25 Dec 2014 12:11:32 +0100 Subject: [PATCH 037/124] Prevent segfault while scanning for MP3 files Make sure the destination string is NULL-terminated when building the uppercase extension. The tmp_ext_u array is uninitialized when it's passed to this function. --- pico/cd/cd_image.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pico/cd/cd_image.c b/pico/cd/cd_image.c index 07b55ceb..ae2ef0cd 100644 --- a/pico/cd/cd_image.c +++ b/pico/cd/cd_image.c @@ -61,6 +61,7 @@ static void to_upper(char *d, const char *s) else *d = *s; } + *d = 0; } // cdd.c uses lba - 150 From c771b2384e0a9b5687a4160421120bb661c1ee2e Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 30 Jan 2015 23:23:33 +0100 Subject: [PATCH 038/124] Buildfix --- pico/sound/ym2612.c | 4 ++-- platform/libpicofe | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pico/sound/ym2612.c b/pico/sound/ym2612.c index f7a073fb..0fc6fa27 100644 --- a/pico/sound/ym2612.c +++ b/pico/sound/ym2612.c @@ -1254,7 +1254,7 @@ STRICTINLINE void refresh_fc_eg_slot(FM_SLOT *SLOT, int fc, int kc) } /* update phase increment counters */ -INLINE void refresh_fc_eg_chan(FM_CH *CH) +void refresh_fc_eg_chan(FM_CH *CH) { if( CH->SLOT[SLOT1].Incr==-1){ int fc = CH->fc; @@ -1266,7 +1266,7 @@ INLINE void refresh_fc_eg_chan(FM_CH *CH) } } -INLINE void refresh_fc_eg_chan_sl3(void) +void refresh_fc_eg_chan_sl3(void) { if( ym2612.CH[2].SLOT[SLOT1].Incr==-1) { diff --git a/platform/libpicofe b/platform/libpicofe index d1453cf7..515ac0b9 160000 --- a/platform/libpicofe +++ b/platform/libpicofe @@ -1 +1 @@ -Subproject commit d1453cf7e6d5d6758cc5d72c6d3af7d37156bf72 +Subproject commit 515ac0b9d2c4d45a465335d54b8c49830914fcea From ceaf498c233ba9ff8461f40cd405c26d01843cfe Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 Mar 2015 19:27:20 +0100 Subject: [PATCH 039/124] Add linux-portable target --- Makefile.libretro | 6 ++++++ platform/libpicofe | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index 8a4d57a5..61deaad5 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -37,6 +37,12 @@ ifeq ($(platform), unix) TARGET := $(TARGET_NAME)_libretro.so SHARED := -shared DONT_COMPILE_IN_ZLIB = 1 + CFLAGS += -DFAMEC_NO_GOTOS +else ifeq ($(platform), linux-portable) + TARGET := $(TARGET_NAME)_libretro.so + SHARED := -shared -nostdlib -L. -lmusl + DONT_COMPILE_IN_ZLIB = 1 + CFLAGS += -DFAMEC_NO_GOTOS else ifeq ($(platform), osx) TARGET := $(TARGET_NAME)_libretro.dylib SHARED := -dynamiclib diff --git a/platform/libpicofe b/platform/libpicofe index 515ac0b9..9fec8a91 160000 --- a/platform/libpicofe +++ b/platform/libpicofe @@ -1 +1 @@ -Subproject commit 515ac0b9d2c4d45a465335d54b8c49830914fcea +Subproject commit 9fec8a91c9b19856ac0b51de53b847b38ed8dc61 From 90bb3895312d4a0d95990bafb724466a06c0826e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 Mar 2015 19:47:18 +0100 Subject: [PATCH 040/124] linux-portable target works now --- Makefile.libretro | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index 61deaad5..8fe30607 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -24,6 +24,7 @@ CC_AS ?= $(CC) CFLAGS ?= TARGET_NAME := picodrive +LIBM := -lm asm_memory = 0 asm_render = 0 @@ -41,6 +42,7 @@ ifeq ($(platform), unix) else ifeq ($(platform), linux-portable) TARGET := $(TARGET_NAME)_libretro.so SHARED := -shared -nostdlib -L. -lmusl + LIBM := DONT_COMPILE_IN_ZLIB = 1 CFLAGS += -DFAMEC_NO_GOTOS else ifeq ($(platform), osx) @@ -250,7 +252,7 @@ endif CFLAGS += -fPIC ifeq ($(findstring Haiku,$(shell uname -a)),) - LDLIBS += -lm + LDLIBS += $(LIBM) endif SHARED ?= -shared LDFLAGS += $(SHARED) From 4cdacae8ddd5aae15a7b670efffd5688ec97371f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 Mar 2015 23:42:04 +0100 Subject: [PATCH 041/124] (linux-portable) No musl --- Makefile.libretro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index 8fe30607..01a3c773 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -41,7 +41,7 @@ ifeq ($(platform), unix) CFLAGS += -DFAMEC_NO_GOTOS else ifeq ($(platform), linux-portable) TARGET := $(TARGET_NAME)_libretro.so - SHARED := -shared -nostdlib -L. -lmusl + SHARED := -shared -nostdlib LIBM := DONT_COMPILE_IN_ZLIB = 1 CFLAGS += -DFAMEC_NO_GOTOS From 6439e8214192d54b105cab48e5f26e88ce742ebd Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Tue, 10 Mar 2015 01:29:47 -0700 Subject: [PATCH 042/124] Don't use xcrun for setting IOSSDK --- Makefile.libretro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index 01a3c773..c5c271ab 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -69,7 +69,7 @@ else ifeq ($(platform), ios) APPLE := 1 ifeq ($(IOSSDK),) - IOSSDK := $(shell xcrun -sdk iphoneos -show-sdk-path) + IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) endif CC = clang -arch armv7 -isysroot $(IOSSDK) From b38bccea1210febbe0ee8df051481e0098ce7681 Mon Sep 17 00:00:00 2001 From: Oggom Date: Mon, 23 Mar 2015 17:46:02 +0100 Subject: [PATCH 043/124] (libretro) Implement region switch --- platform/libretro/libretro.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 057cd525..0cada6bd 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -314,6 +314,7 @@ void retro_set_environment(retro_environment_t cb) { "picodrive_input2", "Input device 2; 3 button pad|6 button pad|None" }, { "picodrive_sprlim", "No sprite limit; disabled|enabled" }, { "picodrive_ramcart", "MegaCD RAM cart; disabled|enabled" }, + { "picodrive_region", "Region; Auto|Japan NTSC|Japan PAL|US|Europe" }, #ifdef DRC_SH2 { "picodrive_drc", "Dynamic recompilers; enabled|disabled" }, #endif @@ -975,6 +976,21 @@ static void update_variables(void) PicoOpt &= ~POPT_EN_MCD_RAMCART; } + var.value = NULL; + var.key = "picodrive_region"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + if (strcmp(var.value, "Auto") == 0) + PicoRegionOverride = 0; + else if (strcmp(var.value, "Japan NTSC") == 0) + PicoRegionOverride = 1; + else if (strcmp(var.value, "Japan PAL") == 0) + PicoRegionOverride = 2; + else if (strcmp(var.value, "US") == 0) + PicoRegionOverride = 4; + else if (strcmp(var.value, "Europe") == 0) + PicoRegionOverride = 8; + } + #ifdef DRC_SH2 var.value = NULL; var.key = "picodrive_drc"; From 24a7ff72233aaf09dfdaa2f11c5c2bbcab236195 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 May 2015 18:54:08 +0200 Subject: [PATCH 044/124] Set aspect ratio --- platform/libpicofe | 2 +- platform/libretro/libretro.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/libpicofe b/platform/libpicofe index 9fec8a91..26ea1817 160000 --- a/platform/libpicofe +++ b/platform/libpicofe @@ -1 +1 @@ -Subproject commit 9fec8a91c9b19856ac0b51de53b847b38ed8dc61 +Subproject commit 26ea18173c1228dd5ce39e2a88ffe1ae10fcb365 diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 0cada6bd..10af6637 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -359,7 +359,7 @@ void retro_get_system_av_info(struct retro_system_av_info *info) info->geometry.base_height = vout_height; info->geometry.max_width = VOUT_MAX_WIDTH; info->geometry.max_height = VOUT_MAX_HEIGHT; - info->geometry.aspect_ratio = 0.0f; + info->geometry.aspect_ratio = 4.0f / 3.0f; } /* savestates */ From 68cf40ec367825dc5a2f7a94c3d65595ecde7a33 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 4 Jul 2015 19:19:32 +0200 Subject: [PATCH 045/124] Change includes so that things build without include dir shenanigans --- platform/common/mp3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/common/mp3.c b/platform/common/mp3.c index b2bcaf40..01ac7823 100644 --- a/platform/common/mp3.c +++ b/platform/common/mp3.c @@ -8,8 +8,8 @@ #include #include -#include -#include +#include "../../pico/pico_int.h" +#include "../../pico/sound/mix.h" #include "mp3.h" static FILE *mp3_current_file; From 1e65be056569d3fa77b1c3b9dc07a8f3aa63a3ba Mon Sep 17 00:00:00 2001 From: sergiobenrocha2 Date: Mon, 27 Jul 2015 00:31:18 -0300 Subject: [PATCH 046/124] Cleanup Makefile.libretro. --- Makefile.libretro | 349 +++++++++++++++++++++++++--------------------- 1 file changed, 189 insertions(+), 160 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index c5c271ab..cc8091fd 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -1,20 +1,20 @@ # Makefile for PicoDrive (libretro) ifeq ($(platform),) -platform = unix -ifeq ($(shell uname -a),) - platform = win -else ifneq ($(findstring MINGW,$(shell uname -a)),) - platform = win -else ifneq ($(findstring Darwin,$(shell uname -a)),) - platform = osx - arch = intel -ifeq ($(shell uname -p),powerpc) - arch = ppc -endif -else ifneq ($(findstring win,$(shell uname -a)),) - platform = win -endif + platform = unix + ifeq ($(shell uname -a),) + platform = win + else ifneq ($(findstring MINGW,$(shell uname -a)),) + platform = win + else ifneq ($(findstring Darwin,$(shell uname -a)),) + platform = osx + arch = intel + ifeq ($(shell uname -p),powerpc) + arch = ppc + endif + else ifneq ($(findstring win,$(shell uname -a)),) + platform = win + endif endif CC ?= gcc @@ -34,73 +34,76 @@ asm_cdpico = 0 asm_cdmemory = 0 asm_mix = 0 +# Unix ifeq ($(platform), unix) - TARGET := $(TARGET_NAME)_libretro.so - SHARED := -shared - DONT_COMPILE_IN_ZLIB = 1 + TARGET := $(TARGET_NAME)_libretro.so + SHARED := -shared + DONT_COMPILE_IN_ZLIB = 1 CFLAGS += -DFAMEC_NO_GOTOS + +# Portable Linux else ifeq ($(platform), linux-portable) - TARGET := $(TARGET_NAME)_libretro.so - SHARED := -shared -nostdlib + TARGET := $(TARGET_NAME)_libretro.so + SHARED := -shared -nostdlib LIBM := - DONT_COMPILE_IN_ZLIB = 1 + DONT_COMPILE_IN_ZLIB = 1 CFLAGS += -DFAMEC_NO_GOTOS + +# OS X else ifeq ($(platform), osx) - TARGET := $(TARGET_NAME)_libretro.dylib - SHARED := -dynamiclib - APPLE := 1 + TARGET := $(TARGET_NAME)_libretro.dylib + SHARED := -dynamiclib + APPLE := 1 + arch = intel + ifeq ($(shell uname -p),powerpc) + arch = ppc + endif + ifeq ($(arch),ppc) + 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"` + ifeq ($(OSX_LT_MAVERICKS),"YES") + SHARED += -mmacosx-version-min=10.5 + endif - arch = intel -ifeq ($(shell uname -p),powerpc) - arch = ppc -endif - -ifeq ($(arch),ppc) - 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"` -ifeq ($(OSX_LT_MAVERICKS),"YES") - SHARED += -mmacosx-version-min=10.5 -endif +# iOS else ifeq ($(platform), ios) - TARGET := $(TARGET_NAME)_libretro_ios.dylib - SHARED := -dynamiclib - APPLE := 1 + TARGET := $(TARGET_NAME)_libretro_ios.dylib + SHARED := -dynamiclib + APPLE := 1 + ifeq ($(IOSSDK),) + IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) + endif + CC = clang -arch armv7 -isysroot $(IOSSDK) + CXX = clang++ -arch armv7 -isysroot $(IOSSDK) + CC_AS = perl ./tools/gas-preprocessor.pl $(CC) + CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm + ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon + 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 + ARCH := arm -ifeq ($(IOSSDK),) - IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) -endif - - CC = clang -arch armv7 -isysroot $(IOSSDK) - CXX = clang++ -arch armv7 -isysroot $(IOSSDK) - CC_AS = perl ./tools/gas-preprocessor.pl $(CC) - CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm - ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon - 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 - - ARCH := arm - - use_cyclone = 0 - use_fame = 1 - use_drz80 = 0 - use_cz80 = 1 - use_sh2drc = 1 - use_svpdrc = 1 + use_cyclone = 0 + use_fame = 1 + use_drz80 = 0 + use_cz80 = 1 + use_sh2drc = 1 + use_svpdrc = 1 +# PS3 else ifeq ($(platform), ps3) - TARGET := $(TARGET_NAME)_libretro_ps3.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 + TARGET := $(TARGET_NAME)_libretro_ps3.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 NO_MMAP = 1 DONT_COMPILE_IN_ZLIB = 1 @@ -112,15 +115,17 @@ else ifeq ($(platform), ps3) asm_cdpico = 0 asm_cdmemory = 0 asm_mix = 0 - use_cyclone = 0 - use_fame = 1 - use_drz80 = 0 - use_cz80 = 1 + use_cyclone = 0 + use_fame = 1 + use_drz80 = 0 + use_cz80 = 1 + +# sncps3 else ifeq ($(platform), sncps3) - 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 + 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 NO_MMAP = 1 DONT_COMPILE_IN_ZLIB = 1 @@ -132,15 +137,17 @@ else ifeq ($(platform), sncps3) asm_cdpico = 0 asm_cdmemory = 0 asm_mix = 0 - use_cyclone = 0 - use_fame = 1 - use_drz80 = 0 - use_cz80 = 1 + use_cyclone = 0 + use_fame = 1 + use_drz80 = 0 + use_cz80 = 1 + +# Lightweight PS3 Homebrew SDK else ifeq ($(platform), psl1ght) - TARGET := $(TARGET_NAME)_libretro_psl1ght.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 + TARGET := $(TARGET_NAME)_libretro_psl1ght.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 STATIC_LINKING = 1 NO_MMAP = 1 DONT_COMPILE_IN_ZLIB = 1 @@ -152,15 +159,17 @@ else ifeq ($(platform), psl1ght) asm_cdpico = 0 asm_cdmemory = 0 asm_mix = 0 - use_cyclone = 0 - use_fame = 1 - use_drz80 = 0 - use_cz80 = 1 + use_cyclone = 0 + use_fame = 1 + use_drz80 = 0 + use_cz80 = 1 + +# PSP else ifeq ($(platform), psp1) - TARGET := $(TARGET_NAME)_libretro_psp1.a - CC = psp-gcc$(EXE_EXT) - AR = psp-ar$(EXE_EXT) - CFLAGS += -G0 + TARGET := $(TARGET_NAME)_libretro_psp1.a + CC = psp-gcc$(EXE_EXT) + AR = psp-ar$(EXE_EXT) + CFLAGS += -G0 STATIC_LINKING = 1 NO_MMAP = 1 DONT_COMPILE_IN_ZLIB = 1 @@ -172,88 +181,108 @@ else ifeq ($(platform), psp1) asm_cdpico = 0 asm_cdmemory = 0 asm_mix = 0 - use_cyclone = 0 - use_fame = 1 - use_drz80 = 0 - use_cz80 = 1 -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__ -else ifeq ($(platform), ngc) - TARGET := $(TARGET_NAME)_libretro_ngc.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 -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -else ifeq ($(platform), wii) - TARGET := libretro_$(TARGET_NAME)_wii.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 -DBLARGG_BIG_ENDIAN=1 -D__ppc__ -else ifeq ($(platform), qnx) - TARGET := $(TARGET_NAME)_libretro_qnx.so - CC = qcc -Vgcc_ntoarmv7le - CC_AS = $(CC) - CFLAGS += -DBASE_ADDR_FIXED=0 -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp - ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp + use_cyclone = 0 + use_fame = 1 + use_drz80 = 0 + use_cz80 = 1 - ARCH = arm - ARM_ASM = 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__ + +# Nintendo Game Cube +else ifeq ($(platform), ngc) + TARGET := $(TARGET_NAME)_libretro_ngc.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 -DBLARGG_BIG_ENDIAN=1 -D__ppc__ + +# Nintendo Wii +else ifeq ($(platform), wii) + TARGET := libretro_$(TARGET_NAME)_wii.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 -DBLARGG_BIG_ENDIAN=1 -D__ppc__ + +# QNX +else ifeq ($(platform), qnx) + TARGET := $(TARGET_NAME)_libretro_qnx.so + CC = qcc -Vgcc_ntoarmv7le + CC_AS = $(CC) + CFLAGS += -DBASE_ADDR_FIXED=0 -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp + ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp + ARCH = arm + ARM_ASM = 1 + +# ARM else ifneq (,$(findstring armv,$(platform))) - TARGET := $(TARGET_NAME)_libretro.so - SHARED := -shared -Wl,--no-undefined -ifneq (,$(findstring cortexa8,$(platform))) - CFLAGS += -marm -mcpu=cortex-a8 - ASFLAGS += -mcpu=cortex-a8 -else ifneq (,$(findstring cortexa9,$(platform))) - CFLAGS += -marm -mcpu=cortex-a9 - ASFLAGS += -mcpu=cortex-a9 -endif - CFLAGS += -marm -ifneq (,$(findstring neon,$(platform))) - CFLAGS += -mfpu=neon - ASFLAGS += -mfpu=neon -endif -ifneq (,$(findstring softfloat,$(platform))) - CFLAGS += -mfloat-abi=softfp - ASFLAGS += -mfloat-abi=softfp -else ifneq (,$(findstring hardfloat,$(platform))) - CFLAGS += -mfloat-abi=hard - ASFLAGS += -mfloat-abi=hard -endif -ifneq (,$(findstring armasm,$(platform))) - ARM_ASM = 1 -endif - ARCH = arm + TARGET := $(TARGET_NAME)_libretro.so + SHARED := -shared -Wl,--no-undefined + ifneq (,$(findstring cortexa5,$(platform))) + CFLAGS += -marm -mcpu=cortex-a5 + ASFLAGS += -mcpu=cortex-a5 + else ifneq (,$(findstring cortexa8,$(platform))) + CFLAGS += -marm -mcpu=cortex-a8 + ASFLAGS += -mcpu=cortex-a8 + else ifneq (,$(findstring cortexa9,$(platform))) + CFLAGS += -marm -mcpu=cortex-a9 + ASFLAGS += -mcpu=cortex-a9 + else ifneq (,$(findstring cortexa15a7,$(platform))) + CFLAGS += -marm -mcpu=cortex-a15.cortex-a7 + ASFLAGS += -mcpu=cortex-a15.cortex-a7 + else + CFLAGS += -marm + endif + ifneq (,$(findstring neon,$(platform))) + CFLAGS += -mfpu=neon + ASFLAGS += -mfpu=neon + endif + ifneq (,$(findstring softfloat,$(platform))) + CFLAGS += -mfloat-abi=softfp + ASFLAGS += -mfloat-abi=softfp + else ifneq (,$(findstring hardfloat,$(platform))) + CFLAGS += -mfloat-abi=hard + ASFLAGS += -mfloat-abi=hard + endif + ifneq (,$(findstring armasm,$(platform))) + ARM_ASM = 1 + endif + ARCH = arm + +# Windows else - TARGET := $(TARGET_NAME)_libretro.dll - CC = gcc - LD_FLAGS := -fPIC - SHARED := -shared -static-libgcc -static-libstdc++ - CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__ + TARGET := $(TARGET_NAME)_libretro.dll + CC = gcc + LD_FLAGS := -fPIC + SHARED := -shared -static-libgcc -static-libstdc++ + CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__ + endif CFLAGS += -DNO_ZLIB ifeq ($(NO_MMAP),1) -CFLAGS += -DNO_MMAP + CFLAGS += -DNO_MMAP endif ifeq ($(ARM_ASM),1) -asm_memory = 1 -asm_render = 1 -asm_ym2612 = 1 -asm_misc = 1 -asm_cdpico = 1 -asm_cdmemory = 1 -asm_mix = 1 + asm_memory = 1 + asm_render = 1 + asm_ym2612 = 1 + asm_misc = 1 + asm_cdpico = 1 + asm_cdmemory = 1 + asm_mix = 1 endif CFLAGS += -fPIC ifeq ($(findstring Haiku,$(shell uname -a)),) - LDLIBS += $(LIBM) + LDLIBS += $(LIBM) endif + SHARED ?= -shared LDFLAGS += $(SHARED) From fb9f9d637c80ae7bb38b535154c8fd8c5843b8a9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 2 Aug 2015 00:09:35 +0200 Subject: [PATCH 047/124] (OSX) Lower requirements to OSX 10.1 --- Makefile.libretro | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index cc8091fd..960c8a6e 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -63,9 +63,7 @@ else ifeq ($(platform), osx) endif OSXVER = `sw_vers -productVersion | cut -d. -f 2` OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"` - ifeq ($(OSX_LT_MAVERICKS),"YES") - SHARED += -mmacosx-version-min=10.5 - endif + SHARED += -mmacosx-version-min=10.1 # iOS else ifeq ($(platform), ios) From 164e4185493c5175a30b37ffe35ea555b2f8ebd0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 31 Aug 2015 23:09:21 +0200 Subject: [PATCH 048/124] (Vita) Add target - not finished --- Makefile.libretro | 24 ++++++++++++++++++++++++ platform/libpicofe | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index 960c8a6e..6e3248ec 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -184,6 +184,30 @@ else ifeq ($(platform), psp1) use_drz80 = 0 use_cz80 = 1 +# 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 + STATIC_LINKING = 1 + NO_MMAP = 1 + DONT_COMPILE_IN_ZLIB = 1 + ARCH = arm + ARM_ASM = 1 + + asm_memory = 1 + asm_render = 1 + asm_ym2612 = 1 + asm_misc = 0 + asm_cdpico = 0 + asm_cdmemory = 0 + asm_mix = 0 + use_cyclone = 0 + use_fame = 1 + use_drz80 = 1 + use_cz80 = 0 + # Xbox 360 else ifeq ($(platform), xenon) TARGET := $(TARGET_NAME)_libretro_xenon360.a diff --git a/platform/libpicofe b/platform/libpicofe index 26ea1817..0415ebf1 160000 --- a/platform/libpicofe +++ b/platform/libpicofe @@ -1 +1 @@ -Subproject commit 26ea18173c1228dd5ce39e2a88ffe1ae10fcb365 +Subproject commit 0415ebf191d0d277d1dfba1bebe6f051a5fc89a8 From 393c344e2ec74cbd5ebd7680d06b54332021088a Mon Sep 17 00:00:00 2001 From: Radius Date: Thu, 10 Sep 2015 23:50:07 +0100 Subject: [PATCH 049/124] add 3ds target --- Makefile.libretro | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Makefile.libretro b/Makefile.libretro index 6e3248ec..aafbfd9a 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -184,6 +184,37 @@ else ifeq ($(platform), psp1) use_drz80 = 0 use_cz80 = 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 + CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard + CFLAGS += -Wall -mword-relocations + CFLAGS += -fomit-frame-pointer -ffast-math + CFLAGS += -D_3DS + PLATFORM_DEFINES := -D_3DS + STATIC_LINKING = 1 + NO_MMAP = 1 + DONT_COMPILE_IN_ZLIB = 1 + + asm_memory = 0 + asm_render = 0 + asm_ym2612 = 0 + asm_misc = 0 + asm_cdpico = 0 + asm_cdmemory = 0 + asm_mix = 0 + use_cyclone = 0 + use_fame = 1 + use_drz80 = 0 + use_cz80 = 1 + + # Vita else ifeq ($(platform), vita) TARGET := $(TARGET_NAME)_libretro_vita.a From b44f946ce8f356f23d69b60a74c108d1d72d9dad Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 19 Sep 2015 05:31:59 +0200 Subject: [PATCH 050/124] (QNX) Fix build --- Makefile.libretro | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile.libretro b/Makefile.libretro index aafbfd9a..dc9bd66a 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -270,6 +270,13 @@ else ifeq ($(platform), qnx) ARCH = arm ARM_ASM = 1 + use_cyclone = 0 + use_fame = 1 + use_drz80 = 0 + use_cz80 = 1 + use_sh2drc = 1 + use_svpdrc = 1 + # ARM else ifneq (,$(findstring armv,$(platform))) TARGET := $(TARGET_NAME)_libretro.so From 0c73267625a4acebfbea8b4ef048c51ee96155d3 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Wed, 30 Sep 2015 23:43:20 +0100 Subject: [PATCH 051/124] (ctr/3ds) optimize build, add support for 32x/svp dynamic recompilers. --- Makefile.libretro | 32 ++--- platform/libretro/3ds/3ds_utils.c | 78 ++++++++++++ platform/libretro/3ds/3ds_utils.h | 18 +++ platform/libretro/libretro.c | 198 ++++++++++++++++++++++++++++-- 4 files changed, 301 insertions(+), 25 deletions(-) create mode 100644 platform/libretro/3ds/3ds_utils.c create mode 100644 platform/libretro/3ds/3ds_utils.h diff --git a/Makefile.libretro b/Makefile.libretro index dc9bd66a..e6766fd9 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -193,27 +193,31 @@ else ifeq ($(platform), ctr) CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT) AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT) CFLAGS += -DARM11 -D_3DS - CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard + CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp CFLAGS += -Wall -mword-relocations CFLAGS += -fomit-frame-pointer -ffast-math - CFLAGS += -D_3DS - PLATFORM_DEFINES := -D_3DS STATIC_LINKING = 1 NO_MMAP = 1 DONT_COMPILE_IN_ZLIB = 1 + ARCH = arm + ARM_ASM = 1 - asm_memory = 0 - asm_render = 0 - asm_ym2612 = 0 - asm_misc = 0 - asm_cdpico = 0 - asm_cdmemory = 0 - asm_mix = 0 - use_cyclone = 0 - use_fame = 1 - use_drz80 = 0 - use_cz80 = 1 + asm_memory = 1 + asm_render = 1 + asm_ym2612 = 1 + asm_misc = 1 + asm_cdpico = 1 + asm_cdmemory = 1 + asm_mix = 1 + use_cyclone = 1 + use_fame = 0 + use_drz80 = 1 + use_cz80 = 0 + use_sh2drc = 1 + use_svpdrc = 1 + + OBJS +=platform/libretro/3ds/3ds_utils.o # Vita else ifeq ($(platform), vita) diff --git a/platform/libretro/3ds/3ds_utils.c b/platform/libretro/3ds/3ds_utils.c new file mode 100644 index 00000000..e0f76ca2 --- /dev/null +++ b/platform/libretro/3ds/3ds_utils.c @@ -0,0 +1,78 @@ + +#include "3ds_utils.h" + +typedef int (*ctr_callback_type)(void); + +int srvGetServiceHandle(unsigned int* out, const char* name); +int svcCloseHandle(unsigned int handle); +int svcBackdoor(ctr_callback_type); + + +static void ctr_enable_all_svc_kernel(void) +{ + __asm__ volatile("cpsid aif"); + + unsigned int* svc_access_control = *(*(unsigned int***)0xFFFF9000 + 0x22) - 0x6; + + svc_access_control[0]=0xFFFFFFFE; + svc_access_control[1]=0xFFFFFFFF; + svc_access_control[2]=0xFFFFFFFF; + svc_access_control[3]=0x3FFFFFFF; +} + + +static 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 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 void ctr_enable_all_svc(void) +{ + svcBackdoor((ctr_callback_type)ctr_enable_all_svc_kernel); +} + +void ctr_invalidate_ICache(void) +{ +// __asm__ volatile("svc 0x2E\n\t"); + svcBackdoor((ctr_callback_type)ctr_invalidate_ICache_kernel); + +} + +void ctr_flush_DCache(void) +{ +// __asm__ volatile("svc 0x4B\n\t"); + svcBackdoor((ctr_callback_type)ctr_flush_DCache_kernel); +} + + +void ctr_flush_invalidate_cache(void) +{ + ctr_flush_DCache(); + ctr_invalidate_ICache(); +} + +int ctr_svchack_init(void) +{ + extern unsigned int __service_ptr; + + if(__service_ptr) + return 0; + + /* CFW */ + ctr_enable_all_svc(); + return 1; +} + diff --git a/platform/libretro/3ds/3ds_utils.h b/platform/libretro/3ds/3ds_utils.h new file mode 100644 index 00000000..5aa452f6 --- /dev/null +++ b/platform/libretro/3ds/3ds_utils.h @@ -0,0 +1,18 @@ +#ifndef _3DS_UTILS_H +#define _3DS_UTILS_H + +void ctr_invalidate_ICache(void); +void ctr_flush_DCache(void); + +void ctr_flush_invalidate_cache(void); + +int ctr_svchack_init(void); + + + +#include +#define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0) + +void wait_for_input(void); + +#endif // _3DS_UTILS_H diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 10af6637..8bd6363f 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -24,6 +24,19 @@ #include #endif +#ifdef _3DS +#include "3ds/3ds_utils.h" +#define MEMOP_PROT 6 +int svcDuplicateHandle(unsigned int* out, unsigned int original); +int svcCloseHandle(unsigned int handle); +int svcControlProcessMemory(unsigned int process, void* addr0, void* addr1, + unsigned int size, unsigned int type, unsigned int perm); +#define MEMOP_MAP 4 +#define MEMOP_UNMAP 5 + +static int ctr_svchack_successful = 0; +#endif + #include #include #include "../common/input_pico.h" @@ -67,8 +80,10 @@ void cache_flush_d_inval_i(void *start, void *end) size_t len = (char *)end - (char *)start; sys_dcache_flush(start, len); sys_icache_invalidate(start, len); +#elif defined(_3DS) + ctr_flush_invalidate_cache(); #else - __clear_cache(start, end); + __clear_cache(start, end); #endif #endif } @@ -190,7 +205,7 @@ void munmap(void *base_addr, size_t len) int mprotect(void *addr, size_t len, int prot) { - /* stub - not really needed at this point since this codepath has no dynarecs */ + /* stub - not really needed at this point since this codepath has no dynarecs */ return 0; } @@ -200,6 +215,134 @@ int mprotect(void *addr, size_t len, int prot) #define MAP_ANONYMOUS MAP_ANON #endif +#ifdef _3DS +typedef struct +{ + unsigned int requested_map; + void* buffer; +}pico_mmap_t; + +pico_mmap_t pico_mmaps[] = { + {0x02000000, 0}, + {0x06000000, 0}, + {NULL, 0} +}; + +void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed) +{ + (void)is_fixed; + + if (ctr_svchack_successful) + { + pico_mmap_t* pico_mmap; + + for (pico_mmap = pico_mmaps; pico_mmap->requested_map; pico_mmap++) + { + if ((pico_mmap->requested_map == addr)) + { + unsigned int ptr_aligned, tmp; + unsigned int currentHandle; + unsigned int perm = 0b011; + + if (need_exec) + perm = 0b111; + + size = (size + 0xFFF) & ~0xFFF; + pico_mmap->buffer = malloc(size + 0x1000); + ptr_aligned = (((unsigned int)pico_mmap->buffer) + 0xFFF) & ~0xFFF; + + svcDuplicateHandle(¤tHandle, 0xFFFF8001); + + if(svcControlProcessMemory(currentHandle, pico_mmap->requested_map, ptr_aligned, size, MEMOP_MAP, perm) < 0) + { + if (log_cb) + log_cb(RETRO_LOG_ERROR, "could not map memory @0x%08X\n", pico_mmap->requested_map); + exit(1); + } + + svcCloseHandle(currentHandle); + return (void*)pico_mmap->requested_map; + } + } + } + + return malloc(size); +} + +void *plat_mremap(void *ptr, size_t oldsize, size_t newsize) +{ + if (ctr_svchack_successful) + { + pico_mmap_t* pico_mmap; + + for (pico_mmap = pico_mmaps; pico_mmap->requested_map; pico_mmap++) + { + if ((pico_mmap->requested_map == (unsigned int)ptr)) + { + unsigned int ptr_aligned; + unsigned int currentHandle; + void* tmp; + + oldsize = (oldsize + 0xFFF) & ~0xFFF; + newsize = (newsize + 0xFFF) & ~0xFFF; + ptr_aligned = (((unsigned int)pico_mmap->buffer) + 0xFFF) & ~0xFFF; + + svcDuplicateHandle(¤tHandle, 0xFFFF8001); + + svcControlProcessMemory(currentHandle, pico_mmap->requested_map, ptr_aligned, oldsize, MEMOP_UNMAP, 0b011); + + tmp = realloc(pico_mmap->buffer, newsize + 0x1000); + if(!tmp) + return NULL; + + pico_mmap->buffer = tmp; + ptr_aligned = (((unsigned int)pico_mmap->buffer) + 0xFFF) & ~0xFFF; + + svcControlProcessMemory(currentHandle, pico_mmap->requested_map, ptr_aligned, newsize, MEMOP_MAP, 0x3); + + svcCloseHandle(currentHandle); + + return ptr; + } + } + } + + return realloc(ptr, newsize); + +} +void plat_munmap(void *ptr, size_t size) +{ + if (ctr_svchack_successful) + { + pico_mmap_t* pico_mmap; + + for (pico_mmap = pico_mmaps; pico_mmap->requested_map; pico_mmap++) + { + if ((pico_mmap->requested_map == (unsigned int)ptr)) + { + unsigned int ptr_aligned; + unsigned int currentHandle; + + size = (size + 0xFFF) & ~0xFFF; + ptr_aligned = (((unsigned int)pico_mmap->buffer) + 0xFFF) & ~0xFFF; + + svcDuplicateHandle(¤tHandle, 0xFFFF8001); + + svcControlProcessMemory(currentHandle, (void*)pico_mmap->requested_map, (void*)ptr_aligned, size, MEMOP_UNMAP, 0b011); + + svcCloseHandle(currentHandle); + + free(pico_mmap->buffer); + pico_mmap->buffer = NULL; + return; + } + } + } + + free(ptr); +} + +#else void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed) { int flags = MAP_PRIVATE | MAP_ANONYMOUS; @@ -265,6 +408,7 @@ void plat_munmap(void *ptr, size_t size) if (ptr != NULL) munmap(ptr, size); } +#endif int plat_mem_set_exec(void *ptr, size_t size) { @@ -272,6 +416,26 @@ int plat_mem_set_exec(void *ptr, size_t size) int ret = VirtualProtect(ptr,size,PAGE_EXECUTE_READWRITE,0); if (ret == 0 && log_cb) log_cb(RETRO_LOG_ERROR, "mprotect(%p, %zd) failed: %d\n", ptr, size, 0); +#elif defined(_3DS) + int ret = -1; + if (ctr_svchack_successful) + { + unsigned int currentHandle; + svcDuplicateHandle(¤tHandle, 0xFFFF8001); + ret = svcControlProcessMemory(currentHandle, ptr, 0x0, + size, MEMOP_PROT, 0b111); + svcCloseHandle(currentHandle); + ctr_flush_invalidate_cache(); + + } + else + { + if (log_cb) + log_cb(RETRO_LOG_ERROR, "plat_mem_set_exec called with no svcControlProcessMemory access\n"); + exit(1); + } + + #else int ret = mprotect(ptr, size, PROT_READ | PROT_WRITE | PROT_EXEC); if (ret != 0 && log_cb) @@ -302,7 +466,8 @@ void lprintf(const char *fmt, ...) vsprintf(buffer, fmt, ap); /* TODO - add 'level' param for warning/error messages? */ if (log_cb) - log_cb(RETRO_LOG_INFO, "%s\n", fmt); + log_cb(RETRO_LOG_INFO, "%s\n", fmt, ap); + va_end(ap); } /* libretro */ @@ -1001,6 +1166,10 @@ static void update_variables(void) PicoOpt &= ~POPT_EN_DRC; } #endif +#ifdef _3DS + if(!ctr_svchack_successful) + PicoOpt &= ~POPT_EN_DRC; +#endif } void retro_run(void) @@ -1011,7 +1180,7 @@ void retro_run(void) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) update_variables(); - input_poll_cb(); + input_poll_cb(); PicoPad[0] = PicoPad[1] = 0; for (pad = 0; pad < 2; pad++) @@ -1047,29 +1216,36 @@ void retro_init(void) environ_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE, &disk_control); +#ifdef _3DS + ctr_svchack_successful = ctr_svchack_init(); +#endif + PicoOpt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 | POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_MCD_GFX | POPT_EN_32X|POPT_EN_PWM | POPT_ACC_SPRITES|POPT_DIS_32C_BORDER; #ifdef __arm__ - PicoOpt |= POPT_EN_DRC; +#ifdef _3DS + if (ctr_svchack_successful) +#endif + PicoOpt |= POPT_EN_DRC; #endif PsndRate = 44100; PicoAutoRgnOrder = 0x184; // US, EU, JP vout_width = 320; - vout_height = 240; - vout_buf = malloc(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2); + vout_height = 240; + vout_buf = malloc(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2); - PicoInit(); - PicoDrawSetOutFormat(PDF_RGB555, 0); - PicoDrawSetOutBuf(vout_buf, vout_width * 2); + PicoInit(); + PicoDrawSetOutFormat(PDF_RGB555, 0); + PicoDrawSetOutBuf(vout_buf, vout_width * 2); //PicoMessage = plat_status_msg_busy_next; PicoMCDopenTray = disk_tray_open; PicoMCDcloseTray = disk_tray_close; - update_variables(); + update_variables(); } void retro_deinit(void) From eac0e638190211e579f169357dfaff28c0aa801a Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 1 Oct 2015 00:30:14 +0100 Subject: [PATCH 052/124] clean indentation --- platform/libretro/libretro.c | 866 +++++++++++++++++------------------ 1 file changed, 433 insertions(+), 433 deletions(-) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 8bd6363f..62b168e3 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -75,11 +75,11 @@ void cache_flush_d_inval_i(void *start, void *end) { #ifdef __arm__ #if defined(__BLACKBERRY_QNX__) - msync(start, end - start, MS_SYNC | MS_CACHE_ONLY | MS_INVALIDATE_ICACHE); + msync(start, end - start, MS_SYNC | MS_CACHE_ONLY | MS_INVALIDATE_ICACHE); #elif defined(__MACH__) - size_t len = (char *)end - (char *)start; - sys_dcache_flush(start, len); - sys_icache_invalidate(start, len); + size_t len = (char *)end - (char *)start; + sys_dcache_flush(start, len); + sys_icache_invalidate(start, len); #elif defined(_3DS) ctr_flush_invalidate_cache(); #else @@ -128,62 +128,62 @@ void cache_flush_d_inval_i(void *start, void *end) 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; + 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_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; + 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; + 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 (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; + 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() ... */ + UnmapViewOfFile(addr); + /* ruh-ro, we leaked handle from CreateFileMapping() ... */ } #elif defined(NO_MMAP) #define PROT_EXEC 0x04 @@ -205,7 +205,7 @@ void munmap(void *base_addr, size_t len) int mprotect(void *addr, size_t len, int prot) { - /* stub - not really needed at this point since this codepath has no dynarecs */ + /* stub - not really needed at this point since this codepath has no dynarecs */ return 0; } @@ -367,46 +367,46 @@ void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed) } } - return ret; + return ret; } void *plat_mremap(void *ptr, size_t oldsize, size_t newsize) { #ifdef __linux__ - void *ret = mremap(ptr, oldsize, newsize, 0); - if (ret == MAP_FAILED) - return NULL; + void *ret = mremap(ptr, oldsize, newsize, 0); + if (ret == MAP_FAILED) + return NULL; - return ret; + return ret; #else - void *tmp, *ret; - size_t preserve_size; - - preserve_size = oldsize; - if (preserve_size > newsize) - preserve_size = newsize; - tmp = malloc(preserve_size); - if (tmp == NULL) - return NULL; - memcpy(tmp, ptr, preserve_size); + void *tmp, *ret; + size_t preserve_size; - munmap(ptr, oldsize); - ret = mmap(ptr, newsize, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (ret == MAP_FAILED) { - free(tmp); - return NULL; - } - memcpy(ret, tmp, preserve_size); - free(tmp); - return ret; + preserve_size = oldsize; + if (preserve_size > newsize) + preserve_size = newsize; + tmp = malloc(preserve_size); + if (tmp == NULL) + return NULL; + memcpy(tmp, ptr, preserve_size); + + munmap(ptr, oldsize); + ret = mmap(ptr, newsize, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (ret == MAP_FAILED) { + free(tmp); + return NULL; + } + memcpy(ret, tmp, preserve_size); + free(tmp); + return ret; #endif } void plat_munmap(void *ptr, size_t size) { - if (ptr != NULL) - munmap(ptr, size); + if (ptr != NULL) + munmap(ptr, size); } #endif @@ -441,17 +441,17 @@ int plat_mem_set_exec(void *ptr, size_t size) if (ret != 0 && log_cb) log_cb(RETRO_LOG_ERROR, "mprotect(%p, %zd) failed: %d\n", ptr, size, errno); #endif - return ret; + return ret; } void emu_video_mode_change(int start_line, int line_count, int is_32cols) { - memset(vout_buf, 0, 320 * 240 * 2); - vout_width = is_32cols ? 256 : 320; - PicoDrawSetOutBuf(vout_buf, vout_width * 2); + memset(vout_buf, 0, 320 * 240 * 2); + vout_width = is_32cols ? 256 : 320; + PicoDrawSetOutBuf(vout_buf, vout_width * 2); - vout_height = line_count; - vout_offset = vout_width * start_line; + vout_height = line_count; + vout_offset = vout_width * start_line; } void emu_32x_startup(void) @@ -473,22 +473,22 @@ void lprintf(const char *fmt, ...) /* libretro */ void retro_set_environment(retro_environment_t cb) { - static const struct retro_variable vars[] = { - //{ "region", "Region; Auto|NTSC|PAL" }, - { "picodrive_input1", "Input device 1; 3 button pad|6 button pad|None" }, - { "picodrive_input2", "Input device 2; 3 button pad|6 button pad|None" }, - { "picodrive_sprlim", "No sprite limit; disabled|enabled" }, - { "picodrive_ramcart", "MegaCD RAM cart; disabled|enabled" }, - { "picodrive_region", "Region; Auto|Japan NTSC|Japan PAL|US|Europe" }, + static const struct retro_variable vars[] = { + //{ "region", "Region; Auto|NTSC|PAL" }, + { "picodrive_input1", "Input device 1; 3 button pad|6 button pad|None" }, + { "picodrive_input2", "Input device 2; 3 button pad|6 button pad|None" }, + { "picodrive_sprlim", "No sprite limit; disabled|enabled" }, + { "picodrive_ramcart", "MegaCD RAM cart; disabled|enabled" }, + { "picodrive_region", "Region; Auto|Japan NTSC|Japan PAL|US|Europe" }, #ifdef DRC_SH2 - { "picodrive_drc", "Dynamic recompilers; enabled|disabled" }, + { "picodrive_drc", "Dynamic recompilers; enabled|disabled" }, #endif - { NULL, NULL }, - }; + { NULL, NULL }, + }; - environ_cb = cb; + environ_cb = cb; - cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void *)vars); + cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void *)vars); } void retro_set_video_refresh(retro_video_refresh_t cb) { video_cb = cb; } @@ -499,7 +499,7 @@ void retro_set_input_state(retro_input_state_t cb) { input_state_cb = cb; } unsigned retro_api_version(void) { - return RETRO_API_VERSION; + return RETRO_API_VERSION; } void retro_set_controller_port_device(unsigned port, unsigned device) @@ -508,145 +508,145 @@ void retro_set_controller_port_device(unsigned port, unsigned device) void retro_get_system_info(struct retro_system_info *info) { - memset(info, 0, sizeof(*info)); - info->library_name = "PicoDrive"; - info->library_version = VERSION; - info->valid_extensions = "bin|gen|smd|md|32x|cue|iso|sms"; - info->need_fullpath = true; + memset(info, 0, sizeof(*info)); + info->library_name = "PicoDrive"; + info->library_version = VERSION; + info->valid_extensions = "bin|gen|smd|md|32x|cue|iso|sms"; + info->need_fullpath = true; } void retro_get_system_av_info(struct retro_system_av_info *info) { - memset(info, 0, sizeof(*info)); - info->timing.fps = Pico.m.pal ? 50 : 60; - info->timing.sample_rate = 44100; - info->geometry.base_width = 320; - info->geometry.base_height = vout_height; - info->geometry.max_width = VOUT_MAX_WIDTH; - info->geometry.max_height = VOUT_MAX_HEIGHT; - info->geometry.aspect_ratio = 4.0f / 3.0f; + memset(info, 0, sizeof(*info)); + info->timing.fps = Pico.m.pal ? 50 : 60; + info->timing.sample_rate = 44100; + info->geometry.base_width = 320; + info->geometry.base_height = vout_height; + info->geometry.max_width = VOUT_MAX_WIDTH; + info->geometry.max_height = VOUT_MAX_HEIGHT; + info->geometry.aspect_ratio = 4.0f / 3.0f; } /* savestates */ struct savestate_state { - const char *load_buf; - char *save_buf; - size_t size; - size_t pos; + const char *load_buf; + char *save_buf; + size_t size; + size_t pos; }; size_t state_read(void *p, size_t size, size_t nmemb, void *file) { - struct savestate_state *state = file; - size_t bsize = size * nmemb; + struct savestate_state *state = file; + size_t bsize = size * nmemb; - if (state->pos + bsize > state->size) { + if (state->pos + bsize > state->size) { if (log_cb) log_cb(RETRO_LOG_ERROR, "savestate error: %u/%u\n", state->pos + bsize, state->size); - bsize = state->size - state->pos; - if ((int)bsize <= 0) - return 0; - } + bsize = state->size - state->pos; + if ((int)bsize <= 0) + return 0; + } - memcpy(p, state->load_buf + state->pos, bsize); - state->pos += bsize; - return bsize; + memcpy(p, state->load_buf + state->pos, bsize); + state->pos += bsize; + return bsize; } size_t state_write(void *p, size_t size, size_t nmemb, void *file) { - struct savestate_state *state = file; - size_t bsize = size * nmemb; + struct savestate_state *state = file; + size_t bsize = size * nmemb; - if (state->pos + bsize > state->size) { + if (state->pos + bsize > state->size) { if (log_cb) log_cb(RETRO_LOG_ERROR, "savestate error: %u/%u\n", state->pos + bsize, state->size); - bsize = state->size - state->pos; - if ((int)bsize <= 0) - return 0; - } + bsize = state->size - state->pos; + if ((int)bsize <= 0) + return 0; + } - memcpy(state->save_buf + state->pos, p, bsize); - state->pos += bsize; - return bsize; + memcpy(state->save_buf + state->pos, p, bsize); + state->pos += bsize; + return bsize; } size_t state_skip(void *p, size_t size, size_t nmemb, void *file) { - struct savestate_state *state = file; - size_t bsize = size * nmemb; + struct savestate_state *state = file; + size_t bsize = size * nmemb; - state->pos += bsize; - return bsize; + state->pos += bsize; + return bsize; } size_t state_eof(void *file) { - struct savestate_state *state = file; + struct savestate_state *state = file; - return state->pos >= state->size; + return state->pos >= state->size; } int state_fseek(void *file, long offset, int whence) { - struct savestate_state *state = file; + struct savestate_state *state = file; - switch (whence) { - case SEEK_SET: - state->pos = offset; - break; - case SEEK_CUR: - state->pos += offset; - break; - case SEEK_END: - state->pos = state->size + offset; - break; - } - return (int)state->pos; + switch (whence) { + case SEEK_SET: + state->pos = offset; + break; + case SEEK_CUR: + state->pos += offset; + break; + case SEEK_END: + state->pos = state->size + offset; + break; + } + return (int)state->pos; } /* savestate sizes vary wildly depending if cd/32x or * carthw is active, so run the whole thing to get size */ -size_t retro_serialize_size(void) -{ - struct savestate_state state = { 0, }; - int ret; +size_t retro_serialize_size(void) +{ + struct savestate_state state = { 0, }; + int ret; - ret = PicoStateFP(&state, 1, NULL, state_skip, NULL, state_fseek); - if (ret != 0) - return 0; + ret = PicoStateFP(&state, 1, NULL, state_skip, NULL, state_fseek); + if (ret != 0) + return 0; - return state.pos; + return state.pos; } bool retro_serialize(void *data, size_t size) -{ - struct savestate_state state = { 0, }; - int ret; +{ + struct savestate_state state = { 0, }; + int ret; - state.save_buf = data; - state.size = size; - state.pos = 0; + state.save_buf = data; + state.size = size; + state.pos = 0; - ret = PicoStateFP(&state, 1, NULL, state_write, - NULL, state_fseek); - return ret == 0; + ret = PicoStateFP(&state, 1, NULL, state_write, + NULL, state_fseek); + return ret == 0; } bool retro_unserialize(const void *data, size_t size) { - struct savestate_state state = { 0, }; - int ret; + struct savestate_state state = { 0, }; + int ret; - state.load_buf = data; - state.size = size; - state.pos = 0; + state.load_buf = data; + state.size = size; + state.pos = 0; - ret = PicoStateFP(&state, 0, state_read, NULL, - state_eof, state_fseek); - return ret == 0; + ret = PicoStateFP(&state, 0, state_read, NULL, + state_eof, state_fseek); + return ret == 0; } /* cheats - TODO */ @@ -663,193 +663,193 @@ static bool disk_ejected; static unsigned int disk_current_index; static unsigned int disk_count; static struct disks_state { - char *fname; + char *fname; } disks[8]; static bool disk_set_eject_state(bool ejected) { - // TODO? - disk_ejected = ejected; - return true; + // TODO? + disk_ejected = ejected; + return true; } static bool disk_get_eject_state(void) { - return disk_ejected; + return disk_ejected; } static unsigned int disk_get_image_index(void) { - return disk_current_index; + return disk_current_index; } static bool disk_set_image_index(unsigned int index) { - enum cd_img_type cd_type; - int ret; + enum cd_img_type cd_type; + int ret; - if (index >= sizeof(disks) / sizeof(disks[0])) - return false; + if (index >= sizeof(disks) / sizeof(disks[0])) + return false; - if (disks[index].fname == NULL) { + if (disks[index].fname == NULL) { if (log_cb) log_cb(RETRO_LOG_ERROR, "missing disk #%u\n", index); - // RetroArch specifies "no disk" with index == count, - // so don't fail here.. - disk_current_index = index; - return true; - } + // RetroArch specifies "no disk" with index == count, + // so don't fail here.. + disk_current_index = index; + return true; + } if (log_cb) log_cb(RETRO_LOG_INFO, "switching to disk %u: \"%s\"\n", index, disks[index].fname); - ret = -1; - cd_type = PicoCdCheck(disks[index].fname, NULL); - if (cd_type != CIT_NOT_CD) - ret = cdd_load(disks[index].fname, cd_type); - if (ret != 0) { + ret = -1; + cd_type = PicoCdCheck(disks[index].fname, NULL); + if (cd_type != CIT_NOT_CD) + ret = cdd_load(disks[index].fname, cd_type); + if (ret != 0) { if (log_cb) log_cb(RETRO_LOG_ERROR, "Load failed, invalid CD image?\n"); - return 0; - } + return 0; + } - disk_current_index = index; - return true; + disk_current_index = index; + return true; } static unsigned int disk_get_num_images(void) { - return disk_count; + return disk_count; } static bool disk_replace_image_index(unsigned index, - const struct retro_game_info *info) + const struct retro_game_info *info) { - bool ret = true; + bool ret = true; - if (index >= sizeof(disks) / sizeof(disks[0])) - return false; + if (index >= sizeof(disks) / sizeof(disks[0])) + return false; - if (disks[index].fname != NULL) - free(disks[index].fname); - disks[index].fname = NULL; + if (disks[index].fname != NULL) + free(disks[index].fname); + disks[index].fname = NULL; - if (info != NULL) { - disks[index].fname = strdup(info->path); - if (index == disk_current_index) - ret = disk_set_image_index(index); - } + if (info != NULL) { + disks[index].fname = strdup(info->path); + if (index == disk_current_index) + ret = disk_set_image_index(index); + } - return ret; + return ret; } static bool disk_add_image_index(void) { - if (disk_count >= sizeof(disks) / sizeof(disks[0])) - return false; + if (disk_count >= sizeof(disks) / sizeof(disks[0])) + return false; - disk_count++; - return true; + disk_count++; + return true; } static struct retro_disk_control_callback disk_control = { - disk_set_eject_state, - disk_get_eject_state, - disk_get_image_index, - disk_set_image_index, - disk_get_num_images, - disk_replace_image_index, - disk_add_image_index, + disk_set_eject_state, + disk_get_eject_state, + disk_get_image_index, + disk_set_image_index, + disk_get_num_images, + disk_replace_image_index, + disk_add_image_index, }; static void disk_tray_open(void) { if (log_cb) log_cb(RETRO_LOG_INFO, "cd tray open\n"); - disk_ejected = 1; + disk_ejected = 1; } static void disk_tray_close(void) { if (log_cb) log_cb(RETRO_LOG_INFO, "cd tray close\n"); - disk_ejected = 0; + disk_ejected = 0; } static const char * const biosfiles_us[] = { - "us_scd2_9306", "SegaCDBIOS9303", "us_scd1_9210", "bios_CD_U" + "us_scd2_9306", "SegaCDBIOS9303", "us_scd1_9210", "bios_CD_U" }; static const char * const biosfiles_eu[] = { - "eu_mcd2_9306", "eu_mcd2_9303", "eu_mcd1_9210", "bios_CD_E" + "eu_mcd2_9306", "eu_mcd2_9303", "eu_mcd1_9210", "bios_CD_E" }; static const char * const biosfiles_jp[] = { - "jp_mcd2_921222", "jp_mcd1_9112", "jp_mcd1_9111", "bios_CD_J" + "jp_mcd2_921222", "jp_mcd1_9112", "jp_mcd1_9111", "bios_CD_J" }; static void make_system_path(char *buf, size_t buf_size, - const char *name, const char *ext) + const char *name, const char *ext) { - const char *dir = NULL; + const char *dir = NULL; - if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir) { - snprintf(buf, buf_size, "%s%c%s%s", dir, SLASH, name, ext); - } - else { - snprintf(buf, buf_size, "%s%s", name, ext); - } + if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir) { + snprintf(buf, buf_size, "%s%c%s%s", dir, SLASH, name, ext); + } + else { + snprintf(buf, buf_size, "%s%s", name, ext); + } } static const char *find_bios(int *region, const char *cd_fname) { - const char * const *files; - static char path[256]; - int i, count; - FILE *f = NULL; + const char * const *files; + static char path[256]; + int i, count; + FILE *f = NULL; - if (*region == 4) { // US - files = biosfiles_us; - count = sizeof(biosfiles_us) / sizeof(char *); - } else if (*region == 8) { // EU - files = biosfiles_eu; - count = sizeof(biosfiles_eu) / sizeof(char *); - } else if (*region == 1 || *region == 2) { - files = biosfiles_jp; - count = sizeof(biosfiles_jp) / sizeof(char *); - } else { - return NULL; - } + if (*region == 4) { // US + files = biosfiles_us; + count = sizeof(biosfiles_us) / sizeof(char *); + } else if (*region == 8) { // EU + files = biosfiles_eu; + count = sizeof(biosfiles_eu) / sizeof(char *); + } else if (*region == 1 || *region == 2) { + files = biosfiles_jp; + count = sizeof(biosfiles_jp) / sizeof(char *); + } else { + return NULL; + } - for (i = 0; i < count; i++) - { - make_system_path(path, sizeof(path), files[i], ".bin"); - f = fopen(path, "rb"); - if (f != NULL) - break; + for (i = 0; i < count; i++) + { + make_system_path(path, sizeof(path), files[i], ".bin"); + f = fopen(path, "rb"); + if (f != NULL) + break; - make_system_path(path, sizeof(path), files[i], ".zip"); - f = fopen(path, "rb"); - if (f != NULL) - break; - } + make_system_path(path, sizeof(path), files[i], ".zip"); + f = fopen(path, "rb"); + if (f != NULL) + break; + } - if (f != NULL) { + if (f != NULL) { if (log_cb) log_cb(RETRO_LOG_INFO, "using bios: %s\n", path); - fclose(f); - return path; - } + fclose(f); + return path; + } - return NULL; + return NULL; } bool retro_load_game(const struct retro_game_info *info) { - enum media_type_e media_type; - static char carthw_path[256]; - size_t i; + enum media_type_e media_type; + static char carthw_path[256]; + size_t i; struct retro_input_descriptor desc[] = { { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, @@ -961,210 +961,210 @@ bool retro_load_game(const struct retro_game_info *info) environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc); - enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; - if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) { + enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; + if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) { if (log_cb) log_cb(RETRO_LOG_ERROR, "RGB565 support required, sorry\n"); - return false; - } + return false; + } - if (info == NULL || info->path == NULL) { + if (info == NULL || info->path == NULL) { if (log_cb) log_cb(RETRO_LOG_ERROR, "info->path required\n"); - return false; - } + return false; + } - for (i = 0; i < sizeof(disks) / sizeof(disks[0]); i++) { - if (disks[i].fname != NULL) { - free(disks[i].fname); - disks[i].fname = NULL; - } - } + for (i = 0; i < sizeof(disks) / sizeof(disks[0]); i++) { + if (disks[i].fname != NULL) { + free(disks[i].fname); + disks[i].fname = NULL; + } + } - disk_current_index = 0; - disk_count = 1; - disks[0].fname = strdup(info->path); + disk_current_index = 0; + disk_count = 1; + disks[0].fname = strdup(info->path); - make_system_path(carthw_path, sizeof(carthw_path), "carthw", ".cfg"); + make_system_path(carthw_path, sizeof(carthw_path), "carthw", ".cfg"); - media_type = PicoLoadMedia(info->path, carthw_path, - find_bios, NULL); + media_type = PicoLoadMedia(info->path, carthw_path, + find_bios, NULL); - switch (media_type) { - case PM_BAD_DETECT: + switch (media_type) { + case PM_BAD_DETECT: if (log_cb) log_cb(RETRO_LOG_ERROR, "Failed to detect ROM/CD image type.\n"); - return false; - case PM_BAD_CD: + return false; + case PM_BAD_CD: if (log_cb) log_cb(RETRO_LOG_ERROR, "Invalid CD image\n"); - return false; - case PM_BAD_CD_NO_BIOS: + return false; + case PM_BAD_CD_NO_BIOS: if (log_cb) log_cb(RETRO_LOG_ERROR, "Missing BIOS\n"); - return false; - case PM_ERROR: + return false; + case PM_ERROR: if (log_cb) log_cb(RETRO_LOG_ERROR, "Load error\n"); - return false; - default: - break; - } + return false; + default: + break; + } - PicoLoopPrepare(); + PicoLoopPrepare(); - PicoWriteSound = snd_write; - memset(sndBuffer, 0, sizeof(sndBuffer)); - PsndOut = sndBuffer; - PsndRerate(0); + PicoWriteSound = snd_write; + memset(sndBuffer, 0, sizeof(sndBuffer)); + PsndOut = sndBuffer; + PsndRerate(0); - return true; + return true; } bool retro_load_game_special(unsigned game_type, const struct retro_game_info *info, size_t num_info) { - return false; + return false; } -void retro_unload_game(void) +void retro_unload_game(void) { } unsigned retro_get_region(void) { - return Pico.m.pal ? RETRO_REGION_PAL : RETRO_REGION_NTSC; + return Pico.m.pal ? RETRO_REGION_PAL : RETRO_REGION_NTSC; } void *retro_get_memory_data(unsigned id) { - if (id != RETRO_MEMORY_SAVE_RAM) - return NULL; + if (id != RETRO_MEMORY_SAVE_RAM) + return NULL; - if (PicoAHW & PAHW_MCD) - return Pico_mcd->bram; - else - return SRam.data; + if (PicoAHW & PAHW_MCD) + return Pico_mcd->bram; + else + return SRam.data; } size_t retro_get_memory_size(unsigned id) { - unsigned int i; - int sum; + unsigned int i; + int sum; - if (id != RETRO_MEMORY_SAVE_RAM) - return 0; + if (id != RETRO_MEMORY_SAVE_RAM) + return 0; - if (PicoAHW & PAHW_MCD) - // bram - return 0x2000; + if (PicoAHW & PAHW_MCD) + // bram + return 0x2000; - if (Pico.m.frame_count == 0) - return SRam.size; + if (Pico.m.frame_count == 0) + return SRam.size; - // if game doesn't write to sram, don't report it to - // libretro so that RA doesn't write out zeroed .srm - for (i = 0, sum = 0; i < SRam.size; i++) - sum |= SRam.data[i]; + // if game doesn't write to sram, don't report it to + // libretro so that RA doesn't write out zeroed .srm + for (i = 0, sum = 0; i < SRam.size; i++) + sum |= SRam.data[i]; - return (sum != 0) ? SRam.size : 0; + return (sum != 0) ? SRam.size : 0; } void retro_reset(void) { - PicoReset(); + PicoReset(); } static const unsigned short retro_pico_map[] = { - 1 << GBTN_B, - 1 << GBTN_A, - 1 << GBTN_MODE, - 1 << GBTN_START, - 1 << GBTN_UP, - 1 << GBTN_DOWN, - 1 << GBTN_LEFT, - 1 << GBTN_RIGHT, - 1 << GBTN_C, - 1 << GBTN_Y, - 1 << GBTN_X, - 1 << GBTN_Z, + 1 << GBTN_B, + 1 << GBTN_A, + 1 << GBTN_MODE, + 1 << GBTN_START, + 1 << GBTN_UP, + 1 << GBTN_DOWN, + 1 << GBTN_LEFT, + 1 << GBTN_RIGHT, + 1 << GBTN_C, + 1 << GBTN_Y, + 1 << GBTN_X, + 1 << GBTN_Z, }; #define RETRO_PICO_MAP_LEN (sizeof(retro_pico_map) / sizeof(retro_pico_map[0])) static void snd_write(int len) { - audio_batch_cb(PsndOut, len / 4); + audio_batch_cb(PsndOut, len / 4); } static enum input_device input_name_to_val(const char *name) { - if (strcmp(name, "3 button pad") == 0) - return PICO_INPUT_PAD_3BTN; - if (strcmp(name, "6 button pad") == 0) - return PICO_INPUT_PAD_6BTN; - if (strcmp(name, "None") == 0) - return PICO_INPUT_NOTHING; + if (strcmp(name, "3 button pad") == 0) + return PICO_INPUT_PAD_3BTN; + if (strcmp(name, "6 button pad") == 0) + return PICO_INPUT_PAD_6BTN; + if (strcmp(name, "None") == 0) + return PICO_INPUT_NOTHING; if (log_cb) log_cb(RETRO_LOG_WARN, "invalid picodrive_input: '%s'\n", name); - return PICO_INPUT_PAD_3BTN; + return PICO_INPUT_PAD_3BTN; } static void update_variables(void) { - struct retro_variable var; + struct retro_variable var; - var.value = NULL; - var.key = "picodrive_input1"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - PicoSetInputDevice(0, input_name_to_val(var.value)); + var.value = NULL; + var.key = "picodrive_input1"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + PicoSetInputDevice(0, input_name_to_val(var.value)); - var.value = NULL; - var.key = "picodrive_input2"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - PicoSetInputDevice(1, input_name_to_val(var.value)); + var.value = NULL; + var.key = "picodrive_input2"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + PicoSetInputDevice(1, input_name_to_val(var.value)); - var.value = NULL; - var.key = "picodrive_sprlim"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - if (strcmp(var.value, "enabled") == 0) - PicoOpt |= POPT_DIS_SPRITE_LIM; - else - PicoOpt &= ~POPT_DIS_SPRITE_LIM; - } + var.value = NULL; + var.key = "picodrive_sprlim"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + if (strcmp(var.value, "enabled") == 0) + PicoOpt |= POPT_DIS_SPRITE_LIM; + else + PicoOpt &= ~POPT_DIS_SPRITE_LIM; + } - var.value = NULL; - var.key = "picodrive_ramcart"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - if (strcmp(var.value, "enabled") == 0) - PicoOpt |= POPT_EN_MCD_RAMCART; - else - PicoOpt &= ~POPT_EN_MCD_RAMCART; - } + var.value = NULL; + var.key = "picodrive_ramcart"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + if (strcmp(var.value, "enabled") == 0) + PicoOpt |= POPT_EN_MCD_RAMCART; + else + PicoOpt &= ~POPT_EN_MCD_RAMCART; + } - var.value = NULL; - var.key = "picodrive_region"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - if (strcmp(var.value, "Auto") == 0) - PicoRegionOverride = 0; - else if (strcmp(var.value, "Japan NTSC") == 0) - PicoRegionOverride = 1; - else if (strcmp(var.value, "Japan PAL") == 0) - PicoRegionOverride = 2; - else if (strcmp(var.value, "US") == 0) - PicoRegionOverride = 4; - else if (strcmp(var.value, "Europe") == 0) - PicoRegionOverride = 8; - } + var.value = NULL; + var.key = "picodrive_region"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + if (strcmp(var.value, "Auto") == 0) + PicoRegionOverride = 0; + else if (strcmp(var.value, "Japan NTSC") == 0) + PicoRegionOverride = 1; + else if (strcmp(var.value, "Japan PAL") == 0) + PicoRegionOverride = 2; + else if (strcmp(var.value, "US") == 0) + PicoRegionOverride = 4; + else if (strcmp(var.value, "Europe") == 0) + PicoRegionOverride = 8; + } #ifdef DRC_SH2 - var.value = NULL; - var.key = "picodrive_drc"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - if (strcmp(var.value, "enabled") == 0) - PicoOpt |= POPT_EN_DRC; - else - PicoOpt &= ~POPT_EN_DRC; - } + var.value = NULL; + var.key = "picodrive_drc"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + if (strcmp(var.value, "enabled") == 0) + PicoOpt |= POPT_EN_DRC; + else + PicoOpt &= ~POPT_EN_DRC; + } #endif #ifdef _3DS if(!ctr_svchack_successful) @@ -1172,26 +1172,26 @@ static void update_variables(void) #endif } -void retro_run(void) +void retro_run(void) { - bool updated = false; - int pad, i; + bool updated = false; + int pad, i; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) - update_variables(); + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) + update_variables(); input_poll_cb(); - PicoPad[0] = PicoPad[1] = 0; - for (pad = 0; pad < 2; pad++) - for (i = 0; i < RETRO_PICO_MAP_LEN; i++) - if (input_state_cb(pad, RETRO_DEVICE_JOYPAD, 0, i)) - PicoPad[pad] |= retro_pico_map[i]; + PicoPad[0] = PicoPad[1] = 0; + for (pad = 0; pad < 2; pad++) + for (i = 0; i < RETRO_PICO_MAP_LEN; i++) + if (input_state_cb(pad, RETRO_DEVICE_JOYPAD, 0, i)) + PicoPad[pad] |= retro_pico_map[i]; - PicoFrame(); + PicoFrame(); - video_cb((short *)vout_buf + vout_offset, - vout_width, vout_height, vout_width * 2); + video_cb((short *)vout_buf + vout_offset, + vout_width, vout_height, vout_width * 2); } static void check_system_specs(void) @@ -1204,36 +1204,36 @@ static void check_system_specs(void) void retro_init(void) { struct retro_log_callback log; - int level; + int level; - level = 0; - environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level); + level = 0; + environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level); if (environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log)) log_cb = log.log; else log_cb = NULL; - environ_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE, &disk_control); + environ_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE, &disk_control); #ifdef _3DS ctr_svchack_successful = ctr_svchack_init(); #endif - PicoOpt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 - | POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_MCD_GFX - | POPT_EN_32X|POPT_EN_PWM - | POPT_ACC_SPRITES|POPT_DIS_32C_BORDER; + PicoOpt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 + | POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_MCD_GFX + | POPT_EN_32X|POPT_EN_PWM + | POPT_ACC_SPRITES|POPT_DIS_32C_BORDER; #ifdef __arm__ #ifdef _3DS if (ctr_svchack_successful) #endif PicoOpt |= POPT_EN_DRC; #endif - PsndRate = 44100; - PicoAutoRgnOrder = 0x184; // US, EU, JP + PsndRate = 44100; + PicoAutoRgnOrder = 0x184; // US, EU, JP - vout_width = 320; + vout_width = 320; vout_height = 240; vout_buf = malloc(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2); @@ -1241,14 +1241,14 @@ void retro_init(void) PicoDrawSetOutFormat(PDF_RGB555, 0); PicoDrawSetOutBuf(vout_buf, vout_width * 2); - //PicoMessage = plat_status_msg_busy_next; - PicoMCDopenTray = disk_tray_open; - PicoMCDcloseTray = disk_tray_close; + //PicoMessage = plat_status_msg_busy_next; + PicoMCDopenTray = disk_tray_open; + PicoMCDcloseTray = disk_tray_close; update_variables(); } void retro_deinit(void) { - PicoExit(); + PicoExit(); } From 4f05464f4cc988115e1512a97957c746047ba7ff Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 1 Oct 2015 01:35:43 +0100 Subject: [PATCH 053/124] make -fPIC platform specific. --- Makefile.libretro | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index e6766fd9..a7b9c811 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -34,9 +34,11 @@ asm_cdpico = 0 asm_cdmemory = 0 asm_mix = 0 +fpic := # Unix ifeq ($(platform), unix) TARGET := $(TARGET_NAME)_libretro.so + fpic := -fPIC SHARED := -shared DONT_COMPILE_IN_ZLIB = 1 CFLAGS += -DFAMEC_NO_GOTOS @@ -45,6 +47,7 @@ ifeq ($(platform), unix) else ifeq ($(platform), linux-portable) TARGET := $(TARGET_NAME)_libretro.so SHARED := -shared -nostdlib + fpic := -fPIC LIBM := DONT_COMPILE_IN_ZLIB = 1 CFLAGS += -DFAMEC_NO_GOTOS @@ -53,6 +56,7 @@ else ifeq ($(platform), linux-portable) else ifeq ($(platform), osx) TARGET := $(TARGET_NAME)_libretro.dylib SHARED := -dynamiclib + fpic := -fPIC APPLE := 1 arch = intel ifeq ($(shell uname -p),powerpc) @@ -69,6 +73,7 @@ else ifeq ($(platform), osx) else ifeq ($(platform), ios) TARGET := $(TARGET_NAME)_libretro_ios.dylib SHARED := -dynamiclib + fpic := -fPIC APPLE := 1 ifeq ($(IOSSDK),) IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) @@ -267,6 +272,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) CFLAGS += -DBASE_ADDR_FIXED=0 -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp @@ -285,6 +291,7 @@ else ifeq ($(platform), qnx) else ifneq (,$(findstring armv,$(platform))) TARGET := $(TARGET_NAME)_libretro.so SHARED := -shared -Wl,--no-undefined + fpic := -fPIC ifneq (,$(findstring cortexa5,$(platform))) CFLAGS += -marm -mcpu=cortex-a5 ASFLAGS += -mcpu=cortex-a5 @@ -320,7 +327,7 @@ else ifneq (,$(findstring armv,$(platform))) else TARGET := $(TARGET_NAME)_libretro.dll CC = gcc - LD_FLAGS := -fPIC + fpic := -fPIC SHARED := -shared -static-libgcc -static-libstdc++ CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__ @@ -342,13 +349,13 @@ ifeq ($(ARM_ASM),1) asm_mix = 1 endif -CFLAGS += -fPIC +CFLAGS += $(fpic) ifeq ($(findstring Haiku,$(shell uname -a)),) LDLIBS += $(LIBM) endif SHARED ?= -shared -LDFLAGS += $(SHARED) +LDFLAGS += $(SHARED) $(fpic) PLATFORM = libretro NO_CONFIG_MAK = yes From 55717e05d2b06fc9f1f8127696e2af3aaaafe614 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 1 Oct 2015 03:10:29 +0100 Subject: [PATCH 054/124] nit --- platform/libretro/3ds/3ds_utils.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/platform/libretro/3ds/3ds_utils.h b/platform/libretro/3ds/3ds_utils.h index 5aa452f6..fe97985c 100644 --- a/platform/libretro/3ds/3ds_utils.h +++ b/platform/libretro/3ds/3ds_utils.h @@ -8,8 +8,6 @@ void ctr_flush_invalidate_cache(void); int ctr_svchack_init(void); - - #include #define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0) From ad2ccfbc0976bb01a516d6694e71d9fd29d861c1 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Fri, 2 Oct 2015 00:30:29 +0100 Subject: [PATCH 055/124] (CTR/3DS) improve performance by using a DMA friendly vout_buf. --- platform/libretro/libretro.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 62b168e3..61d6f7b7 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -26,13 +26,16 @@ #ifdef _3DS #include "3ds/3ds_utils.h" -#define MEMOP_PROT 6 +#define MEMOP_MAP 4 +#define MEMOP_UNMAP 5 +#define MEMOP_PROT 6 + int svcDuplicateHandle(unsigned int* out, unsigned int original); int svcCloseHandle(unsigned int handle); int svcControlProcessMemory(unsigned int process, void* addr0, void* addr1, unsigned int size, unsigned int type, unsigned int perm); -#define MEMOP_MAP 4 -#define MEMOP_UNMAP 5 +void* linearMemAlign(size_t size, size_t alignment); +void linearFree(void* mem); static int ctr_svchack_successful = 0; #endif @@ -1235,7 +1238,11 @@ void retro_init(void) vout_width = 320; vout_height = 240; +#ifdef _3DS + vout_buf = linearMemAlign(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2, 0x80); +#else vout_buf = malloc(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2); +#endif PicoInit(); PicoDrawSetOutFormat(PDF_RGB555, 0); @@ -1250,5 +1257,11 @@ void retro_init(void) void retro_deinit(void) { +#ifdef _3DS + linearFree(vout_buf); +#else + free(vout_buf); +#endif + vout_buf = NULL; PicoExit(); } From d54274b5deb15c0345387f6153c428e44c8ba703 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 15 Oct 2015 16:29:45 +0200 Subject: [PATCH 056/124] Add iOS 9 rules --- Makefile.libretro | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index a7b9c811..82122325 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -70,7 +70,7 @@ else ifeq ($(platform), osx) SHARED += -mmacosx-version-min=10.1 # iOS -else ifeq ($(platform), ios) +else ifneq (,$(findstring ios,$(platform))) TARGET := $(TARGET_NAME)_libretro_ios.dylib SHARED := -dynamiclib fpic := -fPIC @@ -84,14 +84,18 @@ else ifeq ($(platform), ios) CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon 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 ARCH := arm use_cyclone = 0 From 913fd1dc89c9c2bbc8b5bf6b5531e64b8ebc4a68 Mon Sep 17 00:00:00 2001 From: vanfanel Date: Wed, 21 Oct 2015 20:51:32 +0000 Subject: [PATCH 057/124] Added Raspberry Pi 1 platform with optimal parameters to Makefile.libretro --- Makefile.libretro | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Makefile.libretro b/Makefile.libretro index 82122325..1de11c65 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -228,6 +228,34 @@ else ifeq ($(platform), ctr) OBJS +=platform/libretro/3ds/3ds_utils.o +# Raspberry Pi (original model) Raspbian +else ifeq ($(platform), raspberrypi) + CFLAGS += -marm -mfpu=vfp -mfloat-abi=hard -march=armv6j + CFLAGS += -Wall -mword-relocations + CFLAGS += -fomit-frame-pointer -ffast-math + ARCH = arm + ARM_ASM = 1 + + TARGET := $(TARGET_NAME)_libretro.so + SHARED := -shared -nostdlib + fpic := -fPIC + DONT_COMPILE_IN_ZLIB = 1 + + asm_memory = 1 + asm_render = 1 + asm_ym2612 = 1 + asm_misc = 1 + asm_cdpico = 1 + asm_cdmemory = 1 + asm_mix = 1 + + use_cyclone = 1 + use_fame = 0 + use_drz80 = 1 + use_cz80 = 0 + use_sh2drc = 1 + use_svpdrc = 1 + # Vita else ifeq ($(platform), vita) TARGET := $(TARGET_NAME)_libretro_vita.a From bd7b09f4f98effa884fb282329cd55e891f12c22 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 24 Nov 2015 13:49:31 +0100 Subject: [PATCH 058/124] Fix the lprintf method (libretro side) The lprintf method used the format string instead of the buffer build from va_list --- pico/media.c | 8 ++++---- platform/libretro/libretro.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pico/media.c b/pico/media.c index 3ba45324..b7fa7f56 100644 --- a/pico/media.c +++ b/pico/media.c @@ -244,7 +244,7 @@ enum media_type_e PicoLoadMedia(const char *filename, rom = pm_open(rom_fname); if (rom == NULL) { - lprintf("Failed to open ROM"); + lprintf("Failed to open ROM\n"); media_type = PM_ERROR; goto out; } @@ -252,9 +252,9 @@ enum media_type_e PicoLoadMedia(const char *filename, ret = PicoCartLoad(rom, &rom_data, &rom_size, (PicoAHW & PAHW_SMS) ? 1 : 0); pm_close(rom); if (ret != 0) { - if (ret == 2) lprintf("Out of memory"); - else if (ret == 3) lprintf("Read failed"); - else lprintf("PicoCartLoad() failed."); + if (ret == 2) lprintf("Out of memory\n"); + else if (ret == 3) lprintf("Read failed\n"); + else lprintf("PicoCartLoad() failed.\n"); media_type = PM_ERROR; goto out; } diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 61d6f7b7..799ff8d4 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -469,7 +469,7 @@ void lprintf(const char *fmt, ...) vsprintf(buffer, fmt, ap); /* TODO - add 'level' param for warning/error messages? */ if (log_cb) - log_cb(RETRO_LOG_INFO, "%s\n", fmt, ap); + log_cb(RETRO_LOG_INFO, "%s", buffer); va_end(ap); } From 48582bcfb85529a40a585a7f9c0b8e3baf690b21 Mon Sep 17 00:00:00 2001 From: David Date: Sun, 13 Dec 2015 14:54:13 +0100 Subject: [PATCH 059/124] Add core option to force the Region FPS (NTSC, PAL) This new core option will override the Region option. So it's possible to choose the Europe Region and the NTSC FPS. Strangely the region protection has no effect on megadrive :-) But will happend on 32x and SegaCD (Maybe it can be fixed by activating this core option after a little delay on startup) --- pico/pico.c | 30 +++++++++++++++++++++++------- pico/pico.h | 7 ++++--- pico/sound/sound.c | 4 ++++ platform/libretro/libretro.c | 34 ++++++++++++++++++++++++++++------ 4 files changed, 59 insertions(+), 16 deletions(-) diff --git a/pico/pico.c b/pico/pico.c index 8535d486..866f6973 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -12,12 +12,13 @@ struct Pico Pico; int PicoOpt; -int PicoSkipFrame; // skip rendering frame? -int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU -int PicoPadInt[2]; // internal copy -int PicoAHW; // active addon hardware: PAHW_* -int PicoQuirks; // game-specific quirks -int PicoRegionOverride; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe +int PicoSkipFrame; // skip rendering frame? +int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU +int PicoPadInt[2]; // internal copy +int PicoAHW; // active addon hardware: PAHW_* +int PicoQuirks; // game-specific quirks +int PicoRegionOverride; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe +int PicoRegionFPSOverride; // override the refresh rate of the region 0: Auto, 1: NTSC, 2: PAL int PicoAutoRgnOrder; struct PicoSRAM SRam; @@ -91,6 +92,10 @@ void PicoPower(void) PICO_INTERNAL void PicoDetectRegion(void) { + // PicoDetectRegion not ready yet + if (Pico.romsize <= 0) + return; + int support=0, hw=0, i; unsigned char pal=0; @@ -143,6 +148,10 @@ PICO_INTERNAL void PicoDetectRegion(void) else hw=0x80; // USA Pico.m.hardware=(unsigned char)(hw|0x20); // No disk attached + + if (PicoRegionFPSOverride > 0) + pal = PicoRegionFPSOverride - 1; // pal - 0: NTSC, 1: PAL | PicoRegionFPSOverride - 0: Auto, 1: NTSC, 2: PAL + Pico.m.pal=pal; } @@ -216,9 +225,16 @@ int PicoReset(void) // flush config changes before emu loop starts void PicoLoopPrepare(void) { - if (PicoRegionOverride) + if (PicoRegionFPSOverride) // PicoRegionFPSOverride is proprietary on PicoRegionOverride + { + // force setting possibly changed.. + Pico.m.pal = PicoRegionFPSOverride - 1; // Pico.m.pal - 0: NTSC, 1: PAL | PicoRegionFPSOverride - 0: Auto, 1: NTSC, 2: PAL + } + else if (PicoRegionOverride) + { // force setting possibly changed.. Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0; + } // FIXME: PAL has 313 scanlines.. scanlines_total = Pico.m.pal ? 312 : 262; diff --git a/pico/pico.h b/pico/pico.h index d5416727..624adacc 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -81,9 +81,10 @@ extern int PicoAHW; // Pico active hw #define PQUIRK_FORCE_6BTN (1<<0) extern int PicoQuirks; -extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff -extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe -extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP +extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff +extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe +extern int PicoRegionFPSOverride; // override the refresh rate of the region 0: Auto, 1: NTSC, 2: PAL +extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP extern int PicoSVPCycles; void PicoInit(void); void PicoExit(void); diff --git a/pico/sound/sound.c b/pico/sound/sound.c index 69c1be03..18e12250 100644 --- a/pico/sound/sound.c +++ b/pico/sound/sound.c @@ -118,6 +118,10 @@ PICO_INTERNAL void PsndReset(void) // to be called after changing sound rate or chips void PsndRerate(int preserve_state) { + // PsndRerate not ready yet + if (Pico.romsize <= 0) + return; + void *state = NULL; int target_fps = Pico.m.pal ? 50 : 60; diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 799ff8d4..0a4ab495 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -477,12 +477,12 @@ void lprintf(const char *fmt, ...) void retro_set_environment(retro_environment_t cb) { static const struct retro_variable vars[] = { - //{ "region", "Region; Auto|NTSC|PAL" }, - { "picodrive_input1", "Input device 1; 3 button pad|6 button pad|None" }, - { "picodrive_input2", "Input device 2; 3 button pad|6 button pad|None" }, - { "picodrive_sprlim", "No sprite limit; disabled|enabled" }, - { "picodrive_ramcart", "MegaCD RAM cart; disabled|enabled" }, - { "picodrive_region", "Region; Auto|Japan NTSC|Japan PAL|US|Europe" }, + { "picodrive_input1", "Input device 1; 3 button pad|6 button pad|None" }, + { "picodrive_input2", "Input device 2; 3 button pad|6 button pad|None" }, + { "picodrive_sprlim", "No sprite limit; disabled|enabled" }, + { "picodrive_ramcart", "MegaCD RAM cart; disabled|enabled" }, + { "picodrive_region", "Region; Auto|Japan NTSC|Japan PAL|US|Europe" }, + { "picodrive_region_fps", "Region FPS; Auto|NTSC|PAL"}, #ifdef DRC_SH2 { "picodrive_drc", "Dynamic recompilers; enabled|disabled" }, #endif @@ -1144,6 +1144,7 @@ static void update_variables(void) PicoOpt &= ~POPT_EN_MCD_RAMCART; } + int OldPicoRegionOverride = PicoRegionOverride; var.value = NULL; var.key = "picodrive_region"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { @@ -1159,6 +1160,27 @@ static void update_variables(void) PicoRegionOverride = 8; } + int OldPicoRegionFPSOverride = PicoRegionFPSOverride; + var.value = NULL; + var.key = "picodrive_region_fps"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + if (strcmp(var.value, "Auto") == 0) + PicoRegionFPSOverride = 0; + else if (strcmp(var.value, "NTSC") == 0) + PicoRegionFPSOverride = 1; + else if (strcmp(var.value, "PAL") == 0) + PicoRegionFPSOverride = 2; + } + + // Update region, fps and sound flags if needed + if (PicoRegionOverride != OldPicoRegionOverride || + PicoRegionFPSOverride != OldPicoRegionFPSOverride) + { + PicoDetectRegion(); + PicoLoopPrepare(); + PsndRerate(1); + } + #ifdef DRC_SH2 var.value = NULL; var.key = "picodrive_drc"; From 17d4733d38b0518055bf379a1ec486dfc563abe8 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 6 Jan 2016 21:30:41 +0100 Subject: [PATCH 060/124] Add input descriptors for Master System Limit also the number of players for the input descriptors to 2 players until the TeamPlayer didn't work. --- platform/libretro/libretro.c | 115 +++++++++-------------------------- 1 file changed, 30 insertions(+), 85 deletions(-) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 0a4ab495..75fdf90b 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -865,8 +865,8 @@ bool retro_load_game(const struct retro_game_info *info) { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, - { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, - { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT,"Mode" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, @@ -878,91 +878,31 @@ bool retro_load_game(const struct retro_game_info *info) { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, - { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, - { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, - - { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, - { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, - { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, - { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, - { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" }, - { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "C" }, - { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" }, - { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, - { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, - { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, - { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, - { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, - - { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, - { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, - { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, - { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, - { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" }, - { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "C" }, - { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" }, - { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, - { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, - { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, - { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, - { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, - - { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, - { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, - { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, - { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, - { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" }, - { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "C" }, - { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" }, - { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, - { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, - { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, - { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, - { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, - - { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, - { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, - { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, - { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, - { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" }, - { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "C" }, - { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" }, - { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, - { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, - { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, - { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, - { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, - - { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, - { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, - { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, - { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, - { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" }, - { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "C" }, - { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" }, - { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, - { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, - { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, - { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, - { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, - - { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, - { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, - { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, - { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, - { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" }, - { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "C" }, - { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" }, - { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "A" }, - { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "X" }, - { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" }, - { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, - { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT,"Mode" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, { 0 }, }; - environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc); + struct retro_input_descriptor desc_sms[] = { + { 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, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "1 Start" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "2" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Pause" }, + + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "1 Start" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "2" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Pause" }, + + { 0 }, + }; enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) { @@ -1014,6 +954,11 @@ bool retro_load_game(const struct retro_game_info *info) break; } + if (media_type == PM_MARK3) + environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc_sms); + else + environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc); + PicoLoopPrepare(); PicoWriteSound = snd_write; @@ -1171,7 +1116,7 @@ static void update_variables(void) else if (strcmp(var.value, "PAL") == 0) PicoRegionFPSOverride = 2; } - + // Update region, fps and sound flags if needed if (PicoRegionOverride != OldPicoRegionOverride || PicoRegionFPSOverride != OldPicoRegionFPSOverride) @@ -1180,7 +1125,7 @@ static void update_variables(void) PicoLoopPrepare(); PsndRerate(1); } - + #ifdef DRC_SH2 var.value = NULL; var.key = "picodrive_drc"; From 70faf5a316caf8979ad028e0bdde62d922f98690 Mon Sep 17 00:00:00 2001 From: Thomas Daley Date: Sat, 30 Jan 2016 13:40:46 -0600 Subject: [PATCH 061/124] PSP build fix --- Makefile.libretro | 2 +- platform/libretro/psp/draw_amips.s | 1756 ++++++++++++++++++++++++++++ 2 files changed, 1757 insertions(+), 1 deletion(-) create mode 100644 platform/libretro/psp/draw_amips.s diff --git a/Makefile.libretro b/Makefile.libretro index 1de11c65..30612e7e 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -193,7 +193,7 @@ else ifeq ($(platform), psp1) use_drz80 = 0 use_cz80 = 1 - + OBJS +=platform/libretro/psp/draw_amips.o # CTR (3DS) else ifeq ($(platform), ctr) diff --git a/platform/libretro/psp/draw_amips.s b/platform/libretro/psp/draw_amips.s new file mode 100644 index 00000000..fa7906ee --- /dev/null +++ b/platform/libretro/psp/draw_amips.s @@ -0,0 +1,1756 @@ +#* +#* several drawing related functions for Allegrex MIPS +#* (C) notaz, 2007-2008 +#* +#* This work is licensed under the terms of MAME license. +#* See COPYING file in the top-level directory. +#* +#* this is highly specialized, be careful if changing related C code! +#* + +.set noreorder # don't reorder any instructions +.set noat # don't use $at + +.text +.align 4 + +# void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count) + +.global amips_clut + +amips_clut: + srl $a3, 2 +amips_clut_loop: + lbu $t0, 0($a1) # tried lw here, no improvement noticed + lbu $t1, 1($a1) + lbu $t2, 2($a1) + lbu $t3, 3($a1) + sll $t0, 1 + sll $t1, 1 + sll $t2, 1 + sll $t3, 1 + addu $t0, $a2 + addu $t1, $a2 + addu $t2, $a2 + addu $t3, $a2 + lhu $t0, 0($t0) + lhu $t1, 0($t1) + lhu $t2, 0($t2) + lhu $t3, 0($t3) + ins $t0, $t1, 16, 16 # ins rt, rs, pos, size - Insert size bits starting + ins $t2, $t3, 16, 16 # from the LSB of rs into rt starting at position pos + sw $t0, 0($a0) + sw $t2, 4($a0) + addiu $a0, 8 + addiu $a3, -1 + bnez $a3, amips_clut_loop + addiu $a1, 4 + jr $ra + nop + + +.global amips_clut_6bit + +amips_clut_6bit: + srl $a3, 2 + li $t4, 0 + li $t5, 0 + li $t6, 0 + li $t7, 0 +amips_clut_loop6: + lbu $t0, 0($a1) # tried lw here, no improvement noticed + lbu $t1, 1($a1) + lbu $t2, 2($a1) + lbu $t3, 3($a1) + ins $t4, $t0, 1, 6 + ins $t5, $t1, 1, 6 + ins $t6, $t2, 1, 6 + ins $t7, $t3, 1, 6 + addu $t0, $t4, $a2 + addu $t1, $t5, $a2 + addu $t2, $t6, $a2 + addu $t3, $t7, $a2 + lhu $t0, 0($t0) + lhu $t1, 0($t1) + lhu $t2, 0($t2) + lhu $t3, 0($t3) + ins $t0, $t1, 16, 16 # ins rt, rs, pos, size - Insert size bits starting + ins $t2, $t3, 16, 16 # from the LSB of rs into rt starting at position pos + sw $t0, 0($a0) + sw $t2, 4($a0) + addiu $a0, 8 + addiu $a3, -1 + bnez $a3, amips_clut_loop6 + addiu $a1, 4 + jr $ra + nop + + +# $a0 - pd, $a1 - tile word, $a2 - pal +# ext rt, rs, pos, size // Extract size bits from position pos in rs and store in rt + +.macro TilePixelPrep shift dreg offs +.if \shift + ext \dreg, $a1, \shift, 4 +.else + andi \dreg, $a1, 0xf +.endif +.if \offs + sltu $t8, $0, \dreg + ins $t9, $t8, \offs, 1 +.else + sltu $t9, $0, \dreg +.endif +.endm + +.macro TileStartCode + sll $a1, $a1, 1 + lui $t1, %hi(Pico+0x10000) + addu $a1, $a1, $t1 + lw $a1, %lo(Pico+0x10000)($a1) # Pico.vram + addr + beqz $a1, TileEmpty + rotr $t1, $a1, 4 + beq $t1, $a1, SingleColor + and $v0, $0 # not empty tile +.endm + +.macro TileEndCode + xori $t8, $t9, 0xff + beqz $t8, tile11111111 # common case + lui $v1, %hi(HighCol) + lui $t8, %hi(TileTable) + ins $t8, $t9, 2, 8 + lw $t8, %lo(TileTable)($t8) + lw $v1, %lo(HighCol)($v1) + jr $t8 + addu $a0, $v1 +.endm + + +.global TileNorm + +TileNorm: + TileStartCode + TilePixelPrep 12, $t0, 0 + TilePixelPrep 8, $t1, 1 + TilePixelPrep 4, $t2, 2 + TilePixelPrep 0, $t3, 3 + TilePixelPrep 28, $t4, 4 + TilePixelPrep 24, $t5, 5 + TilePixelPrep 20, $t6, 6 + TilePixelPrep 16, $t7, 7 + TileEndCode + + +.global TileFlip + +TileFlip: + TileStartCode + TilePixelPrep 16, $t0, 0 + TilePixelPrep 20, $t1, 1 + TilePixelPrep 24, $t2, 2 + TilePixelPrep 28, $t3, 3 + TilePixelPrep 0, $t4, 4 + TilePixelPrep 4, $t5, 5 + TilePixelPrep 8, $t6, 6 + TilePixelPrep 12, $t7, 7 + TileEndCode + + +SingleColor: + lui $t9, %hi(HighCol) + lw $t9, %lo(HighCol)($t9) + andi $t0, $a1, 0xf + or $t0, $t0, $a2 + addu $a0, $t9 + sb $t0, 0($a0) + sb $t0, 1($a0) + sb $t0, 2($a0) + sb $t0, 3($a0) + sb $t0, 4($a0) + sb $t0, 5($a0) + sb $t0, 6($a0) + jr $ra + sb $t0, 7($a0) + +TileEmpty: + jr $ra + or $v0, $0, 1 # empty tile + +tile11111111: + lw $v1, %lo(HighCol)($v1) + or $t0, $t0, $a2 + addu $a0, $v1 + sb $t0, 0($a0) +tile11111110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile11111100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile11111000: + or $t3, $t3, $a2 + sb $t3, 3($a0) +tile11110000: + or $t4, $t4, $a2 + sb $t4, 4($a0) +tile11100000: + or $t5, $t5, $a2 + sb $t5, 5($a0) +tile11000000: + or $t6, $t6, $a2 + sb $t6, 6($a0) +tile10000000: + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11111101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11111011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile11111010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11111001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11110111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile11110110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile11110100: + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11110101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11110011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile11110010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11110001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11101111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile11101110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile11101100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile11101000: + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11101101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11101011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile11101010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11101001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11100111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile11100110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile11100100: + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11100101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11100011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile11100010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11100001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11011111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile11011110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile11011100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile11011000: + or $t3, $t3, $a2 + sb $t3, 3($a0) +tile11010000: + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11011101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11011011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile11011010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11011001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11010111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile11010110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile11010100: + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11010101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11010011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile11010010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11010001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11001111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile11001110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile11001100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile11001000: + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11001101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11001011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile11001010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11001001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11000111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile11000110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile11000100: + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11000101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11000011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile11000010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile11000001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t6, $t6, $a2 + sb $t6, 6($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10111111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10111110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile10111100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile10111000: + or $t3, $t3, $a2 + sb $t3, 3($a0) +tile10110000: + or $t4, $t4, $a2 + sb $t4, 4($a0) +tile10100000: + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10111101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10111011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10111010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10111001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10110111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10110110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile10110100: + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10110101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10110011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10110010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10110001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10101111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10101110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile10101100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile10101000: + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10101101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10101011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10101010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10101001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10100111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10100110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile10100100: + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10100101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10100011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10100010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10100001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10011111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10011110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile10011100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile10011000: + or $t3, $t3, $a2 + sb $t3, 3($a0) +tile10010000: + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10011101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10011011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10011010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10011001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10010111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10010110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile10010100: + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10010101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10010011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10010010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10010001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10001111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10001110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile10001100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile10001000: + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10001101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10001011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10001010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10001001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10000111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10000110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile10000100: + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10000101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10000011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile10000010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile10000001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t7, $t7, $a2 + jr $ra + sb $t7, 7($a0) +tile01111111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01111110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile01111100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile01111000: + or $t3, $t3, $a2 + sb $t3, 3($a0) +tile01110000: + or $t4, $t4, $a2 + sb $t4, 4($a0) +tile01100000: + or $t5, $t5, $a2 + sb $t5, 5($a0) +tile01000000: + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile00000000: +tile01111101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01111011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01111010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01111001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01110111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01110110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile01110100: + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01110101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01110011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01110010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01110001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01101111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01101110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile01101100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile01101000: + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01101101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01101011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01101010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01101001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01100111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01100110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile01100100: + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01100101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01100011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01100010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01100001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t5, $t5, $a2 + sb $t5, 5($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01011111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01011110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile01011100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile01011000: + or $t3, $t3, $a2 + sb $t3, 3($a0) +tile01010000: + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01011101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01011011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01011010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01011001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01010111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01010110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile01010100: + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01010101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01010011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01010010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01010001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01001111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01001110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile01001100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile01001000: + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01001101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01001011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01001010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01001001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01000111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01000110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile01000100: + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01000101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01000011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile01000010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile01000001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t6, $t6, $a2 + jr $ra + sb $t6, 6($a0) +tile00111111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00111110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile00111100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile00111000: + or $t3, $t3, $a2 + sb $t3, 3($a0) +tile00110000: + or $t4, $t4, $a2 + sb $t4, 4($a0) +tile00100000: + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00111101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00111011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00111010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00111001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00110111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00110110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile00110100: + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00110101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00110011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00110010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00110001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t4, $t4, $a2 + sb $t4, 4($a0) + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00101111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00101110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile00101100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile00101000: + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00101101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00101011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00101010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00101001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00100111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00100110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile00100100: + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00100101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00100011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00100010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00100001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t5, $t5, $a2 + jr $ra + sb $t5, 5($a0) +tile00011111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00011110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile00011100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile00011000: + or $t3, $t3, $a2 + sb $t3, 3($a0) +tile00010000: + or $t4, $t4, $a2 + jr $ra + sb $t4, 4($a0) +tile00011101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + jr $ra + sb $t4, 4($a0) +tile00011011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00011010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + jr $ra + sb $t4, 4($a0) +tile00011001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + sb $t3, 3($a0) + or $t4, $t4, $a2 + jr $ra + sb $t4, 4($a0) +tile00010111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00010110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile00010100: + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + jr $ra + sb $t4, 4($a0) +tile00010101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t4, $t4, $a2 + jr $ra + sb $t4, 4($a0) +tile00010011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00010010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t4, $t4, $a2 + jr $ra + sb $t4, 4($a0) +tile00010001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t4, $t4, $a2 + jr $ra + sb $t4, 4($a0) +tile00001111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00001110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile00001100: + or $t2, $t2, $a2 + sb $t2, 2($a0) +tile00001000: + or $t3, $t3, $a2 + jr $ra + sb $t3, 3($a0) +tile00001101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + sb $t2, 2($a0) + or $t3, $t3, $a2 + jr $ra + sb $t3, 3($a0) +tile00001011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00001010: + or $t1, $t1, $a2 + sb $t1, 1($a0) + or $t3, $t3, $a2 + jr $ra + sb $t3, 3($a0) +tile00001001: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t3, $t3, $a2 + jr $ra + sb $t3, 3($a0) +tile00000111: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00000110: + or $t1, $t1, $a2 + sb $t1, 1($a0) +tile00000100: + or $t2, $t2, $a2 + jr $ra + sb $t2, 2($a0) +tile00000101: + or $t0, $t0, $a2 + sb $t0, 0($a0) + or $t2, $t2, $a2 + jr $ra + sb $t2, 2($a0) +tile00000011: + or $t0, $t0, $a2 + sb $t0, 0($a0) +tile00000010: + or $t1, $t1, $a2 + jr $ra + sb $t1, 1($a0) +tile00000001: + or $t0, $t0, $a2 + jr $ra + sb $t0, 0($a0) + +.data +.align 4 + +TileTable: + .long 000000000000, tile00000001, tile00000010, tile00000011, tile00000100, tile00000101, tile00000110, tile00000111 + .long tile00001000, tile00001001, tile00001010, tile00001011, tile00001100, tile00001101, tile00001110, tile00001111 + .long tile00010000, tile00010001, tile00010010, tile00010011, tile00010100, tile00010101, tile00010110, tile00010111 + .long tile00011000, tile00011001, tile00011010, tile00011011, tile00011100, tile00011101, tile00011110, tile00011111 + .long tile00100000, tile00100001, tile00100010, tile00100011, tile00100100, tile00100101, tile00100110, tile00100111 + .long tile00101000, tile00101001, tile00101010, tile00101011, tile00101100, tile00101101, tile00101110, tile00101111 + .long tile00110000, tile00110001, tile00110010, tile00110011, tile00110100, tile00110101, tile00110110, tile00110111 + .long tile00111000, tile00111001, tile00111010, tile00111011, tile00111100, tile00111101, tile00111110, tile00111111 + .long tile01000000, tile01000001, tile01000010, tile01000011, tile01000100, tile01000101, tile01000110, tile01000111 + .long tile01001000, tile01001001, tile01001010, tile01001011, tile01001100, tile01001101, tile01001110, tile01001111 + .long tile01010000, tile01010001, tile01010010, tile01010011, tile01010100, tile01010101, tile01010110, tile01010111 + .long tile01011000, tile01011001, tile01011010, tile01011011, tile01011100, tile01011101, tile01011110, tile01011111 + .long tile01100000, tile01100001, tile01100010, tile01100011, tile01100100, tile01100101, tile01100110, tile01100111 + .long tile01101000, tile01101001, tile01101010, tile01101011, tile01101100, tile01101101, tile01101110, tile01101111 + .long tile01110000, tile01110001, tile01110010, tile01110011, tile01110100, tile01110101, tile01110110, tile01110111 + .long tile01111000, tile01111001, tile01111010, tile01111011, tile01111100, tile01111101, tile01111110, tile01111111 + .long tile10000000, tile10000001, tile10000010, tile10000011, tile10000100, tile10000101, tile10000110, tile10000111 + .long tile10001000, tile10001001, tile10001010, tile10001011, tile10001100, tile10001101, tile10001110, tile10001111 + .long tile10010000, tile10010001, tile10010010, tile10010011, tile10010100, tile10010101, tile10010110, tile10010111 + .long tile10011000, tile10011001, tile10011010, tile10011011, tile10011100, tile10011101, tile10011110, tile10011111 + .long tile10100000, tile10100001, tile10100010, tile10100011, tile10100100, tile10100101, tile10100110, tile10100111 + .long tile10101000, tile10101001, tile10101010, tile10101011, tile10101100, tile10101101, tile10101110, tile10101111 + .long tile10110000, tile10110001, tile10110010, tile10110011, tile10110100, tile10110101, tile10110110, tile10110111 + .long tile10111000, tile10111001, tile10111010, tile10111011, tile10111100, tile10111101, tile10111110, tile10111111 + .long tile11000000, tile11000001, tile11000010, tile11000011, tile11000100, tile11000101, tile11000110, tile11000111 + .long tile11001000, tile11001001, tile11001010, tile11001011, tile11001100, tile11001101, tile11001110, tile11001111 + .long tile11010000, tile11010001, tile11010010, tile11010011, tile11010100, tile11010101, tile11010110, tile11010111 + .long tile11011000, tile11011001, tile11011010, tile11011011, tile11011100, tile11011101, tile11011110, tile11011111 + .long tile11100000, tile11100001, tile11100010, tile11100011, tile11100100, tile11100101, tile11100110, tile11100111 + .long tile11101000, tile11101001, tile11101010, tile11101011, tile11101100, tile11101101, tile11101110, tile11101111 + .long tile11110000, tile11110001, tile11110010, tile11110011, tile11110100, tile11110101, tile11110110, tile11110111 + .long tile11111000, tile11111001, tile11111010, tile11111011, tile11111100, tile11111101, tile11111110, tile11111111 + +# vim:filetype=mips From 0fa9e859bfd2be1ab82b84370cf57afc59183df8 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 19 Feb 2016 00:10:31 +0100 Subject: [PATCH 062/124] Rename input descriptors label for MasterSystem Rename by adding 'Button' prefix for more clarity --- platform/libretro/libretro.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 75fdf90b..7c271388 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -482,7 +482,7 @@ void retro_set_environment(retro_environment_t cb) { "picodrive_sprlim", "No sprite limit; disabled|enabled" }, { "picodrive_ramcart", "MegaCD RAM cart; disabled|enabled" }, { "picodrive_region", "Region; Auto|Japan NTSC|Japan PAL|US|Europe" }, - { "picodrive_region_fps", "Region FPS; Auto|NTSC|PAL"}, + { "picodrive_region_fps", "Region FPS; Auto|NTSC|PAL" }, #ifdef DRC_SH2 { "picodrive_drc", "Dynamic recompilers; enabled|disabled" }, #endif @@ -889,17 +889,17 @@ bool retro_load_game(const struct retro_game_info *info) { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, - { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "1 Start" }, - { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "2" }, - { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Pause" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Button 1 Start" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Button 2" }, + { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Button Pause" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, - { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "1 Start" }, - { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "2" }, - { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Pause" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Button 1 Start" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Button 2" }, + { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Button Pause" }, { 0 }, }; From f9e77751fabfa0e73111ec28bcb2d864a918492a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 1 Mar 2016 22:31:33 +0100 Subject: [PATCH 063/124] Add GCW Zero target --- Makefile.libretro | 23 +++++++++++++++++++++++ platform/libpicofe | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index 1de11c65..1b6d25da 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -355,6 +355,29 @@ else ifneq (,$(findstring armv,$(platform))) endif ARCH = arm +# GCW0 +else ifeq ($(platform), gcw0) + TARGET := $(TARGET_NAME)_libretro.so + CC = /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc + AR = /opt/gcw0-toolchain/usr/bin/mipsel-linux-ar + SHARED := -shared -nostdlib + fpic := -fPIC + LIBM := + DONT_COMPILE_IN_ZLIB = 1 + CFLAGS += -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float + + asm_memory = 0 + asm_render = 0 + asm_ym2612 = 0 + asm_misc = 0 + asm_cdpico = 0 + asm_cdmemory = 0 + asm_mix = 0 + use_cyclone = 0 + use_fame = 1 + use_drz80 = 0 + use_cz80 = 1 + # Windows else TARGET := $(TARGET_NAME)_libretro.dll diff --git a/platform/libpicofe b/platform/libpicofe index 0415ebf1..21604a04 160000 --- a/platform/libpicofe +++ b/platform/libpicofe @@ -1 +1 @@ -Subproject commit 0415ebf191d0d277d1dfba1bebe6f051a5fc89a8 +Subproject commit 21604a047941b8fe81d381ede0371c75da964afd From c3e69f81d86410bce18d0335d2c879bda71285db Mon Sep 17 00:00:00 2001 From: David Skywalker Date: Fri, 11 Mar 2016 00:56:34 +0100 Subject: [PATCH 064/124] add primary megadrive memory access, allow get cheevos. --- platform/libretro/libretro.c | 70 ++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 22 deletions(-) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 7c271388..1260f483 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -983,38 +983,64 @@ unsigned retro_get_region(void) return Pico.m.pal ? RETRO_REGION_PAL : RETRO_REGION_NTSC; } -void *retro_get_memory_data(unsigned id) +void *retro_get_memory_data(unsigned type) { - if (id != RETRO_MEMORY_SAVE_RAM) - return NULL; + uint8_t* data; - if (PicoAHW & PAHW_MCD) - return Pico_mcd->bram; - else - return SRam.data; + switch(type) + { + case RETRO_MEMORY_SAVE_RAM: + if (PicoAHW & PAHW_MCD) + data = Pico_mcd->bram; + else + data = SRam.data; + break; + case RETRO_MEMORY_SYSTEM_RAM: + if (PicoAHW & PAHW_SMS) + data = Pico.vramb; + else + data = Pico.ram; + break; + default: + data = NULL; + break; + } + + return data; } -size_t retro_get_memory_size(unsigned id) +size_t retro_get_memory_size(unsigned type) { unsigned int i; int sum; + + switch(type) + { + case RETRO_MEMORY_SAVE_RAM: + if (PicoAHW & PAHW_MCD) + // bram + return 0x2000; - if (id != RETRO_MEMORY_SAVE_RAM) - return 0; + if (Pico.m.frame_count == 0) + return SRam.size; - if (PicoAHW & PAHW_MCD) - // bram - return 0x2000; + // if game doesn't write to sram, don't report it to + // libretro so that RA doesn't write out zeroed .srm + for (i = 0, sum = 0; i < SRam.size; i++) + sum |= SRam.data[i]; - if (Pico.m.frame_count == 0) - return SRam.size; - - // if game doesn't write to sram, don't report it to - // libretro so that RA doesn't write out zeroed .srm - for (i = 0, sum = 0; i < SRam.size; i++) - sum |= SRam.data[i]; - - return (sum != 0) ? SRam.size : 0; + return (sum != 0) ? SRam.size : 0; + + case RETRO_MEMORY_SYSTEM_RAM: + if (PicoAHW & PAHW_SMS) + return sizeof(Pico.vramb); + else + return sizeof(Pico.ram); + + default: + return 0; + } + } void retro_reset(void) From 646039c2bfec823063676d97a73d545a8cbc9290 Mon Sep 17 00:00:00 2001 From: Thomas Daley Date: Sat, 12 Mar 2016 15:12:55 -0600 Subject: [PATCH 065/124] Implement psp compiler flags --- Makefile.libretro | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index d380e2e8..0ec70d34 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -173,25 +173,26 @@ else ifeq ($(platform), psl1ght) # PSP else ifeq ($(platform), psp1) - TARGET := $(TARGET_NAME)_libretro_psp1.a - CC = psp-gcc$(EXE_EXT) - AR = psp-ar$(EXE_EXT) - CFLAGS += -G0 - STATIC_LINKING = 1 - NO_MMAP = 1 - DONT_COMPILE_IN_ZLIB = 1 + TARGET := $(TARGET_NAME)_libretro_psp1.a + CC = psp-gcc$(EXE_EXT) + AR = psp-ar$(EXE_EXT) + CFLAGS += -G0 -ftracer + CFLAGS += -DPSP -D_ASM_DRAW_C_AMIPS + STATIC_LINKING = 1 + NO_MMAP = 1 + DONT_COMPILE_IN_ZLIB = 1 - asm_memory = 0 - asm_render = 0 - asm_ym2612 = 0 - asm_misc = 0 - asm_cdpico = 0 - asm_cdmemory = 0 - asm_mix = 0 - use_cyclone = 0 - use_fame = 1 - use_drz80 = 0 - use_cz80 = 1 + asm_memory = 0 + asm_render = 1 + asm_ym2612 = 0 + asm_misc = 0 + asm_cdpico = 0 + asm_cdmemory = 0 + asm_mix = 0 + use_cyclone = 0 + use_fame = 1 + use_drz80 = 0 + use_cz80 = 1 OBJS +=platform/libretro/psp/draw_amips.o From e1360c668cd06a0625e180d7cc1baa31390e4f66 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 19 May 2016 22:54:26 +0200 Subject: [PATCH 066/124] Add a core option to choose between PAR, DAR and CRT aspect ratio The core option let you choose between 3 aspect ratios. PAR: Native resolution DAR: 4/3 CRT: Thinner than 4/3, I did some comparison with my old CRT TV. I did another change to take in account the 224 instead of 240 vertical resolution to fix the integer scale --- platform/libretro/libretro.c | 45 ++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 1260f483..581702c9 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -55,8 +55,14 @@ static retro_audio_sample_batch_t audio_batch_cb; #define VOUT_MAX_WIDTH 320 #define VOUT_MAX_HEIGHT 240 + +static const float VOUT_PAR = 0.0; +static const float VOUT_4_3 = (224.0f * (4.0f / 3.0f)); +static const float VOUT_CRT = (224.0f * 1.29911f); + static void *vout_buf; static int vout_width, vout_height, vout_offset; +static float user_vout_width = 0.0; #ifdef _MSC_VER static short sndBuffer[2*44100/50]; @@ -455,6 +461,11 @@ void emu_video_mode_change(int start_line, int line_count, int is_32cols) vout_height = line_count; vout_offset = vout_width * start_line; + + // Update the geometry + struct retro_system_av_info av_info; + retro_get_system_av_info(&av_info); + environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &av_info); } void emu_32x_startup(void) @@ -483,6 +494,7 @@ void retro_set_environment(retro_environment_t cb) { "picodrive_ramcart", "MegaCD RAM cart; disabled|enabled" }, { "picodrive_region", "Region; Auto|Japan NTSC|Japan PAL|US|Europe" }, { "picodrive_region_fps", "Region FPS; Auto|NTSC|PAL" }, + { "picodrive_aspect", "Core-provided aspect ratio; PAR|4/3|CRT" }, #ifdef DRC_SH2 { "picodrive_drc", "Dynamic recompilers; enabled|disabled" }, #endif @@ -523,11 +535,16 @@ void retro_get_system_av_info(struct retro_system_av_info *info) memset(info, 0, sizeof(*info)); info->timing.fps = Pico.m.pal ? 50 : 60; info->timing.sample_rate = 44100; - info->geometry.base_width = 320; + info->geometry.base_width = vout_width; info->geometry.base_height = vout_height; - info->geometry.max_width = VOUT_MAX_WIDTH; - info->geometry.max_height = VOUT_MAX_HEIGHT; - info->geometry.aspect_ratio = 4.0f / 3.0f; + info->geometry.max_width = vout_width; + info->geometry.max_height = vout_height; + + float common_width = vout_width; + if (user_vout_width != 0) + common_width = user_vout_width; + + info->geometry.aspect_ratio = common_width / vout_height; } /* savestates */ @@ -1152,6 +1169,26 @@ static void update_variables(void) PsndRerate(1); } + float old_user_vout_width = user_vout_width; + var.value = NULL; + var.key = "picodrive_aspect"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + if (strcmp(var.value, "4/3") == 0) + user_vout_width = VOUT_4_3; + else if (strcmp(var.value, "CRT") == 0) + user_vout_width = VOUT_CRT; + else + user_vout_width = VOUT_PAR; + } + + if (user_vout_width != old_user_vout_width) + { + // Update the geometry + struct retro_system_av_info av_info; + retro_get_system_av_info(&av_info); + environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &av_info); + } + #ifdef DRC_SH2 var.value = NULL; var.key = "picodrive_drc"; From d1dfc25952e27e5384a73ee32a4e16347a2218bb Mon Sep 17 00:00:00 2001 From: Jools Wills Date: Fri, 20 May 2016 14:15:54 +0100 Subject: [PATCH 067/124] Fixes undefined symbol: __aeabi_idiv for RPI target --- Makefile.libretro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index 0ec70d34..7edcc6fc 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -238,7 +238,7 @@ else ifeq ($(platform), raspberrypi) ARM_ASM = 1 TARGET := $(TARGET_NAME)_libretro.so - SHARED := -shared -nostdlib + SHARED := -shared fpic := -fPIC DONT_COMPILE_IN_ZLIB = 1 From 4346a841ff9ea69713d65ce95963f6d3ef3b15dc Mon Sep 17 00:00:00 2001 From: meepingsnesroms Date: Mon, 4 Jul 2016 09:55:54 -0700 Subject: [PATCH 068/124] Fix compiling with ndk r11 > --- jni/Android.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jni/Android.mk b/jni/Android.mk index a59144ac..60d6f7de 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -2,6 +2,9 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) +#fix stupid change in ndk r11 that breaks compiling even when the exe would run fine +LOCAL_DISABLE_FATAL_LINKER_WARNINGS := true + LOCAL_MODULE := retro R := ../ From f191d3f8342bea300bac450dcdd37adf86060640 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 7 Sep 2016 07:36:24 +0200 Subject: [PATCH 069/124] Add Emscripten dir and upload --- Makefile.libretro | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index 7edcc6fc..3ea2b118 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -107,7 +107,7 @@ endif # PS3 else ifeq ($(platform), ps3) - TARGET := $(TARGET_NAME)_libretro_ps3.a + 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 @@ -151,7 +151,7 @@ else ifeq ($(platform), sncps3) # Lightweight PS3 Homebrew SDK else ifeq ($(platform), psl1ght) - TARGET := $(TARGET_NAME)_libretro_psl1ght.a + 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 @@ -173,7 +173,7 @@ else ifeq ($(platform), psl1ght) # PSP else ifeq ($(platform), psp1) - TARGET := $(TARGET_NAME)_libretro_psp1.a + TARGET := $(TARGET_NAME)_libretro_$(platform).a CC = psp-gcc$(EXE_EXT) AR = psp-ar$(EXE_EXT) CFLAGS += -G0 -ftracer @@ -198,7 +198,7 @@ else ifeq ($(platform), psp1) # CTR (3DS) else ifeq ($(platform), ctr) - TARGET := $(TARGET_NAME)_libretro_ctr.a + TARGET := $(TARGET_NAME)_libretro_$(platform).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) @@ -259,7 +259,7 @@ else ifeq ($(platform), raspberrypi) # Vita else ifeq ($(platform), vita) - TARGET := $(TARGET_NAME)_libretro_vita.a + TARGET := $(TARGET_NAME)_libretro_$(platform).a CC = arm-vita-eabi-gcc$(EXE_EXT) AR = arm-vita-eabi-ar$(EXE_EXT) CFLAGS += -DVITA @@ -290,21 +290,21 @@ else ifeq ($(platform), xenon) # Nintendo Game Cube else ifeq ($(platform), ngc) - TARGET := $(TARGET_NAME)_libretro_ngc.a + 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 -DBLARGG_BIG_ENDIAN=1 -D__ppc__ # Nintendo Wii else ifeq ($(platform), wii) - TARGET := libretro_$(TARGET_NAME)_wii.a + 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 -DBLARGG_BIG_ENDIAN=1 -D__ppc__ # QNX else ifeq ($(platform), qnx) - TARGET := $(TARGET_NAME)_libretro_qnx.so + TARGET := $(TARGET_NAME)_libretro_$(platform).so fpic := -fPIC CC = qcc -Vgcc_ntoarmv7le CC_AS = $(CC) @@ -356,6 +356,13 @@ else ifneq (,$(findstring armv,$(platform))) endif ARCH = arm +# Emscripten +else ifeq ($(platform), emscripten) + TARGET := $(TARGET_NAME)_libretro_$(platform).bc + STATIC_LINKING = 1 + NO_MMAP = 1 + DONT_COMPILE_IN_ZLIB = 1 + # GCW0 else ifeq ($(platform), gcw0) TARGET := $(TARGET_NAME)_libretro.so From d6a897aa61fb13b435a7bc8798c7f7c78db1930c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 8 Sep 2016 10:43:22 +0200 Subject: [PATCH 070/124] (Emscripten) Target should work now --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7a4e1301..eb5dc0a0 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ TARGET ?= PicoDrive -CFLAGS += -Wall -ggdb -falign-functions=2 +CFLAGS += -Wall CFLAGS += -I. -DINLINE=inline ifndef DEBUG CFLAGS += -O2 -DNDEBUG -ffunction-sections @@ -13,6 +13,10 @@ endif #drc_debug = 7 #profile = 1 +ifneq ($(platform),emscripten) +CFLAGS += ggdb -falign-functions=2 +endif + all: config.mak target_ From a33a365d783c8a6a360de8668eeb86a26086c551 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 8 Sep 2016 12:18:09 +0200 Subject: [PATCH 071/124] Both ios and emscripten have problems with this - hide behind HAVE_GDB ifdef --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index eb5dc0a0..c7fbe9ed 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ endif #drc_debug = 7 #profile = 1 -ifneq ($(platform),emscripten) +ifeq ($(WANT_GDB),1) CFLAGS += ggdb -falign-functions=2 endif From 8289697e8da6f76975028d2a8e713d3924ab0f4e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 8 Sep 2016 12:51:52 +0200 Subject: [PATCH 072/124] (Emscripten) remove NO_MMAP --- Makefile.libretro | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index 3ea2b118..917c765f 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -360,7 +360,6 @@ else ifneq (,$(findstring armv,$(platform))) else ifeq ($(platform), emscripten) TARGET := $(TARGET_NAME)_libretro_$(platform).bc STATIC_LINKING = 1 - NO_MMAP = 1 DONT_COMPILE_IN_ZLIB = 1 # GCW0 From 937c7e5283809a100d4b504296576878d2016ea0 Mon Sep 17 00:00:00 2001 From: lentillog Date: Tue, 20 Sep 2016 11:18:27 -0700 Subject: [PATCH 073/124] (vita) Updated build to work on Vita --- Makefile.libretro | 13 ++++++++----- pico/cart.c | 4 +++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index 917c765f..9e20e247 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -263,23 +263,26 @@ else ifeq ($(platform), vita) CC = arm-vita-eabi-gcc$(EXE_EXT) AR = arm-vita-eabi-ar$(EXE_EXT) CFLAGS += -DVITA + CFLAGS += -mfloat-abi=hard -ffast-math -mword-relocations + CFLAGS += -marm -mfpu=neon -mcpu=cortex-a9 -march=armv7-a STATIC_LINKING = 1 NO_MMAP = 1 DONT_COMPILE_IN_ZLIB = 1 ARCH = arm - ARM_ASM = 1 asm_memory = 1 asm_render = 1 asm_ym2612 = 1 - asm_misc = 0 + asm_misc = 1 asm_cdpico = 0 asm_cdmemory = 0 - asm_mix = 0 - use_cyclone = 0 - use_fame = 1 + asm_mix = 1 + use_cyclone = 1 + use_fame = 0 use_drz80 = 1 use_cz80 = 0 + use_sh2drc = 0 + use_svpdrc = 0 # Xbox 360 else ifeq ($(platform), xenon) diff --git a/pico/cart.c b/pico/cart.c index d237fad9..3bab6158 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -332,7 +332,9 @@ int pm_seek(pm_file *stream, long offset, int whence) if (stream->type == PMT_UNCOMPRESSED) { fseek(stream->file, offset, whence); - return ftell(stream->file); + int ret = ftell(stream->file); + elprintf(EL_STATUS, "seeked ok."); //HACK for VITA + return ret; } #ifndef NO_ZLIB else if (stream->type == PMT_ZIP) From 30b234849f62e896b4dc8386d77ea72211d2775a Mon Sep 17 00:00:00 2001 From: lentillog Date: Tue, 20 Sep 2016 11:18:27 -0700 Subject: [PATCH 074/124] (VITA) Removed gross hack with optimization workaround This also seems to reduce a bit of stutter in some games (like sonic 3) --- Makefile.libretro | 2 +- pico/cart.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index 9e20e247..3b7c0fed 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -263,7 +263,7 @@ else ifeq ($(platform), vita) CC = arm-vita-eabi-gcc$(EXE_EXT) AR = arm-vita-eabi-ar$(EXE_EXT) CFLAGS += -DVITA - CFLAGS += -mfloat-abi=hard -ffast-math -mword-relocations + CFLAGS += -mfloat-abi=hard -ffast-math -mword-relocations -fno-optimize-sibling-calls CFLAGS += -marm -mfpu=neon -mcpu=cortex-a9 -march=armv7-a STATIC_LINKING = 1 NO_MMAP = 1 diff --git a/pico/cart.c b/pico/cart.c index 3bab6158..d237fad9 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -332,9 +332,7 @@ int pm_seek(pm_file *stream, long offset, int whence) if (stream->type == PMT_UNCOMPRESSED) { fseek(stream->file, offset, whence); - int ret = ftell(stream->file); - elprintf(EL_STATUS, "seeked ok."); //HACK for VITA - return ret; + return ftell(stream->file); } #ifndef NO_ZLIB else if (stream->type == PMT_ZIP) From 88f7643f70681d211c71a30d845592d48b1b9bea Mon Sep 17 00:00:00 2001 From: lentillog Date: Fri, 30 Sep 2016 23:44:49 -0700 Subject: [PATCH 075/124] (VITA) Dynarec working --- Makefile | 4 ++++ Makefile.libretro | 14 ++++++++------ cpu/drc/cmn.c | 10 ++++++++++ cpu/drc/cmn.h | 4 ++++ platform/libretro/libretro.c | 18 ++++++++++++++++-- 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index c7fbe9ed..9b364dd9 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,11 @@ TARGET ?= PicoDrive CFLAGS += -Wall CFLAGS += -I. -DINLINE=inline ifndef DEBUG +ifeq ($(platform), vita) +CFLAGS += -O3 -DNDEBUG +else CFLAGS += -O2 -DNDEBUG -ffunction-sections +endif ifneq ($(APPLE),1) LDFLAGS += -Wl,--gc-sections endif diff --git a/Makefile.libretro b/Makefile.libretro index 3b7c0fed..b2759d8e 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -263,8 +263,10 @@ else ifeq ($(platform), vita) CC = arm-vita-eabi-gcc$(EXE_EXT) AR = arm-vita-eabi-ar$(EXE_EXT) CFLAGS += -DVITA - CFLAGS += -mfloat-abi=hard -ffast-math -mword-relocations -fno-optimize-sibling-calls - CFLAGS += -marm -mfpu=neon -mcpu=cortex-a9 -march=armv7-a + CFLAGS += -marm -mfpu=neon -mcpu=cortex-a9 -march=armv7-a -mfloat-abi=hard -ffast-math + CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops + CFLAGS += -mword-relocations -fno-unwind-tables + CFLAGS += -fno-optimize-sibling-calls STATIC_LINKING = 1 NO_MMAP = 1 DONT_COMPILE_IN_ZLIB = 1 @@ -274,15 +276,15 @@ else ifeq ($(platform), vita) asm_render = 1 asm_ym2612 = 1 asm_misc = 1 - asm_cdpico = 0 - asm_cdmemory = 0 + asm_cdpico = 1 + asm_cdmemory = 1 asm_mix = 1 use_cyclone = 1 use_fame = 0 use_drz80 = 1 use_cz80 = 0 - use_sh2drc = 0 - use_svpdrc = 0 + use_sh2drc = 1 + use_svpdrc = 1 # Xbox 360 else ifeq ($(platform), xenon) diff --git a/cpu/drc/cmn.c b/cpu/drc/cmn.c index a07dcbdd..f788ecac 100644 --- a/cpu/drc/cmn.c +++ b/cpu/drc/cmn.c @@ -12,6 +12,11 @@ #ifdef _MSC_VER u8 tcache[DRC_TCACHE_SIZE]; +#elif defined(VITA) +#include +u8 *tcache; +static int sceBlock; +int getVMBlock(); #else u8 __attribute__((aligned(4096))) tcache[DRC_TCACHE_SIZE]; #endif @@ -19,6 +24,11 @@ u8 __attribute__((aligned(4096))) tcache[DRC_TCACHE_SIZE]; void drc_cmn_init(void) { +#ifdef VITA + sceBlock = getVMBlock(); + sceKernelGetMemBlockBase(sceBlock, (void **)&tcache); +#endif + int ret = plat_mem_set_exec(tcache, sizeof(tcache)); elprintf(EL_STATUS, "drc_cmn_init: %p, %zd bytes: %d", tcache, sizeof(tcache), ret); diff --git a/cpu/drc/cmn.h b/cpu/drc/cmn.h index 4737b74d..e6da6eac 100644 --- a/cpu/drc/cmn.h +++ b/cpu/drc/cmn.h @@ -5,7 +5,11 @@ typedef unsigned int u32; #define DRC_TCACHE_SIZE (2*1024*1024) +#ifdef VITA +extern u8 *tcache; +#else extern u8 tcache[DRC_TCACHE_SIZE]; +#endif void drc_cmn_init(void); void drc_cmn_cleanup(void); diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 581702c9..46363618 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -38,6 +38,15 @@ void* linearMemAlign(size_t size, size_t alignment); void linearFree(void* mem); static int ctr_svchack_successful = 0; + +#elif defined(VITA) +#define TARGET_SIZE_2 24 // 2^24 = 16 megabytes + +#include +static int sceBlock; +int getVMBlock(); +int _newlib_vm_size_user = 1 << TARGET_SIZE_2; + #endif #include @@ -83,14 +92,16 @@ static void snd_write(int len); void cache_flush_d_inval_i(void *start, void *end) { #ifdef __arm__ + size_t len = (char *)end - (char *)start; #if defined(__BLACKBERRY_QNX__) msync(start, end - start, MS_SYNC | MS_CACHE_ONLY | MS_INVALIDATE_ICACHE); #elif defined(__MACH__) - size_t len = (char *)end - (char *)start; sys_dcache_flush(start, len); sys_icache_invalidate(start, len); #elif defined(_3DS) ctr_flush_invalidate_cache(); +#elif defined(VITA) + sceKernelSyncVMDomain(sceBlock, start, len); #else __clear_cache(start, end); #endif @@ -444,7 +455,8 @@ int plat_mem_set_exec(void *ptr, size_t size) exit(1); } - +#elif defined(VITA) + int ret = sceKernelOpenVMDomain(); #else int ret = mprotect(ptr, size, PROT_READ | PROT_WRITE | PROT_EXEC); if (ret != 0 && log_cb) @@ -1251,6 +1263,8 @@ void retro_init(void) #ifdef _3DS ctr_svchack_successful = ctr_svchack_init(); +#elif defined(VITA) + sceBlock = getVMBlock(); #endif PicoOpt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 From 6d0aaeaf9036411ceb7aa68205549e246ea86a60 Mon Sep 17 00:00:00 2001 From: lentillog Date: Tue, 4 Oct 2016 18:02:52 -0700 Subject: [PATCH 076/124] Fixed crash on loading sram game after a game with no sram --- platform/libretro/libretro.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 46363618..5f326dac 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -877,6 +877,22 @@ static const char *find_bios(int *region, const char *cd_fname) return NULL; } +static void sram_reset() +{ + SRam.data = NULL; + SRam.start = 0; + SRam.end = 0; + SRam.flags = '\0'; + SRam.unused2 = '\0'; + SRam.changed = '\0' ; + SRam.eeprom_type = '\0'; + SRam.unused3 = '\0'; + SRam.eeprom_bit_cl = '\0'; + SRam.eeprom_bit_in = '\0'; + SRam.eeprom_bit_out = '\0'; + SRam.size = 0; +} + bool retro_load_game(const struct retro_game_info *info) { enum media_type_e media_type; @@ -933,6 +949,8 @@ bool retro_load_game(const struct retro_game_info *info) { 0 }, }; + sram_reset(); + enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) { if (log_cb) From e8454cb09b4e787ee847ba64936f79b3f08a4ea3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 15 Oct 2016 18:43:14 +0200 Subject: [PATCH 077/124] Add author name to libretro.c --- platform/libretro/libretro.c | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 5f326dac..b9b1414c 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -1,6 +1,7 @@ /* * libretro core glue for PicoDrive * (C) notaz, 2013 + * (C) Daniel De Matteis, 2013 * * This work is licensed under the terms of MAME license. * See COPYING file in the top-level directory. From 0d87bd6a48493afbaeefa67cb229a16cb6d60b25 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 15 Oct 2016 18:48:31 +0200 Subject: [PATCH 078/124] Add more copyrights --- cpu/drc/cmn.c | 2 ++ cpu/drc/emit_arm.c | 2 ++ platform/libretro/libretro.c | 1 + 3 files changed, 5 insertions(+) diff --git a/cpu/drc/cmn.c b/cpu/drc/cmn.c index f788ecac..721340a3 100644 --- a/cpu/drc/cmn.c +++ b/cpu/drc/cmn.c @@ -1,6 +1,8 @@ /* * PicoDrive * Copyright (C) 2009,2010 notaz + * Copyright (C) 2016 lentillog + * Copyright (C) 2016 Daniel De Matteis * * This work is licensed under the terms of MAME license. * See COPYING file in the top-level directory. diff --git a/cpu/drc/emit_arm.c b/cpu/drc/emit_arm.c index 64face12..26289a48 100644 --- a/cpu/drc/emit_arm.c +++ b/cpu/drc/emit_arm.c @@ -1,6 +1,8 @@ /* * Basic macros to emit ARM instructions and some utils * Copyright (C) 2008,2009,2010 notaz + * Copyright (C) 2016 lentillog + * Copyright (C) 2016 Daniel De Matteis * * This work is licensed under the terms of MAME license. * See COPYING file in the top-level directory. diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index b9b1414c..061f830d 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -1,6 +1,7 @@ /* * libretro core glue for PicoDrive * (C) notaz, 2013 + * (C) aliaspider, 2016 * (C) Daniel De Matteis, 2013 * * This work is licensed under the terms of MAME license. From 779d96d907ecbd5fce8a9b7c1a7f0cf172bc5c0d Mon Sep 17 00:00:00 2001 From: Christian Fetzer Date: Mon, 5 Dec 2016 23:12:44 +0100 Subject: [PATCH 079/124] Fix compilation with DEBUG flag - Use DEBUG flag similar to other libretro cores (DEBUG=0 disables, DEBUG=1 enables the debug build) - Optimize with -O2 for debugging because the core won't work otherwise - Always strip sections to prevent undefined symbol errors --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9b364dd9..a62d9b11 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,19 @@ TARGET ?= PicoDrive +DEBUG = 0 CFLAGS += -Wall CFLAGS += -I. -DINLINE=inline -ifndef DEBUG +ifeq ($(DEBUG),0) ifeq ($(platform), vita) CFLAGS += -O3 -DNDEBUG else CFLAGS += -O2 -DNDEBUG -ffunction-sections endif +else +CFLAGS += -g -O2 +endif ifneq ($(APPLE),1) LDFLAGS += -Wl,--gc-sections endif -endif #CFLAGS += -DEVT_LOG #CFLAGS += -DDRC_CMP #cpu_cmp = 1 From 4a7781cd376dce2640a12e707fe7b9ea7fde8681 Mon Sep 17 00:00:00 2001 From: orbea Date: Tue, 6 Dec 2016 00:02:23 -0800 Subject: [PATCH 080/124] Check if DEBUG is set rather than not set. --- Makefile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index a62d9b11..ca8ccf6e 100644 --- a/Makefile +++ b/Makefile @@ -2,18 +2,21 @@ TARGET ?= PicoDrive DEBUG = 0 CFLAGS += -Wall CFLAGS += -I. -DINLINE=inline -ifeq ($(DEBUG),0) -ifeq ($(platform), vita) -CFLAGS += -O3 -DNDEBUG + +ifeq ($(DEBUG),1) + CFLAGS += -g -O0 else -CFLAGS += -O2 -DNDEBUG -ffunction-sections -endif -else -CFLAGS += -g -O2 + ifeq ($(platform), vita) + CFLAGS += -O3 -DNDEBUG + else + CFLAGS += -O2 -DNDEBUG -ffunction-sections + endif endif + ifneq ($(APPLE),1) -LDFLAGS += -Wl,--gc-sections + LDFLAGS += -Wl,--gc-sections endif + #CFLAGS += -DEVT_LOG #CFLAGS += -DDRC_CMP #cpu_cmp = 1 @@ -24,7 +27,6 @@ ifeq ($(WANT_GDB),1) CFLAGS += ggdb -falign-functions=2 endif - all: config.mak target_ ifndef NO_CONFIG_MAK From dfa111b787b4a2e000adc85cdb2b13c776cede8e Mon Sep 17 00:00:00 2001 From: orbea Date: Tue, 6 Dec 2016 01:21:36 -0800 Subject: [PATCH 081/124] Fix the debug build and compile warnings. --- pico/sound/ym2612.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pico/sound/ym2612.c b/pico/sound/ym2612.c index 0fc6fa27..b06007b1 100644 --- a/pico/sound/ym2612.c +++ b/pico/sound/ym2612.c @@ -535,7 +535,7 @@ static int g_lfo_ampm = 0; /* OPN Mode Register Write */ -INLINE void set_timers( int v ) +static INLINE void set_timers( int v ) { /* b7 = CSM MODE */ /* b6 = 3 slot mode */ @@ -590,13 +590,13 @@ INLINE void set_det_mul(FM_CH *CH, FM_SLOT *SLOT, int v) } /* set total level */ -INLINE void set_tl(FM_SLOT *SLOT, int v) +static INLINE void set_tl(FM_SLOT *SLOT, int v) { SLOT->tl = (v&0x7f)<<(ENV_BITS-7); /* 7bit TL */ } /* set attack rate & key scale */ -INLINE void set_ar_ksr(FM_CH *CH, FM_SLOT *SLOT, int v) +static INLINE void set_ar_ksr(FM_CH *CH, FM_SLOT *SLOT, int v) { UINT8 old_KSR = SLOT->KSR; @@ -628,7 +628,7 @@ INLINE void set_ar_ksr(FM_CH *CH, FM_SLOT *SLOT, int v) } /* set decay rate */ -INLINE void set_dr(FM_SLOT *SLOT, int v) +static INLINE void set_dr(FM_SLOT *SLOT, int v) { int eg_sh_d1r, eg_sel_d1r; @@ -641,7 +641,7 @@ INLINE void set_dr(FM_SLOT *SLOT, int v) } /* set sustain rate */ -INLINE void set_sr(FM_SLOT *SLOT, int v) +static INLINE void set_sr(FM_SLOT *SLOT, int v) { int eg_sh_d2r, eg_sel_d2r; @@ -654,7 +654,7 @@ INLINE void set_sr(FM_SLOT *SLOT, int v) } /* set release rate */ -INLINE void set_sl_rr(FM_SLOT *SLOT, int v) +static INLINE void set_sl_rr(FM_SLOT *SLOT, int v) { int eg_sh_rr, eg_sel_rr; @@ -668,8 +668,6 @@ INLINE void set_sl_rr(FM_SLOT *SLOT, int v) SLOT->eg_pack_rr = eg_inc_pack[eg_sel_rr] | (eg_sh_rr<<24); } - - INLINE signed int op_calc(UINT32 phase, unsigned int env, signed int pm) { int ret, sin = (phase>>16) + (pm>>1); From a2135a7a4eed2b94ec83b82444daba384c61a3f5 Mon Sep 17 00:00:00 2001 From: orbea Date: Tue, 6 Dec 2016 10:58:06 -0800 Subject: [PATCH 082/124] Actually fix the debug build --- pico/sound/ym2612.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pico/sound/ym2612.c b/pico/sound/ym2612.c index b06007b1..ae53d042 100644 --- a/pico/sound/ym2612.c +++ b/pico/sound/ym2612.c @@ -582,7 +582,7 @@ INLINE void FM_KEYOFF(int c , int s ) /* set detune & multiple */ -INLINE void set_det_mul(FM_CH *CH, FM_SLOT *SLOT, int v) +static INLINE void set_det_mul(FM_CH *CH, FM_SLOT *SLOT, int v) { SLOT->mul = (v&0x0f)? (v&0x0f)*2 : 1; SLOT->DT = ym2612.OPN.ST.dt_tab[(v>>4)&7]; From dfe3ba924b5cbd8b2738bed91de42b19909a01f2 Mon Sep 17 00:00:00 2001 From: Christian Fetzer Date: Tue, 6 Dec 2016 20:51:07 +0100 Subject: [PATCH 083/124] Fix more undefined symbol errors --- pico/sound/ym2612.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pico/sound/ym2612.c b/pico/sound/ym2612.c index ae53d042..692f34ee 100644 --- a/pico/sound/ym2612.c +++ b/pico/sound/ym2612.c @@ -557,7 +557,7 @@ static INLINE void set_timers( int v ) } -INLINE void FM_KEYON(int c , int s ) +static INLINE void FM_KEYON(int c , int s ) { FM_SLOT *SLOT = &ym2612.CH[c].SLOT[s]; if( !SLOT->key ) @@ -569,7 +569,7 @@ INLINE void FM_KEYON(int c , int s ) } } -INLINE void FM_KEYOFF(int c , int s ) +static INLINE void FM_KEYOFF(int c , int s ) { FM_SLOT *SLOT = &ym2612.CH[c].SLOT[s]; if( SLOT->key ) @@ -668,7 +668,7 @@ static INLINE void set_sl_rr(FM_SLOT *SLOT, int v) SLOT->eg_pack_rr = eg_inc_pack[eg_sel_rr] | (eg_sh_rr<<24); } -INLINE signed int op_calc(UINT32 phase, unsigned int env, signed int pm) +static INLINE signed int op_calc(UINT32 phase, unsigned int env, signed int pm) { int ret, sin = (phase>>16) + (pm>>1); int neg = sin & 0x200; @@ -685,7 +685,7 @@ INLINE signed int op_calc(UINT32 phase, unsigned int env, signed int pm) return neg ? -ret : ret; } -INLINE signed int op_calc1(UINT32 phase, unsigned int env, signed int pm) +static INLINE signed int op_calc1(UINT32 phase, unsigned int env, signed int pm) { int ret, sin = (phase+pm)>>16; int neg = sin & 0x200; @@ -703,7 +703,7 @@ INLINE signed int op_calc1(UINT32 phase, unsigned int env, signed int pm) #if !defined(_ASM_YM2612_C) || defined(EXTERNAL_YM2612) /* advance LFO to next sample */ -INLINE int advance_lfo(int lfo_ampm, UINT32 lfo_cnt_old, UINT32 lfo_cnt) +static INLINE int advance_lfo(int lfo_ampm, UINT32 lfo_cnt_old, UINT32 lfo_cnt) { UINT8 pos; UINT8 prev_pos; From 2d4f989df99867149b8fe9a7f2d9a11799f469af Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Fri, 9 Dec 2016 18:50:07 -0500 Subject: [PATCH 084/124] Report git version with library_version --- Makefile.libretro | 4 ++++ jni/Android.mk | 5 +++++ platform/libretro/libretro.c | 5 ++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index b2759d8e..07da2660 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -25,6 +25,10 @@ CFLAGS ?= TARGET_NAME := picodrive LIBM := -lm +GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)" +ifneq ($(GIT_VERSION)," unknown") + CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" +endif asm_memory = 0 asm_render = 0 diff --git a/jni/Android.mk b/jni/Android.mk index 60d6f7de..f94aba2e 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -2,6 +2,11 @@ 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 + #fix stupid change in ndk r11 that breaks compiling even when the exe would run fine LOCAL_DISABLE_FATAL_LINKER_WARNINGS := true diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 061f830d..9588bc88 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -539,7 +539,10 @@ void retro_get_system_info(struct retro_system_info *info) { memset(info, 0, sizeof(*info)); info->library_name = "PicoDrive"; - info->library_version = VERSION; +#ifndef GIT_VERSION +#define GIT_VERSION "" +#endif + info->library_version = VERSION GIT_VERSION; info->valid_extensions = "bin|gen|smd|md|32x|cue|iso|sms"; info->need_fullpath = true; } From c98b37aaa3f75b7b787e7c0e5815e1c8138889cd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 22 Feb 2017 00:04:55 +0100 Subject: [PATCH 085/124] Add ios_static target --- Makefile.libretro | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Makefile.libretro b/Makefile.libretro index 07da2660..b2ccc415 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -109,6 +109,35 @@ endif use_sh2drc = 1 use_svpdrc = 1 +else ifneq (,$(findstring ios_static,$(platform))) + TARGET := $(TARGET_NAME)_libretro_ios.a + SHARED := -dynamiclib + fpic := -fPIC + APPLE := 1 + ifeq ($(IOSSDK),) + IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) + endif + CC = clang -arch armv7 -isysroot $(IOSSDK) + CXX = clang++ -arch armv7 -isysroot $(IOSSDK) + CC_AS = perl ./tools/gas-preprocessor.pl $(CC) + CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm + ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon + CFLAGS += -DIOS + + 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 + ARCH := arm + + STATIC_LINKING = 1 + use_cyclone = 0 + use_fame = 1 + use_drz80 = 0 + use_cz80 = 1 + use_sh2drc = 1 + use_svpdrc = 1 + # PS3 else ifeq ($(platform), ps3) TARGET := $(TARGET_NAME)_libretro_$(platform).a From 9795f2cd889e10510c9dc14ddf8198a0f45f8363 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 22 Feb 2017 00:11:27 +0100 Subject: [PATCH 086/124] Add staticios target (for iOS 8 and later) --- Makefile.libretro | 56 +++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index b2ccc415..d1a75029 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -73,6 +73,33 @@ else ifeq ($(platform), osx) OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"` SHARED += -mmacosx-version-min=10.1 +else ifeq ($(platform), staticios) + TARGET := $(TARGET_NAME)_libretro_ios.a + APPLE := 1 + ifeq ($(IOSSDK),) + IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) + endif + CC = clang -arch armv7 -isysroot $(IOSSDK) + CXX = clang++ -arch armv7 -isysroot $(IOSSDK) + CC_AS = perl ./tools/gas-preprocessor.pl $(CC) + CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm + ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon + CFLAGS += -DIOS + + 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 + ARCH := arm + + STATIC_LINKING = 1 + use_cyclone = 0 + use_fame = 1 + use_drz80 = 0 + use_cz80 = 1 + use_sh2drc = 1 + use_svpdrc = 1 + # iOS else ifneq (,$(findstring ios,$(platform))) TARGET := $(TARGET_NAME)_libretro_ios.dylib @@ -109,35 +136,6 @@ endif use_sh2drc = 1 use_svpdrc = 1 -else ifneq (,$(findstring ios_static,$(platform))) - TARGET := $(TARGET_NAME)_libretro_ios.a - SHARED := -dynamiclib - fpic := -fPIC - APPLE := 1 - ifeq ($(IOSSDK),) - IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) - endif - CC = clang -arch armv7 -isysroot $(IOSSDK) - CXX = clang++ -arch armv7 -isysroot $(IOSSDK) - CC_AS = perl ./tools/gas-preprocessor.pl $(CC) - CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm - ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon - CFLAGS += -DIOS - - 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 - ARCH := arm - - STATIC_LINKING = 1 - use_cyclone = 0 - use_fame = 1 - use_drz80 = 0 - use_cz80 = 1 - use_sh2drc = 1 - use_svpdrc = 1 - # PS3 else ifeq ($(platform), ps3) TARGET := $(TARGET_NAME)_libretro_$(platform).a From aa411429a7c71276f5e3fbe7500f5644211cbba7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 22 Feb 2017 00:29:29 +0100 Subject: [PATCH 087/124] staticios - we don't need SH2 DRC or SVP DRC for now --- Makefile.libretro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index d1a75029..ade5bc66 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -97,8 +97,8 @@ else ifeq ($(platform), staticios) use_fame = 1 use_drz80 = 0 use_cz80 = 1 - use_sh2drc = 1 - use_svpdrc = 1 + use_sh2drc = 0 + use_svpdrc = 0 # iOS else ifneq (,$(findstring ios,$(platform))) From 805d357076689f67010e35dbef938c4d102188f3 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 27 Feb 2017 01:04:44 +0100 Subject: [PATCH 088/124] Update staticios --- Makefile.libretro | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index ade5bc66..4d341341 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -79,11 +79,10 @@ else ifeq ($(platform), staticios) ifeq ($(IOSSDK),) IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) endif - CC = clang -arch armv7 -isysroot $(IOSSDK) - CXX = clang++ -arch armv7 -isysroot $(IOSSDK) + CC = clang -arch armv7 -arch arm64 -isysroot $(IOSSDK) + CXX = clang++ -arch armv7 -arch arm64 -isysroot $(IOSSDK) CC_AS = perl ./tools/gas-preprocessor.pl $(CC) - CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm - ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon + CFLAGS += -marm CFLAGS += -DIOS CC += -miphoneos-version-min=8.0 From f0a3d0dc4bd9060eb6bfdb16fb20dbb80a9e6ae9 Mon Sep 17 00:00:00 2001 From: hizzlekizzle Date: Wed, 8 Mar 2017 22:09:10 -0600 Subject: [PATCH 089/124] move emu_video_mode_change back to original spot nothing gained by moving it --- platform/libretro/libretro.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 9588bc88..332cf651 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -71,6 +71,8 @@ static const float VOUT_PAR = 0.0; static const float VOUT_4_3 = (224.0f * (4.0f / 3.0f)); static const float VOUT_CRT = (224.0f * 1.29911f); +bool show_overscan = false; + static void *vout_buf; static int vout_width, vout_height, vout_offset; static float user_vout_width = 0.0; @@ -472,6 +474,8 @@ void emu_video_mode_change(int start_line, int line_count, int is_32cols) memset(vout_buf, 0, 320 * 240 * 2); vout_width = is_32cols ? 256 : 320; PicoDrawSetOutBuf(vout_buf, vout_width * 2); + if (show_overscan == true) line_count += 16; + if (show_overscan == true) start_line -= 8; vout_height = line_count; vout_offset = vout_width * start_line; @@ -509,6 +513,7 @@ void retro_set_environment(retro_environment_t cb) { "picodrive_region", "Region; Auto|Japan NTSC|Japan PAL|US|Europe" }, { "picodrive_region_fps", "Region FPS; Auto|NTSC|PAL" }, { "picodrive_aspect", "Core-provided aspect ratio; PAR|4/3|CRT" }, + { "picodrive_overscan", "Show Overscan; disabled|enabled" }, #ifdef DRC_SH2 { "picodrive_drc", "Dynamic recompilers; enabled|disabled" }, #endif @@ -556,11 +561,11 @@ void retro_get_system_av_info(struct retro_system_av_info *info) info->geometry.base_height = vout_height; info->geometry.max_width = vout_width; info->geometry.max_height = vout_height; - + float common_width = vout_width; if (user_vout_width != 0) common_width = user_vout_width; - + info->geometry.aspect_ratio = common_width / vout_height; } @@ -1057,7 +1062,7 @@ void *retro_get_memory_data(unsigned type) data = NULL; break; } - + return data; } @@ -1065,7 +1070,7 @@ size_t retro_get_memory_size(unsigned type) { unsigned int i; int sum; - + switch(type) { case RETRO_MEMORY_SAVE_RAM: @@ -1082,17 +1087,17 @@ size_t retro_get_memory_size(unsigned type) sum |= SRam.data[i]; return (sum != 0) ? SRam.size : 0; - + case RETRO_MEMORY_SYSTEM_RAM: if (PicoAHW & PAHW_SMS) return sizeof(Pico.vramb); else return sizeof(Pico.ram); - + default: return 0; } - + } void retro_reset(void) @@ -1192,7 +1197,7 @@ static void update_variables(void) else if (strcmp(var.value, "NTSC") == 0) PicoRegionFPSOverride = 1; else if (strcmp(var.value, "PAL") == 0) - PicoRegionFPSOverride = 2; + PicoRegionFPSOverride = 2; } // Update region, fps and sound flags if needed @@ -1213,7 +1218,16 @@ static void update_variables(void) else if (strcmp(var.value, "CRT") == 0) user_vout_width = VOUT_CRT; else - user_vout_width = VOUT_PAR; + user_vout_width = VOUT_PAR; + } + + var.value = NULL; + var.key = "picodrive_overscan"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + if (strcmp(var.value, "enabled") == 0) + show_overscan = true; + else + show_overscan = false; } if (user_vout_width != old_user_vout_width) From 20563b60d0b9526c133289ca9c7b1ba255991916 Mon Sep 17 00:00:00 2001 From: iLag Date: Wed, 22 Mar 2017 14:19:35 -0700 Subject: [PATCH 090/124] Add support for single-line cheats and PAR codes. --- pico/patch.c | 14 +++++++-- platform/libretro/libretro.c | 59 +++++++++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/pico/patch.c b/pico/patch.c index b961e802..0240cb0d 100644 --- a/pico/patch.c +++ b/pico/patch.c @@ -142,7 +142,7 @@ static void hex_decode(const char *code, struct patch *result) /* THIS is the function you call from the MegaDrive or whatever. This figures * out whether it's a genie or hex code, depunctuates it, and calls the proper * decoder. */ -static void decode(const char* code, struct patch* result) +void decode(const char* code, struct patch* result) { int len = strlen(code), i, j; char code_to_pass[16], *x; @@ -299,6 +299,8 @@ void PicoPatchPrepare(void) PicoPatches[i].addr &= ~1; if (PicoPatches[i].addr < Pico.romsize) PicoPatches[i].data_old = *(unsigned short *)(Pico.rom + PicoPatches[i].addr); + else + PicoPatches[i].data_old = (unsigned short) m68k_read16(PicoPatches[i].addr); if (strstr(PicoPatches[i].name, "AUTO")) PicoPatches[i].active = 1; } @@ -328,7 +330,15 @@ void PicoPatchApply(void) } else { - /* TODO? */ + if (PicoPatches[i].active) + m68k_write16(PicoPatches[i].addr,PicoPatches[i].data); + else { + // if current addr is not patched by older patch, write back original val + for (u = 0; u < i; u++) + if (PicoPatches[u].addr == addr) break; + if (u == i) + m68k_write16(PicoPatches[i].addr,PicoPatches[i].data_old); + } } } } diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 332cf651..73733fdb 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -53,6 +53,7 @@ int _newlib_vm_size_user = 1 << TARGET_SIZE_2; #include #include +#include #include "../common/input_pico.h" #include "../common/version.h" #include "libretro.h" @@ -692,12 +693,67 @@ bool retro_unserialize(const void *data, size_t size) } /* cheats - TODO */ + void retro_cheat_reset(void) { + int i=0; + unsigned int addr; + + for (i = 0; i < PicoPatchCount; i++) + { + addr = PicoPatches[i].addr; + if (addr < Pico.romsize) + if (PicoPatches[i].active) + *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data_old; + else + if (PicoPatches[i].active) + m68k_write16(PicoPatches[i].addr,PicoPatches[i].data_old); + } + + PicoPatchUnload(); } -void retro_cheat_set(unsigned index, bool enabled, const char *code) +void retro_cheat_set(unsigned index, bool enabled, const char *buff) { + struct patch + { + unsigned int addr; + unsigned short data; + } pt; + int array_len = 0; + + //TODO: Split multi-line codes properly + + decode(buff, &pt); + if (pt.addr == (unsigned int)-1 || pt.data == (unsigned short)-1){ + log_cb(RETRO_LOG_ERROR,"CHEATS: Invalid code: %s\n",buff); + return; + } + + /* code was good, add it */ + if (array_len < PicoPatchCount + 1) + { + void *ptr; + array_len *= 2; + array_len++; + ptr = realloc(PicoPatches, array_len * sizeof(PicoPatches[0])); + if (ptr == NULL) { + log_cb(RETRO_LOG_ERROR,"CHEATS: Failed to allocate memory for: %s\n",buff); + return; + } + PicoPatches = ptr; + } + strcpy(PicoPatches[PicoPatchCount].code, buff); + + PicoPatches[PicoPatchCount].name[51] = ""; + PicoPatches[PicoPatchCount].active = enabled; + PicoPatches[PicoPatchCount].addr = pt.addr; + PicoPatches[PicoPatchCount].data = pt.data; + if (PicoPatches[PicoPatchCount].addr < Pico.romsize) + PicoPatches[PicoPatchCount].data_old = *(unsigned short *)(Pico.rom + PicoPatches[PicoPatchCount].addr); + else + PicoPatches[PicoPatchCount].data_old = (unsigned short) m68k_read16(PicoPatches[PicoPatchCount].addr); + PicoPatchCount++; } /* multidisk support */ @@ -1270,6 +1326,7 @@ void retro_run(void) if (input_state_cb(pad, RETRO_DEVICE_JOYPAD, 0, i)) PicoPad[pad] |= retro_pico_map[i]; + PicoPatchApply(); PicoFrame(); video_cb((short *)vout_buf + vout_offset, From 6cf45534d325cc4a2e93910e57f5f1eff7443a88 Mon Sep 17 00:00:00 2001 From: iLag Date: Wed, 22 Mar 2017 14:37:18 -0700 Subject: [PATCH 091/124] Support multiline codes --- platform/libretro/libretro.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 73733fdb..1b914d54 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -713,7 +713,7 @@ void retro_cheat_reset(void) PicoPatchUnload(); } -void retro_cheat_set(unsigned index, bool enabled, const char *buff) +void retro_cheat_set(unsigned index, bool enabled, const char *code) { struct patch { @@ -721,11 +721,16 @@ void retro_cheat_set(unsigned index, bool enabled, const char *buff) unsigned short data; } pt; int array_len = 0; + char *buff; //TODO: Split multi-line codes properly + buff = strtok(code,"+"); + while (buff) + { decode(buff, &pt); - if (pt.addr == (unsigned int)-1 || pt.data == (unsigned short)-1){ + if (pt.addr == (unsigned int)-1 || pt.data == (unsigned short)-1) + { log_cb(RETRO_LOG_ERROR,"CHEATS: Invalid code: %s\n",buff); return; } @@ -754,6 +759,7 @@ void retro_cheat_set(unsigned index, bool enabled, const char *buff) else PicoPatches[PicoPatchCount].data_old = (unsigned short) m68k_read16(PicoPatches[PicoPatchCount].addr); PicoPatchCount++; + } } /* multidisk support */ From d4089d9b8e132e796dca0382bd237b8efeeeac3d Mon Sep 17 00:00:00 2001 From: iLag Date: Wed, 22 Mar 2017 14:45:23 -0700 Subject: [PATCH 092/124] Fix multiline support --- platform/libretro/libretro.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 1b914d54..0f060e6b 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -722,11 +722,17 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code) } pt; int array_len = 0; char *buff; + bool multiline=0; //TODO: Split multi-line codes properly - buff = strtok(code,"+"); + if (strstr(code,"+")){ + multiline=1; + buff = strtok(code,"+"); + } else { + buff=code; + } - while (buff) + while (buff != NULL) { decode(buff, &pt); if (pt.addr == (unsigned int)-1 || pt.data == (unsigned short)-1) @@ -759,6 +765,9 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code) else PicoPatches[PicoPatchCount].data_old = (unsigned short) m68k_read16(PicoPatches[PicoPatchCount].addr); PicoPatchCount++; + + if (!multiline) + break; } } From daae6156b46bd32529d9c6908600409d036b6932 Mon Sep 17 00:00:00 2001 From: iLag Date: Wed, 22 Mar 2017 15:01:58 -0700 Subject: [PATCH 093/124] Fix variable types, silence warnings. --- pico/patch.c | 3 ++- platform/libretro/libretro.c | 36 +++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/pico/patch.c b/pico/patch.c index 0240cb0d..558658c3 100644 --- a/pico/patch.c +++ b/pico/patch.c @@ -211,7 +211,8 @@ bad_code: unsigned int PicoRead16(unsigned int a); void PicoWrite16(unsigned int a, unsigned short d); - +extern unsigned short m68k_read16(unsigned int a); +extern void m68k_write16(int a, unsigned short d); void PicoPatchUnload(void) { diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 0f060e6b..8e1bed35 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -692,7 +692,15 @@ bool retro_unserialize(const void *data, size_t size) return ret == 0; } -/* cheats - TODO */ +typedef struct patch +{ + unsigned int addr; + unsigned short data; +} patch; + +extern void decode(char *buff, patch *dest); +extern uint16_t m68k_read16(uint32_t a); +extern void m68k_write16(uint32_t a, uint16_t d); void retro_cheat_reset(void) { @@ -702,12 +710,13 @@ void retro_cheat_reset(void) for (i = 0; i < PicoPatchCount; i++) { addr = PicoPatches[i].addr; - if (addr < Pico.romsize) + if (addr < Pico.romsize) { if (PicoPatches[i].active) *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data_old; - else + } else { if (PicoPatches[i].active) m68k_write16(PicoPatches[i].addr,PicoPatches[i].data_old); + } } PicoPatchUnload(); @@ -715,27 +724,25 @@ void retro_cheat_reset(void) void retro_cheat_set(unsigned index, bool enabled, const char *code) { - struct patch - { - unsigned int addr; - unsigned short data; - } pt; + patch pt; int array_len = 0; + char codeCopy[256]; char *buff; bool multiline=0; - //TODO: Split multi-line codes properly + strcpy(codeCopy,code); + if (strstr(code,"+")){ multiline=1; - buff = strtok(code,"+"); + buff = strtok(codeCopy,"+"); } else { - buff=code; + buff=codeCopy; } while (buff != NULL) { decode(buff, &pt); - if (pt.addr == (unsigned int)-1 || pt.data == (unsigned short)-1) + if (pt.addr == (uint32_t) -1 || pt.data == (uint16_t) -1) { log_cb(RETRO_LOG_ERROR,"CHEATS: Invalid code: %s\n",buff); return; @@ -756,14 +763,13 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code) } strcpy(PicoPatches[PicoPatchCount].code, buff); - PicoPatches[PicoPatchCount].name[51] = ""; PicoPatches[PicoPatchCount].active = enabled; PicoPatches[PicoPatchCount].addr = pt.addr; PicoPatches[PicoPatchCount].data = pt.data; if (PicoPatches[PicoPatchCount].addr < Pico.romsize) - PicoPatches[PicoPatchCount].data_old = *(unsigned short *)(Pico.rom + PicoPatches[PicoPatchCount].addr); + PicoPatches[PicoPatchCount].data_old = *(uint16_t *)(Pico.rom + PicoPatches[PicoPatchCount].addr); else - PicoPatches[PicoPatchCount].data_old = (unsigned short) m68k_read16(PicoPatches[PicoPatchCount].addr); + PicoPatches[PicoPatchCount].data_old = (uint16_t) m68k_read16(PicoPatches[PicoPatchCount].addr); PicoPatchCount++; if (!multiline) From e5326b1a0e5fe59e95db275c52acffd4bd50e7da Mon Sep 17 00:00:00 2001 From: iLag Date: Thu, 23 Mar 2017 11:13:56 -0700 Subject: [PATCH 094/124] Fix memory management so the emulator won't crash with multiple cheats in a file. --- platform/libretro/libretro.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 8e1bed35..a4bc0a1b 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -725,7 +725,7 @@ void retro_cheat_reset(void) void retro_cheat_set(unsigned index, bool enabled, const char *code) { patch pt; - int array_len = 0; + int array_len = PicoPatchCount; char codeCopy[256]; char *buff; bool multiline=0; @@ -741,6 +741,7 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code) while (buff != NULL) { + log_cb(RETRO_LOG_INFO,"Buff: %s\n",buff); decode(buff, &pt); if (pt.addr == (uint32_t) -1 || pt.data == (uint16_t) -1) { @@ -774,6 +775,7 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code) if (!multiline) break; + buff = strtok(NULL,"+"); } } From cb5021471da11969696c474d922fdaac05e2eb83 Mon Sep 17 00:00:00 2001 From: iLag Date: Thu, 23 Mar 2017 11:16:37 -0700 Subject: [PATCH 095/124] Remove temporary debug print line --- platform/libretro/libretro.c | 1 - 1 file changed, 1 deletion(-) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index a4bc0a1b..f11b5dae 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -741,7 +741,6 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code) while (buff != NULL) { - log_cb(RETRO_LOG_INFO,"Buff: %s\n",buff); decode(buff, &pt); if (pt.addr == (uint32_t) -1 || pt.data == (uint16_t) -1) { From d8e4cc4967b01ab48b1ca93994ffa39f8707fad0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 24 Mar 2017 08:54:08 +0100 Subject: [PATCH 096/124] Cleanups --- Makefile.libretro | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index ade5bc66..9b681911 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -23,6 +23,7 @@ AS ?= as CC_AS ?= $(CC) CFLAGS ?= +STATIC_LINKING:= 0 TARGET_NAME := picodrive LIBM := -lm GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)" @@ -39,9 +40,15 @@ asm_cdmemory = 0 asm_mix = 0 fpic := + +ifeq ($(STATIC_LINKING),1) +EXT=a +endif + # Unix ifeq ($(platform), unix) - TARGET := $(TARGET_NAME)_libretro.so + EXT ?= so + TARGET := $(TARGET_NAME)_libretro.$(EXT) fpic := -fPIC SHARED := -shared DONT_COMPILE_IN_ZLIB = 1 @@ -49,7 +56,8 @@ ifeq ($(platform), unix) # Portable Linux else ifeq ($(platform), linux-portable) - TARGET := $(TARGET_NAME)_libretro.so + EXT ?= so + TARGET := $(TARGET_NAME)_libretro.$(EXT) SHARED := -shared -nostdlib fpic := -fPIC LIBM := @@ -58,7 +66,8 @@ else ifeq ($(platform), linux-portable) # OS X else ifeq ($(platform), osx) - TARGET := $(TARGET_NAME)_libretro.dylib + EXT ?= dylib + TARGET := $(TARGET_NAME)_libretro.$(EXT) SHARED := -dynamiclib fpic := -fPIC APPLE := 1 From fa55ee51c9c1d86311fbd90f055a575e4991ac70 Mon Sep 17 00:00:00 2001 From: iLag Date: Sat, 25 Mar 2017 19:29:00 -0700 Subject: [PATCH 097/124] Add support for Master System cheats. --- pico/memory.c | 4 +- pico/patch.c | 382 +++++++++++++++++++++++++---------- pico/patch.h | 1 + platform/libretro/libretro.c | 14 +- 4 files changed, 287 insertions(+), 114 deletions(-) diff --git a/pico/memory.c b/pico/memory.c index 4f38e5e2..e72628e6 100644 --- a/pico/memory.c +++ b/pico/memory.c @@ -459,7 +459,7 @@ static void PicoWrite16_sram(u32 a, u32 d) // z80 area (0xa00000 - 0xa0ffff) // TODO: verify mirrors VDP and bank reg (bank area mirroring verified) -static u32 PicoRead8_z80(u32 a) +u32 PicoRead8_z80(u32 a) { u32 d = 0xff; if ((Pico.m.z80Run & 1) || Pico.m.z80_reset) { @@ -483,7 +483,7 @@ static u32 PicoRead16_z80(u32 a) return d | (d << 8); } -static void PicoWrite8_z80(u32 a, u32 d) +void PicoWrite8_z80(u32 a, u32 d) { if ((Pico.m.z80Run & 1) || Pico.m.z80_reset) { // verified on real hw diff --git a/pico/patch.c b/pico/patch.c index 558658c3..f08b3707 100644 --- a/pico/patch.c +++ b/pico/patch.c @@ -28,12 +28,13 @@ struct patch { unsigned int addr; unsigned short data; + unsigned char comp; }; struct patch_inst *PicoPatches = NULL; int PicoPatchCount = 0; -static char genie_chars[] = "AaBbCcDdEeFfGgHhJjKkLlMmNnPpRrSsTtVvWwXxYyZz0O1I2233445566778899"; +static char genie_chars_md[] = "AaBbCcDdEeFfGgHhJjKkLlMmNnPpRrSsTtVvWwXxYyZz0O1I2233445566778899"; /* genie_decode * This function converts a Game Genie code to an address:data pair. @@ -47,20 +48,23 @@ static char genie_chars[] = "AaBbCcDdEeFfGgHhJjKkLlMmNnPpRrSsTtVvWwXxYyZz0O1I223 * by result. If an error results, both the address and data will be set to -1. */ -static void genie_decode(const char* code, struct patch* result) +static void genie_decode_md(const char* code, struct patch* result) { int i = 0, n; char* x; - for(; i < 8; ++i) + for(; i < 9; ++i) { + /* Skip i=4; it's going to be the separating hyphen */ + if (i==4) continue; + /* If strchr returns NULL, we were given a bad character */ - if(!(x = strchr(genie_chars, code[i]))) + if(!(x = strchr(genie_chars_md, code[i]))) { result->addr = -1; result->data = -1; return; } - n = (x - genie_chars) >> 1; + n = (x - genie_chars_md) >> 1; /* Now, based on which character this is, fit it into the result */ switch(i) { @@ -81,21 +85,21 @@ static void genie_decode(const char* code, struct patch* result) /* BCDE ____ ____ ___A ____ ____ : ____ ____ ____ ____ */ result->addr |= (n & 0xF) << 20 | (n >> 4) << 8; break; - case 4: + case 5: /* ____ ABCD ____ ____ ____ ____ : ___E ____ ____ ____ */ result->data |= (n & 1) << 12; result->addr |= (n >> 1) << 16; break; - case 5: + case 6: /* ____ ____ ____ ____ ____ ____ : E___ ABCD ____ ____ */ result->data |= (n & 1) << 15 | (n >> 1) << 8; break; - case 6: + case 7: /* ____ ____ ____ ____ CDE_ ____ : _AB_ ____ ____ ____ */ result->data |= (n >> 3) << 13; result->addr |= (n & 7) << 5; break; - case 7: + case 8: /* ____ ____ ____ ____ ___A BCDE : ____ ____ ____ ____ */ result->addr |= n; break; @@ -113,30 +117,165 @@ static void genie_decode(const char* code, struct patch* result) static char hex_chars[] = "00112233445566778899AaBbCcDdEeFf"; -static void hex_decode(const char *code, struct patch *result) +static void hex_decode_md(const char *code, struct patch *result) { char *x; int i; /* 6 digits for address */ for(i = 0; i < 6; ++i) + { + if(!(x = strchr(hex_chars, code[i]))) { - if(!(x = strchr(hex_chars, code[i]))) - { - result->addr = result->data = -1; - return; - } - result->addr = (result->addr << 4) | ((x - hex_chars) >> 1); + result->addr = result->data = -1; + return; } + result->addr = (result->addr << 4) | ((x - hex_chars) >> 1); + } /* 4 digits for data */ - for(i = 6; i < 10; ++i) + for(i = 7; i < 11; ++i) + { + if(!(x = strchr(hex_chars, code[i]))) { + if (i==8) break; + result->addr = result->data = -1; + return; + } + result->data = (result->data << 4) | ((x - hex_chars) >> 1); + } +} + +void genie_decode_ms(const char *code, struct patch *result) +{ + char *x; + int i; + /* 2 digits for data */ + for(i=0;i<2;++i) + { + if(!(x = strchr(hex_chars, code[i]))) + { + result->addr = result->data = -1; + return; + } + result->data = (result->data << 4) | ((x - hex_chars) >> 1); + } + /* 4 digits for address */ + for(i=2;i<7;++i) + { + /* 4th character is hyphen and can be skipped*/ + if (i==3) continue; + if(!(x = strchr(hex_chars, code[i]))) + { + result->addr = result->data = -1; + return; + } + result->addr = (result->addr << 4) | ((x - hex_chars) >> 1); + } + /* Correct the address */ + result->addr = ((result->addr >> 4) | (result->addr << 12 & 0xF000)) ^ 0xF000; + /* Optional: 3 digits for comp */ + if (code[8]){ + for(i=8;i<11;++i) + { + if (i==9) continue; /* 2nd character is ignored */ if(!(x = strchr(hex_chars, code[i]))) { result->addr = result->data = -1; return; } - result->data = (result->data << 4) | ((x - hex_chars) >> 1); + result->comp = (result->comp << 4) | ((x - hex_chars) >> 1); } + /* Correct the comp */ + result->comp = ((result->comp >> 2) | ((result->comp << 6) & 0xC0)) ^ 0xBA; + } +} + +void ar_decode_ms(const char *code, struct patch *result){ + char *x; + int i; + /* 2 digits of padding*/ + /* 4 digits for address */ + for(i=2;i<7;++i) + { + /* 5th character is hyphen and can be skipped*/ + if (i==4) continue; + if(!(x = strchr(hex_chars, code[i]))) + { + result->addr = result->data = -1; + return; + } + result->addr = (result->addr << 4) | ((x - hex_chars) >> 1); + } + /* 2 digits for data */ + for(i=7;i<9;++i) + { + if(!(x = strchr(hex_chars, code[i]))) + { + result->addr = result->data = -1; + return; + } + result->data = (result->data << 4) | ((x - hex_chars) >> 1); + } +} + +void fusion_ram_decode(const char *code, struct patch *result){ + char *x; + int i; + /* 4 digits for address */ + for(i=0;i<4;++i) + { + if(!(x = strchr(hex_chars, code[i]))) + { + result->addr = result->data = -1; + return; + } + result->addr = (result->addr << 4) | ((x - hex_chars) >> 1); + } + /* Skip the ':' */ + /* 2 digits for data */ + for(i=5;i<7;++i) + { + if(!(x = strchr(hex_chars, code[i]))) + { + result->addr = result->data = -1; + return; + } + result->data = (result->data << 4) | ((x - hex_chars) >> 1); + } +} + +void fusion_rom_decode(const char *code, struct patch *result){ + char *x; + int i; + /* 2 digits for comp */ + for(i=0;i<2;++i) + { + if(!(x = strchr(hex_chars, code[i]))) + { + result->addr = result->data = -1; + return; + } + result->comp = (result->comp << 4) | ((x - hex_chars) >> 1); + } + /* 4 digits for address */ + for(i=2;i<6;++i) + { + if(!(x = strchr(hex_chars, code[i]))) + { + result->addr = result->data = -1; + return; + } + result->addr = (result->addr << 4) | ((x - hex_chars) >> 1); + } + /* 2 digits for data */ + for(i=7;i<9;++i) + { + if(!(x = strchr(hex_chars, code[i]))) + { + result->addr = result->data = -1; + return; + } + result->data = (result->data << 4) | ((x - hex_chars) >> 1); + } } /* THIS is the function you call from the MegaDrive or whatever. This figures @@ -144,65 +283,72 @@ static void hex_decode(const char *code, struct patch *result) * decoder. */ void decode(const char* code, struct patch* result) { - int len = strlen(code), i, j; - char code_to_pass[16], *x; - const char *ad, *da; - int adl, dal; + int len = strlen(code); /* Initialize the result */ - result->addr = result->data = 0; + result->addr = result->data = result->comp = 0; - /* Just assume 8 char long string to be Game Genie code */ - if (len == 8) + if(!(PicoAHW & PAHW_SMS)) { - genie_decode(code, result); - return; - } + //If Genesis - /* If it's 9 chars long and the 5th is a hyphen, we have a Game Genie - * code. */ + //Game Genie if(len == 9 && code[4] == '-') { - /* Remove the hyphen and pass to genie_decode */ - code_to_pass[0] = code[0]; - code_to_pass[1] = code[1]; - code_to_pass[2] = code[2]; - code_to_pass[3] = code[3]; - code_to_pass[4] = code[5]; - code_to_pass[5] = code[6]; - code_to_pass[6] = code[7]; - code_to_pass[7] = code[8]; - code_to_pass[8] = '\0'; - genie_decode(code_to_pass, result); + genie_decode_md(code, result); return; } - /* Otherwise, we assume it's a hex code. - * Find the colon so we know where address ends and data starts. If there's - * no colon, then we haven't a code at all! */ - if(!(x = strchr(code, ':'))) goto bad_code; - ad = code; da = x + 1; adl = x - code; dal = len - adl - 1; + //Master + else if(len >=9 && code[6] == ':') + { + hex_decode_md(code, result); + } - /* If a section is empty or too long, toss it */ - if(adl == 0 || adl > 6 || dal == 0 || dal > 4) goto bad_code; + else + { + goto bad_code; + } + } else { + //If Master System - /* Pad the address with zeros, then fill it with the value */ - for(i = 0; i < (6 - adl); ++i) code_to_pass[i] = '0'; - for(j = 0; i < 6; ++i, ++j) code_to_pass[i] = ad[j]; + //Genie + if(len == 11 && code[3] == '-' && code[7] == '-') + { + genie_decode_ms(code, result); + } - /* Do the same for data */ - for(i = 6; i < (10 - dal); ++i) code_to_pass[i] = '0'; - for(j = 0; i < 10; ++i, ++j) code_to_pass[i] = da[j]; + //AR + else if(len == 9 && code[4] == '-') + { + ar_decode_ms(code, result); + } - code_to_pass[10] = '\0'; + //Fusion RAM + else if(len == 7 && code[4] == ':') + { + fusion_ram_decode(code, result); + } + + //Fusion ROM + else if(len == 9 && code[6] == ':') + { + fusion_rom_decode(code, result); + } + + else + { + goto bad_code; + } + + //Convert RAM address space to Genesis location. + if (result->addr>=0xC000) + result->addr= 0xFF0000 | (0x1FFF & result->addr); + } - /* Decode and goodbye */ - hex_decode(code_to_pass, result); return; -bad_code: - - /* AGH! Invalid code! */ + bad_code: result->data = result->addr = -1; return; } @@ -212,7 +358,9 @@ bad_code: unsigned int PicoRead16(unsigned int a); void PicoWrite16(unsigned int a, unsigned short d); extern unsigned short m68k_read16(unsigned int a); -extern void m68k_write16(int a, unsigned short d); +extern void m68k_write16(unsigned int a, unsigned short d); +extern char PicoRead8_z80(unsigned short a); +extern void PicoWrite8_z80(unsigned short a, char d); void PicoPatchUnload(void) { @@ -293,54 +441,84 @@ int PicoPatchLoad(const char *fname) /* to be called when the Rom is loaded and byteswapped */ void PicoPatchPrepare(void) { - int i; + int i; + int addr; - for (i = 0; i < PicoPatchCount; i++) - { - PicoPatches[i].addr &= ~1; - if (PicoPatches[i].addr < Pico.romsize) - PicoPatches[i].data_old = *(unsigned short *)(Pico.rom + PicoPatches[i].addr); - else - PicoPatches[i].data_old = (unsigned short) m68k_read16(PicoPatches[i].addr); - if (strstr(PicoPatches[i].name, "AUTO")) - PicoPatches[i].active = 1; - } + for (i = 0; i < PicoPatchCount; i++) + { + addr=PicoPatches[i].addr; + addr &= ~1; + if (addr < Pico.romsize) + PicoPatches[i].data_old = *(unsigned short *)(Pico.rom + addr); + else + { + if(!(PicoAHW & PAHW_SMS)) + PicoPatches[i].data_old = (unsigned short) m68k_read16(addr); + else + PicoPatches[i].data_old = (unsigned char) PicoRead8_z80(addr); + } + if (strstr(PicoPatches[i].name, "AUTO")) + PicoPatches[i].active = 1; + } } void PicoPatchApply(void) { - int i, u; - unsigned int addr; + int i, u; + unsigned int addr; - for (i = 0; i < PicoPatchCount; i++) + for (i = 0; i < PicoPatchCount; i++) + { + addr = PicoPatches[i].addr; + + if (addr < Pico.romsize) + { + if (PicoPatches[i].active) + { + if (!(PicoAHW & PAHW_SMS)) + *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data; + else if (!PicoPatches[i].comp || PicoPatches[i].comp == *(char *)(Pico.rom + addr)) + *(char *)(Pico.rom + addr) = (char) PicoPatches[i].data; + } + else + { + // if current addr is not patched by older patch, write back original val + for (u = 0; u < i; u++) + if (PicoPatches[u].addr == addr) break; + if (u == i) { - addr = PicoPatches[i].addr; - if (addr < Pico.romsize) - { - if (PicoPatches[i].active) - *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data; - else { - // if current addr is not patched by older patch, write back original val - for (u = 0; u < i; u++) - if (PicoPatches[u].addr == addr) break; - if (u == i) - *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data_old; - } - // fprintf(stderr, "patched %i: %06x:%04x\n", PicoPatches[i].active, addr, - // *(unsigned short *)(Pico.rom + addr)); - } - else - { - if (PicoPatches[i].active) - m68k_write16(PicoPatches[i].addr,PicoPatches[i].data); - else { - // if current addr is not patched by older patch, write back original val - for (u = 0; u < i; u++) - if (PicoPatches[u].addr == addr) break; - if (u == i) - m68k_write16(PicoPatches[i].addr,PicoPatches[i].data_old); - } - } + if (!(PicoAHW & PAHW_SMS)) + *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data_old; + else + *(char *)(Pico.rom + addr) = (char) PicoPatches[i].data_old; } + } + // fprintf(stderr, "patched %i: %06x:%04x\n", PicoPatches[i].active, addr, + // *(unsigned short *)(Pico.rom + addr)); + } + else + { + if (PicoPatches[i].active) + { + if (!(PicoAHW & PAHW_SMS)) + m68k_write16(addr,PicoPatches[i].data); + else + PicoWrite8_z80(addr,PicoPatches[i].data); + } + else + { + // if current addr is not patched by older patch, write back original val + for (u = 0; u < i; u++) + if (PicoPatches[u].addr == addr) break; + if (u == i) + { + if (!(PicoAHW & PAHW_SMS)) + m68k_write16(PicoPatches[i].addr,PicoPatches[i].data_old); + else + PicoWrite8_z80(PicoPatches[i].addr,PicoPatches[i].data_old); + } + } + } + } } diff --git a/pico/patch.h b/pico/patch.h index 6e9420f8..9ab86d36 100644 --- a/pico/patch.h +++ b/pico/patch.h @@ -13,6 +13,7 @@ struct patch_inst unsigned int addr; unsigned short data; unsigned short data_old; + unsigned char comp; }; extern struct patch_inst *PicoPatches; diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index f11b5dae..a1cf22c8 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -696,6 +696,7 @@ typedef struct patch { unsigned int addr; unsigned short data; + unsigned char comp; } patch; extern void decode(char *buff, patch *dest); @@ -728,16 +729,10 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code) int array_len = PicoPatchCount; char codeCopy[256]; char *buff; - bool multiline=0; + if (code=='\0') return; strcpy(codeCopy,code); - - if (strstr(code,"+")){ - multiline=1; - buff = strtok(codeCopy,"+"); - } else { - buff=codeCopy; - } + buff = strtok(codeCopy,"+"); while (buff != NULL) { @@ -766,14 +761,13 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code) PicoPatches[PicoPatchCount].active = enabled; PicoPatches[PicoPatchCount].addr = pt.addr; PicoPatches[PicoPatchCount].data = pt.data; + PicoPatches[PicoPatchCount].comp = pt.comp; if (PicoPatches[PicoPatchCount].addr < Pico.romsize) PicoPatches[PicoPatchCount].data_old = *(uint16_t *)(Pico.rom + PicoPatches[PicoPatchCount].addr); else PicoPatches[PicoPatchCount].data_old = (uint16_t) m68k_read16(PicoPatches[PicoPatchCount].addr); PicoPatchCount++; - if (!multiline) - break; buff = strtok(NULL,"+"); } } From ba47d3dfe32f968db6f062d8524354310c3f3de1 Mon Sep 17 00:00:00 2001 From: iLag Date: Sat, 25 Mar 2017 19:35:36 -0700 Subject: [PATCH 098/124] Restore support for short GG cheats. --- pico/patch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pico/patch.c b/pico/patch.c index f08b3707..fa425266 100644 --- a/pico/patch.c +++ b/pico/patch.c @@ -173,7 +173,7 @@ void genie_decode_ms(const char *code, struct patch *result) /* Correct the address */ result->addr = ((result->addr >> 4) | (result->addr << 12 & 0xF000)) ^ 0xF000; /* Optional: 3 digits for comp */ - if (code[8]){ + if (code[8]=='-'){ for(i=8;i<11;++i) { if (i==9) continue; /* 2nd character is ignored */ @@ -313,7 +313,7 @@ void decode(const char* code, struct patch* result) //If Master System //Genie - if(len == 11 && code[3] == '-' && code[7] == '-') + if(len >= 7 && code[3] == '-') { genie_decode_ms(code, result); } From 5c4adfbaec6c6950797479d5e5a8c4736179e2d5 Mon Sep 17 00:00:00 2001 From: iLag Date: Sat, 25 Mar 2017 20:28:08 -0700 Subject: [PATCH 099/124] Fix remaining bugs and fix indentation --- pico/patch.c | 263 ++++++++++++++++++++++++++------------------------- 1 file changed, 132 insertions(+), 131 deletions(-) diff --git a/pico/patch.c b/pico/patch.c index fa425266..d2bbec4b 100644 --- a/pico/patch.c +++ b/pico/patch.c @@ -26,9 +26,9 @@ struct patch { - unsigned int addr; - unsigned short data; - unsigned char comp; + unsigned int addr; + unsigned short data; + unsigned char comp; }; struct patch_inst *PicoPatches = NULL; @@ -173,14 +173,15 @@ void genie_decode_ms(const char *code, struct patch *result) /* Correct the address */ result->addr = ((result->addr >> 4) | (result->addr << 12 & 0xF000)) ^ 0xF000; /* Optional: 3 digits for comp */ - if (code[8]=='-'){ + printf("CHEAT: code[8]==%c\n",code[8]); + if (code[7]=='-'){ for(i=8;i<11;++i) { if (i==9) continue; /* 2nd character is ignored */ if(!(x = strchr(hex_chars, code[i]))) { - result->addr = result->data = -1; - return; + result->addr = result->data = -1; + return; } result->comp = (result->comp << 4) | ((x - hex_chars) >> 1); } @@ -364,161 +365,161 @@ extern void PicoWrite8_z80(unsigned short a, char d); void PicoPatchUnload(void) { - if (PicoPatches != NULL) - { - free(PicoPatches); - PicoPatches = NULL; - } - PicoPatchCount = 0; + if (PicoPatches != NULL) + { + free(PicoPatches); + PicoPatches = NULL; + } + PicoPatchCount = 0; } int PicoPatchLoad(const char *fname) { - FILE *f; - char buff[256]; - struct patch pt; - int array_len = 0; + FILE *f; + char buff[256]; + struct patch pt; + int array_len = 0; - PicoPatchUnload(); + PicoPatchUnload(); - f = fopen(fname, "r"); - if (f == NULL) - { - return -1; - } + f = fopen(fname, "r"); + if (f == NULL) + { + return -1; + } - while (fgets(buff, sizeof(buff), f)) - { - int llen, clen; + while (fgets(buff, sizeof(buff), f)) + { + int llen, clen; - llen = strlen(buff); - for (clen = 0; clen < llen; clen++) - if (isspace_(buff[clen])) - break; - buff[clen] = 0; + llen = strlen(buff); + for (clen = 0; clen < llen; clen++) + if (isspace_(buff[clen])) + break; + buff[clen] = 0; - if (clen > 11 || clen < 8) - continue; + if (clen > 11 || clen < 8) + continue; - decode(buff, &pt); - if (pt.addr == (unsigned int)-1 || pt.data == (unsigned short)-1) - continue; + decode(buff, &pt); + if (pt.addr == (unsigned int)-1 || pt.data == (unsigned short)-1) + continue; - /* code was good, add it */ - if (array_len < PicoPatchCount + 1) - { - void *ptr; - array_len *= 2; - array_len++; - ptr = realloc(PicoPatches, array_len * sizeof(PicoPatches[0])); - if (ptr == NULL) break; - PicoPatches = ptr; - } - strcpy(PicoPatches[PicoPatchCount].code, buff); - /* strip */ - for (clen++; clen < llen; clen++) - if (!isspace_(buff[clen])) - break; - for (llen--; llen > 0; llen--) - if (!isspace_(buff[llen])) - break; - buff[llen+1] = 0; - strncpy(PicoPatches[PicoPatchCount].name, buff + clen, 51); - PicoPatches[PicoPatchCount].name[51] = 0; - PicoPatches[PicoPatchCount].active = 0; - PicoPatches[PicoPatchCount].addr = pt.addr; - PicoPatches[PicoPatchCount].data = pt.data; - PicoPatches[PicoPatchCount].data_old = 0; - PicoPatchCount++; - // fprintf(stderr, "loaded patch #%i: %06x:%04x \"%s\"\n", PicoPatchCount-1, pt.addr, pt.data, - // PicoPatches[PicoPatchCount-1].name); - } - fclose(f); + /* code was good, add it */ + if (array_len < PicoPatchCount + 1) + { + void *ptr; + array_len *= 2; + array_len++; + ptr = realloc(PicoPatches, array_len * sizeof(PicoPatches[0])); + if (ptr == NULL) break; + PicoPatches = ptr; + } + strcpy(PicoPatches[PicoPatchCount].code, buff); + /* strip */ + for (clen++; clen < llen; clen++) + if (!isspace_(buff[clen])) + break; + for (llen--; llen > 0; llen--) + if (!isspace_(buff[llen])) + break; + buff[llen+1] = 0; + strncpy(PicoPatches[PicoPatchCount].name, buff + clen, 51); + PicoPatches[PicoPatchCount].name[51] = 0; + PicoPatches[PicoPatchCount].active = 0; + PicoPatches[PicoPatchCount].addr = pt.addr; + PicoPatches[PicoPatchCount].data = pt.data; + PicoPatches[PicoPatchCount].data_old = 0; + PicoPatchCount++; + // fprintf(stderr, "loaded patch #%i: %06x:%04x \"%s\"\n", PicoPatchCount-1, pt.addr, pt.data, + // PicoPatches[PicoPatchCount-1].name); + } + fclose(f); - return 0; + return 0; } /* to be called when the Rom is loaded and byteswapped */ void PicoPatchPrepare(void) { - int i; - int addr; + int i; + int addr; - for (i = 0; i < PicoPatchCount; i++) - { - addr=PicoPatches[i].addr; - addr &= ~1; - if (addr < Pico.romsize) - PicoPatches[i].data_old = *(unsigned short *)(Pico.rom + addr); - else - { - if(!(PicoAHW & PAHW_SMS)) - PicoPatches[i].data_old = (unsigned short) m68k_read16(addr); + for (i = 0; i < PicoPatchCount; i++) + { + addr=PicoPatches[i].addr; + addr &= ~1; + if (addr < Pico.romsize) + PicoPatches[i].data_old = *(unsigned short *)(Pico.rom + addr); else - PicoPatches[i].data_old = (unsigned char) PicoRead8_z80(addr); - } - if (strstr(PicoPatches[i].name, "AUTO")) - PicoPatches[i].active = 1; - } + { + if(!(PicoAHW & PAHW_SMS)) + PicoPatches[i].data_old = (unsigned short) m68k_read16(addr); + else + PicoPatches[i].data_old = (unsigned char) PicoRead8_z80(addr); + } + if (strstr(PicoPatches[i].name, "AUTO")) + PicoPatches[i].active = 1; + } } void PicoPatchApply(void) { - int i, u; - unsigned int addr; + int i, u; + unsigned int addr; - for (i = 0; i < PicoPatchCount; i++) - { - addr = PicoPatches[i].addr; + for (i = 0; i < PicoPatchCount; i++) + { + addr = PicoPatches[i].addr; - if (addr < Pico.romsize) - { - if (PicoPatches[i].active) + if (addr < Pico.romsize) { - if (!(PicoAHW & PAHW_SMS)) - *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data; - else if (!PicoPatches[i].comp || PicoPatches[i].comp == *(char *)(Pico.rom + addr)) - *(char *)(Pico.rom + addr) = (char) PicoPatches[i].data; - } - else - { - // if current addr is not patched by older patch, write back original val - for (u = 0; u < i; u++) - if (PicoPatches[u].addr == addr) break; - if (u == i) - { - if (!(PicoAHW & PAHW_SMS)) - *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data_old; - else - *(char *)(Pico.rom + addr) = (char) PicoPatches[i].data_old; - } - } + if (PicoPatches[i].active) + { + if (!(PicoAHW & PAHW_SMS)) + *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data; + else if (!PicoPatches[i].comp || PicoPatches[i].comp == *(char *)(Pico.rom + addr)) + *(char *)(Pico.rom + addr) = (char) PicoPatches[i].data; + } + else + { + // if current addr is not patched by older patch, write back original val + for (u = 0; u < i; u++) + if (PicoPatches[u].addr == addr) break; + if (u == i) + { + if (!(PicoAHW & PAHW_SMS)) + *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data_old; + else + *(char *)(Pico.rom + addr) = (char) PicoPatches[i].data_old; + } + } // fprintf(stderr, "patched %i: %06x:%04x\n", PicoPatches[i].active, addr, - // *(unsigned short *)(Pico.rom + addr)); - } - else - { - if (PicoPatches[i].active) - { - if (!(PicoAHW & PAHW_SMS)) - m68k_write16(addr,PicoPatches[i].data); - else - PicoWrite8_z80(addr,PicoPatches[i].data); + // *(unsigned short *)(Pico.rom + addr)); } else { - // if current addr is not patched by older patch, write back original val - for (u = 0; u < i; u++) - if (PicoPatches[u].addr == addr) break; - if (u == i) - { - if (!(PicoAHW & PAHW_SMS)) - m68k_write16(PicoPatches[i].addr,PicoPatches[i].data_old); - else - PicoWrite8_z80(PicoPatches[i].addr,PicoPatches[i].data_old); - } + if (PicoPatches[i].active) + { + if (!(PicoAHW & PAHW_SMS)) + m68k_write16(addr,PicoPatches[i].data); + else + PicoWrite8_z80(addr,PicoPatches[i].data); + } + else + { + // if current addr is not patched by older patch, write back original val + for (u = 0; u < i; u++) + if (PicoPatches[u].addr == addr) break; + if (u == i) + { + if (!(PicoAHW & PAHW_SMS)) + m68k_write16(PicoPatches[i].addr,PicoPatches[i].data_old); + else + PicoWrite8_z80(PicoPatches[i].addr,PicoPatches[i].data_old); + } + } } - } - } + } } From 11077d343a16f48a80a5c617b71cf27f91d296d5 Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Tue, 18 Apr 2017 21:08:50 +0100 Subject: [PATCH 100/124] Return correct memory info for SMS --- platform/libretro/libretro.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index a1cf22c8..934b6859 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -1126,7 +1126,7 @@ void *retro_get_memory_data(unsigned type) break; case RETRO_MEMORY_SYSTEM_RAM: if (PicoAHW & PAHW_SMS) - data = Pico.vramb; + data = Pico.zram; else data = Pico.ram; break; @@ -1162,7 +1162,7 @@ size_t retro_get_memory_size(unsigned type) case RETRO_MEMORY_SYSTEM_RAM: if (PicoAHW & PAHW_SMS) - return sizeof(Pico.vramb); + return 0x2000; else return sizeof(Pico.ram); From 925254c3fe875acc5d36cb9e5ac2a64851f011f6 Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 4 Aug 2017 00:36:13 +0300 Subject: [PATCH 101/124] fix a name clash with newer zlib --- pico/cart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pico/cart.c b/pico/cart.c index d237fad9..25a847d4 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -50,7 +50,7 @@ typedef struct _cso_struct } cso_struct; -static int uncompress2(void *dest, int destLen, void *source, int sourceLen) +static int uncompress_buf(void *dest, int destLen, void *source, int sourceLen) { z_stream stream; int err; @@ -298,7 +298,7 @@ size_t pm_read(void *ptr, size_t bytes, pm_file *stream) } cso->block_in_buff = block; } - rret = uncompress2(tmp_dst, 2048, cso->in_buff, read_len); + rret = uncompress_buf(tmp_dst, 2048, cso->in_buff, read_len); if (rret != 0) { elprintf(EL_STATUS, "cso: uncompress failed @ %08x with %i", read_pos, rret); break; From 75bf03886e4acb87bd7922d42d828f56c5dbe4bb Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 4 Aug 2017 01:08:17 +0300 Subject: [PATCH 102/124] fix android build --- jni/Android.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jni/Android.mk b/jni/Android.mk index f94aba2e..05b2a37c 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -56,6 +56,9 @@ else use_sh2mame = 1 endif +# PD is currently not strict aliasing safe +LOCAL_CFLAGS += -fno-strict-aliasing + # sources SRCS_COMMON := DEFINES := @@ -73,7 +76,7 @@ LOCAL_SRC_FILES += $(R)zlib/gzio.c $(R)zlib/inffast.c $(R)zlib/inflate.c \ $(R)zlib/crc32.c $(R)zlib/adler32.c $(R)zlib/zutil.c \ $(R)zlib/compress.c $(R)zlib/uncompr.c -LOCAL_SRC_FILES += $(R)unzip/unzip.c $(R)unzip/unzip_stream.c +LOCAL_SRC_FILES += $(R)unzip/unzip.c LOCAL_C_INCLUDES += $(R) From c367ebb8f3cb710d1e8a62341ac997e48c3f426f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 18 Aug 2017 01:20:25 +0200 Subject: [PATCH 103/124] Update submodules --- cpu/cyclone | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/cyclone b/cpu/cyclone index 355815eb..66dda842 160000 --- a/cpu/cyclone +++ b/cpu/cyclone @@ -1 +1 @@ -Subproject commit 355815ebb5b1c60916f66d043a43f3af7839589f +Subproject commit 66dda842eae01f47f5389b931ec9567fb0bbb6a1 From c13c91cd04513cc6c0d12e9714a5952607323333 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 18 Aug 2017 04:56:32 +0200 Subject: [PATCH 104/124] Update jni/Android.mk --- jni/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jni/Android.mk b/jni/Android.mk index 05b2a37c..bf81476c 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -76,7 +76,7 @@ LOCAL_SRC_FILES += $(R)zlib/gzio.c $(R)zlib/inffast.c $(R)zlib/inflate.c \ $(R)zlib/crc32.c $(R)zlib/adler32.c $(R)zlib/zutil.c \ $(R)zlib/compress.c $(R)zlib/uncompr.c -LOCAL_SRC_FILES += $(R)unzip/unzip.c +LOCAL_SRC_FILES += $(R)unzip/unzip.c $(R)unzip/unzip_stream.c LOCAL_C_INCLUDES += $(R) From d3bbc8d2cbb5fcc61e9f4e282effd0f2777a5cc3 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 6 Aug 2017 02:05:09 +0300 Subject: [PATCH 105/124] remove some dead code --- pico/draw.c | 40 ----------------- pico/draw_arm.S | 113 ------------------------------------------------ 2 files changed, 153 deletions(-) diff --git a/pico/draw.c b/pico/draw.c index dbd63631..0480242f 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -1197,46 +1197,6 @@ void PicoDoHighPal555(int sh) } } -#if 0 -static void FinalizeLineBGR444(int sh, int line) -{ - unsigned short *pd=DrawLineDest; - unsigned char *ps=HighCol+8; - unsigned short *pal=Pico.cram; - int len, i, t, mask=0xff; - - if (Pico.video.reg[12]&1) { - len = 320; - } else { - if(!(PicoOpt&POPT_DIS_32C_BORDER)) pd+=32; - len = 256; - } - - if(sh) { - pal=HighPal; - if(Pico.m.dirtyPal) { - blockcpy(pal, Pico.cram, 0x40*2); - // shadowed pixels - for(i = 0x3f; i >= 0; i--) - pal[0x40|i] = pal[0xc0|i] = (unsigned short)((pal[i]>>1)&0x0777); - // hilighted pixels - for(i = 0x3f; i >= 0; i--) { - t=pal[i]&0xeee;t+=0x444;if(t&0x10)t|=0xe;if(t&0x100)t|=0xe0;if(t&0x1000)t|=0xe00;t&=0xeee; - pal[0x80|i]=(unsigned short)t; - } - Pico.m.dirtyPal = 0; - } - } - - if (!sh && (rendstatus & PDRAW_SPR_LO_ON_HI)) - mask=0x3f; // accurate sprites - - for(i = 0; i < len; i++) - pd[i] = pal[ps[i] & mask]; -} -#endif - - void FinalizeLine555(int sh, int line) { unsigned short *pd=DrawLineDest; diff --git a/pico/draw_arm.S b/pico/draw_arm.S index 0bf297b9..bbdda5b0 100644 --- a/pico/draw_arm.S +++ b/pico/draw_arm.S @@ -1479,119 +1479,6 @@ DrawWindow: .endm -.global FinalizeLineBGR444 @ int sh - -FinalizeLineBGR444: - stmfd sp!, {r4-r6,lr} - mov r6, r0 - ldr lr, =(Pico+0x22228) @ Pico.video - ldr r0, =DrawLineDest - ldrb r12, [lr, #12] - ldr r0, [r0] - sub r3, lr, #0x128 @ r3=Pico.cram - - tst r12, #1 - movne r2, #320/4 @ len - bne .fl_no32colBGR444 - ldr r4, =PicoOpt - mov r2, #256/4 - ldr r4, [r4] - tst r4, #0x100 - addeq r0, r0, #32*2 - -.fl_no32colBGR444: - tst r6, r6 - beq .fl_noshBGR444 - - ldr r4, =HighPal - - ldrb r12, [lr, #-0x1a] @ 0x2220e ~ dirtyPal - tst r12, r12 - moveq r3, r4 - beq .fl_noshBGR444 - mov r12, #0 - strb r12, [lr, #-0x1a] - - mov lr, #0x40/8 - @ copy pal: -.fl_loopcpBGR444: - ldmia r3!, {r1,r5,r6,r12} - subs lr, lr, #1 - stmia r4!, {r1,r5,r6,r12} - bne .fl_loopcpBGR444 - - @ shadowed pixels: - mov r12, #0x0077 - orr r12,r12,#0x0700 - orr r12,r12,r12,lsl #16 - sub r3, r3, #0x40*2 - add r5, r4, #0x80*2 - mov lr, #0x40/4 -.fl_loopcpBGR444_sh: - ldmia r3!, {r1,r6} - subs lr, lr, #1 - and r1, r12, r1, lsr #1 - and r6, r12, r6, lsr #1 - stmia r4!, {r1,r6} - stmia r5!, {r1,r6} - bne .fl_loopcpBGR444_sh - - @ hilighted pixels: - sub r3, r3, #0x40*2 - mov lr, #0x40/2 -.fl_loopcpBGR444_hi: - ldr r1, [r3], #4 - TileDoShHi2Pixels444 r1 - str r1, [r4], #4 - subs lr, lr, #1 - bne .fl_loopcpBGR444_hi - - sub r3, r4, #0x40*3*2 - mov r6, #1 - - -.fl_noshBGR444: - ldr r12,=rendstatus - eors r6, r6, #1 @ sh is 0 - ldr r12,[r12] - mov lr, #0xff - tstne r12,#PDRAW_ACC_SPRITES - -.if OVERRIDE_HIGHCOL - ldr r1, =HighCol - movne lr, #0x3f - ldr r1, [r1] - mov lr, lr, lsl #1 - add r1, r1, #8 -.else - ldr r1, =(HighCol+8) - movne lr, #0x3f - mov lr, lr, lsl #1 -.endif - -.fl_loopBGR444: - ldr r12, [r1], #4 - subs r2, r2, #1 - - and r4, lr, r12, lsl #1 - ldrh r4, [r3, r4] - and r5, lr, r12, lsr #7 - ldrh r5, [r3, r5] - and r6, lr, r12, lsr #15 - ldrh r6, [r3, r6] - and r12,lr, r12, lsr #23 - ldrh r12,[r3, r12] @ 1c.i. - orr r4, r4, r5, lsl #16 - orr r5, r6, r12,lsl #16 - - stmia r0!, {r4,r5} - bne .fl_loopBGR444 - - - ldmfd sp!, {r4-r6,lr} - bx lr - - @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ From d01fa2044c98b23dfb72188a7486e567ab2d3dda Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 6 Aug 2017 02:03:35 +0300 Subject: [PATCH 106/124] eliminate texrels (wip) --- pico/32x/32x_draw.c | 4 +- pico/cd/gfx_dma.c | 2 +- pico/debug.c | 2 +- pico/draw.c | 183 ++++++++++++++++++++++++-------------------- pico/draw_arm.S | 182 ++++++++++++++++++++++--------------------- pico/mode4.c | 8 +- pico/pico.c | 3 + pico/pico.h | 6 +- pico/pico_cmn.c | 2 +- pico/pico_int.h | 15 +++- pico/pico_int_o32.h | 5 ++ pico/videoport.c | 12 +-- platform/gp2x/emu.c | 2 +- platform/psp/emu.c | 4 +- tools/Makefile | 5 +- tools/mkoffsets.c | 31 ++++++++ 16 files changed, 268 insertions(+), 198 deletions(-) create mode 100644 pico/pico_int_o32.h create mode 100644 tools/mkoffsets.c diff --git a/pico/32x/32x_draw.c b/pico/32x/32x_draw.c index ff07ef2a..007ef20c 100644 --- a/pico/32x/32x_draw.c +++ b/pico/32x/32x_draw.c @@ -83,7 +83,7 @@ static void convert_pal555(int invert_prio) } // this is almost never used (Wiz and menu bg gen only) -void FinalizeLine32xRGB555(int sh, int line) +void FinalizeLine32xRGB555(int sh, int line, struct PicoEState *est) { unsigned short *pd = DrawLineDest; unsigned short *pal = Pico32xMem->pal_native; @@ -91,7 +91,7 @@ void FinalizeLine32xRGB555(int sh, int line) unsigned short *dram, *p32x; unsigned char mdbg; - FinalizeLine555(sh, line); + FinalizeLine555(sh, line, est); if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 0 || // 32x blanking // XXX: how is 32col mode hadled by real hardware? diff --git a/pico/cd/gfx_dma.c b/pico/cd/gfx_dma.c index 44fa7ab2..a24a1c3c 100644 --- a/pico/cd/gfx_dma.c +++ b/pico/cd/gfx_dma.c @@ -37,7 +37,7 @@ PICO_INTERNAL void DmaSlowCell(unsigned int source, unsigned int a, int len, uns // AutoIncrement a=(u16)(a+inc); } - rendstatus |= PDRAW_SPRITES_MOVED; + Pico.est.rendstatus |= PDRAW_SPRITES_MOVED; break; case 3: // cram diff --git a/pico/debug.c b/pico/debug.c index 959331f8..91bff566 100644 --- a/pico/debug.c +++ b/pico/debug.c @@ -203,7 +203,7 @@ void PDebugShowPalette(unsigned short *screen, int stride) if (PicoAHW & PAHW_SMS) PicoDoHighPal555M4(); else - PicoDoHighPal555(1); + PicoDoHighPal555(1, 0, &Pico.est); Pico.m.dirtyPal = 1; screen += 16*stride+8; diff --git a/pico/draw.c b/pico/draw.c index 0480242f..76820a92 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -54,9 +54,8 @@ int HighPreSpr[80*2+1]; // slightly preprocessed sprites #define SPRL_LO_ABOVE_HI 0x10 // low priority sprites may be on top of hi unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES]; // sprite_count, ^flags, tile_count, [spritep]... -int rendstatus, rendstatus_old; +int rendstatus_old; int rendlines; -int DrawScanline; int PicoDrawMask = -1; static int skip_next_line=0; @@ -75,12 +74,15 @@ struct TileStrip // stuff available in asm: #ifdef _ASM_DRAW_C -void DrawWindow(int tstart, int tend, int prio, int sh); -void DrawAllSprites(unsigned char *sprited, int prio, int sh); -void DrawTilesFromCache(int *hc, int sh, int rlim); -void DrawSpritesSHi(unsigned char *sprited); -void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells); -void FinalizeLineBGR444(int sh, int line); +void DrawWindow(int tstart, int tend, int prio, int sh, + struct PicoEState *est); +void DrawAllSprites(unsigned char *sprited, int prio, int sh, + struct PicoEState *est); +void DrawTilesFromCache(int *hc, int sh, int rlim, + struct PicoEState *est); +void DrawSpritesSHi(unsigned char *sprited, struct PicoEState *est); +void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells, + struct PicoEState *est); void *blockcpy(void *dst, const void *src, size_t n); void blockcpy_or(void *dst, void *src, size_t n, int pat); #else @@ -258,7 +260,7 @@ static void DrawStrip(struct TileStrip *ts, int plane_sh, int cellskip) // terminate the cache list *ts->hc = 0; // if oldcode wasn't changed, it means all layer is hi priority - if (oldcode == -1) rendstatus |= PDRAW_PLANE_HI_PRIO; + if (oldcode == -1) Pico.est.rendstatus |= PDRAW_PLANE_HI_PRIO; } // this is messy @@ -266,7 +268,7 @@ void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip) { int tilex,dx,code=0,addr=0,cell=0; int oldcode=-1,blank=-1; // The tile we know is blank - int pal=0,scan=DrawScanline; + int pal=0,scan=Pico.est.DrawScanline; // Draw tiles across screen: tilex=(-ts->hscroll)>>3; @@ -317,7 +319,7 @@ void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip) // terminate the cache list *ts->hc = 0; - if (oldcode == -1) rendstatus |= PDRAW_PLANE_HI_PRIO; + if (oldcode == -1) Pico.est.rendstatus |= PDRAW_PLANE_HI_PRIO; } #endif @@ -374,7 +376,8 @@ void DrawStripInterlace(struct TileStrip *ts) // -------------------------------------------- #ifndef _ASM_DRAW_C -static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells) +static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells, + struct PicoEState *est) { struct PicoVideo *pvid=&Pico.video; const char shift[4]={5,6,5,7}; // 32,64 or 128 sized tilemaps (2 is invalid) @@ -401,7 +404,7 @@ static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells) else ts.nametab=(pvid->reg[2]&0x38)<< 9; // A htab=pvid->reg[13]<<9; // Horizontal scroll table address - if ( pvid->reg[11]&2) htab+=DrawScanline<<1; // Offset by line + if ( pvid->reg[11]&2) htab+=est->DrawScanline<<1; // Offset by line if ((pvid->reg[11]&1)==0) htab&=~0xf; // Offset by tile htab+=plane_sh&1; // A or B @@ -413,7 +416,7 @@ static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells) vscroll=Pico.vsram[plane_sh&1]; // Get vertical scroll value // Find the line in the name table - ts.line=(vscroll+(DrawScanline<<1))&((ymask<<1)|1); + ts.line=(vscroll+(est->DrawScanline<<1))&((ymask<<1)|1); ts.nametab+=(ts.line>>4)<DrawScanline)&ymask; ts.nametab+=(ts.line>>3)<reg[12]&1) { nametab=(pvid->reg[3]&0x3c)<<9; // 40-cell mode - nametab+=(DrawScanline>>3)<<6; + nametab+=(est->DrawScanline>>3)<<6; } else { nametab=(pvid->reg[3]&0x3e)<<9; // 32-cell mode - nametab+=(DrawScanline>>3)<<5; + nametab+=(est->DrawScanline>>3)<<5; } tilex=tstart<<1; - if (!(rendstatus & PDRAW_WND_DIFF_PRIO)) { + if (!(est->rendstatus & PDRAW_WND_DIFF_PRIO)) { // check the first tile code code=Pico.vram[nametab+tilex]; // if the whole window uses same priority (what is often the case), we may be able to skip this field @@ -465,7 +469,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh) // int *hcache } tend<<=1; - ty=(DrawScanline&7)<<1; // Y-Offset into tile + ty=(est->DrawScanline&7)<<1; // Y-Offset into tile // Draw tiles across screen: if (!sh) @@ -478,7 +482,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh) // int *hcache code=Pico.vram[nametab+tilex]; if (code==blank) continue; if ((code>>15) != prio) { - rendstatus |= PDRAW_WND_DIFF_PRIO; + est->rendstatus |= PDRAW_WND_DIFF_PRIO; continue; } @@ -504,7 +508,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh) // int *hcache code=Pico.vram[nametab+tilex]; if(code==blank) continue; if((code>>15) != prio) { - rendstatus |= PDRAW_WND_DIFF_PRIO; + est->rendstatus |= PDRAW_WND_DIFF_PRIO; continue; } @@ -538,23 +542,23 @@ static void DrawTilesFromCacheShPrep(void) // we can process whole line and then act as if sh/hi mode was off, // but leave lo pri op sprite markers alone int c = 320/4, *zb = (int *)(HighCol+8); - rendstatus |= PDRAW_SHHI_DONE; + Pico.est.rendstatus |= PDRAW_SHHI_DONE; while (c--) { *zb++ &= 0xbfbfbfbf; } } -static void DrawTilesFromCache(int *hc, int sh, int rlim) +static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est) { int code, addr, dx; int pal; // *ts->hc++ = code | (dx<<16) | (ty<<25); // cache it - if (sh && (rendstatus & (PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO))) + if (sh && (est->rendstatus & (PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO))) { - if (!(rendstatus & PDRAW_SHHI_DONE)) + if (!(est->rendstatus & PDRAW_SHHI_DONE)) DrawTilesFromCacheShPrep(); sh = 0; } @@ -658,7 +662,7 @@ static void DrawSprite(int *sprite, int sh) height=(sy>>24)&7; // Width and height in tiles sy=(sy<<16)>>16; // Y - row=DrawScanline-sy; // Row of the sprite we are on + row=Pico.est.DrawScanline-sy; // Row of the sprite we are on if (code&0x1000) row=(height<<3)-1-row; // Flip Y @@ -706,7 +710,7 @@ static void DrawSpriteInterlace(unsigned int *sprite) width=(height>>2)&3; height&=3; width++; height++; // Width and height in tiles - row=(DrawScanline<<1)-sy; // Row of the sprite we are on + row=(Pico.est.DrawScanline<<1)-sy; // Row of the sprite we are on code=sprite[1]; sx=((code>>16)&0x1ff)-0x78; // X @@ -738,7 +742,7 @@ static void DrawSpriteInterlace(unsigned int *sprite) static void DrawAllSpritesInterlace(int pri, int sh) { struct PicoVideo *pvid=&Pico.video; - int i,u,table,link=0,sline=DrawScanline<<1; + int i,u,table,link=0,sline=Pico.est.DrawScanline<<1; unsigned int *sprites[80]; // Sprite index table=pvid->reg[5]&0x7f; @@ -790,7 +794,7 @@ static void DrawAllSpritesInterlace(int pri, int sh) * Index + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: vert./horiz. size * Index + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8 */ -static void DrawSpritesSHi(unsigned char *sprited) +static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est) { int (*fTileFunc)(int sx,int addr,int pal); unsigned char *p; @@ -835,7 +839,7 @@ static void DrawSpritesSHi(unsigned char *sprited) height=(sy>>24)&7; // Width and height in tiles sy=(sy<<16)>>16; // Y - row=DrawScanline-sy; // Row of the sprite we are on + row=est->DrawScanline-sy; // Row of the sprite we are on if (code&0x1000) row=(height<<3)-1-row; // Flip Y @@ -867,7 +871,7 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh) cnt = sprited[0] & 0x7f; if (cnt == 0) return; - rendstatus |= PDRAW_SPR_LO_ON_HI; + Pico.est.rendstatus |= PDRAW_SPR_LO_ON_HI; p = &sprited[3]; @@ -906,7 +910,7 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh) height=(sy>>24)&7; // Width and height in tiles sy=(sy<<16)>>16; // Y - row=DrawScanline-sy; // Row of the sprite we are on + row=Pico.est.DrawScanline-sy; // Row of the sprite we are on if (code&0x1000) row=(height<<3)-1-row; // Flip Y @@ -942,7 +946,7 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh) /* nasty 2: sh operator pass */ sprited[0] = sh_cnt; - DrawSpritesSHi(sprited); + DrawSpritesSHi(sprited, &Pico.est); } @@ -954,7 +958,8 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh) void PrepareSprites(int full) { - struct PicoVideo *pvid=&Pico.video; + const struct PicoVideo *pvid=&Pico.video; + const struct PicoEState *est=&Pico.est; int u,link=0,sh; int table=0; int *pd = HighPreSpr; @@ -991,10 +996,11 @@ void PrepareSprites(int full) sy = (pack << 16) >> 16; height = (pack >> 24) & 0xf; - if (sy < max_lines && sy + (height<<3) > DrawScanline && // sprite onscreen (y)? + if (sy < max_lines && + sy + (height<<3) > est->DrawScanline && // sprite onscreen (y)? (sx > -24 || sx < max_width)) // onscreen x { - int y = (sy >= DrawScanline) ? sy : DrawScanline; + int y = (sy >= est->DrawScanline) ? sy : est->DrawScanline; int entry = ((pd - HighPreSpr) / 2) | ((code2>>8)&0x80); for (; y < sy + (height<<3) && y < max_lines; y++) { @@ -1047,7 +1053,7 @@ found:; sx = (code2>>16)&0x1ff; sx -= 0x78; // Get X coordinate + 8 - if (sy < max_lines && sy + (height<<3) > DrawScanline) // sprite onscreen (y)? + if (sy < max_lines && sy + (height<<3) > est->DrawScanline) // sprite onscreen (y)? { int entry, y, sx_min, onscr_x, maybe_op = 0; @@ -1057,7 +1063,7 @@ found:; maybe_op = SPRL_MAY_HAVE_OP; entry = ((pd - HighPreSpr) / 2) | ((code2>>8)&0x80); - y = (sy >= DrawScanline) ? sy : DrawScanline; + y = (sy >= est->DrawScanline) ? sy : est->DrawScanline; for (; y < sy + (height<<3) && y < max_lines; y++) { unsigned char *p = &HighLnSpr[y][0]; @@ -1110,16 +1116,17 @@ found:; } #ifndef _ASM_DRAW_C -static void DrawAllSprites(unsigned char *sprited, int prio, int sh) +static void DrawAllSprites(unsigned char *sprited, int prio, int sh, + struct PicoEState *est) { - int rs = rendstatus; + int rs = est->rendstatus; unsigned char *p; int cnt; if (rs & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) { //elprintf(EL_STATUS, "PrepareSprites(%i)", (rs>>4)&1); PrepareSprites(rs & PDRAW_DIRTY_SPRITES); - rendstatus = rs & ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES); + est->rendstatus = rs & ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES); } cnt = sprited[0] & 0x7f; @@ -1159,7 +1166,7 @@ void BackFill(int reg7, int sh) unsigned short HighPal[0x100]; #ifndef _ASM_DRAW_C -void PicoDoHighPal555(int sh) +void PicoDoHighPal555(int sh, int line, struct PicoEState *est) { unsigned int *spal, *dpal; unsigned int t, i; @@ -1205,7 +1212,7 @@ void FinalizeLine555(int sh, int line) int len; if (Pico.m.dirtyPal) - PicoDoHighPal555(sh); + PicoDoHighPal555(sh, line, est); if (Pico.video.reg[12]&1) { len = 320; @@ -1217,7 +1224,7 @@ void FinalizeLine555(int sh, int line) { #ifndef PSP int i, mask=0xff; - if (!sh && (rendstatus & PDRAW_SPR_LO_ON_HI)) + if (!sh && (est->rendstatus & PDRAW_SPR_LO_ON_HI)) mask=0x3f; // accurate sprites, upper bits are priority stuff for (i = 0; i < len; i++) @@ -1225,7 +1232,7 @@ void FinalizeLine555(int sh, int line) #else extern void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count); extern void amips_clut_6bit(unsigned short *dst, unsigned char *src, unsigned short *pal, int count); - if (!sh && (rendstatus & PDRAW_SPR_LO_ON_HI)) + if (!sh && (est->rendstatus & PDRAW_SPR_LO_ON_HI)) amips_clut_6bit(pd, ps, pal, len); else amips_clut(pd, ps, pal, len); #endif @@ -1233,10 +1240,10 @@ void FinalizeLine555(int sh, int line) } #endif -static void FinalizeLine8bit(int sh, int line) +static void FinalizeLine8bit(int sh, int line, struct PicoEState *est) { unsigned char *pd = DrawLineDest; - int len, rs = rendstatus; + int len, rs = est->rendstatus; static int dirty_count; if (!sh && Pico.m.dirtyPal == 1) @@ -1246,7 +1253,7 @@ static void FinalizeLine8bit(int sh, int line) dirty_count = 1; else dirty_count++; rs |= PDRAW_SONIC_MODE; - rendstatus = rs; + est->rendstatus = rs; if (dirty_count == 3) { blockcpy(HighPal, Pico.cram, 0x40*2); } else if (dirty_count == 11) { @@ -1273,18 +1280,19 @@ static void FinalizeLine8bit(int sh, int line) } } -static void (*FinalizeLine)(int sh, int line); +static void (*FinalizeLine)(int sh, int line, struct PicoEState *est); // -------------------------------------------- static int DrawDisplay(int sh) { - unsigned char *sprited = &HighLnSpr[DrawScanline][0]; + struct PicoEState *est=&Pico.est; + unsigned char *sprited = &HighLnSpr[est->DrawScanline][0]; struct PicoVideo *pvid=&Pico.video; int win=0,edge=0,hvwind=0; int maxw,maxcells; - rendstatus &= ~(PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO); + est->rendstatus &= ~(PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO); if (pvid->reg[12]&1) { maxw = 328; maxcells = 40; @@ -1296,8 +1304,8 @@ static int DrawDisplay(int sh) win=pvid->reg[0x12]; edge=(win&0x1f)<<3; - if (win&0x80) { if (DrawScanline>=edge) hvwind=1; } - else { if (DrawScanline< edge) hvwind=1; } + if (win&0x80) { if (est->DrawScanline>=edge) hvwind=1; } + else { if (est->DrawScanline< edge) hvwind=1; } if (!hvwind) // we might have a vertical window here { @@ -1315,53 +1323,56 @@ static int DrawDisplay(int sh) /* - layer B low - */ if (PicoDrawMask & PDRAW_LAYERB_ON) - DrawLayer(1|(sh<<1), HighCacheB, 0, maxcells); + DrawLayer(1|(sh<<1), HighCacheB, 0, maxcells, est); /* - layer A low - */ if (!(PicoDrawMask & PDRAW_LAYERA_ON)); else if (hvwind == 1) - DrawWindow(0, maxcells>>1, 0, sh); + DrawWindow(0, maxcells>>1, 0, sh, est); else if (hvwind == 2) { - DrawLayer(0|(sh<<1), HighCacheA, (win&0x80) ? 0 : edge<<1, (win&0x80) ? edge<<1 : maxcells); - DrawWindow( (win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 0, sh); + DrawLayer(0|(sh<<1), HighCacheA, (win&0x80) ? 0 : edge<<1, (win&0x80) ? edge<<1 : maxcells, est); + DrawWindow( (win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 0, sh, est); } else - DrawLayer(0|(sh<<1), HighCacheA, 0, maxcells); + DrawLayer(0|(sh<<1), HighCacheA, 0, maxcells, est); /* - sprites low - */ if (!(PicoDrawMask & PDRAW_SPRITES_LOW_ON)); - else if (rendstatus & PDRAW_INTERLACE) + else if (Pico.est.rendstatus & PDRAW_INTERLACE) DrawAllSpritesInterlace(0, sh); else if (sprited[1] & SPRL_HAVE_LO) - DrawAllSprites(sprited, 0, sh); + DrawAllSprites(sprited, 0, sh, est); /* - layer B hi - */ if ((PicoDrawMask & PDRAW_LAYERB_ON) && HighCacheB[0]) - DrawTilesFromCache(HighCacheB, sh, maxw); + DrawTilesFromCache(HighCacheB, sh, maxw, est); /* - layer A hi - */ if (!(PicoDrawMask & PDRAW_LAYERA_ON)); else if (hvwind == 1) - DrawWindow(0, maxcells>>1, 1, sh); + DrawWindow(0, maxcells>>1, 1, sh, est); else if (hvwind == 2) { - if (HighCacheA[0]) DrawTilesFromCache(HighCacheA, sh, (win&0x80) ? edge<<4 : maxw); - DrawWindow((win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 1, sh); + if (HighCacheA[0]) + DrawTilesFromCache(HighCacheA, sh, (win&0x80) ? edge<<4 : maxw, est); + DrawWindow((win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 1, sh, est); } else - if (HighCacheA[0]) DrawTilesFromCache(HighCacheA, sh, maxw); + if (HighCacheA[0]) + DrawTilesFromCache(HighCacheA, sh, maxw, est); /* - sprites hi - */ if (!(PicoDrawMask & PDRAW_SPRITES_HI_ON)); - else if (rendstatus & PDRAW_INTERLACE) + else if (Pico.est.rendstatus & PDRAW_INTERLACE) DrawAllSpritesInterlace(1, sh); // have sprites without layer pri bit ontop of sprites with that bit else if ((sprited[1] & 0xd0) == 0xd0 && (PicoOpt & POPT_ACC_SPRITES)) DrawSpritesHiAS(sprited, sh); else if (sh && (sprited[1] & SPRL_MAY_HAVE_OP)) - DrawSpritesSHi(sprited); + DrawSpritesSHi(sprited, est); else if (sprited[1] & SPRL_HAVE_HI) - DrawAllSprites(sprited, 1, 0); + DrawAllSprites(sprited, 1, 0, est); #if 0 { int *c, a, b; for (a = 0, c = HighCacheA; *c; c++, a++); for (b = 0, c = HighCacheB; *c; c++, b++); - printf("%i:%03i: a=%i, b=%i\n", Pico.m.frame_count, DrawScanline, a, b); + printf("%i:%03i: a=%i, b=%i\n", Pico.m.frame_count, + Pico.est.DrawScanline, a, b); } #endif @@ -1374,27 +1385,27 @@ PICO_INTERNAL void PicoFrameStart(void) int offs = 8, lines = 224; // prepare to do this frame - rendstatus = 0; + Pico.est.rendstatus = 0; if ((Pico.video.reg[12] & 6) == 6) - rendstatus |= PDRAW_INTERLACE; // interlace mode + Pico.est.rendstatus |= PDRAW_INTERLACE; // interlace mode if (!(Pico.video.reg[12] & 1)) - rendstatus |= PDRAW_32_COLS; + Pico.est.rendstatus |= PDRAW_32_COLS; if (Pico.video.reg[1] & 8) { offs = 0; lines = 240; } - if (rendstatus != rendstatus_old || lines != rendlines) { + if (Pico.est.rendstatus != rendstatus_old || lines != rendlines) { rendlines = lines; // mode_change() might reset rendstatus_old by calling SetColorFormat emu_video_mode_change((lines == 240) ? 0 : 8, lines, (Pico.video.reg[12] & 1) ? 0 : 1); - rendstatus_old = rendstatus; + rendstatus_old = Pico.est.rendstatus; } HighCol = HighColBase + offs * HighColIncrement; DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement; - DrawScanline = 0; + Pico.est.DrawScanline = 0; skip_next_line = 0; if (PicoOpt & POPT_ALT_RENDERER) @@ -1413,7 +1424,7 @@ static void DrawBlankedLine(int line, int offs, int sh, int bgc) BackFill(bgc, sh); if (FinalizeLine != NULL) - FinalizeLine(sh, line); + FinalizeLine(sh, line, &Pico.est); if (PicoScanEnd != NULL) PicoScanEnd(line + offs); @@ -1431,7 +1442,7 @@ static void PicoLine(int line, int offs, int sh, int bgc) return; } - DrawScanline = line; + Pico.est.DrawScanline = line; if (PicoScanBegin != NULL) skip = PicoScanBegin(line + offs); @@ -1446,7 +1457,7 @@ static void PicoLine(int line, int offs, int sh, int bgc) DrawDisplay(sh); if (FinalizeLine != NULL) - FinalizeLine(sh, line); + FinalizeLine(sh, line, &Pico.est); if (PicoScanEnd != NULL) skip_next_line = PicoScanEnd(line + offs); @@ -1466,7 +1477,7 @@ void PicoDrawSync(int to, int blank_last_line) if (rendlines != 240) offs = 8; - for (line = DrawScanline; line < to; line++) + for (line = Pico.est.DrawScanline; line < to; line++) { PicoLine(line, offs, sh, bgc); } @@ -1479,7 +1490,7 @@ void PicoDrawSync(int to, int blank_last_line) else PicoLine(line, offs, sh, bgc); line++; } - DrawScanline = line; + Pico.est.DrawScanline = line; pprof_end(draw); } @@ -1491,8 +1502,8 @@ void PicoDrawUpdateHighPal(void) if (PicoOpt & POPT_ALT_RENDERER) sh = 0; // no s/h support - PicoDoHighPal555(sh); - if (rendstatus & PDRAW_SONIC_MODE) { + PicoDoHighPal555(sh, 0, &Pico.est); + if (Pico.est.rendstatus & PDRAW_SONIC_MODE) { // FIXME? memcpy(HighPal + 0x40, HighPal, 0x40*2); memcpy(HighPal + 0x80, HighPal, 0x40*2); @@ -1528,7 +1539,7 @@ void PicoDrawSetOutBuf(void *dest, int increment) { DrawLineDestBase = dest; DrawLineDestIncrement = increment; - DrawLineDest = (unsigned char*)DrawLineDestBase + DrawScanline * increment; + DrawLineDest = (unsigned char*)DrawLineDestBase + Pico.est.DrawScanline * increment; } void PicoDrawSetInternalBuf(void *dest, int increment) @@ -1536,7 +1547,7 @@ void PicoDrawSetInternalBuf(void *dest, int increment) if (dest != NULL) { HighColBase = dest; HighColIncrement = increment; - HighCol = HighColBase + DrawScanline * increment; + HighCol = HighColBase + Pico.est.DrawScanline * increment; } else { HighColBase = DefHighCol; @@ -1560,3 +1571,5 @@ void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned in PicoScanEnd = end; } } + +// vim:ts=4:sw=4:expandtab diff --git a/pico/draw_arm.S b/pico/draw_arm.S index bbdda5b0..2c1db104 100644 --- a/pico/draw_arm.S +++ b/pico/draw_arm.S @@ -1,6 +1,6 @@ /* * assembly optimized versions of most funtions from draw.c - * (C) notaz, 2006-2010 + * (C) notaz, 2006-2010,2017 * * This work is licensed under the terms of MAME license. * See COPYING file in the top-level directory. @@ -8,12 +8,11 @@ * this is highly specialized, be careful if changing related C code! */ -.extern Pico +#include "pico_int_o32.h" + .extern PicoOpt .extern HighCol -.extern DrawScanline .extern HighSprZ -.extern rendstatus .extern HighPreSpr .extern DrawLineDest .extern DrawStripInterlace @@ -287,14 +286,16 @@ @ int cells; // 0x14 @ }; -@ void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells); +@ void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells, +@ struct PicoEState *est) .global DrawLayer DrawLayer: + ldr r12, [sp] @ est stmfd sp!, {r4-r11,lr} - ldr r11, =(Pico+0x22228) @ Pico.video + ldr r11, [r12, #OFS_Pico_video] mov r8, #1 ldrb r7, [r11, #16] @ ??vv??hh @@ -316,17 +317,17 @@ DrawLayer: cmp r10, #7 subge r10, r10, #1 @ r10=shift[width] (5,6,6,7) - @ calculate xmask: - mov r5, r8, lsl r10 - sub r5, r5, #1 @ r5=xmask + ldr r2, [r12, #OFS_DrawScanline] + ldr lr, [r12, #OFS_Pico_vram] @ Find name table: ands r0, r0, #1 ldreqb r12, [r11, #2] ldrneb r12, [r11, #4] - ldr r2, =DrawScanline @ trying to make good use of pipeline here - ldr lr, =(Pico+0x10000) @ lr=Pico.vram + @ calculate xmask: + mov r5, r8, lsl r10 + sub r5, r5, #1 @ r5=xmask moveq r12, r12, lsl #10 movne r12, r12, lsl #13 @@ -334,7 +335,6 @@ DrawLayer: ldrh r8, [r11, #12] ldrb r7, [r11, #11] - ldr r2, [r2] mov r4, r8, lsr #8 @ pvid->reg[13] mov r4, r4, lsl #10 @ htab=pvid->reg[13]<<9; (halfwords) @@ -504,12 +504,12 @@ DrawLayer: .dsloop_exit: tst r10, #1<<21 @ seen non hi-prio tile - ldreq r1, =rendstatus + ldr r1, [sp, #9*4] @ est mov r0, #0 - ldreq r2, [r1] + ldreq r2, [r1, #OFS_rendstatus] str r0, [r6] @ terminate the cache list orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles - streq r2, [r1] + streq r2, [r1, #OFS_rendstatus] ldmfd sp!, {r4-r11,lr} bx lr @@ -522,9 +522,9 @@ DrawLayer: bic r8, r8, #0x3fc00000 orr r8, r8, r5, lsl #25 @ r8=(xmask[31:25]|had_output[24]|tilex[21:0]) - ldr r4, =DrawScanline + ldr r11, [sp, #9*4] @ est orr r5, r1, r10, lsl #24 - ldr r4, [r4] + ldr r4, [r11, #OFS_DrawScanline] sub r1, r3, #1 orr r5, r5, r4, lsl #16 @ r5=(shift_width[31:24]|scanline[23:16]|ymask[15:0]) and r1, r1, #7 @@ -679,12 +679,12 @@ DrawLayer: .dsloop_vs_exit: tst r8, #(1<<24) @ seen non hi-prio tile - ldreq r1, =rendstatus + ldr r1, [sp, #9*4] @ est mov r0, #0 - ldreq r2, [r1] + ldreq r2, [r1, #OFS_rendstatus] str r0, [r6] @ terminate the cache list orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles - streq r2, [r1] + streq r2, [r1, #OFS_rendstatus] ldmfd sp!, {r4-r11,lr} bx lr @@ -770,11 +770,12 @@ BackFill: @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +@ void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est) -.global DrawTilesFromCache @ int *hc, int sh, int rlim +.global DrawTilesFromCache DrawTilesFromCache: - stmfd sp!, {r4-r8,r11,lr} + stmfd sp!, {r4-r9,r11,lr} @ cache some stuff to avoid mem access .if OVERRIDE_HIGHCOL @@ -785,7 +786,8 @@ DrawTilesFromCache: ldr r11,=HighCol mov r12,#0xf .endif - ldr lr, =(Pico+0x10000) @ lr=Pico.vram + ldr lr, [r3, #OFS_Pico_vram] + mov r9, r3 @ est mvn r5, #0 @ r5=prevcode=-1 ands r8, r1, #1 @@ -796,7 +798,7 @@ DrawTilesFromCache: .dtfc_loop: ldr r6, [r0], #4 @ read code movs r1, r6, lsr #16 @ r1=dx; - ldmeqfd sp!, {r4-r8,r11,pc} @ dx is never zero, this must be a terminator, return + ldmeqfd sp!, {r4-r9,r11,pc} @ dx is never zero, this must be a terminator, return bic r4, r1, #0xfe00 add r1, r11, r4 @ r1=pdest @@ -915,15 +917,14 @@ DrawTilesFromCache: @ check if we have detected layer covered with hi-prio tiles: .dtfc_check_rendflags: - ldr r1, =rendstatus - ldr r2, [r1] + ldr r2, [r9, #OFS_rendstatus] tst r2, #(PDRAW_PLANE_HI_PRIO|PDRAW_SHHI_DONE) beq .dtfc_loop bic r8, r8, #1 @ sh/hi mode off tst r2, #PDRAW_SHHI_DONE bne .dtfc_loop @ already processed orr r2, r2, #PDRAW_SHHI_DONE - str r2, [r1] + str r2, [r9, #OFS_rendstatus] add r1, r11,#8 mov r3, #320/4/4 @@ -948,7 +949,9 @@ DrawTilesFromCache: @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -.global DrawSpritesSHi @ unsigned char *sprited +@ void DrawSpritesSHi(unsigned char *sprited, struct PicoEState *est) + +.global DrawSpritesSHi DrawSpritesSHi: ldr r3, [r0] @@ -956,7 +959,7 @@ DrawSpritesSHi: ands r3, r3, #0x7f bxeq lr - stmfd sp!, {r4-r11,lr} + stmfd sp!, {r1,r4-r11,lr} @ +est strb r12,[r0,#2] @ set end marker add r10,r0, #3 @ r10=HighLnSpr end add r10,r10,r3 @ r10=HighLnSpr end @@ -969,16 +972,16 @@ DrawSpritesSHi: ldr r11,=HighCol mov r12,#0xf .endif - ldr lr, =(Pico+0x10000) @ lr=Pico.vram + ldr lr, [r1, #OFS_Pico_vram] DrawSpriteSHi: @ draw next sprite ldrb r0, [r10,#-1]! + ldr r7, [sp] @ est ldr r1, =HighPreSpr -@ ldr r8, [sp, #-4] cmp r0, #0xff - ldmeqfd sp!, {r4-r11,pc} @ end of list + ldmeqfd sp!, {r1,r4-r11,pc} @ end of list and r0, r0, #0x7f add r0, r1, r0, lsl #3 @@ -997,15 +1000,14 @@ DrawSpriteSHi: bne DrawSpriteSHi @ non-operator low sprite, already drawn ldr r3, [r0] @ sprite[0] - ldr r7, =DrawScanline mov r6, r3, lsr #28 sub r6, r6, #1 @ r6=width-1 (inc later) mov r5, r3, lsr #24 and r5, r5, #7 @ r5=height + ldr r7, [r7, #OFS_DrawScanline] mov r0, r3, lsl #16 @ r4=sy<<16 (tmp) - ldr r7, [r7] sub r7, r7, r0, asr #16 @ r7=row=DrawScanline-sy tst r9, #0x1000 @@ -1128,34 +1130,34 @@ DrawSpriteSHi: @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -.global DrawAllSprites @ unsigned char *sprited, int prio, int sh +@ void DrawAllSprites(unsigned char *sprited, int prio, int sh, +@ struct PicoEState *est) + +.global DrawAllSprites DrawAllSprites: - ldr r3, =rendstatus orr r1, r2, r1, lsl #1 - ldr r12,[r3] + ldr r12,[r3, #OFS_rendstatus] tst r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED) beq das_no_prep - stmfd sp!, {r0,r1,lr} + stmfd sp!, {r0,r1,r3,lr} and r0, r12,#PDRAW_DIRTY_SPRITES bic r12,r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED) - str r12,[r3] + str r12,[r3, #OFS_rendstatus] bl PrepareSprites - ldmfd sp!, {r0,r1,lr} + ldmfd sp!, {r0,r1,r3,lr} das_no_prep: - ldr r3, [r0] - ands r3, r3, #0x7f + ldr r2, [r0] + ands r2, r2, #0x7f bxeq lr @ time to do some real work - stmfd sp!, {r4-r11,lr} + stmfd sp!, {r1,r3-r11,lr} @ +sh|prio<<1 +est mov r12,#0xff strb r12,[r0,#2] @ set end marker add r10,r0, #3 - add r10,r10,r3 @ r10=HighLnSpr end - - str r1, [sp, #-4] @ no calls after this point + add r10,r10,r2 @ r10=HighLnSpr end .if OVERRIDE_HIGHCOL ldr r11,=HighCol @@ -1165,29 +1167,27 @@ das_no_prep: ldr r11,=HighCol mov r12,#0xf .endif - ldr lr, =(Pico+0x10000) @ lr=Pico.vram + ldr lr, [r3, #OFS_Pico_vram] @ + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: horiz. size @ + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8 -DrawSprite: @ was: unsigned int *sprite, int sh, int acc_sprites +DrawSprite: @ draw next sprite ldrb r0, [r10,#-1]! - ldr r1, =HighPreSpr - ldr r8, [sp, #-4] + ldr r8, [sp] @ sh|prio<<1 + ldr r7, [sp, #4] @ est mov r2, r0, lsr #7 cmp r0, #0xff - ldmeqfd sp!, {r4-r11,pc} @ end of list + ldmeqfd sp!, {r1,r3-r11,pc} @ end of list cmp r2, r8, lsr #1 bne DrawSprite @ wrong priority + ldr r1, =HighPreSpr and r0, r0, #0x7f add r0, r1, r0, lsl #3 -@ stmfd sp!, {r4-r9,r11,lr} -@ orr r8, r2, r1, lsl #4 - ldr r3, [r0] @ sprite[0] - ldr r7, =DrawScanline + ldr r7, [r7, #OFS_DrawScanline] mov r6, r3, lsr #28 sub r6, r6, #1 @ r6=width-1 (inc later) mov r5, r3, lsr #24 @@ -1195,7 +1195,6 @@ DrawSprite: @ was: unsigned int *sprite, int sh, int acc_sprites mov r4, r3, lsl #16 @ r4=sy<<16 (tmp) - ldr r7, [r7] ldr r9, [r0, #4] sub r7, r7, r4, asr #16 @ r7=row=DrawScanline-sy @@ -1307,17 +1306,21 @@ DrawSprite: @ was: unsigned int *sprite, int sh, int acc_sprites @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -.global DrawWindow @ int tstart, int tend, int prio, int sh // int *hcache +@ void DrawWindow(int tstart, int tend, int prio, int sh +@ struct PicoEState *est) + +.global DrawWindow DrawWindow: + ldr r12, [sp] @ est stmfd sp!, {r4-r11,lr} - ldr r11, =(Pico+0x22228) @ Pico.video - ldr r10, =DrawScanline - ldrb r12, [r11, #3] @ pvid->reg[3] + ldr r6, [r12, #OFS_Pico_video] + ldr r10, [r12, #OFS_DrawScanline] + mov r11, r12 @ est + ldrb r12, [r6, #3] @ pvid->reg[3] - ldr r10, [r10] - ldr r4, [r11, #12] + ldr r4, [r6, #12] mov r5, r10, lsr #3 and r10, r10, #7 mov r10, r10, lsl #1 @ r10=ty @@ -1331,9 +1334,8 @@ DrawWindow: addeq r12, r12, r5, lsl #6 @ nametab add r12, r12, r0, lsl #2 @ +starttile - ldr r6, =rendstatus - ldr lr, =(Pico+0x10000) @ lr=Pico.vram - ldr r6, [r6] + ldr lr, [r11, #OFS_Pico_vram] + ldr r6, [r11, #OFS_rendstatus] @ fetch the first code now ldrh r7, [lr, r12] @@ -1442,14 +1444,14 @@ DrawWindow: b .dw_shadow_done .dwloop_end: - ldr r0, =rendstatus - ldr r1, [r0] - and r6, r6, #PDRAW_WND_DIFF_PRIO - orr r1, r1, r6 - str r1, [r0] + and r2, r6, #PDRAW_WND_DIFF_PRIO + ldmfd sp!, {r4-r11,lr} + ldr r0, [sp] + ldr r1, [r0, #OFS_rendstatus] + orr r1, r1, r2 + str r1, [r0, #OFS_rendstatus] - ldmfd sp!, {r4-r11,r12} - bx r12 + bx lr @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ -1531,12 +1533,15 @@ vidConvCpyRGB565: @ void *to, void *from, int pixels bx lr -.global PicoDoHighPal555 @ int sh +@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est) + +.global PicoDoHighPal555 PicoDoHighPal555: - stmfd sp!, {r4-r9,lr} + stmfd sp!, {r4-r10,lr} + mov r10,r2 @ est mov r1, #0 - ldr r8, =(Pico+0x22228) @ Pico.video + ldr r8, [r10, #OFS_Pico_video] PicoDoHighPal555_nopush: orr r9, r1, r0, lsl #31 @ 0:called from FinalizeLine555, 31: s/h @@ -1598,17 +1603,20 @@ PicoDoHighPal555_nopush: PicoDoHighPal555_end: tst r9, #1 - ldmeqfd sp!, {r4-r9,pc} + ldmeqfd sp!, {r4-r10,pc} - ldr r8, =(Pico+0x22228) @ Pico.video + ldr r8, [r10, #OFS_Pico_video] b FinalizeLineRGB555_pal_done -.global FinalizeLine555 @ int sh +@ void FinalizeLine555(int sh, int line, struct PicoEState *est) + +.global FinalizeLine555 FinalizeLine555: - stmfd sp!, {r4-r9,lr} - ldr r8, =(Pico+0x22228) @ Pico.video + stmfd sp!, {r4-r10,lr} + mov r10,r2 @ est + ldr r8, [r10, #OFS_Pico_video] ldrb r2, [r8, #-0x1a] @ 0x2220e ~ dirtyPal mov r1, #1 @@ -1618,9 +1626,8 @@ FinalizeLine555: FinalizeLineRGB555_pal_done: ldr r3, =HighPal - ldr r12,=rendstatus + ldr r12, [r10, #OFS_rendstatus] eors r0, r0, #1 @ sh is 0 - ldr r12,[r12] mov lr, #0xff tstne r12,#PDRAW_ACC_SPRITES movne lr, #0x3f @@ -1691,12 +1698,11 @@ FinalizeLineRGB555_pal_done: stmia r0!, {r4,r5,r8,r12} bne .fl_loopRGB555 - ldmfd sp!, {r4-r9,lr} + ldmfd sp!, {r4-r10,lr} bx lr .fl_32scale_RGB555: - stmfd sp!, {r10} mov r9, #0x3900 @ f800 07e0 001f | e000 0780 001c | 3800 01e0 0007 orr r9, r9, #0x00e7 @@ -1757,8 +1763,7 @@ FinalizeLineRGB555_pal_done: stmia r0!, {r4,r5,r6,r8,r10} bne .fl_loop32scale_RGB555 - ldmfd sp!, {r10} - ldmfd sp!, {r4-r9,lr} + ldmfd sp!, {r4-r10,lr} bx lr #ifdef UNALIGNED_DRAWLINEDEST @@ -1804,7 +1809,7 @@ FinalizeLineRGB555_pal_done: strh r8, [r0], #2 - ldmfd sp!, {r4-r9,lr} + ldmfd sp!, {r4-r10,lr} bx lr @@ -1870,8 +1875,7 @@ FinalizeLineRGB555_pal_done: strh r4, [r0], #2 - ldmfd sp!, {r10} - ldmfd sp!, {r4-r9,lr} + ldmfd sp!, {r4-r10,lr} bx lr #endif /* UNALIGNED_DRAWLINEDEST */ diff --git a/pico/mode4.c b/pico/mode4.c index 22e30419..c945f6fe 100644 --- a/pico/mode4.c +++ b/pico/mode4.c @@ -200,7 +200,7 @@ void PicoFrameStartMode4(void) int lines = 192; skip_next_line = 0; screen_offset = 24; - rendstatus = PDRAW_32_COLS; + Pico.est.rendstatus = PDRAW_32_COLS; if ((Pico.video.reg[0] & 6) == 6 && (Pico.video.reg[1] & 0x18)) { if (Pico.video.reg[1] & 0x08) { @@ -213,9 +213,9 @@ void PicoFrameStartMode4(void) } } - if (rendstatus != rendstatus_old || lines != rendlines) { + if (Pico.est.rendstatus != rendstatus_old || lines != rendlines) { emu_video_mode_change(screen_offset, lines, 1); - rendstatus_old = rendstatus; + rendstatus_old = Pico.est.rendstatus; rendlines = lines; } @@ -277,7 +277,7 @@ static void FinalizeLineRGB555M4(int line) // standard FinalizeLine can finish it for us, // with features like scaling and such - FinalizeLine555(0, line); + FinalizeLine555(0, line, &Pico.est); } static void FinalizeLine8bitM4(int line) diff --git a/pico/pico.c b/pico/pico.c index 866f6973..e14c5037 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -37,6 +37,9 @@ void PicoInit(void) memset(&PicoPad,0,sizeof(PicoPad)); memset(&PicoPadInt,0,sizeof(PicoPadInt)); + Pico.est.Pico_video = &Pico.video; + Pico.est.Pico_vram = Pico.vram; + // Init CPUs: SekInit(); z80_init(); // init even if we aren't going to use it diff --git a/pico/pico.h b/pico/pico.h index 624adacc..d899b1a8 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -100,6 +100,8 @@ typedef enum { PI_ROM, PI_ISPAL, PI_IS40_CELL, PI_IS240_LINES } pint_t; typedef union { int vint; void *vptr; } pint_ret_t; void PicoGetInternal(pint_t which, pint_ret_t *ret); +struct PicoEState; + // cd/mcd.c extern void (*PicoMCDopenTray)(void); extern void (*PicoMCDcloseTray)(void); @@ -176,7 +178,7 @@ extern unsigned char *HighCol; #ifdef _ASM_DRAW_C void vidConvCpyRGB565(void *to, void *from, int pixels); #endif -void PicoDoHighPal555(int sh); +void PicoDoHighPal555(int sh, int line, struct PicoEState *est); extern int PicoDrawMask; #define PDRAW_LAYERB_ON (1<<2) #define PDRAW_LAYERA_ON (1<<3) @@ -193,7 +195,7 @@ extern int PicoDrawMask; #define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3) #define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed #define PDRAW_32_COLS (1<<8) // 32 column mode -extern int rendstatus, rendstatus_old; +extern int rendstatus_old; extern int rendlines; extern unsigned short HighPal[0x100]; diff --git a/pico/pico_cmn.c b/pico/pico_cmn.c index e8ad78d4..70d7807a 100644 --- a/pico/pico_cmn.c +++ b/pico/pico_cmn.c @@ -168,7 +168,7 @@ static int PicoFrameHints(void) if (!skip) { - if (DrawScanline < y) + if (Pico.est.DrawScanline < y) PicoDrawSync(y - 1, 0); #ifdef DRAW_FINISH_FUNC DRAW_FINISH_FUNC(); diff --git a/pico/pico_int.h b/pico/pico_int.h index e7f530fe..427460e3 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -333,6 +333,15 @@ struct PicoMS unsigned char pad[0x4e]; }; +// emu state and data for the asm code +struct PicoEState +{ + int DrawScanline; + int rendstatus; + void *Pico_video; + void *Pico_vram; +}; + // some assembly stuff depend on these, do not touch! struct Pico { @@ -353,6 +362,7 @@ struct Pico struct PicoMisc m; struct PicoVideo video; struct PicoMS ms; + struct PicoEState est; }; // sram @@ -582,10 +592,9 @@ int CM_compareRun(int cyc, int is_sub); PICO_INTERNAL void PicoFrameStart(void); void PicoDrawSync(int to, int blank_last_line); void BackFill(int reg7, int sh); -void FinalizeLine555(int sh, int line); +void FinalizeLine555(int sh, int line, struct PicoEState *est); extern int (*PicoScanBegin)(unsigned int num); extern int (*PicoScanEnd)(unsigned int num); -extern int DrawScanline; #define MAX_LINE_SPRITES 29 extern unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES]; extern void *DrawLineDestBase; @@ -861,7 +870,7 @@ void p32x_sh2_poll_event(SH2 *sh2, unsigned int flags, unsigned int m68k_cycles) // 32x/draw.c void PicoDrawSetOutFormat32x(pdso_t which, int use_32x_line_mode); -void FinalizeLine32xRGB555(int sh, int line); +void FinalizeLine32xRGB555(int sh, int line, struct PicoEState *est); void PicoDraw32xLayer(int offs, int lines, int mdbg); void PicoDraw32xLayerMdOnly(int offs, int lines); extern int (*PicoScan32xBegin)(unsigned int num); diff --git a/pico/pico_int_o32.h b/pico/pico_int_o32.h new file mode 100644 index 00000000..1cdc6b58 --- /dev/null +++ b/pico/pico_int_o32.h @@ -0,0 +1,5 @@ +/* autogenerated by ./tools/mkoffsets, do not edit */ +#define OFS_DrawScanline 0x00 +#define OFS_rendstatus 0x04 +#define OFS_Pico_video 0x08 +#define OFS_Pico_vram 0x0c diff --git a/pico/videoport.c b/pico/videoport.c index 61f7f18e..1e67ddb6 100644 --- a/pico/videoport.c +++ b/pico/videoport.c @@ -36,7 +36,7 @@ static void VideoWrite(u16 d) case 1: if(a&1) d=(u16)((d<<8)|(d>>8)); // If address is odd, bytes are swapped (which game needs this?) Pico.vram [(a>>1)&0x7fff]=d; if (a - ((unsigned)(Pico.video.reg[5]&0x7f) << 9) < 0x400) - rendstatus |= PDRAW_DIRTY_SPRITES; + Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES; break; case 3: Pico.m.dirtyPal = 1; Pico.cram [(a>>1)&0x003f]=d; break; // wraps (Desert Strike) @@ -172,7 +172,7 @@ static void DmaSlow(int len) //if(pd >= pdend) pd-=0x8000; // should be good for RAM, bad for ROM } } - rendstatus |= PDRAW_DIRTY_SPRITES; + Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES; break; case 3: // cram @@ -241,7 +241,7 @@ static void DmaCopy(int len) } // remember addr Pico.video.addr=a; - rendstatus |= PDRAW_DIRTY_SPRITES; + Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES; } // check: Contra, Megaman @@ -280,7 +280,7 @@ static void DmaFill(int data) // update length Pico.video.reg[0x13] = Pico.video.reg[0x14] = 0; // Dino Dini's Soccer (E) (by Haze) - rendstatus |= PDRAW_DIRTY_SPRITES; + Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES; } static void CommandDma(void) @@ -319,7 +319,7 @@ static void CommandChange(void) static void DrawSync(int blank_on) { if (Pico.m.scanline < 224 && !(PicoOpt & POPT_ALT_RENDERER) && - !PicoSkipFrame && DrawScanline <= Pico.m.scanline) { + !PicoSkipFrame && Pico.est.DrawScanline <= Pico.m.scanline) { //elprintf(EL_ANOMALY, "sync"); PicoDrawSync(Pico.m.scanline, blank_on); } @@ -412,7 +412,7 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) goto update_irq; case 0x05: //elprintf(EL_STATUS, "spritep moved to %04x", (unsigned)(Pico.video.reg[5]&0x7f) << 9); - if (d^dold) rendstatus |= PDRAW_SPRITES_MOVED; + if (d^dold) Pico.est.rendstatus |= PDRAW_SPRITES_MOVED; break; case 0x0c: // renderers should update their palettes if sh/hi mode is changed diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 244f15d9..3121a6ae 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -310,7 +310,7 @@ static int make_local_pal_md(int fast_mode) localPal[0xf0] = 0x00ffffff; pallen = 0x100; } - else if (rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes + else if (Pico.est.rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes bgr444_to_rgb32(localPal+0x40, HighPal); bgr444_to_rgb32(localPal+0x80, HighPal+0x40); } diff --git a/platform/psp/emu.c b/platform/psp/emu.c index 5a2e8809..8deb7fd3 100644 --- a/platform/psp/emu.c +++ b/platform/psp/emu.c @@ -223,7 +223,7 @@ static void do_pal_update(int allow_sh, int allow_as) localPal[0xe0] = 0; localPal[0xf0] = 0x001f; } - else if (allow_as && (rendstatus & PDRAW_SPR_LO_ON_HI)) + else if (allow_as && (Pico.est.rendstatus & PDRAW_SPR_LO_ON_HI)) { memcpy32((int *)dpal+0x80/2, (void *)localPal, 0x40*2/4); } @@ -250,7 +250,7 @@ static void EmuScanPrepare(void) if (Pico.m.dirtyPal) do_pal_update(1, 1); - if ((rendstatus & PDRAW_SPR_LO_ON_HI) && !(Pico.video.reg[0xC]&8)) + if ((Pico.est.rendstatus & PDRAW_SPR_LO_ON_HI) && !(Pico.video.reg[0xC]&8)) amips_clut_f = amips_clut_6bit; else amips_clut_f = amips_clut; } diff --git a/tools/Makefile b/tools/Makefile index 0c126cc1..28b748d4 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,6 +1,6 @@ CFLAGS = -Wall -ggdb -TARGETS = amalgamate textfilter +TARGETS = amalgamate textfilter mkoffsets OBJS = $(addsuffix .o,$(TARGETS)) all: $(TARGETS) @@ -8,3 +8,6 @@ all: $(TARGETS) clean: $(RM) $(TARGETS) $(OBJS) +mkoffsets: CFLAGS += -m32 -I.. + +.PHONY: clean all diff --git a/tools/mkoffsets.c b/tools/mkoffsets.c new file mode 100644 index 00000000..4044ad3d --- /dev/null +++ b/tools/mkoffsets.c @@ -0,0 +1,31 @@ +#include +#include + +#include "../pico/pico_int.h" + +#define DUMP(f, field) \ + fprintf(f, "#define %-20s 0x%02x\n", \ + "OFS_" #field, \ + (int)offsetof(struct PicoEState, field)) + +int main(int argc, char *argv[]) +{ + char buf[128]; + FILE *f; + + snprintf(buf, sizeof(buf), "pico/pico_int_o%d.h", sizeof(void *) * 8); + f = fopen(buf, "w"); + if (!f) { + perror("fopen"); + return 1; + } + + fprintf(f, "/* autogenerated by %s, do not edit */\n", argv[0]); + DUMP(f, DrawScanline); + DUMP(f, rendstatus); + DUMP(f, Pico_video); + DUMP(f, Pico_vram); + fclose(f); + + return 0; +} From 4981de9ce79d0aa80222f8583667bf2fbf2265f2 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 6 Aug 2017 19:23:20 +0300 Subject: [PATCH 107/124] eliminate texrels (wip2) --- pico/32x/32x_draw.c | 12 +++--- pico/debug.c | 5 +-- pico/draw.c | 68 +++++++++++++++-------------- pico/draw_arm.S | 95 +++++++++-------------------------------- pico/mode4.c | 16 +++---- pico/pico.c | 3 ++ pico/pico.h | 2 - pico/pico_int.h | 7 ++- pico/pico_int_o32.h | 8 +++- platform/gizmondo/emu.c | 11 +---- platform/gp2x/emu.c | 10 ++--- platform/psp/emu.c | 8 ++-- tools/mkoffsets.c | 4 ++ 13 files changed, 102 insertions(+), 147 deletions(-) diff --git a/pico/32x/32x_draw.c b/pico/32x/32x_draw.c index 007ef20c..171a6967 100644 --- a/pico/32x/32x_draw.c +++ b/pico/32x/32x_draw.c @@ -85,9 +85,9 @@ static void convert_pal555(int invert_prio) // this is almost never used (Wiz and menu bg gen only) void FinalizeLine32xRGB555(int sh, int line, struct PicoEState *est) { - unsigned short *pd = DrawLineDest; + unsigned short *pd = est->DrawLineDest; unsigned short *pal = Pico32xMem->pal_native; - unsigned char *pmd = HighCol + 8; + unsigned char *pmd = est->HighCol + 8; unsigned short *dram, *p32x; unsigned char mdbg; @@ -130,7 +130,7 @@ void FinalizeLine32xRGB555(int sh, int line, struct PicoEState *est) #define PICOSCAN_PRE \ PicoScan32xBegin(l + (lines_sft_offs & 0xff)); \ - dst = DrawLineDest; \ + dst = Pico.est.DrawLineDest; \ #define PICOSCAN_POST \ PicoScan32xEnd(l + (lines_sft_offs & 0xff)); \ @@ -228,7 +228,7 @@ void PicoDraw32xLayer(int offs, int lines, int md_bg) int lines_sft_offs; int which_func; - DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement; + Pico.est.DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement; dram = Pico32xMem->dram[Pico32x.vdp_regs[0x0a/2] & P32XV_FS]; if (Pico32xDrawMode == PDM32X_BOTH) { @@ -266,7 +266,7 @@ do_it: if (Pico32x.vdp_regs[2 / 2] & P32XV_SFT) lines_sft_offs |= 1 << 8; - do_loop[which_func](DrawLineDest, dram, lines_sft_offs, md_bg); + do_loop[which_func](Pico.est.DrawLineDest, dram, lines_sft_offs, md_bg); } // mostly unused, games tend to keep 32X layer on @@ -292,7 +292,7 @@ void PicoDraw32xLayerMdOnly(int offs, int lines) for (l = 0; l < lines; l++) { if (have_scan) { PicoScan32xBegin(l + offs); - dst = (unsigned short*)DrawLineDest + poffs; + dst = (unsigned short*)Pico.est.DrawLineDest + poffs; } for (p = 0; p < plen; p += 4) { dst[p + 0] = pal[*pmd++]; diff --git a/pico/debug.c b/pico/debug.c index 91bff566..7cc3c325 100644 --- a/pico/debug.c +++ b/pico/debug.c @@ -20,13 +20,12 @@ char *PDebugMain(void) { struct PicoVideo *pv=&Pico.video; unsigned char *reg=pv->reg, r; - extern int HighPreSpr[]; int i, sprites_lo, sprites_hi; char *dstrp; sprites_lo = sprites_hi = 0; - for (i = 0; HighPreSpr[i] != 0; i+=2) - if (HighPreSpr[i+1] & 0x8000) + for (i = 0; Pico.est.HighPreSpr[i] != 0; i+=2) + if (Pico.est.HighPreSpr[i+1] & 0x8000) sprites_hi++; else sprites_lo++; diff --git a/pico/draw.c b/pico/draw.c index 76820a92..e4bff25a 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -35,18 +35,16 @@ int (*PicoScanBegin)(unsigned int num) = NULL; int (*PicoScanEnd) (unsigned int num) = NULL; static unsigned char DefHighCol[8+320+8]; -unsigned char *HighCol = DefHighCol; static unsigned char *HighColBase = DefHighCol; static int HighColIncrement; static unsigned int DefOutBuff[320*2/2]; -void *DrawLineDest = DefOutBuff; // pointer to dest buffer where to draw this line to void *DrawLineDestBase = DefOutBuff; int DrawLineDestIncrement; static int HighCacheA[41+1]; // caches for high layers static int HighCacheB[41+1]; -int HighPreSpr[80*2+1]; // slightly preprocessed sprites +static int HighPreSpr[80*2+1]; // slightly preprocessed sprites #define SPRL_HAVE_HI 0x80 // have hi priority sprites #define SPRL_HAVE_LO 0x40 // *lo* @@ -100,7 +98,7 @@ void blockcpy_or(void *dst, void *src, size_t n, int pat) #define TileNormMaker(funcname,pix_func) \ static int funcname(int sx,int addr,int pal) \ { \ - unsigned char *pd = HighCol+sx; \ + unsigned char *pd = Pico.est.HighCol+sx; \ unsigned int pack=0; unsigned int t=0; \ \ pack=*(unsigned int *)(Pico.vram+addr); /* Get 8 pixels */ \ @@ -124,7 +122,7 @@ static int funcname(int sx,int addr,int pal) \ #define TileFlipMaker(funcname,pix_func) \ static int funcname(int sx,int addr,int pal) \ { \ - unsigned char *pd = HighCol+sx; \ + unsigned char *pd = Pico.est.HighCol+sx; \ unsigned int pack=0; unsigned int t=0; \ \ pack=*(unsigned int *)(Pico.vram+addr); /* Get 8 pixels */ \ @@ -515,7 +513,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh, pal=((code>>9)&0x30); if (prio) { - int *zb = (int *)(HighCol+8+(tilex<<3)); + int *zb = (int *)(est->HighCol+8+(tilex<<3)); *zb++ &= 0xbfbfbfbf; *zb &= 0xbfbfbfbf; } else { @@ -541,7 +539,7 @@ static void DrawTilesFromCacheShPrep(void) // as some layer has covered whole line with hi priority tiles, // we can process whole line and then act as if sh/hi mode was off, // but leave lo pri op sprite markers alone - int c = 320/4, *zb = (int *)(HighCol+8); + int c = 320/4, *zb = (int *)(Pico.est.HighCol+8); Pico.est.rendstatus |= PDRAW_SHHI_DONE; while (c--) { @@ -591,7 +589,7 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est addr=(code&0x7ff)<<4; addr+=(unsigned int)code>>25; // y offset into tile dx=(code>>16)&0x1ff; - zb = HighCol+dx; + zb = est->HighCol+dx; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; @@ -607,7 +605,7 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est last_cut_tile: { unsigned int t, pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels - unsigned char *pd = HighCol+dx; + unsigned char *pd = est->HighCol+dx; if (!pack) return; if (code&0x0800) { @@ -812,7 +810,7 @@ static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est) int offs, delta, width, height, row; offs = (p[cnt] & 0x7f) * 2; - sprite = HighPreSpr + offs; + sprite = est->HighPreSpr + offs; code = sprite[1]; pal = (code>>9)&0x30; @@ -936,7 +934,7 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh) /* nasty 1: remove 'sprite' flags */ { - int c = 320/4/4, *zb = (int *)(HighCol+8); + int c = 320/4/4, *zb = (int *)(Pico.est.HighCol+8); while (c--) { *zb++ &= 0x7f7f7f7f; *zb++ &= 0x7f7f7f7f; @@ -1147,7 +1145,7 @@ static void DrawAllSprites(unsigned char *sprited, int prio, int sh, // -------------------------------------------- -void BackFill(int reg7, int sh) +void BackFill(int reg7, int sh, struct PicoEState *est) { unsigned int back; @@ -1157,7 +1155,7 @@ void BackFill(int reg7, int sh) back|=back<<8; back|=back<<16; - memset32((int *)(HighCol+8), back, 320/4); + memset32((int *)(est->HighCol+8), back, 320/4); } #endif @@ -1204,10 +1202,10 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est) } } -void FinalizeLine555(int sh, int line) +void FinalizeLine555(int sh, int line, struct PicoEState *est) { - unsigned short *pd=DrawLineDest; - unsigned char *ps=HighCol+8; + unsigned short *pd=est->DrawLineDest; + unsigned char *ps=est->HighCol+8; unsigned short *pal=HighPal; int len; @@ -1242,7 +1240,7 @@ void FinalizeLine555(int sh, int line) static void FinalizeLine8bit(int sh, int line, struct PicoEState *est) { - unsigned char *pd = DrawLineDest; + unsigned char *pd = est->DrawLineDest; int len, rs = est->rendstatus; static int dirty_count; @@ -1271,12 +1269,12 @@ static void FinalizeLine8bit(int sh, int line, struct PicoEState *est) if (!sh && (rs & PDRAW_SONIC_MODE)) { if (dirty_count >= 11) { - blockcpy_or(pd, HighCol+8, len, 0x80); + blockcpy_or(pd, est->HighCol+8, len, 0x80); } else { - blockcpy_or(pd, HighCol+8, len, 0x40); + blockcpy_or(pd, est->HighCol+8, len, 0x40); } } else { - blockcpy(pd, HighCol+8, len); + blockcpy(pd, est->HighCol+8, len); } } @@ -1403,8 +1401,8 @@ PICO_INTERNAL void PicoFrameStart(void) rendstatus_old = Pico.est.rendstatus; } - HighCol = HighColBase + offs * HighColIncrement; - DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement; + Pico.est.HighCol = HighColBase + offs * HighColIncrement; + Pico.est.DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement; Pico.est.DrawScanline = 0; skip_next_line = 0; @@ -1421,7 +1419,7 @@ static void DrawBlankedLine(int line, int offs, int sh, int bgc) if (PicoScanBegin != NULL) PicoScanBegin(line + offs); - BackFill(bgc, sh); + BackFill(bgc, sh, &Pico.est); if (FinalizeLine != NULL) FinalizeLine(sh, line, &Pico.est); @@ -1429,8 +1427,8 @@ static void DrawBlankedLine(int line, int offs, int sh, int bgc) if (PicoScanEnd != NULL) PicoScanEnd(line + offs); - HighCol += HighColIncrement; - DrawLineDest = (char *)DrawLineDest + DrawLineDestIncrement; + Pico.est.HighCol += HighColIncrement; + Pico.est.DrawLineDest = (char *)Pico.est.DrawLineDest + DrawLineDestIncrement; } static void PicoLine(int line, int offs, int sh, int bgc) @@ -1452,7 +1450,7 @@ static void PicoLine(int line, int offs, int sh, int bgc) } // Draw screen: - BackFill(bgc, sh); + BackFill(bgc, sh, &Pico.est); if (Pico.video.reg[1]&0x40) DrawDisplay(sh); @@ -1462,8 +1460,8 @@ static void PicoLine(int line, int offs, int sh, int bgc) if (PicoScanEnd != NULL) skip_next_line = PicoScanEnd(line + offs); - HighCol += HighColIncrement; - DrawLineDest = (char *)DrawLineDest + DrawLineDestIncrement; + Pico.est.HighCol += HighColIncrement; + Pico.est.DrawLineDest = (char *)Pico.est.DrawLineDest + DrawLineDestIncrement; } void PicoDrawSync(int to, int blank_last_line) @@ -1539,7 +1537,7 @@ void PicoDrawSetOutBuf(void *dest, int increment) { DrawLineDestBase = dest; DrawLineDestIncrement = increment; - DrawLineDest = (unsigned char*)DrawLineDestBase + Pico.est.DrawScanline * increment; + Pico.est.DrawLineDest = (unsigned char*)DrawLineDestBase + Pico.est.DrawScanline * increment; } void PicoDrawSetInternalBuf(void *dest, int increment) @@ -1547,7 +1545,7 @@ void PicoDrawSetInternalBuf(void *dest, int increment) if (dest != NULL) { HighColBase = dest; HighColIncrement = increment; - HighCol = HighColBase + Pico.est.DrawScanline * increment; + Pico.est.HighCol = HighColBase + Pico.est.DrawScanline * increment; } else { HighColBase = DefHighCol; @@ -1572,4 +1570,12 @@ void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned in } } -// vim:ts=4:sw=4:expandtab +void PicoDrawInit(void) +{ + Pico.est.DrawLineDest = DefOutBuff; + Pico.est.HighCol = HighColBase; + Pico.est.HighPreSpr = HighPreSpr; + rendstatus_old = -1; +} + +// vim:ts=2:sw=2:expandtab diff --git a/pico/draw_arm.S b/pico/draw_arm.S index 2c1db104..23c522b0 100644 --- a/pico/draw_arm.S +++ b/pico/draw_arm.S @@ -10,15 +10,7 @@ #include "pico_int_o32.h" -.extern PicoOpt -.extern HighCol -.extern HighSprZ -.extern HighPreSpr -.extern DrawLineDest .extern DrawStripInterlace -.extern HighCacheS_ptr - -.equiv OVERRIDE_HIGHCOL, 1 .equ PDRAW_SPRITES_MOVED, (1<<0) .equ PDRAW_WND_DIFF_PRIO, (1<<1) @@ -395,17 +387,12 @@ DrawLayer: sub r10,r10,r9, lsl #16 @ cells-=cellskip @ cache some stuff to avoid mem access -.if OVERRIDE_HIGHCOL - ldr r11,=HighCol + ldr r11,[sp, #9*4] @ est mov r0, #0xf - ldr r11,[r11] -.else - ldr r11,=HighCol - mov r0, #0xf -.endif + ldr r11,[r11, #OFS_HighCol] mvn r9, #0 @ r9=prevcode=-1 - add r1, r11, r7 @ r1=pdest + add r1, r11, r7 @ r1=pdest @ r4 & r7 are scratch in this loop @@ -548,14 +535,9 @@ DrawLayer: add r10,r10,r9, lsl #16 @ cell+=cellskip @ cache some stuff to avoid mem access -.if OVERRIDE_HIGHCOL - ldr r11,=HighCol + ldr r11,[sp, #9*4] @ est mov r0, #0xf - ldr r11,[r11] -.else - ldr r11,=HighCol - mov r0, #0xf -.endif + ldr r11,[r11, #OFS_HighCol] mvn r9, #0 @ r9=prevcode=-1 add r1, r11, r7 @ r1=pdest @@ -722,23 +704,17 @@ DrawLayer: @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +@ void BackFill(int reg7, int sh, struct PicoEState *est) -.global BackFill @ int reg7, int sh +.global BackFill BackFill: stmfd sp!, {r4-r9,lr} -.if OVERRIDE_HIGHCOL - ldr lr, =HighCol mov r0, r0, lsl #26 - ldr lr, [lr] + ldr lr, [r2, #OFS_HighCol] mov r0, r0, lsr #26 add lr, lr, #8 -.else - ldr lr, =(HighCol+8) - mov r0, r0, lsl #26 - mov r0, r0, lsr #26 -.endif orr r0, r0, r1, lsl #6 orr r0, r0, r0, lsl #8 @@ -764,8 +740,8 @@ BackFill: stmia lr!, {r0-r7} stmia lr!, {r0-r7} - ldmfd sp!, {r4-r9,r12} - bx r12 + ldmfd sp!, {r4-r9,lr} + bx lr @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ -778,14 +754,8 @@ DrawTilesFromCache: stmfd sp!, {r4-r9,r11,lr} @ cache some stuff to avoid mem access -.if OVERRIDE_HIGHCOL - ldr r11,=HighCol + ldr r11,[r3, #OFS_HighCol] mov r12,#0xf - ldr r11,[r11] -.else - ldr r11,=HighCol - mov r12,#0xf -.endif ldr lr, [r3, #OFS_Pico_vram] mov r9, r3 @ est @@ -964,14 +934,8 @@ DrawSpritesSHi: add r10,r0, #3 @ r10=HighLnSpr end add r10,r10,r3 @ r10=HighLnSpr end -.if OVERRIDE_HIGHCOL - ldr r11,=HighCol + ldr r11,[r1, #OFS_HighCol] mov r12,#0xf - ldr r11,[r11] -.else - ldr r11,=HighCol - mov r12,#0xf -.endif ldr lr, [r1, #OFS_Pico_vram] @@ -979,7 +943,7 @@ DrawSpriteSHi: @ draw next sprite ldrb r0, [r10,#-1]! ldr r7, [sp] @ est - ldr r1, =HighPreSpr + ldr r1, [r7, #OFS_HighPreSpr] cmp r0, #0xff ldmeqfd sp!, {r1,r4-r11,pc} @ end of list and r0, r0, #0x7f @@ -1159,14 +1123,8 @@ das_no_prep: add r10,r0, #3 add r10,r10,r2 @ r10=HighLnSpr end -.if OVERRIDE_HIGHCOL - ldr r11,=HighCol + ldr r11,[r3, #OFS_HighCol] mov r12,#0xf - ldr r11,[r11] -.else - ldr r11,=HighCol - mov r12,#0xf -.endif ldr lr, [r3, #OFS_Pico_vram] @ + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: horiz. size @@ -1182,7 +1140,7 @@ DrawSprite: ldmeqfd sp!, {r1,r3-r11,pc} @ end of list cmp r2, r8, lsr #1 bne DrawSprite @ wrong priority - ldr r1, =HighPreSpr + ldr r1, [r7, #OFS_HighPreSpr] and r0, r0, #0x7f add r0, r1, r0, lsl #3 @@ -1352,17 +1310,10 @@ DrawWindow: sub r8, r1, r0 @ cache some stuff to avoid mem access -.if OVERRIDE_HIGHCOL - ldr r11,=HighCol + ldr r11, [r11, #OFS_HighCol] mov r8, r8, lsl #1 @ cells - ldr r11,[r11] - mvn r9, #0 @ r9=prevcode=-1 add r11,r11,#8 -.else - ldr r11,=(HighCol+8) - mov r8, r8, lsl #1 @ cells mvn r9, #0 @ r9=prevcode=-1 -.endif add r1, r11, r0, lsl #4 @ r1=pdest mov r0, #0xf b .dwloop_enter @@ -1632,17 +1583,9 @@ FinalizeLineRGB555_pal_done: tstne r12,#PDRAW_ACC_SPRITES movne lr, #0x3f -.if OVERRIDE_HIGHCOL - ldr r1, =HighCol - ldr r0, =DrawLineDest - ldr r1, [r1] - ldr r0, [r0] + ldr r1, [r10, #OFS_HighCol] + ldr r0, [r10, #OFS_DrawLineDest] add r1, r1, #8 -.else - ldr r0, =DrawLineDest - ldr r1, =(HighCol+8) - ldr r0, [r0] -.endif ldrb r12, [r8, #12] mov lr, lr, lsl #1 @@ -1650,7 +1593,7 @@ FinalizeLineRGB555_pal_done: tst r12, #1 movne r2, #320/8 @ len bne .fl_no32colRGB555 - ldr r4, =PicoOpt + ldr r4, [r10, #OFS_PicoOpt] mov r2, #256/8 ldr r4, [r4] tst r4, #0x4000 diff --git a/pico/mode4.c b/pico/mode4.c index c945f6fe..1f9adff5 100644 --- a/pico/mode4.c +++ b/pico/mode4.c @@ -28,7 +28,7 @@ static int screen_offset; static int TileNormM4(int sx, int addr, int pal) { - unsigned char *pd = HighCol + sx; + unsigned char *pd = Pico.est.HighCol + sx; unsigned int pack, t; pack = *(unsigned int *)(Pico.vram + addr); /* Get 4 bitplanes / 8 pixels */ @@ -50,7 +50,7 @@ static int TileNormM4(int sx, int addr, int pal) static int TileFlipM4(int sx,int addr,int pal) { - unsigned char *pd = HighCol + sx; + unsigned char *pd = Pico.est.HighCol + sx; unsigned int pack, t; pack = *(unsigned int *)(Pico.vram + addr); /* Get 4 bitplanes / 8 pixels */ @@ -192,7 +192,7 @@ static void DrawDisplayM4(int scanline) if (pv->reg[0] & 0x20) // first column masked - ((int *)HighCol)[2] = ((int *)HighCol)[3] = 0xe0e0e0e0; + ((int *)Pico.est.HighCol)[2] = ((int *)Pico.est.HighCol)[3] = 0xe0e0e0e0; } void PicoFrameStartMode4(void) @@ -219,7 +219,7 @@ void PicoFrameStartMode4(void) rendlines = lines; } - DrawLineDest = (char *)DrawLineDestBase + screen_offset * DrawLineDestIncrement; + Pico.est.DrawLineDest = (char *)DrawLineDestBase + screen_offset * DrawLineDestIncrement; } void PicoLineMode4(int line) @@ -233,7 +233,7 @@ void PicoLineMode4(int line) skip_next_line = PicoScanBegin(line + screen_offset); // Draw screen: - BackFill(Pico.video.reg[7] & 0x0f, 0); + BackFill(Pico.video.reg[7] & 0x0f, 0, &Pico.est); if (Pico.video.reg[1] & 0x40) DrawDisplayM4(line); @@ -243,7 +243,7 @@ void PicoLineMode4(int line) if (PicoScanEnd != NULL) skip_next_line = PicoScanEnd(line + screen_offset); - DrawLineDest = (char *)DrawLineDest + DrawLineDestIncrement; + Pico.est.DrawLineDest = (char *)Pico.est.DrawLineDest + DrawLineDestIncrement; } void PicoDoHighPal555M4(void) @@ -282,12 +282,12 @@ static void FinalizeLineRGB555M4(int line) static void FinalizeLine8bitM4(int line) { - unsigned char *pd = DrawLineDest; + unsigned char *pd = Pico.est.DrawLineDest; if (!(PicoOpt & POPT_DIS_32C_BORDER)) pd += 32; - memcpy32((int *)pd, (int *)(HighCol+8), 256/4); + memcpy32((int *)pd, (int *)(Pico.est.HighCol+8), 256/4); } void PicoDrawSetOutputMode4(pdso_t which) diff --git a/pico/pico.c b/pico/pico.c index e14c5037..b6a083d0 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -39,6 +39,7 @@ void PicoInit(void) Pico.est.Pico_video = &Pico.video; Pico.est.Pico_vram = Pico.vram; + Pico.est.PicoOpt = &PicoOpt; // Init CPUs: SekInit(); @@ -47,6 +48,8 @@ void PicoInit(void) PicoInitMCD(); PicoSVPInit(); Pico32xInit(); + + PicoDrawInit(); } // to be called once on emu exit diff --git a/pico/pico.h b/pico/pico.h index d899b1a8..98e4c785 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -172,8 +172,6 @@ typedef enum void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode); void PicoDrawSetOutBuf(void *dest, int increment); void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned int num)); -extern void *DrawLineDest; -extern unsigned char *HighCol; // utility #ifdef _ASM_DRAW_C void vidConvCpyRGB565(void *to, void *from, int pixels); diff --git a/pico/pico_int.h b/pico/pico_int.h index 427460e3..b9a4418f 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -338,8 +338,12 @@ struct PicoEState { int DrawScanline; int rendstatus; + void *DrawLineDest; // draw estination + unsigned char *HighCol; + int *HighPreSpr; void *Pico_video; void *Pico_vram; + int *PicoOpt; }; // some assembly stuff depend on these, do not touch! @@ -589,9 +593,10 @@ extern void (*PicoCartUnloadHook)(void); int CM_compareRun(int cyc, int is_sub); // draw.c +void PicoDrawInit(void); PICO_INTERNAL void PicoFrameStart(void); void PicoDrawSync(int to, int blank_last_line); -void BackFill(int reg7, int sh); +void BackFill(int reg7, int sh, struct PicoEState *est); void FinalizeLine555(int sh, int line, struct PicoEState *est); extern int (*PicoScanBegin)(unsigned int num); extern int (*PicoScanEnd)(unsigned int num); diff --git a/pico/pico_int_o32.h b/pico/pico_int_o32.h index 1cdc6b58..4094697d 100644 --- a/pico/pico_int_o32.h +++ b/pico/pico_int_o32.h @@ -1,5 +1,9 @@ /* autogenerated by ./tools/mkoffsets, do not edit */ #define OFS_DrawScanline 0x00 #define OFS_rendstatus 0x04 -#define OFS_Pico_video 0x08 -#define OFS_Pico_vram 0x0c +#define OFS_DrawLineDest 0x08 +#define OFS_HighCol 0x0c +#define OFS_HighPreSpr 0x10 +#define OFS_Pico_video 0x14 +#define OFS_Pico_vram 0x18 +#define OFS_PicoOpt 0x1c diff --git a/platform/gizmondo/emu.c b/platform/gizmondo/emu.c index 3115ebd3..3a6c861b 100644 --- a/platform/gizmondo/emu.c +++ b/platform/gizmondo/emu.c @@ -94,7 +94,7 @@ void pemu_prep_defconfig(void) static int EmuScanBegin16(unsigned int num) { - DrawLineDest = (unsigned short *) giz_screen + 321 * num; + Pico.est.DrawLineDest = (unsigned short *) giz_screen + 321 * num; if ((currentConfig.EmuOpt&0x4000) && (num&1) == 0) // (Pico.m.frame_count&1)) return 1; // skip next line @@ -105,7 +105,7 @@ static int EmuScanBegin16(unsigned int num) static int EmuScanBegin8(unsigned int num) { // draw like the fast renderer - HighCol = gfx_buffer + 328 * num; + Pico.est.HighCol = gfx_buffer + 328 * num; return 0; } @@ -122,13 +122,6 @@ static void osd_text(int x, int y, const char *text) emu_text_out16(x, y, text); } -/* -void log1(void *p1, void *p2) -{ - lprintf("%p %p %p\n", p1, p2, DrawLineDest); -} -*/ - static void cd_leds(void) { static int old_reg = 0; diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 3121a6ae..8db33a9f 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -222,7 +222,7 @@ static unsigned char __attribute__((aligned(4))) rot_buff[320*4*2]; static int EmuScanBegin16_rot(unsigned int num) { - DrawLineDest = rot_buff + (num & 3) * 320 * 2; + Pico.est.DrawLineDest = rot_buff + (num & 3) * 320 * 2; return 0; } @@ -237,7 +237,7 @@ static int EmuScanEnd16_rot(unsigned int num) static int EmuScanBegin8_rot(unsigned int num) { - DrawLineDest = rot_buff + (num & 3) * 320; + Pico.est.DrawLineDest = rot_buff + (num & 3) * 320; return 0; } @@ -262,14 +262,14 @@ static int EmuScanBegin16_ld(unsigned int num) if (emu_scan_begin) return emu_scan_begin(ld_counter); else - DrawLineDest = (char *)g_screen_ptr + 320 * ld_counter * gp2x_current_bpp / 8; + Pico.est.DrawLineDest = (char *)g_screen_ptr + 320 * ld_counter * gp2x_current_bpp / 8; return 0; } static int EmuScanEnd16_ld(unsigned int num) { - void *oldline = DrawLineDest; + void *oldline = Pico.est.DrawLineDest; if (emu_scan_end) emu_scan_end(ld_counter); @@ -280,7 +280,7 @@ static int EmuScanEnd16_ld(unsigned int num) ld_left = ld_lines; EmuScanBegin16_ld(num); - memcpy32(DrawLineDest, oldline, 320 * gp2x_current_bpp / 8 / 4); + memcpy32(Pico.est.DrawLineDest, oldline, 320 * gp2x_current_bpp / 8 / 4); if (emu_scan_end) emu_scan_end(ld_counter); diff --git a/platform/psp/emu.c b/platform/psp/emu.c index 8deb7fd3..cb16d264 100644 --- a/platform/psp/emu.c +++ b/platform/psp/emu.c @@ -242,8 +242,8 @@ static void do_slowmode_lines(int line_to) static void EmuScanPrepare(void) { - HighCol = (unsigned char *)VRAM_CACHED_STUFF + 8; - if (!(Pico.video.reg[1]&8)) HighCol += 8*512; + Pico.est.HighCol = (unsigned char *)VRAM_CACHED_STUFF + 8; + if (!(Pico.video.reg[1]&8)) Pico.est.HighCol += 8*512; if (dynamic_palette > 0) dynamic_palette--; @@ -258,7 +258,7 @@ static void EmuScanPrepare(void) static int EmuScanSlowBegin(unsigned int num) { if (!dynamic_palette) - HighCol = (unsigned char *)VRAM_CACHED_STUFF + num * 512 + 8; + Pico.est.HighCol = (unsigned char *)VRAM_CACHED_STUFF + num * 512 + 8; return 0; } @@ -276,7 +276,7 @@ static int EmuScanSlowEnd(unsigned int num) if (dynamic_palette) { int line_len = (Pico.video.reg[12]&1) ? 320 : 256; void *dst = (char *)VRAM_STUFF + 512*240 + 512*2*num; - amips_clut_f(dst, HighCol + 8, localPal, line_len); + amips_clut_f(dst, Pico.est.HighCol + 8, localPal, line_len); } return 0; diff --git a/tools/mkoffsets.c b/tools/mkoffsets.c index 4044ad3d..e9eb3c5f 100644 --- a/tools/mkoffsets.c +++ b/tools/mkoffsets.c @@ -23,8 +23,12 @@ int main(int argc, char *argv[]) fprintf(f, "/* autogenerated by %s, do not edit */\n", argv[0]); DUMP(f, DrawScanline); DUMP(f, rendstatus); + DUMP(f, DrawLineDest); + DUMP(f, HighCol); + DUMP(f, HighPreSpr); DUMP(f, Pico_video); DUMP(f, Pico_vram); + DUMP(f, PicoOpt); fclose(f); return 0; From 36f37d2d6041b491dd5f506fb4f1778bb4218ea1 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 6 Aug 2017 19:23:36 +0300 Subject: [PATCH 108/124] some fps counter cosmetics --- platform/common/emu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/common/emu.c b/platform/common/emu.c index 7f375a3c..6f42b73d 100644 --- a/platform/common/emu.c +++ b/platform/common/emu.c @@ -1427,7 +1427,7 @@ void emu_loop(void) printf("%s\n", fpsbuff); #else if (currentConfig.EmuOpt & EOPT_SHOW_FPS) - sprintf(fpsbuff, "%02i/%02i ", frames_shown, frames_done); + snprintf(fpsbuff, 8, "%02i/%02i ", frames_shown, frames_done); #endif frames_shown = frames_done = 0; timestamp_fps_x3 += ms_to_ticks(1000) * 3; From cbf31d2c254c956a0b497e3021610ce3a5ff0748 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 6 Aug 2017 21:21:35 +0300 Subject: [PATCH 109/124] configure: allow to override SDL_CONFIG --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 96cea7e2..9ccd2da9 100755 --- a/configure +++ b/configure @@ -52,7 +52,7 @@ CC="${CC-${CROSS_COMPILE}gcc}" CXX="${CXX-${CROSS_COMPILE}g++}" AS="${AS-${CROSS_COMPILE}as}" STRIP="${STRIP-${CROSS_COMPILE}strip}" -SDL_CONFIG="`$CC --print-sysroot 2> /dev/null || true`/usr/bin/sdl-config" +test -n "$SDL_CONFIG" || SDL_CONFIG="`$CC --print-sysroot 2> /dev/null || true`/usr/bin/sdl-config" MAIN_LDLIBS="$LDLIBS -lm" config_mak="config.mak" From 7b4813faa6802f3aa07e9daef4aff729d8f78623 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 6 Aug 2017 22:25:26 +0300 Subject: [PATCH 110/124] eliminate texrels, part 3 --- pico/32x/32x_draw.c | 18 +++++----- pico/debug.c | 13 ++++---- pico/draw.c | 17 +++++----- pico/draw2.c | 73 ++++++++++++++++++++++------------------- pico/draw2_arm.S | 64 +++++++++++++++++++----------------- pico/draw_arm.S | 6 ++-- pico/mode4.c | 4 +-- pico/pico.c | 1 + pico/pico.h | 2 -- pico/pico_int.h | 5 ++- pico/pico_int_o32.h | 2 ++ platform/gizmondo/emu.c | 6 ++-- platform/gp2x/emu.c | 12 +++---- platform/linux/emu.c | 6 ++-- platform/psp/emu.c | 6 ++-- tools/mkoffsets.c | 2 ++ 16 files changed, 125 insertions(+), 112 deletions(-) diff --git a/pico/32x/32x_draw.c b/pico/32x/32x_draw.c index 171a6967..e33cb373 100644 --- a/pico/32x/32x_draw.c +++ b/pico/32x/32x_draw.c @@ -141,9 +141,9 @@ static void do_loop_dc##name(unsigned short *dst, \ unsigned short *dram, int lines_sft_offs, int mdbg) \ { \ int inv_bit = (Pico32x.vdp_regs[0] & P32XV_PRI) ? 0x8000 : 0; \ - unsigned char *pmd = PicoDraw2FB + \ + unsigned char *pmd = Pico.est.Draw2FB + \ 328 * (lines_sft_offs & 0xff) + 8; \ - unsigned short *palmd = HighPal; \ + unsigned short *palmd = Pico.est.HighPal; \ unsigned short *p32x; \ int lines = lines_sft_offs >> 16; \ int l; \ @@ -161,9 +161,9 @@ static void do_loop_pp##name(unsigned short *dst, \ unsigned short *dram, int lines_sft_offs, int mdbg) \ { \ unsigned short *pal = Pico32xMem->pal_native; \ - unsigned char *pmd = PicoDraw2FB + \ + unsigned char *pmd = Pico.est.Draw2FB + \ 328 * (lines_sft_offs & 0xff) + 8; \ - unsigned short *palmd = HighPal; \ + unsigned short *palmd = Pico.est.HighPal; \ unsigned char *p32x; \ int lines = lines_sft_offs >> 16; \ int l; \ @@ -182,9 +182,9 @@ static void do_loop_rl##name(unsigned short *dst, \ unsigned short *dram, int lines_sft_offs, int mdbg) \ { \ unsigned short *pal = Pico32xMem->pal_native; \ - unsigned char *pmd = PicoDraw2FB + \ + unsigned char *pmd = Pico.est.Draw2FB + \ 328 * (lines_sft_offs & 0xff) + 8; \ - unsigned short *palmd = HighPal; \ + unsigned short *palmd = Pico.est.HighPal; \ unsigned short *p32x; \ int lines = lines_sft_offs >> 16; \ int l; \ @@ -274,8 +274,8 @@ void PicoDraw32xLayerMdOnly(int offs, int lines) { int have_scan = PicoScan32xBegin != NULL && PicoScan32xEnd != NULL; unsigned short *dst = (void *)((char *)DrawLineDestBase + offs * DrawLineDestIncrement); - unsigned char *pmd = PicoDraw2FB + 328 * offs + 8; - unsigned short *pal = HighPal; + unsigned char *pmd = Pico.est.Draw2FB + 328 * offs + 8; + unsigned short *pal = Pico.est.HighPal; int poffs = 0, plen = 320; int l, p; @@ -322,7 +322,7 @@ void PicoDrawSetOutFormat32x(pdso_t which, int use_32x_line_mode) } // use the same layout as alt renderer - PicoDrawSetInternalBuf(PicoDraw2FB, 328); + PicoDrawSetInternalBuf(Pico.est.Draw2FB, 328); Pico32xDrawMode = (which == PDF_RGB555) ? PDM32X_32X_ONLY : PDM32X_BOTH; } diff --git a/pico/debug.c b/pico/debug.c index 7cc3c325..efcd3fde 100644 --- a/pico/debug.c +++ b/pico/debug.c @@ -196,29 +196,30 @@ void PDebugShowSpriteStats(unsigned short *screen, int stride) void PDebugShowPalette(unsigned short *screen, int stride) { + struct PicoEState *est = &Pico.est; int x, y; Pico.m.dirtyPal = 1; if (PicoAHW & PAHW_SMS) PicoDoHighPal555M4(); else - PicoDoHighPal555(1, 0, &Pico.est); + PicoDoHighPal555(1, 0, est); Pico.m.dirtyPal = 1; screen += 16*stride+8; for (y = 0; y < 8*4; y++) for (x = 0; x < 8*16; x++) - screen[x + y*stride] = HighPal[x/8 + (y/8)*16]; + screen[x + y*stride] = est->HighPal[x/8 + (y/8)*16]; screen += 160; for (y = 0; y < 8*4; y++) for (x = 0; x < 8*16; x++) - screen[x + y*stride] = HighPal[(x/8 + (y/8)*16) | 0x40]; + screen[x + y*stride] = est->HighPal[(x/8 + (y/8)*16) | 0x40]; screen += stride*48; for (y = 0; y < 8*4; y++) for (x = 0; x < 8*16; x++) - screen[x + y*stride] = HighPal[(x/8 + (y/8)*16) | 0x80]; + screen[x + y*stride] = est->HighPal[(x/8 + (y/8)*16) | 0x80]; } #if defined(DRAW2_OVERRIDE_LINE_WIDTH) @@ -263,9 +264,9 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which) PicoFrameFull(); for (y = 0; y < 8*4; y++) { - unsigned char *ps = PicoDraw2FB + DRAW2_LINE_WIDTH*y + 8; + unsigned char *ps = Pico.est.Draw2FB + DRAW2_LINE_WIDTH*y + 8; for (x = 0; x < 8*4; x++) - if (ps[x]) screen[x] = HighPal[ps[x]], ps[x] = 0; + if (ps[x]) screen[x] = Pico.est.HighPal[ps[x]], ps[x] = 0; screen += stride; } diff --git a/pico/draw.c b/pico/draw.c index e4bff25a..cf638e90 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -1161,8 +1161,6 @@ void BackFill(int reg7, int sh, struct PicoEState *est) // -------------------------------------------- -unsigned short HighPal[0x100]; - #ifndef _ASM_DRAW_C void PicoDoHighPal555(int sh, int line, struct PicoEState *est) { @@ -1172,7 +1170,7 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est) Pico.m.dirtyPal = 0; spal = (void *)Pico.cram; - dpal = (void *)HighPal; + dpal = (void *)est->HighPal; for (i = 0; i < 0x40 / 2; i++) { t = spal[i]; @@ -1206,7 +1204,7 @@ void FinalizeLine555(int sh, int line, struct PicoEState *est) { unsigned short *pd=est->DrawLineDest; unsigned char *ps=est->HighCol+8; - unsigned short *pal=HighPal; + unsigned short *pal=est->HighPal; int len; if (Pico.m.dirtyPal) @@ -1253,9 +1251,9 @@ static void FinalizeLine8bit(int sh, int line, struct PicoEState *est) rs |= PDRAW_SONIC_MODE; est->rendstatus = rs; if (dirty_count == 3) { - blockcpy(HighPal, Pico.cram, 0x40*2); + blockcpy(est->HighPal, Pico.cram, 0x40*2); } else if (dirty_count == 11) { - blockcpy(HighPal+0x40, Pico.cram, 0x40*2); + blockcpy(est->HighPal+0x40, Pico.cram, 0x40*2); } } @@ -1496,15 +1494,16 @@ void PicoDrawSync(int to, int blank_last_line) // also works for fast renderer void PicoDrawUpdateHighPal(void) { + struct PicoEState *est = &Pico.est; int sh = (Pico.video.reg[0xC] & 8) >> 3; // shadow/hilight? if (PicoOpt & POPT_ALT_RENDERER) sh = 0; // no s/h support PicoDoHighPal555(sh, 0, &Pico.est); - if (Pico.est.rendstatus & PDRAW_SONIC_MODE) { + if (est->rendstatus & PDRAW_SONIC_MODE) { // FIXME? - memcpy(HighPal + 0x40, HighPal, 0x40*2); - memcpy(HighPal + 0x80, HighPal, 0x40*2); + memcpy(est->HighPal + 0x40, est->HighPal, 0x40*2); + memcpy(est->HighPal + 0x80, est->HighPal, 0x40*2); } } diff --git a/pico/draw2.c b/pico/draw2.c index 5730d7b6..1b8cdf5f 100644 --- a/pico/draw2.c +++ b/pico/draw2.c @@ -21,7 +21,6 @@ #endif static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)]; -unsigned char *PicoDraw2FB = PicoDraw2FB_; static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers static int HighCache2B[41*(TILE_ROWS+1)+1+1]; @@ -32,11 +31,12 @@ void (*PicoPrepareCram)()=0; // prepares PicoCramHigh for renderer to // stuff available in asm: #ifdef _ASM_DRAW_C -void BackFillFull(int reg7); -void DrawLayerFull(int plane, int *hcache, int planestart, int planeend); -void DrawTilesFromCacheF(int *hc); -void DrawWindowFull(int start, int end, int prio); -void DrawSpriteFull(unsigned int *sprite); +void BackFillFull(void *dst, int reg7); +void DrawLayerFull(int plane, int *hcache, int planestart, int planeend, + struct PicoEState *est); +void DrawTilesFromCacheF(int *hc, struct PicoEState *est); +void DrawWindowFull(int start, int end, int prio, struct PicoEState *est); +void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est); #else @@ -134,11 +134,11 @@ static int TileXflipYflip(unsigned char *pd,int addr,unsigned char pal) // start: (tile_start<<16)|row_start, end: [same] -static void DrawWindowFull(int start, int end, int prio) +static void DrawWindowFull(int start, int end, int prio, struct PicoEState *est) { struct PicoVideo *pvid=&Pico.video; int nametab, nametab_step, trow, tilex, blank=-1, code; - unsigned char *scrpos = PicoDraw2FB; + unsigned char *scrpos = est->Draw2FB; int tile_start, tile_end; // in cells // parse ranges @@ -198,7 +198,8 @@ static void DrawWindowFull(int start, int end, int prio) } -static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend) +static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend, + struct PicoEState *est) { struct PicoVideo *pvid=&Pico.video; static char shift[4]={5,6,6,7}; // 32,64 or 128 sized tilemaps @@ -238,7 +239,7 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend) if (plane==0) nametab=(pvid->reg[2]&0x38)<< 9; // A else nametab=(pvid->reg[4]&0x07)<<12; // B - scrpos = PicoDraw2FB; + scrpos = est->Draw2FB; scrpos+=8*LINE_WIDTH*(planestart-START_ROW); // Get vertical scroll value: @@ -305,14 +306,14 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend) } -static void DrawTilesFromCacheF(int *hc) +static void DrawTilesFromCacheF(int *hc, struct PicoEState *est) { int code, addr, zero = 0; unsigned int prevy=0xFFFFFFFF; // unsigned short *pal; unsigned char pal; short blank=-1; // The tile we know is blank - unsigned char *scrpos = PicoDraw2FB, *pd = 0; + unsigned char *scrpos = est->Draw2FB, *pd = 0; // *hcache++ = code|(dx<<16)|(trow<<27); // cache it scrpos+=(*hc++)*LINE_WIDTH - START_ROW*LINE_WIDTH*8; @@ -344,7 +345,7 @@ static void DrawTilesFromCacheF(int *hc) // sx and sy are coords of virtual screen with 8pix borders on top and on left -static void DrawSpriteFull(unsigned int *sprite) +static void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est) { int width=0,height=0; // unsigned short *pal=NULL; @@ -375,7 +376,7 @@ static void DrawSpriteFull(unsigned int *sprite) // goto first vertically visible tile while(sy <= START_ROW*8) { sy+=8; tile+=tdeltay; height--; } - scrpos = PicoDraw2FB; + scrpos = est->Draw2FB; scrpos+=(sy-START_ROW*8)*LINE_WIDTH; for (; height > 0; height--, sy+=8, tile+=tdeltay) @@ -466,29 +467,29 @@ static void DrawAllSpritesFull(int prio, int maxwidth) } // Go through sprites backwards: - for (i-- ;i>=0; i--) + for (i--; i >= 0; i--) { - DrawSpriteFull(sprites[i]); + DrawSpriteFull(sprites[i], &Pico.est); } } #ifndef _ASM_DRAW_C -static void BackFillFull(int reg7) +static void BackFillFull(void *dst, int reg7) { unsigned int back; // Start with a background color: -// back=PicoCramHigh[reg7&0x3f]; back=reg7&0x3f; back|=back<<8; back|=back<<16; - memset32((int *)PicoDraw2FB, back, LINE_WIDTH*(8+(END_ROW-START_ROW)*8)/4); + memset32(dst, back, LINE_WIDTH*(8+(END_ROW-START_ROW)*8)/4); } #endif static void DrawDisplayFull(void) { + struct PicoEState *est = &Pico.est; struct PicoVideo *pvid=&Pico.video; int win, edge=0, hvwin=0; // LSb->MSb: hwin&plane, vwin&plane, full int planestart=START_ROW, planeend=END_ROW; // plane A start/end when window shares display with plane A (in tile rows or columns) @@ -551,55 +552,55 @@ static void DrawDisplayFull(void) HighCache2A[1] = HighCache2B[1] = 0; if (PicoDrawMask & PDRAW_LAYERB_ON) - DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW); + DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW, est); if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin) { case 4: // fullscreen window - DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0); + DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0, est); break; case 3: // we have plane A and both v and h windows - DrawLayerFull(0, HighCache2A, planestart, planeend); - DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0); // h - DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 0); // v + DrawLayerFull(0, HighCache2A, planestart, planeend, est); + DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0, est); // h + DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 0, est); // v break; case 2: case 1: // both window and plane A visible, window is vertical XOR horizontal - DrawLayerFull(0, HighCache2A, planestart, planeend); - DrawWindowFull(winstart, winend, 0); + DrawLayerFull(0, HighCache2A, planestart, planeend, est); + DrawWindowFull(winstart, winend, 0, est); break; default: // fullscreen plane A - DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW); + DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW, est); break; } if (PicoDrawMask & PDRAW_SPRITES_LOW_ON) DrawAllSpritesFull(0, maxw); - if (HighCache2B[1]) DrawTilesFromCacheF(HighCache2B); - if (HighCache2A[1]) DrawTilesFromCacheF(HighCache2A); + if (HighCache2B[1]) DrawTilesFromCacheF(HighCache2B, est); + if (HighCache2A[1]) DrawTilesFromCacheF(HighCache2A, est); if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin) { case 4: // fullscreen window - DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 1); + DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 1, est); break; case 3: // we have plane A and both v and h windows - DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 1); // h - DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 1); // v + DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 1, est); // h + DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 1, est); // v break; case 2: case 1: // both window and plane A visible, window is vertical XOR horizontal - DrawWindowFull(winstart, winend, 1); + DrawWindowFull(winstart, winend, 1, est); break; } if (PicoDrawMask & PDRAW_SPRITES_HI_ON) @@ -615,10 +616,14 @@ PICO_INTERNAL void PicoFrameFull() if (PicoPrepareCram) PicoPrepareCram(); // Draw screen: - BackFillFull(Pico.video.reg[7]); + BackFillFull(Pico.est.Draw2FB, Pico.video.reg[7]); if (Pico.video.reg[1] & 0x40) DrawDisplayFull(); pprof_end(draw); } +void PicoDraw2Init(void) +{ + Pico.est.Draw2FB = PicoDraw2FB_; +} diff --git a/pico/draw2_arm.S b/pico/draw2_arm.S index c37d059a..6e7e1ac0 100644 --- a/pico/draw2_arm.S +++ b/pico/draw2_arm.S @@ -8,8 +8,7 @@ * this is highly specialized, be careful if changing related C code! */ -.extern Pico -.extern PicoDraw2FB +#include "pico_int_o32.h" @ define these constants in your include file: @ .equiv START_ROW, 1 @@ -25,16 +24,16 @@ .text .align 2 -.global BackFillFull @ int reg7 +@ void BackFillFull(void *dst, int reg7) + +.global BackFillFull BackFillFull: stmfd sp!, {r4-r9,lr} - ldr lr, =PicoDraw2FB @ lr=PicoDraw2FB - mov r0, r0, lsl #26 - ldr lr, [lr] + add lr, r0, #328*8 + mov r0, r1, lsl #26 mov r0, r0, lsr #26 - add lr, lr, #328*8 orr r0, r0, r0, lsl #8 orr r0, r0, r0, lsl #16 @@ -67,8 +66,8 @@ BackFillFull: bne .bff_loop - ldmfd sp!, {r4-r9,r12} - bx r12 + ldmfd sp!, {r4-r9,lr} + bx lr .pool @@ -343,17 +342,19 @@ BackFillFull: @ DrawLayerTiles(*hcache, *scrpos, (cells<<24)|(nametab<<9)|(vscroll&0x3ff)<<11|(shift[width]<<8)|planeend, (ymask<<24)|(planestart<<16)|[htab||hscroll] -@static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend) +@ void DrawLayerFull(int plane, int *hcache, int planestart, int planeend, +@ struct PicoEState *est) .global DrawLayerFull DrawLayerFull: + ldr r12,[sp] @ est stmfd sp!, {r4-r11,lr} mov r6, r1 @ hcache - ldr r11, =(Pico+0x22228) @ Pico.video - ldr r10, =(Pico+0x10000) @ r10=Pico.vram + ldr r11, [r12, #OFS_Pico_video] + ldr r10, [r12, #OFS_Pico_vram] ldrb r5, [r11, #13] @ pvid->reg[13] ldrb r7, [r11, #11] @@ -402,9 +403,9 @@ DrawLayerFull: and r4, r4, #7 orr lr, lr, r4, lsl #13 @ lr|=nametab_bits{3}<<13 - ldr r11, =PicoDraw2FB @ r11=PicoDraw2FB + ldr r11,[sp, #9*4] @ est sub r4, r9, #(START_ROW<<24) - ldr r11, [r11] + ldr r11, [r11, #OFS_Draw2FB] mov r4, r4, asr #24 mov r7, #328*8 mla r11, r4, r7, r11 @ scrpos+=8*328*(planestart-START_ROW); @@ -571,8 +572,9 @@ DrawLayerFull: .pool +@ void DrawTilesFromCacheF(int *hc, struct PicoEState *est) -.global DrawTilesFromCacheF @ int *hc +.global DrawTilesFromCacheF DrawTilesFromCacheF: stmfd sp!, {r4-r10,lr} @@ -580,14 +582,13 @@ DrawTilesFromCacheF: mov r9, #0xff000000 @ r9=prevcode=-1 mvn r6, #0 @ r6=prevy=-1 - ldr r4, =PicoDraw2FB @ r4=PicoDraw2FB - ldr r1, [r0], #4 @ read y offset - ldr r4, [r4] + ldr r4, [r1, #OFS_Draw2FB] + ldr r2, [r0], #4 @ read y offset mov r7, #328 - mla r1, r7, r1, r4 - sub r12, r1, #(328*8*START_ROW) @ r12=scrpos + mla r2, r7, r2, r4 + sub r12, r2, #(328*8*START_ROW) @ r12=scrpos - ldr r10, =(Pico+0x10000) @ r10=Pico.vram + ldr r10, [r1, #OFS_Pico_vram] mov r8, r0 @ hc mov r0, #0xf @@ -666,12 +667,14 @@ DrawTilesFromCacheF: @ @@@@@@@@@@@@@@@ @ (tile_start<<16)|row_start -.global DrawWindowFull @ int tstart, int tend, int prio +@ void DrawWindowFull(int start, int end, int prio, struct PicoEState *est) + +.global DrawWindowFull DrawWindowFull: stmfd sp!, {r4-r11,lr} - ldr r11, =(Pico+0x22228) @ Pico.video + ldr r11, [r3, #OFS_Pico_video] ldrb r12, [r11, #3] @ pvid->reg[3] mov r12, r12, lsl #10 @@ -686,11 +689,11 @@ DrawWindowFull: and r4, r0, #0xff mla r12, r5, r4, r12 @ nametab += nametab_step*start; + ldr r10, [r3, #OFS_Pico_vram] mov r4, r0, lsr #16 @ r4=start_cell_h add r7, r12, r4, lsl #1 @ fetch the first code now - ldr r10, =(Pico+0x10000) @ lr=Pico.vram ldrh r7, [r10, r7] cmp r2, r7, lsr #15 ldmnefd sp!, {r4-r11,pc} @ hack: simply assume that whole window uses same priority @@ -704,11 +707,10 @@ DrawWindowFull: mov r9, #0xff000000 @ r9=prevcode=-1 - ldr r11, =PicoDraw2FB @ r11=scrpos + ldr r11, [r3, #OFS_Draw2FB] and r4, r0, #0xff - ldr r11, [r11] - sub r4, r4, #START_ROW add r11, r11, #328*8 + sub r4, r4, #START_ROW add r11, r11, #8 mov r7, #328*8 @@ -873,8 +875,9 @@ DrawWindowFull: b 52b .endm +@ void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est) -.global DrawSpriteFull @ unsigned int *sprite +.global DrawSpriteFull DrawSpriteFull: stmfd sp!, {r4-r11,lr} @@ -902,9 +905,8 @@ DrawSpriteFull: and r3, lr, #0x6000 mov r3, r3, lsr #9 @ r3=pal=((code>>9)&0x30); - ldr r11, =PicoDraw2FB @ r11=scrpos - ldr r10, =(Pico+0x10000) @ r10=Pico.vram - ldr r11, [r11] + ldr r11, [r1, #OFS_Draw2FB] + ldr r10, [r1, #OFS_Pico_vram] sub r1, r12, #(START_ROW*8) mov r0, #328 mla r11, r1, r0, r11 @ scrpos+=(sy-START_ROW*8)*328; diff --git a/pico/draw_arm.S b/pico/draw_arm.S index 23c522b0..71db183c 100644 --- a/pico/draw_arm.S +++ b/pico/draw_arm.S @@ -1497,7 +1497,7 @@ PicoDoHighPal555: PicoDoHighPal555_nopush: orr r9, r1, r0, lsl #31 @ 0:called from FinalizeLine555, 31: s/h - ldr r0, =HighPal + add r0, r10, #OFS_HighPal mov r1, #0 strb r1, [r8, #-0x1a] @ 0x2220e ~ dirtyPal @@ -1513,7 +1513,7 @@ PicoDoHighPal555_nopush: tst r9, #(1<<31) beq PicoDoHighPal555_end - ldr r3, =HighPal + add r3, r10, #OFS_HighPal @ shadowed pixels: mov r12, #0x008e @@ -1575,7 +1575,7 @@ FinalizeLine555: bne PicoDoHighPal555_nopush FinalizeLineRGB555_pal_done: - ldr r3, =HighPal + add r3, r10, #OFS_HighPal ldr r12, [r10, #OFS_rendstatus] eors r0, r0, #1 @ sh is 0 diff --git a/pico/mode4.c b/pico/mode4.c index 1f9adff5..4abace6b 100644 --- a/pico/mode4.c +++ b/pico/mode4.c @@ -249,7 +249,7 @@ void PicoLineMode4(int line) void PicoDoHighPal555M4(void) { unsigned int *spal=(void *)Pico.cram; - unsigned int *dpal=(void *)HighPal; + unsigned int *dpal=(void *)Pico.est.HighPal; unsigned int t; int i; @@ -267,7 +267,7 @@ void PicoDoHighPal555M4(void) t |= (t >> 4) & 0x08610861; *dpal = t; } - HighPal[0xe0] = 0; + Pico.est.HighPal[0xe0] = 0; } static void FinalizeLineRGB555M4(int line) diff --git a/pico/pico.c b/pico/pico.c index b6a083d0..62994c19 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -50,6 +50,7 @@ void PicoInit(void) Pico32xInit(); PicoDrawInit(); + PicoDraw2Init(); } // to be called once on emu exit diff --git a/pico/pico.h b/pico/pico.h index 98e4c785..a1aa96ee 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -195,7 +195,6 @@ extern int PicoDrawMask; #define PDRAW_32_COLS (1<<8) // 32 column mode extern int rendstatus_old; extern int rendlines; -extern unsigned short HighPal[0x100]; // draw.c void PicoDrawUpdateHighPal(void); @@ -203,7 +202,6 @@ void PicoDrawSetInternalBuf(void *dest, int line_increment); // draw2.c // stuff below is optional -extern unsigned char *PicoDraw2FB; // buffer for fast renderer in format (8+320)x(8+224+8) (eights for borders) extern unsigned short *PicoCramHigh; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now) extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to use diff --git a/pico/pico_int.h b/pico/pico_int.h index b9a4418f..b562b2f1 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -338,12 +338,14 @@ struct PicoEState { int DrawScanline; int rendstatus; - void *DrawLineDest; // draw estination + void *DrawLineDest; // draw destination unsigned char *HighCol; int *HighPreSpr; void *Pico_video; void *Pico_vram; int *PicoOpt; + unsigned char *Draw2FB; + unsigned short HighPal[0x100]; }; // some assembly stuff depend on these, do not touch! @@ -606,6 +608,7 @@ extern void *DrawLineDestBase; extern int DrawLineDestIncrement; // draw2.c +void PicoDraw2Init(void); PICO_INTERNAL void PicoFrameFull(); // mode4.c diff --git a/pico/pico_int_o32.h b/pico/pico_int_o32.h index 4094697d..dc7aaa2a 100644 --- a/pico/pico_int_o32.h +++ b/pico/pico_int_o32.h @@ -7,3 +7,5 @@ #define OFS_Pico_video 0x14 #define OFS_Pico_vram 0x18 #define OFS_PicoOpt 0x1c +#define OFS_Draw2FB 0x20 +#define OFS_HighPal 0x24 diff --git a/platform/gizmondo/emu.c b/platform/gizmondo/emu.c index 3a6c861b..30c6651b 100644 --- a/platform/gizmondo/emu.c +++ b/platform/gizmondo/emu.c @@ -155,11 +155,11 @@ static void blit(const char *fps, const char *notice) } // a hack for VR if (PicoAHW & PAHW_SVP) - memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328); + memset32((int *)(Pico.est.Draw2FB+328*8+328*223), 0xe0e0e0e0, 328); if (!(Pico.video.reg[12]&1)) lines_flags|=0x10000; if (currentConfig.EmuOpt&0x4000) lines_flags|=0x40000; // (Pico.m.frame_count&1)?0x20000:0x40000; - vidCpy8to16((unsigned short *)giz_screen+321*8, PicoDraw2FB+328*8, localPal, lines_flags); + vidCpy8to16((unsigned short *)giz_screen+321*8, Pico.est.Draw2FB+328*8, localPal, lines_flags); } else if (!(emu_opt&0x80)) { @@ -187,7 +187,7 @@ static void blit(const char *fps, const char *notice) if (!(Pico.video.reg[12]&1)) lines_flags|=0x10000; if (currentConfig.EmuOpt&0x4000) lines_flags|=0x40000; // (Pico.m.frame_count&1)?0x20000:0x40000; - vidCpy8to16((unsigned short *)giz_screen+321*8, PicoDraw2FB+328*8, localPal, lines_flags); + vidCpy8to16((unsigned short *)giz_screen+321*8, Pico.est.Draw2FB+328*8, localPal, lines_flags); } if (notice || (emu_opt & 2)) { diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 8db33a9f..8e682f16 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -7,8 +7,8 @@ * - 8bpp tile renderer * In 32x mode: * - 32x layer is overlayed on top of 16bpp one - * - line internal one done on PicoDraw2FB, then mixed with 32x - * - tile internal one done on PicoDraw2FB, then mixed with 32x + * - line internal one done on .Draw2FB, then mixed with 32x + * - tile internal one done on .Draw2FB, then mixed with 32x */ #include @@ -311,8 +311,8 @@ static int make_local_pal_md(int fast_mode) pallen = 0x100; } else if (Pico.est.rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes - bgr444_to_rgb32(localPal+0x40, HighPal); - bgr444_to_rgb32(localPal+0x80, HighPal+0x40); + bgr444_to_rgb32(localPal+0x40, Pico.est.HighPal); + bgr444_to_rgb32(localPal+0x80, Pico.est.HighPal+0x40); } else memcpy32(localPal+0x80, localPal, 0x40); // for spr prio mess @@ -355,9 +355,9 @@ void pemu_finalize_frame(const char *fps, const char *notice) } // a hack for VR if (PicoAHW & PAHW_SVP) - memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328); + memset32((int *)(Pico.est.Draw2FB+328*8+328*223), 0xe0e0e0e0, 328); // do actual copy - vidcpyM2(g_screen_ptr, PicoDraw2FB+328*8, + vidcpyM2(g_screen_ptr, Pico.est.Draw2FB+328*8, !(Pico.video.reg[12] & 1), !(PicoOpt & POPT_DIS_32C_BORDER)); } else if (get_renderer() == RT_8BIT_ACC) diff --git a/platform/linux/emu.c b/platform/linux/emu.c index c22f4fd0..d90d610d 100644 --- a/platform/linux/emu.c +++ b/platform/linux/emu.c @@ -68,8 +68,8 @@ void pemu_finalize_frame(const char *fps, const char *notice) { if (currentConfig.renderer != RT_16BIT && !(PicoAHW & PAHW_32X)) { unsigned short *pd = (unsigned short *)g_screen_ptr + 8 * g_screen_width; - unsigned char *ps = PicoDraw2FB + 328*8 + 8; - unsigned short *pal = HighPal; + unsigned char *ps = Pico.est.Draw2FB + 328*8 + 8; + unsigned short *pal = Pico.est.HighPal; int i, x; if (Pico.m.dirtyPal) PicoDrawUpdateHighPal(); @@ -99,7 +99,7 @@ static void apply_renderer(void) case RT_8BIT_ACC: PicoOpt &= ~POPT_ALT_RENDERER; PicoDrawSetOutFormat(PDF_8BIT, 0); - PicoDrawSetOutBuf(PicoDraw2FB + 8, 328); + PicoDrawSetOutBuf(Pico.est.Draw2FB + 8, 328); break; case RT_8BIT_FAST: PicoOpt |= POPT_ALT_RENDERER; diff --git a/platform/psp/emu.c b/platform/psp/emu.c index cb16d264..dd4381bb 100644 --- a/platform/psp/emu.c +++ b/platform/psp/emu.c @@ -36,7 +36,7 @@ int sceAudio_E0727056(int volume, void *buffer); // blocking output int sceAudioOutput2GetRestSample(); -//unsigned char *PicoDraw2FB = (unsigned char *)VRAM_CACHED_STUFF + 8; // +8 to be able to skip border with 1 quadword.. +//unsigned char *Draw2FB = (unsigned char *)VRAM_CACHED_STUFF + 8; // +8 to be able to skip border with 1 quadword.. int engineStateSuspend; #define PICO_PEN_ADJUST_X 4 @@ -400,9 +400,9 @@ void blit1(void) int i; unsigned char *pd; // clear top and bottom trash - for (pd = PicoDraw2FB+8, i = 8; i > 0; i--, pd += 512) + for (pd = Pico.est.Draw2FB+8, i = 8; i > 0; i--, pd += 512) memset32((int *)pd, 0xe0e0e0e0, 320/4); - for (pd = PicoDraw2FB+512*232+8, i = 8; i > 0; i--, pd += 512) + for (pd = Pico.est.Draw2FB+512*232+8, i = 8; i > 0; i--, pd += 512) memset32((int *)pd, 0xe0e0e0e0, 320/4); } diff --git a/tools/mkoffsets.c b/tools/mkoffsets.c index e9eb3c5f..a5c475f2 100644 --- a/tools/mkoffsets.c +++ b/tools/mkoffsets.c @@ -29,6 +29,8 @@ int main(int argc, char *argv[]) DUMP(f, Pico_video); DUMP(f, Pico_vram); DUMP(f, PicoOpt); + DUMP(f, Draw2FB); + DUMP(f, HighPal); fclose(f); return 0; From 06d30e62f69325ebd722251d68362873ce6c487f Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 6 Aug 2017 23:02:28 +0300 Subject: [PATCH 111/124] remove dead code --- Makefile | 2 - Makefile.libretro | 15 ++- jni/Android.mk | 2 - pico/cd/mcd_arm.s | 185 ------------------------------------- platform/common/common.mak | 5 - platform/gizmondo/Makefile | 1 - 6 files changed, 7 insertions(+), 203 deletions(-) delete mode 100644 pico/cd/mcd_arm.s diff --git a/Makefile b/Makefile index ca8ccf6e..99ba7ecd 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,6 @@ asm_memory ?= 1 asm_render ?= 1 asm_ym2612 ?= 1 asm_misc ?= 1 -asm_cdpico ?= 1 asm_cdmemory ?= 1 asm_mix ?= 1 else # if not arm @@ -67,7 +66,6 @@ endif ifneq "$(use_cyclone)" "1" # due to CPU stop flag access -asm_cdpico = 0 asm_cdmemory = 0 endif diff --git a/Makefile.libretro b/Makefile.libretro index 5d16ca73..306c8afb 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -35,7 +35,6 @@ asm_memory = 0 asm_render = 0 asm_ym2612 = 0 asm_misc = 0 -asm_cdpico = 0 asm_cdmemory = 0 asm_mix = 0 @@ -446,16 +445,16 @@ ifeq ($(NO_MMAP),1) endif ifeq ($(ARM_ASM),1) - asm_memory = 1 - asm_render = 1 - asm_ym2612 = 1 - asm_misc = 1 - asm_cdpico = 1 - asm_cdmemory = 1 - asm_mix = 1 +asm_memory = 1 +asm_render = 1 +asm_ym2612 = 1 +asm_misc = 1 +asm_cdmemory = 1 +asm_mix = 1 endif CFLAGS += $(fpic) + ifeq ($(findstring Haiku,$(shell uname -a)),) LDLIBS += $(LIBM) endif diff --git a/jni/Android.mk b/jni/Android.mk index bf81476c..492cfc92 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -28,7 +28,6 @@ asm_memory = 0 asm_render = 0 asm_ym2612 = 0 asm_misc = 0 -asm_cdpico = 0 asm_cdmemory = 0 asm_mix = 0 @@ -47,7 +46,6 @@ ifeq ($(TARGET_ARCH),arm) asm_render = 1 asm_ym2612 = 1 asm_misc = 1 - asm_cdpico = 1 asm_cdmemory = 1 asm_mix = 1 else diff --git a/pico/cd/mcd_arm.s b/pico/cd/mcd_arm.s deleted file mode 100644 index 9159e28b..00000000 --- a/pico/cd/mcd_arm.s +++ /dev/null @@ -1,185 +0,0 @@ -@* -@* CPU scheduling code -@* (C) notaz, 2007-2008 -@* -@* This work is licensed under the terms of MAME license. -@* See COPYING file in the top-level directory. -@* - -@ SekRunPS runs PicoCpuCM68k and PicoCpuCS68k interleaved in steps of PS_STEP_M68K -@ cycles. This is done without calling CycloneRun and jumping directly to -@ Cyclone code to avoid pushing/popping all the registers every time. - - -.equiv PS_STEP_M68K, ((488<<16)/20) @ ~24 - -@ .extern is ignored by gas, we add these here just to see what we depend on. -.extern CycloneJumpTab -.extern CycloneDoInterrupt -.extern PicoCpuCM68k -.extern PicoCpuCS68k -.extern SekCycleAim -.extern SekCycleCnt -.extern SekCycleAimS68k -.extern SekCycleCntS68k - - -.text -.align 4 - - -.global SekRunPS @ cyc_m68k, cyc_s68k - -SekRunPS: - stmfd sp!, {r4-r8,r10,r11,lr} - sub sp, sp, #2*4 @ sp[0] = main_cycle_cnt, sp[4] = run_cycle_cnt - - @ override CycloneEnd for both contexts - ldr r7, =PicoCpuCM68k - ldr lr, =PicoCpuCS68k - ldr r2, =CycloneEnd_M68k - ldr r3, =CycloneEnd_S68k - str r2, [r7,#0x98] - str r3, [lr,#0x98] - - @ update aims - ldr r8, =SekCycleAim - ldr r10,=SekCycleAimS68k - ldr r2, [r8] - ldr r3, [r10] - add r2, r2, r0 - add r3, r3, r1 - str r2, [r8] - str r3, [r10] - - ldr r6, =CycloneJumpTab - ldr r1, =SekCycleCnt - ldr r0, =((488<<16)-PS_STEP_M68K) - str r6, [r7,#0x54] - str r6, [lr,#0x54] @ make copies to avoid literal pools - - @ schedule m68k for the first time.. - ldr r1, [r1] - str r0, [sp] @ main target 'left cycle' counter - sub r1, r2, r1 - subs r5, r1, r0, asr #16 - ble schedule_s68k @ m68k has not enough cycles - - str r5, [sp,#4] @ run_cycle_cnt - b CycloneRunLocal - - - -CycloneEnd_M68k: - ldr r3, =SekCycleCnt - ldr r0, [sp,#4] @ run_cycle_cnt - ldr r1, [r3] - str r4, [r7,#0x40] ;@ Save Current PC + Memory Base - strb r10,[r7,#0x46] ;@ Save Flags (NZCV) - sub r0, r0, r5 @ subtract leftover cycles (which should be negative) - add r0, r0, r1 - str r0, [r3] - -schedule_s68k: - ldr r8, =SekCycleCntS68k - ldr r10,=SekCycleAimS68k - ldr r3, [sp] - ldr r8, [r8] - ldr r10,[r10] - - sub r0, r10, r8 - mov r2, r3 - add r3, r3, r2, asr #1 - add r3, r3, r2, asr #3 @ cycn_s68k = (cycn + cycn/2 + cycn/8) - - subs r5, r0, r3, asr #16 - ble schedule_m68k @ s68k has not enough cycles - - ldr r7, =PicoCpuCS68k - str r5, [sp,#4] @ run_cycle_cnt - b CycloneRunLocal - - - -CycloneEnd_S68k: - ldr r3, =SekCycleCntS68k - ldr r0, [sp,#4] @ run_cycle_cnt - ldr r1, [r3] - str r4, [r7,#0x40] ;@ Save Current PC + Memory Base - strb r10,[r7,#0x46] ;@ Save Flags (NZCV) - sub r0, r0, r5 @ subtract leftover cycles (should be negative) - add r0, r0, r1 - str r0, [r3] - -schedule_m68k: - ldr r1, =PS_STEP_M68K - ldr r3, [sp] @ main_cycle_cnt - ldr r8, =SekCycleCnt - ldr r10,=SekCycleAim - subs r3, r3, r1 - bmi SekRunPS_end - - ldr r8, [r8] - ldr r10,[r10] - str r3, [sp] @ update main_cycle_cnt - sub r0, r10, r8 - - subs r5, r0, r3, asr #16 - ble schedule_s68k @ m68k has not enough cycles - - ldr r7, =PicoCpuCM68k - str r5, [sp,#4] @ run_cycle_cnt - b CycloneRunLocal - - - -SekRunPS_end: - ldr r7, =PicoCpuCM68k - ldr lr, =PicoCpuCS68k - mov r0, #0 - str r0, [r7,#0x98] @ remove CycloneEnd handler - str r0, [lr,#0x98] - @ return - add sp, sp, #2*4 - ldmfd sp!, {r4-r8,r10,r11,pc} - - - -CycloneRunLocal: - ;@ r0-3 = Temporary registers - ldr r4,[r7,#0x40] ;@ r4 = Current PC + Memory Base - ;@ r5 = Cycles - ;@ r6 = Opcode Jump table - ;@ r7 = Pointer to Cpu Context - ;@ r8 = Current Opcode - ldrb r10,[r7,#0x46];@ r10 = Flags (NZCV) - ldr r1,[r7,#0x44] ;@ get SR high and IRQ level - orr r10,r10,r10,lsl #28 ;@ r10 = Flags 0xf0000000, cpsr format - -;@ CheckInterrupt: - movs r0,r1,lsr #24 ;@ Get IRQ level - beq NoIntsLocal - cmp r0,#6 ;@ irq>6 ? - andle r1,r1,#7 ;@ Get interrupt mask - cmple r0,r1 ;@ irq<=6: Is irq<=mask ? - bgt CycloneDoInterrupt -NoIntsLocal: - -;@ Check if our processor is in special state -;@ and jump to opcode handler if not - ldr r0,[r7,#0x58] ;@ state_flags - ldrh r8,[r4],#2 ;@ Fetch first opcode - tst r0,#0x03 ;@ special state? - andeq r10,r10,#0xf0000000 - ldreq pc,[r6,r8,asl #2] ;@ Jump to opcode handler - -CycloneSpecial2: - tst r0,#2 ;@ tracing? - bne CycloneDoTrace -;@ stopped or halted - sub r4,r4,#2 - ldr r1,[r7,#0x98] - mov r5,#0 - bx r1 - -@ vim:filetype=armasm diff --git a/platform/common/common.mak b/platform/common/common.mak index 3c0a5127..ed3ca487 100644 --- a/platform/common/common.mak +++ b/platform/common/common.mak @@ -8,7 +8,6 @@ asm_memory = 0 asm_render = 0 asm_ym2612 = 0 asm_misc = 0 -asm_cdpico = 0 asm_cdmemory = 0 asm_mix = 0 endif @@ -61,10 +60,6 @@ DEFINES += _ASM_MISC_C SRCS_COMMON += $(R)pico/misc_arm.s SRCS_COMMON += $(R)pico/cd/misc_arm.s endif -ifeq "$(asm_cdpico)" "1" -DEFINES += _ASM_CD_PICO_C -SRCS_COMMON += $(R)pico/cd/mcd_arm.s -endif ifeq "$(asm_cdmemory)" "1" DEFINES += _ASM_CD_MEMORY_C SRCS_COMMON += $(R)pico/cd/memory_arm.s diff --git a/platform/gizmondo/Makefile b/platform/gizmondo/Makefile index d7aab76a..7df468d6 100644 --- a/platform/gizmondo/Makefile +++ b/platform/gizmondo/Makefile @@ -7,7 +7,6 @@ asm_memory = 1 asm_render = 1 asm_ym2612 = 1 asm_misc = 1 -asm_cdpico = 1 asm_cdmemory = 1 amalgamate = 0 #profile = 1 From 006e9addecd09bc7e74634dfc6c6c215d7b92598 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 6 Aug 2017 23:22:53 +0300 Subject: [PATCH 112/124] get some gp2x stuff out of the way for others --- Makefile | 3 +++ pico/sound/{mix_arm.s => mix_arm.S} | 3 +++ platform/common/common.mak | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) rename pico/sound/{mix_arm.s => mix_arm.S} (99%) diff --git a/Makefile b/Makefile index 99ba7ecd..e5206697 100644 --- a/Makefile +++ b/Makefile @@ -204,6 +204,9 @@ tools/textfilter: tools/textfilter.c .s.o: $(CC) $(CFLAGS) -c $< -o $@ +.S.o: + $(CC) $(CFLAGS) -c $< -o $@ + # special flags - perhaps fix this someday instead? pico/draw.o: CFLAGS += -fno-strict-aliasing pico/draw2.o: CFLAGS += -fno-strict-aliasing diff --git a/pico/sound/mix_arm.s b/pico/sound/mix_arm.S similarity index 99% rename from pico/sound/mix_arm.s rename to pico/sound/mix_arm.S index 60a09495..5088e61b 100644 --- a/pico/sound/mix_arm.s +++ b/pico/sound/mix_arm.S @@ -299,6 +299,7 @@ m32_16_mo_no_unal2: bx lr +#ifdef __GP2X__ .data .align 4 @@ -366,4 +367,6 @@ m32_16l_st_l_no_unal2: ldmfd sp!, {r4-r9,lr} bx lr +#endif /* __GP2X__ */ + @ vim:filetype=armasm diff --git a/platform/common/common.mak b/platform/common/common.mak index ed3ca487..c8571ac5 100644 --- a/platform/common/common.mak +++ b/platform/common/common.mak @@ -69,7 +69,7 @@ DEFINES += _ASM_32X_DRAW SRCS_COMMON += $(R)pico/32x/draw_arm.s endif ifeq "$(asm_mix)" "1" -SRCS_COMMON += $(R)pico/sound/mix_arm.s +SRCS_COMMON += $(R)pico/sound/mix_arm.S endif endif # ARCH=arm From a765263b80ef38fb8e0d9ede85b938e47b7d944e Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 8 Aug 2017 02:25:37 +0300 Subject: [PATCH 113/124] android: solve "text segment is not shareable" Some asm is disabled and some performance is lost by this. --- jni/Android.mk | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/jni/Android.mk b/jni/Android.mk index 492cfc92..54b9f061 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -38,15 +38,19 @@ ifeq ($(TARGET_ARCH),arm) endif use_cyclone = 1 - use_drz80 = 1 + + # texrels, -perf ~~8% + use_drz80 = 0 + use_cz80 = 1 + use_sh2drc = 1 use_svpdrc = 1 - asm_memory = 1 +# asm_memory = 1 # texrels, -perf negligible asm_render = 1 - asm_ym2612 = 1 +# asm_ym2612 = 1 # texrels, -perf ~~4% asm_misc = 1 - asm_cdmemory = 1 +# asm_cdmemory = 1 # texrels asm_mix = 1 else use_fame = 1 From 49c8aa78d9e28562f8c5fd0ce90cc7ecde2b2bba Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 11 Aug 2017 02:12:57 +0300 Subject: [PATCH 114/124] drz80: drop fast_sp for compatibility no measurable improvement in most cases anyway --- cpu/DrZ80/drz80.s | 4 +++- pico/z80if.c | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/cpu/DrZ80/drz80.s b/cpu/DrZ80/drz80.s index b92b2c2d..c2a64df3 100644 --- a/cpu/DrZ80/drz80.s +++ b/cpu/DrZ80/drz80.s @@ -12,7 +12,7 @@ .global DrZ80Ver .equiv INTERRUPT_MODE, 0 ;@0 = Use internal int handler, 1 = Use Mames int handler - .equiv FAST_Z80SP, 1 ;@0 = Use mem functions for stack pointer, 1 = Use direct mem pointer + .equiv FAST_Z80SP, 0 ;@0 = Use mem functions for stack pointer, 1 = Use direct mem pointer .equiv UPDATE_CONTEXT, 0 .equiv DRZ80_XMAP, 1 .equiv DRZ80_XMAP_MORE_INLINE, 1 @@ -212,6 +212,7 @@ z80_bad_jump: mov z80pc,r0 ldmfd sp!,{r3,r12,pc} +.if FAST_Z80SP z80_xmap_rebase_sp: ldr r1,[cpucontext,#z80_read8] sub r2,r0,#1 @@ -228,6 +229,7 @@ z80_xmap_rebase_sp: ldr pc,[cpucontext,#z80_rebaseSP] mov z80sp,r0 ldmfd sp!,{r3,r12,pc} +.endif @ FAST_Z80SP .endif @ DRZ80_XMAP diff --git a/pico/z80if.c b/pico/z80if.c index 5efeff89..33a86180 100644 --- a/pico/z80if.c +++ b/pico/z80if.c @@ -14,9 +14,11 @@ uptr z80_read_map [0x10000 >> Z80_MEM_SHIFT]; uptr z80_write_map[0x10000 >> Z80_MEM_SHIFT]; #ifdef _USE_DRZ80 -struct DrZ80 drZ80; +// this causes trouble in some cases, like doukutsu putting sp in bank area +// no perf difference for most, upto 1-2% for some others +//#define FAST_Z80SP -static u32 drz80_sp_base; +struct DrZ80 drZ80; static void drz80_load_pcsp(u32 pc, u32 sp) { @@ -28,6 +30,8 @@ static void drz80_load_pcsp(u32 pc, u32 sp) drZ80.Z80PC_BASE <<= 1; drZ80.Z80PC = drZ80.Z80PC_BASE + pc; } + drZ80.Z80SP = sp; +#ifdef FAST_Z80SP drZ80.Z80SP_BASE = z80_read_map[sp >> Z80_MEM_SHIFT]; if (drZ80.Z80SP_BASE & (1<<31)) { elprintf(EL_STATUS|EL_ANOMALY, "load_pcsp: bad SP: %04x", sp); @@ -37,6 +41,7 @@ static void drz80_load_pcsp(u32 pc, u32 sp) drZ80.Z80SP_BASE <<= 1; drZ80.Z80SP = drZ80.Z80SP_BASE + sp; } +#endif } // called only if internal xmap rebase fails @@ -47,13 +52,19 @@ static unsigned int dz80_rebase_pc(unsigned short pc) return drZ80.Z80PC_BASE; } +#ifdef FAST_Z80SP +static u32 drz80_sp_base; + static unsigned int dz80_rebase_sp(unsigned short sp) { elprintf(EL_STATUS|EL_ANOMALY, "dz80_rebase_sp: fail on %04x", sp); drZ80.Z80SP_BASE = z80_read_map[drz80_sp_base >> Z80_MEM_SHIFT] << 1; return drZ80.Z80SP_BASE + (1 << Z80_MEM_SHIFT) - 0x100; } +#else +#define dz80_rebase_sp NULL #endif +#endif // _USE_DRZ80 void z80_init(void) @@ -91,9 +102,11 @@ void z80_reset(void) drZ80.Z80IX = 0xFFFF << 16; drZ80.Z80IY = 0xFFFF << 16; */ +#ifdef FAST_Z80SP // drZ80 is locked in single bank drz80_sp_base = (PicoAHW & PAHW_SMS) ? 0xc000 : 0x0000; drZ80.Z80SP_BASE = z80_read_map[drz80_sp_base >> Z80_MEM_SHIFT] << 1; +#endif if (PicoAHW & PAHW_SMS) drZ80.Z80SP = drZ80.Z80SP_BASE + 0xdff0; // simulate BIOS // XXX: since we use direct SP pointer, it might make sense to force it to RAM, @@ -286,3 +299,5 @@ void z80_debug(char *dstr) sprintf(dstr, "Z80 state: PC: %04x SP: %04x\n", (unsigned int)(CZ80.PC - CZ80.BasePC), CZ80.SP.W); #endif } + +// vim:ts=2:sw=2:expandtab From 76f3e30ffe83fb0d589ed994ea76ffd8adf6586d Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 18 Aug 2017 03:44:25 +0300 Subject: [PATCH 115/124] sh2: handle some branch exceptions --- cpu/sh2/compiler.c | 31 +++++++++++++++++++++++++++---- cpu/sh2/compiler.h | 1 + cpu/sh2/mame/sh2pico.c | 12 ++++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/cpu/sh2/compiler.c b/cpu/sh2/compiler.c index 2dd3430c..3f006c74 100644 --- a/cpu/sh2/compiler.c +++ b/cpu/sh2/compiler.c @@ -2590,8 +2590,9 @@ static void REGPARM(2) *sh2_translate(SH2 *sh2, int tcache_id) default: default_: - elprintf_sh2(sh2, EL_ANOMALY, - "drc: illegal op %04x @ %08x", op, pc - 2); + if (!(op_flags[i] & OF_B_IN_DS)) + elprintf_sh2(sh2, EL_ANOMALY, + "drc: illegal op %04x @ %08x", op, pc - 2); tmp = rcache_get_reg(SHR_SP, RC_GR_RMW); emith_sub_r_imm(tmp, 4*2); @@ -2604,10 +2605,16 @@ static void REGPARM(2) *sh2_translate(SH2 *sh2, int tcache_id) // push PC rcache_get_reg_arg(0, SHR_SP); tmp = rcache_get_tmp_arg(1); - emith_move_r_imm(tmp, pc - 2); + if (drcf.pending_branch_indirect) { + tmp2 = rcache_get_reg(SHR_PC, RC_GR_READ); + emith_move_r_r(tmp, tmp2); + } + else + emith_move_r_imm(tmp, pc - 2); emit_memhandler_write(2); // obtain new PC - emit_memhandler_read_rr(SHR_PC, SHR_VBR, 4 * 4, 2); + v = (op_flags[i] & OF_B_IN_DS) ? 6 : 4; + emit_memhandler_read_rr(SHR_PC, SHR_VBR, v * 4, 2); // indirect jump -> back to dispatcher rcache_flush(); emith_jump(sh2_drc_dispatcher); @@ -4062,6 +4069,22 @@ void scan_block(u32 base_pc, int is_slave, u8 *op_flags, u32 *end_pc_out, is_slave ? 's' : 'm', op, pc); break; } + + if (op_flags[i] & OF_DELAY_OP) { + switch (opd->op) { + case OP_BRANCH: + case OP_BRANCH_CT: + case OP_BRANCH_CF: + case OP_BRANCH_R: + case OP_BRANCH_RF: + elprintf(EL_ANOMALY, "%csh2 drc: branch in DS @ %08x", + is_slave ? 's' : 'm', pc); + opd->op = OP_UNHANDLED; + op_flags[i] |= OF_B_IN_DS; + next_is_delay = 0; + break; + } + } } i_end = i; end_pc = pc; diff --git a/cpu/sh2/compiler.h b/cpu/sh2/compiler.h index ef1944b4..61d8d2da 100644 --- a/cpu/sh2/compiler.h +++ b/cpu/sh2/compiler.h @@ -20,6 +20,7 @@ void sh2_drc_frame(void); #define OF_BTARGET (1 << 1) #define OF_T_SET (1 << 2) // T is known to be set #define OF_T_CLEAR (1 << 3) // ... clear +#define OF_B_IN_DS (1 << 4) void scan_block(unsigned int base_pc, int is_slave, unsigned char *op_flags, unsigned int *end_pc, diff --git a/cpu/sh2/mame/sh2pico.c b/cpu/sh2/mame/sh2pico.c index 78998785..73241660 100644 --- a/cpu/sh2/mame/sh2pico.c +++ b/cpu/sh2/mame/sh2pico.c @@ -122,6 +122,18 @@ int sh2_execute_interpreter(SH2 *sh2, int cycles) { sh2->ppc = sh2->delay; opcode = RW(sh2, sh2->delay); + + // TODO: more branch types + if ((opcode >> 13) == 5) { // BRA/BSR + sh2->r[15] -= 4; + WL(sh2, sh2->r[15], sh2->sr); + sh2->r[15] -= 4; + WL(sh2, sh2->r[15], sh2->pc); + sh2->pc = RL(sh2, sh2->vbr + 6 * 4); + sh2->icount -= 5; + opcode = 9; // NOP + } + sh2->pc -= 2; } else From 8baf63e2eb38af5c2e661feea2935d0455193ed8 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 17 Apr 2017 00:36:57 +0300 Subject: [PATCH 116/124] fix some warnings warning: array subscript is above array bounds [-Warray-bounds] --- pico/carthw/svp/ssp16.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pico/carthw/svp/ssp16.c b/pico/carthw/svp/ssp16.c index e8de0013..2fb40015 100644 --- a/pico/carthw/svp/ssp16.c +++ b/pico/carthw/svp/ssp16.c @@ -474,6 +474,8 @@ static int get_inc(int mode) static u32 pm_io(int reg, int write, u32 d) { + unsigned int *pmac; + if (ssp->emu_status & SSP_PMC_SET) { // this MUST be blind r or w @@ -484,7 +486,8 @@ static u32 pm_io(int reg, int write, u32 d) return 0; } elprintf(EL_SVP, "PM%i (%c) set to %08x @ %04x", reg, write ? 'w' : 'r', rPMC.v, GET_PPC_OFFS()); - ssp->pmac_read[write ? reg + 6 : reg] = rPMC.v; + pmac = write ? ssp->pmac_write : ssp->pmac_read; + pmac[reg] = rPMC.v; ssp->emu_status &= ~SSP_PMC_SET; if ((rPMC.v & 0x7fffff) == 0x1c8000 || (rPMC.v & 0x7fffff) == 0x1c8240) { elprintf(EL_SVP, "ssp IRAM copy from %06x to %04x", (ssp->RAM1[0]-1)<<1, (rPMC.v&0x7fff)<<1); @@ -573,7 +576,8 @@ static u32 pm_io(int reg, int write, u32 d) } // PMC value corresponds to last PMR accessed (not sure). - rPMC.v = ssp->pmac_read[write ? reg + 6 : reg]; + pmac = write ? ssp->pmac_write : ssp->pmac_read; + rPMC.v = pmac[reg]; return d; } From 3d5e32fe21b56d59a116195a66f300735af5a7ec Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 17 Apr 2017 00:36:30 +0300 Subject: [PATCH 117/124] fix broken error path --- pico/cart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pico/cart.c b/pico/cart.c index 25a847d4..b35eb533 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -513,7 +513,7 @@ int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms) bytes_read = pm_read(rom,size,f); // Load up the rom if (bytes_read <= 0) { elprintf(EL_STATUS, "read failed"); - free(rom); + plat_munmap(rom, rom_alloc_size); return 3; } From 653f0b1399313ecef86d99a2552f40fb9e51b820 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 17 Apr 2017 00:34:00 +0300 Subject: [PATCH 118/124] use system's zlib except for libretro github issue #45 --- Makefile | 4 +++- configure | 6 +++--- pico/cart.c | 3 +-- pico/state.c | 2 +- platform/gizmondo/menu.c | 2 +- platform/gp2x/emu.c | 2 +- platform/psp/menu.c | 2 +- unzip/unzip.c | 2 +- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index e5206697..3b5a7140 100644 --- a/Makefile +++ b/Makefile @@ -163,10 +163,12 @@ else OBJS += platform/common/mp3_dummy.o endif -ifneq "$(DONT_COMPILE_IN_ZLIB)" "1" +ifeq "$(PLATFORM)" "libretro" # zlib OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \ zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o zlib/uncompr.o +CFLAGS += -Izlib +endif # unzip OBJS += unzip/unzip.o unzip/unzip_stream.o endif diff --git a/configure b/configure index 9ccd2da9..a25e7c1c 100755 --- a/configure +++ b/configure @@ -241,7 +241,7 @@ check_zlib() #include int main(void) { uncompress(0, 0, 0, 0); } EOF - compile_binary + compile_binary "$@" } check_libpng() @@ -291,8 +291,8 @@ EOF compile_object "$@" } -#MAIN_LDLIBS="$MAIN_LDLIBS -lz" -#check_zlib || fail "please install zlib (libz-dev)" +MAIN_LDLIBS="$MAIN_LDLIBS -lz" +check_zlib -lz || fail "please install zlib (libz-dev)" MAIN_LDLIBS="-lpng $MAIN_LDLIBS" check_libpng || fail "please install libpng (libpng-dev)" diff --git a/pico/cart.c b/pico/cart.c index b35eb533..9dce38d9 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -8,10 +8,9 @@ */ #include "pico_int.h" -#include "../zlib/zlib.h" #include "../cpu/debug.h" #include "../unzip/unzip.h" -#include "../unzip/unzip_stream.h" +#include static int rom_alloc_size; diff --git a/pico/state.c b/pico/state.c index 089957eb..88b8655c 100644 --- a/pico/state.c +++ b/pico/state.c @@ -7,7 +7,7 @@ */ #include "pico_int.h" -#include +#include #include "../cpu/sh2/sh2.h" #include "sound/ym2612.h" diff --git a/platform/gizmondo/menu.c b/platform/gizmondo/menu.c index d4f6bd49..dd6740a3 100644 --- a/platform/gizmondo/menu.c +++ b/platform/gizmondo/menu.c @@ -32,7 +32,7 @@ #include #include -#include +#include #define gizKeyUnkn "???" diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 8e682f16..c0bc71f4 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include #ifdef BENCHMARK #define OSD_FPS_X 220 diff --git a/platform/psp/menu.c b/platform/psp/menu.c index 24c6d606..f01f0ae5 100644 --- a/platform/psp/menu.c +++ b/platform/psp/menu.c @@ -33,7 +33,7 @@ #include #include -#include +#include #define pspKeyUnkn "???" diff --git a/unzip/unzip.c b/unzip/unzip.c index ddf59aa6..10291652 100644 --- a/unzip/unzip.c +++ b/unzip/unzip.c @@ -5,7 +5,7 @@ #include #include -#include "zlib/zlib.h" +#include /* public globals */ //int gUnzipQuiet = 0; /* flag controls error messages */ From e4a2d86a03126ffb17992b71c1aec0888cb8ce76 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 17 Apr 2017 00:30:30 +0300 Subject: [PATCH 119/124] get rid of the silly unzip_stream ... and just use zlib's inflate. Needed for the next commit. --- Makefile | 3 +- pico/cart.c | 134 +++++++++++++++++++++++--------- unzip/unzip_stream.c | 178 ------------------------------------------- unzip/unzip_stream.h | 4 - 4 files changed, 101 insertions(+), 218 deletions(-) delete mode 100644 unzip/unzip_stream.c delete mode 100644 unzip/unzip_stream.h diff --git a/Makefile b/Makefile index 3b5a7140..9b7e37e8 100644 --- a/Makefile +++ b/Makefile @@ -170,8 +170,7 @@ OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \ CFLAGS += -Izlib endif # unzip -OBJS += unzip/unzip.o unzip/unzip_stream.o -endif +OBJS += unzip/unzip.o include platform/common/common.mak diff --git a/pico/cart.c b/pico/cart.c index 9dce38d9..d29e96cf 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -89,6 +89,16 @@ static const char *get_ext(const char *path) return ext; } +struct zip_file { + pm_file file; + ZIP *zip; + struct zipent *entry; + z_stream stream; + unsigned char inbuf[16384]; + long start; + unsigned int pos; +}; + pm_file *pm_open(const char *path) { pm_file *file = NULL; @@ -102,10 +112,10 @@ pm_file *pm_open(const char *path) #ifndef NO_ZLIB if (strcasecmp(ext, "zip") == 0) { + struct zip_file *zfile = NULL; struct zipent *zipentry; - gzFile gzf = NULL; ZIP *zipfile; - int i; + int i, ret; zipfile = openzip(path); if (zipfile != NULL) @@ -127,25 +137,29 @@ pm_file *pm_open(const char *path) goto zip_failed; found_rom_zip: - /* try to convert to gzip stream, so we could use standard gzio functions from zlib */ - gzf = zip2gz(zipfile, zipentry); - if (gzf == NULL) goto zip_failed; - - file = calloc(1, sizeof(*file)); - if (file == NULL) goto zip_failed; - file->file = zipfile; - file->param = gzf; - file->size = zipentry->uncompressed_size; - file->type = PMT_ZIP; - strncpy(file->ext, ext, sizeof(file->ext) - 1); - return file; + zfile = calloc(1, sizeof(*zfile)); + if (zfile == NULL) + goto zip_failed; + ret = seekcompresszip(zipfile, zipentry); + if (ret != 0) + goto zip_failed; + ret = inflateInit2(&zfile->stream, -15); + if (ret != Z_OK) { + elprintf(EL_STATUS, "zip: inflateInit2 %d", ret); + goto zip_failed; + } + zfile->zip = zipfile; + zfile->entry = zipentry; + zfile->start = ftell(zipfile->fp); + zfile->file.file = zfile; + zfile->file.size = zipentry->uncompressed_size; + zfile->file.type = PMT_ZIP; + strncpy(zfile->file.ext, ext, sizeof(zfile->file.ext) - 1); + return &zfile->file; zip_failed: - if (gzf) { - gzclose(gzf); - zipfile->fp = NULL; // gzclose() closed it - } closezip(zipfile); + free(zfile); return NULL; } } @@ -249,13 +263,33 @@ size_t pm_read(void *ptr, size_t bytes, pm_file *stream) #ifndef NO_ZLIB else if (stream->type == PMT_ZIP) { - gzFile gf = stream->param; - int err; - ret = gzread(gf, ptr, bytes); - err = gzerror2(gf); - if (ret > 0 && (err == Z_DATA_ERROR || err == Z_STREAM_END)) - /* we must reset stream pointer or else next seek/read fails */ - gzrewind(gf); + struct zip_file *z = stream->file; + + if (z->entry->compression_method == 0) { + int ret = fread(ptr, 1, bytes, z->zip->fp); + z->pos += ret; + return ret; + } + + z->stream.next_out = ptr; + z->stream.avail_out = bytes; + while (z->stream.avail_out != 0) { + if (z->stream.avail_in == 0) { + z->stream.avail_in = fread(z->inbuf, 1, sizeof(z->inbuf), z->zip->fp); + if (z->stream.avail_in == 0) + break; + z->stream.next_in = z->inbuf; + } + ret = inflate(&z->stream, Z_NO_FLUSH); + if (ret == Z_STREAM_END) + break; + if (ret != Z_OK) { + elprintf(EL_STATUS, "zip: inflate: %d", ret); + return 0; + } + } + z->pos += bytes - z->stream.avail_out; + return bytes - z->stream.avail_out; } #endif else if (stream->type == PMT_CSO) @@ -336,12 +370,45 @@ int pm_seek(pm_file *stream, long offset, int whence) #ifndef NO_ZLIB else if (stream->type == PMT_ZIP) { - if (PicoMessage != NULL && offset > 6*1024*1024) { - long pos = gztell((gzFile) stream->param); - if (offset < pos || offset - pos > 6*1024*1024) - PicoMessage("Decompressing data..."); + struct zip_file *z = stream->file; + unsigned int pos = z->pos; + int ret; + + switch (whence) + { + case SEEK_CUR: pos += offset; break; + case SEEK_SET: pos = offset; break; + case SEEK_END: pos = stream->size - offset; break; } - return gzseek((gzFile) stream->param, offset, whence); + if (z->entry->compression_method == 0) { + ret = fseek(z->zip->fp, z->start + pos, SEEK_SET); + if (ret == 0) + return (z->pos = pos); + return -1; + } + offset = pos - z->pos; + if (pos < z->pos) { + // full decompress from the start + fseek(z->zip->fp, z->start, SEEK_SET); + z->stream.avail_in = 0; + z->stream.next_in = z->inbuf; + inflateReset(&z->stream); + z->pos = 0; + offset = pos; + } + + if (PicoMessage != NULL && offset > 4 * 1024 * 1024) + PicoMessage("Decompressing data..."); + + while (offset > 0) { + char buf[16 * 1024]; + size_t l = offset > sizeof(buf) ? sizeof(buf) : offset; + ret = pm_read(buf, l, stream); + if (ret != l) + break; + offset -= l; + } + return z->pos; } #endif else if (stream->type == PMT_CSO) @@ -372,10 +439,9 @@ int pm_close(pm_file *fp) #ifndef NO_ZLIB else if (fp->type == PMT_ZIP) { - ZIP *zipfile = fp->file; - gzclose((gzFile) fp->param); - zipfile->fp = NULL; // gzclose() closed it - closezip(zipfile); + struct zip_file *z = fp->file; + inflateEnd(&z->stream); + closezip(z->zip); } #endif else if (fp->type == PMT_CSO) diff --git a/unzip/unzip_stream.c b/unzip/unzip_stream.c deleted file mode 100644 index 7f3e9354..00000000 --- a/unzip/unzip_stream.c +++ /dev/null @@ -1,178 +0,0 @@ -/* seekable zip */ - -#include "unzip.h" - -#include -#include -#include - -#include "zlib/zlib.h" - - -#define errormsg(str1,def,fname) printf("%s: " #def ": " str1 "\n", fname); - - -/* from gzio.c . Be careful with binary compatibility */ -typedef struct gz_stream { - z_stream stream; - int z_err; /* error code for last stream operation */ - int z_eof; /* set if end of input file */ - FILE *file; /* .gz file */ - Byte *inbuf; /* input buffer */ - Byte *outbuf; /* output buffer */ - uLong crc; /* crc32 of uncompressed data */ - char *msg; /* error message */ - char *path; /* path name for debugging only */ - int transparent; /* 1 if input file is not a .gz file */ - char mode; /* 'w' or 'r' */ - z_off_t start; /* start of compressed data in file (header skipped) */ - z_off_t in; /* bytes into deflate or inflate */ - z_off_t out; /* bytes out of deflate or inflate */ - int back; /* one character push-back */ - int last; /* true if push-back is last character */ -} gz_stream; - -#ifndef Z_BUFSIZE -# ifdef MAXSEG_64K -# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */ -# else -# define Z_BUFSIZE 16384 -# endif -#endif -#ifndef Z_PRINTF_BUFSIZE -# define Z_PRINTF_BUFSIZE 4096 -#endif - -#define ALLOC(size) malloc(size) - -int destroy OF((gz_stream *s)); - - -gzFile zip2gz(ZIP* zip, struct zipent* ent) -{ - int err; - gz_stream *s; - const char *path; - int transparent = 0; - uInt len; - - if (!zip || !ent) - return NULL; - - /* zip stuff */ - if (ent->compression_method == 0x0000) - { - /* file is not compressed, simply stored */ - - /* check if size are equal */ - if (ent->compressed_size != ent->uncompressed_size) { - errormsg("Wrong uncompressed size in store compression", ERROR_CORRUPT,zip->zip); - return NULL; - } - - transparent = 1; - } - else if (ent->compression_method == 0x0008) - { - /* file is compressed using "Deflate" method */ - if (ent->version_needed_to_extract > 0x14) { - errormsg("Version too new", ERROR_UNSUPPORTED,zip->zip); - return NULL; - } - - if (ent->os_needed_to_extract != 0x00) { - errormsg("OS not supported", ERROR_UNSUPPORTED,zip->zip); - return NULL; - } - - if (ent->disk_number_start != zip->number_of_this_disk) { - errormsg("Cannot span disks", ERROR_UNSUPPORTED,zip->zip); - return NULL; - } - - } else { - errormsg("Compression method unsupported", ERROR_UNSUPPORTED, zip->zip); - return NULL; - } - - /* seek to compressed data */ - if (seekcompresszip(zip,ent) != 0) { - return NULL; - } - - path = zip->zip; - - /* normal gzip init for read */ - s = (gz_stream *)ALLOC(sizeof(gz_stream)); - if (!s) return Z_NULL; - - s->stream.zalloc = (alloc_func)0; - s->stream.zfree = (free_func)0; - s->stream.opaque = (voidpf)0; - s->stream.next_in = s->inbuf = Z_NULL; - s->stream.next_out = s->outbuf = Z_NULL; - s->stream.avail_in = s->stream.avail_out = 0; - s->file = NULL; - s->z_err = Z_OK; - s->z_eof = 0; - s->in = 0; - s->out = 0; - s->back = EOF; - s->crc = crc32(0L, Z_NULL, 0); - s->msg = NULL; - s->transparent = transparent; - s->mode = 'r'; - - s->path = (char*)ALLOC(strlen(path)+1); - if (s->path == NULL) { - return destroy(s), (gzFile)Z_NULL; - } - strcpy(s->path, path); /* do this early for debugging */ - - s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); - - err = inflateInit2(&(s->stream), -MAX_WBITS); - /* windowBits is passed < 0 to tell that there is no zlib header. - * Note that in this case inflate *requires* an extra "dummy" byte - * after the compressed stream in order to complete decompression and - * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are - * present after the compressed stream. - */ - if (err != Z_OK || s->inbuf == Z_NULL) { - return destroy(s), (gzFile)Z_NULL; - } - s->stream.avail_out = Z_BUFSIZE; - - errno = 0; - s->file = zip->fp; - if (s->file == NULL) { - return destroy(s), (gzFile)Z_NULL; - } - - /* check_header(s); */ - errno = 0; - len = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file); - if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO; - s->stream.avail_in += len; - s->stream.next_in = s->inbuf; - if (s->stream.avail_in < 2) { - return destroy(s), (gzFile)Z_NULL; - } - - s->start = ftell(s->file) - s->stream.avail_in; - - return (gzFile)s; -} - - -int gzerror2(gzFile file) -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL) - return Z_STREAM_ERROR; - - return s->z_err; -} - - diff --git a/unzip/unzip_stream.h b/unzip/unzip_stream.h deleted file mode 100644 index 59ff2faf..00000000 --- a/unzip/unzip_stream.h +++ /dev/null @@ -1,4 +0,0 @@ - -gzFile zip2gz(ZIP* zip, struct zipent* ent); -int gzerror2(gzFile file); - From 571f7fa8ebacb7c636042051984456135e956465 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 18 Aug 2017 05:19:05 +0200 Subject: [PATCH 120/124] Update jni/Android.mk --- jni/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jni/Android.mk b/jni/Android.mk index 54b9f061..e322752b 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -78,7 +78,7 @@ LOCAL_SRC_FILES += $(R)zlib/gzio.c $(R)zlib/inffast.c $(R)zlib/inflate.c \ $(R)zlib/crc32.c $(R)zlib/adler32.c $(R)zlib/zutil.c \ $(R)zlib/compress.c $(R)zlib/uncompr.c -LOCAL_SRC_FILES += $(R)unzip/unzip.c $(R)unzip/unzip_stream.c +LOCAL_SRC_FILES += $(R)unzip/unzip.c LOCAL_C_INCLUDES += $(R) From ebf923683facb316a0e9fc8d26a7a0b4e4bacbfc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 18 Aug 2017 06:33:04 +0200 Subject: [PATCH 121/124] Should hopefully fix PSP --- pico/draw.c | 2 +- pico/draw_amips.s | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pico/draw.c b/pico/draw.c index cf638e90..bccb4d0c 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -35,7 +35,7 @@ int (*PicoScanBegin)(unsigned int num) = NULL; int (*PicoScanEnd) (unsigned int num) = NULL; static unsigned char DefHighCol[8+320+8]; -static unsigned char *HighColBase = DefHighCol; +unsigned char *HighColBase = DefHighCol; static int HighColIncrement; static unsigned int DefOutBuff[320*2/2]; diff --git a/pico/draw_amips.s b/pico/draw_amips.s index fa7906ee..0fa729e3 100644 --- a/pico/draw_amips.s +++ b/pico/draw_amips.s @@ -117,11 +117,11 @@ amips_clut_loop6: .macro TileEndCode xori $t8, $t9, 0xff beqz $t8, tile11111111 # common case - lui $v1, %hi(HighCol) + lui $v1, %hi(HighColBase) lui $t8, %hi(TileTable) ins $t8, $t9, 2, 8 lw $t8, %lo(TileTable)($t8) - lw $v1, %lo(HighCol)($v1) + lw $v1, %lo(HighColBase)($v1) jr $t8 addu $a0, $v1 .endm @@ -158,8 +158,8 @@ TileFlip: SingleColor: - lui $t9, %hi(HighCol) - lw $t9, %lo(HighCol)($t9) + lui $t9, %hi(HighColBase) + lw $t9, %lo(HighColBase)($t9) andi $t0, $a1, 0xf or $t0, $t0, $a2 addu $a0, $t9 @@ -178,7 +178,7 @@ TileEmpty: or $v0, $0, 1 # empty tile tile11111111: - lw $v1, %lo(HighCol)($v1) + lw $v1, %lo(HighColBase)($v1) or $t0, $t0, $a2 addu $a0, $v1 sb $t0, 0($a0) From eac2357fafe6ed29407e583aee71834c36a0319f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 18 Aug 2017 07:07:29 +0200 Subject: [PATCH 122/124] Attempt two to fix PSP --- pico/draw.c | 3 ++- pico/draw_amips.s | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pico/draw.c b/pico/draw.c index bccb4d0c..4c96a9ae 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -35,7 +35,8 @@ int (*PicoScanBegin)(unsigned int num) = NULL; int (*PicoScanEnd) (unsigned int num) = NULL; static unsigned char DefHighCol[8+320+8]; -unsigned char *HighColBase = DefHighCol; +unsigned char *HighCol = DefHighCol; +static unsigned char *HighColBase = DefHighCol; static int HighColIncrement; static unsigned int DefOutBuff[320*2/2]; diff --git a/pico/draw_amips.s b/pico/draw_amips.s index 0fa729e3..fa7906ee 100644 --- a/pico/draw_amips.s +++ b/pico/draw_amips.s @@ -117,11 +117,11 @@ amips_clut_loop6: .macro TileEndCode xori $t8, $t9, 0xff beqz $t8, tile11111111 # common case - lui $v1, %hi(HighColBase) + lui $v1, %hi(HighCol) lui $t8, %hi(TileTable) ins $t8, $t9, 2, 8 lw $t8, %lo(TileTable)($t8) - lw $v1, %lo(HighColBase)($v1) + lw $v1, %lo(HighCol)($v1) jr $t8 addu $a0, $v1 .endm @@ -158,8 +158,8 @@ TileFlip: SingleColor: - lui $t9, %hi(HighColBase) - lw $t9, %lo(HighColBase)($t9) + lui $t9, %hi(HighCol) + lw $t9, %lo(HighCol)($t9) andi $t0, $a1, 0xf or $t0, $t0, $a2 addu $a0, $t9 @@ -178,7 +178,7 @@ TileEmpty: or $v0, $0, 1 # empty tile tile11111111: - lw $v1, %lo(HighColBase)($v1) + lw $v1, %lo(HighCol)($v1) or $t0, $t0, $a2 addu $a0, $v1 sb $t0, 0($a0) From 40cd7bc40b282c451cbb9bf064227d3d069a09f6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 18 Aug 2017 07:13:20 +0200 Subject: [PATCH 123/124] Add this to pico.h --- pico/pico.h | 1 + 1 file changed, 1 insertion(+) diff --git a/pico/pico.h b/pico/pico.h index a1aa96ee..d22babd5 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -172,6 +172,7 @@ typedef enum void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode); void PicoDrawSetOutBuf(void *dest, int increment); void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned int num)); +extern unsigned char *HighCol; // utility #ifdef _ASM_DRAW_C void vidConvCpyRGB565(void *to, void *from, int pixels); From c7d7ac71a421c43c0c701b18c58b87fc868e02d8 Mon Sep 17 00:00:00 2001 From: Conn O'Griofa Date: Tue, 5 Sep 2017 15:40:44 +0100 Subject: [PATCH 124/124] libretro: fix unexpected reloc type 0x03 error on Raspberry Pi 3 Issue is caused by commit 66dda842eae01f47f5389b931ec9567fb0bbb6a1 in cpu/cyclone submodule. --- Makefile.libretro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index 306c8afb..14f2dc50 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -366,7 +366,7 @@ else ifeq ($(platform), qnx) # ARM else ifneq (,$(findstring armv,$(platform))) TARGET := $(TARGET_NAME)_libretro.so - SHARED := -shared -Wl,--no-undefined + SHARED := -shared -Wl,--no-undefined,-Bsymbolic fpic := -fPIC ifneq (,$(findstring cortexa5,$(platform))) CFLAGS += -marm -mcpu=cortex-a5