BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
ilbmifflib.c File Reference
#include "blitzlib.h"
#include <graphics/gfx.h>
#include <datatypes/pictureclass.h>

Data Structures

struct  iffstuff

Macros

#define IFFJSR(tok, valuep, arg)
#define LOBYTE(w)

Functions

void ilbminit (void)
void ilbmgetbyte (void)
void ilbmbitmap (void)
void doilbminfo (void)
void doilbmwidth (void)
void doilbmheight (void)
void doilbmdepth (void)
void doilbmviewmode (void)
void _decodeilbm (void)
static BB_BOOL ilbminit_ (const char *name)
static BB_BOOL ilbminit_c (const char *name)
 ilbminit (+1): open an ILBM file and read its BMHD into iffstuff.
static ULONG getme (ULONG byte, struct iffstuff *st)
static ULONG getbyte (ULONG byte, struct iffstuff *st)
static ULONG ilbmgetbyte_c (ULONG byte, struct iffstuff *st)
 ilbmgetbyte (+2): the next byte of the BODY, ByteRun1 decoded (for lib 154).
static void ilbmbitmap_c (ULONG value, const char *name, struct BitMap *bm)
 ilbmbitmap (+3): load an ILBM file into a BitMap (for libs 158, 160).
static BB_BOOL doilbminfo_c (const char *name)
 ILBMInfo Filename$: read the size, depth and view mode of an ILBM file (for ILBMWidth, ILBMHeight, ILBMDepth, ILBMViewMode); also a function.
 BLITZ_ALIAS (doilbminfo, doilbminfo_c)
static UWORD ilbmwidth_c (void)
 ILBMWidth: the width in pixels of the last ILBMInfo (ilbminit).
static UWORD ilbmheight_c (void)
 ILBMHeight: the height of the last ILBMInfo (ilbminit).
static UWORD ilbmdepth_c (void)
 ILBMDepth: the number of planes of the last ILBMInfo (ilbminit).
 BLITZ_ALIAS (doilbmwidth, ilbmwidth_c)
 BLITZ_ALIAS (doilbmheight, ilbmheight_c)
 BLITZ_ALIAS (doilbmdepth, ilbmdepth_c)
static ULONG ilbmviewmode_c (void)
 ILBMViewMode: the view mode of the last ILBMInfo (ilbminit): $8000 HIRES, 4 LACE.
 BLITZ_ALIAS (doilbmviewmode, ilbmviewmode_c)
static ULONG padded (const UBYTE *data, ULONG len)
static const UBYTE * unpackrow (const UBYTE *src, UBYTE *dst, LONG left, UWORD keep)
static const UBYTE * copyrow (const UBYTE *src, UBYTE *dst, UWORD len, UWORD keep)
static void decodeilbm_c (const ULONG *mem)
 DecodeILBM Bitmap#,MemoryLocation: decode an ILBM file in memory into a bitmap.
 BLITZ_ALIAS (_decodeilbm, decodeilbm_c)

Variables

struct iffstuff iffstuff
static UWORD ilbmvmode
static UBYTE ilbmnofile
static const char mess1 [] = "Can't Open File"
static const char mess2 [] = "Can't Read File"
static const char mess3 [] = "Can't Find IFF 'BODY'"
static const char mess4 [] = "Can't Find IFF 'BMHD'"
UBYTE * ilbm_a0

Macro Definition Documentation

◆ IFFJSR

#define IFFJSR ( tok,
valuep,
arg )
Value:
BLITZ_ALIBJSR_CCR_D0A0(tok, "eq", valuep, arg)
#define BLITZ_ALIBJSR_CCR_D0A0(tok, cc, d0p, a0v)
Definition blitzlib.h:722
Definition cliargslib.c:38

◆ LOBYTE

#define LOBYTE ( w)
Value:
(((UBYTE *)&(w))[1])
struct TagItem w
Definition asllib.c:192

Function Documentation

◆ _decodeilbm()

void _decodeilbm ( void )

◆ BLITZ_ALIAS() [1/6]

BLITZ_ALIAS ( _decodeilbm ,
decodeilbm_c  )

◆ BLITZ_ALIAS() [2/6]

BLITZ_ALIAS ( doilbmdepth ,
ilbmdepth_c  )

◆ BLITZ_ALIAS() [3/6]

BLITZ_ALIAS ( doilbmheight ,
ilbmheight_c  )

◆ BLITZ_ALIAS() [4/6]

BLITZ_ALIAS ( doilbminfo ,
doilbminfo_c  )

◆ BLITZ_ALIAS() [5/6]

BLITZ_ALIAS ( doilbmviewmode ,
ilbmviewmode_c  )

◆ BLITZ_ALIAS() [6/6]

BLITZ_ALIAS ( doilbmwidth ,
ilbmwidth_c  )

◆ copyrow()

const UBYTE * copyrow ( const UBYTE * src,
UBYTE * dst,
UWORD len,
UWORD keep )
static

◆ decodeilbm_c()

void decodeilbm_c ( const ULONG * mem)
static

DecodeILBM Bitmap#,MemoryLocation: decode an ILBM file in memory into a bitmap.

