Subversion Repositories Kolibri OS

Rev

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

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                                 ;;
  3. ;; Copyright (C) KolibriOS team 2010-2015. All rights reserved.    ;;
  4. ;; Distributed under terms of the GNU General Public License       ;;
  5. ;;                                                                 ;;
  6. ;;  VNC client for KolibriOS                                       ;;
  7. ;;                                                                 ;;
  8. ;;  Written by hidnplayr@kolibrios.org                             ;;
  9. ;;                                                                 ;;
  10. ;;          GNU GENERAL PUBLIC LICENSE                             ;;
  11. ;;             Version 2, June 1991                                ;;
  12. ;;                                                                 ;;
  13. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  14.  
  15. pixel_to_24bpp:         ; returns in ecx
  16.  
  17.         push    eax
  18. ;  @@:
  19. ;        lea     eax, [esi+BYTES_PER_PIXEL]
  20. ;        cmp     [datapointer], eax
  21. ;        jae     @f
  22. ;        call    read_data.more
  23. ;        jmp     @b
  24. ;  @@:
  25.  
  26. if BITS_PER_PIXEL = 8
  27.  
  28.         push    ebx
  29.  
  30.         mov     bl, 36
  31.         mov     al, [esi]
  32.         and     al, 7
  33.         mul     bl
  34.         mov     ch, al          ; red
  35.  
  36.         mov     al, [esi]
  37.         shr     al, 3
  38.         and     al, 7
  39.         mul     bl
  40.         mov     cl, al          ; green
  41.  
  42.         mov     bl, 85
  43.         mov     al, [esi]
  44.         shr     al, 6
  45.         and     al, 3
  46.         mul     bl
  47.         shl     ecx, 8
  48.         mov     cl, al          ; blue
  49.  
  50.         inc     esi
  51.         pop     ebx
  52.  
  53. else if BITS_PER_PIXEL = 16
  54.  
  55.         lodsw
  56.         mov     cl, ah
  57.         and     al, 0xf8        ; red
  58.  
  59.         mov     cx, ax
  60.         shl     cx, 5
  61.         and     ch, 0xfc        ; green
  62.         shl     ecx, 8
  63.  
  64.         mov     cl, al
  65.         shl     cl, 3
  66.         and     cx, 0x00f8      ; blue
  67.  
  68. else
  69.  
  70.         xor     ecx, ecx
  71.         mov     cx, [esi]
  72.         shl     ecx, 8
  73.         mov     cl, [esi+2]
  74.         add     esi, 3
  75.  
  76. end if
  77.         pop     eax
  78.  
  79.         ret
  80.  
  81. encoding_RRE:
  82.  
  83.         DEBUGF  1,"RRE\n"
  84.  
  85.   @@:
  86.         lea     eax, [esi+4+BYTES_PER_PIXEL]
  87.         cmp     [datapointer], eax
  88.         jae     @f
  89.         call    read_data.more
  90.         jmp     @b
  91.   @@:
  92.  
  93.         lodsd
  94.         bswap   eax
  95.         mov     [subrectangles], eax
  96.  
  97.         DEBUGF  1, "%u subrectangles\n", eax
  98.  
  99. ; Get background color
  100.         call    pixel_to_24bpp
  101.  
  102. ; Calculate first pixel pos
  103.         movzx   eax, [screen.width]
  104.         mul     [rectangle.y]                           ; [screen.width]*[rectangle.y]
  105.         add     eax, [rectangle.x]                      ; [screen.width]*[rectangle.y]+[rectangle.x]
  106.         lea     edi, [framebuffer_data+eax*3]           ; edi = framebuffer_data+([screen.width]*[rectangle.y]+[rectangle.x])*3
  107.  
  108. ; Calculate offset between two rows of pixels
  109.         movzx   eax, [screen.width]
  110.         sub     eax, [rectangle.width]
  111.         lea     ebp, [eax*3]                            ; ebp = ([screen.width]-[rectangle.width])*3
  112.  
  113. ; Draw background rectangle
  114.         push    edi
  115.         mov     eax, ecx
  116.         mov     edx, [rectangle.height]
  117.   .lineloop:
  118.         mov     ecx, [rectangle.width]
  119.   .pixelloop:
  120.         stosw
  121.         rol     eax, 16
  122.         stosb
  123.         rol     eax, 16
  124.         dec     ecx
  125.         jnz     .pixelloop
  126.         add     edi, ebp
  127.         dec     edx
  128.         jnz     .lineloop
  129.         pop     edi
  130.  
  131. ; Any subrectangles at all?
  132.         cmp     [subrectangles], 0
  133.         je      next_rectangle
  134.  
  135.   .subrectangle:
  136.   @@:
  137.         lea     eax, [esi+8+BYTES_PER_PIXEL]
  138.         cmp     [datapointer], eax
  139.         jae     @f
  140.         call    read_data.more
  141.         jmp     @b
  142.   @@:
  143.  
  144. ; Get subrectangle color
  145.         call    pixel_to_24bpp
  146.  
  147. ; Get coordinates
  148.         xor     eax, eax
  149.         lodsw
  150.         xchg    al, ah
  151.         mov     [subrectangle.x], eax
  152.         lodsw
  153.         xchg    al, ah
  154.         mov     [subrectangle.y], eax
  155.         lodsw
  156.         xchg    al, ah
  157.         mov     [subrectangle.width], eax
  158.         lodsw
  159.         xchg    al, ah
  160.         mov     [subrectangle.height], eax
  161.         DEBUGF  1, "Subrectangle: x=%u y=%u width=%u height=%u\n", \
  162.         [subrectangle.x], [subrectangle.y], [subrectangle.width], [subrectangle.height]
  163.  
  164. ; Calculate pos of first pixel
  165.         push    edi
  166.         movzx   eax, [screen.width]
  167.         mul     [subrectangle.y]
  168.         add     eax, [subrectangle.x]
  169.         lea     eax, [eax*3]
  170.         add     edi, eax
  171.  
  172. ; Calculate offset between two rows of pixels
  173.         movzx   eax, [screen.width]
  174.         sub     eax, [subrectangle.width]
  175.         lea     ebp, [eax*3]                            ; ebp = ([screen.width]-[rectangle.width])*3
  176.  
  177. ; Draw the subrectangle
  178.         mov     eax, ecx
  179.         mov     edx, [subrectangle.height]
  180.   .lineloop2:
  181.         mov     ecx, [subrectangle.width]
  182.   .pixelloop2:
  183.         stosw
  184.         rol     eax, 16
  185.         stosb
  186.         rol     eax, 16
  187.         dec     ecx
  188.         jnz     .pixelloop2
  189.         add     edi, ebp
  190.         dec     edx
  191.         jnz     .lineloop2
  192.         pop     edi
  193.         dec     [subrectangles]
  194.         jnz     .subrectangle
  195.         jmp     next_rectangle