#ifndef lint
static char *sccsid = "@(#)tables.c	1.6 (UKC) 4/1/88";
#endif  lint
#include "bbcplot.h"	/* for typedef grid */
#include "types.h"

/* Table to map single characters (from dil "cx" and "nnc" commands)
 * into either single characters for the beeb or into framboozles
 * which will need to be mapped through charraster[] to give bit pattern
 */

short normchar[127] = {
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	'!',	'"',	'#',	'$',	'%',	'&',	'\'',
	'(',	')',	'*',	'+',	',',	'-',	'.',	'/',
	'0',	'1',	'2',	'3',	'4',	'5',	'6',	'7',
	'8',	'9',	':',	';',	'<',	'=',	'>',	'?',
	'@',	'A',	'B',	'C',	'D',	'E',	'F',	'G',
	'H',	'I',	'J',	'K',	'L',	'M',	'N',	'O',
	'P',	'Q',	'R',	'S',	'T',	'U',	'V',	'W',
	'X',	'Y',	'Z',	'[',	'\\',	']',	'^',	'ru',
	'ga',	'a',	'b',	'c',	'd',	'e',	'f',	'g',
	'h',	'i',	'j',	'k',	'l',	'm',	'n',	'o',
	'p',	'q',	'r',	's',	't',	'u',	'v',	'w',
	'x',	'y',	'z',	'{',	'|',	'}',	'~'
};

/* Table to map short-encoded two-char troff names into framboozles,
 * usually the identity function.
 */
struct abnormchar abnormchar[] = {
	/* C/A/T character set */
	{ 'br', 'br' },	{ 'bv', 'bv' }, { 'lc', 'lc' }, { 'lf', 'lf' },
	{ 'rc', 'rc' }, { 'rf', 'rf' }, { 'st', '`'  }, { 'ru', 'ru' },
	{ 'ul', 'ul' }, { 'em', '-'  }, { 'hy', '-'  }, { '\\-','-'  },
	{ 'pl', '+'  }, { 'mi', '-'  }, { 'eq', '='  }, { '**', '*'  },
	{ 'aa', '\'' }, { 'ga', 'ga' }, { 'sl', '/'  }, { 'fm', '\'' },
	{ '!=', '!=' }, { 'bu', 'bu' }, { 'rk', 'rk' },
	{ 'lk', 'lk' }, { 'lt', 'lt' }, { 'lb', 'lb' }, { 'rt', 'rt' },
	{ 'rb', 'rb' }, { '==', '==' }, { '~=', '~=' }, { 'ap', 'ap' },
	{ 'is', 'is' }, { '>=', '>=' }, { '<=', '<=' }, { '->', '->' },
	{ '<-', '<-' }, { 'ua', 'ua' }, { 'da', 'da' }, { 'mu', 'mu' },
	{ 'di', 'di' }, { '+-', '+-' }, { 'cu', 'cu' }, { 'ca', 'ca' },
	{ 'sb', 'sb' }, { 'sp', 'sp' }, { 'ib', 'ib' }, { 'ip', 'ip' },
	{ 'if', 'if' }, { 'pd', 'pd' }, { 'gr', 'gr' }, { 'no', 'no' },
	{ 'pt', 'pt' }, { 'es', 'es' }, { 'mo', 'mo' }, { 'dd', 'dd' },
	{ 'or', 'or' }, { 'sq', 'sq' }, { 'ci', 'ci' }, { 'rn', 'rn' },
	{ 'fi', 'fi' }, { 'fl', 'fl' }, { 'ff', 'ff' }, { 'Fi', 'Fi' },
	{ 'Fl', 'Fl' }, { 'dg', 'dg' }, { 'de', 'de' }, { '14', '14' },
	{ '12', '12' }, { '34', '34' }, { 'ct', 'ct' }, { 'co', 'co' },
	{ 'rg', 'rg' }, { 'sr', 'sr' }, { 'bs', 'bs' }, { 'sc', 'sc' },
	{ 'lh', 'lh' }, { 'rh', 'rh' },
	{ '*A', 'A'  }, { '*B', 'B'  }, { '*G', '*G' }, { '*D', '*D' },
	{ '*E', 'E'  }, { '*Z', 'Z'  }, { '*Y', 'H'  }, { '*H', '*H' },
	{ '*I', 'I'  }, { '*K', 'K'  },	{ '*L', '*L' },	{ '*M', 'M'  },
	{ '*N', 'N'  },	{ '*C', '*C' },	{ '*O', 'O'  }, { '*P', '*P' },
	{ '*R', 'P'  },	{ '*S', '*S' },	{ '*T', 'T'  }, { '*U', 'Y'  },
	{ '*F', '*F' },	{ '*X', 'X'  }, { '*Q', '*Q' }, { '*W', '*W' },
	{ '*a', '*a' }, { '*b', '*b' }, { '*g', '*g' }, { '*d', '*d' },
	{ '*e', '*e' }, { '*z', '*z' }, { '*y', '*y' }, { '*h', '*h' },
	{ '*i', '*i' }, { '*k', '*k' }, { '*l', '*l' }, { '*m', '*m' },
	{ '*n', '*n' }, { '*c', '*c' }, { '*o', 'o'  }, { '*p', '*p' },
	{ '*r', '*r' }, { '*s', '*s' }, { 'ts', 'ts' }, { '*t', '*t' },
	{ '*u', '*u' }, { '*f', '*f' }, { '*x', '*x' }, { '*q', '*q' },
	{ '*w', '*w' },
	/* Specials for the Canon */
	{ 'hb', 'hb' }, { 'te', 'te' }, { 'fa', 'fa' }, { '<>', '<>' },
	/* Specials for the Sanders */
	{ 'SM', 'SM' }, { 'PR', 'PR' }, { 'ti', 'ti' }, { 'bi', 'bi' },
	/* Specials for the HP Laserjet with Maths fontpack J */
	{ 'wp', 'wp' },
	{ 'tf', 'tf' }, { 'E/', 'E/' }, { 'im', 'im' }, { 'io', 'io' },
	{ 'a+', 'a+' }, { 'a-', 'a-' }, { 'ax', 'ax' }, { 'a/', 'a/' },
	{ 'a.', 'a.' }, { 'an', 'an' }, { 'lo', 'lo' }, { 'pp', 'pp' },
	{ 'h/', 'h/' }, { 'SL', 'SL' }, { 'Sl', 'Sl' }, { 'CU', 'CU' },
	{ 'CA', 'CA' },
	{ 0, 0 }
};

