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;
|
state=0;
|
||||||
else
|
else
|
||||||
state++;
|
state++;
|
||||||
|
simdata->current_clock++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
45
gui.c
45
gui.c
@ -23,6 +23,7 @@
|
|||||||
#include "assembly.h"
|
#include "assembly.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
|
#include "gui.h"
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
#define GENERAL_STACK_MAX_WIDTH 16
|
#define GENERAL_STACK_MAX_WIDTH 16
|
||||||
@ -31,6 +32,8 @@
|
|||||||
int terminal_width;
|
int terminal_width;
|
||||||
int terminal_height;
|
int terminal_height;
|
||||||
|
|
||||||
|
struct gui_settings_t *gui_settings;
|
||||||
|
|
||||||
WINDOW *tabs;
|
WINDOW *tabs;
|
||||||
WINDOW *general_memdump;
|
WINDOW *general_memdump;
|
||||||
WINDOW *general_stack;
|
WINDOW *general_stack;
|
||||||
@ -71,7 +74,7 @@ char *tab_name[]={"Overview","Memory","Internal"};
|
|||||||
|
|
||||||
unsigned int CURRENT_TAB=0;
|
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(){
|
void update_tabs(){
|
||||||
wattron(tabs,A_BOLD);
|
wattron(tabs,A_BOLD);
|
||||||
@ -97,7 +100,7 @@ void update_tabs(){
|
|||||||
wattron(tabs,A_BOLD);
|
wattron(tabs,A_BOLD);
|
||||||
x+=strlen(tab_name[i])+2+3;
|
x+=strlen(tab_name[i])+2+3;
|
||||||
}
|
}
|
||||||
switch(CPU_STATE){
|
switch(GUI_CPU_STATE){
|
||||||
case GUI_CPU_RUNNING:
|
case GUI_CPU_RUNNING:
|
||||||
wattron(tabs,COLOR_PAIR(6));
|
wattron(tabs,COLOR_PAIR(6));
|
||||||
mvwprintw(tabs,0,terminal_width-13,"[ RUNNING ");
|
mvwprintw(tabs,0,terminal_width-13,"[ RUNNING ");
|
||||||
@ -190,6 +193,9 @@ int start_gui(){
|
|||||||
x+=terminal_width/2;
|
x+=terminal_width/2;
|
||||||
x++;
|
x++;
|
||||||
|
|
||||||
|
gui_settings=malloc(sizeof(struct gui_settings_t));
|
||||||
|
gui_settings->cycles_per_frame=100;
|
||||||
|
|
||||||
if(gui_ncurses_refresh())
|
if(gui_ncurses_refresh())
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
@ -707,22 +713,24 @@ int clear_back_window=1;
|
|||||||
|
|
||||||
int update_gui(struct simdata_t *simdata){
|
int update_gui(struct simdata_t *simdata){
|
||||||
if(simdata->cpu_state==CPU_HALTED)
|
if(simdata->cpu_state==CPU_HALTED)
|
||||||
CPU_STATE=GUI_CPU_STOPPED;
|
GUI_CPU_STATE=GUI_CPU_STOPPED;
|
||||||
if(clear_back_window){
|
if(clear_back_window){
|
||||||
clear();
|
clear();
|
||||||
clear_back_window=0;
|
clear_back_window=0;
|
||||||
}
|
}
|
||||||
update_tabs();
|
if((simdata->current_clock)%(gui_settings->cycles_per_frame)==0 || GUI_CPU_STATE!=GUI_CPU_RUNNING ){
|
||||||
if(update_general_memdump(simdata))
|
update_tabs();
|
||||||
return 1;
|
if(update_general_memdump(simdata))
|
||||||
if(update_general_stack(simdata))
|
return 1;
|
||||||
return 1;
|
if(update_general_stack(simdata))
|
||||||
if(update_general_disas(simdata))
|
return 1;
|
||||||
return 1;
|
if(update_general_disas(simdata))
|
||||||
if(update_general_registers(simdata))
|
return 1;
|
||||||
return 1;
|
if(update_general_registers(simdata))
|
||||||
if(update_general_terminal_output(simdata))
|
return 1;
|
||||||
return 1;
|
if(update_general_terminal_output(simdata))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if(gui_ncurses_refresh())
|
if(gui_ncurses_refresh())
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
@ -733,7 +741,7 @@ int gui_continue_request(struct simdata_t *simdata){
|
|||||||
int release=0;
|
int release=0;
|
||||||
while(release==0){
|
while(release==0){
|
||||||
if(((inch=getch())==ERR)){
|
if(((inch=getch())==ERR)){
|
||||||
if(CPU_STATE==GUI_CPU_SINGLE_STEPPING)
|
if(GUI_CPU_STATE==GUI_CPU_SINGLE_STEPPING)
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
release=1;
|
release=1;
|
||||||
@ -741,11 +749,12 @@ int gui_continue_request(struct simdata_t *simdata){
|
|||||||
switch(inch){
|
switch(inch){
|
||||||
case 'r':
|
case 'r':
|
||||||
if(simdata->cpu_state!=CPU_HALTED){
|
if(simdata->cpu_state!=CPU_HALTED){
|
||||||
if(CPU_STATE==GUI_CPU_RUNNING){
|
if(GUI_CPU_STATE==GUI_CPU_RUNNING){
|
||||||
CPU_STATE=GUI_CPU_SINGLE_STEPPING;
|
GUI_CPU_STATE=GUI_CPU_SINGLE_STEPPING;
|
||||||
|
update_gui(simdata);
|
||||||
nodelay(stdscr, FALSE);
|
nodelay(stdscr, FALSE);
|
||||||
}else{
|
}else{
|
||||||
CPU_STATE=GUI_CPU_RUNNING;
|
GUI_CPU_STATE=GUI_CPU_RUNNING;
|
||||||
nodelay(stdscr, TRUE);
|
nodelay(stdscr, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user