
;  GNU C 2.7.2 [AL 1.1, MM 40] RISC NEWS-OS compiled by CC

;  Cc1 defaults:
;  -mmemcpy

;  Cc1 arguments (-G value = 0, Cpu = 3000, ISA = 1):
;  -quiet -dumpbase -O2 -Wall -o

gcc2_compiled.:
__gnu_compiled_c:
	.code
	.align	1
	.global	wsg_mix
wsg_mix:
;	.frame	%sp,68,$31		# vars= 48, regs= 5/0, args= 0, extra= 0
;	.mask	0x800f0000,-4
;	.fmask	0x00000000,0
	pushn	%r3
	sub	%sp,0xc		; 	xsub	%sp,%sp,48
	ld.w	[%sp+0x4],%r12	; 	xld.w	[%sp+16],%r12
	ld.w	[%sp+0x5],%r13	; 	xld.w	[%sp+20],%r13
	ld.w	[%sp+0x6],%r14	; 	xld.w	[%sp+24],%r14
	ld.w	%r15,%r12
	ext	0xd		; 	xadd	%r15,%r15,832
	add	%r15,0x0
	ld.w	[%sp+0x7],%r15	; 	xld.w	[%sp+28],%r15
	ld.w	%r12,%sp
	ld.w	%r13,[%sp+0x4]	; 	xld.w	%r13,[%sp+16]
	ext	0xf		; 	xadd	%r13,%r13,960
	add	%r13,0x0
	ld.w	%r14,0x10	; 	xld.w	%r14,0x00000010		; 16
	ext	memcpy@rm	; 	xcall	memcpy
	call	memcpy@rl
	ld.w	%r15,[%sp+0x6]	; 	xld.w	%r15,[%sp+24]
	cmp	%r15,0x0
	jrle	__LX72		; 	xjrle	__L72
__LX73:				; __L73:
	ld.w	%r3,[%sp+0x2]	; 	xld.w	%r3,[%sp+8]
	ld.w	%r11,[%sp+0x1]	; 	xld.w	%r11,[%sp+4]
	ld.w	%r10,[%sp+0x0]	; 	xld.w	%r10,[%sp]
	add	%r11,%r10
	ld.w	%r10,%r11
	ld.w	[%sp+0x1],%r10	; 	xld.w	[%sp+4],%r10
	cmp	%r10,0x0
	jrlt	__LX74		; 	xjrlt	__L74
	ext	0xfa		; 	xsub	%r10,%r10,16000
	sub	%r10,0x0
	ld.w	[%sp+0x1],%r10	; 	xld.w	[%sp+4],%r10
	add	%r3,0x1		; 	xadd	%r3,%r3,1
__LX74:				; __L74:
	ld.w	%r12,[%sp+0x4]	; 	xld.w	%r12,[%sp+16]
	ld.w	%r13,[%sp+0x7]	; 	xld.w	%r13,[%sp+28]
	ld.w	%r14,%r3
	call	wsg_channel_process	; 	xcall	wsg_channel_process
	ld.w	%r0,%r10
	ld.w	%r12,[%sp+0x4]	; 	xld.w	%r12,[%sp+16]
	ld.w	%r13,[%sp+0x7]	; 	xld.w	%r13,[%sp+28]
	add	%r13,0x10	; 	xadd	%r13,%r13,16
	ld.w	%r14,%r3
	call	wsg_channel_process	; 	xcall	wsg_channel_process
	ld.w	[%sp+0x8],%r10	; 	xld.w	[%sp+32],%r10
	ld.w	%r12,[%sp+0x4]	; 	xld.w	%r12,[%sp+16]
	ld.w	%r13,[%sp+0x7]	; 	xld.w	%r13,[%sp+28]
	add	%r13,0x20	; 	xadd	%r13,%r13,32
	ld.w	%r14,%r3
	call	wsg_channel_process	; 	xcall	wsg_channel_process
	ld.w	[%sp+0x9],%r10	; 	xld.w	[%sp+36],%r10
	ld.w	%r12,[%sp+0x4]	; 	xld.w	%r12,[%sp+16]
	ld.w	%r13,[%sp+0x7]	; 	xld.w	%r13,[%sp+28]
	add	%r13,0x30	; 	xadd	%r13,%r13,48
	ld.w	%r14,%r3
	call	wsg_channel_process	; 	xcall	wsg_channel_process
	ld.w	[%sp+0xa],%r10	; 	xld.w	[%sp+40],%r10
	ld.w	%r12,[%sp+0x4]	; 	xld.w	%r12,[%sp+16]
	ld.w	%r13,[%sp+0x7]	; 	xld.w	%r13,[%sp+28]
	ext	0x1		; 	xadd	%r13,%r13,64
	add	%r13,0x0
	ld.w	%r14,%r3
	call	wsg_channel_process	; 	xcall	wsg_channel_process
	ld.w	[%sp+0xb],%r10	; 	xld.w	[%sp+44],%r10
	ld.w	%r12,[%sp+0x4]	; 	xld.w	%r12,[%sp+16]
	ld.w	%r13,[%sp+0x7]	; 	xld.w	%r13,[%sp+28]
	ext	0x1		; 	xadd	%r13,%r13,80
	add	%r13,0x10
	ld.w	%r14,%r3
	call	wsg_channel_process	; 	xcall	wsg_channel_process
	ld.w	%r2,%r10
	ld.w	%r12,[%sp+0x4]	; 	xld.w	%r12,[%sp+16]
	ld.w	%r13,[%sp+0x7]	; 	xld.w	%r13,[%sp+28]
	ext	0x1		; 	xadd	%r13,%r13,96
	add	%r13,0x20
	ld.w	%r14,%r3
	call	wsg_channel_process	; 	xcall	wsg_channel_process
	ld.w	%r1,%r10
	ld.w	%r12,[%sp+0x4]	; 	xld.w	%r12,[%sp+16]
	ld.w	%r13,[%sp+0x7]	; 	xld.w	%r13,[%sp+28]
	ext	0x1		; 	xadd	%r13,%r13,112
	add	%r13,0x30
	ld.w	%r14,%r3
	call	wsg_channel_process	; 	xcall	wsg_channel_process
	ld.w	%r15,[%sp+0x8]	; 	xld.w	%r15,[%sp+32]
	add	%r0,%r15
	ld.w	%r15,[%sp+0x9]	; 	xld.w	%r15,[%sp+36]
	add	%r0,%r15
	ld.w	%r15,[%sp+0xa]	; 	xld.w	%r15,[%sp+40]
	add	%r0,%r15
	ld.w	%r15,[%sp+0xb]	; 	xld.w	%r15,[%sp+44]
	add	%r0,%r15
	add	%r0,%r2
	add	%r0,%r1
	add	%r0,%r10
	ext	0x1e00		; 	xld.w	%r10,-32767			; 0xffff8001
	ld.w	%r10,0x1
	cmp	%r0,%r10
	jrge	__LX75		; 	xjrge	__L75
	ld.w	%r0,%r10
