GUI: Fixed updating of tabs when switching from run to single step and visa versa, also cleaned up the relavent code a bit
This commit is contained in:
parent
e3d2a1d2c1
commit
51c8edf43f
65
gui.c
65
gui.c
@ -64,17 +64,22 @@ int get_terminal_size(){
|
|||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define OVERVIEW_TAB 1
|
||||||
|
#define MEMORY_TAB 2
|
||||||
|
#define INTERNALS_TAB 3
|
||||||
|
#define DEBUG_TAB 4
|
||||||
|
#define DISPLAY_TAB 5
|
||||||
|
|
||||||
char *tab_name[]={"Overview","Memory","Internals","Debug","Display"};
|
char *tab_name[]={"Overview","Memory","Internals","Debug","Display"};
|
||||||
|
|
||||||
unsigned int CURRENT_TAB=1;
|
unsigned int CURRENT_TAB=OVERVIEW_TAB;
|
||||||
|
|
||||||
int gui_ncurses_refresh(){
|
int gui_ncurses_refresh(){
|
||||||
if(refresh()==ERR)
|
if(refresh()==ERR)
|
||||||
return 1;
|
return 1;
|
||||||
if(wrefresh(tabs)==ERR)
|
if(wrefresh(tabs)==ERR)
|
||||||
return 1;
|
return 1;
|
||||||
if(CURRENT_TAB==1){
|
if(CURRENT_TAB==OVERVIEW_TAB){
|
||||||
if(wrefresh(general_memdump)==ERR)
|
if(wrefresh(general_memdump)==ERR)
|
||||||
return 1;
|
return 1;
|
||||||
if(wrefresh(general_stack)==ERR)
|
if(wrefresh(general_stack)==ERR)
|
||||||
@ -85,18 +90,18 @@ int gui_ncurses_refresh(){
|
|||||||
return 1;
|
return 1;
|
||||||
if(wrefresh(general_terminal_output)==ERR)
|
if(wrefresh(general_terminal_output)==ERR)
|
||||||
return 1;
|
return 1;
|
||||||
}else if(CURRENT_TAB==2){
|
}else if(CURRENT_TAB==MEMORY_TAB){
|
||||||
if(wrefresh(memory_memdump)==ERR)
|
if(wrefresh(memory_memdump)==ERR)
|
||||||
return 1;
|
return 1;
|
||||||
}else if(CURRENT_TAB==3){
|
}else if(CURRENT_TAB==INTERNALS_TAB){
|
||||||
if(wrefresh(internals_disas)==ERR)
|
if(wrefresh(internals_disas)==ERR)
|
||||||
return 1;
|
return 1;
|
||||||
if(wrefresh(internals_internals)==ERR)
|
if(wrefresh(internals_internals)==ERR)
|
||||||
return 1;
|
return 1;
|
||||||
}else if(CURRENT_TAB==4){
|
}else if(CURRENT_TAB==DEBUG_TAB){
|
||||||
if(wrefresh(debug_simdata)==ERR)
|
if(wrefresh(debug_simdata)==ERR)
|
||||||
return 1;
|
return 1;
|
||||||
}else if(CURRENT_TAB==5){
|
}else if(CURRENT_TAB==DISPLAY_TAB){
|
||||||
if(wrefresh(display_terminal_output)==ERR)
|
if(wrefresh(display_terminal_output)==ERR)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -666,7 +671,7 @@ int write_tabs=1;
|
|||||||
int update_gui(struct simdata_t *simdata){
|
int update_gui(struct simdata_t *simdata){
|
||||||
if(simdata->cpu_state==CPU_HALTED){
|
if(simdata->cpu_state==CPU_HALTED){
|
||||||
GUI_CPU_STATE=GUI_CPU_STOPPED;
|
GUI_CPU_STATE=GUI_CPU_STOPPED;
|
||||||
if(CURRENT_TAB==5)
|
if(CURRENT_TAB==DISPLAY_TAB)
|
||||||
force_disp_terminal_output_update(simdata);
|
force_disp_terminal_output_update(simdata);
|
||||||
}
|
}
|
||||||
if(clear_back_window){
|
if(clear_back_window){
|
||||||
@ -678,7 +683,7 @@ int update_gui(struct simdata_t *simdata){
|
|||||||
write_tabs=0;
|
write_tabs=0;
|
||||||
}
|
}
|
||||||
if((simdata->current_clock)%(gui_settings->cycles_per_frame)==0 || GUI_CPU_STATE!=GUI_CPU_RUNNING ){
|
if((simdata->current_clock)%(gui_settings->cycles_per_frame)==0 || GUI_CPU_STATE!=GUI_CPU_RUNNING ){
|
||||||
if(CURRENT_TAB==1){
|
if(CURRENT_TAB==OVERVIEW_TAB){
|
||||||
if(update_general_memdump(simdata))
|
if(update_general_memdump(simdata))
|
||||||
return 1;
|
return 1;
|
||||||
if(update_general_stack(simdata))
|
if(update_general_stack(simdata))
|
||||||
@ -689,23 +694,23 @@ int update_gui(struct simdata_t *simdata){
|
|||||||
return 1;
|
return 1;
|
||||||
if(update_general_terminal_output(general_terminal_output,simdata))
|
if(update_general_terminal_output(general_terminal_output,simdata))
|
||||||
return 1;
|
return 1;
|
||||||
}else if(CURRENT_TAB==2){
|
}else if(CURRENT_TAB==MEMORY_TAB){
|
||||||
if(update_memory_memdump(simdata))
|
if(update_memory_memdump(simdata))
|
||||||
return 1;
|
return 1;
|
||||||
}else if(CURRENT_TAB==3){
|
}else if(CURRENT_TAB==INTERNALS_TAB){
|
||||||
if(update_disas(internals_disas,simdata))
|
if(update_disas(internals_disas,simdata))
|
||||||
return 1;
|
return 1;
|
||||||
if(update_internals(internals_internals,simdata))
|
if(update_internals(internals_internals,simdata))
|
||||||
return 1;
|
return 1;
|
||||||
}else if(CURRENT_TAB==4){
|
}else if(CURRENT_TAB==DEBUG_TAB){
|
||||||
if(update_debug_simdata(simdata))
|
if(update_debug_simdata(simdata))
|
||||||
return 1;
|
return 1;
|
||||||
}else if(CURRENT_TAB==5){
|
}else if(CURRENT_TAB==DISPLAY_TAB){
|
||||||
if(GUI_CPU_STATE!=GUI_CPU_RUNNING)
|
if(GUI_CPU_STATE!=GUI_CPU_RUNNING)
|
||||||
force_disp_terminal_output_update(simdata);
|
force_disp_terminal_output_update(simdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CURRENT_TAB!=5)
|
if(CURRENT_TAB!=DISPLAY_TAB)
|
||||||
if(gui_ncurses_refresh())
|
if(gui_ncurses_refresh())
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -731,11 +736,15 @@ int gui_continue_request(struct simdata_t *simdata){
|
|||||||
if(simdata->cpu_state!=CPU_HALTED){
|
if(simdata->cpu_state!=CPU_HALTED){
|
||||||
if(GUI_CPU_STATE==GUI_CPU_RUNNING){
|
if(GUI_CPU_STATE==GUI_CPU_RUNNING){
|
||||||
GUI_CPU_STATE=GUI_CPU_SINGLE_STEPPING;
|
GUI_CPU_STATE=GUI_CPU_SINGLE_STEPPING;
|
||||||
if(CURRENT_TAB!=5)
|
update_tabs();
|
||||||
|
gui_ncurses_refresh();
|
||||||
|
if(CURRENT_TAB!=DISPLAY_TAB)
|
||||||
update_gui(simdata);
|
update_gui(simdata);
|
||||||
nodelay(stdscr, FALSE);
|
nodelay(stdscr, FALSE);
|
||||||
}else{
|
}else{
|
||||||
GUI_CPU_STATE=GUI_CPU_RUNNING;
|
GUI_CPU_STATE=GUI_CPU_RUNNING;
|
||||||
|
update_tabs();
|
||||||
|
gui_ncurses_refresh();
|
||||||
nodelay(stdscr, TRUE);
|
nodelay(stdscr, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -746,47 +755,47 @@ int gui_continue_request(struct simdata_t *simdata){
|
|||||||
release=1;
|
release=1;
|
||||||
break;
|
break;
|
||||||
case '1':
|
case '1':
|
||||||
if(CURRENT_TAB!=1){
|
if(CURRENT_TAB!=OVERVIEW_TAB){
|
||||||
CURRENT_TAB=1;
|
CURRENT_TAB=OVERVIEW_TAB;
|
||||||
clear();
|
clear();
|
||||||
update_tabs();
|
update_tabs();
|
||||||
update_gui(simdata);
|
update_gui(simdata);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
if(CURRENT_TAB!=2){
|
if(CURRENT_TAB!=MEMORY_TAB){
|
||||||
CURRENT_TAB=2;
|
CURRENT_TAB=MEMORY_TAB;
|
||||||
clear();
|
clear();
|
||||||
update_tabs();
|
update_tabs();
|
||||||
update_gui(simdata);
|
update_gui(simdata);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '3':
|
case '3':
|
||||||
if(CURRENT_TAB!=3){
|
if(CURRENT_TAB!=INTERNALS_TAB){
|
||||||
CURRENT_TAB=3;
|
CURRENT_TAB=INTERNALS_TAB;
|
||||||
clear();
|
clear();
|
||||||
update_tabs();
|
update_tabs();
|
||||||
update_gui(simdata);
|
update_gui(simdata);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '4':
|
case '4':
|
||||||
if(CURRENT_TAB!=4){
|
if(CURRENT_TAB!=DEBUG_TAB){
|
||||||
CURRENT_TAB=4;
|
CURRENT_TAB=DEBUG_TAB;
|
||||||
clear();
|
clear();
|
||||||
update_tabs();
|
update_tabs();
|
||||||
update_gui(simdata);
|
update_gui(simdata);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '5':
|
case '5':
|
||||||
if(CURRENT_TAB!=5){
|
if(CURRENT_TAB!=DISPLAY_TAB){
|
||||||
CURRENT_TAB=5;
|
CURRENT_TAB=DISPLAY_TAB;
|
||||||
clear();
|
clear();
|
||||||
update_tabs();
|
update_tabs();
|
||||||
force_disp_terminal_output_update(simdata);
|
force_disp_terminal_output_update(simdata);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'j':
|
case 'j':
|
||||||
if(CURRENT_TAB==2){
|
if(CURRENT_TAB==MEMORY_TAB){
|
||||||
memory_window_address++;
|
memory_window_address++;
|
||||||
if(memory_window_address==0x01000000)
|
if(memory_window_address==0x01000000)
|
||||||
memory_window_address=0x00000000;
|
memory_window_address=0x00000000;
|
||||||
@ -794,7 +803,7 @@ int gui_continue_request(struct simdata_t *simdata){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
if(CURRENT_TAB==2){
|
if(CURRENT_TAB==MEMORY_TAB){
|
||||||
memory_window_address--;
|
memory_window_address--;
|
||||||
if(memory_window_address==0xFFFFFFFF)
|
if(memory_window_address==0xFFFFFFFF)
|
||||||
memory_window_address=0x00FFFFFF;
|
memory_window_address=0x00FFFFFF;
|
||||||
@ -850,7 +859,7 @@ int clean_cpu_output(struct simdata_t *simdata){
|
|||||||
}
|
}
|
||||||
if(highest_disps<disps_found){
|
if(highest_disps<disps_found){
|
||||||
highest_disps=disps_found;
|
highest_disps=disps_found;
|
||||||
if(CURRENT_TAB==5)
|
if(CURRENT_TAB==DISPLAY_TAB)
|
||||||
force_disp_terminal_output_update(simdata);
|
force_disp_terminal_output_update(simdata);
|
||||||
}
|
}
|
||||||
if(disps_found>=2){
|
if(disps_found>=2){
|
||||||
@ -859,7 +868,7 @@ int clean_cpu_output(struct simdata_t *simdata){
|
|||||||
simdata->terminal_output[0]=0xFFFFFFFF;
|
simdata->terminal_output[0]=0xFFFFFFFF;
|
||||||
simdata->terminal_output=realloc(simdata->terminal_output,final_data_size+4);
|
simdata->terminal_output=realloc(simdata->terminal_output,final_data_size+4);
|
||||||
simdata->terminal_output_size=final_data_size+4;
|
simdata->terminal_output_size=final_data_size+4;
|
||||||
if(CURRENT_TAB==5)
|
if(CURRENT_TAB==DISPLAY_TAB)
|
||||||
force_disp_terminal_output_update(simdata);
|
force_disp_terminal_output_update(simdata);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user