home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 1: Collection A / 17Bit_Collection_A.iso / files / 290.dms / in.adf / quickrif.source / unvcomp.asm < prev    next >
Encoding:
Assembly Source File  |  1989-01-31  |  4.0 KB  |  126 lines

  1.  
  2.  
  3. ; unvcomp.asm  Copyright 1987 Dancing Flame all rights reserved.
  4. ;
  5. ; This file contains a single function which is set up to be called from
  6. ; C.  Ie the parameters are on the stack instead of registers.
  7. ;       decode_vplane(in, out, linebytes)
  8. ; where in is a bit-plane's worth of vertical-byte-run data
  9. ; and out is a bit-plane that gets completely over-written.
  10. ; Linebytes is the number of bytes-per-line in the out bitplane, and it
  11. ; should certainly be noted that the external pointer variable ytable
  12. ; must be initialized to point to a multiplication table of
  13. ; 0*linebytes, 1*linebytes ... n*linebytes  before this routine is called.
  14. ; The format of "in":
  15. ;   Each column of the bitplane is compressed separately.  A 320x200
  16. ;   bitplane would have 40 columns of 200 bytes each.  The linebytes
  17. ;   parameter is used to count through the columns, it is not in the
  18. ;   "in" data, which is simply a concatenation of columns.
  19. ;
  20. ;   Each columns is an op-count followed by a number of ops.
  21. ;   If the op-count is zero, that's ok, it just means there's no change
  22. ;   in this column from the last frame.
  23. ;   The ops are of two classes, and followed by a varying amount of
  24. ;   data depending on which class.
  25. ;       1. Uniq ops - this is a byte with the hi bit set.  The hi bit is
  26. ;          masked down and the remainder is a count of the number of bytes
  27. ;          of data to copy literally.  It's of course followed by the
  28. ;          data to copy.
  29. ;       2. Same ops - this is a byte with hi bit cleared interpreted as
  30. ;          a count byte.  Its followed by a byte value to repeat count times.
  31. ;   Do bear in mind that the data is compressed vertically rather than
  32. ;   horizontally, so to get to the next byte in the destination (out)
  33. ;   we add linebytes instead of one!
  34. ;
  35.  
  36.  
  37.     public _decode_vplane
  38.  
  39. firstp    set    12
  40. in    set    4+firstp
  41. out    set    8+firstp
  42. linebytes    set    14+firstp
  43.  
  44. _decode_vplane
  45.     movem.l    a2/d4/d5,-(sp) ; save register for aztec.
  46.     move.l    in(sp),a0
  47.     move.l    out(sp),a2
  48.     move.w    linebytes(sp),d2
  49.     move.w    d2,d4  ; make a copy of linebytes to use as a column counter.
  50.     bra    zdcp  ; branch to the end of the column loop.
  51.  
  52. dcp        ; this loop goes through once for each column
  53.     move.l    a2,a1    ; grab a copy of the out column pointer
  54.     clr.w    d0       ; clear hi-byte of op-count for this column
  55.     move.b    (a0)+,d0 ; and get lo-byte from in data stream
  56.     bra    zdcvclp      ; branch to end of op-loop (cause count = 0 is ok!)
  57. dcvclp    clr.w    d1     ;clear hi byte of op
  58.     move.b    (a0)+,d1 ;grab the lo byte from in data stream    
  59.     bmi    dcvuniq      ;if it's a uniq run (yuck!) have to branch
  60. dcvsame    move.b    (a0)+,d3 ;yea! we get to repeat d3 d1 times!
  61.     move.w    d1,d5 ; so set up a "tower" to do it.  
  62.     asr.w    #3,d5 ; d5 is number of loops through tower
  63.     and.w    #7,d1 ; d1 is where in tower to start.
  64.     add.w    d1,d1 ; 4 bytes/tower element means we add to self twice
  65.     add.w    d1,d1
  66.     neg.w    d1
  67.     jmp    34+same_tower(pc,d1) ;why the 34 isn't 32 = 8(els in tower)*4
  68.                              ;is pure pure voodoo.  It's not just the
  69.                              ;jmp instruction....
  70. same_tower
  71.     move.b    d3,(a1)
  72.     adda.w    d2,a1
  73.     move.b    d3,(a1)
  74.     adda.w    d2,a1
  75.     move.b    d3,(a1)
  76.     adda.w    d2,a1
  77.     move.b    d3,(a1)
  78.     adda.w    d2,a1
  79.     move.b    d3,(a1)
  80.     adda.w    d2,a1
  81.     move.b    d3,(a1)
  82.     adda.w    d2,a1
  83.     move.b    d3,(a1)
  84.     adda.w    d2,a1
  85.     move.b    d3,(a1)
  86.     adda.w    d2,a1
  87.     dbra    d5,same_tower
  88.     dbra    d0,dcvclp ; through with decoding one op, go fetch next op
  89.     bra    z1dcp         ; through with this column even.
  90.  
  91. dcvuniq    and.b    #$7f,d1 ;it's a uniq run, so mask down to get count
  92.     move.w    d1,d5       ; and start setting up another tower....
  93.     asr.w    #3,d5
  94.     and.w    #7,d1
  95.     add.w    d1,d1
  96.     add.w    d1,d1
  97.     neg.w    d1
  98.     jmp    34+uniq_tower(pc,d1)
  99. uniq_tower
  100.     move.b    (a0)+,(a1)
  101.     adda.w    d2,a1
  102.     move.b    (a0)+,(a1)
  103.     adda.w    d2,a1
  104.     move.b    (a0)+,(a1)
  105.     adda.w    d2,a1
  106.     move.b    (a0)+,(a1)
  107.     adda.w    d2,a1
  108.     move.b    (a0)+,(a1)
  109.     adda.w    d2,a1
  110.     move.b    (a0)+,(a1)
  111.     adda.w    d2,a1
  112.     move.b    (a0)+,(a1)
  113.     adda.w    d2,a1
  114.     move.b    (a0)+,(a1)
  115.     adda.w    d2,a1
  116.     dbra    d5,uniq_tower
  117. zdcvclp dbra    d0,dcvclp
  118.  
  119.  
  120. z1dcp    addq.l    #1,a2 ;all through with this column, so put a2 to next one
  121. zdcp    dbra    d4,dcp ; maybe we're all done?
  122.     movem.l    (sp)+,a2/d4/d5
  123.     rts
  124.  
  125.