summarylogtreecommitdiffstats
path: root/libmikmod-3.2.0-PSP.patch
blob: d1a2d8c457443a503a813bf39775caf2661dc3c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
diff -burN libmikmod-3.2.0/acconfig.h libmikmod-3.2.0-psp/acconfig.h
--- libmikmod-3.2.0/acconfig.h	2012-03-14 18:02:59.000000000 +0100
+++ libmikmod-3.2.0-psp/acconfig.h	2012-06-06 04:58:02.498696602 +0200
@@ -40,6 +40,8 @@
 #undef DRV_OSX
 /* Define this if you want the Carbon Mac Audio driver */
 #undef DRV_MAC
+/* Define this if you want the Playstation Portable driver */
+#undef DRV_PSP
 
 /* Define if you want a debug version of the library */
 #undef MIKMOD_DEBUG
diff -burN libmikmod-3.2.0/config.h.in libmikmod-3.2.0-psp/config.h.in
--- libmikmod-3.2.0/config.h.in	2012-06-01 15:15:43.000000000 +0200
+++ libmikmod-3.2.0-psp/config.h.in	2012-06-06 04:57:21.085695314 +0200
@@ -41,7 +41,8 @@
 #undef DRV_OSX
 /* Define this if you want the Carbon Mac Audio driver */
 #undef DRV_MAC
-
+/* Define this if you want the Playstation Portable driver */
+#undef DRV_PSP
 /* Define if you want a debug version of the library */
 #undef MIKMOD_DEBUG
 /* Define if you want runtime dynamic linking of ALSA and EsounD drivers */
diff -burN libmikmod-3.2.0/config.sub libmikmod-3.2.0-psp/config.sub
--- libmikmod-3.2.0/config.sub	2012-03-14 18:02:59.000000000 +0100
+++ libmikmod-3.2.0-psp/config.sub	2012-06-06 04:57:21.085695314 +0200
@@ -820,6 +820,10 @@
 	ps2)
 		basic_machine=i386-ibm
 		;;
+	psp)
+		basic_machine=mipsallegrexel-psp
+		os=-elf
+		;;
 	pw32)
 		basic_machine=i586-unknown
 		os=-pw32
diff -burN libmikmod-3.2.0/configure.in libmikmod-3.2.0-psp/configure.in
--- libmikmod-3.2.0/configure.in	2012-06-01 15:15:29.000000000 +0200
+++ libmikmod-3.2.0-psp/configure.in	2012-06-06 04:57:21.086695311 +0200
@@ -45,7 +45,7 @@
 libmikmod_driver_osx=yes
 libmikmod_driver_mac=no
 libmikmod_driver_ultra=yes
-
+libmikmod_driver_psp=yes
 libmikmod_driverlist=
 libmikmod_dynload=yes
 libmikmod_dynload_underscores=no
@@ -134,6 +134,15 @@
   libmikmod_driver_ultra=no
 fi])
 
