	SECTION _TEXT CLASS=CODE USE32
	SECTION _DATA CLASS=DATA USE32
	SECTION _BSS  CLASS=BSS USE32
	SECTION _CONST  CLASS=CONST USE32
	SECTION _STRING  CLASS=STRING USE32
	SECTION cstartup CLASS=INITDATA USE32
	SECTION crundown CLASS=EXITDATA USE32
	SECTION cppinit  CLASS=CPPINIT USE32
	SECTION cppexit  CLASS=CPPEXIT USE32
	GROUP DGROUP _DATA _BSS _CONST _STRING

SECTION _TEXT
;
; Line 10:	{
;
_wcinit:
;
; Line 11:		curparms = phidefaults;
;
	PUSH	ESI
	PUSH	EDI
	MOV	ESI,DWORD _phidefaults
	MOV	EDI,DWORD _curparms
	CLD
	MOV	ECX,02H
	REP	MOVSD
	MOVSW
	MOVSB
	POP	EDI
	POP	ESI
;
; Line 12:	}
;
	RET
;
; Line 14:	{
;
_flush:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EBX
	PUSH	ESI
	PUSH	EDI
	MOV	ESI,DWORD [EBP+0CH]
	MOV	EDI,DWORD [EBP+08H]
	MOV	EBX,DWORD _phidefaults
;
; Line 15:		if (phidefaults.size != curparms.size)
;
	MOV	AL,BYTE [EBX+00H]
	CMP	AL,BYTE [_curparms]
	JE	SHORT	L_1
;
; Line 16:			buf[i++] = 0xf0 + phidefaults.size;
;
	MOV	AL,BYTE [EBX+00H]
	ADD	AL,0F0H
	MOV	ECX,ESI
	INC	ESI
	MOV	BYTE [EDI+ECX+00H],AL
L_1:
;
; Line 17:		if (phidefaults.style != curparms.style)
;
	MOV	AL,BYTE [EBX+01H]
	CMP	AL,BYTE [01H+_curparms]
	JE	SHORT	L_3
;
; Line 18:			buf[i++] = 0xe0 + phidefaults.style;
;
	MOV	AL,BYTE [EBX+01H]
	ADD	AL,0E0H
	MOV	ECX,ESI
	INC	ESI
	MOV	BYTE [EDI+ECX+00H],AL
L_3:
;
; Line 19:		if (phidefaults.bgc != curparms.bgc)
;
	MOV	AL,BYTE [EBX+02H]
	CMP	AL,BYTE [02H+_curparms]
	JE	SHORT	L_5
;
; Line 20:			buf[i++] = 0xd0 + phidefaults.bgc;
;
	MOV	AL,BYTE [EBX+02H]
	ADD	AL,0D0H
	MOV	ECX,ESI
	INC	ESI
	MOV	BYTE [EDI+ECX+00H],AL
L_5:
;
; Line 21:		if (phidefaults.fgc != curparms.fgc)
;
	MOV	AL,BYTE [EBX+03H]
	CMP	AL,BYTE [03H+_curparms]
	JE	SHORT	L_7
;
; Line 22:			buf[i++] = 0xc0 + phidefaults.fgc;
;
	MOV	AL,BYTE [EBX+03H]
	ADD	AL,0C0H
	MOV	ECX,ESI
	INC	ESI
	MOV	BYTE [EDI+ECX+00H],AL
L_7:
;
; Line 23:		if (phidefaults.attrib != curparms.attrib)
;
	MOV	AL,BYTE [EBX+04H]
	CMP	AL,BYTE [04H+_curparms]
	JE	SHORT	L_9
;
; Line 24:			buf[i++] = 0xa0 + phidefaults.attrib;
;
	MOV	AL,BYTE [EBX+04H]
	ADD	AL,0A0H
	MOV	ECX,ESI
	INC	ESI
	MOV	BYTE [EDI+ECX+00H],AL
L_9:
;
; Line 25:		if (phidefaults.bank != curparms.bank)
;
	MOV	AL,BYTE [EBX+05H]
	CMP	AL,BYTE [05H+_curparms]
	JE	SHORT	L_11
;
; Line 26:			buf[i++] = 0x90 + phidefaults.bank;
;
	MOV	AL,BYTE [EBX+05H]
	ADD	AL,090H
	MOV	ECX,ESI
	INC	ESI
	MOV	BYTE [EDI+ECX+00H],AL
L_11:
;
; Line 27:		buf[i++] = 0;
;
	MOV	EAX,ESI
	INC	ESI
	MOV	BYTE [EDI+EAX+00H],00H
;
; Line 28:		curparms = phidefaults;
;
	PUSH	ESI
	PUSH	EDI
	LEA	ESI,[EBX+00H]
	MOV	EDI,DWORD _curparms
	CLD
	MOV	ECX,02H
	REP	MOVSD
	MOVSW
	MOVSB
	POP	EDI
	POP	ESI
;
; Line 29:		return i;
;
	MOV	EAX,ESI
L_13:
	POP	EDI
	POP	ESI
	POP	EBX
	POP	EBP
	RET
;
; Line 32:	{
;
_installphichar:
	PUSH	EBP
	MOV	EBP,ESP
	SUB	ESP,BYTE 010H
	PUSH	EBX
	PUSH	ESI
	PUSH	EDI
	MOV	ESI,DWORD [EBP+0CH]
	LEA	EDI,[EBP+0FFFFFFF0H]
	MOV	EBX,DWORD [EBP+08H]
;
; Line 34:		int rv = 0;
;
	MOV	DWORD [EBP+0FFFFFFFCH],00H
;
; Line 35:		buf = buf + i;
;
	ADD	ESI,DWORD [EBP+010H]
;
; Line 36:		newparms = curparms;
;
	PUSH	ESI
	PUSH	EDI
	MOV	ESI,DWORD _curparms
	CLD
	MOV	ECX,02H
	REP	MOVSD
	MOVSW
	MOVSB
	POP	EDI
	POP	ESI
;
; Line 37:		newparms.cwb = (char)(curchar & 0x7f);
;
	MOV	EAX,EBX
	AND	EAX,BYTE 07FH
	MOV	BYTE [EDI+06H],AL
;
; Line 38:		if (newparms.cwb >= 32) {
;
	MOVSX	EAX,BYTE [EDI+06H]
	CMP	EAX,BYTE 020H
	JL	NEAR	L_14
;
; Line 39:			newparms.size = (char )(curchar >> 28);
;
	MOV	EAX,EBX
	SAR	EAX,01CH
	MOV	BYTE [EDI+00H],AL
;
; Line 40:			newparms.style = (char)((curchar >> 24) &0x0f);
;
	MOV	EAX,EBX
	SAR	EAX,018H
	AND	EAX,BYTE 0FH
	MOV	BYTE [EDI+01H],AL
;
; Line 41:			newparms.fgc = (char)((curchar >> 20) &0x0f);
;
	MOV	EAX,EBX
	SAR	EAX,014H
	AND	EAX,BYTE 0FH
	MOV	BYTE [EDI+03H],AL
;
; Line 42:			newparms.bgc = (char)((curchar >> 16) &0x0f);
;
	MOV	EAX,EBX
	SAR	EAX,010H
	AND	EAX,BYTE 0FH
	MOV	BYTE [EDI+02H],AL
;
; Line 43:			newparms.attrib = (char)((curchar>>11) & 0x1f);
;
	MOV	EAX,EBX
	SAR	EAX,0BH
	AND	EAX,BYTE 01FH
	MOV	BYTE [EDI+04H],AL
;
; Line 44:			newparms.bank = (char)((curchar >> 7) & 0xf);
;
	MOV	EAX,EBX
	SAR	EAX,07H
	AND	EAX,BYTE 0FH
	MOV	BYTE [EDI+05H],AL
;
; Line 45:			if (newparms.size != curparms.size)
;
	MOV	AL,BYTE [EDI+00H]
	CMP	AL,BYTE [_curparms]
	JE	SHORT	L_16
;
; Line 46:				buf[rv++] = 0xf0 + newparms.size;
;
	MOV	AL,BYTE [EDI+00H]
	ADD	AL,0F0H
	MOV	ECX,DWORD [EBP+0FFFFFFFCH]
	INC	DWORD [EBP+0FFFFFFFCH]
	MOV	BYTE [ESI+ECX+00H],AL
L_16:
;
; Line 47:			if (newparms.style != curparms.style)
;
	MOV	AL,BYTE [EDI+01H]
	CMP	AL,BYTE [01H+_curparms]
	JE	SHORT	L_18
;
; Line 48:				buf[rv++] = 0xe0 + newparms.style;
;
	MOV	AL,BYTE [EDI+01H]
	ADD	AL,0E0H
	MOV	ECX,DWORD [EBP+0FFFFFFFCH]
	INC	DWORD [EBP+0FFFFFFFCH]
	MOV	BYTE [ESI+ECX+00H],AL
L_18:
;
; Line 49:			if (newparms.bgc != curparms.bgc)
;
	MOV	AL,BYTE [EDI+02H]
	CMP	AL,BYTE [02H+_curparms]
	JE	SHORT	L_20
;
; Line 50:				buf[rv++] = 0xd0 + newparms.bgc;
;
	MOV	AL,BYTE [EDI+02H]
	ADD	AL,0D0H
	MOV	ECX,DWORD [EBP+0FFFFFFFCH]
	INC	DWORD [EBP+0FFFFFFFCH]
	MOV	BYTE [ESI+ECX+00H],AL
L_20:
;
; Line 51:			if (newparms.fgc != curparms.fgc)
;
	MOV	AL,BYTE [EDI+03H]
	CMP	AL,BYTE [03H+_curparms]
	JE	SHORT	L_22
;
; Line 52:				buf[rv++] = 0xc0 + newparms.fgc;
;
	MOV	AL,BYTE [EDI+03H]
	ADD	AL,0C0H
	MOV	ECX,DWORD [EBP+0FFFFFFFCH]
	INC	DWORD [EBP+0FFFFFFFCH]
	MOV	BYTE [ESI+ECX+00H],AL
L_22:
;
; Line 53:			if (newparms.attrib != curparms.attrib)
;
	MOV	AL,BYTE [EDI+04H]
	CMP	AL,BYTE [04H+_curparms]
	JE	SHORT	L_24
;
; Line 54:				buf[rv++] = 0xa0 + newparms.attrib;
;
	MOV	AL,BYTE [EDI+04H]
	ADD	AL,0A0H
	MOV	ECX,DWORD [EBP+0FFFFFFFCH]
	INC	DWORD [EBP+0FFFFFFFCH]
	MOV	BYTE [ESI+ECX+00H],AL
L_24:
;
; Line 55:			if (newparms.bank != curparms.bank)
;
	MOV	AL,BYTE [EDI+05H]
	CMP	AL,BYTE [05H+_curparms]
	JE	SHORT	L_26
;
; Line 56:				buf[rv++] = 0x90 + newparms.bank;
;
	MOV	AL,BYTE [EDI+05H]
	ADD	AL,090H
	MOV	ECX,DWORD [EBP+0FFFFFFFCH]
	INC	DWORD [EBP+0FFFFFFFCH]
	MOV	BYTE [ESI+ECX+00H],AL
L_26:
;
; Line 57:		}
;
L_14:
;
; Line 58:		if (newparms.cwb != curparms.cwb || rv) {
;
	MOV	AL,BYTE [EDI+06H]
	CMP	AL,BYTE [06H+_curparms]
	JNE	SHORT	L_30
	CMP	DWORD [EBP+0FFFFFFFCH],BYTE 00H
	JE	SHORT	L_28
L_30:
;
; Line 59:			buf[rv++] = newparms.cwb;
;
	MOV	EAX,DWORD [EBP+0FFFFFFFCH]
	INC	DWORD [EBP+0FFFFFFFCH]
	MOV	CL,BYTE [EDI+06H]
	MOV	BYTE [ESI+EAX+00H],CL
;
; Line 60:			newparms.repsize = 1;
;
	MOV	DWORD [EDI+07H],01H
;
; Line 61:		}
;
	JMP	L_29
L_28:
;
; Line 63:			newparms.repsize++;
;
	INC	DWORD [EDI+07H]
;
; Line 64:			if (newparms.repsize == 2)
;
	CMP	DWORD [EDI+07H],BYTE 02H
	JNE	SHORT	L_31
;
; Line 65:				buf[rv++] = newparms.cwb;
;
	MOV	EAX,DWORD [EBP+0FFFFFFFCH]
	INC	DWORD [EBP+0FFFFFFFCH]
	MOV	CL,BYTE [EDI+06H]
	MOV	BYTE [ESI+EAX+00H],CL
	JMP	L_32
L_31:
;
; Line 67:				if (newparms.repsize == 3) {
;
	CMP	DWORD [EDI+07H],BYTE 03H
	JNE	SHORT	L_33
;
; Line 68:					*(buf-1) = 0x80;
;
	MOV	BYTE [ESI+00H+0FFFFFFFFH],080H
;
; Line 69:				}
;
	JMP	L_34
L_33:
;
; Line 71:					if (newparms.repsize == 19) {
;
	CMP	DWORD [EDI+07H],BYTE 013H
	JNE	SHORT	L_35
;
; Line 72:						buf[rv++] = 0x80;
;
	MOV	EAX,DWORD [EBP+0FFFFFFFCH]
	INC	DWORD [EBP+0FFFFFFFCH]
	MOV	BYTE [ESI+EAX+00H],080H
;
; Line 73:						*(buf-1) = 0x8f;
;
	MOV	BYTE [ESI+00H+0FFFFFFFFH],08FH
;
; Line 74:					}
;
	JMP	L_36
L_35:
;
; Line 76:						if (newparms.repsize == 260) {
;
	CMP	DWORD [EDI+07H],0104H
	JNE	SHORT	L_37
;
; Line 77:							*(buf-2) = 0x8f;
;
	MOV	BYTE [ESI+00H+0FFFFFFFEH],08FH
;
; Line 78:							*(buf-1) = 0x8f;
;
	MOV	BYTE [ESI+00H+0FFFFFFFFH],08FH
;
; Line 79:							buf[rv++] = 0x80;
;
	MOV	EAX,DWORD [EBP+0FFFFFFFCH]
	INC	DWORD [EBP+0FFFFFFFCH]
	MOV	BYTE [ESI+EAX+00H],080H
;
; Line 80:						}
;
	JMP	L_38
L_37:
;
; Line 81:						else if (newparms.repsize < 19) {
;
	CMP	DWORD [EDI+07H],BYTE 013H
	JGE	SHORT	L_39
;
; Line 82:							(*(buf-1))++;
;
	INC	BYTE [ESI+00H+0FFFFFFFFH]
;
; Line 83:						}
;
	JMP	L_40
L_39:
;
; Line 84:						else if (newparms.repsize < 260) {
;
	CMP	DWORD [EDI+07H],0104H
	JGE	NEAR	L_41
;
; Line 85:							(*(buf-2))++;
;
	INC	BYTE [ESI+00H+0FFFFFFFEH]
;
; Line 86:							if (*(buf-2) == 0x90) {
;
	LEA	EAX,[ESI+0FFFFFFFEH]
	MOVZX	EAX,BYTE [EAX+00H]
	CMP	EAX,090H
	JNE	SHORT	L_43
;
; Line 87:								*(buf-2) = 0x80;
;
	MOV	BYTE [ESI+00H+0FFFFFFFEH],080H
;
; Line 88:								(*(buf-1))++;
;
	INC	BYTE [ESI+00H+0FFFFFFFFH]
;
; Line 89:							}
;
L_43:
;
; Line 90:						}
;
	JMP	L_42
L_41:
;
; Line 92:							(*(buf-3))++;
;
	INC	BYTE [ESI+00H+0FFFFFFFDH]
;
; Line 93:							if (*(buf-3) == 0x90) {
;
	LEA	EAX,[ESI+0FFFFFFFDH]
	MOVZX	EAX,BYTE [EAX+00H]
	CMP	EAX,090H
	JNE	NEAR	L_45
;
; Line 94:								*(buf-3) = 0x80;
;
	MOV	BYTE [ESI+00H+0FFFFFFFDH],080H
;
; Line 95:								(*(buf-2))++;
;
	INC	BYTE [ESI+00H+0FFFFFFFEH]
;
; Line 96:								if (*(buf-2) == 0x90) {
;
	LEA	EAX,[ESI+0FFFFFFFEH]
	MOVZX	EAX,BYTE [EAX+00H]
	CMP	EAX,090H
	JNE	SHORT	L_47
;
; Line 97:									*(buf-2) = 0x80;
;
	MOV	BYTE [ESI+00H+0FFFFFFFEH],080H
;
; Line 98:									(*(buf-1))++;
;
	INC	BYTE [ESI+00H+0FFFFFFFFH]
;
; Line 99:								}
;
L_47:
;
; Line 100:							}
;
L_45:
;
; Line 101:						}
;
L_42:
L_40:
L_38:
L_36:
L_34:
L_32:
;
; Line 102:		}
;
L_29:
;
; Line 103:		if (newparms.cwb == '\n')
;
	MOVSX	EAX,BYTE [EDI+06H]
	CMP	EAX,BYTE 0AH
	JNE	NEAR	L_49
