Subversion Repositories Kolibri OS

Rev

Rev 1700 | Go to most recent revision | 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: 1703 $
  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. ;-------------------------------------------------------
  117. print_vesa_info:
  118.         _setcursor 5,2
  119.  
  120.         mov     [es:vi.VESASignature],'VBE2'
  121.         mov     ax,0x4F00
  122.         mov     di,vi      ;0xa000
  123.         int     0x10
  124.         or      ah,ah
  125.         jz      @f
  126.         mov     [es:vi.VESASignature],'VESA'
  127.         mov     ax,$4F00
  128.         mov     di,vi
  129.         int     0x10
  130.         or      ah,ah
  131.         jnz     $
  132.   @@:
  133.         cmp     [es:vi.VESASignature],'VESA'
  134.         jne     $
  135.         cmp     [es:vi.VESAVersion],0x0100
  136.         jb      $
  137.  
  138.   .vesaok2:
  139.         mov     ax,[es:vi.VESAVersion]
  140.         add     ax,'00'
  141.  
  142.         mov     [s_vesa.ver], ah
  143.         mov     [s_vesa.ver+2], al
  144.         mov     si,s_vesa
  145.         call    printplain
  146.  
  147.         _setcursor 4,2
  148.         mov     si,word[es:vi.OemStringPtr]
  149.         mov     di,si
  150.  
  151.         push    ds
  152.         mov     ds,word[es:vi.OemStringPtr+2]
  153.         call    printplain
  154.         pop     ds
  155.  
  156.         ret
  157. ;-----------------------------------------------------------------------------
  158.  
  159. calc_vmodes_table:
  160.         pushad
  161.  
  162. ;        push    0
  163. ;        pop     es
  164.  
  165.         lfs     si, [es:vi.VideoModePtr]
  166.  
  167.         mov     bx,modes_table
  168.  
  169.   .next_mode:
  170.         mov     cx,word [fs:si] ; mode number
  171.         cmp     cx,-1
  172.         je      .modes_ok.2
  173.  
  174.         mov     ax,0x4F01
  175.         mov     di,mi
  176.         int     0x10
  177.  
  178.         or      ah,ah
  179.         jnz     .modes_ok.2             ;vesa_info.exit
  180.  
  181.         test    [es:mi.ModeAttributes],00000001b   ;videomode support ?
  182.         jz      @f
  183.         test    [es:mi.ModeAttributes],00010000b   ;picture ?
  184.         jz      @f
  185.         test    [es:mi.ModeAttributes],10000000b   ;LFB ?
  186.         jz      @f
  187.  
  188.         cmp     [es:mi.BitsPerPixel], 32        ;to show only 32 bpp videomodes
  189.         jb      @f
  190.  
  191. .l0:
  192.         cmp     [es:mi.XRes],800        ; only 800x600 and higher
  193.         jb      @f
  194.  
  195.         mov     ax,[es:mi.XRes]
  196.         mov     [es:bx+0],ax               ; +0[2] : resolution X
  197.         mov     ax,[es:mi.YRes]
  198.         mov     [es:bx+2],ax               ; +2[2] : resolution Y
  199.         mov     ax,[es:mi.ModeAttributes]
  200.         mov     [es:bx+4],ax               ; +4[2] : attributes
  201.  
  202. ;<<        cmp     [s_vesa.ver],'2'
  203. ;<<        jb      .lp1
  204.  
  205.         or      cx,0x4000                       ; use LFB <<< ?
  206. .lp1:   mov     [es:bx+6],cx               ; +6 : mode number
  207.         movzx   ax,byte [es:mi.BitsPerPixel]
  208.         mov     word [es:bx+8],ax               ; +8 : bits per pixel << ?
  209.         add     bx,size_of_step                 ; size of record
  210.  
  211.     @@:
  212.         add     si,2
  213.         jmp     .next_mode
  214.  
  215.   .modes_ok.2:
  216.  
  217.         mov     word[es:bx],-1  ;end video table
  218.         mov     word[end_cursor],bx     ;save end cursor position
  219.         popad
  220.         ret
  221.  
  222. check_first_parm:
  223.         mov     si,word [preboot_graph]
  224.         test    si,si
  225.         jnz      .no_zero        ;if no zero
  226. .zerro:
  227.  
  228.         mov     ax,1024
  229.         mov     bx,768
  230.         mov     si,modes_table
  231.         call    .loops
  232.         test    ax,ax
  233.         jz     .ok_found_mode
  234.  
  235.         mov     si,modes_table
  236.         jmp     .ok_found_mode
  237.  
  238. .no_zero:
  239.         mov     bp,word [number_vm]
  240.         cmp     bp,word [es:si+6]
  241.         jz      .ok_found_mode
  242.         mov     ax,word [x_save]
  243.         mov     bx,word [y_save]
  244.         mov     si,modes_table
  245.         call    .loops
  246.         test    ax,ax
  247.         jz     .ok_found_mode
  248.  
  249.         mov    si,modes_table
  250.  
  251. .ok_found_mode:
  252.         mov     word [home_cursor],si
  253.         mov     word [preboot_graph],si
  254.         mov     ax,si
  255.  
  256.         mov     ecx,long_v_table
  257.  
  258. .loop:  add     ax,size_of_step
  259.         cmp     ax,word [end_cursor]
  260.         jae     .next_step
  261.         loop    .loop
  262. .next_step:
  263.         sub     ax,size_of_step*long_v_table
  264.         cmp     ax,modes_table
  265.         jae     @f
  266.         mov     ax,modes_table
  267. @@:
  268.  
  269.         mov     word [home_cursor],ax
  270.         mov     si,[preboot_graph]
  271.         mov     word [cursor_pos],si
  272.  
  273.         push    word [es:si]
  274.         pop     word [x_save]
  275.         push    word [es:si+2]
  276.         pop     word [y_save]
  277.         push    word [es:si+6]
  278.         pop     word [number_vm]
  279.  
  280.         ret
  281. ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  282. .loops:
  283.         cmp     ax,word [es:si]
  284.         jne     .next
  285.         cmp     bx,word [es:si+2]
  286.         jne     .next
  287.         je      .ok
  288. .next:  add     si,size_of_step
  289.         cmp     word [es:si],-1
  290.         je      .exit
  291.         jmp     .loops
  292. .ok:    xor     ax,ax
  293.         ret
  294. .exit:  or      ax,-1
  295.         ret
  296.  
  297.  
  298.  
  299. ;-----------------------------------------------------------------------------
  300. ;Clear area of current video page (0xb800)
  301. ;clear_vmodes_table:
  302. ;        pusha
  303.        ; draw frames
  304. ;        push    es
  305. ;        push    0xb800
  306. ;        pop     es
  307. ;        mov     di,1444
  308. ;        xor     ax,ax
  309. ;        mov     ah, 1*16+15
  310. ;        mov     cx,70
  311. ;        mov     bp,12
  312. ;.loop_start:
  313. ;        rep     stosw
  314. ;        mov     cx,70
  315. ;        add     di,20
  316. ;        dec     bp
  317. ;        jns             .loop_start
  318. ;        pop     es
  319. ;        popa
  320. ;        ret
  321.  
  322. ;-----------------------------------------------------------------------------
  323.  
  324. set_vmode:
  325.         push    0 ;0;x1000
  326.         pop     es
  327.  
  328.         mov     si,word [preboot_graph]            ;[preboot_graph]
  329.         mov     cx,word [es:si+6]            ; number of mode
  330.  
  331.  
  332.         mov     ax,word [es:si+0]            ; resolution X
  333.         mov     bx,word [es:si+2]            ; resolution Y
  334.  
  335.  
  336.         mov     word [es:0x900A],ax              ; resolution X
  337.         mov     word [es:0x900C],bx              ; resolution Y
  338.         mov     word [es:0x9008],cx              ; number of mode
  339.  
  340.  
  341. ;  VESA 2 and Vesa 3 only
  342.  
  343.         mov     ax,0x4f01
  344.         and     cx,0xfff
  345.         mov     di,mi;0xa000
  346.         int     0x10
  347.         ; LFB
  348.         mov     eax,[es:mi.PhysBasePtr]         ;di+0x28]
  349.         mov     [es:0x9018],eax
  350.         ; ---- vbe voodoo
  351.         BytesPerLine equ 0x10
  352.         mov     ax, [es:di+BytesPerLine]
  353.         mov     [es:0x9001], ax
  354.         ; BPP
  355. .l0:
  356.         mov     al, byte [es:di+0x19]
  357.         mov     [es:0x9000], al
  358.         jmp     .exit
  359.  
  360.   .exit:
  361.         ret
  362.  
  363.  
  364. ;=============================================================================
  365.  
  366.