-
Notifications
You must be signed in to change notification settings - Fork 0
/
scatter-plot.dm42
167 lines (141 loc) · 1.93 KB
/
scatter-plot.dm42
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
export def scatter {
if { MAT? } else {
"not a matrix", AVIEW
STOP
}
STO "A"
index()
// Find min and max values for x and y
// x: min=0, max=1
// y: min=2, max=3
[MIN]
STO 00
[MAX]
STO 01
J+
[MIN]
STO 02
[MAX]
STO 03
J-
2
STO "GrMod" // 200x120
DROPN 9
CLMENU
CLLCD
x_axis()
y_axis()
while { FC? 76} {
RCLEL
RCL 00, -
RCL 01, RCL 00, -, /
// 119, *, IP
199, *, IP
1, +
J+
1
RCLEL
RCL 02, -
RCL 03, RCL 02, -, /
-
// 15, *, IP,
119, *, IP,
1, +
J-
I+
X<>Y
plot()
}
}
def index {
INDEX "A"
1, 1
STOIJ
DROPN 2
J+, J- // For some reason this is needed to clear flag 76
}
// Draws a dot at the specified coordinates in the x and y registers
def plot {
// Y (05), X (04)
1, -
STO 04
DROP
1, -
STO 05
DROP
0.003
STO 06
DROP
while { ISG 06 } {
0.003
STO 07
DROP
while { ISG 07 } {
RCL 05
RCL 04
PIXEL
1, +
STO 04
DROPN 2
}
1, STO+ 05
3, STO- 04
DROPN 2
}
}
def x_axis {
RCL 02
if { X>0? } {
DROP
RTN
}
// what pixel represents 0
// 02 is miny
// 03 is maxy
RCL 03
RCL 03
RCL 02
-
/
119
*
1
+
200.001
STO 04
DROP
while { DSE 04 } {
RCL 04
PIXEL
DROP
}
DROPN 2
}
def y_axis {
RCL 00
if { X>0? } {
DROP
RTN
}
RCL 00
RCL 01
RCL 00
-
/
200
*
1
+
IP
120.001
STO 04
DROP
while { DSE 04 } {
RCL 04
X<>Y
PIXEL
X<>Y
DROP
}
DROPN 2
}