diff --git a/Chip8/Chip8.cpp b/Chip8/Chip8.cpp index 3ee5b26..95c143d 100644 --- a/Chip8/Chip8.cpp +++ b/Chip8/Chip8.cpp @@ -49,6 +49,7 @@ void Chip8::Reset() for (int i = 0; i < 16 * 5; i++) ram[i] = charMem[i]; for (int i = 0; i < 16; i++) inputs[i] = false; gpu.Clear(); + gpu.Update(); apu.SetBeeping(false); running = false; waitingForKeypress = false; @@ -338,8 +339,8 @@ void Chip8::Update() } catch (const Exception& e) { - MessageWindow::Error(e.GetMsg()); running = false; + throw e; } gpu.Update(); diff --git a/Config.cpp b/Config.cpp index 2b739ce..c2d928a 100644 --- a/Config.cpp +++ b/Config.cpp @@ -42,9 +42,9 @@ bool Config::tryGetValue(const List& input, const String& name, int& val for (int i = 0; i < input.Count(); i++) { auto parts = input[i].Split(':'); - if (parts.Count() == 2 && parts[0] == name) + if (parts.Count() == 2 && parts[0].Trim() == name) { - if (parts[1].TryParseInt(value)) return true; + if (parts[1].Trim().TryParseInt(value)) return true; } } return false; diff --git a/Main.cpp b/Main.cpp index 21aa34e..81172e1 100644 --- a/Main.cpp +++ b/Main.cpp @@ -15,13 +15,7 @@ int Main(const List& arguments) Config config(Directory::GetApplicationDirectory() + "\\config.cfg"); auto window = Window::Create("Vip8"); - Key keys[] = - { - Key::Number1, Key::Number2, Key::Number3, Key::Number4, - Key::Q, Key::W, Key::E, Key::R, - Key::A, Key::S, Key::D, Key::F, - Key::Z, Key::X, Key::C, Key::V - }; + Key keys[] = { Key::X, Key::Number1, Key::Number2, Key::Number3, Key::Q, Key::W, Key::E, Key::A, Key::S, Key::D, Key::Z, Key::C, Key::Number4, Key::R, Key::F, Key::V }; window->KeyDown += [&] (Key key) { if (key == Key::Escape) @@ -199,7 +193,14 @@ int Main(const List& arguments) while (running) { - chip8.Update(); + try + { + chip8.Update(); + } + catch (const Exception& e) + { + MessageWindow::Error(window, "Emulation error: " + e.GetMsg()); + } window->Update(); }