frontend cleanup
authornotaz <notasas@gmail.com>
Mon, 3 Jan 2011 16:40:50 +0000 (18:40 +0200)
committernotaz <notasas@gmail.com>
Mon, 3 Jan 2011 16:40:50 +0000 (18:40 +0200)
Makefile
frontend/main.c
frontend/main.h [moved from gui/Linux.h with 62% similarity]
frontend/menu.c
frontend/plat_dummy.c
frontend/plugin.c
gui/Plugin.c [deleted file]

index 2602abb..28a0c79 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,9 +3,11 @@ AS = $(CROSS_COMPILE)as
 CC = $(CROSS_COMPILE)gcc
 LD = $(CROSS_COMPILE)ld
 
+ARCH = $(shell $(CC) -v 2>&1 | grep -i 'target:' | awk '{print $$2}' | awk -F '-' '{print $$1}')
+
 CFLAGS += -ggdb -Ifrontend
 LDFLAGS += -lz -lpthread -ldl -lpng
-ifdef CROSS_COMPILE
+ifeq "$(ARCH)" "arm"
 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfloat-abi=softfp -ffast-math
 ASFLAGS += -mcpu=cortex-a8 -mfpu=neon
 endif
@@ -55,14 +57,12 @@ plugins/cdrcimg/%.o: CFLAGS += -Wall
 OBJS += plugins/cdrcimg/cdrcimg.o
 
 # gui
-OBJS += gui/Plugin.o
-
 OBJS += frontend/main.o frontend/plugin.o frontend/plugin_lib.o
 OBJS += frontend/menu.o
 OBJS += frontend/linux/fbdev.o frontend/linux/in_evdev.o
 OBJS += frontend/linux/plat.o frontend/linux/oshide.o
 OBJS += frontend/common/fonts.o frontend/common/input.o frontend/common/readpng.o
-ifdef CROSS_COMPILE
+ifeq "$(ARCH)" "arm"
 OBJS += frontend/arm_utils.o
 OBJS += frontend/plat_omap.o
 else
index 0427ce4..7b45983 100644 (file)
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <signal.h>
 
+#include "main.h"
 #include "plugin.h"
 #include "pcnt.h"
 #include "menu.h"
-#include "../gui/Linux.h"
 #include "../libpcsxcore/misc.h"
 #include "../plugins/cdrcimg/cdrcimg.h"
 #include "common/plat.h"
 #include "common/input.h"
 
 int ready_to_go;
-int UseGui;
+unsigned long gpuDisp;
+char cfgfile_basename[MAXPATHLEN];
 static char *(*real_getenv)(const char *name);
 
 static void make_path(char *buf, size_t size, const char *dir, const char *fname)
@@ -228,11 +230,11 @@ int main(int argc, char *argv[])
 
        // If a state has been specified, then load that
        if (loadst) {
-               StatesC = loadst - 1;
-               char *state_filename = get_state_filename(StatesC);
-               int ret = LoadState(state_filename);
+               char state_filename[MAXPATHLEN];
+               int ret = get_state_filename(state_filename, sizeof(state_filename), loadst - 1);
+               if (ret == 0)
+                       ret = LoadState(state_filename);
                printf("%s state %s\n", ret ? "failed to load" : "loaded", state_filename);
-               free(state_filename);
        }
 
        if (ready_to_go)
