|
|
|
|
@@ -61,7 +61,7 @@
|
|
|
|
|
#include <86box/machine.h>
|
|
|
|
|
#include <86box/timer.h>
|
|
|
|
|
#include <86box/mem.h>
|
|
|
|
|
#include <86box/rom.h>
|
|
|
|
|
#include <86box/rom.h>
|
|
|
|
|
#include <86box/pit.h>
|
|
|
|
|
#include <86box/plat.h>
|
|
|
|
|
#include <86box/plat_dynld.h>
|
|
|
|
|
@@ -99,7 +99,7 @@ void *ft_handle = NULL;
|
|
|
|
|
|
|
|
|
|
static int (*ft_Init_FreeType)(FT_Library *alibrary);
|
|
|
|
|
static int (*ft_Done_Face)(FT_Face face);
|
|
|
|
|
static int (*ft_New_Face)(FT_Library library, const char *filepathname,
|
|
|
|
|
static int (*ft_New_Face)(FT_Library library, const char *filepathname,
|
|
|
|
|
FT_Long face_index, FT_Face *aface);
|
|
|
|
|
static int (*ft_Set_Char_Size)(FT_Face face, FT_F26Dot6 char_width,
|
|
|
|
|
FT_F26Dot6 char_height,
|
|
|
|
|
@@ -207,12 +207,12 @@ typedef struct {
|
|
|
|
|
|
|
|
|
|
char page_fn[260];
|
|
|
|
|
uint8_t color;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* page data (TODO: make configurable) */
|
|
|
|
|
double page_width, /* all in inches */
|
|
|
|
|
page_height,
|
|
|
|
|
left_margin,
|
|
|
|
|
top_margin,
|
|
|
|
|
top_margin,
|
|
|
|
|
right_margin,
|
|
|
|
|
bottom_margin;
|
|
|
|
|
uint16_t dpi;
|
|
|
|
|
@@ -291,7 +291,7 @@ typedef struct {
|
|
|
|
|
|
|
|
|
|
uint8_t msb; /* MSB mode, -1 = off */
|
|
|
|
|
uint8_t ctrl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PALETTE palcol;
|
|
|
|
|
} escp_t;
|
|
|
|
|
|
|
|
|
|
@@ -321,9 +321,9 @@ static const uint16_t codepages[15] = {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* "patches" to the codepage for the international charsets
|
|
|
|
|
/* "patches" to the codepage for the international charsets
|
|
|
|
|
* these bytes patch the following 12 positions of the char table, in order:
|
|
|
|
|
* 0x23 0x24 0x40 0x5b 0x5c 0x5d 0x5e 0x60 0x7b 0x7c 0x7d 0x7e
|
|
|
|
|
* 0x23 0x24 0x40 0x5b 0x5c 0x5d 0x5e 0x60 0x7b 0x7c 0x7d 0x7e
|
|
|
|
|
* TODO: Implement the missing international charsets
|
|
|
|
|
*/
|
|
|
|
|
static const uint16_t intCharSets[15][12] = {
|
|
|
|
|
@@ -395,7 +395,7 @@ escp_log(const char *fmt, ...)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Dump the current page into a formatted file. */
|
|
|
|
|
static void
|
|
|
|
|
static void
|
|
|
|
|
dump_page(escp_t *dev)
|
|
|
|
|
{
|
|
|
|
|
char path[1024];
|
|
|
|
|
@@ -453,7 +453,7 @@ timeout_timer(void *priv)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
static void
|
|
|
|
|
fill_palette(uint8_t redmax, uint8_t greenmax, uint8_t bluemax, uint8_t colorID, escp_t *dev)
|
|
|
|
|
{
|
|
|
|
|
uint8_t colormask;
|
|
|
|
|
@@ -499,7 +499,7 @@ reset_printer(escp_t *dev)
|
|
|
|
|
dev->density_k = 0;
|
|
|
|
|
dev->density_l = 1;
|
|
|
|
|
dev->density_y = 2;
|
|
|
|
|
dev->density_z = 3;
|
|
|
|
|
dev->density_z = 3;
|
|
|
|
|
dev->char_tables[0] = 0; /* italics */
|
|
|
|
|
dev->char_tables[1] = dev->char_tables[2] = dev->char_tables[3] = 437; /* all other tables use CP437 */
|
|
|
|
|
dev->defined_unit = -1.0;
|
|
|
|
|
@@ -510,7 +510,7 @@ reset_printer(escp_t *dev)
|
|
|
|
|
dev->msb = 255;
|
|
|
|
|
dev->print_everything_count = 0;
|
|
|
|
|
dev->lq_typeface = TYPEFACE_COURIER;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init_codepage(dev, dev->char_tables[dev->curr_char_table]);
|
|
|
|
|
|
|
|
|
|
update_font(dev);
|
|
|
|
|
@@ -521,10 +521,10 @@ reset_printer(escp_t *dev)
|
|
|
|
|
dev->horizontal_tabs[i] = i * 8.0 * (1.0 / dev->cpi);
|
|
|
|
|
dev->num_horizontal_tabs = 32;
|
|
|
|
|
dev->num_vertical_tabs = -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dev->page != NULL)
|
|
|
|
|
dev->page->dirty = 0;
|
|
|
|
|
|
|
|
|
|
dev->page->dirty = 0;
|
|
|
|
|
|
|
|
|
|
escp_log("ESC/P: width=%.1fin,height=%.1fin dpi=%i cpi=%i lpi=%i\n",
|
|
|
|
|
dev->page_width, dev->page_height, (int)dev->dpi,
|
|
|
|
|
(int)dev->cpi, (int)dev->lpi);
|
|
|
|
|
@@ -690,7 +690,7 @@ process_char(escp_t *dev, uint8_t ch)
|
|
|
|
|
case 0x02: // Undocumented
|
|
|
|
|
case 0x0a: // Reverse line feed
|
|
|
|
|
case 0x0c: // Return to top of current page
|
|
|
|
|
case 0x0e: // Select double-width printing (one line) (ESC SO)
|
|
|
|
|
case 0x0e: // Select double-width printing (one line) (ESC SO)
|
|
|
|
|
case 0x0f: // Select condensed printing (ESC SI)
|
|
|
|
|
case 0x23: // Cancel MSB control (ESC #)
|
|
|
|
|
case 0x30: // Select 1/8-inch line spacing (ESC 0)
|
|
|
|
|
@@ -711,7 +711,7 @@ process_char(escp_t *dev, uint8_t ch)
|
|
|
|
|
case 0x47: // Select double-strike printing (ESC G)
|
|
|
|
|
case 0x48: // Cancel double-strike printing (ESC H)
|
|
|
|
|
case 0x4d: // Select 10.5-point, 12-cpi (ESC M)
|
|
|
|
|
case 0x4f: // Cancel bottom margin
|
|
|
|
|
case 0x4f: // Cancel bottom margin
|
|
|
|
|
case 0x50: // Select 10.5-point, 10-cpi (ESC P)
|
|
|
|
|
case 0x54: // Cancel superscript/subscript printing (ESC T)
|
|
|
|
|
case 0x5e: // Enable printing of all character codes on next character
|
|
|
|
|
@@ -723,7 +723,7 @@ process_char(escp_t *dev, uint8_t ch)
|
|
|
|
|
case 0x852: // Select reverse feed mode (FS R)
|
|
|
|
|
dev->esc_parms_req = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 0x19: // Control paper loading/ejecting (ESC EM)
|
|
|
|
|
case 0x20: // Set intercharacter space (ESC SP)
|
|
|
|
|
case 0x21: // Master select (ESC !)
|
|
|
|
|
@@ -787,7 +787,7 @@ process_char(escp_t *dev, uint8_t ch)
|
|
|
|
|
case 0x5b: // Select character height, width, line spacing
|
|
|
|
|
dev->esc_parms_req = 7;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 0x62: // Set vertical tabs in VFU channels (ESC b)
|
|
|
|
|
case 0x42: // Set vertical tabs (ESC B)
|
|
|
|
|
dev->num_vertical_tabs = 0;
|
|
|
|
|
@@ -813,7 +813,7 @@ process_char(escp_t *dev, uint8_t ch)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
escp_log("ESC/P: Unknown command ESC %c (0x%02x). Unable to skip parameters.\n",
|
|
|
|
|
escp_log("ESC/P: Unknown command ESC %c (0x%02x). Unable to skip parameters.\n",
|
|
|
|
|
dev->esc_pending >= 0x20 ? dev->esc_pending : '?', dev->esc_pending);
|
|
|
|
|
dev->esc_parms_req = 0;
|
|
|
|
|
dev->esc_pending = 0;
|
|
|
|
|
@@ -877,7 +877,7 @@ process_char(escp_t *dev, uint8_t ch)
|
|
|
|
|
/* Collect vertical tabs. */
|
|
|
|
|
if (dev->esc_pending == 0x42) {
|
|
|
|
|
/* check if we're done */
|
|
|
|
|
if ((ch == 0) ||
|
|
|
|
|
if ((ch == 0) ||
|
|
|
|
|
(dev->num_vertical_tabs > 0 && dev->vertical_tabs[dev->num_vertical_tabs - 1] > (double)ch * dev->linespacing)) {
|
|
|
|
|
dev->esc_pending = 0;
|
|
|
|
|
} else {
|
|
|
|
|
@@ -889,7 +889,7 @@ process_char(escp_t *dev, uint8_t ch)
|
|
|
|
|
/* Collect horizontal tabs. */
|
|
|
|
|
if (dev->esc_pending == 0x44) {
|
|
|
|
|
/* check if we're done... */
|
|
|
|
|
if ((ch == 0) ||
|
|
|
|
|
if ((ch == 0) ||
|
|
|
|
|
(dev->num_horizontal_tabs > 0 && dev->horizontal_tabs[dev->num_horizontal_tabs - 1] > (double)ch * (1.0 / dev->cpi))) {
|
|
|
|
|
dev->esc_pending = 0;
|
|
|
|
|
} else {
|
|
|
|
|
@@ -988,8 +988,8 @@ process_char(escp_t *dev, uint8_t ch)
|
|
|
|
|
|
|
|
|
|
case 0x85a: /* Print 24-bit hex-density graphics (FS Z) */
|
|
|
|
|
setup_bit_image(dev, 40, PARAM16(0));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x2a: /* select bit image (ESC *) */
|
|
|
|
|
setup_bit_image(dev, dev->esc_parms[0], PARAM16(1));
|
|
|
|
|
break;
|
|
|
|
|
@@ -1258,9 +1258,9 @@ process_char(escp_t *dev, uint8_t ch)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x846: // Select forward feed mode (FS F) - set reverse not implemented yet
|
|
|
|
|
if (dev->linespacing < 0)
|
|
|
|
|
if (dev->linespacing < 0)
|
|
|
|
|
dev->linespacing *= -1;
|
|
|
|
|
break;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x6a: // Reverse paper feed (ESC j)
|
|
|
|
|
reverse = (double)PARAM16(0) / (double)216.0;
|
|
|
|
|
@@ -1455,7 +1455,7 @@ process_char(escp_t *dev, uint8_t ch)
|
|
|
|
|
switch (ch) {
|
|
|
|
|
case 0x00:
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 0x07: /* Beeper (BEL) */
|
|
|
|
|
/* TODO: beep? */
|
|
|
|
|
return 1;
|
|
|
|
|
@@ -1580,7 +1580,7 @@ process_char(escp_t *dev, uint8_t ch)
|
|
|
|
|
case 0x1b: /* ESC */
|
|
|
|
|
dev->esc_seen = 1;
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 0x1c: /* FS (IBM commands) */
|
|
|
|
|
dev->fss_seen = 1;
|
|
|
|
|
return 1;
|
|
|
|
|
@@ -1651,7 +1651,7 @@ handle_char(escp_t *dev, uint8_t ch)
|
|
|
|
|
/* mark the page as dirty if anything is drawn */
|
|
|
|
|
if ((ch != 0x20) || (dev->font_score != SCORE_NONE))
|
|
|
|
|
dev->page->dirty = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* draw the glyph */
|
|
|
|
|
blit_glyph(dev, pen_x, pen_y, 0);
|
|
|
|
|
blit_glyph(dev, pen_x + 1, pen_y, 1);
|
|
|
|
|
@@ -1687,20 +1687,20 @@ handle_char(escp_t *dev, uint8_t ch)
|
|
|
|
|
if (dev->font_score != SCORE_NONE && (dev->font_style & (STYLE_UNDERLINE | STYLE_STRIKETHROUGH | STYLE_OVERSCORE))) {
|
|
|
|
|
/* Find out where to put the line. */
|
|
|
|
|
line_y = PIXY;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dev->font_style & STYLE_UNDERLINE)
|
|
|
|
|
line_y = (PIXY + (uint16_t)(dev->fontface->size->metrics.height * 0.9));
|
|
|
|
|
if (dev->font_style & STYLE_STRIKETHROUGH)
|
|
|
|
|
line_y = (PIXY + (uint16_t)(dev->fontface->size->metrics.height * 0.45));
|
|
|
|
|
if (dev->font_style & STYLE_OVERSCORE)
|
|
|
|
|
line_y = PIXY - ((dev->font_score == SCORE_DOUBLE || dev->font_score == SCORE_DOUBLEBROKEN) ? 5 : 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
draw_hline(dev, pen_x, PIXX, line_y, dev->font_score == SCORE_SINGLEBROKEN || dev->font_score == SCORE_DOUBLEBROKEN);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dev->font_score == SCORE_DOUBLE || dev->font_score == SCORE_DOUBLEBROKEN)
|
|
|
|
|
draw_hline(dev, line_start, PIXX, line_y + 5, dev->font_score == SCORE_SINGLEBROKEN || dev->font_score == SCORE_DOUBLEBROKEN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((dev->curr_x + x_advance) > dev->right_margin) {
|
|
|
|
|
dev->curr_x = dev->left_margin;
|
|
|
|
|
dev->curr_y += dev->linespacing;
|
|
|
|
|
@@ -1735,7 +1735,7 @@ blit_glyph(escp_t *dev, unsigned destx, unsigned desty, int8_t add)
|
|
|
|
|
*dst |= (dev->color | 0x1f);
|
|
|
|
|
else {
|
|
|
|
|
*dst += src;
|
|
|
|
|
*dst |= dev->color;
|
|
|
|
|
*dst |= dev->color;
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
*dst = src|dev->color;
|
|
|
|
|
@@ -1899,7 +1899,7 @@ print_bit_graph(escp_t *dev, uint8_t ch)
|
|
|
|
|
|
|
|
|
|
pixel_w = 1;
|
|
|
|
|
pixel_h = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dev->bg_adjacent) {
|
|
|
|
|
/* if page DPI is bigger than bitgraphics DPI, drawn pixels get "bigger" */
|
|
|
|
|
pixel_w = dev->dpi / dev->bg_h_density > 0 ? dev->dpi / dev->bg_h_density : 1;
|
|
|
|
|
@@ -1983,7 +1983,7 @@ write_ctrl(uint8_t val, void *priv)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dev->ctrl = val;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dev->autofeed = ((val & 0x02) > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -2071,7 +2071,7 @@ escp_init(void *lpt)
|
|
|
|
|
|
|
|
|
|
dev->page_width = PAGE_WIDTH;
|
|
|
|
|
dev->page_height = PAGE_HEIGHT;
|
|
|
|
|
dev->dpi = PAGE_DPI;
|
|
|
|
|
dev->dpi = PAGE_DPI;
|
|
|
|
|
|
|
|
|
|
/* Create 8-bit grayscale buffer for the page. */
|
|
|
|
|
dev->page = (psurface_t *)malloc(sizeof(psurface_t));
|
|
|
|
|
@@ -2081,7 +2081,7 @@ escp_init(void *lpt)
|
|
|
|
|
dev->page->pixels = (uint8_t *)malloc(dev->page->pitch * dev->page->h);
|
|
|
|
|
memset(dev->page->pixels, 0x00, dev->page->pitch * dev->page->h);
|
|
|
|
|
|
|
|
|
|
/* Initialize parameters. */
|
|
|
|
|
/* Initialize parameters. */
|
|
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
|
dev->palcol[i].r = 255;
|
|
|
|
|
dev->palcol[i].g = 255;
|
|
|
|
|
|