aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'frontend')
-rw-r--r--frontend/config.h2
-rw-r--r--frontend/main.c86
-rw-r--r--frontend/nopic.h57
-rw-r--r--frontend/plugin.c201
-rw-r--r--frontend/plugin.h12
-rw-r--r--frontend/psemu_plugin_defs.h1
6 files changed, 339 insertions, 20 deletions
diff --git a/frontend/config.h b/frontend/config.h
index 84e40f6..b11f75d 100644
--- a/frontend/config.h
+++ b/frontend/config.h
@@ -5,4 +5,4 @@
#define PACKAGE_VERSION "1.9"
#define DEF_PLUGIN_DIR "."
#define EMU_LOG printf
-
+#define USEOSS
diff --git a/frontend/main.c b/frontend/main.c
index 28446d3..6ee0b2f 100644
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -1,3 +1,10 @@
+/*
+ * (C) notaz, 2010
+ *
+ * This work is licensed under the terms of the GNU GPLv2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
@@ -6,6 +13,7 @@
#include <sys/types.h>
#include <unistd.h>
+#include "plugin.h"
#include "../gui/Linux.h"
#include "../libpcsxcore/misc.h"
@@ -65,13 +73,13 @@ int main(int argc, char *argv[])
// it may be redefined by -cfg on the command line
strcpy(cfgfile_basename, "pcsx.cfg");
+ emuLog = stdout;
SetIsoFile(NULL);
Config.PsxOut = 1;
// read command line options
for (i = 1; i < argc; i++) {
- if (!strcmp(argv[i], "-nogui")) UseGui = FALSE;
- else if (!strcmp(argv[i], "-psxout")) Config.PsxOut = 1;
+ if (!strcmp(argv[i], "-psxout")) Config.PsxOut = 1;
else if (!strcmp(argv[i], "-load")) loadst = atol(argv[++i]);
else if (!strcmp(argv[i], "-cfg")) {
if (i+1 >= argc) break;
@@ -131,27 +139,22 @@ int main(int argc, char *argv[])
CheckSubDir();
// ScanAllPlugins();
+ strcpy(Config.Bios, "HLE");
+ strcpy(Config.BiosDir, "./");
+
+ strcpy(Config.PluginsDir, "plugins");
+ strcpy(Config.Gpu, "builtin_gpu");
+ strcpy(Config.Spu, "builtin_spu");
+ strcpy(Config.Cdr, "builtin_cdr");
+ strcpy(Config.Pad1, "builtin_pad");
+ strcpy(Config.Pad2, "builtin_pad");
+
// try to load config
// if the config file doesn't exist
if (LoadConfig() == -1) {
// Uh oh, no config file found, use some defaults
Config.PsxAuto = 1;
- snprintf(Config.BiosDir, sizeof(Config.BiosDir), "." BIOS_DIR);
- snprintf(Config.PluginsDir, sizeof(Config.PluginsDir), "." PLUGINS_DIR);
-
- // Update available plugins, but not GUI
- //UpdatePluginsBIOS();
-
- // Pick some defaults, if they're available
-/*
- set_default_plugin(GpuConfS.plist[0], Config.Gpu);
- set_default_plugin(SpuConfS.plist[0], Config.Spu);
- set_default_plugin(CdrConfS.plist[0], Config.Cdr);
- set_default_plugin(Pad1ConfS.plist[0], Config.Pad1);
- set_default_plugin(Pad2ConfS.plist[0], Config.Pad2);
- set_default_plugin(BiosConfS.plist[0], Config.Bios);
-*/
// create & load default memcards if they don't exist
CreateMemcard("card1.mcd", Config.Mcd1);
CreateMemcard("card2.mcd", Config.Mcd2);
@@ -213,8 +216,6 @@ int main(int argc, char *argv[])
}
int SysInit() {
- emuLog = stdout;
-
if (EmuInit() == -1) {
printf("PSX emulator couldn't be initialized.\n");
return -1;
@@ -369,11 +370,53 @@ void SysMessage(const char *fmt, ...) {
fprintf(stderr, "%s\n", msg);
}
+#if 1
+/* this is to avoid having to hack every plugin to stop using $HOME */
+char *getenv(const char *name)
+{
+ static char ret[8] = ".";
+
+ // HACK
+ if (name && strcmp(name, "DISPLAY") == 0)
+ return ":0";
+
+ if (name && strcmp(name, "HOME") != 0)
+ fprintf(stderr, "getenv called with %s\n", name);
+
+ return ret;
+}
+#endif
+
+/* we hook statically linked plugins here */
+static const char *builtin_plugins[] = {
+ "builtin_gpu", "builtin_spu", "builtin_cdr", "builtin_pad"
+};
+
+static const int builtin_plugin_ids[] = {
+ PLUGIN_GPU, PLUGIN_SPU, PLUGIN_CDR, PLUGIN_PAD,
+};
+
void *SysLoadLibrary(const char *lib) {
+ const char *tmp = strrchr(lib, '/');
+ int i;
+
+ printf("dlopen %s\n", lib);
+ if (tmp != NULL) {
+ tmp++;
+ for (i = 0; i < ARRAY_SIZE(builtin_plugins); i++)
+ if (strcmp(tmp, builtin_plugins[i]) == 0)
+ return (void *)(long)(PLUGIN_DL_BASE + builtin_plugin_ids[i]);
+ }
+
return dlopen(lib, RTLD_NOW);
}
void *SysLoadSym(void *lib, const char *sym) {
+ unsigned int plugid = (unsigned int)(long)lib;
+
+ if (PLUGIN_DL_BASE <= plugid && plugid < PLUGIN_DL_BASE + ARRAY_SIZE(builtin_plugins))
+ return plugin_link(plugid - PLUGIN_DL_BASE, sym);
+
return dlsym(lib, sym);
}
@@ -382,6 +425,11 @@ const char *SysLibError() {
}
void SysCloseLibrary(void *lib) {
+ unsigned int plugid = (unsigned int)(long)lib;
+
+ if (PLUGIN_DL_BASE <= plugid && plugid < PLUGIN_DL_BASE + ARRAY_SIZE(builtin_plugins))
+ return;
+
dlclose(lib);
}
diff --git a/frontend/nopic.h b/frontend/nopic.h
new file mode 100644
index 0000000..d664f80
--- /dev/null
+++ b/frontend/nopic.h
@@ -0,0 +1,57 @@
+/* these are just deps, to be removed */
+
+static const struct {
+ unsigned int width;
+ unsigned int height;
+ unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */
+ unsigned char pixel_data[128 * 96 * 3 + 1];
+} NoPic_Image = {
+ 128, 96, 3, ""
+};
+
+extern void PaintPicDot(unsigned char * p,unsigned char c);
+extern unsigned char cFont[10][120];
+
+void DrawNumBorPic(unsigned char *pMem, int lSelectedSlot)
+{
+ unsigned char *pf;
+ int x,y;
+ int c,v;
+
+ pf=pMem+(103*3); // offset to number rect
+
+ for(y=0;y<20;y++) // loop the number rect pixel
+ {
+ for(x=0;x<6;x++)
+ {
+ c=cFont[lSelectedSlot][x+y*6]; // get 4 char dot infos at once (number depends on selected slot)
+ v=(c&0xc0)>>6;
+ PaintPicDot(pf,(unsigned char)v);pf+=3; // paint the dots into the rect
+ v=(c&0x30)>>4;
+ PaintPicDot(pf,(unsigned char)v);pf+=3;
+ v=(c&0x0c)>>2;
+ PaintPicDot(pf,(unsigned char)v);pf+=3;
+ v=c&0x03;
+ PaintPicDot(pf,(unsigned char)v);pf+=3;
+ }
+ pf+=104*3; // next rect y line
+ }
+
+ pf=pMem; // ptr to first pos in 128x96 pic
+ for(x=0;x<128;x++) // loop top/bottom line
+ {
+ *(pf+(95*128*3))=0x00;*pf++=0x00;
+ *(pf+(95*128*3))=0x00;*pf++=0x00; // paint it red
+ *(pf+(95*128*3))=0xff;*pf++=0xff;
+ }
+ pf=pMem; // ptr to first pos
+ for(y=0;y<96;y++) // loop left/right line
+ {
+ *(pf+(127*3))=0x00;*pf++=0x00;
+ *(pf+(127*3))=0x00;*pf++=0x00; // paint it red
+ *(pf+(127*3))=0xff;*pf++=0xff;
+ pf+=127*3; // offset to next line
+ }
+}
+
+
diff --git a/frontend/plugin.c b/frontend/plugin.c
new file mode 100644
index 0000000..bea6eb5
--- /dev/null
+++ b/frontend/plugin.c
@@ -0,0 +1,201 @@
+/*
+ * (C) notaz, 2010
+ *
+ * This work is licensed under the terms of the GNU GPLv2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+
+#include "plugin.h"
+
+static int dummy_func() {
+ return 0;
+}
+
+static long CDRreadTrack(unsigned char *time) {
+ fprintf(stderr, "CDRreadTrack\n");
+ return -1;
+}
+
+/* SPU */
+extern long SPUopen(void);
+extern long SPUinit(void);
+extern long SPUshutdown(void);
+extern long SPUclose(void);
+extern void SPUplaySample(unsigned char);
+extern void SPUwriteRegister(unsigned long, unsigned short);
+extern unsigned short SPUreadRegister(unsigned long);
+extern void SPUwriteDMA(unsigned short);
+extern unsigned short SPUreadDMA(void);
+extern void SPUwriteDMAMem(unsigned short *, int);
+extern void SPUreadDMAMem(unsigned short *, int);
+extern void SPUplayADPCMchannel(void *);
+extern void SPUregisterCallback(void (*callback)(void));
+extern long SPUconfigure(void);
+extern long SPUtest(void);
+extern void SPUabout(void);
+extern long SPUfreeze(unsigned int, void *);
+extern void SPUasync(unsigned int);
+extern void SPUplayCDDAchannel(short *, int);
+
+/* PAD */
+static uint8_t CurByte;
+
+static unsigned char PADstartPoll(int pad) {
+ CurByte = 0;
+ return 0xFF;
+}
+
+static unsigned char PADpoll(unsigned char value) {
+ static uint8_t buf[] = {0x41, 0x5A, 0xFF, 0xFF, 0x80, 0x80, 0x80, 0x80};
+ if (CurByte >= 4)
+ return 0;
+ return buf[CurByte++];
+}
+
+/* GPU */
+extern long GPUopen(unsigned long *, char *, char *);
+extern long GPUinit(void);
+extern long GPUshutdown(void);
+extern long GPUclose(void);
+extern void GPUwriteStatus(uint32_t);
+extern void GPUwriteData(uint32_t);
+extern void GPUwriteDataMem(uint32_t *, int);
+extern uint32_t GPUreadStatus(void);
+extern uint32_t GPUreadData(void);
+extern void GPUreadDataMem(uint32_t *, int);
+extern long GPUdmaChain(uint32_t *,uint32_t);
+extern void GPUupdateLace(void);
+extern long GPUconfigure(void);
+extern long GPUtest(void);
+extern void GPUabout(void);
+extern void GPUmakeSnapshot(void);
+extern void GPUkeypressed(int);
+extern void GPUdisplayText(char *);
+extern long GPUfreeze(uint32_t, void *);
+extern long GPUgetScreenPic(unsigned char *);
+extern long GPUshowScreenPic(unsigned char *);
+extern void GPUclearDynarec(void (*callback)(void));
+extern void GPUvBlank(int);
+
+
+#define DUMMY(id, name) \
+ { id, #name, dummy_func }
+
+#define DIRECT(id, name) \
+ { id, #name, name }
+
+#define DUMMY_CDR(name) DUMMY(PLUGIN_CDR, name)
+#define DUMMY_PAD(name) DUMMY(PLUGIN_PAD, name)
+#define DIRECT_SPU(name) DIRECT(PLUGIN_SPU, name)
+#define DIRECT_GPU(name) DIRECT(PLUGIN_GPU, name)
+#define DIRECT_PAD(name) DIRECT(PLUGIN_PAD, name)
+
+static const struct {
+ int id;
+ const char *name;
+ void *func;
+} plugin_funcs[] = {
+ /* CDR */
+ DUMMY_CDR(CDRinit),
+ DUMMY_CDR(CDRshutdown),
+ DUMMY_CDR(CDRopen),
+ DUMMY_CDR(CDRclose),
+ DUMMY_CDR(CDRtest),
+ DUMMY_CDR(CDRgetTN),
+ DUMMY_CDR(CDRgetTD),
+ DUMMY_CDR(CDRreadTrack),
+ DUMMY_CDR(CDRgetBuffer),
+ DUMMY_CDR(CDRgetBufferSub),
+ DUMMY_CDR(CDRplay),
+ DUMMY_CDR(CDRstop),
+ DUMMY_CDR(CDRgetStatus),
+ DUMMY_CDR(CDRgetDriveLetter),
+ DUMMY_CDR(CDRconfigure),
+ DUMMY_CDR(CDRabout),
+ DUMMY_CDR(CDRsetfilename),
+ DUMMY_CDR(CDRreadCDDA),
+ DUMMY_CDR(CDRgetTE),
+ DIRECT(PLUGIN_CDR, CDRreadTrack),
+ /* SPU */
+ DIRECT_SPU(SPUconfigure),
+ DIRECT_SPU(SPUabout),
+ DIRECT_SPU(SPUinit),
+ DIRECT_SPU(SPUshutdown),
+ DIRECT_SPU(SPUtest),
+ DIRECT_SPU(SPUopen),
+ DIRECT_SPU(SPUclose),
+// DIRECT_SPU(SPUplaySample), // unused?
+ DIRECT_SPU(SPUwriteRegister),
+ DIRECT_SPU(SPUreadRegister),
+ DIRECT_SPU(SPUwriteDMA),
+ DIRECT_SPU(SPUreadDMA),
+ DIRECT_SPU(SPUwriteDMAMem),
+ DIRECT_SPU(SPUreadDMAMem),
+ DIRECT_SPU(SPUplayADPCMchannel),
+ DIRECT_SPU(SPUfreeze),
+ DIRECT_SPU(SPUregisterCallback),
+ DIRECT_SPU(SPUasync),
+ DIRECT_SPU(SPUplayCDDAchannel),
+ /* PAD */
+ DUMMY_PAD(PADconfigure),
+ DUMMY_PAD(PADabout),
+ DUMMY_PAD(PADinit),
+ DUMMY_PAD(PADshutdown),
+ DUMMY_PAD(PADtest),
+ DUMMY_PAD(PADopen),
+ DUMMY_PAD(PADclose),
+ DUMMY_PAD(PADquery),
+ DUMMY_PAD(PADreadPort1),
+ DUMMY_PAD(PADreadPort2),
+ DUMMY_PAD(PADkeypressed),
+ DUMMY_PAD(PADsetSensitive),
+ DIRECT_PAD(PADstartPoll),
+ DIRECT_PAD(PADpoll),
+ /* GPU */
+ DIRECT_GPU(GPUupdateLace),
+ DIRECT_GPU(GPUinit),
+ DIRECT_GPU(GPUshutdown),
+ DIRECT_GPU(GPUconfigure),
+ DIRECT_GPU(GPUtest),
+ DIRECT_GPU(GPUabout),
+ DIRECT_GPU(GPUopen),
+ DIRECT_GPU(GPUclose),
+ DIRECT_GPU(GPUreadStatus),
+ DIRECT_GPU(GPUreadData),
+ DIRECT_GPU(GPUreadDataMem),
+ DIRECT_GPU(GPUwriteStatus),
+ DIRECT_GPU(GPUwriteData),
+ DIRECT_GPU(GPUwriteDataMem),
+ DIRECT_GPU(GPUdmaChain),
+ DIRECT_GPU(GPUkeypressed),
+ DIRECT_GPU(GPUdisplayText),
+ DIRECT_GPU(GPUmakeSnapshot),
+ DIRECT_GPU(GPUfreeze),
+ DIRECT_GPU(GPUgetScreenPic),
+ DIRECT_GPU(GPUshowScreenPic),
+// DIRECT_GPU(GPUclearDynarec),
+// DIRECT_GPU(GPUvBlank),
+};
+
+void *plugin_link(enum builtint_plugins_e id, const char *sym)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(plugin_funcs); i++) {
+ if (id != plugin_funcs[i].id)
+ continue;
+
+ if (strcmp(sym, plugin_funcs[i].name) != 0)
+ continue;
+
+ return plugin_funcs[i].func;
+ }
+
+ fprintf(stderr, "plugin_link: missing symbol %d %s\n", id, sym);
+ return NULL;
+}
+
diff --git a/frontend/plugin.h b/frontend/plugin.h
new file mode 100644
index 0000000..48ab719
--- /dev/null
+++ b/frontend/plugin.h
@@ -0,0 +1,12 @@
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+
+#define PLUGIN_DL_BASE 0xfbad0000
+
+enum builtint_plugins_e {
+ PLUGIN_GPU,
+ PLUGIN_SPU,
+ PLUGIN_CDR,
+ PLUGIN_PAD,
+};
+
+void *plugin_link(enum builtint_plugins_e id, const char *sym);
diff --git a/frontend/psemu_plugin_defs.h b/frontend/psemu_plugin_defs.h
new file mode 100644
index 0000000..d4cc29a
--- /dev/null
+++ b/frontend/psemu_plugin_defs.h
@@ -0,0 +1 @@
+#include "../libpcsxcore/psemu_plugin_defs.h"