; Written by Resistor. This program simply changes all the character colors 
; on your screen by modifying the character attributes in the video segment.
; Have fun with this. I found it amusing to install this program as a macro
; into DOS, thereby replacing any internal or external commands that DOS 
; offered. Example: DOSKEY cls = c:\...\colors.com. You can do this to dir 
; and other commands. Like I said have fun with this and if you have any
; questions about this program, just ask... I'm on Digital Decay.

        IDEAL
        MODEL   tiny

        DATASEG

color   DB      00000001b

        CODESEG
        ORG     100h

Start:
        mov     ah, 15                  ; Video mode function
        int     10h                     ; Call BIOS

        mov     dx, 2000                
        mov     bx, 0B800h              
        cmp     al, 3
        ja      @@99                    
        cmp     al, 1
        ja      @@10
        shr     dx, 1                   
@@10:
        mov     es, bx                  ; Set ES to screen segment
        mov     cx, dx                  ; Set bytes in screen
        xor     di, di                  ; Start at offset zero
@@20:
        mov     ax, [es:di]             ; AX <- [ES:DI]
        cmp     al, 20h                 ; Is AX a blank?
        jz      @@30                    ; Yes, goto next character
        call    ChangeColors
        mov     [es:di], ax             ; [ES:DI] <- AX
@@30:
        inc     di                      ; Point to the next character
        inc     di
        loop    @@20                    ; Loop until all characters modifed
@@99:
        mov     ah, 4Ch                 ; DOS function: Exit program
        mov     al, 0                   ; Return exit code value
        int     21h                     ; Call DOS. Terminate program

PROC    ChangeColors
        inc     [color]                 ; Add 00000001b to [color]     
        cmp     [color], 00001111b      ; Foreground color limit
        ja      Reset                   ; Reset color if out of limit
        mov     ah, [color]             ; Update character attribute
        ret
Reset:
        mov     [color], 00000001b      ; Reset color to blue
        ret
ENDP    ChangeColors

        END     START                   ; End of program / entry point
