home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / C-ASM_VI.ARJ / PROGASM.ZIP / PROG009.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-04-10  |  2.1 KB  |  49 lines

  1.  
  2. ;************************************************************************
  3. ; Write palette registers from a table                                  *
  4. ;              Set the palette registers to the values in 'table'.      *
  5. ;              The palette registers are contained in the               *
  6. ;              first 16 registers of the attribute controller.          *
  7. ;              Here the 16 registers are loaded using the values from   *
  8. ;              the parameter array.                                     *
  9. ;                                                                       *
  10. ; Entry:        [BP+4] - Pointer to register table (16 palette regs)    *
  11. ;                                                                       *
  12. ;************************************************************************
  13.  
  14.         PUBLIC  _Write_Palette
  15.  
  16. _Write_Palette  PROC NEAR
  17.         PUSH    BP
  18.         MOV     BP,SP
  19.         PUSH    SI
  20.         PUSH    ES
  21.  
  22.         XOR     AX,AX                   ;Get address of CRT controller
  23.         MOV     ES,AX                   ;From segment 0
  24.         MOV     DX,ES:[BIOS_CRT_Addr]
  25.         ADD     DX,6                    ;Compute address of Attrib Read reg
  26.         IN      AL,DX                   ;Reset Attribute flip-flop
  27.  
  28.         MOV     SI,[BP+4]               ;Get pointer to the parameter table
  29.         MOV     DX,03C0H                ;Address of Attribute controller
  30.         MOV     CX,16                   ;Number of values to load
  31.         XOR     AH,AH                   ;First index to load
  32.  
  33. PalLoop:MOV     AL,AH                   ;Fetch next index
  34.         OUT     DX,AL                   ;Select next index
  35.         LODSB                           ;Fetch next value from the table
  36.         OUT     DX,AL                   ;Load register with value
  37.         INC     AH                      ;Update index
  38.         LOOP    PalLoop
  39.  
  40.         MOV     AL,20H                  ;Must turn controller back ON
  41.         OUT     DX,AL
  42.  
  43.         POP     ES
  44.         POP     SI
  45.         MOV     SP,BP
  46.         POP     BP
  47.         RET
  48. _Write_Palette  ENDP
  49.