home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 302.lha / ILBMLib / IFF.i < prev    next >
Text File  |  1980-12-08  |  16KB  |  506 lines

  1. ;************************************************************************
  2. ; IFF.i  defs for IFF-85 Interchange Format Files - ILBM library.  6/9/89
  3. ;
  4. ; Original C includes by Jerry Morrison and Steve Shaw, Electronic Arts.
  5. ; Assembly include file by Jeff Glatt, dissidents. Some structures have been
  6. ; modified from the original EA code such that they are not compatible.
  7. ; This software is in the public domain.
  8. ;
  9. ; Set your editor's TAB width to 3 chars.
  10. ;************************************************************************
  11.  
  12.  
  13. ;********************* LIB VECTOR OFFSETS (LVO) **************************
  14. _LVOLoadIFFToWindow    equ -30
  15. _LVOLoadILBM            equ -36
  16. _LVOLoadIFF                equ -42
  17. _LVOGetCMAP                equ -48
  18. _LVOGetBODY                equ -54
  19. _LVOUnPackRow            equ -60
  20. _LVOOpenRIFF            equ -66
  21. _LVOOpenRGroup            equ -72
  22. _LVOFileLength            equ -78
  23. _LVOGetPChunkHdr        equ -84
  24. _LVOGetF1ChunkHdr        equ -90
  25. _LVOGetFChunkHdr        equ -96
  26. _LVOGetChunkHdr        equ -102
  27. _LVOSkipFwd                equ -108
  28. _LVOIFFReadBytes        equ -114
  29. _LVOCloseRGroup        equ -120
  30. _LVOHandleCCRT            equ -126
  31. _LVOHandleCRNG            equ -132
  32. _LVOHandleCAMG            equ -138
  33. _LVOCopyILBMProp        equ -144
  34. _LVOSaveWindowToIFF    equ -150
  35. _LVOSaveILBM            equ -156
  36. _LVOIFFWriteBytes        equ -162
  37. _LVOPutBODY                equ -168
  38. _LVOPackRow                equ -174
  39. _LVOPutCMAP                equ -180
  40. _LVOOpenWIFF            equ -186
  41. _LVOOpenWGroup            equ -192
  42. _LVOStartWGroup        equ -198
  43. _LVOPutCkHdr            equ -204
  44. _LVOPutCk                equ -210
  45. _LVOPutCkEnd            equ -216
  46. _LVOEndWGroup            equ -222
  47. _LVOCloseWGroup        equ -228
  48. _LVOInitBMHdr            equ -234
  49. _LVOGetIFFPMsg            equ -240
  50. _LVOSearchPROP            equ -246
  51. _LVOGetPROPStruct        equ -252
  52. _LVOFreePROPStruct    equ -258
  53. _LVOSaveANIM            equ -264
  54. _LVODecodeVKPlane        equ -270
  55. _LVOMakeYTable            equ -276
  56. _LVODecompDLTA            equ -282
  57. _LVOBlankPointer        equ -288
  58. _LVOScaleImage            equ -294
  59. _LVOSetupBitmap        equ -300
  60. _LVODecompBODY            equ -306
  61. ;_LVO            equ -312
  62. ;_LVO            equ -318
  63. ;_LVO            equ -324
  64. ;_LVO            equ -330
  65. ;_LVO            equ -336
  66. ;_LVO            equ -342
  67. ;_LVO            equ -348
  68. ;_LVO            equ -354
  69. ;_LVO            equ -360
  70. ;_LVO            equ -366
  71. ;_LVO            equ -372
  72. ;_LVO            equ -378
  73. ;_LVO            equ -384
  74. ;_LVO            equ -390
  75.  
  76. ;=========================================================================
  77. ;The IFF Group IDs (LIST, FORM, PROP, & CAT) are followed by a subtype ID
  78. ;that identifies what kind of chunks will follow (i.e. ILBM, SMUS, 8SVX...).
  79. ;"FORM type XXXX", "LIST of FORM type XXXX", "PROPerties associated
  80. ;with FORM type XXXX", or "conCATenation of XXXX".
  81. ;
  82. ;ChunkID        dc.b [4 ascii letters]    ;also the Group ID in the master Context
  83. ;ChunkSize    dc.l [number of subsequent data bytes, including subID's 4 bytes]
  84. ;SubID        dc.b [4 ascii letters]
  85. ;
  86. ; Every IFF file should start with the above Group header (for example:
  87. ;ChunkID        dc.b 'FORM'
  88. ;ChunkSize    dc.l [the number of bytes following this LONG]
  89. ;SubID        dc.b 'ILBM'        ;this is an IFF picture then
  90. ;
  91. ;The remaining chunks in the file will be those that are expected for that
  92. ;type of file. (i.e. ILBMs have BMHD, CMAP, CAMG, etc chunks) A chunk
  93. ;consists of a 4 byte ID, a ULONG indicating the number of data bytes in the
  94. ;chunk, and then those data bytes.
  95. ;
  96. ; Pass chunkSize = UNKNOWN to save routines to mean "compute the size" after
  97. ; all the data has been written and the context is closed.
  98.  
  99. UNKNOWN equ $80000001
  100.  
  101. ;Address Offsets for a chunk header.
  102. ChunkID        equ    0
  103. ChunkSize    equ    4
  104. ChunkData    equ    8
  105. sizeofChunkHeader    equ    12
  106.  
  107. ;Address Offsets for a group header
  108. GroupID        equ    0
  109. GroupSize    equ    4
  110. SubID            equ    8
  111. GroupData    equ    12
  112. sizeofGroupHeader    equ    16
  113.  
  114. ;This macro rounds up the 32 bit value in a data register to an even number.
  115. WordAlign MACRO
  116.     Bclr.l    #0,\1
  117.     beq.s        _even
  118.     addq.l    #2,\1
  119. _even:
  120.     ENDM
  121.  
  122. ;This macro computes the total "physical size" of a padded chunk from
  123. ;its "data size" or "logical size" which is contained in a data register.
  124. ChunkPSize MACRO
  125.     addq.l    #sizeofChunkHeader,\1
  126.     Bclr.l    #0,\1
  127.     beq.s        _Even
  128.     addq.l    #2,\1
  129. _Even:
  130.     ENDM
  131.  
  132. ;Standard group IDs.  A chunk with one of these IDs contains a
  133. ;SubTypeID followed by zero or more chunks.
  134. ID_FORM        equ    'FORM'
  135. ID_PROP        equ    'PROP'
  136. ID_LIST        equ    'LIST'
  137. ID_CAT        equ    'CAT '
  138. ID_FILLER    equ    '    '
  139.  
  140. ;SubTypeIDs
  141. ID_ILBM        equ    'ILBM'
  142. ID_ANIM        equ    'ANIM'
  143.  
  144. ;ILBM Chunk IDs
  145. ID_BMHD    equ    'BMHD'
  146. ID_CMAP    equ    'CMAP'
  147. ID_GRAB    equ    'GRAB'
  148. ID_DEST    equ    'DEST'
  149. ID_SPRT    equ    'SPRT'
  150. ID_CAMG    equ    'CAMG'
  151. ID_BODY    equ    'BODY'
  152. ID_CRNG    equ    'CRNG'
  153. ID_CCRT    equ    'CCRT'
  154.  
  155. ;ANIM Chunk IDs
  156. ID_DLTA    equ    'DLTA'
  157. ID_ANHD    equ    'ANHD'
  158.  
  159. ID_ANFR    equ    'ANFR'
  160. ID_MAHD    equ    'MAHD'
  161. ID_MFHD    equ    'MFHD'
  162. ID_CM16    equ    'CM16'
  163. ID_ATXT    equ    'ATXT'
  164. ID_PTXT    equ    'PTXT'
  165.  
  166. sizeofID    equ    4
  167.  
  168. ;=============IFFP Status code return from the Lib Functions================
  169. ; A LONG returned in d0, because it must be the same size as a 4 byte ascii,
  170. ; chunkID (as returned by GetChunkHdr for example).
  171. ; Note that the error codes below are not legal IFF IDs because they are not
  172. ; standard ascii chars. If a routine ever returns a LONG that is negative,
  173. ; then this constitutes an IFFP error code, not an IFF ID.
  174. ; Always check IFFP error codes (bmi toError). Don't press on after an error!
  175. ; These routines try to have no side effects in the error case, except
  176. ; partial I/O is sometimes unavoidable.
  177.  
  178. IFF_OKAY         equ  0  ;Keep going...(not end of file, but we haven't found
  179.                            ;our requested FORM or an error yet) Note that the
  180.                            ;highest level routines use this to really mean that
  181.                            ;everything went well. (see LoadIFFToWindow)
  182. END_MARK         equ -1  ;Encountered the end of a group (i.e. FORM, LIST, etc).
  183.                            ;The end of the entire file if you are at the top group.
  184. IFF_DONE         equ -2  ;Returns this when it has READ enough.
  185.                      ;It means return thru all levels. File is Okay.
  186. DOS_ERROR     equ -3  ;AmigaDOS Read or Write error.
  187. NOT_IFF         equ -4  ;Not an IFF file.
  188. NO_FILE         equ -5  ;Tried to open file, AmigaDOS didn't find it.
  189. CLIENT_ERROR equ -6  ;Application made invalid request, for instance, write
  190.                            ;a negative size chunk. Also, out of memory error.
  191. BAD_FORM         equ -7  ;A read routine complains about FORM semantics
  192.                            ;e.g. valid IFF file, but missing a required chunk such
  193.                            ;as an ILBM without a BMHD chunk.
  194. SHORT_CHUNK     equ -8  ;Application asked IFFReadBytes to read more bytes than
  195.                            ;left in the chunk. Could be an applic. bug or bad file.
  196. BAD_IFF         equ -9  ;mal-formed IFF file. Found half a chunk? A CAT with a
  197.                            ;PROP in it?
  198. IFF_NOTFOUND equ -10    ;The requested FORM not found within the IFF file
  199.                             ;(Did you try to find an ILBM in an SMUS file?)
  200. UNKNOWN_ERROR    equ -11    ;This error is unknown (i.e. not 1 of the preceding)
  201.                                 ;The library will never return this.
  202.  
  203. ; =================== BitMapHeader (BMHD Chunk) ================== 
  204.  
  205. ;Choice of masking technique
  206. mskNone                        equ    0
  207. mskHasMask                    equ    1
  208. mskHasTransparentColor    equ    2
  209. mskLasso                        equ    3
  210.  
  211. ;Choice of compression algorithm applied to
  212. ;each row of the source and mask planes. "cmpByteRun1" is the byte run
  213. ;encoding generated by Mac's PackBits.
  214. cmpNone        equ    0
  215. cmpByteRun1    equ    1
  216.  
  217. ;Aspect ratios: The proper fraction xAspect/yAspect represents the pixel
  218. ;aspect ratio pixel_width/pixel_height.
  219.  
  220. ;For the 4 Amiga display modes:
  221. ;      320 x 200: 10/11  (these pixels are taller than they are wide)
  222. ;      320 x 400: 20/11
  223. ;      640 x 200:  5/11
  224. ;      640 x 400: 10/11
  225. x320x200Aspect equ 10
  226. y320x200Aspect equ 11
  227. x320x400Aspect equ 20
  228. y320x400Aspect equ 11
  229. x640x200Aspect equ 5
  230. y640x200Aspect equ 11
  231. x640x400Aspect equ 10
  232. y640x400Aspect equ 11
  233.  
  234. ; A BitMapHeader is stored in a BMHD chunk.
  235. ;    dc.w w,h                            ; raster width & height in pixels
  236. ;    dc.w x,y                            ; position for this image
  237. ;    dc.b nPlanes                    ; # source bitplanes
  238. ;    dc.b masking                    ; masking technique
  239. ;    dc.b compress                    ; compression algoithm 
  240. ;    dc.b pad1                        ; UNUSED.  For consistency, put 0 here
  241. ;    dc.w transparentColor        ; transparent "color number"
  242. ;    dc.b xAspect,yAspect            ; aspect ratio, a rational number x/y
  243. ;    dc.w pageWidth,pageHeight    ; source "page" size in pixels
  244.  
  245. BMHD_w            equ    0
  246. BMHD_h            equ    2
  247. BMHD_x            equ    4
  248. BMHD_y            equ    6
  249. BMHD_nPlanes    equ    8
  250. BMHD_masking    equ    9
  251. BMHD_compress    equ    10
  252. BMHD_pad            equ    11
  253. BMHD_color        equ    12
  254. BMHD_xAspect    equ    14
  255. BMHD_yAspect    equ    15
  256. BMHD_pageW        equ    16
  257. BMHD_pageH        equ    18
  258.  
  259. sizeofBMHD        equ    20 ;not counting the header ID and chunkSize
  260.  
  261. ;This macro computes the number of bytes in a row, from the width in pixels.
  262. RowBytes MACRO
  263.     addi.w    #15,\1
  264.     lsr.w        #3,\1
  265.     Bclr.l    #0,\1
  266.     ENDM
  267.  
  268. ; ==================== ColorRegister ========================== 
  269. ; A CMAP chunk is a packed array of ColorRegisters (3 bytes each).
  270.  
  271. sizeofColorRegister equ 3
  272.  
  273. ;Maximum number of bitplanes in RAM. Current Amiga max w/dual playfield.
  274. MaxAmDepth  equ 6
  275.  
  276. ;Maximum number of color regs in amiga colorTable
  277. maxColorReg equ 32
  278.  
  279. ;This macro is passed the number of colors to save in a data register. It
  280. ;converts that into the number of bytes in the resulting CMAP chunk (not
  281. ;counting the header and any pad byte).
  282. sizeofCMAP MACRO
  283.     mulu.w    #3,\1
  284.     ENDM
  285.  
  286. ; ========================= GRAB ==============================
  287. ; A Point2D is stored in a GRAB chunk.
  288.  
  289. GRAB_x    equ    0
  290. GRAB_y    equ    2
  291.  
  292. sizeofGRAB    equ    4
  293.  
  294. ; ========================= DestMerge ===========================
  295. ; A DestMerge is stored in a DEST chunk.
  296.  
  297. ;    dc.b depth            ; # bitplanes in the original source
  298. ;    dc.b pad1            ; UNUSED, for consistency store 0 here
  299. ;    dc.w planePick    ; how to scatter source bitplanes into destination
  300. ;    dc.w planeOnOff    ; default bitplane data for planePick
  301. ;    dc.w planeMask    ; selects which bitplanes to store into
  302.  
  303. DEST_depth            equ 0
  304. DEST_pad                equ 1
  305. DEST_planePick        equ 2
  306. DEST_planeOnOff    equ 4
  307. DEST_planeMask        equ 6
  308.  
  309. sizeofDEST    equ    8
  310.  
  311. ; =========================== ANHD ==============================
  312.  
  313. ;operation modes
  314. DirectSet        equ 0
  315. _XOR                equ 1
  316. LongDelta        equ 2
  317. ShortDelta        equ 3
  318. ShortLong        equ 4
  319. ByteVertical    equ 5
  320. Juggler            equ 74
  321.  
  322. ;Bits values
  323. ShortData        equ 0
  324. LongData            equ 1
  325. Set                equ 0
  326. _Xor                equ 2
  327. SeparateInfo    equ 0
  328. OneInfoList        equ 4
  329. NotRLC            equ 0
  330. RLC                equ 8
  331. Horizontal        equ 0
  332. Vertical            equ 16
  333. ShortInfo        equ 0
  334. LongInfo            equ 32
  335.  
  336. ;    dc.b operation
  337. ;    dc.b mask
  338. ;    dc.w w,h
  339. ;    dc.w x,y
  340. ;    dc.l abstime
  341. ;    dc.l reltime
  342. ;    dc.b interleave
  343. ;    dc.b AnhdPad0
  344. ;    dc.l bits
  345. ;    ds.b 16
  346.  
  347. ANHD_op            equ    0
  348. ANHD_mask        equ    1
  349. ANHD_w            equ    2
  350. ANHD_h            equ    4
  351. ANHD_x            equ    6
  352. ANHD_y            equ    8
  353. ANHD_abstime    equ    10
  354. ANHD_reltime    equ    14
  355. ANHD_interleave    equ    18
  356. ANHD_pad0        equ    19
  357. ANHD_bits        equ    20
  358. ANHD_pad1        equ    24
  359.  
  360. sizeofANHD        equ    40
  361.  
  362. ;======================= Other Chunks ===========================
  363. ; Commodore Amiga ViewPort->Modes is stored in a CAMG chunk. The
  364. ; chunk's content is declared as a ULONG.
  365.  
  366. sizeofCAMG    equ    4
  367. sizeofSPRT    equ    4
  368.  
  369. ; ======================== CRNG ===============================
  370.  
  371. maxCycles  equ  8        ;the ILBMFrame can hold 8 CRNG chunks
  372. RNG_NORATE equ  36    ;Dpaint uses this rate to mean non-active
  373.  
  374. ;pad1   dc.w  0   ;future use - store 0 here
  375. ;rate   dc.w  0   ;60/sec=16384, 30/sec=8192, 1/sec=16384/60=273
  376. ;active dc.w  0   ;lo bit 0=no cycle, 1=yes; next bit 1=reverse
  377. ;low    dc.b  0   ;range lower
  378. ;high   dc.b  0   ;range upper
  379.  
  380. CRNG_rate    equ    2
  381. CRNG_active    equ    4
  382. CRNG_low        equ    6
  383. CRNG_high    equ    7
  384.  
  385. sizeofCRNG    equ    8
  386.  
  387. ;===================== VECTOR STRUCTURE (16 bytes) ====================
  388. ; When using mid-level load routines, you must allocate and initialize a
  389. ; vector structure. This structure holds the addresses of whatever routines
  390. ; you would like the lib to execute while parsing an IFF file. If the vector
  391. ; address is 0, then the default lib routine is used.
  392. ;
  393. ;
  394. ;PROPhandler dc.l 0 ;address of routine to handle nonILBM 'PROP's or an ILBM
  395. ;                   ;PROP chunk that is "unknown" to the lib (i.e. ANHD,DEST,
  396. ;                   ;GRAB,SPRT,DLTA). If NULL, skips nonILBM PROPs.
  397. ;FORMhandler dc.l 0 ;If not NULL, replaces the lib's default 'FORM' handler.
  398. ;CHUNKhandler dc.l 0 ;Called by lib's default 'FORM' handler when it encounters
  399. ;                   ;"unknown" chunks inside an ILBM (see PROPhandler). If NULL,
  400. ;                   ;unknown chunks are skipped. If you don't use the lib's
  401. ;                   ;default 'FORM' handler, then this field is free to use.
  402. ;NonILBMhandler dc.l 0 
  403. ;                   ;Called by lib's default 'FORM' handler when it encounters
  404. ;                   ;a FORM other than ILBM (i.e. 8SVX, etc). If NULL,
  405. ;                   ;nonILBM FORMs are skipped. If you don't use the lib's
  406. ;                   ;default 'FORM' handler, then this field is free to use.
  407.  
  408. PROPhand        equ 0
  409. FORMhand        equ 4
  410. CHUNKhand    equ 8
  411. NONILBMhand    equ 12
  412.  
  413. sizeofVectors    equ    16
  414.  
  415. ;================ ILBMFrame structure (172 bytes) ====================
  416. ;iFlags            dc.b 0    ;flags for whether BMHD, CAMG chunk found
  417. ;iUserFlags        dc.b 0    ;for whether you want no title bar, mouse pointer
  418. ;iBMHD            ds.b 20   ;20 byte IFF BitMap Header chunk (BHMD)
  419. ;iViewModes        dc.l 0    ;CAMG chunk (contains just 1 LONG, ViewModes)
  420. ;iColorTable    ds.w 32   ;a WORD for each color (32 colors MAX)
  421. ;iNumColors        dc.b 0    ;number of colorTable values loaded (32 MAX)
  422. ;iCycleCnt        dc.b 0    ;# of cycles for color cycling (Range = 0 to 7)
  423. ;iCRNG            ds.b 8*8  ;8, 8 Byte CRNG chunks for color cycling
  424. ;iWindow            dc.l 0
  425. ;iScreen            dc.l 0
  426. ;iBMAP            dc.l 0
  427. ;iBmSize            dc.l 0
  428.  
  429. sizeofILBMFrame equ 172
  430.  
  431. iFlags        equ 0
  432. iUserFlags    equ 1
  433. iBMHD            equ 2
  434. iViewModes    equ 22
  435. iColorTable    equ 26
  436. iNumColors    equ 90
  437. iCycleCnt    equ 91
  438. iCRNG            equ 92
  439. iWindow        equ 156
  440. iScreen        equ 160
  441. iBMAP            equ 164
  442. iBmSize        equ 168
  443.  
  444. ;definitions for bits of iFlags field
  445. BMHDFLAG    equ 0 ;set if a BMHD chunk found in the file
  446. CAMGFLAG    equ 1 ;set if a CAMG chunk found
  447. ANHDFLAG equ 2 ;set if an ANHD chunk found. This is for the use of your
  448.                     ;custom CHUNKhandler or PROPhandler.
  449.  
  450. ;bit definitions for iUserFlags. These must be initialized by you.
  451. MOUSEFLAG    equ 0 ;set for no mouse pointer
  452. SCREENFLAG    equ 1 ;set for hide screen title bar
  453. COLORFLAG    equ 2 ;set for "Don't use loaded colorMap. Use present map."
  454.  
  455. ANIMFLAG        equ 7 ;set if an ANIM file
  456.  
  457. ;===================== A PROPList ============================
  458. ; NextFrame    dc.l [the address of the next frame in list]
  459. ; Entries    dc.w [the number of frames in the list]
  460.  
  461.  
  462. ;================== AN ILBMPropFrame ==============================
  463. ; Since the routines GetPROPStruct and SearchPROP return the data portion
  464. ; (the actual ILBMFrame of the structure), you access the fields using the
  465. ; same offsets as an ILBMFrame. The new, extended fields are at negative
  466. ; offsets to the data portion, and of course, the size is different.
  467. ; The extended fields are as follows:
  468. ;
  469. ;iNext    dc.l 0  ;the Next PropFrame
  470. ;iID        dc.l 0  ;the type of PROP (i.e. 'ILBM')
  471. ;iPFSize    dc.w 0  ;the total size of this structure including this header
  472.  
  473. sizeofILBMProp equ sizeofILBMFrame+10
  474.  
  475. iNext        equ -10
  476. iID        equ -6
  477. iPFSize    equ -2
  478.  
  479. ;========36 byte Context structure (to read/write an IFF Group)===========
  480. ;parentContext dc.l 0     ;Containing group (If NULL, then this is top level)
  481. ;UserData        dc.l 0     ;For application use
  482. ;fileHandle    dc.l 0     ;DOS fileHandle
  483. ;position      dc.l 0     ;The current logical file position.
  484. ;bound         dc.l 0     ;File-absolute context bound
  485. ;                         ;(or UNKNOWN size for save routines).
  486. ;chunkID   dc.b [4 ascii] ;Current chunk ID.
  487. ;chunkSize dc.l 0         ;Current chunk size. If UNKNOWN, this means we need
  488. ;                         ;to go back and set the size (save only).
  489. ;subID     dc.b [4 ascii] ;Group's subtype ID when reading.
  490. ;bytesSoFar    dc.l 0     ;# bytes read/written of current chunk's data.
  491.  
  492. ; To compute the number of bytes not yet read from the current chunk, given
  493. ; a context structure, remainingBytes = chunkSize - bytesSoFar
  494.  
  495. conParent        equ 0
  496. conUserData        equ 4
  497. conFile            equ 8
  498. conPosition        equ 12
  499. conBound            equ 16
  500. conChunkID        equ 20
  501. conChunkSize    equ 24
  502. conSubID            equ 28
  503. conSoFar            equ 32
  504.  
  505. sizeofContext    equ 36
  506.