1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-25 18:30:07 +00:00

Corrects video counter values.

The built-in speed test now passes.
This commit is contained in:
Thomas Harte 2020-12-01 18:35:55 -05:00
parent 3162873a9c
commit 24fcb0c24b
2 changed files with 7 additions and 6 deletions

View File

@ -742,9 +742,9 @@ class ConcreteMachine:
// printf("%06x %s %02x%s\n", address, isReadOperation(operation) ? "->" : "<-", *value,
// operation == CPU::WDC65816::BusOperation::ReadOpcode ? " [*]" : "");
// }
if(operation == CPU::WDC65816::BusOperation::ReadOpcode) {
log = (address >= 0xff6ac7) && (address < 0xff6b09);
}
// if(operation == CPU::WDC65816::BusOperation::ReadOpcode) {
// log = (address >= 0xff6ac7) && (address < 0xff6b09);
// }
// log &= !((operation == CPU::WDC65816::BusOperation::ReadOpcode) && ((address < 0xff6a2c) || (address >= 0xff6a9c)));
if(log) {
printf("%06x %s %02x [%s]", address, isReadOperation(operation) ? "->" : "<-", *value, (is_1Mhz || (speed_register_ & motor_flags_)) ? "1.0" : "2.8");

View File

@ -458,7 +458,7 @@ Video::Counters Video::get_counters(Cycles offset) {
// mode (vertical line count of 312). Vertical counter value $100 corresponds to scan line
// zero in NTSC mode."
// Work out the internal offset into frame.
// Work out the internal offset into frame; a modulo willoccur momentarily...
auto cycles_into_frame = cycles_into_frame_ + offset.as<int>();
// Nudge slightly so that the regular start of line matches mine.
@ -466,9 +466,10 @@ Video::Counters Video::get_counters(Cycles offset) {
cycles_into_frame = (cycles_into_frame + 25 - start_of_pixels)%(Lines * CyclesPerLine);
// Break it down.
const auto cycles_into_line = cycles_into_frame / (CyclesPerLine * CyclesPerTick);
const auto lines_into_frame = (cycles_into_frame % (CyclesPerLine * CyclesPerTick)) + 0x100;
const auto cycles_into_line = (cycles_into_frame % CyclesPerLine) / CyclesPerTick;
auto lines_into_frame = cycles_into_frame / CyclesPerLine;
lines_into_frame += 0x100;
return Counters(
lines_into_frame - ((lines_into_frame / 0x200) * 0x106), // TODO: this assumes NTSC.
cycles_into_line + bool(cycles_into_line) * 0x40);