
;  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:
; APP
	
	.code
	.align	1
	.global	render_font
render_font:
	pushn	%r3
	ld.w	%r0, %r12			; %r0 = render
	ld.w	%r1, %r13			; %r1 = x
	ld.w	%r2, %r14			; %r2 = y
	ld.uh	%r3, %r15			; %r3 = code
	;// %r0 = render
	;// %r1 = x
	;// %r2 = y
	;// %r3 = code
	;// [%sp+20] = type
	;// [%sp+24] = color
	ld.ub	%r12,[%sp+0x14]	; 	xld.ub	%r12, [%sp+20]			; %r12 = type     (00000000 00000000 00000000 ?ttttttt)
	add	%r12, %r12			; %r12 = type * 2 (00000000 00000000 0000000? ttttttt0)
	ld.ub	%r12, %r12			; %r12 = type * 2 (00000000 00000000 00000000 ttttttt0)
	cmp	%r12,0x4	; 	xcmp	%r12, 4				; if(type * 2 > 2 * 2) goto render_font_ERR
	ext	render_font_ERR@rm	; 	xjrgt	render_font_ERR
	jrgt	render_font_ERR@rl
	ext	render_font_size@ah
	ext	render_font_size@al
	ld.uh	%r10, [%r12]			; %r10 = (h<<8)|w (00000000 00000000 hhhhhhhh wwwwwwww)
	;// %r0 = render
	;// %r1 = x
	;// %r2 = y
	;// %r3 = code
	;// %r10 = (h<<8)|w
	;// %r12 = type*2
	;// [%sp+24] = color
	ext	0x0		; 	xcmp	%r3, 0x20			; if(code == ' ') goto render_font_SPC
	cmp	%r3,0x20
	ext	render_font_SPC@rm	; 	xjreq	render_font_SPC
	jreq	render_font_SPC@rl
	ld.h	[%sp+0xa],%r10	; 	xld.h	[%sp+20], %r10			; [%sp+20] = w, [%sp+21] = h
	;// %r0 = render
	;// %r1 = x
	;// %r2 = y
	;// %r3 = code
	;// %r10 = (h<<8)|w
	;// %r12 = type*2
	;// [%sp+20] = w
	;// [%sp+21] = h
	;// [%sp+24] = color
	ext	pceFontSetType@rm	; 	xcall.d	pceFontSetType			; pceFontSetType(type)
	call.d	pceFontSetType@rl
	srl	%r12, 1				; *delay* %r12 = type (00000000 00000000 00000000 0ttttttt)
	ext	pceFontGetAdrs@rm	; 	xcall.d	pceFontGetAdrs			; %r10 = p = pceFontGetAdrs(code) (?ppppppp pppppppp pppppppp pppppppp)
	call.d	pceFontGetAdrs@rl
	ld.w	%r12, %r3			; *delay*
	;// %r0 = render
	;// %r1 = x
	;// %r2 = y
	;// %r10 = p
	;// [%sp+20] = w
	;// [%sp+21] = h
	;// [%sp+24] = color
	ld.w	%r3, [%r0]+			; %r3 = surface
	ld.h	%r4, [%r0]+			; %r4 = render->left
	ld.h	%r5, [%r0]+			; %r5 = render->top
	ld.h	%r6, [%r0]+			; %r6 = render->right
	ld.h	%r7, [%r0]			; %r7 = render->bottom
	;// %r1 = x
	;// %r2 = y
	;// %r3 = surface
	;// %r4 = render->left
	;// %r5 = render->top
	;// %r6 = render->right
	;// %r7 = render->bottom
	;// %r10 = p
	;// [%sp+20] = w
	;// [%sp+21] = h
	;// [%sp+24] = color
	ext	0x4		; 	xld.w	%r0, [%r3+4]			; %r0 = surface->vbuff
	ld.w	%r0,[%r3]
	ld.h	%r3,[%r3]	; 	xld.h	%r3, [%r3+0]			; %r3 = surface->w
	mlt.h	%r3, %r2			; %r0 = vptr = surface->vbuff + surface->w * y + x
	ld.w	%r9, %alr
	add	%r0, %r9
	add	%r0, %r1
	;// %r0 = vptr
	;// %r1 = x
	;// %r2 = y
	;// %r3 = surface->w
	;// %r4 = render->left
	;// %r5 = render->top
	;// %r6 = render->right
	;// %r7 = render->bottom
	;// %r10 = p
	;// [%sp+20] = w
	;// [%sp+21] = h
	;// [%sp+24] = color
	sub	%r1, %r4			; %r1 = x -= render->left
	sub	%r2, %r5			; %r2 = y -= render->top
	sub	%r6, %r4			; %r6 = xlim = render->right - render->left
	sub	%r7, %r5			; %r7 = ylim = render->bottom - render->top
	ld.ub	%r11,[%sp+0x14]	; 	xld.ub	%r11, [%sp+20]			; %r11 = w
	ld.ub	%r12,[%sp+0x15]	; 	xld.ub	%r12, [%sp+21]			; %r12 = h
	ld.w	%r4, %r11			; %r4 = w
	ld.w	%r5, %r3			; %r5 = vadd = surface->w - w
	sub	%r5, %r4
	add	%r11, %r1			; %r11 = xmax = x + w
	add	%r12, %r2			; %r12 = ymax = y + h
	ld.ub	%r13,[%sp+0x18]	; 	xld.ub	%r13, [%sp+24]			; %r13 = color
	;// %r0 = vptr
	;// %r1 = x
	;// %r2 = y
	;// %r3 = surface->w
	;// %r4 = w
	;// %r5 = vadd
	;// %r6 = xlim
	;// %r7 = ylim
	;// %r10 = p
	;// %r11 = xmax
	;// %r12 = ymax
	;// %r13 = color
	;// [%sp+20] = w
	;// [%sp+21] = h
	add	%r10, %r10			; %psr(C) = ?, %r10 = p * 2 (pppppppp pppppppp pppppppp ppppppp0)
	jruge.d	render_font_ZEN	; 	xjruge.d render_font_ZEN		; if(?) goto render_font_ZEN
	srl	%r10, 1				; *delay*      %r10 = p     (0ppppppp pppppppp pppppppp pppppppp)
	;------------ 半角 ------------
	cmp	%r1,0x0		; 	xcmp	%r1, 0				; if(x < 0) goto render_font_HAN_OUT_REPY
	jrlt	render_font_HAN_OUT_REPY	; 	xjrlt	render_font_HAN_OUT_REPY
	cmp	%r11, %r6			; if(xmax > xlim) goto render_font_HAN_OUT_REPY
	jrgt	render_font_HAN_OUT_REPY	; 	xjrgt	render_font_HAN_OUT_REPY
	cmp	%r2,0x0		; 	xcmp	%r2, 0				; if(y < 0) goto render_font_HAN_OUT_REPY
	jrlt	render_font_HAN_OUT_REPY	; 	xjrlt	render_font_HAN_OUT_REPY
	cmp	%r12, %r7			; if(ymax < ylim) goto render_font_HAN_OUT_REPY
	jrgt	render_font_HAN_OUT_REPY	; 	xjrgt	render_font_HAN_OUT_REPY
	;--- 半角(クリッピング無し) ---
