Cleaned up the double handling of the options variables.

This commit is contained in:
Stephen White 2018-06-03 17:54:36 +10:00
parent 457cbafade
commit fdac3079dd
3 changed files with 73 additions and 177 deletions

View file

@ -88,19 +88,7 @@ Options options;
const char* fileBrowserSelectedName;
u8 deviceID = 8;
IEC_Commands m_IEC_Commands;
bool onResetChangeToStartingFolder = false;
bool extraRAM = false;
bool enableRAMBOard = false;
bool disableSD2IECCommands = false;
bool supportUARTInput = false;
bool graphIEC = false;
bool quickBoot = false;
bool displayPNGIcons = false;
bool soundOnGPIO = false;
bool invertIECInputs = false;
bool invertIECOutputs = true;
bool splitIECLines = false;
bool ignoreReset = false;
unsigned int screenWidth = 1024;
unsigned int screenHeight = 768;
@ -209,7 +197,7 @@ u8 read6502(u16 address)
switch (address & 0xe000) // keep bits 15,14,13
{
case 0x8000: // 0x8000-0x9fff
if (enableRAMBOard) {
if (options.GetRAMBOard()) {
value = s_u8Memory[address]; // 74LS42 outputs low on pin 1 or pin 2
break;
}
@ -287,7 +275,7 @@ void write6502(u16 address, const u8 value)
switch (address & 0xe000) // keep bits 15,14,13
{
case 0x8000: // 0x8000-0x9fff
if (enableRAMBOard) {
if (options.GetRAMBOard()) {
s_u8Memory[address] = value; // 74LS42 outputs low on pin 1 or pin 2
break;
}
@ -424,7 +412,7 @@ void UpdateScreen()
}
value = IEC_Bus::GetPI_Atn();
if (graphIEC)
if (options.GraphIEC())
{
bottom = top2 - 2;
if (value ^ oldATN)
@ -447,7 +435,7 @@ void UpdateScreen()
}
value = IEC_Bus::GetPI_Data();
if (graphIEC)
if (options.GraphIEC())
{
bottom = top - 2;
if (value ^ oldDATA)
@ -470,7 +458,7 @@ void UpdateScreen()
}
value = IEC_Bus::GetPI_Clock();
if (graphIEC)
if (options.GraphIEC())
{
bottom = screenHeight - 1;
if (value ^ oldCLOCK)
@ -583,7 +571,7 @@ void emulator()
roms.lastManualSelectedROMIndex = 0;
diskCaddy.SetScreen(&screen);
fileBrowser = new FileBrowser(&diskCaddy, &roms, deviceID, displayPNGIcons);
fileBrowser = new FileBrowser(&diskCaddy, &roms, deviceID, options.DisplayPNGIcons());
fileBrowser->DisplayRoot();
pi1541.Initialise();
@ -603,7 +591,7 @@ void emulator()
fileBrowser->ClearSelections();
// Go back to the root folder so you can load fb* again?
if ((resetWhileEmulating && onResetChangeToStartingFolder) || selectedViaIECCommands) fileBrowser->DisplayRoot(); // Go back to the root folder and display it.
if ((resetWhileEmulating && options.GetOnResetChangeToStartingFolder()) || selectedViaIECCommands) fileBrowser->DisplayRoot(); // Go back to the root folder and display it.
else fileBrowser->RefeshDisplay(); // Just redisplay the current folder.
resetWhileEmulating = false;
@ -613,7 +601,7 @@ void emulator()
fileBrowser->ShowDeviceAndROM();
if (!disableSD2IECCommands)
if (!options.GetDisableSD2IECCommands())
{
m_IEC_Commands.SimulateIECBegin();
@ -624,7 +612,7 @@ void emulator()
switch (updateAction)
{
case IEC_Commands::RESET:
if (onResetChangeToStartingFolder)
if (options.GetOnResetChangeToStartingFolder())
fileBrowser->DisplayRoot();
IEC_Bus::Reset();
m_IEC_Commands.SimulateIECBegin();
@ -734,6 +722,7 @@ void emulator()
inputMappings->directDiskSwapRequest = 0;
bool extraRAM = options.GetExtraRAM();
DataBusReadFn dataBusRead = extraRAM ? read6502ExtraRAM : read6502;
DataBusWriteFn dataBusWrite = extraRAM ? write6502ExtraRAM : write6502;
pi1541.m6502.SetBusFunctions(dataBusRead, dataBusWrite);
@ -797,7 +786,7 @@ void emulator()
if (headDir ^ oldHeadDir) // Need to start a new sound?
{
oldHeadDir = headDir;
if (soundOnGPIO)
if (options.SoundOnGPIO())
{
headSoundCounter = 1000000;
headSoundFreqCounter = headSoundFreq;
@ -808,7 +797,7 @@ void emulator()
}
}
if (soundOnGPIO && headSoundCounter > 0)
if (options.SoundOnGPIO() && headSoundCounter > 0)
{
headSoundFreqCounter--; // Continue updating a GPIO non DMA sound.
if (headSoundFreqCounter <= 0)
@ -869,7 +858,7 @@ void emulator()
IEC_Bus::WaitUntilReset();
//DEBUG_LOG("6502 resetting\r\n");
if (onResetChangeToStartingFolder || selectedViaIECCommands)
if (options.GetOnResetChangeToStartingFolder() || selectedViaIECCommands)
fileBrowser->DisplayRoot();//m_IEC_Commands.ChangeToRoot(); // TO CHECK
emulating = false;
resetWhileEmulating = true;
@ -1005,43 +994,20 @@ static void CheckOptions()
deviceID = (u8)options.GetDeviceID();
DEBUG_LOG("DeviceID = %d\r\n", deviceID);
onResetChangeToStartingFolder = options.GetOnResetChangeToStartingFolder() != 0;
DEBUG_LOG("onResetChangeToStartingFolder = %d\r\n", onResetChangeToStartingFolder);
extraRAM = options.GetExtraRAM() != 0;
DEBUG_LOG("extraRAM = %d\r\n", extraRAM);
enableRAMBOard = options.GetRAMBOard() != 0;
DEBUG_LOG("RAMBOard = %d\r\n", enableRAMBOard);
disableSD2IECCommands = options.GetDisableSD2IECCommands();
//supportUARTInput = options.GetSupportUARTInput() != 0;
graphIEC = options.GraphIEC();
quickBoot = options.QuickBoot();
displayPNGIcons = options.DisplayPNGIcons();
soundOnGPIO = options.SoundOnGPIO();
invertIECInputs = options.InvertIECInputs();
invertIECOutputs = options.InvertIECOutputs();
splitIECLines = options.SplitIECLines();
if (!splitIECLines)
invertIECInputs = false;
ignoreReset = options.IgnoreReset();
// print confirmation of parsed options
if (0) {
screen.Clear(COLOUR_BLACK);
int y_pos = 200;
snprintf(tempBuffer, tempBufferSize, "ignoreReset = %d\r\n", ignoreReset);
snprintf(tempBuffer, tempBufferSize, "ignoreReset = %d\r\n", options.IgnoreReset());
screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK);
snprintf(tempBuffer, tempBufferSize, "RAMBOard = %d\r\n", enableRAMBOard);
snprintf(tempBuffer, tempBufferSize, "RAMBOard = %d\r\n", options.GetRAMBOard());
screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK);
snprintf(tempBuffer, tempBufferSize, "splitIECLines = %d\r\n", splitIECLines);
snprintf(tempBuffer, tempBufferSize, "splitIECLines = %d\r\n", options.SplitIECLines());
screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK);
snprintf(tempBuffer, tempBufferSize, "invertIECInputs = %d\r\n", invertIECInputs);
snprintf(tempBuffer, tempBufferSize, "invertIECInputs = %d\r\n", options.InvertIECInputs());
screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK);
snprintf(tempBuffer, tempBufferSize, "invertIECOutputs = %d\r\n", invertIECOutputs);
snprintf(tempBuffer, tempBufferSize, "invertIECOutputs = %d\r\n", options.InvertIECOutputs());
screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK);
IEC_Bus::WaitMicroSeconds(5 * 1000000);
}
@ -1154,7 +1120,7 @@ extern "C"
screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK);
if (!quickBoot)
if (!options.QuickBoot())
IEC_Bus::WaitMicroSeconds(3 * 1000000);
InterruptSystemInitialize();
@ -1176,16 +1142,15 @@ extern "C"
InputMappings::Instance();
//USPiMouseRegisterStatusHandler(MouseHandler);
onResetChangeToStartingFolder = false;
CheckOptions();
IEC_Bus::SetSplitIECLines(splitIECLines);
IEC_Bus::SetInvertIECInputs(invertIECInputs);
IEC_Bus::SetInvertIECOutputs(invertIECOutputs);
IEC_Bus::SetIgnoreReset(ignoreReset);
IEC_Bus::SetSplitIECLines(options.SplitIECLines());
IEC_Bus::SetInvertIECInputs(options.InvertIECInputs());
IEC_Bus::SetInvertIECOutputs(options.InvertIECOutputs());
IEC_Bus::SetIgnoreReset(options.IgnoreReset());
if (!soundOnGPIO)
if (!options.SoundOnGPIO())
{
dmaSound = (u32*)malloc(Sample_bin_size * 4);
for (int i = 0; i < Sample_bin_size; ++i)

View file

@ -122,7 +122,7 @@ Options::Options(void)
, deviceID(8)
, onResetChangeToStartingFolder(0)
, extraRAM(0)
, enableRAMBOard(0)
, RAMBOard(0)
, disableSD2IECCommands(0)
, supportUARTInput(0)
, graphIEC(0)
@ -148,6 +148,14 @@ Options::Options(void)
ROMNameSlot8[0] = 0;
}
#define ELSE_CHECK_DECIMAL_OPTION(Name) \
else if (strcasecmp(pOption, #Name) == 0) \
{ \
unsigned nValue = 0; \
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE) \
Name = nValue; \
}
void Options::Process(char* buffer)
{
SetData(buffer);
@ -158,106 +166,26 @@ void Options::Process(char* buffer)
/*char* equals = */GetToken();
char* pValue = GetToken();
if (strcasecmp(pOption, "deviceID") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
deviceID = nValue;
}
else if (strcasecmp(pOption, "OnResetChangeToStartingFolder") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
onResetChangeToStartingFolder = nValue;
}
else if (strcasecmp(pOption, "ExtraRAM") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
extraRAM = nValue;
}
else if (strcasecmp(pOption, "RAMBOard") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
enableRAMBOard = nValue;
}
else if (strcasecmp(pOption, "DisableSD2IECCommands") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
disableSD2IECCommands = nValue;
}
else if (strcasecmp(pOption, "SupportUARTInput") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
supportUARTInput = nValue;
}
else if (strcasecmp(pOption, "GraphIEC") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
graphIEC = nValue;
}
else if (strcasecmp(pOption, "QuickBoot") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
quickBoot = nValue;
}
else if (strcasecmp(pOption, "DisplayPNGIcons") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
displayPNGIcons = nValue;
}
else if (strcasecmp(pOption, "soundOnGPIO") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
soundOnGPIO = nValue;
}
else if (strcasecmp(pOption, "invertIECInputs") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
invertIECInputs = nValue;
}
else if (strcasecmp(pOption, "invertIECOutputs") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
invertIECOutputs = nValue;
}
else if (strcasecmp(pOption, "splitIECLines") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
splitIECLines = nValue;
}
else if (strcasecmp(pOption, "ignoreReset") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
ignoreReset = nValue;
}
else if (strcasecmp(pOption, "screenWidth") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
screenWidth = nValue;
}
else if (strcasecmp(pOption, "screenHeight") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
screenHeight = nValue;
}
else if ((strcasecmp(pOption, "Font") == 0))
if ((strcasecmp(pOption, "Font") == 0))
{
strncpy(ROMFontName, pValue, 255);
}
ELSE_CHECK_DECIMAL_OPTION(deviceID)
ELSE_CHECK_DECIMAL_OPTION(onResetChangeToStartingFolder)
ELSE_CHECK_DECIMAL_OPTION(extraRAM)
ELSE_CHECK_DECIMAL_OPTION(RAMBOard)
ELSE_CHECK_DECIMAL_OPTION(disableSD2IECCommands)
ELSE_CHECK_DECIMAL_OPTION(supportUARTInput)
ELSE_CHECK_DECIMAL_OPTION(graphIEC)
ELSE_CHECK_DECIMAL_OPTION(quickBoot)
ELSE_CHECK_DECIMAL_OPTION(displayPNGIcons)
ELSE_CHECK_DECIMAL_OPTION(soundOnGPIO)
ELSE_CHECK_DECIMAL_OPTION(invertIECInputs)
ELSE_CHECK_DECIMAL_OPTION(invertIECOutputs)
ELSE_CHECK_DECIMAL_OPTION(splitIECLines)
ELSE_CHECK_DECIMAL_OPTION(ignoreReset)
ELSE_CHECK_DECIMAL_OPTION(screenWidth)
ELSE_CHECK_DECIMAL_OPTION(screenHeight)
else if ((strcasecmp(pOption, "StarFileName") == 0))
{
strncpy(starFileName, pValue, 255);
@ -295,6 +223,9 @@ void Options::Process(char* buffer)
strncpy(ROMNameSlot8, pValue, 255);
}
}
if (!SplitIECLines())
invertIECInputs = false;
}
unsigned Options::GetDecimal(char* pString)

View file

@ -44,27 +44,27 @@ public:
void Process(char* buffer);
unsigned int GetDeviceID() const { return deviceID; }
unsigned int GetOnResetChangeToStartingFolder() const { return onResetChangeToStartingFolder; }
const char* GetRomFontName() const { return ROMFontName; }
inline unsigned int GetDeviceID() const { return deviceID; }
inline unsigned int GetOnResetChangeToStartingFolder() const { return onResetChangeToStartingFolder; }
inline const char* GetRomFontName() const { return ROMFontName; }
const char* GetRomName(int index) const;
const char* GetStarFileName() const { return starFileName; }
unsigned int GetExtraRAM() const { return extraRAM; }
unsigned int GetRAMBOard() const { return enableRAMBOard; }
unsigned int GetDisableSD2IECCommands() const { return disableSD2IECCommands; }
unsigned int GetSupportUARTInput() const { return supportUARTInput; }
inline const char* GetStarFileName() const { return starFileName; }
inline unsigned int GetExtraRAM() const { return extraRAM; }
inline unsigned int GetRAMBOard() const { return RAMBOard; }
inline unsigned int GetDisableSD2IECCommands() const { return disableSD2IECCommands; }
inline unsigned int GetSupportUARTInput() const { return supportUARTInput; }
unsigned int GraphIEC() const { return graphIEC; }
unsigned int QuickBoot() const { return quickBoot; }
unsigned int DisplayPNGIcons() const { return displayPNGIcons; }
unsigned int SoundOnGPIO() const { return soundOnGPIO; }
unsigned int SplitIECLines() const { return splitIECLines; }
unsigned int InvertIECInputs() const { return invertIECInputs; }
unsigned int InvertIECOutputs() const { return invertIECOutputs; }
unsigned int IgnoreReset() const { return ignoreReset; }
inline unsigned int GraphIEC() const { return graphIEC; }
inline unsigned int QuickBoot() const { return quickBoot; }
inline unsigned int DisplayPNGIcons() const { return displayPNGIcons; }
inline unsigned int SoundOnGPIO() const { return soundOnGPIO; }
inline unsigned int SplitIECLines() const { return splitIECLines; }
inline unsigned int InvertIECInputs() const { return invertIECInputs; }
inline unsigned int InvertIECOutputs() const { return invertIECOutputs; }
inline unsigned int IgnoreReset() const { return ignoreReset; }
unsigned int ScreenWidth() const { return screenWidth; }
unsigned int ScreenHeight() const { return screenHeight; }
inline unsigned int ScreenWidth() const { return screenWidth; }
inline unsigned int ScreenHeight() const { return screenHeight; }
static unsigned GetDecimal(char* pString);
@ -72,7 +72,7 @@ private:
unsigned int deviceID;
unsigned int onResetChangeToStartingFolder;
unsigned int extraRAM;
unsigned int enableRAMBOard;
unsigned int RAMBOard;
unsigned int disableSD2IECCommands;
unsigned int supportUARTInput;
unsigned int graphIEC;