⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uifltk-menu.cpp

📁 一个任天堂掌上游戏机NDS的源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	    // Pause execution.	    case 1:		// Update plugin statuses                cpu->status(cpuStatMode,0);                if(DSmode) cpuSub->status(cpuStatMode,0);		gpu->status(0,0);		mmu->status(mmuDumpAddr,mmuDumpMode);		if(DSmode) mmuSub->status(mmuDumpAddr,mmuDumpMode);		// Stop the FPS counter and step timeouts                Fl::remove_timeout(cbFPScount);		Fl::remove_timeout(cbAStepI);		sbarr->label("");                running=0; stepping=0;		// Update the menu to show we're paused                menu[MENU_DEBUG_RUN].text="@#> &Run";		menu[MENU_DEBUG_BKPT].flags &= ~FL_MENU_INACTIVE;		menu[MENU_DEBUG_STEP].flags &= ~FL_MENU_INACTIVE;                menu[MENU_DEBUG_ASTEP].flags &= ~FL_MENU_INACTIVE;                mbar->copy(&menu[0]);	        apu->togglePause();			        sbarl->label("Paused");		break;	}	redraw();    }}void UIFltk::UI::cbReset(Fl_Widget *w, void *in) { ((UIFltk::UI*)in)->cbResetI(); }inline void UIFltk::UI::cbResetI(){    if(loaded)    {	// Let cbRun do the hard work of setting the initial state, since	// post-Reset is just the same as post-Pause.	running=1; cbRunI();	frames=0;	        events.clear();        timestamp=0;    	// Reset everything, and load the ROM.        cpu->reset();	if(DSmode) cpuSub->reset();	timer->reset();        if(!DSmode) mmu->load(ROMpath);         memset(outbuf, 0, 240*160*4);        gpu->reset();	apu->reset(); 	// Set the menu up to reflect post-Reset        menu[MENU_DEBUG_RUN].text="@#> &Run";        menu[MENU_DEBUG_RESET].flags &= ~FL_MENU_INACTIVE;        mbar->copy(&menu[0]);        sbarl->label("Reset");        running=0;    }}void UIFltk::UI::cbStep(Fl_Widget *w, void *in) { ((UIFltk::UI*)in)->cbStepI(); }inline void UIFltk::UI::cbStepI(){    if(loaded && !running)    {	// Perform one instruction, and update the statuses        execStep();        cpu->status(cpuStatMode,0);        if(DSmode) cpuSub->status(cpuStatMode,0);	gpu->status(0,0);	mmu->status(mmuDumpAddr,mmuDumpMode);	if(DSmode) mmuSub->status(mmuDumpAddr,mmuDumpMode);    }}void UIFltk::UI::cbAStep(Fl_Widget *w, void *in){    ((UIFltk::UI*)in)->sbarl->label("Stepping");    ((UIFltk::UI*)in)->stepping=1;        // Update the menu to show stepping    ((UIFltk::UI*)in)->menu[MENU_DEBUG_RUN].text="@#|| &Pause";    ((UIFltk::UI*)in)->menu[MENU_DEBUG_BKPT].flags |= FL_MENU_INACTIVE;    ((UIFltk::UI*)in)->menu[MENU_DEBUG_STEP].flags |= FL_MENU_INACTIVE;    ((UIFltk::UI*)in)->menu[MENU_DEBUG_ASTEP].flags |= FL_MENU_INACTIVE;    ((UIFltk::UI*)in)->mbar->copy(&menu[0]);        // Start step animation    ((UIFltk::UI*)in)->cbAStepI(in);}void UIFltk::UI::cbAStepI(void *in){    if(((UIFltk::UI*)in)->loaded &&       !((UIFltk::UI*)in)->running)    {	// Remove any existing timeout, then do a step	Fl::remove_timeout(cbAStepI);	((UIFltk::UI*)in)->execStep();        cpu->status(cpuStatMode,0);        if(DSmode) cpuSub->status(cpuStatMode,0);	gpu->status(0,0);	mmu->status(mmuDumpAddr,mmuDumpMode);	if(DSmode) mmuSub->status(mmuDumpAddr,mmuDumpMode);	// Set a timeout for about 50Hz	Fl::repeat_timeout(0.02, cbAStepI, in);    }}//---Breakpoint window-----------------------------------------------------void UIFltk::UI::cbBkpt(Fl_Widget *w, void *in) { ((UIFltk::UI*)in)->cbBkptI(); }inline void UIFltk::UI::cbBkptI(){    switch(bkptVisible)    {	case 0:	    // If the window isn't up, make a new one and show it            bkptWnd = new BkptWindow(260,195, this);	    bkptWnd->show();	    bkptVisible=1;	    break;	case 1:	    // If it is up, we don't need it any more; delete it.	    if(bkptWnd)	    {                bkptWnd->hide();                delete bkptWnd; bkptWnd=NULL;            }	    bkptVisible=0;	    break;    }}// Set the CPU status mode to 1, 2 or 3, and update the radio// buttons involved to reflect the new state.void UIFltk::UI::cbCpuStatARM(Fl_Widget *w, void *in) { ((UIFltk::UI*)in)->cbCpuStatARMI(); }inline void UIFltk::UI::cbCpuStatARMI(){    cpuStatMode = 1;    cpu->status(cpuStatMode,0);    if(DSmode) cpuSub->status(cpuStatMode,0);    menu[MENU_DEBUG_CPUMODE_ARM].flags   |=  FL_MENU_VALUE;    menu[MENU_DEBUG_CPUMODE_THUMB].flags &= ~FL_MENU_VALUE;    menu[MENU_DEBUG_CPUMODE_AUTO].flags  &= ~FL_MENU_VALUE;    mbar->copy(&menu[0]);}void UIFltk::UI::cbCpuStatThumb(Fl_Widget *w, void *in) { ((UIFltk::UI*)in)->cbCpuStatThumbI(); }inline void UIFltk::UI::cbCpuStatThumbI(){    cpuStatMode = 2;    cpu->status(cpuStatMode,0);    if(DSmode) cpuSub->status(cpuStatMode,0);    menu[MENU_DEBUG_CPUMODE_ARM].flags   &= ~FL_MENU_VALUE;    menu[MENU_DEBUG_CPUMODE_THUMB].flags |=  FL_MENU_VALUE;    menu[MENU_DEBUG_CPUMODE_AUTO].flags  &= ~FL_MENU_VALUE;    mbar->copy(&menu[0]);}void UIFltk::UI::cbCpuStatAuto(Fl_Widget *w, void *in) { ((UIFltk::UI*)in)->cbCpuStatAutoI(); }inline void UIFltk::UI::cbCpuStatAutoI(){    cpuStatMode = 3;    cpu->status(cpuStatMode,0);    if(DSmode) cpuSub->status(cpuStatMode,0);    menu[MENU_DEBUG_CPUMODE_ARM].flags   &= ~FL_MENU_VALUE;    menu[MENU_DEBUG_CPUMODE_THUMB].flags &= ~FL_MENU_VALUE;    menu[MENU_DEBUG_CPUMODE_AUTO].flags  |=  FL_MENU_VALUE;    mbar->copy(&menu[0]);}// Set the MMU dump mode to 0, 1 or 2, and update the radio buttons// to show the new state.void UIFltk::UI::cbMmuDumpB(Fl_Widget *w, void *in) { ((UIFltk::UI*)in)->cbMmuDumpBI(); }inline void UIFltk::UI::cbMmuDumpBI(){    mmuDumpMode = 0;    mmu->status(mmuDumpAddr, mmuDumpMode);    if(DSmode) mmuSub->status(mmuDumpAddr, mmuDumpMode);    menu[MENU_DEBUG_MMUMODE_B].flags |=  FL_MENU_VALUE;    menu[MENU_DEBUG_MMUMODE_H].flags &= ~FL_MENU_VALUE;    menu[MENU_DEBUG_MMUMODE_W].flags &= ~FL_MENU_VALUE;    mbar->copy(&menu[0]);}void UIFltk::UI::cbMmuDumpH(Fl_Widget *w, void *in) { ((UIFltk::UI*)in)->cbMmuDumpHI(); }inline void UIFltk::UI::cbMmuDumpHI(){    mmuDumpMode = 1;    mmu->status(mmuDumpAddr, mmuDumpMode);    if(DSmode) mmuSub->status(mmuDumpAddr, mmuDumpMode);    menu[MENU_DEBUG_MMUMODE_B].flags &= ~FL_MENU_VALUE;    menu[MENU_DEBUG_MMUMODE_H].flags |=  FL_MENU_VALUE;    menu[MENU_DEBUG_MMUMODE_W].flags &= ~FL_MENU_VALUE;    mbar->copy(&menu[0]);}void UIFltk::UI::cbMmuDumpW(Fl_Widget *w, void *in) { ((UIFltk::UI*)in)->cbMmuDumpWI(); }inline void UIFltk::UI::cbMmuDumpWI(){    mmuDumpMode = 2;    if(DSmode) mmuSub->status(mmuDumpAddr, mmuDumpMode);    menu[MENU_DEBUG_MMUMODE_B].flags &= ~FL_MENU_VALUE;    menu[MENU_DEBUG_MMUMODE_H].flags &= ~FL_MENU_VALUE;    menu[MENU_DEBUG_MMUMODE_W].flags |=  FL_MENU_VALUE;    mbar->copy(&menu[0]);}// Change the value that the MMU starts dumping atvoid UIFltk::UI::cbMmuAddr(Fl_Widget *w, void *in) { ((UIFltk::UI*)in)->cbMmuAddrI(); }inline void UIFltk::UI::cbMmuAddrI(){    u32 val; const char *in;    // Ask the user for a value    in = fl_input("Please enter an 8-digit hex address to view from:");    if(!in) return;    // Convert to hex (automatically validates)    val = strtol(in, NULL, 16);    mmuDumpAddr = val;    // And tell the MMU to dump from there    mmu->status(mmuDumpAddr, mmuDumpMode);}//---View menu-------------------------------------------------------------// If there's no log window, make a new one and show it; if there is,// delete it.void UIFltk::UI::cbLog(Fl_Widget *w, void *in) { ((UIFltk::UI*)in)->cbLogI(); }inline void UIFltk::UI::cbLogI(){    switch(logVisible)    {	case 0:            logWnd = new LogWindow(640,300, this);	    logWnd->show();	    logVisible=1;	    menu[MENU_VIEW_LOG].flags |= FL_MENU_VALUE;	    mbar->copy(&menu[0]);	    break;	case 1:	    if(logWnd)	    {                logWnd->hide();                delete logWnd; logWnd=NULL;            }	    logVisible=0;	    menu[MENU_VIEW_LOG].flags &= ~FL_MENU_VALUE;	    mbar->copy(&menu[0]);	    break;    }}// Show or hide a subwindow. This function is passed the title of// the window, so it has to search the map for it.void UIFltk::UI::cbSub(Fl_Widget *w, void *in) { ((UIFltk::UI*)in)->cbSubI(((Fl_Menu_*)w)->mvalue()->label()); }inline void UIFltk::UI::cbSubI(const char *t){    int id=0, opt=0;    std::map<int, SubWindow*>::iterator i;    // Search the map for a title, and get the associated ID    for(i=subwindows.begin(); i!=subwindows.end(); ++i)    {	if(!strcmp((*i).second->title, t))	{	    id = (*i).second->winID;	    break;	}    }    // Find the menu option that corresponds to the subwindow title    std::vector<Fl_Menu_Item>::iterator j;    for(j=menu.begin(); j!=menu.end(); ++j, ++opt)    {	if((*j).text)	    if(!strcmp(subwindows[id]->title, (*j).text))	        break;    }        // If that subwindow is available, update the menu and    // subwindow to reflect the new state.    if(id) {    switch(subwindows[id]->visible)    {	case 0:	    subwindows[id]->show();	    subwindows[id]->visible=1;	    menu[opt].flags |= FL_MENU_VALUE;	    mbar->copy(&menu[0]);	    break;	case 1:	    subwindows[id]->hide();	    subwindows[id]->visible=0;	    menu[opt].flags &= ~FL_MENU_VALUE;	    mbar->copy(&menu[0]);	    break;    }    }}//---Options menu----------------------------------------------------------// TODO: Configuration dialog//---Help menu-------------------------------------------------------------void UIFltk::UI::cbAbout(Fl_Widget *w, void *in) { ((UIFltk::UI*)in)->cbAboutI(); }inline void UIFltk::UI::cbAboutI(){    switch(aboutVisible)    {	case 0:            aboutWnd = new AboutWindow(350,390, this);	    aboutWnd->show();	    aboutVisible=1;	    menu[MENU_HELP_ABOUT].flags |= FL_MENU_VALUE;	    mbar->copy(&menu[0]);	    break;	case 1:	    if(aboutWnd)	    {                aboutWnd->hide();                delete aboutWnd; aboutWnd=NULL;            }	    aboutVisible=0;	    menu[MENU_HELP_ABOUT].flags &= ~FL_MENU_VALUE;	    mbar->copy(&menu[0]);	    break;    }}/*** EOF: uifltk-menu.cpp ************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -