0
|
1 /*
|
|
2 * pwplib tty driver: dumb ascii output
|
|
3 *
|
|
4 */
|
|
5
|
|
6 #include "config.h"
|
|
7
|
|
8 #ifdef HAVE_TTYSTUFF
|
|
9
|
|
10 #include <stdio.h>
|
|
11 #include <stdlib.h>
|
|
12 #include <string.h>
|
|
13
|
|
14 #include "pwplib.h"
|
56
|
15 #include "convert.h"
|
0
|
16 #include "tty.h"
|
|
17
|
|
18 struct
|
|
19 {
|
|
20 char*newframe;
|
|
21 char*newline_;
|
|
22 int lgt_newline_;
|
|
23
|
|
24 unsigned char*buf;
|
|
25
|
|
26 int frame;
|
|
27 }
|
|
28 pwp_tty_dumb;
|
|
29
|
|
30 void tty_dumb_dump_attr()
|
|
31 {
|
|
32 u8 *s=pwplib.videobuf.d;
|
|
33 unsigned char *d=pwp_tty_dumb.buf;
|
|
34 int i=pwplib.videobuf.height,j;
|
|
35
|
|
36 #ifndef FUCK1
|
|
37 d+=sprintf((char*)d,(char*)pwp_tty_dumb.newframe,pwp_tty_dumb.frame++);
|
|
38 #else
|
|
39 sprintf((char*)d,(char*)pwp_tty_dumb.newframe,pwp_tty_dumb.frame++);
|
|
40 d+=strlen(d);
|
|
41 #endif
|
|
42
|
|
43 for(;i;i--)
|
|
44 {
|
|
45 for(j=pwplib.videobuf.width;j;j--)
|
|
46 {
|
|
47 *d++=*s;
|
|
48 s+=2;
|
|
49 }
|
|
50 memcpy(d,pwp_tty_dumb.newline_,pwp_tty_dumb.lgt_newline_*sizeof(char));
|
|
51 d+=pwp_tty_dumb.lgt_newline_;
|
|
52 }
|
|
53
|
|
54 fwrite(pwp_tty_dumb.buf,(d-pwp_tty_dumb.buf),sizeof(char),stdout);
|
|
55
|
|
56 if(pwplib.set.framedelay)
|
|
57 usleep(pwplib.set.framedelay*1000);
|
|
58 }
|
|
59
|
|
60 void tty_dumb_prep_attr()
|
|
61 {
|
|
62 if(pwp_tty_dumb.buf!=NULL)
|
|
63 free(pwp_tty_dumb.buf);
|
|
64
|
|
65 pwp_tty_dumb.buf=malloc((
|
|
66 (pwp_tty_dumb.lgt_newline_+pwplib.videobuf.width)*pwplib.videobuf.height
|
|
67 )+strlen(pwp_tty_dumb.newframe));
|
|
68 }
|
|
69
|
|
70 int tty_dumb_init() /*int argc,char**argv) */
|
|
71 {
|
|
72 pwplib.prep_attr=tty_dumb_prep_attr;
|
|
73 pwplib.dump_attr=tty_dumb_dump_attr;
|
|
74
|
|
75 pwp_tty_dumb.newframe="\22";
|
|
76 pwp_tty_dumb.newline_="\n";
|
|
77
|
|
78 /* ... get options */
|
|
79
|
|
80 pwp_tty_dumb.lgt_newline_=strlen(pwp_tty_dumb.newline_);
|
|
81 pwp_tty_dumb.frame=0;
|
|
82
|
|
83 conv_init(8,3,2);
|
|
84
|
|
85 return 1;
|
|
86 }
|
|
87
|
|
88
|
|
89 /*
|
|
90 options to be included:
|
|
91
|
|
92 newline_ "string" set newline_ string
|
|
93 newframe "string" set newframe string
|
|
94 optimize none no optimization
|
|
95 optimize blank skip spaces at end of line (default)
|
|
96 optimize video skip unchanged lines && non-changed areas at eol
|
|
97
|
|
98 */
|
|
99
|
|
100 #endif
|