home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / apps / dtp / pgsmodst / atariimp / tiff.s < prev    next >
Text File  |  1991-06-21  |  68KB  |  2,923 lines

  1.  Include "equ.h"
  2.  Include "impequ.h"
  3.  
  4. TypeBYTE    equ    1
  5. TypeASCII    equ    2
  6. TypeSHORT    equ    3
  7. TypeLONG    equ    4
  8. TypeRATIONAL    equ    5
  9.  
  10.  
  11.  SECTION TIFF,CODE,PUBLIC
  12.  
  13. ***************************************************
  14. ***                        ***
  15. ***************************************************
  16. dumbentry:
  17.     clr.l    d0
  18.     rts
  19.  
  20.     dc.l    "IMPP"        ; magik number for pic import
  21.     dc.w    200
  22.     dc.l    0
  23.  
  24. table:    dc.l    0
  25.     dc.l    name,special,check,TIFF
  26.  
  27.  
  28. ***********************************
  29. ***     Is it really TIFF?      ***
  30. ***********************************
  31. check:    move.l    table,a0
  32.     move.l    buff1(a0),a1
  33.     move.l    (a1),a1
  34.     cmp.w    #"MM",(a1)
  35.     beq    chk1
  36.     cmp.w    #"II",(a1)
  37.     bne    never
  38.     cmp.w    #$2a00,2(a1)
  39.     bne    never
  40.     bra    right
  41.  
  42. chk1:    cmp.w    #$002a,2(a1)
  43.     bne    never
  44.     bra    right
  45.  
  46.  
  47. ***********************************
  48. ***                             ***
  49. ***********************************
  50. TIFF:    move.l    table,a1
  51.     move.l    flen(a1),a0
  52.     move.l    (a0),piclength
  53.  
  54.     move.l    f_openr(a1),a0
  55.     jsr    (a0)
  56.     beq    rrts
  57.  
  58.         clr.l   picture
  59.         clr.l   prefix
  60.         clr.l   suffix
  61.         clr.l   outcode
  62.         
  63.     move.l    table,a0 
  64.     move.l    spclnum(a0),a0
  65.     cmp.w    #1,(a0)
  66.     beq    impobj
  67.         
  68.         
  69. ***********************************
  70. ***                             ***
  71. ***********************************
  72. imppic:    move.l    table,a0
  73.     move.l    p_open(a0),a0
  74.     jsr    (a0)
  75.     beq    abort0                  ;do f_closer and exit
  76.  
  77.         move.l  sp,spsave               ;for errrts conditions
  78.     bsr    getpicinfo
  79.  
  80.     move.l    table,a4
  81.     move.l    cwptr(a4),a4        ;ptr to window handle
  82.     move.l    (a4),a4            ;window handle
  83.     move.l    (a4),a4            ;ptr to window structure
  84.  
  85.     lea    pic,a0
  86.     move.w    pc_Type(a0),pi_Type(a4)
  87.     move.w    pc_SFreq(a0),pi_SFreq(a4)
  88.     move.w    pc_SAngle(a0),pi_SAngle(a4)
  89.     move.w    pc_SSpot(a0),pi_SSpot(a4)
  90.     move.l    pc_SMap(a0),pi_SMap(a4)
  91.     move.l    pc_SMap+4(a0),pi_SMap+4(a4)
  92.     move.w    pc_XDpi(a0),pi_XDpi(a4)
  93.     move.w    pc_YDpi(a0),pi_YDpi(a4)
  94.     move.w    pc_W(a0),pi_W(a4)
  95.     move.w    pc_H(a0),pi_H(a4)
  96.     move.w    pc_Width(a0),pi_Width(a4)
  97.     move.w    pc_BitPln(a0),pi_BitPln(a4)
  98.     move.w    pc_Palet(a0),pi_Palet(a4)
  99.  
  100.     move.w    pi_Palet(a4),d1
  101.     mulu    #pl_Sizeof,d1
  102.         move.l  d1,palsize
  103.     move.w    pi_Width(a4),d0
  104.     mulu    pi_BitPln(a4),d0
  105.     mulu    pi_H(a4),d0
  106.     add.l    d1,d0        ;size of bitmap +( 4 words * #colors)
  107.  
  108.     clr.w    d1
  109.     clr.w    d2
  110.     move.l    table,a0
  111.     move.l    m_alloc(a0),a0
  112.     jsr    (a0)
  113.     beq    abortpic
  114.  
  115.     move.l    table,a3
  116.     move.l    cwptr(a3),a3
  117.     move.l    (a3),a3
  118.     move.l    (a3),a3
  119.     move.l    a0,pi_Ptr(a3)
  120.     move.l    (a0),a4
  121.         move.l  a4,palptr       
  122.         
  123.         add.l   palsize,a4              ;palette data comes first
  124.     move.l    a4,picptr
  125.         move.l  a4,picptrsave
  126.         
  127.         clr.l   d0
  128.         move.w  pic+pc_Width,d0         ;for horizontal differencing
  129.         mulu    pic+pc_H,d0
  130.         move.w  pic+pc_BitPln,d1
  131.         subq.w  #1,d1
  132.         mulu    d1,d0
  133.         add.l   d0,a4
  134.         move.l  a4,picptr2
  135.         move.l  a4,picptrsave2
  136.  
  137.     bsr    putpic
  138.         
  139.         cmp.w   #2,predictor
  140.         bne     imp1
  141.         
  142.         bsr     horidif2
  143.  
  144. imp1:    move.l    table,a0
  145.     move.l    p_close(a0),a0
  146.     jsr    (a0)
  147.  
  148.     move.l    table,a0
  149.     move.l    f_closer(a0),a0
  150.     jmp    (a0)
  151.  
  152.  
  153. abortpic:
  154.         move.l  spsave,sp
  155.     bsr    purgepic
  156.  
  157.     move.l    table,a0
  158.     move.l    p_abort(a0),a0
  159.     jsr    (a0)
  160.  
  161. abort0:    move.l    table,a0
  162.     move.l    f_closer(a0),a0
  163.     jmp    (a0)
  164.         
  165.         
  166. ***********************************
  167. ***                             ***
  168. ***********************************
  169. impobj:    move.l    table,a0
  170.     move.l    o_open(a0),a0
  171.     jsr    (a0)
  172.     beq    abort0
  173.  
  174.         move.l  sp,spsave
  175.     bsr    getpicinfo
  176.         
  177.     move.b    #tpic,object+ob_Type
  178.     clr.l    object+ob_Left
  179.     clr.l    object+ob_Top
  180.  
  181.     move.w    pic+pc_W,d1
  182.     move.l    #7200,d0
  183.     bsr    Mulu1632
  184.     move.w    pic+pc_XDpi,d2
  185.     bsr    Divu1648
  186.     move.l    d0,object+ob_Right
  187.  
  188.     move.w    pic+pc_H,d1
  189.     move.l    #7200,d0
  190.     bsr    Mulu1632
  191.     move.w    pic+pc_YDpi,d2
  192.     bsr    Divu1648
  193.     move.l    d0,object+ob_Bottom
  194.  
  195.     clr.b    object+ob_Flag
  196.     clr.w    object+ob_Slant
  197.     clr.w    object+ob_Twist
  198.     move.w    #50,object+ob_LWidth        ;1 point line
  199.     clr.b    object+ob_LType            ;no line
  200.     move.b    #1,object+ob_LColor        ;black line
  201.     clr.b    object+ob_FType            ;no fill
  202.     move.b    #1,object+ob_FColor        ;black fill
  203.     clr.b    object+ob_LBegin
  204.     clr.b    object+ob_LEnd
  205.     move.w    #900,object+ob_HStandOff    ;1/8 inch
  206.     move.w    #900,object+ob_VStandOff    ;1/8 inch
  207.  
  208.     move.l    table,a1
  209.     move.l    o_obj(a1),a1
  210.     lea    object,a0
  211.     jsr    (a1)
  212.     beq    abortobj
  213.  
  214.     move.w    pic+pc_Width,d0
  215.     mulu    pic+pc_BitPln,d0
  216.     mulu    pic+pc_H,d0
  217.     move.w    pic+pc_Palet,d1
  218.     mulu    #pl_Sizeof,d1
  219.         move.l  d1,palsize
  220.     add.l    d1,d0
  221.     add.l    #pc_Sizeof,d0
  222.  
  223.     move.l    table,a0
  224.     move.l    o_malloc(a0),a0
  225.     jsr    (a0)
  226.     beq    abortobj
  227.  
  228.     lea    pic,a1
  229.     clr.l    pc_DPtr(a1)
  230.     clr.w    pc_DScale(a1)
  231.     move.w    pc_Palet(a1),d0
  232.     mulu    #pl_Sizeof,d0
  233.     add.l    #pc_Sizeof,d0
  234.     move.l    d0,pc_Ptr(a1)
  235.  
  236.     move.w    #pc_Sizeof/2-1,d0
  237. oppic1:    move.w    (a1)+,(a0)+
  238.     dbf    d0,oppic1
  239.  
  240.         move.l  a0,palptr       ;palette data comes after pic struct
  241.         move.l  palsize,d0
  242.         add.l   d0,a0
  243.         
  244.     move.l    a0,picptr       ;pic data comes after palette data
  245.         move.l  a0,picptrsave
  246.  
  247.         clr.l   d0        
  248.         move.w  pic+pc_Width,d0         ;for horizontal differencing
  249.         mulu    pic+pc_H,d0
  250.         move.w  pic+pc_BitPln,d1
  251.         subq.w  #1,d1
  252.         mulu    d1,d0
  253.         add.l   d0,a0
  254.         move.l  a0,picptr2
  255.         move.l  a0,picptrsave2
  256.         
  257.     bsr    putpic
  258.         
  259.         cmp.w   #2,predictor
  260.         bne     oppic2
  261.         bsr     horidif2
  262.  
  263. oppic2: move.l    table,a0
  264.     move.l    o_close(a0),a0
  265.     jsr    (a0)
  266.  
  267.     move.l    table,a0
  268.     move.l    f_closer(a0),a0
  269.     jmp    (a0)
  270.  
  271. abortobj:
  272.         move.l  spsave,sp
  273.     bsr    purgepic
  274.  
  275.     move.l    table,a0
  276.     move.l    o_abort(a0),a0
  277.     jsr    (a0)
  278.  
  279.     move.l    table,a0
  280.     move.l    f_closer(a0),a0
  281.     jmp    (a0)
  282.         
  283.         
  284. ***********************************
  285. ***                             ***
  286. ***********************************
  287. getpicinfo:
  288.     lea    pic,a0
  289.     move.w    #pc_Sizeof-1,d0
  290. gpi1:    clr.b    (a0)+
  291.     dbra    d0,gpi1
  292.  
  293.     clr.l    picture
  294.     move.l    table,a1
  295.     move.l    piclength,d0
  296.     clr.w    d1
  297.     clr.w    d2
  298.     move.l    m_alloc(a1),a1
  299.     jsr    (a1)            ; allocate memory for the picture
  300.         beq     errrts
  301.         
  302.     move.l    a0,picture
  303.  
  304.         move.l  #16384,d0
  305.         clr.l   d1
  306.         clr.l   d2
  307.         move.l  table,a1
  308.         move.l  m_alloc(a1),a1
  309.         jsr     (a1)
  310.         beq     errrts
  311.         move.l  a0,prefix
  312.  
  313.         move.l  #4096,d0
  314.         clr.l   d1
  315.         clr.l   d2
  316.         move.l  table,a1
  317.         move.l  m_alloc(a1),a1
  318.         jsr     (a1)
  319.         beq     errrts
  320.         move.l  a0,suffix
  321.         
  322.         move.l  #1025,d0
  323.         clr.l   d1
  324.         clr.l   d2
  325.         move.l  table,a1
  326.         move.l  m_alloc(a1),a1
  327.         jsr     (a1)
  328.         beq     errrts
  329.         move.l  a0,outcode
  330.  
  331.     clr.l    picoffset
  332.         move.l  picture,a0
  333.     move.l    (a0),a0
  334.     move.l    piclength,d0
  335.     move.l    table,a1
  336.     move.l    f_getr(a1),a1
  337.     jsr    (a1)
  338.     beq    errrts
  339.  
  340.     clr.b    byteorder
  341.     bsr    pgetw        ; "FORM"
  342.     cmp.w    #"II",d0
  343.     bne    gpi2
  344.     move.b    #1,byteorder
  345. gpi2:
  346.     jsr    pgetw            ;version number ($42)
  347.     jsr    pgetl
  348.     move.l    d0,picoffset
  349.     jsr    pgetw
  350.     move.w    d0,tagcount
  351. *
  352. * some defaults set up here!
  353. *
  354.     move.w    #1,bps
  355.         move.l  #0,sbc
  356.     move.w    #1,compression
  357.     move.w    #0,photom
  358.     move.w    #1,planar
  359.     move.w    #1,predictor
  360.     move.w    #1,sppixel
  361.     move.w    #2,resunits
  362.     move.w    #300,xres
  363.     move.w    #300,yres
  364.         move.l  #0,rps
  365.         move.w  #0,palcount
  366.         
  367. gptagloop:
  368.     jsr    pgetw
  369.     move.w    d0,tagid
  370.     jsr    pgetw
  371.     move.w    d0,tagtype
  372.     jsr    pgetl
  373.     move.l    d0,taglength
  374.     cmp.l    #10,d0
  375.     bcc    gptg03
  376.  
  377.     lea    typelen,a0
  378.     move.l    taglength,d0
  379.     move.w    tagtype,d1
  380.     move.b    0(a0,d1.w),d1
  381.     lsl.l    d1,d0
  382.     cmp.l    #4,d0
  383.     bls    gptg01
  384. gptg03:    jsr    pgetl
  385.     move.l    d0,tagvalue
  386.     bra    gptg02
  387. gptg01:    move.l    picoffset,tagvalue
  388.     addq.l    #4,picoffset
  389.  
  390. gptg02:    lea    taglist,a0
  391. gptg1:    move.w    (a0)+,d0
  392.     beq    gptg9
  393.     cmp.w    tagid,d0
  394.     beq    gptg8
  395.     lea    4(a0),a0
  396.     bra    gptg1
  397.  
  398. gptg8:    move.l    (a0),a0
  399.     jsr    (a0)
  400.  
  401. gptg9:    subq.w    #1,tagcount
  402.     bne    gptagloop
  403.  
  404.     lea    pic,a0
  405.     lea    pctypetbl,a1
  406.     move.w    photom,d0
  407.     move.b    0(a1,d0.w),d0
  408.     move.w    d0,pc_Type(a0)
  409.     move.w    #-1,pc_SFreq(a0)
  410.     move.w    #-1,pc_SAngle(a0)
  411.     move.w    #0,pc_SSpot(a0)
  412.     move.l    #0,pc_SMap(a0)
  413.     move.l    #0,pc_SMap+4(a0)
  414.     move.w    xres,pc_XDpi(a0)
  415.     move.w    yres,pc_YDpi(a0)
  416.     move.w    pc_W(a0),d0
  417.     add.w    #15,d0
  418.     lsr.w    #3,d0
  419.     bclr    #0,d0
  420.     move.w    d0,pc_Width(a0)
  421.     move.w    bps,d0
  422.     mulu    sppixel,d0
  423.     move.w    d0,pc_BitPln(a0)
  424.         move.l  palcount,d0
  425.         divu    #3,d0
  426.     move.w    d0,pc_Palet(a0)
  427.     rts
  428.  
  429.  
  430. *******************************************
  431. ***    BitsPerSample            ***
  432. *******************************************
  433. tag_bsample:
  434.     bsr    getdata
  435.     move.w    d0,bps
  436.     rts
  437.  
  438.  
  439. *******************************************
  440. ***    ColorMap            ***
  441. *******************************************
  442. tag_colormap:
  443.         move.l  taglength,palcount
  444.         move.l  tagvalue,cmapoffset
  445.     rts
  446.  
  447.  
  448. *******************************************
  449. ***    ColorResponseCurves        ***
  450. *******************************************
  451. tag_crcurves:
  452.     rts
  453.  
  454.  
  455. *******************************************
  456. ***    Compression            ***
  457. *******************************************
  458. tag_compression:
  459.     bsr    getdata
  460.     move.w    d0,compression
  461.     rts
  462.  
  463.  
  464. *******************************************
  465. ***    GrayResponseCurve        ***
  466. *******************************************
  467. tag_grcurve:
  468.     rts
  469.  
  470.  
  471. *******************************************
  472. ***    GrayResponseUnit        ***
  473. *******************************************
  474. tag_grunit:
  475.     rts
  476.  
  477.  
  478. *******************************************
  479. ***    ImageLength (height)        ***
  480. *******************************************
  481. tag_iheight:
  482.     bsr    getdata
  483.     move.w    d0,pic+pc_H
  484.     rts
  485.  
  486.  
  487. *******************************************
  488. ***    ImageWidth            ***
  489. *******************************************
  490. tag_iwidth:
  491.     bsr    getdata
  492.     move.w    d0,pic+pc_W
  493.     rts
  494.  
  495.  
  496. *******************************************
  497. ***    NewSubfileType            ***
  498. *******************************************
  499. tag_newsftype:
  500.     rts
  501.  
  502.  
  503. *******************************************
  504. ***    PhotometricInterpretation    ***
  505. *******************************************
  506. tag_photometric:
  507.     bsr    getdata
  508.     move.w    d0,photom
  509.     rts
  510.  
  511.  
  512. *******************************************
  513. ***    PlanarConfiguration        ***
  514. *******************************************
  515. tag_planar:
  516.     bsr    getdata
  517.     move.w    d0,planar
  518.     rts
  519.  
  520.  
  521. *******************************************
  522. ***    Predictor            ***
  523. *******************************************
  524. tag_predictor:
  525.     bsr    getdata
  526.     move.w    d0,predictor
  527.             rts
  528.  
  529.  
  530. *******************************************
  531. ***    ResolutionUnit            ***
  532. *******************************************
  533. tag_resolution:
  534.     bsr    getdata
  535.     move.w    d0,resunits
  536.     rts
  537.  
  538.  
  539. *******************************************
  540. ***    StripByteCount            ***
  541. *******************************************
  542. tag_stripbytecnt:
  543.     move.l    tagvalue,sbc
  544.         move.w  tagtype,sbctype
  545.     rts
  546.  
  547.  
  548. *******************************************
  549. ***    RowsPerStrip            ***
  550. *******************************************
  551. tag_rpstrip:
  552.         bsr     getdata
  553.         move.l  d0,rps          
  554.     rts
  555.  
  556.  
  557. *******************************************
  558. ***    SamplesPerPixel            ***
  559. *******************************************
  560. tag_sppixel:
  561.     bsr    getdata
  562.     move.w    d0,sppixel
  563.     rts
  564.  
  565.  
  566. *******************************************
  567. ***    XResolution            ***
  568. *******************************************
  569. tag_xres:
  570.     bsr    getdata
  571.         cmp.w   #20,d0          ;kludge for ADPro's TIFF files
  572.         bcc     tagx1           ;
  573.         move.w  #75,d0          ;
  574. tagx1:  move.w    d0,xres
  575.     rts
  576.  
  577.  
  578. *******************************************
  579. ***    YResolution            ***
  580. *******************************************
  581. tag_yres:
  582.     bsr    getdata
  583.         cmp.w   #20,d0          ;kludge for ADPro's TIFF files
  584.         bcc     tagy1           ;
  585.         move.w  #75,d0          ;
  586. tagy1:    move.w    d0,yres
  587.     rts
  588.  
  589.  
  590.  
  591. *******************************************
  592. ***                    ***
  593. *******************************************
  594. putpic:
  595.     clr.l    picoffset
  596.  
  597.     bsr    pgetw        ; "FORM"
  598.     jsr    pgetw            ;version number ($42)
  599.     jsr    pgetl
  600.     move.l    d0,picoffset
  601.     jsr    pgetw
  602.     move.w    d0,tagcount
  603.  
  604. pptagloop:
  605.     jsr    pgetw
  606.     move.w    d0,tagid
  607.     jsr    pgetw
  608.     move.w    d0,tagtype
  609.     jsr    pgetl
  610.     move.l    d0,taglength
  611.     cmp.l    #10,d0
  612.     bcc    pptg03
  613.  
  614.     lea    typelen,a0
  615.     move.l    taglength,d0
  616.     move.w    tagtype,d1
  617.     move.b    0(a0,d1.w),d1
  618.     lsl.l    d1,d0
  619.     cmp.l    #4,d0
  620.     bls    pptg01
  621. pptg03:    jsr    pgetl
  622.     move.l    d0,tagvalue
  623.     bra    pptg02
  624. pptg01:    move.l    picoffset,tagvalue
  625.     addq.l    #4,picoffset
  626.  
  627. pptg02:    lea    taglist2,a0
  628. pptg1:    move.w    (a0)+,d0
  629.     beq    pptg9
  630.     cmp.w    tagid,d0
  631.     beq    pptg8
  632.     lea    4(a0),a0
  633.     bra    pptg1
  634.  
  635. pptg8:  move.l    (a0),a0
  636.     jsr    (a0)
  637.  
  638. pptg9:    subq.w    #1,tagcount
  639.     bne    pptagloop
  640.  
  641.     bra    purgepic
  642.  
  643.  
  644. *******************************************
  645. ***    StripOffsets            ***
  646. *******************************************
  647. tag_stripoffset:
  648.         cmp.l   #0,rps                  ;was a rps tag found?
  649.         bne     tgso01                  ;yes
  650.         
  651.         clr.l   d0
  652.         move.w  pic+pc_H,d0
  653.         cmp.l   taglength,d0
  654.         bne     tgso0
  655.         move.l  #1,rps
  656.         bra     tgso01
  657.         
  658. tgso0:  lea     taglength,a0
  659.         addq.l  #2,a0
  660.         divu    (a0),d0                 ;calc how many rows per strip
  661.         move.l  d0,rps
  662.  
  663. tgso01: clr.l   d0
  664.         cmp.w   #2,compression
  665.         bne     tgso02
  666.         move.w  #0,hcount               ;for faxcomp
  667.         bra     tgso03
  668. tgso02: move.w  pic+pc_H,hcount         ;for all other compressions
  669. tgso03: move.l  picptr2,apos1           ;for cpystr
  670.         move.l  picptr2,apos2           ; "
  671.         move.w  #7,bitcount             ; "      
  672.         move.w  #0,plncnt               ; "
  673.         move.w  pic+pc_W,d0             ; "
  674.         subq.w  #1,d0                   ; "
  675.         move.w  d0,pixcount             ; "
  676.         move.w  pic+pc_Width,d0         ; "
  677.         mulu    pic+pc_H,d0             ; "
  678.         move.l  d0,plnlen               ; "
  679.         clr.w   flag
  680.                 
  681.         bra     tgso9
  682. tgso1:  cmp.l   #0,sbc            ;strip loop (taglength times)
  683.         bne     tgso2
  684.         clr.l   d0
  685.         move.w    pic+pc_W,d0
  686.         add.w   #7,d0                   ;round to nearest byte (+7)
  687.         lsr.w   #3,d0
  688.     mulu    pic+pc_BitPln,d0
  689.     mulu    pic+pc_H,d0
  690.         move.l  d0,striplength
  691.         bra     tgso3
  692.                   
  693. tgso2:  move.l  tagvalue,-(sp)
  694.         move.w  tagtype,-(sp)
  695.     move.l    sbc,tagvalue
  696.         move.w  sbctype,tagtype
  697.     bsr    getdata
  698.     move.l    d0,striplength
  699.         move.l    tagvalue,sbc
  700.         move.w  (sp)+,tagtype
  701.     move.l    (sp)+,tagvalue
  702.         
  703. tgso3:    bsr    getdata
  704.  
  705.     move.l    picture,a0
  706.     move.l    (a0),a0
  707.     add.l    d0,a0
  708.  
  709.         cmp.w   #5,compression          ;5=lzw
  710.         bne     tgso4
  711.         move.l  outcode,a1
  712.         move.l  (a1),-(sp)
  713.         move.l  suffix,a1
  714.         move.l  (a1),-(sp)
  715.         move.l  prefix,a1
  716.         move.l  (a1),-(sp)
  717.         move.l  #$000000ff,-(sp)
  718.         move.l  #$00000008,-(sp)
  719.         move.l  a0,-(sp)
  720.         jsr     _doLZW
  721.         add.l   #24,sp
  722.         bra     tgso9
  723.         
  724. tgso4:  cmp.w   #$8005,compression      ;$8005 = packbits
  725.         bne     tgso5
  726.         bsr     pbrgb
  727.         bra     tgso9
  728.         
  729. tgso5:  cmp.w   #1,compression          ;1=no compression
  730.         bne     tgso7
  731.         move.l  striplength,d0
  732.         clr.w   flag                    ;clear copy flag (0=inc pointer in a0)
  733.         bsr     nocomp
  734.         bra     tgso9
  735.         
  736. tgso7:  cmp.w   #2,compression          ;CCITT compressed?
  737.         bne     tgso8
  738.         
  739.         cmp.w   #1,photom               ;is the photmetricinterpret = 1?
  740.         bne     tgso71                  ;no
  741.         move.w  #0,photom               ;reverse it if it is.
  742. tgso71: bsr     faxcomp
  743.         bra     tgso9
  744.         
  745. tgso8:  move.l  table,a0                ;clean up and exit
  746.         move.l  spclnum(a0),a0
  747.         cmp.w   #1,(a0)
  748.         beq     abortobj
  749.         bra     abortpic        
  750.         
  751. tgso9:  subq.l    #1,taglength
  752.     bcc    tgso1
  753.     rts
  754.  
  755. ***********************************
  756. ***                             ***
  757. ***********************************  ;called for each strip
  758. nocomp:
  759.         move.l  rps,rowcount
  760.         ;move.l  rps,d1
  761.         ;divu    #0,d7
  762.         bsr     cpystr
  763.         rts
  764.         
  765. ***********************************
  766. ***                             ***
  767. ***********************************
  768. readcode:
  769.         movem.l   d2-d7/a2-a3,-(a7)
  770.         movea.l   36(a7),a3
  771.         move.l    40(a7),d7
  772.         move.l    44(a7),d6
  773.         movea.l   48(a7),a2
  774.         move.l    (a3),d0
  775.         move.l    d0,d1
  776.         lsr.l     #3,d1
  777.         move.b    0(a2,d1.l),d2
  778.         move.b    1(a2,d1.l),d3
  779.         move.b    2(a2,d1.l),d4
  780.         add.l     d7,(a3)
  781.         moveq     #24,d1
  782.         sub.l     d7,d1
  783.         moveq     #7,d5
  784.         and.l     d5,d0
  785.         moveq     #0,d5
  786.         move.b    d4,d5
  787.         moveq     #0,d4
  788.         move.b    d3,d4
  789.         asl.l     #8,d4
  790.         moveq     #0,d3
  791.         move.b    d2,d3
  792.         swap      d3
  793.         clr.w     d3
  794.         add.l     d4,d3
  795.         add.l     d5,d3
  796.         asl.l     d0,d3
  797.         lsr.l     d1,d3
  798.         and.l     d6,d3
  799.         move.l    d3,d0
  800.         movem.l   (a7)+,d2-d7/a2-a3
  801.         rts
  802.       
  803.        
  804. ***********************************
  805. ***                             ***
  806. ***********************************
  807. _doLZW:
  808.         link      a5,#-64
  809.         movem.l   d2-d7/a2-a3,-(a7)
  810.         move.l    rps,rowcount
  811.         movea.l   28(a5),a3
  812.         move.l    12(a5),d7
  813.         moveq     #1,d0
  814.         move.l    d0,d1
  815.         asl.l     d7,d1
  816.         move.l    d1,d2
  817.         addq.l    #1,d2
  818.         move.l    d1,d3
  819.         addq.l    #2,d3
  820.         move.l    d7,d4
  821.         addq.l    #1,d4
  822.         move.l    d1,44(a7)
  823.         move.l    d4,d1
  824.         move.l    d1,32(a7)
  825.         move.l    d0,d1
  826.         asl.l     d4,d1
  827.         move.l    d1,d6
  828.         move.l    d6,d0
  829.         subq.l    #1,d0
  830.         moveq     #0,d1
  831.         move.l    d1,-36(a5)
  832.         move.l    d1,d7
  833.         movea.l   8(a5),a2
  834.         move.l    a2,-(a7)
  835.         move.l    d0,-(a7)
  836.         move.l    d4,-(a7)
  837.         pea       -36(a5)
  838.         move.l    d0,-28(a5)
  839.         move.l    d2,56(a7)
  840.         move.l    d3,-24(a5)
  841.         move.l    d3,52(a7)
  842.         bsr.w     readcode
  843.         lea       16(a7),a7
  844.         move.l    d0,d5
  845.         moveq     #1,d0
  846.         move.l    d0,-40(a5)
  847.         bra.w     dolzw6
  848.        
  849. dolzw1: cmp.l     44(a7),d5
  850.         bne.b     dolzw2
  851.        
  852.         move.l    32(a7),d4
  853.         moveq     #1,d0
  854.         move.l    d0,d1
  855.         asl.l     d4,d1
  856.         move.l    d1,d6
  857.         move.l    d6,d0
  858.         subq.l    #1,d0
  859.         move.l    36(a7),-24(a5)
  860.         move.l    a2,-(a7)
  861.         move.l    d0,-(a7)
  862.         move.l    d4,-(a7)
  863.         pea       -36(a5)
  864.         move.l    d0,-28(a5)
  865.         bsr.w     readcode
  866.         move.l    d0,d5
  867.         move.l    d5,d0
  868.         and.l     16(a5),d0
  869.         move.b    d0,-45(a5)
  870.         pea       1
  871.         pea       -45(a5)
  872.         bsr       _cpystr
  873.         lea       24(a7),a7
  874.         bra.w     dolzw5
  875.        
  876. dolzw2: move.l    d5,d6
  877.         cmp.l     -24(a5),d6
  878.         bcs.b     dolzw4
  879.        
  880.         move.l    -44(a5),d6
  881.         moveq     #1,d7
  882.         move.b    -45(a5),(a3)
  883.         bra.b     dolzw4
  884.        
  885. dolzw3: movea.l   24(a5),a0
  886.         move.b    0(a0,d6.l),(a2)
  887.         move.l    d6,d0
  888.         asl.l     #2,d0
  889.         movea.l   20(a5),a0
  890.         move.l    0(a0,d0.l),d6
  891. dolzw4: movea.l   a3,a2
  892.         adda.l    d7,a2
  893.         addq.l    #1,d7
  894.         cmp.l     16(a5),d6
  895.         bhi.b     dolzw3
  896.        
  897.         move.l    d6,d0
  898.         and.l     16(a5),d0
  899.         move.b    d0,-45(a5)
  900.         move.b    d0,(a2)
  901.         move.l    d7,-(a7)
  902.         move.l    a3,-(a7)
  903.         bsr       _cpystr
  904.         addq.w    #8,a7
  905.         moveq     #0,d7
  906.         move.l    -24(a5),d0
  907.         move.l    d0,d1
  908.         asl.l     #2,d1
  909.         movea.l   20(a5),a0
  910.         move.l    -44(a5),0(a0,d1.l)
  911.         movea.l   24(a5),a0
  912.         move.b    -45(a5),0(a0,d0.l)
  913.         addq.l    #1,-24(a5)
  914.         move.l    -32(a5),d6
  915.         move.l    d6,d0
  916.         subq.l    #1,d0
  917.         move.l    -24(a5),d1
  918.         cmp.l     d0,d1
  919.         bcs.b     dolzw5
  920.        
  921.         moveq     #12,d0
  922.         cmp.l     d0,d4
  923.         bcc.b     dolzw5
  924.        
  925.         addq.l    #1,d4
  926.         add.l     d6,d6
  927.         moveq     #1,d0
  928.         move.l    d0,d1
  929.         asl.l     d4,d1
  930.         subq.l    #1,d1
  931.         move.l    d1,-28(a5)
  932. dolzw5: move.l    d5,-44(a5)
  933.         movea.l   8(a5),a2
  934.         move.l    a2,-(a7)
  935.         move.l    -28(a5),-(a7)
  936.         move.l    d4,-(a7)
  937.         pea       -36(a5)
  938.         bsr.w     readcode
  939.         lea       16(a7),a7
  940.         move.l    d0,d5
  941.         addq.l    #1,-40(a5)
  942. dolzw6: move.l    d6,-32(a5)
  943.         cmp.l     40(a7),d5
  944.         bne.w     dolzw1
  945.        
  946.         move.l    -40(a5),d0
  947.         movem.l   (a7)+,d2-d7/a2-a3
  948.         unlk      a5
  949.         rts
  950.         
  951. **********************************
  952. **                              **
  953. **********************************
  954. faxcomp:
  955.         move.l  #0,rowcount
  956.  
  957. fc2:    clr.l   d5              ;white codes are always first in row
  958.     clr.l   d6
  959.         move.w    pic+pc_W,d6      
  960.     move.l    picptr,a1
  961.         move.l  #0,d0
  962.         move.w  #0,pixcount     ;zero the pixel counter
  963.         move.w  #7,pixpos       ;set current pixel postion in amiga bitmap
  964.  
  965. fc3:    move.b  (a0),temp
  966.         move.b  1(a0),temp+1
  967.         move.b  2(a0),temp+2
  968.         move.b  3(a0),temp+3
  969.         move.l  temp,d0         ;get 4 bytes into d0 for bit testing
  970.         clr.l   d1
  971.         move.l  #31,d1          ;set the bit pointer
  972.         
  973. fc4:    move.l  d1,saved1       ;save d1 for the table switch testing
  974.         move.l  a0,savea0       ;save a0 for table switch testing
  975.                 
  976. fc5:    move.w  #0,d7           ;clear the bit counter
  977.         move.l  saved1,d1       ;reset d1
  978.         move.l  savea0,a0       ;reset a0
  979.         lea     work,a3
  980.         move.l  #0,(a3)         ;clear out work area
  981.         move.l  #0,4(a3)
  982.         move.l  #0,8(a3)
  983.         move.l  #0,12(a3)
  984.  
  985.         btst    d1,d0           ;get the first bit into the work area
  986.         beq.s   fc51
  987.         move.b  #$31,0(a3)
  988.         bra.s   fc52
  989. fc51:   move.b  #$30,0(a3)
  990. fc52:   subq.l  #1,d1
  991.         move.l  #1,d2           ;d2 = index into work area
  992.         addq.w  #1,d7           ;d7 = bitcount
  993.         btst    #0,d5           ;which color?
  994.         bne     ck0             ;smallest black code is 2 bits
  995.  
  996.         btst    d1,d0           ;get next 2 bits into the work area
  997.         beq.s   fc53            ;smallest white code is 4 bits
  998.         move.b  #$31,1(a3)
  999.         bra.s   fc54
  1000. fc53:   move.b  #$30,1(a3)
  1001. fc54:   subq.l  #1,d1        
  1002.         btst    d1,d0
  1003.         beq.s   fc55
  1004.         move.b  #$31,2(a3)
  1005.         bra.s   fc56
  1006. fc55:   move.b  #$30,2(a3)
  1007. fc56:   subq.l  #1,d1        
  1008.         move.l  #3,d2           ;d2 = index into work area
  1009.         addq.w  #2,d7
  1010.         
  1011.         btst    #1,d5           ;which table are we in? 0=makeup; 1=term
  1012.         bne.s   fc57            ;
  1013.         lea     wmindex,a4      ; 
  1014.         bra     ck0             ;
  1015. fc57:   lea     wtindex,a4      ;
  1016.  
  1017.        
  1018. ck0:    btst    d1,d0           ;get next bit into work area
  1019.         beq.s   ck01
  1020.         move.b  #$31,0(a3,d2)
  1021.         bra.s   ck02
  1022. ck01:   move.b  #$30,0(a3,d2)
  1023. ck02:   addq    #1,d2           ;update work area index 
  1024.  
  1025.         btst    #0,d5           ;which color? 0=white; 1=black.
  1026.         bne     ckbm
  1027.  
  1028.         move.l  (a4),a2         ;temp
  1029.  
  1030. ckw1:   move.l  (a2),d4         ;compare work area to code in table
  1031.         cmp.l   (a3),d4         ;if not equal goto ckw2
  1032.         bne     ckw3            ;temp - used to be ckw2
  1033.         move.l  4(a2),d4
  1034.         cmp.l   4(a3),d4
  1035.         bne     ckw2
  1036.         move.l  8(a2),d4
  1037.         cmp.l   8(a3),d4
  1038.         bne     ckw2
  1039.         move.l  12(a2),d4
  1040.         and.l   #$ffffff00,d4
  1041.         cmp.l   12(a3),d4
  1042.         bne     ckw2
  1043.         
  1044.         bra     doit0           ;found a code! do something with it!
  1045.  
  1046. ckw2:   add.l   #18,a2          ;get next table entry
  1047.         tst.b   (a2)            ;are we at end of table yet?
  1048.         bne.s   ckw1            ;if not continue check
  1049.         move.l  (a4),a2         ;reset a2
  1050.         subq.l  #1,d1           ;get next bit into work area 
  1051.         addq.w  #1,d7           ;update bit counter
  1052.         cmp.w   #13,d7          ;have we checked the max possible length?
  1053.         bcs     ck0             ;if not get next bit
  1054.         bchg    #1,d5           ;else switch tables
  1055.         beq     fc5             ;if on first table branch back
  1056.         
  1057.         clr.l   d6              
  1058.         bra     fc7             ;error - could not find code - out of sinc?
  1059.  
  1060. ckw3:   addq.l  #4,a4           ;get next index pointer
  1061.         move.l  (a4),a2         ;set a2 equal to it
  1062.         cmp.l   #0,a2           ;is it the end of the index
  1063.         bne     ckw1            ;if not branch
  1064.  
  1065.         bchg    #1,d5           ;switch tables
  1066.         bne     fc8             ;if term table exit (used to be: beq fc5)
  1067.         
  1068.         btst    #1,d5           ;which table are we in? 0=makeup; 1=term
  1069.         bne.s   ckw4            ;
  1070.         lea     wmindex,a4      ; 
  1071.         move.l  (a4),a2         ;
  1072.         bra     ckw1            ;
  1073. ckw4:   lea     wtindex,a4      ;
  1074.         move.l  (a4),a2         ;
  1075.         bra     ckw1            ;
  1076.         
  1077. ckbm:   btst    #1,d5           ;are we in the makeup codes or term. codes
  1078.         bne.s   ckb0            ;0=makeup code table; 1=term code table.
  1079.         lea     bmakeupcodes,a2 ;check work area against black makeup codes 
  1080.         bra     ckb1
  1081. ckb0:   lea     btermcodes,a2
  1082.  
  1083. ckb1:   move.w  (a2),d4         ;compare work area to code in table
  1084.         cmp.w   (a3),d4         ;if not equal goto ckb2
  1085.         bne     ckb3
  1086.         move.w  2(a2),d4
  1087.         cmp.w   2(a3),d4
  1088.         bne     ckb2
  1089.         move.l  4(a2),d4
  1090.         cmp.l   4(a3),d4
  1091.         bne     ckb2
  1092.         move.l  8(a2),d4
  1093.         cmp.l   8(a3),d4
  1094.         bne     ckb2
  1095.         move.l  12(a2),d4
  1096.         and.l   #$ffffff00,d4
  1097.         cmp.l   12(a3),d4
  1098.         bne     ckb2
  1099.         
  1100.         bra     doit0           ;found a code! do something with it!
  1101.    
  1102. ckb2:   add.l   #18,a2          ;get next table entry
  1103.         tst.b   (a2)            ;are we at end of table yet?
  1104.         bne.s   ckb1            ;if not continue check
  1105.         subq.l  #1,d1           ;else get next bit into work area 
  1106.         addq.w  #1,d7
  1107.         cmp.w   #13,d7
  1108.         bcs     ck0 
  1109.         bchg    #1,d5           ;switch tables
  1110.         beq     fc5             ;branch back if on first table
  1111.         
  1112.         clr.l   d6              ;end this row
  1113.         bra     fc7             ;error - could not find code in table - out of sinc?
  1114.  
  1115. ckb3:   btst    #1,d5
  1116.         bne     ckb2            ;if term table handle normally
  1117.         
  1118.         bset    #1,d5           ;set it to the term table
  1119.         bra     fc5             
  1120.                 
  1121. doit0:  bclr    #3,d5           ;clear term. flag
  1122.         move.w  16(a2),d2       ;get run length (in pixels)
  1123.         move.w  d2,pixcount     ;save for updating the picture width
  1124.         move.w  pixpos,d3       ;get current pixel position in amiga bitmap
  1125.         btst    #1,d5           ;am i in here on a makeup or term code?
  1126.         bne     doit1
  1127.        
  1128.         subq.w  #8,d2           ;remove partial pixels
  1129.         lsr.w   #5,d2           ;d2 = number of long words i need to move
  1130.         cmp.w   #1,photom       ;is it reversed?
  1131.         bne     doit00          ;no
  1132.         cmp.b   #0,15(a2)       ;which color? 0=Black, 1=White
  1133.         bne     doWl0
  1134.         bra     doBl0
  1135.               
  1136. doit00: cmp.b   #0,15(a2)       ;which color? 1=Black, 0=White
  1137.         beq     doWl0
  1138.  
  1139. doBl0:  bclr    d3,(a1)
  1140.         dbf     d3,doBl0
  1141.         addq.l  #1,a1
  1142.         bclr    #2,d5           ;clear odd address flag
  1143.         move.l  a1,d3
  1144.         btst    #0,d3           ;are we on a word boundry (even address)?
  1145.         beq.s   doBl2           ;yes!
  1146.         
  1147.         move.b  #0,(a1)+        ;no - odd address
  1148.         bset    #2,d5           ;set flag
  1149.         bra.s   doBl2
  1150.         
  1151. doBl1:  move.l  #0,(a1)+  
  1152. doBl2:  dbf     d2,doBl1
  1153.         move.w  #0,(a1)+
  1154.         btst    #2,d5           ;check odd address flag
  1155.         bne.s   doBl22          ;yes we started on an odd address
  1156.         move.b  #0,(a1)+
  1157. doBl22: move.w  #7,d3
  1158.         move.w  pixpos,d4
  1159. doBl3:  bclr    d3,(a1)
  1160.         subq.w  #1,d3
  1161.         cmp.w   d3,d4
  1162.         bcs.s   doBl3
  1163.         bra     fc6
  1164.  
  1165. doWl0:  bset    d3,(a1)         ;loop bits to next byte boundry
  1166.         dbf     d3,doWl0         
  1167.         addq.l  #1,a1
  1168.         bclr    #2,d5           ;clear flag odd address flag
  1169.         move.l  a1,d3
  1170.         btst    #0,d3           ;are we on a word boundry (even)?
  1171.         beq.s   doWl2           ;yes!
  1172.         
  1173.         move.b  #$ff,(a1)+      ;no, so make it that way
  1174.         bset    #2,d5           ;set flag odd address flag
  1175.         bra.s   doWl2
  1176.  
  1177. doWl1:  move.l  #$ffffffff,(a1)+        ;white makeup codes
  1178. doWl2:  dbf     d2,doWl1
  1179.         move.w  #$ffff,(a1)+
  1180.         btst    #2,d5
  1181.         bne.s   doWl22
  1182.         move.b  #$ff,(a1)+
  1183. doWl22: move.w  #7,d3
  1184.         move.w  pixpos,d4
  1185. doWl3:  bset    d3,(a1)
  1186.         subq.w  #1,d3
  1187.         cmp.w   d3,d4
  1188.         bcs.s   doWl3
  1189.         bra     fc6
  1190.  
  1191. ;doWl0:  add.w   #1,d2  
  1192. ;        lsl.w   #2,d2           ;d2 = number of bytes
  1193. ;        add.w   d2,a1           ;push ahead  a1
  1194. ;        bra     fc6
  1195.          
  1196. doit1:  bset    #3,d5           ;set term. flag
  1197.         cmp.w   #1,photom       ;is it reversed?
  1198.         bne     doit2           ;no
  1199.         tst.b   15(a2)          ;which color? 0=Black, 1=White
  1200.         bne     doWs2
  1201.         bra     doBs2
  1202.               
  1203. doit2:  tst.b   15(a2)          ;which color? 1=Black, 0=White
  1204.         beq     doWs2
  1205.  
  1206.         bra     doBs2           ;black bit loop
  1207. doBs1:  bclr    d3,(a1)
  1208.         dbf     d3,doBs2
  1209.         addq.l  #1,a1
  1210.         move.w  #7,d3
  1211. doBs2:  dbf     d2,doBs1        
  1212.         bra     doit3
  1213.         
  1214. doWs1:  bset    d3,(a1)         ;white bit loop
  1215.         dbf     d3,doWs2        
  1216.         addq.l  #1,a1
  1217.         move.w  #7,d3
  1218. doWs2:  dbf     d2,doWs1        
  1219.  
  1220. doit3:  move.w  d3,pixpos
  1221.         bchg    #0,d5           ;switch colors
  1222.         bclr    #1,d5           ;set table to makeup table for new color
  1223.         
  1224. fc6:    move.l  #31,d2
  1225.         sub.l   d1,d2           ;d2=31-d1
  1226.         lsr.l   #3,d2           ;divide by 8
  1227.         add.l   d2,a0           ;update memory pointer
  1228.         move.b  (a0),temp       ;reload memory into d0
  1229.         move.b  1(a0),temp+1
  1230.         move.b  2(a0),temp+2
  1231.         move.b  3(a0),temp+3
  1232.         move.l  temp,d0
  1233.         lsl.l   #3,d2           ;multiple by 8
  1234.         subq.l  #1,d1
  1235.         add.l   d2,d1           ;remap d1 to top of 4 byte input
  1236.  
  1237.         sub.w   pixcount,d6        
  1238.         btst    #3,d5           ;was the last code a term or makeup?
  1239.         beq     fc4             ;branch if a makeup code
  1240.         
  1241. fc7:    tst.w   d6              ;have we done an entire row yet?
  1242.         bne     fc4             ;if not branch?
  1243.  
  1244.         move.l    picptr,a1       ;move a1 to the next row in the amiga bitmap
  1245.     add.w    pic+pc_Width,a1
  1246.     move.l    a1,picptr
  1247.  
  1248.         addq.l  #1,rowcount     ;temp - bump up the row counter
  1249.         addq.w  #1,hcount       ;temp - bump up height counter
  1250.         add.l   #1,a0           ;temp - new rows start on a byte boundry
  1251.  
  1252. fc8:    move.w  pic+pc_H,d0     ;temp - get the total height of the picture
  1253.         sub.w   hcount,d0       ;temp - have we done the entire picture?
  1254.         beq     fc9             ;temp - yes so exit
  1255.         
  1256.         move.l  rps,d0          ;temp - have we done all the rows in this strip?
  1257.         sub.l   rowcount,d0     ;temp 
  1258.         bhi     fc2             ;temp - (bhi = carry clear & zero clear)
  1259. fc9:    rts
  1260.  
  1261.  
  1262. **********************************
  1263. **                              **
  1264. **********************************
  1265. _cpystr:
  1266.         move.l  4(sp),a0
  1267.         move.l  8(sp),d0
  1268.         add.l   d0,a0
  1269.         subq.l  #1,a0
  1270.         bset    #1,flag        
  1271. cpystr: 
  1272.         movem.l d1-d7/a1-a2,-(sp)
  1273.  
  1274.         cmp.w   #3,predictor    ;branch if predictor is greater than 2
  1275.         bcs     cp0             ;known lzw pre-compression technique so cont.
  1276.         
  1277.         movem.l (sp)+,d1-d7/a1-a2       ;restore registers
  1278.         move.l  table,a0                ;clean up and exit
  1279.         move.l  spclnum(a0),a0
  1280.         cmp.w   #1,(a0)
  1281.         beq     abortobj
  1282.         bra     abortpic
  1283.         
  1284. cp0:    move.l  apos2,a2        ;restore place in amiga bitmap - plane x
  1285.         move.l  apos1,a1        ;restore place in amiga bitmap - plane 1
  1286.         move.l  plnlen,d7       ;d7 = amiga bitplane length in bytes
  1287.         move.w  bitcount,d5     ;restore bit place in a2
  1288.         move.w  plncnt,d1       ;restore plane counter
  1289.         move.w  pixcount,d6     ;restore pixel counter
  1290.         moveq   #7,d3           ;d3 = bit position in tiff data
  1291.         
  1292. cp1:    cmp.w   #2,predictor    ;if horizontal diff. is used - data is normal
  1293.         beq.s   norm
  1294.         
  1295.         cmp.w   #1,photom
  1296.         bne.s   norm
  1297.         
  1298.         btst    d3,(a0)         ;is the data bit on or off
  1299.     beq.s   cp2             ;off
  1300.     bclr    d5,(a2)
  1301.     bra.s    cp4
  1302. cp2:    bset    d5,(a2)
  1303.         bra.s   cp4
  1304.         
  1305. norm:   btst    d3,(a0)         ;is the data bit on or off
  1306.     beq.s    cp3             ;off
  1307.     bset    d5,(a2)
  1308.     bra.s    cp4
  1309. cp3:    bclr    d5,(a2)
  1310.         
  1311. cp4:    sub.l    d7,a2           ;go to next bitplane
  1312.     addq.w    #1,d1           ;update bitplane counter
  1313.         
  1314.         cmp.w    pic+pc_BitPln,d1
  1315.     bcs    cp7
  1316.         
  1317.         moveq   #0,d1           ;reset bitplane counter
  1318.         move.l  a1,a2           ;reset a2 to last bitplane
  1319.         
  1320. cp5:    dbf     d5,cp6          ;update amiga bit pos
  1321.     addq.l    #1,a1           ;move to next amiga bitmap byte
  1322.         addq.l  #1,a2
  1323.     moveq   #7,d5           ;reset d5 to top of byte
  1324.         
  1325. cp6:    dbf     d6,cp7          ;update pixel width counter
  1326.         
  1327.     move.l    picptr2,a1
  1328.         clr.l   d5
  1329.         move.w  pic+pc_Width,d5
  1330.     add.l   d5,a1
  1331.     move.l    a1,picptr2
  1332.         move.l  a1,a2
  1333.         move.w  #7,d5
  1334.         move.w  pic+pc_W,d6
  1335.         subq.w  #1,d6
  1336.         subq.w  #1,hcount
  1337.         beq     cp81
  1338.         subq.l  #1,rowcount
  1339.         beq     cp81
  1340.         
  1341.         cmp.w   #1,pic+pc_BitPln        ;is it b&w?
  1342.         beq     cp70                    ;yes
  1343.  
  1344.         cmp.w   #1,compression  ;is it compressed data?
  1345.         beq     cp70            ;no, so start next row on a byte boundry
  1346.         
  1347. cp7:    dbf     d3,cp1          ;update tiff bit counter
  1348.         
  1349. cp70:   moveq   #7,d3           ;reset tiff data bit counter
  1350.         btst    #0,flag         ;check copy flag
  1351.         bne.s   cp8             ;0=increment from address, 1=no increment
  1352.         
  1353.         btst    #1,flag
  1354.         bne.s   cp71
  1355.         addq.l  #1,a0           ;move to next byte
  1356.         bra.s   cp8
  1357. cp71:   subq.l  #1,a0           ;move to prev byte
  1358.         
  1359. cp8:    subq.l  #1,d0           ;decrement data byte count
  1360.         bne     cp1
  1361.  
  1362. cp81:   move.l  a2,apos2        ;save place in amiga bitmap - plane x
  1363.         move.l  a1,apos1        ;save place in amiga bitmap - plane 1
  1364.         move.w  d5,bitcount     ;save bit place in a2
  1365.         move.w  d1,plncnt       ;save plane counter
  1366.         move.w  d6,pixcount     ;save pixel counter
  1367.         
  1368.         movem.l (sp)+,d1-d7/a1-a2
  1369.         rts
  1370.         
  1371. **********************************
  1372. **                              **
  1373. **********************************
  1374. horidif2:
  1375.         move.l  picptrsave2,a1  ;a1 = base address in last bit plane 
  1376.         move.l  a1,picptr2      ;get starting address of row 
  1377.         move.l  a1,a2           ;a2 = address in bitmap row
  1378.         move.w  pic+pc_W,d0     ;d0 = horizontal pixel counter
  1379.         move.w  #7,d5           ;d5 = bit counter into bit map
  1380.  
  1381.         move.w  pic+pc_Width,d1
  1382.         mulu    pic+pc_H,d1     ;d1 = length of amiga bitmap
  1383.         
  1384.         move.w  pic+pc_W,d0     ;d0 = horizontal pixel counter
  1385.         subq.w  #1,d0
  1386.         move.w  pic+pc_H,d2     ;d2 = vertical row counter
  1387.         move.l  #0,lastval      ;zero the last pixel value
  1388.         bra     ho5
  1389.  
  1390. ho0:    clr.l   d3              ;d3 = value of pixel 
  1391.         move.w  pic+pc_BitPln,d6        ;d6 = bit plane counter
  1392.         subq.w  #1,d6
  1393.         move.w  d6,d4           ;d4 = bit position in d3
  1394.         move.l  a1,a2           ;reset a2 to first bitplane
  1395.         
  1396. ho1:    btst    d5,(a2)         ;get the pixel's value into d3
  1397.         beq     ho2
  1398.         bset    d4,d3
  1399.         bra     ho3
  1400. ho2:    bclr    d4,d3
  1401. ho3:    subq.w  #1,d4           ;sub 1 from the d3 bit postion counter
  1402.         sub.l   d1,a2           ;move a2 to next amiga bitplane
  1403.         dbf     d6,ho1          ;decrement amiga bitplane counter
  1404.  
  1405.         move.l  d3,temp
  1406.         move.b  temp+3,d3
  1407.         add.b   d3,lastval+3
  1408.         move.b  temp+2,d3
  1409.         add.b   d3,lastval+2
  1410.         move.b  temp+1,d3
  1411.         add.b   d3,lastval+1
  1412.         move.l  lastval,d3
  1413.                   
  1414.         cmp.w   #1,photom       ;is the image reversed?
  1415.         bne     ho30            ;no
  1416.         not.l   d3
  1417.  
  1418. ho30:   move.w  pic+pc_BitPln,d4                 
  1419.         subq.w  #1,d4
  1420.         move.l  a1,a2
  1421.                          
  1422. ho31:   btst    d4,d3
  1423.         beq     ho32
  1424.         bset    d5,(a2)
  1425.         bra     ho33
  1426. ho32:   bclr    d5,(a2)
  1427.         
  1428. ho33:   sub.l   d1,a2
  1429.         dbf     d4,ho31
  1430.  
  1431. ho4:    dbf     d5,ho41
  1432.  
  1433.         add.l   #1,a1           ;move to next byte
  1434.         move.w  #7,d5           ;reset bit counter 
  1435.  
  1436. ho41:   dbf     d0,ho0          ;decrement horizontal counter
  1437.  
  1438.         move.l  picptr2,a1
  1439.         add.w   pic+pc_Width,a1
  1440.         move.l  a1,picptr2
  1441.         move.w  pic+pc_W,d0     ;reset d0 to width in pixels
  1442.         subq.w  #1,d0
  1443.         move.w  #7,d5           ;reset bit counter
  1444.         move.l  #0,lastval      ;reset last pixel value to zero
  1445.  
  1446. ho5:    dbf     d2,ho0          ;decrement row counter
  1447.         rts        
  1448.         
  1449.  
  1450. ***********************************
  1451. ***                             ***
  1452. *********************************** ;called once per strip
  1453. pbrgb:  move.l  rps,rowcount
  1454.         move.l  striplength,d2
  1455.         addq.l  #2,d2           ;not sure why - but it seems to work
  1456.         tst.l   sbc
  1457.         beq     pb2
  1458.         subq.l  #2,d2
  1459.                 
  1460. pb2:    tst.w   hcount
  1461.         beq     pb12
  1462.         tst.l   rowcount
  1463.         beq     pb12
  1464.  
  1465.         clr.l   d0
  1466.         move.b  (a0)+,d0        ;d0 = one byte code
  1467.         tst.l   sbc
  1468.         beq     pb3
  1469.         
  1470.         subq.l  #1,d2           ;subtract 1 from the length for the code
  1471.         beq     pb12
  1472.         bmi     pb11
  1473.         
  1474. pb3:    cmp.b   #128,d0
  1475.         beq.s   pb2             ;code 128 = do nothing, so get next byte
  1476.         
  1477.         btst    #7,d0           ;check the high bit
  1478.         beq.s   pb5             ;if 0 copy the next d0+1 bytes as is
  1479.     
  1480.         neg.b   d0              ;else copy the next byte -d0+1 times
  1481.         add.b   #1,d0
  1482.         clr.l   d3
  1483.         move.b  d0,d3
  1484.         bset    #0,flag         ;set the copy flag (1=don't inc ptr in a0)
  1485.         bsr     cpystr          ;copy the byte (a0) into bitmap (a1)
  1486.         addq.l  #1,a0           ;move to next code
  1487.         tst.l   sbc
  1488.         beq     sb4
  1489.         moveq   #1,d3           ;subtract 1 from the striplength
  1490. sb4:    sub.l   d3,d2
  1491.         beq     pb12
  1492.         bmi     pb11
  1493.         bra     pb2
  1494.         
  1495. pb5:    bclr    #0,flag         ;clear the copy flag (0=inc the ptr in a0)
  1496.         clr.l   d3
  1497.         add.b   #1,d0
  1498.         move.b  d0,d3           ;save for later
  1499.         bsr     cpystr
  1500.         sub.l   d3,d2
  1501.         beq     pb12
  1502.         bmi     pb11
  1503.         bra     pb2
  1504.  
  1505. pb11:
  1506. pb12:   rts
  1507.         
  1508.         
  1509.                 
  1510. ***********************************
  1511. ***                ***
  1512. ***********************************
  1513. get_colormap:
  1514.         movem.l d0-d6/a0-a2,-(sp)
  1515.         move.l  palptr,a0               ;a0 = start of amiga palette
  1516.         move.l  palcount,d0             ;d0 = number of entries
  1517.         divu    #3,d0                   ;d0 = number of colors (rgb)
  1518.         
  1519.         move.l  cmapoffset,d1
  1520.         move.l  picture,a1
  1521.         move.l  (a1),a1
  1522.         add.l   d1,a1                   ;a1 = start of colormap data in tiff
  1523.         
  1524.         move.w  d0,d2
  1525.         lsl.w   #1,d2                   ;d2 = length of each color's data
  1526.         bra     gc4
  1527.         
  1528. gc0:    move.l  a1,a2
  1529.  
  1530.         bsr     getcword                ;get color word in d4
  1531.         move.w  d4,(a0)                 ;red
  1532.         add.w   d2,a2
  1533.         bsr     getcword
  1534.         move.w  d4,2(a0)                ;green
  1535.         add.w   d2,a2
  1536.         bsr     getcword
  1537.         move.w  d4,4(a0)                ;blue
  1538.         
  1539.     move.w    (a0)+,d4
  1540.     move.w    (a0)+,d5
  1541.     move.w    (a0)+,d6
  1542.     mulu    #19661,d4
  1543.     mulu    #38666,d5
  1544.     mulu    #7209,d6
  1545.     add.l    d5,d4
  1546.     add.l    d6,d4
  1547.     swap    d4
  1548.     cmp.w    #$8000,d4
  1549.     bcc    gc1
  1550.     moveq    #1,d4
  1551.         bra    gc2
  1552. gc1:    moveq    #0,d4
  1553. gc2:    move.w    d4,(a0)+                ;screen color
  1554.         addq.l  #2,a1                   ;move to next color word
  1555.  
  1556. gc4:    dbf     d0,gc0
  1557.         movem.l (sp)+,d0-d6/a0-a2
  1558.         rts                             ;when done with all colors - exit
  1559.  
  1560. ***********************************
  1561. ***                ***
  1562. ***********************************
  1563. getcword:
  1564.         
  1565. gt1:    tst.b   byteorder
  1566.         bne     gt2
  1567.  
  1568.         move.w  (a2),d4                 ;Motorola format
  1569.         bra     gt3
  1570.  
  1571. gt2:    move.b  (a2),temp+1             ;Intel format
  1572.         move.b  (a2),temp
  1573.         move.w  temp,d4
  1574.  
  1575. gt3:    rts
  1576.         
  1577.         
  1578. ***********************************
  1579. ***                ***
  1580. ***********************************
  1581. getdata:
  1582.     cmp.w    #TypeBYTE,tagtype
  1583.     bne    getd1
  1584.     move.l    picture,a0
  1585.     move.l    (a0),a0
  1586.     add.l    tagvalue,a0
  1587.         clr.l   d0
  1588.     move.b    (a0),d0
  1589.     addq.l    #1,tagvalue
  1590.     rts
  1591.  
  1592. getd1:    cmp.w    #TypeSHORT,tagtype
  1593.     bne    getd2
  1594.     move.l    picture,a0
  1595.     move.l    (a0),a0
  1596.     add.l    tagvalue,a0
  1597.     tst.b    byteorder
  1598.     bne    getd10
  1599.     move.b    (a0)+,temp
  1600.     move.b    (a0),temp+1
  1601.     bra    getd11
  1602. getd10:    move.b    (a0)+,temp+1
  1603.     move.b    (a0),temp
  1604. getd11:    clr.l   d0
  1605.         move.w    temp,d0
  1606.     addq.l    #2,tagvalue
  1607.     rts
  1608.  
  1609. getd2:    cmp.w    #TypeLONG,tagtype
  1610.     bne    getd3
  1611.     move.l    picture,a0
  1612.     move.l    (a0),a0
  1613.     add.l    tagvalue,a0
  1614.     tst.b    byteorder
  1615.     bne    getd20
  1616.     move.b    (a0)+,temp
  1617.     move.b    (a0)+,temp+1
  1618.     move.b    (a0)+,temp+2
  1619.     move.b    (a0),temp+3
  1620.     bra    getd21
  1621. getd20:    move.b    (a0)+,temp+3
  1622.     move.b    (a0)+,temp+2
  1623.     move.b    (a0)+,temp+1
  1624.     move.b    (a0),temp
  1625. getd21:    move.l    temp,d0
  1626.     addq.l    #4,tagvalue
  1627.     rts
  1628.  
  1629. getd3:    cmp.w    #TypeRATIONAL,tagtype
  1630.     bne    rrts
  1631.     move.l    picture,a0
  1632.     move.l    (a0),a0
  1633.     add.l    tagvalue,a0
  1634.     tst.b    byteorder
  1635.     bne    getd30
  1636.     move.b    (a0)+,temp
  1637.     move.b    (a0)+,temp+1
  1638.     move.b    (a0)+,temp+2
  1639.     move.b    (a0)+,temp+3
  1640.     move.b    (a0)+,temp2
  1641.     move.b    (a0)+,temp2+1
  1642.     move.b    (a0)+,temp2+2
  1643.     move.b    (a0),temp2+3
  1644.     bra    getd31
  1645. getd30:    move.b    (a0)+,temp+3
  1646.     move.b    (a0)+,temp+2
  1647.     move.b    (a0)+,temp+1
  1648.     move.b    (a0)+,temp
  1649.     move.b    (a0)+,temp2+3
  1650.     move.b    (a0)+,temp2+2
  1651.     move.b    (a0)+,temp2+1
  1652.     move.b    (a0),temp2
  1653. getd31:    move.l    temp,d0
  1654.     move.l    temp2,d1
  1655.     divu    d1,d0
  1656.     addq.l    #8,tagvalue
  1657.     rts
  1658.  
  1659.  
  1660. **********************************
  1661. **                              **
  1662. **********************************
  1663. pgetl:    move.l    picture,a0
  1664.     move.l    (a0),a0
  1665.     add.l    picoffset,a0
  1666.     tst.b    byteorder
  1667.     bne    pgetl1
  1668.     move.b    (a0)+,temp
  1669.     move.b    (a0)+,temp+1
  1670.     move.b    (a0)+,temp+2
  1671.     move.b    (a0),temp+3
  1672.     bra    pgetl2
  1673. pgetl1:    move.b    (a0)+,temp+3
  1674.     move.b    (a0)+,temp+2
  1675.     move.b    (a0)+,temp+1
  1676.     move.b    (a0),temp
  1677. pgetl2:    move.l    temp,d0
  1678.     addq.l    #4,picoffset
  1679.     rts
  1680.  
  1681. pgetw:    move.l    picture,a0
  1682.     move.l    (a0),a0
  1683.     add.l    picoffset,a0
  1684.     tst.b    byteorder
  1685.     bne    pgetw1
  1686.     move.b    (a0)+,temp
  1687.     move.b    (a0),temp+1
  1688.     bra    pgetw2
  1689. pgetw1:    move.b    (a0)+,temp+1
  1690.     move.b    (a0),temp
  1691. pgetw2:    move.w    temp,d0
  1692.     addq.l    #2,picoffset
  1693.     rts
  1694.  
  1695. pget:    move.l    picture,a0
  1696.     move.l    (a0),a0
  1697.     add.l    picoffset,a0
  1698.     move.b    (a0),d0
  1699.     addq.l    #1,picoffset
  1700.     rts
  1701.  
  1702.  
  1703. ***********************************
  1704. ***                ***
  1705. ***********************************
  1706. errrts:    bsr    purgepic
  1707.         move.l    table,a0 
  1708.     move.l    spclnum(a0),a0
  1709.     cmp.w    #1,(a0)
  1710.     beq    abortobj
  1711.         bra     abortpic
  1712.         
  1713. rrts:    rts
  1714.  
  1715.  
  1716. ***********************************
  1717. ***                             ***
  1718. ***********************************
  1719. purgepic:
  1720.     tst.l    picture
  1721.     beq    pu1
  1722.     move.l    picture,a0
  1723.     move.l    table,a1
  1724.     move.l    m_delete(a1),a1
  1725.     jsr    (a1)
  1726.         
  1727. pu1:    tst.l   prefix
  1728.         beq     pu2
  1729.         move.l    prefix,a0
  1730.     move.l    table,a1
  1731.     move.l    m_delete(a1),a1
  1732.     jsr    (a1)
  1733.  
  1734. pu2:    tst.l   suffix
  1735.         beq     pu3
  1736.         move.l    suffix,a0
  1737.     move.l    table,a1
  1738.     move.l    m_delete(a1),a1
  1739.     jsr    (a1)        
  1740.  
  1741. pu3:    tst.l   outcode
  1742.         beq     pu4
  1743.         move.l    outcode,a0
  1744.     move.l    table,a1
  1745.     move.l    m_delete(a1),a1
  1746.     jsr    (a1)
  1747.         
  1748. pu4:    rts
  1749.  
  1750.  
  1751. ***********************************
  1752. ***                ***
  1753. ***********************************
  1754. Mulu1632:
  1755.         move.l  table,a0
  1756.         move.l  mulu1632(a0),a0
  1757.         jmp     (a0)
  1758.  
  1759.         
  1760. ***********************************
  1761. ***                ***
  1762. ***********************************
  1763. Divu1648:
  1764.         move.l  table,a0
  1765.         move.l  divu1648(a0),a0
  1766.         jmp     (a0)
  1767.  
  1768.  
  1769. *******************************************************************
  1770. ***    called when the import routine choosen finds something    ***
  1771. ***    wrong with the file loaded.                ***
  1772. *******************************************************************
  1773. never:    clr.w    d0
  1774.     rts
  1775.  
  1776. maybe:    move.w    #1,d0
  1777.     rts
  1778.  
  1779. right:    move.w    #2,d0
  1780.     rts
  1781.  
  1782. *************************************************************
  1783. *************************************************************
  1784.  SECTION TIFF,DATA,PUBLIC
  1785.  
  1786. taglist2:
  1787.     dc.w    $0111
  1788.     dc.l    tag_stripoffset
  1789.         dc.w    $8000           ;used by aldus pagemaker
  1790.         dc.l    tag_stripoffset
  1791.         dc.w    $0140
  1792.         dc.l    get_colormap
  1793.     dc.w    0
  1794.  
  1795. taglist:
  1796.     dc.w    $0102
  1797.     dc.l    tag_bsample
  1798.     dc.w    $0140
  1799.     dc.l    tag_colormap
  1800.     dc.w    $012d
  1801.     dc.l    tag_crcurves
  1802.     dc.w    $0103
  1803.     dc.l    tag_compression
  1804.     dc.w    $0123
  1805.     dc.l    tag_grcurve
  1806.     dc.w    $0122
  1807.     dc.l    tag_grunit
  1808.     dc.w    $0101
  1809.     dc.l    tag_iheight
  1810.     dc.w    $0100
  1811.     dc.l    tag_iwidth
  1812.     dc.w    $00fe
  1813.     dc.l    tag_newsftype
  1814.     dc.w    $0106
  1815.     dc.l    tag_photometric
  1816.     dc.w    $011c
  1817.     dc.l    tag_planar
  1818.     dc.w    $013d
  1819.     dc.l    tag_predictor
  1820.     dc.w    $0128
  1821.     dc.l    tag_resolution
  1822.     dc.w    $0116
  1823.     dc.l    tag_rpstrip
  1824.     dc.w    $0115
  1825.     dc.l    tag_sppixel
  1826.     dc.w    $0117
  1827.     dc.l    tag_stripbytecnt
  1828.     dc.w    $011a
  1829.     dc.l    tag_xres
  1830.     dc.w    $011b
  1831.     dc.l    tag_yres
  1832.     dc.w    0
  1833.  
  1834. wtindex:
  1835.         dc.l    wt1,wt2,wt3,wt4,wt5,wt6,wt7,wt8,wt9,wt10
  1836.         dc.l    wt11,wt12,wt13,wt14,wt15,0
  1837.  
  1838. wmindex:        
  1839.         dc.l    wm1,wm2,wm3,wm4,wm5,wm6,wm7,0
  1840.  
  1841.         
  1842. wtermcodes:             ;OPTOMIZED!
  1843.  
  1844. wt1:    dc.b    "00000010",0,0,0,0,0,0,0
  1845.         dc.b    1
  1846.         dc.w    29
  1847.  
  1848.         dc.b    "00000011",0,0,0,0,0,0,0
  1849.         dc.b    1
  1850.         dc.w    30
  1851.  
  1852.         dc.b    "00000100",0,0,0,0,0,0,0
  1853.         dc.b    1
  1854.         dc.w    45
  1855.  
  1856.         dc.b    "00000101",0,0,0,0,0,0,0
  1857.         dc.b    1
  1858.         dc.w    46
  1859.  
  1860.         dc.b    "0000011",0,0,0,0,0,0,0,0
  1861.         dc.b    1
  1862.         dc.w    22
  1863.  
  1864.         dc.b    "0000100",0,0,0,0,0,0,0,0
  1865.         dc.b    1
  1866.         dc.w    23
  1867.  
  1868.         dc.b    "00001010",0,0,0,0,0,0,0
  1869.         dc.b    1
  1870.         dc.w    47
  1871.  
  1872.         dc.b    "00001011",0,0,0,0,0,0,0
  1873.         dc.b    1
  1874.         dc.w    48
  1875.  
  1876.         dc.b    "000011",0,0,0,0,0,0,0,0,0
  1877.         dc.b    1
  1878.         dc.w    13
  1879.  
  1880.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1881.         dc.b    0
  1882.         dc.w    0
  1883.  
  1884. wt2:    dc.b    "0001000",0,0,0,0,0,0,0,0
  1885.         dc.b    1
  1886.         dc.w    20
  1887.  
  1888.         dc.b    "00010010",0,0,0,0,0,0,0
  1889.         dc.b    1
  1890.         dc.w    33
  1891.  
  1892.         dc.b    "00010011",0,0,0,0,0,0,0
  1893.         dc.b    1
  1894.         dc.w    34
  1895.  
  1896.         dc.b    "00010100",0,0,0,0,0,0,0
  1897.         dc.b    1
  1898.         dc.w    35
  1899.  
  1900.         dc.b    "00010101",0,0,0,0,0,0,0
  1901.         dc.b    1
  1902.         dc.w    36
  1903.  
  1904.         dc.b    "00010110",0,0,0,0,0,0,0
  1905.         dc.b    1
  1906.         dc.w    37
  1907.  
  1908.         dc.b    "00010111",0,0,0,0,0,0,0
  1909.         dc.b    1
  1910.         dc.w    38
  1911.  
  1912.         dc.b    "0001100",0,0,0,0,0,0,0,0
  1913.         dc.b    1
  1914.         dc.w    19
  1915.  
  1916.         dc.b    "00011010",0,0,0,0,0,0,0
  1917.         dc.b    1
  1918.         dc.w    31
  1919.  
  1920.         dc.b    "00011011",0,0,0,0,0,0,0
  1921.         dc.b    1
  1922.         dc.w    32
  1923.         
  1924.         dc.b    "000111",0,0,0,0,0,0,0,0,0
  1925.         dc.b    1
  1926.         dc.w    1
  1927.  
  1928.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1929.         dc.b    0
  1930.         dc.w    0
  1931.  
  1932. wt3:    dc.b    "001000",0,0,0,0,0,0,0,0,0
  1933.         dc.b    1
  1934.         dc.w    12
  1935.  
  1936.         dc.b    "00100100",0,0,0,0,0,0,0
  1937.         dc.b    1
  1938.         dc.w    53
  1939.  
  1940.         dc.b    "00100101",0,0,0,0,0,0,0
  1941.         dc.b    1
  1942.         dc.w    54
  1943.  
  1944.         dc.b    "0010011",0,0,0,0,0,0,0,0
  1945.         dc.b    1
  1946.         dc.w    26
  1947.  
  1948.         dc.b    "00101000",0,0,0,0,0,0,0
  1949.         dc.b    1
  1950.         dc.w    39
  1951.  
  1952.         dc.b    "00101001",0,0,0,0,0,0,0
  1953.         dc.b    1
  1954.         dc.w    40
  1955.  
  1956.         dc.b    "00101010",0,0,0,0,0,0,0
  1957.         dc.b    1
  1958.         dc.w    41
  1959.  
  1960.         dc.b    "00101011",0,0,0,0,0,0,0
  1961.         dc.b    1
  1962.         dc.w    42
  1963.  
  1964.         dc.b    "00101100",0,0,0,0,0,0,0
  1965.         dc.b    1
  1966.         dc.w    43
  1967.  
  1968.         dc.b    "00101101",0,0,0,0,0,0,0
  1969.         dc.b    1
  1970.         dc.w    44
  1971.  
  1972.         dc.b    "0010111",0,0,0,0,0,0,0,0
  1973.         dc.b    1
  1974.         dc.w    21
  1975.  
  1976.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1977.         dc.b    0
  1978.         dc.w    0
  1979.  
  1980. wt4:    dc.b    "0011000",0,0,0,0,0,0,0,0
  1981.         dc.b    1
  1982.         dc.w    28
  1983.  
  1984.         dc.b    "00110010",0,0,0,0,0,0,0
  1985.         dc.b    1
  1986.         dc.w    61
  1987.  
  1988.         dc.b    "00110011",0,0,0,0,0,0,0
  1989.         dc.b    1
  1990.         dc.w    62
  1991.  
  1992.         dc.b    "00110100",0,0,0,0,0,0,0
  1993.         dc.b    1
  1994.         dc.w    63
  1995.  
  1996.         dc.b    "00110101",0,0,0,0,0,0,0    ;code string null terminated
  1997.         dc.b    1                           ;color: 1=White, 0=Black
  1998.         dc.w    0                           ;run length
  1999.  
  2000.         dc.b    "00111",0,0,0,0,0,0,0,0,0,0
  2001.         dc.b    1
  2002.         dc.w    10
  2003.  
  2004.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2005.         dc.b    0
  2006.         dc.w    0
  2007.  
  2008. wt5:    dc.b    "01000",0,0,0,0,0,0,0,0,0,0
  2009.         dc.b    1
  2010.         dc.w    11
  2011.  
  2012.         dc.b    "0100100",0,0,0,0,0,0,0,0
  2013.         dc.b    1
  2014.         dc.w    27
  2015.  
  2016.         dc.b    "01001010",0,0,0,0,0,0,0
  2017.         dc.b    1
  2018.         dc.w    59
  2019.  
  2020.         dc.b    "01001011",0,0,0,0,0,0,0
  2021.         dc.b    1
  2022.         dc.w    60
  2023.  
  2024.         dc.b    "0100111",0,0,0,0,0,0,0,0
  2025.         dc.b    1
  2026.         dc.w    18
  2027.  
  2028.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2029.         dc.b    0
  2030.         dc.w    0
  2031.  
  2032. wt6:    dc.b    "0101000",0,0,0,0,0,0,0,0
  2033.         dc.b    1
  2034.         dc.w    24
  2035.  
  2036.         dc.b    "01010010",0,0,0,0,0,0,0
  2037.         dc.b    1
  2038.         dc.w    49
  2039.  
  2040.         dc.b    "01010011",0,0,0,0,0,0,0
  2041.         dc.b    1
  2042.         dc.w    50
  2043.  
  2044.         dc.b    "01010100",0,0,0,0,0,0,0
  2045.         dc.b    1
  2046.         dc.w    51
  2047.  
  2048.         dc.b    "01010101",0,0,0,0,0,0,0
  2049.         dc.b    1
  2050.         dc.w    52
  2051.  
  2052.         dc.b    "0101011",0,0,0,0,0,0,0,0
  2053.         dc.b    1
  2054.         dc.w    25
  2055.  
  2056.         dc.b    "01011000",0,0,0,0,0,0,0
  2057.         dc.b    1
  2058.         dc.w    55
  2059.  
  2060.         dc.b    "01011001",0,0,0,0,0,0,0
  2061.         dc.b    1
  2062.         dc.w    56
  2063.  
  2064.         dc.b    "01011010",0,0,0,0,0,0,0
  2065.         dc.b    1
  2066.         dc.w    57
  2067.  
  2068.         dc.b    "01011011",0,0,0,0,0,0,0
  2069.         dc.b    1
  2070.         dc.w    58
  2071.  
  2072.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2073.         dc.b    0
  2074.         dc.w    0
  2075.  
  2076. wt7:    dc.b    "0111",0,0,0,0,0,0,0,0,0,0,0
  2077.         dc.b    1
  2078.         dc.w    2
  2079.  
  2080.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2081.         dc.b    0
  2082.         dc.w    0
  2083.         
  2084. wt8:    dc.b    "1000",0,0,0,0,0,0,0,0,0,0,0
  2085.         dc.b    1
  2086.         dc.w    3
  2087.  
  2088.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2089.         dc.b    0
  2090.         dc.w    0
  2091.         
  2092. wt9:    dc.b    "10011",0,0,0,0,0,0,0,0,0,0
  2093.         dc.b    1
  2094.         dc.w    8
  2095.  
  2096.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2097.         dc.b    0
  2098.         dc.w    0
  2099.  
  2100. wt10:   dc.b    "10100",0,0,0,0,0,0,0,0,0,0
  2101.         dc.b    1
  2102.         dc.w    9
  2103.  
  2104.         dc.b    "101010",0,0,0,0,0,0,0,0,0
  2105.         dc.b    1
  2106.         dc.w    16
  2107.  
  2108.         dc.b    "101011",0,0,0,0,0,0,0,0,0
  2109.         dc.b    1
  2110.         dc.w    17
  2111.  
  2112.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2113.         dc.b    0
  2114.         dc.w    0
  2115.  
  2116. wt11:   dc.b    "1011",0,0,0,0,0,0,0,0,0,0,0
  2117.         dc.b    1
  2118.         dc.w    4
  2119.  
  2120.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2121.         dc.b    0
  2122.         dc.w    0
  2123.         
  2124. wt12:   dc.b    "1100",0,0,0,0,0,0,0,0,0,0,0
  2125.         dc.b    1
  2126.         dc.w    5
  2127.  
  2128.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2129.         dc.b    0
  2130.         dc.w    0
  2131.  
  2132. wt13:   dc.b    "110100",0,0,0,0,0,0,0,0,0
  2133.         dc.b    1
  2134.         dc.w    14
  2135.  
  2136.         dc.b    "110101",0,0,0,0,0,0,0,0,0
  2137.         dc.b    1
  2138.         dc.w    15
  2139.  
  2140.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2141.         dc.b    0
  2142.         dc.w    0
  2143.         
  2144. wt14:   dc.b    "1110",0,0,0,0,0,0,0,0,0,0,0
  2145.         dc.b    1
  2146.         dc.w    6
  2147.  
  2148.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2149.         dc.b    0
  2150.         dc.w    0
  2151.         
  2152. wt15:   dc.b    "1111",0,0,0,0,0,0,0,0,0,0,0
  2153.         dc.b    1
  2154.         dc.w    7
  2155.  
  2156.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2157.         dc.b    0
  2158.         dc.w    0
  2159.  
  2160. wmakeupcodes:           ;OPTOMIZED!
  2161.  
  2162. wm1:    ;dc.b    "000000000001",0,0,0
  2163.         ;dc.b    1
  2164.         ;dc.w    0    ;EOL
  2165.  
  2166.     dc.b    "00000001000",0,0,0,0
  2167.         dc.b    1                    
  2168.         dc.w    1792
  2169.  
  2170.     dc.b    "000000010010",0,0,0
  2171.         dc.b    1
  2172.         dc.w    1984
  2173.         
  2174.     dc.b    "000000010011",0,0,0
  2175.         dc.b    1
  2176.         dc.w    2048
  2177.         
  2178.     dc.b    "000000010100",0,0,0
  2179.         dc.b    1
  2180.         dc.w    2112
  2181.         
  2182.     dc.b    "000000010101",0,0,0
  2183.         dc.b    1
  2184.         dc.w    2176
  2185.         
  2186.     dc.b    "000000010110",0,0,0
  2187.         dc.b    1
  2188.         dc.w    2240
  2189.         
  2190.     dc.b    "000000010111",0,0,0
  2191.         dc.b    1
  2192.         dc.w    2304
  2193.  
  2194.     dc.b    "00000001100",0,0,0,0
  2195.         dc.b    1
  2196.         dc.w    1856
  2197.         
  2198.     dc.b    "00000001101",0,0,0,0
  2199.         dc.b    1
  2200.         dc.w    1920
  2201.                 
  2202.     dc.b    "000000011100",0,0,0
  2203.         dc.b    1
  2204.         dc.w    2368
  2205.         
  2206.     dc.b    "000000011101",0,0,0
  2207.         dc.b    1
  2208.         dc.w    2432
  2209.         
  2210.     dc.b    "000000011110",0,0,0
  2211.         dc.b    1
  2212.         dc.w    2496
  2213.         
  2214.     dc.b    "000000011111",0,0,0
  2215.         dc.b    1
  2216.         dc.w    2560
  2217.  
  2218.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2219.         dc.b    0
  2220.         dc.w    0
  2221.  
  2222. wm2:    dc.b    "00110110",0,0,0,0,0,0,0
  2223.         dc.b    1
  2224.         dc.w    320    
  2225.  
  2226.         dc.b    "00110111",0,0,0,0,0,0,0
  2227.         dc.b    1
  2228.         dc.w    384
  2229.  
  2230.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2231.         dc.b    0
  2232.         dc.w    0
  2233.  
  2234. wm3:    dc.b    "010011000",0,0,0,0,0,0
  2235.         dc.b    1
  2236.         dc.w    1472
  2237.  
  2238.         dc.b    "010011001",0,0,0,0,0,0
  2239.         dc.b    1
  2240.         dc.w    1536
  2241.  
  2242.         dc.b    "010011010",0,0,0,0,0,0
  2243.         dc.b    1
  2244.         dc.w    1600
  2245.  
  2246.         dc.b    "010011011",0,0,0,0,0,0
  2247.         dc.b    1
  2248.         dc.w    1728
  2249.  
  2250.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2251.         dc.b    0
  2252.         dc.w    0
  2253.  
  2254. wm4:    dc.b    "010111",0,0,0,0,0,0,0,0,0
  2255.         dc.b    1
  2256.         dc.w    192
  2257.  
  2258.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2259.         dc.b    0
  2260.         dc.w    0
  2261.  
  2262. wm5:    dc.b    "01100100",0,0,0,0,0,0,0
  2263.         dc.b    1
  2264.         dc.w    448
  2265.  
  2266.         dc.b    "01100101",0,0,0,0,0,0,0
  2267.         dc.b    1
  2268.         dc.w    512    
  2269.  
  2270.         dc.b    "011001100",0,0,0,0,0,0
  2271.         dc.b    1
  2272.         dc.w    704
  2273.  
  2274.         dc.b    "011001101",0,0,0,0,0,0
  2275.         dc.b    1
  2276.         dc.w    768
  2277.  
  2278.         dc.b    "01100111",0,0,0,0,0,0,0
  2279.         dc.b    1
  2280.         dc.w    640
  2281.  
  2282.         dc.b    "01101000",0,0,0,0,0,0,0
  2283.         dc.b    1
  2284.         dc.w    576
  2285.  
  2286.         dc.b    "011010010",0,0,0,0,0,0
  2287.         dc.b    1
  2288.         dc.w    832
  2289.  
  2290.         dc.b    "011010011",0,0,0,0,0,0
  2291.         dc.b    1
  2292.         dc.w    896
  2293.  
  2294.         dc.b    "011010100",0,0,0,0,0,0
  2295.         dc.b    1
  2296.         dc.w    960
  2297.  
  2298.         dc.b    "011010101",0,0,0,0,0,0
  2299.         dc.b    1
  2300.         dc.w    1024
  2301.  
  2302.         dc.b    "011010110",0,0,0,0,0,0
  2303.         dc.b    1
  2304.         dc.w    1088
  2305.  
  2306.         dc.b    "011010111",0,0,0,0,0,0
  2307.         dc.b    1
  2308.         dc.w    1152
  2309.  
  2310.         dc.b    "011011000",0,0,0,0,0,0
  2311.         dc.b    1
  2312.         dc.w    1216
  2313.  
  2314.         dc.b    "011011001",0,0,0,0,0,0
  2315.         dc.b    1
  2316.         dc.w    1280
  2317.  
  2318.         dc.b    "011011010",0,0,0,0,0,0
  2319.         dc.b    1
  2320.         dc.w    1344
  2321.  
  2322.         dc.b    "011011011",0,0,0,0,0,0
  2323.         dc.b    1
  2324.         dc.w    1408
  2325.  
  2326.         dc.b    "0110111",0,0,0,0,0,0,0,0
  2327.         dc.b    1
  2328.         dc.w    256
  2329.  
  2330.         dc.b    "011000",0,0,0,0,0,0,0,0,0
  2331.         dc.b    1
  2332.         dc.w    1664
  2333.  
  2334.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2335.         dc.b    0
  2336.         dc.w    0
  2337.  
  2338. wm6:    dc.b    "10010",0,0,0,0,0,0,0,0,0,0
  2339.         dc.b    1
  2340.         dc.w    128
  2341.  
  2342.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2343.         dc.b    0
  2344.         dc.w    0
  2345.  
  2346. wm7:    dc.b    "11011",0,0,0,0,0,0,0,0,0,0
  2347.         dc.b    1
  2348.         dc.w    64          
  2349.        
  2350.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2351.         dc.b    1
  2352.         dc.w    0
  2353.         
  2354.                 
  2355. btermcodes:     ;OPTOMIZED!
  2356.  
  2357.         dc.b    "11",0,0,0,0,0,0,0,0,0,0,0,0,0
  2358.         dc.b    0
  2359.         dc.w    2
  2360.         
  2361.         dc.b    "10",0,0,0,0,0,0,0,0,0,0,0,0,0
  2362.         dc.b    0
  2363.         dc.w    3
  2364.         
  2365.         dc.b    "010",0,0,0,0,0,0,0,0,0,0,0,0
  2366.         dc.b    0
  2367.         dc.w    1
  2368.         
  2369.         dc.b    "011",0,0,0,0,0,0,0,0,0,0,0,0
  2370.         dc.b    0
  2371.         dc.w    4
  2372.         
  2373.         dc.b    "0011",0,0,0,0,0,0,0,0,0,0,0
  2374.         dc.b    0
  2375.         dc.w    5
  2376.         
  2377.         dc.b    "0010",0,0,0,0,0,0,0,0,0,0,0
  2378.         dc.b    0
  2379.         dc.w    6
  2380.         
  2381.         dc.b    "00011",0,0,0,0,0,0,0,0,0,0
  2382.         dc.b    0
  2383.         dc.w    7
  2384.  
  2385.         dc.b    "000101",0,0,0,0,0,0,0,0,0
  2386.         dc.b    0
  2387.         dc.w    8
  2388.  
  2389.         dc.b    "000100",0,0,0,0,0,0,0,0,0
  2390.         dc.b    0
  2391.         dc.w    9
  2392.  
  2393.         dc.b    "0000100",0,0,0,0,0,0,0,0
  2394.         dc.b    0
  2395.         dc.w    10
  2396.  
  2397.         dc.b    "0000101",0,0,0,0,0,0,0,0
  2398.         dc.b    0
  2399.         dc.w    11
  2400.  
  2401.         dc.b    "0000111",0,0,0,0,0,0,0,0
  2402.         dc.b    0
  2403.         dc.w    12
  2404.  
  2405.         dc.b    "00000100",0,0,0,0,0,0,0
  2406.         dc.b    0
  2407.         dc.w    13
  2408.  
  2409.         dc.b    "00000111",0,0,0,0,0,0,0
  2410.         dc.b    0
  2411.         dc.w    14
  2412.  
  2413.         dc.b    "000011000",0,0,0,0,0,0
  2414.         dc.b    0
  2415.         dc.w    15
  2416.  
  2417.         dc.b    "0000010111",0,0,0,0,0
  2418.         dc.b    0
  2419.         dc.w    16
  2420.  
  2421.         dc.b    "0000110111",0,0,0,0,0
  2422.         dc.b    0
  2423.         dc.w    0
  2424.         
  2425.         dc.b    "0000011000",0,0,0,0,0
  2426.         dc.b    0
  2427.         dc.w    17
  2428.  
  2429.         dc.b    "0000001000",0,0,0,0,0
  2430.         dc.b    0
  2431.         dc.w    18
  2432.  
  2433.         dc.b    "00001100111",0,0,0,0
  2434.         dc.b    0
  2435.         dc.w    19
  2436.  
  2437.         dc.b    "00001101000",0,0,0,0
  2438.         dc.b    0
  2439.         dc.w    20
  2440.  
  2441.         dc.b    "00001101100",0,0,0,0
  2442.         dc.b    0
  2443.         dc.w    21
  2444.  
  2445.         dc.b    "00000110111",0,0,0,0
  2446.         dc.b    0
  2447.         dc.w    22
  2448.  
  2449.         dc.b    "00000101000",0,0,0,0
  2450.         dc.b    0
  2451.         dc.w    23
  2452.  
  2453.         dc.b    "00000010111",0,0,0,0
  2454.         dc.b    0
  2455.         dc.w    24
  2456.         
  2457.         dc.b    "00000011000",0,0,0,0
  2458.         dc.b    0
  2459.         dc.w    25
  2460.  
  2461.         dc.b    "000011001010",0,0,0
  2462.         dc.b    0
  2463.         dc.w    26
  2464.  
  2465.         dc.b    "000011001011",0,0,0
  2466.         dc.b    0
  2467.         dc.w    27
  2468.  
  2469.         dc.b    "000011001100",0,0,0
  2470.         dc.b    0
  2471.         dc.w    28
  2472.  
  2473.         dc.b    "000011001101",0,0,0
  2474.         dc.b    0
  2475.         dc.w    29
  2476.  
  2477.         dc.b    "000001101000",0,0,0
  2478.         dc.b    0
  2479.         dc.w    30
  2480.  
  2481.         dc.b    "000001101001",0,0,0
  2482.         dc.b    0
  2483.         dc.w    31
  2484.  
  2485.         dc.b    "000001101010",0,0,0
  2486.         dc.b    0
  2487.         dc.w    32
  2488.  
  2489.         dc.b    "000001101011",0,0,0
  2490.         dc.b    0
  2491.         dc.w    33
  2492.  
  2493.         dc.b    "000011010010",0,0,0
  2494.         dc.b    0
  2495.         dc.w    34
  2496.  
  2497.         dc.b    "000011010011",0,0,0
  2498.         dc.b    0
  2499.         dc.w    35
  2500.  
  2501.         dc.b    "000011010100",0,0,0
  2502.         dc.b    0
  2503.         dc.w    36
  2504.  
  2505.         dc.b    "000011010101",0,0,0
  2506.         dc.b    0
  2507.         dc.w    37
  2508.  
  2509.         dc.b    "000011010110",0,0,0
  2510.         dc.b    0
  2511.         dc.w    38
  2512.  
  2513.         dc.b    "000011010111",0,0,0
  2514.         dc.b    0
  2515.         dc.w    39
  2516.  
  2517.         dc.b    "000001101100",0,0,0
  2518.         dc.b    0
  2519.         dc.w    40
  2520.  
  2521.         dc.b    "000001101101",0,0,0
  2522.         dc.b    0
  2523.         dc.w    41
  2524.  
  2525.         dc.b    "000011011010",0,0,0
  2526.         dc.b    0
  2527.         dc.w    42
  2528.  
  2529.         dc.b    "000011011011",0,0,0
  2530.         dc.b    0
  2531.         dc.w    43
  2532.  
  2533.         dc.b    "000001010100",0,0,0
  2534.         dc.b    0
  2535.         dc.w    44
  2536.  
  2537.         dc.b    "000001010101",0,0,0
  2538.         dc.b    0
  2539.         dc.w    45
  2540.  
  2541.         dc.b    "000001010110",0,0,0
  2542.         dc.b    0
  2543.         dc.w    46
  2544.  
  2545.         dc.b    "000001010111",0,0,0
  2546.         dc.b    0
  2547.         dc.w    47
  2548.  
  2549.         dc.b    "000001100100",0,0,0
  2550.         dc.b    0
  2551.         dc.w    48
  2552.  
  2553.         dc.b    "000001100101",0,0,0
  2554.         dc.b    0
  2555.         dc.w    49
  2556.  
  2557.         dc.b    "000001010010",0,0,0
  2558.         dc.b    0
  2559.         dc.w    50
  2560.  
  2561.         dc.b    "000001010011",0,0,0
  2562.         dc.b    0
  2563.         dc.w    51
  2564.  
  2565.         dc.b    "000000100100",0,0,0
  2566.         dc.b    0
  2567.         dc.w    52
  2568.  
  2569.         dc.b    "000000110111",0,0,0
  2570.         dc.b    0
  2571.         dc.w    53
  2572.  
  2573.         dc.b    "000000111000",0,0,0
  2574.         dc.b    0
  2575.         dc.w    54
  2576.  
  2577.         dc.b    "000000100111",0,0,0
  2578.         dc.b    0
  2579.         dc.w    55
  2580.  
  2581.         dc.b    "000000101000",0,0,0
  2582.         dc.b    0
  2583.         dc.w    56
  2584.  
  2585.         dc.b    "000001011000",0,0,0
  2586.         dc.b    0
  2587.         dc.w    57
  2588.  
  2589.         dc.b    "000001011001",0,0,0
  2590.         dc.b    0
  2591.         dc.w    58
  2592.  
  2593.         dc.b    "000000101011",0,0,0
  2594.         dc.b    0
  2595.         dc.w    59
  2596.  
  2597.         dc.b    "000000101100",0,0,0
  2598.         dc.b    0
  2599.         dc.w    60
  2600.  
  2601.         dc.b    "000001011010",0,0,0
  2602.         dc.b    0
  2603.         dc.w    61
  2604.  
  2605.         dc.b    "000001100110",0,0,0
  2606.         dc.b    0
  2607.         dc.w    62
  2608.  
  2609.         dc.b    "000001100111",0,0,0
  2610.         dc.b    0
  2611.         dc.w    63
  2612.  
  2613.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2614.         dc.b    0
  2615.         dc.w    0
  2616.         
  2617. bmakeupcodes:
  2618.  
  2619.         dc.b    "0000001111",0,0,0,0,0
  2620.         dc.b    0
  2621.         dc.w    64
  2622.  
  2623.         dc.b    "000011001000",0,0,0
  2624.         dc.b    0
  2625.         dc.w    128
  2626.  
  2627.         dc.b    "000011001001",0,0,0
  2628.         dc.b    0
  2629.         dc.w    192
  2630.  
  2631.         dc.b    "000001011011",0,0,0
  2632.         dc.b    0
  2633.         dc.w    256
  2634.  
  2635.         dc.b    "000000110011",0,0,0
  2636.         dc.b    0
  2637.         dc.w    320
  2638.  
  2639.         dc.b    "000000110100",0,0,0
  2640.         dc.b    0
  2641.         dc.w    384
  2642.  
  2643.         dc.b    "000000110101",0,0,0
  2644.         dc.b    0
  2645.         dc.w    448
  2646.  
  2647.         dc.b    "0000001101100",0,0
  2648.         dc.b    0
  2649.         dc.w    512
  2650.  
  2651.         dc.b    "0000001101101",0,0
  2652.         dc.b    0
  2653.         dc.w    576
  2654.  
  2655.         dc.b    "0000001001010",0,0
  2656.         dc.b    0
  2657.         dc.w    640
  2658.  
  2659.         dc.b    "0000001001011",0,0
  2660.         dc.b    0
  2661.         dc.w    704
  2662.  
  2663.         dc.b    "0000001001100",0,0
  2664.         dc.b    0
  2665.         dc.w    768
  2666.  
  2667.         dc.b    "0000001001101",0,0
  2668.         dc.b    0
  2669.         dc.w    832
  2670.  
  2671.         dc.b    "0000001110010",0,0
  2672.         dc.b    0
  2673.         dc.w    896
  2674.  
  2675.         dc.b    "0000001110011",0,0
  2676.         dc.b    0
  2677.         dc.w    960
  2678.  
  2679.         dc.b    "0000001110100",0,0
  2680.         dc.b    0
  2681.         dc.w    1024
  2682.  
  2683.         dc.b    "0000001110101",0,0
  2684.         dc.b    0
  2685.         dc.w    1088
  2686.  
  2687.         dc.b    "0000001110110",0,0
  2688.         dc.b    0
  2689.         dc.w    1152
  2690.  
  2691.         dc.b    "0000001110111",0,0
  2692.         dc.b    0
  2693.         dc.w    1216
  2694.  
  2695.         dc.b    "0000001010010",0,0
  2696.         dc.b    0
  2697.         dc.w    1280
  2698.  
  2699.         dc.b    "0000001010011",0,0
  2700.         dc.b    0
  2701.         dc.w    1344
  2702.  
  2703.         dc.b    "0000001010100",0,0
  2704.         dc.b    0
  2705.         dc.w    1408
  2706.  
  2707.         dc.b    "0000001010101",0,0
  2708.         dc.b    0
  2709.         dc.w    1472
  2710.  
  2711.         dc.b    "0000001011010",0,0
  2712.         dc.b    0
  2713.         dc.w    1536
  2714.  
  2715.         dc.b    "0000001011011",0,0
  2716.         dc.b    0
  2717.         dc.w    1600
  2718.  
  2719.         dc.b    "0000001100100",0,0
  2720.         dc.b    0
  2721.         dc.w    1664
  2722.  
  2723.         dc.b    "0000001100101",0,0
  2724.         dc.b    0
  2725.         dc.w    1728
  2726.  
  2727.     dc.b    "00000001000",0,0,0,0
  2728.         dc.b    0                    
  2729.         dc.w    1792
  2730.  
  2731.     dc.b    "00000001100",0,0,0,0
  2732.         dc.b    0
  2733.         dc.w    1856
  2734.         
  2735.     dc.b    "00000001101",0,0,0,0
  2736.         dc.b    0
  2737.         dc.w    1920
  2738.         
  2739.     dc.b    "000000010010",0,0,0
  2740.         dc.b    0
  2741.         dc.w    1984
  2742.         
  2743.     dc.b    "000000010011",0,0,0
  2744.         dc.b    0
  2745.         dc.w    2048
  2746.         
  2747.     dc.b    "000000010100",0,0,0
  2748.         dc.b    0
  2749.         dc.w    2112
  2750.         
  2751.     dc.b    "000000010101",0,0,0
  2752.         dc.b    0
  2753.         dc.w    2176
  2754.         
  2755.     dc.b    "000000010110",0,0,0
  2756.         dc.b    0
  2757.         dc.w    2240
  2758.         
  2759.     dc.b    "000000010111",0,0,0
  2760.         dc.b    0
  2761.         dc.w    2304
  2762.         
  2763.     dc.b    "000000011100",0,0,0
  2764.         dc.b    0
  2765.         dc.w    2368
  2766.         
  2767.     dc.b    "000000011101",0,0,0
  2768.         dc.b    0
  2769.         dc.w    2432
  2770.         
  2771.     dc.b    "000000011110",0,0,0
  2772.         dc.b    0
  2773.         dc.w    2496
  2774.         
  2775.     dc.b    "000000011111",0,0,0
  2776.         dc.b    0
  2777.         dc.w    2560
  2778.  
  2779.         dc.b    "000000000001",0,0,0
  2780.         dc.b    0
  2781.         dc.w    0       ;EOL
  2782.         
  2783.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2784.         dc.b    0
  2785.         dc.w    0
  2786.  
  2787.  
  2788. special:
  2789.     dc.w    2
  2790.     dc.l    spcl1,spcl2
  2791.  
  2792. vers:   dc.b    "$VER: "
  2793. name:    dc.b    "TIFF  v2.0.6",0
  2794.  
  2795. spcl1:    dc.b    "Picture Window",0
  2796. spcl2:    dc.b    "Object",0
  2797.  
  2798.  
  2799. typelen:    dc.b    0,0,0,1,2,3        ;shift count
  2800.  
  2801. pctypetbl:    dc.b    PC_BW,PC_BW,PC_RGB,PC_PALET,PC_BW
  2802.  
  2803.  
  2804. **********************************************************************
  2805. **********************************************************************
  2806.  SECTION TIFF,BSS,PUBLIC
  2807. temp:        ds.l    1
  2808. temp2:        ds.l    1
  2809. picptr:        ds.l    1
  2810. pptr:        ds.l    1
  2811. pic:        ds.w    pc_Sizeof/2
  2812. object:        ds.w    ob_SizeOf/2
  2813. compression:    ds.w    1
  2814. byteorder:    ds.w    1
  2815. striplength:    ds.l    1
  2816.  
  2817. bps:        ds.w    1
  2818. sbctype:        ds.w    1
  2819. sbc:        ds.l    1
  2820. photom:        ds.w    1
  2821. planar:        ds.w    1
  2822. predictor:    ds.w    1
  2823. resunits:    ds.w    1
  2824. sppixel:    ds.w    1
  2825. xres:        ds.w    1
  2826. yres:        ds.w    1
  2827.  
  2828. picture:    ds.l    1
  2829. picoffset:    ds.l    1
  2830. piclength:    ds.l    1
  2831.  
  2832. tagcount:    ds.w    1
  2833. tagid:        ds.w    1
  2834. tagtype:    ds.w    1
  2835. taglength:    ds.l    1
  2836. tagvalue:    ds.l    1
  2837.  
  2838. work:           ds.l    4
  2839. bytecount:      ds.l    1
  2840. pixcount:       ds.w    1
  2841. pixpos:         ds.w    1
  2842. saved1:         ds.l    1
  2843. savea0:         ds.l    1
  2844. oddtest:        ds.l    1
  2845. rowcount:       ds.l    1
  2846. rps:            ds.l    1
  2847. hcount:         ds.w    1
  2848. plnlen:         ds.l    1
  2849. apos1:          ds.l    1
  2850. apos2:          ds.l    1
  2851. bitcount:       ds.w    1
  2852. plncnt:         ds.w    1
  2853. picptrsave:     ds.l    1
  2854. lastval:        ds.l    1
  2855. picptr2:        ds.l    1
  2856. picptrsave2:    ds.l    1
  2857. palcount:       ds.l    1
  2858. palsize:        ds.l    1
  2859. palptr:         ds.l    1
  2860. cmapoffset:     ds.l    1
  2861. spsave:         ds.l    1
  2862. flag:           ds.w    1
  2863. prefix:         ds.l    1
  2864. suffix:         ds.l    1
  2865. outcode:        ds.l    1
  2866. tagskip:        ds.l    1
  2867.  
  2868. ******************************* CHANGES ********************************
  2869. ;
  2870. ;       version 2.0.6
  2871. ;
  2872. ;       - added a version string
  2873. ;
  2874. ;       - fixed some bugs related to exiting on an error condition (errrts)
  2875. ;
  2876. ;
  2877. ;       version 2.0.5
  2878. ;
  2879. ;       - fixed bug when importing a PALETTE tiff image: the get info routine
  2880. ;         would store the 3 times total number of colors in the cmap.
  2881. ;
  2882. ;       - fixed bug when tiff image had multiple rows per strip
  2883. ;
  2884. ;       - added kludge for ADPro files with <20 DPI it puts it up to 75       
  2885. ;
  2886. ;
  2887. ;       version 2.0.4   (shipped w/ PageStream2.1 12/10/90)
  2888. ;
  2889. ;       - fixed bug in PackBits de-compression  routine that caused
  2890. ;         the de-compression to run on past it's boundries.
  2891. ;         (which in turn caused system problems w/ NewShell & IconX)
  2892. ;
  2893. ;
  2894. ;       version 2.0.3   (uploaded 11/16/90)
  2895. ;
  2896. ;       - increased speed of LZW de-compression
  2897. ;
  2898. ;       - clean up the code to decrease size.
  2899. ;         (b&w uses the same stuff as multiplane now)
  2900. ;
  2901. ;
  2902. ;       version 2.0.2   (uploaded 9/25/90)
  2903. ;
  2904. ;       - bug fix: now no longer assumes that the StripByteCount is the 
  2905. ;         same data type as the StripOffset (indirectly assumed)
  2906. ;
  2907. ;       - added support for packbits compressed multiplane images
  2908. ;         (grey scale, rgb color, and palette color)
  2909. ;
  2910. ;
  2911. ;       version 2.0.1
  2912. ;
  2913. ;       - released with PageStream 2.0
  2914. ;
  2915. ;       - MAJOR UPDATE: now imports most any tiff file, b&w, grey scale,
  2916. ;         rgb, palette, ccitt compressed, packbits compressed, lzw 
  2917. ;         compressed, and horizontally differenced lzw compressed.
  2918. ;
  2919. ;
  2920. ;        version 2.0.0
  2921. ;
  2922. ;       - initial release (same as 1.8 version)
  2923.