Browse Source

atari: add missing bios/xbios/gemdos functions

todo: Some newer MiNT functions
Thorsten Otto 3 years ago
parent
commit
f10fe0985a

+ 2 - 0
packages/tosunits/fpmake.pp

@@ -30,6 +30,8 @@ begin
 
 
     T:=P.Targets.AddUnit('gemdos.pas');
     T:=P.Targets.AddUnit('gemdos.pas');
     T:=P.Targets.AddUnit('xbios.pas');
     T:=P.Targets.AddUnit('xbios.pas');
+    T:=P.Targets.AddUnit('bios.pas');
+    T:=P.Targets.AddUnit('tos.pas');
     T:=P.Targets.AddUnit('vdi.pas');
     T:=P.Targets.AddUnit('vdi.pas');
     T:=P.Targets.AddUnit('aes.pas');
     T:=P.Targets.AddUnit('aes.pas');
 
 

+ 117 - 0
packages/tosunits/src/bios.pas

@@ -0,0 +1,117 @@
+{
+    Copyright (c) 2016 by Free Pascal development team
+
+    BIOS interface unit for Atari TOS
+
+    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 bios;
+
+interface
+
+const
+{* Device codes for Bconin(), Bconout(), Bcostat(), Bconstat() *}
+    _PRT    = 0;
+    _AUX    = 1;
+    _CON    = 2;
+    _MIDI   = 3;
+    _IKBD   = 4;
+    _RAWCON = 5;
+
+    DEV_PRINTER     = _PRT;
+    DEV_AUX         = _AUX;
+    DEV_CONSOLE     = _CON;
+    DEV_MIDI        = _MIDI;
+    DEV_IKBD        = _IKBD;
+    DEV_RAW         = _RAWCON;
+
+{* Mode bitmask used in Rwabs() *}
+    RW_READ         = 0;
+    RW_WRITE        = 0;
+    RW_NOMEDIACH    = 1;
+    RW_NORETRIES    = 2;
+    RW_NOTRANSLATE  = 3;
+
+{* Vector numbers used in Setexc() *}
+    VEC_BUSERROR    = $02;
+    VEC_ADDRESSERROR    = $03;
+    VEC_ILLEGALINSTRUCTION  = $04;
+    VEC_GEMDOS      = $21;
+    VEC_GEM         = $22;
+    VEC_BIOS        = $2d;
+    VEC_XBIOS       = $2e;
+    VEC_TIMER       = $100;
+    VEC_CRITICALERROR   = $101;
+    VEC_CRITICALERR = VEC_CRITICALERROR;
+    VEC_TERMINATE   = $102;
+    VEC_PROCTERM    = VEC_TERMINATE;
+    VEC_INQUIRE:    Pointer = Pointer(-1);
+
+{* Values returned by Mediach() *}
+    MED_NOCHANGE    = 0;
+    MED_UNKNOWN     = 1;
+    MED_CHANGED     = 2;
+
+{* Mode bitmask for Kbshift() *}
+    K_RSHIFT        = $0001;
+    K_LSHIFT        = $0002;
+    K_SHIFT         = $0003;
+    K_CTRL          = $0004;
+    K_ALT           = $0008;
+    K_CAPSLOCK      = $0010;
+    K_CLRHOME       = $0020;
+    K_INSERT        = $0040;
+
+
+type
+    PMD = ^TMD;
+    TMD = record
+        m_link :        PMD;
+        m_start :       Pointer;
+        m_length :      LongInt;
+        m_own :         Pointer; {* to PD *}
+    end;
+
+    PMPB = ^TMPB;
+    TMPB = record
+        mp_mfl :        PMD;
+        mp_mal :        PMD;
+        mp_rover :      PMD;
+    end;
+
+    PBPB = ^TBPB;
+    TBPB = record
+        recsiz :        word;
+        clsiz :         word;
+        clsizb :        word;
+        rdlen :         word;
+        fsiz :          word;
+        fatrec :        word;
+        datrec :        word;
+        numcl :         word;
+        bflags :        word;
+    end;
+
+procedure bios_Getmpb(var p_mpb: TMPB); syscall 13 0;
+function bios_Bconstat(dev: smallint): smallint; syscall 13 1;
+function bios_Bconin(dev: smallint): LongInt; syscall 13 2;
+procedure bios_Bconout(dev, c: smallint); syscall 13 3;
+function bios_Rwabs(rwflag: smallint; buf: Pointer; count, recno, dev: smallint; lrecno: LongInt): LongInt; syscall 13 4;
+function bios_Setexc(vecnum: smallint; vec: Pointer): Pointer; syscall 13 5;
+function bios_Tickcal: LongInt; syscall 13 6;
+function bios_Getbpb(dev: smallint): PBPB; syscall 13 7;
+function bios_Bcostat(dev: smallint): LongInt; syscall 13 8;
+function bios_Mediach(dev: smallint): LongInt; syscall 13 9;
+function bios_Drvmap: LongInt; syscall 13 10;
+function bios_Kbshift(mode: smallint): LongInt; syscall 13 11;
+
+implementation
+
+end.

+ 170 - 16
packages/tosunits/src/gemdos.pas

@@ -17,7 +17,7 @@ unit gemdos;
 interface
 interface
 
 
 { The API description of this file is based on the information available
 { The API description of this file is based on the information available
-  online at: http://toshyp.atari.org }
+  online at: https://freemint.github.io/tos.hyp/en/index.html }
 
 
 const
 const
     E_OK        = 0;       // OK. No error has arisen
     E_OK        = 0;       // OK. No error has arisen
@@ -86,6 +86,50 @@ const
 
 
     MXALLOC_NO_FREE          = (1 shl 14);
     MXALLOC_NO_FREE          = (1 shl 14);
 
 
+// as used by pexec
+const
+    PE_LOADGO           = 0;          {* load & go *}
+    PE_LOAD             = 3;          {* just load *}
+    PE_GO               = 4;          {* just go *}
+    PE_CBASEPAGE        = 5;          {* just create basepage *}
+    PE_GO_FREE          = 6;          {* just go, then free *}
+    PE_CBASEPAGE_FLAGS  = 7;          {* create basepage defining the program flags *}
+    {* MiNT/MagiC *}
+    PE_ASYNC_LOADGO     = 100;        {* load and asynchronously go *}
+    PE_INIT             = 101;        {* Inherits path- and file-handles (MagiC) *}
+    PE_TERM             = 102;        {* The process will be deleted (MagiC) *}
+    PE_ASYNC_GO         = 104;        {* asynchronously go *}
+    PE_ASYNC_GO_FREE    = 106;        {* asynchronously go and free *}
+    PE_XBASE            = 107;        {* As Mode 7, but in place of a command line the process name will be passed. (MagiC) *}
+    PE_EXACC            = 108;        {* Used internally by MagiC for starting an ACC *}
+    PE_OVERLAY          = 200;        {* load and overlay   *}
+    PE_OVERLAY_GO       = 204;        {* overlay and go *}
+    PE_OVERLAY_GO_FREE  = 206;        {* overlay, go and free *}
+    PE_PTRACE           = $8000;      {* activate tracing *}
+
+// Sconfig - Modes
+    SC_GETCONF   = 0;                 {* KAOS 1.2 *}
+    SC_SETCONF   = 1;                 {* KAOS 1.2 *}
+    SC_DOSVARS   = 2;                 {* KAOS 1.4 *}
+    SC_MOWNER    = 3;                 {* MagiC 3.00 *}
+    SC_WBACK     = 4;                 {* MagiC 4.01 *}
+    SC_INTMAVAIL = 5;                 {* MagiC 4.01 *}
+    SC_INTGARBC  = 6;                 {* MagiC 4.01 *}
+
+// Sconfig Bits
+    SCB_PTHCK   = $001;               {* KAOS 1.2 *}
+    SCB_DSKCH   = $002;               {* KAOS 1.2 *}
+    SCB_BREAK   = $004;               {* KAOS 1.2 *}
+    SCB_NCTLC   = $008;               {* KAOS 1.2 *}
+    SCB_NFAST   = $010;               {* KAOS 1.2 *}
+    SCB_CMPTB   = $020;               {* KAOS 1.4 *}
+    SCB_NSMRT   = $040;               {* KAOS 1.4 *}
+    SCB_NGRSH   = $080;               {* KAOS 1.4 *}
+    SCB_NHALT   = $100;               {* KAOS 1.4 *}
+    SCB_RESVD   = $200;               {* KAOS 1.4 *}
+    SCB_PULLM   = $400;               {* KAOS 1.4 *}
+    SCB_FLPAR   = $800;               {* MagiC 3.0 *}
+
 type
 type
     PDTA = ^TDTA;
     PDTA = ^TDTA;
     TDTA = packed record
     TDTA = packed record
@@ -169,47 +213,157 @@ function gemdos_maddalt(start: pointer; size: longint): longint; syscall 1 20;
 function gemdos_srealloc(len: longint): longint; syscall 1 21;
 function gemdos_srealloc(len: longint): longint; syscall 1 21;
 
 
 function gemdos_dgetdrv: smallint; syscall 1 25;
 function gemdos_dgetdrv: smallint; syscall 1 25;
-procedure gemdos_setdta(buf: PDTA); syscall 1 26;
+procedure gemdos_fsetdta(buf: PDTA); syscall 1 26;
 
 
 function gemdos_super(stack: pointer): longint; syscall 1 32;
 function gemdos_super(stack: pointer): longint; syscall 1 32;
 
 
-function gemdos_tgetdate: longint; syscall 1 42;
-function gemdos_tsetdate(date: word): smallint; syscall 1 43;
-function gemdos_tgettime: longint; syscall 1 44;
-function gemdos_tsettime(time: word): smallint; syscall 1 45;
+function gemdos_tgetdate: word; syscall 1 42;
+function gemdos_tsetdate(date: word): word; syscall 1 43;
+function gemdos_tgettime: word; syscall 1 44;
+function gemdos_tsettime(time: word): word; syscall 1 45;
 
 
-function gemdos_getdta: PDTA; syscall 1 47;
+function gemdos_fgetdta: PDTA; syscall 1 47;
 function gemdos_sversion: smallint; syscall 1 48;
 function gemdos_sversion: smallint; syscall 1 48;
+procedure gemdos_ptermres(keepcnt: longint; returncode: smallint); syscall 1 49;
+function gemdos_sconfig(mode: smallint; flags: longint): longint; syscall 1 51;
 
 
-function gemdos_dfree(buf: PDISKINFO; driveno: smallint): smallint; syscall 1 54;
+function gemdos_dfree(var buf: TDISKINFO; driveno: smallint): smallint; syscall 1 54;
 
 
 function gemdos_dcreate(const path: pchar): longint; syscall 1 57;
 function gemdos_dcreate(const path: pchar): longint; syscall 1 57;
 function gemdos_ddelete(const path: pchar): longint; syscall 1 58;
 function gemdos_ddelete(const path: pchar): longint; syscall 1 58;
-function gemdos_dsetpath(path: pchar): smallint; syscall 1 59;
-function gemdos_fcreate(fname: pchar; attr: smallint): smallint; syscall 1 60;
-function gemdos_fopen(fname: pchar; mode: smallint): longint; syscall 1 61;
+function gemdos_dsetpath(const path: pchar): smallint; syscall 1 59;
+function gemdos_fcreate(const fname: pchar; attr: smallint): smallint; syscall 1 60;
+function gemdos_fopen(const fname: pchar; mode: smallint): longint; syscall 1 61;
 function gemdos_fclose(handle: smallint): smallint; syscall 1 62;
 function gemdos_fclose(handle: smallint): smallint; syscall 1 62;
 function gemdos_fread(handle: smallint; count: longint; buf: pointer): longint; syscall 1 63;
 function gemdos_fread(handle: smallint; count: longint; buf: pointer): longint; syscall 1 63;
 function gemdos_fwrite(handle: smallint; count: longint; buf: pointer): longint; syscall 1 64;
 function gemdos_fwrite(handle: smallint; count: longint; buf: pointer): longint; syscall 1 64;
-function gemdos_fdelete(fname: pchar): smallint; syscall 1 65;
+function gemdos_fdelete(const fname: pchar): smallint; syscall 1 65;
 function gemdos_fseek(offset: longint; handle: smallint; seekmode: smallint): longint; syscall 1 66;
 function gemdos_fseek(offset: longint; handle: smallint; seekmode: smallint): longint; syscall 1 66;
-function gemdos_fattrib(filename: pchar; wflag: smallint; attrib: smallint): smallint; syscall 1 67;
+function gemdos_fattrib(const filename: pchar; wflag: smallint; attrib: smallint): smallint; syscall 1 67;
 function gemdos_mxalloc(amount: longint; mode: smallint): pointer; syscall 1 68;
 function gemdos_mxalloc(amount: longint; mode: smallint): pointer; syscall 1 68;
 function gemdos_fdup(handle: smallint): smallint; syscall 1 69;
 function gemdos_fdup(handle: smallint): smallint; syscall 1 69;
 function gemdos_fforce(stdh: smallint; nonstdh: smallint): smallint; syscall 1 70;
 function gemdos_fforce(stdh: smallint; nonstdh: smallint): smallint; syscall 1 70;
 function gemdos_dgetpath(path: pchar; driveno: smallint): smallint; syscall 1 71;
 function gemdos_dgetpath(path: pchar; driveno: smallint): smallint; syscall 1 71;
 function gemdos_malloc(number: dword): pointer; syscall 1 72;
 function gemdos_malloc(number: dword): pointer; syscall 1 72;
-function gemdos_free(block: pointer): dword; syscall 1 73;
+function gemdos_mfree(block: pointer): dword; syscall 1 73;
 function gemdos_mshrink(zero: word; block: pointer; newsiz: longint): longint; syscall 1 74;
 function gemdos_mshrink(zero: word; block: pointer; newsiz: longint): longint; syscall 1 74;
 function gemdos_pexec(mode: word; name: pchar; cmdline: pchar; env: pchar): longint; syscall 1 75;
 function gemdos_pexec(mode: word; name: pchar; cmdline: pchar; env: pchar): longint; syscall 1 75;
 procedure gemdos_pterm(returncode: smallint); syscall 1 76;
 procedure gemdos_pterm(returncode: smallint); syscall 1 76;
 
 
-function gemdos_fsfirst(filename: pchar; attr: smallint): longint; syscall 1 78;
+function gemdos_fsfirst(const filename: pchar; attr: smallint): longint; syscall 1 78;
 function gemdos_fsnext: smallint; syscall 1 79;
 function gemdos_fsnext: smallint; syscall 1 79;
 
 
-function gemdos_frename(zero: word; oldname: pchar; newname: pchar): longint; syscall 1 86;
+function gemdos_frename(zero: word; const oldname: pchar; const newname: pchar): longint; syscall 1 86;
 procedure gemdos_fdatime(timeptr: PDOSTIME; handle: smallint; wflag: smallint); syscall 1 87;
 procedure gemdos_fdatime(timeptr: PDOSTIME; handle: smallint; wflag: smallint); syscall 1 87;
 
 
+function gemdos_Flock(handle, mode: smallint; start, length: LongInt): LongInt; syscall 1 92;
+
+{ MiNT extensions }
+
+type
+    PMSGTYPE = ^TMSGTYPE;
+    TMSGTYPE = record
+        msg1:              LongInt;
+        msg2:              LongInt;
+        pid:               SmallInt;
+    end;
+
+    PXATTR = ^TXATTR;
+    TXATTR = record
+        mode:              Word;
+        index:             LongInt;
+        dev:               Word;
+        rdev:              Word;
+        nlink:             Word;
+        uid:               Word;
+        gid:               Word;
+        size:              LongInt;
+        blksize:           LongInt;
+        nblocks:           LongInt;
+        mtime:             Word;
+        mdate:             Word;
+        atime:             Word;
+        adate:             Word;
+        ctime:             Word;
+        cdate:             Word;
+        attr:              Word;
+        reserved2:         Word;
+        reserved3:         Array[0..1] of LongInt;
+    end;
+
+    PSIGACTION = ^TSIGACTION;
+    TSIGACTION = record
+        sa_handler:        Pointer;
+        sa_mask:           LongInt;
+        sa_flags:          Integer;
+    end;
+
+function gemdos_Syield: smallint; syscall 1 255;
+function gemdos_Fpipe(var usrh: ARRAY of smallint): smallint; syscall 1 256;
+function gemdos_Ffchown(fd, uid, gid: smallint): longint; syscall 1 257;
+function gemdos_Ffchmod(fd: smallint; mode: word): longint; syscall 1 258;
+function gemdos_Fsync(fd: smallint): longint; syscall 1 259;
+function gemdos_Fcntl(f: smallint; arg: LongInt; cmd: smallint): smallint; syscall 1 260;
+function gemdos_Finstat(f: smallint): LongInt; syscall 1 261;
+function gemdos_Foutstat(f: smallint): LongInt; syscall 1 262;
+function gemdos_Fgetchar(f, mode: smallint): LongInt; syscall 1 263;
+function gemdos_Fputchar(f: smallint; c: LongInt; mode: smallint): LongInt; syscall 1 264;
+function gemdos_Pwait: LongInt; syscall 1 265;
+function gemdos_Pnice(delta : smallint): smallint; syscall 1 266;
+function gemdos_Pgetpid: smallint; syscall 1 267;
+function gemdos_Pgetppid: smallint; syscall 1 268;
+function gemdos_Pgetpgrp: smallint; syscall 1 269;
+function gemdos_Psetpgrp(pid, newgrp: smallint): smallint; syscall 1 270;
+function gemdos_Pgetuid: smallint; syscall 1 271;
+function gemdos_Psetuid(id: smallint): smallint; syscall 1 272;
+function gemdos_Pkill(pid, sig: smallint): smallint; syscall 1 273;
+function gemdos_Psignal(sig: smallint; handler: Pointer): Pointer; syscall 1 274;
+function gemdos_Pvfork: smallint; syscall 1 275;
+function gemdos_Pgetgid: smallint; syscall 1 276;
+function gemdos_Psetgid(id : smallint): smallint; syscall 1 277;
+function gemdos_Psigblock(mask: LongInt): LongInt; syscall 1 278;
+function gemdos_Psigsetmask(mask: LongInt): LongInt; syscall 1 279;
+function gemdos_Pusrval(arg: LongInt): LongInt; syscall 1 280;
+function gemdos_Pdomain(newdom: smallint): smallint; syscall 1 281;
+procedure gemdos_Psigreturn; syscall 1 282;
+function gemdos_Pfork: smallint; syscall 1 283;
+function gemdos_Pwait3(flag: smallint; var rusage: ARRAY of LongInt): LongInt; syscall 1 284;
+function gemdos_Fselect(timeout: Word; var rfds, wfds, xfds: LongInt): smallint; syscall 1 285;
+function gemdos_Prusage(var r: ARRAY of LongInt): LongInt; syscall 1 286;
+function gemdos_Psetlimit(lim: smallint; value: LongInt): LongInt; syscall 1 287;
+function gemdos_Talarm(secs: LongInt): LongInt; syscall 1 288;
+procedure gemdos_Pause; syscall 1 289;
+function gemdos_Sysconf(n: smallint): LongInt; syscall 1 290;
+function gemdos_Psigpending: LongInt; syscall 1 291;
+function gemdos_Dpathconf(const name: PChar; n: smallint): LongInt; syscall 1 292;
+function gemdos_Pmsg(mode: smallint; mbox: LongInt; var msg: TMSGTYPE): LongInt; syscall 1 293;
+function gemdos_Fmidipipe(pid, inp, outp: smallint): LongInt; syscall 1 294;
+function gemdos_Prenice(pid, delta: smallint): smallint; syscall 1 295;
+function gemdos_Dopendir(const name: PChar; flag: smallint): LongInt; syscall 1 296;
+function gemdos_Dreaddir(buflen: smallint; dir: LongInt; buf: Pchar): LongInt; syscall 1 297;
+function gemdos_Drewinddir(dir: LongInt): LongInt; syscall 1 298;
+function gemdos_Dclosedir(dir: LongInt): LongInt; syscall 1 299;
+function gemdos_Fxattr(flag: smallint; const name: Pchar; var buf: TXATTR): LongInt; syscall 1 300;
+function gemdos_Flink(const oldname: PChar; const newname: Pchar): LongInt; syscall 1 301;
+function gemdos_Fsymlink(const oldname: PChar; const newname: Pchar): LongInt; syscall 1 302;
+function gemdos_Freadlink(size: smallint; buf: Pchar; const name: Pchar): LongInt; syscall 1 303;
+function gemdos_Dcntl(cmd: smallint; const name: pchar; arg: LongInt): LongInt; syscall 1 304;
+function gemdos_Fchown(const name: Pchar; uid, gid: smallint): LongInt; syscall 1 305;
+function gemdos_Fchmod(const name: Pchar; mode: smallint): LongInt; syscall 1 306;
+function gemdos_Pumask(mode: Word): LongInt; syscall 1 307;
+function gemdos_Psemaphore(mode: smallint; id, timeout: LongInt): LongInt; syscall 1 308;
+function gemdos_Dlock(mode, drive: smallint): LongInt; syscall 1 309;
+procedure gemdos_Psigpause(mask: LongInt); syscall 1 310;
+function gemdos_Psigaction(sig: smallint; act, oact: PSIGACTION): LongInt; syscall 1 311;
+function gemdos_Pgeteuid: smallint; syscall 1 312;
+function gemdos_Pgetegid: smallint; syscall 1 313;
+function gemdos_Pwaitpid(pid, flag: smallint; var rusage: ARRAY of LongInt): LongInt; syscall 1 314;
+function gemdos_Dgetcwd(path: Pchar; drv, size: smallint): LongInt; syscall 1 315;
+procedure gemdos_Salert(str: Pchar); syscall 1 316;
+function gemdos_Tmalarm(time: longint): LongInt; syscall 1 317;
+{ function gemdos_Psigintr(vec, sig: smallint): LongInt; syscall 1 318; }
+function gemdos_Suptime(var uptime: longint; var loadaverage: longint): LongInt; syscall 1 319;
+
 implementation
 implementation
 
 
 end.
 end.

+ 55 - 0
packages/tosunits/src/metados.pas

@@ -0,0 +1,55 @@
+{
+    Copyright (c) 2016 by Free Pascal development team
+
+    XBIOS interface unit for Atari TOS (MetaDOS functions)
+
+    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 metados;
+
+interface
+
+type
+{* Available from MetaDOS version 2.30 *}
+	PMETAINFO2 = ^TMETAINFO2;
+	TMETAINFO2 = record
+		version: word;
+		magic: longint;
+		log2phys: Pointer;
+	end;
+
+{* Structure used by Metainit() *}
+	PMETAINFO = ^TMETAINFO;
+	TMETAINFO = record
+		drivemap:		LongInt;
+		version:		Pchar;
+		reserved:		LongInt;
+	    info: PMETAINFO2;	{* Available from MetaDOS version 2.30 *}
+	end;
+
+	PMETA_DRVINFO = ^TMETA_DRVINFO;
+	TMETA_DRVINFO = record
+		name: PChar;
+		reserved:		array[0..2] of LongInt;
+	end;
+
+
+procedure xbios_Metainit(var buffer: TMETAINFO); syscall 14 48;
+function xbios_Metaopen(drive: smallint; var buffer: TMETA_DRVINFO): LongInt; syscall 14 49;
+function xbios_Metaclose(drive: smallint): LongInt; syscall 14 50;
+function xbios_Metaread(drive: smallint; buffer: Pointer; blockno: LongInt; count: smallint): LongInt; syscall 14 51;
+function xbios_Metawrite(drive: smallint; buffer: Pointer; blockno: LongInt; count: smallint): LongInt; syscall 14 52;
+function xbios_Metaseek(drive: smallint; dummy, offset: longint): LongInt; syscall 14 53;
+function xbios_Metastatus(drive: smallint; buffer: Pointer): LongInt; syscall 14 54;
+function xbios_Metaioctl(drive: smallint; magic: LongInt; opcode: smallint; buffer: Pointer): LongInt; syscall 14 55;
+
+implementation
+
+end.

+ 567 - 0
packages/tosunits/src/tos.pas

@@ -0,0 +1,567 @@
+{
+    Copyright (c) 2016 by Free Pascal development team
+
+    GEMDOS interface unit for Atari TOS
+
+    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.
+
+ **********************************************************************}
+
+{
+    This is used for Pure-Pascal compatibility. For newly written code,
+    consider using the gemdos/bios/xbios units instead.
+}
+
+unit tos;
+
+interface
+
+uses gemdos, xbios, bios, sysutils;
+
+const
+	FO_READ		= 0;
+	FO_WRITE	= 1;
+	FO_RW		= 2;
+
+	FA_RDONLY	= $1;
+	FA_HIDDEN	= $2;
+	FA_SYSTEM	= $4;
+	FA_LABEL	= $8;
+	FA_DIREC	= $10;
+	FA_ARCH		= $20;
+	FA_SYMLINK	= $40;
+	FA_ATTRIB	= $17;
+
+type
+    DOSTIME = TDOSTIME;
+    DOSTIMEPtr = DOSTIME;
+    DISKINFO = TDISKINFO;
+    DISKINFOPtr = ^DISKINFO;
+    LINE = TLINE;
+    LINEPtr = ^LINE;
+    PD = TBASEPAGE;
+    PDPtr = ^PD;
+    MD = TMD;
+    MDPtr =^MD;
+    MPB = TMPB;
+    MPBPtr = ^MPB;
+    BPB = TBPB;
+    BPBPtr = ^BPB;
+    XATTR = TXATTR;
+    XATTRPtr = ^XATTR;
+    MSGTYPE = TMSGTYPE;
+    MSGTYPEPtr = ^MSGTYPE;
+    SIGACTION = TSIGACTION;
+    SIGACTIONPtr = ^SIGACTION;
+    MOUSE = TMOUSE;
+    MOUSEPtr = ^MOUSE;
+    IORECORD = TIORECORD;
+    IORECORDPtr = ^IORECORD;
+    KEYTAB = TKEYTAB;
+    KEYTABPtr = ^KEYTAB;
+	KBDVECS = TKBDVECS;
+	KBDVECSPtr = ^KBDVECS;
+	PBDEF = TPBDEF;
+	PBDEFPtr = ^PBDEF;
+	DSPBLOCK = TDSPBLOCK;
+	DSPBLOCKPtr = ^DSPBLOCK;
+
+	{* same as TDTA in gemdos; except that d_fname is String *}
+	DTAPtr = ^DTA;
+	DTA = record
+		d_reserved :		Array[1..21] of Byte;
+		d_attrib :			Byte;
+		d_time :			word;
+		d_date :			word;
+		d_length :			LongInt;
+		d_fname :			String[12];
+	end;
+
+(* ++++++++++++++++++++++++++++++++++++++++ *)
+(*                  BIOS                    *)
+(* ++++++++++++++++++++++++++++++++++++++++ *)
+
+procedure Getmpb(var p_mpb: TMPB); syscall 13 0;
+function Bconstat(dev: smallint): smallint; syscall 13 1;
+function Bconin(dev: smallint): LongInt; syscall 13 2;
+procedure Bconout(dev, c: smallint); syscall 13 3;
+function Rwabs(rwflag: smallint; buf: Pointer; count, recno, dev: smallint; lrecno: LongInt): LongInt; syscall 13 4;
+function Setexc(vecnum: smallint; vec: Pointer): Pointer; syscall 13 5;
+function Tickcal: LongInt; syscall 13 6;
+function Getbpb(dev: smallint): PBPB; syscall 13 7;
+function Bcostat(dev: smallint): LongInt; syscall 13 8;
+function Mediach(dev: smallint): LongInt; syscall 13 9;
+function Drvmap: LongInt; syscall 13 10;
+function Kbshift(mode: smallint): LongInt; syscall 13 11;
+
+(* ++++++++++++++++++++++++++++++++++++++++ *)
+(*                  XBIOS                   *)
+(* ++++++++++++++++++++++++++++++++++++++++ *)
+
+procedure Initmouse(typ: smallint; var param: TMOUSE; vec: Pointer); syscall 14 0;
+function Ssbrk(amount: smallint): Pointer; syscall 14 1;
+function physbase: pointer; syscall 14 2;
+function logbase: pointer; syscall 14 3;
+function getrez: longint; syscall 14 4;
+procedure setscreen(laddr: pointer; paddr: pointer; rez: smallint); syscall 14 5;
+procedure vsetscreen(laddr: pointer; paddr: pointer; rez: smallint; mode: smallint); syscall 14 5;
+procedure setpalette(palette: pointer); syscall 14 6;
+function setcolor(colornum: smallint; color: smallint): smallint; syscall 14 7;
+function Floprd(buf, filler: Pointer; devno, sectno, trackno, sideno, count: smallint): smallint; syscall 14 8;
+function Flopwr(buf, filler: Pointer; devno, sectno, trackno, sideno, count: smallint): smallint; syscall 14 9;
+function Flopfmt(buf, filler: Pointer; devno, spt, trackno, sideno, interlv: smallint; magic: LongInt; virgin: Word): smallint; syscall 14 10;
+procedure dbmsg(rsrvd: smallint; msg_num: smallint; msg_arg: longint); syscall 14 11;
+procedure Midiws(cnt: smallint; ptr: Pointer); syscall 14 12;
+procedure Mfpint(interno: smallint; vec: Pointer); syscall 14 13;
+function Iorec(devno: smallint): PIORECORD; syscall 14 14;
+function Rsconf(speed, flowctl, ucr, rsr, tsr, scr: smallint): LongInt; syscall 14 15;
+function Keytbl(unshift, shift, capslock: Pointer): PKEYTAB; syscall 14 16;
+function random: longint; syscall 14 17;
+procedure Protobt(buf: Pointer; serialno: LongInt; disktype, execflag: smallint); syscall 14 18;
+function Flopver(buf, filler: Pointer; devno, sectno, trackno, sideno, count: smallint): smallint; syscall 14 19;
+procedure Scrdmp; syscall 14 20;
+function Cursconf(mode, operand: smallint): smallint; syscall 14 21;
+procedure Settime(datetime: LongInt); syscall 14 22;
+function Gettime: LongInt; syscall 14 23;
+procedure Bioskeys; syscall 14 24;
+procedure Ikbdws(cnt: smallint; ptr: Pointer); syscall 14 25;
+procedure Jdisint(intno: smallint); syscall 14 26;
+procedure Jenabint(intno: smallint); syscall 14 27;
+function Giaccess(data: Byte; regno: smallint): Byte; syscall 14 28;
+procedure Offgibit(bitno: smallint); syscall 14 29;
+procedure Ongibit(bitno: smallint); syscall 14 30;
+procedure Xbtimer(timer, control, data: smallint; vec: Pointer); syscall 14 31;
+procedure Dosound(ptr: Pointer); syscall 14 32;
+function Setprt(config: smallint): smallint; syscall 14 33;
+function Kbdvbase: PKBDVECS; syscall 14 34;
+function Kbrate(initial, speed: smallint): smallint; syscall 14 35;
+procedure Prtblk(var defptr: TPBDEF); syscall 14 36;
+procedure vsync; syscall 14 37;
+function Supexec(codeptr: TLongIntFunc): LongInt; syscall 14 38;
+procedure Puntaes; syscall 14 39;
+function Floprate(drive, seekrate: smallint): smallint; syscall 14 41;
+function DMAread(sector: LongInt; count: smallint; buffer: Pointer; devno: smallint): LongInt; syscall 14 42;
+function DMAwrite(sector: LongInt; count: smallint; buffer: Pointer; devno: smallint): LongInt; syscall 14 43;
+function Bconmap(devno: smallint): LongInt; syscall 14 44;
+function NVMaccess(op, start, count: smallint; ptr: Pointer): smallint; syscall 14 46;
+{* 48-63 reserved for MetaDOS *}
+function Blitmode(mode: smallint): smallint; syscall 14 64;
+{* 65-79 used by CENTScreen *}
+function EsetShift(shftmode: smallint): smallint; syscall 14 80;
+function EgetShift: smallint; syscall 14 81;
+function EsetBank(bankNum: smallint): smallint; syscall 14 82;
+function EsetColor(colorNum, color: smallint): smallint; syscall 14 83;
+procedure EsetPalette(colorNum, count: smallint; palettePtr: Pointer); syscall 14 84;
+procedure EgetPalette(colorNum, count: smallint; palettePtr: Pointer); syscall 14 85;
+function EsetGray(switch: smallint): smallint; syscall 14 86;
+function EsetSmear(switch: smallint): smallint; syscall 14 87;
+function Vsetmode(modecode: smallint): smallint; syscall 14 88;
+function mon_type: smallint; syscall 14 89;
+procedure VsetSync(flag: smallint); syscall 14 90;
+function VgetSize(mode: smallint): LongInt; syscall 14 91;
+procedure VsetRGB(index, count: smallint; xrgbArray: Array of TRGB); syscall 14 93;
+procedure VgetRGB(index, count: smallint; var xrgbArray: Array of TRGB); syscall 14 94;
+function Validmode(mode: smallint): smallint; syscall 14 95;
+procedure Dsp_DoBlock(data_in: Pointer; size_in: LongInt; data_out: Pointer; size_out: LongInt); syscall 14 96;
+procedure Dsp_BlkHandShake(data_in: Pointer; size_in: LongInt; data_out: Pointer; size_out: LongInt); syscall 14 97;
+procedure Dsp_BlkUnpacked(data_in: Pointer; size_in: LongInt; data_out: Pointer; size_out: LongInt); syscall 14 98;
+procedure Dsp_InStream(data_in: Pointer; block_size, num_blocks: LongInt; var blocks_done: LongInt); syscall 14 99;
+procedure Dsp_OutStream(data_out: Pointer; block_size, num_blocks: LongInt; var blocks_done: LongInt); syscall 14 100;
+procedure Dsp_IOStream(data_in, data_out: Pointer; block_insize, block_outsize, num_blocks: LongInt;var blocks_done: LongInt); syscall 14 101;
+procedure Dsp_RemoveInterrupts(mask: smallint); syscall 14 102;
+function Dsp_GetWordSize: smallint; syscall 14 103;
+function Dsp_Lock: smallint; syscall 14 104;
+procedure Dsp_Unlock; syscall 14 105;
+procedure Dsp_Available(var xavailable, yavailable: LongInt); syscall 14 106;
+function Dsp_Reserve(xreserve, yreserve: LongInt): smallint; syscall 14 107;
+function Dsp_LoadProg(const filename: String; ability: smallint; buffer: Pointer): smallint;
+procedure Dsp_ExecProg(codeptr: Pointer; codesize: LongInt; ability: smallint); syscall 14 109;
+procedure Dsp_ExecBoot(codeptr: Pointer; codesize: LongInt; ability: smallint); syscall 14 110;
+function Dsp_LodToBinary(const filename: String; codeptr: Pointer): LongInt;
+procedure Dsp_TriggerHC(vector: smallint); syscall 14 112;
+function Dsp_RequestUniqueAbility: smallint; syscall 14 113;
+function Dsp_GetProgAbility: smallint; syscall 14 114;
+procedure Dsp_FlushSubroutines; syscall 14 115;
+function Dsp_LoadSubroutine(codeptr: Pointer; codesize: LongInt; ability: smallint): smallint; syscall 14 116;
+function Dsp_InqSubrAbility(ability: smallint): smallint; syscall 14 117;
+function Dsp_RunSubroutine(handle: smallint): smallint; syscall 14 118;
+function Dsp_Hf0(flag: smallint): smallint; syscall 14 119;
+function Dsp_Hf1(flag: smallint): smallint; syscall 14 120;
+function Dsp_Hf2: smallint; syscall 14 121;
+function Dsp_Hf3: smallint; syscall 14 122;
+procedure Dsp_BlkWords(data_in: Pointer; size_in: LongInt; data_out: Pointer; size_out: LongInt); syscall 14 123;
+procedure Dsp_BlkBytes(data_in: Pointer; size_in: LongInt; data_out: Pointer; size_out: LongInt); syscall 14 124;
+function Dsp_HStat: Byte; syscall 14 125;
+procedure Dsp_SetVectors(receiver, transmitter: Pointer); syscall 14 126;
+procedure Dsp_MultBlocks(numsend, numreceive: LongInt; sendblocks, receiveblocks: PDSPBLOCK); syscall 14 127;
+function locksnd: LongInt; syscall 14 128;
+function unlocksnd: LongInt; syscall 14 129;
+function soundcmd(mode, data: smallint): LongInt; syscall 14 130;
+function nsoundcmd(mode, data: smallint; data2: longint): LongInt; syscall 14 130;
+function setbuffer(reg: smallint; begaddr, endaddr: Pointer): LongInt; syscall 14 131;
+function setmode(mode: smallint): LongInt; syscall 14 132;
+function settracks(playtracks, rectracks: smallint): LongInt; syscall 14 133;
+function setmontracks(montrack: smallint): LongInt; syscall 14 134;
+function setinterrupt(src_inter, cause: smallint): LongInt; syscall 14 135;
+function buffoper(mode: smallint): LongInt; syscall 14 136;
+function dsptristate(dspxmit, dsprec: smallint): LongInt; syscall 14 137;
+function gpio(mode, data: smallint): LongInt; syscall 14 138;
+function devconnect(src, dst, srcclk, prescale, protocol: smallint): LongInt; syscall 14 139;
+function sndstatus(res: smallint): LongInt; syscall 14 140;
+function buffptr(bptr: Pointer): LongInt; syscall 14 141;
+
+procedure VsetMask(ormask, andmask: LongInt; overlay: smallint); syscall 14 150;
+
+(* ++++++++++++++++++++++++++++++++++++++++ *)
+(*                  GEMDOS                  *)
+(* ++++++++++++++++++++++++++++++++++++++++ *)
+
+procedure pterm0; syscall 1 0;
+function cconin: longint; syscall 1 1;
+function cconout(c: smallint): longint; syscall 1 2;
+function cauxin: longint; syscall 1 3;
+function cauxout(c: smallint): longint; syscall 1 4;
+function cprnout(c: smallint): longint; syscall 1 5;
+function crawio(c: smallint): longint; syscall 1 6;
+function crawin: longint; syscall 1 7;
+function cnecin: longint; syscall 1 8;
+procedure cconws(const str: String);
+function cconrs(buf: PLINE): longint; syscall 1 10;
+function cconis: longint; syscall 1 11;
+
+function dsetdrv(drv: smallint): longint; syscall 1 14;
+
+function cconos: smallint; syscall 1 16;
+function cprnos: smallint; syscall 1 17;
+function cauxis: smallint; syscall 1 18;
+function cauxos: smallint; syscall 1 19;
+function maddalt(start: pointer; size: longint): longint; syscall 1 20;
+function srealloc(len: longint): longint; syscall 1 21;
+
+function dgetdrv: smallint; syscall 1 25;
+procedure fsetdta(buf: DTAPtr); syscall 1 26;
+
+function super(stack: pointer): longint; syscall 1 32;
+
+function tgetdate: word; syscall 1 42;
+function tsetdate(date: word): word; syscall 1 43;
+function tgettime: word; syscall 1 44;
+function tsettime(time: word): word; syscall 1 45;
+
+function fgetdta: DTAPtr; syscall 1 47;
+function sversion: smallint; syscall 1 48;
+procedure ptermres(keepcnt: longint; returncode: smallint); syscall 1 49;
+function sconfig(mode: smallint; flags: longint): longint; syscall 1 51;
+
+function dfree(var buf: TDISKINFO; driveno: smallint): smallint; syscall 1 54;
+
+function dcreate(const path: String): longint;
+function ddelete(const path: String): longint;
+function dsetpath(const path: String): smallint;
+function fcreate(const fname: String; attr: smallint): smallint;
+function fopen(const fname: String; mode: smallint): longint;
+function fclose(handle: smallint): smallint; syscall 1 62;
+function fread(handle: smallint; count: longint; buf: pointer): longint; syscall 1 63;
+function fwrite(handle: smallint; count: longint; buf: pointer): longint; syscall 1 64;
+function fdelete(const fname: String): smallint;
+function fseek(offset: longint; handle: smallint; seekmode: smallint): longint; syscall 1 66;
+function fattrib(const filename: String; wflag: smallint; attrib: smallint): smallint;
+function mxalloc(amount: longint; mode: smallint): pointer; syscall 1 68;
+function fdup(handle: smallint): smallint; syscall 1 69;
+function fforce(stdh: smallint; nonstdh: smallint): smallint; syscall 1 70;
+function dgetpath(var path: String; driveno: smallint): smallint;
+function malloc(number: dword): pointer; syscall 1 72;
+function free(block: pointer): dword; syscall 1 73;
+function mfree(block: pointer): dword; syscall 1 73;
+function mshrink(zero: word; block: pointer; newsiz: longint): longint; syscall 1 74;
+function pexec(mode: word; const name: String; cmdline: String; env: pchar): longint;
+procedure pterm(returncode: smallint); syscall 1 76;
+
+function fsfirst(const filename: String; attr: smallint): longint;
+function fsnext: smallint;
+
+function frename(const oldname, newname: String): longint;
+procedure fdatime(timeptr: PDOSTIME; handle: smallint; wflag: smallint); syscall 1 87;
+
+function Flock(handle, mode: smallint; start, length: LongInt): LongInt; syscall 1 92;
+
+function Syield: smallint; syscall 1 255;
+function Fpipe(var usrh: ARRAY of smallint): smallint; syscall 1 256;
+function Ffchown(fd, uid, gid: smallint): longint; syscall 1 257;
+function Ffchmod(fd: smallint; mode: word): longint; syscall 1 258;
+function Fsync(fd: smallint): longint; syscall 1 259;
+function Fcntl(f: smallint; arg: LongInt; cmd: smallint): smallint; syscall 1 260;
+function Finstat(f: smallint): LongInt; syscall 1 261;
+function Foutstat(f: smallint): LongInt; syscall 1 262;
+function Fgetchar(f, mode: smallint): LongInt; syscall 1 263;
+function Fputchar(f: smallint; c: LongInt; mode: smallint): LongInt; syscall 1 264;
+function Pwait: LongInt; syscall 1 265;
+function Pnice(delta : smallint): smallint; syscall 1 266;
+function Pgetpid: smallint; syscall 1 267;
+function Pgetppid: smallint; syscall 1 268;
+function Pgetpgrp: smallint; syscall 1 269;
+function Psetpgrp(pid, newgrp: smallint): smallint; syscall 1 270;
+function Pgetuid: smallint; syscall 1 271;
+function Psetuid(id: smallint): smallint; syscall 1 272;
+function Pkill(pid, sig: smallint): smallint; syscall 1 273;
+function Psignal(sig: smallint; handler: Pointer): Pointer; syscall 1 274;
+function Pvfork: smallint; syscall 1 275;
+function Pgetgid: smallint; syscall 1 276;
+function Psetgid(id : smallint): smallint; syscall 1 277;
+function Psigblock(mask: LongInt): LongInt; syscall 1 278;
+function Psigsetmask(mask: LongInt): LongInt; syscall 1 279;
+function Pusrval(arg: LongInt): LongInt; syscall 1 280;
+function Pdomain(newdom: smallint): smallint; syscall 1 281;
+procedure Psigreturn; syscall 1 282;
+function Pfork: smallint; syscall 1 283;
+function Pwait3(flag: smallint; var rusage: ARRAY of LongInt): LongInt; syscall 1 284;
+function Fselect(timeout: Word; var rfds, wfds, xfds: LongInt): smallint; syscall 1 285;
+function Prusage(var r: ARRAY of LongInt): LongInt; syscall 1 286;
+function Psetlimit(lim: smallint; value: LongInt): LongInt; syscall 1 287;
+function Talarm(secs: LongInt): LongInt; syscall 1 288;
+procedure Pause; syscall 1 289;
+function Sysconf(n: smallint): LongInt; syscall 1 290;
+function Psigpending: LongInt; syscall 1 291;
+function Dpathconf(const name: String; n: smallint): LongInt;
+function Pmsg(mode: smallint; mbox: LongInt; var msg: TMSGTYPE): LongInt; syscall 1 293;
+function Fmidipipe(pid, inp, outp: smallint): LongInt; syscall 1 294;
+function Prenice(pid, delta: smallint): smallint; syscall 1 295;
+function Dopendir(const name: String; flag: smallint): LongInt;
+function Dreaddir(buflen: smallint; dir: LongInt; var buf: String): LongInt;
+function Drewinddir(dir: LongInt): LongInt; syscall 1 298;
+function Dclosedir(dir: LongInt): LongInt; syscall 1 299;
+function Fxattr(flag: smallint; const name: String; var buf: TXATTR): LongInt;
+function Flink(const oldname: String; const newname: String): LongInt;
+function Fsymlink(const oldname: String; const newname: String): LongInt;
+function Freadlink(size: smallint; var buf: String; const name: String): LongInt;
+function Dcntl(cmd: smallint; const name: String; arg: LongInt): LongInt;
+function Fchown(const name: String; uid, gid: smallint): LongInt;
+function Fchmod(const name: String; mode: smallint): LongInt;
+function Pumask(mode: Word): LongInt; syscall 1 307;
+function Psemaphore(mode: smallint; id, timeout: LongInt): LongInt; syscall 1 308;
+function Dlock(mode, drive: smallint): LongInt; syscall 1 309;
+procedure Psigpause(mask: LongInt); syscall 1 310;
+function Psigaction(sig: smallint; act, oact: PSIGACTION): LongInt; syscall 1 311;
+function Pgeteuid: smallint; syscall 1 312;
+function Pgetegid: smallint; syscall 1 313;
+function Pwaitpid(pid, flag: smallint; var rusage: ARRAY of LongInt): LongInt; syscall 1 314;
+function Dgetcwd(path: Pchar; drv, size: smallint): LongInt; syscall 1 315;
+procedure Salert(str: Pchar); syscall 1 316;
+function Tmalarm(time: longint): LongInt; syscall 1 317;
+{ function Psigintr(vec, sig: smallint): LongInt; syscall 1 318; }
+function Suptime(var uptime: longint; var loadaverage: longint): LongInt; syscall 1 319;
+
+(* ++++++++++++++++++++++++++++++++++++++++ *)
+(*              IMPLEMENTATION              *)
+(* ++++++++++++++++++++++++++++++++++++++++ *)
+
+implementation
+
+function Dsp_LoadProg(const filename: String; ability: smallint; buffer: Pointer): smallint;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, filename);
+  Dsp_LoadProg := xbios_Dsp_LoadProg(s, ability, buffer);
+end;
+
+function Dsp_LodToBinary(const filename: String; codeptr: Pointer): LongInt;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, filename);
+  Dsp_LodToBinary := xbios_Dsp_LodToBinary(s, codeptr);
+end;
+
+procedure cconws(const str: String);
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, str);
+  gemdos_cconws(s);
+end;
+
+function pexec(mode: word; const name: String; cmdline: String; env: pchar): longint;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, name);
+  pexec := gemdos_pexec(mode, s, @cmdline[0], env);
+end;
+
+function fsfirst(const filename: String; attr: smallint): longint;
+var s: array[0..255] of char;
+    dta: DTAPtr;
+    temp: String[12];
+begin
+  StrPCopy(s, filename);
+  fsfirst := gemdos_fsfirst(s, attr);
+  if (fsfirst = 0) then
+    begin
+      dta := Fgetdta;
+      temp := StrPas(@dta^.d_fname[0]);
+      dta^.d_fname := temp;
+    end;
+end;
+
+function fsnext: smallint;
+var dta: DTAPtr;
+    temp: String[12];
+begin
+  fsnext := gemdos_fsnext;
+  if (fsnext = 0) then
+    begin
+      dta := Fgetdta;
+      temp := StrPas(@dta^.d_fname[0]);
+      dta^.d_fname := temp;
+    end;
+end;
+
+function frename(const oldname, newname: String): longint;
+var s1: array[0..255] of char;
+    s2: array[0..255] of char;
+begin
+  StrPCopy(s1, oldname);
+  StrPCopy(s2, newname);
+  frename := gemdos_frename(0, s1, s2);
+end;
+
+function fopen(const fname: String; mode: smallint): longint;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, fname);
+  fopen := gemdos_fopen(s, mode);
+end;
+
+function fdelete(const fname: String): smallint;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, fname);
+  fdelete := gemdos_fdelete(s);
+end;
+
+function fcreate(const fname: String; attr: smallint): smallint;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, fname);
+  fcreate := gemdos_fcreate(s, attr);
+end;
+
+function fattrib(const filename: String; wflag: smallint; attrib: smallint): smallint;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, filename);
+  fattrib := gemdos_fattrib(s, wflag, attrib);
+end;
+
+function dsetpath(const path: String): smallint;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, path);
+  dsetpath := gemdos_dsetpath(s);
+end;
+
+function dgetpath(var path: String; driveno: smallint): smallint;
+var s: array[0..255] of char;
+begin
+  Dgetpath := gemdos_dgetpath(s, driveno);
+  if (Dgetpath = 0) then
+    path := StrPas(s);
+end;
+
+function ddelete(const path: String): longint;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, path);
+  Ddelete := gemdos_ddelete(s);
+end;
+
+function dcreate(const path: String): longint;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, path);
+  Dcreate := gemdos_dcreate(s);
+end;
+
+function Dpathconf(const name: String; n: smallint): LongInt;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, name);
+  Dpathconf := gemdos_dpathconf(s, n);
+end;
+
+function Dopendir(const name: String; flag: smallint): LongInt;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, name);
+  Dopendir := gemdos_dopendir(s, flag);
+end;
+
+function Dreaddir(buflen: smallint; dir: LongInt; var buf: String): LongInt;
+var s: array[0..255] of char;
+begin
+  Dreaddir := gemdos_dreaddir(buflen, dir, s);
+  if (dreaddir = 0) then
+    buf := StrPas(s);
+end;
+
+function Fxattr(flag: smallint; const name: String; var buf: TXATTR): LongInt;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, name);
+  Fxattr := gemdos_fxattr(flag, s, buf);
+end;
+
+function Flink(const oldname: String; const newname: String): LongInt;
+var s1: array[0..255] of char;
+    s2: array[0..255] of char;
+begin
+  StrPCopy(s1, oldname);
+  StrPCopy(s2, newname);
+  flink := gemdos_flink(s1, s2);
+end;
+
+function Fsymlink(const oldname: String; const newname: String): LongInt;
+var s1: array[0..255] of char;
+    s2: array[0..255] of char;
+begin
+  StrPCopy(s1, oldname);
+  StrPCopy(s2, newname);
+  fsymlink := gemdos_fsymlink(s1, s2);
+end;
+
+function Freadlink(size: smallint; var buf: String; const name: String): LongInt;
+var s1: array[0..255] of char;
+    s2: array[0..255] of char;
+begin
+  StrPCopy(s1, name);
+  if (size > 256) then
+    size := 256;
+  freadlink := gemdos_freadlink(256, s2, s1);
+  if (freadlink = 0) then
+     buf := StrPas(s2);
+end;
+
+function Dcntl(cmd: smallint; const name: String; arg: LongInt): LongInt;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, name);
+  Dcntl := gemdos_dcntl(cmd, s, arg);
+end;
+
+function Fchown(const name: String; uid, gid: smallint): LongInt;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, name);
+  Fchown := gemdos_fchown(s, uid, gid);
+end;
+
+function Fchmod(const name: String; mode: smallint): LongInt;
+var s: array[0..255] of char;
+begin
+  StrPCopy(s, name);
+  Fchmod := gemdos_fchmod(s, mode);
+end;
+
+end.

