]> wirehaze git hosting - BOS.git/blob - kernel/krl_incs/vga.inc

wirehaze git hosting

Merge commit 'dba047e616f303ce818ba9ac7fb9f8a18a3717d3'
[BOS.git] / kernel / krl_incs / vga.inc
1 ;----------------------------------------------------------;
2 ; BOS 0.04 Christoffer Bubach, 2004-2005. ;
3 ;----------------------------------------------------------;
4 ; ;
5 ; VGA functions. Change video mode etc. ;
6 ; ;
7 ;----------------------------------------------------------;
8
9
10 ;-------------------;
11 ; VGA palettes ;
12 ;-------------------;
13
14 palette256 db 00, 00, 00, 00, 10, 41, 12, 28, 18, 02, 43, 22, 35
15 db 19, 09, 58, 00, 00, 57, 35, 12, 43, 43, 47, 24, 24
16 db 28, 20, 24, 60, 10, 60, 15, 31, 47, 63, 62, 56, 20
17 db 60, 56, 22, 63, 61, 36, 63, 63, 63, 00, 00, 00, 05
18 db 05, 05, 08, 08, 08, 11, 11, 11, 14, 14, 14, 17, 17
19 db 17, 20, 20, 20, 24, 24, 24, 28, 28, 28, 32, 32, 32
20 db 36, 36, 36, 40, 40, 40, 45, 45, 45, 50, 50, 50, 56
21 db 56, 56, 63, 63, 63, 13, 12, 15, 15, 16, 22, 17, 20
22 db 29, 19, 24, 36, 21, 28, 43, 23, 31, 50, 25, 34, 57
23 db 26, 42, 63, 00, 15, 02, 01, 22, 04, 02, 29, 06, 03
24 db 36, 08, 04, 43, 10, 05, 50, 12, 06, 57, 14, 20, 63
25 db 40, 18, 06, 07, 25, 12, 11, 33, 17, 14, 40, 23, 18
26 db 48, 28, 21, 55, 34, 25, 62, 39, 27, 63, 48, 36, 15
27 db 03, 02, 22, 06, 04, 29, 09, 06, 36, 12, 08, 43, 15
28 db 10, 50, 18, 12, 57, 21, 14, 63, 28, 20, 15, 00, 00
29 db 22, 07, 00, 29, 15, 00, 36, 23, 00, 43, 31, 00, 50
30 db 39, 00, 57, 47, 00, 63, 55, 00, 15, 05, 03, 22, 11
31 db 07, 29, 17, 11, 36, 23, 15, 43, 29, 19, 50, 35, 23
32 db 57, 41, 27, 63, 53, 34, 28, 14, 12, 33, 20, 14, 38
33 db 26, 16, 43, 32, 18, 48, 38, 20, 53, 44, 22, 58, 50
34 db 24, 63, 56, 30, 05, 05, 06, 10, 10, 13, 15, 15, 20
35 db 20, 20, 27, 25, 25, 34, 30, 30, 41, 35, 35, 48, 44
36 db 44, 63, 03, 06, 05, 05, 11, 09, 07, 16, 13, 09, 21
37 db 17, 11, 26, 21, 13, 31, 25, 15, 36, 29, 20, 48, 38
38 db 06, 06, 07, 13, 13, 15, 20, 20, 23, 27, 27, 31, 34
39 db 34, 39, 41, 41, 47, 48, 48, 55, 57, 57, 63, 06, 15
40 db 04, 12, 22, 08, 18, 29, 12, 24, 36, 16, 30, 43, 20
41 db 36, 50, 24, 42, 57, 28, 54, 63, 35, 15, 10, 10, 22
42 db 16, 16, 29, 21, 21, 36, 27, 27, 43, 32, 32, 50, 38
43 db 38, 57, 43, 43, 63, 54, 54, 15, 15, 06, 22, 22, 12
44 db 29, 29, 18, 36, 36, 24, 43, 43, 30, 50, 50, 36, 57
45 db 57, 42, 63, 63, 54, 02, 04, 14, 06, 12, 21, 10, 20
46 db 28, 14, 28, 35, 18, 36, 42, 22, 44, 49, 26, 52, 56
47 db 36, 63, 63, 18, 04, 14, 24, 08, 21, 31, 12, 28, 37
48 db 16, 35, 44, 20, 42, 50, 24, 49, 57, 28, 56, 63, 38
49 db 63, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
50 db 00, 00, 00, 00, 00, 00, 00, 00, 00, 53, 44, 22, 09
51 db 08, 12, 16, 14, 16, 22, 21, 20, 29, 27, 24, 35, 34
52 db 28, 42, 40, 32, 48, 47, 36, 57, 56, 43, 08, 12, 16
53 db 14, 16, 22, 21, 20, 29, 27, 24, 35, 34, 28, 42, 40
54 db 32, 48, 47, 36, 57, 56, 43, 63, 13, 09, 11, 21, 16
55 db 15, 27, 22, 18, 36, 29, 22, 42, 35, 25, 51, 42, 29
56 db 57, 48, 32, 63, 56, 39, 06, 14, 09, 12, 21, 14, 18
57 db 27, 22, 24, 33, 28, 30, 39, 36, 36, 46, 42, 42, 52
58 db 47, 50, 59, 53, 00, 00, 00, 00, 00, 00, 00, 00, 00
59 db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
60 db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
61 db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
62 db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
63 db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
64 db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
65 db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
66 db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
67 db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
68 db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
69 db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
70 db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
71 db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
72 db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
73 db 00
74
75
76 ;---------------------------------;
77 ; sets the screen to mode 0x03 ;
78 ;---------------------------------;
79 set_mode_0x03:
80 push eax
81
82 ;mov ax, 0x0003 ; "realmode ax", move to
83 ;shl eax, 16 ; the high part of eax
84 ;mov ax, 0x77 ; os function number for ints
85 ;int 0x32
86
87 ;mov eax, 0x00030077 ; or it could look like this.
88
89 mov eax, 0x00030000
90 mov ebx, 0x00100000 ; int no. in high part and
91 call rmode_int ; realmode bx in low part
92
93 pop eax
94 ret
95
96
97 ;---------------------------------;
98 ; sets the screen to mode 0x13 ;
99 ;---------------------------------;
100 set_mode_0x13:
101 push eax
102 push ebx
103
104 mov eax, 0x00130000 ; realmode ax in high part
105 mov ebx, 0x00100000 ; int no. in high part and
106 call rmode_int ; realmode bx in low part
107
108 mov esi, palette256
109 call set_palette256
110
111 pop ebx
112 pop eax
113 ret
114
115
116 ;------------------------------------;
117 ; put a pixel at x, y with color ;
118 ; used only in mode 0x13 ;
119 ; ;
120 ; input: bx = x ;
121 ; cx = y ;
122 ; al = color ;
123 ; ;
124 ; output: none. ;
125 ;------------------------------------;
126 put_0x13_pixel:
127 push ax
128 push bx
129 push cx
130 push edi
131
132 mov edi, 0xa0000 ; directly to mem
133 add di, bx
134 mov bx, cx
135 shl cx, 8
136 shl bx, 6
137 add cx, bx
138 add di, cx
139 stosb
140
141 pop edi
142 pop cx
143 pop bx
144 pop ax
145 ret
146
147
148 ;-----------------------------------------------------;
149 ; put a sprite at x, y. only for mode 0x13 ;
150 ; ;
151 ; input: ax = x, bx = y, cx = width, dx = height ;
152 ; esi = pointer to sprite ;
153 ; ;
154 ; output: none. ;
155 ;-----------------------------------------------------;
156 put_0x13_sprite:
157 pushad ; this was a
158 .row_loop: ; nightmare to write.
159 dec dx ; guess how many times
160 push cx ; i got lost in the push
161 push ax ; and pops here.. ;)
162 .col_loop: ; not to mention what
163 dec cx ; time it was when i wrote
164 push ax ; it.. :P
165 push bx
166 push cx
167 mov cx, bx
168 mov bx, ax
169 lodsb
170 call put_0x13_pixel
171 pop cx
172 pop bx
173 pop ax
174 inc ax
175 cmp cx, 0
176 jne .col_loop
177 pop ax
178 pop cx
179 inc bx
180 cmp dx, 0
181 jne .row_loop
182 popad
183 ret
184
185
186 ;---------------------------------------------;
187 ; sets the palette (256 colors) ;
188 ; ;
189 ; input: esi = palette. ;
190 ; output: none. ;
191 ;---------------------------------------------;
192 set_palette256:
193 push ax
194 push cx
195 push dx
196
197 xor cx, cx
198 .l1:
199 mov dx, 0x03C8
200 mov al, cl ; color no. = loop no.
201 out dx, al
202 inc dx ; port 0x3C9
203 mov al, byte [esi] ; red
204 out dx, al
205 inc esi
206 mov al, byte [esi] ; green
207 out dx, al
208 inc esi
209 mov al, byte [esi] ; blue
210 out dx, al
211 inc esi
212
213 inc cx
214 cmp cx, 256
215 jl .l1
216
217 pop dx
218 pop cx
219 pop ax
220 ret
221