mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-01-10 10:29:43 +00:00
Add more flexible configuration class for 6502
Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
parent
71d213faec
commit
867b0d5260
@ -21,9 +21,19 @@ Board::Board(const Configuration& configuration)
|
||||
void Board::initialise() {
|
||||
|
||||
m_memory.clear();
|
||||
auto romDirectory = m_configuration.getRomDirectory();
|
||||
|
||||
m_memory.loadRam(romDirectory + "/6502_functional_test.bin", 0x400); // Klaus Dormann functional tests
|
||||
auto programFilename = m_configuration.getProgram();
|
||||
auto programPath = m_configuration.getRomDirectory() + "\\" + m_configuration.getProgram();
|
||||
auto loadAddress = m_configuration.getLoadAddress();
|
||||
|
||||
switch (m_configuration.getLoadMethod()) {
|
||||
case Configuration::LoadMethod::Ram:
|
||||
m_memory.loadRam(programPath, loadAddress);
|
||||
break;
|
||||
case Configuration::LoadMethod::Rom:
|
||||
m_memory.loadRom(programPath, loadAddress);
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_configuration.isProfileMode()) {
|
||||
m_cpu.ExecutingInstruction.connect(std::bind(&Board::Cpu_ExecutingInstruction_Profile, this, std::placeholders::_1));
|
||||
@ -33,7 +43,16 @@ void Board::initialise() {
|
||||
m_cpu.ExecutingInstruction.connect(std::bind(&Board::Cpu_ExecutingInstruction_Debug, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
m_cpu.ExecutedInstruction.connect(std::bind(&Board::Cpu_ExecutedInstruction_StopLoop, this, std::placeholders::_1));
|
||||
switch (m_configuration.getStopCondition()) {
|
||||
case Configuration::StopCondition::Loop:
|
||||
m_cpu.ExecutedInstruction.connect(std::bind(&Board::Cpu_ExecutedInstruction_StopLoop, this, std::placeholders::_1));
|
||||
break;
|
||||
case Configuration::StopCondition::Halt:
|
||||
|
||||
break;
|
||||
default:
|
||||
throw std::domain_error("Unknown stop condition");
|
||||
}
|
||||
|
||||
if (m_configuration.allowInput()) {
|
||||
m_memory.ReadByte.connect(std::bind(&Board::Memory_ReadByte_Input, this, std::placeholders::_1));
|
||||
@ -47,7 +66,7 @@ void Board::initialise() {
|
||||
m_pollInterval = m_configuration.getPollInterval();
|
||||
|
||||
m_cpu.initialise();
|
||||
m_cpu.PC() = m_configuration.getStartAddress();
|
||||
m_cpu.PC().word = m_configuration.getStartAddress();
|
||||
}
|
||||
|
||||
void Board::Cpu_ExecutingInstruction_Profile(const EightBit::MOS6502& cpu) {
|
||||
|
@ -2,7 +2,17 @@
|
||||
#include "Configuration.h"
|
||||
|
||||
Configuration::Configuration()
|
||||
: m_debugMode(false),
|
||||
m_profileMode(false),
|
||||
m_romDirectory("roms") {
|
||||
: m_debugMode(false),
|
||||
m_profileMode(false),
|
||||
m_loadAddress(0x400),
|
||||
m_startAddress(0x400),
|
||||
m_allowInput(false),
|
||||
m_inputAddress(0xbff0),
|
||||
m_allowOutput(false),
|
||||
m_outputAddress(0xbff0),
|
||||
m_pollInterval(2000000 / 50), // 2Mhz, 50 times a second;
|
||||
m_stopCondition(StopCondition::Loop),
|
||||
m_romDirectory("roms"),
|
||||
m_program("6502_functional_test.bin"),
|
||||
m_loadMethod(LoadMethod::Ram) {
|
||||
}
|
||||
|
@ -1,52 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "Memory.h"
|
||||
|
||||
class Configuration {
|
||||
public:
|
||||
enum StopCondition {
|
||||
Halt,
|
||||
Loop
|
||||
};
|
||||
|
||||
enum LoadMethod {
|
||||
Ram,
|
||||
Rom
|
||||
};
|
||||
|
||||
Configuration();
|
||||
|
||||
bool isDebugMode() const {
|
||||
return m_debugMode;
|
||||
}
|
||||
bool isDebugMode() const { return m_debugMode; }
|
||||
void setDebugMode(bool value) { m_debugMode = value; }
|
||||
|
||||
void setDebugMode(bool value) {
|
||||
m_debugMode = value;
|
||||
}
|
||||
bool isProfileMode() const { return m_profileMode; }
|
||||
void setProfileMode(bool value) { m_profileMode = value; }
|
||||
|
||||
bool isProfileMode() const {
|
||||
return m_profileMode;
|
||||
}
|
||||
uint16_t getLoadAddress() const { return m_loadAddress; }
|
||||
uint16_t getStartAddress() const { return m_startAddress; }
|
||||
|
||||
void setProfileMode(bool value) {
|
||||
m_profileMode = value;
|
||||
}
|
||||
bool allowInput() const { return m_allowInput; }
|
||||
uint16_t getInputAddress() const { return m_inputAddress; }
|
||||
|
||||
std::string getRomDirectory() const {
|
||||
return m_romDirectory;
|
||||
}
|
||||
bool allowOutput() const { return m_allowOutput; }
|
||||
uint16_t getOutputAddress() const { return m_outputAddress; }
|
||||
|
||||
EightBit::register16_t getStartAddress() const {
|
||||
EightBit::register16_t returned;
|
||||
returned.word = 0x400;
|
||||
return returned;
|
||||
}
|
||||
uint64_t getPollInterval() const { return m_pollInterval; }
|
||||
|
||||
bool allowInput() const { return false; }
|
||||
uint16_t getInputAddress() const { return 0xbff0; }
|
||||
StopCondition getStopCondition() const { return m_stopCondition; }
|
||||
|
||||
bool allowOutput() const { return false; }
|
||||
uint16_t getOutputAddress() const { return 0xbff0; }
|
||||
std::string getRomDirectory() const { return m_romDirectory; }
|
||||
std::string getProgram() const { return m_program; }
|
||||
|
||||
uint64_t getPollInterval() const {
|
||||
return 2000000 / 50; // 2Mhz, 50 times a second;
|
||||
}
|
||||
LoadMethod getLoadMethod() const { return m_loadMethod; }
|
||||
|
||||
private:
|
||||
bool m_debugMode;
|
||||
bool m_profileMode;
|
||||
|
||||
uint16_t m_loadAddress;
|
||||
uint16_t m_startAddress;
|
||||
bool m_allowInput;
|
||||
uint16_t m_inputAddress;
|
||||
bool m_allowOutput;
|
||||
uint16_t m_outputAddress;
|
||||
uint64_t m_pollInterval;
|
||||
StopCondition m_stopCondition;
|
||||
std::string m_romDirectory;
|
||||
std::string m_program;
|
||||
LoadMethod m_loadMethod;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user