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