Timer improvements for emulated printers

This commit is contained in:
Cacodemon345
2025-07-06 01:21:34 +06:00
parent f36be5ea4e
commit 9cad5f501b
3 changed files with 48 additions and 0 deletions

View File

@@ -1906,6 +1906,13 @@ strobe(uint8_t old, uint8_t val, void *priv)
/* Process incoming character. */ /* Process incoming character. */
handle_char(dev, dev->data); handle_char(dev, dev->data);
if (timer_is_enabled(&dev->timeout_timer)) {
timer_disable(&dev->timeout_timer);
#ifdef USE_DYNAREC
if (cpu_use_dynarec)
update_tsc();
#endif
}
/* ACK it, will be read on next READ STATUS. */ /* ACK it, will be read on next READ STATUS. */
dev->ack = 1; dev->ack = 1;
timer_set_delay_u64(&dev->pulse_timer, ISACONST); timer_set_delay_u64(&dev->pulse_timer, ISACONST);
@@ -1940,6 +1947,13 @@ write_ctrl(uint8_t val, void *priv)
/* Process incoming character. */ /* Process incoming character. */
handle_char(dev, dev->data); handle_char(dev, dev->data);
if (timer_is_enabled(&dev->timeout_timer)) {
timer_disable(&dev->timeout_timer);
#ifdef USE_DYNAREC
if (cpu_use_dynarec)
update_tsc();
#endif
}
/* ACK it, will be read on next READ STATUS. */ /* ACK it, will be read on next READ STATUS. */
dev->ack = 1; dev->ack = 1;
timer_set_delay_u64(&dev->pulse_timer, ISACONST); timer_set_delay_u64(&dev->pulse_timer, ISACONST);

View File

@@ -34,6 +34,7 @@
#include <86box/plat_dynld.h> #include <86box/plat_dynld.h>
#include <86box/ui.h> #include <86box/ui.h>
#include <86box/prt_devs.h> #include <86box/prt_devs.h>
#include "cpu.h"
#ifdef _WIN32 #ifdef _WIN32
# define GSDLLAPI __stdcall # define GSDLLAPI __stdcall
@@ -341,6 +342,14 @@ ps_strobe(uint8_t old, uint8_t val, void *priv)
if (!(val & 0x01) && (old & 0x01)) { if (!(val & 0x01) && (old & 0x01)) {
process_data(dev); process_data(dev);
if (timer_is_enabled(&dev->timeout_timer)) {
timer_disable(&dev->timeout_timer);
#ifdef USE_DYNAREC
if (cpu_use_dynarec)
update_tsc();
#endif
}
dev->ack = true; dev->ack = true;
timer_set_delay_u64(&dev->pulse_timer, ISACONST); timer_set_delay_u64(&dev->pulse_timer, ISACONST);
@@ -371,6 +380,14 @@ ps_write_ctrl(uint8_t val, void *priv)
if (!(val & 0x01) && (dev->ctrl & 0x01)) { if (!(val & 0x01) && (dev->ctrl & 0x01)) {
process_data(dev); process_data(dev);
if (timer_is_enabled(&dev->timeout_timer)) {
timer_disable(&dev->timeout_timer);
#ifdef USE_DYNAREC
if (cpu_use_dynarec)
update_tsc();
#endif
}
dev->ack = true; dev->ack = true;
timer_set_delay_u64(&dev->pulse_timer, ISACONST); timer_set_delay_u64(&dev->pulse_timer, ISACONST);

View File

@@ -63,6 +63,7 @@
#include <86box/lpt.h> #include <86box/lpt.h>
#include <86box/printer.h> #include <86box/printer.h>
#include <86box/prt_devs.h> #include <86box/prt_devs.h>
#include "cpu.h"
#define FULL_PAGE 1 /* set if no top/bot margins */ #define FULL_PAGE 1 /* set if no top/bot margins */
@@ -391,6 +392,14 @@ strobe(uint8_t old, uint8_t val, void *priv)
/* Process incoming character. */ /* Process incoming character. */
handle_char(dev); handle_char(dev);
if (timer_is_enabled(&dev->timeout_timer)) {
timer_disable(&dev->timeout_timer);
#ifdef USE_DYNAREC
if (cpu_use_dynarec)
update_tsc();
#endif
}
/* ACK it, will be read on next READ STATUS. */ /* ACK it, will be read on next READ STATUS. */
dev->ack = 1; dev->ack = 1;
@@ -429,6 +438,14 @@ write_ctrl(uint8_t val, void *priv)
/* ACK it, will be read on next READ STATUS. */ /* ACK it, will be read on next READ STATUS. */
dev->ack = 1; dev->ack = 1;
if (timer_is_enabled(&dev->timeout_timer)) {
timer_disable(&dev->timeout_timer);
#ifdef USE_DYNAREC
if (cpu_use_dynarec)
update_tsc();
#endif
}
timer_set_delay_u64(&dev->pulse_timer, ISACONST); timer_set_delay_u64(&dev->pulse_timer, ISACONST);
timer_set_delay_u64(&dev->timeout_timer, 5000000 * TIMER_USEC); timer_set_delay_u64(&dev->timeout_timer, 5000000 * TIMER_USEC);
} }