Browse Source

qlunits: merged a modified version of a patch by Norman Dunbar, defines system variables as a record

git-svn-id: trunk@49388 -
Károly Balogh 4 years ago
parent
commit
cd5c2b8271

+ 3 - 0
.gitattributes

@@ -8823,12 +8823,15 @@ packages/qlunits/Makefile.fpc svneol=native#text/plain
 packages/qlunits/README.txt svneol=native#text/plain
 packages/qlunits/examples/mtinf.pas svneol=native#text/plain
 packages/qlunits/examples/qlcube.pas svneol=native#text/plain
+packages/qlunits/examples/sms_info.pas svneol=native#text/plain
 packages/qlunits/fpmake.pp svneol=native#text/plain
 packages/qlunits/src/qdos.pas svneol=native#text/plain
+packages/qlunits/src/qdos_sysvars.inc svneol=native#text/plain
 packages/qlunits/src/qdosfuncs.inc svneol=native#text/plain
 packages/qlunits/src/qlfloat.pas svneol=native#text/plain
 packages/qlunits/src/qlutil.pas svneol=native#text/plain
 packages/qlunits/src/sms.pas svneol=native#text/plain
+packages/qlunits/src/sms_sysvars.inc svneol=native#text/plain
 packages/qlunits/src/smsfuncs.inc svneol=native#text/plain
 packages/regexpr/Makefile svneol=native#text/plain
 packages/regexpr/Makefile.fpc svneol=native#text/plain

+ 2 - 0
packages/qlunits/README.txt

@@ -11,3 +11,5 @@ The following units are available:
 The following examples are available:
 
     qlcube - draws a 3D rotating wireframe cube with QDOS drawing functions
+    mtinf - example of using the QDOS version of the System Variables
+    sms_info - example of using the SMSQ version of the System Variables

+ 11 - 16
packages/qlunits/examples/mtinf.pas

