BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
fontlib.c File Reference
#include "blitzlib.h"
#include "blitzobj.h"
#include <graphics/text.h>
#include <stddef.h>

Macros

#define LVO_OpenDiskFont   (-30) /* diskfont: a0 = TextAttr */
#define LVO_CloseFont   (-78) /* graphics: a1 = font */
#define BITCHAR_LINE

Functions

void dobitmapoutput (void)
void dobitmapinput (void)
void docolour (void)
 Colour Foreground Colour,Background Colour: the colours of the bitmap output.
void docolour2 (void)
 Colour Foreground Colour: the foreground colour only.
void dolocate (void)
 Locate X,Y: the cursor of the bitmap output, in characters.
void docursx (void)
void docursy (void)
void fontlib_codeinit (void)
void dousefont (void)
void dofreefont (void)
void bitout2 (void)
void bitout3 (void)
void locatechk (void)
void bitout (void)
void doinput1 (void)
void doloadfont (const UBYTE *name, WORD used, const void *gfx, const void *diskfont)
 LoadBlitzFont BlitzFont#,Fontname.font$: load an 8x8 font.
static void freefont (ULONG *obj, const void *gfx)
static void dofreefont_c (const void *gfx)
 _free of a BlitzFont object: close its font.
static void dousefont_c (void)
 _use of a BlitzFont object (Use BlitzFont n): the font for the output.
static void codeinit_c (WORD used, const void *gfx, const void *diskfont)
static ULONG docursx_c (void)
 CursX: the cursor column of the bitmap output.
 BLITZ_ALIAS (docursx, docursx_c)
static ULONG docursy_c (void)
 CursY: the cursor line of the bitmap output.
 BLITZ_ALIAS (docursy, docursy_c)
BL_ALWAYS_INLINE int calcoff (struct bb_bitmap **bm, struct TextFont **font, LONG *lineoff)
BL_ALWAYS_INLINE void docr (struct bb_bitmap *bm, UWORD *col, UWORD *row, LONG *lineoff)
BL_ALWAYS_INLINE void bitchar (UBYTE c, struct bb_bitmap *bm, struct TextFont *font, LONG *lineoff)
static void bitout_c (UBYTE c)
static void bitout2_c (ULONG len, const UBYTE *s)
 bitout2 (token for other libraries, output handler -4): draw a string on the output bitmap.
static void bitout3_c (const UBYTE *s)
 bitout3 (token for other libraries, output handler -8): draw a null terminated string on the output bitmap, as bitout2.
static void dobitmapoutput_c (struct bb_bitmap *bm)
 BitMapOutput Bitmap#: print to a bitmap with the BlitzFont.
 BLITZ_ALIAS (dobitmapoutput, dobitmapoutput_c)
static ULONG getchar_old (void)
static void docursor (struct bb_bitmap *bm, UWORD x)
static void edstring (struct bb_bitmap *bm, UBYTE *buf, UWORD max, UWORD x)
static ULONG doinput2_c (ULONG len, UBYTE *buf)
static void dobitmapinput_c (void)
 BitMapInput: read with an editor on the output bitmap.
 BLITZ_ALIAS (dobitmapinput, dobitmapinput_c)
static void locatechk_c (void)

Variables

static struct TextAttr textattr = { 0, 8, 0, 0 }
static const char deffont [] = "topaz.font"
void * fontlib_oldin
static struct bb_bitmap * bitmapout
static ULONG * fontout
static UBYTE pcolour = 1
static UBYTE pback = 0
static const char mess1 [] = "Can't Open Font"
static const char mess2 [] = "Uninitialized BitMap"
static const char mess3 [] = "Uninitialized Font"

Macro Definition Documentation

◆ BITCHAR_LINE

#define BITCHAR_LINE
Value:
" move.b (%[s]),%[t]\n" \
" and.b %[x],%[t]\n" \
" eor.b %[bg],%[t]\n" \
" move.b %[t],(%[d])\n" \
" add.w %[mod],%[s]\n" \
" add.w %[bpr],%[d]\n"

