BBS: Inland Empire Archive Date: 10-14-92 (22:42) Number: 395 From: MARK BUTLER Refer#: NONE To: ALL Recvd: NO Subj: Screen save/rest 1/2 Conf: (2) Quik_Bas
Hi all, I had been fooling around with text mode screen save/restore
routines and discovered something kinda neat. In the book "Microsoft
QuickBASIC Programmer's Toolbox" there are two routines in 'C' to do
this; 'MoveBytes' and 'MoveWords'. I looked the C code over and noticed
that both make use of QuickC's "_movedata" funtion so I wondered "why
bother to make a linkable C routine? Why not just link in the asm-based
MOVEDATA.OBJ from MLIBCE.LIB directly?" (which was really all J. C.
Craig's code seemed to be doing in the first place). Well, I fooled with
it and found that it would work just fine. In the below 2 snippets the
first is a simple text screen save/restore demo in Basic. The second is
a debug script for movedata.obj. To run this demo create a QLB from
movedata.obj or compile the program linking in movedata.obj.
==========================8< Cut Here 8<=============================
'*** SCREEN SAVE/RESTORE DEMO by Mark H Butler
DEFINT A-Z
DECLARE SUB DrawBox (Uprow, Ltcol, Lorow, Rtcol)
DECLARE SUB MoveData CDECL (BYVAL fromseg, BYVAL fromoff, BYVAL_
destseg, BYVAL destoff, BYVAL nbytes)
DECLARE SUB RestScrn (Scr())
DECLARE SUB SaveScrn (Scr())
'*** create an array to hold all the text mode screen elements
DIM SHARED Scr(4000)
'*** print some junk to the screen
COLOR 7, 1
CLS
FOR i = 1 TO 13
FOR ch = 33 TO 176
PRINT CHR$(ch);
NEXT ch
NEXT i
'*** save the current screen
SaveScrn Scr()
'*** draw a white window box with black text
COLOR 0, 7
DrawBox 10, 10, 14, 70
LOCATE 12, 15
PRINT "Press any key to remove window non-destructively"
COLOR 7, 0
'*** wait until a key is pressed
DO UNTIL LEN(INKEY$): LOOP
'*** restore the original screen
RestScrn Scr()
SUB DrawBox (Uprow, Ltcol, Lorow, Rtcol) STATIC
Wide = (Rtcol - Ltcol) - 1
LOCATE Uprow, Ltcol
PRINT CHR$(201); STRING$(Wide, CHR$(205)); CHR$(187);
FOR i = Uprow + 1 TO Lorow - 1
LOCATE i, Ltcol
PRINT CHR$(186); SPACE$(Wide); CHR$(186);
NEXT i
LOCATE Lorow, Ltcol
PRINT CHR$(200); STRING$(Wide, CHR$(205)); CHR$(188);
END SUB
SUB RestScrn (Scr())
DEF SEG = &H40
equip = PEEK(&H10)
IF (equip AND 48) = 48 THEN
destseg = &HB000
ELSE
destseg = &HB800
END IF
destoff = 0
fromseg = VARSEG(Scr(0))
fromoff = VARPTR(Scr(0))
nbytes = 4000
MoveData fromseg, fromoff, destseg, destoff, nbytes
END SUB
SUB SaveScrn (Scr())
DEF SEG = &H40
equip = PEEK(&H10)
IF (equip AND 48) = 48 THEN
fromseg = &HB000
ELSE
fromseg = &HB800
END IF
fromoff = 0
destseg = VARSEG(Scr(0))
destoff = VARPTR(Scr(0))
nbytes = 4000
MoveData fromseg, fromoff, destseg, destoff, nbytes
END SUB
==========================8< Cut Here 8<=============================
The next message contains a debug script for MOVEDATA.OBJ
>>> continued in the next message
--- PPoint 1.35
* Origin: Terminal Oasis, Portland OR (1:105/330.5)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET