A guide to programming the Sinclair QL

Anything QL Software or Programming Related.
RWAP
RWAP Master
Posts: 2834
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

A guide to programming the Sinclair QL

Post by RWAP »

I was recently approached by someone on Facebook who is writing a game in C and using cross compilers to convert it to various platforms. He asked about the QL and I pointed him to the cross assemblers available on the Sinclair QL Homepage - http://www.dilwyn.me.uk/c/index.html - most notably QDOS-GCC

However, he also raised an interesting point.

There is a need for a guide to programming the Sinclair QL, which takes account of things such as screen and memory layout, QDOS calls (and possibly their SuperBASIC / C library equivalents).

Whilst many of us have adopted various approaches to programming over the years, for someone new to the QL scene, the amount of information is daunting and spread across numerous sources.


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: A guide to programming the Sinclair QL

Post by tofro »

Rich,

the

QDOS Technical Guide

(as available from Dilwyn's site)

Is the definitive source of information and the only thing you actually need (and, all the 80ies developers had) to develop for the original QL.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
Cristian
Aurora
Posts: 960
Joined: Mon Feb 16, 2015 1:40 pm
Location: Veneto

Re: A guide to programming the Sinclair QL

Post by Cristian »

For what it regards Superbasic, another significant manual IMHO is:
QL SuperBASIC - The Definitive Handbook.
The author is Jan Jones, the designer and writer of QL Superbasic language.
There is also a recent Kindle edition retyped and reformatted by the author personally.


stevepoole
Super Gold Card
Posts: 712
Joined: Mon Nov 24, 2014 2:03 pm

Re: A guide to programming the Sinclair QL

Post by stevepoole »

Hi,
Over some 12 months, a team of 3 QL programmers converted a very long QL 'Travelling Salesman' program into C++.
This was done sucsessfully, but was not a trivial task :
An article on how this was done should soon be appearing in Quanta.

First, you have to Turbo-compile your superbasic, then CPort it, Cfix it. Then you have a QL C program which can be EXECed on a QL.
Next you have to learn C++, and we used the QUINCY front-end with an included Borland graphics interface, on which to code superbasic Keywords in C++.
You then add the C++ Keyword functions to your CPorted C code and ensure there remain no incompatibilities.
But the effort is worth it : The program ran some 400 times faster on a bare PC than on QPC2 !

As said, this is a very exacting task, requiring several platforms.
We needed the expertise of three different domains to achieve our goal.
Cross-platform programming from QLs could put QL software onto PCs, but would need to be written as APPs, yet another kettle of fish...
Steve.


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

Re: A guide to programming the Sinclair QL

Post by dilwyn »

RWAP wrote:I was recently approached by someone on Facebook who is writing a game in C and using cross compilers to convert it to various platforms. He asked about the QL and I pointed him to the cross assemblers available on the Sinclair QL Homepage - http://www.dilwyn.me.uk/c/index.html - most notably QDOS-GCC
However, he also raised an interesting point.
There is a need for a guide to programming the Sinclair QL, which takes account of things such as screen and memory layout, QDOS calls (and possibly their SuperBASIC / C library equivalents).
Whilst many of us have adopted various approaches to programming over the years, for someone new to the QL scene, the amount of information is daunting and spread across numerous sources.
I fully agree, Rich.
While books such as QDOS and QPTR programming guides exist, plus the Jan Jones book and even the SBASIC manual I put together are all capable of being reference sources, there does seem to be a need for a book or document to guide you from routine SuperBASIC programming on a BBQL up to the more modern systems complete with examples. I suppose it could be the QL manual part 2 or "Advanced Programming on the QL"

If anyone thinks they have the time and expertise to produce such a guide, they would be more than welcome to include material and examples from articles I've written over the years and I'd be very happy to help in whatever way I can, lack of time being the main problem for me.


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

Re: A guide to programming the Sinclair QL

Post by RWAP »

I agree - at the moment, there are some old books written in 1984, which are not really relevant for modern systems, plus:

- QDOS / SMS Reference Manual - https://kilgus.net/smsqe/QDOS%20SMS%20R ... Manual.pdf (aimed at machine code)
- The SBASIC/SuperBASIC Reference Manual - http://superbasic-manual.readthedocs.io ... index.html
- QL SuperBASIC - The Definitive Handbook by Jan Jones - http://amzn.to/2xtbZvL
- Pointer Environment Guides (again these are mainly pre high colour) - http://www.dilwyn.me.uk/docs/ptr/index.html
- SMSQ/E Guide - http://www.dilwyn.me.uk/docs/ebooks/smsqe/SMSQE_A4.htm
- High Colour Guide - http://www.dilwyn.me.uk/docs/smsqegd2/index.html

I have just realised that not all of these are even linked on Dilwyn's documentation page - http://www.dilwyn.me.uk/docs/index.html

I seem to recall an online version of Jan Jones book but can't remember if this was OK with her!

But the information is rather spread out and I didn't find anything specific about the use of QDOS C libraries. People new to the QL will face a very steep learning curve - first of all determining what the difference is between QDOS / SMSQ/e and SBASIC / SuperBASIC.


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: A guide to programming the Sinclair QL

Post by tofro »

RWAP wrote: I seem to recall an online version of Jan Jones book but can't remember if this was OK with her!
I'm pretty sure on a no on that, as she still sells it as an e-book on Amazon.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
swensont
Forum Moderator
Posts: 252
Joined: Tue Dec 06, 2011 3:30 am
Location: SF Bay Area
Contact:

Re: A guide to programming the Sinclair QL

Post by swensont »

"I was recently approached by someone on Facebook who is writing a game in C and using cross compilers to convert it to various platforms."

None of the books on SBASIC will help with this project. The main issue is how much QLness is the project going to need. Porting a C program to the QL can be fairly simple if is it mostly text based. Doing graphics is where it gets complicated. Is the end program going to use the PE? That adds another level of complexity.

IIRC, there are tools like QT that allow for porting graphical programs from one environment to another (like Windows to Linux). There is no such tool for the QL. The programmer would have to take the commands for the one graphical environment and write the equivalent code for the QL. The C68 / QPTR docs have some examples, but they might be lacking for a number of people.

Tim Swenson


User avatar
NormanDunbar
Forum Moderator
Posts: 2251
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: A guide to programming the Sinclair QL

Post by NormanDunbar »

Hi Tim,
swensont wrote:"IIRC, there are tools like QT that allow for porting graphical programs from one environment to another (like Windows to Linux).
If I may be so bold as to correct you ...

Qt, wxWidgets, Fox Toolkit etc exist not to assist in porting graphical programs from one OS to another, they are used to write cross platform applications. The same source code is simply recompiled on Windows, Mac, Linux, Raspberry Pi, etc.

I use Qt for things like QStripper, which runs on multiple OSs, and is compiled on each from exactly the same source. No porting required.

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.
stevepoole
Super Gold Card
Posts: 712
Joined: Mon Nov 24, 2014 2:03 pm

Re: A guide to programming the Sinclair QL

Post by stevepoole »

Hi,
I can see one problem porting C programs to QLs. C language allows you to construct code in a huge number of ways. For example just consider FOR loops : Converting C FOR loops to QL Basic FOR loops would probably need to be done by hand, as I doubt whether software could do it, there being just too many combinations.
So forget QL Basic for now. This leaves the possibility of converting PC C into a QL C. As Tim said, QL C contains many keywords specific to the QL. This is a botlekneck when converting QL C to PC C, and the opposite would be much harder to achieve. CPort was written over 30 years ago by a professional QL firm, so who would have the time to write a cross-compiler to convert from PC C to QL C today?
Perhaps it would be more feasable to do it for QPC2, as this emulates QLs already via software. But again, a major task, and one that perhaps only Marcel Kilgus would be capable of undertaking in any case. But that would be to ask a great deal from him!
The fact that nobody has attempted it before reveals the difficulty of the task...
Very few QL programs seem to have been written in QL C, probably because Qlers love to tinker with code, and C code is far less easy to comprehend than Basic, so tinkering would be problematical.
Perhaps the best solution would be for a C programmer to write his algorythm in pseudocode, which somebody could rewite in Basic for QLers. This would ammount to authorised reverse-engineering!
Regards,
Steve Poole.


Post Reply