QStar1 revisited - High Colour mode

Anything QL Software or Programming Related.
User avatar
Artificer
Over Heated PSU
Posts: 147
Joined: Fri Nov 24, 2017 8:43 am

Re: QStar1 revisited - High Colour mode

Post by Artificer »

Dilwyn wrote: You only need to do the code below if your program starts with no windows open. SCR_XLIM etc need an open primary channel.

In my program, to avoid this, I open a tiny temporary window somewhere before SCR_XLIM and SCR_YLIM get a chance to do so, get the info from SCR_XLIM/SCR_YLIM/SCR_LLEN etc, then close that before opening the main windows.
I find than compiled programs sometimes open with "legacy" windows especially #0 or #1. To avoid this closing all windows (#0,#1,#2) at the start and then opening #0 simply as

XXX OPEN#0,"con_" and then using
X10 xsz=SCR_XLIM(#0) : ysz=SCR_YLIM(0)
avoids the ghost window issue.

cheers


Derek_Stewart
Font of All Knowledge
Posts: 4610
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: QStar1 revisited - High Colour mode

Post by Derek_Stewart »

Hi,

With regards to SMS2, I was using an Atari STFM with Mode 8 emulator board, running Level E drivers, long before SMS2.

I may have the name of the Atari QL drivers incorrect, I will look out the floppy disks, an get the correct data.

SMSQ was written for the the QXL, and is a different implementation of SMS. SMS2 has a CLI, whereas SMSQ has a Superbasic interpreter.

The Q40/60, has a high resolution of 1024x512 Mode 33 (65535 colours), using a special version of SMSQ/E, still in development.

The Atari Mega STE, TT030 can only produce 800x600 in Atari High Blacj and White Resolution mode.

A QVME board attached to the VME bus of the Mega STE, TT030 cou,d produce higher resolutions in Mode 4 (4 colours)

However, the Q68 is comparable to the TT030 and QVME, in DISP_MODE 4 (1024x768 Mode 4), but can run more QL software in orher screen modes than the Atari QL emulator.

QSTAR1 in DISP_MODE 6 (1512x384 Mode 33), and the excellent QSTAR2, PITMAN, Picole 1,2


Regards,

Derek
Derek_Stewart
Font of All Knowledge
Posts: 4610
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: QStar1 revisited - High Colour mode

Post by Derek_Stewart »

Artificer wrote: Mon Jan 06, 2025 8:49 pm
Dilwyn wrote: You only need to do the code below if your program starts with no windows open. SCR_XLIM etc need an open primary channel.

In my program, to avoid this, I open a tiny temporary window somewhere before SCR_XLIM and SCR_YLIM get a chance to do so, get the info from SCR_XLIM/SCR_YLIM/SCR_LLEN etc, then close that before opening the main windows.
I find than compiled programs sometimes open with "legacy" windows especially #0 or #1. To avoid this closing all windows (#0,#1,#2) at the start and then opening #0 simply as

XXX OPEN#0,"con_" and then using
X10 xsz=SCR_XLIM(#0) : ysz=SCR_YLIM(0)
avoids the ghost window issue.

cheers
The reason for this "ghost window" is that the compiled programme is still trying to open channel 0 1,2 rather thsn opening its own channels.


Regards,

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

Re: QStar1 revisited - High Colour mode

Post by dilwyn »

Andrew, if you really want to test for screen size etc before drawing the window, I've had this thought, but it's a bit dirty and would need the opinion of someone more expert on the particular subject it uses than me. I've only tried it on my QPC system which was in MODE 32, resolution 1024x768.

It might only "happen" to work on my system and might not work anywhere else and there might be snags I haven't thought of - I wrote the idea down while it was in my head having tea and didn't test it beyond one little run on my PC. Might be worth exploring to see if valid and it does what I think it does. All it does is try to PEEK the screen information out of the con linkage block and compare it to what the SCR_XLIM etc functions say.

On machines with pointer environment (QDOS + SMSQ) there is something called a Con Linkage Block, pointed to by system variable sys_clnk (offset $C4). In machine code there are traps to access it correctly. Below is a very quick and dirty BASIC program to access it. Even if what I do is deemed valid (and I doubt it, seems too dirty) it's showing how to use PEEKs to tease the screen information out of this data block.

You'd need to think of a way of checking if the machine has pointer environment, otherwise assume the machine is a 512x256 BBQL-style screen. I have a feeling that sys_clnk will have a value of zero if there is no con linkage block.

Might be worth experimenting with even if I'm wrong about its non-validity. And using PEEK/POKE indirection to reduce the risk of things moving around in between commands.

I'm nervous about this, please don't shout at me too much if I'm wrong.

Code: Select all

100 REMark access Console Linkage Block
110 CLS
115 PRINT'ITEM' TO 18;'SBASIC' TO 30;'FROM BLOCK'
120 sysbase=VER$(-2) : REMark system bvariables
130 sys_clnk=$C4 : REMark LONG pointer to console linkage
140 blk=PEEK_L(sysbase+sys_clnk):REMark pointer device driver definition block
150 PRINT 'SCR_BASE=' TO 18;SCR_BASE TO 30;PEEK_L(blk+$E8)
160 PRINT'BYTES PER SCREEN=' TO 18;SCR_LLEN*SCR_YLIM TO 30;PEEK_L(blk+$EC)
170 PRINT'SCR_LLEN=' TO 18;SCR_LLEN TO 30;PEEK_W(blk+$F0)
180 PRINT'SCR_XLIM=' TO 18;SCR_XLIM TO 30;PEEK_W(blk+$F2)
190 PRINT'SCR_YLIM=' TO 18;SCR_YLIM TO 30;PEEK_W(blk+$F4)
Sample output of the program
Sample output of the program
conlinkageblock.jpg (5.16 KiB) Viewed 628 times


User avatar
RalfR
QL Wafer Drive
Posts: 1145
Joined: Fri Jun 15, 2018 8:58 pm

Re: QStar1 revisited - High Colour mode

Post by RalfR »

Derek_Stewart wrote: Mon Jan 06, 2025 8:56 pmThe reason for this "ghost window" is that the compiled programme is still trying to open channel 0 1,2 rather thsn opening its own channels.
Must be a Turbo problem, I've never had that with QLiberator when I open my own channels.


7000 4E75
User avatar
dilwyn
Mr QL
Posts: 3032
Joined: Wed Dec 01, 2010 10:39 pm

Re: QStar1 revisited - High Colour mode

Post by dilwyn »

RalfR wrote: Mon Jan 06, 2025 9:17 pm
Derek_Stewart wrote: Mon Jan 06, 2025 8:56 pmThe reason for this "ghost window" is that the compiled programme is still trying to open channel 0 1,2 rather than opening its own channels.
Must be a Turbo problem, I've never had that with QLiberator when I open my own channels.
SBASIC documentation does actually say that SCR_XLIM etc should have an open primary channel when called, otherwise it needs a temporary window. I don't know if Andrew gets the compiler to open windows as the program starts, or opens them himself. Most of us would test SCR_XLIM, SCR_YLIM after opening the primary window, so we'd never notice the ghost window, Andrew hinted at why he checked SCR_XLIM etc before opening a primary window.


User avatar
pjw
QL Wafer Drive
Posts: 1588
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: QStar1 revisited - High Colour mode

Post by pjw »

The basic SBASIC Thing will always open a "ghost" window if any attempt is
made to access channels #0, #1 or #2 and those channels are not open. Any
IO going to either of them will end up in that window; they are treated as
one.

So if you EXecute the "program" 10 PRINT "Hello World!": PAUSE, said window
will open and display the text without a fuss. PRINT defaults to channel
#1. PAUSE on the other hand defaults to channel #0, so EXecuting the
program: 10 BEEP 2000, 2: PAUSE will also open that window, with no text,
just the beep.

You could also try the program: 10 LIST: PAUSE. Same result.

However, if you specify a channel number, such as PRINT#1, or PAUSE#0, or
LIST#2 you will get an error if those channels arent open!

All this was done to make life easier, not to complicate things!

Home grown toolkit keywords, however, wont behave like this. Only all(?)
the built-in system keywords that default to the three basic channels. Thus
SCR_XLIM etc will open a "ghost" window, unless you take precautions.

Now I already demonstrated (at least once) on the forum how this could be
done without using channels at all. I'll repeat it again for slow learners:

Code: Select all

110 sys_clnk = $C4: pt_xscrs = $F2: pt_yscrs = $F4
112 scrx% = PEEK_W(!sys_clnk! pt_xscrs): REMark Get screen size without
114 scry% = PEEK_W(!sys_clnk! pt_yscrs): REMark  a channel (PE only!)
116 :
but this is specific for SMSQ/E or Qdos with PE (+ a little extra leg work).

A more general approach, for even slower learners is:

Code: Select all

ch = fopen('con_'): rem This will be your main window at some point
scx% = SCR_XLIM(#ch): scy% = SCR_YLIM(#ch): rem Get the screen size
do whatever other initialisation you desire here..
...
window#ch; xs, ys, xo, yo: cls#ch: rem Now reveal your window
Remember what was recently said about invisible windows? As long as you dont
CLS it doesnt matter what size the window is!


Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
User avatar
dilwyn
Mr QL
Posts: 3032
Joined: Wed Dec 01, 2010 10:39 pm

Re: QStar1 revisited - High Colour mode

Post by dilwyn »

pjw wrote: Mon Jan 06, 2025 10:44 pm
Now I already demonstrated (at least once) on the forum how this could be
done without using channels at all. I'll repeat it again for slow learners:

A more general approach, for even slower learners is:
OK, sorry I spoke. I won't ever try to help anyone again.


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

Re: QStar1 revisited - High Colour mode

Post by Andrew »

Ok - fixed it! All ghost windows are gone! Because there were 3 or 4, stacked on top of each other.
Yes, part of the problem was calling SCR_XLIM and SCR_YLIM without an open window (The large black ghost window)
The other part of the problem was that in SUPERBASIC is ok to have something like this

Code: Select all

100  fnt1=ALCHP(875)
110 Lbytes win1_font1_fnt, fnt1
120 OPEN#4, scr_
110 CHAR_USE#4,fnt1,0
.....
1000 WIndow#4, 100,100,10,10: Paper#4,4:Cls#4
The window is shown only when line 1000 is executed (the Window keyword) and it will use the loaded font
But in a compiled program a small ghost window is created at line 110!
In fact if you have opened the channel but you have not created the window yet and you call any keyword that needs a window, a ghost window will be automatically created by the compiler.
Thank you again Dilwyn, for pointing out the SCR_XLIM, SCRY_LIM root cause!

Please download the fixed QStar - no ghost windows and also faster level loading!
Attachments
QSTAR1.zip
(435.89 KiB) Downloaded 44 times


User avatar
RalfR
QL Wafer Drive
Posts: 1145
Joined: Fri Jun 15, 2018 8:58 pm

Re: QStar1 revisited - High Colour mode

Post by RalfR »

pjw wrote: Mon Jan 06, 2025 10:44 pmch = fopen('con_'): rem This will be your main window at some point
scx% = SCR_XLIM(#ch): scy% = SCR_YLIM(#ch): rem Get the screen size
do whatever other initialisation you desire here..
...
window#ch; xs, ys, xo, yo: cls#ch: rem Now reveal your window
Thank you, that works, although the procedure is actually a bit obscure. Because when I open the window, it has the default size of 448x180. Or another one that you set. Why the two functions then show the actual screen size instead of the window size is not something you have to understand, you just have to know it.


7000 4E75
Post Reply