/*
 * Table containing number of blank columns to left of char in
 * character square. See "Design decisions" in dbbc1.c
 * Indexed by the ascii code output to the beeb.
 * Synthesised characters should be left-aligned in their character space.
 * These offsets are twice the number of blank columns so that they may
 * simply be added to the plotting position.
 * Sorry about all the 0s - I think it is quicker this way.
 * Besides, offsets might be required for some synthesised chars to move the
 * character space about.
 */
char xcharoffset[256] = {
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
/* ! */	0,	6,	2,	2,	2,	2,	2,	4,
/* ( */	4,	4,	2,	2,	4,	2,	6,	2,
/* 0 */	2,	2,	2,	2,	2,	2,	2,	2,
/* 8 */	2,	2,	6,	4,	2,	2,	4,	2,
/* @ */	2,	2,	2,	2,	2,	2,	2,	2,
/* H */	2,	4,	2,	2,	2,	0,	2,	2,
/* P */	2,	2,	2,	2,	2,	2,	2,	2,
/* X */	2,	2,	2,	2,	2,	4,	2,	0,
/* ` */	2,	2,	2,	2,	2,	2,	2,	2,
/* h */	2,	4,	2,	2,	4,	0,	2,	2,
/* p */	2,	2,	2,	2,	2,	2,	2,	2,
/* x */	2,	2,	2,	2,	6,	4,	2,	2,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
};

#ifdef 0
/*
 * the beeb plots a character dangling from the cursor by its top left corner.
 * This table contains the offset of the chracter's true baseline from the
 * top corner, usually 6 pixels.
 * Note: shifting g p q and y down by one pixel looks ghastly.
 * *** If any of these is ever not 24, change ocmd() to use this table.
 */
char ycharoffset[256] = {
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
	0,	0,	0,	0,	0,	0,	0,	0,
/* ! */	0,	24,	24,	24,	24,	24,	24,	24,
/* ( */	24,	24,	24,	24,	24,	24,	24,	24,
/* 0 */	24,	24,	24,	24,	24,	24,	24,	24,
/* 8 */	24,	24,	24,	24,	24,	24,	24,	24,
/* @ */	24,	24,	24,	24,	24,	24,	24,	24,
/* H */	24,	24,	24,	24,	24,	24,	24,	24,
/* P */	24,	24,	24,	24,	24,	24,	24,	24,
/* X */	24,	24,	24,	24,	24,	24,	24,	24,
/* ` */	24,	24,	24,	24,	24,	24,	24,	24,
/* h */	24,	24,	24,	24,	24,	24,	24,	24,
/* p */	24,	24,	24,	24,	24,	24,	24,	24,
/* x */	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
	24,	24,	24,	24,	24,	24,	24,	24,
};
#endif
