1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-26 09:29:45 +00:00

Factored out the now-sampling binary-level tape player from the Vic and connected it up to the Oric.

This commit is contained in:
Thomas Harte 2016-10-15 21:21:18 -04:00
parent 9730e8247f
commit 6d7c3f6ac2
5 changed files with 54 additions and 71 deletions

View File

@ -16,7 +16,8 @@ using namespace Commodore::Vic20;
Machine::Machine() :
_rom(nullptr),
_is_running_at_zero_cost(false)
_is_running_at_zero_cost(false),
_tape(1022727)
{
// create 6522s, serial port and bus
_userPortVIA.reset(new UserPortVIA);
@ -350,36 +351,13 @@ void Machine::configure_as_target(const StaticAnalyser::Target &target)
}
}
//void Machine::set_tape(std::shared_ptr<Storage::Tape::Tape> tape)
//{
// _tape.set_tape(tape);
// if(_should_automatically_load_media) set_typer_for_string("LOAD\nRUN\n");
//}
void Machine::tape_did_change_input(Tape *tape)
void Machine::tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape)
{
_keyboardVIA->set_control_line_input(KeyboardVIA::Port::A, KeyboardVIA::Line::One, tape->get_input());
}
#pragma mark - Disc
/*void Machine::set_disk(std::shared_ptr<Storage::Disk::Disk> disk)
{
// construct the 1540
_c1540.reset(new ::Commodore::C1540::Machine);
// attach it to the serial bus
_c1540->set_serial_bus(_serialBus);
// hand it the disk
_c1540->set_disk(disk);
// install the ROM if it was previously set
install_disk_rom();
if(_should_automatically_load_media) set_typer_for_string("LOAD\"*\",8,1\nRUN\n");
}*/
void Machine::install_disk_rom()
{
if(_driveROM && _c1540)
@ -496,20 +474,3 @@ bool Machine::typer_set_next_character(::Utility::Typer *typer, char character,
return true;
}
#pragma mark - Tape
Tape::Tape() : TapePlayer(1022727) {}
void Tape::set_motor_control(bool enabled) {}
void Tape::set_tape_output(bool set) {}
void Tape::process_input_pulse(Storage::Tape::PRG::Pulse pulse)
{
bool new_input_level = pulse.type == Storage::Tape::PRG::Pulse::Low;
if(_input_level != new_input_level)
{
_input_level = new_input_level;
if(_delegate) _delegate->tape_did_change_input(this);
}
}

View File

@ -214,29 +214,6 @@ class SerialPort : public ::Commodore::Serial::Port {
std::weak_ptr<UserPortVIA> _userPortVIA;
};
class Tape: public Storage::Tape::TapePlayer {
public:
Tape();
void set_motor_control(bool enabled);
void set_tape_output(bool set);
inline bool get_input() { return _input_level; }
class Delegate {
public:
virtual void tape_did_change_input(Tape *tape) = 0;
};
void set_delegate(Delegate *delegate)
{
_delegate = delegate;
}
private:
Delegate *_delegate;
virtual void process_input_pulse(Storage::Tape::Tape::Pulse pulse);
bool _input_level;
};
class Vic6560: public MOS::MOS6560<Vic6560> {
public:
inline void perform_read(uint16_t address, uint8_t *pixel_data, uint8_t *colour_data)
@ -254,7 +231,7 @@ class Machine:
public CRTMachine::Machine,
public MOS::MOS6522IRQDelegate::Delegate,
public Utility::TypeRecipient,
public Tape::Delegate,
public Storage::Tape::BinaryTapePlayer::Delegate,
public ConfigurationTarget::Machine {
public:
@ -301,7 +278,7 @@ class Machine:
virtual bool typer_set_next_character(Utility::Typer *typer, char character, int phase);
// for Tape::Delegate
virtual void tape_did_change_input(Tape *tape);
virtual void tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape);
private:
uint8_t _characterROM[0x1000];
@ -332,7 +309,7 @@ class Machine:
// std::shared_ptr<::Commodore::Serial::DebugPort> _debugPort;
// Tape
Tape _tape;
Storage::Tape::BinaryTapePlayer _tape;
bool _use_fast_tape_hack, _should_automatically_load_media;
bool _is_running_at_zero_cost;

View File

@ -10,7 +10,7 @@
using namespace Oric;
Machine::Machine() : _cycles_since_video_update(0)
Machine::Machine() : _cycles_since_video_update(0), _tape(1000000)
{
set_clock_rate(1000000);
_via.set_interrupt_delegate(this);
@ -107,3 +107,9 @@ void Machine::clear_all_keys()
{
memset(_keyboard->rows, 0, sizeof(_keyboard->rows));
}
void Machine::tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape_player)
{
// set CB1
_via.set_control_line_input(VIA::Port::B, VIA::Line::One, tape_player->get_input());
}

View File

@ -51,7 +51,8 @@ class Machine:
public CPU6502::Processor<Machine>,
public CRTMachine::Machine,
public ConfigurationTarget::Machine,
public MOS::MOS6522IRQDelegate::Delegate {
public MOS::MOS6522IRQDelegate::Delegate,
public Storage::Tape::BinaryTapePlayer::Delegate {
public:
Machine();
@ -77,6 +78,9 @@ class Machine:
// to satisfy MOS::MOS6522IRQDelegate::Delegate
void mos6522_did_change_interrupt_status(void *mos6522);
// to satisfy Storage::Tape::BinaryTapePlayer::Delegate
void tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape_player);
private:
// RAM and ROM
uint8_t _ram[65536], _rom[16384];
@ -86,12 +90,17 @@ class Machine:
// Outputs
std::unique_ptr<VideoOutput> _videoOutput;
//
// Keyboard
class Keyboard {
public:
uint8_t row;
uint8_t rows[8];
};
// Tape player
Storage::Tape::BinaryTapePlayer _tape;
// VIA
class VIA: public MOS::MOS6522<VIA>, public MOS::MOS6522IRQDelegate {
public:
using MOS6522IRQDelegate::set_interrupt_status;

View File

@ -94,6 +94,36 @@ class TapePlayer: public TimedEventLoop {
Tape::Pulse _current_pulse;
};
class BinaryTapePlayer: public TapePlayer {
public:
BinaryTapePlayer(unsigned int input_clock_rate) : TapePlayer(input_clock_rate) {}
void set_motor_control(bool enabled) {} // TODO
void set_tape_output(bool set) {} // TODO
inline bool get_input() { return _input_level; }
class Delegate {
public:
virtual void tape_did_change_input(BinaryTapePlayer *tape_player) = 0;
};
void set_delegate(Delegate *delegate)
{
_delegate = delegate;
}
private:
Delegate *_delegate;
virtual void process_input_pulse(Storage::Tape::Tape::Pulse pulse)
{
bool new_input_level = pulse.type == Tape::Pulse::Low;
if(_input_level != new_input_level)
{
_input_level = new_input_level;
if(_delegate) _delegate->tape_did_change_input(this);
}
}
bool _input_level;
};
}
}