Subversion Repositories Kolibri OS

Rev

Rev 1161 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1159 hidnplayr 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
1206 hidnplayr 8
$Revision: 1206 $
1159 hidnplayr 9
 
10
struc VBE_VGAInfo {
11
  .VESASignature          dd ?    ; char
12
  .VESAVersion            dw ?    ; short
13
  .OemStringPtr           dd ?    ; char *
14
  .Capabilities           dd ?    ; ulong
15
  .VideoModePtr           dd ?    ; ulong
16
  .TotalMemory            dw ?    ; short
17
  ; VBE 2.0+
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
24
}
25
 
26
struc VBE_ModeInfo {
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
56
  ; VBE 2.0+
57
  .PhysBasePtr            dd ?    ; ulong
58
  .OffScreenMemOffset     dd ?    ; ulong
59
  .OffScreenMemSize       dw ?    ; short
60
  ; VBE 3.0+
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
74
}
75
 
76
virtual at $A000
77
  vi VBE_VGAInfo
78
  mi VBE_ModeInfo
79
modes_table:
80
end virtual
81
cursor_pos  dw 0         ;âðåìåííîå õðàíåíèå êóðñîðà.
82
home_cursor dw 0    ;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
85
scroll_end  dw 0     ;end position of scroll bar
86
long_v_table equ 9   ;long of visible video table
87
size_of_step equ 10
88
scroll_area_size equ (long_v_table-2)
89
int2str:
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
101
 
102
int2strnz:
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
114
 
115
;-------------------------------------------------------
116
;Write message about incorrect v_mode and write message about jmp on swith v_mode
117
v_mode_error:
118
        _setcursor 19,2
119
        mov     si, fatalsel
120
        call    printplain
121
        _setcursor 20,2
122
        mov     si,pres_key
123
        call    printplain
124
        xor     eax,eax
125
        int     16h
126
        jmp     cfgmanager.d
127
;-------------------------------------------------------
128
;
129
 
130
 
131
 
132
;-------------------------------------------------------
133
print_vesa_info:
134
        _setcursor 5,2
135
 
136
        mov     [es:vi.VESASignature],'VBE2'
137
        mov     ax,0x4F00
138
        mov     di,vi      ;0xa000
139
        int     0x10
140
        or      ah,ah
141
        jz      @f
142
        mov     [es:vi.VESASignature],'VESA'
143
        mov     ax,$4F00
144
        mov     di,vi
145
        int     0x10
146
        or      ah,ah
147
        jnz     .exit
148
  @@:
149
        cmp     [es:vi.VESASignature],'VESA'
150
        jne     .exit
151
        cmp     [es:vi.VESAVersion],0x0100
152
        jb      .exit
153
        jmp     .vesaok2
154
 
155
  .exit:
156
        mov     si,novesa
157
        call    printplain
158
        ret
159
 
160
  .vesaok2:
161
        mov     ax,[es:vi.VESAVersion]
162
        add     ax,'00'
163
 
164
        mov     [s_vesa.ver], ah
165
        mov     [s_vesa.ver+2], al
166
        mov     si,s_vesa
167
        call    printplain
168
 
169
        _setcursor 4,2
170
        mov     si,word[es:vi.OemStringPtr]
171
        mov     di,si
172
 
173
        push    ds
174
        mov     ds,word[es:vi.OemStringPtr+2]
175
        call    printplain
176
        pop     ds
177
 
178
        ret
179
;-----------------------------------------------------------------------------
180
 
181
calc_vmodes_table:
182
        pushad
183
 
184
;        push    0
185
;        pop     es
186
 
187
        lfs     si, [es:vi.VideoModePtr]
188
 
189
        mov     bx,modes_table
190
;save no vesa mode of work 320x200, EGA/CGA 256 梥⮢ and 640x480, VGA 16 梥⮢
191
        mov     word [es:bx],640
192
        mov     word [es:bx+2],480
193
        mov     word [es:bx+6],0x13
194
 
195
        mov     word [es:bx+10],640
196
        mov     word [es:bx+12],480
197
        mov     word [es:bx+16],0x12
198
        add     bx,20
199
  .next_mode:
200
        mov     cx,word [fs:si] ; mode number
201
        cmp     cx,-1
202
        je      .modes_ok.2
203
 
204
        mov     ax,0x4F01
205
        mov     di,mi
206
        int     0x10
