; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_2C00:
		push	R0
		mvfc	R0, bpc
		push	R0
		mvfc	R0, psw
		push	R0
		push	R1
		push	R2
		push	R3
		push	R4
		push	R5
		push	R6
		push	R7
		push	lr
		ld24	R0, #unk_800004
		ldb	R0, @R0
		push	R0
		ld24	R0, #unk_800000
		ldh	R0, @R0
		ld	R0, @R0
		jl	R0 || nop
		pop	R0
		ld24	R1, #unk_800004
		stb	R0, @R1
		pop	lr
		pop	R7
		pop	R6
		pop	R5
		pop	R4
		pop	R3
		pop	R2
		pop	R1
		pop	R0
		mvtc	R0, psw
		pop	R0
		mvtc	R0, bpc
		pop	R0
		rte	||\
; End of function sub_2C00

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_2C58:				; CODE XREF: sub_2C90j
					; DATA XREF: ROM_:00000094o ...
		ld24	R0, #unk_802800
		mvtc	R0, spu	|| nop
		ld24	R0, #unk_802800
		mvtc	R0, spi	|| nop
		bl.l	sub_C1FC

loc_2C6C:				; CODE XREF: sub_2C94+10j
		bl.l	sub_C218

loc_2C70:				; CODE XREF: sub_2C7C+10j
		bl.l	sub_C998

loc_2C74:				; CODE XREF: sub_2C58+20j
		bl.l	sub_2CA8
		bra.s	loc_2C74 ||\
; End of function sub_2C58

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_2C7C:				; CODE XREF: sub_30E0+70p
		ld24	R0, #unk_802800
		mvtc	R0, spu	|| nop
		ld24	R0, #unk_802800
		mvtc	R0, spi	|| nop
		bra.l	loc_2C70
; End of function sub_2C7C


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

; Attributes: thunk

sub_2C90:				; CODE XREF: sub_18590+150p
					; sub_18778+BCp
		bra.l	sub_2C58
; End of function sub_2C90


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_2C94:				; CODE XREF: sub_17D08+A4p
		ld24	R0, #unk_802800
		mvtc	R0, spu	|| nop
		ld24	R0, #unk_802800
		mvtc	R0, spi	|| nop
		bra.l	loc_2C6C
; End of function sub_2C94


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_2CA8:				; CODE XREF: sub_2C58:loc_2C74p
		push	R8
		push	lr
		ld24	R8, #unk_801000
		bl.l	sub_3534
		ldub	R0, @(0x88, R8)
		ldub	R1, @(0x7E, R8)
		cmp	R0, R1
		bnc.s	loc_2CD4
		ldub	R0, @(0x7E, R8)
		stb	R0, @(0x88, R8)
		ldub	R0, @(0x9B6, R8)
		stb	R0, @(0x8A, R8)
		bra.s	loc_2CEC || nop
; ---------------------------------------------------------------------------

loc_2CD4:				; CODE XREF: sub_2CA8+16j
		add3	R2, R8,	#0x89
		ldub	R0, @R2	|| nop
		ldub	R1, @(0x7E, R8)
		cmp	R1, R0
		bnc.s	loc_2CEC
		ldub	R0, @(0x7E, R8)
		stb	R0, @R2	|| nop

loc_2CEC:				; CODE XREF: sub_2CA8+28j sub_2CA8+3Aj
		add3	R0, R8,	#0x7C
		lduh	R1, @R0	|| nop
		ldub	R2, @(0x7E, R8)
		add	R1, R2
		sth	R1, @R0
		add3	R0, R8,	#0x86
		ldub	R1, @R0
		addi	R1, #1
		and3	R1, R1,	#0xFF
		stb	R1, @R0
		ldi8	R0, #0x64 ; 'd'
		bne	R1, R0,	loc_2D3C
		add3	R1, R8,	#0x7C
		ldi8	R2, #0x64 ; 'd'
		lduh	R0, @R1
		div	R0, R2
		stb	R0, @(0x87, R8)
		ldi8	R0, #0
		sth	R0, @R1
		stb	R0, @(0x8A, R8)
		stb	R0, @(0x88, R8)
		ldi8	R0, #0xFF || nop
		stb	R0, @(0x89, R8)
		ldi8	R0, #0 || nop
		stb	R0, @(0x86, R8)

loc_2D3C:				; CODE XREF: sub_2CA8+64j
		ldi8	R0, #0 || nop
		stb	R0, @(0x7E, R8)
		bl.l	sub_3528
		pop	lr
		pop	R8
		jmp	lr ||\
; End of function sub_2CA8

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_2D50:				; DATA XREF: ROM_:000000ACo
		push	R8
		push	R9
		push	lr
		ldi8	R0, #0xEE
		ldi8	R5, #0 || nop
		ld24	R9, #unk_801000
		ld24	R1, #unk_800233
		add3	R8, R9,	#0x7E
		stb	R0, @R1
		ldub	R4, @R8
		bl.l	sub_378C
		stb	R0, @R8	|| nop
		add3	R0, R9,	#0x74
		ld	R1, @R0
		addi	R1, #1
		st	R1, @R0	|| nop
		ldub	R0, @(6, R9)
		slli	R0, #0x1D || nop
		bgez	R0, loc_2D9C
		add3	R0, R9,	#0x85
		ldub	R1, @R0
		addi	R1, #1
		stb	R1, @R0	|| nop
		bra.l	loc_2F94
; ---------------------------------------------------------------------------

loc_2D9C:				; CODE XREF: sub_2D50+38j
		ldub	R0, @(6, R9)
		or3	R0, R0,	#4
		stb	R0, @(6, R9)

loc_2DA8:				; CODE XREF: sub_2D50+228j
		bl.l	sub_31FC
		bl.l	sub_2F9C
		bl.l	sub_326C
		bl.l	sub_3540
		bl.l	sub_CDC4

loc_2DBC:				; CODE XREF: sub_2D50+240j
		bl.l	sub_3534
		ldub	R0, @(7, R9)
		slli	R0, #0x1E || nop
		bgez	R0, loc_2DE8
		ldub	R0, @(7, R9)
		and3	R0, R0,	#0xFD
		stb	R0, @(7, R9)
		bl.l	sub_3528
		bl.l	nullsub_11
		bl.l	sub_CDE0
		bra.s	loc_2F88 || nop
; ---------------------------------------------------------------------------

loc_2DE8:				; CODE XREF: sub_2D50+78j
		ldub	R0, @(7, R9)
		slli	R0, #0x1D || nop
		bgez	R0, loc_2E10
		ldub	R0, @(7, R9)
		and3	R0, R0,	#0xFB
		stb	R0, @(7, R9)
		bl.l	sub_3528
		bl.l	sub_309C
		bl.l	sub_CE10
		bra.s	loc_2F88 || nop
; ---------------------------------------------------------------------------

loc_2E10:				; CODE XREF: sub_2D50+A0j
		ldub	R0, @(7, R9)
		slli	R0, #0x1C || nop
		bgez	R0, loc_2E38
		ldub	R0, @(7, R9)
		and3	R0, R0,	#0xF7
		stb	R0, @(7, R9)
		bl.l	sub_3528
		bl.l	sub_3160
		bl.l	sub_CE20
		bra.s	loc_2F88 || nop
; ---------------------------------------------------------------------------

loc_2E38:				; CODE XREF: sub_2D50+C8j
		ldub	R0, @(7, R9)
		slli	R0, #0x1B || nop
		bgez	R0, loc_2E60
		ldub	R0, @(7, R9)
		and3	R0, R0,	#0xEF
		stb	R0, @(7, R9)
		bl.l	sub_3528
		bl.l	sub_30E0
		bl.l	sub_CE40
		bra.s	loc_2F88 || nop
; ---------------------------------------------------------------------------

loc_2E60:				; CODE XREF: sub_2D50+F0j
		add3	R1, R9,	#0x14
		ldub	R0, @(2, R1)
		slli	R0, #0x1C || nop
		bgez	R0, loc_2E88
		ldub	R0, @(0x16, R9)
		and3	R0, R0,	#0xF7
		stb	R0, @(0x16, R9)
		bl.l	sub_3528
		bl.l	sub_CF04
		bra.s	loc_2F88 || nop
; ---------------------------------------------------------------------------

loc_2E88:				; CODE XREF: sub_2D50+11Cj
		ldub	R0, @(2, R1)
		slli	R0, #0x1D || nop
		bgez	R0, loc_2EAC
		ldub	R0, @(2, R1)
		and3	R0, R0,	#0xFB
		stb	R0, @(2, R1)
		bl.l	sub_3528
		bl.l	sub_CEF4
		bra.s	loc_2F88 || nop
; ---------------------------------------------------------------------------

loc_2EAC:				; CODE XREF: sub_2D50+140j
		ldub	R0, @(7, R9)
		slli	R0, #0x1A || nop
		bgez	R0, loc_2ED0
		ldub	R0, @(7, R9)
		and3	R0, R0,	#0xDF
		stb	R0, @(7, R9)
		bl.l	sub_3528
		bl.l	sub_CE78
		bra.s	loc_2F88 || nop
; ---------------------------------------------------------------------------

loc_2ED0:				; CODE XREF: sub_2D50+164j
		ldub	R0, @(7, R9)
		slli	R0, #0x19 || nop
		bgez	R0, loc_2EF4
		ldub	R0, @(7, R9)
		and3	R0, R0,	#0xBF
		stb	R0, @(7, R9)
		bl.l	sub_3528
		bl.l	sub_CE88
		bra.s	loc_2F88 || nop
; ---------------------------------------------------------------------------

loc_2EF4:				; CODE XREF: sub_2D50+188j
		ldub	R0, @(7, R9)
		slli	R0, #0x18 || nop
		bgez	R0, loc_2F18
		ldub	R0, @(7, R9)
		and3	R0, R0,	#0x7F
		stb	R0, @(7, R9)
		bl.l	sub_3528
		bl.l	sub_CE98
		bra.s	loc_2F88 || nop
; ---------------------------------------------------------------------------

loc_2F18:				; CODE XREF: sub_2D50+1ACj
		ldub	R0, @(6, R9)
		slli	R0, #0x1F || nop
		bgez	R0, loc_2F40
		ldub	R0, @(6, R9)
		and3	R0, R0,	#0xFE
		stb	R0, @(6, R9)
		bl.l	sub_3528
		bl.l	sub_CA5C
		bl.l	sub_CEB0
		bra.s	loc_2F88 || nop
; ---------------------------------------------------------------------------

loc_2F40:				; CODE XREF: sub_2D50+1D0j
		ldub	R0, @(6, R9)
		slli	R0, #0x1E || nop
		bgez	R0, loc_2F64
		ldub	R0, @(6, R9)
		and3	R0, R0,	#0xFD
		stb	R0, @(6, R9)
		bl.l	sub_3528
		bl.l	sub_CED0
		bra.s	loc_2F88 || nop
; ---------------------------------------------------------------------------

loc_2F64:				; CODE XREF: sub_2D50+1F8j
		add3	R1, R9,	#0x85
		ldub	R2, @R1	|| nop
		beqz	R2, loc_2F7C
		addi	R2, #-1
		stb	R2, @R1
		bl.l	sub_3528
		bra.s	loc_2DA8 || nop
; ---------------------------------------------------------------------------

loc_2F7C:				; CODE XREF: sub_2D50+21Cj
		ldub	R0, @(6, R9)
		and3	R0, R0,	#0xFB
		stb	R0, @(6, R9)

loc_2F88:				; CODE XREF: sub_2D50+94j sub_2D50+BCj ...
		ldub	R0, @(6, R9)
		slli	R0, #0x1D || nop
		bltz	R0, loc_2DBC

loc_2F94:				; CODE XREF: sub_2D50+48j
		pop	lr
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_2D50


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_2F9C:				; CODE XREF: sub_2D50+5Cp
		ld24	R3, #unk_801000
		add3	R2, R3,	#0x81
		ldub	R1, @R2
		addi	R1, #1
		and3	R1, R1,	#0xFF
		cmpui	R1, #0x32 ; '2'
		stb	R1, @R2
		bc.s	loc_2FC4
		ldi8	R0, #0
		stb	R0, @R2
		ldub	R0, @(6, R3)
		or3	R0, R0,	#2
		stb	R0, @(6, R3)

loc_2FC4:				; CODE XREF: sub_2F9C+16j
		ldi8	R0, #0x19 || nop
		ldub	R1, @(0x81, R3)
		bne	R1, R0,	loc_2FDC
		ldub	R0, @(6, R3)
		or3	R0, R0,	#1
		stb	R0, @(6, R3)

loc_2FDC:				; CODE XREF: sub_2F9C+30j
		add3	R2, R3,	#0x80
		ldub	R1, @R2
		addi	R1, #1
		and3	R1, R1,	#0xFF
		cmpui	R1, #0x14
		stb	R1, @R2
		bc.s	loc_3000
		ldi8	R0, #0
		stb	R0, @R2
		ldub	R0, @(7, R3)
		or3	R0, R0,	#0x80
		stb	R0, @(7, R3)

loc_3000:				; CODE XREF: sub_2F9C+52j
		ldub	R1, @(0x80, R3)
		and3	R0, R1,	#1
		beqz	R0, loc_301C
		ldub	R0, @(7, R3)
		or3	R0, R0,	#2
		stb	R0, @(7, R3)
		bra.s	loc_3030 || nop
; ---------------------------------------------------------------------------

loc_301C:				; CODE XREF: sub_2F9C+6Cj
		slli	R1, #0x1E || nop
		bgez	R1, loc_3030
		ldub	R0, @(7, R3)
		or3	R0, R0,	#4
		stb	R0, @(7, R3)

loc_3030:				; CODE XREF: sub_2F9C+7Cj sub_2F9C+84j
		ldub	R1, @(0x80, R3)
		cmpui	R1, #0xA
		bc.s	loc_303C
		addi	R1, #-0xA

loc_303C:				; CODE XREF: sub_2F9C+9Cj
		ldi8	R0, #1 || nop
		bne	R1, R0,	loc_3054
		ldub	R0, @(7, R3)
		or3	R0, R0,	#0x40
		stb	R0, @(7, R3)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_3054:				; CODE XREF: sub_2F9C+A4j
		ldi8	R0, #3 || nop
		bne	R1, R0,	loc_306C
		ldub	R0, @(7, R3)
		or3	R0, R0,	#8
		stb	R0, @(7, R3)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_306C:				; CODE XREF: sub_2F9C+BCj
		ldi8	R0, #6 || nop
		bne	R1, R0,	loc_3084
		ldub	R0, @(7, R3)
		or3	R0, R0,	#0x20
		stb	R0, @(7, R3)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_3084:				; CODE XREF: sub_2F9C+D4j
		ldi8	R0, #8 || nop
		bne	R1, R0,	locret_3098
		ldub	R0, @(7, R3)
		or3	R0, R0,	#0x10
		stb	R0, @(7, R3)

locret_3098:				; CODE XREF: sub_2F9C+ECj
		jmp	lr ||\
; End of function sub_2F9C

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_309C:				; CODE XREF: sub_2D50+B4p
		ld24	R0, #unk_80107E
		ldub	R0, @R0	|| nop
		ld24	R1, #unk_800000
		cmpui	R0, #0x64 ; 'd'
		bnc.s	locret_30DC || nop
		ldub	R0, @(0x707, R1)
		slli	R0, #0x18 || nop
		bgez	R0, loc_30CC
		add3	R2, R1,	#0x707
		ldub	R0, @R2	|| nop
		and3	R0, R0,	#0x7F
		stb	R0, @R2
		jmp	lr
; ---------------------------------------------------------------------------

loc_30CC:				; CODE XREF: sub_309C+1Cj
		add3	R0, R1,	#0x707
		ldub	R2, @R0	|| nop
		or3	R2, R2,	#0x80
		stb	R2, @R0	|| nop

locret_30DC:				; CODE XREF: sub_309C+10j
		jmp	lr ||\
; End of function sub_309C

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_30E0:				; CODE XREF: sub_2D50+104p
		push	R8
		push	lr
		ld24	R8, #unk_801000
		ldub	R0, @(0x17, R8)
		slli	R0, #0x1F || nop
		bgez	R0, loc_3154
		bl.l	sub_3534
		add3	R1, R8,	#0x7F
		ldub	R0, @R1
		addi	R0, #1
		stb	R0, @R1	|| nop
		bl.l	sub_3528
		add3	R1, R8,	#0x7F
		ldub	R0, @R1	|| nop
		cmpui	R0, #0x64 ; 'd'
		bc.s	loc_3154
		ldi8	R0, #0
		stb	R0, @R1	|| nop
		bl.l	sub_3534
		ldub	R0, @(0x17, R8)
		and3	R0, R0,	#0xFE
		stb	R0, @(0x17, R8)
		ldub	R0, @(0xE, R8)
		and3	R0, R0,	#0xF7
		stb	R0, @(0xE, R8)
		ldub	R0, @(6, R8)
		and3	R0, R0,	#0xFB
		stb	R0, @(6, R8)
		ldi8	R0, #0 || nop
		stb	R0, @(0x85, R8)
		bl.s	nullsub_10 || nop
		bl.l	sub_2C7C

loc_3154:				; CODE XREF: sub_30E0+10j sub_30E0+34j
		pop	lr
		pop	R8
		jmp	lr || nop
; End of function sub_30E0

; [00000002 BYTES: COLLAPSED FUNCTION nullsub_10. PRESS	KEYPAD "+" TO EXPAND]
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3160:				; CODE XREF: sub_2D50+DCp
		push	R8
		push	R9
		push	lr
		ld24	R8, #unk_801000
		bl.l	sub_CA50
		add3	R2, R8,	#0x83
		ldub	R1, @R2
		addi	R1, #1
		and3	R1, R1,	#0xFF
		cmpui	R1, #0xA
		stb	R1, @R2
		bc.s	loc_319C
		ldi8	R0, #0
		stb	R0, @R2
		bl.l	sub_CAA0
		add3	R9, R8,	#0x78
		ldi8	R5, #1
		lduh	R4, @R9
		bl.l	sub_378C
		sth	R0, @R9	|| nop

loc_319C:				; CODE XREF: sub_3160+22j
		ldub	R0, @(0x17, R8)
		slli	R0, #0x1F || nop
		bgez	R0, loc_31B4
		ldub	R0, @(0x38, R8)
		slli	R0, #0x18 || nop
		bgez	R0, loc_31BC

loc_31B4:				; CODE XREF: sub_3160+44j
		ldi8	R0, #0 || nop
		sth	R0, @(0x78, R8)

loc_31BC:				; CODE XREF: sub_3160+50j
		add3	R2, R8,	#0x82
		ldub	R1, @R2
		addi	R1, #1
		and3	R1, R1,	#0xFF
		cmpui	R1, #0x32 ; '2'
		stb	R1, @R2
		bc.s	loc_31D8
		ldi8	R0, #0
		stb	R0, @R2
		bl.l	sub_CADC

loc_31D8:				; CODE XREF: sub_3160+6Ej
		add3	R2, R8,	#0x84
		ldub	R1, @R2
		addi	R1, #1
		and3	R1, R1,	#0xFF
		cmpui	R1, #0x64 ; 'd'
		stb	R1, @R2
		bc.s	loc_31F4
		ldi8	R0, #0
		stb	R0, @R2
		bl.l	sub_CAF0

loc_31F4:				; CODE XREF: sub_3160+8Aj
		pop	lr
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_3160


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_31FC:				; CODE XREF: sub_2D50:loc_2DA8p
		ld24	R2, #unk_800000
		lduh	R0, @(0x92, R2)
		ld24	R4, #unk_801000
		sth	R0, @(0x2F4, R4)
		add3	R0, R2,	#0x84
		ldub	R1, @R0	|| nop
		or3	R1, R1,	#2
		stb	R1, @R0
		ldub	R1, @R0
		or3	R1, R1,	#1
		stb	R1, @R0	|| nop
		ldub	R0, @(0xD, R4)
		slli	R0, #0x1D || nop
		bgez	R0, locret_3268
		lduh	R0, @(0x380, R2)
		cmpi	R0, #0x20 ; ' '
		bnc.s	locret_3268 || nop
		ld24	R0, #0xFEFF
		add3	R1, R2,	#0x3BC
		sth	R0, @R1	|| nop
		add3	R0, R2,	#0x3BE
		lduh	R3, @R0	|| nop
		and3	R3, R3,	#0xFEFF
		sth	R3, @R0
		ldi8	R0, #0
		sth	R0, @R1	|| nop
		ldub	R0, @(0x3C, R4)
		or3	R0, R0,	#4
		stb	R0, @(0x3C, R4)

locret_3268:				; CODE XREF: sub_31FC+30j sub_31FC+3Cj
		jmp	lr || nop
; End of function sub_31FC


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_326C:				; CODE XREF: sub_2D50+60p
		ld24	R1, #unk_80103C
		ldub	R0, @R1
		slli	R0, #0x1D
		ld24	R2, #unk_800000
		bgez	R0, locret_32C4
		ldub	R0, @R1	|| nop
		and3	R0, R0,	#0xFB
		stb	R0, @R1	|| nop

loc_3288:				; CODE XREF: sub_326C+28j
		ldub	R0, @(0x85, R2)
		and3	R0, R0,	#0xF
		cmpi	R0, #2
		bc.s	loc_3288
		ldi8	R0, #0
		sth	R0, @(0x380, R2)
		ldi8	R0, #0xF || nop
		sth	R0, @(0x386, R2)
		ld24	R0, #0xFEFF
		add3	R1, R2,	#0x3BC
		sth	R0, @R1	|| nop
		add3	R0, R2,	#0x3BE
		lduh	R3, @R0	|| nop
		or3	R3, R3,	#0x100
		sth	R3, @R0
		ldi8	R0, #0
		sth	R0, @R1	|| nop

locret_32C4:				; CODE XREF: sub_326C+Cj
		jmp	lr ||\
; End of function sub_326C

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_32C8:				; DATA XREF: ROM_:000000A0o
		push	R8
		push	R9
		push	R10
		push	R11
		push	lr
		ldi8	R0, #0xEE
		ld24	R8, #unk_800000
		ld24	R9, #unk_801000
		stb	R0, @(0x238, R8)
		bl.l	sub_425C
		ldub	R0, @(0xE, R9)
		slli	R0, #0x1D || nop
		bltz	R0, loc_3484
		bl.l	sub_34F4
		bl.l	sub_43E4
		ldub	R0, @(0xE, R9)
		slli	R0, #0x1E || nop
		bgez	R0, loc_338C
		add3	R10, R9, #0xC
		ldub	R0, @(2, R10)
		or3	R0, R0,	#1
		stb	R0, @(2, R10)
		ldub	R0, @(3, R10)
		and3	R0, R0,	#0x3F
		stb	R0, @(3, R10)
		ldi8	R0, #0
		ldi8	R11, #1
		stb	R0, @(0xABC, R9)
		bl.l	sub_4508
		bl.l	sub_4674
		bl.l	sub_75D4
		bl.l	sub_4A10
		bl.l	nullsub_8
		ldub	R0, @(0x16, R9)
		or3	R0, R0,	#8
		stb	R0, @(0x16, R9)
		ldub	R0, @(2, R10)
		slli	R0, #0x1C || nop
		bltz	R0, loc_3384
		ldub	R0, @(2, R10)
		and3	R1, R11, #1
		and3	R0, R0,	#0xF7
		slli	R1, #3
		or	R0, R1
		stb	R0, @(2, R10)
		ldub	R0, @(0x17, R9)
		and3	R11, R11, #1
		and3	R0, R0,	#0xFE
		or	R0, R11	|| nop
		stb	R0, @(0x17, R9)
		ldi8	R0, #0 || nop
		stb	R0, @(0x85E, R9)

loc_3384:				; CODE XREF: sub_32C8+88j
		bl.s	sub_3490 || nop
		bra.s	loc_3484 || nop
; ---------------------------------------------------------------------------

loc_338C:				; CODE XREF: sub_32C8+38j
		ldub	R0, @(0xABC, R9)
		bnez	R0, loc_3400
		ldub	R1, @(0xE, R9)
		and3	R1, R1,	#0xFE
		stb	R1, @(0xE, R9)
		ldub	R1, @(0xF, R9)
		or3	R1, R1,	#0x80
		mv	R1, R1 || nop
		and3	R1, R1,	#0xBF
		add3	R0, R9,	#0xABC
		stb	R1, @(0xF, R9)
		ldub	R1, @R0
		addi	R1, #1
		stb	R1, @R0	|| nop
		bl.l	sub_46C0
		bl.l	sub_6130
		bl.l	sub_61E4
		bl.l	sub_7094
		bl.l	sub_4788
		bl.l	sub_CA3C
		ldi8	R0, #0 || nop
		ldub	R1, @(0x16, R9)
		or3	R1, R1,	#4
		stb	R1, @(0x16, R9)
		ldub	R1, @(0x17, R9)
		or3	R1, R1,	#1
		stb	R1, @(0x17, R9)
		stb	R0, @(0x85E, R9)
		bl.s	sub_3490 || nop
		bra.s	loc_3484 || nop
; ---------------------------------------------------------------------------

loc_3400:				; CODE XREF: sub_32C8+C8j
		ldub	R1, @(0xE, R9)
		and3	R1, R1,	#0xFE
		stb	R1, @(0xE, R9)
		ldub	R1, @(0xF, R9)
		and3	R1, R1,	#0x7F
		or3	R1, R1,	#0x40
		add3	R0, R9,	#0xABC
		stb	R1, @(0xF, R9)
		ldub	R1, @R0
		addi	R1, #1
		and3	R1, R1,	#0xFF
		stb	R1, @R0	|| nop
		bnez	R1, loc_3438
		addi	R1, #-1	|| nop
		stb	R1, @(0xABC, R9)

loc_3438:				; CODE XREF: sub_32C8+164j
		bl.l	sub_4734
		ldub	R0, @(0xA, R9)
		slli	R0, #0x1C || nop
		bltz	R0, loc_3468
		ld24	R0, #0xFFBF
		add3	R1, R8,	#0x224
		sth	R0, @R1	|| nop
		add3	R0, R8,	#0x226
		lduh	R2, @R0	|| nop
		and3	R2, R2,	#0xFFBF
		sth	R2, @R0
		ldi8	R0, #0
		sth	R0, @R1	|| nop

loc_3468:				; CODE XREF: sub_32C8+17Cj
		bl.l	sub_48FC
		bl.l	sub_4A44
		bl.l	sub_5D0C
		bl.l	sub_76C8
		bl.l	nullsub_9
		ldi8	R0, #0 || nop
		stb	R0, @(0x7F, R9)

loc_3484:				; CODE XREF: sub_32C8+24j sub_32C8+C0j ...
		pop	lr
		pop	R11
		pop	R10
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_32C8


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3490:				; CODE XREF: sub_32C8:loc_3384p
					; sub_32C8+130p
		push	R8
		push	lr
		ldi8	R0, #0 || nop
		ld24	R8, #unk_801000
		stb	R0, @(0x7F, R8)
		ldub	R0, @(6, R8)
		slli	R0, #0x1D || nop
		bltz	R0, loc_34EC
		add3	R1, R8,	#0x14
		ldub	R0, @(2, R1)
		slli	R0, #0x1C || nop
		bgez	R0, loc_34D0
		ldub	R0, @(0x16, R8)
		and3	R0, R0,	#0xF7
		stb	R0, @(0x16, R8)
		bl.l	sub_CF04
		bra.s	loc_34EC || nop
; ---------------------------------------------------------------------------

loc_34D0:				; CODE XREF: sub_3490+28j
		ldub	R0, @(2, R1)
		slli	R0, #0x1D || nop
		bgez	R0, loc_34EC
		ldub	R0, @(2, R1)
		and3	R0, R0,	#0xFB
		stb	R0, @(2, R1)
		bl.l	sub_CEF4

loc_34EC:				; CODE XREF: sub_3490+18j sub_3490+3Cj ...
		pop	lr
		pop	R8
		jmp	lr || nop
; End of function sub_3490


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_34F4:				; CODE XREF: sub_32C8+28p
		ldi8	R2, #1 || nop
		ld24	R1, #unk_801000
		ldub	R0, @(0x17, R1)
		or3	R0, R0,	#2
		stb	R0, @(0x17, R1)
		ldub	R0, @(0x3A4, R1)
		beqz	R0, locret_3524
		ldub	R0, @(0x17, R1)
		and3	R2, R2,	#1
		and3	R0, R0,	#0xFB
		slli	R2, #2
		or	R0, R2
		stb	R0, @(0x17, R1)

locret_3524:				; CODE XREF: sub_34F4+18j
		jmp	lr ||\
; End of function sub_34F4

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3528:				; CODE XREF: sub_2CA8+9Cp sub_2D50+88p ...
		mvfc	R0, psw	|| nop
		or3	R0, R0,	#0x40
		mvtc	R0, psw
		jmp	lr
; End of function sub_3528


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3534:				; CODE XREF: sub_2CA8+8p
					; sub_2D50:loc_2DBCp ...
		mvfc	R0, psw	|| nop
		and3	R0, R0,	#0xBF
		mvtc	R0, psw
		jmp	lr
; End of function sub_3534


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3540:				; CODE XREF: sub_2D50+64p
		ld24	R1, #unk_800004
		ldi8	R0, #7
		stb	R0, @R1
		jmp	lr ||\
; End of function sub_3540

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_354C:				; CODE XREF: sub_76C8+70p
					; sub_D7E0+108p ...
		mv	R0, R4
		ldub	R5, @R5
		beqz	R7, loc_3558
		ldub	R5, @R6	|| nop

loc_3558:				; CODE XREF: sub_354C+4j
		ldub	R0, @R0
		cmpu	R0, R5
		bnc.s	loc_3564
		ldi8	R0, #0
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_3564:				; CODE XREF: sub_354C+10j
		ldi8	R0, #1
		jmp	lr
; End of function sub_354C


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3568:				; CODE XREF: sub_10270+38p
					; sub_111F4+1ACp ...
		mv	R0, R4
		ldub	R6, @R6
		beqz	R7, loc_3574
		ldub	R6, @R5	|| nop

loc_3574:				; CODE XREF: sub_3568+4j
		ldub	R0, @R0
		cmpu	R0, R6
		bc.s	loc_3580
		ldi8	R0, #0
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_3580:				; CODE XREF: sub_3568+10j
		ldi8	R0, #1
		jmp	lr
; End of function sub_3568


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3584:				; CODE XREF: sub_48FC+30p sub_48FC+70p ...
		mv	R0, R4
		lduh	R5, @R5
		beqz	R7, loc_3590
		lduh	R5, @R6	|| nop

loc_3590:				; CODE XREF: sub_3584+4j
		lduh	R0, @R0
		cmpu	R0, R5
		bnc.s	loc_359C
		ldi8	R0, #0
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_359C:				; CODE XREF: sub_3584+10j
		ldi8	R0, #1
		jmp	lr
; End of function sub_3584


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_35A0:				; CODE XREF: sub_D2EC+68p sub_D2EC+A4p ...
		mv	R0, R4
		lduh	R6, @R6
		beqz	R7, loc_35AC
		lduh	R6, @R5	|| nop

loc_35AC:				; CODE XREF: sub_35A0+4j
		lduh	R0, @R0
		cmpu	R0, R6
		bc.s	loc_35B8
		ldi8	R0, #0
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_35B8:				; CODE XREF: sub_35A0+10j
		ldi8	R0, #1
		jmp	lr
; End of function sub_35A0


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_35BC:				; CODE XREF: sub_5C54+44p sub_7A00+6Cp ...
		addi	sp, #-0x10
		push	R8
		push	lr
		add3	R8, sp,	#8
		st	R4, @R8	|| nop
		st	R4, @(4, R8)
		st	R5, @(8, R8)
		st	R6, @(0xC, R8)
		mv	R4, R8
		bl.s	sub_35F0
		mv	R5, R0
		mv	R4, R8
		bl.s	sub_3614 || nop
		and3	R0, R0,	#0xFFFF
		pop	lr
		pop	R8
		addi	sp, #0x10
		jmp	lr
; End of function sub_35BC


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_35F0:				; CODE XREF: sub_35BC+1Ep
		ld	R2, @(0xC, R4)
		srl3	R1, R2,	#8
		srli	R2, #0x10 || nop
		ld	R0, @(8, R4)
		and3	R1, R1,	#0xFF
		divu	R0, R1
		cmpu	R0, R2
		bc.s	locret_3610
		add3	R0, R2,	#0xFFFF

locret_3610:				; CODE XREF: sub_35F0+1Aj
		jmp	lr || nop
; End of function sub_35F0


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3614:				; CODE XREF: sub_35BC+24p
		push	R8
		push	R9
		push	R10
		push	lr
		mv	R9, R4
		mv	R10, R5
		ld	R8, @(0xC, R9)
		srl3	R2, R8,	#0x10
		and3	R1, R8,	#1
		add3	R0, R2,	#0xFFFF
		and3	R8, R8,	#0x10
		cmpu	R10, R0
		bc.s	loc_3658
		add3	R1, R2,	#0xFFFF
		ld	R0, @R9
		add	R0, R1
		ldi8	R1, #0x10
		ldub	R0, @R0
		bne	R8, R1,	loc_369C
		slli	R2, #1 || nop
		ld	R0, @(4, R9)
		addi	R2, #-2
		add	R0, R2
		lduh	R0, @R0
		bra.s	loc_369C
; ---------------------------------------------------------------------------

loc_3658:				; CODE XREF: sub_3614+22j
		ldi8	R2, #0 || nop
		bnez	R1, loc_366C
		mv	R4, R9
		mv	R5, R10
		bl.s	sub_36A8 || nop
		mv	R2, R0 || nop

loc_366C:				; CODE XREF: sub_3614+48j
		ld	R1, @R9
		add	R1, R10
		ldub	R0, @(1, R1)
		ldub	R3, @R1
		ldi8	R1, #0x10
		sub	R0, R3
		mul	R0, R2
		srli	R0, #8
		add	R0, R3
		bne	R8, R1,	loc_369C
		slli	R10, #1	|| nop
		ld	R1, @(4, R9)
		add	R1, R10
		lduh	R3, @R1
		lduh	R0, @(2, R1)
		sub	R0, R3
		mul	R0, R2
		srli	R0, #8
		add	R0, R3

loc_369C:				; CODE XREF: sub_3614+30j sub_3614+42j ...
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		jmp	lr || nop
; End of function sub_3614


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_36A8:				; CODE XREF: sub_3614+50p
		ldi8	R0, #0 || nop
		ld	R1, @(0xC, R4)
		srl3	R2, R1,	#8
		srli	R1, #0x10
		addi	R1, #-1
		and3	R2, R2,	#0xFF
		cmpu	R5, R1
		bnc.s	locret_36D0
		mul	R5, R2 || nop
		ld	R0, @(8, R4)
		sub	R0, R5
		slli	R0, #8
		divu	R0, R2

locret_36D0:				; CODE XREF: sub_36A8+16j
		jmp	lr ||\
; End of function sub_36A8

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_36D4:				; CODE XREF: sub_4CF0+FCp
					; sub_4CF0+10Cp ...
		mv	R0, R4 || nop
		bgez	R0, locret_36E0
		ldi8	R0, #0 || nop

locret_36E0:				; CODE XREF: sub_36D4+4j
		jmp	lr || nop
; End of function sub_36D4


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_36E4:				; CODE XREF: sub_4788+78p sub_4788+84p ...
		push	lr
		ldi16	R5, #0xFF
		bl.s	sub_3774 || nop
		pop	lr
		jmp	lr
; End of function sub_36E4


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_36F4:				; CODE XREF: sub_7184+434p
					; sub_10E50+94p ...
		push	lr
		ldi16	R5, #0xFF
		bl.s	sub_3780 || nop
		pop	lr
		jmp	lr
; End of function sub_36F4


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3704:				; CODE XREF: sub_63D4+34p sub_63D4+48p ...
		push	lr
		ld24	R5, #0xFFFF
		bl.s	sub_3774 || nop
		pop	lr
		jmp	lr
; End of function sub_3704


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3714:				; CODE XREF: sub_4674+3Cp sub_46C0+3Cp ...
		push	lr
		ld24	R5, #0xFFFF
		bl.s	sub_3780 || nop
		pop	lr
		jmp	lr
