From 5b091e9b8c8010ce6fc05b9ec51be0cb25e1e5a0 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Sat, 25 Aug 2018 11:43:23 +1000 Subject: [PATCH] options.txt numbers can now be decimal, hex (and probably octal) reboot clears LCD on the way down --- src/InputMappings.cpp | 6 +++--- src/iec_commands.cpp | 6 ++---- src/main.cpp | 7 +++++++ src/options.cpp | 21 ++------------------- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/InputMappings.cpp b/src/InputMappings.cpp index 89b9e5e..1c27c70 100644 --- a/src/InputMappings.cpp +++ b/src/InputMappings.cpp @@ -23,8 +23,8 @@ extern "C" { #include "rpi-aux.h" -extern void reboot_now(void); } +extern void Reboot_Pi(void); // If disk swaps can be done via multiple cores then directDiskSwapRequest needs to be volatile. WARNING: volatile acesses can be very expensive. //volatile unsigned InputMappings::directDiskSwapRequest = 0; @@ -204,7 +204,7 @@ bool InputMappings::CheckKeyboardBrowseMode() } if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() ) - reboot_now(); + Reboot_Pi(); if (keyboard->KeyHeld(KEY_ESC)) SetKeyboardFlag(ESC_FLAG); @@ -295,7 +295,7 @@ void InputMappings::CheckKeyboardEmulationMode(unsigned numberOfImages, unsigned return; if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() ) - reboot_now(); + Reboot_Pi(); if (keyboard->KeyHeld(KEY_ESC)) SetKeyboardFlag(ESC_FLAG); diff --git a/src/iec_commands.cpp b/src/iec_commands.cpp index d737dcc..5da76c2 100644 --- a/src/iec_commands.cpp +++ b/src/iec_commands.cpp @@ -47,9 +47,7 @@ extern unsigned versionMajor; extern unsigned versionMinor; -extern "C" { - extern void reboot_now(void); -} +extern void Reboot_Pi(); #define WaitWhile(checkStatus) \ do\ @@ -1232,7 +1230,7 @@ void IEC_Commands::User(void) break; case 202: // Really hard reset - reboot Pi - reboot_now(); + Reboot_Pi(); break; case '0': //OPEN1,8,15,"U0>"+CHR$(9):CLOSE1 diff --git a/src/main.cpp b/src/main.cpp index adc0eae..fdcc27b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1291,6 +1291,13 @@ static void CheckOptions() } } +void Reboot_Pi() +{ + if (screenLCD) + screenLCD->ClearInit(0); + reboot_now(); +} + extern "C" { void kernel_main(unsigned int r0, unsigned int r1, unsigned int atags) diff --git a/src/options.cpp b/src/options.cpp index 6f30db7..7ba71f1 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -299,26 +299,9 @@ void Options::Process(char* buffer) unsigned Options::GetDecimal(char* pString) { if (pString == 0 || *pString == '\0') - return INVALID_VALUE; + return 0; - unsigned nResult = 0; - - char chChar = *pString++; - while (chChar != '\0' && chChar != 13) - { - if (!('0' <= chChar && chChar <= '9')) - return INVALID_VALUE; - - unsigned nPrevResult = nResult; - - nResult = nResult * 10 + (chChar - '0'); - if (nResult < nPrevResult || nResult == INVALID_VALUE) - return INVALID_VALUE; - - chChar = *pString++; - } - - return nResult; + return strtol(pString, NULL, 0); } float Options::GetFloat(char* pString)