GUI: Added support running instead of just single stepping

This commit is contained in:
(Tim) Efthimis Kritikos 2024-02-03 23:49:45 +00:00
parent 5595ea91f2
commit 2d4c021130
2 changed files with 26 additions and 7 deletions

28
gui.c
View File

@ -64,7 +64,6 @@ char *tab_name[]={"Overview","Memory","Internal"};
unsigned int CURRENT_TAB=0; unsigned int CURRENT_TAB=0;
enum CPU_STATE_t CPU_STATE=SINGLE_STEPPING; enum CPU_STATE_t CPU_STATE=SINGLE_STEPPING;
//enum CPU_STATE_t CPU_STATE=STOPPED;
void update_tabs(){ void update_tabs(){
wattron(tabs,A_BOLD); wattron(tabs,A_BOLD);
@ -170,7 +169,7 @@ int gui_error(char *str){
} }
int update_general_disas(struct simdata_t *simdata){ int update_general_disas(struct simdata_t *simdata){
wclear(general_disas); werase(general_disas);
int width,height; int width,height;
getmaxyx(general_disas,height,width); getmaxyx(general_disas,height,width);
box(general_disas, 0 , 0); box(general_disas, 0 , 0);
@ -220,7 +219,6 @@ int update_general_disas(struct simdata_t *simdata){
} }
int update_general_stack(struct simdata_t *simdata){ int update_general_stack(struct simdata_t *simdata){
wclear(general_stack);
int width,height; int width,height;
getmaxyx(general_stack,height,width); getmaxyx(general_stack,height,width);
box(general_stack, 0 , 0); box(general_stack, 0 , 0);
@ -277,7 +275,6 @@ int update_general_stack(struct simdata_t *simdata){
} }
int update_general_memdump(struct simdata_t *simdata){ int update_general_memdump(struct simdata_t *simdata){
wclear(general_memdump);
int width,height; int width,height;
getmaxyx(general_memdump,height,width); getmaxyx(general_memdump,height,width);
box(general_memdump, 0 , 0); box(general_memdump, 0 , 0);
@ -316,8 +313,13 @@ int update_general_memdump(struct simdata_t *simdata){
return 0; return 0;
} }
int clear_back_window=1;
int update_gui(struct simdata_t *simdata){ int update_gui(struct simdata_t *simdata){
clear(); if(clear_back_window){
clear();
clear_back_window=0;
}
update_tabs(); update_tabs();
if(update_general_memdump(simdata)) if(update_general_memdump(simdata))
return 1; return 1;
@ -331,8 +333,22 @@ int update_gui(struct simdata_t *simdata){
} }
int gui_continue_request(){ int gui_continue_request(){
if(getch()==ERR) char inch;
if(((inch=getch())==ERR)&&CPU_STATE==SINGLE_STEPPING)
return 1; return 1;
switch(inch){
case 'r':
if(CPU_STATE==RUNNING){
CPU_STATE=SINGLE_STEPPING;
nodelay(stdscr, FALSE);
}else{
CPU_STATE=RUNNING;
nodelay(stdscr, TRUE);
}
break;
case 'q':
return 2;
}
return 0; return 0;
} }

5
main.c
View File

@ -159,7 +159,10 @@ int main(int argc, char* argd[] ){
while(1){ while(1){
update_gui(simdata); update_gui(simdata);
if(gui_continue_request()){ int ret_code;
if((ret_code=gui_continue_request())){
if(ret_code==2)
break;
end_gui(); end_gui();
printf("Failed on gui_continue_request()\n"); printf("Failed on gui_continue_request()\n");
cpu_simdata_free(simdata); cpu_simdata_free(simdata);