pcsxr-1.9.92
[pcsx_rearmed.git] / macosx / Plugin.c
CommitLineData
ef79bbde
P
1/* Pcsx - Pc Psx Emulator
2 * Copyright (C) 1999-2002 Pcsx Team
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19#import <CoreFoundation/CoreFoundation.h>
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <signal.h>
24
25#include "psxcommon.h"
26#include "plugins.h"
27#include "spu.h"
28
29void OnFile_Exit();
30
31unsigned long gpuDisp;
32
33long SPU__open(void) {
34 return SPU_open();
35}
36
37int StatesC = 0;
38extern int UseGui;
39int ShowPic=0;
40
41void gpuShowPic() {
42}
43
44void PADhandleKey(int key) {
45}
46
47long PAD1__open(void) {
48 return PAD1_open(&gpuDisp);
49}
50
51long PAD2__open(void) {
52 return PAD2_open(&gpuDisp);
53}
54
55void OnFile_Exit();
56
57void SignalExit(int sig) {
58 ClosePlugins();
59 OnFile_Exit();
60}
61
62void SPUirq(void);
63
64#define PARSEPATH(dst, src) \
65 ptr = src + strlen(src); \
66 while (*ptr != '\\' && ptr != src) ptr--; \
67 if (ptr != src) { \
68 strcpy(dst, ptr+1); \
69 }
70
71int _OpenPlugins() {
72 static char path[1024];
73 CFURLRef pathUrl;
74 int ret;
75
76 //signal(SIGINT, SignalExit);
77 //signal(SIGPIPE, SignalExit);
78
79 GPU_clearDynarec(clearDynarec);
80
81 pathUrl = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("gpuPeopsSoftX.cfg"), NULL, NULL);
82 if (pathUrl)
83 CFURLGetFileSystemRepresentation(pathUrl, true, path, 1024);
84
85 ret = CDR_open();
86 if (ret < 0) { SysMessage(_("Error Opening CDR Plugin")); return -1; }
87 ret = SPU_open();
88 if (ret < 0) { SysMessage(_("Error Opening SPU Plugin")); return -1; }
89 SPU_registerCallback(SPUirq);
90 ret = GPU_open(&gpuDisp, "PCSX", /*pathUrl ? path :*/ NULL);
91 if (ret < 0) { SysMessage(_("Error Opening GPU Plugin")); return -1; }
92 ret = PAD1_open(&gpuDisp);
93 if (ret < 0) { SysMessage(_("Error Opening PAD1 Plugin")); return -1; }
94 ret = PAD2_open(&gpuDisp);
95 if (ret < 0) { SysMessage(_("Error Opening PAD2 Plugin")); return -1; }
96
97 return 0;
98}
99
100int OpenPlugins() {
101 int ret;
102
103 while ((ret = _OpenPlugins()) == -2) {
104 ReleasePlugins();
105 LoadMcds(Config.Mcd1, Config.Mcd2);
106 if (LoadPlugins() == -1) return -1;
107 }
108 return ret;
109}
110
111void ClosePlugins() {
112 int ret;
113
114 //signal(SIGINT, SIG_DFL);
115 //signal(SIGPIPE, SIG_DFL);
116 ret = CDR_close();
117 if (ret < 0) { SysMessage(_("Error Closing CDR Plugin")); return; }
118 ret = SPU_close();
119 if (ret < 0) { SysMessage(_("Error Closing SPU Plugin")); return; }
120 ret = PAD1_close();
121 if (ret < 0) { SysMessage(_("Error Closing PAD1 Plugin")); return; }
122 ret = PAD2_close();
123 if (ret < 0) { SysMessage(_("Error Closing PAD2 Plugin")); return; }
124 ret = GPU_close();
125 if (ret < 0) { SysMessage(_("Error Closing GPU Plugin")); return; }
126}
127
128void ResetPlugins() {
129 int ret;
130
131 CDR_shutdown();
132 GPU_shutdown();
133 SPU_shutdown();
134 PAD1_shutdown();
135 PAD2_shutdown();
136
137 ret = CDR_init();
138 if (ret < 0) { SysMessage(_("CDRinit error: %d"), ret); return; }
139 ret = GPU_init();
140 if (ret < 0) { SysMessage(_("GPUinit error: %d"), ret); return; }
141 ret = SPU_init();
142 if (ret < 0) { SysMessage(_("SPUinit error: %d"), ret); return; }
143 ret = PAD1_init(1);
144 if (ret < 0) { SysMessage(_("PAD1init error: %d"), ret); return; }
145 ret = PAD2_init(2);
146 if (ret < 0) { SysMessage(_("PAD2init error: %d"), ret); return; }
147
148 NetOpened = FALSE;
149}
150