207
 
208
        or      ah,ah
209
        jnz     .modes_ok.2;vesa_info.exit
210
 
211
        test    [es:mi.ModeAttributes],00000001b   ;videomode support ?
212
        jz      @f
213
        test    [es:mi.ModeAttributes],00010000b   ;picture ?
214
        jz      @f
215
        test    [es:mi.ModeAttributes],10000000b   ;LFB ?
216
        jz      @f
217
 
218
        cmp     [es:mi.BitsPerPixel], 24	;It show only videomodes to have support 24 and 32 bpp
219
        jb      @f
220
 
221
;        cmp     [es:mi.BitsPerPixel],16
222
;        jne     .l0
223
;        cmp     [es:mi.GreenMaskSize],5
224
;        jne     .l0
225
;        mov     [es:mi.BitsPerPixel],15
226
 
227
 
228
.l0:
229
        cmp     [es:mi.XRes],640
230
        jb      @f
231
        cmp     [es:mi.YRes],480
232
        jb      @f
233
;        cmp     [es:mi.BitsPerPixel],8
234
;        jb      @f
235
 
236
        mov     ax,[es:mi.XRes]
237
        mov     [es:bx+0],ax               ; +0[2] : resolution X
238
        mov     ax,[es:mi.YRes]
239
        mov     [es:bx+2],ax               ; +2[2] : resolution Y
240
        mov     ax,[es:mi.ModeAttributes]
241
        mov     [es:bx+4],ax               ; +4[2] : attributes
242
 
243
        cmp     [s_vesa.ver],'2'
244
        jb      .lp1
245
 
246
        or      cx,0x4000  ; use LFB
247
.lp1:	mov     [es:bx+6],cx               ; +6 : mode number
248
        movzx   ax,byte [es:mi.BitsPerPixel]
249
        mov     word [es:bx+8],ax               ; +8 : bits per pixel
250
        add     bx,size_of_step                 ; size of record
251
 
252
    @@:
253
        add     si,2
254
        jmp     .next_mode
255
 
256
  .modes_ok.2:
257
 
258
        mov     word[es:bx],-1  ;end video table
259
        mov     word[end_cursor],bx     ;save end cursor position
260
;;;;;;;;;;;;;;;;;;
261
;Sort array
262
;        mov     si,modes_table
263
;.new_mode:
264
;        mov     ax,word [es:si]
265
;        cmp     ax,-1
266
;        je      .exxit
267
;        add     ax,word [es:si+2]
268
;        add     ax,word [es:si+8]
269
;        mov     bp,si
270
;.again:
271
;        add     bp,12
272
;        mov     bx,word [es:bp]
273
;        cmp     bx,-1
274
;        je      .exit
275
;        add     bx,word [es:bp+2]
276
;        add     bx,word [es:bp+8]
277
;
278
;        cmp     ax,bx
279
;        ja      .loops
280
;        jmp     .again
281
;.loops:
282
;        push    dword [es:si]
283
;        push    dword [es:si+4]
284
;        push    dword [es:si+8]
285
;        push    dword [es:bp]
286
;        push    dword [es:bp+4]
287
;        push    dword [es:bp+8]
288
;
289
;        pop     dword [es:si+8]
290
;        pop     dword [es:si+4]
291
;        pop     dword [es:si]
292
;        pop     dword [es:bp+8]
293
;        pop     dword [es:bp+4]
294
;        pop     dword [es:bp]
295
;        jmp     .new_mode
296
;
297
;.exit:  add     si,12
298
;        jmp     .new_mode
299
;.exxit:
300
        popad
301
        ret
302
 
303
;-----------------------------------------------------------------------------
304
 
305
draw_current_vmode:
306
        push    0
307
        pop     es
308
 
309
        mov     si,word [cursor_pos]
310
 
311
        cmp     word [es:si+6],0x12
312
        je      .no_vesa_0x12
313
 
314
        cmp     word [es:si+6],0x13
315
        je      .no_vesa_0x13
316
 
317
        mov     di,loader_block_error
318
        movzx   eax,word[es:si+0]
319
        mov     ecx,10
320
        call    int2strnz
321
        mov     byte[es:di],'x'
322
        inc     di
323
        movzx   eax,word[es:si+2]
324
        call    int2strnz
325
        mov     byte[es:di],'x'
326
        inc     di
