GUI: Added basic support for freeing up unused parts of the cpu output buffer
This commit is contained in:
parent
0b9be7aaa6
commit
9f987da7a6
53
gui.c
53
gui.c
@ -784,11 +784,15 @@ int update_debug_simdata(struct simdata_t *simdata){
|
|||||||
mvwprintw(debug_simdata,1,1,"simdata->terminal_output_size: ");
|
mvwprintw(debug_simdata,1,1,"simdata->terminal_output_size: ");
|
||||||
if(simdata->terminal_output_size<100*1024)
|
if(simdata->terminal_output_size<100*1024)
|
||||||
wattron(debug_simdata,COLOR_PAIR(11));
|
wattron(debug_simdata,COLOR_PAIR(11));
|
||||||
|
else if (simdata->terminal_output_size<500*1024)
|
||||||
|
wattron(debug_simdata,COLOR_PAIR(10));
|
||||||
else
|
else
|
||||||
wattron(debug_simdata,COLOR_PAIR(15));
|
wattron(debug_simdata,COLOR_PAIR(15));
|
||||||
wprintw(debug_simdata,"%d%s",term_size,term_size_unit);
|
wprintw(debug_simdata,"%d%s",term_size,term_size_unit);
|
||||||
if(simdata->terminal_output_size<100*1024)
|
if(simdata->terminal_output_size<100*1024)
|
||||||
wattroff(debug_simdata,COLOR_PAIR(11));
|
wattroff(debug_simdata,COLOR_PAIR(11));
|
||||||
|
else if (simdata->terminal_output_size<500*1024)
|
||||||
|
wattroff(debug_simdata,COLOR_PAIR(10));
|
||||||
else
|
else
|
||||||
wattroff(debug_simdata,COLOR_PAIR(15));
|
wattroff(debug_simdata,COLOR_PAIR(15));
|
||||||
if(height==3)
|
if(height==3)
|
||||||
@ -972,6 +976,55 @@ int gui_continue_request(struct simdata_t *simdata){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int clean_cpu_output(struct simdata_t *simdata){
|
||||||
|
uint32_t last_vect_disp=0;
|
||||||
|
uint32_t second_last_vect_disp=simdata->terminal_output_size/4;//TODO: I shouldn't have to initialise this. GCC gives a warning erroneously
|
||||||
|
int vector=0;
|
||||||
|
int vstate=0;
|
||||||
|
uint32_t disps_found=0;
|
||||||
|
if(!simdata)
|
||||||
|
return 0;
|
||||||
|
for(uint64_t i=0;i < simdata->terminal_output_size/4;i++){
|
||||||
|
uint32_t c=simdata->terminal_output[i];
|
||||||
|
if(vector){
|
||||||
|
switch(vstate){
|
||||||
|
case 0: /*start of line*/
|
||||||
|
if(c==0x00000001)
|
||||||
|
vector=0;
|
||||||
|
else if(c==0x00000003){
|
||||||
|
second_last_vect_disp=last_vect_disp;
|
||||||
|
last_vect_disp=i*4;
|
||||||
|
disps_found++;
|
||||||
|
}else
|
||||||
|
vstate++;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
vstate++;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
vstate=0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
switch(c){
|
||||||
|
case 0xffffffff:
|
||||||
|
vector=1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(disps_found>=2){
|
||||||
|
int final_data_size=simdata->terminal_output_size-(second_last_vect_disp+4);
|
||||||
|
memmove((uint8_t*)simdata->terminal_output+4,(uint8_t*)simdata->terminal_output+simdata->terminal_output_size-final_data_size,final_data_size);
|
||||||
|
simdata->terminal_output[0]=0xFFFFFFFF;
|
||||||
|
simdata->terminal_output=realloc(simdata->terminal_output,final_data_size+4);
|
||||||
|
simdata->terminal_output_size=final_data_size+4;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int end_gui(){
|
int end_gui(){
|
||||||
if(endwin()==ERR)
|
if(endwin()==ERR)
|
||||||
return 1;
|
return 1;
|
||||||
|
1
gui.h
1
gui.h
@ -5,6 +5,7 @@ int gui_continue_request(struct simdata_t*);
|
|||||||
int end_gui();
|
int end_gui();
|
||||||
int gui_error(char *);
|
int gui_error(char *);
|
||||||
int update_gui(struct simdata_t *);
|
int update_gui(struct simdata_t *);
|
||||||
|
int clean_cpu_output(struct simdata_t *simdata);
|
||||||
|
|
||||||
struct gui_settings_t{
|
struct gui_settings_t{
|
||||||
uint8_t cycles_per_frame;
|
uint8_t cycles_per_frame;
|
||||||
|
10
simdata.c
10
simdata.c
@ -20,6 +20,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "simdata.h"
|
#include "simdata.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "gui.h" // for cleaning the cpu output
|
||||||
|
|
||||||
struct simdata_t *init_simdata(){
|
struct simdata_t *init_simdata(){
|
||||||
struct simdata_t * ret=malloc(sizeof(struct simdata_t));
|
struct simdata_t * ret=malloc(sizeof(struct simdata_t));
|
||||||
@ -47,12 +48,17 @@ struct simdata_t *init_simdata(){
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t output_counter=0;
|
||||||
|
|
||||||
int terminal_output(uint32_t c,struct simdata_t *simdata){
|
int terminal_output(uint32_t c,struct simdata_t *simdata){
|
||||||
simdata->terminal_output=realloc(simdata->terminal_output,simdata->terminal_output_size+4);
|
simdata->terminal_output=realloc(simdata->terminal_output,simdata->terminal_output_size+4);
|
||||||
if(!simdata->terminal_output)
|
if(!simdata->terminal_output)
|
||||||
return 1;
|
return 1;
|
||||||
*(uint32_t*)(simdata->terminal_output+simdata->terminal_output_size/4)=c;
|
simdata->terminal_output[simdata->terminal_output_size/4]=c;
|
||||||
simdata->terminal_output_size+=4;
|
simdata->terminal_output_size=simdata->terminal_output_size+4;
|
||||||
|
output_counter++;
|
||||||
|
if((output_counter%100)==0)
|
||||||
|
clean_cpu_output(simdata);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user