The QL UDG Playground

Anything QL Software or Programming Related.
User avatar
Andrew
Aurora
Posts: 786
Joined: Tue Jul 17, 2018 9:10 pm

The QL UDG Playground

Post by Andrew »

Reading about @TMD2003 's trials with UDGs I had the curiosity to look into QL's capabilitities with UDG. Can UDGs be used for simple games? Or only as special fonts in programs? What are possibilities and also the limitations of UDGs?
The first step is to create a new font with the UDG. Dilwyn's article Fun with Fonts offers a lot of great info about creating and using fonts: http://www.dilwyn.me.uk/docs/articles/funfonts.zip
But calculating byte values is tedious work. Of course, there are a number of font creation programs out there, and my favourite is FontEd. But creating UDGs, pixel by pixel, takes a long time and it's rather dull.
So I created RAW2FONT - a small program that builds a QL font from an image, making it very simple to import font sheets from ZX Spectrum or other old computers.
  • The image must be in raw format, have black background, and must use the QL palette
    The image must have X by Y rows of chars (last row may not be complete)
    Each QL character is defined on a tile of W x H pixel (w is 8 to 16 ; H is 9 to 18, thus alowing to have some space between characters and between rows in the image)
    Each QL character is 8x9 pixels, aligned on the left top corner of the tile.
The archive RAW2FONT.zip contains
  • the basic program
    Photoshop QL palette (4 and 8 colors)
    Gimp QL Palette (4 and 8 colors)
    3 fonts - Noir, Vazio and Zeus - each having the png image, the raw image to be used with the program and the QL font created
Attachments
Raw2Font.zip
(40.46 KiB) Downloaded 70 times
Vazio.jpg
Noir.jpg


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

Re: The QL UDG Playground

Post by TMD2003 »

Intriguing. So it can do the whole character set and all the foreign characters at the same time?

When I get enough time, I'll see how my custom Minecraft font works with this. The characters are 4-5 pixels wide, so it'll fir, and I already have it as a PNG that can be easily hacked about in GIMP.

Results will follow... when I'm done scraping paint off the lounge wall. I'm on day six of the job and it just doesn't want to come off easily!


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
dilwyn
Mr QL
Posts: 2753
Joined: Wed Dec 01, 2010 10:39 pm

Re: The QL UDG Playground

Post by dilwyn »

TMD2003 wrote:Intriguing. So it can do the whole character set and all the foreign characters at the same time?

When I get enough time, I'll see how my custom Minecraft font works with this. The characters are 4-5 pixels wide, so it'll fir, and I already have it as a PNG that can be easily hacked about in GIMP.

Results will follow... when I'm done scraping paint off the lounge wall. I'm on day six of the job and it just doesn't want to come off easily!
The QL font format is flexible enough that the range of characters in the font can be altered just by amending the first two bytes in the font file!

The first two bytes are (1) lowest character code in the font file (usually 31) and (2) the number of valid characters in the font less 1 (usually a value of 96).

So assuming those first two bytes are 31 and 96, you get the code of the last character in the font file just by adding them together - 31 (the default chequerboard character) + 96 = 127 (the code of the copyright symbol, or CHR$ 127, the last character in a "standard" QL base character set.

It does mean, though, if you want to create a single font which covers both the standard and extended (accented character set) you can do so if you set appropriate two bytes at the start of the file.

Not all font editors let you do this, but many of the better ones for QL do.

But I agree that designing a font by hand is pretty tedious work - I remember it only too well when I made a load of fonts for my Page Designer programs in the 1980s! :shock: So I'm glad that Andrew has told us about this converter program.


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

Re: The QL UDG Playground

Post by Andrew »

dilwyn wrote:But I agree that designing a font by hand is pretty tedious work - I remember it only too well when I made a load of fonts for my Page Designer programs in the 1980s! :shock:
In 1990, after the Romanian Revolution, when computers became available, all publishing houses started to use them. But there were no romanian fonts! So I created by hand over 120 fonts, at first for GEM (for Ventura Publisher) - each in several sizes and typefaces, as GEM used bitmap fonts. Then I had to create them all over again as True Type, for Adobe Pagemaker. The Romanian (Legacy) keyboard mapping and driver was originally created by me and was sold as a package with the fonts. Microsoft added it to Windows 95, rev. 2 - but they forgot to ask me about it (at that time there was no software copyright law in Romania). Today the copyright law covers only the software created (anywhere in the world) after 1996.


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

Re: The QL UDG Playground

Post by Andrew »

EPISODE 2

So, now that we have an easy way to create the UDG let's try and see what can we build with them.
Creating a nice screen out of UDGs is easy, but time consuming. I tried the old-fashioned way, to draw everything on paper and then build the screen from the sketch. But it takes a lot of time, and I had no desire to print the UDGs to create a puzzle out of them. So I decided to write a UDG TileMap Editor - a simple one. But simple was not also simple to use, so I started to add basic features to it: copy, paste, block commands...
Now it works - so this is sneak preview:
(each screen is 1.5k - but after a bit of optimisation will be less than 1k)
Attachments
Map2.jpg
Map1.jpg
Last edited by Andrew on Mon Sep 13, 2021 6:12 pm, edited 3 times in total.


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

Re: The QL UDG Playground

Post by NormanDunbar »

Hi Andrew,

it's not something I would use, probably, I don;t really do games and such like, but I have to say, those screenshots look absolutely stunning!

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
Andrew
Aurora
Posts: 786
Joined: Tue Jul 17, 2018 9:10 pm

Re: The QL UDG Playground

Post by Andrew »

NormanDunbar wrote:it's not something I would use, probably, I don;t really do games and such like,.
Thank you, Norm
I don't expect anyone will use it, but I want to test the limits of compiled basic for simple games.


User avatar
XorA
Site Admin
Posts: 1358
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: The QL UDG Playground

Post by XorA »

Andrew wrote:EPISODE 2

So, now that we have an easy way to create the UDG let's try and see what can we build with them.
Creating a nice screen out of UDGs is easy, but time consuming. I tried the old-fashioned way, to draw everything on paper and then build the screen from the sketch. But it takes a lot of time, and I had no desire to print the UDGs to create a puzzle out of them. So I decided to write a UDG TileMap Editor - a simple one. But simple was not also simple to use, so I started to add basic features to it: copy, paste, block commands...
Now it works - so this is sneak preview:
(each screen is 1.5k - but after a bit of optimisation will be less than 1k)
Most of the way to a Dizzy port there :-D


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

Re: The QL UDG Playground

Post by NormanDunbar »

Don't let Brane2 know you wrote something useful in SuperBASIC, he won't be impressed! :D He's apparently not a fan of any BASIC version.

Not that I'm saying he's not entitled to an opinion of course, he certainly is. I'm just having a bit of fun.


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
Andrew
Aurora
Posts: 786
Joined: Tue Jul 17, 2018 9:10 pm

Re: The QL UDG Playground

Post by Andrew »

NormanDunbar wrote:Don't let Brane2 know you wrote something useful in SuperBASIC, he won't be impressed! :D He's apparently not a fan of any BASIC version.

Not that I'm saying he's not entitled to an opinion of course, he certainly is. I'm just having a bit of fun.


Cheers,
Norm.
I noticed that when he stated his view on Lear PCB Design's 132k of Basic code! :D
But If I wanted to impress someone with UDGs then I would move to ZX Spectrum world :P


Post Reply