Subversion Repositories Kolibri OS

Rev

Rev 33 | Rev 102 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                        ;;
  3. ;;  VGA.INC                                               ;;
  4. ;;                                                        ;;
  5. ;;  640x480 mode 0x12 VGA functions for MenuetOS          ;;
  6. ;;                                                        ;;
  7. ;;  Paul Butcher, paul.butcher@asa.co.uk                  ;;
  8. ;;                                                        ;;
  9. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  10.  
  11.  
  12.  
  13. paletteVGA:
  14.  
  15. ;16 colour palette
  16.        mov    dx,0x3c8
  17.        mov    al,0
  18.        out    dx,al
  19.  
  20.        mov    ecx,16
  21.        mov    dx,0x3c9
  22.        xor    eax,eax
  23.  
  24.      palvganew:
  25.  
  26.        mov al,0
  27.        test ah,4
  28.        jz palvgalbl1
  29.        add al,31
  30.        test ah,8
  31.        jz palvgalbl1
  32.        add al,32
  33.      palvgalbl1:
  34.        out dx,al  ; red 0,31 or 63
  35.        mov al,0
  36.        test ah,2
  37.        jz palvgalbl2
  38.        add al,31
  39.        test ah,8
  40.        jz palvgalbl2
  41.        add al,32
  42.      palvgalbl2:
  43.        out dx,al  ; blue 0,31 or 63
  44.        mov al,0
  45.        test ah,1
  46.        jz palvgalbl3
  47.        add al,31
  48.        test ah,8
  49.        jz palvgalbl3
  50.        add al,32
  51.      palvgalbl3:
  52.        out dx,al  ; green 0,31 or 63
  53.        add ah,1
  54.        loop palvganew
  55.  
  56.        ret
  57.  
  58.  
  59. vga_putimage:
  60. ; pushad
  61.  call    [disable_mouse]
  62.  push ebp ;
  63.  push esi ;
  64.  push edi ;
  65.  
  66.  push eax ;
  67.  push ebx ; +8 [ptrImage]
  68.  push ecx ; +4 [BH]
  69.  push edx ; +0 [xy]
  70.  
  71.  movzx eax,word [esp+2]   ; eax:=x
  72.  movzx ebx,word [esp+0]   ; ebx:=y
  73.  mov ecx,[0x3010]         ;
  74.  add eax,[ecx-twdw]     ; eax+=Xwin
  75.  add ebx,[ecx-twdw+4]   ; ebx+=Ywin
  76.  mov ecx,ebx              ; ecx = y+Ywin
  77.  mov edx,eax              ; edx = x+Xwin
  78.  
  79.  imul ebx, 640*4          ; (y+Ywin)*BytesPerScanLine
  80.  shl eax,2                ; (x+Xwin)*BytesPerPixel
  81.  add eax,ebx              ;
  82.  mov edi,eax              ; store copy
  83.         add eax,[0xfe80]         ; +AddrLFB
  84.  ;entry point in LFB >> EAX:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+AddrLFB
  85.  
  86.  shr edi,5                ; change from 4 to 1/8 BytesPerPixel
  87.  add edi,0xa0000          ; + VGABasePtr
  88.  ;VGA start address >> EDI:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+AddrVGA
  89.  
  90.  mov ebx, [0xfe00]        ; ScreenXSize
  91.  inc ebx                  ; +1
  92.  imul ebx,ecx             ; *(y+Ywin)
  93.  mov ebp, ebx             ;
  94.  add ebp, edx             ; +(x+Xwin)
  95.  add ebp, WinMapAddress   ; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer
  96.  
  97.  mov esi,[esp+8] ; esi:=AddrImg
  98.  movzx ecx,word [esp+6] ; ecx:=B
  99.  movzx ebx,word [esp+4] ; ebx:=H
  100.  
  101.  ; check limits while draw ?
  102.  
  103.  push ecx ; B
  104.  push eax ; LFB address
  105.  
  106.  mov eax,[0x3010]
  107.  mov ecx,[eax+draw_data-0x3000+0]
  108.  cmp ecx,0
  109.  jnz dbcblimitlset_vga
  110.  
  111.  mov ecx,[eax+draw_data-0x3000+4]
  112.  cmp ecx,0
  113.  jnz dbcblimitlset_vga
  114.  
  115.  mov ecx,[eax+draw_data-0x3000+8]
  116.  cmp ecx,[0xfe00] ; ecx <> Screen X size
  117.  jnz dbcblimitlset_vga
  118.  
  119.  mov ecx,[eax+draw_data-0x3000+12]
  120.  cmp ecx,[0xfe04] ; ecx <> Screen Y size
  121.  jnz dbcblimitlset_vga
  122.  
  123.  pop eax ; LFB address
  124.  pop ecx ; B
  125.  
  126.  push dword 0
  127.  
  128.  jmp pimvga
  129.  
  130.       dbcblimitlset_vga:
  131.  
  132.  pop eax ; LFB address
  133.  pop ecx ; B
  134.  
  135.  push dword 1
  136.  
  137. pimvga:
  138.  push edi
  139.  push esi
  140.  push eax  ; LFB address
  141.  push ecx  ; B
  142.  push ebx  ; H
  143.  push edx  ; x+Xwin
  144.  
  145.  mov ebx,[0x3010]
  146.  mov bl,[ebx+0xe]
  147.  mov bh,[esp+6*4]
  148.  
  149.  cld
  150.  
  151.  npvga:
  152.  
  153.    cmp bl,[ds:ebp]
  154.    jnz impvgano
  155.  
  156. ;   cmp bh,0
  157. ;   jz impvgayes
  158.  
  159. ;   call voodoodbcplimit
  160. ;   jnz impvgano
  161.  
  162. ; impvgayes:
  163.  
  164.    push eax  ; LFB address
  165.    push ebx  ; app no.
  166.    push ecx  ; B
  167.    push edx  ; x+Xwin
  168.  
  169.    mov edx,[esi] ; color
  170.    mov [eax],dx
  171.    shr edx,16
  172.    mov [eax+2],dl
  173.  
  174.    mov eax,[esi] ; color
  175.    mov ecx,[esp] ; x+Xwin
  176.    and ecx,0x07  ; modulo 8
  177.    call setvgapixel ; eax=color, ecx=x%8, edi=VGA address
  178.  
  179.    pop edx
  180.    pop ecx
  181.    pop ebx
  182.    pop eax
  183.  
  184.  impvgano:
  185.  
  186.    add esi,3 ; esi+=3 ptrImage+=3
  187.    add eax,4 ; eax+=4 LFBaddr +=4
  188.    inc ebp
  189.    inc edx ; x+Xwin+n
  190.  
  191.    test edx,0x07  ; test modulo 8
  192.    jnz impvgacont
  193.    inc edi
  194.  
  195.         impvgacont:
  196.    dec ecx ; B--
  197.    jnz npvga
  198.  
  199.       pop edx
  200.       pop ebx
  201.       pop ecx
  202.       pop eax
  203.       pop esi
  204.       pop edi
  205.  
  206.       add edi,640/8  ; add one VGA line
  207.       add eax,640*4  ; add one LFB line
  208.  
  209.       sub ebp, ecx ;  -B
  210.       add ebp, [0xfe00] ;
  211.       inc ebp ; ptrBuffer:=ptrBuffer-B+Screen_Xsize+1
  212.  
  213.       push ecx
  214.       lea ecx,[ecx+ecx*2] ;
  215.       add esi,ecx ; ptrImage:=ptrImage+B*3
  216.       pop ecx
  217.  
  218.       dec ebx ; H--
  219.       jnz pimvga
  220.  
  221.       add esp,4  ; jump saved limit byte
  222.       pop edx
  223.       pop ecx
  224.       pop ebx
  225.       pop eax
  226.       pop edi
  227.       pop esi
  228.       pop ebp
  229.      
  230. ;      call  [draw_pointer]
  231. ;      call    [disable_mouse]
  232. ;      popad
  233.       ret
  234.  
  235.  
  236. VGA_putpixel:
  237.  
  238.  ; eax = x
  239.  ; ebx = y
  240.  
  241.  mov     ecx,eax
  242.  mov     eax, [esp+32-8+4] ; color
  243.  
  244.  imul    ebx, 640*4        ; y*BytesPerLine (Vesa2.0 32)
  245.  lea     edx, [ebx+ecx*4]  ; + x*BytesPerPixel (Vesa2.0 32)
  246.  
  247.  mov     edi,edx
  248.  add     edi, [0xfe80]     ; + LFB address
  249.  mov     [edi], eax        ; write to LFB for Vesa2.0
  250.  
  251.  shr     edx,5             ; change BytesPerPixel to 1/8
  252.  mov     edi,edx
  253.  add     edi, 0x0a0000     ; address of pixel in VGA area
  254.  
  255.  and     ecx,0x07          ; bit no. (modulo 8)
  256.  
  257. setvgapixel:
  258.  cli
  259.  ; edi = address, eax = 24bit colour, ecx = bit no. (modulo 8)
  260.  
  261.  push   eax
  262.  mov    ebx,eax            ; color
  263.  
  264.  ;mov    al,0x08
  265.  ;mov    dx,0x03ce
  266.  ;out    dx,al             ; select GDC bit mask register
  267.  
  268.  inc    cl
  269.  mov    ax, 0x100
  270.  shr    ax,cl
  271.  mov    dx,0x03cf
  272.  out    dx,al              ; set bit mask for pixel
  273.  
  274.  mov    dl,0
  275.  mov    eax,ebx
  276.  and    eax,0x000000ff     ; blue
  277.  cmp    eax,85
  278.  jle    p13green
  279.  or     dl,0x01
  280.  cmp    eax,170
  281.  jle    p13green
  282.  or     dl,0x08
  283.  
  284. p13green:
  285.  and    ebx,0x0000ff00     ; green
  286.  cmp    ebx,85*256
  287.  jle    p13red
  288.  or     dl,0x02
  289.  cmp    ebx,170*256
  290.  jle    p13red
  291.  or     dl,0x08
  292.  
  293. p13red:
  294.  pop    ebx
  295.  and    ebx,0x00ff0000     ; red
  296.  cmp    ebx,85*256*256
  297.  jle    p13cont
  298.  or     dl,0x04
  299.  cmp    ebx,170*256*256
  300.  jle    p13cont
  301.  or     dl,0x08
  302.  
  303. p13cont:
  304.  mov    al,[edi]           ; dummy read
  305.  mov    [edi],dl
  306.  
  307.  sti
  308.  ret
  309.  
  310.  
  311. vga_drawbar:
  312. ;     pushad
  313.  call    [disable_mouse]
  314.      sub edx,ebx ; edx:=Yend-Ystart=H
  315.      sub ecx,eax ; ecx:=Xend-Xstat=B
  316.  
  317.      push ebp ; +24
  318.      push esi ; +20
  319.      push edi ; +16
  320.      push eax ; +12
  321.      push ebx ; +8
  322.      push ecx ; +4
  323.      push edx ; +0
  324.  
  325.      mov ecx,[0x3010] ;
  326.      add eax,[ecx-twdw] ; eax:=Xwin+x
  327.      add ebx,[ecx-twdw+4] ; ebx:=Ywin+y
  328.      mov ecx, eax ; ecx:=(x+Xwin)
  329.      mov edx, ebx ; edx:=(y+Ywin)
  330.  
  331.      imul ebx, 640/8  ;
  332.      mov edi, ebx ; edi:=BytesPerScanLine*(y+Ywin)
  333.      shr eax, 3 ;
  334.      add edi, eax ;  + (x+Xwin)*BytesPerPixel
  335.      add edi,0xa0000  ; + VGAbaseaddress
  336.  
  337.      mov eax, [0xfe00] ; ScreenXSize
  338.      inc eax ; +1
  339.      imul eax,edx ; *(y+Ywin)
  340.      mov ebp, eax ;
  341.      add ebp, ecx ; +(x+Win)
  342.      add ebp, WinMapAddress ; +AddrBuffer
  343.  
  344.      mov eax, [0xfe08]  ; BytesPerScanLine - LFB
  345.      mul edx            ; *(y+Ywin)
  346.      mov esi,eax
  347.      add esi,ecx
  348.      add esi,ecx
  349.      add esi,ecx
  350.      add esi,ecx        ; + 4*(x+Xwin)
  351.      add esi,[0xfe80]   ; +AddrLFB
  352.  
  353. ; edi:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel + AddrVGA
  354. ; esi:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel + AddrLFB
  355. ; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer
  356.  
  357. ; x size
  358.  
  359.      mov eax,[esp+4] ; B [esp+4]
  360.      mov ebx,[esp+0] ; H
  361.  
  362.      mov edx,[esp+16] ; color
  363.      test edx,0x80000000
  364.      jz nodbglvga
  365.  
  366.      ; no color glide for VGA - set to half glide
  367.      shr ebx,1  ; H/2
  368.      sub edx,ebx
  369.      mov [esp+16],edx
  370.      mov ebx,[esp+0] ; reset to H
  371.  
  372.    nodbglvga:
  373.      ; check limits ?
  374.  
  375.      push eax
  376.      push ecx
  377.  
  378.      mov eax,[0x3010]
  379.  
  380.      mov ecx,[eax+draw_data-0x3000+0]
  381.      cmp ecx,0
  382.      jnz dbcblimitlset_vga2
  383.  
  384.      mov ecx,[eax+draw_data-0x3000+4]
  385.      cmp ecx,0
  386.      jnz dbcblimitlset_vga2
  387.  
  388.      mov ecx,[eax+draw_data-0x3000+8]
  389.      cmp ecx,[0xfe00]
  390.      jnz dbcblimitlset_vga2
  391.  
  392.      mov ecx,[eax+draw_data-0x3000+12]
  393.      cmp ecx,[0xfe04]
  394.      jnz dbcblimitlset_vga2
  395.  
  396.      pop ecx
  397.      pop eax
  398.  
  399.      push dword 0
  400.  
  401.      jmp dbnewpivga
  402.  
  403.    dbcblimitlset_vga2:
  404.  
  405.      pop ecx ; x+Xwin
  406.      pop eax ; B
  407.  
  408.      push dword 1
  409.  
  410.    dbnewpivga:
  411.  
  412.      push eax; B
  413.      push ebx ; H
  414.      push edi
  415.      push esi
  416.      push ecx ; x+Xwin
  417.  
  418.      mov   ebx,[0x3010]
  419.      movzx ebx,byte[ebx+0xe]
  420.  
  421.      cld
  422.  
  423.      dbnpvga:
  424.  
  425.        mov dl,[ds:ebp]
  426.  
  427.        cmp dl,bl
  428.        jnz dbimpvgano
  429.  
  430. ;       mov edx,[esp+5*4] ; check limit?
  431. ;       cmp edx,0
  432. ;       jz dbimpvgayes
  433.  
  434. ;       call voodoodbcplimit
  435. ;       jnz  dbimpvgano
  436.  
  437. ;     dbimpvgayes:
  438.  
  439.        push eax ; B
  440.        push ebx
  441.        push ecx ; x+Xwin
  442.  
  443.        mov eax,[esp+12+20+16+4] ; color
  444.        mov ebx,eax
  445.  
  446.        mov [esi],bx    ; write LFB pixel
  447.        shr  ebx,16
  448.        mov  [esi+2],bl
  449.  
  450.        and ecx,0x07 ; modulo 8
  451.        call setvgapixel ; eax=color, ecx=x%8, edi=VGA address
  452.  
  453.        pop ecx
  454.        pop ebx
  455.        pop eax
  456.  
  457.      dbimpvgano:
  458.  
  459.        add esi,4    ; ptrLFB+=4
  460.        inc ebp  ; address buffer
  461.        inc ecx  ; x posn++
  462.        test ecx,0x07  ; test modulo 8
  463.        jnz dbvgacont
  464.        inc edi  ; VGA screen ptr++
  465.  
  466.      dbvgacont:
  467.        dec eax  ; B--  NB ecx in Vesa20 fn?
  468.        jnz dbnpvga
  469.  
  470.    dbnpvgad:
  471.  
  472.      pop ecx
  473.      pop esi
  474.      pop edi
  475.      pop ebx
  476.      pop eax
  477.  
  478.      add esi,[0xfe08]            ; ptrLFB+=BytesPerScanLine
  479.      add edi,640/8               ; ptrScreen+=BytesPerScanLine
  480.  
  481.      add ebp,[0xfe00]            ;
  482.      sub ebp, eax                ; was ecx in vesa20 fn?
  483.      inc ebp                     ; ptrBuffer:=ptrBuffer-B+BytesPerLine+1
  484.  
  485.      dec ebx                     ; H--
  486.      jz nodbnewpivga             ; H<>0
  487.  
  488.      jmp dbnewpivga
  489.  
  490.    nodbnewpivga:
  491.  
  492.      add esp,7*4   ; NB includes limit check flag
  493.      ;pop ebx
  494.      ;pop eax
  495.      ;pop edi
  496.      ;pop esi
  497.      pop ebp
  498.  
  499.      ;pop edx
  500.      ;pop ecx
  501. ;     popad
  502.      ret
  503.  
  504.  
  505. vga_drawbackground_tiled:
  506.  call    [disable_mouse]
  507.      push ebp
  508.      push eax
  509.      push ebx
  510.      push ecx
  511.      push edx
  512.  
  513.      mov edx,dword [0x400000-8] ; B
  514.      add edx,dword [WinMapAddress-8] ; +B
  515.      add edx,dword [WinMapAddress-8] ; +B
  516.      push edx
  517.  
  518.      mov eax,[draw_data+32+0] ; x start:=(x+Xwin)
  519.      mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
  520.      mov ecx,eax
  521.      mov edx,ebx
  522.  
  523.      imul edx, 640*4          ; (y+Ywin)*BytesPerScanLine
  524.      shl ecx,2                ; (x+Xwin)*BytesPerPixel
  525.      add ecx,edx              ;
  526.      mov ebp,ecx              ; store copy
  527.      add ecx,[0xfe80]         ; +AddrLFB
  528.   ;entry point in LFB >> ECX:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+Addr
  529.  
  530.      shr ebp,5                ; change from 4 to 1/8 BytesPerPixel
  531.      add ebp,0xa0000          ; + VGABasePtr
  532.   ;VGA start address >> EBP:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+AddrV
  533.  
  534.  
  535.      call calculate_edi
  536.  
  537.    dp3vga:                            ; MAIN LOOP
  538.  
  539.      cmp [edi+WinMapAddress],byte 1     ; ptrBuffer^<>byte(1)
  540.      je  ybgpvga
  541.  
  542.      jmp nbgpvga
  543.  
  544.    ybgpvga:
  545.  
  546.      push eax  ; x
  547.      push ebx  ; y
  548.      push ecx  ; LFB address
  549.  
  550.      mov ecx,dword [WinMapAddress-8]    ; B
  551.      xor edx,edx                   ; edx:=0
  552.      div ecx                       ; Xstart/B
  553.  
  554.      ; eax=Int(qn) edx:=Rem
  555.  
  556.      lea esi,[edx+edx*2]           ; esi:=edx*3
  557.  
  558.      mov ecx,dword [WinMapAddress-4]    ; ecx:=H
  559.      mov eax,[esp+4]               ; eax:=Ystart
  560.      xor edx,edx                   ;
  561.      div ecx                       ; Ystart/H
  562.  
  563.      mov eax,edx                   ; eax:=Rem
  564.      xor edx,edx                   ;
  565.      mov ebx,[esp+12]              ; ebx:=B*3
  566.      mul ebx                       ;
  567.      add esi,eax                   ;
  568.  
  569.      mov eax,[esi+0x300000]        ; color
  570.      and eax,0xffffff
  571.  
  572.      mov ecx, [esp]   ; LFB address
  573.      mov ebx,eax      ; copy color
  574.      mov [ecx],bx
  575.      shr ebx,16
  576.      mov [ecx+2],bl
  577.  
  578.      xchg edi, ebp
  579.      mov  ecx,[esp+8]     ; x position
  580.      and  ecx,0x07        ; x modulo 8
  581.      call setvgapixel     ; eax=color, ecx=x%8, edi=VGA address
  582.      xchg ebp, edi
  583.  
  584.      pop ecx
  585.      pop ebx
  586.      pop eax
  587.  
  588.    nbgpvga:
  589.  
  590.      inc eax                       ; x++
  591.      cmp eax,[draw_data+32+8]         ; X > xend?
  592.      jg  nodp3vga
  593.  
  594.      test eax,0x07                 ; x test modulo 8
  595.      jnz hook1vga
  596.      inc ebp                       ; VGA address++
  597.  
  598.    hook1vga:
  599.      add ecx,4                     ; LFB address += 4
  600.      inc edi                       ; ptrBuffer++
  601.      add esi,3                     ; ptrImage+=3
  602.      jmp dp3vga
  603.  
  604.    nodp3vga:
  605.  
  606.      mov eax,[draw_data+32+0]         ; x+Xwin
  607.      inc ebx                       ; y position
  608.      mov ecx,eax
  609.      mov edx,ebx
  610.  
  611.      imul edx, 640*4          ; (y+Ywin)*BytesPerScanLine
  612.      shl ecx,2                ; (x+Xwin)*BytesPerPixel
  613.      add ecx,edx              ;
  614.      mov ebp,ecx              ; store copy
  615.      add ecx,[0xfe80]         ; +AddrLFB
  616.     ;entry point in LFB >> ECX:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+Addr
  617.  
  618.  
  619.      shr ebp,5                ; change from 4 to 1/8 BytesPerPixel
  620.      add ebp,0xa0000          ; + VGABasePtr
  621.    ;VGA start address >> EBP:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+AddrV
  622.  
  623.  
  624.      call calculate_edi
  625.  
  626.      cmp ebx,[draw_data+32+12]         ; Y > yend
  627.      jg  dp4vga
  628.  
  629.      jmp dp3vga
  630.  
  631.    dp4vga:
  632.  
  633.      add esp,4
  634.  
  635.      pop edx
  636.      pop ecx
  637.      pop ebx
  638.      pop eax
  639.      pop ebp
  640.  
  641.      ret
  642.  
  643. ; ----------
  644.  
  645.  
  646.  
  647. vga_drawbackground_stretch:
  648.  call    [disable_mouse]
  649.  
  650.      push ebp
  651.      push eax
  652.      push ebx
  653.      push ecx
  654.      push edx
  655.  
  656.      mov edx,dword [WinMapAddress-8] ; B
  657.      add edx,dword [WinMapAddress-8] ; +B
  658.      add edx,dword [WinMapAddress-8] ; +B
  659.      push edx
  660.  
  661.      mov eax,[draw_data+32+0] ; x start:=(x+Xwin)
  662.      mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
  663.      mov ecx,eax
  664.      mov edx,ebx
  665.  
  666.      imul edx, 640*4          ; (y+Ywin)*BytesPerScanLine
  667.      shl ecx,2                ; (x+Xwin)*BytesPerPixel
  668.      add ecx,edx              ;
  669.      mov ebp,ecx              ; store copy
  670.      add ecx,[0xfe80]         ; +AddrLFB
  671.    ;entry point in LFB >> ECX:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+Addr
  672.  
  673.      shr ebp,5                ; change from 4 to 1/8 BytesPerPixel
  674.      add ebp,0xa0000          ; + VGABasePtr
  675.    ;VGA start address >> EBP:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+AddrV
  676.  
  677.  
  678.      call calculate_edi
  679.  
  680.    sdp3vga:                            ; MAIN LOOP
  681.  
  682.      cmp [edi+WinMapAddress],byte 1     ; ptrBuffer^<>byte(1)
  683.      je  sybgpvga
  684.  
  685.      jmp snbgpvga
  686.  
  687.    sybgpvga:
  688.  
  689.      push eax   ; x
  690.      push ebx   ; y
  691.      push ecx   ; LFB address
  692.  
  693.      mov   eax,dword [WinMapAddress-8]  ; B
  694.      xor   edx,edx
  695.      mov   ebx,[esp+8]             ; Xstart
  696.      mul   ebx                     ; B*Xstart
  697.      xor   edx,edx
  698.      mov   ebx,[0xfe00]            ; x screen width
  699.      div   ebx                     ; B*Xstart/xwidth
  700.      lea   esi,[eax+eax*2]         ; *3
  701.      mov   eax,dword [WinMapAddress-4]  ; H
  702.      xor   edx,edx
  703.      mov   ebx,[esp+4]             ; Ystart
  704.      mul   ebx                     ; H*Ystart
  705.      xor   edx,edx
  706.      mov   ebx,[0xfe04]            ; y screen height
  707.      div   ebx                     ; H*Ystart/yheight
  708.  
  709.      xor   edx,edx
  710.      mov   ebx,[esp+12]             ; B*3
  711.      mul   ebx                     ;
  712.      add   esi,eax
  713.      mov   eax,[esi+0x300000]      ; color
  714.      and   eax,0xffffff
  715.  
  716.      mov   ecx, [esp]   ; LFB address
  717.      mov   ebx,eax      ; copy color
  718.      mov   [ecx],bx
  719.      shr   ebx,16
  720.      mov   [ecx+2],bl
  721.  
  722.      xchg  edi, ebp
  723.      mov   ecx,[esp+8]     ; x position
  724.      and   ecx,0x07        ; x modulo 8
  725.      call  setvgapixel     ; eax=color, ecx=x%8, edi=VGA address
  726.      xchg  ebp, edi        ; ebp+=3
  727.  
  728.      pop ecx
  729.      pop ebx
  730.      pop eax
  731.  
  732.    snbgpvga:
  733.  
  734.      inc eax                       ; x++
  735.      cmp eax,[draw_data+32+8]         ; X > xend?
  736.      jg  snodp3vga
  737.  
  738.      test eax,0x07                 ; x test modulo 8
  739.      jnz shook1vga
  740.      inc ebp                       ; VGA address++
  741.  
  742.    shook1vga:
  743.      add ecx,4                     ; LFB address += 4
  744.      inc edi                       ; ptrBuffer++
  745.      add esi,3                     ; ptrImage+=3
  746.      jmp sdp3vga
  747.  
  748.    snodp3vga:
  749.  
  750.      mov eax,[draw_data+32+0]         ; x+Xwin
  751.      inc ebx                       ; y position
  752.      mov ecx,eax
  753.      mov edx,ebx
  754.  
  755.      imul edx, 640*4          ; (y+Ywin)*BytesPerScanLine
  756.      shl ecx,2                ; (x+Xwin)*BytesPerPixel
  757.      add ecx,edx              ;
  758.      mov ebp,ecx              ; store copy
  759.      add ecx,[0xfe80]         ; +AddrLFB
  760.   ;entry point in LFB >> ECX:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+Addr
  761.  
  762.  
  763.      shr ebp,5                ; change from 4 to 1/8 BytesPerPixel
  764.      add ebp,0xa0000          ; + VGABasePtr
  765.           ;VGA start address >> EBP:=(y+Ywin)*BytesPerScanLine+X*BytesPerPixel+A
  766.  
  767.  
  768.      call calculate_edi
  769.  
  770.      cmp ebx,[draw_data+32+12]        ; Y > yend
  771.      jg  sdp4vga
  772.  
  773.      jmp sdp3vga
  774.  
  775.    sdp4vga:
  776.  
  777.      add esp,4
  778.  
  779.      pop edx
  780.      pop ecx
  781.      pop ebx
  782.      pop eax
  783.      pop ebp
  784.  
  785.      ret
  786.  
  787.  
  788.