// to do: make font arrays conditional on whether they are used.
// is it better to test ifdef's or use linker/library to save space?

#include <vectrex.h>

extern int Stop_on_Errors;
static inline void InternalSetScale(unsigned int AbsScale) {
  VIA_t1_cnt_lo = AbsScale;
}

#define MODE_MOVE 1
#define MODE_DRAW 2
int mode = MODE_MOVE;

#define FONT_HERSHEY 1
#define FONT_ASTEROIDS 2
#define FONT_PROTEL 3

#ifndef _hershey_h_
#define _hershey_h_

#define CONFIG_FONT_HERSHEY 1
#define ABEND(s) do { (void) s; } while (0)
#define IN_ROM // __attribute__ ((section(".text")))

typedef unsigned int uint8_t;
typedef int int8_t;
//#include <stdint.h>

typedef struct
{
	uint8_t count;
	uint8_t width;
	int8_t points[62]; // up to 31 xy points
} hershey_char_t;

//extern const hershey_char_t hershey_simplex[];

/** \file
 * Complete ASCII Hershey Simplex font.
 *
 * http://paulbourke.net/dataformats/hershey/
 *
 * A few characters are simplified and all are stored at
 * offset ' ' (0x20).
 */
//#include "hershey_font.h"

const hershey_char_t hershey_simplex[] = {
	 { 
	    0,16, /* Ascii 32 */
        { -1 },
	},
    	 {
		8,10, /* Ascii 33 */
	    { 5,21, 5,7, -1,-1, 5,2, 4,1, 5,0, 6,1, 5,2, },
	},
	 {
	    5,16, /* Ascii 34 */
	    { 4,21, 4,14, -1,-1, 12,21, 12,14, },
	},
	 {
	   11,21, /* Ascii 35 */
	   { 11,25, 4,-7, -1,-1, 17,25, 10,-7, -1,-1, 4,12, 18,12, -1,-1, 3, 6, 17, 6,}
	},
	 {
	   26,20, /* Ascii 36 */
	    {8,25, 8,-4,-1,-1,12,25,12,-4,-1,-1,17,18,15,20,12,21, 8,21, 5,20, 3,
	   18, 3,16, 4,14, 5,13, 7,12,13,10,15, 9,16, 8,17, 6,17, 3,15, 1,12, 0,
	    8, 0, 5, 1, 3, 3,}
	},
   	{
	   31,24, /* Ascii 37 */
	   { 21,21, 3, 0,-1,-1, 8,21,10,19,10,17, 9,15, 7,14, 5,14, 3,16, 3,18, 4,
	   20, 6,21, 8,21,10,20,13,19,16,19,19,20,21,21,-1,-1,17, 7,15, 6,14, 4,
	   14, 2,16, 0,18, 0,20, 1,21, 3,21, 5,19, 7,17, 7, },
	},
	{
#if 0
   34,26, /* Ascii 38 */
   {23,12,23,13,22,14,21,14,20,13,19,11,17, 6,15, 3,13, 1,11, 0, 7, 0, 5,
    1, 4, 2, 3, 4, 3, 6, 4, 8, 5, 9,12,13,13,14,14,16,14,18,13,20,11,21,
    9,20, 8,18, 8,16, 9,13,11,10,16, 3,18, 1,20, 0,22, 0,23, 1,23, 2,-1,}
#else
	    0,16, /* Ascii 38 */
        { -1 },
#endif
	},
	{
    7,10, /* Ascii 39 */
    { 5,19, 4,20, 5,21, 6,20, 6,18, 5,16, 4,15, },
	},
	{
   10,14, /* Ascii 40 */
   { 11,25, 9,23, 7,20, 5,16, 4,11, 4, 7, 5, 2, 7,-2, 9,-5,11,-7, },
	},
	{
   10,14, /* Ascii 41 */
    {3,25, 5,23, 7,20, 9,16,10,11,10, 7, 9, 2, 7,-2, 5,-5, 3,-7,-1,-1,-1,}
	},
	{
    8,16, /* Ascii 42 */
    {8,21, 8, 9,-1,-1, 3,18,13,12,-1,-1,13,18, 3,12,-1,-1,-1,-1,-1,-1,-1,}
	},
	{
    5,26, /* Ascii 43 */
   {13,18,13, 0,-1,-1, 4, 9,22, 9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,}
	},
	{
    8,10, /* Ascii 44 */
    {6, 1, 5, 0, 4, 1, 5, 2, 6, 1, 6,-1, 5,-3, 4,-4,-1,-1,-1,-1,-1,-1,-1,}
	},
	{
    2,26, /* Ascii 45 */
    {4, 9,22, 9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,}
	},
	{
    5,10, /* Ascii 46 */
    {5, 2, 4, 1, 5, 0, 6, 1, 5, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,}
	},
	{
    2,22, /* Ascii 47 */
   {20,25, 2,-7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,}
	},
	{
   17,20, /* Ascii 48 */
    {9,21, 6,20, 4,17, 3,12, 3, 9, 4, 4, 6, 1, 9, 0,11, 0,14, 1,16, 4,17,
    9,17,12,16,17,14,20,11,21, 9,21,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,}
	},
	{
    4,20, /* Ascii 49 */
    {6,17, 8,18,11,21,11, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,}
	},
	{
   14,20, /* Ascii 50 */
    {4,16, 4,17, 5,19, 6,20, 8,21,12,21,14,20,15,19,16,17,16,15,15,13,13,
   10, 3, 0,17, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,}
	},
	{
   15,20, /* Ascii 51 */
    {5,21,16,21,10,13,13,13,15,12,16,11,17, 8,17, 6,16, 3,14, 1,11, 0, 8,
    0, 5, 1, 4, 2, 3, 4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,}
	},
	{
    6,20, /* Ascii 52 */
   {13,21, 3, 7,18, 7,-1,-1,13,21,13, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,}
	},
	{
   17,20, /* Ascii 53 */
   {15,21, 5,21, 4,12, 5,13, 8,14,11,14,14,13,16,11,17, 8,17, 6,16, 3,14,
    1,11, 0, 8, 0, 5, 1, 4, 2, 3, 4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,}
	},
	{
   23,20, /* Ascii 54 */
   {16,18,15,20,12,21,10,21, 7,20, 5,17, 4,12, 4, 7, 5, 3, 7, 1,10, 0,11,
    0,14, 1,16, 3,17, 6,17, 7,16,10,14,12,11,13,10,13, 7,12, 5,10, 4, 7,}
	},
	{
    5,20, /* Ascii 55 */
   {17,21, 7, 0,-1,-1, 3,21,17,21,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,}
	},
	{
   29,20, /* Ascii 56 */
    {8,21, 5,20, 4,18, 4,16, 5,14, 7,13,11,12,14,11,16, 9,17, 7,17, 4,16,
    2,15, 1,12, 0, 8, 0, 5, 1, 4, 2, 3, 4, 3, 7, 4, 9, 6,11, 9,12,13,13,
   15,14,16,16,16,18,15,20,12,21, 8,21,}
	},
	{
   23,20, /* Ascii 57 */
   {16,14,15,11,13, 9,10, 8, 9, 8, 6, 9, 4,11, 3,14, 3,15, 4,18, 6,20, 9,
   21,10,21,13,20,15,18,16,14,16, 9,15, 4,13, 1,10, 0, 8, 0, 5, 1, 4, 3,}
	},
	{
   11,10, /* Ascii 58 */
    {5,14, 4,13, 5,12, 6,13, 5,14,-1,-1, 5, 2, 4, 1, 5, 0, 6, 1, 5, 2,}
	},
	{
   14,10, /* Ascii 59 */
    {5,14, 4,13, 5,12, 6,13, 5,14,-1,-1, 6, 1, 5, 0, 4, 1, 5, 2, 6, 1, 6,
   -1, 5,-3, 4,-4,}
	},
	{
    3,24, /* Ascii 60 */
   {20,18, 4, 9,20, 0,}
	},
	{
    5,26, /* Ascii 61 */
    {4,12,22,12,-1,-1, 4, 6,22, 6,}
	},
	{
    3,24, /* Ascii 62 */
    {4,18,20, 9, 4, 0,}
	},
	{
   20,18, /* Ascii 63 */
    {3,16, 3,17, 4,19, 5,20, 7,21,11,21,13,20,14,19,15,17,15,15,14,13,13,
   12, 9,10, 9, 7,-1,-1, 9, 2, 8, 1, 9, 0,10, 1, 9, 2,}
	},
	{
#if 0
   55,27, /* Ascii 64 */
   {18,13,17,15,15,16,12,16,10,15, 9,14, 8,11, 8, 8, 9, 6,11, 5,14, 5,16,
    6,17, 8,-1,-1,12,16,10,14, 9,11, 9, 8,10, 6,11, 5,-1,-1,18,16,17, 8,
   17, 6,19, 5,21, 5,23, 7,24,10,24,12,23,15,22,17,20,19,18,20,15,21,12,
   21, 9,20, 7,19, 5,17, 4,15, 3,12, 3, 9, 4, 6, 5, 4, 7, 2, 9, 1,12, 0,
   15, 0,18, 1,20, 2,21, 3,-1,-1,19,16,18, 8,18, 6,19, 5,}
#else
	    0,16, /* Ascii 64 */
        { -1 },
#endif
	},
	{
    8,18, /* Ascii 65 */  // 8 entries.  Width 18.
    {9,21,
     1,0,
     -1,-1, // moveto:
     9,21,
     17, 0,
     -1,-1, // moveto:
     4,7,
     14,7,
     }
	},
	{
   23,21, /* Ascii 66 B */
    {4,21,
     4, 0,
     -1,-1, 4,21,
     13,21,
     16,20,
     17,19,
     18,17,
     18,15,
     17,13,
     16,12,
     13,11,
     -1,-1, 4,11,
     13,11,
     16,10,
     17, 9,
     18, 7,
     18, 4,
     17, 2,
     16, 1,
     13, 0,
     4, 0,}
	},
	{
   18,21, /* Ascii 67 */
   {18,16,17,18,15,20,13,21, 9,21, 7,20, 5,18, 4,16, 3,13, 3, 8, 4, 5, 5,
    3, 7, 1, 9, 0,13, 0,15, 1,17, 3,18, 5,}
	},
	{
   15,21, /* Ascii 68 D */
    {4,21, 4, 0,-1,-1, 4,21,11,21,14,20,16,18,17,16,18,13,18, 8,17, 5,16,
    3,14, 1,11, 0, 4, 0,}
	},
	{
   11,19, /* Ascii 69 */
    {4,21, 4, 0,-1,-1, 4,21,17,21,-1,-1, 4,11,12,11,-1,-1, 4, 0,17, 0,0}
	},
	{
    8,18, /* Ascii 70 */
    {4,21, 4, 0,-1,-1, 4,21,17,21,-1,-1, 4,11,12,11,}
	},
	{
   22,21, /* Ascii 71 */
   {18,16,17,18,15,20,13,21, 9,21, 7,20, 5,18, 4,16, 3,13, 3, 8, 4, 5, 5,
    3, 7, 1, 9, 0,13, 0,15, 1,17, 3,18, 5,18, 8,-1,-1,13, 8,18, 8,}
	},
	{
    8,22, /* Ascii 72 */
    {4,21, 4, 0,-1,-1,18,21,18, 0,-1,-1, 4,11,18,11,}
	},
	{
    2, 8, /* Ascii 73 */
    {4,21, 4, 0,}
	},
	{
   10,16, /* Ascii 74 */
   {12,21,12, 5,11, 2,10, 1, 8, 0, 6, 0, 4, 1, 3, 2, 2, 5, 2, 7,}
	},
	{
    8,21, /* Ascii 75 */
    {4,21, 4, 0,-1,-1,18,21, 4, 7,-1,-1, 9,12,18, 0,}
	},
	{
    5,17, /* Ascii 76 */
    {4,21, 4, 0,-1,-1, 4, 0,16, 0,}
	},
	{
   11,24, /* Ascii 77 */
    {4,21, 4, 0,-1,-1, 4,21,12, 0,-1,-1,20,21,12, 0,-1,-1,20,21,20, 0,}
	},
	{
    8,22, /* Ascii 78 */
    {4,21, 4, 0,-1,-1, 4,21,18, 0,-1,-1,18,21,18, 0,}
	},
	{
   21,22, /* Ascii 79 */
    {9,21, 7,20, 5,18, 4,16, 3,13, 3, 8, 4, 5, 5, 3, 7, 1, 9, 0,13, 0,15,
    1,17, 3,18, 5,19, 8,19,13,18,16,17,18,15,20,13,21, 9,21,}
	},
	{
   13,21, /* Ascii 80 */
    {4,21, 4, 0,-1,-1, 4,21,13,21,16,20,17,19,18,17,18,14,17,12,16,11,13,
   10, 4,10,}
	},
	{
   24,22, /* Ascii 81 */
    {9,21, 7,20, 5,18, 4,16, 3,13, 3, 8, 4, 5, 5, 3, 7, 1, 9, 0,13, 0,15,
    1,17, 3,18, 5,19, 8,19,13,18,16,17,18,15,20,13,21, 9,21,-1,-1,12, 4,
   18,-2,}
	},
	{
   16,21, /* Ascii 82 */
    {4,21, 4, 0,-1,-1, 4,21,13,21,16,20,17,19,18,17,18,15,17,13,16,12,13,
   11, 4,11,-1,-1,11,11,18, 0,}
	},
	{
   20,20, /* Ascii 83 */
   {17,18,15,20,12,21, 8,21, 5,20, 3,18, 3,16, 4,14, 5,13, 7,12,13,10,15,
    9,16, 8,17, 6,17, 3,15, 1,12, 0, 8, 0, 5, 1, 3, 3,}
	},
	{
    5,16, /* Ascii 84 */
    {8,21, 8, 0,-1,-1, 1,21,15,21,}
	},
	{
   10,22, /* Ascii 85 */
    {4,21, 4, 6, 5, 3, 7, 1,10, 0,12, 0,15, 1,17, 3,18, 6,18,21,}
	},
	{
    5,18, /* Ascii 86 */
    {1,21, 9, 0,-1,-1,17,21, 9, 0,}
	},
	{
   11,24, /* Ascii 87 */
    {2,21, 7, 0,-1,-1,12,21, 7, 0,-1,-1,12,21,17, 0,-1,-1,22,21,17, 0,}
	},
	{
    5,20, /* Ascii 88 */
    {3,21,17, 0,-1,-1,17,21, 3, 0,}
	},
	{
    6,18, /* Ascii 89 */
    {1,21, 9,11, 9, 0,-1,-1,17,21, 9,11,}
	},
	{
    8,20, /* Ascii 90 */
   {17,21, 3, 0,-1,-1, 3,21,17,21,-1,-1, 3, 0,17, 0,}
	},
	{
   11,14, /* Ascii 91 */
    {4,25, 4,-7,-1,-1, 5,25, 5,-7,-1,-1, 4,25,11,25,-1,-1, 4,-7,11,-7,}
	},
	{
    2,14, /* Ascii 92 */
    {0,21,14,-3,}
	},
	{
   11,14, /* Ascii 93 */
    {9,25, 9,-7,-1,-1,10,25,10,-7,-1,-1, 3,25,10,25,-1,-1, 3,-7,10,-7,}
	},
	{
   10,16, /* Ascii 94 */
    {6,15, 8,18,10,15,-1,-1, 3,12, 8,17,13,12,-1,-1, 8,17, 8, 0,}
	},
	{
    2,16, /* Ascii 95 */
    {0,-2,16,-2,}
	},
	{
    7,10, /* Ascii 96 */
    {6,21, 5,20, 4,18, 4,16, 5,15, 6,16, 5,17,}
	},
	{
   17,19, /* Ascii 97 */
   {15,14,15, 0,-1,-1,15,11,13,13,11,14, 8,14, 6,13, 4,11, 3, 8, 3, 6, 4,
    3, 6, 1, 8, 0,11, 0,13, 1,15, 3,}
	},
	{
   17,19, /* Ascii 98 */
    {4,21, 4, 0,-1,-1, 4,11, 6,13, 8,14,11,14,13,13,15,11,16, 8,16, 6,15,
    3,13, 1,11, 0, 8, 0, 6, 1, 4, 3,}
	},
	{
   14,18, /* Ascii 99 */
   {15,11,13,13,11,14, 8,14, 6,13, 4,11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0,11,
    0,13, 1,15, 3,}
	},
	{
   17,19, /* Ascii 100 */
   {15,21,15, 0,-1,-1,15,11,13,13,11,14, 8,14, 6,13, 4,11, 3, 8, 3, 6, 4,
    3, 6, 1, 8, 0,11, 0,13, 1,15, 3,}
	},
	{
   17,18, /* Ascii 101 */
    {3, 8,15, 8,15,10,14,12,13,13,11,14, 8,14, 6,13, 4,11, 3, 8, 3, 6, 4,
    3, 6, 1, 8, 0,11, 0,13, 1,15, 3,}
	},
	{
    8,12, /* Ascii 102 */
   {10,21, 8,21, 6,20, 5,17, 5, 0,-1,-1, 2,14, 9,14,}
	},
	{
   22,19, /* Ascii 103 */
   {15,14,15,-2,14,-5,13,-6,11,-7, 8,-7, 6,-6,-1,-1,15,11,13,13,11,14, 8,
   14, 6,13, 4,11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0,11, 0,13, 1,15, 3,}
	},
	{
   10,19, /* Ascii 104 */
    {4,21, 4, 0,-1,-1, 4,10, 7,13, 9,14,12,14,14,13,15,10,15, 0,} // delete key?
	},
	{
    8, 8, /* Ascii 105 */
    {3,21, 4,20, 5,21, 4,22, 3,21,-1,-1, 4,14, 4, 0,}
	},
	{
   11,10, /* Ascii 106 */
    {5,21, 6,20, 7,21, 6,22, 5,21,-1,-1, 6,14, 6,-3, 5,-6, 3,-7, 1,-7,}
	},
	{
    8,17, /* Ascii 107 */
    {4,21, 4, 0,-1,-1,14,14, 4, 4,-1,-1, 8, 8,15, 0,}
	},
	{
    2, 8, /* Ascii 108 */
    {4,21, 4, 0,}
	},
	{
   18,30, /* Ascii 109 */
    {4,14, 4, 0,-1,-1, 4,10, 7,13, 9,14,12,14,14,13,15,10,15, 0,-1,-1,15,
   10,18,13,20,14,23,14,25,13,26,10,26, 0,}
	},
	{
   10,19, /* Ascii 110 */
    {4,14, 4, 0,-1,-1, 4,10, 7,13, 9,14,12,14,14,13,15,10,15, 0,}
	},
	{
   17,19, /* Ascii 111 */
    {8,14, 6,13, 4,11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0,11, 0,13, 1,15, 3,16,
    6,16, 8,15,11,13,13,11,14, 8,14,}
	},
	{
   17,19, /* Ascii 112 */
    {4,14, 4,-7,-1,-1, 4,11, 6,13, 8,14,11,14,13,13,15,11,16, 8,16, 6,15,
    3,13, 1,11, 0, 8, 0, 6, 1, 4, 3,}
	},
	{
   17,19, /* Ascii 113 */
   {15,14,15,-7,-1,-1,15,11,13,13,11,14, 8,14, 6,13, 4,11, 3, 8, 3, 6, 4,
    3, 6, 1, 8, 0,11, 0,13, 1,15, 3,}
	},
	{
    8,13, /* Ascii 114 */
    {4,14, 4, 0,-1,-1, 4, 8, 5,11, 7,13, 9,14,12,14,}
	},
	{
   17,17, /* Ascii 115 */
   {14,11,13,13,10,14, 7,14, 4,13, 3,11, 4, 9, 6, 8,11, 7,13, 6,14, 4,14,
    3,13, 1,10, 0, 7, 0, 4, 1, 3, 3,}
	},
	{
    8,12, /* Ascii 116 */
    {5,21, 5, 4, 6, 1, 8, 0,10, 0,-1,-1, 2,14, 9,14,}
	},
	{
   10,19, /* Ascii 117 */
    {4,14, 4, 4, 5, 1, 7, 0,10, 0,12, 1,15, 4,-1,-1,15,14,15, 0,}
	},
	{
    5,16, /* Ascii 118 */
    {2,14, 8, 0,-1,-1,14,14, 8, 0,}
	},
	{
   11,22, /* Ascii 119 */
    {3,14, 7, 0,-1,-1,11,14, 7, 0,-1,-1,11,14,15, 0,-1,-1,19,14,15, 0,}
	},
	{
    5,17, /* Ascii 120 */
    {3,14,14, 0,-1,-1,14,14, 3, 0,}
	},
	{
    9,16, /* Ascii 121 */
    {2,14, 8, 0,-1,-1,14,14, 8, 0, 6,-4, 4,-6, 2,-7, 1,-7,}
	},
	{
    8,17, /* Ascii 122 */
   {14,14, 3, 0,-1,-1, 3,14,14,14,-1,-1, 3, 0,14, 0,}
	},
	{
#if 0
   39,14, /* Ascii 123 */
    9,25, 7,24, 6,23, 5,21, 5,19, 6,17, 7,16, 8,14, 8,12, 6,10,-1,-1, 7,
   24, 6,22, 6,20, 7,18, 8,17, 9,15, 9,13, 8,11, 4, 9, 8, 7, 9, 5, 9, 3,
    8, 1, 7, 0, 6,-2, 6,-4, 7,-6,-1,-1, 6, 8, 8, 6, 8, 4, 7, 2, 6, 1, 5,
   -1, 5,-3, 6,-5, 7,-6, 9,-7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
   -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
#else
	    0,16, /* Ascii 123 */
        { -1 },
#endif
	},
	{
    2, 8, /* Ascii 124 */
    {4,25, 4,-7,}
	},
	{
#if 0
   39,14, /* Ascii 125 */
    {5,25, 7,24, 8,23, 9,21, 9,19, 8,17, 7,16, 6,14, 6,12, 8,10,-1,-1, 7,
   24, 8,22, 8,20, 7,18, 6,17, 5,15, 5,13, 6,11,10, 9, 6, 7, 5, 5, 5, 3,
    6, 1, 7, 0, 8,-2, 8,-4, 7,-6,-1,-1, 8, 8, 6, 6, 6, 4, 7, 2, 8, 1, 9,
   -1, 9,-3, 8,-5, 7,-6, 5,-7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
   -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,}
#else
	    0,16, /* Ascii 125 */
        { -1 },
#endif
	},
	{
   23,24, /* Ascii 126 */
    {3, 6, 3, 8, 4,11, 6,12, 8,12,10,11,14, 8,16, 7,18, 7,20, 8,21,10,-1,
   -1, 3, 8, 4,10, 6,11, 8,11,10,10,14, 7,16, 6,18, 6,20, 7,21,10,21,12,}
	},
};

