
enum { F_READ, F_WRITE, F_READWRITE };

#define  FA_NORMAL     0x00
#define  FA_READONLY   0x01
#define  FA_HIDDEN     0x02
#define  FA_SYSTEM     0x04
#define  FA_VOLUME     0x08
#define  FA_DIRECTORY  0x10
#define  FA_ARCHIVE    0x20

#define  STDIN    0
#define  STDOUT   1
#define  STDERR   2
#define  STDAUX   3
#define  STDPRN   4

#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2


// word OPEN(word filename,byte mode)
:word fastcall OPEN(DX,AL)
{
	AH = 3Dh;
	$int 21h
	IF(CARRYFLAG) AX = 0;
}

:word fastcall CREATE(DX,CX)
{
	AH = 3Ch;
	$int 21h
	IF(CARRYFLAG) AX = 0;
}

// word READ(word handle,word offset,word length)
:word fastcall READ(BX,DX,CX)
{
	AH = 3Fh;
	$int 21h
	IF(CARRYFLAG) AX = 0;
}

// word WRITE(word handle, word offset, word length)
:word fastcall WRITE(BX,DX,CX)
{
	AH = 40h;
	$int 21h
	IF(CARRYFLAG) AX = 0;
}
	
// (d)word FILESIZE(word handle)
:word fastcall FILESIZE(BX)
{
	CX = 0;
	DX = 0;
	AX = 4202h;
	$int 21h
}

:word fastcall LSEEK(BX)
{
	AX = 4200h;
	$int 21h
}

:word fastcall CLOSE(BX)
{
	AH = 3Eh;
	$int 21h
}

:word fastcall FINDFIRSTFILE(DX,CX)
{
	AH = 4Eh;
	$int 21h
//	IF(CARRYFLAG) AX = 0;
}

:byte fastcall FILEEXIST(DX)
{
	FINDFIRSTFILE(DX,FA_NORMAL);
	IF(CARRYFLAG) return FALSE;
	ELSE return TRUE;
}

:byte fastcall TRUENAME(SI,DI)
{
	$push es
	ES = DS;
	AH = 60h;
	$int 21h
	$pop es
	AX = 1;
	IF(CARRYFLAG) AX = 0;
//	ELSE AX = DI;
}