GUI: small improvements to the hex dump window

This commit is contained in:
(Tim) Efthimis Kritikos 2024-01-23 23:56:40 +00:00
parent 988b6802bb
commit ee6481e9de
3 changed files with 9 additions and 4 deletions

10
gui.c
View File

@ -147,9 +147,11 @@ int update_general_memdump(struct simdata_t *simdata){
if(width<16){ if(width<16){
mvwprintw(general_memdump,1,1,"too small window"); mvwprintw(general_memdump,1,1,"too small window");
}else{ }else{
int n=(width-12)/4; int n=(width-12)/4; // bytes in each line
uint32_t ADDRESS=0; int usable_height=height-3-(width-12)%2;
for(int h=0;h<height-3;h++){
uint32_t ADDRESS=(simdata->PC-n*usable_height/2)&0x00FFFFFF;
for(int h=0;h<usable_height;h++){
wmove(general_memdump,h+2,2+(width-12)%2); wmove(general_memdump,h+2,2+(width-12)%2);
wprintw(general_memdump,"%06x ",ADDRESS); wprintw(general_memdump,"%06x ",ADDRESS);
uint32_t temp_address=ADDRESS; uint32_t temp_address=ADDRESS;
@ -157,7 +159,7 @@ int update_general_memdump(struct simdata_t *simdata){
wprintw(general_memdump,"%02x ",simdata->RAM[temp_address++]); wprintw(general_memdump,"%02x ",simdata->RAM[temp_address++]);
for (int i=0;i<n;i++){ for (int i=0;i<n;i++){
wprintw(general_memdump,"%c",(simdata->RAM[ADDRESS]>=0x20&&simdata->RAM[ADDRESS]<0x7F)?simdata->RAM[ADDRESS]:'.'); wprintw(general_memdump,"%c",(simdata->RAM[ADDRESS]>=0x20&&simdata->RAM[ADDRESS]<0x7F)?simdata->RAM[ADDRESS]:'.');
ADDRESS++; ADDRESS=(ADDRESS+1)&0xFFFFFF;
} }
} }
} }

View File

@ -36,6 +36,8 @@ struct simdata_t *init_simdata(){
return 0; return 0;
} }
ret->PC=0;
return ret; return ret;
} }

View File

@ -4,6 +4,7 @@
struct simdata_t{ struct simdata_t{
long unsigned int current_clock; long unsigned int current_clock;
uint8_t *RAM; uint8_t *RAM;
uint32_t PC;
}; };
struct simdata_t *init_simdata(); struct simdata_t *init_simdata();