From 4469010fb16b7e3b94c3730610eb4b0b705040c8 Mon Sep 17 00:00:00 2001 From: Gregor Riepl Date: Sun, 4 Sep 2022 10:24:01 +0200 Subject: [PATCH] Update patch, better timing info --- vice-tape-rs232.patch | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/vice-tape-rs232.patch b/vice-tape-rs232.patch index 8dd71ea..ac5055b 100644 --- a/vice-tape-rs232.patch +++ b/vice-tape-rs232.patch @@ -12,10 +12,10 @@ index cd38b6d..cf10121 100644 + tape-rs232.h diff --git a/src/tapeport/tape-rs232.c b/src/tapeport/tape-rs232.c new file mode 100644 -index 0000000..680a1c4 +index 0000000..416657b --- /dev/null +++ b/src/tapeport/tape-rs232.c -@@ -0,0 +1,270 @@ +@@ -0,0 +1,274 @@ +/* + * tape-rs232.h: RS-232 interface for the PET, connected to the tape port + * @@ -80,6 +80,9 @@ index 0000000..680a1c4 +} tape_rs232_state_t; +static tape_rs232_state_t tape_rs232_state[TAPEPORT_MAX_PORTS] = { { false, }, }; + ++CLOCK last_maincpu_clk = 0; ++CLOCK last_sample_maincpu_clk = 0; ++ +/* ------------------------------------------------------------------------- */ + +/* device interface prototypes */ @@ -186,7 +189,7 @@ index 0000000..680a1c4 + alarm_unset(dev->read_alarm); + } +} -+CLOCK last_maincpu_clk = 0; ++ +static void tape_rs232_write(int port, int write_bit) +{ + if (port < 0 || port >= TAPEPORT_MAX_PORTS) { @@ -235,7 +238,8 @@ index 0000000..680a1c4 + dev->write_register = (dev->write_register >> 1) | (dev->write_level ? 0x200 : 0x000); + /* and decrement the counter */ + --dev->write_shift; -+ long delta = (long) maincpu_clk - last_maincpu_clk; ++ long delta = (long) maincpu_clk - last_sample_maincpu_clk; ++ last_sample_maincpu_clk = maincpu_clk; + last_maincpu_clk = maincpu_clk; + log_debug("tape_rs232: sample %d reg 0x%04x offset %lu clock %lu delta %ld shift %u", dev->write_level, dev->write_register, offset, maincpu_clk, delta, dev->write_shift); + /* transmission complete? */