vbdpss.hlp (Table of Contents; Topic list)
Article Q50000, Example
                                                 Contents  Index  Back
─────────────────────────────────────────────────────────────────────────────
                           Knowledge Base Contents  Knowledge Base Index
 
 How to Save and Restore the VGA Palette Registers, Example
 
 Code Example
 ------------
 
 TYPE colortype           ' Structure to hold RGB color palette.
    red AS STRING * 1
    green AS STRING * 1
    blue AS STRING * 1
 END TYPE
 
 ' Use the following include file for Visual Basic 1.0 for MS-DOS:
 REM $INCLUDE: 'VBDOS.BI'
 
 DIM inregsx AS RegTypeX
 DIM outregsx AS RegTypeX
 DIM colorbuf(255) AS colortype
 SCREEN 13
 
 inregsx.ax = &H1017      ' BIOS interrupt to save palette registers.
 inregsx.bx = 0
 inregsx.cx = 256         ' Save all 256 color registers.
 inregsx.es = VARSEG(colorbuf(0))  ' Address of array holding palette.
 inregsx.dx = VARPTR(colorbuf(0))
 
 CALL INTERRUPTX(&H10, inregsx, outregsx)  ' Save palette registers.
 
 FOR i% = 2 TO 255      ' Display colorful pattern.
    LINE (i%, 10)-(i%, 199), i%
 NEXT
 
 LOCATE 1, 1
 COLOR 1
 PRINT "press any key to blank palette"
 WHILE INKEY$ = "": WEND
 
 FOR i% = 2 TO 255  ' Set all but first palette register to black.
         PALETTE i%, 0
 NEXT
 
 LOCATE 1, 1
 PRINT "press any key to restore palette"
 
 WHILE INKEY$ = "": WEND
 
 inregsx.ax = &H1012      ' BIOS interrupt to restore palette registers.
 inregsx.bx = 0
 inregsx.cx = 256         ' Restore all 256 color registers.
 inregsx.es = VARSEG(colorbuf(0))  ' Address of array holding palette.
 inregsx.dx = VARPTR(colorbuf(0))
 
 CALL INTERRUPTX(&H10, inregsx, outregsx)  ' Restore palette registers.