BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
iffmakelib.c File Reference
#include "blitzlib.h"
#include "blitzobj.h"
#include <graphics/gfx.h>
#include <graphics/view.h>
#include <intuition/screens.h>
#include <proto/dos.h>
#include <proto/graphics.h>

Data Structures

struct  palette

Macros

#define __NOLIBBASE__
#define BUFSIZE   4096
#define SHAPEPLANES   ((sizeof bmcopy - offsetof(struct BitMap, Planes)) / sizeof(PLANEPTR))
#define DOSBase   dosbase /* for proto/dos.h */
#define ID_FORM   0x464f524d
#define ID_ILBM   0x494c424d
#define ID_BMHD   0x424d4844
#define ID_CMAP   0x434d4150
#define ID_BODY   0x424f4459

Functions

void dosavebitmap2 (void)
void dosavebitmap (void)
void dosavescreen (void)
void dosaveshape1 (void)
void dosaveshape2 (void)
void dosavepalette (void)
void bitchk (void)
void bitchk2 (void)
void scrchk (void)
void sschk1 (void)
void sschk2 (void)
static void put_l (UBYTE **p, ULONG v)
static void put_w (UBYTE **p, UWORD v)
static void makehead (const struct BitMap *bm)
static void makecolor (const struct palette *pal)
static void savearow (const UBYTE *row, const struct BitMap *bm)
static void makebody (const struct BitMap *bm)
static void fixhead (void)
static void fixbody (void)
static void savebm (const struct BitMap *bm, const char *name, const struct palette *pal, struct DosLibrary *dos)
static void dosavebitmap2_c (const struct BitMap *bm, const char *name, struct DosLibrary *dos)
 SaveBitmap BitMap#,Filename$: save a bitmap as an ILBM file without a CMAP.
 BLITZ_ALIAS (dosavebitmap2, dosavebitmap2_c)
static void dosavebitmap_c (const struct BitMap *bm, const char *name, const struct palette *pal, struct DosLibrary *dos)
 SaveBitmap BitMap#,Filename$,Palette#: save a bitmap as an ILBM file with a CMAP; also the nullsub dosavebitmap for other libraries.
static void saveshape (const struct bb_shape *shape, const char *name, const struct palette *pal, struct DosLibrary *dos)
static void dosaveshape1_c (const struct bb_shape *shape, const char *name, struct DosLibrary *dos)
 SaveShape Shape#,Filename$: save a shape as an ILBM file.
 BLITZ_ALIAS (dosaveshape1, dosaveshape1_c)
static void dosaveshape2_c (const struct bb_shape *shape, const char *name, const struct palette *pal, struct DosLibrary *dos)
 SaveShape Shape#,Filename$,Palette#: SaveShape with a CMAP of the palette (as SaveBitmap with a palette).
 BLITZ_ALIAS (dosaveshape2, dosaveshape2_c)
static void dosavepalette_c (const struct palette *pal, const char *name, struct DosLibrary *dos)
 SavePalette Palette#,Filename$: save a palette as a file with only the CMAP chunk (no FORM).
 BLITZ_ALIAS (dosavepalette, dosavepalette_c)
static ULONG makelong (UWORD v)
static void dosavescreen_c (struct Screen **scr, const char *name, struct GfxBase *gfx, struct DosLibrary *dos)
 SaveScreen Screen#,Filename$: save a screen as an ILBM file with its colours.
 BLITZ_ALIAS (dosavescreen, dosavescreen_c)
static void scrchk_c (ULONG *scr)
static void bitchk_c (UWORD *bm)
static void palchk_c (const struct palette *pal)
static void bitchk2_c (UWORD *bm, const struct palette *pal)
static void sschk1_c (UWORD *shape)
static void sschk2_c (UWORD *shape, const struct palette *pal)

Variables

static UBYTE iffbuff [BUFSIZE]
static ULONG ifflen
static ULONG bodylen
static ULONG bodyseek
static ULONG scrcols [3 *256+2]
static struct palette scrpal = { scrcols, 0 }
struct { 
   struct BitMap   bm 
   ULONG   more [6] 
} bmcopy
static UWORD usewid
static const UBYTE jeeze [4] = { 0x80, 0, 0, 0 }
static BPTR fh
static struct DosLibrary * dosbase
static const char mess2 [] = "Can't open File"
static const char mess6 [] = "Illegal Shape Depth"

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ BUFSIZE

#define BUFSIZE   4096

◆ DOSBase

