4 * This work is licensed under the terms of the GNU GPLv2 or later.
5 * See the COPYING file in the top-level directory.
8 #define _GNU_SOURCE 1 // strcasestr
14 #include "../libpcsxcore/misc.h"
15 #include "../libpcsxcore/psxcounters.h"
16 #include "../libpcsxcore/psxmem_map.h"
17 #include "../libpcsxcore/new_dynarec/new_dynarec.h"
18 #include "../libpcsxcore/cdrom.h"
19 #include "../libpcsxcore/cdriso.h"
20 #include "../libpcsxcore/cheat.h"
21 #include "../plugins/dfsound/out.h"
22 #include "../plugins/dfinput/externals.h"
26 #include "plugin_lib.h"
30 static retro_video_refresh_t video_cb;
31 static retro_input_poll_t input_poll_cb;
32 static retro_input_state_t input_state_cb;
33 static retro_environment_t environ_cb;
34 static retro_audio_sample_batch_t audio_batch_cb;
36 static void *vout_buf;
37 static int vout_width, vout_height;
38 static int vout_doffs_old, vout_fb_dirty;
39 static bool vout_can_dupe;
40 static bool duping_enable;
42 static int samples_sent, samples_to_send;
43 static int plugins_opened;
44 static int is_pal_mode;
46 /* memory card data */
47 extern char Mcd1Data[MCD_SIZE];
48 extern char McdDisable[2];
50 /* PCSX ReARMed core calls and stuff */
51 int in_type1, in_type2;
52 int in_a1[2] = { 127, 127 }, in_a2[2] = { 127, 127 };
54 int in_enable_vibration;
56 /* PSX max resolution is 640x512, but with enhancement it's 1024x512 */
57 #define VOUT_MAX_WIDTH 1024
58 #define VOUT_MAX_HEIGHT 512
60 static void init_memcard(char *mcd_data)
65 memset(mcd_data, 0, MCD_SIZE);
67 mcd_data[off++] = 'M';
68 mcd_data[off++] = 'C';
70 mcd_data[off++] = 0x0e;
72 for (i = 0; i < 15; i++) {
73 mcd_data[off++] = 0xa0;
75 mcd_data[off++] = 0xff;
76 mcd_data[off++] = 0xff;
78 mcd_data[off++] = 0xa0;
81 for (i = 0; i < 20; i++) {
82 mcd_data[off++] = 0xff;
83 mcd_data[off++] = 0xff;
84 mcd_data[off++] = 0xff;
85 mcd_data[off++] = 0xff;
87 mcd_data[off++] = 0xff;
88 mcd_data[off++] = 0xff;
93 static int vout_open(void)
98 static void vout_set_mode(int w, int h, int raw_w, int raw_h, int bpp)
104 #ifndef FRONTEND_SUPPORTS_RGB565
105 static void convert(void *buf, size_t bytes)
107 unsigned int i, v, *p = buf;
109 for (i = 0; i < bytes / 4; i++) {
111 p[i] = (v & 0x001f001f) | ((v >> 1) & 0x7fe07fe0);
116 static void vout_flip(const void *vram, int stride, int bgr24, int w, int h)
118 unsigned short *dest = vout_buf;
119 const unsigned short *src = vram;
120 int dstride = vout_width, h1 = h;
125 memset(vout_buf, 0, dstride * h * 2);
129 doffs = (vout_height - h) * dstride;
130 doffs += (dstride - w) / 2 & ~1;
131 if (doffs != vout_doffs_old) {
133 memset(vout_buf, 0, dstride * h * 2);
134 vout_doffs_old = doffs;
140 // XXX: could we switch to RETRO_PIXEL_FORMAT_XRGB8888 here?
141 for (; h1-- > 0; dest += dstride, src += stride)
143 bgr888_to_rgb565(dest, src, w * 3);
148 for (; h1-- > 0; dest += dstride, src += stride)
150 bgr555_to_rgb565(dest, src, w * 2);
155 #ifndef FRONTEND_SUPPORTS_RGB565
156 convert(vout_buf, vout_width * vout_height * 2);
159 pl_rearmed_cbs.flip_cnt++;
162 static void vout_close(void)
166 static void *pl_mmap(unsigned int size)
168 return psxMap(0, size, 0, MAP_TAG_VRAM);
171 static void pl_munmap(void *ptr, unsigned int size)
173 psxUnmap(ptr, size, MAP_TAG_VRAM);
176 struct rearmed_cbs pl_rearmed_cbs = {
177 .pl_vout_open = vout_open,
178 .pl_vout_set_mode = vout_set_mode,
179 .pl_vout_flip = vout_flip,
180 .pl_vout_close = vout_close,
183 /* from psxcounters */
184 .gpu_hcnt = &hSyncCount,
185 .gpu_frame_count = &frame_counter,
188 void pl_frame_limit(void)
190 /* called once per frame, make psxCpu->Execute() above return */
194 void pl_timing_prepare(int is_pal)
196 is_pal_mode = is_pal;
199 void plat_trigger_vibrate(int is_strong)
203 void pl_update_gun(int *xn, int *yn, int *xres, int *yres, int *in)
208 static int snd_init(void)
213 static void snd_finish(void)
217 static int snd_busy(void)
219 if (samples_to_send > samples_sent)
220 return 0; /* give more samples */
225 static void snd_feed(void *buf, int bytes)
227 audio_batch_cb(buf, bytes / 4);
228 samples_sent += bytes / 4;
231 void out_register_libretro(struct out_driver *drv)
233 drv->name = "libretro";
234 drv->init = snd_init;
235 drv->finish = snd_finish;
236 drv->busy = snd_busy;
237 drv->feed = snd_feed;
241 void retro_set_environment(retro_environment_t cb)
243 static const struct retro_variable vars[] = {
244 { "frameskip", "Frameskip; 0|1|2|3" },
245 { "region", "Region; Auto|NTSC|PAL" },
246 { "pad1type", "Pad 1 Type; standard|analog" },
248 { "rearmed_drc", "Dynamic recompiler; enabled|disabled" },
250 #if defined(__ARM_NEON__) || defined(NEON_PC)
251 { "neon_interlace_enable", "Enable interlacing mode(s); disabled|enabled" },
252 { "neon_enhancement_enable", "Enhanced resolution (slow); disabled|enabled" },
253 { "neon_enhancement_no_main", "Enhanced resolution speed hack; disabled|enabled" },
255 { "pcsx_rearmed_duping_enable", "Frame duping; on|off" },
261 cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars);
264 void retro_set_video_refresh(retro_video_refresh_t cb) { video_cb = cb; }
265 void retro_set_audio_sample(retro_audio_sample_t cb) { (void)cb; }
266 void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb) { audio_batch_cb = cb; }
267 void retro_set_input_poll(retro_input_poll_t cb) { input_poll_cb = cb; }
268 void retro_set_input_state(retro_input_state_t cb) { input_state_cb = cb; }
270 unsigned retro_api_version(void)
272 return RETRO_API_VERSION;
275 void retro_set_controller_port_device(unsigned port, unsigned device)
279 void retro_get_system_info(struct retro_system_info *info)
281 memset(info, 0, sizeof(*info));
282 info->library_name = "PCSX-ReARMed";
283 info->library_version = "r19";
284 info->valid_extensions = "bin|cue|img|mdf|pbp|toc|cbn|m3u";
285 info->need_fullpath = true;
288 void retro_get_system_av_info(struct retro_system_av_info *info)
290 memset(info, 0, sizeof(*info));
291 info->timing.fps = is_pal_mode ? 50 : 60;
292 info->timing.sample_rate = 44100;
293 info->geometry.base_width = 320;
294 info->geometry.base_height = 240;
295 info->geometry.max_width = VOUT_MAX_WIDTH;
296 info->geometry.max_height = VOUT_MAX_HEIGHT;
297 info->geometry.aspect_ratio = 4.0 / 3.0;
301 size_t retro_serialize_size(void)
303 // it's currently 4380651 bytes, but have some reserved for future
313 static void *save_open(const char *name, const char *mode)
317 if (name == NULL || mode == NULL)
320 fp = malloc(sizeof(*fp));
324 fp->buf = (char *)name;
326 fp->is_write = (mode[0] == 'w' || mode[1] == 'w');
331 static int save_read(void *file, void *buf, u32 len)
333 struct save_fp *fp = file;
334 if (fp == NULL || buf == NULL)
337 memcpy(buf, fp->buf + fp->pos, len);
342 static int save_write(void *file, const void *buf, u32 len)
344 struct save_fp *fp = file;
345 if (fp == NULL || buf == NULL)
348 memcpy(fp->buf + fp->pos, buf, len);
353 static long save_seek(void *file, long offs, int whence)
355 struct save_fp *fp = file;
371 static void save_close(void *file)
373 struct save_fp *fp = file;
374 size_t r_size = retro_serialize_size();
378 if (fp->pos > r_size)
379 SysPrintf("ERROR: save buffer overflow detected\n");
380 else if (fp->is_write && fp->pos < r_size)
381 // make sure we don't save trash in leftover space
382 memset(fp->buf + fp->pos, 0, r_size - fp->pos);
386 bool retro_serialize(void *data, size_t size)
388 int ret = SaveState(data);
389 return ret == 0 ? true : false;
392 bool retro_unserialize(const void *data, size_t size)
394 int ret = LoadState(data);
395 return ret == 0 ? true : false;
399 void retro_cheat_reset(void)
404 void retro_cheat_set(unsigned index, bool enabled, const char *code)
409 // cheat funcs are destructive, need a copy..
410 strncpy(buf, code, sizeof(buf));
411 buf[sizeof(buf) - 1] = 0;
413 if (index < NumCheats)
414 ret = EditCheat(index, "", buf);
416 ret = AddCheat("", buf);
419 SysPrintf("Failed to set cheat %#u\n", index);
420 else if (index < NumCheats)
421 Cheats[index].Enabled = enabled;
424 /* multidisk support */
425 static bool disk_ejected;
426 static unsigned int disk_current_index;
427 static unsigned int disk_count;
428 static struct disks_state {
430 int internal_index; // for multidisk eboots
433 static bool disk_set_eject_state(bool ejected)
436 SetCdOpenCaseTime(ejected ? -1 : (time(NULL) + 2));
439 disk_ejected = ejected;
443 static bool disk_get_eject_state(void)
445 /* can't be controlled by emulated software */
449 static unsigned int disk_get_image_index(void)
451 return disk_current_index;
454 static bool disk_set_image_index(unsigned int index)
456 if (index >= sizeof(disks) / sizeof(disks[0]))
460 CdromLabel[0] = '\0';
462 if (disks[index].fname == NULL) {
463 SysPrintf("missing disk #%u\n", index);
466 // RetroArch specifies "no disk" with index == count,
467 // so don't fail here..
468 disk_current_index = index;
472 SysPrintf("switching to disk %u: \"%s\" #%d\n", index,
473 disks[index].fname, disks[index].internal_index);
475 cdrIsoMultidiskSelect = disks[index].internal_index;
476 set_cd_image(disks[index].fname);
477 if (ReloadCdromPlugin() < 0) {
478 SysPrintf("failed to load cdr plugin\n");
481 if (CDR_open() < 0) {
482 SysPrintf("failed to open cdr plugin\n");
487 SetCdOpenCaseTime(time(NULL) + 2);
491 disk_current_index = index;
495 static unsigned int disk_get_num_images(void)
500 static bool disk_replace_image_index(unsigned index,
501 const struct retro_game_info *info)
506 if (index >= sizeof(disks) / sizeof(disks[0]))
509 old_fname = disks[index].fname;
510 disks[index].fname = NULL;
511 disks[index].internal_index = 0;
514 disks[index].fname = strdup(info->path);
515 if (index == disk_current_index)
516 ret = disk_set_image_index(index);
519 if (old_fname != NULL)
525 static bool disk_add_image_index(void)
534 static struct retro_disk_control_callback disk_control = {
535 .set_eject_state = disk_set_eject_state,
536 .get_eject_state = disk_get_eject_state,
537 .get_image_index = disk_get_image_index,
538 .set_image_index = disk_set_image_index,
539 .get_num_images = disk_get_num_images,
540 .replace_image_index = disk_replace_image_index,
541 .add_image_index = disk_add_image_index,
544 // just in case, maybe a win-rt port in the future?
551 static char base_dir[PATH_MAX];
553 static bool read_m3u(const char *file)
557 FILE *f = fopen(file, "r");
561 while (fgets(line, sizeof(line), f) && disk_count < sizeof(disks) / sizeof(disks[0])) {
564 char *carrige_return = strchr(line, '\r');
566 *carrige_return = '\0';
567 char *newline = strchr(line, '\n');
573 snprintf(name, sizeof(name), "%s%c%s", base_dir, SLASH, line);
574 disks[disk_count++].fname = strdup(name);
579 return (disk_count != 0);
582 static void extract_directory(char *buf, const char *path, size_t size)
585 strncpy(buf, path, size - 1);
586 buf[size - 1] = '\0';
588 base = strrchr(buf, '/');
590 base = strrchr(buf, '\\');
602 /* Blackberry QNX doesn't have strcasestr */
605 * Find the first occurrence of find in s, ignore case.
608 strcasestr(const char *s, const char*find)
613 if ((c = *find++) != 0) {
614 c = tolower((unsigned char)c);
618 if ((sc = *s++) == 0)
620 } while ((char)tolower((unsigned char)sc) != c);
621 } while (strncasecmp(s, find, len) != 0);
628 bool retro_load_game(const struct retro_game_info *info)
631 bool is_m3u = (strcasestr(info->path, ".m3u") != NULL);
633 #ifdef FRONTEND_SUPPORTS_RGB565
634 enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
635 if (environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) {
636 SysPrintf("RGB565 supported, using it\n");
640 if (info == NULL || info->path == NULL) {
641 SysPrintf("info->path required\n");
645 if (plugins_opened) {
650 for (i = 0; i < sizeof(disks) / sizeof(disks[0]); i++) {
651 if (disks[i].fname != NULL) {
652 free(disks[i].fname);
653 disks[i].fname = NULL;
655 disks[i].internal_index = 0;
658 disk_current_index = 0;
659 extract_directory(base_dir, info->path, sizeof(base_dir));
662 if (!read_m3u(info->path)) {
663 SysPrintf("failed to read m3u file\n");
668 disks[0].fname = strdup(info->path);
671 set_cd_image(disks[0].fname);
673 /* have to reload after set_cd_image for correct cdr plugin */
674 if (LoadPlugins() == -1) {
675 SysPrintf("failed to load plugins\n");
682 if (OpenPlugins() == -1) {
683 SysPrintf("failed to open plugins\n");
687 plugin_call_rearmed_cbs();
691 if (CheckCdrom() == -1) {
692 SysPrintf("unsupported/invalid CD image: %s\n", info->path);
698 if (LoadCdrom() == -1) {
699 SysPrintf("could not load CD-ROM!\n");
706 disk_count = cdrIsoMultidiskCount < 8 ? cdrIsoMultidiskCount : 8;
707 for (i = 1; i < sizeof(disks) / sizeof(disks[0]) && i < cdrIsoMultidiskCount; i++) {
708 disks[i].fname = strdup(info->path);
709 disks[i].internal_index = i;
716 bool retro_load_game_special(unsigned game_type, const struct retro_game_info *info, size_t num_info)
721 void retro_unload_game(void)
725 unsigned retro_get_region(void)
727 return is_pal_mode ? RETRO_REGION_PAL : RETRO_REGION_NTSC;
730 void *retro_get_memory_data(unsigned id)
732 if (id == RETRO_MEMORY_SAVE_RAM)
738 size_t retro_get_memory_size(unsigned id)
740 if (id == RETRO_MEMORY_SAVE_RAM)
746 void retro_reset(void)
751 static const unsigned short retro_psx_map[] = {
752 [RETRO_DEVICE_ID_JOYPAD_B] = 1 << DKEY_CROSS,
753 [RETRO_DEVICE_ID_JOYPAD_Y] = 1 << DKEY_SQUARE,
754 [RETRO_DEVICE_ID_JOYPAD_SELECT] = 1 << DKEY_SELECT,
755 [RETRO_DEVICE_ID_JOYPAD_START] = 1 << DKEY_START,
756 [RETRO_DEVICE_ID_JOYPAD_UP] = 1 << DKEY_UP,
757 [RETRO_DEVICE_ID_JOYPAD_DOWN] = 1 << DKEY_DOWN,
758 [RETRO_DEVICE_ID_JOYPAD_LEFT] = 1 << DKEY_LEFT,
759 [RETRO_DEVICE_ID_JOYPAD_RIGHT] = 1 << DKEY_RIGHT,
760 [RETRO_DEVICE_ID_JOYPAD_A] = 1 << DKEY_CIRCLE,
761 [RETRO_DEVICE_ID_JOYPAD_X] = 1 << DKEY_TRIANGLE,
762 [RETRO_DEVICE_ID_JOYPAD_L] = 1 << DKEY_L1,
763 [RETRO_DEVICE_ID_JOYPAD_R] = 1 << DKEY_R1,
764 [RETRO_DEVICE_ID_JOYPAD_L2] = 1 << DKEY_L2,
765 [RETRO_DEVICE_ID_JOYPAD_R2] = 1 << DKEY_R2,
766 [RETRO_DEVICE_ID_JOYPAD_L3] = 1 << DKEY_L3,
767 [RETRO_DEVICE_ID_JOYPAD_R3] = 1 << DKEY_R3,
769 #define RETRO_PSX_MAP_LEN (sizeof(retro_psx_map) / sizeof(retro_psx_map[0]))
771 static void update_variables(bool in_flight)
773 struct retro_variable var;
776 var.key = "frameskip";
778 if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
779 pl_rearmed_cbs.frameskip = atoi(var.value);
784 if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
787 if (strcmp(var.value, "Automatic") == 0)
789 else if (strcmp(var.value, "NTSC") == 0)
791 else if (strcmp(var.value, "PAL") == 0)
796 var.key = "pad1type";
798 if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
800 in_type1 = PSE_PAD_TYPE_STANDARD;
801 if (strcmp(var.value, "analog") == 0)
802 in_type1 = PSE_PAD_TYPE_ANALOGPAD;
805 #if defined(__ARM_NEON__) || defined(NEON_PC)
807 var.key = "neon_interlace_enable";
809 if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
811 if (strcmp(var.value, "disabled") == 0)
812 pl_rearmed_cbs.gpu_neon.allow_interlace = 0;
813 else if (strcmp(var.value, "enabled") == 0)
814 pl_rearmed_cbs.gpu_neon.allow_interlace = 1;
818 var.key = "neon_enhancement_enable";
820 if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
822 if (strcmp(var.value, "disabled") == 0)
823 pl_rearmed_cbs.gpu_neon.enhancement_enable = 0;
824 else if (strcmp(var.value, "enabled") == 0)
825 pl_rearmed_cbs.gpu_neon.enhancement_enable = 1;
829 var.key = "neon_enhancement_no_main";
831 if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
833 if (strcmp(var.value, "disabled") == 0)
834 pl_rearmed_cbs.gpu_neon.enhancement_no_main = 0;
835 else if (strcmp(var.value, "enabled") == 0)
836 pl_rearmed_cbs.gpu_neon.enhancement_no_main = 1;
841 var.key = "pcsx_rearmed_duping_enable";
843 if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
845 if (strcmp(var.value, "off") == 0)
846 duping_enable = false;
847 else if (strcmp(var.value, "on") == 0)
848 duping_enable = true;
853 var.key = "rearmed_drc";
855 if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
857 R3000Acpu *prev_cpu = psxCpu;
859 if (strcmp(var.value, "disabled") == 0)
860 Config.Cpu = CPU_INTERPRETER;
861 else if (strcmp(var.value, "enabled") == 0)
862 Config.Cpu = CPU_DYNAREC;
864 psxCpu = (Config.Cpu == CPU_INTERPRETER) ? &psxInt : &psxRec;
865 if (psxCpu != prev_cpu) {
866 prev_cpu->Shutdown();
868 psxCpu->Reset(); // not really a reset..
874 // inform core things about possible config changes
875 plugin_call_rearmed_cbs();
877 if (GPU_open != NULL && GPU_close != NULL) {
879 GPU_open(&gpuDisp, "PCSX", NULL);
892 bool updated = false;
893 if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
894 update_variables(true);
897 for (i = 0; i < RETRO_PSX_MAP_LEN; i++)
898 if (input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i))
899 in_keystate |= retro_psx_map[i];
901 for (i = 0; i < RETRO_PSX_MAP_LEN; i++)
902 if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i))
903 in_keystate |= retro_psx_map[i];
905 if (in_type1 == PSE_PAD_TYPE_ANALOGPAD)
907 in_a1[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
908 in_a1[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128;
909 in_a2[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
910 in_a2[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128;
916 samples_to_send += is_pal_mode ? 44100 / 50 : 44100 / 60;
918 video_cb((vout_fb_dirty || !vout_can_dupe || !duping_enable) ? vout_buf : NULL,
919 vout_width, vout_height, vout_width * 2);
923 static bool try_use_bios(const char *path)
929 f = fopen(path, "rb");
933 fseek(f, 0, SEEK_END);
937 if (size != 512 * 1024)
940 name = strrchr(path, SLASH);
943 snprintf(Config.Bios, sizeof(Config.Bios), "%s", name);
948 #include <sys/types.h>
951 static bool find_any_bios(const char *dirpath, char *path, size_t path_size)
957 dir = opendir(dirpath);
961 while ((ent = readdir(dir))) {
962 if (strncasecmp(ent->d_name, "scph", 4) != 0)
965 snprintf(path, path_size, "%s/%s", dirpath, ent->d_name);
966 ret = try_use_bios(path);
974 #define find_any_bios(...) false
977 static void check_system_specs(void)
980 environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level);
983 void retro_init(void)
985 const char *bios[] = { "scph1001", "scph5501", "scph7001" };
989 bool found_bios = false;
991 ret = emu_core_preinit();
992 ret |= emu_core_init();
994 SysPrintf("PCSX init failed.\n");
998 #if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L)
999 posix_memalign(&vout_buf, 16, VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2);
1001 vout_buf = malloc(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2);
1004 if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir)
1006 snprintf(Config.BiosDir, sizeof(Config.BiosDir), "%s/", dir);
1008 for (i = 0; i < sizeof(bios) / sizeof(bios[0]); i++) {
1009 snprintf(path, sizeof(path), "%s/%s.bin", dir, bios[i]);
1010 found_bios = try_use_bios(path);
1016 found_bios = find_any_bios(dir, path, sizeof(path));
1019 SysPrintf("found BIOS file: %s\n", Config.Bios);
1023 SysPrintf("no BIOS files found.\n");
1024 struct retro_message msg =
1026 "no BIOS found, expect bugs!",
1029 environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, (void*)&msg);
1033 environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level);
1035 environ_cb(RETRO_ENVIRONMENT_GET_CAN_DUPE, &vout_can_dupe);
1036 environ_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE, &disk_control);
1038 /* Set how much slower PSX CPU runs * 100 (so that 200 is 2 times)
1039 * we have to do this because cache misses and some IO penalties
1040 * are not emulated. Warning: changing this may break compatibility. */
1041 #ifdef __ARM_ARCH_7A__
1042 cycle_multiplier = 175;
1044 cycle_multiplier = 200;
1049 init_memcard(Mcd1Data);
1051 SaveFuncs.open = save_open;
1052 SaveFuncs.read = save_read;
1053 SaveFuncs.write = save_write;
1054 SaveFuncs.seek = save_seek;
1055 SaveFuncs.close = save_close;
1057 update_variables(false);
1058 check_system_specs();
1061 void retro_deinit(void)