Graphics program for SMSQ/E

Helpful tips and guides, also new users can ask for help here.
User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: Graphics program for SMSQ/E

Post by mk79 »

BSJR wrote:Among the Extra keywords you mentioned before I found S_SAVE & S_LOAD which are also part of a Quanta Lib SCREEN routine by Ron Dwight, to compress mode 4 & 8 screens and works with a 16 colour words table.
Maybe an adaptation was used to accommodate for the 1-bit monochrome mode. So far I have not got my head around how the original exactly works though.
Oh, you're right. The code was so small that I didn't expect anything fancy to happen. And there isn't, but it's a simple RLE algorithm. Byte 0..127 signals an uncompressed run of words and a byte 128..255 a repeated 16-bit word, that's all.

The only interesting (and maybe problematic) thing is that the uncompressed buffer size is written to the file header.

Cheers, Marcel


Martin_Head
Aurora
Posts: 847
Joined: Tue Dec 17, 2013 1:17 pm

Re: Graphics program for SMSQ/E

Post by Martin_Head »

I've decompiled the four programs. I'm now looking through them, tidying them up so that they load without complaint.

I've done two of them. But I have not tried to run them yet, or sorted out the SuperBASIC extensions they use.

If anyone feels like having a go. Just say, and I will upload them.


User avatar
Andrew
Aurora
Posts: 786
Joined: Tue Jul 17, 2018 9:10 pm

Re: Graphics program for SMSQ/E

Post by Andrew »

Martin_Head wrote:If anyone feels like having a go. Just say, and I will upload them.
Please, upload them Martin


Martin_Head
Aurora
Posts: 847
Joined: Tue Dec 17, 2013 1:17 pm

Re: Graphics program for SMSQ/E

Post by Martin_Head »

qsanp2_bas and qsnap2_log, is the raw output from the decompiler. qsanp_bas is the tidied up qsnap2_bas. It loads into QPC2 without complaint. But I have not tried to run it at all.

