3dgfx code, untested
[metatoy] / src / vga_s.asm
1         section .text
2         bits 32
3
4         global vga_setpal
5 vga_setpal:
6         mov ecx, [esp + 8]
7         test ecx, ecx
8         jz .done
9         push ebp
10         mov ebp, esp
11         push ebx
12         mov dx, 3c8h
13         mov eax, [ebp + 8]
14         out dx, al
15         inc dx
16         mov ebx, [ebp + 16]
17 .loop:  mov al, [ebx]
18         shr al, 2
19         out dx, al
20         mov al, [ebx + 1]
21         shr al, 2
22         out dx, al
23         mov al, [ebx + 2]
24         shr al, 2
25         out dx, al
26         add ebx, 3
27         dec ecx
28         jnz .loop
29         pop ebx
30         pop ebp
31 .done:  ret
32
33
34         global vga_setpalent
35 vga_setpalent:
36         mov dx, 3c8h
37         mov eax, [esp + 4]
38         out dx, al
39         inc dx
40         mov eax, [esp + 8]
41         shr eax, 2
42         out dx, al
43         mov eax, [esp + 12]
44         shr eax, 2
45         out dx, al
46         mov eax, [esp + 16]
47         shr eax, 2
48         out dx, al
49         ret
50
51 ; vi:set ts=8 sts=8 sw=8 ft=nasm: