home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI03.ARJ / ictari.03 / MISC / GEMDOS / GEMDOS.MAN
Text File  |  1987-10-10  |  98KB  |  2,973 lines

  1. r
  2.         
  3.         
  4.         
  5.         
  6.         
  7.         
  8.         
  9.                                 ATARI GEMDOS
  10.                                      -
  11.                               REFERENCE MANUAL
  12.         
  13.         
  14.                                April 4, 1986
  15.         
  16.         
  17.         
  18.         
  19.         
  20.         
  21.         
  22.         
  23.         
  24.         
  25.         
  26.         
  27.                   TABLE OF CONTENTS
  28.         
  29.                        Introduction
  30.         
  31.                        Calling GEMDOS
  32.                        File Naming
  33.                        File Operations
  34.                        Processes
  35.                        Extended Vectors
  36.                        Error Handling
  37.         
  38.                        GEMDOS Calls
  39.         
  40.                        Executable File Format
  41.                        Disk Structure
  42.         
  43.         
  44.         
  45.         
  46.         
  47.         
  48.         
  49.         
  50.         
  51.         
  52.         
  53.         
  54.         
  55.         
  56.         
  57.         
  58.         
  59.         
  60.         
  61.         
  62.         
  63.         
  64.         
  65.         
  66.         
  67.         
  68.         
  69.         
  70.         
  71.         
  72.         ~/text/gemdos/intro                    Introduction    ( 1 )
  73.         
  74.         
  75.         _✓I_✓N_✓T_✓R_✓O_✓D_✓U_✓C_✓T_✓I_✓O_✓N
  76.         
  77.                       ________________________________
  78.                      | THIS IS A PRELIMINARY DOCUMENT|
  79.                      |    AND IT DOES NOT CLAIM TO   |
  80.                      |   PERFECTLY DESCRIBE REALITY  |
  81.                      |   (or even GEMDOS).  PLEASE   |
  82.                      |    REPORT BUGS AND TYPOS TO   |
  83.                      |✓|_________✓A_✓T_✓A_✓R_✓I_✓.___✓T_✓H_✓A_✓N_✓K_✓S_✓!________|✓_✓|
  84.         
  85.              This is the Atari GEMDOS User's Manual.   It  describes
  86.         the  internals  and  use  of  GEMDOS  on the Atari ST.  This
  87.         manual is divided into three parts; a tutorial and introduc-
  88.         tion for beginning users, a reference manual for application
  89.         writers, and appendices for GEMDOS wizards.
  90.         
  91.              The GEMDOS Tutorial is a  gentle  introduction  to  the
  92.         basics  of  GEMDOS.  Its intention is to get beginning users
  93.         started as quickly as possible.  It gives example  programs,
  94.         designed  to  exercise  most of GEMDOS, which combine into a
  95.         simple commandline interface, or "shell".  The tutorial also
  96.         covers common pitfalls and useful shortcuts.
  97.         
  98.              The GEMDOS Reference Manual is the application-writer's
  99.         bible.  It covers GEMDOS' calling conventions, file and han-
  100.         dle manipulation, process execution, and every GEMDOS call.
  101.         
  102.              The Appendices contain nitty-gritty details  and  hints
  103.         for  those  who  have to push GEMDOS to the limit.  They are
  104.         for application writers (and the merely  curious)  who  have
  105.         "need to know" about obscurities in the system.
  106.         
  107.              To use this manual effectively readers should be  fami-
  108.         liar  with  C and 68000 assembly language.  Familiarity with
  109.         MSDOS, Unix[1], and the standard C runtime library will also
  110.         help.
  111.         
  112.         
  113.         
  114.         
  115.         
  116.         
  117.         
  118.         
  119.         
  120.         
  121.         
  122.         
  123.         ____________________
  124.         
  125.            [1] Unix ist ein eingetragenes Warenzeichen der Bell  La-
  126.         boratories.
  127.         
  128.         
  129.         
  130.         4/4/86 Dyer                                     Atari GEMDOS
  131.         
  132.         
  133.         
  134.         
  135.         
  136.         
  137.         
  138.         ~/text/gemdos/calling                Calling GEMDOS    ( 1 )
  139.         
  140.         
  141.         _✓C_✓A_✓L_✓L_✓I_✓N_✓G _✓C_✓O_✓N_✓V_✓E_✓N_✓T_✓I_✓O_✓N_✓S
  142.              GEMDOS uses the Alcyon (or Digital Research) C  calling
  143.         conventions.   Note  that  these conventions may differ from
  144.         other 68000 C compilers.  If you are using  another  C  com-
  145.         piler  it  might  not  be  possible to call GEMDOS directly;
  146.         please check your compiler's documentation  for  compatibil-
  147.         ity.
  148.         
  149.              Arguments are pushed on the stack, in reverse order  of
  150.         their  declaration.   The  GEMDOS  function number is pushed
  151.         last, as a WORD.  To do the call to GEMDOS,  a  68000  "TRAP
  152.         #1"  instruction is executed.  The trap can be made with the
  153.         68000 in user or supervisor mode.
  154.         
  155.         NOTE
  156.                   Applications running in  supervisor  mode  may  be
  157.                   forced  back into user mode after making a GEM AES
  158.                   call.
  159.         
  160.                                Stack Snapshot
  161.                         (Just Before a GEMDOS Trap)
  162.         
  163.                        ______________________________
  164.                       |__✓s_✓t_✓a_✓c_✓k_✓|_________✓c_✓o_✓n_✓t_✓e_✓n_✓t_✓s_______✓|
  165.                       |  (sp)|  WORD function number|
  166.                       | 2(sp)|  argument 1          |
  167.                       | X(sp)|  argument 2          |
  168.                       | Y(sp)|  argument 3          |
  169.                       |     .|   .                  |
  170.                       |     .|  ... and so on ...   |
  171.                       |     .|   .                  |
  172.                       |_______✓|_______________________✓|
  173.         
  174.         
  175.              Results are returned in D0.  Registers D0-D2 and  A0-A2
  176.         can  be  modified;  registers D3-D7 and A3-A7 will always be
  177.         preserved.  The caller is responsible for popping the  argu-
  178.         ments (including the function number) off of the stack after
  179.         the call.
  180.         
  181.              The Alcyon C compiler does not generate  TRAP  instruc-
  182.         tions,  so  most  applications use a small assembly-language
  183.         binding.  It typically looks like:
  184.         
  185.         
  186.         
  187.         
  188.         
  189.         
  190.         
  191.         
  192.         
  193.         
  194.         
  195.         
  196.         4/4/86 Dyer                                     Atari GEMDOS
  197.         
  198.         
  199.         
  200.         
  201.         
  202.         
  203.         
  204.         ~/text/gemdos/calling                Calling GEMDOS    ( 2 )
  205.         
  206.         
  207.          _________________________________________________________
  208.         |     text                                               |
  209.         | *+                                                     |
  210.         | *  GEMDOS binding for Alcyon C                         |
  211.         | *                                                      |
  212.         | *  NOTE:                                               |
  213.         | *    This binding is NOT re-entrant, and cannot        |
  214.         | *    be shared by foreground and interrupt code.       |
  215.         | *                                                      |
  216.         | *-                                                     |
  217.         |         .globl  _gemdos                                |
  218.         | _gemdos:                                               |
  219.         |         move.l  (sp)+,t1sav     ; save ret addr        |
  220.         |         trap    #1              ; call GEMDOS          |
  221.         |         move.l  t1sav,-(sp)     ; restore ret addr     |
  222.         |         rts                     ; do "real" return     |
  223.         |                                                        |
  224.         |     bss                                                |
  225.         | t1sav:  ds.l    1               ; saved ret addr       |
  226.         |✓|________________________________________________________|✓_✓|
  227.         
  228.         
  229.         
  230.         
  231.         
  232.         
  233.         
  234.         
  235.         
  236.         
  237.         
  238.         
  239.         
  240.         
  241.         
  242.         
  243.         
  244.         
  245.         
  246.         
  247.         
  248.         
  249.         
  250.         
  251.         
  252.         
  253.         
  254.         
  255.         
  256.         
  257.         
  258.         
  259.         
  260.         
  261.         
  262.         4/4/86 Dyer                                     Atari GEMDOS
  263.         
  264.         
  265.         
  266.         
  267.         
  268.         
  269.         
  270.         ~/text/gemdos/filenames                  File Names    ( 1 )
  271.         
  272.         
  273.         _✓F_✓I_✓L_✓E_✓N_✓A_✓M_✓E_✓S
  274.              A filename consists of a drive  specification  followed
  275.         by  a pathname and a simple filename.  A drive specification
  276.         consists of a single letter, A  through  P,  followed  by  a
  277.         colon; if the specification is missing, the default drive is
  278.         used.  A pathname consists of a  list  of  simple  filenames
  279.         separated  with  backslashes.  If the pathname starts with a
  280.         backslash it is anchored in the root directory, otherwise it
  281.         is  anchored  in  the current directory.  If the pathname is
  282.         missing, the current directory is used.  A  simple  filename
  283.         consists  of one to eight characters, optionally followed by
  284.         a period and zero to three more characters.
  285.         
  286.              Legal characters in filenames and pathnames include the
  287.         alphabet   (A-Z),   digits   (0-9),  and  most  punctuation.
  288.         Periods,  colons,  backslashes,   slashes,   question-marks,
  289.         asterisks,  control characters (including NULs), and charac-
  290.         ters greater  than  0x7f  may  never  appear  in  filenames.
  291.         Lowercase letters are converted to uppercase.
  292.         
  293.              A full file specification may not  exceed  125  charac-
  294.         ters.
  295.         
  296.         
  297.                       _______________________________
  298.                      |__✓L_✓e_✓g_✓a_✓l__✓C_✓h_✓a_✓r_✓a_✓c_✓t_✓e_✓r_✓s__✓i_✓n__✓F_✓i_✓l_✓e_✓n_✓a_✓m_✓e_✓s_✓|
  299.                      |       letters A-Z, a-z       |
  300.                      |          numbers 0-9         |
  301.                      |        _ (underscore)        |
  302.                      |       ! @ # $ % ^ & ( )      |
  303.                      |       + - = ~ ` ; ' " ,      |
  304.                      |         < > | [ ] { }        |
  305.                      |_______________________________✓|
  306.         
  307.         
  308.              In a pathname, "." refers to the current directory  and
  309.         ".."  refers  to  the  current directory's parent directory.
  310.         Thus, the paths:
  311.         
  312.                                 "..\..\foo"
  313.         and
  314.                        ".\.\.\.\.\.\..\.\.\..\.\foo"
  315.         
  316.         refer to the same file two directories up from  the  current
  317.         one.  (There is no parent directory at the root.)
  318.         
  319.              There are three  character  devices.   Only  the  calls
  320.         Fread(),  Fwrite() Fopen(), Fcreate(), and Fclose(), and the
  321.         standard I/O functions work on them:
  322.         
  323.         
  324.         
  325.         
  326.         
  327.         
  328.         4/4/86 Dyer                                     Atari GEMDOS
  329.         
  330.         
  331.         
  332.         
  333.         
  334.         
  335.         
  336.         ~/text/gemdos/filenames                  File Names    ( 2 )
  337.         
  338.         
  339.                 ____________________________________________
  340.                |_____✓n_✓a_✓m_✓e__________✓h_✓a_✓n_✓d_✓l_✓e___________✓d_✓e_✓v_✓i_✓c_✓e_____✓|
  341.                | CON:, con:|  0x0ffff (-1)|  system console|
  342.                | AUX:, aux:|  0x0fffe (-2)|  RS232 port    |
  343.                | PRN:, prn:|  0x0fffd (-3)|  printer port  |
  344.                |____________✓|_______________✓|_________________✓|
  345.         
  346.         
  347.              An Fopen() or Fcreate() call on one  of  the  character
  348.         devices  will  return a character device handle.  The handle
  349.         is WORD negative, but not LONG negative.
  350.         
  351.         
  352.         
  353.         
  354.         
  355.         
  356.         
  357.         
  358.         
  359.         
  360.         
  361.         
  362.         
  363.         
  364.         
  365.         
  366.         
  367.         
  368.         
  369.         
  370.         
  371.         
  372.         
  373.         
  374.         
  375.         
  376.         
  377.         
  378.         
  379.         
  380.         
  381.         
  382.         
  383.         
  384.         
  385.         
  386.         
  387.         
  388.         
  389.         
  390.         
  391.         
  392.         
  393.         
  394.         4/4/86 Dyer                                     Atari GEMDOS
  395.         
  396.         
  397.         
  398.         
  399.         
  400.         
  401.         
  402.         ~/text/gemdos/fileops               File Operations    ( 1 )
  403.         
  404.         
  405.         _✓F_✓I_✓L_✓E _✓O_✓P_✓E_✓R_✓A_✓T_✓I_✓O_✓N_✓S
  406.              GEMDOS places no restrictions on what a file  may  con-
  407.         tain.   Most  applications  assume  that  text files contain
  408.         lines  separated  with  carriage-return  linefeeds,  with  a
  409.         control-Z indicating the end of file.  The format of execut-
  410.         able files is documented in the Appendix.
  411.         
  412.              The GEMDOS calls Fcreate() and  Fopen()  return  small,
  413.         positive 16-bit integers, called handles, that refer to open
  414.         files.  A file may be opened for reading only,  for  writing
  415.         only, or for reading and writing.  Closing the file relinqu-
  416.         ishes the handle, allowing the handle to be re-used.
  417.         
  418.              There are three kinds  of  handles.   Standard  handles
  419.         range  from  0  to  5, and may refer to character devices or
  420.         files.  Non-standard handles start at 6, and refer  only  to
  421.         files.   Character  handles refer only to character devices;
  422.         the handle numbers range from 0xfffd to  0xffff,  which  are
  423.         WORD negative, but not LONG negative.
  424.         
  425.              When a process does a Pexec() call  the  child  process
  426.         inherits  the  parent's standard handles.  Handle 0 is often
  427.         referred to as "standard input" or "standard  output";  nor-
  428.         mally it is connected to the console, CON:.  With Fdup() and
  429.         Fforce() calls it is possible to redirect a process's  stan-
  430.         dard I/O to or from a file or another character device.
  431.         
  432.              When a media change occurs, all files open on the  disk
  433.         that was removed are forced closed by GEMDOS.
  434.         
  435.         _✓B_✓U_✓G_✓S
  436.                   There is no concept of "standard error" output.
  437.         
  438.         
  439.         
  440.         
  441.         
  442.         
  443.         
  444.         
  445.         
  446.         
  447.         
  448.         
  449.         
  450.         
  451.         
  452.         
  453.         
  454.         
  455.         
  456.         
  457.         
  458.         
  459.         
  460.         4/4/86 Dyer                                     Atari GEMDOS
  461.         
  462.         
  463.         
  464.         
  465.         
  466.         
  467.         
  468.         ~/text/gemdos/processes                   Processes    ( 1 )
  469.         
  470.         
  471.         _✓P_✓R_✓O_✓C_✓E_✓S_✓S_✓E_✓S
  472.              Although GEMDOS does not support  multitasking,  it  is
  473.         possible  to  execute processes in a subroutine-like manner.
  474.         A process may "call" another with Pexec(); the child process
  475.         will terminate with a WORD return code.
  476.         
  477.              A process owns any files it opens  and  any  memory  it
  478.         allocates.   Open files are closed and memory is deallocated
  479.         when the process terminates.
  480.         
  481.              Before a process is  actually  terminated  GEMDOS  will
  482.         call  extended  vector  0x102.   This allows applications to
  483.         make a "last ditch" effort to recover from error conditions,
  484.         or to deinstall themselves.
  485.         
  486.              The memory model used by GEMDOS is similar to  MSDOS's.
  487.         A  process  runs  in  the TPA (Transient Program Area).  The
  488.         first 0x100 bytes of the  TPA  is  the  process's  basepage,
  489.         which contains process-specific information.
  490.         
  491.                              Basepage Structure
  492.         
  493.             ___________________________________________________
  494.            |__✓o_✓f_✓f_✓s_✓e_✓t_______✓n_✓a_✓m_✓e_______________✓d_✓e_✓s_✓c_✓r_✓i_✓p_✓t_✓i_✓o_✓n_________✓|
  495.            |   0x00   p_lowtpa     -> base of TPA             |
  496.            |   0x04   p_hitpa      -> end of TPA              |
  497.            |   0x08   p_tbase      base of text segment       |
  498.            |   0x0c   p_tlen       size of text segment       |
  499.            |   0x10   p_dbase      base of data segment       |
  500.            |   0x14   p_dlen       size of data segment       |
  501.            |   0x18   p_bbase      size of BSS segment        |
  502.            |   0x1c   p_blen       base of BSS segment        |
  503.            |   0x20   p_dta        Disk Transfer Address (DTA)|
  504.            |   0x24   p_parent     -> parent's basepage       |
  505.            |   0x28   (reserved)                              |
  506.            |   0x2c   p_env        -> enviroment string       |
  507.            |   0x80   p_cmdlin     commandline image          |
  508.            |___________________________________________________✓|
  509.         
  510.         
  511.              `p_lowtpa'  points  to  the   basepage   (to   itself).
  512.         `p_hitpa'  points  to the TPA's limit, to the first unusable
  513.         location.  `p_tbase', `p_tlen' and so on contain the  start-
  514.         ing  addresses and sizes of the text, data and BSS segments.
  515.         `p_parent'  points  to  the   process's   parent   process's
  516.         basepage.   `p_env'  points  to  the  enviroment string [see
  517.         Pexec()].
  518.         
  519.              The first byte of the commandline  image  contains  the
  520.         number of characters in the commandline.  The second through
  521.         Nth bytes contain the image.  The image is _✓n_✓o_✓t guaranteed to
  522.         be null-terminated.
  523.         
  524.         
  525.         
  526.         4/4/86 Dyer                                     Atari GEMDOS
  527.         
  528.         
  529.         
  530.         
  531.         
  532.         
  533.         
  534.         ~/text/gemdos/processes                   Processes    ( 2 )
  535.         
  536.         
  537.              An application receives control at the starting address
  538.         of  its  text  segment.   The  second longword on the stack,
  539.         4(sp), will contain a pointer  to  the  process's  basepage.
  540.         Normally  all  free memory is allocated to a new process; if
  541.         the process is going to use Malloc() or Pexec() then it must
  542.         relocate its stack and call Mshrink() to release memory back
  543.         to the system.  The stack segment starts  near  the  highest
  544.         TPA location and grows toward the BSS.
  545.         
  546.         
  547.         
  548.         
  549.         
  550.         
  551.         
  552.         
  553.         
  554.         
  555.         
  556.         
  557.         
  558.         
  559.         
  560.         
  561.         
  562.         
  563.         
  564.         
  565.         
  566.         
  567.         
  568.         
  569.         
  570.         
  571.         
  572.         
  573.         
  574.         
  575.         
  576.         
  577.         
  578.         
  579.         
  580.         
  581.         
  582.         
  583.         
  584.         
  585.         
  586.         
  587.         
  588.         
  589.         
  590.         
  591.         
  592.         4/4/86 Dyer                                     Atari GEMDOS
  593.         
  594.         
  595.         
  596.         
  597.         
  598.         
  599.         
  600.         ~/text/gemdos/vectors              Extended Vectors    ( 1 )
  601.         
  602.         
  603.         _✓E_✓X_✓T_✓E_✓N_✓D_✓E_✓D _✓V_✓E_✓C_✓T_✓O_✓R_✓S
  604.              The 68000 uses vectors 0x02 through 0xff, corresponding
  605.         to  absolute  locations  0x0000 through 0x03fc.  GEMDOS adds
  606.         eight _✓l_✓o_✓g_✓i_✓c_✓a_✓l vectors, numbered 0x100  through  0x107.   The
  607.         absolute  locations  of the logical vectors is undefined; it
  608.         is up to the BIOS to allocate storage for them.
  609.         
  610.                          Logical Vector Assignments
  611.         
  612.                  _________________________________________
  613.                 |_____✓v_✓e_✓c_✓t_✓o_✓r__________________✓u_✓s_✓e___________✓|
  614.                 |     0x100    |  timer tick             |
  615.                 |     0x101    |  critical error handler |
  616.                 |     0x102    |  terminate (^C) handler |
  617.                 | 0x103 - 0x107|  reserved for future use|
  618.                 |_______________✓|__________________________✓|
  619.         
  620.         
  621.         0x100 Timer Tick
  622.                   This vector is called periodically  (at  50hz)  by
  623.              the  BIOS  to  maintain  the  system's date/time-of-day
  624.              clock and do  housekeeping.   The  first  word  on  the
  625.              stack,  4(sp), contains the number of milliseconds from
  626.              the last timer tick interrupt.
  627.         
  628.                   To intercept the timer vector, use the  BIOS  call
  629.              to get and set the vector.  Each handler should execute
  630.              its own code first, and then  follow  the  old  vector.
  631.              Interrupt  handlers should be short and sweet; dawdling
  632.              here will affect system performance.
  633.         
  634.                   All registers (except SP and USP) are modified  by
  635.              GEMDOS.   The  BIOS  takes  responsibility  for  saving
  636.              registers D0-D7/A0-A6; therefore  handlers  chained  to
  637.              this  interrupt  do not have to save and restore regis-
  638.              ters.
  639.         
  640.         0x101 Critical Error Handler
  641.                   The Critical Error Handler is called by  the  BIOS
  642.              to handle certain errors (rwabs() disk errors and media
  643.              change requests.) It allows the application  to  handle
  644.              the errors as it sees fit.
  645.         
  646.                   The first word on the stack, 4(sp),  is  an  error
  647.              number.   Depending  on  the error, other arguments may
  648.              also be on  the  stack.   The  critical  error  handler
  649.              should   preserve   registers  D3-D7/A3-A6.   When  the
  650.              handler returns, D0 contains a result code:
  651.         
  652.         
  653.         
  654.         
  655.         
  656.         
  657.         
  658.         4/4/86 Dyer                                     Atari GEMDOS
  659.         
  660.         
  661.         
  662.         
  663.         
  664.         
  665.         
  666.         ~/text/gemdos/vectors              Extended Vectors    ( 2 )
  667.         
  668.         
  669.             ________________________________________________________
  670.            |__✓v_✓a_✓l_✓u_✓e__✓i_✓n__✓D_✓0_✓._✓L___________________✓m_✓e_✓a_✓n_✓i_✓n_✓g_________________✓|
  671.            | 0x00010000   |  retry                                 |
  672.            | 0x00000000   |  pretend there wasn't an error (ignore)|
  673.            | 0xffffffXX   |  abort with an error                   |
  674.            |_______________✓|_________________________________________✓|
  675.         
  676.                   The default critical error handler simply  returns
  677.              -1.
  678.         
  679.         0x102 Terminate (^C) Handler
  680.                   Before a process is  actually  terminated,  GEMDOS
  681.              calls  the  terminate  vector.  If the terminate vector
  682.              points to an RTS (the default case), the  process  will
  683.              be  terminated.  If the application does not wish to be
  684.              terminated it should do a longjump (or its  equivalent)
  685.              to an appropriate handler.
  686.         
  687.         
  688.         
  689.         
  690.         
  691.         
  692.         
  693.         
  694.         
  695.         
  696.         
  697.         
  698.         
  699.         
  700.         
  701.         
  702.         
  703.         
  704.         
  705.         
  706.         
  707.         
  708.         
  709.         
  710.         
  711.         
  712.         
  713.         
  714.         
  715.         
  716.         
  717.         
  718.         
  719.         
  720.         
  721.         
  722.         
  723.         
  724.         4/4/86 Dyer                                     Atari GEMDOS
  725.         
  726.         
  727.         
  728.         
  729.         
  730.         
  731.         
  732.         ~/text/gemdos/errors                 Error Handling    ( 1 )
  733.         
  734.         
  735.         _✓E_✓R_✓R_✓O_✓R _✓N_✓U_✓M_✓B_✓E_✓R_✓S
  736.         All error numbers are negative.  Two ranges  of  errors  are
  737.         defined;  BIOS errors range from -1 to -31 and GEMDOS errors
  738.         range from -32 to -127.
  739.         
  740.                               BIOS Error Codes
  741.         
  742.              __________________________________________________
  743.             |___✓n_✓a_✓m_✓e_____✓n_✓u_✓m_✓b_✓e_✓r_____________✓d_✓e_✓s_✓c_✓r_✓i_✓p_✓t_✓i_✓o_✓n___________✓|
  744.             | E_OK          0   OK (no error)                 |
  745.             | ERROR        -1   Error                         |
  746.             | EDRVNR       -2   Drive not ready               |
  747.             | EUNCMD       -3   Unknown command               |
  748.             | E_CRC        -4   CRC error                     |
  749.             | EBADRQ       -5   Bad request                   |
  750.             | E_SEEK       -6   Seek error                    |
  751.             | EMEDIA       -7   Unknown media                 |
  752.             | ESECNF       -8   Sector not found              |
  753.             | EPAPER       -9   Out of paper                  |
  754.             | EWRITF      -10   Write fault                   |
  755.             | EREADF      -11   Read fault                    |
  756.             |             -12   (unused)                      |
  757.             | EWRPRO      -13   Write on write-protected media|
  758.             | E_CHNG      -14   Media change detected         |
  759.             | EUNDEV      -15   Unknown device                |
  760.             | EBADSF      -16   Bad sectors on format         |
  761.             | EOTHER      -17   Insert other disk (request)   |
  762.             |__________________________________________________✓|
  763.         
  764.         
  765.         
  766.              `EOTHER' is really a request from the  BIOS  to  insert
  767.         another  disk  in drive A:.  The "virtual" disk number (0 or
  768.         1) is at 6(sp).  This feature is used to  fake  GEMDOS  into
  769.         thinking that a single drive system really has two drives.
  770.         
  771.         
  772.         
  773.         
  774.         
  775.         
  776.         
  777.         
  778.         
  779.         
  780.         
  781.         
  782.         
  783.         
  784.         
  785.         
  786.         
  787.         
  788.         
  789.         
  790.         4/4/86 Dyer                                     Atari GEMDOS
  791.         
  792.         
  793.         
  794.         
  795.         
  796.         
  797.         
  798.         ~/text/gemdos/errors                 Error Handling    ( 2 )
  799.         
  800.         
  801.                              GEMDOS Error Codes
  802.                           (numbers in parenthesis
  803.                        are MSDOS-equivalent error#s)
  804.         
  805.             ____________________________________________________
  806.            |___✓n_✓a_✓m_✓e______✓n_✓u_✓m_✓b_✓e_✓r______________✓d_✓e_✓s_✓c_✓r_✓i_✓p_✓t_✓i_✓o_✓n___________✓|
  807.            | EINVFN    -32 (1)   Invalid function number       |
  808.            | EFILNF    -33 (2)   File not found                |
  809.            | EPTHNF    -34 (3)   Path not found                |
  810.            | ENHNDL    -35 (4)   Handle pool exhausted         |
  811.            | EACCDN    -36 (5)   Access denied                 |
  812.            | EIHNDL    -37 (6)   Invalid handle                |
  813.            | ENSMEM    -39 (8)   Insufficient memory           |
  814.            | EIMBA     -40 (9)   Invalid memory block address  |
  815.            | EDRIVE   -46 (15)   Invalid drive specification   |
  816.            | ENMFIL   -47 (18)   No more files                 |
  817.            | ERANGE        -64   Range error                   |
  818.            | EINTRN        -65   GEMDOS internal error         |
  819.            | EPLFMT        -66   Invalid executable file format|
  820.            | EGSBF         -67   Memory block growth failure   |
  821.            |____________________________________________________✓|
  822.         
  823.         
  824.         
  825.         
  826.         
  827.         
  828.         
  829.         
  830.         
  831.         
  832.         
  833.         
  834.         
  835.         
  836.         
  837.         
  838.         
  839.         
  840.         
  841.         
  842.         
  843.         
  844.         
  845.         
  846.         
  847.         
  848.         
  849.         
  850.         
  851.         
  852.         
  853.         
  854.         
  855.         
  856.         4/4/86 Dyer                                     Atari GEMDOS
  857.         
  858.         
  859.         
  860.         
  861.         
  862.         
  863.         
  864.         
  865.         
  866.         
  867.         GEMDOS FUNCTIONS BY NUMBER
  868.         0x00 Pterm0 - Terminate Process
  869.         0x01 Cconin - Read character from Standard Input
  870.         0x02 Cconout - Write Character to Standard Output
  871.         0x03 Cauxin - Read Character from Standard AUX:
  872.         0x04 Cauxout - Write Character to Standard AUX:
  873.         0x05 Cprnout - Write Character to Standard PRN:
  874.         0x06 Crawio - Raw I/O to Standard Input/Output
  875.         0x07 Crawcin - Raw Input from Standard Input
  876.         0x08 Cnecin - Read Character from Standard Input, No Echo
  877.         0x09 Cconws - Write String to Standard Output
  878.         0x0A Cconrs - Read Edited String from Standard Input
  879.         0x0B Cconis - Check Status of Standard Input
  880.         0x0E Dsetdrv - Set Default Drive
  881.         0x10 Cconos - Check Status of Standard Output
  882.         0x11 Cprnos - Check Status of Standard PRN:
  883.         0x12 Cauxis - Check Status of Standard AUX: Input
  884.         0x13 Cauxos - Check Status of Standard AUX: Output
  885.         0x19 Dgetdrv - Get Default Drive
  886.         0x1A Fsetdta - Set DTA (Disk Transfer Address)
  887.         0x20 Super - Get/Set/Inquire Supervisor Mode
  888.         0x2A Tgetdate - Get Date
  889.         0x2B Tsetdate - Set Date
  890.         0x2C Tgettime - Get Time
  891.         0x2D Tsettime - Set Time
  892.         0x2F Fgetdta - Get DTA (Disk Transfer Address)
  893.         0x30 Sversion - Get Version Number
  894.         0x31 Ptermres - Terminate and Stay Resident
  895.         0x36 Dfree - Get Drive Free Space
  896.         0x39 Dcreate - Create Directory
  897.         0x3A Ddelete - Delete Directory
  898.         0x3B Dsetpath - Set Current Directory
  899.         0x3C Fcreate - Create File
  900.         0x3D Fopen - Open File
  901.         0x3E Fclose - Close File
  902.         0x3F Fread - Read From File
  903.         0x40 Fwrite - Write To File
  904.         0x41 Fdelete - Delete File
  905.         0x42 Fseek - Seek File Pointer
  906.         0x43 Fattrib - Get/Set File Attributes
  907.         0x45 Fdup - Duplicate File Handle
  908.         0x46 Fforce - Force File Handle
  909.         0x47 Dgetpath - Get Current Directory
  910.         0x48 Malloc - Allocate Memory
  911.         0x49 Mfree - Release Memory
  912.         0x4A Mshrink - Shrink Size of Allocated Block
  913.         0x4B Pexec - Load/Execute Process
  914.         0x4C Pterm - Terminate Process
  915.         0x4E Fsfirst - Search First
  916.         0x4F Fsnext - Search Next
  917.         0x56 Frename - Rename File
  918.         0x57 Fdatime - Get/Set File Timestamp
  919.         
  920.         
  921.         
  922.         
  923.         
  924.         
  925.         
  926.         
  927.         
  928.         
  929.         
  930.         ~/text/gemdos/funcs               File System Calls    ( 2 )
  931.         
  932.         
  933.         GEMDOS FUNCTIONS BY NAME
  934.         0x03 Cauxin - Read Character from Standard AUX:
  935.         0x12 Cauxis - Check Status of Standard AUX: Input
  936.         0x13 Cauxos - Check Status of Standard AUX: Output
  937.         0x04 Cauxout - Write Character to Standard AUX:
  938.         0x01 Cconin - Read character from Standard Input
  939.         0x0B Cconis - Check Status of Standard Input
  940.         0x10 Cconos - Check Status of Standard Output
  941.         0x02 Cconout - Write Character to Standard Output
  942.         0x0A Cconrs - Read Edited String from Standard Input
  943.         0x09 Cconws - Write String to Standard Output
  944.         0x08 Cnecin - Read Character from Standard Input, No Echo
  945.         0x11 Cprnos - Check Status of Standard PRN:
  946.         0x05 Cprnout - Write Character to Standard PRN:
  947.         0x07 Crawcin - Raw Input from Standard Input
  948.         0x06 Crawio - Raw I/O to Standard Input/Output
  949.         0x39 Dcreate - Create Directory
  950.         0x3A Ddelete - Delete Directory
  951.         0x36 Dfree - Get Drive Free Space
  952.         0x19 Dgetdrv - Get Default Drive
  953.         0x47 Dgetpath - Get Current Directory
  954.         0x0E Dsetdrv - Set Default Drive
  955.         0x3B Dsetpath - Set Current Directory
  956.         0x43 Fattrib - Get/Set File Attributes
  957.         0x3E Fclose - Close File
  958.         0x3C Fcreate - Create File
  959.         0x57 Fdatime - Get/Set File Timestamp
  960.         0x41 Fdelete - Delete File
  961.         0x45 Fdup - Duplicate File Handle
  962.         0x46 Fforce - Force File Handle
  963.         0x2F Fgetdta - Get DTA (Disk Transfer Address)
  964.         0x3D Fopen - Open File
  965.         0x3F Fread - Read From File
  966.         0x56 Frename - Rename File
  967.         0x42 Fseek - Seek File Pointer
  968.         0x1A Fsetdta - Set DTA (Disk Transfer Address)
  969.         0x4E Fsfirst - Search First
  970.         0x4F Fsnext - Search Next
  971.         0x40 Fwrite - Write To File
  972.         0x48 Malloc - Allocate Memory
  973.         0x49 Mfree - Release Memory
  974.         0x4A Mshrink - Shrink Size of Allocated Block
  975.         0x4B Pexec - Load/Execute Process
  976.         0x4C Pterm - Terminate Process
  977.         0x00 Pterm0 - Terminate Process
  978.         0x31 Ptermres - Terminate and Stay Resident
  979.         0x20 Super - Get/Set/Inquire Supervisor Mode
  980.         0x30 Sversion - Get Version Number
  981.         0x2A Tgetdate - Get Date
  982.         0x2C Tgettime - Get Time
  983.         0x2B Tsetdate - Set Date
  984.         0x2D Tsettime - Set Time
  985.         
  986.         
  987.         
  988.         4/4/86 Dyer                                     Atari GEMDOS
  989.         
  990.         
  991.         
  992.         
  993.         
  994.         
  995.         
  996.         ~/text/gemdos/funcs               File System Calls    ( 3 )
  997.         
  998.         
  999.         _________________________________
  1000.         |0x00 Pterm0 - Terminate Process|
  1001.         |✓_✓|_______________________________|✓_✓|
  1002.         
  1003.              void Pterm0()
  1004.         
  1005.                   Terminate  this  process,  closing  all  files  it
  1006.              opened  and  releasing any memory it allocated.  Return
  1007.              an exit code of 0x0000 to the parent process.
  1008.         
  1009.         
  1010.         
  1011.         __________________________________________________
  1012.         |0x01 Cconin - Read character from Standard Input|
  1013.         |✓_✓|________________________________________________|✓_✓|
  1014.              LONG Cconin()
  1015.         
  1016.                   Read character from the standard input (handle 0).   If
  1017.              the  standard  input device is the console, the longword re-
  1018.              turned in D0 contains both the ASCII and the  console  scan-
  1019.              code:
  1020.                  ___________________________________________________
  1021.                 |____✓3_✓1_✓._✓._✓2_✓4________✓2_✓3_✓._✓._✓1_✓6________✓1_✓5_✓._✓._✓8__________✓7_✓._✓._✓0____✓|
  1022.                 |  0x00 or  |   scancode |     0x00   |    ASCII   |
  1023.                 | shift bits|   or 0x00  |            |     char   |
  1024.                 |____________✓|_____________✓|_____________✓|_____________✓|
  1025.         
  1026.                   The function keys (F1 through F10,  HELP,  UNDO,  etc.)
  1027.              return  the  ASCII  code  0x00,  with  appropriate  scancode
  1028.              values; see the GEM/VDI manual for keyboard scancode assign-
  1029.              ments.   The  ST  BIOS  is  capable  of placing the keyboard
  1030.              shift-key status in bits 24..31; see the  BIOS  Programmer's
  1031.              Guide for further details.
  1032.         
  1033.         
  1034.              BUGS
  1035.              Does not return any indication of end of file.
  1036.              Control-C is not recognized.
  1037.              There is no way to tell if standard  input  is  a  character
  1038.              device or a file.
  1039.              There should be some way to type all possible 256 codes from
  1040.              the keyboard.
  1041.         
  1042.         
  1043.         
  1044.         
  1045.         
  1046.         
  1047.         
  1048.         
  1049.         
  1050.         
  1051.         
  1052.         
  1053.         
  1054.         4/4/86 Dyer                                     Atari GEMDOS
  1055.         
  1056.         
  1057.         
  1058.         
  1059.         
  1060.         
  1061.         
  1062.         ~/text/gemdos/funcs               File System Calls    ( 4 )
  1063.         
  1064.         
  1065.         ___________________________________________________
  1066.         |0x02 Cconout - Write Character to Standard Output|
  1067.         |✓_✓|_________________________________________________|✓_✓|
  1068.              void Cconout(c)
  1069.              WORD c;
  1070.         
  1071.                   Write the character `c' to the standard output  (handle
  1072.              0).   The  high  eight  bits of `c' are reserved and must be
  1073.              zero.  Tabs are not expanded.
  1074.         
  1075.         
  1076.         
  1077.         _________________________________________________
  1078.         |0x03 Cauxin - Read Character from Standard AUX:|
  1079.         |✓_✓|_______________________________________________|✓_✓|
  1080.              WORD Cauxin()
  1081.         
  1082.                   Read character from handle 1 (normally the serial port,
  1083.              AUX:).
  1084.         
  1085.         
  1086.              BUGS
  1087.              This function causes RS232 flow-control  to  fail;  applica-
  1088.              tions  should  use  the BIOS character device calls to avoid
  1089.              losing received characters.
  1090.         
  1091.         
  1092.         
  1093.         _________________________________________________
  1094.         |0x04 Cauxout - Write Character to Standard AUX:|
  1095.         |✓_✓|_______________________________________________|✓_✓|
  1096.              void Cauxout(c)
  1097.              WORD c;
  1098.         
  1099.                   Write `c' to standard  handle  1  (normally  AUX:,  the
  1100.              serial  port).   The high eight bits of `c' are reserved and
  1101.              must be zero.  Tabs are not expanded.
  1102.         
  1103.         
  1104.              BUGS
  1105.                   This function causes RS232 flow-control to fail; appli-
  1106.              cations  should use the BIOS character device calls to avoid
  1107.              losing transmitted characters.
  1108.         
  1109.         
  1110.         
  1111.         
  1112.         
  1113.         
  1114.         
  1115.         
  1116.         
  1117.         
  1118.         
  1119.         
  1120.         4/4/86 Dyer                                     Atari GEMDOS
  1121.         
  1122.         
  1123.         
  1124.         
  1125.         
  1126.         
  1127.         
  1128.         ~/text/gemdos/funcs               File System Calls    ( 5 )
  1129.         
  1130.         
  1131.         _________________________________________________
  1132.         |0x05 Cprnout - Write Character to Standard PRN:|
  1133.         |✓_✓|_______________________________________________|✓_✓|
  1134.              void Cprnout(c)
  1135.              WORD c;
  1136.         
  1137.                   Write `c' to  handle  2  (normally  PRN:,  the  printer
  1138.              port).   The high eight bits of `c' are reserved and must be
  1139.              zero.  Tabs are not expanded
  1140.         
  1141.         
  1142.         
  1143.         ________________________________________________
  1144.         |0x06 Crawio - Raw I/O to Standard Input/Output|
  1145.         |✓_✓|______________________________________________|✓_✓|
  1146.              LONG Crawio(w)
  1147.              WORD w;
  1148.         
  1149.                   If `w' is not 0x00FF, write it to the standard  output.
  1150.              Tabs are not expanded
  1151.         
  1152.                   Otherwise, if` `w' equals 0x00ff, read a character from
  1153.              the  standard  input.  0x0000 is returned if no character is
  1154.              available.
  1155.         
  1156.              BUGS
  1157.              Because of the way this function is defined,  `0xff'  cannot
  1158.              be written to the standard output with this function.
  1159.              Cannot distinguish between 0x00 and the end of the file.
  1160.         
  1161.         
  1162.         
  1163.         ______________________________________________
  1164.         |0x07 Crawcin - Raw Input from Standard Input|
  1165.         |✓_✓|____________________________________________|✓_✓|
  1166.              LONG Crawcin()
  1167.         
  1168.                   Read a character from the standard  input  (handle  0).
  1169.              If  the input device is CON: no control character processing
  1170.              is done and the character is not echoed.
  1171.         
  1172.              BUGS
  1173.              No end of file indication.
  1174.         
  1175.         
  1176.         
  1177.         
  1178.         
  1179.         
  1180.         
  1181.         
  1182.         
  1183.         
  1184.         
  1185.         
  1186.         4/4/86 Dyer                                     Atari GEMDOS
  1187.         
  1188.         
  1189.         
  1190.         
  1191.         
  1192.         
  1193.         
  1194.         ~/text/gemdos/funcs               File System Calls    ( 6 )
  1195.         
  1196.         
  1197.         ___________________________________________________________
  1198.         |0x08 Cnecin - Read Character from Standard Input, No Echo|
  1199.         |✓_✓|_________________________________________________________|✓_✓|
  1200.              LONG Cnecin()
  1201.         
  1202.                   Read character from the standard input.  If  the  input
  1203.              device is CON:, no echoing is done, although control charac-
  1204.              ters are interpreted.
  1205.         
  1206.         
  1207.         
  1208.         _______________________________________________
  1209.         |0x09 Cconws - Write String to Standard Output|
  1210.         |✓_✓|_____________________________________________|✓_✓|
  1211.              void Cconws(str)
  1212.              char *str;
  1213.         
  1214.                   Write a null-terminated string, starting at  `str',  to
  1215.              the standard output.
  1216.         
  1217.         
  1218.         
  1219.         ______________________________________________________
  1220.         |0x0A Cconrs - Read Edited String from Standard Input|
  1221.         |✓_✓|____________________________________________________|✓_✓|
  1222.              void Cconrs(buf)
  1223.              char *buf;
  1224.         
  1225.                   Read string from the standard  input,  handling  common
  1226.              line editing characters.  The editing characters are:
  1227.                         ______________________________________
  1228.                        |__________✓C_✓h_✓a_✓r____✓F_✓u_✓n_✓c_✓t_✓i_✓o_✓n______________✓|
  1229.                        | <return>, ^J   End the line         |
  1230.                        |    ^H, <rub>   Kill last character  |
  1231.                        |       ^U, ^X   Kill entire line     |
  1232.                        |           ^R   Retype line          |
  1233.                        |           ^C   Terminate the process|
  1234.                        |______________________________________✓|
  1235.         
  1236.                   The first character of `buf' indicates the size of  the
  1237.              data  part  of  the  buffer.   On return, the second byte of
  1238.              `buf' is set to the number of characters read, and locations
  1239.              `buf+2' through 'buf+2+buf[1]' contain the characters.
  1240.         
  1241.                   The string is _✓n_✓o_✓t guaranteed to be null-terminated.
  1242.         
  1243.              BUGS
  1244.              Hangs on end-of-file.
  1245.         
  1246.         
  1247.         
  1248.         
  1249.         
  1250.         
  1251.         
  1252.         4/4/86 Dyer                                     Atari GEMDOS
  1253.         
  1254.         
  1255.         
  1256.         
  1257.         
  1258.         
  1259.         
  1260.         ~/text/gemdos/funcs               File System Calls    ( 7 )
  1261.         
  1262.         
  1263.         ______________________________________________
  1264.         |0x0B Cconis - Check Status of Standard Input|
  1265.         |✓_✓|____________________________________________|✓_✓|
  1266.              WORD Cconis()
  1267.         
  1268.                   Return 0xFFFF if a character is available on the  stan-
  1269.              dard input, 0x0000 otherwise.
  1270.         
  1271.         
  1272.         
  1273.         __________________________________
  1274.         |0x0E Dsetdrv - Set Default Drive|
  1275.         |✓_✓|________________________________|✓_✓|
  1276.              LONG Dsetdrv(drv)
  1277.              WORD drv;
  1278.         
  1279.                   Set the default drive to the  zero-based  drive  number
  1280.              `drv' (ranging from 0 to 15, A: to P:).  Return a bit-string
  1281.              of known drives (bit 0 = A, bit 1 = B, etc.)
  1282.         
  1283.                   A "known drive" is one on which a  directory  has  been
  1284.              used.
  1285.         
  1286.              BUGS
  1287.                   GEMDOS only supports 16 drives  (bits  0  through  15).
  1288.              Future systems will support 32 drives.
  1289.         
  1290.         
  1291.         
  1292.         _______________________________________________
  1293.         |0x10 Cconos - Check Status of Standard Output|
  1294.         |✓_✓|_____________________________________________|✓_✓|
  1295.              WORD Cconos()
  1296.         
  1297.                   Return 0xFFFF if the console  is  ready  to  receive  a
  1298.              character.  Return 0x0000 if the console is NOT ready.
  1299.         
  1300.              BUGS
  1301.              CON: and files are always ready, so why check?
  1302.         
  1303.         
  1304.         
  1305.         _____________________________________________
  1306.         |0x11 Cprnos - Check Status of Standard PRN:|
  1307.         |✓_✓|___________________________________________|✓_✓|
  1308.              WORD Cprnos()
  1309.         
  1310.                   Return 0xFFFF if PRN: is ready to receive a  character,
  1311.              0x0000 if it isn't.
  1312.         
  1313.         
  1314.         
  1315.         
  1316.         
  1317.         
  1318.         4/4/86 Dyer                                     Atari GEMDOS
  1319.         
  1320.         
  1321.         
  1322.         
  1323.         
  1324.         
  1325.         
  1326.         ~/text/gemdos/funcs               File System Calls    ( 8 )
  1327.         
  1328.         
  1329.         ___________________________________________________
  1330.         |0x12 Cauxis - Check Status of Standard AUX: Input|
  1331.         |✓_✓|_________________________________________________|✓_✓|
  1332.              WORD Cauxis()
  1333.         
  1334.                   Return 0xFFFF if a character is available on AUX: (han-
  1335.              dle 1), 0x0000 if not.
  1336.         
  1337.         
  1338.         
  1339.         ____________________________________________________
  1340.         |0x13 Cauxos - Check Status of Standard AUX: Output|
  1341.         |✓_✓|__________________________________________________|✓_✓|
  1342.              WORD Cauxos()
  1343.         
  1344.                   Return 0xFFFF if AUX: (standard handle 1) is  ready  to
  1345.              accept a character, 0x0000 if not.
  1346.         
  1347.         
  1348.         
  1349.         __________________________________
  1350.         |0x19 Dgetdrv - Get Default Drive|
  1351.         |✓_✓|________________________________|✓_✓|
  1352.              WORD Dgetdrv()
  1353.         
  1354.                   Return the current drive number, 0 through 15.
  1355.         
  1356.         
  1357.         
  1358.         ________________________________________________
  1359.         |0x1A Fsetdta - Set DTA (Disk Transfer Address)|
  1360.         |✓_✓|______________________________________________|✓_✓|
  1361.              void Fsetdta(addr)
  1362.              char *addr;
  1363.         
  1364.                   Set the DTA to `addr'.  (The DTA is used  only  by  the
  1365.              functions Fsfirst() and Fsnext().)
  1366.         
  1367.         
  1368.         
  1369.         
  1370.         
  1371.         
  1372.         
  1373.         
  1374.         
  1375.         
  1376.         
  1377.         
  1378.         
  1379.         
  1380.         
  1381.         
  1382.         
  1383.         
  1384.         4/4/86 Dyer                                     Atari GEMDOS
  1385.         
  1386.         
  1387.         
  1388.         
  1389.         
  1390.         
  1391.         
  1392.         ~/text/gemdos/funcs               File System Calls    ( 9 )
  1393.         
  1394.         
  1395.         ______________________________________________
  1396.         |0x20 Super - Get/Set/Inquire Supervisor Mode|
  1397.         |✓_✓|____________________________________________|✓_✓|
  1398.              LONG Super(stack)
  1399.              WORD *stack;
  1400.         
  1401.                   If `stack' is -1L (0xFFFFFFFF)  return  0x0000  if  the
  1402.              processor  is in user mode, or 0x0001 if the processor is in
  1403.              supervisor mode.
  1404.         
  1405.                   Otherwise, if the processor is  in  user  mode,  return
  1406.              with  the processor switched to supervisor mode.  If `stack'
  1407.              is NULL (0x00000000) then the supervisor stack will  be  the
  1408.              same  as  the user stack before the call.  Otherwise the su-
  1409.              pervisor stack will be set to `stack'.
  1410.         
  1411.                   If the processor is in supervisor mode, return with the
  1412.              processor switched back to user mode.  `stack' should be the
  1413.              value of the supervisor stack that was returned by the first
  1414.              call to the function.
  1415.         
  1416.              NOTE
  1417.                        The original supervisor stack value  MUST  be  re-
  1418.                   stored before the process terminates.  Failure to do so
  1419.                   will result in a system crash.
  1420.         
  1421.         
  1422.         
  1423.         __________________________
  1424.         |0x2A Tgetdate - Get Date|
  1425.         |✓_✓|________________________|✓_✓|
  1426.              WORD Tgetdate()
  1427.         
  1428.                   Return the current date, in DOS format:
  1429.                15                     9   8           5   4           0
  1430.               __________________________________________________________
  1431.              |                         |               |               |
  1432.              |      year since 1980    |      month    |       day     |
  1433.              |          0..119         |      1..12    |      1..31    |
  1434.              |✓|_________________________|✓_✓|_______________|✓_✓|_______________|✓_✓|
  1435.         
  1436.              RETURNS
  1437.                   Bits:
  1438.                   0..4 contain the day, ranging 1..31.
  1439.                   5..8 contain the month ranging 1..12.
  1440.                   9..15 contain the year (since 1980) ranging 0..119.
  1441.         
  1442.         
  1443.         
  1444.         
  1445.         
  1446.         
  1447.         
  1448.         
  1449.         
  1450.         4/4/86 Dyer                                     Atari GEMDOS
  1451.         
  1452.         
  1453.         
  1454.         
  1455.         
  1456.         
  1457.         
  1458.         ~/text/gemdos/funcs              File System Calls    ( 10 )
  1459.         
  1460.         
  1461.         __________________________
  1462.         |0x2B Tsetdate - Set Date|
  1463.         |✓_✓|________________________|✓_✓|
  1464.              WORD Tsetdate(date)
  1465.              WORD date;
  1466.         
  1467.                   Set the current date to `date', which is in the  format
  1468.              described in Tgetdate().
  1469.         
  1470.              RETURNS
  1471.                   0 on valid date;
  1472.                   ERROR on an obviously screwed-up date.
  1473.         
  1474.              BUGS
  1475.                   GEMDOS is not picky  about  date  parameters;  for  in-
  1476.              stance, it likes Feb 31st ....
  1477.         
  1478.                   GEMDOS does NOT let the BIOS know  that  the  date  has
  1479.              been changed.
  1480.         
  1481.         
  1482.         
  1483.         __________________________
  1484.         |0x2C Tgettime - Get Time|
  1485.         |✓_✓|________________________|✓_✓|
  1486.              WORD Tgettime()
  1487.         
  1488.                   Return the current time in DOS format:
  1489.                   15           11   10            5   4            0
  1490.                  ____________________________________________________
  1491.                 |      hour      |       minute    |      second    |
  1492.                 |      0..23     |       0..59     |      0..29     |
  1493.                 |✓|________________|✓_✓|_________________|✓_✓|________________|✓_✓|
  1494.         
  1495.              RETURNS
  1496.                   Bits 0..4 contain the second divided by 2, 0..29.
  1497.                   Bits 5..10 contain the minute, 0..59.
  1498.                   Bits 11..15 contain the hour, 0..23.
  1499.         
  1500.         
  1501.         
  1502.         
  1503.         
  1504.         
  1505.         
  1506.         
  1507.         
  1508.         
  1509.         
  1510.         
  1511.         
  1512.         
  1513.         
  1514.         
  1515.         
  1516.         4/4/86 Dyer                                     Atari GEMDOS
  1517.         
  1518.         
  1519.         
  1520.         
  1521.         
  1522.         
  1523.         
  1524.         ~/text/gemdos/funcs              File System Calls    ( 11 )
  1525.         
  1526.         
  1527.         __________________________
  1528.         |0x2D Tsettime - Set Time|
  1529.         |✓_✓|________________________|✓_✓|
  1530.              WORD Tsettime(time)
  1531.              WORD time;
  1532.         
  1533.                   Set the current time to `time', which is in the  format
  1534.              described in Tgettime().
  1535.         
  1536.              RETURNS
  1537.                   0 if GEMDOS liked the time;
  1538.                   ERROR if it didn't.
  1539.         
  1540.              BUGS
  1541.                   GEMDOS does NOT let the BIOS know  that  the  time  has
  1542.              been changed.
  1543.         
  1544.         
  1545.         
  1546.         ________________________________________________
  1547.         |0x2F Fgetdta - Get DTA (Disk Transfer Address)|
  1548.         |✓_✓|______________________________________________|✓_✓|
  1549.              LONG Fgetdta()
  1550.         
  1551.                   Returns the value of the current DTA, a pointer used by
  1552.              the functions Fsfirst() and Fsnext().
  1553.         
  1554.         
  1555.         
  1556.         ____________________________________
  1557.         |0x30 Sversion - Get Version Number|
  1558.         |✓_✓|__________________________________|✓_✓|
  1559.              WORD Sversion()
  1560.         
  1561.                   Return GEMDOS's version number (in  byte-reversed  for-
  1562.              mat).   The high byte contains the minor version number, the
  1563.              low byte contains the major version number.
  1564.         
  1565.              NOTE
  1566.                   The 5/29/85 (first disk-based) and the 11/20/85  (first
  1567.              ROM-based) release of GEMDOS had the version number 0x1300.
  1568.         
  1569.              GEMDOS version numbers and TOS versions numbers are _✓n_✓o_✓t  one
  1570.              and  the  same.   See the _✓S_✓T__✓B_✓I_✓O_✓S__✓R_✓E_✓F_✓E_✓R_✓E_✓N_✓C_✓E__✓M_✓A_✓N_✓U_✓A_✓L for about
  1571.              TOS version numbers.
  1572.         
  1573.         
  1574.         
  1575.         
  1576.         
  1577.         
  1578.         
  1579.         
  1580.         
  1581.         
  1582.         4/4/86 Dyer                                     Atari GEMDOS
  1583.         
  1584.         
  1585.         
  1586.         
  1587.         
  1588.         
  1589.         
  1590.         ~/text/gemdos/funcs              File System Calls    ( 12 )
  1591.         
  1592.         
  1593.         _____________________________________________
  1594.         |0x31 Ptermres - Terminate and Stay Resident|
  1595.         |✓_✓|___________________________________________|✓_✓|
  1596.              void Ptermres(keepcnt, retcode)
  1597.              LONG keepcnt;
  1598.              WORD retcode;
  1599.         
  1600.                   Terminate the current process, keeping some  of  it  in
  1601.              memory.   `keepcnt' is the amount of the memory belonging to
  1602.              the process to keep, including and starting at the  256-byte
  1603.              basepage. `retcode' is the exit code that is returned to the
  1604.              parent process.
  1605.         
  1606.                   Memory the process has allocated (in  addition  to  the
  1607.              TPA) will NOT be released.
  1608.         
  1609.                   Ptermres() will never return.
  1610.         
  1611.         
  1612.              BUGS
  1613.              Open files are closed as part of termination.
  1614.         
  1615.         
  1616.         
  1617.         ___________________________________
  1618.         |0x36 Dfree - Get Drive Free Space|
  1619.         |✓_✓|_________________________________|✓_✓|
  1620.              void Dfree()
  1621.              LONG *buf;
  1622.              WORD driveno;
  1623.         
  1624.                   Get  disk  allocation  information  about   the   drive
  1625.              `driveno'  and  store  it  into  four  longwords starting at
  1626.              `buf':
  1627.                                   ___________________________
  1628.                          buf + 0|     # of free clusters    |
  1629.                                 | ___________________________✓|
  1630.                          buf + 4|     total # of clusters   |
  1631.                                 | ___________________________✓|
  1632.                          buf + 8|   sector size (in bytes)  |
  1633.                                 | ___________________________✓|
  1634.                         buf + 12|  cluster size (in sectors)|
  1635.                                 | ___________________________✓|
  1636.         
  1637.              BUGS
  1638.              Incredibly slow (5-10 seconds) on a hard disk.
  1639.         
  1640.         
  1641.         
  1642.         
  1643.         
  1644.         
  1645.         
  1646.         
  1647.         
  1648.         4/4/86 Dyer                                     Atari GEMDOS
  1649.         
  1650.         
  1651.         
  1652.         
  1653.         
  1654.         
  1655.         
  1656.         ~/text/gemdos/funcs              File System Calls    ( 13 )
  1657.         
  1658.         
  1659.         _________________________________
  1660.         |0x39 Dcreate - Create Directory|
  1661.         |✓_✓|_______________________________|✓_✓|
  1662.              WORD Dcreate(pathname)
  1663.              char *pathname;
  1664.         
  1665.                   Create a  directory.   `pathname'  points  to  a  null-
  1666.              terminated  string specifying the pathname of the new direc-
  1667.              tory.
  1668.         
  1669.              RETURNS
  1670.                   0 on success;
  1671.                   ERROR or appropriate error number on failure.
  1672.         
  1673.         
  1674.         
  1675.         _________________________________
  1676.         |0x3A Ddelete - Delete Directory|
  1677.         |✓_✓|_______________________________|✓_✓|
  1678.              WORD Ddelete(pathname)
  1679.              char *pathname;
  1680.         
  1681.                   Delete a directory (it must be empty,  except  for  the
  1682.              special  directories  "." and "..").  `pathname' points to a
  1683.              null-terminated string specifying the pathname of the direc-
  1684.              tory to remove.
  1685.         
  1686.              RETURNS
  1687.                   0 on success;
  1688.                   ERROR or appropriate error number on failure.
  1689.         
  1690.         
  1691.         
  1692.         _______________________________________
  1693.         |0x3B Dsetpath - Set Current Directory|
  1694.         |✓_✓|_____________________________________|✓_✓|
  1695.              WORD Dsetpath(path)
  1696.              char *path;
  1697.         
  1698.                   Set the current to `path',  a  null-terminated  string.
  1699.              If  the path begins with a drive letter and a colon, set the
  1700.              current directory on the specified drive.
  1701.         
  1702.                   A current directory is kept for each drive in the  sys-
  1703.              tem.
  1704.         
  1705.              RETURNS
  1706.                   0 for success;
  1707.                   ERROR or an appropriate error number.
  1708.         
  1709.         
  1710.         
  1711.         
  1712.         
  1713.         
  1714.         4/4/86 Dyer                                     Atari GEMDOS
  1715.         
  1716.         
  1717.         
  1718.         
  1719.         
  1720.         
  1721.         
  1722.         ~/text/gemdos/funcs              File System Calls    ( 14 )
  1723.         
  1724.         
  1725.         ____________________________
  1726.         |0x3C Fcreate - Create File|
  1727.         |✓_✓|__________________________|✓_✓|
  1728.              WORD Fcreate(fname, attribs)
  1729.              char *fname;
  1730.              WORD attribs;
  1731.         
  1732.                   Create a file `fname'  and  return  a  write-only  non-
  1733.              standard  handle to it.  The attribute word is stored in the
  1734.              directory entry; its bit assignments are:
  1735.                      ___________________________________________
  1736.                     |__✓m_✓a_✓s_✓k_______________✓d_✓e_✓s_✓c_✓r_✓i_✓p_✓t_✓i_✓o_✓n_____________✓|
  1737.                     | 0x01|  file set to read-only             |
  1738.                     | 0x02|  file hidden from directory search |
  1739.                     | 0x04|  file set to "system"              |
  1740.                     | 0x08|  file contains 11-byte volume label|
  1741.                     |______✓|_____________________________________✓|
  1742.         
  1743.              RETURNS
  1744.                   a positive number, a handle, or:
  1745.                   ERROR or an appropriate error number.
  1746.         
  1747.              BUGS
  1748.                   Useless feature department: If the `read-only'  bit  is
  1749.              set,  a  write-only handle is returned, and the handle can't
  1750.              be written to.
  1751.         
  1752.                   Ideally, only one volume  label  is  permitted  in  the
  1753.              volume's  root  directory.   GEMDOS  doesn't  enforce  this,
  1754.              though, which could cause confusion.
  1755.         
  1756.         
  1757.         
  1758.         
  1759.         
  1760.         
  1761.         
  1762.         
  1763.         
  1764.         
  1765.         
  1766.         
  1767.         
  1768.         
  1769.         
  1770.         
  1771.         
  1772.         
  1773.         
  1774.         
  1775.         
  1776.         
  1777.         
  1778.         
  1779.         
  1780.         4/4/86 Dyer                                     Atari GEMDOS
  1781.         
  1782.         
  1783.         
  1784.         
  1785.         
  1786.         
  1787.         
  1788.         ~/text/gemdos/funcs              File System Calls    ( 15 )
  1789.         
  1790.         
  1791.         ________________________
  1792.         |0x3D Fopen - Open File|
  1793.         |✓_✓|______________________|✓_✓|
  1794.              WORD Fopen(fname, mode)
  1795.              char *fname;
  1796.              WORD mode;
  1797.         
  1798.                   Open the `fname' according  to  `mode',  and  return  a
  1799.              non-standard handle to it.  The open mode can be:
  1800.                                 ______________________
  1801.                                |__✓m_✓o_✓d_✓e_✓|____✓d_✓e_✓s_✓c_✓r_✓i_✓p_✓t_✓i_✓o_✓n__✓|
  1802.                                |    0|  read only    |
  1803.                                |    1|  write only   |
  1804.                                |    2|  read or write|
  1805.                                |______✓|________________✓|
  1806.         
  1807.              RETURNS
  1808.                   a positive number, a handle, or:
  1809.                   a negative error number.
  1810.         
  1811.         
  1812.         
  1813.         __________________________
  1814.         |0x3E Fclose - Close File|
  1815.         |✓_✓|________________________|✓_✓|
  1816.              WORD Fclose(handle)
  1817.              WORD handle;
  1818.         
  1819.                   Close the file associated with the handle.
  1820.         
  1821.              RETURNS
  1822.                   0 on success;
  1823.                   ERROR or an appropriate error number.
  1824.         
  1825.         
  1826.         
  1827.         ________________________________
  1828.         |0x3F Fread - Read From File   |
  1829.         |✓_✓|______________________________|✓_✓|
  1830.              LONG Fread(handle, count, buffer)
  1831.              WORD handle;
  1832.              LONG count;
  1833.              char *buffer;
  1834.         
  1835.                   Read from a file.  From the file referred to  by  `han-
  1836.              dle' read `count' bytes into memory starting at `buffer'.
  1837.         
  1838.              RETURNS
  1839.                   the number of bytes actually read, or:
  1840.                   0 on end of file, or:
  1841.                   a negative error number.
  1842.         
  1843.         
  1844.         
  1845.         
  1846.         4/4/86 Dyer                                     Atari GEMDOS
  1847.         
  1848.         
  1849.         
  1850.         
  1851.         
  1852.         
  1853.         
  1854.         ~/text/gemdos/funcs              File System Calls    ( 16 )
  1855.         
  1856.         
  1857.         _____________________________
  1858.         |0x40 Fwrite - Write To File|
  1859.         |✓_✓|___________________________|✓_✓|
  1860.              LONG Fwrite(handle, count, buffer)
  1861.              WORD handle;
  1862.              LONG count;
  1863.              char *buffer;
  1864.         
  1865.                   Write to a file.   Write  `count'  bytes  from  memory,
  1866.              starting at `buffer', to the file referred to by `handle'.
  1867.         
  1868.              RETURNS
  1869.                   the number of bytes actually written, or:
  1870.                   a negative error number.
  1871.         
  1872.         
  1873.         
  1874.         ____________________________
  1875.         |0x41 Fdelete - Delete File|
  1876.         |✓_✓|__________________________|✓_✓|
  1877.              WORD Fdelete(fname)
  1878.              char *fname;
  1879.         
  1880.                   Delete the file `fname'.
  1881.         
  1882.              RETURNS
  1883.                   0, success, or:
  1884.                   a negative error number.
  1885.         
  1886.         
  1887.         
  1888.         
  1889.         
  1890.         
  1891.         
  1892.         
  1893.         
  1894.         
  1895.         
  1896.         
  1897.         
  1898.         
  1899.         
  1900.         
  1901.         
  1902.         
  1903.         
  1904.         
  1905.         
  1906.         
  1907.         
  1908.         
  1909.         
  1910.         
  1911.         
  1912.         4/4/86 Dyer                                     Atari GEMDOS
  1913.         
  1914.         
  1915.         
  1916.         
  1917.         
  1918.         
  1919.         
  1920.         ~/text/gemdos/funcs              File System Calls    ( 17 )
  1921.         
  1922.         
  1923.         ________________________________
  1924.         |0x42 Fseek - Seek File Pointer|
  1925.         |✓_✓|______________________________|✓_✓|
  1926.              LONG Fseek(offset, handle, seekmode)
  1927.              LONG offset;
  1928.              WORD handle;
  1929.              WORD seekmode;
  1930.         
  1931.                   Set the current position  within  the  file  associated
  1932.              with `handle'.  `offset' is a signed number; positive values
  1933.              move toward the end of the file, and  negative  values  move
  1934.              toward its beginning.  `seekmode' can be:
  1935.                       _________________________________________
  1936.                      |__✓s_✓e_✓e_✓k_✓m_✓o_✓d_✓e______✓M_✓o_✓v_✓e_✓s__✓`_✓o_✓f_✓f_✓s_✓e_✓t_✓'__✓b_✓y_✓t_✓e_✓s__✓._✓._✓.___✓|
  1937.                      |    0    |  from beginning of file      |
  1938.                      |    1    |  relative to current position|
  1939.                      |    2    |  from end of file            |
  1940.                      |__________✓|_______________________________✓|
  1941.         
  1942.              RETURNS
  1943.                   The current, absolute position in the file.
  1944.         
  1945.         
  1946.         
  1947.         ________________________________________
  1948.         |0x43 Fattrib - Get/Set File Attributes|
  1949.         |✓_✓|______________________________________|✓_✓|
  1950.              WORD Fattrib(fname, wflag, attribs)
  1951.              char *fname;
  1952.              WORD wflag;
  1953.              WORD attribs;
  1954.         
  1955.                   Get or set a file's attribute bits.  `fname' points  to
  1956.              a null-terminated pathname.  If `wflag' is 1, set the file's
  1957.              attributes from `attribs' (no return value).  If `wflag'  is
  1958.              0, return the file's attributes.
  1959.         
  1960.                   The attribute bits are:
  1961.                     _____________________________________________
  1962.                    |__✓m_✓a_✓s_✓k________________✓d_✓e_✓s_✓c_✓r_✓i_✓p_✓t_✓i_✓o_✓n______________✓|
  1963.                    | 0x01|  file is read-only                   |
  1964.                    | 0x02|  file hidden from directory search   |
  1965.                    | 0x04|  file set to "system"                |
  1966.                    | 0x08|  file contains 11-byte volume label  |
  1967.                    | 0x10|  file is a subdirectory              |
  1968.                    | 0x20|  file has been written to and closed.|
  1969.                    |______✓|_______________________________________✓|
  1970.         
  1971.              BUGS
  1972.                   The "archive" bit, 0x20, doesn't seem to work as adver-
  1973.              tised.
  1974.         
  1975.         
  1976.         
  1977.         
  1978.         4/4/86 Dyer                                     Atari GEMDOS
  1979.         
  1980.         
  1981.         
  1982.         
  1983.         
  1984.         
  1985.         
  1986.         ~/text/gemdos/funcs              File System Calls    ( 18 )
  1987.         
  1988.         
  1989.         ___________________________________
  1990.         |0x45 Fdup - Duplicate File Handle|
  1991.         |✓_✓|_________________________________|✓_✓|
  1992.              WORD Fdup(handle)
  1993.              WORD handle;
  1994.         
  1995.                   The handle `handle' must be a standard  handle  (0..5);
  1996.              Fdup()  returns a non-standard handle (greater than or equal
  1997.              to 6) that refers to the same file.
  1998.         
  1999.              RETURNS
  2000.                   a handle, or:
  2001.                   EIHNDL - not a standard handle
  2002.                   ENHNDL - no more standard handles available
  2003.         
  2004.         
  2005.         
  2006.         _________________________________
  2007.         |0x46 Fforce - Force File Handle|
  2008.         |✓_✓|_______________________________|✓_✓|
  2009.              Fforce(stdh, nonstdh)
  2010.              WORD stdh;
  2011.              WORD nonstdh;
  2012.         
  2013.                   Force the standard handle `stdh' to point to  the  same
  2014.              file or device as the non-standard handle `nonstdh.'
  2015.         
  2016.              RETURNS
  2017.                   OK, or:
  2018.                   EIHNDL - invalid handle
  2019.         
  2020.         
  2021.         
  2022.         _______________________________________
  2023.         |0x47 Dgetpath - Get Current Directory|
  2024.         |✓_✓|_____________________________________|✓_✓|
  2025.              void Dgetpath(buf, driveno)
  2026.              char *buf;
  2027.              WORD driveno;
  2028.         
  2029.                   The current directory for the specified drive `driveno'
  2030.              is copied into `buf'.  The drive number is 1-based: 0 speci-
  2031.              fies the default drive, 1 specifies A:, and so on.
  2032.         
  2033.              BUGS
  2034.                   The maximum size of a pathname is not  limited  by  the
  2035.              system; it is up to the application to provide enough buffer
  2036.              space.  128 bytes should be enough for 8 or 9 levels of sub-
  2037.              directories.
  2038.         
  2039.         
  2040.         
  2041.         
  2042.         
  2043.         
  2044.         4/4/86 Dyer                                     Atari GEMDOS
  2045.         
  2046.         
  2047.         
  2048.         
  2049.         
  2050.         
  2051.         
  2052.         ~/text/gemdos/funcs              File System Calls    ( 19 )
  2053.         
  2054.         
  2055.         _______________________________
  2056.         |0x48 Malloc - Allocate Memory|
  2057.         |✓_✓|_____________________________|✓_✓|
  2058.              LONG Malloc(amount)
  2059.              LONG amount;
  2060.         
  2061.                   If `amount' is -1L ($FFFFFFFF) return the size  of  the
  2062.              largest free block in the system.
  2063.         
  2064.                   Otherwise, if `amount' is not -1L, attempt to  allocate
  2065.              `amount' bytes for the current process.  Return a pointer to
  2066.              the beginning of the block or NULL if there is no free block
  2067.              large enough to meet the request.
  2068.         
  2069.              BUGS
  2070.              WARNING
  2071.                   A process may not have,  at  any  time,  more  than  20
  2072.              blocks of Malloc()'d memory.  Exceeding this limit may crip-
  2073.              ple GEMDOS.  [It is OK to do many Malloc() calls if they are
  2074.              followed  by  matching  Mfree() calls; the limit of 20 is to
  2075.              the number of fragments a process may generate.]
  2076.         
  2077.         
  2078.         
  2079.         _____________________________
  2080.         |0x49 Mfree - Release Memory|
  2081.         |✓_✓|___________________________|✓_✓|
  2082.              WORD Mfree(saddr)
  2083.              LONG saddr;
  2084.         
  2085.                   Free the block of memory starting at `saddr'; the block
  2086.              must be one that was returned by Malloc().
  2087.         
  2088.              RETURNS
  2089.                   0 if the release was successful, or:
  2090.                   ERROR or an appropriate error number.
  2091.         
  2092.         
  2093.         
  2094.         
  2095.         
  2096.         
  2097.         
  2098.         
  2099.         
  2100.         
  2101.         
  2102.         
  2103.         
  2104.         
  2105.         
  2106.         
  2107.         
  2108.         
  2109.         
  2110.         4/4/86 Dyer                                     Atari GEMDOS
  2111.         
  2112.         
  2113.         
  2114.         
  2115.         
  2116.         
  2117.         
  2118.         ~/text/gemdos/funcs              File System Calls    ( 20 )
  2119.         
  2120.         
  2121.         _______________________________________________
  2122.         |0x4A Mshrink - Shrink Size of Allocated Block|
  2123.         |✓_✓|_____________________________________________|✓_✓|
  2124.              WORD Mshrink(0, block, newsiz)
  2125.              (WORD) 0;
  2126.              LONG block;
  2127.              LONG newsiz;
  2128.         
  2129.                   Shrink the  size  of  an  allocated  block  of  memory;
  2130.              `block'  points  to  a process basepage or a piece of memory
  2131.              allocated by Malloc(), `newsiz'  is  the  new  size  of  the
  2132.              block.
  2133.         
  2134.                   The first argument must be a WORD of zero.
  2135.         
  2136.         
  2137.              RETURNS
  2138.                   0 if the size adjustment was successful, or:
  2139.                   EIMBA - invalid memory block address
  2140.                   EGSBF - setblock failure due to growth restrictions
  2141.         
  2142.              BUGS
  2143.                   A block can only be shrunk; `newsiz' must be less  than
  2144.              or equal to the current block size.
  2145.         
  2146.         
  2147.         
  2148.         
  2149.         
  2150.         
  2151.         
  2152.         
  2153.         
  2154.         
  2155.         
  2156.         
  2157.         
  2158.         
  2159.         
  2160.         
  2161.         
  2162.         
  2163.         
  2164.         
  2165.         
  2166.         
  2167.         
  2168.         
  2169.         
  2170.         
  2171.         
  2172.         
  2173.         
  2174.         
  2175.         
  2176.         4/4/86 Dyer                                     Atari GEMDOS
  2177.         
  2178.         
  2179.         
  2180.         
  2181.         
  2182.         
  2183.         
  2184.         ~/text/gemdos/funcs              File System Calls    ( 21 )
  2185.         
  2186.         
  2187.         ___________________________________
  2188.         |0x4B Pexec - Load/Execute Process|
  2189.         |✓_✓|_________________________________|✓_✓|
  2190.              WORD Pexec(mode, ptr1, ptr2, ptr3)
  2191.              WORD mode;
  2192.              char *ptr1;
  2193.              char *ptr2;
  2194.              char *ptr3;
  2195.         
  2196.                   This function wears several hats, according to the flag
  2197.              `mode':
  2198.                  ____________________________________________________
  2199.                 |                |                                  |
  2200.                 |_______✓m_✓o_✓d_✓e_______✓|_____✓p_✓t_✓r_✓1________✓p_✓t_✓r_✓2_________✓p_✓t_✓r_✓3____✓|
  2201.                 |   0 = load & go|    file  |  command |  enviroment|
  2202.                 |                |  to exec |    tail  |    string  |
  2203.                 |_________________✓|___________✓|___________✓|_____________✓|
  2204.                 | 3 = load, no go|    file  |  command |  enviroment|
  2205.                 |                |  to load |    tail  |    string  |
  2206.                 |_________________✓|___________✓|___________✓|_____________✓|
  2207.                 |     4 = just go|  basepage|  (unused)|   (unused) |
  2208.                 |                |  address |          |            |
  2209.                 |_________________✓|___________✓|___________✓|_____________✓|
  2210.                 |      5 = create|  (unused)|  command |  enviroment|
  2211.                 |        basepage|          |    tail  |    string  |
  2212.                 |✓|________________|✓_✓|___________✓|___________✓|____________|✓_✓|
  2213.         
  2214.                   The file to load or exec, `ptr1', and the command tail,
  2215.              `ptr2',   are  null-terminated  pathnames.   The  enviroment
  2216.              string, `ptr3', is either NULL  (0L),  or  a  pointer  to  a
  2217.              string structure of the form:
  2218.         
  2219.                                      "string1\0"
  2220.                                      "string2\0"
  2221.                                      ... etc. ...
  2222.                                      "stringN\0"
  2223.                                         "\0"
  2224.         
  2225.                   The enviroment string is any number of  null-terminated
  2226.              strings,  with  an  empty string (a single null) at the end.
  2227.              If `ptr3' is NULL, then the process inherits a copy  of  the
  2228.              parent's enviroment string.
  2229.         
  2230.                   Load-and-go (mode 0) will load the specified file, set-
  2231.              up  its  basepage,  and  execute it.  Pexec()'s return value
  2232.              will be the child process's  exit  code  (see  Pterm0()  and
  2233.              Pterm()).
  2234.         
  2235.                   Load-nogo will  load  the  specified  file,  setup  its
  2236.              basepage,  and return a pointer to the basepage; the process
  2237.              is not executed.
  2238.         
  2239.                   Just-go is passed a pointer to a basepage.  The process
  2240.         
  2241.         
  2242.         4/4/86 Dyer                                     Atari GEMDOS
  2243.         
  2244.         
  2245.         
  2246.         
  2247.         
  2248.         
  2249.         
  2250.         ~/text/gemdos/funcs              File System Calls    ( 22 )
  2251.         
  2252.         
  2253.              starts  executing at the base of its text segment, as speci-
  2254.              fied in the basepage.
  2255.         
  2256.                   Create-basepage will allocate the largest free block of
  2257.              memory and create most of a basepage for it.  (Some entries,
  2258.              most significantly the text/data/bss size and  base  values,
  2259.              are  NOT  setup -- the caller is responsible for maintaining
  2260.              them).
  2261.         
  2262.                   A child process inherits  the  parent's  standard  file
  2263.              descriptors;  effectively  doing  an  Fdup() and an Fforce()
  2264.              call on handles 0 through 5.
  2265.         
  2266.                   Since system resources are allocated when a basepage is
  2267.              created,  the spawned process MUST be terminated in order to
  2268.              release them.  This is especially important when using over-
  2269.              lays;  see  the  [Pexec cookbook] for details on use of Pex-
  2270.              ec().
  2271.         
  2272.         
  2273.         
  2274.         ________________________________
  2275.         |0x4C Pterm - Terminate Process|
  2276.         |✓_✓|______________________________|✓_✓|
  2277.              void Pterm(retcode)
  2278.              WORD retcode;
  2279.         
  2280.                   Terminate the current process, closing all  open  files
  2281.              and releasing any allocated memory.  Return `retcode' to the
  2282.              parent process.
  2283.         
  2284.         
  2285.         
  2286.         
  2287.         
  2288.         
  2289.         
  2290.         
  2291.         
  2292.         
  2293.         
  2294.         
  2295.         
  2296.         
  2297.         
  2298.         
  2299.         
  2300.         
  2301.         
  2302.         
  2303.         
  2304.         
  2305.         
  2306.         
  2307.         
  2308.         4/4/86 Dyer                                     Atari GEMDOS
  2309.         
  2310.         
  2311.         
  2312.         
  2313.         
  2314.         
  2315.         
  2316.         ~/text/gemdos/funcs              File System Calls    ( 23 )
  2317.         
  2318.         
  2319.         _____________________________
  2320.         |0x4E Fsfirst - Search First|
  2321.         |✓_✓|___________________________|✓_✓|
  2322.              WORD Fsfirst(fspec, attribs)
  2323.              char *fspec;
  2324.              WORD attribs;
  2325.         
  2326.                   Search for the first occurrence of  the  file  `fspec'.
  2327.              The  file  specification may contain wildcards (`?' and `*')
  2328.              in the simple filename, but not in the  path  specification.
  2329.              `attrib'  controls  which files are returned by Fsfirst; its
  2330.              format is described in the documentation on  `Fattrib()'.
  2331.         
  2332.                   If  `attrib'  is  zero,  then  only  normal  files  are
  2333.              searched for (no volume labels, hidden files, subdirectories
  2334.              or system files are returned).  If `attrib' is set for  hid-
  2335.              den  or  system  files, they are included in the search set.
  2336.              If `attrib' is set for volume labels, only volume labels are
  2337.              returned.
  2338.         
  2339.                   When a file is found, a 44-byte structure is written to
  2340.              the location pointed to by the DTA:
  2341.                      ___________________________________________
  2342.                     | offset     size           contents       |
  2343.                     |___________________________________________✓|
  2344.                     |   0-20|          |  (reserved)           |
  2345.                     |     21|  byte    |  file attribute bits  |
  2346.                     |     22|  word    |  time stamp           |
  2347.                     |     24|  word    |  date stamp           |
  2348.                     |     26|  long    |  file size            |
  2349.                     |     30|  14 bytes|  file name + extension|
  2350.                     |________✓|___________✓|________________________✓|
  2351.         
  2352.                   The filename and extension is null-terminated, and con-
  2353.              tains no spaces.
  2354.         
  2355.              RETURNS
  2356.                   0, if a file was found, or:
  2357.                   EFILNF - file not found (no matches), or:
  2358.                   an appropriate error number.
  2359.         
  2360.         
  2361.         
  2362.         
  2363.         
  2364.         
  2365.         
  2366.         
  2367.         
  2368.         
  2369.         
  2370.         
  2371.         
  2372.         
  2373.         
  2374.         4/4/86 Dyer                                     Atari GEMDOS
  2375.         
  2376.         
  2377.         
  2378.         
  2379.         
  2380.         
  2381.         
  2382.         ~/text/gemdos/funcs              File System Calls    ( 24 )
  2383.         
  2384.         
  2385.         ___________________________
  2386.         |0x4F Fsnext - Search Next|
  2387.         |✓_✓|_________________________|✓_✓|
  2388.              WORD Fsnext()
  2389.         
  2390.                   Search for the next occurrence of a file.   (The  first
  2391.              occurrence  should  be  searched for with Fsfirst()).  Bytes
  2392.              0-20 of the DTA must remain unmodified  from  the  Fsfirst()
  2393.              call or the most recent Fsnext() call.
  2394.         
  2395.              RETURNS
  2396.                   0 if a file was found, or:
  2397.                   ENMFIL - no more files were found, or:
  2398.                   an appropriate error number.
  2399.         
  2400.         
  2401.         
  2402.         ____________________________
  2403.         |0x56 Frename - Rename File|
  2404.         |✓_✓|__________________________|✓_✓|
  2405.              WORD Frename(0, oldname, newname)
  2406.              (WORD) 0;
  2407.              char *oldname;
  2408.              char *newname;
  2409.         
  2410.                   Rename a file from `oldname' to `newname'.  The  desti-
  2411.              nation  file must not exist.  The new file may be in another
  2412.              directory.
  2413.         
  2414.                   The first argument must be a zero WORD.
  2415.         
  2416.              RETURNS
  2417.                   EACCDN - destination file already exists;
  2418.                   EPTHNF - `oldname' not found;
  2419.                   ENSAME - `newname' not on save drive;
  2420.                   or an appropriate error.
  2421.         
  2422.         
  2423.         
  2424.         
  2425.         
  2426.         
  2427.         
  2428.         
  2429.         
  2430.         
  2431.         
  2432.         
  2433.         
  2434.         
  2435.         
  2436.         
  2437.         
  2438.         
  2439.         
  2440.         4/4/86 Dyer                                     Atari GEMDOS
  2441.         
  2442.         
  2443.         
  2444.         
  2445.         
  2446.         
  2447.         
  2448.         ~/text/gemdos/funcs              File System Calls    ( 25 )
  2449.         
  2450.         
  2451.         _______________________________________
  2452.         |0x57 Fdatime - Get/Set File Timestamp|
  2453.         |✓_✓|_____________________________________|✓_✓|
  2454.              void Fdatime(handle, timeptr, wflag)
  2455.              WORD handle;
  2456.              LONG timeptr;
  2457.              WORD wflag;
  2458.         
  2459.                   The file is referred to by `handle'.  `timeptr'  points
  2460.              to  two  words  containing  the DOS formatted timestamp (the
  2461.              time word is first, the date word is second).  If `wflag' is
  2462.              1,  set  the file's timestamp from `timeptr', otherwise read
  2463.              the file's timestamp into `timeptr'.
  2464.         
  2465.         
  2466.         
  2467.         
  2468.         
  2469.         
  2470.         
  2471.         
  2472.         
  2473.         
  2474.         
  2475.         
  2476.         
  2477.         
  2478.         
  2479.         
  2480.         
  2481.         
  2482.         
  2483.         
  2484.         
  2485.         
  2486.         
  2487.         
  2488.         
  2489.         
  2490.         
  2491.         
  2492.         
  2493.         
  2494.         
  2495.         
  2496.         
  2497.         
  2498.         
  2499.         
  2500.         
  2501.         
  2502.         
  2503.         
  2504.         
  2505.         
  2506.         4/4/86 Dyer                                     Atari GEMDOS
  2507.         
  2508.         
  2509.         
  2510.         
  2511.         
  2512.         
  2513.         
  2514.         ~/text/gemdos/prg                  Executable Files    ( 1 )
  2515.         
  2516.         
  2517.         _✓E_✓X_✓E_✓C_✓U_✓T_✓A_✓B_✓L_✓E _✓F_✓I_✓L_✓E_✓S
  2518.              An executable file consists of  a  header  followed  by
  2519.         images  for  the text and data segments, zero or more symbol
  2520.         table entries, a  fixup  offset,  and  zero  or  more  fixup
  2521.         records:
  2522.         
  2523.                            Executable File Parts
  2524.         
  2525.                             ___________________
  2526.                            |    file header   |
  2527.                            |___________________✓|
  2528.                            |                  |
  2529.                            |   text segment   |
  2530.                            |                  |
  2531.                            |___________________✓|
  2532.                            |   data segment   |
  2533.                            |___________________✓|
  2534.                            |      symbols     |
  2535.                            |                  |
  2536.                            |___________________✓|
  2537.                            | fixup information|
  2538.                            |✓|__________________|✓_✓|
  2539.         
  2540.         
  2541.              The file header contains a "magic" number (a  signature
  2542.         to indicate that it is an executable file) and several long-
  2543.         words containing size information:
  2544.         
  2545.                            Executable File Header
  2546.         
  2547.                  _________________________________________
  2548.                 |__✓O_✓f_✓f_✓s_✓e_✓t_✓|___✓S_✓i_✓z_✓e_✓|_________✓D_✓e_✓s_✓c_✓r_✓i_✓p_✓t_✓i_✓o_✓n_______✓|
  2549.                 | 0x00  |  word|  0x601A (magic number)  |
  2550.                 | 0x02  |  long|  Size of text segment   |
  2551.                 | 0x06  |  long|  Size of data segment   |
  2552.                 | 0x0A  |  long|  Size of BSS segment    |
  2553.                 | 0x0E  |  long|  Size of symbol table   |
  2554.                 | 0x12  |  long|  (reserved)             |
  2555.                 | 0x16  |  long|  (reserved)             |
  2556.                 | 0x1A  |  long|  (reserved)             |
  2557.                 | 0x1E  |      |  (start of text segment)|
  2558.                 |________✓|_______✓|__________________________✓|
  2559.         
  2560.         
  2561.              The text and data segment images immediately follow the
  2562.         header.  The symbol table, if there is one, follows the data
  2563.         segment.
  2564.         
  2565.              GEMDOS will "fix up" a longword in  the  text  or  data
  2566.         segments by adding the base of the text segment to the value
  2567.         already in the longword.  The  fixup  list  specifies  which
  2568.         longwords need to be relocated.  The first item in the fixup
  2569.         list is a longword specifying the offset of the first fixup;
  2570.         
  2571.         
  2572.         4/4/86 Dyer                                     Atari GEMDOS
  2573.         
  2574.         
  2575.         
  2576.         
  2577.         
  2578.         
  2579.         
  2580.         ~/text/gemdos/prg                  Executable Files    ( 2 )
  2581.         
  2582.         
  2583.         the  longword  is  NULL (0L) if there are no fixups.  Single
  2584.         bytes following the longword specify offsets to more fixups.
  2585.         The  longwords  _✓m_✓u_✓s_✓t start on word boundaries, or the system
  2586.         will crash.
  2587.         
  2588.                               Relocation Bytes
  2589.         
  2590.           _______________________________________________________
  2591.          |______✓B_✓y_✓t_✓e_____✓|________________✓D_✓e_✓s_✓c_✓r_✓i_✓p_✓t_✓i_✓o_✓n_______________✓|
  2592.          | 0           |  end of relocation information         |
  2593.          | 1           |  advance 254 bytes, get next byte      |
  2594.          | 2, 4, .. 254|  fixup longword at location pointer    |
  2595.          | 3, 5, .. 255|  (odd numbers, reserved for future use)|
  2596.          |______________✓|_________________________________________✓|
  2597.         
  2598.         
  2599.         
  2600.         
  2601.         
  2602.         
  2603.         
  2604.         
  2605.         
  2606.         
  2607.         
  2608.         
  2609.         
  2610.         
  2611.         
  2612.         
  2613.         
  2614.         
  2615.         
  2616.         
  2617.         
  2618.         
  2619.         
  2620.         
  2621.         
  2622.         
  2623.         
  2624.         
  2625.         
  2626.         
  2627.         
  2628.         
  2629.         
  2630.         
  2631.         
  2632.         
  2633.         
  2634.         
  2635.         
  2636.         
  2637.         
  2638.         4/4/86 Dyer                                     Atari GEMDOS
  2639.         
  2640.         
  2641.         
  2642.         
  2643.         
  2644.         
  2645.         
  2646.         ~/text/gemdos/prg                  Executable Files    ( 3 )
  2647.         
  2648.         
  2649.         _✓S_✓Y_✓M_✓B_✓O_✓L _✓T_✓A_✓B_✓L_✓E
  2650.              The symbol table consists of symbol-table entries, for-
  2651.         matted as:
  2652.         
  2653.                              Symbol Table Entry
  2654.         
  2655.                             ___________________
  2656.                            |                  |
  2657.                            |                  |
  2658.                            |      8 bytes     |
  2659.                            |    symbol name   |
  2660.                            |___________________✓|
  2661.                            | WORD symbol type |
  2662.                            |___________________✓|
  2663.                            | LONG symbol value|
  2664.                            |                  |
  2665.                            |✓|__________________|✓_✓|
  2666.         
  2667.         
  2668.         <<<explain about symbol types here.  It's really pretty sim-
  2669.         ple...>>>
  2670.                           Values for Symbol Types
  2671.         
  2672.                      _________________________________
  2673.                     |___________✓T_✓y_✓p_✓e__________✓|___✓V_✓a_✓l_✓u_✓e__✓|
  2674.                     | defined               |  0x8000|
  2675.                     | equated               |  0x4000|
  2676.                     | global                |  0x2000|
  2677.                     | equated register      |  0x1000|
  2678.                     | external reference    |  0x0800|
  2679.                     | data based relocatable|  0x0400|
  2680.                     | text based relocatable|  0x0200|
  2681.                     | BSS based relocatable |  0x0100|
  2682.                     |________________________✓|_________✓|
  2683.         
  2684.         
  2685.         
  2686.         
  2687.         
  2688.         
  2689.         
  2690.         
  2691.         
  2692.         
  2693.         
  2694.         
  2695.         
  2696.         
  2697.         
  2698.         
  2699.         
  2700.         
  2701.         
  2702.         
  2703.         
  2704.         4/4/86 Dyer                                     Atari GEMDOS
  2705.         
  2706.         
  2707.         
  2708.         
  2709.         
  2710.         
  2711.         
  2712.         ~/text/gemdos/diskstruct           Volume Structure    ( 1 )
  2713.         
  2714.         
  2715.         _✓V_✓O_✓L_✓U_✓M_✓E _✓O_✓R_✓G_✓A_✓N_✓I_✓Z_✓A_✓T_✓I_✓O_✓N
  2716.              GEMDOS uses the first few sectors of a disk to indicate
  2717.         where  files  are  stored.   A  volume usually contains five
  2718.         parts; an optional boot sector, two identical FAT tables,  a
  2719.         root directory, and a cluster area.
  2720.         
  2721.              When GEMDOS first accesses a  drive  (or  accesses  one
  2722.         after a media change), it makes a `GETBPB' (Get BIOS Parame-
  2723.         ter Block) BIOS call to determine how big these  areas  are,
  2724.         and  where  they  are  stored on the disk.  GETBPB returns a
  2725.         pointer to a nine-word structure.  From this structure, GEM-
  2726.         DOS  can puzzle out where the various parts of the file sys-
  2727.         tem are.
  2728.         
  2729.                          BIOS Parameter Block (BPB)
  2730.         
  2731.             ___________________________________________________
  2732.            |___✓n_✓a_✓m_✓e__✓|___✓v_✓a_✓l_✓u_✓e_✓|_______________✓f_✓u_✓n_✓c_✓t_✓i_✓o_✓n_____________✓|
  2733.            | recsiz|  512  |  physical sector size in bytes   |
  2734.            |  clsiz|  2    |  cluster size in sectors         |
  2735.            | clsizb|  1024 |  cluster size in bytes           |
  2736.            |  rdlen|       |  root directory length in sectors|
  2737.            |   fsiz|       |  FAT size, in sectors            |
  2738.            | fatrec|       |  sector# of 1st sector of 2nd FAT|
  2739.            | datrec|       |  sector# of 1st data sector      |
  2740.            |  numcl|       |  number of data clusters on disk |
  2741.            | bflags|       |  flags                           |
  2742.            |________✓|________✓|___________________________________✓|
  2743.         
  2744.         
  2745.                  RECSIZ indicates the number of bytes per physi-
  2746.             cal  sector;  this must be 512 with the current GEM-
  2747.             DOS.  CLSIZ indicates the number  of  sectors  in  a
  2748.             cluster;  this  must  be  2  in  the current GEMDOS.
  2749.             CLSIZB is the number of bytes in  a  cluster,  which
  2750.             must be 1024.
  2751.         
  2752.                  RDLEN is the size of  the  root  directory,  in
  2753.             sectors.   A  directory  entry uses 32 bytes, so the
  2754.             number of root files available is RDLEN * 512 / 32.
  2755.         
  2756.                  FSIZ is the size of each FAT in  sectors.   FA-
  2757.             TREC is the starting sector number of the first sec-
  2758.             tor of the /second/ FAT.
  2759.         
  2760.                  DATREC is the starting  sector#  of  the  first
  2761.             cluster.   NUMCL  is  the  number of clusters on the
  2762.             device.
  2763.         
  2764.                  BFLAGS was  supposed  to  be  a  bit-vector  of
  2765.             flags.  Currently only bit 0 is being used; when set
  2766.             it indicates that 16-bit  FAT  entries  (instead  of
  2767.             12-bit ones) are to be used.
  2768.         
  2769.         
  2770.         4/4/86 Dyer                                     Atari GEMDOS
  2771.         
  2772.         
  2773.         
  2774.         
  2775.         
  2776.         
  2777.         
  2778.         ~/text/gemdos/diskstruct           Volume Structure    ( 2 )
  2779.         
  2780.         
  2781.              If there are boot sectors, they occupy logical  sectors
  2782.         0  through  FATREC  -  FSIZ  -  1.  The second FAT starts at
  2783.         FATREC, and the first FAT starts at FATREC - FSIZ.  The root
  2784.         directory  starts  at  FATREC  + FSIZ, and the first cluster
  2785.         starts at DATREC.  The cluster region is where the data  for
  2786.         all files on the volume is kept.
  2787.         
  2788.         
  2789.         
  2790.         
  2791.         
  2792.         
  2793.         
  2794.         _✓D_✓I_✓R_✓E_✓C_✓T_✓O_✓R_✓Y _✓E_✓N_✓T_✓R_✓I_✓E_✓S
  2795.              A directory entry contains a filename, some flags,  the
  2796.         file's  creation  time  and  date,  the file's size, and the
  2797.         file's starting cluster number.  The entry itself is  a  32-
  2798.         byte structure that looks like:
  2799.         
  2800.                               Directory Entry
  2801.         
  2802.                           ________________________
  2803.                          |                       |
  2804.                          |      8-character      |
  2805.                          |      primary name     |
  2806.                          |                       |
  2807.                          |________________________✓|
  2808.                          |      3-character      |
  2809.                          |       extension       |
  2810.                          |                       |
  2811.                          |________________________✓|
  2812.                          |______✓A_✓t_✓t_✓r_✓i_✓b_✓u_✓t_✓e__✓b_✓y_✓t_✓e_____✓|
  2813.                          |                       |
  2814.                          |   (10 bytes unused)   |
  2815.                          |                       |
  2816.                          |________________________✓|
  2817.                          |   WORD creation time  |
  2818.                          |________________________✓|
  2819.                          |   WORD creation date  |
  2820.                          |________________________✓|
  2821.                          | WORD starting cluster#|
  2822.                          |________________________✓|
  2823.                          |    LONG file length   |
  2824.                          |                       |
  2825.                          |                       |
  2826.                          |________________________✓|
  2827.         
  2828.         
  2829.              All WORDS and LONGS in the directory entry are in  8086
  2830.         "byte reversed" format.
  2831.         
  2832.              When a file is deleted, the  first  byte  of  the  name
  2833.         field is set to 0xe5.
  2834.         
  2835.         
  2836.         4/4/86 Dyer                                     Atari GEMDOS
  2837.         
  2838.         
  2839.         
  2840.         
  2841.         
  2842.         
  2843.         
  2844.         ~/text/gemdos/diskstruct           Volume Structure    ( 3 )
  2845.         
  2846.         
  2847.              A  subdirectory  is  a  file  that  contains  directory
  2848.         entries.  The first two entries in a subdirectory are always
  2849.         the special directories "." and "..".
  2850.         
  2851.         
  2852.         
  2853.         
  2854.         
  2855.         
  2856.         
  2857.         _✓F_✓A_✓T _✓E_✓N_✓T_✓R_✓I_✓E_✓S
  2858.              The File Allocation Table (FAT)  is  used  to  allocate
  2859.         clusters  and  to  link  clusters  together into files.  FAT
  2860.         entries may be 12 or 16 bits.  A file's directory entry con-
  2861.         tains  the  number  of  the first cluster in the file.  Each
  2862.         cluster's associated FAT entry contains the  number  of  the
  2863.         next  cluster  in  the file, or a number that indicates end-
  2864.         of-file.
  2865.         
  2866.                              12-bit FAT Entries
  2867.         
  2868.                    _____________________________________
  2869.                   |     value             meaning      |
  2870.                   |_______________✓|______________________✓|
  2871.                   |         0x000|  free cluster       |
  2872.                   |         0x001|  (impossible)       |
  2873.                   | 0x002 - 0xfef|  next cluster number|
  2874.                   | 0xff0 - 0xff7|  bad sector         |
  2875.                   | 0xff8 - 0xfff|  end of file        |
  2876.                   |_______________✓|______________________✓|
  2877.         
  2878.         
  2879.                              16-bit FAT Entries
  2880.                   _______________________________________
  2881.                  |      value              meaning      |
  2882.                  |_______________________________________✓|
  2883.                  |          0x0000|  free cluster       |
  2884.                  |          0x0001|  (impossible)       |
  2885.                  | 0x0002 - 0x7fff|  next cluster number|
  2886.                  | 0x8000 - 0xffef|  (impossible)       |
  2887.                  | 0xfff0 - 0xfff7|  bad sector         |
  2888.                  |__✓0_✓x_✓f_✓f_✓f_✓8__✓-__✓0_✓x_✓f_✓f_✓f_✓f|✓_✓|___✓e_✓n_✓d__✓o_✓f__✓f_✓i_✓l_✓e_________✓|
  2889.         
  2890.         
  2891.              For a 12-bit FAT, obtain the next cluster in the  file,
  2892.         NCL, given the current cluster number, CL, by:
  2893.            [1] (Multiply by 1.5)
  2894.                NCL = CL + CL / 2
  2895.            [2] Set NCL to the 16-bit word in the FAT indexed by  NCL
  2896.                (it  must  be  byte-swapped to 68000 format as well.)
  2897.                The word might not be on a 68000 word boundary.
  2898.            [3] (Extract the correct 12 bits.)
  2899.                If CL is odd, set NCL = NCL >> 4.
  2900.         
  2901.         
  2902.         4/4/86 Dyer                                     Atari GEMDOS
  2903.         
  2904.         
  2905.         
  2906.         
  2907.         
  2908.         
  2909.         
  2910.         ~/text/gemdos/diskstruct           Volume Structure    ( 4 )
  2911.         
  2912.         
  2913.            [4] (Mask off incorrect bits.)
  2914.                Set NCL = NCL & 0x0FFF.
  2915.            [5] (Interpret the result.)
  2916.                If NCL is 0x0FF8 or higher,  then  CL  was  the  last
  2917.                cluster  in the file.  If NCL is zero or in the range
  2918.                0x0FF0 to 0x0FF7 then there is a file system problem.
  2919.                Otherwise,  NCL  is the number of the next cluster in
  2920.                the file.
  2921.         
  2922.              For a 16-bit FAT, obtain the next cluster in the  file,
  2923.         NCL, given the current cluster number, CL, by:
  2924.            [1] Set NCL to the 16-bit word in the FAT indexed by  CL.
  2925.                The word must be byte-swapped into 68000 format.
  2926.            [2] If NCL is 0xfff8 or higher,  then  CL  was  the  last
  2927.                cluster  in  the  file.   If NCL is 0 or in the range
  2928.                0x8000 to 0xfff7 then there is a file system problem.
  2929.                Otherwise,  NCL  is the number of the next cluster in
  2930.                the file.
  2931.         
  2932.              To convert from a cluster number, CL, to a logical sec-
  2933.         tor number, LSN:
  2934.            [1] (Adjust for reserved FAT entries.)
  2935.                LSN = CL - 2
  2936.            [2] Multiply LSN by the number  of  sectors  per  cluster
  2937.                (CLSIZ).
  2938.            [3] Add the logical sector# of the first cluster  to  LSN
  2939.                (DATREC).
  2940.         
  2941.         
  2942.         
  2943.         
  2944.         
  2945.         
  2946.         
  2947.         
  2948.         
  2949.         
  2950.         
  2951.         
  2952.         
  2953.         
  2954.         
  2955.         
  2956.         
  2957.         
  2958.         
  2959.         
  2960.         
  2961.         
  2962.         
  2963.         
  2964.         
  2965.         
  2966.         
  2967.         
  2968.         4/4/86 Dyer                                     Atari GEMDOS
  2969.         
  2970.         
  2971.         
  2972.  
  2973. Press <CR> to continue: