Subversion Repositories Kolibri OS

Rev

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