From: hackbard Date: Fri, 21 May 2004 08:35:00 +0000 (+0000) Subject: partial display improvements, to be continued (wont compile) X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3830fbef8513acf7689afa26c5dfeca68ba4900c;p=my-code%2Fivac.git partial display improvements, to be continued (wont compile) --- diff --git a/src/display.c b/src/display.c index 89c6472..afb2a57 100644 --- a/src/display.c +++ b/src/display.c @@ -10,42 +10,92 @@ int display_init(t_display *display) { puts("[display] initializing display ..."); - /* init stuff next .. */ + /* dimensions */ display->max_x=atoi(getenv("COLUMNS")); display->max_y=atoi(getenv("LINES")); + /* allocating 'screen' buffer */ + if((display->screen=(unsigned char *)malloc(display->max_x*display->max_y)) + ==NULL) { + perror("[display] malloc call"); + return D_ERROR; + } + /* space as display pixel default */ + memset(display->screen,0x20,display->max_x*display->max_y); + return D_SUCCESS; } -int display_refresh(t_display *display) { +int display_draw(t_display *display) { - display->max_x=atoi(getenv("COLUMNS")); - display->max_y=atoi(getenv("LINES")); + int x,y; + + for(y=0;ymax_y;y++) { + for(x=0;xmax_x;x++) + printf("%c",display->screen+y*display->max_x+x); + printf("\n"); + } + + return D_SUCCESS; +} + +int display_draw_until_line(t_display *display,int line) { + + int x,y; + + for(x=0;xmax_x;x++) { + for(y=0;yscreen+y*display->max_x+x); + printf("\n"); + } + + return D_SUCCESS; +} + +int display_clear_screen(t_display *display) { + + memcpy(display->screen,0x20,display->max_x*display->max_y); return D_SUCCESS; } int display_shutdown(t_display *display) { + free(display->screen); + puts("[display] shutdown"); return D_SUCCESS; } -int display_term_line(t_display *display,char sym) { +int display_line(t_display *display,int X,int Y,int X_,int Y_,char sym) { - int i; + double m; + int x,y; - for(i=0;imax_x;i++) printf("%c",sym); - printf("\n"); + m=(Y_-Y)/(X_-X); + + for(y=0;ymax_y;y++) + for(x=0;xmax_x;x++) + if((int)((x-X)*m+Y)==y) display->screen+y*display->max_x+x=sym; return D_SUCCESS; } -int display_term_string(t_display *display,char *string) { +int display_string(t_display *display,int x,int y,char *string,int len) { + + if(len>display->max_x-x) return D_INV_STRING_LEN; - /* to be continued ... */ + memcpy(display->screen+y*display->max_x+x,string,len); return D_SUCCESS; } +int display_string_vert(t_display *display,int x,int y,char *string,int len) { + + if(len>display->max_y-y) return D_INV_STRING_LEN; + + for(i=y*display->max_x+x;i<(y+len)*display->max_x+x;i+=display->max_x) + *(display->screen+i)=*(string++); + + return D_SUCCESS; +} diff --git a/src/display.h b/src/display.h index a12f380..ed89a17 100644 --- a/src/display.h +++ b/src/display.h @@ -7,6 +7,7 @@ /* defines */ #define D_SUCCESS 1 #define D_ERROR -1 +#define D_INV_STRING_LEN -2 #define MAX_TERM_STRING 64 @@ -18,13 +19,15 @@ typedef struct s_display { int max_x; int max_y; - int x; - int y; + unsigned char *screen; } t_display; /* function prototypes */ int display_init(t_display *display); -int display_refresh(t_display *display); +int display_draw(t_display *display); +int int display_draw_until_line(t_display *display,int line); +int display_clear_screen(t_display *display); int display_shutdown(t_display *display); -int display_term_line(t_display *display,char sym); -int display_term_string(t_display *display,char *string); +int display_line(t_display *display,int X,int Y,int X_,int Y_,char sym); +int display_string(t_display *display,int x,int y,char *string,int len); +int display_string_vert(t_display *display,int x,int y,char *string,int len); diff --git a/src/ivac.c b/src/ivac.c index 60338ee..9167660 100644 --- a/src/ivac.c +++ b/src/ivac.c @@ -472,15 +472,16 @@ int ivac_parse_command(t_input *input,void *ptr) { int ivac_display_head(t_ivac *ivac) { -#ifndef XXX_GUI - display_term_line(&(ivac->display),'#'); - puts("##### ivac - - Copyright (C) 2004 Frank Zirkelbach #####"); - puts("#########################################################"); -#endif + display_line(&(ivac->display),0,ivac->display.max_x,0,0,'#'); + display_string(&(ivac->display),(display->max_x-strlen(PROG_NAME))/2,2, + PROG_NAME,strlen(PROG_NAME)); + display_line(&(ivac->display),0,ivac->display.max_x,2,2,'#'); return SUCCESS; } +GO ON HERE !!! display stuff + int ivac_display_box(t_ivac *ivac) { #ifndef XXX_GUI diff --git a/src/ivac.h b/src/ivac.h index af2932b..d073592 100644 --- a/src/ivac.h +++ b/src/ivac.h @@ -14,6 +14,7 @@ #include "audio.h" /* defines */ +#define PROG_NAME "ivac -- Copyright (C) 2004 Frank Zirkelbach" #define CHAR_USERNAME 32 #define ERROR -1 #define SUCCESS 1