Skip to content

Commit

Permalink
wip of property rework
Browse files Browse the repository at this point in the history
  • Loading branch information
gulrak committed Sep 18, 2024
1 parent 5f34728 commit 1049915
Show file tree
Hide file tree
Showing 25 changed files with 1,418 additions and 549 deletions.
19 changes: 11 additions & 8 deletions src/cadmium.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extern "C" {
#include <debugger.hpp>
#include <emuhostex.hpp>
#include <emulation/c8bfile.hpp>
//#include <emulation/chip8cores.hpp>
//#include <emulation/chip8generic.hpp>
#include <emulation/coreregistry.hpp>
//#include <emulation/dream6800.hpp>
#include <emulation/time.hpp>
Expand Down Expand Up @@ -566,11 +566,11 @@ class Cadmium : public emu::EmuHostEx
updateEmulatorOptions(props);
Cadmium::whenEmuChanged(*_chipEmu);
_debugger.updateCore(_chipEmu.get());
_screen = GenImageColor(emu::IEmulationCore::SUPPORTED_SCREEN_WIDTH, emu::IEmulationCore::SUPPORTED_SCREEN_HEIGHT, BLACK);
_screen = GenImageColor(emu::SUPPORTED_SCREEN_WIDTH, emu::SUPPORTED_SCREEN_HEIGHT, BLACK);
_screenTexture = LoadTextureFromImage(_screen);
_crt = GenImageColor(256,512,BLACK);
_crtTexture = LoadTextureFromImage(_crt);
_screenShot = GenImageColor(emu::IEmulationCore::SUPPORTED_SCREEN_WIDTH, emu::IEmulationCore::SUPPORTED_SCREEN_HEIGHT, BLACK);
_screenShot = GenImageColor(emu::SUPPORTED_SCREEN_WIDTH, emu::SUPPORTED_SCREEN_HEIGHT, BLACK);
_screenShotTexture = LoadTextureFromImage(_screen);
SetTextureFilter(_crtTexture, TEXTURE_FILTER_BILINEAR);
SetTextureFilter(_screenShotTexture, TEXTURE_FILTER_POINT);
Expand Down Expand Up @@ -2839,20 +2839,20 @@ int main(int argc, char* argv[])
presetsDescription += fmt::format(" {} - {} ({})\n", toOptionName(info->prefix() + '-' + info->variantName(i)), info->variantDescription(i), info->variantExtensions(i));
}
auto proto = info->propertiesPrototype();
auto oldCat = cli.category(fmt::format("{} Options (only available if preset uses {} core)", name, toOptionName(info->prefix())));
auto oldCat = cli.category(fmt::format("{} Options (only available if preset uses {} core)", name, info->prefix().empty() ? "default" : toOptionName(info->prefix())));
for(size_t i = 0; i < proto.numProperties(); ++i) {
auto& prop = proto[i];
if(!prop.isReadonly()) {
auto dependencyCheck = [&presetName, info](){ return info->hasVariant(presetName); };
std::visit(emu::visitor{
[](std::nullptr_t) -> void { },
[dependencyCheck,&prop,&cli](bool& val) -> void { cli.option<bool>({fmt::format("--{}", toOptionName(prop.getName()))}, [](const std::string& paramName, const bool& value) {
[dependencyCheck,&prop,&cli](bool& val) -> void { cli.option<bool>({fmt::format("--{}", prop.getOptionName())}, [](const std::string& paramName, const bool& value) {
coreProperties.at(paramName).setBool(value);
}, prop.getDescription()).dependsOn(dependencyCheck); },
[dependencyCheck,&prop,&cli](emu::Property::Integer& val) -> void { cli.option<std::string>({fmt::format("--{}", toOptionName(prop.getName()))}, [](const std::string& paramName, const std::string& value) {
[dependencyCheck,&prop,&cli](emu::Property::Integer& val) -> void { cli.option<std::string>({fmt::format("--{}", prop.getOptionName())}, [](const std::string& paramName, const std::string& value) {
coreProperties.at(paramName).setString(value);
}, prop.getDescription()).dependsOn(dependencyCheck).range(prop.getIntMin(), prop.getIntMax()); },
[dependencyCheck,&prop,&cli](std::string& val) -> void { cli.option<int>({fmt::format("--{}", toOptionName(prop.getName()))}, [](const std::string& paramName, const int& value) {
[dependencyCheck,&prop,&cli](std::string& val) -> void { cli.option<int>({fmt::format("--{}", prop.getOptionName())}, [](const std::string& paramName, const int& value) {
coreProperties.at(paramName).setInt(value);
}, prop.getDescription()).dependsOn(dependencyCheck); },
[dependencyCheck,&prop,&cli](emu::Property::Combo& val) -> void {
Expand All @@ -2864,7 +2864,7 @@ int main(int argc, char* argv[])
}
optionList << toOptionName(*i);
}
cli.option<ghc::CLI::Combo>({fmt::format("--{}", toOptionName(prop.getName()))}, [](const std::string& paramName, const ghc::CLI::Combo& value) {
cli.option<ghc::CLI::Combo>({fmt::format("--{}", prop.getOptionName())}, [](const std::string& paramName, const ghc::CLI::Combo& value) {
coreProperties.at(paramName).setSelectedIndex(value.index);
}, prop.getDescription() + " (" + optionList.str() +")").dependsOn(dependencyCheck);
}
Expand All @@ -2876,6 +2876,9 @@ int main(int argc, char* argv[])
cli.option({"-p", "--preset"}, presetName, "Select one of the following available preset:\n" + trimRight(presetsDescription), [&presetName](std::string) {
// Todo: Set coreProperties to a matching instance
coreProperties = emu::CoreRegistry::propertiesForPreset(presetName);
if(!coreProperties) {
throw std::runtime_error(fmt::format("Unknown preset: '{}' (use --help to see supported presets)", presetName));
}
});
#if 0
cli.option({"-s", "--exec-speed"}, execSpeed, "Set execution speed in instructions per frame (0-500000, 0: unlimited)");
Expand Down
4 changes: 2 additions & 2 deletions src/emuhostex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <configuration.hpp>
#include <emulation/c8bfile.hpp>
#include <emulation/coreregistry.hpp>
//#include <emulation/chip8cores.hpp>
//#include <emulation/chip8generic.hpp>
//#include <emulation/chip8strict.hpp>
//#include <emulation/cosmacvip.hpp>
//#include <emulation/dream6800.hpp>
Expand Down Expand Up @@ -159,7 +159,7 @@ std::unique_ptr<IEmulationCore> EmuHostEx::create(Properties& properties, IEmula
}
}
else if(engine == IChip8Emulator::eCHIP8MPT) {
return std::make_unique<Chip8EmulatorFP>(*this, options, iother);
return std::make_unique<Chip8GenericEmulator>(*this, options, iother);
}
else if(engine == IChip8Emulator::eCHIP8VIP) {
return std::make_unique<CosmacVIP>(*this, options, iother);
Expand Down
8 changes: 5 additions & 3 deletions src/emulation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

set(CHIP8_EMU_SOURCE
#chip8cores.cpp
#chip8cores.hpp
chip8generic.cpp
chip8generic.hpp
#chip8emulatorbase.cpp
#chip8emulatorbase.hpp
chip8genericbase.cpp
chip8genericbase.hpp
chip8opcodedisass.cpp
chip8opcodedisass.hpp
chip8options.cpp
Expand Down Expand Up @@ -31,7 +33,7 @@ set(CHIP8_EMU_SOURCE
time.cpp
time.hpp
utility.cpp
#octocartridge.cpp
#octocartridge.cpp
#octocartridge.hpp
)

Expand Down
2 changes: 1 addition & 1 deletion src/emulation/chip8emulatorbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ std::unique_ptr<IChip8Emulator> Chip8EmulatorBase::create(Chip8EmulatorHost& hos
}
}
else if(engine == eCHIP8MPT) {
return std::make_unique<Chip8EmulatorFP>(host, options, iother);
return std::make_unique<Chip8GenericEmulator>(host, options, iother);
}
else if(engine == eCHIP8VIP) {
return std::make_unique<CosmacVIP>(host, options, iother);
Expand Down
Loading

0 comments on commit 1049915

Please sign in to comment.