Subversion Repositories Kolibri OS

Rev

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