mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-13 22:32:03 +00:00
Switched to supplying the bus operation by reference, go guarantee that it isn't null.
This commit is contained in:
parent
244b5ba3c2
commit
da65bae86e
@ -157,15 +157,11 @@ struct MicroOp {
|
||||
};
|
||||
|
||||
/*!
|
||||
@abstact An abstract base class for emulation of a 6502 processor via the curiously recurring template pattern/f-bounded polymorphism.
|
||||
@abstact An abstract base class for emulation of a Z80 processor via the curiously recurring template pattern/f-bounded polymorphism.
|
||||
|
||||
@discussion Subclasses should implement @c perform_bus_operation(BusOperation operation, uint16_t address, uint8_t *value) in
|
||||
order to provide the bus on which the 6502 operates and @c flush(), which is called upon completion of a continuous run
|
||||
@discussion Subclasses should implement @c perform_machine_cycle in
|
||||
order to provide the bus on which the Z80 operates and @c flush(), which is called upon completion of a continuous run
|
||||
of cycles to allow a subclass to bring any on-demand activities up to date.
|
||||
|
||||
Additional functionality can be provided by the host machine by providing a jam handler and inserting jam opcodes where appropriate;
|
||||
that will cause call outs when the program counter reaches those addresses. @c return_from_subroutine can be used to exit from a
|
||||
jammed state.
|
||||
*/
|
||||
template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
||||
private:
|
||||
@ -668,7 +664,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
||||
/*!
|
||||
Runs the Z80 for a supplied number of cycles.
|
||||
|
||||
@discussion Subclasses must implement @c perform_machine_cycle(MachineCycle *cycle) .
|
||||
@discussion Subclasses must implement @c perform_machine_cycle(const MachineCycle &cycle) .
|
||||
|
||||
If it is a read operation then @c value will be seeded with the value 0xff.
|
||||
|
||||
@ -699,7 +695,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
||||
case MicroOp::BusOperation:
|
||||
if(number_of_cycles_ < operation->machine_cycle.length) { schedule_program_program_counter_--; return; }
|
||||
number_of_cycles_ -= operation->machine_cycle.length;
|
||||
number_of_cycles_ -= static_cast<T *>(this)->perform_machine_cycle(&operation->machine_cycle);
|
||||
number_of_cycles_ -= static_cast<T *>(this)->perform_machine_cycle(operation->machine_cycle);
|
||||
break;
|
||||
case MicroOp::MoveToNextProgram:
|
||||
move_to_next_program();
|
||||
@ -1407,7 +1403,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
||||
*/
|
||||
void flush() {}
|
||||
|
||||
int perform_machine_cycle(const MachineCycle *cycle) {
|
||||
int perform_machine_cycle(const MachineCycle &cycle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -13,19 +13,19 @@ using namespace CPU::Z80;
|
||||
|
||||
AllRAMProcessor::AllRAMProcessor() : ::CPU::AllRAMProcessor(65536), delegate_(nullptr) {}
|
||||
|
||||
int AllRAMProcessor::perform_machine_cycle(const MachineCycle *cycle) {
|
||||
uint16_t address = cycle->address ? *cycle->address : 0x0000;
|
||||
switch(cycle->operation) {
|
||||
int AllRAMProcessor::perform_machine_cycle(const MachineCycle &cycle) {
|
||||
uint16_t address = cycle.address ? *cycle.address : 0x0000;
|
||||
switch(cycle.operation) {
|
||||
case BusOperation::ReadOpcode:
|
||||
// printf("%04x %02x [BC=%02x]\n", *cycle->address, memory_[*cycle->address], get_value_of_register(CPU::Z80::Register::BC));
|
||||
check_address_for_trap(address);
|
||||
case BusOperation::Read:
|
||||
// printf("r %04x [%02x] AF:%04x BC:%04x DE:%04x HL:%04x SP:%04x\n", *cycle->address, memory_[*cycle->address], get_value_of_register(CPU::Z80::Register::AF), get_value_of_register(CPU::Z80::Register::BC), get_value_of_register(CPU::Z80::Register::DE), get_value_of_register(CPU::Z80::Register::HL), get_value_of_register(CPU::Z80::Register::StackPointer));
|
||||
*cycle->value = memory_[address];
|
||||
*cycle.value = memory_[address];
|
||||
break;
|
||||
case BusOperation::Write:
|
||||
// printf("w %04x\n", *cycle->address);
|
||||
memory_[address] = *cycle->value;
|
||||
memory_[address] = *cycle.value;
|
||||
break;
|
||||
|
||||
case BusOperation::Output:
|
||||
@ -33,7 +33,7 @@ int AllRAMProcessor::perform_machine_cycle(const MachineCycle *cycle) {
|
||||
case BusOperation::Input:
|
||||
// This logic is selected specifically because it seems to match
|
||||
// the FUSE unit tests. It might need factoring out.
|
||||
*cycle->value = address >> 8;
|
||||
*cycle.value = address >> 8;
|
||||
break;
|
||||
|
||||
case BusOperation::Internal:
|
||||
@ -43,10 +43,10 @@ int AllRAMProcessor::perform_machine_cycle(const MachineCycle *cycle) {
|
||||
printf("???\n");
|
||||
break;
|
||||
}
|
||||
timestamp_ += cycle->length;
|
||||
timestamp_ += cycle.length;
|
||||
|
||||
if(delegate_ != nullptr) {
|
||||
delegate_->z80_all_ram_processor_did_perform_bus_operation(*this, cycle->operation, address, cycle->value ? *cycle->value : 0x00, timestamp_);
|
||||
delegate_->z80_all_ram_processor_did_perform_bus_operation(*this, cycle.operation, address, cycle.value ? *cycle.value : 0x00, timestamp_);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -22,7 +22,7 @@ class AllRAMProcessor:
|
||||
public:
|
||||
AllRAMProcessor();
|
||||
|
||||
int perform_machine_cycle(const MachineCycle *cycle);
|
||||
int perform_machine_cycle(const MachineCycle &cycle);
|
||||
|
||||
struct MemoryAccessDelegate {
|
||||
virtual void z80_all_ram_processor_did_perform_bus_operation(AllRAMProcessor &processor, BusOperation operation, uint16_t address, uint8_t value, int time_stamp) = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user