replaced the first 64 colors of the palette with grayscale
authorEleni Maria Stea <estea@igalia.com>
Tue, 5 Jan 2021 13:19:31 +0000 (15:19 +0200)
committerEleni Maria Stea <estea@igalia.com>
Tue, 5 Jan 2021 13:19:31 +0000 (15:19 +0200)
bb.asm

diff --git a/bb.asm b/bb.asm
index 397bb30..3f4bcd1 100644 (file)
--- a/bb.asm
+++ b/bb.asm
@@ -126,7 +126,22 @@ sector_2:
        cmp cx, 200
        jnz .y_loop
 
        cmp cx, 200
        jnz .y_loop
 
-; fix palette (256 colors)
-       
+; setup grayscale palette (64 first colors because ramdac uses 6 bits / color so 2^6)
+; ram dac (digital to analog converter) tis vga
+; in a ^ register which index we want to write
+; 3 writes in another ramdac register (data)
+; ramdac feature: when you need to set a palette
+       mov al, 0               ; first index
+       mov dx, 3c8h    ; ramdac index registe
+       out dx, al              ; because io port (address) > 255
+       inc dx                  ; ramdac data register: 3c9h
+.pal_loop:
+       out dx, al              ; r
+       out dx, al              ; g
+       out dx, al              ; b
+       inc al
+       test al, 3fh    ; test with 3fh to keep the lowest 6 bits of al
+       jnz .pal_loop
+
 .inf_loop:
        jmp .inf_loop
 .inf_loop:
        jmp .inf_loop