; End of function sub_3714


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3724:				; CODE XREF: sub_64D8+264p
					; sub_6E58+11Cp ...
		push	lr
		ldi8	R5, #0
		ldi16	R6, #0xFF
		bl.s	sub_3744 || nop
		pop	lr
		jmp	lr
; End of function sub_3724


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3734:				; CODE XREF: sub_10364+50p
					; sub_103D4+1Cp ...
		push	lr
		ld24	R6, #0xFFFF
		ldi8	R5, #0
		bl.s	sub_3744
		pop	lr
		jmp	lr
; End of function sub_3734


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3744:				; CODE XREF: sub_3724+8p sub_3734+Ap ...
		mv	R0, R4
		cmp	R6, R0
		bnc.s	loc_3750
		mv	R0, R6
		bra.s	locret_3758 || nop
; ---------------------------------------------------------------------------

loc_3750:				; CODE XREF: sub_3744+4j
		cmp	R0, R5
		bnc.s	locret_3758
		mv	R0, R5 || nop

locret_3758:				; CODE XREF: sub_3744+8j sub_3744+Ej
		jmp	lr || nop
; End of function sub_3744


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_375C:
		mv	R0, R4
		cmpu	R6, R0
		bnc.s	loc_3768
		mv	R0, R6
		bra.s	locret_3770 || nop
; ---------------------------------------------------------------------------

loc_3768:				; CODE XREF: sub_375C+4j
		cmpu	R0, R5
		bnc.s	locret_3770
		mv	R0, R5 || nop

locret_3770:				; CODE XREF: sub_375C+8j sub_375C+Ej
		jmp	lr || nop
; End of function sub_375C


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3774:				; CODE XREF: sub_36E4+8p sub_3704+8p
		mv	R0, R4
		cmp	R5, R0
		bnc.s	locret_377C
		mv	R0, R5

locret_377C:				; CODE XREF: sub_3774+4j
		jmp	lr || nop
; End of function sub_3774


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3780:				; CODE XREF: sub_36F4+8p sub_3714+8p
		mv	R0, R4
		cmpu	R5, R0
		bnc.s	locret_3788
		mv	R0, R5

locret_3788:				; CODE XREF: sub_3780+4j
		jmp	lr ||\
; End of function sub_3780

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_378C:				; CODE XREF: sub_2D50+1Cp sub_3160+34p ...
		add3	R0, R4,	#1
		beqz	R5, loc_37A4
		ld24	R5, #0xFFFF
		cmpu	R5, R0
		bnc.s	locret_37B0
		ld24	R0, #0xFFFF
		bra.s	locret_37B0 || nop
; ---------------------------------------------------------------------------

loc_37A4:				; CODE XREF: sub_378C+4j
		cmpui	R0, #0x100
		bc.s	locret_37B0 || nop
		ldi16	R0, #0xFF

locret_37B0:				; CODE XREF: sub_378C+Ej sub_378C+14j	...
		jmp	lr || nop
; End of function sub_378C


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_37B4:				; CODE XREF: sub_3EA4+84p sub_3F54+84p ...
		add3	R0, R4,	#0xFFFF
		bgez	R0, locret_37C0
		ldi8	R0, #0 || nop

locret_37C0:				; CODE XREF: sub_37B4+4j
		jmp	lr ||\
; End of function sub_37B4

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_37C4:				; CODE XREF: sub_D7E0+288p
					; sub_D7E0+2ACp ...
		addi	sp, #-0x2C
		push	R8
		push	R9
		push	R10
		push	R11
		push	R12
		push	lr
		mv	R0, R5
		add3	R10, sp, #0x18
		mv	R9, R6
		st	R4, @R10
		st	R4, @(4, R10)
		st	R4, @(8, R10)
		st	R4, @(0xC, R10)
		st	R0, @(0x10, R10)
		st	R9, @(0x14, R10)
		sth	R7, @(0x18, R10)
		lduh	R8, @(0x46, sp)
		sth	R8, @(0x1A, R10)
		ld	R2, @(0x48, sp)
		srl3	R1, R2,	#0x10
		add3	R11, R10, #0x1C
		srli	R7, #8
		stb	R1, @R11
		srl3	R1, R2,	#8
		stb	R1, @(0x1D, R10)
		stb	R2, @(0x1E, R10)
		mv	R4, R0
		ldub	R11, @R11
		and3	R5, R7,	#0xFFFF
		add3	R12, R10, #0x20
		mv	R6, R11
		bl.s	sub_385C
		srli	R8, #2
		mv	R4, R9
		mv	R6, R11	|| nop
		and3	R5, R8,	#0xFFFF
		st	R0, @R12
		bl.s	sub_385C
		st	R0, @(0x24, R10)
		mul	R0, R11
		ld	R12, @R12
		mv	R4, R10
		add	R0, R12
		st	R0, @(0x28, R10)
		bl.s	sub_3878 || nop
		pop	lr
		pop	R12
		pop	R11
		pop	R10
		pop	R9
		pop	R8
		addi	sp, #0x2C ; ','
		jmp	lr
; End of function sub_37C4


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_385C:				; CODE XREF: sub_37C4+62p sub_37C4+72p
		ldi8	R0, #1
		bra.s	loc_3864
; ---------------------------------------------------------------------------

loc_3860:				; CODE XREF: sub_385C+14j
		addi	R0, #1 || nop

loc_3864:				; CODE XREF: sub_385C+2j
		cmpu	R0, R6
		bnc.s	loc_3874
		mv	R1, R0
		add	R1, R4
		ldub	R1, @R1
		cmp	R5, R1
		bnc.s	loc_3860 || nop

loc_3874:				; CODE XREF: sub_385C+Aj
		addi	R0, #-1
		jmp	lr
; End of function sub_385C


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3878:				; CODE XREF: sub_37C4+84p
		push	R8
		push	R9
		push	R10
		push	lr
		mv	R9, R4 || nop
		ldub	R0, @(0x1D, R9)
		bnez	R0, loc_38C4
		ldi8	R0, #0
		push	R0
		add3	R8, R9,	#0x1C
		ld	R4, @(0x10, R9)
		lduh	R5, @(0x18, R9)
		ld	R6, @(0x20, R9)
		ldub	R7, @R8
		bl.s	sub_38DC
		addi	sp, #4
		mv	R10, R0
		lduh	R0, @(0x1A, R9)
		ldi8	R1, #1
		push	R1
		mv	R5, R0 || nop
		ld	R4, @(0x14, R9)
		ld	R6, @(0x24, R9)
		ldub	R7, @R8
		bl.s	sub_38DC
		addi	sp, #4
		bra.s	loc_38C8
; ---------------------------------------------------------------------------

loc_38C4:				; CODE XREF: sub_3878+10j
		ldi8	R0, #0
		ldi8	R10, #0

loc_38C8:				; CODE XREF: sub_3878+4Aj
		mv	R6, R0
		mv	R4, R9
		mv	R5, R10
		bl.s	sub_3938
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		jmp	lr || nop
; End of function sub_3878


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_38DC:				; CODE XREF: sub_3878+2Ap sub_3878+46p
		ldi16	R2, #0x100
		mv	R0, R4 || nop
		ldub	R1, @(3, sp)
		beqz	R1, loc_38F0
		ldi8	R2, #4 || nop

loc_38F0:				; CODE XREF: sub_38DC+Cj
		addi	R7, #-1
		cmpu	R6, R7
		bnc.s	loc_3908 || nop
		bnez	R6, loc_390C
		mv	R1, R5
		ldub	R7, @R0
		divu	R1, R2
		cmpu	R7, R1
		bc.s	loc_390C

loc_3908:				; CODE XREF: sub_38DC+18j
		ldi8	R5, #0
		bra.s	loc_3934
; ---------------------------------------------------------------------------

loc_390C:				; CODE XREF: sub_38DC+1Cj sub_38DC+2Aj
		add	R6, R0 || nop
		ldub	R1, @(1, R6)
		ldub	R7, @R6
		sub	R1, R7
		ldub	R0, @(3, sp)
		beqz	R0, loc_392C
		ldub	R0, @R6
		slli	R0, #2
		sub	R5, R0
		slli	R5, #8
		srli	R5, #2
		bra.s	loc_3930
; ---------------------------------------------------------------------------

loc_392C:				; CODE XREF: sub_38DC+40j
		slli	R7, #8
		sub	R5, R7

loc_3930:				; CODE XREF: sub_38DC+4Ej
		divu	R5, R1

loc_3934:				; CODE XREF: sub_38DC+2Ej
		mv	R0, R5
		jmp	lr
; End of function sub_38DC


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3938:				; CODE XREF: sub_3878+56p
		push	R8
		push	R9
		push	R10
		push	R11
		push	lr
		mv	R11, R6
		mv	R8, R4
		mv	R9, R5
		ldi8	R6, #0
		mv	R4, R8
		mv	R5, R9
		bl.s	sub_3970
		mv	R4, R8
		mv	R5, R9
		mv	R10, R0
		bl.s	sub_3AA0
		sub	R0, R10
		mul	R0, R11
		srli	R0, #8
		add	R0, R10
		and3	R0, R0,	#0xFFFF
		pop	lr
		pop	R11
		pop	R10
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_3938


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3970:				; CODE XREF: sub_3938+16p sub_3AA0+16p ...
		ldub	R2, @(0x1E, R4)
		and3	R6, R6,	#0xFF
		bnez	R2, loc_39B4
		ld	R0, @(0x28, R4)
		ld	R1, @R4
		add	R1, R0
		ldub	R0, @(0x1C, R4)
		addi	R0, #-1
		add	R1, R6
		ld	R6, @(0x20, R4)
		cmpu	R6, R0
		bc.s	loc_399C
		ldub	R1, @R1
		mv	R1, R1
		bra.s	loc_3A9C || nop
; ---------------------------------------------------------------------------

loc_399C:				; CODE XREF: sub_3970+22j
		ldub	R4, @R1	|| nop
		ldub	R1, @(1, R1)
		sub	R1, R4
		mul	R1, R5
		srli	R1, #8
		add	R1, R4
		and3	R1, R1,	#0xFFFF
		bra.s	loc_3A9C || nop
; ---------------------------------------------------------------------------

loc_39B4:				; CODE XREF: sub_3970+8j
		ldi8	R0, #1 || nop
		bne	R2, R0,	loc_39F8
		slli	R6, #1 || nop
		ld	R0, @(0x28, R4)
		ld	R1, @(8, R4)
		slli	R0, #1
		add	R1, R0
		ldub	R0, @(0x1C, R4)
		addi	R0, #-1
		add	R1, R6
		ld	R6, @(0x20, R4)
		cmpu	R6, R0
		bc.s	loc_39E0
		lduh	R1, @R1
		bra.s	loc_3A9C
; ---------------------------------------------------------------------------

loc_39E0:				; CODE XREF: sub_3970+6Aj
		lduh	R4, @R1	|| nop
		lduh	R1, @(2, R1)
		sub	R1, R4
		mul	R1, R5
		srli	R1, #8
		add	R1, R4
		and3	R1, R1,	#0xFFFF
		bra.s	loc_3A9C || nop
; ---------------------------------------------------------------------------

loc_39F8:				; CODE XREF: sub_3970+48j
		ldi8	R0, #2 || nop
		bne	R2, R0,	loc_3A9C
		ld	R3, @(4, R4)
		ld	R0, @(0x28, R4)
		add	R3, R0 || nop
		ldub	R0, @(0x1C, R4)
		addi	R0, #-1
		add	R3, R6
		ld	R6, @(0x20, R4)
		cmpu	R6, R0
		bc.s	loc_3A28
		ldb	R1, @R3	|| nop
		and3	R1, R1,	#0xFFFF
		bra.s	loc_3A9C || nop
; ---------------------------------------------------------------------------

loc_3A28:				; CODE XREF: sub_3970+AAj
		ldb	R2, @(1, R3)
		ldi8	R6, #0
		cmp	R2, R6
		mv	R1, R2
		mvfc	R6, cbr
		beqz	R6, loc_3A40
		ldb	R4, @R3	|| nop
		bgtz	R4, loc_3A4C

loc_3A40:				; CODE XREF: sub_3970+C4j
		blez	R1, loc_3A8C
		ldb	R4, @R3	|| nop
		bgez	R4, loc_3A8C

loc_3A4C:				; CODE XREF: sub_3970+CCj
		beqz	R6, loc_3A54
		neg	R1, R2
		bra.s	loc_3A58
; ---------------------------------------------------------------------------

loc_3A54:				; CODE XREF: sub_3970:loc_3A4Cj
		mv	R1, R2 || nop

loc_3A58:				; CODE XREF: sub_3970+E2j
		bgez	R4, loc_3A60
		neg	R6, R4
		bra.s	loc_3A64
; ---------------------------------------------------------------------------

loc_3A60:				; CODE XREF: sub_3970:loc_3A58j
		mv	R6, R4 || nop

loc_3A64:				; CODE XREF: sub_3970+EEj
		add	R1, R6
		cmp	R4, R2
		bnc.s	loc_3A7C
		mul	R1, R5
		ldb	R0, @R3
		srli	R1, #8
		add	R1, R0 || nop
		and3	R1, R1,	#0xFFFF
		bra.s	loc_3A9C || nop
; ---------------------------------------------------------------------------

loc_3A7C:				; CODE XREF: sub_3970+F8j
		mul	R1, R5
		srli	R1, #8
		sub	R4, R1 || nop
		and3	R1, R4,	#0xFFFF
		bra.s	loc_3A9C || nop
; ---------------------------------------------------------------------------

loc_3A8C:				; CODE XREF: sub_3970:loc_3A40j
					; sub_3970+D8j
		ldb	R3, @R3
		sub	R1, R3
		mul	R1, R5
		srli	R1, #8
		add	R1, R3 || nop
		and3	R1, R1,	#0xFFFF

loc_3A9C:				; CODE XREF: sub_3970+28j sub_3970+40j ...
		mv	R0, R1
		jmp	lr
; End of function sub_3970


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3AA0:				; CODE XREF: sub_3938+1Ep
		push	lr
		ldub	R0, @(0x1C, R4)
		addi	R0, #-1	|| nop
		ld	R1, @(0x24, R4)
		cmpu	R1, R0
		bc.s	loc_3ABC
		ldi8	R6, #0
		bl.s	sub_3970
		bra.s	loc_3AC4 || nop
; ---------------------------------------------------------------------------

loc_3ABC:				; CODE XREF: sub_3AA0+12j
		ldub	R6, @(0x1C, R4)
		bl.s	sub_3970 || nop

loc_3AC4:				; CODE XREF: sub_3AA0+18j
		pop	lr
		jmp	lr
; End of function sub_3AA0

; ---------------------------------------------------------------------------
		nop
		rte
; ---------------------------------------------------------------------------
		nop
		rte
; ---------------------------------------------------------------------------
		nop
		rte
; ---------------------------------------------------------------------------
		nop
		rte

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3AD8:				; DATA XREF: ROM_:000000BCo
		push	lr
		ld24	R0, #unk_800230
		ldub	R1, @R0	|| nop
		and3	R0, R1,	#1
		bnez	R0, loc_3B04
		and3	R0, R1,	#2
		bnez	R0, loc_3B04
		and3	R0, R1,	#4
		bnez	R0, loc_3B04
		slli	R1, #0x1C || nop
		bgez	R1, loc_3B08

loc_3B04:				; CODE XREF: sub_3AD8+10j sub_3AD8+18j ...
		bl.l	sub_3B0C

loc_3B08:				; CODE XREF: sub_3AD8+28j
		pop	lr
		jmp	lr
; End of function sub_3AD8


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3B0C:				; CODE XREF: sub_3AD8:loc_3B04p
		push	R8
		push	lr
		ld24	R0, #unk_801009
		ldub	R0, @R0
		slli	R0, #0x1F
		ld24	R8, #unk_800000
		bgez	R0, loc_3B70
		ldub	R1, @(0x230, R8)
		ldi8	R0, #0
		slli	R1, #0x1F
		bgez	R1, loc_3B30
		bl.s	sub_3BB8 || nop

loc_3B30:				; CODE XREF: sub_3B0C+1Cj
		bnez	R0, loc_3BB0
		ldub	R1, @(0x230, R8)
		slli	R1, #0x1D || nop
		bgez	R1, loc_3B44
		bl.s	sub_3D30 || nop

loc_3B44:				; CODE XREF: sub_3B0C+30j
		bnez	R0, loc_3BB0
		ldub	R1, @(0x230, R8)
		slli	R1, #0x1E || nop
		bgez	R1, loc_3B58
		bl.s	sub_3C74 || nop

loc_3B58:				; CODE XREF: sub_3B0C+44j
		bnez	R0, loc_3BB0
		ldub	R0, @(0x230, R8)
		slli	R0, #0x1C || nop
		bgez	R0, loc_3BB0
		bl.l	sub_3DEC
		bra.s	loc_3BB0 || nop
; ---------------------------------------------------------------------------

loc_3B70:				; CODE XREF: sub_3B0C+10j
		ldub	R1, @(0x230, R8)
		and3	R0, R1,	#1
		beqz	R0, loc_3B84
		bl.l	sub_3EA4
		bra.s	loc_3BB0 || nop
; ---------------------------------------------------------------------------

loc_3B84:				; CODE XREF: sub_3B0C+6Cj
		and3	R0, R1,	#4
		beqz	R0, loc_3B94
		bl.l	sub_4004
		bra.s	loc_3BB0 || nop
; ---------------------------------------------------------------------------

loc_3B94:				; CODE XREF: sub_3B0C+7Cj
		and3	R0, R1,	#2
		beqz	R0, loc_3BA4
		bl.l	sub_3F54
		bra.s	loc_3BB0 || nop
; ---------------------------------------------------------------------------

loc_3BA4:				; CODE XREF: sub_3B0C+8Cj
		slli	R1, #0x1C || nop
		bgez	R1, loc_3BB0
		bl.l	sub_40B4

loc_3BB0:				; CODE XREF: sub_3B0C:loc_3B30j
					; sub_3B0C:loc_3B44j ...
		pop	lr
		pop	R8
		jmp	lr || nop
; End of function sub_3B0C


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3BB8:				; CODE XREF: sub_3B0C+20p
		push	R8
		push	lr
		ld24	R1, #unk_800230
		ldi8	R0, #0xFE
		stb	R0, @R1
		ld24	R8, #unk_801000
		add3	R2, R8,	#0xC
		ldub	R0, @(1, R2)
		slli	R0, #0x1A || nop
		bltz	R0, loc_3BE0
		bl.l	sub_3EA4
		ldi8	R0, #1
		bra.s	loc_3C6C
; ---------------------------------------------------------------------------

loc_3BE0:				; CODE XREF: sub_3BB8+1Cj
		ldub	R0, @(1, R2)
		and3	R0, R0,	#0xDF
		add3	R1, R8,	#0xC
		stb	R0, @(1, R2)
		ldub	R0, @(1, R1)
		ldi8	R3, #0
		slli	R0, #0x1A
		bltz	R0, loc_3C30
		ldub	R0, @(1, R1)
		slli	R0, #0x19 || nop
		bltz	R0, loc_3C30
		ldub	R0, @(1, R1)
		slli	R0, #0x18 || nop
		bltz	R0, loc_3C30
		ldub	R1, @R1
		slli	R1, #0x1F
		bltz	R1, loc_3C30
		ldub	R0, @(9, R8)
		and3	R0, R0,	#0xFE
		and3	R3, R3,	#1
		or	R0, R3 || nop
		stb	R0, @(9, R8)

loc_3C30:				; CODE XREF: sub_3BB8+40j sub_3BB8+4Cj ...
		ldi8	R0, #0 || nop
		ldub	R3, @(0x3D7, R8)
		addi	R3, #-1
		mv	R1, R3
		ld24	R2, #0x2808
		add	R1, R2
		ldub	R2, @R1
		ldub	R1, @(0xE, R8)
		slli	R1, #0x1F
		mv	R2, R2
		bltz	R1, loc_3C5C
		ld24	R1, #0x280C
		add	R3, R1
		ldub	R2, @R3
		mv	R2, R2 || nop

loc_3C5C:				; CODE XREF: sub_3BB8+94j
		ldi8	R1, #3 || nop
		beq	R2, R1,	loc_3C6C
		ldi8	R1, #2 || nop
		stb	R1, @(0xABF, R8)

loc_3C6C:				; CODE XREF: sub_3BB8+26j sub_3BB8+A8j
		pop	lr
		pop	R8
		jmp	lr || nop
; End of function sub_3BB8


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3C74:				; CODE XREF: sub_3B0C+48p
		push	R8
		push	lr
		ld24	R1, #unk_800230
		ldi8	R0, #0xFD
		stb	R0, @R1
		ld24	R8, #unk_801000
		add3	R2, R8,	#0xC
		ldub	R0, @(1, R2)
		slli	R0, #0x19 || nop
		bltz	R0, loc_3C9C
		bl.l	sub_3F54
		ldi8	R0, #1
		bra.s	loc_3D28
; ---------------------------------------------------------------------------

loc_3C9C:				; CODE XREF: sub_3C74+1Cj
		ldub	R0, @(1, R2)
		and3	R0, R0,	#0xBF
		add3	R1, R8,	#0xC
		stb	R0, @(1, R2)
		ldub	R0, @(1, R1)
		ldi8	R3, #0
		slli	R0, #0x1A
		bltz	R0, loc_3CEC
		ldub	R0, @(1, R1)
		slli	R0, #0x19 || nop
		bltz	R0, loc_3CEC
		ldub	R0, @(1, R1)
		slli	R0, #0x18 || nop
		bltz	R0, loc_3CEC
		ldub	R1, @R1
		slli	R1, #0x1F
		bltz	R1, loc_3CEC
		ldub	R0, @(9, R8)
		and3	R0, R0,	#0xFE
		and3	R3, R3,	#1
		or	R0, R3 || nop
		stb	R0, @(9, R8)

loc_3CEC:				; CODE XREF: sub_3C74+40j sub_3C74+4Cj ...
		ldi8	R0, #0 || nop
		ldub	R3, @(0x3D7, R8)
		addi	R3, #-1
		mv	R1, R3
		ld24	R2, #0x2810
		add	R1, R2
		ldub	R2, @R1
		ldub	R1, @(0xE, R8)
		slli	R1, #0x1F
		mv	R2, R2
		bltz	R1, loc_3D18
		ld24	R1, #0x2814
		add	R3, R1
		ldub	R2, @R3
		mv	R2, R2 || nop

loc_3D18:				; CODE XREF: sub_3C74+94j
		ldi8	R1, #3 || nop
		beq	R2, R1,	loc_3D28
		ldi8	R1, #2 || nop
		stb	R1, @(0xAC3, R8)

loc_3D28:				; CODE XREF: sub_3C74+26j sub_3C74+A8j
		pop	lr
		pop	R8
		jmp	lr || nop
; End of function sub_3C74


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3D30:				; CODE XREF: sub_3B0C+34p
		push	R8
		push	lr
		ld24	R1, #unk_800230
		ldi8	R0, #0xFB
		stb	R0, @R1
		ld24	R8, #unk_801000
		add3	R2, R8,	#0xC
		ldub	R0, @(1, R2)
		slli	R0, #0x18 || nop
		bltz	R0, loc_3D58
		bl.l	sub_4004
		ldi8	R0, #1
		bra.s	loc_3DE4
; ---------------------------------------------------------------------------

loc_3D58:				; CODE XREF: sub_3D30+1Cj
		ldub	R0, @(1, R2)
		and3	R0, R0,	#0x7F
		add3	R1, R8,	#0xC
		stb	R0, @(1, R2)
		ldub	R0, @(1, R1)
		ldi8	R3, #0
		slli	R0, #0x1A
		bltz	R0, loc_3DA8
		ldub	R0, @(1, R1)
		slli	R0, #0x19 || nop
		bltz	R0, loc_3DA8
		ldub	R0, @(1, R1)
		slli	R0, #0x18 || nop
		bltz	R0, loc_3DA8
		ldub	R1, @R1
		slli	R1, #0x1F
		bltz	R1, loc_3DA8
		ldub	R0, @(9, R8)
		and3	R0, R0,	#0xFE
		and3	R3, R3,	#1
		or	R0, R3 || nop
		stb	R0, @(9, R8)

loc_3DA8:				; CODE XREF: sub_3D30+40j sub_3D30+4Cj ...
		ldi8	R0, #0 || nop
		ldub	R3, @(0x3D7, R8)
		addi	R3, #-1
		mv	R1, R3
		ld24	R2, #0x2818
		add	R1, R2
		ldub	R2, @R1
		ldub	R1, @(0xE, R8)
		slli	R1, #0x1F
		mv	R2, R2
		bltz	R1, loc_3DD4
		ld24	R1, #0x281C
		add	R3, R1
		ldub	R2, @R3
		mv	R2, R2 || nop

loc_3DD4:				; CODE XREF: sub_3D30+94j
		ldi8	R1, #3 || nop
		beq	R2, R1,	loc_3DE4
		ldi8	R1, #2 || nop
		stb	R1, @(0xAC7, R8)

loc_3DE4:				; CODE XREF: sub_3D30+26j sub_3D30+A8j
		pop	lr
		pop	R8
		jmp	lr || nop
; End of function sub_3D30


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3DEC:				; CODE XREF: sub_3B0C+5Cp
		push	R8
		push	lr
		ld24	R1, #unk_800230
		ldi8	R0, #0xF7
		stb	R0, @R1
		ld24	R8, #unk_801000
		add3	R2, R8,	#0xC
		ldub	R0, @R2
		slli	R0, #0x1F
		bltz	R0, loc_3E10
		bl.l	sub_40B4
		ldi8	R0, #1
		bra.s	loc_3E9C
; ---------------------------------------------------------------------------

loc_3E10:				; CODE XREF: sub_3DEC+18j
		ldub	R0, @R2	|| nop
		and3	R0, R0,	#0xFE
		stb	R0, @R2	|| nop
		add3	R1, R8,	#0xC
		ldub	R0, @(1, R1)
		ldi8	R3, #0
		slli	R0, #0x1A
		bltz	R0, loc_3E60
		ldub	R0, @(1, R1)
		slli	R0, #0x19 || nop
		bltz	R0, loc_3E60
		ldub	R0, @(1, R1)
		slli	R0, #0x18 || nop
		bltz	R0, loc_3E60
		ldub	R1, @R1
		slli	R1, #0x1F
		bltz	R1, loc_3E60
		ldub	R0, @(9, R8)
		and3	R0, R0,	#0xFE
		and3	R3, R3,	#1
		or	R0, R3 || nop
		stb	R0, @(9, R8)

loc_3E60:				; CODE XREF: sub_3DEC+3Cj sub_3DEC+48j ...
		ldi8	R0, #0 || nop
		ldub	R3, @(0x3D7, R8)
		addi	R3, #-1
		mv	R1, R3
		ld24	R2, #0x2820
		add	R1, R2
		ldub	R2, @R1
		ldub	R1, @(0xE, R8)
		slli	R1, #0x1F
		mv	R2, R2
		bltz	R1, loc_3E8C
		ld24	R1, #0x2824
		add	R3, R1
		ldub	R2, @R3
		mv	R2, R2 || nop

loc_3E8C:				; CODE XREF: sub_3DEC+90j
		ldi8	R1, #3 || nop
		beq	R2, R1,	loc_3E9C
		ldi8	R1, #2 || nop
		stb	R1, @(0xACB, R8)

loc_3E9C:				; CODE XREF: sub_3DEC+22j sub_3DEC+A4j
		pop	lr
		pop	R8
		jmp	lr || nop
; End of function sub_3DEC


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3EA4:				; CODE XREF: sub_3B0C+70p sub_3BB8+20p
		push	R8
		push	R9
		push	R10
		push	lr
		ld24	R8, #unk_801000
		ldub	R0, @(0xE, R8)
		and3	R0, R0,	#0xEF
		stb	R0, @(0xE, R8)
		ldub	R0, @(0x13, R8)
		and3	R0, R0,	#0xFE
		ld24	R9, #unk_800000
		stb	R0, @(0x13, R8)
		lduh	R0, @(0x2FE, R9)
		ldi8	R2, #0
		slli	R0, #0x1F
		bltz	R0, loc_3F40
		add3	R1, R8,	#0xC
		ldub	R0, @R1
		slli	R0, #0x1E
		bltz	R0, loc_3F30
		ldub	R0, @(0x87C, R8)
		bnez	R0, loc_3F20
		ldub	R0, @(0xA96, R8)
		beqz	R0, loc_3F20
		lduh	R1, @(0xA90, R8)
		beqz	R1, loc_3F20
		ldi8	R4, #1 || nop
		sth	R1, @(0x874, R8)
		bl.l	sub_6084
		ldub	R0, @(0xC, R8)
		or3	R0, R0,	#2
		stb	R0, @(0xC, R8)

loc_3F14:				; CODE XREF: sub_3EA4+78j
		ldub	R0, @(0x230, R9)
		slli	R0, #0x1F || nop
		bgez	R0, loc_3F14

loc_3F20:				; CODE XREF: sub_3EA4+44j sub_3EA4+4Cj ...
		add3	R10, R8, #0xA96
		ldub	R4, @R10 || nop
		bl.l	sub_37B4
		stb	R0, @R10
		bra.s	loc_3F40
; ---------------------------------------------------------------------------

loc_3F30:				; CODE XREF: sub_3EA4+3Cj
		and3	R2, R2,	#1
		slli	R2, #1
		ldub	R0, @R1
		and3	R0, R0,	#0xFD
		or	R0, R2
		stb	R0, @R1

loc_3F40:				; CODE XREF: sub_3EA4+30j sub_3EA4+8Aj
		ldi8	R0, #0xFE || nop
		stb	R0, @(0x230, R9)
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		jmp	lr || nop
; End of function sub_3EA4


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_3F54:				; CODE XREF: sub_3B0C+90p sub_3C74+20p
		push	R8
		push	R9
		push	R10
		push	lr
		ld24	R8, #unk_801000
		ldub	R0, @(0xE, R8)
		and3	R0, R0,	#0xDF
		stb	R0, @(0xE, R8)
		ldub	R0, @(0x13, R8)
		and3	R0, R0,	#0xFD
		ld24	R9, #unk_800000
		stb	R0, @(0x13, R8)
		lduh	R0, @(0x2FE, R9)
		ldi8	R2, #0
		slli	R0, #0x1E
		bltz	R0, loc_3FF0
		add3	R1, R8,	#0xC
		ldub	R0, @R1
		slli	R0, #0x1D
		bltz	R0, loc_3FE0
		ldub	R0, @(0x87C, R8)
		bnez	R0, loc_3FD0
		ldub	R0, @(0xA96, R8)
		beqz	R0, loc_3FD0
		lduh	R1, @(0xA90, R8)
		beqz	R1, loc_3FD0
		ldi8	R4, #2 || nop
		sth	R1, @(0x876, R8)
		bl.l	sub_6084
		ldub	R0, @(0xC, R8)
		or3	R0, R0,	#4
		stb	R0, @(0xC, R8)

loc_3FC4:				; CODE XREF: sub_3F54+78j
		ldub	R0, @(0x230, R9)
		slli	R0, #0x1E || nop
		bgez	R0, loc_3FC4

loc_3FD0:				; CODE XREF: sub_3F54+44j sub_3F54+4Cj ...
		add3	R10, R8, #0xA96
		ldub	R4, @R10 || nop
		bl.l	sub_37B4
		stb	R0, @R10
		bra.s	loc_3FF0
; ---------------------------------------------------------------------------

loc_3FE0:				; CODE XREF: sub_3F54+3Cj
		and3	R2, R2,	#1
		slli	R2, #2
		ldub	R0, @R1
		and3	R0, R0,	#0xFB
		or	R0, R2
		stb	R0, @R1

loc_3FF0:				; CODE XREF: sub_3F54+30j sub_3F54+8Aj
		ldi8	R0, #0xFD || nop
		stb	R0, @(0x230, R9)
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		jmp	lr || nop
; End of function sub_3F54


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_4004:				; CODE XREF: sub_3B0C+80p sub_3D30+20p
		push	R8
		push	R9
		push	R10
		push	lr
		ld24	R8, #unk_801000
		ldub	R0, @(0xE, R8)
		and3	R0, R0,	#0xBF
		stb	R0, @(0xE, R8)
		ldub	R0, @(0x13, R8)
		and3	R0, R0,	#0xFB
		ld24	R9, #unk_800000
		stb	R0, @(0x13, R8)
		lduh	R0, @(0x2FE, R9)
		ldi8	R2, #0
		slli	R0, #0x1D
		bltz	R0, loc_40A0
		add3	R1, R8,	#0xC
		ldub	R0, @R1
		slli	R0, #0x1C
		bltz	R0, loc_4090
		ldub	R0, @(0x87C, R8)
		bnez	R0, loc_4080
		ldub	R0, @(0xA96, R8)
		beqz	R0, loc_4080
		lduh	R1, @(0xA90, R8)
		beqz	R1, loc_4080
		ldi8	R4, #3 || nop
		sth	R1, @(0x878, R8)
		bl.l	sub_6084
		ldub	R0, @(0xC, R8)
		or3	R0, R0,	#8
		stb	R0, @(0xC, R8)

loc_4074:				; CODE XREF: sub_4004+78j
		ldub	R0, @(0x230, R9)
		slli	R0, #0x1D || nop
		bgez	R0, loc_4074

loc_4080:				; CODE XREF: sub_4004+44j sub_4004+4Cj ...
		add3	R10, R8, #0xA96
		ldub	R4, @R10 || nop
		bl.l	sub_37B4
		stb	R0, @R10
		bra.s	loc_40A0
; ---------------------------------------------------------------------------

loc_4090:				; CODE XREF: sub_4004+3Cj
		and3	R2, R2,	#1
		slli	R2, #3
		ldub	R0, @R1
		and3	R0, R0,	#0xF7
		or	R0, R2
		stb	R0, @R1

loc_40A0:				; CODE XREF: sub_4004+30j sub_4004+8Aj
		ldi8	R0, #0xFB || nop
		stb	R0, @(0x230, R9)
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		jmp	lr || nop
; End of function sub_4004


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_40B4:				; CODE XREF: sub_3B0C+A0p sub_3DEC+1Cp
		push	R8
		push	R9
		push	R10
		push	lr
		ld24	R8, #unk_801000
		ldub	R0, @(0xE, R8)
		and3	R0, R0,	#0x7F
		stb	R0, @(0xE, R8)
		ldub	R0, @(0x13, R8)
		and3	R0, R0,	#0xF7
		ld24	R9, #unk_800000
		stb	R0, @(0x13, R8)
		lduh	R0, @(0x2FE, R9)
		ldi8	R2, #0
		slli	R0, #0x1C
		bltz	R0, loc_4150
		add3	R1, R8,	#0xC
		ldub	R0, @R1
		slli	R0, #0x1B
		bltz	R0, loc_4140
		ldub	R0, @(0x87C, R8)
		bnez	R0, loc_4130
		ldub	R0, @(0xA96, R8)
		beqz	R0, loc_4130
		lduh	R1, @(0xA90, R8)
		beqz	R1, loc_4130
		ldi8	R4, #4 || nop
		sth	R1, @(0x87A, R8)
		bl.l	sub_6084
		ldub	R0, @(0xC, R8)
		or3	R0, R0,	#0x10
		stb	R0, @(0xC, R8)

loc_4124:				; CODE XREF: sub_40B4+78j
		ldub	R0, @(0x230, R9)
		slli	R0, #0x1C || nop
		bgez	R0, loc_4124

loc_4130:				; CODE XREF: sub_40B4+44j sub_40B4+4Cj ...
		add3	R10, R8, #0xA96
		ldub	R4, @R10 || nop
		bl.l	sub_37B4
		stb	R0, @R10
		bra.s	loc_4150
; ---------------------------------------------------------------------------

loc_4140:				; CODE XREF: sub_40B4+3Cj
		and3	R2, R2,	#1
		slli	R2, #4
		ldub	R0, @R1
		and3	R0, R0,	#0xEF
		or	R0, R2
		stb	R0, @R1

loc_4150:				; CODE XREF: sub_40B4+30j sub_40B4+8Aj
		ldi8	R0, #0xF7 || nop
		stb	R0, @(0x230, R9)
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		jmp	lr ||\
; End of function sub_40B4

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_4164:				; DATA XREF: ROM_:000000C0o
		ldi8	R0, #0xDD || nop
		ld24	R4, #unk_800000
		stb	R0, @(0x232, R4)
		ldub	R0, @(0x70B, R4)
		slli	R0, #0x1E || nop
		ld24	R2, #unk_801000
		bltz	R0, locret_41C4
		ldub	R0, @(0xB, R2)
		slli	R0, #0x1D || nop
		bltz	R0, locret_41C4
		ldub	R3, @(0x3D7, R2)
		addi	R3, #-1
		mv	R0, R3
		ld24	R1, #0x27FC
		add	R0, R1
		ldub	R5, @R0
		ldub	R0, @(0x1C, R2)
		slli	R0, #0x1C
		mv	R5, R5
		bgez	R0, loc_41B4
		ld24	R0, #0x2800
		add	R3, R0
		ldub	R5, @R3
		mv	R5, R5 || nop

loc_41B4:				; CODE XREF: sub_4164+40j
		add3	R0, R4,	#0x704
		ldub	R1, @R0	|| nop
		and3	R1, R1,	#0x87
		or	R1, R5
		stb	R1, @R0

locret_41C4:				; CODE XREF: sub_4164+18j sub_4164+24j
		jmp	lr ||\
; End of function sub_4164

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_41C8:				; DATA XREF: ROM_:000000B0o
		ld24	R0, #unk_800226
		lduh	R0, @R0
		slli	R0, #0x15
		ld24	R2, #0x100
		ld24	R3, #unk_801000
		bgez	R0, locret_4258
		ldub	R0, @(0x1C81, R2)
		add3	R1, R3,	#0x38
		stb	R0, @(0xACD, R3)
		ldub	R0, @R1
		slli	R0, #0x18
		bltz	R0, loc_4218
		ldub	R0, @R1
		slli	R0, #0x1B
		bgez	R0, loc_4218
		ldub	R0, @(0x1C82, R2)
		ldub	R1, @(0x9B6, R3)
		cmp	R0, R1
		bc.s	loc_4218
		ldub	R0, @(0x1C83, R2)
		ldub	R1, @(0xAF8, R3)
		cmp	R0, R1
		bc.s	loc_4218
		ldub	R0, @(0x1C80, R2)
		stb	R0, @(0xACD, R3)

loc_4218:				; CODE XREF: sub_41C8+24j sub_41C8+2Cj ...
		lduh	R5, @(0xA56, R3)
		bra.s	loc_4238 || nop
; ---------------------------------------------------------------------------

loc_4220:				; CODE XREF: sub_41C8+74j
		addi	R4, #-1	|| nop
		lduh	R0, @(0xA46, R3)
		ldi8	R1, #2
		add	R0, R5
		stb	R4, @(0xACD, R3)
		div	R0, R1
		and3	R5, R0,	#0xFFFF

loc_4238:				; CODE XREF: sub_41C8+54j
		ldub	R4, @(0xACD, R3)
		bnez	R4, loc_4220
		srl3	R1, R5,	#1
		sth	R5, @(0xA46, R3)
		and3	R5, R5,	#1
		add	R1, R5 || nop
		ld24	R0, #unk_8002E2
		addi	R1, #-1
		sth	R1, @R0

locret_4258:				; CODE XREF: sub_41C8+10j
		jmp	lr ||\
; End of function sub_41C8

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_425C:				; CODE XREF: sub_32C8+18p
		ld24	R3, #unk_801000
		ldub	R0, @(9, R3)
		slli	R0, #0x19 || nop
		ld24	R2, #unk_800000
		bltz	R0, loc_4290
		ldub	R0, @(9, R3)
		or3	R0, R0,	#0x40
		stb	R0, @(9, R3)
		ldi8	R0, #0 || nop
		st	R0, @(0x3E0, R2)
		st	R0, @(0x98C, R3)
		st	R0, @(0x990, R3)
		bra.s	loc_42A4 || nop
; ---------------------------------------------------------------------------

loc_4290:				; CODE XREF: sub_425C+10j
		add3	R1, R3,	#0x990
		ld	R0, @R1	|| nop
		st	R0, @(0x98C, R3)
		ld	R0, @(0x3F4, R2)
		st	R0, @R1	|| nop

loc_42A4:				; CODE XREF: sub_425C+30j
		ld	R0, @(0x990, R3)
		ld	R1, @(0x98C, R3)
		ldi8	R5, #0
		sub	R0, R1
		lduh	R4, @(0x212, R2)
		st	R0, @(0x994, R3)
		and3	R0, R4,	#2
		beqz	R0, loc_42E0
		add3	R0, R2,	#0x212
		lduh	R1, @R0	|| nop
		and3	R1, R1,	#0xFFFD
		or3	R1, R1,	#1
		sth	R1, @R0	|| nop
		ld	R0, @(0x994, R3)
		st	R0, @(0x988, R3)
		bra.s	loc_4384 || nop
; ---------------------------------------------------------------------------

loc_42E0:				; CODE XREF: sub_425C+60j
		lduh	R0, @(0x9AE, R3)
		cmpui	R0, #0x18
		bnc.s	loc_4308 || nop
		and3	R4, R4,	#0xFFFE
		or3	R4, R4,	#2
		sth	R4, @(0x212, R2)
		ld	R0, @(0x994, R3)
		cmpui	R0, #0x1388
		bc.s	loc_4384
		ldi8	R5, #1
		bra.s	loc_4384 || nop
; ---------------------------------------------------------------------------

loc_4308:				; CODE XREF: sub_425C+8Cj
		ldub	R0, @(0x1E, R3)
		ldi8	R5, #1
		slli	R0, #0x1C
		bgez	R0, loc_4384
		ldub	R0, @(0xA, R3)
		slli	R0, #0x1C || nop
		bgez	R0, loc_4384
		ldub	R0, @(0xA, R3)
		slli	R0, #0x1B || nop
		bgez	R0, loc_4384

loc_432C:				; CODE XREF: sub_425C+E0j
		ld	R0, @(0x3E0, R2)
		add3	R4, R3,	#0x990
		ld	R1, @R4
		sub	R0, R1
		cmpui	R0, #0x32 ; '2'
		bc.s	loc_432C || nop
		ldub	R0, @(0x70F, R2)
		slli	R0, #0x18 || nop
		bgez	R0, loc_437C
		ldub	R0, @(0x238, R2)
		slli	R0, #0x1B || nop
		bgez	R0, loc_4384
		ld	R0, @(0x3F4, R2)
		st	R0, @(0x990, R3)
		ld	R1, @(0x98C, R3)
		sub	R0, R1 || nop
		st	R0, @(0x994, R3)
		add3	R0, R2,	#0x238
		ldub	R1, @R0	|| nop
		and3	R1, R1,	#0xEF
		stb	R1, @R0
		bra.s	loc_4384
; ---------------------------------------------------------------------------

loc_437C:				; CODE XREF: sub_425C+ECj
		ld	R0, @(0x98C, R3)
		ldi8	R5, #0
		st	R0, @R4

loc_4384:				; CODE XREF: sub_425C+80j sub_425C+A4j ...
		beqz	R5, loc_4398
		ldub	R0, @(0xE, R3)
		and3	R0, R0,	#0xFB
		stb	R0, @(0xE, R3)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_4398:				; CODE XREF: sub_425C:loc_4384j
		ldub	R0, @(0xE, R3)
		or3	R0, R0,	#4
		stb	R0, @(0xE, R3)
		ldub	R0, @(9, R3)
		or3	R0, R0,	#0x80
		stb	R0, @(9, R3)
		jmp	lr || nop
; End of function sub_425C


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_43B4:				; CODE XREF: sub_C998+24p
		ld24	R1, #unk_801008
		ldub	R0, @(1, R1)
		and3	R0, R0,	#0x3F
		stb	R0, @(1, R1)
		ld24	R0, #unk_800212
		lduh	R1, @R0	|| nop
		and3	R1, R1,	#0xFFFE
		or3	R1, R1,	#2
		sth	R1, @R0	|| nop
		ld24	R0, #unk_16612A
		ld24	R1, #unk_801A5C
		st	R0, @R1
		jmp	lr
; End of function sub_43B4


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_43E4:				; CODE XREF: sub_32C8+2Cp
		push	R8
		push	R9
		push	R10
		push	lr
		ld24	R8, #unk_800000
		add3	R1, R8,	#0x410
		add3	R2, R8,	#0x420
		ldub	R4, @R1
		ldub	R6, @R2
		add3	R0, R8,	#0x430
		ldub	R7, @R0
		ldub	R3, @R1
		and3	R3, R3,	#0xF7
		stb	R3, @R1
		ldub	R3, @R2
		and3	R3, R3,	#0xF7
		stb	R3, @R2
		ldub	R3, @R0
		and3	R3, R3,	#0xF7
		stb	R3, @R0	|| nop
		ldub	R5, @(0x431, R8)
		not	R5, R5 || nop
		and3	R5, R5,	#0xFF
		ld24	R9, #unk_801000
		stb	R5, @(0x3A4, R9)
		ldub	R3, @R1
		or	R3, R4
		or3	R3, R3,	#0x40
		stb	R3, @R1
		ldub	R1, @R2
		or	R1, R6 || nop
		or3	R1, R1,	#0x40
		stb	R1, @R2
		ldub	R1, @R0
		or	R1, R7 || nop
		cmpui	R5, #0x19
		or3	R1, R1,	#0x40
		stb	R1, @R0
		bc.s	loc_4464
		ldub	R0, @(0xB, R9)
		or3	R0, R0,	#0x80
		stb	R0, @(0xB, R9)

loc_4464:				; CODE XREF: sub_43E4+72j
		ldi8	R0, #0 || nop
		add3	R1, R8,	#0x430
		stb	R0, @R1
		ldi8	R0, #0xFF
		stb	R0, @(0x431, R8)
		ldi8	R0, #0x2C ; ','
		stb	R0, @R1
		ldub	R0, @(0xA, R9)
		slli	R0, #0x1E || nop
		bltz	R0, loc_4498
		ldub	R0, @(0xA, R9)
		or3	R0, R0,	#2
		stb	R0, @(0xA, R9)
		ldi8	R0, #4 || nop
		stb	R0, @(0x3A4, R9)

loc_4498:				; CODE XREF: sub_43E4+9Cj
		ldub	R0, @(0x3A4, R9)
		bnez	R0, loc_44C0
		add3	R10, R9, #0x3A5
		ldi8	R5, #0
		ldub	R4, @R10
		bl.l	sub_378C
		stb	R0, @R10 || nop
		ldub	R0, @(0xE, R9)
		and3	R0, R0,	#0xFD
		stb	R0, @(0xE, R9)
		bra.s	loc_44FC || nop
; ---------------------------------------------------------------------------

loc_44C0:				; CODE XREF: sub_43E4+B8j
		ldi8	R1, #0 || nop
		stb	R1, @(0x3A5, R9)
		ldub	R0, @(0x68, R9)
		and3	R0, R0,	#0xDF
		stb	R0, @(0x68, R9)
		ldub	R0, @(0xE, R9)
		or3	R0, R0,	#2
		cmpui	R5, #0x19
		stb	R0, @(0xE, R9)
		bnc.s	loc_44FC || nop
		ldub	R0, @(0xB, R9)
		and3	R1, R1,	#1
		and3	R0, R0,	#0x7F
		slli	R1, #7
		or	R0, R1
		stb	R0, @(0xB, R9)

loc_44FC:				; CODE XREF: sub_43E4+D8j
					; sub_43E4+100j
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		jmp	lr ||\
; End of function sub_43E4

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_4508:				; CODE XREF: sub_32C8+60p
		push	R8
		push	R9
		push	lr
		ld24	R9, #unk_801000
		add3	R8, R9,	#0x3D7
		ldub	R4, @(0x3A4, R9)
		ldub	R2, @R8
		bra.s	loc_459C
; ---------------------------------------------------------------------------

loc_4520:				; CODE XREF: sub_4508+98j
		bnez	R2, loc_4534
		ldub	R0, @(0xB, R9)
		or3	R0, R0,	#8
		stb	R0, @(0xB, R9)
		bra.s	loc_45B8 || nop
; ---------------------------------------------------------------------------

loc_4534:				; CODE XREF: sub_4508:loc_4520j
		cmpui	R2, #4
		bc.s	loc_4544
		ldi8	R0, #1
		stb	R0, @(0x3D7, R9)
		bra.s	loc_45B8 || nop
; ---------------------------------------------------------------------------

loc_4544:				; CODE XREF: sub_4508+30j
		ldi8	R0, #2 || nop
		stb	R0, @(0x3D7, R9)
		bra.s	loc_45B8 || nop
; ---------------------------------------------------------------------------

loc_4550:				; CODE XREF: sub_4508+A0j
		bnez	R2, loc_4560
		ldi8	R0, #4 || nop
		stb	R0, @(0x3D7, R9)
		bra.s	loc_45B8 || nop
; ---------------------------------------------------------------------------

loc_4560:				; CODE XREF: sub_4508:loc_4550j
		ldi8	R4, #4
		bl.s	sub_45C0
		stb	R0, @(0x3D7, R9)
		bra.s	loc_45B8 || nop
; ---------------------------------------------------------------------------

loc_456C:				; CODE XREF: sub_4508+A8j
		bnez	R2, loc_4578
		stb	R4, @(0x3D7, R9)
		bra.s	loc_45B8 || nop
; ---------------------------------------------------------------------------

loc_4578:				; CODE XREF: sub_4508:loc_456Cj
		bl.s	sub_45C0 || nop
		stb	R0, @R8
		bra.s	loc_45B8
; ---------------------------------------------------------------------------

loc_4580:				; CODE XREF: sub_4508+ACj
		add3	R0, R9,	#0x3D8
		ldub	R1, @R0
		addi	R1, #1
		stb	R1, @R0	|| nop
		beqz	R2, loc_45B8
		bl.s	sub_45C0 || nop
		stb	R0, @(0x3D7, R9)
		bra.s	loc_45B8 || nop
; ---------------------------------------------------------------------------

loc_459C:				; CODE XREF: sub_4508+16j
		ldi8	R0, #1 || nop
		beq	R4, R0,	loc_4520
		ldi8	R0, #2 || nop
		beq	R4, R0,	loc_4550
		ldi8	R0, #3 || nop
		beq	R4, R0,	loc_456C
		bra.s	loc_4580 || nop
; ---------------------------------------------------------------------------

loc_45B8:				; CODE XREF: sub_4508+28j sub_4508+38j ...
		pop	lr
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_4508


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_45C0:				; CODE XREF: sub_4508+5Ap
					; sub_4508:loc_4578p ...
		push	R8
		push	R9
		push	R10
		push	lr
		ld24	R10, #unk_801000
		ldub	R0, @(0x3D7, R10)
		mv	R8, R4
		addi	R0, #-1
		ld24	R1, #0x2804
		add	R0, R1
		ldub	R3, @R0
		bne	R8, R3,	loc_45F0
		add3	R9, R10, #0x3D6
		ldi8	R5, #0
		ldub	R4, @R9
		bl.l	sub_378C
		stb	R0, @R9
		bra.s	loc_4638
; ---------------------------------------------------------------------------

loc_45F0:				; CODE XREF: sub_45C0+1Cj
		add3	R1, R10, #0x3D8
		ld24	R2, #0xB6C
		ldub	R0, @R1
		lduh	R2, @R2
		addi	R0, #1
		stb	R0, @R1
		lduh	R1, @(0x9AE, R10)
		cmp	R1, R2
		bc.s	loc_4614
		ldub	R0, @(0x3D6, R10)
		cmpui	R0, #4
		bnc.s	loc_462C || nop

loc_4614:				; CODE XREF: sub_45C0+46j
		and3	R2, R2,	#0xFFFF
		cmp	R1, R2
		bnc.s	loc_4630
		ld24	R0, #0xB6E
		ldub	R0, @R0	|| nop
		ldub	R1, @(0x3D6, R10)
		cmp	R1, R0
		bc.s	loc_4630

loc_462C:				; CODE XREF: sub_45C0+50j
		and3	R8, R3,	#0xFF

loc_4630:				; CODE XREF: sub_45C0+5Aj sub_45C0+6Aj
		ldi8	R0, #0 || nop
		stb	R0, @(0x3D6, R10)

loc_4638:				; CODE XREF: sub_45C0+2Ej
		mv	R0, R8
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_45C0


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_4644:				; CODE XREF: sub_C998+28p
		ldi8	R0, #0 || nop
		ld24	R1, #unk_801000
		stb	R0, @(0x3D7, R1)
		stb	R0, @(0x3D6, R1)
		stb	R0, @(0x3D8, R1)
		ldub	R0, @(0xB, R1)
		and3	R0, R0,	#0xF7
		stb	R0, @(0xB, R1)
		ldub	R0, @(0xA, R1)
		and3	R0, R0,	#0xFD
		stb	R0, @(0xA, R1)
		jmp	lr ||\
; End of function sub_4644

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_4674:				; CODE XREF: sub_32C8+64p
		push	R8
		push	lr
		ld24	R8, #unk_801000
		ld	R0, @(0x994, R8)
		add3	R1, R8,	#0x988
		ld	R2, @R1
		add	R2, R0
		ldi8	R0, #5
		slli	R2, #1
		divu	R2, R0
		ldi8	R0, #0
		st	R0, @R1
		ldi8	R0, #0x5D ; ']' || nop
		st	R2, @(0xA64, R8)
		slli	R2, #1 || nop
		divu	R2, R0
		and3	R0, R2,	#1
		srli	R2, #1
		add	R2, R0
		mv	R4, R2 || nop
		bl.l	sub_3714
		sth	R0, @(0xA68, R8)
		pop	lr
		pop	R8
		jmp	lr ||\
; End of function sub_4674

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_46C0:				; CODE XREF: sub_32C8+F8p
		push	R8
		push	R9
		push	lr
		ld24	R9, #unk_801000
		ld	R0, @(0x994, R9)
		add3	R1, R9,	#0x988
		ld	R2, @R1
		add	R2, R0
		ldi8	R0, #5
		slli	R2, #1
		divu	R2, R0
		ldi8	R0, #0 || nop
		add3	R8, R9,	#0xA50
		st	R0, @R1
		st	R2, @R8
		slli	R2, #1
		srli	R2, #5
		and3	R0, R2,	#1
		srli	R2, #1
		add	R2, R0
		mv	R4, R2 || nop
		bl.l	sub_3714
		sth	R0, @(0xA54, R9)
		ld	R4, @(0xA64, R9)
		ld	R0, @(0xA5C, R9)
		ld	R8, @R8
		add	R4, R0
		add	R4, R8 || nop
		st	R4, @(0xA4C, R9)
		srli	R4, #4 || nop
		st	R4, @(0xA48, R9)
		srli	R4, #1 || nop
		bl.l	sub_3714
		sth	R0, @(0xA56, R9)
		pop	lr
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_46C0


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_4734:				; CODE XREF: sub_32C8:loc_3438p
		push	R8
		push	lr
		ld24	R8, #unk_801000
		ld	R0, @(0x994, R8)
		add3	R1, R8,	#0x988
		ld	R2, @R1
		add	R2, R0
		ldi8	R0, #5
		slli	R2, #2
		divu	R2, R0
		ldi8	R0, #0
		st	R0, @R1
		ldi8	R0, #0x37 ; '7' || nop
		st	R2, @(0xA58, R8)
		srli	R2, #1 || nop
		st	R2, @(0xA5C, R8)
		slli	R2, #1 || nop
		divu	R2, R0
		and3	R0, R2,	#1
		srli	R2, #1
		add	R2, R0
		mv	R4, R2 || nop
		bl.l	sub_3714
		sth	R0, @(0xA60, R8)
		pop	lr
		pop	R8
		jmp	lr ||\
; End of function sub_4734

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_4788:				; CODE XREF: sub_32C8+108p
		push	R8
		push	R9
		push	R10
		push	lr
		ld24	R9, #unk_801000
		add3	R2, R9,	#0x9A8
		lduh	R0, @R2	|| nop
		sth	R0, @(0x9AC, R9)
		add3	R0, R9,	#0x9A4
		lduh	R1, @R0
		sth	R1, @R2
		add3	R1, R9,	#0x9A0
		lduh	R2, @R1
		sth	R2, @R0
		ldi8	R2, #0x64 ; 'd' || nop
		lduh	R0, @(0x99C, R9)
		ldi8	R10, #8
		sth	R0, @R1
		ld	R1, @(0xA48, R9)
		ld24	R0, #unk_50000
		ld24	R8, #unk_802520
		cmpu	R1, R0
		bnc.s	loc_47E8
		seth	R2, #0x1C9
		or3	R2, R2,	#0xC380
		ld24	R10, #unk_249F00
		divu	R2, R1
		divu	R10, R1
		and3	R2, R2,	#0xFFFF
		and3	R10, R10, #0xFFFF

loc_47E8:				; CODE XREF: sub_4788+42j
		srl3	R0, R10, #2
		sth	R10, @(0x99C, R9)
		sth	R10, @(2, R8)
		mv	R4, R0
		sth	R10, @R8
		sth	R2, @(8, R8)
		sth	R0, @(0x9B0, R9)
		bl.l	sub_36E4
		srl3	R4, R10, #3
		stb	R0, @(0x9B5, R9)
		bl.l	sub_36E4
		srl3	R4, R10, #4
		stb	R0, @(0x9B7, R9)
		bl.l	sub_36E4
		stb	R0, @(0x9B3, R9)
		lduh	R0, @(0x9A0, R9)
		sub	R10, R0	|| nop
		sth	R10, @(0x998, R9)
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		jmp	lr || nop
; End of function sub_4788


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_4838:				; CODE XREF: sub_C998+2Cp
		ldi8	R0, #8 || nop
		ld24	R1, #unk_801000
		ld24	R2, #unk_802520
		sth	R0, @(0x99C, R1)
		sth	R0, @(0x99A, R1)
		sth	R0, @(2, R2)
		sth	R0, @R2	|| nop
		sth	R0, @(0x9A0, R1)
		sth	R0, @(0x99E, R1)
		sth	R0, @(0x9A4, R1)
		sth	R0, @(0x9A2, R1)
		sth	R0, @(0x9A8, R1)
		sth	R0, @(0x9A6, R1)
		sth	R0, @(0x9AC, R1)
		sth	R0, @(0x9AA, R1)
		ldi8	R0, #2 || nop
		sth	R0, @(0x9B0, R1)
		sth	R0, @(0x9AE, R1)
		stb	R0, @(0x9B5, R1)
		stb	R0, @(0x9B4, R1)
		ldi8	R0, #1 || nop
		stb	R0, @(0x9B7, R1)
		stb	R0, @(0x9B6, R1)
		ldi8	R0, #0 || nop
		stb	R0, @(0x9B3, R1)
		stb	R0, @(0x9B2, R1)
		ldi8	R0, #0x64 ; 'd' || nop
		sth	R0, @(8, R2)
		jmp	lr || nop
; End of function sub_4838


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_48AC:				; CODE XREF: sub_CEF4+4p
		ld24	R1, #unk_801000
		lduh	R0, @(0x99C, R1)
		sth	R0, @(0x99A, R1)
		lduh	R0, @(0x9A0, R1)
		sth	R0, @(0x99E, R1)
		lduh	R0, @(0x9A4, R1)
		sth	R0, @(0x9A2, R1)
		lduh	R0, @(0x9A8, R1)
		sth	R0, @(0x9A6, R1)
		lduh	R0, @(0x9AC, R1)
		sth	R0, @(0x9AA, R1)
		lduh	R0, @(0x9B0, R1)
		sth	R0, @(0x9AE, R1)
		ldub	R0, @(0x9B5, R1)
		stb	R0, @(0x9B4, R1)
		ldub	R0, @(0x9B7, R1)
		stb	R0, @(0x9B6, R1)
		ldub	R0, @(0x9B3, R1)
		stb	R0, @(0x9B2, R1)
		jmp	lr ||\
; End of function sub_48AC

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_48FC:				; CODE XREF: sub_32C8:loc_3468p
		push	R8
		push	R9
		push	R10
		push	R11
		push	R12
		push	lr
		ld24	R10, #unk_801000
		add3	R11, R10, #0xC
		ldub	R7, @R11
		slli	R7, #0x1A
		srli	R7, #0x1F || nop
		ld24	R8, #0x100
		add3	R5, R8,	#0xBB2
		add3	R6, R8,	#0xBB4
		ld24	R9, #unk_800000
		add3	R4, R10, #0x9AE
		bl.l	sub_3584
		and3	R0, R0,	#1
		and3	R2, R0,	#1
		slli	R2, #5
		ldub	R1, @R11
		and3	R1, R1,	#0xDF
		or	R1, R2
		stb	R1, @R11
		beqz	R0, loc_4980
		ldub	R0, @(0xA, R10)
		or3	R0, R0,	#0x40
		sll3	R7, R0,	#0x1A
		srli	R7, #0x1F || nop
		add3	R5, R8,	#0xBAE
		add3	R6, R8,	#0xBB0
		add3	R4, R10, #0x9AE
		and3	R12, R0, #0xDF
		stb	R0, @(0xA, R10)
		bl.l	sub_3584
		and3	R0, R0,	#1
		slli	R0, #5
		or	R12, R0
		stb	R12, @(0xA, R10)
		bra.s	loc_498C || nop
; ---------------------------------------------------------------------------

loc_4980:				; CODE XREF: sub_48FC+48j
		ldub	R0, @(0xA, R10)
		and3	R0, R0,	#0xBF
		stb	R0, @(0xA, R10)

loc_498C:				; CODE XREF: sub_48FC+80j
		ldub	R0, @(0xA, R10)
		slli	R0, #0x19 || nop
		bgez	R0, loc_49B8
		ldub	R0, @(0xA, R10)
		slli	R0, #0x1A || nop
		bltz	R0, loc_49B8
		ldi8	R0, #0 || nop
		stb	R0, @(0x231, R9)
		ldi8	R0, #0xF0 || nop
		stb	R0, @(0x230, R9)
		bra.s	loc_49D4 || nop
; ---------------------------------------------------------------------------

loc_49B8:				; CODE XREF: sub_48FC+98j sub_48FC+A4j
		ldi8	R0, #0xF || nop
		stb	R0, @(0x231, R9)
		ldi8	R0, #0 || nop
		stb	R0, @(0xABF, R10)
		stb	R0, @(0xAC3, R10)
		stb	R0, @(0xAC7, R10)
		stb	R0, @(0xACB, R10)

loc_49D4:				; CODE XREF: sub_48FC+B8j
		pop	lr
		pop	R12
		pop	R11
		pop	R10
		pop	R9
		pop	R8
		jmp	lr || nop
; End of function sub_48FC


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_49E4:				; CODE XREF: sub_C998+38p
		ld24	R2, #unk_801000
		ldub	R0, @(0xA, R2)
		and3	R0, R0,	#0x1F
		stb	R0, @(0xA, R2)
		ldi8	R0, #0 || nop
		stb	R0, @(0x881, R2)
		stb	R0, @(0xAC0, R2)
		stb	R0, @(0xAC4, R2)
		stb	R0, @(0xAC8, R2)
		stb	R0, @(0xACC, R2)
		jmp	lr ||\
; End of function sub_49E4

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_4A10:				; CODE XREF: sub_32C8+6Cp
		push	R8
		push	lr
		ld24	R8, #unk_801000
		ldub	R0, @(0x3D7, R8)
		beqz	R0, loc_4A3C
		ldub	R0, @(0xA, R8)
		slli	R0, #0x19 || nop
		bgez	R0, loc_4A3C
		ldub	R0, @(0xA, R8)
		slli	R0, #0x18 || nop
		bgez	R0, loc_4A3C
		bl.l	sub_4CD8

loc_4A3C:				; CODE XREF: sub_4A10+Cj sub_4A10+18j	...
		pop	lr
		pop	R8
		jmp	lr ||\
; End of function sub_4A10

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_4A44:				; CODE XREF: sub_32C8+1A4p
		push	R8
		push	R9
		push	R10
		push	lr
		ld24	R9, #unk_801000
		ldub	R1, @(0xA, R9)
		ldi8	R0, #0
		slli	R1, #0x19
		bgez	R1, loc_4A74
		ldub	R1, @(0xA, R9)
		slli	R1, #0x18 || nop
		bgez	R1, loc_4A74
		bl.l	sub_178D8
		bl.l	sub_4CD8
		bra.l	loc_4CCC
; ---------------------------------------------------------------------------

loc_4A74:				; CODE XREF: sub_4A44+14j sub_4A44+20j
		ldub	R1, @(0xA, R9)
		slli	R1, #0x19 || nop
		bgez	R1, loc_4BC8
		ldi8	R0, #1
		ldi8	R1, #3
		ldub	R3, @(0x3D7, R9)
		bne	R3, R1,	loc_4AD0
		ldi8	R1, #1 || nop
		ldub	R2, @(0x880, R9)
		bne	R2, R1,	loc_4AD0
		ldi8	R1, #5 || nop
		stb	R1, @(0xABE, R9)
		ldi8	R1, #9 || nop
		stb	R1, @(0xAC2, R9)
		ldi8	R1, #7
		ldi8	R8, #3
		stb	R1, @(0xAC6, R9)
		stb	R8, @(0xACA, R9)
		ldub	R4, @(0xE, R9)
		or3	R1, R4,	#0x50
		stb	R1, @(0xE, R9)
		ldub	R3, @(0x13, R9)
		or3	R3, R3,	#8
		stb	R3, @(0x13, R9)
		bra.s	loc_4BC8 || nop
; ---------------------------------------------------------------------------

loc_4AD0:				; CODE XREF: sub_4A44+44j sub_4A44+50j
		ldi8	R1, #4 || nop
		bne	R3, R1,	loc_4B28
		ldi8	R1, #2 || nop
		ldub	R2, @(0x880, R9)
		bne	R2, R1,	loc_4B28
		ldi8	R1, #9 || nop
		stb	R1, @(0xABE, R9)
		ldi8	R5, #5
		ldi8	R1, #3
		stb	R5, @(0xAC2, R9)
		stb	R1, @(0xAC6, R9)
		ldi8	R1, #7 || nop
		stb	R1, @(0xACA, R9)
		ldub	R2, @(0xE, R9)
		or3	R2, R2,	#0x20
		stb	R2, @(0xE, R9)
		ldub	R1, @(0x13, R9)
		or3	R1, R1,	#4
		stb	R1, @(0x13, R9)
		ldub	R2, @(0xE, R9)
		or3	R2, R2,	#0x80
		stb	R2, @(0xE, R9)
		bra.s	loc_4BC8 || nop
; ---------------------------------------------------------------------------

loc_4B28:				; CODE XREF: sub_4A44+90j sub_4A44+9Cj
		ldi8	R1, #2 || nop
		bne	R3, R1,	loc_4B70
		ldi8	R2, #3 || nop
		ldub	R1, @(0x880, R9)
		bne	R1, R2,	loc_4B70
		ldi8	R2, #3
		ldi8	R1, #7
		stb	R2, @(0xABE, R9)
		stb	R1, @(0xAC2, R9)
		ldi8	R2, #5
		ldi8	R1, #9
		stb	R2, @(0xAC6, R9)
		stb	R1, @(0xACA, R9)
		ldub	R2, @(0x13, R9)
		or3	R1, R2,	#1
		stb	R1, @(0x13, R9)
		ldub	R3, @(0xE, R9)
		or3	R2, R3,	#0x60
		stb	R2, @(0xE, R9)
		bra.s	loc_4BC8 || nop
; ---------------------------------------------------------------------------

loc_4B70:				; CODE XREF: sub_4A44+E8j sub_4A44+F4j
		ldi8	R1, #1 || nop
		bne	R3, R1,	loc_4BC4
		ldi8	R1, #4 || nop
		ldub	R10, @(0x880, R9)
		bne	R10, R1, loc_4BC4
		ldi8	R1, #7
		ldi8	R2, #3
		stb	R1, @(0xABE, R9)
		stb	R2, @(0xAC2, R9)
		ldi8	R1, #9
		ldi8	R2, #5
		stb	R1, @(0xAC6, R9)
		stb	R2, @(0xACA, R9)
		ldub	R2, @(0xE, R9)
		or3	R2, R2,	#0x10
		stb	R2, @(0xE, R9)
		ldub	R3, @(0x13, R9)
		or3	R3, R3,	#2
		stb	R3, @(0x13, R9)
		ldub	R3, @(0xE, R9)
		or3	R2, R3,	#0x80
		stb	R2, @(0xE, R9)
		bra.s	loc_4BC8 || nop
; ---------------------------------------------------------------------------

loc_4BC4:				; CODE XREF: sub_4A44+130j
					; sub_4A44+13Cj
		ldi8	R0, #0 || nop

loc_4BC8:				; CODE XREF: sub_4A44+38j sub_4A44+88j ...
		beqz	R0, loc_4BE0
		bl.l	sub_4CD8
		ldub	R2, @(0xA, R9)
		or3	R2, R2,	#0x80
		stb	R2, @(0xA, R9)
		bra.s	loc_4CCC || nop
; ---------------------------------------------------------------------------

loc_4BE0:				; CODE XREF: sub_4A44:loc_4BC8j
		ldub	R2, @(0xA, R9)
		and3	R2, R2,	#0x3F
		add3	R0, R9,	#0x881
		stb	R2, @(0xA, R9)
		ldub	R2, @R0	|| nop
		xor3	R2, R2,	#1
		and3	R2, R2,	#0xFF
		ldi8	R8, #0
		stb	R2, @R0
		beqz	R2, loc_4C48
		ldub	R1, @(0x882, R9)
		cmpui	R1, #0x10
		bc.s	loc_4C14
		ldi8	R1, #0xF
		bra.s	loc_4C14 || nop

loc_4C14:				; CODE XREF: sub_4A44+1C8j
		lduh	R1, @(0xAB8, R9)
		add3	R10, R9, #0x882
		sth	R1, @(0x87E, R9)
		ldi8	R5, #0
		ldub	R4, @R10
		bl.l	sub_378C
		ldi8	R2, #0
		stb	R0, @R10
		ldub	R3, @(0x3D7, R9)
		stb	R3, @(0x880, R9)
		stb	R2, @(0xABE, R9)
		stb	R2, @(0xAC2, R9)
		stb	R2, @(0xAC6, R9)
		stb	R2, @(0xACA, R9)
		bl.l	sub_4CD8

loc_4C48:				; CODE XREF: sub_4A44+1BCj
		ldub	R2, @(0xE, R9)
		and3	R1, R8,	#1
		and3	R2, R2,	#0xEF
		slli	R1, #4
		or	R2, R1
		and3	R3, R8,	#1
		and3	R1, R2,	#0xDF
		slli	R3, #5
		or	R1, R3
		and3	R3, R8,	#1
		and3	R2, R1,	#0xBF
		slli	R3, #6
		or	R2, R3
		and3	R1, R8,	#1
		and3	R2, R2,	#0x7F
		slli	R1, #7
		or	R2, R1
		stb	R2, @(0xE, R9)
		ldub	R1, @(0xA, R9)
		and3	R2, R8,	#1
		and3	R3, R1,	#0xDF
		slli	R2, #5
		or	R3, R2
		stb	R3, @(0xA, R9)
		ldub	R1, @(0x13, R9)
		and3	R2, R1,	#0xFE
		and3	R1, R8,	#1
		or	R2, R1 || nop
		and3	R1, R8,	#1
		and3	R3, R2,	#0xFD
		slli	R1, #1
		or	R3, R1
		and3	R1, R8,	#1
		and3	R4, R3,	#0xFB
		slli	R1, #2
		or	R4, R1
		and3	R1, R8,	#1
		and3	R2, R4,	#0xF7
		slli	R1, #3
		or	R2, R1
		stb	R2, @(0x13, R9)

loc_4CCC:				; CODE XREF: sub_4A44+2Cj
					; sub_4A44+198j
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		jmp	lr ||\
; End of function sub_4A44

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_4CD8:				; CODE XREF: sub_4A10+28p sub_4A44+28p ...
		push	lr
		bl.l	sub_4CF0
		bl.l	sub_5478
		bl.l	sub_50B4
		bl.l	sub_583C
		pop	lr
		jmp	lr