Finds BMHD and BODY in the FORM ILBM; ByteRun1 or uncompressed rows (copied as words). The bitmap object comes in a3 (!libs {bitmaplib,$1380}). Errors: "Can't Find IFF 'BMHD'" (no FORM/ILBM/BMHD), "Can't Find IFF 'BODY'" (the messages in the normal code, fixed: #192). Fixed (#189): the pad byte of an odd chunk is skipped (unless it is not 0: a writer without pad bytes, the original SaveBitmap). Fixed (#190, #191): only the planes, rows and bytes per row that both the ILBM and the bitmap have are stored, a run is cut at the row end; the rest is decoded and dropped (the original wrote all planes, rows and bytes of the ILBM, and a run over the row end into the next row).

Parameters
memd1: the address of the FORM ILBM

◆ doilbmdepth()

void doilbmdepth ( void )

◆ doilbmheight()

void doilbmheight ( void )

◆ doilbminfo()

void doilbminfo ( void )

◆ doilbminfo_c()

BB_BOOL doilbminfo_c ( const char * name)
static

ILBMInfo Filename$: read the size, depth and view mode of an ILBM file (for ILBMWidth, ILBMHeight, ILBMDepth, ILBMViewMode); also a function.

View mode: pageWidth >= 480 gives $8000 (HIRES), pageHeight >= 300 |4 (LACE). Fixed (#186): iffclose closes only an open file (the original: dos Close of 0 for a file that could not be opened).

Parameters
named0: the file name
Returns
d0: BB_TRUE ok, BB_FALSE no file / no BMHD

◆ doilbmviewmode()

void doilbmviewmode ( void )

◆ doilbmwidth()

void doilbmwidth ( void )

◆ getbyte()

ULONG getbyte ( ULONG byte,
struct iffstuff * st )
static

◆ getme()

ULONG getme ( ULONG byte,
struct iffstuff * st )
static

◆ ilbmbitmap()

void ilbmbitmap ( void )

◆ ilbmbitmap_c()

void ilbmbitmap_c ( ULONG value,
const char * name,
struct BitMap * bm )
static

ilbmbitmap (+3): load an ILBM file into a BitMap (for libs 158, 160).

Reads row after row, plane after plane, width-in-words*2 bytes each, and stores what fits into BytesPerRow/Depth/Rows; closes the file. Errors: "Can't Open File", "Can't Find IFF 'BMHD'" (fixed, #187: the original ignored a failed ilbminit and searched "BODY" in what was left in iffiolib's buffer), "Can't Find IFF 'BODY'" (the messages in the normal code, fixed: #192; the file closed first, fixed: #1053, the original left it open); "Can't Read File" from the byte reader (the file closed first, fixed: #1065). Fixed (#188): the depth test is on the byte Depth (the original: the word over Flags and Depth).

Parameters
valued0: the start value of the byte reader
namea0: the file name
bma1: the BitMap; a0 = iffstuff afterwards

◆ ilbmdepth_c()

UWORD ilbmdepth_c ( void )
static

ILBMDepth: the number of planes of the last ILBMInfo (ilbminit).

Returns
d0.w: the depth (the upper word of d0 stays)

◆ ilbmgetbyte()

void ilbmgetbyte ( void )

◆ ilbmgetbyte_c()

ULONG ilbmgetbyte_c ( ULONG byte,
struct iffstuff * st )
static

ilbmgetbyte (+2): the next byte of the BODY, ByteRun1 decoded (for lib 154).

Errors: "Can't Read File" at the end of the data (the message in the normal code, fixed: #192; the file closed first, fixed: #1065, the original left it open).

Parameters
byted0: the previous byte (returned again inside a repeat run)
sta0: iffstuff (from ilbminit)
Returns
d0: the byte in the low byte

◆ ilbmheight_c()

UWORD ilbmheight_c ( void )
static

ILBMHeight: the height of the last ILBMInfo (ilbminit).

Returns
d0.w: the height (the upper word of d0 stays)

◆ ilbminit()

void ilbminit ( void )

◆ ilbminit_()

BB_BOOL ilbminit_ ( const char * name)
static

◆ ilbminit_c()

BB_BOOL ilbminit_c ( const char * name)
static

ilbminit (+1): open an ILBM file and read its BMHD into iffstuff.

For animlib and lib 154. The file stays open. CCR: tst.l d0 (Z = failed).

Parameters
namea0: the file name
Returns
d0: BB_TRUE ok, BB_FALSE no file / no BMHD; a0 = iffstuff, on failure the file name (the original leaves dos.library's a0)

◆ ilbmviewmode_c()

ULONG ilbmviewmode_c ( void )
static

ILBMViewMode: the view mode of the last ILBMInfo (ilbminit): $8000 HIRES, 4 LACE.

Returns
d0: the view mode (a long)

◆ ilbmwidth_c()

UWORD ilbmwidth_c ( void )
static

ILBMWidth: the width in pixels of the last ILBMInfo (ilbminit).

Returns
d0.w: the width (the upper word of d0 stays, not a bug: a word function)

◆ padded()

ULONG padded ( const UBYTE * data,
ULONG len )
static

◆ unpackrow()

const UBYTE * unpackrow ( const UBYTE * src,
UBYTE * dst,
LONG left,
UWORD keep )
static

Variable Documentation

◆ iffstuff

struct iffstuff iffstuff

◆ ilbm_a0

UBYTE* ilbm_a0

◆ ilbmnofile

UBYTE ilbmnofile
static

◆ ilbmvmode

UWORD ilbmvmode
static

◆ mess1

const char mess1[] = "Can't Open File"
static

◆ mess2

const char mess2[] = "Can't Read File"
static

◆ mess3

const char mess3[] = "Can't Find IFF 'BODY'"
static

◆ mess4

const char mess4[] = "Can't Find IFF 'BMHD'"
static