Skip to content

Commit

Permalink
qlunits: merged a modified version of a patch by Norman Dunbar, defin…
Browse files Browse the repository at this point in the history
…es system variables as a record

git-svn-id: trunk@49388 -
  • Loading branch information
chainq committed May 22, 2021
1 parent fd91e82 commit cd5c2b8
Show file tree
Hide file tree
Showing 10 changed files with 443 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions packages/qlunits/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 11 additions & 16 deletions packages/qlunits/examples/mtinf.pas
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,20 +20,15 @@
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;
Expand All @@ -43,11 +38,11 @@ function get_id_str(const id: dword): string;
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 changes: 49 additions & 0 deletions packages/qlunits/examples/sms_info.pas
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions packages/qlunits/fpmake.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
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;
Expand Down
1 change: 1 addition & 0 deletions packages/qlunits/src/qdos.pas
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ TWindowDef = record
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 }

Expand Down
147 changes: 147 additions & 0 deletions packages/qlunits/src/qdos_sysvars.inc
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions packages/qlunits/src/sms.pas
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface
smsfuncs.inc in packages/qlunits must be kept identical to the one in rtl/sinclairql (KB). }

{$i smsfuncs.inc}
{$i sms_sysvars.inc}


implementation
Expand Down
Loading

0 comments on commit cd5c2b8

Please sign in to comment.