2017-05-16 21:19:17 -04:00
|
|
|
//
|
|
|
|
// Z80AllRAM.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 16/05/2017.
|
|
|
|
// Copyright © 2017 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "Z80AllRAM.hpp"
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
using namespace CPU::Z80;
|
|
|
|
|
2017-05-22 19:24:11 -04:00
|
|
|
AllRAMProcessor::AllRAMProcessor() : ::CPU::AllRAMProcessor(65536), delegate_(nullptr) {}
|
2017-05-16 21:19:17 -04:00
|
|
|
|
|
|
|
int AllRAMProcessor::perform_machine_cycle(const MachineCycle *cycle) {
|
2017-05-17 21:45:23 -04:00
|
|
|
switch(cycle->operation) {
|
|
|
|
case BusOperation::ReadOpcode:
|
2017-05-21 20:43:36 -04:00
|
|
|
// printf("! %02x\n", memory_[*cycle->address]);
|
2017-05-19 21:20:28 -04:00
|
|
|
check_address_for_trap(*cycle->address);
|
2017-05-17 21:45:23 -04:00
|
|
|
case BusOperation::Read:
|
2017-05-21 09:47:53 -04:00
|
|
|
// 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));
|
2017-05-17 21:45:23 -04:00
|
|
|
*cycle->value = memory_[*cycle->address];
|
|
|
|
break;
|
|
|
|
case BusOperation::Write:
|
2017-05-21 09:47:53 -04:00
|
|
|
// printf("w %04x\n", *cycle->address);
|
2017-05-17 21:45:23 -04:00
|
|
|
memory_[*cycle->address] = *cycle->value;
|
|
|
|
break;
|
|
|
|
|
2017-05-28 14:50:51 -04:00
|
|
|
case BusOperation::Output:
|
|
|
|
break;
|
|
|
|
case BusOperation::Input:
|
|
|
|
// This logic is selected specifically because it seems to match
|
|
|
|
// the FUSE unit tests. It might need factoring out.
|
|
|
|
*cycle->value = (*cycle->address) >> 8;
|
|
|
|
break;
|
|
|
|
|
2017-05-19 19:18:35 -04:00
|
|
|
case BusOperation::Internal:
|
|
|
|
break;
|
|
|
|
|
2017-05-17 21:45:23 -04:00
|
|
|
default:
|
|
|
|
printf("???\n");
|
|
|
|
break;
|
|
|
|
}
|
2017-05-22 19:24:11 -04:00
|
|
|
timestamp_ += cycle->length;
|
|
|
|
|
|
|
|
if(delegate_ != nullptr) {
|
2017-05-22 21:50:34 -04:00
|
|
|
delegate_->z80_all_ram_processor_did_perform_bus_operation(*this, cycle->operation, cycle->address ? *cycle->address : 0x0000, cycle->value ? *cycle->value : 0x00, timestamp_);
|
2017-05-22 19:24:11 -04:00
|
|
|
}
|
|
|
|
|
2017-05-16 21:19:17 -04:00
|
|
|
return 0;
|
|
|
|
}
|