From 51c8edf43ffd5f9c4d06cf261339cf6ad5be1cfa Mon Sep 17 00:00:00 2001 From: "(Tim) Efthimis Kritikos" Date: Sat, 9 Mar 2024 20:13:53 +0000 Subject: [PATCH] GUI: Fixed updating of tabs when switching from run to single step and visa versa, also cleaned up the relavent code a bit --- gui.c | 65 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/gui.c b/gui.c index 53ce0f8..5761b52 100644 --- a/gui.c +++ b/gui.c @@ -64,17 +64,22 @@ int get_terminal_size(){ 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"}; -unsigned int CURRENT_TAB=1; +unsigned int CURRENT_TAB=OVERVIEW_TAB; int gui_ncurses_refresh(){ if(refresh()==ERR) return 1; if(wrefresh(tabs)==ERR) return 1; - if(CURRENT_TAB==1){ + if(CURRENT_TAB==OVERVIEW_TAB){ if(wrefresh(general_memdump)==ERR) return 1; if(wrefresh(general_stack)==ERR) @@ -85,18 +90,18 @@ int gui_ncurses_refresh(){ return 1; if(wrefresh(general_terminal_output)==ERR) return 1; - }else if(CURRENT_TAB==2){ + }else if(CURRENT_TAB==MEMORY_TAB){ if(wrefresh(memory_memdump)==ERR) return 1; - }else if(CURRENT_TAB==3){ + }else if(CURRENT_TAB==INTERNALS_TAB){ if(wrefresh(internals_disas)==ERR) return 1; if(wrefresh(internals_internals)==ERR) return 1; - }else if(CURRENT_TAB==4){ + }else if(CURRENT_TAB==DEBUG_TAB){ if(wrefresh(debug_simdata)==ERR) return 1; - }else if(CURRENT_TAB==5){ + }else if(CURRENT_TAB==DISPLAY_TAB){ if(wrefresh(display_terminal_output)==ERR) return 1; } @@ -666,7 +671,7 @@ int write_tabs=1; int update_gui(struct simdata_t *simdata){ if(simdata->cpu_state==CPU_HALTED){ GUI_CPU_STATE=GUI_CPU_STOPPED; - if(CURRENT_TAB==5) + if(CURRENT_TAB==DISPLAY_TAB) force_disp_terminal_output_update(simdata); } if(clear_back_window){ @@ -678,7 +683,7 @@ int update_gui(struct simdata_t *simdata){ write_tabs=0; } 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)) return 1; if(update_general_stack(simdata)) @@ -689,23 +694,23 @@ int update_gui(struct simdata_t *simdata){ return 1; if(update_general_terminal_output(general_terminal_output,simdata)) return 1; - }else if(CURRENT_TAB==2){ + }else if(CURRENT_TAB==MEMORY_TAB){ if(update_memory_memdump(simdata)) return 1; - }else if(CURRENT_TAB==3){ + }else if(CURRENT_TAB==INTERNALS_TAB){ if(update_disas(internals_disas,simdata)) return 1; if(update_internals(internals_internals,simdata)) return 1; - }else if(CURRENT_TAB==4){ + }else if(CURRENT_TAB==DEBUG_TAB){ if(update_debug_simdata(simdata)) return 1; - }else if(CURRENT_TAB==5){ + }else if(CURRENT_TAB==DISPLAY_TAB){ if(GUI_CPU_STATE!=GUI_CPU_RUNNING) force_disp_terminal_output_update(simdata); } - if(CURRENT_TAB!=5) + if(CURRENT_TAB!=DISPLAY_TAB) if(gui_ncurses_refresh()) return 1; } @@ -731,11 +736,15 @@ int gui_continue_request(struct simdata_t *simdata){ if(simdata->cpu_state!=CPU_HALTED){ if(GUI_CPU_STATE==GUI_CPU_RUNNING){ GUI_CPU_STATE=GUI_CPU_SINGLE_STEPPING; - if(CURRENT_TAB!=5) + update_tabs(); + gui_ncurses_refresh(); + if(CURRENT_TAB!=DISPLAY_TAB) update_gui(simdata); nodelay(stdscr, FALSE); }else{ GUI_CPU_STATE=GUI_CPU_RUNNING; + update_tabs(); + gui_ncurses_refresh(); nodelay(stdscr, TRUE); } } @@ -746,47 +755,47 @@ int gui_continue_request(struct simdata_t *simdata){ release=1; break; case '1': - if(CURRENT_TAB!=1){ - CURRENT_TAB=1; + if(CURRENT_TAB!=OVERVIEW_TAB){ + CURRENT_TAB=OVERVIEW_TAB; clear(); update_tabs(); update_gui(simdata); } break; case '2': - if(CURRENT_TAB!=2){ - CURRENT_TAB=2; + if(CURRENT_TAB!=MEMORY_TAB){ + CURRENT_TAB=MEMORY_TAB; clear(); update_tabs(); update_gui(simdata); } break; case '3': - if(CURRENT_TAB!=3){ - CURRENT_TAB=3; + if(CURRENT_TAB!=INTERNALS_TAB){ + CURRENT_TAB=INTERNALS_TAB; clear(); update_tabs(); update_gui(simdata); } break; case '4': - if(CURRENT_TAB!=4){ - CURRENT_TAB=4; + if(CURRENT_TAB!=DEBUG_TAB){ + CURRENT_TAB=DEBUG_TAB; clear(); update_tabs(); update_gui(simdata); } break; case '5': - if(CURRENT_TAB!=5){ - CURRENT_TAB=5; + if(CURRENT_TAB!=DISPLAY_TAB){ + CURRENT_TAB=DISPLAY_TAB; clear(); update_tabs(); force_disp_terminal_output_update(simdata); } break; case 'j': - if(CURRENT_TAB==2){ + if(CURRENT_TAB==MEMORY_TAB){ memory_window_address++; if(memory_window_address==0x01000000) memory_window_address=0x00000000; @@ -794,7 +803,7 @@ int gui_continue_request(struct simdata_t *simdata){ } break; case 'k': - if(CURRENT_TAB==2){ + if(CURRENT_TAB==MEMORY_TAB){ memory_window_address--; if(memory_window_address==0xFFFFFFFF) memory_window_address=0x00FFFFFF; @@ -850,7 +859,7 @@ int clean_cpu_output(struct simdata_t *simdata){ } if(highest_disps=2){ @@ -859,7 +868,7 @@ int clean_cpu_output(struct simdata_t *simdata){ simdata->terminal_output[0]=0xFFFFFFFF; simdata->terminal_output=realloc(simdata->terminal_output,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); } return 0;