src/audio/mint/SDL_mintaudio_it.S
author Patrice Mandin <patmandin@gmail.com>
Sun, 17 Jul 2005 07:11:43 +0000
changeset 1093 d00b4d8508ab
parent 961 185acc07127a
child 1096 37b766becf3b
permissions -rw-r--r--
Save all registers on interrupt
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
     1
/*
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
     3
    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
     4
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
     6
    modify it under the terms of the GNU Library General Public
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
     8
    version 2 of the License, or (at your option) any later version.
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
     9
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    13
    Library General Public License for more details.
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    14
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    15
    You should have received a copy of the GNU Library General Public
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    16
    License along with this library; if not, write to the Free
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    18
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    19
    Sam Lantinga
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    20
    slouken@libsdl.org
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    21
*/
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    22
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    23
/*
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    24
	Audio interrupts
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    25
961
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 704
diff changeset
    26
	Patrice Mandin, Didier Méquignon
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    27
 */
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    28
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    29
	.text
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    30
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    31
	.globl	_SDL_MintAudio_Callback
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    32
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    33
	.globl	_SDL_MintAudio_GsxbInterrupt
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    34
	.globl	_SDL_MintAudio_EmptyGsxbInterrupt
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    35
	.globl	_SDL_MintAudio_XbiosInterrupt
961
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 704
diff changeset
    36
	.globl	_SDL_MintAudio_XbiosInterruptMeasureClock
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    37
	.globl	_SDL_MintAudio_Dma8Interrupt
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    38
	.globl	_SDL_MintAudio_StfaInterrupt
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    39
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    40
	.globl	_SDL_MintAudio_mutex
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    41
	.globl	_SDL_MintAudio_audiobuf
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    42
	.globl	_SDL_MintAudio_numbuf
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    43
	.globl	_SDL_MintAudio_audiosize
961
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 704
diff changeset
    44
	.globl	_SDL_MintAudio_clocktics
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    45
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    46
	.globl	_SDL_MintAudio_stfa
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    47
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    48
/*
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    49
	How it works:
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    50
	- Audio is playing buffer #0 (resp. #1)
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    51
	- We must calculate a sample in buffer #1 (resp. #0)
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    52
	  so we first call the callback to do it
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    53
	- Then we swap the buffers
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    54
*/
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    55
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    56
/*--- GSXB interrupt vector ---*/
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    57
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    58
	.text
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    59
_SDL_MintAudio_GsxbInterrupt:
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    60
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    61
	/* Check if we are not already running */
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    62
	tstw	_SDL_MintAudio_mutex
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    63
	bnes	_SDL_MintAudio_EmptyGsxbInterrupt
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    64
	notw	_SDL_MintAudio_mutex
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    65
	
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    66
	/* Swap buffers */
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
    67
	eorw	#1,_SDL_MintAudio_numbuf
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    68
1093
d00b4d8508ab Save all registers on interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 961
diff changeset
    69
	moveml	d0-d7/a0-a6,sp@-
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    70
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    71
	/* Callback */
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    72
	jsr	_SDL_MintAudio_Callback
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
    73
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
    74
	/* Set new buffer */
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
    75
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
    76
	moveq	#0,d0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
    77
	movel	_SDL_MintAudio_audiosize,d1
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    78
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
    79
	movew	_SDL_MintAudio_numbuf,d0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
    80
	lsll	#2,d0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
    81
	lea	_SDL_MintAudio_audiobuf,a0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
    82
	movel	a0@(d0:l),a1
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    83
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
    84
	lea	a1@(d1:l),a2
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
    85
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
    86
	movel	a2,sp@-
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    87
	movel	a1,sp@-
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    88
	clrw	sp@-
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    89
	movew	#131,sp@-
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    90
	trap	#14
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    91
	lea	sp@(12),sp
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    92
1093
d00b4d8508ab Save all registers on interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 961
diff changeset
    93
	moveml	sp@+,d0-d7/a0-a6
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    94
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    95
	clrw	_SDL_MintAudio_mutex
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    96
_SDL_MintAudio_EmptyGsxbInterrupt:
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    97
	rts
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
    98
961
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 704
diff changeset
    99
/*--- Xbios interrupt vector to measure Falcon external clock ---*/
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 704
diff changeset
   100
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 704
diff changeset
   101
_SDL_MintAudio_XbiosInterruptMeasureClock:          /* 1 mS */
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 704
diff changeset
   102
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 704
diff changeset
   103
	btst	#0,0xFFFF8901:w	/* state DMA sound */
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 704
diff changeset
   104
	beqs	SDL_MintAudio_EndIntMeasure
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 704
diff changeset
   105
	addql	#1,_SDL_MintAudio_clocktics
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 704
diff changeset
   106
SDL_MintAudio_EndIntMeasure:
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 704
diff changeset
   107
	bclr	#5,0xFFFFFA0F:w	/* Clear service bit */
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 704
diff changeset
   108
	rte
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 704
diff changeset
   109
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   110
/*--- Xbios interrupt vector ---*/
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   111
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   112
_SDL_MintAudio_XbiosInterrupt:
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   113
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   114
	/* Reenable interrupts, so other interrupts can work */
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   115
	movew	#0x2300,sr
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   116
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   117
	/* Clear service bit, so other MFP interrupts can work */
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   118
	bclr	#5,0xfffffa0f:w
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   119
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   120
	/* Check if we are not already running */
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   121
	tstw	_SDL_MintAudio_mutex
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   122
	bnes	SDL_MintAudio_XbiosEnd
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   123
	notw	_SDL_MintAudio_mutex
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   124
	
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   125
	/* Swap buffers */
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   126
	eorw	#1,_SDL_MintAudio_numbuf
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   127
1093
d00b4d8508ab Save all registers on interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 961
diff changeset
   128
	moveml	d0-d7/a0-a6,sp@-
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   129
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   130
	/* Callback */
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   131
	jsr	_SDL_MintAudio_Callback
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   132
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   133
	/* Set new buffer */
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   134
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   135
	moveq	#0,d0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   136
	movel	_SDL_MintAudio_audiosize,d1
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   137
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   138
	movew	_SDL_MintAudio_numbuf,d0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   139
	lsll	#2,d0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   140
	lea	_SDL_MintAudio_audiobuf,a0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   141
	movel	a0@(d0:l),a1
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   142
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   143
	lea	a1@(d1:l),a2
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   144
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   145
	movel	a2,sp@-
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   146
	movel	a1,sp@-
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   147
	clrw	sp@-
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   148
	movew	#131,sp@-
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   149
	trap	#14
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   150
	lea	sp@(12),sp
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   151
1093
d00b4d8508ab Save all registers on interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 961
diff changeset
   152
	moveml	sp@+,d0-d7/a0-a6
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   153
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   154
	clrw	_SDL_MintAudio_mutex
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   155
SDL_MintAudio_XbiosEnd:
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   156
	rte
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   157
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   158
/*--- DMA 8 bits interrupt vector ---*/
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   159
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   160
_SDL_MintAudio_Dma8Interrupt:
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   161
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   162
	/* Reenable interrupts, so other interrupts can work */
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   163
	movew	#0x2300,sr
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   164
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   165
	/* Clear service bit, so other MFP interrupts can work */
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   166
	bclr	#5,0xfffffa0f:w
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   167
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   168
	/* Check if we are not already running */
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   169
	tstw	_SDL_MintAudio_mutex
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   170
	bnes	SDL_MintAudio_Dma8End
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   171
	notw	_SDL_MintAudio_mutex
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   172
	
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   173
	/* Swap buffers */
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   174
	eorw	#1,_SDL_MintAudio_numbuf
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   175
1093
d00b4d8508ab Save all registers on interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 961
diff changeset
   176
	moveml	d0-d7/a0-a6,sp@-
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   177
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   178
	/* Callback */
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   179
	jsr	_SDL_MintAudio_Callback
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   180
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   181
	/* Set new buffer */
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   182
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   183
	moveq	#0,d0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   184
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   185
	movew	_SDL_MintAudio_numbuf,d0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   186
	lslw	#2,d0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   187
	lea	_SDL_MintAudio_audiobuf,a0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   188
	movel	a0@(d0:w),d1
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   189
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   190
	/* Modify DMA addresses */
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   191
	lea	0xffff8900:w,a0
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   192
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   193
	moveb	d1,a0@(0x07)	/* Start address */
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   194
	rorl	#8,d1
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   195
	moveb	d1,a0@(0x05)
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   196
	rorl	#8,d1
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   197
	moveb	d1,a0@(0x03)
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   198
	swap	d1
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   199
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   200
	addl	_SDL_MintAudio_audiosize,d1
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   201
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   202
	moveb	d1,a0@(0x13)	/* End address */
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   203
	rorl	#8,d1
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   204
	moveb	d1,a0@(0x11)
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   205
	rorl	#8,d1
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   206
	moveb	d1,a0@(0x0f)
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   207
1093
d00b4d8508ab Save all registers on interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 961
diff changeset
   208
	moveml	sp@+,d0-d7/a0-a6
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   209
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   210
	clrw	_SDL_MintAudio_mutex
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   211
SDL_MintAudio_Dma8End:
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   212
	rte
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   213
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   214
/*--- STFA interrupt vector ---*/
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   215
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   216
STFA_SOUND_START	=	6
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   217
STFA_SOUND_END		=	STFA_SOUND_START+8
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   218
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   219
_SDL_MintAudio_StfaInterrupt:
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   220
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   221
	/* Reenable interrupts, so other interrupts can work */
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   222
	movew	#0x2300,sr
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   223
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   224
	/* Check if we are not already running */
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   225
	tstw	_SDL_MintAudio_mutex
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   226
	bnes	SDL_MintAudio_StfaEnd
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   227
	notw	_SDL_MintAudio_mutex
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   228
	
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   229
	/* Swap buffers */
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   230
	eorw	#1,_SDL_MintAudio_numbuf
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   231
1093
d00b4d8508ab Save all registers on interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 961
diff changeset
   232
	moveml	d0-d7/a0-a6,sp@-
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   233
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   234
	/* Callback */
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   235
	jsr	_SDL_MintAudio_Callback
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   236
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   237
	/* Set new buffer */
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   238
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   239
	moveq	#0,d0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   240
	movel	_SDL_MintAudio_stfa,a1
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   241
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   242
	movew	_SDL_MintAudio_numbuf,d0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   243
	lslw	#2,d0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   244
	lea	_SDL_MintAudio_audiobuf,a0
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   245
	movel	a0@(d0:w),d1
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   246
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   247
	/* Modify STFA replay buffers */
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   248
	movel	d1,a1@(STFA_SOUND_START)
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   249
	addl	_SDL_MintAudio_audiosize,d1
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
   250
	movel	d1,a1@(STFA_SOUND_END)
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   251
1093
d00b4d8508ab Save all registers on interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 961
diff changeset
   252
	moveml	sp@+,d0-d7/a0-a6
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   253
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   254
	clrw	_SDL_MintAudio_mutex
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   255
SDL_MintAudio_StfaEnd:
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
   256
	rte