
;  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	huc6280psg_mix
huc6280psg_mix:
;	.frame	%sp,40,$31		# vars= 20, regs= 5/0, args= 0, extra= 0
;	.mask	0x800f0000,-4
;	.fmask	0x00000000,0
	pushn	%r3
	sub	%sp,0x5		; 	xsub	%sp,%sp,20
	ld.w	%r2,%r12
	ld.w	%r1,%r13
	ld.w	%r0,%r14
	ld.w	%r12,%sp
	ext	0x188		; 	xadd	%r13,%r2,392
	add	%r13,%r2
	ld.w	%r14,0x10	; 	xld.w	%r14,0x00000010		; 16
	ext	memcpy@rm	; 	xcall	memcpy
	call	memcpy@rl
	cmp	%r0,0x0
	jrle	__LX72		; 	xjrle	__L72
	ext	0x1e00		; 	xld.w	%r14,-32767			; 0xffff8001
	ld.w	%r14,0x1
	ext	0x1ff		; 	xld.w	%r3,0x00007fff		; 32767
	ld.w	%r3,0x3f
__LX73:				; __L73:
	ld.w	%r13,[%sp+0x2]	; 	xld.w	%r13,[%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	%r13,0x1	; 	xadd	%r13,%r13,1
__LX74:				; __L74:
	ld.w	%r12,%r2
	ld.w	[%sp+0x4],%r14	; 	xld.w	[%sp+16],%r14
	call	huc6280psg_process	; 	xcall	huc6280psg_process
	sra	%r10,0x5	; 	xsra	%r10,5
	ld.w	%r14,[%sp+0x4]	; 	xld.w	%r14,[%sp+16]
	cmp	%r10,%r14
	jrge	__LX75		; 	xjrge	__L75
	ld.w	%r10,%r14
__LX75:				; __L75:
	cmp	%r10,%r3
	jrle	__LX76		; 	xjrle	__L76
	ld.w	%r10,%r3
__LX76:				; __L76:
	ld.h	[%r1],%r10	; 	xld.h	[%r1],%r10
	add	%r1,0x2		; 	xadd	%r1,%r1,2
	sub	%r0,0x1		; 	xsub	%r0,%r0,1
	jrgt	__LX73		; 	xjrgt	__L73
__LX72:				; __L72:
	ext	0x188		; 	xadd	%r12,%r2,392
	add	%r12,%r2
	ld.w	%r13,%sp
	ld.w	%r14,0x10	; 	xld.w	%r14,0x00000010		; 16
	ext	memcpy@rm	; 	xcall	memcpy
	call	memcpy@rl
	add	%sp,0x5		; 	xadd	%sp,%sp,20
	popn	%r3
	ret
	.align	1
	.global	huc6280psg_process
huc6280psg_process:
;	.frame	%sp,32,$31		# vars= 12, regs= 5/0, args= 0, extra= 0
;	.mask	0x800f0000,-4
;	.fmask	0x00000000,0
	pushn	%r3
	sub	%sp,0x3		; 	xsub	%sp,%sp,12
	ld.w	%r0,%r12
	ld.w	%r2,%r13
	ext	0x8		; 	xadd	%r13,%r0,8
	add	%r13,%r0
	ld.w	%r14,%r2
	call	huc6280psg_channel_process	; 	xcall	huc6280psg_channel_process
	ld.w	%r1,%r10
	ld.w	%r12,%r0
	ext	0x48		; 	xadd	%r13,%r0,72
	add	%r13,%r0
	ld.w	%r14,%r2
	call	huc6280psg_channel_process	; 	xcall	huc6280psg_channel_process
	ld.w	[%sp+0x0],%r10	; 	xld.w	[%sp],%r10
	ld.w	%r12,%r0
	ext	0x88		; 	xadd	%r13,%r0,136
	add	%r13,%r0
	ld.w	%r14,%r2
	call	huc6280psg_channel_process	; 	xcall	huc6280psg_channel_process
	ld.w	[%sp+0x1],%r10	; 	xld.w	[%sp+4],%r10
	ld.w	%r12,%r0
	ext	0xc8		; 	xadd	%r13,%r0,200
	add	%r13,%r0
	ld.w	%r14,%r2
	call	huc6280psg_channel_process	; 	xcall	huc6280psg_channel_process
	ld.w	[%sp+0x2],%r10	; 	xld.w	[%sp+8],%r10
	ld.w	%r12,%r0
	ext	0x108		; 	xadd	%r13,%r0,264
	add	%r13,%r0
	ld.w	%r14,%r2
	call	huc6280psg_channel_process	; 	xcall	huc6280psg_channel_process
	ld.w	%r3,%r10
	ld.w	%r12,%r0
	ext	0x148		; 	xadd	%r13,%r12,328
	add	%r13,%r12
	ld.w	%r14,%r2
	call	huc6280psg_channel_process	; 	xcall	huc6280psg_channel_process
	ld.w	%r11,[%sp+0x0]	; 	xld.w	%r11,[%sp]
	add	%r1,%r11
	ld.w	%r11,[%sp+0x1]	; 	xld.w	%r11,[%sp+4]
	add	%r1,%r11
	ld.w	%r11,[%sp+0x2]	; 	xld.w	%r11,[%sp+8]
	add	%r1,%r11
	add	%r1,%r3
	add	%r1,%r10
	ld.w	%r10,%r1
	add	%sp,0x3		; 	xadd	%sp,%sp,12
	popn	%r3
	ret
; APP
	
	.code
	.align 1
	.global huc6280psg_channel_process
huc6280psg_channel_process:
	ext	0x6		; 	xld.ub %r10, [%r13+6]				; %r10 = channel->enable					| + 6, 1: unsigned char enable
	ld.ub	%r10,[%r13]
	cmp	%r10,0x0	; 	xcmp %r10, 0					; if(!channel->enable) return 0 !INTERLOCK!
	jreq	huc6280psg_channel_process_disable	; 	xjreq huc6280psg_channel_process_disable
	;
	ext	0xa		; 	xld.h %r10, [%r13+10]				; %r10 = channel->volume					| +10, 2: short volume
	ld.h	%r10,[%r13]
	cmp	%r10,0x0	; 	xcmp %r10, 0					; if(!channel->volume) return 0 !INTERLOCK!
	jreq	huc6280psg_channel_process_disable	; 	xjreq huc6280psg_channel_process_disable
	;
	ext	0x7		; 	xbtst [%r13+7], 0				; if(channel->dda) goto huc6280psg_channel_process_dda		| + 7, 1: unsigned char dda
	btst	[%r13],0x0
	jrne	huc6280psg_channel_process_dda	; 	xjrne huc6280psg_channel_process_dda
	;
	ext	0x8		; 	xbtst [%r13+8], 0				; if(channel->noise) goto huc6280psg_channel_process_noise	| + 8, 1: unsigned char noise
	btst	[%r13],0x0
	jrne	huc6280psg_channel_process_noise	; 	xjrne huc6280psg_channel_process_noise
	;
	;/*===== Tone mode =====*/
	ext	0x10		; 	xld.w %r4, [%r13+16]				; %r4 = channel->tone_progress					| +16, 4: int tone_progress
	ld.w	%r4,[%r13]
	ext	0x1c		; 	xld.uh %r5, [%r13+28]				; %r5 = channel->tone_index *anti-interlock*			| +28, 2: unsigned short tone_index
	ld.uh	%r5,[%r13]
	sub %r4, %r14					; channel->tone_progress -= cycle
	jruge	huc6280psg_channel_process_tone_break	; 	xjruge huc6280psg_channel_process_tone_break	; if(!%psr(C)) goto huc6280psg_channel_process_tone_break
	;
	ext	0xc		; 	xld.w %r6, [%r13+12]				; %r6 = channel->tone_period					| +12, 4: int tone_period
	ld.w	%r6,[%r13]
huc6280psg_channel_process_tone_loop:
	add %r4, %r6					; channel->tone_progress += channel->tone_period
	jruge.d	huc6280psg_channel_process_tone_loop	; 	xjruge.d huc6280psg_channel_process_tone_loop	; if(!%psr(C)) goto huc6280psg_channel_process_tone_loop
	add %r5, 1					; channel->tone_index++ *delay*
	ext	0x1c		; 	xld.h [%r13+28], %r5				; (store channel->tone_index)					| +28, 2: unsigned short tone_index
	ld.h	[%r13],%r5
	;
huc6280psg_channel_process_tone_break:
	ext	0x10		; 	xld.w [%r13+16], %r4				; (store channel->tone_progress)				| +16, 4: int tone_progress
	ld.w	[%r13],%r4
	;
	and	%r5,0x1f	; 	xand %r5, %r5, 0x1f				; %r11 = channel->wave[channel->tone_index & 0x1f]
	add	%r5,0x20	; 	xadd %r5, %r5, 32				;								| +32,32: char wave[32]
	add %r5, %r13
	ld.b	%r11,[%r5]	; 	xld.b %r11, [%r5]
	;
	mlt.h %r10, %r11				; %alr = volume * sample !INTERLOCK!
	ret.d
	ld.w %r10, %alr					; %r10 = output *delay*(undoc'd)
	;
	;/*===== Noise mode =====*/
huc6280psg_channel_process_noise:
	ext	0x18		; 	xld.w %r4, [%r13+24]				; %r4 = channel->noise_progress					| +24, 4: int noise_progress
	ld.w	%r4,[%r13]
	ext	0x1e		; 	xld.uh %r5, [%r13+30]				; %r5 = channel->noise_lfsr *anti-interlock*			| +30, 2: unsigned short noise_lfsr
	ld.uh	%r5,[%r13]
	sub %r4, %r14					; channel->noise_progress -= cycle
	jruge	huc6280psg_channel_process_noise_break	; 	xjruge huc6280psg_channel_process_noise_break	; if(!%psr(C)) goto huc6280psg_channel_process_noise_break
	;
	ext	0x14		; 	xld.w %r6, [%r13+20]				; %r6 = channel->noise_period					| +20, 4: int noise_period
	ld.w	%r6,[%r13]
huc6280psg_channel_process_noise_loop:
	ld.w %r7, %r5					; lfsr = lfsr>>1 | ((lfsr^(lfsr>>4))&1)<<8
	srl	%r7,0x4		; 	xsrl %r7, 4
	xor %r7, %r5
	and	%r7,0x1		; 	xand %r7, %r7, 1
	sll	%r7,0x8		; 	xsll %r7, 8
	srl	%r5,0x1		; 	xsrl %r5, 1
	add %r4, %r6					; channel->noise_progress += channel->noise_period
	jruge.d	huc6280psg_channel_process_noise_loop	; 	xjruge.d huc6280psg_channel_process_noise_loop	; if(!%psr(C)) goto huc6280psg_channel_process_noise_loop
	or %r5, %r7					; *delay*
	ext	0x1e		; 	xld.h [%r13+30], %r5				; (store channel->noise_lfsr)					| +30, 2: unsigned short noise_lfsr
	ld.h	[%r13],%r5
	;
huc6280psg_channel_process_noise_break:
	ext	0x18		; 	xld.w [%r13+24], %r4				; (store channel->noise_progress)				| +24, 4: int noise_progress
	ld.w	[%r13],%r4
	;
	and	%r5,0x1		; 	xand %r5, %r5, 1				; %r5 =  1 or   0
	sll	%r5,0x5		; 	xsll %r5, 5					; %r5 = 32 or   0
	sub	%r5,0x10	; 	xsub %r5, %r5, 16				; %r5 = 16 or -16
	mlt.h %r10, %r5					; %alr = volume * sample
	ret.d
	ld.w %r10, %alr					; %r10 = output *delay*(undoc'd)
	;
	;/*===== Direct D/A mode =====*/
huc6280psg_channel_process_dda:
	ext	0x20		; 	xld.b %r11, [%r13+32]				; %r11 = channel->wave[0]					| +32,32: char wave[32]
	ld.b	%r11,[%r13]
	;
	mlt.h %r10, %r11				; %alr = volume * sample !INTERLOCK!
	ret.d
	ld.w %r10, %alr					; %r10 = output *delay*(undoc'd)
	;
	;/*===== Disabled channel =====*/
huc6280psg_channel_process_disable:
	ret						; 既に %r10=0 になっています。

