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