@@ -289,11 +291,6 @@ void SysClose() {
 }
 
 void SysUpdate() {
-       PADhandleKey(PAD1_keypressed());
-       PADhandleKey(PAD2_keypressed());
-}
-
-void UpdateMenuSlots() {
 }
 
 void OnFile_Exit() {
@@ -304,57 +301,7 @@ void OnFile_Exit() {
        exit(0);
 }
 
-void state_save(gchar *state_filename) {
-        char Text[MAXPATHLEN + 20];
-
-        GPU_updateLace();
-
-        if (SaveState(state_filename) == 0)
-                sprintf(Text, _("Saved state %s."), state_filename);
-        else
-                sprintf(Text, _("Error saving state %s!"), state_filename);
-
-        GPU_displayText(Text);
-}
-
-void state_load(gchar *state_filename) {
-       int ret;
-       char Text[MAXPATHLEN + 20];
-       FILE *fp;
-
-       // check if the state file actually exists
-       fp = fopen(state_filename, "rb");
-       if (fp == NULL) {
-               // file does not exist
-               return;
-       }
-
-       fclose(fp);
-
-       ret = CheckState(state_filename);
-
-       if (ret == 0) {
-               SysReset();
-               ret = LoadState(state_filename);
-       }
-
-       if (ret == 0) {
-               // Check the CD-ROM is valid
-               if (CheckCdrom() == -1) {
-                       ClosePlugins();
-                       SysRunGui();
-                       return;
-               }
-
-               sprintf(Text, _("Loaded state %s."), state_filename);
-       } else {
-               sprintf(Text, _("Error loading state %s!"), state_filename);
-       }
-       GPU_displayText(Text);
-}
-
-char *get_state_filename(int i) {
-       char SStateFile[256];
+int get_state_filename(char *buf, int size, int i) {
        char trimlabel[33];
        int j;
 
@@ -366,10 +313,10 @@ char *get_state_filename(int i) {
                else
                        continue;
 
-       snprintf(SStateFile, sizeof(SStateFile), "." STATES_DIR "%.32s-%.9s.%3.3d",
+       snprintf(buf, size, "." STATES_DIR "%.32s-%.9s.%3.3d",
                trimlabel, CdromId, i);
 
-       return strdup(SStateFile);
+       return 0;
 }
 
 void SysPrintf(const char *fmt, ...) {
@@ -397,6 +344,132 @@ void SysMessage(const char *fmt, ...) {
        fprintf(stderr, "%s\n", msg);
 }
 
+static void SignalExit(int sig) {
+       ClosePlugins();
+       OnFile_Exit();
+}
+
+#define PARSEPATH(dst, src) \
+       ptr = src + strlen(src); \
+       while (*ptr != '\\' && ptr != src) ptr--; \
+       if (ptr != src) { \
+               strcpy(dst, ptr+1); \
+       }
+
+static int _OpenPlugins(void) {
+       int ret;
+
+       signal(SIGINT, SignalExit);
+       signal(SIGPIPE, SignalExit);
+
+       GPU_clearDynarec(clearDynarec);
+
+       ret = CDR_open();
+       if (ret < 0) { SysMessage(_("Error opening CD-ROM plugin!")); return -1; }
+       ret = SPU_open();
+       if (ret < 0) { SysMessage(_("Error opening SPU plugin!")); return -1; }
+       SPU_registerCallback(SPUirq);
+       // pcsx-rearmed: we handle gpu elsewhere
+       //ret = GPU_open(&gpuDisp, "PCSX", NULL);
+       //if (ret < 0) { SysMessage(_("Error opening GPU plugin!")); return -1; }
+       ret = PAD1_open(&gpuDisp);
+       if (ret < 0) { SysMessage(_("Error opening Controller 1 plugin!")); return -1; }
+       ret = PAD2_open(&gpuDisp);
+       if (ret < 0) { SysMessage(_("Error opening Controller 2 plugin!")); return -1; }
+
+       if (Config.UseNet && !NetOpened) {
+               netInfo info;
+               char path[MAXPATHLEN];
+               char dotdir[MAXPATHLEN];
+
+               MAKE_PATH(dotdir, "/.pcsx/plugins/", NULL);
+
+               strcpy(info.EmuName, "PCSX " PACKAGE_VERSION);
+               strncpy(info.CdromID, CdromId, 9);
+               strncpy(info.CdromLabel, CdromLabel, 9);
+               info.psxMem = psxM;
+               info.GPU_showScreenPic = GPU_showScreenPic;
+               info.GPU_displayText = GPU_displayText;
+               info.GPU_showScreenPic = GPU_showScreenPic;
+               info.PAD_setSensitive = PAD1_setSensitive;
+               sprintf(path, "%s%s", Config.BiosDir, Config.Bios);
+               strcpy(info.BIOSpath, path);
+               strcpy(info.MCD1path, Config.Mcd1);
+               strcpy(info.MCD2path, Config.Mcd2);
+               sprintf(path, "%s%s", dotdir, Config.Gpu);
+               strcpy(info.GPUpath, path);
+               sprintf(path, "%s%s", dotdir, Config.Spu);
+               strcpy(info.SPUpath, path);
+               sprintf(path, "%s%s", dotdir, Config.Cdr);
+               strcpy(info.CDRpath, path);
+               NET_setInfo(&info);
+
+               ret = NET_open(&gpuDisp);
+               if (ret < 0) {
+                       if (ret == -2) {
+                               // -2 is returned when something in the info
+                               // changed and needs to be synced
+                               char *ptr;
+
+                               PARSEPATH(Config.Bios, info.BIOSpath);
+                               PARSEPATH(Config.Gpu,  info.GPUpath);
+                               PARSEPATH(Config.Spu,  info.SPUpath);
+                               PARSEPATH(Config.Cdr,  info.CDRpath);
+
+                               strcpy(Config.Mcd1, info.MCD1path);
+                               strcpy(Config.Mcd2, info.MCD2path);
+                               return -2;
+                       } else {
+                               Config.UseNet = FALSE;
+                       }
+               } else {
+                       if (NET_queryPlayer() == 1) {
+                               if (SendPcsxInfo() == -1) Config.UseNet = FALSE;
+                       } else {
+                               if (RecvPcsxInfo() == -1) Config.UseNet = FALSE;
+                       }
+               }
+               NetOpened = TRUE;
+       } else if (Config.UseNet) {
+               NET_resume();
+       }
+
+       return 0;
+}
+
+int OpenPlugins() {
+       int ret;
+
+       while ((ret = _OpenPlugins()) == -2) {
+               ReleasePlugins();
+               LoadMcds(Config.Mcd1, Config.Mcd2);
+               if (LoadPlugins() == -1) return -1;
+       }
+       return ret;
+}
+
+void ClosePlugins() {
+       int ret;
+
+       signal(SIGINT, SIG_DFL);
+       signal(SIGPIPE, SIG_DFL);
+       ret = CDR_close();
+       if (ret < 0) { SysMessage(_("Error closing CD-ROM plugin!")); return; }
+       ret = SPU_close();
+       if (ret < 0) { SysMessage(_("Error closing SPU plugin!")); return; }
+       ret = PAD1_close();
+       if (ret < 0) { SysMessage(_("Error closing Controller 1 Plugin!")); return; }
+       ret = PAD2_close();
+       if (ret < 0) { SysMessage(_("Error closing Controller 2 plugin!")); return; }
+       // pcsx-rearmed: we handle gpu elsewhere
+       //ret = GPU_close();
+       //if (ret < 0) { SysMessage(_("Error closing GPU plugin!")); return; }
+
+       if (Config.UseNet) {
+               NET_pause();
+       }
+}
+
 #if 1
 /* this is to avoid having to hack every plugin to stop using $HOME */
 char *getenv(const char *name)
@@ -471,4 +544,3 @@ void SysCloseLibrary(void *lib) {
        dlclose(lib);
 }
 
-
similarity index 62%
rename from gui/Linux.h
rename to frontend/main.h
index 6f0e0c0..020b675 100644 (file)
 
 #include "config.h"
 
-#include "../libpcsxcore/psxcommon.h"
-#include <gtk/gtk.h>
-
-#include "Cheat.h"
-
 #define DEFAULT_MEM_CARD_1 "/.pcsx/memcards/card1.mcd"
 #define DEFAULT_MEM_CARD_2 "/.pcsx/memcards/card2.mcd"
 #define MEMCARD_DIR "/.pcsx/memcards/"
 #define CHEATS_DIR "/.pcsx/cheats/"
 #define PATCHES_DIR "/.pcsx/patches/"
 
-extern gboolean UseGui;
-extern int StatesC;
-char cfgfile[MAXPATHLEN];      /* ADB Comment this out - make a local var, or at least use gchar funcs */
-char cfgfile_basename[MAXPATHLEN];     /* ADB Comment this out - make a local var, or at least use gchar funcs */
-
-int LoadConfig();
-void SaveConfig();
-
-void StartGui();
-
-void PADhandleKey(int key);
-
-void UpdateMenuSlots();
-
-gchar* get_state_filename(int i);
-
-void state_save(gchar *state_filename);
-void state_load(gchar *state_filename);
-
-int match(const char* string, char* pattern);
-int plugins_configured();
+extern char cfgfile_basename[MAXPATHLEN];
 
-void UpdatePluginsBIOS();
+int get_state_filename(char *buf, int size, int i);
 
-void SysErrorMessage(gchar *primary, gchar *secondary);
-void SysInfoMessage(gchar *primary, gchar *secondary);
+extern unsigned long gpuDisp;
+extern int ready_to_go;
 
 #endif /* __LINUX_H__ */
index 19ad86f..e04d19e 100644 (file)
 #include <errno.h>
 #include <dlfcn.h>
 
+#include "main.h"
 #include "menu.h"
 #include "config.h"
 #include "plugin.h"
 #include "plugin_lib.h"
 #include "omap.h"
 #include "common/plat.h"
-#include "../gui/Linux.h"
 #include "../libpcsxcore/misc.h"
 #include "../libpcsxcore/new_dynarec/new_dynarec.h"
 #include "revision.h"
@@ -57,7 +57,6 @@ enum {
        SCALE_CUSTOM,
 };
 
-extern int ready_to_go;
 static int last_psx_w, last_psx_h, last_psx_bpp;
 static int scaling, filter, state_slot, cpu_clock, cpu_clock_st;
 static char rom_fname_reload[MAXPATHLEN];
@@ -101,32 +100,30 @@ void emu_make_path(char *buff, const char *end, int size)
 
 static int emu_check_save_file(int slot)
 {
-       char *fname;
+       char fname[MAXPATHLEN];
        int ret;
 
-       fname = get_state_filename(slot);
-       if (fname == NULL)
+       ret = get_state_filename(fname, sizeof(fname), slot);
+       if (ret != 0)
                return 0;
 
        ret = CheckState(fname);
-       free(fname);
        return ret == 0 ? 1 : 0;
 }
 
 static int emu_save_load_game(int load, int sram)
 {
-       char *fname;
+       char fname[MAXPATHLEN];
        int ret;
 
-       fname = get_state_filename(state_slot);
-       if (fname == NULL)
+       ret = get_state_filename(fname, sizeof(fname), state_slot);
+       if (ret != 0)
                return 0;
 
        if (load)
                ret = LoadState(fname);
        else
                ret = SaveState(fname);
-       free(fname);
 
        return ret;
 }
@@ -1225,7 +1222,6 @@ void menu_prepare_emu(void)
        }
 
        if (GPU_open != NULL) {
-               extern unsigned long gpuDisp;
                int ret = GPU_open(&gpuDisp, "PCSX", NULL);
                if (ret)
                        fprintf(stderr, "Warning: GPU_open returned %d\n", ret);
index 0b4f100..a34f900 100644 (file)
@@ -19,6 +19,10 @@ int omap_enable_layer(int enabled)
        return 0;
 }
 
+void plat_video_menu_enter(int is_rom_loaded)
+{
+}
+
 void plat_video_menu_begin(void)
 {
 }
@@ -27,6 +31,10 @@ void plat_video_menu_end(void)
 {
 }
 
+void plat_video_menu_leave(void)
+{
+}
+
 void plat_init(void)
 {
 }
index 6c83a44..c11a1f0 100644 (file)
@@ -68,17 +68,7 @@ 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) \
@@ -87,6 +77,7 @@ extern void GPUvBlank(int);
 #define DIRECT(id, name) \
        { id, #name, name }
 
+#define DUMMY_GPU(name)  DUMMY(PLUGIN_GPU, 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)
@@ -159,9 +150,6 @@ static const struct {
        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),
@@ -171,12 +159,18 @@ static const struct {
        DIRECT_GPU(GPUwriteData),
        DIRECT_GPU(GPUwriteDataMem),
        DIRECT_GPU(GPUdmaChain),
+       DIRECT_GPU(GPUfreeze),
+
+       DUMMY_GPU(GPUdisplayText),
+/*
        DIRECT_GPU(GPUkeypressed),
-       DIRECT_GPU(GPUdisplayText),
        DIRECT_GPU(GPUmakeSnapshot),
-       DIRECT_GPU(GPUfreeze),
+       DIRECT_GPU(GPUconfigure),
+       DIRECT_GPU(GPUtest),
+       DIRECT_GPU(GPUabout),
        DIRECT_GPU(GPUgetScreenPic),
        DIRECT_GPU(GPUshowScreenPic),
+*/
 //     DIRECT_GPU(GPUclearDynarec),
 //     DIRECT_GPU(GPUvBlank),
 };
diff --git a/gui/Plugin.c b/gui/Plugin.c
deleted file mode 100644 (file)
index 7218416..0000000
+++ /dev/null
@@ -1,392 +0,0 @@
-/*  Pcsx - Pc Psx Emulator
- *  Copyright (C) 1999-2002  Pcsx Team
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <dlfcn.h>
-#include <X11/keysym.h>
-#include <signal.h>
-
-#include "Linux.h"
-
-#include "../libpcsxcore/plugins.h"
-#include "../libpcsxcore/spu.h"
-#include "../libpcsxcore/cdriso.h"
-
-#include "nopic.h"
-
-#define MAX_SLOTS 5    /* ADB TODO Same as Gtk2Gui.c */
-
-void OnFile_Exit();
-
-unsigned long gpuDisp;
-
-int StatesC = 0;
-extern int UseGui;
-int ShowPic = 0;
-
-void gpuShowPic() {
-       gchar *state_filename;
-       gzFile f;
-
-       if (!ShowPic) {
-               unsigned char *pMem;
-
-               pMem = (unsigned char *) malloc(128*96*3);
-               if (pMem == NULL) return;
-
-               state_filename = get_state_filename (StatesC);
-
-               GPU_freeze(2, (GPUFreeze_t *)&StatesC);
-
-               f = gzopen(state_filename, "rb");
-               if (f != NULL) {
-                       gzseek(f, 32, SEEK_SET); // skip header
-                       gzread(f, pMem, 128*96*3);
-                       gzclose(f);
-               } else {
-                       memcpy(pMem, NoPic_Image.pixel_data, 128*96*3);
-                       DrawNumBorPic(pMem, StatesC+1);
-               }
-               GPU_showScreenPic(pMem);
-
-               free(pMem);
-               ShowPic = 1;
-               g_free (state_filename);
-       } else {
-               GPU_showScreenPic(NULL);
-               ShowPic = 0;
-       }
-}
-
-void KeyStateSave(int i) {
-       gchar *state_filename;
-
-       state_filename = get_state_filename (i);
-       state_save (state_filename);
-
-       g_free (state_filename);
-}
-
-void KeyStateLoad(int i) {
-       gchar *state_filename;
-
-       state_filename = get_state_filename (i);
-       state_load (state_filename);
-
-       g_free (state_filename);
-
-       // HACKHACK: prevent crash when using recompiler due to execution not
-       // returned from compiled code. This WILL cause memory leak, however a
-       // large amount of refactor is needed for a proper fix.
-       if (Config.Cpu == CPU_DYNAREC) psxCpu->Execute();
-}
-
-static short modctrl = 0, modalt = 0;
-
-/* Handle keyboard keystrokes */
-void PADhandleKey(int key) {
-       char Text[MAXPATHLEN];
-       gchar *state_filename;
-
-       short rel = 0;  //released key flag
-
-       if (key == 0)
-               return;
-
-       if ((key >> 30) & 1)    //specific to dfinput (padJoy)
-               rel = 1;
-
-       if (rel) {
-               switch (key & ~0x40000000) {
-               case XK_Alt_L:
-               case XK_Alt_R:
-                       modalt=0;
-                       break;
-               case XK_Control_L:
-               case XK_Control_R:
-                       modctrl=0;
-                       break;
-               }
-               return;
-       }
-
-       switch (key) {
-               case XK_Alt_L:
-               case XK_Alt_R:
-                       modalt=1;
-                       break;
-               case XK_Control_L:
-               case XK_Control_R:
-                       modctrl=1;
-                       break;
-
-               case XK_0:
-                       if (modalt && modctrl)
-                               return;
-                       if (modalt) KeyStateLoad(10);
-                       break;
-
-               case XK_1:
-                       if (modalt && modctrl)
-                               return;
-                       if (modalt) KeyStateLoad(0);
-                       if (modctrl) KeyStateSave(0);
-                       break;
-               case XK_2:
-                       if (modalt && modctrl)
-                               return;
-                       if (modalt) KeyStateLoad(1);
-                       if (modctrl) KeyStateSave(1);
-                       break;
-               case XK_3:
-                       if (modalt && modctrl)
-                               return;
-                       if (modalt) KeyStateLoad(2);
-                       if (modctrl) KeyStateSave(2);
-                       break;
-               case XK_4:
-                       if (modalt && modctrl)
-                               return;
-                       if (modalt) KeyStateLoad(3);
-                       if (modctrl) KeyStateSave(3);
-                       break;
-               case XK_5:
-                       if (modalt && modctrl)
-                               return;
-                       if (modalt) KeyStateLoad(4);
-                       if (modctrl) KeyStateSave(4);
-                       break;
-
-               case XK_F1:
-                       GPU_freeze(2, (GPUFreeze_t *)&StatesC);
-                       state_filename = get_state_filename (StatesC);
-                       state_save (state_filename);
-
-                       g_free (state_filename);
-
-                       if (ShowPic) { ShowPic = 0; gpuShowPic(); }
-
-                       break;
-               case XK_F2:
-                       if (StatesC < (MAX_SLOTS - 1)) StatesC++;
-                       else StatesC = 0;
-                       GPU_freeze(2, (GPUFreeze_t *)&StatesC);
-                       if (ShowPic) { ShowPic = 0; gpuShowPic(); }
-                       break;
-               case XK_F3:
-                       state_filename = get_state_filename (StatesC);
-                       state_load (state_filename);
-
-                       g_free (state_filename);
-
-                       // HACKHACK: prevent crash when using recompiler due to execution not
-                       // returned from compiled code. This WILL cause memory leak, however a
-                       // large amount of refactor is needed for a proper fix.
-                       if (Config.Cpu == CPU_DYNAREC) psxCpu->Execute();
-
-                       break;
-               case XK_F4:
-                       gpuShowPic();
-                       break;
-               case XK_F5:
-                       Config.Sio ^= 0x1;
-                       if (Config.Sio)
-                               sprintf(Text, _("SIO IRQ Always Enabled"));
-                       else sprintf(Text, _("SIO IRQ Not Always Enabled"));
-                       GPU_displayText(Text);
-                       break;
-               case XK_F6:
-                       Config.Mdec ^= 0x1;
-                       if (Config.Mdec)
-                               sprintf(Text, _("Black & White Mdecs Only Enabled"));
-                       else sprintf(Text, _("Black & White Mdecs Only Disabled"));
-                       GPU_displayText(Text);
-                       break;
-               case XK_F7:
-                       Config.Xa ^= 0x1;
-                       if (Config.Xa == 0)
-                               sprintf (Text, _("XA Enabled"));
-                       else sprintf (Text, _("XA Disabled"));
-                       GPU_displayText(Text);
-                       break;
-               case XK_F8:
-                       GPU_makeSnapshot();
-                       break;
-               case XK_F9:
-                       SetCdOpenCaseTime(-1);
-                       break;
-               case XK_F10:
-                       SetCdOpenCaseTime(0);
-                       break;
-               case XK_Escape:
-                       // TODO
-                       // the architecture is too broken to actually restart the GUI
-                       // because SysUpdate is called from deep within the actual
-                       // execution of the emulation code
-                       // Fixing this would probably require a complete reworking of
-                       // all functions, so that they return 0 or 1 for success
-                       // that way, execution wouldn't continue
-                       if (CdromId[0] != '\0')
-                               KeyStateSave(10);
-                       ClosePlugins();
-                       UpdateMenuSlots();
-                       if (!UseGui) OnFile_Exit();
-                       StartGui();
-                       break;
-               case XK_Return:         //0xff0d
-                       if (modalt)     //alt-return
-                               //I just made this up: a special sym for fullscreen because the current interface can't handle key mods
-                               //though it can be used in the future as a convention...eg bit 29 for alt, bit 28 for cntl, etc.
-                               GPU_keypressed( (1<<29) | 0xFF0D );
-                       break;
-               default:
-                       GPU_keypressed(key);
-                       if (Config.UseNet) NET_keypressed(key);
-       }       
-}
-
-void OnFile_Exit();
-
-void SignalExit(int sig) {
-       ClosePlugins();
-       OnFile_Exit();
-}
-
-#define PARSEPATH(dst, src) \
-       ptr = src + strlen(src); \
-       while (*ptr != '\\' && ptr != src) ptr--; \
-       if (ptr != src) { \
-               strcpy(dst, ptr+1); \
-       }
-
-int _OpenPlugins() {
-       int ret;
-
-       signal(SIGINT, SignalExit);
-       signal(SIGPIPE, SignalExit);
-
-       GPU_clearDynarec(clearDynarec);
-
-       ret = CDR_open();
-       if (ret < 0) { SysMessage(_("Error opening CD-ROM plugin!")); return -1; }
-       ret = SPU_open();
-       if (ret < 0) { SysMessage(_("Error opening SPU plugin!")); return -1; }
-       SPU_registerCallback(SPUirq);
-       // pcsx-rearmed: we handle gpu elsewhere
-       //ret = GPU_open(&gpuDisp, "PCSX", NULL);
-       //if (ret < 0) { SysMessage(_("Error opening GPU plugin!")); return -1; }
-       ret = PAD1_open(&gpuDisp);
-       if (ret < 0) { SysMessage(_("Error opening Controller 1 plugin!")); return -1; }
-       ret = PAD2_open(&gpuDisp);
-       if (ret < 0) { SysMessage(_("Error opening Controller 2 plugin!")); return -1; }
-
-       if (Config.UseNet && !NetOpened) {
-               netInfo info;
-               char path[MAXPATHLEN];
-               char dotdir[MAXPATHLEN];
-
-               strncpy(dotdir, getenv("HOME"), MAXPATHLEN-100);
-               strcat(dotdir, "/.pcsx/plugins/");
-
-               strcpy(info.EmuName, "PCSX " PACKAGE_VERSION);
-               strncpy(info.CdromID, CdromId, 9);
-               strncpy(info.CdromLabel, CdromLabel, 9);
-               info.psxMem = psxM;
-               info.GPU_showScreenPic = GPU_showScreenPic;
-               info.GPU_displayText = GPU_displayText;
-               info.GPU_showScreenPic = GPU_showScreenPic;
-               info.PAD_setSensitive = PAD1_setSensitive;
-               sprintf(path, "%s%s", Config.BiosDir, Config.Bios);
-               strcpy(info.BIOSpath, path);
-               strcpy(info.MCD1path, Config.Mcd1);
-               strcpy(info.MCD2path, Config.Mcd2);
-               sprintf(path, "%s%s", dotdir, Config.Gpu);
-               strcpy(info.GPUpath, path);
-               sprintf(path, "%s%s", dotdir, Config.Spu);
-               strcpy(info.SPUpath, path);
-               sprintf(path, "%s%s", dotdir, Config.Cdr);
-               strcpy(info.CDRpath, path);
-               NET_setInfo(&info);
-
-               ret = NET_open(&gpuDisp);
-               if (ret < 0) {
-                       if (ret == -2) {
-                               // -2 is returned when something in the info
-                               // changed and needs to be synced
-                               char *ptr;
-
-                               PARSEPATH(Config.Bios, info.BIOSpath);
-                               PARSEPATH(Config.Gpu,  info.GPUpath);
-                               PARSEPATH(Config.Spu,  info.SPUpath);
-                               PARSEPATH(Config.Cdr,  info.CDRpath);
-
-                               strcpy(Config.Mcd1, info.MCD1path);
-                               strcpy(Config.Mcd2, info.MCD2path);
-                               return -2;
-                       } else {
-                               Config.UseNet = FALSE;
-                       }
-               } else {
-                       if (NET_queryPlayer() == 1) {
-                               if (SendPcsxInfo() == -1) Config.UseNet = FALSE;
-                       } else {
-                               if (RecvPcsxInfo() == -1) Config.UseNet = FALSE;
-                       }
-               }
-               NetOpened = TRUE;
-       } else if (Config.UseNet) {
-               NET_resume();
-       }
-
-       return 0;
-}
-
-int OpenPlugins() {
-       int ret;
-
-       while ((ret = _OpenPlugins()) == -2) {
-               ReleasePlugins();
-               LoadMcds(Config.Mcd1, Config.Mcd2);
-               if (LoadPlugins() == -1) return -1;
-       }
-       return ret;
-}
-
-void ClosePlugins() {
-       int ret;
-
-       signal(SIGINT, SIG_DFL);
-       signal(SIGPIPE, SIG_DFL);
-       ret = CDR_close();
-       if (ret < 0) { SysMessage(_("Error closing CD-ROM plugin!")); return; }
-       ret = SPU_close();
-       if (ret < 0) { SysMessage(_("Error closing SPU plugin!")); return; }
-       ret = PAD1_close();
-       if (ret < 0) { SysMessage(_("Error closing Controller 1 Plugin!")); return; }
-       ret = PAD2_close();
-       if (ret < 0) { SysMessage(_("Error closing Controller 2 plugin!")); return; }
-       // pcsx-rearmed: we handle gpu elsewhere
-       //ret = GPU_close();
-       //if (ret < 0) { SysMessage(_("Error closing GPU plugin!")); return; }
-
-       if (Config.UseNet) {
-               NET_pause();
-       }
-}