| 1 | /* |
| 2 | * (C) notaz, 2012,2014,2015 |
| 3 | * |
| 4 | * This work is licensed under the terms of the GNU GPLv2 or later. |
| 5 | * See the COPYING file in the top-level directory. |
| 6 | */ |
| 7 | |
| 8 | #define _GNU_SOURCE 1 // strcasestr |
| 9 | #include <stdio.h> |
| 10 | #include <stdlib.h> |
| 11 | #include <string.h> |
| 12 | #include <strings.h> |
| 13 | #ifdef __MACH__ |
| 14 | #include <unistd.h> |
| 15 | #include <sys/syscall.h> |
| 16 | #endif |
| 17 | |
| 18 | #include "../libpcsxcore/misc.h" |
| 19 | #include "../libpcsxcore/psxcounters.h" |
| 20 | #include "../libpcsxcore/psxmem_map.h" |
| 21 | #include "../libpcsxcore/new_dynarec/new_dynarec.h" |
| 22 | #include "../libpcsxcore/cdrom.h" |
| 23 | #include "../libpcsxcore/cdriso.h" |
| 24 | #include "../libpcsxcore/cheat.h" |
| 25 | #include "../libpcsxcore/r3000a.h" |
| 26 | #include "../plugins/dfsound/out.h" |
| 27 | #include "../plugins/dfsound/spu_config.h" |
| 28 | #include "../plugins/dfinput/externals.h" |
| 29 | #include "cspace.h" |
| 30 | #include "main.h" |
| 31 | #include "menu.h" |
| 32 | #include "plugin.h" |
| 33 | #include "plugin_lib.h" |
| 34 | #include "arm_features.h" |
| 35 | #include "revision.h" |
| 36 | #include "libretro.h" |
| 37 | |
| 38 | #ifdef _3DS |
| 39 | #include "3ds/3ds_utils.h" |
| 40 | #endif |
| 41 | |
| 42 | #define PORTS_NUMBER 8 |
| 43 | |
| 44 | #ifndef MIN |
| 45 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) |
| 46 | #endif |
| 47 | |
| 48 | #ifndef MAX |
| 49 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) |
| 50 | #endif |
| 51 | |
| 52 | #define ISHEXDEC ((buf[cursor]>='0') && (buf[cursor]<='9')) || ((buf[cursor]>='a') && (buf[cursor]<='f')) || ((buf[cursor]>='A') && (buf[cursor]<='F')) |
| 53 | |
| 54 | #define INTERNAL_FPS_SAMPLE_PERIOD 64 |
| 55 | |
| 56 | //hack to prevent retroarch freezing when reseting in the menu but not while running with the hot key |
| 57 | static int rebootemu = 0; |
| 58 | |
| 59 | static retro_video_refresh_t video_cb; |
| 60 | static retro_input_poll_t input_poll_cb; |
| 61 | static retro_input_state_t input_state_cb; |
| 62 | static retro_environment_t environ_cb; |
| 63 | static retro_audio_sample_batch_t audio_batch_cb; |
| 64 | static retro_set_rumble_state_t rumble_cb; |
| 65 | static struct retro_log_callback logging; |
| 66 | static retro_log_printf_t log_cb; |
| 67 | |
| 68 | static void *vout_buf; |
| 69 | static void * vout_buf_ptr; |
| 70 | static int vout_width, vout_height; |
| 71 | static int vout_doffs_old, vout_fb_dirty; |
| 72 | static bool vout_can_dupe; |
| 73 | static bool duping_enable; |
| 74 | static bool found_bios; |
| 75 | static bool display_internal_fps = false; |
| 76 | static unsigned frame_count = 0; |
| 77 | static bool libretro_supports_bitmasks = false; |
| 78 | |
| 79 | static int plugins_opened; |
| 80 | static int is_pal_mode; |
| 81 | |
| 82 | /* memory card data */ |
| 83 | extern char Mcd1Data[MCD_SIZE]; |
| 84 | extern char Mcd2Data[MCD_SIZE]; |
| 85 | extern char McdDisable[2]; |
| 86 | |
| 87 | /* PCSX ReARMed core calls and stuff */ |
| 88 | int in_type[8] = { PSE_PAD_TYPE_NONE, PSE_PAD_TYPE_NONE, |
| 89 | PSE_PAD_TYPE_NONE, PSE_PAD_TYPE_NONE, |
| 90 | PSE_PAD_TYPE_NONE, PSE_PAD_TYPE_NONE, |
| 91 | PSE_PAD_TYPE_NONE, PSE_PAD_TYPE_NONE }; |
| 92 | int in_analog_left[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; |
| 93 | int in_analog_right[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; |
| 94 | unsigned short in_keystate[PORTS_NUMBER]; |
| 95 | int multitap1 = 0; |
| 96 | int multitap2 = 0; |
| 97 | int in_enable_vibration = 1; |
| 98 | |
| 99 | // NegCon adjustment parameters |
| 100 | // > The NegCon 'twist' action is somewhat awkward when mapped |
| 101 | // to a standard analog stick -> user should be able to tweak |
| 102 | // response/deadzone for comfort |
| 103 | // > When response is linear, 'additional' deadzone (set here) |
| 104 | // may be left at zero, since this is normally handled via in-game |
| 105 | // options menus |
| 106 | // > When response is non-linear, deadzone should be set to match the |
| 107 | // controller being used (otherwise precision may be lost) |
| 108 | // > negcon_linearity: |
| 109 | // - 1: Response is linear - recommended when using racing wheel |
| 110 | // peripherals, not recommended for standard gamepads |
| 111 | // - 2: Response is quadratic - optimal setting for gamepads |
| 112 | // - 3: Response is cubic - enables precise fine control, but |
| 113 | // difficult to use... |
| 114 | #define NEGCON_RANGE 0x7FFF |
| 115 | static int negcon_deadzone = 0; |
| 116 | static int negcon_linearity = 1; |
| 117 | |
| 118 | /* PSX max resolution is 640x512, but with enhancement it's 1024x512 */ |
| 119 | #define VOUT_MAX_WIDTH 1024 |
| 120 | #define VOUT_MAX_HEIGHT 512 |
| 121 | |
| 122 | //Dummy functions |
| 123 | bool retro_load_game_special(unsigned game_type, const struct retro_game_info *info, size_t num_info){return false;} |
| 124 | void retro_unload_game(void){} |
| 125 | static int vout_open(void){return 0;} |
| 126 | static void vout_close(void){} |
| 127 | static int snd_init(void){return 0;} |
| 128 | static void snd_finish(void){} |
| 129 | static int snd_busy(void){return 0;} |
| 130 | |
| 131 | static void init_memcard(char *mcd_data) |
| 132 | { |
| 133 | unsigned off = 0; |
| 134 | unsigned i; |
| 135 | |
| 136 | memset(mcd_data, 0, MCD_SIZE); |
| 137 | |
| 138 | mcd_data[off++] = 'M'; |
| 139 | mcd_data[off++] = 'C'; |
| 140 | off += 0x7d; |
| 141 | mcd_data[off++] = 0x0e; |
| 142 | |
| 143 | for (i = 0; i < 15; i++) { |
| 144 | mcd_data[off++] = 0xa0; |
| 145 | off += 0x07; |
| 146 | mcd_data[off++] = 0xff; |
| 147 | mcd_data[off++] = 0xff; |
| 148 | off += 0x75; |
| 149 | mcd_data[off++] = 0xa0; |
| 150 | } |
| 151 | |
| 152 | for (i = 0; i < 20; i++) { |
| 153 | mcd_data[off++] = 0xff; |
| 154 | mcd_data[off++] = 0xff; |
| 155 | mcd_data[off++] = 0xff; |
| 156 | mcd_data[off++] = 0xff; |
| 157 | off += 0x04; |
| 158 | mcd_data[off++] = 0xff; |
| 159 | mcd_data[off++] = 0xff; |
| 160 | off += 0x76; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | static void set_vout_fb() |
| 165 | { |
| 166 | struct retro_framebuffer fb = {0}; |
| 167 | |
| 168 | fb.width = vout_width; |
| 169 | fb.height = vout_height; |
| 170 | fb.access_flags = RETRO_MEMORY_ACCESS_WRITE; |
| 171 | |
| 172 | if (environ_cb(RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER, &fb) && fb.format == RETRO_PIXEL_FORMAT_RGB565) |
| 173 | vout_buf_ptr = (uint16_t*)fb.data; |
| 174 | else |
| 175 | vout_buf_ptr = vout_buf; |
| 176 | } |
| 177 | |
| 178 | static void vout_set_mode(int w, int h, int raw_w, int raw_h, int bpp) |
| 179 | { |
| 180 | vout_width = w; |
| 181 | vout_height = h; |
| 182 | |
| 183 | set_vout_fb(); |
| 184 | } |
| 185 | |
| 186 | #ifndef FRONTEND_SUPPORTS_RGB565 |
| 187 | static void convert(void *buf, size_t bytes) |
| 188 | { |
| 189 | unsigned int i, v, *p = buf; |
| 190 | |
| 191 | for (i = 0; i < bytes / 4; i++) { |
| 192 | v = p[i]; |
| 193 | p[i] = (v & 0x001f001f) | ((v >> 1) & 0x7fe07fe0); |
| 194 | } |
| 195 | } |
| 196 | #endif |
| 197 | |
| 198 | static void vout_flip(const void *vram, int stride, int bgr24, int w, int h) |
| 199 | { |
| 200 | unsigned short *dest = vout_buf_ptr; |
| 201 | const unsigned short *src = vram; |
| 202 | int dstride = vout_width, h1 = h; |
| 203 | int doffs; |
| 204 | |
| 205 | if (vram == NULL) { |
| 206 | // blanking |
| 207 | memset(vout_buf_ptr, 0, dstride * h * 2); |
| 208 | goto out; |
| 209 | } |
| 210 | |
| 211 | doffs = (vout_height - h) * dstride; |
| 212 | doffs += (dstride - w) / 2 & ~1; |
| 213 | if (doffs != vout_doffs_old) { |
| 214 | // clear borders |
| 215 | memset(vout_buf_ptr, 0, dstride * h * 2); |
| 216 | vout_doffs_old = doffs; |
| 217 | } |
| 218 | dest += doffs; |
| 219 | |
| 220 | if (bgr24) |
| 221 | { |
| 222 | // XXX: could we switch to RETRO_PIXEL_FORMAT_XRGB8888 here? |
| 223 | for (; h1-- > 0; dest += dstride, src += stride) |
| 224 | { |
| 225 | bgr888_to_rgb565(dest, src, w * 3); |
| 226 | } |
| 227 | } |
| 228 | else |
| 229 | { |
| 230 | for (; h1-- > 0; dest += dstride, src += stride) |
| 231 | { |
| 232 | bgr555_to_rgb565(dest, src, w * 2); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | out: |
| 237 | #ifndef FRONTEND_SUPPORTS_RGB565 |
| 238 | convert(vout_buf_ptr, vout_width * vout_height * 2); |
| 239 | #endif |
| 240 | vout_fb_dirty = 1; |
| 241 | pl_rearmed_cbs.flip_cnt++; |
| 242 | } |
| 243 | |
| 244 | #ifdef _3DS |
| 245 | typedef struct |
| 246 | { |
| 247 | void* buffer; |
| 248 | uint32_t target_map; |
| 249 | size_t size; |
| 250 | enum psxMapTag tag; |
| 251 | }psx_map_t; |
| 252 | |
| 253 | psx_map_t custom_psx_maps[] = { |
| 254 | {NULL, 0x13000000, 0x210000, MAP_TAG_RAM}, // 0x80000000 |
| 255 | {NULL, 0x12800000, 0x010000, MAP_TAG_OTHER}, // 0x1f800000 |
| 256 | {NULL, 0x12c00000, 0x080000, MAP_TAG_OTHER}, // 0x1fc00000 |
| 257 | {NULL, 0x11000000, 0x800000, MAP_TAG_LUTS}, // 0x08000000 |
| 258 | {NULL, 0x12000000, 0x200000, MAP_TAG_VRAM}, // 0x00000000 |
| 259 | }; |
| 260 | |
| 261 | void* pl_3ds_mmap(unsigned long addr, size_t size, int is_fixed, |
| 262 | enum psxMapTag tag) |
| 263 | { |
| 264 | (void)is_fixed; |
| 265 | (void)addr; |
| 266 | |
| 267 | if (__ctr_svchax) |
| 268 | { |
| 269 | psx_map_t* custom_map = custom_psx_maps; |
| 270 | |
| 271 | for (; custom_map->size; custom_map++) |
| 272 | { |
| 273 | if ((custom_map->size == size) && (custom_map->tag == tag)) |
| 274 | { |
| 275 | uint32_t ptr_aligned, tmp; |
| 276 | |
| 277 | custom_map->buffer = malloc(size + 0x1000); |
| 278 | ptr_aligned = (((u32)custom_map->buffer) + 0xFFF) & ~0xFFF; |
| 279 | |
| 280 | if(svcControlMemory(&tmp, (void*)custom_map->target_map, (void*)ptr_aligned, size, MEMOP_MAP, 0x3) < 0) |
| 281 | { |
| 282 | SysPrintf("could not map memory @0x%08X\n", custom_map->target_map); |
| 283 | exit(1); |
| 284 | } |
| 285 | |
| 286 | return (void*)custom_map->target_map; |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | return malloc(size); |
| 292 | } |
| 293 | |
| 294 | void pl_3ds_munmap(void *ptr, size_t size, enum psxMapTag tag) |
| 295 | { |
| 296 | (void)tag; |
| 297 | |
| 298 | if (__ctr_svchax) |
| 299 | { |
| 300 | psx_map_t* custom_map = custom_psx_maps; |
| 301 | |
| 302 | for (; custom_map->size; custom_map++) |
| 303 | { |
| 304 | if ((custom_map->target_map == (uint32_t)ptr)) |
| 305 | { |
| 306 | uint32_t ptr_aligned, tmp; |
| 307 | |
| 308 | ptr_aligned = (((u32)custom_map->buffer) + 0xFFF) & ~0xFFF; |
| 309 | |
| 310 | svcControlMemory(&tmp, (void*)custom_map->target_map, (void*)ptr_aligned, size, MEMOP_UNMAP, 0x3); |
| 311 | |
| 312 | free(custom_map->buffer); |
| 313 | custom_map->buffer = NULL; |
| 314 | return; |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | free(ptr); |
| 320 | } |
| 321 | #endif |
| 322 | |
| 323 | #ifdef VITA |
| 324 | typedef struct |
| 325 | { |
| 326 | void* buffer; |
| 327 | uint32_t target_map; |
| 328 | size_t size; |
| 329 | enum psxMapTag tag; |
| 330 | }psx_map_t; |
| 331 | |
| 332 | void* addr = NULL; |
| 333 | |
| 334 | psx_map_t custom_psx_maps[] = { |
| 335 | {NULL, NULL, 0x210000, MAP_TAG_RAM}, // 0x80000000 |
| 336 | {NULL, NULL, 0x010000, MAP_TAG_OTHER}, // 0x1f800000 |
| 337 | {NULL, NULL, 0x080000, MAP_TAG_OTHER}, // 0x1fc00000 |
| 338 | {NULL, NULL, 0x800000, MAP_TAG_LUTS}, // 0x08000000 |
| 339 | {NULL, NULL, 0x200000, MAP_TAG_VRAM}, // 0x00000000 |
| 340 | }; |
| 341 | |
| 342 | int init_vita_mmap(){ |
| 343 | int n; |
| 344 | void * tmpaddr; |
| 345 | addr = malloc(64*1024*1024); |
| 346 | if(addr==NULL) |
| 347 | return -1; |
| 348 | tmpaddr = ((u32)(addr+0xFFFFFF))&~0xFFFFFF; |
| 349 | custom_psx_maps[0].buffer=tmpaddr+0x2000000; |
| 350 | custom_psx_maps[1].buffer=tmpaddr+0x1800000; |
| 351 | custom_psx_maps[2].buffer=tmpaddr+0x1c00000; |
| 352 | custom_psx_maps[3].buffer=tmpaddr+0x0000000; |
| 353 | custom_psx_maps[4].buffer=tmpaddr+0x1000000; |
| 354 | #if 0 |
| 355 | for(n = 0; n < 5; n++){ |
| 356 | sceClibPrintf("addr reserved %x\n",custom_psx_maps[n].buffer); |
| 357 | } |
| 358 | #endif |
| 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | void deinit_vita_mmap(){ |
| 363 | free(addr); |
| 364 | } |
| 365 | |
| 366 | void* pl_vita_mmap(unsigned long addr, size_t size, int is_fixed, |
| 367 | enum psxMapTag tag) |
| 368 | { |
| 369 | (void)is_fixed; |
| 370 | (void)addr; |
| 371 | |
| 372 | |
| 373 | psx_map_t* custom_map = custom_psx_maps; |
| 374 | |
| 375 | for (; custom_map->size; custom_map++) |
| 376 | { |
| 377 | if ((custom_map->size == size) && (custom_map->tag == tag)) |
| 378 | { |
| 379 | return custom_map->buffer; |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | |
| 384 | return malloc(size); |
| 385 | } |
| 386 | |
| 387 | void pl_vita_munmap(void *ptr, size_t size, enum psxMapTag tag) |
| 388 | { |
| 389 | (void)tag; |
| 390 | |
| 391 | psx_map_t* custom_map = custom_psx_maps; |
| 392 | |
| 393 | for (; custom_map->size; custom_map++) |
| 394 | { |
| 395 | if ((custom_map->buffer == ptr)) |
| 396 | { |
| 397 | return; |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | free(ptr); |
| 402 | } |
| 403 | #endif |
| 404 | |
| 405 | static void *pl_mmap(unsigned int size) |
| 406 | { |
| 407 | return psxMap(0, size, 0, MAP_TAG_VRAM); |
| 408 | } |
| 409 | |
| 410 | static void pl_munmap(void *ptr, unsigned int size) |
| 411 | { |
| 412 | psxUnmap(ptr, size, MAP_TAG_VRAM); |
| 413 | } |
| 414 | |
| 415 | struct rearmed_cbs pl_rearmed_cbs = { |
| 416 | .pl_vout_open = vout_open, |
| 417 | .pl_vout_set_mode = vout_set_mode, |
| 418 | .pl_vout_flip = vout_flip, |
| 419 | .pl_vout_close = vout_close, |
| 420 | .mmap = pl_mmap, |
| 421 | .munmap = pl_munmap, |
| 422 | /* from psxcounters */ |
| 423 | .gpu_hcnt = &hSyncCount, |
| 424 | .gpu_frame_count = &frame_counter, |
| 425 | }; |
| 426 | |
| 427 | void pl_frame_limit(void) |
| 428 | { |
| 429 | /* called once per frame, make psxCpu->Execute() above return */ |
| 430 | stop = 1; |
| 431 | } |
| 432 | |
| 433 | void pl_timing_prepare(int is_pal) |
| 434 | { |
| 435 | is_pal_mode = is_pal; |
| 436 | } |
| 437 | |
| 438 | void plat_trigger_vibrate(int pad, int low, int high) |
| 439 | { |
| 440 | if (!rumble_cb) |
| 441 | return; |
| 442 | |
| 443 | if (in_enable_vibration) |
| 444 | { |
| 445 | rumble_cb(pad, RETRO_RUMBLE_STRONG, high << 8); |
| 446 | rumble_cb(pad, RETRO_RUMBLE_WEAK, low ? 0xffff : 0x0); |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | void pl_update_gun(int *xn, int *yn, int *xres, int *yres, int *in) |
| 451 | { |
| 452 | } |
| 453 | |
| 454 | /* sound calls */ |
| 455 | static void snd_feed(void *buf, int bytes) |
| 456 | { |
| 457 | if (audio_batch_cb != NULL) |
| 458 | audio_batch_cb(buf, bytes / 4); |
| 459 | } |
| 460 | |
| 461 | void out_register_libretro(struct out_driver *drv) |
| 462 | { |
| 463 | drv->name = "libretro"; |
| 464 | drv->init = snd_init; |
| 465 | drv->finish = snd_finish; |
| 466 | drv->busy = snd_busy; |
| 467 | drv->feed = snd_feed; |
| 468 | } |
| 469 | |
| 470 | /* libretro */ |
| 471 | void retro_set_environment(retro_environment_t cb) |
| 472 | { |
| 473 | static const struct retro_variable vars[] = { |
| 474 | { "pcsx_rearmed_frameskip", "Frameskip; 0|1|2|3" }, |
| 475 | { "pcsx_rearmed_bios", "Use BIOS; auto|HLE" }, |
| 476 | { "pcsx_rearmed_region", "Region; auto|NTSC|PAL" }, |
| 477 | { "pcsx_rearmed_memcard2", "Enable second memory card; disabled|enabled" }, |
| 478 | { "pcsx_rearmed_pad1type", "Pad 1 Type; standard|analog|dualshock|negcon|none" }, |
| 479 | { "pcsx_rearmed_pad2type", "Pad 2 Type; standard|analog|dualshock|negcon|none" }, |
| 480 | { "pcsx_rearmed_pad3type", "Pad 3 Type; none|standard|analog|dualshock|negcon" }, |
| 481 | { "pcsx_rearmed_pad4type", "Pad 4 Type; none|standard|analog|dualshock|negcon" }, |
| 482 | { "pcsx_rearmed_pad5type", "Pad 5 Type; none|standard|analog|dualshock|negcon" }, |
| 483 | { "pcsx_rearmed_pad6type", "Pad 6 Type; none|standard|analog|dualshock|negcon" }, |
| 484 | { "pcsx_rearmed_pad7type", "Pad 7 Type; none|standard|analog|dualshock|negcon" }, |
| 485 | { "pcsx_rearmed_pad8type", "Pad 8 Type; none|standard|analog|dualshock|negcon" }, |
| 486 | { "pcsx_rearmed_multitap1", "Multitap 1; auto|disabled|enabled" }, |
| 487 | { "pcsx_rearmed_multitap2", "Multitap 2; auto|disabled|enabled" }, |
| 488 | { "pcsx_rearmed_negcon_deadzone", "NegCon Twist Deadzone (percent); 0|5|10|15|20|25|30" }, |
| 489 | { "pcsx_rearmed_negcon_response", "NegCon Twist Response; linear|quadratic|cubic" }, |
| 490 | { "pcsx_rearmed_vibration", "Enable Vibration; enabled|disabled" }, |
| 491 | { "pcsx_rearmed_dithering", "Enable Dithering; enabled|disabled" }, |
| 492 | #ifndef DRC_DISABLE |
| 493 | { "pcsx_rearmed_drc", "Dynamic recompiler; enabled|disabled" }, |
| 494 | #ifdef HAVE_PRE_ARMV7 |
| 495 | { "pcsx_rearmed_psxclock", "PSX cpu clock (default 50); 50|51|52|53|54|55|5657|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49" }, |
| 496 | #else |
| 497 | { "pcsx_rearmed_psxclock", "PSX cpu clock (default 57); 57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56" }, |
| 498 | #endif |
| 499 | #endif |
| 500 | #ifdef __ARM_NEON__ |
| 501 | { "pcsx_rearmed_neon_interlace_enable", "Enable interlacing mode(s); disabled|enabled" }, |
| 502 | { "pcsx_rearmed_neon_enhancement_enable", "Enhanced resolution (slow); disabled|enabled" }, |
| 503 | { "pcsx_rearmed_neon_enhancement_no_main", "Enhanced resolution speed hack; disabled|enabled" }, |
| 504 | #endif |
| 505 | { "pcsx_rearmed_duping_enable", "Frame duping; enabled|disabled" }, |
| 506 | { "pcsx_rearmed_display_internal_fps", "Display Internal FPS; disabled|enabled" }, |
| 507 | { "pcsx_rearmed_show_bios_bootlogo", "Show Bios Bootlogo(Breaks some games); disabled|enabled" }, |
| 508 | { "pcsx_rearmed_spu_reverb", "Sound: Reverb; enabled|disabled" }, |
| 509 | { "pcsx_rearmed_spu_interpolation", "Sound: Interpolation; simple|gaussian|cubic|off" }, |
| 510 | { "pcsx_rearmed_idiablofix", "Diablo Music Fix; disabled|enabled" }, |
| 511 | { "pcsx_rearmed_pe2_fix", "Parasite Eve 2/Vandal Hearts 1/2 Fix; disabled|enabled" }, |
| 512 | { "pcsx_rearmed_inuyasha_fix", "InuYasha Sengoku Battle Fix; disabled|enabled" }, |
| 513 | |
| 514 | /* Advance options */ |
| 515 | { "pcsx_rearmed_noxadecoding", "XA Decoding; enabled|disabled" }, |
| 516 | { "pcsx_rearmed_nocdaudio", "CD Audio; enabled|disabled" }, |
| 517 | #ifndef DRC_DISABLE |
| 518 | { "pcsx_rearmed_nosmccheck", "(Speed Hack) Disable SMC Checks; disabled|enabled" }, |
| 519 | { "pcsx_rearmed_gteregsunneeded", "(Speed Hack) Assume GTE Regs Unneeded; disabled|enabled" }, |
| 520 | { "pcsx_rearmed_nogteflags", "(Speed Hack) Disable GTE Flags; disabled|enabled" }, |
| 521 | #endif |
| 522 | |
| 523 | { NULL, NULL } |
| 524 | }; |
| 525 | |
| 526 | if (cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &logging)) |
| 527 | log_cb = logging.log; |
| 528 | |
| 529 | environ_cb = cb; |
| 530 | |
| 531 | cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars); |
| 532 | } |
| 533 | |
| 534 | void retro_set_video_refresh(retro_video_refresh_t cb) { video_cb = cb; } |
| 535 | void retro_set_audio_sample(retro_audio_sample_t cb) { (void)cb; } |
| 536 | void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb) { audio_batch_cb = cb; } |
| 537 | void retro_set_input_poll(retro_input_poll_t cb) { input_poll_cb = cb; } |
| 538 | void retro_set_input_state(retro_input_state_t cb) { input_state_cb = cb; } |
| 539 | |
| 540 | unsigned retro_api_version(void) |
| 541 | { |
| 542 | return RETRO_API_VERSION; |
| 543 | } |
| 544 | |
| 545 | static int controller_port_variable(unsigned port, struct retro_variable *var) |
| 546 | { |
| 547 | if (port >= PORTS_NUMBER) |
| 548 | return 0; |
| 549 | |
| 550 | if (!environ_cb) |
| 551 | return 0; |
| 552 | |
| 553 | var->value = NULL; |
| 554 | switch (port) { |
| 555 | case 0: |
| 556 | var->key = "pcsx_rearmed_pad1type"; |
| 557 | break; |
| 558 | case 1: |
| 559 | var->key = "pcsx_rearmed_pad2type"; |
| 560 | break; |
| 561 | case 2: |
| 562 | var->key = "pcsx_rearmed_pad3type"; |
| 563 | break; |
| 564 | case 3: |
| 565 | var->key = "pcsx_rearmed_pad4type"; |
| 566 | break; |
| 567 | case 4: |
| 568 | var->key = "pcsx_rearmed_pad5type"; |
| 569 | break; |
| 570 | case 5: |
| 571 | var->key = "pcsx_rearmed_pad6type"; |
| 572 | break; |
| 573 | case 6: |
| 574 | var->key = "pcsx_rearmed_pad7type"; |
| 575 | break; |
| 576 | case 7: |
| 577 | var->key = "pcsx_rearmed_pad8type"; |
| 578 | break; |
| 579 | } |
| 580 | |
| 581 | return environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, var) || var->value; |
| 582 | } |
| 583 | |
| 584 | static void update_controller_port_variable(unsigned port) |
| 585 | { |
| 586 | if (port >= PORTS_NUMBER) |
| 587 | return; |
| 588 | |
| 589 | struct retro_variable var; |
| 590 | |
| 591 | if (controller_port_variable(port, &var)) |
| 592 | { |
| 593 | if (strcmp(var.value, "standard") == 0) |
| 594 | in_type[port] = PSE_PAD_TYPE_STANDARD; |
| 595 | else if (strcmp(var.value, "analog") == 0) |
| 596 | in_type[port] = PSE_PAD_TYPE_ANALOGJOY; |
| 597 | else if (strcmp(var.value, "dualshock") == 0) |
| 598 | in_type[port] = PSE_PAD_TYPE_ANALOGPAD; |
| 599 | else if (strcmp(var.value, "negcon") == 0) |
| 600 | in_type[port] = PSE_PAD_TYPE_NEGCON; |
| 601 | else if (strcmp(var.value, "none") == 0) |
| 602 | in_type[port] = PSE_PAD_TYPE_NONE; |
| 603 | // else 'default' case, do nothing |
| 604 | } |
| 605 | } |
| 606 | |
| 607 | static void update_controller_port_device(unsigned port, unsigned device) |
| 608 | { |
| 609 | if (port >= PORTS_NUMBER) |
| 610 | return; |
| 611 | |
| 612 | struct retro_variable var; |
| 613 | |
| 614 | if (!controller_port_variable(port, &var)) |
| 615 | return; |
| 616 | |
| 617 | if (strcmp(var.value, "default") != 0) |
| 618 | return; |
| 619 | |
| 620 | switch (device) |
| 621 | { |
| 622 | case RETRO_DEVICE_JOYPAD: |
| 623 | in_type[port] = PSE_PAD_TYPE_STANDARD; |
| 624 | break; |
| 625 | case RETRO_DEVICE_ANALOG: |
| 626 | in_type[port] = PSE_PAD_TYPE_ANALOGPAD; |
| 627 | break; |
| 628 | case RETRO_DEVICE_MOUSE: |
| 629 | in_type[port] = PSE_PAD_TYPE_MOUSE; |
| 630 | break; |
| 631 | case RETRO_DEVICE_LIGHTGUN: |
| 632 | in_type[port] = PSE_PAD_TYPE_GUN; |
| 633 | break; |
| 634 | case RETRO_DEVICE_NONE: |
| 635 | default: |
| 636 | in_type[port] = PSE_PAD_TYPE_NONE; |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | static void update_multitap() |
| 641 | { |
| 642 | struct retro_variable var; |
| 643 | int auto_case, port; |
| 644 | |
| 645 | var.value = NULL; |
| 646 | var.key = "pcsx_rearmed_multitap1"; |
| 647 | auto_case = 0; |
| 648 | if (environ_cb && (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)) |
| 649 | { |
| 650 | if (strcmp(var.value, "enabled") == 0) |
| 651 | multitap1 = 1; |
| 652 | else if (strcmp(var.value, "disabled") == 0) |
| 653 | multitap1 = 0; |
| 654 | else // 'auto' case |
| 655 | auto_case = 1; |
| 656 | } |
| 657 | else |
| 658 | auto_case = 1; |
| 659 | |
| 660 | if (auto_case) |
| 661 | { |
| 662 | // If a gamepad is plugged after port 2, we need a first multitap. |
| 663 | multitap1 = 0; |
| 664 | for (port = 2; port < PORTS_NUMBER; port++) |
| 665 | multitap1 |= in_type[port] != PSE_PAD_TYPE_NONE; |
| 666 | } |
| 667 | |
| 668 | var.value = NULL; |
| 669 | var.key = "pcsx_rearmed_multitap2"; |
| 670 | auto_case = 0; |
| 671 | if (environ_cb && (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)) |
| 672 | { |
| 673 | if (strcmp(var.value, "enabled") == 0) |
| 674 | multitap2 = 1; |
| 675 | else if (strcmp(var.value, "disabled") == 0) |
| 676 | multitap2 = 0; |
| 677 | else // 'auto' case |
| 678 | auto_case = 1; |
| 679 | } |
| 680 | else |
| 681 | auto_case = 1; |
| 682 | |
| 683 | if (auto_case) |
| 684 | { |
| 685 | // If a gamepad is plugged after port 4, we need a second multitap. |
| 686 | multitap2 = 0; |
| 687 | for (port = 4; port < PORTS_NUMBER; port++) |
| 688 | multitap2 |= in_type[port] != PSE_PAD_TYPE_NONE; |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | void retro_set_controller_port_device(unsigned port, unsigned device) |
| 693 | { |
| 694 | SysPrintf("port %u device %u",port,device); |
| 695 | |
| 696 | if (port >= PORTS_NUMBER) |
| 697 | return; |
| 698 | |
| 699 | update_controller_port_device(port, device); |
| 700 | update_multitap(); |
| 701 | } |
| 702 | |
| 703 | void retro_get_system_info(struct retro_system_info *info) |
| 704 | { |
| 705 | memset(info, 0, sizeof(*info)); |
| 706 | info->library_name = "PCSX-ReARMed"; |
| 707 | #ifndef GIT_VERSION |
| 708 | #define GIT_VERSION "" |
| 709 | #endif |
| 710 | info->library_version = "r22" GIT_VERSION; |
| 711 | info->valid_extensions = "bin|cue|img|mdf|pbp|toc|cbn|m3u|chd"; |
| 712 | info->need_fullpath = true; |
| 713 | } |
| 714 | |
| 715 | void retro_get_system_av_info(struct retro_system_av_info *info) |
| 716 | { |
| 717 | memset(info, 0, sizeof(*info)); |
| 718 | info->timing.fps = is_pal_mode ? 50 : 60; |
| 719 | info->timing.sample_rate = 44100; |
| 720 | info->geometry.base_width = 320; |
| 721 | info->geometry.base_height = 240; |
| 722 | info->geometry.max_width = VOUT_MAX_WIDTH; |
| 723 | info->geometry.max_height = VOUT_MAX_HEIGHT; |
| 724 | info->geometry.aspect_ratio = 4.0 / 3.0; |
| 725 | } |
| 726 | |
| 727 | /* savestates */ |
| 728 | size_t retro_serialize_size(void) |
| 729 | { |
| 730 | // it's currently 4380651-4397047 bytes, |
| 731 | // but have some reserved for future |
| 732 | return 0x440000; |
| 733 | } |
| 734 | |
| 735 | struct save_fp { |
| 736 | char *buf; |
| 737 | size_t pos; |
| 738 | int is_write; |
| 739 | }; |
| 740 | |
| 741 | static void *save_open(const char *name, const char *mode) |
| 742 | { |
| 743 | struct save_fp *fp; |
| 744 | |
| 745 | if (name == NULL || mode == NULL) |
| 746 | return NULL; |
| 747 | |
| 748 | fp = malloc(sizeof(*fp)); |
| 749 | if (fp == NULL) |
| 750 | return NULL; |
| 751 | |
| 752 | fp->buf = (char *)name; |
| 753 | fp->pos = 0; |
| 754 | fp->is_write = (mode[0] == 'w' || mode[1] == 'w'); |
| 755 | |
| 756 | return fp; |
| 757 | } |
| 758 | |
| 759 | static int save_read(void *file, void *buf, u32 len) |
| 760 | { |
| 761 | struct save_fp *fp = file; |
| 762 | if (fp == NULL || buf == NULL) |
| 763 | return -1; |
| 764 | |
| 765 | memcpy(buf, fp->buf + fp->pos, len); |
| 766 | fp->pos += len; |
| 767 | return len; |
| 768 | } |
| 769 | |
| 770 | static int save_write(void *file, const void *buf, u32 len) |
| 771 | { |
| 772 | struct save_fp *fp = file; |
| 773 | if (fp == NULL || buf == NULL) |
| 774 | return -1; |
| 775 | |
| 776 | memcpy(fp->buf + fp->pos, buf, len); |
| 777 | fp->pos += len; |
| 778 | return len; |
| 779 | } |
| 780 | |
| 781 | static long save_seek(void *file, long offs, int whence) |
| 782 | { |
| 783 | struct save_fp *fp = file; |
| 784 | if (fp == NULL) |
| 785 | return -1; |
| 786 | |
| 787 | switch (whence) { |
| 788 | case SEEK_CUR: |
| 789 | fp->pos += offs; |
| 790 | return fp->pos; |
| 791 | case SEEK_SET: |
| 792 | fp->pos = offs; |
| 793 | return fp->pos; |
| 794 | default: |
| 795 | return -1; |
| 796 | } |
| 797 | } |
| 798 | |
| 799 | static void save_close(void *file) |
| 800 | { |
| 801 | struct save_fp *fp = file; |
| 802 | size_t r_size = retro_serialize_size(); |
| 803 | if (fp == NULL) |
| 804 | return; |
| 805 | |
| 806 | if (fp->pos > r_size) |
| 807 | SysPrintf("ERROR: save buffer overflow detected\n"); |
| 808 | else if (fp->is_write && fp->pos < r_size) |
| 809 | // make sure we don't save trash in leftover space |
| 810 | memset(fp->buf + fp->pos, 0, r_size - fp->pos); |
| 811 | free(fp); |
| 812 | } |
| 813 | |
| 814 | bool retro_serialize(void *data, size_t size) |
| 815 | { |
| 816 | int ret = SaveState(data); |
| 817 | return ret == 0 ? true : false; |
| 818 | } |
| 819 | |
| 820 | bool retro_unserialize(const void *data, size_t size) |
| 821 | { |
| 822 | int ret = LoadState(data); |
| 823 | return ret == 0 ? true : false; |
| 824 | } |
| 825 | |
| 826 | /* cheats */ |
| 827 | void retro_cheat_reset(void) |
| 828 | { |
| 829 | ClearAllCheats(); |
| 830 | } |
| 831 | |
| 832 | void retro_cheat_set(unsigned index, bool enabled, const char *code) |
| 833 | { |
| 834 | char buf[256]; |
| 835 | int ret; |
| 836 | |
| 837 | // cheat funcs are destructive, need a copy.. |
| 838 | strncpy(buf, code, sizeof(buf)); |
| 839 | buf[sizeof(buf) - 1] = 0; |
| 840 | |
| 841 | //Prepare buffered cheat for PCSX's AddCheat fucntion. |
| 842 | int cursor=0; |
| 843 | int nonhexdec=0; |
| 844 | while (buf[cursor]){ |
| 845 | if (!(ISHEXDEC)){ |
| 846 | if (++nonhexdec%2){ |
| 847 | buf[cursor]=' '; |
| 848 | } else { |
| 849 | buf[cursor]='\n'; |
| 850 | } |
| 851 | } |
| 852 | cursor++; |
| 853 | } |
| 854 | |
| 855 | |
| 856 | if (index < NumCheats) |
| 857 | ret = EditCheat(index, "", buf); |
| 858 | else |
| 859 | ret = AddCheat("", buf); |
| 860 | |
| 861 | if (ret != 0) |
| 862 | SysPrintf("Failed to set cheat %#u\n", index); |
| 863 | else if (index < NumCheats) |
| 864 | Cheats[index].Enabled = enabled; |
| 865 | } |
| 866 | |
| 867 | /* multidisk support */ |
| 868 | static bool disk_ejected; |
| 869 | static unsigned int disk_current_index; |
| 870 | static unsigned int disk_count; |
| 871 | static struct disks_state { |
| 872 | char *fname; |
| 873 | int internal_index; // for multidisk eboots |
| 874 | } disks[8]; |
| 875 | |
| 876 | static bool disk_set_eject_state(bool ejected) |
| 877 | { |
| 878 | // weird PCSX API.. |
| 879 | SetCdOpenCaseTime(ejected ? -1 : (time(NULL) + 2)); |
| 880 | LidInterrupt(); |
| 881 | |
| 882 | disk_ejected = ejected; |
| 883 | return true; |
| 884 | } |
| 885 | |
| 886 | static bool disk_get_eject_state(void) |
| 887 | { |
| 888 | /* can't be controlled by emulated software */ |
| 889 | return disk_ejected; |
| 890 | } |
| 891 | |
| 892 | static unsigned int disk_get_image_index(void) |
| 893 | { |
| 894 | return disk_current_index; |
| 895 | } |
| 896 | |
| 897 | static bool disk_set_image_index(unsigned int index) |
| 898 | { |
| 899 | if (index >= sizeof(disks) / sizeof(disks[0])) |
| 900 | return false; |
| 901 | |
| 902 | CdromId[0] = '\0'; |
| 903 | CdromLabel[0] = '\0'; |
| 904 | |
| 905 | if (disks[index].fname == NULL) { |
| 906 | SysPrintf("missing disk #%u\n", index); |
| 907 | CDR_shutdown(); |
| 908 | |
| 909 | // RetroArch specifies "no disk" with index == count, |
| 910 | // so don't fail here.. |
| 911 | disk_current_index = index; |
| 912 | return true; |
| 913 | } |
| 914 | |
| 915 | SysPrintf("switching to disk %u: \"%s\" #%d\n", index, |
| 916 | disks[index].fname, disks[index].internal_index); |
| 917 | |
| 918 | cdrIsoMultidiskSelect = disks[index].internal_index; |
| 919 | set_cd_image(disks[index].fname); |
| 920 | if (ReloadCdromPlugin() < 0) { |
| 921 | SysPrintf("failed to load cdr plugin\n"); |
| 922 | return false; |
| 923 | } |
| 924 | if (CDR_open() < 0) { |
| 925 | SysPrintf("failed to open cdr plugin\n"); |
| 926 | return false; |
| 927 | } |
| 928 | |
| 929 | if (!disk_ejected) { |
| 930 | SetCdOpenCaseTime(time(NULL) + 2); |
| 931 | LidInterrupt(); |
| 932 | } |
| 933 | |
| 934 | disk_current_index = index; |
| 935 | return true; |
| 936 | } |
| 937 | |
| 938 | static unsigned int disk_get_num_images(void) |
| 939 | { |
| 940 | return disk_count; |
| 941 | } |
| 942 | |
| 943 | static bool disk_replace_image_index(unsigned index, |
| 944 | const struct retro_game_info *info) |
| 945 | { |
| 946 | char *old_fname; |
| 947 | bool ret = true; |
| 948 | |
| 949 | if (index >= sizeof(disks) / sizeof(disks[0])) |
| 950 | return false; |
| 951 | |
| 952 | old_fname = disks[index].fname; |
| 953 | disks[index].fname = NULL; |
| 954 | disks[index].internal_index = 0; |
| 955 | |
| 956 | if (info != NULL) { |
| 957 | disks[index].fname = strdup(info->path); |
| 958 | if (index == disk_current_index) |
| 959 | ret = disk_set_image_index(index); |
| 960 | } |
| 961 | |
| 962 | if (old_fname != NULL) |
| 963 | free(old_fname); |
| 964 | |
| 965 | return ret; |
| 966 | } |
| 967 | |
| 968 | static bool disk_add_image_index(void) |
| 969 | { |
| 970 | if (disk_count >= 8) |
| 971 | return false; |
| 972 | |
| 973 | disk_count++; |
| 974 | return true; |
| 975 | } |
| 976 | |
| 977 | static struct retro_disk_control_callback disk_control = { |
| 978 | .set_eject_state = disk_set_eject_state, |
| 979 | .get_eject_state = disk_get_eject_state, |
| 980 | .get_image_index = disk_get_image_index, |
| 981 | .set_image_index = disk_set_image_index, |
| 982 | .get_num_images = disk_get_num_images, |
| 983 | .replace_image_index = disk_replace_image_index, |
| 984 | .add_image_index = disk_add_image_index, |
| 985 | }; |
| 986 | |
| 987 | // just in case, maybe a win-rt port in the future? |
| 988 | #ifdef _WIN32 |
| 989 | #define SLASH '\\' |
| 990 | #else |
| 991 | #define SLASH '/' |
| 992 | #endif |
| 993 | |
| 994 | #ifndef PATH_MAX |
| 995 | #define PATH_MAX 4096 |
| 996 | #endif |
| 997 | |
| 998 | static char base_dir[PATH_MAX]; |
| 999 | |
| 1000 | static bool read_m3u(const char *file) |
| 1001 | { |
| 1002 | char line[PATH_MAX]; |
| 1003 | char name[PATH_MAX]; |
| 1004 | FILE *f = fopen(file, "r"); |
| 1005 | if (!f) |
| 1006 | return false; |
| 1007 | |
| 1008 | while (fgets(line, sizeof(line), f) && disk_count < sizeof(disks) / sizeof(disks[0])) { |
| 1009 | if (line[0] == '#') |
| 1010 | continue; |
| 1011 | char *carrige_return = strchr(line, '\r'); |
| 1012 | if (carrige_return) |
| 1013 | *carrige_return = '\0'; |
| 1014 | char *newline = strchr(line, '\n'); |
| 1015 | if (newline) |
| 1016 | *newline = '\0'; |
| 1017 | |
| 1018 | if (line[0] != '\0') |
| 1019 | { |
| 1020 | snprintf(name, sizeof(name), "%s%c%s", base_dir, SLASH, line); |
| 1021 | disks[disk_count++].fname = strdup(name); |
| 1022 | } |
| 1023 | } |
| 1024 | |
| 1025 | fclose(f); |
| 1026 | return (disk_count != 0); |
| 1027 | } |
| 1028 | |
| 1029 | static void extract_directory(char *buf, const char *path, size_t size) |
| 1030 | { |
| 1031 | char *base; |
| 1032 | strncpy(buf, path, size - 1); |
| 1033 | buf[size - 1] = '\0'; |
| 1034 | |
| 1035 | base = strrchr(buf, '/'); |
| 1036 | if (!base) |
| 1037 | base = strrchr(buf, '\\'); |
| 1038 | |
| 1039 | if (base) |
| 1040 | *base = '\0'; |
| 1041 | else |
| 1042 | { |
| 1043 | buf[0] = '.'; |
| 1044 | buf[1] = '\0'; |
| 1045 | } |
| 1046 | } |
| 1047 | |
| 1048 | #if defined(__QNX__) || defined(_WIN32) |
| 1049 | /* Blackberry QNX doesn't have strcasestr */ |
| 1050 | |
| 1051 | /* |
| 1052 | * Find the first occurrence of find in s, ignore case. |
| 1053 | */ |
| 1054 | char * |
| 1055 | strcasestr(const char *s, const char*find) |
| 1056 | { |
| 1057 | char c, sc; |
| 1058 | size_t len; |
| 1059 | |
| 1060 | if ((c = *find++) != 0) { |
| 1061 | c = tolower((unsigned char)c); |
| 1062 | len = strlen(find); |
| 1063 | do { |
| 1064 | do { |
| 1065 | if ((sc = *s++) == 0) |
| 1066 | return (NULL); |
| 1067 | } while ((char)tolower((unsigned char)sc) != c); |
| 1068 | } while (strncasecmp(s, find, len) != 0); |
| 1069 | s--; |
| 1070 | } |
| 1071 | return ((char *)s); |
| 1072 | } |
| 1073 | #endif |
| 1074 | |
| 1075 | bool retro_load_game(const struct retro_game_info *info) |
| 1076 | { |
| 1077 | size_t i; |
| 1078 | bool is_m3u = (strcasestr(info->path, ".m3u") != NULL); |
| 1079 | |
| 1080 | struct retro_input_descriptor desc[] = { |
| 1081 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, |
| 1082 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, |
| 1083 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, |
| 1084 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, |
| 1085 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Cross" }, |
| 1086 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Circle" }, |
| 1087 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Triangle" }, |
| 1088 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Square" }, |
| 1089 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L1" }, |
| 1090 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2, "L2" }, |
| 1091 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "L3" }, |
| 1092 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R1" }, |
| 1093 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" }, |
| 1094 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" }, |
| 1095 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" }, |
| 1096 | { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, |
| 1097 | { 0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" }, |
| 1098 | { 0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" }, |
| 1099 | { 0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" }, |
| 1100 | { 0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y, "Right Analog Y" }, |
| 1101 | |
| 1102 | |
| 1103 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, |
| 1104 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, |
| 1105 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, |
| 1106 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, |
| 1107 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Cross" }, |
| 1108 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Circle" }, |
| 1109 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Triangle" }, |
| 1110 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Square" }, |
| 1111 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L1" }, |
| 1112 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2, "L2" }, |
| 1113 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "L3" }, |
| 1114 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R1" }, |
| 1115 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" }, |
| 1116 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" }, |
| 1117 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" }, |
| 1118 | { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, |
| 1119 | { 1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" }, |
| 1120 | { 1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" }, |
| 1121 | { 1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" }, |
| 1122 | { 1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y, "Right Analog Y" }, |
| 1123 | |
| 1124 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, |
| 1125 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, |
| 1126 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, |
| 1127 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, |
| 1128 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Cross" }, |
| 1129 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Circle" }, |
| 1130 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Triangle" }, |
| 1131 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Square" }, |
| 1132 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L1" }, |
| 1133 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2, "L2" }, |
| 1134 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "L3" }, |
| 1135 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R1" }, |
| 1136 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" }, |
| 1137 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" }, |
| 1138 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" }, |
| 1139 | { 2, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, |
| 1140 | { 2, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" }, |
| 1141 | { 2, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" }, |
| 1142 | { 2, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" }, |
| 1143 | { 2, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y, "Right Analog Y" }, |
| 1144 | |
| 1145 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, |
| 1146 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, |
| 1147 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, |
| 1148 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, |
| 1149 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Cross" }, |
| 1150 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Circle" }, |
| 1151 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Triangle" }, |
| 1152 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Square" }, |
| 1153 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L1" }, |
| 1154 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2, "L2" }, |
| 1155 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "L3" }, |
| 1156 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R1" }, |
| 1157 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" }, |
| 1158 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" }, |
| 1159 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" }, |
| 1160 | { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, |
| 1161 | { 3, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" }, |
| 1162 | { 3, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" }, |
| 1163 | { 3, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" }, |
| 1164 | { 3, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y, "Right Analog Y" }, |
| 1165 | |
| 1166 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, |
| 1167 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, |
| 1168 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, |
| 1169 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, |
| 1170 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Cross" }, |
| 1171 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Circle" }, |
| 1172 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Triangle" }, |
| 1173 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Square" }, |
| 1174 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L1" }, |
| 1175 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2, "L2" }, |
| 1176 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "L3" }, |
| 1177 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R1" }, |
| 1178 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" }, |
| 1179 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" }, |
| 1180 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" }, |
| 1181 | { 4, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, |
| 1182 | { 4, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" }, |
| 1183 | { 4, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" }, |
| 1184 | { 4, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" }, |
| 1185 | { 4, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y, "Right Analog Y" }, |
| 1186 | |
| 1187 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, |
| 1188 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, |
| 1189 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, |
| 1190 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, |
| 1191 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Cross" }, |
| 1192 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Circle" }, |
| 1193 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Triangle" }, |
| 1194 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Square" }, |
| 1195 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L1" }, |
| 1196 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2, "L2" }, |
| 1197 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "L3" }, |
| 1198 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R1" }, |
| 1199 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" }, |
| 1200 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" }, |
| 1201 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" }, |
| 1202 | { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, |
| 1203 | { 5, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" }, |
| 1204 | { 5, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" }, |
| 1205 | { 5, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" }, |
| 1206 | { 5, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y, "Right Analog Y" }, |
| 1207 | |
| 1208 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, |
| 1209 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, |
| 1210 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, |
| 1211 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, |
| 1212 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Cross" }, |
| 1213 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Circle" }, |
| 1214 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Triangle" }, |
| 1215 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Square" }, |
| 1216 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L1" }, |
| 1217 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2, "L2" }, |
| 1218 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "L3" }, |
| 1219 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R1" }, |
| 1220 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" }, |
| 1221 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" }, |
| 1222 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" }, |
| 1223 | { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, |
| 1224 | { 6, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" }, |
| 1225 | { 6, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" }, |
| 1226 | { 6, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" }, |
| 1227 | { 6, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y, "Right Analog Y" }, |
| 1228 | |
| 1229 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, |
| 1230 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, |
| 1231 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, |
| 1232 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, |
| 1233 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Cross" }, |
| 1234 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Circle" }, |
| 1235 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Triangle" }, |
| 1236 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Square" }, |
| 1237 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L1" }, |
| 1238 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2, "L2" }, |
| 1239 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "L3" }, |
| 1240 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R1" }, |
| 1241 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" }, |
| 1242 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" }, |
| 1243 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" }, |
| 1244 | { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, |
| 1245 | { 7, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" }, |
| 1246 | { 7, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" }, |
| 1247 | { 7, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" }, |
| 1248 | { 7, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y, "Right Analog Y" }, |
| 1249 | |
| 1250 | { 0 }, |
| 1251 | }; |
| 1252 | |
| 1253 | frame_count = 0; |
| 1254 | |
| 1255 | environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc); |
| 1256 | |
| 1257 | #ifdef FRONTEND_SUPPORTS_RGB565 |
| 1258 | enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; |
| 1259 | if (environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) { |
| 1260 | SysPrintf("RGB565 supported, using it\n"); |
| 1261 | } |
| 1262 | #endif |
| 1263 | |
| 1264 | if (info == NULL || info->path == NULL) { |
| 1265 | SysPrintf("info->path required\n"); |
| 1266 | return false; |
| 1267 | } |
| 1268 | |
| 1269 | if (plugins_opened) { |
| 1270 | ClosePlugins(); |
| 1271 | plugins_opened = 0; |
| 1272 | } |
| 1273 | |
| 1274 | for (i = 0; i < sizeof(disks) / sizeof(disks[0]); i++) { |
| 1275 | if (disks[i].fname != NULL) { |
| 1276 | free(disks[i].fname); |
| 1277 | disks[i].fname = NULL; |
| 1278 | } |
| 1279 | disks[i].internal_index = 0; |
| 1280 | } |
| 1281 | |
| 1282 | disk_current_index = 0; |
| 1283 | extract_directory(base_dir, info->path, sizeof(base_dir)); |
| 1284 | |
| 1285 | if (is_m3u) { |
| 1286 | if (!read_m3u(info->path)) { |
| 1287 | log_cb(RETRO_LOG_INFO, "failed to read m3u file\n"); |
| 1288 | return false; |
| 1289 | } |
| 1290 | } else { |
| 1291 | disk_count = 1; |
| 1292 | disks[0].fname = strdup(info->path); |
| 1293 | } |
| 1294 | |
| 1295 | set_cd_image(disks[0].fname); |
| 1296 | |
| 1297 | /* have to reload after set_cd_image for correct cdr plugin */ |
| 1298 | if (LoadPlugins() == -1) { |
| 1299 | log_cb(RETRO_LOG_INFO, "failed to load plugins\n"); |
| 1300 | return false; |
| 1301 | } |
| 1302 | |
| 1303 | plugins_opened = 1; |
| 1304 | NetOpened = 0; |
| 1305 | |
| 1306 | if (OpenPlugins() == -1) { |
| 1307 | log_cb(RETRO_LOG_INFO, "failed to open plugins\n"); |
| 1308 | return false; |
| 1309 | } |
| 1310 | |
| 1311 | plugin_call_rearmed_cbs(); |
| 1312 | dfinput_activate(); |
| 1313 | |
| 1314 | if (CheckCdrom() == -1) { |
| 1315 | log_cb(RETRO_LOG_INFO, "unsupported/invalid CD image: %s\n", info->path); |
| 1316 | return false; |
| 1317 | } |
| 1318 | |
| 1319 | SysReset(); |
| 1320 | |
| 1321 | if (LoadCdrom() == -1) { |
| 1322 | log_cb(RETRO_LOG_INFO, "could not load CD\n"); |
| 1323 | return false; |
| 1324 | } |
| 1325 | emu_on_new_cd(0); |
| 1326 | |
| 1327 | // multidisk images |
| 1328 | if (!is_m3u) { |
| 1329 | disk_count = cdrIsoMultidiskCount < 8 ? cdrIsoMultidiskCount : 8; |
| 1330 | for (i = 1; i < sizeof(disks) / sizeof(disks[0]) && i < cdrIsoMultidiskCount; i++) { |
| 1331 | disks[i].fname = strdup(info->path); |
| 1332 | disks[i].internal_index = i; |
| 1333 | } |
| 1334 | } |
| 1335 | |
| 1336 | return true; |
| 1337 | } |
| 1338 | |
| 1339 | unsigned retro_get_region(void) |
| 1340 | { |
| 1341 | return is_pal_mode ? RETRO_REGION_PAL : RETRO_REGION_NTSC; |
| 1342 | } |
| 1343 | |
| 1344 | void *retro_get_memory_data(unsigned id) |
| 1345 | { |
| 1346 | if (id == RETRO_MEMORY_SAVE_RAM) |
| 1347 | return Mcd1Data; |
| 1348 | else |
| 1349 | return NULL; |
| 1350 | } |
| 1351 | |
| 1352 | size_t retro_get_memory_size(unsigned id) |
| 1353 | { |
| 1354 | if (id == RETRO_MEMORY_SAVE_RAM) |
| 1355 | return MCD_SIZE; |
| 1356 | else |
| 1357 | return 0; |
| 1358 | } |
| 1359 | |
| 1360 | void retro_reset(void) |
| 1361 | { |
| 1362 | //hack to prevent retroarch freezing when reseting in the menu but not while running with the hot key |
| 1363 | rebootemu = 1; |
| 1364 | //SysReset(); |
| 1365 | } |
| 1366 | |
| 1367 | static const unsigned short retro_psx_map[] = { |
| 1368 | [RETRO_DEVICE_ID_JOYPAD_B] = 1 << DKEY_CROSS, |
| 1369 | [RETRO_DEVICE_ID_JOYPAD_Y] = 1 << DKEY_SQUARE, |
| 1370 | [RETRO_DEVICE_ID_JOYPAD_SELECT] = 1 << DKEY_SELECT, |
| 1371 | [RETRO_DEVICE_ID_JOYPAD_START] = 1 << DKEY_START, |
| 1372 | [RETRO_DEVICE_ID_JOYPAD_UP] = 1 << DKEY_UP, |
| 1373 | [RETRO_DEVICE_ID_JOYPAD_DOWN] = 1 << DKEY_DOWN, |
| 1374 | [RETRO_DEVICE_ID_JOYPAD_LEFT] = 1 << DKEY_LEFT, |
| 1375 | [RETRO_DEVICE_ID_JOYPAD_RIGHT] = 1 << DKEY_RIGHT, |
| 1376 | [RETRO_DEVICE_ID_JOYPAD_A] = 1 << DKEY_CIRCLE, |
| 1377 | [RETRO_DEVICE_ID_JOYPAD_X] = 1 << DKEY_TRIANGLE, |
| 1378 | [RETRO_DEVICE_ID_JOYPAD_L] = 1 << DKEY_L1, |
| 1379 | [RETRO_DEVICE_ID_JOYPAD_R] = 1 << DKEY_R1, |
| 1380 | [RETRO_DEVICE_ID_JOYPAD_L2] = 1 << DKEY_L2, |
| 1381 | [RETRO_DEVICE_ID_JOYPAD_R2] = 1 << DKEY_R2, |
| 1382 | [RETRO_DEVICE_ID_JOYPAD_L3] = 1 << DKEY_L3, |
| 1383 | [RETRO_DEVICE_ID_JOYPAD_R3] = 1 << DKEY_R3, |
| 1384 | }; |
| 1385 | #define RETRO_PSX_MAP_LEN (sizeof(retro_psx_map) / sizeof(retro_psx_map[0])) |
| 1386 | |
| 1387 | static void update_variables(bool in_flight) |
| 1388 | { |
| 1389 | struct retro_variable var; |
| 1390 | int i; |
| 1391 | |
| 1392 | var.value = NULL; |
| 1393 | var.key = "pcsx_rearmed_frameskip"; |
| 1394 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1395 | pl_rearmed_cbs.frameskip = atoi(var.value); |
| 1396 | |
| 1397 | var.value = NULL; |
| 1398 | var.key = "pcsx_rearmed_region"; |
| 1399 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1400 | { |
| 1401 | Config.PsxAuto = 0; |
| 1402 | if (strcmp(var.value, "auto") == 0) |
| 1403 | Config.PsxAuto = 1; |
| 1404 | else if (strcmp(var.value, "NTSC") == 0) |
| 1405 | Config.PsxType = 0; |
| 1406 | else if (strcmp(var.value, "PAL") == 0) |
| 1407 | Config.PsxType = 1; |
| 1408 | } |
| 1409 | |
| 1410 | for (i = 0; i < PORTS_NUMBER; i++) |
| 1411 | update_controller_port_variable(i); |
| 1412 | |
| 1413 | update_multitap(); |
| 1414 | |
| 1415 | var.value = NULL; |
| 1416 | var.key = "pcsx_rearmed_negcon_deadzone"; |
| 1417 | negcon_deadzone = 0; |
| 1418 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1419 | { |
| 1420 | negcon_deadzone = (int)(atoi(var.value) * 0.01f * NEGCON_RANGE); |
| 1421 | } |
| 1422 | |
| 1423 | var.value = NULL; |
| 1424 | var.key = "pcsx_rearmed_negcon_response"; |
| 1425 | negcon_linearity = 1; |
| 1426 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1427 | { |
| 1428 | if (strcmp(var.value, "quadratic") == 0){ |
| 1429 | negcon_linearity = 2; |
| 1430 | } else if (strcmp(var.value, "cubic") == 0){ |
| 1431 | negcon_linearity = 3; |
| 1432 | } |
| 1433 | } |
| 1434 | |
| 1435 | var.value = NULL; |
| 1436 | var.key = "pcsx_rearmed_vibration"; |
| 1437 | |
| 1438 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1439 | { |
| 1440 | if (strcmp(var.value, "disabled") == 0) |
| 1441 | in_enable_vibration = 0; |
| 1442 | else if (strcmp(var.value, "enabled") == 0) |
| 1443 | in_enable_vibration = 1; |
| 1444 | } |
| 1445 | |
| 1446 | var.value = NULL; |
| 1447 | var.key = "pcsx_rearmed_dithering"; |
| 1448 | |
| 1449 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1450 | { |
| 1451 | if (strcmp(var.value, "disabled") == 0) { |
| 1452 | pl_rearmed_cbs.gpu_peops.iUseDither = 0; |
| 1453 | pl_rearmed_cbs.gpu_peopsgl.bDrawDither = 0; |
| 1454 | #ifdef __ARM_NEON__ |
| 1455 | pl_rearmed_cbs.gpu_neon.allow_dithering = 0; |
| 1456 | #endif |
| 1457 | } |
| 1458 | else if (strcmp(var.value, "enabled") == 0) { |
| 1459 | pl_rearmed_cbs.gpu_peops.iUseDither = 1; |
| 1460 | pl_rearmed_cbs.gpu_peopsgl.bDrawDither = 1; |
| 1461 | #ifdef __ARM_NEON__ |
| 1462 | pl_rearmed_cbs.gpu_neon.allow_dithering = 1; |
| 1463 | #endif |
| 1464 | } |
| 1465 | } |
| 1466 | |
| 1467 | #ifdef __ARM_NEON__ |
| 1468 | var.value = "NULL"; |
| 1469 | var.key = "pcsx_rearmed_neon_interlace_enable"; |
| 1470 | |
| 1471 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1472 | { |
| 1473 | if (strcmp(var.value, "disabled") == 0) |
| 1474 | pl_rearmed_cbs.gpu_neon.allow_interlace = 0; |
| 1475 | else if (strcmp(var.value, "enabled") == 0) |
| 1476 | pl_rearmed_cbs.gpu_neon.allow_interlace = 1; |
| 1477 | } |
| 1478 | |
| 1479 | var.value = NULL; |
| 1480 | var.key = "pcsx_rearmed_neon_enhancement_enable"; |
| 1481 | |
| 1482 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1483 | { |
| 1484 | if (strcmp(var.value, "disabled") == 0) |
| 1485 | pl_rearmed_cbs.gpu_neon.enhancement_enable = 0; |
| 1486 | else if (strcmp(var.value, "enabled") == 0) |
| 1487 | pl_rearmed_cbs.gpu_neon.enhancement_enable = 1; |
| 1488 | } |
| 1489 | |
| 1490 | var.value = NULL; |
| 1491 | var.key = "pcsx_rearmed_neon_enhancement_no_main"; |
| 1492 | |
| 1493 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1494 | { |
| 1495 | if (strcmp(var.value, "disabled") == 0) |
| 1496 | pl_rearmed_cbs.gpu_neon.enhancement_no_main = 0; |
| 1497 | else if (strcmp(var.value, "enabled") == 0) |
| 1498 | pl_rearmed_cbs.gpu_neon.enhancement_no_main = 1; |
| 1499 | } |
| 1500 | #endif |
| 1501 | |
| 1502 | var.value = "NULL"; |
| 1503 | var.key = "pcsx_rearmed_duping_enable"; |
| 1504 | |
| 1505 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1506 | { |
| 1507 | if (strcmp(var.value, "disabled") == 0) |
| 1508 | duping_enable = false; |
| 1509 | else if (strcmp(var.value, "enabled") == 0) |
| 1510 | duping_enable = true; |
| 1511 | } |
| 1512 | |
| 1513 | var.value = "NULL"; |
| 1514 | var.key = "pcsx_rearmed_display_internal_fps"; |
| 1515 | |
| 1516 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1517 | { |
| 1518 | if (strcmp(var.value, "disabled") == 0) |
| 1519 | display_internal_fps = false; |
| 1520 | else if (strcmp(var.value, "enabled") == 0) |
| 1521 | display_internal_fps = true; |
| 1522 | } |
| 1523 | |
| 1524 | #ifndef DRC_DISABLE |
| 1525 | var.value = NULL; |
| 1526 | var.key = "pcsx_rearmed_drc"; |
| 1527 | |
| 1528 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1529 | { |
| 1530 | R3000Acpu *prev_cpu = psxCpu; |
| 1531 | |
| 1532 | #ifdef _3DS |
| 1533 | if(!__ctr_svchax) |
| 1534 | Config.Cpu = CPU_INTERPRETER; |
| 1535 | else |
| 1536 | #endif |
| 1537 | if (strcmp(var.value, "disabled") == 0) |
| 1538 | Config.Cpu = CPU_INTERPRETER; |
| 1539 | else if (strcmp(var.value, "enabled") == 0) |
| 1540 | Config.Cpu = CPU_DYNAREC; |
| 1541 | |
| 1542 | psxCpu = (Config.Cpu == CPU_INTERPRETER) ? &psxInt : &psxRec; |
| 1543 | if (psxCpu != prev_cpu) { |
| 1544 | prev_cpu->Shutdown(); |
| 1545 | psxCpu->Init(); |
| 1546 | psxCpu->Reset(); // not really a reset.. |
| 1547 | } |
| 1548 | } |
| 1549 | #endif |
| 1550 | |
| 1551 | var.value = "NULL"; |
| 1552 | var.key = "pcsx_rearmed_spu_reverb"; |
| 1553 | |
| 1554 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1555 | { |
| 1556 | if (strcmp(var.value, "disabled") == 0) |
| 1557 | spu_config.iUseReverb = false; |
| 1558 | else if (strcmp(var.value, "enabled") == 0) |
| 1559 | spu_config.iUseReverb = true; |
| 1560 | } |
| 1561 | |
| 1562 | var.value = "NULL"; |
| 1563 | var.key = "pcsx_rearmed_spu_interpolation"; |
| 1564 | |
| 1565 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1566 | { |
| 1567 | if (strcmp(var.value, "simple") == 0) |
| 1568 | spu_config.iUseInterpolation = 1; |
| 1569 | else if (strcmp(var.value, "gaussian") == 0) |
| 1570 | spu_config.iUseInterpolation = 2; |
| 1571 | else if (strcmp(var.value, "cubic") == 0) |
| 1572 | spu_config.iUseInterpolation = 3; |
| 1573 | else if (strcmp(var.value, "off") == 0) |
| 1574 | spu_config.iUseInterpolation = 0; |
| 1575 | } |
| 1576 | |
| 1577 | var.value = "NULL"; |
| 1578 | var.key = "pcsx_rearmed_pe2_fix"; |
| 1579 | |
| 1580 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1581 | { |
| 1582 | if (strcmp(var.value, "disabled") == 0) |
| 1583 | Config.RCntFix = 0; |
| 1584 | else if (strcmp(var.value, "enabled") == 0) |
| 1585 | Config.RCntFix = 1; |
| 1586 | } |
| 1587 | |
| 1588 | var.value = "NULL"; |
| 1589 | var.key = "pcsx_rearmed_idiablofix"; |
| 1590 | |
| 1591 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1592 | { |
| 1593 | if (strcmp(var.value, "disabled") == 0) |
| 1594 | spu_config.idiablofix = 0; |
| 1595 | else if (strcmp(var.value, "enabled") == 0) |
| 1596 | spu_config.idiablofix = 1; |
| 1597 | } |
| 1598 | |
| 1599 | var.value = "NULL"; |
| 1600 | var.key = "pcsx_rearmed_inuyasha_fix"; |
| 1601 | |
| 1602 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1603 | { |
| 1604 | if (strcmp(var.value, "disabled") == 0) |
| 1605 | Config.VSyncWA = 0; |
| 1606 | else if (strcmp(var.value, "enabled") == 0) |
| 1607 | Config.VSyncWA = 1; |
| 1608 | } |
| 1609 | |
| 1610 | var.value = NULL; |
| 1611 | var.key = "pcsx_rearmed_noxadecoding"; |
| 1612 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1613 | { |
| 1614 | if (strcmp(var.value, "disabled") == 0) |
| 1615 | Config.Xa = 1; |
| 1616 | else |
| 1617 | Config.Xa = 0; |
| 1618 | } |
| 1619 | |
| 1620 | var.value = NULL; |
| 1621 | var.key = "pcsx_rearmed_nocdaudio"; |
| 1622 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1623 | { |
| 1624 | if (strcmp(var.value, "disabled") == 0) |
| 1625 | Config.Cdda = 1; |
| 1626 | else |
| 1627 | Config.Cdda = 0; |
| 1628 | } |
| 1629 | |
| 1630 | #ifndef DRC_DISABLE |
| 1631 | var.value = NULL; |
| 1632 | var.key = "pcsx_rearmed_nosmccheck"; |
| 1633 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1634 | { |
| 1635 | if (strcmp(var.value, "enabled") == 0) |
| 1636 | new_dynarec_hacks |= NDHACK_NO_SMC_CHECK; |
| 1637 | else |
| 1638 | new_dynarec_hacks &= ~NDHACK_NO_SMC_CHECK; |
| 1639 | } |
| 1640 | |
| 1641 | var.value = NULL; |
| 1642 | var.key = "pcsx_rearmed_gteregsunneeded"; |
| 1643 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1644 | { |
| 1645 | if (strcmp(var.value, "enabled") == 0) |
| 1646 | new_dynarec_hacks |= NDHACK_GTE_UNNEEDED; |
| 1647 | else |
| 1648 | new_dynarec_hacks &= ~NDHACK_GTE_UNNEEDED; |
| 1649 | } |
| 1650 | |
| 1651 | var.value = NULL; |
| 1652 | var.key = "pcsx_rearmed_nogteflags"; |
| 1653 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1654 | { |
| 1655 | if (strcmp(var.value, "enabled") == 0) |
| 1656 | new_dynarec_hacks |= NDHACK_GTE_NO_FLAGS; |
| 1657 | else |
| 1658 | new_dynarec_hacks &= ~NDHACK_GTE_NO_FLAGS; |
| 1659 | } |
| 1660 | #endif |
| 1661 | |
| 1662 | if (in_flight) { |
| 1663 | // inform core things about possible config changes |
| 1664 | plugin_call_rearmed_cbs(); |
| 1665 | |
| 1666 | if (GPU_open != NULL && GPU_close != NULL) { |
| 1667 | GPU_close(); |
| 1668 | GPU_open(&gpuDisp, "PCSX", NULL); |
| 1669 | } |
| 1670 | |
| 1671 | dfinput_activate(); |
| 1672 | } |
| 1673 | else |
| 1674 | { |
| 1675 | //not yet running |
| 1676 | |
| 1677 | //bootlogo display hack |
| 1678 | if (found_bios) { |
| 1679 | var.value = "NULL"; |
| 1680 | var.key = "pcsx_rearmed_show_bios_bootlogo"; |
| 1681 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1682 | { |
| 1683 | Config.SlowBoot = 0; |
| 1684 | rebootemu = 0; |
| 1685 | if (strcmp(var.value, "enabled") == 0) |
| 1686 | { |
| 1687 | Config.SlowBoot = 1; |
| 1688 | rebootemu = 1; |
| 1689 | } |
| 1690 | } |
| 1691 | } |
| 1692 | #ifndef DRC_DISABLE |
| 1693 | var.value = "NULL"; |
| 1694 | var.key = "pcsx_rearmed_psxclock"; |
| 1695 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) |
| 1696 | { |
| 1697 | int psxclock = atoi(var.value); |
| 1698 | cycle_multiplier = 10000 / psxclock; |
| 1699 | } |
| 1700 | #endif |
| 1701 | } |
| 1702 | } |
| 1703 | |
| 1704 | // Taken from beetle-psx-libretro |
| 1705 | static uint16_t get_analog_button(int16_t ret, retro_input_state_t input_state_cb, int player_index, int id) |
| 1706 | { |
| 1707 | // NOTE: Analog buttons were added Nov 2017. Not all front-ends support this |
| 1708 | // feature (or pre-date it) so we need to handle this in a graceful way. |
| 1709 | |
| 1710 | // First, try and get an analog value using the new libretro API constant |
| 1711 | uint16_t button = input_state_cb(player_index, |
| 1712 | RETRO_DEVICE_ANALOG, |
| 1713 | RETRO_DEVICE_INDEX_ANALOG_BUTTON, |
| 1714 | id); |
| 1715 | button = MIN(button / 128, 255); |
| 1716 | |
| 1717 | if (button == 0) |
| 1718 | { |
| 1719 | // If we got exactly zero, we're either not pressing the button, or the front-end |
| 1720 | // is not reporting analog values. We need to do a second check using the classic |
| 1721 | // digital API method, to at least get some response - better than nothing. |
| 1722 | |
| 1723 | // NOTE: If we're really just not holding the button, we're still going to get zero. |
| 1724 | |
| 1725 | button = (ret & (1 << id)) ? 255 : 0; |
| 1726 | } |
| 1727 | |
| 1728 | return button; |
| 1729 | } |
| 1730 | |
| 1731 | void retro_run(void) |
| 1732 | { |
| 1733 | int i; |
| 1734 | //SysReset must be run while core is running,Not in menu (Locks up Retroarch) |
| 1735 | if (rebootemu != 0) { |
| 1736 | rebootemu = 0; |
| 1737 | SysReset(); |
| 1738 | if (!Config.HLE && !Config.SlowBoot) { |
| 1739 | // skip BIOS logos |
| 1740 | psxRegs.pc = psxRegs.GPR.n.ra; |
| 1741 | } |
| 1742 | } |
| 1743 | |
| 1744 | if (display_internal_fps) { |
| 1745 | frame_count++; |
| 1746 | |
| 1747 | if (frame_count % INTERNAL_FPS_SAMPLE_PERIOD == 0) { |
| 1748 | unsigned internal_fps = pl_rearmed_cbs.flip_cnt * (is_pal_mode ? 50 : 60) / INTERNAL_FPS_SAMPLE_PERIOD; |
| 1749 | char str[64]; |
| 1750 | const char *strc = (const char*)str; |
| 1751 | struct retro_message msg = |
| 1752 | { |
| 1753 | strc, |
| 1754 | 180 |
| 1755 | }; |
| 1756 | |
| 1757 | str[0] = '\0'; |
| 1758 | |
| 1759 | snprintf(str, sizeof(str), "Internal FPS: %2d", internal_fps); |
| 1760 | |
| 1761 | pl_rearmed_cbs.flip_cnt = 0; |
| 1762 | |
| 1763 | environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, &msg); |
| 1764 | } |
| 1765 | } |
| 1766 | else |
| 1767 | frame_count = 0; |
| 1768 | |
| 1769 | input_poll_cb(); |
| 1770 | |
| 1771 | bool updated = false; |
| 1772 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) |
| 1773 | update_variables(true); |
| 1774 | |
| 1775 | // reset all keystate, query libretro for keystate |
| 1776 | int j; |
| 1777 | int lsx; |
| 1778 | int rsy; |
| 1779 | float negcon_twist_amplitude; |
| 1780 | int negcon_i_rs; |
| 1781 | int negcon_ii_rs; |
| 1782 | for(i = 0; i < PORTS_NUMBER; i++) |
| 1783 | { |
| 1784 | int16_t ret = 0; |
| 1785 | in_keystate[i] = 0; |
| 1786 | |
| 1787 | if (in_type[i] == PSE_PAD_TYPE_NONE) |
| 1788 | continue; |
| 1789 | |
| 1790 | if (libretro_supports_bitmasks) |
| 1791 | ret = input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_MASK); |
| 1792 | else |
| 1793 | { |
| 1794 | unsigned i; |
| 1795 | for (i = 0; i < RETRO_DEVICE_ID_JOYPAD_R3+1; i++) |
| 1796 | { |
| 1797 | if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, i)) |
| 1798 | ret |= (1 << i); |
| 1799 | } |
| 1800 | } |
| 1801 | |
| 1802 | if (in_type[i] == PSE_PAD_TYPE_NEGCON) |
| 1803 | { |
| 1804 | // Query digital inputs |
| 1805 | // |
| 1806 | // > Pad-Up |
| 1807 | if (ret & (1 < RETRO_DEVICE_ID_JOYPAD_UP)) |
| 1808 | in_keystate[i] |= (1 << DKEY_UP); |
| 1809 | // > Pad-Right |
| 1810 | if (ret & (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT)) |
| 1811 | in_keystate[i] |= (1 << DKEY_RIGHT); |
| 1812 | // > Pad-Down |
| 1813 | if (ret & (1 << RETRO_DEVICE_ID_JOYPAD_DOWN)) |
| 1814 | in_keystate[i] |= (1 << DKEY_DOWN); |
| 1815 | // > Pad-Left |
| 1816 | if (ret & (1 << RETRO_DEVICE_ID_JOYPAD_LEFT)) |
| 1817 | in_keystate[i] |= (1 << DKEY_LEFT); |
| 1818 | // > Start |
| 1819 | if (ret & (1 << RETRO_DEVICE_ID_JOYPAD_START)) |
| 1820 | in_keystate[i] |= (1 << DKEY_START); |
| 1821 | // > neGcon A |
| 1822 | if (ret & (1 << RETRO_DEVICE_ID_JOYPAD_A)) |
| 1823 | in_keystate[i] |= (1 << DKEY_CIRCLE); |
| 1824 | // > neGcon B |
| 1825 | if (ret & (1 << RETRO_DEVICE_ID_JOYPAD_X)) |
| 1826 | in_keystate[i] |= (1 << DKEY_TRIANGLE); |
| 1827 | // > neGcon R shoulder (digital) |
| 1828 | if (ret & (1 << RETRO_DEVICE_ID_JOYPAD_R)) |
| 1829 | in_keystate[i] |= (1 << DKEY_R1); |
| 1830 | // Query analog inputs |
| 1831 | // |
| 1832 | // From studying 'libpcsxcore/plugins.c' and 'frontend/plugin.c': |
| 1833 | // >> pad->leftJoyX == in_analog_left[i][0] == NeGcon II |
| 1834 | // >> pad->leftJoyY == in_analog_left[i][1] == NeGcon L |
| 1835 | // >> pad->rightJoyX == in_analog_right[i][0] == NeGcon twist |
| 1836 | // >> pad->rightJoyY == in_analog_right[i][1] == NeGcon I |
| 1837 | // So we just have to map in_analog_left/right to more |
| 1838 | // appropriate inputs... |
| 1839 | // |
| 1840 | // > NeGcon twist |
| 1841 | // >> Get raw analog stick value and account for deadzone |
| 1842 | lsx = input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X); |
| 1843 | if (lsx > negcon_deadzone) |
| 1844 | lsx = lsx - negcon_deadzone; |
| 1845 | else if (lsx < -negcon_deadzone) |
| 1846 | lsx = lsx + negcon_deadzone; |
| 1847 | else |
| 1848 | lsx = 0; |
| 1849 | // >> Convert to an 'amplitude' [-1.0,1.0] and adjust response |
| 1850 | negcon_twist_amplitude = (float)lsx / (float)(NEGCON_RANGE - negcon_deadzone); |
| 1851 | if (negcon_linearity == 2) |
| 1852 | { |
| 1853 | if (negcon_twist_amplitude < 0.0) |
| 1854 | negcon_twist_amplitude = -(negcon_twist_amplitude * negcon_twist_amplitude); |
| 1855 | else |
| 1856 | negcon_twist_amplitude = negcon_twist_amplitude * negcon_twist_amplitude; |
| 1857 | } |
| 1858 | else if (negcon_linearity == 3) |
| 1859 | negcon_twist_amplitude = negcon_twist_amplitude * negcon_twist_amplitude * negcon_twist_amplitude; |
| 1860 | // >> Convert to final 'in_analog' integer value [0,255] |
| 1861 | in_analog_right[i][0] = MAX(MIN((int)(negcon_twist_amplitude * 128.0f) + 128, 255), 0); |
| 1862 | // > NeGcon I + II |
| 1863 | // >> Handle right analog stick vertical axis mapping... |
| 1864 | // - Up (-Y) == accelerate == neGcon I |
| 1865 | // - Down (+Y) == brake == neGcon II |
| 1866 | negcon_i_rs = 0; |
| 1867 | negcon_ii_rs = 0; |
| 1868 | rsy = input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y); |
| 1869 | if (rsy >= 0){ |
| 1870 | // Account for deadzone |
| 1871 | // (Note: have never encountered a gamepad with significant differences |
| 1872 | // in deadzone between left/right analog sticks, so use the regular 'twist' |
| 1873 | // deadzone here) |
| 1874 | if (rsy > negcon_deadzone) |
| 1875 | rsy = rsy - negcon_deadzone; |
| 1876 | else |
| 1877 | rsy = 0; |
| 1878 | // Convert to 'in_analog' integer value [0,255] |
| 1879 | negcon_ii_rs = MIN((int)(((float)rsy / (float)(NEGCON_RANGE - negcon_deadzone)) * 255.0f), 255); |
| 1880 | } else { |
| 1881 | if (rsy < -negcon_deadzone) |
| 1882 | rsy = -1 * (rsy + negcon_deadzone); |
| 1883 | else |
| 1884 | rsy = 0; |
| 1885 | negcon_i_rs = MIN((int)(((float)rsy / (float)(NEGCON_RANGE - negcon_deadzone)) * 255.0f), 255); |
| 1886 | } |
| 1887 | // >> NeGcon I |
| 1888 | in_analog_right[i][1] = MAX( |
| 1889 | MAX( |
| 1890 | get_analog_button(ret, input_state_cb, i, RETRO_DEVICE_ID_JOYPAD_R2), |
| 1891 | get_analog_button(ret, input_state_cb, i, RETRO_DEVICE_ID_JOYPAD_B) |
| 1892 | ), |
| 1893 | negcon_i_rs |
| 1894 | ); |
| 1895 | // >> NeGcon II |
| 1896 | in_analog_left[i][0] = MAX( |
| 1897 | MAX( |
| 1898 | get_analog_button(ret, input_state_cb, i, RETRO_DEVICE_ID_JOYPAD_L2), |
| 1899 | get_analog_button(ret, input_state_cb, i, RETRO_DEVICE_ID_JOYPAD_Y) |
| 1900 | ), |
| 1901 | negcon_ii_rs |
| 1902 | ); |
| 1903 | // > NeGcon L |
| 1904 | in_analog_left[i][1] = get_analog_button(ret, input_state_cb, i, RETRO_DEVICE_ID_JOYPAD_L); |
| 1905 | } |
| 1906 | else |
| 1907 | { |
| 1908 | // Query digital inputs |
| 1909 | for (j = 0; j < RETRO_PSX_MAP_LEN; j++) |
| 1910 | if (ret & (1 << j)) |
| 1911 | in_keystate[i] |= retro_psx_map[j]; |
| 1912 | |
| 1913 | // Query analog inputs |
| 1914 | if (in_type[i] == PSE_PAD_TYPE_ANALOGJOY || in_type[i] == PSE_PAD_TYPE_ANALOGPAD) |
| 1915 | { |
| 1916 | in_analog_left[i][0] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255); |
| 1917 | in_analog_left[i][1] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255); |
| 1918 | in_analog_right[i][0] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255); |
| 1919 | in_analog_right[i][1] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255); |
| 1920 | } |
| 1921 | } |
| 1922 | } |
| 1923 | |
| 1924 | stop = 0; |
| 1925 | psxCpu->Execute(); |
| 1926 | |
| 1927 | video_cb((vout_fb_dirty || !vout_can_dupe || !duping_enable) ? vout_buf_ptr : NULL, |
| 1928 | vout_width, vout_height, vout_width * 2); |
| 1929 | vout_fb_dirty = 0; |
| 1930 | |
| 1931 | set_vout_fb(); |
| 1932 | } |
| 1933 | |
| 1934 | static bool try_use_bios(const char *path) |
| 1935 | { |
| 1936 | FILE *f; |
| 1937 | long size; |
| 1938 | const char *name; |
| 1939 | |
| 1940 | f = fopen(path, "rb"); |
| 1941 | if (f == NULL) |
| 1942 | return false; |
| 1943 | |
| 1944 | fseek(f, 0, SEEK_END); |
| 1945 | size = ftell(f); |
| 1946 | fclose(f); |
| 1947 | |
| 1948 | if (size != 512 * 1024) |
| 1949 | return false; |
| 1950 | |
| 1951 | name = strrchr(path, SLASH); |
| 1952 | if (name++ == NULL) |
| 1953 | name = path; |
| 1954 | snprintf(Config.Bios, sizeof(Config.Bios), "%s", name); |
| 1955 | return true; |
| 1956 | } |
| 1957 | |
| 1958 | #ifndef VITA |
| 1959 | #include <sys/types.h> |
| 1960 | #include <dirent.h> |
| 1961 | |
| 1962 | static bool find_any_bios(const char *dirpath, char *path, size_t path_size) |
| 1963 | { |
| 1964 | DIR *dir; |
| 1965 | struct dirent *ent; |
| 1966 | bool ret = false; |
| 1967 | |
| 1968 | dir = opendir(dirpath); |
| 1969 | if (dir == NULL) |
| 1970 | return false; |
| 1971 | |
| 1972 | while ((ent = readdir(dir))) { |
| 1973 | if (strncasecmp(ent->d_name, "scph", 4) != 0) |
| 1974 | continue; |
| 1975 | |
| 1976 | snprintf(path, path_size, "%s%c%s", dirpath, SLASH, ent->d_name); |
| 1977 | ret = try_use_bios(path); |
| 1978 | if (ret) |
| 1979 | break; |
| 1980 | } |
| 1981 | closedir(dir); |
| 1982 | return ret; |
| 1983 | } |
| 1984 | #else |
| 1985 | #define find_any_bios(...) false |
| 1986 | #endif |
| 1987 | |
| 1988 | static void check_system_specs(void) |
| 1989 | { |
| 1990 | unsigned level = 6; |
| 1991 | environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level); |
| 1992 | } |
| 1993 | |
| 1994 | static int init_memcards(void) |
| 1995 | { |
| 1996 | int ret = 0; |
| 1997 | const char *dir; |
| 1998 | struct retro_variable var = { .key="pcsx_rearmed_memcard2", .value=NULL }; |
| 1999 | static const char CARD2_FILE[] = "pcsx-card2.mcd"; |
| 2000 | |
| 2001 | // Memcard2 will be handled and is re-enabled if needed using core |
| 2002 | // operations. |
| 2003 | // Memcard1 is handled by libretro, doing this will set core to |
| 2004 | // skip file io operations for memcard1 like SaveMcd |
| 2005 | snprintf(Config.Mcd1, sizeof(Config.Mcd1), "none"); |
| 2006 | snprintf(Config.Mcd2, sizeof(Config.Mcd2), "none"); |
| 2007 | init_memcard(Mcd1Data); |
| 2008 | // Memcard 2 is managed by the emulator on the filesystem, |
| 2009 | // There is no need to initialize Mcd2Data like Mcd1Data. |
| 2010 | |
| 2011 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { |
| 2012 | SysPrintf("Memcard 2: %s\n", var.value); |
| 2013 | if (memcmp(var.value, "enabled", 7) == 0) { |
| 2014 | if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &dir) && dir) { |
| 2015 | if (strlen(dir) + strlen(CARD2_FILE) + 2 > sizeof(Config.Mcd2)) { |
| 2016 | SysPrintf("Path '%s' is too long. Cannot use memcard 2. Use a shorter path.\n", dir); |
| 2017 | ret = -1; |
| 2018 | } else { |
| 2019 | McdDisable[1] = 0; |
| 2020 | snprintf(Config.Mcd2, sizeof(Config.Mcd2), "%s/%s", dir, CARD2_FILE); |
| 2021 | SysPrintf("Use memcard 2: %s\n", Config.Mcd2); |
| 2022 | } |
| 2023 | } else { |
| 2024 | SysPrintf("Could not get save directory! Could not create memcard 2."); |
| 2025 | ret = -1; |
| 2026 | } |
| 2027 | } |
| 2028 | } |
| 2029 | return ret; |
| 2030 | } |
| 2031 | |
| 2032 | static void loadPSXBios(void) |
| 2033 | { |
| 2034 | const char *dir; |
| 2035 | char path[256]; |
| 2036 | unsigned useHLE = 0; |
| 2037 | |
| 2038 | const char *bios[] = { |
| 2039 | "SCPH101", "scph101", |
| 2040 | "SCPH5501", "scph5501", |
| 2041 | "SCPH7001", "scph7001", |
| 2042 | "SCPH1001", "scph1001" |
| 2043 | }; |
| 2044 | |
| 2045 | struct retro_variable var = { |
| 2046 | .key = "pcsx_rearmed_bios", |
| 2047 | .value = NULL |
| 2048 | }; |
| 2049 | |
| 2050 | found_bios = 0; |
| 2051 | |
| 2052 | if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { |
| 2053 | if (!strcmp(var.value, "HLE")) |
| 2054 | useHLE = 1; |
| 2055 | } |
| 2056 | |
| 2057 | if (!useHLE) |
| 2058 | { |
| 2059 | if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir) |
| 2060 | { |
| 2061 | unsigned i; |
| 2062 | snprintf(Config.BiosDir, sizeof(Config.BiosDir), "%s", dir); |
| 2063 | |
| 2064 | for (i = 0; i < sizeof(bios) / sizeof(bios[0]); i++) { |
| 2065 | snprintf(path, sizeof(path), "%s%c%s.bin", dir, SLASH, bios[i]); |
| 2066 | found_bios = try_use_bios(path); |
| 2067 | if (found_bios) |
| 2068 | break; |
| 2069 | } |
| 2070 | |
| 2071 | if (!found_bios) |
| 2072 | found_bios = find_any_bios(dir, path, sizeof(path)); |
| 2073 | } |
| 2074 | if (found_bios) { |
| 2075 | SysPrintf("found BIOS file: %s\n", Config.Bios); |
| 2076 | } |
| 2077 | } |
| 2078 | |
| 2079 | if (useHLE || !found_bios) |
| 2080 | { |
| 2081 | SysPrintf("no BIOS files found.\n"); |
| 2082 | struct retro_message msg = |
| 2083 | { |
| 2084 | "No PlayStation BIOS file found - add for better compatibility", |
| 2085 | 180 |
| 2086 | }; |
| 2087 | environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, (void*)&msg); |
| 2088 | } |
| 2089 | } |
| 2090 | |
| 2091 | void retro_init(void) |
| 2092 | { |
| 2093 | struct retro_rumble_interface rumble; |
| 2094 | int ret; |
| 2095 | |
| 2096 | #ifdef __MACH__ |
| 2097 | // magic sauce to make the dynarec work on iOS |
| 2098 | syscall(SYS_ptrace, 0 /*PTRACE_TRACEME*/, 0, 0, 0); |
| 2099 | #endif |
| 2100 | |
| 2101 | #ifdef _3DS |
| 2102 | psxMapHook = pl_3ds_mmap; |
| 2103 | psxUnmapHook = pl_3ds_munmap; |
| 2104 | #endif |
| 2105 | #ifdef VITA |
| 2106 | if(init_vita_mmap()<0) |
| 2107 | abort(); |
| 2108 | psxMapHook = pl_vita_mmap; |
| 2109 | psxUnmapHook = pl_vita_munmap; |
| 2110 | #endif |
| 2111 | ret = emu_core_preinit(); |
| 2112 | #ifdef _3DS |
| 2113 | /* emu_core_preinit sets the cpu to dynarec */ |
| 2114 | if(!__ctr_svchax) |
| 2115 | Config.Cpu = CPU_INTERPRETER; |
| 2116 | #endif |
| 2117 | ret |= init_memcards(); |
| 2118 | |
| 2119 | ret |= emu_core_init(); |
| 2120 | if (ret != 0) { |
| 2121 | SysPrintf("PCSX init failed.\n"); |
| 2122 | exit(1); |
| 2123 | } |
| 2124 | |
| 2125 | #ifdef _3DS |
| 2126 | vout_buf = linearMemAlign(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2, 0x80); |
| 2127 | #elif defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) && !defined(VITA) |
| 2128 | posix_memalign(&vout_buf, 16, VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2); |
| 2129 | #else |
| 2130 | vout_buf = malloc(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2); |
| 2131 | #endif |
| 2132 | |
| 2133 | vout_buf_ptr = vout_buf; |
| 2134 | |
| 2135 | loadPSXBios(); |
| 2136 | |
| 2137 | environ_cb(RETRO_ENVIRONMENT_GET_CAN_DUPE, &vout_can_dupe); |
| 2138 | environ_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE, &disk_control); |
| 2139 | |
| 2140 | rumble_cb = NULL; |
| 2141 | if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble)) |
| 2142 | rumble_cb = rumble.set_rumble_state; |
| 2143 | |
| 2144 | /* Set how much slower PSX CPU runs * 100 (so that 200 is 2 times) |
| 2145 | * we have to do this because cache misses and some IO penalties |
| 2146 | * are not emulated. Warning: changing this may break compatibility. */ |
| 2147 | cycle_multiplier = 175; |
| 2148 | #ifdef HAVE_PRE_ARMV7 |
| 2149 | cycle_multiplier = 200; |
| 2150 | #endif |
| 2151 | pl_rearmed_cbs.gpu_peops.iUseDither = 1; |
| 2152 | spu_config.iUseFixedUpdates = 1; |
| 2153 | |
| 2154 | SaveFuncs.open = save_open; |
| 2155 | SaveFuncs.read = save_read; |
| 2156 | SaveFuncs.write = save_write; |
| 2157 | SaveFuncs.seek = save_seek; |
| 2158 | SaveFuncs.close = save_close; |
| 2159 | |
| 2160 | if (environ_cb(RETRO_ENVIRONMENT_GET_INPUT_BITMASKS, NULL)) |
| 2161 | libretro_supports_bitmasks = true; |
| 2162 | |
| 2163 | update_variables(false); |
| 2164 | check_system_specs(); |
| 2165 | } |
| 2166 | |
| 2167 | void retro_deinit(void) |
| 2168 | { |
| 2169 | SysClose(); |
| 2170 | #ifdef _3DS |
| 2171 | linearFree(vout_buf); |
| 2172 | #else |
| 2173 | free(vout_buf); |
| 2174 | #endif |
| 2175 | vout_buf = NULL; |
| 2176 | |
| 2177 | #ifdef VITA |
| 2178 | deinit_vita_mmap(); |
| 2179 | #endif |
| 2180 | libretro_supports_bitmasks = false; |
| 2181 | } |
| 2182 | |
| 2183 | #ifdef VITA |
| 2184 | #include <psp2/kernel/threadmgr.h> |
| 2185 | int usleep (unsigned long us) |
| 2186 | { |
| 2187 | sceKernelDelayThread(us); |
| 2188 | } |
| 2189 | #endif |