mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-27 16:31:31 +00:00
Made a quick first attempt at all-the-way-through tape wiring for the Vic.
This commit is contained in:
parent
37ba42a52f
commit
c306d705e1
@ -178,6 +178,7 @@ template <class T> class MOS6522 {
|
|||||||
_registers.interrupt_flags |= port ? InterruptFlag::CB1ActiveEdge : InterruptFlag::CA1ActiveEdge;
|
_registers.interrupt_flags |= port ? InterruptFlag::CB1ActiveEdge : InterruptFlag::CA1ActiveEdge;
|
||||||
reevaluate_interrupts();
|
reevaluate_interrupts();
|
||||||
}
|
}
|
||||||
|
_control_inputs[port].line_one = value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Line::Two:
|
case Line::Two:
|
||||||
|
@ -17,6 +17,7 @@ Machine::Machine() :
|
|||||||
{
|
{
|
||||||
_userPortVIA.set_delegate(this);
|
_userPortVIA.set_delegate(this);
|
||||||
_keyboardVIA.set_delegate(this);
|
_keyboardVIA.set_delegate(this);
|
||||||
|
_tape.set_delegate(this);
|
||||||
set_reset_line(true);
|
set_reset_line(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,6 +84,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
|
|||||||
_userPortVIA.run_for_half_cycles(2);
|
_userPortVIA.run_for_half_cycles(2);
|
||||||
_keyboardVIA.run_for_half_cycles(2);
|
_keyboardVIA.run_for_half_cycles(2);
|
||||||
if(_typer) _typer->update(1);
|
if(_typer) _typer->update(1);
|
||||||
|
_tape.run_for_cycles(1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,12 +142,12 @@ void Machine::add_prg(size_t length, const uint8_t *data)
|
|||||||
|
|
||||||
void Machine::set_tape(std::shared_ptr<Storage::Tape> tape)
|
void Machine::set_tape(std::shared_ptr<Storage::Tape> tape)
|
||||||
{
|
{
|
||||||
tape->get_next_pulse();
|
_tape.set_tape(tape);
|
||||||
tape->get_next_pulse();
|
}
|
||||||
tape->get_next_pulse();
|
|
||||||
tape->get_next_pulse();
|
void Machine::tape_did_change_input(Tape *tape)
|
||||||
tape->get_next_pulse();
|
{
|
||||||
tape->get_next_pulse();
|
_keyboardVIA.set_control_line(KeyboardVIA::Port::A, KeyboardVIA::Line::One, tape->get_input());
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Typer
|
#pragma mark - Typer
|
||||||
@ -262,3 +264,20 @@ bool Machine::typer_set_next_character(::Utility::Typer *typer, char character,
|
|||||||
|
|
||||||
return true;
|
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::Pulse pulse)
|
||||||
|
{
|
||||||
|
bool new_input_level = pulse.type == Storage::Tape::Pulse::Low;
|
||||||
|
if(_input_level != new_input_level)
|
||||||
|
{
|
||||||
|
_input_level = new_input_level;
|
||||||
|
if(_delegate) _delegate->tape_did_change_input(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -49,24 +49,6 @@ enum Key: uint16_t {
|
|||||||
TerminateSequence = 0, NotMapped = 0xffff
|
TerminateSequence = 0, NotMapped = 0xffff
|
||||||
};
|
};
|
||||||
|
|
||||||
class Tape {
|
|
||||||
public:
|
|
||||||
void set_motor_control(bool enabled);
|
|
||||||
void set_tape_output(bool set);
|
|
||||||
bool get_tape_input();
|
|
||||||
bool has_tape();
|
|
||||||
|
|
||||||
void set_tape(std::shared_ptr<Storage::Tape> tape);
|
|
||||||
void run_for_cycles(int number_of_cycles);
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct {
|
|
||||||
Storage::Tape::Pulse current_pulse;
|
|
||||||
std::unique_ptr<SignalProcessing::Stepper> pulse_stepper;
|
|
||||||
uint32_t time_into_pulse;
|
|
||||||
} _input;
|
|
||||||
};
|
|
||||||
|
|
||||||
class UserPortVIA: public MOS::MOS6522<UserPortVIA>, public MOS::MOS6522IRQDelegate {
|
class UserPortVIA: public MOS::MOS6522<UserPortVIA>, public MOS::MOS6522IRQDelegate {
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -112,11 +94,36 @@ class KeyboardVIA: public MOS::MOS6522<KeyboardVIA>, public MOS::MOS6522IRQDeleg
|
|||||||
uint8_t _activation_mask;
|
uint8_t _activation_mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Tape: public Storage::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::Pulse pulse);
|
||||||
|
bool _input_level;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class Machine:
|
class Machine:
|
||||||
public CPU6502::Processor<Machine>,
|
public CPU6502::Processor<Machine>,
|
||||||
public CRTMachine::Machine,
|
public CRTMachine::Machine,
|
||||||
public MOS::MOS6522IRQDelegate::Delegate,
|
public MOS::MOS6522IRQDelegate::Delegate,
|
||||||
public Utility::TypeRecipient {
|
public Utility::TypeRecipient,
|
||||||
|
public Tape::Delegate {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Machine();
|
Machine();
|
||||||
@ -150,6 +157,9 @@ class Machine:
|
|||||||
virtual int get_typer_frequency();
|
virtual int get_typer_frequency();
|
||||||
virtual bool typer_set_next_character(Utility::Typer *typer, char character, int phase);
|
virtual bool typer_set_next_character(Utility::Typer *typer, char character, int phase);
|
||||||
|
|
||||||
|
// for Tape::Delegate
|
||||||
|
virtual void tape_did_change_input(Tape *tape);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t _characterROM[0x1000];
|
uint8_t _characterROM[0x1000];
|
||||||
uint8_t _basicROM[0x2000];
|
uint8_t _basicROM[0x2000];
|
||||||
@ -182,6 +192,7 @@ class Machine:
|
|||||||
std::unique_ptr<MOS::MOS6560> _mos6560;
|
std::unique_ptr<MOS::MOS6560> _mos6560;
|
||||||
UserPortVIA _userPortVIA;
|
UserPortVIA _userPortVIA;
|
||||||
KeyboardVIA _keyboardVIA;
|
KeyboardVIA _keyboardVIA;
|
||||||
|
Tape _tape;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,14 +50,17 @@ void TapePlayer::get_next_pulse()
|
|||||||
void TapePlayer::run_for_cycles(unsigned int number_of_cycles)
|
void TapePlayer::run_for_cycles(unsigned int number_of_cycles)
|
||||||
{
|
{
|
||||||
if(has_tape())
|
if(has_tape())
|
||||||
|
{
|
||||||
|
while(number_of_cycles--)
|
||||||
{
|
{
|
||||||
_input.time_into_pulse += (unsigned int)_input.pulse_stepper->step();
|
_input.time_into_pulse += (unsigned int)_input.pulse_stepper->step();
|
||||||
if(_input.time_into_pulse == _input.current_pulse.length.length)
|
while(_input.time_into_pulse >= _input.current_pulse.length.length)
|
||||||
{
|
{
|
||||||
run_for_input_pulse();
|
run_for_input_pulse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TapePlayer::run_for_input_pulse()
|
void TapePlayer::run_for_input_pulse()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user