Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

16 colors for background in MCGA BIOS text mode (AL = 03h)

MCGA supports 4-bits color depth, that is 16 colors. But when I try to print all of these colors, I get only first 8 of them and the rest 8 simply duplicate them as on the pic below. Can it be that I'm doing something wrong here or it is all because of DOSBox?

trying to get all the 16 colors

The code (MASM, under DOSBox 0.74):

TITLE   PROGRAM193
;----------------------------------------------------------
        .MODEL      SMALL
        .STACK      64
        .DATA           
;----------------------------------------------------------
        .CODE
MAIN    PROC    FAR
    MOV     AX, @DATA
    MOV     DS, AX

    MOV     AX, 0600h    ;AH = 06h (scroll up window)
    ; black (0)
    MOV     BH, 0Fh      ;0 (black) background, F (white) text
    MOV     CX, 0000h    ;upper line, left column
    MOV     DX, 004Fh    ;finishing line, right column
    INT     10h

    ; blue (1)
    MOV     BH, 1Fh
    MOV     CX, 0100h
    MOV     DX, 014Fh
    INT     10h

    ; green (2)
    MOV     BH, 2Fh
    MOV     CX, 0200h
    MOV     DX, 024Fh
    INT     10h

    ; cyan (3)
    MOV     BH, 3Fh
    MOV     CX, 0300h
    MOV     DX, 034Fh
    INT     10h

    ; red (4)
    MOV     BH, 4Fh
    MOV     CX, 0400h
    MOV     DX, 044Fh
    INT     10h

    ; magenta (5)
    MOV     BH, 5Fh
    MOV     CX, 0500h
    MOV     DX, 054Fh
    INT     10h

    ; brown (6)
    MOV     BH, 6Fh
    MOV     CX, 0600h
    MOV     DX, 064Fh
    INT     10h

    ; light gray (7)
    MOV     BH, 7Fh
    MOV     CX, 0700h
    MOV     DX, 074Fh
    INT     10h

    ;  -------------------------------
    ; | The problem starts up here... |
    ;  -------------------------------
    ; dark gray (8)
    MOV     BH, 8Fh
    MOV     CX, 0800h
    MOV     DX, 084Fh
    INT     10h

    ; light blue (9)
    MOV     BH, 9Fh
    MOV     CX, 0900h
    MOV     DX, 094Fh
    INT     10h

    ; light green (A)
    MOV     BH, 0AFh
    MOV     CX, 0A00h
    MOV     DX, 0A4Fh
    INT     10h

    ; light cyan (B)
    MOV     BH, 0BFh
    MOV     CX, 0B00h
    MOV     DX, 0B4Fh
    INT     10h

    ; light red (C)
    MOV     BH, 0CFh
    MOV     CX, 0C00h
    MOV     DX, 0C4Fh
    INT     10h

    ; light magenta (D)
    MOV     BH, 0DFh
    MOV     CX, 0D00h
    MOV     DX, 0D4Fh
    INT     10h

    ; yellow (E)
    MOV     BH, 0EFh                        
    MOV     CX, 0E00h
    MOV     DX, 0E4Fh
    INT     10h

    ; white (F)
    MOV     BH, 0F1h
    MOV     CX, 0F00h
    MOV     DX, 0F4Fh
    INT     10h

    MOV     AX, 4C00h
    INT         21h                         
MAIN    ENDP
        END     MAIN
like image 758
yulian Avatar asked Mar 01 '15 05:03

yulian


1 Answers

By default, there are 16 colors for text and only 8 colors for background.

There is a way to get all the 16 colors for background, which requires turning off the "blinking attribute".

Here is how it can be done:

MAIN    PROC    FAR
    MOV     AX, @DATA
    MOV     DS, AX


    ; turn-off blinking attribute
    MOV     AX, 1003h       
    MOV     BL, 00
    INT     10h


    MOV     AX, 0600h    ;AH = 06h (scroll up window)
    ; black (0)
    MOV     BH, 0Fh      ;0 (black) background, F (white) text
    MOV     CX, 0000h    ;upper line, left column
    MOV     DX, 004Fh    ;finishing line, right column
    INT     10h

    ; the rest of the magic...

The result is shown below:

enter image description here

like image 147
yulian Avatar answered Sep 24 '22 16:09

yulian