home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
fish
/
libraries
/
ilbm
/
includes
/
iff.i
next >
Wrap
Text File
|
1991-02-15
|
14KB
|
487 lines
;************************************************************************
; IFF.i defs for IFF-85 Interchange Format Files - ILBM library. 6/9/89
;
; Original C includes by Jerry Morrison and Steve Shaw, Electronic Arts.
; Assembly include file by Jeff Glatt, dissidents. Some structures have been
; modified from the original EA code such that they are not compatible.
; This software is in the public domain.
;
; Set your editor's TAB width to 3 chars.
;************************************************************************
;********************* LIB VECTOR OFFSETS (LVO) **************************
_LVOLoadIFFToWindow equ -30
_LVOLoadILBM equ -36
_LVOLoadIFF equ -42
_LVOGetCMAP equ -48
_LVOGetBODY equ -54
_LVOUnPackRow equ -60
_LVOOpenRIFF equ -66
_LVOOpenRGroup equ -72
_LVOFileLength equ -78
_LVOGetPChunkHdr equ -84
_LVOGetF1ChunkHdr equ -90
_LVOGetFChunkHdr equ -96
_LVOGetChunkHdr equ -102
_LVOSkipFwd equ -108
_LVOIFFReadBytes equ -114
_LVOCloseRGroup equ -120
_LVOHandleCCRT equ -126
_LVOHandleCRNG equ -132
_LVOHandleCAMG equ -138
_LVOCopyILBMProp equ -144
_LVOSaveWindowToIFF equ -150
_LVOSaveILBM equ -156
_LVOIFFWriteBytes equ -162
_LVOPutBODY equ -168
_LVOPackRow equ -174
_LVOPutCMAP equ -180
_LVOOpenWIFF equ -186
_LVOOpenWGroup equ -192
_LVOStartWGroup equ -198
_LVOPutCkHdr equ -204
_LVOPutCk equ -210
_LVOPutCkEnd equ -216
_LVOEndWGroup equ -222
_LVOCloseWGroup equ -228
_LVOInitBMHdr equ -234
_LVOGetIFFPMsg equ -240
_LVOSearchPROP equ -246
_LVOGetPROPStruct equ -252
_LVOFreePROPStruct equ -258
_LVOSaveANIM equ -264
_LVODecodeVKPlane equ -270
_LVOMakeYTable equ -276
_LVODecompDLTA equ -282
_LVOBlankPointer equ -288
_LVOScaleImage equ -294
_LVOSetupBitmap equ -300
_LVODecompBODY equ -306
;=========================================================================
;The IFF Group IDs (LIST, FORM, PROP, & CAT) are followed by a subtype ID
;that identifies what kind of chunks will follow (i.e. ILBM, SMUS, 8SVX...).
;"FORM type XXXX", "LIST of FORM type XXXX", "PROPerties associated
;with FORM type XXXX", or "conCATenation of XXXX".
;
;ChunkID dc.b [4 ascii letters] ;also the Group ID in the master Context
;ChunkSize dc.l [number of subsequent data bytes, including subID's 4 bytes]
;SubID dc.b [4 ascii letters]
;
; Every IFF file should start with the above Group header (for example):
;ChunkID dc.b 'FORM'
;ChunkSize dc.l [the number of bytes following this LONG]
;SubID dc.b 'ILBM' ;this is an IFF picture then
;
;The remaining chunks in the file will be those that are expected for that
;type of file. (i.e. ILBMs have BMHD, CMAP, CAMG, etc chunks) A chunk
;consists of a 4 byte ID, a ULONG indicating the number of data bytes in the
;chunk, and then those data bytes.
;
; Pass chunkSize = UNKNOWN to Writer routines to mean "compute the size" after
; all the data has been written and the context is closed.
UNKNOWN equ $80000001
;Address Offsets for a chunk header.
ChunkID equ 0
ChunkSize equ 4
ChunkData equ 8
sizeofChunkHeader equ 12
;Address Offsets for a group header
GroupID equ 0
GroupSize equ 4
SubID equ 8
GroupData equ 12
sizeofGroupHeader equ 16
;This macro rounds up the 32 bit value in a data register to an even number.
WordAlign MACRO
Bclr.l #0,\1
beq.s _even
addq.l #2,\1
_even:
ENDM
;This macro computes the total "physical size" of a padded chunk from
;its "data size" or "logical size" which is contained in a data register.
; ChunkPSize d0
ChunkPSize MACRO
addq.l #sizeofChunkHeader,\1
Bclr.l #0,\1
beq.s _Even
addq.l #2,\1
_Even:
ENDM
;Standard group IDs. A chunk with one of these IDs contains a
;SubTypeID followed by zero or more chunks.
ID_FORM equ 'FORM'
ID_PROP equ 'PROP'
ID_LIST equ 'LIST'
ID_CAT equ 'CAT '
ID_FILLER equ ' '
;SubTypeIDs
ID_ILBM equ 'ILBM'
ID_ANIM equ 'ANIM'
;ILBM Chunk IDs
ID_BMHD equ 'BMHD'
ID_CMAP equ 'CMAP'
ID_GRAB equ 'GRAB'
ID_DEST equ 'DEST'
ID_SPRT equ 'SPRT'
ID_CAMG equ 'CAMG'
ID_BODY equ 'BODY'
ID_CRNG equ 'CRNG'
ID_CCRT equ 'CCRT'
;ANIM Chunk IDs
ID_DLTA equ 'DLTA'
ID_ANHD equ 'ANHD'
ID_ANFR equ 'ANFR'
ID_MAHD equ 'MAHD'
ID_MFHD equ 'MFHD'
ID_CM16 equ 'CM16'
ID_ATXT equ 'ATXT'
ID_PTXT equ 'PTXT'
sizeofID equ 4
;=============IFFP Status code return from the Lib Functions================
; A LONG returned in d0, because it must be the same size as a 4 byte ascii,
; chunkID (as returned by GetChunkHdr for example).
; Note that the error codes below are not legal IFF IDs because they are not
; standard ascii chars. If a routine ever returns a LONG that is negative,
; then this constitutes an IFFP error code, not an IFF ID.
; Always check IFFP error codes (bmi toError). Don't press on after an error!
; These routines try to have no side effects in the error case, except
; partial I/O is sometimes unavoidable.
IFF_OKAY equ 0 ;Keep going...(not end of file, but we haven't found
;our requested FORM or an error yet) Note that the
;highest level routines use this to really mean that
;everything went well. (see LoadIFFToWindow)
END_MARK equ -1 ;Encountered the end of a group (i.e. FORM, LIST, etc).
;The end of the entire file if you are at the top group.
IFF_DONE equ -2 ;Returns this when it has READ enough.
;It means return thru all levels. File is Okay.
DOS_ERROR equ -3 ;AmigaDOS Read or Write error.
NOT_IFF equ -4 ;Not an IFF file.
NO_FILE equ -5 ;Tried to open file, AmigaDOS didn't find it.
CLIENT_ERROR equ -6 ;Application made invalid request, for instance, write
;a negative size chunk.
BAD_FORM equ -7 ;A read routine complains about FORM semantics
;e.g. valid IFF file, but missing a required chunk such
;as an ILBM without a BMHD chunk.
SHORT_CHUNK equ -8 ;Application asked IFFReadBytes to read more bytes than
;left in the chunk. Could be an applic. bug or bad file.
BAD_IFF equ -9 ;mal-formed IFF file. Found half a chunk? A CAT with a
;PROP in it?
IFF_NOTFOUND equ -10 ;The requested FORM not found within the IFF file
;(Did you try to find an ILBM in an SMUS file?)
IFF_NOMEM equ -11 ;Out of mem while loading file
UNKNOWN_ERROR equ -12 ;This error is unknown (i.e. not 1 of the preceding)
;The library will never return this.
;=================== BitMapHeader (BMHD Chunk) ==================
;Choice of masking technique
mskNone equ 0
mskHasMask equ 1
mskHasTransparentColor equ 2
mskLasso equ 3
;Choice of compression algorithm applied to
;each row of the source and mask planes. "cmpByteRun1" is the byte run
;encoding generated by Mac's PackBits.
cmpNone equ 0
cmpByteRun1 equ 1
;Aspect ratios: The proper fraction xAspect/yAspect represents the pixel
;aspect ratio pixel_width/pixel_height.
;For the 4 Amiga display modes:
; 320 x 200: 10/11 (these pixels are taller than they are wide)
; 320 x 400: 20/11
; 640 x 200: 5/11
; 640 x 400: 10/11
x320x200Aspect equ 10
y320x200Aspect equ 11
x320x400Aspect equ 20
y320x400Aspect equ 11
x640x200Aspect equ 5
y640x200Aspect equ 11
x640x400Aspect equ 10
y640x400Aspect equ 11
; A BitMapHeader is stored in a BMHD chunk.
; dc.w w,h ; raster width & height in pixels
; dc.w x,y ; position for this image
; dc.b nPlanes ; # source bitplanes
; dc.b masking ; masking technique
; dc.b compress ; compression algoithm
; dc.b pad1 ; UNUSED. For consistency, put 0 here
; dc.w transparentColor ; transparent "color number"
; dc.b xAspect,yAspect ; aspect ratio, a rational number x/y
; dc.w pageWidth,pageHeight ; source "page" size in pixels
BMHD_w equ 0
BMHD_h equ 2
BMHD_x equ 4
BMHD_y equ 6
BMHD_nPlanes equ 8
BMHD_masking equ 9
BMHD_compress equ 10
BMHD_pad equ 11
BMHD_color equ 12
BMHD_xAspect equ 14
BMHD_yAspect equ 15
BMHD_pageW equ 16
BMHD_pageH equ 18
sizeofBMHD equ 20 ;not counting the header ID and chunkSize
;This macro computes the number of bytes in a row, from the width in pixels.
; RowBytes d0
RowBytes MACRO
addi.w #15,\1
lsr.w #3,\1
Bclr.l #0,\1
ENDM
; ==================== ColorRegister ==========================
; A CMAP chunk is a packed array of ColorRegisters (3 bytes each).
sizeofColorRegister equ 3
;Maximum number of bitplanes in RAM. Current Amiga max w/dual playfield.
MaxAmDepth equ 6
;Maximum number of color regs in amiga colorTable
maxColorReg equ 32
;This macro is passed the number of colors to save in a data register. It
;converts that into the number of bytes in the resulting CMAP chunk (not
;counting the header and any pad byte).
sizeofCMAP MACRO
mulu.w #3,\1
ENDM
; ========================= GRAB ==============================
; A Point2D is stored in a GRAB chunk.
GRAB_x equ 0
GRAB_y equ 2
sizeofGRAB equ 4
; ========================= DestMerge ===========================
; A DestMerge is stored in a DEST chunk.
; dc.b depth ; # bitplanes in the original source
; dc.b pad1 ; UNUSED, for consistency store 0 here
; dc.w planePick ; how to scatter source bitplanes into destination
; dc.w planeOnOff ; default bitplane data for planePick
; dc.w planeMask ; selects which bitplanes to store into
DEST_depth equ 0
DEST_pad equ 1
DEST_planePick equ 2
DEST_planeOnOff equ 4
DEST_planeMask equ 6
sizeofDEST equ 8
; =========================== ANHD ==============================
;operation modes
DirectSet equ 0
_XOR equ 1
LongDelta equ 2
ShortDelta equ 3
ShortLong equ 4
ByteVertical equ 5
Juggler equ 74
;Bits values
ShortData equ 0
LongData equ 1
Set equ 0
_Xor equ 2
SeparateInfo equ 0
OneInfoList equ 4
NotRLC equ 0
RLC equ 8
Horizontal equ 0
Vertical equ 16
ShortInfo equ 0
LongInfo equ 32
; dc.b operation
; dc.b mask
; dc.w w,h
; dc.w x,y
; dc.l abstime
; dc.l reltime
; dc.b interleave
; dc.b AnhdPad0
; dc.l bits
; ds.b 16
ANHD_op equ 0
ANHD_mask equ 1
ANHD_w equ 2
ANHD_h equ 4
ANHD_x equ 6
ANHD_y equ 8
ANHD_abstime equ 10
ANHD_reltime equ 14
ANHD_interleave equ 18
ANHD_pad0 equ 19
ANHD_bits equ 20
ANHD_pad1 equ 24
sizeofANHD equ 40
;======================= Other Chunks ===========================
; Commodore Amiga ViewPort->Modes is stored in a CAMG chunk. The
; chunk's content is declared as a ULONG.
sizeofCAMG equ 4
sizeofSPRT equ 4
; ======================== CRNG ===============================
maxCycles equ 8 ;the ILBMFrame can hold 8 CRNG chunks
RNG_NORATE equ 36 ;Dpaint uses this rate to mean non-active
;pad1 dc.w 0 ;future use - store 0 here
;rate dc.w 0 ;60/sec=16384, 30/sec=8192, 1/sec=16384/60=273
;active dc.w 0 ;lo bit 0=no cycle, 1=yes; next bit 1=reverse
;low dc.b 0 ;range lower
;high dc.b 0 ;range upper
CRNG_rate equ 2
CRNG_active equ 4
CRNG_low equ 6
CRNG_high equ 7
sizeofCRNG equ 8
;===================== VECTOR STRUCTURE (16 bytes) ====================
; When using mid-level load routines, you must allocate and initialize a
; vector structure. This structure holds the addresses of whatever routines
; you would like the lib to execute while parsing an IFF file. If the vector
; address is 0, then the default lib routine is used.
;
;PROPhandler dc.l 0
;FORMhandler dc.l 0
;CHUNKhandler dc.l 0
;NonILBMhandler dc.l 0
PROPhand equ 0
FORMhand equ 4
CHUNKhand equ 8
NONILBMhand equ 12
sizeofVectors equ 16
;================ ILBMFrame structure (172 bytes) ====================
;iFlags dc.b 0 ;flags for whether BMHD, CAMG chunk found
;iUserFlags dc.b 0 ;for whether you want no title bar, mouse pointer
;iBMHD ds.b 20 ;20 byte IFF BitMap Header chunk (BHMD)
;iViewModes dc.l 0 ;CAMG chunk (contains just 1 LONG, ViewModes)
;iColorTable ds.w 32 ;a WORD for each color (32 colors MAX)
;iNumColors dc.b 0 ;number of colorTable values loaded (32 MAX)
;iCycleCnt dc.b 0 ;# of cycles for color cycling (Range = 0 to 7)
;iCRNG ds.b 8*8 ;8, 8 Byte CRNG chunks for color cycling
;iWindow dc.l 0
;iScreen dc.l 0
;iBMAP dc.l 0
;iBmSize dc.l 0
sizeofILBMFrame equ 172
iFlags equ 0
iUserFlags equ 1
iBMHD equ 2
iViewModes equ 22
iColorTable equ 26
iNumColors equ 90
iCycleCnt equ 91
iCRNG equ 92
iWindow equ 156
iScreen equ 160
iBMAP equ 164
iBmSize equ 168
;definitions for bits of iFlags field
BMHDFLAG equ 0 ;set if a BMHD chunk found in the file
CAMGFLAG equ 1 ;set if a CAMG chunk found
ANHDFLAG equ 2 ;set if an ANHD chunk found. This is for the use of your
;custom CHUNKhandler or PROPhandler.
;bit definitions for iUserFlags. These must be initialized by you.
MOUSEFLAG equ 0 ;set for no mouse pointer
SCREENFLAG equ 1 ;set for hide screen title bar
COLORFLAG equ 2 ;set for "Don't use loaded colorMap. Preserve present map."
NOSCALE equ 3 ;set for "Don't scale a lower res pic to fill a larger bitmap"
ADJUSTVIEW equ 4 ;do overscan if larger than standard Intuition view
FORCEPARSE equ 5 ;ignore IFF_DONE and force parsing to continue to end of file
ANIMFLAG equ 7 ;set if an ANIM file
;===================== A PROPList ============================
; NextFrame dc.l [the address of the next frame in list]
; Entries dc.w [the number of frames in the list]
;================== AN ILBMPropFrame ==============================
; Since the routines GetPROPStruct and SearchPROP return the data portion
; (the actual ILBMFrame of the structure), you access the fields using the
; same offsets as an ILBMFrame. The new, extended fields are at negative
; offsets to the data portion, and of course, the size is different.
; The extended fields are as follows:
;
;iNext dc.l 0 ;the Next PropFrame
;iID dc.l 0 ;the type of PROP (i.e. 'ILBM')
;iPFSize dc.w 0 ;the total size of this structure including this header
sizeofILBMProp equ sizeofILBMFrame+10
iNext equ -10
iID equ -6
iPFSize equ -2
;========36 byte Context structure (to read/write an IFF Group)===========
;parentContext dc.l 0
;UserData dc.l 0 ;For application use
;fileHandle dc.l 0
;position dc.l 0
;bound dc.l 0
;chunkID dc.b [4 ascii]
;chunkSize dc.l 0
;subID dc.b [4 ascii]
;bytesSoFar dc.l 0
; To compute the number of bytes not yet read from the current chunk, given
; a context structure, remainingBytes = chunkSize - bytesSoFar
conParent equ 0
conUserData equ 4
conFile equ 8
conPosition equ 12
conBound equ 16
conChunkID equ 20
conChunkSize equ 24
conSubID equ 28
conSoFar equ 32
sizeofContext equ 36