4 * This work is licensed under the terms of the GNU GPLv2 or later.
5 * See the COPYING file in the top-level directory.
14 #if !defined(_WIN32) && !defined(NO_DYLIB)
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.iUseInterpolation = 1;
142 spu_config.iXAPitch = 0;
143 spu_config.iVolume = 768;
144 spu_config.iTempo = 0;
145 spu_config.iUseThread = 1; // no effect if only 1 core is detected
146 #ifdef HAVE_PRE_ARMV7 /* XXX GPH hack */
147 spu_config.iUseReverb = 0;
148 spu_config.iUseInterpolation = 0;
149 spu_config.iTempo = 1;
151 new_dynarec_hacks = 0;
152 cycle_multiplier = 200;
154 in_type[0] = PSE_PAD_TYPE_STANDARD;
155 in_type[1] = PSE_PAD_TYPE_STANDARD;
158 void do_emu_action(void)
162 emu_action_old = emu_action;
164 switch (emu_action) {
165 case SACTION_LOAD_STATE:
166 ret = emu_load_state(state_slot);
167 snprintf(hud_msg, sizeof(hud_msg), ret == 0 ? "LOADED" : "FAIL!");
169 case SACTION_SAVE_STATE:
170 ret = emu_save_state(state_slot);
171 snprintf(hud_msg, sizeof(hud_msg), ret == 0 ? "SAVED" : "FAIL!");
174 case SACTION_ENTER_MENU:
175 toggle_fast_forward(1);
178 case SACTION_NEXT_SSLOT:
183 case SACTION_PREV_SSLOT:
188 snprintf(hud_msg, sizeof(hud_msg), "STATE SLOT %d [%s]", state_slot,
189 emu_check_state(state_slot) == 0 ? "USED" : "FREE");
191 SysPrintf("* %s\n", hud_msg);
193 case SACTION_TOGGLE_FSKIP:
194 pl_rearmed_cbs.fskip_advice = 0;
195 pl_rearmed_cbs.frameskip++;
196 if (pl_rearmed_cbs.frameskip > 1)
197 pl_rearmed_cbs.frameskip = -1;
198 snprintf(hud_msg, sizeof(hud_msg), "FRAMESKIP: %s",
199 pl_rearmed_cbs.frameskip == -1 ? "AUTO" :
200 pl_rearmed_cbs.frameskip == 0 ? "OFF" : "1" );
201 plugin_call_rearmed_cbs();
203 case SACTION_SWITCH_DISPMODE:
204 pl_switch_dispmode();
205 plugin_call_rearmed_cbs();
206 if (GPU_open != NULL && GPU_close != NULL) {
208 GPU_open(&gpuDisp, "PCSX", NULL);
211 case SACTION_FAST_FORWARD:
212 toggle_fast_forward(0);
213 plugin_call_rearmed_cbs();
215 case SACTION_TOGGLE_FPS:
216 if ((g_opts & (OPT_SHOWFPS|OPT_SHOWCPU))
217 == (OPT_SHOWFPS|OPT_SHOWCPU))
218 g_opts &= ~(OPT_SHOWFPS|OPT_SHOWCPU);
219 else if (g_opts & OPT_SHOWFPS)
220 g_opts |= OPT_SHOWCPU;
222 g_opts |= OPT_SHOWFPS;
224 case SACTION_TOGGLE_FULLSCREEN:
225 plat_target.vout_fullscreen = !plat_target.vout_fullscreen;
226 if (GPU_open != NULL && GPU_close != NULL) {
228 GPU_open(&gpuDisp, "PCSX", NULL);
231 case SACTION_SCREENSHOT:
233 char buf[MAXPATHLEN];
236 time_t t = time(NULL);
237 struct tm *tb = localtime(&t);
238 int ti = tb->tm_yday * 1000000 + tb->tm_hour * 10000 +
239 tb->tm_min * 100 + tb->tm_sec;
241 scrbuf = pl_prepare_screenshot(&w, &h, &bpp);
242 get_gameid_filename(buf, sizeof(buf),
243 "screenshots/%.32s-%.9s.%d.png", ti);
245 if (scrbuf != 0 && bpp == 16)
246 ret = writepng(buf, scrbuf, w, h);
248 snprintf(hud_msg, sizeof(hud_msg), "SCREENSHOT TAKEN");
251 case SACTION_VOLUME_UP:
252 case SACTION_VOLUME_DOWN:
255 plat_target_step_volume(&volume,
256 emu_action == SACTION_VOLUME_UP ? 1 : -1);
259 case SACTION_MINIMIZE:
260 if (GPU_close != NULL)
265 if (GPU_open != NULL) {
266 ret = GPU_open(&gpuDisp, "PCSX", NULL);
268 SysMessage("GPU_open returned %d", ret);
279 static char basic_lcase(char c)
281 if ('A' <= c && c <= 'Z')
282 return c - 'A' + 'a';
286 static int cdidcmp(const char *id1, const char *id2)
288 while (*id1 != 0 && *id2 != 0) {
289 if (*id1 == '_') { id1++; continue; }
290 if (*id2 == '_') { id2++; continue; }
291 if (basic_lcase(*id1) != basic_lcase(*id2))
300 static void parse_cwcheat(void)
302 char line[256], buf[64], name[64], *p;
307 f = fopen("cheatpops.db", "r");
312 while (fgets(line, sizeof(line), f)) {
313 if (sscanf(line, "_S %63s", buf) != 1)
315 if (cdidcmp(buf, CdromId) == 0)
322 SysPrintf("cwcheat section found for %s\n", CdromId);
323 while (fgets(line, sizeof(line), f))
325 p = line + strlen(line);
326 for (p--; p >= line && (*p == '\r' || *p == '\n' || *p == ' '); p--)
328 if (*p == 0 || *p == '#' || *p == ';')
331 if (strncmp(line, "_S", 2) == 0)
333 if (strncmp(line, "_G", 2) == 0) {
334 SysPrintf(" cwcheat game name: '%s'\n", line + 3);
337 if (strncmp(line, "_C0", 3) == 0) {
338 if (!newcheat && Cheats[NumCheats - 1].n == 0) {
339 SysPrintf("cheat '%s' failed to parse\n", name);
340 free(Cheats[NumCheats - 1].Descr);
343 snprintf(name, sizeof(name), "%s", line + 4);
347 if (sscanf(line, "_L %x %x", &a, &v) != 2) {
348 SysPrintf("line failed to parse: '%s'\n", line);
353 if (NumCheats >= NumCheatsAllocated) {
354 NumCheatsAllocated += 16;
355 Cheats = realloc(Cheats, sizeof(Cheat) *
360 Cheats[NumCheats].Descr = strdup(name);
361 Cheats[NumCheats].Enabled = 0;
362 Cheats[NumCheats].WasEnabled = 0;
363 Cheats[NumCheats].First = NumCodes;
364 Cheats[NumCheats].n = 0;
369 if (NumCodes >= NumCodesAllocated) {
370 NumCodesAllocated += 16;
371 CheatCodes = realloc(CheatCodes, sizeof(CheatCode) *
373 if (CheatCodes == NULL)
376 CheatCodes[NumCodes].Addr = a;
377 CheatCodes[NumCodes].Val = v;
379 Cheats[NumCheats - 1].n++;
386 void emu_on_new_cd(int show_hud_msg)
392 SysPrintf("note: running with HLE BIOS, expect compatibility problems\n");
393 SysPrintf("----------------------------------------------------------\n");
397 snprintf(hud_msg, sizeof(hud_msg), BOOT_MSG);
402 int emu_core_preinit(void)
404 // what is the name of the config file?
405 // it may be redefined by -cfg on the command line
406 strcpy(cfgfile_basename, "pcsx.cfg");
409 emuLog = fopen("/User/Documents/pcsxr.log", "w");
411 emuLog = fopen("pcsxr.log", "w");
418 memset(&Config, 0, sizeof(Config));
421 emu_set_default_config();
422 strcpy(Config.Bios, "HLE");
427 int emu_core_init(void)
429 SysPrintf("Starting PCSX-ReARMed " REV "\n");
436 if (EmuInit() == -1) {
437 SysPrintf("PSX emulator couldn't be initialized.\n");
441 LoadMcds(Config.Mcd1, Config.Mcd2);
450 void emu_core_ask_exit(void)
458 #include <sys/stat.h>
459 #include <sys/types.h>
461 static void create_profile_dir(const char *directory) {
462 char path[MAXPATHLEN];
464 MAKE_PATH(path, directory, NULL);
465 mkdir(path, S_IRWXU | S_IRWXG);
468 static void check_profile(void) {
469 // make sure that ~/.pcsx exists
470 create_profile_dir(PCSX_DOT_DIR);
472 create_profile_dir(BIOS_DIR);
473 create_profile_dir(MEMCARD_DIR);
474 create_profile_dir(STATES_DIR);
475 create_profile_dir(PLUGINS_DIR);
476 create_profile_dir(PLUGINS_CFG_DIR);
477 create_profile_dir(CHEATS_DIR);
478 create_profile_dir(PATCHES_DIR);
479 create_profile_dir(PCSX_DOT_DIR "cfg");
480 create_profile_dir("/screenshots/");
483 static void check_memcards(void)
485 char buf[MAXPATHLEN];
489 for (i = 1; i <= 9; i++) {
490 snprintf(buf, sizeof(buf), ".%scard%d.mcd", MEMCARD_DIR, i);
492 f = fopen(buf, "rb");
494 SysPrintf("Creating memcard: %s\n", buf);
502 int main(int argc, char *argv[])
504 char file[MAXPATHLEN] = "";
505 char path[MAXPATHLEN];
506 const char *cdfile = NULL;
507 const char *loadst_f = NULL;
514 // read command line options
515 for (i = 1; i < argc; i++) {
516 if (!strcmp(argv[i], "-psxout")) psxout = 1;
517 else if (!strcmp(argv[i], "-load")) loadst = atol(argv[++i]);
518 else if (!strcmp(argv[i], "-cfg")) {
519 if (i+1 >= argc) break;
520 strncpy(cfgfile_basename, argv[++i], MAXPATHLEN-100); /* TODO buffer overruns */
521 SysPrintf("Using config file %s.\n", cfgfile_basename);
523 else if (!strcmp(argv[i], "-cdfile")) {
524 char isofilename[MAXPATHLEN];
526 if (i+1 >= argc) break;
527 strncpy(isofilename, argv[++i], MAXPATHLEN);
528 if (isofilename[0] != '/') {
529 getcwd(path, MAXPATHLEN);
530 if (strlen(path) + strlen(isofilename) + 1 < MAXPATHLEN) {
532 strcat(path, isofilename);
533 strcpy(isofilename, path);
538 cdfile = isofilename;
540 else if (!strcmp(argv[i], "-loadf")) {
541 if (i+1 >= argc) break;
542 loadst_f = argv[++i];
544 else if (!strcmp(argv[i], "-h") ||
545 !strcmp(argv[i], "-help") ||
546 !strcmp(argv[i], "--help")) {
547 printf("PCSX-ReARMed " REV "\n");
549 " pcsx [options] [file]\n"
551 "\t-cdfile FILE\tRuns a CD image file\n"
552 "\t-cfg FILE\tLoads desired configuration file (default: ~/.pcsx/pcsx.cfg)\n"
553 "\t-psxout\t\tEnable PSX output\n"
554 "\t-load STATENUM\tLoads savestate STATENUM (1-5)\n"
555 "\t-h -help\tDisplay this message\n"
556 "\tfile\t\tLoads a PSX EXE file\n"));
559 strncpy(file, argv[i], MAXPATHLEN);
560 if (file[0] != '/') {
561 getcwd(path, MAXPATHLEN);
562 if (strlen(path) + strlen(file) + 1 < MAXPATHLEN) {
573 set_cd_image(cdfile);
576 // init input but leave probing to platform code,
577 // they add input drivers and may need to modify them after probe
581 menu_init(); // loads config
583 if (emu_core_init() != 0)
589 if (LoadPlugins() == -1) {
590 // FIXME: this recovery doesn't work, just delete bad config and bail out
591 // SysMessage("could not load plugins, retrying with defaults\n");
593 snprintf(path, sizeof(path), "." PCSX_DOT_DIR "%s", cfgfile_basename);
595 SysMessage("Failed loading plugins!");
600 if (OpenPlugins() == -1) {
603 plugin_call_rearmed_cbs();
608 if (file[0] != '\0') {
609 if (Load(file) != -1)
613 if (LoadCdrom() == -1) {
615 SysPrintf(_("Could not load CD-ROM!\n"));
618 emu_on_new_cd(!loadst);
624 int ret = LoadState(loadst_f);
625 SysPrintf("%s state file: %s\n",
626 ret ? "failed to load" : "loaded", loadst_f);
627 ready_to_go |= ret == 0;
633 // If a state has been specified, then load that
635 int ret = emu_load_state(loadst - 1);
636 SysPrintf("%s state %d\n",
637 ret ? "failed to load" : "loaded", loadst);
645 while (!g_emu_want_quit)
648 emu_action = SACTION_NONE;
651 if (emu_action != SACTION_NONE)
664 static void toggle_fast_forward(int force_off)
666 static int fast_forward;
667 static int normal_g_opts;
668 static int normal_frameskip;
669 static int normal_enhancement_enable;
671 if (force_off && !fast_forward)
674 fast_forward = !fast_forward;
676 normal_g_opts = g_opts;
677 normal_frameskip = pl_rearmed_cbs.frameskip;
678 normal_enhancement_enable =
679 pl_rearmed_cbs.gpu_neon.enhancement_enable;
681 g_opts |= OPT_NO_FRAMELIM;
682 pl_rearmed_cbs.frameskip = 3;
683 pl_rearmed_cbs.gpu_neon.enhancement_enable = 0;
685 g_opts = normal_g_opts;
686 pl_rearmed_cbs.frameskip = normal_frameskip;
687 pl_rearmed_cbs.gpu_neon.enhancement_enable =
688 normal_enhancement_enable;
690 pl_timing_prepare(Config.PsxType);
694 snprintf(hud_msg, sizeof(hud_msg), "FAST FORWARD %s",
695 fast_forward ? "ON" : "OFF");
698 static void SignalExit(int sig) {
699 // only to restore framebuffer/resolution on some devices
706 printf("SysRunGui\n");
709 static void dummy_lace()
714 // rearmed hack: EmuReset() runs some code when real BIOS is used,
715 // but we usually do reset from menu while GPU is not open yet,
716 // so we need to prevent updateLace() call..
717 void *real_lace = GPU_updateLace;
718 GPU_updateLace = dummy_lace;
721 // reset can run code, timing must be set
722 pl_timing_prepare(Config.PsxType);
724 // hmh core forgets this
729 GPU_updateLace = real_lace;
739 if (emuLog != NULL && emuLog != stdout && emuLog != stderr) {
748 int get_state_filename(char *buf, int size, int i) {
749 return get_gameid_filename(buf, size,
750 "." STATES_DIR "%.32s-%.9s.%3.3d", i);
753 int emu_check_state(int slot)
755 char fname[MAXPATHLEN];
758 ret = get_state_filename(fname, sizeof(fname), slot);
762 return CheckState(fname);
765 int emu_save_state(int slot)
767 char fname[MAXPATHLEN];
770 ret = get_state_filename(fname, sizeof(fname), slot);
774 ret = SaveState(fname);
775 #if defined(HAVE_PRE_ARMV7) && !defined(_3DS) /* XXX GPH hack */
778 SysPrintf("* %s \"%s\" [%d]\n",
779 ret == 0 ? "saved" : "failed to save", fname, slot);
783 int emu_load_state(int slot)
785 char fname[MAXPATHLEN];
790 ret = get_state_filename(fname, sizeof(fname), slot);
794 return LoadState(fname);
799 void SysPrintf(const char *fmt, ...) {
803 vfprintf(emuLog, fmt, list);
810 #include <android/log.h>
812 void SysPrintf(const char *fmt, ...) {
816 __android_log_vprint(ANDROID_LOG_INFO, "PCSX", fmt, list);
822 void SysMessage(const char *fmt, ...) {
828 ret = vsnprintf(msg, sizeof(msg), fmt, list);
831 if (ret < sizeof(msg) && msg[ret - 1] == '\n')
834 SysPrintf("%s\n", msg);
837 #define PARSEPATH(dst, src) \
838 ptr = src + strlen(src); \
839 while (*ptr != '\\' && ptr != src) ptr--; \
841 strcpy(dst, ptr+1); \
844 static int _OpenPlugins(void) {
848 signal(SIGINT, SignalExit);
849 signal(SIGPIPE, SignalExit);
852 GPU_clearDynarec(clearDynarec);
855 if (ret < 0) { SysMessage(_("Error opening CD-ROM plugin!")); return -1; }
857 if (ret < 0) { SysMessage(_("Error opening SPU plugin!")); return -1; }
858 SPU_registerCallback(SPUirq);
859 SPU_registerScheduleCb(SPUschedule);
860 // pcsx-rearmed: we handle gpu elsewhere
861 //ret = GPU_open(&gpuDisp, "PCSX", NULL);
862 //if (ret < 0) { SysMessage(_("Error opening GPU plugin!")); return -1; }
863 ret = PAD1_open(&gpuDisp);
864 if (ret < 0) { SysMessage(_("Error opening Controller 1 plugin!")); return -1; }
865 ret = PAD2_open(&gpuDisp);
866 if (ret < 0) { SysMessage(_("Error opening Controller 2 plugin!")); return -1; }
868 if (Config.UseNet && !NetOpened) {
870 char path[MAXPATHLEN];
871 char dotdir[MAXPATHLEN];
873 MAKE_PATH(dotdir, "/.pcsx/plugins/", NULL);
875 strcpy(info.EmuName, "PCSX");
876 strncpy(info.CdromID, CdromId, 9);
877 strncpy(info.CdromLabel, CdromLabel, 9);
879 info.GPU_showScreenPic = GPU_showScreenPic;
880 info.GPU_displayText = GPU_displayText;
881 info.GPU_showScreenPic = GPU_showScreenPic;
882 info.PAD_setSensitive = PAD1_setSensitive;
883 sprintf(path, "%s%s", Config.BiosDir, Config.Bios);
884 strcpy(info.BIOSpath, path);
885 strcpy(info.MCD1path, Config.Mcd1);
886 strcpy(info.MCD2path, Config.Mcd2);
887 sprintf(path, "%s%s", dotdir, Config.Gpu);
888 strcpy(info.GPUpath, path);
889 sprintf(path, "%s%s", dotdir, Config.Spu);
890 strcpy(info.SPUpath, path);
891 sprintf(path, "%s%s", dotdir, Config.Cdr);
892 strcpy(info.CDRpath, path);
895 ret = NET_open(&gpuDisp);
898 // -2 is returned when something in the info
899 // changed and needs to be synced
902 PARSEPATH(Config.Bios, info.BIOSpath);
903 PARSEPATH(Config.Gpu, info.GPUpath);
904 PARSEPATH(Config.Spu, info.SPUpath);
905 PARSEPATH(Config.Cdr, info.CDRpath);
907 strcpy(Config.Mcd1, info.MCD1path);
908 strcpy(Config.Mcd2, info.MCD2path);
911 Config.UseNet = FALSE;
914 if (NET_queryPlayer() == 1) {
915 if (SendPcsxInfo() == -1) Config.UseNet = FALSE;
917 if (RecvPcsxInfo() == -1) Config.UseNet = FALSE;
921 } else if (Config.UseNet) {
931 while ((ret = _OpenPlugins()) == -2) {
933 LoadMcds(Config.Mcd1, Config.Mcd2);
934 if (LoadPlugins() == -1) return -1;
939 void ClosePlugins() {
943 signal(SIGINT, SIG_DFL);
944 signal(SIGPIPE, SIG_DFL);
948 if (ret < 0) { SysMessage(_("Error closing CD-ROM plugin!")); return; }
950 if (ret < 0) { SysMessage(_("Error closing SPU plugin!")); return; }
952 if (ret < 0) { SysMessage(_("Error closing Controller 1 Plugin!")); return; }
954 if (ret < 0) { SysMessage(_("Error closing Controller 2 plugin!")); return; }
955 // pcsx-rearmed: we handle gpu elsewhere
957 //if (ret < 0) { SysMessage(_("Error closing GPU plugin!")); return; }
964 /* we hook statically linked plugins here */
965 static const char *builtin_plugins[] = {
966 "builtin_gpu", "builtin_spu", "builtin_cdr", "builtin_pad",
970 static const int builtin_plugin_ids[] = {
971 PLUGIN_GPU, PLUGIN_SPU, PLUGIN_CDR, PLUGIN_PAD,
975 void *SysLoadLibrary(const char *lib) {
976 const char *tmp = strrchr(lib, '/');
980 SysPrintf("plugin: %s\n", lib);
984 for (i = 0; i < ARRAY_SIZE(builtin_plugins); i++)
985 if (strcmp(tmp, builtin_plugins[i]) == 0)
986 return (void *)(long)(PLUGIN_DL_BASE + builtin_plugin_ids[i]);
989 #if !defined(_WIN32) && !defined(NO_DYLIB)
990 ret = dlopen(lib, RTLD_NOW);
992 SysMessage("dlopen: %s", dlerror());
994 /* no external plugin support, abi is no longer
995 * compatible with psemu/pcsx anyway */
1000 void *SysLoadSym(void *lib, const char *sym) {
1001 unsigned int plugid = (unsigned int)(long)lib;
1003 if (PLUGIN_DL_BASE <= plugid && plugid < PLUGIN_DL_BASE + ARRAY_SIZE(builtin_plugins))
1004 return plugin_link(plugid - PLUGIN_DL_BASE, sym);
1006 #if !defined(_WIN32) && !defined(NO_DYLIB)
1007 return dlsym(lib, sym);
1013 const char *SysLibError() {
1014 #if defined(NO_DYLIB)
1016 #elif !defined(_WIN32)
1019 return "not supported";
1023 void SysCloseLibrary(void *lib) {
1024 unsigned int plugid = (unsigned int)(long)lib;
1026 if (PLUGIN_DL_BASE <= plugid && plugid < PLUGIN_DL_BASE + ARRAY_SIZE(builtin_plugins))
1029 #if !defined(_WIN32) && !defined(NO_DYLIB)