Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Aug 1, 2024
1 parent f29e5ed commit f4bb769
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Emulator/Base/Configurable.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Configurable
virtual i64 getOption(Option opt) const { return 0; }

// Gets the fallback for a config option
virtual i64 getFallback(Option opt) const { return 0; }
virtual i64 getFallback(Option opt) const = 0;

// Throws an exception of if the given option/value pair is invalid
virtual void checkOption(Option opt, i64 value) { }
Expand Down
6 changes: 6 additions & 0 deletions Emulator/Base/CoreComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ CoreComponent::routeOption(Option opt, isize objid)
return nullptr;
}

i64
CoreComponent::getFallback(Option opt) const
{
return emulator.defaults.get(opt);
}

void
CoreComponent::initialize()
{
Expand Down
23 changes: 13 additions & 10 deletions Emulator/Base/CoreComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include "CoreComponentTypes.h"
#include "EmulatorTypes.h"
#include "ThreadTypes.h"
#include "CoreObject.h"
#include "Inspectable.h"
#include "Synchronizable.h"
Expand Down Expand Up @@ -119,6 +118,9 @@ public CoreObject, public Serializable, public Suspendable, public Synchronizabl
// Returns the target component for a given configuration option
Configurable *routeOption(Option opt, isize objid);

// Returns the fallback value for a config option
i64 getFallback(Option opt) const override;


//
// Controlling the state
Expand All @@ -127,7 +129,6 @@ public CoreObject, public Serializable, public Suspendable, public Synchronizabl
public:

void initialize();
void reset(bool hard);
void powerOn();
void powerOff();
void run();
Expand All @@ -140,23 +141,18 @@ public CoreObject, public Serializable, public Suspendable, public Synchronizabl
void focus();
void unfocus();

void hardReset() { reset(true); }
void softReset() { reset(false); }

void powerOnOff(bool value) { value ? powerOn() : powerOff(); }
void warpOnOff(bool value) { value ? warpOn() : warpOff(); }
void trackOnOff(bool value) { value ? trackOn() : trackOff(); }


//
// Processing state changes
// Performing state changes
//

private:

virtual void _initialize() { }
virtual void _willReset(bool hard) { }
virtual void _didReset(bool hard) { }
virtual void _isReady() const throws { }
virtual void _powerOn() { }
virtual void _powerOff() { }
Expand All @@ -180,13 +176,20 @@ public CoreObject, public Serializable, public Suspendable, public Synchronizabl
// Returns the size of the internal state in bytes
isize size();

// Resets the internal state
void hardReset() { reset(true); }
void softReset() { reset(false); }
void reset(bool hard);
virtual void _willReset(bool hard) { }
virtual void _didReset(bool hard) { }

// Loads the internal state from a memory buffer
virtual isize load(const u8 *buf) throws;
virtual void _didLoad() { };
virtual void _didLoad() { }

// Saves the internal state to a memory buffer
virtual isize save(u8 *buf);
virtual void _didSave() { };
virtual void _didSave() { }


//
Expand Down
1 change: 1 addition & 0 deletions Emulator/Components/EmulatorTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#pragma once

#include "Reflection.h"
#include "ThreadTypes.h"
#include "AmigaTypes.h"

// namespace vamiga {
Expand Down

0 comments on commit f4bb769

Please sign in to comment.