Skip to content

Commit

Permalink
wip property rework
Browse files Browse the repository at this point in the history
  • Loading branch information
gulrak committed Oct 15, 2024
1 parent 183d853 commit b3a9fff
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 11 deletions.
72 changes: 72 additions & 0 deletions src/emulation/dream6800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,85 @@

namespace emu {

static const std::string PROP_CLASS = "DREAM6800";
static const std::string PROP_TRACE_LOG = "Trace Log";
static const std::string PROP_CPU = "CPU";
static const std::string PROP_CLOCK = "Clock Rate";
static const std::string PROP_RAM = "Memory";
static const std::string PROP_CLEAN_RAM = "Clean RAM";
static const std::string PROP_VIDEO = "Video";
static const std::string PROP_ROM_NAME = "ROM Name";

struct Dream6800Options
{
Properties asProperties() const
{
auto result = registeredPrototype();
result[PROP_TRACE_LOG].setBool(traceLog);
result[PROP_CPU].setString(cpuType);
result[PROP_CLOCK].setInt(clockFrequency);
result[PROP_RAM].setSelectedText(std::to_string(ramSize)); // !!!!
result[PROP_CLEAN_RAM].setBool(cleanRam);
result[PROP_VIDEO].setSelectedIndex(toType(videoType));
result[PROP_AUDIO].setSelectedIndex(toType(audioType));
result[PROP_KEYBOARD].setSelectedIndex(toType(keyboard));
result[PROP_ROM_NAME].setString(romName);
//result[PROP_INTERPRETER].setSelectedIndex(toType(interpreter));
result[PROP_START_ADDRESS].setInt(startAddress);
result.palette() = palette;
return result;
}
static Dream6800Options fromProperties(const Properties& props)
{
Dream6800Options opts{};
opts.traceLog = props[PROP_TRACE_LOG].getBool();
opts.cpuType = props[PROP_CPU].getString();
opts.clockFrequency = props[PROP_CLOCK].getInt();
opts.ramSize = std::stoul(props[PROP_RAM].getSelectedText()); // !!!!
opts.cleanRam = props[PROP_CLEAN_RAM].getBool();
opts.videoType = static_cast<ETIVideoType>(props[PROP_VIDEO].getSelectedIndex());
opts.audioType = static_cast<ETIAudioType>(props[PROP_AUDIO].getSelectedIndex());
opts.keyboard = static_cast<ETIKeyboard>(props[PROP_KEYBOARD].getSelectedIndex());
opts.romName = props[PROP_ROM_NAME].getString();
//opts.interpreter = static_cast<VIPChip8Interpreter>(props[PROP_INTERPRETER].getSelectedIndex());
opts.startAddress = props[PROP_START_ADDRESS].getInt();
opts.palette = props.palette();
return opts;
}
static Properties& registeredPrototype()
{
using namespace std::string_literals;
auto& prototype = Properties::getProperties(PROP_CLASS);
if(!prototype) {
prototype.registerProperty({PROP_TRACE_LOG, false, "Enable trace log", eWritable});
prototype.registerProperty({PROP_CPU, "CDP1802"s, "CPU type (currently only cdp1802)"});
prototype.registerProperty({PROP_CLOCK, Property::Integer{1773448, 100000, 500'000'000}, "Clock frequency, default is 1773448", eWritable});
prototype.registerProperty({PROP_RAM, Property::Combo{"3072"s}, "Size of ram in bytes", eWritable});
prototype.registerProperty({PROP_CLEAN_RAM, false, "Delete ram on startup", eWritable});
prototype.registerProperty({PROP_VIDEO, Property::Combo{"CDP1864"}, "Video hardware, only cdp1864"});
prototype.registerProperty({PROP_AUDIO, Property::Combo{"CDP1864"}, "Audio hardware, only cdp1864"});
prototype.registerProperty({PROP_KEYBOARD, Property::Combo{"ETI660 Hex", "ETI660 2-ROW", "VIP Hex"}, "Keyboard type, default is ETI660 hex"});
prototype.registerProperty({"", nullptr, ""});
prototype.registerProperty({PROP_ROM_NAME, "C8-MONITOR"s, "Rom image name, default c8-monitor"});
//prototype.registerProperty({PROP_INTERPRETER, Property::Combo{"NONE", "CHIP8", "CHIP10", "CHIP8RB", "CHIP8TPD", "CHIP8FPD", "CHIP8X", "CHIP8XTPD", "CHIP8XFPD", "CHIP8E"}, "CHIP-8 interpreter variant"});
prototype.registerProperty({PROP_START_ADDRESS, Property::Integer{512, 0, 4095}, "Initial CHIP-8 interpreter PC address"});
}
return prototype;
}
std::string cpuType;
int clockFrequency;
size_t ramSize;
bool cleanRam;
bool traceLog;
ETIVideoType videoType;
ETIAudioType audioType;
ETIKeyboard keyboard;
std::string romName;
uint16_t startAddress;
Palette palette;ip
};


class Dream6800::Private {
public:
static constexpr uint16_t FETCH_LOOP_ENTRY = 0xC00C;
Expand Down
37 changes: 26 additions & 11 deletions src/emulation/dream6800.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,50 @@

#include <emulation/emulatorhost.hpp>
#include <emulation/chip8realcorebase.hpp>
#include <emulation/coreregistry.hpp>
#include <emulation/hardware/m6800.hpp>
#include <emulation/iemulationcore.hpp>

namespace emu {

class Dream6800 : public Chip8RealCoreBase, public M6800Bus<>
{
public:
public:
//constexpr static uint32_t MAX_MEMORY_SIZE = 4096;
//constexpr static uint32_t MAX_ADDRESS_MASK = MAX_MEMORY_SIZE-1;

Dream6800(EmulatorHost& host, Chip8EmulatorOptions& options, IChip8Emulator* other = nullptr);
Dream6800(EmulatorHost& host, Properties& properties, IChip8Emulator* other = nullptr);
~Dream6800() override;

void reset() override;
bool updateProperties(Properties& props, Property& changed) override;
std::string name() const override;
int64_t executeFor(int64_t microseconds) override;
void executeInstruction() override;
void executeInstructions(int numInstructions) override;

// IEmulationCore
size_t numberOfExecutionUnits() const override;
GenericCpu* executionUnit(size_t index) override;
void setFocussedExecutionUnit(GenericCpu* unit) override;
GenericCpu* focussedExecutionUnit() override;

void executeFrame() override;
int frameRate() const override { return 50; }

bool loadData(std::span<const uint8_t> data, std::optional<uint32_t> loadAddress) override;

ExecMode execMode() const override;
void setExecMode(ExecMode mode) override;

int64_t executeFor(int64_t microseconds) override;
int executeInstruction() override;
void executeInstructions(int numInstructions) override;
int64_t machineCycles() const override;

uint8_t* memory() override;
int memSize() const override;
unsigned stackSize() const override;
StackContent stack() const override;

int64_t frames() const override;

bool isGenericEmulation() const override { return false; }

Expand All @@ -61,9 +80,8 @@ class Dream6800 : public Chip8RealCoreBase, public M6800Bus<>
uint16_t getMaxScreenHeight() const override;
const VideoType* getScreen() const override;

uint8_t soundTimer() const override;
//float getAudioPhase() const override;
//void setAudioPhase(float phase) override;
bool isDisplayEnabled() const override;

void renderAudio(int16_t* samples, size_t frames, int sampleFrequency) override;

// M6800-Bus
Expand All @@ -72,8 +90,6 @@ class Dream6800 : public Chip8RealCoreBase, public M6800Bus<>
uint8_t readMemoryByte(uint32_t addr) const override;
void writeByte(uint16_t addr, uint8_t val) override;

bool isDisplayEnabled() const override;

GenericCpu& getBackendCpu() override;

Properties& getProperties() override;
Expand All @@ -90,7 +106,6 @@ class Dream6800 : public Chip8RealCoreBase, public M6800Bus<>
void forceState();
class Private;
std::unique_ptr<Private> _impl;
Chip8EmulatorOptions _options;
};

};

0 comments on commit b3a9fff

Please sign in to comment.