summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sux.h24
1 files changed, 19 insertions, 5 deletions
diff --git a/sux.h b/sux.h
index efda8f0..18087a0 100644
--- a/sux.h
+++ b/sux.h
@@ -357,11 +357,25 @@ static void *memcopy(void *restrict dst, const void *restrict src, unsigned int
return dst;
}
-
-static /*inline*/ uint64_t read_value(struct sux *cpu, uint64_t reg, uint64_t address, uint8_t size, uint8_t inc_clk, uint8_t check_io) {
+static void tick(struct sux *cpu, uint8_t inc_clk) {
#if getclk
cpu->clk += inc_clk;
#endif
+ #if (IO || debug) && !branch
+ #if keypoll
+ pthread_mutex_lock(&mutex);
+ #endif
+ get_key(scr, 0, cpu->clk);
+ #if keypoll
+ pthread_mutex_unlock(&mutex);
+ #endif
+ #endif
+}
+
+static /*inline*/ uint64_t read_value(struct sux *cpu, uint64_t reg, uint64_t address, uint8_t size, uint8_t inc_clk, uint8_t check_io) {
+ if (inc_clk) {
+ tick(cpu, inc_clk);
+ }
size = (size > 7) ? 7 : size;
uint64_t mask = (-(uint64_t)1 >> ((7 - size) * 8));
if (address < mem_size) {
@@ -415,9 +429,9 @@ static /*inline*/ void write_value(struct sux *cpu, uint64_t value, uint64_t add
#endif
#endif
}
- #if getclk
- cpu->clk += inc_clk;
- #endif
+ if (inc_clk) {
+ tick(cpu, inc_clk);
+ }
}
static /*inline*/ uint64_t offset_addr(struct sux *cpu, uint64_t offset, uint8_t size, uint8_t inc_clk, uint8_t prefix) {