diff io.c @ 1077:1a66d5165ea7

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.
author Michael Pavone <pavone@retrodev.com>
date Mon, 22 Aug 2016 09:46:18 -0700
parents 284d905ca582
children 22e87b739ad6
line wrap: on
line diff
--- a/io.c	Fri Aug 12 09:39:39 2016 -0700
+++ b/io.c	Mon Aug 22 09:46:18 2016 -0700
@@ -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 @@
 	}
 }
 
+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 @@
 			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 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: