Dr. Jim's QL Dumping Ground

Anything QL Software or Programming Related.
User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: Dr. Jim's QL Dumping Ground

Post by mk79 »

Martin_Head wrote:
QL Characters by Philip Smith, Sinclair User March 1985
"To return the characters use POKE_L 167722,41304."
I have not tried to find out what the POKE_L 167722,41304 does. But it's way past the system variables, and probably in the common heap.

I would guess that it's trying to directly alter the channel definition block for either channel #0, #1, or #2. This is not a good idea, as there is no guarantee that the address of the channel definition blocks will not move. It depends on the ROM version, if the channel been closed and re-opened, if the extended environment has been loaded, and probably other things that I have not thought of.
Right, this is either downright evil or shockingly clueless. :shock: Those truly were the wild west days of programming.


User avatar
TMD2003
Trump Card
Posts: 168
Joined: Sat Oct 10, 2020 12:18 pm

Re: Dr. Jim's QL Dumping Ground

Post by TMD2003 »

dilwyn wrote:Link to an article on my website about QL fonts and how to use Toolkit 2 extensions to link in new fonts etc without the problems caused by those POKE_L commands in many old listings. http://www.dilwyn.me.uk/docs/articles/funfonts.zip
This could be the answer to my problems. If so, you've earned yourself a bara brith (which I just made this morning). Unfortunately, Wales doesn't like visitors at the moment, so I suppose I'll have to eat it myself... wouldn't want it going to waste.

Now that I've got Lunar Lander added to the QL Games pages, I did try adapting its UDG definition routine to see if it could work the way I need it to - trim down the number of UDGs defined to two, keep them starting at CHR$ 128 just to make sure, and... what do you know, they've all vanished. Gah. If at all possible, I'd like to be able to make a program that would work on a real just-post-dongle-era QL if possible, that doesn't need Toolkit II - useful though it clearly is for my purposes. I remain convinced that there must be a way.

But seeing as it didn't work, I turned my hand to converting that F.A. Cup program from ZX Computing in 1983. The good news is, it's all but done. All I have to do now is wait for the full line-up for this year's third round to be finalised, and I'll be able to release it. While it's unlikely to be much to shout about, it does represent my first proper foray into QL programming - because the Spectrum original was a tangled web of GOTOs and GOSUBs that are routinely sneered at here, and I had to translate them all into PROCs. One marauding GOTO may just slide through the net, but only if there's no other way.

Anyway, here's what it looks like, in its Spectrum original and QL converted form:

Image Image

Or, if you want to see the QL screenshot in the "real" aspect ratio, try this link.

I didn't input the teams for the Spectrum version, that was... whoever typed it in for either The Type Fantastic, or WOS, or both, circa 2012 - the teams are from the 2011-12 season and have been entered into the array with... no particular care. My QL conversion will have two sets of teams all ready to go - the 1982-83 teams as seen above, because this was the current season when the program was first published in ZX Computing, and the 2020-21 teams, for which I'm about to get to know the complete line-up, once the last qualifying round is out the way.

Come on, Bishop's Stortford! And come on, Hampton & Richmond Borough, with 26 characters in your name so I can use the full width of the space I've defined.

Also, if you're from north of the border, it shouldn't be all that difficult to adapt this program to simulate the Scottish Cup. Who knows, maybe the Old Firm won't win every time...


Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
User avatar
TMD2003
Trump Card
Posts: 168
Joined: Sat Oct 10, 2020 12:18 pm

Re: Dr. Jim's QL Dumping Ground

Post by TMD2003 »

Well, I've done it. Sound the trumpets long and loud - though preferably with some device that uses an AY-3-8912 - because I've completed my first QL program! It's a combination and conversion of the Hexadecimal and Dozenal Fraction Converters I've been hosting on Spectribution.

Here's some screenshots for comparison. And if you want the QL screenshots (four of them) in the correct aspect ratio, see this page.

Image Image

Image

Image Image

Image


The reasons for doing all this are obvious: the Spectrum's accuracy for conversion was limited by the number of digits after the radix point that could be kept on screen at any one time, if we want to see the computer show its working. The Spectrum could handle 30 digits, by cunning use of user-defined graphics for the numbers 10 to 15 (as well as those for "dek" and "el" in the dozenal system). The ZX81 had no such facility, so had to sacrifice one of those digits. The QL, in Mode 4, can display 85 digits across its screen. So there's only four colours available - but colour isn't important, this is all about accuracy. Knowing that there would need to be space for two digits in front of the radix point, this meant that it could accommodate 82 digits after the radix point - giving us a level of accuracy that still won't trouble WolframAlpha (where do you think I found all the values of the constants in two non-decimal number bases?) but will blow the Spectrum into the weeds.

The principle is exactly the same as before - take the string of numbers after the radix point, multiply the block by 16 or 12, the digit that appears before the radix point becomes the next digit in the final sequence, then this is subtracted to leave only the digits after the radix point, and the process repeats. As with the Spectrum and ZX81 versions, it's all shown on screen.

The other reason for converting this program to the QL was to get to grips with its far more convoluted user-defined graphics. The QL's character set has a whole load of foreign characters and symbols between CHR$ 128 and 190, all of which can be redefined if you know what you're doing, though the process is more similar to redefining an entire character set on the Spectrum, in that if one character is redefined, the rest disappear into oblivion. So even though I only needed two characters - for the dozenal "dek" and "el", I had to redefine the down-arrow, pi and phi symbols, and threw in an empty box for good measure. It look a long, hard, frustrating amount of battling with POKEs and PEEKs and channel pointers to understand it, and members of the QL Forum are trying to tell me I'm doing it the hard way, and these days with QL Toolkit II there's a CHAR_USE command which allows easy access to custom characters on multiple channels. Well, in the words of Frank Sinatra, I did it my way.

Or, rather, I did it David Nowotnik's way, because the routine I used is based heavily on the "Lunar Lander" program from his "QL Characteristics" article in the October/November 1985 issue of ZX Computing. By starting out with a routine that would print his UDGs in window #3, I eventually managed to get them to be defined to any channel from 0 to 8, and then start defining the block from a character other than CHR$ 128 (161 is an ideal start point, so that the characters are produced by CTRL+SHIFT+A, CTRL+SHIFT+B, and so on).

The QL is a faster computer than the Spectrum, but it has 82 digits to contend with rather than 30, so it isn't too surprising that it takes a chunky 13 minutes, 24 seconds to produce a full answer. Here's the comparison below with the real values, as well as how the QL measures up against its older Z80-based siblings.

And a bonus point - this program also showed me I had made a mistake in the value of pi in the Spectrum and ZX81 programs, so these have all been updated to version 1.1 and the accuracy of their calculations has been corrected accordingly! And, strangest of all - the ZX81 was MORE accurate than the Spectrum for both hexadecimal and dozenal calculations of pi!)

Download the all-singing*, all-dancing Hexadecimal & Dozenal Fraction Converter for the QL

* NOTE: may not be "all-singing", or if it is, it'll all be off-key due to the QL's horrific implementation of sound in SuperBASIC.

And if you want the originals:

Download the NEW version 1.1 of the Hexadecimal Fraction Converters for the Spectrum & ZX81
Download the NEW version 1.1 of the Dozenal Fraction Converters for the Spectrum & ZX81


Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
Derek_Stewart
Font of All Knowledge
Posts: 3957
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Dr. Jim's QL Dumping Ground

Post by Derek_Stewart »

Hi,

Very interesting, but I have managed without Base12 up now, can you explain the possible application?

For conversion of Hexadecimal, I like to use the Toolkit 2 extensions which work very nicely.

I read the ZX Computing magazines, I do not like the way the attempt at UDGs ard poked into the channel .

I prefer to define a font with the UDG graphics characters defined and usd the Toolkit 2 Font commands to switch the character font in when required.
Last edited by Derek_Stewart on Thu Mar 07, 2024 9:17 am, edited 1 time in total.


Regards,

Derek
User avatar
bwinkel67
QL Wafer Drive
Posts: 1196
Joined: Thu Oct 03, 2019 2:09 am

Re: Dr. Jim's QL Dumping Ground

Post by bwinkel67 »

ZXSimulator was able to run both of your ZX81 programs without any change needed in their BASIC:
hexfrac.png
dozfrac.png


User avatar
TMD2003
Trump Card
Posts: 168
Joined: Sat Oct 10, 2020 12:18 pm

Re: Dr. Jim's QL Dumping Ground

Post by TMD2003 »

Derek_Stewart wrote:Very interesting, but I have managed without Base12 up now, can you explain the possible application?
"There are people out there who want to change the way that you count." - Dr. James Grice on Numberphile.

I'd already made the Hexadecimal Fraction Converter, saw that video, and thought "why not?" The Spectrum original only took a few tweaks here and there, a couple of extra UDGs and a colour change, because the base code was already written. And now, if you've ever wondered what the Euler-Mascheroni constant looks like in base 12, you can find out! Cut it off at about 60 significant figures, because that's about as accurate as this program can manage. Most people would go straight to WolframAlpha, mind...
bwinkel67 wrote:ZXSimulator was able to run both of your ZX81 programs without any change needed in their BASIC:
Wunderbar. I've pretty much run out of my own ZX81 programs at this point, but there are plenty more out there. The Type Fantastic will have a load of very basic type-ins from 1982-83 that'll fit the bill.


