--- previous/src/printer.c 2018/04/24 19:29:54 1.1 +++ previous/src/printer.c 2018/04/24 19:33:14 1.1.1.3 @@ -17,10 +17,9 @@ #include "statusbar.h" #include "file.h" -#include "png.h" - -#define USE_PNG_PRINTING 1 - +#if HAVE_LIBPNG +#include +#endif #define IO_SEG_MASK 0x1FFFF @@ -256,7 +255,7 @@ void lp_release_interrupt(void) { #define LP_GPO_CMD_BIT 0x02 #define LP_GPO_BUSY 0x01 -void lp_gpo(Uint8 cmd) { +static void lp_gpo(Uint8 cmd) { if (cmd&LP_GPO_DENSITY) { Log_Printf(LOG_LP_LEVEL,"[LP] Printer 300 DPI mode"); } @@ -283,7 +282,7 @@ void lp_gpo(Uint8 cmd) { lp_gpo_access(cmd); } -void lp_gpi(void) { +static void lp_gpi(void) { nlp.data = (~nlp.stat)<<24; nlp.csr.cmd = LP_RES_GPI; @@ -363,7 +362,7 @@ void lp_interface_command(Uint8 cmd, Uin lp_buffer.size = 0; } Statusbar_AddMessage("Laser Printer Printing Page.", 0); - CycInt_AddRelativeInterrupt(1000, INT_CPU_CYCLE, INTERRUPT_LP_IO); + CycInt_AddRelativeInterruptUs(1000, 100, INTERRUPT_LP_IO); } else { Log_Printf(LOG_LP_LEVEL,"[LP] Disable printer data transfer"); if (lp_data_transfer) { @@ -472,16 +471,16 @@ Uint32 lp_data_read(void) { #define STAT15_NOTONER 0x04 -Uint8 lp_serial_status[16] = { +static Uint8 lp_serial_status[16] = { 0,0,0,0, 0,STAT5_A4,0,0, 0,0,0,0, 0,0,0,0 }; -Uint8 lp_serial_phase = 0; +static Uint8 lp_serial_phase = 0; -Uint8 lp_printer_status(Uint8 num) { +static Uint8 lp_printer_status(Uint8 num) { int i; Uint8 val; @@ -520,7 +519,7 @@ void lp_printer_reset(void) { lp_serial_phase = 0; } -Uint8 lp_printer_command(Uint8 cmd) { +static Uint8 lp_printer_command(Uint8 cmd) { switch (cmd) { case CMD_STATUS0: Log_Printf(LOG_LP_LEVEL, "[LP] Read status register 0"); @@ -628,7 +627,7 @@ void Printer_IO_Handler(void) { lp_buffer.size = 0; - CycInt_AddRelativeInterrupt(200000, INT_CPU_CYCLE, INTERRUPT_LP_IO); + CycInt_AddRelativeInterruptUs(10000, 1000, INTERRUPT_LP_IO); } } @@ -648,8 +647,8 @@ void Printer_Reset(void) { /* Helper function for building path and filename of output file */ -char *lp_get_filename(void) { - static char *lp_outfile = NULL; +static const char *lp_get_filename(void) { + static const char *lp_outfile = NULL; static char lp_filename[32]; static char lp_extension[16]; static int lp_pagecount = 0; @@ -683,7 +682,7 @@ char *lp_get_filename(void) { /* PNG printing functions */ -#if USE_PNG_PRINTING +#if HAVE_LIBPNG const int MAX_PAGE_LEN = 400 * 14; // 14 inches is the length of US legal paper, longest paper that fits into the NeXT printer cartridge png_structp png_ptr = NULL; png_infop png_info_ptr = NULL; @@ -692,11 +691,11 @@ int png_width; int png_height; int png_count; int png_page_count = 0; -char* png_path; +const char* png_path; #endif void lp_png_setup(Uint32 data) { -#if USE_PNG_PRINTING +#if HAVE_LIBPNG int i; png_width = ((data >> 16) & 0x7F) * 32; @@ -729,7 +728,7 @@ void lp_png_setup(Uint32 data) { } void lp_png_print(void) { -#if USE_PNG_PRINTING +#if HAVE_LIBPNG int i; for (i = 0; i < lp_buffer.size; i++) { @@ -740,7 +739,7 @@ void lp_png_print(void) { } void lp_png_finish(void) { -#if USE_PNG_PRINTING +#if HAVE_LIBPNG png_set_IHDR(png_ptr, png_info_ptr, png_width,