#include <vectrex.h>

// If you don't already use 'draw_synced_list_c', uncomment the #define below:

//#define USE_LOCAL_DRAW_SYNCHED_LIST 1


#ifdef USE_LOCAL_DRAW_SYNCHED_LIST

// this is Malban's "C" optimized version of print_sync
// (remember to set the project options to -O3 and no_frame_pointer)

#define ZERO_DELAY 5

static void draw_synced_list_c(
	const signed char *u,
	signed int y,
	signed int x,
	unsigned int scaleMove,
	unsigned int scaleList
	)
{
	
	do
	{
		// resync / startsync
		dp_VIA_shift_reg = 0;		// all output is BLANK
		
		// move to zero
		dp_VIA_cntl = (unsigned int)0xcc;	// zero the integrators
		dp_VIA_port_a = 0;			// reset integrator offset
		dp_VIA_port_b = (int)0b10000010;
		
		dp_VIA_t1_cnt_lo = scaleMove;
		// delay, till beam is at zero
		// volatile - otherwise delay loop does not work with -O
		for (volatile signed int b=ZERO_DELAY; b>0; b--);
		dp_VIA_port_b= (int)0b10000011;
		
		// move to "location"
		dp_VIA_port_a = y;			// y pos to dac
		dp_VIA_cntl = (unsigned int)0xce;	// disable zero, disable all blank
		dp_VIA_port_b = 0;			// mux enable, dac to -> integrator y (and x)
		dp_VIA_port_b = 1;			// mux disable, dac only to x
		dp_VIA_port_a = x;			// dac -> x
		dp_VIA_t1_cnt_hi=0;		// start timer
		
		// this can be done before the wait loop
		// since it only fills the latch, not the actual timer!
		dp_VIA_t1_cnt_lo = scaleList;
		u+=3;
		
		// moving test for yx == 0 into the move delay
		if ((*(u-2)!=0) || (*(u-1)!=0))
		{
			while ((dp_VIA_int_flags & 0x40) == 0); // wait till timer finishes
			
			// internal moveTo
			dp_VIA_port_a = *(u-2);	// y pos to dac
			dp_VIA_cntl = (unsigned int)0xce;	// disable zero, disable all blank
			dp_VIA_port_b = 0;			// mux enable, dac to -> integrator y (and x)
			dp_VIA_port_b = 1;			// mux disable, dac only to x
			dp_VIA_port_a = *(u-1);	// dac -> x
			dp_VIA_t1_cnt_hi=0;		// start timer
			while ((dp_VIA_int_flags & 0x40) == 0); // wait till timer finishes
		}
		else
		{
			while ((dp_VIA_int_flags & 0x40) == 0); // wait till timer finishes
		}
		
		while (1)
		{
			if (*u<0) // draw line
			{
				// draw a vector
				dp_VIA_port_a = *(1+u);		// y pos to dac
				dp_VIA_port_b = 0;				// mux enable, dac to -> integrator y (and x)
				dp_VIA_port_b=1;				// mux disable, dac only to x
				dp_VIA_port_a = *(2+u);		// dac -> x
				dp_VIA_t1_cnt_hi=0;			// start timer
				dp_VIA_shift_reg = (unsigned int)0xff;	// draw complete line

				if (scaleList>10)
				{
					while ((dp_VIA_int_flags & 0x40) == 0); // wait till timer finishes
				}
				dp_VIA_shift_reg = 0;			// all output is BLANK
			}
			else if (*u == 0) // moveTo
			{
				if ((*(u+1)!=0) || (*(u+2)!=0))
				{
					// internal moveTo
					dp_VIA_port_a = *(1+u);	// y pos to dac
					dp_VIA_cntl = (unsigned int)0xce;	// disable zero, disable all blank
					dp_VIA_port_b = 0;			// mux enable, dac to -> integrator y (and x)
					dp_VIA_port_b =1;			// mux disable, dac only to x
					dp_VIA_port_a = *(2+u);	// dac -> x
					dp_VIA_t1_cnt_hi=0;		// start timer
					while ((dp_VIA_int_flags & 0x40) == 0); // wait till timer finishes
				}
			}
			else
			{
				break;
			}
			u+=3;
		}
	} while (*u != 2);
}
#else
extern void draw_synced_list_c(
	const signed char *u,
	signed int y,
	signed int x,
	unsigned int scaleMove,
	unsigned int scaleList
	);