Meanwhile, I've been distracted by the delivery of a refurbished ZX81 that I've been testing - but aside from that, I've put some new additions onto the QL Type-Ins games page - Reconnaissance and Space Warp (the only two QL listings from Computer & Video Games, ever), plus Quadruplets and Blue Meanies from Your Computer (the remaining seven listings from YC are utilities, and I'll get to those in time). Blue Meanies is particularly impressive - it's all in machine code which I've just about managed to get right - maybe the firing routine isn't quite right but it doesn't crash at unexpected moments, so I'll leave it as it is for now until I go through the hex dump with an even finer-toothed comb than I did before.


Better still, though, the F.A. Cup simulation I converted from the Spectrum original is done.

Image

I chose green for the 1982-83 season (see above), red for the 2020-21 season. The simulation expands on the original with the title and prompts in separate windows, as well as the much longer team names - Hampton & Richmond Borough, with 26 characters, qualified for the First Round proper and filled out the space available. It also has the same limitations - any tie needing a second replay (or a third, or a fourth...) will always keep the same teams "inverted" (i.e. the original home team in the draw will always be the away team in all the replays). The way the scores are worked out has stayed exactly the same from the original - there is a bias towards the home team, as well as the difference in classes (1-6, with 1 and 2 for Premiership teams, 3 for Championship, 4 for League One, 5 for League Two and 6 for all Non-League). Maybe the QL's random number generator works differently to the Spectrum's, because I don't ever remember a team from the fourth tier doing as well as Harrogate Town did, the first time I tried this with the 2020-21 teams... newly promoted into the Football League this season, they progressed right the way through and beat Blackburn Rovers in the final!

Anyway, enjoy this not-really-a-game-at-all, and my QL-ised rendition of Back Home, resurrected 25 years after the original release as the theme tune from Fantasy Football League. All together now: "Saint aaaaaaaand Greavsie talk about the Endsleigh League, as if it's iiiiiiiiimportaaaaaant..."


Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
User avatar
TMD2003
Trump Card
Posts: 168
Joined: Sat Oct 10, 2020 12:18 pm

Re: Dr. Jim's QL Dumping Ground

Post by TMD2003 »

I am having all sorts of idea of things I could do with the QL, none of which will exactly be whizz-bang, but I'm still firmly in the beginner phase. Typing in other people's programs certainly helps, and I've just added six more programs to the Spectribution archive...

Go here, yon heathens, and find amusement from the "Wild West days of programming".

The QL Games page on Spectribution is as complete as it can be at this stage, despite a mere 28 titles. These are all the QL titles indexed by The Type Fantastic tht are classified as games (plus another two that weren't), minus one listing that clearly wasn't printed in its complete form (in that there's a "Listing One" but no "Listing Two" or more). In time, I'll get round to adding the utilities, but there's a good reason I prioritised the games - though I'll have to be a bit secretive about that for a couple of months yet.

These last six programs have all been from the pages of Popular Computing Weekly, which was printed on toilet paper and the original World Of Spectrum 300 dpi scans, with heavy JPEG compression, were... shonky, some of them to the point of being utterly illegible. I suspect it was to do with the amount of server space and individual users' hard drive space available back in the day the scans were done; Mort, on Spectrum Computing, has been scanning magazines in 600 dpi with low compression and some of them - large issues of Sinclair User, for instance - are over 1 GB. I didn't need anything quite so chunky, and Mort doesn't have everything going. But somewhere that seemingly does is the Centre for Computing History, and their online archive of old computer magazines turned up the issues of PCW I needed, in a resolution that showed the listings clearly, even when they'd been printed with smaller text than usual to fit on one page.

The result is that I have typed in five of PCW's Star Games from 1984-85, and the sixth is worth it as well. Examine the code and be horrified at all those GOTO sataments (gasp!), or just take them as they are, a snapshot of QL programming in the machine's early days.


Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
Derek_Stewart
Font of All Knowledge
Posts: 3957
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Dr. Jim's QL Dumping Ground

Post by Derek_Stewart »

Hi Dr,

Do you include games that are written in assembly language?

As I was always told by many Spectrum programmers, that the best games are written in assembler or machine code.


Regards,

Derek
User avatar
TMD2003
Trump Card
Posts: 168
Joined: Sat Oct 10, 2020 12:18 pm

Re: Dr. Jim's QL Dumping Ground

Post by TMD2003 »

Hails... again!

There were a few problems for some of you viewing images that I was hosting from my webspace, previously - but I've sorted out SSL for it, though I'll have to go through that rigmarole every 90 days until I'm a bit more financially solvent (which I might be by the end of the decade, if I'm outrageously lucky).

Anyway, for now, is there anyone who can't see this image (which I've only just uploaded), and if so, what are your browser details?

Image

I'm going to need to know this in... a few days.


Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: Dr. Jim's QL Dumping Ground

Post by mk79 »

Works fine in Opera, Edge, Firefox, Chrome...


Post Reply