home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / OWLSRC.PAK / DIBBLT16.ASM < prev    next >
Encoding:
Assembly Source File  |  1997-05-06  |  4.1 KB  |  204 lines

  1. ;//---------------------------------------------------------------------------
  2. ;// ObjectWindows
  3. ;// Copyright (c) 1995, 1996 by Borland International, All rights Reserved
  4. ;//
  5. ;//$Revision:   10.2  $
  6. ;// 
  7. ;//   DibSpriteBlt8 : 16 Bit Non-GDI SpriteBlt for 8bpp DIBs
  8. ;//   DibCopyBlt8 :   16 Bit Non-GDI CopyBlt for 8bpp DIBs
  9. ;// 
  10. ;//---------------------------------------------------------------------------
  11.     page ,132
  12.  
  13.     TITLE DibBlt16.asm
  14.  
  15. _TEXT   SEGMENT BYTE PUBLIC 'CODE'
  16. _TEXT   ENDS
  17.  
  18. _DATA   SEGMENT DWORD PUBLIC 'DATA'
  19. _DATA   ENDS
  20.  
  21. DGROUP  GROUP   _DATA
  22.  
  23.         ASSUME  CS: _TEXT, DS: DGROUP
  24.  
  25. _DATA   SEGMENT
  26. ALIGN   4
  27. srcOffset DD  0000  ; Source Offset.
  28. dstOffset DD  0000  ; Destination Offset.
  29. _DATA   ENDS
  30.  
  31. _TEXT   SEGMENT
  32.  
  33. ;//---------------------------------------------------------------------------
  34. ;
  35. ;void WINAPI
  36. ;DibCopyBlt(uint8 HUGE* dstBits, uint32 width, uint32 height, uint32 dstPitch,
  37. ;           uint8 HUGE* srcBits, uint32 srcPitch);
  38.  
  39. public DIBCOPYBLT8
  40. DIBCOPYBLT8 proc far
  41.  
  42. dstBits   EQU [bp+26]  ; Destination bits surface
  43. wdth      EQU [bp+22]  ; Bits Width
  44. height    EQU [bp+18]  ; Bits Height
  45. dstPitch  EQU [bp+14]  ; Destination scan pitch
  46.  
  47. srcBits   EQU [bp+10]  ; Source bits surface
  48. srcPitch  EQU [bp+6]   ; Source scan pitch
  49.  
  50.     .386
  51.  
  52.     push bp
  53.     mov  bp,sp
  54.  
  55.     push ds
  56.     push es
  57.     push esi
  58.     push edi
  59.  
  60.     mov ecx, wdth
  61.     or  ecx,ecx
  62.     jz  DCBComplete         ; No Width
  63.  
  64.     mov edx, height         ; EDX is line counter
  65.     or edx,edx
  66.     jz DCBComplete          ; No Width
  67.  
  68.     xor esi, esi
  69.     lds si, srcBits         ; DS:[ESI] point to source
  70.  
  71.     xor edi, edi
  72.     les di, dstBits         ; ES:[EDI] point to dest
  73.  
  74.     sub srcPitch,ecx
  75.     sub dstPitch,ecx
  76.  
  77.     mov ebx,ecx
  78.     shr ebx,2
  79.  
  80.     mov eax,ecx
  81.     and eax,11b
  82.  
  83. DCBLoopY:
  84.  
  85.     mov ecx,ebx
  86.     rep movs dword ptr es:[edi], dword ptr ds:[esi]
  87.     mov ecx,eax
  88.     rep movs byte ptr es:[edi], byte ptr ds:[esi]
  89.     add esi,srcPitch
  90.     add edi,dstPitch
  91.     dec edx
  92.     jnz short DCBLoopY
  93.  
  94. DCBComplete:
  95.  
  96.     pop edi
  97.     pop esi
  98.     pop es
  99.     pop ds
  100.     pop bp
  101.  
  102.     ret
  103.  
  104.     .286
  105.  
  106. DIBCOPYBLT8 endp
  107.  
  108. ;//---------------------------------------------------------------------------
  109. ;
  110. ;void WINAPI
  111. ;DibSpriteBlt8(uint8 HUGE* dstBits, uint32 width, uint32 height, uint32 dstPitch,
  112. ;             uint8 HUGE* srcBits, uint32 srcPitch, uint8 transparent);
  113.  
  114. public DIBSPRITEBLT8
  115. DIBSPRITEBLT8 proc far
  116.  
  117. dstBits   EQU [bp+28]  ; Destination bits surface
  118. wdth      EQU [bp+24]  ; Bits Width
  119. height    EQU [bp+20]  ; Bits Height
  120. dstPitch  EQU [bp+16]  ; Destination scan pitch
  121.  
  122. srcBits   EQU [bp+12]  ; Source bits surface
  123. srcPitch  EQU [bp+8]   ; Source scan pitch
  124. trans     EQU [bp+6]   ; Transparent color
  125.  
  126.     .386
  127.  
  128.     push bp
  129.     mov  bp,sp
  130.  
  131.     push ds
  132.     push es
  133.     push esi
  134.     push edi
  135.  
  136.     mov ecx, wdth
  137.     jecxz DSBComplete       ; No Source Width
  138.  
  139.     mov edx, height         ; EDX is line counter
  140.     mov ah, trans           ; AH has transparency color
  141.  
  142.     xor esi, esi
  143.     lds si, srcBits         ; DS:[ESI] point to source
  144.     mov srcOffset, esi      ; save offset
  145.  
  146.     xor edi, edi
  147.     les di, dstBits         ; ES:[EDI] point to dest
  148.     mov dstOffset, edi      ; save offset
  149.  
  150. DSBLoopY:
  151.  
  152.     and edx, edx
  153.     jz  DSBComplete
  154.  
  155.     mov esi, srcOffset      ; DS:[ESI] point to source
  156.     mov edi, dstOffset      ; ES:[EDI] point to dest
  157.     mov ecx, wdth           ; ECX is pixel counter
  158.  
  159. DSBLoopX: 
  160.  
  161.     mov al, ds:[esi]
  162.     cmp al, ah
  163.     jz  DSBLoopXMasked
  164.  
  165.     mov es:[edi], al
  166.  
  167. DSBLoopXMasked:
  168.  
  169.     inc esi
  170.     inc edi
  171.  
  172.     dec ecx
  173.     jnz DSBLoopX
  174.  
  175. ; move on to the start of the next line
  176.  
  177.     mov esi, srcOffset
  178.     add esi, srcPitch
  179.     mov srcOffset, esi
  180.  
  181.     mov esi, dstOffset
  182.     add esi, dstPitch
  183.     mov dstOffset, esi
  184.  
  185.     dec edx                 ; line counter
  186.     jmp DSBLoopY
  187.  
  188. DSBComplete:
  189.  
  190.     pop edi
  191.     pop esi
  192.     pop es
  193.     pop ds
  194.     pop bp
  195.  
  196.     ret
  197.  
  198.     .286
  199.  
  200. DIBSPRITEBLT8 endp
  201.  
  202. _TEXT   ends
  203.         END
  204.