#endif

/** \file
 * Super simple font from Asteroids.
 *
 * http://www.edge-online.com/wp-content/uploads/edgeonline/oldfiles/images/feature_article/2009/05/asteroids2.jpg
 */

//#include <stdint.h>
//#include "asteroids_font.h"
/** \file
 * Asteroids simple font.
 */

#ifndef _asteroids_font_h_
#define _asteroids_font_h_ 1

typedef struct
{
	uint8_t points[8]; // 4 bits x, 4 bits y
} asteroids_char_t;

#define FONT_UP 0xFEU
#define FONT_LAST 0xFFU
#endif

#define P(x,y)	(((((uint8_t)x) & 0xFU) << 4U) | ((((uint8_t)y) & 0xFU)))
 
const asteroids_char_t asteroids_font[127-32] = {
/*	[' ' - 0x20] = */ {{ FONT_LAST }},
/*	['!' - 0x20] = */ {{ P(4,0), P(3,2), P(5,2), P(4,0), FONT_UP, P(4,4), P(4,12), FONT_LAST }},
/*	['"' - 0x20] = */ {{ P(2,10), P(2,6), FONT_UP, P(6,10), P(6,6), FONT_LAST }},
/*	['#' - 0x20] = */ {{ P(0,4), P(8,4), P(6,2), P(6,10), P(8,8), P(0,8), P(2,10), P(2,2) }},
/*	['$' - 0x20] = */ {{ P(6,2), P(2,6), P(6,10), FONT_UP, P(4,12), P(4,0), FONT_LAST }},
/*   ['%' - 0x20] = */ {{ P(0,0), P(8,12), FONT_UP, P(2,10), P(2,8), FONT_UP, P(6,4), P(6,2) }},
/*   ['&' - 0x20] = */ {{ P(8,0), P(4,12), P(8,8), P(0,4), P(4,0), P(8,4), FONT_LAST }},
/*   ['\'' - 0x20] = */{{ P(2,6), P(6,10), FONT_LAST }},
/*	['(' - 0x20] = */ {{ P(6,0), P(2,4), P(2,8), P(6,12), FONT_LAST }},
/*	[')' - 0x20] = */ {{ P(2,0), P(6,4), P(6,8), P(2,12), FONT_LAST }},
/*	['*' - 0x20] = */ {{ P(0,0), P(4,12), P(8,0), P(0,8), P(8,8), P(0,0), FONT_LAST }},
/*	['+' - 0x20] = */ {{ P(1,6), P(7,6), FONT_UP, P(4,9), P(4,3), FONT_LAST }},
/*	[',' - 0x20] = */ {{ P(2,0), P(4,2), FONT_LAST }},
/*	['-' - 0x20] = */ {{ P(2,6), P(6,6), FONT_LAST }},
/*	['.' - 0x20] = */ {{ P(3,0), P(4,0), FONT_LAST }},
/*	['/' - 0x20] = */ {{ P(0,0), P(8,12), FONT_LAST }},
/*	['0' - 0x20] = */ {{ P(0,0), P(8,0), P(8,12), P(0,12), P(0,0), P(8,12), FONT_LAST }},
/*	['1' - 0x20] = */ {{ P(4,0), P(4,12), P(3,10), FONT_LAST }},
/*	['2' - 0x20] = */ {{ P(0,12), P(8,12), P(8,7), P(0,5), P(0,0), P(8,0), FONT_LAST }},
/*	['3' - 0x20] = */ {{ P(0,12), P(8,12), P(8,0), P(0,0), FONT_UP, P(0,6), P(8,6), FONT_LAST }},
/*	['4' - 0x20] = */ {{ P(0,12), P(0,6), P(8,6), FONT_UP, P(8,12), P(8,0), FONT_LAST }},
/*	['5' - 0x20] = */ {{ P(0,0), P(8,0), P(8,6), P(0,7), P(0,12), P(8,12), FONT_LAST }},
/*	['6' - 0x20] = */ {{ P(0,12), P(0,0), P(8,0), P(8,5), P(0,7), FONT_LAST }},
/*	['7' - 0x20] = */ {{ P(0,12), P(8,12), P(8,6), P(4,0), FONT_LAST }},
/*	['8' - 0x20] = */ {{ P(0,0), P(8,0), P(8,12), P(0,12), P(0,0), FONT_UP, P(0,6), P(8,6), }},
/*	['9' - 0x20] = */ {{ P(8,0), P(8,12), P(0,12), P(0,7), P(8,5), FONT_LAST }},
/*	[':' - 0x20] = */ {{ P(4,9), P(4,7), FONT_UP, P(4,5), P(4,3), FONT_LAST }},
/*	[';' - 0x20] = */ {{ P(4,9), P(4,7), FONT_UP, P(4,5), P(1,2), FONT_LAST }},
/*	['<' - 0x20] = */ {{ P(6,0), P(2,6), P(6,12), FONT_LAST }},
/*	['=' - 0x20] = */ {{ P(1,4), P(7,4), FONT_UP, P(1,8), P(7,8), FONT_LAST }},
/*	['>' - 0x20] = */ {{ P(2,0), P(6,6), P(2,12), FONT_LAST }},
/*	['?' - 0x20] = */ {{ P(0,8), P(4,12), P(8,8), P(4,4), FONT_UP, P(4,1), P(4,0), FONT_LAST }},
/*	['@' - 0x20] = */ {{ P(8,4), P(4,0), P(0,4), P(0,8), P(4,12), P(8,8), P(4,4), P(3,6) }},
/*	['A' - 0x20] = */ {{ P(0,0), P(0,8), P(4,12), P(8,8), P(8,0), FONT_UP, P(0,4), P(8,4) }},
/*	['B' - 0x20] = */ {{ P(0,0), P(0,12), P(4,12), P(8,10), P(4,6), P(8,2), P(4,0), P(0,0) }},
/*	['C' - 0x20] = */ {{ P(8,0), P(0,0), P(0,12), P(8,12), FONT_LAST }},
/*	['D' - 0x20] = */ {{ P(0,0), P(0,12), P(4,12), P(8,8), P(8,4), P(4,0), P(0,0), FONT_LAST }},
/*	['E' - 0x20] = */ {{ P(8,0), P(0,0), P(0,12), P(8,12), FONT_UP, P(0,6), P(6,6), FONT_LAST }},
/*	['F' - 0x20] = */ {{ P(0,0), P(0,12), P(8,12), FONT_UP, P(0,6), P(6,6), FONT_LAST }},
/*	['G' - 0x20] = */ {{ P(6,6), P(8,4), P(8,0), P(0,0), P(0,12), P(8,12), FONT_LAST }},
/*	['H' - 0x20] = */ {{ P(0,0), P(0,12), FONT_UP, P(0,6), P(8,6), FONT_UP, P(8,12), P(8,0) }},
/*	['I' - 0x20] = */ {{ P(0,0), P(8,0), FONT_UP, P(4,0), P(4,12), FONT_UP, P(0,12), P(8,12) }},
/*	['J' - 0x20] = */ {{ P(0,4), P(4,0), P(8,0), P(8,12), FONT_LAST }},
/*	['K' - 0x20] = */ {{ P(0,0), P(0,12), FONT_UP, P(8,12), P(0,6), P(6,0), FONT_LAST }},
/*	['L' - 0x20] = */ {{ P(8,0), P(0,0), P(0,12), FONT_LAST }},
/*	['M' - 0x20] = */ {{ P(0,0), P(0,12), P(4,8), P(8,12), P(8,0), FONT_LAST }},
/*	['N' - 0x20] = */ {{ P(0,0), P(0,12), P(8,0), P(8,12), FONT_LAST }},
/*	['O' - 0x20] = */ {{ P(0,0), P(0,12), P(8,12), P(8,0), P(0,0), FONT_LAST }},
/*	['P' - 0x20] = */ {{ P(0,0), P(0,12), P(8,12), P(8,6), P(0,5), FONT_LAST }},
/*	['Q' - 0x20] = */ {{ P(0,0), P(0,12), P(8,12), P(8,4), P(0,0), FONT_UP, P(4,4), P(8,0) }},
/*	['R' - 0x20] = */ {{ P(0,0), P(0,12), P(8,12), P(8,6), P(0,5), FONT_UP, P(4,5), P(8,0) }},
/*	['S' - 0x20] = */ {{ P(0,2), P(2,0), P(8,0), P(8,5), P(0,7), P(0,12), P(6,12), P(8,10) }},
/*	['T' - 0x20] = */ {{ P(0,12), P(8,12), FONT_UP, P(4,12), P(4,0), FONT_LAST }},
/*	['U' - 0x20] = */ {{ P(0,12), P(0,2), P(4,0), P(8,2), P(8,12), FONT_LAST }},
/*	['V' - 0x20] = */ {{ P(0,12), P(4,0), P(8,12), FONT_LAST }},
/*	['W' - 0x20] = */ {{ P(0,12), P(2,0), P(4,4), P(6,0), P(8,12), FONT_LAST }},
/*	['X' - 0x20] = */ {{ P(0,0), P(8,12), FONT_UP, P(0,12), P(8,0), FONT_LAST }},
/*	['Y' - 0x20] = */ {{ P(0,12), P(4,6), P(8,12), FONT_UP, P(4,6), P(4,0), FONT_LAST }},
/*	['Z' - 0x20] = */ {{ P(0,12), P(8,12), P(0,0), P(8,0), FONT_UP, P(2,6), P(6,6), FONT_LAST }},
/*	['[' - 0x20] = */ {{ P(6,0), P(2,0), P(2,12), P(6,12), FONT_LAST }},
/*	['\\' - 0x20] =*/  {{ P(0,12), P(8,0), FONT_LAST }},
/*	[']' - 0x20] = */ {{ P(2,0), P(6,0), P(6,12), P(2,12), FONT_LAST }},
/*	['^' - 0x20] = */ {{ P(2,6), P(4,12), P(6,6), FONT_LAST }},
/*	['_' - 0x20] = */ {{ P(0,0), P(8,0), FONT_LAST }},
/*	['`' - 0x20] = */ {{ P(2,10), P(6,6), FONT_LAST }},
/*	['A' - 0x20] = */ {{ P(0,0), P(0,8), P(4,12), P(8,8), P(8,0), FONT_UP, P(0,4), P(8,4) }},
/*	['B' - 0x20] = */ {{ P(0,0), P(0,12), P(4,12), P(8,10), P(4,6), P(8,2), P(4,0), P(0,0) }},
/*	['C' - 0x20] = */ {{ P(8,0), P(0,0), P(0,12), P(8,12), FONT_LAST }},
/*	['D' - 0x20] = */ {{ P(0,0), P(0,12), P(4,12), P(8,8), P(8,4), P(4,0), P(0,0), FONT_LAST }},
/*	['E' - 0x20] = */ {{ P(8,0), P(0,0), P(0,12), P(8,12), FONT_UP, P(0,6), P(6,6), FONT_LAST }},
/*	['F' - 0x20] = */ {{ P(0,0), P(0,12), P(8,12), FONT_UP, P(0,6), P(6,6), FONT_LAST }},
/*	['G' - 0x20] = */ {{ P(6,6), P(8,4), P(8,0), P(0,0), P(0,12), P(8,12), FONT_LAST }},
/*	['H' - 0x20] = */ {{ P(0,0), P(0,12), FONT_UP, P(0,6), P(8,6), FONT_UP, P(8,12), P(8,0) }},
/*	['I' - 0x20] = */ {{ P(0,0), P(8,0), FONT_UP, P(4,0), P(4,12), FONT_UP, P(0,12), P(8,12) }},
/*	['J' - 0x20] = */ {{ P(0,4), P(4,0), P(8,0), P(8,12), FONT_LAST }},
/*	['K' - 0x20] = */ {{ P(0,0), P(0,12), FONT_UP, P(8,12), P(0,6), P(6,0), FONT_LAST }},
/*	['L' - 0x20] = */ {{ P(8,0), P(0,0), P(0,12), FONT_LAST }},
/*	['M' - 0x20] = */ {{ P(0,0), P(0,12), P(4,8), P(8,12), P(8,0), FONT_LAST }},
/*	['N' - 0x20] = */ {{ P(0,0), P(0,12), P(8,0), P(8,12), FONT_LAST }},
/*	['O' - 0x20] = */ {{ P(0,0), P(0,12), P(8,12), P(8,0), P(0,0), FONT_LAST }},
/*	['P' - 0x20] = */ {{ P(0,0), P(0,12), P(8,12), P(8,6), P(0,5), FONT_LAST }},
/*	['Q' - 0x20] = */ {{ P(0,0), P(0,12), P(8,12), P(8,4), P(0,0), FONT_UP, P(4,4), P(8,0) }},
/*	['R' - 0x20] = */ {{ P(0,0), P(0,12), P(8,12), P(8,6), P(0,5), FONT_UP, P(4,5), P(8,0) }},
/*	['S' - 0x20] = */ {{ P(0,2), P(2,0), P(8,0), P(8,5), P(0,7), P(0,12), P(6,12), P(8,10) }},
/*	['T' - 0x20] = */ {{ P(0,12), P(8,12), FONT_UP, P(4,12), P(4,0), FONT_LAST }},
/*	['U' - 0x20] = */ {{ P(0,12), P(0,2), P(4,0), P(8,2), P(8,12), FONT_LAST }},
/*	['V' - 0x20] = */ {{ P(0,12), P(4,0), P(8,12), FONT_LAST }},
/*	['W' - 0x20] = */ {{ P(0,12), P(2,0), P(4,4), P(6,0), P(8,12), FONT_LAST }},
/*	['X' - 0x20] = */ {{ P(0,0), P(8,12), FONT_UP, P(0,12), P(8,0), FONT_LAST }},
/*	['Y' - 0x20] = */ {{ P(0,12), P(4,6), P(8,12), FONT_UP, P(4,6), P(4,0), FONT_LAST }},
/*	['Z' - 0x20] = */ {{ P(0,12), P(8,12), P(0,0), P(8,0), FONT_UP, P(2,6), P(6,6), FONT_LAST }},
/*	['{' - 0x20] = */ {{ P(6,0), P(4,2), P(4,10), P(6,12), FONT_UP, P(2,6), P(4,6), FONT_LAST }},
/*	['|' - 0x20] = */ {{ P(4,0), P(4,5), FONT_UP, P(4,6), P(4,12), FONT_LAST }},
/*	['}' - 0x20] = */ {{ P(4,0), P(6,2), P(6,10), P(4,12), FONT_UP, P(6,6), P(8,6), FONT_LAST }},
/*	['~' - 0x20] = */ {{ P(0,4), P(2,8), P(6,4), P(8,8), FONT_LAST }},
};