+ 710 - 3
packages/tosunits/src/xbios.pas

@@ -17,18 +17,725 @@ unit xbios;
 interface
 interface
 
 
 { The API description of this file is based on the information available
 { The API description of this file is based on the information available
-  online at: http://toshyp.atari.org }
+  online at: https://freemint.github.io/tos.hyp/en/index.html }
 
 
+const
+{* Codes used with Cursconf() *}
+    CURS_HIDE       = 0;
+    CURS_SHOW       = 1;
+    CURS_BLINK      = 2;
+    CURS_NOBLINK    = 3;
+    CURS_SETRATE    = 4;
+    CURS_GETRATE    = 5;
+
+{* Modes for Initmous() *}
+    IM_DISABLE      = 0;
+    IM_RELATIVE     = 1;
+    IM_ABSOLUTE     = 2;
+    IM_KEYCODE      = 4;
+
+    IM_YBOT         = 0;
+    IM_YTOP         = 1;
+    IM_PACKETS      = 2;
+    IM_KEYS         = 3;
+
+{* VsetScreen() modes *}
+    SCR_NOCHANGE    = -1;
+    SCR_MODECODE    = 3;
+
+    COL_INQUIRE     = -1;
+
+{* Floprd() devices *}
+    FLOP_DRIVEA     = 0;
+    FLOP_DRIVEB     = 1;
+
+{* Flopfmt() params *}
+    FLOP_NOSKEW      = 1;
+    FLOP_SKEW       = -1;
+
+    FLOP_MAGIC      = $8754321;
+    FLOP_VIRGIN     = $e5e5;
+
+    FLOPPY_DSDD     = 0;
+    FLOPPY_DSHD     = 1;
+    FLOPPY_DSED     = 2;
+
+{* Dbmsg() messages *}
+    DB_NULLSTRING   = $f000;
+    DB_COMMAND      = $f100;
+
+{* Mfpint() vector indices *}
+    MFP_PARALLEL    = 0;
+    MFP_DCD         = 1;
+    MFP_CTS         = 2;
+    MFP_BITBLT      = 3;
+    MFP_TIMERD      = 4;
+    MFP_BAUDRATE    = MFP_TIMERD;
+    MFP_200HZ       = 5;
+    MFP_ACIA        = 6;
+    MFP_DISK        = 7;
+    MFP_TIMERB      = 8;
+    MFP_HBLANK      = MFP_TIMERB;
+    MFP_TERR        = 9;
+    MFP_TBE         = 10;
+    MFP_RERR        = 11;
+    MFP_RBF         = 12;
+    MFP_TIMERA      = 13;
+    MFP_DMASOUND    = MFP_TIMERA;
+    MFP_RING        = 14;
+    MFP_MONODETECT  = 15;
+
+{* Iorec() devices *}
+    IO_SERIAL       = 0;
+    IO_KEYBOARD     = 1;
+    IO_MIDI         = 2;
+
+{* Rsconf() speeds *}
+    BAUD_19200      = 0;
+    BAUD_9600       = 1;
+    BAUD_4800       = 2;
+    BAUD_3600       = 3;
+    BAUD_2400       = 4;
+    BAUD_2000       = 5;
+    BAUD_1800       = 6;
+    BAUD_1200       = 7;
+    BAUD_600        = 8;
+    BAUD_300        = 9;
+    BAUD_200        = 10;
+    BAUD_150        = 11;
+    BAUD_134        = 12;
+    BAUD_110        = 13;
+    BAUD_75         = 14;
+    BAUD_50         = 15;
+    BAUD_INQUIRE    = -2;
+
+{* Rsconf() params *}
+    FLOW_NONE       = 0;
+    FLOW_SOFT       = 1;
+    FLOW_HARD       = 2;
+    FLOW_BOTH       = 3;
+
+    RS_RECVENABLE   = $01;
+    RS_SYNCSTRIP    = $02;
+    RS_MATCHBUSY    = $04;
+    RS_BRKDETECT    = $08;
+    RS_FRAMEERR     = $10;
+    RS_PARITYERR    = $20;
+    RS_OVERRUNERR   = $40;
+    RS_BUFFUL       = $80;
+
+    RS_ODDPARITY    = $02;
+    RS_EVENPARITY   = $00;
+    RS_PARITYENABLE = $04;
+
+    RS_NOSTOP       = $00;
+    RS_1STOP        = $08;
+    RS_15STOP       = $10;
+    RS_2STOP        = $18;
+
+    RS_8BITS        = $00;
+    RS_7BITS        = $20;
+    RS_6BITS        = $40;
+    RS_5BITS        = $60;
+
+    RS_CLK16        = $80;
+
+    RS_INQUIRE      = -1;
+    RS_LASTBAUD     = -2;
+
+{* Keytbl() param *}
+    KT_NOCHANGE : Pointer   = Pointer(-1);
+
+{* Protobt() params *}
+    SERIAL_NOCHANGE = -1;
+    SERIAL_RANDOM   = $01000001;
+
+    DISK_NOCHANGE   = -1;
+    DISK_SSSD       = 0;
+    DISK_DSSD       = 1;
+    DISK_SSDD       = 2;
+    DISK_DSDD       = 3;
+    DISK_DSHD       = 4;
+    DISK_DSED       = 5;
+
+    EXEC_NOCHANGE   = -1;
+    EXEC_NO         = 0;
+    EXEC_YES        = 1;
+
+{* Giaccess() registers *}
+    PSG_APITCHLOW   = 0;
+    PSG_APITCHHIGH  = 1;
+    PSG_BPITCHLOW   = 2;
+    PSG_BPTICHHIGH  = 3;
+    PSG_CPITCHLOW   = 4;
+    PSG_CPITCHHIGH  = 5;
+    PSG_NOISEPITCH  = 6;
+    PSG_MODE        = 7;
+    PSG_AVOLUME     = 8;
+    PSG_BVOLUME     = 9;
+    PSG_CVOLUME     = 10;
+    PSG_FREQLOW     = 11;
+    PSG_FREQHIGH    = 12;
+    PSG_ENVELOPE    = 13;
+    PSG_PORTA       = 14;
+    PSG_PORTB       = 15;
+
+    PSG_ENABLEA     = $01;
+    PSG_ENABLEB     = $02;
+    PSG_ENABLEC     = $04;
+    PSG_NOISEA      = $08;
+    PSG_NOISEB      = $10;
+    PSG_NOISEC      = $20;
+    PSG_PRTAOUT     = $40;
+    PSG_PRTBOUT     = $80;
+
+{* Bitmasks for Offgibit() *}
+    GI_FLOPPYSIDE   = $01;
+    GI_FLOPPYA      = $02;
+    GI_FLOPPYB      = $04;
+    GI_RTS          = $08;
+    GI_DTR          = $10;
+    GI_STROBE       = $20;
+    GI_GPO          = $40;
+    GI_SCCPORT      = $80;
+
+{* Xbtimer() values *}
+    XB_TIMERA       = 0;
+    XB_TIMERB       = 1;
+    XB_TIMERC       = 2;
+    XB_TIMERD       = 3;
+
+{* Dosound() param *}
+    DS_INQUIRE      = -1;
+
+{* Setprt() modes *}
+    PRT_DOTMATRIX   = $01;
+    PRT_MONO        = $02;
+    PRT_ATARI       = $04;
+    PRT_DRAFT       = $08;
+    PRT_PARALLEL    = $10;
+    PRT_CONTINUOUS  = $20;
+
+    PRT_DAISY       = $01;
+    PRT_COLOR       = $02;
+    PRT_EPSON       = $04;
+    PRT_FINAL       = $08;
+    PRT_SERIAL      = $10;
+    PRT_SINGLE      = $20;
+
+    PRT_INQUIRE     = -1;
+
+{* Kbrate() param *}
+    KB_INQUIRE      = -1;
+
+{* Floprate() seek rates *}
+    FRATE_6         = 0;
+    FRATE_12        = 1;
+    FRATE_2         = 2;
+    FRATE_3         = 3;
+    FRATE_INQUIRE   = -1;
+
+{* Bconmap() params *}
+    BMAP_CHECK      = 0;
+    BMAP_INQUIRE    = -1;
+    BMAP_MAPTAB     = -2;
+
+{* NVMaccess params *}
+    NVM_READ        = 0;
+    NVM_WRITE       = 1;
+    NVM_RESET       = 2;
+
+{* Blitmode() modes *}
+    BLIT_SOFT       = 0;
+    BLIT_HARD       = 1;
+
+{* EsetShift() modes *}
+    ST_LOW          = $0000;
+    ST_MED          = $0100;
+    ST_HIGH         = $0200;
+    TT_MED          = $0400;
+    TT_HIGH         = $0600;
+    TT_LOW          = $0700;
+
+    ES_GRAY         = 12;
+    ES_SMEAR        = 15;
+
+{* Esetbank() params *}
+    ESB_INQUIRE     = -1;
+    EC_INQUIRE      = -1;
+
+{* EsetGray() modes *}
+    ESG_INQUIRE     = -1;
+    ESG_COLOR       = 0;
+    ESG_GRAY        = 1;
+
+{* EsetSmear() modes *}
+    ESM_INQUIRE     = 1;
+    ESM_NORMAL      = 0;
+    ESM_SMEAR       = 1;
+
+{* Bitmasks for Vsetmode() *}
+    VERTFLAG    = $0100;
+    STMODES     = $0080;
+    OVERSCAN    = $0040;
+    PAL         = $0020;
+    VGA_FALCON  = $0010;
+    TV          = $0000;
+
+    COL80       = $08;
+    COL40       = $00;
+
+    BPS16       = 4;
+    BPS8        = 3;
+    BPS4        = 2;
+    BPS2        = 1;
+    BPS1        = 0;
+
+    NUMCOLS     = 7;
+
+{* Values returned by VgetMonitor() *}
+    MON_MONO        = 0;
+    MON_COLOR       = 1;
+    MON_VGA         = 2;
+    MON_TV          = 3;
+
+{* VsetSync flags - 0=internal, 1=external *}
+
+    VID_CLOCK   = 1;
+    VID_VSYNC   = 2;
+    VID_HSYNC   = 4;
+
+{* VsetSync() params *}
+    VCLK_EXTERNAL   = 0;
+    VCLK_EXTVSYNC   = 1;
+    VCLK_EXTHSYNC   = 2;
+
+    OVERLAY_ON      = 1;
+    OVERLAY_OFF     = 0;
+
+{* Bitmasks for Dsp_RemoveInterrupts() *}
+    RTS_OFF         = $01;
+    RTR_OFF         = $02;
+
+{* Dsp_Hf0() params *}
+    HF_CLEAR        = 0;
+    HF_SET          = 1;
+    HF_INQUIRE      = -1;
+
+{* Dsp_Hstat() bits *}
+    ICR_RXDF        = 0;
+    ICR_TXDE        = 1;
+    ICR_TRDY        = 2;
+    ICR_HF2         = 3;
+    ICR_HF3         = 4;
+    ICR_DMA         = 6;
+    ICR_HREQ        = 7;
+
+{* Dsp_SetVectors() params *}
+    DSPSEND_NOTHING = $00000000;
+    DSPSEND_ZERO    = $ff000000;
+
+{* Dsp_MultBlocks() params *}
+    BLOCK_LONG = 0;
+    BLOCK_WORD = 1;
+    BLOCK_UBYTE = 2;
+
+{* _SND cookie values *}
+    SND_PSG     = $01;  {* Yamaha PSG *}
+    SND_8BIT    = $02;  {* 8-bit DMA *}
+    SND_16BIT   = $04;  {* 16-bit CODEC *}
+    SND_DSP     = $08;  {* DSP *}
+    SND_MATRIX  = $10;  {* Connection matrix *}
+    SND_EXT     = $20;  {* Extended XBIOS routines (Milan, GSXB) *}
+    SND_GSXB    = SND_EXT;
+
+{* Setbuffer regions *}
+    SR_PLAY     = 0;    {* Set playback registers *}
+    SR_RECORD   = 1;    {* Set record registers *}
+
+{* Soundcmd Modes *}
+    LTATTEN     = 0;    {* Left-channel output attenuation *}
+    RTATTEN     = 1;    {* Right channel atten *}
+    LTGAIN      = 2;    {* Left input gain *}
+    RTGAIN      = 3;    {* Right channel gain *}
+    {* gain and attenuation in 1.5 dB units, $00V0, V:0-15 *}
+    ADDERIN     = 4;    {* Select inputs to adder 0=off, 1=on *}
+    ADCIN       = 1;    {* Input from ADC *}
+    MATIN       = 2;    {* Input from connection matrix *}
+    ADCINPUT    = 5;    {* Select input to ADC, 0=mic, 1=PSG *}
+    ADCRT       = 1;    {* Right channel input *}
+    ADCLT       = 2;    {* Left input *}
+    SETPRESCALE = 6;    {* Set TT compatibility prescaler *}
+    PREMUTE     = 0;    {* was /1280, now is invalid, mutes *}
+    PRE1280     = PREMUTE;
+    PRE640      = 1;    {* divide by 640 *}
+    PRE320      = 2;    {* / 320 *}
+    PRE160      = 3;    {* / 160 *}
+
+{* Record/Playback modes *}
+
+    STEREO8     = 0;    {* 8 bit stereo *}
+    STEREO16    = 1;    {* 16 bit stereo *}
+    MONO8       = 2;    {* 8 bit mono *}
+
+{* Record/Playback tracks range from 0 to 3 *}
+
+{* XXX Doc for Settracks could be clearer. Can we individually set, e.g.,
+   tracks 0 & 2 for playback, or must track selections be contiguous? *}
+
+{* Sound buffer interrupts *}
+    {* sources *}
+    SI_TIMERA   = 0;    {* Timer A interrupt *}
+    SI_MFPI7    = 1;    {* MFP interrupt 7 *}
+    {* causes *}
+    SI_NONE     = 0;    {* No interrupts *}
+    SI_PLAY     = 1;    {* Intr at end of play buffer *}
+    SI_RECORD   = 2;    {* Intr at end of record buffer *}
+    SI_BOTH     = 3;    {* Interrupt for either play or record *}
+
+{* Buffoper flags *}
+    SB_PLA_ENA  = 1;    {* Play enable *}
+    SB_PLA_RPT  = 2;    {* Play repeat (continuous loop mode) *}
+    SB_REC_ENA  = 4;    {* Record enable *}
+    SB_REC_RPT  = 8;    {* Record repeat *}
+
+{* Dsptristate - 0=tristate, 1=enable *}
+
+{* Gpio modes *}
+    GPIO_SET    = 0;    {* Set I/O direction, 0=in, 1=out *}
+    GPIO_READ   = 1;    {* Read bits - only 3 bits on gpio *}
+    GPIO_WRITE  = 2;    {* Write gpio data bits *}
+
+{* Devconnect (connection matrix) source devices *}
+    DMAPLAY     = 0;    {* DMA playback *}
+    DSPXMIT     = 1;    {* DSP transmit *}
+    EXTINP      = 2;    {* External input *}
+    ADC     = 3;    {* Microphone/PSG, see Soundcmd(ADCINPUT) *}
+
+{* Devconnect destination devices, bitmapped *}
+    DMAREC      = 1;    {* DMA record *}
+    DSPRECV     = 2;    {* DSP receive *}
+    EXTOUT      = 4;    {* External output *}
+    DAC     = 8;    {* Headphone, internal speaker, monitor *}
+
+{* Devconnect clock sources *}
+    CLK25M      = 0;    {* Internal 25.175 MHz clock *}
+    CLKEXT      = 1;    {* External clock *}
+    CLK32M      = 2;    {* Internal 32 MHz. Invalid for CODEC *}
+
+{* Devconnect clock prescaler values *}
+    CLKOLD      = 0;    {* TT compatible, see Soundcmd(SETPRESCALE) *}
+    CLK50K      = 1;    {* 49170 hz *}
+    CLK33K      = 2;    {* 32780 hz *}
+    CLK25K      = 3;    {* 24585 hz *}
+    CLK20K      = 4;    {* 19668 hz *}
+    CLK16K      = 5;    {* 16390 hz *}
+        {*  6   (14049 hz) invalid for CODEC *}
+    CLK12K      = 7;    {* 12292 hz *}
+        {*  8   (10927 hz) invalid for CODEC *}
+    CLK10K      = 9;    {* 9834 hz *}
+        {*  10  (8940 hz) invalid for CODEC *}
+    CLK8K       = 11;   {* 8195 hz *}
+        {*  12  (7565 hz) invalid *}
+        {*  13  (7024 hz) invalid *}
+        {*  14  (6556 hz) invalid *}
+        {*  15  (6146 hz) invalid *}
+
+{* Sndstatus command *}
+    SND_CHECK   = 0;    {* Check current status *}
+    SND_RESET   = 1;    {* Reset sound system *}
+    {*
+     * Reset effects: DSP tristated, gain=atten=0, matrix reset,
+     * ADDERIN=0, Mode=STEREO8, Play=Record=Monitor tracks=0,
+     * interrupts disabled, buffer operation disabled.
+     *}
+
+{* Sndstatus status return *}
+    SS_OK       = 0;    {* No errors *}
+    SS_CTRL     = 1;    {* Invalid control field (Data assumed OK) *}
+    SS_SYNC     = 2;    {* Invalid sync format (mutes) *}
+    SS_SCLK     = 3;    {* Serial clock out of valid range (mutes) *}
+
+    SS_RTCLIP   = $10;  {* Right channel is clipping *}
+    SS_LTCLIP   = $20;  {* Left channel is clipping *}
+
+    SS_ERROR    = $f;
+
+
+{* Soundcmd() params *}
+    LEFT_MIC        = $00;
+    LEFT_PSG        = $02;
+    RIGHT_MIC       = $00;
+    RIGHT_PSG       = $01;
+
+    SND_INQUIRE     = -1;
+
+{* Value returned by Locksnd() *}
+    SNDLOCKED       = -129;
+
+{* Value returned by Unlocksnd() *}
+    SNDNOTLOCK      = -128;
+
+{* Setmode() modes *}
+    MODE_STEREO8    = 0;
+    MODE_STEREO16   = 1;
+    MODE_MONO       = 2;
+
+{* Dsptristate() params *}
+    DSP_TRISTATE    = 0;
+    DSP_ENABLE      = 1;
+
+    HANDSHAKE       = 0;
+    NO_SHAKE        = 1;
+
+type
+{* Structure returned by Iorec() *}
+    PIORECORD = ^TIORECORD;
+    TIORECORD = record
+        ibuf:       Pointer;
+        ibufsiz:    smallint;
+        ibufhd:     smallint;
+        ibuftl:     smallint;
+        ibuflow:    smallint;
+        ibufhi:     smallint;
+    end;
+
+{* Structure used by Initmouse() *}
+    PMOUSE = ^TMOUSE;
+    TMOUSE = record
+        topmode:        Byte;
+        buttons:        Byte;
+        x_scale:        Byte;
+        y_scale:        Byte;
+        x_max:          smallint;
+        y_max:          smallint;
+        x_start:        smallint;
+        y_start:        smallint;
+    end;
+
+{*
+ * Structure returned by Kbdvbase()
+ * no need to declare the functions cdecl,
+ * since the arg is passed in a0 AND on stack
+ *}
+    PKBDVECS = ^TKBDVECS;
+    TKBDVECS = record
+        midivec:        Pointer;
+        vkbderr:        Pointer;
+        vmiderr:        Pointer;
+        statvec:        Pointer;
+        mousevec:       Pointer;
+        clockvec:       Pointer;
+        joyvec:         Pointer;
+        midisys:        Pointer;
+        ikdbsys:        Pointer;
+        drvstat:        Byte;
+    end;
+
+{* Structure returned by Keytbl() *}
+    PKEYTAB = ^TKEYTAB;
+    TKEYTAB = record
+        unshift:        Pointer;
+        shift:          Pointer;
+        capslock:       Pointer;
+    {* Entries below available
+     * when _AKP cookie is present.
+     *}
+        alt:            Pointer;
+        altshift:       Pointer;
+        altcaps:        Pointer;
+   {* Entry below is available
+    * on MilanTOS and as of FreeMiNT 1.16.1
+    *}
+        altgr:          Pointer;
+    end;
+
+{* Structure used by Prtblk() *}
+    PPBDEF = ^TPBDEF;
+    TPBDEF = record
+        pb_scrptr:      Pointer;
+        pb_offset:      smallint;
+        pb_width:       smallint;
+        pb_height:      smallint;
+        pb_left:        smallint;
+        pb_right:       smallint;
+        pb_screz:       smallint;
+        pb_prrez:       smallint;
+        pb_colptr:      Pointer;
+        pb_prtype:      smallint;
+        pb_prport:      smallint;
+        pb_mask:        Pointer;
+    end;
+
+{* Structure used by VgetRGB *}
+    PRGB = ^TRGB;
+    TRGB = record
+        reserved: byte;
+        red: byte;
+        green: byte;
+        blue: byte;
+    end;
+
+{* Structure used by Bconmap() *}
+    PMAPTAB = ^TMAPTAB;
+    TMAPTAB = record
+        Bconstat: Pointer;
+        Bconin: Pointer;
+        Bcostat: Pointer;
+        Bconout: Pointer;
+        Rsconf: Pointer;
+        iorec: PIORECORD;
+    end;
+
+{* Structure used by Bconmap() *}
+    PBCONMAP = ^TBCONMAP;
+    TBCONMAP = record
+        maptab: PMAPTAB;
+        maptabsize: smallint;
+    end;
+
+{* Structure used by Settime *}
+    PBIOSTIME = ^TBIOSTIME;
+    TBIOSTIME = bitpacked record
+        year: 0..127;
+        month: 0..15;
+        day: 0..31;
+        hour: 0..31;
+        minute: 0..63;
+        second: 0..31;
+    end;
+
+    PDSPBLOCK = ^TDSPBLOCK;
+    TDSPBLOCK = record
+        blocktype:      smallint;
+        blocksize:      LongInt;
+        blockaddr:      Pointer;
+    end;
+
+    PSndBuf = ^TSndBuf;
+    TSndBuf = record
+        play: Pointer;
+        record_: Pointer;
+        reserve1: longint;
+        reserve2: longint;
+    end;
+
+
+    TLongIntFunc = Function: LongInt;
+
+procedure xbios_Initmouse(typ: smallint; var param: TMOUSE; vec: Pointer); syscall 14 0;
+function xbios_Ssbrk(amount: smallint): Pointer; syscall 14 1;
 function xbios_physbase: pointer; syscall 14 2;
 function xbios_physbase: pointer; syscall 14 2;
 function xbios_logbase: pointer; syscall 14 3;
 function xbios_logbase: pointer; syscall 14 3;
 function xbios_getrez: longint; syscall 14 4;
 function xbios_getrez: longint; syscall 14 4;
 procedure xbios_setscreen(laddr: pointer; paddr: pointer; rez: smallint); syscall 14 5;
 procedure xbios_setscreen(laddr: pointer; paddr: pointer; rez: smallint); syscall 14 5;
+procedure xbios_vsetscreen(laddr: pointer; paddr: pointer; rez: smallint; mode: smallint); syscall 14 5;
 procedure xbios_setpalette(palette: pointer); syscall 14 6;
 procedure xbios_setpalette(palette: pointer); syscall 14 6;
 function xbios_setcolor(colornum: smallint; color: smallint): smallint; syscall 14 7;
 function xbios_setcolor(colornum: smallint; color: smallint): smallint; syscall 14 7;
-
+function xbios_Floprd(buf, filler: Pointer; devno, sectno, trackno, sideno, count: smallint): smallint; syscall 14 8;
+function xbios_Flopwr(buf, filler: Pointer; devno, sectno, trackno, sideno, count: smallint): smallint; syscall 14 9;
+function xbios_Flopfmt(buf, filler: Pointer; devno, spt, trackno, sideno, interlv: smallint; magic: LongInt; virgin: Word): smallint; syscall 14 10;
+procedure xbios_dbmsg(rsrvd: smallint; msg_num: smallint; msg_arg: longint); syscall 14 11;
+procedure xbios_Midiws(cnt: smallint; ptr: Pointer); syscall 14 12;
+procedure xbios_Mfpint(interno: smallint; vec: Pointer); syscall 14 13;
+function xbios_Iorec(devno: smallint): PIORECORD; syscall 14 14;
+function xbios_Rsconf(speed, flowctl, ucr, rsr, tsr, scr: smallint): LongInt; syscall 14 15;
+function xbios_Keytbl(unshift, shift, capslock: Pointer): PKEYTAB; syscall 14 16;
 function xbios_random: longint; syscall 14 17;
 function xbios_random: longint; syscall 14 17;
-
+procedure xbios_Protobt(buf: Pointer; serialno: LongInt; disktype, execflag: smallint); syscall 14 18;
+function xbios_Flopver(buf, filler: Pointer; devno, sectno, trackno, sideno, count: smallint): smallint; syscall 14 19;
+procedure xbios_Scrdmp; syscall 14 20;
+function xbios_Cursconf(mode, operand: smallint): smallint; syscall 14 21;
+procedure xbios_Settime(datetime: LongInt); syscall 14 22;
+function xbios_Gettime: LongInt; syscall 14 23;
+procedure xbios_Bioskeys; syscall 14 24;
+procedure xbios_Ikbdws(cnt: smallint; ptr: Pointer); syscall 14 25;
+procedure xbios_Jdisint(intno: smallint); syscall 14 26;
+procedure xbios_Jenabint(intno: smallint); syscall 14 27;
+function xbios_Giaccess(data: Byte; regno: smallint): Byte; syscall 14 28;
+procedure xbios_Offgibit(bitno: smallint); syscall 14 29;
+procedure xbios_Ongibit(bitno: smallint); syscall 14 30;
+procedure xbios_Xbtimer(timer, control, data: smallint; vec: Pointer); syscall 14 31;
+procedure xbios_Dosound(ptr: Pointer); syscall 14 32;
+function xbios_Setprt(config: smallint): smallint; syscall 14 33;
+function xbios_Kbdvbase: PKBDVECS; syscall 14 34;
+function xbios_Kbrate(initial, speed: smallint): smallint; syscall 14 35;
+procedure xbios_Prtblk(var defptr: TPBDEF); syscall 14 36;
 procedure xbios_vsync; syscall 14 37;
 procedure xbios_vsync; syscall 14 37;
+function xbios_Supexec(codeptr: TLongIntFunc): LongInt; syscall 14 38;
+procedure xbios_Puntaes; syscall 14 39;
+function xbios_Floprate(drive, seekrate: smallint): smallint; syscall 14 41;
+function xbios_DMAread(sector: LongInt; count: smallint; buffer: Pointer; devno: smallint): LongInt; syscall 14 42;
+function xbios_DMAwrite(sector: LongInt; count: smallint; buffer: Pointer; devno: smallint): LongInt; syscall 14 43;
+function xbios_Bconmap(devno: smallint): LongInt; syscall 14 44;
+function xbios_NVMaccess(op, start, count: smallint; ptr: Pointer): smallint; syscall 14 46;
+{* 48-63 reserved for MetaDOS *}
+function xbios_Blitmode(mode: smallint): smallint; syscall 14 64;
+{* 65-79 used by CENTScreen *}
+function xbios_EsetShift(shftmode: smallint): smallint; syscall 14 80;
+function xbios_EgetShift: smallint; syscall 14 81;
+function xbios_EsetBank(bankNum: smallint): smallint; syscall 14 82;
+function xbios_EsetColor(colorNum, color: smallint): smallint; syscall 14 83;
+procedure xbios_EsetPalette(colorNum, count: smallint; palettePtr: Pointer); syscall 14 84;
+procedure xbios_EgetPalette(colorNum, count: smallint; palettePtr: Pointer); syscall 14 85;
+function xbios_EsetGray(switch: smallint): smallint; syscall 14 86;
+function xbios_EsetSmear(switch: smallint): smallint; syscall 14 87;
+function xbios_Vsetmode(modecode: smallint): smallint; syscall 14 88;
+function xbios_mon_type: smallint; syscall 14 89;
+procedure xbios_VsetSync(flag: smallint); syscall 14 90;
+function xbios_VgetSize(mode: smallint): LongInt; syscall 14 91;
+procedure xbios_VsetRGB(index, count: smallint; xrgbArray: Array of TRGB); syscall 14 93;
+procedure xbios_VgetRGB(index, count: smallint; var xrgbArray: Array of TRGB); syscall 14 94;
+function xbios_Validmode(mode: smallint): smallint; syscall 14 95;
+procedure xbios_Dsp_DoBlock(data_in: Pointer; size_in: LongInt; data_out: Pointer; size_out: LongInt); syscall 14 96;
+procedure xbios_Dsp_BlkHandShake(data_in: Pointer; size_in: LongInt; data_out: Pointer; size_out: LongInt); syscall 14 97;
+procedure xbios_Dsp_BlkUnpacked(data_in: Pointer; size_in: LongInt; data_out: Pointer; size_out: LongInt); syscall 14 98;
+procedure xbios_Dsp_InStream(data_in: Pointer; block_size, num_blocks: LongInt; var blocks_done: LongInt); syscall 14 99;
+procedure xbios_Dsp_OutStream(data_out: Pointer; block_size, num_blocks: LongInt; var blocks_done: LongInt); syscall 14 100;
+procedure xbios_Dsp_IOStream(data_in, data_out: Pointer; block_insize, block_outsize, num_blocks: LongInt;var blocks_done: LongInt); syscall 14 101;
+procedure xbios_Dsp_RemoveInterrupts(mask: smallint); syscall 14 102;
+function xbios_Dsp_GetWordSize: smallint; syscall 14 103;
+function xbios_Dsp_Lock: smallint; syscall 14 104;
+procedure xbios_Dsp_Unlock; syscall 14 105;
+procedure xbios_Dsp_Available(var xavailable, yavailable: LongInt); syscall 14 106;
+function xbios_Dsp_Reserve(xreserve, yreserve: LongInt): smallint; syscall 14 107;
+function xbios_Dsp_LoadProg(filename: PChar; ability: smallint; buffer: Pointer): smallint; syscall 14 108;
+procedure xbios_Dsp_ExecProg(codeptr: Pointer; codesize: LongInt; ability: smallint); syscall 14 109;
+procedure xbios_Dsp_ExecBoot(codeptr: Pointer; codesize: LongInt; ability: smallint); syscall 14 110;
+function xbios_Dsp_LodToBinary(filename: PChar; codeptr: Pointer): LongInt; syscall 14 111;
+procedure xbios_Dsp_TriggerHC(vector: smallint); syscall 14 112;
+function xbios_Dsp_RequestUniqueAbility: smallint; syscall 14 113;
+function xbios_Dsp_GetProgAbility: smallint; syscall 14 114;
+procedure xbios_Dsp_FlushSubroutines; syscall 14 115;
+function xbios_Dsp_LoadSubroutine(codeptr: Pointer; codesize: LongInt; ability: smallint): smallint; syscall 14 116;
+function xbios_Dsp_InqSubrAbility(ability: smallint): smallint; syscall 14 117;
+function xbios_Dsp_RunSubroutine(handle: smallint): smallint; syscall 14 118;
+function xbios_Dsp_Hf0(flag: smallint): smallint; syscall 14 119;
+function xbios_Dsp_Hf1(flag: smallint): smallint; syscall 14 120;
+function xbios_Dsp_Hf2: smallint; syscall 14 121;
+function xbios_Dsp_Hf3: smallint; syscall 14 122;
+procedure xbios_Dsp_BlkWords(data_in: Pointer; size_in: LongInt; data_out: Pointer; size_out: LongInt); syscall 14 123;
+procedure xbios_Dsp_BlkBytes(data_in: Pointer; size_in: LongInt; data_out: Pointer; size_out: LongInt); syscall 14 124;
+function xbios_Dsp_HStat: Byte; syscall 14 125;
+procedure xbios_Dsp_SetVectors(receiver, transmitter: Pointer); syscall 14 126;
+procedure xbios_Dsp_MultBlocks(numsend, numreceive: LongInt; sendblocks, receiveblocks: PDSPBLOCK); syscall 14 127;
+function xbios_locksnd: LongInt; syscall 14 128;
+function xbios_unlocksnd: LongInt; syscall 14 129;
+function xbios_soundcmd(mode, data: smallint): LongInt; syscall 14 130;
+function xbios_nsoundcmd(mode, data: smallint; data2: longint): LongInt; syscall 14 130;
+function xbios_setbuffer(reg: smallint; begaddr, endaddr: Pointer): LongInt; syscall 14 131;
+function xbios_setmode(mode: smallint): LongInt; syscall 14 132;
+function xbios_settracks(playtracks, rectracks: smallint): LongInt; syscall 14 133;
+function xbios_setmontracks(montrack: smallint): LongInt; syscall 14 134;
+function xbios_setinterrupt(src_inter, cause: smallint): LongInt; syscall 14 135;
+function xbios_buffoper(mode: smallint): LongInt; syscall 14 136;
+function xbios_dsptristate(dspxmit, dsprec: smallint): LongInt; syscall 14 137;
+function xbios_gpio(mode, data: smallint): LongInt; syscall 14 138;
+function xbios_devconnect(src, dst, srcclk, prescale, protocol: smallint): LongInt; syscall 14 139;
+function xbios_sndstatus(res: smallint): LongInt; syscall 14 140;
+function xbios_buffptr(bptr: Pointer): LongInt; syscall 14 141;
+
+procedure xbios_VsetMask(ormask, andmask: LongInt; overlay: smallint); syscall 14 150;
 
 
 implementation
 implementation