From 9036cf3b7cf8d0467772dee53db06d6313309428 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 19 Jan 2016 23:03:27 -0500 Subject: [PATCH] Thus did the first UEF load. --- Machines/Electron/Electron.cpp | 33 ++++++++++++++++++--------------- Machines/Electron/Electron.hpp | 3 ++- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index 290bee98e..c74f5953f 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -103,7 +103,9 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin case 0x4: if(isReadOperation(operation)) { - *value = (uint8_t)_tape.dataRegister; + *value = (uint8_t)(_tape.dataRegister >> 2); + _interruptStatus &= ~InterruptTransmitDataEmpty; + evaluate_interrupts(); } printf("Cassette\n"); break; @@ -328,29 +330,30 @@ inline void Machine::get_next_tape_pulse() inline void Machine::push_tape_bit(uint16_t bit) { - _tape.dataRegister = (uint16_t)((_tape.dataRegister >> 1) | (bit << 9)); + _tape.dataRegister = (uint16_t)((_tape.dataRegister >> 1) | (bit << 10)); - if(_tape.dataRegister == 0x3ff) - _interruptStatus |= InterruptHighToneDetect; - else - _interruptStatus &= !InterruptHighToneDetect; - - if(_tape.bits_since_start > 0) + if(_tape.bits_since_start) { _tape.bits_since_start--; - if(_tape.bits_since_start == 0) + if(_tape.bits_since_start == 7) { - printf("%02x [%c]\n", _tape.dataRegister&0xff, _tape.dataRegister&0x7f); - _interruptStatus |= InterruptTransmitDataEmpty; + _interruptStatus &= ~InterruptTransmitDataEmpty; } } - - if(!bit && !_tape.bits_since_start) + else { - _tape.bits_since_start = 10; - } + if((_tape.dataRegister&0x3) == 0x1) + { + _interruptStatus |= InterruptTransmitDataEmpty; + _tape.bits_since_start = 9; + } + if(_tape.dataRegister == 0x3ff) + _interruptStatus |= InterruptHighToneDetect; + else + _interruptStatus &= ~InterruptHighToneDetect; + } printf("."); evaluate_interrupts(); diff --git a/Machines/Electron/Electron.hpp b/Machines/Electron/Electron.hpp index 26d943619..89b616348 100644 --- a/Machines/Electron/Electron.hpp +++ b/Machines/Electron/Electron.hpp @@ -114,9 +114,10 @@ class Machine: public CPU6502::Processor { std::shared_ptr pulseStepper; uint32_t time_into_pulse; bool is_running; - uint16_t dataRegister; int bits_since_start; + uint16_t dataRegister; + enum { Long, Short, Unrecognised } crossings[4];