Decoding QSaved Files

Anything QL Software or Programming Related.
Post Reply
User avatar
NormanDunbar
Forum Moderator
Posts: 2525
Joined: Tue Dec 14, 2010 9:04 am
Location: Buckie, Scotland
Contact:

Decoding QSaved Files

Post by NormanDunbar »

New topic to avpoid flooding a different one, with mainly irrelevant stuff (Irrelevant to that other topic I mean!)
pjw wrote:I havent tested extensively but DECODE_SAV seems not to work with integer
tokens produced by Qloadref V1.9 and possibly other, not ancient, versions
of QSAVE. V1.9 is the current version of QLOAD/QSAVE that came with
Q_Liberator V3.36 and beyond. The SMSQ/E version works fine.
Do you know what the token codes that are being missed/messed are please? EDIT: $89 and $86 for 2 and 4 byte integers. However, I'm puzzled by the range of these as per your LIST document. two bytes covers values -128 through +127 and 4 byte integers are for 128 and above? Sadluy, I don't have Mievra to test with though. Could you upload me a quick and dirty test sample please? Much obliged.
pjw wrote: Note that these utilities are pretty useless. All they do is convert
tokenised S*BASIC programs (SAV files) into their human-readable form -
something the S*BASIC interpreters manage perfectly well on their own!
Of course they are! I knew that when I wrote mine many, many years ago. However, I was working on something or other back then---I forget what---and I needed the RAM to be able to do something with a SuperBASIC program. I didn't have enough RAM to have the source program and the proposed utility/program/application/whatever it was, loaded together.

The decode_sav mini-program was my starting point to decode a QSAVEd program which, if I had ever got around to finishing it, would have been converted to whatever the thing I was writing, back then, would have been!

Getting old is a PITA, you forget a lot of things!

Let's, for the sake of argument, say I had been planning to write a new version of Turbo. However, instead of compiling the source program already loaded, the plan was to QSAVE it and then compile the QSAVEd version, more memeory and/or bigger source programs could be compiled in that way. At least, that was my thinking. But no, I wasn't planning on rewriting Turbo!

Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
User avatar
pjw
QL Wafer Drive
Posts: 1662
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Decoding QSaved Files

Post by pjw »

NormanDunbar wrote: Sun Sep 21, 2025 4:34 pm New topic to avpoid flooding a different one, with mainly irrelevant stuff (Irrelevant to that other topic I mean!)
pjw wrote:I havent tested extensively but DECODE_SAV seems not to work with integer
tokens produced by Qloadref V1.9 and possibly other, not ancient, versions
of QSAVE. V1.9 is the current version of QLOAD/QSAVE that came with
Q_Liberator V3.36 and beyond. The SMSQ/E version works fine.
Do you know what the token codes that are being missed/messed are please? EDIT: $89 and $86 for 2 and 4 byte integers. However, I'm puzzled by the range of these as per your LIST document. two bytes covers values -128 through +127 and 4 byte integers are for 128 and above? Sadluy, I don't have Mievra to test with though. Could you upload me a quick and dirty test sample please? Much obliged.
I havent quite finished. I havent tested the range for the four byte variant yet.
NormanDunbar wrote: Sun Sep 21, 2025 4:34 pm
pjw wrote: Note that these utilities are pretty useless. All they do is convert
tokenised S*BASIC programs (SAV files) into their human-readable form -
something the S*BASIC interpreters manage perfectly well on their own!
Of course they are! I knew that when I wrote mine many, many years ago. However, I was working on something or other back then---I forget what---and I needed the RAM to be able to do something with a SuperBASIC program. I didn't have enough RAM to have the source program and the proposed utility/program/application/whatever it was, loaded together.
I know you know, Norm ;o) My audience was those who dont.
NormanDunbar wrote: Sun Sep 21, 2025 4:34 pm The decode_sav mini-program was my starting point to decode a QSAVEd program which, if I had ever got around to finishing it, would have been converted to whatever the thing I was writing, back then, would have been!

Getting old is a PITA, you forget a lot of things!

Let's, for the sake of argument, say I had been planning to write a new version of Turbo. However, instead of compiling the source program already loaded, the plan was to QSAVE it and then compile the QSAVEd version, more memeory and/or bigger source programs could be compiled in that way. At least, that was my thinking. But no, I wasn't planning on rewriting Turbo!
That could work, and maybe it wouldnt be too hard either. But I dont think there is any need for it these days.
Heres the test program:

Code: Select all

100 Sel on x
102 = -300: print -300
104 = -257: print -257
106 = -258: print -258
108 = -1: print -1
110 = -100: print -100
112 =  0: print 0
114 =  1: print 1
116 =  126: print 126
118 =  127: print 127
120 =  128: print 128
122 =  129: print 129
124 =  130: print 130
126 =  131: print 131
128 =  132: print 132
130 =  254: print 254
132 =  255: print 255
134 =  256: print 256
136 =  257: print 257
138 =  300: print 300
140 =  500: print 500
142 end sel
I had to zip the SAV version:
demo.zip
Demo
(666 Bytes) Downloaded 1 time
It was QSAVEd with QLOADREF under Qdos, with QSAVE being version 1.9. I think it is identical if saved under Minerva with the same QLOADQREF. Ive just tried so many variants I no longer know which is which..


Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
User avatar
pjw
QL Wafer Drive
Posts: 1662
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Decoding QSaved Files

Post by pjw »

Talking of ambitious projects, I started to write an S*BASIC editor with syntax colouring and various other bells and whistles using my decoder as the starting point. Viewing code in glorious colour wasnt too hard, but editing was a lot more difficult (re-parsing each line, etc), so I abandoned the project and ended up merely outputting the code as HTML instead.


Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
Post Reply