/*
	font.h
*/

#include "bits.h"

#define tstbit(b,x) ( \
	*( ((byte *) b ) + ( (x) / 8 ) ) & \
		( 0x80 >> ( (x) % 8 ) ) \
	)

#define setbit(b,x) ( \
	*( ((byte *) b ) + ( (x) / 8 ) ) |= \
		( 0x80 >> ( (x) % 8 ) ) \
	)

#define tstbit2(b,x,y,z) ( \
	*( ((byte *) b ) + ( (x) / 8 ) + (y) * ( (z) / 8 ) ) & \
		( 0x80 >> ( (x) % 8 ) ) \
	)

#define setbit2(b,x,y,z) ( \
	*( ((byte *) b ) + ( (x) / 8 ) + (y) * ( (z) / 8 ) ) |= \
		( 0x80 >> ( (x) % 8 ) ) \
	)

typedef struct {
	FILE *fp;
	byte *b;
	BITS *bp;
	int ofs,size;
	byte width,type;
} FONT;

FONT *fontini( char *fn, byte width, byte type );
void putfont( FONT *f, int xx, int yy, byte cf, byte cb, byte pg );
void getfont( FONT *f, word k );
