Qbasicnews.com

Full Version: Windows issues
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I use Qbx out of Windows 98. In Windows 95, I could leave a basic program running in the background while I did other things (Some of my fractals can take hours to run). In 98 the program is suspended when I leave it. There was a short time when they did work in the background, but I don't know what I did to cause it to work, or what happened that it stopped working. Does any one have any clues?
Also, using the built in screen modes, I can use Print Scrn to copy a screen to the Windows clipboard, switch to a graphics program in Windows to manipulate it, then switch back to BASIC and find my original screen intact. When I use the SVGAQB library for higher resolution and color, Windows won't capture the screen and If I leave BASIC, the image on the screen is messed when I return. Is there a graphics library that is more compatible with Windows?
Quote:I use Qbx out of Windows 98. In Windows 95, I could leave a basic program running in the background while I did other things (Some of my fractals can take hours to run).
So you're doing fractals in SVGA... You should contact Jark, he's doing the same thing..

Quote: In 98 the program is suspended when I leave it. There was a short time when they did work in the background, but I don't know what I did to cause it to work, or what happened that it stopped working. Does any one have any clues?
You must edit the exe properties (I have spanish W2000 so the labels i provide may not be correct) In "Miscellaneous" tab you must uncheck "Always paused" in "Background execution". There is a default shortcut in the Windows directory, if you edit that one, all new DOS exes you create will use it.


Quote: Also, using the built in screen modes, I can use Print Scrn to copy a screen to the Windows clipboard, switch to a graphics program in Windows to manipulate it, then switch back to BASIC and find my original screen intact. When I use the SVGAQB library for higher resolution and color, Windows won't capture the screen and If I leave BASIC, the image on the screen is messed when I return. Is there a graphics library that is more compatible with Windows?
This won't work in SVGA, Windows does'nt preserve DOS SVGA status or capture DOS SVGA screens. AFAIK no library solves it. The solution Jark uses is to save the graphics to a BMP file so he can display or print it. Check Jark's TCLib, a 24-32Bit SVGA library, able to save to BMP
http://forum.qbasicnews.com/viewtopic.php?t=3458
24 bit bmp saver from 16 bit screen. You need to figure out what rts.dir$ is..
Also, it uses UGL's uglPGet. Gets a point from the screen (video) array.

Code:
SUB output.bitmap
bmp.dir$ = rts.dir$ + "screen\"

''this commented part clears out lastloc.txt.
'OPEN SHRTFN$(bmp.dir$ + "lastloc.txt") FOR BINARY AS #1
'n$ = CHR$(0): PUT #1, 1, n$
'exit.program
''----------

OPEN bmp.dir$ + "lastloc.txt" FOR BINARY AS #1
n$ = " ": GET #1, 1, n$: n% = ASC(n$) + 1: n$ = CHR$(n%): PUT #1, 1, n$: CLOSE
n$ = LTRIM$(STR$(n%))
n$ = STRING$(4 - LEN(n$), "0") + n$
OPEN SHRTFN$(bmp.dir$) + n$ + ".bmp" FOR BINARY AS #1
prstring$ = CHR$(0) + CHR$(0) + CHR$(1) + CHR$(0) + CHR$(24)
prstring$ = prstring$ + STRING$(6, CHR$(0))
prstring$ = prstring$ + CHR$(249) + CHR$(21) + CHR$(0)
prstring$ = prstring$ + CHR$(196) + CHR$(14) + CHR$(0) + CHR$(0) + CHR$(196)
prstring$ = prstring$ + CHR$(14) + STRING$(10, CHR$(0))
n$ = "BM": PUT #1, , n$
n& = xRes: n& = n& * yRes * 3: n& = n& + 54: PUT #1, , n&
n% = 0: PUT #1, , n%
n% = 0: PUT #1, , n%
n% = 54: PUT #1, , n%
n% = 0: PUT #1, , n%
n% = 40: PUT #1, , n%
n% = 0: PUT #1, , n%
n% = xRes: PUT #1, , n%
n% = 0: PUT #1, , n%
n% = yRes: PUT #1, , n%
PUT #1, , prstring$
n$ = SPACE$(xRes * 3)
FOR y% = yRes - 1 TO 0 STEP -1
x2% = 0
FOR x% = 0 TO xRes - 1: x2% = x2% + 3
pixel16& = uglPGet(video, x%, y%)
blue% = pixel16& AND 31
green% = (pixel16& \ 32) AND 63
red% = (pixel16& \ 2048) AND 31
MID$(n$, x2% - 2, 1) = CHR$((blue% * 255) \ 31)
MID$(n$, x2% - 1, 1) = CHR$((green% * 255) \ 63)
MID$(n$, x2%, 1) = CHR$((red% * 255) \ 31)
NEXT x%: PUT #1, , n$: NEXT y%: CLOSE
END SUB
Aga, I think the routine you quote is based on 16 bits pixels only: I just read that fast, but Pixel16& seems to be a combination of the three components, coded into a 2 bytes parameter. Correct me if I'm wrong, this may help me to optimise the TC-Lib...

To SCM : when I realised I would never make hi-res graphics with good'ol Screen 12, I developed a lot of progs based on 24 bits bitmaps. The technique is slow, but really reliable, since it is fully independant from the graphic card of the machine. Most of the graphics on The Mandelbrot Dazibao were made that way, and that allowed also making videos by merging still images, generated through a batch.

