mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-25 09:30:14 +00:00
Begin usage of RDY.
This commit is contained in:
parent
3d7e016b42
commit
709f350d60
@ -154,6 +154,10 @@ public:
|
|||||||
|
|
||||||
video_.run_for(length);
|
video_.run_for(length);
|
||||||
|
|
||||||
|
if(operation == CPU::MOS6502::BusOperation::Ready) {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
// Perform actual access.
|
// Perform actual access.
|
||||||
if(address < 0x0002) {
|
if(address < 0x0002) {
|
||||||
// TODO: 0x0000: data directions for parallel IO; 1 = output.
|
// TODO: 0x0000: data directions for parallel IO; 1 = output.
|
||||||
|
@ -116,9 +116,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Cycles cycle_length([[maybe_unused]] bool is_ready) const {
|
Cycles cycle_length([[maybe_unused]] bool is_ready) const {
|
||||||
// TODO: the complete test is more than this.
|
if(is_ready) {
|
||||||
// TODO: if this is a RDY cycle, can reply with time until end-of-RDY.
|
// return
|
||||||
const bool is_long_cycle = single_clock_ || refresh_;
|
// Cycles(EndCharacterFetchWindow - horizontal_counter_ + EndOfLine) * is_ntsc_ ? Cycles(4) : Cycles(5) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool is_long_cycle = single_clock_ || refresh_ || external_fetch_;
|
||||||
|
|
||||||
if(is_ntsc_) {
|
if(is_ntsc_) {
|
||||||
return is_long_cycle ? Cycles(16) : Cycles(8);
|
return is_long_cycle ? Cycles(16) : Cycles(8);
|
||||||
@ -202,33 +205,6 @@ public:
|
|||||||
interrupts_.apply(Interrupts::Flag::Raster);
|
interrupts_.apply(Interrupts::Flag::Raster);
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of events.
|
|
||||||
enum HorizontalEvent {
|
|
||||||
Begin38Columns = 3,
|
|
||||||
EndExternalFetchWindow = 288,
|
|
||||||
LatchCharacterPosition = 290,
|
|
||||||
EndCharacterFetchWindow = 296,
|
|
||||||
EndVideoShiftRegister = 304,
|
|
||||||
End38Columns = 307,
|
|
||||||
End40Columns = 315,
|
|
||||||
EndRefresh = 328,
|
|
||||||
IncrementBlink = 336,
|
|
||||||
BeginBlank = 344,
|
|
||||||
BeginSync = 358,
|
|
||||||
TestRasterInterrupt = 368,
|
|
||||||
IncrementVerticalLine = 376,
|
|
||||||
BeginBurst = 384,
|
|
||||||
EndSync = 390,
|
|
||||||
BeginExternalFetchWindow = 400,
|
|
||||||
EndBurst = 408,
|
|
||||||
EndBlank = 416,
|
|
||||||
IncrementCharacterPositionReload = 424,
|
|
||||||
BeginCharacterFetchWindow = 432,
|
|
||||||
BeginVideoShiftRegister = 440,
|
|
||||||
Begin40Columns = 451,
|
|
||||||
EndOfLine = 456,
|
|
||||||
};
|
|
||||||
|
|
||||||
const auto next = Numeric::upper_bound<
|
const auto next = Numeric::upper_bound<
|
||||||
0, Begin38Columns,
|
0, Begin38Columns,
|
||||||
EndExternalFetchWindow, LatchCharacterPosition,
|
EndExternalFetchWindow, LatchCharacterPosition,
|
||||||
@ -238,7 +214,7 @@ public:
|
|||||||
BeginBlank, BeginSync,
|
BeginBlank, BeginSync,
|
||||||
TestRasterInterrupt, IncrementVerticalLine,
|
TestRasterInterrupt, IncrementVerticalLine,
|
||||||
BeginBurst, EndSync,
|
BeginBurst, EndSync,
|
||||||
BeginExternalFetchWindow, EndBurst,
|
BeginExternalFetchWindow, //EndBurst,
|
||||||
EndBlank, IncrementCharacterPositionReload,
|
EndBlank, IncrementCharacterPositionReload,
|
||||||
BeginCharacterFetchWindow, BeginVideoShiftRegister,
|
BeginCharacterFetchWindow, BeginVideoShiftRegister,
|
||||||
Begin40Columns, EndOfLine
|
Begin40Columns, EndOfLine
|
||||||
@ -255,6 +231,10 @@ public:
|
|||||||
state = horizontal_burst_ ? OutputState::Burst : OutputState::Blank;
|
state = horizontal_burst_ ? OutputState::Burst : OutputState::Blank;
|
||||||
} else {
|
} else {
|
||||||
state = vertical_window_ && output_pixels_ ? OutputState::Pixels : OutputState::Border;
|
state = vertical_window_ && output_pixels_ ? OutputState::Pixels : OutputState::Border;
|
||||||
|
|
||||||
|
// if(output_pixels_) {
|
||||||
|
// printf("%d -> %d\n", horizontal_counter_, horizontal_counter_ + period);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state != output_state_) {
|
if(state != output_state_) {
|
||||||
@ -303,13 +283,34 @@ public:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BeginExternalFetchWindow:
|
case BeginExternalFetchWindow:
|
||||||
// TODO: set RDY line if this is an appropriate row.
|
external_fetch_ = true;
|
||||||
|
switch(fetch_phase_) {
|
||||||
|
case FetchPhase::Waiting:
|
||||||
|
// TODO: the < 200 is obviously phoney baloney. Figure out what the actual condition is here.
|
||||||
|
if(vertical_counter_ < 200 && (vertical_counter_&7) == y_scroll_ && vertical_window_) {
|
||||||
|
fetch_phase_ = FetchPhase::FetchingCharacters;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FetchPhase::FetchingCharacters:
|
||||||
|
fetch_phase_ = FetchPhase::FetchingAttributes;
|
||||||
|
break;
|
||||||
|
case FetchPhase::FetchingAttributes:
|
||||||
|
fetch_phase_ = FetchPhase::Waiting;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
interrupts_.bus().set_ready_line(fetch_phase_ != FetchPhase::Waiting);
|
||||||
|
|
||||||
|
horizontal_burst_ = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LatchCharacterPosition: line_character_address_ = character_address_; break;
|
case LatchCharacterPosition:
|
||||||
|
line_character_address_ = character_address_;
|
||||||
|
break;
|
||||||
|
|
||||||
case EndCharacterFetchWindow:
|
case EndCharacterFetchWindow:
|
||||||
fetch_characters_ = false;
|
fetch_characters_ = false;
|
||||||
|
external_fetch_ = false;
|
||||||
|
interrupts_.bus().set_ready_line(false);
|
||||||
break;
|
break;
|
||||||
case BeginCharacterFetchWindow:
|
case BeginCharacterFetchWindow:
|
||||||
fetch_characters_ = true;
|
fetch_characters_ = true;
|
||||||
@ -339,7 +340,7 @@ public:
|
|||||||
case BeginBlank: horizontal_blank_ = true; break;
|
case BeginBlank: horizontal_blank_ = true; break;
|
||||||
case BeginSync: horizontal_sync_ = true; break;
|
case BeginSync: horizontal_sync_ = true; break;
|
||||||
case EndSync: horizontal_sync_ = false; break;
|
case EndSync: horizontal_sync_ = false; break;
|
||||||
case EndBurst: horizontal_burst_ = false; break;
|
// case EndBurst: horizontal_burst_ = false; break;
|
||||||
case EndBlank: horizontal_blank_ = false; break;
|
case EndBlank: horizontal_blank_ = false; break;
|
||||||
|
|
||||||
case TestRasterInterrupt:
|
case TestRasterInterrupt:
|
||||||
@ -409,8 +410,9 @@ private:
|
|||||||
|
|
||||||
uint16_t character_address_ = 0;
|
uint16_t character_address_ = 0;
|
||||||
uint16_t line_character_address_ = 0;
|
uint16_t line_character_address_ = 0;
|
||||||
bool fetch_characters_;
|
bool fetch_characters_ = false;
|
||||||
bool output_pixels_;
|
bool external_fetch_ = false;
|
||||||
|
bool output_pixels_ = false;
|
||||||
bool refresh_ = false;
|
bool refresh_ = false;
|
||||||
bool single_clock_ = false;
|
bool single_clock_ = false;
|
||||||
uint8_t ff07_;
|
uint8_t ff07_;
|
||||||
@ -443,8 +445,35 @@ private:
|
|||||||
enum class FetchPhase {
|
enum class FetchPhase {
|
||||||
Waiting,
|
Waiting,
|
||||||
FetchingCharacters,
|
FetchingCharacters,
|
||||||
FetchingAttributs,
|
FetchingAttributes,
|
||||||
} fetch_phase_ = FetchPhase::Waiting;
|
} fetch_phase_ = FetchPhase::Waiting;
|
||||||
|
|
||||||
|
// List of events.
|
||||||
|
enum HorizontalEvent {
|
||||||
|
Begin38Columns = 3,
|
||||||
|
EndExternalFetchWindow = 288,
|
||||||
|
LatchCharacterPosition = 290,
|
||||||
|
EndCharacterFetchWindow = 300, // 296
|
||||||
|
EndVideoShiftRegister = 304,
|
||||||
|
End38Columns = 307,
|
||||||
|
End40Columns = 315,
|
||||||
|
EndRefresh = 328,
|
||||||
|
IncrementBlink = 336,
|
||||||
|
BeginBlank = 344,
|
||||||
|
BeginSync = 358,
|
||||||
|
TestRasterInterrupt = 368,
|
||||||
|
IncrementVerticalLine = 376,
|
||||||
|
BeginBurst = 384,
|
||||||
|
EndSync = 390,
|
||||||
|
BeginExternalFetchWindow = 408, // 400,
|
||||||
|
// EndBurst = 408,
|
||||||
|
EndBlank = 416,
|
||||||
|
IncrementCharacterPositionReload = 424,
|
||||||
|
BeginCharacterFetchWindow = 436, // 432,
|
||||||
|
BeginVideoShiftRegister = 440,
|
||||||
|
Begin40Columns = 451,
|
||||||
|
EndOfLine = 456,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user