mirror of
https://github.com/TomHarte/CLK.git
synced 2025-04-21 18:37:11 +00:00
Merge pull request #1494 from TomHarte/MoreAT
AT: adjust reported RAM refresh timing.
This commit is contained in:
commit
15da707324
@ -118,6 +118,7 @@ public:
|
||||
KeyboardController(PICs<model> &pics, Speaker &speaker) : pics_(pics), speaker_(speaker) {}
|
||||
|
||||
void run_for(const Cycles cycles) {
|
||||
instruction_count_ += cycles.as<int>();
|
||||
if(!write_delay_) return;
|
||||
write_delay_ -= cycles.as<int>();
|
||||
if(write_delay_ <= 0) {
|
||||
@ -181,15 +182,12 @@ public:
|
||||
return input_;
|
||||
|
||||
case 0x0061:
|
||||
// In a real machine bit 4 toggles as a function of memory refresh; it is often
|
||||
// used by BIOSes to check that refresh is happening, with no greater inspection
|
||||
// than that it is toggling. So toggle on read.
|
||||
//
|
||||
// TODO: is this really from the keyboard controller?
|
||||
refresh_toggle_ ^= 0x10;
|
||||
|
||||
// log_.info().append("AT keyboard: %02x from %04x", refresh_toggle_, port);
|
||||
return refresh_toggle_;
|
||||
// In a real machine bit 4 toggles as a function of memory refresh and some BIOSes
|
||||
// (including IBM's) do a polled loop to test its speed. So that effectively compares
|
||||
// PIT counts against CPU cycle counts. Since this emulator does nothing whatsoever
|
||||
// to attempt realistic CPU timing, the ratio here is just one I found that passed
|
||||
// BIOS inspection. I may have overfitted to IBM's. This counts as an ugliness.
|
||||
return ((instruction_count_ * 2) / 25) & 0x10;
|
||||
|
||||
case 0x0064: {
|
||||
// Status:
|
||||
@ -301,7 +299,7 @@ private:
|
||||
Speaker &speaker_;
|
||||
CPUControl<model> *cpu_control_ = nullptr;
|
||||
|
||||
uint8_t refresh_toggle_ = 0;
|
||||
int instruction_count_ = 0;
|
||||
|
||||
bool has_input_ = false;
|
||||
uint8_t input_;
|
||||
|
@ -619,13 +619,16 @@ public:
|
||||
throw ROMMachine::Error::MissingROMs;
|
||||
}
|
||||
|
||||
const auto install_bios = [&](const std::vector<uint8_t> &source) {
|
||||
context_.memory.install(0x10'0000 - source.size(), source.data(), source.size());
|
||||
};
|
||||
|
||||
switch(pc_model) {
|
||||
default: {
|
||||
const auto &bios_contents = roms.find(bios_XT)->second;
|
||||
context_.memory.install(0x10'0000 - bios_contents.size(), bios_contents.data(), bios_contents.size());
|
||||
install_bios(roms.find(bios_XT)->second);
|
||||
|
||||
// If found, install GlaTICK at 0xd'0000.
|
||||
auto tick_contents = roms.find(tick_XT);
|
||||
const auto tick_contents = roms.find(tick_XT);
|
||||
if(tick_contents != roms.end()) {
|
||||
context_.memory.install(0xd'0000, tick_contents->second.data(), tick_contents->second.size());
|
||||
}
|
||||
@ -642,22 +645,14 @@ public:
|
||||
bios[c] = (c & 1) ? bios_odd->second[c >> 1] : bios_even->second[c >> 1];
|
||||
}
|
||||
|
||||
context_.memory.install(
|
||||
0x10'0000 - bios.size(),
|
||||
bios.data(),
|
||||
bios.size()
|
||||
);
|
||||
install_bios(bios);
|
||||
return;
|
||||
}
|
||||
|
||||
for(const auto name: {bios_AT, bios_AT_Phoenix}) {
|
||||
const auto bios_contents = roms.find(name);
|
||||
if(bios_contents != roms.end()) {
|
||||
context_.memory.install(
|
||||
0x10'0000 - bios_contents->second.size(),
|
||||
bios_contents->second.data(),
|
||||
bios_contents->second.size()
|
||||
);
|
||||
install_bios(bios_contents->second);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user