From 4a56a7e2dfe615e03e81e29952003291090470fe Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Mon, 22 Aug 2016 09:46:18 -0700 Subject: Cleanup the separation of render backend and VDP code in preparation for having extra debug windows. Make determination of H40/H32 based on number of lines in each mode. --- io.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'io.c') diff --git a/io.c b/io.c index 30783a9..acab08f 100644 --- a/io.c +++ b/io.c @@ -21,6 +21,7 @@ #include "util.h" #define CYCLE_NEVER 0xFFFFFFFF +#define MIN_POLL_INTERVAL 6840 const char * device_type_names[] = { "3-button gamepad", @@ -1146,6 +1147,7 @@ void mouse_check_ready(io_port *port, uint32_t current_cycle) } } +uint32_t last_poll_cycle; void io_adjust_cycles(io_port * port, uint32_t current_cycle, uint32_t deduction) { /*uint8_t control = pad->control | 0x80; @@ -1167,6 +1169,11 @@ void io_adjust_cycles(io_port * port, uint32_t current_cycle, uint32_t deduction port->device.mouse.ready_cycle -= deduction; } } + if (last_poll_cycle >= deduction) { + last_poll_cycle -= deduction; + } else { + last_poll_cycle = 0; + } } #ifndef _WIN32 @@ -1345,6 +1352,10 @@ uint8_t io_data_read(io_port * port, uint32_t current_cycle) uint8_t output = (control & port->output) | (~control & 0xFF); uint8_t th = output & 0x40; uint8_t input; + if (current_cycle - last_poll_cycle > MIN_POLL_INTERVAL) { + process_events(); + last_poll_cycle = current_cycle; + } switch (port->device_type) { case IO_GAMEPAD3: -- cgit v1.2.3