mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-19 08:31:11 +00:00
Pulled the Z80 from the MicroOpScheduler inheritance tree as it barely uses the thing, and that allows me to make the MicroOp structure private.
This commit is contained in:
parent
0f438f524b
commit
3ceef2005b
@ -14,7 +14,6 @@
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
|
||||
#include "../MicroOpScheduler.hpp"
|
||||
#include "../RegisterSizes.hpp"
|
||||
|
||||
namespace CPU {
|
||||
@ -79,7 +78,49 @@ struct MachineCycle {
|
||||
uint8_t *value;
|
||||
};
|
||||
|
||||
struct MicroOp {
|
||||
/*!
|
||||
@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_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.
|
||||
*/
|
||||
template <class T> class Processor {
|
||||
private:
|
||||
uint8_t a_, i_, r_;
|
||||
RegisterPair bc_, de_, hl_;
|
||||
RegisterPair afDash_, bcDash_, deDash_, hlDash_;
|
||||
RegisterPair ix_, iy_, pc_, sp_;
|
||||
bool iff1_, iff2_;
|
||||
int interrupt_mode_;
|
||||
uint16_t pc_increment_;
|
||||
uint8_t sign_result_; // the sign flag is set if the value in sign_result_ is negative
|
||||
uint8_t zero_result_; // the zero flag is set if the value in zero_result_ is zero
|
||||
uint8_t half_carry_result_; // the half-carry flag is set if bit 4 of half_carry_result_ is set
|
||||
uint8_t bit53_result_; // the bit 3 and 5 flags are set if the corresponding bits of bit53_result_ are set
|
||||
uint8_t parity_overflow_result_; // the parity/overflow flag is set if the corresponding bit of parity_overflow_result_ is set
|
||||
uint8_t subtract_flag_; // contains a copy of the subtract flag in isolation
|
||||
uint8_t carry_result_; // the carry flag is set if bit 0 of carry_result_ is set
|
||||
uint8_t halt_mask_;
|
||||
|
||||
int number_of_cycles_;
|
||||
|
||||
enum Interrupt: uint8_t {
|
||||
IRQ = 0x01,
|
||||
NMI = 0x02,
|
||||
Reset = 0x04,
|
||||
PowerOn = 0x08
|
||||
};
|
||||
uint8_t request_status_;
|
||||
uint8_t last_request_status_;
|
||||
bool irq_line_;
|
||||
bool bus_request_line_;
|
||||
|
||||
uint8_t operation_;
|
||||
RegisterPair temp16_;
|
||||
uint8_t temp8_;
|
||||
|
||||
struct MicroOp {
|
||||
enum Type {
|
||||
BusOperation,
|
||||
DecodeOperation,
|
||||
@ -163,49 +204,9 @@ struct MicroOp {
|
||||
void *source;
|
||||
void *destination;
|
||||
MachineCycle machine_cycle;
|
||||
};
|
||||
|
||||
/*!
|
||||
@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_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.
|
||||
*/
|
||||
template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
||||
private:
|
||||
uint8_t a_, i_, r_;
|
||||
RegisterPair bc_, de_, hl_;
|
||||
RegisterPair afDash_, bcDash_, deDash_, hlDash_;
|
||||
RegisterPair ix_, iy_, pc_, sp_;
|
||||
bool iff1_, iff2_;
|
||||
int interrupt_mode_;
|
||||
uint16_t pc_increment_;
|
||||
uint8_t sign_result_; // the sign flag is set if the value in sign_result_ is negative
|
||||
uint8_t zero_result_; // the zero flag is set if the value in zero_result_ is zero
|
||||
uint8_t half_carry_result_; // the half-carry flag is set if bit 4 of half_carry_result_ is set
|
||||
uint8_t bit53_result_; // the bit 3 and 5 flags are set if the corresponding bits of bit53_result_ are set
|
||||
uint8_t parity_overflow_result_; // the parity/overflow flag is set if the corresponding bit of parity_overflow_result_ is set
|
||||
uint8_t subtract_flag_; // contains a copy of the subtract flag in isolation
|
||||
uint8_t carry_result_; // the carry flag is set if bit 0 of carry_result_ is set
|
||||
uint8_t halt_mask_;
|
||||
|
||||
int number_of_cycles_;
|
||||
|
||||
enum Interrupt: uint8_t {
|
||||
IRQ = 0x01,
|
||||
NMI = 0x02,
|
||||
Reset = 0x04,
|
||||
PowerOn = 0x08
|
||||
};
|
||||
uint8_t request_status_;
|
||||
uint8_t last_request_status_;
|
||||
bool irq_line_;
|
||||
bool bus_request_line_;
|
||||
const MicroOp *scheduled_program_counter_;
|
||||
|
||||
uint8_t operation_;
|
||||
RegisterPair temp16_;
|
||||
uint8_t temp8_;
|
||||
|
||||
struct InstructionPage {
|
||||
std::vector<MicroOp *> instructions;
|
||||
@ -665,14 +666,15 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
||||
}
|
||||
|
||||
public:
|
||||
Processor() : MicroOpScheduler(),
|
||||
Processor() :
|
||||
halt_mask_(0xff),
|
||||
number_of_cycles_(0),
|
||||
request_status_(Interrupt::PowerOn),
|
||||
last_request_status_(Interrupt::PowerOn),
|
||||
irq_line_(false),
|
||||
bus_request_line_(false),
|
||||
pc_increment_(1) {
|
||||
pc_increment_(1),
|
||||
scheduled_program_counter_(nullptr) {
|
||||
set_flags(0xff);
|
||||
|
||||
assemble_base_page(base_page_, hl_, false, cb_page_);
|
||||
|
Loading…
Reference in New Issue
Block a user