Subversion Repositories Kolibri OS

Rev

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

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