Colors (in tiny intros)

Hey, for a good looking intro you need fancy colors!

Now I will show the most common color palettes grouped by functionality...

Grayscale palette

If you want do some shading the cheapest way is to use a grayscale pal. All three color component get the same value and we can set 64 different shades of gray.

Spongy by Mentor
Stainless Steel by Digimind
 MOV DX,3C8H
 OUT DX,AL
 INC DX
.1:
 OUT DX,AL
 OUT DX,AL
 OUT DX,AL
 INC AX
 JNZ .1
 MOV AX,0A000H
 MOV ES,AX
 MOV DX,3C9H
.1:
 OUT DX,AL
 OUT DX,AL
 OUT DX,AL
 INC AX
 LOOP .1

Stainless Steel will set exactly the same palette as Spongy on many VGA cards, but not all of them! If you don't set the color index register (#3c8h), then it's not sure, you will start with the first color.

Note: The standard VGA palette also has a grayscale gradient, but it's only 16 colors long.

One gradient palette

Similar to grayscale, the palette goes from dark to bright (or vice versa), but one or two color components get less intensity or a constant value.

LL by frag
Cloudy by TomCat
 MOV DX,3C9H
.1:
 SHR AL,1
 OUT DX,AL
 SHRD AX,CX,18
 OUT DX,AL
 OUT DX,AL
 LOOP .1
 MOV AL,13H
.1:
 INT 10H
 MOV CH,48
 IMUL DX,BX,64
 MOV AX,1010H
 INC BL
 JNZ .1

Two gradients palette

When you want two different things, for example a shaded object with a nice backgroud then the two gradient palette is the ideal choice.

Tube by baze
Seeing the light at the end of the tunnel by TC
 XOR CX,CX
.1:
 MOV DX,3C8H
 MOV AX,CX
;DEC AX
 OUT DX,AL
 INC DX
 SAR AL,1
 JS .2
 OUT DX,AL
 MUL AL
 SHR AX,6
 OUT DX,AL
.2:
 MOV AL,0
 OUT DX,AL
 JNS .3
 SUB AL,CL
 SHR AL,1
 OUT DX,AL
 SHR AL,1
 OUT DX,AL
.3:
 MOV BX,CX
 LOOP .1
 MOV AL,13H
.1:
 INT 10H
 IMUL DX,BX,7FH
 IMUL CX,BX,3FH
 IMUL AX,BX,30H
 MOV CL,AH
 INC BX
 MOV AX,1010H
 JNS .1

Four gradients palette

These palettes have so many possibilities. Good choice for multipart intros or nice to see so many kinds of colors at one scene too.

Anapurna by Dee
Gitter by frag
 SALC
 MOV DX,3C8H
 OUT DX,AL
 INC DX
.1:
 PUSH AX
 OUT DX,AL
 SHR AX,1
 OUT DX,AL
 SHR AX,1
 OUT DX,AL
 POP AX
 INC AX
 JNZ .1
 SALC
 MOV DX,3C8H
 OUT DX,AL
 INC DX
.1:
 MOV CL,3
.2:
 IMUL AX,BX,2
 SAR AX,CL
 OUT DX,AL
 LOOP .2
 INC BX
 JNZ .1

2D gradient palette

No doubt, the king of the palettes is Rrrola. His two dimensional palettes have the advantage that every color is different, no redundant colors like in 1D pals.

Symetrie by Rrrola
Atraktor by Rrrola
;4 bits black>red>yellow | 4 bits black>blue
 salc         ; al = 0
 mov dx,3C8h
 out dx,al
 inc dx
.1:
 or ax,0000111111000011b
 push ax      ; ax = rrrr1111 11bbbb11
 shr ax,10
 out dx,al
 mul al
 shr ax,6
 out dx,al    ; g = r*r
 pop ax
 out dx,al
 inc ax       ; b overflows to r
 jnz .1
;vintage palette: ttttoooo (teal * orange)
 mov dx,3c8h
 salc         ; al=0
 out dx,al
 inc dx
.1:
 or ax,1100001111000011b
 push ax
 out dx,al    ; R
 add al,ah
 shr al,1
 out dx,al    ; G
 add al,ah
 shr al,2
 out dx,al    ; B
 pop ax
 inc ax
 jnz .1

Multi gradient palette

These are not separated gradients in one pal, but connected ones. Where one gradient ends, the other starts.

The best-known multi grad pal is the fire palette. Black->red->yellow->white fade. Picard made a very interesting variant of it, but Pirx wrote the craziest pal code ever.

Zmora by Pirx
RTX ON by TomCat
 PUSH 0A000H
 POP ES
 CMPSW
.1:
 SALC
.2:
 STOSB
 CMPSW
 INC AX
 CMP AL,63
 JB .2
 PUSHA
.3:
 STOSB
 CMPSW
 LOOP .3
 POPA
 INC DI
 JNS .1
 MOV AX,1012H
 CWD
 INT 10H
 MOV BL,253
.1:
 IMUL DX,BX,6DH   ; setting the color palette
 IMUL CX,BX,3FH   ; from color black to brown
 IMUL AX,BX,30H
 CMP BL,105
 JB .2
 IMUL DX,BX,37H   ; then from brown to a bit
 IMUL CX,BX,50H   ; yellowish body color
 IMUL AX,BX,5CH
 ADD DH,016H
 ADD CH,0F9H
 ADD AH,0EDH
.2:
 MOV CL,AH
 MOV AX,1010H
 INT 10H
 DEC BX
 JNZ .1

Cyclic gradient palette

When the first color is the same as the last color then I call this palette cyclic. To set this kind of palette it's not important to set the first color firstly, just be sure you set every color. So you can omit writing the color index register.

This pal code works like iq's cosine palette. But keeping the code small, it uses another periodic function: the triangle wave instead of trigonometric functions. You can find here an interactive tool to design your own palette: gradients

HyperVibes by TomCat
2(56)unlimited by TomCat
 INC CX
 MOV DX,3C9H
.1:
 PUSH 77H
 PUSH 44H
 PUSH 22H
.2:
 POP AX
 ADD AX,CX
 CBW
 XOR AL,AH
 SHR AL,1
 OUT DX,AL
 CMP DI,SP
 JNE .2
 LOOP .1
 SALC
 MOV DX,3C8H
 OUT DX,AL
 INC DX
 MOV CX,SI
.1:
 MOV BX,SI
.2:
 MOV AL,[BX]
 SUB AL,CL
 CBW
 XOR AL,AH
 SHR AL,1
 OUT DX,AL
 INC BX
 JPO .2
 LOOP .1

No palette

Finaly there are two ways to use nice colors without a palette code.

  1. Pick some catchy colors from the standard VGA palette.
  2. Setup a true color video mode without palette.
Above by Sensenstahl
Colorful by TomCat
;640x480x32bits video mode:
; #13Fh - VMware
; #121h - ATI/AMD
; #112h - nVidia/Intel/DOSBox
 MOV BX,13FH
.1:
 MOV AX,4F02H
 INT 10H
 SHR BL,1
 INC BX
 INC BX
 CMP AH,BH
 JE .1

Note: the last 8 colors of the VGA palette is not definied. It can be black or white depending on the VGA card.