home *** CD-ROM | disk | FTP | other *** search
- '*******************************LOADKYBD.BAS******************************
- 'More PEEK and POKES
- 'This program POKES a command into the keyboard type-ahead buffer so that you
- 'can execute a program -after- you exit a QuickBASIC program or EXIT
- 'and restart the QuickBASIC program with a batch file that restarts
- 'LOADKYBD.BAS.
- 'The SUB ClearKeyBoard ==really== clears the keyboard buffer
- 'not sure it is better than:
- 'WHILE INKEY$ <> "": WEND
- 'but the SUB ClearKeyBoard -erases- the keyboard buffer
- '
- 'ideas and code from Ethan Winer's book, an article by Phil Weber, &
- 'from QuickBASIC Bible examples on PEEK and POKE
- 'I just provided the glue code.
- '
- 'The executable file is made with Crescent's PDQ library to be tiny; the
- 'QuickBASIC program -looks- better but was 40K, LOAD.COM is less than 5K
- '
- '12/20/93
-
- DEFINT A-Z
- CONST False = 0, True = NOT False
-
- TYPE RegType
- AX AS INTEGER
- BX AS INTEGER
- CX AS INTEGER
- DX AS INTEGER
- BP AS INTEGER
- SI AS INTEGER
- DI AS INTEGER
- Flags AS INTEGER
- DS AS INTEGER
- ES AS INTEGER
- END TYPE
-
- DECLARE SUB SetBorder (ColrByte%)
- DECLARE SUB CursorBlock ()
- DECLARE SUB CursorNone ()
- DECLARE SUB ColorIt (Fgd%, Bkgd%)
- DECLARE SUB PokeColor (Address%, Colr%)
- DECLARE SUB BackScreen (Char%)
- DECLARE SUB Shadowbox2 (top%, Bottom%, wide%, BoxColr%, Fgd%, Bkgd%, ColorFlag%)
- DECLARE SUB Mono (Flag%)
- DECLARE SUB CursorOn2 ()
- DECLARE SUB CursorOff2 ()
- DECLARE SUB Buffer (Cmd$)
- DECLARE SUB ClearKeyBoard ()
- DECLARE SUB LocateIt (Row%, text$)
- DECLARE SUB INTERRUPT (intNum AS INTEGER, Reg AS RegType)
-
- 'executable code starts here
- DEF FnCenterit (text$) = 41 - (LEN(text$) \ 2)
- COLOR 15, 1
- CLS
- CALL CursorNone
- CALL SetBorder(4)
- CALL Mono(Flag)
-
- IF Flag THEN
- ColorFlag% = &H800 'if a mono screen this is where we
- 'must be to make the shadow with POKE
- ELSE
- ColorFlag% = &HB800 'where I usually am... in color
- END IF
-
- CALL BackScreen(178)
- 'STOP
- wide% = 60
- CALL Shadowbox2(2, 20, wide%, 4, 15, 4, ColorFlag%)
- 'STOP
- CALL ColorIt(14, 4)
- text$ = "Enter DOS command to run when this program EXITs"
- CALL LocateIt(4, text$)
- 'STOP
- text$ = "Command must not be more than 14 Characters"
- CALL LocateIt(6, text$)
-
- CALL ColorIt(13, 4)
- text$ = STRING$(wide% - 4, 196)
- CALL LocateIt(8, text$)
-
- text$ = " »»» Press {Enter} ─┘ when Finished Editing ««« "
- CALL ColorIt(11, 0)
- CALL LocateIt(18, text$)
-
- text$ = STRING$(14, 32)
- CALL ColorIt(7, 0)
- CALL LocateIt(12, text$)
-
- LOCATE 12, FnCenterit(text$)
- CALL CursorBlock
- CALL ClearKeyBoard
- INPUT "", Cmd$
- CALL CursorNone
- 'Cmd$ = "CLS" + CHR$(13) + "DIR/W"
- CALL Buffer(Cmd$)
- 'STOP
-
- SUB BackScreen (Char%)
- CLS
- FOR i = 1 TO 24
- PRINT STRING$(80, Char%);
- NEXT
- LOCATE 25, 1
- PRINT STRING$(80, Char%);
- END SUB
-
- 'from QuickBASIC Bible p 721
- SUB Buffer (Cmd$)
- Cmd$ = LEFT$(Cmd$, 14) + CHR$(13)
- length% = LEN(Cmd$)
- DEF SEG = &H40
- head% = &H1A
- tail% = &H1C
- start% = &H1E
- FOR i = 1 TO length%
- POKE start% + (i - 1) * 2, ASC(MID$(Cmd$, i, 1))
- NEXT
- POKE tail%, start% + (i - 1) * 2
- POKE head%, start%
- DEF SEG
-
- END SUB
-
- SUB ClearKeyBoard
-
- DEF SEG = 0
- Temp& = PEEK(&H41A) + (PEEK(&H41B) * 256&)
- head = Temp& AND &HFFFF& 'Clear keyboard buffer
- POKE &H41C, head AND 255 'by setting head ptr
- POKE &H41D, head \ 256 'equal to tail ptr.
-
- END SUB
-
- SUB ColorIt (Fgd%, Bkgd%)
- COLOR Fgd%, Bkgd%
- END SUB
-
- SUB CursorBlock
- LOCATE , , 1, 4, 7
- END SUB
-
- SUB CursorNone
- LOCATE , , 0
- END SUB
-
- SUB LocateIt (Row%, text$)
- LOCATE Row%, FnCenterit(text$)
- PRINT text$;
- END SUB
-
- SUB Mono (Flag%)
- IF PEEK(&H463) = &H4B THEN
- 'we got a monochrome screen
- Flag% = True
- ELSE
- 'we gots color
- Flag% = False
- END IF
- END SUB
-
- SUB PokeColor (Address%, Colr%)
- 'POKE Address%, Character%
- POKE Address% + 1, Colr%
- END SUB
-
- DEFSNG A-Z
- SUB SetBorder (ColrByte%) STATIC
- DIM Regs AS RegType
- Regs.AX = &H1001
- Regs.BX = ColrByte% * &H100
- CALL INTERRUPT(&H10, Regs)
- END SUB
-
- DEFINT A-Z
- SUB Shadowbox2 (top%, Bottom%, wide%, BoxColr%, Fgd%, Bkgd%, ColorFlag%)
- DEF SEG = ColorFlag%
- REDIM box$(3)
- box$(1) = "█"
-
- box$(2) = "▀"
- box$(3) = "▄"
-
-
- 'this sets the colors
- COLOR Fgd%, Bkgd%
- Left% = (80 - wide%) \ 2
- right% = Left% + wide%
- middle% = right% - Left%
- rows% = top%
-
- boxtop% = wide% - 1
-
- 'this prints the box and sets the background color of the box
- 'if you use a zero, you get a transparent box
- IF BoxColr% = 0 THEN GOTO MakeBox
- COLOR , BoxColr%
-
- FOR boxsize% = top% TO Bottom%
- LOCATE rows%, Left%, 0
- PRINT SPACE$(middle%);
- rows% = rows% + 1
- NEXT
-
- 'this prints the box outline
-
- MakeBox:
- LOCATE top%, Left%
- COLOR Fgd%, Bkgd%
- PRINT box$(1); STRING$(boxtop%, box$(2)); box$(1);
- FOR rows% = top% + 1 TO Bottom% - 1
- LOCATE rows%, Left%
- PRINT box$(1);
- LOCATE rows%, right%
- PRINT box$(1);
- NEXT rows%
- LOCATE Bottom%, Left%
- PRINT box$(1); STRING$(boxtop%, box$(3)); box$(1);
- 'STOP
-
- 'Now the shadow
-
- foregd = 7
- Backgd = 0
-
- 'use the simple color formula
- Colr% = foregd + (16 * Backgd)
- 'prints the bottom
- FOR i = 0 TO wide%
- 'from QuickBASIC Bible, p 715
- offset% = (Bottom%) * 160 + (Left% + i) * 2
- Character% = PEEK(offset%)
- CALL PokeColor(offset%, Colr%)
- NEXT i
- 'STOP
- 'prints the right side
- FOR i = top% TO Bottom%
- offset% = (i) * 160 + (right%) * 2
- Character% = PEEK(offset%)
- CALL PokeColor(offset%, Colr%)
- offset% = (i) * 160 + (right% + 1) * 2
- Character% = PEEK(offset%)
- CALL PokeColor(offset%, Colr%)
-
- NEXT
- 'STOP
- DEF SEG
- END SUB
-
-