mirror of https://github.com/JorjBauer/aiie.git
fix escape & international charset handling
This commit is contained in:
parent
d6d20877fa
commit
1e192f4299
|
@ -7,8 +7,31 @@
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
|
static const
|
||||||
|
uint8_t intlCharsetMap[9][12] = { { '#', '$', '@', '[', '\\', ']', '^', '`', '{', '|', '}', '~' }, // USA
|
||||||
|
{ '#', '$', 0, 5, 15, 16, '^', '`', 30, 2, 1, 22 }, // France
|
||||||
|
{ '#', '$', 16, 23, 24, 25, '^', '`', 26, 27, 28, 17 }, // Germany
|
||||||
|
{ 6, '$', '@', '[', '\\', ']', '^', '`', '{', '|', '}', '~' }, // UK
|
||||||
|
{ '#', '$', '@', 18, 20, 13, '^', '`', 19, 21, 14, '~' }, // Denmark
|
||||||
|
{ '#', 11, 29, 23, 24, 13, 25, 30, 26, 27, 14, 28 }, // Sweden
|
||||||
|
{ '#', '$', '@', 5, '\\', 30, '^', 2, 0, 3, 1, 4 }, // Italy
|
||||||
|
{ 12, '$', '@', 7, 9, 8, '^', '`', 22, 10, '}', '~' }, // Spain
|
||||||
|
{ '#', '$', '@', '[', 31, ']', '^', '`', '{', '|', '}', '~' }, // Japan
|
||||||
|
};
|
||||||
|
|
||||||
Fx80::Fx80()
|
Fx80::Fx80()
|
||||||
{
|
{
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
Fx80::~Fx80()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Fx80::Reset()
|
||||||
|
{
|
||||||
|
charsetEnabled = CS_USA;
|
||||||
|
|
||||||
clearLine();
|
clearLine();
|
||||||
escapeMode = false;
|
escapeMode = false;
|
||||||
proportionalMode = false;
|
proportionalMode = false;
|
||||||
|
@ -22,13 +45,9 @@ Fx80::Fx80()
|
||||||
escapeModeLength = 0;
|
escapeModeLength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fx80::~Fx80()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Fx80::handleEscape(uint8_t c)
|
void Fx80::handleEscape(uint8_t c)
|
||||||
{
|
{
|
||||||
switch (c & 0x7F) {
|
switch (c) {
|
||||||
case 75: // FIXME: single-density 480 dpi graphics line
|
case 75: // FIXME: single-density 480 dpi graphics line
|
||||||
graphicsWidth = 480;
|
graphicsWidth = 480;
|
||||||
break;
|
break;
|
||||||
|
@ -57,6 +76,10 @@ void Fx80::handleEscape(uint8_t c)
|
||||||
case 38: // FIXME: define chars in RAM
|
case 38: // FIXME: define chars in RAM
|
||||||
case 42: // FIXME: set vertical tabs
|
case 42: // FIXME: set vertical tabs
|
||||||
case 43: // FIXME: set form length (default: 66 lines, 11 inches)
|
case 43: // FIXME: set form length (default: 66 lines, 11 inches)
|
||||||
|
break;
|
||||||
|
case 64: // Reset
|
||||||
|
Reset();
|
||||||
|
break;
|
||||||
case 68: // FIXME: reset current tabs, pitch
|
case 68: // FIXME: reset current tabs, pitch
|
||||||
case 69: // FIXME: emphasized mode on
|
case 69: // FIXME: emphasized mode on
|
||||||
case 70: // FIXME: emphasized mode off
|
case 70: // FIXME: emphasized mode off
|
||||||
|
@ -69,7 +92,11 @@ void Fx80::handleEscape(uint8_t c)
|
||||||
case 79: // FIXME: turn off skip-over perforation
|
case 79: // FIXME: turn off skip-over perforation
|
||||||
case 80: // FIXME: disable elite; enable pica mode (unless compressed is enabled)
|
case 80: // FIXME: disable elite; enable pica mode (unless compressed is enabled)
|
||||||
case 81: // FIXME: cancel print buffer, set right margin
|
case 81: // FIXME: cancel print buffer, set right margin
|
||||||
|
break;
|
||||||
case 82: // FIXME: select international charset
|
case 82: // FIXME: select international charset
|
||||||
|
escapeModeExpectingBytes = 1;
|
||||||
|
escapeModeActive = c;
|
||||||
|
break;
|
||||||
case 83: // FIXME: script mode on
|
case 83: // FIXME: script mode on
|
||||||
case 84: // FIXME: script mode off
|
case 84: // FIXME: script mode off
|
||||||
case 85: // FIXME: unidirecitonal mode on/off
|
case 85: // FIXME: unidirecitonal mode on/off
|
||||||
|
@ -108,6 +135,10 @@ void Fx80::handleActiveEscapeMode(uint8_t c)
|
||||||
case 65: // set line spacing to n/72ths of an inch (n=0-85)
|
case 65: // set line spacing to n/72ths of an inch (n=0-85)
|
||||||
twoSixteenthsLineSpacing = 3 * c;
|
twoSixteenthsLineSpacing = 3 * c;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 82:
|
||||||
|
printf("setting charset to %d\n", c);
|
||||||
|
charsetEnabled = (Charset) (c % 9);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("unhandled active escape mode %d\n", c);
|
printf("unhandled active escape mode %d\n", c);
|
||||||
|
@ -152,7 +183,7 @@ void Fx80::input(uint8_t c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: all these also work as 128 + c
|
// FIXME: all these also work as 128 + c
|
||||||
switch (c & 0x7F) {
|
switch (c) {
|
||||||
case 0: // FIXME: terminate horiz/vert tab setting
|
case 0: // FIXME: terminate horiz/vert tab setting
|
||||||
return;
|
return;
|
||||||
case 7: // beep
|
case 7: // beep
|
||||||
|
@ -188,12 +219,54 @@ void Fx80::input(uint8_t c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// normal print - send the character verbatim...
|
// normal print - send the character verbatim...
|
||||||
addCharacter(c & 0x7F); // FIXME: masking high bit
|
addCharacter(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the given character on the line at the current carriage dot position
|
// add the given character on the line at the current carriage dot position
|
||||||
void Fx80::addCharacter(uint8_t c)
|
void Fx80::addCharacter(uint8_t c)
|
||||||
{
|
{
|
||||||
|
// Jigger up the character if we're in an international mode
|
||||||
|
if (charsetEnabled != CS_USA) {
|
||||||
|
switch (c) {
|
||||||
|
case 35:
|
||||||
|
c = intlCharsetMap[charsetEnabled][0];
|
||||||
|
break;
|
||||||
|
case 36:
|
||||||
|
c = intlCharsetMap[charsetEnabled][1];
|
||||||
|
break;
|
||||||
|
case 64:
|
||||||
|
c = intlCharsetMap[charsetEnabled][2];
|
||||||
|
break;
|
||||||
|
case 91:
|
||||||
|
c = intlCharsetMap[charsetEnabled][3];
|
||||||
|
break;
|
||||||
|
case 92:
|
||||||
|
c = intlCharsetMap[charsetEnabled][4];
|
||||||
|
break;
|
||||||
|
case 93:
|
||||||
|
c = intlCharsetMap[charsetEnabled][5];
|
||||||
|
break;
|
||||||
|
case 94:
|
||||||
|
c = intlCharsetMap[charsetEnabled][6];
|
||||||
|
break;
|
||||||
|
case 96:
|
||||||
|
c = intlCharsetMap[charsetEnabled][7];
|
||||||
|
break;
|
||||||
|
case 123:
|
||||||
|
c = intlCharsetMap[charsetEnabled][8];
|
||||||
|
break;
|
||||||
|
case 124:
|
||||||
|
c = intlCharsetMap[charsetEnabled][9];
|
||||||
|
break;
|
||||||
|
case 125:
|
||||||
|
c = intlCharsetMap[charsetEnabled][10];
|
||||||
|
break;
|
||||||
|
case 126:
|
||||||
|
c = intlCharsetMap[charsetEnabled][11];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t width = Fx80Font[c * 19];
|
uint8_t width = Fx80Font[c * 19];
|
||||||
// FIXME: is 12 right for non-proportional mode?
|
// FIXME: is 12 right for non-proportional mode?
|
||||||
if (!proportionalMode)
|
if (!proportionalMode)
|
||||||
|
|
16
apple/fx80.h
16
apple/fx80.h
|
@ -29,11 +29,25 @@ class TeensyPrinter;
|
||||||
class OpenCVPrinter;
|
class OpenCVPrinter;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum Charset {
|
||||||
|
CS_USA = 0,
|
||||||
|
CS_France = 1,
|
||||||
|
CS_Germany = 2,
|
||||||
|
CS_UK = 3,
|
||||||
|
CS_Denmark = 4,
|
||||||
|
CS_Sweden = 5,
|
||||||
|
CS_Italy = 6,
|
||||||
|
CS_Spain = 7,
|
||||||
|
CS_Japan = 8
|
||||||
|
};
|
||||||
|
|
||||||
class Fx80 {
|
class Fx80 {
|
||||||
public:
|
public:
|
||||||
Fx80();
|
Fx80();
|
||||||
~Fx80();
|
~Fx80();
|
||||||
|
|
||||||
|
void Reset();
|
||||||
|
|
||||||
void input(uint8_t c);
|
void input(uint8_t c);
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
@ -70,6 +84,8 @@ class Fx80 {
|
||||||
|
|
||||||
// 9 pixel-rows of (FX80_MAXWIDTH) bits (stuffed in 8-bit bytes)
|
// 9 pixel-rows of (FX80_MAXWIDTH) bits (stuffed in 8-bit bytes)
|
||||||
uint8_t rowOfBits[(FX80_MAXWIDTH/8)*9];
|
uint8_t rowOfBits[(FX80_MAXWIDTH/8)*9];
|
||||||
|
|
||||||
|
Charset charsetEnabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue