/*
* 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.
* See COPYING file in the top-level directory.
void linearFree(void* mem);
static int ctr_svchack_successful = 0;
+
+#elif defined(VITA)
+#define TARGET_SIZE_2 24 // 2^24 = 16 megabytes
+
+#include <psp2/kernel/sysmem.h>
+static int sceBlock;
+int getVMBlock();
+int _newlib_vm_size_user = 1 << TARGET_SIZE_2;
+
#endif
#include <pico/pico_int.h>
#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];
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
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)
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)
{ "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
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 */
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;
{ 0 },
};
+ sram_reset();
+
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) {
if (log_cb)
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";
#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