FUNCTION 15: Open File              
FUNCTION 16: Close File             
FUNCTION 17: Search for First       
FUNCTION 18: Search for Next        
FUNCTION 19: Delete File            
FUNCTION 20: Read Sequential         
FUNCTION 21: Write Sequential       
FUNCTION 22: Make File              
FUNCTION 23: Rename File            
FUNCTION 26: Set DMA Address        
FUNCTION 30: Set File Attributes    
FUNCTION 33: Read Random            
FUNCTION 34: Write Random           
FUNCTION 35: Compute File Size      
FUNCTION 36: Set random Record      
FUNCTION 40: Write Random zero fill 
FUNCTION 47: Get Current Dma Address
DIRCECTORY CODES
:FUNCTION 15:  OPEN FILE

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 0FH             | Register (A): Directory Code |
| Register (DE): FCB Address     |                              |
-----------------------------------------------------------------

     Function  to open a specified file.  The drive code,  if not 
zero, is used to select a drive. The directory is scanned for the 
first match to the filename and extent number in the fcb  pointed 
to by the register pair (DE). The filename may contain wildcards. 
A  matching directory entry is then copied into the specified fcb 
and  register  (A) is return with the directory  sector  location 
code 0 - 3 (See section on Directory Codes). If no match is found 
register (A) will contain 0FFH.
:FUNCTION 16:  CLOSE FILE

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 10H             | Register (A): Directory Code |
| Register (DE): FCB Address     |                              |
-----------------------------------------------------------------

     Function to close a specified file.  The filename and extent 
number  in  the  fcb pointed to by the  register  pair  (DE)  are 
located in the directory. The file name may contain wildcards. If 
they are found,  the record count and data map from the specified 
fcb  are  copied  into  the directory  entry  and  the  directory 
location code 0 - 3 is returned in register (A).  If the filename 
can not be found 0FFH is returned in register (A).
:FUNCTION 17:  SEARCH FOR FIRST

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 11H             | Register (A): Directory Code |
| Register (DE): FCB Address     |                              |
-----------------------------------------------------------------

     Function to return the first occurrence of a specified  file 
name.  The directory of the default drive is scanned for an entry 
that matches the filename and extent number in the fcb pointed to 
by the register pair (DE). The filename may contain wildcards. If 
a  match is found,  the directory location code 0 - 3 is returned 
in  register  (A).  If  no match is found  0FFH  is  returned  in 
register (A).  If the extent number contains 00H,  only the first 
extent for a file can be matched. If the extent number contains a 
question  mark,  the first entry found is returned.  If the drive 
number  of  the  specified fcb  contains  a  question  mark,  all 
directory  entries  of  any user code,  and entries of  any  type 
including those not in use, are compared.  
:FUNCTION 18:  SEARCH FOR NEXT

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 12H             | Register (A): Directory Code |
| Register (DE): FCB Address     |                              |
-----------------------------------------------------------------

     Function to return the next occurrence of a file name.  This 
function performs the same as function 17 except that the  search 
begins  with  the  entry following the one returned by  the  last 
search (function 17 or 18).  For this function to work  correctly 
it must be proceeded by a search function.
:FUNCTION 19:  DELETE FILE

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 13H             | Register (A): Directory Code |
| Register (DE): FCB Address     |                              |
-----------------------------------------------------------------

     Function to delete a file by name.  The drive code,  if  not 
zero, is used to select a drive. The directory is scanned for all 
entries   that  match  the  given  filename  (which  may  contain 
wildcards). Only files in the active user area are considered.
:FUNCTION 20:  READ SEQUENTIAL

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 14H             | Register (A): Directory Code |
| Register (DE): FCB Address     |                              |
-----------------------------------------------------------------

     Function  to  execute  a sequential read  of  the  specified 
