GUI: Added an option to run multiple cycles per frame when in run mode so that the bottleneck isn't the terminal as much
This commit is contained in:
parent
519c762287
commit
8f817a17b7
1
cpu.c
1
cpu.c
@ -452,6 +452,7 @@ int cpu_cycle_clock(struct simdata_t *simdata){
|
||||
state=0;
|
||||
else
|
||||
state++;
|
||||
simdata->current_clock++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
23
gui.c
23
gui.c
@ -23,6 +23,7 @@
|
||||
#include "assembly.h"
|
||||
#include <stdlib.h>
|
||||
#include "cpu.h"
|
||||
#include "gui.h"
|
||||
#include <locale.h>
|
||||
|
||||
#define GENERAL_STACK_MAX_WIDTH 16
|
||||
@ -31,6 +32,8 @@
|
||||
int terminal_width;
|
||||
int terminal_height;
|
||||
|
||||
struct gui_settings_t *gui_settings;
|
||||
|
||||
WINDOW *tabs;
|
||||
WINDOW *general_memdump;
|
||||
WINDOW *general_stack;
|
||||
@ -71,7 +74,7 @@ char *tab_name[]={"Overview","Memory","Internal"};
|
||||
|
||||
unsigned int CURRENT_TAB=0;
|
||||
|
||||
enum GUI_CPU_STATE_t CPU_STATE=GUI_CPU_SINGLE_STEPPING;
|
||||
enum GUI_CPU_STATE_t GUI_CPU_STATE=GUI_CPU_SINGLE_STEPPING;
|
||||
|
||||
void update_tabs(){
|
||||
wattron(tabs,A_BOLD);
|
||||
@ -97,7 +100,7 @@ void update_tabs(){
|
||||
wattron(tabs,A_BOLD);
|
||||
x+=strlen(tab_name[i])+2+3;
|
||||
}
|
||||
switch(CPU_STATE){
|
||||
switch(GUI_CPU_STATE){
|
||||
case GUI_CPU_RUNNING:
|
||||
wattron(tabs,COLOR_PAIR(6));
|
||||
mvwprintw(tabs,0,terminal_width-13,"[ RUNNING ");
|
||||
@ -190,6 +193,9 @@ int start_gui(){
|
||||
x+=terminal_width/2;
|
||||
x++;
|
||||
|
||||
gui_settings=malloc(sizeof(struct gui_settings_t));
|
||||
gui_settings->cycles_per_frame=100;
|
||||
|
||||
if(gui_ncurses_refresh())
|
||||
return 1;
|
||||
return 0;
|
||||
@ -707,11 +713,12 @@ int clear_back_window=1;
|
||||
|
||||
int update_gui(struct simdata_t *simdata){
|
||||
if(simdata->cpu_state==CPU_HALTED)
|
||||
CPU_STATE=GUI_CPU_STOPPED;
|
||||
GUI_CPU_STATE=GUI_CPU_STOPPED;
|
||||
if(clear_back_window){
|
||||
clear();
|
||||
clear_back_window=0;
|
||||
}
|
||||
if((simdata->current_clock)%(gui_settings->cycles_per_frame)==0 || GUI_CPU_STATE!=GUI_CPU_RUNNING ){
|
||||
update_tabs();
|
||||
if(update_general_memdump(simdata))
|
||||
return 1;
|
||||
@ -723,6 +730,7 @@ int update_gui(struct simdata_t *simdata){
|
||||
return 1;
|
||||
if(update_general_terminal_output(simdata))
|
||||
return 1;
|
||||
}
|
||||
if(gui_ncurses_refresh())
|
||||
return 1;
|
||||
return 0;
|
||||
@ -733,7 +741,7 @@ int gui_continue_request(struct simdata_t *simdata){
|
||||
int release=0;
|
||||
while(release==0){
|
||||
if(((inch=getch())==ERR)){
|
||||
if(CPU_STATE==GUI_CPU_SINGLE_STEPPING)
|
||||
if(GUI_CPU_STATE==GUI_CPU_SINGLE_STEPPING)
|
||||
return 1;
|
||||
else
|
||||
release=1;
|
||||
@ -741,11 +749,12 @@ int gui_continue_request(struct simdata_t *simdata){
|
||||
switch(inch){
|
||||
case 'r':
|
||||
if(simdata->cpu_state!=CPU_HALTED){
|
||||
if(CPU_STATE==GUI_CPU_RUNNING){
|
||||
CPU_STATE=GUI_CPU_SINGLE_STEPPING;
|
||||
if(GUI_CPU_STATE==GUI_CPU_RUNNING){
|
||||
GUI_CPU_STATE=GUI_CPU_SINGLE_STEPPING;
|
||||
update_gui(simdata);
|
||||
nodelay(stdscr, FALSE);
|
||||
}else{
|
||||
CPU_STATE=GUI_CPU_RUNNING;
|
||||
GUI_CPU_STATE=GUI_CPU_RUNNING;
|
||||
nodelay(stdscr, TRUE);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user