mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-15 14:27:29 +00:00
With a very basic stab at something a bit like the memory map (sans paging), execution begins.
This commit is contained in:
@@ -20,6 +20,40 @@ HalfCycles Machine::perform_machine_cycle(const CPU::Z80::PartialMachineCycle &c
|
|||||||
clock_offset_ = (clock_offset_ + cycle.length) & HalfCycles(7);
|
clock_offset_ = (clock_offset_ + cycle.length) & HalfCycles(7);
|
||||||
set_wait_line(clock_offset_ >= HalfCycles(2));
|
set_wait_line(clock_offset_ >= HalfCycles(2));
|
||||||
|
|
||||||
|
// Stop now if no action is strictly required.
|
||||||
|
if(!cycle.is_terminal()) return HalfCycles(0);
|
||||||
|
|
||||||
|
uint16_t address = cycle.address ? *cycle.address : 0x0000;
|
||||||
|
switch(cycle.operation) {
|
||||||
|
case CPU::Z80::PartialMachineCycle::ReadOpcode:
|
||||||
|
case CPU::Z80::PartialMachineCycle::Read:
|
||||||
|
switch(address >> 14) {
|
||||||
|
case 0: *cycle.value = os_[address & 16383]; break;
|
||||||
|
case 1: case 2:
|
||||||
|
*cycle.value = ram_[address];
|
||||||
|
break;
|
||||||
|
case 3: *cycle.value = basic_[address & 16383]; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CPU::Z80::PartialMachineCycle::Write:
|
||||||
|
ram_[address] = *cycle.value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CPU::Z80::PartialMachineCycle::Output:
|
||||||
|
printf("Output %02x -> %04x?\n", *cycle.value, address);
|
||||||
|
break;
|
||||||
|
case CPU::Z80::PartialMachineCycle::Input:
|
||||||
|
printf("Input %04x?\n", address);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CPU::Z80::PartialMachineCycle::Interrupt:
|
||||||
|
*cycle.value = 0xff;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
return HalfCycles(0);
|
return HalfCycles(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,6 +61,12 @@ void Machine::flush() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Machine::set_rom(ROMType type, std::vector<uint8_t> data) {
|
void Machine::set_rom(ROMType type, std::vector<uint8_t> data) {
|
||||||
|
// Keep only the two ROMs that are currently of interest.
|
||||||
|
switch(type) {
|
||||||
|
case ROMType::OS464: os_ = data; break;
|
||||||
|
case ROMType::BASIC464: basic_ = data; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Machine::setup_output(float aspect_ratio) {
|
void Machine::setup_output(float aspect_ratio) {
|
||||||
|
@@ -48,6 +48,9 @@ class Machine:
|
|||||||
private:
|
private:
|
||||||
std::shared_ptr<Outputs::CRT::CRT> crt_;
|
std::shared_ptr<Outputs::CRT::CRT> crt_;
|
||||||
HalfCycles clock_offset_;
|
HalfCycles clock_offset_;
|
||||||
|
|
||||||
|
uint8_t ram_[65536];
|
||||||
|
std::vector<uint8_t> os_, basic_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user