-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tek4014-1.c
119 lines (105 loc) · 3.03 KB
/
tek4014-1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*-
* Copyright (c) 2008 Poul-Henning Kamp
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: tek4014-1.c,v 1.1.1.1 2009/04/27 23:30:28 demon Exp $
*/
#include "aduc.h"
#include "loran0.h"
/**********************************************************************
* TEK4014 plotting functions
*/
#define SC(x) ser_char(x)
#define SS(x) ser_str(x)
void
tek4014_start(void)
{
SC(0x9d); SS("15;green"); SC(0x9c); /* TEK fg col */
SC(0x9d); SS("16;black"); SC(0x9c); /* TEK bg col */
SC(0x9b); SS("?38h"); /* TEK mode */
SC(0x0d);
SC(27); SC(12); /* TEK PAGE */
/* Draw an outline */
tek4014_pen();
tek4014_coord( 0, 0);
tek4014_coord(4095 - 0, 0);
tek4014_coord(4095 - 0, 3071 - 0);
tek4014_coord( 0, 3071 - 0);
tek4014_coord( 0, 0);
}
void
tek4014_end(void)
{
SC(31); /* Text mode */
SC(27); SC(3); /* VT PAGE */
}
void
tek4014_coord(unsigned x, unsigned y)
{
unsigned char lox, loy, hix, hiy, eb;
static unsigned char lloy = -1, lhix = -1, lhiy = -1, leb = -1;
if (y > 3071)
y = 3071;
if (x > 4095)
x = 4095;
hiy = (y >> 7) & 0x1f;
loy = (y >> 2) & 0x1f;
hix = (x >> 7) & 0x1f;
lox = (x >> 2) & 0x1f;
eb = (x & 3) | ((y & 3) << 2);
if (hiy != lhiy)
SC(hiy | 0x20);
if (eb != leb)
SC( eb | 0x60);
if (eb != leb || loy != lloy || hix != lhix)
SC(loy | 0x60);
if (hix != lhix)
SC(hix | 0x20);
SC(lox | 0x40);
lhiy = hiy;
lhix = hix;
lloy = loy;
leb = eb;
}
void
tek4014_pen(void)
{
SC(29);
}
void
tek4014_text(void)
{
SC(31);
}
void
tek4014_curve(unsigned x, unsigned y, int *p, unsigned len, int scalex, int scaley)
{
int i;
tek4014_pen();
tek4014_coord(0, y);
tek4014_coord(50, y);
tek4014_pen();
for (i = 0; i < len; i++)
tek4014_coord(i * scalex + x, y + p[i] / scaley);
}