From 2d4c021130ad0e22bbf5fd2694d3634c650adaf2 Mon Sep 17 00:00:00 2001 From: "(Tim) Efthimis Kritikos" Date: Sat, 3 Feb 2024 23:49:45 +0000 Subject: [PATCH] GUI: Added support running instead of just single stepping --- gui.c | 28 ++++++++++++++++++++++------ main.c | 5 ++++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/gui.c b/gui.c index 41c943b..8957ea6 100644 --- a/gui.c +++ b/gui.c @@ -64,7 +64,6 @@ char *tab_name[]={"Overview","Memory","Internal"}; unsigned int CURRENT_TAB=0; enum CPU_STATE_t CPU_STATE=SINGLE_STEPPING; -//enum CPU_STATE_t CPU_STATE=STOPPED; void update_tabs(){ wattron(tabs,A_BOLD); @@ -170,7 +169,7 @@ int gui_error(char *str){ } int update_general_disas(struct simdata_t *simdata){ - wclear(general_disas); + werase(general_disas); int width,height; getmaxyx(general_disas,height,width); 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){ - wclear(general_stack); int width,height; getmaxyx(general_stack,height,width); 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){ - wclear(general_memdump); int width,height; getmaxyx(general_memdump,height,width); box(general_memdump, 0 , 0); @@ -316,8 +313,13 @@ int update_general_memdump(struct simdata_t *simdata){ return 0; } +int clear_back_window=1; + int update_gui(struct simdata_t *simdata){ - clear(); + if(clear_back_window){ + clear(); + clear_back_window=0; + } update_tabs(); if(update_general_memdump(simdata)) return 1; @@ -331,8 +333,22 @@ int update_gui(struct simdata_t *simdata){ } int gui_continue_request(){ - if(getch()==ERR) + char inch; + if(((inch=getch())==ERR)&&CPU_STATE==SINGLE_STEPPING) 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; } diff --git a/main.c b/main.c index 06952dc..70bb1eb 100644 --- a/main.c +++ b/main.c @@ -159,7 +159,10 @@ int main(int argc, char* argd[] ){ while(1){ update_gui(simdata); - if(gui_continue_request()){ + int ret_code; + if((ret_code=gui_continue_request())){ + if(ret_code==2) + break; end_gui(); printf("Failed on gui_continue_request()\n"); cpu_simdata_free(simdata);