home *** CD-ROM | disk | FTP | other *** search
Wrap
DECLARE SUB logo () : DECLARE SUB TextMode () : DECLARE SUB GraphicsMode () : DECLARE SUB DefaultMode () : DECLARE SUB GraphicsDemo () : DECLARE SUB MemoryDump () : DECLARE SUB attributes () : DECLARE SUB Diversion () : DECLARE SUB Fill () : DECLARE _ SUB k () : DECLARE SUB machine () : DECLARE SUB PrintxDemo () : DECLARE SUB train () : DECLARE SUB VgaSetDefaultReg () : DECLARE SUB VgaViewReg () : DECLARE SUB Window1 () : DECLARE SUB Window2 () : DECLARE SUB Window3 () : DECLARE SUB _ PrintMainMenu () : DECLARE SUB Copyright () : DECLARE SUB Pause (n!) : DECLARE SUB configure () : DECLARE SUB MemoryScroll () : DECLARE SUB DBox (Msg$, f$) : DECLARE SUB dec (n) : DECLARE SUB inc (n) : DECLARE SUB VGARead16ColReg (ColorReg$) : _ DECLARE SUB VGAReadFile (File$, RGB$) : DECLARE SUB VGAReadPalReg (palette$) : DECLARE SUB VGASet16ColReg (RGB$) : DECLARE SUB VGASet1ColReg (reg!, red!, green!, blue!) '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ' Here is a list of all the VGA calls (these are subs in W32.BAS) ' The calls to read or set 16 registers use strings, ' those to read or set one register use numbers. 'VGARead16ColReg (RGB$) ' returns a 49 byte string with contents of 16 color registers ' and the overscan register. 'VGARead1ColReg (Register,Red,Green,Blue) ' reads a single color register 'VGAReadFile (filename$,RGB$) ' reads a file created by VPT.EXE into a 49 byte string 'VGAReadPalReg (Palette$) ' Reads the 16 palette registers and overscan attribute into ' a 17 byte string 'VGASet16ColReg ' Sets 16 color registers from a 48 or 49 byte string. Can use the ' string returned by VGARead16ColReg or VGAReadFile. 'VGASet1ColReg (Register,Red,Green,Blue) [Red Green & Blue = 0 to 63] ' sets a single color register. 'VGASetDefaultReg ' Sets the 16 palette and color registers to their defaults, except ' for color 7 which is set to green instead of white. 'VGASetOverScanReg (n) [n = 0 to 15] ' sets the attribute for the overscan register. ' Th]re is no separate call to read the attribute of the overscan ' register, but it is the last byte of the string returned ' by ReadPalReg, ReadFile, or Read16ColReg. '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ' These statements are in a file called W32.DEC and should be merged ' or included ( use REM $INCLUDE:'W32.DEC') with any program using the ' W32 library. Programs load slower with INCLUDE statements but are easier ' to update. DECLARE SUB Adapter (a%) : 'returns active adapter 0\mono 1\cga 2\ega 3\vga DECLARE SUB Border (BYVAL b%) DECLARE SUB CloseLastW () DECLARE SUB CloseW (BYVAL segment%, BYVAL tr%, BYVAL lc%, BYVAL br%, BYVAL rc%) DECLARE SUB CloseWgra (BYVAL segment%, BYVAL tr%, BYVAL lc%, BYVAL br%, BYVAL rc%) DECLARE SUB ConvertTG (tr%, lc%, br%, rc%) DECLARE SUB DebugW () DECLARE SUB DefBorder (x$) DECLARE SUB Dump1 (BYVAL segment%, BYVAL offset%, BYVAL attr%, BYVAL NLines%, BYVAL Row%) DECLARE SUB FillW (BYVAL offset%, BYVAL stringAddress%) DECLARE SUB InitW (RR%, CC%) DECLARE SUB Int10 (ax%, bx%, cx%, dx%) DECLARE SUB Int3 DECLARE SUB KLS DECLARE SUB Kolor (BYVAL fore%, BYVAL back%) DECLARE SUB Lokate (BYVAL r%, BYVAL c%) DECLARE SUB MapMask (BYVAL m%) DECLARE SUB Monochrome () DECLARE SUB OpenW (BYVAL segment%, BYVAL tr%, BYVAL lc%, BYVAL br%, BYVAL rc%) DECLARE SUB Prnt (a$) DECLARE SUB Printt (a$, BYVAL attr%, BYVAL r%, BYVAL c%) DECLARE SUB PrntW (a$) DECLARE SUB PrintW (a$, BYVAL attr%, BYVAL r%, BYVAL c%) DECLARE SUB PrntS (BYVAL i!) DECLARE SUB PrntUsingS (Mask$, BYVAL i!) DECLARE SUB ReadScreen (a$, BYVAL r%, BYVAL c%) DECLARE SUB Refresh () DECLARE SUB SaveW (BYVAL segment%, BYVAL tr%, BYVAL lc%, BYVAL br%, BYVAL rc%) DECLARE SUB SaveWgra (BYVAL segment%, BYVAL tr%, BYVAL lc%, BYVAL br%, BYVAL rc%) DECLARE SUB ScrollD (BYVAL Lines%, BYVAL tr%, BYVAL lc%, BYVAL br%, BYVAL rc%) DECLARE SUB ScrollL (BYVAL cols%, BYVAL tr%, BYVAL lc%, BYVAL br%, BYVAL rc%) DECLARE SUB ScrollR (BYVAL cols%, BYVAL tr%, BYVAL lc%, BYVAL br%, BYVAL rc%) DECLARE SUB scrollU (BYVAL Lines%, BYVAL tr%, BYVAL lc%, BYVAL br%, BYVAL rc%) DECLARE SUB SetViewPage (BYVAL p%) DECLARE SUB SetViewW (BYVAL Page%, BYVAL tr%, BYVAL lc%, BYVAL br%, BYVAL rc%) DECLARE SUB SnowCheckingOn DECLARE SUB SnowCheckingOff DECLARE SUB Tabb (BYVAL Col%) DECLARE SUB WSize (Bytes&, BYVAL tr%, BYVAL lc%, BYVAL br%, BYVAL rc%) DECLARE SUB WSizeGra (Bytes&, BYVAL tr%, BYVAL lc%, BYVAL br%, BYVAL rc%) '$DYNAMIC COMMON SHARED RR AS INTEGER, CC AS INTEGER 'InitW RR, CC '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OPTION BASE 1 COMMON SHARED EE: 'result of On Error Goto COMMON SHARED Mode, Lines, Columns: 'Screen mode and lines and 'columns of text being displayed COMMON SHARED i$: 'Result of a keypress from the sub K COMMON SHARED Monitor AS INTEGER, MDump AS INTEGER 'Monitor is set by DefaultMode & Configure. MDump = 1: 'determines whether the sub MemoryDump 'will print to the MDA or the CGA-VGA. Can be changed by 'the sub Configure CALL DefaultMode: ' sets display to SCREEN 0, 25 lines & 80 columns clock2 = 1: 'flag to toggle displaytime on & off Speed = 1: 'used by Pause CALL Copyright 'initialize some strings for PrintxDemo REDIM e$(30): OPEN "i", #3, "W32.dec" FOR x = 1 TO 30: LINE INPUT #3, e$(x): NEXT: CLOSE '=========================================================================== start: CALL PrintMainMenu: CALL k: i$ = LCASE$(i$) SELECT CASE i$ CASE "w": CALL Window1: CALL Window2: CALL Window3 CASE "s": CALL train: CALL machine: CALL GraphicsDemo CASE "f": CALL Fill CASE "d": CALL DebugW CASE "p": CALL PrintxDemo CASE "c": CALL configure CASE "q": PLAY OFF: CALL DefaultMode: CALL Copyright: END CASE "g": CALL GraphicsMode CASE "t": CALL TextMode CASE "x": IF Mode = 0 THEN CALL MemoryDump ELSE BEEP CASE "h": SWAP Clock1, clock2: IF Clock1 = 1 THEN ON TIMER(1) GOSUB DisplayTime: TIMER ON ELSE TIMER OFF END IF CASE "r": CALL Diversion CASE "m": CALL MemoryScroll CASE ELSE END SELECT: GOTO start '========================================================================== ResumeNext: EE = ERR: RESUME NEXT DisplayTime: cccR = CSRLIN: cccC = POS(x) LOCATE 2, 60: PRINT "FRE(1) ="; FRE(1); LOCATE 1, 60: PRINT TIME$; LOCATE cccR, cccC: 'restore cursor position RETURN MemDump: 'This is a sort of multi-tasking and yes, I got the idea from PC Magazine. PLAY "MB N0" CALL Refresh RETURN REM $STATIC SUB configure STATIC SHARED Speed: 'shared with 'Pause' IF Columns <> 80 THEN CALL DefaultMode BeginC: IF Mode = 0 THEN COLOR 2, 0 IF Mode = 12 THEN COLOR 2 CLS : Border 1: OpenW 0, 1, 1, 15, 80 SC: LOCATE 2, 2: PRINT " M Print to the monochrome monitor" LOCATE 3, 2: PRINT " C Print to the CGA,EGA or VGA monitor" LOCATE 5, 2: PRINT " S Enable snow checking" LOCATE 6, 2: PRINT " D Disable snow checking" LOCATE 8, 2: PRINT " 1-8 Speed (determines the length of pauses in this demo)" LOCATE 9, 2: PRINT " 1 - fastest 8 - slowest" LOCATE 11, 2: PRINT " X Memory Dump prints to the CGA/EGA/VGA" LOCATE 12, 2: PRINT " Y Memory Dump prints to the monochrome monitor" LOCATE &O16, 2: PRINT " ESC Exit" IF Monitor THEN LOCATE 3, 9: PRINT "**" ELSE LOCATE 2, 9: PRINT "**"; IF snow THEN LOCATE 5, 9: PRINT "**" ELSE LOCATE 6, 9: PRINT "**"; LOCATE 8, 8: PRINT Speed; IF MDump THEN LOCATE 11, 9: PRINT "**" ELSE LOCATE 12, 9: PRINT "**"; LOCATE 20, 10: PRINT "M and C do not change the active monitor. If " LOCATE 21, 10: PRINT "your computer has two monitors, this program" LOCATE 22, 10: PRINT "can print to both a MDA and CGA/EGA/VGA " LOCATE 23, 10: PRINT "regardless of which is active. However, the" LOCATE 24, 10: PRINT "cursor will move only on the active monitor"; CALL k: i$ = LCASE$(i$): SELECT CASE i$ CASE "m": Monitor = 0: CALL Monochrome: Lines = 25: Columns = 80: Mode = 0 CASE "c": Monitor = 1: CALL DefaultMode: GOTO BeginC CASE "s": snow = -1: CALL SnowCheckingOn CASE "d": snow = 0: CALL SnowCheckingOff CASE "1", "2", "3", "4", "5", "6", "7", "8": Speed = VAL(i$) CASE "x": MDump = 1 CASE "y": MDump = 0 CASE ELSE: EXIT SUB END SELECT: GOTO SC END SUB SUB Copyright Kolor 3, 0 CALL Monochrome: GOSUB CR2: 'Print on the MDA monitor InitW RR, CC: GOSUB CR2: 'and on the VGA monitor Pause 700: EXIT SUB '------------------------------- CR2: Border 3: KLS 'draw 4 boxes for a border Kolor 5, 0: OpenW 0, 2, 2, 3, 79: 'top Kolor 3, 0: OpenW 0, 1, 76, 25, 77: 'right Kolor 6, 0: OpenW 0, 23, 1, 24, 79: 'bottom 'Attribute 4 won't show up on a monochrome monitor CALL Adapter(a%): IF a% < 2 THEN Kolor 3, 0 ELSE Kolor 4, 0 OpenW 0, 1, 3, 25, 4: 'left 'Put a border around the text window Border 1: Kolor 3, 0: OpenW 0, 7, 18, 18, 62 Printt "QuickBasic Windows Library", 3, 9, 20 Printt "Version 3.2 Sept 15, 1990", 3, 10, 20 Printt "By Jim Paisley", 3, 12, 24 Printt "10690 Allen Rd", 3, 13, 24 Printt "Washington C.H., Oh 43160", 3, 14, 24 Printt "Copyright 1990", 3, 16, 24 RETURN END SUB SUB DBox (Msg$, f$) '$DYNAMIC 'QuickBasic's famous box-in-a-box. Called by FILL tr = 5: lc = 15: 'Box location c1 = 10: c2 = 4: 'color '-------------------------------------------- attr = c1 + c2 * 16 br = tr + 13: rc = lc + 50 WSize Bytes&, tr, lc, br, rc REDIM box(Bytes& / 2) AS INTEGER Border 1: Kolor c1, c2: OpenW VARSEG(box(1)), tr, lc, br, rc OpenW 0, tr + 4, lc + 6, tr + 6, lc + 44 Printt Msg$, attr, tr + 3, lc + 7 Border 2 OpenW 0, tr + 8, lc + 13, tr + 10, lc + 18 Printt "OK", attr, tr + 9, lc + 15 Border 1 OpenW 0, tr + 8, lc + 28, tr + 10, lc + 37 Printt "Cancel", attr, tr + 9, lc + 30 IF Mode = 0 THEN COLOR c1, c1 IF Mode = 12 THEN COLOR c1 LOCATE tr + 5, lc + 8, 1 INPUT "", f$: ' comma suppresses the '?' 'We only saved 1 window to an array, but have to close the other 3 to 'pop them off the CloseLastW stack FOR x = 1 TO 4: CALL CloseLastW: NEXT ERASE box END SUB REM $STATIC SUB dec (n) STATIC n = n - 1 END SUB SUB DefaultMode SHARED Clock1 PALETTE: 'default palette Mode = 0: Lines = 25: Columns = 80: Page = 0 SCREEN Mode, 1, Page, Page 'If you quit this program while in a 132 column mode and start it again, 'the WIDTH 80,25 will not change it back to 80 columns unless preceded 'by the WIDTH 40,25 command. You must not let the timer call DisplayTime 'while in the 40 column mode. TIMER OFF: WIDTH 40, 25 IF Clock1 = 1 THEN ON TIMER(1) GOSUB DisplayTime: TIMER ON WIDTH Columns, Lines CALL Adapter(Monitor): '''IF Monitor > 1 THEN CALL vgasetdefaultreg 'Monitor determines whether this program will print to the MDA 'or the CGA-VGA. It can be changed by the sub Configure. LOCATE , , 1, 5, 7: 'visible thick line cursor InitW RR, CC: ' initialize W32 END SUB SUB Diversion '$DYNAMIC CALL Adapter(a%): IF a% <> 3 THEN BEEP: EXIT SUB Kolor 2, 0 'view current colors KLS CALL VgaViewReg 'save current colors CALL VGARead16ColReg(SaveReg$) 'read new colors from a file Printt "Press a key to load colors from the file W32.VPT... ", 2, 22, 1: k CALL VGAReadFile("W32.VPT", RGB$) 'set the VGA to these new colors IF LEN(RGB$) <> 0 THEN CALL VGASet16ColReg(RGB$) 'if the file wasn't found, set 4 registers individually ELSE red = 0: green = 0: blue = 0: reg = 0 CALL VGASet1ColReg(reg, red, green, blue) red = 63: green = 10: blue = 10: reg = 1 CALL VGASet1ColReg(reg, red, green, blue) red = 63: green = 48: blue = 7: reg = 2 CALL VGASet1ColReg(reg, red, green, blue) red = 30: green = 49: blue = 63: reg = 3 CALL VGASet1ColReg(reg, red, green, blue) END IF 'view the new colors: CALL VgaViewReg: Kolor 2, 0 'restore the original colors Printt "Press any key to set the colors to their defaults...", 2, 22, 1: k CALL VgaSetDefaultReg CALL VgaViewReg Printt "Press any key ... ", 2, 22, 1: k END SUB SUB Fill STATIC f$ = "W32.doc": 'name of a text file to view CALL KLS StartFillDemo: '--------------------------------------------------------------------------- 'initialize the editing keys PgUp$ = CHR$(0) + CHR$(73): PgDn$ = CHR$(0) + CHR$(81) up$ = CHR$(0) + CHR$(72): down$ = CHR$(0) + CHR$(80) Lft$ = CHR$(0) + CHR$(75): rght$ = CHR$(0) + CHR$(77) Ins$ = CHR$(0) + CHR$(82): del$ = CHR$(0) + CHR$(83) backspace$ = CHR$(0) + CHR$(8): ShiftTab$ = CHR$(0) + CHR$(15) Home$ = CHR$(0) + CHR$(71): end$ = CHR$(0) + CHR$(79) cr$ = CHR$(13): ESC$ = CHR$(27): tab$ = CHR$(9): eol$ = CHR$(10) '--------------------INITIALIZE THE DATA------------------------------- REDIM a%(75 * 132): 'array used to save the screen NStrings = FRE(1) / 50: REDIM a$(NStrings): 'array holds the strings to be viewed IF fore = 0 THEN fore = 15: back = 5: 'initial colors e$ = "L32ege": 'play when scrolling hits the end SIZE = 2: 'initial size of the window n = 0: 'initial string offset (increase n to scroll left) L = 1: 'a$(L) is the string at the top of the window FBorder = 2: CALL Border(FBorder): 'initial border, a double line CALL DefBorder(CHR$(220) + CHR$(220) + CHR$(220) + CHR$(221) + CHR$(32) + CHR$(222) + CHR$(223) + CHR$(223) + CHR$(223)) CenterRow = INT(Lines / 2): CenterColumn = INT(Columns / 2) tr = CenterRow - 4: br = tr + 8: lc = CenterColumn - 16: rc = lc + 32 '-------------------------Open a text file --------------------------------- OpenFile: EE = 0: ON ERROR GOTO ResumeNext CLOSE : OPEN "i", #3, f$ ON ERROR GOTO 0 IF EE = 0 GOTO ReadFile CALL DBox("Name of a text file to view:", f$) IF f$ = "" GOTO ExitFillDemo ELSE GOTO OpenFile '-------------------------Read the file into A$() ----------------------- ReadFile: Printt "Loading " + f$, 2, 10, 30 Printt "Press <Esc> to stop", 2, 12, 30 LastLine = 1: 'number of strings used in a$() DO UNTIL EOF(3): LINE INPUT #3, a$(LastLine) Lokate 9, 40: PrntUsingS "####", LastLine IF FRE(x$) < 2000 OR LastLine > NStrings THEN Lokate 13, 40: Prnt "Not enough room...": PLAY e$: CALL k EXIT DO END IF inc LastLine i$ = INKEY$: IF i$ = ESC$ THEN EXIT DO LOOP: CLOSE #3 '------------Clear the screen and print a help menu -------------------------- DrawScreen: Kolor 2, 0: KLS Kolor 6, 0: OpenW 0, 1, 1, 24, 24: Lokate 1, 1: 'draw a box Kolor 12, 0: PrntW "Keys to scroll:" + cr$ Kolor 6, 0 PrntW " " + CHR$(25) + " " + CHR$(26) + " " + CHR$(27) + " " + CHR$(24) + cr$ PrntW " PageUp PageDown " + cr$ PrntW " Home End" + cr$ PrntW " tab shift/tab" + cr$ Kolor 6, 0: PrntW "______________________": PrntW cr$ Kolor 12, 0: PrntW "Change the display:" + cr$: Kolor 6, 0 PrntW "b Border" + cr$ PrntW "f New file" + cr$ PrntW "+ - Window size" + cr$ PrntW "1,2 Foreground color" + cr$ PrntW "9,0 Background color" + cr$ PrntW "t Select text mode" + cr$ PrntW "g Select graphics" + cr$ PrntW " mode" + cr$ PrntW "<esc> Quit" + cr$ Kolor 6, 0: PrntW "______________________": PrntW cr$ Kolor 12, 0: PrntW "Current colors:" + cr$: Kolor 6, 0 PrntW " Foreground " + cr$ PrntW " Background " '-------------------------Set up a window----------------------------------- OpenWindow: Kolor 12, 0 Lokate 22, 17: PrntUsingS "###", fore Lokate 23, 17: PrntUsingS "###", back Kolor fore, back IF tr < 1 THEN tr = 1 IF tr > CenterRow - 2 THEN tr = CenterRow - 2 IF br > Lines THEN br = Lines: IF br < tr + 8 THEN br = tr + 8 IF br < CenterRow + 2 THEN br = CenterRow + 2 IF lc < 1 THEN lc = 1 IF lc > CenterColumn - 12 THEN lc = CenterColumn - 12 IF rc > Columns THEN rc = Columns: IF rc < lc + 24 THEN rc = lc + 24 IF Mode = 0 THEN OpenW VARSEG(a%(1)), tr, lc, br, rc IF Mode > 0 THEN OpenW 0, tr, lc, br, rc '-------------------------Print the file in the window---------------------- PrintWindow: IF L > LastLine - CenterRow THEN L = LastLine - CenterRow: PLAY e$ IF L < 1 THEN L = 1: PLAY e$ IF n < 0 THEN n = 0: PLAY e$ IF n > 80 THEN n = 80: PLAY e$ FillW n, VARPTR(a$(L)) '-----------------------Wait for instructions------------------------------- CALL k SELECT CASE i$ CASE ESC$: GOTO ExitFillDemo CASE "f", "F": f$ = "": GOTO StartFillDemo CASE up$: dec L: GOTO PrintWindow CASE down$: inc L: GOTO PrintWindow CASE Lft$: inc n: GOTO PrintWindow CASE rght$: dec n: GOTO PrintWindow CASE tab$: n = n + 5: GOTO PrintWindow CASE ShiftTab$: n = n - 5: GOTO PrintWindow CASE PgUp$: L = L - (br - tr): GOTO PrintWindow CASE PgDn$: L = L + (br - tr): GOTO PrintWindow CASE Home$: n = 0: L = 1: GOTO PrintWindow CASE end$: L = 9999: GOTO PrintWindow CASE "-": tr = tr + 2: br = br - 2: lc = lc + 6: rc = rc - 6 CASE "+": tr = tr - 2: br = br + 2: lc = lc - 6: rc = rc + 6 CASE "t": CALL TextMode CASE "g": CALL GraphicsMode CASE "1": fore = fore + 1: IF fore > 15 THEN fore = 0 CASE "9": back = back + 1: IF back > 7 THEN back = 0 CASE "2": fore = fore - 1: IF fore < 0 THEN fore = 15 CASE "0": back = back - 1: IF back < 0 THEN back = 7 CASE "b": inc FBorder: FBorder = FBorder MOD 4: CALL Border(FBorder) CASE ELSE END SELECT IF Mode = 0 THEN CloseLastW: GOTO OpenWindow ELSE GOTO DrawScreen ExitFillDemo: ERASE a%: ERASE a$ END SUB REM $STATIC SUB GraphicsDemo IF Monitor = 0 THEN EXIT SUB '----------------------------- move balls ----------------------------- CALL Adapter(a%) SELECT CASE a% CASE IS > 1: 'EGA or VGA SCREEN 12, , 0, 0: COLOR 1 CLS : CIRCLE (559, 350), 30: FOR y = 1 TO 66: CALL ScrollL(5, 320, 0, 380, 639): NEXT CIRCLE (559, 350), 30: FOR y = 1 TO 56: CALL ScrollL(4, 320, 80, 380, 639): NEXT CIRCLE (559, 350), 30: FOR y = 1 TO 46: CALL ScrollL(3, 320, 160, 380, 639): NEXT CIRCLE (559, 350), 30: FOR y = 1 TO 36: CALL ScrollL(2, 320, 240, 380, 639): NEXT '--------------------- move a triangle wave ---------------------------- COLOR 4: i$ = "" IF a% > 1 THEN LOCATE 3, 21: PRINT "It is possible to scroll" LOCATE 4, 21: PRINT "selected colors only by" LOCATE 5, 21: PRINT "calling MapMask" COLOR 11 END IF tr = 24: lc = 0: br = 87: rc = 639 y = 86: z = -1: LINE (0, 23)-(639, 23): LINE (0, 88)-(639, 88) DO UNTIL i$ <> "" 'draw part of the graph FOR x = 632 TO 639 PSET (x, y): y = y + z IF y < 32 THEN z = 1 ELSE IF y > 86 THEN z = -1 NEXT x 'scroll left MapMask 11: CALL ScrollL(8, tr, lc, br, rc) i$ = INKEY$ LOOP '------------------- Scroll with the cursor keys ------------------------- LOCATE 10, 1: COLOR 2: PRINT "Scroll L-R and U-D with the cursor keys" LOCATE 16, 1: PRINT "-------------------------------------------------------------------------------" up$ = CHR$(0) + CHR$(72): down$ = CHR$(0) + CHR$(80) Lft$ = CHR$(0) + CHR$(75): rght$ = CHR$(0) + CHR$(77) DO i$ = INKEY$ SELECT CASE i$ CASE Lft$: MapMask 11: ScrollL 1, tr, lc, br, rc CASE rght$: MapMask 11: ScrollR 1, tr, lc, br, rc CASE up$: MapMask 4: scrollU 1, 0, 160, 255, 360: 'up 1 line CASE down$: MapMask 4: ScrollD 4, 0, 160, 255, 360: 'down 4 lines CASE "" CASE ELSE: EXIT DO END SELECT LOOP '---------------------- Restore the defaults --------------------------- MapMask 15: CALL DefaultMode CASE 1: 'CGA SCREEN 0, 1, 0, 0 SCREEN 2: CLS CIRCLE (559, 50), 30 FOR y = 1 TO 66: ScrollL 8, 20, 0, 80, 639: NEXT CIRCLE (559, 50), 30 FOR y = 1 TO 56: ScrollL 8, 20, 80, 80, 639: NEXT CIRCLE (559, 50), 30 FOR y = 1 TO 46: ScrollL 8, 20, 160, 80, 639: NEXT CIRCLE (559, 50), 30 FOR y = 1 TO 36: ScrollL 8, 20, 240, 80, 639: NEXT CALL DefaultMode CASE ELSE END SELECT END SUB SUB GraphicsMode 'Rows, Columns and Mode are COMMON SHARED SHARED Trap1, Trap2 h = 1: 't$ that is highlighted StartGraMode: '$DYNAMIC REDIM t$(1 TO 2) t$(1) = "SCREEN 2" t$(2) = "SCREEN 12" up$ = CHR$(0) + CHR$(72): down$ = CHR$(0) + CHR$(80) c1 = 3: c2 = 4: IF Mode = 2 THEN c1 = 4: c2 = 0 Kolor c1, c2: 'window colors tr = 8: lc = 45: '------------------------------------------------------------------------ 'Print a help menu Border 3: Kolor c1, c2: OpenW 0, 3, 4, 11, 30: Lokate 1, 1 PrntW CHR$(24) + " " + CHR$(25) + " Select mode" + CHR$(13) PrntW "<Enter> Change mode" + CHR$(13) PrntW "<Esc> Exit" + CHR$(13) PrntW "C Count " + CHR$(13) PrntW CHR$(13) PrntW "Current Mode: " IF Mode = 0 THEN PrntW "Text" + CHR$(13): PrntW " " + STR$(Lines) + " x" + STR$(Columns) END IF IF Mode = 2 THEN PrntW "Graphics" + CHR$(13) PrntW " SCREEN 2 25 x 80" END IF IF Mode = 12 THEN PrntW "Graphics" + CHR$(13): PrntW " SCREEN 12 30 x 80" END IF '------------------------------------------------------------------------ 'Print the possible modes in a window Border 1: Kolor c1, c2 OpenW 0, tr, lc, tr + 3, lc + 12: 'draw a box, don't save FOR x = 1 TO 2: PrntW t$(x) + CHR$(10): NEXT '------------------------------------------------------------------------- gTL: Lokate tr + h, lc + 11: Prnt CHR$(27): 'highlight selection CALL k SELECT CASE i$ CASE up$ Lokate tr + h, lc + 11: Prnt " " h = h - 1: IF h = 0 THEN h = 2 Lokate tr + h, lc + 11: Prnt " " GOTO gTL CASE down$ Lokate tr + h, lc + 11: Prnt " " h = h + 1: IF h = 3 THEN h = 1 Lokate tr + h, lc + 11: Prnt " " GOTO gTL CASE CHR$(13) IF h = 2 THEN EE = 0: ON ERROR GOTO ResumeNext: SCREEN 12: ON ERROR GOTO 0 IF EE = 0 THEN Columns = 80: Lines = 30: Mode = 12: WIDTH Columns, Lines 'don't use MemoryDump in graphics modes: IF Trap1 = 1 THEN PLAY OFF: SWAP Trap1, Trap2 InitW RR, CC ELSE BEEP END IF END IF IF h = 1 THEN Mode = 2: Columns = 80: Lines = 25 SCREEN Mode: WIDTH Columns, Lines InitW RR, CC IF Trap1 = 1 THEN PLAY OFF: SWAP Trap1, Trap2 END IF GOTO StartGraMode CASE CHR$(27) EXIT SUB CASE ELSE GOTO gTL END SELECT END SUB REM $STATIC SUB inc (n) STATIC n = n + 1 END SUB SUB k k: i$ = "": DO UNTIL i$ <> "": i$ = INKEY$: LOOP: END SUB SUB logo IF Mode <> 12 THEN EXIT SUB 'Circle (Column, Row) , radius , color, start, end 'start is + - 2 pi radians 0-pi top 'C 0 to 639 'R 0 to 479 r = 18 * 16: c = 408 c2 = c + 88 radius = 16 start = 3.14 / 2 eend = 3.14 * 1.5 COLOR 4 CIRCLE (c - 248, r), radius, 4, start, eend LINE (c - 248, r - radius)-(c2 - 248, r - radius) LINE (c - 248, r + radius)-(c2 - 248, r + radius) CIRCLE (c2 - 248, r), radius, 4, eend, start COLOR 1 'FOR x = 1 TO 200: PRINT "1234567890"; : NEXT LOCATE (r + radius - 1) / 16 - 8, c / 8 + 1: PRINT "VGA Version" FOR n = 1 TO 31 MapMask 4 ScrollR 8, r - radius, c - 248 - radius, r + radius, c2 + radius MapMask 1 ScrollD 4, (r + radius - 1) - 192, c - radius, r + radius, c2 + radius Pause 2 NEXT MapMask 15 END SUB REM $DYNAMIC '=========================================================================== SUB machine STATIC CALL KLS SELECT CASE Mode CASE 0 c1 = 0: c2 = 6: attr = c1 + c2 * 16: 'color to use here CLS : Kolor c1, c2: KLS 'this sub is too slow with snow checking on. Variables are 'a little faster than passing constants L = 1: tr = 3: lc = 44: br = 23: rc = 53 cr$ = CHR$(13): Lokate 5, 1 Prnt " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + cr$ Prnt " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + cr$ Prnt " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + cr$ Prnt " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx " REDIM c%(800) CALL SaveW(VARSEG(c%(1)), 3, 5, 9, 40) Lokate 3, 1 Prnt " xxxxxxxxxxxx" + cr$ Prnt " xxxxxxxxxxxxxxxxxxxxxx " + cr$ Prnt " xxxxxxxxxxxxxxxxxxxxxxxxx " + cr$ Prnt " xxxxxxxxxxxxxxxxxxxxxxxx " + cr$ Prnt " xxxxxxxxxxxxxxxxxxxxxxx " + cr$ Prnt " xxxxxxxxxxxxxxxxxxxx " + cr$ Prnt "xxxxxxxxxxxxx " + cr$ REDIM ccc%(800) CALL SaveW(VARSEG(ccc%(1)), 3, 5, 9, 40) KLS 'Draw a black box (attribute is 0) Kolor 0, 0: IF Monitor = 0 THEN Kolor 3, 0 CALL OpenW(0, 10, 51, 23, 53): Kolor c1, c2 Printt "A B C D E F G H I J K L M N O", attr, 24, 51: ' A at 51, O is at 79 y = 97: DO UNTIL y = 123 i$ = INKEY$: IF i$ <> "" THEN EXIT DO '----go left and up Pause 10 FOR x = 1 TO 7: ScrollL L, tr, lc, br, rc: NEXT CALL CloseW(VARSEG(ccc%(1)), 3, 5, 9, 40): 'print arm in up position FOR x = 1 TO 10: scrollU L, tr, lc, br, rc: NEXT '---go right and down Pause 10 FOR x = 1 TO 7: ScrollR L, tr, lc, br, rc: NEXT CALL CloseW(VARSEG(c%(1)), 3, 5, 8, 40): 'print arm in down position FOR x = 1 TO 10: ScrollD L, tr, lc, br, rc: NEXT 'scroll the letters ScrollL 2, 24, 1, 25, 79 Printt CHR$(y), attr, 24, 49: ' small letter IF y < 108 THEN Printt CHR$(y - 17), attr, 24, 79: 'capital letter inc y: LOOP COLOR 2, 0 CASE 2 Kolor 4, 0: CALL OpenW(0, 14, 50, 23, 53): Kolor 6, 0 Printt "A B C D E F G H I J K L M N O", 6, 24, 51: ' A at 51, O is at 79 tr = 5 * 8: lc = 43 * 8: br = (23 * 8) - 1: rc = 52 * 8 y = ASC("a"): DO UNTIL y = ASC("z") i$ = INKEY$: IF i$ <> "" THEN EXIT DO '----move the hammermill left and up 'FOR x = 1 TO 6: ScrollL 8, TR, LC, BR, RC: NEXT FOR x = 1 TO 8: scrollU 8, tr, lc, br, rc: NEXT '---move the hammer right and down 'FOR x = 1 TO 6: ScrollR 8, TR, LC, BR, RC: NEXT FOR x = 1 TO 8: ScrollD 8, tr, lc, br, rc: NEXT 'scroll the letters ScrollL 16, 23 * 8, 0, (24 * 8) - 1, 639 Printt CHR$(y), 6, 24, 49: ' small letter IF y < 108 THEN Printt CHR$(y - 17), 6, 24, 79: 'capital letter inc y: LOOP CASE 12 Kolor 4, 0: CALL OpenW(0, 14, 51, 23, 52): Kolor 6, 0 Printt "A B C D E F G H I J K L M N O", 6, 24, 51: ' A at 51, O is at 79 tr = 5 * 16: lc = 43 * 8: br = (23 * 16) - 1: rc = 52 * 8 y = ASC("a"): DO UNTIL y = ASC("z") i$ = INKEY$: IF i$ <> "" THEN EXIT DO '----move the hammermill up and down 'FOR x = 1 TO 6: ScrollL 8, TR, LC, BR, RC: NEXT FOR x = 1 TO 8: scrollU 16, tr, lc, br, rc: NEXT 'FOR x = 1 TO 6: ScrollR 8, TR, LC, BR, RC: NEXT FOR x = 1 TO 8: ScrollD 16, tr, lc, br, rc: NEXT 'scroll the letters ScrollL 16, 23 * 16, 0, (24 * 16) - 1, 639 Printt CHR$(y), 6, 24, 49: ' small letter IF y < 108 THEN Printt CHR$(y - 17), 6, 24, 79: 'capital letter inc y: LOOP END SELECT Pause 250 ERASE c%: ERASE ccc% END SUB REM $STATIC SUB MemoryDump STATIC 'Share flags so MemoryScroll can turn this off, monitor to restore it SHARED Trap1, Trap2 'MDump determines which monitor this sub prints to (0/MDA 1/CGA) 'Monitor determines which monitor the rest of the program is using (0/MDA...) 'initialize flags the first time thru IF Trap1 + Trap2 = 0 THEN Trap2 = 1: cr$ = CHR$(13) 'Toggle the flag SWAP Trap1, Trap2 IF Trap1 = 0 THEN PLAY OFF: EXIT SUB CALL KLS: Prnt "This uses the routine 'Dump1' to do a debug-style memory dump. The area currently being viewed is that of the keyboard buffer. Press keys not used by the main menu to see it change. Press any key to continue....." _ : CALL k PLAY ON PLAY "MB T120 L16 N0" ON PLAY(1) GOSUB MemDump: ' MemDump is at the end of the ' main part of this program IF MDump = 0 THEN CALL Monochrome ELSE CALL CGA ' seg off attr lines row CALL Dump1(&H40, &H10, 3, 6, 18) IF Monitor = 0 THEN CALL Monochrome ELSE CALL CGA END SUB SUB MemoryScroll STATIC '$DYNAMIC 'Turn off the XRay-type memory dump: SHARED Trap1, Trap2 Trap1 = 0: Trap2 = 1 PLAY OFF Lokate 1, 1: Prnt "Scroll - PgUp & PgDn Exit - Esc " + CHR$(13) PgUp$ = CHR$(0) + CHR$(73): PgDn$ = CHR$(0) + CHR$(81) up$ = CHR$(0) + CHR$(72): down$ = CHR$(0) + CHR$(80): ESC$ = CHR$(27) offset = &H3B60: ds = VARSEG(PgUp$) '-------------------------------------------------------------------------- DO UNTIL i$ = ESC$ Dump1 ds, offset, &H5F, Lines - 4, 2 'put refresh in the inkey$ loop so it displays data that changes i$ = "": DO UNTIL i$ <> "": i$ = INKEY$: Refresh: LOOP IF i$ = PgUp$ THEN offset = offset - (Lines - 3) * 16 IF i$ = PgDn$ THEN offset = offset + (Lines - 3) * 16 IF offset < -32767 THEN offset = offset + 65536 IF offset > 32767 THEN offset = offset - 65536 LOOP END SUB '=========================================================================== SUB NewBorders STATIC Kolor 3, 0: KLS: Lokate 10, 1: Prnt "Pattern:" Lokate 12, 1: x$ = "123456789": Prnt x$ CALL DefBorder(x$): Border 4: Kolor 3, 0 OpenW 0, 4, 2, 8, 11 Lokate 12, 21: x$ = CHR$(220) + CHR$(220) + CHR$(220) x$ = x$ + CHR$(221) + CHR$(32) + CHR$(222) x$ = x$ + CHR$(223) + CHR$(223) + CHR$(223) Prnt x$ CALL DefBorder(x$): OpenW 0, 4, 22, 8, 31 Lokate 12, 41: x$ = CHR$(236) + CHR$(240) + CHR$(236) x$ = x$ + CHR$(177) + CHR$(32) + CHR$(177) x$ = x$ + CHR$(236) + CHR$(240) + CHR$(236) Prnt x$ CALL DefBorder(x$): OpenW 0, 4, 42, 8, 51 Lokate 12, 61: x$ = CHR$(176) + CHR$(176) + CHR$(176) x$ = x$ + CHR$(219) + CHR$(32) + CHR$(219) x$ = x$ + CHR$(176) + CHR$(176) + CHR$(176) Prnt x$ CALL DefBorder(x$): OpenW 0, 4, 62, 8, 71 CALL k END SUB REM $STATIC SUB pages STATIC '$DYNAMIC 'tests if printx prints to correct pages 'find # rows and columns being displayed DEF SEG = 0: pagesize = PEEK(&H44C) + PEEK(&H44D) * 256 ppages = 16384 / pagesize IF ppages = 1 THEN EXIT SUB: 'only 1 page is possible FOR p = 0 TO ppages - 1 SCREEN , , p, p: CALL SetViewPage(p): KLS Border 2: Kolor 7, 7: OpenW 0, 5 + p, 5 + p * 4, 20 + p, 40 + p * 4 PrntW "This was printed on page ": PrntS p NEXT p 'view each page FOR x = 0 TO ppages - 1: SCREEN , , x, x: SetViewPage x Printt "Viewing page ", 4, x * 2, 60: PrntS x: CALL k: NEXT FOR x = 0 TO ppages - 1: SCREEN , , x, x: SetViewPage x CALL k: NEXT SCREEN , , 0, 0: SetViewPage (0) END SUB REM $STATIC SUB Pause (n!) SHARED Speed FOR x = 1 TO n * Speed: NEXT END SUB SUB PrintMainMenu STATIC '$DYNAMIC 'This sub prints the main menu, and illustrates the use of FillW '----Initialize the data for the main menu---- IF items = 0 THEN REDIM m$(20) items = 15: tr = 4: lc = 10: '# items in window & its location m$(2) = " Examples" m$(3) = " T Set Text Mode" m$(4) = " G Set Graphics Mode" m$(5) = " S Scrolling" m$(6) = " F Fill Window" m$(7) = " W Windows & Borders" m$(8) = " D Call DebugW " m$(9) = " C Configure this program" m$(10) = " P Printx Demo " m$(11) = " H Display time on/off" m$(12) = " X Memory Dump on/off (text modes only)" m$(13) = " R Color Registers (VGA only)" m$(14) = " M Scroll thru memory" m$(15) = " Q Quit" END IF 'draw the window for the menu Kolor 3, 0: IF Mode = 12 THEN Kolor 2, 0 CALL KLS: Border 2 OpenW 0, tr, lc, tr + items + 2, lc + 60 'the window is drawn but not saved if segment = 0 'QuickPrint the menu - fills the window with strings from M$() FillW 0, VARPTR(m$(1)) CALL logo END SUB REM $STATIC SUB PrintxDemo STATIC '$DYNAMIC CLS : LOCATE 1, 1, 1, 1, 12: 'block cursor SHARED e$() cr$ = CHR$(13) FOR px = 1 TO 3: 'demo's for PrntW, PrntW + CR$ and PrntW + EOL$ '---------------------------initialize the screen-------------------- Kolor 2, 0: KLS: 'color for text and window 'print a ruler below and left of the window: FOR x = 1 TO 16: Lokate x, 6: PrntS x: NEXT Lokate 17, 1: FOR x = 1 TO 6: Prnt "1234567890": NEXT Kolor 7, 0: OpenW 0, 4, 10, 16, 66 Printt " Call to PrintW ", 7, 4, 25 Printt "Next string to print is", 7, 18, 1 IF px = 2 THEN Printt " + chr$(13) ", 7, 4, 40 IF px = 3 THEN Printt " + chr$(10) ", 7, 4, 40 '---------------------print 13 strings, each a different color -------------- Lokate 1, 1: 'top left of the window attr = 32: 'imit val of color to print strings x = 1: PDemoLoop: IF x = 16 GOTO PDemoD: ' at = at + &H10: 'print each string a diff. color IF at = &H40 THEN at = &H50: '40h not visible on mono monitor IF at = &H80 THEN at = &H20 attr = at IF Mode = 12 THEN attr = attr \ 16 '-------------print RR & CC------------------------------ nr = RR: nc = CC: 'save cursor loc 'Lokate 1, 40: Prnt "RR = ": PrntS nr: Prnt " CC = ": PrntS nc '------print the next string to be printed (below the window) ----- Lokate 19, 1 Printt e$(x), attr, RR, CC Printt CHR$(13), &H7, RR, CC: 'and 2 blank lines to erase the Printt CHR$(13), &H7, RR, CC: 'last string 'try to explain how eol$ and cr$ work IF nr = 16 OR nc = 66 THEN Lokate 22, 1: Prnt "Note the cursor goes out of bounds instead " Prnt "of scrolling the last line" END IF '----------------locate the cursor, make it visible------- RR = nr: CC = nc: 'restore the cursor location Lokate RR, CC: 'block cursor '------------------------Pause, then make the call to PrintW--------------- CALL k: IF i$ = CHR$(27) THEN EXIT SUB IF px = 1 THEN PrintW e$(x), attr, RR, CC IF px = 2 THEN PrintW e$(x) + CHR$(13), attr, RR, CC IF px = 3 THEN PrintW e$(x) + CHR$(10), attr, RR, CC inc x: GOTO PDemoLoop PDemoD: NEXT px END SUB REM $STATIC SUB TextMode 'Rows, Columns and Mode are COMMON SHARED CALL KLS '$DYNAMIC REDIM t$(13) t$(1) = "25 x 80" t$(2) = "25 x 132" t$(3) = "34 x 80" t$(4) = "37 x 100" t$(5) = "34 x 132" t$(6) = "43 x 80" t$(7) = "42 x 100" t$(8) = "43 x 132" t$(9) = "50 x 80" t$(10) = "50 x 132" t$(11) = "60 x 80" t$(12) = "75 x 100" t$(13) = "60 x 132" up$ = CHR$(0) + CHR$(72): down$ = CHR$(0) + CHR$(80) c1 = 3: c2 = 4: Kolor c1, c2: 'window colors tr = 8: lc = 45: h = 1: 't$ that is highlighted '------------------------------------------------------------------------ StartTextMode: 'Print a help menu Border 3: Kolor c1, c2: OpenW 0, 3, 6, 11, 32: Lokate 1, 1 PrntW CHR$(24) + " " + CHR$(25) + " Select mode" + CHR$(13) PrntW "<Enter> Change mode" + CHR$(13) PrntW "<Esc> Exit" + CHR$(13) PrntW "C Count " + CHR$(13) PrntW CHR$(13) PrntW "Current Mode: " IF Mode = 0 AND Monitor = 0 THEN PrntW "Monochrome" + CHR$(13): PrntW " 25 x 80" END IF IF Mode = 0 AND Monitor > 0 THEN PrntW "Text" + CHR$(13): PrntW " " + STR$(Lines) + " x" + STR$(Columns) END IF IF Mode = 2 THEN PrntW "Graphics" + CHR$(13) PrntW " SCREEN 2 25 x 80" END IF IF Mode = 12 THEN PrntW "Graphics" + CHR$(13): PrntW " SCREEN 12 30 x 80" END IF '------------------------------------------------------------------------ 'Print the possible modes in a window Border 1: Kolor c1, c2: Lokate 1, 1 OpenW 0, tr, lc, tr + 14, lc + 12: 'draw a box, don't save FOR x = 1 TO 13: PrntW t$(x) + CHR$(10): NEXT '---------- Highlight the selected mode, wait for a keypress -------------- TL: GOSUB HighLight CALL k SELECT CASE i$ CASE up$ GOSUB UnHighlight h = h - 1: IF h = 0 THEN h = 13 GOSUB HighLight GOTO TL CASE down$ GOSUB UnHighlight h = h + 1: IF h = 14 THEN h = 1 GOSUB HighLight GOTO TL CASE CHR$(13) 'if in graphics mode, change to text mode: IF Mode <> 0 THEN CALL DefaultMode IF h = 1 THEN ScanLines = &H1202: ExtMode = &H0: Font = &H1114 IF h = 2 THEN ScanLines = &H1202: ExtMode = &H17: Font = &H1114 IF h = 3 THEN ScanLines = &H1203: ExtMode = &H1111: Font = &H0 IF h = 4 THEN ScanLines = &H1201: ExtMode = &H1F: Font = &H1114 IF h = 5 THEN ScanLines = &H1203: ExtMode = &H17: Font = &H1111 IF h = 6 THEN ScanLines = &H1201: ExtMode = &H0: Font = &H1112 IF h = 7 THEN ScanLines = &H0: ExtMode = &H1F: Font = &H1111 IF h = 8 THEN ScanLines = &H1201: ExtMode = &H17: Font = &H1112 IF h = 9 THEN ScanLines = &H1202: ExtMode = &H0: Font = &H1112 IF h = 10 THEN ScanLines = &H1202: ExtMode = &H17: Font = &H1112 IF h = 11 THEN ScanLines = &H1203: ExtMode = &H0: Font = &H1112 IF h = 12 THEN ScanLines = &H0: ExtMode = &H1F: Font = &H1112 IF h = 13 THEN ScanLines = &H1203: ExtMode = &H17: Font = &H1112 'set number of scan lines: al= 0/200 1/350 2/400 3/480 'On return, if AL <> 12h, the call was invalid, meaning the adapter 'is not a VGA or could be a VGA in CGA mode. This test is skipped 'in the 100-column modes because setting the number of scan lines 'is not needed. ax% = ScanLines: bx% = &H30 IF ax% <> 0 THEN CALL Int10(ax%, bx%, cx%, dx%) IF ax% MOD 256 <> &H12 THEN e$ = "L32ege": PLAY e$: GOTO StartTextMode END IF 'Set text mode ax% = 3: bx% = 0 CALL Int10(ax%, bx%, cx%, dx%) 'change to the extended mode ax% = ExtMode: bx% = 0 IF ax% <> 0 THEN CALL Int10(ax%, bx%, cx%, dx%) 'load a character set into the first font area ax% = Font: bx% = 0: IF ax% <> 0 THEN CALL Int10(ax%, bx%, cx%, dx%) Lines = VAL(LEFT$(t$(h), 3)) Columns = VAL(RIGHT$(t$(h), 3)) InitW RR, CC CALL Adapter(Monitor) GOTO StartTextMode CASE "C", "c" 'print a 'ruler' to check # of rows & columns Kolor 4, 0: Lokate 1, 1 FOR x = 10 TO Columns STEP 10 PrntUsingS "##########", x: NEXT FOR x = 1 TO Lines: Lokate x, 1: PrntUsingS "#####", x: NEXT GOTO TL CASE CHR$(27) EXIT SUB CASE ELSE GOTO TL END SELECT '------------------------------------------------------------------------ UnHighlight: IF Mode = 0 AND Monitor <> 0 THEN Lokate tr + h, 1: Kolor c1, c2: PrntW t$(h) + CHR$(10) ELSE Lokate tr + h, lc + 11: Prnt " " END IF RETURN HighLight: IF Mode = 0 AND Monitor <> 0 THEN Kolor c2, c1: Lokate tr + h, lc + 1: PrntW t$(h) + CHR$(10) ELSE Lokate tr + h, lc + 11: Prnt CHR$(27) END IF RETURN END SUB SUB train STATIC Delay = 4: Kolor 3, 0: KLS Lokate 1, 1: Prnt " f/faster s/slower esc/quit delay =" Lokate 1, 60: PrntUsingS "###", Delay x$ = ".eiee[] o---o o---o o---o o---o o---o o---o eee[]e" SELECT CASE Mode CASE 0 'run onto the screen FOR x = 1 TO LEN(x$) Printt MID$(x$, x, 1), 3, 16, 1 ScrollR 1, 16, 1, 16, 80 scrollU 1, 10, 80, 16, 80 ScrollL 1, 10, 1, 10, 80 ScrollD 1, 10, 1, 16, 1 NEXT 'run around until a keypress DO ScrollR 1, 16, 1, 16, 80 scrollU 1, 10, 80, 16, 80 ScrollL 1, 10, 1, 10, 80 ScrollD 1, 10, 1, 16, 1 Pause Delay i$ = INKEY$: IF i$ = CHR$(27) THEN EXIT DO IF i$ <> "" THEN GOSUB TrainKeyPress LOOP 'To run off the screen, stop scrolling up when the '.' gets to the BR corner. FOR x = 1 TO 350 IF SCREEN(16, 79) = 46 THEN x = 200 ScrollR 1, 16, 1, 16, 80 IF x < 199 THEN scrollU 1, 10, 80, 16, 80 ScrollL 1, 10, 1, 10, 80 ScrollD 1, 10, 1, 16, 1 Pause Delay NEXT CASE 2 Lokate 10, 1: Prnt x$ 'run around until a keypress DO ScrollR 8, 120, 0, 127, 639 scrollU 8, 72, 632, 127, 639 ScrollL 8, 72, 0, 79, 639 ScrollD 8, 72, 0, 127, 7 i$ = INKEY$: IF i$ = CHR$(27) THEN EXIT DO LOOP CASE 12 Lokate 10, 1: Prnt x$ DO ScrollR 8, 240, 0, 255, 639 scrollU 16, 144, 632, 255, 639 ScrollL 8, 144, 0, 159, 639 ScrollD 16, 144, 0, 255, 7 i$ = INKEY$: IF i$ = CHR$(27) THEN EXIT DO LOOP END SELECT EXIT SUB '----------------------------------------------------------- TrainKeyPress: IF i$ = "f" AND Delay > 0 THEN dec Delay IF i$ = "s" AND Delay < 80 THEN inc Delay: inc Delay Lokate 1, 60: PrntUsingS "###", Delay RETURN END SUB REM $STATIC SUB VGARead16ColReg (ColorReg$) STATIC 'Save the state of 16 color registers and the overscan register. On 'return, Palette$ is 49 bytes long and contains the values of the 16 'color registers currently in use, plus one byte for the overscan register. '''It would have been easier and more reliable to just save all 256 but '''this is compatible with VPT.EXE 'Read the current palette registers to see 'which color registers they are mapped to. CALL VGAReadPalReg(palette$) 'Read each color register into a string ColorReg$ = STRING$(49, " ") FOR n = 1 TO 16 ax% = &H1017 bx% = ASC(MID$(palette$, n, 1)): 'first register to read cx% = 1: 'number of registers to read dx% = SADD(ColorReg$) + (n - 1) * 3: 'string at es:dx Int10 ax%, bx%, cx%, dx% NEXT 'This function reads cx registers into a string at es:dx, starting 'with register number bx. You may read up to 255 reg at once with 'this call. Each takes 3 bytes, the order is Red-Green-Blue. 'If you wish to read the registers into numeric arrays or 'variables instead of a string, VGARead1ColReg may be easier. 'overscan reg goes in the last byte MID$(ColorReg$, 49, 1) = MID$(palette$, 17, 1) END SUB SUB VGARead1ColReg (reg, red, green, blue) 'Reads the current values for one color register. 'The default registers for VGA are: ' Color Register ' 0 0 ' 1 1 ' 2 2 ' 3 3 ' 4 4 ' 5 5 ' 6 20 ' 7 7 ' 8 56 ' 9 57 ' 10 58 ' 11 59 ' 12 60 ' 13 61 ' 14 62 ' 15 63 'Ex. to change the color displayed by the QB statement COLOR 8,0, change 'the values in register 56 ' IF reg < 0 OR reg > 255 THEN STOP ax% = &H1015 bx% = reg: 'register you wish to read, 0 to 255 Int10 ax%, bx%, cx%, dx% 'results: red = dx% \ 256 blue = cx% \ 256 green = cx% MOD 256 END SUB SUB VGAReadFile (File$, RGB$) STATIC ' loads a file created by VPT.EXE into RBG$ ' on exit, RGB$ is 49 bytes, ***or a null string if an error occurred*** ' VPT.EXE is a very nice editor for the vga color registers ' and may be found on the EXEC-PC bulletin board. 'save a window, print message Border 2: Kolor 2, 0 WSize Bytes&, 10, 30, 12, 60 REDIM t(Bytes& / 2) AS INTEGER OpenW VARSEG(t(1)), 10, 30, 12, 60 Lokate 1, 1: PrntW "Loading " + File$ RGB$ = SPACE$(49) ' Be sure the file exists! ON ERROR GOTO ResumeNext OPEN File$ FOR RANDOM AS #1 ON ERROR GOTO 0 FileLength = LOF(1) CLOSE IF FileLength = 49 THEN OPEN File$ FOR BINARY AS #3: GET #3, , RGB$ ELSE RGB$ = "": PrintW File$ + " not found", 2, 1, 1 END IF 'Be sure the file exists because OPEN FOR BINARY will create a file by 'this name with 0 length, ON ERROR will not trap the error, and RGB$ 'will be a string of 49 zero's. That would make for a very black monitor. FOR x = 1 TO 300: NEXT: 'time to read the message CALL CloseLastW: ERASE t END SUB SUB VGAReadPalReg (palette$) STATIC 'Reads the state of 16 palette registers and 'the overscan register into a 17 byte string palette$ = STRING$(17, " ") Int10 &H1009, 0, 0, SADD(palette$) END SUB SUB VGASet16ColReg (RGB$) STATIC 'set all 16 color registers from a 48 or 49 byte string 'Get a list of the color registers being displayed CALL VGAReadPalReg(palette$) 'Be sure we are not calling with a null or blank string: IF RGB$ <> SPACE$(49) AND (LEN(RGB$) = 49 OR LEN(RGB$) = 48) THEN FOR n = 1 TO 15 ax% = &H1012 bx% = ASC(MID$(palette$, n, 1)): 'first register to write cx% = 1: 'number of registers to write dx% = SADD(RGB$) + (n - 1) * 3: 'string at es:dx Int10 ax%, bx%, cx%, dx% NEXT END IF END SUB SUB VGASet1ColReg (reg, red, green, blue) STATIC IF reg < 0 OR reg > 255 THEN STOP IF red < 0 OR red > 63 THEN STOP IF green < 0 OR red > 63 THEN STOP IF blue < 0 OR red > 63 THEN STOP ax% = &H1010 bx% = reg cx% = green * 256 + blue dx% = red * 256 Int10 ax%, bx%, cx%, dx% END SUB SUB VgaSetDefaultReg STATIC ' set the palette and color registers to their default state REDIM reg(0 TO 63, 1 TO 3) AS INTEGER red = 1: green = 2: blue = 3 'Default values for COLOR 7 are 42, 42 & 42, but 'I usually change it to 0, 63, 0 so the DOS prompt is green reg(0, red) = 0: reg(0, green) = 0: reg(0, blue) = 0 reg(1, red) = 0: reg(1, green) = 0: reg(1, blue) = 42 reg(2, red) = 0: reg(2, green) = 42: reg(2, blue) = 0 reg(3, red) = 0: reg(3, green) = 42: reg(3, blue) = 42 reg(4, red) = 42: reg(4, green) = 0: reg(4, blue) = 0 reg(5, red) = 42: reg(5, green) = 0: reg(5, blue) = 42 reg(20, red) = 42: reg(20, green) = 21: reg(20, blue) = 0 reg(7, red) = 0: reg(7, green) = 63: reg(7, blue) = 0 reg(56, red) = 21: reg(56, green) = 21: reg(56, blue) = 21 reg(57, red) = 21: reg(57, green) = 21: reg(57, blue) = 63 reg(58, red) = 21: reg(58, green) = 63: reg(58, blue) = 21 reg(59, red) = 21: reg(59, green) = 63: reg(59, blue) = 63 reg(60, red) = 63: reg(60, green) = 21: reg(60, blue) = 21 reg(61, red) = 63: reg(61, green) = 21: reg(61, blue) = 63 reg(62, red) = 63: reg(62, green) = 63: reg(62, blue) = 21 reg(63, red) = 63: reg(63, green) = 63: reg(63, blue) = 63 REDIM PalReg(0 TO 16) AS INTEGER '0-15 are Palette registers, 16 is the overscan register FOR n = 0 TO 7: PalReg(n) = n: NEXT FOR n = 8 TO 15: PalReg(n) = n + 48: NEXT PalReg(6) = 20: ' one oddball PalReg(16) = 0: 'overscan register 'set the palette register FOR n = 0 TO 15 'ax = 1000 'bh = color reg value 'bl = palette reg Int10 &H1000, PalReg(n) * 256 + n, 0, 0 'set the corresponding color register 'ax=1010 'bx = register 'ch = green 'cl = blue 'dh = red 'PRINT &H1010, PalReg(n), HEX$(reg(PalReg(n), green) * 256 + reg(PalReg(n), blue)), HEX$(reg(PalReg(n), red) * 256) Int10 &H1010, PalReg(n), reg(PalReg(n), green) * 256 + reg(PalReg(n), blue), reg(PalReg(n), red) * 256 NEXT 'set the overscan register to zero Int10 &H1001, PalReg(16) * 256, 0, 0 ERASE reg: ERASE PalReg END SUB SUB VGASetOverScanReg (n) STATIC IF n < 0 OR n > 15 THEN STOP ax% = &H1001 bx% = n Int10 ax%, bx%, cx%, dx% END SUB SUB VgaViewReg STATIC CALL VGARead16ColReg(V$) CALL VGAReadPalReg(palette$) Lokate 1, 1: 'CALL KLS Black$ = CHR$(0) + CHR$(0) + CHR$(0): cr$ = CHR$(13) Prnt " Current colors" + cr$: Prnt cr$ Prnt " Color Register Red Green Blue" + cr$ FOR x = 1 TO 46 STEP 3 c = (x - 1) / 3 IF MID$(V$, x, 3) = Black$ THEN Kolor 7, 0 ELSE Kolor c, 0 PrntUsingS "##########", c PrntUsingS "##########", ASC(MID$(palette$, c + 1, 1)) FOR y = 0 TO 2 PrntUsingS "##########", ASC(MID$(V$, x + y, 1)) NEXT IF MID$(V$, x, 3) = Black$ THEN Prnt " (Black)" + cr$ ELSE Prnt " " + CHR$(219) + CHR$(219) + CHR$(219) + cr$ END IF NEXT Kolor 2, 0 Prnt "Overscan is color ": PrntS ASC(RIGHT$(V$, 1)) END SUB SUB Window1 '$DYNAMIC 'this sub draws several windows, illustrates CloseLastW, zooming, and DBox SELECT CASE Mode CASE 0 'zoom this one WSize Bytes&, 12, 30, 24, 80: : REDIM t4%(Bytes& / 2) SaveW VARSEG(t4%(1)), 12, 30, 24, 80: 'note SaveW, not OpenW FOR x = 80 TO 30 STEP -1 Kolor 0, 6: OpenW 0, 12, x, 24, 80 Pause 1 NEXT WSize Bytes&, 2, 2, 7, 79: REDIM t1%(Bytes& / 2): Pause 50 Kolor 0, 2: OpenW VARSEG(t1%(1)), 2, 2, 7, 79 WSize Bytes&, 1, 70, 25, 77: REDIM t2%(Bytes& / 2): Pause 50 Border 3: Kolor 0, 3: OpenW VARSEG(t2%(1)), 1, 70, 25, 77 WSize Bytes&, 6, 12, 20, 35: REDIM t3%(Bytes& / 2): Pause 50 Kolor 0, 3: OpenW VARSEG(t3%(1)), 6, 12, 20, 35 Lokate 3, 3: Kolor 3, 0: Prnt "Restoring the screen is as easy as calling 'CloseLastW'." 'the last box to draw is in the QBasic sub DBox Pause 50 CALL DBox("Press <Enter> to continue.....", "") Pause 50 'now erase the boxes FOR x = 1 TO 3: CloseLastW: Pause 100: NEXT 'WATCH OUT - that zooming effectively trashes the CloseLastW Stack 'so close the last one with CloseW CloseW VARSEG(t4%(1)), 12, 30, 24, 80 Pause 200 ERASE t4%: ERASE t3%: ERASE t2%: ERASE t1% CASE 2 'zoom this one WSize Bytes&, 12, 30, 24, 80: : REDIM t4%(Bytes& / 2) SaveW VARSEG(t4%(1)), 12, 30, 24, 80: 'note SaveW, not OpenW FOR x = 80 TO 30 STEP -1 Kolor 0, 6: OpenW 0, 12, x, 24, 80 Pause 1 NEXT WSize Bytes&, 2, 2, 7, 79: REDIM t1%(Bytes& / 2): Pause 50 Kolor 0, 2: OpenW VARSEG(t1%(1)), 2, 2, 7, 79 WSize Bytes&, 1, 70, 25, 77: REDIM t2%(Bytes& / 2): Pause 50 Border 3: Kolor 0, 3: OpenW VARSEG(t2%(1)), 1, 70, 25, 77 WSize Bytes&, 6, 12, 20, 35: REDIM t3%(Bytes& / 2): Pause 50 Kolor 0, 3: OpenW VARSEG(t3%(1)), 6, 12, 20, 35 Lokate 3, 3: Kolor 3, 0: Prnt "Restoring the screen is as easy as calling 'CloseLastW'." 'the last box to draw is in the QBasic sub DBox Pause 50 CALL DBox("Press <Enter> to continue.....", "") 'now erase the boxes FOR x = 1 TO 3: CloseLastW: Pause 200: NEXT 'WATCH OUT - that zooming effectively trashes the CloseLastW Stack 'so close the last one with CloseW CloseW VARSEG(t4%(1)), 12, 30, 24, 80 Pause 200 ERASE t4%: ERASE t3%: ERASE t2%: ERASE t1% CASE 12 FOR x = 80 TO 30 STEP -1 Kolor 6, 0: OpenW 0, 12, x, 24, 80 Pause 1 NEXT Kolor 2, 0: OpenW 0, 2, 2, 7, 79 Border 3: Kolor 3, 0: OpenW 0, 1, 70, 25, 77 Kolor 3, 0: OpenW 0, 6, 12, 20, 35 Pause 250 END SELECT END SUB REM $STATIC SUB Window2 '$DYNAMIC 'This demo uses OpenW with user-defined borders to draw a background and 'prints a window with a shadow 'defborder (x$) string of 9 char for user defined borders Bd$ = "": FOR x = 1 TO 9: Bd$ = Bd$ + CHR$(176): NEXT DefBorder Bd$: Border 4 KLS 'draw the background Kolor 2, 0: OpenW 0, 1, 1, 25, 15 Kolor 3, 0: OpenW 0, 1, 16, 25, 29 Kolor 5, 0: OpenW 0, 1, 30, 25, 47 Kolor 6, 0: OpenW 0, 1, 48, 25, 63 Kolor 2, 0: OpenW 0, 1, 64, 25, 80 'draw the shadow of the window tr = 8: br = 16: lc = 20: rc = 60 Kolor 0, 0: OpenW 0, tr + 1, lc - 1, br + 1, rc - 1 'draw the window Kolor 0, 3: Border 2: OpenW 0, tr, lc, br, rc Lokate 1, 1: Kolor 3, 0: PrntW "Illustrates shadows and backgrounds. Press any key..." CALL k: CALL KLS '------------------------------------------------------------------------- END SUB REM $STATIC SUB Window3 '$DYNAMIC IF Mode <> 0 THEN EXIT SUB Kolor 0, 6: KLS: REDIM temp%(500) Lokate 1, 1: Prnt "This demonstrates the error checking that occurs (in text modes only)" Lokate 2, 1: Prnt "when window coordinates are outside the viewing area" up$ = CHR$(0) + CHR$(72): down$ = CHR$(0) + CHR$(80) Lft$ = CHR$(0) + CHR$(75): rght$ = CHR$(0) + CHR$(77) tr = 8: lc = 40: br = 15: rc = 62 WSize Bytes&, tr, lc, br, rc: REDIM temp%(Bytes& / 2) i$ = "" DO 'print the coordinates Lokate 5, 5: Prnt "TR ": PrntS tr IF tr < 1 THEN Prnt " " + CHR$(27) ELSE Prnt " " Lokate 6, 5: Prnt "LC ": PrntS lc IF lc < 1 THEN Prnt " " + CHR$(27) ELSE Prnt " " Lokate 7, 5: Prnt "BR ": PrntS br IF br > 25 THEN Prnt " " + CHR$(27) ELSE Prnt " " Lokate 8, 5: Prnt "RC ": PrntS rc IF rc > 80 THEN Prnt " " + CHR$(27) ELSE Prnt " " 'print the box Border 0: Kolor 0, 7: OpenW VARSEG(temp%(1)), tr, lc, br, rc Lokate 1, 1 PrntW "Move this box " + CHR$(13) PrntW "off the screen " + CHR$(13) PrntW "with the cursor keys." + CHR$(13) PrntW "Press ESC to quit" 'wait for a keypress, then drag the window around the screen using the 'cursor keys i$ = "": DO UNTIL i$ <> "": i$ = INKEY$: LOOP SELECT CASE i$ CASE up$: tr = tr - 1: br = br - 1 CASE down$: tr = tr + 1: br = br + 1 CASE Lft$: lc = lc - 1: rc = rc - 1 CASE rght$: lc = lc + 1: rc = rc + 1 CASE ELSE: EXIT DO END SELECT CALL CloseLastW LOOP ERASE temp% END SUB