; End of function sub_4CD8


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_4CF0:				; CODE XREF: sub_4CD8+4p
		addi	sp, #-8
		push	R8
		push	R9
		push	R10
		push	lr
		ldi8	R0, #0xA
		ld24	R8, #unk_801000
		sth	R0, @(0x14, sp)
		ldub	R1, @(0xA, R8)
		ldi8	R0, #0
		slli	R1, #0x19
		ld24	R9, #0xFFFE
		ld24	R10, #unk_800000
		bltz	R1, loc_4D24
		lduh	R0, @(0x87E, R8)
		sth	R0, @(0x10, sp)
		ldi8	R0, #1
		bra.s	loc_4DBC
; ---------------------------------------------------------------------------

loc_4D24:				; CODE XREF: sub_4CF0+24j
		ldub	R1, @(0xA, R8)
		slli	R1, #0x1A || nop
		bgez	R1, loc_4D5C
		ldi8	R1, #1 || nop
		ldub	R2, @(0x3D7, R8)
		bne	R2, R1,	loc_4DBC
		ldub	R1, @(0xF, R8)
		slli	R1, #0x19 || nop
		bgez	R1, loc_4DBC
		lduh	R0, @(0xAB0, R8)
		add3	R4, sp,	#0x10
		sth	R0, @(0x10, sp)
		ldi8	R5, #1
		bl.s	sub_4E38
		ldi8	R0, #1
		bra.s	loc_4DBC
; ---------------------------------------------------------------------------

loc_4D5C:				; CODE XREF: sub_4CF0+3Cj
		lduh	R4, @(0xAB8, R8)
		bl.l	sub_3714
		sth	R0, @(0x10, sp)
		ldub	R0, @(0xE, R8)
		slli	R0, #0x1B || nop
		bltz	R0, loc_4D9C
		lduh	R0, @(0xAB0, R8)
		sth	R0, @(0x10, sp)
		ld24	R0, #unk_8024F3
		ldub	R0, @R0
		slli	R0, #0x1E
		bgez	R0, loc_4D94
		ld24	R0, #unk_80212E
		lduh	R0, @R0	|| nop
		sth	R0, @(0x10, sp)

loc_4D94:				; CODE XREF: sub_4CF0+94j
		add3	R4, sp,	#0x10
		ldi8	R5, #4
		bl.s	sub_4E38

loc_4D9C:				; CODE XREF: sub_4CF0+80j
		ldub	R0, @(0x13, R8)
		slli	R0, #0x1F || nop
		bgez	R0, loc_4DB0
		ldi8	R0, #0 || nop
		sth	R0, @(0x10, sp)

loc_4DB0:				; CODE XREF: sub_4CF0+B4j
		add3	R4, sp,	#0x14
		add3	R5, sp,	#0x10
		bl.s	sub_4F24 || nop

loc_4DBC:				; CODE XREF: sub_4CF0+32j sub_4CF0+48j ...
		beqz	R0, loc_4E2C
		add3	R0, R10, #0x2FE
		sth	R9, @(0x2FC, R10)
		lduh	R1, @R0
		and	R1, R9
		sth	R1, @R0	|| nop
		ldub	R0, @(0xA, R8)
		slli	R0, #0x1A || nop
		bgez	R0, loc_4DE4
		ldi8	R0, #3 || nop
		stb	R0, @(0xA7E, R8)

loc_4DE4:				; CODE XREF: sub_4CF0+E8j
		lduh	R4, @(0x14, sp)
		addi	R4, #-1	|| nop
		bl.l	sub_36D4
		sth	R0, @(0x240, R10)
		lduh	R4, @(0x10, sp)
		addi	R4, #-1	|| nop
		bl.l	sub_36D4
		add3	R1, R10, #0x224
		sth	R0, @(0x242, R10)
		add3	R0, R10, #0x226
		sth	R9, @R1
		lduh	R2, @R0
		and	R2, R9
		sth	R2, @R0
		ldi8	R0, #0
		sth	R0, @R1
		add3	R0, R10, #0x2FE
		lduh	R1, @R0	|| nop
		or3	R1, R1,	#1
		sth	R1, @R0
		ldi8	R0, #0
		sth	R0, @(0x2FC, R10)

loc_4E2C:				; CODE XREF: sub_4CF0:loc_4DBCj
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		addi	sp, #8
		jmp	lr
; End of function sub_4CF0


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_4E38:				; CODE XREF: sub_4CF0+66p sub_4CF0+AAp ...
		ld24	R2, #unk_801000
		ldub	R0, @(0xA84, R2)
		and3	R1, R0,	#0x40
		and3	R0, R0,	#0x80
		beqz	R0, loc_4E68
		beqz	R1, loc_4E68
		ldub	R4, @(0xF, R2)
		or3	R4, R4,	#0x20
		mv	R4, R4 || nop
		or3	R4, R4,	#0x10
		stb	R4, @(0xF, R2)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_4E68:				; CODE XREF: sub_4E38+10j sub_4E38+14j
		bnez	R0, loc_4E84
		bnez	R1, loc_4E84
		ldub	R5, @(0xF, R2)
		and3	R5, R5,	#0xCF
		stb	R5, @(0xF, R2)
		lduh	R0, @(0xAD0, R2)
		sth	R0, @R4
		jmp	lr
; ---------------------------------------------------------------------------

loc_4E84:				; CODE XREF: sub_4E38:loc_4E68j
					; sub_4E38+34j
		ldub	R0, @(0x3D7, R2)
		bne	R0, R5,	loc_4EE0
		add3	R5, R2,	#0xC
		ldub	R0, @(3, R5)
		slli	R0, #0x19 || nop
		bgez	R0, loc_4EE0
		ldub	R0, @(3, R5)
		slli	R0, #0x1A || nop
		bgez	R0, loc_4EC4
		ldub	R5, @(0xF, R2)
		or3	R5, R5,	#0x10
		mv	R5, R5 || nop
		and3	R5, R5,	#0xDF
		stb	R5, @(0xF, R2)
		lduh	R0, @(0xAD0, R2)
		sth	R0, @R4
		jmp	lr
; ---------------------------------------------------------------------------

loc_4EC4:				; CODE XREF: sub_4E38+6Cj
		ldub	R0, @(3, R5)
		and3	R0, R0,	#0xEF
		stb	R0, @(3, R5)
		ldub	R0, @(0xF, R2)
		or3	R0, R0,	#0x20
		stb	R0, @(0xF, R2)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_4EE0:				; CODE XREF: sub_4E38+50j sub_4E38+60j
		add3	R5, R2,	#0xC
		ldub	R0, @(3, R5)
		slli	R0, #0x1A || nop
		bgez	R0, loc_4F04
		ldub	R4, @(0xF, R2)
		and3	R4, R4,	#0xEF
		or3	R4, R4,	#0x20
		stb	R4, @(0xF, R2)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_4F04:				; CODE XREF: sub_4E38+B4j
		ldub	R0, @(3, R5)
		or3	R0, R0,	#0x10
		stb	R0, @(3, R5)
		ldub	R0, @(0xF, R2)
		and3	R0, R0,	#0xDF
		stb	R0, @(0xF, R2)
		lduh	R0, @(0xAD0, R2)
		sth	R0, @R4
		jmp	lr
; End of function sub_4E38


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_4F24:				; CODE XREF: sub_4CF0+C8p
		push	R8
		push	R9
		push	R10
		push	R11
		push	R12
		push	lr
		ldi8	R8, #0
		mv	R9, R4
		ld24	R0, #unk_8002FE
		mv	R10, R5
		lduh	R0, @R0
		and3	R0, R0,	#1
		cmpui	R0, #1
		subx	R1, R1
		addi	R1, #1
		beqz	R1, loc_4FDC
		ld24	R0, #unk_80070B
		ldub	R0, @R0
		slli	R0, #0x18
		bgez	R0, loc_4FDC
		ld24	R2, #unk_801AC0
		ldub	R2, @R2	|| nop
		beqz	R2, loc_4FB4
		ldi8	R0, #9 || nop
		bne	R2, R0,	loc_4F84
		ld24	R0, #unk_80100E
		ldub	R0, @R0
		slli	R0, #0x1F
		bltz	R0, loc_4F84
		ld24	R1, #unk_8013D7
		ldi8	R0, #4
		ldub	R1, @R1
		beq	R1, R0,	loc_4FA4

loc_4F84:				; CODE XREF: sub_4F24+44j sub_4F24+50j
		ldi8	R0, #9 || nop
		beq	R2, R0,	loc_4FB4
		ld24	R0, #unk_80100E
		ldub	R0, @R0
		slli	R0, #0x1F
		bgez	R0, loc_4FB4
		ld24	R1, #unk_8013D7
		ldi8	R0, #1
		ldub	R1, @R1
		bne	R1, R0,	loc_4FB4

loc_4FA4:				; CODE XREF: sub_4F24+5Cj
		ldi8	R5, #1
		mv	R4, R10
		bl.s	sub_4E38 || nop
		ldi8	R0, #0xA
		ldi8	R8, #1
		sth	R0, @R9
		bra.s	loc_50A4
; ---------------------------------------------------------------------------

loc_4FB4:				; CODE XREF: sub_4F24+3Cj sub_4F24+64j ...
		ld24	R1, #unk_80100E
		ldub	R1, @R1	|| nop
		and3	R1, R1,	#0xEF
		ld24	R0, #unk_80100E
		stb	R1, @R0	|| nop
		ld24	R1, #unk_801013
		ldub	R1, @R1	|| nop
		and3	R1, R1,	#0xFE
		ld24	R0, #unk_801013
		stb	R1, @R0
		bra.s	loc_50A4
; ---------------------------------------------------------------------------

loc_4FDC:				; CODE XREF: sub_4F24+24j sub_4F24+30j
		ldi8	R11, #1	|| nop
		bnez	R1, loc_5068
		ld24	R0, #unk_80070B
		ldub	R0, @R0
		slli	R0, #0x18
		bltz	R0, loc_5068
		ldi8	R0, #3 || nop
		ld24	R1, #unk_801A7E
		ld24	R12, #unk_80187C
		stb	R0, @R1
		ldub	R4, @R12
		bl.l	sub_37B4
		ld24	R2, #unk_8013D7
		stb	R0, @R12
		ldub	R2, @R2
		addi	R2, #-1
		mv	R0, R2
		ld24	R1, #0x2808
		add	R0, R1
		ldub	R3, @R0
		ld24	R0, #unk_80100E
		ldub	R0, @R0
		slli	R0, #0x1F
		mv	R3, R3 || nop
		bltz	R0, loc_5034
		ld24	R0, #0x280C
		add	R2, R0
		ldub	R3, @R2
		mv	R3, R3 || nop

loc_5034:				; CODE XREF: sub_4F24+100j
		ld24	R1, #unk_801ABF
		ldub	R1, @R1
		cmp	R3, R1
		bnc.s	loc_5048
		ldi8	R11, #0
		ld24	R1, #unk_801AC0
		stb	R11, @R1
		bra.s	loc_5068
; ---------------------------------------------------------------------------

loc_5048:				; CODE XREF: sub_4F24+118j
		cmp	R1, R3
		bnc.s	loc_5058
		ldi8	R0, #0 || nop
		ld24	R1, #unk_801AC0
		stb	R0, @R1
		bra.s	loc_5060
; ---------------------------------------------------------------------------

loc_5058:				; CODE XREF: sub_4F24+126j
		ld24	R0, #unk_801AC0
		stb	R3, @R0	|| nop

loc_5060:				; CODE XREF: sub_4F24+132j
		ld24	R0, #unk_801ABE
		stb	R3, @R0	|| nop

loc_5068:				; CODE XREF: sub_4F24+BCj sub_4F24+C8j ...
		beqz	R11, loc_50A4
		ld24	R2, #unk_801ABE
		ld24	R4, #unk_801ABF
		ldub	R1, @R2
		stb	R1, @R4
		addi	R1, #-1
		stb	R1, @R2
		ldub	R4, @R4
		lduh	R5, @R10
		bl.l	sub_5BC8
		sth	R0, @R9	|| nop
		ld24	R0, #unk_80070B
		ldub	R0, @R0
		slli	R0, #0x18
		bgez	R0, loc_50A0
		ld24	R0, #unk_801009
		ldub	R0, @R0
		slli	R0, #0x1F
		bgez	R0, loc_50A4

loc_50A0:				; CODE XREF: sub_4F24+16Cj
		ldi8	R8, #1 || nop

loc_50A4:				; CODE XREF: sub_4F24+8Ej sub_4F24+B6j ...
		mv	R0, R8
		pop	lr
		pop	R12
		pop	R11
		pop	R10
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_4F24


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_50B4:				; CODE XREF: sub_4CD8+Cp
		addi	sp, #-8
		push	R8
		push	R9
		push	R10
		push	lr
		ldi8	R0, #0xA
		ld24	R8, #unk_801000
		sth	R0, @(0x14, sp)
		ldub	R1, @(0xA, R8)
		ldi8	R0, #0
		slli	R1, #0x19
		ld24	R9, #0xFFFD
		ld24	R10, #unk_800000
		bltz	R1, loc_50E8
		lduh	R0, @(0x87E, R8)
		sth	R0, @(0x10, sp)
		ldi8	R0, #1
		bra.s	loc_5180
; ---------------------------------------------------------------------------

loc_50E8:				; CODE XREF: sub_50B4+24j
		ldub	R1, @(0xA, R8)
		slli	R1, #0x1A || nop
		bgez	R1, loc_5120
		ldi8	R1, #2 || nop
		ldub	R2, @(0x3D7, R8)
		bne	R2, R1,	loc_5180
		ldub	R1, @(0xF, R8)
		slli	R1, #0x19 || nop
		bgez	R1, loc_5180
		lduh	R0, @(0xAB2, R8)
		add3	R4, sp,	#0x10
		sth	R0, @(0x10, sp)
		ldi8	R5, #2
		bl.s	sub_51FC
		ldi8	R0, #1
		bra.s	loc_5180
; ---------------------------------------------------------------------------

loc_5120:				; CODE XREF: sub_50B4+3Cj
		lduh	R4, @(0xAB8, R8)
		bl.l	sub_3714
		sth	R0, @(0x10, sp)
		ldub	R0, @(0xE, R8)
		slli	R0, #0x1A || nop
		bltz	R0, loc_5160
		lduh	R0, @(0xAB2, R8)
		sth	R0, @(0x10, sp)
		ld24	R0, #unk_8024F3
		ldub	R0, @R0
		slli	R0, #0x1E
		bgez	R0, loc_5158
		ld24	R0, #unk_80212E
		lduh	R0, @R0	|| nop
		sth	R0, @(0x10, sp)

loc_5158:				; CODE XREF: sub_50B4+94j
		add3	R4, sp,	#0x10
		ldi8	R5, #3
		bl.s	sub_51FC

loc_5160:				; CODE XREF: sub_50B4+80j
		ldub	R0, @(0x13, R8)
		slli	R0, #0x1E || nop
		bgez	R0, loc_5174
		ldi8	R0, #0 || nop
		sth	R0, @(0x10, sp)

loc_5174:				; CODE XREF: sub_50B4+B4j
		add3	R4, sp,	#0x14
		add3	R5, sp,	#0x10
		bl.s	sub_52E8 || nop

loc_5180:				; CODE XREF: sub_50B4+32j sub_50B4+48j ...
		beqz	R0, loc_51F0
		add3	R0, R10, #0x2FE
		sth	R9, @(0x2FC, R10)
		lduh	R1, @R0
		and	R1, R9
		sth	R1, @R0	|| nop
		ldub	R0, @(0xA, R8)
		slli	R0, #0x1A || nop
		bgez	R0, loc_51A8
		ldi8	R0, #4 || nop
		stb	R0, @(0xA7E, R8)

loc_51A8:				; CODE XREF: sub_50B4+E8j
		lduh	R4, @(0x14, sp)
		addi	R4, #-1	|| nop
		bl.l	sub_36D4
		sth	R0, @(0x250, R10)
		lduh	R4, @(0x10, sp)
		addi	R4, #-1	|| nop
		bl.l	sub_36D4
		add3	R1, R10, #0x224
		sth	R0, @(0x252, R10)
		add3	R0, R10, #0x226
		sth	R9, @R1
		lduh	R2, @R0
		and	R2, R9
		sth	R2, @R0
		ldi8	R0, #0
		sth	R0, @R1
		add3	R0, R10, #0x2FE
		lduh	R1, @R0	|| nop
		or3	R1, R1,	#2
		sth	R1, @R0
		ldi8	R0, #0
		sth	R0, @(0x2FC, R10)

loc_51F0:				; CODE XREF: sub_50B4:loc_5180j
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		addi	sp, #8
		jmp	lr
; End of function sub_50B4


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_51FC:				; CODE XREF: sub_50B4+66p sub_50B4+AAp ...
		ld24	R2, #unk_801000
		ldub	R1, @(0xA84, R2)
		and3	R0, R1,	#4
		and3	R1, R1,	#8
		beqz	R0, loc_522C
		beqz	R1, loc_522C
		ldub	R4, @(0xF, R2)
		or3	R4, R4,	#4
		mv	R4, R4 || nop
		or3	R4, R4,	#8
		stb	R4, @(0xF, R2)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_522C:				; CODE XREF: sub_51FC+10j sub_51FC+14j
		bnez	R0, loc_5248
		bnez	R1, loc_5248
		ldub	R5, @(0xF, R2)
		and3	R5, R5,	#0xF3
		stb	R5, @(0xF, R2)
		lduh	R0, @(0xAD0, R2)
		sth	R0, @R4
		jmp	lr
; ---------------------------------------------------------------------------

loc_5248:				; CODE XREF: sub_51FC:loc_522Cj
					; sub_51FC+34j
		ldub	R0, @(0x3D7, R2)
		bne	R0, R5,	loc_52A4
		add3	R5, R2,	#0xC
		ldub	R0, @(3, R5)
		slli	R0, #0x19 || nop
		bgez	R0, loc_52A4
		ldub	R0, @(3, R5)
		slli	R0, #0x1C || nop
		bgez	R0, loc_5288
		ldub	R5, @(0xF, R2)
		or3	R5, R5,	#4
		mv	R5, R5 || nop
		and3	R5, R5,	#0xF7
		stb	R5, @(0xF, R2)
		lduh	R0, @(0xAD0, R2)
		sth	R0, @R4
		jmp	lr
; ---------------------------------------------------------------------------

loc_5288:				; CODE XREF: sub_51FC+6Cj
		ldub	R0, @(3, R5)
		and3	R0, R0,	#0xFB
		stb	R0, @(3, R5)
		ldub	R0, @(0xF, R2)
		or3	R0, R0,	#8
		stb	R0, @(0xF, R2)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_52A4:				; CODE XREF: sub_51FC+50j sub_51FC+60j
		add3	R5, R2,	#0xC
		ldub	R0, @(3, R5)
		slli	R0, #0x1C || nop
		bgez	R0, loc_52C8
		ldub	R4, @(0xF, R2)
		and3	R4, R4,	#0xFB
		or3	R4, R4,	#8
		stb	R4, @(0xF, R2)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_52C8:				; CODE XREF: sub_51FC+B4j
		ldub	R0, @(3, R5)
		or3	R0, R0,	#4
		stb	R0, @(3, R5)
		ldub	R0, @(0xF, R2)
		and3	R0, R0,	#0xF7
		stb	R0, @(0xF, R2)
		lduh	R0, @(0xAD0, R2)
		sth	R0, @R4
		jmp	lr
; End of function sub_51FC


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_52E8:				; CODE XREF: sub_50B4+C8p
		push	R8
		push	R9
		push	R10
		push	R11
		push	R12
		push	lr
		ldi8	R8, #0
		mv	R9, R4
		ld24	R0, #unk_8002FE
		mv	R10, R5
		lduh	R0, @R0
		and3	R0, R0,	#2
		cmpui	R0, #1
		subx	R1, R1
		addi	R1, #1
		beqz	R1, loc_53A0
		ld24	R0, #unk_80070B
		ldub	R0, @R0
		slli	R0, #0x19
		bgez	R0, loc_53A0
		ld24	R2, #unk_801AC4
		ldub	R2, @R2	|| nop
		beqz	R2, loc_5378
		ldi8	R0, #9 || nop
		bne	R2, R0,	loc_5348
		ld24	R0, #unk_80100E
		ldub	R0, @R0
		slli	R0, #0x1F
		bltz	R0, loc_5348
		ld24	R1, #unk_8013D7
		ldi8	R0, #3
		ldub	R1, @R1
		beq	R1, R0,	loc_5368

loc_5348:				; CODE XREF: sub_52E8+44j sub_52E8+50j
		ldi8	R0, #9 || nop
		beq	R2, R0,	loc_5378
		ld24	R0, #unk_80100E
		ldub	R0, @R0
		slli	R0, #0x1F
		bgez	R0, loc_5378
		ld24	R1, #unk_8013D7
		ldi8	R0, #2
		ldub	R1, @R1
		bne	R1, R0,	loc_5378

loc_5368:				; CODE XREF: sub_52E8+5Cj
		ldi8	R5, #2
		mv	R4, R10
		bl.s	sub_51FC || nop
		ldi8	R0, #0xA
		ldi8	R8, #1
		sth	R0, @R9
		bra.s	loc_5468
; ---------------------------------------------------------------------------

loc_5378:				; CODE XREF: sub_52E8+3Cj sub_52E8+64j ...
		ld24	R1, #unk_80100E
		ldub	R1, @R1	|| nop
		and3	R1, R1,	#0xDF
		ld24	R0, #unk_80100E
		stb	R1, @R0	|| nop
		ld24	R1, #unk_801013
		ldub	R1, @R1	|| nop
		and3	R1, R1,	#0xFD
		ld24	R0, #unk_801013
		stb	R1, @R0
		bra.s	loc_5468
; ---------------------------------------------------------------------------

loc_53A0:				; CODE XREF: sub_52E8+24j sub_52E8+30j
		ldi8	R11, #1	|| nop
		bnez	R1, loc_542C
		ld24	R0, #unk_80070B
		ldub	R0, @R0
		slli	R0, #0x19
		bltz	R0, loc_542C
		ldi8	R0, #4 || nop
		ld24	R1, #unk_801A7E
		ld24	R12, #unk_80187C
		stb	R0, @R1
		ldub	R4, @R12
		bl.l	sub_37B4
		ld24	R2, #unk_8013D7
		stb	R0, @R12
		ldub	R2, @R2
		addi	R2, #-1
		mv	R0, R2
		ld24	R1, #0x2810
		add	R0, R1
		ldub	R3, @R0
		ld24	R0, #unk_80100E
		ldub	R0, @R0
		slli	R0, #0x1F
		mv	R3, R3 || nop
		bltz	R0, loc_53F8
		ld24	R0, #0x2814
		add	R2, R0
		ldub	R3, @R2
		mv	R3, R3 || nop

loc_53F8:				; CODE XREF: sub_52E8+100j
		ld24	R1, #unk_801AC3
		ldub	R1, @R1
		cmp	R3, R1
		bnc.s	loc_540C
		ldi8	R11, #0
		ld24	R1, #unk_801AC4
		stb	R11, @R1
		bra.s	loc_542C
; ---------------------------------------------------------------------------

loc_540C:				; CODE XREF: sub_52E8+118j
		cmp	R1, R3
		bnc.s	loc_541C
		ldi8	R0, #0 || nop
		ld24	R1, #unk_801AC4
		stb	R0, @R1
		bra.s	loc_5424
; ---------------------------------------------------------------------------

loc_541C:				; CODE XREF: sub_52E8+126j
		ld24	R0, #unk_801AC4
		stb	R3, @R0	|| nop

loc_5424:				; CODE XREF: sub_52E8+132j
		ld24	R0, #unk_801AC2
		stb	R3, @R0	|| nop

loc_542C:				; CODE XREF: sub_52E8+BCj sub_52E8+C8j ...
		beqz	R11, loc_5468
		ld24	R2, #unk_801AC2
		ld24	R4, #unk_801AC3
		ldub	R1, @R2
		stb	R1, @R4
		addi	R1, #-1
		stb	R1, @R2
		ldub	R4, @R4
		lduh	R5, @R10
		bl.l	sub_5BC8
		sth	R0, @R9	|| nop
		ld24	R0, #unk_80070B
		ldub	R0, @R0
		slli	R0, #0x19
		bgez	R0, loc_5464
		ld24	R0, #unk_801009
		ldub	R0, @R0
		slli	R0, #0x1F
		bgez	R0, loc_5468

loc_5464:				; CODE XREF: sub_52E8+16Cj
		ldi8	R8, #1 || nop

loc_5468:				; CODE XREF: sub_52E8+8Ej sub_52E8+B6j ...
		mv	R0, R8
		pop	lr
		pop	R12
		pop	R11
		pop	R10
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_52E8


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_5478:				; CODE XREF: sub_4CD8+8p
		addi	sp, #-8
		push	R8
		push	R9
		push	R10
		push	lr
		ldi8	R0, #0xA
		ld24	R8, #unk_801000
		sth	R0, @(0x14, sp)
		ldub	R1, @(0xA, R8)
		ldi8	R0, #0
		slli	R1, #0x19
		ld24	R9, #0xFFFB
		ld24	R10, #unk_800000
		bltz	R1, loc_54AC
		lduh	R0, @(0x87E, R8)
		sth	R0, @(0x10, sp)
		ldi8	R0, #1
		bra.s	loc_5544
; ---------------------------------------------------------------------------

loc_54AC:				; CODE XREF: sub_5478+24j
		ldub	R1, @(0xA, R8)
		slli	R1, #0x1A || nop
		bgez	R1, loc_54E4
		ldi8	R1, #3 || nop
		ldub	R2, @(0x3D7, R8)
		bne	R2, R1,	loc_5544
		ldub	R1, @(0xF, R8)
		slli	R1, #0x19 || nop
		bgez	R1, loc_5544
		lduh	R0, @(0xAB4, R8)
		add3	R4, sp,	#0x10
		sth	R0, @(0x10, sp)
		ldi8	R5, #3
		bl.s	sub_55C0
		ldi8	R0, #1
		bra.s	loc_5544
; ---------------------------------------------------------------------------

loc_54E4:				; CODE XREF: sub_5478+3Cj
		lduh	R4, @(0xAB8, R8)
		bl.l	sub_3714
		sth	R0, @(0x10, sp)
		ldub	R0, @(0xE, R8)
		slli	R0, #0x19 || nop
		bltz	R0, loc_5524
		lduh	R0, @(0xAB4, R8)
		sth	R0, @(0x10, sp)
		ld24	R0, #unk_8024F3
		ldub	R0, @R0
		slli	R0, #0x1E
		bgez	R0, loc_551C
		ld24	R0, #unk_80212E
		lduh	R0, @R0	|| nop
		sth	R0, @(0x10, sp)

loc_551C:				; CODE XREF: sub_5478+94j
		add3	R4, sp,	#0x10
		ldi8	R5, #1
		bl.s	sub_55C0

loc_5524:				; CODE XREF: sub_5478+80j
		ldub	R0, @(0x13, R8)
		slli	R0, #0x1D || nop
		bgez	R0, loc_5538
		ldi8	R0, #0 || nop
		sth	R0, @(0x10, sp)

loc_5538:				; CODE XREF: sub_5478+B4j
		add3	R4, sp,	#0x14
		add3	R5, sp,	#0x10
		bl.s	sub_56AC || nop

loc_5544:				; CODE XREF: sub_5478+32j sub_5478+48j ...
		beqz	R0, loc_55B4
		add3	R0, R10, #0x2FE
		sth	R9, @(0x2FC, R10)
		lduh	R1, @R0
		and	R1, R9
		sth	R1, @R0	|| nop
		ldub	R0, @(0xA, R8)
		slli	R0, #0x1A || nop
		bgez	R0, loc_556C
		ldi8	R0, #2 || nop
		stb	R0, @(0xA7E, R8)

loc_556C:				; CODE XREF: sub_5478+E8j
		lduh	R4, @(0x14, sp)
		addi	R4, #-1	|| nop
		bl.l	sub_36D4
		sth	R0, @(0x260, R10)
		lduh	R4, @(0x10, sp)
		addi	R4, #-1	|| nop
		bl.l	sub_36D4
		add3	R1, R10, #0x224
		sth	R0, @(0x262, R10)
		add3	R0, R10, #0x226
		sth	R9, @R1
		lduh	R2, @R0
		and	R2, R9
		sth	R2, @R0
		ldi8	R0, #0
		sth	R0, @R1
		add3	R0, R10, #0x2FE
		lduh	R1, @R0	|| nop
		or3	R1, R1,	#4
		sth	R1, @R0
		ldi8	R0, #0
		sth	R0, @(0x2FC, R10)

loc_55B4:				; CODE XREF: sub_5478:loc_5544j
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		addi	sp, #8
		jmp	lr
; End of function sub_5478


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_55C0:				; CODE XREF: sub_5478+66p sub_5478+AAp ...
		ld24	R2, #unk_801000
		ldub	R1, @(0xA84, R2)
		and3	R0, R1,	#0x10
		and3	R1, R1,	#0x20
		beqz	R0, loc_55F0
		beqz	R1, loc_55F0
		ldub	R4, @(0xF, R2)
		or3	R4, R4,	#2
		mv	R4, R4 || nop
		or3	R4, R4,	#1
		stb	R4, @(0xF, R2)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_55F0:				; CODE XREF: sub_55C0+10j sub_55C0+14j
		bnez	R0, loc_560C
		bnez	R1, loc_560C
		ldub	R5, @(0xF, R2)
		and3	R5, R5,	#0xFC
		stb	R5, @(0xF, R2)
		lduh	R0, @(0xAD0, R2)
		sth	R0, @R4
		jmp	lr
; ---------------------------------------------------------------------------

loc_560C:				; CODE XREF: sub_55C0:loc_55F0j
					; sub_55C0+34j
		ldub	R0, @(0x3D7, R2)
		bne	R0, R5,	loc_5668
		add3	R5, R2,	#0xC
		ldub	R0, @(3, R5)
		slli	R0, #0x19 || nop
		bgez	R0, loc_5668
		ldub	R0, @(3, R5)
		slli	R0, #0x1E || nop
		bgez	R0, loc_564C
		ldub	R5, @(0xF, R2)
		or3	R5, R5,	#1
		mv	R5, R5 || nop
		and3	R5, R5,	#0xFD
		stb	R5, @(0xF, R2)
		lduh	R0, @(0xAD0, R2)
		sth	R0, @R4
		jmp	lr
; ---------------------------------------------------------------------------

loc_564C:				; CODE XREF: sub_55C0+6Cj
		ldub	R0, @(3, R5)
		and3	R0, R0,	#0xFE
		stb	R0, @(3, R5)
		ldub	R0, @(0xF, R2)
		or3	R0, R0,	#2
		stb	R0, @(0xF, R2)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_5668:				; CODE XREF: sub_55C0+50j sub_55C0+60j
		add3	R5, R2,	#0xC
		ldub	R0, @(3, R5)
		slli	R0, #0x1E || nop
		bgez	R0, loc_568C
		ldub	R4, @(0xF, R2)
		and3	R4, R4,	#0xFE
		or3	R4, R4,	#2
		stb	R4, @(0xF, R2)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_568C:				; CODE XREF: sub_55C0+B4j
		ldub	R0, @(3, R5)
		or3	R0, R0,	#1
		stb	R0, @(3, R5)
		ldub	R0, @(0xF, R2)
		and3	R0, R0,	#0xFD
		stb	R0, @(0xF, R2)
		lduh	R0, @(0xAD0, R2)
		sth	R0, @R4
		jmp	lr
; End of function sub_55C0


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_56AC:				; CODE XREF: sub_5478+C8p
		push	R8
		push	R9
		push	R10
		push	R11
		push	R12
		push	lr
		ldi8	R8, #0
		mv	R9, R4
		ld24	R0, #unk_8002FE
		mv	R10, R5
		lduh	R0, @R0
		and3	R0, R0,	#4
		cmpui	R0, #1
		subx	R1, R1
		addi	R1, #1
		beqz	R1, loc_5764
		ld24	R0, #unk_80070B
		ldub	R0, @R0
		slli	R0, #0x1A
		bgez	R0, loc_5764
		ld24	R2, #unk_801AC8
		ldub	R2, @R2	|| nop
		beqz	R2, loc_573C
		ldi8	R0, #9 || nop
		bne	R2, R0,	loc_570C
		ld24	R0, #unk_80100E
		ldub	R0, @R0
		slli	R0, #0x1F
		bltz	R0, loc_570C
		ld24	R1, #unk_8013D7
		ldi8	R0, #1
		ldub	R1, @R1
		beq	R1, R0,	loc_572C

loc_570C:				; CODE XREF: sub_56AC+44j sub_56AC+50j
		ldi8	R0, #9 || nop
		beq	R2, R0,	loc_573C
		ld24	R0, #unk_80100E
		ldub	R0, @R0
		slli	R0, #0x1F
		bgez	R0, loc_573C
		ld24	R1, #unk_8013D7
		ldi8	R0, #3
		ldub	R1, @R1
		bne	R1, R0,	loc_573C

loc_572C:				; CODE XREF: sub_56AC+5Cj
		ldi8	R5, #3
		mv	R4, R10
		bl.s	sub_55C0 || nop
		ldi8	R0, #0xA
		ldi8	R8, #1
		sth	R0, @R9
		bra.s	loc_582C
; ---------------------------------------------------------------------------

loc_573C:				; CODE XREF: sub_56AC+3Cj sub_56AC+64j ...
		ld24	R1, #unk_80100E
		ldub	R1, @R1	|| nop
		and3	R1, R1,	#0xBF
		ld24	R0, #unk_80100E
		stb	R1, @R0	|| nop
		ld24	R1, #unk_801013
		ldub	R1, @R1	|| nop
		and3	R1, R1,	#0xFB
		ld24	R0, #unk_801013
		stb	R1, @R0
		bra.s	loc_582C
; ---------------------------------------------------------------------------

loc_5764:				; CODE XREF: sub_56AC+24j sub_56AC+30j
		ldi8	R11, #1	|| nop
		bnez	R1, loc_57F0
		ld24	R0, #unk_80070B
		ldub	R0, @R0
		slli	R0, #0x1A
		bltz	R0, loc_57F0
		ldi8	R0, #2 || nop
		ld24	R1, #unk_801A7E
		ld24	R12, #unk_80187C
		stb	R0, @R1
		ldub	R4, @R12
		bl.l	sub_37B4
		ld24	R2, #unk_8013D7
		stb	R0, @R12
		ldub	R2, @R2
		addi	R2, #-1
		mv	R0, R2
		ld24	R1, #0x2818
		add	R0, R1
		ldub	R3, @R0
		ld24	R0, #unk_80100E
		ldub	R0, @R0
		slli	R0, #0x1F
		mv	R3, R3 || nop
		bltz	R0, loc_57BC
		ld24	R0, #0x281C
		add	R2, R0
		ldub	R3, @R2
		mv	R3, R3 || nop

loc_57BC:				; CODE XREF: sub_56AC+100j
		ld24	R1, #unk_801AC7
		ldub	R1, @R1
		cmp	R3, R1
		bnc.s	loc_57D0
		ldi8	R11, #0
		ld24	R1, #unk_801AC8
		stb	R11, @R1
		bra.s	loc_57F0
; ---------------------------------------------------------------------------

loc_57D0:				; CODE XREF: sub_56AC+118j
		cmp	R1, R3
		bnc.s	loc_57E0
		ldi8	R0, #0 || nop
		ld24	R1, #unk_801AC8
		stb	R0, @R1
		bra.s	loc_57E8
; ---------------------------------------------------------------------------

loc_57E0:				; CODE XREF: sub_56AC+126j
		ld24	R0, #unk_801AC8
		stb	R3, @R0	|| nop

loc_57E8:				; CODE XREF: sub_56AC+132j
		ld24	R0, #unk_801AC6
		stb	R3, @R0	|| nop