#endif

// font came from protel hardware, hence the name. (via Nadim el Saleh, thanks.)
// Coded with multiple arrays to minimise wasted space if we used a 2D array...
// Should really remove the initial redundant move (or accumulate moves internally and only
//  move the beam once before drawing a line)
// Beam should be positioned ready for next character after drawing each character, so
// some optimisation possible there too at the cost of fewer Reset0Ref's.

const int protel_32[/*' '*/] = { 0,15,15, 0,-15,0x6f,  2 };
const int protel_33[/*'!'*/] = { 0,15,15, -1,16,0, 0,16,0, -1,64,0, 0,-111,32,  2 };
const int protel_34[/*'"'*/] = { 0,15,15, 0,64,0, -1,32,0, 0,0,16, -1,-32,0, 0,-79,32,  2 };
const int protel_35[/*'#'*/] = { 0,15,15, 0,32,0, -1,0,64, 0,32,0, -1,0,-64, 0,32,16, -1,-96,0, 0,0,32, -1,96,0, 0,-111,48,  2 };
const int protel_36[/*'$'*/] = { 0,15,15, 0,16,0, -1,0,48, -1,16,16, -1,16,-16, -1,0,-32, -1,16,-16, -1,16,16, -1,0,48, 0,16,-32, -1,-96,0, 0,-15,64,  2 };
const int protel_37[/*'%'*/] = { 0,15,15, -1,16,0, -1,64,64, -1,16,0, 0,0,-48, -1,0,-16, -1,-16,0, -1,0,16, -1,16,0, 0,-96,48, -1,16,0, -1,0,-16, -1,-16,0, -1,0,16, 0,-15,32,  2 };
const int protel_38[/*'&'*/] = { 0,15,15, 0,32,64, -1,-32,-32, -1,0,-16, -1,16,-16, -1,16,0, -1,32,32, -1,16,0, -1,16,-16, -1,-16,-16, -1,-16,0, -1,-64,64, 0,-15,32,  2 };
const int protel_39[/*'''*/] = { 0,15,15, 0,64,0, -1,32,0, 0,-111,32,  2 };
const int protel_40[/*'('*/] = { 0,15,15, 0,96,32, -1,-32,-32, -1,-32,0, -1,-32,32, 0,-15,32,  2 };
const int protel_41[/*')'*/] = { 0,15,15, -1,32,32, -1,32,0, -1,32,-32, 0,-111,64,  2 };
const int protel_42[/*'*'*/] = { 0,15,15, 0,16,0, -1,64,64, 0,0,-32, -1,-64,0, 0,32,32, -1,0,-64, 0,32,0, -1,-64,64, 0,-31,32,  2 };
const int protel_43[/*'+'*/] = { 0,15,15, 0,48,0, -1,0,64, 0,32,-32, -1,-64,0, 0,-31,64,  2 };
const int protel_44[/*','*/] = { 0,15,15, 0,-46,-46, -1,46,46, -1,16,0, 0,-31,32,  2 };
const int protel_45[/*'-'*/] = { 0,15,15, 0,48,0, -1,0,64, 0,-63,32,  2 };
const int protel_46[/*'.'*/] = { 0,15,15, -1,16,0, 0,-31,32,  2 };
const int protel_47[/*'/'*/] = { 0,15,15, -1,16,0, -1,64,64, -1,16,0, 0,-111,32,  2 };
const int protel_48[/*'0'*/] = { 0,15,15, 0,16,0, -1,64,0, -1,16,16, -1,0,16, -1,-16,16, -1,-64,0, -1,-16,-16, -1,0,-16, -1,16,-16, 0,-31,80,  2 };
const int protel_49[/*'1'*/] = { 0,15,15, -1,0,32, 0,80,-32, -1,16,16, -1,-96,0, 0,-15,48,  2 };
const int protel_50[/*'2'*/] = { 0,15,15, 0,80,0, -1,16,16, -1,0,32, -1,-16,16, -1,-16,0, -1,-16,-16, -1,0,-32, -1,-16,-16, -1,-32,0, -1,0,64, 0,-15,32,  2 };
const int protel_51[/*'3'*/] = { 0,15,15, 0,16,0, -1,-16,16, -1,0,32, -1,16,16, -1,16,0, -1,16,-16, -1,0,-16, 0,0,16, -1,16,16, -1,16,0, -1,16,-16, -1,0,-32, -1,-16,-16, 0,-95,96,  2 };
const int protel_52[/*'4'*/] = { 0,15,15, 0,0,48, -1,96,0, -1,-48,-48, -1,-16,0, -1,0,64, 0,-47,32,  2 };
const int protel_53[/*'5'*/] = { 0,15,15, 0,16,0, -1,-16,16, -1,0,32, -1,16,16, -1,32,0, -1,16,-16, -1,0,-48, -1,32,0, -1,0,64, 0,-111,32,  2 };
const int protel_54[/*'6'*/] = { 0,15,15, 0,48,0, -1,0,48, -1,-16,16, -1,-16,0, -1,-16,-16, -1,0,-32, -1,16,-16, -1,48,0, -1,32,32, -1,0,16, 0,-111,48,  2 };
const int protel_55[/*'7'*/] = { 0,15,15, -1,16,0, -1,64,64, -1,16,0, -1,0,-64, 0,-111,96,  2 };
const int protel_56[/*'8'*/] = { 0,15,15, 0,0,16, -1,16,-16, -1,16,0, -1,16,16, -1,16,-16, -1,16,0, -1,16,16, -1,0,32, -1,-16,16, -1,-16,0, -1,-16,-16, -1,-16,16, -1,-16,0, -1,-16,-16, -1,0,-32, 0,48,0, -1,0,32, 0,-63,48,  2 };
const int protel_57[/*'9'*/] = { 0,15,15, 0,0,16, -1,0,16, -1,32,32, -1,48,0, -1,16,-16, -1,0,-32, -1,-16,-16, -1,-16,0, -1,-16,16, -1,0,48, 0,-63,32,  2 };
const int protel_58[/*':'*/] = { 0,15,15, 0,16,0, -1,16,0, 0,16,0, -1,16,0, 0,-79,32,  2 };
const int protel_59[/*';'*/] = { 0,15,15, 0,-46,-46, -1,46,46, -1,32,0, 0,16,0, -1,16,0, 0,-79,32,  2 };
const int protel_60[/*'<'*/] = { 0,15,15, 0,96,32, -1,-48,-78, -1,-48,78, 0,-15,32,  2 };
const int protel_61[/*'='*/] = { 0,15,15, 0,32,0, -1,0,64, 0,16,0, -1,0,-64, 0,-63,96,  2 };
const int protel_62[/*'>'*/] = { 0,15,15, -1,48,48, -1,48,-48, 0,-111,80,  2 };
const int protel_63[/*'?'*/] = { 0,15,15, 0,80,0, -1,16,16, -1,0,16, -1,-16,16, -1,-16,0, -1,-16,-16, -1,-16,0, 0,-16,0, -1,-16,0, 0,-15,48,  2 };
const int protel_64[/*'@'*/] = { 0,15,15, 0,80,0, -1,16,16, -1,0,32, -1,-16,16, -1,-64,0, -1,-16,-16, -1,0,-32, -1,16,-16, -1,16,0, -1,16,16, -1,-16,16, -1,-16,0, 0,-31,64,  2 };
const int protel_65[/*'A'*/] = { 0,15,15, -1,32,0, -1,64,32, -1,-64,32, -1,0,-64, 0,0,64, -1,-32,0, 0,-15,32,  2 };
const int protel_66[/*'B'*/] = { 0,15,15, -1,0,16, -1,0,32, -1,16,16, -1,16,0, -1,16,-16, -1,16,16, -1,16,0, -1,16,-16, -1,0,-48, 0,0,16, -1,-96,0, 0,48,0, -1,0,32, 0,-63,48,  2 };
const int protel_67[/*'C'*/] = { 0,15,15, 0,80,64, -1,16,-16, -1,0,-32, -1,-16,-16, -1,-64,0, -1,-16,16, -1,0,32, -1,16,16, 0,-31,32,  2 };
const int protel_68[/*'D'*/] = { 0,15,15, -1,0,48, -1,16,16, -1,64,0, -1,16,-16, -1,0,-48, 0,0,16, -1,-96,0, 0,-15,80,  2 };
const int protel_69[/*'E'*/] = { 0,15,15, 0,96,64, -1,0,-64, -1,-96,0, -1,0,64, 0,48,-64, -1,0,32, 0,-63,64,  2 };
const int protel_70[/*'F'*/] = { 0,15,15, -1,96,0, -1,0,64, 0,-48,-64, -1,0,32, 0,-63,64,  2 };
const int protel_71[/*'G'*/] = { 0,15,15, 0,96,64, -1,0,-48, -1,-16,-16, -1,-64,0, -1,-16,16, -1,0,48, -1,48,0, -1,0,-16, 0,-63,48,  2 };
const int protel_72[/*'H'*/] = { 0,15,15, -1,96,0, 0,-48,0, -1,0,64, 0,48,0, -1,-96,0, 0,-15,32,  2 };
const int protel_73[/*'I'*/] = { 0,15,15, -1,0,32, 0,0,-16, -1,96,0, 0,0,-16, -1,0,32, 0,-111,32,  2 };
const int protel_74[/*'J'*/] = { 0,15,15, 0,16,0, -1,-16,16, -1,0,32, -1,16,16, -1,80,0, 0,-111,32,  2 };
const int protel_75[/*'K'*/] = { 0,15,15, -1,96,0, 0,-48,0, -1,0,16, -1,48,48, 0,-48,-48, -1,-48,48, 0,-15,32,  2 };
const int protel_76[/*'L'*/] = { 0,15,15, 0,96,0, -1,-96,0, -1,0,64, 0,-15,32,  2 };
const int protel_77[/*'M'*/] = { 0,15,15, -1,96,0, -1,-64,32, -1,64,32, -1,-96,0, 0,-15,32,  2 };
const int protel_78[/*'N'*/] = { 0,15,15, -1,96,0, -1,-64,64, 0,64,0, -1,-96,0, 0,-15,32,  2 };
const int protel_79[/*'O'*/] = { 0,15,15, -1,96,0, -1,0,64, -1,-96,0, -1,0,-64, 0,-15,96,  2 };
const int protel_80[/*'P'*/] = { 0,15,15, -1,96,0, -1,0,48, -1,-16,16, -1,-16,0, -1,-16,-16, -1,0,-48, 0,-63,96,  2 };
const int protel_81[/*'Q'*/] = { 0,15,15, 0,16,0, -1,64,0, -1,16,16, -1,0,32, -1,-16,16, -1,-48,0, -1,-32,-32, -1,0,-16, -1,16,-16, 0,16,32, -1,-32,32, 0,-15,32,  2 };
const int protel_82[/*'R'*/] = { 0,15,15, -1,96,0, -1,0,48, -1,-16,16, -1,-16,0, -1,-16,-16, -1,0,-48, 0,0,16, -1,-48,48, 0,-15,32,  2 };
const int protel_83[/*'S'*/] = { 0,15,15, 0,16,0, -1,-16,16, -1,0,32, -1,16,16, -1,64,-64, -1,16,16, -1,0,32, -1,-16,16, 0,-95,32,  2 };
const int protel_84[/*'T'*/] = { 0,15,15, 0,96,0, -1,0,64, 0,0,-32, -1,-96,0, 0,-15,64,  2 };
const int protel_85[/*'U'*/] = { 0,15,15, 0,96,0, -1,-80,0, -1,-16,16, -1,0,32, -1,16,16, -1,80,0, 0,-111,32,  2 };
const int protel_86[/*'V'*/] = { 0,15,15, 0,96,0, -1,-96,48, -1,96,48, 0,-111,32,  2 };
const int protel_87[/*'W'*/] = { 0,15,15, 0,96,0, -1,-80,0, -1,-16,16, -1,32,32, -1,16,0, 0,-16,0, -1,-32,32, -1,16,16, -1,80,0, 0,-111,32,  2 };
const int protel_88[/*'X'*/] = { 0,15,15, -1,16,0, -1,64,64, -1,16,0, 0,0,-64, -1,-16,0, -1,-64,64, -1,-16,0, 0,-15,32,  2 };
const int protel_89[/*'Y'*/] = { 0,15,15, 0,96,0, -1,-16,0, -1,-32,32, -1,32,32, -1,16,0, 0,-48,-32, -1,-48,0, 0,-15,64,  2 };
const int protel_90[/*'Z'*/] = { 0,15,15, 0,96,0, -1,0,64, -1,-16,0, -1,-64,-64, -1,-16,0, -1,0,64, 0,-15,32,  2 };
const int protel_91[/*'['*/] = { 0,15,15, 0,96,32, -1,0,-32, -1,-96,0, -1,0,32, 0,-15,32,  2 };
const int protel_92[/*'\'*/] = { 0,15,15, 0,96,0, -1,-16,0, -1,-64,64, -1,-16,0, 0,-15,32,  2 };
const int protel_93[/*']'*/] = { 0,15,15, -1,0,32, -1,96,0, -1,0,-32, 0,-111,64,  2 };
const int protel_94[/*'^'*/] = { 0,15,15, 0,64,0, -1,32,32, -1,-32,32, 0,32,-32, -1,-96,0, 0,-15,64,  2 };
const int protel_95[/*'_'*/] = { 0,15,15, 0,-46,0, -1,0,64, 0,31,32,  2 };
const int protel_96[/*'`'*/] = { 0,15,15, 0,96,0, -1,-32,32, 0,-79,32,  2 };
const int protel_97[/*'a'*/] = { 0,15,15, 0,16,48, -1,-16,-16, -1,0,-16, -1,16,-16, -1,32,0, -1,16,16, -1,0,16, -1,-16,16, -1,-32,0, -1,-16,16, 0,-15,32,  2 };
const int protel_98[/*'b'*/] = { 0,15,15, -1,96,0, 0,-64,0, -1,32,32, -1,0,16, -1,-16,16, -1,-32,0, -1,-16,-16, -1,0,-16, -1,32,-32, 0,-47,96,  2 };
const int protel_99[/*'c'*/] = { 0,15,15, 0,64,64, -1,0,-48, -1,-16,-16, -1,-32,0, -1,-16,16, -1,0,48, 0,-15,32,  2 };
const int protel_100[/*'d'*/] = { 0,15,15, 0,16,0, -1,32,0, -1,16,16, -1,0,16, -1,-32,32, -1,-32,-32, -1,0,-16, -1,16,-16, 0,80,64, -1,-96,0, 0,-15,32,  2 };
const int protel_101[/*'e'*/] = { 0,15,15, 0,32,0, -1,0,48, -1,16,16, -1,16,-16, -1,0,-32, -1,-16,-16, -1,-32,0, -1,-16,16, -1,0,32, 0,-15,48,  2 };
const int protel_102[/*'f'*/] = { 0,15,15, 0,0,16, -1,80,0, -1,16,16, -1,0,16, -1,-16,16, 0,-32,-64, -1,0,48, 0,-63,48,  2 };
const int protel_103[/*'g'*/] = { 0,15,15, 0,-46,0, -1,-16,16, -1,0,32, -1,16,16, -1,94,0, -1,16,-16, -1,0,-32, -1,-16,-16, -1,-32,0, -1,-16,16, -1,0,48, 0,-15,32,  2 };
const int protel_104[/*'h'*/] = { 0,15,15, -1,96,0, 0,-64,0, -1,32,32, -1,0,16, -1,-16,16, -1,-48,0, 0,-15,32,  2 };
const int protel_105[/*'i'*/] = { 0,15,15, -1,48,0, 0,16,0, -1,16,0, 0,-95,32,  2 };
const int protel_106[/*'j'*/] = { 0,15,15, 0,-46,0, -1,-16,16, -1,0,16, -1,16,16, -1,94,0, 0,16,0, -1,16,0, 0,-95,32,  2 };
const int protel_107[/*'k'*/] = { 0,15,15, -1,96,0, 0,-64,0, -1,0,32, -1,32,32, 0,-32,-32, -1,-32,32, 0,-15,32,  2 };
const int protel_108[/*'l'*/] = { 0,15,15, 0,96,0, -1,-80,0, -1,-16,16, 0,-15,32,  2 };
const int protel_109[/*'m'*/] = { 0,15,15, -1,64,0, 0,-16,0, -1,16,16, -1,-16,16, -1,-16,0, 0,16,0, -1,16,16, -1,-16,16, -1,-48,0, 0,-15,32,  2 };
const int protel_110[/*'n'*/] = { 0,15,15, -1,64,0, 0,-16,0, -1,16,16, -1,0,16, -1,-16,16, -1,-48,0, 0,-15,32,  2 };
const int protel_111[/*'o'*/] = { 0,15,15, 0,16,0, -1,32,0, -1,16,16, -1,0,32, -1,-16,16, -1,-32,0, -1,-16,-16, -1,0,-32, -1,16,-16, 0,-31,96,  2 };
const int protel_112[/*'p'*/] = { 0,15,15, -1,0,48, -1,16,16, -1,32,0, -1,16,-16, -1,0,-32, -1,-16,-16, 0,16,0, -1,-126,0, 0,47,96,  2 };
const int protel_113[/*'q'*/] = { 0,15,15, 0,0,64, -1,0,-48, -1,16,-16, -1,32,0, -1,16,16, -1,0,32, -1,-16,16, 0,16,0, -1,-126,0, 0,47,32,  2 };
const int protel_114[/*'r'*/] = { 0,15,15, -1,64,0, 0,-32,0, -1,32,32, -1,0,16, -1,-16,16, 0,-63,32,  2 };
const int protel_115[/*'s'*/] = { 0,15,15, -1,0,48, -1,16,16, -1,16,-16, -1,0,-32, -1,16,-16, -1,16,16, -1,0,48, 0,-79,32,  2 };
const int protel_116[/*'t'*/] = { 0,15,15, 0,96,32, -1,-80,0, -1,-16,16, -1,16,16, 0,48,-64, -1,0,64, 0,-79,32,  2 };
const int protel_117[/*'u'*/] = { 0,15,15, 0,64,0, -1,-48,0, -1,-16,16, -1,0,16, -1,32,32, 0,32,0, -1,-64,0, 0,-15,32,  2 };
const int protel_118[/*'v'*/] = { 0,15,15, 0,64,0, -1,-64,32, -1,64,32, 0,-79,32,  2 };
const int protel_119[/*'w'*/] = { 0,15,15, 0,64,0, -1,-48,0, -1,-16,16, -1,16,16, -1,16,0, 0,-16,0, -1,-16,16, -1,16,16, -1,48,0, 0,-79,32,  2 };
const int protel_120[/*'x'*/] = { 0,15,15, -1,64,64, 0,0,-64, -1,-64,64, 0,-15,32,  2 };
const int protel_121[/*'y'*/] = { 0,15,15, 0,64,0, -1,-48,0, -1,-16,16, -1,0,16, -1,32,32, 0,32,0, -1,-110,0, -1,-16,-16, -1,0,-32, 0,47,80,  2 };
const int protel_122[/*'z'*/] = { 0,15,15, 0,64,0, -1,0,64, -1,-64,-64, -1,0,64, 0,-15,32,  2 };
const int protel_123[/*'{'*/] = { 0,15,15, 0,96,32, -1,-16,-16, -1,-16,0, -1,-16,-16, -1,-16,16, -1,-16,0, -1,-16,16, 0,-15,32,  2 };
const int protel_124[/*'|'*/] = { 0,15,15, -1,96,0, 0,-111,32,  2 };
const int protel_125[/*'}'*/] = { 0,15,15, -1,16,16, -1,16,0, -1,16,16, -1,16,-16, -1,16,0, -1,16,-16, 0,-111,64,  2 };
const int protel_126[/*'~'*/] = { 0,15,15, 0,16,0, -1,16,16, -1,0,32, -1,16,16, 0,-63,32,  2 };

