/* gui.c This file is part of the "First" CPU simulator project. Copyright (c) 2024 Efthymios Kritikos This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include "simdata.h" int terminal_width; int terminal_height; WINDOW *tabs; WINDOW *general_memdump; int monochrome; int get_terminal_size(){ int new_height,new_width; getmaxyx(stdscr,new_height,new_width); int changed=(new_width!=terminal_width)||(new_height!=terminal_height); terminal_width=new_width; terminal_height=new_height; return changed; } int gui_ncurses_refresh(){ if(refresh()==ERR) return 1; if(wrefresh(tabs)==ERR) return 1; if(wrefresh(general_memdump)==ERR) return 1; return 0; } 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,COLOR_PAIR(2)); for(int i=0;iPC-n*usable_height/2)&0x00FFFFFF; for(int h=0;hRAM[ADDRESS]); ADDRESS=(ADDRESS+1)&0xFFFFFF; } ADDRESS=temp_address; for (int i=0;iRAM[ADDRESS]>=0x20&&simdata->RAM[ADDRESS]<0x7F)?simdata->RAM[ADDRESS]:'.'); ADDRESS=(ADDRESS+1)&0xFFFFFF; } } } return 0; } int update_gui(struct simdata_t *simdata){ clear(); update_tabs(); if(update_general_memdump(simdata)) return 1; if(gui_ncurses_refresh()) return 1; return 0; } int gui_continue_request(){ if(getch()==ERR) return 1; return 0; } int end_gui(){ if(endwin()==ERR) return 1; return 0; }