Added Atari audio support (thanks Patrice!)
authorSam Lantinga <slouken@libsdl.org>
Mon, 10 Jun 2002 20:42:53 +0000
changeset 398d219b0e02f5f
parent 397 283d348cb624
child 399 cfcf6bf1640c
Added Atari audio support (thanks Patrice!)
README.MiNT
configure.in
src/audio/Makefile.am
src/audio/SDL_audio.c
src/audio/SDL_sysaudio.h
src/audio/mint/.cvsignore
src/audio/mint/Makefile.am
src/audio/mint/SDL_mintaudio.c
src/audio/mint/SDL_mintaudio.h
src/audio/mint/SDL_mintaudiodma.h
src/audio/mint/SDL_mintaudiogsxb.h
src/audio/mint/SDL_mintaudiointerrupt.S
src/audio/mint/SDL_mintaudiointerrupt_s.h
     1.1 --- a/README.MiNT	Mon Jun 10 20:42:02 2002 +0000
     1.2 +++ b/README.MiNT	Mon Jun 10 20:42:53 2002 +0000
     1.3 @@ -10,9 +10,8 @@
     1.4    Do the classic configure, with --disable-shared --enable-static and:
     1.5  
     1.6      Tos version (should run everywhere):
     1.7 -      --disable-audio --disable-threads
     1.8 -    Tos does not support threads, so can not support audio, maybe in a future
     1.9 -    version audio support will be added via interrupts.
    1.10 +      --disable-threads
    1.11 +    Tos does not support threads.
    1.12  
    1.13      MiNT version (maybe Magic, only for multitasking OS):
    1.14        --disable-pthreads --enable-pth
    1.15 @@ -50,11 +49,11 @@
    1.16  Video (XBIOS (Fullscreen), GEM (Windowed and Fullscreen))
    1.17  Timer (VBL vector)
    1.18  Joystick and joypad support (Ikbd, Hardware)
    1.19 +Audio support (Hardware, XBIOS, GSXB, /dev/audio if threads enabled)
    1.20 +Threads support (Multitasking OS only via GNU pth library)
    1.21  
    1.22  - What is missing:
    1.23 -Audio support (TOS)
    1.24  CDROM support (Metados, /dev/cdrom)
    1.25 -Threads support (TOS)
    1.26  
    1.27  - Driver combinations:
    1.28  Video	Kbd	Mouse	Timer	Jstick	Joypads
    1.29 @@ -69,15 +68,20 @@
    1.30  ==============================================================================
    1.31  V.  Environment variables:
    1.32  
    1.33 +SDL_VIDEODRIVER:
    1.34 +	Set to 'xbios' to force xbios video driver
    1.35 +	Set to 'gem' to force gem video driver
    1.36 +
    1.37 +SDL_AUDIODRIVER:
    1.38 +	Set to 'mint' to force Atari audio driver
    1.39 +	Set to 'audio' to force Sun /dev/audio audio driver
    1.40 +	Set to 'disk' to force disk-writing audio driver
    1.41 +
    1.42  SDL_ATARI_EVENTSDRIVER
    1.43  	Set to 'ikbd' to force IKBD 6301 keyboard driver
    1.44  	Set to 'gemdos' to force gemdos keyboard driver
    1.45  	Set to 'bios' to force bios keyboard driver
    1.46  
    1.47 -SDL_VIDEODRIVER:
    1.48 -	Set to 'xbios' to force xbios video driver
    1.49 -	Set to 'gem' to force gem video driver
    1.50 -
    1.51  SDL_JOYSTICK_ATARI:
    1.52  	Use any of these strings in the environment variable to enable or
    1.53  	disable a joystick:
    1.54 @@ -151,7 +155,19 @@
    1.55  	Available if _MCH cookie is STE or Falcon.
    1.56  
    1.57  VBL timer driver:
    1.58 -	Available all machines (I think).
    1.59 +	Available on all machines (I think).
    1.60 +
    1.61 +Audio driver:
    1.62 +	Cookie _SND is used to detect supported audio capabilities
    1.63 +
    1.64 +	STE, Mega STE, TT:
    1.65 +		8 bits DMA (hardware access)
    1.66 +
    1.67 +	Falcon, machines with GSXB driver:
    1.68 +		Xbios functions
    1.69 +
    1.70 +	Other machines:
    1.71 +		Not supported
    1.72  
    1.73  -- 
    1.74  Patrice Mandin <pmandin@caramail.com>
     2.1 --- a/configure.in	Mon Jun 10 20:42:02 2002 +0000
     2.2 +++ b/configure.in	Mon Jun 10 20:42:53 2002 +0000
     2.3 @@ -435,6 +435,24 @@
     2.4      fi
     2.5  }
     2.6  
     2.7 +dnl Set up the Atari Audio driver
     2.8 +CheckAtariAudio()
     2.9 +{
    2.10 +    AC_ARG_ENABLE(mintaudio,
    2.11 +[  --enable-mintaudio      support Atari audio driver [default=yes]],
    2.12 +                  , enable_mintaudio=yes)
    2.13 +    if test x$enable_audio = xyes -a x$enable_mintaudio = xyes; then
    2.14 +        mintaudio=no
    2.15 +        AC_CHECK_HEADER(mint/falcon.h, have_mint_falcon_hdr=yes)
    2.16 +        if test x$have_mint_falcon_hdr = xyes; then
    2.17 +            mintaudio=yes
    2.18 +            CFLAGS="$CFLAGS -DMINTAUDIO_SUPPORT"
    2.19 +            AUDIO_SUBDIRS="$AUDIO_SUBDIRS mint"
    2.20 +            AUDIO_DRIVERS="$AUDIO_DRIVERS mint/libaudio_mintaudio.la"
    2.21 +        fi
    2.22 +    fi
    2.23 +}
    2.24 +
    2.25  dnl See if we can use x86 assembly blitters
    2.26  # NASM is available from: http://nasm.octium.net/
    2.27  CheckNASM()
    2.28 @@ -2380,13 +2398,17 @@
    2.29          CheckAtariBiosEvent
    2.30          CheckAtariXbiosVideo
    2.31          CheckAtariGemVideo
    2.32 +        CheckAtariAudio
    2.33          CheckPTH
    2.34          # Set up files for the main() stub
    2.35          COPY_ARCH_SRC(src/main, linux, SDL_main.c)
    2.36          # Set up files for the audio library
    2.37 -        if test x$enable_audio = xyes; then
    2.38 -            AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
    2.39 -            AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
    2.40 +        if test x$enable_threads = xyes -a x$enable_pth = xyes; then
    2.41 +            if test x$enable_audio = xyes; then
    2.42 +                CFLAGS="$CFLAGS -DSUNAUDIO_SUPPORT"
    2.43 +                AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
    2.44 +                AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
    2.45 +            fi
    2.46          fi
    2.47          # Set up files for the joystick library
    2.48          if test x$enable_joystick = xyes; then
    2.49 @@ -2575,6 +2597,7 @@
    2.50  src/audio/windib/Makefile
    2.51  src/audio/windx5/Makefile
    2.52  src/audio/disk/Makefile
    2.53 +src/audio/mint/Makefile
    2.54  src/video/Makefile
    2.55  src/video/XFree86/Makefile
    2.56  src/video/XFree86/extensions/Makefile
     3.1 --- a/src/audio/Makefile.am	Mon Jun 10 20:42:02 2002 +0000
     3.2 +++ b/src/audio/Makefile.am	Mon Jun 10 20:42:53 2002 +0000
     3.3 @@ -5,7 +5,8 @@
     3.4  
     3.5  # Define which subdirectories need to be built
     3.6  SUBDIRS = @AUDIO_SUBDIRS@
     3.7 -DIST_SUBDIRS = alsa arts baudio dma dmedia dsp esd macrom nas nto openbsd paudio sun ums windib windx5 disk
     3.8 +DIST_SUBDIRS = alsa arts baudio dma dmedia dsp esd macrom nas nto openbsd \
     3.9 +	paudio sun ums windib windx5 disk mint
    3.10  
    3.11  DRIVERS = @AUDIO_DRIVERS@
    3.12  
     4.1 --- a/src/audio/SDL_audio.c	Mon Jun 10 20:42:02 2002 +0000
     4.2 +++ b/src/audio/SDL_audio.c	Mon Jun 10 20:42:53 2002 +0000
     4.3 @@ -83,6 +83,9 @@
     4.4  #ifdef ENABLE_AHI
     4.5  	&AHI_bootstrap,
     4.6  #endif
     4.7 +#ifdef MINTAUDIO_SUPPORT
     4.8 +	&MINTAUDIO_bootstrap,
     4.9 +#endif
    4.10  #ifdef DISKAUD_SUPPORT
    4.11  	&DISKAUD_bootstrap,
    4.12  #endif
    4.13 @@ -378,6 +381,9 @@
    4.14  #ifdef macintosh
    4.15  	/* FIXME: Need to implement PPC interrupt asm for SDL_LockAudio() */
    4.16  #else
    4.17 +#if defined(__MINT__) && !defined(ENABLE_THREADS)
    4.18 +	/* Uses interrupt driven audio, without thread */
    4.19 +#else
    4.20  	/* Create a semaphore for locking the sound buffers */
    4.21  	audio->mixer_lock = SDL_CreateMutex();
    4.22  	if ( audio->mixer_lock == NULL ) {
    4.23 @@ -385,7 +391,8 @@
    4.24  		SDL_CloseAudio();
    4.25  		return(-1);
    4.26  	}
    4.27 -#endif
    4.28 +#endif /* __MINT__ */
    4.29 +#endif /* macintosh */
    4.30  
    4.31  	/* Calculate the silence and size of the audio specification */
    4.32  	SDL_CalculateAudioSpec(desired);
     5.1 --- a/src/audio/SDL_sysaudio.h	Mon Jun 10 20:42:02 2002 +0000
     5.2 +++ b/src/audio/SDL_sysaudio.h	Mon Jun 10 20:42:53 2002 +0000
     5.3 @@ -147,6 +147,9 @@
     5.4  #ifdef ENABLE_AHI
     5.5  extern AudioBootStrap AHI_bootstrap;
     5.6  #endif
     5.7 +#ifdef MINTAUDIO_SUPPORT
     5.8 +extern AudioBootStrap MINTAUDIO_bootstrap;
     5.9 +#endif
    5.10  #ifdef DISKAUD_SUPPORT
    5.11  extern AudioBootStrap DISKAUD_bootstrap;
    5.12  #endif
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/audio/mint/.cvsignore	Mon Jun 10 20:42:53 2002 +0000
     6.3 @@ -0,0 +1,6 @@
     6.4 +Makefile.in
     6.5 +Makefile
     6.6 +.libs
     6.7 +*.o
     6.8 +*.lo
     6.9 +*.la
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/audio/mint/Makefile.am	Mon Jun 10 20:42:53 2002 +0000
     7.3 @@ -0,0 +1,14 @@
     7.4 +
     7.5 +## Makefile.am for SDL using Xbios/Dma/whatever available audio functions
     7.6 +
     7.7 +noinst_LTLIBRARIES = libaudio_mintaudio.la
     7.8 +libaudio_mintaudio_la_SOURCES = $(SRCS)
     7.9 +
    7.10 +# The SDL audio driver sources
    7.11 +SRCS =	SDL_mintaudio.c	\
    7.12 +	SDL_mintaudio.h	\
    7.13 +	SDL_mintaudiointerrupt.S \
    7.14 +	SDL_mintaudiointerrupt_s.h \
    7.15 +	SDL_mintaudiodma.h \
    7.16 +	SDL_mintaudiogsxb.h
    7.17 +
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/audio/mint/SDL_mintaudio.c	Mon Jun 10 20:42:53 2002 +0000
     8.3 @@ -0,0 +1,628 @@
     8.4 +/*
     8.5 + * MiNT audio driver
     8.6 + * 
     8.7 + * Patrice Mandin
     8.8 + */
     8.9 +
    8.10 +#include <stdlib.h>
    8.11 +#include <stdio.h>
    8.12 +#include <string.h>
    8.13 +
    8.14 +/* Mint includes */
    8.15 +#include <mint/osbind.h>
    8.16 +#include <mint/falcon.h>
    8.17 +#include <sys/cookie.h>
    8.18 +
    8.19 +#include "SDL_endian.h"
    8.20 +#include "SDL_audio.h"
    8.21 +#include "SDL_audio_c.h"
    8.22 +#include "SDL_audiomem.h"
    8.23 +#include "SDL_sysaudio.h"
    8.24 +
    8.25 +#include "SDL_mintaudio.h"
    8.26 +#include "SDL_mintaudiodma.h"
    8.27 +#include "SDL_mintaudiogsxb.h"
    8.28 +#include "SDL_mintaudiointerrupt_s.h"
    8.29 +
    8.30 +#include "SDL_atarimxalloc_c.h"
    8.31 +
    8.32 +/*--- Defines ---*/
    8.33 +
    8.34 +#define MINT_AUDIO_DRIVER_NAME "mint"
    8.35 +
    8.36 +/* Master clocks for replay frequencies */
    8.37 +#define MASTERCLOCK_STE		8010666		/* Not sure of this one */
    8.38 +#define MASTERCLOCK_TT		16107953	/* Not sure of this one */
    8.39 +#define MASTERCLOCK_FALCON1	25175000
    8.40 +#define MASTERCLOCK_FALCON2	32000000	/* Only usable for DSP56K */
    8.41 +#define MASTERCLOCK_FALCONEXT	-1		/* Clock on DSP56K port, unknown */
    8.42 +#define MASTERCLOCK_MILAN1	22579200	/* Standard clock for 44.1 Khz */
    8.43 +#define MASTERCLOCK_MILAN2	24576000	/* Standard clock for 48 Khz */
    8.44 +
    8.45 +/* Master clock predivisors */
    8.46 +#define MASTERPREDIV_STE	160
    8.47 +#define MASTERPREDIV_TT		320
    8.48 +#define MASTERPREDIV_FALCON	256
    8.49 +#define MASTERPREDIV_MILAN	256
    8.50 +
    8.51 +/* Values>>16 in _MCH cookie */
    8.52 +enum {
    8.53 +	MCH_ST=0,
    8.54 +	MCH_STE,
    8.55 +	MCH_TT,
    8.56 +	MCH_F30
    8.57 +};
    8.58 +
    8.59 +/* MFP 68901 interrupt sources */
    8.60 +enum {
    8.61 +	MFP_PARALLEL=0,
    8.62 +	MFP_DCD,
    8.63 +	MFP_CTS,
    8.64 +	MFP_BITBLT,
    8.65 +	MFP_TIMERD,
    8.66 +	MFP_BAUDRATE=MFP_TIMERD,
    8.67 +	MFP_TIMERC,
    8.68 +	MFP_200HZ=MFP_TIMERC,
    8.69 +	MFP_ACIA,
    8.70 +	MFP_DISK,
    8.71 +	MFP_TIMERB,
    8.72 +	MFP_HBLANK=MFP_TIMERB,
    8.73 +	MFP_TERR,
    8.74 +	MFP_TBE,
    8.75 +	MFP_RERR,
    8.76 +	MFP_RBF,
    8.77 +	MFP_TIMERA,
    8.78 +	MFP_DMASOUND=MFP_TIMERA,
    8.79 +	MFP_RING,
    8.80 +	MFP_MONODETECT
    8.81 +};
    8.82 +
    8.83 +/* Xbtimer() timers */
    8.84 +enum {
    8.85 +	XB_TIMERA=0,
    8.86 +	XB_TIMERB,
    8.87 +	XB_TIMERC,
    8.88 +	XB_TIMERD
    8.89 +};
    8.90 +
    8.91 +/*--- Static variables ---*/
    8.92 +
    8.93 +static unsigned long cookie_snd, cookie_mch, cookie_gsxb;
    8.94 +static Uint16 hardfreq[16];
    8.95 +static Uint16 numfreq;
    8.96 +static SDL_AudioDevice *SDL_MintAudio_device;
    8.97 +
    8.98 +/*--- Audio driver functions ---*/
    8.99 +
   8.100 +static void Mint_CloseAudio(_THIS);
   8.101 +static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec);
   8.102 +static void Mint_LockAudio(_THIS);
   8.103 +static void Mint_UnlockAudio(_THIS);
   8.104 +
   8.105 +/*--- Audio driver bootstrap functions ---*/
   8.106 +
   8.107 +static int Audio_Available(void)
   8.108 +{
   8.109 +	const char *envr = getenv("SDL_AUDIODRIVER");
   8.110 +
   8.111 +	/* Check if user asked a different audio driver */
   8.112 +	if ((envr) && (strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
   8.113 +		return 0;
   8.114 +	}
   8.115 +
   8.116 +	/* Cookie _SND present ? if not, assume ST machine */
   8.117 +	if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
   8.118 +		cookie_snd = SND_PSG;
   8.119 +	}
   8.120 +
   8.121 +	/* Cookie _MCH present ? if not, assume ST machine */
   8.122 +	if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
   8.123 +		cookie_mch = MCH_ST << 16;
   8.124 +	}
   8.125 +
   8.126 +	/* Cookie GSXB present ? */
   8.127 +	cookie_gsxb = (Getcookie(C_GSXB, &cookie_gsxb) == C_FOUND);
   8.128 +
   8.129 +	/* Check if we have xbios functions (Falcon, clones) */
   8.130 +	if ((cookie_snd & SND_16BIT)!=0) {
   8.131 +		/* Check if audio is lockable */
   8.132 +		if (Locksnd()==1) {
   8.133 +			Unlocksnd();
   8.134 +		} else {
   8.135 +			/* Already in use */
   8.136 +			return(0);
   8.137 +		}
   8.138 +
   8.139 +		return(1);
   8.140 +	}
   8.141 +
   8.142 +	/* Check if we have 8 bits DMA audio (STE, TT) */
   8.143 +	if ((cookie_snd & SND_8BIT)!=0) {
   8.144 +		return(1);
   8.145 +	}
   8.146 +
   8.147 +    return(0);
   8.148 +}
   8.149 +
   8.150 +static void Audio_DeleteDevice(SDL_AudioDevice *device)
   8.151 +{
   8.152 +    free(device->hidden);
   8.153 +    free(device);
   8.154 +}
   8.155 +
   8.156 +static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   8.157 +{
   8.158 +    SDL_AudioDevice *this;
   8.159 +
   8.160 +    /* Initialize all variables that we clean on shutdown */
   8.161 +    this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   8.162 +    if ( this ) {
   8.163 +        memset(this, 0, (sizeof *this));
   8.164 +    }
   8.165 +    if ( this == NULL ) {
   8.166 +        SDL_OutOfMemory();
   8.167 +        if ( this ) {
   8.168 +            free(this);
   8.169 +        }
   8.170 +        return(0);
   8.171 +    }
   8.172 +
   8.173 +    /* Set the function pointers */
   8.174 +    this->OpenAudio   = Mint_OpenAudio;
   8.175 +    this->CloseAudio  = Mint_CloseAudio;
   8.176 +    this->LockAudio   = Mint_LockAudio;
   8.177 +    this->UnlockAudio = Mint_UnlockAudio;
   8.178 +    this->free        = Audio_DeleteDevice;
   8.179 +
   8.180 +    return this;
   8.181 +}
   8.182 +
   8.183 +AudioBootStrap MINTAUDIO_bootstrap = {
   8.184 +	MINT_AUDIO_DRIVER_NAME, "MiNT audio driver",
   8.185 +	Audio_Available, Audio_CreateDevice
   8.186 +};
   8.187 +
   8.188 +static void Mint_LockAudio(_THIS)
   8.189 +{
   8.190 +	void *oldpile;
   8.191 +
   8.192 +	/* Stop replay */
   8.193 +	if ((cookie_snd & SND_16BIT)!=0) {
   8.194 +		Buffoper(0);
   8.195 +	} else if ((cookie_snd & SND_8BIT)!=0) {
   8.196 +		oldpile=(void *)Super(0);
   8.197 +		DMAAUDIO_IO.control=0;
   8.198 +		Super(oldpile);
   8.199 +	}
   8.200 +}
   8.201 +
   8.202 +static void Mint_UnlockAudio(_THIS)
   8.203 +{
   8.204 +	void *oldpile;
   8.205 +
   8.206 +	/* Restart replay */
   8.207 +	if ((cookie_snd & SND_16BIT)!=0) {
   8.208 +		Buffoper(SB_PLA_ENA|SB_PLA_RPT);
   8.209 +	} else if ((cookie_snd & SND_8BIT)!=0) {
   8.210 +		oldpile=(void *)Super(0);
   8.211 +		DMAAUDIO_IO.control=3;
   8.212 +		Super(oldpile);
   8.213 +	}
   8.214 +}
   8.215 +
   8.216 +/* This is called from the interrupt routine */
   8.217 +void SDL_MintAudio_Callback(void)
   8.218 +{
   8.219 +	SDL_AudioDevice *audio;
   8.220 +	Uint8 *buffer;
   8.221 +
   8.222 +	audio = SDL_MintAudio_device;
   8.223 + 	buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
   8.224 +
   8.225 +	if ( ! audio->paused ) {
   8.226 +		if ( audio->convert.needed ) {
   8.227 +			audio->spec.callback(audio->spec.userdata,
   8.228 +				(Uint8 *)audio->convert.buf,audio->convert.len);
   8.229 +			SDL_ConvertAudio(&audio->convert);
   8.230 +			memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
   8.231 +		} else {
   8.232 +			audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size);
   8.233 +		}
   8.234 +	}
   8.235 +}
   8.236 +
   8.237 +static void Mint_StopAudio_Dma8(void)
   8.238 +{
   8.239 +	void *oldpile;
   8.240 +	
   8.241 +	oldpile=(void *)Super(0);
   8.242 +	DMAAUDIO_IO.control=0;
   8.243 +	Super(oldpile);
   8.244 +
   8.245 +	Jdisint(MFP_DMASOUND);
   8.246 +}
   8.247 +
   8.248 +static void Mint_StopAudio_Xbios(void)
   8.249 +{
   8.250 +	Buffoper(0);
   8.251 +	Jdisint(MFP_DMASOUND);
   8.252 +}
   8.253 +
   8.254 +static void Mint_StopAudio_Gsxb(void)
   8.255 +{
   8.256 +	Buffoper(0);
   8.257 +}
   8.258 +
   8.259 +static void Mint_CloseAudio(_THIS)
   8.260 +{
   8.261 +	if (cookie_gsxb && ((cookie_snd & (SND_GSXB|SND_16BIT))==(SND_GSXB|SND_16BIT)) ) {
   8.262 +		Mint_StopAudio_Gsxb();
   8.263 +	} else if ((cookie_snd & SND_16BIT)!=0) {
   8.264 +		Mint_StopAudio_Xbios();
   8.265 +	} else if ((cookie_snd & SND_8BIT)!=0) {
   8.266 +		Mint_StopAudio_Dma8();
   8.267 +	}
   8.268 +
   8.269 +	/* Clear buffers */
   8.270 +	if (SDL_MintAudio_audiobuf[0]) {
   8.271 +		Mfree(SDL_MintAudio_audiobuf[0]);
   8.272 +		SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL;
   8.273 +	}
   8.274 +
   8.275 +	/* Unlock sound system */
   8.276 +	if ((cookie_snd & SND_16BIT)!=0) {
   8.277 +		Unlocksnd();
   8.278 +	}
   8.279 +}
   8.280 +
   8.281 +static void Mint_CheckAudio_Dma8(SDL_AudioSpec *spec)
   8.282 +{
   8.283 +	int i;
   8.284 +
   8.285 +	spec->format = AUDIO_S8;
   8.286 +
   8.287 +	switch(cookie_mch>>16) {
   8.288 +		case MCH_STE:
   8.289 +			/* STE replay frequencies */
   8.290 +			for (i=0;i<4;i++) {
   8.291 +				hardfreq[i]=MASTERCLOCK_STE/(MASTERPREDIV_STE*(i+1));
   8.292 +			}
   8.293 +
   8.294 +			if (spec->freq>=(hardfreq[0]+hardfreq[1])>>1) {
   8.295 +				numfreq=3;		/* 50066 */
   8.296 +			} else if (spec->freq>=(hardfreq[1]+hardfreq[2])>>1) {
   8.297 +				numfreq=2;		/* 25033 */
   8.298 +			} else if (spec->freq>=(hardfreq[2]+hardfreq[3])>>1) {
   8.299 +				numfreq=1;		/* 12517 */
   8.300 +			} else {
   8.301 +				numfreq=0;		/* 6258 */
   8.302 +			}
   8.303 +
   8.304 +			spec->freq=hardfreq[numfreq];
   8.305 +			break;
   8.306 +		case MCH_TT:
   8.307 +			/* TT replay frequencies */
   8.308 +			for (i=0;i<4;i++) {
   8.309 +				hardfreq[i]=MASTERCLOCK_TT/(MASTERPREDIV_TT*(i+1));
   8.310 +			}
   8.311 +
   8.312 +			if (spec->freq>=(hardfreq[0]+hardfreq[1])>>1) {
   8.313 +				numfreq=3;		/* 50337 */
   8.314 +			} else if (spec->freq>=(hardfreq[1]+hardfreq[2])>>1) {
   8.315 +				numfreq=2;		/* 25169 */
   8.316 +			} else if (spec->freq>=(hardfreq[2]+hardfreq[3])>>1) {
   8.317 +				numfreq=1;		/* 12584 */
   8.318 +			} else {
   8.319 +				numfreq=0;		/* 6292 */
   8.320 +			}
   8.321 +			spec->freq=hardfreq[numfreq];
   8.322 +			break;
   8.323 +	}
   8.324 +}
   8.325 +
   8.326 +static void Mint_CheckAudio_Xbios(SDL_AudioSpec *spec)
   8.327 +{
   8.328 +	int i;
   8.329 +
   8.330 +	/* Check conversions needed */
   8.331 +	switch (spec->format & 0xff) {
   8.332 +		case 8:
   8.333 +			spec->format = AUDIO_S8;
   8.334 +			break;
   8.335 +		case 16:
   8.336 +			spec->format = AUDIO_S16MSB;
   8.337 +			break;
   8.338 +	}
   8.339 +	
   8.340 +	/* Check hardware channels */
   8.341 +	if ((spec->channels==1) && ((spec->format & 0xff)==16)) {
   8.342 +		spec->channels=2;
   8.343 +	}
   8.344 +
   8.345 +	/* Falcon replay frequencies */
   8.346 +	for (i=0;i<16;i++) {
   8.347 +		hardfreq[i]=MASTERCLOCK_FALCON1/(MASTERPREDIV_FALCON*(i+1));
   8.348 +	}
   8.349 +
   8.350 +	/* The Falcon CODEC only support some frequencies */
   8.351 +	if (spec->freq>=(hardfreq[CLK50K]+hardfreq[CLK33K])>>1) {
   8.352 +		numfreq=CLK50K;		/* 49170 */
   8.353 +	} else if (spec->freq>=(hardfreq[CLK33K]+hardfreq[CLK25K])>>1) {
   8.354 +		numfreq=CLK33K;		/* 32780 */
   8.355 +	} else if (spec->freq>=(hardfreq[CLK25K]+hardfreq[CLK20K])>>1) {
   8.356 +		numfreq=CLK25K;		/* 24585 */
   8.357 +	} else if (spec->freq>=(hardfreq[CLK20K]+hardfreq[CLK16K])>>1) {
   8.358 +		numfreq=CLK20K;		/* 19668 */
   8.359 +	} else if (spec->freq>=(hardfreq[CLK16K]+hardfreq[CLK12K])>>1) {
   8.360 +		numfreq=CLK16K;		/* 16390 */
   8.361 +	} else if (spec->freq>=(hardfreq[CLK12K]+hardfreq[CLK10K])>>1) {
   8.362 +		numfreq=CLK12K;		/* 12292 */
   8.363 +	} else if (spec->freq>=(hardfreq[CLK10K]+hardfreq[CLK8K])>>1) {
   8.364 +		numfreq=CLK10K;		/* 9834 */
   8.365 +	} else {
   8.366 +		numfreq=CLK8K;		/* 8195 */
   8.367 +	}				
   8.368 +
   8.369 +	spec->freq=hardfreq[numfreq];
   8.370 +}
   8.371 +
   8.372 +static int Mint_CheckAudio_Gsxb(SDL_AudioSpec *spec)
   8.373 +{
   8.374 +	long snd_format;
   8.375 +	int i, resolution, format_signed, format_bigendian;
   8.376 +
   8.377 +	resolution = spec->format & 0x00ff;
   8.378 +	format_signed = ((spec->format & 0x8000)!=0);
   8.379 +	format_bigendian = ((spec->format & 0x1000)!=0);
   8.380 +
   8.381 +	/* Check formats available */
   8.382 +	snd_format = Sndstatus(SND_QUERYFORMATS);
   8.383 +	switch (resolution) {
   8.384 +		case 8:
   8.385 +			if ((snd_format & SND_FORMAT8)==0) {
   8.386 +				SDL_SetError("Mint_CheckAudio: 8 bits samples not supported");
   8.387 +				return -1;
   8.388 +			}
   8.389 +			snd_format = Sndstatus(SND_QUERY8BIT);
   8.390 +			break;
   8.391 +		case 16:
   8.392 +			if ((snd_format & SND_FORMAT16)==0) {
   8.393 +				SDL_SetError("Mint_CheckAudio: 16 bits samples not supported");
   8.394 +				return -1;
   8.395 +			}
   8.396 +			snd_format = Sndstatus(SND_QUERY16BIT);
   8.397 +			break;
   8.398 +		default:
   8.399 +			SDL_SetError("Mint_CheckAudio: Unsupported sample resolution");
   8.400 +			return -1;
   8.401 +			break;
   8.402 +	}
   8.403 +
   8.404 +	/* Check signed/unsigned format */
   8.405 +	if (format_signed) {
   8.406 +		if (snd_format & SND_FORMATSIGNED) {
   8.407 +			/* Ok */
   8.408 +		} else if (snd_format & SND_FORMATUNSIGNED) {
   8.409 +			/* Give unsigned format */
   8.410 +			spec->format = spec->format & (~0x8000);
   8.411 +		}
   8.412 +	} else {
   8.413 +		if (snd_format & SND_FORMATUNSIGNED) {
   8.414 +			/* Ok */
   8.415 +		} else if (snd_format & SND_FORMATSIGNED) {
   8.416 +			/* Give signed format */
   8.417 +			spec->format |= 0x8000;
   8.418 +		}
   8.419 +	}
   8.420 +
   8.421 +	if (format_bigendian) {
   8.422 +		if (snd_format & SND_FORMATBIGENDIAN) {
   8.423 +			/* Ok */
   8.424 +		} else if (snd_format & SND_FORMATLITTLEENDIAN) {
   8.425 +			/* Give little endian format */
   8.426 +			spec->format = spec->format & (~0x1000);
   8.427 +		}
   8.428 +	} else {
   8.429 +		if (snd_format & SND_FORMATBIGENDIAN) {
   8.430 +			/* Ok */
   8.431 +		} else if (snd_format & SND_FORMATLITTLEENDIAN) {
   8.432 +			/* Give big endian format */
   8.433 +			spec->format |= 0x1000;
   8.434 +		}
   8.435 +	}
   8.436 +	
   8.437 +	/* Only xbios functions available = clone with PC board */
   8.438 +	for (i=0;i<8;i++) {
   8.439 +		hardfreq[i]=MASTERCLOCK_MILAN1/(MASTERPREDIV_MILAN*(i+1));
   8.440 +	}
   8.441 +
   8.442 +	if (spec->freq>=(hardfreq[CLK_44K]+hardfreq[CLK_22K])>>1) {
   8.443 +		numfreq = CLK_44K;	/* 44100 */
   8.444 +	} else if (spec->freq>=(hardfreq[CLK_22K]+hardfreq[CLK_11K])>>1) {
   8.445 +		numfreq = CLK_22K;	/* 22050 */
   8.446 +	} else {
   8.447 +		numfreq = CLK_11K;	/* 11025 */
   8.448 +	}				
   8.449 +
   8.450 +	spec->freq=hardfreq[numfreq];
   8.451 +
   8.452 +	return 0;
   8.453 +}
   8.454 +
   8.455 +static void Mint_InitAudio_Dma8(SDL_AudioSpec *spec)
   8.456 +{
   8.457 +	void *oldpile;
   8.458 +	unsigned long buffer;
   8.459 +	unsigned char mode;
   8.460 +	
   8.461 +	oldpile=(void *)Super(0);
   8.462 +
   8.463 +	/* Stop currently playing sound */
   8.464 +	DMAAUDIO_IO.control=0;
   8.465 +
   8.466 +	/* Set buffer */
   8.467 +	buffer = (unsigned long) SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
   8.468 +	DMAAUDIO_IO.start_high = (buffer>>16) & 255;
   8.469 +	DMAAUDIO_IO.start_mid = (buffer>>8) & 255;
   8.470 +	DMAAUDIO_IO.start_low = buffer & 255;
   8.471 +
   8.472 +	buffer += SDL_MintAudio_audiosize;
   8.473 +	DMAAUDIO_IO.end_high = (buffer>>16) & 255;
   8.474 +	DMAAUDIO_IO.end_mid = (buffer>>8) & 255;
   8.475 +	DMAAUDIO_IO.end_low = buffer & 255;
   8.476 +
   8.477 +	mode = numfreq;
   8.478 +	if (spec->channels==1) {
   8.479 +		mode |= 1<<7;
   8.480 +	}
   8.481 +	DMAAUDIO_IO.mode = mode;	
   8.482 +
   8.483 +	/* Set interrupt */
   8.484 +	Jdisint(MFP_DMASOUND);
   8.485 +	Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_IntDma);
   8.486 +	Jenabint(MFP_DMASOUND);
   8.487 +
   8.488 +	/* Go */
   8.489 +	DMAAUDIO_IO.control = 3;	/* playback + repeat */
   8.490 +
   8.491 +	Super(oldpile);
   8.492 +}
   8.493 +
   8.494 +static void Mint_InitAudio_Xbios(SDL_AudioSpec *spec)
   8.495 +{
   8.496 +	int channels_mode;
   8.497 +	void *buffer;
   8.498 +
   8.499 +	/* Stop currently playing sound */
   8.500 +	Buffoper(0);
   8.501 +
   8.502 +	Settracks(0,0);
   8.503 +	Setmontracks(0);
   8.504 +
   8.505 +	switch (spec->format & 0xff) {
   8.506 +		case 8:
   8.507 +			if (spec->channels==2) {
   8.508 +				channels_mode=STEREO8;
   8.509 +			} else {
   8.510 +				channels_mode=MONO8;
   8.511 +			}
   8.512 +			break;
   8.513 +		case 16:
   8.514 +		default:
   8.515 +			channels_mode=STEREO16;
   8.516 +			break;
   8.517 +	}
   8.518 +	Setmode(channels_mode);
   8.519 +
   8.520 +	Devconnect(DMAPLAY, DAC, CLK25M, numfreq, 1);
   8.521 +
   8.522 +	/* Set buffer */
   8.523 +	buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
   8.524 +	Setbuffer(0, buffer, buffer+SDL_MintAudio_audiosize);
   8.525 +	
   8.526 +	/* Install interrupt */
   8.527 +	Setinterrupt(SI_TIMERA, SI_PLAY);
   8.528 +
   8.529 +	Jdisint(MFP_DMASOUND);
   8.530 +	Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_IntXbios);
   8.531 +	Jenabint(MFP_DMASOUND);
   8.532 +
   8.533 +	/* Go */
   8.534 +	Buffoper(SB_PLA_ENA|SB_PLA_RPT);
   8.535 +}
   8.536 +
   8.537 +static void Mint_InitAudio_Gsxb(SDL_AudioSpec *spec)
   8.538 +{
   8.539 +	int channels_mode;
   8.540 +	void *buffer;
   8.541 +
   8.542 +	/* Stop currently playing sound */
   8.543 +	Buffoper(0);
   8.544 +
   8.545 +	switch (spec->format & 0xff) {
   8.546 +		case 8:
   8.547 +			if (spec->channels==2) {
   8.548 +				channels_mode=STEREO8;
   8.549 +			} else {
   8.550 +				channels_mode=MONO8;
   8.551 +			}
   8.552 +			break;
   8.553 +		case 16:
   8.554 +			if (spec->channels==2) {
   8.555 +				channels_mode=STEREO16;
   8.556 +			} else {
   8.557 +				channels_mode=MONO16;
   8.558 +			}
   8.559 +			break;
   8.560 +		default:
   8.561 +			channels_mode=STEREO16;
   8.562 +			break;
   8.563 +	}
   8.564 +	Setmode(channels_mode);
   8.565 +
   8.566 +	Devconnect(0, 0, CLKEXT, numfreq, 1);
   8.567 +
   8.568 +	/* Set buffer */
   8.569 +	buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
   8.570 +	Setbuffer(0, buffer, buffer+SDL_MintAudio_audiosize);
   8.571 +	
   8.572 +	/* Install interrupt */
   8.573 +	NSetinterrupt(2, SI_PLAY, SDL_MintAudio_IntGsxb);
   8.574 +		
   8.575 +	/* Go */
   8.576 +	Buffoper(SB_PLA_ENA|SB_PLA_RPT);
   8.577 +}
   8.578 +
   8.579 +static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec)
   8.580 +{
   8.581 +	/* Lock sound system */
   8.582 +	if ((cookie_snd & SND_16BIT)!=0) {
   8.583 +		if (Locksnd()!=1) {
   8.584 +    	    SDL_SetError("Mint_OpenAudio: Audio system already in use");
   8.585 +	        return(-1);
   8.586 +		}
   8.587 +	}
   8.588 +
   8.589 +	/* Check audio capabilities */
   8.590 +	if (cookie_gsxb && ((cookie_snd & (SND_GSXB|SND_16BIT))==(SND_GSXB|SND_16BIT)) ) {
   8.591 +		if (Mint_CheckAudio_Gsxb(spec)==-1) {
   8.592 +			return -1;
   8.593 +		}
   8.594 +	} else if ((cookie_snd & SND_16BIT)!=0) {
   8.595 +		Mint_CheckAudio_Xbios(spec);
   8.596 +	} else if ((cookie_snd & SND_8BIT)!=0) {
   8.597 +		Mint_CheckAudio_Dma8(spec);
   8.598 +	}
   8.599 +
   8.600 +	SDL_CalculateAudioSpec(spec);
   8.601 +
   8.602 +	/* Allocate memory for audio buffers in DMA-able RAM */
   8.603 +	spec->size = spec->samples;
   8.604 +	spec->size *= spec->channels;
   8.605 +	spec->size *= (spec->format & 0xFF)/8;
   8.606 +
   8.607 +	SDL_MintAudio_audiosize = spec->size;
   8.608 +
   8.609 +	SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(SDL_MintAudio_audiosize *2, MX_STRAM);
   8.610 +	if (SDL_MintAudio_audiobuf[0]==NULL) {
   8.611 +		SDL_SetError("MINT_OpenAudio: Not enough memory for audio buffer");
   8.612 +		return (-1);
   8.613 +	}
   8.614 +	SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + SDL_MintAudio_audiosize;
   8.615 +	SDL_MintAudio_numbuf=0;
   8.616 +	memset(SDL_MintAudio_audiobuf[0], 0, SDL_MintAudio_audiosize * 2);
   8.617 +	SDL_MintAudio_mutex = 0;
   8.618 +
   8.619 +	SDL_MintAudio_device = this;
   8.620 +
   8.621 +	/* Setup audio hardware */
   8.622 +	if (cookie_gsxb && ((cookie_snd & (SND_GSXB|SND_16BIT))==(SND_GSXB|SND_16BIT)) ) {
   8.623 +		Mint_InitAudio_Gsxb(spec);
   8.624 +	} else if ((cookie_snd & SND_16BIT)!=0) {
   8.625 +		Mint_InitAudio_Xbios(spec);
   8.626 +	} else if ((cookie_snd & SND_8BIT)!=0) {
   8.627 +		Mint_InitAudio_Dma8(spec);
   8.628 +	}
   8.629 +
   8.630 +    return 1;
   8.631 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/src/audio/mint/SDL_mintaudio.h	Mon Jun 10 20:42:53 2002 +0000
     9.3 @@ -0,0 +1,15 @@
     9.4 +/*
     9.5 + * MiNT audio driver
     9.6 + * 
     9.7 + * Patrice Mandin
     9.8 + */
     9.9 +
    9.10 +#ifndef _SDL_mintaudio_h
    9.11 +#define _SDL_mintaudio_h
    9.12 +
    9.13 +#include "SDL_sysaudio.h"
    9.14 +
    9.15 +/* Hidden "this" pointer for the audio functions */
    9.16 +#define _THIS	SDL_AudioDevice *this
    9.17 +
    9.18 +#endif /* _SDL_mintaudio_h */
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/src/audio/mint/SDL_mintaudiodma.h	Mon Jun 10 20:42:53 2002 +0000
    10.3 @@ -0,0 +1,43 @@
    10.4 +/*
    10.5 + * STE/TT 8 bits audio dma registers
    10.6 + * 
    10.7 + * Patrice Mandin
    10.8 + */
    10.9 +
   10.10 +#ifndef _SDL_mintdma_h
   10.11 +#define _SDL_mintdma_h
   10.12 +
   10.13 +#define DMAAUDIO_IO_BASE (0xffff8900)
   10.14 +struct DMAAUDIO_IO_S {
   10.15 +	unsigned char int_ctrl;
   10.16 +	unsigned char control;
   10.17 +
   10.18 +	unsigned char dummy1;
   10.19 +	unsigned char start_high;
   10.20 +	unsigned char dummy2;
   10.21 +	unsigned char start_mid;
   10.22 +	unsigned char dummy3;
   10.23 +	unsigned char start_low;
   10.24 +
   10.25 +	unsigned char dummy4;
   10.26 +	unsigned char cur_high;
   10.27 +	unsigned char dummy5;
   10.28 +	unsigned char cur_mid;
   10.29 +	unsigned char dummy6;
   10.30 +	unsigned char cur_low;
   10.31 +
   10.32 +	unsigned char dummy7;
   10.33 +	unsigned char end_high;
   10.34 +	unsigned char dummy8;
   10.35 +	unsigned char end_mid;
   10.36 +	unsigned char dummy9;
   10.37 +	unsigned char end_low;
   10.38 +
   10.39 +	unsigned char dummy10[12];
   10.40 +
   10.41 +	unsigned char track_select; /* CODEC only */
   10.42 +	unsigned char mode;
   10.43 +};
   10.44 +#define DMAAUDIO_IO ((*(volatile struct DMAAUDIO_IO_S *)DMAAUDIO_IO_BASE))
   10.45 +
   10.46 +#endif /* _SDL_mintdma_h */
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/src/audio/mint/SDL_mintaudiogsxb.h	Mon Jun 10 20:42:53 2002 +0000
    11.3 @@ -0,0 +1,85 @@
    11.4 +/*
    11.5 + * GSXB audio definitions
    11.6 + * 
    11.7 + * Patrice Mandin
    11.8 + */
    11.9 +
   11.10 +#ifndef _SDL_mintgsxb_h
   11.11 +#define _SDL_mintgsxb_h
   11.12 +
   11.13 +#include <mint/falcon.h>	/* for trap_14_xxx macros */
   11.14 +
   11.15 +/* GSXB Cookie */
   11.16 +
   11.17 +#define C_GSXB		0x47535842L
   11.18 +
   11.19 +/* Bit 5 in cookie _SND */
   11.20 +
   11.21 +#define SND_GSXB	(1<<5)
   11.22 +
   11.23 +/* NSoundcmd modes */
   11.24 +
   11.25 +#define SETRATE			7	/* Set sample rate */
   11.26 +#define SET8BITFORMAT	8	/* 8 bits format */
   11.27 +#define SET16BITFORMAT	9	/* 16 bits format */
   11.28 +#define SET24BITFORMAT	10	/* 24 bits format */
   11.29 +#define SET32BITFORMAT	11	/* 32 bits format */
   11.30 +#define LTATTEN_MASTER	12	/* Attenuation */
   11.31 +#define RTATTEN_MASTER	13
   11.32 +#define LTATTEN_MICIN	14
   11.33 +#define RTATTEN_MICIN	15
   11.34 +#define LTATTEN_FMGEN	16
   11.35 +#define RTATTEN_FMGEN	17
   11.36 +#define LTATTEN_LINEIN	18
   11.37 +#define RTATTEN_LINEIN	19
   11.38 +#define LTATTEN_CDIN	20
   11.39 +#define RTATTEN_CDIN	21
   11.40 +#define LTATTEN_VIDIN	22
   11.41 +#define RTATTEN_VIDIN	23
   11.42 +#define LTATTEN_AUXIN	24
   11.43 +#define RTATTEN_AUXIN	25
   11.44 +
   11.45 +/* Setmode modes */
   11.46 +
   11.47 +#define MONO16		3
   11.48 +#define STEREO24	4
   11.49 +#define STEREO32	5
   11.50 +#define MONO24		6
   11.51 +#define MONO32		7
   11.52 +
   11.53 +/* Sndstatus modes */
   11.54 +
   11.55 +#define SND_QUERYFORMATS	2
   11.56 +#define SND_QUERYMIXERS		3
   11.57 +#define SND_QUERYSOURCES	4
   11.58 +#define SND_QUERYDUPLEX		5
   11.59 +#define SND_QUERY8BIT		8
   11.60 +#define SND_QUERY16BIT		9
   11.61 +#define SND_QUERY24BIT		10
   11.62 +#define SND_QUERY32BIT		11
   11.63 +
   11.64 +#define SND_FORMAT8		(1<<0)
   11.65 +#define SND_FORMAT16	(1<<1)
   11.66 +#define SND_FORMAT24	(1<<2)
   11.67 +#define SND_FORMAT32	(1<<3)
   11.68 +
   11.69 +#define SND_FORMATSIGNED		(1<<0)
   11.70 +#define SND_FORMATUNSIGNED		(1<<1)
   11.71 +#define SND_FORMATBIGENDIAN		(1<<2)
   11.72 +#define SND_FORMATLITTLEENDIAN	(1<<3)
   11.73 +
   11.74 +/* Devconnect prescalers */
   11.75 +
   11.76 +#define CLK_44K		1
   11.77 +#define CLK_22K		3
   11.78 +#define CLK_11K		7
   11.79 +
   11.80 +/* Extra xbios functions */
   11.81 +
   11.82 +#define NSoundcmd(mode,data,data2)	\
   11.83 +	(long)trap_14_wwl((short)130,(short)(mode),(short)(data),(long)(data2))
   11.84 +#define NSetinterrupt(src_inter,cause,inth_addr)	\
   11.85 +	(long)trap_14_wwwl((short)135,(short)(src_inter),(short)(cause),	\
   11.86 +		(long)(inth_addr))
   11.87 +
   11.88 +#endif /* _SDL_mintgsxb_h */
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/audio/mint/SDL_mintaudiointerrupt.S	Mon Jun 10 20:42:53 2002 +0000
    12.3 @@ -0,0 +1,183 @@
    12.4 +/*
    12.5 + *	Audio interrupt routines
    12.6 + *
    12.7 + *	Patrice Mandin
    12.8 + */
    12.9 +
   12.10 +	.text
   12.11 +
   12.12 +	.globl	_SDL_MintAudio_Callback
   12.13 +
   12.14 +	.globl	_SDL_MintAudio_IntDma
   12.15 +	.globl	_SDL_MintAudio_IntXbios
   12.16 +	.globl	_SDL_MintAudio_IntGsxb
   12.17 +
   12.18 +	.globl	_SDL_MintAudio_mutex
   12.19 +	.globl	_SDL_MintAudio_audiobuf
   12.20 +	.globl	_SDL_MintAudio_numbuf
   12.21 +	.globl	_SDL_MintAudio_audiosize
   12.22 +
   12.23 +/*
   12.24 +	How it works:
   12.25 +	- Audio is playing buffer #0 (resp. #1)
   12.26 +	- We must calculate a sample in buffer #1 (resp. #0)
   12.27 +	  so we first call the callback to do it
   12.28 +	- Then we swap the buffers
   12.29 +*/
   12.30 +
   12.31 +/*--- DMA 8 bits interrupt vector ---*/
   12.32 +
   12.33 +	.text
   12.34 +_SDL_MintAudio_IntDma:
   12.35 +
   12.36 +	/* Check if we are not already running */
   12.37 +	tstw	_SDL_MintAudio_mutex
   12.38 +	bnes	intdma_end
   12.39 +	notw	_SDL_MintAudio_mutex
   12.40 +	
   12.41 +	/* Reenable interrupts */
   12.42 +	movew	#0x2300,sr
   12.43 +
   12.44 +	/* Swap buffers */
   12.45 +	moveml	d0-d1/a0-a1,sp@-
   12.46 +
   12.47 +	movel	_SDL_MintAudio_numbuf,d0
   12.48 +	movel	_SDL_MintAudio_audiobuf,d1
   12.49 +	eorl	#1,d0
   12.50 +	beqs	intdma_buffer0
   12.51 +	movel	_SDL_MintAudio_audiobuf+4,d1
   12.52 +intdma_buffer0:
   12.53 +	movel	d0,_SDL_MintAudio_numbuf
   12.54 +
   12.55 +	/* Callback */
   12.56 +	movel	d1,sp@-
   12.57 +	jsr	_SDL_MintAudio_Callback
   12.58 +	movel	sp@+,d1
   12.59 +
   12.60 +	/* Modify DMA addresses */
   12.61 +	lea	0xffff8900:w,a0
   12.62 +
   12.63 +	moveb	d1,a0@(0x07)	/* Start address */
   12.64 +	rorl	#8,d1
   12.65 +	moveb	d1,a0@(0x05)
   12.66 +	rorl	#8,d1
   12.67 +	moveb	d1,a0@(0x03)
   12.68 +	swap	d1
   12.69 +
   12.70 +	addl	_SDL_MintAudio_audiosize,d1
   12.71 +
   12.72 +	moveb	d1,a0@(0x13)	/* End address */
   12.73 +	rorl	#8,d1
   12.74 +	moveb	d1,a0@(0x11)
   12.75 +	rorl	#8,d1
   12.76 +	moveb	d1,a0@(0x0f)
   12.77 +
   12.78 +	moveml	sp@+,d0-d1/a0-a1
   12.79 +
   12.80 +	clrw	_SDL_MintAudio_mutex
   12.81 +intdma_end:
   12.82 +	bclr	#5,0xfffffa0f:w
   12.83 +	rte
   12.84 +
   12.85 +/*--- Xbios interrupt vector ---*/
   12.86 +
   12.87 +	.text
   12.88 +_SDL_MintAudio_IntXbios:
   12.89 +
   12.90 +	/* Check if we are not already running */
   12.91 +	tstw	_SDL_MintAudio_mutex
   12.92 +	bnes	intxbios_end
   12.93 +	notw	_SDL_MintAudio_mutex
   12.94 +	
   12.95 +	/* Reenable interrupts */
   12.96 +	movew	#0x2300,sr
   12.97 +
   12.98 +	/* Swap buffers */
   12.99 +	moveml	d0-d2/a0-a2,sp@-
  12.100 +
  12.101 +	movel	_SDL_MintAudio_numbuf,d0
  12.102 +	movel	_SDL_MintAudio_audiobuf,a0
  12.103 +	eorl	#1,d0
  12.104 +	beqs	intxbios_buffer0
  12.105 +	movel	_SDL_MintAudio_audiobuf+4,a0
  12.106 +intxbios_buffer0:
  12.107 +	movel	d0,_SDL_MintAudio_numbuf
  12.108 +
  12.109 +	/* Callback */
  12.110 +	moveml	a0,sp@-
  12.111 +	jsr	_SDL_MintAudio_Callback
  12.112 +	moveml	sp@+,a0
  12.113 +
  12.114 +	/* Setbuffer xbios function */
  12.115 +	movel	_SDL_MintAudio_audiosize,d1
  12.116 +	lea	a0@(0,d1:l),a1
  12.117 +
  12.118 +	movel	a1,sp@-
  12.119 +	movel	a0,sp@-
  12.120 +	clrw	sp@-
  12.121 +	movew	#131,sp@-
  12.122 +	trap	#14
  12.123 +	lea	sp@(12),sp
  12.124 +
  12.125 +	moveml	sp@+,d0-d2/a0-a2
  12.126 +
  12.127 +	clrw	_SDL_MintAudio_mutex
  12.128 +intxbios_end:
  12.129 +	bclr	#5,0xfffffa0f:w
  12.130 +	rte
  12.131 +
  12.132 +/*--- GSXB interrupt vector ---*/
  12.133 +
  12.134 +	.text
  12.135 +_SDL_MintAudio_IntGsxb:
  12.136 +
  12.137 +	/* Check if we are not already running */
  12.138 +	tstw	_SDL_MintAudio_mutex
  12.139 +	bnes	intgsxb_end
  12.140 +	notw	_SDL_MintAudio_mutex
  12.141 +
  12.142 +	/* Swap buffers */
  12.143 +	moveml	d0-d2/a0-a2,sp@-
  12.144 +
  12.145 +	movel	_SDL_MintAudio_numbuf,d0
  12.146 +	movel	_SDL_MintAudio_audiobuf,a0
  12.147 +	eorl	#1,d0
  12.148 +	beqs	intgsxb_buffer0
  12.149 +	movel	_SDL_MintAudio_audiobuf+4,a0
  12.150 +intgsxb_buffer0:
  12.151 +	movel	d0,_SDL_MintAudio_numbuf
  12.152 +
  12.153 +	/* Callback */
  12.154 +	moveml	a0,sp@-
  12.155 +	jsr	_SDL_MintAudio_Callback
  12.156 +	moveml	sp@+,a0
  12.157 +
  12.158 +	/* Setbuffer xbios function */
  12.159 +	movel	_SDL_MintAudio_audiosize,d1
  12.160 +	lea	a0@(0,d1:l),a1
  12.161 +
  12.162 +	movel	a1,sp@-
  12.163 +	movel	a0,sp@-
  12.164 +	clrw	sp@-
  12.165 +	movew	#131,sp@-
  12.166 +	trap	#14
  12.167 +	lea	sp@(12),sp
  12.168 +
  12.169 +	moveml	sp@+,d0-d2/a0-a2
  12.170 +
  12.171 +	clrw	_SDL_MintAudio_mutex
  12.172 +intgsxb_end:
  12.173 +	rts
  12.174 +
  12.175 +/*--- Common variables ---*/
  12.176 +
  12.177 +	.data
  12.178 +	.even
  12.179 +	.comm	_SDL_MintAudio_mutex,4
  12.180 +	.even
  12.181 +	.comm	_SDL_MintAudio_audiobuf,8
  12.182 +	.even
  12.183 +	.comm	_SDL_MintAudio_numbuf,4
  12.184 +	.even
  12.185 +	.comm	_SDL_MintAudio_audiosize,4
  12.186 +
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/audio/mint/SDL_mintaudiointerrupt_s.h	Mon Jun 10 20:42:53 2002 +0000
    13.3 @@ -0,0 +1,24 @@
    13.4 +/*
    13.5 + *	Audio interrupt
    13.6 + *
    13.7 + *	Patrice Mandin
    13.8 + */
    13.9 +
   13.10 +#ifndef _SDL_MINTAUDIOINTERRUPT_S_H_
   13.11 +#define _SDL_MINTAUDIOINTERRUPT_S_H_
   13.12 +
   13.13 +#include "SDL_types.h"
   13.14 +
   13.15 +/* Variables */
   13.16 +
   13.17 +extern void *SDL_MintAudio_audiobuf[2];	/* Pointers to buffers */
   13.18 +extern long SDL_MintAudio_audiosize;	/* Length of audio buffer */
   13.19 +extern long SDL_MintAudio_numbuf;		/* Buffer to play */
   13.20 +extern long SDL_MintAudio_mutex;
   13.21 +
   13.22 +/* Functions */
   13.23 +void SDL_MintAudio_IntDma(void);
   13.24 +void SDL_MintAudio_IntXbios(void);
   13.25 +void SDL_MintAudio_IntGsxb(void);
   13.26 +
   13.27 +#endif /* _SDL_MINTAUDIOINTERRUPT_S_H_ */