by:
Réal Gagnon
8286 St-Hubert
Montréal (Qué)
CANADA H2P 1Z3
Default device on the QL
Say you are writting a program and it is important to know from which device the user is running it. What can you do?
If the user’s QL is equipped with TOOLKIT II, then it is possible to set the default devices for the program and the data and retrieve them with the functions PROGD$ and DATAD$. But if the user don’t set default devices then we are out of luck.
One solution to this problem is to look in the system variable area to determine from which device the QL was booted. The following function, BOOT_DEVICE$, will retrieve that information.
DEFine FuNction BOOT_DEVICE$
pointer1=PEEK_L(164096)+16
pointer2=PEEK_L(pointer1)+36
length=PEEK_W(pointer2)
b$=""
FOR i=0 to length
b$=b$&CHR$(PEEK(i+length+pointer2))
END FOR i
RETurn b$&"1_"
END DEFine
The first variable, POINTER1, contains SV_FSDEF which give us the address of the file system physical definition. From this address, we read the variable POINTER2, called FS.NMLEN in the QL TECHNICAL GUIDE. This word gives us the length of the boot device name. From that point, all we have to do is to read the device name with the PEEK function.
Type in the function BOOT_DEVICE$ and try the following command to test it:
PRINT "QL booted from ";BOOT_DEVICE$
For example, the BOOT_DEVICE$ function can be used in a menu program to detect from which device the QL was booted from.
QL Tip
To load a machine code file in memory, we have to proceed in 3 steps:
1. reserve some RAM with RESPR
2. load the file with LBYTES
3. execute the machine code with CALL
For example, we have a game called YOYO, which represents 5000 bytes. To start the game, we type:
a=RESPR(5000)
LBYTES mdv1_YOYO,a
CALL a
It is possible to do the same thing with only 1 or 2 commands.
-with TOOLKIT II:
LRESPR mdv1_YOYO
-without TKII:
LBYTES mdv1_YOYO,RESPR(5000):
CALL RESPR(0)
that way we don’t have to declare any variable and it is faster to type.
Special effects with CSIZE
The appearance is important, even with software. Let’s see some techniques to make the look of our programs more pretty.
The command CSIZE is used to change the character size. The syntax is simple:
CSIZE [channel],width,heigth
The width parameter can be 0,1,2 or 3. The heigth parameter can be 0 or 1.
When used alone, CSIZE is boring but with a judicious combinaison of INK and PAPER the result can be quite interesting. Try this:
OPEN#5,scr_200x30a195x25
PAPER#5,0: INK#5,7: BORDER#5,1,7
CLS#5
CSIZE#5,2,1: INK#5,49
PRINT#5,"The Quebec Link"
Ok, now if we use the OVER function and the CURSOR command, the result is a totally unexpected and very good looking!
OPEN#5,scr_200x30a195x25
PAPER #5,2 : INK#5,7 : BORDER#5,1,7
CSIZE#5,2,1: OVER#5,1: CLS#5
test$="The Quebec Link"
CURSOR#5,1,1 : PRINT#5,test$;
CURSOR#5,2,2 : PRINT#5,test$;
OVER#5,-1
CURSOR#5,1,1 : PRINT#5,test$;
CURSOR#5,2,2 : PRINT#5,test$;
CSIZE#5,1,0
Try to experiment with different PAPER, INK and CSIZE values.
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.