The qsnap1/2_ext and qsnap1/2_ext_log are the imbedded SuperBASIC extensions. The _log file is a list of the procedures and functions, and the kind of Qliberator command line required. The _ext file is the actual extensions. (I'm not sure if they will just LRESPR or not. Have not tried them out)

The same goes for qdesign_config.

I have also included the fonted and qdesign files. But I am still doing the tidying up on them.

I have also included the current decompiler. It has a bit of an issue that I am still looking into with slicing arrays, other than the last index.

In fonted there is a line that it has problems with

It decompiles as -
17192 SPSET var0678,var0680,var0688,0var0660$(var0670,1 TO var0668)
But should be
17192 SPSET var0690,var0678,var0680,var0688,var0660$((0 TO var0670),(1 TO var0668))

The array is
17004 LOCal var0660$(32,32)
Attachments
Q_Design.zip
(124.73 KiB) Downloaded 118 times
DeLib.zip
(17.35 KiB) Downloaded 124 times


Martin_Head
Aurora
Posts: 847
Joined: Tue Dec 17, 2013 1:17 pm

Re: Graphics program for SMSQ/E

Post by Martin_Head »

Here's the tidied up fonted file. Just leaves the qdesign file to do, It's the big one. over 4000 lines of code and line numbers up into the 70 thousands. I will need to do some creative renumbering.

Forgot to mention that QDOS may get upset about my tidied code. I think it's more fussy than SMSQ/E is.
Attachments
fonted_bas.zip
(12.41 KiB) Downloaded 130 times


User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: Graphics program for SMSQ/E

Post by mk79 »

Thank you Martin. The line numbers are derived from the token position? Is there a technical reason why the END IF and END SELECT for example don't get their own lines?

Also I see a REPeat in the new source code, is this due to manual cleanup? I see that the QDesign code is a jumble of GO TOs, all previously having been REPeats I guess.

Cheers, Marcel


Martin_Head
Aurora
Posts: 847
Joined: Tue Dec 17, 2013 1:17 pm

Re: Graphics program for SMSQ/E

Post by Martin_Head »

mk79 wrote:Thank you Martin. The line numbers are derived from the token position? Is there a technical reason why the END IF and END SELECT for example don't get their own lines?

Also I see a REPeat in the new source code, is this due to manual cleanup? I see that the QDesign code is a jumble of GO TOs, all previously having been REPeats I guess.

Cheers, Marcel
The four programs were compiled without line numbers. So the decompiler doe's not know where lines start and end, So it assumes every statement has it's own line.
There is nothing in the compiled program that marks where END IF's and END SELects are. The decompiler has to work out where it thinks the END IF and END Selects are. And it can get confused with IF THEN ELSE's, especially in REPeat loops.

Something like
IF condition THEN
Statements
EXIT loop
END IF

Looks just like
IF condition THEN
statements
ELSE
rest of loop
END REPeat loop
END IF

GO TO's are a pain. Whenever the decompilers see a GO TO, it has to try to decide if it's a real GO TO, or an ELSE, or part of a SELect, or jumping over a Proc/fun etc.

When the line numbers are omitted, the decompilers use the current offset from the start of the coded BASIC program + 100. So if that's what you mean by the token position, then yes.

REPeat loops are converted into GO TO's including the NEXT's and EXIT's. When I do the initial tidying up, I try to spot these GO TO's that make up REPeat loops and convert them to REPeats, and EXIT's etc. Qliberator make life a bit easier, as it replaces the initial REPeat with a variable assignment of zero. So when you see a backwards GO TO to just passed a variable assignment of zero, and the variable is not used again, then it's likely a REPeat.

I try to get rid of as many GO TO's as I can. But I sometimes sit looking at a GO TO trying to decide if it's an actual GO TO, of part of a REPeat. So sometimes I get my tidying up wrong, and cause myself problems later.


Martin_Head
Aurora
Posts: 847
Joined: Tue Dec 17, 2013 1:17 pm

Re: Graphics program for SMSQ/E

Post by Martin_Head »

I'm still working on tidying up the Qdesign program. I've done about 1400 of the 4319 program lines.

It's going a bit slow, due the the number of SELects that need tidying up. And I will apologise in advance for any problems I may add in my tidying up.


User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: Graphics program for SMSQ/E

Post by mk79 »

Martin_Head wrote:Here's the tidied up fonted file.
Again, thanks. I have found 2 curious things:

Code: Select all

17764    READ var05C8(1776,var02D8(var06F0))
The 1776 index is way out of bounds and suspiciously similar to the line number.

Code: Select all

17830  RETurn MK_LIL
All the parameters for MK_LIL are missing.

For what's it worth, here is the source for the FontEd extension. The assembler it was created with apparently filled spare bytes with garbage, which made the source a bit strange at time. I have patched those bytes to zero. In one case an RTS was already halve destroyed with a 0, resulting in a possible crash and the PURGE function jumps into unrelated code if called from BASIC... not sure where those invalid bytes were introduced. I have fixed the RTS but left the PURGE problem as I'm not sure what it was supposed to do.

There are a few interesting functions in there (most aren't even used in FontEd), like "REPLACE" which can be used to re-factor basic code by exchanging one variable name with another.

Code: Select all

REPLACE var1,var2
or PICK$, which selects one string of the given parameter strings:

Code: Select all

xyz$ = PICK$(1, "abc", "def", "ghi"): REMark returns "abc"
xyz$ = PICK$(2, "abc", "def", "ghi"): REMark returns "def"
USE is a curious command, it seems to copy the given channel definition to #1, making that the default output channel instead.

The complete list:

Code: Select all

RESET megabytes - QDOS only!
PURGE - Remove job or crash(?) if Basic
USE(#ch) - Use #ch as #1
REPLACE search-name,replace-name - replace name in basic code
POKE_$ addr, str$
KEYBOARD delay, time
FREEZE 0/1
CAPSLOCK 0/1
val = CHECK_FLOAT(str$) - get float value or -1E600 on error
val% = CHECK_INT(str$) - get int value or -32768 on error
str$ = PICK$(param_index, str1$, str2$, str3$, ...) - pick one of the string parameters
val = CHAN_B(#ch, offset)
val = CHAN_W(#ch, offset)
val = CHAN_L(#ch, offset)
str$ = PEEK_$(addr)
str$ = EDLINE$(#ch, max, str$)
str$ = UPPER$(str$)
str$ = LOWER$(str$)
ver$ = QDOS$
ver$ = QPTR$
node = NET%
The second extension file is just the QPtr toolkit, the sources for that already exist ;)
Attachments
fonted1.zip
(7.08 KiB) Downloaded 117 times


Martin_Head
Aurora
Posts: 847
Joined: Tue Dec 17, 2013 1:17 pm

Re: Graphics program for SMSQ/E

Post by Martin_Head »

mk79 wrote:
Martin_Head wrote:Here's the tidied up fonted file.
Again, thanks. I have found 2 curious things:

Code: Select all

17764    READ var05C8(1776,var02D8(var06F0))
The 1776 index is way out of bounds and suspiciously similar to the line number.

Code: Select all

17830  RETurn MK_LIL
All the parameters for MK_LIL are missing.
I will have a look into these.

Here is the tidied up QDesign program. There was a hell of a lot of SELects to tidy up. I hope I have not introduced too many problems.

There is an odd bit near the end, where there is a ON something line, with nothing in it. I suspect a REM'ed out line. I have stuck a REMark in there to highlight it.

The 'qdesign_bas_tidy_full' file is the tidied up file. And the 'qdesign_bas' is the same, but renumbered to be able to load it. Note that some of the GO TO's in REMarks will have the wrong line numbers, due the renumbering.

I had to split the main file into three, Used a program to renumber two of them. And then had to had to actually renumber the three, then merge them together.

So if in doubt, refer to the 'qdesign_bas_tidy_full' file to see where the GO TO's went.
Attachments
Q_Design_bas.zip
(74.25 KiB) Downloaded 115 times


Post Reply