@@ -1,7 +1,7 @@
 {
-    Copyright (c) 2021 Karoly Balogh
+    Copyright (c) 2021 Karoly Balogh and Norman Dunbar
 
-    System info/System variables access on a Sinclair QL
+    System info/System variables access on a Sinclair QL, QDOS naming
     Example program for Free Pascal's Sinclair QL support
 
     This example program is in the Public Domain under the terms of
@@ -20,20 +20,15 @@ type
 var
   job_id: longint;
   ver_ascii: longint;
-  system_vars: pbyte;
+  system_vars: pSystemVariables;
 
 function get_id_str(const id: dword): string;
-const
-  QDOS = $D2540000;
-  SMS = $53324154; { S2AT }
-  SMSQ = $534D5351; { SMSQ }
-  ARGOS_THOR = $DC010000;
 begin
   case id of
-    QDOS: get_id_str:='QDOS';
-    SMS: get_id_str:='SMS';
-    SMSQ: get_id_str:='SMSQ';
-    ARGOS_THOR: get_id_str:='Thor (ARGOS)';
+    SYSID_QL: get_id_str:='QDOS';
+    SYSID_AT: get_id_str:='Atari (SMS)';
+    SYSID_SQ: get_id_str:='SMSQ';
+    SYSID_TH: get_id_str:='Thor (ARGOS)';
   else
     get_id_str:='unknown ($'+hexstr(id,8)+')';
   end;
@@ -43,11 +38,11 @@ begin
   job_id:=mt_inf(@system_vars,@ver_ascii);
 
   writeln('Job ID:',lo(job_id),' Tag:',hi(job_id));
-  writeln('Identification: ',get_id_str(pdword(@system_vars[SV_IDENT])^));
+  writeln('Identification: ',get_id_str(system_vars^.SV_IDENT));
   writeln('Version: ',Tver(ver_ascii));
 
   writeln('System vars are at: $',hexstr(system_vars));
-  writeln('Processor type: 680',hexstr(system_vars[SV_PTYP],2));
-  writeln('Monitor mode: ',system_vars[SV_TVMOD]);
-  writeln('Random number: ',pword(@system_vars[SV_RAND])^);
+  writeln('Processor type: 680',hexstr(system_vars^.SV_PTYP,2));
+  writeln('Monitor mode: ',system_vars^.SV_TVMOD);
+  writeln('Random number: ',system_vars^.SV_RAND);
 end.

+ 49 - 0
packages/qlunits/examples/sms_info.pas

@@ -0,0 +1,49 @@
+{
+    Copyright (c) 2021 Karoly Balogh and Norman Dunbar
+
+    System info/System variables access on a Sinclair QL, SMS naming
+    Example program for Free Pascal's Sinclair QL support
+
+    This example program is in the Public Domain under the terms of
+    Unlicense: http://unlicense.org/
+
+ **********************************************************************}
+
+program sms_info;
+
+uses
+  sms;
+
+type
+  Tver = array[0..3] of char;
+
+var
+  job_id: longint;
+  ver_ascii: longint;
+  system_vars: pSystemVariables;
+
+function get_id_str(const id: dword): string;
+begin
+  case id of
+    SYSID_QL: get_id_str:='QDOS';
+    SYSID_AT: get_id_str:='Atari (SMS)';
+    SYSID_SQ: get_id_str:='SMSQ';
+    SYSID_TH: get_id_str:='Thor (ARGOS)';
+  else
+    get_id_str:='unknown ($'+hexstr(id,8)+')';
+  end;
+end;
+
+begin
+  job_id:=sms_info(@system_vars,@ver_ascii);
+
+  writeln('Job ID:',lo(job_id),' Tag:',hi(job_id));
+  writeln('Identification: ',get_id_str(system_vars^.SYS_IDNT));
+  writeln('Version: ',Tver(ver_ascii));
+
+  writeln('System vars are at: $',hexstr(system_vars));
+  writeln('Processor type: 680',hexstr(system_vars^.SYS_PTYP,2));
+  writeln('Monitor mode: ',system_vars^.SYS_TMOD);
+  writeln('Random number: ',system_vars^.SYS_RAND);
+  writeln('Real Time Clock: ',system_vars^.SYS_RTC);
+end.

+ 1 - 0
packages/qlunits/fpmake.pp

@@ -37,6 +37,7 @@ begin
     P.ExamplePath.Add('examples');
     T:=P.Targets.AddExampleProgram('qlcube.pas');
     T:=P.Targets.AddExampleProgram('mtinf.pas');
+    T:=P.Targets.AddExampleProgram('sms_info.pas');
 
 {$ifndef ALLPACKAGES}
     Run;

+ 1 - 0
packages/qlunits/src/qdos.pas

@@ -148,6 +148,7 @@ type
   qdosfuncs.inc in packages/qlunits must be kept identical to the one in rtl/sinclairql (KB). }
 
 {$i qdosfuncs.inc}
+{$i qdos_sysvars.inc}
 
 { other functions, not used/implemented by the RTL }
 

+ 147 - 0
packages/qlunits/src/qdos_sysvars.inc

