clang-format in src/printer/

This commit is contained in:
Jasmine Iwanek
2022-09-18 17:17:25 -04:00
parent 97a7459fd4
commit d4c4ef6a5d
5 changed files with 2276 additions and 2335 deletions

View File

@@ -73,11 +73,9 @@
#define PNGFUNC(x) png_##x #define PNGFUNC(x) png_##x
#ifdef ENABLE_ESCP_LOG #ifdef ENABLE_ESCP_LOG
int png_do_log = ENABLE_ESCP_LOG; int png_do_log = ENABLE_ESCP_LOG;
static void static void
png_log(const char *fmt, ...) png_log(const char *fmt, ...)
{ {
@@ -93,21 +91,18 @@ png_log(const char *fmt, ...)
# define png_log(fmt, ...) # define png_log(fmt, ...)
#endif #endif
static void static void
error_handler(png_structp arg, const char *str) error_handler(png_structp arg, const char *str)
{ {
png_log("PNG: stream 0x%08lx error '%s'\n", arg, str); png_log("PNG: stream 0x%08lx error '%s'\n", arg, str);
} }
static void static void
warning_handler(png_structp arg, const char *str) warning_handler(png_structp arg, const char *str)
{ {
png_log("PNG: stream 0x%08lx warning '%s'\n", arg, str); png_log("PNG: stream 0x%08lx warning '%s'\n", arg, str);
} }
/* Write the given image as an 8-bit GrayScale PNG image file. */ /* Write the given image as an 8-bit GrayScale PNG image file. */
int int
png_write_gray(char *fn, int inv, uint8_t *pix, int16_t w, int16_t h) png_write_gray(char *fn, int inv, uint8_t *pix, int16_t w, int16_t h)
@@ -128,7 +123,8 @@ png_write_gray(char *fn, int inv, uint8_t *pix, int16_t w, int16_t h)
error: error:
png_log("PNG: fatal error, bailing out, error = %i\n", errno); png_log("PNG: fatal error, bailing out, error = %i\n", errno);
if (png != NULL) if (png != NULL)
PNGFUNC(destroy_write_struct)(&png, &info); PNGFUNC(destroy_write_struct)
(&png, &info);
if (fp != NULL) if (fp != NULL)
(void) fclose(fp); (void) fclose(fp);
return (0); return (0);
@@ -148,14 +144,16 @@ error:
goto error; goto error;
} }
PNGFUNC(init_io)
(png, fp);
PNGFUNC(init_io)(png, fp); PNGFUNC(set_IHDR)
(png, info, w, h, 8, PNG_COLOR_TYPE_GRAY,
PNGFUNC(set_IHDR)(png, info, w, h, 8, PNG_COLOR_TYPE_GRAY,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT); PNG_FILTER_TYPE_DEFAULT);
PNGFUNC(write_info)(png, info); PNGFUNC(write_info)
(png, info);
/* Create a buffer for one scanline of pixels. */ /* Create a buffer for one scanline of pixels. */
row = (png_bytep) malloc(PNGFUNC(get_rowbytes)(png, info)); row = (png_bytep) malloc(PNGFUNC(get_rowbytes)(png, info));
@@ -171,15 +169,18 @@ error:
} }
/* Write image to the file. */ /* Write image to the file. */
PNGFUNC(write_rows)(png, &row, 1); PNGFUNC(write_rows)
(png, &row, 1);
} }
/* No longer need the row buffer. */ /* No longer need the row buffer. */
free(row); free(row);
PNGFUNC(write_end)(png, NULL); PNGFUNC(write_end)
(png, NULL);
PNGFUNC(destroy_write_struct)(&png, &info); PNGFUNC(destroy_write_struct)
(&png, &info);
/* Clean up. */ /* Clean up. */
(void) fclose(fp); (void) fclose(fp);
@@ -187,7 +188,6 @@ error:
return (1); return (1);
} }
/* Write the given BITMAP-format image as an 8-bit RGBA PNG image file. */ /* Write the given BITMAP-format image as an 8-bit RGBA PNG image file. */
void void
png_write_rgb(char *fn, uint8_t *pix, int16_t w, int16_t h, uint16_t pitch, PALETTE palcol) png_write_rgb(char *fn, uint8_t *pix, int16_t w, int16_t h, uint16_t pitch, PALETTE palcol)
@@ -205,7 +205,8 @@ png_write_rgb(char *fn, uint8_t *pix, int16_t w, int16_t h, uint16_t pitch, PALE
png_log("PNG: File %s could not be opened for writing!\n", fn); png_log("PNG: File %s could not be opened for writing!\n", fn);
error: error:
if (png != NULL) if (png != NULL)
PNGFUNC(destroy_write_struct)(&png, &info); PNGFUNC(destroy_write_struct)
(&png, &info);
if (fp != NULL) if (fp != NULL)
(void) fclose(fp); (void) fclose(fp);
return; return;
@@ -226,17 +227,25 @@ error:
} }
/* Finalize the initing of png library */ /* Finalize the initing of png library */
PNGFUNC(init_io)(png, fp); PNGFUNC(init_io)
PNGFUNC(set_compression_level)(png, 9); (png, fp);
PNGFUNC(set_compression_level)
(png, 9);
/* set other zlib parameters */ /* set other zlib parameters */
PNGFUNC(set_compression_mem_level)(png, 8); PNGFUNC(set_compression_mem_level)
PNGFUNC(set_compression_strategy)(png, PNG_Z_DEFAULT_STRATEGY); (png, 8);
PNGFUNC(set_compression_window_bits)(png, 15); PNGFUNC(set_compression_strategy)
PNGFUNC(set_compression_method)(png, 8); (png, PNG_Z_DEFAULT_STRATEGY);
PNGFUNC(set_compression_buffer_size)(png, 8192); PNGFUNC(set_compression_window_bits)
(png, 15);
PNGFUNC(set_compression_method)
(png, 8);
PNGFUNC(set_compression_buffer_size)
(png, 8192);
PNGFUNC(set_IHDR)(png, info, w, h, 8, PNG_COLOR_TYPE_PALETTE, PNGFUNC(set_IHDR)
(png, info, w, h, 8, PNG_COLOR_TYPE_PALETTE,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT); PNG_FILTER_TYPE_DEFAULT);
@@ -246,7 +255,8 @@ error:
palette[i].blue = palcol[i].b; palette[i].blue = palcol[i].b;
} }
PNGFUNC(set_PLTE)(png, info, palette, 256); PNGFUNC(set_PLTE)
(png, info, palette, 256);
/* Create a buffer for scanlines of pixels. */ /* Create a buffer for scanlines of pixels. */
rows = (png_bytep *) malloc(sizeof(png_bytep) * h); rows = (png_bytep *) malloc(sizeof(png_bytep) * h);
@@ -255,14 +265,17 @@ error:
rows[i] = (pix + (i * pitch)); rows[i] = (pix + (i * pitch));
} }
PNGFUNC(set_rows)(png, info, rows); PNGFUNC(set_rows)
(png, info, rows);
PNGFUNC(write_png)(png, info, 0, NULL); PNGFUNC(write_png)
(png, info, 0, NULL);
/* Clean up. */ /* Clean up. */
(void) fclose(fp); (void) fclose(fp);
PNGFUNC(destroy_write_struct)(&png, &info); PNGFUNC(destroy_write_struct)
(&png, &info);
/* No longer need the row buffers. */ /* No longer need the row buffers. */
free(rows); free(rows);

