Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- dBsee 4.6 - The Library - <b>dfpalette()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
dfPalette()
Sets the DOS palette
------------------------------------------------------------------------------
Syntax:

     dfPalette( <nReg>, [<nDAC>] ) --> nOldDAC

Parameters:

     <nReg>     Palette register (0<=nReg<=15)
     <nDAC>     DAC register where to read the values (0<=nDAC<=63)

Returns:

     <nOldDAC> Old DAC register.

Description:

     Associates a DAC register to a DOS palette. If the new register is not
     specified, the function simply returns the current register.

Example:

     #include "inkey.ch"
     
     * ############################
     PROCEDURE Main()
     * ############################
     LOCAL nReg    := 0
     LOCAL nNewVal := 0
     LOCAL nCount
     LOCAL aPalette := {}
     
     CLS
     
     FOR nCount := 0 TO 15  // Old Value
        AADD( aPalette, { nCount, dfPalette(nCount) })
        @ 3+nCount, 1 SAY ;
             "Register ("+ Str(nCount,2)+ ")  " +;
             "Value ("+ Str(dfPalette(nCount),2)+ ")"
     NEXT
     
     @  3, 28 SAY "######" COLOR  "N"
     @  4, 28 SAY "######" COLOR  "B"
     @  5, 28 SAY "######" COLOR  "G"
     @  6, 28 SAY "######" COLOR  "BG"
     @  7, 28 SAY "######" COLOR  "R"
     @  8, 28 SAY "######" COLOR  "RB"
     @  9, 28 SAY "######" COLOR  "GR"
     @ 10, 28 SAY "######" COLOR  "W"
     @ 11, 28 SAY "######" COLOR  "N+"
     @ 12, 28 SAY "######" COLOR  "B+"
     @ 13, 28 SAY "######" COLOR  "G+"
     @ 14, 28 SAY "######" COLOR  "BG+"
     @ 15, 28 SAY "######" COLOR  "R+"
     @ 16, 28 SAY "######" COLOR  "RB+"
     @ 17, 28 SAY "######" COLOR  "GR+"
     @ 18, 28 SAY "######" COLOR  "W+"
     
     WHILE Inkey(0) # K_ESC
        DO CASE
           CASE LastKey() == K_UP
                nReg++
                nNewVal := dfPalette( nReg )
           CASE LastKey() == K_DOWN
                nReg--
                nNewVal := dfPalette( nReg )
           CASE LastKey() == K_LEFT
                nNewVal--
           CASE LastKey() == K_RIGHT
                nNewVal++
        ENDCASE
        @ 0,0 SAY ;
              "Old Palette (Reg:" +Str(nReg,2) +") " +;
              "(Val:" +Str(dfPalette(nReg),2) +")"
        dfPalette( nReg, nNewVal )
        @ 1,0 SAY ;
              "New Palette (Reg:" +Str(nReg,2) +") " +;
              "(Val:" +Str(nNewVal,2)       +")"
     ENDDO
     
     // Restore Palette
     AEVAL( aPalette, {|a| dfPalette(a[1], a[2]) } )
     
     CLS
     
     RETURN

See also:

     dfDacSet()

See Also: dfDacSet()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson