mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-16 05:27:43 +00:00
Removes boilerplate from header.
This commit is contained in:
@@ -81,3 +81,45 @@ void State::apply(ProcessorBase &target) {
|
|||||||
target.next_address_.full = execution_state.next_address;
|
target.next_address_.full = execution_state.next_address;
|
||||||
target.scheduled_program_counter_ = &target.operations_[execution_state.micro_program][execution_state.micro_program_offset];
|
target.scheduled_program_counter_ = &target.operations_[execution_state.micro_program][execution_state.micro_program_offset];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Boilerplate follows here, to establish 'reflection'.
|
||||||
|
State::State() {
|
||||||
|
if(needs_declare()) {
|
||||||
|
DeclareField(registers);
|
||||||
|
DeclareField(execution_state);
|
||||||
|
DeclareField(inputs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
State::Registers::Registers() {
|
||||||
|
if(needs_declare()) {
|
||||||
|
DeclareField(program_counter);
|
||||||
|
DeclareField(stack_pointer);
|
||||||
|
DeclareField(flags);
|
||||||
|
DeclareField(a);
|
||||||
|
DeclareField(x);
|
||||||
|
DeclareField(y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
State::ExecutionState::ExecutionState() {
|
||||||
|
if(needs_declare()) {
|
||||||
|
AnnounceEnum(Phase);
|
||||||
|
DeclareField(phase);
|
||||||
|
DeclareField(micro_program);
|
||||||
|
DeclareField(micro_program_offset);
|
||||||
|
DeclareField(operation);
|
||||||
|
DeclareField(operand);
|
||||||
|
DeclareField(address);
|
||||||
|
DeclareField(next_address);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
State::Inputs::Inputs() {
|
||||||
|
if(needs_declare()) {
|
||||||
|
DeclareField(ready);
|
||||||
|
DeclareField(irq);
|
||||||
|
DeclareField(nmi);
|
||||||
|
DeclareField(reset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -24,12 +24,6 @@ namespace MOS6502 {
|
|||||||
encapsulated in Reflection/[Enum/Struct].hpp just don't use this class.
|
encapsulated in Reflection/[Enum/Struct].hpp just don't use this class.
|
||||||
*/
|
*/
|
||||||
struct State: public Reflection::StructImpl<State> {
|
struct State: public Reflection::StructImpl<State> {
|
||||||
/// Instantiates a new State based on the processor @c src.
|
|
||||||
State(const ProcessorBase &src);
|
|
||||||
|
|
||||||
/// Applies this state to @c target.
|
|
||||||
void apply(ProcessorBase &target);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Provides the current state of the well-known, published internal registers.
|
Provides the current state of the well-known, published internal registers.
|
||||||
*/
|
*/
|
||||||
@@ -85,48 +79,16 @@ struct State: public Reflection::StructImpl<State> {
|
|||||||
ExecutionState();
|
ExecutionState();
|
||||||
} execution_state;
|
} execution_state;
|
||||||
|
|
||||||
State() {
|
/// Default constructor; makes no guarantees as to field values beyond those given above.
|
||||||
if(needs_declare()) {
|
State();
|
||||||
DeclareField(registers);
|
|
||||||
DeclareField(execution_state);
|
/// Instantiates a new State based on the processor @c src.
|
||||||
DeclareField(inputs);
|
State(const ProcessorBase &src);
|
||||||
}
|
|
||||||
}
|
/// Applies this state to @c target.
|
||||||
|
void apply(ProcessorBase &target);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Boilerplate follows here, to establish 'reflection' for the state struct defined above.
|
|
||||||
inline State::Registers::Registers() {
|
|
||||||
if(needs_declare()) {
|
|
||||||
DeclareField(program_counter);
|
|
||||||
DeclareField(stack_pointer);
|
|
||||||
DeclareField(flags);
|
|
||||||
DeclareField(a);
|
|
||||||
DeclareField(x);
|
|
||||||
DeclareField(y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline State::ExecutionState::ExecutionState() {
|
|
||||||
if(needs_declare()) {
|
|
||||||
AnnounceEnum(Phase);
|
|
||||||
DeclareField(phase);
|
|
||||||
DeclareField(micro_program);
|
|
||||||
DeclareField(micro_program_offset);
|
|
||||||
DeclareField(operation);
|
|
||||||
DeclareField(operand);
|
|
||||||
DeclareField(address);
|
|
||||||
DeclareField(next_address);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline State::Inputs::Inputs() {
|
|
||||||
if(needs_declare()) {
|
|
||||||
DeclareField(ready);
|
|
||||||
DeclareField(irq);
|
|
||||||
DeclareField(nmi);
|
|
||||||
DeclareField(reset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user