mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-28 22:29:36 +00:00
Added a direct-to-two-cycles emulation path for 6522 owners.
This commit is contained in:
parent
2eda0b3c86
commit
4fab794747
@ -230,18 +230,6 @@ template <class T> class MOS6522 {
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Runs for a specified number of half cycles.
|
||||
|
||||
Although the original chip accepts only a phase-2 input, timer reloads are specified as occuring
|
||||
1.5 cycles after the timer hits zero. It is therefore necessary to emulate at half-cycle precision.
|
||||
|
||||
The first emulated half-cycle will be the period between the trailing edge of a phase-2 input and the
|
||||
next rising edge. So it should align with a full system's phase-1. The next emulated half-cycle will be
|
||||
that which occurs during phase-2.
|
||||
*/
|
||||
inline void run_for_half_cycles(unsigned int number_of_cycles)
|
||||
{
|
||||
#define phase2() \
|
||||
_registers.last_timer[0] = _registers.timer[0];\
|
||||
_registers.last_timer[1] = _registers.timer[1];\
|
||||
@ -276,6 +264,21 @@ template <class T> class MOS6522 {
|
||||
_timer_is_running[0] = false;\
|
||||
}
|
||||
|
||||
/*!
|
||||
Runs for a specified number of half cycles.
|
||||
|
||||
Although the original chip accepts only a phase-2 input, timer reloads are specified as occuring
|
||||
1.5 cycles after the timer hits zero. It therefore may be necessary to emulate at half-cycle precision.
|
||||
|
||||
The first emulated half-cycle will be the period between the trailing edge of a phase-2 input and the
|
||||
next rising edge. So it should align with a full system's phase-1. The next emulated half-cycle will be
|
||||
that which occurs during phase-2.
|
||||
|
||||
Callers should decide whether they are going to use @c run_for_half_cycles or @c run_for_cycles, and not
|
||||
intermingle usage.
|
||||
*/
|
||||
inline void run_for_half_cycles(unsigned int number_of_cycles)
|
||||
{
|
||||
if(_is_phase2)
|
||||
{
|
||||
phase2();
|
||||
@ -300,6 +303,24 @@ template <class T> class MOS6522 {
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Runs for a specified number of cycles.
|
||||
|
||||
Callers should decide whether they are going to use @c run_for_half_cycles or @c run_for_cycles, and not
|
||||
intermingle usage.
|
||||
*/
|
||||
inline void run_for_cycles(unsigned int number_of_cycles)
|
||||
{
|
||||
while(number_of_cycles--)
|
||||
{
|
||||
phase1();
|
||||
phase2();
|
||||
}
|
||||
}
|
||||
|
||||
#undef phase1
|
||||
#undef phase2
|
||||
|
||||
/*! @returns @c true if the IRQ line is currently active; @c false otherwise. */
|
||||
inline bool get_interrupt_line()
|
||||
{
|
||||
|
@ -91,8 +91,8 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
|
||||
_driveVIA.set_register(address, *value);
|
||||
}
|
||||
|
||||
_serialPortVIA->run_for_half_cycles(2);
|
||||
_driveVIA.run_for_half_cycles(2);
|
||||
_serialPortVIA->run_for_cycles(1);
|
||||
_driveVIA.run_for_cycles(1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -139,8 +139,8 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
|
||||
{
|
||||
while(!_userPortVIA->get_interrupt_line() && !_keyboardVIA->get_interrupt_line() && !_tape.get_tape()->is_at_end())
|
||||
{
|
||||
_userPortVIA->run_for_half_cycles(2);
|
||||
_keyboardVIA->run_for_half_cycles(2);
|
||||
_userPortVIA->run_for_cycles(1);
|
||||
_keyboardVIA->run_for_cycles(1);
|
||||
_tape.run_for_cycles(1);
|
||||
}
|
||||
}
|
||||
@ -157,8 +157,8 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
|
||||
}
|
||||
}
|
||||
|
||||
_userPortVIA->run_for_half_cycles(2);
|
||||
_keyboardVIA->run_for_half_cycles(2);
|
||||
_userPortVIA->run_for_cycles(1);
|
||||
_keyboardVIA->run_for_cycles(1);
|
||||
if(_typer && operation == CPU6502::BusOperation::ReadOpcode && address == 0xEB1E)
|
||||
{
|
||||
if(!_typer->type_next_character())
|
||||
|
@ -61,7 +61,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
|
||||
}
|
||||
}
|
||||
|
||||
_via.run_for_half_cycles(2);
|
||||
_via.run_for_cycles(1);
|
||||
_via.tape->run_for_cycles(1);
|
||||
_cycles_since_video_update++;
|
||||
return 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user