@@ -0,0 +1,147 @@
+{
+    This file is part of the Free Pascal Sinclair QL support package.
+    Copyright (c) 2021 by Norman Dunbar
+
+    Include file to define the system variables record, QDOS naming
+
+    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 file holds the system variables for a QDOS system and uses
+  the QDOS (original) naming convention. ND. }
+
+Const
+  { System Identifier constants }
+  sysid_ql = $D2540000;    { QL (QDOS) system variable identifier }
+  sysid_at = $53324154;    { SMS Atari system variable identifier }
+  sysid_sq = $534D5351;    { SMSQ identifier }
+  sysid_th = $DC010000;    { Thor (ARGOS) system variable identifier }
+
+  { Display Type constants }
+  dtype_monitor = 0;
+  dtype_tv_625 = 1;
+  dtype_tv_525 = 2;
+
+Type
+  SystemVariables = record
+    sv_ident: Longint;  {$00 - system variables identifier }
+
+{
+  The following variables are the pointers which define the 
+  current state of the memory map.
+}
+    sv_cheap: Pointer;  {$04 - Start of Common Heap area }
+    sv_chpfr: Pointer; {$08 - First free space in Common Heap }
+    sv_free: Pointer;  {$0C - Start of free area }
+    sv_basic: Pointer; {$10 - Start of SuperBasic Area }
+    sv_trnsp: Pointer; {$14 - Start of Transient Program Area }
+    sv_trnfr: Pointer; {$18 - First free space in Transient Program Area }
+    sv_respr: Pointer; {$1C - Resident Procedure Area Base }
+    sv_ramt: Pointer;  {$20 - RAM Top (+1) }
+    sv_unused_24: Array [0..9] of Byte; {$24 - $2D, Unused }
+    sv_rand: Word;     {$2E - Random number }
+    sv_pollm: Word;    {$30 - Number of missed poll interrupts }
+    sv_tvmod: Byte;    {$32 - Display Type (0=normal, 1=TV PAL, 2=TV NSTC), <>2 = TV PAL }
+    sv_scrst: Byte;    {$33 - Display Frozen (0=active, <>0 = frozen) }
+    sv_mcsta: Byte;    {$34 - Copy of TV Register (MC_STAT) }
+    sv_pcint: Byte;    {$35 - Copy of Interrupt Register (PC_INTR) }
+    sv_unused_36: Byte; {$36 - Unused }
+    sv_netnr: Byte;    {$37 - Network node number }
+
+    sv_i2lst: Pointer; {$38 - Start of External Interrupt List }
+    sv_plist: Pointer; {$3C - Start of Polled Tasks List }
+    sv_shlst: Pointer; {$40 - Start of Scheduler Tasks List }
+    sv_drlst: Pointer; {$44 - Start of simple Device Driver List }
+    sv_ddlst: Pointer; {$48 - Start of Directory Driver List }
+    sv_keyq: Pointer;  {$4C - Current Keyboard Queue, 0 if none }
+    sv_trapv: Pointer; {$50 - Exception Redirection Table, 0 if none }
+
+    sv_btpnt: Pointer; {$54 - Most recent slave block entry }
+    sv_btbas: Pointer; {$58 - Start of Slave Block Table }
+    sv_bttop: Pointer; {$5C - End of Slave Block Table }
+
+    sv_jbtag: Word;    {$60   Current value of Job Tag }
+    sv_jbmax: Word;    {$62 - Highest Job Number so far }
+    sv_jbpnt: Pointer; {$64 - Current Job Table entry }
+    sv_jbbas: Pointer; {$68 - Job Table Base }
+    sv_jbtop: Pointer; {$6C - Job Table Top }
+
+    sv_chtag: Word;    {$70 - Current value of Channel Tag }
+    sv_chmax: Word;    {$72 - Highest Channel Number so far }
+    sv_chpnt: Pointer; {$74 - Last channel checked for I/O }
+    sv_chbas: Pointer; {$78 - Start of Channel Table }
+    sv_chtop: Pointer; {$7C - End of Channel Table }
+
+    sv_unused_80: Array [0..7] of Byte; {$80-$87, Unused }
+    sv_caps: Word;     {$88 - CAPS lock (0 if off, $FF00 if on) }
+    sv_arbuf: Word;    {$8A - Last Character (for auto-repeat) }
+                       { = $00xx if ALT not pressed
+                         = $xxFF if ALT pressed }
+    sv_ardel: Word;    {$8C - Repeat Delay (20ms units) }
+    sv_arfrq: Word;    {$8E - Repeat Frequency (20ms units) }
+    sv_arcnt: Word;    {$90 - Repeat Counter (decremented every 20ms) }
+    sv_cqch: Word;     {$92 - Change keyboard queue character }
+    sv_wp: Word;       {$94 - Should be MDV write protect status, but not implemented }
+    sv_sound: Word;    {$96 - Beeping? (0 if off, $FF00 if on) }
+    sv_ser1c: Pointer; {$98 - Address of SER1 input queue }
+    sv_ser2c: Pointer; {$9C - Address of SER2 input queue }
+    sv_tmode: Byte;    {$A0 - ULA transmit mode }
+                       { Bits 0-2: Baud rate number
+                         Bit 3   : 0 = SER1, 1 = SER2
+                         Bit 4   : MDV running }
+    sv_ptyp: Byte;     {$A1 - Processor Type $00=68000/8, $30=68030 etc. [SMSQ] }
+    sv_csub: Pointer;  {$A2 - Subroutine to jump to on Caps Lock }
+    sv_timo: Word;     {$A6 - Counter for timing serial output }
+    sv_timov: Word;    {$A8 - Initial value of sv_timo }
+                        {  Formula = (1200/baud+1, i.e. 
+                                     11 = 75   bps, 
+                                      5 = 300  bps, 
+                                      3 = 600  bps, 
+                                      2 = 1200 bps, 
+                                      1 = 2400 bps+) [QL] }
+    sv_fstat: Word;    {$AA - Cursor flash counter }
+
+{ 
+  The original QL had 66 unused bytes between $AC and $ED inclusive. Over time
+  these have been used by Toolkit 2, for example, for default devices etc. These
+  are defined with the SMS names as QDOS didn't have them. 
+}
+
+    sv_prgd: Pointer;  {$AC - Pointer to Program Default device }
+    sv_datd: Pointer;  {$B0 - Pointer to Data Default device }
+    sv_dstd: Pointer;  {$B4 - Pointer to Destination Default device }
+    sv_thgl: Pointer;  {$B8 - Pointer to ThinG List }
+    sv_unused_bc: Array [0..49] of Byte; {$BC-$ED Unused }
+    sv_mdrun: Byte;    {$EE - Which MDV drive is running? }
+    sv_mdcnt: Byte;    {$EF - MDV run-up run-down counter }
+    sv_mddid: Array [0..7] of Byte; {$F0 - Drive ID*4 of each microdrive [QL] }
+    sv_mdsta: Array [0..7] of Byte; {$F8 - MDV Status: 0=no pending ops [QL] }
+    sv_fsdef: Array [0..15] of Pointer; {$100 Long Pointers to File System Drive Definitions }
+    sv_unused_140: Array [0..3] of Byte; {$140 - Unused }
+    sv_xact: Byte;     {$144 - Set if TRANSLATE active [QDOS V1.10+, SMSQ, not SMS2] }
+    sv_unused_145: Byte; {$145 - Unused }
+    sv_xtab: Pointer;  {$146 - Pointer to TRANSLATE table [QDOS V1.10+, SMSQ, not SMS2] }
+    sv_erms: Pointer;  {$14A -Pointer to (QDOS) error message table [QDOS V1.10+,
+SMSQ, not SMS2] }
+    sv_unused_14e: Array [0..5] of Byte; {$014E-$0153, Unused }
+
+{
+  Offset $0154 is a table of 4 long words used by Taskmaster
+  but one which is also used by TURBO. I've used the most 
+  likely case here, Taskmaster is pretty much defunct.
+  (Famous last words?) 
+}
+
+    //sv_taskm: Array [0..3] of Longint; {$154 - 4 Long Used by Taskmaster }
+    sv_unused_154: Array [0..2] of Longint; { First 3 Taskmaster longs }
+    sv_turbo: Longint; {$160 - Used by Turbo }
+  end; 
+
+  pSystemVariables = ^SystemVariables;

