
Tucked away in a description of the QL hardware in the Technical Guide is mention of the fact that bit 7 of the Display Control Register “can be used to switch the base of screen memory from $20000 to $28000”. Hmmm, interesting I thought and went on to more pressing concerns.
Recently, I went back to investigate the dual screen display. There is a discussion & program dealing with it in Adrian Dickens “QL Advanced User Guide”. The news is it is real; but flawed. First a quick overview of the QL memory map.
K HEX USE
-------------------------------------------------------
256K 00040000 Top of On Board RAM
192K 00030000 Top of Screen1
Top of Common Heap
Base of Common Heap
00028480 Top of Sys_Var
160K 00028000 System Variables & Base of Screen1
00027FFF Top of Screen0
128K 00020000 Base of Screen0
-------------------------------------------------------
The immediate problem with the second Screen is the fact that the System Variables are locked into $28000 which is the base of Screen1. This means that if you simply flick the bit which controls the base of the display, you will get a bunch of garbage on the top of your screen. The garbage is the video representation of the System Variables.
You can take a look at this effect with the following short Superbasic Procedure.
100 REMark switch in Screen 2
110 :
120 DEFine PROCedure SWITCH
130 SV_MCSTA=163892 : REMark $28034
135 DC_REG =98403 : REMark $18063
140 DCR_STATUS=PEEK(SV_MCSTA)
150 DCR_STATUS=DCR_STATUS ^^ 128: REMark toggle bit 7
160 POKE SV_MCSTA,DCR_STATUS : REMark tell Sys_Var
170 POKE DC_REG,DCR_STATUS : REMark tell hardware
180 END DEFine SWITCH
190 :
This is interesting, but useless. To make a useable display, one has to be a little trickier. One of the neat things about the QL is that QDOS is extensible. In particular, one can link in tasks for the QL to perform after each interrupt. There is a Level 2 Interrupt (called a Frame Interrupt) on the QL every 1/60 second; which is related to the Vertical Sync signal.
What we need to do is Link in a short Task which checks what screen we are displaying; then if we are displaying Screen0, do nothing, while if we are displaying Screen1, wait until the display has passed the 5K or so of System Variables then switch in Screen1.
The assembly language code to do this is listed below in the file DualScr_asm. Once you have this code installed, you will run into the next problem. There is no support in QDOS for writing to Screen1. It is evident that in the development of the QL, this was a matter of some debate, because in the SCR/CON Channel Definition Block (CD_Blk), there is an entry (SD_SCRB) Base address of screen. The unfortunate fact is that the SCR/CON device driver does not use this variable. Instead the base address ($20000) is hardcoded into the driver. This was no doubt done in concert with the decision to tie the System_Variables at $28000.
As the QL is at present, if the driver did use the CD_Blk variable, clearing the screen would erase all the System_Variables; so it is just as well that it is not implemented!
What’s to do? It seemed to me that the simplest method to use would be to simply copy Screen0 into the useable part of Screen1. The Superbasic extension SCOPY performs this task. I wanted a Clear Screen1 capability as well, so I added the PROCedure SCLR. This procedure expects one parameter which is used to colour Screen1. The video ram of the QL display is arranged thus:
Mode 4
Even Byte : Odd Byte
76543210 76543210 - Bits
GGGGGGGG : RRRRRRRR G - Green
R - Red
Mode 8 F - Flash
Even Byte : Odd Byte B - Blue
76543210 76543210 - Bits
GFGFGFGF : RBRBRBRB
Passing SCLR the parameter 0, will paint the screen black. You can play with other parameters to see the effect of setting various bits. If you use 65280 for Green, the interpreter returns an overflow error; but -256 works fine. 255 paints the screen red.
The procedure SCR0 turns off the Auto-Toggle and gives you the default display, ie. Screen0. The procedure SCR1 turns off the Auto-Toggle and gives you Screen1. The procedure SCRA turns on the Auto-Toggle; ie. switch between the two screen using <CTRL><F5>.
The function SCRNUM tells you which screen is currently being displayed, 0 or 1. The function SWHERE tell you the base of the Common Heap Memory reserved by the initialization code.
There are some proviso’s with this code. It should be initialized from a boot: in particular before a directory of a second device is done. This is because we want Screen1 to begin as close to the Base of the Common Heap as possible. If you do a directory of another device before initializing; QDOS reserves some common heap as a Channel Definition Block and a Physical Definition Block. This will show up as a white band similar to what SWITCH produces.
Related to this situation is the value of the Timeout value used to wait before switching Screen1 on. See the comments in the _asm file.
The other proviso, is that the dividing line where Screen1 switches in is not stable. The easiest way to handle this problem, is to put a black border over the region similar to the PROCedure SDEMO below.
The first SBasic program below creates a file DSCR_ext which is used by the second the SBasic program SDEMO.
100 REMark PLAY WITH SCREEN UTIL
110 :
120 LAYOUT
130 INIT
140 DEMO
150 STOP
160 :
170 DEFine PROCedure DEMO
180 PAPER 0: CLS
190 PICTURE
200 PAPER 4
210 AT 0,0: PRINT 'SCREEN 1'
220 SCOPY
230 SCR1
240 CLS
250 SCR0
260 SCRA
270 LIST TO 260
280 AT 0,0: PRINT 'SCREEN 0'
290 PRINT#0,'USE <CTRL><F5> TO TOGGLE SCREENS'
300 END DEFine DEMO
310 :
320 DEFine PROCedure PICTURE
330 FOR M=0 TO PI STEP .25: FOR N=0
TO 105 STEP 15 : INK (RND(2,6)): CIRCLE 20
0,128,N,.5,M: END FOR N : END FOR M
340 INK 7
350 END DEFine PICTURE
360 :
370 DEFine PROCedure INIT
380 nam$='SCR2_ext'
390 dev$='flp1_'
400 LBYTES dev$ & nam$,RESPR(512)
410 PRINT'Loaded'
420 CALL RESPR(0)
430 PRINT'Initialized'
440 END DEFine INIT
450 :
460 DEFine PROCedure LAYOUT
470 WINDOW#0,512,64,0,0 : BORDER #0,10,0
480 WINDOW#1,512,192,0,64 : BORDER #1,10,0
490 WINDOW#2,512,192,0,64 : BORDER #2,10,0
500 PAPER#2,4: INK#2,0
510 PAPER#1,4: INK#1,7
520 PAPER#0,2: INK#0,7
530 SCALE 256,0,0: MODE 4
540 END DEFine LAYOUT
550 :
100 REMark Create SCR2_EXT file
110 :
120 DLOAD
130 DSAVE
140 STOP
150 :
160 DEFine PROCedure DSAVE
170 REMark Save memory to file
180 nam$='SCR2_ext'
190 dev$='flp1_'
200 SBYTES dev$ & nam$,RESPR(0),408
210 END DEFine DSAVE
220 :
230 DEFine PROCedure DLOAD
240 REMark writes DATA to memory & inits PROC & FUNC
250 addr=RESPR(512)
260 RESTORE 400
270 REPeat loop
280 READ x: IF x=-1: EXIT loop
290 POKE addr,x
300 addr=addr+1
310 END REPeat loop
320 PRINT#0,'Loaded '
330 CALL RESPR(0)
340 PRINT#0,'Initialized'
350 END DEFine DLOAD
360 :
370 REMark SCR2_ext code for 2 screens utility
380 REMark SCLR,SCOPY,SCR0,SCR1,SCRA; SCRNUM,SWHERE
390 REMark
400 DATA 67,250,0,70,52,120,1,16
410 DATA 78,146,116,0,34,60,0,3
420 DATA 0,0,65,249,0,2,128,0
430 DATA 32,40,0,8,65,240,8,0
440 DATA 146,136,47,1,112,24,78,65
450 DATA 34,31,74,128,102,24,67,250
460 DATA 1,16,34,136,67,250,1,24
470 DATA 65,250,1,12,112,28,33,73
480 DATA 0,4,78,65,112,0,78,117
490 DATA 0,5,0,144,4,83,67,82
500 DATA 65,0,0,144,4,83,67,82
510 DATA 48,0,0,144,4,83,67,82
520 DATA 49,0,0,88,5,83,67,79
530 DATA 80,89,0,34,4,83,67,76
540 DATA 82,0,0,0,0,2,0,174
550 DATA 6,83,67,82,78,85,77,0
560 DATA 0,116,6,83,87,72,69,82
570 DATA 69,0,0,0,52,120,1,18
580 DATA 78,146,74,128,102,8,12,67
590 DATA 0,1,103,4,112,241,78,117
600 DATA 48,54,152,0,65,250,0,154
610 DATA 32,80,67,249,0,3,0,0
620 DATA 48,192,177,201,101,250,96,0
630 DATA 0,132,67,249,0,3,0,0
640 DATA 32,9,65,250,0,124,32,80
650 DATA 144,136,83,64,69,249,0,2
660 DATA 128,0,19,34,81,200,255,252
670 DATA 96,98,67,250,0,104,80,209
680 DATA 96,90,67,250,0,96,66,81
690 DATA 96,82,67,250,0,88,50,188
700 DATA 0,255,96,72,67,250,0,74
710 DATA 34,17,34,110,0,88,93,73
720 DATA 45,73,0,88,66,118,152,0
730 DATA 74,129,103,16,52,60,8,32
740 DATA 83,66,227,129,104,250,226,145
750 DATA 61,130,152,0,45,129,152,2
760 DATA 120,2,96,24,114,1,194,58
770 DATA 0,29,34,110,0,88,85,73
780 DATA 45,73,0,88,61,129,152,0
790 DATA 56,60,0,3,112,0,78,117
800 DATA 0,0,0,0,0,0,0,0
810 DATA 0,0,0,0,0,0,18,46
820 DATA 0,52,19,193,0,1,128,99
830 DATA 74,43,0,7,103,36,74,174
840 DATA 0,152,102,50,74,174,0,156
850 DATA 102,44,74,46,0,238,102,38
860 DATA 48,60,6,44,81,200,255,254
870 DATA 8,193,0,7,19,193,0,1
880 DATA 128,99,74,43,0,6,103,14
890 DATA 74,46,0,51,103,8,81,238
900 DATA 0,51,70,43,0,7,78,117,-1
910 :
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.