                NAME    SETCLR ; John Schnell (1986)

;               Modify individual register color for EGA board
;
;               FORMAT:
;                      CALL SETCLR(reg%,clr%) 

;               WHERE: reg% = register, position in color table.
;		       clr% = new color assigned to register table entry.
;
;		ERROR: If parameters are out of range, a -1 is returned in
;			the clr% parameter.  If it looks like the color is
;			not changing, look for -1 flag and check your ranges. 



PARMLST         STRUC
                                        ;
SAVE_BP         DW      ?               ; Save contents of BP onto stack
RET_OFF         DW      ?               ; Return address of calling program
RET_SEG         DW      ?               ; Return address of segment
CLR	        DW      ?               ; Color value
REG		DW	?		; Register value
PARMLST         ENDS

PARM_SIZE       EQU     OFFSET REG-RET_SEG



CODE SEGMENT BYTE PUBLIC 'CODE'
                ASSUME CS:CODE


SETCLR         PROC    FAR
                PUBLIC  SETCLR
                PUSH    BP              ;Contents of BP saved
                MOV     BP,SP           ;Set to parms

                MOV     SI,[BP].REG     ;Get REGISTER
                MOV     AX,[SI]         ;Read first arg.
		CMP	AX, 15		;Check high
		JG	ERROR		;Jump if over
		CMP	AX, 0		;Check low
		JL	ERROR		;Jump if under
		MOV	BL,AL		;Move REG 

                MOV     SI,[BP].CLR     ;Get COLOR
		MOV	AX,[SI]		;Read second arg.
                CMP	AX,63		;Check high
		JG	ERROR		;Jump if over
		CMP	AX,0		;Check low
		JL	ERROR		;Jump if under
		MOV	BH,AL		;Move COLOR

		MOV	AH,10H		;Select palette operation
		MOV	AL,0H		;Select set individual reg.
		INT	10H		;Do it
		JMP	EXIT

ERROR:
		MOV	AX,-1		;Load error flag 
		MOV	SI,[BP].CLR	;Locate Attribute
		MOV	[SI],AX		;Load -1 flag to signal an error

EXIT:
	        POP     BP
                RET     PARM_SIZE       ;Restore stack
SETCLR          ENDP
CODE            ENDS
                END