record number.  The drive code,  if not zero, is used to select a 
drive. The 128-byte record referenced to by the (cr) byte is read 
and  placed  into  the current file  buffer.  The  (cr)  byte  is 
incremented.  If it then equals the (rc) byte,  the entire extent 
has  bee read;  the directory entry describing the next extent of 
the file is copied into the FCB and (cr( is zeroed.  If there are 
no further extents the extent map in the referenced fcb is set to 
zero.   If  the  record is successfully  read,  register  (A)  is 
returned containing 00H.  If an end of file occurs,  register (A) 
is returned containing 0FFH.  The format of the referenced fcb is 
shown below:



         0    1   -   8   9   -   B   C    D    E    F
       --------------------------------------------------
       | dr | filename  | filetype  | ex | s1 | s2 | rc |  
       --------------------------------------------------
       |                    extent map                  |
       --------------------------------------------------
       | cr |         |
       ----------------

                          FCB format
:FUNCTION 21:  WRITE SEQUENTIAL

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 15H             | Register (A): Directory Code |
| Register (DE): FCB Address     |                              |
-----------------------------------------------------------------

     Function to write the next sequential record. The drive code 
if  not zero,  is used to select a drive.  If no block  has  been 
allocated to the record referenced by (cr) of this extent, one is 
allocated  and entered in the bit map.  The record in the current 
file buffer is written into the position referenced by (cr).  The 
FCB  bytes (cr) and (rc) are then incremented.  If the extent  is 
then  full,  the FCB is copied into the matching directory  entry 
and  a new entry is made for the next extent,  the (cr) and  (rc) 
bytes  are reset to zero as is the data map area of the  FCB.  If 
the  write  was  successful,  00H is  returned  in  register  (A) 
otherwise a none zero value is returned.  
:FUNCTION 22:  MAKE FILE

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 16H             | Register (A): Directory Code |
| Register (DE): FCB Address     |                              |
-----------------------------------------------------------------

     Function to create a file.  A directory entry is created for 
the  filename  specified by the fcb pointed to by  register  pair 
(DE). The newly created entry will contain a pointer to the first 
extent  but with no space allocated to it.  Upon return  register 
(A)  will  contain  the Directory Code for the  new  fcb  if  the 
operation  was  successful or 0FFH if no more directory space  is 
available.  A successfully created file can be treated as open.
:FUNCTION 23:  RENAME FILE

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 17H             | Register (A): Directory Code |
| Register (DE): FCB Address     |                              |
-----------------------------------------------------------------

     Function  to rename a file.  The drive code if not zero,  is 
used to select a drive.  The directory is scanned and all entries 
for  the  explicit  filename in bytes 01H - 0BH of  the  fcb  are 
changed to that in bytes 11H - 1BH. If no such directory entry is 
found,  0FFH is returned in register (A) else the Directory  Code 
is returned in register (A).
:FUNCTION 26:  SET DMA ADDRESS

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 1AH             | Register (DE): DMA Address   |
-----------------------------------------------------------------

     Function  to set the dma address to the address supplied  in 
the register pair (DE). The Direct Memory Address used to address 
a  128 byte file buffer for disk read/write transfers is  set  to 
the address specified in the register pair (DE).  The default DMA 
address used by ZRDOS is 0080H.
:FUNCTION 30:  SET FILE ATTRIBUTES

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 1EH             | Register (A): Directory Code |
| Register (DE): FCB Address     |                              |
-----------------------------------------------------------------

     Function  to set the file attributes.  The attributes  f1-f4 
can  be  used by the user for any purpose.  The  next  three  are 
reserved  for  future  use.  Attribute t1 is the File  Read  Only 
attribute  and is used to prevent a file from being  written  to. 
The  t2 attribute is the system attribute it alerts the ZCPR3 DIR 
command that this file is not to be displayed.  The t3  attribute 
is  the file archive attribute and is used to indicate whether  a 
file has been updated.  Attributes are set by turning on the high 
order bit of the specified byte and reset by turning it off.  The 
f8  attribute is the Wheel Protect attribute.  If this bit is set 
and  the ZCPR3 Wheel byte is off the file can not be  written  to 
nor  can the file's attributes be changed.  If the Wheel byte  is 
set the file is treated as any other file.




 Attribute         User Defined  Reserved   W/P R/O SYS ARChive
                     _____|_____ ___|___    /   /   /  /
                     |         | |     |   /   /   /  /
 Attribute           f1 f2 f3 f4 f5 f6 f7 f8  t1  t2  t3
                ------------------------------------------
 FCB Byte No.   | 0 | 1  2  3  4  5  6  7  8 | 9  10  11 |
                |---|------------------------|-----------|
                |drv|        filename        | extension |

                       File Attribute Format.
:FUNCTION 33:  READ RANDOM

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 21H             | Register (A): Return Code    |
| Register (DE): FCB Address     |                              |
-----------------------------------------------------------------

     Function to read a random record from a file. The 'r0', 'r1' 
and 'r2' bytes used to construct the fcb pointer to the specified 
record  number (see fig. 4-6 on next page).  Unlike a  sequential 
read operation,  the record number is not advanced.  Thus, if the 
calling  program does not increment the record number  subsequent 
random read operations will continue to read the same record.    

     As each random read operation automatically sets the  extent 
and  record  values into the specified fcb the file can  then  be 
sequentially  read  or  written,   starting  from  the  currently 
accessed position.




     Upon  return  from  a  random read  operation  register  (A) 
contains  00H  if  the  operation was a success  or  one  of  the 
following error codes:

                   01 - Reading unwritten data 
                   03 - Cannot close current extent
                   04 - Seek to unwritten extent
                   06 - Seek past physical end of disk
:FUNCTION 34:  WRITE RANDOM

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 21H             | Register (A): Return Code    |
| Register (DE): FCB Address     |                              |
-----------------------------------------------------------------

     Function to write a random record to a file.  This operation 
is  similar  to the Read Random operation,  except that  data  is 
written  to the specified record from the currently  defined  DMA 
address.  If  the  addressed  extent or record has not  yet  been 
allocated,  an automatic allocation will be performed before  the 
data is written.








     Upon  return register (A) contains 00H if the operation  was 
successful or an error code if not.  The error codes are the same 
as  those returned for a Random Read operation with the  addition 
of the following code:

                     05 - Directory Overflow

     For random R/W, the fcb for the desired record number is set 
per  the  'r0,r1,r2' bytes.  These bytes in the fcb are  used  as 
follows:
	       fcb+35            fcb+34            fcb+33
	 _______________________________________________________
 Byte	 |       r2        |       r1        |       r0        |
	 |-----------------|-----------------|-----------------|
 Bit #   | 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 |
	 |_________________|_________________|_________________|
	 |                 | extra  |           |              |
	 |    overflow     | extent |  extent   |    record    |
	 |                 |and 's2'|  number   |    number    |
	 |_________________|________|___________|______________|

                Use of FCB bytes 'r0','r1' and 'r2'.
:FUNCTION 35:  COMPUTE FILE SIZE

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 23H             | Random Record Field Set      |
| Register (DE): FCB Address     |                              |
-----------------------------------------------------------------

     Function to compute the size of a random file. The directory 
is  scanned  to find the highest numbered extent of the  filename  
in the fcb specified by register pair (DE). The direct address of 
the specified file's last record,  plus one, is set in the record 
address field of the specified fcb.
:FUNCTION 36:  SET RANDOM RECORD

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 24H             | Random Record Field Set      |
| Register (DE): FCB Address     |                              |
-----------------------------------------------------------------

     Function  to  return the random record position of  a  given 
file which has been read in sequential mode up to now. The extent 
number and current record number of the fcb specified by register 
pair  (DE) are used to calculate the direct address of the record 
returned by the last sequential read operation. 
:FUNCTION 40:  WRITE RANDOM WITH ZERO FILL

-----------------------------------------------------------------
|       Entry Parameters         |       Returned Value         |
|--------------------------------|------------------------------|
| Register  (C): 28H             | Register (A): Return Code    |
| Register (DE): FCB Address     |                              |
-----------------------------------------------------------------

     Function to write random records with zero fill. When Direct 
Access  Write  (Function 34) is used to build a  file,  unwritten 
records within an allocation block contain unpredictable garbage. 
This  request fills the unwritten records of each new block  with 
binary zeros.
:FUNCTION 47:  RETURN CURRENT DMA ADDRESS

-----------------------------------------------------------------
|       Entry Parameters        |        Returned Value         |
|-------------------------------|-------------------------------|
| Register  (C): 2FH            | Register (HL): DMA Address    |
-----------------------------------------------------------------

     Function to return the current DMA Address.
:DIRECTORY CODES


Many  of the ZRDOS functions return a directory code as a  return 
parameter. The Directory Code is actually a multiplier to be used 
in  determining the directory entry location in the default  file 
buffer. The default buffer (location 80H) contains 128 bytes (one 
sector) of  the directory entries read off of the specified disk. 
There are four 32 byte directory entries to a sector of directory 
information.  The returned Directory Code points to one of  these 
entries.  The  specified  entry can be found by  multiplying  the 
Directory  Code times 32 and adding this offset to the  beginning 
address  of the default buffer (80H).  Below is shown a hex ASCII 
image  of  a  typical directory sector loaded  into  the  default 
buffer:








 DEFAULT BUFFER ADDRESS
      /
     /               HEX IMAGE                  ASCII IMAGE
    /                    |                           |
  _/     ________________|_________________    ______|_______  
 /  \   /                                  \  /              \ 
 0080   00444454 20202020  20434F4D 00000026  .DDT     COM...&
 0090   07000000 00000000  00000000 00000000  ................
 00A0   00454449 54202020  20434F4D 0000004C  .EDIT    COM...L
 00B0   0A0B0000 00000000  00000000 00000000  ................
 00C0   00474F54 4F202020  20434F4D 00000006  .GOTO    COM....
 00D0   91000000 00000000  00000000 00000000  ................
 00E0   0048454C 4C4F2020  20202020 00000009  .HELLO      ....
 00F0   3D000000 00000000  00000000 00000000  =...............
        
               Fig. 5-1: Example Directory Sector.


The  Directory  code for the directory entry EDIT.COM  is  1.  So 
multiplying  the  directory code by 32 gives us  32  decimal.  32 
decimal is 20 hex. Adding 20 hex to 80 hex gives us A0 hex.
