home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c010 / 1.ddi / FLILIB3.ZIP / FLISRC3.ZIP / SKIP.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-08-29  |  2.5 KB  |  135 lines

  1. ;skip.asm - low level stuff to help compress pictures into FLI's.
  2. ;:ts=10
  3.  
  4.     TITLE    skip
  5.  
  6.     dosseg
  7.     .model    large
  8.     .code
  9.  
  10.     PUBLIC _fii_tnskip
  11. ;fii_tnskip(s1,s2,bcount,mustmatch)
  12. s1    equ    [bp+4+2]
  13. s1s    equ    [bp+6+2]
  14. s2    equ    [bp+8+2]
  15. s2s    equ    [bp+10+2]
  16. bcount    equ    [bp+12+2]
  17. mmatch    equ    [bp+14+2]
  18. _fii_tnskip    proc far
  19. difcount    equ    [bp-2]
  20.     push bp
  21.     mov bp,sp
  22.     sub sp,4    ;space for locals
  23.     push bx
  24.     push si
  25.     push di
  26.     push ds
  27.  
  28.     mov word ptr difcount,0 ;zero out return value
  29.     lds si,s1
  30.     les di,s2
  31.     mov bx,bcount
  32.     mov dx,mmatch
  33.  
  34. tnsloop:
  35.     ;calculate number of pixels different in s1 and s2 into ax
  36.     mov cx,bx
  37.     inc cx
  38.     repne cmpsb
  39.     mov ax,bx
  40.     sub ax,cx
  41.     dec si    ;move source pointers just past this different run
  42.     dec di
  43.     sub bx,ax
  44.     add difcount,ax ;and different count to return value
  45.  
  46.     cmp bx,dx        ;see if near the end...
  47.     js endcheck
  48.  
  49.     ;see if enough in a row match to break out of this
  50.     mov cx,dx
  51.     repe cmpsb
  52.     jz zfii_tnskip    ;if all of them match between s1 and s2 go home
  53.     inc cx
  54.     mov ax,dx        ;calc ones that do match into ax
  55.     sub ax,cx
  56.     add difcount,ax ;add it to difcount return value
  57.     sub bx,ax        ;sub it from pixels left to examine
  58.     dec si        ;update s1,s2 pointers
  59.     dec di
  60.     jmp tnsloop
  61. endcheck:
  62.     ;check last couple of pixels
  63.     mov cx,bx
  64.     inc cx
  65.     repe cmpsb
  66.     jcxz zfii_tnskip    ;if all of them match between s1 and s2 go home
  67.     add difcount,bx ;otherwise assume no skip this time around
  68.  
  69. zfii_tnskip:
  70.     mov ax,difcount
  71.     pop ds
  72.     pop di
  73.     pop si
  74.     pop bx
  75.     mov sp,bp
  76.     pop bp
  77.     ret
  78. _fii_tnskip    endp
  79.  
  80.  
  81.     PUBLIC    _fii_tnsame
  82. ;fii_tnsame(s2x,wcount,mustmatch)
  83. s2x    equ [bp+4+2]
  84. wcount    equ word ptr[bp+8+2]
  85. mumatch equ [bp+10+2]
  86. _fii_tnsame    PROC far
  87.     push bp
  88.     mov bp,sp
  89.     push ds
  90.     push si
  91.     push di
  92.     push bx
  93.  
  94.                 
  95.     les    di,s2x        ;get starting address in es:di
  96.         mov     dx,wcount               ;dx is 'dif_count' return value
  97.     mov    bx,dx        ;bx is # of pixels left
  98.     mov    si,0        ;si is # of pixels examined
  99. alp:
  100.                 ;break out of loop if less than 4 pixels
  101.                 ;left to examine
  102.     cmp    bx,mumatch
  103.     js    zalp
  104.  
  105.     ;same_count = i86_bsame(s2x,wcount)
  106.     mov cx,bx
  107.     mov al,es:[di]
  108.     rep scasb
  109.     inc cx
  110.     sub di,2
  111.     mov ax,bx
  112.     sub ax,cx
  113.  
  114.     cmp ax,mumatch            ;if mustmatch or more
  115.     jns gotsame        ;go truncate dif_count
  116.     add    si,ax
  117.     add    di,ax
  118.     sub    bx,ax
  119.     jmp    alp
  120. gotsame:
  121.     mov    dx,si        
  122. zalp:
  123.     mov ax,dx        ;return dif_count
  124.     pop bx
  125.     pop di
  126.     pop si
  127.     pop ds
  128.     pop bp
  129.     ret
  130.  
  131. _fii_tnsame    ENDP
  132.  
  133.  
  134. END
  135.