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 +#include +#include +#include + + +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