SMSQ/e Help needed
- Mr_Navigator
- QL Fanatic
- Posts: 782
- Joined: Mon Dec 13, 2010 11:17 pm
- Location: UK, Essex
- Contact:
SMSQ/e Help needed
I am trying to find a suitable PEEK/PEEK_W/PEEK_L possibly from the system variables that will give me an incremental number based around the system clock.
A$=DATE$:PRINT A$(19 to 20) gives me seconds, as does PRINT DATE but I would like something with greater resolution. I.e 10ths or 100ths of a second. Is their documentation of the system variables under SMSQ/e I can refer to?
Now there is a document on Dilwyn's site called System Variables which contains the following:
System Variables List
The following are relative to MT_INF trap result: the $280xx can only be relied on for ROMs up to JS/MG. "+" numbers in braces are decimal offsets in the area. The base address of the system variables should be checked by using a call to the MT.INF trap (Trap #1 with D0 = 0), where the resultant value of A0 is the pointer to the system variables. Several extensions have been written for SuperBASIC to check this value, such as the function VER$(-2) in the Minerva ROM.
DEFine FuNction GET_SYSVARS
REMark a fairly simple system variable base address check
LET system_vars = 163840
LET v$ = VER$
IF v$ = 'JSL1' OR v$ = 'HBA' THEN LET system_vars = VER$(-2)
RETurn system_vars
END DEFine
$28000.W SV_IDENT Identification
$d2450000 QL (QDOS) system variable identifier
"S2AT" SMS Atari system variable identifier
Pointers defining QDOS memory map:
$28004.L SV_CHEAP Base of common heap area
$28008.L SV_CHPFR First free space in common heap area
$2800C.L SV_FREE Base of free area [+12 ]
$28010.L SV_BASIC Base of BASIC area [+16 ]
$28014.L SV_TRNSP Base of transient program area
$28018.L SV_TRNFR First free space in TPA
$2801C.L SV_RESPR Base of resident procedure area
$28020.L SV_RAMT Top of RAM(+1) [+32 ]
$28024.L SYS_MXFR Maximum return from free memory call (SMS only)
$28028.L SYS_RTC Real time in seconds (SMS only)
$2802C.W SYS_RTCF Real time fractional, countdown (SMS only)
These last two look promising, especially the 'Real time fractional', in order to test this I need to peek it I suppose, but I dont know how to do this correctly. Not having done a great deal of this before i am a bit lost, any ideas clever people?
A$=DATE$:PRINT A$(19 to 20) gives me seconds, as does PRINT DATE but I would like something with greater resolution. I.e 10ths or 100ths of a second. Is their documentation of the system variables under SMSQ/e I can refer to?
Now there is a document on Dilwyn's site called System Variables which contains the following:
System Variables List
The following are relative to MT_INF trap result: the $280xx can only be relied on for ROMs up to JS/MG. "+" numbers in braces are decimal offsets in the area. The base address of the system variables should be checked by using a call to the MT.INF trap (Trap #1 with D0 = 0), where the resultant value of A0 is the pointer to the system variables. Several extensions have been written for SuperBASIC to check this value, such as the function VER$(-2) in the Minerva ROM.
DEFine FuNction GET_SYSVARS
REMark a fairly simple system variable base address check
LET system_vars = 163840
LET v$ = VER$
IF v$ = 'JSL1' OR v$ = 'HBA' THEN LET system_vars = VER$(-2)
RETurn system_vars
END DEFine
$28000.W SV_IDENT Identification
$d2450000 QL (QDOS) system variable identifier
"S2AT" SMS Atari system variable identifier
Pointers defining QDOS memory map:
$28004.L SV_CHEAP Base of common heap area
$28008.L SV_CHPFR First free space in common heap area
$2800C.L SV_FREE Base of free area [+12 ]
$28010.L SV_BASIC Base of BASIC area [+16 ]
$28014.L SV_TRNSP Base of transient program area
$28018.L SV_TRNFR First free space in TPA
$2801C.L SV_RESPR Base of resident procedure area
$28020.L SV_RAMT Top of RAM(+1) [+32 ]
$28024.L SYS_MXFR Maximum return from free memory call (SMS only)
$28028.L SYS_RTC Real time in seconds (SMS only)
$2802C.W SYS_RTCF Real time fractional, countdown (SMS only)
These last two look promising, especially the 'Real time fractional', in order to test this I need to peek it I suppose, but I dont know how to do this correctly. Not having done a great deal of this before i am a bit lost, any ideas clever people?
-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
Re: SMSQ/e Help needed
Hi!
Because SMSQ/E's system variables are not located at a fixed location, SBASIC uses a specific syntax to peek into them:
So, peeking into the variable that would be addressed by $2802C.L on a "normal QL" goes like
in SBASIC
Tobias
Because SMSQ/E's system variables are not located at a fixed location, SBASIC uses a specific syntax to peek into them:
Also, SMSQ/E understands the Motorola hex code notation using the "$" sign.PEEK may be referenced form the system variables if the first parameter of PEEK is preceded by an exclamation mark, then the address of the peek is in the system variables or referenced via the system variables. There are two variations:
direct and indirect references.
For direct references, the exclamation mark is followed by another exclamation mark and an
offset within the system variables
So, peeking into the variable that would be addressed by $2802C.L on a "normal QL" goes like
Code: Select all
PRINT PEEK_L (!!$2c)
Tobias
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
- Mr_Navigator
- QL Fanatic
- Posts: 782
- Joined: Mon Dec 13, 2010 11:17 pm
- Location: UK, Essex
- Contact:
Re: SMSQ/e Help needed
Well I tried that and got a sequence of random numbers repeating in duplicates of 5 and 7, very strange.
Will investigate further and put up some screen shots
Will investigate further and put up some screen shots
-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
- Mr_Navigator
- QL Fanatic
- Posts: 782
- Joined: Mon Dec 13, 2010 11:17 pm
- Location: UK, Essex
- Contact:
Re: SMSQ/e Help needed
OK this is the program used to printout the numbers
Its on a laptop using Q-emuLator with SMSQ/e loaded and running in DISP_COLOUR 0, 512,256
The first set at the program running at QL speed, the second at GoldCard speed, the last is at Full speed. I can understand the repeated numbers as the PEEK sample must be acting quicker than the actual time updating, but at slower speeds there seems no logic to the numbering sequence. Any further clues?, am i doing something wrong?
Its on a laptop using Q-emuLator with SMSQ/e loaded and running in DISP_COLOUR 0, 512,256
The first set at the program running at QL speed, the second at GoldCard speed, the last is at Full speed. I can understand the repeated numbers as the PEEK sample must be acting quicker than the actual time updating, but at slower speeds there seems no logic to the numbering sequence. Any further clues?, am i doing something wrong?
-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
-
- RWAP Master
- Posts: 2892
- Joined: Sun Nov 28, 2010 4:51 pm
- Location: Stone, United Kingdom
- Contact:
Re: SMSQ/e Help needed
You should be use PRINT PEEK_W (!!$2C) for starters (as it is only a word).
On QPC2 I just get zeros - so maybe this is not emulated on QPC2 or q-emulator....
PRINT PEEK_L(!!$28) also returns 128 constantly...
On QPC2 I just get zeros - so maybe this is not emulated on QPC2 or q-emulator....
PRINT PEEK_L(!!$28) also returns 128 constantly...
Rich Mellor
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module - add a USB printer to your QL
Also Involved in:
Icephorm
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module - add a USB printer to your QL
Also Involved in:
Icephorm
-
- RWAP Master
- Posts: 2892
- Joined: Sun Nov 28, 2010 4:51 pm
- Location: Stone, United Kingdom
- Contact:
Re: SMSQ/e Help needed
If all you need is a timer, have a look at the DIY toolkit TIMER routines.. 

Rich Mellor
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module - add a USB printer to your QL
Also Involved in:
Icephorm
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module - add a USB printer to your QL
Also Involved in:
Icephorm
Re: SMSQ/e Help needed
...http://www.dilwyn.me.uk/tk/index.html - scroll down to DIY Toolkit. The timer code is in Volume H which I think is disk 1. It provides 3 or 4 timer stopwatches which work by the 50/60Hz polled routines.RWAP wrote:If all you need is a timer, have a look at the DIY toolkit TIMER routines..
--
All things QL - https://dilwyn.theqlforum.com
All things QL - https://dilwyn.theqlforum.com
- Mr_Navigator
- QL Fanatic
- Posts: 782
- Joined: Mon Dec 13, 2010 11:17 pm
- Location: UK, Essex
- Contact:
Re: SMSQ/e Help needed
No I dont need a Timer at the moment, I am trying to understand what the program is doing, so i can correct it to work on an emulator.dilwyn wrote:...http://www.dilwyn.me.uk/tk/index.html - scroll down to DIY Toolkit. The timer code is in Volume H which I think is disk 1. It provides 3 or 4 timer stopwatches which work by the 50/60Hz polled routines.RWAP wrote:If all you need is a timer, have a look at the DIY toolkit TIMER routines..
I think it resets to the clock with a poke of 0 then reads the same location after as a time delay reference, any read of zero crashes the program out with an aritmentic error later in the code.
So still struggling to sort this problem out

-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
Re: SMSQ/e Help needed
Would you like to post a copy (or PM it to me) of the code that's going wrong so I can have a look to see if I can spot anything to help?No I dont need a Timer at the moment, I am trying to understand what the program is doing, so i can correct it to work on an emulator.
I think it resets to the clock with a poke of 0 then reads the same location after as a time delay reference, any read of zero crashes the program out with an aritmentic error later in the code.
So still struggling to sort this problem out
Dilwyn
--
All things QL - https://dilwyn.theqlforum.com
All things QL - https://dilwyn.theqlforum.com
- Mr_Navigator
- QL Fanatic
- Posts: 782
- Joined: Mon Dec 13, 2010 11:17 pm
- Location: UK, Essex
- Contact:
Re: SMSQ/e Help needed
Earlier in the program there is a pokedilwyn wrote:Would you like to post a copy (or PM it to me) of the code that's going wrong so I can have a look to see if I can spot anything to help?
Dilwyn
2220 DEFine PROCedure start
2270 height=55000
2280 velocity=-180
2290 fuel=3000: accel=0
2300 setting=0: dr=1: mv=9
2310 ADATE (-DATE): time=0
2320 POKE_W 163886,0: old_time=0
2330 END DEFine
then this routine crashes out with arithmetic overflow at linem2670
2575 DEFine PROCedure calculations
2580 new_time= PEEK_W (163886)
2590 update=(new_time-old_time)/60
2600 old_time=new_time: sign=1
2610 accel=5.4*update*(.2*setting -1): IF accel<0 THEN sign= -1
2620 change_in_height= update*(velocity+sign*(accel^2))
2630 height= height+change_in_height
2640 REMark ============added to see what is happening==================
2650 PRINT
2655 PRINT "new_time,update,old_time,accel,change_in_height,height,velocity"
2660 PRINT new_time,update,old_time,accel,change_in_height,height,velocity
2665 REMark=========================================================
2670 velocity=(change_in_height/update)
2680 mv=(change_in_height)/30
2760 fuel=fuel-update*setting*2
2770 IF fuel<=0 THEN fuel=0
2780 IF height<0 THEN height=0
2790 END DEFine
Any help appreciated

-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/