SetVideoSeg in Screen 13
Awesome!

To be able to use double buffering in SCREEN 13, all you have to do is change QB's default drawing segment to your layer:

'SetVideoSeg by Plasma357
' Changes QB's active video segment for SCREEN 13
'
' (Works both compiled and in the IDE)
'
' Note: Text is still output to segment A000, but all graphics functions will
' use the new segment specified.

DEFINT A-Z

DECLARE SUB setVideoSeg (Segment)

' Here's a useless example that just shifts the segment 16 bytes. Not very
' useful, but you get the picture. ;) You can easily change the segment to
' the EMS pageframe or a buffer in conventional memory.

SCREEN 13
setVideoSeg &HA000
PSET (0, 0), 15

setVideoSeg &HA001
PSET (0, 0), 15

k$ = INPUT$(1)
END

SUB SetVideoSeg (Segment) STATIC

'===============================================================
' SetVideoSeg by Plasma
'---------------------------------------------------------------
' Changes QB's active video segment for SCREEN 13
'---------------------------------------------------------------
' * Works for all graphics functions (does not work with PRINT)
' * Compatible with: QBasic 1.x
' QuickBasic 4.x (IDE & compiled)
' QB PDS 7.1 (IDE & compiled)
' VBDOS 1.0 (IDE & compiled)
'===============================================================


DEF SEG

' If SetVideoSeg was previously called, we can just
' set the new segment and bail.

IF videoSegOff <> 0 THEN
POKE videoSegOff, Segment AND &HFF
POKE videoSegOff + 1, (Segment AND &HFF00&) \ &H100
EXIT SUB
END IF


' Otherwise we have to search for b$AddrC, which holds the
' graphics offset (b$OffC) and segment (b$SegC). Since b$AddrC
' is in the default segment, we can find it by setting it to a
' certain value, and then searching for that value.

SCREEN 13 ' Set b$SegC to A000 (00A0 in memory)
PSET (160, 100), 0 ' Set b$OffC to 7DA0 (not needed in the IDE)

' Search for b$AddrC, which is in the default segment and
' should have a value of A0 7D 00 A0.
FOR i = 0 TO &H7FFC
IF PEEK(i) = &HA0 AND PEEK(i + 1) = &H7D THEN
IF PEEK(i + 2) = &H0 AND PEEK(i + 3) = &HA0 THEN
' Found it, so set b$SegC to the specified segment and exit
videoSegOff = i + 2
POKE videoSegOff, Segment AND &HFF
POKE videoSegOff + 1, (Segment AND &HFF00&) \ &H100
EXIT SUB
END IF
END IF
NEXT

SCREEN 0
WIDTH 80, 25
PRINT "SetVideoSeg Error: Cannot find video segment offset."
PRINT "Check to make sure you are using a compatible version of QB."
END

END SUB


If your layer is a base layer, you have to get the segment of the layer (depends on the lib, I know there's a function in DQB at least). If your layer is an EMS layer, you have to get the EMS pageframe segment (the lib might have a function to do this, otherwise you can do it with an interrupt).

Then you just use:
SetVideoSeg layersegment%

To set the drawing segment back to the screen (video memory), use &HA000 for the segment.

Also, as stated in the code, this only works for graphics routines...text still goes to the screen.


SetVideoSegInScreenThirteen - page last edited 2004-02-10 12:33:08 by 172.167.146.22 (home) (edit)
Blast WIKI - by RoboticBoy - edited and tweaked for our evil purposes by Hexadecimal Disaster