327
        movzx   eax,word[es:si+8]
328
        call    int2strnz
329
        mov     dword[es:di],0x00000d0a
330
        mov     si,loader_block_error
331
        push    ds
332
        push    es
333
        pop     ds
334
        call    printplain
335
        pop     ds
336
        ret
337
.no_vesa_0x13:
338
        mov     si,mode0
339
        jmp     .print
340
.no_vesa_0x12:
341
        mov     si,mode9
342
.print:
343
        call    printplain
344
        ret
345
;-----------------------------------------------------------------------------
346
check_first_parm:
347
        mov     si,word [preboot_graph]
348
        test    si,si
349
        jnz      .no_zero        ;if no zero
350
.zerro:
351
;        mov     ax,modes_table
352
;        mov     word [cursor_pos],ax
353
;        mov     word [home_cursor],ax
354
;        mov     word [preboot_graph],ax
355
;SET default video of mode first probe will fined a move of work 1024x768@32
356
 
357
        mov     ax,1024
358
        mov     bx,768
359
        mov     si,modes_table
360
        call    .loops
361
        test    ax,ax
362
        jz     .ok_found_mode
363
        mov     ax,800
364
        mov     bx,600
365
        mov     si,modes_table
366
        call    .loops
367
        test    ax,ax
368
        jz     .ok_found_mode
369
        mov     ax,640
370
        mov     bx,480
371
        mov     si,modes_table
372
        call    .loops
373
        test    ax,ax
374
        jz     .ok_found_mode
375
 
376
        mov     si,modes_table
377
        jmp     .ok_found_mode
378
 
379
 
380
 
381
.no_zero:
382
	mov	bp,word [number_vm]
383
        cmp     bp,word [es:si+6]
384
        jz      .ok_found_mode
385
        mov     ax,word [x_save]
386
        mov     bx,word [y_save]
387
        mov     si,modes_table
388
        call    .loops
389
        test    ax,ax
390
        jz     .ok_found_mode
391
 
392
	mov    si,modes_table
393
;        cmp     ax,modes_table
394
;        jb      .zerro           ;check on correct if bellow
395
;        cmp     ax,word [end_cursor]
396
;        ja      .zerro           ;check on correct if anymore
397
 
398
.ok_found_mode:
399
        mov     word [home_cursor],si
400
;        mov     word [cursor_pos],si
401
        mov     word [preboot_graph],si
402
        mov     ax,si
403
 
404
        mov     ecx,long_v_table
405
 
406
.loop:  add     ax,size_of_step
407
        cmp     ax,word [end_cursor]
408
        jae     .next_step
409
        loop    .loop
410
.next_step:
411
        sub     ax,size_of_step*long_v_table
412
        cmp     ax,modes_table
413
        jae     @f
414
        mov     ax,modes_table
415
@@:
416
 
417
        mov     word [home_cursor],ax
418
        mov	si,[preboot_graph]
419
        mov     word [cursor_pos],si
420
 
421
        push    word [es:si]
422
        pop     word [x_save]
423
        push    word [es:si+2]
424
        pop     word [y_save]
425
        push    word [es:si+6]
426
        pop     word [number_vm]
427
 
428
        ret
429
;;;;;;;;;;;;;;;;;;;;;;;;;;;
430
.loops:
431
        cmp     ax,word [es:si]
432
        jne     .next
433
        cmp     bx,word [es:si+2]
434
        jne     .next
435
        cmp     word [es:si+8],32
436
        je      .ok
437
        cmp     word [es:si+8],24
438
        je      .ok
439
.next:  add     si,size_of_step
440
        cmp     word [es:si],-1
441
        je      .exit
442
        jmp     .loops
443
.ok:    xor     ax,ax
444
	ret
445
.exit:  or	ax,-1
446
	ret
447
 
448
 
449
;-----------------------------------------------------------------------------
450
 
451
;default_vmode:
452
 
453
;-----------------------------------------------------------------------------
454
draw_vmodes_table:
455
        _setcursor 9, 2
456
        mov     si,gr_mode
457
        call    printplain
458
 
459
        mov     si,_st
460
        call    printplain
461
 
462
        push    word [cursor_pos]
463
        pop     ax
464
        push    word [home_cursor]
465
        pop     si
466
        mov     cx,si
467
 
468
        cmp     ax,si
469
        je      .ok
470
        jb      .low
471
 
