stevepoole wrote:Hi TMD,
On some more recent QL systems, replace 131072 with SCR_BASE, as this keeps any shifts in the memory area located....
Also replace 32768 (bytes), with SCR_XLIM * SCR_YLIM
Eg: 100 SBYTES flp1_filename, SCR_BASE, SCR_XLIM * SCR_YLIM
On emulators, you may need to modify again to allow for resolution : eg: bytes = ( SCR_XLIM * SCR_YLIM ) * 2 : (where '2' doubles to a bigger screen resolution).
If in doubt, experiment to adapt to your system.... starting with the smaller values so as not to load in non_screen addresses, which may cause crashes !
Steve.
Even better, instead of trying to adjust the SCR_XLIM part and having to test for the different colour depths, use SCR_LLEN, which tells you the number of bytes per line of the screen display in SBASIC. You can hide the absence of these SBASIC functions from SuperBASIC when running on a QL by using a VER$ function call to examine the version of BASIC that the program is running on:
Code: Select all
1000 DEFine PROCedure Save_Screen (filename$)
1010 LOCal v$
1020 v$ = VER$
1030 IF v$ = 'HBA' THEN
1040 REMark SBASIC
1050 SBYTES filename$,SCR_BASE,SCR_LLEN*SCR_YLIM
1060 ELSE
1070 REMark other systems
1080 SBYTES filename$,131072,32768
1090 END IF
1100 END DEFine Save_Screen
Line 120 makes a note of the BASIC version on this machine. A little peculiarity is that you should really copy VER$ to a variable rather than use it in an expression on some systems - it's a documented bug that upsets the stack on some versions of BASIC, can't remember the full details, probably covered in Simon Goodwin and Mark Knight's articles on S*BASIC bugs.
Line 1030 tests if we are running on SBASIC (version code is HBA) and if it is, work out the screen size by multiplying the screen line length by the number of lines down the screen. The function SCR_BASE tells you where in memory the screen starts.
If we are not running on SBASIC, line 1080 then saves the screen as it would on a standard QL.
A saved screen will then load with LBYTES filename$,SCR_BASE as long as the screen is the same size as the current display. Sadly, an SBYTES screen does not save the screen dimensions within the file, so the only check you can do when reloading is that the length matches the current display. At best with a mismatch, you'll get a scarmbled display or a picture which only covers part of the display. At worst, screen files larger than the screen will overwrite what is beyong the screen in memory (e.g. system variables) and a crash will follow.
This copes with all screen variations with two notable exceptions.
1.
Aurora. The video display has a fixed line width, which may be larger than the visible part in certain modes. To work around this, you would need to test for an Aurora then do different variants of Steve's method depending on the display mode, for mode 4 or 8 it would be pixel width DIV 4, while for the 256 colour mode it would be screen width * screen height.
2.
uQLx-derived emulators. Some, such as SQLUX, have the facility to use fixed higher resolution displays in mode 4. Meaning that the line width may not be 512 pixels/128 bytes. Again, you'd need to find a way to test for uQLx then use functions defined in its BASIC to get the size of screen to save.
Once you have the code needed to check for those systems, you can add extra IF statements to handle those cases - afraid I don't know how to test for Aurora and uQLx from BASIC, although their manuals probably explain.
So, sadly, when it comes to QL graphics, nothing is simple, largely because the original QL design never really foresaw the need for handling high resolution or high colour displays, so the extensions to handle it are only present in later versions of BASIC. So it can be hard to make the necessary tests to allow routines to adapt to also work on the older systems.
In fairness, not that many people regularly use the high colour, high resolution modes, so just using SBYTES filename$,131072,32768 will probably work 90% of the time, as long as you document that your program will only work on systems with QL-style display.