Subversion Repositories Kolibri OS

Rev

Rev 1508 | Blame | Last modification | View Log | Download | RSS feed

  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. $Revision: 1700 $
  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.  
  191.   .next_mode:
  192.         mov     cx,word [fs:si] ; mode number
  193.         cmp     cx,-1
  194.         je      .modes_ok.2
  195.  
  196.         mov     ax,0x4F01
  197.         mov     di,mi
  198.         int     0x10
  199.  
  200.         or      ah,ah
  201.         jnz     .modes_ok.2             ;vesa_info.exit
  202.  
  203.         test    [es:mi.ModeAttributes],00000001b   ;videomode support ?
  204.         jz      @f
  205.         test    [es:mi.ModeAttributes],00010000b   ;picture ?
  206.         jz      @f
  207.         test    [es:mi.ModeAttributes],10000000b   ;LFB ?
  208.         jz      @f
  209.  
  210.         cmp     [es:mi.BitsPerPixel], 32        ;to show only 32 bpp videomodes
  211.         jb      @f
  212.  
  213. .l0:
  214.         cmp     [es:mi.XRes],800        ; only 800x600 and higher
  215.         jb      @f
  216.  
  217.         mov     ax,[es:mi.XRes]
  218.         mov     [es:bx+0],ax               ; +0[2] : resolution X
  219.         mov     ax,[es:mi.YRes]
  220.         mov     [es:bx+2],ax               ; +2[2] : resolution Y
  221.         mov     ax,[es:mi.ModeAttributes]
  222.         mov     [es:bx+4],ax               ; +4[2] : attributes
  223.  
  224. ;<<        cmp     [s_vesa.ver],'2'
  225. ;<<        jb      .lp1
  226.  
  227.         or      cx,0x4000                       ; use LFB <<< ?
  228. .lp1:   mov     [es:bx+6],cx               ; +6 : mode number
  229.         movzx   ax,byte [es:mi.BitsPerPixel]
  230.         mov     word [es:bx+8],ax               ; +8 : bits per pixel << ?
  231.         add     bx,size_of_step                 ; size of record
  232.  
  233.     @@:
  234.         add     si,2
  235.         jmp     .next_mode
  236.  
  237.   .modes_ok.2:
  238.  
  239.         mov     word[es:bx],-1  ;end video table
  240.         mov     word[end_cursor],bx     ;save end cursor position
  241.         popad
  242.         ret
  243.  
  244. ;-----------------------------------------------------------------------------
  245.  
  246. ;draw_current_vmode:
  247. ;        push    0
  248. ;        pop     es
  249.  
  250. ;        mov     si,word [cursor_pos]
  251.  
  252. ;        cmp     word [es:si+6],0x12
  253. ;        je      .no_vesa_0x12
  254.  
  255. ;        cmp     word [es:si+6],0x13
  256. ;        je      .no_vesa_0x13
  257.  
  258. ;        mov     di,loader_block_error
  259. ;        movzx   eax,word[es:si+0]
  260. ;        mov     ecx,10
  261. ;        call    int2strnz
  262. ;        mov     byte[es:di],'x'
  263. ;        inc     di
  264. ;        movzx   eax,word[es:si+2]
  265. ;        call    int2strnz
  266. ;        mov     byte[es:di],'x'
  267. ;        inc     di
  268. ;        movzx   eax,word[es:si+8]
  269. ;        call    int2strnz
  270. ;        mov     dword[es:di],0x00000d0a
  271. ;        mov     si,loader_block_error
  272. ;        push    ds
  273. ;        push    es
  274. ;        pop     ds
  275. ;        call    printplain
  276. ;        pop     ds
  277. ;        ret
  278. ;.no_vesa_0x13:
  279. ;        mov     si,mode0
  280. ;        jmp     .print
  281. ;.no_vesa_0x12:
  282. ;        mov     si,mode9
  283. ;.print:
  284. ;        call    printplain
  285. ;        ret        
  286. ;-----------------------------------------------------------------------------
  287. check_first_parm:
  288.         mov     si,word [preboot_graph]
  289.         test    si,si
  290.         jnz      .no_zero        ;if no zero
  291. .zerro:
  292. ;        mov     ax,modes_table
  293. ;        mov     word [cursor_pos],ax
  294. ;        mov     word [home_cursor],ax
  295. ;        mov     word [preboot_graph],ax
  296. ;SET default video of mode first probe will fined a move of work 1024x768@32
  297.  
  298.         mov     ax,1024
  299.         mov     bx,768
  300.         mov     si,modes_table
  301.         call    .loops
  302.         test    ax,ax
  303.         jz     .ok_found_mode
  304.  
  305.         mov     si,modes_table
  306.         jmp     .ok_found_mode
  307.  
  308. .no_zero:
  309.         mov     bp,word [number_vm]
  310.         cmp     bp,word [es:si+6]
  311.         jz      .ok_found_mode
  312.         mov     ax,word [x_save]
  313.         mov     bx,word [y_save]
  314.         mov     si,modes_table
  315.         call    .loops
  316.         test    ax,ax
  317.         jz     .ok_found_mode
  318.  
  319.         mov    si,modes_table
  320.  
  321. .ok_found_mode:
  322.         mov     word [home_cursor],si
  323.         mov     word [preboot_graph],si
  324.         mov     ax,si
  325.  
  326.         mov     ecx,long_v_table
  327.  
  328. .loop:  add     ax,size_of_step
  329.         cmp     ax,word [end_cursor]
  330.         jae     .next_step
  331.         loop    .loop
  332. .next_step:
  333.         sub     ax,size_of_step*long_v_table
  334.         cmp     ax,modes_table
  335.         jae     @f
  336.         mov     ax,modes_table
  337. @@:
  338.  
  339.         mov     word [home_cursor],ax
  340.         mov     si,[preboot_graph]
  341.         mov     word [cursor_pos],si
  342.  
  343.         push    word [es:si]
  344.         pop     word [x_save]
  345.         push    word [es:si+2]
  346.         pop     word [y_save]
  347.         push    word [es:si+6]
  348.         pop     word [number_vm]
  349.  
  350.         ret
  351. ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  352. .loops:
  353.         cmp     ax,word [es:si]
  354.         jne     .next
  355.         cmp     bx,word [es:si+2]
  356.         jne     .next
  357.         je      .ok
  358. .next:  add     si,size_of_step
  359.         cmp     word [es:si],-1
  360.         je      .exit
  361.         jmp     .loops
  362. .ok:    xor     ax,ax        
  363.         ret
  364. .exit:  or      ax,-1
  365.         ret
  366.  
  367.  
  368. ;-----------------------------------------------------------------------------
  369.  
  370. ;default_vmode:
  371.        
  372. ;-----------------------------------------------------------------------------
  373. draw_vmodes_table:
  374. ;        _setcursor 9, 2
  375. ;        mov     si,gr_mode
  376. ;        call    printplain
  377.  
  378. ;        mov     si,_st
  379. ;        call    printplain
  380.  
  381. ;        push    word [cursor_pos]
  382. ;        pop     ax
  383. ;        push    word [home_cursor]
  384. ;        pop     si
  385. ;        mov     cx,si
  386.  
  387.  ;       cmp     ax,si
  388. ;        je      .ok
  389. ;        jb      .low
  390.  
  391.  
  392.  ;       add     cx,size_of_step*long_v_table
  393.        
  394.   ;      cmp     ax,cx
  395. ;        jb      .ok
  396.        
  397. ;        sub     cx,size_of_step*long_v_table
  398. ;        add     cx,size_of_step
  399. ;        cmp     cx,word[end_cursor]
  400. ;        jae     .ok
  401. ;        add     si,size_of_step
  402. ;        push    si
  403. ;        pop     word [home_cursor]
  404. ;        jmp     .ok
  405.  
  406.  
  407. ;.low:   sub     cx,size_of_step
  408. ;        cmp     cx,modes_table
  409. ;        jb      .ok
  410. ;        push    cx
  411. ;        push    cx
  412. ;        pop     word [home_cursor]
  413. ;        pop     si
  414.  
  415.  
  416. ;.ok:
  417. ; calculate scroll position
  418. ;        push    si
  419. ;        mov     ax, [end_cursor]
  420. ;        sub     ax, modes_table
  421. ;        mov     bx, size_of_step
  422. ;        cwd
  423. ;        div     bx
  424. ;        mov     si, ax          ; si = size of list
  425. ;        mov     ax, [home_cursor]
  426. ;        sub     ax, modes_table
  427. ;        cwd
  428. ;        div     bx
  429. ;        mov     di, ax
  430. ;        mov     ax, scroll_area_size*long_v_table
  431. ;        cwd
  432. ;        div     si
  433. ;        test    ax, ax
  434. ;        jnz     @f
  435. ;        inc     ax
  436. ;@@:
  437. ;        cmp     al, scroll_area_size
  438. ;        jb      @f
  439. ;        mov     al, scroll_area_size
  440. ;@@:
  441. ;        mov     cx, ax
  442. ; cx = scroll height
  443. ; calculate scroll pos
  444. ;        xor     bx, bx          ; initialize scroll pos
  445. ;        sub     al, scroll_area_size+1
  446. ;        neg     al
  447. ;        sub     si, long_v_table-1
  448. ;        jbe     @f
  449. ;        mul     di
  450. ;        div     si
  451. ;        mov     bx, ax
  452. ;@@:
  453. ;        inc     bx
  454. ;        imul    ax, bx, size_of_step
  455. ;        add     ax, [home_cursor]
  456. ;        mov     [scroll_start], ax
  457. ;        imul    cx, size_of_step
  458. ;        add     ax, cx
  459. ;        mov     [scroll_end], ax
  460. ;        pop     si
  461. ;        mov     bp,long_v_table               ;show rows
  462. ;.@@_next_bit:
  463. ;clear cursor
  464. ;       mov     ax,'  '
  465. ;        mov     word[ds:_r1+21],ax
  466. ;        mov     word[ds:_r1+50],ax
  467.  
  468. ;        mov     word[ds:_r2+21],ax
  469. ;        mov     word[ds:_r2+45],ax
  470.  
  471. ;        mov     word[ds:_rs+21],ax
  472. ;        mov     word[ds:_rs+46],ax
  473. ; draw string
  474. ;        cmp     word [es:si+6],0x12
  475. ;        je      .show_0x12
  476. ;        cmp     word [es:si+6],0x13
  477. ;        je      .show_0x13
  478.  
  479. ;        movzx   eax,word[es:si]
  480. ;        cmp     ax,-1
  481. ;        je      .@@_end
  482. ;        mov     di,_rs+23          
  483. ;        mov     ecx,10
  484. ;        mov     bl,4
  485. ;        call    int2str
  486. ;        movzx   eax,word[es:si+2]
  487. ;        inc     di
  488. ;        mov     bl,4
  489. ;        call    int2str
  490.  
  491. ;        movzx   eax,word[es:si+8]
  492. ;        inc     di
  493. ;        mov     bl,2
  494. ;        call    int2str
  495.  
  496. ;        cmp     si, word [cursor_pos]
  497. ;        jne     .next
  498. ;draw   cursor
  499. ;        mov     word[ds:_rs+21],'>>'
  500. ;        mov     word[ds:_rs+46],'<<'
  501.        
  502.  
  503.  
  504. ;.next:
  505. ;        push    si
  506. ;        mov     si,_rs
  507. ;.@@_sh:
  508. ; add to the string pseudographics for scrollbar
  509. ;        pop     bx
  510. ;        push    bx
  511. ;        mov     byte [si+53], ' '
  512. ;        cmp     bx, [scroll_start]
  513. ;        jb      @f
  514. ;        cmp     bx, [scroll_end]
  515. ;        jae     @f
  516. ;        mov     byte [si+53], 0xDB ; filled bar
  517. ;@@:
  518. ;        push    bx
  519. ;        add     bx, size_of_step
  520. ;        cmp     bx, [end_cursor]
  521. ;        jnz     @f
  522. ;        mov     byte [si+53], 31 ; 'down arrow' symbol
  523. ;@@:
  524. ;        sub     bx, [home_cursor]
  525. ;        cmp     bx, size_of_step*long_v_table
  526. ;        jnz     @f
  527. ;        mov     byte [si+53], 31 ; 'down arrow' symbol
  528. ;@@:
  529. ;        pop     bx
  530. ;        cmp     bx, [home_cursor]
  531. ;        jnz     @f
  532. ;        mov     byte [si+53], 30 ; 'up arrow' symbol
  533. ;@@:
  534. ;        call    printplain
  535. ;        pop     si
  536. ;        add     si,size_of_step
  537.  
  538. ;        dec     bp
  539. ;        jnz     .@@_next_bit
  540.  
  541. ;.@@_end:
  542. ;        mov     si,_bt
  543. ;        call    printplain
  544.         ret
  545. ;.show_0x13:
  546. ;        push    si
  547.  
  548. ;        cmp     si, word [cursor_pos]
  549. ;        jne     @f
  550. ;        mov     word[ds:_r1+21],'>>'
  551. ;        mov     word[ds:_r1+50],'<<'        
  552. ;@@:
  553. ;        mov     si,_r1
  554. ;        jmp     .@@_sh
  555. ;.show_0x12:
  556. ;        push    si
  557. ;        cmp     si, word [cursor_pos]
  558. ;        jne     @f
  559.  
  560. ;        mov     word[ds:_r2+21],'>>'
  561. ;        mov     word[ds:_r2+45],'<<'
  562. ;@@:
  563. ;        mov     si,_r2
  564. ;        jmp     .@@_sh
  565.  
  566. ;-----------------------------------------------------------------------------
  567. ;Clear area of current video page (0xb800)
  568. clear_vmodes_table:
  569.         pusha
  570.        ; draw frames
  571.         push    es
  572.         push    0xb800
  573.         pop     es
  574.         mov     di,1444
  575.         xor     ax,ax
  576.         mov     ah, 1*16+15
  577.         mov     cx,70
  578.         mov     bp,12
  579. .loop_start:
  580.         rep     stosw
  581.         mov     cx,70
  582.         add     di,20
  583.         dec     bp
  584.         jns             .loop_start      
  585.         pop     es
  586.         popa
  587.         ret
  588.  
  589. ;-----------------------------------------------------------------------------
  590.  
  591. set_vmode:
  592.         push    0 ;0;x1000
  593.         pop     es
  594.  
  595.         mov     si,word [preboot_graph]            ;[preboot_graph]
  596.         mov     cx,word [es:si+6]            ; number of mode
  597.        
  598.  
  599.         mov     ax,word [es:si+0]            ; resolution X
  600.         mov     bx,word [es:si+2]            ; resolution Y
  601.  
  602.  
  603.         mov     word [es:0x900A],ax              ; resolution X
  604.         mov     word [es:0x900C],bx              ; resolution Y
  605.         mov     word [es:0x9008],cx              ; number of mode
  606.  
  607.  
  608. ;  VESA 2 and Vesa 3 only
  609.  
  610.         mov     ax,0x4f01
  611.         and     cx,0xfff
  612.         mov     di,mi;0xa000
  613.         int     0x10
  614.         ; LFB
  615.         mov     eax,[es:mi.PhysBasePtr]         ;di+0x28]
  616.         mov     [es:0x9018],eax
  617.         ; ---- vbe voodoo
  618.         BytesPerLine equ 0x10
  619.         mov     ax, [es:di+BytesPerLine]
  620.         mov     [es:0x9001], ax
  621.         ; BPP
  622. .l0:
  623.         mov     al, byte [es:di+0x19]
  624.         mov     [es:0x9000], al
  625.         jmp     .exit
  626.  
  627.   .exit:
  628.         ret
  629.  
  630.  
  631. ;=============================================================================
  632.  
  633.