void DoConsoleCommand() { // Get command text TCHAR command[32]; GetWindowText(m_hwndConsoleEdit, command, 32); SendMessage(m_hwndConsoleEdit, WM_SETTEXT, 0, (LPARAM) _T("")); // Clear command if (command[0] == 0) return; // Nothing to do // Echo command to the log TCHAR buffer[36]; ::GetWindowText(m_hwndConsolePrompt, buffer, 14); ConsoleView_Print(buffer); wsprintf(buffer, _T(" %s\r\n"), command); ConsoleView_Print(buffer); BOOL okUpdateAllViews = FALSE; // Flag - need to update all debug views CProcessor* pProc = ConsoleView_GetCurrentProcessor(); // Execute the command switch (command[0]) { case _T('h'): ConsoleView_ShowHelp(); break; case _T('c'): // Clear log ClearConsole(); break; case _T('r'): // Register operations if (command[1] == 0) // Print all registers { for (int r = 0; r < 8; r++) { LPCTSTR name = REGISTER_NAME[r]; WORD value = pProc->GetReg(r); PrintRegister(name, value); } PrintRegister(_T("PS"), pProc->GetPSW()); } else if (command[1] >= _T('0') && command[1] <= _T('7')) // "r0".."r7" { int r = command[1] - _T('0'); LPCTSTR name = REGISTER_NAME[r]; if (command[2] == 0) // "rN" - show register N { WORD value = pProc->GetReg(r); PrintRegister(name, value); } else if (command[2] == _T('=') || command[2] == _T(' ')) // "rN=XXXXXX" - set register N to value XXXXXX { WORD value; if (! ParseOctalValue(command + 3, &value)) ConsoleView_Print(MESSAGE_WRONG_VALUE); else { pProc->SetReg(r, value); PrintRegister(name, value); okUpdateAllViews = TRUE; } } else ConsoleView_Print(MESSAGE_UNKNOWN_COMMAND); } else if (command[1] == _T('p') && command[2] == _T('s')) // "rps" { if (command[3] == 0) // "rps" - show PSW { WORD value = pProc->GetPSW(); PrintRegister(_T("PS"), value); } else if (command[3] == _T('=') || command[3] == _T(' ')) // "rps=XXXXXX" - set PSW to value XXXXXX { WORD value; if (! ParseOctalValue(command + 4, &value)) ConsoleView_Print(MESSAGE_WRONG_VALUE); else { pProc->SetPSW(value); PrintRegister(_T("PS"), value); okUpdateAllViews = TRUE; } } else ConsoleView_Print(MESSAGE_UNKNOWN_COMMAND); } else ConsoleView_Print(MESSAGE_UNKNOWN_COMMAND); break; case _T('s'): // Step if (command[1] == 0) // "s" - Step Into, execute one instruction { PrintDisassemble(pProc, pProc->GetPC(), TRUE, FALSE); //pProc->Execute(); g_pBoard->DebugTicks(); okUpdateAllViews = TRUE; } else if (command[1] == _T('o')) // "so" - Step Over { int instrLength = PrintDisassemble(pProc, pProc->GetPC(), TRUE, FALSE); WORD bpaddress = (WORD)(pProc->GetPC() + instrLength * 2); Emulator_SetCPUBreakpoint(bpaddress); Emulator_Start(); } break; case _T('d'): // Disassemble case _T('D'): // Disassemble, short format { BOOL okShort = (command[0] == _T('D')); if (command[1] == 0) // "d" - disassemble at current address PrintDisassemble(pProc, pProc->GetPC(), FALSE, okShort); else if (command[1] >= _T('0') && command[1] <= _T('7')) // "dXXXXXX" - disassemble at address XXXXXX { WORD value; if (! ParseOctalValue(command + 1, &value)) ConsoleView_Print(MESSAGE_WRONG_VALUE); else { PrintDisassemble(pProc, value, FALSE, okShort); } } else ConsoleView_Print(MESSAGE_UNKNOWN_COMMAND); } break; case _T('u'): SaveMemoryDump(pProc); break; case _T('m'): if (command[1] == 0) // "m" - dump memory at current address { PrintMemoryDump(pProc, pProc->GetPC(), 8); } else if (command[1] >= _T('0') && command[1] <= _T('7')) // "mXXXXXX" - dump memory at address XXXXXX { WORD value; if (! ParseOctalValue(command + 1, &value)) ConsoleView_Print(MESSAGE_WRONG_VALUE); else { PrintMemoryDump(pProc, value, 8); } } else if (command[1] == _T('r') && command[2] >= _T('0') && command[2] <= _T('7')) // "mrN" - dump memory at address from register N { int r = command[2] - _T('0'); WORD address = pProc->GetReg(r); PrintMemoryDump(pProc, address, 8); } else if (command[1] == _T('o')) { ConsoleView_GotoMonitor(); } else ConsoleView_Print(MESSAGE_UNKNOWN_COMMAND); break; //TODO: "mXXXXXX YYYYYY" - set memory cell at XXXXXX to value YYYYYY //TODO: "mrN YYYYYY" - set memory cell at address from rN to value YYYYYY case _T('g'): if (command[1] == 0) { Emulator_Start(); } else { WORD value; if (! ParseOctalValue(command + 1, &value)) ConsoleView_Print(MESSAGE_WRONG_VALUE); else { Emulator_SetCPUBreakpoint(value); Emulator_Start(); } } break; #if !defined(PRODUCT) case _T('t'): { BOOL okTrace = !g_pBoard->GetTrace(); g_pBoard->SetTrace(okTrace); if (okTrace) ConsoleView_Print(_T(" Trace is ON.\r\n")); else { ConsoleView_Print(_T(" Trace is OFF.\r\n")); DebugLogCloseFile(); } } break; #endif default: ConsoleView_Print(MESSAGE_UNKNOWN_COMMAND); break; } PrintConsolePrompt(); if (okUpdateAllViews) { MainWindow_UpdateAllViews(); } }
int main(int argc, char** argv) { const char *inPath = argv[0]; // Get application directory int i, j; for (i = 0, j = 0; inPath[i] != '\0'; i++) { if ((inPath[i] == '\\') || (inPath[i] == '/')) j = i + 1; } strncpy(g_AppDirectory, inPath, j); g_AppDirectory[j] = '\0'; // Get application INI file path const char *inPathDot = strrchr(inPath, '.'); int c = (inPathDot == NULL) ? strlen(inPath) : inPathDot - inPath; strncpy(g_AppIniPath, inPath, c); strncpy(g_AppIniPath + c, ".ini", 4); #if defined(_DINGOO) SDL_putenv("DINGOO_IGNORE_OS_EVENTS=1"); //HACK to fix "push long time on X" problem #endif Settings_ParseIniFile(g_AppIniPath); // Init SDL video if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) return 255; // Unable to initialize SDL #ifdef _WIN32 SDL_putenv("SDL_VIDEO_WINDOW_POS=300,200"); SDL_WM_SetCaption("BKBTL SDL", "BKBTL SDL"); #else SDL_ShowCursor(SDL_DISABLE); #endif // Prepare screen surface g_Screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BITPERPIXEL, 0); if (g_Screen == NULL) return 254; // Unable to set video mode g_Keyboard = SDL_CreateRGBSurface(0, KEYBOARD_WIDTH, KEYBOARD_HEIGHT, 32, 0,0,0,0); SDL_SetAlpha(g_Keyboard, SDL_SRCALPHA, 180); SDL_SetColorKey(g_Keyboard, SDL_SRCCOLORKEY, SDL_MapRGB(g_Keyboard->format, 0,0,0)); SDL_Delay(1000); if (SDL_NumJoysticks()) g_Joystick = SDL_JoystickOpen(0); Fonts_Initialize(); if (!Emulator_Init()) return 255; if (!Emulator_InitConfiguration(DEFAULT_BK_CONF)) return 255; Main_ClearScreen(); Main_SetScreenMode(0); Emulator_Start(); Uint32 ticksLast; Uint32 ticksLastFps = SDL_GetTicks(); int frames = 0; while (!g_okQuit) { ticksLast = SDL_GetTicks(); // Time at frame start SDL_Event evt; while (SDL_PollEvent(&evt)) { if (evt.type == SDL_QUIT) { g_okQuit = TRUE; break; } else { if (evt.type == SDL_KEYDOWN || evt.type == SDL_KEYUP || evt.type == SDL_JOYBUTTONDOWN || evt.type == SDL_JOYBUTTONUP) { Main_OnKeyJoyEvent(evt); } } } if (g_okEmulatorRunning) { Emulator_SystemFrame(); Main_DrawScreen(); frames++; } // Delay Uint32 ticksNew = SDL_GetTicks(); Uint32 ticksElapsed = ticksNew - ticksLast; g_LastDelay = 0; if (ticksElapsed < FRAME_TICKS) { g_LastDelay = FRAME_TICKS - ticksElapsed; SDL_Delay(FRAME_TICKS - ticksElapsed); } ticksLast = ticksNew; if (ticksLast - ticksLastFps > 1000) //DEBUG: FPS calculation { g_LastFps = frames; frames = 0; ticksLastFps += 1000; } } Emulator_Stop(); Emulator_Done(); Main_SetScreenMode(-1); if (g_Joystick != NULL) { SDL_JoystickClose(g_Joystick); } // Free memory SDL_FreeSurface(g_Keyboard); SDL_FreeSurface(g_Screen); Fonts_Finalize(); SDL_Quit(); return 0; }
void QConsoleView::execConsoleCommand(const QString &command) { if (command.isNull() || command.isEmpty()) return; // Nothing to do if (g_okEmulatorRunning) return; // Echo command to the log this->printLine(command); BOOL okUpdateAllViews = FALSE; // Flag - need to update all debug views BOOL okUpdateMenu = FALSE; // Flag - need to update main menu CProcessor* pProc = g_pBoard->GetCPU(); // Execute the command if (command == _T("h")) { this->printHelp(); } else if (command == _T("c")) // Clear log { this->clear(); } else if (command.startsWith(_T("r"))) // Register operations { if (command.length() == 1) // Print all registers { for (int r = 0; r < 8; r++) { LPCTSTR name = REGISTER_NAME[r]; WORD value = pProc->GetReg(r); this->printRegister(name, value); } } else if (command[1].toAscii() >= '0' && command[1].toAscii() <= '7') // "r0".."r7" { int r = command[1].toAscii() - '0'; LPCTSTR name = REGISTER_NAME[r]; if (command.length() == 2) // "rN" - show register N { WORD value = pProc->GetReg(r); this->printRegister(name, value); } else if (command[2].toAscii() == '=' || command[2].toAscii() == ' ') // "rN=XXXXXX" - set register N to value XXXXXX { WORD value; if (! ParseOctalValue(command.mid(3), &value)) this->print(MESSAGE_WRONG_VALUE); else { pProc->SetReg(r, value); this->printRegister(name, value); okUpdateAllViews = TRUE; } } else this->print(MESSAGE_UNKNOWN_COMMAND); } else if (command.length() >= 2 && command[1].toAscii() == 'p' && command[2].toAscii() == 's') // "rps" { if (command.length() == 2) // "rps" - show PSW { WORD value = pProc->GetPSW(); this->printRegister(_T("PS"), value); } else if (command[3].toAscii() == '=' || command[3].toAscii() == ' ') // "rps=XXXXXX" - set PSW to value XXXXXX { WORD value; if (! ParseOctalValue(command.mid(4), &value)) this->print(MESSAGE_WRONG_VALUE); else { pProc->SetPSW(value); this->printRegister(_T("PS"), value); okUpdateAllViews = TRUE; } } else this->print(MESSAGE_UNKNOWN_COMMAND); } else this->print(MESSAGE_UNKNOWN_COMMAND); } else if (command == _T("s")) // "s" - Step Into, execute one instruction { this->printDisassemble(pProc->GetPC(), TRUE, FALSE); //pProc->Execute(); g_pBoard->DebugTicks(); okUpdateAllViews = TRUE; } else if (command == _T("so")) // "so" - Step Over { int instrLength = this->printDisassemble(pProc->GetPC(), TRUE, FALSE); WORD bpaddress = pProc->GetPC() + instrLength * 2; Emulator_SetCPUBreakpoint(bpaddress); Emulator_Start(); okUpdateMenu = TRUE; } else if (command.startsWith(_T("d")) || // Disassemble command.startsWith(_T("D"))) // Disassemble, short format { BOOL okShort = (command[0] == _T('D')); if (command.length() == 1) // "d" - disassemble at current address this->printDisassemble(pProc->GetPC(), FALSE, okShort); else if (command[1].toAscii() >= '0' && command[1].toAscii() <= '7') // "dXXXXXX" - disassemble at address XXXXXX { WORD value; if (! ParseOctalValue(command.mid(1), &value)) this->print(MESSAGE_WRONG_VALUE); else this->printDisassemble(value, FALSE, okShort); } else this->print(MESSAGE_UNKNOWN_COMMAND); } else if (command.startsWith(_T("m"))) { if (command.length() == 1) // "m" - dump memory at current address { this->printMemoryDump(pProc->GetPC(), 8); } else if (command[1].toAscii() >= '0' && command[1].toAscii() <= '7') // "mXXXXXX" - dump memory at address XXXXXX { WORD value; if (! ParseOctalValue(command.mid(1), &value)) this->print(MESSAGE_WRONG_VALUE); else this->printMemoryDump(value, 8); } else if (command[1].toAscii() == 'r' && command.length() >= 3 && command[2].toAscii() >= '0' && command[2].toAscii() <= '7') // "mrN" - dump memory at address from register N { int r = command[2].toAscii() - '0'; WORD address = pProc->GetReg(r); this->printMemoryDump(address, 8); } else this->print(MESSAGE_UNKNOWN_COMMAND); //TODO: "mXXXXXX YYYYYY" - set memory cell at XXXXXX to value YYYYYY //TODO: "mrN YYYYYY" - set memory cell at address from rN to value YYYYYY } else if (command == _T("g")) // Go { Emulator_Start(); okUpdateAllViews = TRUE; } else if (command.startsWith(_T("g"))) // Go { WORD value; if (! ParseOctalValue(command.mid(1), &value)) this->print(MESSAGE_WRONG_VALUE); else { Emulator_SetCPUBreakpoint(value); Emulator_Start(); okUpdateMenu = TRUE; } } else { this->print(MESSAGE_UNKNOWN_COMMAND); } this->printConsolePrompt(); if (okUpdateAllViews) Global_UpdateAllViews(); else if (okUpdateMenu) Global_UpdateMenu(); }
int main(int argc, char* argv[]) { // Get application path g_ApplicationExePath.append(argv[0]); // Calculate INI file path g_ApplicationIniPath = g_ApplicationExePath; g_ApplicationIniPath.resize(g_ApplicationIniPath.find_last_of(_T('.'))); g_ApplicationIniPath.append(_T(".ini")); if (! InitInstance()) return 255; Emulator_Start(); // The main loop Uint32 ticksLast; Uint32 ticksLastFps = SDL_GetTicks(); int frames = 0; while (!g_okQuit) { ticksLast = SDL_GetTicks(); // Time at frame start SDL_Event evt; while (SDL_PollEvent(&evt)) { if (evt.type == SDL_QUIT) { g_okQuit = TRUE; break; } else { if (evt.type == SDL_KEYDOWN || evt.type == SDL_KEYUP || evt.type == SDL_JOYBUTTONDOWN || evt.type == SDL_JOYBUTTONUP) { Main_OnKeyJoyEvent(evt); } } } if (g_okEmulatorRunning) { Emulator_SystemFrame(); Main_DrawScreen(); frames++; } // Delay Uint32 ticksNew = SDL_GetTicks(); Uint32 ticksElapsed = ticksNew - ticksLast; g_LastDelay = 0; if (ticksElapsed < FRAME_TICKS) { g_LastDelay = FRAME_TICKS - ticksElapsed; SDL_Delay(FRAME_TICKS - ticksElapsed); } ticksLast = ticksNew; if (ticksLast - ticksLastFps > 1000) //DEBUG: FPS calculation { g_LastFps = frames; frames = 0; ticksLastFps += 1000; } } Emulator_Stop(); DoneInstance(); return 0; }
int main() { struct stat st; sys_spu_initialize(6, 1); cellSysmoduleLoadModule(CELL_SYSMODULE_FS); cellSysmoduleLoadModule(CELL_SYSMODULE_IO); cellSysutilRegisterCallback(0, sysutil_exit_callback, NULL); LOG_INIT(); LOG_DBG("LOG INIT\n"); mode_switch = MODE_MENU; Graphics = new PS3Graphics(); LOG_DBG("Graphics->Init()\n"); Graphics->Init(); CellInput = new CellInputFacade(); LOG_DBG("CellInput->Init()\n"); CellInput->Init(); oskutil = new OSKUtil(); // FIXME: Is this necessary? if (Graphics->InitCg() != CELL_OK) { LOG_DBG("Failed to InitCg: %d\n", __LINE__); exit(0); } LOG_DBG("Graphics->InitDbgFont()\n"); Graphics->InitDbgFont(); Emulator_ToggleSound(); emulation_running = true; /* if (ini_parse("/dev_hdd0/game/GENP00001/USRDIR/GenesisConf.ini", handler, &Iniconfig) < 0) { gl_dprintf(0.09f,0.05f,Emulator_GetFontSize(),"Could not load /dev_hdd0/game/GENP00001/GenesisConf.ini\n"); sys_timer_sleep(5); gl_dprintf(0.09f,0.05f,Emulator_GetFontSize(),"Now exiting to XMB...\n"); sys_timer_sleep(5); sys_process_exit(0); } */ //REPLACEMENT if (load_settings) { Emulator_InitSettings(); load_settings = false; } /* //main path - Check if not present - create all folders and exit if(stat(Iniconfig.rompath,&st) != 0) { gl_dprintf(0.09f,0.05f,Emulator_GetFontSize(),"Creating generic folder tree for Genesisplus...\n"); sys_timer_sleep(5); CreateFolder(Iniconfig.rompath); CreateFolder(Iniconfig.savpath); CreateFolder(Iniconfig.cartpath); CreateFolder(Iniconfig.sram_path); CreateFolder(Iniconfig.biospath); gl_dprintf(0.09f,0.05f,Emulator_GetFontSize(),"Generic folder tree done! Will now exit to XMB...\nPlease put all your ROMs inside %s\n",Iniconfig.rompath); sys_timer_sleep(5); sys_process_exit(0); } */ ////Set Bios //sprintf(Iniconfig.biospath,"%s/bios.bin",Iniconfig.biospath); while(1) { switch(mode_switch) { case MODE_MENU: MenuMainLoop(); break; case MODE_EMULATION: Emulator_Start(); CellAudio->pause(); break; case MODE_EXIT: Emulator_Shutdown(); } } return 0; }