View File

@@ -57,7 +57,6 @@
#include <86box/plat.h> #include <86box/plat.h>
#include <86box/printer.h> #include <86box/printer.h>
static const uint16_t cp437Map[256] = { static const uint16_t cp437Map[256] = {
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
@@ -548,7 +547,6 @@ static const uint16_t cp866Map[256] = {
0x00b0, 0x2219, 0x00b7, 0x221a, 0x2116, 0x00a4, 0x25a0, 0x00a0 0x00b0, 0x2219, 0x00b7, 0x221a, 0x2116, 0x00a4, 0x25a0, 0x00a0
}; };
static const struct { static const struct {
uint16_t code; uint16_t code;
const uint16_t *map; const uint16_t *map;
@@ -572,7 +570,6 @@ static const struct {
// clang-format on // clang-format on
}; };
/* Select a ASCII->Unicode mapping by CP number */ /* Select a ASCII->Unicode mapping by CP number */
void void
select_codepage(uint16_t code, uint16_t *curmap) select_codepage(uint16_t code, uint16_t *curmap)

View File

@@ -73,7 +73,6 @@
#include <86box/printer.h> #include <86box/printer.h>
#include <86box/prt_devs.h> #include <86box/prt_devs.h>
/* Default page values (for now.) */ /* Default page values (for now.) */
#define COLOR_BLACK 7 << 5 #define COLOR_BLACK 7 << 5
#define PAGE_WIDTH 8.5 /* standard U.S. Letter */ #define PAGE_WIDTH 8.5 /* standard U.S. Letter */
@@ -86,7 +85,6 @@
#define PAGE_CPI 10.0 /* standard 10 cpi */ #define PAGE_CPI 10.0 /* standard 10 cpi */
#define PAGE_LPI 6.0 /* standard 6 lpi */ #define PAGE_LPI 6.0 /* standard 6 lpi */
#ifdef _WIN32 #ifdef _WIN32
# define PATH_FREETYPE_DLL "freetype.dll" # define PATH_FREETYPE_DLL "freetype.dll"
#elif defined __APPLE__ #elif defined __APPLE__
@@ -95,7 +93,6 @@
# define PATH_FREETYPE_DLL "libfreetype.so.6" # define PATH_FREETYPE_DLL "libfreetype.so.6"
#endif #endif
/* FreeType library handles - global so they can be shared. */ /* FreeType library handles - global so they can be shared. */
FT_Library ft_lib = NULL; FT_Library ft_lib = NULL;
void *ft_handle = NULL; void *ft_handle = NULL;
@@ -116,7 +113,6 @@ static int (*ft_Load_Glyph)(FT_Face face, FT_UInt glyph_index,
static int (*ft_Render_Glyph)(FT_GlyphSlot slot, static int (*ft_Render_Glyph)(FT_GlyphSlot slot,
FT_Render_Mode render_mode); FT_Render_Mode render_mode);
static dllimp_t ft_imports[] = { static dllimp_t ft_imports[] = {
{"FT_Init_FreeType", &ft_Init_FreeType }, {"FT_Init_FreeType", &ft_Init_FreeType },
{ "FT_New_Face", &ft_New_Face }, { "FT_New_Face", &ft_New_Face },
@@ -129,7 +125,6 @@ static dllimp_t ft_imports[] = {
{ NULL, NULL } { NULL, NULL }
}; };
/* The fonts. */ /* The fonts. */
#define FONT_DEFAULT 0 #define FONT_DEFAULT 0
#define FONT_ROMAN 1 #define FONT_ROMAN 1
@@ -181,13 +176,11 @@ static dllimp_t ft_imports[] = {
#define TYPEFACE_SVBUSABA 30 #define TYPEFACE_SVBUSABA 30
#define TYPEFACE_SVJITTRA 31 #define TYPEFACE_SVJITTRA 31
/* Some helper macros. */ /* Some helper macros. */
#define PARAM16(x) (dev->esc_parms[x + 1] * 256 + dev->esc_parms[x]) #define PARAM16(x) (dev->esc_parms[x + 1] * 256 + dev->esc_parms[x])
#define PIXX ((unsigned) floor(dev->curr_x * dev->dpi + 0.5)) #define PIXX ((unsigned) floor(dev->curr_x * dev->dpi + 0.5))
#define PIXY ((unsigned) floor(dev->curr_y * dev->dpi + 0.5)) #define PIXY ((unsigned) floor(dev->curr_y * dev->dpi + 0.5))
typedef struct { typedef struct {
int8_t dirty; /* has the page been printed on? */ int8_t dirty; /* has the page been printed on? */
char pad; char pad;
@@ -199,7 +192,6 @@ typedef struct {
uint8_t *pixels; /* grayscale pixel data */ uint8_t *pixels; /* grayscale pixel data */
} psurface_t; } psurface_t;
typedef struct { typedef struct {
const char *name; const char *name;
@@ -298,7 +290,6 @@ typedef struct {
PALETTE palcol; PALETTE palcol;
} escp_t; } escp_t;
static void static void
update_font(escp_t *dev); update_font(escp_t *dev);
static void static void
@@ -316,14 +307,12 @@ print_bit_graph(escp_t *dev, uint8_t ch);
static void static void
new_page(escp_t *dev, int8_t save, int8_t resetx); new_page(escp_t *dev, int8_t save, int8_t resetx);
/* Codepage table, needed for ESC t ( */ /* Codepage table, needed for ESC t ( */
static const uint16_t codepages[15] = { static const uint16_t codepages[15] = {
0, 437, 932, 850, 851, 853, 855, 860, 0, 437, 932, 850, 851, 853, 855, 860,
863, 865, 852, 857, 862, 864, 866 863, 865, 852, 857, 862, 864, 866
}; };
/* "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: * 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
@@ -376,11 +365,9 @@ static const uint16_t intCharSets[15][12] = {
0x00b6, 0x0060, 0x00a9, 0x00ae, 0x2020, 0x2122} 0x00b6, 0x0060, 0x00a9, 0x00ae, 0x2020, 0x2122}
}; };
#ifdef ENABLE_ESCP_LOG #ifdef ENABLE_ESCP_LOG
int escp_do_log = ENABLE_ESCP_LOG; int escp_do_log = ENABLE_ESCP_LOG;
static void static void
escp_log(const char *fmt, ...) escp_log(const char *fmt, ...)
{ {
@@ -396,7 +383,6 @@ escp_log(const char *fmt, ...)
# define escp_log(fmt, ...) # define escp_log(fmt, ...)
#endif #endif
/* Dump the current page into a formatted file. */ /* Dump the current page into a formatted file. */
static void static void
dump_page(escp_t *dev) dump_page(escp_t *dev)
@@ -408,7 +394,6 @@ dump_page(escp_t *dev)
png_write_rgb(path, dev->page->pixels, dev->page->w, dev->page->h, dev->page->pitch, dev->palcol); png_write_rgb(path, dev->page->pixels, dev->page->w, dev->page->h, dev->page->pitch, dev->palcol);
} }
static void static void
new_page(escp_t *dev, int8_t save, int8_t resetx) new_page(escp_t *dev, int8_t save, int8_t resetx)
{ {
@@ -429,7 +414,6 @@ new_page(escp_t *dev, int8_t save, int8_t resetx)
plat_tempfile(dev->page_fn, NULL, ".png"); plat_tempfile(dev->page_fn, NULL, ".png");
} }
static void static void
pulse_timer(void *priv) pulse_timer(void *priv)
{ {
@@ -443,7 +427,6 @@ pulse_timer(void *priv)
timer_disable(&dev->pulse_timer); timer_disable(&dev->pulse_timer);
} }
static void static void
timeout_timer(void *priv) timeout_timer(void *priv)
{ {
@@ -455,7 +438,6 @@ timeout_timer(void *priv)
timer_disable(&dev->timeout_timer); timer_disable(&dev->timeout_timer);
} }
static void static void
fill_palette(uint8_t redmax, uint8_t greenmax, uint8_t bluemax, uint8_t colorID, escp_t *dev) fill_palette(uint8_t redmax, uint8_t greenmax, uint8_t bluemax, uint8_t colorID, escp_t *dev)
{ {
@@ -475,7 +457,6 @@ fill_palette(uint8_t redmax, uint8_t greenmax, uint8_t bluemax, uint8_t colorID,
} }
} }
static void static void
reset_printer(escp_t *dev) reset_printer(escp_t *dev)
{ {
@@ -533,7 +514,6 @@ reset_printer(escp_t *dev)
(int) dev->cpi, (int) dev->lpi); (int) dev->cpi, (int) dev->lpi);
} }
static void static void
reset_printer_hard(escp_t *dev) reset_printer_hard(escp_t *dev)
{ {
@@ -543,7 +523,6 @@ reset_printer_hard(escp_t *dev)
reset_printer(dev); reset_printer(dev);
} }
/* Select a ASCII->Unicode mapping by CP number */ /* Select a ASCII->Unicode mapping by CP number */
static void static void
init_codepage(escp_t *dev, uint16_t num) init_codepage(escp_t *dev, uint16_t num)
@@ -552,7 +531,6 @@ init_codepage(escp_t *dev, uint16_t num)
select_codepage(num, dev->curr_cpmap); select_codepage(num, dev->curr_cpmap);
} }
static void static void
update_font(escp_t *dev) update_font(escp_t *dev)
{ {
@@ -572,7 +550,8 @@ update_font(escp_t *dev)
if (dev->print_quality == QUALITY_DRAFT) if (dev->print_quality == QUALITY_DRAFT)
fn = FONT_FILE_DOTMATRIX; fn = FONT_FILE_DOTMATRIX;
else switch (dev->lq_typeface) { else
switch (dev->lq_typeface) {
case TYPEFACE_ROMAN: case TYPEFACE_ROMAN:
fn = FONT_FILE_ROMAN; fn = FONT_FILE_ROMAN;
break; break;
@@ -627,12 +606,10 @@ update_font(escp_t *dev)
hpoints *= 10.0 / 20.0; hpoints *= 10.0 / 20.0;
vpoints *= 10.0 / 12.0; vpoints *= 10.0 / 12.0;
} }
} } else if (dev->font_style & STYLE_CONDENSED)
else if (dev->font_style & STYLE_CONDENSED)
hpoints /= 2.0; hpoints /= 2.0;
if ((dev->font_style & STYLE_DOUBLEWIDTH) || if ((dev->font_style & STYLE_DOUBLEWIDTH) || (dev->font_style & STYLE_DOUBLEWIDTHONELINE)) {
(dev->font_style & STYLE_DOUBLEWIDTHONELINE)) {
dev->actual_cpi /= 2.0; dev->actual_cpi /= 2.0;
hpoints *= 2.0; hpoints *= 2.0;
} }
@@ -655,8 +632,7 @@ update_font(escp_t *dev)
(uint16_t) (hpoints * 64), (uint16_t) (vpoints * 64), (uint16_t) (hpoints * 64), (uint16_t) (vpoints * 64),
dev->dpi, dev->dpi); dev->dpi, dev->dpi);
if ((dev->font_style & STYLE_ITALICS) || if ((dev->font_style & STYLE_ITALICS) || (dev->char_tables[dev->curr_char_table] == 0)) {
(dev->char_tables[dev->curr_char_table] == 0)) {
/* Italics transformation. */ /* Italics transformation. */
matrix.xx = 0x10000L; matrix.xx = 0x10000L;
matrix.xy = (FT_Fixed) (0.20 * 0x10000L); matrix.xy = (FT_Fixed) (0.20 * 0x10000L);
@@ -666,7 +642,6 @@ update_font(escp_t *dev)
} }
} }
/* This is the actual ESC/P interpreter. */ /* This is the actual ESC/P interpreter. */
static int static int
process_char(escp_t *dev, uint8_t ch) process_char(escp_t *dev, uint8_t ch)
@@ -880,8 +855,7 @@ process_char(escp_t *dev, uint8_t ch)
/* Collect vertical tabs. */ /* Collect vertical tabs. */
if (dev->esc_pending == 0x42) { if (dev->esc_pending == 0x42) {
/* check if we're done */ /* 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->num_vertical_tabs > 0 && dev->vertical_tabs[dev->num_vertical_tabs - 1] > (double)ch * dev->linespacing)) {
dev->esc_pending = 0; dev->esc_pending = 0;
} else { } else {
if (dev->num_vertical_tabs >= 0 && dev->num_vertical_tabs < 16) if (dev->num_vertical_tabs >= 0 && dev->num_vertical_tabs < 16)
@@ -892,8 +866,7 @@ process_char(escp_t *dev, uint8_t ch)
/* Collect horizontal tabs. */ /* Collect horizontal tabs. */
if (dev->esc_pending == 0x44) { if (dev->esc_pending == 0x44) {
/* check if we're done... */ /* 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->num_horizontal_tabs > 0 && dev->horizontal_tabs[dev->num_horizontal_tabs - 1] > (double)ch * (1.0 / dev->cpi))) {
dev->esc_pending = 0; dev->esc_pending = 0;
} else { } else {
if (dev->num_horizontal_tabs < 32) if (dev->num_horizontal_tabs < 32)
@@ -1596,7 +1569,6 @@ process_char(escp_t *dev, uint8_t ch)
return 0; return 0;
} }
static void static void
handle_char(escp_t *dev, uint8_t ch) handle_char(escp_t *dev, uint8_t ch)
{ {
@@ -1712,7 +1684,6 @@ handle_char(escp_t *dev, uint8_t ch)
} }
} }
/* TODO: This can be optimized quite a bit... I'm just too lazy right now ;-) */ /* TODO: This can be optimized quite a bit... I'm just too lazy right now ;-) */
static void static void
blit_glyph(escp_t *dev, unsigned destx, unsigned desty, int8_t add) blit_glyph(escp_t *dev, unsigned destx, unsigned desty, int8_t add)
@@ -1747,7 +1718,6 @@ blit_glyph(escp_t *dev, unsigned destx, unsigned desty, int8_t add)
} }
} }
/* Draw anti-aliased line. */ /* Draw anti-aliased line. */
static void static void
draw_hline(escp_t *dev, unsigned from_x, unsigned to_x, unsigned y, int8_t broken) draw_hline(escp_t *dev, unsigned from_x, unsigned to_x, unsigned y, int8_t broken)
@@ -1769,7 +1739,6 @@ draw_hline(escp_t *dev, unsigned from_x, unsigned to_x, unsigned y, int8_t broke
} }
} }
static void static void
setup_bit_image(escp_t *dev, uint8_t density, uint16_t num_columns) setup_bit_image(escp_t *dev, uint8_t density, uint16_t num_columns)
{ {
@@ -1882,7 +1851,6 @@ setup_bit_image(escp_t *dev, uint8_t density, uint16_t num_columns)
dev->bg_bytes_read = 0; dev->bg_bytes_read = 0;
} }
static void static void
print_bit_graph(escp_t *dev, uint8_t ch) print_bit_graph(escp_t *dev, uint8_t ch)
{ {
@@ -1939,7 +1907,6 @@ print_bit_graph(escp_t *dev, uint8_t ch)
dev->curr_x += 1.0 / dev->bg_h_density; dev->curr_x += 1.0 / dev->bg_h_density;
} }
static void static void
write_data(uint8_t val, void *priv) write_data(uint8_t val, void *priv)
{ {
@@ -1951,7 +1918,6 @@ write_data(uint8_t val, void *priv)
dev->data = val; dev->data = val;
} }
static void static void
write_ctrl(uint8_t val, void *priv) write_ctrl(uint8_t val, void *priv)
{ {
@@ -1990,7 +1956,6 @@ write_ctrl(uint8_t val, void *priv)
dev->autofeed = ((val & 0x02) > 0); dev->autofeed = ((val & 0x02) > 0);
} }
static uint8_t static uint8_t
read_data(void *priv) read_data(void *priv)
{ {
@@ -1999,7 +1964,6 @@ read_data(void *priv)
return dev->data; return dev->data;
} }
static uint8_t static uint8_t
read_ctrl(void *priv) read_ctrl(void *priv)
{ {
@@ -2008,7 +1972,6 @@ read_ctrl(void *priv)
return 0xe0 | (dev->autofeed ? 0x02 : 0x00) | (dev->ctrl & 0xfd); return 0xe0 | (dev->autofeed ? 0x02 : 0x00) | (dev->ctrl & 0xfd);
} }
static uint8_t static uint8_t
read_status(void *priv) read_status(void *priv)
{ {
@@ -2023,7 +1986,6 @@ read_status(void *priv)
return (ret); return (ret);
} }
static void * static void *
escp_init(void *lpt) escp_init(void *lpt)
{ {
@@ -2123,13 +2085,13 @@ escp_init(void *lpt)
return (dev); return (dev);
} }
static void static void
escp_close(void *priv) escp_close(void *priv)
{ {
escp_t *dev = (escp_t *) priv; escp_t *dev = (escp_t *) priv;
if (dev == NULL) return; if (dev == NULL)
return;
if (dev->page != NULL) { if (dev->page != NULL) {
/* Print last page if it contains data. */ /* Print last page if it contains data. */
@@ -2144,7 +2106,6 @@ escp_close(void *priv)
free(dev); free(dev);
} }
const lpt_device_t lpt_prt_escp_device = { const lpt_device_t lpt_prt_escp_device = {
.name = "Generic ESC/P Dot-Matrix", .name = "Generic ESC/P Dot-Matrix",
.internal_name = "dot_matrix", .internal_name = "dot_matrix",

View File

@@ -33,14 +33,12 @@
#include <86box/ui.h> #include <86box/ui.h>
#include <86box/prt_devs.h> #include <86box/prt_devs.h>
#ifdef _WIN32 #ifdef _WIN32
# define GSDLLAPI __stdcall # define GSDLLAPI __stdcall
#else #else
# define GSDLLAPI # define GSDLLAPI
#endif #endif
#define GS_ARG_ENCODING_UTF8 1 #define GS_ARG_ENCODING_UTF8 1
#define gs_error_Quit -101 #define gs_error_Quit -101
@@ -58,7 +56,6 @@
#define POSTSCRIPT_BUFFER_LENGTH 65536 #define POSTSCRIPT_BUFFER_LENGTH 65536
typedef struct typedef struct
{ {
const char *name; const char *name;
@@ -92,7 +89,6 @@ typedef struct gsapi_revision_s {
long revisiondate; long revisiondate;
} gsapi_revision_t; } gsapi_revision_t;
static int(GSDLLAPI *gsapi_revision)(gsapi_revision_t *pr, int len); static int(GSDLLAPI *gsapi_revision)(gsapi_revision_t *pr, int len);
static int(GSDLLAPI *gsapi_new_instance)(void **pinstance, void *caller_handle); static int(GSDLLAPI *gsapi_new_instance)(void **pinstance, void *caller_handle);
static void(GSDLLAPI *gsapi_delete_instance)(void *instance); static void(GSDLLAPI *gsapi_delete_instance)(void *instance);
@@ -114,7 +110,6 @@ static dllimp_t ghostscript_imports[] = {
static void *ghostscript_handle = NULL; static void *ghostscript_handle = NULL;
static void static void
reset_ps(ps_t *dev) reset_ps(ps_t *dev)
{ {
@@ -130,7 +125,6 @@ reset_ps(ps_t *dev)
timer_disable(&dev->timeout_timer); timer_disable(&dev->timeout_timer);
} }
static void static void
pulse_timer(void *priv) pulse_timer(void *priv)
{ {
@@ -144,7 +138,6 @@ pulse_timer(void *priv)
timer_disable(&dev->pulse_timer); timer_disable(&dev->pulse_timer);
} }
static int static int
convert_to_pdf(ps_t *dev) convert_to_pdf(ps_t *dev)
{ {
@@ -193,7 +186,6 @@ convert_to_pdf(ps_t *dev)
return code; return code;
} }
static void static void
write_buffer(ps_t *dev, bool finish) write_buffer(ps_t *dev, bool finish)
{ {
@@ -231,7 +223,6 @@ write_buffer(ps_t *dev, bool finish)
} }
} }
static void static void
timeout_timer(void *priv) timeout_timer(void *priv)
{ {
@@ -242,7 +233,6 @@ timeout_timer(void *priv)
timer_disable(&dev->timeout_timer); timer_disable(&dev->timeout_timer);
} }
static void static void
ps_write_data(uint8_t val, void *p) ps_write_data(uint8_t val, void *p)
{ {
@@ -254,7 +244,6 @@ ps_write_data(uint8_t val, void *p)
dev->data = (char) val; dev->data = (char) val;
} }
static void static void
process_data(ps_t *dev) process_data(ps_t *dev)
{ {
@@ -293,7 +282,6 @@ process_data(ps_t *dev)
dev->buffer[dev->buffer_pos] = 0; dev->buffer[dev->buffer_pos] = 0;
} }
static void static void
ps_write_ctrl(uint8_t val, void *p) ps_write_ctrl(uint8_t val, void *p)
{ {
@@ -326,7 +314,6 @@ ps_write_ctrl(uint8_t val, void *p)
dev->ctrl = val; dev->ctrl = val;
} }
static uint8_t static uint8_t
ps_read_status(void *p) ps_read_status(void *p)
{ {
@@ -339,7 +326,6 @@ ps_read_status(void *p)
return (ret); return (ret);
} }
static void * static void *
ps_init(void *lpt) ps_init(void *lpt)
{ {
@@ -379,7 +365,6 @@ ps_init(void *lpt)
return (dev); return (dev);
} }
static void static void
ps_close(void *p) ps_close(void *p)
{ {
@@ -399,7 +384,6 @@ ps_close(void *p)
free(dev); free(dev);
} }
const lpt_device_t lpt_prt_ps_device = { const lpt_device_t lpt_prt_ps_device = {
.name = "Generic PostScript Printer", .name = "Generic PostScript Printer",
.internal_name = "postscript", .internal_name = "postscript",

View File

@@ -66,10 +66,8 @@
#include <86box/printer.h> #include <86box/printer.h>
#include <86box/prt_devs.h> #include <86box/prt_devs.h>
#define FULL_PAGE 1 /* set if no top/bot margins */ #define FULL_PAGE 1 /* set if no top/bot margins */
/* Default page values (for now.) */ /* Default page values (for now.) */
#define PAGE_WIDTH 8.5 /* standard U.S. Letter */ #define PAGE_WIDTH 8.5 /* standard U.S. Letter */
#define PAGE_HEIGHT 11 #define PAGE_HEIGHT 11
@@ -85,7 +83,6 @@
#define PAGE_CPI 10.0 /* standard 10 cpi */ #define PAGE_CPI 10.0 /* standard 10 cpi */
#define PAGE_LPI 6.0 /* standard 6 lpi */ #define PAGE_LPI 6.0 /* standard 6 lpi */
typedef struct { typedef struct {
int8_t dirty; /* has the page been printed on? */ int8_t dirty; /* has the page been printed on? */
char pad; char pad;
@@ -96,7 +93,6 @@ typedef struct {
char *chars; /* character data */ char *chars; /* character data */
} psurface_t; } psurface_t;
typedef struct { typedef struct {
const char *name; const char *name;
@@ -139,7 +135,6 @@ typedef struct {
uint8_t ctrl; uint8_t ctrl;
} prnt_t; } prnt_t;
/* Dump the current page into a formatted file. */ /* Dump the current page into a formatted file. */
static void static void
dump_page(prnt_t *dev) dump_page(prnt_t *dev)
@@ -186,7 +181,6 @@ dump_page(prnt_t *dev)
fclose(fp); fclose(fp);
} }
static void static void
new_page(prnt_t *dev) new_page(prnt_t *dev)
{ {
@@ -200,7 +194,6 @@ new_page(prnt_t *dev)
dev->page->dirty = 0; dev->page->dirty = 0;
} }
static void static void
pulse_timer(void *priv) pulse_timer(void *priv)
{ {
@@ -214,7 +207,6 @@ pulse_timer(void *priv)
timer_disable(&dev->pulse_timer); timer_disable(&dev->pulse_timer);
} }
static void static void
timeout_timer(void *priv) timeout_timer(void *priv)
{ {
@@ -226,7 +218,6 @@ timeout_timer(void *priv)
timer_disable(&dev->timeout_timer); timer_disable(&dev->timeout_timer);
} }
static void static void
reset_printer(prnt_t *dev) reset_printer(prnt_t *dev)
{ {
@@ -257,7 +248,6 @@ reset_printer(prnt_t *dev)
timer_disable(&dev->timeout_timer); timer_disable(&dev->timeout_timer);
} }
static int static int
process_char(prnt_t *dev, uint8_t ch) process_char(prnt_t *dev, uint8_t ch)
{ {
@@ -344,13 +334,13 @@ process_char(prnt_t *dev, uint8_t ch)
return (0); return (0);
} }
static void static void
handle_char(prnt_t *dev) handle_char(prnt_t *dev)
{ {
uint8_t ch = dev->data; uint8_t ch = dev->data;
if (dev->page == NULL) return; if (dev->page == NULL)
return;
if (process_char(dev, ch) == 1) { if (process_char(dev, ch) == 1) {
/* Command was processed. */ /* Command was processed. */
@@ -369,24 +359,24 @@ handle_char(prnt_t *dev)
} }
} }
static void static void
write_data(uint8_t val, void *priv) write_data(uint8_t val, void *priv)
{ {
prnt_t *dev = (prnt_t *) priv; prnt_t *dev = (prnt_t *) priv;
if (dev == NULL) return; if (dev == NULL)
return;
dev->data = val; dev->data = val;
} }
static void static void
write_ctrl(uint8_t val, void *priv) write_ctrl(uint8_t val, void *priv)
{ {
prnt_t *dev = (prnt_t *) priv; prnt_t *dev = (prnt_t *) priv;
if (dev == NULL) return; if (dev == NULL)
return;
/* set autofeed value */ /* set autofeed value */
dev->autofeed = val & 0x02 ? 1 : 0; dev->autofeed = val & 0x02 ? 1 : 0;
@@ -417,7 +407,6 @@ write_ctrl(uint8_t val, void *priv)
dev->ctrl = val; dev->ctrl = val;
} }
static uint8_t static uint8_t
read_status(void *priv) read_status(void *priv)
{ {
@@ -432,7 +421,6 @@ read_status(void *priv)
return (ret); return (ret);
} }
static void * static void *
prnt_init(void *lpt) prnt_init(void *lpt)
{ {
@@ -460,7 +448,6 @@ prnt_init(void *lpt)
return (dev); return (dev);
} }
static void static void
prnt_close(void *priv) prnt_close(void *priv)
{ {
@@ -482,7 +469,6 @@ prnt_close(void *priv)
free(dev); free(dev);
} }
const lpt_device_t lpt_prt_text_device = { const lpt_device_t lpt_prt_text_device = {
.name = "Generic Text Printer", .name = "Generic Text Printer",
.internal_name = "text_prt", .internal_name = "text_prt",