projects
/
my-code
/
api.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
downgraded network api again
[my-code/api.git]
/
display
/
display.c
diff --git
a/display/display.c
b/display/display.c
index
a925e3a
..
b7612d6
100644
(file)
--- a/
display/display.c
+++ b/
display/display.c
@@
-6,9
+6,9
@@
#include "display.h"
#include "display.h"
-
//
#define USE_NCURSES
+#define USE_NCURSES
-int display_init(t_display *display) {
+int display_init(t_display *display
,int outfd
) {
struct winsize ws;
struct winsize ws;
@@
-20,11
+20,13
@@
int display_init(t_display *display) {
display->max_x=ws.ws_col;
display->max_y=ws.ws_row;
display->max_x=ws.ws_col;
display->max_y=ws.ws_row;
- printf("[display] initializing display, width: %02d / height: %02d ...\n",
- ws.ws_col,ws.ws_row);
+ display->outfd=outfd;
+
+ dprintf(display->outfd,"[display] initializing display, w: %02d / h: %02d\n",
+ ws.ws_col,ws.ws_row);
/* allocating 'screen' buffer */
/* allocating 'screen' buffer */
- if((display->screen=(
unsigned
char *)malloc(display->max_x*display->max_y))
+ if((display->screen=(char *)malloc(display->max_x*display->max_y))
==NULL) {
perror("[display] malloc call");
return D_ERROR;
==NULL) {
perror("[display] malloc call");
return D_ERROR;
@@
-56,8
+58,8
@@
int display_draw(t_display *display) {
#else
for(y=0;y<display->max_y;y++) {
for(x=0;x<display->max_x;x++)
#else
for(y=0;y<display->max_y;y++) {
for(x=0;x<display->max_x;x++)
-
printf(
"%c",*(display->screen+y*display->max_x+x));
-
printf(
"\n");
+
fprintf(stderr,
"%c",*(display->screen+y*display->max_x+x));
+
fprintf(stderr,
"\n");
}
#endif
}
#endif
@@
-77,8
+79,8
@@
int display_draw_until_line(t_display *display,int line) {
#else
for(y=0;y<line;y++) {
for(x=0;x<display->max_x;x++)
#else
for(y=0;y<line;y++) {
for(x=0;x<display->max_x;x++)
-
printf(
"%c",*(display->screen+y*display->max_x+x));
-
printf(
"\n");
+
fprintf(stderr,
"%c",*(display->screen+y*display->max_x+x));
+
fprintf(stderr,
"\n");
}
#endif
}
#endif
@@
-110,7
+112,7
@@
int display_shutdown(t_display *display) {
free(display->screen);
free(display->screen);
-
puts("[display] shutdow
n");
+
dprintf(display->outfd,"[display] shutdown\
n");
return D_SUCCESS;
}
return D_SUCCESS;
}
@@
-122,9
+124,10
@@
int display_line(t_display *display,int X,int Y,int X_,int Y_,char sym) {
m=(Y_-Y)/(X_-X);
m=(Y_-Y)/(X_-X);
- for(y=0;y<display->max_y;y++)
- for(x=0;x<display->max_x;x++)
- if((int)((x-X)*m+Y)==y) *(display->screen+y*display->max_x+x)=sym;
+ for(x=X;x<=X_;x++) {
+ y=(x-X)*m+Y;
+ *(display->screen+y*display->max_x+x)=sym;
+ }
return D_SUCCESS;
}
return D_SUCCESS;
}