loc_57F0:				; CODE XREF: sub_56AC+BCj sub_56AC+C8j ...
		beqz	R11, loc_582C
		ld24	R2, #unk_801AC6
		ld24	R4, #unk_801AC7
		ldub	R1, @R2
		stb	R1, @R4
		addi	R1, #-1
		stb	R1, @R2
		ldub	R4, @R4
		lduh	R5, @R10
		bl.l	sub_5BC8
		sth	R0, @R9	|| nop
		ld24	R0, #unk_80070B
		ldub	R0, @R0
		slli	R0, #0x1A
		bgez	R0, loc_5828
		ld24	R0, #unk_801009
		ldub	R0, @R0
		slli	R0, #0x1F
		bgez	R0, loc_582C

loc_5828:				; CODE XREF: sub_56AC+16Cj
		ldi8	R8, #1 || nop

loc_582C:				; CODE XREF: sub_56AC+8Ej sub_56AC+B6j ...
		mv	R0, R8
		pop	lr
		pop	R12
		pop	R11
		pop	R10
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_56AC


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_583C:				; CODE XREF: sub_4CD8+10p
		addi	sp, #-8
		push	R8
		push	R9
		push	R10
		push	lr
		ldi8	R0, #0xA
		ld24	R8, #unk_801000
		sth	R0, @(0x14, sp)
		ldub	R1, @(0xA, R8)
		ldi8	R0, #0
		slli	R1, #0x19
		ld24	R9, #0xFFF7
		ld24	R10, #unk_800000
		bltz	R1, loc_5870
		lduh	R0, @(0x87E, R8)
		sth	R0, @(0x10, sp)
		ldi8	R0, #1
		bra.s	loc_5908
; ---------------------------------------------------------------------------

loc_5870:				; CODE XREF: sub_583C+24j
		ldub	R1, @(0xA, R8)
		slli	R1, #0x1A || nop
		bgez	R1, loc_58A8
		ldi8	R1, #4 || nop
		ldub	R2, @(0x3D7, R8)
		bne	R2, R1,	loc_5908
		ldub	R1, @(0xF, R8)
		slli	R1, #0x19 || nop
		bgez	R1, loc_5908
		lduh	R0, @(0xAB6, R8)
		add3	R4, sp,	#0x10
		sth	R0, @(0x10, sp)
		ldi8	R5, #4
		bl.s	sub_5984
		ldi8	R0, #1
		bra.s	loc_5908
; ---------------------------------------------------------------------------

loc_58A8:				; CODE XREF: sub_583C+3Cj
		lduh	R4, @(0xAB8, R8)
		bl.l	sub_3714
		sth	R0, @(0x10, sp)
		ldub	R0, @(0xE, R8)
		slli	R0, #0x18 || nop
		bltz	R0, loc_58E8
		lduh	R0, @(0xAB6, R8)
		sth	R0, @(0x10, sp)
		ld24	R0, #unk_8024F3
		ldub	R0, @R0
		slli	R0, #0x1E
		bgez	R0, loc_58E0
		ld24	R0, #unk_80212E
		lduh	R0, @R0	|| nop
		sth	R0, @(0x10, sp)

loc_58E0:				; CODE XREF: sub_583C+94j
		add3	R4, sp,	#0x10
		ldi8	R5, #2
		bl.s	sub_5984

loc_58E8:				; CODE XREF: sub_583C+80j
		ldub	R0, @(0x13, R8)
		slli	R0, #0x1C || nop
		bgez	R0, loc_58FC
		ldi8	R0, #0 || nop
		sth	R0, @(0x10, sp)

loc_58FC:				; CODE XREF: sub_583C+B4j
		add3	R4, sp,	#0x14
		add3	R5, sp,	#0x10
		bl.s	sub_5A38 || nop

loc_5908:				; CODE XREF: sub_583C+32j sub_583C+48j ...
		beqz	R0, loc_5978
		add3	R0, R10, #0x2FE
		sth	R9, @(0x2FC, R10)
		lduh	R1, @R0
		and	R1, R9
		sth	R1, @R0	|| nop
		ldub	R0, @(0xA, R8)
		slli	R0, #0x1A || nop
		bgez	R0, loc_5930
		ldi8	R0, #1 || nop
		stb	R0, @(0xA7E, R8)

loc_5930:				; CODE XREF: sub_583C+E8j
		lduh	R4, @(0x14, sp)
		addi	R4, #-1	|| nop
		bl.l	sub_36D4
		sth	R0, @(0x270, R10)
		lduh	R4, @(0x10, sp)
		addi	R4, #-1	|| nop
		bl.l	sub_36D4
		add3	R1, R10, #0x224
		sth	R0, @(0x272, R10)
		add3	R0, R10, #0x226
		sth	R9, @R1
		lduh	R2, @R0
		and	R2, R9
		sth	R2, @R0
		ldi8	R0, #0
		sth	R0, @R1
		add3	R0, R10, #0x2FE
		lduh	R1, @R0	|| nop
		or3	R1, R1,	#8
		sth	R1, @R0
		ldi8	R0, #0
		sth	R0, @(0x2FC, R10)

loc_5978:				; CODE XREF: sub_583C:loc_5908j
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		addi	sp, #8
		jmp	lr
; End of function sub_583C


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_5984:				; CODE XREF: sub_583C+66p sub_583C+AAp ...
		ld24	R2, #unk_801000
		ldub	R1, @(0xA84, R2)
		and3	R0, R1,	#1
		and3	R1, R1,	#2
		beqz	R0, loc_59B4
		beqz	R1, loc_59B4
		add3	R0, R2,	#8
		ldub	R4, @R0	|| nop
		or3	R4, R4,	#0x40
		mv	R4, R4 || nop
		or3	R4, R4,	#0x80
		stb	R4, @R0
		jmp	lr
; ---------------------------------------------------------------------------

loc_59B4:				; CODE XREF: sub_5984+10j sub_5984+14j
		bnez	R0, loc_59D4
		bnez	R1, loc_59D4
		add3	R0, R2,	#8
		ldub	R5, @R0	|| nop
		and3	R5, R5,	#0x3F
		stb	R5, @R0	|| nop
		lduh	R0, @(0xAD0, R2)
		sth	R0, @R4
		jmp	lr
; ---------------------------------------------------------------------------

loc_59D4:				; CODE XREF: sub_5984:loc_59B4j
					; sub_5984+34j
		ldub	R0, @(0x3D7, R2)
		bne	R0, R5,	loc_59F8
		ldub	R0, @(0xF, R2)
		slli	R0, #0x19 || nop
		bgez	R0, loc_59F8
		ldub	R0, @(8, R2)
		slli	R0, #0x18 || nop
		bgez	R0, loc_5A04
		bra.s	loc_5A18 || nop
; ---------------------------------------------------------------------------

loc_59F8:				; CODE XREF: sub_5984+54j sub_5984+60j
		ldub	R0, @(8, R2)
		slli	R0, #0x18 || nop
		bgez	R0, loc_5A18

loc_5A04:				; CODE XREF: sub_5984+6Cj
		add3	R0, R2,	#8
		ldub	R4, @R0	|| nop
		and3	R4, R4,	#0xBF
		or3	R4, R4,	#0x80
		stb	R4, @R0
		jmp	lr
; ---------------------------------------------------------------------------

loc_5A18:				; CODE XREF: sub_5984+70j sub_5984+7Cj
		add3	R0, R2,	#8
		ldub	R5, @R0	|| nop
		or3	R5, R5,	#0x40
		mv	R5, R5 || nop
		and3	R5, R5,	#0x7F
		stb	R5, @R0	|| nop
		lduh	R0, @(0xAD0, R2)
		sth	R0, @R4
		jmp	lr
; End of function sub_5984


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_5A38:				; CODE XREF: sub_583C+C8p
		push	R8
		push	R9
		push	R10
		push	R11
		push	R12
		push	lr
		ldi8	R8, #0
		mv	R9, R4
		ld24	R0, #unk_8002FE
		mv	R10, R5
		lduh	R0, @R0
		and3	R0, R0,	#8
		cmpui	R0, #1
		subx	R1, R1
		addi	R1, #1
		beqz	R1, loc_5AF0
		ld24	R0, #unk_80070B
		ldub	R0, @R0
		slli	R0, #0x1B
		bgez	R0, loc_5AF0
		ld24	R2, #unk_801ACC
		ldub	R2, @R2	|| nop
		beqz	R2, loc_5AC8
		ldi8	R0, #9 || nop
		bne	R2, R0,	loc_5A98
		ld24	R0, #unk_80100E
		ldub	R0, @R0
		slli	R0, #0x1F
		bltz	R0, loc_5A98
		ld24	R1, #unk_8013D7
		ldi8	R0, #2
		ldub	R1, @R1
		beq	R1, R0,	loc_5AB8

loc_5A98:				; CODE XREF: sub_5A38+44j sub_5A38+50j
		ldi8	R0, #9 || nop
		beq	R2, R0,	loc_5AC8
		ld24	R0, #unk_80100E
		ldub	R0, @R0
		slli	R0, #0x1F
		bgez	R0, loc_5AC8
		ld24	R1, #unk_8013D7
		ldi8	R0, #4
		ldub	R1, @R1
		bne	R1, R0,	loc_5AC8

loc_5AB8:				; CODE XREF: sub_5A38+5Cj
		ldi8	R5, #4
		mv	R4, R10
		bl.s	sub_5984 || nop
		ldi8	R0, #0xA
		ldi8	R8, #1
		sth	R0, @R9
		bra.s	loc_5BB8
; ---------------------------------------------------------------------------

loc_5AC8:				; CODE XREF: sub_5A38+3Cj sub_5A38+64j ...
		ld24	R1, #unk_80100E
		ldub	R1, @R1	|| nop
		and3	R1, R1,	#0x7F
		ld24	R0, #unk_80100E
		stb	R1, @R0	|| nop
		ld24	R1, #unk_801013
		ldub	R1, @R1	|| nop
		and3	R1, R1,	#0xF7
		ld24	R0, #unk_801013
		stb	R1, @R0
		bra.s	loc_5BB8
; ---------------------------------------------------------------------------

loc_5AF0:				; CODE XREF: sub_5A38+24j sub_5A38+30j
		ldi8	R11, #1	|| nop
		bnez	R1, loc_5B7C
		ld24	R0, #unk_80070B
		ldub	R0, @R0
		slli	R0, #0x1B
		bltz	R0, loc_5B7C
		ldi8	R0, #1 || nop
		ld24	R1, #unk_801A7E
		ld24	R12, #unk_80187C
		stb	R0, @R1
		ldub	R4, @R12
		bl.l	sub_37B4
		ld24	R2, #unk_8013D7
		stb	R0, @R12
		ldub	R2, @R2
		addi	R2, #-1
		mv	R0, R2
		ld24	R1, #0x2820
		add	R0, R1
		ldub	R3, @R0
		ld24	R0, #unk_80100E
		ldub	R0, @R0
		slli	R0, #0x1F
		mv	R3, R3 || nop
		bltz	R0, loc_5B48
		ld24	R0, #0x2824
		add	R2, R0
		ldub	R3, @R2
		mv	R3, R3 || nop

loc_5B48:				; CODE XREF: sub_5A38+100j
		ld24	R1, #unk_801ACB
		ldub	R1, @R1
		cmp	R3, R1
		bnc.s	loc_5B5C
		ldi8	R11, #0
		ld24	R1, #unk_801ACC
		stb	R11, @R1
		bra.s	loc_5B7C
; ---------------------------------------------------------------------------

loc_5B5C:				; CODE XREF: sub_5A38+118j
		cmp	R1, R3
		bnc.s	loc_5B6C
		ldi8	R0, #0 || nop
		ld24	R1, #unk_801ACC
		stb	R0, @R1
		bra.s	loc_5B74
; ---------------------------------------------------------------------------

loc_5B6C:				; CODE XREF: sub_5A38+126j
		ld24	R0, #unk_801ACC
		stb	R3, @R0	|| nop

loc_5B74:				; CODE XREF: sub_5A38+132j
		ld24	R0, #unk_801ACA
		stb	R3, @R0	|| nop

loc_5B7C:				; CODE XREF: sub_5A38+BCj sub_5A38+C8j ...
		beqz	R11, loc_5BB8
		ld24	R2, #unk_801ACA
		ld24	R4, #unk_801ACB
		ldub	R1, @R2
		stb	R1, @R4
		addi	R1, #-1
		stb	R1, @R2
		ldub	R4, @R4
		lduh	R5, @R10
		bl.l	sub_5BC8
		sth	R0, @R9	|| nop
		ld24	R0, #unk_80070B
		ldub	R0, @R0
		slli	R0, #0x1B
		bgez	R0, loc_5BB4
		ld24	R0, #unk_801009
		ldub	R0, @R0
		slli	R0, #0x1F
		bgez	R0, loc_5BB8

loc_5BB4:				; CODE XREF: sub_5A38+16Cj
		ldi8	R8, #1 || nop

loc_5BB8:				; CODE XREF: sub_5A38+8Ej sub_5A38+B6j ...
		mv	R0, R8
		pop	lr
		pop	R12
		pop	R11
		pop	R10
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_5A38


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_5BC8:				; CODE XREF: sub_4F24+15Cp
					; sub_52E8+15Cp ...
		push	R8
		push	R9
		push	R10
		push	lr
		mv	R8, R5 || nop
		ld24	R10, #unk_801000
		mv	R9, R4
		bl.s	nullsub_4
		ldub	R0, @(0xE, R10)
		slli	R0, #0x1F || nop
		lduh	R2, @(0xA60, R10)
		bgez	R0, loc_5BF0
		lduh	R2, @(0xA68, R10)

loc_5BF0:				; CODE XREF: sub_5BC8+20j
		slli	R9, #1
		addi	R9, #-2
		ld24	R0, #0x2828
		ldub	R1, @(0x86D, R10)
		add	R9, R0
		lduh	R0, @R9
		mul	R0, R2
		mul	R1, R2
		srli	R1, #4
		add	R1, R8
		srli	R0, #4
		sub	R0, R1
		ld24	R1, #unk_8003E0
		ld	R2, @R1	|| nop
		ld	R1, @(0x990, R10)
		sub	R2, R1
		ldi8	R1, #0x28 ; '('
		mv	R3, R2 || nop
		remu	R2, R1
		divu	R3, R1
		cmpui	R2, #0x14
		bc.s	loc_5C30
		addi	R3, #1

loc_5C30:				; CODE XREF: sub_5BC8+64j
		sub	R0, R3
		mv	R4, R0
		ldi8	R5, #0x14 || nop
		ld24	R6, #0xFFFF
		bl.l	sub_3744
		and3	R0, R0,	#0xFFFF
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		jmp	lr || nop
; End of function sub_5BC8

; [00000004 BYTES: COLLAPSED FUNCTION nullsub_4. PRESS KEYPAD "+" TO EXPAND]

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_5C54:				; CODE XREF: sub_EC6C+40p
		push	R8
		push	R9
		push	R10
		push	lr
		ld24	R10, #unk_801000
		ldub	R0, @(0x40, R10)
		slli	R0, #0x1B || nop
		ld24	R9, #0x100
		add3	R8, R9,	#0xC32
		bgez	R0, loc_5C78
		add3	R8, R9,	#0xC22

loc_5C78:				; CODE XREF: sub_5C54+1Cj
		ldub	R4, @(0x9B6, R10)
		addi	R4, #-0x20
		slli	R4, #0x10
		srai	R4, #0x10 || nop
		bl.l	sub_36D4
		slli	R0, #0x10
		mv	R4, R8
		srai	R0, #0x10 || nop
		ld24	R6, #unk_101000
		and3	R5, R0,	#0xFF
		bl.l	sub_35BC
		and3	R2, R0,	#0xFF
		stb	R2, @(0x86E, R10)
		ldub	R1, @(0x86D, R10)
		mv	R3, R2
		mv	R4, R1
		cmp	R2, R1
		bnc.s	loc_5CC4
		ldub	R4, @(0x86D, R10)
		ldub	R0, @(0xC21, R9)
		sub	R4, R0
		cmp	R2, R4
		bc.s	loc_5CD8
		mv	R4, R2
		bra.s	loc_5CD8 || nop
; ---------------------------------------------------------------------------

loc_5CC4:				; CODE XREF: sub_5C54+5Aj
		cmp	R1, R3
		bnc.s	loc_5CD8
		ldub	R0, @(0xC21, R9)
		mv	R4, R1
		add	R4, R0
		cmp	R4, R3
		bc.s	loc_5CD8
		mv	R4, R3 || nop

loc_5CD8:				; CODE XREF: sub_5C54+68j sub_5C54+6Cj ...
		ld24	R0, #unk_8024F3
		ldub	R0, @R0
		slli	R0, #0x1E
		bltz	R0, loc_5D00
		ldi8	R5, #0x14 || nop
		ldi16	R6, #0xFF
		bl.l	sub_3744
		and3	R0, R0,	#0xFF
		ld24	R1, #unk_802547
		stb	R0, @R1	|| nop
		stb	R0, @(0x86D, R10)

loc_5D00:				; CODE XREF: sub_5C54+8Cj
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		jmp	lr ||\
; End of function sub_5C54

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_5D0C:				; CODE XREF: sub_32C8+1A8p
		push	R8
		push	lr
		ld24	R8, #unk_801000
		ldub	R0, @(0xA, R8)
		slli	R0, #0x19 || nop
		bgez	R0, loc_5D38
		ldub	R0, @(0xA, R8)
		slli	R0, #0x18 || nop
		bgez	R0, loc_5D38
		ldub	R0, @(0x86D, R8)
		cmpui	R0, #0xC8 ; '+'
		bnc.s	loc_5D54 || nop

loc_5D38:				; CODE XREF: sub_5D0C+10j sub_5D0C+1Cj
		ldub	R0, @(9, R8)
		and3	R0, R0,	#0xFD
		stb	R0, @(9, R8)
		ldub	R0, @(0x16, R8)
		and3	R0, R0,	#0xEF
		stb	R0, @(0x16, R8)
		bra.s	loc_5DC0 || nop
; ---------------------------------------------------------------------------

loc_5D54:				; CODE XREF: sub_5D0C+28j
		ldub	R0, @(0x22, R8)
		slli	R0, #0x1A || nop
		bgez	R0, loc_5D84
		ldub	R0, @(9, R8)
		slli	R0, #0x1E || nop
		bltz	R0, loc_5DBC
		ldub	R0, @(0xA96, R8)
		bnez	R0, loc_5DC0
		ldub	R0, @(0x16, R8)
		slli	R0, #0x1B || nop
		bgez	R0, loc_5DC0
		bra.s	loc_5DA8 || nop
; ---------------------------------------------------------------------------

loc_5D84:				; CODE XREF: sub_5D0C+50j
		ldub	R0, @(0xA96, R8)
		beqz	R0, loc_5D9C
		ldub	R0, @(9, R8)
		and3	R0, R0,	#0xFD
		stb	R0, @(9, R8)
		bra.s	loc_5DC0 || nop
; ---------------------------------------------------------------------------

loc_5D9C:				; CODE XREF: sub_5D0C+7Cj
		ldub	R0, @(0x16, R8)
		slli	R0, #0x1B || nop
		bgez	R0, loc_5DB0

loc_5DA8:				; CODE XREF: sub_5D0C+74j
		bl.s	sub_5DFC || nop
		bra.s	loc_5DC0 || nop
; ---------------------------------------------------------------------------

loc_5DB0:				; CODE XREF: sub_5D0C+98j
		ldub	R0, @(9, R8)
		slli	R0, #0x1E || nop
		bgez	R0, loc_5DC0

loc_5DBC:				; CODE XREF: sub_5D0C+5Cj
		bl.s	sub_5DC8 || nop

loc_5DC0:				; CODE XREF: sub_5D0C+44j sub_5D0C+64j ...
		pop	lr
		pop	R8
		jmp	lr || nop
; End of function sub_5D0C


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_5DC8:				; CODE XREF: sub_5D0C:loc_5DBCp
		push	R8
		push	lr
		ld24	R0, #0xD59
		ldub	R0, @R0	|| nop
		ld24	R8, #unk_801000
		stb	R0, @(0x87C, R8)
		lduh	R0, @(0x870, R8)
		sth	R0, @(0x874, R8)
		sth	R0, @(0x876, R8)
		sth	R0, @(0x878, R8)
		sth	R0, @(0x87A, R8)
		bl.s	sub_5E90 || nop
		pop	lr
		pop	R8
		jmp	lr || nop
; End of function sub_5DC8


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_5DFC:				; CODE XREF: sub_5D0C:loc_5DA8p
		push	R8
		push	lr
		ld24	R8, #unk_801000
		ldub	R0, @(9, R8)
		and3	R0, R0,	#0xFD
		stb	R0, @(9, R8)
		ld24	R0, #0x1C66
		ldub	R4, @R0
		addi	R4, #-1
		bl.l	sub_36D4
		stb	R0, @(0xA96, R8)
		ldub	R0, @(0x16, R8)
		and3	R0, R0,	#0xEF
		stb	R0, @(0x16, R8)
		ldub	R0, @(0x87C, R8)
		bnez	R0, loc_5E88
		ldi8	R0, #1 || nop
		ldub	R1, @(0x3D7, R8)
		bne	R1, R0,	loc_5E48
		ldi8	R4, #2 || nop
		bl.l	sub_60EC

loc_5E48:				; CODE XREF: sub_5DFC+40j
		ldi8	R0, #2 || nop
		ldub	R1, @(0x3D7, R8)
		bne	R1, R0,	loc_5E5C
		ldi8	R4, #1 || nop
		bl.l	sub_60EC

loc_5E5C:				; CODE XREF: sub_5DFC+54j
		ldi8	R0, #3 || nop
		ldub	R1, @(0x3D7, R8)
		bne	R1, R0,	loc_5E70
		ldi8	R4, #4 || nop
		bl.l	sub_60EC

loc_5E70:				; CODE XREF: sub_5DFC+68j
		ldi8	R0, #4 || nop
		ldub	R1, @(0x3D7, R8)
		bne	R1, R0,	loc_5E84
		ldi8	R4, #3 || nop
		bl.l	sub_60EC

loc_5E84:				; CODE XREF: sub_5DFC+7Cj
		bl.s	sub_5E90 || nop

loc_5E88:				; CODE XREF: sub_5DFC+34j
		pop	lr
		pop	R8
		jmp	lr || nop
; End of function sub_5DFC


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_5E90:				; CODE XREF: sub_5DC8+28p
					; sub_5DFC:loc_5E84p
		push	R8
		push	R9
		push	lr
		ld24	R9, #unk_801000
		ldub	R0, @(0xABE, R9)
		ld24	R8, #unk_800000
		cmpui	R0, #2
		bc.s	loc_5EE8 || nop
		ldub	R0, @(0x70B, R8)
		slli	R0, #0x18 || nop
		bltz	R0, loc_5EE8
		lduh	R0, @(0x874, R9)
		beqz	R0, loc_5EE8
		ldub	R0, @(0xD, R9)
		or3	R0, R0,	#0x20
		stb	R0, @(0xD, R9)
		ldi8	R4, #1
		bl.s	sub_6084
		ldub	R0, @(9, R9)
		slli	R0, #0x1E || nop
		bgez	R0, loc_5EE8
		add3	R1, R9,	#0x87C
		ldub	R0, @R1
		addi	R0, #1
		stb	R0, @R1	|| nop

loc_5EE8:				; CODE XREF: sub_5E90+18j sub_5E90+24j ...
		ldub	R0, @(0xAC6, R9)
		cmpui	R0, #2
		bc.s	loc_5F30 || nop
		ldub	R0, @(0x70B, R8)
		slli	R0, #0x1A || nop
		bltz	R0, loc_5F30
		lduh	R0, @(0x878, R9)
		beqz	R0, loc_5F30
		ldub	R0, @(0xD, R9)
		or3	R0, R0,	#0x80
		stb	R0, @(0xD, R9)
		ldi8	R4, #3
		bl.s	sub_6084
		ldub	R0, @(9, R9)
		slli	R0, #0x1E || nop
		bgez	R0, loc_5F30
		add3	R0, R9,	#0x87C
		ldub	R1, @R0
		addi	R1, #1
		stb	R1, @R0	|| nop

loc_5F30:				; CODE XREF: sub_5E90+60j sub_5E90+6Cj ...
		ldub	R0, @(0xAC2, R9)
		cmpui	R0, #2
		bc.s	loc_5F78 || nop
		ldub	R0, @(0x70B, R8)
		slli	R0, #0x19 || nop
		bltz	R0, loc_5F78
		lduh	R0, @(0x876, R9)
		beqz	R0, loc_5F78
		ldub	R0, @(0xD, R9)
		or3	R0, R0,	#0x40
		stb	R0, @(0xD, R9)
		ldi8	R4, #2
		bl.s	sub_6084
		ldub	R0, @(9, R9)
		slli	R0, #0x1E || nop
		bgez	R0, loc_5F78
		add3	R0, R9,	#0x87C
		ldub	R1, @R0
		addi	R1, #1
		stb	R1, @R0	|| nop

loc_5F78:				; CODE XREF: sub_5E90+A8j sub_5E90+B4j ...
		ldub	R0, @(0xACA, R9)
		cmpui	R0, #2
		bc.s	loc_5FC0 || nop
		ldub	R0, @(0x70B, R8)
		slli	R0, #0x1B || nop
		bltz	R0, loc_5FC0
		lduh	R0, @(0x87A, R9)
		beqz	R0, loc_5FC0
		ldub	R0, @(0xC, R9)
		or3	R0, R0,	#1
		stb	R0, @(0xC, R9)
		ldi8	R4, #4
		bl.s	sub_6084
		ldub	R0, @(9, R9)
		slli	R0, #0x1E || nop
		bgez	R0, loc_5FC0
		add3	R0, R9,	#0x87C
		ldub	R1, @R0
		addi	R1, #1
		stb	R1, @R0	|| nop

loc_5FC0:				; CODE XREF: sub_5E90+F0j sub_5E90+FCj ...
		lduh	R0, @(0x874, R9)
		bnez	R0, loc_5FE0
		lduh	R0, @(0x878, R9)
		bnez	R0, loc_5FE0
		lduh	R0, @(0x876, R9)
		bnez	R0, loc_5FE0
		lduh	R0, @(0x87A, R9)
		beqz	R0, loc_5FEC

loc_5FE0:				; CODE XREF: sub_5E90+134j
					; sub_5E90+13Cj ...
		ldub	R0, @(9, R9)
		or3	R0, R0,	#1
		stb	R0, @(9, R9)

loc_5FEC:				; CODE XREF: sub_5E90+14Cj
		ldub	R0, @(9, R9)
		and3	R0, R0,	#0xFD
		add3	R1, R9,	#0xC
		stb	R0, @(9, R9)
		ldub	R0, @(1, R1)
		slli	R0, #0x1A || nop
		bgez	R0, loc_601C

loc_6008:				; CODE XREF: sub_5E90+180j
		ldub	R0, @(0x230, R8)
		slli	R0, #0x1F || nop
		bgez	R0, loc_6008
		ldi8	R0, #0xFE || nop
		stb	R0, @(0x230, R8)

loc_601C:				; CODE XREF: sub_5E90+174j
		ldub	R2, @(1, R1)
		slli	R2, #0x18 || nop
		bgez	R2, loc_603C

loc_6028:				; CODE XREF: sub_5E90+1A0j
		ldub	R0, @(0x230, R8)
		slli	R0, #0x1D || nop
		bgez	R0, loc_6028
		ldi8	R0, #0xFB || nop
		stb	R0, @(0x230, R8)

loc_603C:				; CODE XREF: sub_5E90+194j
		ldub	R0, @(1, R1)
		slli	R0, #0x19 || nop
		bgez	R0, loc_605C

loc_6048:				; CODE XREF: sub_5E90+1C0j
		ldub	R0, @(0x230, R8)
		slli	R0, #0x1E || nop
		bgez	R0, loc_6048
		ldi8	R2, #0xFD || nop
		stb	R2, @(0x230, R8)

loc_605C:				; CODE XREF: sub_5E90+1B4j
		ldub	R0, @R1	|| nop
		and3	R2, R0,	#1
		beqz	R2, loc_607C

loc_6068:				; CODE XREF: sub_5E90+1E0j
		ldub	R0, @(0x230, R8)
		slli	R0, #0x1C || nop
		bgez	R0, loc_6068
		ldi8	R0, #0xF7 || nop
		stb	R0, @(0x230, R8)

loc_607C:				; CODE XREF: sub_5E90+1D4j
		pop	lr
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_5E90


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6084:				; CODE XREF: sub_3EA4+60p sub_3F54+60p ...
		push	R8
		addi	R4, #-1
		ldi8	R3, #1 || nop
		and3	R4, R4,	#0xFF
		sll	R3, R4
		not	R7, R3
		ld24	R5, #unk_800000
		add3	R2, R5,	#0x2FC
		add3	R6, R5,	#0x2FE
		sll3	R8, R4,	#4
		and3	R1, R7,	#0xFFFF
		sth	R1, @R2
		lduh	R0, @R6
		and	R0, R7
		sth	R0, @R6
		add3	R0, R5,	#0x240
		add	R8, R0
		ldi8	R0, #0
		sth	R0, @R8	|| nop
		ld24	R0, #unk_801874
		slli	R4, #1
		add	R4, R0
		addi	R8, #2
		lduh	R4, @R4
		addi	R4, #-1
		sth	R4, @R8
		add3	R4, R5,	#0x224
		add3	R0, R5,	#0x226
		sth	R1, @R4
		lduh	R1, @R0
		and	R1, R7
		sth	R1, @R0
		lduh	R0, @R6
		or	R0, R3
		sth	R0, @R6
		ldi8	R0, #0
		sth	R0, @R2
		sth	R0, @R4
		pop	R8
		jmp	lr
; End of function sub_6084


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_60EC:				; CODE XREF: sub_5DFC+48p sub_5DFC+5Cp ...
		addi	R4, #-1	|| nop
		and3	R4, R4,	#0xFF
		ld24	R0, #0x283C
		slli	R4, #2
		add	R4, R0
		ldub	R3, @(3, R4)
		ld24	R1, #unk_801A90
		slli	R3, #1
		lduh	R1, @R1
		ld24	R2, #unk_801874
		add	R3, R2
		sth	R1, @R3
		ldub	R3, @(2, R4)
		slli	R3, #1
		add	R3, R2
		sth	R1, @R3	|| nop
		ldub	R3, @(1, R4)
		slli	R3, #1
		add	R3, R2
		sth	R1, @R3
		ldub	R0, @R4
		slli	R0, #1
		add	R0, R2
		sth	R1, @R0
		jmp	lr
; End of function sub_60EC


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6130:				; CODE XREF: sub_32C8+FCp
		ld24	R2, #unk_801000
		ldub	R0, @(0x38, R2)
		slli	R0, #0x18 || nop
		bltz	R0, loc_615C
		ldub	R0, @(0xA, R2)
		slli	R0, #0x1C || nop
		bgez	R0, loc_6174
		ld24	R0, #0xBCC
		lduh	R0, @R0	|| nop
		lduh	R1, @(0x9AE, R2)
		cmp	R1, R0
		bnc.s	locret_619C

loc_615C:				; CODE XREF: sub_6130+Cj
		ldub	R0, @(0xA, R2)
		and3	R0, R0,	#0xF7
		stb	R0, @(0xA, R2)
		ldi8	R0, #0 || nop
		stb	R0, @(0x2AA, R2)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_6174:				; CODE XREF: sub_6130+18j
		ld24	R0, #0xBCA
		lduh	R0, @R0	|| nop
		lduh	R1, @(0x9AE, R2)
		cmp	R1, R0
		bc.s	loc_6194
		ldub	R0, @(0xA, R2)
		or3	R0, R0,	#8
		stb	R0, @(0xA, R2)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_6194:				; CODE XREF: sub_6130+52j
		ldi8	R0, #0 || nop
		stb	R0, @(0x2AA, R2)

locret_619C:				; CODE XREF: sub_6130+2Aj
		jmp	lr || nop
; End of function sub_6130


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_61A0:				; CODE XREF: sub_C998+3Cp
		ld24	R1, #unk_801008
		ldub	R0, @(2, R1)
		and3	R0, R0,	#0xE7
		ld24	R3, #unk_800000
		stb	R0, @(2, R1)
		ld24	R0, #0xFFBF
		add3	R1, R3,	#0x224
		sth	R0, @R1	|| nop
		add3	R0, R3,	#0x226
		lduh	R2, @R0	|| nop
		and3	R2, R2,	#0xFFBF
		sth	R2, @R0
		ldi8	R0, #0
		sth	R0, @R1	|| nop
		add3	R0, R3,	#0x704
		ldub	R1, @R0	|| nop
		and3	R1, R1,	#7
		stb	R1, @R0
		jmp	lr
; End of function sub_61A0


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_61E4:				; CODE XREF: sub_32C8+100p
		push	R8
		push	R9
		push	R10
		push	R11
		push	R12
		push	lr
		ldi8	R2, #0 || nop
		ld24	R9, #unk_801000
		ldub	R11, @(0x3D7, R9)
		ld24	R8, #0xFF3F
		ld24	R10, #unk_800000
		beqz	R11, loc_6250
		ldub	R0, @(0xA, R9)
		addi	R11, #-1
		slli	R0, #0x1C
		and3	R11, R11, #0xFF
		bltz	R0, loc_6228
		ldub	R0, @(0xA, R9)
		and3	R0, R0,	#0xEF
		stb	R0, @(0xA, R9)
		ldi8	R12, #1
		bra.s	loc_6270
; ---------------------------------------------------------------------------

loc_6228:				; CODE XREF: sub_61E4+30j
		ldub	R0, @(0xA, R9)
		slli	R0, #0x1B || nop
		bltz	R0, loc_6244
		ldub	R0, @(0xA, R9)
		or3	R0, R0,	#0x10
		stb	R0, @(0xA, R9)
		ldi8	R12, #1
		bra.s	loc_6248
; ---------------------------------------------------------------------------

loc_6244:				; CODE XREF: sub_61E4+4Cj
		ldi8	R12, #0	|| nop

loc_6248:				; CODE XREF: sub_61E4+5Ej
		bl.s	sub_63D4 || nop
		ldi8	R2, #1
		bra.s	loc_6270
; ---------------------------------------------------------------------------

loc_6250:				; CODE XREF: sub_61E4+20j
		ldub	R0, @(0xB, R9)
		slli	R0, #0x1C || nop
		bgez	R0, loc_626C
		ldub	R0, @(0xB, R9)
		and3	R0, R0,	#0xF7
		stb	R0, @(0xB, R9)
		ldi8	R12, #1
		bra.s	loc_6270
; ---------------------------------------------------------------------------

loc_626C:				; CODE XREF: sub_61E4+74j
		ldi8	R2, #2
		ldi8	R12, #0

loc_6270:				; CODE XREF: sub_61E4+42j sub_61E4+6Aj ...
		ldi8	R0, #1 || nop
		bne	R12, R0, loc_62AC
		mv	R0, R11	|| nop
		ld24	R1, #0x284C
		add	R0, R1
		ldub	R3, @R0
		ldub	R0, @(0x1C, R9)
		mv	R3, R3
		slli	R0, #0x1C
		bgez	R0, loc_629C
		ld24	R0, #0x2850
		add	R11, R0
		ldub	R3, @R11
		mv	R3, R3 || nop

loc_629C:				; CODE XREF: sub_61E4+A8j
		add3	R0, R10, #0x704
		ldub	R1, @R0	|| nop
		and3	R1, R1,	#0x87
		or	R1, R3
		stb	R1, @R0

loc_62AC:				; CODE XREF: sub_61E4+90j
		bnez	R2, loc_62F4
		add3	R1, R10, #0x2FC
		add3	R0, R10, #0x2FE
		sth	R8, @R1
		lduh	R2, @R0
		and	R2, R8
		sth	R2, @R0
		ld24	R0, #0xFFBF
		add3	R2, R10, #0x224
		sth	R0, @R2	|| nop
		add3	R0, R10, #0x226
		lduh	R3, @R0	|| nop
		or3	R3, R3,	#0x40
		sth	R3, @R0
		ldi8	R0, #0
		sth	R0, @R2	|| nop
		ldub	R0, @(0xB, R9)
		or3	R0, R0,	#4
		stb	R0, @(0xB, R9)
		ldi8	R0, #0
		sth	R0, @R1
		bra.s	loc_63C4 || nop