#define DOSBase   dosbase /* for proto/dos.h */

◆ ID_BMHD

#define ID_BMHD   0x424d4844

◆ ID_BODY

#define ID_BODY   0x424f4459

◆ ID_CMAP

#define ID_CMAP   0x434d4150

◆ ID_FORM

#define ID_FORM   0x464f524d

◆ ID_ILBM

#define ID_ILBM   0x494c424d

◆ SHAPEPLANES

#define SHAPEPLANES   ((sizeof bmcopy - offsetof(struct BitMap, Planes)) / sizeof(PLANEPTR))

Function Documentation

◆ bitchk()

void bitchk ( void )

◆ bitchk2()

void bitchk2 ( void )

◆ bitchk2_c()

void bitchk2_c ( UWORD * bm,
const struct palette * pal )
static

◆ bitchk_c()

void bitchk_c ( UWORD * bm)
static

◆ BLITZ_ALIAS() [1/5]

BLITZ_ALIAS ( dosavebitmap2 ,
dosavebitmap2_c  )

◆ BLITZ_ALIAS() [2/5]

BLITZ_ALIAS ( dosavepalette ,
dosavepalette_c  )

◆ BLITZ_ALIAS() [3/5]

BLITZ_ALIAS ( dosavescreen ,
dosavescreen_c  )

◆ BLITZ_ALIAS() [4/5]

BLITZ_ALIAS ( dosaveshape1 ,
dosaveshape1_c  )

◆ BLITZ_ALIAS() [5/5]

BLITZ_ALIAS ( dosaveshape2 ,
dosaveshape2_c  )

◆ dosavebitmap()

void dosavebitmap ( void )

◆ dosavebitmap2()

void dosavebitmap2 ( void )

◆ dosavebitmap2_c()

void dosavebitmap2_c ( const struct BitMap * bm,
const char * name,
struct DosLibrary * dos )
static

SaveBitmap BitMap#,Filename$: save a bitmap as an ILBM file without a CMAP.

