mirror of https://github.com/stella-emu/stella.git
Minor refactoring, slight speedup of passing data in sound code.
This commit is contained in:
parent
2a5eafd6fd
commit
025a1a7918
|
@ -261,11 +261,7 @@ void SoundSDL2::set(uInt16 addr, uInt8 value, Int32 cycle)
|
||||||
// the sound to "scale" correctly, we have to know the games real frame
|
// the sound to "scale" correctly, we have to know the games real frame
|
||||||
// rate (e.g., 50 or 60) and the currently emulated frame rate. We use these
|
// rate (e.g., 50 or 60) and the currently emulated frame rate. We use these
|
||||||
// values to "scale" the time before the register change occurs.
|
// values to "scale" the time before the register change occurs.
|
||||||
RegWrite info;
|
myRegWriteQueue.enqueue(addr, value, delta);
|
||||||
info.addr = addr;
|
|
||||||
info.value = value;
|
|
||||||
info.delta = delta;
|
|
||||||
myRegWriteQueue.enqueue(info);
|
|
||||||
|
|
||||||
// Update last cycle counter to the current cycle
|
// Update last cycle counter to the current cycle
|
||||||
myLastRegisterSetCycle = cycle;
|
myLastRegisterSetCycle = cycle;
|
||||||
|
@ -476,14 +472,17 @@ double SoundSDL2::RegWriteQueue::duration() const
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void SoundSDL2::RegWriteQueue::enqueue(const RegWrite& info)
|
void SoundSDL2::RegWriteQueue::enqueue(uInt16 addr, uInt8 value, double delta)
|
||||||
{
|
{
|
||||||
// If an attempt is made to enqueue more than the queue can hold then
|
// If an attempt is made to enqueue more than the queue can hold then
|
||||||
// we'll enlarge the queue's capacity.
|
// we'll enlarge the queue's capacity.
|
||||||
if(mySize == myCapacity)
|
if(mySize == myCapacity)
|
||||||
grow();
|
grow();
|
||||||
|
|
||||||
myBuffer[myTail] = info;
|
RegWrite& reg = myBuffer[myTail];
|
||||||
|
reg.addr = addr;
|
||||||
|
reg.value = value;
|
||||||
|
reg.delta = delta;
|
||||||
myTail = (myTail + 1) % myCapacity;
|
myTail = (myTail + 1) % myCapacity;
|
||||||
++mySize;
|
++mySize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,6 +174,9 @@ class SoundSDL2 : public Sound
|
||||||
uInt16 addr;
|
uInt16 addr;
|
||||||
uInt8 value;
|
uInt8 value;
|
||||||
double delta;
|
double delta;
|
||||||
|
|
||||||
|
RegWrite(uInt16 a = 0, uInt8 v = 0, double d = 0.0)
|
||||||
|
: addr(a), value(v), delta(d) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -209,7 +212,7 @@ class SoundSDL2 : public Sound
|
||||||
/**
|
/**
|
||||||
Enqueue the specified object.
|
Enqueue the specified object.
|
||||||
*/
|
*/
|
||||||
void enqueue(const RegWrite& info);
|
void enqueue(uInt16 addr, uInt8 value, double delta);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return the item at the front on the queue.
|
Return the item at the front on the queue.
|
||||||
|
|
|
@ -41,7 +41,7 @@ class DiStella
|
||||||
// A list of options that can be applied to the disassembly
|
// A list of options that can be applied to the disassembly
|
||||||
// This will eventually grow to include all options supported by
|
// This will eventually grow to include all options supported by
|
||||||
// standalone Distella
|
// standalone Distella
|
||||||
struct Settings{
|
struct Settings {
|
||||||
Common::Base::Format gfx_format;
|
Common::Base::Format gfx_format;
|
||||||
bool resolve_code; // Attempt to detect code vs. data sections
|
bool resolve_code; // Attempt to detect code vs. data sections
|
||||||
bool show_addresses; // Show PC addresses (always off for external output)
|
bool show_addresses; // Show PC addresses (always off for external output)
|
||||||
|
|
|
@ -295,7 +295,7 @@ void Settings::validate()
|
||||||
|
|
||||||
#ifdef SOUND_SUPPORT
|
#ifdef SOUND_SUPPORT
|
||||||
i = getInt("volume");
|
i = getInt("volume");
|
||||||
if(i < 0 || i > 100) setInternal("volume", "100");
|
if(i < 0 || i > 100) setInternal("volume", "100");
|
||||||
i = getInt("freq");
|
i = getInt("freq");
|
||||||
if(!(i == 11025 || i == 22050 || i == 31400 || i == 44100 || i == 48000))
|
if(!(i == 11025 || i == 22050 || i == 31400 || i == 44100 || i == 48000))
|
||||||
setInternal("freq", "31400");
|
setInternal("freq", "31400");
|
||||||
|
@ -622,9 +622,7 @@ int Settings::setInternal(const string& key, const Variant& value,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Setting setting;
|
Setting setting(key, value);
|
||||||
setting.key = key;
|
|
||||||
setting.value = value;
|
|
||||||
if(useAsInitial) setting.initialValue = value;
|
if(useAsInitial) setting.initialValue = value;
|
||||||
|
|
||||||
myInternalSettings.push_back(setting);
|
myInternalSettings.push_back(setting);
|
||||||
|
@ -676,9 +674,7 @@ int Settings::setExternal(const string& key, const Variant& value,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Setting setting;
|
Setting setting(key, value);
|
||||||
setting.key = key;
|
|
||||||
setting.value = value;
|
|
||||||
if(useAsInitial) setting.initialValue = value;
|
if(useAsInitial) setting.initialValue = value;
|
||||||
|
|
||||||
myExternalSettings.push_back(setting);
|
myExternalSettings.push_back(setting);
|
||||||
|
|
|
@ -115,6 +115,9 @@ class Settings
|
||||||
string key;
|
string key;
|
||||||
Variant value;
|
Variant value;
|
||||||
Variant initialValue;
|
Variant initialValue;
|
||||||
|
|
||||||
|
Setting(const string& k, const Variant& v, const Variant& i = EmptyVariant)
|
||||||
|
: key(k), value(v), initialValue(i) { }
|
||||||
};
|
};
|
||||||
using SettingsArray = vector<Setting>;
|
using SettingsArray = vector<Setting>;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue