1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

Added a 'power on' flag that is set automatically at construction but can be declined. Saves all that stuff of every machine having to set and then unset the RST line, and fixes an Electron bug related to that.

This commit is contained in:
Thomas Harte 2016-06-29 19:13:24 -04:00
parent 6419d9c485
commit 0182b0483a
6 changed files with 16 additions and 11 deletions

View File

@ -69,7 +69,7 @@ void MOS6560::set_output_mode(OutputMode output_mode)
chrominances = ntsc_chrominances;
display_type = Outputs::CRT::NTSC60;
_timing.cycles_per_line = 65;
_timing.line_counter_increment_offset = 65 - 36; // TODO: 36 is from memory; need to look up.
_timing.line_counter_increment_offset = 65 - 33; // TODO: this is a bit of a hack; separate vertical and horizontal counting
_timing.lines_per_progressive_field = 261;
_timing.supports_interlacing = true;
break;

View File

@ -28,7 +28,6 @@ Machine::Machine() :
_is_pal_region(false)
{
memset(_collisions, 0xff, sizeof(_collisions));
set_reset_line(true);
setup_reported_collisions();
for(int vbextend = 0; vbextend < 2; vbextend++)
@ -414,8 +413,6 @@ void Machine::output_pixels(unsigned int count)
unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value)
{
set_reset_line(false);
uint8_t returnValue = 0xff;
unsigned int cycles_run_for = 3;

View File

@ -55,7 +55,6 @@ Machine::Machine() :
memset(_roms[c], 0xff, 16384);
_tape.set_delegate(this);
set_reset_line(true);
}
void Machine::setup_output(float aspect_ratio)
@ -86,7 +85,6 @@ void Machine::close_output()
unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value)
{
unsigned int cycles = 1;
set_reset_line(false);
if(address < 0x8000)
{

View File

@ -18,7 +18,6 @@ Machine::Machine() :
_userPortVIA.set_delegate(this);
_keyboardVIA.set_delegate(this);
_tape.set_delegate(this);
set_reset_line(true);
}
Machine::~Machine()
@ -28,8 +27,6 @@ Machine::~Machine()
unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value)
{
set_reset_line(false);
// test for PC at F92F
if(_use_fast_tape_hack && address == 0xf92f && operation == CPU6502::BusOperation::ReadOpcode)
{

View File

@ -459,6 +459,8 @@ template <class T> class Processor {
Reset = 0x80,
IRQ = 0x40,
NMI = 0x20,
PowerOn = 0x10,
};
uint8_t _interrupt_requests;
@ -539,7 +541,7 @@ template <class T> class Processor {
_interruptFlag(Flag::Interrupt),
_s(0),
_nextBusOperation(BusOperation::None),
_interrupt_requests(0)
_interrupt_requests(InterruptRequestFlags::PowerOn)
{
// only the interrupt flag is defined upon reset but get_flags isn't going to
// mask the other flags so we need to do that, at least
@ -587,7 +589,8 @@ template <class T> class Processor {
if(!_scheduledPrograms[scheduleProgramsReadPointer]) {\
scheduleProgramsReadPointer = _scheduleProgramsWritePointer = scheduleProgramProgramCounter = 0;\
if(_interrupt_requests) {\
if(_interrupt_requests & InterruptRequestFlags::Reset) {\
if(_interrupt_requests & (InterruptRequestFlags::Reset | InterruptRequestFlags::PowerOn)) {\
_interrupt_requests &= ~InterruptRequestFlags::PowerOn;\
schedule_program(get_reset_program());\
} else if(_interrupt_requests & InterruptRequestFlags::NMI) {\
_interrupt_requests &= ~InterruptRequestFlags::NMI;\
@ -1196,6 +1199,15 @@ template <class T> class Processor {
return !!(_interrupt_requests & InterruptRequestFlags::Reset);
}
/*!
This emulation automatically sets itself up in power-on state at creation, which has the effect of triggering a
reset at the first opportunity. Use @c set_power_on to disable that behaviour.
*/
inline void set_power_on(bool active)
{
_interrupt_requests = (_interrupt_requests & ~InterruptRequestFlags::PowerOn) | (active ? InterruptRequestFlags::PowerOn : 0);
}
/*!
Sets the current level of the IRQ line.

View File

@ -16,6 +16,7 @@ AllRAMProcessor::AllRAMProcessor() : _timestamp(0) {}
int AllRAMProcessor::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value)
{
set_power_on(false);
_timestamp++;
if(isReadOperation(operation)) {