Subversion Repositories Kolibri OS

Rev

Rev 5201 | Details | Compare with Previous | Last modification | View Log | RSS feed

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