Ok, so what, if anything is wrong with the plot_4 routine? The answer is that there is no checking to see if the x and y values are out of range. If you try to plot say pixel 2000, 494 the chances are that it would corrupt something in memory (probably a system variable) with either immediate or later results.
It is probably easy to check the x value (or accross) because there are 8 pixels per word in mode 4 so multiplying the scan line width (in bytes) by 4 should give the maximum resolution across. Indeed, on my QXL, this works out. My scan line is 160 bytes and the maximum resolution is 640 across by 480 down. 160 times 4 is indeed 640. Unfortunately, I cannot think or find a method of calculating the maximum display resolution in the 'downward' direction.
It may be true that all current display resolutions that are 640 accross must be 480 down, but is this true or not? It appears not. A quick check with the demo version of QPC 2 (an old demo version at that) shows that It can have the following resolutions ( across by down) :
X (Across) | y (Down) |
---|---|
512 | 256 |
640 | 400 |
640 | 480 |
800 | 600 |
1024 | 768 |
1152 | 864 |
1280 | 1024 |
1600 | 1200 |
So we can already see that detecting a 640 pixels across resolution leads to a decision about the downward resolution, is it 400 or 480?
I feel the need to be told if there is a way, simple and effective and which works on all machines, whether thay are black box QLs or Q40s or emulators, to tell the maximum screen resolution. Anyone got any ideas? If so, Dilwyn will be glad to print the article you are about to write !!