472
 
473
        add     cx,size_of_step*long_v_table
474
 
475
        cmp     ax,cx
476
        jb      .ok
477
 
478
        sub     cx,size_of_step*long_v_table
479
        add     cx,size_of_step
480
        cmp     cx,word[end_cursor]
481
        jae     .ok
482
        add     si,size_of_step
483
        push    si
484
        pop     word [home_cursor]
485
        jmp     .ok
486
 
487
 
488
.low:   sub     cx,size_of_step
489
        cmp     cx,modes_table
490
        jb      .ok
491
        push    cx
492
        push    cx
493
        pop     word [home_cursor]
494
        pop     si
495
 
496
 
497
.ok:
498
; calculate scroll position
499
        push    si
500
        mov     ax, [end_cursor]
501
        sub     ax, modes_table
502
        mov     bx, size_of_step
503
        cwd
504
        div     bx
505
        mov     si, ax          ; si = size of list
506
        mov     ax, [home_cursor]
507
        sub     ax, modes_table
508
        cwd
509
        div     bx
510
        mov     di, ax
511
        mov     ax, scroll_area_size*long_v_table
512
        cwd
513
        div     si
514
        test    ax, ax
515
        jnz     @f
516
        inc     ax
517
@@:
518
        cmp     al, scroll_area_size
519
        jb      @f
520
        mov     al, scroll_area_size
521
@@:
522
        mov     cx, ax
523
; cx = scroll height
524
; calculate scroll pos
525
        xor     bx, bx          ; initialize scroll pos
526
        sub     al, scroll_area_size+1
527
        neg     al
528
        sub     si, long_v_table-1
529
        jbe     @f
530
        mul     di
531
        div     si
532
        mov     bx, ax
533
@@:
534
        inc     bx
535
        imul    ax, bx, size_of_step
536
        add     ax, [home_cursor]
537
        mov     [scroll_start], ax
538
        imul    cx, size_of_step
539
        add     ax, cx
540
        mov     [scroll_end], ax
541
        pop     si
542
        mov     bp,long_v_table               ;show rows
543
.@@_next_bit:
544
;clear cursor
545
	mov	ax,'  '
546
        mov     word[ds:_r1+21],ax
547
        mov     word[ds:_r1+50],ax
548
 
549
        mov     word[ds:_r2+21],ax
550
        mov     word[ds:_r2+45],ax
551
 
552
        mov     word[ds:_rs+21],ax
553
        mov     word[ds:_rs+46],ax
554
; draw string
555
        cmp     word [es:si+6],0x12
556
        je      .show_0x12
557
        cmp     word [es:si+6],0x13
558
        je      .show_0x13
559
 
560
        movzx   eax,word[es:si]
561
        cmp     ax,-1
562
        je      .@@_end
563
        mov     di,_rs+23
564
        mov     ecx,10
565
        mov     bl,4
566
        call    int2str
567
        movzx   eax,word[es:si+2]
568
        inc     di
569
        mov     bl,4
570
        call    int2str
571
 
572
        movzx   eax,word[es:si+8]
573
        inc     di
574
        mov     bl,2
575
        call    int2str
576
 
577
        cmp     si, word [cursor_pos]
578
        jne     .next
579
;draw   cursor
580
        mov     word[ds:_rs+21],'>>'
581
        mov     word[ds:_rs+46],'<<'
582
 
583
 
584
 
585
.next:
586
        push    si
587
        mov     si,_rs
588
.@@_sh:
589
; add to the string pseudographics for scrollbar
590
        pop     bx
591
        push    bx
592
        mov     byte [si+53], ' '
593
        cmp     bx, [scroll_start]
594
        jb      @f
595
        cmp     bx, [scroll_end]
596
        jae     @f
597
        mov     byte [si+53], 0xDB ; filled bar
598
@@:
599
        push    bx
600
        add     bx, size_of_step
601
        cmp     bx, [end_cursor]
602
        jnz     @f
603
        mov     byte [si+53], 31 ; 'down arrow' symbol
604
@@:
605
        sub     bx, [home_cursor]
606
        cmp     bx, size_of_step*long_v_table
607
        jnz     @f
608
        mov     byte [si+53], 31 ; 'down arrow' symbol
609
@@:
610
        pop     bx
611
        cmp     bx, [home_cursor]
612
        jnz     @f