; ---------------------------------------------------------------------------

loc_62F4:				; CODE XREF: sub_61E4:loc_62ACj
		ldi8	R0, #1 || nop
		bne	R2, R0,	loc_63C4
		add3	R0, R10, #0x2FE
		sth	R8, @(0x2FC, R10)
		lduh	R1, @R0
		and	R1, R8
		sth	R1, @R0	|| nop
		lduh	R1, @(0x332, R9)
		lduh	R0, @(0x334, R9)
		sub	R1, R0
		slli	R1, #0x10
		srai	R1, #0x10 || nop
		cmpi	R1, #4
		sth	R1, @(0x330, R9)
		bc.s	loc_634C || nop
		ldub	R0, @(0x70B, R10)
		slli	R0, #0x1E || nop
		bltz	R0, loc_6378
		addi	R1, #-1	|| nop
		sth	R1, @(0x2A0, R10)
		lduh	R0, @(0x334, R9)
		addi	R0, #-1	|| nop
		sth	R0, @(0x2A2, R10)
		bra.s	loc_6390 || nop
; ---------------------------------------------------------------------------

loc_634C:				; CODE XREF: sub_61E4+140j
		ldub	R0, @(0x70B, R10)
		slli	R0, #0x1E || nop
		bltz	R0, loc_6378
		ld24	R0, #0xFFBF
		add3	R1, R10, #0x224
		sth	R0, @R1	|| nop
		add3	R0, R10, #0x226
		lduh	R2, @R0	|| nop
		or3	R2, R2,	#0x40
		sth	R2, @R0
		ldi8	R0, #0
		sth	R0, @R1	|| nop

loc_6378:				; CODE XREF: sub_61E4+14Cj
					; sub_61E4+170j
		lduh	R1, @(0x332, R9)
		addi	R1, #-1	|| nop
		sth	R1, @(0x2A0, R10)
		lduh	R1, @(0x336, R9)
		addi	R1, #-1	|| nop
		sth	R1, @(0x2A2, R10)

loc_6390:				; CODE XREF: sub_61E4+164j
		lduh	R2, @(0x332, R9)
		addi	R2, #-1	|| nop
		ld24	R0, #0xFFFF
		add3	R1, R10, #0x2FE
		sth	R2, @(0x2B0, R10)
		sth	R0, @(0x2B2, R10)
		lduh	R0, @R1	|| nop
		or3	R0, R0,	#0xC0
		sth	R0, @R1
		ldi8	R1, #0
		sth	R1, @(0x2FC, R10)
		ldub	R1, @(0xB, R9)
		and3	R1, R1,	#0xFB
		stb	R1, @(0xB, R9)

loc_63C4:				; CODE XREF: sub_61E4+10Cj
					; sub_61E4+114j
		pop	lr
		pop	R12
		pop	R11
		pop	R10
		pop	R9
		pop	R8
		jmp	lr || nop
; End of function sub_61E4


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_63D4:				; CODE XREF: sub_61E4:loc_6248p
		push	R8
		push	R9
		push	R10
		push	lr
		ld24	R9, #unk_801000
		bl.l	sub_64D8
		ld24	R0, #unk_8024F3
		ldub	R0, @R0
		slli	R0, #0x1E
		bltz	R0, loc_6430
		ld24	R0, #0x99A
		ldub	R4, @R0	|| nop
		add3	R8, R9,	#0xA54
		lduh	R0, @R8
		mul	R4, R0
		lduh	R0, @(0x830, R9)
		srai	R4, #4
		add	R4, R0
		bl.l	sub_3704
		mv	R10, R0	|| nop
		ld24	R0, #0x908
		lduh	R4, @R8
		ldub	R0, @R0
		mul	R4, R0
		srai	R4, #4
		bl.l	sub_3704
		cmp	R0, R10
		bnc.s	loc_6428
		mv	R10, R0
		bra.s	loc_6428

loc_6428:				; CODE XREF: sub_63D4+4Ej
		sth	R10, @(0x334, R9)
		bra.s	loc_643C || nop
; ---------------------------------------------------------------------------

loc_6430:				; CODE XREF: sub_63D4+18j
		ld24	R0, #unk_80212A
		lduh	R0, @R0	|| nop
		sth	R0, @(0x334, R9)

loc_643C:				; CODE XREF: sub_63D4+58j
		ldi16	R0, #0xB4 ; '¦'
		lduh	R4, @(0xA54, R9)
		mul	R4, R0
		srai	R4, #4
		bl.l	sub_3704
		lduh	R1, @(0x334, R9)
		and3	R2, R0,	#0xFFFF
		mv	R0, R2
		sub	R0, R1
		cmpi	R0, #0xFA ; '·'
		bnc.s	loc_6468 || nop
		ldi16	R2, #0xFA ; '·'
		bra.s	loc_646C || nop
; ---------------------------------------------------------------------------

loc_6468:				; CODE XREF: sub_63D4+88j
		sub	R2, R1 || nop

loc_646C:				; CODE XREF: sub_63D4+90j
		ld24	R0, #unk_802242
		sth	R2, @(0x336, R9)
		ldub	R1, @R0	|| nop
		ld24	R0, #unk_8024F3
		ldub	R0, @R0
		slli	R1, #8
		slli	R0, #0x1E || nop
		bltz	R0, loc_648C
		ldh	R1, @(0x372, R9)

loc_648C:				; CODE XREF: sub_63D4+B0j
		ldi16	R2, #0x4100
		sub	R2, R1 || nop
		lduh	R1, @(0xA54, R9)
		mul	R2, R1 || nop
		ld24	R0, #unk_8003E0
		ldi16	R1, #0x1000
		ld	R0, @R0	|| nop
		div	R2, R1
		ld	R1, @(0x990, R9)
		sub	R0, R1
		ldi8	R1, #0x28 ; '('
		divu	R0, R1
		sub	R2, R0 || nop
		cmpui	R2, #0xB
		bnc.s	loc_64C8
		ldi8	R2, #0xB
		bra.s	loc_64C8 || nop

loc_64C8:				; CODE XREF: sub_63D4+ECj
		sth	R2, @(0x332, R9)
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		jmp	lr ||\
; End of function sub_63D4

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_64D8:				; CODE XREF: sub_63D4+Cp
		push	R8
		push	R9
		push	R10
		push	R11
		push	lr
		ld24	R9, #unk_801000
		ldub	R0, @(0x1E, R9)
		slli	R0, #0x19 || nop
		ld24	R8, #0x100
		ldh	R11, @(0x2F6, R9)
		bgez	R0, loc_6530
		ldi8	R0, #1 || nop
		ldub	R1, @(0x3D7, R9)
		bne	R1, R0,	loc_650C
		ldh	R11, @(0x2FA, R9)

loc_650C:				; CODE XREF: sub_64D8+2Cj
		ldi8	R0, #2 || nop
		bne	R1, R0,	loc_6518
		ldh	R11, @(0x2FC, R9)

loc_6518:				; CODE XREF: sub_64D8+38j
		ldi8	R0, #3 || nop
		bne	R1, R0,	loc_6524
		ldh	R11, @(0x2FE, R9)

loc_6524:				; CODE XREF: sub_64D8+44j
		ldi8	R0, #4 || nop
		bne	R1, R0,	loc_6530
		ldh	R11, @(0x300, R9)

loc_6530:				; CODE XREF: sub_64D8+20j sub_64D8+50j
		ldub	R0, @(0x28, R9)
		slli	R0, #0x19 || nop
		bgez	R0, loc_6548
		ldi8	R0, #0 || nop
		stb	R0, @(0x2AA, R9)
		bra.s	loc_659C || nop
; ---------------------------------------------------------------------------

loc_6548:				; CODE XREF: sub_64D8+60j
		ldub	R0, @(0x928, R9)
		beqz	R0, loc_6574
		lduh	R0, @(0x7EA, R8)
		sub	R11, R0	|| nop
		cmpi	R11, #0x8000
		bnc.s	loc_6568 || nop
		ldi16	R11, #0x8000
		bra.s	loc_6568 || nop

loc_6568:				; CODE XREF: sub_64D8+84j
		ldi8	R0, #0
		slli	R11, #0x10
		stb	R0, @(0x2AA, R9)
		srai	R11, #0x10
		bra.s	loc_659C
; ---------------------------------------------------------------------------

loc_6574:				; CODE XREF: sub_64D8+74j
		ldub	R0, @(8, R8)
		slli	R0, #0x1A || nop
		bltz	R0, loc_658C
		mv	R4, R11
		bl.s	sub_6764
		sll3	R11, R0, #0x10
		srai	R11, #0x10 || nop

loc_658C:				; CODE XREF: sub_64D8+A4j
		add3	R10, R9, #0x2AA
		ldub	R4, @R10 || nop
		bl.l	sub_37B4
		stb	R0, @R10 || nop

loc_659C:				; CODE XREF: sub_64D8+6Cj sub_64D8+9Aj
		sth	R11, @(0x370, R9)
		ldub	R0, @(0xB, R9)
		slli	R0, #0x1E || nop
		bgez	R0, loc_65CC
		ldub	R0, @(0xD, R9)
		and3	R0, R0,	#0xF7
		stb	R0, @(0xD, R9)
		ldub	R0, @(0xB, R9)
		and3	R0, R0,	#0xEF
		stb	R0, @(0xB, R9)
		bl.l	sub_68A0
		bra.s	loc_66E8 || nop
; ---------------------------------------------------------------------------

loc_65CC:				; CODE XREF: sub_64D8+D0j
		ldub	R0, @(0xD, R9)
		slli	R0, #0x1C || nop
		bltz	R0, loc_6604
		ldub	R0, @(0xB, R9)
		slli	R0, #0x1B || nop
		bltz	R0, loc_65EC
		bl.l	sub_68A0
		bra.s	loc_66E8 || nop
; ---------------------------------------------------------------------------

loc_65EC:				; CODE XREF: sub_64D8+108j
		ldub	R0, @(0xB, R9)
		and3	R0, R0,	#0xEF
		stb	R0, @(0xB, R9)
		ldh	R2, @(0x370, R9)
		sth	R2, @(0x2F8, R9)
		bra.s	loc_66E8 || nop
; ---------------------------------------------------------------------------

loc_6604:				; CODE XREF: sub_64D8+FCj
		add3	R3, R9,	#0x2C
		ldub	R2, @(1, R3)
		slli	R2, #0x1E || nop
		bltz	R2, loc_6620
		ldub	R2, @(1, R3)
		slli	R2, #0x1F || nop
		bgez	R2, loc_6674

loc_6620:				; CODE XREF: sub_64D8+138j
		add3	R10, R9, #0x37C
		ldi8	R5, #0
		ldub	R4, @R10
		bl.l	sub_378C
		and3	R1, R0,	#0xFF
		stb	R1, @R10 || nop
		ldub	R2, @(0x37A, R9)
		cmp	R1, R2
		bc.s	loc_66C8
		ldi8	R0, #0
		stb	R0, @R10
		ldub	R11, @(0xB, R9)
		or3	R11, R11, #0x10
		stb	R11, @(0xB, R9)
		ldub	R11, @(0x376, R9)
		ldub	R0, @(0x37B, R9)
		add	R11, R0
		slli	R11, #0x10
		srai	R11, #0x10 || nop
		ldub	R1, @(0x379, R9)
		cmp	R1, R11
		bnc.s	loc_6668
		bra.s	loc_666C || nop
; ---------------------------------------------------------------------------

loc_6668:				; CODE XREF: sub_64D8+18Aj
		mv	R1, R11	|| nop

loc_666C:				; CODE XREF: sub_64D8+18Cj
		stb	R1, @(0x376, R9)
		bra.s	loc_66C8 || nop
; ---------------------------------------------------------------------------

loc_6674:				; CODE XREF: sub_64D8+144j
		add3	R11, R9, #0x37D
		ldi8	R5, #0
		ldub	R4, @R11
		bl.l	sub_378C
		and3	R1, R0,	#0xFF
		stb	R1, @R11 || nop
		ldub	R2, @(0x378, R9)
		cmp	R1, R2
		bc.s	loc_66C8
		ldi8	R0, #0
		stb	R0, @R11
		ldub	R11, @(0x376, R9)
		ldub	R0, @(0x377, R9)
		sub	R11, R0
		slli	R11, #0x10
		srai	R11, #0x10 || nop
		bgtz	R11, loc_66C4
		ldi8	R11, #0	|| nop
		ldub	R0, @(0xD, R9)
		and3	R1, R0,	#0xF7
		stb	R1, @(0xD, R9)
		ldub	R0, @(0xB, R9)
		and3	R0, R0,	#0xEF
		stb	R0, @(0xB, R9)

loc_66C4:				; CODE XREF: sub_64D8+1CCj
		stb	R11, @(0x376, R9)

loc_66C8:				; CODE XREF: sub_64D8+162j
					; sub_64D8+198j ...
		ldub	R11, @(0x376, R9)
		ldh	R2, @(0x370, R9)
		slli	R11, #8
		sub	R2, R11
		cmpi	R2, #0x8000
		bnc.s	loc_66E4 || nop
		ldi16	R2, #0x8000
		bra.s	loc_66E4 || nop

loc_66E4:				; CODE XREF: sub_64D8+200j
		sth	R2, @(0x2F8, R9)

loc_66E8:				; CODE XREF: sub_64D8+F0j
					; sub_64D8+110j ...
		ldh	R4, @(0x2F8, R9)
		bl.l	sub_69D8
		sth	R0, @(0x9DA, R9)
		bl.l	sub_6B74
		mv	R4, R0
		bl.s	sub_6760
		mv	R4, R0 || nop
		bl.l	sub_6FE0
		ldub	R1, @(0x9B6, R9)
		ldub	R2, @(0x8A0, R8)
		ldh	R10, @(0x896, R8)
		cmp	R1, R2
		bnc.s	loc_6718
		ldh	R10, @(0x898, R8)

loc_6718:				; CODE XREF: sub_64D8+23Aj
		mv	R4, R0
		mv	R5, R10
		ldh	R6, @(0x894, R8)
		bl.l	sub_3744
		slli	R0, #0x10
		srai	R0, #0x10
		sth	R0, @(0x372, R9)
		srai	R0, #7 || nop
		add3	R0, R0,	#0x80
		slli	R0, #0x10
		srai	R0, #0x10
		mv	R4, R0 || nop
		bl.l	sub_3724
		ld24	R1, #unk_802599
		stb	R0, @R1	|| nop
		bl.l	nullsub_5
		bl.l	nullsub_6
		bl.l	nullsub_7
		pop	lr
		pop	R11
		pop	R10
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_64D8


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6760:				; CODE XREF: sub_64D8+222p
		mv	R0, R4
		jmp	lr
; End of function sub_6760


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6764:				; CODE XREF: sub_64D8+AAp
		push	R8
		push	R9
		push	lr
		mv	R8, R4
		ld24	R9, #unk_801000
		add3	R2, R9,	#0x18
		ldub	R0, @(2, R2)
		mv	R1, R8
		slli	R0, #0x1F
		bgez	R0, loc_678C
		ldub	R0, @(0x28, R9)
		slli	R0, #0x1D || nop
		bgez	R0, loc_6854

loc_678C:				; CODE XREF: sub_6764+18j
		ldub	R0, @(2, R2)
		slli	R0, #0x1F || nop
		bltz	R0, loc_67A4
		ldub	R0, @(0x28, R9)
		slli	R0, #0x1B || nop
		bgez	R0, loc_6854

loc_67A4:				; CODE XREF: sub_6764+30j
		ldub	R0, @(0xD, R9)
		slli	R0, #0x1B || nop
		bltz	R0, loc_6854
		ldub	R0, @(0x29, R9)
		slli	R0, #0x1E || nop
		bltz	R0, loc_6854
		ldub	R0, @(0x62, R9)
		slli	R0, #0x1F || nop
		bltz	R0, loc_6854
		add3	R2, R9,	#0x38
		ldub	R0, @(2, R2)
		slli	R0, #0x19 || nop
		bltz	R0, loc_6854
		ldub	R0, @(2, R2)
		slli	R0, #0x1A || nop
		bltz	R0, loc_6854
		ldub	R0, @(0x29, R9)
		slli	R0, #0x1C || nop
		bgez	R0, loc_6800
		ld24	R0, #0x8F0
		ldub	R0, @R0
		slli	R0, #8
		ldh	R2, @(0x372, R9)
		cmp	R0, R2
		bc.s	loc_6854

loc_6800:				; CODE XREF: sub_6764+88j
		add3	R2, R9,	#0x6C
		ldub	R0, @(3, R2)
		slli	R0, #0x1C || nop
		bltz	R0, loc_6854
		ldub	R0, @(3, R2)
		slli	R0, #0x1D || nop
		bltz	R0, loc_6854
		ldub	R0, @(0x68, R9)
		slli	R0, #0x1E || nop
		bltz	R0, loc_6854
		ldub	R0, @(0x1C, R9)
		slli	R0, #0x18 || nop
		bgez	R0, loc_6840
		ldub	R0, @(0x3F, R9)
		slli	R0, #0x18 || nop
		bltz	R0, loc_6854

loc_6840:				; CODE XREF: sub_6764+CCj
		ldub	R0, @(0x2AA, R9)
		bnez	R0, loc_6854
		ldub	R0, @(0x67, R9)
		slli	R0, #0x1E || nop
		bltz	R0, loc_6868

loc_6854:				; CODE XREF: sub_6764+24j sub_6764+3Cj ...
		lduh	R4, @(0x304, R9)
		add3	R4, R4,	#0x80
		bl.l	sub_3704
		and3	R0, R0,	#0xFF00
		mv	R1, R8
		sub	R1, R0

loc_6868:				; CODE XREF: sub_6764+ECj
		ldub	R0, @(9, R9)
		slli	R0, #0x1D || nop
		bgez	R0, loc_6880
		ld24	R0, #0x99C
		ldub	R0, @R0
		slli	R0, #8
		sub	R1, R0 || nop

loc_6880:				; CODE XREF: sub_6764+10Cj
		cmpi	R1, #0x8000
		bnc.s	loc_6890 || nop
		ldi16	R1, #0x8000
		bra.s	loc_6890 || nop

loc_6890:				; CODE XREF: sub_6764+120j
		slli	R1, #0x10
		srai	R1, #0x10
		mv	R0, R1
		pop	lr
		pop	R9
		pop	R8
		jmp	lr || nop
; End of function sub_6764


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_68A0:				; CODE XREF: sub_64D8+ECp
					; sub_64D8+10Cp
		addi	sp, #-8
		push	R8
		push	R9
		push	R10
		push	lr
		ld24	R8, #unk_801000
		ldh	R9, @(0x370, R8)
		ldh	R0, @(0x2F8, R8)
		mv	R10, R9
		sub	R10, R0
		ld24	R0, #0x99A
		ldub	R0, @R0
		slli	R0, #8
		sth	R0, @(0x14, sp)
		ld24	R0, #0x99D
		ldub	R0, @R0
		slli	R0, #8
		add3	R4, sp,	#0x14
		add3	R5, sp,	#0x10
		sth	R0, @(0x10, sp)
		bl.s	sub_698C || nop
		bgez	R10, loc_691C
		ldub	R0, @(0xB, R8)
		slli	R0, #0x1E || nop
		bltz	R0, loc_697C
		bgez	R10, loc_68F8
		neg	R10, R10
		bra.s	loc_68F8

loc_68F8:				; CODE XREF: sub_68A0+50j
		lduh	R0, @(0x10, sp)
		cmp	R10, R0
		bc.s	loc_697C
		ldh	R9, @(0x2F8, R8)
		lduh	R0, @(0x10, sp)
		sub	R9, R0 || nop
		cmpi	R9, #0x8000
		bnc.s	loc_697C || nop
		ldi16	R9, #0x8000
		bra.s	loc_697C || nop
; ---------------------------------------------------------------------------

loc_691C:				; CODE XREF: sub_68A0+40j
		ldub	R0, @(0xB, R8)
		slli	R0, #0x1E || nop
		bltz	R0, loc_694C
		lduh	R0, @(0x14, sp)
		cmp	R10, R0
		bc.s	loc_697C
		ldh	R9, @(0x2F8, R8)
		lduh	R0, @(0x14, sp)
		add	R9, R0 || nop
		cmpi	R9, #0x3C01
		bc.s	loc_697C || nop
		ldi16	R9, #0x3C00
		bra.s	loc_697C || nop
; ---------------------------------------------------------------------------

loc_694C:				; CODE XREF: sub_68A0+84j
		add3	R2, R8,	#0x374
		ldub	R1, @R2
		addi	R1, #1
		and3	R1, R1,	#0xFF
		ldh	R9, @(0x2F8, R8)
		stb	R1, @R2	|| nop
		ldub	R0, @(0x2B0, R8)
		cmp	R1, R0
		bc.s	loc_697C
		ldi8	R0, #0
		stb	R0, @R2
		ldh	R1, @(0x370, R8)
		add3	R9, R9,	#0x100
		cmp	R1, R9
		bnc.s	loc_697C
		mv	R9, R1 || nop

loc_697C:				; CODE XREF: sub_68A0+4Cj sub_68A0+5Ej ...
		sth	R9, @(0x2F8, R8)
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		addi	sp, #8
		jmp	lr
; End of function sub_68A0


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_698C:				; CODE XREF: sub_68A0+3Cp
		ld24	R0, #unk_801328
		ldub	R0, @R0	|| nop
		ld24	R1, #0x100
		beqz	R0, locret_69C8
		ldub	R0, @(0x89B, R1)
		slli	R0, #8
		sth	R0, @R4
		ld24	R4, #unk_801B5C
		ldub	R4, @R4	|| nop
		ldub	R0, @(0x1EAD, R1)
		cmp	R4, R0
		bc.s	loc_69BC
		ldub	R4, @(0x89E, R1)
		bra.s	loc_69C0 || nop
; ---------------------------------------------------------------------------

loc_69BC:				; CODE XREF: sub_698C+26j
		ldub	R4, @(0x89F, R1)

loc_69C0:				; CODE XREF: sub_698C+2Cj
		and3	R4, R4,	#0xFF
		slli	R4, #8
		sth	R4, @R5

locret_69C8:				; CODE XREF: sub_698C+Cj
		jmp	lr || nop
; End of function sub_698C

; [00000004 BYTES: COLLAPSED FUNCTION nullsub_5. PRESS KEYPAD "+" TO EXPAND]
; [00000004 BYTES: COLLAPSED FUNCTION nullsub_6. PRESS KEYPAD "+" TO EXPAND]
; [00000002 BYTES: COLLAPSED FUNCTION nullsub_7. PRESS KEYPAD "+" TO EXPAND]
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_69D8:				; CODE XREF: sub_64D8+214p
		addi	sp, #-4
		push	R8
		push	R9
		push	R10
		push	lr
		ldi8	R9, #0
		sll3	R8, R4,	#0x10
		ld24	R10, #unk_801000
		add3	R4, sp,	#0x10
		srai	R8, #0x10
		bl.s	sub_6A8C
		beqz	R0, loc_6A08
		ld	R4, @(0x10, sp)
		bl.s	sub_6AFC || nop
		beqz	R0, loc_6A08
		ldi8	R9, #1 || nop

loc_6A08:				; CODE XREF: sub_69D8+1Cj sub_69D8+28j
		ldi8	R0, #1 || nop
		bne	R9, R0,	loc_6A5C
		ld	R2, @(0x10, sp)
		ldub	R0, @(3, R2)
		stb	R0, @(0x2B0, R10)
		ldub	R0, @(7, R2)
		ldub	R1, @(0xA3A, R10)
		cmp	R0, R1
		bc.s	loc_6A4C
		ld	R4, @(0x10, sp)
		bl.s	sub_6B44 || nop
		sll3	R8, R0,	#0x10
		sth	R0, @(0x2F8, R10)
		ldi8	R0, #0
		srai	R8, #0x10
		stb	R0, @(0x374, R10)
		ldub	R0, @(0xB, R10)
		or3	R0, R0,	#2
		stb	R0, @(0xB, R10)

loc_6A4C:				; CODE XREF: sub_69D8+4Ej
		ld	R0, @(0x10, sp)
		ldub	R1, @(0xA3D, R10)
		ldub	R0, @(6, R0)
		cmp	R1, R0
		bc.s	loc_6A70

loc_6A5C:				; CODE XREF: sub_69D8+34j
		ldub	R0, @(0xB, R10)
		and3	R0, R0,	#0xFD
		stb	R0, @(0xB, R10)
		ldi8	R0, #0 || nop
		stb	R0, @(0x374, R10)

loc_6A70:				; CODE XREF: sub_69D8+82j
		add3	R9, R10, #0xA3A
		ldi8	R5, #0
		ldub	R4, @R9
		bl.l	sub_378C
		stb	R0, @R9
		mv	R0, R8
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		addi	sp, #4
		jmp	lr
; End of function sub_69D8


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6A8C:				; CODE XREF: sub_69D8+1Ap
		ld24	R3, #unk_801C74
		ldi8	R1, #1
		ld	R0, @R3
		ld24	R5, #unk_801000
		ldub	R2, @(0xAF8, R5)
		ldub	R0, @(2, R0)
		ld24	R6, #0x100
		cmp	R2, R0
		bnc.s	loc_6AC4
		ldub	R0, @(0x38, R5)
		slli	R0, #0x1D || nop
		bgez	R0, loc_6ABC
		add3	R2, R6,	#0x1AA
		bra.s	loc_6AC0 || nop
; ---------------------------------------------------------------------------

loc_6ABC:				; CODE XREF: sub_6A8C+24j
		add3	R2, R6,	#0x1BE

loc_6AC0:				; CODE XREF: sub_6A8C+2Cj
		st	R2, @R4
		bra.s	loc_6AF8
; ---------------------------------------------------------------------------

loc_6AC4:				; CODE XREF: sub_6A8C+1Aj
		ld	R0, @R3	|| nop
		ldub	R0, @(1, R0)
		cmp	R2, R0
		bc.s	loc_6AF4
		ld	R0, @R3
		ldub	R0, @R0
		cmp	R0, R2
		bc.s	loc_6AF4
		ldub	R0, @(0x38, R5)
		slli	R0, #0x1D || nop
		bgez	R0, loc_6AEC
		add3	R2, R6,	#0x1B4
		bra.s	loc_6AF0 || nop
; ---------------------------------------------------------------------------

loc_6AEC:				; CODE XREF: sub_6A8C+54j
		add3	R2, R6,	#0x1C8

loc_6AF0:				; CODE XREF: sub_6A8C+5Cj
		st	R2, @R4
		bra.s	loc_6AF8
; ---------------------------------------------------------------------------

loc_6AF4:				; CODE XREF: sub_6A8C+42j sub_6A8C+4Aj
		ldi8	R1, #0 || nop

loc_6AF8:				; CODE XREF: sub_6A8C+36j sub_6A8C+66j
		mv	R0, R1
		jmp	lr
; End of function sub_6A8C


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6AFC:				; CODE XREF: sub_69D8+24p
		ldi8	R1, #0 || nop
		ld24	R3, #unk_801000
		ldub	R2, @(0xAE0, R3)
		ldub	R0, @(8, R4)
		cmp	R2, R0
		bc.s	loc_6B40
		ldub	R0, @(0x38, R3)
		slli	R0, #0x19 || nop
		bltz	R0, loc_6B40
		ldub	R2, @(0x9B6, R3)
		ldub	R0, @(5, R4)
		cmp	R2, R0
		bc.s	loc_6B40
		ldub	R0, @(4, R4)
		cmp	R0, R2
		bc.s	loc_6B40
		ldub	R0, @(2, R4)
		ldub	R2, @(0xA9F, R3)
		cmp	R0, R2
		bc.s	loc_6B40
		ldi8	R1, #1 || nop

loc_6B40:				; CODE XREF: sub_6AFC+12j sub_6AFC+1Cj ...
		mv	R0, R1
		jmp	lr
; End of function sub_6AFC


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6B44:				; CODE XREF: sub_69D8+54p
		ldh	R0, @R4
		jmp	lr
; End of function sub_6B44


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6B48:				; CODE XREF: sub_CAA0+1Cp
		push	R8
		push	lr
		ld24	R8, #unk_801A3D
		ldi8	R5, #0
		ldub	R4, @R8
		bl.l	sub_378C
		stb	R0, @R8
		pop	lr
		pop	R8
		jmp	lr
; End of function sub_6B48


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6B60:				; CODE XREF: sub_C998+30p
		ld24	R1, #unk_801000
		lduh	R0, @(0x99A, R1)
		sth	R0, @(0x9E0, R1)
		sth	R0, @(0x9DE, R1)
		jmp	lr || nop
; End of function sub_6B60


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6B74:				; CODE XREF: sub_64D8+21Cp
		push	R8
		push	R9
		push	lr
		ld24	R8, #unk_801000
		ldi8	R9, #0
		bl.s	sub_6C18
		beqz	R0, loc_6BE0
		ldub	R0, @(8, R8)
		slli	R0, #0x1D || nop
		bgez	R0, loc_6BC8
		add3	R0, R8,	#8
		ldub	R1, @R0	|| nop
		and3	R1, R1,	#0xF1
		or3	R1, R1,	#1
		stb	R1, @R0
		ldi8	R0, #0
		stb	R0, @(0x9E9, R8)
		stb	R0, @(0x9EA, R8)
		stb	R0, @(0x9E6, R8)
		ldub	R0, @(0x9B6, R8)
		addi	R0, #0x1E || nop
		and3	R4, R0,	#0xFFFF
		bl.l	sub_36E4
		stb	R0, @(0x9E8, R8)

loc_6BC8:				; CODE XREF: sub_6B74+1Cj
		bl.l	sub_6E18
		bnez	R0, loc_6BE0
		bl.l	sub_6E58
		sll3	R9, R0,	#8
		stb	R0, @(0x9E7, R8)
		bra.s	loc_6BEC || nop
; ---------------------------------------------------------------------------

loc_6BE0:				; CODE XREF: sub_6B74+10j sub_6B74+58j
		ldub	R0, @(8, R8)
		and3	R0, R0,	#0xFE
		stb	R0, @(8, R8)

loc_6BEC:				; CODE XREF: sub_6B74+68j
		ldub	R1, @(8, R8)
		slli	R1, #0x1F || nop
		ldh	R0, @(0x9DA, R8)
		bgez	R1, loc_6C10
		sub	R0, R9
		mv	R4, R0
		ldi16	R5, #0x8000
		ldi16	R6, #0x7FFF
		bl.l	sub_3744
		slli	R0, #0x10
		srai	R0, #0x10

loc_6C10:				; CODE XREF: sub_6B74+84j
		pop	lr
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_6B74


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6C18:				; CODE XREF: sub_6B74+Ep
		ld24	R3, #unk_801000
		add3	R5, R3,	#0x38
		ldub	R0, @R5
		ldi8	R1, #1
		slli	R0, #0x1D || nop
		ld24	R4, #0x100
		bgez	R0, loc_6C64
		ldub	R0, @(0x1940, R4)
		ldub	R2, @(0xA3D, R3)
		cmp	R0, R2
		bc.s	loc_6C6C
		ldub	R2, @(0xAF8, R3)
		ldub	R0, @(0x1941, R4)
		cmp	R2, R0
		bnc.s	loc_6C6C
		ldub	R0, @(0x1942, R4)
		cmp	R2, R0
		bc.s	loc_6C6C
		ldub	R2, @(0x9B6, R3)
		ldub	R0, @(0x193E, R4)
		cmp	R2, R0
		bnc.s	loc_6C6C
		ldub	R0, @(0x193F, R4)
		cmp	R2, R0
		bc.s	loc_6C6C

loc_6C64:				; CODE XREF: sub_6C18+14j
		ldub	R0, @R5
		slli	R0, #0x19
		bgez	R0, loc_6C70

loc_6C6C:				; CODE XREF: sub_6C18+22j sub_6C18+2Ej ...
		ldi8	R1, #0 || nop

loc_6C70:				; CODE XREF: sub_6C18+50j
		mv	R0, R1
		jmp	lr
; End of function sub_6C18


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6C74:				; CODE XREF: sub_CE10+4p
		push	R8
		push	R9
		push	R10
		push	R11
		push	lr
		ld24	R10, #unk_801000
		add3	R11, R10, #0x99A
		lduh	R4, @R11 || nop
		add3	R8, R10, #0x9E0
		lduh	R0, @R8
		sub	R4, R0
		add3	R9, R10, #0x9D8
		ldh	R0, @R9
		srai	R0, #4
		add	R4, R0
		ldi8	R0, #0xF
		ldi16	R5, #0x8000
		mul	R4, R0 || nop
		ldh	R0, @(0x9DC, R10)
		ldi16	R6, #0x7FFF
		add	R4, R0 || nop
		bl.l	sub_3744
		sth	R0, @R9
		srai	R0, #7
		ldi8	R5, #0x80
		ldi8	R6, #0x7F ; ''
		slli	R0, #0x10
		srai	R0, #0x10
		mv	R4, R0 || nop
		bl.l	sub_3744
		slli	R0, #0x10
		srai	R0, #0x10
		stb	R0, @(0x9E2, R10)
		lduh	R11, @R11
		sth	R11, @R8
		pop	lr
		pop	R11
		pop	R10
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_6C74


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6CE4:				; CODE XREF: sub_CE98+Cp
		push	R8
		push	R9
		push	R10
		push	R11
		push	lr
		ld24	R9, #0x100
		ld24	R10, #unk_801000
		bl.l	sub_3534
		add3	R8, R10, #0x9E9
		ldi8	R5, #0
		ldub	R4, @R8
		bl.l	sub_378C
		stb	R0, @R8	|| nop
		bl.l	sub_3528
		ldub	R0, @(8, R10)
		slli	R0, #0x1E || nop
		bgez	R0, loc_6D3C
		bl.l	sub_3534
		add3	R8, R10, #0x9EA
		ldub	R4, @R8
		addi	R4, #4
		slli	R4, #0x10
		srai	R4, #0x10
		bl.l	sub_36E4
		slli	R0, #0x10
		srai	R0, #0x10
		stb	R0, @R8	|| nop
		bl.l	sub_3528

loc_6D3C:				; CODE XREF: sub_6CE4+34j
		ldi16	R5, #0x8000
		lduh	R4, @(0x972, R10)
		lduh	R0, @(0x976, R10)
		ldi16	R6, #0x7FFF
		sub	R4, R0 || nop
		bl.l	sub_3744
		ldi8	R5, #0x80
		ldi8	R6, #0x7F ; ''
		ldb	R4, @(0x9E4, R10)
		sll3	R11, R0, #0x10
		ldb	R0, @(0x9E2, R10)
		sub	R4, R0
		srai	R11, #0x10
		bl.l	sub_3744
		sll3	R8, R0,	#0x18
		ldub	R0, @(8, R10)
		srai	R8, #0x18
		slli	R0, #0x1F
		bltz	R0, loc_6DAC
		lduh	R0, @(0x1932, R9)
		cmp	R11, R0
		bc.s	loc_6D90
		lduh	R0, @(0x1934, R9)
		lduh	R1, @(0x976, R10)
		cmp	R0, R1
		bnc.s	loc_6D98

loc_6D90:				; CODE XREF: sub_6CE4+9Ej
		ldub	R0, @(0x1936, R9)
		cmp	R8, R0
		bc.s	loc_6DAC

loc_6D98:				; CODE XREF: sub_6CE4+AAj
		bl.l	sub_3534
		ldub	R0, @(8, R10)
		or3	R0, R0,	#4
		stb	R0, @(8, R10)
		bl.l	sub_3528

