Browse Source

* Amiga includes (from 0.99.5 release)

carl 23 years ago
parent
commit
151fab7d5d
52 changed files with 28925 additions and 0 deletions
  1. 4008 0
      packages/extra/amunits/units/amigados.pas
  2. 466 0
      packages/extra/amunits/units/amigaguide.pas
  3. 195 0
      packages/extra/amunits/units/amigalib.pas
  4. 237 0
      packages/extra/amunits/units/amigaprinter.pas
  5. 498 0
      packages/extra/amunits/units/asl.pas
  6. 72 0
      packages/extra/amunits/units/audio.pas
  7. 42 0
      packages/extra/amunits/units/bootblock.pas
  8. 426 0
      packages/extra/amunits/units/bullet.pas
  9. 333 0
      packages/extra/amunits/units/cd.pas
  10. 80 0
      packages/extra/amunits/units/clipboard.pas
  11. 99 0
      packages/extra/amunits/units/colorwheel.pas
  12. 565 0
      packages/extra/amunits/units/commodities.pas
  13. 275 0
      packages/extra/amunits/units/configregs.pas
  14. 71 0
      packages/extra/amunits/units/configvars.pas
  15. 155 0
      packages/extra/amunits/units/console.pas
  16. 106 0
      packages/extra/amunits/units/conunit.pas
  17. 1274 0
      packages/extra/amunits/units/datatypes.pas
  18. 192 0
      packages/extra/amunits/units/diskfont.pas
  19. 318 0
      packages/extra/amunits/units/expansion.pas
  20. 94 0
      packages/extra/amunits/units/expansionbase.pas
  21. 710 0
      packages/extra/amunits/units/gadtools.pas
  22. 74 0
      packages/extra/amunits/units/gameport.pas
  23. 39 0
      packages/extra/amunits/units/gradientslider.pas
  24. 4637 0
      packages/extra/amunits/units/graphics.pas
  25. 251 0
      packages/extra/amunits/units/hardblocks.pas
  26. 591 0
      packages/extra/amunits/units/hardware.pas
  27. 210 0
      packages/extra/amunits/units/icon.pas
  28. 791 0
      packages/extra/amunits/units/iffparse.pas
  29. 55 0
      packages/extra/amunits/units/input.pas
  30. 287 0
      packages/extra/amunits/units/inputevent.pas
  31. 5624 0
      packages/extra/amunits/units/intuition.pas
  32. 39 0
      packages/extra/amunits/units/keyboard.pas
  33. 157 0
      packages/extra/amunits/units/keymap.pas
  34. 531 0
      packages/extra/amunits/units/layers.pas
  35. 628 0
      packages/extra/amunits/units/locale.pas
  36. 446 0
      packages/extra/amunits/units/lowlevel.pas
  37. 178 0
      packages/extra/amunits/units/nonvolatile.pas
  38. 116 0
      packages/extra/amunits/units/parallel.pas
  39. 695 0
      packages/extra/amunits/units/prefs.pas
  40. 165 0
      packages/extra/amunits/units/prtbase.pas
  41. 91 0
      packages/extra/amunits/units/prtgfx.pas
  42. 359 0
      packages/extra/amunits/units/realtime.pas
  43. 600 0
      packages/extra/amunits/units/rexx.pas
  44. 43 0
      packages/extra/amunits/units/romboot_base.pas
  45. 136 0
      packages/extra/amunits/units/scsidisk.pas
  46. 197 0
      packages/extra/amunits/units/serial.pas
  47. 57 0
      packages/extra/amunits/units/tapedeck.pas
  48. 148 0
      packages/extra/amunits/units/timer.pas
  49. 270 0
      packages/extra/amunits/units/trackdisk.pas
  50. 49 0
      packages/extra/amunits/units/translator.pas
  51. 910 0
      packages/extra/amunits/units/utility.pas
  52. 335 0
      packages/extra/amunits/units/workbench.pas

+ 4008 - 0
packages/extra/amunits/units/amigados.pas

@@ -0,0 +1,4008 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit amigados;
+
+INTERFACE
+
+uses exec, utility, timer;
+
+Const
+
+{ Predefined Amiga DOS global constants }
+
+    DOSTRUE     = -1;
+    DOSFALSE    =  0;
+
+{ Mode parameter to Open() }
+
+    MODE_OLDFILE        = 1005;         { Open existing file read/write
+                                          positioned at beginning of file. }
+    MODE_NEWFILE        = 1006;         { Open freshly created file (delete
+                                          old file) read/write }
+    MODE_READWRITE      = 1004;         { Open old file w/exclusive lock }
+
+{ Relative position to Seek() }
+
+    OFFSET_BEGINNING    = -1;           { relative to Begining Of File }
+    OFFSET_CURRENT      = 0;            { relative to Current file position }
+    OFFSET_END          = 1;            { relative to End Of File }
+
+    BITSPERBYTE         = 8;
+    BYTESPERLONG        = 4;
+    BITSPERLONG         = 32;
+    MAXINT              = $7FFFFFFF;
+    MININT              = $80000000;
+
+{ Passed as type to Lock() }
+
+    SHARED_LOCK         = -2;           { File is readable by others }
+    ACCESS_READ         = -2;           { Synonym }
+    EXCLUSIVE_LOCK      = -1;           { No other access allowed }
+    ACCESS_WRITE        = -1;           { Synonym }
+
+Type
+
+    FileHandle  = BPTR;
+    FileLock    = BPTR;
+
+    pDateStamp = ^tDateStamp;
+    tDateStamp = record
+        ds_Days         : Longint;      { Number of days since Jan. 1, 1978 }
+        ds_Minute       : Longint;      { Number of minutes past midnight }
+        ds_Tick         : Longint;      { Number of ticks past minute }
+    end;
+
+Const
+
+    TICKS_PER_SECOND    = 50;           { Number of ticks in one second }
+
+{$PACKRECORDS 4}
+Type
+
+{ Returned by Examine() and ExInfo(), must be on a 4 byte boundary }
+
+    pFileInfoBlock = ^tFileInfoBlock;
+    tFileInfoBlock = record
+        fib_DiskKey      : Longint;
+        fib_DirEntryType : Longint;
+                        { Type of Directory. If < 0, then a plain file.
+                          If > 0 a directory }
+        fib_FileName     : Array [0..107] of Char;
+                        { Null terminated. Max 30 chars used for now }
+        fib_Protection   : Longint;
+                        { bit mask of protection, rwxd are 3-0. }
+        fib_EntryType    : Longint;
+        fib_Size         : Longint;      { Number of bytes in file }
+        fib_NumBlocks    : Longint;      { Number of blocks in file }
+        fib_Date         : tDateStamp;   { Date file last changed }
+        fib_Comment      : Array [0..79] of Char;
+                        { Null terminated comment associated with file }
+        fib_OwnerUID     : Word;
+        fib_OwnerGID     : Word;
+        fib_Reserved     : Array [0..31] of Char;
+    end;
+
+Const
+
+{ FIB stands for FileInfoBlock }
+
+{* FIBB are bit definitions, FIBF are field definitions *}
+{* Regular RWED bits are 0 == allowed. *}
+{* NOTE: GRP and OTR RWED permissions are 0 == not allowed! *}
+{* Group and Other permissions are not directly handled by the filesystem *}
+
+    FIBB_OTR_READ       = 15;   {* Other: file is readable *}
+    FIBB_OTR_WRITE      = 14;   {* Other: file is writable *}
+    FIBB_OTR_EXECUTE    = 13;   {* Other: file is executable *}
+    FIBB_OTR_DELETE     = 12;   {* Other: prevent file from being deleted *}
+    FIBB_GRP_READ       = 11;   {* Group: file is readable *}
+    FIBB_GRP_WRITE      = 10;   {* Group: file is writable *}
+    FIBB_GRP_EXECUTE    = 9;    {* Group: file is executable *}
+    FIBB_GRP_DELETE     = 8;    {* Group: prevent file from being deleted *}
+
+    FIBB_SCRIPT         = 6;    { program is a script (execute) file }
+    FIBB_PURE           = 5;    { program is reentrant and rexecutable}
+    FIBB_ARCHIVE        = 4;    { cleared whenever file is changed }
+    FIBB_READ           = 3;    { ignored by old filesystem }
+    FIBB_WRITE          = 2;    { ignored by old filesystem }
+    FIBB_EXECUTE        = 1;    { ignored by system, used by Shell }
+    FIBB_DELETE         = 0;    { prevent file from being deleted }
+
+    FIBF_OTR_READ      = (1 shl FIBB_OTR_READ);
+    FIBF_OTR_WRITE     = (1 shl FIBB_OTR_WRITE);
+    FIBF_OTR_EXECUTE   = (1 shl FIBB_OTR_EXECUTE);
+    FIBF_OTR_DELETE    = (1 shl FIBB_OTR_DELETE);
+    FIBF_GRP_READ      = (1 shl FIBB_GRP_READ);
+    FIBF_GRP_WRITE     = (1 shl FIBB_GRP_WRITE);
+    FIBF_GRP_EXECUTE   = (1 shl FIBB_GRP_EXECUTE);
+    FIBF_GRP_DELETE    = (1 shl FIBB_GRP_DELETE);
+
+    FIBF_SCRIPT         = 64;
+    FIBF_PURE           = 32;
+    FIBF_ARCHIVE        = 16;
+    FIBF_READ           = 8;
+    FIBF_WRITE          = 4;
+    FIBF_EXECUTE        = 2;
+    FIBF_DELETE         = 1;
+
+{* Standard maximum length for an error string from fault.  However, most *}
+{* error strings should be kept under 60 characters if possible.  Don't   *}
+{* forget space for the header you pass in. *}
+
+    FAULT_MAX  = 82;
+
+{* All BCPL data must be long Integer aligned.  BCPL pointers are the long Integer
+ *  address (i.e byte address divided by 4 (>>2)) *}
+
+{* BCPL strings have a length in the first byte and then the characters.
+ * For example:  s[0]=3 s[1]=S s[2]=Y s[3]=S                 *}
+
+
+Type
+
+{ returned by Info(), must be on a 4 byte boundary }
+
+    pInfoData = ^tInfoData;
+    tInfoData = record
+        id_NumSoftErrors        : Longint;      { number of soft errors on disk }
+        id_UnitNumber           : Longint;      { Which unit disk is (was) mounted on }
+        id_DiskState            : Longint;      { See defines below }
+        id_NumBlocks            : Longint;      { Number of blocks on disk }
+        id_NumBlocksUsed        : Longint;      { Number of block in use }
+        id_BytesPerBlock        : Longint;
+        id_DiskType             : Longint;      { Disk Type code }
+        id_VolumeNode           : BPTR;         { BCPL pointer to volume node }
+        id_InUse                : Longint;      { Flag, zero if not in use }
+    end;
+
+{$PACKRECORDS NORMAL}
+
+Const
+
+{ ID stands for InfoData }
+
+        { Disk states }
+
+    ID_WRITE_PROTECTED  = 80;   { Disk is write protected }
+    ID_VALIDATING       = 81;   { Disk is currently being validated }
+    ID_VALIDATED        = 82;   { Disk is consistent and writeable }
+
+CONST
+ ID_NO_DISK_PRESENT     = -1;
+ ID_UNREADABLE_DISK     = $42414400;   { 'BAD\0' }
+ ID_DOS_DISK            = $444F5300;   { 'DOS\0' }
+ ID_FFS_DISK            = $444F5301;   { 'DOS\1' }
+ ID_NOT_REALLY_DOS      = $4E444F53;   { 'NDOS'  }
+ ID_KICKSTART_DISK      = $4B49434B;   { 'KICK'  }
+ ID_MSDOS_DISK          = $4d534400;   { 'MSD\0' }
+
+{ Errors from IoErr(), etc. }
+ ERROR_NO_FREE_STORE              = 103;
+ ERROR_TASK_TABLE_FULL            = 105;
+ ERROR_BAD_TEMPLATE               = 114;
+ ERROR_BAD_NUMBER                 = 115;
+ ERROR_REQUIRED_ARG_MISSING       = 116;
+ ERROR_KEY_NEEDS_ARG              = 117;
+ ERROR_TOO_MANY_ARGS              = 118;
+ ERROR_UNMATCHED_QUOTES           = 119;
+ ERROR_LINE_TOO_LONG              = 120;
+ ERROR_FILE_NOT_OBJECT            = 121;
+ ERROR_INVALID_RESIDENT_LIBRARY   = 122;
+ ERROR_NO_DEFAULT_DIR             = 201;
+ ERROR_OBJECT_IN_USE              = 202;
+ ERROR_OBJECT_EXISTS              = 203;
+ ERROR_DIR_NOT_FOUND              = 204;
+ ERROR_OBJECT_NOT_FOUND           = 205;
+ ERROR_BAD_STREAM_NAME            = 206;
+ ERROR_OBJECT_TOO_LARGE           = 207;
+ ERROR_ACTION_NOT_KNOWN           = 209;
+ ERROR_INVALID_COMPONENT_NAME     = 210;
+ ERROR_INVALID_LOCK               = 211;
+ ERROR_OBJECT_WRONG_TYPE          = 212;
+ ERROR_DISK_NOT_VALIDATED         = 213;
+ ERROR_DISK_WRITE_PROTECTED       = 214;
+ ERROR_RENAME_ACROSS_DEVICES      = 215;
+ ERROR_DIRECTORY_NOT_EMPTY        = 216;
+ ERROR_TOO_MANY_LEVELS            = 217;
+ ERROR_DEVICE_NOT_MOUNTED         = 218;
+ ERROR_SEEK_ERROR                 = 219;
+ ERROR_COMMENT_TOO_BIG            = 220;
+ ERROR_DISK_FULL                  = 221;
+ ERROR_DELETE_PROTECTED           = 222;
+ ERROR_WRITE_PROTECTED            = 223;
+ ERROR_READ_PROTECTED             = 224;
+ ERROR_NOT_A_DOS_DISK             = 225;
+ ERROR_NO_DISK                    = 226;
+ ERROR_NO_MORE_ENTRIES            = 232;
+{ added for 1.4 }
+ ERROR_IS_SOFT_LINK               = 233;
+ ERROR_OBJECT_LINKED              = 234;
+ ERROR_BAD_HUNK                   = 235;
+ ERROR_NOT_IMPLEMENTED            = 236;
+ ERROR_RECORD_NOT_LOCKED          = 240;
+ ERROR_LOCK_COLLISION             = 241;
+ ERROR_LOCK_TIMEOUT               = 242;
+ ERROR_UNLOCK_ERROR               = 243;
+
+{ error codes 303-305 are defined in dosasl.h }
+
+{ These are the return codes used by convention by AmigaDOS commands }
+{ See FAILAT and IF for relvance to EXECUTE files                    }
+ RETURN_OK                        =   0;  { No problems, success }
+ RETURN_WARN                      =   5;  { A warning only }
+ RETURN_ERROR                     =  10;  { Something wrong }
+ RETURN_FAIL                      =  20;  { Complete or severe failure}
+
+{ Bit numbers that signal you that a user has issued a break }
+ SIGBREAKB_CTRL_C   = 12;
+ SIGBREAKB_CTRL_D   = 13;
+ SIGBREAKB_CTRL_E   = 14;
+ SIGBREAKB_CTRL_F   = 15;
+
+{ Bit fields that signal you that a user has issued a break }
+{ for example:  if (SetSignal(0,0) & SIGBREAKF_CTRL_C) cleanup_and_exit(); }
+ SIGBREAKF_CTRL_C   = 4096;
+ SIGBREAKF_CTRL_D   = 8192;
+ SIGBREAKF_CTRL_E   = 16384;
+ SIGBREAKF_CTRL_F   = 32768;
+
+{ Values returned by SameLock() }
+ LOCK_SAME             =  0;
+ LOCK_SAME_HANDLER     =  1;       { actually same volume }
+ LOCK_DIFFERENT        =  -1;
+
+{ types for ChangeMode() }
+ CHANGE_LOCK    = 0;
+ CHANGE_FH      = 1;
+
+{ Values for MakeLink() }
+ LINK_HARD      = 0;
+ LINK_SOFT      = 1;       { softlinks are not fully supported yet }
+
+{ values returned by ReadItem }
+ ITEM_EQUAL     = -2;              { "=" Symbol }
+ ITEM_ERROR     = -1;              { error }
+ ITEM_NOTHING   = 0;               { *N, ;, endstreamch }
+ ITEM_UNQUOTED  = 1;               { unquoted item }
+ ITEM_QUOTED    = 2;               { quoted item }
+
+{ types for AllocDosObject/FreeDosObject }
+ DOS_FILEHANDLE        =  0;       { few people should use this }
+ DOS_EXALLCONTROL      =  1;       { Must be used to allocate this! }
+ DOS_FIB               =  2;       { useful }
+ DOS_STDPKT            =  3;       { for doing packet-level I/O }
+ DOS_CLI               =  4;       { for shell-writers, etc }
+ DOS_RDARGS            =  5;       { for ReadArgs if you pass it in }
+
+
+{
+ *      Data structures and equates used by the V1.4 DOS functions
+ * StrtoDate() and DatetoStr()
+ }
+
+{--------- String/Date structures etc }
+Type
+       pDateTime = ^tDateTime;
+       tDateTime = record
+        dat_Stamp   : tDateStamp;      { DOS DateStamp }
+        dat_Format,                    { controls appearance of dat_StrDate }
+        dat_Flags   : Byte;           { see BITDEF's below }
+        dat_StrDay,                    { day of the week string }
+        dat_StrDate,                   { date string }
+        dat_StrTime : STRPTR;          { time string }
+       END;
+
+{ You need this much room for each of the DateTime strings: }
+CONST
+ LEN_DATSTRING =  16;
+
+{      flags for dat_Flags }
+
+ DTB_SUBST      = 0;               { substitute Today, Tomorrow, etc. }
+ DTF_SUBST      = 1;
+ DTB_FUTURE     = 1;               { day of the week is in future }
+ DTF_FUTURE     = 2;
+
+{
+ *      date format values
+ }
+
+ FORMAT_DOS     = 0;               { dd-mmm-yy }
+ FORMAT_INT     = 1;               { yy-mm-dd  }
+ FORMAT_USA     = 2;               { mm-dd-yy  }
+ FORMAT_CDN     = 3;               { dd-mm-yy  }
+ FORMAT_MAX     = FORMAT_CDN;
+
+
+{**********************************************************************
+************************ PATTERN MATCHING ******************************
+************************************************************************
+
+* structure expected by MatchFirst, MatchNext.
+* Allocate this structure and initialize it as follows:
+*
+* Set ap_BreakBits to the signal bits (CDEF) that you want to take a
+* break on, or NULL, if you don't want to convenience the user.
+*
+* If you want to have the FULL PATH NAME of the files you found,
+* allocate a buffer at the END of this structure, and put the size of
+* it into ap_Strlen.  If you don't want the full path name, make sure
+* you set ap_Strlen to zero.  In this case, the name of the file, and stats
+* are available in the ap_Info, as per usual.
+*
+* Then call MatchFirst() and then afterwards, MatchNext() with this structure.
+* You should check the return value each time (see below) and take the
+* appropriate action, ultimately calling MatchEnd() when there are
+* no more files and you are done.  You can tell when you are done by
+* checking for the normal AmigaDOS return code ERROR_NO_MORE_ENTRIES.
+*
+}
+
+Type
+       pAChain = ^tAChain;
+       tAChain = record
+        an_Child,
+        an_Parent   : pAChain;
+        an_Lock     : BPTR;
+        an_Info     : tFileInfoBlock;
+        an_Flags    : Shortint;
+        an_String   : Array[0..0] of Char;   { FIX!! }
+       END;
+
+       pAnchorPath = ^tAnchorPath;
+       tAnchorPath = record
+        case integer of
+        0 : (
+        ap_First      : pAChain;
+        ap_Last       : pAChain;
+        );
+        1 : (
+        ap_Base,                    { pointer to first anchor }
+        ap_Current    : pAChain;    { pointer to last anchor }
+        ap_BreakBits,               { Bits we want to break on }
+        ap_FoundBreak : Longint;    { Bits we broke on. Also returns ERROR_BREAK }
+        ap_Flags      : Shortint;       { New use for extra Integer. }
+        ap_Reserved   : Shortint;
+        ap_Strlen     : Integer;       { This is what ap_Length used to be }
+        ap_Info       : tFileInfoBlock;
+        ap_Buf        : Array[0..0] of Char;     { Buffer for path name, allocated by user !! }
+        { FIX! }
+        );
+       END;
+
+
+CONST
+    APB_DOWILD    =  0;       { User option ALL }
+    APF_DOWILD    =  1;
+
+    APB_ITSWILD   =  1;       { Set by MatchFirst, used by MatchNext  }
+    APF_ITSWILD   =  2;       { Application can test APB_ITSWILD, too }
+                                { (means that there's a wildcard        }
+                                { in the pattern after calling          }
+                                { MatchFirst).                          }
+
+    APB_DODIR     =  2;       { Bit is SET IF a DIR node should be }
+    APF_DODIR     =  4;       { entered. Application can RESET this }
+                                { bit after MatchFirst/MatchNext to AVOID }
+                                { entering a dir. }
+
+    APB_DIDDIR    =  3;       { Bit is SET for an "expired" dir node. }
+    APF_DIDDIR    =  8;
+
+    APB_NOMEMERR  =  4;       { Set on memory error }
+    APF_NOMEMERR  =  16;
+
+    APB_DODOT     =  5;       { IF set, allow conversion of '.' to }
+    APF_DODOT     =  32;      { CurrentDir }
+
+    APB_DirChanged  = 6;       { ap_Current->an_Lock changed }
+    APF_DirChanged  = 64;      { since last MatchNext call }
+
+
+    DDB_PatternBit  = 0;
+    DDF_PatternBit  = 1;
+    DDB_ExaminedBit = 1;
+    DDF_ExaminedBit = 2;
+    DDB_Completed   = 2;
+    DDF_Completed   = 4;
+    DDB_AllBit      = 3;
+    DDF_AllBit      = 8;
+    DDB_Single      = 4;
+    DDF_Single      = 16;
+
+{
+ * Constants used by wildcard routines, these are the pre-parsed tokens
+ * referred to by pattern match.  It is not necessary for you to do
+ * anything about these, MatchFirst() MatchNext() handle all these for you.
+ }
+
+    P_ANY         =  $80;    { Token for '*' or '#?  }
+    P_SINGLE      =  $81;    { Token for '?' }
+    P_ORSTART     =  $82;    { Token for '(' }
+    P_ORNEXT      =  $83;    { Token for '|' }
+    P_OREND       =  $84;    { Token for ')' }
+    P_NOT         =  $85;    { Token for '~' }
+    P_NOTEND      =  $86;    { Token for }
+    P_NOTCLASS    =  $87;    { Token for '^' }
+    P_CLASS       =  $88;    { Token for '[]' }
+    P_REPBEG      =  $89;    { Token for '[' }
+    P_REPEND      =  $8A;    { Token for ']' }
+    P_STOP        =  $8B;    { token to force end of evaluation }
+
+{ Values for an_Status, NOTE: These are the actual bit numbers }
+
+    COMPLEX_BIT   =  1;       { Parsing complex pattern }
+    EXAMINE_BIT   =  2;       { Searching directory }
+
+{
+ * Returns from MatchFirst(), MatchNext()
+ * You can also get dos error returns, such as ERROR_NO_MORE_ENTRIES,
+ * these are in the dos.h file.
+ }
+
+    ERROR_BUFFER_OVERFLOW  = 303;     { User OR internal buffer overflow }
+    ERROR_BREAK            = 304;     { A break character was received }
+    ERROR_NOT_EXECUTABLE   = 305;     { A file has E bit cleared }
+
+{   hunk types }
+     HUNK_UNIT      = 999 ;
+     HUNK_NAME      = 1000;
+     HUNK_CODE      = 1001;
+     HUNK_DATA      = 1002;
+     HUNK_BSS       = 1003;
+     HUNK_RELOC32   = 1004;
+     HUNK_RELOC16   = 1005;
+     HUNK_RELOC8    = 1006;
+     HUNK_EXT       = 1007;
+     HUNK_SYMBOL    = 1008;
+     HUNK_DEBUG     = 1009;
+     HUNK_END       = 1010;
+     HUNK_HEADER    = 1011;
+
+     HUNK_OVERLAY   = 1013;
+     HUNK_BREAK     = 1014;
+
+     HUNK_DREL32    = 1015;
+     HUNK_DREL16    = 1016;
+     HUNK_DREL8     = 1017;
+
+     HUNK_LIB       = 1018;
+     HUNK_INDEX     = 1019;
+
+{   hunk_ext sub-types }
+     EXT_SYMB       = 0  ;     {   symbol table }
+     EXT_DEF        = 1  ;     {   relocatable definition }
+     EXT_ABS        = 2  ;     {   Absolute definition }
+     EXT_RES        = 3  ;     {   no longer supported }
+     EXT_REF32      = 129;     {   32 bit reference to symbol }
+     EXT_COMMON     = 130;     {   32 bit reference to COMMON block }
+     EXT_REF16      = 131;     {   16 bit reference to symbol }
+     EXT_REF8       = 132;     {    8 bit reference to symbol }
+     EXT_DEXT32     = 133;     {   32 bit data releative reference }
+     EXT_DEXT16     = 134;     {   16 bit data releative reference }
+     EXT_DEXT8      = 135;     {    8 bit data releative reference }
+
+
+Type
+
+{ All DOS processes have this structure }
+{ Create and Device Proc returns pointer to the MsgPort in this structure }
+{ dev_proc = Address(Integer(DeviceProc()) - SizeOf(Task)) }
+
+    pProcess = ^tProcess;
+    tProcess = record
+        pr_Task         : tTask;
+        pr_MsgPort      : tMsgPort;     { This is BPTR address from DOS functions  }
+        pr_Pad          : Integer;         { Remaining variables on 4 byte boundaries }
+        pr_SegList      : BPTR;         { Array of seg lists used by this process  }
+        pr_StackSize    : Longint;      { Size of process stack in bytes            }
+        pr_GlobVec      : Pointer;      { Global vector for this process (BCPL)    }
+        pr_TaskNum      : Longint;      { CLI task number of zero if not a CLI      }
+        pr_StackBase    : BPTR;         { Ptr to high memory end of process stack  }
+        pr_Result2      : Longint;      { Value of secondary result from last call }
+        pr_CurrentDir   : BPTR;         { Lock associated with current directory   }
+        pr_CIS          : BPTR;         { Current CLI Input Stream                  }
+        pr_COS          : BPTR;         { Current CLI Output Stream                 }
+        pr_ConsoleTask  : Pointer;      { Console handler process for current window}
+        pr_FileSystemTask : Pointer;    { File handler process for current drive   }
+        pr_CLI          : BPTR;         { pointer to ConsoleLineInterpreter         }
+        pr_ReturnAddr   : Pointer;      { pointer to previous stack frame           }
+        pr_PktWait      : Pointer;      { Function to be called when awaiting msg  }
+        pr_WindowPtr    : Pointer;      { Window for error printing }
+        { following definitions are new with 2.0 }
+        pr_HomeDir      : BPTR;         { Home directory of executing program      }
+        pr_Flags        : Longint;      { flags telling dos about process          }
+        pr_ExitCode     : Pointer;      { code to call on exit of program OR NULL  }
+        pr_ExitData     : Longint;      { Passed as an argument to pr_ExitCode.    }
+        pr_Arguments    : STRPTR;       { Arguments passed to the process at start }
+        pr_LocalVars    : tMinList;      { Local environment variables             }
+        pr_ShellPrivate : ULONG;        { for the use of the current shell         }
+        pr_CES          : BPTR;         { Error stream - IF NULL, use pr_COS       }
+    end;
+
+{
+ * Flags for pr_Flags
+ }
+CONST
+ PRB_FREESEGLIST       =  0 ;
+ PRF_FREESEGLIST       =  1 ;
+ PRB_FREECURRDIR       =  1 ;
+ PRF_FREECURRDIR       =  2 ;
+ PRB_FREECLI           =  2 ;
+ PRF_FREECLI           =  4 ;
+ PRB_CLOSEINPUT        =  3 ;
+ PRF_CLOSEINPUT        =  8 ;
+ PRB_CLOSEOUTPUT       =  4 ;
+ PRF_CLOSEOUTPUT       =  16;
+ PRB_FREEARGS          =  5 ;
+ PRF_FREEARGS          =  32;
+
+
+{ The long Integer address (BPTR) of this structure is returned by
+ * Open() and other routines that return a file.  You need only worry
+ * about this struct to do async io's via PutMsg() instead of
+ * standard file system calls }
+
+Type
+
+    pFileHandle = ^tFileHandle;
+    tFileHandle = record
+        fh_Link         : pMessage;   { EXEC message        }
+        fh_Port         : pMsgPort;   { Reply port for the packet }
+        fh_Type         : pMsgPort;   { Port to do PutMsg() to
+                                          Address is negative if a plain file }
+        fh_Buf          : Longint;
+        fh_Pos          : Longint;
+        fh_End          : Longint;
+        fh_Func1        : Longint;
+        fh_Func2        : Longint;
+        fh_Func3        : Longint;
+        fh_Arg1         : Longint;
+        fh_Arg2         : Longint;
+    end;
+
+{ This is the extension to EXEC Messages used by DOS }
+
+    pDosPacket = ^tDosPacket;
+    tDosPacket = record
+        dp_Link : pMessage;     { EXEC message        }
+        dp_Port : pMsgPort;     { Reply port for the packet }
+                                { Must be filled in each send. }
+        case integer of
+        0 : (
+        dp_Action : Longint;
+        dp_Status : Longint;
+        dp_Status2 : Longint;
+        dp_BufAddr : Longint;
+        );
+        1 : (
+        dp_Type : Longint;      { See ACTION_... below and
+                                * 'R' means Read, 'W' means Write to the
+                                * file system }
+        dp_Res1 : Longint;      { For file system calls this is the result
+                                * that would have been returned by the
+                                * function, e.g. Write ('W') returns actual
+                                * length written }
+        dp_Res2 : Longint;      { For file system calls this is what would
+                                * have been returned by IoErr() }
+        dp_Arg1 : Longint;
+        dp_Arg2 : Longint;
+        dp_Arg3 : Longint;
+        dp_Arg4 : Longint;
+        dp_Arg5 : Longint;
+        dp_Arg6 : Longint;
+        dp_Arg7 : Longint;
+        );
+    end;
+
+
+{ A Packet does not require the Message to be before it in memory, but
+ * for convenience it is useful to associate the two.
+ * Also see the function init_std_pkt for initializing this structure }
+
+    pStandardPacket = ^tStandardPacket;
+    tStandardPacket = record
+        sp_Msg          : tMessage;
+        sp_Pkt          : tDosPacket;
+    end;
+
+
+Const
+
+{ Packet types }
+    ACTION_NIL                  = 0;
+    ACTION_GET_BLOCK            = 2;    { OBSOLETE }
+    ACTION_SET_MAP              = 4;
+    ACTION_DIE                  = 5;
+    ACTION_EVENT                = 6;
+    ACTION_CURRENT_VOLUME       = 7;
+    ACTION_LOCATE_OBJECT        = 8;
+    ACTION_RENAME_DISK          = 9;
+    ACTION_WRITE                = $57;  { 'W' }
+    ACTION_READ                 = $52;  { 'R' }
+    ACTION_FREE_LOCK            = 15;
+    ACTION_DELETE_OBJECT        = 16;
+    ACTION_RENAME_OBJECT        = 17;
+    ACTION_MORE_CACHE           = 18;
+    ACTION_COPY_DIR             = 19;
+    ACTION_WAIT_CHAR            = 20;
+    ACTION_SET_PROTECT          = 21;
+    ACTION_CREATE_DIR           = 22;
+    ACTION_EXAMINE_OBJECT       = 23;
+    ACTION_EXAMINE_NEXT         = 24;
+    ACTION_DISK_INFO            = 25;
+    ACTION_INFO                 = 26;
+    ACTION_FLUSH                = 27;
+    ACTION_SET_COMMENT          = 28;
+    ACTION_PARENT               = 29;
+    ACTION_TIMER                = 30;
+    ACTION_INHIBIT              = 31;
+    ACTION_DISK_TYPE            = 32;
+    ACTION_DISK_CHANGE          = 33;
+    ACTION_SET_DATE             = 34;
+
+    ACTION_SCREEN_MODE          = 994;
+
+    ACTION_READ_RETURN          = 1001;
+    ACTION_WRITE_RETURN         = 1002;
+    ACTION_SEEK                 = 1008;
+    ACTION_FINDUPDATE           = 1004;
+    ACTION_FINDINPUT            = 1005;
+    ACTION_FINDOUTPUT           = 1006;
+    ACTION_END                  = 1007;
+    ACTION_TRUNCATE             = 1022; { fast file system only }
+    ACTION_WRITE_PROTECT        = 1023; { fast file system only }
+
+{ new 2.0 packets }
+    ACTION_SAME_LOCK       = 40;
+    ACTION_CHANGE_SIGNAL   = 995;
+    ACTION_FORMAT          = 1020;
+    ACTION_MAKE_LINK       = 1021;
+{}
+{}
+    ACTION_READ_LINK       = 1024;
+    ACTION_FH_FROM_LOCK    = 1026;
+    ACTION_IS_FILESYSTEM   = 1027;
+    ACTION_CHANGE_MODE     = 1028;
+{}
+    ACTION_COPY_DIR_FH     = 1030;
+    ACTION_PARENT_FH       = 1031;
+    ACTION_EXAMINE_ALL     = 1033;
+    ACTION_EXAMINE_FH      = 1034;
+
+    ACTION_LOCK_RECORD     = 2008;
+    ACTION_FREE_RECORD     = 2009;
+
+    ACTION_ADD_NOTIFY      = 4097;
+    ACTION_REMOVE_NOTIFY   = 4098;
+
+    {* Added in V39: *}
+    ACTION_EXAMINE_ALL_END  = 1035;
+    ACTION_SET_OWNER        = 1036;
+
+{* Tell a file system to serialize the current volume. This is typically
+ * done by changing the creation date of the disk. This packet does not take
+ * any arguments.  NOTE: be prepared to handle failure of this packet for
+ * V37 ROM filesystems.
+ *}
+
+    ACTION_SERIALIZE_DISK  = 4200;
+
+{
+ * A structure for holding error messages - stored as array with error == 0
+ * for the last entry.
+ }
+Type
+       pErrorString = ^tErrorString;
+       tErrorString = record
+        estr_Nums     : Pointer;
+        estr_Strings  : Pointer;
+       END;
+
+
+{ DOS library node structure.
+ * This is the data at positive offsets from the library node.
+ * Negative offsets from the node is the jump table to DOS functions
+ * node = (struct DosLibrary *) OpenLibrary( "dos.library" .. )      }
+
+Type
+
+    pDosLibrary = ^tDosLibrary;
+    tDosLibrary = record
+        dl_lib          : tLibrary;
+        dl_Root         : Pointer;      { Pointer to RootNode, described below }
+        dl_GV           : Pointer;      { Pointer to BCPL global vector       }
+        dl_A2           : Longint;      { Private register dump of DOS        }
+        dl_A5           : Longint;
+        dl_A6           : Longint;
+        dl_Errors       : pErrorString; { pointer to array of error msgs }
+        dl_TimeReq      : pTimeRequest; { private pointer to timer request }
+        dl_UtilityBase  : pLibrary;     { private ptr to utility library }
+        dl_IntuitionBase : pLibrary;
+    end;
+
+    pRootNode = ^tRootNode;
+    tRootNode = record
+        rn_TaskArray    : BPTR;         { [0] is max number of CLI's
+                                          [1] is APTR to process id of CLI 1
+                                          [n] is APTR to process id of CLI n }
+        rn_ConsoleSegment : BPTR;       { SegList for the CLI }
+        rn_Time          : tDateStamp;  { Current time }
+        rn_RestartSeg   : Longint;      { SegList for the disk validator process }
+        rn_Info         : BPTR;         { Pointer ot the Info structure }
+        rn_FileHandlerSegment : BPTR;   { segment for a file handler }
+        rn_CliList      : tMinList;     { new list of all CLI processes }
+                                        { the first cpl_Array is also rn_TaskArray }
+        rn_BootProc     : pMsgPort;     { private ptr to msgport of boot fs      }
+        rn_ShellSegment : BPTR;         { seglist for Shell (for NewShell)         }
+        rn_Flags        : Longint;      { dos flags }
+    end;
+
+CONST
+ RNB_WILDSTAR   = 24;
+ RNF_WILDSTAR   = 16777216;
+ RNB_PRIVATE1   = 1;       { private for dos }
+ RNF_PRIVATE1   = 2;
+
+Type
+    pDosInfo = ^tDosInfo;
+    tDosInfo = record
+        case integer of
+        0 : (
+        di_ResList : BPTR;
+        );
+        1 : (
+        di_McName       : BPTR;          { Network name of this machine; currently 0 }
+        di_DevInfo      : BPTR;          { Device List }
+        di_Devices      : BPTR;          { Currently zero }
+        di_Handlers     : BPTR;          { Currently zero }
+        di_NetHand      : Pointer;       { Network handler processid; currently zero }
+        di_DevLock,                      { do NOT access directly! }
+        di_EntryLock,                    { do NOT access directly! }
+        di_DeleteLock   : tSignalSemaphore; { do NOT access directly! }
+        );
+    end;
+
+{ ONLY to be allocated by DOS! }
+
+       pCliProcList = ^tCliProcList;
+       tCliProcList = record
+        cpl_Node   : tMinNode;
+        cpl_First  : Longint;      { number of first entry in array }
+        cpl_Array  : Array[0..0] of pMsgPort;
+                             { [0] is max number of CLI's in this entry (n)
+                              * [1] is CPTR to process id of CLI cpl_First
+                              * [n] is CPTR to process id of CLI cpl_First+n-1
+                              }
+       END;
+
+{ structure for the Dos resident list.  Do NOT allocate these, use       }
+{ AddSegment(), and heed the warnings in the autodocs!                   }
+
+Type
+       pSegment = ^tSegment;
+       tSegment = record
+        seg_Next  : BPTR;
+        seg_UC    : Longint;
+        seg_Seg   : BPTR;
+        seg_Name  : Array[0..3] of Char;      { actually the first 4 chars of BSTR name }
+       END;
+
+CONST
+ CMD_SYSTEM    =  -1;
+ CMD_INTERNAL  =  -2;
+ CMD_DISABLED  =  -999;
+
+
+{ DOS Processes started from the CLI via RUN or NEWCLI have this additional
+ * set to data associated with them }
+Type
+    pCommandLineInterface = ^tCommandLineInterface;
+    tCommandLineInterface = record
+        cli_Result2        : Longint;      { Value of IoErr from last command }
+        cli_SetName        : BSTR;         { Name of current directory }
+        cli_CommandDir     : BPTR;         { Lock associated with command directory }
+        cli_ReturnCode     : Longint;      { Return code from last command }
+        cli_CommandName    : BSTR;         { Name of current command }
+        cli_FailLevel      : Longint;      { Fail level (set by FAILAT) }
+        cli_Prompt         : BSTR;         { Current prompt (set by PROMPT) }
+        cli_StandardInput  : BPTR;         { Default (terminal) CLI input }
+        cli_CurrentInput   : BPTR;         { Current CLI input }
+        cli_CommandFile    : BSTR;         { Name of EXECUTE command file }
+        cli_Interactive    : Longint;      { Boolean; True if prompts required }
+        cli_Background     : Longint;      { Boolean; True if CLI created by RUN }
+        cli_CurrentOutput  : BPTR;         { Current CLI output }
+        cli_DefaultStack   : Longint;      { Stack size to be obtained in long words }
+        cli_StandardOutput : BPTR;         { Default (terminal) CLI output }
+        cli_Module         : BPTR;         { SegList of currently loaded command }
+    end;
+
+{ This structure can take on different values depending on whether it is
+ * a device, an assigned directory, or a volume.  Below is the structure
+ * reflecting volumes only.  Following that is the structure representing
+ * only devices.
+ }
+
+{ structure representing a volume }
+
+    pDeviceList = ^tDeviceList;
+    tDeviceList = record
+        dl_Next         : BPTR;         { bptr to next device list }
+        dl_Type         : Longint;      { see DLT below }
+        dl_Task         : pMsgPort;     { ptr to handler task }
+        dl_Lock         : BPTR;         { not for volumes }
+        dl_VolumeDate   : tDateStamp;   { creation date }
+        dl_LockList     : BPTR;         { outstanding locks }
+        dl_DiskType     : Longint;      { 'DOS', etc }
+        dl_unused       : Longint;
+        dl_Name         : BSTR;         { bptr to bcpl name }
+    end;
+
+{ device structure (same as the DeviceNode structure in filehandler.h) }
+
+    pDevInfo = ^tDevInfo;
+    tDevInfo = record
+        dvi_Next        : BPTR;
+        dvi_Type        : Longint;
+        dvi_Task        : Pointer;
+        dvi_Lock        : BPTR;
+        dvi_Handler     : BSTR;
+        dvi_StackSize   : Longint;
+        dvi_Priority    : Longint;
+        dvi_Startup     : Longint;
+        dvi_SegList     : BPTR;
+        dvi_GlobVec     : BSTR;
+        dvi_Name        : BSTR;
+    end;
+
+{    structure used for multi-directory assigns. AllocVec()ed. }
+
+       pAssignList = ^tAssignList;
+       tAssignList = record
+        al_Next : pAssignList;
+        al_Lock : BPTR;
+       END;
+
+
+{ combined structure for devices, assigned directories, volumes }
+
+   pDosList = ^tDosList;
+   tDosList = record
+    dol_Next            : BPTR;           {    bptr to next device on list }
+    dol_Type            : Longint;        {    see DLT below }
+    dol_Task            : pMsgPort;       {    ptr to handler task }
+    dol_Lock            : BPTR;
+    case integer of
+    0 : (
+        dol_Handler : record
+          dol_Handler    : BSTR;      {    file name to load IF seglist is null }
+          dol_StackSize,              {    stacksize to use when starting process }
+          dol_Priority,               {    task priority when starting process }
+          dol_Startup    : Longint;   {    startup msg: FileSysStartupMsg for disks }
+          dol_SegList,                {    already loaded code for new task }
+          dol_GlobVec    : BPTR;      {    BCPL global vector to use when starting
+                                 * a process. -1 indicates a C/Assembler
+                                 * program. }
+        end;
+    );
+    1 : (
+        dol_Volume       : record
+          dol_VolumeDate : tDateStamp; {    creation date }
+          dol_LockList   : BPTR;       {    outstanding locks }
+          dol_DiskType   : Longint;    {    'DOS', etc }
+        END;
+    );
+    2 : (
+        dol_assign       :  record
+          dol_AssignName : STRPTR;        {    name for non-OR-late-binding assign }
+          dol_List       : pAssignList;   {    for multi-directory assigns (regular) }
+        END;
+    dol_Name            : BSTR;           {    bptr to bcpl name }
+    );
+   END;
+
+Const
+
+{ definitions for dl_Type }
+
+    DLT_DEVICE          = 0;
+    DLT_DIRECTORY       = 1;
+    DLT_VOLUME          = 2;
+    DLT_LATE            = 3;       {    late-binding assign }
+    DLT_NONBINDING      = 4;       {    non-binding assign }
+    DLT_PRIVATE         = -1;      {    for internal use only }
+
+{    structure return by GetDeviceProc() }
+Type
+
+       pDevProc = ^tDevProc;
+       tDevProc = record
+        dvp_Port        : pMsgPort;
+        dvp_Lock        : BPTR;
+        dvp_Flags       : Longint;
+        dvp_DevNode     : pDosList;    {    DON'T TOUCH OR USE! }
+       END;
+
+CONST
+{    definitions for dvp_Flags }
+     DVPB_UNLOCK   =  0;
+     DVPF_UNLOCK   =  1;
+     DVPB_ASSIGN   =  1;
+     DVPF_ASSIGN   =  2;
+
+{    Flags to be passed to LockDosList(), etc }
+     LDB_DEVICES   =  2;
+     LDF_DEVICES   =  4;
+     LDB_VOLUMES   =  3;
+     LDF_VOLUMES   =  8;
+     LDB_ASSIGNS   =  4;
+     LDF_ASSIGNS   =  16;
+     LDB_ENTRY     =  5;
+     LDF_ENTRY     =  32;
+     LDB_DELETE    =  6;
+     LDF_DELETE    =  64;
+
+{    you MUST specify one of LDF_READ or LDF_WRITE }
+     LDB_READ      =  0;
+     LDF_READ      =  1;
+     LDB_WRITE     =  1;
+     LDF_WRITE     =  2;
+
+{    actually all but LDF_ENTRY (which is used for internal locking) }
+     LDF_ALL       =  (LDF_DEVICES+LDF_VOLUMES+LDF_ASSIGNS);
+
+{    error report types for ErrorReport() }
+     REPORT_STREAM          = 0;       {    a stream }
+     REPORT_TASK            = 1;       {    a process - unused }
+     REPORT_LOCK            = 2;       {    a lock }
+     REPORT_VOLUME          = 3;       {    a volume node }
+     REPORT_INSERT          = 4;       {    please insert volume }
+
+{    Special error codes for ErrorReport() }
+     ABORT_DISK_ERROR       = 296;     {    Read/write error }
+     ABORT_BUSY             = 288;     {    You MUST replace... }
+
+{    types for initial packets to shells from run/newcli/execute/system. }
+{    For shell-writers only }
+     RUN_EXECUTE           =  -1;
+     RUN_SYSTEM            =  -2;
+     RUN_SYSTEM_ASYNCH     =  -3;
+
+{    Types for fib_DirEntryType.  NOTE that both USERDIR and ROOT are      }
+{    directories, and that directory/file checks should use <0 and >=0.    }
+{    This is not necessarily exhaustive!  Some handlers may use other      }
+{    values as needed, though <0 and >=0 should remain as supported as     }
+{    possible.                                                             }
+     ST_ROOT       =  1 ;
+     ST_USERDIR    =  2 ;
+     ST_SOFTLINK   =  3 ;      {    looks like dir, but may point to a file! }
+     ST_LINKDIR    =  4 ;      {    hard link to dir }
+     ST_FILE       =  -3;      {    must be negative for FIB! }
+     ST_LINKFILE   =  -4;      {    hard link to file }
+     ST_PIPEFILE   =  -5;      {    for pipes that support ExamineFH   }
+
+Type
+
+{ a lock structure, as returned by Lock() or DupLock() }
+
+    pFileLock = ^tFileLock;
+    tFileLock = record
+        fl_Link         : BPTR;         { bcpl pointer to next lock }
+        fl_Key          : Longint;      { disk block number }
+        fl_Access       : Longint;      { exclusive or shared }
+        fl_Task         : pMsgPort;     { handler task's port }
+        fl_Volume       : BPTR;         { bptr to a DeviceList }
+    end;
+
+
+{  NOTE: V37 dos.library, when doing ExAll() emulation, and V37 filesystems  }
+{  will return an error if passed ED_OWNER.  If you get ERROR_BAD_NUMBER,    }
+{  retry with ED_COMMENT to get everything but owner info.  All filesystems  }
+{  supporting ExAll() must support through ED_COMMENT, and must check Type   }
+{  and return ERROR_BAD_NUMBER if they don't support the type.               }
+
+{   values that can be passed for what data you want from ExAll() }
+{   each higher value includes those below it (numerically)       }
+{   you MUST chose one of these values }
+CONST
+     ED_NAME        = 1;
+     ED_TYPE        = 2;
+     ED_SIZE        = 3;
+     ED_PROTECTION  = 4;
+     ED_DATE        = 5;
+     ED_COMMENT     = 6;
+     ED_OWNER       = 7;
+{
+ *   Structure in which exall results are returned in.  Note that only the
+ *   fields asked for will exist!
+ }
+Type
+       pExAllData = ^tExAllData;
+       tExAllData = record
+        ed_Next     : pExAllData;
+        ed_Name     : STRPTR;
+        ed_Type,
+        ed_Size,
+        ed_Prot,
+        ed_Days,
+        ed_Mins,
+        ed_Ticks    : ULONG;
+        ed_Comment  : STRPTR;     {   strings will be after last used field }
+        ed_OwnerUID,              { new for V39 }
+        ed_OwnerGID : Word;
+       END;
+
+{
+ *   Control structure passed to ExAll.  Unused fields MUST be initialized to
+ *   0, expecially eac_LastKey.
+ *
+ *   eac_MatchFunc is a hook (see utility.library documentation for usage)
+ *   It should return true if the entry is to returned, false if it is to be
+ *   ignored.
+ *
+ *   This structure MUST be allocated by AllocDosObject()!
+ }
+
+       pExAllControl = ^tExAllControl;
+       tExAllControl = record
+        eac_Entries,                 {   number of entries returned in buffer      }
+        eac_LastKey     : ULONG;     {   Don't touch inbetween linked ExAll calls! }
+        eac_MatchString : STRPTR;    {   wildcard string for pattern match OR NULL }
+        eac_MatchFunc   : pHook;     {   optional private wildcard FUNCTION     }
+       END;
+
+
+
+{ The disk "environment" is a longword array that describes the
+ * disk geometry.  It is variable sized, with the length at the beginning.
+ * Here are the constants for a standard geometry.
+}
+
+Type
+
+    pDosEnvec = ^tDosEnvec;
+    tDosEnvec = record
+        de_TableSize      : ULONG;      { Size of Environment vector }
+        de_SizeBlock      : ULONG;      { in longwords: standard value is 128 }
+        de_SecOrg         : ULONG;      { not used; must be 0 }
+        de_Surfaces       : ULONG;      { # of heads (surfaces). drive specific }
+        de_SectorPerBlock : ULONG;      { not used; must be 1 }
+        de_BlocksPerTrack : ULONG;      { blocks per track. drive specific }
+        de_Reserved       : ULONG;      { DOS reserved blocks at start of partition. }
+        de_PreAlloc       : ULONG;      { DOS reserved blocks at end of partition }
+        de_Interleave     : ULONG;      { usually 0 }
+        de_LowCyl         : ULONG;      { starting cylinder. typically 0 }
+        de_HighCyl        : ULONG;      { max cylinder. drive specific }
+        de_NumBuffers     : ULONG;      { Initial # DOS of buffers.  }
+        de_BufMemType     : ULONG;      { type of mem to allocate for buffers }
+        de_MaxTransfer    : ULONG;      { Max number of bytes to transfer at a time }
+        de_Mask           : ULONG;      { Address Mask to block out certain memory }
+        de_BootPri        : Longint;    { Boot priority for autoboot }
+        de_DosType        : ULONG;      { ASCII (HEX) string showing filesystem type;
+                                        * 0X444F5300 is old filesystem,
+                                        * 0X444F5301 is fast file system }
+        de_Baud           : ULONG;      {     Baud rate for serial handler }
+        de_Control        : ULONG;      {     Control Integer for handler/filesystem }
+        de_BootBlocks     : ULONG;      {     Number of blocks containing boot code }
+    end;
+
+Const
+
+{ these are the offsets into the array }
+
+    DE_TABLESIZE        = 0;    { standard value is 11 }
+    DE_SIZEBLOCK        = 1;    { in longwords: standard value is 128 }
+    DE_SECORG           = 2;    { not used; must be 0 }
+    DE_NUMHEADS         = 3;    { # of heads (surfaces). drive specific }
+    DE_SECSPERBLK       = 4;    { not used; must be 1 }
+    DE_BLKSPERTRACK     = 5;    { blocks per track. drive specific }
+    DE_RESERVEDBLKS     = 6;    { unavailable blocks at start.   usually 2 }
+    DE_PREFAC           = 7;    { not used; must be 0 }
+    DE_INTERLEAVE       = 8;    { usually 0 }
+    DE_LOWCYL           = 9;    { starting cylinder. typically 0 }
+    DE_UPPERCYL         = 10;   { max cylinder.  drive specific }
+    DE_NUMBUFFERS       = 11;   { starting # of buffers.  typically 5 }
+    DE_MEMBUFTYPE       = 12;   { type of mem to allocate for buffers. }
+    DE_BUFMEMTYPE       = 12;   { same as above, better name
+                                 * 1 is public, 3 is chip, 5 is fast }
+    DE_MAXTRANSFER      = 13;   { Max number bytes to transfer at a time }
+    DE_MASK             = 14;   { Address Mask to block out certain memory }
+    DE_BOOTPRI          = 15;   { Boot priority for autoboot }
+    DE_DOSTYPE          = 16;   { ASCII (HEX) string showing filesystem type;
+                                 * 0X444F5300 is old filesystem,
+                                 * 0X444F5301 is fast file system }
+    DE_BAUD             = 17;   {     Baud rate for serial handler }
+    DE_CONTROL          = 18;   {     Control Integer for handler/filesystem }
+    DE_BOOTBLOCKS       = 19;   {     Number of blocks containing boot code }
+
+
+{ The file system startup message is linked into a device node's startup
+** field.  It contains a pointer to the above environment, plus the
+** information needed to do an exec OpenDevice().
+}
+
+Type
+
+    pFileSysStartupMsg = ^tFileSysStartupMsg;
+    tFileSysStartupMsg = record
+        fssm_Unit       : ULONG;        { exec unit number for this device }
+        fssm_Device     : BSTR;         { null terminated bstring to the device name }
+        fssm_Environ    : BPTR;         { ptr to environment table (see above) }
+        fssm_Flags      : ULONG;        { flags for OpenDevice() }
+    end;
+
+
+{ The include file "libraries/dosextens.h" has a DeviceList structure.
+ * The "device list" can have one of three different things linked onto
+ * it.  Dosextens defines the structure for a volume.  DLT_DIRECTORY
+ * is for an assigned directory.  The following structure is for
+ * a dos "device" (DLT_DEVICE).
+}
+
+    pDeviceNode = ^tDeviceNode;
+    tDeviceNode = record
+        dn_Next         : BPTR;         { singly linked list }
+        dn_Type         : ULONG;        { always 0 for dos "devices" }
+        dn_Task         : pMsgPort;     { standard dos "task" field.  If this is
+                                         * null when the node is accesses, a task
+                                         * will be started up }
+        dn_Lock         : BPTR;         { not used for devices -- leave null }
+        dn_Handler      : BSTR;         { filename to loadseg (if seglist is null) }
+        dn_StackSize    : ULONG;        { stacksize to use when starting task }
+        dn_Priority     : Longint;      { task priority when starting task }
+        dn_Startup      : BPTR;         { startup msg: FileSysStartupMsg for disks }
+        dn_SegList      : BPTR;         { code to run to start new task (if necessary).
+                                         * if null then dn_Handler will be loaded. }
+        dn_GlobalVec    : BPTR; { BCPL global vector to use when starting
+                                 * a task.  -1 means that dn_SegList is not
+                                 * for a bcpl program, so the dos won't
+                                 * try and construct one.  0 tell the
+                                 * dos that you obey BCPL linkage rules,
+                                 * and that it should construct a global
+                                 * vector for you.
+                                 }
+        dn_Name         : BSTR;         { the node name, e.g. '\3','D','F','3' }
+    end;
+
+CONST
+{     use of Class and code is discouraged for the time being - we might want to
+   change things }
+{     --- NotifyMessage Class ------------------------------------------------ }
+     NOTIFY_CLASS  =  $40000000;
+
+{     --- NotifyMessage Codes ------------------------------------------------ }
+     NOTIFY_CODE   =  $1234;
+
+
+{     Sent to the application if SEND_MESSAGE is specified.                    }
+
+Type
+{     Do not modify or reuse the notifyrequest while active.                   }
+{     note: the first LONG of nr_Data has the length transfered                }
+
+
+       pNotifyRequest = ^tNotifyRequest;
+       tNotifyRequest = record
+            nr_Name : pchar;
+            nr_FullName : pchar;
+            nr_UserData : ULONG;
+            nr_Flags : ULONG;
+            nr_stuff : record
+                case integer of
+                   0 : ( nr_Msg : record
+                        nr_Port : pMsgPort;
+                     end );
+                   1 : ( nr_Signal : record
+                        nr_Task : pTask;
+                        nr_SignalNum : BYTE;
+                        nr_pad : array[0..2] of BYTE;
+                     end );
+                end;
+            nr_Reserved : array[0..3] of ULONG;
+            nr_MsgCount : ULONG;
+            nr_Handler : pMsgPort;
+         end;
+
+   pNotifyMessage = ^tNotifyMessage;
+   tNotifyMessage = record
+    nm_ExecMessage : tMessage;
+    nm_Class       : ULONG;
+    nm_Code        : Word;
+    nm_NReq        : pNotifyRequest;     {     don't modify the request! }
+    nm_DoNotTouch,                       {     like it says!  For use by handlers }
+    nm_DoNotTouch2 : ULONG;            {     ditto }
+   END;
+
+
+CONST
+{     --- NotifyRequest Flags ------------------------------------------------ }
+     NRF_SEND_MESSAGE      =  1 ;
+     NRF_SEND_SIGNAL       =  2 ;
+     NRF_WAIT_REPLY        =  8 ;
+     NRF_NOTIFY_INITIAL    =  16;
+
+{     do NOT set or remove NRF_MAGIC!  Only for use by handlers! }
+     NRF_MAGIC             = $80000000;
+
+{     bit numbers }
+     NRB_SEND_MESSAGE      =  0;
+     NRB_SEND_SIGNAL       =  1;
+     NRB_WAIT_REPLY        =  3;
+     NRB_NOTIFY_INITIAL    =  4;
+
+     NRB_MAGIC             =  31;
+
+{     Flags reserved for private use by the handler: }
+     NR_HANDLER_FLAGS      =  $ffff0000;
+
+{   *********************************************************************
+ *
+ * The CSource data structure defines the input source for "ReadItem()"
+ * as well as the ReadArgs call.  It is a publicly defined structure
+ * which may be used by applications which use code that follows the
+ * conventions defined for access.
+ *
+ * When passed to the dos.library functions, the value passed as
+ * struct *CSource is defined as follows:
+ *      if ( CSource == 0)      Use buffered IO "ReadChar()" as data source
+ *      else                    Use CSource for input character stream
+ *
+ * The following two pseudo-code routines define how the CSource structure
+ * is used:
+ *
+ * long CS_ReadChar( struct CSource *CSource )
+ *
+ *      if ( CSource == 0 )     return ReadChar();
+ *      if ( CSource->CurChr >= CSource->Length )       return ENDSTREAMCHAR;
+ *      return CSource->Buffer[ CSource->CurChr++ ];
+ *
+ *
+ * BOOL CS_UnReadChar( struct CSource *CSource )
+ *
+ *      if ( CSource == 0 )     return UnReadChar();
+ *      if ( CSource->CurChr <= 0 )     return FALSE;
+ *      CSource->CurChr--;
+ *      return TRUE;
+ *
+ *
+ * To initialize a struct CSource, you set CSource->CS_Buffer to
+ * a string which is used as the data source, and set CS_Length to
+ * the number of characters in the string.  Normally CS_CurChr should
+ * be initialized to ZERO, or left as it was from prior use as
+ * a CSource.
+ *
+ *********************************************************************}
+
+Type
+       pCSource = ^tCSource;
+       tCSource = record
+        CS_Buffer  : STRPTR;
+        CS_Length,
+        CS_CurChr  : Longint;
+       END;
+
+{   *********************************************************************
+ *
+ * The RDArgs data structure is the input parameter passed to the DOS
+ * ReadArgs() function call.
+ *
+ * The RDA_Source structure is a CSource as defined above;
+ * if RDA_Source.CS_Buffer is non-null, RDA_Source is used as the input
+ * character stream to parse, else the input comes from the buffered STDIN
+ * calls ReadChar/UnReadChar.
+ *
+ * RDA_DAList is a private address which is used internally to track
+ * allocations which are freed by FreeArgs().  This MUST be initialized
+ * to NULL prior to the first call to ReadArgs().
+ *
+ * The RDA_Buffer and RDA_BufSiz fields allow the application to supply
+ * a fixed-size buffer in which to store the parsed data.  This allows
+ * the application to pre-allocate a buffer rather than requiring buffer
+ * space to be allocated.  If either RDA_Buffer or RDA_BufSiz is NULL,
+ * the application has not supplied a buffer.
+ *
+ * RDA_ExtHelp is a text string which will be displayed instead of the
+ * template string, if the user is prompted for input.
+ *
+ * RDA_Flags bits control how ReadArgs() works.  The flag bits are
+ * defined below.  Defaults are initialized to ZERO.
+ *
+ *********************************************************************}
+
+       pRDArgs = ^tRDArgs;
+       tRDArgs = record
+        RDA_Source  : tCSource;     {    Select input source }
+        RDA_DAList  : Longint;      {    PRIVATE. }
+        RDA_Buffer  : STRPTR;       {    Optional string parsing space. }
+        RDA_BufSiz  : Longint;      {    Size of RDA_Buffer (0..n) }
+        RDA_ExtHelp : STRPTR;       {    Optional extended help }
+        RDA_Flags   : Longint;      {    Flags for any required control }
+       END;
+
+CONST
+       RDAB_STDIN     = 0;       {    Use "STDIN" rather than "COMMAND LINE" }
+       RDAF_STDIN     = 1;
+       RDAB_NOALLOC   = 1;       {    If set, do not allocate extra string space.}
+       RDAF_NOALLOC   = 2;
+       RDAB_NOPROMPT  = 2;       {    Disable reprompting for string input. }
+       RDAF_NOPROMPT  = 4;
+
+{   *********************************************************************
+ * Maximum number of template keywords which can be in a template passed
+ * to ReadArgs(). IMPLEMENTOR NOTE - must be a multiple of 4.
+ *********************************************************************}
+       MAX_TEMPLATE_ITEMS     = 100;
+
+{   *********************************************************************
+ * Maximum number of MULTIARG items returned by ReadArgs(), before
+ * an ERROR_LINE_TOO_LONG.  These two limitations are due to stack
+ * usage.  Applications should allow "a lot" of stack to use ReadArgs().
+ *********************************************************************}
+       MAX_MULTIARGS          = 128;
+
+CONST
+{     Modes for LockRecord/LockRecords() }
+       REC_EXCLUSIVE          = 0;
+       REC_EXCLUSIVE_IMMED    = 1;
+       REC_SHARED             = 2;
+       REC_SHARED_IMMED       = 3;
+
+{     struct to be passed to LockRecords()/UnLockRecords() }
+
+Type
+       pRecordLock = ^tRecordLock;
+       tRecordLock = record
+        rec_FH    : BPTR;         {     filehandle }
+        rec_Offset,               {     offset in file }
+        rec_Length,               {     length of file to be locked }
+        rec_Mode  : ULONG;        {     Type of lock }
+       END;
+
+
+{      the structure in the pr_LocalVars list }
+{      Do NOT allocate yourself, use SetVar()!!! This structure may grow in }
+{      future releases!  The list should be left in alphabetical order, and }
+{      may have multiple entries with the same name but different types.    }
+Type
+       pLocalVar = ^tLocalVar;
+       tLocalVar = record
+        lv_Node  : tNode;
+        lv_Flags : Word;
+        lv_Value : STRPTR;
+        lv_Len   : ULONG;
+       END;
+
+{
+ * The lv_Flags bits are available to the application.  The unused
+ * lv_Node.ln_Pri bits are reserved for system use.
+ }
+
+CONST
+{      bit definitions for lv_Node.ln_Type: }
+       LV_VAR               =   0;       {      an variable }
+       LV_ALIAS             =   1;       {      an alias }
+{      to be or'ed into type: }
+       LVB_IGNORE           =   7;       {      ignore this entry on GetVar, etc }
+       LVF_IGNORE           =   $80;
+
+{      definitions of flags passed to GetVar()/SetVar()/DeleteVar() }
+{      bit defs to be OR'ed with the type: }
+{      item will be treated as a single line of text unless BINARY_VAR is used }
+       GVB_GLOBAL_ONLY       =  8   ;
+       GVF_GLOBAL_ONLY       =  $100;
+       GVB_LOCAL_ONLY        =  9   ;
+       GVF_LOCAL_ONLY        =  $200;
+       GVB_BINARY_VAR        =  10  ;            {      treat variable as binary }
+       GVF_BINARY_VAR        =  $400;
+       GVB_DONT_NULL_TERM    =  11;            { only with GVF_BINARY_VAR }
+       GVF_DONT_NULL_TERM    =  $800;
+
+{ this is only supported in >= V39 dos.  V37 dos ignores this. }
+{ this causes SetVar to affect ENVARC: as well as ENV:.        }
+      GVB_SAVE_VAR           = 12 ;     { only with GVF_GLOBAL_VAR }
+      GVF_SAVE_VAR           = $1000 ;
+
+
+CONST
+{   ***************************************************************************}
+{    definitions for the System() call }
+
+    SYS_Dummy      = (TAG_USER + 32);
+    SYS_Input      = (SYS_Dummy + 1);
+                                {    specifies the input filehandle  }
+    SYS_Output     = (SYS_Dummy + 2);
+                                {    specifies the output filehandle }
+    SYS_Asynch     = (SYS_Dummy + 3);
+                                {    run asynch, close input/output on exit(!) }
+    SYS_UserShell  = (SYS_Dummy + 4);
+                                {    send to user shell instead of boot shell }
+    SYS_CustomShell= (SYS_Dummy + 5);
+                                {    send to a specific shell (data is name) }
+{         SYS_Error, }
+
+
+{   ***************************************************************************}
+{    definitions for the CreateNewProc() call }
+{    you MUST specify one of NP_Seglist or NP_Entry.  All else is optional. }
+
+    NP_Dummy       = (TAG_USER + 1000);
+    NP_Seglist     = (NP_Dummy + 1);
+                                {    seglist of code to run for the process  }
+    NP_FreeSeglist = (NP_Dummy + 2);
+                                {    free seglist on exit - only valid for   }
+                                {    for NP_Seglist.  Default is TRUE.       }
+    NP_Entry       = (NP_Dummy + 3);
+                                {    entry point to run - mutually exclusive }
+                                {    with NP_Seglist! }
+    NP_Input       = (NP_Dummy + 4);
+                                {    filehandle - default is Open("NIL:"...) }
+    NP_Output      = (NP_Dummy + 5);
+                                {    filehandle - default is Open("NIL:"...) }
+    NP_CloseInput  = (NP_Dummy + 6);
+                                {    close input filehandle on exit          }
+                                {    default TRUE                            }
+    NP_CloseOutput = (NP_Dummy + 7);
+                                {    close output filehandle on exit         }
+                                {    default TRUE                            }
+    NP_Error       = (NP_Dummy + 8);
+                                {    filehandle - default is Open("NIL:"...) }
+    NP_CloseError  = (NP_Dummy + 9);
+                                {    close error filehandle on exit          }
+                                {    default TRUE                            }
+    NP_CurrentDir  = (NP_Dummy + 10);
+                                {    lock - default is parent's current dir  }
+    NP_StackSize   = (NP_Dummy + 11);
+                                {    stacksize for process - default 4000    }
+    NP_Name        = (NP_Dummy + 12);
+                                {    name for process - default "New Process"}
+    NP_Priority    = (NP_Dummy + 13);
+                                {    priority - default same as parent       }
+    NP_ConsoleTask = (NP_Dummy + 14);
+                                {    consoletask - default same as parent    }
+    NP_WindowPtr   = (NP_Dummy + 15);
+                                {    window ptr - default is same as parent  }
+    NP_HomeDir     = (NP_Dummy + 16);
+                                {    home directory - default curr home dir  }
+    NP_CopyVars    = (NP_Dummy + 17);
+                                {    boolean to copy local vars-default TRUE }
+    NP_Cli         = (NP_Dummy + 18);
+                                {    create cli structure - default FALSE    }
+    NP_Path        = (NP_Dummy + 19);
+                                {    path - default is copy of parents path  }
+                                {    only valid if a cli process!    }
+    NP_CommandName = (NP_Dummy + 20);
+                                {    commandname - valid only for CLI        }
+    NP_Arguments   = (NP_Dummy + 21);
+                                {    cstring of arguments - passed with str  }
+                                {    in a0, length in d0.  (copied and freed }
+                                {    on exit.  Default is empty string.      }
+                                {    NOTE: not operational until 2.04 - see  }
+                                {    BIX/TechNotes for more info/workarounds }
+                                {    NOTE: in 2.0, it DIDN'T pass "" - the   }
+                                {    registers were random.                  }
+{    FIX! should this be only for cli's? }
+    NP_NotifyOnDeath = (NP_Dummy + 22);
+                                {    notify parent on death - default FALSE  }
+                                {    Not functional yet. }
+    NP_Synchronous   = (NP_Dummy + 23);
+                                {    don't return until process finishes -   }
+                                {    default FALSE.                          }
+                                {    Not functional yet. }
+    NP_ExitCode      = (NP_Dummy + 24);
+                                {    code to be called on process exit       }
+    NP_ExitData      = (NP_Dummy + 25);
+                                {    optional argument for NP_EndCode rtn -  }
+                                {    default NULL                            }
+
+
+{   ***************************************************************************}
+{    tags for AllocDosObject }
+
+    ADO_Dummy        = (TAG_USER + 2000);
+    ADO_FH_Mode      = (ADO_Dummy + 1);
+                                {    for type DOS_FILEHANDLE only            }
+                                {    sets up FH for mode specified.
+                                   This can make a big difference for buffered
+                                   files.                                  }
+        {    The following are for DOS_CLI }
+        {    If you do not specify these, dos will use it's preferred values }
+        {    which may change from release to release.  The BPTRs to these   }
+        {    will be set up correctly for you.  Everything will be zero,     }
+        {    except cli_FailLevel (10) and cli_Background (DOSTRUE).         }
+        {    NOTE: you may also use these 4 tags with CreateNewProc.         }
+
+    ADO_DirLen     = (ADO_Dummy + 2);
+                                {    size in bytes for current dir buffer    }
+    ADO_CommNameLen= (ADO_Dummy + 3);
+                                {    size in bytes for command name buffer   }
+    ADO_CommFileLen= (ADO_Dummy + 4);
+                                {    size in bytes for command file buffer   }
+    ADO_PromptLen  = (ADO_Dummy + 5);
+                                {    size in bytes for the prompt buffer     }
+
+{   ***************************************************************************}
+{    tags for NewLoadSeg }
+{    no tags are defined yet for NewLoadSeg }
+
+
+PROCEDURE AbortPkt(port : pMsgPort; pkt : pDosPacket);
+FUNCTION AddBuffers(name : pCHAR; number : LONGINT) : BOOLEAN;
+FUNCTION AddDosEntry(dlist : pDosList) : BOOLEAN;
+FUNCTION AddPart(dirname : pCHAR; filename : pCHAR; size : ULONG) : BOOLEAN;
+FUNCTION AddSegment(name : pCHAR; seg : LONGINT; system : LONGINT) : BOOLEAN;
+FUNCTION AllocDosObject(type_ : ULONG; tags : pTagItem) : POINTER;
+FUNCTION AllocDosObjectTagList(type_ : ULONG; tags : pTagItem) : POINTER;
+FUNCTION AssignAdd(name : pCHAR; lock : LONGINT) : BOOLEAN;
+FUNCTION AssignLate(name : pCHAR; path : pCHAR) : BOOLEAN;
+FUNCTION AssignLock(name : pCHAR; lock : LONGINT) : BOOLEAN;
+FUNCTION AssignPath(name : pCHAR; path : pCHAR) : BOOLEAN;
+FUNCTION AttemptLockDosList(flags : ULONG) : pDosList;
+FUNCTION ChangeMode(type_ : LONGINT; fh : LONGINT; newmode : LONGINT) : BOOLEAN;
+FUNCTION CheckSignal(mask : LONGINT) : LONGINT;
+FUNCTION Cli : pCommandLineInterface;
+FUNCTION CliInitNewcli(dp : pDosPacket) : LONGINT;
+FUNCTION CliInitRun(dp : pDosPacket) : LONGINT;
+FUNCTION CompareDates(date1 : pDateStamp; date2 : pDateStamp) : LONGINT;
+FUNCTION CreateDir(name : pCHAR) : LONGINT;
+FUNCTION CreateNewProc(tags : pTagItem) : pProcess;
+FUNCTION CreateNewProcTagList(tags : pTagItem) : pProcess;
+FUNCTION CreateProc(name : pCHAR; pri : LONGINT; segList : LONGINT; stackSize : LONGINT) : pMsgPort;
+FUNCTION CurrentDir(lock : LONGINT) : LONGINT;
+PROCEDURE DateStamp(VAR date : pDateStamp);
+FUNCTION DateToStr(datetime : pDateTime) : BOOLEAN;
+FUNCTION DeleteFile(name : pCHAR) : BOOLEAN;
+FUNCTION DeleteVar(name : pCHAR; flags : ULONG) : BOOLEAN;
+FUNCTION DeviceProc(name : pCHAR) : pMsgPort;
+FUNCTION DoPkt(port : pMsgPort; action : LONGINT; arg1 : LONGINT; arg2 : LONGINT; arg3 : LONGINT; arg4 : LONGINT; arg5 : LONGINT) : LONGINT;
+FUNCTION DoPkt0(port : pMsgPort; action : LONGINT) : LONGINT;
+FUNCTION DoPkt1(port : pMsgPort; action : LONGINT; arg1 : LONGINT) : LONGINT;
+FUNCTION DoPkt2(port : pMsgPort; action : LONGINT; arg1 : LONGINT; arg2 : LONGINT) : LONGINT;
+FUNCTION DoPkt3(port : pMsgPort; action : LONGINT; arg1 : LONGINT; arg2 : LONGINT; arg3 : LONGINT) : LONGINT;
+FUNCTION DoPkt4(port : pMsgPort; action : LONGINT; arg1 : LONGINT; arg2 : LONGINT; arg3 : LONGINT; arg4 : LONGINT) : LONGINT;
+PROCEDURE DOSClose(file_ : LONGINT);
+PROCEDURE DOSDelay(timeout : LONGINT);
+PROCEDURE DOSExit(returnCode : LONGINT);
+FUNCTION DOSFlush(fh : LONGINT) : BOOLEAN;
+FUNCTION DOSInput : LONGINT;
+FUNCTION DOSOpen(name : pCHAR; accessMode : LONGINT) : LONGINT;
+FUNCTION DOSOutput : LONGINT;
+FUNCTION DOSRead(file_ : LONGINT; buffer : POINTER; length : LONGINT) : LONGINT;
+FUNCTION DOSRename(oldName : pCHAR; newName : pCHAR) : LONGINT;
+FUNCTION DOSSeek(file_ : LONGINT; position : LONGINT; offset : LONGINT) : LONGINT;
+FUNCTION DOSWrite(file_ : LONGINT; buffer : POINTER; length : LONGINT) : LONGINT;
+FUNCTION DupLock(lock : LONGINT) : LONGINT;
+FUNCTION DupLockFromFH(fh : LONGINT) : LONGINT;
+PROCEDURE EndNotify(notify : pNotifyRequest);
+FUNCTION ErrorReport(code : LONGINT; type_ : LONGINT; arg1 : ULONG; device : pMsgPort) : BOOLEAN;
+FUNCTION ExAll(lock : LONGINT; buffer : pExAllData; size : LONGINT; data : LONGINT; control : pExAllControl) : BOOLEAN;
+PROCEDURE ExAllEnd(lock : LONGINT; buffer : pExAllData; size : LONGINT; data : LONGINT; control : pExAllControl);
+FUNCTION Examine(lock : LONGINT; fileInfoBlock : pFileInfoBlock) : BOOLEAN;
+FUNCTION ExamineFH(fh : LONGINT; fib : pFileInfoBlock) : BOOLEAN;
+FUNCTION Execute(string_ : pCHAR; file_ : LONGINT; file2 : LONGINT) : BOOLEAN;
+FUNCTION ExNext(lock : LONGINT; fileInfoBlock : pFileInfoBlock) : BOOLEAN;
+FUNCTION Fault(code : LONGINT; header : pCHAR; buffer : pCHAR; len : LONGINT) : BOOLEAN;
+FUNCTION FGetC(fh : LONGINT) : LONGINT;
+FUNCTION FGets(fh : LONGINT; buf : pCHAR; buflen : ULONG) : pCHAR;
+FUNCTION FilePart(path : pCHAR) : pCHAR;
+FUNCTION FindArg(keyword : pCHAR; arg_template : pCHAR) : LONGINT;
+FUNCTION FindCliProc(num : ULONG) : pProcess;
+FUNCTION FindDosEntry(dlist : pDosList; name : pCHAR; flags : ULONG) : pDosList;
+FUNCTION FindSegment(name : pCHAR; seg : pSegment; system : LONGINT) : pSegment;
+FUNCTION FindVar(name : pCHAR; type_ : ULONG) : pLocalVar;
+FUNCTION Format(filesystem : pCHAR; volumename : pCHAR; dostype : ULONG) : BOOLEAN;
+FUNCTION FPutC(fh : LONGINT; ch : LONGINT) : LONGINT;
+FUNCTION FPuts(fh : LONGINT; str : pCHAR) : BOOLEAN;
+FUNCTION FRead(fh : LONGINT; block : POINTER; blocklen : ULONG; number : ULONG) : LONGINT;
+PROCEDURE FreeArgs(args : pRDArgs);
+PROCEDURE FreeDeviceProc(dp : pDevProc);
+PROCEDURE FreeDosEntry(dlist : pDosList);
+PROCEDURE FreeDosObject(type_ : ULONG; ptr : POINTER);
+FUNCTION FWrite(fh : LONGINT; block : POINTER; blocklen : ULONG; number : ULONG) : LONGINT;
+FUNCTION GetArgStr : pCHAR;
+FUNCTION GetConsoleTask : pMsgPort;
+FUNCTION GetCurrentDirName(buf : pCHAR; len : LONGINT) : BOOLEAN;
+FUNCTION GetDeviceProc(name : pCHAR; dp : pDevProc) : pDevProc;
+FUNCTION GetFileSysTask : pMsgPort;
+FUNCTION GetProgramDir : LONGINT;
+FUNCTION GetProgramName(buf : pCHAR; len : LONGINT) : BOOLEAN;
+FUNCTION GetPrompt(buf : pCHAR; len : LONGINT) : BOOLEAN;
+FUNCTION GetVar(name : pCHAR; buffer : pCHAR; size : LONGINT; flags : LONGINT) : LONGINT;
+FUNCTION Info(lock : LONGINT; parameterBlock : pInfoData) : BOOLEAN;
+FUNCTION Inhibit(name : pCHAR; onoff : LONGINT) : BOOLEAN;
+FUNCTION InternalLoadSeg(fh : LONGINT; table : LONGINT; VAR funcarray : LONGINT; VAR stack : LONGINT) : LONGINT;
+FUNCTION InternalUnLoadSeg(seglist : LONGINT; freefunc : tPROCEDURE) : BOOLEAN;
+FUNCTION IoErr : LONGINT;
+FUNCTION IsFileSystem(name : pCHAR) : BOOLEAN;
+FUNCTION IsInteractive(file_ : LONGINT) : BOOLEAN;
+FUNCTION LoadSeg(name : pCHAR) : LONGINT;
+FUNCTION Lock(name : pCHAR; type_ : LONGINT) : LONGINT;
+FUNCTION LockDosList(flags : ULONG) : pDosList;
+FUNCTION LockRecord(fh : LONGINT; offset : ULONG; length : ULONG; mode : ULONG; timeout : ULONG) : BOOLEAN;
+FUNCTION LockRecords(recArray : pRecordLock; timeout : ULONG) : BOOLEAN;
+FUNCTION MakeDosEntry(name : pCHAR; type_ : LONGINT) : pDosList;
+FUNCTION MakeLink(name : pCHAR; dest : LONGINT; soft : LONGINT) : BOOLEAN;
+PROCEDURE MatchEnd(anchor : pAnchorPath);
+FUNCTION MatchFirst(pat : pCHAR; anchor : pAnchorPath) : LONGINT;
+FUNCTION MatchNext(anchor : pAnchorPath) : LONGINT;
+FUNCTION MatchPattern(pat : pCHAR; str : pCHAR) : BOOLEAN;
+FUNCTION MatchPatternNoCase(pat : pCHAR; str : pCHAR) : BOOLEAN;
+FUNCTION MaxCli : ULONG;
+FUNCTION NameFromFH(fh : LONGINT; buffer : pCHAR; len : LONGINT) : BOOLEAN;
+FUNCTION NameFromLock(lock : LONGINT; buffer : pCHAR; len : LONGINT) : BOOLEAN;
+FUNCTION NewLoadSeg(file_ : pCHAR; tags : pTagItem) : LONGINT;
+FUNCTION NewLoadSegTagList(file_ : pCHAR; tags : pTagItem) : LONGINT;
+FUNCTION NextDosEntry(dlist : pDosList; flags : ULONG) : pDosList;
+FUNCTION OpenFromLock(lock : LONGINT) : LONGINT;
+FUNCTION ParentDir(lock : LONGINT) : LONGINT;
+FUNCTION ParentOfFH(fh : LONGINT) : LONGINT;
+FUNCTION ParsePattern(pat : pCHAR; buf : pCHAR; buflen : LONGINT) : LONGINT;
+FUNCTION ParsePatternNoCase(pat : pCHAR; buf : pCHAR; buflen : LONGINT) : LONGINT;
+FUNCTION PathPart(path : pCHAR) : pCHAR;
+FUNCTION PrintFault(code : LONGINT; header : pCHAR) : BOOLEAN;
+FUNCTION PutStr(str : pCHAR) : BOOLEAN;
+FUNCTION ReadArgs(arg_template : pCHAR; VAR arra : LONGINT; args : pRDArgs) : pRDArgs;
+FUNCTION ReadItem(name : pCHAR; maxchars : LONGINT; cSource : pCSource) : LONGINT;
+FUNCTION ReadLink(port : pMsgPort; lock : LONGINT; path : pCHAR; buffer : pCHAR; size : ULONG) : BOOLEAN;
+FUNCTION Relabel(drive : pCHAR; newname : pCHAR) : BOOLEAN;
+FUNCTION RemAssignList(name : pCHAR; lock : LONGINT) : BOOLEAN;
+FUNCTION RemDosEntry(dlist : pDosList) : BOOLEAN;
+FUNCTION RemSegment(seg : pSegment) : BOOLEAN;
+PROCEDURE ReplyPkt(dp : pDosPacket; res1 : LONGINT; res2 : LONGINT);
+FUNCTION RunCommand(seg : LONGINT; stack : LONGINT; paramptr : pCHAR; paramlen : LONGINT) : LONGINT;
+FUNCTION SameDevice(lock1 : LONGINT; lock2 : LONGINT) : BOOLEAN;
+FUNCTION SameLock(lock1 : LONGINT; lock2 : LONGINT) : LONGINT;
+FUNCTION SelectInput(fh : LONGINT) : LONGINT;
+FUNCTION SelectOutput(fh : LONGINT) : LONGINT;
+PROCEDURE SendPkt(dp : pDosPacket; port : pMsgPort; replyport : pMsgPort);
+FUNCTION SetArgStr(string_ : pCHAR) : BOOLEAN;
+FUNCTION SetComment(name : pCHAR; comment : pCHAR) : BOOLEAN;
+FUNCTION SetConsoleTask(task : pMsgPort) : pMsgPort;
+FUNCTION SetCurrentDirName(name : pCHAR) : BOOLEAN;
+FUNCTION SetFileDate(name : pCHAR; date : pDateStamp) : BOOLEAN;
+FUNCTION SetFileSize(fh : LONGINT; pos : LONGINT; mode : LONGINT) : BOOLEAN;
+FUNCTION SetFileSysTask(task : pMsgPort) : pMsgPort;
+FUNCTION SetIoErr(result : LONGINT) : LONGINT;
+FUNCTION SetMode(fh : LONGINT; mode : LONGINT) : BOOLEAN;
+FUNCTION SetOwner(name : pCHAR; owner_info : LONGINT) : BOOLEAN;
+FUNCTION SetProgramDir(lock : LONGINT) : LONGINT;
+FUNCTION SetProgramName(name : pCHAR) : BOOLEAN;
+FUNCTION SetPrompt(name : pCHAR) : BOOLEAN;
+FUNCTION SetProtection(name : pCHAR; protect : LONGINT) : BOOLEAN;
+FUNCTION SetVar(name : pCHAR; buffer : pCHAR; size : LONGINT; flags : LONGINT) : BOOLEAN;
+FUNCTION SetVBuf(fh : LONGINT; buff : pCHAR; type_ : LONGINT; size : LONGINT) : BOOLEAN;
+FUNCTION SplitName(name : pCHAR; seperator : ULONG; buf : pCHAR; oldpos : LONGINT; size : LONGINT) : INTEGER;
+FUNCTION StartNotify(notify : pNotifyRequest) : BOOLEAN;
+FUNCTION StrToDate(datetime : pDateTime) : BOOLEAN;
+FUNCTION StrToLong(string_ : pCHAR; VAR value : LONGINT) : LONGINT;
+FUNCTION SystemTagList(command : pCHAR; tags : pTagItem) : LONGINT;
+FUNCTION DOSSystem(command : pCHAR; tags : pTagItem) : LONGINT;
+FUNCTION UnGetC(fh : LONGINT; character : LONGINT) : LONGINT;
+PROCEDURE UnLoadSeg(seglist : LONGINT);
+PROCEDURE UnLock(lock : LONGINT);
+PROCEDURE UnLockDosList(flags : ULONG);
+FUNCTION UnLockRecord(fh : LONGINT; offset : ULONG; length : ULONG) : BOOLEAN;
+FUNCTION UnLockRecords(recArray : pRecordLock) : BOOLEAN;
+FUNCTION VFPrintf(fh : LONGINT; format : pCHAR; argarray : POINTER) : LONGINT;
+PROCEDURE VFWritef(fh : LONGINT; format : pCHAR; VAR argarray : LONGINT);
+FUNCTION VPrintf(format : pCHAR; argarray : POINTER) : LONGINT;
+FUNCTION WaitForChar(file_ : LONGINT; timeout : LONGINT) : BOOLEAN;
+FUNCTION WaitPkt : pDosPacket;
+FUNCTION WriteChars(buf : pCHAR; buflen : ULONG) : LONGINT;
+
+FUNCTION BADDR(bval :BPTR): POINTER;
+FUNCTION MKBADDR(adr: Pointer): BPTR;
+
+IMPLEMENTATION
+
+FUNCTION BADDR(bval : BPTR): POINTER;
+BEGIN
+    BADDR := POINTER( bval shl 2);
+END;
+
+FUNCTION MKBADDR(adr : POINTER): BPTR;
+BEGIN
+    MKBADDR := BPTR( LONGINT(adr) shr 2);
+END;
+
+PROCEDURE AbortPkt(port : pMsgPort; pkt : pDosPacket);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  port,D1
+    MOVE.L  pkt,D2
+    MOVEA.L _DOSBase,A6
+    JSR -264(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION AddBuffers(name : pCHAR; number : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  number,D2
+    MOVEA.L _DOSBase,A6
+    JSR -732(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION AddDosEntry(dlist : pDosList) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  dlist,D1
+    MOVEA.L _DOSBase,A6
+    JSR -678(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION AddPart(dirname : pCHAR; filename : pCHAR; size : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  dirname,D1
+    MOVE.L  filename,D2
+    MOVE.L  size,D3
+    MOVEA.L _DOSBase,A6
+    JSR -882(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION AddSegment(name : pCHAR; seg : LONGINT; system : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  seg,D2
+    MOVE.L  system,D3
+    MOVEA.L _DOSBase,A6
+    JSR -774(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION AllocDosObject(type_ : ULONG; tags : pTagItem) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  type_,D1
+    MOVE.L  tags,D2
+    MOVEA.L _DOSBase,A6
+    JSR -228(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AllocDosObjectTagList(type_ : ULONG; tags : pTagItem) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  type_,D1
+    MOVE.L  tags,D2
+    MOVEA.L _DOSBase,A6
+    JSR -228(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AssignAdd(name : pCHAR; lock : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  lock,D2
+    MOVEA.L _DOSBase,A6
+    JSR -630(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION AssignLate(name : pCHAR; path : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  path,D2
+    MOVEA.L _DOSBase,A6
+    JSR -618(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION AssignLock(name : pCHAR; lock : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  lock,D2
+    MOVEA.L _DOSBase,A6
+    JSR -612(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION AssignPath(name : pCHAR; path : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  path,D2
+    MOVEA.L _DOSBase,A6
+    JSR -624(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION AttemptLockDosList(flags : ULONG) : pDosList;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  flags,D1
+    MOVEA.L _DOSBase,A6
+    JSR -666(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ChangeMode(type_ : LONGINT; fh : LONGINT; newmode : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  type_,D1
+    MOVE.L  fh,D2
+    MOVE.L  newmode,D3
+    MOVEA.L _DOSBase,A6
+    JSR -450(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION CheckSignal(mask : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  mask,D1
+    MOVEA.L _DOSBase,A6
+    JSR -792(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION Cli : pCommandLineInterface;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _DOSBase,A6
+    JSR -492(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CliInitNewcli(dp : pDosPacket) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L dp,A0
+    MOVEA.L _DOSBase,A6
+    JSR -930(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CliInitRun(dp : pDosPacket) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L dp,A0
+    MOVEA.L _DOSBase,A6
+    JSR -936(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CompareDates(date1 : pDateStamp; date2 : pDateStamp) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  date1,D1
+    MOVE.L  date2,D2
+    MOVEA.L _DOSBase,A6
+    JSR -738(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CreateDir(name : pCHAR) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVEA.L _DOSBase,A6
+    JSR -120(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CreateNewProc(tags : pTagItem) : pProcess;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  tags,D1
+    MOVEA.L _DOSBase,A6
+    JSR -498(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CreateNewProcTagList(tags : pTagItem) : pProcess;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  tags,D1
+    MOVEA.L _DOSBase,A6
+    JSR -498(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CreateProc(name : pCHAR; pri : LONGINT; segList : LONGINT; stackSize : LONGINT) : pMsgPort;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  pri,D2
+    MOVE.L  segList,D3
+    MOVE.L  stackSize,D4
+    MOVEA.L _DOSBase,A6
+    JSR -138(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CurrentDir(lock : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  lock,D1
+    MOVEA.L _DOSBase,A6
+    JSR -126(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE DateStamp(VAR date : pDateStamp);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  date,D1
+    MOVEA.L _DOSBase,A6
+    JSR -192(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION DateToStr(datetime : pDateTime) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  datetime,D1
+    MOVEA.L _DOSBase,A6
+    JSR -744(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION DeleteFile(name : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVEA.L _DOSBase,A6
+    JSR -072(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION DeleteVar(name : pCHAR; flags : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  flags,D2
+    MOVEA.L _DOSBase,A6
+    JSR -912(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION DeviceProc(name : pCHAR) : pMsgPort;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVEA.L _DOSBase,A6
+    JSR -174(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DoPkt(port : pMsgPort; action : LONGINT; arg1 : LONGINT; arg2 : LONGINT; arg3 : LONGINT; arg4 : LONGINT; arg5 : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  port,D1
+    MOVE.L  action,D2
+    MOVE.L  arg1,D3
+    MOVE.L  arg2,D4
+    MOVE.L  arg3,D5
+    MOVE.L  arg4,D6
+    MOVE.L  arg5,D7
+    MOVEA.L _DOSBase,A6
+    JSR -240(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DoPkt0(port : pMsgPort; action : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  port,D1
+    MOVE.L  action,D2
+    MOVEA.L _DOSBase,A6
+    JSR -240(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DoPkt1(port : pMsgPort; action : LONGINT; arg1 : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  port,D1
+    MOVE.L  action,D2
+    MOVE.L  arg1,D3
+    MOVEA.L _DOSBase,A6
+    JSR -240(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DoPkt2(port : pMsgPort; action : LONGINT; arg1 : LONGINT; arg2 : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  port,D1
+    MOVE.L  action,D2
+    MOVE.L  arg1,D3
+    MOVE.L  arg2,D4
+    MOVEA.L _DOSBase,A6
+    JSR -240(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DoPkt3(port : pMsgPort; action : LONGINT; arg1 : LONGINT; arg2 : LONGINT; arg3 : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  port,D1
+    MOVE.L  action,D2
+    MOVE.L  arg1,D3
+    MOVE.L  arg2,D4
+    MOVE.L  arg3,D5
+    MOVEA.L _DOSBase,A6
+    JSR -240(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DoPkt4(port : pMsgPort; action : LONGINT; arg1 : LONGINT; arg2 : LONGINT; arg3 : LONGINT; arg4 : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  port,D1
+    MOVE.L  action,D2
+    MOVE.L  arg1,D3
+    MOVE.L  arg2,D4
+    MOVE.L  arg3,D5
+    MOVE.L  arg4,D6
+    MOVEA.L _DOSBase,A6
+    JSR -240(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE DOSClose(file_ : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  file_,D1
+    MOVEA.L _DOSBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE DOSDelay(timeout : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  timeout,D1
+    MOVEA.L _DOSBase,A6
+    JSR -198(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE DOSExit(returnCode : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  returnCode,D1
+    MOVEA.L _DOSBase,A6
+    JSR -144(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION DOSFlush(fh : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVEA.L _DOSBase,A6
+    JSR -360(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION DOSInput : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _DOSBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DOSOpen(name : pCHAR; accessMode : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  accessMode,D2
+    MOVEA.L _DOSBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DOSOutput : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _DOSBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DOSRead(file_ : LONGINT; buffer : POINTER; length : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  file_,D1
+    MOVE.L  buffer,D2
+    MOVE.L  length,D3
+    MOVEA.L _DOSBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DOSRename(oldName : pCHAR; newName : pCHAR) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  oldName,D1
+    MOVE.L  newName,D2
+    MOVEA.L _DOSBase,A6
+    JSR -078(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DOSSeek(file_ : LONGINT; position : LONGINT; offset : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  file_,D1
+    MOVE.L  position,D2
+    MOVE.L  offset,D3
+    MOVEA.L _DOSBase,A6
+    JSR -066(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DOSWrite(file_ : LONGINT; buffer : POINTER; length : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  file_,D1
+    MOVE.L  buffer,D2
+    MOVE.L  length,D3
+    MOVEA.L _DOSBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DupLock(lock : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  lock,D1
+    MOVEA.L _DOSBase,A6
+    JSR -096(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DupLockFromFH(fh : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVEA.L _DOSBase,A6
+    JSR -372(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE EndNotify(notify : pNotifyRequest);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  notify,D1
+    MOVEA.L _DOSBase,A6
+    JSR -894(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION ErrorReport(code : LONGINT; type_ : LONGINT; arg1 : ULONG; device : pMsgPort) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  code,D1
+    MOVE.L  type_,D2
+    MOVE.L  arg1,D3
+    MOVE.L  device,D4
+    MOVEA.L _DOSBase,A6
+    JSR -480(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION ExAll(lock : LONGINT; buffer : pExAllData; size : LONGINT; data : LONGINT; control : pExAllControl) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  lock,D1
+    MOVE.L  buffer,D2
+    MOVE.L  size,D3
+    MOVE.L  data,D4
+    MOVE.L  control,D5
+    MOVEA.L _DOSBase,A6
+    JSR -432(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ExAllEnd(lock : LONGINT; buffer : pExAllData; size : LONGINT; data : LONGINT; control : pExAllControl);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  lock,D1
+    MOVE.L  buffer,D2
+    MOVE.L  size,D3
+    MOVE.L  data,D4
+    MOVE.L  control,D5
+    MOVEA.L _DOSBase,A6
+    JSR -990(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION Examine(lock : LONGINT; fileInfoBlock : pFileInfoBlock) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  lock,D1
+    MOVE.L  fileInfoBlock,D2
+    MOVEA.L _DOSBase,A6
+    JSR -102(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION ExamineFH(fh : LONGINT; fib : pFileInfoBlock) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVE.L  fib,D2
+    MOVEA.L _DOSBase,A6
+    JSR -390(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION Execute(string_ : pCHAR; file_ : LONGINT; file2 : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  string_,D1
+    MOVE.L  file_,D2
+    MOVE.L  file2,D3
+    MOVEA.L _DOSBase,A6
+    JSR -222(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION ExNext(lock : LONGINT; fileInfoBlock : pFileInfoBlock) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  lock,D1
+    MOVE.L  fileInfoBlock,D2
+    MOVEA.L _DOSBase,A6
+    JSR -108(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION Fault(code : LONGINT; header : pCHAR; buffer : pCHAR; len : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  code,D1
+    MOVE.L  header,D2
+    MOVE.L  buffer,D3
+    MOVE.L  len,D4
+    MOVEA.L _DOSBase,A6
+    JSR -468(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION FGetC(fh : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVEA.L _DOSBase,A6
+    JSR -306(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION FGets(fh : LONGINT; buf : pCHAR; buflen : ULONG) : pCHAR;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVE.L  buf,D2
+    MOVE.L  buflen,D3
+    MOVEA.L _DOSBase,A6
+    JSR -336(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION FilePart(path : pCHAR) : pCHAR;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  path,D1
+    MOVEA.L _DOSBase,A6
+    JSR -870(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION FindArg(keyword : pCHAR; arg_template : pCHAR) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  keyword,D1
+    MOVE.L  arg_template,D2
+    MOVEA.L _DOSBase,A6
+    JSR -804(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION FindCliProc(num : ULONG) : pProcess;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  num,D1
+    MOVEA.L _DOSBase,A6
+    JSR -546(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION FindDosEntry(dlist : pDosList; name : pCHAR; flags : ULONG) : pDosList;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  dlist,D1
+    MOVE.L  name,D2
+    MOVE.L  flags,D3
+    MOVEA.L _DOSBase,A6
+    JSR -684(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION FindSegment(name : pCHAR; seg : pSegment; system : LONGINT) : pSegment;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  seg,D2
+    MOVE.L  system,D3
+    MOVEA.L _DOSBase,A6
+    JSR -780(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION FindVar(name : pCHAR; type_ : ULONG) : pLocalVar;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  type_,D2
+    MOVEA.L _DOSBase,A6
+    JSR -918(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION Format(filesystem : pCHAR; volumename : pCHAR; dostype : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  filesystem,D1
+    MOVE.L  volumename,D2
+    MOVE.L  dostype,D3
+    MOVEA.L _DOSBase,A6
+    JSR -714(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION FPutC(fh : LONGINT; ch : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVE.L  ch,D2
+    MOVEA.L _DOSBase,A6
+    JSR -312(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION FPuts(fh : LONGINT; str : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVE.L  str,D2
+    MOVEA.L _DOSBase,A6
+    JSR -342(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION FRead(fh : LONGINT; block : POINTER; blocklen : ULONG; number : ULONG) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVE.L  block,D2
+    MOVE.L  blocklen,D3
+    MOVE.L  number,D4
+    MOVEA.L _DOSBase,A6
+    JSR -324(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE FreeArgs(args : pRDArgs);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  args,D1
+    MOVEA.L _DOSBase,A6
+    JSR -858(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeDeviceProc(dp : pDevProc);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  dp,D1
+    MOVEA.L _DOSBase,A6
+    JSR -648(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeDosEntry(dlist : pDosList);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  dlist,D1
+    MOVEA.L _DOSBase,A6
+    JSR -702(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeDosObject(type_ : ULONG; ptr : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  type_,D1
+    MOVE.L  ptr,D2
+    MOVEA.L _DOSBase,A6
+    JSR -234(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION FWrite(fh : LONGINT; block : POINTER; blocklen : ULONG; number : ULONG) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVE.L  block,D2
+    MOVE.L  blocklen,D3
+    MOVE.L  number,D4
+    MOVEA.L _DOSBase,A6
+    JSR -330(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetArgStr : pCHAR;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _DOSBase,A6
+    JSR -534(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetConsoleTask : pMsgPort;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _DOSBase,A6
+    JSR -510(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetCurrentDirName(buf : pCHAR; len : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  buf,D1
+    MOVE.L  len,D2
+    MOVEA.L _DOSBase,A6
+    JSR -564(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetDeviceProc(name : pCHAR; dp : pDevProc) : pDevProc;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  dp,D2
+    MOVEA.L _DOSBase,A6
+    JSR -642(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetFileSysTask : pMsgPort;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _DOSBase,A6
+    JSR -522(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetProgramDir : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _DOSBase,A6
+    JSR -600(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetProgramName(buf : pCHAR; len : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  buf,D1
+    MOVE.L  len,D2
+    MOVEA.L _DOSBase,A6
+    JSR -576(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetPrompt(buf : pCHAR; len : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  buf,D1
+    MOVE.L  len,D2
+    MOVEA.L _DOSBase,A6
+    JSR -588(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetVar(name : pCHAR; buffer : pCHAR; size : LONGINT; flags : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  buffer,D2
+    MOVE.L  size,D3
+    MOVE.L  flags,D4
+    MOVEA.L _DOSBase,A6
+    JSR -906(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION Info(lock : LONGINT; parameterBlock : pInfoData) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  lock,D1
+    MOVE.L  parameterBlock,D2
+    MOVEA.L _DOSBase,A6
+    JSR -114(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION Inhibit(name : pCHAR; onoff : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  onoff,D2
+    MOVEA.L _DOSBase,A6
+    JSR -726(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION InternalLoadSeg(fh : LONGINT; table : LONGINT; VAR funcarray : LONGINT; VAR stack : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D0
+    MOVEA.L table,A0
+    MOVEA.L funcarray,A1
+    MOVEA.L stack,A2
+    MOVEA.L _DOSBase,A6
+    JSR -756(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION InternalUnLoadSeg(seglist : LONGINT; freefunc : tPROCEDURE) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  seglist,D1
+    MOVEA.L freefunc,A1
+    MOVEA.L _DOSBase,A6
+    JSR -762(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION IoErr : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _DOSBase,A6
+    JSR -132(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION IsFileSystem(name : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVEA.L _DOSBase,A6
+    JSR -708(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION IsInteractive(file_ : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  file_,D1
+    MOVEA.L _DOSBase,A6
+    JSR -216(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION LoadSeg(name : pCHAR) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVEA.L _DOSBase,A6
+    JSR -150(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION Lock(name : pCHAR; type_ : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  type_,D2
+    MOVEA.L _DOSBase,A6
+    JSR -084(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION LockDosList(flags : ULONG) : pDosList;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  flags,D1
+    MOVEA.L _DOSBase,A6
+    JSR -654(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION LockRecord(fh : LONGINT; offset : ULONG; length : ULONG; mode : ULONG; timeout : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVE.L  offset,D2
+    MOVE.L  length,D3
+    MOVE.L  mode,D4
+    MOVE.L  timeout,D5
+    MOVEA.L _DOSBase,A6
+    JSR -270(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION LockRecords(recArray : pRecordLock; timeout : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  recArray,D1
+    MOVE.L  timeout,D2
+    MOVEA.L _DOSBase,A6
+    JSR -276(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION MakeDosEntry(name : pCHAR; type_ : LONGINT) : pDosList;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  type_,D2
+    MOVEA.L _DOSBase,A6
+    JSR -696(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION MakeLink(name : pCHAR; dest : LONGINT; soft : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  dest,D2
+    MOVE.L  soft,D3
+    MOVEA.L _DOSBase,A6
+    JSR -444(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE MatchEnd(anchor : pAnchorPath);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  anchor,D1
+    MOVEA.L _DOSBase,A6
+    JSR -834(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION MatchFirst(pat : pCHAR; anchor : pAnchorPath) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  pat,D1
+    MOVE.L  anchor,D2
+    MOVEA.L _DOSBase,A6
+    JSR -822(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION MatchNext(anchor : pAnchorPath) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  anchor,D1
+    MOVEA.L _DOSBase,A6
+    JSR -828(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION MatchPattern(pat : pCHAR; str : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  pat,D1
+    MOVE.L  str,D2
+    MOVEA.L _DOSBase,A6
+    JSR -846(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION MatchPatternNoCase(pat : pCHAR; str : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  pat,D1
+    MOVE.L  str,D2
+    MOVEA.L _DOSBase,A6
+    JSR -972(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION MaxCli : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _DOSBase,A6
+    JSR -552(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION NameFromFH(fh : LONGINT; buffer : pCHAR; len : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVE.L  buffer,D2
+    MOVE.L  len,D3
+    MOVEA.L _DOSBase,A6
+    JSR -408(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION NameFromLock(lock : LONGINT; buffer : pCHAR; len : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  lock,D1
+    MOVE.L  buffer,D2
+    MOVE.L  len,D3
+    MOVEA.L _DOSBase,A6
+    JSR -402(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION NewLoadSeg(file_ : pCHAR; tags : pTagItem) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  file_,D1
+    MOVE.L  tags,D2
+    MOVEA.L _DOSBase,A6
+    JSR -768(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION NewLoadSegTagList(file_ : pCHAR; tags : pTagItem) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  file_,D1
+    MOVE.L  tags,D2
+    MOVEA.L _DOSBase,A6
+    JSR -768(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION NextDosEntry(dlist : pDosList; flags : ULONG) : pDosList;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  dlist,D1
+    MOVE.L  flags,D2
+    MOVEA.L _DOSBase,A6
+    JSR -690(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION OpenFromLock(lock : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  lock,D1
+    MOVEA.L _DOSBase,A6
+    JSR -378(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ParentDir(lock : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  lock,D1
+    MOVEA.L _DOSBase,A6
+    JSR -210(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ParentOfFH(fh : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVEA.L _DOSBase,A6
+    JSR -384(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ParsePattern(pat : pCHAR; buf : pCHAR; buflen : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  pat,D1
+    MOVE.L  buf,D2
+    MOVE.L  buflen,D3
+    MOVEA.L _DOSBase,A6
+    JSR -840(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ParsePatternNoCase(pat : pCHAR; buf : pCHAR; buflen : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  pat,D1
+    MOVE.L  buf,D2
+    MOVE.L  buflen,D3
+    MOVEA.L _DOSBase,A6
+    JSR -966(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION PathPart(path : pCHAR) : pCHAR;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  path,D1
+    MOVEA.L _DOSBase,A6
+    JSR -876(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION PrintFault(code : LONGINT; header : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  code,D1
+    MOVE.L  header,D2
+    MOVEA.L _DOSBase,A6
+    JSR -474(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION PutStr(str : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  str,D1
+    MOVEA.L _DOSBase,A6
+    JSR -948(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION ReadArgs(arg_template : pCHAR; VAR arra : LONGINT; args : pRDArgs) : pRDArgs;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  arg_template,D1
+    MOVE.L  arra,D2
+    MOVE.L  args,D3
+    MOVEA.L _DOSBase,A6
+    JSR -798(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ReadItem(name : pCHAR; maxchars : LONGINT; cSource : pCSource) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  maxchars,D2
+    MOVE.L  cSource,D3
+    MOVEA.L _DOSBase,A6
+    JSR -810(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ReadLink(port : pMsgPort; lock : LONGINT; path : pCHAR; buffer : pCHAR; size : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  port,D1
+    MOVE.L  lock,D2
+    MOVE.L  path,D3
+    MOVE.L  buffer,D4
+    MOVE.L  size,D5
+    MOVEA.L _DOSBase,A6
+    JSR -438(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION Relabel(drive : pCHAR; newname : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  drive,D1
+    MOVE.L  newname,D2
+    MOVEA.L _DOSBase,A6
+    JSR -720(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION RemAssignList(name : pCHAR; lock : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  lock,D2
+    MOVEA.L _DOSBase,A6
+    JSR -636(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION RemDosEntry(dlist : pDosList) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  dlist,D1
+    MOVEA.L _DOSBase,A6
+    JSR -672(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION RemSegment(seg : pSegment) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  seg,D1
+    MOVEA.L _DOSBase,A6
+    JSR -786(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ReplyPkt(dp : pDosPacket; res1 : LONGINT; res2 : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  dp,D1
+    MOVE.L  res1,D2
+    MOVE.L  res2,D3
+    MOVEA.L _DOSBase,A6
+    JSR -258(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION RunCommand(seg : LONGINT; stack : LONGINT; paramptr : pCHAR; paramlen : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  seg,D1
+    MOVE.L  stack,D2
+    MOVE.L  paramptr,D3
+    MOVE.L  paramlen,D4
+    MOVEA.L _DOSBase,A6
+    JSR -504(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SameDevice(lock1 : LONGINT; lock2 : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  lock1,D1
+    MOVE.L  lock2,D2
+    MOVEA.L _DOSBase,A6
+    JSR -984(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION SameLock(lock1 : LONGINT; lock2 : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  lock1,D1
+    MOVE.L  lock2,D2
+    MOVEA.L _DOSBase,A6
+    JSR -420(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SelectInput(fh : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVEA.L _DOSBase,A6
+    JSR -294(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SelectOutput(fh : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVEA.L _DOSBase,A6
+    JSR -300(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE SendPkt(dp : pDosPacket; port : pMsgPort; replyport : pMsgPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  dp,D1
+    MOVE.L  port,D2
+    MOVE.L  replyport,D3
+    MOVEA.L _DOSBase,A6
+    JSR -246(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION SetArgStr(string_ : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  string_,D1
+    MOVEA.L _DOSBase,A6
+    JSR -540(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetComment(name : pCHAR; comment : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  comment,D2
+    MOVEA.L _DOSBase,A6
+    JSR -180(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetConsoleTask(task : pMsgPort) : pMsgPort;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  task,D1
+    MOVEA.L _DOSBase,A6
+    JSR -516(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetCurrentDirName(name : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVEA.L _DOSBase,A6
+    JSR -558(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetFileDate(name : pCHAR; date : pDateStamp) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  date,D2
+    MOVEA.L _DOSBase,A6
+    JSR -396(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetFileSize(fh : LONGINT; pos : LONGINT; mode : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVE.L  pos,D2
+    MOVE.L  mode,D3
+    MOVEA.L _DOSBase,A6
+    JSR -456(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetFileSysTask(task : pMsgPort) : pMsgPort;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  task,D1
+    MOVEA.L _DOSBase,A6
+    JSR -528(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetIoErr(result : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  result,D1
+    MOVEA.L _DOSBase,A6
+    JSR -462(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetMode(fh : LONGINT; mode : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVE.L  mode,D2
+    MOVEA.L _DOSBase,A6
+    JSR -426(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetOwner(name : pCHAR; owner_info : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  owner_info,D2
+    MOVEA.L _DOSBase,A6
+    JSR -996(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetProgramDir(lock : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  lock,D1
+    MOVEA.L _DOSBase,A6
+    JSR -594(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetProgramName(name : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVEA.L _DOSBase,A6
+    JSR -570(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetPrompt(name : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVEA.L _DOSBase,A6
+    JSR -582(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetProtection(name : pCHAR; protect : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  protect,D2
+    MOVEA.L _DOSBase,A6
+    JSR -186(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetVar(name : pCHAR; buffer : pCHAR; size : LONGINT; flags : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  buffer,D2
+    MOVE.L  size,D3
+    MOVE.L  flags,D4
+    MOVEA.L _DOSBase,A6
+    JSR -900(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetVBuf(fh : LONGINT; buff : pCHAR; type_ : LONGINT; size : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVE.L  buff,D2
+    MOVE.L  type_,D3
+    MOVE.L  size,D4
+    MOVEA.L _DOSBase,A6
+    JSR -366(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION SplitName(name : pCHAR; seperator : ULONG; buf : pCHAR; oldpos : LONGINT; size : LONGINT) : INTEGER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D1
+    MOVE.L  seperator,D2
+    MOVE.L  buf,D3
+    MOVE.L  oldpos,D4
+    MOVE.L  size,D5
+    MOVEA.L _DOSBase,A6
+    JSR -414(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION StartNotify(notify : pNotifyRequest) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  notify,D1
+    MOVEA.L _DOSBase,A6
+    JSR -888(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION StrToDate(datetime : pDateTime) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  datetime,D1
+    MOVEA.L _DOSBase,A6
+    JSR -750(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION StrToLong(string_ : pCHAR; VAR value : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  string_,D1
+    MOVE.L  value,D2
+    MOVEA.L _DOSBase,A6
+    JSR -816(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SystemTagList(command : pCHAR; tags : pTagItem) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  command,D1
+    MOVE.L  tags,D2
+    MOVEA.L _DOSBase,A6
+    JSR -606(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DOSSystem(command : pCHAR; tags : pTagItem) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  command,D1
+    MOVE.L  tags,D2
+    MOVEA.L _DOSBase,A6
+    JSR -606(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION UnGetC(fh : LONGINT; character : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVE.L  character,D2
+    MOVEA.L _DOSBase,A6
+    JSR -318(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE UnLoadSeg(seglist : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  seglist,D1
+    MOVEA.L _DOSBase,A6
+    JSR -156(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE UnLock(lock : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  lock,D1
+    MOVEA.L _DOSBase,A6
+    JSR -090(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE UnLockDosList(flags : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  flags,D1
+    MOVEA.L _DOSBase,A6
+    JSR -660(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION UnLockRecord(fh : LONGINT; offset : ULONG; length : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVE.L  offset,D2
+    MOVE.L  length,D3
+    MOVEA.L _DOSBase,A6
+    JSR -282(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION UnLockRecords(recArray : pRecordLock) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  recArray,D1
+    MOVEA.L _DOSBase,A6
+    JSR -288(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION VFPrintf(fh : LONGINT; format : pCHAR; argarray : POINTER) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVE.L  format,D2
+    MOVE.L  argarray,D3
+    MOVEA.L _DOSBase,A6
+    JSR -354(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE VFWritef(fh : LONGINT; format : pCHAR; VAR argarray : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  fh,D1
+    MOVE.L  format,D2
+    MOVE.L  argarray,D3
+    MOVEA.L _DOSBase,A6
+    JSR -348(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION VPrintf(format : pCHAR; argarray : POINTER) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  format,D1
+    MOVE.L  argarray,D2
+    MOVEA.L _DOSBase,A6
+    JSR -954(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION WaitForChar(file_ : LONGINT; timeout : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  file_,D1
+    MOVE.L  timeout,D2
+    MOVEA.L _DOSBase,A6
+    JSR -204(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION WaitPkt : pDosPacket;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _DOSBase,A6
+    JSR -252(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION WriteChars(buf : pCHAR; buflen : ULONG) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  buf,D1
+    MOVE.L  buflen,D2
+    MOVEA.L _DOSBase,A6
+    JSR -942(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT DOS *)
+

+ 466 - 0
packages/extra/amunits/units/amigaguide.pas

@@ -0,0 +1,466 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+unit amigaguide;
+
+INTERFACE
+
+uses exec,amigados, intuition, utility;
+
+const
+ APSH_TOOL_ID           = 11000;
+ StartupMsgID           = (APSH_TOOL_ID+1) ;      { Startup message }
+ LoginToolID            = (APSH_TOOL_ID+2) ;      { Login a tool SIPC port }
+ LogoutToolID           = (APSH_TOOL_ID+3) ;      { Logout a tool SIPC port }
+ ShutdownMsgID          = (APSH_TOOL_ID+4) ;      { Shutdown message }
+ ActivateToolID         = (APSH_TOOL_ID+5) ;      { Activate tool }
+ DeactivateToolID       = (APSH_TOOL_ID+6) ;      { Deactivate tool }
+ ActiveToolID           = (APSH_TOOL_ID+7) ;      { Tool Active }
+ InactiveToolID         = (APSH_TOOL_ID+8) ;      { Tool Inactive }
+ ToolStatusID           = (APSH_TOOL_ID+9) ;      { Status message }
+ ToolCmdID              = (APSH_TOOL_ID+10);      { Tool command message }
+ ToolCmdReplyID         = (APSH_TOOL_ID+11);      { Reply to tool command }
+ ShutdownToolID         = (APSH_TOOL_ID+12);      { Shutdown tool }
+
+{ Attributes accepted by GetAmigaGuideAttr() }
+ AGA_Dummy              = (TAG_USER)   ;
+ AGA_Path               = (AGA_Dummy+1);
+ AGA_XRefList           = (AGA_Dummy+2);
+ AGA_Activate           = (AGA_Dummy+3);
+ AGA_Context            = (AGA_Dummy+4);
+
+ AGA_HelpGroup          = (AGA_Dummy+5);
+    { (ULONG) Unique identifier }
+
+ AGA_Reserved1          = (AGA_Dummy+6);
+ AGA_Reserved2          = (AGA_Dummy+7);
+ AGA_Reserved3          = (AGA_Dummy+8);
+
+ AGA_ARexxPort          = (AGA_Dummy+9);
+    { (struct MsgPort *) Pointer to the ARexx message port (V40) }
+
+ AGA_ARexxPortName      = (AGA_Dummy+10);
+   { (STRPTR) Used to specify the ARexx port name (V40) (not copied) }
+
+Type
+    AMIGAGUIDECONTEXT = Pointer;
+
+ pAmigaGuideMsg = ^tAmigaGuideMsg;
+ tAmigaGuideMsg = record
+    agm_Msg     : tMessage;                     { Embedded Exec message structure }
+    agm_Type    : ULONG;                        { Type of message }
+    agm_Data    : Pointer;                      { Pointer to message data }
+    agm_DSize,                                  { Size of message data }
+    agm_DType,                                  { Type of message data }
+    agm_Pri_Ret,                                { Primary return value }
+    agm_Sec_Ret : ULONG;                        { Secondary return value }
+    agm_System1,
+    agm_System2 : Pointer;
+ end;
+
+{ Allocation description structure }
+  pNewAmigaGuide = ^tNewAmigaGuide;
+  tNewAmigaGuide = record
+    nag_Lock  : BPTR;                           { Lock on the document directory }
+    nag_Name  : STRPTR;                         { Name of document file }
+    nag_Screen : pScreen;                       { Screen to place windows within }
+    nag_PubScreen,                              { Public screen name to open on }
+    nag_HostPort,                               { Application's ARexx port name }
+    nag_ClientPort,                             { Name to assign to the clients ARexx port }
+    nag_BaseName  : STRPTR;                     { Base name of the application }
+    nag_Flags  : ULONG;                         { Flags }
+    nag_Context: Pointer;                       { NULL terminated context table }
+    nag_Node   : STRPTR;                        { Node to align on first (defaults to Main) }
+    nag_Line   : Longint;                       { Line to align on }
+    nag_Extens : pTagItem;                      { Tag array extension }
+    nag_Client : Pointer;                       { Private! MUST be NULL }
+  END;
+
+CONST
+{ public Client flags }
+    HTF_LOAD_INDEX = 0;                 { Force load the index at init time }
+    HTF_LOAD_ALL   = 2;                 { Force load the entire database at init }
+    HTF_CACHE_NODE = 3;                 { Cache each node as visited }
+    HTF_CACHE_DB   = 8;                 { Keep the buffers around UNTIL expunge }
+    HTF_UNIQUE     = 32768;             { Unique ARexx port name }
+    HTF_NOACTIVATE = 65536;             { Don't activate window }
+
+    HTFC_SYSGADS   = $80000000;
+
+{ Callback function ID's }
+    HTH_OPEN       = 0;
+    HTH_CLOSE      = 1;
+
+    HTERR_NOT_ENOUGH_MEMORY       =  100;
+    HTERR_CANT_OPEN_DATABASE      =  101;
+    HTERR_CANT_FIND_NODE          =  102;
+    HTERR_CANT_OPEN_NODE          =  103;
+    HTERR_CANT_OPEN_WINDOW        =  104;
+    HTERR_INVALID_COMMAND         =  105;
+    HTERR_CANT_COMPLETE           =  106;
+    HTERR_PORT_CLOSED             =  107;
+    HTERR_CANT_CREATE_PORT        =  108;
+    HTERR_KEYWORD_NOT_FOUND       =  113;
+
+Type
+{ Cross reference node }
+  pXRef = ^tXRef;
+  tXRef = record
+    xr_Node   : tNode;            { Embedded node }
+    xr_Pad    : WORD;             { Padding }
+    xr_DF     : Pointer;          { Document defined in }
+    xr_File,                      { Name of document file }
+    xr_Name   : STRPTR;           { Name of item }
+    xr_Line   : Longint;          { Line defined at }
+   END;
+
+CONST
+{ Types of cross reference nodes }
+    XR_GENERIC     = 0;
+    XR_FUNCTION    = 1;
+    XR_COMMAND     = 2;
+    XR_INCLUDE     = 3;
+    XR_MACRO       = 4;
+    XR_STRUCT      = 5;
+    XR_FIELD       = 6;
+    XR_TYPEDEF     = 7;
+    XR_DEFINE      = 8;
+
+Type
+{ Callback handle }
+   pAmigaGuideHost = ^tAmigaGuideHost;
+   tAmigaGuideHost = record
+    agh_Dispatcher  : tHook;         { Dispatcher }
+    agh_Reserved,                 { Must be 0 }
+    agh_Flags,
+    agh_UseCnt      : ULONG;                   { Number of open nodes }
+    agh_SystemData,                        { Reserved for system use }
+    agh_UserData    : Pointer;                  { Anything you want... }
+   END;
+
+CONST
+{ Methods }
+    HM_FindNode    = 1 ;
+    HM_OpenNode    = 2 ;
+    HM_CloseNode   = 3 ;
+    HM_Expunge     = 10;              { Expunge DataBase }
+
+Type
+{ HM_FindNode }
+   popFindHost = ^topFindHost;
+   topFindHost = record
+    MethodID  : ULONG;
+    ofh_Attrs : pTagItem;           {  R: Additional attributes }
+    ofh_Node,                    {  R: Name of node }
+    ofh_TOC,                     {  W: Table of Contents }
+    ofh_Title,                   {  W: Title to give to the node }
+    ofh_Next,                    {  W: Next node to browse to }
+    ofh_Prev  : STRPTR;          {  W: Previous node to browse to }
+   END;
+
+{ HM_OpenNode, HM_CloseNode }
+   popNodeIO = ^topNodeIO;
+   topNodeIO = record
+    MethodID  : ULONG;
+    onm_Attrs : pTagItem;          {  R: Additional attributes }
+    onm_Node,                    {  R: Node name AND arguments }
+    onm_FileName,                {  W: File name buffer }
+    onm_DocBuffer : STRPTR;               {  W: Node buffer }
+    onm_BuffLen : ULONG;                  {  W: Size of buffer }
+    onm_Flags : ULONG;                    { RW: Control flags }
+   END;
+
+CONST
+{ onm_Flags }
+    HTNF_KEEP      = 0; { Don't flush this node UNTIL database is
+                                 * closed. }
+    HTNF_Reserved1 = 2 ; { Reserved for system use }
+    HTNF_Reserved2 = 4 ; { Reserved for system use }
+    HTNF_ASCII     = 8 ; { Node is straight ASCII }
+    HTNF_Reserved3 = 16; { Reserved for system use }
+    HTNF_CLEAN     = 32; { Remove the node from the database }
+    HTNF_DONE      = 64; { Done with node }
+
+{ onm_Attrs }
+    HTNA_Dummy     = TAG_USER;
+    HTNA_Screen    = (TAG_USER + 1);  { Screen that window resides in }
+    HTNA_Pens      = (TAG_USER + 2);  { Pen array (from DrawInfo) }
+    HTNA_Rectangle = (TAG_USER + 3);  { Window box }
+
+    HTNA_HelpGroup = (HTNA_Dummy+5);  { (ULONG) unique identifier }
+
+
+Type
+{ HM_Expunge }
+  popExpungeNode = ^topExpungeNode;
+  topExpungeNode = record
+    MethodID  : ULONG;
+    oen_Attrs : pTagItem;          {  R: Additional attributes }
+  END;
+
+VAR AmigaGuideBase : pLibrary;
+
+FUNCTION AddAmigaGuideHostA(h : pHook; name : pCHAR; attrs : pTagItem) : POINTER;
+FUNCTION AmigaGuideSignal(cl : POINTER) : ULONG;
+PROCEDURE CloseAmigaGuide(cl : POINTER);
+PROCEDURE ExpungeXRef;
+FUNCTION GetAmigaGuideAttr(tag : ULONG; cl : POINTER; storage : POINTER) : LONGINT;
+FUNCTION GetAmigaGuideMsg(cl : POINTER) : pAmigaGuideMsg;
+FUNCTION GetAmigaGuideString(id : LONGINT) : pCHAR;
+FUNCTION LoadXRef(lock : LONGINT; name : pCHAR) : LONGINT;
+FUNCTION LockAmigaGuideBase(handle : POINTER) : LONGINT;
+FUNCTION OpenAmigaGuideA(nag : pNewAmigaGuide; taglist : pTagItem) : POINTER;
+FUNCTION OpenAmigaGuideAsyncA(nag : pNewAmigaGuide; attrs : pTagItem) : POINTER;
+FUNCTION RemoveAmigaGuideHostA(hh : POINTER; attrs : pTagItem) : LONGINT;
+PROCEDURE ReplyAmigaGuideMsg(amsg : pAmigaGuideMsg);
+FUNCTION SendAmigaGuideCmdA(cl : POINTER; cmd : pCHAR; attrs : pTagItem) : LONGINT;
+FUNCTION SendAmigaGuideContextA(cl : POINTER; attrs : pTagItem) : LONGINT;
+FUNCTION SetAmigaGuideAttrsA(cl : POINTER; attrs : pTagItem) : LONGINT;
+FUNCTION SetAmigaGuideContextA(cl : POINTER; id : ULONG; attrs : pTagItem) : LONGINT;
+PROCEDURE UnlockAmigaGuideBase(key : LONGINT);
+
+IMPLEMENTATION
+
+FUNCTION AddAmigaGuideHostA(h : pHook; name : pCHAR; attrs : pTagItem) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L h,A0
+    MOVE.L  name,D0
+    MOVEA.L attrs,A1
+    MOVEA.L AmigaGuideBase,A6
+    JSR -138(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AmigaGuideSignal(cl : POINTER) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cl,A0
+    MOVEA.L AmigaGuideBase,A6
+    JSR -072(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE CloseAmigaGuide(cl : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cl,A0
+    MOVEA.L AmigaGuideBase,A6
+    JSR -066(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ExpungeXRef;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L AmigaGuideBase,A6
+    JSR -132(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION GetAmigaGuideAttr(tag : ULONG; cl : POINTER; storage : POINTER) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  tag,D0
+    MOVEA.L cl,A0
+    MOVEA.L storage,A1
+    MOVEA.L AmigaGuideBase,A6
+    JSR -114(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetAmigaGuideMsg(cl : POINTER) : pAmigaGuideMsg;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cl,A0
+    MOVEA.L AmigaGuideBase,A6
+    JSR -078(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetAmigaGuideString(id : LONGINT) : pCHAR;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  id,D0
+    MOVEA.L AmigaGuideBase,A6
+    JSR -210(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION LoadXRef(lock : LONGINT; name : pCHAR) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L lock,A0
+    MOVEA.L name,A1
+    MOVEA.L AmigaGuideBase,A6
+    JSR -126(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION LockAmigaGuideBase(handle : POINTER) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L handle,A0
+    MOVEA.L AmigaGuideBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION OpenAmigaGuideA(nag : pNewAmigaGuide; taglist : pTagItem) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L nag,A0
+    MOVEA.L taglist,A1
+    MOVEA.L AmigaGuideBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION OpenAmigaGuideAsyncA(nag : pNewAmigaGuide; attrs : pTagItem) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L nag,A0
+    MOVE.L  attrs,D0
+    MOVEA.L AmigaGuideBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION RemoveAmigaGuideHostA(hh : POINTER; attrs : pTagItem) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L hh,A0
+    MOVEA.L attrs,A1
+    MOVEA.L AmigaGuideBase,A6
+    JSR -144(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ReplyAmigaGuideMsg(amsg : pAmigaGuideMsg);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L amsg,A0
+    MOVEA.L AmigaGuideBase,A6
+    JSR -084(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION SendAmigaGuideCmdA(cl : POINTER; cmd : pCHAR; attrs : pTagItem) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cl,A0
+    MOVE.L  cmd,D0
+    MOVE.L  attrs,D1
+    MOVEA.L AmigaGuideBase,A6
+    JSR -102(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SendAmigaGuideContextA(cl : POINTER; attrs : pTagItem) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cl,A0
+    MOVE.L  attrs,D0
+    MOVEA.L AmigaGuideBase,A6
+    JSR -096(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetAmigaGuideAttrsA(cl : POINTER; attrs : pTagItem) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cl,A0
+    MOVEA.L attrs,A1
+    MOVEA.L AmigaGuideBase,A6
+    JSR -108(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetAmigaGuideContextA(cl : POINTER; id : ULONG; attrs : pTagItem) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cl,A0
+    MOVE.L  id,D0
+    MOVE.L  attrs,D1
+    MOVEA.L AmigaGuideBase,A6
+    JSR -090(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE UnlockAmigaGuideBase(key : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  key,D0
+    MOVEA.L AmigaGuideBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+END. (* UNIT AMIGAGUIDE *)
+
+
+

+ 195 - 0
packages/extra/amunits/units/amigalib.pas

@@ -0,0 +1,195 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit amigalib;
+
+INTERFACE
+
+uses exec;
+
+{*  Exec support functions from amiga.lib  *}
+
+procedure BeginIO (ioRequest: pIORequest);
+function CreateExtIO (port: pMsgPort; size: Longint): pIORequest;
+procedure DeleteExtIO (ioReq: pIORequest);
+function CreateStdIO (port: pMsgPort): pIOStdReq;
+procedure DeleteStdIO (ioReq: pIOStdReq);
+function CreatePort (name: STRPTR; pri: integer): pMsgPort;
+procedure DeletePort (port: pMsgPort);
+function CreateTask (name: STRPTR; pri: longint; 
+                     initPC : Pointer;
+             stackSize : ULONG): pTask; 
+procedure DeleteTask (task: pTask);
+procedure NewList (list: pList);
+
+IMPLEMENTATION
+
+{*  Exec support functions from amiga.lib  *}
+
+procedure BeginIO (ioRequest: pIORequest);
+begin
+   asm
+      move.l  a6,-(a7)
+      move.l  ioRequest,a1    ; get IO Request
+      move.l  20(a1),a6      ; extract Device ptr
+      jsr     -30(a6)        ; call BEGINIO directly
+      move.l  (a7)+,a6
+   end;
+end;
+
+function CreateExtIO (port: pMsgPort; size: Longint): pIORequest;
+var
+   IOReq: pIORequest;
+begin
+    IOReq := NIL;
+    if port <> NIL then
+    begin
+        IOReq := AllocMem(size, MEMF_CLEAR or MEMF_PUBLIC);
+        if IOReq <> NIL then
+        begin
+            IOReq^.io_Message.mn_Node.ln_Type   := NT_REPLYMSG;
+            IOReq^.io_Message.mn_Length    := size;
+            IOReq^.io_Message.mn_ReplyPort := port;
+        end;
+    end;
+    CreateExtIO := IOReq;
+end;
+
+
+procedure DeleteExtIO (ioReq: pIORequest);
+begin
+    if ioReq <> NIL then
+    begin
+        ioReq^.io_Message.mn_Node.ln_Type := $FF;
+        ioReq^.io_Message.mn_ReplyPort    := pMsgPort(-1);
+        ioReq^.io_Device                  := pDevice(-1);
+        ExecFreeMem(ioReq, ioReq^.io_Message.mn_Length);
+    end
+end;
+
+
+function CreateStdIO (port: pMsgPort): pIOStdReq;
+begin
+    CreateStdIO := pIOStdReq(CreateExtIO(port, sizeof(tIOStdReq)))
+end;
+
+
+procedure DeleteStdIO (ioReq: pIOStdReq);
+begin
+    DeleteExtIO(pIORequest(ioReq))
+end;
+
+
+function CreatePort (name: STRPTR; pri: integer): pMsgPort;
+var
+   port   : pMsgPort;
+   sigbit : shortint;
+begin
+    port  := NIL;
+    sigbit := AllocSignal(-1);
+    if sigbit <> -1 then
+    begin
+        port := AllocMem(sizeof(tMsgPort), MEMF_CLEAR or MEMF_PUBLIC);
+        if port = NIL then
+            FreeSignal(sigbit)
+        else
+            begin
+                port^.mp_Node.ln_Name  := name;
+                port^.mp_Node.ln_Pri   := pri;
+                port^.mp_Node.ln_Type  := NT_MSGPORT;
+
+                port^.mp_Flags    := PA_SIGNAL;
+                port^.mp_SigBit   := sigbit;
+                port^.mp_SigTask  := FindTask(NIL);
+
+                if name <> NIL then
+                    AddPort(port)
+                else
+                    NewList(@port^.mp_MsgList);
+            end;
+    end;
+    CreatePort := port;
+end;
+
+
+procedure DeletePort (port: pMsgPort);
+begin
+    if port <> NIL then
+    begin
+        if port^.mp_Node.ln_Name <> NIL then
+            RemPort(port);
+
+        port^.mp_SigTask       := pTask(-1);
+        port^.mp_MsgList.lh_Head  := pNode(-1);
+        FreeSignal(port^.mp_SigBit);
+        ExecFreeMem(port, sizeof(tMsgPort));
+    end;
+end;
+
+
+function CreateTask (name: STRPTR; pri: longint;
+        initPC: pointer; stackSize: ULONG): pTask;
+var
+   memlist : pMemList;
+   task    : pTask;
+   totalsize : Longint;
+begin
+    task  := NIL;
+    stackSize   := (stackSize + 3) and not 3;
+    totalsize := sizeof(tMemList) + sizeof(tTask) + stackSize;
+
+    memlist := AllocMem(totalsize, MEMF_PUBLIC + MEMF_CLEAR);
+    if memlist <> NIL then begin
+       memlist^.ml_NumEntries := 1;
+       memlist^.ml_ME[0].me_Un.meu_Addr := Pointer(memlist + 1);
+       memlist^.ml_ME[0].me_Length := totalsize - sizeof(tMemList);
+
+       task := pTask(memlist + sizeof(tMemList) + stackSize);
+       task^.tc_Node.ln_Pri := pri;
+       task^.tc_Node.ln_Type := NT_TASK;
+       task^.tc_Node.ln_Name := name;
+       task^.tc_SPLower := Pointer(memlist + sizeof(tMemList));
+       task^.tc_SPUpper := Pointer(task^.tc_SPLower + stackSize);
+       task^.tc_SPReg := task^.tc_SPUpper;
+
+       NewList(@task^.tc_MemEntry);
+       AddTail(@task^.tc_MemEntry,@memlist^.ml_Node);
+
+       AddTask(task,initPC,NIL) 
+    end;
+    CreateTask := task;
+end;
+
+
+procedure DeleteTask (task: pTask);
+begin
+    RemTask(task)
+end;
+
+
+procedure NewList (list: pList);
+begin
+    with list^ do
+    begin
+        lh_Head     := pNode(@lh_Tail);
+        lh_Tail     := NIL;
+        lh_TailPred := pNode(@lh_Head)
+    end
+end;
+
+end.
+
+

+ 237 - 0
packages/extra/amunits/units/amigaprinter.pas

@@ -0,0 +1,237 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit amigaprinter;
+
+INTERFACE
+
+uses exec, graphics;
+
+
+Const
+
+    PRD_RAWWRITE        = CMD_NONSTD + 0;
+    PRD_PRTCOMMAND      = CMD_NONSTD + 1;
+    PRD_DUMPRPORT       = CMD_NONSTD + 2;
+    PRD_QUERY           = CMD_NONSTD + 3;
+
+{ printer command definitions }
+
+    aRIS        = 0;            { ESCc  reset                   ISO }
+    aRIN        = 1;            { ESC#1 initialize              +++ }
+    aIND        = 2;            { ESCD  lf                      ISO }
+    aNEL        = 3;            { ESCE  return,lf               ISO }
+    aRI         = 4;            { ESCM  reverse lf              ISO }
+
+    aSGR0       = 5;            { ESC[0m normal char set        ISO }
+    aSGR3       = 6;            { ESC[3m italics on             ISO }
+    aSGR23      = 7;            { ESC[23m italics off           ISO }
+    aSGR4       = 8;            { ESC[4m underline on           ISO }
+    aSGR24      = 9;            { ESC[24m underline off         ISO }
+    aSGR1       = 10;           { ESC[1m boldface on            ISO }
+    aSGR22      = 11;           { ESC[22m boldface off          ISO }
+    aSFC        = 12;           { SGR30-39 set foreground color ISO }
+    aSBC        = 13;           { SGR40-49 set background color ISO }
+
+    aSHORP0     = 14;           { ESC[0w normal pitch           DEC }
+    aSHORP2     = 15;           { ESC[2w elite on               DEC }
+    aSHORP1     = 16;           { ESC[1w elite off              DEC }
+    aSHORP4     = 17;           { ESC[4w condensed fine on      DEC }
+    aSHORP3     = 18;           { ESC[3w condensed off          DEC }
+    aSHORP6     = 19;           { ESC[6w enlarged on            DEC }
+    aSHORP5     = 20;           { ESC[5w enlarged off           DEC }
+
+    aDEN6       = 21;           { ESC[6"z shadow print on       DEC (sort of) }
+    aDEN5       = 22;           { ESC[5"z shadow print off      DEC }
+    aDEN4       = 23;           { ESC[4"z doublestrike on       DEC }
+    aDEN3       = 24;           { ESC[3"z doublestrike off      DEC }
+    aDEN2       = 25;           { ESC[2"z NLQ on                DEC }
+    aDEN1       = 26;           { ESC[1"z NLQ off               DEC }
+
+    aSUS2       = 27;           { ESC[2v superscript on         +++ }
+    aSUS1       = 28;           { ESC[1v superscript off        +++ }
+    aSUS4       = 29;           { ESC[4v subscript on           +++ }
+    aSUS3       = 30;           { ESC[3v subscript off          +++ }
+    aSUS0       = 31;           { ESC[0v normalize the line     +++ }
+    aPLU        = 32;           { ESCL  partial line up         ISO }
+    aPLD        = 33;           { ESCK  partial line down       ISO }
+
+    aFNT0       = 34;           { ESC(B US char set or Typeface  0 (default) }
+    aFNT1       = 35;           { ESC(R French char set or Typeface  1 }
+    aFNT2       = 36;           { ESC(K German char set or Typeface  2 }
+    aFNT3       = 37;           { ESC(A UK char set or Typeface  3 }
+    aFNT4       = 38;           { ESC(E Danish I char set or Typeface  4 }
+    aFNT5       = 39;           { ESC(H Sweden char set or Typeface  5 }
+    aFNT6       = 40;           { ESC(Y Italian char set or Typeface  6 }
+    aFNT7       = 41;           { ESC(Z Spanish char set or Typeface  7 }
+    aFNT8       = 42;           { ESC(J Japanese char set or Typeface  8 }
+    aFNT9       = 43;           { ESC(6 Norweign char set or Typeface  9 }
+    aFNT10      = 44;           { ESC(C Danish II char set or Typeface 10 }
+
+{
+        Suggested typefaces are:
+
+         0 - default typeface.
+         1 - Line Printer or equiv.
+         2 - Pica or equiv.
+         3 - Elite or equiv.
+         4 - Helvetica or equiv.
+         5 - Times Roman or equiv.
+         6 - Gothic or equiv.
+         7 - Script or equiv.
+         8 - Prestige or equiv.
+         9 - Caslon or equiv.
+        10 - Orator or equiv.
+}
+
+    aPROP2      = 45;           { ESC[2p  proportional on       +++ }
+    aPROP1      = 46;           { ESC[1p  proportional off      +++ }
+    aPROP0      = 47;           { ESC[0p  proportional clear    +++ }
+    aTSS        = 48;           { ESC[n E set proportional offset ISO }
+    aJFY5       = 49;           { ESC[5 F auto left justify     ISO }
+    aJFY7       = 50;           { ESC[7 F auto right justify    ISO }
+    aJFY6       = 51;           { ESC[6 F auto full justify     ISO }
+    aJFY0       = 52;           { ESC[0 F auto justify off      ISO }
+    aJFY3       = 53;           { ESC[3 F letter space (justify) ISO (special) }
+    aJFY1       = 54;           { ESC[1 F word fill(auto center) ISO (special) }
+
+    aVERP0      = 55;           { ESC[0z  1/8" line spacing     +++ }
+    aVERP1      = 56;           { ESC[1z  1/6" line spacing     +++ }
+    aSLPP       = 57;           { ESC[nt  set form length n     DEC }
+    aPERF       = 58;           { ESC[nq  perf skip n (n>0)     +++ }
+    aPERF0      = 59;           { ESC[0q  perf skip off         +++ }
+
+    aLMS        = 60;           { ESC#9   Left margin set       +++ }
+    aRMS        = 61;           { ESC#0   Right margin set      +++ }
+    aTMS        = 62;           { ESC#8   Top margin set        +++ }
+    aBMS        = 63;           { ESC#2   Bottom marg set       +++ }
+    aSTBM       = 64;           { ESC[Pn1;Pn2r  T&B margins     DEC }
+    aSLRM       = 65;           { ESC[Pn1;Pn2s  L&R margin      DEC }
+    aCAM        = 66;           { ESC#3   Clear margins         +++ }
+
+    aHTS        = 67;           { ESCH    Set horiz tab         ISO }
+    aVTS        = 68;           { ESCJ    Set vertical tabs     ISO }
+    aTBC0       = 69;           { ESC[0g  Clr horiz tab         ISO }
+    aTBC3       = 70;           { ESC[3g  Clear all h tab       ISO }
+    aTBC1       = 71;           { ESC[1g  Clr vertical tabs     ISO }
+    aTBC4       = 72;           { ESC[4g  Clr all v tabs        ISO }
+    aTBCALL     = 73;           { ESC#4   Clr all h & v tabs    +++ }
+    aTBSALL     = 74;           { ESC#5   Set default tabs      +++ }
+    aEXTEND     = 75;           { ESC[Pn"x extended commands    +++ }
+
+    aRAW        = 76;           { ESC[Pn"r Next 'Pn' chars are raw +++ }
+
+Type
+
+    pIOPrtCmdReq = ^tIOPrtCmdReq;
+    tIOPrtCmdReq = record
+        io_Message      : tMessage;
+        io_Device       : pDevice;      { (DevicePtr) device node pointer  }
+        io_Unit         : pUnit;        { (UnitPtr) unit (driver private)}
+        io_Command      : Word;         { device command }
+        io_Flags        : Byte;
+        io_Error        : Shortint;     { error or warning num }
+        io_PrtCommand   : Word;         { printer command }
+        io_Parm0        : Byte;         { first command parameter }
+        io_Parm1        : Byte;         { second command parameter }
+        io_Parm2        : Byte;         { third command parameter }
+        io_Parm3        : Byte;         { fourth command parameter }
+    end;
+
+
+    pIODRPReq = ^tIODRPReq;
+    tIODRPReq = record
+        io_Message      : tMessage;
+        io_Device       : pDevice;      { (DevicePtr) device node pointer  }
+        io_Unit         : pUnit;        { (UnitPtr) unit (driver private)}
+        io_Command      : Word;         { device command }
+        io_Flags        : Byte;
+        io_Error        : Shortint;     { error or warning num }
+        io_RastPort     : pRastPort;    { (RastPortPtr) raster port }
+        io_ColorMap     : pColorMap;    { (ColorMapPtr) color map }
+        io_Modes        : ULONG;        { graphics viewport modes }
+        io_SrcX         : Word;         { source x origin }
+        io_SrcY         : Word;         { source y origin }
+        io_SrcWidth     : Word;         { source x width }
+        io_SrcHeight    : Word;         { source x height }
+        io_DestCols     : Longint;      { destination x width }
+        io_DestRows     : Longint;      { destination y height }
+        io_Special      : Word;         { option flags }
+    end;
+
+Const
+
+    SPECIAL_MILCOLS     = $0001;        { DestCols specified in 1/1000" }
+    SPECIAL_MILROWS     = $0002;        { DestRows specified in 1/1000" }
+    SPECIAL_FULLCOLS    = $0004;        { make DestCols maximum possible }
+    SPECIAL_FULLROWS    = $0008;        { make DestRows maximum possible }
+    SPECIAL_FRACCOLS    = $0010;        { DestCols is fraction of FULLCOLS }
+    SPECIAL_FRACROWS    = $0020;        { DestRows is fraction of FULLROWS }
+    SPECIAL_CENTER      = $0040;        { center image on paper }
+    SPECIAL_ASPECT      = $0080;        { ensure correct aspect ratio }
+    SPECIAL_DENSITY1    = $0100;        { lowest resolution (dpi) }
+    SPECIAL_DENSITY2    = $0200;        { next res }
+    SPECIAL_DENSITY3    = $0300;        { next res }
+    SPECIAL_DENSITY4    = $0400;        { next res }
+    SPECIAL_DENSITY5    = $0500;        { next res }
+    SPECIAL_DENSITY6    = $0600;        { next res }
+    SPECIAL_DENSITY7    = $0700;        { highest res }
+    SPECIAL_NOFORMFEED  = $0800;        { don't eject paper on gfx prints }
+    SPECIAL_TRUSTME     = $1000;        { don't reset on gfx prints }
+
+{
+        Compute print size, set 'io_DestCols' and 'io_DestRows' in the calling
+        program's 'IODRPReq' structure and exit, DON'T PRINT.  This allows the
+        calling program to see what the final print size would be in printer
+        pixels.  Note that it modifies the 'io_DestCols' and 'io_DestRows'
+        fields of your 'IODRPReq' structure.  Also, set the print density and
+        update the 'MaxXDots', 'MaxYDots', 'XDotsInch', and 'YDotsInch' fields
+        of the 'PrinterExtendedData' structure.
+}
+
+    SPECIAL_NOPRINT     = $2000;        { see above }
+
+    PDERR_NOERR         = 0;            { clean exit, no errors }
+    PDERR_CANCEL        = 1;            { user cancelled print }
+    PDERR_NOTGRAPHICS   = 2;            { printer cannot output graphics }
+    PDERR_INVERTHAM     = 3;            { OBSOLETE }
+    PDERR_BADDIMENSION  = 4;            { print dimensions illegal }
+    PDERR_DIMENSIONOVFLOW       = 5;    { OBSOLETE }
+    PDERR_INTERNALMEMORY        = 6;    { no memory for internal variables }
+    PDERR_BUFFERMEMORY  = 7;            { no memory for print buffer }
+
+{
+        Note : this is an internal error that can be returned from the render
+        function to the printer device.  It is NEVER returned to the user.
+        If the printer device sees this error it converts it 'PDERR_NOERR'
+        and exits gracefully.  Refer to the document on
+        'How to Write a Graphics Printer Driver' for more info.
+}
+
+    PDERR_TOOKCONTROL   = 8;            { Took control in case 0 of render }
+
+{ internal use }
+
+    SPECIAL_DENSITYMASK = $0700;        { masks out density values }
+    SPECIAL_DIMENSIONSMASK = SPECIAL_MILCOLS + SPECIAL_MILROWS +
+                        SPECIAL_FULLCOLS + SPECIAL_FULLROWS + SPECIAL_FRACCOLS +
+                        SPECIAL_FRACROWS + SPECIAL_ASPECT;
+
+IMPLEMENTATION
+
+end.
+
+

+ 498 - 0
packages/extra/amunits/units/asl.pas

@@ -0,0 +1,498 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+UNIT asl;
+
+INTERFACE
+uses exec, utility, workbench, graphics;
+
+{************************************************************************}
+
+CONST
+  ASLNAME : PChar = 'asl.library';
+  ASL_TB          =     TAG_USER+$80000;
+
+{************************************************************************}
+
+{ Types of requesters known to ASL, used as arguments to AllocAslRequest() }
+  ASL_FileRequest       = 0;
+  ASL_FontRequest       = 1;
+  ASL_ScreenModeRequest = 2;
+
+
+{****************************************************************************
+ *
+ * ASL File Requester data structures and constants
+ *
+ * This structure must only be allocated by asl.library amd is READ-ONLY!
+ * Control of the various fields is provided via tags when the requester
+ * is created with AllocAslRequest() and when it is displayed via
+ * AslRequest()
+ }
+
+Type
+       pFileRequester = ^tFileRequester;
+       tFileRequester = record
+           rf_Reserved0   : Array[0..3] Of Byte;
+           rf_File        : STRPTR;        { Filename pointer             }
+           rf_Dir         : STRPTR;        { Directory name pointer       }
+           rf_Reserved1   : Array[0..9] Of Byte;
+           rf_LeftEdge    : Integer;
+           rf_TopEdge     : Integer;          { Preferred window pos }
+           rf_Width       : Integer;
+           rf_Height      : Integer;          { Preferred window size  }
+           rf_Reserved2   : Array[0..1] Of Byte;
+           rf_NumArgs     : LongInt;       { A-la WB Args, FOR multiselects }
+           rf_ArgList     : pWBArg
+           rf_UserData    : Pointer;       { Applihandle (you may write!!) }
+           rf_Reserved3   : Array[0..7] Of Byte;
+           rf_Pat         : STRPTR;        { Pattern match pointer }
+       END;                                { note - more reserved fields follow }
+
+
+{ File requester tag values, used by AllocAslRequest() and AslRequest() }
+
+const
+{ Window control }
+  ASLFR_Window         = ASL_TB+2 ;  { Parent window                    }
+  ASLFR_Screen         = ASL_TB+40;  { Screen to open on if no window   }
+  ASLFR_PubScreenName  = ASL_TB+41;  { Name of public screen            }
+  ASLFR_PrivateIDCMP   = ASL_TB+42;  { Allocate private IDCMP?          }
+  ASLFR_IntuiMsgFunc   = ASL_TB+70;  { Function to handle IntuiMessages }
+  ASLFR_SleepWindow    = ASL_TB+43;  { Block input in ASLFR_Window?     }
+  ASLFR_UserData       = ASL_TB+52;  { What to put in fr_UserData       }
+
+{ Text display }
+  ASLFR_TextAttr       = ASL_TB+51;  { Text font to use for gadget text }
+  ASLFR_Locale         = ASL_TB+50;  { Locale ASL should use for text   }
+  ASLFR_TitleText      = ASL_TB+1 ;  { Title of requester               }
+  ASLFR_PositiveText   = ASL_TB+18;  { Positive gadget text             }
+  ASLFR_NegativeText   = ASL_TB+19;  { Negative gadget text             }
+
+{ Initial settings }
+  ASLFR_InitialLeftEdge= ASL_TB+3 ;  { Initial requester coordinates    }
+  ASLFR_InitialTopEdge = ASL_TB+4 ;
+  ASLFR_InitialWidth   = ASL_TB+5 ;  { Initial requester dimensions     }
+  ASLFR_InitialHeight  = ASL_TB+6 ;
+  ASLFR_InitialFile    = ASL_TB+8 ;  { Initial contents of File gadget  }
+  ASLFR_InitialDrawer  = ASL_TB+9 ;  { Initial contents of Drawer gadg. }
+  ASLFR_InitialPattern = ASL_TB+10;  { Initial contents of Pattern gadg.}
+
+{ Options }
+  ASLFR_Flags1         = ASL_TB+20;  { Option flags                     }
+  ASLFR_Flags2         = ASL_TB+22;  { Additional option flags          }
+  ASLFR_DoSaveMode     = ASL_TB+44;  { Being used for saving?           }
+  ASLFR_DoMultiSelect  = ASL_TB+45;  { Do multi-select?                 }
+  ASLFR_DoPatterns     = ASL_TB+46;  { Display a Pattern gadget?        }
+
+{ Filtering }
+  ASLFR_DrawersOnly    = ASL_TB+47;  { Don't display files?             }
+  ASLFR_FilterFunc     = ASL_TB+49;  { Function to filter files         }
+  ASLFR_RejectIcons    = ASL_TB+60;  { Display .info files?             }
+  ASLFR_RejectPattern  = ASL_TB+61;  { Don't display files matching pat }
+  ASLFR_AcceptPattern  = ASL_TB+62;  { Accept only files matching pat   }
+  ASLFR_FilterDrawers  = ASL_TB+63;  { Also filter drawers with patterns}
+  ASLFR_HookFunc       = ASL_TB+7 ;  { Combined callback function       }
+
+{ Flag bits for the ASLFR_Flags1 tag }
+  FRB_FILTERFUNC     = 7;
+  FRB_INTUIFUNC      = 6;
+  FRB_DOSAVEMODE     = 5;
+  FRB_PRIVATEIDCMP   = 4;
+  FRB_DOMULTISELECT  = 3;
+  FRB_DOPATTERNS     = 0;
+
+  FRF_FILTERFUNC     = 128;
+  FRF_INTUIFUNC      = 64;
+  FRF_DOSAVEMODE     = 32;
+  FRF_PRIVATEIDCMP   = 16;
+  FRF_DOMULTISELECT  = 8;
+  FRF_DOPATTERNS     = 1;
+
+{ Flag bits for the ASLFR_Flags2 tag }
+  FRB_DRAWERSONLY    = 0;
+  FRB_FILTERDRAWERS  = 1;
+  FRB_REJECTICONS    = 2;
+
+  FRF_DRAWERSONLY    = 1;
+  FRF_FILTERDRAWERS  = 2;
+  FRF_REJECTICONS    = 4;
+
+
+{****************************************************************************
+ *
+ * ASL Font Requester data structures and constants
+ *
+ * This structure must only be allocated by asl.library amd is READ-ONLY!
+ * Control of the various fields is provided via tags when the requester
+ * is created with AllocAslRequest() and when it is displayed via
+ * AslRequest()
+ }
+
+Type
+    pFontRequester = ^tFontRequester;
+    tFontRequester = record
+       fo_Reserved0        : Array[0..7] Of Byte;
+       fo_Attr             : tTextAttr;            { Returned TextAttr                }
+       fo_FrontPen         : Byte;                 { Returned front pen               }
+       fo_BackPen          : Byte;                 { Returned back pen                }
+       fo_DrawMode         : Byte;                 { Returned drawing mode            }
+       fo_Reserved1        : Byte;
+       fo_UserData         : Pointer;              { You can store your own data here }
+       fo_LeftEdge         : Integer;                 { Coordinates Of requester on Exit }
+       fo_TopEdge          : Integer;
+       fo_Width            : Integer;
+       fo_Height           : Integer;
+       fo_TAttr            : tTTextAttr;           { Returned TTextAttr               }
+    end;
+
+
+{ Font requester tag values, used by AllocAslRequest() AND AslRequest() }
+
+const
+{ Window control }
+  ASLFO_Window         = ASL_TB+2 ;  { Parent window                    }
+  ASLFO_Screen         = ASL_TB+40;  { Screen to open on if no window   }
+  ASLFO_PubScreenName  = ASL_TB+41;  { Name of public screen            }
+  ASLFO_PrivateIDCMP   = ASL_TB+42;  { Allocate private IDCMP?          }
+  ASLFO_IntuiMsgFunc   = ASL_TB+70;  { Function to handle IntuiMessages }
+  ASLFO_SleepWindow    = ASL_TB+43;  { Block input in ASLFO_Window?     }
+  ASLFO_UserData       = ASL_TB+52;  { What to put in fo_UserData       }
+
+{ Text display }
+  ASLFO_TextAttr       = ASL_TB+51;  { Text font to use for gadget text }
+  ASLFO_Locale         = ASL_TB+50;  { Locale ASL should use for text   }
+  ASLFO_TitleText      = ASL_TB+1 ;  { Title of requester               }
+  ASLFO_PositiveText   = ASL_TB+18;  { Positive gadget text             }
+  ASLFO_NegativeText   = ASL_TB+19;  { Negative gadget text             }
+
+{ Initial settings }
+  ASLFO_InitialLeftEdge= ASL_TB+3 ;  { Initial requester coordinates    }
+  ASLFO_InitialTopEdge = ASL_TB+4 ;
+  ASLFO_InitialWidth   = ASL_TB+5 ;  { Initial requester dimensions     }
+  ASLFO_InitialHeight  = ASL_TB+6 ;
+  ASLFO_InitialName    = ASL_TB+10;  { Initial contents of Name gadget  }
+  ASLFO_InitialSize    = ASL_TB+11;  { Initial contents of Size gadget  }
+  ASLFO_InitialStyle   = ASL_TB+12;  { Initial font style               }
+  ASLFO_InitialFlags   = ASL_TB+13;  { Initial font flags for TextAttr  }
+  ASLFO_InitialFrontPen= ASL_TB+14;  { Initial front pen                }
+  ASLFO_InitialBackPen = ASL_TB+15;  { Initial back pen                 }
+  ASLFO_InitialDrawMode= ASL_TB+59;  { Initial draw mode                }
+
+{ Options }
+  ASLFO_Flags          = ASL_TB+20;  { Option flags                     }
+  ASLFO_DoFrontPen     = ASL_TB+44;  { Display Front color selector?    }
+  ASLFO_DoBackPen      = ASL_TB+45;  { Display Back color selector?     }
+  ASLFO_DoStyle        = ASL_TB+46;  { Display Style checkboxes?        }
+  ASLFO_DoDrawMode     = ASL_TB+47;  { Display DrawMode cycle gadget?   }
+
+{ Filtering }
+  ASLFO_FixedWidthOnly = ASL_TB+48;  { Only allow fixed-width fonts?    }
+  ASLFO_MinHeight      = ASL_TB+16;  { Minimum font height to display   }
+  ASLFO_MaxHeight      = ASL_TB+17;  { Maximum font height to display   }
+  ASLFO_FilterFunc     = ASL_TB+49;  { Function to filter fonts         }
+  ASLFO_HookFunc       = ASL_TB+7 ;  { Combined callback function       }
+  ASLFO_MaxFrontPen    = ASL_TB+66;  { Max # of colors in front palette }
+  ASLFO_MaxBackPen     = ASL_TB+67;  { Max # of colors in back palette  }
+
+{ Custom additions }
+  ASLFO_ModeList       = ASL_TB+21;  { Substitute list for drawmodes    }
+  ASLFO_FrontPens      = ASL_TB+64;  { Color table for front pen palette}
+  ASLFO_BackPens       = ASL_TB+65;  { Color table for back pen palette }
+
+{ Flag bits for ASLFO_Flags tag }
+  FOB_DOFRONTPEN    =  0;
+  FOB_DOBACKPEN     =  1;
+  FOB_DOSTYLE       =  2;
+  FOB_DODRAWMODE    =  3;
+  FOB_FIXEDWIDTHONLY=  4;
+  FOB_PRIVATEIDCMP  =  5;
+  FOB_INTUIFUNC     =  6;
+  FOB_FILTERFUNC    =  7;
+
+  FOF_DOFRONTPEN     = 1;
+  FOF_DOBACKPEN      = 2;
+  FOF_DOSTYLE        = 4;
+  FOF_DODRAWMODE     = 8;
+  FOF_FIXEDWIDTHONLY = 16;
+  FOF_PRIVATEIDCMP   = 32;
+  FOF_INTUIFUNC      = 64;
+  FOF_FILTERFUNC     = 128;
+
+{****************************************************************************
+ *
+ * ASL Screen Mode Requester data structures and constants
+ *
+ * This structure must only be allocated by asl.library and is READ-ONLY!
+ * Control of the various fields is provided via tags when the requester
+ * is created with AllocAslRequest() and when it is displayed via
+ * AslRequest()
+ }
+
+Type
+ pScreenModeRequester = ^tScreenModeRequester;
+ tScreenModeRequester = record
+    sm_DisplayID        : ULONG;    { Display mode ID                  }
+    sm_DisplayWidth     : ULONG;    { Width Of display IN pixels       }
+    sm_DisplayHeight    : ULONG;    { Height Of display IN pixels      }
+    sm_DisplayDepth     : word;     { Number OF bit-planes OF display  }
+    sm_OverscanType     : word;     { TYPE OF overscan OF display      }
+    sm_AutoScroll       : Boolean;  { Display should auto-scroll?      }
+
+    sm_BitMapWidth      : ULONG;    { Used TO create your own BitMap   }
+    sm_BitMapHeight     : ULONG;
+
+    sm_LeftEdge         : Integer;     { Coordinates OF requester on Exit }
+    sm_TopEdge          : Integer;
+    sm_Width            : Integer;
+    sm_Height           : Integer;
+
+    sm_InfoOpened       : Boolean;  { Info window opened on exit?      }
+    sm_InfoLeftEdge     : Integer;     { Last coordinates OF Info window  }
+    sm_InfoTopEdge      : Integer;
+    sm_InfoWidth        : Integer;
+    sm_InfoHeight       : Integer;
+
+    sm_UserData         : Pointer;     { You can store your own data here }
+ END;
+
+
+{ An Exec list of custom modes can be added to the list of available modes.
+ * The DimensionInfo structure must be completely initialized, including the
+ * Header. See <graphics/displayinfo.h>. Custom mode ID's must be in the range
+ * $FFFF0000..$FFFFFFFF. Regular properties which apply to your custom modes
+ * can be added in the dn_PropertyFlags field. Custom properties are not
+ * allowed.
+ }
+ pDisplayMode = ^tDisplayMode;
+ tDisplayMode = record
+    dm_Node     : tNode;                 { see ln_Name           }
+    dm_DimensionInfo : tDimensionInfo;   { mode description      }
+    dm_PropertyFlags : ULONG;           { applicable properties }
+ end;
+
+
+{ ScreenMode requester tag values, used by AllocAslRequest() and AslRequest() }
+const
+{ Window control }
+  ASLSM_Window        =  ASL_TB+2 ;  { Parent window                    }
+  ASLSM_Screen        =  ASL_TB+40;  { Screen to open on if no window   }
+  ASLSM_PubScreenName =  ASL_TB+41;  { Name of public screen            }
+  ASLSM_PrivateIDCMP  =  ASL_TB+42;  { Allocate private IDCMP?          }
+  ASLSM_IntuiMsgFunc  =  ASL_TB+70;  { Function to handle IntuiMessages }
+  ASLSM_SleepWindow   =  ASL_TB+43;  { Block input in ASLSM_Window?     }
+  ASLSM_UserData      =  ASL_TB+52;  { What to put in sm_UserData       }
+
+{ Text display }
+  ASLSM_TextAttr      =  ASL_TB+51;  { Text font to use for gadget text }
+  ASLSM_Locale        =  ASL_TB+50;  { Locale ASL should use for text   }
+  ASLSM_TitleText     =  ASL_TB+1 ;  { Title of requester               }
+  ASLSM_PositiveText  =  ASL_TB+18;  { Positive gadget text             }
+  ASLSM_NegativeText  =  ASL_TB+19;  { Negative gadget text             }
+
+{ Initial settings }
+  ASLSM_InitialLeftEdge      = ASL_TB+3  ; { Initial requester coordinates    }
+  ASLSM_InitialTopEdge       = ASL_TB+4  ;
+  ASLSM_InitialWidth         = ASL_TB+5  ; { Initial requester dimensions     }
+  ASLSM_InitialHeight        = ASL_TB+6  ;
+  ASLSM_InitialDisplayID     = ASL_TB+100; { Initial display mode id     }
+  ASLSM_InitialDisplayWidth  = ASL_TB+101; { Initial display width       }
+  ASLSM_InitialDisplayHeight = ASL_TB+102; { Initial display height      }
+  ASLSM_InitialDisplayDepth  = ASL_TB+103; { Initial display depth       }
+  ASLSM_InitialOverscanType  = ASL_TB+104; { Initial type of overscan    }
+  ASLSM_InitialAutoScroll    = ASL_TB+105; { Initial autoscroll setting  }
+  ASLSM_InitialInfoOpened    = ASL_TB+106; { Info wndw initially opened? }
+  ASLSM_InitialInfoLeftEdge  = ASL_TB+107; { Initial Info window coords. }
+  ASLSM_InitialInfoTopEdge   = ASL_TB+108;
+
+{ Options }
+  ASLSM_DoWidth         = ASL_TB+109;  { Display Width gadget?           }
+  ASLSM_DoHeight        = ASL_TB+110;  { Display Height gadget?          }
+  ASLSM_DoDepth         = ASL_TB+111;  { Display Depth gadget?           }
+  ASLSM_DoOverscanType  = ASL_TB+112;  { Display Overscan Type gadget?   }
+  ASLSM_DoAutoScroll    = ASL_TB+113;  { Display AutoScroll gadget?      }
+
+{ Filtering }
+  ASLSM_PropertyFlags   = ASL_TB+114;  { Must have these Property flags  }
+  ASLSM_PropertyMask    = ASL_TB+115;  { Only these should be looked at  }
+  ASLSM_MinWidth        = ASL_TB+116;  { Minimum display width to allow  }
+  ASLSM_MaxWidth        = ASL_TB+117;  { Maximum display width to allow  }
+  ASLSM_MinHeight       = ASL_TB+118;  { Minimum display height to allow }
+  ASLSM_MaxHeight       = ASL_TB+119;  { Maximum display height to allow }
+  ASLSM_MinDepth        = ASL_TB+120;  { Minimum display depth           }
+  ASLSM_MaxDepth        = ASL_TB+121;  { Maximum display depth           }
+  ASLSM_FilterFunc      = ASL_TB+122;  { Function to filter mode id's    }
+
+{ Custom additions }
+  ASLSM_CustomSMList    = ASL_TB+123;  { Exec list of struct DisplayMode }
+
+
+{****************************************************************************
+ *
+ * Obsolete ASL definitions, here for source code compatibility only.
+ * Please do NOT use in new code.
+ *
+ *   ASL_V38_NAMES_ONLY to remove these older names
+ }
+Const
+  ASL_Dummy       = (TAG_USER + $80000);
+  ASL_Hail        = ASL_Dummy+1 ;
+  ASL_Window      = ASL_Dummy+2 ;
+  ASL_LeftEdge    = ASL_Dummy+3 ;
+  ASL_TopEdge     = ASL_Dummy+4 ;
+  ASL_Width       = ASL_Dummy+5 ;
+  ASL_Height      = ASL_Dummy+6 ;
+  ASL_HookFunc    = ASL_Dummy+7 ;
+  ASL_File        = ASL_Dummy+8 ;
+  ASL_Dir         = ASL_Dummy+9 ;
+  ASL_FontName    = ASL_Dummy+10;
+  ASL_FontHeight  = ASL_Dummy+11;
+  ASL_FontStyles  = ASL_Dummy+12;
+  ASL_FontFlags   = ASL_Dummy+13;
+  ASL_FrontPen    = ASL_Dummy+14;
+  ASL_BackPen     = ASL_Dummy+15;
+  ASL_MinHeight   = ASL_Dummy+16;
+  ASL_MaxHeight   = ASL_Dummy+17;
+  ASL_OKText      = ASL_Dummy+18;
+  ASL_CancelText  = ASL_Dummy+19;
+  ASL_FuncFlags   = ASL_Dummy+20;
+  ASL_ModeList    = ASL_Dummy+21;
+  ASL_ExtFlags1   = ASL_Dummy+22;
+  ASL_Pattern     = ASL_FontName;
+{ remember what I said up there? Do not use these anymore! }
+  FILB_DOWILDFUNC  = 7;
+  FILB_DOMSGFUNC   = 6;
+  FILB_SAVE        = 5;
+  FILB_NEWIDCMP    = 4;
+  FILB_MULTISELECT = 3;
+  FILB_PATGAD      = 0;
+  FILF_DOWILDFUNC  = 128;
+  FILF_DOMSGFUNC   = 64;
+  FILF_SAVE        = 32;
+  FILF_NEWIDCMP    = 16;
+  FILF_MULTISELECT = 8;
+  FILF_PATGAD      = 1;
+  FIL1B_NOFILES    = 0;
+  FIL1B_MATCHDIRS  = 1;
+  FIL1F_NOFILES    = 1;
+  FIL1F_MATCHDIRS  = 2;
+  FONB_FRONTCOLOR  = 0;
+  FONB_BACKCOLOR   = 1;
+  FONB_STYLES      = 2;
+  FONB_DRAWMODE    = 3;
+  FONB_FIXEDWIDTH  = 4;
+  FONB_NEWIDCMP    = 5;
+  FONB_DOMSGFUNC   = 6;
+  FONB_DOWILDFUNC  = 7;
+  FONF_FRONTCOLOR  = 1;
+  FONF_BACKCOLOR   = 2;
+  FONF_STYLES      = 4;
+  FONF_DRAWMODE    = 8;
+  FONF_FIXEDWIDTH  = 16;
+  FONF_NEWIDCMP    = 32;
+  FONF_DOMSGFUNC   = 64;
+  FONF_DOWILDFUNC  = 128;
+
+
+VAR AslBase : pLibrary;
+
+FUNCTION AllocAslRequest(reqType : ULONG; tagList : pTagItem) : POINTER;
+FUNCTION AllocFileRequest : pFileRequester;
+FUNCTION AslRequest(requester : POINTER; tagList : pTagItem) : BOOLEAN;
+PROCEDURE FreeAslRequest(requester : POINTER);
+PROCEDURE FreeFileRequest(fileReq : pFileRequester);
+FUNCTION RequestFile(fileReq : pFileRequester) : BOOLEAN;
+
+IMPLEMENTATION
+
+FUNCTION AllocAslRequest(reqType : ULONG; tagList : pTagItem) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  reqType,D0
+    MOVEA.L tagList,A0
+    MOVEA.L AslBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AllocFileRequest : pFileRequester;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L AslBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AslRequest(requester : POINTER; tagList : pTagItem) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L requester,A0
+    MOVEA.L tagList,A1
+    MOVEA.L AslBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE FreeAslRequest(requester : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L requester,A0
+    MOVEA.L AslBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeFileRequest(fileReq : pFileRequester);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L fileReq,A0
+    MOVEA.L AslBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION RequestFile(fileReq : pFileRequester) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L fileReq,A0
+    MOVEA.L AslBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT ASL *)

+ 72 - 0
packages/extra/amunits/units/audio.pas

@@ -0,0 +1,72 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit audio;
+
+INTERFACE
+
+uses exec;
+
+const
+
+    AUDIONAME           : PChar = 'audio.device';
+
+    ADHARD_CHANNELS     = 4;
+
+    ADALLOC_MINPREC     = -128;
+    ADALLOC_MAXPREC     = 127;
+
+    ADCMD_FREE          = CMD_NONSTD + 0;
+    ADCMD_SETPREC       = CMD_NONSTD + 1;
+    ADCMD_FINISH        = CMD_NONSTD + 2;
+    ADCMD_PERVOL        = CMD_NONSTD + 3;
+    ADCMD_LOCK          = CMD_NONSTD + 4;
+    ADCMD_WAITCYCLE     = CMD_NONSTD + 5;
+    ADCMDB_NOUNIT       = 5;
+    ADCMDF_NOUNIT       = 32;
+    ADCMD_ALLOCATE      = ADCMDF_NOUNIT + 0;
+
+    ADIOB_PERVOL        = 4;
+    ADIOF_PERVOL        = 16;
+    ADIOB_SYNCCYCLE     = 5;
+    ADIOF_SYNCCYCLE     = 32;
+    ADIOB_NOWAIT        = 6;
+    ADIOF_NOWAIT        = 64;
+    ADIOB_WRITEMESSAGE  = 7;
+    ADIOF_WRITEMESSAGE  = 128;
+ 
+    ADIOERR_NOALLOCATION        = -10;
+    ADIOERR_ALLOCFAILED         = -11;
+    ADIOERR_CHANNELSTOLEN       = -12;
+
+type
+    pIOAudio = ^tIOAudio;
+    tIOAudio = record
+        ioa_Request     : tIORequest;
+        ioa_AllocKey    : Integer;
+        ioa_Data        : Pointer;
+        ioa_Length      : ULONG;
+        ioa_Period      : Word;
+        ioa_Volume      : Word;
+        ioa_Cycles      : Word;
+        ioa_WriteMsg    : tMessage;
+    end;
+
+IMPLEMENTATION
+
+end.
+
+

+ 42 - 0
packages/extra/amunits/units/bootblock.pas

@@ -0,0 +1,42 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit bootblock;
+
+INTERFACE
+
+type
+    pBootBlock = ^tBootBlock;
+    tBootBlock = record
+        bb_id           : Array [0..3] of Byte; { 4 character identifier }
+        bb_chksum       : Longint;              { boot block checksum (balance) }
+        bb_dosblock     : Longint;              { reserved for DOS patch }
+    end;
+
+const
+    BOOTSECTS   = 2;    { 1K bootstrap }
+
+    BBID_DOS    : PChar = 'DOS\0';
+    BBID_KICK   : PChar = 'KICK';
+
+    BBNAME_DOS  = $444F5300;    { DOS\0 as an Integer }
+    BBNAME_KICK = $4B49434B;    { KICK as an Integer }
+
+IMPLEMENTATION
+
+end.
+
+

+ 426 - 0
packages/extra/amunits/units/bullet.pas

@@ -0,0 +1,426 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit bullet;
+
+INTERFACE
+
+uses exec, utility;
+
+type
+
+{ A GlyphEngine must be acquired via OpenEngine and is read-only }
+
+ pGlyphEngine = ^tGlyphEngine;
+ tGlyphEngine = record
+    gle_Library  : pLibrary; { engine library }
+    gle_Name     : STRPTR;     { library basename: e.g. "bullet" }
+    { private library data follows... }
+ end;
+
+ FIXED = Longint;             { 32 bit signed w/ 16 bits of fraction }
+
+ pGlyphMap = ^tGlyphMap;
+ tGlyphMap = record
+    glm_BMModulo,               { # of bytes in row: always multiple of 4 }
+    glm_BMRows,                 { # of rows in bitmap }
+    glm_BlackLeft,              { # of blank pixel columns at left }
+    glm_BlackTop,               { # of blank rows at top }
+    glm_BlackWidth,             { span of contiguous non-blank columns }
+    glm_BlackHeight : WORD;     { span of contiguous non-blank rows }
+    glm_XOrigin,                { distance from upper left corner of bitmap }
+    glm_YOrigin     : FIXED;    {   to initial CP, in fractional pixels }
+    glm_X0,                     { approximation of XOrigin in whole pixels }
+    glm_Y0,                     { approximation of YOrigin in whole pixels }
+    glm_X1,                     { approximation of XOrigin + Width }
+    glm_Y1          : Integer;  { approximation of YOrigin + Width }
+    glm_Width       : FIXED;    { character advance, as fraction of em width }
+    glm_BitMap      : Pointer;  { actual glyph bitmap }
+ end;
+
+ pGlyphWidthEntry = ^tGlyphWidthEntry;
+ tGlyphWidthEntry = record
+    gwe_Node  : tMinNode;        { on list returned by OT_WidthList inquiry }
+    gwe_Code  : WORD;           { entry's character code value }
+    gwe_Width : FIXED;          { character advance, as fraction of em width }
+ end;
+
+const
+{ Level 0 entries never appear in the .otag tag list, but appear in font
+ * specifications }
+     OT_Level0     = TAG_USER;
+{ Level 1 entries are required to exist in the .otag tag list }
+     OT_Level1     = (TAG_USER OR $1000);
+{ Level 2 entries are optional typeface metric tags }
+     OT_Level2     = (TAG_USER OR $2000);
+{ Level 3 entries are required for some OT_Engines }
+     OT_Level3     = (TAG_USER OR $3000);
+{ Indirect entries are at (tag address + data offset) }
+     OT_Indirect   = $8000;
+
+
+{******************************************************************}
+{ font specification and inquiry tags }
+
+{ !  tags flagged with an exclaimation mark are valid for
+ *    specification.
+ *  ? tags flagged with a question mark are valid for inquiry
+ *
+ * fixed binary numbers are encoded as 16 bits of integer and
+ * 16 bits of fraction.  Negative values are indicated by twos
+ * complement of all 32 bits.
+ }
+
+{ !  OT_DeviceDPI specifies the target device dots per inch -- X DPI is
+ *    in the high word, Y DPI in the low word. }
+     OT_DeviceDPI  = (OT_Level0 OR $01);      { == TA_DeviceDPI }
+
+{ !  OT_DotSize specifies the target device dot size as a percent of
+ *    it's resolution-implied size -- X percent in high word, Y percent
+ *    in low word. }
+     OT_DotSize    = (OT_Level0 OR $02);
+
+{ !  OT_PointHeight specifies the requested point height of a typeface,
+ *    specifically, the height and nominal width of the em-square.
+ *    The point referred to here is 1/72".  It is encoded as a fixed
+ *    binary number. }
+     OT_PointHeight = (OT_Level0 OR $08);
+
+{ !  OT_SetFactor specifies the requested set width of a typeface.
+ *    It distorts the width of the em-square from that specified by
+ *    OT_PointHeight.  To compensate for a device with different
+ *    horizontal and vertical resolutions, OT_DeviceDPI should be used
+ *    instead.  For a normal aspect ratio, set to 1.0 (encoded as
+ *    $00010000).  This is the default value. }
+     OT_SetFactor   = (OT_Level0 OR $09);
+
+{ !  OT_Shear... specifies the Sine and Cosine of the vertical stroke
+ *    angle, as two fixed point binary fractions.  Both must be specified:
+ *    first the Sine and then the Cosine.  Setting the sine component
+ *    changes the Shear to an undefined value, setting the cosine
+ *    component completes the Shear change to the new composite value.
+ *    For no shear, set to 0.0, 1.0 (encoded as $00000000, $00010000).
+ *    This is the default value. }
+     OT_ShearSin   = (OT_Level0 OR $0a);
+     OT_ShearCos   = (OT_Level0 OR $0b);
+
+{ !  OT_Rotate... specifies the Sine and Cosine of the baselin rotation
+ *    angle, as two fixed point binary fractions.  Both must be specified:
+ *    first the Sine and then the Cosine.  Setting the sine component
+ *    changes the Shear to an undefined value, setting the cosine
+ *    component completes the Shear change to the new composite value.
+ *    For no shear, set to 0.0, 1.0 (encoded as $00000000, $00010000).
+ *    This is the default value. }
+     OT_RotateSin  = (OT_Level0 OR $0c);
+     OT_RotateCos  = (OT_Level0 OR $0d);
+
+{ !  OT_Embolden... specifies values to algorithimically embolden -- or,
+ *    when negative, lighten -- the glyph.  It is encoded as a fixed point
+ *    binary fraction of the em-square.  The X and Y components can be
+ *    changed indendently.  For normal characters, set to 0.0, 0.0
+ *    (encoded as $00000000, $00000000).  This is the default value. }
+     OT_EmboldenX  = (OT_Level0 OR $0e);
+     OT_EmboldenY  = (OT_Level0 OR $0f);
+
+{ !  OT_PointSize is an old method of specifying the point size,
+ *    encoded as (points * 16). }
+     OT_PointSize  = (OT_Level0 OR $10);
+
+{ !  OT_GlyphCode specifies the glyph (character) code to use with
+ *    subsequent operations.  For example, this is the code for an
+ *    OT_Glyph inquiry }
+     OT_GlyphCode  = (OT_Level0 OR $11);
+
+{ !  OT_GlyphCode2 specifies the second glyph code.  For example,
+ *    this is the right glyph of the two glyphs of an OT_KernPair
+ *    inquiry }
+     OT_GlyphCode2 = (OT_Level0 OR $12);
+
+{ !  OT_GlyphWidth specifies a specific width for a glyph.
+ *    It sets a specific escapement (advance) width for subsequent
+ *    glyphs.  It is encoded as a fixed binary fraction of the em-square.
+ *    To revert to using the font-defined escapement for each glyph, set
+ *    to 0.0 (encoded as $00000000).  This is the default value. }
+     OT_GlyphWidth = (OT_Level0 OR $13);
+
+{ !  OT_OTagPath and
+ * !  OT_OTagList specify the selected typeface.  Both must be specified:
+ *    first the Path and then the List.  Setting the path name changes
+ *    changes the typeface to an undefined value, providing the List
+ *    completes the typeface selection to the new typeface.  OTagPath
+ *    is the null terminated full file path of the .otag file associated
+ *    with the typeface.  OTagList is a memory copy of the processed
+ *    contents of that .otag file (i.e. with indirections resolved).
+ *    There are no default values for the typeface. }
+     OT_OTagPath   = (OT_Level0 OR OT_Indirect OR $14);
+     OT_OTagList   = (OT_Level0 OR OT_Indirect OR $15);
+
+{  ? OT_GlyphMap supplies a read-only struct GlyphMap pointer that
+ *    describes a bitmap for a glyph with the current attributes. }
+     OT_GlyphMap   = (OT_Level0 OR OT_Indirect OR $20);
+
+{  ? OT_WidthList supplies a read-only struct MinList of struct
+ *    GlyphWidthEntry nodes for glyphs that are defined from GlyphCode
+ *    to GlyphCode2, inclusive.  The widths are represented as fixed
+ *    binary fractions of the em-square, ignoring any effect of
+ *    SetFactor or GlyphWidth.  A width would need to be converted to
+ *    a distance along the baseline in device units by the
+ *    application. }
+     OT_WidthList  = (OT_Level0 OR OT_Indirect OR $21);
+
+{  ? OT_...KernPair supplies the kern adjustment to be added to the
+ *    current position after placement of the GlyphCode glyph and
+ *    before placement of the GlyphCode2 glyph.  Text kern pairs are
+ *    for rendering body text.  Display kern pairs are generally
+ *    tighter values for display (e.g. headline) purposes.  The
+ *    adjustment is represented as a fixed binary fraction of the
+ *    em-square, ignoring any effect of SetFactor.  This number would
+ *    need to be converted to a distance along the baseline in device
+ *    units by the application. }
+     OT_TextKernPair = (OT_Level0 OR OT_Indirect OR $22);
+     OT_DesignKernPair = (OT_Level0 OR OT_Indirect OR $23);
+
+{  ? OT_Underlined is an unsigned word which is used to request
+ *    algorithimic underlining for the engine when rendering the glyph.
+ *    Bullet.library currently does not support this tag, though it
+ *    may be used by other engines in the future.  The default for
+ *    any engine which supports this tag must be OTUL_None.  Engines which
+ *    do not support this tag should return an appropriate OTERR value.
+ *
+ *    As of V39, diskfont.library will request underlining if specified
+ *    in the TextAttr, or TTextAttr passed to OpenDiskFont().  Diskfont
+ *    will first request Broken underlining (like the Text() function
+ *    does when SetSoftStyle() is used), and then Solid underlining if
+ *    the engine returns an error.  If the engine returns an error for
+ *    both, then diskfont.library attempts to find, or create the best
+ *    non-underlined font that it can. }
+     OT_UnderLined        =  (OT_Level0 OR $24);
+
+     OTUL_None            =  0;
+     OTUL_Solid           =  1;
+     OTUL_Broken          =  2;
+     OTUL_DoubleSolid     =  3;
+     OUTL_DoubleBroken    =  4;
+
+{  ? OT_StrikeThrough is a boolean which is used to request
+ *    algorithimic strike through when rendering the glyph.
+ *    Bullet.library currently does not support this tag, though it
+ *    may be used by other engines in the future.  The default for
+ *    any engined which supports this tag must be FALSE.  Engines which
+ *    do not support this tag should return an appropriate OTERR value. }
+     OT_StrikeThrough     =  (OT_Level0 OR $25);
+
+
+{******************************************************************}
+{ .otag tags }
+
+{ suffix for files in FONTS: that contain these tags }
+     OTSUFFIX     : PChar =  '.otag';
+
+{ OT_FileIdent both identifies this file and verifies its size.
+ * It is required to be the first tag in the file. }
+     OT_FileIdent =  (OT_Level1 OR $01);
+
+{ OT_Engine specifies the font engine this file is designed to use }
+     OT_Engine    =  (OT_Level1 OR OT_Indirect OR $02);
+     OTE_Bullet   =  'bullet';
+
+{ OT_Family is the family name of this typeface }
+     OT_Family    =  (OT_Level1 OR OT_Indirect OR $03);
+
+{ The name of this typeface is implicit in the name of the .otag file }
+{ OT_BName is used to find the bold variant of this typeface }
+     OT_BName     =  (OT_Level2 OR OT_Indirect OR $05);
+{ OT_IName is used to find the italic variant of this typeface }
+     OT_IName     =  (OT_Level2 OR OT_Indirect OR $06);
+{ OT_BIName is used to find the bold italic variant of this typeface }
+     OT_BIName    =  (OT_Level2 OR OT_Indirect OR $07);
+
+{ OT_SymSet is used to select the symbol set that has the OT_YSizeFactor
+ * described here.  Other symbol sets might have different extremes }
+     OT_SymbolSet =  (OT_Level1 OR $10);
+
+{ OT_YSizeFactor is a ratio to assist in calculating the Point height
+ * to BlackHeight relationship -- high word: Point height term, low
+ * word: Black height term -- pointSize = ysize*<high>/<low> }
+     OT_YSizeFactor = (OT_Level1 OR $11);
+
+{ OT_SpaceWidth specifies the width of the space character relative
+ * to the character height }
+     OT_SpaceWidth = (OT_Level2 OR $12);
+
+{ OT_IsFixed is a boolean indicating that all the characters in the
+ * typeface are intended to have the same character advance }
+     OT_IsFixed    = (OT_Level2 OR $13);
+
+{ OT_SerifFlag is a boolean indicating if the character has serifs }
+     OT_SerifFlag  = (OT_Level1 OR $14);
+
+{ OT_StemWeight is an unsigned byte indicating the weight of the character }
+     OT_StemWeight = (OT_Level1 OR $15);
+
+     OTS_UltraThin  =   8;     {   0- 15 }
+     OTS_ExtraThin  =  24;     {  16- 31 }
+     OTS_Thin       =  40;     {  32- 47 }
+     OTS_ExtraLight =  56;     {  48- 63 }
+     OTS_Light      =  72;     {  64- 79 }
+     OTS_DemiLight  =  88;     {  80- 95 }
+     OTS_SemiLight  = 104;     {  96-111 }
+     OTS_Book       = 120;     { 112-127 }
+     OTS_Medium     = 136;     { 128-143 }
+     OTS_SemiBold   = 152;     { 144-159 }
+     OTS_DemiBold   = 168;     { 160-175 }
+     OTS_Bold       = 184;     { 176-191 }
+     OTS_ExtraBold  = 200;     { 192-207 }
+     OTS_Black      = 216;     { 208-223 }
+     OTS_ExtraBlack = 232;     { 224-239 }
+     OTS_UltraBlack = 248;     { 240-255 }
+
+{ OT_SlantStyle is an unsigned byte indicating the font posture }
+     OT_SlantStyle  = (OT_Level1 OR $16);
+     OTS_Upright    = 0;
+     OTS_Italic     = 1;       { Oblique, Slanted, etc. }
+     OTS_LeftItalic = 2;       { Reverse Slant }
+
+{ OT_HorizStyle is an unsigned byte indicating the appearance width }
+     OT_HorizStyle  = (OT_Level1 OR $17);
+     OTH_UltraCompressed  =   16;     {   0- 31 }
+     OTH_ExtraCompressed  =   48;     {  32- 63 }
+     OTH_Compressed       =   80;     {  64- 95 }
+     OTH_Condensed        =  112;     {  96-127 }
+     OTH_Normal           =  144;     { 128-159 }
+     OTH_SemiExpanded     =  176;     { 160-191 }
+     OTH_Expanded         =  208;     { 192-223 }
+     OTH_ExtraExpanded    =  240;     { 224-255 }
+
+{ OT_SpaceFactor specifies the width of the space character relative
+ * to the character height }
+     OT_SpaceFactor = (OT_Level2 OR $18);
+
+{ OT_InhibitAlgoStyle indicates which ta_Style bits, if any, should
+ * be ignored even if the font does not already have that quality.
+ * For example, if FSF_BOLD is set and the typeface is not bold but
+ * the user specifies bold, the application or diskfont library is
+ * not to use OT_Embolden to achieve a bold result. }
+     OT_InhibitAlgoStyle = (OT_Level2 OR $19);
+
+{ OT_AvailSizes is an indirect pointer to sorted UWORDs, 0th is count }
+     OT_AvailSizes  = (OT_Level1 OR OT_Indirect OR $20);
+     OT_MAXAVAILSIZES    =   20;      { no more than 20 sizes allowed }
+
+{ OT_SpecCount is the count number of parameters specified here }
+     OT_SpecCount   = (OT_Level1 OR $100);
+
+{ Specs can be created as appropriate for the engine by ORing in the
+ * parameter number (1 is first, 2 is second, ... up to 15th) }
+     OT_Spec        = (OT_Level1 OR $100);
+{ OT_Spec1 is the (first) parameter to the font engine to select
+ * this particular typeface }
+     OT_Spec1       = (OT_Level1 OR $101) ;
+
+
+const
+{ PRELIMINARY }
+    OTERR_Failure        =  -1;      { catch-all for error }
+    OTERR_Success        =  0 ;      { no error }
+    OTERR_BadTag         =  1 ;      { inappropriate tag for function }
+    OTERR_UnknownTag     =  2 ;      { unknown tag for function }
+    OTERR_BadData        =  3 ;      { catch-all for bad tag data }
+    OTERR_NoMemory       =  4 ;      { insufficient memory for operation }
+    OTERR_NoFace         =  5 ;      { no typeface currently specified }
+    OTERR_BadFace        =  6 ;      { typeface specification problem }
+    OTERR_NoGlyph        =  7 ;      { no glyph specified }
+    OTERR_BadGlyph       =  8 ;      { bad glyph code or glyph range }
+    OTERR_NoShear        =  9 ;      { shear only partially specified }
+    OTERR_NoRotate       =  10;      { rotate only partially specified }
+    OTERR_TooSmall       =  11;      { typeface metrics yield tiny glyphs }
+    OTERR_UnknownGlyph   =  12;      { glyph not known by engine }
+
+VAR BulletBase : pLibrary;
+
+PROCEDURE CloseEngine(glyphEngine : pGlyphEngine);
+FUNCTION ObtainInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
+FUNCTION OpenEngine : pGlyphEngine;
+FUNCTION ReleaseInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
+FUNCTION SetInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
+
+IMPLEMENTATION
+
+PROCEDURE CloseEngine(glyphEngine : pGlyphEngine);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L glyphEngine,A0
+    MOVEA.L BulletBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION ObtainInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L glyphEngine,A0
+    MOVEA.L tagList,A1
+    MOVEA.L BulletBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION OpenEngine : pGlyphEngine;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L BulletBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ReleaseInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L glyphEngine,A0
+    MOVEA.L tagList,A1
+    MOVEA.L BulletBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L glyphEngine,A0
+    MOVEA.L tagList,A1
+    MOVEA.L BulletBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT BULLET *)
+
+
+

+ 333 - 0
packages/extra/amunits/units/cd.pas

@@ -0,0 +1,333 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit cd;
+
+INTERFACE
+
+uses exec;
+  { Only V40+ }
+
+{*************************************************************************
+ *                                                                        *
+ *   CD Commands                                                          *
+ *                                                                        *
+ *************************************************************************}
+
+const
+   CD_RESET          =   1;
+   CD_READ           =   2;
+   CD_WRITE          =   3;
+   CD_UPDATE         =   4;
+   CD_CLEAR          =   5;
+   CD_STOP           =   6;
+   CD_START          =   7;
+   CD_FLUSH          =   8;
+   CD_MOTOR          =   9;
+   CD_SEEK           =  10;
+   CD_FORMAT         =  11;
+   CD_REMOVE         =  12;
+   CD_CHANGENUM      =  13;
+   CD_CHANGESTATE    =  14;
+   CD_PROTSTATUS     =  15;
+
+   CD_GETDRIVETYPE   =  18;
+   CD_GETNUMTRACKS   =  19;
+   CD_ADDCHANGEINT   =  20;
+   CD_REMCHANGEINT   =  21;
+   CD_GETGEOMETRY    =  22;
+   CD_EJECT          =  23;
+
+
+   CD_INFO           =  32;
+   CD_CONFIG         =  33;
+   CD_TOCMSF         =  34;
+   CD_TOCLSN         =  35;
+
+   CD_READXL         =  36;
+
+   CD_PLAYTRACK      =  37;
+   CD_PLAYMSF        =  38;
+   CD_PLAYLSN        =  39;
+   CD_PAUSE          =  40;
+   CD_SEARCH         =  41;
+
+   CD_QCODEMSF       =  42;
+   CD_QCODELSN       =  43;
+   CD_ATTENUATE      =  44;
+
+   CD_ADDFRAMEINT    =  45;
+   CD_REMFRAMEINT    =  46;
+
+
+{*************************************************************************
+ *                                                                        *
+ *   Device Driver Error Codes                                            *
+ *                                                                        *
+ *************************************************************************}
+
+   CDERR_OPENFAIL     =  (-1); { device/unit failed to open   }
+   CDERR_ABORTED      =  (-2); { request terminated early             }
+   CDERR_NOCMD        =  (-3); { command not supported by device      }
+   CDERR_BADLENGTH    =  (-4); { invalid length (IO_LENGTH/IO_OFFSET) }
+   CDERR_BADADDRESS   =  (-5); { invalid address (IO_DATA misaligned) }
+   CDERR_UNITBUSY     =  (-6); { device opens ok, but unit is busy    }
+   CDERR_SELFTEST     =  (-7); { hardware failed self-test            }
+
+   CDERR_NotSpecified   = 20;   { general catchall                     }
+   CDERR_NoSecHdr       = 21;   { couldn't even find a sector          }
+   CDERR_BadSecPreamble = 22;   { sector looked wrong                  }
+   CDERR_BadSecID       = 23;   { ditto                                }
+   CDERR_BadHdrSum      = 24;   { header had incorrect checksum        }
+   CDERR_BadSecSum      = 25;   { data had incorrect checksum          }
+   CDERR_TooFewSecs     = 26;   { couldn't find enough sectors         }
+   CDERR_BadSecHdr      = 27;   { another "sector looked wrong"        }
+   CDERR_WriteProt      = 28;   { can't write to a protected disk      }
+   CDERR_NoDisk         = 29;   { no disk in the drive                 }
+   CDERR_SeekError      = 30;   { couldn't find track 0                }
+   CDERR_NoMem          = 31;   { ran out of memory                    }
+   CDERR_BadUnitNum     = 32;   { asked for a unit > NUMUNITS          }
+   CDERR_BadDriveType   = 33;   { not a drive cd.device understands    }
+   CDERR_DriveInUse     = 34;   { someone else allocated the drive     }
+   CDERR_PostReset      = 35;   { user hit reset; awaiting doom        }
+   CDERR_BadDataType    = 36;   { data on disk is wrong type   }
+   CDERR_InvalidState   = 37;   { invalid cmd under current conditions }
+
+   CDERR_Phase          = 42;   { illegal or unexpected SCSI phase     }
+   CDERR_NoBoard        = 50;   { open failed for non-existant board   }
+
+
+
+{*************************************************************************
+ *                                                                        *
+ * Configuration                                                          *
+ *                                                                        *
+ *       The drive is configured by TagList items defined as follows:     *
+ *                                                                        *
+ *************************************************************************}
+
+   TAGCD_PLAYSPEED        = $0001;
+   TAGCD_READSPEED        = $0002;
+   TAGCD_READXLSPEED      = $0003;
+   TAGCD_SECTORSIZE       = $0004;
+   TAGCD_XLECC            = $0005;
+   TAGCD_EJECTRESET       = $0006;
+
+
+{*************************************************************************
+ *                                                                        *
+ * Information                                                            *
+ *                                                                        *
+ *      Information/Status structure describes current speed settings     *
+ *      for read and play commands, sector size, audio attenuation        *
+ *      precision, and drive status.                                      *
+ *                                                                        *
+ *************************************************************************}
+
+Type
+
+ pCDInfo = ^tCDInfo;
+ tCDInfo = record
+                                        {                                Default     }
+    PlaySpeed,                          { Audio play speed       (75)        }
+    ReadSpeed,                          { Data-rate of CD_READ command   (Max)       }
+    ReadXLSpeed,                        { Data-rate of CD_READXL command (75)        }
+    SectorSize,                         { Number of bytes per sector     (2048)      }
+    XLECC,                              { CDXL ECC enabled/disabled                  }
+    EjectReset : WORD;                  { Reset on eject enabled/disabled            }
+    Reserved1 : Array[0..3] of WORD;    { Reserved for future expansion              }
+    MaxSpeed,                           { Maximum speed drive can handle (75, 150)   }
+    AudioPrecision,                     { 0 = no attenuator, 1 = mute only,          }
+                                        { other = (# levels - 1)                     }
+    Status : WORD;                      { See flags below                            }
+    Reserved2 : Array[0..3] of WORD;    { Reserved for future expansion              }
+ end;
+
+
+const
+{ Flags for Status }
+
+   CDSTSB_CLOSED    = 0; { Drive door is closed                        }
+   CDSTSB_DISK      = 1; { A disk has been detected                    }
+   CDSTSB_SPIN      = 2; { Disk is spinning (motor is on)              }
+   CDSTSB_TOC       = 3; { Table of contents read.  Disk is valid.     }
+   CDSTSB_CDROM     = 4; { Track 1 contains CD-ROM data                }
+   CDSTSB_PLAYING   = 5; { Audio is playing                            }
+   CDSTSB_PAUSED    = 6; { Pause mode (pauses on play command)         }
+   CDSTSB_SEARCH    = 7; { Search mode (Fast Forward/Fast Reverse)     }
+   CDSTSB_DIRECTION = 8; { Search direction (0 = Forward, 1 = Reverse) }
+
+   CDSTSF_CLOSED    = $0001;
+   CDSTSF_DISK      = $0002;
+   CDSTSF_SPIN      = $0004;
+   CDSTSF_TOC       = $0008;
+   CDSTSF_CDROM     = $0010;
+   CDSTSF_PLAYING   = $0020;
+   CDSTSF_PAUSED    = $0040;
+   CDSTSF_SEARCH    = $0080;
+   CDSTSF_DIRECTION = $0100;
+
+
+{ Modes for CD_SEARCH }
+
+   CDMODE_NORMAL  = 0;         { Normal play at current play speed    }
+   CDMODE_FFWD    = 1;         { Fast forward play (skip-play forward)}
+   CDMODE_FREV    = 2;         { Fast reverse play (skip-play reverse)}
+
+
+{*************************************************************************
+ *                                                                        *
+ * Position Information                                           *
+ *                                                                        *
+ *      Position information can be described in two forms: MSF and LSN   *
+ *      form.  MSF (Minutes, Seconds, Frames) form is a time encoding.    *
+ *      LSN (Logical Sector Number) form is frame (sector) count.         *
+ *      The desired form is selected using the io_Flags field of the      *
+ *      IOStdReq structure.  The flags and the union are described        *
+ *      below.                                                            *
+ *                                                                        *
+ *************************************************************************}
+
+Type
+ pRMSF = ^tRMSF;
+ tRMSF = record
+    Reserved,       { Reserved (always zero) }
+    Minute,         { Minutes (0-72ish)      }
+    Second,         { Seconds (0-59)         }
+    Frame  : Byte;  { Frame   (0-74)         }
+ end;
+
+ pLSNMSF = ^tLSNMSF;
+ tLSNMSF = record
+    MSF     : tRMSF;         { Minute, Second, Frame  }
+    LSN     : ULONG;         { Logical Sector Number  }
+ end;
+
+
+{*************************************************************************
+ *                                                                        *
+ * CD Transfer Lists                                                      *
+ *                                                                        *
+ *      A CDXL node is a double link node; however only single linkage    *
+ *      is used by the device driver.  If you wish to construct a         *
+ *      transfer list manually, it is only neccessary to define the       *
+ *      mln_Succ pointer of the MinNode.  You may also use the Exec       *
+ *      list functions by defining a List or MinList structure and by     *
+ *      using the AddHead/AddTail functions to create the list.  This     *
+ *      will create a double-linked list.  Although a double-linked       *
+ *      list is not required by the device driver, you may wish use it    *
+ *      for your own purposes.  Don't forget to initialize the            *
+ *      the List/MinList before using it!                                 *
+ *                                                                        *
+ *************************************************************************}
+
+ pCDXL = ^tCDXL;
+ tCDXL = record
+    Node              : tMinNode;       { double linkage                  }
+    Buffer            : Pointer;       { data destination (word aligned) }
+    Length,                            { must be even # bytes            }
+    Actual            : Longint;       { bytes transferred               }
+    IntData           : Pointer;       { interrupt server data segment   }
+    IntCode           : Pointer;       { interrupt server code entry     }
+ end;
+
+
+{*************************************************************************
+ *                                                                        *
+ * CD Table of Contents                                           *
+ *                                                                        *
+ *      The CD_TOC command returns an array of CDTOC entries.             *
+ *      Entry zero contains summary information describing how many       *
+ *      tracks the disk has and the play-time of the disk.                *
+ *      Entries 1 through N (N = Number of tracks on disk) contain        *
+ *      information about the track.                                      *
+ *                                                                        *
+ *************************************************************************}
+
+ pTOCSummary = ^tTOCSummary;
+ tTOCSummary = record
+    FirstTrack,            { First track on disk (always 1)            }
+    LastTrack   : Byte;    { Last track on disk                        }
+    LeadOut     : tLSNMSF;  { Beginning of lead-out track (end of disk) }
+ end;
+
+
+ pTOCEntry = ^tTOCEntry;
+ tTOCEntry = record
+    CtlAdr,             { Q-Code info                  }
+    Track  : Byte;      { Track number                 }
+    Position  : tLSNMSF; { Start position of this track }
+ end;
+
+
+ pCDTOC = ^tCDTOC;
+ tCDTOC = record
+    Summary  : tTOCSummary;  { First entry (0) is summary information }
+    Entry    : tTOCEntry;    { Entries 1-N are track entries          }
+ end;
+
+
+
+{*************************************************************************
+ *                                                                        *
+ * Q-Code Packets                                                         *
+ *                                                                        *
+ *      Q-Code packets are only returned when audio is playing.   *
+ *      Currently, only position packets are returned (ADR_POSITION)      *
+ *      The other ADR_ types are almost never encoded on the disk         *
+ *      and are of little use anyway.  To avoid making the QCode          *
+ *      structure a union, these other ADR_ structures are not defined.   *
+ *                                                                        *
+ *************************************************************************}
+
+ pQCode = ^tQCode;
+ tQCode = record
+  CtlAdr,               { Data type / QCode type           }
+  Track,                { Track number             }
+  Index,                { Track subindex number            }
+  Zero : Byte;          { The "Zero" byte of Q-Code packet }
+  TrackPosition,        { Position from start of track     }
+  DiskPosition  : tLSNMSF;  { Position from start of disk      }
+ end;
+
+const
+   CTLADR_CTLMASK = $F0;   { Control field }
+
+   CTL_CTLMASK    = $D0;   { To be ANDed with CtlAdr before compared  }
+
+   CTL_2AUD       = $00;   { 2 audio channels without preemphasis     }
+   CTL_2AUDEMPH   = $10;   { 2 audio channels with preemphasis        }
+   CTL_4AUD       = $80;   { 4 audio channels without preemphasis     }
+   CTL_4AUDEMPH   = $90;   { 4 audio channels with preemphasis        }
+   CTL_DATA       = $40;   { CD-ROM Data                              }
+
+   CTL_COPYMASK   = $20;   { To be ANDed with CtlAdr before compared  }
+
+   CTL_COPY       = $20;   { When true, this audio/data can be copied }
+
+   CTLADR_ADRMASK = $0F;   { Address field                            }
+
+   ADR_POSITION   = $01;   { Q-Code is position information   }
+   ADR_UPC        = $02;   { Q-Code is UPC information (not used)     }
+   ADR_ISRC       = $03;   { Q-Code is ISRC (not used)                }
+   ADR_HYBRID     = $05;   { This disk is a hybrid disk               }
+
+IMPLEMENTATION
+
+end.
+
+
+

+ 80 - 0
packages/extra/amunits/units/clipboard.pas

@@ -0,0 +1,80 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit clipboard;
+
+INTERFACE
+
+uses exec;
+
+const
+    CBD_POST            = CMD_NONSTD + 0;
+    CBD_CURRENTREADID   = CMD_NONSTD + 1;
+    CBD_CURRENTWRITEID  = CMD_NONSTD + 2;
+    CBD_CHANGEHOOK      = CMD_NONSTD + 3;
+
+    CBERR_OBSOLETEID    = 1;
+
+type
+
+    pClipboardUnitPartial = ^tClipboardUnitPartial;
+    tClipboardUnitPartial = record
+        cu_Node         : tNode;         { list of units }
+        cu_UnitNum      : ULONG;      { unit number for this unit }
+    { the remaining unit data is private to the device }
+    end;
+
+
+    pIOClipReq = ^tIOClipReq;
+    tIOClipReq = record
+        io_Message      : tMessage;
+        io_Device       : pDevice;      { device node pointer   }
+        io_Unit         : pClipboardUnitPartial;      { unit (driver private) }
+        io_Command      : Word;        { device command        }
+        io_Flags        : Byte;         { including QUICK and SATISFY }
+        io_Error        : Shortint;     { error or warning num  }
+        io_Actual       : ULONG;        { number of bytes transferred }
+        io_Length       : ULONG;        { number of bytes requested }
+        io_Data         : STRPTR;       { either clip stream or post port }
+        io_Offset       : ULONG;        { offset in clip stream }
+        io_ClipID       : Longint;      { ordinal clip identifier }
+    end;
+
+const
+    PRIMARY_CLIP        = 0;    { primary clip unit }
+
+type
+
+    pSatisfyMsg = ^tSatisfyMsg;
+    tSatisfyMsg = record
+        sm_Msg  : tMessage;      { the length will be 6 }
+        sm_Unit : Word;          { which clip unit this is }
+        sm_ClipID : Longint;     { the clip identifier of the post }
+    end;
+
+   pClipHookMsg = ^tClipHookMsg;
+   tClipHookMsg = record
+    chm_Type   : ULONG;          { zero for this structure format }
+    chm_ChangeCmd,               { command that caused this hook invocation: }
+                                 { either CMD_UPDATE OR CBD_POST }
+    chm_ClipID : Longint;        { the clip identifier of the new data }
+   END;
+
+IMPLEMENTATION
+
+end.
+
+

+ 99 - 0
packages/extra/amunits/units/colorwheel.pas

@@ -0,0 +1,99 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+UNIT colorwhell;
+
+INTERFACE
+USES exec, utility;
+
+Type
+{ For use with the WHEEL_HSB tag }
+ pColorWheelHSB = ^tColorWheelHSB;
+ tColorWheelHSB = record
+    cw_Hue,
+    cw_Saturation,
+    cw_Brightness  : ULONG;
+ end;
+
+{ For use with the WHEEL_RGB tag }
+ pColorWheelRGB = ^tColorWheelRGB;
+ tColorWheelRGB = record
+    cw_Red,
+    cw_Green,
+    cw_Blue  : ULONG;
+ end;
+
+
+{***************************************************************************}
+
+const
+    WHEEL_Dummy          = (TAG_USER+$04000000);
+    WHEEL_Hue            = (WHEEL_Dummy+1) ;  { set/get Hue              }
+    WHEEL_Saturation     = (WHEEL_Dummy+2) ;  { set/get Saturation        }
+    WHEEL_Brightness     = (WHEEL_Dummy+3) ;  { set/get Brightness        }
+    WHEEL_HSB            = (WHEEL_Dummy+4) ;  { set/get ColorWheelHSB     }
+    WHEEL_Red            = (WHEEL_Dummy+5) ;  { set/get Red               }
+    WHEEL_Green          = (WHEEL_Dummy+6) ;  { set/get Green     }
+    WHEEL_Blue           = (WHEEL_Dummy+7) ;  { set/get Blue              }
+    WHEEL_RGB            = (WHEEL_Dummy+8) ;  { set/get ColorWheelRGB     }
+    WHEEL_Screen         = (WHEEL_Dummy+9) ;  { init screen/enviroment    }
+    WHEEL_Abbrv          = (WHEEL_Dummy+10);  { "GCBMRY" if English       }
+    WHEEL_Donation       = (WHEEL_Dummy+11);  { colors donated by app     }
+    WHEEL_BevelBox       = (WHEEL_Dummy+12);  { inside a bevel box        }
+    WHEEL_GradientSlider = (WHEEL_Dummy+13);  { attached gradient slider  }
+    WHEEL_MaxPens        = (WHEEL_Dummy+14);  { max # of pens to allocate }
+
+
+{***************************************************************************}
+
+{--- functions in V39 or higher (Release 3) ---}
+
+VAR ColorWheelBase : pLibrary;
+
+PROCEDURE ConvertHSBToRGB(hsb : pColorWheelHSB; rgb : pColorWheelRGB);
+PROCEDURE ConvertRGBToHSB(rgb : pColorWheelRGB; hsb : pColorWheelHSB);
+
+IMPLEMENTATION
+
+PROCEDURE ConvertHSBToRGB(hsb : pColorWheelHSB; rgb : pColorWheelRGB);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L hsb,A0
+    MOVEA.L rgb,A1
+    MOVEA.L ColorWheelBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ConvertRGBToHSB(rgb : pColorWheelRGB; hsb : pColorWheelHSB);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rgb,A0
+    MOVEA.L hsb,A1
+    MOVEA.L ColorWheelBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+END. (* UNIT COLORWHEEL *)
+
+
+

+ 565 - 0
packages/extra/amunits/units/commodities.pas

@@ -0,0 +1,565 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit commodities;
+
+INTERFACE
+
+uses exec, inputevent, keymap;
+
+
+{    **************
+ * Broker stuff
+ **************}
+
+CONST
+{     buffer sizes   }
+      CBD_NAMELEN   =  24;
+      CBD_TITLELEN  =  40;
+      CBD_DESCRLEN  =  40;
+
+{     CxBroker errors   }
+      CBERR_OK      =  0;        {     No error                         }
+      CBERR_SYSERR  =  1;        {     System error , no memory, etc    }
+      CBERR_DUP     =  2;        {     uniqueness violation             }
+      CBERR_VERSION =  3;        {     didn't understand nb_VERSION     }
+
+      NB_VERSION    =  5;        {     Version of NewBroker structure   }
+
+Type
+  pNewBroker = ^tNewBroker;
+  tNewBroker = record
+   nb_Version   : Shortint;  {     set to NB_VERSION                }
+   nb_Name,
+   nb_Title,
+   nb_Descr     : STRPTR;
+   nb_Unique,
+   nb_Flags     : Integer;
+   nb_Pri       : Shortint;
+   {     new in V5   }
+   nb_Port      : pMsgPort;
+   nb_ReservedChannel  : Integer;  {     plans for later port sharing     }
+  END;
+
+CONST
+{     Flags for nb_Unique }
+      NBU_DUPLICATE  = 0;
+      NBU_UNIQUE     = 1;        {     will not allow duplicates        }
+      NBU_NOTIFY     = 2;        {     sends CXM_UNIQUE to existing broker }
+
+{     Flags for nb_Flags }
+        COF_SHOW_HIDE = 4;
+
+{    *******
+ * cxusr
+ *******}
+
+{    * Fake data types for system private objects   }
+Type
+  CxObj = Longint;
+  pCxObj = ^CxObj;
+  CxMsg = Longint;
+  pCXMsg = ^CxMsg;
+
+
+CONST
+{    ******************************}
+{    * Commodities Object Types   *}
+{    ******************************}
+      CX_INVALID     = 0;     {     not a valid object (probably null)  }
+      CX_FILTER      = 1;     {     input event messages only           }
+      CX_TYPEFILTER  = 2;     {     filter on message type      }
+      CX_SEND        = 3;     {     sends a message                     }
+      CX_SIGNAL      = 4;     {     sends a signal              }
+      CX_TRANSLATE   = 5;     {     translates IE into chain            }
+      CX_BROKER      = 6;     {     application representative          }
+      CX_DEBUG       = 7;     {     dumps kprintf to serial port        }
+      CX_CUSTOM      = 8;     {     application provids function        }
+      CX_ZERO        = 9;     {     system terminator node      }
+
+{    ***************}
+{    * CxMsg types *}
+{    ***************}
+      CXM_UNIQUE     = 16;    {     sent down broker by CxBroker()      }
+{     Obsolete: subsumed by CXM_COMMAND (below)   }
+
+{     Messages of this type rattle around the Commodities input network.
+ * They will be sent to you by a Sender object, and passed to you
+ * as a synchronous function call by a Custom object.
+ *
+ * The message port or function entry point is stored in the object,
+ * and the ID field of the message will be set to what you arrange
+ * issuing object.
+ *
+ * The Data field will point to the input event triggering the
+ * message.
+ }
+      CXM_IEVENT     = 32;
+
+{     These messages are sent to a port attached to your Broker.
+ * They are sent to you when the controller program wants your
+ * program to do something.  The ID field identifies the command.
+ *
+ * The Data field will be used later.
+ }
+      CXM_COMMAND    = 64;
+
+{     ID values   }
+      CXCMD_DISABLE   = (15);   {     please disable yourself       }
+      CXCMD_ENABLE    = (17);   {     please enable yourself        }
+      CXCMD_APPEAR    = (19);   {     open your window, if you can  }
+      CXCMD_DISAPPEAR = (21);   {     go dormant                    }
+      CXCMD_KILL      = (23);   {     go away for good              }
+      CXCMD_UNIQUE    = (25);   {     someone tried to create a broker
+                               * with your name.  Suggest you Appear.
+                               }
+      CXCMD_LIST_CHG  = (27);  {     Used by Exchange program. Someone }
+                              {     has changed the broker list       }
+
+{     return values for BrokerCommand(): }
+      CMDE_OK        = (0);
+      CMDE_NOBROKER  = (-1);
+      CMDE_NOPORT    = (-2);
+      CMDE_NOMEM     = (-3);
+
+{     IMPORTANT NOTE: for V5:
+ * Only CXM_IEVENT messages are passed through the input network.
+ *
+ * Other types of messages are sent to an optional port in your broker.
+ *
+ * This means that you must test the message type in your message handling,
+ * if input messages and command messages come to the same port.
+ *
+ * Older programs have no broker port, so processing loops which
+ * make assumptions about type won't encounter the new message types.
+ *
+ * The TypeFilter CxObject is hereby obsolete.
+ *
+ * It is less convenient for the application, but eliminates testing
+ * for type of input messages.
+ }
+
+{    ********************************************************}
+{    * CxObj Error Flags (return values from CxObjError())  *}
+{    ********************************************************}
+      COERR_ISNULL      = 1;  {     you called CxError(NULL)            }
+      COERR_NULLATTACH  = 2;  {     someone attached NULL to my list    }
+      COERR_BADFILTER   = 4;  {     a bad filter description was given  }
+      COERR_BADTYPE     = 8;  {     unmatched type-specific operation   }
+
+
+{    ****************************}
+{     Input Expression structure }
+{    ****************************}
+
+      IX_VERSION        = 2;
+
+Type
+  pInputXpression = ^tInputXpression;
+  tInputXpression = record
+   ix_Version,               {     must be set to IX_VERSION  }
+   ix_Class    : Byte;       {     class must match exactly   }
+
+   ix_Code     : Word;      {     Bits that we want  }
+
+   ix_CodeMask : Word;      {     Set bits here to indicate  }
+                             {     which bits in ix_Code are  }
+                             {     don't care bits.           }
+
+   ix_Qualifier: Word;      {     Bits that we want  }
+
+   ix_QualMask : Word;      {     Set bits here to indicate  }
+                           {     which bits in ix_Qualifier }
+                                                   {     are don't care bits        }
+
+   ix_QualSame : Word;    {     synonyms in qualifier      }
+  END;
+
+   IX = tInputXpression;
+   pIX = ^IX;
+
+CONST
+{     QualSame identifiers }
+      IXSYM_SHIFT = 1;     {     left- and right- shift are equivalent     }
+      IXSYM_CAPS  = 2;     {     either shift or caps lock are equivalent  }
+      IXSYM_ALT   = 4;     {     left- and right- alt are equivalent       }
+
+{     corresponding QualSame masks }
+      IXSYM_SHIFTMASK = (IEQUALIFIER_LSHIFT + IEQUALIFIER_RSHIFT);
+      IXSYM_CAPSMASK  = (IXSYM_SHIFTMASK    + IEQUALIFIER_CAPSLOCK);
+      IXSYM_ALTMASK   = (IEQUALIFIER_LALT   + IEQUALIFIER_RALT);
+
+      IX_NORMALQUALS  = $7FFF;   {     for QualMask field: avoid RELATIVEMOUSE }
+
+
+VAR CxBase : pLibrary;
+
+FUNCTION ActivateCxObj(co : pCxObj; tru : LONGINT) : LONGINT;
+PROCEDURE AddIEvents(events : pInputEvent);
+PROCEDURE AttachCxObj(headObj : pCxObj; co : pCxObj);
+PROCEDURE ClearCxObjError(co : pCxObj);
+FUNCTION CreateCxObj(typ : ULONG; arg1 : LONGINT; arg2 : LONGINT): pCxObj;
+FUNCTION CxBroker(nb : pNewBroker; error : pCxObj) : pCxObj;
+FUNCTION CxMsgData(cxm : pCxMsg) : POINTER;
+FUNCTION CxMsgID(cxm : pCxMsg) : LONGINT;
+FUNCTION CxMsgType(cxm : pCxMsg) : ULONG;
+FUNCTION CxObjError(co : pCxObj) : LONGINT;
+FUNCTION CxObjType(co : pCxObj) : ULONG;
+PROCEDURE DeleteCxObj(co : pCxObj);
+PROCEDURE DeleteCxObjAll(co : pCxObj);
+PROCEDURE DisposeCxMsg(cxm : pCxMsg);
+PROCEDURE DivertCxMsg(cxm : pCxMsg; headObj : pCxObj; returnObj : pCxObj);
+PROCEDURE EnqueueCxObj(headObj : pCxObj; co : pCxObj);
+PROCEDURE InsertCxObj(headObj : pCxObj; co : pCxObj; pred : pCxObj);
+FUNCTION InvertKeyMap(ansiCode : ULONG; event : pInputEvent; km : pKeyMap) : BOOLEAN;
+FUNCTION MatchIX(event : pInputEvent; ix : pInputXpression) : BOOLEAN;
+FUNCTION ParseIX(description : pCHAR; ix : pInputXpression) : LONGINT;
+PROCEDURE RemoveCxObj(co : pCxObj);
+PROCEDURE RouteCxMsg(cxm : pCxMsg; co : pCxObj);
+FUNCTION SetCxObjPri(co : pCxObj; pri : LONGINT) : LONGINT;
+PROCEDURE SetFilter(filter : pCxObj; text : pCHAR);
+PROCEDURE SetFilterIX(filter : pCxObj; ix : pInputXpression);
+PROCEDURE SetTranslate(translator : pCxObj; events : pInputEvent);
+
+IMPLEMENTATION
+
+FUNCTION ActivateCxObj(co : pCxObj; tru : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L co,A0
+    MOVE.L  tru,D0
+    MOVEA.L CxBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE AddIEvents(events : pInputEvent);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L events,A0
+    MOVEA.L CxBase,A6
+    JSR -180(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE AttachCxObj(headObj : pCxObj; co : pCxObj);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L headObj,A0
+    MOVEA.L co,A1
+    MOVEA.L CxBase,A6
+    JSR -084(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ClearCxObjError(co : pCxObj);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L co,A0
+    MOVEA.L CxBase,A6
+    JSR -072(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION CreateCxObj(typ : ULONG; arg1 : LONGINT; arg2 : LONGINT) : pCxObj;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  typ,D0
+    MOVEA.L arg1,A0
+    MOVEA.L arg2,A1
+    MOVEA.L CxBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CxBroker(nb : pNewBroker; error : pCxObj) : pCxObj;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L nb,A0
+    MOVE.L  error,D0
+    MOVEA.L CxBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CxMsgData(cxm : pCxMsg) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cxm,A0
+    MOVEA.L CxBase,A6
+    JSR -144(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CxMsgID(cxm : pCxMsg) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cxm,A0
+    MOVEA.L CxBase,A6
+    JSR -150(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CxMsgType(cxm : pCxMsg) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cxm,A0
+    MOVEA.L CxBase,A6
+    JSR -138(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CxObjError(co : pCxObj) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L co,A0
+    MOVEA.L CxBase,A6
+    JSR -066(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CxObjType(co : pCxObj) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L co,A0
+    MOVEA.L CxBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE DeleteCxObj(co : pCxObj);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L co,A0
+    MOVEA.L CxBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE DeleteCxObjAll(co : pCxObj);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L co,A0
+    MOVEA.L CxBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE DisposeCxMsg(cxm : pCxMsg);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cxm,A0
+    MOVEA.L CxBase,A6
+    JSR -168(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE DivertCxMsg(cxm : pCxMsg; headObj : pCxObj; returnObj : pCxObj);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cxm,A0
+    MOVEA.L headObj,A1
+    MOVEA.L returnObj,A2
+    MOVEA.L CxBase,A6
+    JSR -156(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE EnqueueCxObj(headObj : pCxObj; co : pCxObj);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L headObj,A0
+    MOVEA.L co,A1
+    MOVEA.L CxBase,A6
+    JSR -090(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE InsertCxObj(headObj : pCxObj; co : pCxObj; pred : pCxObj);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L headObj,A0
+    MOVEA.L co,A1
+    MOVEA.L pred,A2
+    MOVEA.L CxBase,A6
+    JSR -096(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION InvertKeyMap(ansiCode : ULONG; event : pInputEvent; km : pKeyMap) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  ansiCode,D0
+    MOVEA.L event,A0
+    MOVEA.L km,A1
+    MOVEA.L CxBase,A6
+    JSR -174(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION MatchIX(event : pInputEvent; ix : pInputXpression) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L event,A0
+    MOVEA.L ix,A1
+    MOVEA.L CxBase,A6
+    JSR -204(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION ParseIX(description : pCHAR; ix : pInputXpression) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L description,A0
+    MOVEA.L ix,A1
+    MOVEA.L CxBase,A6
+    JSR -132(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE RemoveCxObj(co : pCxObj);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L co,A0
+    MOVEA.L CxBase,A6
+    JSR -102(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE RouteCxMsg(cxm : pCxMsg; co : pCxObj);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cxm,A0
+    MOVEA.L co,A1
+    MOVEA.L CxBase,A6
+    JSR -162(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION SetCxObjPri(co : pCxObj; pri : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L co,A0
+    MOVE.L  pri,D0
+    MOVEA.L CxBase,A6
+    JSR -078(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE SetFilter(filter : pCxObj; text : pCHAR);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L filter,A0
+    MOVEA.L text,A1
+    MOVEA.L CxBase,A6
+    JSR -120(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SetFilterIX(filter : pCxObj; ix : pInputXpression);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L filter,A0
+    MOVEA.L ix,A1
+    MOVEA.L CxBase,A6
+    JSR -126(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SetTranslate(translator : pCxObj; events : pInputEvent);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L translator,A0
+    MOVEA.L events,A1
+    MOVEA.L CxBase,A6
+    JSR -114(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+END. (* UNIT COMMODITIES *)
+
+
+

+ 275 - 0
packages/extra/amunits/units/configregs.pas

@@ -0,0 +1,275 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit configregs;
+
+INTERFACE
+
+uses exec;
+
+{
+** AutoConfig (tm) boards each contain a 32 byte "ExpansionRom" area that is
+** read by the system software at configuration time.  Configuration of each
+** board starts when the ConfigIn* signal is passed from the previous board
+** (or from the system for the first board).  Each board will present it's
+** ExpansionRom structure at location $00E80000 to be read by the system.
+** This file defines the appearance of the ExpansionRom area.
+**
+** Expansion boards are actually organized such that only one nybble per
+** 16 bit word contains valid information.  The low nybbles of each
+** word are combined to fill the structure below. (This table is structured
+** as LOGICAL information.  This means that it never corresponds exactly
+** with a physical implementation.)
+**
+** The ExpansionRom space is further split into two regions:  The first 16
+** bytes are read-only.  Except for the er_type field, this area is inverted
+** by the system software when read in.  The second 16 bytes contain the
+** control portion, where all read/write registers are located.
+**
+** The system builds one "ConfigDev" structure for each board found.  The
+** list of boards can be examined using the expansion.library/FindConfigDev
+** function.
+**
+** A special "hacker" Manufacturer ID number is reserved for test use:
+** 2011 ($7DB).  When inverted this will look like $F824.
+}
+
+Type
+
+    pExpansionRom = ^tExpansionRom;
+    tExpansionRom = record
+        er_Type         : Byte;
+        er_Product      : Byte;
+        er_Flags        : Byte;
+        er_Reserved03   : Byte;
+        er_Manufacturer : Word;
+        er_SerialNumber : ULONG;
+        er_InitDiagVec  : Word;
+        er_Reserved0c   : Byte;
+        er_Reserved0d   : Byte;
+        er_Reserved0e   : Byte;
+        er_Reserved0f   : Byte;
+    end;
+
+{
+** Note that use of the ec_BaseAddress register is tricky.  The system
+** will actually write twice.  First the low order nybble is written
+** to the ec_BaseAddress register+2 (D15-D12).  Then the entire byte is
+** written to ec_BaseAddress (D15-D8).  This allows writing of a byte-wide
+** address to nybble size registers.
+}
+
+    pExpansionControl = ^tExpansionControl;
+    tExpansionControl = record
+        ec_Interrupt    : Byte;         { interrupt control register }
+        ec_Reserved11   : Byte;
+        ec_BaseAddress  : Byte;         { set new config address }
+        ec_Shutup       : Byte;         { don't respond, pass config out }
+        ec_Reserved14   : Byte;
+        ec_Reserved15   : Byte;
+        ec_Reserved16   : Byte;
+        ec_Reserved17   : Byte;
+        ec_Reserved18   : Byte;
+        ec_Reserved19   : Byte;
+        ec_Reserved1a   : Byte;
+        ec_Reserved1b   : Byte;
+        ec_Reserved1c   : Byte;
+        ec_Reserved1d   : Byte;
+        ec_Reserved1e   : Byte;
+        ec_Reserved1f   : Byte;
+    end;
+
+{
+** many of the constants below consist of a triplet of equivalent
+** definitions: xxMASK is a bit mask of those bits that matter.
+** xxBIT is the starting bit number of the field.  xxSIZE is the
+** number of bits that make up the definition.  This method is
+** used when the field is larger than one bit.
+**
+** If the field is only one bit wide then the xxB_xx and xxF_xx convention
+** is used (xxB_xx is the bit number, and xxF_xx is mask of the bit).
+}
+
+Const
+
+{ manifest constants }
+
+           E_SLOTSIZE          = $10000;
+           E_SLOTMASK          = -1;
+           E_SLOTSHIFT         = 16;
+
+{ these define the two free regions of Zorro memory space.
+** THESE MAY WELL CHANGE FOR FUTURE PRODUCTS!
+}
+
+           E_EXPANSIONBASE     = $e80000;
+           EZ3_EXPANSIONBASE   = $ff000000;      {           Zorro III config address }
+           E_EXPANSIONSIZE     = $080000;
+           E_EXPANSIONSLOTS    = 8;
+
+           E_MEMORYBASE        = $200000;
+           E_MEMORYSIZE        = $800000;
+           E_MEMORYSLOTS       = 128;
+
+           EZ3_CONFIGAREA      =    $40000000;      {           Zorro III space }
+           EZ3_CONFIGAREAEND   =    $7FFFFFFF;      {           Zorro III space }
+           EZ3_SIZEGRANULARITY =    $00080000;      {           512K increments }
+
+
+
+{          *** er_Type definitions (ttldcmmm) **************************************}
+
+{           er_Type board type bits -- the OS ignores "old style" boards }
+           ERT_TYPEMASK          =  $c0;    {Bits 7-6 }
+           ERT_TYPEBIT           =  6  ;
+           ERT_TYPESIZE          =  2  ;
+           ERT_NEWBOARD          =  $c0;
+           ERT_ZORROII           =  ERT_NEWBOARD;
+           ERT_ZORROIII          =  $80;
+
+{           other bits defined in er_Type }
+           ERTB_MEMLIST          =  5;   {           Link RAM into free memory list }
+           ERTB_DIAGVALID        =  4;   {           ROM vector is valid }
+           ERTB_CHAINEDCONFIG    =  3;   {           Next config is part of the same card }
+
+           ERTF_MEMLIST          =  32;
+           ERTF_DIAGVALID        =  16;
+           ERTF_CHAINEDCONFIG    =  8;
+
+{           er_Type field memory size bits }
+           ERT_MEMMASK           =  $07;    {Bits 2-0 }
+           ERT_MEMBIT            =  0  ;
+           ERT_MEMSIZE           =  3  ;
+
+
+
+{          *** er_Flags byte -- for those things that didn't fit into the type byte ***}
+{          *** the hardware stores this byte in inverted form                       ***}
+           ERFF_MEMSPACE         =  128;     {           Wants to be in 8 meg space. }
+           ERFB_MEMSPACE         =  7;       {           (NOT IMPLEMENTED) }
+
+           ERFF_NOSHUTUP         =  64;      {           Board can't be shut up }
+           ERFB_NOSHUTUP         =  6;
+
+           ERFF_EXTENDED         =  32;      {           Zorro III: Use extended size table }
+           ERFB_EXTENDED         =  5;       {                      for bits 0-2 of er_Type }
+                                             {           Zorro II : Must be 0 }
+
+           ERFF_ZORRO_III        =  16;      {           Zorro III: must be 1 }
+           ERFB_ZORRO_III        =  4;       {           Zorro II : must be 0 }
+
+           ERT_Z3_SSMASK         =  $0F;     {           Bits 3-0.  Zorro III Sub-Size.  How }
+           ERT_Z3_SSBIT          =  0;       {           much space the card actually uses   }
+           ERT_Z3_SSSIZE         =  4;       {           (regardless of config granularity)  }
+                                             {           Zorro II : must be 0        }
+
+
+{           ec_Interrupt register (unused) *******************************************}
+           ECIB_INTENA           =  1;
+           ECIB_RESET            =  3;
+           ECIB_INT2PEND         =  4;
+           ECIB_INT6PEND         =  5;
+           ECIB_INT7PEND         =  6;
+           ECIB_INTERRUPTING     =  7;
+
+           ECIF_INTENA           =  2;
+           ECIF_RESET            =  8;
+           ECIF_INT2PEND         =  16;
+           ECIF_INT6PEND         =  32;
+           ECIF_INT7PEND         =  64;
+           ECIF_INTERRUPTING     =  128;
+
+
+{**************************************************************************
+**
+** these are the specifications for the diagnostic area.  If the Diagnostic
+** Address Valid bit is set in the Board Type byte (the first byte in
+** expansion space) then the Diag Init vector contains a valid offset.
+**
+** The Diag Init vector is actually a word offset from the base of the
+** board.  The resulting address points to the base of the DiagArea
+** structure.  The structure may be physically implemented either four,
+** eight, or sixteen bits wide.  The code will be copied out into
+** ram first before being called.
+**
+** The da_Size field, and both code offsets (da_DiagPoint and da_BootPoint)
+** are offsets from the diag area AFTER it has been copied into ram, and
+** "de-nibbleized" (if needed).  Inotherwords, the size is the size of
+** the actual information, not how much address space is required to
+** store it.
+**
+** All bits are encoded with uninverted logic (e.g. 5 volts on the bus
+** is a logic one).
+**
+** If your board is to make use of the boot facility then it must leave
+** its config area available even after it has been configured.  Your
+** boot vector will be called AFTER your board's final address has been
+** set.
+**
+***************************************************************************}
+
+Type
+
+    pDiagArea = ^tDiagArea;
+    tDiagArea = record
+        da_Config       : Byte;         { see below for definitions }
+        da_Flags        : Byte;         { see below for definitions }
+        da_Size         : Word;         { the size (in bytes) of the total diag area }
+        da_DiagPoint    : Word;         { where to start for diagnostics, or zero }
+        da_BootPoint    : Word;         { where to start for booting }
+        da_Name         : Word;         { offset in diag area where a string }
+                                        {   identifier can be found (or zero if no }
+                                        {   identifier is present). }
+
+        da_Reserved01   : Word;         { two words of reserved data.   must be zero. }
+        da_Reserved02   : Word;
+    end;
+
+Const
+
+{ da_Config definitions }
+
+    DAC_BUSWIDTH        = $C0;  { two bits for bus width }
+    DAC_NIBBLEWIDE      = $00;
+    DAC_BYTEWIDE        = $40;
+    DAC_WORDWIDE        = $80;
+
+    DAC_BOOTTIME        = $30;  { two bits for when to boot }
+    DAC_NEVER           = $00;  { obvious }
+    DAC_CONFIGTIME      = $10;  { call da_BootPoint when first configing the }
+                                {   the device }
+    DAC_BINDTIME        = $20;  { run when binding drivers to boards }
+
+{
+** These are the calling conventions for Diag or Boot area
+**
+** A7 -- points to at least 2K of stack
+** A6 -- ExecBase
+** A5 -- ExpansionBase
+** A3 -- your board's ConfigDev structure
+** A2 -- Base of diag/init area that was copied
+** A0 -- Base of your board
+**
+** Your board should return a value in D0.  If this value is NULL, then
+** the diag/init area that was copied in will be returned to the free
+** memory pool.
+}
+
+IMPLEMENTATION
+
+end.
+
+

+ 71 - 0
packages/extra/amunits/units/configvars.pas

@@ -0,0 +1,71 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit configvars;
+
+INTERFACE
+
+uses exec, configregs;
+
+Type
+
+    pConfigDev = ^tConfigDev;
+    tConfigDev = record
+        cd_Node         : tNode;
+        cd_Flags        : Byte;
+        cd_Pad          : Byte;
+        cd_Rom          : tExpansionRom; { image of expansion rom area }
+        cd_BoardAddr    : Pointer;       { where in memory the board is }
+        cd_BoardSize    : ULONG;         { size in bytes }
+        cd_SlotAddr     : Word;          { which slot number }
+        cd_SlotSize     : Word;          { number of slots the board takes }
+        cd_Driver       : Pointer;       { pointer to node of driver }
+        cd_NextCD       : pConfigDev;    { linked list of drivers to config }
+        cd_Unused       : Array [0..3] of ULONG;
+                                         { for whatever the driver whats }
+    end;
+
+
+Const
+
+{ cd_Flags }
+    CDB_SHUTUP          = 0;    { this board has been shut up }
+    CDB_CONFIGME        = 1;    { this board needs a driver to claim it }
+    CDB_BADMEMORY       = 2;
+    CDB_PROCESSED       = 3;
+
+    CDF_SHUTUP          = $01;
+    CDF_CONFIGME        = $02;
+    CDF_BADMEMORY       = $04;
+    CDF_PROCESSED       = $08;
+
+Type
+
+{ this structure is used by GetCurrentBinding() and SetCurrentBinding() }
+
+    pCurrentBinding = ^tCurrentBinding;
+    tCurrentBinding = record
+        cb_ConfigDev    : pConfigDev;           { first configdev in chain }
+        cb_FileName     : STRPTR;               { file name of driver }
+        cb_ProductString : STRPTR;              { product # string }
+        cb_ToolTypes    : POINTER;              { tooltypes from disk object }
+    end;
+
+IMPLEMENTATION
+
+end.
+
+

+ 155 - 0
packages/extra/amunits/units/console.pas

@@ -0,0 +1,155 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{
+    To call the two routines defined below, you'll need to set
+    ConsoleBase to an appropriate value.
+}
+
+unit console;
+
+INTERFACE
+
+uses exec, inputevent, keymap;
+
+
+const
+
+{***** Console commands *****}
+
+     CD_ASKKEYMAP               = CMD_NONSTD + 0;
+     CD_SETKEYMAP               = CMD_NONSTD + 1;
+     CD_ASKDEFAULTKEYMAP        = CMD_NONSTD + 2;
+     CD_SETDEFAULTKEYMAP        = CMD_NONSTD + 3;
+
+
+{***** SGR parameters *****}
+
+    SGR_PRIMARY         = 0;
+    SGR_BOLD            = 1;
+    SGR_ITALIC          = 3;
+    SGR_UNDERSCORE      = 4;
+    SGR_NEGATIVE        = 7;
+
+    SGR_NORMAL          = 22;      { default foreground color, not bold }
+    SGR_NOTITALIC       = 23;
+    SGR_NOTUNDERSCORE   = 24;
+    SGR_POSITIVE        = 27;
+
+{ these names refer to the ANSI standard, not the implementation }
+
+    SGR_BLACK           = 30;
+    SGR_RED             = 31;
+    SGR_GREEN           = 32;
+    SGR_YELLOW          = 33;
+    SGR_BLUE            = 34;
+    SGR_MAGENTA         = 35;
+    SGR_CYAN            = 36;
+    SGR_WHITE           = 37;
+    SGR_DEFAULT         = 39;
+
+    SGR_BLACKBG         = 40;
+    SGR_REDBG           = 41;
+    SGR_GREENBG         = 42;
+    SGR_YELLOWBG        = 43;
+    SGR_BLUEBG          = 44;
+    SGR_MAGENTABG       = 45;
+    SGR_CYANBG          = 46;
+    SGR_WHITEBG         = 47;
+    SGR_DEFAULTBG       = 49;
+
+{ these names refer to the implementation, they are the preferred   }
+{ names for use with the Amiga console device.        }
+
+    SGR_CLR0            = 30;
+    SGR_CLR1            = 31;
+    SGR_CLR2            = 32;
+    SGR_CLR3            = 33;
+    SGR_CLR4            = 34;
+    SGR_CLR5            = 35;
+    SGR_CLR6            = 36;
+    SGR_CLR7            = 37;
+
+    SGR_CLR0BG          = 40;
+    SGR_CLR1BG          = 41;
+    SGR_CLR2BG          = 42;
+    SGR_CLR3BG          = 43;
+    SGR_CLR4BG          = 44;
+    SGR_CLR5BG          = 45;
+    SGR_CLR6BG          = 46;
+    SGR_CLR7BG          = 47;
+
+
+{***** DSR parameters *****}
+
+    DSR_CPR             = 6;
+
+{***** CTC parameters *****}
+
+    CTC_HSETTAB         = 0;
+    CTC_HCLRTAB         = 2;
+    CTC_HCLRTABSALL     = 5;
+
+{*****   TBC parameters *****}
+
+    TBC_HCLRTAB         = 0;
+    TBC_HCLRTABSALL     = 3;
+
+{*****   SM and RM parameters *****}
+
+    M_LNM               = 20;           { linefeed newline mode }
+    M_ASM               = '>1';         { auto scroll mode }
+    M_AWM               = '?7';         { auto wrap mode }
+
+VAR ConsoleDevice : pDevice;
+
+FUNCTION CDInputHandler(events : pInputEvent; consoleDev : pLibrary) : pInputEvent;
+FUNCTION RawKeyConvert(events : pInputEvent; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : LONGINT;
+
+IMPLEMENTATION
+
+FUNCTION CDInputHandler(events : pInputEvent; consoleDev : pLibrary) : pInputEvent;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L events,A0
+    MOVEA.L consoleDev,A1
+    MOVEA.L ConsoleDevice,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION RawKeyConvert(events : pInputEvent; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L events,A0
+    MOVEA.L buffer,A1
+    MOVE.L  length,D1
+    MOVEA.L keyMap,A2
+    MOVEA.L ConsoleDevice,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT CONSOLE *)
+
+
+

+ 106 - 0
packages/extra/amunits/units/conunit.pas

@@ -0,0 +1,106 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit conunit;
+
+INTERFACE
+
+uses exec, console, keymap, inputevent;
+
+const
+{ ---- console unit numbers for OpenDevice() }
+ CONU_LIBRARY   = -1;      { no unit, just fill in IO_DEVICE field }
+ CONU_STANDARD  = 0;       { standard unmapped console }
+
+{ ---- New unit numbers for OpenDevice() - (V36) }
+
+ CONU_CHARMAP   = 1;       { bind character map to console }
+ CONU_SNIPMAP   = 3;       { bind character map w/ snip to console }
+
+{ ---- New flag defines for OpenDevice() - (V37) }
+
+ CONFLAG_DEFAULT               =  0;
+ CONFLAG_NODRAW_ON_NEWSIZE     =  1;
+
+
+    PMB_ASM     = M_LNM + 1;    { internal storage bit for AS flag }
+    PMB_AWM     = PMB_ASM + 1;  { internal storage bit for AW flag }
+    MAXTABS     = 80;
+
+
+type
+
+    pConUnit = ^tConUnit;
+    tConUnit = record
+        cu_MP   : tMsgPort;
+        { ---- read only variables }
+        cu_Window       : Pointer;      { (WindowPtr) intuition window bound to this unit }
+        cu_XCP          : Integer;        { character position }
+        cu_YCP          : Integer;
+        cu_XMax         : Integer;        { max character position }
+        cu_YMax         : Integer;
+        cu_XRSize       : Integer;        { character raster size }
+        cu_YRSize       : Integer;
+        cu_XROrigin     : Integer;        { raster origin }
+        cu_YROrigin     : Integer;
+        cu_XRExtant     : Integer;        { raster maxima }
+        cu_YRExtant     : Integer;
+        cu_XMinShrink   : Integer;        { smallest area intact from resize process }
+        cu_YMinShrink   : Integer;
+        cu_XCCP         : Integer;        { cursor position }
+        cu_YCCP         : Integer;
+
+   { ---- read/write variables (writes must must be protected) }
+   { ---- storage for AskKeyMap and SetKeyMap }
+
+        cu_KeyMapStruct : tKeyMap;
+
+   { ---- tab stops }
+
+        cu_TabStops     : Array [0..MAXTABS-1] of Word;
+                                { 0 at start, -1 at end of list }
+
+   { ---- console rastport attributes }
+
+        cu_Mask         : Shortint;
+        cu_FgPen        : Shortint;
+        cu_BgPen        : Shortint;
+        cu_AOLPen       : Shortint;
+        cu_DrawMode     : Shortint;
+        cu_AreaPtSz     : Shortint;
+        cu_AreaPtrn     : Pointer;      { cursor area pattern }
+        cu_Minterms     : Array [0..7] of Byte; { console minterms }
+        cu_Font         : Pointer;      { (TextFontPtr) }
+        cu_AlgoStyle    : Byte;
+        cu_TxFlags      : Byte;
+        cu_TxHeight     : Word;
+        cu_TxWidth      : Word;
+        cu_TxBaseline   : Word;
+        cu_TxSpacing    : Word;
+
+   { ---- console MODES and RAW EVENTS switches }
+
+        cu_Modes        : Array [0..(PMB_AWM+7) div 8 - 1] of Byte;
+                                { one bit per mode }
+        cu_RawEvents    : Array [0..(IECLASS_MAX+7) div 8 - 1] of Byte;
+    end;
+
+IMPLEMENTATION
+
+end.
+
+
+

+ 1274 - 0
packages/extra/amunits/units/datatypes.pas

@@ -0,0 +1,1274 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit datatypes;
+
+INTERFACE
+
+uses exec, amigados, intuition, utility,
+     graphics, iffparse, amigaprinter, prtbase;
+
+const
+{***************************************************************************}
+
+ ID_DTYP = 1146378576;
+
+{***************************************************************************}
+
+ ID_DTHD = 1146374212;
+
+Type
+ pDataTypeHeader = ^tDataTypeHeader;
+ tDataTypeHeader = record
+    dth_Name,                                         { Descriptive name of the data type }
+    dth_BaseName,                                     { Base name of the data type }
+    dth_Pattern  : STRPTR;                            { Match pattern for file name. }
+    dth_Mask : Pointer;                               { Comparision mask }
+    dth_GroupID,                                      { Group that the DataType is in }
+    dth_ID   : ULONG;                                 { ID for DataType (same as IFF FORM type) }
+    dth_MaskLen,                                      { Length of comparision mask }
+    dth_Pad   : Integer;                              { Unused at present (must be 0) }
+    dth_Flags,                                        { Flags }
+    dth_Priority  : WORD;                             { Priority }
+ end;
+
+const
+ DTHSIZE = 32;
+
+{***************************************************************************}
+
+{ Basic type }
+ DTF_TYPE_MASK  = $000F;
+ DTF_BINARY     = $0000;
+ DTF_ASCII      = $0001;
+ DTF_IFF        = $0002;
+ DTF_MISC       = $0003;
+
+{ Set if case is important }
+ DTF_CASE       = $0010;
+
+{ Reserved for system use }
+ DTF_SYSTEM1    = $1000;
+
+{****************************************************************************
+ *
+ * GROUP ID and ID
+ *
+ * This is used for filtering out objects that you don't want.  For
+ * example, you could make a filter for the ASL file requester so
+ * that it only showed the files that were pictures, or even to
+ * narrow it down to only show files that were ILBM pictures.
+ *
+ * Note that the Group ID's are in lower case, and always the first
+ * four characters of the word.
+ *
+ * For ID's; If it is an IFF file, then the ID is the same as the
+ * FORM type.  If it isn't an IFF file, then the ID would be the
+ * first four characters of name for the file type.
+ *
+ ****************************************************************************}
+
+{ System file, such as; directory, executable, library, device, font, etc. }
+ GID_SYSTEM      = 1937339252;
+
+{ Formatted or unformatted text }
+ GID_TEXT        = 1952807028;
+
+{ Formatted text with graphics or other DataTypes }
+ GID_DOCUMENT    = 1685021557;
+
+{ Sound }
+ GID_SOUND       = 1936684398;
+
+{ Musical instruments used for musical scores }
+ GID_INSTRUMENT  = 1768846196;
+
+{ Musical score }
+ GID_MUSIC       = 1836413801;
+
+{ Still picture }
+ GID_PICTURE     = 1885954932;
+
+{ Animated picture }
+ GID_ANIMATION   = 1634625901;
+
+{ Animation with audio track }
+ GID_MOVIE       = 1836021353;
+
+{***************************************************************************}
+
+{ A code chunk contains an embedded executable that can be loaded
+ * with InternalLoadSeg. }
+ ID_CODE = 1146372932;
+
+Type
+{ DataTypes comparision hook context (Read-Only).  This is the
+ * argument that is passed to a custom comparision routine. }
+
+ pDTHookContext = ^tDTHookContext;
+ tDTHookContext = record
+    { Libraries that are already opened for your use }
+    dthc_SysBase,
+    dthc_DOSBase,
+    dthc_IFFParseBase,
+    dthc_UtilityBase             : pLibrary;
+
+    { File context }
+    dthc_Lock                    : BPTR;                { Lock on the file }
+    dthc_FIB                     : pFileInfoBlock;      { Pointer to a FileInfoBlock }
+    dthc_FileHandle              : BPTR;                { Pointer to the file handle (may be NULL) }
+    dthc_IFF                     : pIFFHandle;          { Pointer to an IFFHandle (may be NULL) }
+    dthc_Buffer                  : STRPTR;              { Buffer }
+    dthc_BufferLength            : ULONG;               { Length of the buffer }
+ end;
+
+{***************************************************************************}
+
+const
+ ID_TOOL = 1146377292;
+
+Type
+ pTool = ^tTool;
+ tTool = record
+    tn_Which,                                      { Which tool is this }
+    tn_Flags  : WORD;                              { Flags }
+    tn_Program : STRPTR;                           { Application to use }
+ end;
+
+const
+ TSIZE = 8;
+
+{ defines for tn_Which }
+ TW_INFO               =  1;
+ TW_BROWSE             =  2;
+ TW_EDIT               =  3;
+ TW_PRINT              =  4;
+ TW_MAIL               =  5;
+
+{ defines for tn_Flags }
+ TF_LAUNCH_MASK        =  $000F;
+ TF_SHELL              =  $0001;
+ TF_WORKBENCH          =  $0002;
+ TF_RX                 =  $0003;
+
+{***************************************************************************}
+
+ ID_TAGS = 1146377287;
+
+{***************************************************************************}
+
+Type
+ pDataType = ^tDataType;
+ tDataType = record
+    dtn_Node1,                      { Reserved for system use }
+    dtn_Node2   : tNode;            { Reserved for system use }
+    dtn_Header  : pDataTypeHeader;  { Pointer to the DataTypeHeader }
+    dtn_ToolList: tList;            { List of tool nodes }
+    dtn_FunctionName : STRPTR;      { Name of comparision routine }
+    dtn_AttrList : pTagItem;         { Object creation tags }
+    dtn_Length : ULONG;             { Length of the memory block }
+ end;
+
+{***************************************************************************}
+
+ pToolNode = ^tToolNode;
+ tToolNode = Record
+    tn_Node   : tNode;                               { Embedded node }
+    tn_Tool   : tTool;                               { Embedded tool }
+    tn_Length : ULONG;                            { Length of the memory block }
+ end;
+
+{***************************************************************************}
+
+const
+ ID_NAME = 1312902469;
+
+{***************************************************************************}
+
+{ text ID's }
+ DTERROR_UNKNOWN_DATATYPE              =  2000;
+ DTERROR_COULDNT_SAVE                  =  2001;
+ DTERROR_COULDNT_OPEN                  =  2002;
+ DTERROR_COULDNT_SEND_MESSAGE          =  2003;
+
+{ new for V40 }
+ DTERROR_COULDNT_OPEN_CLIPBOARD        =  2004;
+ DTERROR_Reserved                      =  2005;
+ DTERROR_UNKNOWN_COMPRESSION           =  2006;
+ DTERROR_NOT_ENOUGH_DATA               =  2007;
+ DTERROR_INVALID_DATA                  =  2008;
+
+{ Offset for types }
+ DTMSG_TYPE_OFFSET                     =  2100;
+
+{***************************************************************************}
+
+  DATATYPESCLASS        : Pchar =  'datatypesclass';
+
+{***************************************************************************}
+
+  DTA_Dummy             =  (TAG_USER+$1000);
+
+{ Generic attributes }
+  DTA_TextAttr          =  (DTA_Dummy+10);
+        { (struct TextAttr ) Pointer to the default TextAttr to use for
+         * the text within the object. }
+
+  DTA_TopVert           =  (DTA_Dummy+11);
+        { (LONG) Current top vertical unit }
+
+  DTA_VisibleVert       =  (DTA_Dummy+12);
+        { (LONG) Number of visible vertical units }
+
+  DTA_TotalVert         =  (DTA_Dummy+13);
+        { (LONG) Total number of vertical units }
+
+  DTA_VertUnit          =  (DTA_Dummy+14);
+        { (LONG) Number of pixels per vertical unit }
+
+  DTA_TopHoriz          =  (DTA_Dummy+15);
+        { (LONG) Current top horizontal unit }
+
+  DTA_VisibleHoriz      =  (DTA_Dummy+16);
+        { (LONG)  Number of visible horizontal units }
+
+  DTA_TotalHoriz        =  (DTA_Dummy+17);
+        { (LONG) Total number of horizontal units }
+
+  DTA_HorizUnit         =  (DTA_Dummy+18);
+        { (LONG) Number of pixels per horizontal unit }
+
+  DTA_NodeName          =  (DTA_Dummy+19);
+        { (UBYTE ) Name of the current element within the object. }
+
+  DTA_Title             =  (DTA_Dummy+20);
+        { (UBYTE ) Title of the object. }
+
+  DTA_TriggerMethods    =  (DTA_Dummy+21);
+        { (struct DTMethod ) Pointer to a NULL terminated array of
+         * supported trigger methods. }
+
+  DTA_Data              =  (DTA_Dummy+22);
+        { (APTR) Object specific data. }
+
+  DTA_TextFont          =  (DTA_Dummy+23);
+        { (struct TextFont ) Default font to use for text within the
+         * object. }
+
+  DTA_Methods           =  (DTA_Dummy+24);
+        { (ULONG ) Pointer to a ~0 terminated array of supported
+         * methods. }
+
+  DTA_PrinterStatus     =  (DTA_Dummy+25);
+        { (LONG) Printer error message.  Error numbers are defined in
+         * <devices/printer.h> }
+
+  DTA_PrinterProc       =  (DTA_Dummy+26);
+        { PRIVATE (struct Process ) Pointer to the print process. }
+
+  DTA_LayoutProc        =  (DTA_Dummy+27);
+        { PRIVATE (struct Process ) Pointer to the layout process. }
+
+  DTA_Busy              =  (DTA_Dummy+28);
+        { Used to turn the applications' busy pointer off and on }
+
+  DTA_Sync              =  (DTA_Dummy+29);
+        { Used to indicate that new information has been loaded into
+         * an object.  This is for models that cache the DTA_TopVert-
+         * like tags }
+
+  DTA_BaseName          =  (DTA_Dummy+30);
+        { The base name of the class }
+
+  DTA_GroupID           =  (DTA_Dummy+31);
+        { Group that the object must belong in }
+
+  DTA_ErrorLevel        =  (DTA_Dummy+32);
+        { Error level }
+
+  DTA_ErrorNumber       =  (DTA_Dummy+33);
+        { datatypes.library error number }
+
+  DTA_ErrorString       =  (DTA_Dummy+34);
+        { Argument for datatypes.library error }
+
+  DTA_Conductor         =  (DTA_Dummy+35);
+        { New for V40. (UBYTE ) specifies the name of the
+         * realtime.library conductor.  Defaults to "Main". }
+
+  DTA_ControlPanel      =  (DTA_Dummy+36);
+        { New for V40. (BOOL) Indicate whether a control panel should be
+         * embedded within the object (in the animation datatype, for
+         * example).  Defaults to TRUE. }
+
+  DTA_Immediate         =  (DTA_Dummy+37);
+        { New for V40. (BOOL) Indicate whether the object should
+         * immediately begin playing.  Defaults to FALSE. }
+
+  DTA_Repeat            =  (DTA_Dummy+38);
+        { New for V40. (BOOL) Indicate that the object should repeat
+         * playing.  Defaults to FALSE. }
+
+
+{ DTObject attributes }
+  DTA_Name              =  (DTA_Dummy+100);
+  DTA_SourceType        =  (DTA_Dummy+101);
+  DTA_Handle            =  (DTA_Dummy+102);
+  DTA_DataType          =  (DTA_Dummy+103);
+  DTA_Domain            =  (DTA_Dummy+104);
+
+{ DON'T USE THE FOLLOWING FOUR TAGS.  USE THE CORRESPONDING TAGS IN
+ * <intuition/gadgetclass.h> }
+  DTA_Left              =  (DTA_Dummy+105);
+  DTA_Top               =  (DTA_Dummy+106);
+  DTA_Width             =  (DTA_Dummy+107);
+  DTA_Height            =  (DTA_Dummy+108);
+
+  DTA_ObjName           =  (DTA_Dummy+109);
+  DTA_ObjAuthor         =  (DTA_Dummy+110);
+  DTA_ObjAnnotation     =  (DTA_Dummy+111);
+  DTA_ObjCopyright      =  (DTA_Dummy+112);
+  DTA_ObjVersion        =  (DTA_Dummy+113);
+  DTA_ObjectID          =  (DTA_Dummy+114);
+  DTA_UserData          =  (DTA_Dummy+115);
+  DTA_FrameInfo         =  (DTA_Dummy+116);
+
+{ DON'T USE THE FOLLOWING FOUR TAGS.  USE THE CORRESPONDING TAGS IN
+ * <intuition/gadgetclass.h> }
+  DTA_RelRight          =  (DTA_Dummy+117);
+  DTA_RelBottom         =  (DTA_Dummy+118);
+  DTA_RelWidth          =  (DTA_Dummy+119);
+  DTA_RelHeight         =  (DTA_Dummy+120);
+
+  DTA_SelectDomain      =  (DTA_Dummy+121);
+  DTA_TotalPVert        =  (DTA_Dummy+122);
+  DTA_TotalPHoriz       =  (DTA_Dummy+123);
+  DTA_NominalVert       =  (DTA_Dummy+124);
+  DTA_NominalHoriz      =  (DTA_Dummy+125);
+
+{ Printing attributes }
+  DTA_DestCols          =  (DTA_Dummy+400);
+        { (LONG) Destination X width }
+
+  DTA_DestRows          =  (DTA_Dummy+401);
+        { (LONG) Destination Y height }
+
+  DTA_Special           =  (DTA_Dummy+402);
+        { (UWORD) Option flags }
+
+  DTA_RastPort          =  (DTA_Dummy+403);
+        { (struct RastPort ) RastPort to use when printing. (V40) }
+
+  DTA_ARexxPortName     =  (DTA_Dummy+404);
+        { (STRPTR) Pointer to base name for ARexx port (V40) }
+
+
+{***************************************************************************}
+
+  DTST_RAM              =  1;
+  DTST_FILE             =  2;
+  DTST_CLIPBOARD        =  3;
+  DTST_HOTLINK          =  4;
+
+{***************************************************************************}
+
+{ Attached to the Gadget.SpecialInfo field of the gadget.  Don't access directly,
+ * use the Get/Set calls instead.
+ }
+Type
+
+ pDTSpecialInfo = ^tDTSpecialInfo;
+ tDTSpecialInfo = record
+    si_Lock            : tSignalSemaphore;       { Locked while in DoAsyncLayout() }
+    si_Flags,
+
+    si_TopVert,    { Top row (in units) }
+    si_VisVert,    { Number of visible rows (in units) }
+    si_TotVert,    { Total number of rows (in units) }
+    si_OTopVert,   { Previous top (in units) }
+    si_VertUnit,   { Number of pixels in vertical unit }
+
+    si_TopHoriz,   { Top column (in units) }
+    si_VisHoriz,   { Number of visible columns (in units) }
+    si_TotHoriz,   { Total number of columns (in units) }
+    si_OTopHoriz,  { Previous top (in units) }
+    si_HorizUnit  : Longint;  { Number of pixels in horizontal unit }
+ end;
+
+
+const
+{ Object is in layout processing }
+  DTSIF_LAYOUT         =   1;
+
+{ Object needs to be layed out }
+  DTSIF_NEWSIZE        =   2;
+
+  DTSIF_DRAGGING       =   4;
+  DTSIF_DRAGSELECT     =   8;
+
+  DTSIF_HIGHLIGHT      =   16;
+
+{ Object is being printed }
+  DTSIF_PRINTING       =   32;
+
+{ Object is in layout process }
+  DTSIF_LAYOUTPROC     =   64;
+
+{***************************************************************************}
+
+Type
+ pDTMethod = ^tDTMethod;
+ tDTMethod = record
+    dtm_Label,
+    dtm_Command  : STRPTR;
+    dtm_Method   : ULONG;
+ end;
+
+{***************************************************************************}
+
+Const
+  DTM_Dummy             =  ($600);
+
+{ Inquire what environment an object requires }
+  DTM_FRAMEBOX          =  ($601);
+
+{ Same as GM_LAYOUT except guaranteed to be on a process already }
+  DTM_PROCLAYOUT        =  ($602);
+
+{ Layout that is occurring on a process }
+  DTM_ASYNCLAYOUT       =  ($603);
+
+{ When a RemoveDTObject() is called }
+  DTM_REMOVEDTOBJECT    =  ($604);
+
+  DTM_SELECT            =  ($605);
+  DTM_CLEARSELECTED     =  ($606);
+
+  DTM_COPY              =  ($607);
+  DTM_PRINT             =  ($608);
+  DTM_ABORTPRINT        =  ($609);
+
+  DTM_NEWMEMBER         =  ($610);
+  DTM_DISPOSEMEMBER     =  ($611);
+
+  DTM_GOTO              =  ($630);
+  DTM_TRIGGER           =  ($631);
+
+  DTM_OBTAINDRAWINFO    =  ($640);
+  DTM_DRAW              =  ($641);
+  DTM_RELEASEDRAWINFO   =  ($642);
+
+  DTM_WRITE             =  ($650);
+
+{ Used to ask the object about itself }
+type
+ pFrameInfo = ^tFrameInfo;
+ tFrameInfo = record
+            fri_PropertyFlags : ULONG;
+            fri_Resolution : tPoint;
+            fri_RedBits :  BYTE;
+            fri_GreenBits : BYTE;
+            fri_BlueBits : BYTE;
+            fri_Dimensions : record
+                 Width : ULONG;
+                 Height : ULONG;
+                 Depth : ULONG;
+              end;
+            fri_Screen : pScreen;
+            fri_ColorMap : pColorMap;
+            fri_Flags : ULONG;
+         end;
+
+
+CONST
+
+  FIF_SCALABLE    = $1;
+  FIF_SCROLLABLE  = $2;
+  FIF_REMAPPABLE  = $4;
+
+{ DTM_REMOVEDTOBJECT, DTM_CLEARSELECTED, DTM_COPY, DTM_ABORTPRINT }
+Type
+
+ pdtGeneral = ^tdtGeneral;
+ tdtGeneral = record
+    MethodID   : ULONG;
+    dtg_GInfo  : pGadgetInfo;
+ end;
+
+{ DTM_SELECT }
+ pdtSelect = ^tdtSelect;
+ tdtSelect = record
+    MethodID  : ULONG;
+    dts_GInfo : pGadgetInfo;
+    dts_Select : tRectangle;
+ end;
+
+{ DTM_FRAMEBOX }
+
+ pdtFrameBox = ^tdtFrameBox;
+ tdtFrameBox = record
+    MethodID             : ULONG;
+    dtf_GInfo            : pGadgetInfo;
+    dtf_ContentsInfo,     { Input }
+    dtf_FrameInfo        : pFrameInfo;         { Output }
+    dtf_SizeFrameInfo,
+    dtf_FrameFlags       : ULONG;
+ end;
+
+{ DTM_GOTO }
+ pdtGoto = ^tdtGoto;
+ tdtGoto = record
+    MethodID             : ULONG;
+    dtg_GInfo            : pGadgetInfo;
+    dtg_NodeName         : STRPTR;          { Node to goto }
+    dtg_AttrList         : pTagItem;         { Additional attributes }
+ end;
+
+{ DTM_TRIGGER }
+
+ pdtTrigger = ^tdtTrigger;
+ tdtTrigger = record
+    MethodID             : ULONG;
+    dtt_GInfo            : pGadgetInfo;
+    dtt_Function         : ULONG;
+    dtt_Data             : Pointer;
+ end;
+
+const
+  STM_PAUSE             =  1 ;
+  STM_PLAY              =  2 ;
+  STM_CONTENTS          =  3 ;
+  STM_INDEX             =  4 ;
+  STM_RETRACE           =  5 ;
+  STM_BROWSE_PREV       =  6 ;
+  STM_BROWSE_NEXT       =  7 ;
+
+  STM_NEXT_FIELD        =  8 ;
+  STM_PREV_FIELD        =  9 ;
+  STM_ACTIVATE_FIELD    =  10;
+
+  STM_COMMAND           =  11;
+
+{ New for V40 }
+  STM_REWIND            =  12;
+  STM_FASTFORWARD       =  13;
+  STM_STOP              =  14;
+  STM_RESUME            =  15;
+  STM_LOCATE            =  16;
+
+Type
+{ Printer IO request }
+ pprinterIO = ^tprinterIO;
+ tprinterIO = record
+     ios : tIOStdReq;
+     iodrp : tIODRPReq;
+     iopc : tIOPrtCmdReq;
+ end;
+{ DTM_PRINT }
+
+        pdtPrint = ^tdtPrint;
+        tdtPrint = record
+            MethodID : ULONG;
+            dtp_GInfo : pGadgetInfo;
+            dtp_PIO : pprinterIO;
+            dtp_AttrList : pTagItem;
+         end;
+
+
+{ DTM_DRAW }
+ pdtDraw = ^tdtDraw;
+ tdtDraw = record
+    MethodID             : ULONG;
+    dtd_RPort            : pRastPort;
+    dtd_Left,
+    dtd_Top,
+    dtd_Width,
+    dtd_Height,
+    dtd_TopHoriz,
+    dtd_TopVert          : Longint;
+    dtd_AttrList         : pTagItem;          { Additional attributes }
+ end;
+
+{ DTM_WRITE }
+ pdtWrite = ^tdtWrite;
+ tdtWrite = record
+    MethodID             : ULONG;
+    dtw_GInfo            : pGadgetInfo;       { Gadget information }
+    dtw_FileHandle       : BPTR;              { File handle to write to }
+    dtw_Mode             : ULONG;
+    dtw_AttrList         : pTagItem;          { Additional attributes }
+ end;
+
+const
+{ Save data as IFF data }
+  DTWM_IFF       = 0;
+
+{ Save data as local data format }
+  DTWM_RAW       = 1;
+
+{***************************************************************************}
+
+   PICTUREDTCLASS        : PChar =  'picture.datatype';
+
+{***************************************************************************}
+
+{ Picture attributes }
+   PDTA_ModeID           =  (DTA_Dummy + 200);
+        { Mode ID of the picture }
+
+   PDTA_BitMapHeader     =  (DTA_Dummy + 201);
+
+   PDTA_BitMap           =  (DTA_Dummy + 202);
+        { Pointer to a class-allocated bitmap, that will end
+         * up being freed by picture.class when DisposeDTObject()
+         * is called }
+
+   PDTA_ColorRegisters   =  (DTA_Dummy + 203);
+   PDTA_CRegs            =  (DTA_Dummy + 204);
+   PDTA_GRegs            =  (DTA_Dummy + 205);
+   PDTA_ColorTable       =  (DTA_Dummy + 206);
+   PDTA_ColorTable2      =  (DTA_Dummy + 207);
+   PDTA_Allocated        =  (DTA_Dummy + 208);
+   PDTA_NumColors        =  (DTA_Dummy + 209);
+   PDTA_NumAlloc         =  (DTA_Dummy + 210);
+
+   PDTA_Remap            =  (DTA_Dummy + 211);
+        { Boolean : Remap picture (defaults to TRUE) }
+
+   PDTA_Screen           =  (DTA_Dummy + 212);
+        { Screen to remap to }
+
+   PDTA_FreeSourceBitMap =  (DTA_Dummy + 213);
+        { Boolean : Free the source bitmap after remapping }
+
+   PDTA_Grab             =  (DTA_Dummy + 214);
+        { Pointer to a Point structure }
+
+   PDTA_DestBitMap       =  (DTA_Dummy + 215);
+        { Pointer to the destination (remapped) bitmap }
+
+   PDTA_ClassBitMap      =  (DTA_Dummy + 216);
+        { Pointer to class-allocated bitmap, that will end
+         * up being freed by the class after DisposeDTObject()
+         * is called }
+
+   PDTA_NumSparse        =  (DTA_Dummy + 217);
+        { (UWORD) Number of colors used for sparse remapping }
+
+   PDTA_SparseTable      =  (DTA_Dummy + 218);
+        { (UBYTE *) Pointer to a table of pen numbers indicating
+         * which colors should be used when remapping the image.
+         * This array must contain as many entries as there
+         * are colors specified with PDTA_NumSparse }
+
+{***************************************************************************}
+
+{  Masking techniques  }
+   mskNone                = 0;
+   mskHasMask             = 1;
+   mskHasTransparentColor = 2;
+   mskLasso               = 3;
+   mskHasAlpha            = 4;
+
+{  Compression techniques  }
+   cmpNone                = 0;
+   cmpByteRun1            = 1;
+   cmpByteRun2            = 2;
+
+Type
+{  Bitmap header (BMHD) structure  }
+ pBitMapHeader = ^tBitMapHeader;
+ tBitMapHeader = record
+    bmh_Width,                         { Width in pixels }
+    bmh_Height   : Word;               { Height in pixels }
+    bmh_Left,                          { Left position }
+    bmh_Top      : Integer;            { Top position }
+    bmh_Depth,                         { Number of planes }
+    bmh_Masking,                       { Masking type }
+    bmh_Compression,                   { Compression type }
+    bmh_Pad      : Byte;
+    bmh_Transparent : WORD;            { Transparent color }
+    bmh_XAspect,
+    bmh_YAspect     : Byte;
+    bmh_PageWidth,
+    bmh_PageHeight  : Integer;
+ end;
+
+{***************************************************************************}
+
+{  Color register structure }
+ pColorRegister = ^tColorRegister;
+ tColorRegister = record
+   red, green, blue : Byte;
+ end;
+
+{***************************************************************************}
+
+const
+{ IFF types that may be in pictures }
+   ID_ILBM         = 1229734477;
+   ID_BMHD         = 1112361028;
+   ID_BODY         = 1112491097;
+   ID_CMAP         = 1129136464;
+   ID_CRNG         = 1129467463;
+   ID_GRAB         = 1196572994;
+   ID_SPRT         = 1397772884;
+   ID_DEST         = 1145394004;
+   ID_CAMG         = 1128353095;
+
+{***************************************************************************}
+
+   SOUNDDTCLASS          : PChar =  'sound.datatype';
+
+{***************************************************************************}
+
+{ Sound attributes }
+   SDTA_Dummy            =  (DTA_Dummy + 500);
+   SDTA_VoiceHeader      =  (SDTA_Dummy + 1);
+   SDTA_Sample           =  (SDTA_Dummy + 2);
+   { (UBYTE *) Sample data }
+
+   SDTA_SampleLength     =  (SDTA_Dummy + 3);
+   { (ULONG) Length of the sample data in UBYTEs }
+
+   SDTA_Period           =  (SDTA_Dummy + 4);
+    { (UWORD) Period }
+
+   SDTA_Volume           =  (SDTA_Dummy + 5);
+    { (UWORD) Volume.  Range from 0 to 64 }
+
+   SDTA_Cycles           =  (SDTA_Dummy + 6);
+
+{ The following tags are new for V40 }
+   SDTA_SignalTask       =  (SDTA_Dummy + 7);
+    { (struct Task *) Task to signal when sound is complete or
+        next buffer needed. }
+
+   SDTA_SignalBit        =  (SDTA_Dummy + 8);
+    { (BYTE) Signal bit to use on completion or -1 to disable }
+
+   SDTA_Continuous       =  (SDTA_Dummy + 9);
+    { (ULONG) Playing a continuous stream of data.  Defaults to
+        FALSE. }
+
+{***************************************************************************}
+
+   CMP_NONE     = 0;
+   CMP_FIBDELTA = 1;
+
+Type
+ pVoiceHeader = ^tVoiceHeader;
+ tVoiceHeader = record
+    vh_OneShotHiSamples,
+    vh_RepeatHiSamples,
+    vh_SamplesPerHiCycle : ULONG;
+    vh_SamplesPerSec     : WORD;
+    vh_Octaves,
+    vh_Compression       : Byte;
+    vh_Volume            : ULONG;
+ end;
+
+{***************************************************************************}
+
+const
+{ IFF types }
+   ID_8SVX = 944985688;
+   ID_VHDR = 1447576658;
+
+{***************************************************************************}
+
+{ ***************************************************************************}
+
+   TEXTDTCLASS           : PChar =  'text.datatype';
+
+{ ***************************************************************************}
+
+{  Text attributes }
+   TDTA_Buffer           =  (DTA_Dummy + 300);
+   TDTA_BufferLen        =  (DTA_Dummy + 301);
+   TDTA_LineList         =  (DTA_Dummy + 302);
+   TDTA_WordSelect       =  (DTA_Dummy + 303);
+   TDTA_WordDelim        =  (DTA_Dummy + 304);
+   TDTA_WordWrap         =  (DTA_Dummy + 305);
+     {  Boolean. Should the text be word wrapped.  Defaults to false. }
+
+{ ***************************************************************************}
+
+Type
+{  There is one Line structure for every line of text in our document.  }
+ pLine = ^tLine;
+ tLine = record
+    ln_Link              : tMinNode;            {  to link the lines together }
+    ln_Text              : STRPTR;              {  pointer to the text for this line }
+    ln_TextLen           : ULONG;               {  the character length of the text for this line }
+    ln_XOffset,                                 {  where in the line the text starts }
+    ln_YOffset,                                 {  line the text is on }
+    ln_Width,                                   {  Width of line in pixels }
+    ln_Height,                                  {  Height of line in pixels }
+    ln_Flags             : WORD;                {  info on the line }
+    ln_FgPen,                                   {  foreground pen }
+    ln_BgPen             : Shortint;            {  background pen }
+    ln_Style             : ULONG;               {  Font style }
+    ln_Data              : Pointer;             {  Link data... }
+ end;
+
+{ ***************************************************************************}
+
+const
+{  Line.ln_Flags }
+
+{  Line Feed }
+   LNF_LF        = 1;
+
+{  Segment is a link }
+   LNF_LINK      = 2;
+
+{  ln_Data is a pointer to an DataTypes object }
+   LNF_OBJECT    = 4;
+
+{  Object is selected }
+   LNF_SELECTED  = 8;
+
+{ ***************************************************************************}
+
+{  IFF types that may be text }
+   ID_FTXT         = 1179932756;
+   ID_CHRS         = 1128813139;
+
+{ ***************************************************************************}
+
+   ANIMATIONDTCLASS         : PChar =       'animation.datatype';
+
+{ ***************************************************************************}
+
+{  Animation attributes }
+   ADTA_Dummy            =  (DTA_Dummy + 600);
+   ADTA_ModeID           =  PDTA_ModeID      ;
+   ADTA_KeyFrame         =  PDTA_BitMap      ;
+        {  (struct BitMap *) Key frame (first frame) bitmap }
+
+   ADTA_ColorRegisters   =  PDTA_ColorRegisters;
+   ADTA_CRegs            =  PDTA_CRegs         ;
+   ADTA_GRegs            =  PDTA_GRegs         ;
+   ADTA_ColorTable       =  PDTA_ColorTable    ;
+   ADTA_ColorTable2      =  PDTA_ColorTable2   ;
+   ADTA_Allocated        =  PDTA_Allocated     ;
+   ADTA_NumColors        =  PDTA_NumColors     ;
+   ADTA_NumAlloc         =  PDTA_NumAlloc      ;
+
+   ADTA_Remap            =  PDTA_Remap;
+        {  (BOOL) : Remap animation (defaults to TRUE) }
+
+   ADTA_Screen           =  PDTA_Screen;
+        {  (struct Screen *) Screen to remap to }
+
+   ADTA_NumSparse        =  PDTA_NumSparse;
+        {  (UWORD) Number of colors used for sparse remapping }
+
+   ADTA_SparseTable      =  PDTA_SparseTable;
+        {  (UBYTE *) Pointer to a table of pen numbers indicating
+         * which colors should be used when remapping the image.
+         * This array must contain as many entries as there
+         * are colors specified with ADTA_NumSparse }
+
+   ADTA_Width            =  (ADTA_Dummy + 1);
+   ADTA_Height           =  (ADTA_Dummy + 2);
+   ADTA_Depth            =  (ADTA_Dummy + 3);
+   ADTA_Frames           =  (ADTA_Dummy + 4);
+        {  (ULONG) Number of frames in the animation }
+
+   ADTA_Frame            =  (ADTA_Dummy + 5);
+        {  (ULONG) Current frame }
+
+   ADTA_FramesPerSecond  =  (ADTA_Dummy + 6);
+        {  (ULONG) Frames per second }
+
+   ADTA_FrameIncrement   =  (ADTA_Dummy + 7);
+        {  (LONG) Amount to change frame by when fast forwarding or
+         * rewinding.  Defaults to 10. }
+
+{  Sound attributes }
+   ADTA_Sample           =  SDTA_Sample      ;
+   ADTA_SampleLength     =  SDTA_SampleLength;
+   ADTA_Period           =  SDTA_Period      ;
+   ADTA_Volume           =  SDTA_Volume      ;
+   ADTA_Cycles           =  SDTA_Cycles      ;
+
+{ ***************************************************************************}
+
+   ID_ANIM   = 1095649613;
+   ID_ANHD   = 1095649348;
+   ID_DLTA   = 1145852993;
+
+{ ***************************************************************************}
+
+{   Required ANHD structure describes an ANIM frame }
+Type
+ pAnimHeader = ^tAnimHeader;
+ tAnimHeader = record
+    ah_Operation   : Byte;  {   The compression method:
+                                     0  set directly (normal ILBM BODY),
+                                     1  XOR ILBM mode,
+                                     2  Long Delta mode,
+                                     3  Short Delta mode,
+                                     4  Generalized short/long Delta mode,
+                                     5  Byte Vertical Delta mode
+                                     6  Stereo op 5 (third party)
+                                    74  (ascii 'J') reserved for Eric Graham's
+                                        compression technique (details to be
+                                        released later). }
+
+    ah_Mask        : Byte;      {  (XOR mode only - plane mask where each
+                                   bit is set =1 if there is data and =0
+                                   if not.) }
+
+    ah_Width,                   {  (XOR mode only - width and height of the }
+    ah_Height,                  {  area represented by the BODY to eliminate }
+                                {  unnecessary un-changed data) }
+
+
+    ah_Left,                    {  (XOR mode only - position of rectangular }
+    ah_Top         : WORD;      {  area representd by the BODY) }
+
+
+    ah_AbsTime,                 {  Timing for a frame relative to the time
+                                   the first frame was displayed, in
+                                   jiffies (1/60 sec) }
+
+    ah_RelTime     : ULONG;    {  Timing for frame relative to time
+                                   previous frame was displayed - in
+                                   jiffies (1/60 sec) }
+
+    ah_Interleave,              {  Indicates how may frames back this data is to
+                                   modify.  0 defaults to indicate two frames back
+                                   (for double buffering). n indicates n frames back.
+                                   The main intent here is to allow values
+                                   of 1 for special applications where
+                                   frame data would modify the immediately
+                                   previous frame. }
+
+    ah_Pad0        :  Byte;     {  Pad byte, not used at present. }
+
+    ah_Flags       : ULONG;     {  32 option bits used by options=4 and 5.
+                                   At present only 6 are identified, but the
+                                   rest are set =0 so they can be used to
+                                   implement future ideas.  These are defined
+                                   for option 4 only at this point.  It is
+                                   recommended that all bits be set =0 for
+                                   option 5 and that any bit settings
+                                   used in the future (such as for XOR mode)
+                                   be compatible with the option 4
+                                   bit settings.   Player code should check
+                                   undefined bits in options 4 and 5 to assure
+                                   they are zero.
+
+                                   The six bits for current use are:
+
+                                    bit #       set =0                  set =1
+                                    ===============================================
+                                    0           short data              long data
+                                    1           set                     XOR
+                                    2           separate info           one info list
+                                                for each plane          for all planes
+                                    3           not RLC                 RLC (run length coded)
+                                    4           horizontal              vertical
+                                    5           short info offsets      long info offsets
+                                }
+
+    ah_Pad  : Array[0..15] of Byte;    {  This is a pad for future use for future
+                                   compression modes. }
+ end;
+
+{ ***************************************************************************}
+
+const
+   ADTM_Dummy            =  ($700);
+
+   ADTM_LOADFRAME        =  ($701);
+    {  Used to load a frame of the animation }
+
+   ADTM_UNLOADFRAME      =  ($702);
+    {  Used to unload a frame of the animation }
+
+   ADTM_START            =  ($703);
+    {  Used to start the animation }
+
+   ADTM_PAUSE            =  ($704);
+    {  Used to pause the animation (don't reset the timer) }
+
+   ADTM_STOP             =  ($705);
+    {  Used to stop the animation }
+
+   ADTM_LOCATE           =  ($706);
+    {  Used to locate a frame in the animation (as set by a slider...) }
+
+{ ***************************************************************************}
+
+{  ADTM_LOADFRAME, ADTM_UNLOADFRAME }
+Type
+ padtFrame = ^tadtFrame;
+ tadtFrame = record
+    MethodID,
+    alf_TimeStamp,         {  Timestamp of frame to load }
+
+    {  The following fields are filled in by the ADTM_LOADFRAME method, }
+    {  and are read-only for any other methods. }
+
+    alf_Frame,                        {  Frame number }
+    alf_Duration  :  ULONG;           {  Duration of frame }
+
+    alf_BitMap    :  pBitMap;         {  Loaded BitMap }
+    alf_CMap      :  pColorMap;       {  Colormap, if changed }
+
+    alf_Sample    :  Pointer;         {  Sound data }
+    alf_SampleLength,
+    alf_Period    : ULONG;
+
+    alf_UserData  : Pointer;          {  Used by load frame for extra data }
+ end;
+
+{  ADTM_START, ADTM_PAUSE, ADTM_STOP, ADTM_LOCATE }
+ padtStart = ^tadtStart;
+ tadtStart = record
+    MethodID,
+    asa_Frame : ULONG;             {  Frame # to start at }
+ end;
+
+{ ***************************************************************************}
+
+VAR DataTypesBase : pLibrary;
+
+FUNCTION AddDTObject(win : pWindow; req : pRequester; o : pObject_; pos : LONGINT) : LONGINT;
+PROCEDURE DisposeDTObject(o : pObject_);
+FUNCTION DoAsyncLayout(o : pObject_; gpl : pgpLayout) : ULONG;
+FUNCTION DoDTMethodA(o : pObject_; win : pWindow; req : pRequester; msg : pLONGINT) : ULONG;
+FUNCTION GetDTAttrsA(o : pObject_; attrs : pTagItem) : ULONG;
+FUNCTION GetDTMethods(obj : pObject_) : Pointer;
+FUNCTION GetDTString(id : ULONG) : pCHAR;
+FUNCTION GetDTTriggerMethods(obj : pObject_) : pDTMethod;
+FUNCTION NewDTObjectA(name : POINTER; attrs : pTagItem): POINTER;
+FUNCTION ObtainDataTypeA(typ : ULONG; handle : POINTER; attrs : pTagItem) : pDataType;
+FUNCTION PrintDTObjectA(o : pObject_; w : pWindow; r : pRequester; msg : pdtPrint) : ULONG;
+PROCEDURE RefreshDTObjectA(o : pObject_; win : pWindow; req : pRequester; attrs : pTagItem);
+PROCEDURE ReleaseDataType(dt : pDataType);
+FUNCTION RemoveDTObject(win : pWindow; o : pObject_) : LONGINT;
+FUNCTION SetDTAttrsA(o : pObject_; win : pWindow; req : pRequester; attrs : pTagItem) : ULONG;
+
+IMPLEMENTATION
+
+FUNCTION AddDTObject(win : pWindow; req : pRequester; o : pObject_; pos : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L win,A0
+    MOVEA.L req,A1
+    MOVEA.L o,A2
+    MOVE.L  pos,D0
+    MOVEA.L DataTypesBase,A6
+    JSR -072(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE DisposeDTObject(o : pObject_);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L o,A0
+    MOVEA.L DataTypesBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION DoAsyncLayout(o : pObject_; gpl : pgpLayout) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L o,A0
+    MOVEA.L gpl,A1
+    MOVEA.L DataTypesBase,A6
+    JSR -084(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DoDTMethodA(o : pObject_; win : pWindow; req : pRequester; msg : pLONGINT) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L o,A0
+    MOVEA.L win,A1
+    MOVEA.L req,A2
+    MOVEA.L msg,A3
+    MOVEA.L DataTypesBase,A6
+    JSR -090(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetDTAttrsA(o : pObject_; attrs : pTagItem) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L o,A0
+    MOVEA.L attrs,A2
+    MOVEA.L DataTypesBase,A6
+    JSR -066(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetDTMethods(obj : pObject_) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L obj,A0
+    MOVEA.L DataTypesBase,A6
+    JSR -102(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetDTString(id : ULONG) : pCHAR;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  id,D0
+    MOVEA.L DataTypesBase,A6
+    JSR -138(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetDTTriggerMethods(obj : pObject_) : pDTMethod;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L obj,A0
+    MOVEA.L DataTypesBase,A6
+    JSR -108(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION NewDTObjectA(name : POINTER; attrs : pTagItem) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  name,D0
+    MOVEA.L attrs,A0
+    MOVEA.L DataTypesBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ObtainDataTypeA(typ : ULONG; handle : POINTER; attrs : pTagItem) : pDataType;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  typ,D0
+    MOVEA.L handle,A0
+    MOVEA.L attrs,A1
+    MOVEA.L DataTypesBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION PrintDTObjectA(o : pObject_; w : pWindow; r : pRequester; msg : pdtPrint) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L o,A0
+    MOVEA.L w,A1
+    MOVEA.L r,A2
+    MOVEA.L msg,A3
+    MOVEA.L DataTypesBase,A6
+    JSR -114(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE RefreshDTObjectA(o : pObject_; win : pWindow; req : pRequester; attrs : pTagItem);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L o,A0
+    MOVEA.L win,A1
+    MOVEA.L req,A2
+    MOVEA.L attrs,A3
+    MOVEA.L DataTypesBase,A6
+    JSR -078(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ReleaseDataType(dt : pDataType);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L dt,A0
+    MOVEA.L DataTypesBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION RemoveDTObject(win : pWindow; o : pObject_) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L win,A0
+    MOVEA.L o,A1
+    MOVEA.L DataTypesBase,A6
+    JSR -096(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetDTAttrsA(o : pObject_; win : pWindow; req : pRequester; attrs : pTagItem) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L o,A0
+    MOVEA.L win,A1
+    MOVEA.L req,A2
+    MOVEA.L attrs,A3
+    MOVEA.L DataTypesBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT DATATYPES *)
+
+
+
+

+ 192 - 0
packages/extra/amunits/units/diskfont.pas

@@ -0,0 +1,192 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit diskfont;
+
+INTERFACE
+
+uses exec, graphics;
+
+Const
+
+    MAXFONTPATH         = 256;
+
+Type
+
+    pFontContents = ^tFontContents;
+    tFontContents = record
+        fc_FileName     : Array [0..MAXFONTPATH-1] of Char;
+        fc_YSize        : Word;
+        fc_Style        : Byte;
+        fc_Flags        : Byte;
+    end;
+
+
+   pTFontContents = ^tTFontContents;
+   tTFontContents = record
+    tfc_FileName  : Array[0..MAXFONTPATH-3] of Char;
+    tfc_TagCount  : Word;
+
+    tfc_YSize     : Word;
+    tfc_Style,
+    tfc_Flags     : Byte;
+   END;
+
+
+Const
+
+    FCH_ID              = $0f00;
+    TFCH_ID             = $0f02;
+    OFCH_ID             = $0f03;
+
+
+
+Type
+
+    pFontContentsHeader = ^tFontContentsHeader;
+    tFontContentsHeader = record
+        fch_FileID      : Word;
+        fch_NumEntries  : Word;
+    end;
+
+Const
+
+    DFH_ID              = $0f80;
+    MAXFONTNAME         = 32;
+
+Type
+
+    pDiskFontHeader = ^tDiskFontHeader;
+    tDiskFontHeader = record
+        dfh_DF          : tNode;
+        dfh_FileID      : Word;
+        dfh_Revision    : Word;
+        dfh_Segment     : Longint;
+        dfh_Name        : Array [0..MAXFONTNAME-1] of Char;
+        dfh_TF          : tTextFont;
+    end;
+
+Const
+
+    AFB_MEMORY          = 0;
+    AFF_MEMORY          = 1;
+    AFB_DISK            = 1;
+    AFF_DISK            = 2;
+    AFB_SCALED          = 2;
+    AFF_SCALED          = $0004;
+    AFB_BITMAP          = 3;
+    AFF_BITMAP          = $0008;
+    AFB_TAGGED          = 16;
+    AFF_TAGGED          = $10000;
+
+
+Type
+
+    pAvailFonts = ^tAvailFonts;
+    tAvailFonts = record
+        af_Type         : Word;
+        af_Attr         : tTextAttr;
+    end;
+
+    pTAvailFonts = ^tTAvailFonts;
+    tTAvailFonts = record
+        taf_Type        : Word;
+        taf_Attr        : tTTextAttr;
+    END;
+
+    pAvailFontsHeader = ^tAvailFontsHeader;
+    tAvailFontsHeader = record
+        afh_NumEntries  : Word;
+    end;
+
+VAR DiskfontBase : pLibrary;
+
+FUNCTION AvailFonts(buffer : pCHAR; bufBytes : LONGINT; flags : LONGINT) : LONGINT;
+PROCEDURE DisposeFontContents(fontContentsHeader : pFontContentsHeader);
+FUNCTION NewFontContents(fontsLock : BPTR; fontName : pCHAR) : pFontContentsHeader;
+FUNCTION NewScaledDiskFont(sourceFont : pTextFont; destTextAttr : pTextAttr) : pDiskFontHeader;
+FUNCTION OpenDiskFont(textAttr : pTextAttr) : pTextFont;
+
+IMPLEMENTATION
+
+FUNCTION AvailFonts(buffer : pCHAR; bufBytes : LONGINT; flags : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L buffer,A0
+    MOVE.L  bufBytes,D0
+    MOVE.L  flags,D1
+    MOVEA.L DiskfontBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE DisposeFontContents(fontContentsHeader : pFontContentsHeader);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L fontContentsHeader,A1
+    MOVEA.L DiskfontBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION NewFontContents(fontsLock : BPTR; fontName : pCHAR) : pFontContentsHeader;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L fontsLock,A0
+    MOVEA.L fontName,A1
+    MOVEA.L DiskfontBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION NewScaledDiskFont(sourceFont : pTextFont; destTextAttr : pTextAttr) : pDiskFontHeader;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L sourceFont,A0
+    MOVEA.L destTextAttr,A1
+    MOVEA.L DiskfontBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION OpenDiskFont(textAttr : pTextAttr) : pTextFont;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L textAttr,A0
+    MOVEA.L DiskfontBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT DISKFONT *)
+
+
+
+

+ 318 - 0
packages/extra/amunits/units/expansion.pas

@@ -0,0 +1,318 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+UNIT expansion;
+
+INTERFACE
+USES exec, configvars, amigados;
+
+Const
+    EXPANSIONNAME       : PChar = 'expansion.library';
+
+{ flags for the AddDosNode() call }
+    ADNB_STARTPROC      = 0;
+
+    ADNF_STARTPROC      = 1;
+
+VAR ExpansionBase : pLibrary;
+
+FUNCTION AddBootNode(bootPri : LONGINT; flags : ULONG; deviceNode : pDeviceNode; configDev : pConfigDev) : BOOLEAN;
+PROCEDURE AddConfigDev(configDev : pConfigDev);
+FUNCTION AddDosNode(bootPri : LONGINT; flags : ULONG; deviceNode : pDeviceNode) : BOOLEAN;
+PROCEDURE AllocBoardMem(slotSpec : ULONG);
+FUNCTION AllocConfigDev : pConfigDev;
+FUNCTION AllocExpansionMem(numSlots : ULONG; slotAlign : ULONG) : POINTER;
+PROCEDURE ConfigBoard(board : POINTER; configDev : pConfigDev);
+PROCEDURE ConfigChain(baseAddr : POINTER);
+FUNCTION FindConfigDev(oldConfigDev : pConfigDev; manufacturer : LONGINT; product : LONGINT) : pConfigDev;
+PROCEDURE FreeBoardMem(startSlot : ULONG; slotSpec : ULONG);
+PROCEDURE FreeConfigDev(configDev : pConfigDev);
+PROCEDURE FreeExpansionMem(startSlot : ULONG; numSlots : ULONG);
+FUNCTION GetCurrentBinding(currentBinding : pCurrentBinding; bindingSize : ULONG) : ULONG;
+FUNCTION MakeDosNode(parmPacket : POINTER) : pDeviceNode;
+PROCEDURE ObtainConfigBinding;
+FUNCTION ReadExpansionByte(board : POINTER; offset : ULONG) : BYTE;
+PROCEDURE ReadExpansionRom(board : POINTER; configDev : pConfigDev);
+PROCEDURE ReleaseConfigBinding;
+PROCEDURE RemConfigDev(configDev : pConfigDev);
+PROCEDURE SetCurrentBinding(currentBinding : pCurrentBinding; bindingSize : ULONG);
+PROCEDURE WriteExpansionByte(board : POINTER; offset : ULONG; byte : ULONG);
+
+IMPLEMENTATION
+
+FUNCTION AddBootNode(bootPri : LONGINT; flags : ULONG; deviceNode : pDeviceNode; configDev : pConfigDev) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  bootPri,D0
+    MOVE.L  flags,D1
+    MOVEA.L deviceNode,A0
+    MOVEA.L configDev,A1
+    MOVEA.L ExpansionBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE AddConfigDev(configDev : pConfigDev);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L configDev,A0
+    MOVEA.L ExpansionBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION AddDosNode(bootPri : LONGINT; flags : ULONG; deviceNode : pDeviceNode) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  bootPri,D0
+    MOVE.L  flags,D1
+    MOVEA.L deviceNode,A0
+    MOVEA.L ExpansionBase,A6
+    JSR -150(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE AllocBoardMem(slotSpec : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  slotSpec,D0
+    MOVEA.L ExpansionBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION AllocConfigDev : pConfigDev;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L ExpansionBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AllocExpansionMem(numSlots : ULONG; slotAlign : ULONG) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  numSlots,D0
+    MOVE.L  slotAlign,D1
+    MOVEA.L ExpansionBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ConfigBoard(board : POINTER; configDev : pConfigDev);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L board,A0
+    MOVEA.L configDev,A1
+    MOVEA.L ExpansionBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ConfigChain(baseAddr : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L baseAddr,A0
+    MOVEA.L ExpansionBase,A6
+    JSR -066(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION FindConfigDev(oldConfigDev : pConfigDev; manufacturer : LONGINT; product : LONGINT) : pConfigDev;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L oldConfigDev,A0
+    MOVE.L  manufacturer,D0
+    MOVE.L  product,D1
+    MOVEA.L ExpansionBase,A6
+    JSR -072(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE FreeBoardMem(startSlot : ULONG; slotSpec : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  startSlot,D0
+    MOVE.L  slotSpec,D1
+    MOVEA.L ExpansionBase,A6
+    JSR -078(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeConfigDev(configDev : pConfigDev);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L configDev,A0
+    MOVEA.L ExpansionBase,A6
+    JSR -084(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeExpansionMem(startSlot : ULONG; numSlots : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  startSlot,D0
+    MOVE.L  numSlots,D1
+    MOVEA.L ExpansionBase,A6
+    JSR -090(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION GetCurrentBinding(currentBinding : pCurrentBinding; bindingSize : ULONG) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L currentBinding,A0
+    MOVE.L  bindingSize,D0
+    MOVEA.L ExpansionBase,A6
+    JSR -138(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION MakeDosNode(parmPacket : POINTER) : pDeviceNode;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L parmPacket,A0
+    MOVEA.L ExpansionBase,A6
+    JSR -144(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ObtainConfigBinding;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L ExpansionBase,A6
+    JSR -120(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION ReadExpansionByte(board : POINTER; offset : ULONG) : BYTE;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L board,A0
+    MOVE.L  offset,D0
+    MOVEA.L ExpansionBase,A6
+    JSR -096(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ReadExpansionRom(board : POINTER; configDev : pConfigDev);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L board,A0
+    MOVEA.L configDev,A1
+    MOVEA.L ExpansionBase,A6
+    JSR -102(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ReleaseConfigBinding;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L ExpansionBase,A6
+    JSR -126(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE RemConfigDev(configDev : pConfigDev);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L configDev,A0
+    MOVEA.L ExpansionBase,A6
+    JSR -108(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SetCurrentBinding(currentBinding : pCurrentBinding; bindingSize : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L currentBinding,A0
+    MOVE.L  bindingSize,D0
+    MOVEA.L ExpansionBase,A6
+    JSR -132(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE WriteExpansionByte(board : POINTER; offset : ULONG; byte : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L board,A0
+    MOVE.L  offset,D0
+    MOVE.L  byte,D1
+    MOVEA.L ExpansionBase,A6
+    JSR -114(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+END. (* UNIT EXPANSION *)
+
+
+

+ 94 - 0
packages/extra/amunits/units/expansionbase.pas

@@ -0,0 +1,94 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+unit expansionbase;
+
+INTERFACE
+
+uses exec, configvars;
+
+Const
+
+    TOTALSLOTS  = 256;
+
+Type
+
+{ BootNodes are scanned by dos.library at startup.  Items found on the
+   list are started by dos. BootNodes are added with the AddDosNode() or
+   the V36 AddBootNode() calls. }
+
+   pBootNode = ^tBootNode;
+   tBootNode = record
+    bn_Node     : tNode;
+    bn_Flags    : Word;
+    bn_DeviceNode  : Pointer;
+   END;
+
+    pExpansionBase = ^tExpansionBase;
+    tExpansionBase = record
+        LibNode         : tLibrary;
+        Flags           : Byte;
+        eb_Private01    : Byte;
+        eb_Private02    : ULONG;
+        eb_Private02    : ULONG;
+        eb_Private04    : tCurrentBinding;
+        eb_Private05    : tList;
+        MountList       : tList;
+        { private }
+    end;
+
+CONST
+{ error codes }
+     EE_OK          = 0 ;
+     EE_LASTBOARD   = 40;  { could not shut him up }
+     EE_NOEXPANSION = 41;  { not enough expansion mem; board shut up }
+     EE_NOMEMORY    = 42;  { not enough normal memory }
+     EE_NOBOARD     = 43;  { no board at that address }
+     EE_BADMEM      = 44;  { tried to add bad memory card }
+
+{ Flags }
+     EBB_CLOGGED    = 0;       { someone could not be shutup }
+     EBF_CLOGGED    = 1;
+     EBB_SHORTMEM   = 1;       { ran out of expansion mem }
+     EBF_SHORTMEM   = 2;
+     EBB_BADMEM     = 2;       { tried to add bad memory card }
+     EBF_BADMEM     = 4;
+     EBB_DOSFLAG    = 3;       { reserved for use by AmigaDOS }
+     EBF_DOSFLAG    = 8;
+     EBB_KICKBACK33 = 4;       { reserved for use by AmigaDOS }
+     EBF_KICKBACK33 = 16;
+     EBB_KICKBACK36 = 5;       { reserved for use by AmigaDOS }
+     EBF_KICKBACK36 = 32;
+{ If the following flag is set by a floppy's bootblock code, the initial
+   open of the initial shell window will be delayed until the first output
+   to that shell.  Otherwise the 1.3 compatible behavior applies. }
+     EBB_SILENTSTART = 6;
+     EBF_SILENTSTART = 64;
+
+{ Magic kludge for CC0 use }
+    EBB_START_CC0    = 7;
+    EBF_START_CC0    = 128;
+
+IMPLEMENTATION
+
+end.
+
+
+
+
+
+

+ 710 - 0
packages/extra/amunits/units/gadtools.pas

@@ -0,0 +1,710 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit gadtools;
+
+INTERFACE
+
+uses exec, intuition, graphics, utility;
+
+
+{------------------------------------------------------------------------}
+
+{  The kinds (almost classes) of gadgets in the toolkit.  Use these
+    identifiers when calling CreateGadgetA() }
+
+CONST
+ GENERIC_KIND  =  0;
+ BUTTON_KIND   =  1;
+ CHECKBOX_KIND =  2;
+ INTEGER_KIND  =  3;
+ LISTVIEW_KIND =  4;
+ MX_KIND       =  5;
+ NUMBER_KIND   =  6;
+ CYCLE_KIND    =  7;
+ PALETTE_KIND  =  8;
+ SCROLLER_KIND =  9;
+{ Kind number 10 is reserved }
+ SLIDER_KIND   =  11;
+ STRING_KIND   =  12;
+ TEXT_KIND     =  13;
+
+ NUM_KINDS     =  14;
+
+ GADTOOLSNAME   : PChar = 'gadtools.library';
+
+
+{------------------------------------------------------------------------}
+
+{  'Or' the appropriate set together for your Window IDCMPFlags: }
+
+ ARROWIDCMP    =  (IDCMP_GADGETUP + IDCMP_GADGETDOWN +
+                   IDCMP_INTUITICKS + IDCMP_MOUSEBUTTONS);
+
+ BUTTONIDCMP   =  (IDCMP_GADGETUP);
+ CHECKBOXIDCMP =  (IDCMP_GADGETUP);
+ INTEGERIDCMP  =  (IDCMP_GADGETUP);
+ LISTVIEWIDCMP =  (IDCMP_GADGETUP + IDCMP_GADGETDOWN +
+                   IDCMP_MOUSEMOVE + ARROWIDCMP);
+
+ MXIDCMP       =  (IDCMP_GADGETDOWN);
+ NUMBERIDCMP   =  0;
+ CYCLEIDCMP    =  (IDCMP_GADGETUP);
+ PALETTEIDCMP  =  (IDCMP_GADGETUP);
+
+{  Use ARROWIDCMP+SCROLLERIDCMP if your scrollers have arrows: }
+ SCROLLERIDCMP =  (IDCMP_GADGETUP + IDCMP_GADGETDOWN + IDCMP_MOUSEMOVE);
+ SLIDERIDCMP   =  (IDCMP_GADGETUP + IDCMP_GADGETDOWN + IDCMP_MOUSEMOVE);
+ STRINGIDCMP   =  (IDCMP_GADGETUP);
+
+ TEXTIDCMP     =  0;
+
+
+{------------------------------------------------------------------------}
+
+{  Generic NewGadget used by several of the gadget classes: }
+
+Type
+   pNewGadget = ^tNewGadget;
+   tNewGadget = record
+    ng_LeftEdge, ng_TopEdge : Integer;     {  gadget position }
+    ng_Width, ng_Height     : Integer;     {  gadget size }
+    ng_GadgetText           : STRPTR;      {  gadget label }
+    ng_TextAttr             : pTextAttr;   {  desired font for gadget label }
+    ng_GadgetID             : Word;        {  gadget ID }
+    ng_Flags                : ULONG;       {  see below }
+    ng_VisualInfo           : Pointer;     {  Set to retval of GetVisualInfo() }
+    ng_UserData             : Pointer;     {  gadget UserData }
+   END;
+
+
+{  ng_Flags control certain aspects of the gadget.  The first five control
+    the placement of the descriptive text.  All larger groups supply a
+    default: }
+
+CONST
+ PLACETEXT_LEFT  = $0001;  { Right-align text on left side }
+ PLACETEXT_RIGHT = $0002;  { Left-align text on right side }
+ PLACETEXT_ABOVE = $0004;  { Center text above }
+ PLACETEXT_BELOW = $0008;  { Center text below }
+ PLACETEXT_IN    = $0010;  { Center text on }
+
+ NG_HIGHLABEL    = $0020;  { Highlight the label }
+
+{------------------------------------------------------------------------}
+
+{ Fill out an array of these and pass that to CreateMenus(): }
+
+Type
+   pNewMenu = ^tNewMenu;
+   tNewMenu = record
+    nm_Type           : Byte;              {  See below }
+    nm_Label          : STRPTR;            {  Menu's label }
+    nm_CommKey        : STRPTR;            {  MenuItem Command Key Equiv }
+    nm_Flags          : Word;              {  Menu OR MenuItem flags (see note) }
+    nm_MutualExclude  : Longint;           {  MenuItem MutualExclude word }
+    nm_UserData       : Pointer;           {  For your own use, see note }
+   END;
+
+const
+{ Needed only by inside IM_ definitions below }
+ MENU_IMAGE     = 128;
+
+{ nm_Type determines what each NewMenu structure corresponds to.
+ * for the NM_TITLE, NM_ITEM, and NM_SUB values, nm_Label should
+ * be a text string to use for that menu title, item, or sub-item.
+ * For IM_ITEM or IM_SUB, set nm_Label to point at the Image structure
+ * you wish to use for this item or sub-item.
+ * NOTE: At present, you may only use conventional images.
+ * Custom images created from Intuition image-classes do not work.
+ }
+ NM_TITLE      =  1;       { Menu header }
+ NM_ITEM       =  2;       { Textual menu item }
+ NM_SUB        =  3;       { Textual menu sub-item }
+
+ IM_ITEM       =  (NM_ITEM OR MENU_IMAGE);    { Graphical menu item }
+ IM_SUB        =  (NM_SUB OR MENU_IMAGE);     { Graphical menu sub-item }
+
+{ The NewMenu array should be terminated with a NewMenu whose
+ * nm_Type equals NM_END.
+ }
+ NM_END        =  0;       { End of NewMenu array }
+
+{ Starting with V39, GadTools will skip any NewMenu entries whose
+ * nm_Type field has the NM_IGNORE bit set.
+ }
+ NM_IGNORE     =  64;
+
+
+{ nm_Label should be a text string for textual items, a pointer
+ * to an Image structure for graphical menu items, or the special
+ * constant NM_BARLABEL, to get a separator bar.
+ }
+ NM_BARLABEL   = -1;
+
+{ The nm_Flags field is used to fill out either the Menu->Flags or
+ * MenuItem->Flags field.  Note that the sense of the MENUENABLED or
+ * ITEMENABLED bit is inverted between this use and Intuition's use,
+ * in other words, NewMenus are enabled by default.  The following
+ * labels are provided to disable them:
+ }
+ NM_MENUDISABLED = MENUENABLED;
+ NM_ITEMDISABLED = ITEMENABLED;
+
+{ New for V39:  NM_COMMANDSTRING.  For a textual MenuItem or SubItem,
+ * point nm_CommKey at an arbitrary string, and set the NM_COMMANDSTRING
+ * flag.
+ }
+ NM_COMMANDSTRING = COMMSEQ;
+
+{ The following are pre-cleared (COMMSEQ, ITEMTEXT, and HIGHxxx are set
+ * later as appropriate):
+ * Under V39, the COMMSEQ flag bit is not cleared, since it now has
+ * meaning.
+ }
+ NM_FLAGMASK    = NOT (COMMSEQ OR ITEMTEXT OR HIGHFLAGS);
+ NM_FLAGMASK_V39 = NOT (ITEMTEXT OR HIGHFLAGS);
+
+{ You may choose among CHECKIT, MENUTOGGLE, and CHECKED.
+ * Toggle-select menuitems are of type CHECKIT|MENUTOGGLE, along
+ * with CHECKED if currently selected.  Mutually exclusive ones
+ * are of type CHECKIT, and possibly CHECKED too.  The nm_MutualExclude
+ * is a bit-wise representation of the items excluded by this one,
+ * so in the simplest case (choose 1 among n), these flags would be
+ * ~1, ~2, ~4, ~8, ~16, etc.  See the Intuition Menus chapter.
+ }
+
+{ A UserData pointer can be associated with each Menu and MenuItem structure.
+ * The CreateMenus() call allocates space for a UserData after each
+ * Menu or MenuItem (header, item or sub-item).  You should use the
+ * GTMENU_USERDATA() or GTMENUITEM_USERDATA() macro to extract it.
+ }
+
+const
+{ These return codes can be obtained through the GTMN_SecondaryError tag }
+ GTMENU_TRIMMED = $00000001;      { Too many menus, items, or subitems,
+                                         * menu has been trimmed down
+                                         }
+ GTMENU_INVALID = $00000002;      { Invalid NewMenu array }
+ GTMENU_NOMEM   = $00000003;      { Out of memory }
+
+{------------------------------------------------------------------------}
+
+{ Starting with V39, checkboxes and mx gadgets can be scaled to your
+ * specified gadget width/height.  Use the new GTCB_Scaled or GTMX_Scaled
+ * tags, respectively.  Under V37, and by default in V39, the imagery
+ * is of the following fixed size:
+ }
+
+{ MX gadget default dimensions: }
+ MX_WIDTH      =  17;
+ MX_HEIGHT     =  9;
+
+{ Checkbox default dimensions: }
+ CHECKBOX_WIDTH  = 26;
+ CHECKBOX_HEIGHT = 11;
+
+{------------------------------------------------------------------------}
+
+
+{------------------------------------------------------------------------}
+
+{  Tags for GadTools functions: }
+CONST
+ GT_TagBase        =   TAG_USER + $80000;
+
+ GTVI_NewWindow    =   GT_TagBase+1;  { Unused }
+ GTVI_NWTags       =   GT_TagBase+2;  { Unused }
+
+ GT_Private0       =   GT_TagBase+3;  { (private) }
+
+ GTCB_Checked      =   GT_TagBase+4;  { State of checkbox }
+
+ GTLV_Top          =   GT_TagBase+5;  { Top visible one in listview }
+ GTLV_Labels       =   GT_TagBase+6;  { List to display in listview }
+ GTLV_ReadOnly     =   GT_TagBase+7;  { TRUE IF listview is to be
+                                              read-only }
+ GTLV_ScrollWidth  =   GT_TagBase+8;  { Width of scrollbar }
+
+ GTMX_Labels       =   GT_TagBase+9;  { NULL-terminated array of labels }
+ GTMX_Active       =   GT_TagBase+10; { Active one in mx gadget }
+
+ GTTX_Text         =   GT_TagBase+11; { Text to display }
+ GTTX_CopyText     =   GT_TagBase+12; { Copy text label instead of
+                                              referencing it }
+
+ GTNM_Number       =   GT_TagBase+13; { Number to display }
+
+ GTCY_Labels       =   GT_TagBase+14; { NULL-terminated array of labels }
+ GTCY_Active       =   GT_TagBase+15; { The active one in the cycle gad }
+
+ GTPA_Depth        =   GT_TagBase+16; { Number of bitplanes in palette }
+ GTPA_Color        =   GT_TagBase+17; { Palette color }
+ GTPA_ColorOffset  =   GT_TagBase+18; { First color to use in palette }
+ GTPA_IndicatorWidth = GT_TagBase+19; { Width of current-color indicator }
+ GTPA_IndicatorHeight = GT_TagBase+20; { Height of current-color indicator }
+
+ GTSC_Top          =   GT_TagBase+21; { Top visible in scroller }
+ GTSC_Total        =   GT_TagBase+22; { Total in scroller area }
+ GTSC_Visible      =   GT_TagBase+23; { Number visible in scroller }
+ GTSC_Overlap      =   GT_TagBase+24; { Unused }
+
+{  GT_TagBase+25 through GT_TagBase+37 are reserved }
+
+ GTSL_Min          =   GT_TagBase+38; { Slider min value }
+ GTSL_Max          =   GT_TagBase+39; { Slider max value }
+ GTSL_Level        =   GT_TagBase+40; { Slider level }
+ GTSL_MaxLevelLen  =   GT_TagBase+41; { Max length of printed level }
+ GTSL_LevelFormat  =   GT_TagBase+42; { Format string for level }
+ GTSL_LevelPlace   =   GT_TagBase+43; { Where level should be placed }
+ GTSL_DispFunc     =   GT_TagBase+44; { Callback for number calculation
+                                              before display }
+
+ GTST_String       =   GT_TagBase+45; { String gadget's displayed string }
+ GTST_MaxChars     =   GT_TagBase+46; { Max length of string }
+
+ GTIN_Number       =   GT_TagBase+47; { Number in integer gadget }
+ GTIN_MaxChars     =   GT_TagBase+48; { Max number of digits }
+
+ GTMN_TextAttr     =   GT_TagBase+49; { MenuItem font TextAttr }
+ GTMN_FrontPen     =   GT_TagBase+50; { MenuItem text pen color }
+
+ GTBB_Recessed     =   GT_TagBase+51; { Make BevelBox recessed }
+
+ GT_VisualInfo     =   GT_TagBase+52; { result of VisualInfo call }
+
+ GTLV_ShowSelected =   GT_TagBase+53; { show selected entry beneath
+                listview, set tag data = NULL for display-only, or pointer
+                to a string gadget you've created }
+ GTLV_Selected     =   GT_TagBase+54; { Set ordinal number of selected
+                                              entry in the list }
+ GT_Reserved0      =   GT_TagBase+55; { Reserved }
+ GT_Reserved1      =   GT_TagBase+56; { Reserved for future use }
+
+ GTTX_Border       =   GT_TagBase+57; { Put a border around
+                                              Text-display gadgets }
+ GTNM_Border       =   GT_TagBase+58; { Put a border around
+                                              Number-display gadgets }
+
+ GTSC_Arrows       =   GT_TagBase+59; { Specify size of arrows for
+                                              scroller }
+
+ GTMN_Menu         =   GT_TagBase+60; { Pointer to Menu for use by
+                                              LayoutMenuItems() }
+ GTMX_Spacing      =   GT_TagBase+61; { Added to font height to
+                figure spacing between mx choices.  Use this instead
+                of LAYOUTA_SPACING for mx gadgets. }
+
+{ New to V37 GadTools.  Ignored by GadTools V36 }
+ GTMN_FullMenu     =   GT_TagBase+62; { Asks CreateMenus() to
+                validate that this is a complete menu structure }
+ GTMN_SecondaryError =  GT_TagBase+63; { ti_Data is a pointer
+                to a ULONG to receive error reports from CreateMenus() }
+ GT_Underscore     =   GT_TagBase+64; { ti_Data points to the symbol
+                that preceeds the character you'd like to underline in a
+                gadget label }
+
+{ New to V39 GadTools.  Ignored by GadTools V36 and V37 }
+ GTMN_Checkmark     =  GT_TagBase+65; { ti_Data is checkmark img to use }
+ GTMN_AmigaKey      =  GT_TagBase+66; { ti_Data is Amiga-key img to use }
+ GTMN_NewLookMenus  =  GT_TagBase+67; { ti_Data is boolean }
+
+{ New to V39 GadTools.  Ignored by GadTools V36 and V37.
+ * Set to TRUE if you want the checkbox or mx image scaled to
+ * the gadget width/height you specify.  Defaults to FALSE,
+ * for compatibility.
+ }
+ GTCB_Scaled         = GT_TagBase+68; { ti_Data is boolean }
+ GTMX_Scaled         = GT_TagBase+69; { ti_Data is boolean }
+
+ GTPA_NumColors      = GT_TagBase+70; { Number of colors in palette }
+
+ GTMX_TitlePlace     = GT_TagBase+71; { Where to put the title }
+
+ GTTX_FrontPen       = GT_TagBase+72; { Text color in TEXT_KIND gad }
+ GTTX_BackPen        = GT_TagBase+73; { Bgrnd color in TEXT_KIND gad }
+ GTTX_Justification  = GT_TagBase+74; { See GTJ_#? constants }
+
+ GTNM_FrontPen       = GT_TagBase+72; { Text color in NUMBER_KIND gad }
+ GTNM_BackPen        = GT_TagBase+73; { Bgrnd color in NUMBER_KIND gad }
+ GTNM_Justification  = GT_TagBase+74; { See GTJ_#? constants }
+ GTNM_Format         = GT_TagBase+75; { Formatting string for number }
+ GTNM_MaxNumberLen   = GT_TagBase+76; { Maximum length of number }
+
+ GTBB_FrameType      = GT_TagBase+77; { defines what kind of boxes
+                                            * DrawBevelBox() renders. See
+                                            * the BBFT_#? constants for
+                                            * possible values
+                                            }
+
+ GTLV_MakeVisible    = GT_TagBase+78; { Make this item visible }
+ GTLV_ItemHeight     = GT_TagBase+79; { Height of an individual item }
+
+ GTSL_MaxPixelLen    = GT_TagBase+80; { Max pixel size of level display }
+ GTSL_Justification  = GT_TagBase+81; { how should the level be displayed }
+
+ GTPA_ColorTable     = GT_TagBase+82; { colors to use in palette }
+
+ GTLV_CallBack       = GT_TagBase+83; { general-purpose listview call back }
+ GTLV_MaxPen         = GT_TagBase+84; { maximum pen number used by call back }
+
+ GTTX_Clipped        = GT_TagBase+85; { make a TEXT_KIND clip text }
+ GTNM_Clipped        = GT_TagBase+85; { make a NUMBER_KIND clip text }
+
+
+{------------------------------------------------------------------------}
+
+{ Justification types for GTTX_Justification and GTNM_Justification tags }
+ GTJ_LEFT   = 0;
+ GTJ_RIGHT  = 1;
+ GTJ_CENTER = 2;
+
+{------------------------------------------------------------------------}
+
+{ Bevel box frame types for GTBB_FrameType tag }
+ BBFT_BUTTON      = 1;  { Standard button gadget box }
+ BBFT_RIDGE       = 2;  { Standard string gadget box }
+ BBFT_ICONDROPBOX = 3;  { Standard icon drop box     }
+
+{------------------------------------------------------------------------}
+
+{ Typical suggested spacing between "elements": }
+ INTERWIDTH    =  8;
+ INTERHEIGHT   =  4;
+
+{------------------------------------------------------------------------}
+
+
+{  "NWay" is an old synonym for cycle gadgets }
+ NWAY_KIND    =   CYCLE_KIND;
+ NWAYIDCMP    =   CYCLEIDCMP;
+ GTNW_Labels  =   GTCY_Labels;
+ GTNW_Active  =   GTCY_Active;
+
+{------------------------------------------------------------------------}
+
+{ These two definitions are obsolete, but are here for backwards
+ * compatibility.  You never need to worry about these:
+ }
+ GADTOOLBIT    =  ($8000);
+{ Use this mask to isolate the user part: }
+ GADTOOLMASK   =  NOT (GADTOOLBIT);
+
+{------------------------------------------------------------------------}
+
+{ These definitions are for the GTLV_CallBack tag }
+
+{ The different types of messages that a listview callback hook can see }
+ LV_DRAW     =  $202;    { draw yourself, with state }
+
+{ Possible return values from a callback hook }
+ LVCB_OK      = 0;         { callback understands this message type    }
+ LVCB_UNKNOWN = 1;         { callback does not understand this message }
+
+{ states for LVDrawMsg.lvdm_State }
+ LVR_NORMAL           = 0; { the usual                 }
+ LVR_SELECTED         = 1; { for selected gadgets      }
+ LVR_NORMALDISABLED   = 2;         { for disabled gadgets      }
+ LVR_SELECTEDDISABLED = 8;         { disabled and selected     }
+
+Type
+{ structure of LV_DRAW messages, object is a (struct Node *) }
+ pLVDrawMsg = ^tLVDrawMsg;
+ tLVDrawMsg = record
+    lvdm_MethodID       : ULONG;       { LV_DRAW                   }
+    lvdm_RastPort       : pRastPort;   { where to render to        }
+    lvdm_DrawInfo       : pDrawInfo;   { useful to have around     }
+    lvdm_Bounds         : tRectangle;  { limits of where to render }
+    lvdm_State          : ULONG;     { how to render     }
+ end;
+
+
+VAR
+    GadToolsBase : pLibrary;
+
+FUNCTION CreateContext(glistptr : pGadget): pGadget;
+FUNCTION CreateGadgetA(kind : ULONG; gad : pGadget; ng : pNewGadget; taglist : pTagItem) : pGadget;
+FUNCTION CreateMenusA(newmenu : pNewMenu; taglist : pTagItem) : pMenu;
+PROCEDURE DrawBevelBoxA(rport : pRastPort; left : LONGINT; top : LONGINT; width : LONGINT; height : LONGINT; taglist : pTagItem);
+PROCEDURE FreeGadgets(gad : pGadget);
+PROCEDURE FreeMenus(menu : pMenu);
+PROCEDURE FreeVisualInfo(vi : POINTER);
+FUNCTION GetVisualInfoA(screen : pScreen; taglist : pTagItem) : POINTER;
+PROCEDURE GT_BeginRefresh(win : pWindow);
+PROCEDURE GT_EndRefresh(win : pWindow; complete : LONGINT);
+FUNCTION GT_FilterIMsg(imsg : pIntuiMessage) : pIntuiMessage;
+FUNCTION GT_GetGadgetAttrsA(gad : pGadget; win : pWindow; req : pRequester; taglist : pTagItem) : LONGINT;
+FUNCTION GT_GetIMsg(iport : pMsgPort) : pIntuiMessage;
+FUNCTION GT_PostFilterIMsg(imsg : pIntuiMessage) : pIntuiMessage;
+PROCEDURE GT_RefreshWindow(win : pWindow; req : pRequester);
+PROCEDURE GT_ReplyIMsg(imsg : pIntuiMessage);
+PROCEDURE GT_SetGadgetAttrsA(gad : pGadget; win : pWindow; req : pRequester; taglist : pTagItem);
+FUNCTION LayoutMenuItemsA(firstitem : pMenuItem; vi : POINTER; taglist : pTagItem) : BOOLEAN;
+FUNCTION LayoutMenusA(firstmenu : pMenu; vi : POINTER; taglist : pTagItem) : BOOLEAN;
+
+IMPLEMENTATION
+
+FUNCTION CreateContext(glistptr : pGadget): pGadget;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L glistptr,A0
+    MOVEA.L GadToolsBase,A6
+    JSR -114(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CreateGadgetA(kind : ULONG; gad : pGadget; ng : pNewGadget; taglist : pTagItem) : pGadget;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  kind,D0
+    MOVEA.L gad,A0
+    MOVEA.L ng,A1
+    MOVEA.L taglist,A2
+    MOVEA.L GadToolsBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CreateMenusA(newmenu : pNewMenu; taglist : pTagItem) : pMenu;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L newmenu,A0
+    MOVEA.L taglist,A1
+    MOVEA.L GadToolsBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE DrawBevelBoxA(rport : pRastPort; left : LONGINT; top : LONGINT; width : LONGINT; height : LONGINT; taglist : pTagItem);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rport,A0
+    MOVE.L  left,D0
+    MOVE.L  top,D1
+    MOVE.L  width,D2
+    MOVE.L  height,D3
+    MOVEA.L taglist,A1
+    MOVEA.L GadToolsBase,A6
+    JSR -120(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeGadgets(gad : pGadget);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L gad,A0
+    MOVEA.L GadToolsBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeMenus(menu : pMenu);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L menu,A0
+    MOVEA.L GadToolsBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeVisualInfo(vi : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vi,A0
+    MOVEA.L GadToolsBase,A6
+    JSR -132(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION GetVisualInfoA(screen : pScreen; taglist : pTagItem) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L screen,A0
+    MOVEA.L taglist,A1
+    MOVEA.L GadToolsBase,A6
+    JSR -126(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE GT_BeginRefresh(win : pWindow);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L win,A0
+    MOVEA.L GadToolsBase,A6
+    JSR -090(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE GT_EndRefresh(win : pWindow; complete : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L win,A0
+    MOVE.L  complete,D0
+    MOVEA.L GadToolsBase,A6
+    JSR -096(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION GT_FilterIMsg(imsg : pIntuiMessage) : pIntuiMessage;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L imsg,A1
+    MOVEA.L GadToolsBase,A6
+    JSR -102(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GT_GetGadgetAttrsA(gad : pGadget; win : pWindow; req : pRequester; taglist : pTagItem) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L gad,A0
+    MOVEA.L win,A1
+    MOVEA.L req,A2
+    MOVEA.L taglist,A3
+    MOVEA.L GadToolsBase,A6
+    JSR -174(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GT_GetIMsg(iport : pMsgPort) : pIntuiMessage;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iport,A0
+    MOVEA.L GadToolsBase,A6
+    JSR -072(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GT_PostFilterIMsg(imsg : pIntuiMessage) : pIntuiMessage;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L imsg,A1
+    MOVEA.L GadToolsBase,A6
+    JSR -108(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE GT_RefreshWindow(win : pWindow; req : pRequester);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L win,A0
+    MOVEA.L req,A1
+    MOVEA.L GadToolsBase,A6
+    JSR -084(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE GT_ReplyIMsg(imsg : pIntuiMessage);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L imsg,A1
+    MOVEA.L GadToolsBase,A6
+    JSR -078(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE GT_SetGadgetAttrsA(gad : pGadget; win : pWindow; req : pRequester; taglist : pTagItem);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L gad,A0
+    MOVEA.L win,A1
+    MOVEA.L req,A2
+    MOVEA.L taglist,A3
+    MOVEA.L GadToolsBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION LayoutMenuItemsA(firstitem : pMenuItem; vi : POINTER; taglist : pTagItem) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L firstitem,A0
+    MOVEA.L vi,A1
+    MOVEA.L taglist,A2
+    MOVEA.L GadToolsBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION LayoutMenusA(firstmenu : pMenu; vi : POINTER; taglist : pTagItem) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L firstmenu,A0
+    MOVEA.L vi,A1
+    MOVEA.L taglist,A2
+    MOVEA.L GadToolsBase,A6
+    JSR -066(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT GADTOOLS *)
+
+
+

+ 74 - 0
packages/extra/amunits/units/gameport.pas

@@ -0,0 +1,74 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit gameport;
+
+INTERFACE
+
+uses exec;
+
+const
+
+{*****   GamePort commands *****}
+
+    GPD_READEVENT       = CMD_NONSTD + 0;
+    GPD_ASKCTYPE        = CMD_NONSTD + 1;
+    GPD_SETCTYPE        = CMD_NONSTD + 2;
+    GPD_ASKTRIGGER      = CMD_NONSTD + 3;
+    GPD_SETTRIGGER      = CMD_NONSTD + 4;
+
+{*****   GamePort structures *****}
+
+{ gpt_Keys }
+
+    GPTB_DOWNKEYS       = 0;
+    GPTF_DOWNKEYS       = 1;
+    GPTB_UPKEYS         = 1;
+    GPTF_UPKEYS         = 2;
+
+type
+
+    pGamePortTrigger = ^tGamePortTrigger;
+    tGamePortTrigger = record
+        gpt_Keys        : Word;        { key transition triggers }
+        gpt_Timeout     : Word;        { time trigger (vertical blank units) }
+        gpt_XDelta      : Word;        { X distance trigger }
+        gpt_YDelta      : Word;        { Y distance trigger }
+    end;
+
+
+const
+
+{***** Controller Types *****}
+
+    GPCT_ALLOCATED      = -1;   { allocated by another user }
+    GPCT_NOCONTROLLER   = 0;
+
+    GPCT_MOUSE          = 1;
+    GPCT_RELJOYSTICK    = 2;
+    GPCT_ABSJOYSTICK    = 3;
+
+
+{***** Errors *****}
+
+    GPDERR_SETCTYPE     = 1;    { this controller not valid at this time }
+
+IMPLEMENTATION
+
+end.
+
+
+

+ 39 - 0
packages/extra/amunits/units/gradientslider.pas

@@ -0,0 +1,39 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit gradientslider;
+
+INTERFACE
+
+uses utility;
+
+
+Const
+    GRAD_Dummy       = (TAG_USER+$05000000);
+    GRAD_MaxVal      = (GRAD_Dummy+1);     {  max value of slider         }
+    GRAD_CurVal      = (GRAD_Dummy+2);     {  current value of slider     }
+    GRAD_SkipVal     = (GRAD_Dummy+3);     {  "body click" move amount    }
+    GRAD_KnobPixels  = (GRAD_Dummy+4);     {  size of knob in pixels      }
+    GRAD_PenArray    = (GRAD_Dummy+5);     {  pen colors                  }
+
+
+IMPLEMENTATION
+
+end.
+
+
+
+

+ 4637 - 0
packages/extra/amunits/units/graphics.pas

@@ -0,0 +1,4637 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit graphics;
+
+INTERFACE
+
+uses exec, hardware, utility;
+
+
+const
+
+    BITSET      = $8000;
+    BITCLR      = 0;
+
+type
+
+
+    pRectangle = ^tRectangle;
+    tRectangle = record
+        MinX,MinY       : Word;
+        MaxX,MaxY       : Word;
+    end;
+
+    pRect32 = ^tRect32;
+    tRect32 = record
+        MinX,MinY       : Longint;
+        MaxX,MaxY       : Longint;
+    end;
+
+    pPoint = ^tPoint;
+    tPoint = record
+        x,y     : Word;
+    end;
+
+    PLANEPTR = Pointer;
+
+    pBitMap = ^tBitMap;
+    tBitMap = record
+        BytesPerRow     : Word;
+        Rows            : Word;
+        Flags           : Byte;
+        Depth           : Byte;
+        pad             : Word;
+        Planes          : Array [0..7] of PLANEPTR;
+    end;
+{* flags for AllocBitMap, etc. *}
+const
+     BMB_CLEAR       = 0;
+     BMB_DISPLAYABLE = 1;
+     BMB_INTERLEAVED = 2;
+     BMB_STANDARD    = 3;
+     BMB_MINPLANES   = 4;
+
+     BMF_CLEAR       = (1 shl BMB_CLEAR);
+     BMF_DISPLAYABLE = (1 shl BMB_DISPLAYABLE);
+     BMF_INTERLEAVED = (1 shl BMB_INTERLEAVED);
+     BMF_STANDARD    = (1 shl BMB_STANDARD);
+     BMF_MINPLANES   = (1 shl BMB_MINPLANES);
+
+{* the following are for GetBitMapAttr() *}
+     BMA_HEIGHT      = 0;
+     BMA_DEPTH       = 4;
+     BMA_WIDTH       = 8;
+     BMA_FLAGS       = 12;
+
+
+{ structures used by and constructed by windowlib.a }
+{ understood by rom software }
+type
+    pClipRect = ^tClipRect;
+    tClipRect = record
+        Next    : pClipRect;    { roms used to find next ClipRect }
+        prev    : pClipRect;    { ignored by roms, used by windowlib }
+        lobs    : Pointer;      { ignored by roms, used by windowlib (LayerPtr)}
+        BitMap  : pBitMap;
+        bounds  : tRectangle;    { set up by windowlib, used by roms }
+        _p1,
+        _p2     : Pointer;    { system reserved }
+        reserved : Longint;     { system use }
+        Flags   : Longint;      { only exists in layer allocation }
+    end;
+
+    pLayer = ^tLayer;
+    tLayer = record
+        front,
+        back            : pLayer;       { ignored by roms }
+        ClipRect        : pClipRect;  { read by roms to find first cliprect }
+        rp              : Pointer;      { (RastPortPtr) ignored by roms, I hope }
+        bounds          : tRectangle;    { ignored by roms }
+        reserved        : Array [0..3] of Byte;
+        priority        : Word;        { system use only }
+        Flags           : Word;        { obscured ?, Virtual BitMap? }
+        SuperBitMap     : pBitMap;
+        SuperClipRect   : pClipRect;  { super bitmap cliprects if
+                                                VBitMap != 0}
+                                        { else damage cliprect list for refresh }
+        Window          : Pointer;      { reserved for user interface use }
+        Scroll_X,
+        Scroll_Y        : Word;
+        cr,
+        cr2,
+        crnew           : pClipRect;  { used by dedice }
+        SuperSaveClipRects : pClipRect; { preallocated cr's }
+        cliprects      : pClipRect;  { system use during refresh }
+        LayerInfo       : Pointer;      { points to head of the list }
+        Lock            : tSignalSemaphore;
+        BackFill        : pHook;
+        reserved1       : ULONG;
+        ClipRegion      : Pointer;
+        saveClipRects   : Pointer;      { used to back out when in trouble}
+        Width,
+        Height          : Integer;
+        reserved2       : Array [0..17] of Byte;
+        { this must stay here }
+        DamageList      : Pointer;      { list of rectangles to refresh
+                                                through }
+    end;
+
+const
+
+{ internal cliprect flags }
+
+    CR_NEEDS_NO_CONCEALED_RASTERS       = 1;
+    CR_NEEDS_NO_LAYERBLIT_DAMAGE        = 2;
+
+
+{ defines for code values for getcode }
+
+    ISLESSX     = 1;
+    ISLESSY     = 2;
+    ISGRTRX     = 4;
+    ISGRTRY     = 8;
+
+
+{------ Font Styles ------------------------------------------------}
+
+    FS_NORMAL           = 0;    { normal text (no style bits set) }
+    FSB_EXTENDED        = 3;    { extended face (wider than normal) }
+    FSF_EXTENDED        = 8;
+    FSB_ITALIC          = 2;    { italic (slanted 1:2 right) }
+    FSF_ITALIC          = 4;
+    FSB_BOLD            = 1;    { bold face text (ORed w/ shifted) }
+    FSF_BOLD            = 2;
+    FSB_UNDERLINED      = 0;    { underlined (under baseline) }
+    FSF_UNDERLINED      = 1;
+
+    FSB_COLORFONT       = 6;       { this uses ColorTextFont structure }
+    FSF_COLORFONT       = $40;
+    FSB_TAGGED          = 7;       { the TextAttr is really an TTextAttr, }
+    FSF_TAGGED          = $80;
+
+
+{------ Font Flags -------------------------------------------------}
+    FPB_ROMFONT         = 0;    { font is in rom }
+    FPF_ROMFONT         = 1;
+    FPB_DISKFONT        = 1;    { font is from diskfont.library }
+    FPF_DISKFONT        = 2;
+    FPB_REVPATH         = 2;    { designed path is reversed (e.g. left) }
+    FPF_REVPATH         = 4;
+    FPB_TALLDOT         = 3;    { designed for hires non-interlaced }
+    FPF_TALLDOT         = 8;
+    FPB_WIDEDOT         = 4;    { designed for lores interlaced }
+    FPF_WIDEDOT         = 16;
+    FPB_PROPORTIONAL    = 5;    { character sizes can vary from nominal }
+    FPF_PROPORTIONAL    = 32;
+    FPB_DESIGNED        = 6;    { size is "designed", not constructed }
+    FPF_DESIGNED        = 64;
+    FPB_REMOVED         = 7;    { the font has been removed }
+    FPF_REMOVED         = 128;
+
+{***** TextAttr node, matches text attributes in RastPort *********}
+
+type
+
+    pTextAttr = ^tTextAttr;
+    tTextAttr = record
+        ta_Name : STRPTR;       { name of the font }
+        ta_YSize : Word;       { height of the font }
+        ta_Style : Byte;        { intrinsic font style }
+        ta_Flags : Byte;        { font preferences and flags }
+    end;
+
+    pTTextAttr = ^tTTextAttr;
+    tTTextAttr = record
+        tta_Name : STRPTR;       { name of the font }
+        tta_YSize : Word;       { height of the font }
+        tta_Style : Byte;        { intrinsic font style }
+        tta_Flags : Byte;        { font preferences AND flags }
+        tta_Tags  : pTagItem;     { extended attributes }
+    end;
+
+{***** Text Tags **************************************************}
+CONST
+  TA_DeviceDPI  =  (1+TAG_USER);    { Tag value is Point union: }
+                                        { Hi Longint XDPI, Lo Longint YDPI }
+
+  MAXFONTMATCHWEIGHT  =    32767;   { perfect match from WeighTAMatch }
+
+
+
+{***** TextFonts node *********************************************}
+Type
+
+    pTextFont = ^tTextFont;
+    tTextFont = record
+        tf_Message      : tMessage;      { reply message for font removal }
+                                        { font name in LN \    used in this }
+        tf_YSize        : Word;        { font height     |    order to best }
+        tf_Style        : Byte;         { font style      |    match a font }
+        tf_Flags        : Byte;         { preferences and flags /    request. }
+        tf_XSize        : Word;        { nominal font width }
+        tf_Baseline     : Word; { distance from the top of char to baseline }
+        tf_BoldSmear    : Word;        { smear to affect a bold enhancement }
+
+        tf_Accessors    : Word;        { access count }
+
+        tf_LoChar       : Byte;         { the first character described here }
+        tf_HiChar       : Byte;         { the last character described here }
+        tf_CharData     : Pointer;      { the bit character data }
+
+        tf_Modulo       : Word; { the row modulo for the strike font data }
+        tf_CharLoc      : Pointer; { ptr to location data for the strike font }
+                                        { 2 words: bit offset then size }
+        tf_CharSpace    : Pointer; { ptr to words of proportional spacing data }
+        tf_CharKern     : Pointer;      { ptr to words of kerning data }
+    end;
+
+
+{----- tfe_Flags0 (partial definition) ----------------------------}
+CONST
+ TE0B_NOREMFONT = 0;       { disallow RemFont for this font }
+ TE0F_NOREMFONT = $01;
+
+Type
+
+   pTextFontExtension = ^tTextFontExtension;
+   tTextFontExtension = record              { this structure is read-only }
+    tfe_MatchWord  : Word;                { a magic cookie for the extension }
+    tfe_Flags0     : Byte;                 { (system private flags) }
+    tfe_Flags1     : Byte;                 { (system private flags) }
+    tfe_BackPtr    : pTextFont;          { validation of compilation }
+    tfe_OrigReplyPort : pMsgPort;        { original value in tf_Extension }
+    tfe_Tags       : pTagItem;              { Text Tags for the font }
+    tfe_OFontPatchS,                       { (system private use) }
+    tfe_OFontPatchK : Pointer;             { (system private use) }
+    { this space is reserved for future expansion }
+   END;
+
+{***** ColorTextFont node *****************************************}
+{----- ctf_Flags --------------------------------------------------}
+CONST
+ CT_COLORMASK  =  $000F;  { mask to get to following color styles }
+ CT_COLORFONT  =  $0001;  { color map contains designer's colors }
+ CT_GREYFONT   =  $0002;  { color map describes even-stepped }
+                                { brightnesses from low to high }
+ CT_ANTIALIAS  =  $0004;  { zero background thru fully saturated char }
+
+ CTB_MAPCOLOR  =  0;      { map ctf_FgColor to the rp_FgPen IF it's }
+ CTF_MAPCOLOR  =  $0001;  { is a valid color within ctf_Low..ctf_High }
+
+{----- ColorFontColors --------------------------------------------}
+Type
+   pColorFontColors = ^tColorFontColors;
+   tColorFontColors = record
+    cfc_Reserved,                 { *must* be zero }
+    cfc_Count   : Word;          { number of entries in cfc_ColorTable }
+    cfc_ColorTable : Pointer;     { 4 bit per component color map packed xRGB }
+   END;
+
+{----- ColorTextFont ----------------------------------------------}
+
+   pColorTextFont = ^tColorTextFont;
+   tColorTextFont = record
+    ctf_TF      : tTextFont;
+    ctf_Flags   : Word;          { extended flags }
+    ctf_Depth,          { number of bit planes }
+    ctf_FgColor,        { color that is remapped to FgPen }
+    ctf_Low,            { lowest color represented here }
+    ctf_High,           { highest color represented here }
+    ctf_PlanePick,      { PlanePick ala Images }
+    ctf_PlaneOnOff : Byte;     { PlaneOnOff ala Images }
+    ctf_ColorFontColors : pColorFontColors; { colors for font }
+    ctf_CharData : Array[0..7] of APTR;    {pointers to bit planes ala tf_CharData }
+   END;
+
+{***** TextExtent node ********************************************}
+
+   pTextExtent = ^tTextExtent;
+   tTextExtent = record
+    te_Width,                   { same as TextLength }
+    te_Height : Word;          { same as tf_YSize }
+    te_Extent : tRectangle;      { relative to CP }
+   END;
+
+
+const
+
+    COPPER_MOVE = 0;    { pseude opcode for move #XXXX,dir }
+    COPPER_WAIT = 1;    { pseudo opcode for wait y,x }
+    CPRNXTBUF   = 2;    { continue processing with next buffer }
+    CPR_NT_LOF  = $8000; { copper instruction only for Longint frames }
+    CPR_NT_SHT  = $4000; { copper instruction only for long frames }
+    CPR_NT_SYS  = $2000; { copper user instruction only }
+type
+
+{ Note: The combination VWaitAddr and HWaitAddr replace a three way
+        union in C.  The three possibilities are:
+
+        nxtList : CopListPtr;  or
+
+        VWaitPos : Longint;
+        HWaitPos : Longint;  or
+
+        DestAddr : Longint;
+        DestData : Longint;
+}
+
+    pCopIns = ^tCopIns;
+    tCopIns = record
+        OpCode  : Integer; { 0 = move, 1 = wait }
+        VWaitAddr : Integer; { vertical or horizontal wait position }
+        HWaitData : Integer; { destination Pointer or data to send }
+    end;
+
+{ structure of cprlist that points to list that hardware actually executes }
+
+    pcprlist = ^tcprlist;
+    tcprlist = record
+        Next    : pcprlist;
+        start   : pInteger;       { start of copper list }
+        MaxCount : Integer;       { number of long instructions }
+    end;
+
+    pCopList = ^tCopList;
+    tCopList = record
+        Next    : pCopList;     { next block for this copper list }
+        CopList : pCopList;    { system use }
+        ViewPort : Pointer;    { system use }
+        CopIns  : pCopIns;    { start of this block }
+        CopPtr  : pCopIns;    { intermediate ptr }
+        CopLStart : pInteger;     { mrgcop fills this in for Long Frame}
+        CopSStart : pInteger;     { mrgcop fills this in for Longint Frame}
+        Count   : Integer;        { intermediate counter }
+        MaxCount : Integer;       { max # of copins for this block }
+        DyOffset : Integer;       { offset this copper list vertical waits }
+        SLRepeat : Word;
+        Flags    : Word;
+    end;
+
+    pUCopList = ^tUCopList;
+    tUCopList = record
+        Next    : pUCopList;
+        FirstCopList : pCopList;      { head node of this copper list }
+        CopList : pCopList;           { node in use }
+    end;
+
+    pcopinit = ^tcopinit;
+    tcopinit = record
+        vsync_hblank : array [0..1] of word;
+        diagstrt : Array [0..11] of word;
+        fm0      : array [0..1] of word;
+        diwstart : array [0..9] of word;
+        bplcon2  : array [0..1] of word;
+        sprfix   : array [0..(2*8)] of word;
+        sprstrtup : Array [0..(2*8*2)] of Word;
+        wait14    : array [0..1] of word;
+        norm_hblank : array [0..1] of word;
+        jump        : array [0..1] of word;
+        wait_forever : array [0..5] of word;
+        sprstop : Array [0..7] of Word;
+    end;
+
+
+
+    pAreaInfo = ^tAreaInfo;
+    tAreaInfo = record
+        VctrTbl : Pointer;      { ptr to start of vector table }
+        VctrPtr : Pointer;      { ptr to current vertex }
+        FlagTbl : Pointer;      { ptr to start of vector flag table }
+        FlagPtr : Pointer;      { ptrs to areafill flags }
+        Count   : Integer;        { number of vertices in list }
+        MaxCount : Integer;       { AreaMove/Draw will not allow Count>MaxCount}
+        FirstX,
+        FirstY  : Integer;        { first point for this polygon }
+    end;
+
+    pTmpRas = ^tTmpRas;
+    tTmpRas = record
+        RasPtr  : Pointer;
+        Size    : Longint;
+    end;
+
+{ unoptimized for 32bit alignment of pointers }
+
+    pGelsInfo = ^tGelsInfo;
+    tGelsInfo = record
+        sprRsrvd        : Shortint; { flag of which sprites to reserve from
+                                  vsprite system }
+        Flags   : Byte;       { system use }
+        gelHead,
+        gelTail : Pointer; { (VSpritePtr) dummy vSprites for list management}
+
+    { pointer to array of 8 WORDS for sprite available lines }
+
+        nextLine : Pointer;
+
+    { pointer to array of 8 pointers for color-last-assigned to vSprites }
+
+        lastColor : Pointer;
+        collHandler : Pointer;  { (collTablePtr) Pointeres of collision routines }
+        leftmost,
+        rightmost,
+        topmost,
+        bottommost      : Integer;
+        firstBlissObj,
+        lastBlissObj    : Pointer;    { system use only }
+    end;
+
+    pRastPort = ^tRastPort;
+    tRastPort = record
+        Layer           : pLayer;      { LayerPtr }
+        BitMap          : pBitMap;      { BitMapPtr }
+        AreaPtrn        : Pointer;      { ptr to areafill pattern }
+        TmpRas          : pTmpRas;
+        AreaInfo        : pAreaInfo;
+        GelsInfo        : pGelsInfo;
+        Mask            : Byte;         { write mask for this raster }
+        FgPen           : Shortint;         { foreground pen for this raster }
+        BgPen           : Shortint;         { background pen         }
+        AOlPen          : Shortint;         { areafill outline pen }
+        DrawMode        : Shortint; { drawing mode for fill, lines, and text }
+        AreaPtSz        : Shortint;         { 2^n words for areafill pattern }
+        linpatcnt       : Shortint; { current line drawing pattern preshift }
+        dummy           : Shortint;
+        Flags           : Word;        { miscellaneous control bits }
+        LinePtrn        : Word;        { 16 bits for textured lines }
+        cp_x,
+        cp_y            : Integer;        { current pen position }
+        minterms        : Array [0..7] of Byte;
+        PenWidth        : Integer;
+        PenHeight       : Integer;
+        Font            : pTextFont;      { (TextFontPtr) current font Pointer }
+        AlgoStyle       : Byte;         { the algorithmically generated style }
+        TxFlags         : Byte;         { text specific flags }
+        TxHeight        : Word;        { text height }
+        TxWidth         : Word;        { text nominal width }
+        TxBaseline      : Word;        { text baseline }
+        TxSpacing       : Integer;        { text spacing (per character) }
+        RP_User         : Pointer;
+        longreserved    : Array [0..1] of ULONG;
+        wordreserved    : Array [0..6] of Word;        { used to be a node }
+        reserved        : Array [0..7] of Byte;         { for future use }
+    end;
+
+const
+
+{ drawing modes }
+
+    JAM1        = 0;    { jam 1 color into raster }
+    JAM2        = 1;    { jam 2 colors into raster }
+    COMPLEMENT  = 2;    { XOR bits into raster }
+    INVERSVID   = 4;    { inverse video for drawing modes }
+
+{ these are the flag bits for RastPort flags }
+
+    FRST_DOT    = $01;  { draw the first dot of this line ? }
+    ONE_DOT     = $02;  { use one dot mode for drawing lines }
+    DBUFFER     = $04;  { flag set when RastPorts are double-buffered }
+
+             { only used for bobs }
+
+    AREAOUTLINE = $08;  { used by areafiller }
+    NOCROSSFILL = $20;  { areafills have no crossovers }
+
+{ there is only one style of clipping: raster clipping }
+{ this preserves the continuity of jaggies regardless of clip window }
+{ When drawing into a RastPort, if the ptr to ClipRect is nil then there }
+{ is no clipping done, this is dangerous but useful for speed }
+
+
+Const
+    CleanUp     = $40;
+    CleanMe     = CleanUp;
+
+    BltClearWait        = 1;    { Waits for blit to finish }
+    BltClearXY          = 2;    { Use Row/Bytes per row method }
+
+        { Useful minterms }
+
+    StraightCopy        = $C0;  { Vanilla copy }
+    InvertAndCopy       = $30;  { Invert the source before copy }
+    InvertDest          = $50;  { Forget source, invert dest }
+
+
+ {      mode coercion definitions }
+
+const
+{  These flags are passed (in combination) to CoerceMode() to determine the
+ * type of coercion required.
+ }
+
+{  Ensure that the mode coerced to can display just as many colours as the
+ * ViewPort being coerced.
+ }
+    PRESERVE_COLORS = 1;
+
+{  Ensure that the mode coerced to is not interlaced. }
+    AVOID_FLICKER   = 2;
+
+{  Coercion should ignore monitor compatibility issues. }
+    IGNORE_MCOMPAT  = 4;
+
+
+    BIDTAG_COERCE   = 1; {  Private }
+
+const
+
+{ VSprite flags }
+{ user-set VSprite flags: }
+
+    SUSERFLAGS  = $00FF;        { mask of all user-settable VSprite-flags }
+    VSPRITE_f   = $0001;        { set if VSprite, clear if Bob }
+                                { VSPRITE had to be changed for name conflict }
+    SAVEBACK    = $0002;        { set if background is to be saved/restored }
+    OVERLAY     = $0004;        { set to mask image of Bob onto background }
+    MUSTDRAW    = $0008;        { set if VSprite absolutely must be drawn }
+
+{ system-set VSprite flags: }
+
+    BACKSAVED   = $0100;        { this Bob's background has been saved }
+    BOBUPDATE   = $0200;        { temporary flag, useless to outside world }
+    GELGONE     = $0400;        { set if gel is completely clipped (offscreen) }
+    VSOVERFLOW  = $0800;        { VSprite overflow (if MUSTDRAW set we draw!) }
+
+{ Bob flags }
+{ these are the user flag bits }
+
+    BUSERFLAGS  = $00FF;        { mask of all user-settable Bob-flags }
+    SAVEBOB     = $0001;        { set to not erase Bob }
+    BOBISCOMP   = $0002;        { set to identify Bob as AnimComp }
+
+{ these are the system flag bits }
+
+    BWAITING    = $0100;        { set while Bob is waiting on 'after' }
+    BDRAWN      = $0200;        { set when Bob is drawn this DrawG pass}
+    BOBSAWAY    = $0400;        { set to initiate removal of Bob }
+    BOBNIX      = $0800;        { set when Bob is completely removed }
+    SAVEPRESERVE = $1000;       { for back-restore during double-buffer}
+    OUTSTEP     = $2000;        { for double-clearing if double-buffer }
+
+{ defines for the animation procedures }
+
+    ANFRACSIZE  = 6;
+    ANIMHALF    = $0020;
+    RINGTRIGGER = $0001;
+
+
+{ UserStuff definitions
+ *  the user can define these to be a single variable or a sub-structure
+ *  if undefined by the user, the system turns these into innocuous variables
+ *  see the manual for a thorough definition of the UserStuff definitions
+ *
+ }
+
+type
+
+    VUserStuff  = Integer;        { Sprite user stuff }
+    BUserStuff  = Integer;        { Bob user stuff }
+    AUserStuff  = Integer;        { AnimOb user stuff }
+
+{********************** GEL STRUCTURES **********************************}
+
+    pVSprite = ^tVSprite;
+    tVSprite = record
+
+{ --------------------- SYSTEM VARIABLES ------------------------------- }
+{ GEL linked list forward/backward pointers sorted by y,x value }
+
+        NextVSprite     : pVSprite;
+        PrevVSprite     : pVSprite;
+
+{ GEL draw list constructed in the order the Bobs are actually drawn, then
+ *  list is copied to clear list
+ *  must be here in VSprite for system boundary detection
+ }
+
+        DrawPath        : pVSprite;     { pointer of overlay drawing }
+        ClearPath       : pVSprite;     { pointer for overlay clearing }
+
+{ the VSprite positions are defined in (y,x) order to make sorting
+ *  sorting easier, since (y,x) as a long Longint
+ }
+
+        OldY, OldX      : Integer;        { previous position }
+
+{ --------------------- COMMON VARIABLES --------------------------------- }
+
+        Flags           : Integer;        { VSprite flags }
+
+
+{ --------------------- USER VARIABLES ----------------------------------- }
+{ the VSprite positions are defined in (y,x) order to make sorting
+ *  sorting easier, since (y,x) as a long Longint
+ }
+
+        Y, X            : Integer;        { screen position }
+
+        Height  : Integer;
+        Width   : Integer;        { number of words per row of image data }
+        Depth   : Integer;        { number of planes of data }
+
+        MeMask  : Integer;        { which types can collide with this VSprite}
+        HitMask : Integer;        { which types this VSprite can collide with}
+
+        ImageData       : Pointer;      { pointer to VSprite image }
+
+{ borderLine is the one-dimensional logical OR of all
+ *  the VSprite bits, used for fast collision detection of edge
+ }
+
+        BorderLine      : Pointer; { logical OR of all VSprite bits }
+        CollMask        : Pointer; { similar to above except this is a matrix }
+
+{ pointer to this VSprite's color definitions (not used by Bobs) }
+
+        SprColors       : Pointer;
+
+        VSBob   : Pointer;      { (BobPtr) points home if this VSprite
+                                   is part of a Bob }
+
+{ planePick flag:  set bit selects a plane from image, clear bit selects
+ *  use of shadow mask for that plane
+ * OnOff flag: if using shadow mask to fill plane, this bit (corresponding
+ *  to bit in planePick) describes whether to fill with 0's or 1's
+ * There are two uses for these flags:
+ *      - if this is the VSprite of a Bob, these flags describe how the Bob
+ *        is to be drawn into memory
+ *      - if this is a simple VSprite and the user intends on setting the
+ *        MUSTDRAW flag of the VSprite, these flags must be set too to describe
+ *        which color registers the user wants for the image
+ }
+
+        PlanePick       : Shortint;
+        PlaneOnOff      : Shortint;
+
+        VUserExt        : VUserStuff;   { user definable:  see note above }
+    end;
+
+
+
+
+{ dBufPacket defines the values needed to be saved across buffer to buffer
+ *  when in double-buffer mode
+ }
+
+    pDBufPacket = ^tDBufPacket;
+    tDBufPacket = record
+        BufY,
+        BufX    : Word;        { save other buffers screen coordinates }
+        BufPath : pVSprite;   { carry the draw path over the gap }
+
+{ these pointers must be filled in by the user }
+{ pointer to other buffer's background save buffer }
+
+        BufBuffer : Pointer;
+    end;
+
+
+
+
+
+    pBob = ^tBob;
+    tBob = record
+{ blitter-objects }
+
+{ --------------------- SYSTEM VARIABLES --------------------------------- }
+
+{ --------------------- COMMON VARIABLES --------------------------------- }
+
+        Flags   : Integer; { general purpose flags (see definitions below) }
+
+{ --------------------- USER VARIABLES ----------------------------------- }
+
+        SaveBuffer : Pointer;   { pointer to the buffer for background save }
+
+{ used by Bobs for "cookie-cutting" and multi-plane masking }
+
+        ImageShadow : Pointer;
+
+{ pointer to BOBs for sequenced drawing of Bobs
+ *  for correct overlaying of multiple component animations
+ }
+        Before  : pBob; { draw this Bob before Bob pointed to by before }
+        After   : pBob; { draw this Bob after Bob pointed to by after }
+
+        BobVSprite : pVSprite;        { this Bob's VSprite definition }
+
+        BobComp : Pointer; { (AnimCompPtr) pointer to this Bob's AnimComp def }
+
+        DBuffer : Pointer;        { pointer to this Bob's dBuf packet }
+
+        BUserExt : BUserStuff;  { Bob user extension }
+    end;
+
+    pAnimComp = ^tAnimComp;
+    tAnimComp = record
+
+{ --------------------- SYSTEM VARIABLES --------------------------------- }
+
+{ --------------------- COMMON VARIABLES --------------------------------- }
+
+        Flags   : Integer;        { AnimComp flags for system & user }
+
+{ timer defines how long to keep this component active:
+ *  if set non-zero, timer decrements to zero then switches to nextSeq
+ *  if set to zero, AnimComp never switches
+ }
+
+        Timer   : Integer;
+
+{ --------------------- USER VARIABLES ----------------------------------- }
+{ initial value for timer when the AnimComp is activated by the system }
+
+        TimeSet : Integer;
+
+{ pointer to next and previous components of animation object }
+
+        NextComp        : pAnimComp;
+        PrevComp        : pAnimComp;
+
+{ pointer to component component definition of next image in sequence }
+
+        NextSeq : pAnimComp;
+        PrevSeq : pAnimComp;
+
+        AnimCRoutine : Pointer; { Pointer of special animation procedure }
+
+        YTrans  : Integer; { initial y translation (if this is a component) }
+        XTrans  : Integer; { initial x translation (if this is a component) }
+
+        HeadOb  : Pointer; { AnimObPtr }
+
+        AnimBob : pBob;
+    end;
+
+    pAnimOb = ^tAnimOb;
+    tAnimOb = record
+
+{ --------------------- SYSTEM VARIABLES --------------------------------- }
+
+        NextOb,
+        PrevOb  : pAnimOb;
+
+{ number of calls to Animate this AnimOb has endured }
+
+        Clock   : Longint;
+
+        AnOldY,
+        AnOldX  : Integer;        { old y,x coordinates }
+
+{ --------------------- COMMON VARIABLES --------------------------------- }
+
+        AnY,
+        AnX     : Integer;        { y,x coordinates of the AnimOb }
+
+{ --------------------- USER VARIABLES ----------------------------------- }
+
+        YVel,
+        XVel    : Integer;        { velocities of this object }
+        YAccel,
+        XAccel  : Integer;        { accelerations of this object }
+
+        RingYTrans,
+        RingXTrans      : Integer;        { ring translation values }
+
+        AnimORoutine    : Pointer;      { Pointer of special animation
+                                          procedure }
+
+        HeadComp        : pAnimComp;  { pointer to first component }
+
+        AUserExt        : AUserStuff;       { AnimOb user extension }
+    end;
+
+    ppAnimOb = ^pAnimOb;
+
+
+{ ************************************************************************ }
+
+const
+
+    B2NORM      = 0;
+    B2SWAP      = 1;
+    B2BOBBER    = 2;
+
+{ ************************************************************************ }
+
+type
+
+{ a structure to contain the 16 collision procedure addresses }
+
+    collTable = Array [0..15] of Pointer;
+    pcollTable = ^collTable;
+
+const
+
+{   These bit descriptors are used by the GEL collide routines.
+ *  These bits are set in the hitMask and meMask variables of
+ *  a GEL to describe whether or not these types of collisions
+ *  can affect the GEL.  BNDRY_HIT is described further below;
+ *  this bit is permanently assigned as the boundary-hit flag.
+ *  The other bit GEL_HIT is meant only as a default to cover
+ *  any GEL hitting any other; the user may redefine this bit.
+ }
+
+    BORDERHIT   = 0;
+
+{   These bit descriptors are used by the GEL boundry hit routines.
+ *  When the user's boundry-hit routine is called (via the argument
+ *  set by a call to SetCollision) the first argument passed to
+ *  the user's routine is the Pointer of the GEL involved in the
+ *  boundry-hit, and the second argument has the appropriate bit(s)
+ *  set to describe which boundry was surpassed
+ }
+
+    TOPHIT      = 1;
+    BOTTOMHIT   = 2;
+    LEFTHIT     = 4;
+    RIGHTHIT    = 8;
+
+Type
+ pExtendedNode = ^tExtendedNode;
+ tExtendedNode = record
+  xln_Succ,
+  xln_Pred  : pNode;
+  xln_Type  : Byte;
+  xln_Pri   : Shortint;
+  xln_Name  : STRPTR;
+  xln_Subsystem : Byte;
+  xln_Subtype   : Byte;
+  xln_Library : Longint;
+  xln_Init : Pointer;
+ END;
+
+CONST
+ SS_GRAPHICS   =  $02;
+
+ VIEW_EXTRA_TYPE       =  1;
+ VIEWPORT_EXTRA_TYPE   =  2;
+ SPECIAL_MONITOR_TYPE  =  3;
+ MONITOR_SPEC_TYPE     =  4;
+
+type
+
+{ structure used by AddTOFTask }
+
+    pIsrvstr = ^tIsrvstr;
+    tIsrvstr = record
+        is_Node : tNode;
+        Iptr    : pIsrvstr;     { passed to srvr by os }
+        code    : Pointer;
+        ccode   : Pointer;
+        Carg    : Pointer;
+    end;
+
+Type
+ pAnalogSignalInterval = ^tAnalogSignalInterval;
+ tAnalogSignalInterval = record
+  asi_Start,
+  asi_Stop  : Word;
+ END;
+
+ pSpecialMonitor = ^tSpecialMonitor;
+ tSpecialMonitor = record
+  spm_Node      : tExtendedNode;
+  spm_Flags     : Word;
+  do_monitor,
+  reserved1,
+  reserved2,
+  reserved3     : Pointer;
+  hblank,
+  vblank,
+  hsync,
+  vsync : tAnalogSignalInterval;
+ END;
+
+
+ pMonitorSpec = ^tMonitorSpec;
+ tMonitorSpec = record
+    ms_Node     : tExtendedNode;
+    ms_Flags    : Word;
+    ratioh,
+    ratiov      : Longint;
+    total_rows,
+    total_colorclocks,
+    DeniseMaxDisplayColumn,
+    BeamCon0,
+    min_row     : Word;
+    ms_Special  : pSpecialMonitor;
+    ms_OpenCount : Word;
+    ms_transform,
+    ms_translate,
+    ms_scale    : Pointer;
+    ms_xoffset,
+    ms_yoffset  : Word;
+    ms_LegalView : tRectangle;
+    ms_maxoscan,       { maximum legal overscan }
+    ms_videoscan  : Pointer;      { video display overscan }
+    DeniseMinDisplayColumn : Word;
+    DisplayCompatible      : ULONG;
+    DisplayInfoDataBase    : tList;
+    DisplayInfoDataBaseSemaphore : tSignalSemaphore;
+    ms_MrgCop,
+    ms_LoadView,
+    ms_KillView  : Longint;
+ END;
+
+const
+  TO_MONITOR            =  0;
+  FROM_MONITOR          =  1;
+  STANDARD_XOFFSET      =  9;
+  STANDARD_YOFFSET      =  0;
+
+  MSB_REQUEST_NTSC      =  0;
+  MSB_REQUEST_PAL       =  1;
+  MSB_REQUEST_SPECIAL   =  2;
+  MSB_REQUEST_A2024     =  3;
+  MSB_DOUBLE_SPRITES    =  4;
+  MSF_REQUEST_NTSC      =  1;
+  MSF_REQUEST_PAL       =  2;
+  MSF_REQUEST_SPECIAL   =  4;
+  MSF_REQUEST_A2024     =  8;
+  MSF_DOUBLE_SPRITES    =  16;
+
+
+{ obsolete, v37 compatible definitions follow }
+  REQUEST_NTSC          =  1;
+  REQUEST_PAL           =  2;
+  REQUEST_SPECIAL       =  4;
+  REQUEST_A2024         =  8;
+
+  DEFAULT_MONITOR_NAME  : PChar =  'default.monitor';
+  NTSC_MONITOR_NAME     : PChar =  'ntsc.monitor';
+  PAL_MONITOR_NAME      : PChar =  'pal.monitor';
+  STANDARD_MONITOR_MASK =  ( REQUEST_NTSC OR REQUEST_PAL ) ;
+
+  STANDARD_NTSC_ROWS    =  262;
+  STANDARD_PAL_ROWS     =  312;
+  STANDARD_COLORCLOCKS  =  226;
+  STANDARD_DENISE_MAX   =  455;
+  STANDARD_DENISE_MIN   =  93 ;
+  STANDARD_NTSC_BEAMCON =  $0000;
+  STANDARD_PAL_BEAMCON  =  DISPLAYPAL ;
+
+  SPECIAL_BEAMCON       = ( VARVBLANK OR LOLDIS OR VARVSYNC OR VARHSYNC OR VARBEAM OR CSBLANK OR VSYNCTRUE);
+
+  MIN_NTSC_ROW    = 21   ;
+  MIN_PAL_ROW     = 29   ;
+  STANDARD_VIEW_X = $81  ;
+  STANDARD_VIEW_Y = $2C  ;
+  STANDARD_HBSTRT = $06  ;
+  STANDARD_HSSTRT = $0B  ;
+  STANDARD_HSSTOP = $1C  ;
+  STANDARD_HBSTOP = $2C  ;
+  STANDARD_VBSTRT = $0122;
+  STANDARD_VSSTRT = $02A6;
+  STANDARD_VSSTOP = $03AA;
+  STANDARD_VBSTOP = $1066;
+
+  VGA_COLORCLOCKS = (STANDARD_COLORCLOCKS/2);
+  VGA_TOTAL_ROWS  = (STANDARD_NTSC_ROWS*2);
+  VGA_DENISE_MIN  = 59   ;
+  MIN_VGA_ROW     = 29   ;
+  VGA_HBSTRT      = $08  ;
+  VGA_HSSTRT      = $0E  ;
+  VGA_HSSTOP      = $1C  ;
+  VGA_HBSTOP      = $1E  ;
+  VGA_VBSTRT      = $0000;
+  VGA_VSSTRT      = $0153;
+  VGA_VSSTOP      = $0235;
+  VGA_VBSTOP      = $0CCD;
+
+  VGA_MONITOR_NAME  : PChar    =  'vga.monitor';
+
+{ NOTE: VGA70 definitions are obsolete - a VGA70 monitor has never been
+ * implemented.
+ }
+  VGA70_COLORCLOCKS = (STANDARD_COLORCLOCKS/2) ;
+  VGA70_TOTAL_ROWS  = 449;
+  VGA70_DENISE_MIN  = 59;
+  MIN_VGA70_ROW     = 35   ;
+  VGA70_HBSTRT      = $08  ;
+  VGA70_HSSTRT      = $0E  ;
+  VGA70_HSSTOP      = $1C  ;
+  VGA70_HBSTOP      = $1E  ;
+  VGA70_VBSTRT      = $0000;
+  VGA70_VSSTRT      = $02A6;
+  VGA70_VSSTOP      = $0388;
+  VGA70_VBSTOP      = $0F73;
+
+  VGA70_BEAMCON     = (SPECIAL_BEAMCON XOR VSYNCTRUE);
+  VGA70_MONITOR_NAME  : PChar  =      'vga70.monitor';
+
+  BROADCAST_HBSTRT  =      $01  ;
+  BROADCAST_HSSTRT  =      $06  ;
+  BROADCAST_HSSTOP  =      $17  ;
+  BROADCAST_HBSTOP  =      $27  ;
+  BROADCAST_VBSTRT  =      $0000;
+  BROADCAST_VSSTRT  =      $02A6;
+  BROADCAST_VSSTOP  =      $054C;
+  BROADCAST_VBSTOP  =      $1C40;
+  BROADCAST_BEAMCON =      ( LOLDIS OR CSBLANK );
+  RATIO_FIXEDPART   =      4;
+  RATIO_UNITY       =      16;
+
+
+
+Type
+    pRasInfo = ^tRasInfo;
+    tRasInfo = record    { used by callers to and InitDspC() }
+        Next    : pRasInfo;     { used for dualpf }
+        BitMap  : pBitMap;
+        RxOffset,
+        RyOffset : Integer;       { scroll offsets in this BitMap }
+    end;
+
+
+    pView = ^tView;
+    tView = record
+        ViewPort        : Pointer;      { ViewPortPtr }
+        LOFCprList      : pcprlist;   { used for interlaced and noninterlaced }
+        SHFCprList      : pcprlist;   { only used during interlace }
+        DyOffset,
+        DxOffset        : Integer;        { for complete View positioning }
+                                { offsets are +- adjustments to standard #s }
+        Modes           : WORD;        { such as INTERLACE, GENLOC }
+    end;
+
+{ these structures are obtained via GfxNew }
+{ and disposed by GfxFree }
+Type
+       pViewExtra = ^tViewExtra;
+       tViewExtra = record
+        n : tExtendedNode;
+        View     : pView;       { backwards link }   { view in C-Includes }
+        Monitor : pMonitorSpec; { monitors for this view }
+        TopLine : Word;
+       END;
+
+
+    pViewPort = ^tViewPort;
+    tViewPort = record
+        Next    : pViewPort;
+        ColorMap : Pointer; { table of colors for this viewport }        { ColorMapPtr }
+                          { if this is nil, MakeVPort assumes default values }
+        DspIns  : pCopList;   { user by MakeView() }
+        SprIns  : pCopList;   { used by sprite stuff }
+        ClrIns  : pCopList;   { used by sprite stuff }
+        UCopIns : pUCopList;  { User copper list }
+        DWidth,
+        DHeight : Integer;
+        DxOffset,
+        DyOffset : Integer;
+        Modes   : Word;
+        SpritePriorities : Byte;        { used by makevp }
+        reserved : Byte;
+        RasInfo : pRasInfo;
+    end;
+
+
+{ this structure is obtained via GfxNew }
+{ and disposed by GfxFree }
+
+ pViewPortExtra = ^tViewPortExtra;
+ tViewPortExtra = record
+  n : tExtendedNode;
+  ViewPort     : pViewPort;      { backwards link }   { ViewPort in C-Includes }
+  DisplayClip  : tRectangle;  { makevp display clipping information }
+        { These are added for V39 }
+  VecTable     : Pointer;                { Private }
+  DriverData   : Array[0..1] of Pointer;
+  Flags        : WORD;
+  Origin       : Array[0..1] of tPoint;  { First visible point relative to the DClip.
+                                         * One for each possible playfield.
+                                         }
+  cop1ptr,                  { private }
+  cop2ptr      : ULONG;   { private }
+ END;
+
+
+    pColorMap = ^tColorMap;
+    tColorMap = record
+        Flags   : Byte;
+        CType   : Byte;         { This is "Type" in C includes }
+        Count   : Word;
+        ColorTable      : Pointer;
+        cm_vpe  : pViewPortExtra;
+        LowColorBits : Pointer;
+        TransparencyPlane,
+        SpriteResolution,
+        SpriteResDefault,
+        AuxFlags         : Byte;
+        cm_vp            : pViewPort;   { ViewPortPtr }
+        NormalDisplayInfo,
+        CoerceDisplayInfo : Pointer;
+        cm_batch_items   : pTagItem;
+        VPModeID         : ULONG;
+        PalExtra         : Pointer;
+        SpriteBase_Even,
+        SpriteBase_Odd,
+        Bp_0_base,
+        Bp_1_base        : Word;
+    end;
+
+{ if Type == 0 then ColorMap is V1.2/V1.3 compatible }
+{ if Type != 0 then ColorMap is V36       compatible }
+{ the system will never create other than V39 type colormaps when running V39 }
+
+CONST
+ COLORMAP_TYPE_V1_2     = $00;
+ COLORMAP_TYPE_V1_4     = $01;
+ COLORMAP_TYPE_V36      = COLORMAP_TYPE_V1_4;    { use this definition }
+ COLORMAP_TYPE_V39      = $02;
+
+
+{ Flags variable }
+ COLORMAP_TRANSPARENCY   = $01;
+ COLORPLANE_TRANSPARENCY = $02;
+ BORDER_BLANKING         = $04;
+ BORDER_NOTRANSPARENCY   = $08;
+ VIDEOCONTROL_BATCH      = $10;
+ USER_COPPER_CLIP        = $20;
+
+
+CONST
+ EXTEND_VSTRUCT = $1000;  { unused bit in Modes field of View }
+
+
+{ defines used for Modes in IVPargs }
+
+CONST
+ GENLOCK_VIDEO  =  $0002;
+ LACE           =  $0004;
+ SUPERHIRES     =  $0020;
+ PFBA           =  $0040;
+ EXTRA_HALFBRITE=  $0080;
+ GENLOCK_AUDIO  =  $0100;
+ DUALPF         =  $0400;
+ HAM            =  $0800;
+ EXTENDED_MODE  =  $1000;
+ VP_HIDE        =  $2000;
+ SPRITES        =  $4000;
+ HIRES          =  $8000;
+
+ VPF_A2024      =  $40;
+ VPF_AGNUS      =  $20;
+ VPF_TENHZ      =  $20;
+
+ BORDERSPRITES   = $40;
+
+ CMF_CMTRANS   =  0;
+ CMF_CPTRANS   =  1;
+ CMF_BRDRBLNK  =  2;
+ CMF_BRDNTRAN  =  3;
+ CMF_BRDRSPRT  =  6;
+
+ SPRITERESN_ECS       =   0;
+{ ^140ns, except in 35ns viewport, where it is 70ns. }
+ SPRITERESN_140NS     =   1;
+ SPRITERESN_70NS      =   2;
+ SPRITERESN_35NS      =   3;
+ SPRITERESN_DEFAULT   =   -1;
+
+{ AuxFlags : }
+ CMAB_FULLPALETTE = 0;
+ CMAF_FULLPALETTE = 1;
+ CMAB_NO_INTERMED_UPDATE = 1;
+ CMAF_NO_INTERMED_UPDATE = 2;
+ CMAB_NO_COLOR_LOAD = 2;
+ CMAF_NO_COLOR_LOAD = 4;
+ CMAB_DUALPF_DISABLE = 3;
+ CMAF_DUALPF_DISABLE = 8;
+
+Type
+    pPaletteExtra = ^tPaletteExtra;
+    tPaletteExtra = record                            { structure may be extended so watch out! }
+        pe_Semaphore  : tSignalSemaphore;                { shared semaphore for arbitration     }
+        pe_FirstFree,                                   { *private*                            }
+        pe_NFree,                                       { number of free colors                }
+        pe_FirstShared,                                 { *private*                            }
+        pe_NShared    : WORD;                           { *private*                            }
+        pe_RefCnt     : Pointer;                        { *private*                            }
+        pe_AllocList  : Pointer;                        { *private*                            }
+        pe_ViewPort   : pViewPort;                    { back pointer to viewport             }
+        pe_SharableColors : WORD;                       { the number of sharable colors.       }
+    end;
+{ flags values for ObtainPen }
+Const
+ PENB_EXCLUSIVE = 0;
+ PENB_NO_SETCOLOR = 1;
+
+ PENF_EXCLUSIVE = 1;
+ PENF_NO_SETCOLOR = 2;
+
+{ obsolete names for PENF_xxx flags: }
+
+ PEN_EXCLUSIVE = PENF_EXCLUSIVE;
+ PEN_NO_SETCOLOR = PENF_NO_SETCOLOR;
+
+{ precision values for ObtainBestPen : }
+
+ PRECISION_EXACT = -1;
+ PRECISION_IMAGE = 0;
+ PRECISION_ICON  = 16;
+ PRECISION_GUI   = 32;
+
+
+{ tags for ObtainBestPen: }
+ OBP_Precision = $84000000;
+ OBP_FailIfBad = $84000001;
+
+{ From V39, MakeVPort() will return an error if there is not enough memory,
+ * or the requested mode cannot be opened with the requested depth with the
+ * given bitmap (for higher bandwidth alignments).
+ }
+
+ MVP_OK        =  0;       { you want to see this one }
+ MVP_NO_MEM    =  1;       { insufficient memory for intermediate workspace }
+ MVP_NO_VPE    =  2;       { ViewPort does not have a ViewPortExtra, and
+                                 * insufficient memory to allocate a temporary one.
+                                 }
+ MVP_NO_DSPINS =  3;       { insufficient memory for intermidiate copper
+                                 * instructions.
+                                 }
+ MVP_NO_DISPLAY = 4;       { BitMap data is misaligned for this viewport's
+                                 * mode and depth - see AllocBitMap().
+                                 }
+ MVP_OFF_BOTTOM = 5;       { PRIVATE - you will never see this. }
+
+{ From V39, MrgCop() will return an error if there is not enough memory,
+ * or for some reason MrgCop() did not need to make any copper lists.
+ }
+
+ MCOP_OK       =  0;       { you want to see this one }
+ MCOP_NO_MEM   =  1;       { insufficient memory to allocate the system
+                                 * copper lists.
+                                 }
+ MCOP_NOP      =  2;       { MrgCop() did not merge any copper lists
+                                 * (eg, no ViewPorts in the list, or all marked as
+                                 * hidden).
+                                 }
+Type
+    pDBufInfo = ^tDBufInfo;
+    tDBufInfo = record
+        dbi_Link1   : Pointer;
+        dbi_Count1  : ULONG;
+        dbi_SafeMessage : tMessage;         { replied to when safe to write to old bitmap }
+        dbi_UserData1   : Pointer;                     { first user data }
+
+        dbi_Link2   : Pointer;
+        dbi_Count2  : ULONG;
+        dbi_DispMessage : tMessage; { replied to when new bitmap has been displayed at least
+                                                        once }
+        dbi_UserData2 : Pointer;                  { second user data }
+        dbi_MatchLong : ULONG;
+        dbi_CopPtr1,
+        dbi_CopPtr2,
+        dbi_CopPtr3   : Pointer;
+        dbi_BeamPos1,
+        dbi_BeamPos2  : WORD;
+    end;
+
+
+
+   {   include define file for graphics display mode IDs.   }
+
+
+const
+
+   INVALID_ID                   =   NOT 0;
+
+{ With all the new modes that are available under V38 and V39, it is highly
+ * recommended that you use either the asl.library screenmode requester,
+ * and/or the V39 graphics.library function BestModeIDA().
+ *
+ * DO NOT interpret the any of the bits in the ModeID for its meaning. For
+ * example, do not interpret bit 3 ($4) as meaning the ModeID is interlaced.
+ * Instead, use GetDisplayInfoData() with DTAG_DISP, and examine the DIPF_...
+ * flags to determine a ModeID's characteristics. The only exception to
+ * this rule is that bit 7 ($80) will always mean the ModeID is
+ * ExtraHalfBright, and bit 11 ($800) will always mean the ModeID is HAM.
+ }
+
+{ normal identifiers }
+
+   MONITOR_ID_MASK              =   $FFFF1000;
+
+   DEFAULT_MONITOR_ID           =   $00000000;
+   NTSC_MONITOR_ID              =   $00011000;
+   PAL_MONITOR_ID               =   $00021000;
+
+{ the following 22 composite keys are for Modes on the default Monitor.
+ * NTSC & PAL "flavors" of these particular keys may be made by or'ing
+ * the NTSC or PAL MONITOR_ID with the desired MODE_KEY...
+ *
+ * For example, to specifically open a PAL HAM interlaced ViewPort
+ * (or intuition screen), you would use the modeid of
+ * (PAL_MONITOR_ID OR HAMLACE_KEY)
+ }
+
+   LORES_KEY                     =  $00000000;
+   HIRES_KEY                     =  $00008000;
+   SUPER_KEY                     =  $00008020;
+   HAM_KEY                       =  $00000800;
+   LORESLACE_KEY                 =  $00000004;
+   HIRESLACE_KEY                 =  $00008004;
+   SUPERLACE_KEY                 =  $00008024;
+   HAMLACE_KEY                   =  $00000804;
+   LORESDPF_KEY                  =  $00000400;
+   HIRESDPF_KEY                  =  $00008400;
+   SUPERDPF_KEY                  =  $00008420;
+   LORESLACEDPF_KEY              =  $00000404;
+   HIRESLACEDPF_KEY              =  $00008404;
+   SUPERLACEDPF_KEY              =  $00008424;
+   LORESDPF2_KEY                 =  $00000440;
+   HIRESDPF2_KEY                 =  $00008440;
+   SUPERDPF2_KEY                 =  $00008460;
+   LORESLACEDPF2_KEY             =  $00000444;
+   HIRESLACEDPF2_KEY             =  $00008444;
+   SUPERLACEDPF2_KEY             =  $00008464;
+   EXTRAHALFBRITE_KEY            =  $00000080;
+   EXTRAHALFBRITELACE_KEY        =  $00000084;
+{ New for AA ChipSet (V39) }
+   HIRESHAM_KEY                  =  $00008800;
+   SUPERHAM_KEY                  =  $00008820;
+   HIRESEHB_KEY                  =  $00008080;
+   SUPEREHB_KEY                  =  $000080a0;
+   HIRESHAMLACE_KEY              =  $00008804;
+   SUPERHAMLACE_KEY              =  $00008824;
+   HIRESEHBLACE_KEY              =  $00008084;
+   SUPEREHBLACE_KEY              =  $000080a4;
+{ Added for V40 - may be useful modes for some games or animations. }
+   LORESSDBL_KEY                 =  $00000008;
+   LORESHAMSDBL_KEY              =  $00000808;
+   LORESEHBSDBL_KEY              =  $00000088;
+   HIRESHAMSDBL_KEY              =  $00008808;
+
+
+{ VGA identifiers }
+
+   VGA_MONITOR_ID                =  $00031000;
+
+   VGAEXTRALORES_KEY             =  $00031004;
+   VGALORES_KEY                  =  $00039004;
+   VGAPRODUCT_KEY                =  $00039024;
+   VGAHAM_KEY                    =  $00031804;
+   VGAEXTRALORESLACE_KEY         =  $00031005;
+   VGALORESLACE_KEY              =  $00039005;
+   VGAPRODUCTLACE_KEY            =  $00039025;
+   VGAHAMLACE_KEY                =  $00031805;
+   VGAEXTRALORESDPF_KEY          =  $00031404;
+   VGALORESDPF_KEY               =  $00039404;
+   VGAPRODUCTDPF_KEY             =  $00039424;
+   VGAEXTRALORESLACEDPF_KEY      =  $00031405;
+   VGALORESLACEDPF_KEY           =  $00039405;
+   VGAPRODUCTLACEDPF_KEY         =  $00039425;
+   VGAEXTRALORESDPF2_KEY         =  $00031444;
+   VGALORESDPF2_KEY              =  $00039444;
+   VGAPRODUCTDPF2_KEY            =  $00039464;
+   VGAEXTRALORESLACEDPF2_KEY     =  $00031445;
+   VGALORESLACEDPF2_KEY          =  $00039445;
+   VGAPRODUCTLACEDPF2_KEY        =  $00039465;
+   VGAEXTRAHALFBRITE_KEY         =  $00031084;
+   VGAEXTRAHALFBRITELACE_KEY     =  $00031085;
+{ New for AA ChipSet (V39) }
+   VGAPRODUCTHAM_KEY             =  $00039824;
+   VGALORESHAM_KEY               =  $00039804;
+   VGAEXTRALORESHAM_KEY          =  VGAHAM_KEY;
+   VGAPRODUCTHAMLACE_KEY         =  $00039825;
+   VGALORESHAMLACE_KEY           =  $00039805;
+   VGAEXTRALORESHAMLACE_KEY      =  VGAHAMLACE_KEY;
+   VGAEXTRALORESEHB_KEY          =  VGAEXTRAHALFBRITE_KEY;
+   VGAEXTRALORESEHBLACE_KEY      =  VGAEXTRAHALFBRITELACE_KEY;
+   VGALORESEHB_KEY               =  $00039084;
+   VGALORESEHBLACE_KEY           =  $00039085;
+   VGAEHB_KEY                    =  $000390a4;
+   VGAEHBLACE_KEY                =  $000390a5;
+{ These ModeIDs are the scandoubled equivalents of the above, with the
+ * exception of the DualPlayfield modes, as AA does not allow for scandoubling
+ * dualplayfield.
+ }
+   VGAEXTRALORESDBL_KEY          =  $00031000;
+   VGALORESDBL_KEY               =  $00039000;
+   VGAPRODUCTDBL_KEY             =  $00039020;
+   VGAEXTRALORESHAMDBL_KEY       =  $00031800;
+   VGALORESHAMDBL_KEY            =  $00039800;
+   VGAPRODUCTHAMDBL_KEY          =  $00039820;
+   VGAEXTRALORESEHBDBL_KEY       =  $00031080;
+   VGALORESEHBDBL_KEY            =  $00039080;
+   VGAPRODUCTEHBDBL_KEY          =  $000390a0;
+
+{ a2024 identifiers }
+
+   A2024_MONITOR_ID              =  $00041000;
+
+   A2024TENHERTZ_KEY             =  $00041000;
+   A2024FIFTEENHERTZ_KEY         =  $00049000;
+
+{ prototype identifiers (private) }
+
+   PROTO_MONITOR_ID              =  $00051000;
+
+
+{ These monitors and modes were added for the V38 release. }
+
+   EURO72_MONITOR_ID             =  $00061000;
+
+   EURO72EXTRALORES_KEY          =  $00061004;
+   EURO72LORES_KEY               =  $00069004;
+   EURO72PRODUCT_KEY             =  $00069024;
+   EURO72HAM_KEY                 =  $00061804;
+   EURO72EXTRALORESLACE_KEY      =  $00061005;
+   EURO72LORESLACE_KEY           =  $00069005;
+   EURO72PRODUCTLACE_KEY         =  $00069025;
+   EURO72HAMLACE_KEY             =  $00061805;
+   EURO72EXTRALORESDPF_KEY       =  $00061404;
+   EURO72LORESDPF_KEY            =  $00069404;
+   EURO72PRODUCTDPF_KEY          =  $00069424;
+   EURO72EXTRALORESLACEDPF_KEY   =  $00061405;
+   EURO72LORESLACEDPF_KEY        =  $00069405;
+   EURO72PRODUCTLACEDPF_KEY      =  $00069425;
+   EURO72EXTRALORESDPF2_KEY      =  $00061444;
+   EURO72LORESDPF2_KEY           =  $00069444;
+   EURO72PRODUCTDPF2_KEY         =  $00069464;
+   EURO72EXTRALORESLACEDPF2_KEY  =  $00061445;
+   EURO72LORESLACEDPF2_KEY       =  $00069445;
+   EURO72PRODUCTLACEDPF2_KEY     =  $00069465;
+   EURO72EXTRAHALFBRITE_KEY      =  $00061084;
+   EURO72EXTRAHALFBRITELACE_KEY  =  $00061085;
+{ New AA modes (V39) }
+   EURO72PRODUCTHAM_KEY          =  $00069824;
+   EURO72PRODUCTHAMLACE_KEY      =  $00069825;
+   EURO72LORESHAM_KEY            =  $00069804;
+   EURO72LORESHAMLACE_KEY        =  $00069805;
+   EURO72EXTRALORESHAM_KEY       =  EURO72HAM_KEY;
+   EURO72EXTRALORESHAMLACE_KEY   =  EURO72HAMLACE_KEY ;
+   EURO72EXTRALORESEHB_KEY       =  EURO72EXTRAHALFBRITE_KEY;
+   EURO72EXTRALORESEHBLACE_KEY   =  EURO72EXTRAHALFBRITELACE_KEY;
+   EURO72LORESEHB_KEY            =  $00069084;
+   EURO72LORESEHBLACE_KEY        =  $00069085;
+   EURO72EHB_KEY                 =  $000690a4;
+   EURO72EHBLACE_KEY             =  $000690a5;
+{ These ModeIDs are the scandoubled equivalents of the above, with the
+ * exception of the DualPlayfield modes, as AA does not allow for scandoubling
+ * dualplayfield.
+ }
+   EURO72EXTRALORESDBL_KEY       =  $00061000;
+   EURO72LORESDBL_KEY            =  $00069000;
+   EURO72PRODUCTDBL_KEY          =  $00069020;
+   EURO72EXTRALORESHAMDBL_KEY    =  $00061800;
+   EURO72LORESHAMDBL_KEY         =  $00069800;
+   EURO72PRODUCTHAMDBL_KEY       =  $00069820;
+   EURO72EXTRALORESEHBDBL_KEY    =  $00061080;
+   EURO72LORESEHBDBL_KEY         =  $00069080;
+   EURO72PRODUCTEHBDBL_KEY       =  $000690a0;
+
+
+   EURO36_MONITOR_ID             =  $00071000;
+
+{ Euro36 modeids can be ORed with the default modeids a la NTSC and PAL.
+ * For example, Euro36 SuperHires is
+ * (EURO36_MONITOR_ID OR SUPER_KEY)
+ }
+
+   SUPER72_MONITOR_ID            =  $00081000;
+
+{ Super72 modeids can be ORed with the default modeids a la NTSC and PAL.
+ * For example, Super72 SuperHiresLace (80$600) is
+ * (SUPER72_MONITOR_ID OR SUPERLACE_KEY).
+ * The following scandoubled Modes are the exception:
+ }
+   SUPER72LORESDBL_KEY           =  $00081008;
+   SUPER72HIRESDBL_KEY           =  $00089008;
+   SUPER72SUPERDBL_KEY           =  $00089028;
+   SUPER72LORESHAMDBL_KEY        =  $00081808;
+   SUPER72HIRESHAMDBL_KEY        =  $00089808;
+   SUPER72SUPERHAMDBL_KEY        =  $00089828;
+   SUPER72LORESEHBDBL_KEY        =  $00081088;
+   SUPER72HIRESEHBDBL_KEY        =  $00089088;
+   SUPER72SUPEREHBDBL_KEY        =  $000890a8;
+
+
+{ These monitors and modes were added for the V39 release. }
+
+   DBLNTSC_MONITOR_ID            =  $00091000;
+
+   DBLNTSCLORES_KEY              =  $00091000;
+   DBLNTSCLORESFF_KEY            =  $00091004;
+   DBLNTSCLORESHAM_KEY           =  $00091800;
+   DBLNTSCLORESHAMFF_KEY         =  $00091804;
+   DBLNTSCLORESEHB_KEY           =  $00091080;
+   DBLNTSCLORESEHBFF_KEY         =  $00091084;
+   DBLNTSCLORESLACE_KEY          =  $00091005;
+   DBLNTSCLORESHAMLACE_KEY       =  $00091805;
+   DBLNTSCLORESEHBLACE_KEY       =  $00091085;
+   DBLNTSCLORESDPF_KEY           =  $00091400;
+   DBLNTSCLORESDPFFF_KEY         =  $00091404;
+   DBLNTSCLORESDPFLACE_KEY       =  $00091405;
+   DBLNTSCLORESDPF2_KEY          =  $00091440;
+   DBLNTSCLORESDPF2FF_KEY        =  $00091444;
+   DBLNTSCLORESDPF2LACE_KEY      =  $00091445;
+   DBLNTSCHIRES_KEY              =  $00099000;
+   DBLNTSCHIRESFF_KEY            =  $00099004;
+   DBLNTSCHIRESHAM_KEY           =  $00099800;
+   DBLNTSCHIRESHAMFF_KEY         =  $00099804;
+   DBLNTSCHIRESLACE_KEY          =  $00099005;
+   DBLNTSCHIRESHAMLACE_KEY       =  $00099805;
+   DBLNTSCHIRESEHB_KEY           =  $00099080;
+   DBLNTSCHIRESEHBFF_KEY         =  $00099084;
+   DBLNTSCHIRESEHBLACE_KEY       =  $00099085;
+   DBLNTSCHIRESDPF_KEY           =  $00099400;
+   DBLNTSCHIRESDPFFF_KEY         =  $00099404;
+   DBLNTSCHIRESDPFLACE_KEY       =  $00099405;
+   DBLNTSCHIRESDPF2_KEY          =  $00099440;
+   DBLNTSCHIRESDPF2FF_KEY        =  $00099444;
+   DBLNTSCHIRESDPF2LACE_KEY      =  $00099445;
+   DBLNTSCEXTRALORES_KEY         =  $00091200;
+   DBLNTSCEXTRALORESHAM_KEY      =  $00091a00;
+   DBLNTSCEXTRALORESEHB_KEY      =  $00091280;
+   DBLNTSCEXTRALORESDPF_KEY      =  $00091600;
+   DBLNTSCEXTRALORESDPF2_KEY     =  $00091640;
+   DBLNTSCEXTRALORESFF_KEY       =  $00091204;
+   DBLNTSCEXTRALORESHAMFF_KEY    =  $00091a04;
+   DBLNTSCEXTRALORESEHBFF_KEY    =  $00091284;
+   DBLNTSCEXTRALORESDPFFF_KEY    =  $00091604;
+   DBLNTSCEXTRALORESDPF2FF_KEY   =  $00091644;
+   DBLNTSCEXTRALORESLACE_KEY     =  $00091205;
+   DBLNTSCEXTRALORESHAMLACE_KEY  =  $00091a05;
+   DBLNTSCEXTRALORESEHBLACE_KEY  =  $00091285;
+   DBLNTSCEXTRALORESDPFLACE_KEY  =  $00091605;
+   DBLNTSCEXTRALORESDPF2LACE_KEY =  $00091645;
+
+   DBLPAL_MONITOR_ID             =  $000a1000;
+
+   DBLPALLORES_KEY               =  $000a1000;
+   DBLPALLORESFF_KEY             =  $000a1004;
+   DBLPALLORESHAM_KEY            =  $000a1800;
+   DBLPALLORESHAMFF_KEY          =  $000a1804;
+   DBLPALLORESEHB_KEY            =  $000a1080;
+   DBLPALLORESEHBFF_KEY          =  $000a1084;
+   DBLPALLORESLACE_KEY           =  $000a1005;
+   DBLPALLORESHAMLACE_KEY        =  $000a1805;
+   DBLPALLORESEHBLACE_KEY        =  $000a1085;
+   DBLPALLORESDPF_KEY            =  $000a1400;
+   DBLPALLORESDPFFF_KEY          =  $000a1404;
+   DBLPALLORESDPFLACE_KEY        =  $000a1405;
+   DBLPALLORESDPF2_KEY           =  $000a1440;
+   DBLPALLORESDPF2FF_KEY         =  $000a1444;
+   DBLPALLORESDPF2LACE_KEY       =  $000a1445;
+   DBLPALHIRES_KEY               =  $000a9000;
+   DBLPALHIRESFF_KEY             =  $000a9004;
+   DBLPALHIRESHAM_KEY            =  $000a9800;
+   DBLPALHIRESHAMFF_KEY          =  $000a9804;
+   DBLPALHIRESLACE_KEY           =  $000a9005;
+   DBLPALHIRESHAMLACE_KEY        =  $000a9805;
+   DBLPALHIRESEHB_KEY            =  $000a9080;
+   DBLPALHIRESEHBFF_KEY          =  $000a9084;
+   DBLPALHIRESEHBLACE_KEY        =  $000a9085;
+   DBLPALHIRESDPF_KEY            =  $000a9400;
+   DBLPALHIRESDPFFF_KEY          =  $000a9404;
+   DBLPALHIRESDPFLACE_KEY        =  $000a9405;
+   DBLPALHIRESDPF2_KEY           =  $000a9440;
+   DBLPALHIRESDPF2FF_KEY         =  $000a9444;
+   DBLPALHIRESDPF2LACE_KEY       =  $000a9445;
+   DBLPALEXTRALORES_KEY          =  $000a1200;
+   DBLPALEXTRALORESHAM_KEY       =  $000a1a00;
+   DBLPALEXTRALORESEHB_KEY       =  $000a1280;
+   DBLPALEXTRALORESDPF_KEY       =  $000a1600;
+   DBLPALEXTRALORESDPF2_KEY      =  $000a1640;
+   DBLPALEXTRALORESFF_KEY        =  $000a1204;
+   DBLPALEXTRALORESHAMFF_KEY     =  $000a1a04;
+   DBLPALEXTRALORESEHBFF_KEY     =  $000a1284;
+   DBLPALEXTRALORESDPFFF_KEY     =  $000a1604;
+   DBLPALEXTRALORESDPF2FF_KEY    =  $000a1644;
+   DBLPALEXTRALORESLACE_KEY      =  $000a1205;
+   DBLPALEXTRALORESHAMLACE_KEY   =  $000a1a05;
+   DBLPALEXTRALORESEHBLACE_KEY   =  $000a1285;
+   DBLPALEXTRALORESDPFLACE_KEY   =  $000a1605;
+   DBLPALEXTRALORESDPF2LACE_KEY  =  $000a1645;
+
+
+{ Use these tags for passing to BestModeID() (V39) }
+
+   SPECIAL_FLAGS = $100E;
+   { Original:
+     SPECIAL_FLAGS = DIPF_IS_DUALPF OR DIPF_IS_PF2PRI OR DIPF_IS_HAM OR DIPF_IS_EXTRAHALFBRITE;
+     ( Mu?te aufgrund eines Fehler in PCQ ge?ndert werden )
+   }
+
+
+   BIDTAG_DIPFMustHave     = $80000001;      { mask of the DIPF_ flags the ModeID must have }
+                                { Default - NULL }
+   BIDTAG_DIPFMustNotHave  = $80000002;      { mask of the DIPF_ flags the ModeID must not have }
+                                { Default - SPECIAL_FLAGS }
+   BIDTAG_ViewPort         = $80000003;      { ViewPort for which a ModeID is sought. }
+                                { Default - NULL }
+   BIDTAG_NominalWidth     = $80000004;      { \ together make the aspect ratio and }
+   BIDTAG_NominalHeight    = $80000005;      { / override the vp->Width/Height. }
+                                { Default - SourceID NominalDimensionInfo,
+                                 * or vp->DWidth/Height, or (640 * 200),
+                                 * in that preferred order.
+                                 }
+   BIDTAG_DesiredWidth     = $80000006;      { \ Nominal Width and Height of the }
+   BIDTAG_DesiredHeight    = $80000007;      { / returned ModeID. }
+                                { Default - same as Nominal }
+   BIDTAG_Depth            = $80000008;      { ModeID must support this depth. }
+                                { Default - vp->RasInfo->BitMap->Depth or 1 }
+   BIDTAG_MonitorID        = $80000009;      { ModeID must use this monitor. }
+                                { Default - use best monitor available }
+   BIDTAG_SourceID         = $8000000a;      { instead of a ViewPort. }
+                                { Default - VPModeID(vp) if BIDTAG_ViewPort is
+                                 * specified, else leave the DIPFMustHave and
+                                 * DIPFMustNotHave values untouched.
+                                 }
+   BIDTAG_RedBits        =  $8000000b;      { \                            }
+   BIDTAG_BlueBits       =  $8000000c;      {  > Match up from the database }
+   BIDTAG_GreenBits      =  $8000000d;      { /                            }
+                                            { Default - 4 }
+   BIDTAG_GfxPrivate     =  $8000000e;      { Private }
+
+
+const
+
+{ bplcon0 defines }
+
+    MODE_640    = $8000;
+    PLNCNTMSK   = $7;           { how many bit planes? }
+                                { 0 = none, 1->6 = 1->6, 7 = reserved }
+    PLNCNTSHFT  = 12;           { bits to shift for bplcon0 }
+    PF2PRI      = $40;          { bplcon2 bit }
+    COLORON     = $0200;        { disable color burst }
+    DBLPF       = $400;
+    HOLDNMODIFY = $800;
+    INTERLACE   = 4;            { interlace mode for 400 }
+
+{ bplcon1 defines }
+
+    PFA_FINE_SCROLL             = $F;
+    PFB_FINE_SCROLL_SHIFT       = 4;
+    PF_FINE_SCROLL_MASK         = $F;
+
+{ display window start and stop defines }
+
+    DIW_HORIZ_POS       = $7F;  { horizontal start/stop }
+    DIW_VRTCL_POS       = $1FF; { vertical start/stop }
+    DIW_VRTCL_POS_SHIFT = $7;
+
+{ Data fetch start/stop horizontal position }
+
+    DFTCH_MASK  = $FF;
+
+{ vposr bits }
+
+    VPOSRLOF    = $8000;
+
+  {   include define file for displayinfo database }
+
+{ the "public" handle to a DisplayInfoRecord }
+Type
+
+ DisplayInfoHandle = APTR;
+
+{ datachunk type identifiers }
+
+CONST
+ DTAG_DISP            =   $80000000;
+ DTAG_DIMS            =   $80001000;
+ DTAG_MNTR            =   $80002000;
+ DTAG_NAME            =   $80003000;
+ DTAG_VEC             =   $80004000;      { internal use only }
+
+Type
+
+  pQueryHeader = ^tQueryHeader;
+  tQueryHeader = record
+   tructID,                    { datachunk type identifier }
+   DisplayID,                  { copy of display record key   }
+   SkipID,                     { TAG_SKIP -- see tagitems.h }
+   Length  :  ULONG;         { length of local data in double-longwords }
+  END;
+
+  pDisplayInfo = ^tDisplayInfo;
+  tDisplayInfo = record
+   Header : tQueryHeader;
+   NotAvailable : Word;    { IF NULL available, else see defines }
+   PropertyFlags : ULONG;  { Properties of this mode see defines }
+   Resolution : tPoint;     { ticks-per-pixel X/Y                 }
+   PixelSpeed : Word;     { aproximation in nanoseconds         }
+   NumStdSprites : Word;  { number of standard amiga sprites    }
+   PaletteRange : Word;   { distinguishable shades available    }
+   SpriteResolution : tPoint; { std sprite ticks-per-pixel X/Y    }
+   pad : Array[0..3] of Byte;
+   RedBits     : Byte;
+   GreenBits   : Byte;
+   BlueBits    : Byte;
+   pad2        : array [0..4] of Byte;
+   reserved : Array[0..1] of ULONG;    { terminator }
+  END;
+
+{ availability }
+
+CONST
+ DI_AVAIL_NOCHIPS        =$0001;
+ DI_AVAIL_NOMONITOR      =$0002;
+ DI_AVAIL_NOTWITHGENLOCK =$0004;
+
+{ mode properties }
+
+ DIPF_IS_LACE          =  $00000001;
+ DIPF_IS_DUALPF        =  $00000002;
+ DIPF_IS_PF2PRI        =  $00000004;
+ DIPF_IS_HAM           =  $00000008;
+
+ DIPF_IS_ECS           =  $00000010;      {      note: ECS modes (SHIRES, VGA, AND **
+                                                 PRODUCTIVITY) do not support      **
+                                                 attached sprites.                 **
+                                                                                        }
+ DIPF_IS_AA            =  $00010000;      { AA modes - may only be available
+                                                ** if machine has correct memory
+                                                ** type to support required
+                                                ** bandwidth - check availability.
+                                                ** (V39)
+                                                }
+ DIPF_IS_PAL           =  $00000020;
+ DIPF_IS_SPRITES       =  $00000040;
+ DIPF_IS_GENLOCK       =  $00000080;
+
+ DIPF_IS_WB            =  $00000100;
+ DIPF_IS_DRAGGABLE     =  $00000200;
+ DIPF_IS_PANELLED      =  $00000400;
+ DIPF_IS_BEAMSYNC      =  $00000800;
+
+ DIPF_IS_EXTRAHALFBRITE = $00001000;
+
+{ The following DIPF_IS_... flags are new for V39 }
+  DIPF_IS_SPRITES_ATT           =  $00002000;      { supports attached sprites }
+  DIPF_IS_SPRITES_CHNG_RES      =  $00004000;      { supports variable sprite resolution }
+  DIPF_IS_SPRITES_BORDER        =  $00008000;      { sprite can be displayed in the border }
+  DIPF_IS_SCANDBL               =  $00020000;      { scan doubled }
+  DIPF_IS_SPRITES_CHNG_BASE     =  $00040000;
+                                                   { can change the sprite base colour }
+  DIPF_IS_SPRITES_CHNG_PRI      =  $00080000;
+                                                                                        { can change the sprite priority
+                                                                                        ** with respect to the playfield(s).
+                                                                                        }
+  DIPF_IS_DBUFFER       =  $00100000;      { can support double buffering }
+  DIPF_IS_PROGBEAM      =  $00200000;      { is a programmed beam-sync mode }
+  DIPF_IS_FOREIGN       =  $80000000;      { this mode is not native to the Amiga }
+
+Type
+ pDimensionInfo =^tDimensionInfo;
+ tDimensionInfo = record
+  Header : tQueryHeader;
+  MaxDepth,             { log2( max number of colors ) }
+  MinRasterWidth,       { minimum width in pixels      }
+  MinRasterHeight,      { minimum height in pixels     }
+  MaxRasterWidth,       { maximum width in pixels      }
+  MaxRasterHeight : Word;      { maximum height in pixels     }
+  Nominal,              { "standard" dimensions        }
+  MaxOScan,             { fixed, hardware dependant    }
+  VideoOScan,           { fixed, hardware dependant    }
+  TxtOScan,             { editable via preferences     }
+  StdOScan  : tRectangle; { editable via preferences     }
+  pad  : Array[0..13] of Byte;
+  reserved : Array[0..1] of Longint;          { terminator }
+ END;
+
+ pMonitorInfo = ^tMonitorInfo;
+ tMonitorInfo = record
+  Header : tQueryHeader;
+  Mspc   : pMonitorSpec;         { pointer to monitor specification  }
+  ViewPosition,                    { editable via preferences          }
+  ViewResolution : tPoint;          { standard monitor ticks-per-pixel  }
+  ViewPositionRange : tRectangle;   { fixed, hardware dependant }
+  TotalRows,                       { display height in scanlines       }
+  TotalColorClocks,                { scanline width in 280 ns units    }
+  MinRow        : Word;            { absolute minimum active scanline  }
+  Compatibility : Integer;           { how this coexists with others     }
+  pad : Array[0..31] of Byte;
+  MouseTicks    : tPoint;
+  DefaultViewPosition : tPoint;
+  PreferredModeID : ULONG;
+  reserved : Array[0..1] of ULONG;          { terminator }
+ END;
+
+{ monitor compatibility }
+
+CONST
+ MCOMPAT_MIXED =  0;       { can share display with other MCOMPAT_MIXED }
+ MCOMPAT_SELF  =  1;       { can share only within same monitor }
+ MCOMPAT_NOBODY= -1;       { only one viewport at a time }
+
+ DISPLAYNAMELEN = 32;
+
+Type
+ pNameInfo = ^tNameInfo;
+ tNameInfo = record
+  Header : tQueryHeader;
+  Name   : Array[0..DISPLAYNAMELEN-1] of Char;
+  reserved : Array[0..1] of ULONG;          { terminator }
+ END;
+
+
+{****************************************************************************}
+
+{ The following VecInfo structure is PRIVATE, for our use only
+ * Touch these, and burn! (V39)
+ }
+Type
+ pVecInfo = ^tVecInfo;
+ tVecInfo = record
+        Header  : tQueryHeader;
+        Vec     : Pointer;
+        Data    : Pointer;
+        vi_Type : WORD;               { Type in C Includes }
+        pad     : Array[0..2] of WORD;
+        reserved : Array[0..1] of ULONG;
+ end;
+
+
+CONST
+ VTAG_END_CM            = $00000000;
+ VTAG_CHROMAKEY_CLR     = $80000000;
+ VTAG_CHROMAKEY_SET     = $80000001;
+ VTAG_BITPLANEKEY_CLR   = $80000002;
+ VTAG_BITPLANEKEY_SET   = $80000003;
+ VTAG_BORDERBLANK_CLR   = $80000004;
+ VTAG_BORDERBLANK_SET   = $80000005;
+ VTAG_BORDERNOTRANS_CLR = $80000006;
+ VTAG_BORDERNOTRANS_SET = $80000007;
+ VTAG_CHROMA_PEN_CLR    = $80000008;
+ VTAG_CHROMA_PEN_SET    = $80000009;
+ VTAG_CHROMA_PLANE_SET  = $8000000A;
+ VTAG_ATTACH_CM_SET     = $8000000B;
+ VTAG_NEXTBUF_CM        = $8000000C;
+ VTAG_BATCH_CM_CLR      = $8000000D;
+ VTAG_BATCH_CM_SET      = $8000000E;
+ VTAG_NORMAL_DISP_GET   = $8000000F;
+ VTAG_NORMAL_DISP_SET   = $80000010;
+ VTAG_COERCE_DISP_GET   = $80000011;
+ VTAG_COERCE_DISP_SET   = $80000012;
+ VTAG_VIEWPORTEXTRA_GET = $80000013;
+ VTAG_VIEWPORTEXTRA_SET = $80000014;
+ VTAG_CHROMAKEY_GET     = $80000015;
+ VTAG_BITPLANEKEY_GET   = $80000016;
+ VTAG_BORDERBLANK_GET   = $80000017;
+ VTAG_BORDERNOTRANS_GET = $80000018;
+ VTAG_CHROMA_PEN_GET    = $80000019;
+ VTAG_CHROMA_PLANE_GET  = $8000001A;
+ VTAG_ATTACH_CM_GET     = $8000001B;
+ VTAG_BATCH_CM_GET      = $8000001C;
+ VTAG_BATCH_ITEMS_GET   = $8000001D;
+ VTAG_BATCH_ITEMS_SET   = $8000001E;
+ VTAG_BATCH_ITEMS_ADD   = $8000001F;
+ VTAG_VPMODEID_GET      = $80000020;
+ VTAG_VPMODEID_SET      = $80000021;
+ VTAG_VPMODEID_CLR      = $80000022;
+ VTAG_USERCLIP_GET      = $80000023;
+ VTAG_USERCLIP_SET      = $80000024;
+ VTAG_USERCLIP_CLR      = $80000025;
+{ The following tags are V39 specific. They will be ignored (returing error -3) by
+        earlier versions }
+ VTAG_PF1_BASE_GET             =  $80000026;
+ VTAG_PF2_BASE_GET             =  $80000027;
+ VTAG_SPEVEN_BASE_GET          =  $80000028;
+ VTAG_SPODD_BASE_GET           =  $80000029;
+ VTAG_PF1_BASE_SET             =  $8000002a;
+ VTAG_PF2_BASE_SET             =  $8000002b;
+ VTAG_SPEVEN_BASE_SET          =  $8000002c;
+ VTAG_SPODD_BASE_SET           =  $8000002d;
+ VTAG_BORDERSPRITE_GET         =  $8000002e;
+ VTAG_BORDERSPRITE_SET         =  $8000002f;
+ VTAG_BORDERSPRITE_CLR         =  $80000030;
+ VTAG_SPRITERESN_SET           =  $80000031;
+ VTAG_SPRITERESN_GET           =  $80000032;
+ VTAG_PF1_TO_SPRITEPRI_SET     =  $80000033;
+ VTAG_PF1_TO_SPRITEPRI_GET     =  $80000034;
+ VTAG_PF2_TO_SPRITEPRI_SET     =  $80000035;
+ VTAG_PF2_TO_SPRITEPRI_GET     =  $80000036;
+ VTAG_IMMEDIATE                =  $80000037;
+ VTAG_FULLPALETTE_SET          =  $80000038;
+ VTAG_FULLPALETTE_GET          =  $80000039;
+ VTAG_FULLPALETTE_CLR          =  $8000003A;
+ VTAG_DEFSPRITERESN_SET        =  $8000003B;
+ VTAG_DEFSPRITERESN_GET        =  $8000003C;
+
+{ all the following tags follow the new, rational standard for videocontrol tags:
+ * VC_xxx,state         set the state of attribute 'xxx' to value 'state'
+ * VC_xxx_QUERY,&var    get the state of attribute 'xxx' and store it into the longword
+ *                      pointed to by &var.
+ *
+ * The following are new for V40:
+ }
+
+ VC_IntermediateCLUpdate       =  $80000080;
+        { default=true. When set graphics will update the intermediate copper
+         * lists on color changes, etc. When false, it won't, and will be faster.
+         }
+ VC_IntermediateCLUpdate_Query =  $80000081;
+
+ VC_NoColorPaletteLoad         =  $80000082;
+        { default = false. When set, graphics will only load color 0
+         * for this ViewPort, and so the ViewPort's colors will come
+         * from the previous ViewPort's.
+         *
+         * NB - Using this tag and VTAG_FULLPALETTE_SET together is undefined.
+         }
+ VC_NoColorPaletteLoad_Query   =  $80000083;
+
+ VC_DUALPF_Disable             =  $80000084;
+        { default = false. When this flag is set, the dual-pf bit
+           in Dual-Playfield screens will be turned off. Even bitplanes
+           will still come from the first BitMap and odd bitplanes
+           from the second BitMap, and both R[xy]Offsets will be
+           considered. This can be used (with appropriate palette
+           selection) for cross-fades between differently scrolling
+           images.
+           When this flag is turned on, colors will be loaded for
+           the viewport as if it were a single viewport of depth
+           depth1+depth2 }
+ VC_DUALPF_Disable_Query       =  $80000085;
+
+
+const
+
+    SPRITE_ATTACHED     = $80;
+
+type
+
+    pSimpleSprite = ^tSimpleSprite;
+    tSimpleSprite = record
+        posctldata      : Pointer;
+        height          : Word;
+        x,y             : Word;        { current position }
+        num             : Word;
+    end;
+
+    pExtSprite = ^tExtSprite;
+    tExtSprite = record
+        es_SimpleSprite : tSimpleSprite;         { conventional simple sprite structure }
+        es_wordwidth    : WORD;                 { graphics use only, subject to change }
+        es_flags        : WORD;                 { graphics use only, subject to change }
+    end;
+
+const
+{ tags for AllocSpriteData() }
+ SPRITEA_Width          = $81000000;
+ SPRITEA_XReplication   = $81000002;
+ SPRITEA_YReplication   = $81000004;
+ SPRITEA_OutputHeight   = $81000006;
+ SPRITEA_Attached       = $81000008;
+ SPRITEA_OldDataFormat  = $8100000a;      { MUST pass in outputheight if using this tag }
+
+{ tags for GetExtSprite() }
+ GSTAG_SPRITE_NUM = $82000020;
+ GSTAG_ATTACHED   = $82000022;
+ GSTAG_SOFTSPRITE = $82000024;
+
+{ tags valid for either GetExtSprite or ChangeExtSprite }
+ GSTAG_SCANDOUBLED     =  $83000000;      { request "NTSC-Like" height if possible. }
+
+
+Type
+    pBitScaleArgs = ^tBitScaleArgs;
+    tBitScaleArgs = record
+    bsa_SrcX, bsa_SrcY,                 { source origin }
+    bsa_SrcWidth, bsa_SrcHeight,        { source size }
+    bsa_XSrcFactor, bsa_YSrcFactor,     { scale factor denominators }
+    bsa_DestX, bsa_DestY,               { destination origin }
+    bsa_DestWidth, bsa_DestHeight,      { destination size result }
+    bsa_XDestFactor, bsa_YDestFactor : Word;   { scale factor numerators }
+    bsa_SrcBitMap,                           { source BitMap }
+    bsa_DestBitMap : pBitMap;              { destination BitMap }
+    bsa_Flags   : ULONG;              { reserved.  Must be zero! }
+    bsa_XDDA, bsa_YDDA : Word;         { reserved }
+    bsa_Reserved1,
+    bsa_Reserved2 : Longint;
+   END;
+
+  {    tag definitions for GetRPAttr, SetRPAttr     }
+
+const
+ RPTAG_Font            =  $80000000;      { get/set font }
+ RPTAG_APen            =  $80000002;      { get/set apen }
+ RPTAG_BPen            =  $80000003;      { get/set bpen }
+ RPTAG_DrMd            =  $80000004;      { get/set draw mode }
+ RPTAG_OutlinePen      =  $80000005;      { get/set outline pen. corrected case. }
+ RPTAG_WriteMask       =  $80000006;      { get/set WriteMask }
+ RPTAG_MaxPen          =  $80000007;      { get/set maxpen }
+
+ RPTAG_DrawBounds      =  $80000008;      { get only rastport draw bounds. pass &rect }
+
+
+
+
+TYPE
+
+ pRegionRectangle = ^tRegionRectangle;
+ tRegionRectangle = record
+    Next, Prev  : pRegionRectangle;
+    bounds      : tRectangle;
+ END;
+
+ pRegion = ^tRegion;
+ tRegion = record
+    bounds      : tRectangle;
+    RegionRectangle  : pRegionRectangle;
+ END;
+
+type
+
+    pGfxBase = ^tGfxBase;
+    tGfxBase = record
+        LibNode         : tLibrary;
+        ActiView        : pView;      { ViewPtr }
+        copinit         : pcopinit; { (copinitptr) ptr to copper start up list }
+        cia             : Pointer;      { for 8520 resource use }
+        blitter         : Pointer;      { for future blitter resource use }
+        LOFlist         : Pointer;
+        SHFlist         : Pointer;
+        blthd,
+        blttl           : pbltnode;
+        bsblthd,
+        bsblttl         : pbltnode;      { Previous four are (bltnodeptr) }
+        vbsrv,
+        timsrv,
+        bltsrv          : tInterrupt;
+        TextFonts       : tList;
+        DefaultFont     : pTextFont;      { TextFontPtr }
+        Modes           : Word;        { copy of current first bplcon0 }
+        VBlank          : Shortint;
+        Debug           : Shortint;
+        BeamSync        : Integer;
+        system_bplcon0  : Integer; { it is ored into each bplcon0 for display }
+        SpriteReserved  : Byte;
+        bytereserved    : Byte;
+        Flags           : Word;
+        BlitLock        : Integer;
+        BlitNest        : Integer;
+
+        BlitWaitQ       : tList;
+        BlitOwner       : pTask;      { TaskPtr }
+        TOF_WaitQ       : tList;
+        DisplayFlags    : Word;        { NTSC PAL GENLOC etc}
+
+                { Display flags are determined at power on }
+
+        SimpleSprites   : Pointer;      { SimpleSpritePtr ptr }
+        MaxDisplayRow   : Word;        { hardware stuff, do not use }
+        MaxDisplayColumn : Word;       { hardware stuff, do not use }
+        NormalDisplayRows : Word;
+        NormalDisplayColumns : Word;
+
+        { the following are for standard non interlace, 1/2 wb width }
+
+        NormalDPMX      : Word;        { Dots per meter on display }
+        NormalDPMY      : Word;        { Dots per meter on display }
+        LastChanceMemory : pSignalSemaphore;     { SignalSemaphorePtr }
+        LCMptr          : Pointer;
+        MicrosPerLine   : Word;        { 256 time usec/line }
+        MinDisplayColumn : Word;
+        ChipRevBits0    : Byte;
+        MemType         : Byte;
+        crb_reserved  :  Array[0..3] of Byte;
+        monitor_id  : Word;             { normally null }
+        hedley  : Array[0..7] of ULONG;
+        hedley_sprites  : Array[0..7] of ULONG;     { sprite ptrs for intuition mouse }
+        hedley_sprites1 : Array[0..7] of ULONG;            { sprite ptrs for intuition mouse }
+        hedley_count    : Integer;
+        hedley_flags    : Word;
+        hedley_tmp      : Integer;
+        hash_table      : Pointer;
+        current_tot_rows : Word;
+        current_tot_cclks : Word;
+        hedley_hint     : Byte;
+        hedley_hint2    : Byte;
+        nreserved       : Array[0..3] of ULONG;
+        a2024_sync_raster : Pointer;
+        control_delta_pal : Word;
+        control_delta_ntsc : Word;
+        current_monitor : pMonitorSpec;
+        MonitorList     : tList;
+        default_monitor : pMonitorSpec;
+        MonitorListSemaphore : pSignalSemaphore;
+        DisplayInfoDataBase : Pointer;
+        TopLine      : Word;
+        ActiViewCprSemaphore : pSignalSemaphore;
+        UtilityBase  : Pointer;           { for hook AND tag utilities   }
+        ExecBase     : Pointer;              { to link with rom.lib }
+        bwshifts     : Pointer;
+        StrtFetchMasks,
+        StopFetchMasks,
+        Overrun,
+        RealStops    : Pointer;
+        SpriteWidth,                    { current width (in words) of sprites }
+        SpriteFMode  : WORD;            { current sprite fmode bits    }
+        SoftSprites,                    { bit mask of size change knowledgeable sprites }
+        arraywidth   : Shortint;
+        DefaultSpriteWidth : WORD;      { what width intuition wants }
+        SprMoveDisable : Shortint;
+        WantChips,
+        BoardMemType,
+        Bugs         : Byte;
+        gb_LayersBase : Pointer;
+        ColorMask    : ULONG;
+        IVector,
+        IData        : Pointer;
+        SpecialCounter : ULONG;         { special for double buffering }
+        DBList       : Pointer;
+        MonitorFlags : WORD;
+        ScanDoubledSprites,
+        BP3Bits      : Byte;
+        MonitorVBlank  : tAnalogSignalInterval;
+        natural_monitor  : pMonitorSpec;
+        ProgData     : Pointer;
+        ExtSprites   : Byte;
+        pad3         : Byte;
+        GfxFlags     : WORD;
+        VBCounter    : ULONG;
+        HashTableSemaphore  : pSignalSemaphore;
+        HWEmul       : Array[0..8] of Pointer;
+    end;
+
+const
+
+    NTSC        = 1;
+    GENLOC      = 2;
+    PAL         = 4;
+    TODA_SAFE   = 8;
+
+    BLITMSG_FAULT = 4;
+
+{ bits defs for ChipRevBits }
+   GFXB_BIG_BLITS = 0 ;
+   GFXB_HR_AGNUS  = 0 ;
+   GFXB_HR_DENISE = 1 ;
+   GFXB_AA_ALICE  = 2 ;
+   GFXB_AA_LISA   = 3 ;
+   GFXB_AA_MLISA  = 4 ;      { internal use only. }
+
+   GFXF_BIG_BLITS = 1 ;
+   GFXF_HR_AGNUS  = 1 ;
+   GFXF_HR_DENISE = 2 ;
+   GFXF_AA_ALICE  = 4 ;
+   GFXF_AA_LISA   = 8 ;
+   GFXF_AA_MLISA  = 16;      { internal use only }
+
+{ Pass ONE of these to SetChipRev() }
+   SETCHIPREV_A   = GFXF_HR_AGNUS;
+   SETCHIPREV_ECS = (GFXF_HR_AGNUS OR GFXF_HR_DENISE);
+   SETCHIPREV_AA  = (GFXF_AA_ALICE OR GFXF_AA_LISA OR SETCHIPREV_ECS);
+   SETCHIPREV_BEST= $ffffffff;
+
+{ memory type }
+   BUS_16         = 0;
+   NML_CAS        = 0;
+   BUS_32         = 1;
+   DBL_CAS        = 2;
+   BANDWIDTH_1X   = (BUS_16 OR NML_CAS);
+   BANDWIDTH_2XNML= BUS_32;
+   BANDWIDTH_2XDBL= DBL_CAS;
+   BANDWIDTH_4X   = (BUS_32 OR DBL_CAS);
+
+{ GfxFlags (private) }
+   NEW_DATABASE   = 1;
+
+   GRAPHICSNAME   : PChar  = 'graphics.library';
+
+
+var
+    GfxBase : pLibrary;
+
+PROCEDURE AddAnimOb(anOb : pAnimOb; anKey : ppAnimOb; rp : pRastPort);
+PROCEDURE AddBob(bob : pBob; rp : pRastPort);
+PROCEDURE AddFont(textFont : pTextFont);
+PROCEDURE AddVSprite(vSprite : pVSprite; rp : pRastPort);
+FUNCTION AllocBitMap(sizex : ULONG; sizey : ULONG; depth : ULONG; flags : ULONG; friend_bitmap : pBitMap) : pBitMap;
+FUNCTION AllocDBufInfo(vp : pViewPort) : pDBufInfo;
+FUNCTION AllocRaster(width : ULONG; height : ULONG) : pCHAR;
+FUNCTION AllocSpriteDataA(bm : pBitMap; tags : pTagItem) : pExtSprite;
+PROCEDURE AndRectRegion(region : pRegion; rectangle : pRectangle);
+FUNCTION AndRegionRegion(srcRegion : pRegion; destRegion : pRegion) : BOOLEAN;
+PROCEDURE Animate(anKey : ppAnimOb; rp : pRastPort);
+FUNCTION AreaDraw(rp : pRastPort; x : LONGINT; y : LONGINT) : LONGINT;
+FUNCTION AreaEllipse(rp : pRastPort; xCenter : LONGINT; yCenter : LONGINT; a : LONGINT; b : LONGINT) : LONGINT;
+FUNCTION AreaEnd(rp : pRastPort) : LONGINT;
+FUNCTION AreaMove(rp : pRastPort; x : LONGINT; y : LONGINT) : LONGINT;
+PROCEDURE AskFont(rp : pRastPort; textAttr : pTextAttr);
+FUNCTION AskSoftStyle(rp : pRastPort) : ULONG;
+FUNCTION AttachPalExtra(cm : pColorMap; vp : pViewPort) : LONGINT;
+FUNCTION AttemptLockLayerRom(layer : pLayer) : BOOLEAN;
+FUNCTION BestModeIDA(tags : pTagItem) : ULONG;
+PROCEDURE BitMapScale(bitScaleArgs : pBitScaleArgs);
+FUNCTION BltBitMap(srcBitMap : pBitMap; xSrc : LONGINT; ySrc : LONGINT; destBitMap : pBitMap; xDest : LONGINT; yDest : LONGINT; xSize : LONGINT; ySize : LONGINT; minterm : ULONG; mask : ULONG; tempA : pCHAR) : LONGINT;
+PROCEDURE BltBitMapRastPort(srcBitMap : pBitMap; xSrc : LONGINT; ySrc : LONGINT; destRP : pRastPort; xDest : LONGINT; yDest : LONGINT; xSize : LONGINT; ySize : LONGINT; minterm : ULONG);
+PROCEDURE BltClear(memBlock : pCHAR; byteCount : ULONG; flags : ULONG);
+PROCEDURE BltMaskBitMapRastPort(srcBitMap : pBitMap; xSrc : LONGINT; ySrc : LONGINT; destRP : pRastPort; xDest : LONGINT; yDest : LONGINT; xSize : LONGINT; ySize : LONGINT; minterm : ULONG; bltMask : pCHAR);
+PROCEDURE BltPattern(rp : pRastPort; mask : pCHAR; xMin : LONGINT; yMin : LONGINT; xMax : LONGINT; yMax : LONGINT; maskBPR : ULONG);
+PROCEDURE BltTemplate(source : pCHAR; xSrc : LONGINT; srcMod : LONGINT; destRP : pRastPort; xDest : LONGINT; yDest : LONGINT; xSize : LONGINT; ySize : LONGINT);
+FUNCTION CalcIVG(v : pView; vp : pViewPort) : WORD;
+PROCEDURE CBump(copList : pUCopList);
+FUNCTION ChangeExtSpriteA(vp : pViewPort; oldsprite : pExtSprite; newsprite : pExtSprite; tags : pTagItem) : LONGINT;
+PROCEDURE ChangeSprite(vp : pViewPort; sprite : pSimpleSprite; newData : pCHAR);
+PROCEDURE ChangeVPBitMap(vp : pViewPort; bm : pBitMap; db : pDBufInfo);
+PROCEDURE ClearEOL(rp : pRastPort);
+FUNCTION ClearRectRegion(region : pRegion; rectangle : pRectangle) : BOOLEAN;
+PROCEDURE ClearRegion(region : pRegion);
+PROCEDURE ClearScreen(rp : pRastPort);
+PROCEDURE ClipBlit(srcRP : pRastPort; xSrc : LONGINT; ySrc : LONGINT; destRP : pRastPort; xDest : LONGINT; yDest : LONGINT; xSize : LONGINT; ySize : LONGINT; minterm : ULONG);
+PROCEDURE CloseFont(textFont : pTextFont);
+FUNCTION CloseMonitor(monitorSpec : pMonitorSpec) : BOOLEAN;
+PROCEDURE CMove(copList : pUCopList; destination : POINTER; data : LONGINT);
+FUNCTION CoerceMode(vp : pViewPort; monitorid : ULONG; flags : ULONG) : ULONG;
+PROCEDURE CopySBitMap(layer : pLayer);
+PROCEDURE CWait(copList : pUCopList; v : LONGINT; h : LONGINT);
+PROCEDURE DisownBlitter;
+PROCEDURE DisposeRegion(region : pRegion);
+PROCEDURE DoCollision(rp : pRastPort);
+PROCEDURE Draw(rp : pRastPort; x : LONGINT; y : LONGINT);
+PROCEDURE DrawEllipse(rp : pRastPort; xCenter : LONGINT; yCenter : LONGINT; a : LONGINT; b : LONGINT);
+PROCEDURE DrawGList(rp : pRastPort; vp : pViewPort);
+PROCEDURE EraseRect(rp : pRastPort; xMin : LONGINT; yMin : LONGINT; xMax : LONGINT; yMax : LONGINT);
+FUNCTION ExtendFont(font : pTextFont; fontTags : pTagItem) : ULONG;
+FUNCTION FindColor(cm : pColorMap; r : ULONG; g : ULONG; b : ULONG; maxcolor : LONGINT) : LONGINT;
+FUNCTION FindDisplayInfo(displayID : ULONG) : POINTER;
+FUNCTION Flood(rp : pRastPort; mode : ULONG; x : LONGINT; y : LONGINT) : BOOLEAN;
+PROCEDURE FontExtent(font : pTextFont; fontExtent : pTextExtent);
+PROCEDURE FreeBitMap(bm : pBitMap);
+PROCEDURE FreeColorMap(colorMap : pColorMap);
+PROCEDURE FreeCopList(copList : pCopList);
+PROCEDURE FreeCprList(cprList : pcprlist);
+PROCEDURE FreeDBufInfo(dbi : pDBufInfo);
+PROCEDURE FreeGBuffers(anOb : pAnimOb; rp : pRastPort; flag : LONGINT);
+PROCEDURE FreeRaster(p : pCHAR; width : ULONG; height : ULONG);
+PROCEDURE FreeSprite(num : LONGINT);
+PROCEDURE FreeSpriteData(sp : pExtSprite);
+PROCEDURE FreeVPortCopLists(vp : pViewPort);
+FUNCTION GetAPen(rp : pRastPort) : ULONG;
+FUNCTION GetBitMapAttr(bm : pBitMap; attrnum : ULONG) : ULONG;
+FUNCTION GetBPen(rp : pRastPort) : ULONG;
+FUNCTION GetColorMap(entries : LONGINT) : pColorMap;
+FUNCTION GetDisplayInfoData(handle : POINTER; buf : pCHAR; size : ULONG; tagID : ULONG; displayID : ULONG) : ULONG;
+FUNCTION GetDrMd(rp : pRastPort) : ULONG;
+FUNCTION GetExtSpriteA(ss : pExtSprite; tags : pTagItem) : LONGINT;
+FUNCTION GetGBuffers(anOb : pAnimOb; rp : pRastPort; flag : LONGINT) : BOOLEAN;
+FUNCTION GetOutlinePen(rp : pRastPort) : ULONG;
+PROCEDURE GetRGB32(cm : pColorMap; firstcolor : ULONG; ncolors : ULONG; table : POINTER);
+FUNCTION GetRGB4(colorMap : pColorMap; entry : LONGINT) : ULONG;
+PROCEDURE GetRPAttrsA(rp : pRastPort; tags : pTagItem);
+FUNCTION GetSprite(sprite : pSimpleSprite; num : LONGINT) : INTEGER;
+FUNCTION GetVPModeID(vp : pViewPort) : LONGINT;
+PROCEDURE GfxAssociate(associateNode : POINTER; gfxNodePtr : POINTER);
+PROCEDURE GfxFree(gfxNodePtr : POINTER);
+FUNCTION GfxLookUp(associateNode : POINTER) : POINTER;
+FUNCTION GfxNew(gfxNodeType : ULONG) : POINTER;
+PROCEDURE InitArea(areaInfo : pAreaInfo; vectorBuffer : POINTER; maxVectors : LONGINT);
+PROCEDURE InitBitMap(bitMap : pBitMap; depth : LONGINT; width : LONGINT; height : LONGINT);
+PROCEDURE InitGels(head : pVSprite; tail : pVSprite; gelsInfo : pGelsInfo);
+PROCEDURE InitGMasks(anOb : pAnimOb);
+PROCEDURE InitMasks(vSprite : pVSprite);
+PROCEDURE InitRastPort(rp : pRastPort);
+FUNCTION InitTmpRas(tmpRas : pTmpRas; buffer : pCHAR; size : LONGINT) : pTmpRas;
+PROCEDURE InitView(view : pView);
+PROCEDURE InitVPort(vp : pViewPort);
+PROCEDURE LoadRGB32(vp : pViewPort; table : POINTER);
+PROCEDURE LoadRGB4(vp : pViewPort; colors : POINTER; count : LONGINT);
+PROCEDURE LoadView(view : pView);
+PROCEDURE LockLayerRom(layer : pLayer);
+FUNCTION MakeVPort(view : pView; vp : pViewPort) : ULONG;
+FUNCTION ModeNotAvailable(modeID : ULONG) : LONGINT;
+PROCEDURE Move(rp : pRastPort; x : LONGINT; y : LONGINT);
+PROCEDURE MoveSprite(vp : pViewPort; sprite : pSimpleSprite; x : LONGINT; y : LONGINT);
+FUNCTION MrgCop(view : pView) : ULONG;
+FUNCTION NewRegion : pRegion;
+FUNCTION NextDisplayInfo(displayID : ULONG) : ULONG;
+FUNCTION ObtainBestPenA(cm : pColorMap; r : ULONG; g : ULONG; b : ULONG; tags : pTagItem) : LONGINT;
+FUNCTION ObtainPen(cm : pColorMap; n : ULONG; r : ULONG; g : ULONG; b : ULONG; f : LONGINT) : ULONG;
+FUNCTION OpenFont(textAttr : pTextAttr) : pTextFont;
+FUNCTION OpenMonitor(monitorName : pCHAR; displayID : ULONG) : pMonitorSpec;
+FUNCTION OrRectRegion(region : pRegion; rectangle : pRectangle) : BOOLEAN;
+FUNCTION OrRegionRegion(srcRegion : pRegion; destRegion : pRegion) : BOOLEAN;
+PROCEDURE OwnBlitter;
+PROCEDURE PolyDraw(rp : pRastPort; count : LONGINT; polyTable : POINTER);
+PROCEDURE QBlit(blit : pbltnode);
+PROCEDURE QBSBlit(blit : pbltnode);
+FUNCTION ReadPixel(rp : pRastPort; x : LONGINT; y : LONGINT) : ULONG;
+FUNCTION ReadPixelArray8(rp : pRastPort; xstart : ULONG; ystart : ULONG; xstop : ULONG; ystop : ULONG; array_ : pCHAR; temprp : pRastPort) : LONGINT;
+FUNCTION ReadPixelLine8(rp : pRastPort; xstart : ULONG; ystart : ULONG; width : ULONG; array_ : pCHAR; tempRP : pRastPort) : LONGINT;
+PROCEDURE RectFill(rp : pRastPort; xMin : LONGINT; yMin : LONGINT; xMax : LONGINT; yMax : LONGINT);
+PROCEDURE ReleasePen(cm : pColorMap; n : ULONG);
+PROCEDURE RemFont(textFont : pTextFont);
+PROCEDURE RemIBob(bob : pBob; rp : pRastPort; vp : pViewPort);
+PROCEDURE RemVSprite(vSprite : pVSprite);
+FUNCTION ScalerDiv(factor : ULONG; numerator : ULONG; denominator : ULONG) : WORD;
+PROCEDURE ScrollRaster(rp : pRastPort; dx : LONGINT; dy : LONGINT; xMin : LONGINT; yMin : LONGINT; xMax : LONGINT; yMax : LONGINT);
+PROCEDURE ScrollRasterBF(rp : pRastPort; dx : LONGINT; dy : LONGINT; xMin : LONGINT; yMin : LONGINT; xMax : LONGINT; yMax : LONGINT);
+PROCEDURE ScrollVPort(vp : pViewPort);
+PROCEDURE SetABPenDrMd(rp : pRastPort; apen : ULONG; bpen : ULONG; drawmode : ULONG);
+PROCEDURE SetAPen(rp : pRastPort; pen : ULONG);
+PROCEDURE SetBPen(rp : pRastPort; pen : ULONG);
+FUNCTION SetChipRev(want : ULONG) : ULONG;
+PROCEDURE SetCollision(num : ULONG; routine : tPROCEDURE; gelsInfo : pGelsInfo);
+PROCEDURE SetDrMd(rp : pRastPort; drawMode : ULONG);
+FUNCTION SetFont(rp : pRastPort; textFont : pTextFont) : LONGINT;
+PROCEDURE SetMaxPen(rp : pRastPort; maxpen : ULONG);
+FUNCTION SetOutlinePen(rp : pRastPort; pen : ULONG) : ULONG;
+PROCEDURE SetRast(rp : pRastPort; pen : ULONG);
+PROCEDURE SetRGB32(vp : pViewPort; n : ULONG; r : ULONG; g : ULONG; b : ULONG);
+PROCEDURE SetRGB32CM(cm : pColorMap; n : ULONG; r : ULONG; g : ULONG; b : ULONG);
+PROCEDURE SetRGB4(vp : pViewPort; index : LONGINT; red : ULONG; green : ULONG; blue : ULONG);
+PROCEDURE SetRGB4CM(colorMap : pColorMap; index : LONGINT; red : ULONG; green : ULONG; blue : ULONG);
+PROCEDURE SetRPAttrsA(rp : pRastPort; tags : pTagItem);
+FUNCTION SetSoftStyle(rp : pRastPort; style : ULONG; enable : ULONG) : ULONG;
+FUNCTION SetWriteMask(rp : pRastPort; msk : ULONG) : ULONG;
+PROCEDURE SortGList(rp : pRastPort);
+PROCEDURE StripFont(font : pTextFont);
+PROCEDURE SyncSBitMap(layer : pLayer);
+FUNCTION Text(rp : pRastPort; string_ : pCHAR; count : ULONG) : LONGINT;
+FUNCTION TextExtent(rp : pRastPort; string_ : pCHAR; count : LONGINT; textExtent : pTextExtent) : INTEGER;
+FUNCTION TextFit(rp : pRastPort; string_ : pCHAR; strLen : ULONG; textExtent : pTextExtent; constrainingExtent : pTextExtent; strDirection : LONGINT; constrainingBitWidth : ULONG; constrainingBitHeight : ULONG) : ULONG;
+FUNCTION TextLength(rp : pRastPort; string_ : pCHAR; count : ULONG) : INTEGER;
+FUNCTION UCopperListInit(uCopList : pUCopList; n : LONGINT) : pCopList;
+PROCEDURE UnlockLayerRom(layer : pLayer);
+FUNCTION VBeamPos : LONGINT;
+FUNCTION VideoControl(colorMap : pColorMap; tagarray : pTagItem) : BOOLEAN;
+PROCEDURE WaitBlit;
+PROCEDURE WaitBOVP(vp : pViewPort);
+PROCEDURE WaitTOF;
+FUNCTION WeighTAMatch(reqTextAttr : pTextAttr; targetTextAttr : pTextAttr; targetTags : pTagItem) : INTEGER;
+PROCEDURE WriteChunkyPixels(rp : pRastPort; xstart : ULONG; ystart : ULONG; xstop : ULONG; ystop : ULONG; array_ : pCHAR; bytesperrow : LONGINT);
+FUNCTION WritePixel(rp : pRastPort; x : LONGINT; y : LONGINT) : LONGINT;
+FUNCTION WritePixelArray8(rp : pRastPort; xstart : ULONG; ystart : ULONG; xstop : ULONG; ystop : ULONG; array_ : pCHAR; temprp : pRastPort) : LONGINT;
+FUNCTION WritePixelLine8(rp : pRastPort; xstart : ULONG; ystart : ULONG; width : ULONG; array_ : pCHAR; tempRP : pRastPort) : LONGINT;
+FUNCTION XorRectRegion(region : pRegion; rectangle : pRectangle) : BOOLEAN;
+FUNCTION XorRegionRegion(srcRegion : pRegion; destRegion : pRegion) : BOOLEAN;
+
+{ gfxmacros }
+
+PROCEDURE BNDRYOFF (w: pRastPort);
+PROCEDURE InitAnimate (animkey: ppAnimOb);
+PROCEDURE SetAfPt(w: pRastPort;p: Pointer; n: Byte);
+PROCEDURE SetDrPt(w: pRastPort;p: Word);
+PROCEDURE SetOPen(w: pRastPort;c: Byte);
+PROCEDURE SetWrMsk(w: pRastPort; m: Byte);
+
+PROCEDURE SafeSetOutlinePen(w : pRastPort; c : byte);
+PROCEDURE SafeSetWriteMask( w : pRastPort ; m : Integer ) ;
+
+PROCEDURE OFF_DISPLAY (cust: pCustom);
+PROCEDURE ON_DISPLAY (cust: pCustom);
+PROCEDURE OFF_SPRITE (cust: pCustom);
+PROCEDURE ON_SPRITE (cust: pCustom);
+PROCEDURE OFF_VBLANK (cust: pCustom);
+PROCEDURE ON_VBLANK (cust: pCustom);
+
+
+IMPLEMENTATION
+
+PROCEDURE BNDRYOFF (w: pRastPort);
+BEGIN
+    WITH w^ DO BEGIN
+        Flags := Flags AND (NOT AREAOUTLINE);
+    END;
+END;
+
+PROCEDURE InitAnimate (animkey: ppAnimOb);
+BEGIN
+    animkey^ := NIL;
+END;
+
+PROCEDURE SetAfPt(w: pRastPort;p: Pointer; n: Byte);
+BEGIN
+    WITH w^ DO
+    BEGIN
+        AreaPtrn := p;
+        AreaPtSz := n;
+    END;
+END;
+
+PROCEDURE SetDrPt(w: pRastPort;p: Word);
+BEGIN
+    WITH w^ DO
+    BEGIN
+        LinePtrn    := p;
+        Flags       := Flags OR FRST_DOT;
+        linpatcnt   := 15;
+    END;
+END;
+
+PROCEDURE SetOPen(w: pRastPort;c: Byte);
+BEGIN
+    WITH w^ DO
+    BEGIN
+        AOlPen  := c;
+        Flags   := Flags OR AREAOUTLINE;
+    END;
+END;
+
+{ This FUNCTION is fine, but FOR OS39 the SetWriteMask() gfx FUNCTION
+  should be prefered because it SHOULD operate WITH gfx boards as well.
+  At least I hope it does.... }
+PROCEDURE SetWrMsk(w: pRastPort; m: Byte);
+BEGIN
+    w^.Mask := m;
+END;
+
+PROCEDURE SafeSetOutlinePen(w : pRastPort; c : byte);
+begin
+    IF pGfxBase(GfxBase)^.LibNode.Lib_Version < 39 THEN begin
+        w^.AOlPen := c;
+        w^.Flags := w^.Flags OR AREAOUTLINE;
+    END ELSE begin
+        c := SetOutlinePen(w,c);
+    END;
+END;
+
+PROCEDURE SafeSetWriteMask( w : pRastPort ; m : Integer ) ;
+  VAR x : INTEGER ;
+BEGIN
+  IF pGfxBase(GfxBase)^.LibNode.Lib_Version < 39 THEN w^.Mask := BYTE(m)
+  ELSE x := SetWriteMask( w, m );
+END;
+
+PROCEDURE OFF_DISPLAY (cust: pCustom);
+BEGIN
+    cust^.dmacon := BITCLR OR DMAF_RASTER;
+END;
+
+PROCEDURE ON_DISPLAY (cust: pCustom);
+BEGIN
+    cust^.dmacon := BITSET OR DMAF_RASTER;
+END;
+
+PROCEDURE OFF_SPRITE (cust: pCustom);
+BEGIN
+    cust^.dmacon := BITCLR OR DMAF_SPRITE;
+END;
+
+PROCEDURE ON_SPRITE (cust: pCustom);
+BEGIN
+    cust^.dmacon := BITSET OR DMAF_SPRITE;
+END;
+
+PROCEDURE OFF_VBLANK (cust: pCustom);
+BEGIN
+    cust^.intena := BITCLR OR INTF_VERTB;
+END;
+
+PROCEDURE ON_VBLANK (cust: pCustom);
+BEGIN
+    cust^.intena := BITSET OR INTF_VERTB;
+END;
+
+PROCEDURE AddAnimOb(anOb : pAnimOb; anKey : ppAnimOb; rp : pRastPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L anOb,A0
+    MOVEA.L anKey,A1
+    MOVEA.L rp,A2
+    MOVEA.L GfxBase,A6
+    JSR -156(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE AddBob(bob : pBob; rp : pRastPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L bob,A0
+    MOVEA.L rp,A1
+    MOVEA.L GfxBase,A6
+    JSR -096(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE AddFont(textFont : pTextFont);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L textFont,A1
+    MOVEA.L GfxBase,A6
+    JSR -480(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE AddVSprite(vSprite : pVSprite; rp : pRastPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vSprite,A0
+    MOVEA.L rp,A1
+    MOVEA.L GfxBase,A6
+    JSR -102(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION AllocBitMap(sizex : ULONG; sizey : ULONG; depth : ULONG; flags : ULONG; friend_bitmap : pBitMap) : pBitMap;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  sizex,D0
+    MOVE.L  sizey,D1
+    MOVE.L  depth,D2
+    MOVE.L  flags,D3
+    MOVEA.L friend_bitmap,A0
+    MOVEA.L GfxBase,A6
+    JSR -918(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AllocDBufInfo(vp : pViewPort) : pDBufInfo;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vp,A0
+    MOVEA.L GfxBase,A6
+    JSR -966(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AllocRaster(width : ULONG; height : ULONG) : pCHAR;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  width,D0
+    MOVE.L  height,D1
+    MOVEA.L GfxBase,A6
+    JSR -492(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AllocSpriteDataA(bm : pBitMap; tags : pTagItem) : pExtSprite;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L bm,A2
+    MOVEA.L tags,A1
+    MOVEA.L GfxBase,A6
+    JSR -1020(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE AndRectRegion(region : pRegion; rectangle : pRectangle);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L region,A0
+    MOVEA.L rectangle,A1
+    MOVEA.L GfxBase,A6
+    JSR -504(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION AndRegionRegion(srcRegion : pRegion; destRegion : pRegion) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L srcRegion,A0
+    MOVEA.L destRegion,A1
+    MOVEA.L GfxBase,A6
+    JSR -624(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE Animate(anKey : ppAnimOb; rp : pRastPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L anKey,A0
+    MOVEA.L rp,A1
+    MOVEA.L GfxBase,A6
+    JSR -162(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION AreaDraw(rp : pRastPort; x : LONGINT; y : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  x,D0
+    MOVE.L  y,D1
+    MOVEA.L GfxBase,A6
+    JSR -258(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AreaEllipse(rp : pRastPort; xCenter : LONGINT; yCenter : LONGINT; a : LONGINT; b : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  xCenter,D0
+    MOVE.L  yCenter,D1
+    MOVE.L  a,D2
+    MOVE.L  b,D3
+    MOVEA.L GfxBase,A6
+    JSR -186(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AreaEnd(rp : pRastPort) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVEA.L GfxBase,A6
+    JSR -264(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AreaMove(rp : pRastPort; x : LONGINT; y : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  x,D0
+    MOVE.L  y,D1
+    MOVEA.L GfxBase,A6
+    JSR -252(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE AskFont(rp : pRastPort; textAttr : pTextAttr);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVEA.L textAttr,A0
+    MOVEA.L GfxBase,A6
+    JSR -474(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION AskSoftStyle(rp : pRastPort) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVEA.L GfxBase,A6
+    JSR -084(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AttachPalExtra(cm : pColorMap; vp : pViewPort) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cm,A0
+    MOVEA.L vp,A1
+    MOVEA.L GfxBase,A6
+    JSR -834(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AttemptLockLayerRom(layer : pLayer) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L layer,A5
+    MOVEA.L GfxBase,A6
+    JSR -654(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION BestModeIDA(tags : pTagItem) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L tags,A0
+    MOVEA.L GfxBase,A6
+    JSR -1050(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE BitMapScale(bitScaleArgs : pBitScaleArgs);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L bitScaleArgs,A0
+    MOVEA.L GfxBase,A6
+    JSR -678(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION BltBitMap(srcBitMap : pBitMap; xSrc : LONGINT; ySrc : LONGINT; destBitMap : pBitMap; xDest : LONGINT; yDest : LONGINT; xSize : LONGINT; ySize : LONGINT; minterm : ULONG; mask : ULONG; tempA : pCHAR) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L srcBitMap,A0
+    MOVE.L  xSrc,D0
+    MOVE.L  ySrc,D1
+    MOVEA.L destBitMap,A1
+    MOVE.L  xDest,D2
+    MOVE.L  yDest,D3
+    MOVE.L  xSize,D4
+    MOVE.L  ySize,D5
+    MOVE.L  minterm,D6
+    MOVE.L  mask,D7
+    MOVEA.L tempA,A2
+    MOVEA.L GfxBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE BltBitMapRastPort(srcBitMap : pBitMap; xSrc : LONGINT; ySrc : LONGINT; destRP : pRastPort; xDest : LONGINT; yDest : LONGINT; xSize : LONGINT; ySize : LONGINT; minterm : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L srcBitMap,A0
+    MOVE.L  xSrc,D0
+    MOVE.L  ySrc,D1
+    MOVEA.L destRP,A1
+    MOVE.L  xDest,D2
+    MOVE.L  yDest,D3
+    MOVE.L  xSize,D4
+    MOVE.L  ySize,D5
+    MOVE.L  minterm,D6
+    MOVEA.L GfxBase,A6
+    JSR -606(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE BltClear(memBlock : pCHAR; byteCount : ULONG; flags : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L memBlock,A1
+    MOVE.L  byteCount,D0
+    MOVE.L  flags,D1
+    MOVEA.L GfxBase,A6
+    JSR -300(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE BltMaskBitMapRastPort(srcBitMap : pBitMap; xSrc : LONGINT; ySrc : LONGINT; destRP : pRastPort; xDest : LONGINT; yDest : LONGINT; xSize : LONGINT; ySize : LONGINT; minterm : ULONG; bltMask : pCHAR);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L srcBitMap,A0
+    MOVE.L  xSrc,D0
+    MOVE.L  ySrc,D1
+    MOVEA.L destRP,A1
+    MOVE.L  xDest,D2
+    MOVE.L  yDest,D3
+    MOVE.L  xSize,D4
+    MOVE.L  ySize,D5
+    MOVE.L  minterm,D6
+    MOVEA.L bltMask,A2
+    MOVEA.L GfxBase,A6
+    JSR -636(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE BltPattern(rp : pRastPort; mask : pCHAR; xMin : LONGINT; yMin : LONGINT; xMax : LONGINT; yMax : LONGINT; maskBPR : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVEA.L mask,A0
+    MOVE.L  xMin,D0
+    MOVE.L  yMin,D1
+    MOVE.L  xMax,D2
+    MOVE.L  yMax,D3
+    MOVE.L  maskBPR,D4
+    MOVEA.L GfxBase,A6
+    JSR -312(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE BltTemplate(source : pCHAR; xSrc : LONGINT; srcMod : LONGINT; destRP : pRastPort; xDest : LONGINT; yDest : LONGINT; xSize : LONGINT; ySize : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L source,A0
+    MOVE.L  xSrc,D0
+    MOVE.L  srcMod,D1
+    MOVEA.L destRP,A1
+    MOVE.L  xDest,D2
+    MOVE.L  yDest,D3
+    MOVE.L  xSize,D4
+    MOVE.L  ySize,D5
+    MOVEA.L GfxBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION CalcIVG(v : pView; vp : pViewPort) : WORD;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L v,A0
+    MOVEA.L vp,A1
+    MOVEA.L GfxBase,A6
+    JSR -828(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE CBump(copList : pUCopList);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L copList,A1
+    MOVEA.L GfxBase,A6
+    JSR -366(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION ChangeExtSpriteA(vp : pViewPort; oldsprite : pExtSprite; newsprite : pExtSprite; tags : pTagItem) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vp,A0
+    MOVEA.L oldsprite,A1
+    MOVEA.L newsprite,A2
+    MOVEA.L tags,A3
+    MOVEA.L GfxBase,A6
+    JSR -1026(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ChangeSprite(vp : pViewPort; sprite : pSimpleSprite; newData : pCHAR);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vp,A0
+    MOVEA.L sprite,A1
+    MOVEA.L newData,A2
+    MOVEA.L GfxBase,A6
+    JSR -420(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ChangeVPBitMap(vp : pViewPort; bm : pBitMap; db : pDBufInfo);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vp,A0
+    MOVEA.L bm,A1
+    MOVEA.L db,A2
+    MOVEA.L GfxBase,A6
+    JSR -942(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ClearEOL(rp : pRastPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVEA.L GfxBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION ClearRectRegion(region : pRegion; rectangle : pRectangle) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L region,A0
+    MOVEA.L rectangle,A1
+    MOVEA.L GfxBase,A6
+    JSR -522(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ClearRegion(region : pRegion);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L region,A0
+    MOVEA.L GfxBase,A6
+    JSR -528(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ClearScreen(rp : pRastPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVEA.L GfxBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ClipBlit(srcRP : pRastPort; xSrc : LONGINT; ySrc : LONGINT; destRP : pRastPort; xDest : LONGINT; yDest : LONGINT; xSize : LONGINT; ySize : LONGINT; minterm : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L srcRP,A0
+    MOVE.L  xSrc,D0
+    MOVE.L  ySrc,D1
+    MOVEA.L destRP,A1
+    MOVE.L  xDest,D2
+    MOVE.L  yDest,D3
+    MOVE.L  xSize,D4
+    MOVE.L  ySize,D5
+    MOVE.L  minterm,D6
+    MOVEA.L GfxBase,A6
+    JSR -552(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE CloseFont(textFont : pTextFont);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L textFont,A1
+    MOVEA.L GfxBase,A6
+    JSR -078(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION CloseMonitor(monitorSpec : pMonitorSpec) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L monitorSpec,A0
+    MOVEA.L GfxBase,A6
+    JSR -720(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE CMove(copList : pUCopList; destination : POINTER; data : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L copList,A1
+    MOVE.L  destination,D0
+    MOVE.L  data,D1
+    MOVEA.L GfxBase,A6
+    JSR -372(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION CoerceMode(vp : pViewPort; monitorid : ULONG; flags : ULONG) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vp,A0
+    MOVE.L  monitorid,D0
+    MOVE.L  flags,D1
+    MOVEA.L GfxBase,A6
+    JSR -936(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE CopySBitMap(layer : pLayer);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L layer,A0
+    MOVEA.L GfxBase,A6
+    JSR -450(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE CWait(copList : pUCopList; v : LONGINT; h : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L copList,A1
+    MOVE.L  v,D0
+    MOVE.L  h,D1
+    MOVEA.L GfxBase,A6
+    JSR -378(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE DisownBlitter;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L GfxBase,A6
+    JSR -462(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE DisposeRegion(region : pRegion);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L region,A0
+    MOVEA.L GfxBase,A6
+    JSR -534(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE DoCollision(rp : pRastPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVEA.L GfxBase,A6
+    JSR -108(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE Draw(rp : pRastPort; x : LONGINT; y : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  x,D0
+    MOVE.L  y,D1
+    MOVEA.L GfxBase,A6
+    JSR -246(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE DrawEllipse(rp : pRastPort; xCenter : LONGINT; yCenter : LONGINT; a : LONGINT; b : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  xCenter,D0
+    MOVE.L  yCenter,D1
+    MOVE.L  a,D2
+    MOVE.L  b,D3
+    MOVEA.L GfxBase,A6
+    JSR -180(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE DrawGList(rp : pRastPort; vp : pViewPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVEA.L vp,A0
+    MOVEA.L GfxBase,A6
+    JSR -114(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE EraseRect(rp : pRastPort; xMin : LONGINT; yMin : LONGINT; xMax : LONGINT; yMax : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  xMin,D0
+    MOVE.L  yMin,D1
+    MOVE.L  xMax,D2
+    MOVE.L  yMax,D3
+    MOVEA.L GfxBase,A6
+    JSR -810(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION ExtendFont(font : pTextFont; fontTags : pTagItem) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L font,A0
+    MOVEA.L fontTags,A1
+    MOVEA.L GfxBase,A6
+    JSR -816(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION FindColor(cm : pColorMap; r : ULONG; g : ULONG; b : ULONG; maxcolor : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cm,A3
+    MOVE.L  r,D1
+    MOVE.L  g,D2
+    MOVE.L  b,D3
+    MOVE.L  maxcolor,D4
+    MOVEA.L GfxBase,A6
+    JSR -1008(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION FindDisplayInfo(displayID : ULONG) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  displayID,D0
+    MOVEA.L GfxBase,A6
+    JSR -726(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION Flood(rp : pRastPort; mode : ULONG; x : LONGINT; y : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  mode,D2
+    MOVE.L  x,D0
+    MOVE.L  y,D1
+    MOVEA.L GfxBase,A6
+    JSR -330(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE FontExtent(font : pTextFont; fontExtent : pTextExtent);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L font,A0
+    MOVEA.L fontExtent,A1
+    MOVEA.L GfxBase,A6
+    JSR -762(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeBitMap(bm : pBitMap);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L bm,A0
+    MOVEA.L GfxBase,A6
+    JSR -924(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeColorMap(colorMap : pColorMap);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L colorMap,A0
+    MOVEA.L GfxBase,A6
+    JSR -576(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeCopList(copList : pCopList);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L copList,A0
+    MOVEA.L GfxBase,A6
+    JSR -546(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeCprList(cprList : pcprlist);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cprList,A0
+    MOVEA.L GfxBase,A6
+    JSR -564(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeDBufInfo(dbi : pDBufInfo);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L dbi,A1
+    MOVEA.L GfxBase,A6
+    JSR -972(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeGBuffers(anOb : pAnimOb; rp : pRastPort; flag : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L anOb,A0
+    MOVEA.L rp,A1
+    MOVE.L  flag,D0
+    MOVEA.L GfxBase,A6
+    JSR -600(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeRaster(p : pCHAR; width : ULONG; height : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L p,A0
+    MOVE.L  width,D0
+    MOVE.L  height,D1
+    MOVEA.L GfxBase,A6
+    JSR -498(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeSprite(num : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  num,D0
+    MOVEA.L GfxBase,A6
+    JSR -414(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeSpriteData(sp : pExtSprite);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L sp,A2
+    MOVEA.L GfxBase,A6
+    JSR -1032(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeVPortCopLists(vp : pViewPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vp,A0
+    MOVEA.L GfxBase,A6
+    JSR -540(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION GetAPen(rp : pRastPort) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVEA.L GfxBase,A6
+    JSR -858(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetBitMapAttr(bm : pBitMap; attrnum : ULONG) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L bm,A0
+    MOVE.L  attrnum,D1
+    MOVEA.L GfxBase,A6
+    JSR -960(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetBPen(rp : pRastPort) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVEA.L GfxBase,A6
+    JSR -864(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetColorMap(entries : LONGINT) : pColorMap;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  entries,D0
+    MOVEA.L GfxBase,A6
+    JSR -570(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetDisplayInfoData(handle : POINTER; buf : pCHAR; size : ULONG; tagID : ULONG; displayID : ULONG) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L handle,A0
+    MOVEA.L buf,A1
+    MOVE.L  size,D0
+    MOVE.L  tagID,D1
+    MOVE.L  displayID,D2
+    MOVEA.L GfxBase,A6
+    JSR -756(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetDrMd(rp : pRastPort) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVEA.L GfxBase,A6
+    JSR -870(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetExtSpriteA(ss : pExtSprite; tags : pTagItem) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L ss,A2
+    MOVEA.L tags,A1
+    MOVEA.L GfxBase,A6
+    JSR -930(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetGBuffers(anOb : pAnimOb; rp : pRastPort; flag : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L anOb,A0
+    MOVEA.L rp,A1
+    MOVE.L  flag,D0
+    MOVEA.L GfxBase,A6
+    JSR -168(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetOutlinePen(rp : pRastPort) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVEA.L GfxBase,A6
+    JSR -876(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE GetRGB32(cm : pColorMap; firstcolor : ULONG; ncolors : ULONG; table : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cm,A0
+    MOVE.L  firstcolor,D0
+    MOVE.L  ncolors,D1
+    MOVEA.L table,A1
+    MOVEA.L GfxBase,A6
+    JSR -900(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION GetRGB4(colorMap : pColorMap; entry : LONGINT) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L colorMap,A0
+    MOVE.L  entry,D0
+    MOVEA.L GfxBase,A6
+    JSR -582(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE GetRPAttrsA(rp : pRastPort; tags : pTagItem);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVEA.L tags,A1
+    MOVEA.L GfxBase,A6
+    JSR -1044(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION GetSprite(sprite : pSimpleSprite; num : LONGINT) : INTEGER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L sprite,A0
+    MOVE.L  num,D0
+    MOVEA.L GfxBase,A6
+    JSR -408(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetVPModeID(vp : pViewPort) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vp,A0
+    MOVEA.L GfxBase,A6
+    JSR -792(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE GfxAssociate(associateNode : POINTER; gfxNodePtr : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L associateNode,A0
+    MOVEA.L gfxNodePtr,A1
+    MOVEA.L GfxBase,A6
+    JSR -672(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE GfxFree(gfxNodePtr : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L gfxNodePtr,A0
+    MOVEA.L GfxBase,A6
+    JSR -666(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION GfxLookUp(associateNode : POINTER) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L associateNode,A0
+    MOVEA.L GfxBase,A6
+    JSR -702(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GfxNew(gfxNodeType : ULONG) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  gfxNodeType,D0
+    MOVEA.L GfxBase,A6
+    JSR -660(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE InitArea(areaInfo : pAreaInfo; vectorBuffer : POINTER; maxVectors : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L areaInfo,A0
+    MOVEA.L vectorBuffer,A1
+    MOVE.L  maxVectors,D0
+    MOVEA.L GfxBase,A6
+    JSR -282(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE InitBitMap(bitMap : pBitMap; depth : LONGINT; width : LONGINT; height : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L bitMap,A0
+    MOVE.L  depth,D0
+    MOVE.L  width,D1
+    MOVE.L  height,D2
+    MOVEA.L GfxBase,A6
+    JSR -390(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE InitGels(head : pVSprite; tail : pVSprite; gelsInfo : pGelsInfo);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L head,A0
+    MOVEA.L tail,A1
+    MOVEA.L gelsInfo,A2
+    MOVEA.L GfxBase,A6
+    JSR -120(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE InitGMasks(anOb : pAnimOb);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L anOb,A0
+    MOVEA.L GfxBase,A6
+    JSR -174(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE InitMasks(vSprite : pVSprite);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vSprite,A0
+    MOVEA.L GfxBase,A6
+    JSR -126(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE InitRastPort(rp : pRastPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVEA.L GfxBase,A6
+    JSR -198(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION InitTmpRas(tmpRas : pTmpRas; buffer : pCHAR; size : LONGINT) : pTmpRas;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L tmpRas,A0
+    MOVEA.L buffer,A1
+    MOVE.L  size,D0
+    MOVEA.L GfxBase,A6
+    JSR -468(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE InitView(view : pView);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L view,A1
+    MOVEA.L GfxBase,A6
+    JSR -360(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE InitVPort(vp : pViewPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vp,A0
+    MOVEA.L GfxBase,A6
+    JSR -204(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE LoadRGB32(vp : pViewPort; table : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vp,A0
+    MOVEA.L table,A1
+    MOVEA.L GfxBase,A6
+    JSR -882(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE LoadRGB4(vp : pViewPort; colors : POINTER; count : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vp,A0
+    MOVEA.L colors,A1
+    MOVE.L  count,D0
+    MOVEA.L GfxBase,A6
+    JSR -192(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE LoadView(view : pView);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L view,A1
+    MOVEA.L GfxBase,A6
+    JSR -222(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE LockLayerRom(layer : pLayer);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L layer,A5
+    MOVEA.L GfxBase,A6
+    JSR -432(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION MakeVPort(view : pView; vp : pViewPort) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L view,A0
+    MOVEA.L vp,A1
+    MOVEA.L GfxBase,A6
+    JSR -216(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ModeNotAvailable(modeID : ULONG) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  modeID,D0
+    MOVEA.L GfxBase,A6
+    JSR -798(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE Move(rp : pRastPort; x : LONGINT; y : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  x,D0
+    MOVE.L  y,D1
+    MOVEA.L GfxBase,A6
+    JSR -240(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE MoveSprite(vp : pViewPort; sprite : pSimpleSprite; x : LONGINT; y : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vp,A0
+    MOVEA.L sprite,A1
+    MOVE.L  x,D0
+    MOVE.L  y,D1
+    MOVEA.L GfxBase,A6
+    JSR -426(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION MrgCop(view : pView) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L view,A1
+    MOVEA.L GfxBase,A6
+    JSR -210(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION NewRegion : pRegion;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L GfxBase,A6
+    JSR -516(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION NextDisplayInfo(displayID : ULONG) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  displayID,D0
+    MOVEA.L GfxBase,A6
+    JSR -732(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ObtainBestPenA(cm : pColorMap; r : ULONG; g : ULONG; b : ULONG; tags : pTagItem) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cm,A0
+    MOVE.L  r,D1
+    MOVE.L  g,D2
+    MOVE.L  b,D3
+    MOVEA.L tags,A1
+    MOVEA.L GfxBase,A6
+    JSR -840(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ObtainPen(cm : pColorMap; n : ULONG; r : ULONG; g : ULONG; b : ULONG; f : LONGINT) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cm,A0
+    MOVE.L  n,D0
+    MOVE.L  r,D1
+    MOVE.L  g,D2
+    MOVE.L  b,D3
+    MOVE.L  f,D4
+    MOVEA.L GfxBase,A6
+    JSR -954(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION OpenFont(textAttr : pTextAttr) : pTextFont;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L textAttr,A0
+    MOVEA.L GfxBase,A6
+    JSR -072(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION OpenMonitor(monitorName : pCHAR; displayID : ULONG) : pMonitorSpec;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L monitorName,A1
+    MOVE.L  displayID,D0
+    MOVEA.L GfxBase,A6
+    JSR -714(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION OrRectRegion(region : pRegion; rectangle : pRectangle) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L region,A0
+    MOVEA.L rectangle,A1
+    MOVEA.L GfxBase,A6
+    JSR -510(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION OrRegionRegion(srcRegion : pRegion; destRegion : pRegion) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L srcRegion,A0
+    MOVEA.L destRegion,A1
+    MOVEA.L GfxBase,A6
+    JSR -612(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE OwnBlitter;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L GfxBase,A6
+    JSR -456(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE PolyDraw(rp : pRastPort; count : LONGINT; polyTable : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  count,D0
+    MOVEA.L polyTable,A0
+    MOVEA.L GfxBase,A6
+    JSR -336(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE QBlit(blit : pbltnode);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L blit,A1
+    MOVEA.L GfxBase,A6
+    JSR -276(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE QBSBlit(blit : pbltnode);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L blit,A1
+    MOVEA.L GfxBase,A6
+    JSR -294(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION ReadPixel(rp : pRastPort; x : LONGINT; y : LONGINT) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  x,D0
+    MOVE.L  y,D1
+    MOVEA.L GfxBase,A6
+    JSR -318(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ReadPixelArray8(rp : pRastPort; xstart : ULONG; ystart : ULONG; xstop : ULONG; ystop : ULONG; array_ : pCHAR; temprp : pRastPort) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVE.L  xstart,D0
+    MOVE.L  ystart,D1
+    MOVE.L  xstop,D2
+    MOVE.L  ystop,D3
+    MOVEA.L array_,A2
+    MOVEA.L temprp,A1
+    MOVEA.L GfxBase,A6
+    JSR -780(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ReadPixelLine8(rp : pRastPort; xstart : ULONG; ystart : ULONG; width : ULONG; array_ : pCHAR; tempRP : pRastPort) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVE.L  xstart,D0
+    MOVE.L  ystart,D1
+    MOVE.L  width,D2
+    MOVEA.L array_,A2
+    MOVEA.L tempRP,A1
+    MOVEA.L GfxBase,A6
+    JSR -768(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE RectFill(rp : pRastPort; xMin : LONGINT; yMin : LONGINT; xMax : LONGINT; yMax : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  xMin,D0
+    MOVE.L  yMin,D1
+    MOVE.L  xMax,D2
+    MOVE.L  yMax,D3
+    MOVEA.L GfxBase,A6
+    JSR -306(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ReleasePen(cm : pColorMap; n : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cm,A0
+    MOVE.L  n,D0
+    MOVEA.L GfxBase,A6
+    JSR -948(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE RemFont(textFont : pTextFont);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L textFont,A1
+    MOVEA.L GfxBase,A6
+    JSR -486(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE RemIBob(bob : pBob; rp : pRastPort; vp : pViewPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L bob,A0
+    MOVEA.L rp,A1
+    MOVEA.L vp,A2
+    MOVEA.L GfxBase,A6
+    JSR -132(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE RemVSprite(vSprite : pVSprite);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vSprite,A0
+    MOVEA.L GfxBase,A6
+    JSR -138(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION ScalerDiv(factor : ULONG; numerator : ULONG; denominator : ULONG) : WORD;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  factor,D0
+    MOVE.L  numerator,D1
+    MOVE.L  denominator,D2
+    MOVEA.L GfxBase,A6
+    JSR -684(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ScrollRaster(rp : pRastPort; dx : LONGINT; dy : LONGINT; xMin : LONGINT; yMin : LONGINT; xMax : LONGINT; yMax : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  dx,D0
+    MOVE.L  dy,D1
+    MOVE.L  xMin,D2
+    MOVE.L  yMin,D3
+    MOVE.L  xMax,D4
+    MOVE.L  yMax,D5
+    MOVEA.L GfxBase,A6
+    JSR -396(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ScrollRasterBF(rp : pRastPort; dx : LONGINT; dy : LONGINT; xMin : LONGINT; yMin : LONGINT; xMax : LONGINT; yMax : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  dx,D0
+    MOVE.L  dy,D1
+    MOVE.L  xMin,D2
+    MOVE.L  yMin,D3
+    MOVE.L  xMax,D4
+    MOVE.L  yMax,D5
+    MOVEA.L GfxBase,A6
+    JSR -1002(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ScrollVPort(vp : pViewPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vp,A0
+    MOVEA.L GfxBase,A6
+    JSR -588(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SetABPenDrMd(rp : pRastPort; apen : ULONG; bpen : ULONG; drawmode : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  apen,D0
+    MOVE.L  bpen,D1
+    MOVE.L  drawmode,D2
+    MOVEA.L GfxBase,A6
+    JSR -894(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SetAPen(rp : pRastPort; pen : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  pen,D0
+    MOVEA.L GfxBase,A6
+    JSR -342(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SetBPen(rp : pRastPort; pen : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  pen,D0
+    MOVEA.L GfxBase,A6
+    JSR -348(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION SetChipRev(want : ULONG) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  want,D0
+    MOVEA.L GfxBase,A6
+    JSR -888(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE SetCollision(num : ULONG; routine : tPROCEDURE; gelsInfo : pGelsInfo);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  num,D0
+    MOVEA.L routine,A0
+    MOVEA.L gelsInfo,A1
+    MOVEA.L GfxBase,A6
+    JSR -144(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SetDrMd(rp : pRastPort; drawMode : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  drawMode,D0
+    MOVEA.L GfxBase,A6
+    JSR -354(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION SetFont(rp : pRastPort; textFont : pTextFont) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVEA.L textFont,A0
+    MOVEA.L GfxBase,A6
+    JSR -066(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE SetMaxPen(rp : pRastPort; maxpen : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVE.L  maxpen,D0
+    MOVEA.L GfxBase,A6
+    JSR -990(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION SetOutlinePen(rp : pRastPort; pen : ULONG) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVE.L  pen,D0
+    MOVEA.L GfxBase,A6
+    JSR -978(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE SetRast(rp : pRastPort; pen : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  pen,D0
+    MOVEA.L GfxBase,A6
+    JSR -234(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SetRGB32(vp : pViewPort; n : ULONG; r : ULONG; g : ULONG; b : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vp,A0
+    MOVE.L  n,D0
+    MOVE.L  r,D1
+    MOVE.L  g,D2
+    MOVE.L  b,D3
+    MOVEA.L GfxBase,A6
+    JSR -852(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SetRGB32CM(cm : pColorMap; n : ULONG; r : ULONG; g : ULONG; b : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L cm,A0
+    MOVE.L  n,D0
+    MOVE.L  r,D1
+    MOVE.L  g,D2
+    MOVE.L  b,D3
+    MOVEA.L GfxBase,A6
+    JSR -996(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SetRGB4(vp : pViewPort; index : LONGINT; red : ULONG; green : ULONG; blue : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vp,A0
+    MOVE.L  index,D0
+    MOVE.L  red,D1
+    MOVE.L  green,D2
+    MOVE.L  blue,D3
+    MOVEA.L GfxBase,A6
+    JSR -288(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SetRGB4CM(colorMap : pColorMap; index : LONGINT; red : ULONG; green : ULONG; blue : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L colorMap,A0
+    MOVE.L  index,D0
+    MOVE.L  red,D1
+    MOVE.L  green,D2
+    MOVE.L  blue,D3
+    MOVEA.L GfxBase,A6
+    JSR -630(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SetRPAttrsA(rp : pRastPort; tags : pTagItem);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVEA.L tags,A1
+    MOVEA.L GfxBase,A6
+    JSR -1038(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION SetSoftStyle(rp : pRastPort; style : ULONG; enable : ULONG) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  style,D0
+    MOVE.L  enable,D1
+    MOVEA.L GfxBase,A6
+    JSR -090(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetWriteMask(rp : pRastPort; msk : ULONG) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVE.L  msk,D0
+    MOVEA.L GfxBase,A6
+    JSR -984(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE SortGList(rp : pRastPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVEA.L GfxBase,A6
+    JSR -150(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE StripFont(font : pTextFont);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L font,A0
+    MOVEA.L GfxBase,A6
+    JSR -822(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SyncSBitMap(layer : pLayer);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L layer,A0
+    MOVEA.L GfxBase,A6
+    JSR -444(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION Text(rp : pRastPort; string_ : pCHAR; count : ULONG) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVEA.L string_,A0
+    MOVE.L  count,D0
+    MOVEA.L GfxBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION TextExtent(rp : pRastPort; string_ : pCHAR; count : LONGINT; textExtent : pTextExtent) : INTEGER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVEA.L string_,A0
+    MOVE.L  count,D0
+    MOVEA.L textExtent,A2
+    MOVEA.L GfxBase,A6
+    JSR -690(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION TextFit(rp : pRastPort; string_ : pCHAR; strLen : ULONG; textExtent : pTextExtent; constrainingExtent : pTextExtent; strDirection : LONGINT; constrainingBitWidth : ULONG; constrainingBitHeight : ULONG) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVEA.L string_,A0
+    MOVE.L  strLen,D0
+    MOVEA.L textExtent,A2
+    MOVEA.L constrainingExtent,A3
+    MOVE.L  strDirection,D1
+    MOVE.L  constrainingBitWidth,D2
+    MOVE.L  constrainingBitHeight,D3
+    MOVEA.L GfxBase,A6
+    JSR -696(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION TextLength(rp : pRastPort; string_ : pCHAR; count : ULONG) : INTEGER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVEA.L string_,A0
+    MOVE.L  count,D0
+    MOVEA.L GfxBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION UCopperListInit(uCopList : pUCopList; n : LONGINT) : pCopList;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L uCopList,A0
+    MOVE.L  n,D0
+    MOVEA.L GfxBase,A6
+    JSR -594(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE UnlockLayerRom(layer : pLayer);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L layer,A5
+    MOVEA.L GfxBase,A6
+    JSR -438(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION VBeamPos : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L GfxBase,A6
+    JSR -384(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION VideoControl(colorMap : pColorMap; tagarray : pTagItem) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L colorMap,A0
+    MOVEA.L tagarray,A1
+    MOVEA.L GfxBase,A6
+    JSR -708(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE WaitBlit;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L GfxBase,A6
+    JSR -228(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE WaitBOVP(vp : pViewPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L vp,A0
+    MOVEA.L GfxBase,A6
+    JSR -402(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE WaitTOF;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L GfxBase,A6
+    JSR -270(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION WeighTAMatch(reqTextAttr : pTextAttr; targetTextAttr : pTextAttr; targetTags : pTagItem) : INTEGER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L reqTextAttr,A0
+    MOVEA.L targetTextAttr,A1
+    MOVEA.L targetTags,A2
+    MOVEA.L GfxBase,A6
+    JSR -804(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE WriteChunkyPixels(rp : pRastPort; xstart : ULONG; ystart : ULONG; xstop : ULONG; ystop : ULONG; array_ : pCHAR; bytesperrow : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVE.L  xstart,D0
+    MOVE.L  ystart,D1
+    MOVE.L  xstop,D2
+    MOVE.L  ystop,D3
+    MOVEA.L array_,A2
+    MOVE.L  bytesperrow,D4
+    MOVEA.L GfxBase,A6
+    JSR -1056(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION WritePixel(rp : pRastPort; x : LONGINT; y : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A1
+    MOVE.L  x,D0
+    MOVE.L  y,D1
+    MOVEA.L GfxBase,A6
+    JSR -324(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION WritePixelArray8(rp : pRastPort; xstart : ULONG; ystart : ULONG; xstop : ULONG; ystop : ULONG; array_ : pCHAR; temprp : pRastPort) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVE.L  xstart,D0
+    MOVE.L  ystart,D1
+    MOVE.L  xstop,D2
+    MOVE.L  ystop,D3
+    MOVEA.L array_,A2
+    MOVEA.L temprp,A1
+    MOVEA.L GfxBase,A6
+    JSR -786(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION WritePixelLine8(rp : pRastPort; xstart : ULONG; ystart : ULONG; width : ULONG; array_ : pCHAR; tempRP : pRastPort) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVE.L  xstart,D0
+    MOVE.L  ystart,D1
+    MOVE.L  width,D2
+    MOVEA.L array_,A2
+    MOVEA.L tempRP,A1
+    MOVEA.L GfxBase,A6
+    JSR -774(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION XorRectRegion(region : pRegion; rectangle : pRectangle) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L region,A0
+    MOVEA.L rectangle,A1
+    MOVEA.L GfxBase,A6
+    JSR -558(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION XorRegionRegion(srcRegion : pRegion; destRegion : pRegion) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L srcRegion,A0
+    MOVEA.L destRegion,A1
+    MOVEA.L GfxBase,A6
+    JSR -618(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT GRAPHICS *)
+
+
+
+
+

+ 251 - 0
packages/extra/amunits/units/hardblocks.pas

@@ -0,0 +1,251 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit hardblocks;
+
+INTERFACE
+
+uses exec;
+
+{--------------------------------------------------------------------
+ *
+ *      This file describes blocks of data that exist on a hard disk
+ *      to describe that disk.  They are not generically accessable to
+ *      the user as they do not appear on any DOS drive.  The blocks
+ *      are tagged with a unique identifier, checksummed, and linked
+ *      together.  The root of these blocks is the RigidDiskBlock.
+ *
+ *      The RigidDiskBlock must exist on the disk within the first
+ *      RDB_LOCATION_LIMIT blocks.  This inhibits the use of the zero
+ *      cylinder in an AmigaDOS partition: although it is strictly
+ *      possible to store the RigidDiskBlock data in the reserved
+ *      area of a partition, this practice is discouraged since the
+ *      reserved blocks of a partition are overwritten by "Format",
+ *      "Install", "DiskCopy", etc.  The recommended disk layout,
+ *      then, is to use the first cylinder(s) to store all the drive
+ *      data specified by these blocks: i.e. partition descriptions,
+ *      file system load images, drive bad block maps, spare blocks,
+ *      etc.
+ *
+ *      Though only 512 byte blocks are currently supported by the
+ *      file system, this proposal tries to be forward-looking by
+ *      making the block size explicit, and by using only the first
+ *      256 bytes for all blocks but the LoadSeg data.
+ *
+ *------------------------------------------------------------------}
+
+{
+ *  NOTE
+ *      optional block addresses below contain $ffffffff to indicate
+ *      a NULL address, as zero is a valid address
+}
+
+type
+
+    pRigidDiskBlock = ^tRigidDiskBlock;
+    tRigidDiskBlock = record
+        rdb_ID          : ULONG;      { 4 character identifier }
+        rdb_SummedLongs : ULONG;      { size of this checksummed structure }
+        rdb_ChkSum      : ULONG;      { block checksum (longword sum to zero) }
+        rdb_HostID      : ULONG;      { SCSI Target ID of host }
+        rdb_BlockBytes  : ULONG;      { size of disk blocks }
+        rdb_Flags       : ULONG;      { see below for defines }
+
+    { block list heads }
+
+        rdb_BadBlockList : ULONG;     { optional bad block list }
+        rdb_PartitionList : ULONG;    { optional first partition block }
+        rdb_FileSysHeaderList : ULONG; { optional file system header block }
+        rdb_DriveInit   : ULONG;      { optional drive-specific init code }
+
+                                { DriveInit(lun,rdb,ior): "C" stk & d0/a0/a1 }
+
+        rdb_Reserved1   : Array [0..5] of ULONG; { set to $ffffffff }
+
+    { physical drive characteristics }
+
+        rdb_Cylinders   : ULONG;      { number of drive cylinders }
+        rdb_Sectors     : ULONG;      { sectors per track }
+        rdb_Heads       : ULONG;      { number of drive heads }
+        rdb_Interleave  : ULONG;      { interleave }
+        rdb_Park        : ULONG;      { landing zone cylinder }
+        rdb_Reserved2   : Array [0..2] of ULONG;
+        rdb_WritePreComp : ULONG;     { starting cylinder: write precompensation }
+        rdb_ReducedWrite : ULONG;     { starting cylinder: reduced write current }
+        rdb_StepRate    : ULONG;      { drive step rate }
+        rdb_Reserved3   : Array [0..4] of ULONG;
+
+    { logical drive characteristics }
+
+        rdb_RDBBlocksLo : ULONG;      { low block of range reserved for hardblocks }
+        rdb_RDBBlocksHi : ULONG;      { high block of range for these hardblocks }
+        rdb_LoCylinder  : ULONG;      { low cylinder of partitionable disk area }
+        rdb_HiCylinder  : ULONG;      { high cylinder of partitionable data area }
+        rdb_CylBlocks   : ULONG;      { number of blocks available per cylinder }
+        rdb_AutoParkSeconds : ULONG;  { zero for no auto park }
+        rdb_Reserved4   : Array [0..1] of ULONG;
+
+    { drive identification }
+
+        rdb_DiskVendor  : Array [0..7] of Char;
+        rdb_DiskProduct : Array [0..15] of Char;
+        rdb_DiskRevision : Array [0..3] of Char;
+        rdb_ControllerVendor : Array [0..7] of Char;
+        rdb_ControllerProduct : Array [0..15] of Char;
+        rdb_ControllerRevision : Array [0..3] of Char;
+        rdb_Reserved5   : Array [0..9] of ULONG;
+    end;
+
+const
+    IDNAME_RIGIDDISK    = $5244534B;   { RDSK }
+
+    RDB_LOCATION_LIMIT  = 16;
+
+    RDBFB_LAST          = 0;    { no disks exist to be configured after }
+    RDBFF_LAST          = $01;  {   this one on this controller }
+    RDBFB_LASTLUN       = 1;    { no LUNs exist to be configured greater }
+    RDBFF_LASTLUN       = $02;  {   than this one at this SCSI Target ID }
+    RDBFB_LASTTID       = 2;    { no Target IDs exist to be configured }
+    RDBFF_LASTTID       = $04;  {   greater than this one on this SCSI bus }
+    RDBFB_NORESELECT    = 3;    { don't bother trying to perform reselection }
+    RDBFF_NORESELECT    = $08;  {   when talking to this drive }
+    RDBFB_DISKID        = 4;    { rdb_Disk... identification valid }
+    RDBFF_DISKID        = $10;
+    RDBFB_CTRLRID       = 5;    { rdb_Controller... identification valid }
+    RDBFF_CTRLRID       = $20;
+                                { added 7/20/89 by commodore: }
+    RDBFB_SYNCH         = 6;    { drive supports scsi synchronous mode }
+    RDBFF_SYNCH         = $40;  { CAN BE DANGEROUS TO USE IF IT DOESN'T! }
+
+{------------------------------------------------------------------}
+
+type
+
+    pBadBlockEntry = ^tBadBlockEntry;
+    tBadBlockEntry = record
+        bbe_BadBlock    : ULONG;      { block number of bad block }
+        bbe_GoodBlock   : ULONG;      { block number of replacement block }
+    end;
+
+    pBadBlockBlock = ^tBadBlockBlock;
+    tBadBlockBlock = record
+        bbb_ID          : ULONG;      { 4 character identifier }
+        bbb_SummedLongs : ULONG;      { size of this checksummed structure }
+        bbb_ChkSum      : Longint;      { block checksum (longword sum to zero) }
+        bbb_HostID      : ULONG;      { SCSI Target ID of host }
+        bbb_Next        : ULONG;      { block number of the next BadBlockBlock }
+        bbb_Reserved    : ULONG;
+        bbb_BlockPairs  : Array [0..60] of tBadBlockEntry; { bad block entry pairs }
+    { note [61] assumes 512 byte blocks }
+    end;
+
+const
+
+    IDNAME_BADBLOCK     = $42414442;   { BADB }
+
+{------------------------------------------------------------------}
+
+type
+
+    pPartitionBlock = ^tPartitionBlock;
+    tPartitionBlock = record
+        pb_ID           : ULONG;      { 4 character identifier }
+        pb_SummedLongs  : ULONG;      { size of this checksummed structure }
+        pb_ChkSum       : Longint;      { block checksum (longword sum to zero) }
+        pb_HostID       : ULONG;      { SCSI Target ID of host }
+        pb_Next         : ULONG;      { block number of the next PartitionBlock }
+        pb_Flags        : ULONG;      { see below for defines }
+        pb_Reserved1    : Array [0..1] of ULONG;
+        pb_DevFlags     : ULONG;      { preferred flags for OpenDevice }
+        pb_DriveName    : Array [0..31] of Char; { preferred DOS device name: BSTR form }
+                                        { (not used if this name is in use) }
+        pb_Reserved2    : Array [0..14] of ULONG; { filler to 32 longwords }
+        pb_Environment  : Array [0..16] of ULONG; { environment vector for this partition }
+        pb_EReserved    : Array [0..14] of ULONG; { reserved for future environment vector }
+    end;
+
+const
+
+    IDNAME_PARTITION    = $50415254;    { PART }
+
+    PBFB_BOOTABLE       = 0;    { this partition is intended to be bootable }
+    PBFF_BOOTABLE       = 1;    {   (expected directories and files exist) }
+    PBFB_NOMOUNT        = 1;    { do not mount this partition (e.g. manually }
+    PBFF_NOMOUNT        = 2;    {   mounted, but space reserved here) }
+
+{------------------------------------------------------------------}
+
+type
+
+    pFileSysHeaderBlock = ^tFileSysHeaderBlock;
+    tFileSysHeaderBlock = record
+        fhb_ID          : ULONG;      { 4 character identifier }
+        fhb_SummedLongs : ULONG;      { size of this checksummed structure }
+        fhb_ChkSum      : Longint;      { block checksum (longword sum to zero) }
+        fhb_HostID      : ULONG;      { SCSI Target ID of host }
+        fhb_Next        : ULONG;      { block number of next FileSysHeaderBlock }
+        fhb_Flags       : ULONG;      { see below for defines }
+        fhb_Reserved1   : Array [0..1] of ULONG;
+        fhb_DosType     : ULONG;      { file system description: match this with }
+                                { partition environment's DE_DOSTYPE entry }
+        fhb_Version     : ULONG;      { release version of this code }
+        fhb_PatchFlags  : ULONG;      { bits set for those of the following that }
+                                {   need to be substituted into a standard }
+                                {   device node for this file system: e.g. }
+                                {   0x180 to substitute SegList & GlobalVec }
+        fhb_Type        : ULONG;      { device node type: zero }
+        fhb_Task        : ULONG;      { standard dos "task" field: zero }
+        fhb_Lock        : ULONG;      { not used for devices: zero }
+        fhb_Handler     : ULONG;      { filename to loadseg: zero placeholder }
+        fhb_StackSize   : ULONG;      { stacksize to use when starting task }
+        fhb_Priority    : Longint;      { task priority when starting task }
+        fhb_Startup     : Longint;      { startup msg: zero placeholder }
+        fhb_SegListBlocks : Longint;    { first of linked list of LoadSegBlocks: }
+                                {   note that this entry requires some }
+                                {   processing before substitution }
+        fhb_GlobalVec   : Longint;      { BCPL global vector when starting task }
+        fhb_Reserved2   : Array [0..22] of ULONG; { (those reserved by PatchFlags) }
+        fhb_Reserved3   : Array [0..20] of ULONG;
+    end;
+
+const
+
+    IDNAME_FILESYSHEADER        = $46534844;    { FSHD }
+
+{------------------------------------------------------------------}
+
+Type
+
+    pLoadSegBlock = ^tLoadSegBlock;
+    tLoadSegBlock = record
+        lsb_ID          : ULONG;      { 4 character identifier }
+        lsb_SummedLongs : ULONG;      { size of this checksummed structure }
+        lsb_ChkSum      : Longint;      { block checksum (longword sum to zero) }
+        lsb_HostID      : ULONG;      { SCSI Target ID of host }
+        lsb_Next        : ULONG;      { block number of the next LoadSegBlock }
+        lsb_LoadData    : Array [0..122] of ULONG;    { data for "loadseg" }
+    { note [123] assumes 512 byte blocks }
+    end;
+
+const
+
+    IDNAME_LOADSEG      = $4C534547;    { LSEG }
+
+IMPLEMENTATION
+
+end.
+
+

+ 591 - 0
packages/extra/amunits/units/hardware.pas

@@ -0,0 +1,591 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{
+    registers and bits in the Complex Interface Adapter (CIA) chip
+}
+
+unit hardware;
+
+INTERFACE
+uses exec;
+
+{
+ * ciaa is on an ODD Pointer (e.g. the low Byte) -- $bfe001
+ * ciab is on an EVEN Pointer (e.g. the high Byte) -- $bfd000
+ *
+ * do this to get the definitions:
+ *    extern struct CIA ciaa, ciab;
+}
+
+Type
+
+    pCIA = ^tCIA;
+    tCIA = record
+    ciapra      : Byte;
+    pad0        : Array [0..254] of Byte;
+    ciaprb      : Byte;
+    pad1        : Array [0..254] of Byte;
+    ciaddra     : Byte;
+    pad2        : Array [0..254] of Byte;
+    ciaddrb     : Byte;
+    pad3        : Array [0..254] of Byte;
+    ciatalo     : Byte;
+    pad4        : Array [0..254] of Byte;
+    ciatahi     : Byte;
+    pad5        : Array [0..254] of Byte;
+    ciatblo     : Byte;
+    pad6        : Array [0..254] of Byte;
+    ciatbhi     : Byte;
+    pad7        : Array [0..254] of Byte;
+    ciatodlow   : Byte;
+    pad8        : Array [0..254] of Byte;
+    ciatodmid   : Byte;
+    pad9        : Array [0..254] of Byte;
+    ciatodhi    : Byte;
+    pad10       : Array [0..254] of Byte;
+    unusedreg   : Byte;
+    pad11       : Array [0..254] of Byte;
+    ciasdr      : Byte;
+    pad12       : Array [0..254] of Byte;
+    ciaicr      : Byte;
+    pad13       : Array [0..254] of Byte;
+    ciacra      : Byte;
+    pad14       : Array [0..254] of Byte;
+    ciacrb      : Byte;
+    end;
+
+
+Const
+
+{ interrupt control register bit numbers }
+
+    CIAICRB_TA      = 0;
+    CIAICRB_TB      = 1;
+    CIAICRB_ALRM    = 2;
+    CIAICRB_SP      = 3;
+    CIAICRB_FLG     = 4;
+    CIAICRB_IR      = 7;
+    CIAICRB_SETCLR  = 7;
+
+{ control register A bit numbers }
+
+    CIACRAB_START   = 0;
+    CIACRAB_PBON    = 1;
+    CIACRAB_OUTMODE     = 2;
+    CIACRAB_RUNMODE     = 3;
+    CIACRAB_LOAD    = 4;
+    CIACRAB_INMODE  = 5;
+    CIACRAB_SPMODE  = 6;
+    CIACRAB_TODIN   = 7;
+
+{ control register B bit numbers }
+
+    CIACRBB_START   = 0;
+    CIACRBB_PBON    = 1;
+    CIACRBB_OUTMODE     = 2;
+    CIACRBB_RUNMODE     = 3;
+    CIACRBB_LOAD    = 4;
+    CIACRBB_INMODE0     = 5;
+    CIACRBB_INMODE1     = 6;
+    CIACRBB_ALARM   = 7;
+ 
+{ interrupt control register masks }
+
+    CIAICRF_TA      = $01;
+    CIAICRF_TB      = $02;
+    CIAICRF_ALRM    = $04;
+    CIAICRF_SP      = $08;
+    CIAICRF_FLG     = $10;
+    CIAICRF_IR      = $80;
+    CIAICRF_SETCLR  = $80;
+
+{ control register A register masks }
+
+    CIACRAF_START   = $01;
+    CIACRAF_PBON    = $02;
+    CIACRAF_OUTMODE = $04;
+    CIACRAF_RUNMODE = $08;
+    CIACRAF_LOAD    = $10;
+    CIACRAF_INMODE  = $20;
+    CIACRAF_SPMODE  = $40;
+    CIACRAF_TODIN   = $80;
+ 
+{ control register B register masks }
+
+    CIACRBF_START   = $01;
+    CIACRBF_PBON    = $02;
+    CIACRBF_OUTMODE = $04;
+    CIACRBF_RUNMODE = $08;
+    CIACRBF_LOAD    = $10;
+    CIACRBF_INMODE0 = $20;
+    CIACRBF_INMODE1 = $40;
+    CIACRBF_ALARM   = $80;
+
+{ control register B INMODE masks }
+
+    CIACRBF_IN_PHI2 = 0;
+    CIACRBF_IN_CNT  = CIACRBF_INMODE0;
+    CIACRBF_IN_TA   = CIACRBF_INMODE1;
+    CIACRBF_IN_CNT_TA   = CIACRBF_INMODE0 + CIACRBF_INMODE1;
+
+{
+ * Port definitions -- what each bit in a cia peripheral register is tied to
+ }
+
+{ ciaa port A (0xbfe001) }
+
+    CIAB_GAMEPORT1  = 7;    { gameport 1, pin 6 (fire button*) }
+    CIAB_GAMEPORT0  = 6;    { gameport 0, pin 6 (fire button*) }
+    CIAB_DSKRDY     = 5;    { disk ready* }
+    CIAB_DSKTRACK0  = 4;    { disk on track 00* }
+    CIAB_DSKPROT    = 3;    { disk write protect* }
+    CIAB_DSKCHANGE  = 2;    { disk change* }
+    CIAB_LED        = 1;    { led light control (0==>bright) }
+    CIAB_OVERLAY    = 0;    { memory overlay bit }
+
+{ ciaa port B (0xbfe101) -- parallel port }
+
+{ ciab port A (0xbfd000) -- serial and printer control }
+
+    CIAB_COMDTR     = 7;    { serial Data Terminal Ready* }
+    CIAB_COMRTS     = 6;    { serial Request to Send* }
+    CIAB_COMCD      = 5;    { serial Carrier Detect* }
+    CIAB_COMCTS     = 4;    { serial Clear to Send* }
+    CIAB_COMDSR     = 3;    { serial Data Set Ready* }
+    CIAB_PRTRSEL    = 2;    { printer SELECT }
+    CIAB_PRTRPOUT   = 1;    { printer paper out }
+    CIAB_PRTRBUSY   = 0;    { printer busy }
+
+{ ciab port B (0xbfd100) -- disk control }
+
+    CIAB_DSKMOTOR   = 7;    { disk motorr* }
+    CIAB_DSKSEL3    = 6;    { disk select unit 3* }
+    CIAB_DSKSEL2    = 5;    { disk select unit 2* }
+    CIAB_DSKSEL1    = 4;    { disk select unit 1* }
+    CIAB_DSKSEL0    = 3;    { disk select unit 0* }
+    CIAB_DSKSIDE    = 2;    { disk side select* }
+    CIAB_DSKDIREC   = 1;    { disk direction of seek* }
+    CIAB_DSKSTEP    = 0;    { disk step heads* }
+
+{ ciaa port A (0xbfe001) }
+
+    CIAF_GAMEPORT1  = 128;
+    CIAF_GAMEPORT0  = 64;
+    CIAF_DSKRDY     = 32;
+    CIAF_DSKTRACK0  = 16;
+    CIAF_DSKPROT    = 8;
+    CIAF_DSKCHANGE  = 4;
+    CIAF_LED        = 2;
+    CIAF_OVERLAY    = 1;
+
+{ ciaa port B (0xbfe101) -- parallel port }
+
+{ ciab port A (0xbfd000) -- serial and printer control }
+
+    CIAF_COMDTR     = 128;
+    CIAF_COMRTS     = 64;
+    CIAF_COMCD      = 32;
+    CIAF_COMCTS     = 16;
+    CIAF_COMDSR     = 8;
+    CIAF_PRTRSEL    = 4;
+    CIAF_PRTRPOUT   = 2;
+    CIAF_PRTRBUSY   = 1;
+
+{ ciab port B (0xbfd100) -- disk control }
+
+    CIAF_DSKMOTOR   = 128;
+    CIAF_DSKSEL3    = 64;
+    CIAF_DSKSEL2    = 32;
+    CIAF_DSKSEL1    = 16;
+    CIAF_DSKSEL0    = 8;
+    CIAF_DSKSIDE    = 4;
+    CIAF_DSKDIREC   = 2;
+    CIAF_DSKSTEP    = 1;
+
+
+Type
+
+    pAudChannel = ^tAudChannel;
+    tAudChannel = record
+        ac_ptr          : Pointer;      { ptr to start of waveform data }
+        ac_len          : Word;         { length of waveform in words }
+        ac_per          : Word;         { sample period }
+        ac_vol          : Word;         { volume }
+        ac_dat          : Word;         { sample pair }
+        ac_pad          : Array [0..1] of Word;        { unused }
+    end;
+
+    pSpriteDef = ^tSpriteDef;
+    tSpriteDef = record
+        pos             : Word;
+        ctl             : Word;
+        dataa           : Word;
+        datab           : Word;
+    end;
+
+   pCustom = ^tCustom;
+   tCustom = record
+        bltddat         : Word;
+        dmaconr         : Word;
+        vposr           : Word;
+        vhposr          : Word;
+        dskdatr         : Word;
+        joy0dat         : Word;
+        joy1dat         : Word;
+        clxdat          : Word;
+        adkconr         : Word;
+        pot0dat         : Word;
+        pot1dat         : Word;
+        potinp          : Word;
+        serdatr         : Word;
+        dskbytr         : Word;
+        intenar         : Word;
+        intreqr         : Word;
+        dskpt           : Pointer;
+        dsklen          : Word;
+        dskdat          : Word;
+        refptr          : Word;
+        vposw           : Word;
+        vhposw          : Word;
+        copcon          : Word;
+        serdat          : Word;
+        serper          : Word;
+        potgo           : Word;
+        joytest         : Word;
+        strequ          : Word;
+        strvbl          : Word;
+        strhor          : Word;
+        strlong         : Word;
+        bltcon0         : Word;
+        bltcon1         : Word;
+        bltafwm         : Word;
+        bltalwm         : Word;
+        bltcpt          : Pointer;
+        bltbpt          : Pointer;
+        bltapt          : Pointer;
+        bltdpt          : Pointer;
+        bltsize         : Word;
+        pad2d           : Byte;
+        bltcon0l        : Byte;
+        bltsizv         : Word;
+        bltsizh         : Word;
+        bltcmod         : Word;
+        bltbmod         : Word;
+        bltamod         : Word;
+        bltdmod         : Word;
+        pad34           : Array [0..3] of Word;
+        bltcdat         : Word;
+        bltbdat         : Word;
+        bltadat         : Word;
+        pad3b           : Array [0..2] of Word;
+        deniseid        : Word;
+        dsksync         : Word;
+        cop1lc          : Longint;
+        cop2lc          : Longint;
+        copjmp1         : Word;
+        copjmp2         : Word;
+        copins          : Word;
+        diwstrt         : Word;
+        diwstop         : Word;
+        ddfstrt         : Word;
+        ddfstop         : Word;
+        dmacon          : Word;
+        clxcon          : Word;
+        intena          : Word;
+        intreq          : Word;
+        adkcon          : Word;
+        aud             : Array [0..3] of tAudChannel;
+        bplpt           : Array [0..7] of Pointer;
+        bplcon0         : Word;
+        bplcon1         : Word;
+        bplcon2         : Word;
+        bplcon3         : Word;
+        bpl1mod         : Word;
+        bpl2mod         : Word;
+        bplcon4         : Word;
+        clxcon2         : Word;
+        bpldat          : Array [0..7] of Word;
+        sprpt           : Array [0..7] of Pointer;
+        spr             : Array [0..7] of tSpriteDef;
+        color           : Array [0..31] of Word;
+        htotal          : Word;
+        hsstop          : Word;
+        hbstrt          : Word;
+        hbstop          : Word;
+        vtotal          : Word;
+        vsstop          : Word;
+        vbstrt          : Word;
+        vbstop          : Word;
+        sprhstrt        : Word;
+        sprhstop        : Word;
+        bplhstrt        : Word;
+        bplhstop        : Word;
+        hhposw          : Word;
+        hhposr          : Word;
+        beamcon0        : Word;
+        hsstrt          : Word;
+        vsstrt          : Word;
+        hcenter         : Word;
+        diwhigh         : Word;
+        padf3           : Array [0..10] of Word;
+        fmode           : Word;
+    end;
+
+CONST
+{    defines for beamcon register }
+  VARVBLANK     =  $1000;  {    Variable vertical blank enable }
+  LOLDIS        =  $0800;  {    long line disable }
+  CSCBLANKEN    =  $0400;  {    redirect composite sync }
+  VARVSYNC      =  $0200;  {    Variable vertical sync enable }
+  VARHSYNC      =  $0100;  {    Variable horizontal sync enable }
+  VARBEAM       =  $0080;  {    variable beam counter enable }
+  DISPLAYDUAL   =  $0040;  {    use UHRES pointer AND standard pointers }
+  DISPLAYPAL    =  $0020;  {    set decodes to generate PAL display }
+  VARCSYNC      =  $0010;  {    Variable composite sync enable }
+  CSBLANK       =  $0008;  {    Composite blank out to CSY* pin }
+  CSYNCTRUE     =  $0004;  {    composite sync TRUE signal }
+  VSYNCTRUE     =  $0002;  {    vertical sync TRUE }
+  HSYNCTRUE     =  $0001;  {    horizontal sync TRUE }
+
+{    new defines for bplcon0 }
+  USE_BPLCON3   =  1;
+
+{    new defines for bplcon2 }
+  BPLCON2_ZDCTEN        =  1024; {    colormapped genlock bit }
+  BPLCON2_ZDBPEN        =  2048; {    use bitplane as genlock bits }
+  BPLCON2_ZDBPSEL0      =  4096; {    three bits to select one }
+  BPLCON2_ZDBPSEL1      =  8192; {    of 8 bitplanes in }
+  BPLCON2_ZDBPSEL2      =  16384; {    ZDBPEN genlock mode }
+
+{    defines for bplcon3 register }
+  BPLCON3_EXTBLNKEN     =  1;  {    external blank enable }
+  BPLCON3_EXTBLKZD      =  2;  {    external blank ored into trnsprncy }
+  BPLCON3_ZDCLKEN       =  4;  {    zd pin outputs a 14mhz clock}
+  BPLCON3_BRDNTRAN      =  16;  {    border is opaque }
+  BPLCON3_BRDNBLNK      =  32;  {    border is opaque }
+
+
+Const
+
+    ADKB_SETCLR     = 15;   { standard set/clear bit }
+    ADKB_PRECOMP1   = 14;   { two bits of precompensation }
+    ADKB_PRECOMP0   = 13;
+    ADKB_MFMPREC    = 12;   { use mfm style precompensation }
+    ADKB_UARTBRK    = 11;   { force uart output to zero }
+    ADKB_WORDSYNC   = 10;   { enable DSKSYNC register matching }
+    ADKB_MSBSYNC    = 9;    { (Apple GCR Only) sync on MSB for reading }
+    ADKB_FAST       = 8;    { 1 -> 2 us/bit (mfm), 2 -> 4 us/bit (gcr) }
+    ADKB_USE3PN     = 7;    { use aud chan 3 to modulate period of ?? }
+    ADKB_USE2P3     = 6;    { use aud chan 2 to modulate period of 3 }
+    ADKB_USE1P2     = 5;    { use aud chan 1 to modulate period of 2 }
+    ADKB_USE0P1     = 4;    { use aud chan 0 to modulate period of 1 }
+    ADKB_USE3VN     = 3;    { use aud chan 3 to modulate volume of ?? }
+    ADKB_USE2V3     = 2;    { use aud chan 2 to modulate volume of 3 }
+    ADKB_USE1V2     = 1;    { use aud chan 1 to modulate volume of 2 }
+    ADKB_USE0V1     = 0;    { use aud chan 0 to modulate volume of 1 }
+
+    ADKF_SETCLR     = $8000;
+    ADKF_PRECOMP1   = $4000;
+    ADKF_PRECOMP0   = $2000;
+    ADKF_MFMPREC    = $1000;
+    ADKF_UARTBRK    = $0800;
+    ADKF_WORDSYNC   = $0400;
+    ADKF_MSBSYNC    = $0200;
+    ADKF_FAST       = $0100;
+    ADKF_USE3PN     = $0080;
+    ADKF_USE2P3     = $0040;
+    ADKF_USE1P2     = $0020;
+    ADKF_USE0P1     = $0010;
+    ADKF_USE3VN     = $0008;
+    ADKF_USE2V3     = $0004;
+    ADKF_USE1V2     = $0002;
+    ADKF_USE0V1     = $0001;
+
+    ADKF_PRE000NS   = 0;            { 000 ns of precomp }
+    ADKF_PRE140NS   = ADKF_PRECOMP0;    { 140 ns of precomp }
+    ADKF_PRE280NS   = ADKF_PRECOMP1;    { 280 ns of precomp }
+    ADKF_PRE560NS   = ADKF_PRECOMP0 + ADKF_PRECOMP1; { 560 ns of precomp }
+
+
+Const
+
+    HSIZEBITS           = 6;
+    VSIZEBITS           = 16 - HSIZEBITS;
+    HSIZEMASK           = $3F;                  { 2^6 - 1 }
+    VSIZEMASK           = $3FF;                 { 2^10 - 1 }
+
+    MAXBYTESPERROW      = 128;
+
+{ definitions for blitter control register 0 }
+
+    ABC         = $80;
+    ABNC        = $40;
+    ANBC        = $20;
+    ANBNC       = $10;
+    NABC        = $08;
+    NABNC       = $04;
+    NANBC       = $02;
+    NANBNC      = $01;
+
+{ some commonly used operations }
+
+    A_OR_B      = ABC + ANBC + NABC + ABNC + ANBNC + NABNC;
+    A_OR_C      = ABC + NABC + ABNC + ANBC + NANBC + ANBNC;
+    A_XOR_C     = NABC + ABNC + NANBC + ANBNC;
+    A_TO_D      = ABC + ANBC + ABNC + ANBNC;
+
+    BC0B_DEST   = 8;
+    BC0B_SRCC   = 9;
+    BC0B_SRCB   = 10;
+    BC0B_SRCA   = 11;
+    BC0F_DEST   = $100;
+    BC0F_SRCC   = $200;
+    BC0F_SRCB   = $400;
+    BC0F_SRCA   = $800;
+
+    BC1F_DESC   = 2;            { blitter descend direction }
+
+    DEST        = $100;
+    SRCC        = $200;
+    SRCB        = $400;
+    SRCA        = $800;
+
+    ASHIFTSHIFT = 12;           { bits to right align ashift value }
+    BSHIFTSHIFT = 12;           { bits to right align bshift value }
+
+{ definations for blitter control register 1 }
+
+    LINEMODE    = $01;
+    FILL_OR     = $08;
+    FILL_XOR    = $10;
+    FILL_CARRYIN = $04;
+    ONEDOT      = $02;          { one dot per horizontal line }
+    OVFLAG      = $20;
+    SIGNFLAG    = $40;
+    BLITREVERSE = $02;
+
+    SUD         = $10;
+    SUL         = $08;
+    AUL         = $04;
+
+    OCTANT8     = 24;
+    OCTANT7     = 4;
+    OCTANT6     = 12;
+    OCTANT5     = 28;
+    OCTANT4     = 20;
+    OCTANT3     = 8;
+    OCTANT2     = 0;
+    OCTANT1     = 16;
+
+ type
+    pbltnode = ^tbltnode;
+    tbltnode = record
+       n         : pbltnode;
+       _function : Pointer;
+       stat      : Byte;
+       blitsize  : Integer;
+       beamsync  : Integer;
+       cleanup   : Pointer;
+    end;
+
+Const
+
+{ write definitions for dmaconw }
+
+    DMAF_SETCLR     = $8000;
+    DMAF_AUDIO      = $000F;    { 4 bit mask }
+    DMAF_AUD0       = $0001;
+    DMAF_AUD1       = $0002;
+    DMAF_AUD2       = $0004;
+    DMAF_AUD3       = $0008;
+    DMAF_DISK       = $0010;
+    DMAF_SPRITE     = $0020;
+    DMAF_BLITTER    = $0040;
+    DMAF_COPPER     = $0080;
+    DMAF_RASTER     = $0100;
+    DMAF_MASTER     = $0200;
+    DMAF_BLITHOG    = $0400;
+    DMAF_ALL        = $01FF;    { all dma channels }
+
+{ read definitions for dmaconr }
+{ bits 0-8 correspnd to dmaconw definitions }
+
+    DMAF_BLTDONE    = $4000;
+    DMAF_BLTNZERO   = $2000;
+
+    DMAB_SETCLR     = 15;
+    DMAB_AUD0       = 0;
+    DMAB_AUD1       = 1;
+    DMAB_AUD2       = 2;
+    DMAB_AUD3       = 3;
+    DMAB_DISK       = 4;
+    DMAB_SPRITE     = 5;
+    DMAB_BLITTER    = 6;
+    DMAB_COPPER     = 7;
+    DMAB_RASTER     = 8;
+    DMAB_MASTER     = 9;
+    DMAB_BLITHOG    = 10;
+    DMAB_BLTDONE    = 14;
+    DMAB_BLTNZERO   = 13;
+
+
+Const
+
+    INTB_SETCLR     = 15;   { Set/Clear control bit. Determines if bits }
+                { written with a 1 get set or cleared. Bits }
+                { written with a zero are allways unchanged }
+    INTB_INTEN      = 14;   { Master interrupt (enable only ) }
+    INTB_EXTER      = 13;   { External interrupt }
+    INTB_DSKSYNC    = 12;   { Disk re-SYNChronized }
+    INTB_RBF        = 11;   { serial port Receive Buffer Full }
+    INTB_AUD3       = 10;   { Audio channel 3 block finished }
+    INTB_AUD2       = 9;    { Audio channel 2 block finished }
+    INTB_AUD1       = 8;    { Audio channel 1 block finished }
+    INTB_AUD0       = 7;    { Audio channel 0 block finished }
+    INTB_BLIT       = 6;    { Blitter finished }
+    INTB_VERTB      = 5;    { start of Vertical Blank }
+    INTB_COPER      = 4;    { Coprocessor }
+    INTB_PORTS      = 3;    { I/O Ports and timers }
+    INTB_SOFTINT    = 2;    { software interrupt request }
+    INTB_DSKBLK     = 1;    { Disk Block done }
+    INTB_TBE        = 0;    { serial port Transmit Buffer Empty }
+
+
+    INTF_SETCLR     = $8000;
+    INTF_INTEN      = $4000;
+    INTF_EXTER      = $2000;
+    INTF_DSKSYNC    = $1000;
+    INTF_RBF        = $0800;
+    INTF_AUD3       = $0400;
+    INTF_AUD2       = $0200;
+    INTF_AUD1       = $0100;
+    INTF_AUD0       = $0080;
+    INTF_BLIT       = $0040;
+    INTF_VERTB      = $0020;
+    INTF_COPER      = $0010;
+    INTF_PORTS      = $0008;
+    INTF_SOFTINT    = $0004;
+    INTF_DSKBLK     = $0002;
+    INTF_TBE        = $0001;
+
+IMPLEMENTATION
+
+end.
+
+
+
+

+ 210 - 0
packages/extra/amunits/units/icon.pas

@@ -0,0 +1,210 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit icon;
+
+INTERFACE
+
+uses exec, workbench;
+
+Const
+
+    ICONNAME    : PChar = 'icon.library';
+
+VAR IconBase : pLibrary;
+
+FUNCTION AddFreeList(freelist : pFreeList; mem : POINTER; size : ULONG) : BOOLEAN;
+FUNCTION BumpRevision(newname : pCHAR; oldname : pCHAR) : pCHAR;
+FUNCTION DeleteDiskObject(name : pCHAR) : BOOLEAN;
+FUNCTION FindToolType(toolTypeArray : POINTER; typeName : pCHAR) : pCHAR;
+PROCEDURE FreeDiskObject(diskobj : pDiskObject);
+PROCEDURE FreeFreeList(freelist : pFreeList);
+FUNCTION GetDefDiskObject(typ : LONGINT) : pDiskObject;
+FUNCTION GetDiskObject(name : pCHAR) : pDiskObject;
+FUNCTION GetDiskObjectNew(name : pCHAR) : pDiskObject;
+FUNCTION MatchToolValue(typeString : pCHAR; value : pCHAR) : BOOLEAN;
+FUNCTION PutDefDiskObject(diskObject : pDiskObject) : BOOLEAN;
+FUNCTION PutDiskObject(name : pCHAR; diskobj : pDiskObject) : BOOLEAN;
+
+IMPLEMENTATION
+
+FUNCTION AddFreeList(freelist : pFreeList; mem : POINTER; size : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L freelist,A0
+    MOVEA.L mem,A1
+    MOVEA.L size,A2
+    MOVEA.L IconBase,A6
+    JSR -072(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION BumpRevision(newname : pCHAR; oldname : pCHAR) : pCHAR;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L newname,A0
+    MOVEA.L oldname,A1
+    MOVEA.L IconBase,A6
+    JSR -108(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DeleteDiskObject(name : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L name,A0
+    MOVEA.L IconBase,A6
+    JSR -138(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION FindToolType(toolTypeArray : POINTER; typeName : pCHAR) : pCHAR;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L toolTypeArray,A0
+    MOVEA.L typeName,A1
+    MOVEA.L IconBase,A6
+    JSR -096(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE FreeDiskObject(diskobj : pDiskObject);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L diskobj,A0
+    MOVEA.L IconBase,A6
+    JSR -090(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeFreeList(freelist : pFreeList);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L freelist,A0
+    MOVEA.L IconBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION GetDefDiskObject(typ : LONGINT) : pDiskObject;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  typ,D0
+    MOVEA.L IconBase,A6
+    JSR -120(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetDiskObject(name : pCHAR) : pDiskObject;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L name,A0
+    MOVEA.L IconBase,A6
+    JSR -078(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetDiskObjectNew(name : pCHAR) : pDiskObject;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L name,A0
+    MOVEA.L IconBase,A6
+    JSR -132(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION MatchToolValue(typeString : pCHAR; value : pCHAR) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L typeString,A0
+    MOVEA.L value,A1
+    MOVEA.L IconBase,A6
+    JSR -102(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION PutDefDiskObject(diskObject : pDiskObject) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L diskObject,A0
+    MOVEA.L IconBase,A6
+    JSR -126(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION PutDiskObject(name : pCHAR; diskobj : pDiskObject) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L name,A0
+    MOVEA.L diskobj,A1
+    MOVEA.L IconBase,A6
+    JSR -084(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT ICON *)
+
+
+

+ 791 - 0
packages/extra/amunits/units/iffparse.pas

@@ -0,0 +1,791 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit iffparse;
+
+INTERFACE
+
+uses exec, clipboard, utility;
+
+
+const
+
+    IFFPARSENAME  : PChar = 'iffparse.library';
+
+{
+ * Struct associated with an active IFF stream.
+ * "iff_Stream" is a value used by the client's read/write/seek functions -
+ * it will not be accessed by the library itself and can have any value
+ * (could even be a pointer or a BPTR).
+ }
+Type
+       pIFFHandle = ^tIFFHandle;
+       tIFFHandle = record
+        iff_Stream,
+        iff_Flags   : ULONG
+        iff_Depth   : LONGINT;      {  Depth of context stack.  }
+        {  There are private fields hiding here.  }
+       END;
+
+{
+ * Bit masks for "iff_Flags" field.
+ }
+CONST
+ IFFF_READ     =  0;                      { read mode - default }
+ IFFF_WRITE    =  1;                      { write mode }
+ IFFF_RWBITS   =  (IFFF_READ + IFFF_WRITE);        { read/write bits }
+ IFFF_FSEEK    =  2;                 { forward seek only }
+ IFFF_RSEEK    =  4;                 { random seek }
+ IFFF_RESERVED =  $FFFF0000;             { Don't touch these bits. }
+
+{
+ * When the library calls your stream handler, you'll be passed a pointer
+ * to this structure as the "message packet".
+ }
+Type
+       pIFFStreamCmd = ^tIFFStreamCmd;
+       tIFFStreamCmd = record
+        sc_Command    : Longint;     {  Operation to be performed (IFFCMD_) }
+        sc_Buf        : Pointer;     {  Pointer to data buffer              }
+        sc_NBytes     : Longint;     {  Number of bytes to be affected      }
+       END;
+{
+ * A node associated with a context on the iff_Stack.  Each node
+ * represents a chunk, the stack representing the current nesting
+ * of chunks in the open IFF file.  Each context node has associated
+ * local context items in the (private) LocalItems list.  The ID, type,
+ * size and scan values describe the chunk associated with this node.
+ }
+       pContextNode = ^tContextNode;
+       tContextNode = record
+        cn_Node         : tMinNode;
+        cn_ID,
+        cn_Type,
+        cn_Size,        {  Size of this chunk             }
+        cn_Scan  : Longint;        {  # of bytes read/written so far }
+        {  There are private fields hiding here.  }
+       END;
+
+{
+ * Local context items live in the ContextNode's.  Each class is identified
+ * by its lci_Ident code and has a (private) purge vector for when the
+ * parent context node is popped.
+ }
+       pLocalContextItem = ^tLocalContextItem;
+       tLocalContextItem = record
+        lci_Node        : tMinNode;
+        lci_ID,
+        lci_Type,
+        lci_Ident       : ULONG;
+        {  There are private fields hiding here.  }
+       END;
+
+{
+ * StoredProperty: a local context item containing the data stored
+ * from a previously encountered property chunk.
+ }
+       pStoredProperty = ^tStoredProperty;
+       tStoredProperty = Record
+        sp_Size  : Longint;
+        sp_Data  : Pointer;
+       END;
+
+{
+ * Collection Item: the actual node in the collection list at which
+ * client will look.  The next pointers cross context boundaries so
+ * that the complete list is accessable.
+ }
+       pCollectionItem = ^tCollectionItem;
+       tCollectionItem = record
+        ci_Next                 : pCollectionItem;
+        ci_Size                 : Longint;
+        ci_Data                 : Pointer;
+       END;
+
+{
+ * Structure returned by OpenClipboard().  You may do CMD_POSTs and such
+ * using this structure.  However, once you call OpenIFF(), you may not
+ * do any more of your own I/O to the clipboard until you call CloseIFF().
+ }
+       pClipboardHandle = ^tClipBoardHandle;
+       tClipboardHandle = record
+        cbh_Req                 : tIOClipReq;
+        cbh_CBport,
+        cbh_SatisfyPort         : tMsgPort;
+       END;
+
+{
+ * IFF return codes.  Most functions return either zero for success or
+ * one of these codes.  The exceptions are the read/write functions which
+ * return positive values for number of bytes or records read or written,
+ * or a negative error code.  Some of these codes are not errors per sae,
+ * but valid conditions such as EOF or EOC (End of Chunk).
+ }
+CONST
+ IFFERR_EOF            =  -1 ;    {  Reached logical END of file }
+ IFFERR_EOC            =  -2 ;    {  About to leave context      }
+ IFFERR_NOSCOPE        =  -3 ;    {  No valid scope for property }
+ IFFERR_NOMEM          =  -4 ;    {  Internal memory alloc failed}
+ IFFERR_READ           =  -5 ;    {  Stream read error           }
+ IFFERR_WRITE          =  -6 ;    {  Stream write error          }
+ IFFERR_SEEK           =  -7 ;    {  Stream seek error           }
+ IFFERR_MANGLED        =  -8 ;    {  Data in file is corrupt     }
+ IFFERR_SYNTAX         =  -9 ;    {  IFF syntax error            }
+ IFFERR_NOTIFF         =  -10;    {  Not an IFF file             }
+ IFFERR_NOHOOK         =  -11;    {  No call-back hook provided  }
+ IFF_RETURN2CLIENT     =  -12;    {  Client handler normal return}
+
+{
+ MAKE_ID(a,b,c,d)        \
+        ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
+     }
+{
+ * Universal IFF identifiers.
+ }
+ ID_FORM = 1179603533;
+ ID_LIST = 1279873876;
+ ID_CAT  = 1128354848;
+ ID_PROP = 1347571536;
+ ID_NULL = 538976288;
+
+{
+ * Ident codes for universally recognized local context items.
+ }
+ IFFLCI_PROP         = 1886547824;
+ IFFLCI_COLLECTION   = 1668246636;
+ IFFLCI_ENTRYHANDLER = 1701734500;
+ IFFLCI_EXITHANDLER  = 1702389860;
+
+
+{
+ * Control modes for ParseIFF() function.
+ }
+ IFFPARSE_SCAN         =  0;
+ IFFPARSE_STEP         =  1;
+ IFFPARSE_RAWSTEP      =  2;
+
+{
+ * Control modes for StoreLocalItem().
+ }
+ IFFSLI_ROOT           =  1;      {  Store in default context       }
+ IFFSLI_TOP            =  2;      {  Store in current context       }
+ IFFSLI_PROP           =  3;      {  Store in topmost FORM OR LIST  }
+
+{
+ * "Flag" for writing functions.  If you pass this value in as a size
+ * to PushChunk() when writing a file, the parser will figure out the
+ * size of the chunk for you.  (Chunk sizes >= 2**31 are forbidden by the
+ * IFF specification, so this works.)
+ }
+ IFFSIZE_UNKNOWN       =  -1;
+
+{
+ * Possible call-back command values.  (Using 0 as the value for IFFCMD_INIT
+ * was, in retrospect, probably a bad idea.)
+ }
+ IFFCMD_INIT    = 0;       {  Prepare the stream for a session    }
+ IFFCMD_CLEANUP = 1;       {  Terminate stream session            }
+ IFFCMD_READ    = 2;       {  Read bytes from stream              }
+ IFFCMD_WRITE   = 3;       {  Write bytes to stream               }
+ IFFCMD_SEEK    = 4;       {  Seek on stream                      }
+ IFFCMD_ENTRY   = 5;       {  You just entered a new context      }
+ IFFCMD_EXIT    = 6;       {  You're about to leave a context     }
+ IFFCMD_PURGELCI= 7;       {  Purge a LocalContextItem            }
+
+{  Backward compatibility.  Don't use these in new code.  }
+ IFFSCC_INIT    = IFFCMD_INIT;
+ IFFSCC_CLEANUP = IFFCMD_CLEANUP;
+ IFFSCC_READ    = IFFCMD_READ;
+ IFFSCC_WRITE   = IFFCMD_WRITE;
+ IFFSCC_SEEK    = IFFCMD_SEEK;
+
+VAR IFFParseBase : pLibrary;
+
+FUNCTION AllocIFF : pIFFHandle;
+FUNCTION AllocLocalItem(typ : LONGINT; id : LONGINT; ident : LONGINT; dataSize : LONGINT) : pLocalContextItem;
+PROCEDURE CloseClipboard(clipHandle : pClipboardHandle);
+PROCEDURE CloseIFF(iff : pIFFHandle);
+FUNCTION CollectionChunk(iff : pIFFHandle; typ : LONGINT; id : LONGINT) : LONGINT;
+FUNCTION CollectionChunks(iff : pIFFHandle; propArray : LONGINT; numPairs : LONGINT) : LONGINT;
+FUNCTION CurrentChunk(iff : pIFFHandle) : pContextNode;
+FUNCTION EntryHandler(iff : pIFFHandle; typ : LONGINT; id : LONGINT; position : LONGINT; handler : pHook; obj : POINTER) : LONGINT;
+FUNCTION ExitHandler(iff : pIFFHandle; typ : LONGINT; id : LONGINT; position : LONGINT; handler : pHook; obj : POINTER) : LONGINT;
+FUNCTION FindCollection(iff : pIFFHandle; typ : LONGINT; id : LONGINT) : pCollectionItem;
+FUNCTION FindLocalItem(iff : pIFFHandle; typ : LONGINT; id : LONGINT; ident : LONGINT) : pLocalContextItem;
+FUNCTION FindProp(iff : pIFFHandle; typ : LONGINT; id : LONGINT) : pStoredProperty;
+FUNCTION FindPropContext(iff : pIFFHandle) : pContextNode;
+PROCEDURE FreeIFF(iff : pIFFHandle);
+PROCEDURE FreeLocalItem(localItem : pLocalContextItem);
+FUNCTION GoodID(id : LONGINT) : LONGINT;
+FUNCTION GoodType(typ : LONGINT) : LONGINT;
+FUNCTION IDtoStr(id : LONGINT; buf : pCHAR) : pCHAR;
+PROCEDURE InitIFF(iff : pIFFHandle; flags : LONGINT; streamHook : pHook);
+PROCEDURE InitIFFasClip(iff : pIFFHandle);
+PROCEDURE InitIFFasDOS(iff : pIFFHandle);
+FUNCTION LocalItemData(localItem : pLocalContextItem) : POINTER;
+FUNCTION OpenClipboard(unitNumber : LONGINT) : pClipboardHandle;
+FUNCTION OpenIFF(iff : pIFFHandle; rwMode : LONGINT) : LONGINT;
+FUNCTION ParentChunk(contextNode : pContextNode) : pContextNode;
+FUNCTION ParseIFF(iff : pIFFHandle; control : LONGINT) : LONGINT;
+FUNCTION PopChunk(iff : pIFFHandle) : LONGINT;
+FUNCTION PropChunk(iff : pIFFHandle; typ : LONGINT; id : LONGINT) : LONGINT;
+FUNCTION PropChunks(iff : pIFFHandle; propArray : LONGINT; numPairs : LONGINT) : LONGINT;
+FUNCTION PushChunk(iff : pIFFHandle; typ : LONGINT; id : LONGINT; size : LONGINT) : LONGINT;
+FUNCTION ReadChunkBytes(iff : pIFFHandle; buf : POINTER; numBytes : LONGINT) : LONGINT;
+FUNCTION ReadChunkRecords(iff : pIFFHandle; buf : POINTER; bytesPerRecord : LONGINT; numRecords : LONGINT) : LONGINT;
+PROCEDURE SetLocalItemPurge(localItem : pLocalContextItem; purgeHook : pHook);
+FUNCTION StopChunk(iff : pIFFHandle; typ : LONGINT; id : LONGINT) : LONGINT;
+FUNCTION StopChunks(iff : pIFFHandle; propArray : LONGINT; numPairs : LONGINT) : LONGINT;
+FUNCTION StopOnExit(iff : pIFFHandle; typ : LONGINT; id : LONGINT) : LONGINT;
+PROCEDURE StoreItemInContext(iff : pIFFHandle; localItem : pLocalContextItem; contextNode : pContextNode);
+FUNCTION StoreLocalItem(iff : pIFFHandle; localItem : pLocalContextItem; position : LONGINT) : LONGINT;
+FUNCTION WriteChunkBytes(iff : pIFFHandle; buf : POINTER; numBytes : LONGINT) : LONGINT;
+FUNCTION WriteChunkRecords(iff : pIFFHandle; buf : POINTER; bytesPerRecord : LONGINT; numRecords : LONGINT) : LONGINT;
+
+IMPLEMENTATION
+
+FUNCTION AllocIFF : pIFFHandle;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L IFFParseBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AllocLocalItem(typ : LONGINT; id : LONGINT; ident : LONGINT; dataSize : LONGINT) : pLocalContextItem;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  typ,D0
+    MOVE.L  id,D1
+    MOVE.L  ident,D2
+    MOVE.L  dataSize,D3
+    MOVEA.L IFFParseBase,A6
+    JSR -186(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE CloseClipboard(clipHandle : pClipboardHandle);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L clipHandle,A0
+    MOVEA.L IFFParseBase,A6
+    JSR -252(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE CloseIFF(iff : pIFFHandle);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L IFFParseBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION CollectionChunk(iff : pIFFHandle; typ : LONGINT; id : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVE.L  typ,D0
+    MOVE.L  id,D1
+    MOVEA.L IFFParseBase,A6
+    JSR -138(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CollectionChunks(iff : pIFFHandle; propArray : LONGINT; numPairs : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L propArray,A1
+    MOVE.L  numPairs,D0
+    MOVEA.L IFFParseBase,A6
+    JSR -144(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CurrentChunk(iff : pIFFHandle) : pContextNode;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L IFFParseBase,A6
+    JSR -174(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION EntryHandler(iff : pIFFHandle; typ : LONGINT; id : LONGINT; position : LONGINT; handler : pHook; obj : POINTER) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVE.L  typ,D0
+    MOVE.L  id,D1
+    MOVE.L  position,D2
+    MOVEA.L handler,A1
+    MOVEA.L obj,A2
+    MOVEA.L IFFParseBase,A6
+    JSR -102(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ExitHandler(iff : pIFFHandle; typ : LONGINT; id : LONGINT; position : LONGINT; handler : pHook; obj : POINTER) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVE.L  typ,D0
+    MOVE.L  id,D1
+    MOVE.L  position,D2
+    MOVEA.L handler,A1
+    MOVEA.L obj,A2
+    MOVEA.L IFFParseBase,A6
+    JSR -108(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION FindCollection(iff : pIFFHandle; typ : LONGINT; id : LONGINT) : pCollectionItem;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVE.L  typ,D0
+    MOVE.L  id,D1
+    MOVEA.L IFFParseBase,A6
+    JSR -162(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION FindLocalItem(iff : pIFFHandle; typ : LONGINT; id : LONGINT; ident : LONGINT) : pLocalContextItem;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVE.L  typ,D0
+    MOVE.L  id,D1
+    MOVE.L  ident,D2
+    MOVEA.L IFFParseBase,A6
+    JSR -210(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION FindProp(iff : pIFFHandle; typ : LONGINT; id : LONGINT) : pStoredProperty;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVE.L  typ,D0
+    MOVE.L  id,D1
+    MOVEA.L IFFParseBase,A6
+    JSR -156(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION FindPropContext(iff : pIFFHandle) : pContextNode;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L IFFParseBase,A6
+    JSR -168(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE FreeIFF(iff : pIFFHandle);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L IFFParseBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeLocalItem(localItem : pLocalContextItem);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L localItem,A0
+    MOVEA.L IFFParseBase,A6
+    JSR -204(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION GoodID(id : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  id,D0
+    MOVEA.L IFFParseBase,A6
+    JSR -258(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GoodType(typ : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  typ,D0
+    MOVEA.L IFFParseBase,A6
+    JSR -264(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION IDtoStr(id : LONGINT; buf : pCHAR) : pCHAR;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  id,D0
+    MOVEA.L buf,A0
+    MOVEA.L IFFParseBase,A6
+    JSR -270(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE InitIFF(iff : pIFFHandle; flags : LONGINT; streamHook : pHook);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVE.L  flags,D0
+    MOVEA.L streamHook,A1
+    MOVEA.L IFFParseBase,A6
+    JSR -228(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE InitIFFasClip(iff : pIFFHandle);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L IFFParseBase,A6
+    JSR -240(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE InitIFFasDOS(iff : pIFFHandle);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L IFFParseBase,A6
+    JSR -234(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION LocalItemData(localItem : pLocalContextItem) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L localItem,A0
+    MOVEA.L IFFParseBase,A6
+    JSR -192(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION OpenClipboard(unitNumber : LONGINT) : pClipboardHandle;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  unitNumber,D0
+    MOVEA.L IFFParseBase,A6
+    JSR -246(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION OpenIFF(iff : pIFFHandle; rwMode : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVE.L  rwMode,D0
+    MOVEA.L IFFParseBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ParentChunk(contextNode : pContextNode) : pContextNode;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L contextNode,A0
+    MOVEA.L IFFParseBase,A6
+    JSR -180(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ParseIFF(iff : pIFFHandle; control : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVE.L  control,D0
+    MOVEA.L IFFParseBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION PopChunk(iff : pIFFHandle) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L IFFParseBase,A6
+    JSR -090(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION PropChunk(iff : pIFFHandle; typ : LONGINT; id : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVE.L  typ,D0
+    MOVE.L  id,D1
+    MOVEA.L IFFParseBase,A6
+    JSR -114(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION PropChunks(iff : pIFFHandle; propArray : LONGINT; numPairs : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L propArray,A1
+    MOVE.L  numPairs,D0
+    MOVEA.L IFFParseBase,A6
+    JSR -120(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION PushChunk(iff : pIFFHandle; typ : LONGINT; id : LONGINT; size : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVE.L  typ,D0
+    MOVE.L  id,D1
+    MOVE.L  size,D2
+    MOVEA.L IFFParseBase,A6
+    JSR -084(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ReadChunkBytes(iff : pIFFHandle; buf : POINTER; numBytes : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L buf,A1
+    MOVE.L  numBytes,D0
+    MOVEA.L IFFParseBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ReadChunkRecords(iff : pIFFHandle; buf : POINTER; bytesPerRecord : LONGINT; numRecords : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L buf,A1
+    MOVE.L  bytesPerRecord,D0
+    MOVE.L  numRecords,D1
+    MOVEA.L IFFParseBase,A6
+    JSR -072(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE SetLocalItemPurge(localItem : pLocalContextItem; purgeHook : pHook);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L localItem,A0
+    MOVEA.L purgeHook,A1
+    MOVEA.L IFFParseBase,A6
+    JSR -198(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION StopChunk(iff : pIFFHandle; typ : LONGINT; id : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVE.L  typ,D0
+    MOVE.L  id,D1
+    MOVEA.L IFFParseBase,A6
+    JSR -126(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION StopChunks(iff : pIFFHandle; propArray : LONGINT; numPairs : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L propArray,A1
+    MOVE.L  numPairs,D0
+    MOVEA.L IFFParseBase,A6
+    JSR -132(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION StopOnExit(iff : pIFFHandle; typ : LONGINT; id : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVE.L  typ,D0
+    MOVE.L  id,D1
+    MOVEA.L IFFParseBase,A6
+    JSR -150(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE StoreItemInContext(iff : pIFFHandle; localItem : pLocalContextItem; contextNode : pContextNode);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L localItem,A1
+    MOVEA.L contextNode,A2
+    MOVEA.L IFFParseBase,A6
+    JSR -222(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION StoreLocalItem(iff : pIFFHandle; localItem : pLocalContextItem; position : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L localItem,A1
+    MOVE.L  position,D0
+    MOVEA.L IFFParseBase,A6
+    JSR -216(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION WriteChunkBytes(iff : pIFFHandle; buf : POINTER; numBytes : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L buf,A1
+    MOVE.L  numBytes,D0
+    MOVEA.L IFFParseBase,A6
+    JSR -066(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION WriteChunkRecords(iff : pIFFHandle; buf : POINTER; bytesPerRecord : LONGINT; numRecords : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iff,A0
+    MOVEA.L buf,A1
+    MOVE.L  bytesPerRecord,D0
+    MOVE.L  numRecords,D1
+    MOVEA.L IFFParseBase,A6
+    JSR -078(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT IFFPARSE *)
+
+
+
+

+ 55 - 0
packages/extra/amunits/units/input.pas

@@ -0,0 +1,55 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit input;
+
+INTERFACE
+
+uses exec;
+
+
+const
+
+    IND_ADDHANDLER      = CMD_NONSTD + 0;
+    IND_REMHANDLER      = CMD_NONSTD + 1;
+    IND_WRITEEVENT      = CMD_NONSTD + 2;
+    IND_SETTHRESH       = CMD_NONSTD + 3;
+    IND_SETPERIOD       = CMD_NONSTD + 4;
+    IND_SETMPORT        = CMD_NONSTD + 5;
+    IND_SETMTYPE        = CMD_NONSTD + 6;
+    IND_SETMTRIG        = CMD_NONSTD + 7;
+
+VAR InputBase : pDevice;
+
+FUNCTION PeekQualifier : WORD;
+
+IMPLEMENTATION
+
+FUNCTION PeekQualifier : WORD;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L InputBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT INPUT *)
+
+
+

+ 287 - 0
packages/extra/amunits/units/inputevent.pas

@@ -0,0 +1,287 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit inputevent;
+
+INTERFACE
+
+uses exec, utility, timer;
+
+const
+
+{------ constants -------------------------------------------------}
+
+{   --- InputEvent.ie_Class --- }
+{ A NOP input event }
+    IECLASS_NULL        = $00;
+{ A raw keycode from the keyboard device }
+    IECLASS_RAWKEY      = $01;
+{ The raw mouse report from the game port device }
+    IECLASS_RAWMOUSE    = $02;
+{ A private console event }
+    IECLASS_EVENT       = $03;
+{ A Pointer Position report }
+    IECLASS_POINTERPOS  = $04;
+{ A timer event }
+    IECLASS_TIMER       = $06;
+{ select button pressed down over a Gadget (address in ie_EventAddress) }
+    IECLASS_GADGETDOWN  = $07;
+{ select button released over the same Gadget (address in ie_EventAddress) }
+    IECLASS_GADGETUP    = $08;
+{ some Requester activity has taken place.  See Codes REQCLEAR and REQSET }
+    IECLASS_REQUESTER   = $09;
+{ this is a Menu Number transmission (Menu number is in ie_Code) }
+    IECLASS_MENULIST    = $0A;
+{ User has selected the active Window's Close Gadget }
+    IECLASS_CLOSEWINDOW = $0B;
+{ this Window has a new size }
+    IECLASS_SIZEWINDOW  = $0C;
+{ the Window pointed to by ie_EventAddress needs to be refreshed }
+    IECLASS_REFRESHWINDOW = $0D;
+{ new preferences are available }
+    IECLASS_NEWPREFS    = $0E;
+{ the disk has been removed }
+    IECLASS_DISKREMOVED = $0F;
+{ the disk has been inserted }
+    IECLASS_DISKINSERTED = $10;
+{ the window is about to be been made active }
+    IECLASS_ACTIVEWINDOW = $11;
+{ the window is about to be made inactive }
+    IECLASS_INACTIVEWINDOW = $12;
+{ extended-function pointer position report (V36) }
+    IECLASS_NEWPOINTERPOS  = $13;
+{ Help key report during Menu session (V36) }
+    IECLASS_MENUHELP       = $14;
+{ the Window has been modified with move, size, zoom, or change (V36) }
+    IECLASS_CHANGEWINDOW   = $15;
+
+
+
+{ the last class }
+
+    IECLASS_MAX         = $15;
+
+{  --- InputEvent.ie_SubClass --- }
+{  IECLASS_NEWPOINTERPOS }
+{      like IECLASS_POINTERPOS }
+ IESUBCLASS_COMPATIBLE  = $00;
+{      ie_EventAddress points to struct IEPointerPixel }
+ IESUBCLASS_PIXEL       = $01;
+{      ie_EventAddress points to struct IEPointerTablet }
+ IESUBCLASS_TABLET      = $02;
+
+{ pointed to by ie_EventAddress for IECLASS_NEWPOINTERPOS,
+ * and IESUBCLASS_PIXEL.
+ *
+ * You specify a screen and pixel coordinates in that screen
+ * at which you'd like the mouse to be positioned.
+ * Intuition will try to oblige, but there will be restrictions
+ * to positioning the pointer over offscreen pixels.
+ *
+ * IEQUALIFIER_RELATIVEMOUSE is supported for IESUBCLASS_PIXEL.
+ }
+Type
+
+   pIEPointerPixel = ^tIEPointerPixel;
+   tIEPointerPixel = record
+    iepp_Screen : Pointer;   { pointer to an open screen }
+    iepp_Position : record
+       x,y : Integer;
+    end;
+   END;
+
+{ pointed to by ie_EventAddress for IECLASS_NEWPOINTERPOS,
+ * and IESUBCLASS_TABLET.
+ *
+ * You specify a range of values and a value within the range
+ * independently for each of X and Y (the minimum value of
+ * the ranges is always normalized to 0).
+ *
+ * Intuition will position the mouse proportionally within its
+ * natural mouse position rectangle limits.
+ *
+ * IEQUALIFIER_RELATIVEMOUSE is not supported for IESUBCLASS_TABLET.
+ }
+
+   pIEPointerTablet = ^tIEPointerTablet;
+   tIEPointerTablet = record
+    iept_Range : record       { 0 is min, these are max      }
+       x,y : Word;
+    end;
+    iept_Value : record       { between 0 AND iept_Range     }
+       x,y : Word;
+    end;
+    iept_Pressure : Word;  { -128 to 127 (unused, set to 0)  }
+   END;
+
+{ The ie_EventAddress of an IECLASS_NEWPOINTERPOS event of subclass
+ * IESUBCLASS_NEWTABLET points at an IENewTablet structure.
+ *
+ *
+ * IEQUALIFIER_RELATIVEMOUSE is not supported for IESUBCLASS_NEWTABLET.
+ }
+
+ pIENewTablet = ^tIENewTablet;
+ tIENewTablet = record
+    { Pointer to a hook you wish to be called back through, in
+     * order to handle scaling.  You will be provided with the
+     * width and height you are expected to scale your tablet
+     * to, perhaps based on some user preferences.
+     * If NULL, the tablet's specified range will be mapped directly
+     * to that width and height for you, and you will not be
+     * called back.
+     }
+    ient_CallBack : pHook;
+
+    { Post-scaling coordinates and fractional coordinates.
+     * DO NOT FILL THESE IN AT THE TIME THE EVENT IS WRITTEN!
+     * Your driver will be called back and provided information
+     * about the width and height of the area to scale the
+     * tablet into.  It should scale the tablet coordinates
+     * (perhaps based on some preferences controlling aspect
+     * ratio, etc.) and place the scaled result into these
+     * fields.  The ient_ScaledX and ient_ScaledY fields are
+     * in screen-pixel resolution, but the origin ( [0,0]-point )
+     * is not defined.  The ient_ScaledXFraction and
+     * ient_ScaledYFraction fields represent sub-pixel position
+     * information, and should be scaled to fill a UWORD fraction.
+     }
+    ient_ScaledX, ient_ScaledY,
+    ient_ScaledXFraction, ient_ScaledYFraction : WORD;
+
+    { Current tablet coordinates along each axis: }
+    ient_TabletX, ient_TabletY : ULONG;
+
+    { Tablet range along each axis.  For example, if ient_TabletX
+     * can take values 0-999, ient_RangeX should be 1000.
+     }
+    ient_RangeX, ient_RangeY : ULONG;
+
+    { Pointer to tag-list of additional tablet attributes.
+     * See <intuition/intuition.h> for the tag values.
+     }
+    ient_TagList : pTagItem;
+ end;
+
+
+CONST
+{   --- InputEvent.ie_Code ---   }
+{ IECLASS_RAWKEY }
+    IECODE_UP_PREFIX            = $80;
+    IECODE_KEY_CODE_FIRST       = $00;
+    IECODE_KEY_CODE_LAST        = $77;
+    IECODE_COMM_CODE_FIRST      = $78;
+    IECODE_COMM_CODE_LAST       = $7F;
+
+{ IECLASS_ANSI }
+    IECODE_C0_FIRST             = $00;
+    IECODE_C0_LAST              = $1F;
+    IECODE_ASCII_FIRST          = $20;
+    IECODE_ASCII_LAST           = $7E;
+    IECODE_ASCII_DEL            = $7F;
+    IECODE_C1_FIRST             = $80;
+    IECODE_C1_LAST              = $9F;
+    IECODE_LATIN1_FIRST         = $A0;
+    IECODE_LATIN1_LAST          = $FF;
+
+{ IECLASS_RAWMOUSE }
+    IECODE_LBUTTON              = $68;  { also uses IECODE_UP_PREFIX }
+    IECODE_RBUTTON              = $69;
+    IECODE_MBUTTON              = $6A;
+    IECODE_NOBUTTON             = $FF;
+
+{ IECLASS_EVENT }
+    IECODE_NEWACTIVE            = $01;  { active input window changed }
+    IECODE_NEWSIZE              = $02;  { resize of window }
+    IECODE_REFRESH              = $03;  { refresh of window }
+
+{ IECLASS_REQUESTER Codes }
+{ REQSET is broadcast when the first Requester (not subsequent ones) opens
+ * in the Window
+ }
+    IECODE_REQSET               = $01;
+{ REQCLEAR is broadcast when the last Requester clears out of the Window }
+    IECODE_REQCLEAR             = $00;
+
+
+{   --- InputEvent.ie_Qualifier --- }
+    IEQUALIFIER_LSHIFT          = $0001;
+    IEQUALIFIER_RSHIFT          = $0002;
+    IEQUALIFIER_CAPSLOCK        = $0004;
+    IEQUALIFIER_CONTROL         = $0008;
+    IEQUALIFIER_LALT            = $0010;
+    IEQUALIFIER_RALT            = $0020;
+    IEQUALIFIER_LCOMMAND        = $0040;
+    IEQUALIFIER_RCOMMAND        = $0080;
+    IEQUALIFIER_NUMERICPAD      = $0100;
+    IEQUALIFIER_REPEAT          = $0200;
+    IEQUALIFIER_INTERRUPT       = $0400;
+    IEQUALIFIER_MULTIBROADCAST  = $0800;
+    IEQUALIFIER_MIDBUTTON       = $1000;
+    IEQUALIFIER_RBUTTON         = $2000;
+    IEQUALIFIER_LEFTBUTTON      = $4000;
+    IEQUALIFIER_RELATIVEMOUSE   = $8000;
+
+    IEQUALIFIERB_LSHIFT         = 0;
+    IEQUALIFIERB_RSHIFT         = 1;
+    IEQUALIFIERB_CAPSLOCK       = 2;
+    IEQUALIFIERB_CONTROL        = 3;
+    IEQUALIFIERB_LALT           = 4;
+    IEQUALIFIERB_RALT           = 5;
+    IEQUALIFIERB_LCOMMAND       = 6;
+    IEQUALIFIERB_RCOMMAND       = 7;
+    IEQUALIFIERB_NUMERICPAD     = 8;
+    IEQUALIFIERB_REPEAT         = 9;
+    IEQUALIFIERB_INTERRUPT      = 10;
+    IEQUALIFIERB_MULTIBROADCAST = 11;
+    IEQUALIFIERB_MIDBUTTON      = 12;
+    IEQUALIFIERB_RBUTTON        = 13;
+    IEQUALIFIERB_LEFTBUTTON     = 14;
+    IEQUALIFIERB_RELATIVEMOUSE  = 15;
+
+
+{------ InputEvent ------------------------------------------------}
+
+    type
+       pInputEvent = ^tInputEvent;
+       tInputEvent = record
+            ie_NextEvent : pInputEvent;
+            ie_Class : BYTE;
+            ie_SubClass : BYTE;
+            ie_Code : WORD;
+            ie_Qualifier : WORD;
+            ie_position : record
+                case longint of
+                   0 : ( ie_xy : record
+                        ie_x : Integer;
+                        ie_y : Integer;
+                     end );
+                   1 : ( ie_addr : APTR );
+                   2 : ( ie_dead : record
+                        ie_prev1DownCode : BYTE;
+                        ie_prev1DownQual : BYTE;
+                        ie_prev2DownCode : BYTE;
+                        ie_prev2DownQual : BYTE;
+                     end );
+                end;
+            ie_TimeStamp : tTimeVal;
+         end;
+
+IMPLEMENTATION
+
+end.
+
+

+ 5624 - 0
packages/extra/amunits/units/intuition.pas

@@ -0,0 +1,5624 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit intuition;
+
+INTERFACE
+
+uses exec, graphics, utility, inputevent, timer, layers;
+
+{
+ * NOTE:  intuition/iobsolete.h is included at the END of this file!
+ }
+
+{ ======================================================================== }
+{ === IntuiText ========================================================== }
+{ ================================= ======================================= }
+{ IntuiText is a series of strings that start with a screen location
+ *  (always relative to the upper-left corner of something) and then the
+ *  text of the string.  The text is null-terminated.
+ }
+Type
+    pIntuiText = ^tIntuiText;
+    tIntuiText = record
+        FrontPen,
+        BackPen         : Byte;         { the pen numbers for the rendering }
+        DrawMode        : Byte;         { the mode for rendering the text }
+        LeftEdge        : Integer;        { relative start location for the text }
+        TopEdge         : Integer;        { relative start location for the text }
+        ITextFont       : pTextAttr;  { if NULL, you accept the default }
+        IText           : STRPTR;       { pointer to null-terminated text }
+        NextText        : pIntuiText;   { continuation to TxWrite another text }
+    end;
+
+
+
+{ ======================================================================== }
+{ === Border ============================================================= }
+{ ======================================================================== }
+{ Data type Border, used for drawing a series of lines which is intended for
+ *  use as a border drawing, but which may, in fact, be used to render any
+ *  arbitrary vector shape.
+ *  The routine DrawBorder sets up the RastPort with the appropriate
+ *  variables, then does a Move to the first coordinate, then does Draws
+ *  to the subsequent coordinates.
+ *  After all the Draws are done, if NextBorder is non-zero we call DrawBorder
+ *  recursively
+ }
+Type
+    pBorder = ^tBorder;
+    tBorder = record
+        LeftEdge,
+        TopEdge         : Integer;        { initial offsets from the origin }
+        FrontPen,
+        BackPen         : Byte;         { pens numbers for rendering }
+        DrawMode        : Byte;         { mode for rendering }
+        Count           : Shortint;         { number of XY pairs }
+        XY              : Pointer;      { vector coordinate pairs rel to LeftTop}
+        NextBorder      : pBorder;      { pointer to any other Border too }
+    end;
+
+{ ======================================================================== }
+{ === MenuItem =========================================================== }
+{ ======================================================================== }
+
+Type
+
+    pMenuItem = ^tMenuItem;
+    tMenuItem = record
+        NextItem        : pMenuItem;    { pointer to next in chained list }
+        LeftEdge,
+        TopEdge         : Integer;        { position of the select box }
+        Width,
+        Height          : Integer;        { dimensions of the select box }
+        Flags           : Word;        { see the defines below }
+
+        MutualExclude   : Longint;      { set bits mean this item excludes that }
+
+        ItemFill        : Pointer;      { points to Image, IntuiText, or NULL }
+
+    { when this item is pointed to by the cursor and the items highlight
+     *  mode HIGHIMAGE is selected, this alternate image will be displayed
+     }
+
+        SelectFill      : Pointer;      { points to Image, IntuiText, or NULL }
+
+        Command         : Char;         { only if appliprog sets the COMMSEQ flag }
+
+        SubItem         : pMenuItem;    { if non-zero, DrawMenu shows "->" }
+
+    { The NextSelect field represents the menu number of next selected
+     *  item (when user has drag-selected several items)
+     }
+
+        NextSelect      : Word;
+    end;
+
+
+Const
+
+{ FLAGS SET BY THE APPLIPROG }
+    CHECKIT     = $0001;        { whether to check this item if selected }
+    ITEMTEXT    = $0002;        { set if textual, clear if graphical item }
+    COMMSEQ     = $0004;        { set if there's an command sequence }
+    MENUTOGGLE  = $0008;        { set to toggle the check of a menu item }
+    ITEMENABLED = $0010;        { set if this item is enabled }
+
+{ these are the SPECIAL HIGHLIGHT FLAG state meanings }
+    HIGHFLAGS   = $00C0;        { see definitions below for these bits }
+    HIGHIMAGE   = $0000;        { use the user's "select image" }
+    HIGHCOMP    = $0040;        { highlight by complementing the selectbox }
+    HIGHBOX     = $0080;        { highlight by "boxing" the selectbox }
+    HIGHNONE    = $00C0;        { don't highlight }
+
+{ FLAGS SET BY BOTH APPLIPROG AND INTUITION }
+    CHECKED     = $0100;        { if CHECKIT, then set this when selected }
+
+{ FLAGS SET BY INTUITION }
+    ISDRAWN     = $1000;        { this item's subs are currently drawn }
+    HIGHITEM    = $2000;        { this item is currently highlighted }
+    MENUTOGGLED = $4000;        { this item was already toggled }
+
+
+{ ======================================================================== }
+{ === Menu =============================================================== }
+{ ======================================================================== }
+Type
+
+    pMenu = ^tMenu;
+    tMenu = record
+        NextMenu        : pMenu;        { same level }
+        LeftEdge,
+        TopEdge         : Integer;        { position of the select box }
+        Width,
+        Height          : Integer;        { dimensions of the select box }
+        Flags           : Word;        { see flag definitions below }
+        MenuName        : STRPTR;       { text for this Menu Header }
+        FirstItem       : pMenuItem;  { pointer to first in chain }
+
+    { these mysteriously-named variables are for internal use only }
+
+        JazzX,
+        JazzY,
+        BeatX,
+        BeatY           : Integer;
+    end;
+
+CONST
+{ FLAGS SET BY BOTH THE APPLIPROG AND INTUITION }
+    MENUENABLED = $0001;        { whether or not this menu is enabled }
+
+{ FLAGS SET BY INTUITION }
+    MIDRAWN     = $0100;        { this menu's items are currently drawn }
+
+
+
+
+{ ======================================================================== }
+{ === Gadget ============================================================= }
+{ ======================================================================== }
+
+Type
+
+    pGadget = ^tGadget;
+    tGadget = record
+        NextGadget      : pGadget;      { next gadget in the list }
+
+        LeftEdge,
+        TopEdge         : Integer;        { "hit box" of gadget }
+        Width,
+        Height          : Integer;        { "hit box" of gadget }
+
+        Flags           : Word;        { see below for list of defines }
+
+        Activation      : Word;        { see below for list of defines }
+
+        GadgetType      : Word;        { see below for defines }
+
+    { appliprog can specify that the Gadget be rendered as either as Border
+     * or an Image.  This variable points to which (or equals NULL if there's
+     * nothing to be rendered about this Gadget)
+     }
+
+        GadgetRender    : Pointer;
+
+    { appliprog can specify "highlighted" imagery rather than algorithmic
+     * this can point to either Border or Image data
+     }
+
+        SelectRender    : Pointer;
+
+        GadgetText      : pIntuiText; { text for this gadget }
+
+    { by using the MutualExclude word, the appliprog can describe
+     * which gadgets mutually-exclude which other ones.  The bits
+     * in MutualExclude correspond to the gadgets in object containing
+     * the gadget list.  If this gadget is selected and a bit is set
+     * in this gadget's MutualExclude and the gadget corresponding to
+     * that bit is currently selected (e.g. bit 2 set and gadget 2
+     * is currently selected) that gadget must be unselected.
+     * Intuition does the visual unselecting (with checkmarks) and
+     * leaves it up to the program to unselect internally
+     }
+
+        MutualExclude   : Longint;      { set bits mean this gadget excludes that gadget }
+
+    { pointer to a structure of special data required by Proportional,
+     * String and Longint Gadgets
+     }
+
+        SpecialInfo     : Pointer;
+
+        GadgetID        : Word;        { user-definable ID field }
+        UserData        : Pointer;      { ptr to general purpose User data (ignored by In) }
+    end;
+
+ pExtGadget = ^tExtGadget;
+ tExtGadget = record
+    { The first fields match struct Gadget exactly }
+    NextGadget     : pExtGadget;  { Matches struct Gadget }
+    LeftEdge, TopEdge,            { Matches struct Gadget }
+    Width, Height  : Integer;     { Matches struct Gadget }
+    Flags,                        { Matches struct Gadget }
+    Activation,                   { Matches struct Gadget }
+    GadgetType     : WORD;        { Matches struct Gadget }
+    GadgetRender,                 { Matches struct Gadget }
+    SelectRender   : Pointer;     { Matches struct Gadget }
+    GadgetText     : pIntuiText;  { Matches struct Gadget }
+    MutualExclude  : Longint;     { Matches struct Gadget }
+    SpecialInfo    : Pointer;     { Matches struct Gadget }
+    GadgetID       : WORD;        { Matches struct Gadget }
+    UserData       : Pointer;     { Matches struct Gadget }
+
+    { These fields only exist under V39 and only if GFLG_EXTENDED is set }
+    MoreFlags      : ULONG;     { see GMORE_ flags below }
+    BoundsLeftEdge,             { Bounding extent for gadget, valid   }
+    BoundsTopEdge,              { only if GMORE_BOUNDS is set.  The   }
+    BoundsWidth,                { GFLG_RELxxx flags affect these      }
+    BoundsHeight   : Integer;      { coordinates as well.        }
+ end;
+
+
+CONST
+{ --- Gadget.Flags values      --- }
+{ combinations in these bits describe the highlight technique to be used }
+ GFLG_GADGHIGHBITS  = $0003;
+ GFLG_GADGHCOMP     = $0000;  { Complement the select box }
+ GFLG_GADGHBOX      = $0001;  { Draw a box around the image }
+ GFLG_GADGHIMAGE    = $0002;  { Blast in this alternate image }
+ GFLG_GADGHNONE     = $0003;  { don't highlight }
+
+ GFLG_GADGIMAGE     = $0004;  { set IF GadgetRender AND SelectRender
+                                   * point to an Image structure, clear
+                                   * if they point to Border structures
+                                   }
+
+{ combinations in these next two bits specify to which corner the gadget's
+ *  Left & Top coordinates are relative.  If relative to Top/Left,
+ *  these are "normal" coordinates (everything is relative to something in
+ *  this universe).
+ *
+ * Gadget positions and dimensions are relative to the window or
+ * requester which contains the gadget
+ }
+ GFLG_RELBOTTOM   = $0008;  { vert. pos. is relative to bottom edge }
+ GFLG_RELRIGHT    = $0010;  { horiz. pos. is relative to right edge }
+ GFLG_RELWIDTH    = $0020;  { width is relative to req/window    }
+ GFLG_RELHEIGHT   = $0040;  { height is relative to req/window   }
+
+{ New for V39: GFLG_RELSPECIAL allows custom gadget implementors to
+ * make gadgets whose position and size depend in an arbitrary way
+ * on their window's dimensions.  The GM_LAYOUT method will be invoked
+ * for such a gadget (or any other GREL_xxx gadget) at suitable times,
+ * such as when the window opens or the window's size changes.
+ }
+ GFLG_RELSPECIAL  = $4000;  { custom gadget has special relativity.
+                                   * Gadget box values are absolutes, but
+                                   * can be changed via the GM_LAYOUT method.
+                                   }
+
+ GFLG_SELECTED    = $0080;  { you may initialize AND look at this        }
+
+{ the GFLG_DISABLED flag is initialized by you and later set by Intuition
+ * according to your calls to On/OffGadget().  It specifies whether or not
+ * this Gadget is currently disabled from being selected
+ }
+ GFLG_DISABLED    = $0100;
+
+{ These flags specify the type of text field that Gadget.GadgetText
+ * points to.  In all normal (pre-V36) gadgets which you initialize
+ * this field should always be zero.  Some types of gadget objects
+ * created from classes will use these fields to keep track of
+ * types of labels/contents that different from IntuiText, but are
+ * stashed in GadgetText.
+ }
+
+ GFLG_LABELMASK   = $3000;
+ GFLG_LABELITEXT  = $0000;  { GadgetText points to IntuiText     }
+ GFLG_LABELSTRING = $1000;  { GadgetText points to (UBYTE *)     }
+ GFLG_LABELIMAGE  = $2000;  { GadgetText points to Image (object)        }
+
+{ New for V37: GFLG_TABCYCLE }
+ GFLG_TABCYCLE    = $0200;  { (string OR custom) gadget participates in
+                                   * cycling activation with Tab or Shift-Tab
+                                   }
+{ New for V37: GFLG_STRINGEXTEND.  We discovered that V34 doesn't properly
+ * ignore the value we had chosen for the Gadget->Activation flag
+ * GACT_STRINGEXTEND.  NEVER SET THAT FLAG WHEN RUNNING UNDER V34.
+ * The Gadget->Flags bit GFLG_STRINGEXTEND is provided as a synonym which is
+ * safe under V34, and equivalent to GACT_STRINGEXTEND under V37.
+ * (Note that the two flags are not numerically equal)
+ }
+ GFLG_STRINGEXTEND = $0400;  { this String Gadget has StringExtend        }
+
+{ New for V39: GFLG_IMAGEDISABLE.  This flag is automatically set if
+ * the custom image of this gadget knows how to do disabled rendering
+ * (more specifically, if its IA_SupportsDisable attribute is TRUE).
+ * Intuition uses this to defer the ghosting to the image-class,
+ * instead of doing it itself (the old compatible way).
+ * Do not set this flag yourself - Intuition will do it for you.
+ }
+
+ GFLG_IMAGEDISABLE = $0800;  { Gadget's image knows how to do disabled
+                                   * rendering
+                                   }
+
+{ New for V39:  If set, this bit means that the Gadget is actually
+ * a struct ExtGadget, with new fields and flags.  All V39 boopsi
+ * gadgets are ExtGadgets.  Never ever attempt to read the extended
+ * fields of a gadget if this flag is not set.
+ }
+ GFLG_EXTENDED    = $8000;  { Gadget is extended }
+
+{ ---  Gadget.Activation flag values   --- }
+{ Set GACT_RELVERIFY if you want to verify that the pointer was still over
+ * the gadget when the select button was released.  Will cause
+ * an IDCMP_GADGETUP message to be sent if so.
+ }
+ GACT_RELVERIFY    = $0001;
+
+{ the flag GACT_IMMEDIATE, when set, informs the caller that the gadget
+ *  was activated when it was activated.  This flag works in conjunction with
+ *  the GACT_RELVERIFY flag
+ }
+ GACT_IMMEDIATE    = $0002;
+
+{ the flag GACT_ENDGADGET, when set, tells the system that this gadget,
+ * when selected, causes the Requester to be ended.  Requesters
+ * that are ended are erased and unlinked from the system.
+ }
+ GACT_ENDGADGET    = $0004;
+
+{ the GACT_FOLLOWMOUSE flag, when set, specifies that you want to receive
+ * reports on mouse movements while this gadget is active.
+ * You probably want to set the GACT_IMMEDIATE flag when using
+ * GACT_FOLLOWMOUSE, since that's the only reasonable way you have of
+ * learning why Intuition is suddenly sending you a stream of mouse
+ * movement events.  If you don't set GACT_RELVERIFY, you'll get at
+ * least one Mouse Position event.
+ }
+ GACT_FOLLOWMOUSE = $0008;
+
+{ if any of the BORDER flags are set in a Gadget that's included in the
+ * Gadget list when a Window is opened, the corresponding Border will
+ * be adjusted to make room for the Gadget
+ }
+ GACT_RIGHTBORDER = $0010;
+ GACT_LEFTBORDER  = $0020;
+ GACT_TOPBORDER   = $0040;
+ GACT_BOTTOMBORDER= $0080;
+ GACT_BORDERSNIFF = $8000;  { neither set nor rely on this bit   }
+
+ GACT_TOGGLESELECT= $0100;  { this bit for toggle-select mode }
+ GACT_BOOLEXTEND  = $2000;  { this Boolean Gadget has a BoolInfo }
+
+{ should properly be in StringInfo, but aren't }
+ GACT_STRINGLEFT  = $0000;  { NOTE WELL: that this has value zero        }
+ GACT_STRINGCENTER= $0200;
+ GACT_STRINGRIGHT = $0400;
+ GACT_LONGINT     = $0800;  { this String Gadget is for Long Ints        }
+ GACT_ALTKEYMAP   = $1000;  { this String has an alternate keymap        }
+ GACT_STRINGEXTEND= $2000;  { this String Gadget has StringExtend        }
+                                  { NOTE: NEVER SET GACT_STRINGEXTEND IF YOU
+                                   * ARE RUNNING ON LESS THAN V36!  SEE
+                                   * GFLG_STRINGEXTEND (ABOVE) INSTEAD
+                                   }
+
+ GACT_ACTIVEGADGET = $4000;  { this gadget is "active".  This flag
+                                   * is maintained by Intuition, and you
+                                   * cannot count on its value persisting
+                                   * while you do something on your program's
+                                   * task.  It can only be trusted by
+                                   * people implementing custom gadgets
+                                   }
+
+{ note $8000 is used above (GACT_BORDERSNIFF);
+ * all Activation flags defined }
+
+{ --- GADGET TYPES ------------------------------------------------------- }
+{ These are the Gadget Type definitions for the variable GadgetType
+ * gadget number type MUST start from one.  NO TYPES OF ZERO ALLOWED.
+ * first comes the mask for Gadget flags reserved for Gadget typing
+ }
+ GTYP_GADGETTYPE = $FC00;  { all Gadget Global Type flags (padded) }
+ GTYP_SYSGADGET  = $8000;  { 1 = Allocated by the system, 0 = by app. }
+ GTYP_SCRGADGET  = $4000;  { 1 = ScreenGadget, 0 = WindowGadget }
+ GTYP_GZZGADGET  = $2000;  { 1 = for WFLG_GIMMEZEROZERO borders }
+ GTYP_REQGADGET  = $1000;  { 1 = this is a Requester Gadget }
+{ system gadgets }
+ GTYP_SIZING     = $0010;
+ GTYP_WDRAGGING  = $0020;
+ GTYP_SDRAGGING  = $0030;
+ GTYP_WUPFRONT   = $0040;
+ GTYP_SUPFRONT   = $0050;
+ GTYP_WDOWNBACK  = $0060;
+ GTYP_SDOWNBACK  = $0070;
+ GTYP_CLOSE      = $0080;
+{ application gadgets }
+ GTYP_BOOLGADGET = $0001;
+ GTYP_GADGET0002 = $0002;
+ GTYP_PROPGADGET = $0003;
+ GTYP_STRGADGET  = $0004;
+ GTYP_CUSTOMGADGET    =   $0005;
+
+
+{* GTYP_GTYPEMASK is a mask you can apply to tell what class
+ * of gadget this is.  The possible classes follow.
+ *}
+ GTYP_GTYPEMASK        =  $0007;
+
+{ This bit in GadgetType is reserved for undocumented internal use
+ * by the Gadget Toolkit, and cannot be used nor relied on by
+ * applications:        $0100;
+ }
+
+{ New for V39.  Gadgets which have the GFLG_EXTENDED flag set are
+ * actually ExtGadgets, which have more flags.  The GMORE_xxx
+ * identifiers describe those flags.  For GMORE_SCROLLRASTER, see
+ * important information in the ScrollWindowRaster() autodoc.
+ * NB: GMORE_SCROLLRASTER must be set before the gadget is
+ * added to a window.
+ }
+ GMORE_BOUNDS       = $00000001; { ExtGadget has valid Bounds }
+ GMORE_GADGETHELP   = $00000002; { This gadget responds to gadget help }
+ GMORE_SCROLLRASTER = $00000004; { This (custom) gadget uses ScrollRaster }
+
+{ ======================================================================== }
+{ === BoolInfo======================================================= }
+{ ======================================================================== }
+{ This is the special data needed by an Extended Boolean Gadget
+ * Typically this structure will be pointed to by the Gadget field SpecialInfo
+ }
+Type
+    pBoolInfo = ^tBoolInfo;
+    tBoolInfo = record
+        Flags   : Word;        { defined below }
+        Mask    : Pointer; { bit mask for highlighting and selecting
+                         * mask must follow the same rules as an Image
+                         * plane.  It's width and height are determined
+                         * by the width and height of the gadget's
+                         * select box. (i.e. Gadget.Width and .Height).
+                         }
+        Reserved : ULONG;     { set to 0      }
+    end;
+
+Const
+
+{ set BoolInfo.Flags to this flag bit.
+ * in the future, additional bits might mean more stuff hanging
+ * off of BoolInfo.Reserved.
+}
+    BOOLMASK    = $0001;        { extension is for masked gadget }
+
+{ ======================================================================== }
+{ === PropInfo =========================================================== }
+{ ======================================================================== }
+{ this is the special data required by the proportional Gadget
+ * typically, this data will be pointed to by the Gadget variable SpecialInfo
+ }
+
+Type
+
+    pPropInfo = ^tPropInfo;
+    tPropInfo = record
+        Flags   : Word;        { general purpose flag bits (see defines below) }
+
+    { You initialize the Pot variables before the Gadget is added to
+     * the system.  Then you can look here for the current settings
+     * any time, even while User is playing with this Gadget.  To
+     * adjust these after the Gadget is added to the System, use
+     * ModifyProp();  The Pots are the actual proportional settings,
+     * where a value of zero means zero and a value of MAXPOT means
+     * that the Gadget is set to its maximum setting.
+     }
+
+        HorizPot        : WORD; { 16-bit FixedPoint horizontal quantity percentage }
+        VertPot         : WORD; { 16-bit FixedPoint vertical quantity percentage }
+
+    { the 16-bit FixedPoint Body variables describe what percentage of
+     * the entire body of stuff referred to by this Gadget is actually
+     * shown at one time.  This is used with the AUTOKNOB routines,
+     * to adjust the size of the AUTOKNOB according to how much of
+     * the data can be seen.  This is also used to decide how far
+     * to advance the Pots when User hits the Container of the Gadget.
+     * For instance, if you were controlling the display of a 5-line
+     * Window of text with this Gadget, and there was a total of 15
+     * lines that could be displayed, you would set the VertBody value to
+     *     (MAXBODY / (TotalLines / DisplayLines)) = MAXBODY / 3.
+     * Therefore, the AUTOKNOB would fill 1/3 of the container, and
+     * if User hits the Cotainer outside of the knob, the pot would
+     * advance 1/3 (plus or minus) If there's no body to show, or
+     * the total amount of displayable info is less than the display area,
+     * set the Body variables to the MAX.  To adjust these after the
+     * Gadget is added to the System, use ModifyProp();
+     }
+
+        HorizBody       : Word;        { horizontal Body }
+        VertBody        : Word;        { vertical Body }
+
+    { these are the variables that Intuition sets and maintains }
+
+        CWidth          : Word;        { Container width (with any relativity absoluted) }
+        CHeight         : Word;        { Container height (with any relativity absoluted) }
+        HPotRes,
+        VPotRes         : Word;        { pot increments }
+        LeftBorder      : Word;        { Container borders }
+        TopBorder       : Word;        { Container borders }
+    end;
+
+CONST
+{ --- FLAG BITS ---------------------------------------------------------- }
+ AUTOKNOB     =   $0001;  { this flag sez:  gimme that old auto-knob }
+{ NOTE: if you do not use an AUTOKNOB for a proportional gadget,
+ * you are currently limited to using a single Image of your own
+ * design: Intuition won't handle a linked list of images as
+ * a proportional gadget knob.
+ }
+
+ FREEHORIZ     =  $0002;  { IF set, the knob can move horizontally }
+ FREEVERT      =  $0004;  { IF set, the knob can move vertically }
+ PROPBORDERLESS =  $0008;  { IF set, no border will be rendered }
+ KNOBHIT       =  $0100;  { set when this Knob is hit }
+ PROPNEWLOOK   =  $0010;  { set this IF you want to get the new
+                                 * V36 look
+                                 }
+
+ KNOBHMIN      =  6;       { minimum horizontal size of the Knob }
+ KNOBVMIN      =  4;       { minimum vertical size of the Knob }
+ MAXBODY       =  $FFFF;  { maximum body value }
+ MAXPOT        =  $FFFF;  { maximum pot value }
+
+{ ======================================================================== }
+{ === StringInfo ========================================================= }
+{ ======================================================================== }
+{ this is the special data required by the string Gadget
+ * typically, this data will be pointed to by the Gadget variable SpecialInfo
+ }
+
+Type
+
+    pStringInfo = ^tStringInfo;
+    tStringInfo = record
+    { you initialize these variables, and then Intuition maintains them }
+        Buffer          : STRPTR;       { the buffer containing the start and final string }
+        UndoBuffer      : STRPTR;       { optional buffer for undoing current entry }
+        BufferPos       : Integer;        { character position in Buffer }
+        MaxChars        : Integer;        { max number of chars in Buffer (including NULL) }
+        DispPos         : Integer;        { Buffer position of first displayed character }
+
+    { Intuition initializes and maintains these variables for you }
+
+        UndoPos         : Integer;        { character position in the undo buffer }
+        NumChars        : Integer;        { number of characters currently in Buffer }
+        DispCount       : Integer;        { number of whole characters visible in Container }
+        CLeft,
+        CTop            : Integer;        { topleft offset of the container }
+
+    { you can initialize this variable before the gadget is submitted to
+     * Intuition, and then examine it later to discover what Longint
+     * the user has entered (if the user never plays with the gadget,
+     * the value will be unchanged from your initial setting)
+     }
+        Extension       : Pointer;
+        _LongInt         : Longint;
+
+    { If you want this Gadget to use your own Console keymapping, you
+     * set the ALTKEYMAP bit in the Activation flags of the Gadget, and then
+     * set this variable to point to your keymap.  If you don't set the
+     * ALTKEYMAP, you'll get the standard ASCII keymapping.
+     }
+
+        AltKeyMap       : Pointer;
+    end;
+
+
+{ ======================================================================== }
+{ === Requester ========================================================== }
+{ ======================================================================== }
+
+Type
+
+    pRequester = ^tRequester;
+    tRequester = record
+    { the ClipRect and BitMap and used for rendering the requester }
+        OlderRequest    : pRequester;
+        LeftEdge,
+        TopEdge         : Integer;        { dimensions of the entire box }
+        Width,
+        Height          : Integer;        { dimensions of the entire box }
+        RelLeft,
+        RelTop          : Integer;        { for Pointer relativity offsets }
+
+        ReqGadget       : pGadget;    { pointer to a list of Gadgets }
+        ReqBorder       : pBorder;    { the box's border }
+        ReqText         : pIntuiText; { the box's text }
+        Flags           : Word;        { see definitions below }
+
+    { pen number for back-plane fill before draws }
+
+        BackFill        : Byte;
+
+    { Layer in place of clip rect       }
+
+        ReqLayer        : pLayer;
+
+        ReqPad1         : Array [0..31] of Byte;
+
+    { If the BitMap plane pointers are non-zero, this tells the system
+     * that the image comes pre-drawn (if the appliprog wants to define
+     * it's own box, in any shape or size it wants!);  this is OK by
+     * Intuition as long as there's a good correspondence between
+     * the image and the specified Gadgets
+     }
+
+        ImageBMap       : pBitMap;    { points to the BitMap of PREDRAWN imagery }
+        RWindow         : Pointer;      { added.  points back to Window }
+        ReqImage        : Pointer;
+        ReqPad2         : Array [0..31] of Shortint;
+    end;
+
+
+Const
+
+{ FLAGS SET BY THE APPLIPROG }
+    POINTREL            = $0001;    { if POINTREL set, TopLeft is relative to pointer}
+    PREDRAWN            = $0002;    { if ReqBMap points to predrawn Requester imagery }
+    NOISYREQ            = $0004;    { if you don't want requester to filter input          }
+
+    SIMPLEREQ           = $0010;
+        { to use SIMPLEREFRESH layer (recommended)     }
+
+    { New for V36          }
+    USEREQIMAGE         = $0020;
+         {  render linked list ReqImage after BackFill
+         * but before gadgets and text
+         }
+    NOREQBACKFILL       = $0040;
+        { don't bother filling requester with Requester.BackFill pen   }
+
+
+{ FLAGS SET BY INTUITION }
+    REQOFFWINDOW        = $1000;        { part of one of the Gadgets was offwindow }
+    REQACTIVE           = $2000;        { this requester is active }
+    SYSREQUEST          = $4000;        { this requester caused by system }
+    DEFERREFRESH        = $8000;        { this Requester stops a Refresh broadcast }
+
+
+
+
+{ ======================================================================== }
+{ === Image ============================================================== }
+{ ======================================================================== }
+{ This is a brief image structure for very simple transfers of
+ * image data to a RastPort
+ }
+
+Type
+    pImage = ^tImage;
+    tImage = record
+        LeftEdge        : Integer;        { starting offset relative to some origin }
+        TopEdge         : Integer;        { starting offsets relative to some origin }
+        Width           : Integer;        { pixel size (though data is word-aligned) }
+        Height,
+        Depth           : Integer;        { pixel sizes }
+        ImageData       : Pointer;      { pointer to the actual word-aligned bits }
+
+    { the PlanePick and PlaneOnOff variables work much the same way as the
+     * equivalent GELS Bob variables.  It's a space-saving
+     * mechanism for image data.  Rather than defining the image data
+     * for every plane of the RastPort, you need define data only
+     * for the planes that are not entirely zero or one.  As you
+     * define your Imagery, you will often find that most of the planes
+     * ARE just as color selectors.  For instance, if you're designing
+     * a two-color Gadget to use colors two and three, and the Gadget
+     * will reside in a five-plane display, bit plane zero of your
+     * imagery would be all ones, bit plane one would have data that
+     * describes the imagery, and bit planes two through four would be
+     * all zeroes.  Using these flags allows you to avoid wasting all
+     * that memory in this way:  first, you specify which planes you
+     * want your data to appear in using the PlanePick variable.  For
+     * each bit set in the variable, the next "plane" of your image
+     * data is blitted to the display.  For each bit clear in this
+     * variable, the corresponding bit in PlaneOnOff is examined.
+     * If that bit is clear, a "plane" of zeroes will be used.
+     * If the bit is set, ones will go out instead.  So, for our example:
+     *   Gadget.PlanePick = $02;
+     *   Gadget.PlaneOnOff = $01;
+     * Note that this also allows for generic Gadgets, like the
+     * System Gadgets, which will work in any number of bit planes.
+     * Note also that if you want an Image that is only a filled
+     * rectangle, you can get this by setting PlanePick to zero
+     * (pick no planes of data) and set PlaneOnOff to describe the pen
+     * color of the rectangle.
+     }
+
+        PlanePick,
+        PlaneOnOff      : Byte;
+
+    { if the NextImage variable is not NULL, Intuition presumes that
+     * it points to another Image structure with another Image to be
+     * rendered
+     }
+
+        NextImage       : pImage;
+    end;
+
+
+{ New for V39, Intuition supports the IESUBCLASS_NEWTABLET subclass
+ * of the IECLASS_NEWPOINTERPOS event.  The ie_EventAddress of such
+ * an event points to a TabletData structure (see below).
+ *
+ * The TabletData structure contains certain elements including a taglist.
+ * The taglist can be used for special tablet parameters.  A tablet driver
+ * should include only those tag-items the tablet supports.  An application
+ * can listen for any tag-items that interest it.  Note: an application
+ * must set the WA_TabletMessages attribute to TRUE to receive this
+ * extended information in its IntuiMessages.
+ *
+ * The definitions given here MUST be followed.  Pay careful attention
+ * to normalization and the interpretation of signs.
+ *
+ * TABLETA_TabletZ:  the current value of the tablet in the Z direction.
+ * This unsigned value should typically be in the natural units of the
+ * tablet.  You should also provide TABLETA_RangeZ.
+ *
+ * TABLETA_RangeZ:  the maximum value of the tablet in the Z direction.
+ * Normally specified along with TABLETA_TabletZ, this allows the
+ * application to scale the actual Z value across its range.
+ *
+ * TABLETA_AngleX:  the angle of rotation or tilt about the X-axis.  This
+ * number should be normalized to fill a signed long Longint.  Positive
+ * values imply a clockwise rotation about the X-axis when viewing
+ * from +X towards the origin.
+ *
+ * TABLETA_AngleY:  the angle of rotation or tilt about the Y-axis.  This
+ * number should be normalized to fill a signed long Longint.  Positive
+ * values imply a clockwise rotation about the Y-axis when viewing
+ * from +Y towards the origin.
+ *
+ * TABLETA_AngleZ:  the angle of rotation or tilt about the Z axis.  This
+ * number should be normalized to fill a signed long Longint.  Positive
+ * values imply a clockwise rotation about the Z-axis when viewing
+ * from +Z towards the origin.
+ *
+ *      Note: a stylus that supports tilt should use the TABLETA_AngleX
+ *      and TABLETA_AngleY attributes.  Tilting the stylus so the tip
+ *      points towards increasing or decreasing X is actually a rotation
+ *      around the Y-axis.  Thus, if the stylus tip points towards
+ *      positive X, then that tilt is represented as a negative
+ *      TABLETA_AngleY.  Likewise, if the stylus tip points towards
+ *      positive Y, that tilt is represented by positive TABLETA_AngleX.
+ *
+ * TABLETA_Pressure:  the pressure reading of the stylus.  The pressure
+ * should be normalized to fill a signed long Longint.  Typical devices
+ * won't generate negative pressure, but the possibility is not precluded.
+ * The pressure threshold which is considered to cause a button-click is
+ * expected to be set in a Preferences program supplied by the tablet
+ * vendor.  The tablet driver would send IECODE_LBUTTON-type events as
+ * the pressure crossed that threshold.
+ *
+ * TABLETA_ButtonBits:  ti_Data is a long Longint whose bits are to
+ * be interpreted at the state of the first 32 buttons of the tablet.
+ *
+ * TABLETA_InProximity:  ti_Data is a boolean.  For tablets that support
+ * proximity, they should send the (TABLETA_InProximity,FALSE) tag item
+ * when the stylus is out of proximity.  One possible use we can forsee
+ * is a mouse-blanking commodity which keys off this to blank the
+ * mouse.  When this tag is absent, the stylus is assumed to be
+ * in proximity.
+ *
+ * TABLETA_ResolutionX:  ti_Data is an unsigned long Longint which
+ * is the x-axis resolution in dots per inch.
+ *
+ * TABLETA_ResolutionY:  ti_Data is an unsigned long Longint which
+ * is the y-axis resolution in dots per inch.
+ }
+
+const
+ TABLETA_Dummy          = (TAG_USER + $3A000)  ;
+ TABLETA_TabletZ        = (TABLETA_Dummy + $01);
+ TABLETA_RangeZ         = (TABLETA_Dummy + $02);
+ TABLETA_AngleX         = (TABLETA_Dummy + $03);
+ TABLETA_AngleY         = (TABLETA_Dummy + $04);
+ TABLETA_AngleZ         = (TABLETA_Dummy + $05);
+ TABLETA_Pressure       = (TABLETA_Dummy + $06);
+ TABLETA_ButtonBits     = (TABLETA_Dummy + $07);
+ TABLETA_InProximity    = (TABLETA_Dummy + $08);
+ TABLETA_ResolutionX    = (TABLETA_Dummy + $09);
+ TABLETA_ResolutionY    = (TABLETA_Dummy + $0A);
+
+{ If your window sets WA_TabletMessages to TRUE, then it will receive
+ * extended IntuiMessages (struct ExtIntuiMessage) whose eim_TabletData
+ * field points at a TabletData structure.  This structure contains
+ * additional information about the input event.
+ }
+
+Type
+ pTabletData = ^tTabletData;
+ tTabletData = record
+    { Sub-pixel position of tablet, in screen coordinates,
+     * scaled to fill a UWORD fraction:
+     }
+    td_XFraction, td_YFraction  : WORD;
+
+    { Current tablet coordinates along each axis: }
+    td_TabletX, td_TabletY      : ULONG;
+
+    { Tablet range along each axis.  For example, if td_TabletX
+     * can take values 0-999, td_RangeX should be 1000.
+     }
+    td_RangeX, td_RangeY        : ULONG;
+
+    { Pointer to tag-list of additional tablet attributes.
+     * See <intuition/intuition.h> for the tag values.
+     }
+    td_TagList                  : pTagItem;
+ end;
+
+{ If a tablet driver supplies a hook for ient_CallBack, it will be
+ * invoked in the standard hook manner.  A0 will point to the Hook
+ * itself, A2 will point to the InputEvent that was sent, and
+ * A1 will point to a TabletHookData structure.  The InputEvent's
+ * ie_EventAddress field points at the IENewTablet structure that
+ * the driver supplied.
+ *
+ * Based on the thd_Screen, thd_Width, and thd_Height fields, the driver
+ * should scale the ient_TabletX and ient_TabletY fields and store the
+ * result in ient_ScaledX, ient_ScaledY, ient_ScaledXFraction, and
+ * ient_ScaledYFraction.
+ *
+ * The tablet hook must currently return NULL.  This is the only
+ * acceptable return-value under V39.
+ }
+
+ pTabletHookData = ^tTabletHookData;
+ tTabletHookData = record
+    { Pointer to the active screen:
+     * Note: if there are no open screens, thd_Screen will be NULL.
+     * thd_Width and thd_Height will then describe an NTSC 64$400
+     * screen.  Please scale accordingly.
+     }
+    thd_Screen      : Pointer;
+
+    { The width and height (measured in pixels of the active screen)
+     * that your are to scale to:
+     }
+    thd_Width,
+    thd_Height      : ULONG;
+
+    { Non-zero if the screen or something about the screen
+     * changed since the last time you were invoked:
+     }
+    thd_ScreenChanged   : Longint;
+ end;
+
+
+{ ======================================================================== }
+{ === IntuiMessage ======================================================= }
+{ ======================================================================== }
+
+Type
+
+    pIntuiMessage = ^tIntuiMessage;
+    tIntuiMessage = record
+        ExecMessage     : tMessage;
+
+    { the Class bits correspond directly with the IDCMP Flags, except for the
+     * special bit LONELYMESSAGE (defined below)
+     }
+
+        IClass           : ULONG;
+
+    { the Code field is for special values like MENU number }
+
+        Code            : Word;
+
+    { the Qualifier field is a copy of the current InputEvent's Qualifier }
+
+        Qualifier       : Word;
+
+    { IAddress contains particular addresses for Intuition functions, like
+     * the pointer to the Gadget or the Screen
+     }
+
+        IAddress        : Pointer;
+
+    { when getting mouse movement reports, any event you get will have the
+     * the mouse coordinates in these variables.  the coordinates are relative
+     * to the upper-left corner of your Window (GIMMEZEROZERO notwithstanding)
+     }
+
+        MouseX,
+        MouseY          : Integer;
+
+    { the time values are copies of the current system clock time.  Micros
+     * are in units of microseconds, Seconds in seconds.
+     }
+
+        Seconds,
+        Micros          : ULONG;
+
+    { the IDCMPWindow variable will always have the Pointer of the Window of
+     * this IDCMP
+     }
+
+        IDCMPWindow     : Pointer;
+
+    { system-use variable }
+
+        SpecialLink     : pIntuiMessage;
+    end;
+
+{ New for V39:
+ * All IntuiMessages are now slightly extended.  The ExtIntuiMessage
+ * structure has an additional field for tablet data, which is usually
+ * NULL.  If a tablet driver which is sending IESUBCLASS_NEWTABLET
+ * events is installed in the system, windows with the WA_TabletMessages
+ * property set will find that eim_TabletData points to the TabletData
+ * structure.  Applications must first check that this field is non-NULL;
+ * it will be NULL for certain kinds of message, including mouse activity
+ * generated from other than the tablet (i.e. the keyboard equivalents
+ * or the mouse itself).
+ *
+ * NEVER EVER examine any extended fields when running under pre-V39!
+ *
+ * NOTE: This structure is subject to grow in the future.  Making
+ * assumptions about its size is A BAD IDEA.
+ }
+
+ pExtIntuiMessage = ^tExtIntuiMessage;
+ tExtIntuiMessage = record
+    eim_IntuiMessage  : tIntuiMessage;
+    eim_TabletData    : pTabletData;
+ end;
+
+
+CONST
+
+{ --- IDCMP Classes ------------------------------------------------------ }
+{ Please refer to the Autodoc for OpenWindow() and to the Rom Kernel
+ * Manual for full details on the IDCMP classes.
+ }
+ IDCMP_SIZEVERIFY      =  $00000001;
+ IDCMP_NEWSIZE         =  $00000002;
+ IDCMP_REFRESHWINDOW   =  $00000004;
+ IDCMP_MOUSEBUTTONS    =  $00000008;
+ IDCMP_MOUSEMOVE       =  $00000010;
+ IDCMP_GADGETDOWN      =  $00000020;
+ IDCMP_GADGETUP        =  $00000040;
+ IDCMP_REQSET          =  $00000080;
+ IDCMP_MENUPICK        =  $00000100;
+ IDCMP_CLOSEWINDOW     =  $00000200;
+ IDCMP_RAWKEY          =  $00000400;
+ IDCMP_REQVERIFY       =  $00000800;
+ IDCMP_REQCLEAR        =  $00001000;
+ IDCMP_MENUVERIFY      =  $00002000;
+ IDCMP_NEWPREFS        =  $00004000;
+ IDCMP_DISKINSERTED    =  $00008000;
+ IDCMP_DISKREMOVED     =  $00010000;
+ IDCMP_WBENCHMESSAGE   =  $00020000;  {  System use only         }
+ IDCMP_ACTIVEWINDOW    =  $00040000;
+ IDCMP_INACTIVEWINDOW  =  $00080000;
+ IDCMP_DELTAMOVE       =  $00100000;
+ IDCMP_VANILLAKEY      =  $00200000;
+ IDCMP_INTUITICKS      =  $00400000;
+{  for notifications from "boopsi" gadgets               }
+ IDCMP_IDCMPUPDATE     =  $00800000;  { new for V36      }
+{ for getting help key report during menu session        }
+ IDCMP_MENUHELP        =  $01000000;  { new for V36      }
+{ for notification of any move/size/zoom/change window   }
+ IDCMP_CHANGEWINDOW    =  $02000000;  { new for V36      }
+ IDCMP_GADGETHELP      =  $04000000;  { new for V39      }
+
+{ NOTEZ-BIEN:                          $80000000 is reserved for internal use   }
+
+{ the IDCMP Flags do not use this special bit, which is cleared when
+ * Intuition sends its special message to the Task, and set when Intuition
+ * gets its Message back from the Task.  Therefore, I can check here to
+ * find out fast whether or not this Message is available for me to send
+ }
+ IDCMP_LONELYMESSAGE   =  $80000000;
+
+
+{ --- IDCMP Codes -------------------------------------------------------- }
+{ This group of codes is for the IDCMP_CHANGEWINDOW message }
+ CWCODE_MOVESIZE = $0000;  { Window was moved and/or sized }
+ CWCODE_DEPTH    = $0001;  { Window was depth-arranged (new for V39) }
+
+{ This group of codes is for the IDCMP_MENUVERIFY function }
+ MENUHOT       =  $0001;  { IntuiWants verification OR MENUCANCEL    }
+ MENUCANCEL    =  $0002;  { HOT Reply of this cancels Menu operation }
+ MENUWAITING   =  $0003;  { Intuition simply wants a ReplyMsg() ASAP }
+
+{ These are internal tokens to represent state of verification attempts
+ * shown here as a clue.
+ }
+ OKOK          =  MENUHOT; { guy didn't care                      }
+ OKABORT       =  $0004;  { window rendered question moot        }
+ OKCANCEL      =  MENUCANCEL; { window sent cancel reply          }
+
+{ This group of codes is for the IDCMP_WBENCHMESSAGE messages }
+ WBENCHOPEN    =  $0001;
+ WBENCHCLOSE   =  $0002;
+
+
+{ A data structure common in V36 Intuition processing  }
+Type
+   pIBox = ^tIBox;
+   tIBox = record
+    Left,
+    Top,
+    Width,
+    Height : Integer;
+   END;
+
+
+{ ======================================================================== }
+{ === Window ============================================================= }
+{ ======================================================================== }
+
+Type
+
+    pWindow = ^tWindow;
+    tWindow = record
+        NextWindow      : pWindow;      { for the linked list in a screen }
+
+        LeftEdge,
+        TopEdge         : Integer;        { screen dimensions of window }
+        Width,
+        Height          : Integer;        { screen dimensions of window }
+
+        MouseY,
+        MouseX          : Integer;        { relative to upper-left of window }
+
+        MinWidth,
+        MinHeight       : Integer;        { minimum sizes }
+        MaxWidth,
+        MaxHeight       : Word;        { maximum sizes }
+
+        Flags           : ULONG;      { see below for defines }
+
+        MenuStrip       : pMenu;      { the strip of Menu headers }
+
+        Title           : STRPTR;       { the title text for this window }
+
+        FirstRequest    : pRequester; { all active Requesters }
+
+        DMRequest       : pRequester; { double-click Requester }
+
+        ReqCount        : Integer;        { count of reqs blocking Window }
+
+        WScreen         : Pointer;      { this Window's Screen }
+        RPort           : pRastPort;  { this Window's very own RastPort }
+
+    { the border variables describe the window border.   If you specify
+     * GIMMEZEROZERO when you open the window, then the upper-left of the
+     * ClipRect for this window will be upper-left of the BitMap (with correct
+     * offsets when in SuperBitMap mode; you MUST select GIMMEZEROZERO when
+     * using SuperBitMap).  If you don't specify ZeroZero, then you save
+     * memory (no allocation of RastPort, Layer, ClipRect and associated
+     * Bitmaps), but you also must offset all your writes by BorderTop,
+     * BorderLeft and do your own mini-clipping to prevent writing over the
+     * system gadgets
+     }
+
+        BorderLeft,
+        BorderTop,
+        BorderRight,
+        BorderBottom    : Shortint;
+        BorderRPort     : pRastPort;
+
+
+    { You supply a linked-list of Gadgets for your Window.
+     * This list DOES NOT include system gadgets.  You get the standard
+     * window system gadgets by setting flag-bits in the variable Flags (see
+     * the bit definitions below)
+     }
+
+        FirstGadget     : pGadget;
+
+    { these are for opening/closing the windows }
+
+        Parent,
+        Descendant      : pWindow;
+
+    { sprite data information for your own Pointer
+     * set these AFTER you Open the Window by calling SetPointer()
+     }
+
+        _Pointer         : Pointer;      { sprite data }
+        PtrHeight       : Shortint;         { sprite height (not including sprite padding) }
+        PtrWidth        : Shortint;         { sprite width (must be less than or equal to 16) }
+        XOffset,
+        YOffset         : Shortint;         { sprite offsets }
+
+    { the IDCMP Flags and User's and Intuition's Message Ports }
+        IDCMPFlags      : ULONG;      { User-selected flags }
+        UserPort,
+        WindowPort      : pMsgPort;
+        MessageKey      : pIntuiMessage;
+
+        DetailPen,
+        BlockPen        : Byte; { for bar/border/gadget rendering }
+
+    { the CheckMark is a pointer to the imagery that will be used when
+     * rendering MenuItems of this Window that want to be checkmarked
+     * if this is equal to NULL, you'll get the default imagery
+     }
+
+        CheckMark       : pImage;
+
+        ScreenTitle     : STRPTR; { if non-null, Screen title when Window is active }
+
+    { These variables have the mouse coordinates relative to the
+     * inner-Window of GIMMEZEROZERO Windows.  This is compared with the
+     * MouseX and MouseY variables, which contain the mouse coordinates
+     * relative to the upper-left corner of the Window, GIMMEZEROZERO
+     * notwithstanding
+     }
+
+        GZZMouseX       : Integer;
+        GZZMouseY       : Integer;
+
+    { these variables contain the width and height of the inner-Window of
+     * GIMMEZEROZERO Windows
+     }
+
+        GZZWidth        : Integer;
+        GZZHeight       : Integer;
+
+        ExtData         : Pointer;
+
+        UserData        : Pointer;      { general-purpose pointer to User data extension }
+
+    {* jimm: NEW: 11/18/85: this pointer keeps a duplicate of what
+     * Window.RPort->Layer is _supposed_ to be pointing at
+     }
+
+        WLayer          : pLayer;
+
+    { jimm: NEW 1.2: need to keep track of the font that
+     * OpenWindow opened, in case user SetFont's into RastPort
+     }
+
+        IFont           : pTextFont;
+    {* (V36) another flag word (the Flags field is used up).
+     * At present, all flag values are system private.
+     * Until further notice, you may not change nor use this field.
+     *}
+        MoreFlags       : ULONG;
+
+    {**** Data beyond this point are Intuition Private.  DO NOT USE ****}
+
+    end;
+
+CONST
+{ --- Flags requested at OpenWindow() time by the application --------- }
+ WFLG_SIZEGADGET   =  $00000001;  { include sizing system-gadget? }
+ WFLG_DRAGBAR      =  $00000002;  { include dragging system-gadget? }
+ WFLG_DEPTHGADGET  =  $00000004;  { include depth arrangement gadget? }
+ WFLG_CLOSEGADGET  =  $00000008;  { include close-box system-gadget? }
+
+ WFLG_SIZEBRIGHT   =  $00000010;  { size gadget uses right border }
+ WFLG_SIZEBBOTTOM  =  $00000020;  { size gadget uses bottom border }
+
+{ --- refresh modes ------------------------------------------------------ }
+{ combinations of the WFLG_REFRESHBITS select the refresh type }
+ WFLG_REFRESHBITS   = $000000C0;
+ WFLG_SMART_REFRESH = $00000000;
+ WFLG_SIMPLE_REFRESH= $00000040;
+ WFLG_SUPER_BITMAP  = $00000080;
+ WFLG_OTHER_REFRESH = $000000C0;
+
+ WFLG_BACKDROP      = $00000100;  { this is a backdrop window }
+
+ WFLG_REPORTMOUSE   = $00000200;  { to hear about every mouse move }
+
+ WFLG_GIMMEZEROZERO = $00000400;  { a GimmeZeroZero window       }
+
+ WFLG_BORDERLESS    = $00000800;  { to get a Window sans border }
+
+ WFLG_ACTIVATE      = $00001000;  { when Window opens, it's Active }
+
+
+{ --- Other User Flags --------------------------------------------------- }
+ WFLG_RMBTRAP       = $00010000;  { Catch RMB events for your own }
+ WFLG_NOCAREREFRESH = $00020000;  { not to be bothered with REFRESH }
+
+{ - V36 new Flags which the programmer may specify in NewWindow.Flags  }
+ WFLG_NW_EXTENDED   = $00040000;  { extension data provided      }
+                                        { see struct ExtNewWindow      }
+
+{ - V39 new Flags which the programmer may specify in NewWindow.Flags  }
+ WFLG_NEWLOOKMENUS  = $00200000;  { window has NewLook menus     }
+
+{ These flags are set only by Intuition.  YOU MAY NOT SET THEM YOURSELF! }
+ WFLG_WINDOWACTIVE  = $00002000;  { this window is the active one }
+ WFLG_INREQUEST     = $00004000;  { this window is in request mode }
+ WFLG_MENUSTATE     = $00008000;  { Window is active with Menus on }
+ WFLG_WINDOWREFRESH = $01000000;  { Window is currently refreshing }
+ WFLG_WBENCHWINDOW  = $02000000;  { WorkBench tool ONLY Window }
+ WFLG_WINDOWTICKED  = $04000000;  { only one timer tick at a time }
+
+{ --- V36 Flags to be set only by Intuition -------------------------  }
+ WFLG_VISITOR       = $08000000;  { visitor window               }
+ WFLG_ZOOMED        = $10000000;  { identifies "zoom state"      }
+ WFLG_HASZOOM       = $20000000;  { windowhas a zoom gadget      }
+
+{ --- Other Window Values ---------------------------------------------- }
+ DEFAULTMOUSEQUEUE  =     (5);     { no more mouse messages       }
+
+{ --- see struct IntuiMessage for the IDCMP Flag definitions ------------- }
+
+
+{ ======================================================================== }
+{ === NewWindow ========================================================== }
+{ ======================================================================== }
+
+Type
+
+    pNewWindow = ^tNewWindow;
+    tNewWindow = record
+        LeftEdge,
+        TopEdge         : Integer;        { screen dimensions of window }
+        Width,
+        Height          : Integer;        { screen dimensions of window }
+
+        DetailPen,
+        BlockPen        : Byte;         { for bar/border/gadget rendering }
+
+        IDCMPFlags      : ULONG;      { User-selected IDCMP flags }
+
+        Flags           : ULONG;      { see Window struct for defines }
+
+    { You supply a linked-list of Gadgets for your Window.
+     *  This list DOES NOT include system Gadgets.  You get the standard
+     *  system Window Gadgets by setting flag-bits in the variable Flags (see
+     *  the bit definitions under the Window structure definition)
+     }
+
+        FirstGadget     : pGadget;
+
+    { the CheckMark is a pointer to the imagery that will be used when
+     * rendering MenuItems of this Window that want to be checkmarked
+     * if this is equal to NULL, you'll get the default imagery
+     }
+
+        CheckMark       : pImage;
+
+        Title           : STRPTR;  { the title text for this window }
+
+    { the Screen pointer is used only if you've defined a CUSTOMSCREEN and
+     * want this Window to open in it.  If so, you pass the Pointer of the
+     * Custom Screen structure in this variable.  Otherwise, this variable
+     * is ignored and doesn't have to be initialized.
+     }
+
+        Screen          : Pointer;
+
+    { SUPER_BITMAP Window?  If so, put the Pointer of your BitMap structure
+     * in this variable.  If not, this variable is ignored and doesn't have
+     * to be initialized
+     }
+
+        BitMap          : pBitMap;
+
+    { the values describe the minimum and maximum sizes of your Windows.
+     * these matter only if you've chosen the WINDOWSIZING Gadget option,
+     * which means that you want to let the User to change the size of
+     * this Window.  You describe the minimum and maximum sizes that the
+     * Window can grow by setting these variables.  You can initialize
+     * any one these to zero, which will mean that you want to duplicate
+     * the setting for that dimension (if MinWidth == 0, MinWidth will be
+     * set to the opening Width of the Window).
+     * You can change these settings later using SetWindowLimits().
+     * If you haven't asked for a SIZING Gadget, you don't have to
+     * initialize any of these variables.
+     }
+
+        MinWidth,
+        MinHeight       : Integer;        { minimums }
+        MaxWidth,
+        MaxHeight       : Word;        { maximums }
+
+    { the type variable describes the Screen in which you want this Window to
+     * open.  The type value can either be CUSTOMSCREEN or one of the
+     * system standard Screen Types such as WBENCHSCREEN.  See the
+     * type definitions under the Screen structure
+     }
+
+        WType           : Word;        { is "Type" in C includes }
+    end;
+
+
+{ The following structure is the future NewWindow.  Compatibility
+ * issues require that the size of NewWindow not change.
+ * Data in the common part (NewWindow) indicates the the extension
+ * fields are being used.
+ * NOTE WELL: This structure may be subject to future extension.
+ * Writing code depending on its size is not allowed.
+ }
+   pExtNewWindow = ^tExtNewWindow;
+   tExtNewWindow = record
+    LeftEdge, TopEdge : Integer;
+    Width, Height : Integer;
+
+    DetailPen, BlockPen : Byte;
+    IDCMPFlags    : ULONG;
+    Flags         : ULONG;
+    FirstGadget   : pGadget;
+
+    CheckMark     : pImage;
+
+    Title         : STRPTR;
+    WScreen       : Pointer;
+    WBitMap       : pBitMap;
+
+    MinWidth, MinHeight : Integer;
+    MaxWidth, MaxHeight : Word;
+
+    { the type variable describes the Screen in which you want this Window to
+     * open.  The type value can either be CUSTOMSCREEN or one of the
+     * system standard Screen Types such as WBENCHSCREEN.  See the
+     * type definitions under the Screen structure.
+     * A new possible value for this field is PUBLICSCREEN, which
+     * defines the window as a 'visitor' window.  See below for
+     * additional information provided.
+     }
+    WType  : Word;
+
+    { ------------------------------------------------------- *
+     * extensions for V36
+     * if the NewWindow Flag value WFLG_NW_EXTENDED is set, then
+     * this field is assumed to point to an array ( or chain of arrays)
+     * of TagItem structures.  See also ExtNewScreen for another
+     * use of TagItems to pass optional data.
+     *
+     * see below for tag values and the corresponding data.
+     }
+    Extension : pTagItem;
+  END;
+
+{
+ * The TagItem ID's (ti_Tag values) for OpenWindowTagList() follow.
+ * They are values in a TagItem array passed as extension/replacement
+ * values for the data in NewWindow.  OpenWindowTagList() can actually
+ * work well with a NULL NewWindow pointer.
+ }
+CONST
+ WA_Dummy     =   (TAG_USER + 99); { $80000063   }
+
+{ these tags simply override NewWindow parameters }
+ WA_Left               =  (WA_Dummy + $01);
+ WA_Top                =  (WA_Dummy + $02);
+ WA_Width              =  (WA_Dummy + $03);
+ WA_Height             =  (WA_Dummy + $04);
+ WA_DetailPen          =  (WA_Dummy + $05);
+ WA_BlockPen           =  (WA_Dummy + $06);
+ WA_IDCMP              =  (WA_Dummy + $07);
+                        { "bulk" initialization of NewWindow.Flags }
+ WA_Flags              =  (WA_Dummy + $08);
+ WA_Gadgets            =  (WA_Dummy + $09);
+ WA_Checkmark          =  (WA_Dummy + $0A);
+ WA_Title              =  (WA_Dummy + $0B);
+                        { means you don't have to call SetWindowTitles
+                         * after you open your window
+                         }
+ WA_ScreenTitle        =  (WA_Dummy + $0C);
+ WA_CustomScreen       =  (WA_Dummy + $0D);
+ WA_SuperBitMap        =  (WA_Dummy + $0E);
+                        { also implies WFLG_SUPER_BITMAP property      }
+ WA_MinWidth           =  (WA_Dummy + $0F);
+ WA_MinHeight          =  (WA_Dummy + $10);
+ WA_MaxWidth           =  (WA_Dummy + $11);
+ WA_MaxHeight          =  (WA_Dummy + $12);
+
+{ The following are specifications for new features    }
+
+ WA_InnerWidth         =  (WA_Dummy + $13);
+ WA_InnerHeight        =  (WA_Dummy + $14);
+                        { You can specify the dimensions of the interior
+                         * region of your window, independent of what
+                         * the border widths will be.  You probably want
+                         * to also specify WA_AutoAdjust to allow
+                         * Intuition to move your window or even
+                         * shrink it so that it is completely on screen.
+                         }
+
+ WA_PubScreenName      =  (WA_Dummy + $15);
+                        { declares that you want the window to open as
+                         * a visitor on the public screen whose name is
+                         * pointed to by (UBYTE *) ti_Data
+                         }
+ WA_PubScreen          =  (WA_Dummy + $16);
+                        { open as a visitor window on the public screen
+                         * whose Pointer is in (struct Screen *) ti_Data.
+                         * To ensure that this screen remains open, you
+                         * should either be the screen's owner, have a
+                         * window open on the screen, or use LockPubScreen().
+                         }
+ WA_PubScreenFallBack  =  (WA_Dummy + $17);
+                        { A Boolean, specifies whether a visitor window
+                         * should "fall back" to the default public screen
+                         * (or Workbench) if the named public screen isn't
+                         * available
+                         }
+ WA_WindowName         =  (WA_Dummy + $18);
+                        { not implemented      }
+ WA_Colors             =  (WA_Dummy + $19);
+                        { a ColorSpec array for colors to be set
+                         * when this window is active.  This is not
+                         * implemented, and may not be, since the default
+                         * values to restore would be hard to track.
+                         * We'd like to at least support per-window colors
+                         * for the mouse pointer sprite.
+                         }
+ WA_Zoom       =  (WA_Dummy + $1A);
+                        { ti_Data points to an array of four WORD's,
+                         * the initial Left/Top/Width/Height values of
+                         * the "alternate" zoom position/dimensions.
+                         * It also specifies that you want a Zoom gadget
+                         * for your window, whether or not you have a
+                         * sizing gadget.
+                         }
+ WA_MouseQueue         =  (WA_Dummy + $1B);
+                        { ti_Data contains initial value for the mouse
+                         * message backlog limit for this window.
+                         }
+ WA_BackFill           =  (WA_Dummy + $1C);
+                        { unimplemented at present: provides a "backfill
+                         * hook" for your window's layer.
+                         }
+ WA_RptQueue           =  (WA_Dummy + $1D);
+                        { initial value of repeat key backlog limit    }
+
+    { These Boolean tag items are alternatives to the NewWindow.Flags
+     * boolean flags with similar names.
+     }
+ WA_SizeGadget         =  (WA_Dummy + $1E);
+ WA_DragBar            =  (WA_Dummy + $1F);
+ WA_DepthGadget        =  (WA_Dummy + $20);
+ WA_CloseGadget        =  (WA_Dummy + $21);
+ WA_Backdrop           =  (WA_Dummy + $22);
+ WA_ReportMouse        =  (WA_Dummy + $23);
+ WA_NoCareRefresh      =  (WA_Dummy + $24);
+ WA_Borderless         =  (WA_Dummy + $25);
+ WA_Activate           =  (WA_Dummy + $26);
+ WA_RMBTrap            =  (WA_Dummy + $27);
+ WA_WBenchWindow       =  (WA_Dummy + $28);       { PRIVATE!! }
+ WA_SimpleRefresh      =  (WA_Dummy + $29);
+                        { only specify if TRUE }
+ WA_SmartRefresh       =  (WA_Dummy + $2A);
+                        { only specify if TRUE }
+ WA_SizeBRight         =  (WA_Dummy + $2B);
+ WA_SizeBBottom        =  (WA_Dummy + $2C);
+
+    { New Boolean properties   }
+ WA_AutoAdjust         =  (WA_Dummy + $2D);
+                        { shift or squeeze the window's position and
+                         * dimensions to fit it on screen.
+                         }
+
+ WA_GimmeZeroZero      =  (WA_Dummy + $2E);
+                        { equiv. to NewWindow.Flags WFLG_GIMMEZEROZERO }
+
+{ New for V37: WA_MenuHelp (ignored by V36) }
+ WA_MenuHelp           =  (WA_Dummy + $2F);
+                        { Enables IDCMP_MENUHELP:  Pressing HELP during menus
+                         * will return IDCMP_MENUHELP message.
+                         }
+
+{ New for V39:  (ignored by V37 and earlier) }
+ WA_NewLookMenus       =  (WA_Dummy + $30);
+                        { Set to TRUE if you want NewLook menus }
+ WA_AmigaKey           =  (WA_Dummy + $31);
+                        { Pointer to image for Amiga-key equiv in menus }
+ WA_NotifyDepth        =  (WA_Dummy + $32);
+                        { Requests IDCMP_CHANGEWINDOW message when
+                         * window is depth arranged
+                         * (imsg->Code = CWCODE_DEPTH)
+                         }
+
+{ WA_Dummy + $33 is obsolete }
+
+ WA_Pointer            =  (WA_Dummy + $34);
+                        { Allows you to specify a custom pointer
+                         * for your window.  ti_Data points to a
+                         * pointer object you obtained via
+                         * "pointerclass". NULL signifies the
+                         * default pointer.
+                         * This tag may be passed to OpenWindowTags()
+                         * or SetWindowPointer().
+                         }
+
+ WA_BusyPointer        =  (WA_Dummy + $35);
+                        { ti_Data is boolean.  Set to TRUE to
+                         * request the standard busy pointer.
+                         * This tag may be passed to OpenWindowTags()
+                         * or SetWindowPointer().
+                         }
+
+ WA_PointerDelay       =  (WA_Dummy + $36);
+                        { ti_Data is boolean.  Set to TRUE to
+                         * request that the changing of the
+                         * pointer be slightly delayed.  The change
+                         * will be called off if you call NewSetPointer()
+                         * before the delay expires.  This allows
+                         * you to post a busy-pointer even if you think
+                         * the busy-time may be very Word, without
+                         * fear of a flashing pointer.
+                         * This tag may be passed to OpenWindowTags()
+                         * or SetWindowPointer().
+                         }
+
+ WA_TabletMessages     =  (WA_Dummy + $37);
+                        { ti_Data is a boolean.  Set to TRUE to
+                         * request that tablet information be included
+                         * in IntuiMessages sent to your window.
+                         * Requires that something (i.e. a tablet driver)
+                         * feed IESUBCLASS_NEWTABLET InputEvents into
+                         * the system.  For a pointer to the TabletData,
+                         * examine the ExtIntuiMessage->eim_TabletData
+                         * field.  It is UNSAFE to check this field
+                         * when running on pre-V39 systems.  It's always
+                         * safe to check this field under V39 and up,
+                         * though it may be NULL.
+                         }
+
+ WA_HelpGroup          =  (WA_Dummy + $38);
+                        { When the active window has gadget help enabled,
+                         * other windows of the same HelpGroup number
+                         * will also get GadgetHelp.  This allows GadgetHelp
+                         * to work for multi-windowed applications.
+                         * Use GetGroupID() to get an ID number.  Pass
+                         * this number as ti_Data to all your windows.
+                         * See also the HelpControl() function.
+                         }
+
+ WA_HelpGroupWindow    =  (WA_Dummy + $39);
+                        { When the active window has gadget help enabled,
+                         * other windows of the same HelpGroup will also get
+                         * GadgetHelp.  This allows GadgetHelp to work
+                         * for multi-windowed applications.  As an alternative
+                         * to WA_HelpGroup, you can pass a pointer to any
+                         * other window of the same group to join its help
+                         * group.  Defaults to NULL, which has no effect.
+                         * See also the HelpControl() function.
+                         }
+
+
+{ HelpControl() flags:
+ *
+ * HC_GADGETHELP - Set this flag to enable Gadget-Help for one or more
+ * windows.
+ }
+
+ HC_GADGETHELP  = 1;
+
+
+{ ======================================================================== }
+{ === Remember =========================================================== }
+{ ======================================================================== }
+{ this structure is used for remembering what memory has been allocated to
+ * date by a given routine, so that a premature abort or systematic exit
+ * can deallocate memory cleanly, easily, and completely
+ }
+
+Type
+
+    pRemember = ^tRemember;
+    tRemember = record
+        NextRemember    : pRemember;
+        RememberSize    : ULONG;
+        Memory          : Pointer;
+    end;
+
+
+{ === Color Spec ====================================================== }
+{ How to tell Intuition about RGB values for a color table entry. }
+
+  pColorSpec = ^tColorSpec;
+  tColorSpec = record
+    ColorIndex  : Integer;     { -1 terminates an array of ColorSpec  }
+    Red         : Word;     { only the _bottom_ 4 bits recognized }
+    Green       : Word;     { only the _bottom_ 4 bits recognized }
+    Blue        : Word;     { only the _bottom_ 4 bits recognized }
+  END;
+
+{ === Easy Requester Specification ======================================= }
+{ see also autodocs for EasyRequest and BuildEasyRequest       }
+{ NOTE: This structure may grow in size in the future          }
+
+   pEasyStruct = ^tEasyStruct;
+   tEasyStruct = record
+    es_StructSize   : ULONG;  { should be sizeof (struct EasyStruct )}
+    es_Flags        : ULONG;  { should be 0 for now                  }
+    es_Title        : STRPTR;   { title of requester window            }
+    es_TextFormat   : STRPTR;   { 'printf' style formatting string     }
+    es_GadgetFormat : STRPTR;   { 'printf' style formatting string   }
+   END;
+
+
+
+{ ======================================================================== }
+{ === Miscellaneous ====================================================== }
+{ ======================================================================== }
+CONST
+{ = MENU STUFF =========================================================== }
+    NOMENU      = $001F;
+    NOITEM      = $003F;
+    NOSUB       = $001F;
+    MENUNULL    = -1;
+
+
+{ = =RJ='s peculiarities ================================================= }
+
+{ these defines are for the COMMSEQ and CHECKIT menu stuff.  If CHECKIT,
+ * I'll use a generic Width (for all resolutions) for the CheckMark.
+ * If COMMSEQ, likewise I'll use this generic stuff
+ }
+
+    CHECKWIDTH          = 19;
+    COMMWIDTH           = 27;
+    LOWCHECKWIDTH       = 13;
+    LOWCOMMWIDTH        = 16;
+
+{ these are the AlertNumber defines.  if you are calling DisplayAlert()
+ * the AlertNumber you supply must have the ALERT_TYPE bits set to one
+ * of these patterns
+ }
+
+    ALERT_TYPE          = $80000000;
+    RECOVERY_ALERT      = $00000000;    { the system can recover from this }
+    DEADEND_ALERT       = $80000000;    { no recovery possible, this is it }
+
+
+{ When you're defining IntuiText for the Positive and Negative Gadgets
+ * created by a call to AutoRequest(), these defines will get you
+ * reasonable-looking text.  The only field without a define is the IText
+ * field; you decide what text goes with the Gadget
+ }
+
+    AUTOFRONTPEN        = 0;
+    AUTOBACKPEN         = 1;
+    AUTODRAWMODE        = JAM2;
+    AUTOLEFTEDGE        = 6;
+    AUTOTOPEDGE         = 3;
+
+{ -
+    AUTOITEXTFONT       = Nil;
+    AUTONEXTTEXT        = Nil;
+- }
+
+
+{ --- RAWMOUSE Codes and Qualifiers (Console OR IDCMP) ------------------- }
+
+
+    SELECTUP            = IECODE_LBUTTON + IECODE_UP_PREFIX;
+    SELECTDOWN          = IECODE_LBUTTON;
+    MENUUP              = IECODE_RBUTTON + IECODE_UP_PREFIX;
+    MENUDOWN            = IECODE_RBUTTON;
+    ALTLEFT             = IEQUALIFIER_LALT;
+    ALTRIGHT            = IEQUALIFIER_RALT;
+    AMIGALEFT           = IEQUALIFIER_LCOMMAND;
+    AMIGARIGHT          = IEQUALIFIER_RCOMMAND;
+    AMIGAKEYS           = AMIGALEFT + AMIGARIGHT;
+
+    CURSORUP            = $4C;
+    CURSORLEFT          = $4F;
+    CURSORRIGHT         = $4E;
+    CURSORDOWN          = $4D;
+    KEYCODE_Q           = $10;
+    KEYCODE_X           = $32;
+    KEYCODE_N           = $36;
+    KEYCODE_M           = $37;
+    KEYCODE_V           = $34;
+    KEYCODE_B           = $35;
+    KEYCODE_LESS        = $38;
+    KEYCODE_GREATER     = $39;
+
+{ these are the display modes for which we have corresponding parameter
+ *  settings in the config arrays
+ }
+CONST
+ DMODECOUNT    =  $0002;  { how many modes there are }
+ HIRESPICK     =  $0000;
+ LOWRESPICK    =  $0001;
+
+ EVENTMAX = 10;             { size of event array }
+
+{ these are the system Gadget defines }
+ RESCOUNT       = 2;
+ HIRESGADGET    = 0;
+ LOWRESGADGET   = 1;
+
+ GADGETCOUNT    = 8;
+ UPFRONTGADGET  = 0;
+ DOWNBACKGADGET = 1;
+ SIZEGADGET     = 2;
+ CLOSEGADGET    = 3;
+ DRAGGADGET     = 4;
+ SUPFRONTGADGET = 5;
+ SDOWNBACKGADGET= 6;
+ SDRAGGADGET    = 7;
+
+
+{ ======================================================================== }
+{ === DrawInfo ========================================================= }
+{ ======================================================================== }
+
+{ This is a packet of information for graphics rendering.  It originates
+ * with a Screen, and is gotten using GetScreenDrawInfo( screen );
+ }
+
+{ If you find dri_Version >= DRI_VERSION, you know this structure
+ * has at least the fields defined in this version of the include file
+ }
+CONST
+ RI_VERSION  =    (1);     { obsolete, will be removed            }
+ DRI_VERSION =    (1);
+
+Type
+
+ pDrawInfo = ^tDrawInfo;
+ tDrawInfo = record
+    dri_Version : Word;    { will be  DRI_VERSION                 }
+    dri_NumPens : Word;    { guaranteed to be >= numDrIPens       }
+    dri_Pens    : Pointer;  { pointer to pen array                 }
+
+    dri_Font    : pTextFont;      { screen default font          }
+    dri_Depth   : Word;            { (initial) depth of screen bitmap     }
+
+    dri_Resolution : record      { from DisplayInfo database for initial display mode }
+                   x : word;
+                   y : word;
+                   end;
+
+    dri_Flags : ULONG;              { defined below                }
+{ New for V39: dri_CheckMark, dri_AmigaKey. }
+    dri_CheckMark : pImage; { ImagePtr }         { pointer to scaled checkmark image
+                                                  * Will be NULL if DRI_VERSION < 2
+                                                  }
+    dri_AmigaKey  : pImage; { ImagePtr }    { pointer to scaled Amiga-key image
+                                             * Will be NULL if DRI_VERSION < 2
+                                             }
+
+    dri_Reserved : Array[0..4] of ULONG;        { avoid recompilation ;^)      }
+ END;
+
+CONST
+ DRIF_NEWLOOK =   $00000001;      { specified SA_Pens, full treatment }
+
+{ rendering pen number indexes into DrawInfo.dri_Pens[]        }
+ DETAILPEN    =    ($0000);       { compatible Intuition rendering pens  }
+ BLOCKPEN     =    ($0001);       { compatible Intuition rendering pens  }
+ TEXTPEN      =    ($0002);       { text on background                   }
+ SHINEPEN     =    ($0003);       { bright edge on 3D objects            }
+ SHADOWPEN    =    ($0004);       { dark edge on 3D objects              }
+ FILLPEN      =    ($0005);       { active-window/selected-gadget fill   }
+ FILLTEXTPEN  =    ($0006);       { text over FILLPEN                    }
+ BACKGROUNDPEN =   ($0007);       { always color 0                       }
+ HIGHLIGHTTEXTPEN = ($0008);       { special color text, on background    }
+{ New for V39, only present if DRI_VERSION >= 2: }
+ BARDETAILPEN   =  ($0009);       { text/detail in screen-bar/menus }
+ BARBLOCKPEN    =  ($000A);       { screen-bar/menus fill }
+ BARTRIMPEN     =  ($000B);       { trim under screen-bar }
+
+ NUMDRIPENS   =    ($0009);
+
+{ New for V39:  It is sometimes useful to specify that a pen value
+ * is to be the complement of color zero to three.  The "magic" numbers
+ * serve that purpose:
+ }
+ PEN_C3        =  $FEFC;          { Complement of color 3 }
+ PEN_C2        =  $FEFD;          { Complement of color 2 }
+ PEN_C1        =  $FEFE;          { Complement of color 1 }
+ PEN_C0        =  $FEFF;          { Complement of color 0 }
+
+{ ======================================================================== }
+{ === Screen ============================================================= }
+{ ======================================================================== }
+
+Type
+
+    pScreen = ^tScreen;
+    tScreen = record
+        NextScreen      : pScreen;      { linked list of screens }
+        FirstWindow     : pWindow;      { linked list Screen's Windows }
+
+        LeftEdge,
+        TopEdge         : Integer;        { parameters of the screen }
+        Width,
+        Height          : Integer;        { parameters of the screen }
+
+        MouseY,
+        MouseX          : Integer;        { position relative to upper-left }
+
+        Flags           : Word;        { see definitions below }
+
+        Title           : STRPTR;       { null-terminated Title text }
+        DefaultTitle    : STRPTR;       { for Windows without ScreenTitle }
+
+    { Bar sizes for this Screen and all Window's in this Screen }
+        BarHeight,
+        BarVBorder,
+        BarHBorder,
+        MenuVBorder,
+        MenuHBorder     : Shortint;
+        WBorTop,
+        WBorLeft,
+        WBorRight,
+        WBorBottom      : Shortint;
+
+        Font            : pTextAttr;  { this screen's default font       }
+
+    { the display data structures for this Screen (note the prefix S)}
+        ViewPort        : tViewPort;     { describing the Screen's display }
+        RastPort        : tRastPort;     { describing Screen rendering      }
+        BitMap          : tBitMap;       { extra copy of RastPort BitMap   }
+        LayerInfo       : tLayer_Info;   { each screen gets a LayerInfo     }
+
+    { You supply a linked-list of Gadgets for your Screen.
+     *  This list DOES NOT include system Gadgets.  You get the standard
+     *  system Screen Gadgets by default
+     }
+
+        FirstGadget     : pGadget;
+
+        DetailPen,
+        BlockPen        : Byte;         { for bar/border/gadget rendering }
+
+    { the following variable(s) are maintained by Intuition to support the
+     * DisplayBeep() color flashing technique
+     }
+        SaveColor0      : Word;
+
+    { This layer is for the Screen and Menu bars }
+        BarLayer        : pLayer;
+
+        ExtData         : Pointer;
+        UserData        : Pointer;
+                        { general-purpose pointer to User data extension }
+    {**** Data below this point are SYSTEM PRIVATE ****}
+
+    end;
+
+Const
+
+{ The screen flags have the suffix "_f" added to avoid conflicts with
+  routine names. }
+
+{ --- FLAGS SET BY INTUITION --------------------------------------------- }
+{ The SCREENTYPE bits are reserved for describing various Screen types
+ * available under Intuition.
+ }
+    SCREENTYPE_f        = $000F;        { all the screens types available       }
+{ --- the definitions for the Screen Type ------------------------------- }
+    WBENCHSCREEN_f      = $0001;        { Ta Da!  The Workbench         }
+    CUSTOMSCREEN_f      = $000F;        { for that special look         }
+
+    SHOWTITLE_f         = $0010;        { this gets set by a call to ShowTitle() }
+
+    BEEPING_f           = $0020;        { set when Screen is beeping            }
+
+    CUSTOMBITMAP_f      = $0040;        { if you are supplying your own BitMap }
+
+    SCREENBEHIND_f      = $0080;        { if you want your screen to open behind
+                                         * already open screens
+                                         }
+    SCREENQUIET_f       = $0100;        { if you do not want Intuition to render
+                                         * into your screen (gadgets, title)     }
+    SCREENHIRES         = $0200;        { do no use lowres gadgets (private)       }
+
+    NS_EXTENDED         = $1000;          { ExtNewScreen.Extension is valid      }
+    { V36 applications can use OpenScreenTagList() instead of NS_EXTENDED  }
+
+{ New for V39: }
+    PENSHARED           = $0400;  { Screen opener set (SA_SharePens,TRUE) }
+
+
+    AUTOSCROLL          = $4000;  { screen is to autoscoll               }
+
+    STDSCREENHEIGHT     = -1;           { supply in NewScreen.Height            }
+    STDSCREENWIDTH      = -1;           { supply in NewScreen.Width             }
+
+
+
+{
+ * Screen attribute tag ID's.  These are used in the ti_Tag field of
+ * TagItem arrays passed to OpenScreenTagList() (or in the
+ * ExtNewScreen.Extension field).
+ }
+
+{ Screen attribute tags.  Please use these versions, not those in
+ * iobsolete.h.
+ }
+CONST
+  SA_Dummy    =    (TAG_USER + 32);
+{
+ * these items specify items equivalent to fields in NewScreen
+ }
+ SA_Left     =    (SA_Dummy + $0001);
+ SA_Top      =    (SA_Dummy + $0002);
+ SA_Width    =    (SA_Dummy + $0003);
+ SA_Height   =    (SA_Dummy + $0004);
+                        { traditional screen positions and dimensions  }
+ SA_Depth    =    (SA_Dummy + $0005);
+                        { screen bitmap depth                          }
+ SA_DetailPen=    (SA_Dummy + $0006);
+                        { serves as default for windows, too           }
+ SA_BlockPen =    (SA_Dummy + $0007);
+ SA_Title    =    (SA_Dummy + $0008);
+                        { default screen title                         }
+ SA_Colors   =    (SA_Dummy + $0009);
+                        { ti_Data is an array of struct ColorSpec,
+                         * terminated by ColorIndex = -1.  Specifies
+                         * initial screen palette colors.
+                         }
+ SA_ErrorCode=    (SA_Dummy + $000A);
+                        { ti_Data points to LONG error code (values below)}
+ SA_Font     =    (SA_Dummy + $000B);
+                        { equiv. to NewScreen.Font                     }
+ SA_SysFont  =    (SA_Dummy + $000C);
+                        { Selects one of the preferences system fonts:
+                         *      0 - old DefaultFont, fixed-width
+                         *      1 - WB Screen preferred font
+                         }
+ SA_Type     =    (SA_Dummy + $000D);
+                        { equiv. to NewScreen.Type                     }
+ SA_BitMap   =    (SA_Dummy + $000E);
+                        { ti_Data is pointer to custom BitMap.  This
+                         * implies type of CUSTOMBITMAP
+                         }
+ SA_PubName  =    (SA_Dummy + $000F);
+                        { presence of this tag means that the screen
+                         * is to be a public screen.  Please specify
+                         * BEFORE the two tags below
+                         }
+ SA_PubSig   =    (SA_Dummy + $0010);
+ SA_PubTask  =    (SA_Dummy + $0011);
+                        { Task ID and signal for being notified that
+                         * the last window has closed on a public screen.
+                         }
+ SA_DisplayID=    (SA_Dummy + $0012);
+                        { ti_Data is new extended display ID from
+                         * <graphics/displayinfo.h>.
+                         }
+ SA_DClip    =    (SA_Dummy + $0013);
+                        { ti_Data points to a rectangle which defines
+                         * screen display clip region
+                         }
+ SA_Overscan =    (SA_Dummy + $0014);
+                        { was S_STDDCLIP.  Set to one of the OSCAN_
+                         * specifiers below to get a system standard
+                         * overscan region for your display clip,
+                         * screen dimensions (unless otherwise specified),
+                         * and automatically centered position (partial
+                         * support only so far).
+                         * If you use this, you shouldn't specify
+                         * SA_DClip.  SA_Overscan is for "standard"
+                         * overscan dimensions, SA_DClip is for
+                         * your custom numeric specifications.
+                         }
+ SA_Obsolete1=    (SA_Dummy + $0015);
+                        { obsolete S_MONITORNAME                       }
+
+{* booleans *}
+ SA_ShowTitle  =  (SA_Dummy + $0016);
+                        { boolean equivalent to flag SHOWTITLE         }
+ SA_Behind     =  (SA_Dummy + $0017);
+                        { boolean equivalent to flag SCREENBEHIND      }
+ SA_Quiet      =  (SA_Dummy + $0018);
+                        { boolean equivalent to flag SCREENQUIET       }
+ SA_AutoScroll =  (SA_Dummy + $0019);
+                        { boolean equivalent to flag AUTOSCROLL        }
+ SA_Pens       =  (SA_Dummy + $001A);
+                        { pointer to ~0 terminated UWORD array, as
+                         * found in struct DrawInfo
+                         }
+ SA_FullPalette=  (SA_Dummy + $001B);
+                        { boolean: initialize color table to entire
+                         *  preferences palette (32 for V36), rather
+                         * than compatible pens 0-3, 17-19, with
+                         * remaining palette as returned by GetColorMap()
+                         }
+
+ SA_ColorMapEntries = (SA_Dummy + $001C);
+                        { New for V39:
+                         * Allows you to override the number of entries
+                         * in the ColorMap for your screen.  Intuition
+                         * normally allocates (1<<depth) or 32, whichever
+                         * is more, but you may require even more if you
+                         * use certain V39 graphics.library features
+                         * (eg. palette-banking).
+                         }
+
+ SA_Parent      = (SA_Dummy + $001D);
+                        { New for V39:
+                         * ti_Data is a pointer to a "parent" screen to
+                         * attach this one to.  Attached screens slide
+                         * and depth-arrange together.
+                         }
+
+ SA_Draggable   = (SA_Dummy + $001E);
+                        { New for V39:
+                         * Boolean tag allowing non-draggable screens.
+                         * Do not use without good reason!
+                         * (Defaults to TRUE).
+                         }
+
+ SA_Exclusive   = (SA_Dummy + $001F);
+                        { New for V39:
+                         * Boolean tag allowing screens that won't share
+                         * the display.  Use sparingly!  Starting with 3.01,
+                         * attached screens may be SA_Exclusive.  Setting
+                         * SA_Exclusive for each screen will produce an
+                         * exclusive family.   (Defaults to FALSE).
+                         }
+
+ SA_SharePens   = (SA_Dummy + $0020);
+                        { New for V39:
+                         * For those pens in the screen's DrawInfo->dri_Pens,
+                         * Intuition obtains them in shared mode (see
+                         * graphics.library/ObtainPen()).  For compatibility,
+                         * Intuition obtains the other pens of a public
+                         * screen as PEN_EXCLUSIVE.  Screens that wish to
+                         * manage the pens themselves should generally set
+                         * this tag to TRUE.  This instructs Intuition to
+                         * leave the other pens unallocated.
+                         }
+
+ SA_BackFill    = (SA_Dummy + $0021);
+                        { New for V39:
+                         * provides a "backfill hook" for your screen's
+                         * Layer_Info.
+                         * See layers.library/InstallLayerInfoHook()
+                         }
+
+ SA_Interleaved = (SA_Dummy + $0022);
+                        { New for V39:
+                         * Boolean tag requesting that the bitmap
+                         * allocated for you be interleaved.
+                         * (Defaults to FALSE).
+                         }
+
+ SA_Colors32    = (SA_Dummy + $0023);
+                        { New for V39:
+                         * Tag to set the screen's initial palette colors
+                         * at 32 bits-per-gun.  ti_Data is a pointer
+                         * to a table to be passed to the
+                         * graphics.library/LoadRGB32() function.
+                         * This format supports both runs of color
+                         * registers and sparse registers.  See the
+                         * autodoc for that function for full details.
+                         * Any color set here has precedence over
+                         * the same register set by SA_Colors.
+                         }
+
+ SA_VideoControl = (SA_Dummy + $0024);
+                        { New for V39:
+                         * ti_Data is a pointer to a taglist that Intuition
+                         * will pass to graphics.library/VideoControl(),
+                         * upon opening the screen.
+                         }
+
+ SA_FrontChild  = (SA_Dummy + $0025);
+                        { New for V39:
+                         * ti_Data is a pointer to an already open screen
+                         * that is to be the child of the screen being
+                         * opened.  The child screen will be moved to the
+                         * front of its family.
+                         }
+
+ SA_BackChild   = (SA_Dummy + $0026);
+                        { New for V39:
+                         * ti_Data is a pointer to an already open screen
+                         * that is to be the child of the screen being
+                         * opened.  The child screen will be moved to the
+                         * back of its family.
+                         }
+
+ SA_LikeWorkbench     =   (SA_Dummy + $0027);
+                        { New for V39:
+                         * Set ti_Data to 1 to request a screen which
+                         * is just like the Workbench.  This gives
+                         * you the same screen mode, depth, size,
+                         * colors, etc., as the Workbench screen.
+                         }
+
+ SA_Reserved          =   (SA_Dummy + $0028);
+                        { Reserved for private Intuition use }
+
+ SA_MinimizeISG       =   (SA_Dummy + $0029);
+                        { New for V40:
+                         * For compatibility, Intuition always ensures
+                         * that the inter-screen gap is at least three
+                         * non-interlaced lines.  If your application
+                         * would look best with the smallest possible
+                         * inter-screen gap, set ti_Data to TRUE.
+                         * If you use the new graphics VideoControl()
+                         * VC_NoColorPaletteLoad tag for your screen's
+                         * ViewPort, you should also set this tag.
+                          }
+
+
+{ this is an obsolete tag included only for compatibility with V35
+ * interim release for the A2024 and Viking monitors
+ }
+ NSTAG_EXT_VPMODE = (TAG_USER + 1);
+
+
+{ OpenScreen error codes, which are returned in the (optional) LONG
+ * pointed to by ti_Data for the SA_ErrorCode tag item
+ }
+ OSERR_NOMONITOR   = (1);     { named monitor spec not available     }
+ OSERR_NOCHIPS     = (2);     { you need newer custom chips          }
+ OSERR_NOMEM       = (3);     { couldn't get normal memory           }
+ OSERR_NOCHIPMEM   = (4);     { couldn't get chipmem                 }
+ OSERR_PUBNOTUNIQUE= (5);     { public screen name already used      }
+ OSERR_UNKNOWNMODE = (6);     { don't recognize mode asked for       }
+
+{ ======================================================================== }
+{ === NewScreen ========================================================== }
+{ ======================================================================== }
+
+Type
+
+    pNewScreen = ^tNewScreen;
+    tNewScreen = record
+        LeftEdge,
+        TopEdge,
+        Width,
+        Height,
+        Depth           : Integer;        { screen dimensions }
+
+        DetailPen,
+        BlockPen        : Byte;         { for bar/border/gadget rendering }
+
+        ViewModes       : Word;        { the Modes for the ViewPort (and View) }
+
+        SType           : Word;        { the Screen type (see defines above) }
+
+        Font            : pTextAttr;  { this Screen's default text attributes }
+
+        DefaultTitle    : STRPTR;       { the default title for this Screen }
+
+        Gadgets         : pGadget;      { your own Gadgets for this Screen }
+
+    { if you are opening a CUSTOMSCREEN and already have a BitMap
+     * that you want used for your Screen, you set the flags CUSTOMBITMAP in
+     * the Type field and you set this variable to point to your BitMap
+     * structure.  The structure will be copied into your Screen structure,
+     * after which you may discard your own BitMap if you want
+     }
+
+        CustomBitMap    : pBitMap;
+    end;
+
+
+type
+
+ pExtNewScreen = ^tExtNewScreen;
+ tExtNewScreen = record
+  LeftEdge, TopEdge, Width, Height, Depth : Integer;
+  DetailPen, BlockPen : Byte;
+  ViewModes : Word;
+  ens_Type : Word;     { Type in C-Includes }
+  Font : pTextAttr;
+  DefaultTitle : STRPTR;
+  Gadgets : pGadget;
+  CustomBitMap : pBitMap;
+  Extension : pTagItem;
+ END;
+
+
+CONST
+{ === Overscan Types ===       }
+ OSCAN_TEXT     = (1);     { entirely visible     }
+ OSCAN_STANDARD = (2);     { just past edges      }
+ OSCAN_MAX      = (3);     { as much as possible  }
+ OSCAN_VIDEO    = (4);     { even more than is possible   }
+
+
+{ === Public Shared Screen Node ===    }
+
+{ This is the representative of a public shared screen.
+ * This is an internal data structure, but some functions may
+ * present a copy of it to the calling application.  In that case,
+ * be aware that the screen pointer of the structure can NOT be
+ * used safely, since there is no guarantee that the referenced
+ * screen will remain open and a valid data structure.
+ *
+ * Never change one of these.
+ }
+
+Type
+   pPubScreenNode = ^tPubScreenNode;
+   tPubScreenNode = record
+    psn_Node    : tNode;       { ln_Name is screen name }
+    psn_Screen  : pScreen;
+    psn_Flags   : Word;      { below                }
+    psn_Size    : Integer;      { includes name buffer }
+    psn_VisitorCount  : Integer; { how many visitor windows }
+    psn_SigTask : pTask;    { who to signal when visitors gone }
+    psn_SigBit  : Byte;     { which signal }
+   END;
+
+CONST
+ PSNF_PRIVATE  =  ($0001);
+
+ MAXPUBSCREENNAME  =      (139);   { names no longer, please      }
+
+{ pub screen modes     }
+ SHANGHAI      =  $0001;  { put workbench windows on pub screen }
+ POPPUBSCREEN  =  $0002;  { pop pub screen to front when visitor opens }
+
+{ New for V39:  Intuition has new screen depth-arrangement and movement
+ * functions called ScreenDepth() and ScreenPosition() respectively.
+ * These functions permit the old behavior of ScreenToFront(),
+ * ScreenToBack(), and MoveScreen().  ScreenDepth() also allows
+ * independent depth control of attached screens.  ScreenPosition()
+ * optionally allows positioning screens even though they were opened
+ * (SA_Draggable,FALSE).
+ }
+
+{ For ScreenDepth(), specify one of SDEPTH_TOFRONT or SDEPTH_TOBACK,
+ * and optionally also SDEPTH_INFAMILY.
+ *
+ * NOTE: ONLY THE OWNER OF THE SCREEN should ever specify
+ * SDEPTH_INFAMILY.  Commodities, "input helper" programs,
+ * or any other program that did not open a screen should never
+ * use that flag.  (Note that this is a style-behavior
+ * requirement;  there is no technical requirement that the
+ * task calling this function need be the task which opened
+ * the screen).
+ }
+
+ SDEPTH_TOFRONT        =  (0);     { Bring screen to front }
+ SDEPTH_TOBACK         =  (1);     { Send screen to back }
+ SDEPTH_INFAMILY       =  (2);     { Move an attached screen with
+                                         * respect to other screens of
+                                         * its family
+                                         }
+
+{ Here's an obsolete name equivalent to SDEPTH_INFAMILY: }
+ SDEPTH_CHILDONLY      =  SDEPTH_INFAMILY;
+
+
+{ For ScreenPosition(), specify one of SPOS_RELATIVE, SPOS_ABSOLUTE,
+ * or SPOS_MAKEVISIBLE to describe the kind of screen positioning you
+ * wish to perform:
+ *
+ * SPOS_RELATIVE: The x1 and y1 parameters to ScreenPosition() describe
+ *      the offset in coordinates you wish to move the screen by.
+ * SPOS_ABSOLUTE: The x1 and y1 parameters to ScreenPosition() describe
+ *      the absolute coordinates you wish to move the screen to.
+ * SPOS_MAKEVISIBLE: (x1,y1)-(x2,y2) describes a rectangle on the
+ *      screen which you would like autoscrolled into view.
+ *
+ * You may additionally set SPOS_FORCEDRAG along with any of the
+ * above.  Set this if you wish to reposition an (SA_Draggable,FALSE)
+ * screen that you opened.
+ *
+ * NOTE: ONLY THE OWNER OF THE SCREEN should ever specify
+ * SPOS_FORCEDRAG.  Commodities, "input helper" programs,
+ * or any other program that did not open a screen should never
+ * use that flag.
+ }
+
+ SPOS_RELATIVE         =  (0);     { Coordinates are relative }
+
+ SPOS_ABSOLUTE         =  (1);     { Coordinates are expressed as
+                                         * absolutes, not relatives.
+                                         }
+
+ SPOS_MAKEVISIBLE      =  (2);     { Coordinates describe a box on
+                                         * the screen you wish to be
+                                         * made visible by autoscrolling
+                                         }
+
+ SPOS_FORCEDRAG        =  (4);     { Move non-draggable screen }
+
+{ New for V39: Intuition supports double-buffering in screens,
+ * with friendly interaction with menus and certain gadgets.
+ * For each buffer, you need to get one of these structures
+ * from the AllocScreenBuffer() call.  Never allocate your
+ * own ScreenBuffer structures!
+ *
+ * The sb_DBufInfo field is for your use.  See the graphics.library
+ * AllocDBufInfo() autodoc for details.
+ }
+Type
+
+ pScreenBuffer = ^tScreenBuffer;
+ tScreenBuffer = record
+    sb_BitMap  : pBitMap;           { BitMap of this buffer }
+    sb_DBufInfo : pDBufInfo;       { DBufInfo for this buffer }
+ end;
+
+const
+{ These are the flags that may be passed to AllocScreenBuffer().
+ }
+ SB_SCREEN_BITMAP      =  1;
+ SB_COPY_BITMAP        =  2;
+
+
+{ ======================================================================== }
+{ === Preferences ======================================================== }
+{ ======================================================================== }
+
+Const
+
+{ these are the definitions for the printer configurations }
+    FILENAME_SIZE       = 30;           { Filename size }
+
+    POINTERSIZE         = (1 + 16 + 1) * 2;     { Size of Pointer data buffer }
+
+{ These defines are for the default font size.   These actually describe the
+ * height of the defaults fonts.  The default font type is the topaz
+ * font, which is a fixed width font that can be used in either
+ * eighty-column or sixty-column mode.  The Preferences structure reflects
+ * which is currently selected by the value found in the variable FontSize,
+ * which may have either of the values defined below.  These values actually
+ * are used to select the height of the default font.  By changing the
+ * height, the resolution of the font changes as well.
+ }
+    TOPAZ_EIGHTY        = 8;
+    TOPAZ_SIXTY         = 9;
+
+Type
+
+    pPreferences = ^tPreferences;
+    tPreferences = record
+    { the default font height }
+        FontHeight      : Shortint;         { height for system default font  }
+
+    { constant describing what's hooked up to the port }
+        PrinterPort     : Byte;         { printer port connection     }
+
+    { the baud rate of the port }
+        BaudRate        : Word;        { baud rate for the serial port   }
+
+    { various timing rates }
+        KeyRptSpeed     : ttimeval;      { repeat speed for keyboard       }
+        KeyRptDelay     : ttimeval;      { Delay before keys repeat             }
+        DoubleClick     : ttimeval;      { Interval allowed between clicks }
+
+    { Intuition Pointer data }
+        PointerMatrix   : Array [0..POINTERSIZE-1] of Word;
+                                        { Definition of pointer sprite     }
+        XOffset         : Shortint;         { X-Offset for active 'bit'       }
+        YOffset         : Shortint;         { Y-Offset for active 'bit'       }
+        color17         : Word;        {*********************************}
+        color18         : Word;        { Colours for sprite pointer      }
+        color19         : Word;        {*********************************}
+        PointerTicks    : Word;        { Sensitivity of the pointer       }
+
+    { Workbench Screen colors }
+        color0          : Word;        {*********************************}
+        color1          : Word;        {   Standard default colours      }
+        color2          : Word;        {   Used in the Workbench         }
+        color3          : Word;        {*********************************}
+
+    { positioning data for the Intuition View }
+        ViewXOffset     : Shortint;         { Offset for top lefthand corner  }
+        ViewYOffset     : Shortint;         { X and Y dimensions           }
+        ViewInitX,
+        ViewInitY       : Integer;        { View initial offset values      }
+
+        EnableCLI       : Boolean;      { CLI availability switch }
+
+    { printer configurations }
+        PrinterType     : Word;        { printer type                     }
+        PrinterFilename : Array [0..FILENAME_SIZE-1] of Char;
+                                        { file for printer         }
+
+    { print format and quality configurations }
+        PrintPitch      : Word;        { print pitch              }
+        PrintQuality    : Word;        { print quality    }
+        PrintSpacing    : Word;        { number of lines per inch    }
+        PrintLeftMargin : Word;        { left margin in characters        }
+        PrintRightMargin : Word;       { right margin in characters       }
+        PrintImage      : Word;        { positive or negative         }
+        PrintAspect     : Word;        { horizontal or vertical      }
+        PrintShade      : Word;        { b&w, half-tone, or color    }
+        PrintThreshold  : Integer;        { darkness ctrl for b/w dumps      }
+
+    { print paper descriptors }
+        PaperSize       : Word;        { paper size               }
+        PaperLength     : Word;        { paper length in number of lines }
+        PaperType       : Word;        { continuous or single sheet       }
+
+    { Serial device settings: These are six nibble-fields in three bytes }
+    { (these look a little strange so the defaults will map out to zero) }
+        SerRWBits       : Byte;
+                             { upper nibble = (8-number of read bits)     }
+                             { lower nibble = (8-number of write bits)    }
+        SerStopBuf      : Byte;
+                             { upper nibble = (number of stop bits - 1)  }
+                             { lower nibble = (table value for BufSize)  }
+        SerParShk       : Byte;
+                             { upper nibble = (value for Parity setting) }
+                             { lower nibble = (value for Handshake mode) }
+        LaceWB          : Byte;         { if workbench is to be interlaced      }
+
+        WorkName        : Array [0..FILENAME_SIZE-1] of Char;
+                                        { temp file for printer         }
+
+        RowSizeChange   : Shortint;
+        ColumnSizeChange : Shortint;
+
+        PrintFlags      : Word;        { user preference flags }
+        PrintMaxWidth   : Word;        { max width of printed picture in 10ths/inch }
+        PrintMaxHeight  : Word;        { max height of printed picture in 10ths/inch }
+        PrintDensity    : Byte;         { print density }
+        PrintXOffset    : Byte;         { offset of printed picture in 10ths/inch }
+
+        wb_Width        : Word;        { override default workbench width       }
+        wb_Height       : Word;        { override default workbench height }
+        wb_Depth        : Byte;         { override default workbench depth       }
+
+        ext_size        : Byte;         { extension information -- do not touch! }
+                            { extension size in blocks of 64 bytes }
+    end;
+
+Const
+
+{ Workbench Interlace (use one bit) }
+    LACEWB              = $01;
+    LW_RESERVED         = 1;     { internal use only }
+
+{ PrinterPort }
+    PARALLEL_PRINTER    = $00;
+    SERIAL_PRINTER      = $01;
+
+{ BaudRate }
+    BAUD_110            = $00;
+    BAUD_300            = $01;
+    BAUD_1200           = $02;
+    BAUD_2400           = $03;
+    BAUD_4800           = $04;
+    BAUD_9600           = $05;
+    BAUD_19200          = $06;
+    BAUD_MIDI           = $07;
+
+{ PaperType }
+    FANFOLD             = $00;
+    SINGLE              = $80;
+
+{ PrintPitch }
+    PICA                = $000;
+    ELITE               = $400;
+    FINE                = $800;
+
+{ PrintQuality }
+    DRAFT               = $000;
+    LETTER              = $100;
+
+{ PrintSpacing }
+    SIX_LPI             = $000;
+    EIGHT_LPI           = $200;
+
+{ Print Image }
+    IMAGE_POSITIVE      = $00;
+    IMAGE_NEGATIVE      = $01;
+
+{ PrintAspect }
+    ASPECT_HORIZ        = $00;
+    ASPECT_VERT         = $01;
+
+{ PrintShade }
+    SHADE_BW            = $00;
+    SHADE_GREYSCALE     = $01;
+    SHADE_COLOR         = $02;
+
+{ PaperSize }
+    US_LETTER           = $00;
+    US_LEGAL            = $10;
+    N_TRACTOR           = $20;
+    W_TRACTOR           = $30;
+    CUSTOM_PAPER        = $40;
+
+{ New PaperSizes for V36: }
+ EURO_A0 = $50;            { European size A0: 841 x 1189 }
+ EURO_A1 = $60;            { European size A1: 594 x 841 }
+ EURO_A2 = $70;            { European size A2: 420 x 594 }
+ EURO_A3 = $80;            { European size A3: 297 x 420 }
+ EURO_A4 = $90;            { European size A4: 210 x 297 }
+ EURO_A5 = $A0;            { European size A5: 148 x 210 }
+ EURO_A6 = $B0;            { European size A6: 105 x 148 }
+ EURO_A7 = $C0;            { European size A7: 74 x 105 }
+ EURO_A8 = $D0;            { European size A8: 52 x 74 }
+
+{ PrinterType }
+    CUSTOM_NAME         = $00;
+    ALPHA_P_101         = $01;
+    BROTHER_15XL        = $02;
+    CBM_MPS1000         = $03;
+    DIAB_630            = $04;
+    DIAB_ADV_D25        = $05;
+    DIAB_C_150          = $06;
+    EPSON               = $07;
+    EPSON_JX_80         = $08;
+    OKIMATE_20          = $09;
+    QUME_LP_20          = $0A;
+{ new printer entries, 3 October 1985 }
+    HP_LASERJET         = $0B;
+    HP_LASERJET_PLUS    = $0C;
+
+{ Serial Input Buffer Sizes }
+    SBUF_512            = $00;
+    SBUF_1024           = $01;
+    SBUF_2048           = $02;
+    SBUF_4096           = $03;
+    SBUF_8000           = $04;
+    SBUF_16000          = $05;
+
+{ Serial Bit Masks }
+    SREAD_BITS          = $F0;          { for SerRWBits   }
+    SWRITE_BITS         = $0F;
+
+    SSTOP_BITS          = $F0;          { for SerStopBuf  }
+    SBUFSIZE_BITS       = $0F;
+
+    SPARITY_BITS        = $F0;          { for SerParShk }
+    SHSHAKE_BITS        = $0F;
+
+{ Serial Parity (upper nibble, after being shifted by
+ * macro SPARNUM() )
+ }
+    SPARITY_NONE        = 0;
+    SPARITY_EVEN        = 1;
+    SPARITY_ODD         = 2;
+
+{ Serial Handshake Mode (lower nibble, after masking using
+ * macro SHANKNUM() )
+ }
+    SHSHAKE_XON         = 0;
+    SHSHAKE_RTS         = 1;
+    SHSHAKE_NONE        = 2;
+
+{ new defines for PrintFlags }
+
+    CORRECT_RED         = $0001;        { color correct red shades }
+    CORRECT_GREEN       = $0002;        { color correct green shades }
+    CORRECT_BLUE        = $0004;        { color correct blue shades }
+
+    CENTER_IMAGE        = $0008;        { center image on paper }
+
+    IGNORE_DIMENSIONS   = $0000;        { ignore max width/height settings }
+    BOUNDED_DIMENSIONS  = $0010;        { use max width/height as boundaries }
+    ABSOLUTE_DIMENSIONS = $0020;        { use max width/height as absolutes }
+    PIXEL_DIMENSIONS    = $0040;        { use max width/height as prt pixels }
+    MULTIPLY_DIMENSIONS = $0080;        { use max width/height as multipliers }
+
+    INTEGER_SCALING     = $0100;        { force integer scaling }
+
+    ORDERED_DITHERING   = $0000;        { ordered dithering }
+    HALFTONE_DITHERING  = $0200;        { halftone dithering }
+    FLOYD_DITHERING     = $0400;        { Floyd-Steinberg dithering }
+
+    ANTI_ALIAS          = $0800;        { anti-alias image }
+    GREY_SCALE2         = $1000;        { for use with hi-res monitor }
+
+{ masks used for checking bits }
+
+    CORRECT_RGB_MASK    = CORRECT_RED + CORRECT_GREEN + CORRECT_BLUE;
+    DIMENSIONS_MASK     = BOUNDED_DIMENSIONS + ABSOLUTE_DIMENSIONS +
+                                PIXEL_DIMENSIONS + MULTIPLY_DIMENSIONS;
+    DITHERING_MASK      = HALFTONE_DITHERING + FLOYD_DITHERING;
+
+
+
+
+
+
+{ ======================================================================== }
+{ === IntuitionBase ====================================================== }
+{ ======================================================================== }
+{
+ * Be sure to protect yourself against someone modifying these data as
+ * you look at them.  This is done by calling:
+ *
+ * lock = LockIBase(0), which returns an Integer.  When done call
+ * UnlockIBase(lock) where lock is what LockIBase() returned.
+ }
+
+Type
+
+    pIntuitionBase = ^tIntuitionBase;
+    tIntuitionBase = record
+{ IntuitionBase should never be directly modified by programs   }
+{ even a little bit, guys/gals; do you hear me? }
+
+        LibNode         : tLibrary;
+
+        ViewLord        : tView;
+
+        ActiveWindow    : pWindow;
+        ActiveScreen    : pScreen;
+
+    { the FirstScreen variable points to the frontmost Screen.   Screens are
+     * then maintained in a front to back order using Screen.NextScreen
+     }
+
+        FirstScreen     : pScreen;    { for linked list of all screens }
+
+        Flags           : ULONG;      { see definitions below }
+        MouseY,
+        MouseX          : Integer;        { mouse position relative to View }
+
+        Seconds         : ULONG;      { timestamp of most current input event }
+        Micros          : ULONG;      { timestamp of most current input event }
+
+    { I told you this was private.
+     * The data beyond this point has changed, is changing, and
+     * will continue to change.
+     }
+
+    end;
+
+
+{
+ * Package of information passed to custom and 'boopsi'
+ * gadget 'hook' functions.  This structure is READ ONLY.
+ }
+Type
+
+   pGadgetInfo = ^tGadgetInfo;
+   tGadgetInfo = record
+    gi_Screen                   : pScreen;       { ScreenPtr }
+    gi_Window                   : pWindow;       { null for screen gadgets }    { WindowPtr }
+    gi_Requester                : pRequester;    { null IF not GTYP_REQGADGET } { RequesterPtr }
+
+    { rendering information:
+     * don't use these without cloning/locking.
+     * Official way is to call ObtainRPort()
+     }
+    gi_RastPort                 : pRastPort;     { RastPortPtr }
+    gi_Layer                    : pLayer;        { LayerPtr }
+
+    { copy of dimensions of screen/window/g00/req(/group)
+     * that gadget resides in.  Left/Top of this box is
+     * offset from window mouse coordinates to gadget coordinates
+     *          screen gadgets:                 0,0 (from screen coords)
+     *  window gadgets (no g00):        0,0
+     *  GTYP_GZZGADGETs (borderlayer):          0,0
+     *  GZZ innerlayer gadget:          borderleft, bordertop
+     *  Requester gadgets:              reqleft, reqtop
+     }
+    gi_Domain                   : tIBox;
+
+    gi_Pens                     : record
+                      DetailPen : Byte;
+                      BlockPen  : Byte;
+                                  end;
+
+    { the Detail and Block pens in gi_DrInfo->dri_Pens[] are
+     * for the screen.  Use the above for window-sensitive
+     * colors.
+     }
+    gi_DrInfo                   : pDrawInfo;  { DrawInfoPtr }
+
+    { reserved space: this structure is extensible
+     * anyway, but using these saves some recompilation
+     }
+    gi_Reserved                 : Array[0..5] of ULONG;
+   END;
+
+{** system private data structure for now **}
+{ prop gadget extra info       }
+
+   pPGX = ^tPGX;
+   tPGX = record
+    pgx_Container : tIBox;
+    pgx_NewKnob   : tIBox;
+   END;
+
+{ this casts MutualExclude for easy assignment of a hook
+ * pointer to the unused MutualExclude field of a custom gadget
+ }
+
+{** User visible handles on objects, classes, messages **}
+Type
+ Object_ = ULONG;
+ pObject_ = ^Object_;
+ ClassID = ^Byte;
+
+{
+ you can use this type to point to a 'generic' message,
+ * in the object-oriented programming parlance.  Based on
+ * the value of 'MethodID', you dispatch to processing
+ * for the various message types.  The meaningful parameter
+ * packet structure definitions are defined below.
+
+typedef struct
+    ULONG MethodID;
+     method-specific data follows, some examples below
+               *Msg; }
+
+  pMsg = ^tMsg;
+  tMsg = record
+     MethodID : ULONG;
+  end;
+
+{
+ * Class id strings for Intuition classes.
+ * There's no real reason to use the uppercase constants
+ * over the lowercase strings, but this makes a good place
+ * to list the names of the built-in classes.
+ }
+CONST
+ ROOTCLASS      : PChar = 'rootclass'    ;         { classusr.h   }
+ IMAGECLASS     : PChar = 'imageclass'   ;         { imageclass.h }
+ FRAMEICLASS    : PChar = 'frameiclass'  ;
+ SYSICLASS      : PChar = 'sysiclass'    ;
+ FILLRECTCLASS  : PChar = 'fillrectclass';
+ GADGETCLASS    : PChar = 'gadgetclass'  ;         { gadgetclass.h }
+ PROPGCLASS     : PChar = 'propgclass'   ;
+ STRGCLASS      : PChar = 'strgclass'    ;
+ BUTTONGCLASS   : PChar = 'buttongclass' ;
+ FRBUTTONCLASS  : PChar = 'frbuttonclass';
+ GROUPGCLASS    : PChar = 'groupgclass'  ;
+ ICCLASS        : PChar = 'icclass'      ;         { icclass.h    }
+ MODELCLASS     : PChar = 'modelclass'   ;
+ ITEXTICLASS    : PChar = 'itexticlass'  ;
+ POINTERCLASS   : PChar = 'pointerclass' ;         { pointerclass.h }
+
+
+{ Dispatched method ID's
+ * NOTE: Applications should use Intuition entry points, not direct
+ * DoMethod() calls, for NewObject, DisposeObject, SetAttrs,
+ * SetGadgetAttrs, and GetAttr.
+ }
+
+ OM_Dummy       = ($100);
+ OM_NEW         = ($101); { 'object' parameter is 'true class'   }
+ OM_DISPOSE     = ($102); { delete self (no parameters)          }
+ OM_SET         = ($103); { set attributes (in tag list)         }
+ OM_GET         = ($104); { return single attribute value        }
+ OM_ADDTAIL     = ($105); { add self to a List (let root do it)  }
+ OM_REMOVE      = ($106); { remove self from list                }
+ OM_NOTIFY      = ($107); { send to self: notify dependents      }
+ OM_UPDATE      = ($108); { notification message from somebody   }
+ OM_ADDMEMBER   = ($109); { used by various classes with lists   }
+ OM_REMMEMBER   = ($10A); { used by various classes with lists   }
+
+{ Parameter 'Messages' passed to methods       }
+
+{ OM_NEW and OM_SET    }
+Type
+   popSet = ^topSet;
+   topSet = record
+    MethodID            : ULONG;
+    ops_AttrList        : pTagItem;    { new attributes       }
+    ops_GInfo           : pGadgetInfo; { always there for gadgets,
+                                         * when SetGadgetAttrs() is used,
+                                         * but will be NULL for OM_NEW
+                                         }
+   END;
+
+{ OM_NOTIFY, and OM_UPDATE     }
+
+  popUpdate = ^topUpdate;
+  topUpdate = record
+    MethodID            : ULONG;
+    opu_AttrList        : pTagItem;     { new attributes       }
+    opu_GInfo           : pGadgetInfo;  { non-NULL when SetGadgetAttrs OR
+                                         * notification resulting from gadget
+                                         * input occurs.
+                                         }
+    opu_Flags           : ULONG;        { defined below        }
+  END;
+
+{ this flag means that the update message is being issued from
+ * something like an active gadget, a la GACT_FOLLOWMOUSE.  When
+ * the gadget goes inactive, it will issue a final update
+ * message with this bit cleared.  Examples of use are for
+ * GACT_FOLLOWMOUSE equivalents for propgadclass, and repeat strobes
+ * for buttons.
+ }
+CONST
+ OPUF_INTERIM   = 1;
+
+{ OM_GET       }
+Type
+
+  popGet = ^topGet;
+  topGet = record
+    MethodID,
+    opg_AttrID          : ULONG;
+    opg_Storage         : Pointer;   { may be other types, but 'int'
+                                         * types are all ULONG
+                                         }
+  END;
+
+{ OM_ADDTAIL   }
+
+  popAddTail = ^topAddTail;
+  topAddTail = record
+    MethodID  : ULONG;
+    opat_List : pList;
+  END;
+
+{ OM_ADDMEMBER, OM_REMMEMBER   }
+Type
+
+   popMember = ^topMember;
+   topMember = record
+    MethodID   : ULONG;
+    opam_Object : pObject_;
+   END;
+
+
+
+{*****************************************}
+{** 'White box' access to struct IClass **}
+{*****************************************}
+
+{ This structure is READ-ONLY, and allocated only by Intuition }
+TYPE
+
+   pIClass = ^tIClass;
+   tIClass = record
+    cl_Dispatcher       : tHook;
+    cl_Reserved         : ULONG;    { must be 0  }
+    cl_Super            : pIClass;
+    cl_ID               : ClassID;
+
+    { where within an object is the instance data for this class? }
+    cl_InstOffset       : Word;
+    cl_InstSize         : Word;
+
+    cl_UserData         : ULONG;    { per-class data of your choice }
+    cl_SubclassCount    : ULONG;
+                                        { how many direct subclasses?  }
+    cl_ObjectCount      : ULONG;
+                                { how many objects created of this class? }
+    cl_Flags            : ULONG;
+   END;
+
+CONST
+ CLF_INLIST    =  $00000001;      { class is in public class list }
+
+
+
+{************************************************}
+{** 'White box' access to struct _Object       **}
+{************************************************}
+
+{
+ * We have this, the instance data of the root class, PRECEDING
+ * the 'object'.  This is so that Gadget objects are Gadget pointers,
+ * and so on.  If this structure grows, it will always have o_Class
+ * at the end, so the macro OCLASS(o) will always have the same
+ * offset back from the pointer returned from NewObject().
+ *
+ * This data structure is subject to change.  Do not use the o_Node
+ * embedded structure.
+ }
+Type
+  p_Object = ^t_Object;
+  t_Object = record
+    o_Node    : tMinNode;
+    o_Class   : pIClass;
+  END;
+
+
+{
+ * NOTE:  <intuition/iobsolete.h> is included at the END of this file!
+ }
+
+{ Gadget Class attributes      }
+CONST
+    GA_Dummy           =  (TAG_USER +$30000);
+    GA_Left            =  (GA_Dummy + $0001);
+    GA_RelRight        =  (GA_Dummy + $0002);
+    GA_Top             =  (GA_Dummy + $0003);
+    GA_RelBottom       =  (GA_Dummy + $0004);
+    GA_Width           =  (GA_Dummy + $0005);
+    GA_RelWidth        =  (GA_Dummy + $0006);
+    GA_Height          =  (GA_Dummy + $0007);
+    GA_RelHeight       =  (GA_Dummy + $0008);
+    GA_Text            =  (GA_Dummy + $0009); { ti_Data is (UBYTE *) }
+    GA_Image           =  (GA_Dummy + $000A);
+    GA_Border          =  (GA_Dummy + $000B);
+    GA_SelectRender    =  (GA_Dummy + $000C);
+    GA_Highlight       =  (GA_Dummy + $000D);
+    GA_Disabled        =  (GA_Dummy + $000E);
+    GA_GZZGadget       =  (GA_Dummy + $000F);
+    GA_ID              =  (GA_Dummy + $0010);
+    GA_UserData        =  (GA_Dummy + $0011);
+    GA_SpecialInfo     =  (GA_Dummy + $0012);
+    GA_Selected        =  (GA_Dummy + $0013);
+    GA_EndGadget       =  (GA_Dummy + $0014);
+    GA_Immediate       =  (GA_Dummy + $0015);
+    GA_RelVerify       =  (GA_Dummy + $0016);
+    GA_FollowMouse     =  (GA_Dummy + $0017);
+    GA_RightBorder     =  (GA_Dummy + $0018);
+    GA_LeftBorder      =  (GA_Dummy + $0019);
+    GA_TopBorder       =  (GA_Dummy + $001A);
+    GA_BottomBorder    =  (GA_Dummy + $001B);
+    GA_ToggleSelect    =  (GA_Dummy + $001C);
+
+    { internal use only, until further notice, please }
+    GA_SysGadget       =  (GA_Dummy + $001D);
+        { bool, sets GTYP_SYSGADGET field in type      }
+    GA_SysGType        =  (GA_Dummy + $001E);
+        { e.g., GTYP_WUPFRONT, ...     }
+
+    GA_Previous        =  (GA_Dummy + $001F);
+        { previous gadget (or (struct Gadget **)) in linked list
+         * NOTE: This attribute CANNOT be used to link new gadgets
+         * into the gadget list of an open window or requester.
+         * You must use AddGList().
+         }
+
+    GA_Next            =  (GA_Dummy + $0020);
+         { not implemented }
+
+    GA_DrawInfo        =  (GA_Dummy + $0021);
+        { some fancy gadgets need to see a DrawInfo
+         * when created or for layout
+         }
+
+{ You should use at most ONE of GA_Text, GA_IntuiText, and GA_LabelImage }
+ GA_IntuiText          =  (GA_Dummy + $0022);
+        { ti_Data is (struct IntuiText *) }
+
+ GA_LabelImage         =  (GA_Dummy + $0023);
+        { ti_Data is an image (object), used in place of
+         * GadgetText
+         }
+
+ GA_TabCycle           =  (GA_Dummy + $0024);
+        { New for V37:
+         * Boolean indicates that this gadget is to participate in
+         * cycling activation with Tab or Shift-Tab.
+         }
+
+ GA_GadgetHelp         =  (GA_Dummy + $0025);
+        { New for V39:
+         * Boolean indicates that this gadget sends gadget-help
+         }
+
+ GA_Bounds             =  (GA_Dummy + $0026);
+        { New for V39:
+         * ti_Data is a pointer to an IBox structure which is
+         * to be copied into the extended gadget's bounds.
+         }
+
+ GA_RelSpecial         =  (GA_Dummy + $0027);
+        { New for V39:
+         * Boolean indicates that this gadget has the "special relativity"
+         * property, which is useful for certain fancy relativity
+         * operations through the GM_LAYOUT method.
+         }
+
+{ PROPGCLASS attributes }
+
+ PGA_Dummy      = (TAG_USER + $31000);
+ PGA_Freedom    = (PGA_Dummy + $0001);
+        { only one of FREEVERT or FREEHORIZ }
+ PGA_Borderless = (PGA_Dummy + $0002);
+ PGA_HorizPot   = (PGA_Dummy + $0003);
+ PGA_HorizBody  = (PGA_Dummy + $0004);
+ PGA_VertPot    = (PGA_Dummy + $0005);
+ PGA_VertBody   = (PGA_Dummy + $0006);
+ PGA_Total      = (PGA_Dummy + $0007);
+ PGA_Visible    = (PGA_Dummy + $0008);
+ PGA_Top        = (PGA_Dummy + $0009);
+{ New for V37: }
+ PGA_NewLook    = (PGA_Dummy + $000A);
+
+{ STRGCLASS attributes }
+
+ STRINGA_Dummy         =  (TAG_USER      +$32000);
+ STRINGA_MaxChars      =  (STRINGA_Dummy + $0001);
+ STRINGA_Buffer        =  (STRINGA_Dummy + $0002);
+ STRINGA_UndoBuffer    =  (STRINGA_Dummy + $0003);
+ STRINGA_WorkBuffer    =  (STRINGA_Dummy + $0004);
+ STRINGA_BufferPos     =  (STRINGA_Dummy + $0005);
+ STRINGA_DispPos       =  (STRINGA_Dummy + $0006);
+ STRINGA_AltKeyMap     =  (STRINGA_Dummy + $0007);
+ STRINGA_Font          =  (STRINGA_Dummy + $0008);
+ STRINGA_Pens          =  (STRINGA_Dummy + $0009);
+ STRINGA_ActivePens    =  (STRINGA_Dummy + $000A);
+ STRINGA_EditHook      =  (STRINGA_Dummy + $000B);
+ STRINGA_EditModes     =  (STRINGA_Dummy + $000C);
+
+{ booleans }
+ STRINGA_ReplaceMode    = (STRINGA_Dummy + $000D);
+ STRINGA_FixedFieldMode = (STRINGA_Dummy + $000E);
+ STRINGA_NoFilterMode   = (STRINGA_Dummy + $000F);
+
+ STRINGA_Justification  = (STRINGA_Dummy + $0010);
+        { GACT_STRINGCENTER, GACT_STRINGLEFT, GACT_STRINGRIGHT }
+ STRINGA_LongVal        = (STRINGA_Dummy + $0011);
+ STRINGA_TextVal        = (STRINGA_Dummy + $0012);
+
+ STRINGA_ExitHelp       = (STRINGA_Dummy + $0013);
+        { STRINGA_ExitHelp is new for V37, and ignored by V36.
+         * Set this if you want the gadget to exit when Help is
+         * pressed.  Look for a code of $5F, the rawkey code for Help
+         }
+
+ SG_DEFAULTMAXCHARS     = (128);
+
+{ Gadget Layout related attributes     }
+
+ LAYOUTA_Dummy          = (TAG_USER  + $38000);
+ LAYOUTA_LayoutObj      = (LAYOUTA_Dummy + $0001);
+ LAYOUTA_Spacing        = (LAYOUTA_Dummy + $0002);
+ LAYOUTA_Orientation    = (LAYOUTA_Dummy + $0003);
+
+{ orientation values   }
+ LORIENT_NONE   = 0;
+ LORIENT_HORIZ  = 1;
+ LORIENT_VERT   = 2;
+
+
+{ Gadget Method ID's   }
+
+ GM_Dummy      =  (-1);    { not used for anything                }
+ GM_HITTEST    =  (0);     { return GMR_GADGETHIT IF you are clicked on
+                                 * (whether or not you are disabled).
+                                 }
+ GM_RENDER      = (1);     { draw yourself, in the appropriate state }
+ GM_GOACTIVE    = (2);     { you are now going to be fed input    }
+ GM_HANDLEINPUT = (3);     { handle that input                    }
+ GM_GOINACTIVE  = (4);     { whether or not by choice, you are done  }
+ GM_HELPTEST    = (5);     { Will you send gadget help if the mouse is
+                                 * at the specified coordinates?  See below
+                                 * for possible GMR_ values.
+                                 }
+ GM_LAYOUT      = (6);     { re-evaluate your size based on the GadgetInfo
+                                 * Domain.  Do NOT re-render yourself yet, you
+                                 * will be called when it is time...
+                                 }
+
+{ Parameter "Messages" passed to gadget class methods  }
+
+{ GM_HITTEST   }
+type
+
+  pgpHitTest = ^tgpHitTest;
+  tgpHitTest = record
+    MethodID  : ULONG;
+    gpht_GInfo : pGadgetInfo;
+    gpht_Mouse : record
+             x : Integer;
+             y : Integer;
+                 end;
+  END;
+
+const
+{ For GM_HITTEST, return GMR_GADGETHIT if you were indeed hit,
+ * otherwise return zero.
+ *
+ * For GM_HELPTEST, return GMR_NOHELPHIT (zero) if you were not hit.
+ * Typically, return GMR_HELPHIT if you were hit.
+ * It is possible to pass a UWORD to the application via the Code field
+ * of the IDCMP_GADGETHELP message.  Return GMR_HELPCODE or'd with
+ * the UWORD-sized result you wish to return.
+ *
+ * GMR_HELPHIT yields a Code value of ((UWORD) ~0), which should
+ * mean "nothing particular" to the application.
+ }
+
+ GMR_GADGETHIT  = ($00000004);    { GM_HITTEST hit }
+
+ GMR_NOHELPHIT  = ($00000000);    { GM_HELPTEST didn't hit }
+ GMR_HELPHIT    = ($FFFFFFFF);    { GM_HELPTEST hit, return code = ~0 }
+ GMR_HELPCODE   = ($00010000);    { GM_HELPTEST hit, return low word as code }
+
+
+{ GM_RENDER    }
+Type
+   pgpRender = ^tgpRender;
+   tgpRender = record
+    MethodID  : ULONG;
+    gpr_GInfo : pGadgetInfo;      { gadget context               }
+    gpr_RPort : pRastPort;        { all ready for use            }
+    gpr_Redraw : Longint;           { might be a "highlight pass"  }
+   END;
+
+{ values of gpr_Redraw }
+CONST
+ GREDRAW_UPDATE = (2);     { incremental update, e.g. prop slider }
+ GREDRAW_REDRAW = (1);     { redraw gadget        }
+ GREDRAW_TOGGLE = (0);     { toggle highlight, IF applicable      }
+
+{ GM_GOACTIVE, GM_HANDLEINPUT  }
+Type
+
+  pgpInput = ^tgpInput;
+  tgpInput = record
+    MethodID : ULONG;
+    gpi_GInfo : pGadgetInfo;
+    gpi_IEvent : pInputEvent;
+    gpi_Termination : Pointer;
+    gpi_Mouse : record
+            x : Integer;
+            y : Integer;
+                end;
+    {* (V39) Pointer to TabletData structure, if this event originated
+     * from a tablet which sends IESUBCLASS_NEWTABLET events, or NULL if
+     * not.
+     *
+     * DO NOT ATTEMPT TO READ THIS FIELD UNDER INTUITION PRIOR TO V39!
+     * IT WILL BE INVALID!
+     *}
+   gpi_TabletData  : pTabletData;
+  END;
+
+{ GM_HANDLEINPUT and GM_GOACTIVE  return code flags    }
+{ return GMR_MEACTIVE (0) alone if you want more input.
+ * Otherwise, return ONE of GMR_NOREUSE and GMR_REUSE, and optionally
+ * GMR_VERIFY.
+ }
+CONST
+ GMR_MEACTIVE  =  (0);
+ GMR_NOREUSE   =  (2);
+ GMR_REUSE     =  (4);
+ GMR_VERIFY    =  (8);        { you MUST set cgp_Termination }
+
+{ New for V37:
+ * You can end activation with one of GMR_NEXTACTIVE and GMR_PREVACTIVE,
+ * which instructs Intuition to activate the next or previous gadget
+ * that has GFLG_TABCYCLE set.
+ }
+ GMR_NEXTACTIVE = (16);
+ GMR_PREVACTIVE = (32);
+
+{ GM_GOINACTIVE }
+Type
+
+   pgpGoInactive = ^tgpGoInactive;
+   tgpGoInactive = record
+    MethodID    : ULONG;
+    gpgi_GInfo  : pGadgetInfo;
+
+    { V37 field only!  DO NOT attempt to read under V36! }
+    gpgi_Abort  : ULONG;               { gpgi_Abort=1 IF gadget was aborted
+                                         * by Intuition and 0 if gadget went
+                                         * inactive at its own request
+                                         }
+   END;
+
+{* New for V39: Intuition sends GM_LAYOUT to any GREL_ gadget when
+ * the gadget is added to the window (or when the window opens, if
+ * the gadget was part of the NewWindow.FirstGadget or the WA_Gadgets
+ * list), or when the window is resized.  Your gadget can set the
+ * GA_RelSpecial property to get GM_LAYOUT events without Intuition
+ * changing the interpretation of your gadget select box.  This
+ * allows for completely arbitrary resizing/repositioning based on
+ * window size.
+ *}
+{* GM_LAYOUT *}
+Type
+
+ pgpLayout = ^tgpLayout;
+ tgpLayout = record
+    MethodID            : ULONG;
+    gpl_GInfo           : pGadgetInfo;
+    gpl_Initial         : ULONG;      {* non-zero if this method was invoked
+                                         * during AddGList() or OpenWindow()
+                                         * time.  zero if this method was invoked
+                                         * during window resizing.
+                                         *}
+ end;
+
+
+CONST
+ ICM_Dummy      = ($0401);       { used for nothing             }
+ ICM_SETLOOP    = ($0402);       { set/increment loop counter   }
+ ICM_CLEARLOOP  = ($0403);       { clear/decrement loop counter }
+ ICM_CHECKLOOP  = ($0404);       { set/increment loop           }
+
+{ no parameters for ICM_SETLOOP, ICM_CLEARLOOP, ICM_CHECKLOOP  }
+
+{ interconnection attributes used by icclass, modelclass, and gadgetclass }
+ ICA_Dummy      = (TAG_USER+$40000);
+ ICA_TARGET     = (ICA_Dummy + 1);
+        { interconnection target               }
+ ICA_MAP        = (ICA_Dummy + 2);
+        { interconnection map tagitem list     }
+ ICSPECIAL_CODE = (ICA_Dummy + 3);
+        { a "pseudo-attribute", see below.     }
+
+{ Normally, the value for ICA_TARGET is some object pointer,
+ * but if you specify the special value ICTARGET_IDCMP, notification
+ * will be send as an IDCMP_IDCMPUPDATE message to the appropriate window's
+ * IDCMP port.  See the definition of IDCMP_IDCMPUPDATE.
+ *
+ * When you specify ICTARGET_IDCMP for ICA_TARGET, the map you
+ * specify will be applied to derive the attribute list that is
+ * sent with the IDCMP_IDCMPUPDATE message.  If you specify a map list
+ * which results in the attribute tag id ICSPECIAL_CODE, the
+ * lower sixteen bits of the corresponding ti_Data value will
+ * be copied into the Code field of the IDCMP_IDCMPUPDATE IntuiMessage.
+ }
+ ICTARGET_IDCMP = (NOT 0);
+
+
+CONST
+ CUSTOMIMAGEDEPTH     =   (-1);
+{ if image.Depth is this, it's a new Image class object }
+
+
+{****************************************************}
+CONST
+ IA_Dummy             =   (TAG_USER + $20000);
+ IA_Left              =   (IA_Dummy + $01);
+ IA_Top               =   (IA_Dummy + $02);
+ IA_Width             =   (IA_Dummy + $03);
+ IA_Height            =   (IA_Dummy + $04);
+ IA_FGPen             =   (IA_Dummy + $05);
+                    { IA_FGPen also means "PlanePick"  }
+ IA_BGPen             =   (IA_Dummy + $06);
+                    { IA_BGPen also means "PlaneOnOff" }
+ IA_Data              =   (IA_Dummy + $07);
+                    { bitplanes, for classic image,
+                     * other image classes may use it for other things
+                     }
+ IA_LineWidth         =   (IA_Dummy + $08);
+ IA_Pens              =   (IA_Dummy + $0E);
+                    { pointer to UWORD pens[],
+                     * ala DrawInfo.Pens, MUST be
+                     * terminated by ~0.  Some classes can
+                     * choose to have this, or SYSIA_DrawInfo,
+                     * or both.
+                     }
+ IA_Resolution        =   (IA_Dummy + $0F);
+                    { packed uwords for x/y resolution into a longword
+                     * ala DrawInfo.Resolution
+                     }
+
+{*** see class documentation to learn which    ****}
+{*** classes recognize these                   ****}
+ IA_APattern           =  (IA_Dummy + $10);
+ IA_APatSize           =  (IA_Dummy + $11);
+ IA_Mode               =  (IA_Dummy + $12);
+ IA_Font               =  (IA_Dummy + $13);
+ IA_Outline            =  (IA_Dummy + $14);
+ IA_Recessed           =  (IA_Dummy + $15);
+ IA_DoubleEmboss       =  (IA_Dummy + $16);
+ IA_EdgesOnly          =  (IA_Dummy + $17);
+
+{*** "sysiclass" attributes                    ****}
+ SYSIA_Size            =  (IA_Dummy + $0B);
+                    { 's below          }
+ SYSIA_Depth           =  (IA_Dummy + $0C);
+                    { this is unused by Intuition.  SYSIA_DrawInfo
+                     * is used instead for V36
+                     }
+ SYSIA_Which           =  (IA_Dummy + $0D);
+                    { see 's below      }
+ SYSIA_DrawInfo        =  (IA_Dummy + $18);
+                    { pass to sysiclass, please }
+
+{****  obsolete: don't use these, use IA_Pens  ****}
+ SYSIA_Pens            =  IA_Pens;
+ IA_ShadowPen          =  (IA_Dummy + $09);
+ IA_HighlightPen       =  (IA_Dummy + $0A);
+
+{ New for V39: }
+ SYSIA_ReferenceFont   =  (IA_Dummy + $19);
+                    { Font to use as reference for scaling
+                     * certain sysiclass images
+                     }
+ IA_SupportsDisable    =  (IA_Dummy + $1a);
+                    { By default, Intuition ghosts gadgets itself,
+                     * instead of relying on IDS_DISABLED or
+                     * IDS_SELECTEDDISABLED.  An imageclass that
+                     * supports these states should return this attribute
+                     * as TRUE.  You cannot set or clear this attribute,
+                     * however.
+                     }
+
+ IA_FrameType          =  (IA_Dummy + $1b);
+                    { Starting with V39, FrameIClass recognizes
+                     * several standard types of frame.  Use one
+                     * of the FRAME_ specifiers below.  Defaults
+                     * to FRAME_DEFAULT.
+                     }
+
+{* next attribute: (IA_Dummy + $1c)   *}
+
+{***********************************************}
+
+{ data values for SYSIA_Size   }
+ SYSISIZE_MEDRES = (0);
+ SYSISIZE_LOWRES = (1);
+ SYSISIZE_HIRES  = (2);
+
+{
+ * SYSIA_Which tag data values:
+ * Specifies which system gadget you want an image for.
+ * Some numbers correspond to internal Intuition s
+ }
+ DEPTHIMAGE     = ($00);
+ ZOOMIMAGE      = ($01);
+ SIZEIMAGE      = ($02);
+ CLOSEIMAGE     = ($03);
+ SDEPTHIMAGE    = ($05); { screen depth gadget }
+ LEFTIMAGE      = ($0A);
+ UPIMAGE        = ($0B);
+ RIGHTIMAGE     = ($0C);
+ DOWNIMAGE      = ($0D);
+ CHECKIMAGE     = ($0E);
+ MXIMAGE        = ($0F); { mutual exclude "button" }
+{* New for V39: *}
+ MENUCHECK      = ($10); { Menu checkmark image }
+ AMIGAKEY       = ($11); { Menu Amiga-key image }
+
+
+{ image message id's   }
+    IM_DRAW     = $202;  { draw yourself, with "state"          }
+    IM_HITTEST  = $203;  { return TRUE IF click hits image      }
+    IM_ERASE    = $204;  { erase yourself                       }
+    IM_MOVE     = $205;  { draw new AND erase old, smoothly     }
+
+    IM_DRAWFRAME= $206;  { draw with specified dimensions       }
+    IM_FRAMEBOX = $207;  { get recommended frame around some box}
+    IM_HITFRAME = $208;  { hittest with dimensions              }
+    IM_ERASEFRAME= $209; { hittest with dimensions              }
+
+{ image draw states or styles, for IM_DRAW }
+    IDS_NORMAL          = (0);
+    IDS_SELECTED        = (1);    { for selected gadgets     }
+    IDS_DISABLED        = (2);    { for disabled gadgets     }
+    IDS_BUSY            = (3);    { for future functionality }
+    IDS_INDETERMINATE   = (4);    { for future functionality }
+    IDS_INACTIVENORMAL  = (5);    { normal, in inactive window border }
+    IDS_INACTIVESELECTED= (6);    { selected, in inactive border }
+    IDS_INACTIVEDISABLED= (7);    { disabled, in inactive border }
+
+{ oops, please forgive spelling error by jimm }
+ IDS_INDETERMINANT = IDS_INDETERMINATE;
+
+{ IM_FRAMEBOX  }
+Type
+
+  pimpFrameBox = ^timpFrameBox;
+  timpFrameBox = record
+    MethodID   : ULONG;
+    imp_ContentsBox  : pIBox;       { input: relative box of contents }
+    imp_FrameBox     : pIBox;          { output: rel. box of encl frame  }
+    imp_DrInfo       : pDrawInfo;
+    imp_FrameFlags   : ULONG;
+  END;
+
+CONST
+ FRAMEF_SPECIFY = (1);  { Make do with the dimensions of FrameBox
+                                 * provided.
+                                 }
+
+{ IM_DRAW, IM_DRAWFRAME        }
+Type
+
+   pimpDraw = ^timpDraw;
+   timpDraw = record
+    MethodID    : ULONG;
+    imp_RPort   : pRastPort;
+    imp_Offset  : record
+              x : Word;
+              y : Word;
+                  end;
+    imp_State   : ULONG;
+    imp_DrInfo  : pDrawInfo;
+
+    { these parameters only valid for IM_DRAWFRAME }
+    imp_Dimensions : record
+             Width : Word;
+            Height : Word;
+                     end;
+   END;
+
+{ IM_ERASE, IM_ERASEFRAME      }
+{ NOTE: This is a subset of impDraw    }
+
+   pimpErase = ^timpErase;
+   timpErase = record
+    MethodID       : ULONG;
+    imp_RPort      : pRastPort;
+    imp_Offset     : record
+                 x : Word;
+                 y : Word;
+                     end;
+
+    { these parameters only valid for IM_ERASEFRAME }
+    imp_Dimensions : record
+             Width : Word;
+            Height : Word;
+                     end;
+   END;
+
+{ IM_HITTEST, IM_HITFRAME      }
+
+   pimpHitTest = ^timpHitTest;
+   timpHitTest = record
+    MethodID   : ULONG;
+    imp_Point  : record
+             x : Word;
+             y : Word;
+                 end;
+
+    { these parameters only valid for IM_HITFRAME }
+    imp_Dimensions : record
+               Width : Word;
+               Height : Word;
+               end;
+   END;
+
+ { **  'boopsi' pointer class interface }
+
+const
+{ The following tags are recognized at NewObject() time by
+ * pointerclass:
+ *
+ * POINTERA_BitMap (struct BitMap *) - Pointer to bitmap to
+ *      get pointer imagery from.  Bitplane data need not be
+ *      in chip RAM.
+ * POINTERA_XOffset (LONG) - X-offset of the pointer hotspot.
+ * POINTERA_YOffset (LONG) - Y-offset of the pointer hotspot.
+ * POINTERA_WordWidth (ULONG) - designed width of the pointer in words
+ * POINTERA_XResolution (ULONG) - one of the POINTERXRESN_ flags below
+ * POINTERA_YResolution (ULONG) - one of the POINTERYRESN_ flags below
+ *
+ }
+
+ POINTERA_Dummy = (TAG_USER + $39000);
+
+ POINTERA_BitMap        = (POINTERA_Dummy + $01);
+ POINTERA_XOffset       = (POINTERA_Dummy + $02);
+ POINTERA_YOffset       = (POINTERA_Dummy + $03);
+ POINTERA_WordWidth     = (POINTERA_Dummy + $04);
+ POINTERA_XResolution   = (POINTERA_Dummy + $05);
+ POINTERA_YResolution   = (POINTERA_Dummy + $06);
+
+{ These are the choices for the POINTERA_XResolution attribute which
+ * will determine what resolution pixels are used for this pointer.
+ *
+ * POINTERXRESN_DEFAULT (ECS-compatible pointer width)
+ *      = 70 ns if SUPERHIRES-type mode, 140 ns if not
+ *
+ * POINTERXRESN_SCREENRES
+ *      = Same as pixel speed of screen
+ *
+ * POINTERXRESN_LORES (pointer always in lores-like pixels)
+ *      = 140 ns in 15kHz modes, 70 ns in 31kHz modes
+ *
+ * POINTERXRESN_HIRES (pointer always in hires-like pixels)
+ *      = 70 ns in 15kHz modes, 35 ns in 31kHz modes
+ *
+ * POINTERXRESN_140NS (pointer always in 140 ns pixels)
+ *      = 140 ns always
+ *
+ * POINTERXRESN_70NS (pointer always in 70 ns pixels)
+ *      = 70 ns always
+ *
+ * POINTERXRESN_35NS (pointer always in 35 ns pixels)
+ *      = 35 ns always
+ }
+
+ POINTERXRESN_DEFAULT   = 0;
+ POINTERXRESN_140NS     = 1;
+ POINTERXRESN_70NS      = 2;
+ POINTERXRESN_35NS      = 3;
+
+ POINTERXRESN_SCREENRES = 4;
+ POINTERXRESN_LORES     = 5;
+ POINTERXRESN_HIRES     = 6;
+
+{ These are the choices for the POINTERA_YResolution attribute which
+ * will determine what vertical resolution is used for this pointer.
+ *
+ * POINTERYRESN_DEFAULT
+ *      = In 15 kHz modes, the pointer resolution will be the same
+ *        as a non-interlaced screen.  In 31 kHz modes, the pointer
+ *        will be doubled vertically.  This means there will be about
+ *        200-256 pointer lines per screen.
+ *
+ * POINTERYRESN_HIGH
+ * POINTERYRESN_HIGHASPECT
+ *      = Where the hardware/software supports it, the pointer resolution
+ *        will be high.  This means there will be about 400-480 pointer
+ *        lines per screen.  POINTERYRESN_HIGHASPECT also means that
+ *        when the pointer comes out double-height due to hardware/software
+ *        restrictions, its width would be doubled as well, if possible
+ *        (to preserve aspect).
+ *
+ * POINTERYRESN_SCREENRES
+ * POINTERYRESN_SCREENRESASPECT
+ *      = Will attempt to match the vertical resolution of the pointer
+ *        to the screen's vertical resolution.  POINTERYRESN_SCREENASPECT also
+ *        means that when the pointer comes out double-height due to
+ *        hardware/software restrictions, its width would be doubled as well,
+ *        if possible (to preserve aspect).
+ *
+ }
+
+ POINTERYRESN_DEFAULT          =  0;
+ POINTERYRESN_HIGH             =  2;
+ POINTERYRESN_HIGHASPECT       =  3;
+ POINTERYRESN_SCREENRES        =  4;
+ POINTERYRESN_SCREENRESASPECT  =  5;
+
+{ Compatibility note:
+ *
+ * The AA chipset supports variable sprite width and resolution, but
+ * the setting of width and resolution is global for all sprites.
+ * When no other sprites are in use, Intuition controls the sprite
+ * width and sprite resolution for correctness based on pointerclass
+ * attributes specified by the creator of the pointer.  Intuition
+ * controls sprite resolution with the VTAG_DEFSPRITERESN_SET tag
+ * to VideoControl().  Applications can override this on a per-viewport
+ * basis with the VTAG_SPRITERESN_SET tag to VideoControl().
+ *
+ * If an application uses a sprite other than the pointer sprite,
+ * Intuition will automatically regenerate the pointer sprite's image in
+ * a compatible width.  This might involve BitMap scaling of the imagery
+ * you supply.
+ *
+ * If any sprites other than the pointer sprite were obtained with the
+ * old GetSprite() call, Intuition assumes that the owner of those
+ * sprites is unaware of sprite resolution, hence Intuition will set the
+ * default sprite resolution (VTAG_DEFSPRITERESN_SET) to ECS-compatible,
+ * instead of as requested by the various pointerclass attributes.
+ *
+ * No resolution fallback occurs when applications use ExtSprites.
+ * Such applications are expected to use VTAG_SPRITERESN_SET tag if
+ * necessary.
+ *
+ * NB:  Under release V39, only sprite width compatibility is implemented.
+ * Sprite resolution compatibility was added for V40.
+ }
+
+
+Type
+
+   pStringExtend = ^tStringExtend;
+   tStringExtend = record
+    { display specifications   }
+    Font        : pTextFont;      { must be an open Font (not TextAttr)  }
+    Pens        : Array[0..1] of Byte;        { color of text/backgroun              }
+    ActivePens  : Array[0..1] of Byte;  { colors when gadget is active         }
+
+    { edit specifications      }
+    InitialModes : ULONG;   { initial mode flags, below            }
+    EditHook     : pHook;      { IF non-NULL, must supply WorkBuffer  }
+    WorkBuffer   : STRPTR;    { must be as large as StringInfo.Buffer}
+
+    Reserved     : Array[0..3] of ULONG;    { set to 0                             }
+   END;
+
+   pSGWork = ^tSGWork;
+   tSGWork = record
+    { set up when gadget is first activated    }
+    Gad       : pGadget;         { the contestant itself        }   { Gadget in C-Includes }
+    StrInfo   : pStringInfo;     { easy access to sinfo         }   { StrInfo in C-Includes }
+    WorkBuffer : STRPTR;           { intuition's planned result   }
+    PrevBuffer : STRPTR;           { what was there before        }
+    Modes      : ULONG;          { current mode                 }
+
+    { modified for each input event    }
+    IEvent     : pInputEvent;    { actual event: do not change  }
+    Code       : Word;            { character code, IF one byte  }
+    BufferPos  : Integer;            { cursor position              }
+    NumChars   : Integer;
+    Actions    : ULONG;          { what Intuition will do       }
+    LongInt_   : Longint;          { temp storage for longint     }
+
+    GInfo      : pGadgetInfo;    { see cghooks.h                }   { GadgetInfo in C-Includes }
+    EditOp     : Word;            { from constants below         }
+   END;
+
+{ SGWork.EditOp -
+ * These values indicate what basic type of operation the global
+ * editing hook has performed on the string before your gadget's custom
+ * editing hook gets called.  You do not have to be concerned with the
+ * value your custom hook leaves in the EditOp field, only if you
+ * write a global editing hook.
+ *
+ * For most of these general edit operations, you'll want to compare
+ * the BufferPos and NumChars of the StringInfo (before global editing)
+ * and SGWork (after global editing).
+ }
+
+CONST
+ EO_NOOP       =  ($0001);
+        { did nothing                                                  }
+ EO_DELBACKWARD=  ($0002);
+        { deleted some chars (maybe 0).                                }
+ EO_DELFORWARD =  ($0003);
+        { deleted some characters under and in front of the cursor     }
+ EO_MOVECURSOR =  ($0004);
+        { moved the cursor                                             }
+ EO_ENTER      =  ($0005);
+        { "enter" or "return" key, terminate                           }
+ EO_RESET      =  ($0006);
+        { current Intuition-style undo                                 }
+ EO_REPLACECHAR=  ($0007);
+        { replaced one character and (maybe) advanced cursor           }
+ EO_INSERTCHAR =  ($0008);
+        { inserted one char into string or added one at end            }
+ EO_BADFORMAT  =  ($0009);
+        { didn't like the text data, e.g., Bad LONGINT                 }
+ EO_BIGCHANGE  =  ($000A);        { unused by Intuition  }
+        { complete or major change to the text, e.g. new string        }
+ EO_UNDO       =  ($000B);        { unused by Intuition  }
+        { some other style of undo                                     }
+ EO_CLEAR      =  ($000C);
+        { clear the string                                             }
+ EO_SPECIAL    =  ($000D);        { unused by Intuition  }
+        { some operation that doesn't fit into the categories here     }
+
+
+{ Mode Flags definitions (ONLY first group allowed as InitialModes)    }
+ SGM_REPLACE   =  (1);       { replace mode                 }
+{ please initialize StringInfo with in-range value of BufferPos
+ * if you are using SGM_REPLACE mode.
+ }
+
+ SGM_FIXEDFIELD = (2);       { fixed length buffer          }
+                                        { always set SGM_REPLACE, too  }
+ SGM_NOFILTER   = (4);       { don't filter control chars   }
+
+{ SGM_EXITHELP is new for V37, and ignored by V36: }
+ SGM_EXITHELP   = (128);       { exit with code = $5F IF HELP hit }
+
+
+{ These Mode Flags are for internal use only                           }
+ SGM_NOCHANGE   = (8);       { no edit changes yet          }
+ SGM_NOWORKB    = (16);       { Buffer == PrevBuffer         }
+ SGM_CONTROL    = (32);       { control char escape mode     }
+ SGM_LONGINT    = (64);       { an intuition longint gadget  }
+
+{ String Gadget Action Flags (put in SGWork.Actions by EditHook)       }
+ SGA_USE        = ($1);  { use contents of SGWork               }
+ SGA_END        = ($2);  { terminate gadget, code in Code field }
+ SGA_BEEP       = ($4);  { flash the screen for the user        }
+ SGA_REUSE      = ($8);  { reuse input event                    }
+ SGA_REDISPLAY  = ($10); { gadget visuals changed               }
+
+{ New for V37: }
+ SGA_NEXTACTIVE = ($20); { Make next possible gadget active.    }
+ SGA_PREVACTIVE = ($40); { Make previous possible gadget active.}
+
+{ function id for only existing custom string gadget edit hook }
+
+ SGH_KEY        = (1);    { process editing keystroke            }
+ SGH_CLICK      = (2);    { process mouse click cursor position  }
+
+{ Here's a brief summary of how the custom string gadget edit hook works:
+ *      You provide a hook in StringInfo.Extension.EditHook.
+ *      The hook is called in the standard way with the 'object'
+ *      a pointer to SGWork, and the 'message' a pointer to a command
+ *      block, starting either with (longword) SGH_KEY, SGH_CLICK,
+ *      or something new.
+ *
+ *      You return 0 if you don't understand the command (SGH_KEY is
+ *      required and assumed).  Return non-zero if you implement the
+ *      command.
+ *
+ *   SGH_KEY:
+ *      There are no parameters following the command longword.
+ *
+ *      Intuition will put its idea of proper values in the SGWork
+ *      before calling you, and if you leave SGA_USE set in the
+ *      SGWork.Actions field, Intuition will use the values
+ *      found in SGWork fields WorkBuffer, NumChars, BufferPos,
+ *      and LongInt, copying the WorkBuffer back to the StringInfo
+ *      Buffer.
+ *
+ *      NOTE WELL: You may NOT change other SGWork fields.
+ *
+ *      If you clear SGA_USE, the string gadget will be unchanged.
+ *
+ *      If you set SGA_END, Intuition will terminate the activation
+ *      of the string gadget.  If you also set SGA_REUSE, Intuition
+ *      will reuse the input event after it deactivates your gadget.
+ *
+ *      In this case, Intuition will put the value found in SGWork.Code
+ *      into the IntuiMessage.Code field of the IDCMP_GADGETUP message it
+ *      sends to the application.
+ *
+ *      If you set SGA_BEEP, Intuition will call DisplayBeep(); use
+ *      this if the user has typed in error, or buffer is full.
+ *
+ *      Set SGA_REDISPLAY if the changes to the gadget warrant a
+ *      gadget redisplay.  Note: cursor movement requires a redisplay.
+ *
+ *      Starting in V37, you may set SGA_PREVACTIVE or SGA_NEXTACTIVE
+ *      when you set SGA_END.  This tells Intuition that you want
+ *      the next or previous gadget with GFLG_TABCYCLE to be activated.
+ *
+ *   SGH_CLICK:
+ *      This hook command is called when Intuition wants to position
+ *      the cursor in response to a mouse click in the string gadget.
+ *
+ *      Again, here are no parameters following the command longword.
+ *
+ *      This time, Intuition has already calculated the mouse position
+ *      character cell and put it in SGWork.BufferPos.  The previous
+ *      BufferPos value remains in the SGWork.StringInfo.BufferPos.
+ *
+ *      Intuition will again use the SGWork fields listed above for
+ *      SGH_KEY.  One restriction is that you are NOT allowed to set
+ *      SGA_END or SGA_REUSE for this command.  Intuition will not
+ *      stand for a gadget which goes inactive when you click in it.
+ *
+ *      You should always leave the SGA_REDISPLAY flag set, since Intuition
+ *      uses this processing when activating a string gadget.
+ }
+
+FUNCTION ActivateGadget(gadgets : pGadget; window : pWindow; requester : pRequester) : BOOLEAN;
+PROCEDURE ActivateWindow(window : pWindow);
+PROCEDURE AddClass(classPtr : pIClass);
+FUNCTION AddGadget(window : pWindow; gadget : pGadget; position : ULONG) : WORD;
+FUNCTION AddGList(window : pWindow; gadget : pGadget; position : ULONG; numGad : LONGINT; requester : pRequester) : WORD;
+FUNCTION AllocRemember(VAR rememberKey : pRemember; size : ULONG; flags : ULONG) : POINTER;
+FUNCTION AllocScreenBuffer(sc : pScreen; bm : pBitMap; flags : ULONG) : pScreenBuffer;
+FUNCTION AutoRequest(window : pWindow; body : pIntuiText; posText : pIntuiText; negText : pIntuiText; pFlag : ULONG; nFlag : ULONG; width : ULONG; height : ULONG) : BOOLEAN;
+PROCEDURE BeginRefresh(window : pWindow);
+FUNCTION BuildEasyRequestArgs(window : pWindow; easyStruct : pEasyStruct; idcmp : ULONG; args : POINTER) : pWindow;
+FUNCTION BuildSysRequest(window : pWindow; body : pIntuiText; posText : pIntuiText; negText : pIntuiText; flags : ULONG; width : ULONG; height : ULONG) : pWindow;
+FUNCTION ChangeScreenBuffer(sc : pScreen; sb : pScreenBuffer) : ULONG;
+PROCEDURE ChangeWindowBox(window : pWindow; left : LONGINT; top : LONGINT; width : LONGINT; height : LONGINT);
+FUNCTION ClearDMRequest(window : pWindow) : BOOLEAN;
+PROCEDURE ClearMenuStrip(window : pWindow);
+PROCEDURE ClearPointer(window : pWindow);
+PROCEDURE CloseScreen(screen : pScreen);
+PROCEDURE CloseWindow(window : pWindow);
+FUNCTION CloseWorkBench : BOOLEAN;
+PROCEDURE CurrentTime(VAR seconds : ULONG; VAR micros : ULONG);
+FUNCTION DisplayAlert(alertNumber : ULONG; string_ : pCHAR; height : ULONG) : BOOLEAN;
+PROCEDURE DisplayBeep(screen : pScreen);
+PROCEDURE DisposeObject(obj : POINTER);
+FUNCTION DoGadgetMethodA(gad : pGadget; win : pWindow; req : pRequester; message : tMsg) : ULONG;
+FUNCTION DoubleClick(sSeconds : ULONG; sMicros : ULONG; cSeconds : ULONG; cMicros : ULONG) : BOOLEAN;
+PROCEDURE DrawBorder(rp : pRastPort; border : pBorder; leftOffset : LONGINT; topOffset : LONGINT);
+PROCEDURE DrawImage(rp : pRastPort; image : pImage; leftOffset : LONGINT; topOffset : LONGINT);
+PROCEDURE DrawImageState(rp : pRastPort; image : pImage; leftOffset : LONGINT; topOffset : LONGINT; state : ULONG; drawInfo : pDrawInfo);
+FUNCTION EasyRequestArgs(window : pWindow; easyStruct : pEasyStruct; idcmpPtr : ULONG; args : POINTER) : LONGINT;
+PROCEDURE EndRefresh(window : pWindow; complete : LONGINT);
+PROCEDURE EndRequest(requester : pRequester; window : pWindow);
+PROCEDURE EraseImage(rp : pRastPort; image : pImage; leftOffset : LONGINT; topOffset : LONGINT);
+FUNCTION FreeClass(classPtr : pIClass) : BOOLEAN;
+PROCEDURE FreeRemember(VAR rememberKey : pRemember; reallyForget : LONGINT);
+PROCEDURE FreeScreenBuffer(sc : pScreen; sb : pScreenBuffer);
+PROCEDURE FreeScreenDrawInfo(screen : pScreen; drawInfo : pDrawInfo);
+PROCEDURE FreeSysRequest(window : pWindow);
+PROCEDURE GadgetMouse(gadget : pGadget; gInfo : pGadgetInfo; mousePoint : POINTER);
+FUNCTION GetAttr(attrID : ULONG; obj : POINTER; storagePtr : POINTER) : ULONG;
+PROCEDURE GetDefaultPubScreen(nameBuffer : pCHAR);
+FUNCTION GetDefPrefs(preferences : pPreferences; size : LONGINT) : pPreferences;
+FUNCTION GetPrefs(preferences : pPreferences; size : LONGINT) : pPreferences;
+FUNCTION GetScreenData(buffer : POINTER; size : ULONG; type_ : ULONG; screen : pScreen) : BOOLEAN;
+FUNCTION GetScreenDrawInfo(screen : pScreen) : pDrawInfo;
+PROCEDURE HelpControl(win : pWindow; flags : ULONG);
+PROCEDURE InitRequester(requester : pRequester);
+FUNCTION IntuiTextLength(iText : pIntuiText) : LONGINT;
+FUNCTION ItemAddress(menuStrip : pMenu; menuNumber : ULONG) : pMenuItem;
+PROCEDURE LendMenus(fromwindow : pWindow; towindow : pWindow);
+FUNCTION LockIBase(dontknow : ULONG) : ULONG;
+FUNCTION LockPubScreen(name : pCHAR) : pScreen;
+FUNCTION LockPubScreenList : pList;
+FUNCTION MakeClass(classID : pCHAR; superClassID : pCHAR; superClassPtr : pIClass; instanceSize : ULONG; flags : ULONG) : pIClass;
+FUNCTION MakeScreen(screen : pScreen) : LONGINT;
+FUNCTION ModifyIDCMP(window : pWindow; flags : ULONG) : BOOLEAN;
+PROCEDURE ModifyProp(gadget : pGadget; window : pWindow; requester : pRequester; flags : ULONG; horizPot : ULONG; vertPot : ULONG; horizBody : ULONG; vertBody : ULONG);
+PROCEDURE MoveScreen(screen : pScreen; dx : LONGINT; dy : LONGINT);
+PROCEDURE MoveWindow(window : pWindow; dx : LONGINT; dy : LONGINT);
+PROCEDURE MoveWindowInFrontOf(window : pWindow; behindWindow : pWindow);
+PROCEDURE NewModifyProp(gadget : pGadget; window : pWindow; requester : pRequester; flags : ULONG; horizPot : ULONG; vertPot : ULONG; horizBody : ULONG; vertBody : ULONG; numGad : LONGINT);
+FUNCTION NewObjectA(classPtr : pIClass; classID : pCHAR; tagList : pTagItem) : POINTER;
+FUNCTION NextObject(objectPtrPtr : POINTER) : POINTER;
+FUNCTION NextPubScreen(screen : pScreen; namebuf : pCHAR) : pCHAR;
+FUNCTION ObtainGIRPort(gInfo : pGadgetInfo) : pRastPort;
+PROCEDURE OffGadget(gadget : pGadget; window : pWindow; requester : pRequester);
+PROCEDURE OffMenu(window : pWindow; menuNumber : ULONG);
+PROCEDURE OnGadget(gadget : pGadget; window : pWindow; requester : pRequester);
+PROCEDURE OnMenu(window : pWindow; menuNumber : ULONG);
+FUNCTION OpenScreen(newScreen : pNewScreen) : pScreen;
+FUNCTION OpenScreenTagList(newScreen : pNewScreen; tagList : pTagItem) : pScreen;
+FUNCTION OpenWindow(newWindow : pNewWindow) : pWindow;
+FUNCTION OpenWindowTagList(newWindow : pNewWindow; tagList : pTagItem) : pWindow;
+FUNCTION OpenWorkBench : ULONG;
+FUNCTION PointInImage(point : ULONG; image : pImage) : BOOLEAN;
+PROCEDURE PrintIText(rp : pRastPort; iText : pIntuiText; left : LONGINT; top : LONGINT);
+FUNCTION PubScreenStatus(screen : pScreen; statusFlags : ULONG) : WORD;
+FUNCTION QueryOverscan(displayID : ULONG; rect : pRectangle; oScanType : LONGINT) : LONGINT;
+PROCEDURE RefreshGadgets(gadgets : pGadget; window : pWindow; requester : pRequester);
+PROCEDURE RefreshGList(gadgets : pGadget; window : pWindow; requester : pRequester; numGad : LONGINT);
+PROCEDURE RefreshWindowFrame(window : pWindow);
+PROCEDURE ReleaseGIRPort(rp : pRastPort);
+FUNCTION RemakeDisplay : LONGINT;
+PROCEDURE RemoveClass(classPtr : pIClass);
+FUNCTION RemoveGadget(window : pWindow; gadget : pGadget) : WORD;
+FUNCTION RemoveGList(remPtr : pWindow; gadget : pGadget; numGad : LONGINT) : WORD;
+PROCEDURE ReportMouse(flag : LONGINT; window : pWindow);
+FUNCTION Request(requester : pRequester; window : pWindow) : BOOLEAN;
+FUNCTION ResetMenuStrip(window : pWindow; menu : pMenu) : BOOLEAN;
+FUNCTION RethinkDisplay : LONGINT;
+PROCEDURE ScreenDepth(screen : pScreen; flags : ULONG; reserved : POINTER);
+PROCEDURE ScreenPosition(screen : pScreen; flags : ULONG; x1 : LONGINT; y1 : LONGINT; x2 : LONGINT; y2 : LONGINT);
+PROCEDURE ScreenToBack(screen : pScreen);
+PROCEDURE ScreenToFront(screen : pScreen);
+PROCEDURE ScrollWindowRaster(win : pWindow; dx : LONGINT; dy : LONGINT; xMin : LONGINT; yMin : LONGINT; xMax : LONGINT; yMax : LONGINT);
+FUNCTION SetAttrsA(obj : POINTER; tagList : pTagItem) : ULONG;
+PROCEDURE SetDefaultPubScreen(name : pCHAR);
+FUNCTION SetDMRequest(window : pWindow; requester : pRequester) : BOOLEAN;
+FUNCTION SetEditHook(hook : pHook) : pHook;
+FUNCTION SetGadgetAttrsA(gadget : pGadget; window : pWindow; requester : pRequester; tagList : pTagItem) : ULONG;
+FUNCTION SetMenuStrip(window : pWindow; menu : pMenu) : BOOLEAN;
+FUNCTION SetMouseQueue(window : pWindow; queueLength : ULONG) : LONGINT;
+PROCEDURE SetPointer(window : pWindow; pointer_ : POINTER; height : LONGINT; width : LONGINT; xOffset : LONGINT; yOffset : LONGINT);
+FUNCTION SetPrefs(preferences : pPreferences; size : LONGINT; inform : LONGINT) : pPreferences;
+FUNCTION SetPubScreenModes(modes : ULONG) : WORD;
+PROCEDURE SetWindowPointerA(win : pWindow; taglist : pTagItem);
+PROCEDURE SetWindowTitles(window : pWindow; windowTitle : pCHAR; screenTitle : pCHAR);
+PROCEDURE ShowTitle(screen : pScreen; showIt : LONGINT);
+PROCEDURE SizeWindow(window : pWindow; dx : LONGINT; dy : LONGINT);
+FUNCTION SysReqHandler(window : pWindow; idcmpPtr : ULONG; waitInput : LONGINT) : LONGINT;
+FUNCTION TimedDisplayAlert(alertNumber : ULONG; string_ : pCHAR; height : ULONG; time : ULONG) : BOOLEAN;
+PROCEDURE UnlockIBase(ibLock : ULONG);
+PROCEDURE UnlockPubScreen(name : pCHAR; screen : pScreen);
+PROCEDURE UnlockPubScreenList;
+FUNCTION ViewAddress : pView;
+FUNCTION ViewPortAddress(window : pWindow) : pViewPort;
+FUNCTION WBenchToBack : BOOLEAN;
+FUNCTION WBenchToFront : BOOLEAN;
+FUNCTION WindowLimits(window : pWindow; widthMin : LONGINT; heightMin : LONGINT; widthMax : ULONG; heightMax : ULONG) : BOOLEAN;
+PROCEDURE WindowToBack(window : pWindow);
+PROCEDURE WindowToFront(window : pWindow);
+PROCEDURE ZipWindow(window : pWindow);
+
+{ Intuition macros }
+function INST_DATA (cl: pIClass; o: p_Object): Pointer;
+function SIZEOF_INSTANCE (cl: pIClass): Longint;
+function BASEOBJECT (o: p_Object): Pointer;
+function _OBJ(o: p_Object): p_Object;
+function __OBJECT (o: Pointer): p_Object;
+function OCLASS (o: Pointer): pIClass;
+function SHIFTITEM (n: integer): word;
+function SHIFTMENU (n: integer): word;
+function SHIFTSUB (n: integer): word;
+function FULLMENUNUM (menu, item, sub: integer): word;
+function IM_BGPEN (im: pImage): byte;
+function IM_BOX (im: pImage): pIBox;
+function IM_FGPEN (im: pImage): byte;
+function GADGET_BOX (g: pGadget): pIBox;
+function CUSTOM_HOOK (gadget: pGadget): pHook;
+function ITEMNUM( n : Word): Word;
+function MENUNUM( n : Word): Word;
+function SUBNUM( n : Word): Word;
+
+IMPLEMENTATION
+
+function INST_DATA (cl: pIClass; o: p_Object): Pointer;
+begin
+    INST_DATA := Pointer(Longint(o) + cl^.cl_InstOffset);
+end;
+
+function SIZEOF_INSTANCE (cl: pIClass): Longint;
+begin
+    SIZEOF_INSTANCE := cl^.cl_InstOffset + cl^.cl_InstSize + sizeof(t_Object);
+end;
+
+function BASEOBJECT (o: p_Object): Pointer;
+begin
+    BASEOBJECT := Pointer(Longint(o) + sizeof(t_Object));
+end;
+
+function _OBJ(o: p_Object): p_Object;
+begin
+     _OBJ := p_Object(o);
+END;
+
+function __OBJECT (o: Pointer): p_Object;
+begin
+    __OBJECT := p_Object(Longint(o) - sizeof(t_Object))
+end;
+
+function OCLASS (o: Pointer): pIClass;
+var
+    obj: p_Object;
+begin
+    obj := p_Object(Longint(o) - sizeof(t_Object));
+    OCLASS := obj^.o_Class;
+end;
+
+function SHIFTITEM (n: integer): word;
+begin
+    SHIFTITEM := (n and $3f) shl 5
+end;
+
+function SHIFTMENU (n: integer): word;
+begin
+    SHIFTMENU := n and $1f
+end;
+
+function SHIFTSUB (n: integer): word;
+begin
+    SHIFTSUB := (n and $1f) shl 11
+end;
+
+function FULLMENUNUM (menu, item, sub: integer): word;
+begin
+    FULLMENUNUM := ((sub and $1f) shl 11) or
+                    ((item and $3f) shl 5) or
+                      (menu and $1f)
+end;
+
+
+
+{ The next functons _BGPEN AND _FGPEN aren't a full replacement of the
+  C macros because the C preprocessor makes it possible to set the
+  A/BPen values of the image class objects as well. This can't work
+  in pascal, of course! }
+
+function IM_BGPEN (im: pImage): byte;
+begin
+    IM_BGPEN := im^.PlaneOnOff;
+end;
+
+function IM_BOX (im: pImage): pIBox;
+begin
+    IM_BOX := pIBox(@im^.LeftEdge);
+END;
+
+function IM_FGPEN (im: pImage): byte;
+begin
+    IM_FGPEN := im^.PlanePick;
+end;
+
+function GADGET_BOX (g: pGadget): pIBox;
+begin
+    GADGET_BOX := pIBox(@g^.LeftEdge);
+end;
+
+function CUSTOM_HOOK (gadget: pGadget): pHook;
+begin
+    CUSTOM_HOOK := pHook(gadget^.MutualExclude);
+end;
+
+function ITEMNUM( n : Word): Word;
+begin
+    ITEMNUM := (n shr 5) and $3F
+end;
+
+function MENUNUM( n : Word): Word;
+begin
+    MENUNUM := n and $1f
+end;
+
+function SUBNUM( n : Word): Word;
+begin
+    SUBNUM := (n shr 11) and $1f
+end;
+
+FUNCTION ActivateGadget(gadgets : pGadget; window : pWindow; requester : pRequester) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L gadgets,A0
+    MOVEA.L window,A1
+    MOVEA.L requester,A2
+    MOVEA.L _IntuitionBase,A6
+    JSR -462(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ActivateWindow(window : pWindow);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -450(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE AddClass(classPtr : pIClass);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L classPtr,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -684(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION AddGadget(window : pWindow; gadget : pGadget; position : ULONG) : WORD;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L gadget,A1
+    MOVE.L  position,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AddGList(window : pWindow; gadget : pGadget; position : ULONG; numGad : LONGINT; requester : pRequester) : WORD;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L gadget,A1
+    MOVE.L  position,D0
+    MOVE.L  numGad,D1
+    MOVEA.L requester,A2
+    MOVEA.L _IntuitionBase,A6
+    JSR -438(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AllocRemember(VAR rememberKey : pRemember; size : ULONG; flags : ULONG) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rememberKey,A0
+    MOVE.L  size,D0
+    MOVE.L  flags,D1
+    MOVEA.L _IntuitionBase,A6
+    JSR -396(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AllocScreenBuffer(sc : pScreen; bm : pBitMap; flags : ULONG) : pScreenBuffer;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L sc,A0
+    MOVEA.L bm,A1
+    MOVE.L  flags,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -768(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AutoRequest(window : pWindow; body : pIntuiText; posText : pIntuiText; negText : pIntuiText; pFlag : ULONG; nFlag : ULONG; width : ULONG; height : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L body,A1
+    MOVEA.L posText,A2
+    MOVEA.L negText,A3
+    MOVE.L  pFlag,D0
+    MOVE.L  nFlag,D1
+    MOVE.L  width,D2
+    MOVE.L  height,D3
+    MOVEA.L _IntuitionBase,A6
+    JSR -348(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE BeginRefresh(window : pWindow);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -354(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION BuildEasyRequestArgs(window : pWindow; easyStruct : pEasyStruct; idcmp : ULONG; args : POINTER) : pWindow;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L easyStruct,A1
+    MOVE.L  idcmp,D0
+    MOVEA.L args,A3
+    MOVEA.L _IntuitionBase,A6
+    JSR -594(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION BuildSysRequest(window : pWindow; body : pIntuiText; posText : pIntuiText; negText : pIntuiText; flags : ULONG; width : ULONG; height : ULONG) : pWindow;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L body,A1
+    MOVEA.L posText,A2
+    MOVEA.L negText,A3
+    MOVE.L  flags,D0
+    MOVE.L  width,D1
+    MOVE.L  height,D2
+    MOVEA.L _IntuitionBase,A6
+    JSR -360(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ChangeScreenBuffer(sc : pScreen; sb : pScreenBuffer) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L sc,A0
+    MOVEA.L sb,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -780(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ChangeWindowBox(window : pWindow; left : LONGINT; top : LONGINT; width : LONGINT; height : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVE.L  left,D0
+    MOVE.L  top,D1
+    MOVE.L  width,D2
+    MOVE.L  height,D3
+    MOVEA.L _IntuitionBase,A6
+    JSR -486(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION ClearDMRequest(window : pWindow) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ClearMenuStrip(window : pWindow);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ClearPointer(window : pWindow);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE CloseScreen(screen : pScreen);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L screen,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -066(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE CloseWindow(window : pWindow);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -072(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION CloseWorkBench : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _IntuitionBase,A6
+    JSR -078(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE CurrentTime(VAR seconds : ULONG; VAR micros : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L seconds,A0
+    MOVEA.L micros,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -084(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION DisplayAlert(alertNumber : ULONG; string_ : pCHAR; height : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  alertNumber,D0
+    MOVEA.L string_,A0
+    MOVE.L  height,D1
+    MOVEA.L _IntuitionBase,A6
+    JSR -090(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE DisplayBeep(screen : pScreen);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L screen,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -096(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE DisposeObject(obj : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L obj,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -642(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION DoGadgetMethodA(gad : pGadget; win : pWindow; req : pRequester; message : tMsg) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L gad,A0
+    MOVEA.L win,A1
+    MOVEA.L req,A2
+    MOVEA.L message,A3
+    MOVEA.L _IntuitionBase,A6
+    JSR -810(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DoubleClick(sSeconds : ULONG; sMicros : ULONG; cSeconds : ULONG; cMicros : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  sSeconds,D0
+    MOVE.L  sMicros,D1
+    MOVE.L  cSeconds,D2
+    MOVE.L  cMicros,D3
+    MOVEA.L _IntuitionBase,A6
+    JSR -102(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE DrawBorder(rp : pRastPort; border : pBorder; leftOffset : LONGINT; topOffset : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVEA.L border,A1
+    MOVE.L  leftOffset,D0
+    MOVE.L  topOffset,D1
+    MOVEA.L _IntuitionBase,A6
+    JSR -108(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE DrawImage(rp : pRastPort; image : pImage; leftOffset : LONGINT; topOffset : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVEA.L image,A1
+    MOVE.L  leftOffset,D0
+    MOVE.L  topOffset,D1
+    MOVEA.L _IntuitionBase,A6
+    JSR -114(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE DrawImageState(rp : pRastPort; image : pImage; leftOffset : LONGINT; topOffset : LONGINT; state : ULONG; drawInfo : pDrawInfo);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVEA.L image,A1
+    MOVE.L  leftOffset,D0
+    MOVE.L  topOffset,D1
+    MOVE.L  state,D2
+    MOVEA.L drawInfo,A2
+    MOVEA.L _IntuitionBase,A6
+    JSR -618(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION EasyRequestArgs(window : pWindow; easyStruct : pEasyStruct; idcmpPtr : ULONG; args : POINTER) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L easyStruct,A1
+    MOVEA.L idcmpPtr,A2
+    MOVEA.L args,A3
+    MOVEA.L _IntuitionBase,A6
+    JSR -588(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE EndRefresh(window : pWindow; complete : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVE.L  complete,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -366(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE EndRequest(requester : pRequester; window : pWindow);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L requester,A0
+    MOVEA.L window,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -120(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE EraseImage(rp : pRastPort; image : pImage; leftOffset : LONGINT; topOffset : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVEA.L image,A1
+    MOVE.L  leftOffset,D0
+    MOVE.L  topOffset,D1
+    MOVEA.L _IntuitionBase,A6
+    JSR -630(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION FreeClass(classPtr : pIClass) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L classPtr,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -714(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE FreeRemember(VAR rememberKey : pRemember; reallyForget : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rememberKey,A0
+    MOVE.L  reallyForget,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -408(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeScreenBuffer(sc : pScreen; sb : pScreenBuffer);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L sc,A0
+    MOVEA.L sb,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -774(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeScreenDrawInfo(screen : pScreen; drawInfo : pDrawInfo);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L screen,A0
+    MOVEA.L drawInfo,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -696(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE FreeSysRequest(window : pWindow);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -372(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE GadgetMouse(gadget : pGadget; gInfo : pGadgetInfo; mousePoint : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L gadget,A0
+    MOVEA.L gInfo,A1
+    MOVEA.L mousePoint,A2
+    MOVEA.L _IntuitionBase,A6
+    JSR -570(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION GetAttr(attrID : ULONG; obj : POINTER; storagePtr : POINTER) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  attrID,D0
+    MOVEA.L obj,A0
+    MOVEA.L storagePtr,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -654(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE GetDefaultPubScreen(nameBuffer : pCHAR);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L nameBuffer,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -582(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION GetDefPrefs(preferences : pPreferences; size : LONGINT) : pPreferences;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L preferences,A0
+    MOVE.L  size,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -126(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetPrefs(preferences : pPreferences; size : LONGINT) : pPreferences;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L preferences,A0
+    MOVE.L  size,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -132(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetScreenData(buffer : POINTER; size : ULONG; type_ : ULONG; screen : pScreen) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L buffer,A0
+    MOVE.L  size,D0
+    MOVE.L  type_,D1
+    MOVEA.L screen,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -426(A6)
+    MOVEA.L (A7)+,A6
+    TST.L   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+    @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetScreenDrawInfo(screen : pScreen) : pDrawInfo;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L screen,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -690(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE HelpControl(win : pWindow; flags : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L win,A0
+    MOVE.L  flags,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -828(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE InitRequester(requester : pRequester);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L requester,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -138(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION IntuiTextLength(iText : pIntuiText) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L iText,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -330(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ItemAddress(menuStrip : pMenu; menuNumber : ULONG) : pMenuItem;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L menuStrip,A0
+    MOVE.L  menuNumber,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -144(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE LendMenus(fromwindow : pWindow; towindow : pWindow);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L fromwindow,A0
+    MOVEA.L towindow,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -804(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION LockIBase(dontknow : ULONG) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  dontknow,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -414(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION LockPubScreen(name : pCHAR) : pScreen;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L name,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -510(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION LockPubScreenList : pList;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _IntuitionBase,A6
+    JSR -522(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION MakeClass(classID : pCHAR; superClassID : pCHAR; superClassPtr : pIClass; instanceSize : ULONG; flags : ULONG) : pIClass;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L classID,A0
+    MOVEA.L superClassID,A1
+    MOVEA.L superClassPtr,A2
+    MOVE.L  instanceSize,D0
+    MOVE.L  flags,D1
+    MOVEA.L _IntuitionBase,A6
+    JSR -678(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION MakeScreen(screen : pScreen): LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L screen,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -378(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ModifyIDCMP(window : pWindow; flags : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVE.L  flags,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -150(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ModifyProp(gadget : pGadget; window : pWindow; requester : pRequester; flags : ULONG; horizPot : ULONG; vertPot : ULONG; horizBody : ULONG; vertBody : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L gadget,A0
+    MOVEA.L window,A1
+    MOVEA.L requester,A2
+    MOVE.L  flags,D0
+    MOVE.L  horizPot,D1
+    MOVE.L  vertPot,D2
+    MOVE.L  horizBody,D3
+    MOVE.L  vertBody,D4
+    MOVEA.L _IntuitionBase,A6
+    JSR -156(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE MoveScreen(screen : pScreen; dx : LONGINT; dy : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L screen,A0
+    MOVE.L  dx,D0
+    MOVE.L  dy,D1
+    MOVEA.L _IntuitionBase,A6
+    JSR -162(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE MoveWindow(window : pWindow; dx : LONGINT; dy : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVE.L  dx,D0
+    MOVE.L  dy,D1
+    MOVEA.L _IntuitionBase,A6
+    JSR -168(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE MoveWindowInFrontOf(window : pWindow; behindWindow : pWindow);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L behindWindow,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -480(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE NewModifyProp(gadget : pGadget; window : pWindow; requester : pRequester; flags : ULONG; horizPot : ULONG; vertPot : ULONG; horizBody : ULONG; vertBody : ULONG; numGad : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L gadget,A0
+    MOVEA.L window,A1
+    MOVEA.L requester,A2
+    MOVE.L  flags,D0
+    MOVE.L  horizPot,D1
+    MOVE.L  vertPot,D2
+    MOVE.L  horizBody,D3
+    MOVE.L  vertBody,D4
+    MOVE.L  numGad,D5
+    MOVEA.L _IntuitionBase,A6
+    JSR -468(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION NewObjectA(classPtr : pIClass; classID : pCHAR; tagList : pTagItem) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L classPtr,A0
+    MOVEA.L classID,A1
+    MOVEA.L tagList,A2
+    MOVEA.L _IntuitionBase,A6
+    JSR -636(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION NextObject(objectPtrPtr : POINTER) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L objectPtrPtr,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -666(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION NextPubScreen(screen : pScreen; namebuf : pCHAR) : pCHAR;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L screen,A0
+    MOVEA.L namebuf,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -534(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ObtainGIRPort(gInfo : pGadgetInfo) : pRastPort;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L gInfo,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -558(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE OffGadget(gadget : pGadget; window : pWindow; requester : pRequester);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L gadget,A0
+    MOVEA.L window,A1
+    MOVEA.L requester,A2
+    MOVEA.L _IntuitionBase,A6
+    JSR -174(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE OffMenu(window : pWindow; menuNumber : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVE.L  menuNumber,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -180(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE OnGadget(gadget : pGadget; window : pWindow; requester : pRequester);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L gadget,A0
+    MOVEA.L window,A1
+    MOVEA.L requester,A2
+    MOVEA.L _IntuitionBase,A6
+    JSR -186(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE OnMenu(window : pWindow; menuNumber : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVE.L  menuNumber,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -192(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION OpenScreen(newScreen : pNewScreen) : pScreen;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L newScreen,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -198(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION OpenScreenTagList(newScreen : pNewScreen; tagList : pTagItem) : pScreen;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L newScreen,A0
+    MOVEA.L tagList,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -612(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION OpenWindow(newWindow : pNewWindow) : pWindow;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L newWindow,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -204(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION OpenWindowTagList(newWindow : pNewWindow; tagList : pTagItem) : pWindow;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L newWindow,A0
+    MOVEA.L tagList,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -606(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION OpenWorkBench : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _IntuitionBase,A6
+    JSR -210(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION PointInImage(point : ULONG; image : pImage) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  point,D0
+    MOVEA.L image,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -624(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE PrintIText(rp : pRastPort; iText : pIntuiText; left : LONGINT; top : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVEA.L iText,A1
+    MOVE.L  left,D0
+    MOVE.L  top,D1
+    MOVEA.L _IntuitionBase,A6
+    JSR -216(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION PubScreenStatus(screen : pScreen; statusFlags : ULONG) : WORD;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L screen,A0
+    MOVE.L  statusFlags,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -552(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION QueryOverscan(displayID : ULONG; rect : pRectangle; oScanType : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L displayID,A0
+    MOVEA.L rect,A1
+    MOVE.L  oScanType,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -474(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE RefreshGadgets(gadgets : pGadget; window : pWindow; requester : pRequester);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L gadgets,A0
+    MOVEA.L window,A1
+    MOVEA.L requester,A2
+    MOVEA.L _IntuitionBase,A6
+    JSR -222(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE RefreshGList(gadgets : pGadget; window : pWindow; requester : pRequester; numGad : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L gadgets,A0
+    MOVEA.L window,A1
+    MOVEA.L requester,A2
+    MOVE.L  numGad,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -432(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE RefreshWindowFrame(window : pWindow);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -456(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ReleaseGIRPort(rp : pRastPort);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -564(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION RemakeDisplay : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _IntuitionBase,A6
+    JSR -384(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE RemoveClass(classPtr : pIClass);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L classPtr,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -708(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION RemoveGadget(window : pWindow; gadget : pGadget) : WORD;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L gadget,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -228(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION RemoveGList(remPtr : pWindow; gadget : pGadget; numGad : LONGINT) : WORD;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L remPtr,A0
+    MOVEA.L gadget,A1
+    MOVE.L  numGad,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -444(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ReportMouse(flag : LONGINT; window : pWindow);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  flag,D0
+    MOVEA.L window,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -234(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION Request(requester : pRequester; window : pWindow) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L requester,A0
+    MOVEA.L window,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -240(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION ResetMenuStrip(window : pWindow; menu : pMenu) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L menu,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -702(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION RethinkDisplay : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _IntuitionBase,A6
+    JSR -390(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ScreenDepth(screen : pScreen; flags : ULONG; reserved : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L screen,A0
+    MOVE.L  flags,D0
+    MOVEA.L reserved,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -786(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ScreenPosition(screen : pScreen; flags : ULONG; x1 : LONGINT; y1 : LONGINT; x2 : LONGINT; y2 : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L screen,A0
+    MOVE.L  flags,D0
+    MOVE.L  x1,D1
+    MOVE.L  y1,D2
+    MOVE.L  x2,D3
+    MOVE.L  y2,D4
+    MOVEA.L _IntuitionBase,A6
+    JSR -792(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ScreenToBack(screen : pScreen);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L screen,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -246(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ScreenToFront(screen : pScreen);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L screen,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -252(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ScrollWindowRaster(win : pWindow; dx : LONGINT; dy : LONGINT; xMin : LONGINT; yMin : LONGINT; xMax : LONGINT; yMax : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L win,A1
+    MOVE.L  dx,D0
+    MOVE.L  dy,D1
+    MOVE.L  xMin,D2
+    MOVE.L  yMin,D3
+    MOVE.L  xMax,D4
+    MOVE.L  yMax,D5
+    MOVEA.L _IntuitionBase,A6
+    JSR -798(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION SetAttrsA(obj : POINTER; tagList : pTagItem) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L obj,A0
+    MOVEA.L tagList,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -648(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE SetDefaultPubScreen(name : pCHAR);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L name,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -540(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION SetDMRequest(window : pWindow; requester : pRequester) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L requester,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -258(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetEditHook(hook : pHook) : pHook;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L hook,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -492(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetGadgetAttrsA(gadget : pGadget; window : pWindow; requester : pRequester; tagList : pTagItem) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L gadget,A0
+    MOVEA.L window,A1
+    MOVEA.L requester,A2
+    MOVEA.L tagList,A3
+    MOVEA.L _IntuitionBase,A6
+    JSR -660(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetMenuStrip(window : pWindow; menu : pMenu) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L menu,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -264(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetMouseQueue(window : pWindow; queueLength : ULONG) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVE.L  queueLength,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -498(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE SetPointer(window : pWindow; pointer_ : POINTER; height : LONGINT; width : LONGINT; xOffset : LONGINT; yOffset : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L pointer_,A1
+    MOVE.L  height,D0
+    MOVE.L  width,D1
+    MOVE.L  xOffset,D2
+    MOVE.L  yOffset,D3
+    MOVEA.L _IntuitionBase,A6
+    JSR -270(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION SetPrefs(preferences : pPreferences; size : LONGINT; inform : LONGINT) : pPreferences;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L preferences,A0
+    MOVE.L  size,D0
+    MOVE.L  inform,D1
+    MOVEA.L _IntuitionBase,A6
+    JSR -324(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetPubScreenModes(modes : ULONG) : WORD;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  modes,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -546(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE SetWindowPointerA(win : pWindow; taglist : pTagItem);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L win,A0
+    MOVEA.L taglist,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -816(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SetWindowTitles(window : pWindow; windowTitle : pCHAR; screenTitle : pCHAR);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L windowTitle,A1
+    MOVEA.L screenTitle,A2
+    MOVEA.L _IntuitionBase,A6
+    JSR -276(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ShowTitle(screen : pScreen; showIt : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L screen,A0
+    MOVE.L  showIt,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -282(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SizeWindow(window : pWindow; dx : LONGINT; dy : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVE.L  dx,D0
+    MOVE.L  dy,D1
+    MOVEA.L _IntuitionBase,A6
+    JSR -288(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION SysReqHandler(window : pWindow; idcmpPtr : ULONG; waitInput : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L idcmpPtr,A1
+    MOVE.L  waitInput,D0
+    MOVEA.L _IntuitionBase,A6
+    JSR -600(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION TimedDisplayAlert(alertNumber : ULONG; string_ : pCHAR; height : ULONG; time : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  alertNumber,D0
+    MOVEA.L string_,A0
+    MOVE.L  height,D1
+    MOVEA.L time,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -822(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE UnlockIBase(ibLock : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L ibLock,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -420(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE UnlockPubScreen(name : pCHAR; screen : pScreen);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L name,A0
+    MOVEA.L screen,A1
+    MOVEA.L _IntuitionBase,A6
+    JSR -516(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE UnlockPubScreenList;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _IntuitionBase,A6
+    JSR -528(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION ViewAddress : pView;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _IntuitionBase,A6
+    JSR -294(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ViewPortAddress(window : pWindow) : pViewPort;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -300(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION WBenchToBack : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _IntuitionBase,A6
+    JSR -336(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION WBenchToFront : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L _IntuitionBase,A6
+    JSR -342(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION WindowLimits(window : pWindow; widthMin : LONGINT; heightMin : LONGINT; widthMax : ULONG; heightMax : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVE.L  widthMin,D0
+    MOVE.L  heightMin,D1
+    MOVE.L  widthMax,D2
+    MOVE.L  heightMax,D3
+    MOVEA.L _IntuitionBase,A6
+    JSR -318(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE WindowToBack(window : pWindow);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -306(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE WindowToFront(window : pWindow);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -312(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ZipWindow(window : pWindow);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L window,A0
+    MOVEA.L _IntuitionBase,A6
+    JSR -504(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+END. (* UNIT INTUITION *)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 39 - 0
packages/extra/amunits/units/keyboard.pas

@@ -0,0 +1,39 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{
+        Keyboard device command definitions
+}
+
+unit keyboard;
+
+INTERFACE
+
+uses exec;
+
+
+Const
+    KBD_READEVENT               = CMD_NONSTD + 0;
+    KBD_READMATRIX              = CMD_NONSTD + 1;
+    KBD_ADDRESETHANDLER         = CMD_NONSTD + 2;
+    KBD_REMRESETHANDLER         = CMD_NONSTD + 3;
+    KBD_RESETHANDLERDONE        = CMD_NONSTD + 4;
+
+IMPLEMENTATION
+
+end.
+
+

+ 157 - 0
packages/extra/amunits/units/keymap.pas

@@ -0,0 +1,157 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{
+        keymap.resource definitions and console.device key map definitions
+}
+
+unit keymap;
+
+INTERFACE
+
+uses exec, inputevent;
+
+Type
+
+    pKeyMap = ^tKeyMap;
+    tKeyMap = record
+        km_LoKeyMapTypes        : Pointer;
+        km_LoKeyMap             : Pointer;
+        km_LoCapsable           : Pointer;
+        km_LoRepeatable         : Pointer;
+        km_HiKeyMapTypes        : Pointer;
+        km_HiKeyMap             : Pointer;
+        km_HiCapsable           : Pointer;
+        km_HiRepeatable         : Pointer;
+    end;
+
+
+    pKeymapNode = ^tKeyMapNode;
+    tKeyMapNode = record
+        kn_Node         : tNode;         { including name of keymap }
+        kn_KeyMap       : tKeyMap;
+    end;
+
+{ the structure of keymap.resource }
+
+    pKeyMapResource = ^tKeyMapResource;
+    tKeyMapResource = record
+        kr_Node         : tNode;
+        kr_List         : tList;         { a list of KeyMapNodes }
+    end;
+
+
+Const
+
+{ Key Map Types }
+
+    KC_NOQUAL           = 0;
+    KC_VANILLA          = 7;    { note that SHIFT+ALT+CTRL is VANILLA }
+    KCB_SHIFT           = 0;
+    KCF_SHIFT           = $01;
+    KCB_ALT             = 1;
+    KCF_ALT             = $02;
+    KCB_CONTROL         = 2;
+    KCF_CONTROL         = $04;
+    KCB_DOWNUP          = 3;
+    KCF_DOWNUP          = $08;
+
+    KCB_DEAD            = 5;    { may be dead or modified by dead key:  }
+    KCF_DEAD            = $20;  {   use dead prefix bytes               }
+
+    KCB_STRING          = 6;
+    KCF_STRING          = $40;
+
+    KCB_NOP             = 7;
+    KCF_NOP             = $80;
+
+
+{ Dead Prefix Bytes }
+
+    DPB_MOD             = 0;
+    DPF_MOD             = $01;
+    DPB_DEAD            = 3;
+    DPF_DEAD            = $08;
+
+    DP_2DINDEXMASK      = $0f;  { mask for index for 1st of two dead keys }
+    DP_2DFACSHIFT       = 4;    { shift for factor for 1st of two dead keys }
+
+VAR KeymapBase : pLibrary;
+
+FUNCTION AskKeyMapDefault : pKeyMap;
+FUNCTION MapANSI(thestring : pCHAR; count : LONGINT; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : LONGINT;
+FUNCTION MapRawKey(event : pInputEvent; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : INTEGER;
+PROCEDURE SetKeyMapDefault(keyMap : pKeyMap);
+
+IMPLEMENTATION
+
+FUNCTION AskKeyMapDefault : pKeyMap;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L KeymapBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION MapANSI(thestring : pCHAR; count : LONGINT; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L thestring,A0
+    MOVE.L  count,D0
+    MOVEA.L buffer,A1
+    MOVE.L  length,D1
+    MOVEA.L keyMap,A2
+    MOVEA.L KeymapBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION MapRawKey(event : pInputEvent; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : INTEGER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L event,A0
+    MOVEA.L buffer,A1
+    MOVE.L  length,D1
+    MOVEA.L keyMap,A2
+    MOVEA.L KeymapBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE SetKeyMapDefault(keyMap : pKeyMap);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L keyMap,A0
+    MOVEA.L KeymapBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+END. (* UNIT KEYMAP *)
+
+
+

+ 531 - 0
packages/extra/amunits/units/layers.pas

@@ -0,0 +1,531 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+UNIT layers;
+
+INTERFACE
+USES exec, graphics, utility;
+
+const
+
+    LAYERSIMPLE         = 1;
+    LAYERSMART          = 2;
+    LAYERSUPER          = 4;
+    LAYERUPDATING       = $10;
+    LAYERBACKDROP       = $40;
+    LAYERREFRESH        = $80;
+    LAYER_CLIPRECTS_LOST = $100;        { during BeginUpdate }
+                                        { or during layerop }
+                                        { this happens if out of memory }
+    LMN_REGION          = -1;
+
+type
+ pLayer_Info = ^tLayer_Info;
+ tLayer_Info = record
+    top_layer           : pLayer;
+    check_lp            : pLayer;              { !! Private !! }
+    obs                 : pClipRect;
+    FreeClipRects       : pClipRect;              { !! Private !! }
+    PrivateReserve1,                            { !! Private !! }
+    PrivateReserve2     : Longint;              { !! Private !! }
+    Lock                : tSignalSemaphore;      { !! Private !! }
+    gs_Head             : tMinList;              { !! Private !! }
+    PrivateReserve3     : Integer;                 { !! Private !! }
+    PrivateReserve4     : Pointer;              { !! Private !! }
+    Flags               : WORD;
+    fatten_count        : Shortint;                 { !! Private !! }
+    LockLayersCount     : Shortint;                 { !! Private !! }
+    PrivateReserve5     : Integer;                 { !! Private !! }
+    BlankHook,                                  { !! Private !! }
+    LayerInfo_extra     : Pointer;              { !! Private !! }
+ end;
+
+const
+    NEWLAYERINFO_CALLED = 1;
+
+{
+ * LAYERS_NOBACKFILL is the value needed to get no backfill hook
+ * LAYERS_BACKFILL is the value needed to get the default backfill hook
+ }
+ LAYERS_NOBACKFILL      = 1;
+ LAYERS_BACKFILL        = 0;
+
+VAR LayersBase : pLibrary;
+
+FUNCTION BeginUpdate(l : pLayer) : LONGINT;
+FUNCTION BehindLayer(dummy : LONGINT; layer : pLayer) : LONGINT;
+FUNCTION CreateBehindHookLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; hook : pHook; bm2 : pBitMap) : pLayer;
+FUNCTION CreateBehindLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; bm2 : pBitMap) : pLayer;
+FUNCTION CreateUpfrontHookLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; hook : pHook; bm2 : pBitMap) : pLayer;
+FUNCTION CreateUpfrontLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; bm2 : pBitMap) : pLayer;
+FUNCTION DeleteLayer(dummy : LONGINT; layer : pLayer) : LONGINT;
+PROCEDURE DisposeLayerInfo(li : pLayer_Info);
+PROCEDURE DoHookClipRects(hook : pHook; rport : pRastPort; rect : pRectangle);
+PROCEDURE EndUpdate(layer : pLayer; flag : ULONG);
+FUNCTION FattenLayerInfo(li : pLayer_Info) : LONGINT;
+PROCEDURE InitLayers(li : pLayer_Info);
+FUNCTION InstallClipRegion(layer : pLayer; region : pRegion) : pRegion;
+FUNCTION InstallLayerHook(layer : pLayer; hook : pHook) : pHook;
+FUNCTION InstallLayerInfoHook(li : pLayer_Info; hook : pHook) : pHook;
+PROCEDURE LockLayer(dummy : LONGINT; layer : pLayer);
+PROCEDURE LockLayerInfo(li : pLayer_Info);
+PROCEDURE LockLayers(li : pLayer_Info);
+FUNCTION MoveLayer(dummy : LONGINT; layer : pLayer; dx : LONGINT; dy : LONGINT) : LONGINT;
+FUNCTION MoveLayerInFrontOf(layer_to_move : pLayer; other_layer : pLayer) : LONGINT;
+FUNCTION MoveSizeLayer(layer : pLayer; dx : LONGINT; dy : LONGINT; dw : LONGINT; dh : LONGINT) : LONGINT;
+FUNCTION NewLayerInfo : pLayer_Info;
+PROCEDURE ScrollLayer(dummy : LONGINT; layer : pLayer; dx : LONGINT; dy : LONGINT);
+FUNCTION SizeLayer(dummy : LONGINT; layer : pLayer; dx : LONGINT; dy : LONGINT) : LONGINT;
+PROCEDURE SortLayerCR(layer : pLayer; dx : LONGINT; dy : LONGINT);
+PROCEDURE SwapBitsRastPortClipRect(rp : pRastPort; cr : pClipRect);
+PROCEDURE ThinLayerInfo(li : pLayer_Info);
+PROCEDURE UnlockLayer(layer : pLayer);
+PROCEDURE UnlockLayerInfo(li : pLayer_Info);
+PROCEDURE UnlockLayers(li : pLayer_Info);
+FUNCTION UpfrontLayer(dummy : LONGINT; layer : pLayer) : LONGINT;
+FUNCTION WhichLayer(li : pLayer_Info; x : LONGINT; y : LONGINT) : pLayer;
+
+IMPLEMENTATION
+
+FUNCTION BeginUpdate(l : pLayer) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L l,A0
+    MOVEA.L LayersBase,A6
+    JSR -078(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION BehindLayer(dummy : LONGINT; layer : pLayer) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L dummy,A0
+    MOVEA.L layer,A1
+    MOVEA.L LayersBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CreateBehindHookLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; hook : pHook; bm2 : pBitMap) : pLayer;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L li,A0
+    MOVEA.L bm,A1
+    MOVE.L  x0,D0
+    MOVE.L  y0,D1
+    MOVE.L  x1,D2
+    MOVE.L  y1,D3
+    MOVE.L  flags,D4
+    MOVEA.L hook,A3
+    MOVEA.L bm2,A2
+    MOVEA.L LayersBase,A6
+    JSR -192(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CreateBehindLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; bm2 : pBitMap) : pLayer;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L li,A0
+    MOVEA.L bm,A1
+    MOVE.L  x0,D0
+    MOVE.L  y0,D1
+    MOVE.L  x1,D2
+    MOVE.L  y1,D3
+    MOVE.L  flags,D4
+    MOVEA.L bm2,A2
+    MOVEA.L LayersBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CreateUpfrontHookLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; hook : pHook; bm2 : pBitMap) : pLayer;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L li,A0
+    MOVEA.L bm,A1
+    MOVE.L  x0,D0
+    MOVE.L  y0,D1
+    MOVE.L  x1,D2
+    MOVE.L  y1,D3
+    MOVE.L  flags,D4
+    MOVEA.L hook,A3
+    MOVEA.L bm2,A2
+    MOVEA.L LayersBase,A6
+    JSR -186(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CreateUpfrontLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; bm2 : pBitMap) : pLayer;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L li,A0
+    MOVEA.L bm,A1
+    MOVE.L  x0,D0
+    MOVE.L  y0,D1
+    MOVE.L  x1,D2
+    MOVE.L  y1,D3
+    MOVE.L  flags,D4
+    MOVEA.L bm2,A2
+    MOVEA.L LayersBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION DeleteLayer(dummy : LONGINT; layer : pLayer) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L dummy,A0
+    MOVEA.L layer,A1
+    MOVEA.L LayersBase,A6
+    JSR -090(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE DisposeLayerInfo(li : pLayer_Info);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L li,A0
+    MOVEA.L LayersBase,A6
+    JSR -150(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE DoHookClipRects(hook : pHook; rport : pRastPort; rect : pRectangle);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L hook,A0
+    MOVEA.L rport,A1
+    MOVEA.L rect,A2
+    MOVEA.L LayersBase,A6
+    JSR -216(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE EndUpdate(layer : pLayer; flag : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L layer,A0
+    MOVE.L  flag,D0
+    MOVEA.L LayersBase,A6
+    JSR -084(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION FattenLayerInfo(li : pLayer_Info) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L li,A0
+    MOVEA.L LayersBase,A6
+    JSR -156(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE InitLayers(li : pLayer_Info);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L li,A0
+    MOVEA.L LayersBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION InstallClipRegion(layer : pLayer; region : pRegion) : pRegion;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L layer,A0
+    MOVEA.L region,A1
+    MOVEA.L LayersBase,A6
+    JSR -174(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION InstallLayerHook(layer : pLayer; hook : pHook) : pHook;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L layer,A0
+    MOVEA.L hook,A1
+    MOVEA.L LayersBase,A6
+    JSR -198(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION InstallLayerInfoHook(li : pLayer_Info; hook : pHook) : pHook;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L li,A0
+    MOVEA.L hook,A1
+    MOVEA.L LayersBase,A6
+    JSR -204(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE LockLayer(dummy : LONGINT; layer : pLayer);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L dummy,A0
+    MOVEA.L layer,A1
+    MOVEA.L LayersBase,A6
+    JSR -096(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE LockLayerInfo(li : pLayer_Info);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L li,A0
+    MOVEA.L LayersBase,A6
+    JSR -120(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE LockLayers(li : pLayer_Info);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L li,A0
+    MOVEA.L LayersBase,A6
+    JSR -108(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION MoveLayer(dummy : LONGINT; layer : pLayer; dx : LONGINT; dy : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L dummy,A0
+    MOVEA.L layer,A1
+    MOVE.L  dx,D0
+    MOVE.L  dy,D1
+    MOVEA.L LayersBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION MoveLayerInFrontOf(layer_to_move : pLayer; other_layer : pLayer) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L layer_to_move,A0
+    MOVEA.L other_layer,A1
+    MOVEA.L LayersBase,A6
+    JSR -168(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION MoveSizeLayer(layer : pLayer; dx : LONGINT; dy : LONGINT; dw : LONGINT; dh : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L layer,A0
+    MOVE.L  dx,D0
+    MOVE.L  dy,D1
+    MOVE.L  dw,D2
+    MOVE.L  dh,D3
+    MOVEA.L LayersBase,A6
+    JSR -180(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION NewLayerInfo : pLayer_Info;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L LayersBase,A6
+    JSR -144(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE ScrollLayer(dummy : LONGINT; layer : pLayer; dx : LONGINT; dy : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L dummy,A0
+    MOVEA.L layer,A1
+    MOVE.L  dx,D0
+    MOVE.L  dy,D1
+    MOVEA.L LayersBase,A6
+    JSR -072(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION SizeLayer(dummy : LONGINT; layer : pLayer; dx : LONGINT; dy : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L dummy,A0
+    MOVEA.L layer,A1
+    MOVE.L  dx,D0
+    MOVE.L  dy,D1
+    MOVEA.L LayersBase,A6
+    JSR -066(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE SortLayerCR(layer : pLayer; dx : LONGINT; dy : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L layer,A0
+    MOVE.L  dx,D0
+    MOVE.L  dy,D1
+    MOVEA.L LayersBase,A6
+    JSR -210(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE SwapBitsRastPortClipRect(rp : pRastPort; cr : pClipRect);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L rp,A0
+    MOVEA.L cr,A1
+    MOVEA.L LayersBase,A6
+    JSR -126(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE ThinLayerInfo(li : pLayer_Info);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L li,A0
+    MOVEA.L LayersBase,A6
+    JSR -162(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE UnlockLayer(layer : pLayer);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L layer,A0
+    MOVEA.L LayersBase,A6
+    JSR -102(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE UnlockLayerInfo(li : pLayer_Info);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L li,A0
+    MOVEA.L LayersBase,A6
+    JSR -138(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE UnlockLayers(li : pLayer_Info);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L li,A0
+    MOVEA.L LayersBase,A6
+    JSR -114(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION UpfrontLayer(dummy : LONGINT; layer : pLayer) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L dummy,A0
+    MOVEA.L layer,A1
+    MOVEA.L LayersBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION WhichLayer(li : pLayer_Info; x : LONGINT; y : LONGINT) : pLayer;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L li,A0
+    MOVE.L  x,D0
+    MOVE.L  y,D1
+    MOVEA.L LayersBase,A6
+    JSR -132(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT LAYERS *)

+ 628 - 0
packages/extra/amunits/units/locale.pas

@@ -0,0 +1,628 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+UNIT locale;
+
+INTERFACE
+USES exec, amigados, utility;
+
+const
+{ constants for GetLocaleStr() }
+ DAY_1          = 1;       { Sunday    }
+ DAY_2          = 2;       { Monday    }
+ DAY_3          = 3;       { Tuesday   }
+ DAY_4          = 4;       { Wednesday }
+ DAY_5          = 5;       { Thursday  }
+ DAY_6          = 6;       { Friday    }
+ DAY_7          = 7;       { Saturday  }
+
+ ABDAY_1        = 8 ;      { Sun }
+ ABDAY_2        = 9 ;      { Mon }
+ ABDAY_3        = 10;      { Tue }
+ ABDAY_4        = 11;      { Wed }
+ ABDAY_5        = 12;      { Thu }
+ ABDAY_6        = 13;      { Fri }
+ ABDAY_7        = 14;      { Sat }
+
+ MON_1          = 15;      { January   }
+ MON_2          = 16;      { February  }
+ MON_3          = 17;      { March     }
+ MON_4          = 18;      { April     }
+ MON_5          = 19;      { May       }
+ MON_6          = 20;      { June      }
+ MON_7          = 21;      { July      }
+ MON_8          = 22;      { August    }
+ MON_9          = 23;      { September }
+ MON_10         = 24;      { October   }
+ MON_11         = 25;      { November  }
+ MON_12         = 26;      { December  }
+
+ ABMON_1        = 27;      { Jan }
+ ABMON_2        = 28;      { Feb }
+ ABMON_3        = 29;      { Mar }
+ ABMON_4        = 30;      { Apr }
+ ABMON_5        = 31;      { May }
+ ABMON_6        = 32;      { Jun }
+ ABMON_7        = 33;      { Jul }
+ ABMON_8        = 34;      { Aug }
+ ABMON_9        = 35;      { Sep }
+ ABMON_10       = 36;      { Oct }
+ ABMON_11       = 37;      { Nov }
+ ABMON_12       = 38;      { Dec }
+
+ YESSTR         = 39;      { affirmative response for yes/no queries }
+ NOSTR          = 40;      { negative response for yes/no queries    }
+
+ AM_STR         = 41;      { AM }
+ PM_STR         = 42;      { PM }
+
+ SOFTHYPHEN     = 43;      { soft hyphenation }
+ HARDHYPHEN     = 44;      { hard hyphenation }
+
+ OPENQUOTE      = 45;      { start of quoted block }
+ CLOSEQUOTE     = 46;      { end of quoted block   }
+
+ YESTERDAYSTR   = 47;      { Yesterday }
+ TODAYSTR       = 48;      { Today     }
+ TOMORROWSTR    = 49;      { Tomorrow  }
+ FUTURESTR      = 50;      { Future    }
+
+ MAXSTRMSG      = 51;      { current number of defined strings }
+
+
+{***************************************************************************}
+
+Type
+{ OpenLibrary("locale.library",0) returns a pointer to this structure }
+ pLocaleBase = ^tLocaleBase;
+ tLocaleBase = record
+    lb_LibNode      : tLibrary;
+    lb_SysPatches   : Boolean;   { TRUE if locale installed its patches }
+ end;
+
+{***************************************************************************}
+
+Type
+{ This structure must only be allocated by locale.library and is READ-ONLY! }
+ pLocale = ^tLocale;
+ tLocale = record
+    loc_LocaleName,                         { locale's name               }
+    loc_LanguageName    : STRPTR;           { language of this locale     }
+    loc_PrefLanguages   : Array[0..9] of STRPTR;    { preferred languages }
+    loc_Flags           : ULONG;            { always 0 for now            }
+
+    loc_CodeSet,                            { always 0 for now            }
+    loc_CountryCode,                        { user's country code         }
+    loc_TelephoneCode,                      { country's telephone code    }
+    loc_GMTOffset       : ULONG;            { minutes from GMT            }
+    loc_MeasuringSystem,                    { what measuring system?      }
+    loc_CalendarType    : Byte;             { what calendar type?         }
+    loc_Reserved0       : Array[0..1] of Byte;
+
+    loc_DateTimeFormat,                     { regular date & time format  }
+    loc_DateFormat,                         { date format by itself       }
+    loc_TimeFormat,                         { time format by itself       }
+
+    loc_ShortDateTimeFormat,                { short date & time format    }
+    loc_ShortDateFormat,                    { short date format by itself }
+    loc_ShortTimeFormat,                    { short time format by itself }
+
+    { for numeric values }
+    loc_DecimalPoint,                       { character before the decimals }
+    loc_GroupSeparator,                     { separates groups of digits    }
+    loc_FracGroupSeparator : STRPTR;        { separates groups of digits    }
+    loc_Grouping,                           { size of each group            }
+    loc_FracGrouping    : Pointer;          { size of each group            }
+
+    { for monetary values }
+    loc_MonDecimalPoint,
+    loc_MonGroupSeparator,
+    loc_MonFracGroupSeparator : STRPTR;
+    loc_MonGrouping,
+    loc_MonFracGrouping : Pointer;
+    loc_MonFracDigits,                      { digits after the decimal point   }
+    loc_MonIntFracDigits : Byte;            { for international representation }
+    loc_Reserved1       : Array[0..1] of Byte;
+
+    { for currency symbols }
+    loc_MonCS,                              { currency symbol              }
+    loc_MonSmallCS,                         { symbol for small amounts     }
+    loc_MonIntCS        : STRPTR;           { internationl (ISO 4217) code }
+
+    { for positive monetary values }
+    loc_MonPositiveSign : STRPTR;           { indicate positive money value   }
+    loc_MonPositiveSpaceSep,                { determine if separated by space }
+    loc_MonPositiveSignPos,                 { position of positive sign       }
+    loc_MonPositiveCSPos,                   { position of currency symbol     }
+    loc_Reserved2       : Byte;
+
+    { for negative monetary values }
+    loc_MonNegativeSign : STRPTR;           { indicate negative money value   }
+    loc_MonNegativeSpaceSep,                { determine if separated by space }
+    loc_MonNegativeSignPos,                 { position of negative sign       }
+    loc_MonNegativeCSPos,                   { position of currency symbol     }
+    loc_Reserved3       : Byte;
+ end;
+
+const
+{ constants for Locale.loc_MeasuringSystem }
+ MS_ISO         = 0;       { international metric system }
+ MS_AMERICAN    = 1;       { american system             }
+ MS_IMPERIAL    = 2;       { imperial system             }
+ MS_BRITISH     = 3;       { british system              }
+
+{ constants for Locale.loc_CalendarType }
+ CT_7SUN        = 0;       { 7 days a week, Sunday is the first day    }
+ CT_7MON        = 1;       { 7 days a week, Monday is the first day    }
+ CT_7TUE        = 2;       { 7 days a week, Tuesday is the first day   }
+ CT_7WED        = 3;       { 7 days a week, Wednesday is the first day }
+ CT_7THU        = 4;       { 7 days a week, Thursday is the first day  }
+ CT_7FRI        = 5;       { 7 days a week, Friday is the first day    }
+ CT_7SAT        = 6;       { 7 days a week, Saturday is the first day  }
+
+{ constants for Locale.loc_MonPositiveSpaceSep and Locale.loc_MonNegativeSpaceSep }
+ SS_NOSPACE     = 0;       { cur. symbol is NOT separated from value with a space }
+ SS_SPACE       = 1;       { cur. symbol IS separated from value with a space     }
+
+{ constants for Locale.loc_MonPositiveSignPos and Locale.loc_MonNegativeSignPos }
+ SP_PARENS      = 0;       { () surround the quantity and currency_symbol   }
+ SP_PREC_ALL    = 1;       { sign string comes before amount and symbol     }
+ SP_SUCC_ALL    = 2;       { sign string comes after amount and symbol      }
+ SP_PREC_CURR   = 3;       { sign string comes right before currency symbol }
+ SP_SUCC_CURR   = 4;       { sign string comes right after currency symbol  }
+
+{ constants for Locale.loc_MonPositiveCSPos and Locale.loc_MonNegativeCSPos }
+ CSP_PRECEDES   = 0;  { currency symbol comes before value }
+ CSP_SUCCEEDS   = 1;  { currency symbol comes after value  }
+
+{ elements of the byte arrays pointed to by:
+ *   Locale.loc_Grouping
+ *   Locale.loc_FracGrouping
+ *   Locale.loc_MonGrouping
+ *   Locale.loc_MonFracGrouping
+ * are interpreted as follows:
+ *
+ *    255     indicates that no further grouping is to be performed
+ *    0       indicates that the previous element is to be repeatedly used
+ *            for the remainder of the digits
+ *    <other> the number of digits that comprises the current group
+ }
+
+
+{***************************************************************************}
+
+
+{ Tags for OpenCatalog() }
+ OC_TagBase         = (TAG_USER + $90000);
+ OC_BuiltInLanguage = OC_TagBase+1;   { language of built-in strings    }
+ OC_BuiltInCodeSet  = OC_TagBase+2;   { code set of built-in strings    }
+ OC_Version         = OC_TagBase+3;   { catalog version number required }
+ OC_Language        = OC_TagBase+4;   { preferred language of catalog   }
+
+
+{***************************************************************************}
+
+
+{ Comparison types for StrnCmp() }
+ SC_ASCII    = 0;
+ SC_COLLATE1 = 1;
+ SC_COLLATE2 = 2;
+
+
+{***************************************************************************}
+
+Type
+{ This structure must only be allocated by locale.library and is READ-ONLY! }
+ pCatalog = ^tCatalog;
+ tCatalog = record
+    cat_Link    : tNode;        { for internal linkage    }
+    cat_Pad     : WORD;         { to longword align       }
+    cat_Language: STRPTR;       { language of the catalog }
+    cat_CodeSet : ULONG;        { currently always 0      }
+    cat_Version : WORD;         { version of the catalog  }
+    cat_Revision: WORD;         { revision of the catalog }
+ end;
+
+{***************************************************************************}
+
+{ --- functions in V38 or higher (Release 2.1) --- }
+
+VAR LocaleBase : pLocaleBase;
+
+PROCEDURE CloseCatalog(catalog : pCatalog);
+PROCEDURE CloseLocale(locale : pLocale);
+FUNCTION ConvToLower(locale : pLocale; character : ULONG) : ULONG;
+FUNCTION ConvToUpper(locale : pLocale; character : ULONG) : ULONG;
+PROCEDURE FormatDate(locale : pLocale; fmtTemplate : pCHAR; date : pDateStamp; putCharFunc : pHook);
+FUNCTION FormatString(locale : pLocale; fmtTemplate : pCHAR; dataStream : POINTER; putCharFunc : pHook) : POINTER;
+FUNCTION GetCatalogStr(catalog : pCatalog; stringNum : LONGINT; defaultString : pCHAR) : pCHAR;
+FUNCTION GetLocaleStr(locale : pLocale; stringNum : ULONG) : pCHAR;
+FUNCTION IsAlNum(locale : pLocale; character : ULONG) : BOOLEAN;
+FUNCTION IsAlpha(locale : pLocale; character : ULONG) : BOOLEAN;
+FUNCTION IsCntrl(locale : pLocale; character : ULONG) : BOOLEAN;
+FUNCTION IsDigit(locale : pLocale; character : ULONG) : BOOLEAN;
+FUNCTION IsGraph(locale : pLocale; character : ULONG) : BOOLEAN;
+FUNCTION IsLower(locale : pLocale; character : ULONG) : BOOLEAN;
+FUNCTION IsPrint(locale : pLocale; character : ULONG) : BOOLEAN;
+FUNCTION IsPunct(locale : pLocale; character : ULONG) : BOOLEAN;
+FUNCTION IsSpace(locale : pLocale; character : ULONG) : BOOLEAN;
+FUNCTION IsUpper(locale : pLocale; character : ULONG) : BOOLEAN;
+FUNCTION IsXDigit(locale : pLocale; character : ULONG) : BOOLEAN;
+FUNCTION OpenCatalogA(locale : pLocale; name : pCHAR; tags : pTagItem) : pCatalog;
+FUNCTION OpenLocale(name : pCHAR) : pLocale;
+FUNCTION ParseDate(locale : pLocale; date : pDateStamp; fmtTemplate : pCHAR; getCharFunc : pHook) : BOOLEAN;
+FUNCTION StrConvert(locale : pLocale; string1 : pCHAR; buffer : POINTER; bufferSize : ULONG; typ : ULONG) : ULONG;
+FUNCTION StrnCmp(locale : pLocale; string1 : pCHAR; string2 : pCHAR; length : LONGINT; typ : ULONG) : LONGINT;
+
+IMPLEMENTATION
+
+PROCEDURE CloseCatalog(catalog : pCatalog);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L catalog,A0
+    MOVEA.L LocaleBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE CloseLocale(locale : pLocale);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVEA.L LocaleBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION ConvToLower(locale : pLocale; character : ULONG) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVE.L  character,D0
+    MOVEA.L LocaleBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ConvToUpper(locale : pLocale; character : ULONG) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVE.L  character,D0
+    MOVEA.L LocaleBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE FormatDate(locale : pLocale; fmtTemplate : pCHAR; date : pDateStamp; putCharFunc : pHook);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVEA.L fmtTemplate,A1
+    MOVEA.L date,A2
+    MOVEA.L putCharFunc,A3
+    MOVEA.L LocaleBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION FormatString(locale : pLocale; fmtTemplate : pCHAR; dataStream : POINTER; putCharFunc : pHook) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVEA.L fmtTemplate,A1
+    MOVEA.L dataStream,A2
+    MOVEA.L putCharFunc,A3
+    MOVEA.L LocaleBase,A6
+    JSR -066(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetCatalogStr(catalog : pCatalog; stringNum : LONGINT; defaultString : pCHAR) : pCHAR;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L catalog,A0
+    MOVE.L  stringNum,D0
+    MOVEA.L defaultString,A1
+    MOVEA.L LocaleBase,A6
+    JSR -072(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetLocaleStr(locale : pLocale; stringNum : ULONG) : pCHAR;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVE.L  stringNum,D0
+    MOVEA.L LocaleBase,A6
+    JSR -078(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION IsAlNum(locale : pLocale; character : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVE.L  character,D0
+    MOVEA.L LocaleBase,A6
+    JSR -084(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION IsAlpha(locale : pLocale; character : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVE.L  character,D0
+    MOVEA.L LocaleBase,A6
+    JSR -090(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION IsCntrl(locale : pLocale; character : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVE.L  character,D0
+    MOVEA.L LocaleBase,A6
+    JSR -096(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION IsDigit(locale : pLocale; character : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVE.L  character,D0
+    MOVEA.L LocaleBase,A6
+    JSR -102(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION IsGraph(locale : pLocale; character : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVE.L  character,D0
+    MOVEA.L LocaleBase,A6
+    JSR -108(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION IsLower(locale : pLocale; character : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVE.L  character,D0
+    MOVEA.L LocaleBase,A6
+    JSR -114(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION IsPrint(locale : pLocale; character : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVE.L  character,D0
+    MOVEA.L LocaleBase,A6
+    JSR -120(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION IsPunct(locale : pLocale; character : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVE.L  character,D0
+    MOVEA.L LocaleBase,A6
+    JSR -126(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION IsSpace(locale : pLocale; character : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVE.L  character,D0
+    MOVEA.L LocaleBase,A6
+    JSR -132(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION IsUpper(locale : pLocale; character : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVE.L  character,D0
+    MOVEA.L LocaleBase,A6
+    JSR -138(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION IsXDigit(locale : pLocale; character : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVE.L  character,D0
+    MOVEA.L LocaleBase,A6
+    JSR -144(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION OpenCatalogA(locale : pLocale; name : pCHAR; tags : pTagItem) : pCatalog;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVEA.L name,A1
+    MOVEA.L tags,A2
+    MOVEA.L LocaleBase,A6
+    JSR -150(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION OpenLocale(name : pCHAR) : pLocale;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L name,A0
+    MOVEA.L LocaleBase,A6
+    JSR -156(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ParseDate(locale : pLocale; date : pDateStamp; fmtTemplate : pCHAR; getCharFunc : pHook) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVEA.L date,A1
+    MOVEA.L fmtTemplate,A2
+    MOVEA.L getCharFunc,A3
+    MOVEA.L LocaleBase,A6
+    JSR -162(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION StrConvert(locale : pLocale; string1 : pCHAR; buffer : POINTER; bufferSize : ULONG; typ : ULONG) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVEA.L string1,A1
+    MOVEA.L buffer,A2
+    MOVE.L  bufferSize,D0
+    MOVE.L  typ,D1
+    MOVEA.L LocaleBase,A6
+    JSR -174(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION StrnCmp(locale : pLocale; string1 : pCHAR; string2 : pCHAR; length : LONGINT; typ : ULONG) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L locale,A0
+    MOVEA.L string1,A1
+    MOVEA.L string2,A2
+    MOVE.L  length,D0
+    MOVE.L  typ,D1
+    MOVEA.L LocaleBase,A6
+    JSR -180(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT LOCALE *)

+ 446 - 0
packages/extra/amunits/units/lowlevel.pas

@@ -0,0 +1,446 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+UNIT lowlevel;
+
+INTERFACE
+USES exec, utility, timer;
+
+Type
+{ structure for use with QueryKeys() }
+ pKeyQuery = ^tKeyQuery;
+ tKeyQuery = record
+    kq_KeyCode  : WORD;
+    kq_Pressed  : Boolean;
+ end;
+
+{***************************************************************************}
+
+Const
+{ bits in the return value of GetKey() }
+ LLKB_LSHIFT     = 16;
+ LLKB_RSHIFT     = 17;
+ LLKB_CAPSLOCK   = 18;
+ LLKB_CONTROL    = 19;
+ LLKB_LALT       = 20;
+ LLKB_RALT       = 21;
+ LLKB_LAMIGA     = 22;
+ LLKB_RAMIGA     = 23;
+
+ LLKF_LSHIFT     = 65536;
+ LLKF_RSHIFT     = 131072;
+ LLKF_CAPSLOCK   = 262144;
+ LLKF_CONTROL    = 524288;
+ LLKF_LALT       = 1048576;
+ LLKF_RALT       = 2097152;
+ LLKF_LAMIGA     = 4194304;
+ LLKF_RAMIGA     = 8388608;
+
+{***************************************************************************}
+
+
+{ Tags for SetJoyPortAttrs() }
+ SJA_Dummy        = (TAG_USER+$c00100);
+ SJA_Type         = (SJA_Dummy+1); { force type to mouse, joy, game cntrlr }
+ SJA_Reinitialize = (SJA_Dummy+2); { free potgo bits, reset to autosense   }
+
+{ Controller types for SJA_Type tag }
+ SJA_TYPE_AUTOSENSE = 0;
+ SJA_TYPE_GAMECTLR  = 1;
+ SJA_TYPE_MOUSE     = 2;
+ SJA_TYPE_JOYSTK    = 3;
+
+
+{***************************************************************************}
+
+
+{ ReadJoyPort() return value definitions }
+
+{ Port types }
+ JP_TYPE_NOTAVAIL  = 0;          { port data unavailable    }
+ JP_TYPE_GAMECTLR  = 268435456;  { port has game controller }
+ JP_TYPE_MOUSE     = 536870912;  { port has mouse           }
+ JP_TYPE_JOYSTK    = 805306368;  { port has joystick        }
+ JP_TYPE_UNKNOWN   = 1073741824; { port has unknown device  }
+ JP_TYPE_MASK      = -268435456; { controller type          }
+
+{ Button types, valid for all types except JP_TYPE_NOTAVAIL }
+ JPB_BUTTON_BLUE    = 23;     { Blue - Stop; Right Mouse                }
+ JPB_BUTTON_RED     = 22;     { Red - Select; Left Mouse; Joystick Fire }
+ JPB_BUTTON_YELLOW  = 21;     { Yellow - Repeat                         }
+ JPB_BUTTON_GREEN   = 20;     { Green - Shuffle                         }
+ JPB_BUTTON_FORWARD = 19;     { Charcoal - Forward              }
+ JPB_BUTTON_REVERSE = 18;     { Charcoal - Reverse              }
+ JPB_BUTTON_PLAY    = 17;     { Grey - Play/Pause; Middle Mouse         }
+ JPF_BUTTON_BLUE    = 8388608;
+ JPF_BUTTON_RED     = 4194304;
+ JPF_BUTTON_YELLOW  = 2097152;
+ JPF_BUTTON_GREEN   = 1048576;
+ JPF_BUTTON_FORWARD = 524288;
+ JPF_BUTTON_REVERSE = 262144;
+ JPF_BUTTON_PLAY    = 131072;
+ JP_BUTTON_MASK     = JPF_BUTTON_BLUE OR JPF_BUTTON_RED OR JPF_BUTTON_YELLOW OR JPF_BUTTON_GREEN OR JPF_BUTTON_FORWARD OR JPF_BUTTON_REVERSE OR JPF_BUTTON_PLAY;
+
+{ Direction types, valid for JP_TYPE_GAMECTLR and JP_TYPE_JOYSTK }
+ JPB_JOY_UP        = 3;
+ JPB_JOY_DOWN      = 2;
+ JPB_JOY_LEFT      = 1;
+ JPB_JOY_RIGHT     = 0;
+ JPF_JOY_UP        = 8;
+ JPF_JOY_DOWN      = 4;
+ JPF_JOY_LEFT      = 2;
+ JPF_JOY_RIGHT     = 1;
+ JP_DIRECTION_MASK = JPF_JOY_UP OR JPF_JOY_DOWN OR JPF_JOY_LEFT OR JPF_JOY_RIGHT;
+
+{ Mouse position reports, valid for JP_TYPE_MOUSE }
+ JP_MHORZ_MASK     = 255;        { horzizontal position }
+ JP_MVERT_MASK     = 65280;      { vertical position    }
+ JP_MOUSE_MASK     = JP_MHORZ_MASK OR JP_MVERT_MASK;
+
+{ Obsolete ReadJoyPort() definitions, here for source code compatibility only.
+ * Please do NOT use in new code.
+ }
+ JPB_BTN1  = JPB_BUTTON_BLUE   ;
+ JPF_BTN1  = JPF_BUTTON_BLUE   ;
+ JPB_BTN2  = JPB_BUTTON_RED    ;
+ JPF_BTN2  = JPF_BUTTON_RED    ;
+ JPB_BTN3  = JPB_BUTTON_YELLOW ;
+ JPF_BTN3  = JPF_BUTTON_YELLOW ;
+ JPB_BTN4  = JPB_BUTTON_GREEN  ;
+ JPF_BTN4  = JPF_BUTTON_GREEN  ;
+ JPB_BTN5  = JPB_BUTTON_FORWARD;
+ JPF_BTN5  = JPF_BUTTON_FORWARD;
+ JPB_BTN6  = JPB_BUTTON_REVERSE;
+ JPF_BTN6  = JPF_BUTTON_REVERSE;
+ JPB_BTN7  = JPB_BUTTON_PLAY   ;
+ JPF_BTN7  = JPF_BUTTON_PLAY   ;
+ JPB_UP    = JPB_JOY_UP        ;
+ JPF_UP    = JPF_JOY_UP        ;
+ JPB_DOWN  = JPB_JOY_DOWN      ;
+ JPF_DOWN  = JPF_JOY_DOWN      ;
+ JPB_LEFT  = JPB_JOY_LEFT      ;
+ JPF_LEFT  = JPF_JOY_LEFT      ;
+ JPB_RIGHT = JPB_JOY_RIGHT     ;
+ JPF_RIGHT = JPF_JOY_RIGHT     ;
+
+
+{***************************************************************************}
+
+
+{ Tags for SystemControl() }
+ SCON_Dummy         = (TAG_USER+$00C00000);
+ SCON_TakeOverSys   = (SCON_Dummy+0);
+ SCON_KillReq       = (SCON_Dummy+1);
+ SCON_CDReboot      = (SCON_Dummy+2);
+ SCON_StopInput     = (SCON_Dummy+3);
+ SCON_AddCreateKeys = (SCON_Dummy+4);
+ SCON_RemCreateKeys = (SCON_Dummy+5);
+
+{ Reboot control values for use with SCON_CDReboot tag }
+ CDReboot_On        =     1;
+ CDReboot_Off       =     0;
+ CDReboot_Default   =     2;
+
+
+{***************************************************************************}
+
+
+{ Rawkey codes returned when using SCON_AddCreateKeys with SystemControl() }
+
+ RAWKEY_PORT0_BUTTON_BLUE      =  $72;
+ RAWKEY_PORT0_BUTTON_RED       =  $78;
+ RAWKEY_PORT0_BUTTON_YELLOW    =  $77;
+ RAWKEY_PORT0_BUTTON_GREEN     =  $76;
+ RAWKEY_PORT0_BUTTON_FORWARD   =  $75;
+ RAWKEY_PORT0_BUTTON_REVERSE   =  $74;
+ RAWKEY_PORT0_BUTTON_PLAY      =  $73;
+ RAWKEY_PORT0_JOY_UP           =  $79;
+ RAWKEY_PORT0_JOY_DOWN         =  $7A;
+ RAWKEY_PORT0_JOY_LEFT         =  $7C;
+ RAWKEY_PORT0_JOY_RIGHT        =  $7B;
+
+ RAWKEY_PORT1_BUTTON_BLUE      =  $172;
+ RAWKEY_PORT1_BUTTON_RED       =  $178;
+ RAWKEY_PORT1_BUTTON_YELLOW    =  $177;
+ RAWKEY_PORT1_BUTTON_GREEN     =  $176;
+ RAWKEY_PORT1_BUTTON_FORWARD   =  $175;
+ RAWKEY_PORT1_BUTTON_REVERSE   =  $174;
+ RAWKEY_PORT1_BUTTON_PLAY      =  $173;
+ RAWKEY_PORT1_JOY_UP           =  $179;
+ RAWKEY_PORT1_JOY_DOWN         =  $17A;
+ RAWKEY_PORT1_JOY_LEFT         =  $17C;
+ RAWKEY_PORT1_JOY_RIGHT        =  $17B;
+
+ RAWKEY_PORT2_BUTTON_BLUE      =  $272;
+ RAWKEY_PORT2_BUTTON_RED       =  $278;
+ RAWKEY_PORT2_BUTTON_YELLOW    =  $277;
+ RAWKEY_PORT2_BUTTON_GREEN     =  $276;
+ RAWKEY_PORT2_BUTTON_FORWARD   =  $275;
+ RAWKEY_PORT2_BUTTON_REVERSE   =  $274;
+ RAWKEY_PORT2_BUTTON_PLAY      =  $273;
+ RAWKEY_PORT2_JOY_UP           =  $279;
+ RAWKEY_PORT2_JOY_DOWN         =  $27A;
+ RAWKEY_PORT2_JOY_LEFT         =  $27C;
+ RAWKEY_PORT2_JOY_RIGHT        =  $27B;
+
+ RAWKEY_PORT3_BUTTON_BLUE      =  $372;
+ RAWKEY_PORT3_BUTTON_RED       =  $378;
+ RAWKEY_PORT3_BUTTON_YELLOW    =  $377;
+ RAWKEY_PORT3_BUTTON_GREEN     =  $376;
+ RAWKEY_PORT3_BUTTON_FORWARD   =  $375;
+ RAWKEY_PORT3_BUTTON_REVERSE   =  $374;
+ RAWKEY_PORT3_BUTTON_PLAY      =  $373;
+ RAWKEY_PORT3_JOY_UP           =  $379;
+ RAWKEY_PORT3_JOY_DOWN         =  $37A;
+ RAWKEY_PORT3_JOY_LEFT         =  $37C;
+ RAWKEY_PORT3_JOY_RIGHT        =  $37B;
+
+
+{***************************************************************************}
+
+
+{ Return values for GetLanguageSelection() }
+ LANG_UNKNOWN    = 0 ;
+ LANG_AMERICAN   = 1 ;      { American English }
+ LANG_ENGLISH    = 2 ;      { British English  }
+ LANG_GERMAN     = 3 ;
+ LANG_FRENCH     = 4 ;
+ LANG_SPANISH    = 5 ;
+ LANG_ITALIAN    = 6 ;
+ LANG_PORTUGUESE = 7 ;
+ LANG_DANISH     = 8 ;
+ LANG_DUTCH      = 9 ;
+ LANG_NORWEGIAN  = 10;
+ LANG_FINNISH    = 11;
+ LANG_SWEDISH    = 12;
+ LANG_JAPANESE   = 13;
+ LANG_CHINESE    = 14;
+ LANG_ARABIC     = 15;
+ LANG_GREEK      = 16;
+ LANG_HEBREW     = 17;
+ LANG_KOREAN     = 18;
+
+
+{***************************************************************************}
+
+
+{ --- functions in V40 or higher (Release 3.1) --- }
+
+VAR LowLevelBase : pLibrary;
+
+FUNCTION AddKBInt(intRoutine : POINTER; intData : POINTER) : POINTER;
+FUNCTION AddTimerInt(intRoutine : POINTER; intData : POINTER) : POINTER;
+FUNCTION AddVBlankInt(intRoutine : POINTER; intData : POINTER) : POINTER;
+FUNCTION ElapsedTime(context : pEClockVal) : ULONG;
+FUNCTION GetKey : ULONG;
+FUNCTION GetLanguageSelection : BYTE;
+PROCEDURE QueryKeys(queryArray : pKeyQuery; arraySize : ULONG);
+FUNCTION ReadJoyPort(port : ULONG) : ULONG;
+PROCEDURE RemKBInt(intHandle : POINTER);
+PROCEDURE RemTimerInt(intHandle : POINTER);
+PROCEDURE RemVBlankInt(intHandle : POINTER);
+FUNCTION SetJoyPortAttrsA(portNumber : ULONG; tagList : pTagItem) : BOOLEAN;
+PROCEDURE StartTimerInt(intHandle : POINTER; timeInterval : ULONG; continuous : LONGINT);
+PROCEDURE StopTimerInt(intHandle : POINTER);
+FUNCTION SystemControlA(tagList : pTagItem) : ULONG;
+
+IMPLEMENTATION
+
+FUNCTION AddKBInt(intRoutine : POINTER; intData : POINTER) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L intRoutine,A0
+    MOVEA.L intData,A1
+    MOVEA.L LowLevelBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AddTimerInt(intRoutine : POINTER; intData : POINTER) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L intRoutine,A0
+    MOVEA.L intData,A1
+    MOVEA.L LowLevelBase,A6
+    JSR -078(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AddVBlankInt(intRoutine : POINTER; intData : POINTER) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L intRoutine,A0
+    MOVEA.L intData,A1
+    MOVEA.L LowLevelBase,A6
+    JSR -108(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION ElapsedTime(context : pEClockVal) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L context,A0
+    MOVEA.L LowLevelBase,A6
+    JSR -102(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetKey : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L LowLevelBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetLanguageSelection : BYTE;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L LowLevelBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE QueryKeys(queryArray : pKeyQuery; arraySize : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L queryArray,A0
+    MOVE.L  arraySize,D1
+    MOVEA.L LowLevelBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION ReadJoyPort(port : ULONG) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  port,D0
+    MOVEA.L LowLevelBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE RemKBInt(intHandle : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L intHandle,A1
+    MOVEA.L LowLevelBase,A6
+    JSR -066(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE RemTimerInt(intHandle : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L intHandle,A1
+    MOVEA.L LowLevelBase,A6
+    JSR -084(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE RemVBlankInt(intHandle : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L intHandle,A1
+    MOVEA.L LowLevelBase,A6
+    JSR -114(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION SetJoyPortAttrsA(portNumber : ULONG; tagList : pTagItem) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  portNumber,D0
+    MOVEA.L tagList,A1
+    MOVEA.L LowLevelBase,A6
+    JSR -132(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE StartTimerInt(intHandle : POINTER; timeInterval : ULONG; continuous : LONGINT);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L intHandle,A1
+    MOVE.L  timeInterval,D0
+    MOVE.L  continuous,D1
+    MOVEA.L LowLevelBase,A6
+    JSR -096(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE StopTimerInt(intHandle : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L intHandle,A1
+    MOVEA.L LowLevelBase,A6
+    JSR -090(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION SystemControlA(tagList : pTagItem) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L tagList,A1
+    MOVEA.L LowLevelBase,A6
+    JSR -072(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT LOWLEVEL *)
+
+

+ 178 - 0
packages/extra/amunits/units/nonvolatile.pas

@@ -0,0 +1,178 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+UNIT nonvolatile;
+
+INTERFACE
+USES exec;
+
+
+Type
+ pNVInfo = ^tNVInfo;
+ tNVInfo = record
+    nvi_MaxStorage,
+    nvi_FreeStorage : ULONG;
+ end;
+
+{***************************************************************************}
+
+
+ pNVEntry = ^tNVEntry;
+ tNVEntry = record
+    nve_Node        : tMinNode;
+    nve_Name        : STRPTR;
+    nve_Size,
+    nve_Protection  : ULONG;
+ end;
+
+const
+{ bit definitions for mask in SetNVProtection().  Also used for
+ * NVEntry.nve_Protection.
+ }
+ NVEB_DELETE  = 0 ;
+ NVEB_APPNAME = 31;
+
+ NVEF_DELETE  = 1;
+ NVEF_APPNAME = -2147483648;
+
+
+{***************************************************************************}
+
+
+{ errors from StoreNV() }
+ NVERR_BADNAME   = 1;
+ NVERR_WRITEPROT = 2;
+ NVERR_FAIL      = 3;
+ NVERR_FATAL     = 4;
+
+
+
+{ --- functions in V40 or higher (Release 3.1) --- }
+
+VAR NVBase : pLibrary;
+
+FUNCTION DeleteNV(appName : pCHAR; itemName : pCHAR; killRequesters : LONGINT) : BOOLEAN;
+PROCEDURE FreeNVData(data : POINTER);
+FUNCTION GetCopyNV(appName : pCHAR; itemName : pCHAR; killRequesters : LONGINT) : POINTER;
+FUNCTION GetNVInfo(killRequesters : LONGINT) : pNVInfo;
+FUNCTION GetNVList(appName : pCHAR; killRequesters : LONGINT) : pMinList;
+FUNCTION SetNVProtection(appName : pCHAR; itemName : pCHAR; mask : LONGINT; killRequesters : LONGINT) : BOOLEAN;
+FUNCTION StoreNV(appName : pCHAR; itemName : pCHAR; data : POINTER; length : ULONG; killRequesters : LONGINT) : WORD;
+
+IMPLEMENTATION
+
+FUNCTION DeleteNV(appName : pCHAR; itemName : pCHAR; killRequesters : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L appName,A0
+    MOVEA.L itemName,A1
+    MOVE.L  killRequesters,D1
+    MOVEA.L NVBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE FreeNVData(data : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L data,A0
+    MOVEA.L NVBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION GetCopyNV(appName : pCHAR; itemName : pCHAR; killRequesters : LONGINT) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L appName,A0
+    MOVEA.L itemName,A1
+    MOVE.L  killRequesters,D1
+    MOVEA.L NVBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetNVInfo(killRequesters : LONGINT) : pNVInfo;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  killRequesters,D1
+    MOVEA.L NVBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetNVList(appName : pCHAR; killRequesters : LONGINT) : pMinList;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L appName,A0
+    MOVE.L  killRequesters,D1
+    MOVEA.L NVBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetNVProtection(appName : pCHAR; itemName : pCHAR; mask : LONGINT; killRequesters : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L appName,A0
+    MOVEA.L itemName,A1
+    MOVE.L  mask,D2
+    MOVE.L  killRequesters,D1
+    MOVEA.L NVBase,A6
+    JSR -066(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION StoreNV(appName : pCHAR; itemName : pCHAR; data : POINTER; length : ULONG; killRequesters : LONGINT) : WORD;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L appName,A0
+    MOVEA.L itemName,A1
+    MOVEA.L data,A2
+    MOVE.L  length,D0
+    MOVE.L  killRequesters,D1
+    MOVEA.L NVBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT NONVOLATILE *)

+ 116 - 0
packages/extra/amunits/units/parallel.pas

@@ -0,0 +1,116 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{
+        external declarations for Parallel Port Driver
+}
+
+unit parallel;
+
+INTERFACE
+
+uses exec;
+
+
+Type
+
+    pIOPArray = ^tIOPArray;
+    tIOPArray = record
+        PTermArray0     : ULONG;
+        PTermArray1     : ULONG;
+    end;
+
+
+{****************************************************************}
+{ CAUTION !!  IF YOU ACCESS the parallel.device, you MUST (!!!!) use
+   an IOExtPar-sized structure or you may overlay innocent memory !! }
+{****************************************************************}
+ 
+    pIOExtPar = ^tIOExtPar;
+    tIOExtPar = record
+        IOPar           : tIOStdReq;
+
+{     STRUCT    MsgNode
+*   0   APTR     Succ
+*   4   APTR     Pred
+*   8   UBYTE    Type
+*   9   UBYTE    Pri
+*   A   APTR     Name
+*   E   APTR     ReplyPort
+*  12   UWORD    MNLength
+*     STRUCT   IOExt
+*  14   APTR     io_Device
+*  18   APTR     io_Unit
+*  1C   UWORD    io_Command
+*  1E   UBYTE    io_Flags
+*  1F   UBYTE    io_Error
+*     STRUCT   IOStdExt
+*  20   ULONG    io_Actual
+*  24   ULONG    io_Length
+*  28   APTR     io_Data
+*  2C   ULONG    io_Offset
+*  30 }
+        io_PExtFlags    : ULONG;      { (not used) flag extension area }
+        io_Status       : Byte;         { status of parallel port and registers }
+        io_ParFlags     : Byte;         { see PARFLAGS bit definitions below }
+        io_PTermArray   : tIOPArray;     { termination character array }
+    end;
+
+Const
+
+    PARB_SHARED         = 5;    { ParFlags non-exclusive access bit }
+    PARF_SHARED         = 32;   {     "     non-exclusive access mask }
+    PARB_RAD_BOOGIE     = 3;    {     "     (not yet implemented) }
+    PARF_RAD_BOOGIE     = 8;    {     "     (not yet implemented) }
+    PARB_EOFMODE        = 1;    {     "     EOF mode enabled bit }
+    PARF_EOFMODE        = 2;    {     "     EOF mode enabled mask }
+    IOPARB_QUEUED       = 6;    { IO_FLAGS rqst-queued bit }
+    IOPARF_QUEUED       = 64;   {     "     rqst-queued mask }
+    IOPARB_ABORT        = 5;    {     "     rqst-aborted bit }
+    IOPARF_ABORT        = 32;   {     "     rqst-aborted mask }
+    IOPARB_ACTIVE       = 4;    {     "     rqst-qued-or-current bit }
+    IOPARF_ACTIVE       = 16;   {     "     rqst-qued-or-current mask }
+    IOPTB_RWDIR         = 3;    { IO_STATUS read=0,write=1 bit }
+    IOPTF_RWDIR         = 8;    {     "     read=0,write=1 mask }
+    IOPTB_PARSEL        = 2;    {     "     printer selected on the A1000 }
+    IOPTF_PARSEL        = 4;    { printer selected & serial "Ring Indicator"
+                                  on the A500 & A2000.  Be careful when
+                                  making cables }
+    IOPTB_PAPEROUT      = 1;    {     "     paper out bit }
+    IOPTF_PAPEROUT      = 2;    {     "     paper out mask }
+    IOPTB_PARBUSY       = 0;    {     "     printer in busy toggle bit }
+    IOPTF_PARBUSY       = 1;    {     "     printer in busy toggle mask }
+
+{ Note: previous versions of this include files had bits 0 and 2 swapped }
+
+    PARALLELNAME        : PChar = 'parallel.device';
+
+    PDCMD_QUERY         = CMD_NONSTD;
+    PDCMD_SETPARAMS     = CMD_NONSTD + 1;
+
+    ParErr_DevBusy      = 1;
+    ParErr_BufTooBig    = 2;
+    ParErr_InvParam     = 3;
+    ParErr_LineErr      = 4;
+    ParErr_NotOpen      = 5;
+    ParErr_PortReset    = 6;
+    ParErr_InitErr      = 7;
+
+IMPLEMENTATION
+
+end.
+
+

+ 695 - 0
packages/extra/amunits/units/prefs.pas

@@ -0,0 +1,695 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit prefs;
+
+INTERFACE
+uses exec, iffparse, graphics, timer, intuition;
+
+
+{ Font }
+{***************************************************************************}
+
+const
+ ID_FONT = 1179602516;
+
+
+ FONTNAMESIZE = 128;
+
+type
+ pFontPrefs = ^tFontPrefs;
+ tFontPrefs = record
+    fp_Reserved     : Array[0..2] of Longint;
+    fp_Reserved2    : WORD;
+    fp_Type         : WORD;
+    fp_FrontPen,
+    fp_BackPen,
+    fp_DrawMode     : Byte;
+    fp_TextAttr     : tTextAttr;
+    fp_Name         : Array[0..FONTNAMESIZE-1] of Char;
+ end;
+
+const
+{ constants for FontPrefs.fp_Type }
+ FP_WBFONT     = 0;
+ FP_SYSFONT    = 1;
+ FP_SCREENFONT = 2;
+
+
+{***************************************************************************}
+
+{ IControl }
+{***************************************************************************}
+
+const
+ ID_ICTL = 1229149260;
+
+Type
+ pIControlPrefs = ^tIControlPrefs;
+ tIControlPrefs = record
+    ic_Reserved     : Array[0..3] Of Longint;       { System reserved              }
+    ic_TimeOut      : WORD;                         { Verify timeout               }
+    ic_MetaDrag     : Integer;                      { Meta drag mouse event        }
+    ic_Flags        : ULONG;                        { IControl flags (see below)   }
+    ic_WBtoFront,                                   { CKey: WB to front            }
+    ic_FrontToBack,                                 { CKey: front screen to back   }
+    ic_ReqTrue,                                     { CKey: Requester TRUE         }
+    ic_ReqFalse     : Byte;                         { CKey: Requester FALSE        }
+ end;
+
+const
+{ flags for IControlPrefs.ic_Flags }
+ ICB_COERCE_COLORS = 0;
+ ICB_COERCE_LACE   = 1;
+ ICB_STRGAD_FILTER = 2;
+ ICB_MENUSNAP      = 3;
+ ICB_MODEPROMOTE   = 4;
+
+ ICF_COERCE_COLORS = 1;
+ ICF_COERCE_LACE   = 2;
+ ICF_STRGAD_FILTER = 4;
+ ICF_MENUSNAP      = 8;
+ ICF_MODEPROMOTE   = 16;
+
+
+{***************************************************************************}
+
+  {      File format for input preferences     }
+
+
+const
+ ID_INPT = 1229869140;
+
+Type
+ pInputPrefs = ^tInputPrefs;
+ tInputPrefs = record
+    ip_Keymap      : Array[0..15] of Char;
+    ip_PointerTicks : WORD;
+    ip_DoubleClick,
+    ip_KeyRptDelay,
+    ip_KeyRptSpeed : tTimeVal;
+    ip_MouseAccel  : Integer;
+ end;
+
+ {      File format for locale preferences }
+
+const
+ ID_LCLE = 1279478853;
+ ID_CTRY = 1129599577;
+
+
+Type
+ pCountryPrefs = ^tCountryPrefs;
+ tCountryPrefs = record
+    cp_Reserved     : Array[0..3] of ULONG;
+    cp_CountryCode  : ULONG;
+    cp_TelephoneCode: ULONG;
+    cp_MeasuringSystem : Byte;
+
+    cp_DateTimeFormat  : Array[0..79] of Char;
+    cp_DateFormat      : Array[0..39] of Char;
+    cp_TimeFormat      : Array[0..39] of Char;
+
+    cp_ShortDateTimeFormat  : Array[0..79] of Char;
+    cp_ShortDateFormat      : Array[0..39] of Char;
+    cp_ShortTimeFormat      : Array[0..39] of Char;
+
+    { for numeric values }
+    cp_DecimalPoint,
+    cp_GroupSeparator,
+    cp_FracGroupSeparator   : Array[0..9] of Char;
+    cp_Grouping,
+    cp_FracGrouping         : Array[0..9] of Byte;
+
+    { for monetary values }
+    cp_MonDecimalPoint,
+    cp_MonGroupSeparator,
+    cp_MonFracGroupSeparator   : Array[0..9] of Char;
+    cp_MonGrouping,
+    cp_MonFracGrouping         : Array[0..9] of Byte;
+    cp_MonFracDigits,
+    cp_MonIntFracDigits        : Byte;
+
+    { for currency symbols }
+    cp_MonCS,
+    cp_MonSmallCS,
+    cp_MonIntCS                : Array[0..9] of Char;
+
+    { for positive monetary values }
+    cp_MonPositiveSign         : Array[0..9] of Char;
+    cp_MonPositiveSpaceSep,
+    cp_MonPositiveSignPos,
+    cp_MonPositiveCSPos        : Byte;
+
+    { for negative monetary values }
+    cp_MonNegativeSign         : Array[0..9] of Char;
+    cp_MonNegativeSpaceSep,
+    cp_MonNegativeSignPos,
+    cp_MonNegativeCSPos        : Byte;
+
+    cp_CalendarType            : Byte;
+ end;
+
+ pLocalePrefs = ^tLocalePrefs;
+ tLocalePrefs = record
+    lp_Reserved         : Array[0..3] of ULONG;
+    lp_CountryName      : Array[0..31] of Char;
+    lp_PreferredLanguages : Array[0..9] of Array[0..29] of Char;
+    lp_GMTOffset        : Longint;
+    lp_Flags            : ULONG;
+    lp_CountryData      : tCountryPrefs;
+ end;
+
+   {   File format for overscan preferences  }
+
+const
+    ID_OSCN = 1330856782;
+    OSCAN_MAGIC = $FEDCBA89;
+
+
+Type
+ pOverscanPrefs = ^tOverscanPrefs;
+ tOverscanPrefs = record
+    os_Reserved,
+    os_Magic         : ULONG;
+    os_HStart,
+    os_HStop,
+    os_VStart,
+    os_VStop         : WORD;
+    os_DisplayID     : ULONG;
+    os_ViewPos,
+    os_Text          : tPoint;
+    os_Standard      : tRectangle;
+ end;
+
+{ os_HStart, os_HStop, os_VStart, os_VStop can only be looked at if
+ * os_Magic equals OSCAN_MAGIC. If os_Magic is set to any other value,
+ * these four fields are undefined
+ }
+
+
+{***************************************************************************}
+
+  {      File format for palette preferences    }
+
+
+const
+    ID_PALT = 1346456660;
+
+Type
+ pPalettePrefs = ^tPalettePrefs;
+ tPalettePrefs = record
+    pap_Reserved     : Array[0..3] of Longint;    { System reserved                }
+    pap_4ColorPens   : Array[1..32] of WORD;
+    pap_8ColorPens   : Array[1..32] of WORD;
+    pap_Colors       : Array[1..32] of tColorSpec;     { Used as full 16-bit RGB values }
+ end;
+
+
+{***************************************************************************}
+
+
+ {      File format for pointer preferences }
+
+const
+      ID_PNTR = 1347310674;
+
+
+Type
+ pPointerPrefs = ^tPointerPrefs;
+ tPointerPrefs = record
+    pp_Reserved : Array[0..3] of ULONG;
+    pp_Which,                             { 0=NORMAL, 1=BUSY }
+    pp_Size,                              { see <intuition/pointerclass.h> }
+    pp_Width,                             { Width in pixels }
+    pp_Height,                            { Height in pixels }
+    pp_Depth,                             { Depth }
+    pp_YSize,                             { YSize }
+    pp_X, pp_Y  : WORD;                   { Hotspot }
+
+    { Color Table:  numEntries = (1 << pp_Depth) - 1 }
+
+    { Data follows }
+ end;
+
+{***************************************************************************}
+
+Const
+{ constants for PointerPrefs.pp_Which }
+ WBP_NORMAL    =  0;
+ WBP_BUSY      =  1;
+
+{***************************************************************************}
+
+Type
+ pRGBTable = ^tRGBTable;
+ tRGBTable = record
+    t_Red,
+    t_Green,
+    t_Blue  : Byte;
+ end;
+
+{***************************************************************************}
+
+  {    File format for preferences header }
+
+const
+ ID_PREF = 1347568966;
+ ID_PRHD = 1347569732;
+
+Type
+ pPrefHeader = ^tPrefHeader;
+ tPrefHeader = record
+    ph_Version,             { version of following data }
+    ph_Type     : Byte;     { type of following data    }
+    ph_Flags    : ULONG;    { always set to 0 for now   }
+ end;
+
+  {     File format for graphics printer preferences }
+
+const
+ ID_PGFX = 1346848344;
+
+Type
+ pPrinterGfxPrefs = ^tPrinterGfxPrefs;
+ tPrinterGfxPrefs = record
+    pg_Reserved     : Array[0..3] of Longint;
+    pg_Aspect,
+    pg_Shade,
+    pg_Image        : Word
+    pg_Threshold    : Integer;
+    pg_ColorCorrect,
+    pg_Dimensions,
+    pg_Dithering    : Byte;
+    pg_GraphicFlags : WORD;
+    pg_PrintDensity : Byte;              { Print density 1 - 7 }
+    pg_PrintMaxWidth,
+    pg_PrintMaxHeight : WORD;
+    pg_PrintXOffset,
+    pg_PrintYOffset : Byte;
+ end;
+
+const
+{ constants for PrinterGfxPrefs.pg_Aspect }
+ PA_HORIZONTAL = 0;
+ PA_VERTICAL   = 1;
+
+{ constants for PrinterGfxPrefs.pg_Shade }
+ PS_BW          = 0;
+ PS_GREYSCALE   = 1;
+ PS_COLOR       = 2;
+ PS_GREY_SCALE2 = 3;
+
+{ constants for PrinterGfxPrefs.pg_Image }
+ PI_POSITIVE = 0;
+ PI_NEGATIVE = 1;
+
+{ flags for PrinterGfxPrefs.pg_ColorCorrect }
+ PCCB_RED   = 1;    { color correct red shades   }
+ PCCB_GREEN = 2;    { color correct green shades }
+ PCCB_BLUE  = 3;    { color correct blue shades  }
+
+ PCCF_RED   = 1;
+ PCCF_GREEN = 2;
+ PCCF_BLUE  = 4;
+
+{ constants for PrinterGfxPrefs.pg_Dimensions }
+ PD_IGNORE   = 0;  { ignore max width/height settings }
+ PD_BOUNDED  = 1;  { use max w/h as boundaries        }
+ PD_ABSOLUTE = 2;  { use max w/h as absolutes         }
+ PD_PIXEL    = 3;  { use max w/h as prt pixels        }
+ PD_MULTIPLY = 4;  { use max w/h as multipliers       }
+
+{ constants for PrinterGfxPrefs.pg_Dithering }
+ PD_ORDERED     = 0;  { ordered dithering }
+ PD_HALFTONE    = 1;  { halftone dithering        }
+ PD_FLOYD       = 2;  { Floyd-Steinberg dithering }
+
+{ flags for PrinterGfxPrefs.pg_GraphicsFlags }
+ PGFB_CENTER_IMAGE      = 0;       { center image on paper }
+ PGFB_INTEGER_SCALING   = 1;       { force integer scaling }
+ PGFB_ANTI_ALIAS        = 2;       { anti-alias image      }
+
+ PGFF_CENTER_IMAGE      = 1;
+ PGFF_INTEGER_SCALING   = 2;
+ PGFF_ANTI_ALIAS        = 4;
+
+
+ {      File format for PostScript printer preferences   }
+
+const
+ ID_PSPD = 1347637316;
+
+Type
+ pPrinterPSPrefs = ^tPrinterPSPrefs;
+ tPrinterPSPrefs = record
+    ps_Reserved     : Array[0..3] of Longint;               { System reserved }
+
+    { Global printing attributes }
+    ps_DriverMode,
+    ps_PaperFormat  : Byte;
+    ps_Reserved1    : Array[0..1] of Byte;
+    ps_Copies,
+    ps_PaperWidth,
+    ps_PaperHeight,
+    ps_HorizontalDPI,
+    ps_VerticalDPI  : Longint;
+
+    { Text Options }
+    ps_Font,
+    ps_Pitch,
+    ps_Orientation,
+    ps_Tab          : Byte;
+    ps_Reserved2    : Array[0..7] of Byte;
+
+    { Text Dimensions }
+    ps_LeftMargin,
+    ps_RightMargin,
+    ps_TopMargin,
+    ps_BottomMargin,
+    ps_FontPointSize,
+    ps_Leading      : Longint;
+    ps_Reserved3    : Array[0..7] of Byte;
+
+    { Graphics Options }
+    ps_LeftEdge,
+    ps_TopEdge,
+    ps_Width,
+    ps_Height       : Longint;
+    ps_Image,
+    ps_Shading,
+    ps_Dithering    : Byte;
+    ps_Reserved4    : Array[0..8] of Byte;
+
+    { Graphics Scaling }
+    ps_Aspect,
+    ps_ScalingType,
+    ps_Reserved5,
+    ps_Centering    : Byte;
+    ps_Reserved6    : Array[0..7] of byte;
+ end;
+
+const
+{ All measurements are in Millipoints which is 1/1000 of a point, or
+ * in other words 1/72000 of an inch
+ }
+
+{ constants for PrinterPSPrefs.ps_DriverMode }
+ DM_POSTSCRIPT  = 0;
+ DM_PASSTHROUGH = 1;
+
+{ constants for PrinterPSPrefs.ps_PaperFormat }
+ PF_USLETTER = 0;
+ PF_USLEGAL  = 1;
+ PF_A4       = 2;
+ PF_CUSTOM   = 3;
+
+{ constants for PrinterPSPrefs.ps_Font }
+ FONT_COURIER      = 0;
+ FONT_TIMES        = 1;
+ FONT_HELVETICA    = 2;
+ FONT_HELV_NARROW  = 3;
+ FONT_AVANTGARDE   = 4;
+ FONT_BOOKMAN      = 5;
+ FONT_NEWCENT      = 6;
+ FONT_PALATINO     = 7;
+ FONT_ZAPFCHANCERY = 8;
+
+{ constants for PrinterPSPrefs.ps_Pitch }
+ PITCH_NORMAL     = 0;
+ PITCH_COMPRESSED = 1;
+ PITCH_EXPANDED   = 2;
+
+{ constants for PrinterPSPrefs.ps_Orientation }
+ ORIENT_PORTRAIT  = 0;
+ ORIENT_LANDSCAPE = 1;
+
+{ constants for PrinterPSPrefs.ps_Tab }
+ TAB_4     = 0;
+ TAB_8     = 1;
+ TAB_QUART = 2;
+ TAB_HALF  = 3;
+ TAB_INCH  = 4;
+
+{ constants for PrinterPSPrefs.ps_Image }
+ IM_POSITIVE = 0;
+ IM_NEGATIVE = 1;
+
+{ constants for PrinterPSPrefs.ps_Shading }
+ SHAD_BW        = 0;
+ SHAD_GREYSCALE = 1;
+ SHAD_COLOR     = 2;
+
+{ constants for PrinterPSPrefs.ps_Dithering }
+ DITH_DEFAULT = 0;
+ DITH_DOTTY   = 1;
+ DITH_VERT    = 2;
+ DITH_HORIZ   = 3;
+ DITH_DIAG    = 4;
+
+{ constants for PrinterPSPrefs.ps_Aspect }
+ ASP_HORIZ = 0;
+ ASP_VERT  = 1;
+
+{ constants for PrinterPSPrefs.ps_ScalingType }
+ ST_ASPECT_ASIS    = 0;
+ ST_ASPECT_WIDE    = 1;
+ ST_ASPECT_TALL    = 2;
+ ST_ASPECT_BOTH    = 3;
+ ST_FITS_WIDE      = 4;
+ ST_FITS_TALL      = 5;
+ ST_FITS_BOTH      = 6;
+
+{ constants for PrinterPSPrefs.ps_Centering }
+ CENT_NONE  = 0;
+ CENT_HORIZ = 1;
+ CENT_VERT  = 2;
+ CENT_BOTH  = 3;
+
+
+   {   File format for text printer preferences }
+
+const
+ ID_PTXT = 1347704916;
+ ID_PUNT = 1347767892;
+
+
+ DRIVERNAMESIZE = 30;               { Filename size     }
+ DEVICENAMESIZE = 32;               { .device name size }
+
+Type
+ pPrinterTxtPrefs = ^tPrinterTxtPrefs;
+ tPrinterTxtPrefs = record
+    pt_Reserved     : Array[0..3] of Longint;               { System reserved            }
+    pt_Driver       : Array[0..DRIVERNAMESIZE-1] of Char;   { printer driver filename    }
+    pt_Port         : Byte;                                 { printer port connection    }
+
+    pt_PaperType,
+    pt_PaperSize,
+    pt_PaperLength,               { Paper length in # of lines }
+
+    pt_Pitch,
+    pt_Spacing,
+    pt_LeftMargin,                { Left margin                }
+    pt_RightMargin,               { Right margin       }
+    pt_Quality      : WORD;
+ end;
+
+const
+{ constants for PrinterTxtPrefs.pt_Port }
+ PP_PARALLEL = 0;
+ PP_SERIAL   = 1;
+
+{ constants for PrinterTxtPrefs.pt_PaperType }
+ PT_FANFOLD  = 0;
+ PT_SINGLE   = 1;
+
+{ constants for PrinterTxtPrefs.pt_PaperSize }
+ PS_US_LETTER   = 0 ;
+ PS_US_LEGAL    = 1 ;
+ PS_N_TRACTOR   = 2 ;
+ PS_W_TRACTOR   = 3 ;
+ PS_CUSTOM      = 4 ;
+ PS_EURO_A0     = 5 ;              { European size A0: 841 x 1189 }
+ PS_EURO_A1     = 6 ;              { European size A1: 594 x 841  }
+ PS_EURO_A2     = 7 ;              { European size A2: 420 x 594  }
+ PS_EURO_A3     = 8 ;              { European size A3: 297 x 420  }
+ PS_EURO_A4     = 9 ;              { European size A4: 210 x 297  }
+ PS_EURO_A5     = 10;              { European size A5: 148 x 210  }
+ PS_EURO_A6     = 11;              { European size A6: 105 x 148  }
+ PS_EURO_A7     = 12;              { European size A7: 74 x 105   }
+ PS_EURO_A8     = 13;              { European size A8: 52 x 74    }
+
+{ constants for PrinterTxtPrefs.pt_PrintPitch }
+ PP_PICA  = 0;
+ PP_ELITE = 1;
+ PP_FINE  = 2;
+
+{ constants for PrinterTxtPrefs.pt_PrintSpacing }
+ PS_SIX_LPI   = 0;
+ PS_EIGHT_LPI = 1;
+
+{ constants for PrinterTxtPrefs.pt_PrintQuality }
+ PQ_DRAFT  = 0;
+ PQ_LETTER = 1;
+
+Type
+ pPrinterUnitPrefs = ^tPrinterUnitPrefs;
+ tPrinterUnitPrefs = record
+    pu_Reserved         : Array[0..3] of Longint;              { System reserved              }
+    pu_UnitNum          : Longint;                             { Unit number for OpenDevice() }
+    pu_OpenDeviceFlags  : ULONG;                               { Flags for OpenDevice()       }
+    pu_DeviceName       : Array[0..DEVICENAMESIZE-1] of Char;  { Name for OpenDevice()        }
+ end;
+
+  {     File format for screen mode preferences }
+
+const
+ ID_SCRM = 1396920909;
+
+
+Type
+ pScreenModePrefs = ^tScreenModePrefs;
+ tScreenModePrefs = record
+    smp_Reserved        : Array[0..3] of ULONG;
+    smp_DisplayID       : ULONG;
+    smp_Width,
+    smp_Height,
+    smp_Depth,
+    smp_Control         : Word;
+ end;
+
+const
+{ flags for ScreenModePrefs.smp_Control }
+ SMB_AUTOSCROLL = 1;
+
+ SMF_AUTOSCROLL = 1;
+
+ {      File format for serial preferences }
+
+const
+ ID_SERL = 1397051980;
+
+
+Type
+ pSerialPrefs = ^tSerialPrefs;
+ tSerialPrefs = record
+    sp_Reserved     : Array[0..2] of Longint;               { System reserved                  }
+    sp_Unit0Map,                  { What unit 0 really refers to     }
+    sp_BaudRate,                  { Baud rate                        }
+
+    sp_InputBuffer,               { Input buffer: 0 - 65536          }
+    sp_OutputBuffer : ULONG;      { Future: Output: 0 - 65536        }
+
+    sp_InputHandshake,            { Input handshaking                }
+    sp_OutputHandshake,           { Future: Output handshaking       }
+
+    sp_Parity,                    { Parity                           }
+    sp_BitsPerChar,               { I/O bits per character           }
+    sp_StopBits     : Byte;       { Stop bits                        }
+ end;
+
+const
+{ constants for SerialPrefs.sp_Parity }
+ PARITY_NONE     = 0;
+ PARITY_EVEN     = 1;
+ PARITY_ODD      = 2;
+ PARITY_MARK     = 3;               { Future enhancement }
+ PARITY_SPACE    = 4;               { Future enhancement }
+
+{ constants for SerialPrefs.sp_Input/OutputHandshaking }
+ HSHAKE_XON      = 0;
+ HSHAKE_RTS      = 1;
+ HSHAKE_NONE     = 2;
+
+    {   File format for sound preferences  }
+
+const
+ ID_SOND = 1397706308;
+
+Type
+ pSoundPrefs = ^tSoundPrefs;
+ tSoundPrefs = record
+    sop_Reserved        : Array[0..3] of Longint;            { System reserved            }
+    sop_DisplayQueue,               { Flash the display?         }
+    sop_AudioQueue      : Boolean;  { Make some sound?           }
+    sop_AudioType,                  { Type of sound, see below   }
+    sop_AudioVolume,                { Volume of sound, 0..64     }
+    sop_AudioPeriod,                { Period of sound, 127..2500 }
+    sop_AudioDuration   : WORD;     { Length of simple beep      }
+    sop_AudioFileName   : Array[0..255] of Char;     { Filename of 8SVX file      }
+ end;
+
+const
+{ constants for SoundPrefs.sop_AudioType }
+ SPTYPE_BEEP    = 0;       { simple beep sound }
+ SPTYPE_SAMPLE  = 1;       { sampled sound     }
+
+   {   File format for wbpattern preferences  }
+
+const
+ ID_PTRN = 1347703374;
+
+Type
+ pWBPatternPrefs = ^tWBPatternPrefs;
+ tWBPatternPrefs = record
+    wbp_Reserved    : Array[0..3] of ULONG;
+    wbp_Which,                     { Which pattern is it }
+    wbp_Flags       : WORD;
+    wbp_Revision,                  { Must be set to zero }
+    wbp_Depth       : Byte;        { Depth of pattern }
+    wbp_DataLength  : WORD;        { Length of following data }
+ end;
+
+const
+{ constants for WBPatternPrefs.wbp_Which }
+ WBP_ROOT       = 0;
+ WBP_DRAWER     = 1;
+ WBP_SCREEN     = 2;
+
+{ wbp_Flags values }
+ WBPF_PATTERN   = $0001;
+    { Data contains a pattern }
+
+ WBPF_NOREMAP   = $0010;
+    { Don't remap the pattern }
+
+{***************************************************************************}
+
+ MAXDEPTH       = 3;       {  Max depth supported (8 colors) }
+ DEFPATDEPTH    = 2;       {  Depth of default patterns }
+
+{  Pattern width & height: }
+ PAT_WIDTH      = 16;
+ PAT_HEIGHT     = 16;
+
+IMPLEMENTATION
+
+END.
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 165 - 0
packages/extra/amunits/units/prtbase.pas

@@ -0,0 +1,165 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{
+        printer device data definition
+}
+
+unit prtbase;
+
+INTERFACE
+
+uses exec, parallel, serial, amigados, intuition, timer;
+
+
+Type
+
+    pDeviceData = ^tDeviceData;
+    tDeviceData = record
+        dd_Device       : tLibrary;     { standard library node }
+        dd_Segment      : Pointer;      { A0 when initialized }
+        dd_ExecBase     : Pointer;      { A6 for exec }
+        dd_CmdVectors   : Pointer;      { command table for device commands }
+        dd_CmdBytes     : Pointer;      { bytes describing which command queue }
+        dd_NumCommands  : Word;         { the number of commands supported }
+    end;
+
+Const
+
+    P_OLDSTKSIZE        = $0800;        { stack size for child task }
+    P_STKSIZE           = $1000;
+    P_BUFSIZE           = 256;          { size of internal buffers for text i/o }
+    P_SAFESIZE          = 128;          { safety margin for text output buffer }
+
+Type
+       pPrinterData = ^tPrinterData;
+       tPrinterData = record
+            pd_Device : tDeviceData;
+            pd_Unit : tMsgPort;
+            pd_PrinterSegment : BPTR;
+            pd_PrinterType : WORD;
+            pd_SegmentData : Pointer;
+            pd_PrintBuf : Pointer;
+            pd_PWrite : Pointer;
+            pd_PBothReady : Pointer;
+            pd_ior0 : record
+                case longint of
+                   0 : ( pd_p0 : tIOExtPar );
+                   1 : ( pd_s0 : tIOExtSer );
+                end;
+            pd_ior1 : record
+                case longint of
+                   0 : ( pd_p1 : tIOExtPar );
+                   1 : ( pd_s1 : tIOExtSer );
+                end;
+            pd_TIOR : tTimeRequest;
+            pd_IORPort : tMsgPort;
+            pd_TC : tTask;
+            pd_OldStk : array[0..(P_OLDSTKSIZE)-1] of BYTE;
+            pd_Flags : BYTE;
+            pd_pad : BYTE;
+            pd_Preferences : tPreferences;
+            pd_PWaitEnabled : BYTE;
+            pd_Flags1 : BYTE;
+            pd_Stk : array[0..(P_STKSIZE)-1] of BYTE;
+         end;
+
+Const
+
+{ Printer Class }
+
+    PPCB_GFX            = 0;            { graphics (bit position) }
+    PPCF_GFX            = 1;            { graphics (and/or flag) }
+    PPCB_COLOR          = 1;            { color (bit position) }
+    PPCF_COLOR          = 2;            { color (and/or flag) }
+
+    PPC_BWALPHA         = 0;            { black&white alphanumerics }
+    PPC_BWGFX           = 1;            { black&white graphics }
+    PPC_COLORALPHA      = 2;            { color alphanumerics }
+    PPC_COLORGFX        = 3;            { color graphics }
+
+{ Color Class }
+
+    PCC_BW              = 1;            { black&white only }
+    PCC_YMC             = 2;            { yellow/magenta/cyan only }
+    PCC_YMC_BW          = 3;            { yellow/magenta/cyan or black&white }
+    PCC_YMCB            = 4;            { yellow/magenta/cyan/black }
+    PCC_4COLOR          = 4;            { a flag for YMCB and BGRW }
+    PCC_ADDITIVE        = 8;            { not ymcb but blue/green/red/white }
+    PCC_WB              = 9;            { black&white only, 0 == BLACK }
+    PCC_BGR             = 10;           { blue/green/red }
+    PCC_BGR_WB          = 11;           { blue/green/red or black&white }
+    PCC_BGRW            = 12;           { blue/green/red/white }
+
+{
+        The picture must be scanned once for each color component, as the
+        printer can only define one color at a time.  ie. If 'PCC_YMC' then
+        first pass sends all 'Y' info to printer, second pass sends all 'M'
+        info, and third pass sends all C info to printer.  The CalComp
+        PlotMaster is an example of this type of printer.
+}
+
+    PCC_MULTI_PASS      = $10;          { see explanation above }
+
+Type
+
+    pPrinterExtendedData = ^tPrinterExtendedData;
+    tPrinterExtendedData = record
+        ped_PrinterName : STRPTR;       { printer name, null terminated }
+        ped_Init        : Pointer;      { called after LoadSeg }
+        ped_Expunge     : Pointer;      { called before UnLoadSeg }
+        ped_Open        : Pointer;      { called at OpenDevice }
+        ped_Close       : Pointer;      { called at CloseDevice }
+        ped_PrinterClass : Byte;        { printer class }
+        ped_ColorClass  : Byte;         { color class }
+        ped_MaxColumns  : Byte;         { number of print columns available }
+        ped_NumCharSets : Byte;         { number of character sets }
+        ped_NumRows     : Word;         { number of 'pins' in print head }
+        ped_MaxXDots    : ULONG;        { number of dots max in a raster dump }
+        ped_MaxYDots    : ULONG;        { number of dots max in a raster dump }
+        ped_XDotsInch   : Word;         { horizontal dot density }
+        ped_YDotsInch   : Word;         { vertical dot density }
+        ped_Commands    : Pointer;      { printer text command table }
+        ped_DoSpecial   : Pointer;      { special command handler }
+        ped_Render      : Pointer;      { raster render function }
+        ped_TimeoutSecs : Longint;      { good write timeout }
+
+        { the following only exists if the segment version is >= 33 }
+
+        ped_8BitChars   : Pointer;      { conv. strings for the extended font }
+        ped_PrintMode   : Longint;      { set if text printed, otherwise 0 }
+
+        { the following only exists if the segment version is >= 34 }
+        { ptr to conversion function for all chars }
+
+        ped_ConvFunc    : Pointer;
+    end;
+
+
+    pPrinterSegment = ^tprinterSegment;
+    tPrinterSegment = record
+        ps_NextSegment  : ULONG;        { (actually a BPTR) }
+        ps_runAlert     : ULONG;        { MOVEQ #0,D0 : RTS }
+        ps_Version      : Word;         { segment version }
+        ps_Revision     : Word;         { segment revision }
+        ps_PED          : tPrinterExtendedData;  { printer extended data }
+    end;
+
+IMPLEMENTATION
+
+end.
+
+

+ 91 - 0
packages/extra/amunits/units/prtgfx.pas

@@ -0,0 +1,91 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit prtgfx;
+
+INTERFACE
+
+uses exec;
+Const
+
+    PCMYELLOW           = 0;            { byte index for yellow }
+    PCMMAGENTA          = 1;            { byte index for magenta }
+    PCMCYAN             = 2;            { byte index for cyan }
+    PCMBLACK            = 3;            { byte index for black }
+    PCMBLUE             = PCMYELLOW;    { byte index for blue }
+    PCMGREEN            = PCMMAGENTA;   { byte index for green }
+    PCMRED              = PCMCYAN;      { byte index for red }
+    PCMWHITE            = PCMBLACK;     { byte index for white }
+
+Type
+
+    pColorEntry = ^tColorEntry;
+    tcolorEntry = record
+        colorLong       : ULONG;      { quick access to all of YMCB }
+        colorByte       : Array [0..3] of Byte; { 1 entry for each of YMCB }
+        colorSByte      : Array [0..3] of Shortint; { ditto (except signed) }
+    end;
+
+    pPrtInfo = ^tPrtInfo;
+    tPrtInfo = record { printer info }
+        pi_render       : Pointer;      { PRIVATE - DO NOT USE! }
+        pi_rp           : Pointer;      { PRIVATE - DO NOT USE! (RastPortPtr)}
+        pi_temprp       : Pointer;      { PRIVATE - DO NOT USE! (RastPortPtr)}
+        pi_RowBuf       : Pointer;      { PRIVATE - DO NOT USE! }
+        pi_HamBuf       : Pointer;      { PRIVATE - DO NOT USE! }
+        pi_ColorMap     : pcolorEntry;  { PRIVATE - DO NOT USE! }
+        pi_ColorInt     : pcolorEntry;  { color intensities for entire row }
+        pi_HamInt       : pcolorEntry;  { PRIVATE - DO NOT USE! }
+        pi_Dest1Int     : pcolorEntry;  { PRIVATE - DO NOT USE! }
+        pi_Dest2Int     : pcolorEntry;  { PRIVATE - DO NOT USE! }
+        pi_ScaleX       : Pointer;      { array of scale values for X }
+        pi_ScaleXAlt    : Pointer;      { PRIVATE - DO NOT USE! }
+        pi_dmatrix      : Pointer;      { pointer to dither matrix }
+        pi_TopBuf       : Pointer;      { PRIVATE - DO NOT USE! }
+        pi_BotBuf       : Pointer;      { PRIVATE - DO NOT USE! }
+
+        pi_RowBufSize   : Word;         { PRIVATE - DO NOT USE! }
+        pi_HamBufSize   : Word;         { PRIVATE - DO NOT USE! }
+        pi_ColorMapSize : Word;         { PRIVATE - DO NOT USE! }
+        pi_ColorIntSize : Word;         { PRIVATE - DO NOT USE! }
+        pi_HamIntSize   : Word;         { PRIVATE - DO NOT USE! }
+        pi_Dest1IntSize : Word;         { PRIVATE - DO NOT USE! }
+        pi_Dest2IntSize : Word;         { PRIVATE - DO NOT USE! }
+        pi_ScaleXSize   : Word;         { PRIVATE - DO NOT USE! }
+        pi_ScaleXAltSize : Word;        { PRIVATE - DO NOT USE! }
+
+        pi_PrefsFlags   : Word;         { PRIVATE - DO NOT USE! }
+        pi_special      : ULONG;        { PRIVATE - DO NOT USE! }
+        pi_xstart       : Word;         { PRIVATE - DO NOT USE! }
+        pi_ystart       : Word;         { PRIVATE - DO NOT USE! }
+        pi_width        : Word;         { source width (in pixels) }
+        pi_height       : Word;         { PRIVATE - DO NOT USE! }
+        pi_pc           : ULONG;        { PRIVATE - DO NOT USE! }
+        pi_pr           : ULONG;        { PRIVATE - DO NOT USE! }
+        pi_ymult        : Word;         { PRIVATE - DO NOT USE! }
+        pi_ymod         : Word;         { PRIVATE - DO NOT USE! }
+        pi_ety          : Shortint;     { PRIVATE - DO NOT USE! }
+        pi_xpos         : Word;         { offset to start printing picture }
+        pi_threshold    : Word;         { threshold value (from prefs) }
+        pi_tempwidth    : Word;         { PRIVATE - DO NOT USE! }
+        pi_flags        : Word;         { PRIVATE - DO NOT USE! }
+    end;
+
+IMPLEMENTATION
+
+end.
+
+

+ 359 - 0
packages/extra/amunits/units/realtime.pas

@@ -0,0 +1,359 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+UNIT realtime;
+
+INTERFACE
+USES exec, utility;
+
+{***************************************************************************}
+
+const
+{ realtime.library's idea of time is based on a clock which emits a pulse
+ * 1200 times a second (1.2kHz). All time values maintained by realtime.library
+ * are based on this number. For example, the field RealTimeBase->rtb_Time
+ * expresses an amount of time equivalent to (RealTimeBase->rtb_Time/TICK_FREQ)
+ * seconds.
+ }
+ TICK_FREQ = 1200;
+
+
+{***************************************************************************}
+
+
+{ Each Conductor represents a group of applications which wish to remain
+ * synchronized together.
+ *
+ * This structure must only be allocated by realtime.library and is
+ * READ-ONLY!
+ }
+Type
+ pConductor = ^tConductor;
+ tConductor = record
+    cdt_Link        : tNode;
+    cdt_Reserved0   : WORD;
+    cdt_Players     : tMinList;          { this conductor's players      }
+    cdt_ClockTime,                       { current time of this sequence }
+    cdt_StartTime,                       { start time of this sequence   }
+    cdt_ExternalTime,                    { time from external unit       }
+    cdt_MaxExternalTime,                 { upper limit on sync'd time    }
+    cdt_Metronome   : ULONG;             { MetricTime highest pri node   }
+    cdt_Reserved1   : WORD;
+    cdt_Flags       : WORD;              { conductor flags               }
+    cdt_State       : Byte;              { playing or stopped            }
+ end;
+
+const
+{ Flag bits for Conductor.cdt_Flags }
+ CONDUCTF_EXTERNAL = 1;   { clock is externally driven }
+ CONDUCTF_GOTTICK  = 2;   { received 1st external tick }
+ CONDUCTF_METROSET = 4;   { cdt_Metronome filled in    }
+ CONDUCTF_PRIVATE  = 8;   { conductor is private       }
+
+ CONDUCTB_EXTERNAL = 0;
+ CONDUCTB_GOTTICK  = 1;
+ CONDUCTB_METROSET = 2;
+ CONDUCTB_PRIVATE  = 3;
+
+{ constants for Conductor.cdt_State and SetConductorState() }
+ CONDSTATE_STOPPED    = 0;   { clock is stopped              }
+ CONDSTATE_PAUSED     = 1;   { clock is paused               }
+ CONDSTATE_LOCATE     = 2;   { go to 'running' when ready    }
+ CONDSTATE_RUNNING    = 3;   { run clock NOW                 }
+
+{ These do not actually exist as Conductor states, but are used as additional
+ * arguments to SetConductorState()
+ }
+ CONDSTATE_METRIC     = -1;   { ask high node to locate       }
+ CONDSTATE_SHUTTLE    = -2;   { time changing but not running }
+ CONDSTATE_LOCATE_SET = -3;   { maestro done locating         }
+
+
+{***************************************************************************}
+
+
+{ The Player is the connection between a Conductor and an application.
+ *
+ * This structure must only be allocated by realtime.library and is
+ * READ-ONLY!
+ }
+Type
+ pPlayer = ^tPlayer;
+ tPlayer = record
+    pl_Link             : tNode;
+    pl_Reserved0,
+    pl_Reserved1        : Shortint;
+    pl_Hook             : pHook;         { player's hook function       }
+    pl_Source           : pConductor;    { pointer to parent context    }
+    pl_Task             : pTask;         { task to signal for alarm     }
+    pl_MetricTime       : Longint;       { current time in app's metric }
+    pl_AlarmTime        : Longint;       { time to wake up              }
+    pl_UserData         : Pointer;       { for application use  }
+    pl_PlayerID         : WORD;          { for application use  }
+    pl_Flags            : WORD;          { general Player flags         }
+ end;
+
+const
+{ Flag bits for Player.pl_Flags }
+ PLAYERF_READY     = 1;   { player is ready to go!        }
+ PLAYERF_ALARMSET  = 2;   { alarm is set                  }
+ PLAYERF_QUIET     = 3;   { a dummy player, used for sync }
+ PLAYERF_CONDUCTED = 8;   { give me metered time          }
+ PLAYERF_EXTSYNC   = 16;   { granted external sync         }
+
+ PLAYERB_READY     = 0;
+ PLAYERB_ALARMSET  = 1;
+ PLAYERB_QUIET     = 2;
+ PLAYERB_CONDUCTED = 3;
+ PLAYERB_EXTSYNC   = 4;
+
+
+{***************************************************************************}
+
+
+{ Tags for CreatePlayer(), SetPlayerAttrs(), and GetPlayerAttrs() }
+ PLAYER_Base         = (TAG_USER+64)   ;
+ PLAYER_Hook         = (PLAYER_Base+1) ;  { set address of hook function }
+ PLAYER_Name         = (PLAYER_Base+2) ;  { name of player       }
+ PLAYER_Priority     = (PLAYER_Base+3) ;  { priority of player           }
+ PLAYER_Conductor    = (PLAYER_Base+4) ;  { set conductor for player     }
+ PLAYER_Ready        = (PLAYER_Base+5) ;  { the "ready" flag             }
+ PLAYER_AlarmTime    = (PLAYER_Base+12);  { alarm time (sets PLAYERF_ALARMSET) }
+ PLAYER_Alarm        = (PLAYER_Base+13);  { sets/clears PLAYERF_ALARMSET flag  }
+ PLAYER_AlarmSigTask = (PLAYER_Base+6) ;  { task to signal for alarm/notify    }
+ PLAYER_AlarmSigBit  = (PLAYER_Base+8) ;  { signal bit for alarm (or -1) }
+ PLAYER_Conducted    = (PLAYER_Base+7) ;  { sets/clears PLAYERF_CONDUCTED flag   }
+ PLAYER_Quiet        = (PLAYER_Base+9) ;  { don't process time thru this }
+ PLAYER_UserData     = (PLAYER_Base+10);
+ PLAYER_ID           = (PLAYER_Base+11);
+ PLAYER_ExtSync      = (PLAYER_Base+14);  { attempt/release to ext sync  }
+ PLAYER_ErrorCode    = (PLAYER_Base+15);  { error return value           }
+
+
+{***************************************************************************}
+
+
+{ Method types for messages sent via a Player's hook }
+ PM_TICK     = 0;
+ PM_STATE    = 1;
+ PM_POSITION = 2;
+ PM_SHUTTLE  = 3;
+
+Type
+{ used for PM_TICK, PM_POSITION and PM_SHUTTLE methods }
+ ppmTime = ^tpmTime;
+ tpmTime = record
+    pmt_Method  : ULONG;        { PM_TICK, PM_POSITION, or PM_SHUTTLE }
+    pmt_Time    : ULONG;
+ end;
+
+{ used for the PM_STATE method }
+ ppmState = ^tpmState;
+ tpmState = record
+    pms_Method  : ULONG;        { PM_STATE }
+    pms_OldState: ULONG;
+ end;
+
+
+{***************************************************************************}
+
+const
+{ Possible lock types for LockRealTime() }
+ RT_CONDUCTORS = 0;   { conductor list }
+
+
+{***************************************************************************}
+
+
+{ realtime.library error codes }
+ RTE_NOMEMORY    = 801;   { memory allocation failed      }
+ RTE_NOCONDUCTOR = 802;   { player needs a conductor      }
+ RTE_NOTIMER     = 803;   { timer (CIA) allocation failed }
+ RTE_PLAYING     = 804;   { can't shuttle while playing   }
+
+
+{***************************************************************************}
+
+
+{ OpenLibrary("realtime.library",0) returns a pointer to this structure.
+ * All fields are READ-ONLY.
+ }
+Type
+ pRealTimeBase = ^tRealTimeBase;
+ tRealTimeBase = record
+    rtb_LibNode     : tLibrary;
+    rtb_Reserved0   : Array[0..1] of Byte;
+
+    rtb_Time,                      { current time                         }
+    rtb_TimeFrac    : ULONG;       { fixed-point fraction part of time    }
+    rtb_Reserved1   : WORD;
+    rtb_TickErr     : Integer;     { nanosecond error from ideal Tick     }
+ end;                              { length to real tick length           }
+
+{ Actual tick length is: 1/TICK_FREQ + rtb_TickErr/1e9 }
+
+const
+ RealTime_TickErr_Min = -705;
+ RealTime_TickErr_Max =  705;
+
+{*--- functions in V37 or higher (Release 2.04) ---*}
+
+VAR RealTimeBase : pRealTimeBase;
+
+FUNCTION CreatePlayerA(tagList : pTagItem) : pPlayer;
+PROCEDURE DeletePlayer(player : pPlayer);
+FUNCTION ExternalSync(player : pPlayer; minTime : LONGINT; maxTime : LONGINT) : BOOLEAN;
+FUNCTION FindConductor(name : pCHAR) : pConductor;
+FUNCTION GetPlayerAttrsA(player : pPlayer; tagList : pTagItem) : ULONG;
+FUNCTION LockRealTime(lockType : ULONG) : POINTER;
+FUNCTION NextConductor(previousConductor : pConductor) : pConductor;
+FUNCTION SetConductorState(player : pPlayer; state : ULONG; time : LONGINT) : LONGINT;
+FUNCTION SetPlayerAttrsA(player : pPlayer; tagList : pTagItem) : BOOLEAN;
+PROCEDURE UnlockRealTime(lock : POINTER);
+
+IMPLEMENTATION
+
+FUNCTION CreatePlayerA(tagList : pTagItem) : pPlayer;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L tagList,A0
+    MOVEA.L RealTimeBase,A6
+    JSR -042(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE DeletePlayer(player : pPlayer);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L player,A0
+    MOVEA.L RealTimeBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION ExternalSync(player : pPlayer; minTime : LONGINT; maxTime : LONGINT) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L player,A0
+    MOVE.L  minTime,D0
+    MOVE.L  maxTime,D1
+    MOVEA.L RealTimeBase,A6
+    JSR -066(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION FindConductor(name : pCHAR) : pConductor;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L name,A0
+    MOVEA.L RealTimeBase,A6
+    JSR -078(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION GetPlayerAttrsA(player : pPlayer; tagList : pTagItem) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L player,A0
+    MOVEA.L tagList,A1
+    MOVEA.L RealTimeBase,A6
+    JSR -084(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION LockRealTime(lockType : ULONG) : POINTER;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  lockType,D0
+    MOVEA.L RealTimeBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION NextConductor(previousConductor : pConductor) : pConductor;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L previousConductor,A0
+    MOVEA.L RealTimeBase,A6
+    JSR -072(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetConductorState(player : pPlayer; state : ULONG; time : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L player,A0
+    MOVE.L  state,D0
+    MOVE.L  time,D1
+    MOVEA.L RealTimeBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION SetPlayerAttrsA(player : pPlayer; tagList : pTagItem) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L player,A0
+    MOVEA.L tagList,A1
+    MOVEA.L RealTimeBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE UnlockRealTime(lock : POINTER);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L lock,A0
+    MOVEA.L RealTimeBase,A6
+    JSR -036(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+END. (* UNIT REALTIME *)

+ 600 - 0
packages/extra/amunits/units/rexx.pas

@@ -0,0 +1,600 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+UNIT rexx;
+
+INTERFACE
+USES exec;
+
+
+{ === rexx/storage.h ==================================================
+ *
+ * Copyright (c) 1986, 1987 by William S. Hawes (All Rights Reserved)
+ *
+ * =====================================================================
+ * Header file to define ARexx data structures.
+}
+
+
+{ The NexxStr structure is used to maintain the internal strings in REXX.
+ * It includes the buffer area for the string and associated attributes.
+ * This is actually a variable-length structure; it is allocated for a
+ * specific length string, and the length is never modified thereafter
+ * (since it's used for recycling).
+ }
+
+Type
+
+    pNexxStr = ^tNexxStr;
+    tNexxStr = record
+    ns_Ivalue   : Longint;  { integer value                 }
+    ns_Length   : Word;     { length in bytes (excl null)   }
+    ns_Flags    : Byte;     { attribute flags               }
+    ns_Hash     : Byte;     { hash code                     }
+    ns_Buff     : Array [0..7] of Byte;
+                    { buffer area for strings       }
+    end;                { size: 16 bytes (minimum)      }
+
+Const
+
+    NXADDLEN    = 9;            { offset plus null byte         }
+
+{ String attribute flag bit definitions                                }
+
+    NSB_KEEP    = 0;            { permanent string?             }
+    NSB_STRING  = 1;            { string form valid?            }
+    NSB_NOTNUM  = 2;            { non-numeric?                  }
+    NSB_NUMBER  = 3;            { a valid number?               }
+    NSB_BINARY  = 4;            { integer value saved?          }
+    NSB_FLOAT   = 5;            { floating point format?        }
+    NSB_EXT = 6;            { an external string?           }
+    NSB_SOURCE  = 7;            { part of the program source?   }
+
+{ The flag form of the string attributes                               }
+
+    NSF_KEEP    = 1;
+    NSF_STRING  = 2;
+    NSF_NOTNUM  = 4;
+    NSF_NUMBER  = 8;
+    NSF_BINARY  = 16;
+    NSF_FLOAT   = 32;
+    NSF_EXT = 64;
+    NSF_SOURCE  = 128;
+
+{ Combinations of flags                                                }
+
+    NSF_INTNUM  = NSF_NUMBER + NSF_BINARY + NSF_STRING;
+    NSF_DPNUM   = NSF_NUMBER + NSF_FLOAT;
+    NSF_ALPHA   = NSF_NOTNUM + NSF_STRING;
+    NSF_OWNED   = NSF_SOURCE + NSF_EXT    + NSF_KEEP;
+    KEEPSTR = NSF_STRING + NSF_SOURCE + NSF_NOTNUM;
+    KEEPNUM = NSF_STRING + NSF_SOURCE + NSF_NUMBER + NSF_BINARY;
+
+{ The RexxArg structure is identical to the NexxStr structure, but
+ * is allocated from system memory rather than from internal storage.
+ * This structure is used for passing arguments to external programs.
+ * It is usually passed as an "argstring", a pointer to the string buffer.
+}
+
+Type
+
+    pRexxArg = ^tRexxArg;
+    tRexxArg = record
+    ra_Size     : Longint;  { total allocated length        }
+    ra_Length   : Word;     { length of string              }
+    ra_Flags    : Byte;     { attribute flags               }
+    ra_Hash     : Byte;     { hash code                     }
+    ra_Buff     : Array [0..7] of Byte;
+                    { buffer area                   }
+    end;                { size: 16 bytes (minimum)      }
+
+{ The RexxMsg structure is used for all communications with REXX
+ * programs.  It is an EXEC message with a parameter block appended.
+}
+
+    pRexxMsg = ^tRexxMsg;
+    tRexxMsg = record
+    rm_Node     : tMessage;  { EXEC message structure        }
+    rm_TaskBlock    : Pointer;  { global structure (private)    }
+    rm_LibBase  : Pointer;  { library base (private)        }
+    rm_Action   : Longint;  { command (action) code         }
+    rm_Result1  : Longint;  { primary result (return code)  }
+    rm_Result2  : Longint;  { secondary result              }
+    rm_Args     : Array [0..15] of STRPTR;
+                    { argument block (ARG0-ARG15)   }
+
+    rm_PassPort : pMsgPort;   { forwarding port               }
+    rm_CommAddr : STRPTR;   { host address (port name)      }
+    rm_FileExt  : STRPTR;   { file extension                }
+    rm_Stdin    : Longint;  { input stream (filehandle)     }
+    rm_Stdout   : Longint;  { output stream (filehandle)    }
+    rm_avail    : Longint;  { future expansion              }
+    end;                { size: 128 bytes               }
+
+Const
+
+    MAXRMARG        = 15;       { maximum arguments             }
+
+{ Command (action) codes for message packets                           }
+
+    RXCOMM      = $01000000;    { a command-level invocation    }
+    RXFUNC      = $02000000;    { a function call               }
+    RXCLOSE     = $03000000;    { close the REXX server         }
+    RXQUERY     = $04000000;    { query for information         }
+    RXADDFH     = $07000000;    { add a function host           }
+    RXADDLIB        = $08000000;    { add a function library        }
+    RXREMLIB        = $09000000;    { remove a function library     }
+    RXADDCON        = $0A000000;    { add/update a ClipList string  }
+    RXREMCON        = $0B000000;    { remove a ClipList string      }
+    RXTCOPN     = $0C000000;    { open the trace console        }
+    RXTCCLS     = $0D000000;    { close the trace console       }
+
+{ Command modifier flag bits                                           }
+
+    RXFB_NOIO       = 16;       { suppress I/O inheritance?     }
+    RXFB_RESULT     = 17;       { result string expected?       }
+    RXFB_STRING     = 18;       { program is a "string file"?   }
+    RXFB_TOKEN      = 19;       { tokenize the command line?    }
+    RXFB_NONRET     = 20;       { a "no-return" message?        }
+
+{ The flag form of the command modifiers                               }
+
+    RXFF_NOIO       = $00010000;
+    RXFF_RESULT     = $00020000;
+    RXFF_STRING     = $00040000;
+    RXFF_TOKEN      = $00080000;
+    RXFF_NONRET     = $00100000;
+
+    RXCODEMASK      = $FF000000;
+    RXARGMASK       = $0000000F;
+
+{ The RexxRsrc structure is used to manage global resources.  Each node 
+ * has a name string created as a RexxArg structure, and the total size
+ * of the node is saved in the "rr_Size" field.  The REXX systems library
+ * provides functions to allocate and release resource nodes.  If special
+ * deletion operations are required, an offset and base can be provided in
+ * "rr_Func" and "rr_Base", respectively.  This "autodelete" function will
+ * be called with the base in register A6 and the node in A0.
+ }
+
+Type
+
+    pRexxRsrc = ^tRexxRsrc;
+    tRexxRsrc = record
+    rr_Node     : tNode;
+    rr_Func     : Integer;    { "auto-delete" offset          }
+    rr_Base     : Pointer;  { "auto-delete" base            }
+    rr_Size     : Longint;  { total size of node            }
+    rr_Arg1     : Longint;  { available ...                 }
+    rr_Arg2     : Longint;  { available ...                 }
+    end;                { size: 32 bytes                }
+
+Const
+
+{ Resource node types                                                  }
+
+    RRT_ANY     = 0;        { any node type ...             }
+    RRT_LIB     = 1;        { a function library            }
+    RRT_PORT        = 2;        { a public port                 }
+    RRT_FILE        = 3;        { a file IoBuff                 }
+    RRT_HOST        = 4;        { a function host               }
+    RRT_CLIP        = 5;        { a Clip List node              }
+
+{ The RexxTask structure holds the fields used by REXX to communicate with
+ * external processes, including the client task.  It includes the global
+ * data structure (and the base environment).  The structure is passed to
+ * the newly-created task in its "wake-up" message.
+ }
+
+    GLOBALSZ        = 200;      { total size of GlobalData      }
+
+Type
+
+    pRexxTask = ^tRexxTask;
+    tRexxTask = record
+    rt_Global   : Array [0..GLOBALSZ-1] of Byte;
+                    { global data structure         }
+    rt_MsgPort  : tMsgPort;  { global message port           }
+    rt_Flags    : Byte;     { task flag bits                }
+    rt_SigBit   : Shortint;     { signal bit                    }
+
+    rt_ClientID : Pointer;  { the client's task ID          }
+    rt_MsgPkt   : Pointer;  { the packet being processed    }
+    rt_TaskID   : Pointer;  { our task ID                   }
+    rt_RexxPort : Pointer;  { the REXX public port          }
+
+    rt_ErrTrap  : Pointer;  { Error trap address            }
+    rt_StackPtr : Pointer;  { stack pointer for traps       }
+
+    rt_Header1  : tList;     { Environment list              }
+    rt_Header2  : tList;     { Memory freelist               }
+    rt_Header3  : tList;     { Memory allocation list        }
+    rt_Header4  : tList;     { Files list                    }
+    rt_Header5  : tList;     { Message Ports List            }
+    end;
+
+Const
+
+{ Definitions for RexxTask flag bits                                   }
+
+    RTFB_TRACE      = 0;        { external trace flag           }
+    RTFB_HALT       = 1;        { external halt flag            }
+    RTFB_SUSP       = 2;        { suspend task?                 }
+    RTFB_TCUSE      = 3;        { trace console in use?         }
+    RTFB_WAIT       = 6;        { waiting for reply?            }
+    RTFB_CLOSE      = 7;        { task completed?               }
+
+{ Definitions for memory allocation constants                          }
+
+    MEMQUANT        = 16;       { quantum of memory space       }
+    MEMMASK     = $FFFFFFF0;    { mask for rounding the size    }
+
+    MEMQUICK        = 1;        { EXEC flags: MEMF_PUBLIC       }
+    MEMCLEAR        = $00010000;    { EXEC flags: MEMF_CLEAR        }
+
+{ The SrcNode is a temporary structure used to hold values destined for
+ * a segment array.  It is also used to maintain the memory freelist.
+}
+
+Type
+
+    pSrcNode = ^tSrcNode;
+    tSrcNode = record
+    sn_Succ     : pSrcNode; { next node                     }
+    sn_Pred     : pSrcNode; { previous node                 }
+    sn_Ptr      : Pointer;  { pointer value                 }
+    sn_Size     : Longint;  { size of object                }
+    end;                { size: 16 bytes                }
+
+{ === rexx/rexxio.h ====================================================
+ *
+ * Copyright (c) 1986, 1987 by William S. Hawes.  All Rights Reserved.
+ *
+ * ======================================================================
+ * Header file for ARexx Input/Output related structures
+}
+
+Const
+
+    RXBUFFSZ    = 204;          { buffer length                 }
+
+{
+ * The IoBuff is a resource node used to maintain the File List.  Nodes
+ * are allocated and linked into the list whenever a file is opened.
+}
+
+Type
+
+    pIoBuff = ^tIoBuff;
+    tIoBuff = record
+    iobNode     : tRexxRsrc; { structure for files/strings   }
+    iobRpt      : Pointer;  { read/write pointer            }
+    iobRct      : Longint;  { character count               }
+    iobDFH      : Longint;  { DOS filehandle                }
+    iobLock     : Longint;  { DOS lock                      }
+    iobBct      : Longint;  { buffer length                 }
+    iobArea     : Array [0..RXBUFFSZ-1] of Byte;
+                    { buffer area                   }
+    end;                { size: 256 bytes               }
+
+Const
+
+{ Access mode definitions                                              }
+
+    RXIO_EXIST      = -1;       { an external filehandle        }
+    RXIO_STRF       = 0;        { a "string file"               }
+    RXIO_READ       = 1;        { read-only access              }
+    RXIO_WRITE      = 2;        { write mode                    }
+    RXIO_APPEND     = 3;        { append mode (existing file)   }
+
+{
+ * Offset anchors for SeekF()
+}
+
+    RXIO_BEGIN      = -1;       { relative to start             }
+    RXIO_CURR       = 0;        { relative to current position  }
+    RXIO_END        = 1;        { relative to end               }
+
+{
+ * A message port structure, maintained as a resource node.  The ReplyList
+ * holds packets that have been received but haven't been replied.
+}
+
+Type
+
+    pRexxMsgPort = ^tRexxMsgPort;
+    tRexxMsgPort = record
+    rmp_Node    : tRexxRsrc; { linkage node                  }
+    rmp_Port    : tMsgPort;  { the message port              }
+    rmp_ReplyList   : tList;     { messages awaiting reply       }
+    end;
+
+Const
+
+{
+ * DOS Device types
+}
+
+    DT_DEV  = 0;            { a device                      }
+    DT_DIR  = 1;            { an ASSIGNed directory         }
+    DT_VOL  = 2;            { a volume                      }
+
+{
+ * Private DOS packet types
+}
+
+    ACTION_STACK    = 2002;     { stack a line                  }
+    ACTION_QUEUE    = 2003;     { queue a line                  }
+
+{ === rexx/rxslib.h ===================================================
+ *
+ * Copyright (c) 1986, 1987, 1989 by William S. Hawes (All Rights Reserved)
+ *
+ * =====================================================================
+ * The header file for the REXX Systems Library
+}
+
+{ Some macro definitions                                               }
+
+Const
+
+    RXSNAME    : PChar = 'rexxsyslib.library';
+    RXSID      : PChar = 'rexxsyslib 1.06 (07 MAR 88)';
+    RXSDIR     : PChar = 'REXX';
+    RXSTNAME   : PChar = 'ARexx';
+
+{ The REXX systems library structure.  This should be considered as    }
+{ semi-private and read-only, except for documented exceptions.        }
+
+Type
+
+    pRxsLib = ^tRxsLib;
+    tRxsLib = record
+    rl_Node     : tLibrary;  { EXEC library node             }
+    rl_Flags    : Byte;     { global flags                  }
+    rl_pad      : Byte;
+    rl_SysBase  : Pointer;  { EXEC library base             }
+    rl_DOSBase  : Pointer;  { DOS library base              }
+    rl_IeeeDPBase   : Pointer;  { IEEE DP math library base     }
+    rl_SegList  : Longint;  { library seglist               }
+    rl_NIL      : Longint;  { global NIL: filehandle        }
+    rl_Chunk    : Longint;  { allocation quantum            }
+    rl_MaxNest  : Longint;  { maximum expression nesting    }
+    rl_NULL     : pNexxStr;   { static string: NULL           }
+    rl_FALSE    : pNexxStr;   { static string: FALSE          }
+    rl_TRUE     : pNexxStr;   { static string: TRUE           }
+    rl_REXX     : pNexxStr;   { static string: REXX           }
+    rl_COMMAND  : pNexxStr;   { static string: COMMAND        }
+    rl_STDIN    : pNexxStr;   { static string: STDIN          }
+    rl_STDOUT   : pNexxStr;   { static string: STDOUT         }
+    rl_STDERR   : pNexxStr;   { static string: STDERR         }
+    rl_Version  : STRPTR;   { version/configuration string  }
+
+    rl_TaskName : STRPTR;   { name string for tasks         }
+    rl_TaskPri  : Longint;  { starting priority             }
+    rl_TaskSeg  : Longint;  { startup seglist               }
+    rl_StackSize    : Longint;  { stack size                    }
+    rl_RexxDir  : STRPTR;   { REXX directory                }
+    rl_CTABLE   : STRPTR;   { character attribute table     }
+    rl_Notice   : STRPTR;   { copyright notice              }
+
+    rl_RexxPort : tMsgPort;  { REXX public port              }
+    rl_ReadLock : Word;    { lock count                    }
+    rl_TraceFH  : Longint;  { global trace console          }
+    rl_TaskList : tList;     { REXX task list                }
+    rl_NumTask  : Integer;    { task count                    }
+    rl_LibList  : tList;     { Library List header           }
+    rl_NumLib   : Integer;    { library count                 }
+    rl_ClipList : tList;     { ClipList header               }
+    rl_NumClip  : Integer;    { clip node count               }
+    rl_MsgList  : tList;     { pending messages              }
+    rl_NumMsg   : Integer;    { pending count                 }
+    rl_PgmList  : tList;     { cached programs               }
+    rl_NumPgm   : Integer;    { program count                 }
+
+    rl_TraceCnt : Word;    { usage count for trace console }
+    rl_avail    : Integer;
+    end;
+
+Const
+
+{ Global flag bit definitions for RexxMaster                           }
+    RLFB_TRACE  = RTFB_TRACE;       { interactive tracing?          }
+    RLFB_HALT   = RTFB_HALT;        { halt execution?               }
+    RLFB_SUSP   = RTFB_SUSP;        { suspend execution?            }
+    RLFB_STOP   = 6;            { deny further invocations      }
+    RLFB_CLOSE  = 7;            { close the master              }
+
+    RLFMASK = 1 + 2 + 4;
+
+{ Initialization constants                                             }
+
+    RXSVERS = 34;           { main version                  }
+    RXSREV  = 7;            { revision                      }
+    RXSALLOC    = $800000;      { maximum allocation            }
+    RXSCHUNK    = 1024;         { allocation quantum            }
+    RXSNEST = 32;           { expression nesting limit      }
+    RXSTPRI = 0;            { task priority                 }
+    RXSSTACK    = 4096;         { stack size                    }
+    RXSLISTH    = 5;            { number of list headers        }
+
+{ Character attribute flag bits used in REXX.                          }
+
+    CTB_SPACE   = 0;            { white space characters        }
+    CTB_DIGIT   = 1;            { decimal digits 0-9            }
+    CTB_ALPHA   = 2;            { alphabetic characters         }
+    CTB_REXXSYM = 3;            { REXX symbol characters        }
+    CTB_REXXOPR = 4;            { REXX operator characters      }
+    CTB_REXXSPC = 5;            { REXX special symbols          }
+    CTB_UPPER   = 6;            { UPPERCASE alphabetic          }
+    CTB_LOWER   = 7;            { lowercase alphabetic          }
+                                                                      
+{ Attribute flags                                                      }
+
+    CTF_SPACE   = 1;
+    CTF_DIGIT   = 2;
+    CTF_ALPHA   = 4;
+    CTF_REXXSYM = 8;
+    CTF_REXXOPR = 16;
+    CTF_REXXSPC = 32;
+    CTF_UPPER   = 64;
+    CTF_LOWER   = 128;
+
+
+VAR RexxSysBase : pLibrary;
+
+PROCEDURE ClearRexxMsg(msgptr : pRexxMsg; count : ULONG);
+FUNCTION CreateArgstring(argstring : pCHAR; length : ULONG) : pCHAR;
+FUNCTION CreateRexxMsg(port : pMsgPort; extension : pCHAR; host : pCHAR) : pRexxMsg;
+PROCEDURE DeleteArgstring(argstring : pCHAR);
+PROCEDURE DeleteRexxMsg(packet : pRexxMsg);
+FUNCTION FillRexxMsg(msgptr : pRexxMsg; count : ULONG; mask : ULONG) : BOOLEAN;
+FUNCTION IsRexxMsg(msgptr : pRexxMsg) : BOOLEAN;
+FUNCTION LengthArgstring(argstring : pCHAR) : ULONG;
+PROCEDURE LockRexxBase(resource : ULONG);
+PROCEDURE UnlockRexxBase(resource : ULONG);
+
+IMPLEMENTATION
+
+PROCEDURE ClearRexxMsg(msgptr : pRexxMsg; count : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L msgptr,A0
+    MOVE.L  count,D0
+    MOVEA.L RexxSysBase,A6
+    JSR -156(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION CreateArgstring(argstring : pCHAR; length : ULONG) : pCHAR;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L argstring,A0
+    MOVE.L  length,D0
+    MOVEA.L RexxSysBase,A6
+    JSR -126(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION CreateRexxMsg(port : pMsgPort; extension : pCHAR; host : pCHAR) : pRexxMsg;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L port,A0
+    MOVEA.L extension,A1
+    MOVE.L  host,D0
+    MOVEA.L RexxSysBase,A6
+    JSR -144(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE DeleteArgstring(argstring : pCHAR);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L argstring,A0
+    MOVEA.L RexxSysBase,A6
+    JSR -132(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE DeleteRexxMsg(packet : pRexxMsg);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L packet,A0
+    MOVEA.L RexxSysBase,A6
+    JSR -150(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+FUNCTION FillRexxMsg(msgptr : pRexxMsg; count : ULONG; mask : ULONG) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L msgptr,A0
+    MOVE.L  count,D0
+    MOVE.L  mask,D1
+    MOVEA.L RexxSysBase,A6
+    JSR -162(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION IsRexxMsg(msgptr : pRexxMsg) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L msgptr,A0
+    MOVEA.L RexxSysBase,A6
+    JSR -168(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION LengthArgstring(argstring : pCHAR) : ULONG;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L argstring,A0
+    MOVEA.L RexxSysBase,A6
+    JSR -138(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+PROCEDURE LockRexxBase(resource : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  resource,D0
+    MOVEA.L RexxSysBase,A6
+    JSR -450(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+PROCEDURE UnlockRexxBase(resource : ULONG);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  resource,D0
+    MOVEA.L RexxSysBase,A6
+    JSR -456(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+END. (* UNIT REXXSYSLIB *)

+ 43 - 0
packages/extra/amunits/units/romboot_base.pas

@@ -0,0 +1,43 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit romboot_base;
+
+INTERFACE
+
+uses exec;
+
+Type
+
+    pRomBootBase = ^tRomBootBase;
+    tRomBootBase = record
+        LibNode         : tLibrary;
+        ExecBase        : pExecBase;
+        BootList        : tList;
+        Reserved        : Array [0..3] of Longint;
+                                { for future expansion }
+    end;
+
+Const
+
+    ROMBOOT_NAME : PChar = 'romboot.library';
+
+IMPLEMENTATION
+
+end.
+
+
+

+ 136 - 0
packages/extra/amunits/units/scsidisk.pas

@@ -0,0 +1,136 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{
+        SCSI exec-level device command
+}
+
+unit scsidisk;
+
+INTERFACE
+
+uses exec;
+
+{--------------------------------------------------------------------
+ *
+ *   SCSI Command
+ *      Several Amiga SCSI controller manufacturers are converging on
+ *      standard ways to talk to their controllers.  This include
+ *      file describes an exec-device command (e.g. for hddisk.device)
+ *      that can be used to issue SCSI commands
+ *
+ *   UNIT NUMBERS
+ *      Unit numbers to the OpenDevice call have encoded in them which
+ *      SCSI device is being referred to.  The three decimal digits of
+ *      the unit number refer to the SCSI Target ID (bus address) in
+ *      the 1's digit, the SCSI logical unit (LUN) in the 10's digit,
+ *      and the controller board in the 100's digit.
+ *
+ *      Examples:
+ *                0     drive at address 0
+ *               12     LUN 1 on multiple drive controller at address 2
+ *              104     second controller board, address 4
+ *               88     not valid: both logical units and addresses
+ *                      range from 0..7.
+ *
+ *   CAVEATS
+ *      Original 2090 code did not support this command.
+ *
+ *      Commodore 2090/2090A unit numbers are different.  The SCSI
+ *      logical unit is the 100's digit, and the SCSI Target ID
+ *      is a permuted 1's digit: Target ID 0..6 maps to unit 3..9
+ *      (7 is reserved for the controller).
+ *
+ *          Examples:
+ *                3     drive at address 0
+ *              109     drive at address 6, logical unit 1
+ *                1     not valid: this is not a SCSI unit.  Perhaps
+ *                      it's an ST506 unit.
+ *
+ *      Some controller boards generate a unique name (e.g. 2090A's
+ *      iddisk.device) for the second controller board, instead of
+ *      implementing the 100's digit.
+ *
+ *      There are optional restrictions on the alignment, bus
+ *      accessability, and size of the data for the data phase.
+ *      Be conservative to work with all manufacturer's controllers.
+ *
+ *------------------------------------------------------------------}
+
+Const
+
+    HD_SCSICMD          = 28;   { issue a SCSI command to the unit }
+                                { io_Data points to a SCSICmd }
+                                { io_Length is sizeof(struct SCSICmd) }
+                                { io_Actual and io_Offset are not used }
+
+Type
+
+    pSCSICmd = ^tSCSICmd;
+    tSCSICmd = record
+        scsi_Data       : Pointer; { word aligned data for SCSI Data Phase }
+                                   { (optional) data need not be byte aligned }
+                                   { (optional) data need not be bus accessable }
+        scsi_Length     : ULONG;   { even length of Data area }
+                                   { (optional) data can have odd length }
+                                   { (optional) data length can be > 2**24 }
+        scsi_Actual     : ULONG;   { actual Data used }
+        scsi_Command    : Pointer; { SCSI Command (same options as scsi_Data) }
+        scsi_CmdLength  : Word;    { length of Command }
+        scsi_CmdActual  : Word;    { actual Command used }
+        scsi_Flags      : Byte;    { includes intended data direction }
+        scsi_Status     : Byte;    { SCSI status of command }
+        scsi_SenseData  : STRPTR;  { sense data: filled IF SCSIF_[OLD]AUTOSENSE }
+                                   { is set AND scsi_Status has CHECK CONDITION }
+                                   { (bit 1) set }
+        scsi_SenseLength : Word;   { size of scsi_SenseData, also bytes to }
+                                   { request w/ SCSIF_AUTOSENSE, must be 4..255 }
+        scsi_SenseActual : Word;   { amount actually fetched (0 means no sense) }
+    end;
+
+
+Const
+
+{----- scsi_Flags -----}
+    SCSIF_WRITE         = 0;    { intended data direction is out }
+    SCSIF_READ          = 1;    { intended data direction is in }
+    SCSIB_READ_WRITE    = 0;    { (the bit to test) }
+
+    SCSIF_NOSENSE       = 0;       { no automatic request sense }
+    SCSIF_AUTOSENSE     = 2;       { do standard extended request sense }
+                                         { on check condition }
+    SCSIF_OLDAUTOSENSE  = 6;       { do 4 byte non-extended request }
+                                        { sense on check condition }
+    SCSIB_AUTOSENSE     = 1;       { (the bit to test) }
+    SCSIB_OLDAUTOSENSE  = 2;       { (the bit to test) }
+
+
+{----- SCSI io_Error values -----}
+    HFERR_SelfUnit      = 40;   { cannot issue SCSI command to self }
+    HFERR_DMA           = 41;   { DMA error }
+    HFERR_Phase         = 42;   { illegal or unexpected SCSI phase }
+    HFERR_Parity        = 43;   { SCSI parity error }
+    HFERR_SelTimeout    = 44;   { Select timed out }
+    HFERR_BadStatus     = 45;   { status and/or sense error }
+
+{----- OpenDevice io_Error values -----}
+    HFERR_NoBoard       = 50;   { Open failed for non-existant board }
+
+IMPLEMENTATION
+
+end.
+
+

+ 197 - 0
packages/extra/amunits/units/serial.pas

@@ -0,0 +1,197 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit serial;
+
+INTERFACE
+
+uses exec;
+
+
+Type
+
+                   { array of termination char's }
+                   { to use,see serial.doc setparams }
+
+    pIOTArray = ^tIOTArray;
+    tIOTArray = record
+        TermArray0 : ULONG;
+        TermArray1 : ULONG;
+    end;
+
+Const
+
+    SER_DEFAULT_CTLCHAR = $11130000;    { default chars for xON,xOFF }
+
+{ You may change these via SETPARAMS.   At this time, parity is not
+   calculated for xON/xOFF characters.  You must supply them with the
+   desired parity. }
+
+{****************************************************************}
+{ CAUTION !!  IF YOU ACCESS the serial.device, you MUST (!!!!) use an
+   IOExtSer-sized structure or you may overlay innocent memory !! }
+{****************************************************************}
+
+Type
+
+    pIOExtSer = ^tIOExtSer;
+    tIOExtSer = record
+        IOSer   : tIOStdReq;
+
+{     STRUCT    MsgNode
+*   0   APTR     Succ
+*   4   APTR     Pred
+*   8   UBYTE    Type
+*   9   UBYTE    Pri
+*   A   APTR     Name
+*   E   APTR     ReplyPort
+*  12   UWORD    MNLength
+*     STRUCT   IOExt
+*  14   APTR     io_Device
+*  18   APTR     io_Unit
+*  1C   UWORD    io_Command
+*  1E   UBYTE    io_Flags
+*  1F   UBYTE    io_Error
+*     STRUCT   IOStdExt
+*  20   ULONG    io_Actual
+*  24   ULONG    io_Length
+*  28   APTR     io_Data
+*  2C   ULONG    io_Offset
+*
+*  30 }
+
+        io_CtlChar      : ULONG; { control char's (order = xON,xOFF,INQ,ACK) }
+        io_RBufLen      : ULONG; { length in bytes of serial port's read buffer }
+        io_ExtFlags     : ULONG; { additional serial flags (see bitdefs below) }
+        io_Baud         : ULONG; { baud rate requested (true baud) }
+        io_BrkTime      : ULONG; { duration of break signal in MICROseconds }
+        io_TermArray    : tIOTArray; { termination character array }
+        io_ReadLen      : Byte;   { bits per read character (# of bits) }
+        io_WriteLen     : Byte;   { bits per write character (# of bits) }
+        io_StopBits     : Byte;   { stopbits for read (# of bits) }
+        io_SerFlags     : Byte;   { see SerFlags bit definitions below   }
+        io_Status       : Word;
+    end;
+
+   { status of serial port, as follows:
+*                  BIT  ACTIVE  FUNCTION
+*                   0    ---    reserved
+*                   1    ---    reserved
+*                   2    high   Connected to parallel "select" on the A1000.
+*                               Connected to both the parallel "select" and
+*                               serial "ring indicator" pins on the A500 &
+*                               A2000.  Take care when making cables.
+*                   3    low    Data Set Ready
+*                   4    low    Clear To Send
+*                   5    low    Carrier Detect
+*                   6    low    Ready To Send
+*                   7    low    Data Terminal Ready
+*                   8    high   read overrun
+*                   9    high   break sent
+*                  10    high   break received
+*                  11    high   transmit x-OFFed
+*                  12    high   receive x-OFFed
+*               13-15           reserved
+}
+
+Const
+
+    SDCMD_QUERY         = CMD_NONSTD;
+    SDCMD_BREAK         = CMD_NONSTD + 1;
+    SDCMD_SETPARAMS     = CMD_NONSTD + 2;
+
+
+    SERB_XDISABLED      = 7;    { io_SerFlags xOn-xOff feature disabled bit }
+    SERF_XDISABLED      = 128;  {    "      xOn-xOff feature disabled mask }
+    SERB_EOFMODE        = 6;    {    "      EOF mode enabled bit }
+    SERF_EOFMODE        = 64;   {    "      EOF mode enabled mask }
+    SERB_SHARED         = 5;    {    "      non-exclusive access bit }
+    SERF_SHARED         = 32;   {    "      non-exclusive access mask }
+    SERB_RAD_BOOGIE     = 4;    {    "      high-speed mode active bit }
+    SERF_RAD_BOOGIE     = 16;   {    "      high-speed mode active mask }
+    SERB_QUEUEDBRK      = 3;    {    "      queue this Break ioRqst }
+    SERF_QUEUEDBRK      = 8;    {    "      queue this Break ioRqst }
+    SERB_7WIRE          = 2;    {    "      RS232 7-wire protocol }
+    SERF_7WIRE          = 4;    {    "      RS232 7-wire protocol }
+    SERB_PARTY_ODD      = 1;    {    "      parity feature enabled bit }
+    SERF_PARTY_ODD      = 2;    {    "      parity feature enabled mask }
+    SERB_PARTY_ON       = 0;    {    "      parity-enabled bit }
+    SERF_PARTY_ON       = 1;    {    "      parity-enabled mask }
+
+{ These now refect the actual bit positions in the io_Status UWORD }
+
+    IO_STATB_XOFFREAD   = 12;      { io_Status receive currently xOFF'ed bit }
+    IO_STATF_XOFFREAD   = $1000;   {     "     receive currently xOFF'ed mask }
+    IO_STATB_XOFFWRITE  = 11;      {     "     transmit currently xOFF'ed bit }
+    IO_STATF_XOFFWRITE  = $0800;   {     "     transmit currently xOFF'ed mask }
+    IO_STATB_READBREAK  = 10;      {     "     break was latest input bit }
+    IO_STATF_READBREAK  = $0400;   {     "     break was latest input mask }
+    IO_STATB_WROTEBREAK = 9;       {     "     break was latest output bit }
+    IO_STATF_WROTEBREAK = $0200;   {     "     break was latest output mask }
+    IO_STATB_OVERRUN    = 8;       {     "     status word RBF overrun bit }
+    IO_STATF_OVERRUN    = $0100;   {     "     status word RBF overrun mask }
+
+
+    SEXTB_MSPON         = 1;    { io_ExtFlags. Use mark-space parity, }
+                                {           instead of odd-even. }
+    SEXTF_MSPON         = 2;    {    "      mark-space parity mask }
+    SEXTB_MARK          = 0;    {    "      if mark-space, use mark }
+    SEXTF_MARK          = 1;    {    "      if mark-space, use mark mask }
+
+
+    SerErr_DevBusy      = 1;
+    SerErr_BaudMismatch = 2;    { baud rate not supported by hardware }
+    SerErr_BufErr       = 4;    { Failed to allocate new read buffer }
+    SerErr_InvParam     = 5;
+    SerErr_LineErr      = 6;
+    SerErr_ParityErr    = 9;
+    SerErr_TimerErr     = 11;   {(See the serial/OpenDevice autodoc)}
+    SerErr_BufOverflow  = 12;
+    SerErr_NoDSR        = 13;
+    SerErr_DetectedBreak = 15;
+
+
+{ These defines refer to the HIGH ORDER byte of io_Status.  They have
+   been replaced by the new, corrected ones above }
+    IOSTB_XOFFREAD  = 4;       { iost_hob receive currently xOFF'ed bit }
+    IOSTF_XOFFREAD  = 16;      {    "     receive currently xOFF'ed mask }
+    IOSTB_XOFFWRITE = 3;       {    "     transmit currently xOFF'ed bit }
+    IOSTF_XOFFWRITE = 8;       {    "     transmit currently xOFF'ed mask }
+    IOSTB_READBREAK = 2;       {    "     break was latest input bit }
+    IOSTF_READBREAK = 4;       {    "     break was latest input mask }
+    IOSTB_WROTEBREAK= 1;       {    "     break was latest output bit }
+    IOSTF_WROTEBREAK= 2;       {    "     break was latest output mask }
+    IOSTB_OVERRUN   = 0;       {    "     status word RBF overrun bit }
+    IOSTF_OVERRUN   = 1;       {    "     status word RBF overrun mask }
+
+    IOSERB_BUFRREAD = 7  ;     { io_Flags from read buffer bit }
+    IOSERF_BUFRREAD = 128;  {    "     from read buffer mask }
+    IOSERB_QUEUED   = 6  ;     {    "     rqst-queued bit }
+    IOSERF_QUEUED   = 64 ; {    "     rqst-queued mask }
+    IOSERB_ABORT    = 5  ;     {    "     rqst-aborted bit }
+    IOSERF_ABORT    = 32 ; {    "     rqst-aborted mask }
+    IOSERB_ACTIVE   = 4  ;     {    "     rqst-qued-OR-current bit }
+    IOSERF_ACTIVE   = 16 ; {    "     rqst-qued-OR-current mask }
+
+
+
+    SERIALNAME          : PChar = 'serial.device';
+
+IMPLEMENTATION
+
+end.
+
+

+ 57 - 0
packages/extra/amunits/units/tapedeck.pas

@@ -0,0 +1,57 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit tapedeck;
+
+INTERFACE
+
+uses utility;
+
+const
+    TDECK_Dummy            = (TAG_USER+$05000000);
+    TDECK_Mode             = (TDECK_Dummy + 1);
+    TDECK_Paused           = (TDECK_Dummy + 2);
+
+    TDECK_Tape             = (TDECK_Dummy + 3);
+        { (BOOL) Indicate whether tapedeck or animation controls.  Defaults
+         * to FALSE. }
+
+    TDECK_Frames           = (TDECK_Dummy + 11);
+        { (LONG) Number of frames in animation.  Only valid when using
+         * animation controls. }
+
+    TDECK_CurrentFrame     = (TDECK_Dummy + 12);
+        { (LONG) Current frame.  Only valid when using animation controls. }
+
+{***************************************************************************}
+
+{ Possible values for TDECK_Mode }
+    BUT_REWIND     = 0;
+    BUT_PLAY       = 1;
+    BUT_FORWARD    = 2;
+    BUT_STOP       = 3;
+    BUT_PAUSE      = 4;
+    BUT_BEGIN      = 5;
+    BUT_FRAME      = 6;
+    BUT_END        = 7;
+
+{***************************************************************************}
+
+IMPLEMENTATION
+
+end.
+
+

+ 148 - 0
packages/extra/amunits/units/timer.pas

@@ -0,0 +1,148 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit timer;
+
+INTERFACE
+
+uses exec;
+
+Const
+
+{ unit defintions }
+    UNIT_MICROHZ        = 0;
+    UNIT_VBLANK         = 1;
+    UNIT_ECLOCK         = 2;
+    UNIT_WAITUNTIL      = 3;
+    UNIT_WAITECLOCK     = 4;
+
+    TIMERNAME : PChar   = 'timer.device';
+
+Type
+
+    ptimeval = ^ttimeval;
+    ttimeval = record
+        tv_secs         : ULONG;
+        tv_micro        : ULONG;
+    end;
+
+    ptimerequest = ^ttimerequest;
+    ttimerequest = record
+        tr_node         : tIORequest;
+        tr_time         : ttimeval;
+    end;
+
+    pEClockVal = ^tEClockVal;
+    tEClockVal = record
+        ev_hi : ULONG;
+        ev_lo : ULONG;
+    end;
+
+
+Const
+
+{ IO_COMMAND to use for adding a timer }
+    TR_ADDREQUEST       = CMD_NONSTD;
+    TR_GETSYSTIME       = CMD_NONSTD + 1;
+    TR_SETSYSTIME       = CMD_NONSTD + 2;
+
+{  To use any of the routines below, TimerBase must be set to point
+   to the timer.device, either by calling CreateTimer or by pulling
+   the device pointer from a valid TimeRequest, i.e.
+
+        TimerBase := TimeRequest.io_Device;
+
+    _after_ you have called OpenDevice on the timer.
+ }
+
+var
+    TimerBase   : Pointer;
+
+Procedure AddTime(VAR Dest, Source : ptimeval);
+Function CmpTime(VAR Dest, Source : ptimeval) : ULONG;
+Procedure SubTime(VAR Dest, Source : ptimeval);
+function ReadEClock(Dest : pEClockVal): longint;
+procedure GetSysTime(Dest : ptimeval);
+
+IMPLEMENTATION
+
+Procedure AddTime(VAR Dest, Source : ptimeval);
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Dest,a0
+       MOVE.L  Source,a1
+       MOVE.L  TimerBase,A6
+       JSR -042(A6)
+       MOVE.L  (A7)+,A6
+   end;
+end;
+
+Function CmpTime(VAR Dest, Source : ptimeval) : ULONG;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Dest,a0
+       MOVE.L  Source,a1
+       MOVE.L  TimerBase,A6
+       JSR -054(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+Procedure SubTime(VAR Dest, Source : ptimeval);
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Dest,a0
+       MOVE.L  Source,a1
+       MOVE.L  TimerBase,A6
+       JSR -048(A6)
+       MOVE.L  (A7)+,A6
+   end;
+end;
+
+function ReadEClock(Dest : pEClockVal): longint;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Dest,a0
+       MOVE.L  TimerBase,A6
+       JSR -060(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+procedure GetSysTime(Dest : ptimeval);
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Dest,a0
+       MOVE.L  TimerBase,A6
+       JSR -066(A6)
+       MOVE.L  (A7)+,A6
+   end;
+end;
+
+
+end.
+
+
+
+
+

+ 270 - 0
packages/extra/amunits/units/trackdisk.pas

@@ -0,0 +1,270 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit trackdisk;
+
+INTERFACE
+
+uses exec;
+
+{
+ *--------------------------------------------------------------------
+ *
+ * Physical drive constants
+ *
+ *--------------------------------------------------------------------
+}
+
+Const
+
+    NUMSECS     = 11;
+    NUMUNITS    = 4;
+
+{
+ *--------------------------------------------------------------------
+ *
+ * Useful constants
+ *
+ *--------------------------------------------------------------------
+ }
+
+{-- sizes before mfm encoding }
+    TD_SECTOR   = 512;
+    TD_SECSHIFT = 9;            { log TD_SECTOR }
+
+{
+ *--------------------------------------------------------------------
+ *
+ * Driver Specific Commands
+ *
+ *--------------------------------------------------------------------
+ }
+
+{
+ *-- TD_NAME is a generic macro to get the name of the driver.  This
+ *-- way if the name is ever changed you will pick up the change
+ *-- automatically.
+ *--
+ *-- Normal usage would be:
+ *--
+ *-- char internalName[] = TD_NAME;
+ *--
+ }
+
+    TD_NAME     : PChar = 'trackdisk.device';
+
+    TDF_EXTCOM  = $00010000;            { for internal use only! }
+
+
+    TD_MOTOR            = CMD_NONSTD + 0;       { control the disk's motor }
+    TD_SEEK             = CMD_NONSTD + 1;       { explicit seek (for testing) }
+    TD_FORMAT           = CMD_NONSTD + 2;       { format disk }
+    TD_REMOVE           = CMD_NONSTD + 3;       { notify when disk changes }
+    TD_CHANGENUM        = CMD_NONSTD + 4;       { number of disk changes }
+    TD_CHANGESTATE      = CMD_NONSTD + 5;       { is there a disk in the drive? }
+    TD_PROTSTATUS       = CMD_NONSTD + 6;       { is the disk write protected? }
+    TD_RAWREAD          = CMD_NONSTD + 7;       { read raw bits from the disk }
+    TD_RAWWRITE         = CMD_NONSTD + 8;       { write raw bits to the disk }
+    TD_GETDRIVETYPE     = CMD_NONSTD + 9;       { get the type of the disk drive }
+    TD_GETNUMTRACKS     = CMD_NONSTD + 10;      { # of tracks for this type drive }
+    TD_ADDCHANGEINT     = CMD_NONSTD + 11;      { TD_REMOVE done right }
+    TD_REMCHANGEINT     = CMD_NONSTD + 12;      { remove softint set by ADDCHANGEINT }
+    TD_GETGEOMETRY      = CMD_NONSTD + 13;
+    TD_EJECT            = CMD_NONSTD + 14;      { for those drives that support it }
+    TD_LASTCOMM         = CMD_NONSTD + 15;
+
+{
+ *
+ * The disk driver has an "extended command" facility.  These commands
+ * take a superset of the normal IO Request block.
+ *
+ }
+
+    ETD_WRITE           = CMD_WRITE + TDF_EXTCOM;
+    ETD_READ            = CMD_READ + TDF_EXTCOM;
+    ETD_MOTOR           = TD_MOTOR + TDF_EXTCOM;
+    ETD_SEEK            = TD_SEEK + TDF_EXTCOM;
+    ETD_FORMAT          = TD_FORMAT + TDF_EXTCOM;
+    ETD_UPDATE          = CMD_UPDATE + TDF_EXTCOM;
+    ETD_CLEAR           = CMD_CLEAR + TDF_EXTCOM;
+    ETD_RAWREAD         = TD_RAWREAD + TDF_EXTCOM;
+    ETD_RAWWRITE        = TD_RAWWRITE + TDF_EXTCOM;
+
+{
+ *
+ * extended IO has a larger than normal io request block.
+ *
+ }
+
+Type
+
+    pIOExtTD = ^tIOExtTD;
+    tIOExtTD = record
+        iotd_Req        : tIOStdReq;
+        iotd_Count      : ULONG;
+        iotd_SecLabel   : ULONG;
+    end;
+
+{
+ *  This is the structure returned by TD_DRIVEGEOMETRY
+ *  Note that the layout can be defined three ways:
+ *
+ *  1. TotalSectors
+ *  2. Cylinders and CylSectors
+ *  3. Cylinders, Heads, and TrackSectors.
+ *
+ *  #1 is most accurate, #2 is less so, and #3 is least accurate.  All
+ *  are usable, though #2 and #3 may waste some portion of the available
+ *  space on some drives.
+ }
+       pDriveGeometry = ^tDriveGeometry;
+       tDriveGeometry = record
+        dg_SectorSize,          {    in bytes }
+        dg_TotalSectors,        {    total # of sectors on drive }
+        dg_Cylinders,           {    number of cylinders }
+        dg_CylSectors,          {    number of sectors/cylinder }
+        dg_Heads,               {    number of surfaces }
+        dg_TrackSectors,        {    number of sectors/track }
+        dg_BufMemType : ULONG;          {    preferred buffer memory type }
+                                        {    (usually MEMF_PUBLIC) }
+        dg_DeviceType,          {    codes as defined in the SCSI-2 spec}
+        dg_Flags      : Byte;               {    flags, including removable }
+        dg_Reserved   : Word;
+       END;
+
+
+Const
+{    device types }
+    DG_DIRECT_ACCESS       = 0 ;
+    DG_SEQUENTIAL_ACCESS   = 1 ;
+    DG_PRINTER             = 2 ;
+    DG_PROCESSOR           = 3 ;
+    DG_WORM                = 4 ;
+    DG_CDROM               = 5 ;
+    DG_SCANNER             = 6 ;
+    DG_OPTICAL_DISK        = 7 ;
+    DG_MEDIUM_CHANGER      = 8 ;
+    DG_COMMUNICATION       = 9 ;
+    DG_UNKNOWN             = 31;
+
+{    flags }
+    DGB_REMOVABLE          = 0;
+    DGF_REMOVABLE          = 1;
+
+{
+** raw read and write can be synced with the index pulse.  This flag
+** in io request's IO_FLAGS field tells the driver that you want this.
+}
+
+    IOTDB_INDEXSYNC     = 4;
+    IOTDF_INDEXSYNC     = 16;
+
+{
+** raw read and write can be synced with a $4489 sync pattern.  This flag
+** in io request's IO_FLAGS field tells the driver that you want this.
+}
+    IOTDB_WORDSYNC = 5;
+    IOTDF_WORDSYNC = 32;
+
+
+{ labels are TD_LABELSIZE bytes per sector }
+
+    TD_LABELSIZE        = 16;
+
+{
+** This is a bit in the FLAGS field of OpenDevice.  If it is set, then
+** the driver will allow you to open all the disks that the trackdisk
+** driver understands.  Otherwise only 3.5" disks will succeed.
+}
+
+    TDB_ALLOW_NON_3_5   = 0;
+    TDF_ALLOW_NON_3_5   = 1;
+
+{
+**  If you set the TDB_ALLOW_NON_3_5 bit in OpenDevice, then you don't
+**  know what type of disk you really got.  These defines are for the
+**  TD_GETDRIVETYPE command.  In addition, you can find out how many
+**  tracks are supported via the TD_GETNUMTRACKS command.
+}
+
+    DRIVE3_5            = 1;
+    DRIVE5_25           = 2;
+    DRIVE3_5_150RPM     = 3;
+
+{
+ *--------------------------------------------------------------------
+ *
+ * Driver error defines
+ *
+ *--------------------------------------------------------------------
+ }
+
+    TDERR_NotSpecified          = 20;   { general catchall }
+    TDERR_NoSecHdr              = 21;   { couldn't even find a sector }
+    TDERR_BadSecPreamble        = 22;   { sector looked wrong }
+    TDERR_BadSecID              = 23;   { ditto }
+    TDERR_BadHdrSum             = 24;   { header had incorrect checksum }
+    TDERR_BadSecSum             = 25;   { data had incorrect checksum }
+    TDERR_TooFewSecs            = 26;   { couldn't find enough sectors }
+    TDERR_BadSecHdr             = 27;   { another "sector looked wrong" }
+    TDERR_WriteProt             = 28;   { can't write to a protected disk }
+    TDERR_DiskChanged           = 29;   { no disk in the drive }
+    TDERR_SeekError             = 30;   { couldn't find track 0 }
+    TDERR_NoMem                 = 31;   { ran out of memory }
+    TDERR_BadUnitNum            = 32;   { asked for a unit > NUMUNITS }
+    TDERR_BadDriveType          = 33;   { not a drive that trackdisk groks }
+    TDERR_DriveInUse            = 34;   { someone else allocated the drive }
+    TDERR_PostReset             = 35;   { user hit reset; awaiting doom }
+
+{
+ *--------------------------------------------------------------------
+ *
+ * public portion of the unit structure
+ *
+ *--------------------------------------------------------------------
+ }
+
+Type
+
+    pTDU_PublicUnit = ^tTDU_PublicUnit;
+    tTDU_PublicUnit = record
+        tdu_Unit        : tUnit;         { base message port }
+        tdu_Comp01Track : Word;         { track for first precomp }
+        tdu_Comp10Track : Word;         { track for second precomp }
+        tdu_Comp11Track : Word;         { track for third precomp }
+        tdu_StepDelay   : ULONG;        { time to wait after stepping }
+        tdu_SettleDelay : ULONG;        { time to wait after seeking }
+        tdu_RetryCnt    : Byte;         { # of times to retry }
+        tdu_PubFlags    : Byte;         {    public flags, see below }
+        tdu_CurrTrk     : Word;         {    track the heads are over... }
+                                        {    ONLY ACCESS WHILE UNIT IS STOPPED! }
+        tdu_CalibrateDelay : ULONG;     {    time to wait after stepping }
+                                        {    during a recalibrate }
+        tdu_Counter     : ULONG;        {    counter for disk changes... }
+                                        {    ONLY ACCESS WHILE UNIT IS STOPPED! }
+
+    end;
+
+CONST
+{    flags for tdu_PubFlags }
+    TDPB_NOCLICK  =  0;
+    TDPF_NOCLICK  =  1;
+
+IMPLEMENTATION
+
+end.
+
+

+ 49 - 0
packages/extra/amunits/units/translator.pas

@@ -0,0 +1,49 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+UNIT translator;
+
+INTERFACE
+USES exec;
+
+Const
+
+    TR_NotUsed          = -1;   { This is an oft used system rc }
+    TR_NoMem            = -2;   { Can't allocate memory }
+    TR_MakeBad          = -4;   { Error in MakeLibrary call }
+
+VAR TranslatorBase : pLibrary;
+
+FUNCTION Translate(inputString : pCHAR; inputLength : LONGINT; outputBuffer : pCHAR; bufferSize : LONGINT) : LONGINT;
+
+IMPLEMENTATION
+
+FUNCTION Translate(inputString : pCHAR; inputLength : LONGINT; outputBuffer : pCHAR; bufferSize : LONGINT) : LONGINT;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L inputString,A0
+    MOVE.L  inputLength,D0
+    MOVEA.L outputBuffer,A1
+    MOVE.L  bufferSize,D1
+    MOVEA.L TranslatorBase,A6
+    JSR -030(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+END. (* UNIT TRANSLATOR *)

+ 910 - 0
packages/extra/amunits/units/utility.pas

@@ -0,0 +1,910 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit utility;
+
+INTERFACE
+uses exec;
+
+
+Type
+      pClockData = ^tClockData;
+      tClockData = record
+        sec   : Word;
+        min   : Word;
+        hour  : Word;
+        mday  : Word;
+        month : Word;
+        year  : Word;
+        wday  : Word;
+      END;
+
+      pHook = ^tHook;
+      tHook = record
+        h_MinNode  : tMinNode;
+        h_Entry    : Pointer;   { assembler entry point        }
+        h_SubEntry : Pointer;   { often HLL entry point        }
+        h_Data     : Pointer;   { owner specific               }
+      END;
+
+{
+ * Hook calling conventions:
+ *      A0 - pointer to hook data structure itself
+ *      A1 - pointer to parameter structure ("message") typically
+ *           beginning with a longword command code, which makes
+ *           sense in the context in which the hook is being used.
+ *      A2 - Hook specific address data ("object," e.g, GadgetInfo)
+ *
+ * Control will be passed to the routine h_Entry.  For many
+ * High-Level Languages (HLL), this will be an assembly language
+ * stub which pushes registers on the stack, does other setup,
+ * and then calls the function at h_SubEntry.
+ *
+ * The C standard receiving code is:
+ * CDispatcher( hook, object, message )
+ *     struct Hook      *hook;
+ *     APTR             object;
+ *     APTR             message;
+ *
+ * NOTE that register natural order differs from this convention
+ * for C parameter order, which is A0,A2,A1.
+ *
+ * The assembly language stub for "vanilla" C parameter conventions
+ * could be:
+
+ _hookEntry:
+        move.l  a1,-(sp)                ; push message packet pointer
+        move.l  a2,-(sp)                ; push object pointer
+        move.l  a0,-(sp)                ; push hook pointer
+        move.l  h_SubEntry(a0),a0       ; fetch C entry point ...
+        jsr     (a0)                    ; ... and call it
+        lea     12(sp),sp               ; fix stack
+        rts
+
+ * with this function as your interface stub, you can write
+ * a Hook setup function as:
+
+ SetupHook( hook, c_function, userdata )
+ struct Hook    *hook;
+ ULONG          (*c_function)();
+ VOID           *userdata;
+
+        ULONG   (*hookEntry)();
+
+        hook->h_Entry =         hookEntry;
+        hook->h_SubEntry =      c_function;
+        hook->h_Data =                  userdata;
+
+
+ * with Lattice C pragmas, you can put the C function in the
+ * h_Entry field directly if you declare the function:
+
+ULONG __saveds __asm
+CDispatcher(    register __a0 struct Hook       *hook,
+                register __a2 VOID              *object,
+                register __a1 ULONG             *message );
+ *
+ ***}
+
+ {      Namespace definitions      }
+
+
+Type
+{ The named object structure }
+ pNamedObject = ^tNamedObject;
+ tNamedObject = record
+    no_Object  : Pointer;       { Your pointer, for whatever you want }
+ END;
+
+const
+{ Tags for AllocNamedObject() }
+ ANO_NameSpace  = 4000;    { Tag to define namespace      }
+ ANO_UserSpace  = 4001;    { tag to define userspace      }
+ ANO_Priority   = 4002;    { tag to define priority       }
+ ANO_Flags      = 4003;    { tag to define flags          }
+
+{ Flags for tag ANO_Flags }
+ NSB_NODUPS     = 0;
+ NSB_CASE       = 1;
+
+ NSF_NODUPS     = 1;      { Default allow duplicates }
+ NSF_CASE       = 2;      { Default to caseless... }
+
+
+   {    Control attributes for Pack/UnpackStructureTags() }
+
+
+{ PackTable definition:
+ *
+ * The PackTable is a simple array of LONGWORDS that are evaluated by
+ * PackStructureTags() and UnpackStructureTags().
+ *
+ * The table contains compressed information such as the tag offset from
+ * the base tag. The tag offset has a limited range so the base tag is
+ * defined in the first longword.
+ *
+ * After the first longword, the fields look as follows:
+ *
+ *      +--------- 1 = signed, 0 = unsigned (for bits, 1=inverted boolean)
+ *      |
+ *      |  +------ 00 = Pack/Unpack, 10 = Pack, 01 = Unpack, 11 = special
+ *      | / \
+ *      | | |  +-- 00 = Byte, 01 = Integer, 10 = Long, 11 = Bit
+ *      | | | / \
+ *      | | | | | /----- For bit operations: 1 = TAG_EXISTS is TRUE
+ *      | | | | | |
+ *      | | | | | | /-------------------- Tag offset from base tag value
+ *      | | | | | | |                 \
+ *      m n n o o p q q q q q q q q q q r r r s s s s s s s s s s s s s
+ *                                      \   | |               |
+ *      Bit offset (for bit operations) ----/ |               |
+ *                                            \                       |
+ *      Offset into data structure -----------------------------------/
+ *
+ * A -1 longword signifies that the next longword will be a new base tag
+ *
+ * A 0 longword signifies that it is the end of the pack table.
+ *
+ * What this implies is that there are only 13-bits of address offset
+ * and 10 bits for tag offsets from the base tag.  For most uses this
+ * should be enough, but when this is not, either multiple pack tables
+ * or a pack table with extra base tags would be able to do the trick.
+ * The goal here was to make the tables small and yet flexible enough to
+ * handle most cases.
+ }
+
+const
+ PSTB_SIGNED =31;
+ PSTB_UNPACK =30;    { Note that these are active low... }
+ PSTB_PACK   =29;    { Note that these are active low... }
+ PSTB_EXISTS =26;    { Tag exists bit true flag hack...  }
+
+ PSTF_SIGNED = $80000000;
+ PSTF_UNPACK = $40000000;
+ PSTF_PACK   = $20000000;
+
+ PSTF_EXISTS = $4000000;
+
+
+{***************************************************************************}
+
+
+ PKCTRL_PACKUNPACK = $00000000;
+ PKCTRL_PACKONLY   = $40000000;
+ PKCTRL_UNPACKONLY = $20000000;
+
+ PKCTRL_BYTE       = $80000000;
+ PKCTRL_WORD       = $88000000;
+ PKCTRL_LONG       = $90000000;
+
+ PKCTRL_UBYTE      = $00000000;
+ PKCTRL_UWORD      = $08000000;
+ PKCTRL_ULONG      = $10000000;
+
+ PKCTRL_BIT        = $18000000;
+ PKCTRL_FLIPBIT    = $98000000;
+
+
+{***************************************************************************}
+
+
+{ Macros used by the next batch of macros below. Normally, you don't use
+ * this batch directly. Then again, some folks are wierd
+ }
+
+
+
+{***************************************************************************}
+
+
+{ Some handy dandy macros to easily create pack tables
+ *
+ * Use PACK_STARTTABLE() at the start of a pack table. You pass it the
+ * base tag value that will be handled in the following chunk of the pack
+ * table.
+ *
+ * PACK_ENDTABLE() is used to mark the end of a pack table.
+ *
+ * PACK_NEWOFFSET() lets you change the base tag value used for subsequent
+ * entries in the table
+ *
+ * PACK_ENTRY() lets you define an entry in the pack table. You pass it the
+ * base tag value, the tag of interest, the type of the structure to use,
+ * the field name in the structure to affect and control bits (combinations of
+ * the various PKCTRL_XXX bits)
+ *
+ * PACK_BYTEBIT() lets you define a bit-control entry in the pack table. You
+ * pass it the same data as PACK_ENTRY, plus the flag bit pattern this tag
+ * affects. This macro should be used when the field being affected is byte
+ * sized.
+ *
+ * PACK_WORDBIT() lets you define a bit-control entry in the pack table. You
+ * pass it the same data as PACK_ENTRY, plus the flag bit pattern this tag
+ * affects. This macro should be used when the field being affected is Integer
+ * sized.
+ *
+ * PACK_LONGBIT() lets you define a bit-control entry in the pack table. You
+ * pass it the same data as PACK_ENTRY, plus the flag bit pattern this tag
+ * affects. This macro should be used when the field being affected is longword
+ * sized.
+ *
+ * EXAMPLE:
+ *
+ *    ULONG packTable[] =
+ *    (
+ *         PACK_STARTTABLE(GA_Dummy),
+ *         PACK_ENTRY(GA_Dummy,GA_Left,Gadget,LeftEdge,PKCTRL_WORD|PKCTRL_PACKUNPACK),
+ *         PACK_ENTRY(GA_Dummy,GA_Top,Gadget,TopEdge,PKCTRL_WORD|PKCTRL_PACKUNPACK),
+ *         PACK_ENTRY(GA_Dummy,GA_Width,Gadget,Width,PKCTRL_UWORD|PKCTRL_PACKUNPACK),
+ *         PACK_ENTRY(GA_Dummy,GA_Height,Gadget,Height,PKCTRL_UWORD|PKCTRL_PACKUNPACK),
+ *         PACK_WORDBIT(GA_Dummy,GA_RelVerify,Gadget,Activation,PKCTRL_BIT|PKCTRL_PACKUNPACK,GACT_RELVERIFY)
+ *         PACK_ENDTABLE
+ *    );
+ }
+
+
+{ ======================================================================= }
+{ ==== TagItem ========================================================== }
+{ ======================================================================= }
+{ This data type may propagate through the system for more general use.
+ * In the meantime, it is used as a general mechanism of extensible data
+ * arrays for parameter specification and property inquiry (coming soon
+ * to a display controller near you).
+ *
+ * In practice, an array (or chain of arrays) of TagItems is used.
+ }
+Type
+    Tag = LongInt;
+    pTag = ^Tag;
+
+    pTagItem = ^tTagItem;
+    tTagItem = record
+     ti_Tag  : Tag;
+     ti_Data : LongInt;
+    END;
+
+    ppTagItem = ^pTagItem;
+
+{ ---- system tag values ----------------------------- }
+CONST
+ TAG_DONE          = 0; { terminates array of TagItems. ti_Data unused }
+ TAG_END           = TAG_DONE;
+ TAG_IGNORE        = 1; { ignore this item, not END of array           }
+ TAG_MORE          = 2; { ti_Data is pointer to another array of TagItems
+                         * note that this tag terminates the current array
+                         }
+ TAG_SKIP          = 3; { skip this AND the next ti_Data items         }
+
+{ differentiates user tags from control tags }
+ TAG_USER          = $80000000;    { differentiates user tags from system tags}
+
+{* If the TAG_USER bit is set in a tag number, it tells utility.library that
+ * the tag is not a control tag (like TAG_DONE, TAG_IGNORE, TAG_MORE) and is
+ * instead an application tag. "USER" means a client of utility.library in
+ * general, including system code like Intuition or ASL, it has nothing to do
+ * with user code.
+ *}
+
+
+{ Tag filter logic specifiers for use with FilterTagItems() }
+ TAGFILTER_AND     = 0;       { exclude everything but filter hits   }
+ TAGFILTER_NOT     = 1;       { exclude only filter hits             }
+
+{ Mapping types for use with MapTags() }
+ MAP_REMOVE_NOT_FOUND = 0;  { remove tags that aren't in mapList }
+ MAP_KEEP_NOT_FOUND   = 1;  { keep tags that aren't in mapList   }
+
+
+
+Type
+ tUtilityBase = record
+    ub_LibNode   : tLibrary;
+    ub_Language  : Byte;
+    ub_Reserved  : Byte;
+ END;
+
+function AddNamedObject(nameSpace,
+                        obj : pNamedObject) : Boolean;
+function AllocateTagItems(num : ULONG) : pTagItem;
+function AllocNamedObjectA(name : STRPTR;
+                           TagList : pTagItem) : pNamedObject;
+procedure Amiga2Date(amigatime : ULONG;
+                     resultat : pClockData);
+procedure ApplyTagChanges(TagList,
+                          ChangeList : pTagItem);
+function AttemptRemNamedObject(obj : pNamedObject) : LongInt;
+function CallHookPkt(h : pHook;
+                     obj, paramPkt : APTR) : ULONG;
+function CheckDate(date : pClockData) : ULONG;
+function CloneTagItems(tagList : pTagItem) : pTagItem;
+function Date2Amiga(date : pClockData) : ULONG;
+procedure FilterTagChanges(changelist, oldvalues : pTagItem;
+                           apply : ULONG);
+function FilterTagItems(taglist : pTagItem ;
+                        tagArray : Pointer;
+                        logic : ULONG) : ULONG;
+function FindNamedObject(nameSpace : pNamedObject;
+                         name : STRPTR;
+                         lastobject: pNamedObject) : pNamedObject;
+function FindTagItem(TagVal : Tag;
+                     TagList : pTagItem) : pTagItem;
+procedure FreeNamedObject(Obj : pNamedObject);
+procedure FreeTagItems(TagList : pTagItem);
+function GetTagData(tagval : Tag;
+                    default : ULONG;
+                    TagList : pTagItem) : ULONG;
+function GetUniqueID : ULONG;
+procedure MapTags(TagList : pTagItem;
+                  maplist : pTagItem;
+                  IncludeMiss : ULONG);
+function NamedObjectName(Obj : pNamedObject) : STRPTR;
+function NextTagItem(Item : ppTagItem) : pTagItem;
+function PackBoolTags(InitialFlags : ULONG;
+                      TagList, boolmap : pTagItem) : ULONG;
+function PackStructureTags(packk: APTR;
+                           packTable : Pointer;
+                           TagList : pTagItem) : ULONG;
+procedure RefreshTagItemClones(cloneTagItems,
+                               OriginalTagItems : pTagItem);
+procedure ReleaseNamedObject(Obj : pNamedObject);
+procedure RemNamedObject(Obj : pNamedObject;
+                         Msg : pointer);
+function SDivMod32( dividend , divisor : LongInt) : LongInt;
+function SMult32(Arg1, Arg2 : LongInt) : LongInt;
+function SMult64(Arg1, Arg2 : LongInt) : LongInt;
+function Stricmp(Str1, Str2 : STRPTR) : LongInt;
+function Strnicmp(Str1, Str2 : STRPTR;
+                  len : LongInt) : LongInt;
+function TagInArray(t : Tag;
+                    TagArray : Pointer) : Boolean;
+function ToLower(c : ULONG) : Char;
+function ToUpper(c : ULONG) : Char;
+function UDivMod32( dividend , divisor : ULONG) : ULONG;
+function UMult32(Arg1, Arg2 : ULONG) : ULONG;
+function UMult64(Arg1, Arg2 : ULONG) : ULONG;
+function UnpackStructureTags(pac: APTR;
+                             packTable: Pointer;
+                             TagList : pTagItem) : ULONG;
+
+IMPLEMENTATION
+
+function AddNamedObject(nameSpace,
+                        obj : pNamedObject) : Boolean;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  nameSpace,a0
+       MOVE.L  obj,a1
+       MOVE.L  _UtilityBase,A6
+       JSR -222(A6)
+       MOVE.L  (A7)+,A6
+       TST.L   d0
+       bne     @success
+       bra     @end
+   @success:
+       move.b  #1,d0
+   @end:
+       move.b  d0,@RESULT
+   end;
+end;
+
+function AllocateTagItems(num : ULONG) : pTagItem;
+begin
+  asm
+      MOVE.L  A6,-(A7)
+      MOVE.L  num,d0
+      MOVE.L  _UtilityBase,A6
+      JSR -066(A6)
+      MOVE.L  (A7)+,A6
+      MOVE.L  d0,@RESULT
+  end;
+end;
+
+function AllocNamedObjectA(name : STRPTR;
+                           TagList : pTagItem) : pNamedObject;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  name,a0
+       MOVE.L  TagList,a1
+       MOVE.L  _UtilityBase,A6
+       JSR -228(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+procedure Amiga2Date(amigatime : ULONG;
+                     resultat : pClockData);
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  amigatime,d0
+       MOVE.L  resultat,a0
+       MOVE.L  _UtilityBase,A6
+       JSR -120(A6)
+       MOVE.L  (A7)+,A6
+   end;
+end;
+
+procedure ApplyTagChanges(TagList,
+                          ChangeList : pTagItem);
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  TagList,a0
+       MOVE.L  ChangeList,a1
+       MOVE.L  _UtilityBase,A6
+       JSR -186(A6)
+       MOVE.L  (A7)+,A6
+   end;
+end;
+
+function AttemptRemNamedObject(obj : pNamedObject) : LongInt;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  obj,a0
+       MOVE.L  _UtilityBase,A6
+       JSR -234(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function CallHookPkt(h : pHook;
+                     obj, paramPkt : APTR) : ULONG;
+begin
+   asm
+       MOVEM.L a2/a6,-(A7)
+       MOVE.L  h,a0
+       MOVE.L  obj,a2
+       MOVE.L  paramPkt,a1
+       MOVE.L  _UtilityBase,A6
+       JSR -102(A6)
+       MOVEM.L (A7)+,a2/a6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function CheckDate(date : pClockData) : ULONG;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  date,a0
+       MOVE.L  _UtilityBase,A6
+       JSR -132(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function CloneTagItems(tagList : pTagItem) : pTagItem;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  taglist,a0
+       MOVE.L  _UtilityBase,A6
+       JSR -072(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function Date2Amiga(date : pClockData) : ULONG;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  date,a0
+       MOVE.L  _UtilityBase,A6
+       JSR -126(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+procedure FilterTagChanges(changelist, oldvalues : pTagItem;
+                           apply : ULONG);
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  changelist,a0
+       MOVE.L  oldvalues,a1
+       MOVE.L  apply,d0
+       MOVE.L  _UtilityBase,A6
+       JSR -054(A6)
+       MOVE.L  (A7)+,A6
+   end;
+end;
+
+function FilterTagItems(taglist : pTagItem ;
+                        tagArray : Pointer;
+                        logic : ULONG) : ULONG;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  taglist,a0
+       MOVE.L  tagArray,a1
+       MOVE.L  logic,d0
+       MOVE.L  _UtilityBase,A6
+       JSR -096(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function FindNamedObject(nameSpace : pNamedObject;
+                         name : STRPTR;
+                         lastobject: pNamedObject) : pNamedObject;
+begin
+   asm
+       MOVEM.L a2/a6,-(A7)
+       MOVE.L  nameSpace,a0
+       MOVE.L  name,a1
+       MOVE.L  lastobject,a2
+       MOVE.L  _UtilityBase,A6
+       JSR -240(A6)
+       MOVEM.L (A7)+,a2/a6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function FindTagItem(TagVal : Tag;
+                     TagList : pTagItem) : pTagItem;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  TagVal,d0
+       MOVE.L  TagList,a0
+       MOVE.L  _UtilityBase,A6
+       JSR -030(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+procedure FreeNamedObject(Obj : pNamedObject);
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Obj,a0
+       MOVE.L  _UtilityBase,A6
+       JSR -246(A6)
+       MOVE.L  (A7)+,A6
+   end;
+end;
+
+procedure FreeTagItems(TagList : pTagItem);
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  TagList,a0
+       MOVE.L  _UtilityBase,A6
+       JSR -078(A6)
+       MOVE.L  (A7)+,A6
+   end;
+end;
+
+function GetTagData(tagval : Tag;
+                    default : ULONG;
+                    TagList : pTagItem) : ULONG;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  tagval,d0
+       MOVE.L  default,d1
+       MOVE.L  TagList,a0
+       MOVE.L  _UtilityBase,A6
+       JSR -036(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function GetUniqueID : ULONG;
+begin
+   asm
+      MOVE.L  A6,-(A7)
+      MOVE.L  _UtilityBase,A6
+      JSR -270(A6)
+      MOVE.L  (A7)+,A6
+      MOVE.L  d0,@RESULT
+   end;
+end;
+
+procedure MapTags(TagList : pTagItem;
+                  maplist : pTagItem;
+                  IncludeMiss : ULONG);
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  TagList,a0
+       MOVE.L  maplist,a1
+       MOVE.L  IncludeMiss,d0
+       MOVE.L  _UtilityBase,A6
+       JSR -060(A6)
+       MOVE.L  (A7)+,A6
+   end;
+end;
+
+function NamedObjectName(Obj : pNamedObject) : STRPTR;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Obj,a0
+       MOVE.L  _UtilityBase,A6
+       JSR -252(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function NextTagItem(Item : ppTagItem) : pTagItem;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Item,a0
+       MOVE.L  _UtilityBase,A6
+       JSR -048(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function PackBoolTags(InitialFlags : ULONG;
+                      TagList, boolmap : pTagItem) : ULONG;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  InitialFlags,d0
+       MOVE.L  TagList,a0
+       MOVE.L  boolmap,a1
+       MOVE.L  _UtilityBase,A6
+       JSR -042(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function PackStructureTags(packk: APTR;
+                           packTable : Pointer;
+                           TagList : pTagItem) : ULONG;
+begin
+   asm
+       MOVEM.L a2/a6,-(A7)
+       MOVE.L  packk,a0
+       MOVE.L  packTable,a1
+       MOVE.L  TagList,a2
+       MOVE.L  _UtilityBase,A6
+       JSR -210(A6)
+       MOVEM.L (A7)+,a2/a6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+procedure RefreshTagItemClones(cloneTagItems,
+                               OriginalTagItems : pTagItem);
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  cloneTagItems,a0
+       MOVE.L  OriginalTagItems,a1
+       MOVE.L  _UtilityBase,A6
+       JSR -084(A6)
+       MOVE.L  (A7)+,A6
+   end;
+end;
+
+procedure ReleaseNamedObject(Obj : pNamedObject);
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Obj,a0
+       MOVE.L  _UtilityBase,A6
+       JSR -258(A6)
+       MOVE.L  (A7)+,A6
+   end;
+end;
+
+procedure RemNamedObject(Obj : pNamedObject;
+                         Msg : pointer);
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Obj,a0
+       MOVE.L  Msg,a1
+       MOVE.L  _UtilityBase,A6
+       JSR -264(A6)
+       MOVE.L  (A7)+,A6
+   end;
+end;
+
+function SDivMod32( dividend , divisor : LongInt) : LongInt;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  dividend,d0
+       MOVE.L  divisor,d1
+       MOVE.L  _UtilityBase,A6
+       JSR -150(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function SMult32(Arg1, Arg2 : LongInt) : LongInt;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Arg1,d0
+       MOVE.L  Arg2,d1
+       MOVE.L  _UtilityBase,A6
+       JSR -138(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function SMult64(Arg1, Arg2 : LongInt) : LongInt;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Arg1,d0
+       MOVE.L  Arg2,d1
+       MOVE.L  _UtilityBase,A6
+       JSR -198(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function Stricmp(Str1, Str2 : STRPTR) : LongInt;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Str1,a0
+       MOVE.L  Str2,a1
+       MOVE.L  _UtilityBase,A6
+       JSR -162(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function Strnicmp(Str1, Str2 : STRPTR;
+                  len : LongInt) : LongInt;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Str1,a0
+       MOVE.L  Str2,a1
+       MOVE.L  len,d0
+       MOVE.L  _UtilityBase,A6
+       JSR -168(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function TagInArray(t : Tag;
+                    TagArray : Pointer) : Boolean;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  t,d0
+       MOVE.L  TagArray,a0
+       MOVE.L  _UtilityBase,A6
+       JSR -090(A6)
+       MOVE.L  (A7)+,A6
+       TST.L   d0
+       bne     @success
+       bra     @end
+   @success:
+       move.b  #1,d0
+   @end:
+       move.b  d0,@RESULT
+   end;
+end;
+
+function ToLower(c : ULONG) : Char;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  c,d0
+       MOVE.L  _UtilityBase,A6
+       JSR -180(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.B  d0,@RESULT
+   end;
+end;
+
+function ToUpper(c : ULONG) : Char;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  c,d0
+       MOVE.L  _UtilityBase,A6
+       JSR -174(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.B  d0,@RESULT
+   end;
+end;
+
+function UDivMod32( dividend , divisor : ULONG) : ULONG;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  dividend,d0
+       MOVE.L  divisor,d1
+       MOVE.L  _UtilityBase,A6
+       JSR -156(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function UMult32(Arg1, Arg2 : ULONG) : ULONG;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Arg1,d0
+       MOVE.L  Arg2,d1
+       MOVE.L  _UtilityBase,A6
+       JSR -144(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function UMult64(Arg1, Arg2 : ULONG) : ULONG;
+begin
+   asm
+       MOVE.L  A6,-(A7)
+       MOVE.L  Arg1,d0
+       MOVE.L  Arg2,d1
+       MOVE.L  _UtilityBase,A6
+       JSR -204(A6)
+       MOVE.L  (A7)+,A6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+function UnpackStructureTags(pac: APTR;
+                             packTable: Pointer;
+                             TagList : pTagItem) : ULONG;
+begin
+   asm
+       MOVEM.L a2/a6,-(A7)
+       MOVE.L  pac,a0
+       MOVE.L  packTable,a1
+       MOVE.L  TagList,a2
+       MOVE.L  _UtilityBase,A6
+       JSR -216(A6)
+       MOVEM.L (A7)+,a2/a6
+       MOVE.L  d0,@RESULT
+   end;
+end;
+
+end.
+
+
+
+
+
+
+
+
+

+ 335 - 0
packages/extra/amunits/units/workbench.pas

@@ -0,0 +1,335 @@
+{
+    This file is part of the Free Pascal run time library.
+
+    A file in Amiga system run time library.
+    Copyright (c) 1998 by Nils Sjoholm
+    member of the Amiga RTL development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+unit workbench;
+
+INTERFACE
+
+uses exec,amigados,utility, intuition;
+
+
+Type
+
+    pWBArg = ^tWBArg;
+    tWBArg = record
+        wa_Lock         : Pointer;      { a lock descriptor }
+        wa_Name         : STRPTR;       { a string relative to that lock }
+    end;
+
+    WBArgList = Array [1..100] of tWBArg; { Only 1..smNumArgs are valid }
+    pWBArgList = ^WBArgList;
+
+
+    pWBStartup = ^tWBStartup;
+    tWBStartup = record
+        sm_Message      : tMessage;      { a standard message structure }
+        sm_Process      : pMsgPort;   { the process descriptor for you }
+        sm_Segment      : BPTR;         { a descriptor for your code }
+        sm_NumArgs      : Longint;      { the number of elements in ArgList }
+        sm_ToolWindow   : STRPTR;       { description of window }
+        sm_ArgList      : pWBArgList; { the arguments themselves }
+    end;
+
+
+Const
+
+    WBDISK              = 1;
+    WBDRAWER            = 2;
+    WBTOOL              = 3;
+    WBPROJECT           = 4;
+    WBGARBAGE           = 5;
+    WBDEVICE            = 6;
+    WBKICK              = 7;
+    WBAPPICON           = 8;
+
+Type
+
+    pOldDrawerData = ^tOldDrawerData;
+    tOldDrawerData = record
+        dd_NewWindow    : tNewWindow;    { args to open window }
+        dd_CurrentX     : Longint;      { current x coordinate of origin }
+        dd_CurrentY     : Longint;      { current y coordinate of origin }
+    end;
+
+Const
+
+{ the amount of DrawerData actually written to disk }
+
+    OLDDRAWERDATAFILESIZE  = 56;  { sizeof(OldDrawerData) }
+
+Type
+    pDrawerData = ^tDrawerData;
+    tDrawerData = record
+        dd_NewWindow    : tNewWindow;    { args to open window }
+        dd_CurrentX     : Longint;      { current x coordinate of origin }
+        dd_CurrentY     : Longint;      { current y coordinate of origin }
+        dd_Flags        : Longint;      { flags for drawer }
+        dd_ViewModes    : Word;        { view mode for drawer }
+    end;
+
+Const
+
+{ the amount of DrawerData actually written to disk }
+
+    DRAWERDATAFILESIZE  = 62;  { sizeof(DrawerData) }
+
+
+Type
+
+    pDiskObject = ^tDiskObject;
+    tDiskObject = record
+        do_Magic        : Word;        { a magic number at the start of the file }
+        do_Version      : Word;        { a version number, so we can change it }
+        do_Gadget       : tGadget;       { a copy of in core gadget }
+        do_Type         : Byte;
+        do_DefaultTool  : STRPTR;
+        do_ToolTypes    : Pointer;
+        do_CurrentX     : Pointer;
+        do_CurrentY     : Longint;
+        do_DrawerData   : pDrawerData;
+        do_ToolWindow   : STRPTR;       { only applies to tools }
+        do_StackSize    : Longint;      { only applies to tools }
+    end;
+
+Const
+
+    WB_DISKMAGIC        = $e310;        { a magic number, not easily impersonated }
+    WB_DISKVERSION      = 1;            { our current version number }
+    WB_DISKREVISION     = 1;            { our current revision number }
+  {I only use the lower 8 bits of Gadget.UserData for the revision # }
+    WB_DISKREVISIONMASK = 255;
+Type
+    pFreeList = ^tFreeList;
+    tFreeList = record
+        fl_NumFree      : Integer;
+        fl_MemList      : tList;
+    end;
+
+Const
+
+{ each message that comes into the WorkBenchPort must have a type field
+ * in the preceeding short.  These are the defines for this type
+ }
+
+    MTYPE_PSTD          = 1;    { a "standard Potion" message }
+    MTYPE_TOOLEXIT      = 2;    { exit message from our tools }
+    MTYPE_DISKCHANGE    = 3;    { dos telling us of a disk change }
+    MTYPE_TIMER         = 4;    { we got a timer tick }
+    MTYPE_CLOSEDOWN     = 5;    { <unimplemented> }
+    MTYPE_IOPROC        = 6;    { <unimplemented> }
+    MTYPE_APPWINDOW     = 7;    {     msg from an app window }
+    MTYPE_APPICON       = 8;    {     msg from an app icon }
+    MTYPE_APPMENUITEM   = 9;    {     msg from an app menuitem }
+    MTYPE_COPYEXIT      = 10;   {     exit msg from copy process }
+    MTYPE_ICONPUT       = 11;   {     msg from PutDiskObject in icon.library }
+
+
+{ workbench does different complement modes for its gadgets.
+ * It supports separate images, complement mode, and backfill mode.
+ * The first two are identical to intuitions GADGIMAGE and GADGHCOMP.
+ * backfill is similar to GADGHCOMP, but the region outside of the
+ * image (which normally would be color three when complemented)
+ * is flood-filled to color zero.
+ }
+
+    GFLG_GADGBACKFILL   = $0001;
+    GADGBACKFILL        = $0001;   { an old synonym }
+
+{ if an icon does not really live anywhere, set its current position
+ * to here
+ }
+
+    NO_ICON_POSITION    = $80000000;
+
+{    If you find am_Version >= AM_VERSION, you know this structure has
+ * at least the fields defined in this version of the include file
+ }
+ AM_VERSION   =   1;
+
+Type
+   pAppMessage = ^tAppMessage;
+   tAppMessage = record
+    am_Message       : tMessage;            {    standard message structure }
+    am_Type          : Word;              {    message type }
+    am_UserData      : ULONG;            {    application specific }
+    am_ID            : ULONG;            {    application definable ID }
+    am_NumArgs       : ULONG;            {    # of elements in arglist }
+    am_ArgList       : pWBArgList;       {    the arguements themselves }
+    am_Version       : Word;              {    will be AM_VERSION }
+    am_Class         : Word;              {    message class }
+    am_MouseX        : Integer;              {    mouse x position of event }
+    am_MouseY        : Integer;              {    mouse y position of event }
+    am_Seconds       : ULONG;            {    current system clock time }
+    am_Micros        : ULONG;            {    current system clock time }
+    am_Reserved      : Array[0..7] of ULONG;       {    avoid recompilation }
+   END;
+
+{* types of app messages *}
+const
+    AMTYPE_APPWINDOW   = 7;    {* app window message    *}
+    AMTYPE_APPICON     = 8;    {* app icon message  *}
+    AMTYPE_APPMENUITEM = 9;    {* app menu item message *}
+
+{
+ * The following structures are private.  These are just stub
+ * structures for code compatibility...
+ }
+type
+
+ tAppWindow = record
+   aw_PRIVATE : Pointer;
+ END;
+ pAppWindow = ^tAppWindow;
+
+ tAppIcon = record
+   ai_PRIVATE : Pointer;
+ END;
+ pAppIcon = ^tAppIcon;
+
+ tAppMenuItem = record
+   ami_PRIVATE : Pointer;
+ END;
+ pAppMenuItem = ^tAppMenuItem;
+
+
+CONST
+    WORKBENCHNAME : PChar  = 'workbench.library';
+
+VAR
+    WorkbenchBase : pLibrary;
+
+FUNCTION AddAppIconA(id : ULONG; userdata : ULONG; text : pCHAR; msgport : pMsgPort; lock : pFileLock; diskobj : pDiskObject; taglist : pTagItem) : pAppIcon;
+FUNCTION AddAppMenuItemA(id : ULONG; userdata : ULONG; text : pCHAR; msgport : pMsgPort; taglist : pTagItem) : pAppMenuItem;
+FUNCTION AddAppWindowA(id : ULONG; userdata : ULONG; window : pWindow; msgport : pMsgPort; taglist : pTagItem) : pAppWindow;
+FUNCTION RemoveAppIcon(appIcon : pAppIcon) : BOOLEAN;
+FUNCTION RemoveAppMenuItem(appMenuItem : pAppMenuItem) : BOOLEAN;
+FUNCTION RemoveAppWindow(appWindow : pAppWindow) : BOOLEAN;
+PROCEDURE WBInfo(lock : BPTR; name : pCHAR; screen : pScreen);
+
+IMPLEMENTATION
+
+FUNCTION AddAppIconA(id : ULONG; userdata : ULONG; text : pCHAR; msgport : pMsgPort; lock : pFileLock; diskobj : pDiskObject; taglist : pTagItem) : pAppIcon;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  id,D0
+    MOVE.L  userdata,D1
+    MOVEA.L text,A0
+    MOVEA.L msgport,A1
+    MOVEA.L lock,A2
+    MOVEA.L diskobj,A3
+    MOVEA.L taglist,A4
+    MOVEA.L WorkbenchBase,A6
+    JSR -060(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AddAppMenuItemA(id : ULONG; userdata : ULONG; text : pCHAR; msgport : pMsgPort; taglist : pTagItem) : pAppMenuItem;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  id,D0
+    MOVE.L  userdata,D1
+    MOVEA.L text,A0
+    MOVEA.L msgport,A1
+    MOVEA.L taglist,A2
+    MOVEA.L WorkbenchBase,A6
+    JSR -072(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION AddAppWindowA(id : ULONG; userdata : ULONG; window : pWindow; msgport : pMsgPort; taglist : pTagItem) : pAppWindow;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVE.L  id,D0
+    MOVE.L  userdata,D1
+    MOVEA.L window,A0
+    MOVEA.L msgport,A1
+    MOVEA.L taglist,A2
+    MOVEA.L WorkbenchBase,A6
+    JSR -048(A6)
+    MOVEA.L (A7)+,A6
+    MOVE.L  D0,@RESULT
+  END;
+END;
+
+FUNCTION RemoveAppIcon(appIcon : pAppIcon) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L appIcon,A0
+    MOVEA.L WorkbenchBase,A6
+    JSR -066(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION RemoveAppMenuItem(appMenuItem : pAppMenuItem) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L appMenuItem,A0
+    MOVEA.L WorkbenchBase,A6
+    JSR -078(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+FUNCTION RemoveAppWindow(appWindow : pAppWindow) : BOOLEAN;
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L appWindow,A0
+    MOVEA.L WorkbenchBase,A6
+    JSR -054(A6)
+    MOVEA.L (A7)+,A6
+    TST.W   D0
+    BEQ.B   @end
+    MOVEQ   #1,D0
+  @end: MOVE.B  D0,@RESULT
+  END;
+END;
+
+PROCEDURE WBInfo(lock : BPTR; name : pCHAR; screen : pScreen);
+BEGIN
+  ASM
+    MOVE.L  A6,-(A7)
+    MOVEA.L lock,A0
+    MOVEA.L name,A1
+    MOVEA.L screen,A2
+    MOVEA.L WorkbenchBase,A6
+    JSR -090(A6)
+    MOVEA.L (A7)+,A6
+  END;
+END;
+
+END. (* UNIT WB *)
+
+
+