|
|
1.1 root 1: #include <stdio.h>
2: #define DEFINING
3: #include "cv.h"
4:
5: int cv;
6: #define NCVBUF 4096
7: char cvbuf[NCVBUF];
8: char *cvbufp=cvbuf;
9: int ncvbuf=0;
10: int cvdmamode=0;
11: cvput(x){
12: if(ncvbuf >= NCVBUF-1)
13: cvflush();
14: *cvbufp++=x, ncvbuf++;
15: }
16: cvnput(n, p)
17: register n;
18: register char *p;
19: {
20: while(n--)
21: cvput(*p++);
22: }
23: cvmode(x)
24: {
25: if(ioctl(cv, CVSETDMA, &x))
26: perror("ioctl");
27: }
28: cvflush(){
29: register n;
30: if(ncvbuf&1)
31: cvput(0);
32: n=write(cv, cvbuf, ncvbuf);
33: if(n!=ncvbuf)
34: fprintf(stderr, "incomplete write got %d wanted %d\n", n, ncvbuf);
35: if(n<0){
36: perror("write");
37: exit(1);
38: }
39: cvbufp=cvbuf;
40: ncvbuf=0;
41: }
42: cvinit(cold){
43: cv=open("/dev/cv0", 2);
44: if(cv < 0){
45: fprintf(stderr, "can't open /dev/cv0\n");
46: exit(1);
47: }
48: if(ioctl(cv, CVSETDMA, &WR_CMD)){
49: perror("ioctl");
50: abort();
51: }
52: cvput(4); /* wake up */
53: cvflush();
54: if(cold){
55: cvput(0xFD); /* cold */
56: cvflush();
57: cvput(4); /* wake up */
58: cvflush();
59: cvput(0x9D); /* write enable masks */
60: cvput(0xFF);
61: cvput(0x7);
62: cvload(3,-256,-256); /* lower left screen = 0,0 (ehg) */
63: cvflush();
64: }
65: }
66: cvvalue(r, g, b)
67: {
68: cvput(6);
69: cvput(r);
70: cvput(g);
71: cvput(b);
72: }
73: cvflood()
74: {
75: cvput(7);
76: }
77: cvload(n, val)
78: Point val;
79: {
80: cvput(160);
81: cvput(n);
82: cvput(val.x>>8);
83: cvput(val.x);
84: cvput(val.y>>8);
85: cvput(val.y);
86: }
87:
88: image(in, x0, y0, x1, y1, bank)
89: char *in;
90: {
91: int around=0;
92: int y2;
93: static char cmd[]={0x9D, 0xFF, 0x00, 0xAE};
94: long n, saved, m;
95: if(((int)in)&1){ error("odd address\n"); }
96: n=(x1-x0+1)*(y1-y0+1);
97: if(n>32767){
98: y2 = y0 + 62;
99: if(y2>y1) error("bad image: %d %d %d %d",x0,y0,x1,y1);
100: n=(x1-x0+1)*(y2-y0);
101: image(in,x0,y0,x1,y2-1,bank);
102: image(in+n,x0,y2,x1,y1,bank);
103: }else{
104: if(n&1) n++;/* display will ignore extra byte */
105: cvload(13, x0, y0); /* window start (lower left) */
106: cvload(14, x1, y1); /* window end (upper right)*/
107: cmd[2]=bank;
108: cvnput(sizeof cmd, cmd); /* WRMASK bank; DMA_write */
109: cvflush();
110: cvmode(WR_IMAGE);
111: Write(cv, in, n);
112: cvmode(WR_CMD);
113: }
114: }
115:
116: zoom(fact)
117: int fact;
118: {
119: cvput(0x34);
120: cvput(fact);
121: }
122:
123: lutrte(bank)
124: int bank;
125: {
126: cvput(0x1E);
127: cvput(bank);
128: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.