const int *protel[128-32-1] = { // VLp/synched list format
  protel_32, protel_33, protel_34, protel_35, protel_36, protel_37, protel_38, protel_39,
  protel_40, protel_41, protel_42, protel_43, protel_44, protel_45, protel_46, protel_47,
  protel_48, protel_49, protel_50, protel_51, protel_52, protel_53, protel_54, protel_55,
  protel_56, protel_57, protel_58, protel_59, protel_60, protel_61, protel_62, protel_63,
  protel_64, protel_65, protel_66, protel_67, protel_68, protel_69, protel_70, protel_71,
  protel_72, protel_73, protel_74, protel_75, protel_76, protel_77, protel_78, protel_79,
  protel_80, protel_81, protel_82, protel_83, protel_84, protel_85, protel_86, protel_87,
  protel_88, protel_89, protel_90, protel_91, protel_92, protel_93, protel_94, protel_95,
  protel_96, protel_97, protel_98, protel_99, protel_100, protel_101, protel_102, protel_103,
  protel_104, protel_105, protel_106, protel_107, protel_108, protel_109, protel_110, protel_111,
  protel_112, protel_113, protel_114, protel_115, protel_116, protel_117, protel_118, protel_119,
  protel_120, protel_121, protel_122, protel_123, protel_124, protel_125, protel_126,
};

