home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Crawly Crypt Collection 2
/
crawlyvol2.bin
/
apps
/
dtp
/
pgsmodst
/
atariimp
/
tiff.s
< prev
next >
Wrap
Text File
|
1991-06-21
|
68KB
|
2,923 lines
Include "equ.h"
Include "impequ.h"
TypeBYTE equ 1
TypeASCII equ 2
TypeSHORT equ 3
TypeLONG equ 4
TypeRATIONAL equ 5
SECTION TIFF,CODE,PUBLIC
***************************************************
*** ***
***************************************************
dumbentry:
clr.l d0
rts
dc.l "IMPP" ; magik number for pic import
dc.w 200
dc.l 0
table: dc.l 0
dc.l name,special,check,TIFF
***********************************
*** Is it really TIFF? ***
***********************************
check: move.l table,a0
move.l buff1(a0),a1
move.l (a1),a1
cmp.w #"MM",(a1)
beq chk1
cmp.w #"II",(a1)
bne never
cmp.w #$2a00,2(a1)
bne never
bra right
chk1: cmp.w #$002a,2(a1)
bne never
bra right
***********************************
*** ***
***********************************
TIFF: move.l table,a1
move.l flen(a1),a0
move.l (a0),piclength
move.l f_openr(a1),a0
jsr (a0)
beq rrts
clr.l picture
clr.l prefix
clr.l suffix
clr.l outcode
move.l table,a0
move.l spclnum(a0),a0
cmp.w #1,(a0)
beq impobj
***********************************
*** ***
***********************************
imppic: move.l table,a0
move.l p_open(a0),a0
jsr (a0)
beq abort0 ;do f_closer and exit
move.l sp,spsave ;for errrts conditions
bsr getpicinfo
move.l table,a4
move.l cwptr(a4),a4 ;ptr to window handle
move.l (a4),a4 ;window handle
move.l (a4),a4 ;ptr to window structure
lea pic,a0
move.w pc_Type(a0),pi_Type(a4)
move.w pc_SFreq(a0),pi_SFreq(a4)
move.w pc_SAngle(a0),pi_SAngle(a4)
move.w pc_SSpot(a0),pi_SSpot(a4)
move.l pc_SMap(a0),pi_SMap(a4)
move.l pc_SMap+4(a0),pi_SMap+4(a4)
move.w pc_XDpi(a0),pi_XDpi(a4)
move.w pc_YDpi(a0),pi_YDpi(a4)
move.w pc_W(a0),pi_W(a4)
move.w pc_H(a0),pi_H(a4)
move.w pc_Width(a0),pi_Width(a4)
move.w pc_BitPln(a0),pi_BitPln(a4)
move.w pc_Palet(a0),pi_Palet(a4)
move.w pi_Palet(a4),d1
mulu #pl_Sizeof,d1
move.l d1,palsize
move.w pi_Width(a4),d0
mulu pi_BitPln(a4),d0
mulu pi_H(a4),d0
add.l d1,d0 ;size of bitmap +( 4 words * #colors)
clr.w d1
clr.w d2
move.l table,a0
move.l m_alloc(a0),a0
jsr (a0)
beq abortpic
move.l table,a3
move.l cwptr(a3),a3
move.l (a3),a3
move.l (a3),a3
move.l a0,pi_Ptr(a3)
move.l (a0),a4
move.l a4,palptr
add.l palsize,a4 ;palette data comes first
move.l a4,picptr
move.l a4,picptrsave
clr.l d0
move.w pic+pc_Width,d0 ;for horizontal differencing
mulu pic+pc_H,d0
move.w pic+pc_BitPln,d1
subq.w #1,d1
mulu d1,d0
add.l d0,a4
move.l a4,picptr2
move.l a4,picptrsave2
bsr putpic
cmp.w #2,predictor
bne imp1
bsr horidif2
imp1: move.l table,a0
move.l p_close(a0),a0
jsr (a0)
move.l table,a0
move.l f_closer(a0),a0
jmp (a0)
abortpic:
move.l spsave,sp
bsr purgepic
move.l table,a0
move.l p_abort(a0),a0
jsr (a0)
abort0: move.l table,a0
move.l f_closer(a0),a0
jmp (a0)
***********************************
*** ***
***********************************
impobj: move.l table,a0
move.l o_open(a0),a0
jsr (a0)
beq abort0
move.l sp,spsave
bsr getpicinfo
move.b #tpic,object+ob_Type
clr.l object+ob_Left
clr.l object+ob_Top
move.w pic+pc_W,d1
move.l #7200,d0
bsr Mulu1632
move.w pic+pc_XDpi,d2
bsr Divu1648
move.l d0,object+ob_Right
move.w pic+pc_H,d1
move.l #7200,d0
bsr Mulu1632
move.w pic+pc_YDpi,d2
bsr Divu1648
move.l d0,object+ob_Bottom
clr.b object+ob_Flag
clr.w object+ob_Slant
clr.w object+ob_Twist
move.w #50,object+ob_LWidth ;1 point line
clr.b object+ob_LType ;no line
move.b #1,object+ob_LColor ;black line
clr.b object+ob_FType ;no fill
move.b #1,object+ob_FColor ;black fill
clr.b object+ob_LBegin
clr.b object+ob_LEnd
move.w #900,object+ob_HStandOff ;1/8 inch
move.w #900,object+ob_VStandOff ;1/8 inch
move.l table,a1
move.l o_obj(a1),a1
lea object,a0
jsr (a1)
beq abortobj
move.w pic+pc_Width,d0
mulu pic+pc_BitPln,d0
mulu pic+pc_H,d0
move.w pic+pc_Palet,d1
mulu #pl_Sizeof,d1
move.l d1,palsize
add.l d1,d0
add.l #pc_Sizeof,d0
move.l table,a0
move.l o_malloc(a0),a0
jsr (a0)
beq abortobj
lea pic,a1
clr.l pc_DPtr(a1)
clr.w pc_DScale(a1)
move.w pc_Palet(a1),d0
mulu #pl_Sizeof,d0
add.l #pc_Sizeof,d0
move.l d0,pc_Ptr(a1)
move.w #pc_Sizeof/2-1,d0
oppic1: move.w (a1)+,(a0)+
dbf d0,oppic1
move.l a0,palptr ;palette data comes after pic struct
move.l palsize,d0
add.l d0,a0
move.l a0,picptr ;pic data comes after palette data
move.l a0,picptrsave
clr.l d0
move.w pic+pc_Width,d0 ;for horizontal differencing
mulu pic+pc_H,d0
move.w pic+pc_BitPln,d1
subq.w #1,d1
mulu d1,d0
add.l d0,a0
move.l a0,picptr2
move.l a0,picptrsave2
bsr putpic
cmp.w #2,predictor
bne oppic2
bsr horidif2
oppic2: move.l table,a0
move.l o_close(a0),a0
jsr (a0)
move.l table,a0
move.l f_closer(a0),a0
jmp (a0)
abortobj:
move.l spsave,sp
bsr purgepic
move.l table,a0
move.l o_abort(a0),a0
jsr (a0)
move.l table,a0
move.l f_closer(a0),a0
jmp (a0)
***********************************
*** ***
***********************************
getpicinfo:
lea pic,a0
move.w #pc_Sizeof-1,d0
gpi1: clr.b (a0)+
dbra d0,gpi1
clr.l picture
move.l table,a1
move.l piclength,d0
clr.w d1
clr.w d2
move.l m_alloc(a1),a1
jsr (a1) ; allocate memory for the picture
beq errrts
move.l a0,picture
move.l #16384,d0
clr.l d1
clr.l d2
move.l table,a1
move.l m_alloc(a1),a1
jsr (a1)
beq errrts
move.l a0,prefix
move.l #4096,d0
clr.l d1
clr.l d2
move.l table,a1
move.l m_alloc(a1),a1
jsr (a1)
beq errrts
move.l a0,suffix
move.l #1025,d0
clr.l d1
clr.l d2
move.l table,a1
move.l m_alloc(a1),a1
jsr (a1)
beq errrts
move.l a0,outcode
clr.l picoffset
move.l picture,a0
move.l (a0),a0
move.l piclength,d0
move.l table,a1
move.l f_getr(a1),a1
jsr (a1)
beq errrts
clr.b byteorder
bsr pgetw ; "FORM"
cmp.w #"II",d0
bne gpi2
move.b #1,byteorder
gpi2:
jsr pgetw ;version number ($42)
jsr pgetl
move.l d0,picoffset
jsr pgetw
move.w d0,tagcount
*
* some defaults set up here!
*
move.w #1,bps
move.l #0,sbc
move.w #1,compression
move.w #0,photom
move.w #1,planar
move.w #1,predictor
move.w #1,sppixel
move.w #2,resunits
move.w #300,xres
move.w #300,yres
move.l #0,rps
move.w #0,palcount
gptagloop:
jsr pgetw
move.w d0,tagid
jsr pgetw
move.w d0,tagtype
jsr pgetl
move.l d0,taglength
cmp.l #10,d0
bcc gptg03
lea typelen,a0
move.l taglength,d0
move.w tagtype,d1
move.b 0(a0,d1.w),d1
lsl.l d1,d0
cmp.l #4,d0
bls gptg01
gptg03: jsr pgetl
move.l d0,tagvalue
bra gptg02
gptg01: move.l picoffset,tagvalue
addq.l #4,picoffset
gptg02: lea taglist,a0
gptg1: move.w (a0)+,d0
beq gptg9
cmp.w tagid,d0
beq gptg8
lea 4(a0),a0
bra gptg1
gptg8: move.l (a0),a0
jsr (a0)
gptg9: subq.w #1,tagcount
bne gptagloop
lea pic,a0
lea pctypetbl,a1
move.w photom,d0
move.b 0(a1,d0.w),d0
move.w d0,pc_Type(a0)
move.w #-1,pc_SFreq(a0)
move.w #-1,pc_SAngle(a0)
move.w #0,pc_SSpot(a0)
move.l #0,pc_SMap(a0)
move.l #0,pc_SMap+4(a0)
move.w xres,pc_XDpi(a0)
move.w yres,pc_YDpi(a0)
move.w pc_W(a0),d0
add.w #15,d0
lsr.w #3,d0
bclr #0,d0
move.w d0,pc_Width(a0)
move.w bps,d0
mulu sppixel,d0
move.w d0,pc_BitPln(a0)
move.l palcount,d0
divu #3,d0
move.w d0,pc_Palet(a0)
rts
*******************************************
*** BitsPerSample ***
*******************************************
tag_bsample:
bsr getdata
move.w d0,bps
rts
*******************************************
*** ColorMap ***
*******************************************
tag_colormap:
move.l taglength,palcount
move.l tagvalue,cmapoffset
rts
*******************************************
*** ColorResponseCurves ***
*******************************************
tag_crcurves:
rts
*******************************************
*** Compression ***
*******************************************
tag_compression:
bsr getdata
move.w d0,compression
rts
*******************************************
*** GrayResponseCurve ***
*******************************************
tag_grcurve:
rts
*******************************************
*** GrayResponseUnit ***
*******************************************
tag_grunit:
rts
*******************************************
*** ImageLength (height) ***
*******************************************
tag_iheight:
bsr getdata
move.w d0,pic+pc_H
rts
*******************************************
*** ImageWidth ***
*******************************************
tag_iwidth:
bsr getdata
move.w d0,pic+pc_W
rts
*******************************************
*** NewSubfileType ***
*******************************************
tag_newsftype:
rts
*******************************************
*** PhotometricInterpretation ***
*******************************************
tag_photometric:
bsr getdata
move.w d0,photom
rts
*******************************************
*** PlanarConfiguration ***
*******************************************
tag_planar:
bsr getdata
move.w d0,planar
rts
*******************************************
*** Predictor ***
*******************************************
tag_predictor:
bsr getdata
move.w d0,predictor
rts
*******************************************
*** ResolutionUnit ***
*******************************************
tag_resolution:
bsr getdata
move.w d0,resunits
rts
*******************************************
*** StripByteCount ***
*******************************************
tag_stripbytecnt:
move.l tagvalue,sbc
move.w tagtype,sbctype
rts
*******************************************
*** RowsPerStrip ***
*******************************************
tag_rpstrip:
bsr getdata
move.l d0,rps
rts
*******************************************
*** SamplesPerPixel ***
*******************************************
tag_sppixel:
bsr getdata
move.w d0,sppixel
rts
*******************************************
*** XResolution ***
*******************************************
tag_xres:
bsr getdata
cmp.w #20,d0 ;kludge for ADPro's TIFF files
bcc tagx1 ;
move.w #75,d0 ;
tagx1: move.w d0,xres
rts
*******************************************
*** YResolution ***
*******************************************
tag_yres:
bsr getdata
cmp.w #20,d0 ;kludge for ADPro's TIFF files
bcc tagy1 ;
move.w #75,d0 ;
tagy1: move.w d0,yres
rts
*******************************************
*** ***
*******************************************
putpic:
clr.l picoffset
bsr pgetw ; "FORM"
jsr pgetw ;version number ($42)
jsr pgetl
move.l d0,picoffset
jsr pgetw
move.w d0,tagcount
pptagloop:
jsr pgetw
move.w d0,tagid
jsr pgetw
move.w d0,tagtype
jsr pgetl
move.l d0,taglength
cmp.l #10,d0
bcc pptg03
lea typelen,a0
move.l taglength,d0
move.w tagtype,d1
move.b 0(a0,d1.w),d1
lsl.l d1,d0
cmp.l #4,d0
bls pptg01
pptg03: jsr pgetl
move.l d0,tagvalue
bra pptg02
pptg01: move.l picoffset,tagvalue
addq.l #4,picoffset
pptg02: lea taglist2,a0
pptg1: move.w (a0)+,d0
beq pptg9
cmp.w tagid,d0
beq pptg8
lea 4(a0),a0
bra pptg1
pptg8: move.l (a0),a0
jsr (a0)
pptg9: subq.w #1,tagcount
bne pptagloop
bra purgepic
*******************************************
*** StripOffsets ***
*******************************************
tag_stripoffset:
cmp.l #0,rps ;was a rps tag found?
bne tgso01 ;yes
clr.l d0
move.w pic+pc_H,d0
cmp.l taglength,d0
bne tgso0
move.l #1,rps
bra tgso01
tgso0: lea taglength,a0
addq.l #2,a0
divu (a0),d0 ;calc how many rows per strip
move.l d0,rps
tgso01: clr.l d0
cmp.w #2,compression
bne tgso02
move.w #0,hcount ;for faxcomp
bra tgso03
tgso02: move.w pic+pc_H,hcount ;for all other compressions
tgso03: move.l picptr2,apos1 ;for cpystr
move.l picptr2,apos2 ; "
move.w #7,bitcount ; "
move.w #0,plncnt ; "
move.w pic+pc_W,d0 ; "
subq.w #1,d0 ; "
move.w d0,pixcount ; "
move.w pic+pc_Width,d0 ; "
mulu pic+pc_H,d0 ; "
move.l d0,plnlen ; "
clr.w flag
bra tgso9
tgso1: cmp.l #0,sbc ;strip loop (taglength times)
bne tgso2
clr.l d0
move.w pic+pc_W,d0
add.w #7,d0 ;round to nearest byte (+7)
lsr.w #3,d0
mulu pic+pc_BitPln,d0
mulu pic+pc_H,d0
move.l d0,striplength
bra tgso3
tgso2: move.l tagvalue,-(sp)
move.w tagtype,-(sp)
move.l sbc,tagvalue
move.w sbctype,tagtype
bsr getdata
move.l d0,striplength
move.l tagvalue,sbc
move.w (sp)+,tagtype
move.l (sp)+,tagvalue
tgso3: bsr getdata
move.l picture,a0
move.l (a0),a0
add.l d0,a0
cmp.w #5,compression ;5=lzw
bne tgso4
move.l outcode,a1
move.l (a1),-(sp)
move.l suffix,a1
move.l (a1),-(sp)
move.l prefix,a1
move.l (a1),-(sp)
move.l #$000000ff,-(sp)
move.l #$00000008,-(sp)
move.l a0,-(sp)
jsr _doLZW
add.l #24,sp
bra tgso9
tgso4: cmp.w #$8005,compression ;$8005 = packbits
bne tgso5
bsr pbrgb
bra tgso9
tgso5: cmp.w #1,compression ;1=no compression
bne tgso7
move.l striplength,d0
clr.w flag ;clear copy flag (0=inc pointer in a0)
bsr nocomp
bra tgso9
tgso7: cmp.w #2,compression ;CCITT compressed?
bne tgso8
cmp.w #1,photom ;is the photmetricinterpret = 1?
bne tgso71 ;no
move.w #0,photom ;reverse it if it is.
tgso71: bsr faxcomp
bra tgso9
tgso8: move.l table,a0 ;clean up and exit
move.l spclnum(a0),a0
cmp.w #1,(a0)
beq abortobj
bra abortpic
tgso9: subq.l #1,taglength
bcc tgso1
rts
***********************************
*** ***
*********************************** ;called for each strip
nocomp:
move.l rps,rowcount
;move.l rps,d1
;divu #0,d7
bsr cpystr
rts
***********************************
*** ***
***********************************
readcode:
movem.l d2-d7/a2-a3,-(a7)
movea.l 36(a7),a3
move.l 40(a7),d7
move.l 44(a7),d6
movea.l 48(a7),a2
move.l (a3),d0
move.l d0,d1
lsr.l #3,d1
move.b 0(a2,d1.l),d2
move.b 1(a2,d1.l),d3
move.b 2(a2,d1.l),d4
add.l d7,(a3)
moveq #24,d1
sub.l d7,d1
moveq #7,d5
and.l d5,d0
moveq #0,d5
move.b d4,d5
moveq #0,d4
move.b d3,d4
asl.l #8,d4
moveq #0,d3
move.b d2,d3
swap d3
clr.w d3
add.l d4,d3
add.l d5,d3
asl.l d0,d3
lsr.l d1,d3
and.l d6,d3
move.l d3,d0
movem.l (a7)+,d2-d7/a2-a3
rts
***********************************
*** ***
***********************************
_doLZW:
link a5,#-64
movem.l d2-d7/a2-a3,-(a7)
move.l rps,rowcount
movea.l 28(a5),a3
move.l 12(a5),d7
moveq #1,d0
move.l d0,d1
asl.l d7,d1
move.l d1,d2
addq.l #1,d2
move.l d1,d3
addq.l #2,d3
move.l d7,d4
addq.l #1,d4
move.l d1,44(a7)
move.l d4,d1
move.l d1,32(a7)
move.l d0,d1
asl.l d4,d1
move.l d1,d6
move.l d6,d0
subq.l #1,d0
moveq #0,d1
move.l d1,-36(a5)
move.l d1,d7
movea.l 8(a5),a2
move.l a2,-(a7)
move.l d0,-(a7)
move.l d4,-(a7)
pea -36(a5)
move.l d0,-28(a5)
move.l d2,56(a7)
move.l d3,-24(a5)
move.l d3,52(a7)
bsr.w readcode
lea 16(a7),a7
move.l d0,d5
moveq #1,d0
move.l d0,-40(a5)
bra.w dolzw6
dolzw1: cmp.l 44(a7),d5
bne.b dolzw2
move.l 32(a7),d4
moveq #1,d0
move.l d0,d1
asl.l d4,d1
move.l d1,d6
move.l d6,d0
subq.l #1,d0
move.l 36(a7),-24(a5)
move.l a2,-(a7)
move.l d0,-(a7)
move.l d4,-(a7)
pea -36(a5)
move.l d0,-28(a5)
bsr.w readcode
move.l d0,d5
move.l d5,d0
and.l 16(a5),d0
move.b d0,-45(a5)
pea 1
pea -45(a5)
bsr _cpystr
lea 24(a7),a7
bra.w dolzw5
dolzw2: move.l d5,d6
cmp.l -24(a5),d6
bcs.b dolzw4
move.l -44(a5),d6
moveq #1,d7
move.b -45(a5),(a3)
bra.b dolzw4
dolzw3: movea.l 24(a5),a0
move.b 0(a0,d6.l),(a2)
move.l d6,d0
asl.l #2,d0
movea.l 20(a5),a0
move.l 0(a0,d0.l),d6
dolzw4: movea.l a3,a2
adda.l d7,a2
addq.l #1,d7
cmp.l 16(a5),d6
bhi.b dolzw3
move.l d6,d0
and.l 16(a5),d0
move.b d0,-45(a5)
move.b d0,(a2)
move.l d7,-(a7)
move.l a3,-(a7)
bsr _cpystr
addq.w #8,a7
moveq #0,d7
move.l -24(a5),d0
move.l d0,d1
asl.l #2,d1
movea.l 20(a5),a0
move.l -44(a5),0(a0,d1.l)
movea.l 24(a5),a0
move.b -45(a5),0(a0,d0.l)
addq.l #1,-24(a5)
move.l -32(a5),d6
move.l d6,d0
subq.l #1,d0
move.l -24(a5),d1
cmp.l d0,d1
bcs.b dolzw5
moveq #12,d0
cmp.l d0,d4
bcc.b dolzw5
addq.l #1,d4
add.l d6,d6
moveq #1,d0
move.l d0,d1
asl.l d4,d1
subq.l #1,d1
move.l d1,-28(a5)
dolzw5: move.l d5,-44(a5)
movea.l 8(a5),a2
move.l a2,-(a7)
move.l -28(a5),-(a7)
move.l d4,-(a7)
pea -36(a5)
bsr.w readcode
lea 16(a7),a7
move.l d0,d5
addq.l #1,-40(a5)
dolzw6: move.l d6,-32(a5)
cmp.l 40(a7),d5
bne.w dolzw1
move.l -40(a5),d0
movem.l (a7)+,d2-d7/a2-a3
unlk a5
rts
**********************************
** **
**********************************
faxcomp:
move.l #0,rowcount
fc2: clr.l d5 ;white codes are always first in row
clr.l d6
move.w pic+pc_W,d6
move.l picptr,a1
move.l #0,d0
move.w #0,pixcount ;zero the pixel counter
move.w #7,pixpos ;set current pixel postion in amiga bitmap
fc3: move.b (a0),temp
move.b 1(a0),temp+1
move.b 2(a0),temp+2
move.b 3(a0),temp+3
move.l temp,d0 ;get 4 bytes into d0 for bit testing
clr.l d1
move.l #31,d1 ;set the bit pointer
fc4: move.l d1,saved1 ;save d1 for the table switch testing
move.l a0,savea0 ;save a0 for table switch testing
fc5: move.w #0,d7 ;clear the bit counter
move.l saved1,d1 ;reset d1
move.l savea0,a0 ;reset a0
lea work,a3
move.l #0,(a3) ;clear out work area
move.l #0,4(a3)
move.l #0,8(a3)
move.l #0,12(a3)
btst d1,d0 ;get the first bit into the work area
beq.s fc51
move.b #$31,0(a3)
bra.s fc52
fc51: move.b #$30,0(a3)
fc52: subq.l #1,d1
move.l #1,d2 ;d2 = index into work area
addq.w #1,d7 ;d7 = bitcount
btst #0,d5 ;which color?
bne ck0 ;smallest black code is 2 bits
btst d1,d0 ;get next 2 bits into the work area
beq.s fc53 ;smallest white code is 4 bits
move.b #$31,1(a3)
bra.s fc54
fc53: move.b #$30,1(a3)
fc54: subq.l #1,d1
btst d1,d0
beq.s fc55
move.b #$31,2(a3)
bra.s fc56
fc55: move.b #$30,2(a3)
fc56: subq.l #1,d1
move.l #3,d2 ;d2 = index into work area
addq.w #2,d7
btst #1,d5 ;which table are we in? 0=makeup; 1=term
bne.s fc57 ;
lea wmindex,a4 ;
bra ck0 ;
fc57: lea wtindex,a4 ;
ck0: btst d1,d0 ;get next bit into work area
beq.s ck01
move.b #$31,0(a3,d2)
bra.s ck02
ck01: move.b #$30,0(a3,d2)
ck02: addq #1,d2 ;update work area index
btst #0,d5 ;which color? 0=white; 1=black.
bne ckbm
move.l (a4),a2 ;temp
ckw1: move.l (a2),d4 ;compare work area to code in table
cmp.l (a3),d4 ;if not equal goto ckw2
bne ckw3 ;temp - used to be ckw2
move.l 4(a2),d4
cmp.l 4(a3),d4
bne ckw2
move.l 8(a2),d4
cmp.l 8(a3),d4
bne ckw2
move.l 12(a2),d4
and.l #$ffffff00,d4
cmp.l 12(a3),d4
bne ckw2
bra doit0 ;found a code! do something with it!
ckw2: add.l #18,a2 ;get next table entry
tst.b (a2) ;are we at end of table yet?
bne.s ckw1 ;if not continue check
move.l (a4),a2 ;reset a2
subq.l #1,d1 ;get next bit into work area
addq.w #1,d7 ;update bit counter
cmp.w #13,d7 ;have we checked the max possible length?
bcs ck0 ;if not get next bit
bchg #1,d5 ;else switch tables
beq fc5 ;if on first table branch back
clr.l d6
bra fc7 ;error - could not find code - out of sinc?
ckw3: addq.l #4,a4 ;get next index pointer
move.l (a4),a2 ;set a2 equal to it
cmp.l #0,a2 ;is it the end of the index
bne ckw1 ;if not branch
bchg #1,d5 ;switch tables
bne fc8 ;if term table exit (used to be: beq fc5)
btst #1,d5 ;which table are we in? 0=makeup; 1=term
bne.s ckw4 ;
lea wmindex,a4 ;
move.l (a4),a2 ;
bra ckw1 ;
ckw4: lea wtindex,a4 ;
move.l (a4),a2 ;
bra ckw1 ;
ckbm: btst #1,d5 ;are we in the makeup codes or term. codes
bne.s ckb0 ;0=makeup code table; 1=term code table.
lea bmakeupcodes,a2 ;check work area against black makeup codes
bra ckb1
ckb0: lea btermcodes,a2
ckb1: move.w (a2),d4 ;compare work area to code in table
cmp.w (a3),d4 ;if not equal goto ckb2
bne ckb3
move.w 2(a2),d4
cmp.w 2(a3),d4
bne ckb2
move.l 4(a2),d4
cmp.l 4(a3),d4
bne ckb2
move.l 8(a2),d4
cmp.l 8(a3),d4
bne ckb2
move.l 12(a2),d4
and.l #$ffffff00,d4
cmp.l 12(a3),d4
bne ckb2
bra doit0 ;found a code! do something with it!
ckb2: add.l #18,a2 ;get next table entry
tst.b (a2) ;are we at end of table yet?
bne.s ckb1 ;if not continue check
subq.l #1,d1 ;else get next bit into work area
addq.w #1,d7
cmp.w #13,d7
bcs ck0
bchg #1,d5 ;switch tables
beq fc5 ;branch back if on first table
clr.l d6 ;end this row
bra fc7 ;error - could not find code in table - out of sinc?
ckb3: btst #1,d5
bne ckb2 ;if term table handle normally
bset #1,d5 ;set it to the term table
bra fc5
doit0: bclr #3,d5 ;clear term. flag
move.w 16(a2),d2 ;get run length (in pixels)
move.w d2,pixcount ;save for updating the picture width
move.w pixpos,d3 ;get current pixel position in amiga bitmap
btst #1,d5 ;am i in here on a makeup or term code?
bne doit1
subq.w #8,d2 ;remove partial pixels
lsr.w #5,d2 ;d2 = number of long words i need to move
cmp.w #1,photom ;is it reversed?
bne doit00 ;no
cmp.b #0,15(a2) ;which color? 0=Black, 1=White
bne doWl0
bra doBl0
doit00: cmp.b #0,15(a2) ;which color? 1=Black, 0=White
beq doWl0
doBl0: bclr d3,(a1)
dbf d3,doBl0
addq.l #1,a1
bclr #2,d5 ;clear odd address flag
move.l a1,d3
btst #0,d3 ;are we on a word boundry (even address)?
beq.s doBl2 ;yes!
move.b #0,(a1)+ ;no - odd address
bset #2,d5 ;set flag
bra.s doBl2
doBl1: move.l #0,(a1)+
doBl2: dbf d2,doBl1
move.w #0,(a1)+
btst #2,d5 ;check odd address flag
bne.s doBl22 ;yes we started on an odd address
move.b #0,(a1)+
doBl22: move.w #7,d3
move.w pixpos,d4
doBl3: bclr d3,(a1)
subq.w #1,d3
cmp.w d3,d4
bcs.s doBl3
bra fc6
doWl0: bset d3,(a1) ;loop bits to next byte boundry
dbf d3,doWl0
addq.l #1,a1
bclr #2,d5 ;clear flag odd address flag
move.l a1,d3
btst #0,d3 ;are we on a word boundry (even)?
beq.s doWl2 ;yes!
move.b #$ff,(a1)+ ;no, so make it that way
bset #2,d5 ;set flag odd address flag
bra.s doWl2
doWl1: move.l #$ffffffff,(a1)+ ;white makeup codes
doWl2: dbf d2,doWl1
move.w #$ffff,(a1)+
btst #2,d5
bne.s doWl22
move.b #$ff,(a1)+
doWl22: move.w #7,d3
move.w pixpos,d4
doWl3: bset d3,(a1)
subq.w #1,d3
cmp.w d3,d4
bcs.s doWl3
bra fc6
;doWl0: add.w #1,d2
; lsl.w #2,d2 ;d2 = number of bytes
; add.w d2,a1 ;push ahead a1
; bra fc6
doit1: bset #3,d5 ;set term. flag
cmp.w #1,photom ;is it reversed?
bne doit2 ;no
tst.b 15(a2) ;which color? 0=Black, 1=White
bne doWs2
bra doBs2
doit2: tst.b 15(a2) ;which color? 1=Black, 0=White
beq doWs2
bra doBs2 ;black bit loop
doBs1: bclr d3,(a1)
dbf d3,doBs2
addq.l #1,a1
move.w #7,d3
doBs2: dbf d2,doBs1
bra doit3
doWs1: bset d3,(a1) ;white bit loop
dbf d3,doWs2
addq.l #1,a1
move.w #7,d3
doWs2: dbf d2,doWs1
doit3: move.w d3,pixpos
bchg #0,d5 ;switch colors
bclr #1,d5 ;set table to makeup table for new color
fc6: move.l #31,d2
sub.l d1,d2 ;d2=31-d1
lsr.l #3,d2 ;divide by 8
add.l d2,a0 ;update memory pointer
move.b (a0),temp ;reload memory into d0
move.b 1(a0),temp+1
move.b 2(a0),temp+2
move.b 3(a0),temp+3
move.l temp,d0
lsl.l #3,d2 ;multiple by 8
subq.l #1,d1
add.l d2,d1 ;remap d1 to top of 4 byte input
sub.w pixcount,d6
btst #3,d5 ;was the last code a term or makeup?
beq fc4 ;branch if a makeup code
fc7: tst.w d6 ;have we done an entire row yet?
bne fc4 ;if not branch?
move.l picptr,a1 ;move a1 to the next row in the amiga bitmap
add.w pic+pc_Width,a1
move.l a1,picptr
addq.l #1,rowcount ;temp - bump up the row counter
addq.w #1,hcount ;temp - bump up height counter
add.l #1,a0 ;temp - new rows start on a byte boundry
fc8: move.w pic+pc_H,d0 ;temp - get the total height of the picture
sub.w hcount,d0 ;temp - have we done the entire picture?
beq fc9 ;temp - yes so exit
move.l rps,d0 ;temp - have we done all the rows in this strip?
sub.l rowcount,d0 ;temp
bhi fc2 ;temp - (bhi = carry clear & zero clear)
fc9: rts
**********************************
** **
**********************************
_cpystr:
move.l 4(sp),a0
move.l 8(sp),d0
add.l d0,a0
subq.l #1,a0
bset #1,flag
cpystr:
movem.l d1-d7/a1-a2,-(sp)
cmp.w #3,predictor ;branch if predictor is greater than 2
bcs cp0 ;known lzw pre-compression technique so cont.
movem.l (sp)+,d1-d7/a1-a2 ;restore registers
move.l table,a0 ;clean up and exit
move.l spclnum(a0),a0
cmp.w #1,(a0)
beq abortobj
bra abortpic
cp0: move.l apos2,a2 ;restore place in amiga bitmap - plane x
move.l apos1,a1 ;restore place in amiga bitmap - plane 1
move.l plnlen,d7 ;d7 = amiga bitplane length in bytes
move.w bitcount,d5 ;restore bit place in a2
move.w plncnt,d1 ;restore plane counter
move.w pixcount,d6 ;restore pixel counter
moveq #7,d3 ;d3 = bit position in tiff data
cp1: cmp.w #2,predictor ;if horizontal diff. is used - data is normal
beq.s norm
cmp.w #1,photom
bne.s norm
btst d3,(a0) ;is the data bit on or off
beq.s cp2 ;off
bclr d5,(a2)
bra.s cp4
cp2: bset d5,(a2)
bra.s cp4
norm: btst d3,(a0) ;is the data bit on or off
beq.s cp3 ;off
bset d5,(a2)
bra.s cp4
cp3: bclr d5,(a2)
cp4: sub.l d7,a2 ;go to next bitplane
addq.w #1,d1 ;update bitplane counter
cmp.w pic+pc_BitPln,d1
bcs cp7
moveq #0,d1 ;reset bitplane counter
move.l a1,a2 ;reset a2 to last bitplane
cp5: dbf d5,cp6 ;update amiga bit pos
addq.l #1,a1 ;move to next amiga bitmap byte
addq.l #1,a2
moveq #7,d5 ;reset d5 to top of byte
cp6: dbf d6,cp7 ;update pixel width counter
move.l picptr2,a1
clr.l d5
move.w pic+pc_Width,d5
add.l d5,a1
move.l a1,picptr2
move.l a1,a2
move.w #7,d5
move.w pic+pc_W,d6
subq.w #1,d6
subq.w #1,hcount
beq cp81
subq.l #1,rowcount
beq cp81
cmp.w #1,pic+pc_BitPln ;is it b&w?
beq cp70 ;yes
cmp.w #1,compression ;is it compressed data?
beq cp70 ;no, so start next row on a byte boundry
cp7: dbf d3,cp1 ;update tiff bit counter
cp70: moveq #7,d3 ;reset tiff data bit counter
btst #0,flag ;check copy flag
bne.s cp8 ;0=increment from address, 1=no increment
btst #1,flag
bne.s cp71
addq.l #1,a0 ;move to next byte
bra.s cp8
cp71: subq.l #1,a0 ;move to prev byte
cp8: subq.l #1,d0 ;decrement data byte count
bne cp1
cp81: move.l a2,apos2 ;save place in amiga bitmap - plane x
move.l a1,apos1 ;save place in amiga bitmap - plane 1
move.w d5,bitcount ;save bit place in a2
move.w d1,plncnt ;save plane counter
move.w d6,pixcount ;save pixel counter
movem.l (sp)+,d1-d7/a1-a2
rts
**********************************
** **
**********************************
horidif2:
move.l picptrsave2,a1 ;a1 = base address in last bit plane
move.l a1,picptr2 ;get starting address of row
move.l a1,a2 ;a2 = address in bitmap row
move.w pic+pc_W,d0 ;d0 = horizontal pixel counter
move.w #7,d5 ;d5 = bit counter into bit map
move.w pic+pc_Width,d1
mulu pic+pc_H,d1 ;d1 = length of amiga bitmap
move.w pic+pc_W,d0 ;d0 = horizontal pixel counter
subq.w #1,d0
move.w pic+pc_H,d2 ;d2 = vertical row counter
move.l #0,lastval ;zero the last pixel value
bra ho5
ho0: clr.l d3 ;d3 = value of pixel
move.w pic+pc_BitPln,d6 ;d6 = bit plane counter
subq.w #1,d6
move.w d6,d4 ;d4 = bit position in d3
move.l a1,a2 ;reset a2 to first bitplane
ho1: btst d5,(a2) ;get the pixel's value into d3
beq ho2
bset d4,d3
bra ho3
ho2: bclr d4,d3
ho3: subq.w #1,d4 ;sub 1 from the d3 bit postion counter
sub.l d1,a2 ;move a2 to next amiga bitplane
dbf d6,ho1 ;decrement amiga bitplane counter
move.l d3,temp
move.b temp+3,d3
add.b d3,lastval+3
move.b temp+2,d3
add.b d3,lastval+2
move.b temp+1,d3
add.b d3,lastval+1
move.l lastval,d3
cmp.w #1,photom ;is the image reversed?
bne ho30 ;no
not.l d3
ho30: move.w pic+pc_BitPln,d4
subq.w #1,d4
move.l a1,a2
ho31: btst d4,d3
beq ho32
bset d5,(a2)
bra ho33
ho32: bclr d5,(a2)
ho33: sub.l d1,a2
dbf d4,ho31
ho4: dbf d5,ho41
add.l #1,a1 ;move to next byte
move.w #7,d5 ;reset bit counter
ho41: dbf d0,ho0 ;decrement horizontal counter
move.l picptr2,a1
add.w pic+pc_Width,a1
move.l a1,picptr2
move.w pic+pc_W,d0 ;reset d0 to width in pixels
subq.w #1,d0
move.w #7,d5 ;reset bit counter
move.l #0,lastval ;reset last pixel value to zero
ho5: dbf d2,ho0 ;decrement row counter
rts
***********************************
*** ***
*********************************** ;called once per strip
pbrgb: move.l rps,rowcount
move.l striplength,d2
addq.l #2,d2 ;not sure why - but it seems to work
tst.l sbc
beq pb2
subq.l #2,d2
pb2: tst.w hcount
beq pb12
tst.l rowcount
beq pb12
clr.l d0
move.b (a0)+,d0 ;d0 = one byte code
tst.l sbc
beq pb3
subq.l #1,d2 ;subtract 1 from the length for the code
beq pb12
bmi pb11
pb3: cmp.b #128,d0
beq.s pb2 ;code 128 = do nothing, so get next byte
btst #7,d0 ;check the high bit
beq.s pb5 ;if 0 copy the next d0+1 bytes as is
neg.b d0 ;else copy the next byte -d0+1 times
add.b #1,d0
clr.l d3
move.b d0,d3
bset #0,flag ;set the copy flag (1=don't inc ptr in a0)
bsr cpystr ;copy the byte (a0) into bitmap (a1)
addq.l #1,a0 ;move to next code
tst.l sbc
beq sb4
moveq #1,d3 ;subtract 1 from the striplength
sb4: sub.l d3,d2
beq pb12
bmi pb11
bra pb2
pb5: bclr #0,flag ;clear the copy flag (0=inc the ptr in a0)
clr.l d3
add.b #1,d0
move.b d0,d3 ;save for later
bsr cpystr
sub.l d3,d2
beq pb12
bmi pb11
bra pb2
pb11:
pb12: rts
***********************************
*** ***
***********************************
get_colormap:
movem.l d0-d6/a0-a2,-(sp)
move.l palptr,a0 ;a0 = start of amiga palette
move.l palcount,d0 ;d0 = number of entries
divu #3,d0 ;d0 = number of colors (rgb)
move.l cmapoffset,d1
move.l picture,a1
move.l (a1),a1
add.l d1,a1 ;a1 = start of colormap data in tiff
move.w d0,d2
lsl.w #1,d2 ;d2 = length of each color's data
bra gc4
gc0: move.l a1,a2
bsr getcword ;get color word in d4
move.w d4,(a0) ;red
add.w d2,a2
bsr getcword
move.w d4,2(a0) ;green
add.w d2,a2
bsr getcword
move.w d4,4(a0) ;blue
move.w (a0)+,d4
move.w (a0)+,d5
move.w (a0)+,d6
mulu #19661,d4
mulu #38666,d5
mulu #7209,d6
add.l d5,d4
add.l d6,d4
swap d4
cmp.w #$8000,d4
bcc gc1
moveq #1,d4
bra gc2
gc1: moveq #0,d4
gc2: move.w d4,(a0)+ ;screen color
addq.l #2,a1 ;move to next color word
gc4: dbf d0,gc0
movem.l (sp)+,d0-d6/a0-a2
rts ;when done with all colors - exit
***********************************
*** ***
***********************************
getcword:
gt1: tst.b byteorder
bne gt2
move.w (a2),d4 ;Motorola format
bra gt3
gt2: move.b (a2),temp+1 ;Intel format
move.b (a2),temp
move.w temp,d4
gt3: rts
***********************************
*** ***
***********************************
getdata:
cmp.w #TypeBYTE,tagtype
bne getd1
move.l picture,a0
move.l (a0),a0
add.l tagvalue,a0
clr.l d0
move.b (a0),d0
addq.l #1,tagvalue
rts
getd1: cmp.w #TypeSHORT,tagtype
bne getd2
move.l picture,a0
move.l (a0),a0
add.l tagvalue,a0
tst.b byteorder
bne getd10
move.b (a0)+,temp
move.b (a0),temp+1
bra getd11
getd10: move.b (a0)+,temp+1
move.b (a0),temp
getd11: clr.l d0
move.w temp,d0
addq.l #2,tagvalue
rts
getd2: cmp.w #TypeLONG,tagtype
bne getd3
move.l picture,a0
move.l (a0),a0
add.l tagvalue,a0
tst.b byteorder
bne getd20
move.b (a0)+,temp
move.b (a0)+,temp+1
move.b (a0)+,temp+2
move.b (a0),temp+3
bra getd21
getd20: move.b (a0)+,temp+3
move.b (a0)+,temp+2
move.b (a0)+,temp+1
move.b (a0),temp
getd21: move.l temp,d0
addq.l #4,tagvalue
rts
getd3: cmp.w #TypeRATIONAL,tagtype
bne rrts
move.l picture,a0
move.l (a0),a0
add.l tagvalue,a0
tst.b byteorder
bne getd30
move.b (a0)+,temp
move.b (a0)+,temp+1
move.b (a0)+,temp+2
move.b (a0)+,temp+3
move.b (a0)+,temp2
move.b (a0)+,temp2+1
move.b (a0)+,temp2+2
move.b (a0),temp2+3
bra getd31
getd30: move.b (a0)+,temp+3
move.b (a0)+,temp+2
move.b (a0)+,temp+1
move.b (a0)+,temp
move.b (a0)+,temp2+3
move.b (a0)+,temp2+2
move.b (a0)+,temp2+1
move.b (a0),temp2
getd31: move.l temp,d0
move.l temp2,d1
divu d1,d0
addq.l #8,tagvalue
rts
**********************************
** **
**********************************
pgetl: move.l picture,a0
move.l (a0),a0
add.l picoffset,a0
tst.b byteorder
bne pgetl1
move.b (a0)+,temp
move.b (a0)+,temp+1
move.b (a0)+,temp+2
move.b (a0),temp+3
bra pgetl2
pgetl1: move.b (a0)+,temp+3
move.b (a0)+,temp+2
move.b (a0)+,temp+1
move.b (a0),temp
pgetl2: move.l temp,d0
addq.l #4,picoffset
rts
pgetw: move.l picture,a0
move.l (a0),a0
add.l picoffset,a0
tst.b byteorder
bne pgetw1
move.b (a0)+,temp
move.b (a0),temp+1
bra pgetw2
pgetw1: move.b (a0)+,temp+1
move.b (a0),temp
pgetw2: move.w temp,d0
addq.l #2,picoffset
rts
pget: move.l picture,a0
move.l (a0),a0
add.l picoffset,a0
move.b (a0),d0
addq.l #1,picoffset
rts
***********************************
*** ***
***********************************
errrts: bsr purgepic
move.l table,a0
move.l spclnum(a0),a0
cmp.w #1,(a0)
beq abortobj
bra abortpic
rrts: rts
***********************************
*** ***
***********************************
purgepic:
tst.l picture
beq pu1
move.l picture,a0
move.l table,a1
move.l m_delete(a1),a1
jsr (a1)
pu1: tst.l prefix
beq pu2
move.l prefix,a0
move.l table,a1
move.l m_delete(a1),a1
jsr (a1)
pu2: tst.l suffix
beq pu3
move.l suffix,a0
move.l table,a1
move.l m_delete(a1),a1
jsr (a1)
pu3: tst.l outcode
beq pu4
move.l outcode,a0
move.l table,a1
move.l m_delete(a1),a1
jsr (a1)
pu4: rts
***********************************
*** ***
***********************************
Mulu1632:
move.l table,a0
move.l mulu1632(a0),a0
jmp (a0)
***********************************
*** ***
***********************************
Divu1648:
move.l table,a0
move.l divu1648(a0),a0
jmp (a0)
*******************************************************************
*** called when the import routine choosen finds something ***
*** wrong with the file loaded. ***
*******************************************************************
never: clr.w d0
rts
maybe: move.w #1,d0
rts
right: move.w #2,d0
rts
*************************************************************
*************************************************************
SECTION TIFF,DATA,PUBLIC
taglist2:
dc.w $0111
dc.l tag_stripoffset
dc.w $8000 ;used by aldus pagemaker
dc.l tag_stripoffset
dc.w $0140
dc.l get_colormap
dc.w 0
taglist:
dc.w $0102
dc.l tag_bsample
dc.w $0140
dc.l tag_colormap
dc.w $012d
dc.l tag_crcurves
dc.w $0103
dc.l tag_compression
dc.w $0123
dc.l tag_grcurve
dc.w $0122
dc.l tag_grunit
dc.w $0101
dc.l tag_iheight
dc.w $0100
dc.l tag_iwidth
dc.w $00fe
dc.l tag_newsftype
dc.w $0106
dc.l tag_photometric
dc.w $011c
dc.l tag_planar
dc.w $013d
dc.l tag_predictor
dc.w $0128
dc.l tag_resolution
dc.w $0116
dc.l tag_rpstrip
dc.w $0115
dc.l tag_sppixel
dc.w $0117
dc.l tag_stripbytecnt
dc.w $011a
dc.l tag_xres
dc.w $011b
dc.l tag_yres
dc.w 0
wtindex:
dc.l wt1,wt2,wt3,wt4,wt5,wt6,wt7,wt8,wt9,wt10
dc.l wt11,wt12,wt13,wt14,wt15,0
wmindex:
dc.l wm1,wm2,wm3,wm4,wm5,wm6,wm7,0
wtermcodes: ;OPTOMIZED!
wt1: dc.b "00000010",0,0,0,0,0,0,0
dc.b 1
dc.w 29
dc.b "00000011",0,0,0,0,0,0,0
dc.b 1
dc.w 30
dc.b "00000100",0,0,0,0,0,0,0
dc.b 1
dc.w 45
dc.b "00000101",0,0,0,0,0,0,0
dc.b 1
dc.w 46
dc.b "0000011",0,0,0,0,0,0,0,0
dc.b 1
dc.w 22
dc.b "0000100",0,0,0,0,0,0,0,0
dc.b 1
dc.w 23
dc.b "00001010",0,0,0,0,0,0,0
dc.b 1
dc.w 47
dc.b "00001011",0,0,0,0,0,0,0
dc.b 1
dc.w 48
dc.b "000011",0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 13
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wt2: dc.b "0001000",0,0,0,0,0,0,0,0
dc.b 1
dc.w 20
dc.b "00010010",0,0,0,0,0,0,0
dc.b 1
dc.w 33
dc.b "00010011",0,0,0,0,0,0,0
dc.b 1
dc.w 34
dc.b "00010100",0,0,0,0,0,0,0
dc.b 1
dc.w 35
dc.b "00010101",0,0,0,0,0,0,0
dc.b 1
dc.w 36
dc.b "00010110",0,0,0,0,0,0,0
dc.b 1
dc.w 37
dc.b "00010111",0,0,0,0,0,0,0
dc.b 1
dc.w 38
dc.b "0001100",0,0,0,0,0,0,0,0
dc.b 1
dc.w 19
dc.b "00011010",0,0,0,0,0,0,0
dc.b 1
dc.w 31
dc.b "00011011",0,0,0,0,0,0,0
dc.b 1
dc.w 32
dc.b "000111",0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 1
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wt3: dc.b "001000",0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 12
dc.b "00100100",0,0,0,0,0,0,0
dc.b 1
dc.w 53
dc.b "00100101",0,0,0,0,0,0,0
dc.b 1
dc.w 54
dc.b "0010011",0,0,0,0,0,0,0,0
dc.b 1
dc.w 26
dc.b "00101000",0,0,0,0,0,0,0
dc.b 1
dc.w 39
dc.b "00101001",0,0,0,0,0,0,0
dc.b 1
dc.w 40
dc.b "00101010",0,0,0,0,0,0,0
dc.b 1
dc.w 41
dc.b "00101011",0,0,0,0,0,0,0
dc.b 1
dc.w 42
dc.b "00101100",0,0,0,0,0,0,0
dc.b 1
dc.w 43
dc.b "00101101",0,0,0,0,0,0,0
dc.b 1
dc.w 44
dc.b "0010111",0,0,0,0,0,0,0,0
dc.b 1
dc.w 21
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wt4: dc.b "0011000",0,0,0,0,0,0,0,0
dc.b 1
dc.w 28
dc.b "00110010",0,0,0,0,0,0,0
dc.b 1
dc.w 61
dc.b "00110011",0,0,0,0,0,0,0
dc.b 1
dc.w 62
dc.b "00110100",0,0,0,0,0,0,0
dc.b 1
dc.w 63
dc.b "00110101",0,0,0,0,0,0,0 ;code string null terminated
dc.b 1 ;color: 1=White, 0=Black
dc.w 0 ;run length
dc.b "00111",0,0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 10
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wt5: dc.b "01000",0,0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 11
dc.b "0100100",0,0,0,0,0,0,0,0
dc.b 1
dc.w 27
dc.b "01001010",0,0,0,0,0,0,0
dc.b 1
dc.w 59
dc.b "01001011",0,0,0,0,0,0,0
dc.b 1
dc.w 60
dc.b "0100111",0,0,0,0,0,0,0,0
dc.b 1
dc.w 18
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wt6: dc.b "0101000",0,0,0,0,0,0,0,0
dc.b 1
dc.w 24
dc.b "01010010",0,0,0,0,0,0,0
dc.b 1
dc.w 49
dc.b "01010011",0,0,0,0,0,0,0
dc.b 1
dc.w 50
dc.b "01010100",0,0,0,0,0,0,0
dc.b 1
dc.w 51
dc.b "01010101",0,0,0,0,0,0,0
dc.b 1
dc.w 52
dc.b "0101011",0,0,0,0,0,0,0,0
dc.b 1
dc.w 25
dc.b "01011000",0,0,0,0,0,0,0
dc.b 1
dc.w 55
dc.b "01011001",0,0,0,0,0,0,0
dc.b 1
dc.w 56
dc.b "01011010",0,0,0,0,0,0,0
dc.b 1
dc.w 57
dc.b "01011011",0,0,0,0,0,0,0
dc.b 1
dc.w 58
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wt7: dc.b "0111",0,0,0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 2
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wt8: dc.b "1000",0,0,0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 3
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wt9: dc.b "10011",0,0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 8
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wt10: dc.b "10100",0,0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 9
dc.b "101010",0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 16
dc.b "101011",0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 17
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wt11: dc.b "1011",0,0,0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 4
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wt12: dc.b "1100",0,0,0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 5
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wt13: dc.b "110100",0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 14
dc.b "110101",0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 15
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wt14: dc.b "1110",0,0,0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 6
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wt15: dc.b "1111",0,0,0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 7
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wmakeupcodes: ;OPTOMIZED!
wm1: ;dc.b "000000000001",0,0,0
;dc.b 1
;dc.w 0 ;EOL
dc.b "00000001000",0,0,0,0
dc.b 1
dc.w 1792
dc.b "000000010010",0,0,0
dc.b 1
dc.w 1984
dc.b "000000010011",0,0,0
dc.b 1
dc.w 2048
dc.b "000000010100",0,0,0
dc.b 1
dc.w 2112
dc.b "000000010101",0,0,0
dc.b 1
dc.w 2176
dc.b "000000010110",0,0,0
dc.b 1
dc.w 2240
dc.b "000000010111",0,0,0
dc.b 1
dc.w 2304
dc.b "00000001100",0,0,0,0
dc.b 1
dc.w 1856
dc.b "00000001101",0,0,0,0
dc.b 1
dc.w 1920
dc.b "000000011100",0,0,0
dc.b 1
dc.w 2368
dc.b "000000011101",0,0,0
dc.b 1
dc.w 2432
dc.b "000000011110",0,0,0
dc.b 1
dc.w 2496
dc.b "000000011111",0,0,0
dc.b 1
dc.w 2560
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wm2: dc.b "00110110",0,0,0,0,0,0,0
dc.b 1
dc.w 320
dc.b "00110111",0,0,0,0,0,0,0
dc.b 1
dc.w 384
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wm3: dc.b "010011000",0,0,0,0,0,0
dc.b 1
dc.w 1472
dc.b "010011001",0,0,0,0,0,0
dc.b 1
dc.w 1536
dc.b "010011010",0,0,0,0,0,0
dc.b 1
dc.w 1600
dc.b "010011011",0,0,0,0,0,0
dc.b 1
dc.w 1728
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wm4: dc.b "010111",0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 192
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wm5: dc.b "01100100",0,0,0,0,0,0,0
dc.b 1
dc.w 448
dc.b "01100101",0,0,0,0,0,0,0
dc.b 1
dc.w 512
dc.b "011001100",0,0,0,0,0,0
dc.b 1
dc.w 704
dc.b "011001101",0,0,0,0,0,0
dc.b 1
dc.w 768
dc.b "01100111",0,0,0,0,0,0,0
dc.b 1
dc.w 640
dc.b "01101000",0,0,0,0,0,0,0
dc.b 1
dc.w 576
dc.b "011010010",0,0,0,0,0,0
dc.b 1
dc.w 832
dc.b "011010011",0,0,0,0,0,0
dc.b 1
dc.w 896
dc.b "011010100",0,0,0,0,0,0
dc.b 1
dc.w 960
dc.b "011010101",0,0,0,0,0,0
dc.b 1
dc.w 1024
dc.b "011010110",0,0,0,0,0,0
dc.b 1
dc.w 1088
dc.b "011010111",0,0,0,0,0,0
dc.b 1
dc.w 1152
dc.b "011011000",0,0,0,0,0,0
dc.b 1
dc.w 1216
dc.b "011011001",0,0,0,0,0,0
dc.b 1
dc.w 1280
dc.b "011011010",0,0,0,0,0,0
dc.b 1
dc.w 1344
dc.b "011011011",0,0,0,0,0,0
dc.b 1
dc.w 1408
dc.b "0110111",0,0,0,0,0,0,0,0
dc.b 1
dc.w 256
dc.b "011000",0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 1664
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wm6: dc.b "10010",0,0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 128
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
wm7: dc.b "11011",0,0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 64
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 1
dc.w 0
btermcodes: ;OPTOMIZED!
dc.b "11",0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 2
dc.b "10",0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 3
dc.b "010",0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 1
dc.b "011",0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 4
dc.b "0011",0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 5
dc.b "0010",0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 6
dc.b "00011",0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 7
dc.b "000101",0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 8
dc.b "000100",0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 9
dc.b "0000100",0,0,0,0,0,0,0,0
dc.b 0
dc.w 10
dc.b "0000101",0,0,0,0,0,0,0,0
dc.b 0
dc.w 11
dc.b "0000111",0,0,0,0,0,0,0,0
dc.b 0
dc.w 12
dc.b "00000100",0,0,0,0,0,0,0
dc.b 0
dc.w 13
dc.b "00000111",0,0,0,0,0,0,0
dc.b 0
dc.w 14
dc.b "000011000",0,0,0,0,0,0
dc.b 0
dc.w 15
dc.b "0000010111",0,0,0,0,0
dc.b 0
dc.w 16
dc.b "0000110111",0,0,0,0,0
dc.b 0
dc.w 0
dc.b "0000011000",0,0,0,0,0
dc.b 0
dc.w 17
dc.b "0000001000",0,0,0,0,0
dc.b 0
dc.w 18
dc.b "00001100111",0,0,0,0
dc.b 0
dc.w 19
dc.b "00001101000",0,0,0,0
dc.b 0
dc.w 20
dc.b "00001101100",0,0,0,0
dc.b 0
dc.w 21
dc.b "00000110111",0,0,0,0
dc.b 0
dc.w 22
dc.b "00000101000",0,0,0,0
dc.b 0
dc.w 23
dc.b "00000010111",0,0,0,0
dc.b 0
dc.w 24
dc.b "00000011000",0,0,0,0
dc.b 0
dc.w 25
dc.b "000011001010",0,0,0
dc.b 0
dc.w 26
dc.b "000011001011",0,0,0
dc.b 0
dc.w 27
dc.b "000011001100",0,0,0
dc.b 0
dc.w 28
dc.b "000011001101",0,0,0
dc.b 0
dc.w 29
dc.b "000001101000",0,0,0
dc.b 0
dc.w 30
dc.b "000001101001",0,0,0
dc.b 0
dc.w 31
dc.b "000001101010",0,0,0
dc.b 0
dc.w 32
dc.b "000001101011",0,0,0
dc.b 0
dc.w 33
dc.b "000011010010",0,0,0
dc.b 0
dc.w 34
dc.b "000011010011",0,0,0
dc.b 0
dc.w 35
dc.b "000011010100",0,0,0
dc.b 0
dc.w 36
dc.b "000011010101",0,0,0
dc.b 0
dc.w 37
dc.b "000011010110",0,0,0
dc.b 0
dc.w 38
dc.b "000011010111",0,0,0
dc.b 0
dc.w 39
dc.b "000001101100",0,0,0
dc.b 0
dc.w 40
dc.b "000001101101",0,0,0
dc.b 0
dc.w 41
dc.b "000011011010",0,0,0
dc.b 0
dc.w 42
dc.b "000011011011",0,0,0
dc.b 0
dc.w 43
dc.b "000001010100",0,0,0
dc.b 0
dc.w 44
dc.b "000001010101",0,0,0
dc.b 0
dc.w 45
dc.b "000001010110",0,0,0
dc.b 0
dc.w 46
dc.b "000001010111",0,0,0
dc.b 0
dc.w 47
dc.b "000001100100",0,0,0
dc.b 0
dc.w 48
dc.b "000001100101",0,0,0
dc.b 0
dc.w 49
dc.b "000001010010",0,0,0
dc.b 0
dc.w 50
dc.b "000001010011",0,0,0
dc.b 0
dc.w 51
dc.b "000000100100",0,0,0
dc.b 0
dc.w 52
dc.b "000000110111",0,0,0
dc.b 0
dc.w 53
dc.b "000000111000",0,0,0
dc.b 0
dc.w 54
dc.b "000000100111",0,0,0
dc.b 0
dc.w 55
dc.b "000000101000",0,0,0
dc.b 0
dc.w 56
dc.b "000001011000",0,0,0
dc.b 0
dc.w 57
dc.b "000001011001",0,0,0
dc.b 0
dc.w 58
dc.b "000000101011",0,0,0
dc.b 0
dc.w 59
dc.b "000000101100",0,0,0
dc.b 0
dc.w 60
dc.b "000001011010",0,0,0
dc.b 0
dc.w 61
dc.b "000001100110",0,0,0
dc.b 0
dc.w 62
dc.b "000001100111",0,0,0
dc.b 0
dc.w 63
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
bmakeupcodes:
dc.b "0000001111",0,0,0,0,0
dc.b 0
dc.w 64
dc.b "000011001000",0,0,0
dc.b 0
dc.w 128
dc.b "000011001001",0,0,0
dc.b 0
dc.w 192
dc.b "000001011011",0,0,0
dc.b 0
dc.w 256
dc.b "000000110011",0,0,0
dc.b 0
dc.w 320
dc.b "000000110100",0,0,0
dc.b 0
dc.w 384
dc.b "000000110101",0,0,0
dc.b 0
dc.w 448
dc.b "0000001101100",0,0
dc.b 0
dc.w 512
dc.b "0000001101101",0,0
dc.b 0
dc.w 576
dc.b "0000001001010",0,0
dc.b 0
dc.w 640
dc.b "0000001001011",0,0
dc.b 0
dc.w 704
dc.b "0000001001100",0,0
dc.b 0
dc.w 768
dc.b "0000001001101",0,0
dc.b 0
dc.w 832
dc.b "0000001110010",0,0
dc.b 0
dc.w 896
dc.b "0000001110011",0,0
dc.b 0
dc.w 960
dc.b "0000001110100",0,0
dc.b 0
dc.w 1024
dc.b "0000001110101",0,0
dc.b 0
dc.w 1088
dc.b "0000001110110",0,0
dc.b 0
dc.w 1152
dc.b "0000001110111",0,0
dc.b 0
dc.w 1216
dc.b "0000001010010",0,0
dc.b 0
dc.w 1280
dc.b "0000001010011",0,0
dc.b 0
dc.w 1344
dc.b "0000001010100",0,0
dc.b 0
dc.w 1408
dc.b "0000001010101",0,0
dc.b 0
dc.w 1472
dc.b "0000001011010",0,0
dc.b 0
dc.w 1536
dc.b "0000001011011",0,0
dc.b 0
dc.w 1600
dc.b "0000001100100",0,0
dc.b 0
dc.w 1664
dc.b "0000001100101",0,0
dc.b 0
dc.w 1728
dc.b "00000001000",0,0,0,0
dc.b 0
dc.w 1792
dc.b "00000001100",0,0,0,0
dc.b 0
dc.w 1856
dc.b "00000001101",0,0,0,0
dc.b 0
dc.w 1920
dc.b "000000010010",0,0,0
dc.b 0
dc.w 1984
dc.b "000000010011",0,0,0
dc.b 0
dc.w 2048
dc.b "000000010100",0,0,0
dc.b 0
dc.w 2112
dc.b "000000010101",0,0,0
dc.b 0
dc.w 2176
dc.b "000000010110",0,0,0
dc.b 0
dc.w 2240
dc.b "000000010111",0,0,0
dc.b 0
dc.w 2304
dc.b "000000011100",0,0,0
dc.b 0
dc.w 2368
dc.b "000000011101",0,0,0
dc.b 0
dc.w 2432
dc.b "000000011110",0,0,0
dc.b 0
dc.w 2496
dc.b "000000011111",0,0,0
dc.b 0
dc.w 2560
dc.b "000000000001",0,0,0
dc.b 0
dc.w 0 ;EOL
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0
dc.w 0
special:
dc.w 2
dc.l spcl1,spcl2
vers: dc.b "$VER: "
name: dc.b "TIFF v2.0.6",0
spcl1: dc.b "Picture Window",0
spcl2: dc.b "Object",0
typelen: dc.b 0,0,0,1,2,3 ;shift count
pctypetbl: dc.b PC_BW,PC_BW,PC_RGB,PC_PALET,PC_BW
**********************************************************************
**********************************************************************
SECTION TIFF,BSS,PUBLIC
temp: ds.l 1
temp2: ds.l 1
picptr: ds.l 1
pptr: ds.l 1
pic: ds.w pc_Sizeof/2
object: ds.w ob_SizeOf/2
compression: ds.w 1
byteorder: ds.w 1
striplength: ds.l 1
bps: ds.w 1
sbctype: ds.w 1
sbc: ds.l 1
photom: ds.w 1
planar: ds.w 1
predictor: ds.w 1
resunits: ds.w 1
sppixel: ds.w 1
xres: ds.w 1
yres: ds.w 1
picture: ds.l 1
picoffset: ds.l 1
piclength: ds.l 1
tagcount: ds.w 1
tagid: ds.w 1
tagtype: ds.w 1
taglength: ds.l 1
tagvalue: ds.l 1
work: ds.l 4
bytecount: ds.l 1
pixcount: ds.w 1
pixpos: ds.w 1
saved1: ds.l 1
savea0: ds.l 1
oddtest: ds.l 1
rowcount: ds.l 1
rps: ds.l 1
hcount: ds.w 1
plnlen: ds.l 1
apos1: ds.l 1
apos2: ds.l 1
bitcount: ds.w 1
plncnt: ds.w 1
picptrsave: ds.l 1
lastval: ds.l 1
picptr2: ds.l 1
picptrsave2: ds.l 1
palcount: ds.l 1
palsize: ds.l 1
palptr: ds.l 1
cmapoffset: ds.l 1
spsave: ds.l 1
flag: ds.w 1
prefix: ds.l 1
suffix: ds.l 1
outcode: ds.l 1
tagskip: ds.l 1
******************************* CHANGES ********************************
;
; version 2.0.6
;
; - added a version string
;
; - fixed some bugs related to exiting on an error condition (errrts)
;
;
; version 2.0.5
;
; - fixed bug when importing a PALETTE tiff image: the get info routine
; would store the 3 times total number of colors in the cmap.
;
; - fixed bug when tiff image had multiple rows per strip
;
; - added kludge for ADPro files with <20 DPI it puts it up to 75
;
;
; version 2.0.4 (shipped w/ PageStream2.1 12/10/90)
;
; - fixed bug in PackBits de-compression routine that caused
; the de-compression to run on past it's boundries.
; (which in turn caused system problems w/ NewShell & IconX)
;
;
; version 2.0.3 (uploaded 11/16/90)
;
; - increased speed of LZW de-compression
;
; - clean up the code to decrease size.
; (b&w uses the same stuff as multiplane now)
;
;
; version 2.0.2 (uploaded 9/25/90)
;
; - bug fix: now no longer assumes that the StripByteCount is the
; same data type as the StripOffset (indirectly assumed)
;
; - added support for packbits compressed multiplane images
; (grey scale, rgb color, and palette color)
;
;
; version 2.0.1
;
; - released with PageStream 2.0
;
; - MAJOR UPDATE: now imports most any tiff file, b&w, grey scale,
; rgb, palette, ccitt compressed, packbits compressed, lzw
; compressed, and horizontally differenced lzw compressed.
;
;
; version 2.0.0
;
; - initial release (same as 1.8 version)