FORM/ILBM/BMHD, the ByteRun1 packed BODY (see the head comment). Amiga mode only. Errors: "Can't open File" if the file cannot be created (the message in the normal code, fixed, #185); debugger only: "Uninitialized Bitmap" (bitchk). By design (#181): the row and plane loops run at least once. Fixed (#183): savearow no longer reads the byte behind the row. Fixed (#180): the plane loop compares with the byte Depth (the original: the word over Flags and Depth).

Parameters
bma0: the BitMap (!libs {bitmaplib,$1080})
named1: the file name
dosa6: dos.library

◆ dosavebitmap_c()

void dosavebitmap_c ( const struct BitMap * bm,
const char * name,
const struct palette * pal,
struct DosLibrary * dos )
static

SaveBitmap BitMap#,Filename$,Palette#: save a bitmap as an ILBM file with a CMAP; also the nullsub dosavebitmap for other libraries.

As SaveBitmap without a palette, plus the CMAP chunk (3 bytes per colour, the top bytes of the palette's longs) when a palette is given. Errors (debugger only): also "Uninitialized Palette" (bitchk2; also for a palette of 0 colours, fixed #182: the original wrote 65536 colours over the end of the buffer). Fixed (#184): a CMAP of an odd size gets the pad byte.

Parameters
bma0: the BitMap (!libs {bitmaplib,$1080})
named1: the file name
pala1: the palette (!libs {palettelib,$1182}), for other libraries 0 = none
dosa6: dos.library

◆ dosavepalette()

void dosavepalette ( void )

◆ dosavepalette_c()

void dosavepalette_c ( const struct palette * pal,
const char * name,
struct DosLibrary * dos )
static

SavePalette Palette#,Filename$: save a palette as a file with only the CMAP chunk (no FORM).

Nothing for a palette without colours. Amiga mode only. Errors: "Can't open File" as SaveBitmap. Fixed (#184): a CMAP of an odd size gets the pad byte (the original's file ended without it).

Parameters
pala2: the palette (!libs {palettelib,$1280})
named1: the file name
dosa6: dos.library

◆ dosavescreen()

void dosavescreen ( void )

◆ dosavescreen_c()

void dosavescreen_c ( struct Screen ** scr,
const char * name,
struct GfxBase * gfx,
struct DosLibrary * dos )
static

SaveScreen Screen#,Filename$: save a screen as an ILBM file with its colours.

The palette from the screen's ColorMap (at most 256 colours): with Exec 39+ (environlib ExecVersion; a signed word compare, not a bug) GetRGB32 one colour at a time, before that the 4 bit values of the ColorTable spread to 32 bits. The BitMap is copied (64 bytes from the RastPort's BitMap, Flags cleared), then saved as SaveBitmap with a palette. Amiga mode only. Errors: as SaveBitmap; debugger only: "Uninitialized Screen" (scrchk). Not a bug in practice (#182): a ColorMap of 0 colours would run the colour loops 65536 times; a screen always has colours.

Parameters
scra0: the screen object (!libs {screenslib,$1080})
named1: the file name
gfxa1: graphics.library
dosa6: dos.library

◆ dosaveshape1()

void dosaveshape1 ( void )

◆ dosaveshape1_c()

void dosaveshape1_c ( const struct bb_shape * shape,
const char * name,
struct DosLibrary * dos )
static

SaveShape Shape#,Filename$: save a shape as an ILBM file.

The shape is described as a BitMap (BytesPerRow = its even byte width, Rows = its height, the depth word, plane pointers from its data in steps of its plane size); the BMHD width is the shape's pixel width. Amiga mode only. Errors as SaveBitmap; debugger only: "Uninitialized Shape" (sschk1). Errors: also "Illegal Shape Depth" for a depth of 0 or more than 14 (fixed, #326: the original wrote 65536 plane pointers for depth 0 and ran past the 14 pointers of tempbm from depth 15 on).

Parameters
shapea0: the shape (!libs {shapeslib,$1080})
named1: the file name
dosa6: dos.library

◆ dosaveshape2()

void dosaveshape2 ( void )

◆ dosaveshape2_c()

void dosaveshape2_c ( const struct bb_shape * shape,
const char * name,
const struct palette * pal,
struct DosLibrary * dos )
static

SaveShape Shape#,Filename$,Palette#: SaveShape with a CMAP of the palette (as SaveBitmap with a palette).

Errors (debugger only): also "Uninitialized Palette" (sschk2; also for a palette of 0 colours, fixed #182).

Parameters
shapea0: the shape (!libs {shapeslib,$1080})
named1: the file name
pala1: the palette (!libs {palettelib,$1182})
dosa6: dos.library

◆ fixbody()

void fixbody ( void )
static

◆ fixhead()

void fixhead ( void )
static

◆ makebody()

void makebody ( const struct BitMap * bm)
static

◆ makecolor()

void makecolor ( const struct palette * pal)
static

◆ makehead()

void makehead ( const struct BitMap * bm)
static

◆ makelong()

ULONG makelong ( UWORD v)
static

◆ palchk_c()

void palchk_c ( const struct palette * pal)
static

◆ put_l()

void put_l ( UBYTE ** p,
ULONG v )
static

◆ put_w()

void put_w ( UBYTE ** p,
UWORD v )
static

◆ savearow()

void savearow ( const UBYTE * row,
const struct BitMap * bm )
static

◆ savebm()

void savebm ( const struct BitMap * bm,
const char * name,
const struct palette * pal,
struct DosLibrary * dos )
static

◆ saveshape()

void saveshape ( const struct bb_shape * shape,
const char * name,
const struct palette * pal,
struct DosLibrary * dos )
static

◆ scrchk()

void scrchk ( void )

◆ scrchk_c()

void scrchk_c ( ULONG * scr)
static

◆ sschk1()

void sschk1 ( void )

◆ sschk1_c()

void sschk1_c ( UWORD * shape)
static

◆ sschk2()

void sschk2 ( void )

◆ sschk2_c()

void sschk2_c ( UWORD * shape,
const struct palette * pal )
static

Variable Documentation

◆ bm

struct BitMap bm

◆ [struct]

struct { ... } bmcopy

◆ bodylen

ULONG bodylen
static

◆ bodyseek

ULONG bodyseek
static

◆ dosbase

struct DosLibrary* dosbase
static

◆ fh

BPTR fh
static

◆ iffbuff

UBYTE iffbuff[BUFSIZE]
static

◆ ifflen

ULONG ifflen
static

◆ jeeze

const UBYTE jeeze[4] = { 0x80, 0, 0, 0 }
static

◆ mess2

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

◆ mess6

const char mess6[] = "Illegal Shape Depth"
static

◆ more

ULONG more[6]

◆ scrcols

ULONG scrcols[3 *256+2]
static

◆ scrpal

struct palette scrpal = { scrcols, 0 }
static

◆ usewid

UWORD usewid
static