;
;		ish file converter for MS-DOS  Ver 2.00 (90/3/27)
;
;
;		Copyright (c) 1986, 1987, 1989, 1990  by  M. ishizuka
;		All rights reserved.
;



;-----------------------------------------------;
;						;
;	check_filename				;
;						;
;	INPUT :	si(filename pointer)		;
;	OUTPUT:	NON				;
;	ERROR :	NON				;
;	BREAK :	flags				;
;						;
;-----------------------------------------------;

check_filename:	push	ax
		push	cx
		push	si
		mov	cx, 11d
check_loop:	lodsb
		cmp	al, ' '
		jb	subst_char
		jz	fill_space
		cmp	al, '"'
		jz	subst_char
		cmp	al, '*'
		jb	check_next
		cmp	al, '-'
		jb	subst_char
		cmp	al, '.'
		jb	check_next
		cmp	al, '0'
		jb	subst_char
		cmp	al, ':'
		jb	check_next
		cmp	al, '@'
		jb	subst_char
		cmp	al, '['
		jb	check_next
		cmp	al, '^'
		jb	subst_char
		cmp	al, '|'
		jz	subst_char
		cmp	al, 7fh
		jb	check_next
		cmp	al, 81h
		jb	subst_char
		cmp	al, 0a0h
		jb	check_kanji
		jz	subst_char
		cmp	al, 0e0h
		jb	check_next
		cmp	al, 0ebh
		jb	check_kanji
subst_char:	mov	byte ptr [si-1], '_'
check_next:	loop	check_loop
check_ret:	pop	si
		pop	cx
		pop	ax
		ret

fill_space:	cmp	cl, 11d
		jnz	fill_space_loop
		mov	byte ptr [si-1], '_'
		inc	si
		dec	cl
fill_space_loop:
		mov	byte ptr [si-1], ' '
		cmp	cl, 4
		jz	check_next
		loop	fill_space_loop
		jmp	check_ret

check_kanji:	cmp	cl, 4
		jz	subst_char
		cmp	cl, 1
		jz	subst_char
		dec	cl
		lodsb
		cmp	al, '@'
		jb	subst_double_char
		cmp	al, '\'
		jz	subst_double_char
		cmp	al, '|'
		jz	subst_double_char
		cmp	al, 7fh
		jz	subst_double_char
		cmp	al, 0fdh
		jb	check_next
subst_double_char:
		mov	word ptr [si-2], '__'
		jmp	check_next
