static void psp_main_menu_reset(void) { /* Reset ! */ psp_display_screen_menu(); psp_sdl_back2_print( 120, 100, "Reset MSX !", PSP_MENU_WARNING_COLOR); psp_sdl_flip(); emulator_reset(); sleep(1); }
static void psp_main_menu_reset(void) { /* Reset ! */ psp_display_screen_menu(); psp_sdl_back2_print( 140, 110, "Reset CPC !", PSP_MENU_WARNING_COLOR); psp_sdl_flip(); emulator_reset(false); reset_save_name(); sleep(1); }
void emulator_load_from_parser(struct emulator *emu, struct parser *parser) { emu->backup_text.data = malloc(parser->text.len); memcpy(emu->backup_text.data, parser->text.data, parser->text.len); emu->backup_text.len = parser->text.len; emu->backup_text.alloced = parser->text.len; emu->backup_text.addr = parser->text.addr; emu->backup_data.data = malloc(parser->data.len); memcpy(emu->backup_data.data, parser->data.data, parser->data.len); emu->backup_data.len = parser->data.len; emu->backup_data.alloced = parser->data.len; emu->backup_data.addr = parser->data.addr; emulator_reset(emu); }
bool CapriceLoadSave::HandleMessage(CMessage* pMessage) { bool bHandled = false; if (pMessage) { switch(pMessage->MessageType()) { case CMessage::CTRL_SINGLELCLICK: { if (pMessage->Destination() == this) { if (pMessage->Source() == m_pCancelButton) { CloseFrame(); bHandled = true; break; } if (pMessage->Source() == m_pLoadSaveButton) { bool actionDone = false; std::string filename = m_pFileNameValue->GetWindowText(); if(!filename.empty()) { std::string directory = m_pDirectoryValue->GetWindowText(); filename = directory + '/' + filename; switch (m_pActionValue->GetSelectedIndex()) { case 0: // Load { DRIVE drive; switch (m_pTypeValue->GetSelectedIndex()) { case 0: // Drive A drive = DSK_A; actionDone = true; CPC.current_dsk_path = directory; break; case 1: // Drive B drive = DSK_B; actionDone = true; CPC.current_dsk_path = directory; break; case 2: // Snapshot drive = OTHER; actionDone = true; CPC.current_snap_path = directory; break; case 3: // Tape drive = OTHER; actionDone = true; CPC.current_tape_path = directory; break; case 4: // Cartridge drive = OTHER; actionDone = true; CPC.current_cart_path = directory; break; } if (actionDone) { file_load(filename, drive); } if (m_pTypeValue->GetSelectedIndex() == 4) { emulator_reset(false); } break; } case 1: // Save // TODO(cpitrat): Ensure the proper extension is present in the filename, otherwise add it. switch (m_pTypeValue->GetSelectedIndex()) { case 0: // Drive A std::cout << "Save dsk A: " << filename << std::endl; dsk_save(filename, &driveA); actionDone = true; break; case 1: // Drive B std::cout << "Save dsk B: " << filename << std::endl; dsk_save(filename, &driveB); actionDone = true; break; case 2: // Snapshot std::cout << "Save snapshot: " << filename << std::endl; snapshot_save(filename); actionDone = true; break; case 3: // Tape { std::cout << "Save tape: " << filename << std::endl; // Unsupported wGui::CMessageBox *pMessageBox = new wGui::CMessageBox(CRect(CPoint(m_ClientRect.Width() /2 - 125, m_ClientRect.Height() /2 - 30), 250, 60), this, nullptr, "Not implemented", "Saving tape not yet implemented", CMessageBox::BUTTON_OK); pMessageBox->SetModal(true); //tape_save(filename); break; } case 4: // Cartridge { std::cout << "Save cartridge: " << filename << std::endl; // Unsupported wGui::CMessageBox *pMessageBox = new wGui::CMessageBox(CRect(CPoint(m_ClientRect.Width() /2 - 125, m_ClientRect.Height() /2 - 30), 250, 60), this, nullptr, "Not implemented", "Saving cartridge not yet implemented", CMessageBox::BUTTON_OK); pMessageBox->SetModal(true); //cpr_save(filename); break; } } break; } } if(actionDone) { CloseFrame(); } bHandled = true; break; } } } break; case CMessage::CTRL_VALUECHANGE: if (pMessage->Destination() == m_pActionValue) { switch (m_pActionValue->GetSelectedIndex()) { case 0: // Load m_pLoadSaveButton->SetWindowText("Load"); m_pFileNameValue->SetReadOnly(true); break; case 1: // Save m_pLoadSaveButton->SetWindowText("Save"); m_pFileNameValue->SetReadOnly(false); break; } } if (pMessage->Destination() == m_pTypeValue) { switch (m_pTypeValue->GetSelectedIndex()) { case 0: // Drive A m_pDirectoryValue->SetWindowText(simplifyDirPath(CPC.current_dsk_path)); #ifndef WITH_IPF m_fileSpec = { ".dsk", ".zip" }; #else m_fileSpec = { ".dsk", ".ipf", ".zip" }; #endif UpdateFilesList(); break; case 1: // Drive B m_pDirectoryValue->SetWindowText(simplifyDirPath(CPC.current_dsk_path)); m_fileSpec = { ".dsk", ".zip" }; UpdateFilesList(); break; case 2: // Snapshot m_pDirectoryValue->SetWindowText(simplifyDirPath(CPC.current_snap_path)); m_fileSpec = { ".sna", ".zip" }; UpdateFilesList(); break; case 3: // Tape m_pDirectoryValue->SetWindowText(simplifyDirPath(CPC.current_tape_path)); m_fileSpec = { ".cdt", ".voc", ".zip" }; UpdateFilesList(); break; case 4: // Cartridge m_pDirectoryValue->SetWindowText(simplifyDirPath(CPC.current_cart_path)); m_fileSpec = { ".cpr", ".zip" }; UpdateFilesList(); break; } } if (pMessage->Source() == m_pFilesList) { int idx = m_pFilesList->getFirstSelectedIndex(); std::string fn; if (idx != -1) { fn = m_pFilesList->GetItem(idx).sItemText; } if(!fn.empty() && fn[fn.size()-1] == '/') { m_pDirectoryValue->SetWindowText(simplifyDirPath(m_pDirectoryValue->GetWindowText() + '/' + fn)); m_pFileNameValue->SetWindowText(""); UpdateFilesList(); } else { m_pFileNameValue->SetWindowText(fn); } } break; default : break; } } if (!bHandled) { bHandled = CFrame::HandleMessage(pMessage); } return bHandled; }
bool CapriceGuiView::HandleMessage(CMessage* pMessage) { bool bHandled = false; if (pMessage) { switch (pMessage->MessageType()) { case CMessage::CTRL_SINGLELCLICK: if (pMessage->Destination() == this) { bHandled = true; const wGui::CMessageClient* pSource = pMessage->Source(); if (pSource == m_pBtnOptions) { wGui::CapriceOptions* pOptionsBox = new wGui::CapriceOptions(CRect(CPoint(m_pScreenSurface->w /2 - 165, m_pScreenSurface->h /2 - 127), 330, 260), this, 0); pOptionsBox->SetModal(true); break; } if (pSource == m_pBtnReset) { emulator_reset(false); // Exit gui CMessageServer::Instance().QueueMessage(new CMessage(CMessage::APP_EXIT, 0, this)); break; } if (pSource == m_pBtnAbout) { wGui::CapriceAbout* pAboutBox = new wGui::CapriceAbout(CRect(CPoint(m_pScreenSurface->w /2 - 120, m_pScreenSurface->h /2 - 50), 240, 110), this, 0); pAboutBox->SetModal(true); break; } if (pSource == m_pBtnResume) { // Exit gui, see also handling of SDLK_ESCAPE below. CMessageServer::Instance().QueueMessage(new CMessage(CMessage::APP_EXIT, 0, this)); break; } if (pSource == m_pBtnQuit) { // atexit() takes care of all the cleanup exit (0); break; } } break; case CMessage::KEYBOARD_KEYDOWN: if (m_bVisible && pMessage->Destination() == this) { CKeyboardMessage* pKeyboardMessage = dynamic_cast<CKeyboardMessage*>(pMessage); if (pKeyboardMessage) { if (pKeyboardMessage->Key == SDLK_ESCAPE) { // Exit gui, see handling of m_pBtmResume above. CMessageServer::Instance().QueueMessage(new CMessage(CMessage::APP_EXIT, 0, this)); bHandled = true; } } } break; //case wGui::CMessage::CTRL_MESSAGEBOXRETURN: // { // bHandled = false; // break; // } default: bHandled = CView::HandleMessage(pMessage); break; } } return bHandled; }