home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / utility / 95 / pascal / gemdos.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-01-15  |  7.7 KB  |  283 lines

  1. (* GEMDOS.PAS
  2.    Written by Jinfu Chen
  3.    Copyright @ Jan, 1987  *)
  4.  
  5. (* An included file for GEMDOS definition in Personal Pascal.
  6.    Portion of this file is copyright by OSS and CCD, 1986, used
  7.    by permission of OSS.
  8.  
  9.    I finally decide to do this after creating some GEMDOS files
  10.    for several programs again and again. This file is not a
  11.    program, it is basically a collection of ALL GEMDOS calls.
  12.    Efforts have been made to make the calling convention consistent
  13.    with Atari's in C since there are many C source codes available
  14.    in public domain.
  15.  
  16.    The major references are Abacus's Atari ST Internals and Atari's
  17.    GEMDOS Reference Manual. I haven't tested all the calls extesively
  18.    so use of these calls are on your own risk. Bugs report can be
  19.    sent to:
  20.  
  21.    Jinfu Chen
  22.    41 Riverbend Drive
  23.    Yarmouth, ME04096
  24.  
  25.    BBS : MANIAC BBS, 207-854-2687
  26.    GEnie J.CHEN
  27.    CompuServe [72327,2434]
  28.  
  29. *)
  30.  
  31. (* In order to use the routines, we have to define some constants and
  32.    types and they have to be included as a seperate file.
  33. *)
  34.  
  35. PROCEDURE Pterm0 ;
  36.   GEMDOS($00) ;
  37. (* Terminate Process *)
  38.  
  39. FUNCTION Cconin : LONG ;
  40.   GEMDOS($01) ;
  41. (* Read character from Standard Input *)
  42. (* format :
  43.      31..24 bits    $00 or shift bytes
  44.      23..16 bits    scancode or $00
  45.      15..8  bits    $00
  46.      7..0   bits    ASCII
  47. *)
  48.  
  49. PROCEDURE Cconout( outchar : WORD ) ;
  50.   GEMDOS($02) ;
  51. (* Write character to Standard Output *)
  52.  
  53. FUNCTION Cauxin : WORD ;
  54.   GEMDOS($03) ;
  55. (* Read character from Standard AUX *)
  56.  
  57. PROCEDURE Cauxout( outchar : WORD ) ;
  58.   GEMDOS($04) ;
  59. (* Write character to Standard AUX *)
  60.  
  61. PROCEDURE Cprnout( outchar : WORD ) ;
  62.   GEMDOS($05) ;
  63. (* Write character to Standard PRN *)
  64.  
  65. FUNCTION Crawio( VAR iochar : WORD ) : LONG ;
  66.   GEMDOS($06) ;
  67. (* Raw I/O to Standard Input/Output *)
  68.  
  69. FUNCTION Crawin : LONG ;
  70.   GEMDOS($07) ;
  71. (* Raw Input from Standard Input *)
  72.  
  73. FUNCTION Cnecin : LONG ;
  74.   GEMDOS($08) ;
  75. (* Read character from Standard Input, No Echo *)
  76.  
  77. PROCEDURE Conws( VAR outstr : CSTRING ) ;
  78.   GEMDOS($09) ;
  79. (* Write string to Standard Output *)
  80. (* String has to be in C format ! *)
  81.  
  82. PROCEDURE Cconrs( VAR buf : edit_str ) ;
  83.   GEMDOS($0A) ;
  84. (* Read Edited String from Standard Input *)
  85. (* According to GEMDOS manual, the first byte of the string is the maximum
  86.    size of the input line and has to be initialized. In Pascal string type,
  87.    buf[0] is just the one we need here. The second byte, buf[1], is the
  88.    actual size of the string read from keyboard and the string starts from
  89.    buf[2]
  90. *)
  91.  
  92. FUNCTION Cconis : BOOLEAN ;
  93.   GEMDOS($0B) ;
  94. (* Check Status of Standard Input *)
  95.  
  96. FUNCTION Dsetdrv( drive : WORD ) : LONG ;
  97.   GEMDOS($0E) ;
  98. (* Set Default Drive *)
  99. (* Don't know why GEMDOS asks 16 bit data for selected drive id and return
  100.    32 bit data for the 'old' drive id. Stupid heh? *)
  101.  
  102. FUNCTION Cconos : BOOLEAN ;
  103.   GEMDOS($10) ;
  104. (* Check Status of Standard Output *)
  105.  
  106. FUNCTION Cprnos : BOOLEAN ;
  107.   GEMDOS($11) ;
  108. (* Check Status of Standard PRN *)
  109.  
  110. FUNCTION Cauxis : BOOLEAN ;
  111.   GEMDOS($12) ;
  112. (* Check Status of Standard AUX: Input *)
  113.  
  114. FUNCTION Cauxos : BOOLEAN ;
  115.   GEMDOS($13) ;
  116. (* Check Status of Standard AUX: Output *)
  117.  
  118. FUNCTION Dgetdrv : WORD ;
  119.   GEMDOS($19) ;
  120. (* Get Default Drive *)
  121.  
  122. PROCEDURE Tsetdta( VAR addr : dta ) ;
  123.   GEMDOS($1A) ;
  124. (* Set DTA( Disk Transfer Address) *)
  125. (* Used by Fsfirst, Fsnext *)
  126.  
  127. FUNCTION Super( stack : LONG ) : LONG ;
  128.   GEMDOS($20) ;
  129. (* Get/Set/Inquire Supervisor Mode *)
  130.  
  131. FUNCTION Tgetdate : WORD ;
  132.   GEMDOS($2A) ;
  133. (* Get Date *)
  134.  
  135. FUNCTION Tsetdate( date : WORD ) : WORD ;
  136.   GEMDOS($2B) ;
  137. (* Set Date *)
  138.  
  139. FUNCTION Tgettime : WORD ;
  140.   GEMDOS($2C) ;
  141. (* Get Time *)
  142.  
  143. FUNCTION Tsettime( time : WORD ) : WORD ;
  144.   GEMDOS($2D) ;
  145. (* Set Time *)
  146.  
  147. FUNCTION Fgetdta : LONG ;
  148.   GEMDOS($2F) ;
  149. (* Get DTA( Disk Transfer Address ) *)
  150.  
  151. FUNCTION Sversion : WORD ;
  152.   GEMDOS($30) ;
  153. (* Get Version Number *)
  154. (* High byte is minor number and low byte is major number. For TOS in ROM, it
  155.    should return $1300 ==> 0.19 (?), no wonder GEM is buggy *)
  156.  
  157. PROCEDURE Ptermres ( keepcnt : LONG ; VAR retcode : WORD ) ;
  158.   GEMDOS($31) ;
  159. (* Terminate and Stay Resident *)
  160.  
  161. PROCEDURE Dfree( VAR buf : DRIVE_ARRAY ; driveno : WORD ) ;
  162.   GEMDOS($36) ;
  163. (* Get Drive Free Space *)
  164. (* Some Information :
  165.   buf[1] : number of free clusters ;
  166.   buf[2] : total number of clusters ;
  167.   buf[3] : sector size in bytes ;
  168.   buf[4] : cluster size in butes.
  169. *)
  170.  
  171. FUNCTION Dcreate( VAR pathname : CSTRING ) : WORD ;
  172.   GEMDOS($39) ;
  173. (* Create Directory *)
  174.  
  175. FUNCTION Ddelete( VAR pathname : CSTRING ) : WORD ;
  176.   GEMDOS($3A) ;
  177. (* Delete Directory *)
  178.  
  179. FUNCTION Dsetpath( VAR pathname : CSTRING ) : WORD ;
  180.   GEMDOS($3B) ;
  181. (* Set Current Directory *)
  182. (* Typos in Atari ST Internal, filename should proceeded with a backslash
  183.    '\' instead of slash '/' *)
  184.  
  185. FUNCTION Fcreate( VAR fname : CSTRING ; sttribs : WORD ) : WORD ;
  186.   GEMDOS($3C) ;
  187. (* Create File *)
  188.  
  189. FUNCTION Fopen ( VAR fname : CSTRING ; mode : WORD ) : WORD ;
  190.   GEMDOS($3D) ;
  191. (* Open File *)
  192.  
  193. FUNCTION Fclose( handle : WORD ) : WORD ;
  194.   GEMDOS($3E) ;
  195. (* Close File *)
  196.  
  197. FUNCTION Fread( handle : WORD ; count : LONG ; VAR buffer : buf_type ) : WORD ;
  198.   GEMDOS($3F) ;
  199. (* Read from File *)
  200. (* define your own buf_type, not necessory as in my example. Read OSS's doc
  201.    for more details *)
  202.  
  203. FUNCTION Fwrite(handle : WORD ; count : LONG ; VAR buffer : buf_type ) : WORD ;
  204.   GEMDOS($40) ;
  205. (* Write to File *)
  206. (* define your own buf_type, not necessory as in my example. Read OSS's doc
  207.    for more details *)
  208.  
  209. FUNCTION Fdelete( VAR fname : CSTRING ) : WORD ;
  210.   GEMDOS($41) ;
  211. (* Delete File *)
  212.  
  213. FUNCTION Fseek( offset : LONG ; handle, seekmode : WORD ) : LONG ;
  214.   GEMDOS($42) ;
  215. (* Seek File Pointer *)
  216.  
  217. FUNCTION Fattribs(VAR fname : CSTRING ; wflag : WORD ;
  218.                   VAR attribs : WORD) : WORD ;
  219.   GEMDOS($43) ;
  220. (* Get/Set File Attributes *)
  221.  
  222. FUNCTION Fdup( handle : WORD ) : WORD ;
  223.   GEMDOS($45) ;
  224. (* Duplicate File Handle *)
  225.  
  226. FUNCTION Fforce( stdh, nonstdh : WORD ) : WORD ;
  227.   GEMDOS($46) ;
  228. (* Force File Handle *)
  229.  
  230. PROCEDURE Dgetpath( VAR buf : CSTRING ; driveno : WORD ) ;
  231.   GEMDOS($47) ;
  232. (* Get Current Directory *)
  233.  
  234. FUNCTION Malloc( VAR amoutn : LONG ) : LONG ;
  235.   GEMDOS($48) ;
  236. (* Allocate Memory *)
  237.  
  238. FUNCTION Mfree( saddr : LONG ) : WORD ;
  239.   GEMDOS($49) ;
  240. (* Release Memory *)
  241.  
  242. FUNCTION Mshrink( block, newsize : LONG ) : WORD ;
  243.   GEMDOS($4A) ;
  244. (* Shrink Size of Allocated Block *)
  245. (* PASLIB takes care of the first zeri argument already *)
  246.  
  247. FUNCTION Pexec( mode : WORD ; VAR ptr1, ptr2, ptr3 : CSTRING ) : WORD ;
  248.   GEMDOS($4B) ;
  249. (* Load/Execute Process *)
  250. (* Brief information:
  251.  
  252.     Mode                  Ptr1                 Ptr2             Ptr3
  253. ---------------------------------------------------------------------------
  254.  0 = Load & Go         file to execute    command trail    enviroment string
  255.  3 = Load, no go       file to load       command trail    enviroment string
  256.  4 = Just go           unused             unused           basepage address
  257.  5 = Create basepage   unused             command trail    enviroment string
  258. ---------------------------------------------------------------------------
  259.  
  260. *)
  261.  
  262. PROCEDURE Pterm( VAR reccode : WORD ) ;
  263.   GEMDOS($4C) ;
  264. (* Terminate Process *)
  265.  
  266. FUNCTION Ffirst( VAR fspec : CSTRING ; attribs : WORD ) : WORD ;
  267.   GEMDOS($4E) ;
  268. (* Search First *)
  269.  
  270. FUNCTION Fsnext : WORD ;
  271.   GEMDOS($4F) ;
  272. (* Search Next *)
  273.  
  274. FUNCTION Frename( VAR oldname, newname : CSTRING ) : WORD ;
  275.   GEMDOS($56) ;
  276. (* Rename File *)
  277.  
  278. PROCEDURE Fdatime( VAR timeptr : LONG ; handle, wflag : WORD ) ;
  279.   GEMDOS($57) ;
  280. (* Get/Set File Timestamp *)
  281.  
  282. (* END of GEMDOS.PAS *)
  283.