#include "config.h" #include #include "simdata.h" #include #include #include "gui.h" #include "gui_display.h" #ifdef USE_AALIB #include #endif int term_curs_x,term_curs_y; /////////////////////////////////////////////// //// Braille code /////////////////////////////////////////////// wchar_t braille_lookup[256]={ L'⠀',L'⠁',L'⠂',L'⠃',L'⠄',L'⠅',L'⠆',L'⠇',L'⠈',L'⠉',L'⠊',L'⠋',L'⠌',L'⠍',L'⠎',L'⠏',L'⠐',L'⠑',L'⠒',L'⠓',L'⠔',L'⠕',L'⠖',L'⠗',L'⠘',L'⠙',L'⠚',L'⠛',L'⠜',L'⠝',L'⠞',L'⠟', L'⠠',L'⠡',L'⠢',L'⠣',L'⠤',L'⠥',L'⠦',L'⠧',L'⠨',L'⠩',L'⠪',L'⠫',L'⠬',L'⠭',L'⠮',L'⠯',L'⠰',L'⠱',L'⠲',L'⠳',L'⠴',L'⠵',L'⠶',L'⠷',L'⠸',L'⠹',L'⠺',L'⠻',L'⠼',L'⠽',L'⠾',L'⠿', L'⡀',L'⡁',L'⡂',L'⡃',L'⡄',L'⡅',L'⡆',L'⡇',L'⡈',L'⡉',L'⡊',L'⡋',L'⡌',L'⡍',L'⡎',L'⡏',L'⡐',L'⡑',L'⡒',L'⡓',L'⡔',L'⡕',L'⡖',L'⡗',L'⡘',L'⡙',L'⡚',L'⡛',L'⡜',L'⡝',L'⡞',L'⡟',L'⡠',L'⡡',L'⡢',L'⡣',L'⡤',L'⡥',L'⡦',L'⡧',L'⡨',L'⡩',L'⡪',L'⡫',L'⡬',L'⡭',L'⡮',L'⡯',L'⡰',L'⡱',L'⡲',L'⡳',L'⡴',L'⡵',L'⡶',L'⡷',L'⡸',L'⡹',L'⡺',L'⡻',L'⡼',L'⡽',L'⡾',L'⡿', L'⢀',L'⢁',L'⢂',L'⢃',L'⢄',L'⢅',L'⢆',L'⢇',L'⢈',L'⢉',L'⢊',L'⢋',L'⢌',L'⢍',L'⢎',L'⢏',L'⢐',L'⢑',L'⢒',L'⢓',L'⢔',L'⢕',L'⢖',L'⢗',L'⢘',L'⢙',L'⢚',L'⢛',L'⢜',L'⢝',L'⢞',L'⢟',L'⢠',L'⢡',L'⢢',L'⢣',L'⢤',L'⢥',L'⢦',L'⢧',L'⢨',L'⢩',L'⢪',L'⢫',L'⢬',L'⢭',L'⢮',L'⢯',L'⢰',L'⢱',L'⢲',L'⢳',L'⢴',L'⢵',L'⢶',L'⢷',L'⢸',L'⢹',L'⢺',L'⢻',L'⢼',L'⢽',L'⢾',L'⢿', L'⣀',L'⣁',L'⣂',L'⣃',L'⣄',L'⣅',L'⣆',L'⣇',L'⣈',L'⣉',L'⣊',L'⣋',L'⣌',L'⣍',L'⣎',L'⣏',L'⣐',L'⣑',L'⣒',L'⣓',L'⣔',L'⣕',L'⣖',L'⣗',L'⣘',L'⣙',L'⣚',L'⣛',L'⣜',L'⣝',L'⣞',L'⣟',L'⣠',L'⣡',L'⣢',L'⣣',L'⣤',L'⣥',L'⣦',L'⣧',L'⣨',L'⣩',L'⣪',L'⣫',L'⣬',L'⣭',L'⣮',L'⣯',L'⣰',L'⣱',L'⣲',L'⣳',L'⣴',L'⣵',L'⣶',L'⣷',L'⣸',L'⣹',L'⣺',L'⣻',L'⣼',L'⣽',L'⣾',L'⣿', }; int print_braille_frame_buffer(WINDOW* win,uint8_t *buffer,int width,int height,int fullscreen){ for(int h=0;hdy ? dx : -dy)/2, e2; uint32_t addr; for(;;){ addr=x0+y0*buffer_width; if(addr>0&&addr<(uint64_t)(buffer_width*buffer_height)&&x00) buffer[addr]=1; if (x0==x1 && y0==y1) break; e2 = err; if (e2 >-dx) { err -= dy; x0 += sx; } if (e2 < dy) { err += dx; y0 += sy; } } } int update_terminal_output(WINDOW *win, struct simdata_t *simdata,uint8_t fullscreen){ int width,height; werase(win); getmaxyx(win,height,width); term_curs_x=0; term_curs_y=0; int vector=0; int vstate=0; init(win,fullscreen); int vfb_width, vfb_height; #ifdef USE_AALIB if(selected_fb_driver==FB_AALIB){ vfb_width=aa_imgwidth(aactx); vfb_height=aa_imgheight(aactx); }else #endif vfb_width=braille_width,vfb_height=braille_height; uint8_t* vector_working_frame_buffer=malloc(vfb_height*vfb_width); uint8_t* vector_display_frame_buffer=malloc(vfb_height*vfb_width); memset(vector_working_frame_buffer,0,vfb_height*vfb_width); memset(vector_display_frame_buffer,0,vfb_height*vfb_width); float x0,y0,x1,y1; 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==0x00000002) memset(vector_working_frame_buffer,0,vfb_height*vfb_width); else if(c==0x00000003) memcpy(vector_display_frame_buffer,vector_working_frame_buffer,vfb_height*vfb_width); else vstate++; break; case 1: /*x of start*/ x0=uint32_to_ieee754_float(c); vstate++; break; case 2: /*y of start*/ y0=uint32_to_ieee754_float(c); vstate++; break; case 3: /*x of end*/ x1=uint32_to_ieee754_float(c); vstate++; break; case 4: /*y of end*/ y1=uint32_to_ieee754_float(c); float min_dim=(vfb_width>vfb_height)?vfb_height:vfb_width; int xoff=0,yoff=0; x0*=get_aspec_ratio(); x1*=get_aspec_ratio(); if(vfb_width>vfb_height) xoff=(vfb_width-vfb_height)/2; else yoff=(vfb_height-vfb_width)/2; braille_frame_buffer_line(vector_working_frame_buffer,vfb_width,vfb_height,xoff+(x0+1)*(min_dim/2),yoff+(y0+1)*(min_dim/2),xoff+(x1+1)*(min_dim/2),yoff+(y1+1)*(min_dim/2)); vstate=0; break; } }else{ if(c>=' '&&c<='~'){ mvwprintw(win,term_curs_y+1,term_curs_x+1,"%c",c); term_curs_x++; if(term_curs_x>=width){ term_curs_x=0; term_curs_y++; } if(term_curs_y>=height){ wscrl(win,1); term_curs_y--; for(int i=0;i=vfb_height){ wscrl(win,1); term_curs_y--; box(win, 0 , 0); mvwprintw(win,0,width/2-7,"[ TERM OUTPUT ]"); } break; default: werase(win); box(win, 0 , 0); mvwprintw(win,0,width/2-7,"[ TERM OUTPUT ]"); mvwprintw(win,1,1,"Invalid output"); return 0; } } } } if(!fullscreen){ box(win, 0 , 0); if(!vector){ mvwchgat(win,term_curs_y+1,term_curs_x+1, 1, A_REVERSE, 0, NULL); mvwprintw(win,0,width/2-7,"[ TERM OUTPUT ]"); }else{ mvwprintw(win,0,width/2-9,"[ VECTOR DISPLAY ]"); } }else if(!vector){ mvwchgat(win,term_curs_y,term_curs_x, 1, A_REVERSE, 0, NULL); } if(vector) print_frame_buffer(win,vector_display_frame_buffer,vfb_width,vfb_height,fullscreen); free(vector_working_frame_buffer); free(vector_display_frame_buffer); # ifdef USE_AALIB if(selected_fb_driver==FB_AALIB) clean_aalib(); else #endif clean_braille(); return 0; } int update_general_terminal_output(WINDOW *win, struct simdata_t *simdata){ return update_terminal_output(win,simdata,0); } int update_display_terminal_output(WINDOW *win, struct simdata_t *simdata){ return update_terminal_output(win,simdata,1); }