+ 1 - 0
packages/qlunits/src/sms.pas

@@ -27,6 +27,7 @@ uses
   smsfuncs.inc in packages/qlunits must be kept identical to the one in rtl/sinclairql (KB). }
 
 {$i smsfuncs.inc}
+{$i sms_sysvars.inc}
 
 
 implementation

+ 226 - 0
packages/qlunits/src/sms_sysvars.inc

@@ -0,0 +1,226 @@
+{
+    This file is part of the Free Pascal Sinclair QL support package.
+    Copyright (c) 2021 by Norman Dunbar
+
+    Include file to define the system variables record, SMSQ naming
+
+    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 file holds the system variables for an SMSQ system and uses
+  the SMSQ naming convention. ND. }
+
+Const
+  { System Identifier constants }
+  sysid_ql = $D2540000;    { QL (QDOS) system variable identifier }
+  sysid_at = $53324154;    { SMS Atari system variable identifier }
+  sysid_sq = $534D5351;    { SMSQ identifier }
+  sysid_th = $DC010000;    { Thor (ARGOS) system variable identifier }
+
+  { Display Type constants }
+  dtype_monitor = 0;
+  dtype_tv_625 = 1;
+  dtype_tv_525 = 2;
+
+  { Machine Identifier constants }
+  mtype_st = 0;
+  mtype_mega_st_rtc = 2;
+  mtype_stacy = 4;
+  mtype_ste = 6;
+  mtype_mega_ste = 8;
+  mtype_gold_card = $0A;
+  mtype_super_gold_card = $0C;
+  mtype_falcon = $10;
+  mtype_q40_q60 = $11;
+  mtype_smsqmulator = $14;
+  mtype_tt = $18;
+  mtype_qxl = $1C;
+  mtype_qpc = $1E;
+
+Type
+  SystemVariables = record
+    sys_idnt: Longint;  { system variables identifier }
+
+{
+  The following variables are the pointers which define the 
+  current state of the memory map.
+}
+    sys_chpb: Pointer;  { Common HeaP Base }
+    sys_chpf: Pointer;  { Common HeaP Free space pointer }
+    sys_fsbb: Pointer;  { Filing system Slave Block area Base }
+    sys_sbab: Pointer;  { 'QL S*Basic' Area Base }
+    sys_tpab: Pointer;  { Transient Program Area Base }
+    sys_tpaf: Pointer;  { Transient Program Area Free space pointer }
+    sys_rpab: Pointer;  { Resident Procedure Area Base }
+    sys_ramt: Pointer;  { RAM Top (+1) }
+    sys_mxfr: Pointer;  { Maximum return from free memory call [SMS] }
+    sys_rtc:  Longint;  { Real time (seconds) [SMS] }
+    sys_rtcf: Word;     { Real time fractional, count down [SMS] }
+    sys_rand: Word;     { RANDom number }
+
+    sys_pict: Word;     { Polling Interupt CounT }
+    sys_dtyp: Byte;     { Display TYPe (0=normal, 1=TV 625, 2=TV 525) }
+    sys_dfrz: Byte;     { Display FRoZen (T or F) }
+    sys_qlmr: Byte;     { QL Master chip Register value (Copy of MC_STAT) }
+    sys_qlir: Byte;     { QL Interrupt Register value (Copy of PC_INTR) }
+    sys_rshd: Byte;     { True to reschedule [SMS] }
+    sys_nnnr: Byte;     { Network Node NumbeR }
+
+{
+  The following system variables are pointers to the list of
+  tasks and drivers.
+}
+
+    sys_exil: Pointer;  { EXternal Interrupt action List }
+    sys_poll: Pointer;  { POLled action List }
+    sys_shdl: Pointer;  { ScHeDuler loop action List }
+    sys_iodl: Pointer;  { IO Driver List }
+    sys_fsdl: Pointer;  { Filing System Driver List }
+    sys_ckyq: Pointer;  { Current Keyboard Queue }
+    sys_ertb: Pointer;  { Exception Redirection Table Base }
+
+{
+  The following system variables are pointers to the resource
+  management tables. The slave block tables have 8 byte 
+  entries, whilst the others have 4 byte entries.
+}
+
+    { First the slave block tables }
+
+    sys_sbrp: Pointer;  { Slave Block Running Pointer }
+    sys_sbtb: Pointer;  { Slave Block Table Base }
+    sys_sbtt: Pointer;  { Slave Block Table Top }
+
+    { Then job stuff }
+
+    sys_jbtg: Word;     { Next JoB TaG }
+    sys_jbtp: Word;     { Highest JoB in table (ToP one) }
+    sys_jbpt: Pointer;  { Current JoB PoinTer }
+    sys_jbtb: Pointer;  { JoB Table Base }
+    sys_jbtt: Pointer;  { JoB Table Top }
+
+    { Then channel stuff. (Not SuperBASIC channels) }
+
+    sys_chtg: Word;     { Next CHannel TaG }
+    sys_chtp: Word;     { Highest CHannel in table (ToP one) }
+    sys_chpt: Pointer;  { Last checked CHannel PoinTer }
+    sys_chtb: Pointer;  { CHannel Table Base }
+    sys_chtt: Pointer;  { CHannel Table Top }
+
+    { Then odds and sods }
+
+    sys_frbl: Pointer;  { FRee Block List (to return to common heap) [SMS] }
+    sys_tsdd: Byte;     { Thor flag [THOR] }
+    sys_unused_85: array [0..2] of Byte; { Unused, offset = $85, $86 and $87 }
+{
+  The following variables contain information about how to 
+  treat the keyboard, and about other aspects of the
+  IPC and serial port communications.
+}
+
+    sys_caps: Word;     { CAPS lock (0 if off, $FF00 if on) }
+    sys_lchr: Word;     { Last CHaRacter (for auto-repeat) }
+    sys_rdel: Word;     { Repeat DELay (20ms units) }
+    sys_rtim: Word;     { Repeat TIMe (20ms units) }
+    sys_rcnt: Word;     { Repeat CouNTer (decremented every 20ms) }
+    sys_swtc: Word;     { SWiTch Keyboard queues Character }
+    sys_unused_94: array [0..1] of Byte;  { Unused, offset = $94 and $95 }
+    sys_qlbp: Word;     { QL BeePing (0 if off, $FF00 if on) }
+    sys_ser1: Pointer;  { Receive channel 1 queue address [QL] }
+    sys_ser2: Pointer;  { Receive channel 2 queue address [QL] }
+    sys_tmod: Byte;     { ZX8302 transmit mode (includes baudrate) (copy of PC_TCTRL) [QL] }
+    sys_ptyp: Byte;     { Processor TYPe $00=68000/8, $30=68030 etc. [SMSQ] }
+    sys_csub: Pointer;  { Subroutine to jump to on Caps Lock }
+
+    { Sys_stmo only on QL. Sys_dmiu/sys_mtyp on everything else. }
+    // sys_stmo: Word;     { Serial xmit timeout [QL] }
+
+    sys_dmiu: Byte;     { DMA in use? [SMS2, ST, SMSQ] }
+    sys_mtyp: Byte;     { Machine TYPe [SMSQ] }
+
+    { Sys_stmv on  QL Only. Redefined by other systems by sys_polf }
+    //sys_stmv: Word;   { Value of serial timeout }
+                        {  Formula = (1200/baud+1, i.e. 
+                                     11 = 75   bps, 
+                                      5 = 300  bps, 
+                                      3 = 600  bps, 
+                                      2 = 1200 bps, 
+                                      1 = 2400 bps+) [QL] }
+
+    sys_polf: Word;     { Polling frequency [SMSQ] }
+    sys_cfst: Word;     { Flashing cursor status }
+
+    { Filing system defaults }
+
+    sys_prgd: Pointer;  { Pointer to PRoGram Default [EXT][SMSQ] }
+    sys_datd: Pointer;  { Pointer to DATa Default [EXT][SMSQ] }
+    sys_dstd: Pointer;  { Pointer to DeSTination Default [EXT][SMSQ] }
+    sys_thgl: Pointer;  { Pointer to THinG List [EXT][SMSQ] }
+    sys_psf:  Pointer;  { Primary stack frame pointer [SMSQ] }
+    sys_200i: Byte;     { 200 Hz in service/interrupt 2 in service [SMSQ] }
+    sys_50i:  Byte;     { 50 Hz in service [SMSQ] }
+    sys_10i:  Byte;     { 10 Hz in service [SMSQ] }
+    sys_plrq: Byte;     { Poll requested (-ve for request) [SMSQ] }
+
+    sys_clnk: Pointer;  { Pointer to console linkage [SMSQ] }
+    sys_castat: Byte;   { -1 cache on, +1 instruction cache temp off [SMSQ] }
+    sys_casup: Byte;    { Cache suppressed timer [SMSQ] }
+    sys_iopr: Word;     { I/O priority [SMSQ] }
+    sys_cbas: Pointer;  { Current basic (copy of sys_jbpt) [SMSQ] }
+    sys_fpu:  Array [0..15] of Byte; { FPU stuff? [SMSQ] }
+    sys_prtc: Byte;     {  Set if real time clock protected [SMSQ] }
+    sys_pmem: Byte;     { Memory protection level [SMSQ, ST] }
+    sys_slug: Word;     { Slug level [SMSQ] }
+    sys_klock: Byte;    { Key lock [SMSQ/E] }
+    sys_unused_e5: Byte; { Not used, offset = $E5 }
+    sys_mtick: Word;    { Mini tick counter [SMSQ/E] }
+    sys_klnk: Pointer;  { Pointer to keyboard linkage [SMSQ/E] }
+    sys_unused_ec: Array [1..2] of Byte; { Not used, offset = $EC and $ED }
+
+    { Fixed filing system working area [QL] }
+
+    sys_mdrn: Byte;     { Which MDV drive is running? }
+    sys_mdct: Byte;     { MDV run-up run-down counter [QL] }
+    sys_mdid: Array [0..7] of Byte; { Drive ID*4 of each microdrive [QL] }
+    sys_mdst: Array [0..7] of Byte; { MDV Status: 0=no pending ops [QL] }
+    sys_fsdd: Array [0..15] of Pointer; { Long Pointers to Filing System Drive Definitions }
+
+    sys_fsch: Pointer;  { Linked list of Filing System CHannel blocks }
+    sys_xact: Byte;     { Set if TRANSLATE active [QDOS V1.10+, SMSQ, not SMS2] }
+    sys_unused_145: Byte; { Unused, offset = $0145 }
+    sys_xtab: Pointer;  { Pointer to TRANSLATE table [QDOS V1.10+, SMSQ, not SMS2] }
+    sys_erms: Pointer;  { Pointer to (QDOS) error message table [QDOS V1.10+, SMSQ, not SMS2] }
+
+    sys_mstab: Pointer; { Pointer to (SMSQ) message table [SMSQ]. }
+                        { This is a pointer to a 256 long word table of
+                          pointers to message groups. All undefined 
+                          message groups have a zero pointer. }
+    sys_unused_152: Array [0..1] of Byte; { Unused, Offset = $0152 and $0153 }
+
+    { Offset $0154 is a table of 4 long words used by Taskmaster
+      but one which is also used by TURBO. I've used the most 
+      likely case here, Taskmaster is pretty much defunct.
+      (Famous last words?) }
+    //sys_taskm: Array [0..3] of Longint; { 4 Long Used by Taskmaster }
+    sys_unused_154: Array [0..2] of Longint; { First 3 Taskmaster longs }
+    sys_turbo: Longint; { Used by Turbo }
+
+    sys_qsound: Longint; { Used by QSound }
+    sys_ldmlst: Pointer; { Language dependent module list [SMSQ] }
+    sys_lang: Word;      { Current language [SMSQ] }
+    sys_vers: Longint;   { Operating system version [SMSQ] }
+    sys_rthg: Byte;      { Use RECENT Thing (<>0 if yes) [SMSQ/E 3.24+] }
+    sys_xdly: Byte;      { Suspend delay after executing another job [SMSQ/E 3.13+] }
+    sys_ouch: Byte;      { Ouch flag (currently used to activate SGC debug) [SMSQ] }
+
+  end; 
+
+  pSystemVariables = ^SystemVariables;
+

+ 2 - 0
packages/qlunits/src/smsfuncs.inc

@@ -13,4 +13,6 @@
 
  **********************************************************************}
 
+function sms_info(sys_vars: ppchar; ver_ascii: plongint): Tjobid; external name '_mt_inf';
+function iob_fbyt(chan: Tchanid; timeout: Ttimeout): longint; external name '_io_fbyte';
 function iof_mkdr(chan: Tchanid): longint; external name '_iof_mkdr';