home *** CD-ROM | disk | FTP | other *** search
- DECLARE SUB MemoryDump ()
- DECLARE SUB attributes ()
- DECLARE SUB DBox (F$)
- DECLARE SUB DebugData ()
- DECLARE SUB dec (n)
- DECLARE SUB Diversion ()
- DECLARE SUB Fill ()
- DECLARE SUB GraphicsDemo1 ()
- DECLARE SUB GraphicsDemo2 ()
- DECLARE SUB GraphicsDemo3 ()
- DECLARE SUB inc (n)
- DECLARE SUB k ()
- DECLARE SUB machine ()
- DECLARE SUB NewBorders ()
- DECLARE SUB open10 ()
- DECLARE SUB pages ()
- DECLARE SUB PrintxDemo ()
- DECLARE SUB ReadScreenDemo ()
- DECLARE SUB StringArray ()
- DECLARE SUB testpattern ()
- DECLARE SUB TextMode (r, c)
- DECLARE SUB train ()
- DECLARE SUB VGARead16ColReg (ColorReg$)
- DECLARE SUB VGAReadFile (File$, RGB$)
- DECLARE SUB VGAReadPalReg (Palette$)
- DECLARE SUB VGASet16ColReg (RGB$)
- DECLARE SUB VGASet1ColReg (Reg!, Red!, Green!, Blue!)
- DECLARE SUB VGASetDefaultReg ()
- DECLARE SUB VGAViewReg ()
-
- '==================================================================
- REM $DYNAMIC
- COMMON SHARED i$
- '$INCLUDE: 'W30.dec'
- OPTION BASE 1
- REDIM mode$(14, 5): 'used by TextMode
-
- '==================================================================
-
- 'flags to toggle displaytime & memorydump on/off
- clock2 = 1: Trap2 = 1
-
- 'initialize some strings for PrintxDemo
- REDIM e$(100): OPEN "i", #3, "W30.DEC"
- FOR x = 1 TO 30: LINE INPUT #3, e$(x): NEXT: CLOSE
-
- '----Initialize the data for the main menu----
- items = 14: TR = 4: LC = 10: '# items in the window & its location
- RESTORE 100: REDIM M$(20)
- FOR x = 1 TO 20: READ M$(x): NEXT
-
- '===========================================================================
- start:
- '----clear the screen, print the menu----
- Kolor 3, 0:
- KLS
- OpenW 2, 3, 0, TR, LC, TR + items + 4, 70
- CALL FillW(0, VARPTR(M$(1)))
-
- '----Wait for a keypress----
- MainMenuLoop:
- i$ = "": DO UNTIL i$ <> "": i$ = INKEY$: LOOP: i$ = LCASE$(i$)
-
- SELECT CASE i$
- CASE "s": CALL train: CALL machine
- CASE "f": CALL Fill
- CASE "v": CALL attributes
- CASE "c": CALL open10
- CASE "d": CALL DebugData
- CASE "p": CALL PrintxDemo
- CASE "b": CALL NewBorders
- CASE "q": CALL TextMode(25, 80): END
- CASE "g": CALL GraphicsDemo2: CALL GraphicsDemo3: CALL GraphicsDemo1
- CASE "t": CALL TextMode(0, 0)
- CASE "x": SWAP Trap1, Trap2:
- IF Trap1 = 1 THEN
- PLAY ON
- PLAY "MB T130 L32 N0"
- ON PLAY(1) GOSUB MemDump
- CALL Dump2(17, 1, 3, 1, 5, 0, &H40, 16, 0, 1)
- ELSE PLAY OFF
- END IF
- CASE "h": SWAP clock1, clock2:
- IF clock1 = 1 THEN
- ON TIMER(1) GOSUB DisplayTime: TIMER ON
- ELSE TIMER OFF
- END IF
- CASE "n": CALL pages
- 'CASE "n": CALL SP
- CASE "r": CALL Diversion
- CASE "m": CALL MemoryDump
- CASE ELSE: GOTO MainMenuLoop
- END SELECT: GOTO start
- '==========================================================================
-
- 100
- DATA " Examples"
- DATA ""
- DATA " S Scrollx"
- DATA " F Fill Window"
- DATA " V View Attributes"
- DATA " C CloseLastW"
- DATA " D Call DebugW "
- DATA " B User defined borders"
- DATA " P Printx Demo "
- DATA " G Scroll Left in Graphics Mode"
- DATA " H Display time on/off"
- DATA " X Memory Dump on/off"
- DATA " T Change Text Mode (VGA/EGA)"
- DATA " R Color Registers (VGA only)"
- 'DATA " N SpreadSheet demo"
- DATA " M Scroll thru memory"
- DATA " Q Quit"
- DATA ,,,,,,,,,,,,,,
-
- ResumeNext: EE = ERR: RESUME NEXT
-
- DisplayTime:
- cccR = CSRLIN: cccC = POS(x)
- 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 attributes STATIC
- Kolor 2, 0: KLS: DEF SEG = &HB800: 'segment of screen 1
- LOCATE 10, 30: PRINT "Decimal"; : LOCATE 20, 30: PRINT "Hex";
- LOCATE 25, 1: PRINT "Press any key to quit"
-
- '----------------print all the a ttributes in decimal-----------
- LOCATE 1, 1, 0
- x = 0: DO UNTIL x = 127
- PRINT USING "#####"; x;
-
- FOR y = 1 TO 9 STEP 2
- POKE x * 10 + y, x
- NEXT: i$ = INKEY$: IF i$ <> "" THEN EXIT DO
- x = x + 1: LOOP
-
- '-------Print all the attributes in hex-----------------
- LOCATE 11, 1
- x = 0: DO UNTIL x = 127
- i$ = INKEY$: IF ii$ <> "" THEN EXIT SUB
- PRINT USING "\ \"; HEX$(x);
-
- FOR y = 1 TO 9 STEP 2
- POKE x * 10 + y + 1600, x
- NEXT: i$ = INKEY$: IF i$ <> "" THEN EXIT DO
- x = x + 1: LOOP
-
- Printt CHR$(10), 7, 25, 1: 'erase message
-
- Printt "Press any key to call SwapAttr", 7, 20, 1
- CALL k
- Printt "Press any key to call SwapAttr", 7, 21, 1: CALL SwapAttr
-
- CALL k:
- Printt "Press any key to call ChangeAttr(15)", &H70, 22, 1: CALL SwapAttr
-
- CALL k:
- Printt "Press any key to call ChangeAttr(&h70)", 7, 23, 1
- CALL ChangeAttr(15)
-
- CALL k:
- Printt "Press any key to call SwapAttr" + CHR$(10), 15, 24, 1
- CALL ChangeAttr(&H70)
- CALL k:
- CALL SwapAttr
- Printt "Press any key...", 7, 25, 1
-
- CALL k
-
-
- END SUB
-
- SUB DBox (F$)
- '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
- REDIM box(2000) AS INTEGER
- OpenW 1, attr, VARSEG(box(1)), TR, LC, BR, RC
-
- OpenW 1, attr, 0, TR + 4, LC + 6, TR + 6, LC + 44
- Printt "Name of a text file to view:", attr, TR + 3, LC + 7
-
- OpenW 2, attr, 0, TR + 8, LC + 13, TR + 10, LC + 18
- Printt "OK", attr, TR + 9, LC + 15
-
- OpenW 1, attr, 0, TR + 8, LC + 28, TR + 10, LC + 37
- Printt "Cancel", attr, TR + 9, LC + 30
-
- COLOR c1, c2: LOCATE TR + 5, LC + 8, 1
- INPUT "", F$: ' comma suppresses the '?'
- FOR x = 1 TO 4: CALL CloseLastW: NEXT
- END SUB
-
- '===========================================================================
- SUB DebugData STATIC
- CALL DebugW
- END SUB
-
- SUB dec (n) STATIC
- n = n - 1
- END SUB
-
- SUB Diversion
- Kolor 2, 0
- CALL Adapter(n%): IF n% <> 3 THEN EXIT SUB
-
- 'view current colors
- KLS
- CALL VGAViewReg
- Printt "Press a key...", 2, 22, 1: k
-
- 'save current colors
- CALL VGARead16ColReg(SaveReg$)
-
- 'read new colors from a file
- CALL VGAReadFile("W30.VPT", RGB$)
-
- 'set the VGA to these new colors
- 'changes those wimpy pastels to flaming reds and oranges
- 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
-
- 'here's the diversion
- Lokate 22, 1: Prnt "Play RedBaron? y/n":
- i$ = "": DO UNTIL i$ <> "": i$ = INKEY$: LOOP
-
- 'run the game from a batch file instead of a simple shell command
- 'so control - break will be handled properly
- IF LCASE$(i$) = "y" THEN
- CLOSE : OPEN "W30Temp.bat" FOR OUTPUT AS #3
- PRINT #3, "\games\Redbaron"
- CLOSE
- SHELL "W30Temp.bat"
- END IF
-
- 'restore the original colors
- Printt "restore colors to 1/original 2/default ", 2, 24, 1
- CALL k: x = VAL(i$)
- IF x = 1 THEN CALL VGASet16ColReg(SaveReg$) ELSE CALL VGASetDefaultReg
-
- CALL VGAViewReg
- END SUB
-
- SUB Doc
-
- ' Quick Reference:
- 'Adapter (a%) active adapter returned in a 0\mono 1\cga 2\ega 3\vga
- 'CGA () sets video segment for the cga
- 'ChangeAttr (attr)
- 'CloseLastW () close window opened with OpenW or SaveW
- 'closew ( segment, TR, LC, BR, RC)
- 'DebugW ()
- 'defborder (x$) string of 9 char for user defined borders
- 'Dump2 (r,c,attr, border, #Lines, #Col, segment, offset%, format, refreshrate)
- 'FillW ( offset, varptr(a$(n)) fill a window from a string array.
- 'GScrollL8 ( TR, LC, BR, RC)
- 'InitW (RR, CC)
- 'Int10 (ax%, bx%, cx%, dx%)
- 'int3
- 'KLS
- 'Kolor ( foreground, background)
- 'Lokate ( r, c)
- 'Monochrome () sets video segment for monochrome adapter
- 'OpenW ( border, attr, segment, TR, LC, BR, RC)
- 'Printt (a$, attr, r, c)
- 'PrintW (a$, attr, r, c)
- 'Prnt (a$)
- 'PrntS (i!)
- 'PrntUsingS (Mask$, i!)
- 'PrntW (a$)
- 'ReadScreen (a$, r, c)
- 'Refresh () repeats the call to dump2
- 'saveW ( segment, TR, LC, BR, RC)
- 'scrolld ( attr, lines, TR, LC, BR, RC)
- 'scrollL ( attr, cols, TR, LC, BR, RC)
- 'scrollr ( attr, cols, TR, LC, BR, RC)
- 'scrollu ( attr, lines, TR, LC, BR, RC)
- 'SetViewPage (p)
- 'SetViewW ( page, TR, LC, BR, RC)
- 'SwapAttr ()
- '
- '
- '--------------------------------------------------------------------------
- 'Here is a list of all the VGA calls (these are subs in W30.BAS):
-
- 'Adapter(n%) [n is an integer variable, not BYVAL]
- ' type of adapter in use 0/mono 1/cga 2/ega 3/vga
- '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.
-
- ' Note: the calls to read or set 16 registers use strings,
- ' those to read or set one register use numbers.
-
- '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.
-
- ' There 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.
-
-
- END SUB
-
- REM $DYNAMIC
- SUB Fill STATIC
- SHARED EE: 'error code from resumenext
- SHARED SkipCheck: 'used by TextMode
- 'this routine prints tab character, may need to filter the file
- F$ = "W30.doc": 'name of a text file to view
-
- 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$(2000): 'array holds the strings to be viewed
- LastLine = 1: 'number of strings used in a$()
- 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
- border = 2: 'initial border, a double line
- REDIM a%(9900): 'array used to save the screen, enough for 75x132
- CALL defborder(CHR$(220) + CHR$(220) + CHR$(220) + CHR$(221) + CHR$(32) + CHR$(222) + CHR$(223) + CHR$(223) + CHR$(223))
-
- '------------Clear the screen and print a help menu --------------------------
- Kolor 2, 0: KLS
- OpenW 4, 6, 0, 2, 1, 24, 24: Lokate 1, 1: 'draw a box
- Kolor 12, 0: PrntW "Keys to scroll:" + CR$
- Kolor 9, 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 9, 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 "<esc> Quit" + CR$
- Kolor 6, 0: PrntW "______________________": PrntW CR$
- Kolor 12, 0: PrntW "Current colors:" + CR$:
-
- Kolor 9, 0
- PrntW " Foreground " + CR$
- PrntW " Background " + CR$
- PrntW " Attribute "
-
- '-------------------------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(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
- DO UNTIL EOF(3): LINE INPUT #3, a$(LastLine)
- Lokate 9, 40: PrntUsingS "####", LastLine
-
- IF FRE(x$) < 2000 OR LastLine > 1999 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
- Printt " ", 2, 12, 30: 'erase the message
-
- '---------------------------------------------------------------------------
- FileLoaded:
- 'find the center of the display
- DEF SEG = 0
- columns = PEEK(&H44A) + PEEK(&H44B) * 256
- rows = PEEK(&H484) + 1
- MiddleRow = INT(rows / 2): MiddleCol = INT(columns / 2)
- DeltaR = MiddleRow / 6: 'add/subtract to window TR,LC,BR & RC when
- DeltaC = MiddleCol / 6: ' changing the window size
-
- '-------------------------Set up a window-----------------------------------
- OpenWindow:
- 'Update colors while not covered up by the file window
- Kolor 12, 0:
- Lokate 21, 17: PrntUsingS "###", fore
- Lokate 22, 17: PrntUsingS "###", back
- aa$ = HEX$(back * 16 + fore)
- Lokate 23, 17: Prnt aa$ + " hex "
-
- 'check bounds
- IF SIZE < 1 THEN SIZE = 1
- IF SIZE > MiddleRow / DeltaR + 1 THEN SIZE = MiddleRow / DeltaR + 1
- TR = MiddleRow - SIZE * DeltaR: BR = MiddleRow + SIZE * DeltaR
- LC = MiddleCol - SIZE * DeltaC: RC = MiddleCol + SIZE * DeltaC
- attr = back * 16 + fore
-
- 'open and save the window
- CALL OpenW(border, attr, VARSEG(a%(1)), TR, LC, BR, RC)
-
- '-------------------------Print the file in the window----------------------
- PrintWindow:
- IF L > LastLine - MiddleRow THEN L = LastLine - MiddleRow: PLAY e$
- IF L < 1 THEN L = 1: PLAY e$
- IF n < 0 THEN n = 0: PLAY e$ ELSE IF n > 120 THEN n = 120: PLAY e$
- CALL FillW(n, VARPTR(a$(L)))
-
- '-----------------------Wait for instructions-------------------------------
- CALL k
- SELECT CASE i$
- CASE "f", "F": F$ = "": GOTO StartFillDemo: 'OpenFile
- CASE up$: dec L
- CASE down$: inc L
- CASE lft$: inc n
- CASE rght$: dec n
- CASE "b": inc border: IF border = 5 THEN border = 0:
- CALL CloseLastW: GOTO OpenWindow
- CASE tab$: n = n + 5
- CASE ShiftTab$: n = n - 5
- CASE esc$: GOTO ExitFillDemo
- CASE PgUp$: L = L - MiddleRow * 2
- CASE PgDn$: L = L + MiddleRow * 2
- CASE Home$: n = 0: L = 1
- CASE end$: L = 9999
- CASE "-": dec SIZE: CALL CloseLastW: GOTO OpenWindow
- CASE "+": inc SIZE: CALL CloseLastW: GOTO OpenWindow
- CASE "t": SkipCheck = 1: CloseLastW: CALL TextMode(0, 0): GOTO FileLoaded
- CASE "1": fore = fore + 1: IF fore > 15 THEN fore = 0
- CALL CloseLastW: GOTO OpenWindow
- CASE "9": back = back + 1: IF back > 7 THEN back = 0
- CALL CloseLastW: GOTO OpenWindow
- CASE "2": fore = fore - 1: IF fore < 0 THEN fore = 15
- CALL CloseLastW: GOTO OpenWindow
- CASE "0": back = back - 1: IF back < 0 THEN back = 7
- CALL CloseLastW: GOTO OpenWindow
-
- CASE ELSE
- END SELECT: GOTO PrintWindow
- ExitFillDemo:
- ERASE a%: ERASE a$
-
- END SUB
-
- REM $STATIC
- SUB GraphicsDemo1 STATIC
- SCREEN 2, , 0, 0: CLS
- 'move a triangle wave
-
- y = 86: Z = -1
- LINE (0, 23)-(639, 23)
- LINE (0, 88)-(639, 88)
-
- i$ = "": DO UNTIL i$ <> ""
- 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
-
- CALL GScrollL8(24, 0, 87, 639)
- i$ = INKEY$: LOOP
- SCREEN 0
- END SUB
-
- SUB GraphicsDemo2 STATIC
- SCREEN 0, 1, 0, 0
- SCREEN 2: CLS
- 'rack up some balls
-
- CIRCLE (559, 50), 30:
- FOR y = 1 TO 66: CALL GScrollL8(20, 0, 80, 639): NEXT
-
- CIRCLE (559, 50), 30:
- FOR y = 1 TO 56: CALL GScrollL8(20, 80, 80, 639): NEXT
-
- CIRCLE (559, 50), 30:
- FOR y = 1 TO 46: CALL GScrollL8(20, 160, 80, 639): NEXT
-
- CIRCLE (559, 50), 30:
- FOR y = 1 TO 36: CALL GScrollL8(20, 240, 80, 639): NEXT
-
- END SUB
-
- SUB GraphicsDemo3 STATIC
- SCREEN 2, 0, 0, 0: CLS
- 'characters in SCREEN 2 are 8 by 8 so it is easy to scroll one char at a time
- 'draw a pattern
- FOR x = 1 TO 20
- PRINT "Hello 1 2 3 4 5 6 7 8 9 0 q w e r t y u i o p z x c v b n m , . / a s h j k l []"
- NEXT
-
- 'define the window size. The row (a&c) is 1 to 25 and
- 'the columns (b & d) are 1 to 80
- a = 3: B = 1: c = 6: d = 80
-
- 'convert rows & columns to 0-199 and 0-639 format
- TR = (a - 1) * 8: LC = (B - 1) * 8: BR = c * 8 - 1: RC = (d - 1) * 8
-
- PRINT TR, LC, BR, RC: INPUT "Pause....."; x$
-
- 'scroll 8 characters left
- CALL GScrollL8(TR, LC, BR, RC)
- CALL GScrollL8(TR, LC, BR, RC)
- CALL GScrollL8(TR, LC, BR, RC)
- CALL GScrollL8(TR, LC, BR, RC)
- CALL GScrollL8(TR, LC, BR, RC)
- CALL GScrollL8(TR, LC, BR, RC)
- CALL GScrollL8(TR, LC, BR, RC)
- CALL GScrollL8(TR, LC, BR, RC)
- INPUT "Pause....."; x$
- END SUB
-
- SUB inc (n) STATIC
- n = n + 1
- END SUB
-
- SUB k
- k: i$ = "": DO UNTIL i$ <> "": i$ = INKEY$: LOOP:
-
- END SUB
-
- REM $DYNAMIC
- '===========================================================================
- SUB machine STATIC
- c1 = 0: c2 = 4: attr = c1 + c2 * 16: 'color to use here
- COLOR c1, c2: Kolor c1, c2: KLS
- 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
-
- CALL OpenW(0, 0, 0, 10, 49, 23, 53): 'Draw a black box (attribute is 0)
-
- Printt "A B C D E F G H I J K L M N O", attr, 24, 51: ' A at 51, 0 is at 79
- y = 97: DO UNTIL y = 123
- i$ = INKEY$: IF i$ <> "" THEN EXIT DO
-
- '----go left and up
- FOR pause = 1 TO 10: NEXT
- FOR x = 1 TO 7: CALL scrollL(attr, 1, 1, 44, 23, 60): NEXT
- CALL closew(VARSEG(ccc%(1)), 3, 5, 9, 40): 'print arm in up position
- FOR x = 1 TO 10: CALL scrollu(attr, 1, 1, 44, 23, 60): NEXT
-
- '---go right and down
- FOR pause = 1 TO 10: NEXT
- FOR x = 1 TO 7: CALL scrollr(attr, 1, 1, 44, 23, 60): NEXT
- CALL closew(VARSEG(c%(1)), 3, 5, 8, 40): 'print arm in down position
- FOR x = 1 TO 10: CALL scrolld(attr, 1, 1, 44, 23, 60): NEXT
-
- 'scroll the letters
- CALL scrollL(attr, 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
-
- FOR pause = 1 TO 250: NEXT
- COLOR 2, 0
- ERASE c%: ERASE ccc%
- END SUB
-
- REM $STATIC
- SUB MemoryDump STATIC
-
- 'Turn off the XRay-type memory dump:
- SHARED Trap1, Trap2
- Trap1 = 0: Trap2 = 1
- PLAY OFF
-
- '--------------------------------------------------------------------------
- IF PgUp$ = "" THEN
- Lokate 1, 1: Prnt "Scroll - PgUp & PgDn Exit - Esc " + CHR$(13)
- Prnt "Press any key to continue.......": CALL k
- CALL ReturnSegments(cs%, ds%)
- PgUp$ = CHR$(0) + CHR$(73): PgDn$ = CHR$(0) + CHR$(81)
- up$ = CHR$(0) + CHR$(72): down$ = CHR$(0) + CHR$(80): esc$ = CHR$(27)
- offset% = &H1600
- END IF
- '--------------------------------------------------------------------------
- DEF SEG = 0: r = PEEK(&H484) - 1: 'leave 2 lines for the border
-
- DO UNTIL i$ = esc$
-
- Dump2 1, 1, &H5F, 2, r, 0, ds%, offset%, 0, 0
- i$ = ""
- 'put refresh in the inkey$ loop so it displays data that changes
- DO UNTIL i$ <> "": i$ = INKEY$:
-
- 'moving the cursor makes the 2 bytes at 17C2 change:
- FOR x = 1 TO 2: : LOCATE x, x + 2
- Refresh
- NEXT
- LOOP
-
- IF i$ = PgUp$ THEN
- n = offset% - r * 32
- IF n < -32767 THEN n = n + 65536
- IF n > 32767 THEN n = n - 65536
- offset% = n
- END IF
- LOOP
- END SUB
-
- REM $DYNAMIC
- '===========================================================================
- SUB NewBorders STATIC
- Kolor 3, 0: KLS: Lokate 10, 1: Prnt "Pattern:"
- Lokate 12, 1: x$ = "123456789": Prnt x$
- CALL defborder(x$):
- CALL OpenW(4, &H3, 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$):
- CALL OpenW(4, &H3, 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$):
- CALL OpenW(4, &H3, 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$):
- CALL OpenW(4, &H3, 0, 4, 62, 8, 71)
-
- CALL k
- END SUB
-
- '===========================================================================
- SUB open10 STATIC
- r = 2000
- REDIM a%(r): REDIM B%(r): REDIM c%(r): REDIM d%(r): REDIM e%(r)
- REDIM F%(r): REDIM G%(r): REDIM h%(r): REDIM i%(r): REDIM J%(r)
- pause = 64
-
-
-
- '-------------------------------------------------
- CALL OpenW(2, &H1, VARSEG(a%(1)), 1, 1, 15, 20)
- FOR x = 1 TO pause: NEXT
- CALL OpenW(2, &H2, VARSEG(B%(1)), 2, 4, 16, 24)
- FOR x = 1 TO pause: NEXT
- CALL OpenW(2, &H3, VARSEG(c%(1)), 3, 8, 17, 28)
- FOR x = 1 TO pause: NEXT
- CALL OpenW(2, &H40, VARSEG(d%(1)), 4, 12, 18, 32)
- FOR x = 1 TO pause: NEXT
- CALL OpenW(2, &H50, VARSEG(e%(1)), 5, 16, 19, 36)
- FOR x = 1 TO pause: NEXT
- CALL OpenW(2, &H60, VARSEG(F%(1)), 6, 20, 20, 40)
- FOR x = 1 TO pause: NEXT
- CALL OpenW(2, &H70, VARSEG(G%(1)), 7, 24, 21, 44)
- FOR x = 1 TO pause: NEXT
- CALL OpenW(2, &H10, VARSEG(h%(1)), 8, 28, 22, 48)
- FOR x = 1 TO pause: NEXT
- CALL OpenW(2, &H20, VARSEG(i%(1)), 9, 32, 23, 52)
- FOR x = 1 TO pause: NEXT
- CALL OpenW(2, &H30, VARSEG(J%(1)), 10, 36, 24, 56)
- FOR x = 1 TO 200: NEXT
-
- FOR x = 1 TO 10:
- CALL CloseLastW:
- FOR xx = 1 TO 50: NEXT
- NEXT
-
- ERASE a%: ERASE B%: ERASE c%: ERASE d%: ERASE e%: ERASE F%:
- ERASE G%: ERASE h%: ERASE i%: ERASE J%:
- END SUB
-
- REM $STATIC
- SUB pages STATIC
- '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
- CALL OpenW(2, &H77, 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
- Printt "Viewing page ", 4, 1, 1: PrntS x:
- CALL k: NEXT
-
- SCREEN , , 0, 0: SetViewPage (0)
- END SUB
-
- SUB PrintxDemo STATIC
- 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$
- 'print a description of each call
- 'call kls:kolor
- ' IF px = 1 THEN
-
- '---------------------------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
- CALL OpenW(2, 7, 0, 4, 10, 16, 66)
- Printt "Next string to print is", 7, 18, 1
- IF px = 1 THEN Printt "Call to PrintW", 7, 4, 30
- IF px = 2 THEN Printt "Call to PrintW $ + chr$(13)", 7, 4, 30
- IF px = 3 THEN Printt "Call to PrintW $ + chr$(10)", 7, 4, 30
-
-
- '---------------------print 13 strings, each a different color --------------
- Lokate 1, 1: 'top left of the window
- attr% = 0: 'init val of color to print strings
-
- x = 1:
- PDemoLoop: IF x = 16 GOTO PDemoD: '
- attr% = attr% + &H10: IF attr% = &H80 THEN attr% = &H10
-
- '-------------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 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
-
- SUB sp
- '$DYNAMIC
- EXIT SUB: 'doesn't work yet
- Kolor 2, 0: KLS
-
- 'dimension and initialize an array
- MinR = 1: MaxR = 10: MinC = 1: MaxC = 10
- REDIM ar(MinR TO MaxR, MinC TO MaxC) AS SINGLE
- FOR x = 1 TO 10: FOR y = 1 TO 10: ar(x, y) = x + y / 100: NEXT: NEXT
-
- 'print part of it as a spreadsheet
- Row = 1: Col = 1: 'initial cursor position
- ArraySegment = VARSEG(ar(1, 1)): ArrayOffset = VARPTR(ar(1, 1))
- Nrows = 10: Ncols = 10: 'r & c to print
- Rstep = 1: Cstep = 1
- FirstR = 1: FirstC = 1
- MaskSt$ = "#####.##"
- CALL SpreadSheet(Row, Col, ArraySegment, ArrayOffset, Nrows, Ncols, Rstep, Cstep, FirstR, FirstC, MaskSt$, MaxR, MaxC, MinR, MinC)
- 'this prints about 7 times faster that basic
-
- END SUB
-
- REM $STATIC
- SUB testpattern
- Kolor 7, 0
- DEF SEG = 0: c = PEEK(&H44A) + PEEK(&H44B) * 256:
- r = PEEK(&H484) + 1
- Lokate 1, 1
- FOR x = 1 TO r: FOR y = 10 TO c STEP 10
- PrntUsingS "#######.##", x + y / 100
- NEXT: NEXT
- END SUB
-
- SUB testscroll
- '==================================================================
- CALL testpattern
- CALL k
- scrollu 48, 2, 3, 20, 12, 60
- CALL k
- CALL testpattern
- CALL k
- scrolld 48, 2, 3, 20, 12, 60
- CALL k
- CALL testpattern
- CALL k
- scrollL 48, 2, 3, 20, 12, 60
- CALL k
- CALL testpattern
- CALL k
- scrollr 48, 2, 3, 20, 12, 60
- CALL k
-
- END SUB
-
- SUB TextMode (rows, columns) STATIC
- '$DYNAMIC
- SHARED mode$()
- SHARED SkipCheck: 'shared with 'Fill'
- IF mode$(1, 1) = "" THEN GOSUB InitTextMode
- '------------------------------------------------------------------------
- ' This sub should be entirely self-contained except for these two lines
- ' in the main part of the program:
- ' Rem $INCLUDE:'W30.DEC'
- ' REDIM Mode$(14, 5)
- 'so it can be copied as is into another program. Call with the desired
- 'number of rows and columns to be displayed. If it is not a valid mode,
- 'a window will pop up showing the available modes. This was written on
- 'a Magnavox VGA, I'm not sure all cards have all these modes.
- '------------------------------------------------------------------------
-
- 'see if row & column define a valid mode
- h = 0: FOR x = 1 TO 13
- IF VAL(mode$(x, 1)) = rows AND VAL(mode$(x, 2)) = columns THEN h = x
- NEXT:
- IF h <> 0 THEN GOSUB CallInt10: EXIT SUB
- '------------------------------------------------------------------------
-
- 'Save the part of the screen containing the main menu
- REDIM tmp(1 TO 2000) AS INTEGER
- saveW VARSEG(tmp(1)), 1, 1, 25, 80
-
- 'initialize data
- up$ = CHR$(0) + CHR$(72): down$ = CHR$(0) + CHR$(80)
- c1 = 3: c2 = 6: Kolor c1, c2: 'window colors
- TR = 8: LC = 45: BR = TR + 14: n = 13: 'window location & size
-
- '------------------------------------------------------------------------
- StartTextMode:
-
- 'Print a help menu
- OpenW 3, c2, 0, 3, 4, 9, 30: Lokate 1, 1: Kolor c1, c2
- PrntW CHR$(25) + " " + CHR$(26) + " Select display" + CHR$(13)
- PrntW "<Enter> Change Display" + CHR$(13)
- PrntW "<Esc> Exit" + CHR$(13)
- PrntW "y/n Count on/off" + CHR$(13)
- PrntW CHR$(13)
- '------------------------------------------------------------------------
- 'find # rows and columns being displayed
- DEF SEG = 0: c = PEEK(&H44A) + PEEK(&H44B) * 256: r = PEEK(&H484) + 1
- mode = 0: FOR x = 1 TO 13
- IF VAL(mode$(x, 1)) = r AND VAL(mode$(x, 2)) = c THEN mode = x
- NEXT: h = mode
-
- '------------------------------------------------------------------------
- 'could it be a configuration I don't have?
- IF mode = 0 THEN
- BR = BR + 1: mode$(14, 1) = STR$(r):
- mode$(14, 2) = STR$(c)
- n = n + 1: 'add 1 more line to the window
- mode = 14: h = 14
- END IF
- CurrentMode = mode
-
- '------------------------------------------------------------------------
- 'Print the possible modes in a window
- Kolor c1, c2
- OpenW 1, &H6B, 0, TR, LC, BR, LC + 12: 'draw a box, don't save
- Lokate 0, 0: FOR x = 1 TO n
- PrntW " " + mode$(x, 1): PrntW " x ": PrntW mode$(x, 2) + CHR$(10)
- NEXT
-
- '-------------------------------------------------------------------------
- highlight:
- IF mode < 1 THEN mode = n ELSE IF mode > n THEN mode = 1
- Lokate TR + h, 1: Kolor c1, c2: 'un-highlight
- PrntW " " + mode$(h, 1): PrntW " x ": PrntW mode$(h, 2) + CHR$(10)
- h = mode
- Lokate TR + h, 1: Kolor c2, c1: 'highlight
- PrntW " " + mode$(h, 1): PrntW " x ": PrntW mode$(h, 2) + CHR$(10)
-
- '-------------------------------------------------------------------------
- TL:
- CALL k
- IF i$ = up$ THEN mode = mode - 1: GOTO highlight
- IF i$ = down$ THEN mode = mode + 1: GOTO highlight
- IF i$ = CHR$(13) GOTO ChangeMode
- IF LCASE$(i$) = "y" THEN SkipCheck = 0: CurrentMode = 0: GOTO ChangeMode
- IF LCASE$(i$) = "n" THEN SkipCheck = 1: CurrentMode = 0: GOTO ChangeMode
- IF i$ = CHR$(27) GOTO ExitTextMode
- GOTO TL
- 'mode is display just selected by the scroll bar
- 'h is highlighted bar. h trails mode to unhighlight the last bar
- 'currentmode is how the display is now
-
- '------------------------------------------------------------------------
- ChangeMode:
- IF mode = 14 GOTO StartTextMode: 'don't support current mode
- IF mode = CurrentMode GOTO StartTextMode: 'no change
- GOSUB CallInt10
- closew VARSEG(tmp(1)), 1, 1, 25, 80: 'Restore the main menu
-
- '------------------------------------------------------------------------
- 'print a 'ruler' to check # of rows & columns
- IF SkipCheck = 0 THEN
- Kolor 4, 0: Lokate 1, 1
- FOR x = 10 TO VAL(mode$(mode, 2)) STEP 10
- PrntUsingS "##########", x: NEXT
- FOR x = 1 TO VAL(mode$(mode, 1)): Lokate x, 1:
- PrntUsingS "#####", x: NEXT
- END IF
- GOTO StartTextMode
- '------------------------------------------------------------------------
- ExitTextMode:
- closew VARSEG(tmp(1)), 1, 1, 25, 80: 'restore main menu
- EXIT SUB
- '=====================================
- CallInt10:
-
- 'set number of scan lines: al= 0/200 1/350 2/400 3/480
- ax% = VAL("&h0" + (mode$(h, 3))): bx% = &H30
- IF ax% <> 0 THEN
- CALL Int10(ax%, bx%, cx%, dx%)
- IF ax% \ 256 <> &H12 THEN e$ = "L32ege": PLAY e$: GOTO ExitTextMode
- END IF
-
- 'Set text mode
- ax% = 3: bx% = 0
- CALL Int10(ax%, bx%, cx%, dx%)
-
- 'change to the extended mode
- ax% = VAL("&h0" + mode$(h, 4)): bx% = 0
- IF ax% <> 0 THEN CALL Int10(ax%, bx%, cx%, dx%)
-
- 'load a character set into the first font area
- ax% = VAL("&h0" + mode$(h, 5)): bx% = 0:
- IF ax% <> 0 THEN CALL Int10(ax%, bx%, cx%, dx%)
- RETURN
- '-------------------------------------------------------------------------
-
-
- InitTextMode:
- mode$(1, 1) = "25": 'lines
- mode$(1, 2) = "80": 'columns
- mode$(1, 3) = "1202": 'scan lines (skip if 0). BL = 30h
- 'always set text mode here AX = 3
- mode$(1, 4) = "0": 'extended mode (skip if 0)
- mode$(1, 5) = "1114": 'character set (skip if 0) BX = 0
-
- mode$(2, 1) = "25"
- mode$(2, 2) = "132"
- mode$(2, 3) = "1202"
- mode$(2, 4) = "17"
- mode$(2, 5) = "1114"
-
- mode$(3, 1) = "34"
- mode$(3, 2) = "80"
- mode$(3, 3) = "1203"
- mode$(3, 4) = "1111"
- mode$(3, 5) = "0"
-
- mode$(4, 1) = "37"
- mode$(4, 2) = "100"
- mode$(4, 3) = "1201"
- mode$(4, 4) = "1F"
- mode$(4, 5) = "1114"
-
- mode$(5, 1) = "34"
- mode$(5, 2) = "132"
- mode$(5, 3) = "1203"
- mode$(5, 4) = "17"
- mode$(5, 5) = "1111"
-
- mode$(6, 1) = "43"
- mode$(6, 2) = "80"
- mode$(6, 3) = "1201"
- mode$(6, 4) = "0"
- mode$(6, 5) = "1112"
-
- mode$(7, 1) = "42"
- mode$(7, 2) = "100"
- mode$(7, 3) = "0"
- mode$(7, 4) = "1F"
- mode$(7, 5) = "1111"
-
- mode$(8, 1) = "43"
- mode$(8, 2) = "132"
- mode$(8, 3) = "1201"
- mode$(8, 4) = "17"
- mode$(8, 5) = "1112"
-
- mode$(9, 1) = "50"
- mode$(9, 2) = "80"
- mode$(9, 3) = "1202"
- mode$(9, 4) = "0"
- mode$(9, 5) = "1112"
-
- mode$(10, 1) = "50"
- mode$(10, 2) = "132"
- mode$(10, 3) = "1202"
- mode$(10, 4) = "17"
- mode$(10, 5) = "1112"
-
- mode$(11, 1) = "60"
- mode$(11, 2) = "80"
- mode$(11, 3) = "1203"
- mode$(11, 4) = "0"
- mode$(11, 5) = "1112"
-
- mode$(12, 1) = "75"
- mode$(12, 2) = "100"
- mode$(12, 3) = "0"
- mode$(12, 4) = "1F"
- mode$(12, 5) = "1112"
-
- mode$(13, 1) = "60"
- mode$(13, 2) = "132"
- mode$(13, 3) = "1203"
- mode$(13, 4) = "17"
- mode$(13, 5) = "1112"
- RETURN
- END SUB
-
- '===========================================================================
- SUB train STATIC
-
- pause = 4: Kolor 2, 0: KLS
- LOCATE 1, 1: PRINT " f/faster s/slower esc/quit delay ="
- Lokate 1, 60: PrntUsingS "###", pause
- x$ = ".eiee[] o---o o---o o---o o---o o---o o---o eee[]e "
- 'run onto the screen
- FOR x = 1 TO LEN(x$)
- Printt MID$(x$, x, 1), 2, 10, 80
- CALL scrollL(&H7, 1, 10, 1, 10, 80)
- CALL scrolld(&H7, 1, 1, 5, 16, 5)
- CALL scrollr(7, 1, 16, 1, 16, 80)
- CALL scrollu(7, 1, 10, 80, 16, 80)
- NEXT
-
- 'run around until a keypress
- DO
- CALL scrollL(&H7, 1, 10, 1, 10, 80)
- CALL scrolld(&H7, 1, 1, 5, 16, 5)
- CALL scrollr(7, 1, 16, 1, 16, 80)
- CALL scrollu(&H7, 1, 10, 80, 16, 80)
- FOR y = 1 TO pause: NEXT
- i$ = INKEY$: IF i$ = CHR$(27) THEN EXIT DO
- IF i$ <> "" THEN GOSUB TrainKeyPress
- LOOP
-
- 'jump out if 132 column display
- DEF SEG = 0: IF PEEK(&H44A) <> 80 THEN EXIT SUB
-
- 'run off the screen
- xs = 16
- FOR x = 1 TO 250
- y = SCREEN(16, 79)
- IF y = 46 THEN xs = 15: x = 200
- CALL scrollL(&H7, 1, 10, 1, 10, 80)
- CALL scrolld(&H7, 1, 1, 5, 16, 5)
- CALL scrollr(7, 1, 16, 1, 16, 80)
- CALL scrollu(&H7, 1, 10, 80, xs, 80)
- NEXT
-
- EXIT SUB
- '-----------------------------------------------------------
- TrainKeyPress:
- IF i$ = "f" AND pause > 0 THEN dec pause
- IF i$ = "s" AND pause < 100 THEN inc pause
- Lokate 1, 60: PrntUsingS "###", pause
- 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.
-
- '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
- REDIM t(200) AS INTEGER
- OpenW 2, 2, 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 CReg(0 TO 15, 1 TO 3) AS INTEGER
- Red = 1: Green = 2: Blue = 3
- CReg(0, Red) = 0: CReg(0, Green) = 0: CReg(0, Blue) = 0
- CReg(1, Red) = 0: CReg(1, Green) = 0: CReg(1, Blue) = 42
- CReg(2, Red) = 0: CReg(2, Green) = 42: CReg(2, Blue) = 0
- CReg(3, Red) = 0: CReg(3, Green) = 42: CReg(3, Blue) = 42
-
- CReg(4, Red) = 42: CReg(4, Green) = 0: CReg(4, Blue) = 0
- CReg(5, Red) = 42: CReg(5, Green) = 0: CReg(5, Blue) = 42
- CReg(6, Red) = 42: CReg(6, Green) = 21: CReg(6, Blue) = 0
- 'Default values:
- CReg(7, Red) = 42: CReg(7, Green) = 42: CReg(7, Blue) = 42
- 'I usually change 7 so the DOS prompt is green
- CReg(7, Red) = 0: CReg(7, Green) = 63: CReg(7, Blue) = 0
-
- CReg(8, Red) = 21: CReg(8, Green) = 21: CReg(8, Blue) = 21
- CReg(9, Red) = 21: CReg(9, Green) = 21: CReg(9, Blue) = 63
- CReg(1, Red) = 21: CReg(10, Green) = 63: CReg(10, Blue) = 21
- CReg(11, Red) = 21: CReg(11, Green) = 63: CReg(11, Blue) = 63
-
- CReg(12, Red) = 63: CReg(12, Green) = 21: CReg(12, Blue) = 21
- CReg(13, Red) = 63: CReg(13, Green) = 21: CReg(13, Blue) = 63
- CReg(14, Red) = 63: CReg(14, Green) = 63: CReg(14, Blue) = 21
- CReg(15, Red) = 63: CReg(15, Green) = 63: CReg(15, 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
-
- FOR n = 0 TO 15
- 'set the palette register
- Int10 &H1000, PalReg(n) * 256 + n, 0, 0
-
- 'set the corresponding color register
- Int10 &H1010, n + 0, CReg(n, Green) * 256 + CReg(n, Blue), CReg(n, Red) * 256
- NEXT
-
- 'set the overscan register to zero
- Int10 &H1001, PalReg(16) * 256, 0, 0
-
-
- 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
-
-