//static int last = 0;
static long pendingx = 0L, pendingy = 0L;
static long beam_x = 0L, beam_y = 0L;

static inline void movetoabs(int x, int y) {
  pendingx = (long)x; pendingy = (long)y;
}

static inline void movetorel(int dx, int dy) {
  pendingx += (long)dx; pendingy += (long)dy;
}


static int lines_without_move = 0;

void force_move(void) {
  if ((beam_x != pendingx) || (beam_y != pendingy)) {
    if (mode == MODE_MOVE) {
      Reset0Ref(); // too many. could reduce.
      Moveto_d((int)(beam_y = pendingy), (int)(beam_x = pendingx));
      lines_without_move = 0;
    } else if (mode == MODE_DRAW) {
      // do the same but with rel moves and no Reset0Ref()
      Moveto_d((int)(pendingy-beam_y), (int)(pendingx-beam_x)); lines_without_move += 1;
      beam_x = pendingx; beam_y = pendingy;
    }
  }
}

void DrawMode(void) {
  pendingx = 0L, pendingy = 0L;
  beam_x = 0L, beam_y = 0L;
  mode = MODE_DRAW;
}

void MoveMode(void) {
  pendingx = 0L, pendingy = 0L;
  beam_x = 0L, beam_y = 0L;
  mode = MODE_MOVE;
  Reset0Ref();
}


static inline void linetorel(int dy, int dx) {
  if (((beam_x != pendingx) || (beam_y != pendingy)) && (lines_without_move > 2)) {
    if (mode == MODE_MOVE) {
      Reset0Ref(); // too many. could reduce.
      Moveto_d((int)(beam_y = pendingy), (int)(beam_x = pendingx));
      lines_without_move = 0;
    } else if (mode == MODE_DRAW) {
      Moveto_d((int)(pendingy-beam_y), (int)(pendingx-beam_x)); lines_without_move += 1;
      beam_x = pendingx; beam_y = pendingy;
    }
  }
  Draw_Line_d(dy, dx); lines_without_move += 1;
  pendingx += (long)dx; pendingy += (long)dy;
  beam_x = pendingx; beam_y = pendingy;
}
#ifdef SELDOM
static void linetoabs(int x, int y) {
  //if ((beam_x != pendingx) || (beam_y != pendingy)) {
    //if (lines_without_move >= 3) {
    if (mode == MODE_MOVE) {
      Reset0Ref(); // Serious overkill but looks awful without it :-(
      Moveto_d((int)(beam_y = pendingy), (int)(beam_x = pendingx));
      lines_without_move = 0;
    } else if (mode == MODE_DRAW) {
      // it's only absolute relative to the 0,0 origin of this character.
      if ((pendingy != beam_y) || (pendingx != beam_x)) {
        Moveto_d((int)(pendingy-beam_y), (int)(pendingx-beam_x)); lines_without_move += 1;
        beam_x = pendingx; beam_y = pendingy;
      }
    }
    //} else {
      //Moveto_d((int)(pendingy-beam_y), (int)(pendingx-beam_x));
      //beam_x = pendingx; beam_y = pendingy;
    //}
  //}
  Draw_Line_d((int)(y-beam_y), (int)(x-beam_x)); lines_without_move += 1;
  beam_x = pendingx = (long)x; beam_y = pendingy = (long)y;
}
#endif
#define moveto(x,y) movetoabs(x,y)
#define lineto(x,y) linetoabs(x,y)

