Fixed printer IRQ handler, both printers now work with OS/2, fixes #374.
This commit is contained in:
@@ -8,15 +8,15 @@
|
||||
*
|
||||
* Implementation of the Generic ESC/P Dot-Matrix printer.
|
||||
*
|
||||
* Version: @(#)prt_escp.c 1.0.6 2018/11/09
|
||||
* Version: @(#)prt_escp.c 1.0.7 2019/09/23
|
||||
*
|
||||
* Authors: Michael Dr<44>ing, <michael@drueing.de>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Based on code by Frederic Weymann (originally for DosBox.)
|
||||
*
|
||||
* Copyright 2018 Michael Dr<44>ing.
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2018,2019 Michael Dr<44>ing.
|
||||
* Copyright 2019,2019 Fred N. van Kempen.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with
|
||||
* or without modification, are permitted provided that the
|
||||
@@ -62,6 +62,7 @@
|
||||
#include "../timer.h"
|
||||
#include "../mem.h"
|
||||
#include "../rom.h"
|
||||
#include "../pit.h"
|
||||
#include "../plat.h"
|
||||
#include "../plat_dynld.h"
|
||||
#include "../ui.h"
|
||||
@@ -201,6 +202,7 @@ typedef struct {
|
||||
|
||||
void *lpt;
|
||||
|
||||
pc_timer_t pulse_timer;
|
||||
pc_timer_t timeout_timer;
|
||||
|
||||
wchar_t page_fn[260];
|
||||
@@ -290,8 +292,6 @@ typedef struct {
|
||||
uint8_t msb; /* MSB mode, -1 = off */
|
||||
uint8_t ctrl;
|
||||
|
||||
uint8_t char_read;
|
||||
|
||||
PALETTE palcol;
|
||||
} escp_t;
|
||||
|
||||
@@ -425,6 +425,20 @@ new_page(escp_t *dev, int8_t save, int8_t resetx)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
pulse_timer(void *priv)
|
||||
{
|
||||
escp_t *dev = (escp_t *) priv;
|
||||
|
||||
if (dev->ack) {
|
||||
dev->ack = 0;
|
||||
lpt_irq(dev->lpt, 1);
|
||||
}
|
||||
|
||||
timer_disable(&dev->pulse_timer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
timeout_timer(void *priv)
|
||||
{
|
||||
@@ -518,8 +532,8 @@ reset_printer(escp_t *dev)
|
||||
static void
|
||||
reset_printer_hard(escp_t *dev)
|
||||
{
|
||||
dev->char_read = 0;
|
||||
lpt_irq(dev->lpt, 1);
|
||||
dev->ack = 0;
|
||||
timer_disable(&dev->pulse_timer);
|
||||
timer_disable(&dev->timeout_timer);
|
||||
reset_printer(dev);
|
||||
}
|
||||
@@ -1590,8 +1604,6 @@ handle_char(escp_t *dev, uint8_t ch)
|
||||
uint16_t line_start, line_y;
|
||||
double x_advance;
|
||||
|
||||
dev->char_read = 1;
|
||||
|
||||
if (dev->page == NULL)
|
||||
return;
|
||||
|
||||
@@ -1757,19 +1769,6 @@ draw_hline(escp_t *dev, unsigned from_x, unsigned to_x, unsigned y, int8_t broke
|
||||
}
|
||||
|
||||
|
||||
static int8_t
|
||||
print_ack(escp_t *dev)
|
||||
{
|
||||
if (dev->char_read) {
|
||||
dev->char_read = 0;
|
||||
lpt_irq(dev->lpt, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
setup_bit_image(escp_t *dev, uint8_t density, uint16_t num_columns)
|
||||
{
|
||||
@@ -1980,6 +1979,7 @@ write_ctrl(uint8_t val, void *priv)
|
||||
|
||||
/* ACK it, will be read on next READ STATUS. */
|
||||
dev->ack = 1;
|
||||
timer_set_delay_u64(&dev->pulse_timer, ISACONST);
|
||||
|
||||
timer_set_delay_u64(&dev->timeout_timer, 500000 * TIMER_USEC);
|
||||
}
|
||||
@@ -2016,7 +2016,7 @@ read_status(void *priv)
|
||||
|
||||
ret |= 0x80;
|
||||
|
||||
if (!print_ack(dev))
|
||||
if (!dev->ack)
|
||||
ret |= 0x40;
|
||||
|
||||
return(ret);
|
||||
@@ -2111,7 +2111,8 @@ escp_init(void *lpt)
|
||||
escp_log("ESC/P: created a virtual page of dimensions %d x %d pixels.\n",
|
||||
dev->page->w, dev->page->h);
|
||||
|
||||
timer_add(&dev->timeout_timer, timeout_timer, dev, 0);
|
||||
timer_add(&dev->pulse_timer, pulse_timer, dev, 0);
|
||||
timer_add(&dev->timeout_timer, timeout_timer, dev, 0);
|
||||
|
||||
return(dev);
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
* printer mechanics. This would lead to a page being 66 lines
|
||||
* of 80 characters each.
|
||||
*
|
||||
* Version: @(#)prt_text.c 1.0.6 2018/11/09
|
||||
* Version: @(#)prt_text.c 1.0.7 2019/09/23
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2018,2019 Fred N. van Kempen.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with
|
||||
* or without modification, are permitted provided that the
|
||||
@@ -59,6 +59,7 @@
|
||||
#include "../86box.h"
|
||||
#include "../device.h"
|
||||
#include "../timer.h"
|
||||
#include "../pit.h"
|
||||
#include "../plat.h"
|
||||
#include "../lpt.h"
|
||||
#include "printer.h"
|
||||
@@ -104,6 +105,7 @@ typedef struct {
|
||||
wchar_t filename[1024];
|
||||
|
||||
/* Printer timeout. */
|
||||
pc_timer_t pulse_timer;
|
||||
pc_timer_t timeout_timer;
|
||||
|
||||
/* page data (TODO: make configurable) */
|
||||
@@ -198,6 +200,20 @@ new_page(prnt_t *dev)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
pulse_timer(void *priv)
|
||||
{
|
||||
prnt_t *dev = (prnt_t *) priv;
|
||||
|
||||
if (dev->ack) {
|
||||
dev->ack = 0;
|
||||
lpt_irq(dev->lpt, 1);
|
||||
}
|
||||
|
||||
timer_disable(&dev->pulse_timer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
timeout_timer(void *priv)
|
||||
{
|
||||
@@ -222,15 +238,12 @@ reset_printer(prnt_t *dev)
|
||||
dev->bot_margin = PAGE_BMARGIN;
|
||||
dev->cpi = PAGE_CPI;
|
||||
dev->lpi = PAGE_LPI;
|
||||
dev->ack = 0;
|
||||
|
||||
/* Default page layout. */
|
||||
dev->max_chars = (int) ((dev->page_width - dev->left_margin - dev->right_margin) * dev->cpi);
|
||||
dev->max_lines = (int) ((dev->page_height -dev->top_margin - dev->bot_margin) * dev->lpi);
|
||||
|
||||
//INFO("PRNT: width=%.1fin,height=%.1fin cpi=%i lpi=%i cols=%i lines=%i\n",
|
||||
// dev->page_width, dev->page_height, (int)dev->cpi,
|
||||
// (int)dev->lpi, dev->max_chars, dev->max_lines);
|
||||
|
||||
dev->curr_x = dev->curr_y = 0;
|
||||
|
||||
if (dev->page != NULL)
|
||||
@@ -239,7 +252,8 @@ reset_printer(prnt_t *dev)
|
||||
/* Create a file for this page. */
|
||||
plat_tempfile(dev->filename, NULL, L".txt");
|
||||
|
||||
timer_disable(&dev->timeout_timer);
|
||||
timer_disable(&dev->pulse_timer);
|
||||
timer_disable(&dev->timeout_timer);
|
||||
}
|
||||
|
||||
|
||||
@@ -395,6 +409,7 @@ write_ctrl(uint8_t val, void *priv)
|
||||
/* ACK it, will be read on next READ STATUS. */
|
||||
dev->ack = 1;
|
||||
|
||||
timer_set_delay_u64(&dev->pulse_timer, ISACONST);
|
||||
timer_set_delay_u64(&dev->timeout_timer, 500000 * TIMER_USEC);
|
||||
}
|
||||
|
||||
@@ -406,19 +421,12 @@ static uint8_t
|
||||
read_status(void *priv)
|
||||
{
|
||||
prnt_t *dev = (prnt_t *)priv;
|
||||
uint8_t ret = 0xff;
|
||||
uint8_t ret = 0x1f;
|
||||
|
||||
if (dev == NULL) return(ret);
|
||||
ret |= 0x80;
|
||||
|
||||
ret = (dev->ack ? 0x00 : 0x40) |
|
||||
(dev->select ? 0x10 : 0x00) |
|
||||
(dev->busy ? 0x00 : 0x80) |
|
||||
(dev->int_pending ? 0x00 : 0x04) |
|
||||
(dev->error ? 0x00 : 0x08);
|
||||
|
||||
/* Clear ACK after reading status. */
|
||||
dev->ack = 0;
|
||||
lpt_irq(dev->lpt, 1);
|
||||
if (!dev->ack)
|
||||
ret |= 0x40;
|
||||
|
||||
return(ret);
|
||||
}
|
||||
@@ -445,6 +453,7 @@ prnt_init(void *lpt)
|
||||
dev->page->chars = (char *)malloc(dev->page->w * dev->page->h);
|
||||
memset(dev->page->chars, 0x00, dev->page->w * dev->page->h);
|
||||
|
||||
timer_add(&dev->pulse_timer, pulse_timer, dev, 0);
|
||||
timer_add(&dev->timeout_timer, timeout_timer, dev, 0);
|
||||
|
||||
return(dev);
|
||||
|
||||
Reference in New Issue
Block a user