1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-27 01:31:42 +00:00

Temporarily disabled the existing fast loading implementation in pursuit of another, and started trying to correct the lack of connection between the userport VIA and the tape drive.

This commit is contained in:
Thomas Harte 2017-05-06 22:00:12 -04:00
parent 6a37a02eee
commit 2edf73908c
3 changed files with 31 additions and 25 deletions

View File

@ -17,12 +17,13 @@ using namespace Commodore::Vic20;
Machine::Machine() :
rom_(nullptr),
is_running_at_zero_cost_(false),
tape_(1022727) {
tape_(new Storage::Tape::BinaryTapePlayer(1022727)) {
// create 6522s, serial port and bus
user_port_via_.reset(new UserPortVIA);
keyboard_via_.reset(new KeyboardVIA);
serial_port_.reset(new SerialPort);
serial_bus_.reset(new ::Commodore::Serial::Bus);
user_port_via_->set_tape(tape_);
// wire up the serial bus and serial port
Commodore::Serial::AttachPortAndBus(serial_port_, serial_bus_);
@ -35,7 +36,7 @@ Machine::Machine() :
// wire up the 6522s, tape and machine
user_port_via_->set_interrupt_delegate(this);
keyboard_via_->set_interrupt_delegate(this);
tape_.set_delegate(this);
tape_->set_delegate(this);
// establish the memory maps
set_memory_size(MemorySize::Default);
@ -124,11 +125,11 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
// PC hits the start of the loop that just waits for an interesting tape interrupt to have
// occurred then skip both 6522s and the tape ahead to the next interrupt without any further
// CPU or 6560 costs.
if(use_fast_tape_hack_ && tape_.has_tape() && address == 0xf92f && operation == CPU6502::BusOperation::ReadOpcode) {
while(!user_port_via_->get_interrupt_line() && !keyboard_via_->get_interrupt_line() && !tape_.get_tape()->is_at_end()) {
user_port_via_->run_for_cycles(1);
keyboard_via_->run_for_cycles(1);
tape_.run_for_cycles(1);
if(use_fast_tape_hack_ && tape_->has_tape() && operation == CPU6502::BusOperation::ReadOpcode) {
if(address == 0xf7b2) {
printf("Find header");
} else if(address == 0xf90b) {
printf("Tape receive");
}
}
} else {
@ -149,7 +150,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
typer_.reset();
}
}
tape_.run_for_cycles(1);
tape_->run_for_cycles(1);
if(c1540_) c1540_->run_for_cycles(1);
// If using fast tape then:
@ -163,19 +164,19 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
// Note the additional test above for PC hitting 0xf92f, which is a loop in the ROM that waits
// for an interesting interrupt. Up there the fast tape hack goes even further in also cutting
// the CPU out of the action.
if(use_fast_tape_hack_ && tape_.has_tape()) {
/* if(use_fast_tape_hack_ && tape_->has_tape()) {
if(address == 0xf98e && operation == CPU6502::BusOperation::ReadOpcode) {
is_running_at_zero_cost_ = true;
set_clock_is_unlimited(true);
}
if(
(address < 0xe000 && operation == CPU6502::BusOperation::ReadOpcode) ||
tape_.get_tape()->is_at_end()
tape_->get_tape()->is_at_end()
) {
is_running_at_zero_cost_ = false;
set_clock_is_unlimited(false);
}
}
}*/
return 1;
}
@ -265,7 +266,7 @@ void Machine::set_rom(ROMSlot slot, size_t length, const uint8_t *data) {
void Machine::configure_as_target(const StaticAnalyser::Target &target) {
if(target.tapes.size()) {
tape_.set_tape(target.tapes.front());
tape_->set_tape(target.tapes.front());
}
if(target.disks.size()) {
@ -292,8 +293,8 @@ void Machine::configure_as_target(const StaticAnalyser::Target &target) {
write_to_map(processor_read_memory_map_, rom_, rom_address_, 0x2000);
}
if(should_automatically_load_media_) {
if(target.loadingCommand.length()) { // TODO: and automatic loading option enabled
// if(should_automatically_load_media_) {
if(target.loadingCommand.length()) {
set_typer_for_string(target.loadingCommand.c_str());
}
@ -308,7 +309,7 @@ void Machine::configure_as_target(const StaticAnalyser::Target &target) {
set_memory_size(ThirtyTwoKB);
break;
}
}
// }
}
void Machine::tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape) {
@ -329,15 +330,16 @@ void Machine::install_disk_rom() {
uint8_t UserPortVIA::get_port_input(Port port) {
if(!port) {
return port_a_; // TODO: bit 6 should be high if there is no tape, low otherwise
return port_a_ | (tape_->has_tape() ? 0x00 : 0x40);
}
return 0xff;
}
void UserPortVIA::set_control_line_output(Port port, Line line, bool value) {
// if(port == Port::A && line == Line::Two) {
// printf("Tape motor %s\n", value ? "on" : "off");
// }
if(port == Port::A && line == Line::Two) {
tape_->set_motor_control(!value);
printf("Tape motor: %d\n", value ? 1 : 0);
}
}
void UserPortVIA::set_serial_line_state(::Commodore::Serial::Line line, bool value) {
@ -369,6 +371,10 @@ void UserPortVIA::set_serial_port(std::shared_ptr<::Commodore::Serial::Port> ser
serial_port_ = serialPort;
}
void UserPortVIA::set_tape(std::shared_ptr<Storage::Tape::BinaryTapePlayer> tape) {
tape_ = tape;
}
#pragma mark - KeyboardVIA
KeyboardVIA::KeyboardVIA() : port_b_(0xff) {

View File

@ -87,10 +87,12 @@ class UserPortVIA: public MOS::MOS6522<UserPortVIA>, public MOS::MOS6522IRQDeleg
void set_port_output(Port port, uint8_t value, uint8_t mask);
void set_serial_port(std::shared_ptr<::Commodore::Serial::Port> serialPort);
void set_tape(std::shared_ptr<Storage::Tape::BinaryTapePlayer> tape);
private:
uint8_t port_a_;
std::weak_ptr<::Commodore::Serial::Port> serial_port_;
std::shared_ptr<Storage::Tape::BinaryTapePlayer> tape_;
};
class KeyboardVIA: public MOS::MOS6522<KeyboardVIA>, public MOS::MOS6522IRQDelegate {
@ -164,7 +166,7 @@ class Machine:
void set_region(Region region);
inline void set_use_fast_tape_hack(bool activate) { use_fast_tape_hack_ = activate; }
inline void set_should_automatically_load_media(bool activate) { should_automatically_load_media_ = activate; }
// inline void set_should_automatically_load_media(bool activate) { should_automatically_load_media_ = activate; }
// to satisfy CPU6502::Processor
unsigned int perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value);
@ -213,15 +215,13 @@ class Machine:
std::shared_ptr<::Commodore::Serial::Bus> serial_bus_;
// Tape
Storage::Tape::BinaryTapePlayer tape_;
bool use_fast_tape_hack_, should_automatically_load_media_;
std::shared_ptr<Storage::Tape::BinaryTapePlayer> tape_;
bool use_fast_tape_hack_;//, should_automatically_load_media_;
bool is_running_at_zero_cost_;
// Disk
std::shared_ptr<::Commodore::C1540::Machine> c1540_;
void install_disk_rom();
// Autoload string
};
}

View File

@ -181,7 +181,7 @@ using namespace Commodore::Vic20;
- (void)setShouldLoadAutomatically:(BOOL)shouldLoadAutomatically {
_shouldLoadAutomatically = shouldLoadAutomatically;
@synchronized(self) {
_vic20.set_should_automatically_load_media(shouldLoadAutomatically ? true : false);
// _vic20.set_should_automatically_load_media(shouldLoadAutomatically ? true : false);
}
}