(************************************************************************
*                                                                       *
*       Atari Support for the new Single Pass Compiler                  *
*                                                                       *
*       Version:  m1pc                                                  *
*                                                                       *
*       M.Jetter    20/02/87    v0.1                                    *
*                                                                       *
************************************************************************)


DEFINITION MODULE GEMDOS;

FROM SYSTEM IMPORT ADDRESS ;

CONST

  (* BIOS error codes *)
  EOK           =   0 ;
  Error         =  -1 ;
  EDrvNR        =  -2 ;         (* Drive not ready *)
  EUnCmd        =  -3 ;         (* Unknown command *)
  ECRC          =  -4 ;         (* CRC error *)
  EBadRq        =  -5 ;         (* Bad request *)
  ESeek         =  -6 ;         (* Seek error *)
  EMedia        =  -7 ;         (* Unknown media *)
  ESecNF        =  -8 ;         (* Sector not found *)
  EPaper        =  -9 ;         (* No paper *)
  EWritF        = -10 ;         (* Write fault *)
  EReadF        = -11 ;         (* Read fault *)
  EGenrl        = -12 ;         (* General error *)
  EWrPro        = -13 ;         (* Write protect *)
  EChng         = -14 ;         (* Media change *)
  EUnDev        = -15 ;         (* Unknown device *)
  EBadSF        = -16 ;         (* Bad sectors on format *)
  EOther        = -17 ;         (* Insert other disk *)

  (* BDOS Error codes *)
  EInvFN        = -32 ;         (* Invalid function number *)
  EFilNF        = -33 ;         (* File not found *)
  EPthNF        = -34 ;         (* Path not found *)
  ENHndl        = -35 ;         (* No handles left *)
  EAccDn        = -36 ;         (* Access denied *)
  EIHndl        = -37 ;         (* Invalid handle *)
  ENSMem        = -39 ;         (* Insufficient memory *)
  EIMBA         = -40 ;         (* Invalid memory block address *)
  EDrive        = -46 ;         (* Invaild drive specified *)
  ENMFil        = -49 ;         (* No more files *)

  (* Other errors *)
  ERange        = -64 ;         (* Range error *)
  EIntrn        = -65 ;         (* Internal error *)
  EPLFmt        = -66 ;         (* Invalid program load format *)
  EGSBF         = -67 ;         (* Setblock failure due to growth restr *)

TYPE

  IOMode   = ( read, write ) ;
  SeekMode = ( beginning, relative, end ) ;
  ExecMode = ( loadExecute, resrvd1, resrvd2, load ) ;
  SetOrGet = ( set, get ) ;

  DiskInfoBuffer = RECORD 
                     freeSpace   : LONGINT ; (* in clusters *)
                     clusters    : LONGINT ; (* num on disk *)
                     sectorSize  : LONGINT ; (* in bytes *)
                     clusterSize : LONGINT ; (* sectors per cluster *)
                   END ;


VAR   ErrorNo   :    INTEGER;      (* the return code of the last system *) 
                                   (* call (perhaps an error code)       *)
                                 
PROCEDURE OldTerm () ;
(* Terminate process (old version) *)

PROCEDURE ConIn ( VAR Ch : CHAR ) ;
(* Read character from standard input *)

PROCEDURE ConScanIn ( VAR Ch, Scan : CHAR ) ;
(* Read character and scan code from standard input *)

PROCEDURE ConOut ( Ch : CHAR ) ;
(* Write character to standard output *)

PROCEDURE AuxIn ( VAR Ch : CHAR ) ;
(* Read character from auxiliary port *)

PROCEDURE AuxOut ( Ch : CHAR ) ;
(* Write character to auxiliary port *)

PROCEDURE PrnOut ( Ch : CHAR ) ;
(* Write character to printer port *)

PROCEDURE RawIO ( VAR Ch : CHAR ; Mode : IOMode ) ;
(* Raw IO to standard input/output device *)

PROCEDURE RawIn ( VAR Ch : CHAR ) ;
(* Raw input from standard input *)

PROCEDURE RawScanIn ( VAR Ch, Scan : CHAR ) ;
(* Raw inpput of character and scan code from standard input *)

PROCEDURE NecIn ( VAR Ch : CHAR ) ;
(* Read character from standard input with no echo *)

PROCEDURE ConWS ( String : ARRAY OF CHAR ) ;
(* Write null terminated string to standard output device *)

PROCEDURE ConRS ( VAR String : ARRAY OF CHAR ) ;
(* Read edited string from standard input device *)

PROCEDURE ConIS () : BOOLEAN ;
(* Return status of standard input *)

PROCEDURE SetDrv ( Drive : CARDINAL ; VAR DriveMap : LONGINT ) ;
(* Set default drive *)