loc_6DAC:				; CODE XREF: sub_6CE4+94j sub_6CE4+B2j
		ld24	R0, #0x8000
		add	R11, R0	|| nop
		add3	R0, R10, #0x974
		sth	R11, @(0x978, R10)
		lduh	R1, @R0	|| nop
		sth	R1, @(0x976, R10)
		lduh	R1, @(0x972, R10)
		sth	R1, @R0	|| nop
		add3	R8, R8,	#0x80
		add3	R1, R10, #0x9E3
		stb	R8, @(0x9E5, R10)
		ldb	R0, @R1	|| nop
		stb	R0, @(0x9E4, R10)
		ldb	R2, @(0x9E2, R10)
		ldi16	R5, #0x8000
		stb	R2, @R1	|| nop
		add3	R11, R10, #0x99A
		add3	R8, R10, #0x9DE
		lduh	R4, @R11
		lduh	R0, @R8
		ldi16	R6, #0x7FFF
		sub	R4, R0 || nop
		bl.l	sub_3744
		sth	R0, @(0x9DC, R10)
		lduh	R11, @R11
		sth	R11, @R8
		pop	lr
		pop	R11
		pop	R10
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_6CE4


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6E18:				; CODE XREF: sub_6B74:loc_6BC8p
		ld24	R4, #unk_801000
		ldub	R0, @(8, R4)
		ldi8	R1, #0
		slli	R0, #0x1F
		bgez	R0, loc_6E50
		ldub	R2, @(0x9B6, R4)
		ldub	R0, @(0x9E8, R4)
		cmp	R2, R0
		bnc.s	loc_6E50
		ld24	R3, #0x1A43
		ldub	R3, @R3	|| nop
		ldub	R2, @(0x9E9, R4)
		cmp	R3, R2
		bc.s	loc_6E50
		ldub	R0, @(0x9EA, R4)
		and3	R3, R3,	#0xFF
		cmp	R3, R0
		bnc.s	loc_6E54

loc_6E50:				; CODE XREF: sub_6E18+Cj sub_6E18+1Aj	...
		ldi8	R1, #1 || nop

loc_6E54:				; CODE XREF: sub_6E18+36j
		mv	R0, R1
		jmp	lr
; End of function sub_6E18


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6E58:				; CODE XREF: sub_6B74+5Cp
		push	R8
		push	R9
		push	R10
		push	lr
		ld24	R8, #unk_801000
		ldb	R0, @(0x9E2, R8)
		ld24	R10, #0x100
		cmpi	R0, #1
		ldi8	R9, #0
		bnc.s	loc_6EC4
		ldub	R0, @(8, R8)
		slli	R0, #0x1E || nop
		bgez	R0, loc_6F54
		add3	R2, R8,	#8
		ldub	R0, @R2	|| nop
		and3	R0, R0,	#0xFD
		stb	R0, @R2	|| nop
		and3	R0, R0,	#0xFF
		ldi8	R1, #0
		slli	R0, #0x1C
		bgez	R0, loc_6EB4
		ldub	R0, @(8, R8)
		and3	R0, R0,	#0xFE
		and3	R1, R1,	#1
		or	R0, R1 || nop
		stb	R0, @(8, R8)
		bra.s	loc_6F54 || nop
; ---------------------------------------------------------------------------

loc_6EB4:				; CODE XREF: sub_6E58+40j
		ldub	R0, @(8, R8)
		or3	R0, R0,	#8
		stb	R0, @(8, R8)
		bra.s	loc_6F54 || nop
; ---------------------------------------------------------------------------

loc_6EC4:				; CODE XREF: sub_6E58+1Aj
		ldub	R0, @(8, R8)
		or3	R0, R0,	#2
		stb	R0, @(8, R8)
		bl.s	sub_6F8C || nop
		ldub	R1, @(0x9B6, R8)
		and3	R4, R0,	#0xFF
		ldub	R0, @(0x1939, R10)
		cmp	R1, R0
		bnc.s	loc_6EFC
		ldub	R0, @(0x193C, R10)
		sub	R4, R0 || nop
		ldub	R0, @(0x1938, R10)
		sub	R4, R0 || nop
		bl.l	sub_36D4
		and3	R4, R0,	#0xFF

loc_6EFC:				; CODE XREF: sub_6E58+8Aj
		ldub	R0, @(8, R8)
		slli	R0, #0x1C || nop
		bgez	R0, loc_6F20
		ldub	R9, @(0x193D, R10)
		ldb	R0, @(0x9E6, R8)
		mul	R9, R0
		srai	R9, #5
		slli	R9, #0x10
		srai	R9, #0x10
		cmp	R4, R9
		bnc.s	loc_6F54
		bra.s	loc_6F4C || nop
; ---------------------------------------------------------------------------

loc_6F20:				; CODE XREF: sub_6E58+ACj
		add3	R1, R8,	#0x9E6
		ldb	R0, @R1	|| nop
		ldb	R2, @(0x9E2, R8)
		cmp	R2, R0
		bc.s	loc_6F34
		stb	R2, @R1	|| nop

loc_6F34:				; CODE XREF: sub_6E58+D6j
		ldub	R0, @(0xA9F, R8)
		srli	R0, #4 || nop
		ldub	R1, @(0x1937, R10)
		sub	R0, R1
		addi	R0, #1
		ldb	R2, @(0x9E2, R8)
		cmp	R2, R0
		bc.s	loc_6F54

loc_6F4C:				; CODE XREF: sub_6E58+C4j
		sll3	R9, R4,	#0x10
		srai	R9, #0x10 || nop

loc_6F54:				; CODE XREF: sub_6E58+24j sub_6E58+58j ...
		ldub	R1, @(0x9B6, R8)
		ldub	R0, @(0x1939, R10)
		cmp	R1, R0
		bnc.s	loc_6F70
		ldub	R0, @(0x1938, R10)
		add	R0, R9 || nop
		sll3	R9, R0,	#0x10
		srai	R9, #0x10 || nop

loc_6F70:				; CODE XREF: sub_6E58+106j
		mv	R4, R9 || nop
		bl.l	sub_3724
		slli	R0, #0x10
		srai	R0, #0x10
		and3	R0, R0,	#0xFF
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		jmp	lr || nop
; End of function sub_6E58


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6F8C:				; CODE XREF: sub_6E58+78p
		ld24	R4, #unk_801000
		ldub	R0, @(0xAF8, R4)
		ld24	R2, #0x100
		cmpui	R0, #3
		ldi8	R3, #0
		bc.s	loc_6FDC
		ldub	R1, @(0xAE0, R4)
		ldub	R0, @(0x193B, R2)
		cmp	R1, R0
		bnc.s	loc_6FB0
		ldi8	R3, #2
		bra.s	loc_6FBC
; ---------------------------------------------------------------------------

loc_6FB0:				; CODE XREF: sub_6F8C+1Ej
		ldub	R0, @(0x193A, R2)
		cmp	R1, R0
		bnc.s	loc_6FBC
		ldi8	R3, #1 || nop

loc_6FBC:				; CODE XREF: sub_6F8C+22j sub_6F8C+2Aj
		ldub	R1, @(0x9B6, R4)
		ldub	R0, @(0x1939, R2)
		cmp	R1, R0
		bc.s	loc_6FD0
		addi	R3, #1 || nop
		and3	R3, R3,	#0xFF

loc_6FD0:				; CODE XREF: sub_6F8C+3Aj
		ldh	R0, @(0x9DA, R4)
		srai	R0, #8
		sra	R0, R3
		and3	R3, R0,	#0xFF

loc_6FDC:				; CODE XREF: sub_6F8C+12j
		mv	R0, R3
		jmp	lr
; End of function sub_6F8C


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_6FE0:				; CODE XREF: sub_64D8+228p
		push	R8
		push	R9
		push	R10
		push	R11
		push	R12
		push	lr
		mv	R8, R4 || nop
		ld24	R9, #unk_801000
		ldub	R0, @(0x38, R9)
		ldi8	R10, #0
		slli	R0, #0x1E
		ld24	R11, #0x100
		bgez	R0, loc_7014
		ldub	R0, @(0xB, R9)
		or3	R0, R0,	#1
		stb	R0, @(0xB, R9)
		bra.s	loc_7058 || nop
; ---------------------------------------------------------------------------

loc_7014:				; CODE XREF: sub_6FE0+20j
		ldub	R0, @(0xB, R9)
		slli	R0, #0x1F || nop
		bgez	R0, loc_7058
		ldub	R0, @(0xB, R9)
		and3	R0, R0,	#0xFE
		stb	R0, @(0xB, R9)
		ldub	R1, @(0xAF8, R9)
		ldub	R0, @(0x109, R11)
		cmp	R1, R0
		bnc.s	loc_7058
		lduh	R1, @(0x9AE, R9)
		lduh	R0, @(0x102, R11)
		cmp	R1, R0
		bnc.s	loc_7058
		lduh	R0, @(0x104, R11)
		cmp	R0, R1
		bnc.s	loc_7058
		ldi8	R10, #1	|| nop
		ldub	R0, @(0x108, R11)
		stb	R0, @(0x2A0, R9)

loc_7058:				; CODE XREF: sub_6FE0+30j sub_6FE0+3Cj ...
		bnez	R10, loc_7078
		add3	R12, R9, #0x2A0
		ldub	R4, @R12 || nop
		bl.l	sub_37B4
		and3	R0, R0,	#0xFF
		stb	R0, @R12 || nop
		beqz	R0, loc_7078
		ldi8	R10, #1	|| nop

loc_7078:				; CODE XREF: sub_6FE0:loc_7058j
					; sub_6FE0+90j
		ldi8	R0, #1 || nop
		bne	R10, R0, loc_7084
		ldh	R8, @(0x106, R11)

loc_7084:				; CODE XREF: sub_6FE0+9Cj
		mv	R0, R8
		pop	lr
		pop	R12
		pop	R11
		pop	R10
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_6FE0


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_7094:				; CODE XREF: sub_32C8+104p
		push	R8
		push	R9
		push	lr
		ld24	R9, #unk_801000
		ldub	R0, @(0x38, R9)
		slli	R0, #0x1A || nop
		ld24	R8, #unk_800000
		bltz	R0, loc_70B8
		bl.s	sub_7144 || nop
		bra.s	loc_713C || nop
; ---------------------------------------------------------------------------

loc_70B8:				; CODE XREF: sub_7094+18j
		ldub	R0, @(8, R9)
		slli	R0, #0x1A || nop
		bltz	R0, loc_713C
		ldub	R0, @(8, R9)
		slli	R0, #0x1B || nop
		bgez	R0, loc_7130
		lduh	R0, @(0xA56, R9)
		sth	R0, @(0xA46, R9)
		srli	R0, #1 || nop
		add3	R1, R8,	#0x2E2
		addi	R0, #-1
		sth	R0, @R1
		ld24	R0, #0xFBFF
		lduh	R1, @R1	|| nop
		sth	R1, @(0x2E0, R8)
		add3	R1, R8,	#0x2FC
		add3	R2, R8,	#0x224
		sth	R0, @R1
		sth	R0, @R2
		add3	R0, R8,	#0x226
		lduh	R3, @R0	|| nop
		or3	R3, R3,	#0x400
		sth	R3, @R0	|| nop
		add3	R0, R8,	#0x2FE
		lduh	R3, @R0	|| nop
		or3	R3, R3,	#0x400
		sth	R3, @R0
		ldi8	R0, #0
		sth	R0, @R1
		sth	R0, @R2
		ldub	R0, @(8, R9)
		or3	R0, R0,	#0x20
		stb	R0, @(8, R9)
		bra.s	loc_713C || nop
; ---------------------------------------------------------------------------

loc_7130:				; CODE XREF: sub_7094+38j
		ldub	R0, @(8, R9)
		or3	R0, R0,	#0x10
		stb	R0, @(8, R9)

loc_713C:				; CODE XREF: sub_7094+20j sub_7094+2Cj ...
		pop	lr
		pop	R9
		pop	R8
		jmp	lr
; End of function sub_7094


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_7144:				; CODE XREF: sub_7094+1Cp sub_C998+20p
		ld24	R3, #unk_800000
		ld24	R5, #0xFBFF
		add3	R2, R3,	#0x2FC
		add3	R0, R3,	#0x2FE
		sth	R5, @R2
		lduh	R1, @R0
		and	R1, R5
		sth	R1, @R0
		add3	R1, R3,	#0x224
		sth	R5, @R1	|| nop
		add3	R0, R3,	#0x226
		lduh	R4, @R0
		and	R4, R5
		sth	R4, @R0
		ldi8	R0, #0
		sth	R0, @R2
		sth	R0, @R1
		ld24	R0, #unk_801008
		ldub	R1, @R0	|| nop
		and3	R1, R1,	#0xCF
		stb	R1, @R0
		jmp	lr
; End of function sub_7144


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_7184:				; DATA XREF: ROM_:000000C8o
		push	R8
		push	lr
		ld24	R1, #unk_800400
		ldi8	R0, #0xFC
		stb	R0, @R1
		ld24	R8, #unk_801000
		add3	R5, R8,	#0xC
		ldub	R0, @(1, R5)
		slli	R0, #0x1F || nop
		bgez	R0, loc_71B4
		ldub	R0, @(0xD, R8)
		and3	R0, R0,	#0xFE
		stb	R0, @(0xD, R8)
		bra.l	loc_75CC
; ---------------------------------------------------------------------------

loc_71B4:				; CODE XREF: sub_7184+1Cj
		ld24	R1, #0xFEFF
		ld24	R4, #unk_8003BC
		ld24	R0, #unk_8003BE
		sth	R1, @R4
		lduh	R3, @R0
		and3	R3, R3,	#0xFEFF
		sth	R3, @R0
		ldi8	R3, #0xF7
		ld24	R1, #unk_800229
		ld24	R0, #unk_80022B
		stb	R3, @R1
		ldub	R6, @R0
		and3	R3, R6,	#0xF7
		ldi8	R2, #0
		stb	R3, @R0
		sth	R2, @R4
		stb	R2, @R1
		ldub	R0, @(1, R5)
		and3	R0, R0,	#0xFB
		ld24	R4, #unk_8024F3
		stb	R0, @(1, R5)
		sth	R2, @(0x80A, R8)
		sth	R2, @(0x80C, R8)
		ldub	R3, @R4
		slli	R3, #0x1E
		bgez	R3, loc_728C
		ldi8	R5, #0
		bra.s	loc_7270
; ---------------------------------------------------------------------------

loc_7208:				; CODE XREF: sub_7184+F2j
		sll3	R4, R5,	#1
		add3	R7, R8,	#0x3FE
		ld24	R1, #0xB71
		add	R4, R7
		lduh	R3, @R4
		srli	R3, #2
		ldub	R1, @R1
		mv	R6, R3
		sub	R6, R1
		bgez	R6, loc_7228
		neg	R6, R6
		bra.s	loc_7230
; ---------------------------------------------------------------------------

loc_7228:				; CODE XREF: sub_7184+9Cj
		and3	R4, R1,	#0xFF
		sub	R3, R4
		mv	R6, R3

loc_7230:				; CODE XREF: sub_7184+A2j
		add3	R4, R8,	#0x816
		ldub	R0, @R4
		cmp	R0, R6
		bnc.s	loc_723C
		stb	R6, @R4

loc_723C:				; CODE XREF: sub_7184+B4j
		add3	R0, R8,	#0x80C
		lduh	R1, @R0	|| nop
		and3	R4, R6,	#0xFFFF
		add	R1, R4
		sth	R1, @R0
		ldub	R3, @(0x933, R8)
		sub	R6, R3 || nop
		blez	R6, loc_7268
		add3	R1, R8,	#0x80A
		lduh	R0, @R1	|| nop
		and3	R6, R6,	#0xFFFF
		add	R0, R6
		sth	R0, @R1

loc_7268:				; CODE XREF: sub_7184+D0j
		add3	R1, R5,	#1
		and3	R5, R1,	#0xFFFF

loc_7270:				; CODE XREF: sub_7184+82j
		lduh	R7, @(0x800, R8)
		cmp	R5, R7
		bc.s	loc_7208
		add3	R7, R8,	#0x816
		ldub	R0, @R7	|| nop
		stb	R0, @(0x81A, R8)
		ldi8	R0, #0
		stb	R0, @R7
		bra.s	loc_730C || nop
; ---------------------------------------------------------------------------

loc_728C:				; CODE XREF: sub_7184+7Cj
		ldi8	R5, #0
		bra.s	loc_7304
; ---------------------------------------------------------------------------

loc_7290:				; CODE XREF: sub_7184+186j
		sll3	R1, R5,	#1
		add3	R3, R8,	#0x3FE
		ld24	R4, #0xB71
		add	R1, R3
		lduh	R1, @R1
		srli	R1, #2
		ldub	R4, @R4
		mv	R6, R1
		sub	R6, R4
		bgez	R6, loc_72B0
		neg	R6, R6
		bra.s	loc_72B8
; ---------------------------------------------------------------------------

loc_72B0:				; CODE XREF: sub_7184+124j
		and3	R4, R4,	#0xFF
		sub	R1, R4
		mv	R6, R1

loc_72B8:				; CODE XREF: sub_7184+12Aj
		add3	R0, R8,	#0x80C
		lduh	R1, @R0	|| nop
		and3	R3, R6,	#0xFFFF
		add	R1, R3
		sth	R1, @R0
		ldub	R0, @(0x933, R8)
		sub	R6, R0 || nop
		blez	R6, loc_72E4
		add3	R1, R8,	#0x80A
		lduh	R0, @R1	|| nop
		and3	R6, R6,	#0xFFFF
		add	R0, R6
		sth	R0, @R1

loc_72E4:				; CODE XREF: sub_7184+14Cj
		lduh	R0, @(0x80C, R8)
		ld24	R1, #0xFF00
		cmp	R1, R0
		bnc.s	loc_72FC
		addi	R5, #1 || nop
		sth	R5, @(0x800, R8)
		bra.s	loc_730C || nop
; ---------------------------------------------------------------------------

loc_72FC:				; CODE XREF: sub_7184+16Aj
		addi	R5, #1 || nop
		and3	R5, R5,	#0xFFFF

loc_7304:				; CODE XREF: sub_7184+10Aj
		lduh	R0, @(0x800, R8)
		cmp	R5, R0
		bc.s	loc_7290

loc_730C:				; CODE XREF: sub_7184+104j
					; sub_7184+174j
		lduh	R0, @(0x80A, R8)
		ld24	R3, #unk_8025AE
		srli	R0, #5
		stb	R0, @R3
		lduh	R0, @(0x80C, R8)
		ld24	R3, #unk_8025AF
		add3	R1, R8,	#0x817
		srli	R0, #5
		stb	R0, @R3
		ldub	R0, @R1
		addi	R0, #-1
		and3	R0, R0,	#0xFF
		stb	R0, @R1	|| nop
		bnez	R0, loc_7374
		ldi8	R1, #0x80 || nop
		add3	R3, R8,	#0x802
		stb	R1, @(0x817, R8)
		lduh	R0, @R3	|| nop
		sth	R0, @(0x808, R8)
		ldi8	R5, #0
		srli	R0, #5
		ld24	R1, #unk_8025B0
		stb	R0, @R1
		sth	R5, @R3
		add3	R3, R8,	#0x3E8
		ld	R5, @R3
		srli	R5, #7
		ld24	R1, #unk_8025AD
		and3	R0, R5,	#0xFFFF
		sth	R0, @(0x7FE, R8)
		srli	R0, #5
		stb	R0, @R1
		ldi8	R0, #0
		st	R0, @R3

loc_7374:				; CODE XREF: sub_7184+1B0j
		add3	R1, R8,	#0x818
		ldub	R6, @R1	|| nop
		bnez	R6, loc_73B8
		ldi8	R0, #0x80 || nop
		add3	R4, R8,	#0x804
		stb	R0, @R1
		lduh	R1, @R4
		sth	R1, @(0x812, R8)
		ldi8	R0, #0
		srli	R1, #5
		ld24	R3, #unk_8025D0
		stb	R1, @R3
		sth	R0, @R4
		add3	R0, R8,	#0x3EC
		ld	R4, @R0
		srli	R4, #7
		ld24	R1, #unk_8025D2
		and3	R6, R4,	#0xFFFF
		sth	R6, @(0x80E, R8)
		srli	R6, #5
		stb	R6, @R1
		ldi8	R6, #0
		st	R6, @R0

loc_73B8:				; CODE XREF: sub_7184+1F8j
		add3	R3, R8,	#0x819
		ldub	R1, @R3	|| nop
		bnez	R1, loc_7400
		ldi8	R0, #0x80 || nop
		add3	R1, R8,	#0x806
		stb	R0, @R3
		lduh	R0, @R1
		ld24	R5, #unk_8025D1
		sth	R0, @(0x814, R8)
		srli	R0, #5
		stb	R0, @R5
		ldi8	R0, #0
		sth	R0, @R1
		add3	R0, R8,	#0x3F0
		ld	R7, @R0
		ldi8	R5, #0
		srli	R7, #7 || nop
		and3	R7, R7,	#0xFFFF
		sth	R7, @(0x810, R8)
		srli	R7, #5 || nop
		ld24	R1, #unk_8025D3
		stb	R7, @R1
		st	R5, @R0

loc_7400:				; CODE XREF: sub_7184+23Cj
		add3	R1, R8,	#0x802
		lduh	R0, @R1	|| nop
		lduh	R7, @(0x80A, R8)
		cmp	R0, R7
		bnc.s	loc_7414
		sth	R7, @R1	|| nop

loc_7414:				; CODE XREF: sub_7184+28Aj
		lduh	R1, @(0x80A, R8)
		add3	R3, R8,	#0x3E8
		ld	R4, @R3
		add	R4, R1
		st	R4, @R3
		ldi8	R4, #1
		ldub	R1, @(0x934, R8)
		beq	R1, R4,	loc_7438
		ldi8	R0, #3 || nop
		and3	R4, R1,	#0xFF
		bne	R4, R0,	loc_7468

loc_7438:				; CODE XREF: sub_7184+2A4j
		add3	R3, R8,	#0x804
		lduh	R4, @R3	|| nop
		lduh	R6, @(0x80A, R8)
		cmp	R4, R6
		bnc.s	loc_744C
		sth	R6, @R3	|| nop

loc_744C:				; CODE XREF: sub_7184+2C2j
		add3	R6, R8,	#0x3EC
		ld	R0, @R6	|| nop
		lduh	R4, @(0x80A, R8)
		add3	R7, R8,	#0x818
		add	R0, R4
		st	R0, @R6
		ldub	R4, @R7
		addi	R4, #-1
		stb	R4, @R7
		bra.s	loc_7494
; ---------------------------------------------------------------------------

loc_7468:				; CODE XREF: sub_7184+2B0j
		add3	R5, R8,	#0x806
		lduh	R3, @R5	|| nop
		lduh	R1, @(0x80A, R8)
		cmp	R3, R1
		bnc.s	loc_747C
		sth	R1, @R5	|| nop

loc_747C:				; CODE XREF: sub_7184+2F2j
		lduh	R5, @(0x80A, R8)
		add3	R3, R8,	#0x3F0
		ld	R0, @R3
		add	R0, R5
		add3	R1, R8,	#0x819
		st	R0, @R3
		ldub	R0, @R1
		addi	R0, #-1
		stb	R0, @R1

loc_7494:				; CODE XREF: sub_7184+2E2j
		ldi8	R0, #1 || nop
		ldub	R3, @(0x934, R8)
		beq	R3, R0,	loc_74A8
		ldi8	R6, #3 || nop
		bne	R3, R6,	loc_74B0

loc_74A8:				; CODE XREF: sub_7184+318j
		lduh	R3, @(0x91E, R8)
		bra.s	loc_74B4 || nop
; ---------------------------------------------------------------------------

loc_74B0:				; CODE XREF: sub_7184+320j
		lduh	R3, @(0x920, R8)

loc_74B4:				; CODE XREF: sub_7184+328j
		lduh	R0, @(0x80A, R8)
		cmp	R3, R0
		bnc.s	loc_74C8
		ldub	R0, @(9, R8)
		or3	R0, R0,	#8
		stb	R0, @(9, R8)

loc_74C8:				; CODE XREF: sub_7184+336j
		ld24	R0, #unk_80009E
		lduh	R0, @R0
		srai	R0, #2
		and3	R0, R0,	#0xFF
		cmpui	R0, #0xAF ; '»'
		bnc.s	loc_74E4 || nop
		cmpui	R0, #0x1E
		bnc.s	loc_74F4 || nop

loc_74E4:				; CODE XREF: sub_7184+354j
		ldub	R1, @(9, R8)
		or3	R0, R1,	#0x10
		stb	R0, @(9, R8)
		bra.s	loc_7508 || nop
; ---------------------------------------------------------------------------

loc_74F4:				; CODE XREF: sub_7184+35Cj
		ldub	R3, @(9, R8)
		and3	R0, R2,	#1
		and3	R1, R3,	#0xEF
		slli	R0, #4
		or	R1, R0
		stb	R1, @(9, R8)

loc_7508:				; CODE XREF: sub_7184+36Cj
		lduh	R1, @(0x800, R8)
		beqz	R1, loc_75CC
		lduh	R5, @(0x80C, R8)
		mv	R6, R5 || nop
		rem	R5, R1
		slli	R5, #8 || nop
		div	R5, R1
		srai	R5, #7 || nop
		ld24	R0, #unk_8025AC
		div	R6, R1
		and3	R6, R6,	#0xFF
		add	R5, R6
		stb	R6, @R0
		sth	R5, @(0x3FC, R8)
		ldub	R4, @(0x926, R8)
		ldub	R1, @(9, R8)
		mv	R0, R4
		slli	R1, #0x1C
		bgez	R1, loc_7560
		ld24	R1, #0xB72
		ldub	R5, @R1
		mul	R4, R5
		srai	R4, #4 || nop
		bl.l	sub_36E4
		and3	R0, R0,	#0xFF

loc_7560:				; CODE XREF: sub_7184+3C4j
		mv	R2, R0 || nop
		ld24	R7, #unk_8025B1
		stb	R2, @(0x81B, R8)
		stb	R2, @R7	|| nop
		ldub	R6, @(0x934, R8)
		slli	R6, #1
		addi	R6, #-2
		add3	R4, R8,	#0x3F4
		mv	R7, R6
		add	R7, R4
		beqz	R2, loc_75AC
		add3	R0, R2,	#0xFFFF
		lduh	R4, @R7
		mul	R4, R0
		lduh	R1, @(0x3FC, R8)
		add	R4, R1
		mv	R3, R4
		remu	R4, R2
		slli	R4, #8 || nop
		divu	R3, R2
		divu	R4, R2
		srli	R4, #7
		add	R3, R4
		sth	R3, @R7
		bra.s	loc_75B4
; ---------------------------------------------------------------------------

loc_75AC:				; CODE XREF: sub_7184+3FCj
		lduh	R1, @(0x3FC, R8)
		sth	R1, @R7	|| nop

loc_75B4:				; CODE XREF: sub_7184+426j
		lduh	R4, @R7	|| nop
		bl.l	sub_36F4
		ldub	R5, @(0x934, R8)
		addi	R5, #-1	|| nop
		ld24	R1, #unk_8025A8
		add	R5, R1
		stb	R0, @R5

loc_75CC:				; CODE XREF: sub_7184+2Cj
					; sub_7184+388j
		pop	lr
		pop	R8
		jmp	lr ||\
; End of function sub_7184

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_75D4:				; CODE XREF: sub_32C8+68p
		ld24	R2, #0x100
		ldub	R0, @(8, R2)
		slli	R0, #0x1A || nop
		ld24	R3, #unk_801000
		bgez	R0, loc_7608
		ldub	R0, @(9, R3)
		or3	R0, R0,	#4
		stb	R0, @(9, R3)
		ldi8	R0, #0 || nop
		ld24	R1, #unk_8025A7
		stb	R0, @(0x928, R3)
		stb	R0, @(0x929, R3)
		stb	R0, @R1
		jmp	lr
; ---------------------------------------------------------------------------

loc_7608:				; CODE XREF: sub_75D4+10j
		ldub	R0, @(0x2F2, R3)
		cmpui	R0, #0x57 ; 'W'
		ldi8	R1, #0
		bc.s	loc_7624
		ldub	R0, @(9, R3)
		slli	R0, #0x1B || nop
		bgez	R0, loc_7624
		ldi8	R1, #1 || nop

loc_7624:				; CODE XREF: sub_75D4+3Ej sub_75D4+48j
		stb	R1, @(0x928, R3)
		ldub	R0, @(9, R3)
		ldi8	R1, #0
		slli	R0, #0x1C
		bgez	R0, loc_7638
		ldi16	R1, #0x88 ; 'ê'

loc_7638:				; CODE XREF: sub_75D4+5Cj
		ld24	R0, #unk_8025A7
		stb	R1, @(0x929, R3)
		stb	R1, @R0	|| nop
		ldub	R0, @(0x321, R3)
		stb	R0, @(0x92A, R3)
		ldub	R0, @(9, R3)
		and3	R0, R0,	#0xFB
		stb	R0, @(9, R3)
		lduh	R1, @(0x78, R3)
		lduh	R0, @(0x13BE, R2)
		cmp	R1, R0
		bc.s	loc_76A0
		ldub	R1, @(0x9B6, R3)
		ldub	R0, @(0x13C2, R2)
		cmp	R1, R0
		bc.s	loc_7698
		ldh	R1, @(0x9DC, R3)
		bltz	R1, loc_7698
		lduh	R0, @(0x13C0, R2)
		cmp	R1, R0
		bc.s	loc_7698
		ldub	R0, @(0x13C3, R2)
		stb	R0, @(0x92B, R3)
		ldub	R0, @(9, R3)
		or3	R0, R0,	#4
		stb	R0, @(9, R3)
		jmp	lr || nop
; ---------------------------------------------------------------------------

loc_7698:				; CODE XREF: sub_75D4+9Aj sub_75D4+A0j ...
		ldub	R0, @(0x92B, R3)
		beqz	R0, locret_76AC

loc_76A0:				; CODE XREF: sub_75D4+8Ej
		ldub	R0, @(9, R3)
		or3	R0, R0,	#4
		stb	R0, @(9, R3)

locret_76AC:				; CODE XREF: sub_75D4+C8j
		jmp	lr || nop
; End of function sub_75D4


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_76B0:				; CODE XREF: sub_CAA0+10p
		push	R8
		push	lr
		ld24	R8, #unk_80192B
		ldub	R4, @R8	|| nop
		bl.l	sub_37B4
		stb	R0, @R8
		pop	lr
		pop	R8
		jmp	lr
; End of function sub_76B0


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_76C8:				; CODE XREF: sub_32C8+1ACp
		push	R8
		push	R9
		push	R10
		push	R11
		push	R12
		push	lr
		ldi8	R11, #0	|| nop
		ld24	R10, #unk_801000
		ldub	R0, @(9, R10)
		and3	R0, R0,	#0xF7
		ld24	R9, #0x100
		ld24	R8, #unk_800000
		stb	R0, @(9, R10)
		ldub	R4, @(0x13C5, R9)
		bl.l	sub_7958
		sth	R0, @(0x92E, R10)
		ldub	R4, @(0x13C4, R9)
		bl.l	sub_7958
		mv	R1, R0
		srli	R0, #4
		cmpi	R0, #0x201
		sth	R1, @(0x92C, R10)
		bc.s	loc_771C || nop
		ldi16	R1, #0x200
		bra.s	loc_7720 || nop
; ---------------------------------------------------------------------------

loc_771C:				; CODE XREF: sub_76C8+48j
		srli	R1, #4 || nop

loc_7720:				; CODE XREF: sub_76C8+50j
		sth	R1, @(0x800, R10)
		ldub	R7, @(0xD, R10)
		slli	R7, #0x1E
		srli	R7, #0x1F
		add3	R5, R9,	#0x13C7
		add3	R6, R9,	#0x13C8
		add3	R4, R10, #0x9B6
		bl.l	sub_354C
		ldub	R1, @(0xD, R10)
		and3	R0, R0,	#1
		and3	R2, R0,	#1
		and3	R1, R1,	#0xFD
		slli	R2, #1
		or	R1, R2
		stb	R1, @(0xD, R10)
		beqz	R0, loc_7944
		ldub	R2, @(8, R9)
		slli	R2, #0x1A || nop
		bltz	R2, loc_7944
		ldub	R4, @(0x3D7, R10)
		beqz	R4, loc_7944
		stb	R4, @(0x934, R10)
		ldub	R5, @(9, R10)
		or3	R5, R5,	#0x20
		stb	R5, @(9, R10)
		ldub	R5, @(0xD, R10)
		or3	R0, R5,	#4
		stb	R0, @(0xD, R10)
		ldi8	R0, #0 || nop
		add3	R6, R8,	#0x420
		stb	R0, @R6
		ldub	R6, @R6
		add3	R2, R8,	#0x410
		ldi8	R0, #0xFC
		stb	R6, @R2
		add3	R1, R8,	#0x401
		stb	R0, @(0x400, R8)
		ldub	R6, @R1	|| nop
		or3	R6, R6,	#2
		stb	R6, @R1
		ldub	R5, @R1
		and3	R0, R5,	#0xFE
		stb	R0, @R1	|| nop
		add3	R1, R8,	#0xA0
		add3	R0, R10, #0x930
		sth	R1, @(0x416, R8)
		sth	R0, @(0x426, R8)
		add3	R0, R10, #0x3FE
		sth	R0, @(0x41A, R8)
		sth	R2, @(0x42A, R8)
		ldub	R0, @(0xD, R10)
		and3	R0, R0,	#0xFE
		and3	R11, R11, #1
		ldi8	R3, #1
		or	R0, R11
		stb	R0, @(0xD, R10)
		lduh	R0, @(0x800, R10)
		add3	R2, R0,	#0xFFFF
		cmpui	R0, #0x101
		stb	R2, @(0x411, R8)
		bc.s	loc_7840 || nop
		ldub	R4, @(0xD, R10)
		and3	R0, R4,	#0xFE
		and3	R4, R3,	#1
		ldi8	R1, #0xFF
		or	R0, R4
		add3	R2, R8,	#0x421
		stb	R0, @(0xD, R10)
		stb	R1, @R2
		ldub	R2, @R2
		stb	R2, @(0x411, R8)
		lduh	R1, @(0x800, R10)
		add3	R1, R1,	#0xFEFF
		and3	R1, R1,	#0xFF
		add3	R2, R10, #0x931
		cmpui	R1, #0xC
		stb	R1, @R2
		bnc.s	loc_7838
		ldi8	R0, #0xC
		stb	R0, @R2

loc_7838:				; CODE XREF: sub_76C8+16Aj
		ldi8	R0, #0x38 ; '8' || nop
		stb	R0, @(0x420, R8)

loc_7840:				; CODE XREF: sub_76C8+130j
		ldi8	R0, #0x19
		ldi8	R1, #0x48 ; 'H'
		ldi8	R2, #0x38 ; '8' || nop
		add3	R3, R8,	#0x229
		stb	R0, @(0x930, R10)
		stb	R0, @(0x410, R8)
		stb	R1, @(0x81, R8)
		stb	R2, @(0x80, R8)
		ldi8	R1, #0xF7
		stb	R1, @R3
		add3	R1, R8,	#0x22B
		ldub	R2, @R1	|| nop
		and3	R2, R2,	#0xF7
		ldi8	R0, #0
		stb	R2, @R1
		stb	R0, @R3
		ldi8	R3, #0xA
		ld	R4, @(0x3E0, R8)
		ld	R2, @(0x990, R10)
		sub	R4, R2
		mv	R0, R4
		lduh	R4, @(0x92E, R10)
		divu	R0, R3
		sub	R4, R0
		addi	R4, #-4
		bl.l	sub_36D4
		ldi8	R1, #0xF || nop
		ld24	R11, #0xFEFF
		add3	R2, R8,	#0x3BC
		sth	R0, @(0x380, R8)
		ldub	R5, @(0x934, R10)
		sth	R1, @(0x386, R8)
		add3	R1, R8,	#0x3BE
		sth	R11, @R2
		lduh	R0, @R1
		or3	R11, R0, #0x100
		ldi8	R0, #0
		sth	R11, @R1
		sth	R0, @R2
		ldi8	R0, #1
		beq	R5, R0,	loc_78C8
		ldi8	R0, #3 || nop
		bne	R5, R0,	loc_7900

loc_78C8:				; CODE XREF: sub_76C8+1F4j
		ldub	R1, @(0x934, R10)
		slli	R1, #1 || nop
		add3	R0, R10, #0x3F4
		addi	R1, #-2
		add	R1, R0
		ldub	R0, @(0x924, R10)
		lduh	R1, @R1
		mul	R1, R0
		ldub	R6, @(0x13C6, R9)
		sra3	R0, R1,	#4
		cmp	R6, R0
		bnc.s	loc_78F4
		and3	R6, R6,	#0xFF
		bra.s	loc_78F8 || nop