__LX75:				; __L75:
	ext	0x1ff		; 	xld.w	%r10,0x00007fff		; 32767
	ld.w	%r10,0x3f
	cmp	%r0,%r10
	jrle	__LX76		; 	xjrle	__L76
	ld.w	%r0,%r10
__LX76:				; __L76:
	ld.w	%r15,[%sp+0x5]	; 	xld.w	%r15,[%sp+20]
	ld.h	[%r15],%r0	; 	xld.h	[%r15],%r0
	add	%r15,0x2	; 	xadd	%r15,%r15,2
	ld.w	[%sp+0x5],%r15	; 	xld.w	[%sp+20],%r15
	ld.w	%r15,[%sp+0x6]	; 	xld.w	%r15,[%sp+24]
	sub	%r15,0x1	; 	xsub	%r15,%r15,1
	ld.w	[%sp+0x6],%r15	; 	xld.w	[%sp+24],%r15
	jrgt	__LX73		; 	xjrgt	__L73
__LX72:				; __L72:
	ld.w	%r12,[%sp+0x4]	; 	xld.w	%r12,[%sp+16]
	ext	0xf		; 	xadd	%r12,%r12,960
	add	%r12,0x0
	ld.w	%r13,%sp
	ld.w	%r14,0x10	; 	xld.w	%r14,0x00000010		; 16
	ext	memcpy@rm	; 	xcall	memcpy
	call	memcpy@rl
	add	%sp,0xc		; 	xadd	%sp,%sp,48
	popn	%r3
	ret
; APP
	
	.code
	.align 1
	.global wsg_channel_process
wsg_channel_process:
	ld.w %alr, %r8			; %alr = 0
	ld.uh	%r4,[%r13]	; 	xld.uh %r4, [%r13+0]		; %r4 = volume
	ext	0x4		; 	xld.w  %r5, [%r13+4]		; %r5 = frequency *anti-interlock*
	ld.w	%r5,[%r13]
	cmp	%r4,0x0		; 	xcmp %r4, 0			; if(!volume) return 0
	jreq	wsg_channel_process_exit	; 	xjreq wsg_channel_process_exit
	cmp	%r5,0x0		; 	xcmp %r5, 0			; if(!frequency) return 0
	jreq	wsg_channel_process_exit	; 	xjreq wsg_channel_process_exit
	;
	ext	0x8		; 	xld.w %r6, [%r13+8]		; %r6 = progress
	ld.w	%r6,[%r13]
	ext	0xc		; 	xld.w %r7, [%r13+12]		; %r7 = wave
	ld.w	%r7,[%r13]
	;
	mlt.w %r5, %r14			; progress += frequency * cycle
	ld.w %r5, %alr
	add %r6, %r5
	ext	0x8		; 	xld.w [%r13+8], %r6		; progressŹ‘‚«–ß‚µ
	ld.w	[%r13],%r6
	;
	srl	%r6,0x8		; 	xsrl %r6, 15			; %r10 = sample
	srl	%r6,0x7
	and	%r6,0x1f	; 	xand %r6, %r6, 0x1f
	add %r7, %r6
	ld.b	%r10,[%r7]	; 	xld.b %r10, [%r7]
	mlt.h %r10, %r4			; %alr = sample * volume
	;
wsg_channel_process_exit:
	ret.d
	ld.w %r10, %alr			; *delay* (Undoc'd)

