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

wirehaze git hosting

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