render_font_HAN_IN_REPY:			; do {
	ld.ub	%r14, [%r10]+			;   c = *p++
	swap	%r14, %r14			;   c = abcdefgh 00000000 00000000 00000000
render_font_HAN_IN_REPX:			;   do {
	add	%r14, %r14			;       %psr(C) = a, c = bcdefgh0 00000000 00000000 00000000
	jruge.d	3				;       if(a)
	 add	%r1, 1				; 	| *delay* <-----+
	 ld.b	[%r0], %r13			;       | *vptr = color |
;//	xadd	%r1, %r1, 1			;       ----------------+
	cmp	%r1, %r11			; 
	jrlt.d	render_font_HAN_IN_REPX	; 	xjrlt.d	render_font_HAN_IN_REPX		;   } while(++x < xmax)
	add	%r0, 1				;   *delay* vptr++
	sub	%r1, %r4			;   x -= w
	add	%r2,0x1		; 	xadd	%r2, %r2, 1			; 
	cmp	%r2, %r12			; 
	jrlt.d	render_font_HAN_IN_REPY	; 	xjrlt.d	render_font_HAN_IN_REPY		; } while(++y < ymax)
	add	%r0, %r5			; *delay* vptr += vadd
	jp	render_font_RET	; 	xjp	render_font_RET
	;--- 半角(クリッピング有り) ---
render_font_HAN_OUT_REPY:			; do {
	ld.ub	%r14, [%r10]+			;   c = *p++
	swap	%r14, %r14			;   c = abcdefgh 00000000 00000000 00000000
render_font_HAN_OUT_REPX:			;   do {
	add	%r14, %r14			;       %psr(C) = a, c = bcdefgh0 00000000 00000000 00000000
	jruge	6				;       if(a)
	 cmp	%r1, %r6			;       | 
	 jruge	4				;       | if((unsigned)x < (unsigned)xlim)
	  cmp	%r2, %r7			;       | | 
	  jruge	2				;       | | if((unsigned)y < (unsigned)ylim)
	   ld.b	[%r0], %r13			;       | | | *vptr = color
	add	%r1,0x1		; 	xadd	%r1, %r1, 1			; 
	cmp	%r1, %r11			; 
	jrlt.d	render_font_HAN_OUT_REPX	; 	xjrlt.d	render_font_HAN_OUT_REPX	;   } while(++x < xmax)
	add	%r0, 1				;   *delay* vptr++
	sub	%r1, %r4			;   x -= w
	add	%r2,0x1		; 	xadd	%r2, %r2, 1			; 
	cmp	%r2, %r12			; 
	jrlt.d	render_font_HAN_OUT_REPY	; 	xjrlt.d	render_font_HAN_OUT_REPY	; } while(++y < ymax)
	add	%r0, %r5			; *delay* vptr += vadd
	jp	render_font_RET	; 	xjp	render_font_RET
	;------------ 全角 ------------
render_font_ZEN:
	add	%r11, %r4			; xmax += w
	add	%r4, %r4			; w    *= 2
	add	%r5, %r5			; vadd *= 2
	ld.b	[%sp+0x14],%r4	; 	xld.b	[%sp+20], %r4			; [%sp+20] = w * 2
	cmp	%r1,0x0		; 	xcmp	%r1, 0				; if(x < 0) goto render_font_ZEN_OUT_REPY
	jrlt	render_font_ZEN_OUT_REPY	; 	xjrlt	render_font_ZEN_OUT_REPY
	cmp	%r11, %r6			; if(xmax > xlim) goto render_font_ZEN_OUT_REPY
	jrgt	render_font_ZEN_OUT_REPY	; 	xjrgt	render_font_ZEN_OUT_REPY
	cmp	%r2,0x0		; 	xcmp	%r2, 0				; if(y < 0) goto render_font_ZEN_OUT_REPY
	jrlt	render_font_ZEN_OUT_REPY	; 	xjrlt	render_font_ZEN_OUT_REPY
	cmp	%r12, %r7			; if(ymax < ylim) goto render_font_ZEN_OUT_REPY
	jrgt	render_font_ZEN_OUT_REPY	; 	xjrgt	render_font_ZEN_OUT_REPY
	;--- 全角(クリッピング無し) ---
render_font_ZEN_IN_REPY:			; do {
	ld.ub	%r14, [%r10]+			;   c =          *p++ (00000000 00000000 00000000 abcdefgh)
	ld.ub	%r9, [%r10]+			; 
	sll	%r14,0x8	; 	xsll	%r14, 8				; 
	or	%r14, %r9			;   c = (c<<8) | *p++ (00000000 00000000 abcdefgh ij00klmn)
	ld.ub	%r9, [%r10]+			; 
	sll	%r14,0x8	; 	xsll	%r14, 8				; 
	or	%r14, %r9			;   c = (c<<8) | *p++ (00000000 abcdefgh ij00klmn opqrst00)
;//{{高速化
;//render_font_ZEN_IN_REPX:			;   do {
;//	xand	%r9, %r14, 0x800000		; 
;//	jreq	2				;     if(c & (1<<23))
;//	 ld.b	[%r0], %r13			;     | *(vptr + 0         ) = color
;//	xand	%r9, %r14, 0x800		; 
;//	jreq	4				;     if(c & (1<<11))
;//	 add	%r0, %r3			;     |
;//	 ld.b	[%r0], %r13			;     | *(vptr + surface->w) = color
;//	 sub	%r0, %r3			;     |
;//	add	%r14, %r14			;     c <<= 1
;//	xadd	%r1, %r1, 1			; 
;//↓高速化
	sll	%r14,0x8	; 	xsll	%r14, 8				;   %r14 = c1 (abcdefgh ij00klmn opqrst00 00000000)
	ld.w	%r15, %r14			;   %r15 = c2 (klmnopqr st000000 00000000 00000000)
	sll	%r15,0x8	; 	xsll	%r15, 12
	sll	%r15,0x4
render_font_ZEN_IN_REPX:			;   do {
	add	%r14, %r14			;     %psr(C) = a, c1 = bcdefghi j00klmno pqrst000 00000000
	jruge.d	3				;     if(a)
	 add	%r15, %r15			;     | *delay* %psr(C) = k, c2 = lmnopqrs t0000000 00000000 00000000
	 ld.b	[%r0], %r13			;     | *(vptr + 0         ) = color
	jruge.d	5				;     if(k)
	 add	%r1, 1				;     | *delay*
	 add	%r0, %r3			;     |
	 ld.b	[%r0], %r13			;     | *(vptr + surface->w) = color
	 sub	%r0, %r3			;     |
;//}}高速化
	cmp	%r1, %r11			; 
	jrlt.d	render_font_ZEN_IN_REPX	; 	xjrlt.d	render_font_ZEN_IN_REPX		;   } while(++x < xmax)
	add	%r0, 1				;   *delay* vptr++
	sub	%r1, %r4			;   x -= w
	add	%r2,0x2		; 	xadd	%r2, %r2, 2			; 
	cmp	%r2, %r12			; 
	jrlt.d	render_font_ZEN_IN_REPY	; 	xjrlt.d	render_font_ZEN_IN_REPY		; } while((y += 2) < ymax)
	add	%r0, %r5			; *delay* vptr += vadd
	jp	render_font_RET	; 	xjp	render_font_RET
	;--- 全角(クリッピング有り) ---
