4 #include <exec/memory.h>
5 #include <libraries/iffparse.h>
6 #include <intuition/intuition.h>
8 #include <proto/exec.h>
9 #include <proto/graphics.h>
10 #include <proto/iffparse.h>
12 extern struct Library
* IFFParseBase
;
13 extern struct GfxBase
* GfxBase
;
15 static UBYTE Buffer
[1024], * ptr
;
20 int GetByte (struct IFFHandle
* iff
)
24 Fill
= ReadChunkBytes (iff
, Buffer
, sizeof (Buffer
));
37 int ReadRow (struct IFFHandle
* iff
,
39 ULONG Width
, UWORD Depth
, BOOL Compression
, BOOL masking
)
44 Width
= (Width
+ 7) / 8;
46 for (i
=0; i
<Depth
; i
++)
50 for (x
=0; x
<Width
; x
++)
51 planes
[i
][x
] = GetByte (iff
);
64 planes
[i
][x
++] = GetByte (iff
);
81 int ReadILBM (struct IFFHandle
* iff
,
82 struct Window
* window
, ULONG Width
, ULONG Height
, UWORD Depth
,
83 BOOL Compression
, BOOL masking
)
85 struct RastPort
* rp
= window
->RPort
;
86 BYTE
* planes
[MAX_PLANES
];
87 int t
,x
,bit
,byte
,row
,pen
= 0,lastpen
;
89 printf ("ReadILBM iff=%p win=%p Size=%ldx%ld Depth=%d %s%s\n",
90 iff
, window
, (long)Width
, (long)Height
, Depth
,
95 planes
[0] = AllocMem (Width
*Depth
+ ((masking
) ? Width
: 0), MEMF_ANY
);
100 for (t
=1; t
<Depth
; t
++)
101 planes
[t
] = planes
[t
-1] + Width
;
104 planes
[t
] = planes
[t
-1] + Width
;
106 for ( ; t
<MAX_PLANES
; t
++)
109 for (row
=0; row
<Height
; row
++)
111 if (!ReadRow (iff
, planes
, Width
, Depth
, Compression
, masking
))
113 FreeMem (planes
[0], Width
*Depth
+ ((masking
) ? Width
: 0));
117 /* printf ("row %d, %08lx\n", row, *(ULONG*)planes[0]); */
123 for (x
=0; x
<Width
; x
++)
125 bit
= 0x80 >> (x
& 7);
128 for (pen
=t
=0; t
<Depth
; t
++)
129 if (planes
[t
][byte
] & bit
)
135 /* SetAPen (rp, pen);
136 WritePixel (rp, x, row); */
140 SetAPen (rp
, lastpen
);
147 Draw (rp
, Width
, row
);