;
;		ish file converter for MS-DOS  Ver 2.00 (90/3/27)
;
;
;		Copyright (c) 1986, 1987, 1989, 1990  by  M. ishizuka
;		All rights reserved.
;
;
;		Usage:  A>ish filename [{/r|/a|/q|/s [{8|7|s|n}]|/o}]
;			     [/m [path]] [/c [path]] [/9 [path]]
;			     [/u [path]] [/? [path]] [/* [path]]
;			     [/ma [path]] [/l] [{/n|/e}] [/t [num]] [/lf]
;			     [/p char[char[...]]] [/kp] [/mt num] [/nv]
;			     [/it] [/qu]
;
;		Caution: /l is a dummy switch for compatibility
;			    of old versions.
;
;			 /x is reserved for Rish.
;
;			 /a is the same as /r.
;
;

;-----------------------------------------------;
;						;
;	include macros and constants		;
;						;
;-----------------------------------------------;

.xlist
include	ish.h
include	default.h
include	masm.h
include	v30.h
include	crc.h
include	int21.h
include	display.h
include	ishsub.h
include	makeish.h
include	makehsi.h
include	decode.h
include multivol.h
include	timezone.h
.list

;-----------------------------------------------;
;						;
;	assembler control			;
;						;
;-----------------------------------------------;

cseg		segment	word
		assume	cs:cseg, ds:cseg, es:cseg, ss:cseg

		org	0
base		equ	$

		org	2ch
ENV_SEG		equ	$



;-----------------------------------------------;
;						;
;	main program				;
;						;
;-----------------------------------------------;

		org	100h
start:		@@set_int_23h
		@@display	msg_start
		@@check_stack
		mov	sp, offset end_of_stack
		@@allocate_memory_and_set_buffer_seg
		@@get_dos_version
		@@get_file_name
		mov	word ptr save_pathname_2, si ; input filename pointer
		@@skip_file_name
		@@get_parameter
		cmp	word ptr save_pathname_2, di ; if no parameters 
		jnz	check_stdin_skip
		@@check_stdin			     ;  then check_stdin.
check_stdin_skip:
		@@check_stdout
		@@check_parameter
		@@disp_start_msg
		@@check_prefix
		@@get_tz
		@@set_shell_name
		@@disp_and_set_stdout
		mov	ax, word ptr mv_num
		mov	word ptr mv_num_save, ax
expand_wildcards:
		mov	sp, offset end_of_stack
		call	init_constants
		@@init_constants2
		cmp	byte ptr stdin, 0
		jnz	skip_open
		@@expand_wildcards
		jc	normal_end
		mov	dx, offset save_input_filename
		@@disp_input_fname
		@@open_input_file_and_get_file_size
		jmp	check_cpu

skip_open:	@@display	msg_stdin
check_cpu:	@@check_cpu_and_patch
		cmp	mode, 'r'		; restore
		jz	make_hsi
		cmp	mode, 'q'		; restore with question
		jz	make_hsi
make_ish:	mov	si, word ptr save_input_filename_without_path
		@@make_ish_main
		@@display	msg_normal_end
		inc	word ptr store_count
go_next:	mov	ax, word ptr mv_num_save
		mov	word ptr mv_num, ax
		@@all_close
		cmp	byte ptr stdin, 0
		jz	expand_wildcards
normal_end:	call	end_msg
		mov	ax, 4c00h
		int	21h

make_hsi:	@@display	msg_crlf
.lall
		@@make_hsi_main			; loop forever

include	ishsub.asm
include	errors.asm
include	emulate.asm
include	makehsi.asm
include	encode.asm
include	makeish.asm
include filename.asm
include crc32.asm
include int21.asm
include	timezone.asm

		@@int_23h_handler		; int 23h handler

include	crc.dat
include	crc32.dat
include	encdec.dat
include	formpara.dat
include	errors.dat
include	emulate.dat
include	msg.dat
include	path.dat
include	misc.dat
include idblock.dat
include	work.dat

		even
		dw	128d dup(?)	; stack area
end_of_stack	equ	$

end_of_stack_para equ	(offset end_of_stack - offset base + 15) / 16

read_buffer_seg	equ	(offset read_buffer - offset base) / 16

write_buffer_seg equ	(offset write_buffer - offset base) / 16

cseg		ends

		end	start