render_font_ZEN_OUT_REPY:			; do {
	ld.ub	%r14, [%r10]+			;   c =          *p++ (00000000 00000000 00000000 abcdefgh)
	ld.ub	%r9, [%r10]+			; 
	sll	%r14,0x8	; 	xsll	%r14, 8				; 
	or	%r14, %r9			;   c = (c<<8) | *p++ (00000000 00000000 abcdefgh ij00klmn)
	ld.ub	%r9, [%r10]+			; 
	sll	%r14,0x8	; 	xsll	%r14, 8				; 
	or	%r14, %r9			;   c = (c<<8) | *p++ (00000000 abcdefgh ij00klmn opqrst00)
render_font_ZEN_OUT_REPX:			;   do {
	cmp	%r1, %r6			; 
	jruge.d	render_font_ZEN_OUT_SKIP	; 	xjruge.d render_font_ZEN_OUT_SKIP	;     if((unsigned)x < (unsigned)xlim) {
	add	%r1, 1				;     *delay* <----------------------------+
	ext	0x400		; 	xand	%r9, %r14, 0x800000		;                                          |
	ext	0x0
	and	%r9,%r14
	jreq	4				;       if(c & (1<<23))                    |
	 cmp	%r2, %r7			;       |                                  |
	 jruge	2				;       | if((unsigned)y < (unsigned)ylim) |
	  ld.b	[%r0], %r13			;       |   *(vptr + 0         ) = color   |
	ext	0x800		; 	xand	%r9, %r14, 0x800		;                                          |
	and	%r9,%r14
	jreq	8				;       if(c & (1<<11))                    |
	 add	%r2, 1				;       | y++                              |
	 cmp	%r2, %r7			;       |                                  |
	 jruge.d 5				;       | if((unsigned)y < (unsigned)ylim) |
	  sub	%r2, 1				;       | | *delay* y--                    |
	  add	%r0, %r3			;       | |                                |
	  ld.b	[%r0], %r13			;       | | *(vptr + surface->w) = color   |
	  sub	%r0, %r3			;       | |                                |
render_font_ZEN_OUT_SKIP:			;     }                                    |
	add	%r14, %r14			;     c <<= 1                              |
;//	xadd	%r1, %r1, 1			;     -------------------------------------+
	cmp	%r1, %r11			; 
	jrlt.d	render_font_ZEN_OUT_REPX	; 	xjrlt.d	render_font_ZEN_OUT_REPX	;   } while(++x < xmax)
	add	%r0, 1				;   *delay* vptr++
	sub	%r1, %r4			;   x -= w
	add	%r2,0x2		; 	xadd	%r2, %r2, 2			; 
	cmp	%r2, %r12			; 
	jrlt.d	render_font_ZEN_OUT_REPY	; 	xjrlt.d	render_font_ZEN_OUT_REPY	; } while((y += 2) < ymax)
	add	%r0, %r5			; *delay* vptr += vadd
	;----------------
render_font_RET:
	ld.uh	%r10,[%sp+0xa]	; 	xld.uh	%r10, [%sp+20]			; %r10 = (h<<8)|w
render_font_SPC:
	popn	%r3
	ret
render_font_ERR:
	jp.d	render_font_SPC	; 	xjp.d	render_font_SPC
	ld.w	%r10, 0				; *delay*