◆ LVO_CloseFont

#define LVO_CloseFont   (-78) /* graphics: a1 = font */

◆ LVO_OpenDiskFont

#define LVO_OpenDiskFont   (-30) /* diskfont: a0 = TextAttr */

Function Documentation

◆ bitchar()

BL_ALWAYS_INLINE void bitchar ( UBYTE c,
struct bb_bitmap * bm,
struct TextFont * font,
LONG * lineoff )

◆ bitout()

void bitout ( void )

◆ bitout2()

void bitout2 ( void )

◆ bitout2_c()

void bitout2_c ( ULONG len,
const UBYTE * s )
static

bitout2 (token for other libraries, output handler -4): draw a string on the output bitmap.

Characters below tf_LoChar or above tf_HiChar are ignored (fixed, #148: the original compared signed bytes), 10 = new line; at the right edge a new line, below the bitmap nothing is drawn. By design (#149): a bitmap of depth 0 runs the plane loop 65536 times (the error check of BitMap/CludgeBitMap refuses such a bitmap). Errors: "Uninitialized BitMap", "Uninitialized Font" (DIFF: nothing drawn if the trap returns).

Parameters
lend0: the length
sa0: the string

◆ bitout3()

void bitout3 ( void )

◆ bitout3_c()

void bitout3_c ( const UBYTE * s)
static

bitout3 (token for other libraries, output handler -8): draw a null terminated string on the output bitmap, as bitout2.

Parameters
sa0: the string

◆ bitout_c()

void bitout_c ( UBYTE c)
static

◆ BLITZ_ALIAS() [1/4]

BLITZ_ALIAS ( dobitmapinput ,
dobitmapinput_c  )

◆ BLITZ_ALIAS() [2/4]

BLITZ_ALIAS ( dobitmapoutput ,
dobitmapoutput_c  )

◆ BLITZ_ALIAS() [3/4]

BLITZ_ALIAS ( docursx ,
docursx_c  )

◆ BLITZ_ALIAS() [4/4]

BLITZ_ALIAS ( docursy ,
docursy_c  )

◆ calcoff()

BL_ALWAYS_INLINE int calcoff ( struct bb_bitmap ** bm,
struct TextFont ** font,
LONG * lineoff )

◆ codeinit_c()

void codeinit_c ( WORD used,
const void * gfx,
const void * diskfont )
static

◆ dobitmapinput()

void dobitmapinput ( void )

◆ dobitmapinput_c()

void dobitmapinput_c ( void )
static

BitMapInput: read with an editor on the output bitmap.

doinput1 becomes the input handler (setin), the previous one is kept: single characters come from it, lines are edited on the bitmap (doinput2: printable characters inserted, 31/30 cursor left/right, 8 backspace, 127 delete, 13 return; the result is the line without trailing spaces). Blitz mode only (error1 = 1). BUG(orig) (#151): at the end of the input (-1 from the previous handler) the editor waits forever.

◆ dobitmapoutput()

void dobitmapoutput ( void )

◆ dobitmapoutput_c()

void dobitmapoutput_c ( struct bb_bitmap * bm)
static

BitMapOutput Bitmap#: print to a bitmap with the BlitzFont.

The bitmap becomes the output bitmap and bitout the output handler of inputoutputlib (setout).

Parameters
bma0: the bitmap (!libs bitmaplib,$1080)

◆ docolour()

void docolour ( void )

Colour Foreground Colour,Background Colour: the colours of the bitmap output.

MOVE.b d1,pback and on into the one-argument form. Changes no register.

In: d0.b the foreground colour (the planes that get the character bits), d1.b the background colour

◆ docolour2()

void docolour2 ( void )

Colour Foreground Colour: the foreground colour only.

In: d0.b the foreground colour

◆ docr()

BL_ALWAYS_INLINE void docr ( struct bb_bitmap * bm,
UWORD * col,
UWORD * row,
LONG * lineoff )

◆ docursor()

void docursor ( struct bb_bitmap * bm,
UWORD x )
static

◆ docursx()

void docursx ( void )

◆ docursx_c()

ULONG docursx_c ( void )
static

CursX: the cursor column of the bitmap output.

(pixel cursor << 16) >> 3 as Quick: not a bug, fractions of a character are possible. Errors (debugger): "Uninitialized BitMap".

Returns
d0: the column (Quick)

◆ docursy()

void docursy ( void )

◆ docursy_c()

ULONG docursy_c ( void )
static

CursY: the cursor line of the bitmap output.

(pixel cursor << 16) >> 3 as Quick. Errors (debugger): "Uninitialized BitMap".

Returns
d0: the line (Quick)

◆ dofreefont()

void dofreefont ( void )

◆ dofreefont_c()

void dofreefont_c ( const void * gfx)
static

_free of a BlitzFont object: close its font.

a3 = the object; CloseFont of the TextFont if it is set, the object is cleared.

Parameters
gfxa6: graphics.library

◆ doinput1()

void doinput1 ( void )

◆ doinput2_c()

ULONG doinput2_c ( ULONG len,
UBYTE * buf )
static

◆ doloadfont()

void doloadfont ( const UBYTE * name,
WORD used,
const void * gfx,
const void * diskfont )

LoadBlitzFont BlitzFont#,Fontname.font$: load an 8x8 font.

a3 = the object. The object becomes the used and the output font, its old font is closed, then OpenDiskFont with the TextAttr {name, 8, 0, 0}. Only non-proportional 8x8 fonts are accepted. Amiga mode only. Fixed (#150): a refused font is closed before the error (the original left it open). Errors (also without the debugger, err1 in the normal code): "Can't Open Font".

Parameters
named1: the font name
usedd5: the offset of the library's used global from a5 (!libs fontlib,$0504)
gfxd6: graphics.library (for freeing the old font)
diskfonta6: diskfont.library

◆ dolocate()

void dolocate ( void )

Locate X,Y: the cursor of the bitmap output, in characters.

LSL #3,d0:LSL.l #3,d1:SWAP d1:MOVEM d0-d1,40(a0): the pixel cursor of the output bitmap (cursx, cursy) = x * 8, the integer part of y * 8. Not a bug: Y is a Quick, X a word. Changes d0, d1 and a0. Errors (debugger, locatechk): "Uninitialized BitMap".

In: d0.w the column, d1 the line (Quick)

◆ dousefont()

void dousefont ( void )

◆ dousefont_c()

void dousefont_c ( void )
static

_use of a BlitzFont object (Use BlitzFont n): the font for the output.

MOVE.l a3,fontout: the object in a3 becomes the output font.

◆ edstring()

void edstring ( struct bb_bitmap * bm,
UBYTE * buf,
UWORD max,
UWORD x )
static

◆ fontlib_codeinit()

void fontlib_codeinit ( void )

◆ freefont()

void freefont ( ULONG * obj,
const void * gfx )
static

◆ getchar_old()

ULONG getchar_old ( void )
static

◆ locatechk()

void locatechk ( void )

◆ locatechk_c()

void locatechk_c ( void )
static

Variable Documentation

◆ bitmapout

struct bb_bitmap* bitmapout
static

◆ deffont

const char deffont[] = "topaz.font"
static

◆ fontlib_oldin

void* fontlib_oldin

◆ fontout

ULONG* fontout
static

◆ mess1

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

◆ mess2

const char mess2[] = "Uninitialized BitMap"
static

◆ mess3

const char mess3[] = "Uninitialized Font"
static

◆ pback

UBYTE pback = 0
static

◆ pcolour

UBYTE pcolour = 1
static

◆ textattr

struct TextAttr textattr = { 0, 8, 0, 0 }
static