4 * This work is licensed under the terms of the GNU GPLv2 or later.
5 * See the COPYING file in the top-level directory.
20 #include "plugin_lib.h"
24 #include "../libpcsxcore/misc.h"
25 #include "../libpcsxcore/cheat.h"
26 #include "../libpcsxcore/new_dynarec/new_dynarec.h"
27 #include "../plugins/cdrcimg/cdrcimg.h"
28 #include "../plugins/dfsound/spu_config.h"
29 #include "arm_features.h"
33 #include "libpicofe/input.h"
34 #include "libpicofe/plat.h"
35 #include "libpicofe/readpng.h"
37 static void toggle_fast_forward(int force_off);
38 static void check_profile(void);
39 static void check_memcards(void);
42 #define BOOT_MSG "Booting up..."
45 // don't include debug.h - it breaks ARM build (R1 redefined)
49 int ready_to_go, g_emu_want_quit, g_emu_resetting;
50 unsigned long gpuDisp;
51 char cfgfile_basename[MAXPATHLEN];
53 enum sched_action emu_action, emu_action_old;
57 static void make_path(char *buf, size_t size, const char *dir, const char *fname)
60 snprintf(buf, size, ".%s%s", dir, fname);
62 snprintf(buf, size, ".%s", dir);
64 #define MAKE_PATH(buf, dir, fname) \
65 make_path(buf, sizeof(buf), dir, fname)
67 static int get_gameid_filename(char *buf, int size, const char *fmt, int i) {
71 strncpy(trimlabel, CdromLabel, 32);
73 for (j = 31; j >= 0; j--)
74 if (trimlabel[j] == ' ')
79 snprintf(buf, size, fmt, trimlabel, CdromId, i);
84 void set_cd_image(const char *fname)
86 const char *ext = NULL;
89 ext = strrchr(fname, '.');
92 strcasecmp(ext, ".z") == 0 || strcasecmp(ext, ".bz") == 0 ||
93 strcasecmp(ext, ".znx") == 0 /*|| strcasecmp(ext, ".pbp") == 0*/)) {
95 cdrcimg_set_fname(fname);
96 strcpy(Config.Cdr, "builtin_cdrcimg");
99 strcpy(Config.Cdr, "builtin_cdr");
103 static void set_default_paths(void)
106 snprintf(Config.PatchesDir, sizeof(Config.PatchesDir), "." PATCHES_DIR);
107 MAKE_PATH(Config.Mcd1, MEMCARD_DIR, "card1.mcd");
108 MAKE_PATH(Config.Mcd2, MEMCARD_DIR, "card2.mcd");
109 strcpy(Config.BiosDir, "bios");
112 strcpy(Config.PluginsDir, "plugins");
113 strcpy(Config.Gpu, "builtin_gpu");
114 strcpy(Config.Spu, "builtin_spu");
115 strcpy(Config.Cdr, "builtin_cdr");
116 strcpy(Config.Pad1, "builtin_pad");
117 strcpy(Config.Pad2, "builtin_pad");
118 strcpy(Config.Net, "Disabled");
121 void emu_set_default_config(void)
123 // try to set sane config on which most games work
124 Config.Xa = Config.Cdda = Config.Sio =
125 Config.SpuIrq = Config.RCntFix = Config.VSyncWA = 0;
128 pl_rearmed_cbs.gpu_neon.allow_interlace = 2; // auto
129 pl_rearmed_cbs.gpu_neon.enhancement_enable =
130 pl_rearmed_cbs.gpu_neon.enhancement_no_main = 0;
131 pl_rearmed_cbs.gpu_peops.iUseDither = 0;
132 pl_rearmed_cbs.gpu_peops.dwActFixes = 1<<7;
133 pl_rearmed_cbs.gpu_unai.abe_hack =
134 pl_rearmed_cbs.gpu_unai.no_light =
135 pl_rearmed_cbs.gpu_unai.no_blend = 0;
136 memset(&pl_rearmed_cbs.gpu_peopsgl, 0, sizeof(pl_rearmed_cbs.gpu_peopsgl));
137 pl_rearmed_cbs.gpu_peopsgl.iVRamSize = 64;
138 pl_rearmed_cbs.gpu_peopsgl.iTexGarbageCollection = 1;
140 spu_config.iUseReverb = 1;
141 spu_config.idiablofix = 0;
142 spu_config.iUseInterpolation = 1;
143 spu_config.iXAPitch = 0;
144 spu_config.iVolume = 768;
145 spu_config.iTempo = 0;
146 spu_config.iUseThread = 1; // no effect if only 1 core is detected
147 #ifdef HAVE_PRE_ARMV7 /* XXX GPH hack */
148 spu_config.iUseReverb = 0;
149 spu_config.iUseInterpolation = 0;
150 spu_config.iTempo = 1;
152 new_dynarec_hacks = 0;
153 cycle_multiplier = 200;
155 in_type1 = PSE_PAD_TYPE_STANDARD;
156 in_type2 = PSE_PAD_TYPE_STANDARD;
159 void do_emu_action(void)
163 emu_action_old = emu_action;
165 switch (emu_action) {
166 case SACTION_LOAD_STATE:
167 ret = emu_load_state(state_slot);
168 snprintf(hud_msg, sizeof(hud_msg), ret == 0 ? "LOADED" : "FAIL!");
170 case SACTION_SAVE_STATE:
171 ret = emu_save_state(state_slot);
172 snprintf(hud_msg, sizeof(hud_msg), ret == 0 ? "SAVED" : "FAIL!");
175 case SACTION_ENTER_MENU:
176 toggle_fast_forward(1);
179 case SACTION_NEXT_SSLOT:
184 case SACTION_PREV_SSLOT:
189 snprintf(hud_msg, sizeof(hud_msg), "STATE SLOT %d [%s]", state_slot,
190 emu_check_state(state_slot) == 0 ? "USED" : "FREE");
192 SysPrintf("* %s\n", hud_msg);
194 case SACTION_TOGGLE_FSKIP:
195 pl_rearmed_cbs.fskip_advice = 0;
196 pl_rearmed_cbs.frameskip++;
197 if (pl_rearmed_cbs.frameskip > 1)
198 pl_rearmed_cbs.frameskip = -1;
199 snprintf(hud_msg, sizeof(hud_msg), "FRAMESKIP: %s",
200 pl_rearmed_cbs.frameskip == -1 ? "AUTO" :
201 pl_rearmed_cbs.frameskip == 0 ? "OFF" : "1" );
202 plugin_call_rearmed_cbs();
204 case SACTION_SWITCH_DISPMODE:
205 pl_switch_dispmode();
206 plugin_call_rearmed_cbs();
207 if (GPU_open != NULL && GPU_close != NULL) {
209 GPU_open(&gpuDisp, "PCSX", NULL);
212 case SACTION_FAST_FORWARD:
213 toggle_fast_forward(0);
214 plugin_call_rearmed_cbs();
216 case SACTION_TOGGLE_FPS:
217 if ((g_opts & (OPT_SHOWFPS|OPT_SHOWCPU))
218 == (OPT_SHOWFPS|OPT_SHOWCPU))
219 g_opts &= ~(OPT_SHOWFPS|OPT_SHOWCPU);
220 else if (g_opts & OPT_SHOWFPS)
221 g_opts |= OPT_SHOWCPU;
223 g_opts |= OPT_SHOWFPS;
225 case SACTION_TOGGLE_FULLSCREEN:
226 plat_target.vout_fullscreen = !plat_target.vout_fullscreen;
227 if (GPU_open != NULL && GPU_close != NULL) {
229 GPU_open(&gpuDisp, "PCSX", NULL);
232 case SACTION_SCREENSHOT:
234 char buf[MAXPATHLEN];
237 time_t t = time(NULL);
238 struct tm *tb = localtime(&t);
239 int ti = tb->tm_yday * 1000000 + tb->tm_hour * 10000 +
240 tb->tm_min * 100 + tb->tm_sec;
242 scrbuf = pl_prepare_screenshot(&w, &h, &bpp);
243 get_gameid_filename(buf, sizeof(buf),
244 "screenshots/%.32s-%.9s.%d.png", ti);
246 if (scrbuf != 0 && bpp == 16)
247 ret = writepng(buf, scrbuf, w, h);
249 snprintf(hud_msg, sizeof(hud_msg), "SCREENSHOT TAKEN");
252 case SACTION_VOLUME_UP:
253 case SACTION_VOLUME_DOWN:
256 plat_target_step_volume(&volume,
257 emu_action == SACTION_VOLUME_UP ? 1 : -1);
260 case SACTION_MINIMIZE:
261 if (GPU_close != NULL)
266 if (GPU_open != NULL) {
267 ret = GPU_open(&gpuDisp, "PCSX", NULL);
269 SysMessage("GPU_open returned %d", ret);
280 static char basic_lcase(char c)
282 if ('A' <= c && c <= 'Z')
283 return c - 'A' + 'a';
287 static int cdidcmp(const char *id1, const char *id2)
289 while (*id1 != 0 && *id2 != 0) {
290 if (*id1 == '_') { id1++; continue; }
291 if (*id2 == '_') { id2++; continue; }
292 if (basic_lcase(*id1) != basic_lcase(*id2))
301 static void parse_cwcheat(void)
303 char line[256], buf[64], name[64], *p;
308 f = fopen("cheatpops.db", "r");
313 while (fgets(line, sizeof(line), f)) {
314 if (sscanf(line, "_S %63s", buf) != 1)
316 if (cdidcmp(buf, CdromId) == 0)
323 SysPrintf("cwcheat section found for %s\n", CdromId);
324 while (fgets(line, sizeof(line), f))
326 p = line + strlen(line);
327 for (p--; p >= line && (*p == '\r' || *p == '\n' || *p == ' '); p--)
329 if (*p == 0 || *p == '#' || *p == ';')
332 if (strncmp(line, "_S", 2) == 0)
334 if (strncmp(line, "_G", 2) == 0) {
335 SysPrintf(" cwcheat game name: '%s'\n", line + 3);
338 if (strncmp(line, "_C0", 3) == 0) {
339 if (!newcheat && Cheats[NumCheats - 1].n == 0) {
340 SysPrintf("cheat '%s' failed to parse\n", name);
341 free(Cheats[NumCheats - 1].Descr);
344 snprintf(name, sizeof(name), "%s", line + 4);
348 if (sscanf(line, "_L %x %x", &a, &v) != 2) {
349 SysPrintf("line failed to parse: '%s'\n", line);
354 if (NumCheats >= NumCheatsAllocated) {
355 NumCheatsAllocated += 16;
356 Cheats = realloc(Cheats, sizeof(Cheat) *
361 Cheats[NumCheats].Descr = strdup(name);
362 Cheats[NumCheats].Enabled = 0;
363 Cheats[NumCheats].WasEnabled = 0;
364 Cheats[NumCheats].First = NumCodes;
365 Cheats[NumCheats].n = 0;
370 if (NumCodes >= NumCodesAllocated) {
371 NumCodesAllocated += 16;
372 CheatCodes = realloc(CheatCodes, sizeof(CheatCode) *
374 if (CheatCodes == NULL)
377 CheatCodes[NumCodes].Addr = a;
378 CheatCodes[NumCodes].Val = v;
380 Cheats[NumCheats - 1].n++;
387 void emu_on_new_cd(int show_hud_msg)
393 SysPrintf("note: running with HLE BIOS, expect compatibility problems\n");
394 SysPrintf("----------------------------------------------------------\n");
398 snprintf(hud_msg, sizeof(hud_msg), BOOT_MSG);
403 int emu_core_preinit(void)
405 // what is the name of the config file?
406 // it may be redefined by -cfg on the command line
407 strcpy(cfgfile_basename, "pcsx.cfg");
410 emuLog = fopen("/User/Documents/pcsxr.log", "w");
412 emuLog = fopen("pcsxr.log", "w");
419 memset(&Config, 0, sizeof(Config));
422 emu_set_default_config();
423 strcpy(Config.Bios, "HLE");
428 int emu_core_init(void)
430 SysPrintf("Starting PCSX-ReARMed " REV "\n");
437 if (EmuInit() == -1) {
438 SysPrintf("PSX emulator couldn't be initialized.\n");
442 LoadMcds(Config.Mcd1, Config.Mcd2);
451 void emu_core_ask_exit(void)
459 #include <sys/stat.h>
460 #include <sys/types.h>
462 static void create_profile_dir(const char *directory) {
463 char path[MAXPATHLEN];
465 MAKE_PATH(path, directory, NULL);
466 mkdir(path, S_IRWXU | S_IRWXG);
469 static void check_profile(void) {
470 // make sure that ~/.pcsx exists
471 create_profile_dir(PCSX_DOT_DIR);
473 create_profile_dir(BIOS_DIR);
474 create_profile_dir(MEMCARD_DIR);
475 create_profile_dir(STATES_DIR);
476 create_profile_dir(PLUGINS_DIR);
477 create_profile_dir(PLUGINS_CFG_DIR);
478 create_profile_dir(CHEATS_DIR);
479 create_profile_dir(PATCHES_DIR);
480 create_profile_dir(PCSX_DOT_DIR "cfg");
481 create_profile_dir("/screenshots/");
484 static void check_memcards(void)
486 char buf[MAXPATHLEN];
490 for (i = 1; i <= 9; i++) {
491 snprintf(buf, sizeof(buf), ".%scard%d.mcd", MEMCARD_DIR, i);
493 f = fopen(buf, "rb");
495 SysPrintf("Creating memcard: %s\n", buf);
503 int main(int argc, char *argv[])
505 char file[MAXPATHLEN] = "";
506 char path[MAXPATHLEN];
507 const char *cdfile = NULL;
508 const char *loadst_f = NULL;
515 // read command line options
516 for (i = 1; i < argc; i++) {
517 if (!strcmp(argv[i], "-psxout")) psxout = 1;
518 else if (!strcmp(argv[i], "-load")) loadst = atol(argv[++i]);
519 else if (!strcmp(argv[i], "-cfg")) {
520 if (i+1 >= argc) break;
521 strncpy(cfgfile_basename, argv[++i], MAXPATHLEN-100); /* TODO buffer overruns */
522 SysPrintf("Using config file %s.\n", cfgfile_basename);
524 else if (!strcmp(argv[i], "-cdfile")) {
525 char isofilename[MAXPATHLEN];
527 if (i+1 >= argc) break;
528 strncpy(isofilename, argv[++i], MAXPATHLEN);
529 if (isofilename[0] != '/') {
530 getcwd(path, MAXPATHLEN);
531 if (strlen(path) + strlen(isofilename) + 1 < MAXPATHLEN) {
533 strcat(path, isofilename);
534 strcpy(isofilename, path);
539 cdfile = isofilename;
541 else if (!strcmp(argv[i], "-loadf")) {
542 if (i+1 >= argc) break;
543 loadst_f = argv[++i];
545 else if (!strcmp(argv[i], "-h") ||
546 !strcmp(argv[i], "-help") ||
547 !strcmp(argv[i], "--help")) {
548 printf("PCSX-ReARMed " REV "\n");
550 " pcsx [options] [file]\n"
552 "\t-cdfile FILE\tRuns a CD image file\n"
553 "\t-cfg FILE\tLoads desired configuration file (default: ~/.pcsx/pcsx.cfg)\n"
554 "\t-psxout\t\tEnable PSX output\n"
555 "\t-load STATENUM\tLoads savestate STATENUM (1-5)\n"
556 "\t-h -help\tDisplay this message\n"
557 "\tfile\t\tLoads a PSX EXE file\n"));
560 strncpy(file, argv[i], MAXPATHLEN);
561 if (file[0] != '/') {
562 getcwd(path, MAXPATHLEN);
563 if (strlen(path) + strlen(file) + 1 < MAXPATHLEN) {
574 set_cd_image(cdfile);
577 // init input but leave probing to platform code,
578 // they add input drivers and may need to modify them after probe
582 menu_init(); // loads config
584 if (emu_core_init() != 0)
590 if (LoadPlugins() == -1) {
591 // FIXME: this recovery doesn't work, just delete bad config and bail out
592 // SysMessage("could not load plugins, retrying with defaults\n");
594 snprintf(path, sizeof(path), "." PCSX_DOT_DIR "%s", cfgfile_basename);
596 SysMessage("Failed loading plugins!");
601 if (OpenPlugins() == -1) {
604 plugin_call_rearmed_cbs();
609 if (file[0] != '\0') {
610 if (Load(file) != -1)
614 if (LoadCdrom() == -1) {
616 SysPrintf(_("Could not load CD-ROM!\n"));
619 emu_on_new_cd(!loadst);
625 int ret = LoadState(loadst_f);
626 SysPrintf("%s state file: %s\n",
627 ret ? "failed to load" : "loaded", loadst_f);
628 ready_to_go |= ret == 0;
634 // If a state has been specified, then load that
636 int ret = emu_load_state(loadst - 1);
637 SysPrintf("%s state %d\n",
638 ret ? "failed to load" : "loaded", loadst);
646 while (!g_emu_want_quit)
649 emu_action = SACTION_NONE;
652 if (emu_action != SACTION_NONE)
665 static void toggle_fast_forward(int force_off)
667 static int fast_forward;
668 static int normal_g_opts;
669 static int normal_frameskip;
670 static int normal_enhancement_enable;
672 if (force_off && !fast_forward)
675 fast_forward = !fast_forward;
677 normal_g_opts = g_opts;
678 normal_frameskip = pl_rearmed_cbs.frameskip;
679 normal_enhancement_enable =
680 pl_rearmed_cbs.gpu_neon.enhancement_enable;
682 g_opts |= OPT_NO_FRAMELIM;
683 pl_rearmed_cbs.frameskip = 3;
684 pl_rearmed_cbs.gpu_neon.enhancement_enable = 0;
686 g_opts = normal_g_opts;
687 pl_rearmed_cbs.frameskip = normal_frameskip;
688 pl_rearmed_cbs.gpu_neon.enhancement_enable =
689 normal_enhancement_enable;
691 pl_timing_prepare(Config.PsxType);
695 snprintf(hud_msg, sizeof(hud_msg), "FAST FORWARD %s",
696 fast_forward ? "ON" : "OFF");
699 static void SignalExit(int sig) {
700 // only to restore framebuffer/resolution on some devices
707 printf("SysRunGui\n");
710 static void dummy_lace()
715 // rearmed hack: EmuReset() runs some code when real BIOS is used,
716 // but we usually do reset from menu while GPU is not open yet,
717 // so we need to prevent updateLace() call..
718 void *real_lace = GPU_updateLace;
719 GPU_updateLace = dummy_lace;
722 // reset can run code, timing must be set
723 pl_timing_prepare(Config.PsxType);
727 // hmh core forgets this
730 GPU_updateLace = real_lace;
740 if (emuLog != NULL && emuLog != stdout && emuLog != stderr) {
749 int get_state_filename(char *buf, int size, int i) {
750 return get_gameid_filename(buf, size,
751 "." STATES_DIR "%.32s-%.9s.%3.3d", i);
754 int emu_check_state(int slot)
756 char fname[MAXPATHLEN];
759 ret = get_state_filename(fname, sizeof(fname), slot);
763 return CheckState(fname);
766 int emu_save_state(int slot)
768 char fname[MAXPATHLEN];
771 ret = get_state_filename(fname, sizeof(fname), slot);
775 ret = SaveState(fname);
776 #ifdef HAVE_PRE_ARMV7 /* XXX GPH hack */
779 SysPrintf("* %s \"%s\" [%d]\n",
780 ret == 0 ? "saved" : "failed to save", fname, slot);
784 int emu_load_state(int slot)
786 char fname[MAXPATHLEN];
791 ret = get_state_filename(fname, sizeof(fname), slot);
795 return LoadState(fname);
800 void SysPrintf(const char *fmt, ...) {
804 vfprintf(emuLog, fmt, list);
811 #include <android/log.h>
813 void SysPrintf(const char *fmt, ...) {
817 __android_log_vprint(ANDROID_LOG_INFO, "PCSX", fmt, list);
823 void SysMessage(const char *fmt, ...) {
829 ret = vsnprintf(msg, sizeof(msg), fmt, list);
832 if (ret < sizeof(msg) && msg[ret - 1] == '\n')
835 SysPrintf("%s\n", msg);
838 #define PARSEPATH(dst, src) \
839 ptr = src + strlen(src); \
840 while (*ptr != '\\' && ptr != src) ptr--; \
842 strcpy(dst, ptr+1); \
845 static int _OpenPlugins(void) {
849 signal(SIGINT, SignalExit);
850 signal(SIGPIPE, SignalExit);
853 GPU_clearDynarec(clearDynarec);
856 if (ret < 0) { SysMessage(_("Error opening CD-ROM plugin!")); return -1; }
858 if (ret < 0) { SysMessage(_("Error opening SPU plugin!")); return -1; }
859 SPU_registerCallback(SPUirq);
860 SPU_registerScheduleCb(SPUschedule);
861 // pcsx-rearmed: we handle gpu elsewhere
862 //ret = GPU_open(&gpuDisp, "PCSX", NULL);
863 //if (ret < 0) { SysMessage(_("Error opening GPU plugin!")); return -1; }
864 ret = PAD1_open(&gpuDisp);
865 if (ret < 0) { SysMessage(_("Error opening Controller 1 plugin!")); return -1; }
866 ret = PAD2_open(&gpuDisp);
867 if (ret < 0) { SysMessage(_("Error opening Controller 2 plugin!")); return -1; }
869 if (Config.UseNet && !NetOpened) {
871 char path[MAXPATHLEN];
872 char dotdir[MAXPATHLEN];
874 MAKE_PATH(dotdir, "/.pcsx/plugins/", NULL);
876 strcpy(info.EmuName, "PCSX");
877 strncpy(info.CdromID, CdromId, 9);
878 strncpy(info.CdromLabel, CdromLabel, 9);
880 info.GPU_showScreenPic = GPU_showScreenPic;
881 info.GPU_displayText = GPU_displayText;
882 info.GPU_showScreenPic = GPU_showScreenPic;
883 info.PAD_setSensitive = PAD1_setSensitive;
884 sprintf(path, "%s%s", Config.BiosDir, Config.Bios);
885 strcpy(info.BIOSpath, path);
886 strcpy(info.MCD1path, Config.Mcd1);
887 strcpy(info.MCD2path, Config.Mcd2);
888 sprintf(path, "%s%s", dotdir, Config.Gpu);
889 strcpy(info.GPUpath, path);
890 sprintf(path, "%s%s", dotdir, Config.Spu);
891 strcpy(info.SPUpath, path);
892 sprintf(path, "%s%s", dotdir, Config.Cdr);
893 strcpy(info.CDRpath, path);
896 ret = NET_open(&gpuDisp);
899 // -2 is returned when something in the info
900 // changed and needs to be synced
903 PARSEPATH(Config.Bios, info.BIOSpath);
904 PARSEPATH(Config.Gpu, info.GPUpath);
905 PARSEPATH(Config.Spu, info.SPUpath);
906 PARSEPATH(Config.Cdr, info.CDRpath);
908 strcpy(Config.Mcd1, info.MCD1path);
909 strcpy(Config.Mcd2, info.MCD2path);
912 Config.UseNet = FALSE;
915 if (NET_queryPlayer() == 1) {
916 if (SendPcsxInfo() == -1) Config.UseNet = FALSE;
918 if (RecvPcsxInfo() == -1) Config.UseNet = FALSE;
922 } else if (Config.UseNet) {
932 while ((ret = _OpenPlugins()) == -2) {
934 LoadMcds(Config.Mcd1, Config.Mcd2);
935 if (LoadPlugins() == -1) return -1;
940 void ClosePlugins() {
944 signal(SIGINT, SIG_DFL);
945 signal(SIGPIPE, SIG_DFL);
949 if (ret < 0) { SysMessage(_("Error closing CD-ROM plugin!")); return; }
951 if (ret < 0) { SysMessage(_("Error closing SPU plugin!")); return; }
953 if (ret < 0) { SysMessage(_("Error closing Controller 1 Plugin!")); return; }
955 if (ret < 0) { SysMessage(_("Error closing Controller 2 plugin!")); return; }
956 // pcsx-rearmed: we handle gpu elsewhere
958 //if (ret < 0) { SysMessage(_("Error closing GPU plugin!")); return; }
965 /* we hook statically linked plugins here */
966 static const char *builtin_plugins[] = {
967 "builtin_gpu", "builtin_spu", "builtin_cdr", "builtin_pad",
971 static const int builtin_plugin_ids[] = {
972 PLUGIN_GPU, PLUGIN_SPU, PLUGIN_CDR, PLUGIN_PAD,
976 void *SysLoadLibrary(const char *lib) {
977 const char *tmp = strrchr(lib, '/');
981 SysPrintf("plugin: %s\n", lib);
985 for (i = 0; i < ARRAY_SIZE(builtin_plugins); i++)
986 if (strcmp(tmp, builtin_plugins[i]) == 0)
987 return (void *)(long)(PLUGIN_DL_BASE + builtin_plugin_ids[i]);
991 ret = dlopen(lib, RTLD_NOW);
993 SysMessage("dlopen: %s", dlerror());
995 /* no external plugin support, abi is no longer
996 * compatible with psemu/pcsx anyway */
1001 void *SysLoadSym(void *lib, const char *sym) {
1002 unsigned int plugid = (unsigned int)(long)lib;
1004 if (PLUGIN_DL_BASE <= plugid && plugid < PLUGIN_DL_BASE + ARRAY_SIZE(builtin_plugins))
1005 return plugin_link(plugid - PLUGIN_DL_BASE, sym);
1008 return dlsym(lib, sym);
1014 const char *SysLibError() {
1018 return "not supported";
1022 void SysCloseLibrary(void *lib) {
1023 unsigned int plugid = (unsigned int)(long)lib;
1025 if (PLUGIN_DL_BASE <= plugid && plugid < PLUGIN_DL_BASE + ARRAY_SIZE(builtin_plugins))