home *** CD-ROM | disk | FTP | other *** search
- page 58,132
- ; dos1fun.asm
- ; contains: dos1read(),dos1write(),dos1open(),dos1close(),dos1create()
- ; contains: dos1delete(),dos1append(),dos1rename()
- ;
- ;
- ; MODIFICATIONS
- ;
- include model.h
- include prologue.h
- include equ.h
-
- name dos1fun
- dseg dos1fu
- temp db 135 dup (0)
- endds
- pseg dos1fun
-
- ;==>-- int dos1read(table)
- ;
- ;; ARGUMENTS:
- ; (struct DISKTABLE *) table - Points to disk table
- ;
- ;; DESCRIPTION:
- ; Read sequentially the record addressed by the current block
- ; table->dskfcb.blocknum and current record table->dskfcb.fcbcr
- ; elements of the FCB into the current DTA (disk transfer address)
- ;
- ;; RETURNS:
- ; 0= read was successful, 1=EOF (no data read), 2=DTA too small
- ; 3= EOF (a partial record was read)
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc dos1read
- if _LDATA
- push ds
- lds dx,parm1_ ;ds:dx points to DISKTABLE
- else
- mov dx,parm1_ ;ds:dx points to DISKTABLE
- endif
- add dx,fcb ;ds:dx points to FCB
- mov bx,dx
- mov byte ptr [bx],0ffh ;make extended fcb
- mov ah,14h ;ms-dos sequential read function
- int 21h
- if _LDATA
- pop ds
- endif
- xor ah,ah ;return any errors in al
- cproce
-
- ;==>-- int dos1write(table)
- ;
- ;; ARGUMENTS:
- ; (struct DISKTABLE *) table - Points to disk table
- ;
- ;; DESCRIPTION:
- ; Write sequentially the record addressed by the current block
- ; table->dskfcb.blocknum and current record table->dskfcb.fcbcr
- ; elements of the FCB from the current DTA (disk transfer address)
- ;
- ;; RETURNS:
- ; 0= write was successful, 1=diskette full, 2=DTA too small
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc dos1write,,dos1writ
- if _LDATA
- push ds
- lds dx,parm1_ ;ds:dx points to DISKTABLE
- else
- mov dx,parm1_ ;ds:dx points to DISKTABLE
- endif
- add dx,fcb ;ds:dx points to FCB
- mov bx,dx
- mov byte ptr [bx],0ffh ;make extended fcb
- mov ah,15h ;ms-dos sequential write function
- int 21h
- if _LDATA
- pop ds
- endif
- xor ah,ah ;return any errors in al
- cproce
-
- ;==>-- unsigned dos1open(table)
- ;
- ;; ARGUMENTS:
- ; (struct DISKTABLE *) table - Pointer to DISKTABLE
- ;
- ;; DESCRIPTION:
- ; Dos 1.x open file. The FCB portion of the structure must contain
- ; a filename and drive code. The directory is checked, and if the
- ; file exists it is opened.
- ;
- ;; RETURNS:
- ; 0==Successful (file found), 0xFF = if Unsuccessful (not found)
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc dos1open
- if _LDATA
- push ds
- lds dx,parm1_ ;ds:dx points to DISKTABLE
- else
- mov dx,parm1_ ;ds:dx points to DISKTABLE
- endif
- add dx,fcb ;ds:dx points to FCB
- mov bx,dx
- mov byte ptr [bx],0ffh ;make extended fcb
- mov ah,0fh ;ms-dos open file function
- int 21h
- if _LDATA
- pop ds
- endif
- xor ah,ah ;return any errors in al
- cproce
-
- ;==>-- unsigned dos1close(table)
- ;
- ;; ARGUMENTS:
- ; (struct DISKTABLE *) table -
- ;
- ;; DESCRIPTION:
- ; DOS 1.x file close
- ;
- ;; RETURNS:
- ; 00=successful, FF=File not found (unsuccessful)
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc dos1close,,dos1clos
- if _LDATA
- push ds
- lds dx,parm1_ ;ds:dx points to DISKTABLE
- else
- mov dx,parm1_ ;ds:dx points to DISKTABLE
- endif
- add dx,fcb ;ds:dx points to X-FCB
- mov bx,dx
- mov byte ptr [bx],0ffh ;make extended fcb
- mov ah,10h ;ms-dos close file function
- int 21h
- if _LDATA
- pop ds
- endif
- xor ah,ah ;return any errors in al
- cproce
-
- ;==>-- unsigned dos1create(table)
- ;
- ;; ARGUMENTS:
- ; (struct DISKTABLE *) table - points to DISKTABLE structure
- ;
- ;; DESCRIPTION:
- ; DOS 1.x file create
- ;
- ;; RETURNS:
- ; Normally if successful 00, if no directory space exists
- ; return 0xFF.
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc dos1create,,dos1crea,
- if _LDATA
- push ds
- lds dx,parm1_ ;ds:dx points to DISKTABLE
- else
- mov dx,parm1_ ;ds:dx points to DISKTABLE
- endif
- add dx,fcb ;ds:dx points to X-FCB
- mov bx,dx
- mov byte ptr [bx],0ffh ;make extended fcb
- mov ah,16h ;ms-dos file create function
- int 21h
- if _LDATA
- pop ds
- endif
- xor ah,ah ;return any errors in al
- cproce
-
- ;==>-- unsigned dos1delete(table)
- ;
- ;; ARGUMENTS:
- ; (struct DISKTABLE *) table - points to DISKTABLE structure
- ;
- ;; DESCRIPTION:
- ; DOS 1.x file delete
- ;
- ;; RETURNS:
- ; 00 if successful, 0xff if directory entry match was not found
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc dos1delete,,dos1dele
- if _LDATA
- push ds
- lds dx,parm1_ ;ds:dx points to DISKTABLE
- else
- mov dx,parm1_ ;ds:dx points to DISKTABLE
- endif
- add dx,fcb ;ds:dx points to X-FCB
- mov bx,dx
- mov byte ptr [bx],0ffh ;make extended fcb
- mov ah,13h ;ms-dos file delete function
- int 21h
- if _LDATA
- pop ds
- endif
- xor ah,ah ;return any errors in al
- cproce
-
- ;==>-- unsigned dos1append(table)
- ;
- ;; ARGUMENTS:
- ; (struct DISKTABLE *) table - points to DISKTABLE structure
- ;
- ;; DESCRIPTION:
- ; Sets FCB parameters so that the random record number fcbrec is
- ; at the first byte past the end of file.
- ;
- ;; RETURNS:
- ; 0 normally, 0xff if file not found
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc dos1append,,dos1appe
- if _LDATA
- push ds
- lds bx,parm1_ ;ds:bx points to DISKTABLE
- else
- mov bx,parm1_ ;ds:bx points to DISKTABLE
- endif
- mov bx,dx
- add dx,fcb ;ds:dxpoint to X-FCB
- mov [bx+fcb],0ffh ;make extended FCB
- mov [bx+lrs],1 ;record size = 1 byte
- mov ah,23h ;determine file size
- int 21h
- if _LDATA
- pop ds
- endif
- or al,al ;check for error
- jnz do1apex ;if error exit
- add [bx+fcbrec],1 ;increment lo-order part
- adc [bx+_fcbr2],0 ;adjust hi=order part
- do1apex:xor ah,ah
- cproce
-
- ;==>-- unsigned dos1rename(from,to)
- ;
- ;; ARGUMENTS:
- ; (struct DISKTABLE *) from - existing filename
- ; (struct DISKTABLE *) to - new filename
- ;
- ;; DESCRIPTION:
- ; DOS 1.x Rename file
- ;
- ;; RETURNS:
- ; 00 normally success, 0xFF from file does not exist
- ;
- ;; AUTHOR:
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc dos1rename,,dos1rena,
- if _LDATA
- push es
- les si,parm1_ ;es:si = parm1_
- else
- mov si,parm1_
- endif
- add si,fdrive
- lea bx,temp ;bx points to temporary fcb
- mov cx,6 ;move 6 words (12 bytes)
- d1rlp1:
- if _LDATA
- mov ax,es:[si]
- else
- mov ax,[si]
- endif
- mov [bx],ax
- add bx,2
- add si,2
- loop d1rlp1
- add bx,4 ;ds:bx points to next area
- if _LDATA
- les si,parm2_
- else
- mov si,parm2_
- endif
- add si,fname
- mov cx,11 ;move 11 bytes
- dlrlp2:
- if _LDATA
- mov al,es:[si]
- else
- mov al,[si]
- endif
- mov [bx],al ;save in temp
- inc si
- inc bx
- loop dlrlp2 ;move file name to temp area
- if _LDATA
- pop es
- endif
- lea dx,temp ;ds:dx points to temporary area
- mov ah,17h ;dos rename function
- int 21h
- xor ah,ah ;return error in al
- cproce
- endps
- end
-