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

Data Structures

struct  fns
struct  fnshead

Macros

#define TOK_bload   ((LIB_riamosfunclib << 7) + 15) /* form 1: d0 name, d1 bank */
#define TOK_start   ((LIB_riamosfunclib << 7) + 17) /* d0 bank -> d0 address */
#define TOK_length   ((LIB_riamosfunclib << 7) + 18) /* d0 bank -> d0 its length */
#define TOK_erase   ((LIB_riamosfunclib << 7) + 19) /* d0 bank */
#define TOK_banklimit   ((LIB_riamosfunclib << 7) + 36) /* form 1: -> d0 the number of banks */
#define FNSID   0x464e532eUL /* "FNS." */
#define FONTSIZE   1712
#define BMAP0   LIB_bitmaplib, BL_IA0|BL_PD0 /* !bmap {0,0} */
#define OFF_TCOLOUR   44
#define OFF_TCOLOUR2   45
#define OFF_TEXTPREFS   46
#define OFF_TEXTPREFS2   47
#define OFF_BITADDRESS   78
#define FNS_FONT   "../../../archive/amiblitz3-github/Sourcecodes/Data/fns/fonts/PERSONAL.FNS"
#define FH(font)
#define LONGAT(p)
#define DEFLAST   (122 - 32)
#define BITSTACK   ((ULONG *)((UBYTE *)&fns + offsetof(struct fns, bitstack)))
#define S_(x)

Functions

void _fnsprint (void)
void _fnsprint2 (void)
void _installfns (void)
void _installfns3 (void)
void _fnsoutput2 (void)
void _fnsoutput (void)
void _fnsink (void)
void _fnsprefs2 (void)
void _fnsprefs (void)
void _fnsheight (void)
void _fnsclipset (void)
void _fnsclipoutputset (void)
void _removefns (void)
void _fnsunderline (void)
void _fnslength2 (void)
void _fnslength (void)
void _fnsversion (void)
 FNSVersion: the version of the library, 1.1 as a Quick.
void _fnsorigin2 (void)
void _fnsorigin (void)
void _fnswidth (void)
void _fnsload (void)
void _fnsslot (void)
void _fnsunload (void)
void _fnssettab (void)
void _fnsshadowprint (void)
void _fnsshadowprint2 (void)
void _fnsshadowprint3 (void)
void rifnslib_libinit (void)
void clipchk (void)
void tabchk (void)
static void _libfinit (void)
 finit: nothing.
static int isfont (const UBYTE *font)
static void underline (UWORD x)
static UWORD countwidth (const UBYTE *font, const UBYTE *p, UBYTE bold, UBYTE lastg)
static void drawchar (const UWORD *g, ULONG rowoff, UWORD s)
static UBYTE * print (UWORD fontnum, UWORD x0, UWORD y0, const UBYTE *str, UBYTE prefs, UBYTE colour, UBYTE *result)
static UBYTE * print_c (UWORD fontnum, UWORD x, UWORD y, const UBYTE *str, UWORD prefs, UWORD colour, UBYTE *result)
 FNSPrint fontnum,x,y,a$,prefs,colour: prints a text into the FNSOutput bitmap.
static UBYTE * shadow_c (UWORD fontnum, UWORD x, UWORD y, const UBYTE *str, UWORD prefs, UWORD colour, UWORD shadow, UBYTE *result)
 FNSShadowPrint fontnum,x,y,a$,prefs,colour,shadow: prints a text with a shadow.
static void libinit_c (void)
 init: the variables as the library is loaded, slot 0 = the built-in font.
static ULONG installfns3_c (ULONG n, const UBYTE *font, UWORD count)
 InstallFNS(fontnum,address,characters): puts a font of characters glyphs into a slot.
static ULONG installfns_c (ULONG n, const UBYTE *font)
 InstallFNS(fontnum,address): puts a font in memory into a slot.
static void removefns_c (ULONG n)
 RemoveFNS fontnum: empties a font slot.
static void clipoutput_c (void)
 FNSClipOutput: the clipping zone = the whole output bitmap.
static void output_c (UWORD clip, struct BitMap *bm)
 FNSOutput bitmap,clip_update: the bitmap to print into.
static void output2_c (struct BitMap *bm)
 FNSOutput bitmap: as FNSOutput bitmap,Off (the clipping zone stays).
static void ink_c (UWORD c)
 FNSInk colour: the colour of FNSPrint without prefs,colour.
static void prefs2_c (UWORD p)
 FNSPrefs prefs: the prefs of FNSPrint without prefs,colour.
static void prefs_c (UWORD p, UWORD c)
 FNSPrefs prefs,colour: the prefs and the colour of FNSPrint without them.
static ULONG fontword (ULONG n, int off)
static ULONG height_c (ULONG n)
 FNSHeight(fontnum): the height of a font.
static ULONG underline_c (ULONG n)
 FNSUnderline(fontnum): the underline offset of a font.
static ULONG width_c (ULONG n)
 FNSWidth(fontnum): the width of a font in pixels (16, 32, 48, 64).
static void clipset_c (UWORD x0, UWORD y0, UWORD x1, UWORD y1)
 FNSClip xmin,ymin,xmax,ymax: the clipping zone; x rounded down to 16.
static ULONG length_c (UWORD n, const UBYTE *str, UWORD prefs)
 FNSLength(fontnum,a$,prefs): the width of a text in pixels.
static ULONG length2_c (UWORD n, const UBYTE *str)
 FNSLength(fontnum,a$): as FNSLength with FNSPrefs' prefs.
static void origin2_c (void)
 FNSOrigin: the origin of FNSPrint back to 0,0.
static void origin_c (UWORD x, UWORD y)
 FNSOrigin x,y: the origin added to FNSPrint's x,y.
static UBYTE filelast (const UBYTE *font, ULONG size)
static ULONG load_c (ULONG name, ULONG slot)
 FNSLoad(fontname$,fontslot): loads a font file into a slot.
static void unload_c (ULONG slot)
 FNSUnload fontslot: empties the slot and erases its bank.
static ULONG slot_c (void)
 FNSSlot: the address of the 16 font slots (longs).
static void settab_c (UWORD t)
 FNSSetTab tab_size: the tab size in pixels (32 at first).
static void clipchk_c (UWORD x0, UWORD y0)
 The error check of FNSClip (debugger only).
static void tabchk_c (UWORD t)
 The error check of FNSSetTab (debugger only).

Variables

struct fns fns
static UBYTE lastglyph [16] = { [0 ... 15] = DEFLAST }
static UWORD loadedslots
static LONG slotbank [16] = { [0 ... 15] = -1 }
static UWORD gly
static UWORD glrows

Macro Definition Documentation

◆ BITSTACK

#define BITSTACK   ((ULONG *)((UBYTE *)&fns + offsetof(struct fns, bitstack)))

◆ BMAP0

#define BMAP0   LIB_bitmaplib, BL_IA0|BL_PD0 /* !bmap {0,0} */

◆ DEFLAST

#define DEFLAST   (122 - 32)

◆ FH

#define FH ( font)
Value:
((const struct fnshead *)(font))
Definition rifnslib.c:370

◆ FNS_FONT

#define FNS_FONT   "../../../archive/amiblitz3-github/Sourcecodes/Data/fns/fonts/PERSONAL.FNS"

◆ FNSID

#define FNSID   0x464e532eUL /* "FNS." */

◆ FONTSIZE

#define FONTSIZE   1712

◆ LONGAT

#define LONGAT ( p)
Value:
(*(ULONG *)(p))

◆ OFF_BITADDRESS

#define OFF_BITADDRESS   78

◆ OFF_TCOLOUR

#define OFF_TCOLOUR   44

◆ OFF_TCOLOUR2

#define OFF_TCOLOUR2   45

◆ OFF_TEXTPREFS

#define OFF_TEXTPREFS   46

◆ OFF_TEXTPREFS2

#define OFF_TEXTPREFS2   47

◆ S_

#define S_ ( x)
Value:
ULONG x
Definition 2dlib.c:2491
#define BL_STR(x)
Definition blitzlib.h:533

◆ TOK_banklimit

#define TOK_banklimit   ((LIB_riamosfunclib << 7) + 36) /* form 1: -> d0 the number of banks */

◆ TOK_bload

#define TOK_bload   ((LIB_riamosfunclib << 7) + 15) /* form 1: d0 name, d1 bank */

◆ TOK_erase

#define TOK_erase   ((LIB_riamosfunclib << 7) + 19) /* d0 bank */

◆ TOK_length

#define TOK_length   ((LIB_riamosfunclib << 7) + 18) /* d0 bank -> d0 its length */

◆ TOK_start

#define TOK_start   ((LIB_riamosfunclib << 7) + 17) /* d0 bank -> d0 address */

Function Documentation

◆ _fnsclipoutputset()

void _fnsclipoutputset ( void )

◆ _fnsclipset()

void _fnsclipset ( void )

◆ _fnsheight()

void _fnsheight ( void )

◆ _fnsink()

void _fnsink ( void )

◆ _fnslength()

void _fnslength ( void )

◆ _fnslength2()

void _fnslength2 ( void )

◆ _fnsload()

void _fnsload ( void )

◆ _fnsorigin()

void _fnsorigin ( void )

◆ _fnsorigin2()

void _fnsorigin2 ( void )

◆ _fnsoutput()

void _fnsoutput ( void )

◆ _fnsoutput2()

void _fnsoutput2 ( void )

◆ _fnsprefs()

void _fnsprefs ( void )

◆ _fnsprefs2()

void _fnsprefs2 ( void )

◆ _fnsprint()

void _fnsprint ( void )

◆ _fnsprint2()

void _fnsprint2 ( void )

◆ _fnssettab()

void _fnssettab ( void )

◆ _fnsshadowprint()

void _fnsshadowprint ( void )

◆ _fnsshadowprint2()

void _fnsshadowprint2 ( void )

◆ _fnsshadowprint3()

void _fnsshadowprint3 ( void )

◆ _fnsslot()

void _fnsslot ( void )

◆ _fnsunderline()

void _fnsunderline ( void )

◆ _fnsunload()

void _fnsunload ( void )

◆ _fnsversion()

void _fnsversion ( void )

FNSVersion: the version of the library, 1.1 as a Quick.

Inline: MOVE.l #65536+6553,d0.

Result
d0: 1.1 (a Quick)

◆ _fnswidth()

void _fnswidth ( void )

◆ _installfns()

void _installfns ( void )

◆ _installfns3()

void _installfns3 ( void )

◆ _libfinit()

void _libfinit ( void )
static

finit: nothing.

◆ _removefns()

void _removefns ( void )

◆ clipchk()

void clipchk ( void )

◆ clipchk_c()

void clipchk_c ( UWORD x0,
UWORD y0 )
static

The error check of FNSClip (debugger only).

Fixed (#664), not in the original (rifnslib had no error check area): FNSPrint tests the rows signed at ymin and unsigned at ymax and takes the byte offset of x as ASR.w of the long x & $FFF0; with a negative xmin or ymin a text at negative x or y was written about 64K bytes or rows away. The release code is unchanged (an invalid argument, D-005).

Errors: "FNSClip zone must not start below 0" (xmin or ymin below 0).

Parameters
x0d0: xmin
y0d1: ymin

◆ clipoutput_c()

void clipoutput_c ( void )
static

FNSClipOutput: the clipping zone = the whole output bitmap.

xmin, ymin 0, xmax = the bytes per row * 8, ymax = the rows (fixed, #1128: the first row outside, as xmax; the original set the rows - 1).

◆ clipset_c()

void clipset_c ( UWORD x0,
UWORD y0,
UWORD x1,
UWORD y1 )
static

FNSClip xmin,ymin,xmax,ymax: the clipping zone; x rounded down to 16.

xmax and ymax are the first column and row outside the zone (fixed, #1128: the manual's "FNSClip 0,0,320,256" for a 320x256 bitmap; the original drew rows up to ymax itself, one behind such a bitmap). A negative xmin or ymin is the programmer's: with runtime error checking clipchk refuses it (fixed #664).

Parameters
x0d0: xmin
y0d1: ymin
x1d2: xmax
y1d3: ymax

◆ countwidth()

UWORD countwidth ( const UBYTE * font,
const UBYTE * p,
UBYTE bold,
UBYTE lastg )
inlinestatic

◆ drawchar()

void drawchar ( const UWORD * g,
ULONG rowoff,
UWORD s )
static

◆ filelast()

UBYTE filelast ( const UBYTE * font,
ULONG size )
static

◆ fontword()

ULONG fontword ( ULONG n,
int off )
static

◆ height_c()

ULONG height_c ( ULONG n)
static

FNSHeight(fontnum): the height of a font.

Parameters
nd0: the slot (& 15)
Returns
d0.w: the height, -1 if the slot has no FNS font

◆ ink_c()

void ink_c ( UWORD c)
static

FNSInk colour: the colour of FNSPrint without prefs,colour.

Parameters
cd0: the colour (its low byte)

◆ installfns3_c()

ULONG installfns3_c ( ULONG n,
const UBYTE * font,
UWORD count )
static

InstallFNS(fontnum,address,characters): puts a font of characters glyphs into a slot.

Fixed (#657), a form the original does not have: the font has the glyphs of the codes 32 to 31 + characters (1 to 224: 0 is taken as 1, the space; above 224 as 224, up to code 255); a code behind them is printed and counted as a space. Only an "FNS." font with a height of at least 1 (fixed, #663).

Parameters
nd0: the slot (& 15)
fontd1: the address of the font
countd2: the number of glyphs (a word)
Returns
d0.b: the slot, 0 if it is no FNS font or its height is 0

◆ installfns_c()

ULONG installfns_c ( ULONG n,
const UBYTE * font )
static

InstallFNS(fontnum,address): puts a font in memory into a slot.

Only an "FNS." font with a height of at least 1 (fixed, #663: the original took a height of 0, which drew 65536 rows per character). The font is taken to have the glyphs of the codes 32 to 122 (fixed, #657: the 91 of every known font; a code behind them is a space).

Parameters
nd0: the slot (& 15)
fontd1: the address of the font
Returns
d0.b: the slot, 0 if it is no FNS font or its height is 0

◆ isfont()

int isfont ( const UBYTE * font)
static

◆ length2_c()

ULONG length2_c ( UWORD n,
const UBYTE * str )
static

FNSLength(fontnum,a$): as FNSLength with FNSPrefs' prefs.

Fixed (#661): the prefs FNSPrint without prefs uses; the original took those of the last FNSPrint.

Parameters
nd0: the slot (& 15)
strd1: the text
Returns
d0.w: as FNSLength

◆ length_c()

ULONG length_c ( UWORD n,
const UBYTE * str,
UWORD prefs )
static

FNSLength(fontnum,a$,prefs): the width of a text in pixels.

The widths of the characters (+ 1 for bold, prefs bit 1) up to the first code that ends the text: the width FNSPrint uses (fixed, #662: the original returned the width - 2, 0 at least). Fixed (#660): the font number & 15 (the original shifted the whole word: 16 on read the font data, negative numbers the variables before font_add).

Parameters
nd0: the slot (& 15)
strd1: the text
prefsd2: the prefs (a byte)
Returns
d0.w: the width, -1 if the slot has no FNS font

◆ libinit_c()

void libinit_c ( void )
static

init: the variables as the library is loaded, slot 0 = the built-in font.

Fixed (#1124): every variable in front of the built-in font back to its start value (0, the tab size 32: no output bitmap, the slots 1-15 empty, FNSPrefs, FNSInk, the clip zone and the origin 0), the slots' glyph counts 91 and no FNSLoad bank; the original set slot 0 and the origin only, so a second run of a program from the editor (the library stays loaded) printed with the first run's settings, and FNSPrint before FNSOutput drew into the first run's freed bitmap.

◆ load_c()

ULONG load_c ( ULONG name,
ULONG slot )
static

FNSLoad(fontname$,fontslot): loads a font file into a slot.

RIAmosFuncLib BLoad into a bank, then its Start into the slot. Fixed (#984): bank 55 + slot when it exists (below BankLimit); else the bank the slot's font is in, or the highest free bank below the limit (-1 when every bank is in use), remembered for FNSUnload. The original always used 55 + slot: with RIAmosFuncLib's default of 50 banks BLoad took the number as an address and read the file to the address 55 + slot, Start returned 0 and FNSLoad -1. Fixed (#657): the font has the glyphs of the codes 32 to 31 + (the bank's length - 256) / bytes per character (Length of the bank, the file's size). Fixed (#663): a file that is no "FNS." font or has a height of 0 is refused: -1, the bank erased, and the slot emptied if its font was the one FNSLoad had put in that bank (BLoad overwrote it); the original stored whatever Start returned (FNSPrint then drew nothing, a font of height 0 65536 rows per character). Amiga mode only.

Parameters
named0: the file name
slotd1: the slot (& 15)
Returns
d0.w: the slot, -1 if the load failed

◆ origin2_c()

void origin2_c ( void )
static

FNSOrigin: the origin of FNSPrint back to 0,0.

◆ origin_c()

void origin_c ( UWORD x,
UWORD y )
static

FNSOrigin x,y: the origin added to FNSPrint's x,y.

Parameters
xd0: x
yd1: y

◆ output2_c()

void output2_c ( struct BitMap * bm)
static

FNSOutput bitmap: as FNSOutput bitmap,Off (the clipping zone stays).

Parameters
bma0: the bitmap object

◆ output_c()

void output_c ( UWORD clip,
struct BitMap * bm )
static

FNSOutput bitmap,clip_update: the bitmap to print into.

Keeps the bitmap, its bytes per row and depth. BUG(orig) (#658): the 16 pixel loop draws (Flags<<8 | Depth) - 1 + 1 planes - with Flags set or depth 0 hundreds or 65536.

Parameters
clipd1: On: also FNSClipOutput (a byte)
bma0: the bitmap object (!bmap)

◆ prefs2_c()

void prefs2_c ( UWORD p)
static

FNSPrefs prefs: the prefs of FNSPrint without prefs,colour.

Parameters
pd0: the prefs (its low byte)

◆ prefs_c()

void prefs_c ( UWORD p,
UWORD c )
static

FNSPrefs prefs,colour: the prefs and the colour of FNSPrint without them.

Parameters
pd0: the prefs (its low byte)
cd1: the colour (its low byte)

◆ print()

UBYTE * print ( UWORD fontnum,
UWORD x0,
UWORD y0,
const UBYTE * str,
UBYTE prefs,
UBYTE colour,
UBYTE * result )
static

◆ print_c()

UBYTE * print_c ( UWORD fontnum,
UWORD x,
UWORD y,
const UBYTE * str,
UWORD prefs,
UWORD colour,
UBYTE * result )
static

FNSPrint fontnum,x,y,a$,prefs,colour: prints a text into the FNSOutput bitmap.

Behind the entries _fnsprint/_fnsprint2 (below), which check the bitmap. At x,y + the origin, in the font of slot fontnum & 15 (nothing if it is no "FNS." font); prefs bit 0 centred, 1 bold, 2 underlined, 3 right aligned; chr$(1) + c changes the colour, chr$(9) a tab (FNSSetTab), chr$(10) a new line, chr$(0) and other codes below 32 end the text, a code behind the font's last is printed as a space (fixed #657); clipped by FNSClip; an empty line is neither centred, aligned nor underlined (fixed #659). BUG(orig): depth 0 or above 8 overruns the plane stack (#658). With a negative xmin or ymin (refused by FNSClip's error check, fixed #664) text at negative x or y is written about 64K bytes or rows away; with a tab size of 0 (refused by FNSSetTab's error check, fixed #666) a chr$(9) divides by 0.

Parameters
fontnumd0: the font slot
xd1: x
yd2: y
strd3: the text (a string or an address)
prefsd4: the prefs (a byte)
colourd5: the colour (a byte)
resulta0: the caller's a0 (the result without a font)
Returns
a0: the address of the end x and y (words, in the variable block)

◆ removefns_c()

void removefns_c ( ULONG n)
static

RemoveFNS fontnum: empties a font slot.

Parameters
nd0: the slot (& 15)

◆ rifnslib_libinit()

void rifnslib_libinit ( void )

◆ settab_c()

void settab_c ( UWORD t)
static

FNSSetTab tab_size: the tab size in pixels (32 at first).

A size of 0 makes chr$(9) divide by 0: with runtime error checking tabchk refuses a size below 1 (fixed #666).

Parameters
td0: the tab size

◆ shadow_c()

UBYTE * shadow_c ( UWORD fontnum,
UWORD x,
UWORD y,
const UBYTE * str,
UWORD prefs,
UWORD colour,
UWORD shadow,
UBYTE * result )
static

FNSShadowPrint fontnum,x,y,a$,prefs,colour,shadow: prints a text with a shadow.

Behind the entries _fnsshadowprint..3 (below). First the text at x+1,y+1 in the shadow colour, then normally, as FNSPrint.

Parameters
fontnumd0: the font slot
xd1: x
yd2: y
strd3: the text
prefsd4: the prefs (a byte)
colourd5: the colour (a byte)
shadowd6: the shadow colour (a byte)
resulta0: the caller's a0
Returns
a0: the address of the end x and y of the second print

◆ slot_c()

ULONG slot_c ( void )
static

FNSSlot: the address of the 16 font slots (longs).

Returns
d0: the address (in the variable block)

◆ tabchk()

void tabchk ( void )

◆ tabchk_c()

void tabchk_c ( UWORD t)
static

The error check of FNSSetTab (debugger only).

Fixed (#666), not in the original: a chr$(9) in a printed text moves x to the next tab stop with DIVU tabsize; a size of 0 divided by 0. The release code is unchanged (an invalid argument, D-005).

Errors: "FNSSetTab size must be at least 1" (the size, a signed word, below 1).

Parameters
td0: the tab size

◆ underline()

void underline ( UWORD x)
static

◆ underline_c()

ULONG underline_c ( ULONG n)
static

FNSUnderline(fontnum): the underline offset of a font.

Parameters
nd0: the slot (& 15)
Returns
d0.w: the offset, -1 if the slot has no FNS font

◆ unload_c()

void unload_c ( ULONG slot)
static

FNSUnload fontslot: empties the slot and erases its bank.

The bank FNSLoad last loaded the slot's font into (fixed, #984), bank 55 + slot if there is none (the original's always).

Parameters
slotd0: the slot (& 15)

◆ width_c()

ULONG width_c ( ULONG n)
static

FNSWidth(fontnum): the width of a font in pixels (16, 32, 48, 64).

Parameters
nd0: the slot (& 15)
Returns
d0.w: the width, -1 if the slot has no FNS font

Variable Documentation

◆ fns

struct fns fns
Initial value:
= {
.tabsize = 32,
.def_font = {
,
0x10, 0x00, 0x18, 0x00, 0x1c, 0x00, 0xfe, 0x00, 0x1c, 0x00, 0x18, 0x00, 0x10, 0x00,
},
}

◆ glrows

UWORD glrows
static

◆ gly

UWORD gly
static

◆ lastglyph

UBYTE lastglyph[16] = { [0 ... 15] = DEFLAST }
static

◆ loadedslots

UWORD loadedslots
static

◆ slotbank

LONG slotbank[16] = { [0 ... 15] = -1 }
static