;
; Line 104:			curparms =phidefaults;
;
	PUSH	ESI
	PUSH	EDI
	MOV	ESI,DWORD _phidefaults
	MOV	EDI,DWORD _curparms
	CLD
	MOV	ECX,02H
	REP	MOVSD
	MOVSW
	MOVSB
	POP	EDI
	POP	ESI
	JMP	L_50
L_49:
;
; Line 106:			curparms = newparms;
;
	PUSH	ESI
	PUSH	EDI
	LEA	ESI,[EDI+00H]
	MOV	EDI,DWORD _curparms
	CLD
	MOV	ECX,02H
	REP	MOVSD
	MOVSW
	MOVSB
	POP	EDI
	POP	ESI
L_50:
;
; Line 107:		return(rv);
;
	MOV	EAX,DWORD [EBP+0FFFFFFFCH]
L_51:
	POP	EDI
	POP	ESI
	POP	EBX
	MOV	ESP,EBP
	POP	EBP
	RET
[GLOBAL	_wctombflush]
;
; Line 110:	{
;
_wctombflush:
	PUSH	EBP
	MOV	EBP,ESP
	SUB	ESP,BYTE 04H
	PUSH	EBX
	MOV	EBX,DWORD [EBP+08H]
;
; Line 112:		if (s)
;
	TEST	EBX,EBX
	JE	SHORT	L_52
;
; Line 114:			return flush(s,0)-1;
;
	PUSH	BYTE 00H
	PUSH	EBX
	CALL	_flush
	ADD	ESP,BYTE 08H
	DEC	EAX
	JMP	L_54
L_52:
;
; Line 116:		return 0;
;
	MOV	EAX,00H
L_54:
	POP	EBX
	MOV	ESP,EBP
	POP	EBP
	RET
[GLOBAL	_wctomb]
;
; Line 119:	{
;
_wctomb:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EBX
	PUSH	ESI
	MOV	ESI,DWORD [EBP+08H]
;
; Line 120:		int i=0;
;
	MOV	EBX,00H
;
; Line 121:		if (!s) {
;
	TEST	ESI,ESI
	JNE	NEAR	L_55
;
; Line 122:			curparms = phidefaults;
;
	PUSH	ESI
	PUSH	EDI
	MOV	ESI,DWORD _phidefaults
	MOV	EDI,DWORD _curparms
	CLD
	MOV	ECX,02H
	REP	MOVSD
	MOVSW
	MOVSB
	POP	EDI
	POP	ESI
;
; Line 123:			return 0;
;
	MOV	EAX,00H
	JMP	L_57
L_55:
;
; Line 125:		i+=installphichar(wchar,s,i);
;
	PUSH	EBX
	PUSH	ESI
	PUSH	DWORD [EBP+0CH]
	CALL	_installphichar
	ADD	ESP,BYTE 0CH
	ADD	EBX,EAX
;
; Line 126:		return i;
;
	MOV	EAX,EBX
L_57:
	POP	ESI
	POP	EBX
	POP	EBP
	RET
[GLOBAL	_wcstombs]
;
; Line 129:	{
;
_wcstombs:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EBX
	PUSH	ESI
	PUSH	EDI
	MOV	ESI,DWORD [EBP+08H]
;
; Line 130:		int i=0,j=0;
;
	MOV	EBX,00H
	MOV	EDI,00H
;
; Line 131:		if (!mbs) {
;
	TEST	ESI,ESI
	JNE	NEAR	L_58
;
; Line 132:			curparms = phidefaults;
;
	PUSH	ESI
	PUSH	EDI
	MOV	ESI,DWORD _phidefaults
	MOV	EDI,DWORD _curparms
	CLD
	MOV	ECX,02H
	REP	MOVSD
	MOVSW
	MOVSB
	POP	EDI
	POP	ESI
;
; Line 133:			return 0;
;
	MOV	EAX,00H
	JMP	L_60
L_58:
	JMP	L_61
L_63:
;
; Line 136:			i+=installphichar(pwcs[j++],mbs,i);
;
	PUSH	EBX
	PUSH	ESI
	MOV	EAX,DWORD [EBP+0CH]
	MOV	ECX,EDI
	INC	EDI
	PUSH	DWORD [EAX+ECX*4+00H]
	CALL	_installphichar
	ADD	ESP,BYTE 0CH
	ADD	EBX,EAX
L_61:
;
; Line 135:		while (j < n)
;
	CMP	EDI,DWORD [EBP+010H]
	JB	NEAR	L_63
L_62:
;
; Line 137:		return flush(mbs,i)-1;
;
	PUSH	EBX
	PUSH	ESI
	CALL	_flush
	ADD	ESP,BYTE 08H
	DEC	EAX
L_60:
	POP	EDI
	POP	ESI
	POP	EBX
	POP	EBP
	RET

SECTION _DATA

_phidefaults	DB	04H,00H,0FH,00H,00H,00H,07FH
	DD	01H
SECTION _BSS

_curparms	RESB	0BH
SECTION cstartup
	DD	_wcinit,120
