Rev 1700 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
750 | victor | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
||
4 | ;; Distributed under terms of the GNU General Public License ;; |
||
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
714 | Lrz | 7 | |
750 | victor | 8 | $Revision: 1703 $ |
9 | |||
714 | Lrz | 10 | struc VBE_VGAInfo { |
1703 | art_zh | 11 | .VESASignature dd ? ; char |
12 | .VESAVersion dw ? ; short |
||
13 | .OemStringPtr dd ? ; char * |
||
14 | .Capabilities dd ? ; ulong |
||
15 | .VideoModePtr dd ? ; ulong |
||
16 | .TotalMemory dw ? ; short |
||
714 | Lrz | 17 | ; VBE 2.0+ |
1703 | art_zh | 18 | .OemSoftwareRev db ? ; short |
19 | .OemVendorNamePtr dw ? ; char * |
||
20 | .OemProductNamePtr dw ? ; char * |
||
21 | .OemProductRevPtr dw ? ; char * |
||
22 | .reserved rb 222 ; char |
||
23 | .OemData rb 256 ; char |
||
714 | Lrz | 24 | } |
25 | |||
26 | struc VBE_ModeInfo { |
||
1703 | art_zh | 27 | .ModeAttributes dw ? ; short |
28 | .WinAAttributes db ? ; char |
||
29 | .WinBAttributes db ? ; char |
||
30 | .WinGranularity dw ? ; short |
||
31 | .WinSize dw ? ; short |
||
32 | .WinASegment dw ? ; ushort |
||
33 | .WinBSegment dw ? ; ushort |
||
34 | .WinFuncPtr dd ? ; void * |
||
35 | .BytesPerScanLine dw ? ; short |
||
36 | .XRes dw ? ; short |
||
37 | .YRes dw ? ; short |
||
38 | .XCharSize db ? ; char |
||
39 | .YCharSize db ? ; char |
||
40 | .NumberOfPlanes db ? ; char |
||
41 | .BitsPerPixel db ? ; char |
||
42 | .NumberOfBanks db ? ; char |
||
43 | .MemoryModel db ? ; char |
||
44 | .BankSize db ? ; char |
||
45 | .NumberOfImagePages db ? ; char |
||
46 | .res1 db ? ; char |
||
47 | .RedMaskSize db ? ; char |
||
48 | .RedFieldPosition db ? ; char |
||
49 | .GreenMaskSize db ? ; char |
||
50 | .GreenFieldPosition db ? ; char |
||
51 | .BlueMaskSize db ? ; char |
||
52 | .BlueFieldPosition db ? ; char |
||
53 | .RsvedMaskSize db ? ; char |
||
54 | .RsvedFieldPosition db ? ; char |
||
55 | .DirectColorModeInfo db ? ; char ; MISSED IN THIS TUTORIAL!! SEE ABOVE |
||
714 | Lrz | 56 | ; VBE 2.0+ |
1703 | art_zh | 57 | .PhysBasePtr dd ? ; ulong |
58 | .OffScreenMemOffset dd ? ; ulong |
||
59 | .OffScreenMemSize dw ? ; short |
||
714 | Lrz | 60 | ; VBE 3.0+ |
1703 | art_zh | 61 | .LinbytesPerScanLine dw ? ; short |
62 | .BankNumberOfImagePages db ? ; char |
||
63 | .LinNumberOfImagePages db ? ; char |
||
64 | .LinRedMaskSize db ? ; char |
||
65 | .LinRedFieldPosition db ? ; char |
||
66 | .LingreenMaskSize db ? ; char |
||
67 | .LinGreenFieldPosition db ? ; char |
||
68 | .LinBlueMaskSize db ? ; char |
||
69 | .LinBlueFieldPosition db ? ; char |
||
70 | .LinRsvdMaskSize db ? ; char |
||
71 | .LinRsvdFieldPosition db ? ; char |
||
72 | .MaxPixelClock dd ? ; ulong |
||
73 | .res2 rb 190 ; char |
||
714 | Lrz | 74 | } |
75 | |||
76 | virtual at $A000 |
||
77 | vi VBE_VGAInfo |
||
78 | mi VBE_ModeInfo |
||
79 | modes_table: |
||
80 | end virtual |
||
1703 | art_zh | 81 | cursor_pos dw 0 ;временное хранение курсора. |
714 | Lrz | 82 | home_cursor dw 0 ;current shows rows a table |
83 | end_cursor dw 0 ;end of position current shows rows a table |
||
834 | diamond | 84 | scroll_start dw 0 ;start position of scroll bar |
85 | scroll_end dw 0 ;end position of scroll bar |
||
714 | Lrz | 86 | long_v_table equ 9 ;long of visible video table |
731 | diamond | 87 | size_of_step equ 10 |
88 | scroll_area_size equ (long_v_table-2) |
||
714 | Lrz | 89 | int2str: |
1703 | art_zh | 90 | dec bl |
91 | jz @f |
||
92 | xor edx,edx |
||
93 | div ecx |
||
94 | push edx |
||
95 | call int2str |
||
96 | pop eax |
||
97 | @@: or al,0x30 |
||
98 | mov [ds:di],al |
||
99 | inc di |
||
100 | ret |
||
714 | Lrz | 101 | |
102 | int2strnz: |
||
1703 | art_zh | 103 | cmp eax,ecx |
104 | jb @f |
||
105 | xor edx,edx |
||
106 | div ecx |
||
107 | push edx |
||
108 | call int2strnz |
||
109 | pop eax |
||
110 | @@: or al,0x30 |
||
111 | mov [es:di],al |
||
112 | inc di |
||
113 | ret |
||
946 | lrz | 114 | |
714 | Lrz | 115 | |
116 | ;------------------------------------------------------- |
||
117 | print_vesa_info: |
||
1703 | art_zh | 118 | _setcursor 5,2 |
714 | Lrz | 119 | |
1703 | art_zh | 120 | mov [es:vi.VESASignature],'VBE2' |
121 | mov ax,0x4F00 |
||
122 | mov di,vi ;0xa000 |
||
123 | int 0x10 |
||
124 | or ah,ah |
||
125 | jz @f |
||
126 | mov [es:vi.VESASignature],'VESA' |
||
127 | mov ax,$4F00 |
||
128 | mov di,vi |
||
129 | int 0x10 |
||
130 | or ah,ah |
||
131 | jnz $ |
||
714 | Lrz | 132 | @@: |
1703 | art_zh | 133 | cmp [es:vi.VESASignature],'VESA' |
134 | jne $ |
||
135 | cmp [es:vi.VESAVersion],0x0100 |
||
136 | jb $ |
||
714 | Lrz | 137 | |
138 | .vesaok2: |
||
1703 | art_zh | 139 | mov ax,[es:vi.VESAVersion] |
140 | add ax,'00' |
||
714 | Lrz | 141 | |
1703 | art_zh | 142 | mov [s_vesa.ver], ah |
143 | mov [s_vesa.ver+2], al |
||
144 | mov si,s_vesa |
||
145 | call printplain |
||
714 | Lrz | 146 | |
1703 | art_zh | 147 | _setcursor 4,2 |
148 | mov si,word[es:vi.OemStringPtr] |
||
149 | mov di,si |
||
714 | Lrz | 150 | |
1703 | art_zh | 151 | push ds |
152 | mov ds,word[es:vi.OemStringPtr+2] |
||
153 | call printplain |
||
154 | pop ds |
||
714 | Lrz | 155 | |
1703 | art_zh | 156 | ret |
714 | Lrz | 157 | ;----------------------------------------------------------------------------- |
158 | |||
159 | calc_vmodes_table: |
||
1703 | art_zh | 160 | pushad |
714 | Lrz | 161 | |
162 | ; push 0 |
||
163 | ; pop es |
||
164 | |||
1703 | art_zh | 165 | lfs si, [es:vi.VideoModePtr] |
714 | Lrz | 166 | |
1703 | art_zh | 167 | mov bx,modes_table |
1700 | art_zh | 168 | |
714 | Lrz | 169 | .next_mode: |
1703 | art_zh | 170 | mov cx,word [fs:si] ; mode number |
171 | cmp cx,-1 |
||
172 | je .modes_ok.2 |
||
714 | Lrz | 173 | |
1703 | art_zh | 174 | mov ax,0x4F01 |
175 | mov di,mi |
||
176 | int 0x10 |
||
714 | Lrz | 177 | |
1703 | art_zh | 178 | or ah,ah |
179 | jnz .modes_ok.2 ;vesa_info.exit |
||
714 | Lrz | 180 | |
1703 | art_zh | 181 | test [es:mi.ModeAttributes],00000001b ;videomode support ? |
182 | jz @f |
||
183 | test [es:mi.ModeAttributes],00010000b ;picture ? |
||
184 | jz @f |
||
185 | test [es:mi.ModeAttributes],10000000b ;LFB ? |
||
186 | jz @f |
||
714 | Lrz | 187 | |
1703 | art_zh | 188 | cmp [es:mi.BitsPerPixel], 32 ;to show only 32 bpp videomodes |
189 | jb @f |
||
730 | diamond | 190 | |
947 | lrz | 191 | .l0: |
1703 | art_zh | 192 | cmp [es:mi.XRes],800 ; only 800x600 and higher |
193 | jb @f |
||
714 | Lrz | 194 | |
1703 | art_zh | 195 | mov ax,[es:mi.XRes] |
196 | mov [es:bx+0],ax ; +0[2] : resolution X |
||
197 | mov ax,[es:mi.YRes] |
||
198 | mov [es:bx+2],ax ; +2[2] : resolution Y |
||
199 | mov ax,[es:mi.ModeAttributes] |
||
200 | mov [es:bx+4],ax ; +4[2] : attributes |
||
714 | Lrz | 201 | |
1700 | art_zh | 202 | ;<< cmp [s_vesa.ver],'2' |
203 | ;<< jb .lp1 |
||
714 | Lrz | 204 | |
1703 | art_zh | 205 | or cx,0x4000 ; use LFB <<< ? |
206 | .lp1: mov [es:bx+6],cx ; +6 : mode number |
||
207 | movzx ax,byte [es:mi.BitsPerPixel] |
||
208 | mov word [es:bx+8],ax ; +8 : bits per pixel << ? |
||
209 | add bx,size_of_step ; size of record |
||
714 | Lrz | 210 | |
211 | @@: |
||
1703 | art_zh | 212 | add si,2 |
213 | jmp .next_mode |
||
714 | Lrz | 214 | |
215 | .modes_ok.2: |
||
216 | |||
1703 | art_zh | 217 | mov word[es:bx],-1 ;end video table |
218 | mov word[end_cursor],bx ;save end cursor position |
||
219 | popad |
||
220 | ret |
||
714 | Lrz | 221 | |
222 | check_first_parm: |
||
1703 | art_zh | 223 | mov si,word [preboot_graph] |
224 | test si,si |
||
225 | jnz .no_zero ;if no zero |
||
714 | Lrz | 226 | .zerro: |
227 | |||
1703 | art_zh | 228 | mov ax,1024 |
229 | mov bx,768 |
||
230 | mov si,modes_table |
||
231 | call .loops |
||
232 | test ax,ax |
||
233 | jz .ok_found_mode |
||
714 | Lrz | 234 | |
1703 | art_zh | 235 | mov si,modes_table |
236 | jmp .ok_found_mode |
||
714 | Lrz | 237 | |
746 | Lrz | 238 | .no_zero: |
749 | Lrz | 239 | mov bp,word [number_vm] |
1703 | art_zh | 240 | cmp bp,word [es:si+6] |
241 | jz .ok_found_mode |
||
242 | mov ax,word [x_save] |
||
243 | mov bx,word [y_save] |
||
244 | mov si,modes_table |
||
245 | call .loops |
||
246 | test ax,ax |
||
247 | jz .ok_found_mode |
||
746 | Lrz | 248 | |
749 | Lrz | 249 | mov si,modes_table |
746 | Lrz | 250 | |
714 | Lrz | 251 | .ok_found_mode: |
1703 | art_zh | 252 | mov word [home_cursor],si |
253 | mov word [preboot_graph],si |
||
254 | mov ax,si |
||
714 | Lrz | 255 | |
1703 | art_zh | 256 | mov ecx,long_v_table |
714 | Lrz | 257 | |
1703 | art_zh | 258 | .loop: add ax,size_of_step |
259 | cmp ax,word [end_cursor] |
||
260 | jae .next_step |
||
261 | loop .loop |
||
714 | Lrz | 262 | .next_step: |
1703 | art_zh | 263 | sub ax,size_of_step*long_v_table |
264 | cmp ax,modes_table |
||
265 | jae @f |
||
266 | mov ax,modes_table |
||
738 | diamond | 267 | @@: |
714 | Lrz | 268 | |
1703 | art_zh | 269 | mov word [home_cursor],ax |
270 | mov si,[preboot_graph] |
||
271 | mov word [cursor_pos],si |
||
946 | lrz | 272 | |
1703 | art_zh | 273 | push word [es:si] |
274 | pop word [x_save] |
||
275 | push word [es:si+2] |
||
276 | pop word [y_save] |
||
277 | push word [es:si+6] |
||
278 | pop word [number_vm] |
||
946 | lrz | 279 | |
1703 | art_zh | 280 | ret |
714 | Lrz | 281 | ;;;;;;;;;;;;;;;;;;;;;;;;;;; |
282 | .loops: |
||
1703 | art_zh | 283 | cmp ax,word [es:si] |
284 | jne .next |
||
285 | cmp bx,word [es:si+2] |
||
286 | jne .next |
||
287 | je .ok |
||
288 | .next: add si,size_of_step |
||
289 | cmp word [es:si],-1 |
||
290 | je .exit |
||
291 | jmp .loops |
||
292 | .ok: xor ax,ax |
||
946 | lrz | 293 | ret |
1703 | art_zh | 294 | .exit: or ax,-1 |
946 | lrz | 295 | ret |
714 | Lrz | 296 | |
297 | |||
298 | |||
299 | ;----------------------------------------------------------------------------- |
||
1700 | art_zh | 300 | ;Clear area of current video page (0xb800) |
1703 | art_zh | 301 | ;clear_vmodes_table: |
302 | ; pusha |
||
714 | Lrz | 303 | ; draw frames |
1703 | art_zh | 304 | ; push es |
305 | ; push 0xb800 |
||
306 | ; pop es |
||
307 | ; mov di,1444 |
||
308 | ; xor ax,ax |
||
309 | ; mov ah, 1*16+15 |
||
310 | ; mov cx,70 |
||
311 | ; mov bp,12 |
||
312 | ;.loop_start: |
||
313 | ; rep stosw |
||
314 | ; mov cx,70 |
||
315 | ; add di,20 |
||
316 | ; dec bp |
||
317 | ; jns .loop_start |
||
318 | ; pop es |
||
319 | ; popa |
||
320 | ; ret |
||
714 | Lrz | 321 | |
322 | ;----------------------------------------------------------------------------- |
||
323 | |||
324 | set_vmode: |
||
1703 | art_zh | 325 | push 0 ;0;x1000 |
326 | pop es |
||
714 | Lrz | 327 | |
1703 | art_zh | 328 | mov si,word [preboot_graph] ;[preboot_graph] |
329 | mov cx,word [es:si+6] ; number of mode |
||
714 | Lrz | 330 | |
331 | |||
1703 | art_zh | 332 | mov ax,word [es:si+0] ; resolution X |
333 | mov bx,word [es:si+2] ; resolution Y |
||
714 | Lrz | 334 | |
335 | |||
1703 | art_zh | 336 | mov word [es:0x900A],ax ; resolution X |
337 | mov word [es:0x900C],bx ; resolution Y |
||
338 | mov word [es:0x9008],cx ; number of mode |
||
714 | Lrz | 339 | |
1703 | art_zh | 340 | |
1700 | art_zh | 341 | ; VESA 2 and Vesa 3 only |
714 | Lrz | 342 | |
1703 | art_zh | 343 | mov ax,0x4f01 |
344 | and cx,0xfff |
||
345 | mov di,mi;0xa000 |
||
346 | int 0x10 |
||
347 | ; LFB |
||
348 | mov eax,[es:mi.PhysBasePtr] ;di+0x28] |
||
349 | mov [es:0x9018],eax |
||
350 | ; ---- vbe voodoo |
||
351 | BytesPerLine equ 0x10 |
||
352 | mov ax, [es:di+BytesPerLine] |
||
353 | mov [es:0x9001], ax |
||
354 | ; BPP |
||
714 | Lrz | 355 | .l0: |
1703 | art_zh | 356 | mov al, byte [es:di+0x19] |
357 | mov [es:0x9000], al |
||
358 | jmp .exit |
||
714 | Lrz | 359 | |
360 | .exit: |
||
1703 | art_zh | 361 | ret |
714 | Lrz | 362 | |
363 | |||
364 | ;=============================================================================><>><><<>><>><> |
||
365 |