diff --git a/Emulator/Base/Host.cpp b/Emulator/Base/Host.cpp index 711b952a0..fbb0e908a 100644 --- a/Emulator/Base/Host.cpp +++ b/Emulator/Base/Host.cpp @@ -38,6 +38,7 @@ Host::checkOption(Option opt, i64 value) case OPT_HOST_SAMPLE_RATE: case OPT_HOST_FRAMEBUF_WIDTH: case OPT_HOST_FRAMEBUF_HEIGHT: + return; default: diff --git a/Emulator/Components/Agnus/Agnus.cpp b/Emulator/Components/Agnus/Agnus.cpp index 1e76cd7d2..40f2a3115 100644 --- a/Emulator/Components/Agnus/Agnus.cpp +++ b/Emulator/Components/Agnus/Agnus.cpp @@ -77,9 +77,9 @@ Agnus::getOption(Option option) const } void -Agnus::setOption(Option option, i64 value) +Agnus::checkOption(Option opt, i64 value) { - switch (option) { + switch (opt) { case OPT_AGNUS_REVISION: @@ -89,6 +89,23 @@ Agnus::setOption(Option option, i64 value) if (!AgnusRevisionEnum::isValid(value)) { throw Error(ERROR_OPT_INV_ARG, AgnusRevisionEnum::keyList()); } + return; + + case OPT_AGNUS_PTR_DROPS: + + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + +void +Agnus::setOption(Option option, i64 value) +{ + switch (option) { + + case OPT_AGNUS_REVISION: switch (config.revision = (AgnusRevision)value) { diff --git a/Emulator/Components/Agnus/Agnus.h b/Emulator/Components/Agnus/Agnus.h index 0507568c0..e6f77cf93 100644 --- a/Emulator/Components/Agnus/Agnus.h +++ b/Emulator/Components/Agnus/Agnus.h @@ -362,6 +362,7 @@ class Agnus : public SubComponent, public Inspectable { const AgnusConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; void setVideoFormat(VideoFormat newFormat); diff --git a/Emulator/Components/Agnus/AgnusEvents.cpp b/Emulator/Components/Agnus/AgnusEvents.cpp index 8aadde33b..46e4efc27 100644 --- a/Emulator/Components/Agnus/AgnusEvents.cpp +++ b/Emulator/Components/Agnus/AgnusEvents.cpp @@ -720,15 +720,6 @@ Agnus::serviceDASEvent(EventID id) ciab.tod.increment(); break; - /* - case DAS_HSYNC: - - syncEvent = id; - // recordRegisterChange(DMA_CYCLES(1), REG_NONE, 0); - scheduleRel (DMA_CYCLES(1), REG_CHANGE); - break; - */ - case DAS_EOL: assert(pos.h == HPOS_MAX_PAL || pos.h == HPOS_MAX_NTSC); diff --git a/Emulator/Components/Agnus/Blitter/Blitter.cpp b/Emulator/Components/Agnus/Blitter/Blitter.cpp index a5fb199f1..38eb8a0c1 100644 --- a/Emulator/Components/Agnus/Blitter/Blitter.cpp +++ b/Emulator/Components/Agnus/Blitter/Blitter.cpp @@ -86,20 +86,32 @@ Blitter::getOption(Option option) const } void -Blitter::setOption(Option option, i64 value) +Blitter::checkOption(Option opt, i64 value) { - switch (option) { - + switch (opt) { + case OPT_BLITTER_ACCURACY: - { + if (value < 0 || value > 2) { throw Error(ERROR_OPT_INV_ARG, "0, 1, 2"); } + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + +void +Blitter::setOption(Option option, i64 value) +{ + switch (option) { - SUSPENDED + case OPT_BLITTER_ACCURACY: + config.accuracy = (isize)value; return; - } + default: fatalError; } diff --git a/Emulator/Components/Agnus/Blitter/Blitter.h b/Emulator/Components/Agnus/Blitter/Blitter.h index a336c369e..e28011b28 100644 --- a/Emulator/Components/Agnus/Blitter/Blitter.h +++ b/Emulator/Components/Agnus/Blitter/Blitter.h @@ -365,6 +365,7 @@ class Blitter : public SubComponent, public Inspectable const BlitterConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; diff --git a/Emulator/Components/Agnus/DmaDebugger/DmaDebugger.cpp b/Emulator/Components/Agnus/DmaDebugger/DmaDebugger.cpp index a93430c76..97ec0e542 100644 --- a/Emulator/Components/Agnus/DmaDebugger/DmaDebugger.cpp +++ b/Emulator/Components/Agnus/DmaDebugger/DmaDebugger.cpp @@ -50,6 +50,47 @@ DmaDebugger::getOption(Option option) const } } +void +DmaDebugger::checkOption(Option opt, i64 value) +{ + switch (opt) { + + case OPT_DMA_DEBUG_ENABLE: + + return; + + case OPT_DMA_DEBUG_MODE: + + if (!DmaDisplayModeEnum::isValid(value)) { + throw Error(ERROR_OPT_INV_ARG, DmaDisplayModeEnum::keyList()); + } + return; + + case OPT_DMA_DEBUG_OPACITY: + case OPT_DMA_DEBUG_CHANNEL0: + case OPT_DMA_DEBUG_CHANNEL1: + case OPT_DMA_DEBUG_CHANNEL2: + case OPT_DMA_DEBUG_CHANNEL3: + case OPT_DMA_DEBUG_CHANNEL4: + case OPT_DMA_DEBUG_CHANNEL5: + case OPT_DMA_DEBUG_CHANNEL6: + case OPT_DMA_DEBUG_CHANNEL7: + case OPT_DMA_DEBUG_COLOR0: + case OPT_DMA_DEBUG_COLOR1: + case OPT_DMA_DEBUG_COLOR2: + case OPT_DMA_DEBUG_COLOR3: + case OPT_DMA_DEBUG_COLOR4: + case OPT_DMA_DEBUG_COLOR5: + case OPT_DMA_DEBUG_COLOR6: + case OPT_DMA_DEBUG_COLOR7: + + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + void DmaDebugger::setOption(Option option, i64 value) { @@ -63,10 +104,6 @@ DmaDebugger::setOption(Option option, i64 value) case OPT_DMA_DEBUG_MODE: - if (!DmaDisplayModeEnum::isValid(value)) { - throw Error(ERROR_OPT_INV_ARG, DmaDisplayModeEnum::keyList()); - } - config.displayMode = (DmaDisplayMode)value; return; diff --git a/Emulator/Components/Agnus/DmaDebugger/DmaDebugger.h b/Emulator/Components/Agnus/DmaDebugger/DmaDebugger.h index 95c709255..c27864095 100644 --- a/Emulator/Components/Agnus/DmaDebugger/DmaDebugger.h +++ b/Emulator/Components/Agnus/DmaDebugger/DmaDebugger.h @@ -118,6 +118,7 @@ class DmaDebugger : public SubComponent, public Inspectable { const DmaDebuggerConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; private: diff --git a/Emulator/Components/Amiga.cpp b/Emulator/Components/Amiga.cpp index 640f03f23..b2db4561c 100644 --- a/Emulator/Components/Amiga.cpp +++ b/Emulator/Components/Amiga.cpp @@ -189,6 +189,12 @@ Amiga::checkOption(Option opt, i64 value) switch (opt) { case OPT_AMIGA_VIDEO_FORMAT: + + if (!VideoFormatEnum::isValid(value)) { + throw Error(ERROR_OPT_INV_ARG, VideoFormatEnum::keyList()); + } + return; + case OPT_AMIGA_WARP_BOOT: return; @@ -201,7 +207,16 @@ Amiga::checkOption(Option opt, i64 value) return; case OPT_AMIGA_VSYNC: + + return; + case OPT_AMIGA_SPEED_BOOST: + + if (value < 50 || value > 200) { + throw Error(ERROR_OPT_INV_ARG, "50...200"); + } + return; + case OPT_AMIGA_SNAPSHOTS: return; @@ -232,14 +247,8 @@ Amiga::setOption(Option option, i64 value) case OPT_AMIGA_VIDEO_FORMAT: - if (!VideoFormatEnum::isValid(value)) { - throw Error(ERROR_OPT_INV_ARG, VideoFormatEnum::keyList()); - } - if (value != config.type) { - SUSPENDED - config.type = VideoFormat(value); agnus.setVideoFormat(config.type); } @@ -252,10 +261,6 @@ Amiga::setOption(Option option, i64 value) case OPT_AMIGA_WARP_MODE: - if (!WarpModeEnum::isValid(value)) { - throw Error(ERROR_OPT_INV_ARG, WarpModeEnum::keyList()); - } - config.warpMode = WarpMode(value); return; @@ -266,10 +271,6 @@ Amiga::setOption(Option option, i64 value) case OPT_AMIGA_SPEED_BOOST: - if (value < 50 || value > 200) { - throw Error(ERROR_OPT_INV_ARG, "50...200"); - } - config.timeLapse = isize(value); return; diff --git a/Emulator/Components/CIA/CIA.cpp b/Emulator/Components/CIA/CIA.cpp index 3e503ba51..46b430db0 100755 --- a/Emulator/Components/CIA/CIA.cpp +++ b/Emulator/Components/CIA/CIA.cpp @@ -77,10 +77,10 @@ CIA::getOption(Option option) const { switch (option) { - case OPT_CIA_REVISION: return config.revision; - case OPT_CIA_TODBUG: return config.todBug; - case OPT_CIA_ECLOCK_SYNCING: return config.eClockSyncing; - case OPT_CIA_IDLE_SLEEP: return config.idleSleep; + case OPT_CIA_REVISION: return config.revision; + case OPT_CIA_TODBUG: return config.todBug; + case OPT_CIA_ECLOCK_SYNCING: return config.eClockSyncing; + case OPT_CIA_IDLE_SLEEP: return config.idleSleep; default: fatalError; @@ -88,16 +88,35 @@ CIA::getOption(Option option) const } void -CIA::setOption(Option option, i64 value) +CIA::checkOption(Option opt, i64 value) { - switch (option) { - + switch (opt) { + case OPT_CIA_REVISION: - + if (!CIARevisionEnum::isValid(value)) { throw Error(ERROR_OPT_INV_ARG, CIARevisionEnum::keyList()); } + return; + + case OPT_CIA_TODBUG: + case OPT_CIA_ECLOCK_SYNCING: + case OPT_CIA_IDLE_SLEEP: + + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + +void +CIA::setOption(Option option, i64 value) +{ + switch (option) { + case OPT_CIA_REVISION: + config.revision = (CIARevision)value; return; diff --git a/Emulator/Components/CIA/CIA.h b/Emulator/Components/CIA/CIA.h index fc683a660..61aed27b1 100755 --- a/Emulator/Components/CIA/CIA.h +++ b/Emulator/Components/CIA/CIA.h @@ -431,6 +431,7 @@ class CIA : public SubComponent, public Inspectable { const CIAConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; diff --git a/Emulator/Components/CPU/CPU.cpp b/Emulator/Components/CPU/CPU.cpp index c6eab09f6..293e5a587 100644 --- a/Emulator/Components/CPU/CPU.cpp +++ b/Emulator/Components/CPU/CPU.cpp @@ -300,24 +300,15 @@ CPU::getOption(Option option) const } void -CPU::setOption(Option option, i64 value) +CPU::checkOption(Option opt, i64 value) { - auto cpuModel = [&](CPURevision rev) { return moira::Model(rev); }; - auto dasmModel = [&](DasmRevision rev) { return moira::Model(rev); }; - auto syntax = [&](DasmSyntax rev) { return moira::DasmSyntax(rev); }; - - switch (option) { + switch (opt) { case OPT_CPU_REVISION: if (!CPURevisionEnum::isValid(value)) { throw Error(ERROR_OPT_INV_ARG, CPURevisionEnum::keyList()); } - - suspend(); - config.revision = CPURevision(value); - setModel(cpuModel(config.revision), dasmModel(config.dasmRevision)); - resume(); return; case OPT_CPU_DASM_REVISION: @@ -325,11 +316,6 @@ CPU::setOption(Option option, i64 value) if (!DasmRevisionEnum::isValid(value)) { throw Error(ERROR_OPT_INV_ARG, DasmRevisionEnum::keyList()); } - - suspend(); - config.dasmRevision = DasmRevision(value); - setModel(cpuModel(config.revision), dasmModel(config.dasmRevision)); - resume(); return; case OPT_CPU_DASM_SYNTAX: @@ -337,18 +323,48 @@ CPU::setOption(Option option, i64 value) if (!DasmSyntaxEnum::isValid(value)) { throw Error(ERROR_OPT_INV_ARG, DasmSyntaxEnum::keyList()); } + return; + + case OPT_CPU_OVERCLOCKING: + case OPT_CPU_RESET_VAL: + + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + +void +CPU::setOption(Option option, i64 value) +{ + auto cpuModel = [&](CPURevision rev) { return moira::Model(rev); }; + auto dasmModel = [&](DasmRevision rev) { return moira::Model(rev); }; + auto syntax = [&](DasmSyntax rev) { return moira::DasmSyntax(rev); }; + + switch (option) { + + case OPT_CPU_REVISION: + + config.revision = CPURevision(value); + setModel(cpuModel(config.revision), dasmModel(config.dasmRevision)); + return; + + case OPT_CPU_DASM_REVISION: + + config.dasmRevision = DasmRevision(value); + setModel(cpuModel(config.revision), dasmModel(config.dasmRevision)); + return; + + case OPT_CPU_DASM_SYNTAX: - suspend(); config.dasmSyntax = DasmSyntax(value); setDasmSyntax(syntax(config.dasmSyntax)); - resume(); return; case OPT_CPU_OVERCLOCKING: - suspend(); config.overclocking = isize(value); - resume(); msgQueue.put(MSG_OVERCLOCKING, config.overclocking); return; diff --git a/Emulator/Components/CPU/CPU.h b/Emulator/Components/CPU/CPU.h index 639d92e2f..6d49788dd 100644 --- a/Emulator/Components/CPU/CPU.h +++ b/Emulator/Components/CPU/CPU.h @@ -224,6 +224,7 @@ class CPU : public moira::Moira, public Inspectable const CPUConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option opt) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option opt, i64 value) override; diff --git a/Emulator/Components/Denise/Denise.cpp b/Emulator/Components/Denise/Denise.cpp index f4bab1de4..6a73000c0 100644 --- a/Emulator/Components/Denise/Denise.cpp +++ b/Emulator/Components/Denise/Denise.cpp @@ -40,16 +40,16 @@ Denise::getOption(Option option) const { switch (option) { - case OPT_DENISE_REVISION: return config.revision; - case OPT_DENISE_VIEWPORT_TRACKING: return config.viewportTracking; - case OPT_DENISE_FRAME_SKIPPING: return config.frameSkipping; - case OPT_DENISE_HIDDEN_BITPLANES: return config.hiddenBitplanes; - case OPT_DENISE_HIDDEN_SPRITES: return config.hiddenSprites; - case OPT_DENISE_HIDDEN_LAYERS: return config.hiddenLayers; - case OPT_DENISE_HIDDEN_LAYER_ALPHA: return config.hiddenLayerAlpha; - case OPT_DENISE_CLX_SPR_SPR: return config.clxSprSpr; - case OPT_DENISE_CLX_SPR_PLF: return config.clxSprPlf; - case OPT_DENISE_CLX_PLF_PLF: return config.clxPlfPlf; + case OPT_DENISE_REVISION: return config.revision; + case OPT_DENISE_VIEWPORT_TRACKING: return config.viewportTracking; + case OPT_DENISE_FRAME_SKIPPING: return config.frameSkipping; + case OPT_DENISE_HIDDEN_BITPLANES: return config.hiddenBitplanes; + case OPT_DENISE_HIDDEN_SPRITES: return config.hiddenSprites; + case OPT_DENISE_HIDDEN_LAYERS: return config.hiddenLayers; + case OPT_DENISE_HIDDEN_LAYER_ALPHA: return config.hiddenLayerAlpha; + case OPT_DENISE_CLX_SPR_SPR: return config.clxSprSpr; + case OPT_DENISE_CLX_SPR_PLF: return config.clxSprPlf; + case OPT_DENISE_CLX_PLF_PLF: return config.clxPlfPlf; default: fatalError; @@ -57,16 +57,41 @@ Denise::getOption(Option option) const } void -Denise::setOption(Option option, i64 value) +Denise::checkOption(Option opt, i64 value) { - switch (option) { - + switch (opt) { + case OPT_DENISE_REVISION: - + if (!DeniseRevisionEnum::isValid(value)) { throw Error(ERROR_OPT_INV_ARG, DeniseRevisionEnum::keyList()); } + return; + + case OPT_DENISE_VIEWPORT_TRACKING: + case OPT_DENISE_FRAME_SKIPPING: + case OPT_DENISE_HIDDEN_BITPLANES: + case OPT_DENISE_HIDDEN_SPRITES: + case OPT_DENISE_HIDDEN_LAYERS: + case OPT_DENISE_HIDDEN_LAYER_ALPHA: + case OPT_DENISE_CLX_SPR_SPR: + case OPT_DENISE_CLX_SPR_PLF: + case OPT_DENISE_CLX_PLF_PLF: + + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + +void +Denise::setOption(Option option, i64 value) +{ + switch (option) { + case OPT_DENISE_REVISION: + config.revision = (DeniseRevision)value; return; diff --git a/Emulator/Components/Denise/Denise.h b/Emulator/Components/Denise/Denise.h index 867691945..ce6c2d66d 100644 --- a/Emulator/Components/Denise/Denise.h +++ b/Emulator/Components/Denise/Denise.h @@ -488,6 +488,7 @@ class Denise : public SubComponent, public Inspectable { const DeniseConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; diff --git a/Emulator/Components/Denise/PixelEngine.cpp b/Emulator/Components/Denise/PixelEngine.cpp index 46f2026a7..be0f774ef 100644 --- a/Emulator/Components/Denise/PixelEngine.cpp +++ b/Emulator/Components/Denise/PixelEngine.cpp @@ -93,38 +93,29 @@ PixelEngine::getOption(Option option) const } void -PixelEngine::setOption(Option option, i64 value) +PixelEngine::checkOption(Option opt, i64 value) { - switch (option) { - + switch (opt) { + case OPT_MON_PALETTE: - + if (!PaletteEnum::isValid(value)) { throw Error(ERROR_OPT_INV_ARG, PaletteEnum::keyList()); } - - config.palette = (Palette)value; - updateRGBA(); return; case OPT_MON_BRIGHTNESS: - + if (value < 0 || value > 100) { throw Error(ERROR_OPT_INV_ARG, "0...100"); } - - config.brightness = (isize)value; - updateRGBA(); return; - + case OPT_MON_CONTRAST: if (value < 0 || value > 100) { throw Error(ERROR_OPT_INV_ARG, "0...100"); } - - config.contrast = (isize)value; - updateRGBA(); return; case OPT_MON_SATURATION: @@ -132,7 +123,38 @@ PixelEngine::setOption(Option option, i64 value) if (value < 0 || value > 100) { throw Error(ERROR_OPT_INV_ARG, "0...100"); } + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + +void +PixelEngine::setOption(Option option, i64 value) +{ + switch (option) { + + case OPT_MON_PALETTE: + + config.palette = (Palette)value; + updateRGBA(); + return; + + case OPT_MON_BRIGHTNESS: + + config.brightness = (isize)value; + updateRGBA(); + return; + case OPT_MON_CONTRAST: + + config.contrast = (isize)value; + updateRGBA(); + return; + + case OPT_MON_SATURATION: + config.saturation = (isize)value; updateRGBA(); return; diff --git a/Emulator/Components/Denise/PixelEngine.h b/Emulator/Components/Denise/PixelEngine.h index 15d83f921..d6367c8d9 100644 --- a/Emulator/Components/Denise/PixelEngine.h +++ b/Emulator/Components/Denise/PixelEngine.h @@ -167,6 +167,7 @@ class PixelEngine : public SubComponent { const PixelEngineConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; diff --git a/Emulator/Components/Memory/Memory.cpp b/Emulator/Components/Memory/Memory.cpp index 70aa012fe..eb3547ce7 100644 --- a/Emulator/Components/Memory/Memory.cpp +++ b/Emulator/Components/Memory/Memory.cpp @@ -140,55 +140,105 @@ Memory::getOption(Option option) const } void -Memory::setOption(Option option, i64 value) +Memory::checkOption(Option opt, i64 value) { - switch (option) { - + switch (opt) { + case OPT_MEM_CHIP_RAM: - + if (!isPoweredOff()) { throw Error(ERROR_OPT_LOCKED); } if (value != 256 && value != 512 && value != 1024 && value != 2048) { throw Error(ERROR_OPT_INV_ARG, "256, 512, 1024, 2048"); } - - mem.allocChip((i32)KB(value)); return; - + case OPT_MEM_SLOW_RAM: - + if (!isPoweredOff()) { throw Error(ERROR_OPT_LOCKED); } if ((value % 256) != 0 || value > 1536) { throw Error(ERROR_OPT_INV_ARG, "0, 256, 512, ..., 1536"); } - - mem.allocSlow((i32)KB(value)); return; - + case OPT_MEM_FAST_RAM: - + if (!isPoweredOff()) { throw Error(ERROR_OPT_LOCKED); } if ((value % 64) != 0 || value > 8192) { throw Error(ERROR_OPT_INV_ARG, "0, 64, 128, ..., 8192"); } - - mem.allocFast((i32)KB(value)); return; - + case OPT_MEM_EXT_START: - + if (!isPoweredOff()) { throw Error(ERROR_OPT_LOCKED); } if (value != 0xE0 && value != 0xF0) { throw Error(ERROR_OPT_INV_ARG, "E0, F0"); } + return; + + case OPT_MEM_SAVE_ROMS: + case OPT_MEM_SLOW_RAM_DELAY: + case OPT_MEM_SLOW_RAM_MIRROR: + + return; + + case OPT_MEM_BANKMAP: + + if (!BankMapEnum::isValid(value)) { + throw Error(ERROR_OPT_INV_ARG, BankMapEnum::keyList()); + } + return; + + case OPT_MEM_UNMAPPING_TYPE: + + if (!UnmappedMemoryEnum::isValid(value)) { + throw Error(ERROR_OPT_INV_ARG, UnmappedMemoryEnum::keyList()); + } + return; + + case OPT_MEM_RAM_INIT_PATTERN: + + if (!RamInitPatternEnum::isValid(value)) { + throw Error(ERROR_OPT_INV_ARG, RamInitPatternEnum::keyList()); + } + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + + +void +Memory::setOption(Option option, i64 value) +{ + switch (option) { + case OPT_MEM_CHIP_RAM: + + mem.allocChip((i32)KB(value)); + return; + + case OPT_MEM_SLOW_RAM: + + mem.allocSlow((i32)KB(value)); + return; + + case OPT_MEM_FAST_RAM: + + mem.allocFast((i32)KB(value)); + return; + + case OPT_MEM_EXT_START: + config.extStart = (u32)value; updateMemSrcTables(); return; @@ -210,29 +260,17 @@ Memory::setOption(Option option, i64 value) return; case OPT_MEM_BANKMAP: - { - if (!BankMapEnum::isValid(value)) { - throw Error(ERROR_OPT_INV_ARG, BankMapEnum::keyList()); - } - + config.bankMap = (BankMap)value; updateMemSrcTables(); return; - } + case OPT_MEM_UNMAPPING_TYPE: - { - if (!UnmappedMemoryEnum::isValid(value)) { - throw Error(ERROR_OPT_INV_ARG, UnmappedMemoryEnum::keyList()); - } - + config.unmappingType = (UnmappedMemory)value; return; - } - case OPT_MEM_RAM_INIT_PATTERN: - if (!RamInitPatternEnum::isValid(value)) { - throw Error(ERROR_OPT_INV_ARG, RamInitPatternEnum::keyList()); - } + case OPT_MEM_RAM_INIT_PATTERN: config.ramInitPattern = (RamInitPattern)value; if (isPoweredOff()) fillRamWithInitPattern(); diff --git a/Emulator/Components/Memory/Memory.h b/Emulator/Components/Memory/Memory.h index 651256d44..eb5c8b84d 100644 --- a/Emulator/Components/Memory/Memory.h +++ b/Emulator/Components/Memory/Memory.h @@ -327,6 +327,7 @@ class Memory : public SubComponent, public Inspectable { const MemConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; diff --git a/Emulator/Components/Paula/Audio/AudioFilter.cpp b/Emulator/Components/Paula/Audio/AudioFilter.cpp index 6691f54aa..36dddba67 100644 --- a/Emulator/Components/Paula/Audio/AudioFilter.cpp +++ b/Emulator/Components/Paula/Audio/AudioFilter.cpp @@ -246,15 +246,28 @@ AudioFilter::getOption(Option option) const } void -AudioFilter::setOption(Option option, i64 value) +AudioFilter::checkOption(Option opt, i64 value) { - switch (option) { + switch (opt) { case OPT_AUD_FILTER_TYPE: if (!FilterTypeEnum::isValid(value)) { throw Error(ERROR_OPT_INV_ARG, FilterTypeEnum::keyList()); } + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + +void +AudioFilter::setOption(Option option, i64 value) +{ + switch (option) { + + case OPT_AUD_FILTER_TYPE: config.filterType = (FilterType)value; setup(double(emulator.get(OPT_HOST_SAMPLE_RATE))); diff --git a/Emulator/Components/Paula/Audio/AudioFilter.h b/Emulator/Components/Paula/Audio/AudioFilter.h index 6d73441e8..1c32d07c4 100644 --- a/Emulator/Components/Paula/Audio/AudioFilter.h +++ b/Emulator/Components/Paula/Audio/AudioFilter.h @@ -233,6 +233,7 @@ class AudioFilter : public SubComponent { const AudioFilterConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; private: diff --git a/Emulator/Components/Paula/DiskController/DiskController.cpp b/Emulator/Components/Paula/DiskController/DiskController.cpp index 4627545a9..c19d40ea7 100644 --- a/Emulator/Components/Paula/DiskController/DiskController.cpp +++ b/Emulator/Components/Paula/DiskController/DiskController.cpp @@ -46,21 +46,37 @@ DiskController::getOption(Option option) const } void -DiskController::setOption(Option option, i64 value) +DiskController::checkOption(Option opt, i64 value) { - switch (option) { - + switch (opt) { + case OPT_DC_SPEED: - { + if (!isValidDriveSpeed((isize)value)) { throw Error(ERROR_OPT_INV_ARG, "-1, 1, 2, 4, 8"); } + return; + + case OPT_DC_AUTO_DSKSYNC: + case OPT_DC_LOCK_DSKSYNC: + + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + +void +DiskController::setOption(Option option, i64 value) +{ + switch (option) { - SUSPENDED + case OPT_DC_SPEED: + config.speed = (i32)value; scheduleFirstDiskEvent(); return; - } case OPT_DC_AUTO_DSKSYNC: diff --git a/Emulator/Components/Paula/DiskController/DiskController.h b/Emulator/Components/Paula/DiskController/DiskController.h index 60c44c3f7..a5140ff9b 100644 --- a/Emulator/Components/Paula/DiskController/DiskController.h +++ b/Emulator/Components/Paula/DiskController/DiskController.h @@ -198,6 +198,7 @@ class DiskController : public SubComponent, public Inspectable { const SerialPortConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; diff --git a/Emulator/Components/RTC/RTC.cpp b/Emulator/Components/RTC/RTC.cpp index 631c308f9..8dda2e3fd 100644 --- a/Emulator/Components/RTC/RTC.cpp +++ b/Emulator/Components/RTC/RTC.cpp @@ -28,10 +28,10 @@ RTC::getOption(Option option) const } void -RTC::setOption(Option option, i64 value) +RTC::checkOption(Option opt, i64 value) { - switch (option) { - + switch (opt) { + case OPT_RTC_MODEL: if (!isPoweredOff()) { @@ -40,7 +40,20 @@ RTC::setOption(Option option, i64 value) if (!RTCRevisionEnum::isValid(value)) { throw Error(ERROR_OPT_INV_ARG, RTCRevisionEnum::keyList()); } + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + +void +RTC::setOption(Option option, i64 value) +{ + switch (option) { + case OPT_RTC_MODEL: + config.model = (RTCRevision)value; mem.updateMemSrcTables(); return; diff --git a/Emulator/Components/RTC/RTC.h b/Emulator/Components/RTC/RTC.h index bc1323f97..aaee5355a 100644 --- a/Emulator/Components/RTC/RTC.h +++ b/Emulator/Components/RTC/RTC.h @@ -134,6 +134,7 @@ class RTC : public SubComponent { const RTCConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; diff --git a/Emulator/Components/Zorro/DiagBoard.cpp b/Emulator/Components/Zorro/DiagBoard.cpp index 5d6912c05..1b90c89e9 100644 --- a/Emulator/Components/Zorro/DiagBoard.cpp +++ b/Emulator/Components/Zorro/DiagBoard.cpp @@ -53,15 +53,29 @@ DiagBoard::getOption(Option option) const } void -DiagBoard::setOption(Option option, i64 value) +DiagBoard::checkOption(Option opt, i64 value) { - switch (option) { - + switch (opt) { + case OPT_DIAG_BOARD: if (!isPoweredOff()) { throw Error(ERROR_OPT_LOCKED); } + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + +void +DiagBoard::setOption(Option option, i64 value) +{ + switch (option) { + + case OPT_DIAG_BOARD: + config.enabled = value; return; diff --git a/Emulator/Components/Zorro/DiagBoard.h b/Emulator/Components/Zorro/DiagBoard.h index 670d0e572..fb866f629 100644 --- a/Emulator/Components/Zorro/DiagBoard.h +++ b/Emulator/Components/Zorro/DiagBoard.h @@ -77,6 +77,7 @@ class DiagBoard : public ZorroBoard { const DiagBoardConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; diff --git a/Emulator/Components/Zorro/HdController.cpp b/Emulator/Components/Zorro/HdController.cpp index c0d8a1053..3f1491bd5 100644 --- a/Emulator/Components/Zorro/HdController.cpp +++ b/Emulator/Components/Zorro/HdController.cpp @@ -95,31 +95,43 @@ HdController::getOption(Option option) const } void -HdController::setOption(Option option, i64 value) +HdController::checkOption(Option opt, i64 value) { - switch (option) { + switch (opt) { case OPT_HDC_CONNECT: - + if (!isPoweredOff()) { throw Error(ERROR_OPT_LOCKED); } - - if (bool(value) == config.connected) { - break; - } + return; - if (value) { - - config.connected = true; - drive.connect(); - msgQueue.put(MSG_HDC_CONNECT, DriveMsg { i16(objid), true, 0, 0 } ); + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} - } else { - - config.connected = false; - drive.disconnect(); - msgQueue.put(MSG_HDC_CONNECT, DriveMsg { i16(objid), false, 0, 0 } ); +void +HdController::setOption(Option option, i64 value) +{ + switch (option) { + + case OPT_HDC_CONNECT: + + if (bool(value) != config.connected) { + + if (value) { + + config.connected = true; + drive.connect(); + msgQueue.put(MSG_HDC_CONNECT, DriveMsg { i16(objid), true, 0, 0 } ); + + } else { + + config.connected = false; + drive.disconnect(); + msgQueue.put(MSG_HDC_CONNECT, DriveMsg { i16(objid), false, 0, 0 } ); + } } return; diff --git a/Emulator/Components/Zorro/HdController.h b/Emulator/Components/Zorro/HdController.h index 187ec6b58..012f06b77 100644 --- a/Emulator/Components/Zorro/HdController.h +++ b/Emulator/Components/Zorro/HdController.h @@ -174,6 +174,7 @@ class HdController : public ZorroBoard, public Inspectable { const HdcConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; diff --git a/Emulator/Misc/RemoteServers/RemoteServer.cpp b/Emulator/Misc/RemoteServers/RemoteServer.cpp index 0cea81c49..1403a0d48 100644 --- a/Emulator/Misc/RemoteServers/RemoteServer.cpp +++ b/Emulator/Misc/RemoteServers/RemoteServer.cpp @@ -80,6 +80,23 @@ RemoteServer::getOption(Option option) const } } +void +RemoteServer::checkOption(Option opt, i64 value) +{ + switch (opt) { + + case OPT_SRV_PORT: + case OPT_SRV_PROTOCOL: + case OPT_SRV_AUTORUN: + case OPT_SRV_VERBOSE: + + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + void RemoteServer::setOption(Option option, i64 value) { @@ -95,8 +112,6 @@ RemoteServer::setOption(Option option, i64 value) } else { - SUSPENDED - stop(); config.port = (u16)value; start(); diff --git a/Emulator/Misc/RemoteServers/RemoteServer.h b/Emulator/Misc/RemoteServers/RemoteServer.h index 3f07c9f80..1ad88fa83 100644 --- a/Emulator/Misc/RemoteServers/RemoteServer.h +++ b/Emulator/Misc/RemoteServers/RemoteServer.h @@ -121,6 +121,7 @@ class RemoteServer : public SubComponent { const ServerConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; diff --git a/Emulator/Peripherals/Drive/FloppyDrive.cpp b/Emulator/Peripherals/Drive/FloppyDrive.cpp index 30921b617..4d0fd3b27 100644 --- a/Emulator/Peripherals/Drive/FloppyDrive.cpp +++ b/Emulator/Peripherals/Drive/FloppyDrive.cpp @@ -111,6 +111,47 @@ FloppyDrive::getOption(Option option) const } } +void +FloppyDrive::checkOption(Option opt, i64 value) +{ + switch (opt) { + + case OPT_DRIVE_CONNECT: + + return; + + case OPT_DRIVE_TYPE: + + if (!FloppyDriveTypeEnum::isValid(value)) { + throw Error(ERROR_OPT_INV_ARG, FloppyDriveTypeEnum::keyList()); + } + if (value != DRIVE_DD_35 && value != DRIVE_HD_35) { + throw Error(ERROR_OPT_UNSUPPORTED); + } + return; + + case OPT_DRIVE_MECHANICS: + + if (!DriveMechanicsEnum::isValid(value)) { + throw Error(ERROR_OPT_INV_ARG, DriveMechanicsEnum::keyList()); + } + return; + + case OPT_DRIVE_RPM: + case OPT_DRIVE_SWAP_DELAY: + case OPT_DRIVE_PAN: + case OPT_DRIVE_STEP_VOLUME: + case OPT_DRIVE_POLL_VOLUME: + case OPT_DRIVE_EJECT_VOLUME: + case OPT_DRIVE_INSERT_VOLUME: + + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + void FloppyDrive::setOption(Option option, i64 value) { @@ -129,23 +170,12 @@ FloppyDrive::setOption(Option option, i64 value) break; case OPT_DRIVE_TYPE: - - if (!FloppyDriveTypeEnum::isValid(value)) { - throw Error(ERROR_OPT_INV_ARG, FloppyDriveTypeEnum::keyList()); - } - if (value != DRIVE_DD_35 && value != DRIVE_HD_35) { - throw Error(ERROR_OPT_UNSUPPORTED); - } - + config.type = (FloppyDriveType)value; break; case OPT_DRIVE_MECHANICS: - if (!DriveMechanicsEnum::isValid(value)) { - throw Error(ERROR_OPT_INV_ARG, DriveMechanicsEnum::keyList()); - } - config.mechanics = (DriveMechanics)value; break; diff --git a/Emulator/Peripherals/Drive/FloppyDrive.h b/Emulator/Peripherals/Drive/FloppyDrive.h index 7565fd4d8..15ee0d896 100644 --- a/Emulator/Peripherals/Drive/FloppyDrive.h +++ b/Emulator/Peripherals/Drive/FloppyDrive.h @@ -230,6 +230,7 @@ class FloppyDrive : public Drive, public Inspectable { const FloppyDriveConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; const std::filesystem::path &getSearchPath() const { return searchPath; } diff --git a/Emulator/Peripherals/Drive/HardDrive.cpp b/Emulator/Peripherals/Drive/HardDrive.cpp index efad95675..0d83e7d9d 100644 --- a/Emulator/Peripherals/Drive/HardDrive.cpp +++ b/Emulator/Peripherals/Drive/HardDrive.cpp @@ -266,6 +266,28 @@ HardDrive::getOption(Option option) const } } +void +HardDrive::checkOption(Option opt, i64 value) +{ + switch (opt) { + + case OPT_HDR_TYPE: + + if (!HardDriveTypeEnum::isValid(value)) { + throw Error(ERROR_OPT_INV_ARG, HardDriveTypeEnum::keyList()); + } + return; + + case OPT_HDR_PAN: + case OPT_HDR_STEP_VOLUME: + + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + void HardDrive::setOption(Option option, i64 value) { diff --git a/Emulator/Peripherals/Drive/HardDrive.h b/Emulator/Peripherals/Drive/HardDrive.h index 85c7f8838..26c5c5be5 100644 --- a/Emulator/Peripherals/Drive/HardDrive.h +++ b/Emulator/Peripherals/Drive/HardDrive.h @@ -269,6 +269,7 @@ class HardDrive : public Drive, public Inspectable { const HardDriveConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; private: diff --git a/Emulator/Peripherals/Joystick/Joystick.cpp b/Emulator/Peripherals/Joystick/Joystick.cpp index 3af631e96..f81e4007b 100644 --- a/Emulator/Peripherals/Joystick/Joystick.cpp +++ b/Emulator/Peripherals/Joystick/Joystick.cpp @@ -45,6 +45,23 @@ Joystick::getOption(Option option) const } } +void +Joystick::checkOption(Option opt, i64 value) +{ + switch (opt) { + + case OPT_JOY_AUTOFIRE: + case OPT_JOY_AUTOFIRE_BURSTS: + case OPT_JOY_AUTOFIRE_BULLETS: + case OPT_JOY_AUTOFIRE_DELAY: + + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + void Joystick::setOption(Option option, i64 value) { diff --git a/Emulator/Peripherals/Joystick/Joystick.h b/Emulator/Peripherals/Joystick/Joystick.h index 6dba69dd4..f97850c5c 100644 --- a/Emulator/Peripherals/Joystick/Joystick.h +++ b/Emulator/Peripherals/Joystick/Joystick.h @@ -148,6 +148,7 @@ class Joystick : public SubComponent, public Inspectable { const JoystickConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; diff --git a/Emulator/Peripherals/Keyboard/Keyboard.cpp b/Emulator/Peripherals/Keyboard/Keyboard.cpp index 23e1e277c..e7cb644e5 100644 --- a/Emulator/Peripherals/Keyboard/Keyboard.cpp +++ b/Emulator/Peripherals/Keyboard/Keyboard.cpp @@ -34,6 +34,20 @@ Keyboard::getOption(Option option) const } } +void +Keyboard::checkOption(Option opt, i64 value) +{ + switch (opt) { + + case OPT_KBD_ACCURACY: + + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + void Keyboard::setOption(Option option, i64 value) { diff --git a/Emulator/Peripherals/Keyboard/Keyboard.h b/Emulator/Peripherals/Keyboard/Keyboard.h index 6c8c8241a..ec062940f 100644 --- a/Emulator/Peripherals/Keyboard/Keyboard.h +++ b/Emulator/Peripherals/Keyboard/Keyboard.h @@ -126,6 +126,7 @@ class Keyboard : public SubComponent { const KeyboardConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; diff --git a/Emulator/Peripherals/Mouse/Mouse.cpp b/Emulator/Peripherals/Mouse/Mouse.cpp index 6a81d00f1..da124cda5 100644 --- a/Emulator/Peripherals/Mouse/Mouse.cpp +++ b/Emulator/Peripherals/Mouse/Mouse.cpp @@ -34,6 +34,28 @@ Mouse::getOption(Option option) const } } +void +Mouse::checkOption(Option opt, i64 value) +{ + switch (opt) { + + case OPT_MOUSE_PULLUP_RESISTORS: + case OPT_MOUSE_SHAKE_DETECTION: + + return; + + case OPT_MOUSE_VELOCITY: + + if (value < 0 || value > 255) { + throw Error(ERROR_OPT_INV_ARG, "0...255"); + } + return; + + default: + throw(ERROR_OPT_UNSUPPORTED); + } +} + void Mouse::setOption(Option option, i64 value) { @@ -51,9 +73,6 @@ Mouse::setOption(Option option, i64 value) case OPT_MOUSE_VELOCITY: - if (value < 0 || value > 255) { - throw Error(ERROR_OPT_INV_ARG, "0...255"); - } config.velocity = (isize)value; updateScalingFactors(); return; diff --git a/Emulator/Peripherals/Mouse/Mouse.h b/Emulator/Peripherals/Mouse/Mouse.h index c2a788164..56fca6924 100644 --- a/Emulator/Peripherals/Mouse/Mouse.h +++ b/Emulator/Peripherals/Mouse/Mouse.h @@ -190,6 +190,7 @@ class Mouse : public SubComponent { const MouseConfig &getConfig() const { return config; } const ConfigOptions &getOptions() const override { return options; } i64 getOption(Option option) const override; + void checkOption(Option opt, i64 value) override; void setOption(Option option, i64 value) override; private: