Compare commits
No commits in common. "756d8a49d962bbceb67ab07f953c63982204b772" and "a5f7444733c799b273284f8c725f8a92431389e5" have entirely different histories.
756d8a49d9
...
a5f7444733
62
gui.c
62
gui.c
@ -18,8 +18,6 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <string.h>
|
||||
#include "simdata.h"
|
||||
|
||||
int terminal_width;
|
||||
int terminal_height;
|
||||
@ -45,74 +43,22 @@ int gui_ncurses_refresh(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *tab_name[]={"Overview","Memory","Test"};
|
||||
|
||||
unsigned int CURRENT_TAB=0;
|
||||
|
||||
enum CPU_STATE_t CPU_STATE=STOPPED;
|
||||
|
||||
void update_tabs(){
|
||||
wattron(tabs,COLOR_PAIR(2));
|
||||
for(int i=0;i<terminal_width;i++)
|
||||
wprintw(tabs," ");
|
||||
|
||||
int x=1;
|
||||
for(unsigned int i=0;i<sizeof(tab_name)/sizeof(tab_name[0]);i++){
|
||||
if(i==CURRENT_TAB)
|
||||
wattron(tabs,COLOR_PAIR(4));
|
||||
else
|
||||
wattron(tabs,COLOR_PAIR(5));
|
||||
mvwprintw(tabs,0,x," %1d",i);
|
||||
x+=2;
|
||||
if(i==CURRENT_TAB)
|
||||
wattron(tabs,COLOR_PAIR(3));
|
||||
else
|
||||
wattron(tabs,COLOR_PAIR(2));
|
||||
mvwprintw(tabs,0,x," %s ",tab_name[i]);
|
||||
x+=strlen(tab_name[i])+2+3;
|
||||
}
|
||||
switch(CPU_STATE){
|
||||
case RUNNING:
|
||||
wattron(tabs,COLOR_PAIR(6));
|
||||
mvwprintw(tabs,0,terminal_width-13,"[ RUNNING ");
|
||||
break;
|
||||
case SINGLE_STEPPING:
|
||||
wattron(tabs,COLOR_PAIR(7));
|
||||
mvwprintw(tabs,0,terminal_width-21,"[ SINGLE-STEPPING ");
|
||||
break;
|
||||
case STOPPED:
|
||||
wattron(tabs,COLOR_PAIR(8));
|
||||
mvwprintw(tabs,0,terminal_width-13,"[ STOPPED ");
|
||||
break;
|
||||
}
|
||||
mvwprintw(tabs,0,terminal_width-3,"]");
|
||||
}
|
||||
|
||||
int start_gui(){
|
||||
if(!initscr())
|
||||
return 1;
|
||||
monochrome=( has_colors() == FALSE );
|
||||
init_color(8, 700, 700, 700);
|
||||
init_color(COLOR_WHITE, 100, 1000, 1000);
|
||||
if(!monochrome){
|
||||
start_color();
|
||||
init_pair(1, COLOR_RED, COLOR_BLACK);
|
||||
|
||||
//tab colors
|
||||
init_pair(2, COLOR_BLACK, 8);
|
||||
init_pair(3, 8, COLOR_BLACK);
|
||||
init_pair(4, COLOR_WHITE, COLOR_BLACK);
|
||||
init_pair(5, COLOR_WHITE, 8);
|
||||
init_pair(6, COLOR_BLACK,COLOR_GREEN);
|
||||
init_pair(7, COLOR_BLACK,COLOR_YELLOW);
|
||||
init_pair(8, COLOR_BLACK,COLOR_RED);
|
||||
}
|
||||
noecho();
|
||||
curs_set(0);
|
||||
get_terminal_size();
|
||||
mvprintw((terminal_height-3)/2+3,terminal_width/2-15,"Initialising the simulator...");
|
||||
tabs = newwin(1,terminal_width,0,0);
|
||||
update_tabs();
|
||||
tabs = newwin(3,terminal_width,0,0);
|
||||
box(tabs, 0 , 0);
|
||||
mvwprintw(tabs,1,2,"[ 0 Overview ]");
|
||||
mvwprintw(tabs,1,17," 1 Memory ");
|
||||
if(gui_ncurses_refresh())
|
||||
return 1;
|
||||
return 0;
|
||||
|
12
main.c
12
main.c
@ -23,7 +23,6 @@
|
||||
#include "simdata.h"
|
||||
#include "stdint.h"
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
void help(char* progname){
|
||||
printf("Usage: %s -i <file> \n", progname);
|
||||
@ -55,13 +54,6 @@ int main(int argc, char* argd[] ){
|
||||
|
||||
/// READ ROM FILE ///
|
||||
FILE* rom=fopen(infile,"r");
|
||||
|
||||
if (rom == NULL) {
|
||||
printf("ERROR: Couldn't open rom file\n");
|
||||
perror(infile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fseek(rom, 0, SEEK_END);
|
||||
if(ftell(rom)!=16777216){
|
||||
printf("ERROR: ROM file isn't 16MiB\n");
|
||||
@ -95,6 +87,10 @@ int main(int argc, char* argd[] ){
|
||||
free(RAM);
|
||||
return 1;
|
||||
}
|
||||
char *temp=malloc(1000);
|
||||
sprintf(temp,"Last byte of ram is 0x%02x",RAM[0xFFFFFF]);
|
||||
gui_error(temp);
|
||||
free(temp);
|
||||
|
||||
if(gui_continue_request()){
|
||||
end_gui();
|
||||
|
Loading…
Reference in New Issue
Block a user