Skip to content

Commit

Permalink
Added checkOption() to all components
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Jul 29, 2024
1 parent 6b5a924 commit 361f524
Show file tree
Hide file tree
Showing 45 changed files with 611 additions and 177 deletions.
1 change: 1 addition & 0 deletions Emulator/Base/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 19 additions & 2 deletions Emulator/Components/Agnus/Agnus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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) {

Expand Down
1 change: 1 addition & 0 deletions Emulator/Components/Agnus/Agnus.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ class Agnus : public SubComponent, public Inspectable<AgnusInfo, AgnusStats> {
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);
Expand Down
9 changes: 0 additions & 9 deletions Emulator/Components/Agnus/AgnusEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <SLOT_REG> (DMA_CYCLES(1), REG_CHANGE);
break;
*/

case DAS_EOL:

assert(pos.h == HPOS_MAX_PAL || pos.h == HPOS_MAX_NTSC);
Expand Down
24 changes: 18 additions & 6 deletions Emulator/Components/Agnus/Blitter/Blitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions Emulator/Components/Agnus/Blitter/Blitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ class Blitter : public SubComponent, public Inspectable<BlitterInfo>
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;


Expand Down
45 changes: 41 additions & 4 deletions Emulator/Components/Agnus/DmaDebugger/DmaDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;

Expand Down
1 change: 1 addition & 0 deletions Emulator/Components/Agnus/DmaDebugger/DmaDebugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class DmaDebugger : public SubComponent, public Inspectable<DmaDebuggerInfo> {
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:
Expand Down
29 changes: 15 additions & 14 deletions Emulator/Components/Amiga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;

Expand All @@ -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;

Expand Down
35 changes: 27 additions & 8 deletions Emulator/Components/CIA/CIA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,46 @@ 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;
}
}

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;

Expand Down
1 change: 1 addition & 0 deletions Emulator/Components/CIA/CIA.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ class CIA : public SubComponent, public Inspectable<CIAInfo, CIAStats> {
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;


Expand Down
Loading

0 comments on commit 361f524

Please sign in to comment.