From 41fed482fec495348efec64653deeea01cd492b2 Mon Sep 17 00:00:00 2001 From: "(Tim) Efthimis Kritikos" Date: Mon, 12 Feb 2024 15:15:54 +0000 Subject: [PATCH] GUI: Added display of PC and SP to the registers window --- gui.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/gui.c b/gui.c index 207a444..7e17326 100644 --- a/gui.c +++ b/gui.c @@ -455,9 +455,13 @@ int update_general_registers(struct simdata_t *simdata){ else{ int center_x_offset=((width-2)-35*per_line)/2; int lines_used=(8/(int)per_line<8/(float)per_line)?8/per_line+1:8/per_line; - int center_y_offset=((height-2)-(lines_used+2))/2; - if((lines_used+2)>(height-2)||width<37) + int lines_for_special_registers; + lines_for_special_registers=( width < 22+27+8 )?2:1; + + int center_y_offset=((height-2)-(lines_used+lines_for_special_registers+1))/2; + + if((lines_used+lines_for_special_registers+1)>(height-2)||width<37) mvwprintw(general_registers,1,1,"too small window"); else{ int n=0,y=0; @@ -478,8 +482,28 @@ int update_general_registers(struct simdata_t *simdata){ for(int i=0;i<35*per_line;i++) mvwaddch(general_registers,1+center_y_offset+lines_used,center_x_offset+i,ACS_HLINE); + int spec_reg_1_offset, spec_reg_2_offset; + + if(lines_for_special_registers==2){ + spec_reg_1_offset=((width-2)/2)-(23/2); + spec_reg_2_offset=((width-2)/2)-(27/2); + }else{ + spec_reg_1_offset=((width-2)/2)-(22+27+8)/2; + spec_reg_2_offset=spec_reg_1_offset+22+8; + } + wattron(general_registers,A_BOLD); - mvwprintw(general_registers,1+center_y_offset+lines_used+1,1+center_x_offset," ZERO"); + mvwprintw(general_registers,1+center_y_offset+lines_used+1,spec_reg_1_offset," PC"); + wattroff(general_registers,A_BOLD); + wprintw(general_registers,": %06X ",simdata->registers->PC); + + wattron(general_registers,A_BOLD); + wprintw(general_registers,"SP"); + wattroff(general_registers,A_BOLD); + wprintw(general_registers,": %06X ",simdata->registers->SP); + + wattron(general_registers,A_BOLD); + mvwprintw(general_registers,center_y_offset+lines_used+1+lines_for_special_registers,spec_reg_2_offset," ZERO"); wattroff(general_registers,A_BOLD); wprintw(general_registers,": %c ",(simdata->registers->FLAGS&1)?'1':'0');