613
        mov     byte [si+53], 30 ; 'up arrow' symbol
614
@@:
615
        call    printplain
616
        pop     si
617
        add     si,size_of_step
618
 
619
        dec     bp
620
        jnz     .@@_next_bit
621
 
622
.@@_end:
623
        mov     si,_bt
624
        call    printplain
625
        ret
626
.show_0x13:
627
        push    si
628
 
629
        cmp     si, word [cursor_pos]
630
        jne     @f
631
        mov     word[ds:_r1+21],'>>'
632
        mov     word[ds:_r1+50],'<<'
633
@@:
634
        mov     si,_r1
635
        jmp     .@@_sh
636
.show_0x12:
637
        push    si
638
        cmp     si, word [cursor_pos]
639
        jne     @f
640
 
641
        mov     word[ds:_r2+21],'>>'
642
        mov     word[ds:_r2+45],'<<'
643
@@:
644
        mov     si,_r2
645
        jmp     .@@_sh
646
 
647
;-----------------------------------------------------------------------------
648
;Clear arrea of current video page (0xb800)
649
clear_vmodes_table:
650
        pusha
651
       ; draw frames
652
        push    es
653
        push    0xb800
654
        pop     es
655
        mov     di,1444
656
        xor     ax,ax
657
        mov     ah, 1*16+15
658
        mov     cx,70
659
        mov     bp,12
660
.loop_start:
661
        rep     stosw
662
        mov     cx,70
663
        add     di,20
664
        dec     bp
665
        jns		.loop_start
666
        pop     es
667
        popa
668
        ret
669
 
670
;-----------------------------------------------------------------------------
671
 
672
set_vmode:
673
        push    0 ;0;x1000
674
        pop     es
675
 
676
        mov     si,word [preboot_graph]            ;[preboot_graph]
677
        mov     cx,word [es:si+6]            ; number of mode
678
 
679
 
680
        mov     ax,word [es:si+0]            ; resolution X
681
        mov     bx,word [es:si+2]            ; resolution Y
682
 
683
 
684
        mov     word [es:0x900A],ax              ; resolution X
685
        mov     word [es:0x900C],bx              ; resolution Y
686
        mov     word [es:0x9008],cx              ; number of mode
687
 
688
        cmp     cx,0x12
689
        je      .mode0x12_0x13
690
        cmp     cx,0x13
691
        je      .mode0x12_0x13
692
 
693
 
694
        cmp     byte [s_vesa.ver],'2'
695
        jb      .vesa12
696
 
697
;  VESA 2 and Vesa 3
698
 
699
        mov     ax,0x4f01
700
        and     cx,0xfff
701
        mov     di,mi;0xa000
702
        int     0x10
703
        ; LFB
704
        mov     eax,[es:mi.PhysBasePtr];di+0x28]
705
        mov     [es:0x9018],eax
706
        ; ---- vbe voodoo
707
        BytesPerLine equ 0x10
708
        mov     ax, [es:di+BytesPerLine]
709
        mov     [es:0x9001], ax
710
        ; BPP
711
        cmp     [es:mi.BitsPerPixel],16
712
        jne     .l0
713
        cmp     [es:mi.GreenMaskSize],5
714
        jne     .l0
715
        mov     [es:mi.BitsPerPixel],15
716
.l0:
717
        mov     al, byte [es:di+0x19]
718
        mov     [es:0x9000], al
719
        jmp     .exit
720
 
721
.mode0x12_0x13:
722
        mov     byte [es:0x9000], 32
723
        or      dword [es:0x9018], 0xFFFFFFFF; 0x800000
724
 
725
 
726
;  VESA 1.2 PM BANK SWITCH ADDRESS
727
 
728
.vesa12:
729
 
730
 
731
        mov     ax,0x4f0A
732
        xor     bx,bx
733
        int     0x10
734
        xor     eax,eax
735
        xor     ebx,ebx
736
        mov     ax,es
737
        shl     eax,4
738
        mov     bx,di
739
        add     eax,ebx
740
        movzx   ebx,word[es:di]
741
        add     eax,ebx
742
        push    0x0000
743
        pop     es
744
        mov     [es:0x9014],eax
745
  .exit:
746
        ret
747
 
748
 
749
;        mov     dword[es:0x9018],0x000A0000
750
;        ret
751
 
752
;=============================================================================
753
;=============================================================================
754
;=============================================================================
755