#NO_APP
gcc2_compiled.:
___gnu_compiled_c:
.text
LC0:
	.ascii "$Id: sound_falcon.s,v 1.1 1998/02/21 14:47:19 david Exp $\0"
.data
	.even
_rcsid:
	.long LC0
	.even
_sound_enabled:
	.long 0
	.even
_dsp_sample_rate:
	.long 12517
	.even
_sndbufsize:
	.long 628
	.even
_AUDCTL:
	.long 0
	.even
_AUDF:
	.long 0
	.long 0
	.long 0
	.long 0
	.even
_AUDC:
	.long 0
	.long 0
	.long 0
	.long 0
.globl _DMActrlptr
	.even
_DMActrlptr:
	.long 16746752
.text
	.even
.globl _Setbuffer
_Setbuffer:
	link a6,#0
	movel d2,sp@-
	movel _DMActrlptr,a0
	addqw #2,a0
	movel a6@(8),d1
	movel d1,d0
	swap d0
	extl d0
	movew d0,d2
	andw #255,d2
	movew d2,a0@
	movel _DMActrlptr,a0
	addqw #4,a0
	movel a6@(8),d1
	movel d1,d0
	asrl #8,d0
	movew d0,d2
	andw #255,d2
	movew d2,a0@
	movel _DMActrlptr,a0
	addqw #6,a0
	movew a6@(10),d2
	andw #255,d2
	movew d2,a0@
	movel _DMActrlptr,a1
	lea a1@(14),a0
	movel a6@(12),d1
	movel d1,d0
	swap d0
	extl d0
	movew d0,d2
	andw #255,d2
	movew d2,a0@
	movel _DMActrlptr,a1
	lea a1@(16),a0
	movel a6@(12),d1
	movel d1,d0
	asrl #8,d0
	movew d0,d2
	andw #255,d2
	movew d2,a0@
	movel _DMActrlptr,a1
	lea a1@(18),a0
	movew a6@(14),d2
	andw #255,d2
	movew d2,a0@
L1:
	movel a6@(-4),d2
	unlk a6
	rts
.data
	.even
_even.4:
	.long 0
.text
	.even
_new_timer_A:
	link a6,#-72
#APP
	movew %sr,d1
	movew #0x2500,%sr
#NO_APP
	movel d1,a6@(-4)
	lea a6@(-68),a0
	movel a0,a6@(-72)
#APP
	moveml %a0-%a7/%d0-%d7,a6@(-72)
#NO_APP
	tstl _even.4
	jeq L3
	movel _sndbufsize,sp@-
	movel _dsp_buffer2,sp@-
	jbsr _Setbuffer
	addqw #8,sp
	moveq #0,d0
	movew _sndbufsize+2,d0
	movel d0,sp@-
	movel _dsp_buffer1,sp@-
	jbsr _Pokey_process
	addqw #8,sp
	clrl _even.4
	jra L4
L3:
	movel _sndbufsize,sp@-
	movel _dsp_buffer1,sp@-
	jbsr _Setbuffer
	addqw #8,sp
	moveq #0,d0
	movew _sndbufsize+2,d0
	movel d0,sp@-
	movel _dsp_buffer2,sp@-
	jbsr _Pokey_process
	addqw #8,sp
	moveq #1,d1
	movel d1,_even.4
L4:
	movel a6@(-4),d1
#APP
	movew d1,%sr
	rte
#NO_APP
L2:
	unlk a6
	rts
	.even
.globl _DMAcontrol
_DMAcontrol:
	link a6,#0
	movel _DMActrlptr,a0
	movew a6@(10),a0@
L5:
	unlk a6
	rts
	.even
.globl _Soundcontrol
_Soundcontrol:
	link a6,#0
	movel _DMActrlptr,a1
	lea a1@(32),a0
	movew a6@(10),d0
	orw #128,d0
	movew d0,a0@
L6:
	unlk a6
	rts
	.even
.globl _MPF_IRQ_on
_MPF_IRQ_on:
	link a6,#0
	moveb 16775687,_old_iea
	moveb 16775699,_old_ima
	moveb 16775711,_old_tadata
	moveb 16775705,_old_tactrl
	moveb 16775703,_old_ivector
	andb #247,16775703
	andb #223,16775687
	movel 308:w,_old_timer_A
	movel #_new_timer_A,308:w
	orb #32,16775687
	orb #32,16775699
	moveb #1,16775711
	moveb #8,16775705
L7:
	unlk a6
	rts
	.even
.globl _MPF_IRQ_off
_MPF_IRQ_off:
	link a6,#-4
#APP
	movew %sr,d0
	movew #0x2500,%sr
#NO_APP
	movel d0,a6@(-4)
	andb #223,16775687
	movel _old_timer_A,308:w
	moveb _old_iea,16775687
	moveb _old_ima,16775699
	moveb _old_tadata,16775711
	moveb _old_tactrl,16775705
	moveb _old_ivector,16775703
	movel a6@(-4),d0
#APP
	movew d0,%sr
#NO_APP
L8:
	unlk a6
	rts
LC1:
	.ascii "-sound\0"
LC2:
	.ascii "-nosound\0"
LC3:
	.ascii "can't allocate sound buffer\12\0"
	.even
.globl _Sound_Initialise
_Sound_Initialise:
	link a6,#-16
	moveml #0x3820,sp@-
	nop
	moveq #1,d3
	movel d3,a6@(-8)
	moveq #1,d4
	movel d4,a6@(-4)
