SMSQ/e Help needed

Discussion and advice about emulating the QL on other machines.
User avatar
Mr_Navigator
QL Fanatic
Posts: 782
Joined: Mon Dec 13, 2010 11:17 pm
Location: UK, Essex
Contact:

SMSQ/e Help needed

Post by Mr_Navigator »

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?


-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
User avatar
tofro
Font of All Knowledge
Posts: 2702
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: SMSQ/e Help needed

Post by tofro »

Hi!

Because SMSQ/E's system variables are not located at a fixed location, SBASIC uses a specific syntax to peek into them:
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
Also, SMSQ/E understands the Motorola hex code notation using the "$" sign.

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)
in SBASIC

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
Mr_Navigator
QL Fanatic
Posts: 782
Joined: Mon Dec 13, 2010 11:17 pm
Location: UK, Essex
Contact:

Re: SMSQ/e Help needed

Post by Mr_Navigator »

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


-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
User avatar
Mr_Navigator
QL Fanatic
Posts: 782
Joined: Mon Dec 13, 2010 11:17 pm
Location: UK, Essex
Contact:

Re: SMSQ/e Help needed

Post by Mr_Navigator »

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.
Untitled-4.png
Untitled-4.png (2.56 KiB) Viewed 6243 times
Untitled-3.png
Untitled-3.png (10.77 KiB) Viewed 6243 times
Untitled-2.png
Untitled-2.png (11.71 KiB) Viewed 6243 times
Untitled-1.png
Untitled-1.png (9.06 KiB) Viewed 6243 times
Any further clues?, am i doing something wrong?


-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
RWAP
RWAP Master
Posts: 2839
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: SMSQ/e Help needed

Post by RWAP »

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...


RWAP
RWAP Master
Posts: 2839
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: SMSQ/e Help needed

Post by RWAP »

If all you need is a timer, have a look at the DIY toolkit TIMER routines.. :)


User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: SMSQ/e Help needed

Post by dilwyn »

RWAP wrote:If all you need is a timer, have a look at the DIY toolkit TIMER routines.. :)
...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.


User avatar
Mr_Navigator
QL Fanatic
Posts: 782
Joined: Mon Dec 13, 2010 11:17 pm
Location: UK, Essex
Contact:

Re: SMSQ/e Help needed

Post by Mr_Navigator »

dilwyn wrote:
RWAP wrote:If all you need is a timer, have a look at the DIY toolkit TIMER routines.. :)
...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.
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 :-(


-----------------------------------------------------------------------------------
QLick here for the Back 2 the QL Blog http://backtotheql.blogspot.co.uk/
User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: SMSQ/e Help needed

Post by dilwyn »

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 :-(
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


User avatar
Mr_Navigator
QL Fanatic
Posts: 782
Joined: Mon Dec 13, 2010 11:17 pm
Location: UK, Essex
Contact:

Re: SMSQ/e Help needed

Post by Mr_Navigator »

dilwyn 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
Earlier in the program there is a poke

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/
Post Reply