/** ComplxFrame * * Constructor */ ComplxFrame::ComplxFrame(const ComplxFrame::Options& opts) : ComplxFrameDecl(NULL, wxID_ANY, opts.title, wxDefaultPosition, wxSize(opts.width, opts.height)), console(NULL), memoryView(NULL), base_title(opts.title) { InitImages(); menuViewInstructionHighlighting->Check(opts.highlight); menuViewBasic->Check(opts.disassemble == 0); menuViewNormal->Check(opts.disassemble == 1); menuViewHighLevel->Check(opts.disassemble == 2); this->stack_size = opts.stack_size; this->call_stack_size = opts.call_stack_size; DoLoadFile(opts.loading_options); memoryView = new MemoryView(); memory->SetView(memoryView, opts.exact_column_sizing, opts.column_sizes); memory->SetDisassembleLevel(opts.disassemble); memory->SetUnsignedMode(false); memory->SetHighlight(opts.highlight); int widths[5] = {-6, -2, -2, -2, -2}; int styles[5] = {wxSB_NORMAL, wxSB_NORMAL, wxSB_NORMAL, wxSB_NORMAL, wxSB_NORMAL}; statusBar->SetStatusWidths(5, widths); statusBar->SetStatusStyles(5, styles); UpdateMemory(); UpdateStatus(); Connect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_COMPLETED, wxThreadEventHandler(ComplxFrame::OnRunComplete)); Connect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_IO, wxThreadEventHandler(ComplxFrame::OnIo)); Connect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_NOIO, wxThreadEventHandler(ComplxFrame::OnNoIo)); Connect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_OUTPUT, wxThreadEventHandler(ComplxFrame::OnOutput)); }
void GarbageTestCase::LoadGarbage() { srand(1234); wxInitAllImageHandlers(); for (size_t size = 1; size < GARBAGE_DATA_SIZE; size *= size+1) { // first, generate some garbage data unsigned char *data = new unsigned char[size]; for (size_t i = 0; i < size; i++) data[i] = rand(); // write it to a file wxString garbagename = wxFileName::CreateTempFileName("garbage"); CPPUNIT_ASSERT( !garbagename.empty() ); wxFile garbage(garbagename, wxFile::write); CPPUNIT_ASSERT( garbage.IsOpened() ); CPPUNIT_ASSERT( garbage.Write(data, size) == size ); garbage.Close(); // try to load it by name DoLoadFile(garbagename); // try to load it from a wxInputStream wxMemoryInputStream stream(data, size); DoLoadStream(stream); wxDELETEA(data); } }
/** OnReloadOver * * Called when the user wants to reload the last file over the current state. */ void ComplxFrame::OnReloadOver(wxCommandEvent& event) { if (Running()) return; if (currentFile.GetFullName().IsEmpty()) { OnLoadOver(event); return; } DoLoadFile(currentFile); }
/** OnReload * * Called when the user wants to reload the last file. */ void ComplxFrame::OnReload(wxCommandEvent& event) { if (Running()) return; if (reload_options.file.empty()) { OnLoad(event); return; } DoLoadFile(reload_options); }
/** OnLoadOver * * Called when the user wants to load a new file over the current state */ void ComplxFrame::OnLoadOver(wxCommandEvent& event) { if (Running()) return; wxFileDialog* dialog = new wxFileDialog(NULL, _("Load .asm file"), wxEmptyString, wxEmptyString, _("LC-3 Assembly Files (*.asm)|*.asm"), wxFD_OPEN|wxFD_FILE_MUST_EXIST|wxFD_CHANGE_DIR); if (dialog->ShowModal() == wxID_OK) { wxFileName filename(dialog->GetPath()); DoLoadFile(filename); } delete dialog; }
/** OnRandomizeAndReload * * Called when the user wants to reload the last file. */ void ComplxFrame::OnRandomizeAndReload(wxCommandEvent& event) { if (Running()) return; if (currentFile.GetFullName().IsEmpty()) { OnLoad(event); return; } OnInit(); lc3_randomize(state); DoLoadFile(currentFile); }
/** OnLoad * * Called when a file needs to be loaded. */ void ComplxFrame::OnLoad(wxCommandEvent& event) { if (Running()) return; wxFileDialog* dialog = new wxFileDialog(NULL, _("Load .asm file"), wxEmptyString, wxEmptyString, _("LC-3 Assembly Files (*.asm)|*.asm"), wxFD_OPEN|wxFD_FILE_MUST_EXIST|wxFD_CHANGE_DIR); if (dialog->ShowModal() == wxID_OK) { LoadingOptions opts; opts.file = dialog->GetPath().ToStdString(); DoLoadFile(opts); } delete dialog; }
/** ComplxFrame * * Constructor */ ComplxFrame::ComplxFrame(long decimal, long disassemble, long stack_size, long true_traps, long interrupts, long highlight, wxString address_str, wxString state_file, wxArrayString files) : ComplxFrameDecl(NULL), console(NULL), memoryView(NULL) { InitImages(); menuStateTrueTraps->Check(true_traps == 1); menuStateInterrupts->Check(interrupts == 1); menuViewInstructionHighlighting->Check(highlight != 0); menuViewUnsignedDecimal->Check(decimal == 1); this->stack_size = stack_size; OnInit(); if (!address_str.IsEmpty()) { int addr; lc3_calculate(state, address_str.ToStdString(), addr); state.pc = addr; } if (!state_file.IsEmpty()) DoLoadMachine(wxFileName(state_file)); if (files.size() > 0) DoLoadFile(wxFileName(files[0])); memoryView = new MemoryView(); memory->SetView(memoryView); memory->SetDisassembleLevel(disassemble > 2 ? 2 : disassemble); memory->SetUnsignedMode(decimal > 1 ? 0 : decimal); memory->SetHighlight(highlight > 1 ? 1 : highlight); int widths[3] = {-7, -3, -3}; int styles[3] = {wxSB_NORMAL, wxSB_NORMAL, wxSB_NORMAL}; statusBar->SetStatusWidths(3, widths); statusBar->SetStatusStyles(3, styles); UpdateMemory(); UpdateStatus(); Connect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_COMPLETED, wxThreadEventHandler(ComplxFrame::OnRunComplete)); Connect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_UPDATE, wxThreadEventHandler(ComplxFrame::OnRunUpdate)); Connect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_IO, wxThreadEventHandler(ComplxFrame::OnIo)); Connect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_NOIO, wxThreadEventHandler(ComplxFrame::OnNoIo)); Connect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_OUTPUT, wxThreadEventHandler(ComplxFrame::OnOutput)); }
void ComplxFrame::OnActivate(wxActivateEvent& event) { bool reload_asm = false; bool reload_tests = false; /*if (!reload_options.tests.empty()) { wxFileName tests_file(reload_options.tests); if (tests_file.GetModificationTime().IsLaterThan(reload_options.tests_modification_time)) { // To prevent multiple occurrences reload_options.tests_modification_time = tests_file.GetModificationTime(); int answer = wxMessageBox(wxString::Format("%s has been modified.\n" "Do you wish to reload it?\n" "(Note simulation will be reset and breakpoints " "not present in code will not be reloaded.)", tests_file.GetFullName()), "Reload test xml file?", wxOK | wxOK_DEFAULT | wxCANCEL); reload_tests = answer == wxID_OK; } }*/ if (!reload_options.file.empty()) { wxFileName asm_file(reload_options.file); if (asm_file.GetModificationTime().IsLaterThan(reload_options.file_modification_time)) { // To prevent multiple occurrences reload_options.file_modification_time = asm_file.GetModificationTime(); if (!reload_tests) { int answer = wxMessageBox(wxString::Format("%s has been modified.\n" "Do you wish to reload it?\n" "(Note simulation will be reset and breakpoints " "not present in code will not be reloaded.)", asm_file.GetFullName()), "Reload asm file?", wxOK | wxOK_DEFAULT | wxCANCEL); reload_asm = answer == wxOK; } } } if (reload_asm) DoLoadFile(reload_options); }
void ComplxFrame::OnAdvancedLoad(wxCommandEvent& event) { if (Running()) return; AdvancedLoadDialog* dialog = new AdvancedLoadDialog(this, reload_options); if (dialog->ShowModal() == wxID_OK) { LoadingOptions options = dialog->GetOptions(); if (options.file.empty()) { wxMessageBox("No file to load", "Error"); delete dialog; return; } reload_options = options; DoLoadFile(reload_options); if (!reload_options.replay_string.empty()) DoSetupReplayString(reload_options.replay_string); } delete dialog; }
/** * * Constructor */ EditorPanel::EditorPanel(const wxString& file, wxWindow* parent) : EditorPanelDecl(parent) { DoLoadFile(file); }