L10:
	movel a6@(8),a0
	movel a6@(-4),d3
	cmpl a0@,d3
	jlt L13
	jra L11
L13:
	pea LC1
	movel a6@(-4),d0
	movel d0,d1
	movel d1,d0
	asll #2,d0
	movel a6@(12),a0
	movel a0@(d0:l),sp@-
	jbsr _strcmp
	addqw #8,sp
	tstl d0
	jne L14
	moveq #1,d4
	movel d4,_sound_enabled
	jra L15
L14:
	pea LC2
	movel a6@(-4),d0
	movel d0,d1
	movel d1,d0
	asll #2,d0
	movel a6@(12),a0
	movel a0@(d0:l),sp@-
	jbsr _strcmp
	addqw #8,sp
	tstl d0
	jne L16
	clrl _sound_enabled
	jra L17
L16:
	movel a6@(-8),d0
	movel d0,d1
	movel d1,d0
	asll #2,d0
	movel a6@(12),a0
	movel a6@(-4),d1
	movel d1,d2
	movel d2,d1
	asll #2,d1
	movel a6@(12),a1
	movel a1@(d1:l),a0@(d0:l)
	addql #1,a6@(-8)
L17:
L15:
L12:
	addql #1,a6@(-4)
	jra L10
L11:
	movel a6@(8),a0
	movel a6@(-8),a0@
	tstl _sound_enabled
	jeq L18
	movel _sndbufsize,d1
	movel d1,d0
	movel d0,d3
	addl d1,d3
	movel d3,a6@(-12)
	clrw a6@(-14)
	movel a6@(-12),d4
	movew a6@(-14),d3
#APP
			movw    d3,sp@-; 		movl    d4,sp@-; 		movw    #68,sp@-; 		trap    #1;			addqw   #8,sp 
#NO_APP
	movel d0,_dsp_buffer1
	movel _dsp_buffer1,d0
	addl _sndbufsize,d0
	movel d0,d1
	movel d1,_dsp_endbuf1
	movel d1,_dsp_buffer2
	movel _dsp_buffer2,d4
	addl _sndbufsize,d4
	movel d4,_dsp_endbuf2
	tstl _dsp_buffer1
	jne L19
	pea LC3
	jbsr _printf
	addqw #4,sp
	pea 1:w
	jbsr _exit
	addqw #4,sp
L19:
	pea 1:w
	moveq #0,d0
	movew _dsp_sample_rate+2,d0
	movel d0,sp@-
	movel #1789790,sp@-
	jbsr _Pokey_sound_init
	addw #12,sp
	jbsr _MFP_IRQ_on
	pea 1:w
	jbsr _Soundcontrol
	addqw #4,sp
	pea 3:w
	jbsr _DMAcontrol
	addqw #4,sp
L18:
L9:
	moveml a6@(-32),#0x41c
	unlk a6
	rts
	.even
.globl _Sound_Exit
_Sound_Exit:
	link a6,#-4
	moveml #0x3020,sp@-
	tstl _sound_enabled
	jeq L21
	clrl sp@-
	jbsr _DMAcontrol
	addqw #4,sp
	jbsr _MFP_IRQ_off
	movel _dsp_buffer1,a6@(-4)
	movel a6@(-4),d3
#APP
			movl	d3,sp@-; 		movw    #73,sp@-; 		trap    #1;			addqw   #6,sp 
#NO_APP
L21:
L20:
	moveml a6@(-16),#0x40c
	unlk a6
	rts
	.even
.globl _Sound_UpdateSound
_Sound_UpdateSound:
	link a6,#0
L22:
	unlk a6
	rts
	.even
.globl _Atari_AUDC
_Atari_AUDC:
	link a6,#0
	subql #1,a6@(8)
	pea 4:w
	clrl sp@-
	moveq #0,d0
	moveb a6@(15),d0
	movel d0,sp@-
	movew a6@(10),d0
	addw #-11775,d0
	movew d0,d1
	addw a6@(10),d1
	moveq #0,d0
	movew d1,d0
	movel d0,sp@-
	jbsr _Update_pokey_sound
	addw #16,sp
L23:
	unlk a6
	rts
	.even
.globl _Atari_AUDF
_Atari_AUDF:
	link a6,#0
	subql #1,a6@(8)
	pea 4:w
	clrl sp@-
	moveq #0,d0
	moveb a6@(15),d0
	movel d0,sp@-
	movew a6@(10),d0
	addw #-11776,d0
	movew d0,d1
	addw a6@(10),d1
	moveq #0,d0
	movew d1,d0
	movel d0,sp@-
	jbsr _Update_pokey_sound
	addw #16,sp
L24:
	unlk a6
	rts
	.even
.globl _Atari_AUDCTL
_Atari_AUDCTL:
	link a6,#0
	pea 4:w
	clrl sp@-
	moveq #0,d0
	moveb a6@(11),d0
	movel d0,sp@-
	movel #53768,sp@-
	jbsr _Update_pokey_sound
	addw #16,sp
L25:
	unlk a6
	rts
.lcomm _dsp_buffer1,4
.lcomm _dsp_endbuf1,4
.lcomm _dsp_buffer2,4
.lcomm _dsp_endbuf2,4
.comm _old_timer_A,4
.comm _old_tactrl,2
.comm _old_tadata,2
.comm _old_ivector,2
.comm _old_iea,2
.comm _old_isra,2
.comm _old_ima,2