PROCEDURE ConOS () : BOOLEAN ;
(* Return output status of standard output *)

PROCEDURE PrnOS () : BOOLEAN ;
(* Return output status of standard printer *)

PROCEDURE AuxIS () : BOOLEAN ;
(* Return status of standard auxiliary *)

PROCEDURE AuxOS () : BOOLEAN ;
(* Return output status of standard auxiliary *)

PROCEDURE GetDrv ( VAR Drive : CARDINAL ) ;
(* Get default drive *)

PROCEDURE SetDTA ( Address : ADDRESS ) ;
(* Set disk transfer address *)

PROCEDURE GetDate ( VAR Date : CARDINAL ) ;
(* Get Date *)

PROCEDURE SetDate ( Date : CARDINAL ) ;
(* Set Date *)

PROCEDURE GetTime ( VAR Time : CARDINAL ) ;
(* Get Date *)

PROCEDURE SetTime ( Time : CARDINAL ) ;
(* Set Date *)

PROCEDURE GetDTA ( VAR Addr : ADDRESS ) ;
(* Get disk transfer address *)

PROCEDURE Version ( VAR Ver : CARDINAL ) ;
(* Get version number *)

PROCEDURE TermRes ( NumBytes : LONGINT ; ExitCode : CARDINAL ) ;
(* Terminate and stay resident *)

PROCEDURE DFree (VAR InfoBuffer : DiskInfoBuffer ; Drive : CARDINAL ) ;
(* Get drive free space *)

PROCEDURE DirCreate ( Path : ARRAY OF CHAR ) : BOOLEAN ;
(* Create a subdirectory *)

PROCEDURE DirDelete ( Path : ARRAY OF CHAR ) : BOOLEAN;
(* Delete a subdirectory *)

PROCEDURE SetPath ( Path : ARRAY OF CHAR ) : BOOLEAN ;
(* Set current directory *)

PROCEDURE Create ( Name : ARRAY OF CHAR ; Attr : CARDINAL ; 
                   VAR Handle : INTEGER  ) ;
(* Create a file *)

PROCEDURE Open ( Name : ARRAY OF CHAR ; Mode : CARDINAL ;
                 VAR Handle : INTEGER ) ;
(* Open a file *)

PROCEDURE Close ( Handle : INTEGER ) : BOOLEAN ;
(* Close a file *)

PROCEDURE Read ( Handle : INTEGER ; VAR Count : LONGINT ; Buffer: ADDRESS);
(* Read file *)

PROCEDURE Write ( Handle : INTEGER ; VAR Count: LONGINT ; Buffer: ADDRESS);
(* Write file *)

PROCEDURE Delete ( Name : ARRAY OF CHAR ) : BOOLEAN ;
(* Delete file *)

PROCEDURE Seek ( Offset : LONGINT ; Handle : INTEGER ; Mode : SeekMode ;
                 VAR Position : LONGINT ) ;
(* Seek file pointer *)


PROCEDURE Attrib ( Name : ARRAY OF CHAR ; Which : SetOrGet ; 
                   VAR Attr : CARDINAL ) ;
(* Get/Set file attributes *)

PROCEDURE GetPath ( VAR PathName : ARRAY OF CHAR ; Drive : CARDINAL ) ;
(* Get current directory *)

PROCEDURE Alloc ( Bytes : LONGINT ; VAR Addr : ADDRESS ) ;
(* Allocate memory *)

PROCEDURE Free ( Addr : ADDRESS ) : BOOLEAN ;
(* Free memory *)

PROCEDURE Shrink ( Addr : ADDRESS ; NewSize : LONGINT ) : BOOLEAN ;
(* Shrink size of allocated memory *)

PROCEDURE Exec ( Mode : ExecMode ; Name : ARRAY OF CHAR ; 
                 Tail : ARRAY OF CHAR ; EnvStr : ARRAY OF CHAR ;
                 VAR Result : INTEGER ) ;
(* Load or execute a process *)

PROCEDURE Term ( Code : INTEGER ) : BOOLEAN ;
(* Terminate a process *)

PROCEDURE SFirst ( Name : ARRAY OF CHAR ; Attr : CARDINAL ;
                   VAR Result : INTEGER ) ;
(* Search for first file *)

PROCEDURE SNext ( VAR Result : INTEGER ) ;
(* Search for next file *)

PROCEDURE Rename ( CurrentName, NewName : ARRAY OF CHAR ) ;
(* Rename a file *)

PROCEDURE DaTime ( Handle : INTEGER ; Buffer : ADDRESS ; Which : SetOrGet ) ;
(* Get/Set file date and time stamp *)


END GEMDOS.
