Page 1 of 2

Lunar lander and UDG generally

Posted: Sat Mar 16, 2024 11:14 am
by Jbizzel
I ran Lunar lander using a SGC on a bbql.

The udg routine doesn't work, but not sure why?

Actually this picture isn't helpful. Essentially the udgs are coloured letters rather than a lunar lander!
IMG_20240316_104545.jpg
Here is the udg routine...
IMG_20240316_104712.jpg
Not sure what is wrong. Can anyone help?

Re: Lunar lander and UDG generally

Posted: Sat Mar 16, 2024 11:21 am
by t0nyt
Not used BASIC much for a while but shouldn’t line 820 be Restore 860?

Re: Lunar lander and UDG generally

Posted: Sat Mar 16, 2024 11:33 am
by Jbizzel
Thanks, it's not fixed the issue, but hasn't seemed to break anything!
IMG_20240316_113403__01.jpg

Re: Lunar lander and UDG generally

Posted: Sat Mar 16, 2024 12:11 pm
by Derek_Stewart
Hi,

I tired the game in sQLux and Q-emulator, the UDGs are not defined if the RAM s greater than 256K.
Lunar.png
Lunar.png (5.9 KiB) Viewed 869 times

The actual programme does not run very well, i fact I would say the author does not understand the QL graphics setup, he is poke-ing into the channel table, which, is no a good idea.

It would be better to define a font and attach it to the QL Channel.

I will update this with a proper UDG Font routine.

Re: Lunar lander and UDG generally

Posted: Sat Mar 16, 2024 12:30 pm
by tofro
On the QL, "everything is floating". That means that POKEing to fixed addresses is potentially dangerous.

Your POKE in line 810 pokes to memory in the free memory area of the QL . This might or might not be what you assume (you seem to assume that it's a font address in a channel definition block). Apparently, on your system that's not it :) (and, as Derek rightly said: That is a clear no-no!). The address of a channel definition block depends very much on your running OS, your Minerva dual-screen settings and the history of opened and closed channels in your system.

You're also POKEing your font not into the allocated memory at a (line 830), but rather (again) into free memory at udg_base. It's a bit of a miracle your code didn't crash the machine.

The proper way to set a font in a channel is actually: Use Toolkit II's (or SMSQ/E's) CHAR_USE function to set the font.

I was thinking about providing an alternative way to do it without TK2, but you seem to be using it, so, so let's make it simple:

Code: Select all

100 udg_base = ALCHP (<fontsize>)
101 REMark POKE your font starting from udg_base here (line 820+ in your program)
110 CHAR_USE #channel,udg_base,0

Re: Lunar lander and UDG generally

Posted: Sat Mar 16, 2024 1:41 pm
by Jbizzel
Thanks for your help, this isn't my code, and I'm not familiar with the tk2 commands.

Having a go though.

When you say font size you mean the size of the data in the data statements?

11*9 bytes, + 2 bytes in the initial data statement, so the frontsize is 808 maybe

Re: Lunar lander and UDG generally

Posted: Sat Mar 16, 2024 1:55 pm
by tofro
Jbizzel wrote: Sat Mar 16, 2024 1:41 pm When you say font size you mean the size of the data in the data statements?
11*9 bytes, + 2 bytes in the initial data statement, so the frontsize is 808 maybe
yep.

cw/you/your program/ :) No offense meant ;)

Re: Lunar lander and UDG generally

Posted: Sat Mar 16, 2024 2:06 pm
by Derek_Stewart
Hi,

Have look at QL Today Vol13 issue 2,3,4 Dilwyn did an excellent article on the use of Fonts.

Re: Lunar lander and UDG generally

Posted: Sat Mar 16, 2024 2:07 pm
by Jbizzel
Haha, don't worry :)

If only I *HAD* written it :D :D


Can you help me with what the new poke should look like?

Is it ...

Code: Select all

poke (udg_base +n ), but 
Assuming I am wrong, but still it shows my workings out....
IMG_20240316_141259.jpg

Re: Lunar lander and UDG generally

Posted: Sat Mar 16, 2024 2:24 pm
by tofro
Looks alright, but the CHAR_USE should (logically, I don't think it matters) come after the font is poked.