Then I discovered the SVGA modes, and developed the TC-Lib, 100% true-colours dedicated. The lib is slow from a technical point of view but, as you said above, when its takes hours to perform a heavy fractal computation, it is more important to get reliable results than to have a faast display.

I have the same problem as you when quitting the SVGA modes activated from QB. The last lib I made was finally a "virtual screen" graphic library, which allows using a 24 bits bitmap file with Pset and a Point routines. This way, you can run your prog in the background of Windows, and check the result from time to time with an external viewer. I personally use Thumbnails Plus from Cerious Software, this is the best images manager I know (it can, amongst other features, view an non complete bmp file!).

Note: with the virtual screen technique, you can prog when at work :lol: :wink:

See the three routine below, they allow working with an anysize bitmap file as a virtual true-colour screen. They are fully compatible with the TC-Lib programs, so you can switch from TCLib.bas to TCBmp.bas without changing a line in the main prog...

Code:
SUB SetVGA

SELECT CASE SizeScreen
CASE 1: ScrWidth = 400: ScrHeight = 300
CASE 2: ScrWidth = 640: ScrHeight = 480
CASE 3: ScrWidth = 800: ScrHeight = 600
CASE 4: ScrWidth = 1024: ScrHeight = 768
CASE 5: ScrWidth = 2048: ScrHeight = 1524
CASE ELSE
CLS
PRINT "Define a mode number (1-4) before calling SetVGA"
DO WHILE INKEY$ = "": LOOP
SYSTEM
END SELECT


' Bitmap structure parameters
CLS
IF Name$ = "" THEN Name$ = "TCLib"
PRINT "Creating blank bitmap "; Name$
Bw& = ScrWidth
Bh& = ScrHeight
Os& = 54
IF (3 * Bw& MOD (4)) <> 0 THEN PadBytes% = 4 - ((3 * Bw&) MOD (4))
Fs& = (3 * Bw& + PadBytes%) * Bh& + Os&
Ps& = (3 * Bw& + PadBytes%) * Bh&


Pic$ = SaveDir$ + Name$ + ".bmp"
OPEN Pic$ FOR BINARY AS #2

' Bitmap header
Buffer$ = "BM"
Buffer$ = Buffer$ + MKL$(Fs&)                      'File Size
Buffer$ = Buffer$ + CHR$(0) + CHR$(0)              'Reserved 1
Buffer$ = Buffer$ + CHR$(0) + CHR$(0)              'Reserved 2
Buffer$ = Buffer$ + MKL$(Os&)                      'Offset
Buffer$ = Buffer$ + MKL$(40)                       'File Info size
Buffer$ = Buffer$ + MKL$(Bw&)                      'Pic Width
Buffer$ = Buffer$ + MKL$(Bh&)                      'Pic Height
Buffer$ = Buffer$ + CHR$(1) + CHR$(0)              'Number of planes
Buffer$ = Buffer$ + CHR$(24) + CHR$(0)             'Number of bits per pixel
Buffer$ = Buffer$ + MKL$(0)                        'No compression
Buffer$ = Buffer$ + MKL$(Ps&)                      'Image Size
Buffer$ = Buffer$ + MKL$(0)                        'X Size (pixel/meter)
Buffer$ = Buffer$ + MKL$(0)                        'Y Size (pixel/meter)
Buffer$ = Buffer$ + MKL$(0)                        'Colors used
Buffer$ = Buffer$ + MKL$(0)                        'Important colors
PUT #2, 1, Buffer$

' Blank Pixels (three bytes per pixel)

FOR Ny = 1 TO Bh&
Buffer$ = CHR$(0) + CHR$(0) + CHR$(0)
FOR Nx = 1 TO Bw&
PUT #2, , Buffer$
NEXT Nx
Buffer$ = ""
FOR i = 1 TO PadBytes%
Buffer$ = Buffer$ + CHR$(0)
NEXT i
PUT #2, , Buffer$
NEXT Ny

CLS
PRINT "Bitmap "; Name$; " created"; Bw&; "x"; Bh&; ". Picture in progress"

END SUB

Code:
SUB Point24 (x%, y%)
' Returns the current RGB combination of the selected pixel
IF x% < 1 OR x% > ScrWidth OR y% < 1 OR y% > ScrHeight THEN EXIT SUB
Bw& = ScrWidth
Bh& = ScrHeight
IF (3 * Bw& MOD (4)) <> 0 THEN PadBytes% = 4 - ((3 * Bw&) MOD (4))
LineLength& = 3 * Bw& + PadBytes%
Os& = 54
Offset& = (Os& + 1) + (ScrHeight - y%) * LineLength& + (x% - 1) * 3
Col$ = "   "
GET #2, Offset&, Col$
Blue% = ASC(LEFT$(Col$, 1))
Green% = ASC(MID$(Col$, 2, 1))
Red% = ASC(RIGHT$(Col$, 1))

END SUB

SUB Pset24 (x%, y%)
' Plots a pixel using the current RGB combination
IF x% < 1 OR x% > ScrWidth OR y% < 1 OR y% > ScrHeight THEN EXIT SUB
Col$ = CHR$(Blue%) + CHR$(Green%) + CHR$(Red%)
Bw& = ScrWidth
Bh& = ScrHeight
IF (3 * Bw& MOD (4)) <> 0 THEN PadBytes% = 4 - ((3 * Bw&) MOD (4))
LineLength& = 3 * Bw& + PadBytes%
Os& = 54
Offset& = (Os& + 1) + (ScrHeight - y%) * LineLength& + (x% - 1) * 3
PUT #2, Offset&, Col$
END SUB