; ---------------------------------------------------------------------------

loc_78F4:				; CODE XREF: sub_76C8+222j
		srai	R1, #4
		mv	R6, R1

loc_78F8:				; CODE XREF: sub_76C8+228j
		stb	R6, @(0x933, R10)
		bra.s	loc_7930 || nop
; ---------------------------------------------------------------------------

loc_7900:				; CODE XREF: sub_76C8+1FCj
		slli	R5, #1 || nop
		add3	R0, R10, #0x3F4
		addi	R5, #-2
		add	R5, R0
		ldub	R0, @(0x925, R10)
		lduh	R2, @R5
		mul	R2, R0
		ldub	R1, @(0x13C6, R9)
		sra3	R4, R2,	#4
		cmp	R1, R4
		bnc.s	loc_7928
		and3	R1, R1,	#0xFF
		bra.s	loc_792C || nop
; ---------------------------------------------------------------------------

loc_7928:				; CODE XREF: sub_76C8+256j
		sra3	R1, R2,	#4

loc_792C:				; CODE XREF: sub_76C8+25Cj
		stb	R1, @(0x933, R10)

loc_7930:				; CODE XREF: sub_76C8+234j
		ld24	R2, #unk_8025B4
		ldub	R0, @(0x933, R10)
		stb	R0, @R2	|| nop
		stb	R0, @(0x932, R10)
		bra.s	loc_7948 || nop
; ---------------------------------------------------------------------------

loc_7944:				; CODE XREF: sub_76C8+8Cj sub_76C8+98j ...
		bl.s	sub_7974 || nop

loc_7948:				; CODE XREF: sub_76C8+278j
		pop	lr
		pop	R12
		pop	R11
		pop	R10
		pop	R9
		pop	R8
		jmp	lr || nop
; End of function sub_76C8


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_7958:				; CODE XREF: sub_76C8+2Cp sub_76C8+38p
		push	lr
		ld24	R0, #unk_801A60
		lduh	R0, @R0
		mul	R0, R4
		sra3	R4, R0,	#2
		bl.l	sub_3704
		and3	R0, R0,	#0xFFFF
		pop	lr
		jmp	lr
; End of function sub_7958


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_7974:				; CODE XREF: sub_76C8:loc_7944p
					; sub_C998+1Cp
		ld24	R1, #unk_801000
		ldub	R0, @(9, R1)
		and3	R0, R0,	#0xD7
		stb	R0, @(9, R1)
		ldub	R0, @(0xD, R1)
		and3	R0, R0,	#0xFB
		stb	R0, @(0xD, R1)
		ldi8	R0, #0x80 || nop
		stb	R0, @(0x817, R1)
		ldi8	R0, #0 || nop
		sth	R0, @(0x808, R1)
		sth	R0, @(0x814, R1)
		sth	R0, @(0x812, R1)
		sth	R0, @(0x802, R1)
		sth	R0, @(0x7FE, R1)
		sth	R0, @(0x810, R1)
		sth	R0, @(0x80E, R1)
		st	R0, @(0x3E8, R1)
		sth	R0, @(0x3F4, R1)
		sth	R0, @(0x3F6, R1)
		sth	R0, @(0x3F8, R1)
		sth	R0, @(0x3FA, R1)
		stb	R0, @(0x933, R1)
		stb	R0, @(0x932, R1)
		jmp	lr || nop
; End of function sub_7974


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_79D8:				; CODE XREF: sub_C998+18p
		ldi8	R0, #0x20 ; ' ' || nop
		ld24	R1, #unk_801000
		stb	R0, @(0x923, R1)
		ldub	R0, @(9, R1)
		and3	R0, R0,	#0xEF
		stb	R0, @(9, R1)
		ldi8	R0, #0 || nop
		stb	R0, @(0x816, R1)
		stb	R0, @(0x81A, R1)
		jmp	lr ||\
; End of function sub_79D8

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_7A00:				; CODE XREF: sub_CE88+8p
		addi	sp, #-0x48
		push	R8
		push	R9
		push	R10
		push	R11
		push	R12
		push	lr
		push	fp
		ld24	fp, #unk_801000
		lduh	R2, @(0x980, fp)
		ldi8	R1, #0x20 ; ' '
		srli	R2, #5
		ld24	R11, #0x100
		ldub	R0, @(0x1390, R11)
		ld24	R12, #unk_802520
		cmp	R2, R0
		bnc.s	loc_7A34
		ldub	R1, @(0x13BC, R11)
		mv	R1, R1 || nop

loc_7A34:				; CODE XREF: sub_7A00+2Aj
		add3	R0, R11, #0x1391
		add3	R10, fp, #0x923
		st	R0, @(0x58, sp)
		stb	R1, @R10 || nop
		add3	R0, fp,	#0x9B6
		ldub	R4, @R0
		addi	R4, #-0x10
		st	R0, @(0x5C, sp)
		bl.l	sub_36D4
		and3	R1, R0,	#0xFFFF
		ld24	R6, #unk_101000
		add3	R4, R11, #0x1392
		add3	R9, fp,	#0x91A
		st	R1, @(0x60, sp)
		lduh	R5, @(0x62, sp)
		bl.l	sub_35BC
		ld	R2, @(0x58, sp)
		ldub	R1, @R2
		sll	R0, R1
		sth	R0, @R9	|| nop
		ld24	R6, #unk_101000
		add3	R4, R11, #0x13A2
		add3	R8, fp,	#0x91C
		st	R2, @(0x58, sp)
		lduh	R5, @(0x62, sp)
		bl.l	sub_35BC
		ld	R2, @(0x58, sp)
		ldub	R1, @R2
		sll	R0, R1
		sth	R0, @R8
		ldub	R10, @R10
		lduh	R1, @R9	|| nop
		and3	R10, R10, #0x3F
		mul	R1, R10
		srai	R1, #5
		add3	R0, fp,	#0x91E
		sth	R1, @R0
		lduh	R1, @R8
		mul	R1, R10
		srai	R1, #5
		and3	R1, R1,	#0xFFFF
		sth	R1, @(0x920, fp)
		lduh	R0, @R0
		srli	R0, #5
		srli	R1, #5 || nop
		stb	R0, @(0x92, R12)
		stb	R1, @(0xA5, R12)
		ld	R0, @(0x5C, sp)
		ldub	R4, @R0
		addi	R4, #-0x40
		st	R2, @(0x58, sp)
		st	R0, @(0x5C, sp)
		bl.l	sub_36D4
		and3	R8, R0,	#0xFFFF
		mv	R5, R8 || nop
		ld24	R6, #unk_44000
		add3	R4, R11, #0x13B2
		bl.l	sub_35BC
		mv	R5, R8 || nop
		ld24	R6, #unk_44000
		add3	R4, R11, #0x13B6
		stb	R0, @(0x924, fp)
		bl.l	sub_35BC
		stb	R0, @(0x925, fp)
		ld	R1, @(0x5C, sp)
		ldub	R4, @R1	|| nop
		ldub	R0, @(0x13BB, R11)
		mul	R4, R0
		ldi8	R0, #0x40 ; '@'
		div	R4, R0
		bl.l	sub_36E4
		and3	R1, R0,	#0xFF
		ldub	R0, @(0x2B, fp)
		slli	R0, #0x1F || nop
		bgez	R0, loc_7B4C
		ldub	R4, @(0x13BA, R11)
		ldi8	R0, #0x10
		mul	R4, R1
		div	R4, R0
		bl.l	sub_36E4
		and3	R1, R0,	#0xFF

loc_7B4C:				; CODE XREF: sub_7A00+134j
		and3	R1, R1,	#0xFF
		stb	R1, @(0x926, fp)
		ldub	R2, @(0x932, fp)
		srl3	R0, R2,	#2
		cmpi	R0, #0x10
		stb	R1, @(0x93, R12)
		bc.s	loc_7B6C
		ldi8	R2, #0xF
		bra.s	loc_7B70 || nop
; ---------------------------------------------------------------------------

loc_7B6C:				; CODE XREF: sub_7A00+164j
		srli	R2, #2 || nop

loc_7B70:				; CODE XREF: sub_7A00+168j
		stb	R2, @(0x922, fp)
		pop	fp
		pop	lr
		pop	R12
		pop	R11
		pop	R10
		pop	R9
		pop	R8
		addi	sp, #0x48 ; 'H'
		jmp	lr ||\
; End of function sub_7A00

; ---------------------------------------------------------------------------
		.byte 0xFF
		.byte 0xFF

; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_7B88:				; DATA XREF: ROM_:000000D4o
					; ROM_:000000D8o
		push	lr
		bl.l	sub_7BA0
		pop	lr
		jmp	lr
; End of function sub_7B88


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_7B94:				; DATA XREF: ROM_:000000D0o
		push	lr
		bl.l	sub_917C
		pop	lr
		jmp	lr
; End of function sub_7B94


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_7BA0:				; CODE XREF: sub_7B88+4p
		addi	sp, #-4
		push	R8
		push	R9
		push	lr
		ld24	R8, #unk_800000
		add3	R1, sp,	#0xC
		lduh	R0, @(0x108, R8)
		sth	R0, @R1	|| nop
		ld24	R9, #unk_801000
		add3	R2, R9,	#0x1D8
		ldub	R0, @R1
		stb	R0, @R2
		ldub	R0, @(1, R1)
		stb	R0, @(0x1D7, R9)
		ldub	R2, @R2	|| nop
		and3	R0, R2,	#0x40
		beqz	R0, loc_7C00
		bl.l	sub_8524
		bl.l	sub_84F4
		add3	R0, R8,	#0x105
		ldub	R1, @R0	|| nop
		and3	R1, R1,	#0xFC
		stb	R1, @R0	|| nop
		ldub	R0, @(0x16, R9)
		and3	R0, R0,	#0xDF
		stb	R0, @(0x16, R9)
		bra.s	loc_7DA4 || nop
; ---------------------------------------------------------------------------

loc_7C00:				; CODE XREF: sub_7BA0+34j
		and3	R0, R2,	#4
		beqz	R0, loc_7CF0
		ldub	R0, @(0x105, R8)
		slli	R0, #0x1E || nop
		bnez	R0, loc_7DA4
		ldub	R0, @(0xB5, R9)
		beqz	R0, loc_7C2C
		ldub	R0, @(0x9C7, R9)
		cmpui	R0, #9
		bc.s	loc_7C2C || nop
		bl.l	sub_84F4

loc_7C2C:				; CODE XREF: sub_7BA0+78j sub_7BA0+84j
		ldub	R0, @(0xB5, R9)
		cmpui	R0, #0x90 ; 'É'
		bnc.s	loc_7CD8 || nop
		ldub	R0, @(0x16, R9)
		or3	R0, R0,	#0x40
		stb	R0, @(0x16, R9)
		add3	R0, R9,	#0xB5
		add3	R3, R9,	#0xB6
		ldub	R1, @R0
		add	R1, R3
		ldub	R2, @(0x1D7, R9)
		stb	R2, @R1
		ldub	R1, @R0
		addi	R1, #1
		stb	R1, @R0
		ldi16	R0, #0x80 ; 'Ç'
		ldub	R1, @R3	|| nop
		beq	R1, R0,	loc_7C74
		ldi8	R0, #1 || nop
		ldub	R1, @(0xB5, R9)
		beq	R1, R0,	loc_7CD8

loc_7C74:				; CODE XREF: sub_7BA0+C4j
		ldi8	R0, #0x10 || nop
		ldub	R1, @(1, R3)
		beq	R1, R0,	loc_7C8C
		ldi8	R0, #2 || nop
		ldub	R1, @(0xB5, R9)
		beq	R1, R0,	loc_7CD8

loc_7C8C:				; CODE XREF: sub_7BA0+DCj
		ldi16	R0, #0xF0 ; '='
		ldub	R1, @(2, R3)
		beq	R1, R0,	loc_7CA4
		ldi8	R0, #3 || nop
		ldub	R1, @(0xB5, R9)
		beq	R1, R0,	loc_7CD8

loc_7CA4:				; CODE XREF: sub_7BA0+F4j
		ldub	R1, @(0xB5, R9)
		cmpui	R1, #4
		bc.s	loc_7CBC || nop
		ldub	R0, @(3, R3)
		addi	R0, #4
		cmp	R0, R1
		bc.s	loc_7CCC || nop

loc_7CBC:				; CODE XREF: sub_7BA0+10Cj
		ldub	R2, @(0x1D7, R9)
		add3	R0, R9,	#0x1D6
		ldub	R1, @R0
		add	R1, R2
		stb	R1, @R0
		bra.s	loc_7CE4
; ---------------------------------------------------------------------------

loc_7CCC:				; CODE XREF: sub_7BA0+118j
		ldub	R1, @(0x1D7, R9)
		ldub	R0, @(0x1D6, R9)
		beq	R1, R0,	loc_7CE0

loc_7CD8:				; CODE XREF: sub_7BA0+94j sub_7BA0+D0j ...
		bl.l	sub_84F4
		bra.s	loc_7CE4 || nop
; ---------------------------------------------------------------------------

loc_7CE0:				; CODE XREF: sub_7BA0+134j
		bl.l	sub_837C

loc_7CE4:				; CODE XREF: sub_7BA0+12Aj
					; sub_7BA0+13Cj
		ldi8	R0, #0 || nop
		stb	R0, @(0x9C7, R9)
		bra.s	loc_7DA4 || nop
; ---------------------------------------------------------------------------

loc_7CF0:				; CODE XREF: sub_7BA0+64j
		slli	R2, #0x1E || nop
		bgez	R2, loc_7DA0
		add3	R0, R8,	#0x102
		ldub	R1, @R0	|| nop
		and3	R1, R1,	#0xFE
		stb	R1, @R0	|| nop
		add3	R0, R8,	#0x105
		ldub	R1, @R0	|| nop
		and3	R1, R1,	#0xFD
		stb	R1, @R0
		ldi8	R0, #0
		stb	R0, @(0x9C8, R9)
		ldub	R0, @(0xC, R9)
		slli	R0, #0x19 || nop
		bgez	R0, loc_7D58
		ld24	R0, #unk_801320
		ld24	R2, #0xB578
		bra.s	loc_7D3C || nop
; ---------------------------------------------------------------------------

loc_7D34:				; CODE XREF: sub_7BA0+1A2j
		ld	R1, @R2+
		st	R1, @R0
		addi	R0, #4 || nop

loc_7D3C:				; CODE XREF: sub_7BA0+190j
		ld24	R1, #0xC1FC
		cmp	R2, R1
		bc.s	loc_7D34
		ld24	R1, #unk_FFFF38
		ld24	R0, #unk_801000
		neg	R1, R1
		st	R1, @R0
		bl.l	sub_856C
		bra.s	loc_7DA4 || nop
; ---------------------------------------------------------------------------

loc_7D58:				; CODE XREF: sub_7BA0+184j
		ldi8	R3, #0 || nop
		ldi16	R0, #0xA0 ; 'á'
		add3	R2, R9,	#0x146
		ldub	R1, @(4, R2)
		beq	R1, R0,	loc_7D74
		ldi16	R0, #0xA8 ; '¿'
		bne	R1, R0,	loc_7D84

loc_7D74:				; CODE XREF: sub_7BA0+1C8j
		ldub	R2, @(5, R2)
		slli	R2, #0x1F || nop
		bgez	R2, loc_7D84
		ldi8	R3, #1 || nop

loc_7D84:				; CODE XREF: sub_7BA0+1D0j
					; sub_7BA0+1DCj
		bnez	R3, loc_7DA4
		ldub	R2, @(0x16, R9)
		and3	R2, R2,	#0xDF
		stb	R2, @(0x16, R9)
		bl.l	sub_84F4
		bl.l	sub_8524
		bra.s	loc_7DA4 || nop
; ---------------------------------------------------------------------------

loc_7DA0:				; CODE XREF: sub_7BA0+154j
		bl.s	sub_7DB0 || nop

loc_7DA4:				; CODE XREF: sub_7BA0+5Cj sub_7BA0+70j ...
		pop	lr
		pop	R9
		pop	R8
		addi	sp, #4
		jmp	lr || nop
; End of function sub_7BA0


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_7DB0:				; CODE XREF: sub_7BA0:loc_7DA0p
					; sub_88C4+84p
		push	R8
		push	lr
		ld24	R8, #unk_801000
		ldub	R0, @(0x9C9, R8)
		add3	R2, R8,	#0x1DE
		addi	R0, #4
		ldub	R1, @R2
		cmp	R1, R0
		bnc.s	loc_7E38
		ldub	R0, @(0x1D9, R8)
		bnez	R0, loc_7DD4
		bl.s	sub_7E68 || nop

loc_7DD4:				; CODE XREF: sub_7DB0+1Cj
		add3	R0, R8,	#0x1DA
		ldub	R4, @(0x1D9, R8)
		add	R4, R0 || nop
		add3	R0, R8,	#0x1DF
		add3	R2, R8,	#0x1DE
		ldub	R1, @R0
		ldub	R4, @R4
		add	R1, R4
		stb	R1, @R0
		ldub	R3, @R2
		addi	R3, #1
		and3	R3, R3,	#0xFF
		cmpui	R3, #5
		stb	R3, @R2
		bc.s	loc_7E2C
		ldi16	R0, #0xA0 ; 'á'
		ldub	R1, @(0x14A, R8)
		beq	R1, R0,	loc_7E1C
		ldi16	R0, #0xA8 ; '¿'
		beq	R1, R0,	loc_7E1C
		ldi16	R0, #0xB0 ; '¦'
		bne	R1, R0,	loc_7E2C

loc_7E1C:				; CODE XREF: sub_7DB0+58j sub_7DB0+60j
		ldub	R2, @R2
		addi	R2, #-1
		and3	R2, R2,	#3
		stb	R2, @(0x1D9, R8)
		bra.s	loc_7E5C || nop
; ---------------------------------------------------------------------------

loc_7E2C:				; CODE XREF: sub_7DB0+4Ej sub_7DB0+68j
		and3	R3, R3,	#3
		stb	R3, @(0x1D9, R8)
		bra.s	loc_7E5C || nop
; ---------------------------------------------------------------------------

loc_7E38:				; CODE XREF: sub_7DB0+16j
		ld24	R0, #unk_800105
		ldub	R1, @R0	|| nop
		and3	R1, R1,	#0xFE
		ldub	R4, @(0x1DF, R8)
		stb	R1, @R0
		ldub	R1, @R0
		or3	R1, R1,	#2
		stb	R1, @R0
		ldi8	R0, #0
		stb	R0, @R2	|| nop
		stb	R0, @(0x1D9, R8)

loc_7E5C:				; CODE XREF: sub_7DB0+78j sub_7DB0+84j
		ld24	R0, #unk_800107
		stb	R4, @R0
		pop	lr
		pop	R8
		jmp	lr
; End of function sub_7DB0


; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B	R O U T	I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


sub_7E68:				; CODE XREF: sub_7DB0+20p
		push	R8
		push	R9
		push	R10
		push	lr
		ld24	R8, #unk_801000
		add3	R1, R8,	#0x146
		mv	R3, R1
		ldi8	R5, #0
		mv	R6, R1 || nop
		ldi16	R2, #0xBF ; '+'
		ldub	R4, @(4, R1)
		bne	R4, R2,	loc_7FA4
		ldub	R2, @(0x1DE, R8)
		cmpui	R2, #4
		bnc.s	loc_7EB8
		ldi8	R0, #0x80
		ldi8	R4, #0xF0 || nop
		stb	R0, @(0x1DA, R8)
		ldi8	R9, #0x10
		ldi8	R0, #0x29 ; ')'
		stb	R4, @(0x1DB, R8)
		stb	R9, @(0x1DC, R8)
		stb	R0, @(0x1DD, R8)
		stb	R0, @(0x9C9, R8)
		bra.l	loc_8370
; ---------------------------------------------------------------------------

loc_7EB8:				; CODE XREF: sub_7E68+2Cj
		cmpui	R2, #8
		bnc.s	loc_7EE4
		ldi8	R9, #0xFF
		ld24	R1, #0x1A24
		stb	R9, @(0x1DA, R8)
		ldub	R0, @R1	|| nop
		stb	R0, @(0x1DB, R8)
		ldub	R2, @(1, R1)
		stb	R2, @(0x1DC, R8)
		ldub	R2, @(2, R1)
		stb	R2, @(0x1DD, R8)
		bra.l	loc_8370
; ---------------------------------------------------------------------------

loc_7EE4:				; CODE XREF: sub_7E68+54j
		cmpui	R2, #0xC
		bnc.s	loc_7F20 || nop
		ld24	R9, #0x1F8
		ldub	R9, @R9	|| nop
		ld24	R4, #0x1F9
		stb	R9, @(0x1DA, R8)
		ldub	R4, @R4	|| nop
		ld24	R10, #0x1FA
		stb	R4, @(0x1DB, R8)
		ldub	R10, @R10 || nop
		ld24	R1, #0x1FB
		stb	R10, @(0x1DC, R8)
		ldub	R0, @R1	|| nop
		stb	R0, @(0x1DD, R8)
		bra.l	loc_8370
; ---------------------------------------------------------------------------

loc_7F20:				; CODE XREF: sub_7E68+80j
		cmpui	R2, #0x10
		bnc.s	loc_7F54 || nop
		ld24	R3, #0x1FC
		ldub	R2, @R3	|| nop
		ld24	R1, #0x1A04
		stb	R2, @(0x1DA, R8)
		ldub	R0, @R1	|| nop
		stb	R0, @(0x1DB, R8)
		ldub	R2, @(1, R1)
		stb	R2, @(0x1DC, R8)
		ldub	R6, @(2, R1)
		stb	R6, @(0x1DD, R8)
		bra.l	loc_8370
; ---------------------------------------------------------------------------

loc_7F54:				; CODE XREF: sub_7E68+BCj
		cmpui	R2, #0x2C ; ','
		bnc.s	loc_7F94
		addi	R2, #-0xD
		ld24	R1, #0x1A04
		and3	R6, R2,	#0xFF
		mv	R3, R1
		add	R3, R6
		add3	R0, R6,	#1
		add3	R4, R6,	#2
		add	R0, R1
		ldub	R3, @R3
		stb	R3, @(0x1DA, R8)
		add	R4, R1
		ldub	R9, @R0
		stb	R9, @(0x1DB, R8)
		addi	R6, #3
		ldub	R9, @R4
		stb	R9, @(0x1DC, R8)
		add	R6, R1
		ldub	R0, @R6
		stb	R0, @(0x1DD, R8)
		bra.l	loc_8370
; ---------------------------------------------------------------------------

loc_7F94:				; CODE XREF: sub_7E68+F0j
		ld24	R10, #0x1A23
		ldub	R2, @R10 || nop
		stb	R2, @(0x1DA, R8)
		bra.l	loc_8370
; ---------------------------------------------------------------------------

loc_7FA4:				; CODE XREF: sub_7E68+20j
		ldi16	R2, #0xA0 ; 'á'
		bne	R4, R2,	loc_805C
		ldub	R1, @(0x1DE, R8)
		cmpui	R1, #4
		bnc.s	loc_7FE8
		ldi8	R0, #0x80
		stb	R0, @(0x1DA, R8)
		ldi8	R0, #0xF0 || nop
		stb	R0, @(0x1DB, R8)
		ldi8	R0, #0x10 || nop
		stb	R0, @(0x1DC, R8)
		ldub	R4, @(0x14F, R8)
		addi	R4, #2 || nop
		bl.l	sub_36E4
		and3	R0, R0,	#0xFF
		stb	R0, @(0x1DD, R8)
		stb	R0, @(0x9C9, R8)
		bra.l	loc_8370
; ---------------------------------------------------------------------------

loc_7FE8:				; CODE XREF: sub_7E68+14Cj
		ldi8	R0, #4 || nop
		bne	R1, R0,	loc_7FFC
		ldi8	R0, #0xE0 || nop
		stb	R0, @(0x1DA, R8)
		bra.l	loc_8370
; ---------------------------------------------------------------------------

loc_7FFC:				; CODE XREF: sub_7E68+184j
		ldi8	R10, #0	|| nop
		ldub	R4, @(6, R3)
		ldub	R0, @(7, R3)
		slli	R4, #0x10
		slli	R0, #8
		add	R4, R0
		mv	R9, R4
		ldub	R0, @(8, R3)
		add	R9, R0
		bra.s	loc_8040
; ---------------------------------------------------------------------------

loc_8018:				; CODE XREF: sub_7E68+1F0j
		add	R4, R9 || nop
		bl.l	sub_8544
		mv	R1, R10	|| nop
		add3	R2, R8,	#0x1DA
		add	R1, R2
		stb	R0, @R1
		add3	R0, R8,	#0xB4
		ldub	R4, @R0
		addi	R4, #1
		stb	R4, @R0	|| nop
		add3	R0, R10, #1
		and3	R10, R0, #0xFF

loc_8040:				; CODE XREF: sub_7E68+1AEj
		cmpui	R10, #4
		bnc.l	loc_8370
		ldub	R1, @(0x14F, R8)
		ldub	R4, @(0xB4, R8)
		cmp	R1, R4 || nop
		bc.l	loc_8370
		bra.s	loc_8018 || nop
; ---------------------------------------------------------------------------

loc_805C:				; CODE XREF: sub_7E68+140j
		ldi16	R0, #0xA8 ; '¿'
		bne	R4, R0,	loc_8174
		ldub	R1, @(0x1DE, R8)
		cmpui	R1, #4
		bnc.s	loc_80BC
		ldi8	R9, #0x80
		ldi8	R0, #0xF0 || nop
		stb	R9, @(0x1DA, R8)
		stb	R0, @(0x1DB, R8)
		ldi8	R0, #0x10 || nop
		stb	R0, @(0x1DC, R8)
		ldub	R4, @(0x149, R8)
		addi	R4, #-2	|| nop
		bl.l	sub_36D4
		ldi8	R4, #3 || nop
		div	R0, R4
		addi	R0, #1 || nop
		and3	R4, R0,	#0xFFFF
		cmpui	R4, #0x2F ; '/'
		bc.s	loc_80AC
		ldi8	R4, #0x2E ; '.'
		bra.s	loc_80AC || nop

loc_80AC:				; CODE XREF: sub_7E68+23Cj
		and3	R4, R4,	#0xFF
		stb	R4, @(0x1DD, R8)
		stb	R4, @(0x9C9, R8)
		bra.l	loc_8370
; ---------------------------------------------------------------------------

loc_80BC:				; CODE XREF: sub_7E68+204j
		ldi8	R0, #4 || nop
		bne	R1, R0,	loc_80D0
		ldi8	R4, #0xE8 || nop
		stb	R4, @(0x1DA, R8)
		bra.l	loc_8370
; ---------------------------------------------------------------------------

loc_80D0:				; CODE XREF: sub_7E68+258j
		ldi8	R10, #0
		bra.s	loc_8158
; ---------------------------------------------------------------------------

loc_80D4:				; CODE XREF: sub_7E68+308j
		ldi8	R3, #3 || nop
		ldub	R6, @(0xB4, R8)
		mul	R6, R3
		addi	R6, #6
		add3	R2, R8,	#0x146
		and3	R4, R6,	#0xFFFF
		mv	R0, R2
		add	R0, R4
		add3	R3, R4,	#1
		addi	R4, #2
		ldub	R9, @R0
		add	R3, R2
		slli	R9, #0x10
		add	R4, R2
		ldub	R0, @R3
		slli	R0, #8
		ldub	R4, @R4
		add	R9, R0
		add	R9, R4
		cmpui	R9, #0x100
		bnc.s	loc_8134 || nop
		ldub	R0, @(5, R2)
		and3	R3, R0,	#2
		bnez	R3, loc_8134
		and3	R6, R9,	#0xFFFF
		ld24	R2, #0x1604
		slli	R6, #2
		add	R6, R2
		add3	R0, R8,	#0x1DA
		mv	R2, R10
		ld	R9, @R6
		add	R2, R0
		ldub	R9, @R9
		stb	R9, @R2
		bra.s	loc_8148
; ---------------------------------------------------------------------------

loc_8134:				; CODE XREF: sub_7E68+2A0j
					; sub_7E68+2ACj
		mv	R4, R9 || nop
		bl.l	sub_8544
		mv	R3, R10	|| nop
		add3	R2, R8,	#0x1DA
		add	R3, R2
		stb	R0, @R3

loc_8148:				; CODE XREF: sub_7E68+2CAj
		add3	R2, R8,	#0xB4
		addi	R10, #1
		ldub	R1, @R2
		and3	R10, R10, #0xFF
		addi	R1, #1
		stb	R1, @R2

loc_8158:				; CODE XREF: sub_7E68+26Aj
		cmpui	R10, #4
		bnc.l	loc_8370
		ldub	R1, @(0x9C9, R8)
		ldub	R0, @(0xB4, R8)
		addi	R1, #-1
		cmp	R0, R1
		bnc.l	loc_8370
		bra.s	loc_80D4 || nop
; ---------------------------------------------------------------------------

loc_8174:				; CODE XREF: sub_7E68+1F8j
		ldi16	R9, #0xB0 ; '¦'
		bne	R4, R9,	loc_8224
		ldub	R1, @(0x1DE, R8)
		cmpui	R1, #4
		bnc.s	loc_81B4
		ldi8	R2, #0x80
		stb	R2, @(0x1DA, R8)
		ldi8	R2, #0xF0
		ldi8	R0, #0x10
		stb	R2, @(0x1DB, R8)
		stb	R0, @(0x1DC, R8)
		ldub	R4, @(0x149, R8)
		addi	R4, #-3	|| nop
		bl.l	sub_36D4
		and3	R0, R0,	#0xFF
		stb	R0, @(0x1DD, R8)
		stb	R0, @(0x9C9, R8)
		bra.s	loc_8370 || nop
; ---------------------------------------------------------------------------

loc_81B4:				; CODE XREF: sub_7E68+31Cj
		ldi8	R0, #4 || nop
		bne	R1, R0,	loc_81C8
		ldi8	R0, #0xF0 || nop
		stb	R0, @(0x1DA, R8)
		bra.s	loc_8370 || nop
; ---------------------------------------------------------------------------

loc_81C8:				; CODE XREF: sub_7E68+350j
		ldub	R0, @(5, R6)
		ldi8	R10, #0
		slli	R0, #0x10
		ldub	R1, @(6, R6)
		mv	R4, R0
		slli	R1, #8
		add	R4, R1
		mv	R9, R4
		ldub	R0, @(7, R6)
		add	R9, R0
		bra.s	loc_820C
; ---------------------------------------------------------------------------

loc_81E4:				; CODE XREF: sub_7E68+3BAj
		add	R4, R9 || nop
		bl.l	sub_8544
		mv	R2, R10	|| nop
		add3	R5, R8,	#0x1DA
		add3	R1, R10, #1
		add	R2, R5
		stb	R0, @R2
		add3	R0, R8,	#0xB4
		and3	R10, R1, #0xFF
		ldub	R4, @R0
		addi	R4, #1
		stb	R4, @R0	|| nop

loc_820C:				; CODE XREF: sub_7E68+37Aj
		cmpui	R10, #4
		bnc.s	loc_8370 || nop
		ldub	R0, @(0x9C9, R8)
		ldub	R4, @(0xB4, R8)
		addi	R0, #-1
		cmp	R4, R0
		bnc.s	loc_8370
		bra.s	loc_81E4
; ---------------------------------------------------------------------------

loc_8224:				; CODE XREF: sub_7E68+310j
		ldi16	R0, #0xB8 ; '+'
		and3	R9, R4,	#0xFF
		bne	R9, R0,	loc_8278
		ldub	R1, @(0x1DE, R8)
		cmpui	R1, #4
		bc.s	loc_8298
		ldi8	R1, #0xF8
		stb	R1, @(0x1DA, R8)
		ldub	R9, @(0x14B, R8)
		ldub	R4, @(0x14C, R8)
		slli	R9, #0x10
		slli	R4, #8
		ldub	R2, @(0x14D, R8)
		add	R9, R4
		add	R9, R2
		cmpui	R9, #0x100
		bnc.s	loc_826C || nop
		and3	R2, R9,	#0xFFFF
		slli	R2, #2 || nop
		ld24	R0, #0x1604
		add	R2, R0
		ld	R9, @R2

loc_826C:				; CODE XREF: sub_7E68+3F0j
		ldub	R9, @R9	|| nop
		stb	R9, @(0x1DB, R8)
		bra.s	loc_8370 || nop
; ---------------------------------------------------------------------------

loc_8278:				; CODE XREF: sub_7E68+3C4j
		ldi16	R0, #0xAF ; '»'
		bne	R4, R0,	loc_8370
		ldi8	R4, #0x11 || nop
		ldub	R1, @(5, R1)
		bne	R1, R4,	loc_8370
		ldub	R10, @(0x1DE, R8)
		cmpui	R10, #4
		bnc.s	loc_82B8 || nop

loc_8298:				; CODE XREF: sub_7E68+3D0j
		ldi8	R0, #0x80
		ldi8	R2, #0xF0
		stb	R0, @(0x1DA, R8)
		stb	R2, @(0x1DB, R8)
		ldi8	R2, #0x10
		ldi8	R0, #2
		stb	R2, @(0x1DC, R8)
		stb	R0, @(0x1DD, R8)
		stb	R0, @(0x9C9, R8)
		bra.s	loc_8370 || nop
; ---------------------------------------------------------------------------

loc_82B8:				; CODE XREF: sub_7E68+42Cj
		ldi8	R9, #0xEF || nop
		ld24	R2, #0x116
		stb	R9, @(0x1DA, R8)
		ldub	R6, @R2	|| nop
		and3	R2, R6,	#0x10
		beqz	R2, loc_8304
		ldi8	R10, #0
		bra.s	loc_82FC
; ---------------------------------------------------------------------------

loc_82D4:				; CODE XREF: sub_7E68+498j
		add3	R3, R10, #6
		add3	R0, R8,	#0x146
		add	R3, R0
		ldub	R9, @R3
		mv	R3, R10	|| nop
		ld24	R0, #0x1F8
		add	R3, R0
		ldub	R3, @R3
		beq	R9, R3,	loc_82F4
		ldi8	R5, #1 || nop

loc_82F4:				; CODE XREF: sub_7E68+484j
		add3	R4, R10, #1
		and3	R10, R4, #0xFF

loc_82FC:				; CODE XREF: sub_7E68+46Aj
		cmpui	R10, #5
		bc.s	loc_82D4 || nop

loc_8304:				; CODE XREF: sub_7E68+464j
		ldub	R2, @(0x151, R8)
		slli	R2, #0x10 || nop
		ldub	R10, @(0x152, R8)
		slli	R10, #8
		add	R2, R10
		ldub	R4, @(0x153, R8)
		mv	R6, R2
		add	R6, R4
		st	R6, @(0x1E0, R8)
		ldub	R0, @(0x38, R8)
		slli	R0, #0x1A || nop
		bgez	R0, loc_8338
		ldub	R4, @(0x17, R8)
		and3	R0, R4,	#1
		beqz	R0, loc_8344

loc_8338:				; CODE XREF: sub_7E68+4C0j
		ldi8	R1, #0x2A ; '*' || nop
		stb	R1, @(0x1DB, R8)
		bra.s	loc_8370 || nop
; ---------------------------------------------------------------------------

loc_8344:				; CODE XREF: sub_7E68+4CCj
		ld24	R0, #unk_20000
		cmpu	R0, R6
		bc.s	loc_8350
		beqz	R5, loc_835C

loc_8350:				; CODE XREF: sub_7E68+4E2j
		ldi8	R0, #0x2C ; ',' || nop
		stb	R0, @(0x1DB, R8)
		bra.s	loc_8370 || nop
; ---------------------------------------------------------------------------

loc_835C:				; CODE XREF: sub_7E68+4E4j
		ldi8	R0, #0x22 ; '"' || nop
		stb	R0, @(0x1DB, R8)
		ldub	R4, @(0xC, R8)
		or3	R0, R4,	#0x40
		stb	R0, @(0xC, R8)

loc_8370:				; CODE XREF: sub_7E68+4Cj sub_7E68+78j ...
		pop	lr
		pop	R10
		pop	R9
		pop	R8
		jmp	lr || nop
; End of function sub_7E68