// A very quick hack of Nadim El-Saleh's java code for use in C
// on the Vectrex.  Obviously needs some support code to be added.

//  moveAbs and lineAbs will be absolute in terms of a 0,0 origin
// for the current character, which will have to be added.  Named
// that way to distinguish them from being relative to the end of
// the last move rather than being relative to the origin of the
// character.

// A better optimisation would be to reduce the parameters to the
// first digit (eg 0f -> 1, 3f -> 4, etc) and convert everything to
// a packed array.  Perhaps use 0,0 as a shift code to indicate what
// follows is a move rather than a line?

#ifdef NEVER
#define moveAbs(x,y) movetoabs(x,y)
#define lineAbs(x,y) linetoabs(x,y)
#define moveRel(x,y) movetorel(x,y)
#define lineRel(x,y) linetorel(x,y)
#else
static int lastx = 0, lasty = 0;
#define RESET_FREQ 6   // 4 if not realigning on moves...
#define REALIGN_ON_MOVE 1
static int forced_realignment = RESET_FREQ;
static inline void xxmovetoabs(unsigned int x, unsigned int y, /* at draw scale */
                             int virtual_origin_x, int virtual_origin_y, /* at move scale */
                             int move_scale, int draw_scale) {
  if (REALIGN_ON_MOVE || --forced_realignment==0) {
    forced_realignment = RESET_FREQ;
    InternalSetScale((unsigned int)move_scale);
    Reset0Ref();
    Moveto_d(virtual_origin_y,virtual_origin_x);
    InternalSetScale((unsigned int)draw_scale);
    Moveto_d(lasty=(int)y,lastx=(int)x);
  } else { // broken
    InternalSetScale((unsigned int)draw_scale);
    Moveto_d((int)y-lasty,(int)x-lastx);
    lasty=(int)y;lastx=(int)x;
  }
}

static inline void xxmovetorel(unsigned int dx, unsigned int dy, /* at draw scale */
                             int virtual_origin_x, int virtual_origin_y, /* at move scale */
                             int move_scale, int draw_scale) {
  if (--forced_realignment==0) {
    forced_realignment = RESET_FREQ;
    InternalSetScale((unsigned int)move_scale);
    Reset0Ref();
    Moveto_d(virtual_origin_y,virtual_origin_x);
  }
  InternalSetScale((unsigned int)draw_scale);
  Moveto_d(lasty=lasty+(int)dy,lastx=lastx+(int)dx);
}

static inline void xxlinetoabs(unsigned int x, unsigned int y, /* at draw scale */
                             int virtual_origin_x, int virtual_origin_y, /* at move scale */
                            int move_scale, int draw_scale) {
  if (--forced_realignment==0) {  //bad
    forced_realignment = RESET_FREQ;
    InternalSetScale((unsigned int)draw_scale);
    Draw_Line_d((int)y-lasty,(int)x-lastx);
    InternalSetScale((unsigned int)move_scale);
    Reset0Ref();
    Moveto_d(virtual_origin_y,virtual_origin_x);
    InternalSetScale((unsigned int)draw_scale);
    Moveto_d(lasty=(int)y,lastx=(int)x);
  } else {
    InternalSetScale((unsigned int)draw_scale);
    Draw_Line_d((int)y-lasty,(int)x-lastx);
    lasty=(int)y; lastx=(int)x;
  }
}

static inline void xxlinetorel(unsigned int dx, unsigned int dy, /* at draw scale */
                             int virtual_origin_x, int virtual_origin_y, /* at move scale */
                             int move_scale, int draw_scale) {
  if (--forced_realignment==0) {
    forced_realignment = RESET_FREQ;
    InternalSetScale((unsigned int)draw_scale);
    Draw_Line_d((int)dy,(int)dx);
    InternalSetScale((unsigned int)move_scale);
    Reset0Ref();
    Moveto_d(virtual_origin_y,virtual_origin_x);
    InternalSetScale((unsigned int)draw_scale);
    Moveto_d(lasty=lasty+(int)dy,lastx=lastx+(int)dx);
  } else {
    InternalSetScale((unsigned int)draw_scale);
    Draw_Line_d(lasty=lasty+(int)dy,lastx=lastx+(int)dx);
  }
}

#define moveAbs(x,y) xxmovetoabs((unsigned int)x,(unsigned int)y,virtual_origin_x,virtual_origin_y,move_scale,draw_scale)
#define lineAbs(x,y) xxlinetoabs((unsigned int)x,(unsigned int)y,virtual_origin_x,virtual_origin_y,move_scale,draw_scale)
#define moveRel(x,y) xxmovetorel((unsigned int)x,(unsigned int)y,virtual_origin_x,virtual_origin_y,move_scale,draw_scale)
#define lineRel(x,y) xxlinetorel((unsigned int)x,(unsigned int)y,virtual_origin_x,virtual_origin_y,move_scale,draw_scale)
#endif

// still work to do, to position string and letters within a string
uint8_t Protel(char charToPlot, int virtual_origin_x, int virtual_origin_y,
                                int move_scale, int draw_scale) {
  // this one includes lower case!
  // to do: final move to (relative) y=0 so text does not creep upwards
  Reset0Ref();
  InternalSetScale((unsigned int)move_scale);
  Moveto_d(virtual_origin_y,virtual_origin_x);
  lastx=0; lasty=0;
  moveAbs(0x0f,0x0f);	// min gap between letters, and sometimes starting position
  switch(charToPlot) {

    case 'A':
      lineAbs(0x0f,0x2f);
      lineAbs(0x2f,0x6f);
      lineAbs(0x4f,0x2f);
      lineAbs(0x0f,0x2f);
      moveAbs(0x4f,0x2f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'B':
      lineAbs(0x1f,0x0f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x4f,0x2f);
      lineAbs(0x3f,0x3f);
      lineAbs(0x4f,0x4f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x3f,0x6f);
      lineAbs(0x0f,0x6f);
      moveAbs(0x1f,0x6f);
      lineAbs(0x1f,0x0f);
      moveAbs(0x1f,0x3f);
      lineAbs(0x3f,0x3f);
      moveAbs(0x6f,0x0);
      break;
    case 'C':
      moveAbs(0x4f,0x5f);
      lineAbs(0x3f,0x6f);
      lineAbs(0x1f,0x6f);
      lineAbs(0x0f,0x5f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x4f,0x1f);
      moveAbs(0x6f,0x0);
      break;
    case 'D':
      lineAbs(0x3f,0x0f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x3f,0x6f);
      lineAbs(0x0f,0x6f);
      moveAbs(0x1f,0x6f);
      lineAbs(0x1f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'E':
      moveAbs(0x4f,0x6f);
      lineAbs(0x0f,0x6f);
      lineAbs(0x0f,0x0f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x0f,0x3f);
      lineAbs(0x2f,0x3f);
      moveAbs(0x6f,0x0);
      break;
    case 'F':
      lineAbs(0x0f,0x6f);
      lineAbs(0x4f,0x6f);
      moveAbs(0x0f,0x3f);
      lineAbs(0x2f,0x3f);
      moveAbs(0x6f,0x0);
      break;
    case 'G':
      moveAbs(0x4f,0x6f);
      lineAbs(0x1f,0x6f);
      lineAbs(0x0f,0x5f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x4f,0x0f);
      lineAbs(0x4f,0x3f);
      lineAbs(0x3f,0x3f);
      moveAbs(0x6f,0x0);
      break;
    case 'H':
      lineAbs(0x0f,0x6f);
      moveAbs(0x0f,0x3f);
      lineAbs(0x4f,0x3f);
      moveAbs(0x4f,0x6f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'I':
      lineAbs(0x2f,0x0f);
      moveAbs(0x1f,0x0f);
      lineAbs(0x1f,0x6f);
      moveAbs(0x0f,0x6f);
      lineAbs(0x2f,0x6f);
      moveAbs(0x4f,0x0);
      return 0x4f;
      //break;
    case 'J':
      moveAbs(0x0f,0x1f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x4f,0x6f);
      moveAbs(0x6f,0x0);
      break;
    case 'K':
      lineAbs(0x0f,0x6f);
      moveAbs(0x0f,0x3f);
      lineAbs(0x1f,0x3f);
      lineAbs(0x4f,0x6f);
      moveAbs(0x1f,0x3f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'L':
      moveAbs(0x0f,0x6f);
      lineAbs(0x0f,0x0f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'M':
      lineAbs(0x0f,0x6f);
      lineAbs(0x2f,0x2f);
      lineAbs(0x4f,0x6f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'N':
      lineAbs(0x0f,0x6f);
      lineAbs(0x4f,0x2f);
      moveAbs(0x4f,0x6f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'O':
      lineAbs(0x0f,0x6f);
      lineAbs(0x4f,0x6f);
      lineAbs(0x4f,0x0f);
      lineAbs(0x0f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'P':
      lineAbs(0x0f,0x6f);
      lineAbs(0x3f,0x6f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x4f,0x4f);
      lineAbs(0x3f,0x3f);
      lineAbs(0x0f,0x3f);
      moveAbs(0x6f,0x0);
      break;
    case 'Q':
      moveAbs(0x0f,0x1f);
      lineAbs(0x0f,0x5f);
      lineAbs(0x1f,0x6f);
      lineAbs(0x3f,0x6f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x4f,0x2f);
      lineAbs(0x2f,0x0f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x0f,0x1f);
      moveAbs(0x2f,0x2f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'R':
      lineAbs(0x0f,0x6f);
      lineAbs(0x3f,0x6f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x4f,0x4f);
      lineAbs(0x3f,0x3f);
      lineAbs(0x0f,0x3f);
      moveAbs(0x1f,0x3f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'S':
      moveAbs(0x0f,0x1f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x0f,0x5f);
      lineAbs(0x1f,0x6f);
      lineAbs(0x3f,0x6f);
      lineAbs(0x4f,0x5f);
      moveAbs(0x6f,0x0);
      break;
    case 'T':
      moveAbs(0x0f,0x6f);
      lineAbs(0x4f,0x6f);
      moveAbs(0x2f,0x6f);
      lineAbs(0x2f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'U':
      moveAbs(0x0f,0x6f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x4f,0x6f);
      moveAbs(0x6f,0x0);
      break;
    case 'V':
      moveAbs(0x0f,0x6f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x6f,0x6f);
    /*moveAbs(0x8f,0x0f);*/ moveAbs(0x7f,0x0); moveRel(0x10, 0);
      return 0x8fU;
      //break;
    case 'W':
      moveAbs(0x0f,0x6f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x3f,0x2f);
      lineAbs(0x3f,0x3f);
      moveAbs(0x3f,0x2f);
      lineAbs(0x5f,0x0f);
      lineAbs(0x6f,0x1f);
      lineAbs(0x6f,0x6f);
    /*moveAbs(0x8f,0x0f);*/ moveAbs(0x7f,0x0); moveRel(0x10, 0);
      return 0x8fU;
      // break;
    case 'X':
      lineAbs(0x0f,0x1f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x4f,0x6f);
      moveAbs(0x0f,0x6f);
      lineAbs(0x0f,0x5f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'Y':
      moveAbs(0x0f,0x6f);
      lineAbs(0x0f,0x5f);
      lineAbs(0x2f,0x3f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x4f,0x6f);
      moveAbs(0x2f,0x3f);
      lineAbs(0x2f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'Z':
      moveAbs(0x0f,0x6f);
      lineAbs(0x4f,0x6f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x0f,0x0f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;

    case 'a':
      moveAbs(0x3f,0x1f);
      lineAbs(0x2f,0x0f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x0f,0x3f);
      lineAbs(0x1f,0x4f);
      lineAbs(0x2f,0x4f);
      lineAbs(0x3f,0x3f);
      lineAbs(0x3f,0x1f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'b':
      lineAbs(0x0f,0x6f);
      moveAbs(0x0f,0x2f);
      lineAbs(0x2f,0x4f);
      lineAbs(0x3f,0x4f);
      lineAbs(0x4f,0x3f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x2f,0x0f);
      lineAbs(0x0f,0x2f);
      moveAbs(0x6f,0x0);
      break;
    case 'c':
      moveAbs(0x4f,0x4f);
      lineAbs(0x1f,0x4f);
      lineAbs(0x0f,0x3f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'd':
      moveAbs(0x0f,0x1f);
      lineAbs(0x0f,0x3f);
      lineAbs(0x1f,0x4f);
      lineAbs(0x2f,0x4f);
      lineAbs(0x4f,0x2f);
      lineAbs(0x2f,0x0f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x0f,0x1f);
      moveAbs(0x4f,0x6f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'e':
      moveAbs(0x0f,0x2f);
      lineAbs(0x3f,0x2f);
      lineAbs(0x4f,0x3f);
      lineAbs(0x3f,0x4f);
      lineAbs(0x1f,0x4f);
      lineAbs(0x0f,0x3f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x3f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'f':
      moveAbs(0x1f,0x0f);
      lineAbs(0x1f,0x5f);
      lineAbs(0x2f,0x6f);
      lineAbs(0x3f,0x6f);
      lineAbs(0x4f,0x5f);
      moveAbs(0x0f,0x3f);
      lineAbs(0x3f,0x3f);
      moveAbs(0x6f,0x0);
      break;
    case 'g':
      moveAbs(0x0f,-0x1f);
      lineAbs(0x1f,-0x2f);
      lineAbs(0x3f,-0x2f);
      lineAbs(0x4f,-0x1f);
      lineAbs(0x4f,0x3f);
      lineAbs(0x3f,0x4f);
      lineAbs(0x1f,0x4f);
      lineAbs(0x0f,0x3f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'h':
      lineAbs(0x0f,0x6f);
      moveAbs(0x0f,0x2f);
      lineAbs(0x2f,0x4f);
      lineAbs(0x3f,0x4f);
      lineAbs(0x4f,0x3f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'i':
      lineAbs(0x0f,0x3f);
      moveAbs(0x0f,0x4f);
      lineAbs(0x0f,0x5f);
      moveAbs(0x2f,0x0);
      return 0x2f;
      //break;
    case 'j':
      moveAbs(0x0f,-0x1f);
      lineAbs(0x1f,-0x2f);
      lineAbs(0x2f,-0x2f);
      lineAbs(0x3f,-0x1f);
      lineAbs(0x3f,0x3f);
      moveAbs(0x3f,0x4f);
      lineAbs(0x3f,0x5f);
      moveAbs(0x5f,0x0);
      return 0x5f;
      //break;
    case 'k':
      lineAbs(0x0f,0x6f);
      moveAbs(0x0f,0x2f);
      lineAbs(0x2f,0x2f);
      lineAbs(0x4f,0x4f);
      moveAbs(0x2f,0x2f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'l':
      moveAbs(0x0f,0x6f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x1f,0x0f);
      moveAbs(0x3f,0x0);
      return 0x3f;
      break;
    case 'm':
      lineAbs(0x0f,0x4f);
      moveAbs(0x0f,0x3f);
      lineAbs(0x1f,0x4f);
      lineAbs(0x2f,0x3f);
      lineAbs(0x2f,0x2f);
      moveAbs(0x2f,0x3f);
      lineAbs(0x3f,0x4f);
      lineAbs(0x4f,0x3f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'n':
      lineAbs(0x0f,0x4f);
      moveAbs(0x0f,0x3f);
      lineAbs(0x1f,0x4f);
      lineAbs(0x2f,0x4f);
      lineAbs(0x3f,0x3f);
      lineAbs(0x3f,0x0f);
      moveAbs(0x5f,0x0);
      return 0x5f;
      break;
    case 'o':
      moveAbs(0x0f,0x1f);
      lineAbs(0x0f,0x3f);
      lineAbs(0x1f,0x4f);
      lineAbs(0x3f,0x4f);
      lineAbs(0x4f,0x3f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x0f,0x1f);
      moveAbs(0x6f,0x0);
      break;
    case 'p':
      lineAbs(0x3f,0x0f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x4f,0x3f);
      lineAbs(0x3f,0x4f);
      lineAbs(0x1f,0x4f);
      lineAbs(0x0f,0x3f);
      moveAbs(0x0f,0x4f);
      lineAbs(0x0f,-0x2f);
      moveAbs(0x6f,0x0);
      break;
    case 'q':
      moveAbs(0x4f,0x0f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x0f,0x3f);
      lineAbs(0x1f,0x4f);
      lineAbs(0x3f,0x4f);
      lineAbs(0x4f,0x3f);
      moveAbs(0x4f,0x4f);
      lineAbs(0x4f,-0x2f);
      moveAbs(0x6f,0x0);
      break;
    case 'r':
      lineAbs(0x0f,0x4f);
      moveAbs(0x0f,0x2f);
      lineAbs(0x2f,0x4f);
      lineAbs(0x3f,0x4f);
      lineAbs(0x4f,0x3f);
      moveAbs(0x6f,0x0);
      break;
    case 's':
      lineAbs(0x3f,0x0f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x3f,0x2f);
      lineAbs(0x1f,0x2f);
      lineAbs(0x0f,0x3f);
      lineAbs(0x1f,0x4f);
      lineAbs(0x4f,0x4f);
      moveAbs(0x6f,0x0);
      break;
    case 't':
      moveAbs(0x2f,0x6f);
      lineAbs(0x2f,0x1f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x4f,0x1f);
      moveAbs(0x0f,0x4f);
      lineAbs(0x4f,0x4f);
      moveAbs(0x6f,0x0);
      break;
    case 'u':
      moveAbs(0x0f,0x4f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x2f,0x0f);
      lineAbs(0x4f,0x2f);
      moveAbs(0x4f,0x4f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'v':
      moveAbs(0x0f,0x4f);
      lineAbs(0x2f,0x0f);
      lineAbs(0x4f,0x4f);
      moveAbs(0x6f,0x0);
      break;
    case 'w':
      moveAbs(0x0f,0x4f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x2f,0x1f);
      lineAbs(0x2f,0x2f);
      moveAbs(0x2f,0x1f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x4f,0x4f);
      moveAbs(0x6f,0x0);
      break;
    case 'x':
      lineAbs(0x4f,0x4f);
      moveAbs(0x0f,0x4f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case 'y':
      moveAbs(0x0f,0x4f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x2f,0x0f);
      lineAbs(0x4f,0x2f);
      moveAbs(0x4f,0x4f);
      lineAbs(0x4f,-0x1f);
      lineAbs(0x3f,-0x2f);
      lineAbs(0x1f,-0x2f);
      moveAbs(0x6f,0x0);
      break;
    case 'z':
      moveAbs(0x0f,0x4f);
      lineAbs(0x4f,0x4f);
      lineAbs(0x0f,0x0f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;

    case '0':
      moveAbs(0x0f,0x1f);
      lineAbs(0x0f,0x5f);
      lineAbs(0x1f,0x6f);
      lineAbs(0x2f,0x6f);
      lineAbs(0x3f,0x5f);
      lineAbs(0x3f,0x1f);
      lineAbs(0x2f,0x0f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x0f,0x1f);
      moveAbs(0x5f,0x0);
      return 0x5f;
      //break;
    case '1':
      lineAbs(0x2f,0x0f);
      moveAbs(0x0f,0x5f);
      lineAbs(0x1f,0x6f);
      lineAbs(0x1f,0x0f);
      moveAbs(0x4f,0x0);
      return 0x4f;
      //break;
    case '2':
      moveAbs(0x0f,0x5f);
      lineAbs(0x1f,0x6f);
      lineAbs(0x3f,0x6f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x4f,0x4f);
      lineAbs(0x3f,0x3f);
      lineAbs(0x1f,0x3f);
      lineAbs(0x0f,0x2f);
      lineAbs(0x0f,0x0f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case '3':
      moveAbs(0x0f,0x1f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x4f,0x2f);
      lineAbs(0x3f,0x3f);
      lineAbs(0x2f,0x3f);
      moveAbs(0x3f,0x3f);
      lineAbs(0x4f,0x4f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x3f,0x6f);
      lineAbs(0x1f,0x6f);
      lineAbs(0x0f,0x5f);
      moveAbs(0x6f,0x0);
      break;
    case '4':
      moveAbs(0x3f,0x0f);
      lineAbs(0x3f,0x6f);
      lineAbs(0x0f,0x3f);
      lineAbs(0x0f,0x2f);
      lineAbs(0x4f,0x2f);
      moveAbs(0x6f,0x0);
      break;
    case '5':
      moveAbs(0x0f,0x1f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x4f,0x3f);
      lineAbs(0x3f,0x4f);
      lineAbs(0x0f,0x4f);
      lineAbs(0x0f,0x6f);
      lineAbs(0x4f,0x6f);
      moveAbs(0x6f,0x0);
      break;
    case '6':
      moveAbs(0x0f,0x3f);
      lineAbs(0x3f,0x3f);
      lineAbs(0x4f,0x2f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x0f,0x4f);
      lineAbs(0x2f,0x6f);
      lineAbs(0x3f,0x6f);
      moveAbs(0x6f,0x0);
      break;
    case '7':
      lineAbs(0x0f,0x1f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x4f,0x6f);
      lineAbs(0x0f,0x6f);
      moveAbs(0x6f,0x0);
      break;
    case '8':
      moveAbs(0x1f,0x0f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x0f,0x2f);
      lineAbs(0x1f,0x3f);
      lineAbs(0x0f,0x4f);
      lineAbs(0x0f,0x5f);
      lineAbs(0x1f,0x6f);
      lineAbs(0x3f,0x6f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x4f,0x4f);
      lineAbs(0x3f,0x3f);
      lineAbs(0x4f,0x2f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x1f,0x0f);
      moveAbs(0x1f,0x3f);
      lineAbs(0x3f,0x3f);
      moveAbs(0x6f,0x0);
      break;
    case '9':
      moveAbs(0x1f,0x0f);
      lineAbs(0x2f,0x0f);
      lineAbs(0x4f,0x2f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x3f,0x6f);
      lineAbs(0x1f,0x6f);
      lineAbs(0x0f,0x5f);
      lineAbs(0x0f,0x4f);
      lineAbs(0x1f,0x3f);
      lineAbs(0x4f,0x3f);
      moveAbs(0x6f,0x0);
      break;

    case '/':
      lineAbs(0x0f,0x1f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x4f,0x6f);
      moveAbs(0x6f,0x0);
      break;
    case '?':
      moveAbs(0x0f,0x5f);
      lineAbs(0x1f,0x6f);
      lineAbs(0x2f,0x6f);
      lineAbs(0x3f,0x5f);
      lineAbs(0x3f,0x4f);
      lineAbs(0x2f,0x3f);
      lineAbs(0x2f,0x2f);
      moveAbs(0x2f,0x1f);
      lineAbs(0x2f,0x0f);
      moveAbs(0x5f,0x0);
      return 0x5f;
      //break;
    case ';':
      moveAbs(-0x1f,-0x1f);
      lineAbs(0x0f,0x0f);
      lineAbs(0x0f,0x2f);
      moveAbs(0x0f,0x3f);
      lineAbs(0x0f,0x4f);
      moveAbs(0x2f,0x0);
      return 0x2f;
      //break;
    case ':':
      moveAbs(0x0f,0x1f);
      lineAbs(0x0f,0x2f);
      moveAbs(0x0f,0x3f);
      lineAbs(0x0f,0x4f);
      moveAbs(0x2f,0x0);
      return 0x2f;
      //break;
    case '\'':
      moveAbs(0x0f,0x4f);
      lineAbs(0x0f,0x6f);
      moveAbs(0x2f,0x0);
      return 0x2f;
      //break;
    case '"':
      moveAbs(0x0f,0x4f);
      lineAbs(0x0f,0x6f);
      moveAbs(0x1f,0x6f);
      lineAbs(0x1f,0x4f);
      moveAbs(0x3f,0x0);
      return 0x3f;
      //break;
    case '[':
      moveAbs(0x2f,0x6f);
      lineAbs(0x0f,0x6f);
      lineAbs(0x0f,0x0f);
      lineAbs(0x2f,0x0f);
      moveAbs(0x4f,0x0);
      return 0x4f;
      //break;
    case '{':
      moveAbs(0x2f,0x6f);
      lineAbs(0x1f,0x5f);
      lineAbs(0x1f,0x4f);
      lineAbs(0x0f,0x3f);
      lineAbs(0x1f,0x2f);
      lineAbs(0x1f,0x1f);
      lineAbs(0x2f,0x0f);
      moveAbs(0x4f,0x0);
      break;
    case ']':
      lineAbs(0x2f,0x0f);
      lineAbs(0x2f,0x6f);
      lineAbs(0x0f,0x6f);
      moveAbs(0x4f,0x0);
      break;
    case '}':
      lineAbs(0x1f,0x1f);
      lineAbs(0x1f,0x2f);
      lineAbs(0x2f,0x3f);
      lineAbs(0x1f,0x4f);
      lineAbs(0x1f,0x5f);
      lineAbs(0x0f,0x6f);
      moveAbs(0x4f,0x0);
      return 0x4f;
      //break;
    case '\\':
      moveAbs(0x0f,0x6f);
      lineAbs(0x0f,0x5f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case '|':
      lineAbs(0x0f,0x6f);
      moveAbs(0x2f,0x0);
      return 0x2f;
      //break;
    case '-':
      moveAbs(0x0f,0x3f);
      lineAbs(0x4f,0x3f);
      moveAbs(0x6f,0x0);
      break;
    case '_':
      moveAbs(0x0f,-0x1f);
      lineAbs(0x4f,-0x1f);
      moveAbs(0x6f,0x0);
      break;
    case '=':
      moveAbs(0x0f,0x2f);
      lineAbs(0x4f,0x2f);
      moveAbs(0x4f,0x3f);
      lineAbs(0x0f,0x3f);
      moveAbs(0x6f,0x0);
      break;
    case '+':
      moveAbs(0x0f,0x3f);
      lineAbs(0x4f,0x3f);
      moveAbs(0x2f,0x5f);
      lineAbs(0x2f,0x1f);
      moveAbs(0x6f,0x0);
      break;
    case '`':
      moveAbs(0x0f,0x6f);
      lineAbs(0x2f,0x4f);
      moveAbs(0x4f,0x0);
      return 0x4f;
      //break;
    case '~':
      moveAbs(0x0f,0x1f);
      lineAbs(0x1f,0x2f);
      lineAbs(0x3f,0x2f);
      lineAbs(0x4f,0x3f);
      moveAbs(0x6f,0x0);
      break;
    case '!':
      lineAbs(0x0f,0x1f);
      moveAbs(0x0f,0x2f);
      lineAbs(0x0f,0x6f);
      moveAbs(0x2f,0x0);
      return 0x2f;
      break;
    case '@':
      moveAbs(0x0f,0x5f);
      lineAbs(0x1f,0x6f);
      lineAbs(0x3f,0x6f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x0f,0x2f);
      lineAbs(0x1f,0x3f);
      lineAbs(0x2f,0x2f);
      lineAbs(0x2f,0x1f);
      moveAbs(0x6f,0x0);
      break;
    case '#':
      moveAbs(0x0f,0x2f);
      lineAbs(0x4f,0x2f);
      moveAbs(0x4f,0x4f);
      lineAbs(0x0f,0x4f);
      moveAbs(0x1f,0x6f);
      lineAbs(0x1f,0x0f);
      moveAbs(0x3f,0x0f);
      lineAbs(0x3f,0x6f);
      moveAbs(0x6f,0x0);
      break;
    case '$':
      moveAbs(0x0f,0x1f);
      lineAbs(0x3f,0x1f);
      lineAbs(0x4f,0x2f);
      lineAbs(0x3f,0x3f);
      lineAbs(0x1f,0x3f);
      lineAbs(0x0f,0x4f);
      lineAbs(0x1f,0x5f);
      lineAbs(0x4f,0x5f);
      moveAbs(0x2f,0x6f);
      lineAbs(0x2f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case '%':
      lineAbs(0x0f,0x1f);
      lineAbs(0x4f,0x5f);
      lineAbs(0x4f,0x6f);
      moveAbs(0x1f,0x6f);
      lineAbs(0x0f,0x6f);
      lineAbs(0x0f,0x5f);
      lineAbs(0x1f,0x5f);
      lineAbs(0x1f,0x6f);
      moveAbs(0x4f,0x0f);
      lineAbs(0x4f,0x1f);
      lineAbs(0x3f,0x1f);
      lineAbs(0x3f,0x0f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case '^':
      moveAbs(0x0f,0x4f);
      lineAbs(0x2f,0x6f);
      lineAbs(0x4f,0x4f);
      moveAbs(0x2f,0x6f);
      lineAbs(0x2f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case '&':
      moveAbs(0x4f,0x2f);
      lineAbs(0x2f,0x0f);
      lineAbs(0x1f,0x0f);
      lineAbs(0x0f,0x1f);
      lineAbs(0x0f,0x2f);
      lineAbs(0x2f,0x4f);
      lineAbs(0x2f,0x5f);
      lineAbs(0x1f,0x6f);
      lineAbs(0x0f,0x5f);
      lineAbs(0x0f,0x4f);
      lineAbs(0x4f,0x0f);
      moveAbs(0x6f,0x0);
      break;
    case '*':
      moveAbs(0x0f,0x1f);
      lineAbs(0x4f,0x5f);
      moveAbs(0x2f,0x5f);
      lineAbs(0x2f,0x1f);
      moveAbs(0x4f,0x3f);
      lineAbs(0x0f,0x3f);
      moveAbs(0x0f,0x5f);
      lineAbs(0x4f,0x1f);
      moveAbs(0x6f,0x0);
      break;
    case '(':
      moveAbs(0x2f,0x6f);
      lineAbs(0x0f,0x4f);
      lineAbs(0x0f,0x2f);
      lineAbs(0x2f,0x0f);
      moveAbs(0x4f,0x0);
      return 0x4f;
      //break;
    case ')':
      lineAbs(0x2f,0x2f);
      lineAbs(0x2f,0x4f);
      lineAbs(0x0f,0x6f);
      moveAbs(0x4f,0x0);
      return 0x4f;
      //break;
    case ',':
      moveAbs(-0x1f,-0x1f);
      lineAbs(0x0f,0x0f);
      lineAbs(0x0f,0x1f);
      moveAbs(0x2f,0x0);
      return 0x2f;
      //break;
    case '.':
      lineAbs(0x0f,0x1f);
      moveAbs(0x2f,0x0);
      return 0x2f;
      //break;
    case '<':
      moveAbs(0x2f,0x6f);
      lineAbs(-0x1f,0x3f);
      lineAbs(0x2f,0x0f);
      moveAbs(0x4f,0x0);
      return 0x4f;
      //break;
    case '>':
      lineAbs(0x3f,0x3f);
      lineAbs(0x0f,0x6f);
      moveAbs(0x5f,0x0);
      return 0x4f;
      //break;

    default:
      moveAbs(0x0,0x0);	// try this
      return 0;
      break;
  }
  return 0x6f;
}

// string to be rendered is at x,y in MOVE SCALE.  Once positioned, all character
// drawing and relative movement to start of string is in terms of DRAW SCALE.
// Draw character must always draw from the same y baseline, which is externally
// positioned.  only dx offset from start of contiguous string is relevant.

uint8_t
draw_character(
     int font,
	char c,
	int x, int y,
     int move_scale,
     int draw_scale
)
{
#ifdef NEVER
  int x = 0; (void)xoffset;
  if (font == FONT_HERSHEY) {
    // using font layout from another system. Need to convert to something more efficient
	const hershey_char_t * const f = &hershey_simplex[c - ' '];
	int next_moveto = 1;

	for(uint8_t i = 0 ; i < f->count ; i++)
	{

		long int dx = f->points[2*i+0];
		long int dy = f->points[2*i+1];
		if (dx == -1)
		{
			next_moveto = 1;
			continue;
		}

#ifdef NEVER
		dx = (dx * size) * 3 / 4; // to avoid top line of char going negative...
		dy = (dy * size) * 3 / 4;
#else
		dx = dx * 3 / 4; // to avoid top line of char going negative...
		dy = dy * 3 / 4;
#endif

		if (next_moveto) {
			moveto((int)(x + dx), (int)(0 + dy));
		} else {
			lineto((int)(x + dx), (int)(0 + dy));
         }

		next_moveto = 0;
	}

	//return (int8_t)f->width;
#ifdef NEVER
	return (((uint8_t)f->width * (uint8_t)size) * 3U / 4U);
#else
	return ((uint8_t)f->width * 3U / 4U);
#endif
  } else if (font == FONT_ASTEROIDS) {
	const uint8_t * const pts = asteroids_font[c - ' '].points;
	int next_moveto = 1;

	for(int i = 0 ; i < 8 ; i++)
	{
		uint8_t delta = pts[i];
		if (delta == FONT_LAST)
			break;
		if (delta == FONT_UP)
		{
			next_moveto = 1;
			continue;
		}

#ifdef NEVER
		uint8_t dx = (uint8_t)(((delta >> 4U) & 0xFU) * (uint8_t)size);
		uint8_t dy = (uint8_t)(((delta      ) & 0xFU) * (uint8_t)size);
#else
		uint8_t dx = (uint8_t)(((delta >> 4U) & 0xFU));
		uint8_t dy = (uint8_t)(((delta      ) & 0xFU));
#endif

		if (next_moveto)
			moveto((x + (int)dx), (0 + (int)dy));
		else
			lineto((x + (int)dx), (0 + (int)dy));

		next_moveto = 0;
	}

	return 12;

  } else
#endif
  if (font == FONT_PROTEL) {

    uint8_t step = Protel(c, x, y, move_scale, draw_scale);
    //moveRel(0,0x0f);
    //force_move(); DrawMode();
    return step;
  } else {
    if (!Stop_on_Errors) return 12;
    ABEND("Invalid font");
  }
  return 12 /* * size */;
}


void
draw_string(
    int font, 
	const char * s,
	int x,
	int y,
    unsigned int move_scale,
    unsigned int draw_scale
)
{
  long int dx = 0; // width of text at draw scale
  for (;;) {
    long unsigned int deltax;
    char c = *s++;
    if (c == '\0') break;
             deltax =
                (unsigned long int)
                   ((
                      (unsigned long int)dx
                       *
                       (unsigned long int)draw_scale
                     ) / 
                        (unsigned long int)move_scale
                    )
                   ;
    beam_y=pendingy=y;
    pendingx=x;
    pendingx = pendingx + (long int)deltax;
    beam_x=pendingx;
    Moveto_d(y,(int)beam_x );
    InternalSetScale(draw_scale); DrawMode();
    dx += (long)(unsigned long int)(unsigned int)draw_character(font, c, x+(int)deltax, y, (int)move_scale, (int)draw_scale);  // DRAW scal
  }
}
