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

  1.  
  2.  Include "equ.h"
  3.  Include "impequ.h"
  4.  
  5.  SECTION IFF,CODE,PUBLIC
  6.  
  7. ***************************************************
  8. ***                        ***
  9. ***************************************************
  10. dumbentry:
  11.     clr.l    d0
  12.     rts
  13.  
  14.     dc.l    "IMPP"        ; magik number for pic import
  15.     dc.w    200
  16.     dc.l    0
  17.  
  18. table:    dc.l    0
  19.     dc.l    name,special,check,IFF
  20.  
  21.  
  22. *****************************
  23. * Is it really IFF ILBM?    *
  24. *****************************
  25. check:    move.l    table,a0
  26.     move.l    buff1(a0),a1
  27.     move.l    (a1),a1
  28.     cmp.l    #"FORM",(a1)
  29.     bne    never
  30.     cmp.l    #"ILBM",8(a1)
  31.     beq    right
  32.         cmp.l   #"ACBM",8(a1)
  33.         bne     never
  34.     bra    right
  35.  
  36.  
  37.  
  38. ***********************************
  39. ***                             ***
  40. ***********************************
  41. IFF:    move.l    sp,savesp
  42.         clr.l   rtable
  43.         clr.l   gtable
  44.         clr.l   btable
  45.         clr.l   palhndl
  46.         clr.l   ctblptr
  47.         clr.b   flag
  48.  
  49.     move.l    table,a0
  50.     move.l    f_openr(a0),a0
  51.     jsr    (a0)
  52.     beq    rrts
  53.  
  54.     move.l    table,a0
  55.     move.l    spclnum(a0),a0
  56.     cmp.w    #1,(a0)
  57.     beq    impobj
  58.         
  59.         
  60. *********************************
  61. *                               *
  62. *********************************
  63. imppic:    move.l    table,a0
  64.     move.l    p_open(a0),a0
  65.     jsr    (a0)
  66.     beq    rrts
  67.  
  68.     bsr    getpicinfo
  69.  
  70.     move.l    table,a4
  71.     move.l    cwptr(a4),a4        ;ptr to window handle
  72.     move.l    (a4),a4            ;window handle
  73.     move.l    (a4),a4            ;ptr to window structure
  74.         
  75.     lea    pic,a0
  76.     move.w    pc_Type(a0),pi_Type(a4)
  77.     move.w    pc_SFreq(a0),pi_SFreq(a4)
  78.     move.w    pc_SAngle(a0),pi_SAngle(a4)
  79.     move.w    pc_SSpot(a0),pi_SSpot(a4)
  80.     move.l    pc_SMap(a0),pi_SMap(a4)
  81.     move.l    pc_SMap+4(a0),pi_SMap+4(a4)
  82.     move.w    pc_XDpi(a0),pi_XDpi(a4)
  83.     move.w    pc_YDpi(a0),pi_YDpi(a4)
  84.     move.w    pc_W(a0),pi_W(a4)
  85.     move.w    pc_H(a0),pi_H(a4)
  86.     move.w    pc_Width(a0),pi_Width(a4)
  87.     move.w    pc_BitPln(a0),pi_BitPln(a4)
  88.     move.w    pc_Palet(a0),pi_Palet(a4)
  89.  
  90.     move.w    pi_Palet(a4),d1
  91.     mulu    #pl_Sizeof,d1
  92.     move.w    pi_Width(a4),d0
  93.     mulu    pi_BitPln(a4),d0
  94.     mulu    pi_H(a4),d0
  95.     add.l    d1,d0        ;size of bitmap +( 4 words * #colors)
  96.  
  97.     clr.w    d1
  98.     clr.w    d2
  99.     move.l    table,a0
  100.     move.l    m_alloc(a0),a0
  101.     jsr    (a0)
  102.     beq    abortpic
  103.  
  104.     move.l    table,a3
  105.     move.l    cwptr(a3),a3
  106.     move.l    (a3),a3
  107.     move.l    (a3),a3
  108.     move.l    a0,pi_Ptr(a3)
  109.     move.l    (a0),a4
  110.     move.l    a4,picptr
  111.  
  112.         bsr     putcolor
  113.         
  114.         btst    #6,flag                 ;is this an ACBM picture?
  115.         beq     ip1                     ;no
  116.         bsr     putACBM
  117.         bra     ip2
  118. ip1:    bsr    putILBM
  119.  
  120. ip2:    move.l    table,a0
  121.     move.l    p_close(a0),a0
  122.     jsr    (a0)
  123.  
  124.     move.l    table,a0
  125.     move.l    f_closer(a0),a0
  126.     jmp    (a0)
  127.  
  128.  
  129. abortpic:
  130.     move.l    table,a0
  131.     move.l    p_abort(a0),a0
  132.     jsr    (a0)
  133.  
  134. abort0:    move.l    table,a0
  135.     move.l    f_closer(a0),a0
  136.     jmp    (a0)
  137.  
  138.  
  139. *********************************
  140. *                               *
  141. *********************************
  142. impobj:    move.l    table,a0
  143.     move.l    o_open(a0),a0
  144.     jsr    (a0)
  145.     beq    abort0
  146.  
  147.     bsr    getpicinfo
  148.         
  149.     move.b    #tpic,object+ob_Type
  150.     clr.l    object+ob_Left
  151.     clr.l    object+ob_Top
  152.  
  153.     move.w    pic+pc_W,d1
  154.     move.l    #7200,d0
  155.     bsr    Mulu1632
  156.     move.w    pic+pc_XDpi,d2
  157.     bsr    Divu1648
  158.     move.l    d0,object+ob_Right
  159.  
  160.     move.w    pic+pc_H,d1
  161.     move.l    #7200,d0
  162.     bsr    Mulu1632
  163.     move.w    pic+pc_YDpi,d2
  164.     bsr    Divu1648
  165.     move.l    d0,object+ob_Bottom
  166.  
  167.     clr.b    object+ob_Flag
  168.     clr.w    object+ob_Slant
  169.     clr.w    object+ob_Twist
  170.     move.w    #50,object+ob_LWidth        ;1 point line
  171.     clr.b    object+ob_LType            ;no line
  172.     move.b    #1,object+ob_LColor        ;black line
  173.     clr.b    object+ob_FType            ;no fill
  174.     move.b    #1,object+ob_FColor        ;black fill
  175.     clr.b    object+ob_LBegin
  176.     clr.b    object+ob_LEnd
  177.     move.w    #900,object+ob_HStandOff    ;1/8 inch
  178.     move.w    #900,object+ob_VStandOff    ;1/8 inch
  179.  
  180.     move.l    table,a1
  181.     move.l    o_obj(a1),a1
  182.     lea    object,a0
  183.     jsr    (a1)
  184.     beq    abortobj
  185.  
  186.     move.w    pic+pc_Width,d0
  187.     mulu    pic+pc_BitPln,d0
  188.     mulu    pic+pc_H,d0
  189.     move.w    pic+pc_Palet,d1
  190.     mulu    #pl_Sizeof,d1
  191.     add.l    d1,d0
  192.     add.l    #pc_Sizeof,d0
  193.  
  194.     move.l    table,a0
  195.     move.l    o_malloc(a0),a0
  196.     jsr    (a0)
  197.     beq    abortobj
  198.  
  199.     lea    pic,a1
  200.     clr.l    pc_DPtr(a1)
  201.     clr.w    pc_DScale(a1)
  202.     move.w    pc_Palet(a1),d0
  203.     mulu    #pl_Sizeof,d0
  204.     add.l    #pc_Sizeof,d0
  205.     move.l    d0,pc_Ptr(a1)
  206.  
  207.     move.w    #pc_Sizeof/2-1,d0
  208. oppic1:    move.w    (a1)+,(a0)+
  209.     dbf    d0,oppic1
  210.     move.l    a0,picptr
  211.  
  212.     bsr    putcolor
  213.         btst    #6,flag
  214.         beq     io1
  215.         bsr     putACBM
  216.         bra     io2
  217. io1:    bsr    putILBM
  218.  
  219. io2:    move.l    table,a0
  220.     move.l    o_close(a0),a0
  221.     jsr    (a0)
  222.  
  223.     move.l    table,a0
  224.     move.l    f_closer(a0),a0
  225.     jmp    (a0)
  226.  
  227.  
  228. abortobj:
  229.     move.l    table,a0
  230.     move.l    o_abort(a0),a0
  231.     jsr    (a0)
  232.  
  233.     move.l    table,a0
  234.     move.l    f_closer(a0),a0
  235.     jmp    (a0)
  236.         
  237.         
  238. *********************************
  239. *                               *
  240. *********************************
  241. getpicinfo:
  242.     lea    pic,a0
  243.     move.w    #pc_Sizeof-1,d0
  244. gpi1:    clr.b    (a0)+
  245.     dbra    d0,gpi1
  246.  
  247.         move.w    #-1,pic+pc_SFreq
  248.     move.w    #-1,pic+pc_SAngle
  249.  
  250.     clr.b    flag
  251.     clr.l    palhndl
  252.     clr.l    vport
  253.  
  254.     bsr    pgetl        ; "FORM"
  255.     bsr    pgetl        ; length of form
  256.     move.l    d0,length
  257.     bsr    pgetl        ; "ILBM"
  258.     sub.l    #4,length
  259.         cmp.l   #"ILBM",d0
  260.         beq     getchunk
  261.         bset    #6,flag         ;set the ACBM flag
  262.  
  263. getchunk:
  264.     bsr    pgetl        ;get chunk type in temp (CMAP, BODY, etc.)
  265.     move.l    d0,temp
  266.     bsr    pgetl           ;get chunk length in clength
  267.     move.l    d0,clength
  268.         beq     getchunk        ;skip 0 length chunk
  269.     sub.l    #8,length       ;sub 8 from length of file left
  270.     move.l    temp,d0
  271.         
  272.     lea    chunks-4,a0     ;get address of chunk table
  273.     move.w    numchunks,d1    ;number of chunks in table
  274.  
  275. gc1:    lea    4(a0),a0        ;get address of next chunk type
  276.     cmp.l    (a0)+,d0        
  277.     dbeq    d1,gc1          ;loop until end of table or a match
  278.  
  279.     tst.l    (a0)            ;did i find one? or is it the last one (BODY)
  280.     beq    gc2             ;no
  281.  
  282.     move.l    (a0),a0         ;get address of routine to use for this chunk
  283.     jsr    (a0)            ;do it
  284.  
  285.     tst.l    length          ;is there any data left in the file?
  286.     bne    getchunk        ;yes
  287.     bra    errrts          ;no - so get out
  288.  
  289. gc2:    btst    #0,flag         ;did i find a BMHD?
  290.     beq    errrts        ;no - so get out
  291.         
  292.         btst    #6,flag         ;is this an ACBM picture?
  293.         bne     rrts            ;yes
  294.         
  295.         btst    #3,flag         ;is this a Digi-View picture?
  296.         bne     rrts            ;yes!
  297.         
  298.         btst    #4,flag         ;is this a dynamic hires picture?
  299.         bne     rrts            ;yes!
  300.         
  301.         btst    #2,flag         ;did i find a CLUT?
  302.         bne     rrts            ;yes!
  303.     
  304.         ;btst    #1,flag         ;did i find a CMAP?
  305.     ;beq    errrts        ;no - so don't load image
  306.         
  307. rrts:    rts                     ;everything is OK
  308.  
  309.  
  310. *********************************
  311. *                               *
  312. *********************************
  313. bmhd:    bset    #0,flag            ; found a BMHD
  314.  
  315.     bsr    pgetw
  316.     move.w    d0,pc_W+pic        ; width in pixels
  317.     add.w    #15,d0
  318.     lsr.w    #3,d0
  319.     bclr    #0,d0
  320.     move.w    d0,pc_Width+pic        ; width in bytes (even)
  321.  
  322.     bsr    pgetw
  323.     move.w    d0,pc_H+pic        ; height in pixels
  324.  
  325.     mulu    pc_Width+pic,d0
  326.     move.l    d0,planesize
  327.  
  328.     bsr    pgetl            ; skip x,y
  329.  
  330.     bsr    pget            ; number of bitplanes
  331.     clr.w    pic+pc_BitPln
  332.     move.b    d0,pic+pc_BitPln+1
  333.     move.w    pic+pc_BitPln,truebitpln
  334.         
  335.         btst    #6,flag                 ;is this a ACBM picture?
  336.         beq     bmhd0                   ;no
  337.         cmp.w   #32,pic+pc_BitPln       ;is it a toaster file?
  338.         bne     bmhd0                   ;no
  339.         move.w  #24,pic+pc_BitPln       ;if yes then set it to 24 bitplanes
  340.  
  341. bmhd0:    bsr    pget
  342.     bsr    pget            ; type of compression
  343.     move.b    d0,compression
  344.  
  345.     bsr    pget            ; pad
  346.     bsr    pgetw            ; transparent color
  347.  
  348.     bsr    pgetw                   ;skip the XAspect & YAspect
  349.         bsr     pgetl                   ;skip the pageWidth and pageHeight
  350.         
  351. bmhd01: move.w    #65,pc_XDpi+pic         ;default to 640 x 400
  352.     move.w    #55,pc_YDpi+pic
  353.  
  354.     cmp.w    #320,pc_W+pic
  355.     bne    bmhd1
  356.  
  357.     move.w    #32,pc_XDpi+pic
  358.  
  359. bmhd1:    cmp.w    #200,pc_H+pic
  360.     bne    bmhd2
  361.  
  362.     move.w    #27,pc_YDpi+pic
  363.  
  364. bmhd2:    cmp.w    #800,pc_H+pic
  365.     bcc    bmhd2a
  366.  
  367.     cmp.w    #1000,pc_W+pic
  368.     bcs    bmhd3
  369.  
  370. bmhd2a: move.w    #300,pc_XDpi+pic
  371.     move.w    #300,pc_YDpi+pic
  372.  
  373. bmhd3:    move.l    table,a0
  374.     move.l    spclname(a0),a0
  375.     lea    4(a0),a0
  376.     move.w    -2(a0),d0
  377.     clr.b    0(a0,d0.w)
  378.     lea    dpistr1,a1
  379.         lea     dpistr2,a2
  380.         
  381. bmh3a:  move.b  (a0)+,d0
  382.         move.b  (a1)+,d1
  383.         cmp.b    d0,d1
  384.     bne    bmh3ab
  385.     tst.b    (a1)
  386.     bne    bmh3a
  387.         bra     bmh3ac
  388.         
  389. bmh3ab: move.b  (a2)+,d1
  390.         cmp.b    d0,d1
  391.     bne    bmh3b
  392.     tst.b    (a2)
  393.     bne    bmh3a
  394.  
  395. bmh3ac: bset    #5,flag                 ;set resolution override flag
  396.     bsr    getnum
  397.     move.w    d0,pc_XDpi+pic
  398.     bsr    getnum
  399.     move.w    d0,pc_YDpi+pic
  400.  
  401. bmh3b:    clr.b    truecolor
  402.  
  403.         cmp.w   #12,truebitpln
  404.         bcs     bmhd4
  405.  
  406.         ;cmp.w   #18,pc_BitPln+pic
  407.         ;beq     bmhd3c
  408.         ;cmp.w   #21,pc_BitPln+pic
  409.         ;beq     bmhd3c
  410.     ;cmp.w     #24,pc_BitPln+pic
  411.     ;bne     bmhd4
  412.     
  413.         move.b    #1,truecolor
  414.     clr.w    pc_Palet+pic
  415.     move.w    #PC_RGB,pc_Type+pic
  416.         bra     adjlen
  417.  
  418. bmhd4:    move.w    #PC_PALET,pc_Type+pic
  419.     move.w    pc_BitPln+pic,d0
  420.     moveq    #1,d1
  421.     lsl.w    d0,d1
  422.     move.w    d1,pc_Palet+pic
  423.  
  424.     move.l    vport,d0
  425.     btst    #11,d0
  426.     beq    bmhd5
  427.         
  428.     move.w    #12,pc_BitPln+pic
  429.     clr.w    pc_Palet+pic
  430.     move.w    #PC_RGB,pc_Type+pic
  431.     
  432. bmhd5:  cmp.l   #20,clength
  433.         beq     adjlen
  434.         sub.l   #20,clength
  435.         sub.l   #20,length
  436.         bra     skip
  437.         
  438.         
  439. *********************************
  440. *                               *
  441. *********************************
  442. camg:    bsr    pgetl
  443.     move.l    d0,vport
  444.  
  445.         btst    #5,flag                 ;override the resolution?
  446.         bne     camg2                   ;yes
  447.         
  448.         btst    #15,d0                  ;is it HIRES (640)
  449.         bne     camg1                   ;yes!
  450.         move.w  #32,pic+pc_XDpi
  451.         
  452. camg1:  btst    #2,d0                   ;is it interlaced?
  453.         bne     camg2                   ;yes!
  454.         move.w  #27,pic+pc_YDpi                 
  455.  
  456. camg2:    btst    #0,flag                 ;did i find a BMHD before this?
  457.     beq    adjlen                  ;no
  458.  
  459.     btst    #11,d0                  ;is it a HAM picture?
  460.     beq    adjlen                  ;no
  461.     move.w    #12,pc_BitPln+pic       ;convert HAM to 12 bit picture
  462.     clr.w    pc_Palet+pic
  463.     move.w    #PC_RGB,pc_Type+pic
  464.     bra    adjlen
  465.  
  466.  
  467. ***********************************
  468. ***                ***
  469. ***********************************
  470. clut:
  471.         bsr     pgetl           ;get clut type (1=r, 2=g, 3=b, 0,4-7 skip)
  472.         subq.l  #4,length       
  473.         
  474. clut1:  cmp.l   #1,d0           ;is it the red table?
  475.         bne     clut2           ;no
  476.         lea     rtable,a4       ;get the pointer to the red table into a4
  477.         bra     clut5
  478.         
  479. clut2:  cmp.l   #2,d0           ;is it the green table?
  480.         bne     clut3           ;no
  481.         lea     gtable,a4       ;get the pointer to the green table into a4
  482.         bra     clut5
  483.         
  484. clut3:  cmp.l   #3,d0           ;is it the blue table
  485.         bne     clut4
  486.         lea     btable,a4       ;get the pointer to the blue table into a4
  487.         bra     clut5
  488.         
  489. clut4:  subq.l  #4,clength      ;take off for the data i just read
  490.         bra     skip            ;skip will rts for me
  491.         
  492. clut5:  bsr     pgetl           ;skip the reserved long word
  493.         subq.l  #4,length
  494.         subq.l  #4,clength
  495.         
  496.         move.l  a4,-(sp)        ;save it
  497.         bset    #2,flag         ;yes i found a CLUT! (r, g, or b)
  498.         move.w  #256,d0         ;length of table is always 256
  499.         clr.l   d1              ;allocate memory for table data
  500.         clr.l   d2
  501.         move.l  table,a0
  502.         move.l  m_alloc(a0),a0
  503.         jsr     (a0)
  504.         bne     clut6
  505.         
  506.         move.l  (sp)+,a4
  507.         move.l  #0,(a4)         ;clear table pointer
  508.         bra     skip            ;skip the rest
  509.         
  510. clut6:  move.l  (sp)+,a4
  511.         move.l  a0,(a4)         ;store memory handle into table pointer
  512.         move.l  (a0),a4         ;a4 = address of data
  513.         move.w  #256,temp
  514.         
  515. clut7:  bsr     pget            ;get a byte into d0
  516.         move.b  d0,(a4)+
  517.         subq.w  #1,temp
  518.         bne     clut7   
  519.         
  520.         sub.l   #256,length  
  521.         rts
  522.         
  523.  
  524. *********************************
  525. *                               *
  526. *********************************
  527. cmap:    bset    #1,flag            ; found a CMAP
  528.  
  529.     tst.b    truecolor
  530.     bne    cmaptc
  531.  
  532.     move.l    clength,d0
  533.     divu    #3,d0            ; # of cmap entries
  534.     move.w    d0,temp
  535.         move.l  d0,d1
  536.         swap    d1
  537.         move.w  d1,cmapleftover
  538.     mulu    #pl_Sizeof,d0
  539.     jsr    allocpalet
  540.  
  541. getentry:
  542.     bsr    pget            ; red
  543.     and.w    #$ff,d0
  544.     mulu    #65535,d0
  545.     divu    #240,d0
  546.     move.w    d0,(a4)
  547.     bsr    pget            ; green
  548.     and.w    #$ff,d0
  549.     mulu    #65535,d0
  550.     divu    #240,d0
  551.     move.w    d0,2(a4)
  552.     bsr    pget            ; blue
  553.     and.w    #$ff,d0
  554.     mulu    #65535,d0
  555.     divu    #240,d0
  556.     move.w    d0,4(a4)
  557.  
  558.     move.w    (a4)+,d0
  559.     move.w    (a4)+,d1
  560.     move.w    (a4)+,d2
  561.     mulu    #19661,d0
  562.     mulu    #38666,d1
  563.     mulu    #7209,d2
  564.     add.l    d1,d0
  565.     add.l    d2,d0
  566.     swap    d0
  567.     cmp.w    #$8000,d0
  568.     bcc    ge1
  569.     moveq    #1,d0
  570.     bra    ge2
  571. ge1:    moveq    #0,d0
  572. ge2:    move.w    d0,(a4)+        ; black
  573.     sub.w    #1,temp
  574.     bne    getentry
  575.         
  576.         tst.w   cmapleftover
  577.         beq     ge4
  578. ge3:    bsr     pget
  579.         subq.w  #1,cmapleftover
  580.         bne     ge3     
  581. ge4:    bra    adjlen
  582.  
  583. cmaptc:    move.l    clength,d0
  584.     move.l    d0,temp
  585.     bsr    allocpalet
  586.  
  587. cmtc1:    bsr    pget
  588.     move.b    d0,(a4)+
  589.     sub.l    #1,temp
  590.     bne    cmtc1
  591.     bra    adjlen
  592.  
  593.         
  594. ***********************************
  595. ***                ***
  596. ***********************************
  597. ctbl:
  598.         bset    #4,flag                 ;this is a dynamic hires/ham picture!
  599.         clr.l   ctblptr
  600.         
  601.         btst    #1,flag                 ;did i find a CMAP before
  602.         beq     ctbl0                   ;no
  603.       
  604.         move.l  palhndl,a0              ;if yes, then delete it
  605.         move.l  table,a1
  606.         move.l  m_delete(a1),a1
  607.         jsr     (a1)
  608.         bclr    #1,flag
  609.     clr.w    pc_Palet+pic
  610.         move.w  #12,pic+pc_BitPln
  611.     move.w    #PC_RGB,pic+pc_Type
  612.           
  613. ctbl0:  move.l  clength,d0
  614.         clr.l   d1
  615.         clr.l   d2
  616.         move.l  table,a0
  617.         move.l  m_alloc(a0),a0
  618.         jsr     (a0)
  619.         bne     ctbl1
  620.         
  621.         bra     errrts          ;get out        
  622.  
  623. ctbl1:  move.l  a0,ctblptr
  624.         move.l  (a0),a0
  625.         move.l  a0,temppal      ;save incase this is a dynamic HAM picture
  626.         move.l  clength,d1
  627.         sub.l   d1,length       ;adjust file length down
  628.         
  629. ctbl2:  move.l  a0,-(sp)
  630.         move.l  d1,-(sp)    
  631.         bsr     pget
  632.         move.l  (sp)+,d1
  633.         move.l  (sp)+,a0
  634.         move.b  d0,(a0)+
  635.         subq.l  #1,d1
  636.         bne     ctbl2
  637.         
  638.         bsr     fakepal         ;set up a fake palette for later
  639.         rts
  640.  
  641.                 
  642. ***********************************
  643. ***                ***
  644. ***********************************
  645. dgvw:
  646.         bset    #3,flag         ;this is a digi-view picture!
  647.         bsr     skip            ;skip the data
  648.         bsr     fakepal         ;set up a "fake" palette for later
  649.         rts
  650.  
  651.  
  652. ***********************************
  653. ***                             ***
  654. ***********************************        
  655. fakepal:                
  656.         move.w  #768,d0         ;length of table is always 768 (256*3)
  657.         clr.l   d1              ;allocate memory for table data
  658.         clr.l   d2
  659.         move.l  table,a0
  660.         move.l  m_alloc(a0),a0
  661.         jsr     (a0)
  662.         bne     fkpl1
  663.         
  664.         clr.l   palhndl         ;clear table pointer - (a4) ?????
  665.         rts
  666.         
  667. fkpl1:  move.l  a0,palhndl      ;store memory handle into table pointer
  668.         move.l  (a0),a4         ;a4 = address of data
  669.         move.b  #0,temp         ;for the red data
  670.         
  671. fkpl2:  move.b  temp,(a4)+
  672.         add.b   #1,temp
  673.         cmp.b   #255,temp
  674.         bne     fkpl2
  675.                  
  676.         move.b  #0,temp         ;for the green data
  677.         
  678. fkpl4:  move.b  temp,(a4)+
  679.         add.b   #1,temp
  680.         cmp.b   #255,temp
  681.         bne     fkpl4
  682.  
  683.         move.b  #0,temp         ;for the blue data
  684.         
  685. fkpl6:  move.b  temp,(a4)+
  686.         add.b   #1,temp
  687.         cmp.b   #255,temp
  688.         bne     fkpl6
  689.      
  690.         rts     
  691.                
  692. ***********************************
  693. ***                ***
  694. ***********************************
  695. allocpalet:
  696.     move.l    table,a1
  697.     tst.l    palhndl
  698.     beq    apal1
  699.  
  700.     move.l    palhndl,a0
  701.     move.l    m_realloc(a1),a1    ; already had a color map
  702.     jsr    (a1)
  703.     move.l    palhndl,a4
  704.     move.l    (a4),a4
  705.     rts
  706.  
  707. apal1:    clr.w    d1
  708.     clr.w    d2
  709.     move.l    m_alloc(a1),a1
  710.     jsr    (a1)            ; allocate memory for the color map
  711.     move.l    a0,palhndl
  712.     move.l    (a0),a4
  713.     rts
  714.  
  715.  
  716. ***********************************
  717. ***                ***
  718. ***********************************
  719. adjlen:    move.l    clength,d0
  720.     btst    #0,d0
  721.     beq    al1
  722.     bsr    pget
  723.     move.l    clength,d0
  724.     add.l    #1,d0
  725.  
  726. al1:    sub.l    d0,length
  727.     rts
  728.  
  729.  
  730. ***********************************
  731. **                               **
  732. ***********************************
  733. getnum:    moveq    #0,d0
  734. gn1:    move.b    (a0)+,d1
  735.     sub.b    #"0",d1
  736.     bcs    gn2
  737.     cmp.b    #10,d1
  738.     bcc    gn2
  739.     and.w    #$ff,d1
  740.     mulu    #10,d0
  741.     add.w    d1,d0
  742.     bra    gn1
  743.  
  744. gn2:    rts
  745.  
  746. ***********************************
  747. ***                ***
  748. ***********************************
  749. skip:    move.l    clength,d0
  750.     add.l    #1,d0
  751.     bclr    #0,d0
  752.     sub.l    d0,length
  753.  
  754. sk1:    move.l    d0,-(sp)
  755.     bsr    pgetw
  756.     move.l    (sp)+,d0
  757.     sub.l    #2,d0
  758.     bgt    sk1
  759.     rts
  760.  
  761.  
  762. *********************************
  763. *                               *
  764. *********************************
  765. pgetl:    move.l    table,a0
  766.     move.l    f_getl(a0),a0
  767.     jsr    (a0)
  768.     beq    errrts
  769.     rts
  770.  
  771. *********************************
  772. *                               *
  773. *********************************
  774. pgetw:    move.l    table,a0
  775.     move.l    f_getw(a0),a0
  776.     jsr    (a0)
  777.     beq    errrts
  778.     rts
  779.  
  780. *********************************
  781. *                               *
  782. *********************************
  783. pget:    move.l    table,a0
  784.     move.l    f_get(a0),a0
  785.     jsr    (a0)
  786.     beq    errrts
  787.     rts
  788.  
  789.  
  790. ***********************************
  791. ***                ***
  792. ***********************************
  793. errrts:    tst.l    palhndl
  794.     beq    er1
  795.     move.l    palhndl,a0
  796.     move.l    table,a1
  797.     move.l    m_delete(a1),a1
  798.     jsr    (a1)
  799.  
  800. er1:    tst.l    rtable
  801.     beq    er2
  802.     move.l    rtable,a0
  803.     move.l    table,a1
  804.     move.l    m_delete(a1),a1
  805.     jsr    (a1)
  806.  
  807. er2:    tst.l    gtable
  808.     beq    er3
  809.     move.l    gtable,a0
  810.     move.l    table,a1
  811.     move.l    m_delete(a1),a1
  812.     jsr    (a1)
  813.  
  814. er3:    tst.l    btable
  815.     beq    er4
  816.     move.l    btable,a0
  817.     move.l    table,a1
  818.     move.l    m_delete(a1),a1
  819.     jsr    (a1)
  820.         
  821. er4:    tst.l    ctblptr
  822.     beq    er5
  823.     move.l    ctblptr,a0
  824.     move.l    table,a1
  825.     move.l    m_delete(a1),a1
  826.     jsr    (a1)
  827.         
  828. er5:    move.l    savesp,sp
  829.         
  830.     move.l    table,a0        
  831.     move.l    spclnum(a0),a0  
  832.     cmp.w    #1,(a0)         
  833.     beq    abortobj        
  834.         bra     abortpic        
  835.         
  836. ;rts
  837.         
  838.  
  839. ***********************************************************
  840. ***                            ***
  841. ***********************************************************
  842. putcolor:
  843.     move.w    pc_Palet+pic,d1
  844.     mulu    #pl_Sizeof,d1
  845.         beq     rrts                    ;incase no pal exist
  846.  
  847.     move.l    picptr,a0
  848.     move.l    palhndl,a1
  849.     move.l    (a1),a1
  850.     bra    pc2
  851. pc1:    move.b    (a1)+,(a0)+
  852. pc2:    dbf    d1,pc1
  853.     move.l    a0,picptr
  854.  
  855.     rts
  856.  
  857.  
  858. ***********************************************************
  859. ***                            ***
  860. ***********************************************************
  861. putILBM:
  862.         move.l  vport,d0
  863.         btst    #11,d0                  ;is this a ham picture?
  864.         bne     pp09                    ;yes
  865.         
  866.         btst    #4,flag                 ;is this a dynamic hires picture?
  867.         beq     pp00
  868.         
  869.         move.w  #4,truebitpln           ;read in as a 4bit picture
  870.         
  871. pp00:   btst    #2,flag                 ;is this a CLUT picture?
  872.         beq     pp0
  873.         
  874.         bsr     cluttopal               ;change clut into a palette
  875.         
  876. pp0:    btst    #3,flag                 ;is this is digi-view (RGB) picture
  877.         beq     pp09                    ;no
  878.         cmp.w   #21,truebitpln          ;is this a 21 bit rgb picture?
  879.         bne     pp09                    ;no
  880.  
  881.         move.w  pic+pc_H,theight
  882.         move.w  #7,bitplanes
  883.         move.l  picptr,a4
  884.         move.l  a4,pptr
  885.         
  886.         move.l  planesize,d0
  887.         lsl.l   #3,d0
  888.         sub.l   planesize,d0    ;multiply by seven
  889.         move.l  d0,planeoffset
  890.         
  891.         add.l   d0,a4
  892.         sub.l   planesize,a4
  893.         move.l  a4,picptr
  894.         move.l  a4,pptr2
  895.         move.w  #3,ccount
  896.         
  897. pp01:   bsr     getrow
  898.         add.l   planeoffset,a4
  899.         sub.w   #1,ccount               ;do the x row for each color (rgb)
  900.         bne     pp01
  901.         
  902.         move.w  #3,ccount               ;reset color count
  903.         move.l  picptr,a4
  904.         sub.l   planesize,a4            ;move to next plane back
  905.         move.l  a4,picptr
  906.         sub.w   #1,bitplanes
  907.         bne     pp01
  908.            
  909.         move.l  pptr2,a4
  910.         add.w   pic+pc_Width,a4
  911.         move.l  a4,pptr2
  912.         move.l  a4,picptr
  913.         move.w  #3,ccount
  914.         move.w  #7,bitplanes
  915.         
  916.         sub.w   #1,theight
  917.         bne     pp01
  918.         
  919.         bra     pp2
  920.         
  921. pp09:   move.w    truebitpln,bitplanes
  922.     move.w    pc_H+pic,theight
  923.     move.l    picptr,a4
  924.     move.l    a4,pptr
  925.  
  926. pp1:    bsr    getrow          ;put a row into the amiga bitmap
  927.     add.l    planesize,a4    ;one for each bit plane
  928.     sub.w    #1,bitplanes
  929.     bne    pp1
  930.  
  931.     move.w    truebitpln,bitplanes    ;get next row
  932.     move.l    picptr,a4
  933.     add.w    pc_Width+pic,a4
  934.     move.l    a4,picptr
  935.     sub.w    #1,theight
  936.     bgt    pp1
  937.         
  938. *
  939. * possibly convert into ham
  940. *
  941. pp2:    move.l    vport,d0                ;is it a HAM picture?
  942.     btst    #11,d0
  943.     beq    notham                  ;no!
  944.  
  945.     clr.w    curcolor
  946.     move.w    pc_H+pic,theight
  947. pp3:    bsr    unhamrow                ;change HAM into 12 bit data
  948.     move.l    pptr,a0
  949.     add.w    pc_Width+pic,a0
  950.     move.l    a0,pptr
  951.     subq.w    #1,theight
  952.     bhi    pp3
  953.     bra    nottrue
  954. *
  955. * possible needs a truecolor lookup
  956. *
  957. notham: btst    #4,flag                 ;is it a dynamic hires picture?
  958.         beq     pp31                    ;no
  959.         
  960.         bsr     undynam                 ;change from dynamic hires into 12bit
  961.           
  962. pp31:   tst.b    truecolor
  963.     beq    nottrue
  964.  
  965.     move.w    pc_H+pic,theight
  966. pp4:    bsr    truecolorlookup
  967.     move.l    pptr,a0
  968.     add.w    pc_Width+pic,a0
  969.     move.l    a0,pptr
  970.     subq.w    #1,theight
  971.     bhi    pp4
  972.  
  973. nottrue:
  974.         tst.l   palhndl                 ;clean up memory
  975.         beq     pp5
  976.     move.l    palhndl,a0
  977.     move.l    table,a1
  978.     move.l    m_delete(a1),a1
  979.     jsr    (a1)
  980.  
  981. pp5:    tst.l   rtable
  982.         beq     pp6
  983.     move.l    rtable,a0
  984.     move.l    table,a1
  985.     move.l    m_delete(a1),a1
  986.     jsr    (a1)
  987.     
  988. pp6:    tst.l   gtable
  989.         beq     pp7
  990.     move.l    gtable,a0
  991.     move.l    table,a1
  992.     move.l    m_delete(a1),a1
  993.     jsr    (a1)
  994.     
  995. pp7:    tst.l   btable
  996.         beq     pp8
  997.     move.l    btable,a0
  998.     move.l    table,a1
  999.     move.l    m_delete(a1),a1
  1000.     jsr    (a1)
  1001.     
  1002. pp8:    tst.l   ctblptr
  1003.         beq     pp9
  1004.     move.l    ctblptr,a0
  1005.     move.l    table,a1
  1006.     move.l    m_delete(a1),a1
  1007.     jsr    (a1)   
  1008.          
  1009. pp9:    bra    adjlen          ;will rts for me
  1010.  
  1011.  
  1012. *******************************************
  1013. ***                    ***
  1014. *******************************************
  1015. putACBM:
  1016.         clr.l   d0
  1017.         move.w  pic+pc_Width,d0
  1018.         mulu    pic+pc_H,d0
  1019.         move.l  d0,planesize
  1020.         
  1021.         cmp.w   #6,pic+pc_BitPln
  1022.         bcc     pa1
  1023.     
  1024.         mulu    pic+pc_BitPln,d0
  1025.         move.l  picptr,a0
  1026.         move.l  table,a1
  1027.         move.l  f_getr(a1),a1
  1028.         jsr     (a1)
  1029.         beq     errrts            
  1030.         bra     pa9     
  1031.  
  1032. pa1:    lsl.l   #1,d0                   ;skip the first 3 bitplanes
  1033.         add.l   planesize,d0
  1034.         move.l  picptr,a0
  1035.         move.l  table,a1
  1036.         move.l  f_getr(a1),a1
  1037.         jsr     (a1)
  1038.         beq     errrts
  1039.         
  1040.         clr.l   d1                      ;red plane?
  1041.         move.l  planesize,d0
  1042.         move.w  pic+pc_BitPln,d1
  1043.         divu    #3,d1
  1044.         mulu    d1,d0
  1045.         move.l  picptr,a0
  1046.         add.l   d0,a0
  1047.         add.l   d0,a0    
  1048.         move.l  table,a1
  1049.         move.l  f_getr(a1),a1
  1050.         jsr     (a1)
  1051.         beq     errrts
  1052.  
  1053.         move.l  planesize,d0
  1054.         lsl.l   #1,d0                   ;skip the next 2 bitplanes
  1055.         move.l  picptr,a0
  1056.         move.l  table,a1
  1057.         move.l  f_getr(a1),a1
  1058.         jsr     (a1)
  1059.         beq     errrts
  1060.         
  1061.         clr.l   d1                      ;green planes?
  1062.         move.l  planesize,d0
  1063.         move.w  pic+pc_BitPln,d1
  1064.         divu    #3,d1
  1065.         mulu    d1,d0
  1066.         move.l  picptr,a0
  1067.         add.l   d0,a0
  1068.         move.l  table,a1
  1069.         move.l  f_getr(a1),a1
  1070.         jsr     (a1)
  1071.         beq     errrts
  1072.  
  1073.         move.l  planesize,d0
  1074.         lsl.l   #1,d0                   ;skip the next 2 bitplanes
  1075.         move.l  picptr,a0
  1076.         move.l  table,a1
  1077.         move.l  f_getr(a1),a1
  1078.         jsr     (a1)
  1079.         beq     errrts
  1080.  
  1081.         clr.l   d1                      ;blue planes?
  1082.         move.l  planesize,d0
  1083.         move.w  pic+pc_BitPln,d1
  1084.         divu    #3,d1
  1085.         mulu    d1,d0
  1086.         move.l  picptr,a0
  1087.         move.l  table,a1
  1088.         move.l  f_getr(a1),a1
  1089.         jsr     (a1)
  1090.         beq     errrts
  1091.  
  1092. pa9:    rts
  1093.         
  1094. *******************************************
  1095. ***                    ***
  1096. *******************************************
  1097. unhamrow:
  1098.         btst    #4,flag                 ;is this a dynamic HAM picture?
  1099.         beq     uhr0
  1100.         move.l  temppal,a1
  1101.         move.l  a1,a2
  1102.         add.l   #32,a2
  1103.         move.l  a2,temppal              ;set temppal to next pal for row
  1104.         bra     uhr01
  1105.         
  1106. uhr0:   move.l    palhndl,a1
  1107.     move.l    (a1),a1
  1108.     
  1109. uhr01:  move.w    pc_Width+pic,d0
  1110.     lsl.w    #3,d0
  1111.     move.w    d0,twidth
  1112.     move.l    pptr,a4
  1113.     moveq    #7,d7
  1114.         move.w  (a1),curcolor   ;set the starting color to the background (0)
  1115.  
  1116. uhr1:    move.l    a4,a2
  1117.     move.l    a4,a3
  1118.     moveq    #0,d1
  1119.     moveq    #0,d0
  1120.  
  1121.     btst    d7,(a2)
  1122.     beq    uhr10
  1123.     bset    #0,d0
  1124. uhr10:    add.l    planesize,a2
  1125.     btst    d7,(a2)
  1126.     beq    uhr11
  1127.     bset    #1,d0
  1128. uhr11:    add.l    planesize,a2
  1129.     btst    d7,(a2)
  1130.     beq    uhr12
  1131.     bset    #2,d0
  1132. uhr12:    add.l    planesize,a2
  1133.     btst    d7,(a2)
  1134.     beq    uhr13
  1135.     bset    #3,d0
  1136. uhr13:    add.l    planesize,a2
  1137.     btst    d7,(a2)
  1138.     beq    uhr14
  1139.     bset    #2,d1
  1140. uhr14:    add.l    planesize,a2
  1141.     btst    d7,(a2)
  1142.     beq    uhr15
  1143.     bset    #3,d1
  1144.  
  1145. uhr15:    lea    ham,a0
  1146.     jsr    0(a0,d1.w)
  1147.  
  1148.     move.w    curcolor,d0
  1149.  
  1150.     move.w    #0,d1
  1151.     move.w    #11,d2
  1152. uhr20:    btst    d1,d0
  1153.     beq    uhr21
  1154.     bset    d7,(a3)
  1155.     bra    uhr22
  1156. uhr21:    bclr    d7,(a3)
  1157. uhr22:    add.l    planesize,a3
  1158.     addq.w    #1,d1
  1159.     dbf    d2,uhr20
  1160.  
  1161.     dbf    d7,uhr2
  1162.     moveq    #7,d7
  1163.     addq.l    #1,a4
  1164. uhr2:    sub.w    #1,twidth
  1165.     bhi    uhr1
  1166.     rts
  1167.  
  1168. ham:    bra.w    selpal
  1169.     bra.w    selblue
  1170.     bra.w    selred
  1171.     bra.w    selgreen
  1172.  
  1173. selpal: btst    #4,flag                 ;is it a dynamic HAM picture?
  1174.         beq     selp1
  1175.         lsl.w   #1,d0
  1176.         move.w  0(a1,d0.w),curcolor
  1177.         rts
  1178.         
  1179. selp1:  lsl.w    #3,d0
  1180.     move.w    pl_Red(a1,d0.w),d1
  1181.     mulu    #15,d1
  1182.     divu    #65535,d1
  1183.     and.w    #$f,d1
  1184.     lsl.w    #8,d1
  1185.  
  1186.     move.w    pl_Green(a1,d0.w),d2
  1187.     mulu    #15,d2
  1188.     divu    #65535,d2
  1189.     and.w    #$f,d2
  1190.     lsl.w    #4,d2
  1191.     or.w    d2,d1
  1192.  
  1193.     move.w    pl_Blue(a1,d0.w),d2
  1194.     mulu    #15,d2
  1195.     divu    #65535,d2
  1196.     and.w    #$f,d2
  1197.     or.w    d2,d1
  1198.  
  1199.     move.w    d1,curcolor
  1200.     rts
  1201.  
  1202. selblue:
  1203.     move.w    curcolor,d1
  1204.     and.w    #$ff0,d1
  1205.     or.w    d0,d1
  1206.     move.w    d1,curcolor
  1207.     rts
  1208.  
  1209. selgreen:
  1210.     move.w    curcolor,d1
  1211.     and.w    #$f0f,d1
  1212.     lsl.w    #4,d0
  1213.     or.w    d0,d1
  1214.     move.w    d1,curcolor
  1215.     rts
  1216.  
  1217. selred:
  1218.     move.w    curcolor,d1
  1219.     and.w    #$0ff,d1
  1220.     lsl.w    #8,d0
  1221.     or.w    d0,d1
  1222.     move.w    d1,curcolor
  1223.     rts
  1224.  
  1225. *******************************************
  1226. ***                    ***
  1227. *******************************************
  1228. truecolorlookup:
  1229.     move.w    pc_Width+pic,d0
  1230.     lsl.w    #3,d0
  1231.     move.w    d0,twidth
  1232.     move.l    pptr,a4
  1233.     moveq    #7,d7
  1234.         
  1235.         move.w  truebitpln,d3
  1236.         divu    #3,d3
  1237.         subq.w  #1,d3
  1238.         move.w  d3,numplane
  1239.  
  1240. tcl1:    move.l    a4,a2
  1241.     move.l    a4,a3
  1242.  
  1243.     moveq    #0,d0            ;red
  1244.     moveq    #0,d1            ;green
  1245.     moveq    #0,d2            ;blue
  1246.  
  1247.     move.w  numplane,d3             ;get the red plane's value
  1248.         
  1249. tcl2:    lsr.b    #1,d0
  1250.     btst    d7,(a2)
  1251.     beq    tcl3
  1252.     bset    #7,d0
  1253. tcl3:    add.l    planesize,a2
  1254.     dbf    d3,tcl2
  1255.  
  1256.         move.w  numplane,d3             ;get the green planes's value
  1257.         
  1258. tcl4:    lsr.b    #1,d1
  1259.     btst    d7,(a2)
  1260.     beq    tcl5
  1261.     bset    #7,d1
  1262. tcl5:    add.l    planesize,a2
  1263.     dbf    d3,tcl4
  1264.  
  1265.         move.w  numplane,d3             ;get the blue plane's value
  1266.  
  1267. tcl6:    lsr.b    #1,d2
  1268.     btst    d7,(a2)
  1269.     beq    tcl7
  1270.     bset    #7,d2
  1271. tcl7:    add.l    planesize,a2
  1272.     dbf    d3,tcl6
  1273.  
  1274.         move.w  #7,d3
  1275.         sub.w   numplane,d3
  1276.         beq     tcl8
  1277.         
  1278.         lsr.b   d3,d0
  1279.         lsr.b   d3,d1
  1280.         lsr.b   d3,d2
  1281.         
  1282. tcl8:    tst.l   palhndl
  1283.         beq     tcl80
  1284.         
  1285.         move.l    palhndl,a1
  1286.     move.l    (a1),a1
  1287.     move.b    0(a1,d0.w),d0        ;red lookup
  1288.     lea    256(a1),a1
  1289.     move.b    0(a1,d1.w),d1        ;green lookup
  1290.     lea    256(a1),a1
  1291.     move.b    0(a1,d2.w),d2        ;blue lookup
  1292.         
  1293. tcl80:  btst    #3,flag                 ;is this a digi-view picture?
  1294.         beq     tcl9                    ;no - needs no color adjusting
  1295.         
  1296.         cmp.w   #21,truebitpln          ;is this a 21 bit digi view picture?
  1297.         beq     tcl81                   ;nope
  1298.         cmp.w   #24,truebitpln          ;is this a 24 bit digi view picture?
  1299.         bne     tcl9                    ;nope
  1300.         
  1301.         lea     contrast24,a1           ;get the contrast adjusted values
  1302.         move.b  0(a1,d0.w),d0
  1303.         move.b  0(a1,d1.w),d1
  1304.         move.b  0(a1,d2.w),d2
  1305.         bra     tcl9
  1306.         
  1307. tcl81:  lea     contrast21,a1           ;get the contrast adjusted values
  1308.         move.b  0(a1,d0.w),d0
  1309.         move.b  0(a1,d1.w),d1
  1310.         move.b  0(a1,d2.w),d2
  1311.         
  1312. tcl9:    move.w    #0,d3            ;copy blue back
  1313.         move.w  numplane,d4
  1314.         
  1315. tcl10:    btst    d3,d2
  1316.     beq    tcl11
  1317.     bset    d7,(a3)
  1318.     bra    tcl12
  1319. tcl11:    bclr    d7,(a3)
  1320. tcl12:    add.l    planesize,a3
  1321.     addq.w    #1,d3
  1322.     dbf    d4,tcl10
  1323.  
  1324.     move.w    #0,d3            ;copy green back
  1325.         move.w  numplane,d4
  1326.         
  1327. tcl13:    btst    d3,d1
  1328.     beq    tcl14
  1329.         bset    d7,(a3)
  1330.     bra    tcl15
  1331. tcl14:    bclr    d7,(a3)
  1332. tcl15:    add.l    planesize,a3
  1333.     addq.w    #1,d3
  1334.     dbf    d4,tcl13
  1335.  
  1336.     move.w    #0,d3            ;copy red back
  1337.         move.w  numplane,d4
  1338.         
  1339. tcl16:    btst    d3,d0
  1340.     beq    tcl17
  1341.     bset    d7,(a3)
  1342.     bra    tcl18
  1343. tcl17:    bclr    d7,(a3)
  1344. tcl18:    add.l    planesize,a3
  1345.     addq.w    #1,d3
  1346.     dbf    d4,tcl16
  1347.  
  1348.  
  1349.     dbf    d7,tcl20
  1350.     moveq    #7,d7
  1351.     addq.l    #1,a4
  1352. tcl20:    sub.w    #1,twidth
  1353.     bhi    tcl1
  1354.     rts
  1355.  
  1356.  
  1357. *******************************************
  1358. ***                    ***
  1359. *******************************************
  1360. getrow:    move.l    a4,temp
  1361.     move.w    pc_Width+pic,twidth
  1362.  
  1363.     tst.b    compression
  1364.     beq    nocomp
  1365.     cmp.b    #1,compression
  1366.     bne    errrts
  1367.  
  1368. gr1:    tst.w    twidth
  1369.     beq    grtn
  1370.     bsr    pget
  1371.         cmp.b   #$80,d0
  1372.         beq     gr1
  1373.         
  1374.     tst.b    d0
  1375.     bmi    gr3
  1376.     move.b    d0,temp1
  1377. gr2:    bsr    pget
  1378.     move.b    d0,(a4)+
  1379.     sub.w    #1,twidth
  1380.     sub.b    #1,temp1
  1381.     bge    gr2
  1382.     bra    gr1
  1383.  
  1384. gr3:    clr.w    temp1
  1385.     neg.b    d0
  1386.     move.b    d0,temp1+1
  1387.     bsr    pget
  1388.     move.w    temp1,d1
  1389. gr4:    move.b    d0,(a4)+
  1390.     sub.w    #1,twidth
  1391.     dbra    d1,gr4
  1392.     bra    gr1
  1393.     
  1394. nocomp: bsr    pget
  1395.     move.b    d0,(a4)+
  1396.     sub.w    #1,twidth
  1397.     bne    nocomp
  1398.  
  1399. grtn:    move.l    temp,a4
  1400.     rts
  1401.  
  1402.  
  1403. *******************************************
  1404. ***                    ***
  1405. *******************************************
  1406. cluttopal:
  1407.         move.w  #768,d0
  1408.         clr.l   d1
  1409.         clr.l   d2
  1410.         move.l  table,a0
  1411.         move.l  m_alloc(a0),a0
  1412.         jsr     (a0)
  1413.         beq     errrts                  ;can i do this?
  1414.         
  1415.         move.l  a0,palhndl 
  1416.         move.l  (a0),a0
  1417.         move.l  rtable,a1
  1418.         move.l  (a1),a1
  1419.         move.w  #255,d0
  1420.         
  1421. clpt1:  move.b  (a1)+,(a0)+
  1422.         dbf     d0,clpt1
  1423.  
  1424.         move.l  #255,d0
  1425.         move.l  gtable,a1
  1426.         move.l  (a1),a1
  1427.         
  1428. clpt2:  move.b  (a1)+,(a0)+
  1429.         dbf     d0,clpt2
  1430.  
  1431.         move.l  #255,d0
  1432.         move.l  btable,a1
  1433.         move.l  (a1),a1
  1434.  
  1435. clpt3:  move.b  (a1)+,(a0)+
  1436.         dbf     d0,clpt3
  1437.      
  1438.         rts
  1439.         
  1440. ***********************************
  1441. ***                             ***
  1442. ***********************************
  1443. undynam:
  1444.         move.l  ctblptr,a0
  1445.         move.l  (a0),a0                 ;a0 = address of palettes
  1446.         move.w  pic+pc_H,d0             ;d0 = number of rows
  1447.         subq.w  #1,d0
  1448.         move.w  pic+pc_Width,d4         ;d4 = width of picture in bytes
  1449.         subq.w  #1,d4
  1450.         move.l  pptr,a1                 ;a1 = pointer into amiga bitmap
  1451.         moveq   #7,d1                   ;d1 = bit counter into amiga bitmap  
  1452.         
  1453. undy1:  clr.w   d2                      ;d2= pixel value
  1454.         moveq   #0,d3                   ;d3 = counter
  1455.         move.l  a1,a2                   ;a2 = temp hold for a1
  1456.                 
  1457. undy2:  btst    d1,(a2)                 ;get 4bit value from amiga bitmap
  1458.         beq     undy3
  1459.         bset    d3,d2
  1460. undy3:  add.l   planesize,a2
  1461.         addq.w  #1,d3
  1462.         cmp.w   #4,d3
  1463.         bcs     undy2
  1464.         
  1465.         lsl.w   #1,d2
  1466.         move.w  0(a0,d2.w),d2           ;get pixel value from palette
  1467.         
  1468.         move.l  a1,a2
  1469.         moveq   #0,d3                   ;put 12bit value back
  1470.         
  1471. undy4:  btst    d3,d2
  1472.         beq     undy5
  1473.         bset    d1,(a2)
  1474.         bra     undy6
  1475. undy5:  bclr    d1,(a2)
  1476. undy6:  add.l   planesize,a2
  1477.         addq.w  #1,d3
  1478.         cmp.w   #12,d3
  1479.         bcs     undy4
  1480.       
  1481.         dbf     d1,undy1
  1482.         moveq   #7,d1
  1483.         addq.l  #1,a1
  1484.         
  1485.         dbf     d4,undy1
  1486.         move.l  pptr,a1
  1487.         add.w   pic+pc_Width,a1
  1488.         move.l  a1,pptr
  1489.         add.l   #32,a0          ;move to next palette
  1490.         move.w  pic+pc_Width,d4 ;reset width
  1491.         
  1492.         dbf     d0,undy1
  1493.         
  1494.         rts
  1495.         
  1496.         
  1497. ***********************************
  1498. ***                ***
  1499. ***********************************
  1500. Mulu1632:
  1501.     move.l    table,a0
  1502.     move.l    mulu1632(a0),a0
  1503.     jmp    (a0)
  1504.  
  1505.  
  1506. ***********************************
  1507. ***                ***
  1508. ***********************************
  1509. Divu1648:
  1510.     move.l    table,a0
  1511.     move.l    divu1648(a0),a0
  1512.     jmp    (a0)
  1513.  
  1514.         
  1515. *******************************************************************
  1516. ***    called when the import routine choosen finds something    ***
  1517. ***    wrong with the file loaded.                ***
  1518. *******************************************************************
  1519. never:    clr.w    d0
  1520.     rts
  1521.  
  1522. maybe:    move.w    #1,d0
  1523.     rts
  1524.  
  1525. right:    move.w    #2,d0
  1526.     rts
  1527.  
  1528.  
  1529. *************************************************************
  1530. *************************************************************
  1531.  SECTION IFF,DATA,PUBLIC
  1532.  
  1533. chunks:    dc.l    "BEAM",ctbl
  1534.         dc.l    "BMHD",bmhd
  1535.         dc.l    "CAMG",camg
  1536.         dc.l    "CLUT",clut
  1537.         dc.l    "CMAP",cmap
  1538.         dc.l    "CTBL",ctbl
  1539.         dc.l    "DGVW",dgvw
  1540.         dc.l    "BODY",0
  1541.         dc.l    "ABIT",0
  1542.         dc.l    0,skip
  1543.                 
  1544. numchunks:      
  1545.         dc.w    9
  1546.  
  1547.  
  1548. special:
  1549.     dc.w    2
  1550.     dc.l    spcl1,spcl2
  1551.  
  1552. vers:   dc.b    "$VER: "
  1553. name:    dc.b    "IFF ILBM/ACBM v2.0.9",0
  1554.  
  1555. spcl1:    dc.b    "Picture Window",0
  1556. spcl2:    dc.b    "Object",0
  1557.  
  1558. dpistr1:        dc.b    "dpi=",0
  1559. dpistr2:        dc.b    "DPI=",0
  1560.  
  1561. contrast21:       
  1562.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1563.         dc.b    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1564.         dc.b    2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32
  1565.         dc.b    34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64
  1566.         dc.b    68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98
  1567.         dc.b    100,102,104,106,108,110,112,114,116,118,120,122,124,126,127,127
  1568.         dc.b    127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127
  1569.         dc.b    127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127
  1570.  
  1571.  
  1572. contrast24:       
  1573.         dc.b    0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5
  1574.         dc.b    6,6,6,7,7,7,8,8,8,9,9,9,10,10,10,11
  1575.         dc.b    11,11,12,12,12,13,13,13
  1576.         dc.b    14,14,14,15,15,15,16,16,18,20,22,24,26,28,30,32
  1577.         dc.b    34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64
  1578.         dc.b    68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98
  1579.         dc.b    100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130
  1580.         dc.b    132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162
  1581.         dc.b    164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194
  1582.         dc.b    196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226
  1583.         dc.b    228,230,232,234,236,238,240,242,246,248,250,252,254,255,255,255
  1584.         dc.b    255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
  1585.         dc.b    255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
  1586.         dc.b    255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
  1587.         dc.b    255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
  1588.         dc.b    255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
  1589.         dc.b    255,255,255,255,255,255,255,255
  1590.  
  1591.  
  1592. **************************************************************
  1593. **************************************************************
  1594.  SECTION IFF,BSS,PUBLIC
  1595. savesp:        ds.l    1
  1596. length:        ds.l    1
  1597. clength:    ds.l    1
  1598. temp:        ds.l    1
  1599. temp1:        ds.w    1
  1600. palhndl:    ds.l    1
  1601. picptr:        ds.l    1
  1602. pptr:        ds.l    1
  1603. planesize:    ds.l    1
  1604. twidth:        ds.w    1
  1605. theight:    ds.w    1
  1606. bitplanes:    ds.w    1
  1607. pic:        ds.w    pc_Sizeof/2
  1608. object:        ds.w    ob_SizeOf/2
  1609. compression:    ds.b    1
  1610. flag:        ds.b    1
  1611. vport:        ds.l    1
  1612. truebitpln:    ds.w    1
  1613. curcolor:    ds.w    1
  1614. truecolor:    ds.w    1
  1615. rtable:         ds.l    1
  1616. gtable:         ds.l    1
  1617. btable:         ds.l    1
  1618. xpage:          ds.w    1
  1619. ypage:          ds.w    1
  1620. ccount:         ds.l    1
  1621. planeoffset:    ds.l    1
  1622. pptr2:          ds.l    1
  1623. ctblptr:        ds.l    1
  1624. temppal:        ds.l    1
  1625. numplane:       ds.w    1
  1626. cmapleftover:   ds.w    1
  1627.  
  1628. ******************************* CHANGES ************************************
  1629. ;
  1630. ;       version 2.0.9
  1631. ;
  1632. ;       - removed support for extended BMHD (xdpi and ydpi), although it will
  1633. ;         still skip the extra chunk data if there is any.
  1634. ;
  1635. ;       - added a version string
  1636. ;
  1637. ;       - misc fixes for atari st
  1638. ;
  1639. ;       
  1640. ;       version 2.0.8   (uploaded 4/19/91)
  1641. ;
  1642. ;       - fixes bug when loading a picture with no cmap or clut tables
  1643. ;
  1644. ;
  1645. ;       version 2.0.7
  1646. ;
  1647. ;       - handles an extended BMHD and uses the xdpi and ydpi info
  1648. ;
  1649. ;
  1650. ;       version 2.0.6   (uploaded 02/19/91)
  1651. ;
  1652. ;       - now handles correctly 0 length chunks (nasty programs)
  1653. ;
  1654. ;       - handles bad cmap chunk lengths (chunklength%3 != 0)
  1655. ;
  1656. ;
  1657. ;       version 2.0.5   (uploaded 1/16/91)
  1658. ;
  1659. ;       - added support for IFF's without CMAPs (24 bit)
  1660. ;
  1661. ;       
  1662. ;       version 2.0.4   (shipped with PgS 2.1  12/7/90)
  1663. ;
  1664. ;       - added support for IFF ACBM files (video toaster)
  1665. ;
  1666. ;       version 2.0.3   (uploaded 10/12/90)
  1667. ;
  1668. ;       - adding color correction for digi view 24 bit files 
  1669. ;
  1670. ;
  1671. ;       version 2.0.2   (uploaded 9/xx/90)
  1672. ;
  1673. ;        - bug fix: now correctly handles the 'dpi=' option
  1674. ;        
  1675. ;        - supports images in 15 and 18 bit standard IFF format (deep ilbm)
  1676. ;          (this has not been tested - only works in theory)
  1677. ;          
  1678. ;        - supports the BEAM chunk as a CTBL chunk
  1679. ;
  1680. ;       version 2.0.1
  1681. ;
  1682. ;       - shipped with pagestream2.0
  1683.