+AC_ARG_ENABLE(psp,
+[  --enable-psp            include PSP driver [guessed]],
+[if test "$enableval" = "yes"
+then
+  libmikmod_driver_psp=yes
+else
+  libmikmod_driver_psp=no
+fi])
+
 AC_ARG_ENABLE(dl,
 [  --enable-dl             load alsa, esound and ultra drivers at runtime
                           [default=yes]],
@@ -732,6 +741,38 @@
 	;;
 esac
 	
+# Check for valid PSPSDK installation
+CheckPSPSDK()
+{
+	AC_CHECK_PROG(psp_config, psp-config, psp-config, no)
+	if test x%psp_config = xno; then
+		AC_MSG_ERROR(Couldn't locate psp-config.)
+	fi
+
+	AC_MSG_CHECKING(for PSPSDK)
+	pspsdk_path=`$psp_config --pspsdk-path`
+	if test ! -d $pspsdk_path -o -z $pspsdk_path; then
+		AC_MSG_RESULT(not found)
+		AC_MSG_ERROR(Couldn't locate PSPSDK.)
+	fi
+	AC_MSG_RESULT($pspsdk_path)
+
+	# Compile libmikmod with -G0 to disable the $gp register.
+	CFLAGS="$CFLAGS -G0 -I\"${pspsdk_path}/include\""
+}
+
+case "$host" in
+*-psp-*)
+	ARCH=psp
+	if test $libmikmod_driver_psp = yes
+	then
+		CheckPSPSDK
+		libmikmod_driverlist="psp $libmikmod_driverlist"
+	AC_DEFINE(DRV_PSP)
+	fi
+	;;
+esac
+
 # =================
 # Create Makefiles.
 # =================
diff -burN libmikmod-3.2.0/drivers/drv_psp.c libmikmod-3.2.0-psp/drivers/drv_psp.c
--- libmikmod-3.2.0/drivers/drv_psp.c	1970-01-01 01:00:00.000000000 +0100
+++ libmikmod-3.2.0-psp/drivers/drv_psp.c	2012-06-06 04:57:21.086695311 +0200
@@ -0,0 +1,180 @@
+/*	MikMod sound library
+	(c) 1998, 1999, 2000 Miodrag Vallat and others - see file AUTHORS for
+	complete list.
+
+	This library is free software; you can redistribute it and/or modify
+	it under the terms of the GNU Library 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 Library General Public License for more details.
+
+	You should have received a copy of the GNU Library General Public
+	License along with this library; if not, write to the Free Software
+	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+	02111-1307, USA.
+*/
+
+/*==============================================================================
+
+  $Id: drv_psp.c,v 1.1 $
+
+  Output data to PSP audio device
+
+==============================================================================*/
+
+/*
+
+By sweetlilmre 12 November 2005, (mikmod 3.1.11 port), original by Jim Shaw.
+Public Domain
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "mikmod_internals.h"
+
+#ifdef DRV_PSP
+
+#include <pspkernel.h>
+#include <pspaudio.h>
+#include <pspaudiolib.h>
+#include <string.h>
+
+
+static int audio_ready=0;
+static int audio_handle = -1;
+static volatile int audio_terminate=0;
+static volatile int bufidx=0;
+
+static short mkimod_sndbuf[2][PSP_NUM_AUDIO_SAMPLES][2];
+
+
+static volatile int playing = 0;
+
+static void PSP_Update(void)
+{
+	if (audio_terminate == 0)
+	{
+		void *bufptr=&mkimod_sndbuf[bufidx];
+		if (playing)
+		{
+			VC_WriteBytes(bufptr, PSP_NUM_AUDIO_SAMPLES*4);
+		}
+		else
+		{
+			memset(bufptr, 0, PSP_NUM_AUDIO_SAMPLES*4);
+		}
+		if (audio_ready)
+		{
+			sceAudioOutputPannedBlocking(audio_handle, PSP_VOLUME_MAX, PSP_VOLUME_MAX, bufptr);
+		}
+		bufidx=(bufidx?0:1);
+	}
+}
+
+
+static BOOL PSP_IsThere(void)
+{
+	return 1;
+}
+
+
+static BOOL PSP_Init(void)
+{
+	if (VC_Init())
+		return 1;
+    
+	audio_terminate=0;
+	audio_ready=0;
+	audio_handle = -1;
+
+	if ((audio_handle = sceAudioChReserve(-1,PSP_NUM_AUDIO_SAMPLES,0))<0)
+	{
+		return 1;
+	}
+	audio_ready = 1;
+	return 0;
+}
+
+static void PSP_Exit(void)
+{
+	audio_ready=0;
+	audio_terminate=1;
+	if (audio_handle != -1)
+	{
+		sceAudioChRelease(audio_handle);
+		audio_handle = -1;
+	}
+
+	VC_Exit();
+}
+
+
+static BOOL PSP_Reset(void)
+{
+	VC_Exit();
+	return VC_Init();
+}
+
+static BOOL PSP_PlayStart(void)
+{
+	VC_PlayStart();
+	playing = 1;
+	return 0;
+}
+
+static void PSP_PlayStop(void)
+{
+	playing = 0;
+	VC_PlayStop();
+}
+
+MIKMODAPI MDRIVER drv_psp =
+{
+	NULL,
+	"PSP Audio",
+	"PSP Output Driver v1.1 - by sweetlilmre, original by Jim Shaw",
+	0,255,
+	"pspdrv",
+
+	NULL,
+	PSP_IsThere,
+	VC_SampleLoad,
+	VC_SampleUnload,
+	VC_SampleSpace,
+	VC_SampleLength,
+	PSP_Init,
+	PSP_Exit,
+	PSP_Reset,
+  
+	VC_SetNumVoices,
+	PSP_PlayStart,
+	PSP_PlayStop,
+	PSP_Update,
+	NULL,
+  
+	VC_VoiceSetVolume,
+	VC_VoiceGetVolume,
+	VC_VoiceSetFrequency,
+	VC_VoiceGetFrequency,
+	VC_VoiceSetPanning,
+	VC_VoiceGetPanning,
+	VC_VoicePlay,
+	VC_VoiceStop,
+	VC_VoiceStopped,
+	VC_VoiceGetPosition,
+	VC_VoiceRealVolume
+};
+
+#else
+
+MISSING(drv_psp);
+
+#endif
+
+
diff -burN libmikmod-3.2.0/drivers/Makefile.am libmikmod-3.2.0-psp/drivers/Makefile.am
--- libmikmod-3.2.0/drivers/Makefile.am	2012-03-14 18:02:59.000000000 +0100
+++ libmikmod-3.2.0-psp/drivers/Makefile.am	2012-06-06 04:57:21.086695311 +0200
@@ -13,6 +13,7 @@
              drv_oss.c    \
              drv_osx.c    \
              drv_pipe.c   \
+             drv_psp.c    \
              drv_raw.c    \
              drv_sam9407.c\
              drv_sb.c     \
diff -burN libmikmod-3.2.0/include/mikmod.h.in libmikmod-3.2.0-psp/include/mikmod.h.in
--- libmikmod-3.2.0/include/mikmod.h.in	2012-05-12 11:52:13.000000000 +0200
+++ libmikmod-3.2.0-psp/include/mikmod.h.in	2012-06-06 04:57:21.087695311 +0200
@@ -738,6 +738,8 @@
 MIKMODAPI extern struct MDRIVER drv_wss;    /* DOS WSS driver */
 MIKMODAPI extern struct MDRIVER drv_sb;     /* DOS SB driver */
 
+MIKMODAPI extern struct MDRIVER drv_psp;    /* PSP Sound driver */
+
 /*========== Virtual channel mixer interface (for user-supplied drivers only) */
 
 MIKMODAPI extern BOOL  VC_Init(void);
diff -burN libmikmod-3.2.0/libmikmod/Makefile.in libmikmod-3.2.0-psp/libmikmod/Makefile.in
--- libmikmod-3.2.0/libmikmod/Makefile.in	2012-06-01 15:16:08.000000000 +0200
+++ libmikmod-3.2.0-psp/libmikmod/Makefile.in	2012-06-06 04:57:21.087695311 +0200
@@ -35,7 +35,7 @@
 LIB = libmikmod.la
 OBJ = $(LIBOBJS) $(DLOBJS) \
       drv_AF.lo drv_aiff.lo drv_aix.lo drv_alsa.lo drv_esd.lo drv_hp.lo drv_nos.lo \
-      drv_oss.lo drv_osx.lo drv_mac.lo drv_nas.lo drv_pipe.lo drv_raw.lo drv_sam9407.lo drv_sgi.lo \
+      drv_oss.lo drv_osx.lo drv_mac.lo drv_nas.lo drv_pipe.lo drv_psp.lo drv_raw.lo drv_sam9407.lo drv_sgi.lo \
       drv_stdout.lo drv_sun.lo drv_ultra.lo drv_wav.lo \
       load_669.lo load_amf.lo load_asy.lo load_dsm.lo load_far.lo \
       load_gdm.lo load_gt2.lo load_it.lo load_imf.lo load_m15.lo load_med.lo \
@@ -115,6 +115,9 @@
 drv_osx.lo:	$(top_srcdir)/drivers/drv_osx.c \
 			$(top_builddir)/include/mikmod.h $(top_srcdir)/include/mikmod_internals.h
 	$(COMPILE) -c $(top_srcdir)/drivers/drv_osx.c
+drv_psp.lo:	$(top_srcdir)/drivers/drv_psp.c \
+			$(top_builddir)/include/mikmod.h $(top_srcdir)/include/mikmod_internals.h
+	$(COMPILE) -c $(top_srcdir)/drivers/drv_psp.c
 drv_raw.lo:	$(top_srcdir)/drivers/drv_raw.c \
 			$(top_builddir)/include/mikmod.h $(top_srcdir)/include/mikmod_internals.h
 	$(COMPILE) -c $(top_srcdir)/drivers/drv_raw.c