Subversion Repositories Kolibri OS

Rev

Rev 5717 | 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. load_pixel_rre:             ; 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 if BITS_PER_PIXEL = 24
  69.  
  70.         mov     ecx, [esi]
  71.         and     ecx, 0x00ffffff
  72.         add     esi, 3
  73.  
  74. else if BITS_PER_PIXEL = 32
  75.  
  76.         mov     ecx, [esi]
  77.         and     ecx, 0x00ffffff
  78.         add     esi, 4
  79.  
  80. end if
  81.         pop     eax
  82.  
  83.         ret
  84.  
  85. encoding_RRE:
  86.  
  87.         DEBUGF  1,"RRE\n"
  88.  
  89.   @@:
  90.         lea     eax, [esi+4+BYTES_PER_PIXEL]
  91.         cmp     [datapointer], eax
  92.         jae     @f
  93.         call    read_data.more
  94.         jmp     @b
  95.   @@:
  96.  
  97.         lodsd
  98.         bswap   eax
  99.         mov     [subrectangles], eax
  100.  
  101.         DEBUGF  1, "%u subrectangles\n", eax
  102.  
  103. ; Get background color
  104.         call    load_pixel_rre
  105.  
  106. ; Calculate first pixel pos
  107.         movzx   eax, [screen.width]
  108.         mul     [rectangle.y]                           ; [screen.width]*[rectangle.y]
  109.         add     eax, [rectangle.x]                      ; [screen.width]*[rectangle.y]+[rectangle.x]
  110.         lea     edi, [framebuffer+eax*3]                ; edi = framebuffer_data+([screen.width]*[rectangle.y]+[rectangle.x])*3
  111.  
  112. ; Calculate offset between two rows of pixels
  113.         movzx   eax, [screen.width]
  114.         sub     eax, [rectangle.width]
  115.         lea     ebp, [eax*3]                            ; ebp = ([screen.width]-[rectangle.width])*3
  116.  
  117. ; Draw background rectangle
  118.         push    edi
  119.         mov     eax, ecx
  120.         mov     edx, [rectangle.height]
  121.   .lineloop:
  122.         mov     ecx, [rectangle.width]
  123.   .pixelloop:
  124.         stosw
  125.         rol     eax, 16
  126.         stosb
  127.         rol     eax, 16
  128.         dec     ecx
  129.         jnz     .pixelloop
  130.         add     edi, ebp
  131.         dec     edx
  132.         jnz     .lineloop
  133.         pop     edi
  134.  
  135. ; Any subrectangles at all?
  136.         cmp     [subrectangles], 0
  137.         je      next_rectangle
  138.  
  139.   .subrectangle:
  140.   @@:
  141.         lea     eax, [esi+8+BYTES_PER_PIXEL]
  142.         cmp     [datapointer], eax
  143.         jae     @f
  144.         call    read_data.more
  145.         jmp     @b
  146.   @@:
  147.  
  148. ; Get subrectangle color
  149.         call    load_pixel_rre
  150.  
  151. ; Get coordinates
  152.         xor     eax, eax
  153.         lodsw
  154.         xchg    al, ah
  155.         mov     [subrectangle.x], eax
  156.         lodsw
  157.         xchg    al, ah
  158.         mov     [subrectangle.y], eax
  159.         lodsw
  160.         xchg    al, ah
  161.         mov     [subrectangle.width], eax
  162.         lodsw
  163.         xchg    al, ah
  164.         mov     [subrectangle.height], eax
  165.         DEBUGF  1, "Subrectangle: x=%u y=%u width=%u height=%u\n", \
  166.         [subrectangle.x], [subrectangle.y], [subrectangle.width], [subrectangle.height]
  167.  
  168. ; Calculate pos of first pixel
  169.         push    edi
  170.         movzx   eax, [screen.width]
  171.         mul     [subrectangle.y]
  172.         add     eax, [subrectangle.x]
  173.         lea     eax, [eax*3]
  174.         add     edi, eax
  175.  
  176. ; Calculate offset between two rows of pixels
  177.         movzx   eax, [screen.width]
  178.         sub     eax, [subrectangle.width]
  179.         lea     ebp, [eax*3]                            ; ebp = ([screen.width]-[rectangle.width])*3
  180.  
  181. ; Draw the subrectangle
  182.         mov     eax, ecx
  183.         mov     edx, [subrectangle.height]
  184.   .lineloop2:
  185.         mov     ecx, [subrectangle.width]
  186.   .pixelloop2:
  187.         stosw
  188.         rol     eax, 16
  189.         stosb
  190.         rol     eax, 16
  191.         dec     ecx
  192.         jnz     .pixelloop2
  193.         add     edi, ebp
  194.         dec     edx
  195.         jnz     .lineloop2
  196.         pop     edi
  197.         dec     [subrectangles]
  198.         jnz     .subrectangle
  199.         jmp     next_rectangle