From 372efa11f12a3d133982cc31d4a9ba2727eeebfc Mon Sep 17 00:00:00 2001 From: shygoo Date: Sat, 19 Aug 2017 14:35:38 -0500 Subject: [PATCH] Fix #1358 debugger code edit instability --- Source/Project64/N64System/Debugger/Assembler.cpp | 15 ++++++++++++++- .../N64System/Debugger/Debugger-Commands.cpp | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Source/Project64/N64System/Debugger/Assembler.cpp b/Source/Project64/N64System/Debugger/Assembler.cpp index 4a399a3ec..be15899c9 100644 --- a/Source/Project64/N64System/Debugger/Assembler.cpp +++ b/Source/Project64/N64System/Debugger/Assembler.cpp @@ -11,7 +11,7 @@ REGISTER* lookup_register(char* name); -static int parse_error = 0; +static ParseError parse_error = ERR_NONE; static uint32_t m_Address = 0x00000000; void to_lower(char* str) @@ -51,6 +51,12 @@ uint32_t pop_val() { char* v = strtok(NULL, " \t,()"); + if (v == NULL) + { + parse_error = ERR_EXPECTED_VAL; + return 0; + } + if (isalpha(*v)) { // todo lookup label value @@ -306,6 +312,8 @@ REGISTER* lookup_register(char* name) bool CAssembler::AssembleLine(char* line, uint32_t* opcode, uint32_t address) { + parse_error = ERR_NONE; + m_Address = address; char line_c[128]; strncpy(line_c, line, 128); @@ -338,6 +346,11 @@ bool CAssembler::AssembleLine(char* line, uint32_t* opcode, uint32_t address) for (int i = 0; instruction->syntax[i]; i++) { instruction->syntax[i](opcode); + + if (parse_error != ERR_NONE) + { + return false; + } } return true; } \ No newline at end of file diff --git a/Source/Project64/N64System/Debugger/Debugger-Commands.cpp b/Source/Project64/N64System/Debugger/Debugger-Commands.cpp index 261c7cc4b..70085ecbc 100644 --- a/Source/Project64/N64System/Debugger/Debugger-Commands.cpp +++ b/Source/Project64/N64System/Debugger/Debugger-Commands.cpp @@ -202,11 +202,11 @@ LRESULT CDebugCommandsView::OnOpKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, int textLen = m_OpEdit.GetWindowTextLengthA(); char text[256]; m_OpEdit.GetWindowTextA(text, 255); - m_OpEdit.SetWindowTextA(""); uint32_t op; bool bValid = CAssembler::AssembleLine(text, &op, m_SelectedAddress); if (bValid) { + m_OpEdit.SetWindowTextA(""); EditOp(m_SelectedAddress, op); m_SelectedAddress += 4; BeginOpEdit(m_SelectedAddress);