// (V and W are a bit of a nuisance but we can live with them being wider than 127.)
const unsigned int protel_width[128-32-1] = {
  0x68, 47, 63, 111, 111, 111, 111, 47, 79, 79, 111, 111, 47, 111, 47, 111, 95, 79, 111, 111, 111, 111, 111, 111, 111, 111, 47, 47, 79, 111, 95, 95,
  111, 111, 111, 111, 111, 111, 111, 111, 111, 79, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 143, 143, 111, 111, 111, 79, 111, 79, 111, 111,
  79, 111, 111, 111, 111, 111, 111, 111, 111, 47, 95, 111, 63, 111, 95, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 79, 47, 79, 111,
};

void draw_text(char *s, int x_at_move_scale, int y_at_move_scale,
                        unsigned int move_scale, unsigned int draw_scale) {
  long unsigned int text_width_at_draw_scale = 0; // width of text at draw scale
  // caller can do this.  Intensity_a(127);
  for (;;) {
    long unsigned int text_width_at_move_scale;
    char c = *s++;
    if (c == '\0') break;
    if ((c < ' ') || (c >= 127)) continue;
    // convert the width in draw_scale to move_scale for positioning next character
    // unfortunately this is an expensive calculation. (but not the reason drawing
    // vector text is slow)
    text_width_at_move_scale = (( text_width_at_draw_scale * (unsigned long int)draw_scale )
                                                           / (unsigned long int)move_scale );
    draw_synced_list_c(
      (const signed char *)protel[(unsigned int)c-32U],
      y_at_move_scale, x_at_move_scale+(int)text_width_at_move_scale, // position each character in string, for now.
      move_scale, draw_scale
    );
    text_width_at_draw_scale += protel_width[c-32]; // accumulate dx using draw_scale
  }
}