    	SUBROUTINE COLORS( IC )
C
C	PROGRAMMER: R.S. ZHOU		FEB-1986
C
C	THIS ROUTINE IMPLEMENTS THE STANDARD ANSI GRAPHICS RENDITIONS
C
C	IC=#*, # = background color 1 to 7, 0 = unchanged.
C	       * = character color  1 to 7, 0 = unchanged.
C	IC=0 means 17: white characters on black background.
C
C	If IC<0, reverse video is on, otherwise off (if not unchanged colors).
C	If *=9 blink on (e.g. IC=9 just blinking)
C	If #=9 underscore on (.e.g. IC=90 just underscore)
C	If #=8 bold display on (.e.g. IC=80 just bold)
C
    	BYTE TEXT(6)
    	DATA TEXT / 0, 27, 91, 0, 0, 109 /
C
C   TEXT = <ESC>[00m
C
    	IC0 = IC
     	IF( IC0.EQ.0 ) THEN
     	    IC0 = 1
     	    IC1 = 7
     	ELSE
    	    IR = 0
    	    IF( IC0.LT.0 ) IR = 1
    	    IC1 = IABS(IC0)
     	    IC0 = IC1/10
    	    IC1 = IC1 - IC0*10
    	ENDIF

    	IF( IC0.LT.8 .AND. IC1.LT.8 ) THEN
    	    TEXT(4) = 48
    	    TEXT(5) = 48
     	    WRITE(6,1) TEXT  		!ALL ATTRIBUTES OFF
    	ENDIF
     	IF( IR.EQ.1 ) THEN
    	    TEXT(4) = 48
    	    TEXT(5) = 55		!REVERSE VIDEO ON
     	    WRITE(6,1) TEXT
     	ENDIF

     	IF( IC0.NE.0 ) THEN
     	    IF( IC0.EQ.8 ) THEN
    	    	TEXT(4) = 0
    	    	TEXT(5) = 49		!BOLD PRINT ON
     	    	WRITE(6,1) TEXT
     	    ENDIF
     	    IF( IC0.EQ.9 ) THEN
    	    	TEXT(4) = 0
    	    	TEXT(5) = 52		!UNDERSCORE ON
     	    	WRITE(6,1) TEXT
     	    ENDIF
C    	    IF( IC0.LT.8 ) THEN
C    	    	TEXT(4) = 52
C    	    	TEXT(5) = 48 + IC0	!BACKGROUND COLOR
C     	    	WRITE(6,1) TEXT
C     	    ENDIF
     	ENDIF

     	IF( IC1.NE.0 ) THEN
     	    IF( IC1.EQ.9 ) THEN
    	    	TEXT(4) = 0
    	    	TEXT(5) = 53		!BLINK ON
     	    	WRITE(6,1) TEXT
C     	    ELSE
C    	    	TEXT(4) = 51
C    	    	TEXT(5) = 48 + IC1	!CHARACTER COLOR
C     	    	WRITE(6,1) TEXT
     	    ENDIF
     	ENDIF
1	FORMAT(6A1$)
    	RETURN
     	END
