Rev 7908 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7908 | Rev 7933 | ||
---|---|---|---|
1 | #include "func.h" |
1 | #include "func.h" |
2 | #include "parser.h" |
2 | #include "parser.h" |
3 | #include "use_library.h" |
3 | #include "use_library.h" |
4 | 4 | ||
5 | const char header[] = "Graph"; |
5 | const char header[] = "Graph"; |
6 | const char empty_text[] = "No function loaded. Type file name and press Enter. "; |
6 | const char empty_text[] = "No function loaded. Type file name and press Enter. "; |
7 | const char er_file_not_found[] = "Cannot open file. "; |
7 | const char er_file_not_found[] = "Cannot open file. "; |
8 | const char str_filename[]="Filename:"; |
8 | const char str_filename[]="Filename:"; |
9 | const char str_editfile[]="Edit"; |
9 | const char str_editfile[]="Edit"; |
10 | 10 | ||
11 | // íà÷àëüíûå ðàçìåðû |
11 | // íà÷àëüíûå ðàçìåðû |
12 | #define WND_W 600 |
12 | #define WND_W 600 |
13 | #define WND_H 470 |
13 | #define WND_H 470 |
14 | 14 | ||
15 | #define LIGHTGREEN 0xff0000 |
15 | #define LIGHTGREEN 0xff0000 |
16 | #define WHITE 0xffffff |
16 | #define WHITE 0xffffff |
17 | #define BLACK 0x0 |
17 | #define BLACK 0x0 |
18 | #define LIGHTBLUE 0x0000ff |
18 | #define LIGHTBLUE 0x0000ff |
19 | #define LIGHTRED 0xff0000 |
19 | #define LIGHTRED 0xff0000 |
20 | 20 | ||
21 | // font colors |
21 | // font colors |
22 | #define BIGFONTCOLOR BLACK |
22 | #define BIGFONTCOLOR BLACK |
23 | #define SMALLFONTCOLOR BLACK |
23 | #define SMALLFONTCOLOR BLACK |
24 | 24 | ||
25 | #define THREE 3.0 |
25 | #define THREE 3.0 |
26 | // minimum space: 3 pixels |
26 | // minimum space: 3 pixels |
27 | 27 | ||
28 | #define BIG_HEIGHT 4.0 |
28 | #define BIG_HEIGHT 4.0 |
29 | #define SMALL_HEIGHT 2.0 |
29 | #define SMALL_HEIGHT 2.0 |
30 | #define TEXT_X 15.0 |
30 | #define TEXT_X 15.0 |
31 | // numeric format for output |
31 | // numeric format for output |
32 | #define FORMAT "%f" |
32 | #define FORMAT "%f" |
33 | // format for two coords |
33 | // format for two coords |
34 | #define FORMAT_COORD "(%f,%f)" |
34 | #define FORMAT_COORD "(%f,%f)" |
35 | // special value to text if enough space |
35 | // special value to text if enough space |
36 | #define FORMAT_TEST "0.00" |
36 | #define FORMAT_TEST "0.00" |
37 | 37 | ||
38 | #define DELTA_BIG 1.0 |
38 | #define DELTA_BIG 1.0 |
39 | #define DELTA_SMALL 0.1 |
39 | #define DELTA_SMALL 0.1 |
40 | 40 | ||
41 | double *points; |
41 | double *points; |
42 | Dword point_count = 0; |
42 | Dword point_count = 0; |
43 | double x1,y1,x2,y2; |
43 | double x1,y1,x2,y2; |
44 | char *funct = NULL; |
44 | char *funct = NULL; |
45 | 45 | ||
46 | char edit_path[256]; |
46 | char edit_path[256]; |
47 | edit_box mybox = {0,92,WND_H-16-32,0xffffff,0x94AECE,0,0x808080,0x10000000, |
47 | edit_box mybox = {200,92,WND_H-16-32,0xffffff,0x94AECE,0,0x808080,0x10000000, |
48 | sizeof(edit_path)-1,(dword)&edit_path, 0, 0}; |
48 | sizeof(edit_path)-1,(dword)&edit_path, 0, 0, 0}; |
49 | 49 | ||
50 | char *full_head; |
50 | char *full_head; |
51 | 51 | ||
52 | char *HugeBuf = NULL; |
52 | char *HugeBuf = NULL; |
53 | 53 | ||
54 | //char fuck[64] = "$this is a fucking marker$"; |
54 | //char fuck[64] = "$this is a fucking marker$"; |
55 | // ïàðàìåòðû êîìàíäíîé ñòðîêè |
55 | // ïàðàìåòðû êîìàíäíîé ñòðîêè |
56 | #ifdef AUTOBUILD |
56 | #ifdef AUTOBUILD |
57 | extern char params[1024]; |
57 | extern char params[1024]; |
58 | char params[1024]; |
58 | char params[1024]; |
59 | #else |
59 | #else |
60 | char params[1024] = "_FIND_ME_"; |
60 | char params[1024] = "_FIND_ME_"; |
61 | #endif |
61 | #endif |
62 | 62 | ||
63 | /* |
63 | /* |
64 | 64 | ||
65 | fucking piece of shit |
65 | fucking piece of shit |
66 | 66 | ||
67 | */ |
67 | */ |
68 | 68 | ||
69 | // constructor of TCoord |
69 | // constructor of TCoord |
70 | TCoord coord(double x, double y) |
70 | TCoord coord(double x, double y) |
71 | { |
71 | { |
72 | TCoord r; |
72 | TCoord r; |
73 | r.x = x; |
73 | r.x = x; |
74 | r.y = y; |
74 | r.y = y; |
75 | return r; |
75 | return r; |
76 | } |
76 | } |
77 | 77 | ||
78 | // move and scale mathematical coords to fit screen coords |
78 | // move and scale mathematical coords to fit screen coords |
79 | TCoord mat2Graf(TCoord c, TCoord scrMin, TCoord scrMax, TCoord mMin, TCoord mMax) |
79 | TCoord mat2Graf(TCoord c, TCoord scrMin, TCoord scrMax, TCoord mMin, TCoord mMax) |
80 | { |
80 | { |
81 | TCoord r; |
81 | TCoord r; |
82 | if (c.x > mMax.x) |
82 | if (c.x > mMax.x) |
83 | c.x = mMax.x; |
83 | c.x = mMax.x; |
84 | if (c.x < mMin.x) |
84 | if (c.x < mMin.x) |
85 | c.x = mMin.x; |
85 | c.x = mMin.x; |
86 | if (c.y > mMax.y) |
86 | if (c.y > mMax.y) |
87 | c.y = mMax.y; |
87 | c.y = mMax.y; |
88 | if (c.y < mMin.y) |
88 | if (c.y < mMin.y) |
89 | c.y = mMin.y; |
89 | c.y = mMin.y; |
90 | r.x = (scrMax.x - scrMin.x) / (mMax.x - mMin.x) * (c.x - mMin.x) + scrMin.x; |
90 | r.x = (scrMax.x - scrMin.x) / (mMax.x - mMin.x) * (c.x - mMin.x) + scrMin.x; |
91 | r.y = (scrMax.y - scrMin.y) / (mMax.y - mMin.y) * (mMax.y - c.y) + scrMin.y; |
91 | r.y = (scrMax.y - scrMin.y) / (mMax.y - mMin.y) * (mMax.y - c.y) + scrMin.y; |
92 | 92 | ||
93 | return r; |
93 | return r; |
94 | } |
94 | } |
95 | 95 | ||
96 | // double-îáåðòêè |
96 | // double-îáåðòêè |
97 | void line_d( double x1, double y1, double x2, double y2) |
97 | void line_d( double x1, double y1, double x2, double y2) |
98 | { |
98 | { |
99 | line(di(x1), di(y1), di(x2), di(y2)); |
99 | line(di(x1), di(y1), di(x2), di(y2)); |
100 | } |
100 | } |
101 | 101 | ||
102 | void outtextxy_d( double x, double y, char * text, int len) |
102 | void outtextxy_d( double x, double y, char * text, int len) |
103 | { |
103 | { |
104 | outtextxy(di(x), di(y), text, len); |
104 | outtextxy(di(x), di(y), text, len); |
105 | } |
105 | } |
106 | 106 | ||
107 | // huge function to draw all the stuff except the function itself |
107 | // huge function to draw all the stuff except the function itself |
108 | void drawAxis( TCoord scrMin, TCoord scrMax, TCoord mMin, TCoord mMax) |
108 | void drawAxis( TCoord scrMin, TCoord scrMax, TCoord mMin, TCoord mMax) |
109 | { |
109 | { |
110 | TCoord cZero={0.0,0.0}, |
110 | TCoord cZero={0.0,0.0}, |
111 | gMin, gMax, gZero, step; |
111 | gMin, gMax, gZero, step; |
112 | TCoord from, to; |
112 | TCoord from, to; |
113 | double i=0.0; |
113 | double i=0.0; |
114 | int j; |
114 | int j; |
115 | double xmin, xmin2, ymin, ymin2; |
115 | double xmin, xmin2, ymin, ymin2; |
116 | char buf[30]=""; |
116 | char buf[30]=""; |
117 | 117 | ||
118 | 118 | ||
119 | // scr means Screen(bounding rect) |
119 | // scr means Screen(bounding rect) |
120 | // m means Mathematical |
120 | // m means Mathematical |
121 | // g means Graphic(real screen position) |
121 | // g means Graphic(real screen position) |
122 | 122 | ||
123 | //rtlDebugOutString("draw axis called\n"); |
123 | //rtlDebugOutString("draw axis called\n"); |
124 | 124 | ||
125 | //format(debuf, 30, "test: %f,%f,%f,%f\n", 123.45, 1.0, -0.9, 12.57); |
125 | //format(debuf, 30, "test: %f,%f,%f,%f\n", 123.45, 1.0, -0.9, 12.57); |
126 | //rtlDebugOutString(debuf); |
126 | //rtlDebugOutString(debuf); |
127 | 127 | ||
128 | gMin = mat2Graf(mMin, scrMin, scrMax, mMin, mMax); |
128 | gMin = mat2Graf(mMin, scrMin, scrMax, mMin, mMax); |
129 | gMax = mat2Graf(mMax, scrMin, scrMax, mMin, mMax); |
129 | gMax = mat2Graf(mMax, scrMin, scrMax, mMin, mMax); |
130 | gZero = mat2Graf(cZero, scrMin, scrMax, mMin, mMax); |
130 | gZero = mat2Graf(cZero, scrMin, scrMax, mMin, mMax); |
131 | 131 | ||
132 | // clear |
132 | // clear |
133 | // setcolor(WHITE); |
133 | // setcolor(WHITE); |
134 | //rectangle(di(gMin.x), di(gMin.y), di(gMax.x), di(gMax.y)); |
134 | //rectangle(di(gMin.x), di(gMin.y), di(gMax.x), di(gMax.y)); |
135 | // ftopku |
135 | // ftopku |
136 | 136 | ||
137 | setcolor(BLACK); |
137 | setcolor(BLACK); |
138 | // osy X |
138 | // osy X |
139 | line_d(gMin.x, gZero.y ,gMax.x, gZero.y); |
139 | line_d(gMin.x, gZero.y ,gMax.x, gZero.y); |
140 | // osy Y |
140 | // osy Y |
141 | line_d(gZero.x, gMin.y, gZero.x, gMax.y); |
141 | line_d(gZero.x, gMin.y, gZero.x, gMax.y); |
142 | // bounding rect |
142 | // bounding rect |
143 | line_d(gMin.x, gMin.y, gMax.x, gMin.y); |
143 | line_d(gMin.x, gMin.y, gMax.x, gMin.y); |
144 | line_d(gMin.x, gMax.y, gMax.x, gMax.y); |
144 | line_d(gMin.x, gMax.y, gMax.x, gMax.y); |
145 | 145 | ||
146 | line_d(gMin.x, gMin.y, gMin.x, gMax.y); |
146 | line_d(gMin.x, gMin.y, gMin.x, gMax.y); |
147 | line_d(gMax.x, gMin.y, gMax.x, gMax.y); |
147 | line_d(gMax.x, gMin.y, gMax.x, gMax.y); |
148 | 148 | ||
149 | // coords of the rect : lower left |
149 | // coords of the rect : lower left |
150 | format(buf, 30, FORMAT_COORD, x1, y1); |
150 | format(buf, 30, FORMAT_COORD, x1, y1); |
151 | //rtlDebugOutString(buf); |
151 | //rtlDebugOutString(buf); |
152 | outtextxy_d(gMin.x, gMin.y + textheight(buf, 20), buf, 20); |
152 | outtextxy_d(gMin.x, gMin.y + textheight(buf, 20), buf, 20); |
153 | // upper left |
153 | // upper left |
154 | format(buf, 30, FORMAT_COORD, x1, y2); |
154 | format(buf, 30, FORMAT_COORD, x1, y2); |
155 | outtextxy_d(gMin.x, gMax.y - textheight(buf, 20), buf, 20); |
155 | outtextxy_d(gMin.x, gMax.y - textheight(buf, 20), buf, 20); |
156 | // lower right |
156 | // lower right |
157 | format(buf, 30, FORMAT_COORD, x2, y1); |
157 | format(buf, 30, FORMAT_COORD, x2, y1); |
158 | outtextxy_d(gMax.x - textwidth(buf, 20), gMin.y + textheight(buf, 20), buf, 20); |
158 | outtextxy_d(gMax.x - textwidth(buf, 20), gMin.y + textheight(buf, 20), buf, 20); |
159 | // upper right |
159 | // upper right |
160 | format(buf, 30, FORMAT_COORD, x2, y2); |
160 | format(buf, 30, FORMAT_COORD, x2, y2); |
161 | outtextxy_d(gMax.x - textwidth(buf, 20), gMax.y - textheight(buf, 20), buf, 20); |
161 | outtextxy_d(gMax.x - textwidth(buf, 20), gMax.y - textheight(buf, 20), buf, 20); |
162 | 162 | ||
163 | //rtlDebugOutString("some lines painted\n"); |
163 | //rtlDebugOutString("some lines painted\n"); |
164 | 164 | ||
165 | 165 | ||
166 | step.x = (mMax.x - mMin.x) / (scrMax.x - scrMin.x); |
166 | step.x = (mMax.x - mMin.x) / (scrMax.x - scrMin.x); |
167 | step.y = (mMax.y - mMin.y) / (scrMax.y - scrMin.y); |
167 | step.y = (mMax.y - mMin.y) / (scrMax.y - scrMin.y); |
168 | 168 | ||
169 | // round values |
169 | // round values |
170 | xmin = id(di((mMin.x / DELTA_BIG) * DELTA_BIG)); |
170 | xmin = id(di((mMin.x / DELTA_BIG) * DELTA_BIG)); |
171 | ymin = id(di((mMin.y / DELTA_BIG) * DELTA_BIG)); |
171 | ymin = id(di((mMin.y / DELTA_BIG) * DELTA_BIG)); |
172 | 172 | ||
173 | // (0,0) |
173 | // (0,0) |
174 | 174 | ||
175 | if ((x1 * x2 <= 0.0) && (y1 * y2 <= 0.0)) |
175 | if ((x1 * x2 <= 0.0) && (y1 * y2 <= 0.0)) |
176 | { |
176 | { |
177 | from.x=0.0; |
177 | from.x=0.0; |
178 | from.y=0.0; |
178 | from.y=0.0; |
179 | from = mat2Graf(from, scrMin, scrMax, mMin, mMax); |
179 | from = mat2Graf(from, scrMin, scrMax, mMin, mMax); |
180 | setcolor(BLACK); |
180 | setcolor(BLACK); |
181 | format(buf, 30, FORMAT, 0.0); |
181 | format(buf, 30, FORMAT, 0.0); |
182 | outtextxy_d(from.x - textwidth(buf, 20), from.y + textheight(buf, 20), buf, 20); |
182 | outtextxy_d(from.x - textwidth(buf, 20), from.y + textheight(buf, 20), buf, 20); |
183 | } |
183 | } |
184 | 184 | ||
185 | 185 | ||
186 | // big marks on X |
186 | // big marks on X |
187 | //settextstyle(0, 0, 1); |
187 | //settextstyle(0, 0, 1); |
188 | if (DELTA_BIG / step.x > THREE) |
188 | if (DELTA_BIG / step.x > THREE) |
189 | { |
189 | { |
190 | for (i = xmin; i <= mMax.x; i += DELTA_BIG) |
190 | for (i = xmin; i <= mMax.x; i += DELTA_BIG) |
191 | { |
191 | { |
192 | if (i != 0.0) |
192 | if (i != 0.0) |
193 | { |
193 | { |
194 | from.x = i; |
194 | from.x = i; |
195 | to.x = from.x; |
195 | to.x = from.x; |
196 | from.y = -BIG_HEIGHT * step.y; |
196 | from.y = -BIG_HEIGHT * step.y; |
197 | to.y = BIG_HEIGHT * step.y; |
197 | to.y = BIG_HEIGHT * step.y; |
198 | from = mat2Graf(from, scrMin, scrMax, mMin, mMax); |
198 | from = mat2Graf(from, scrMin, scrMax, mMin, mMax); |
199 | to = mat2Graf(to, scrMin, scrMax, mMin, mMax); |
199 | to = mat2Graf(to, scrMin, scrMax, mMin, mMax); |
200 | setcolor(BLACK); |
200 | setcolor(BLACK); |
201 | line_d(from.x, from.y, to.x, to.y); |
201 | line_d(from.x, from.y, to.x, to.y); |
202 | // write number |
202 | // write number |
203 | format(buf, 30, FORMAT, i); |
203 | format(buf, 30, FORMAT, i); |
204 | // if it fits in the GAP, then write it |
204 | // if it fits in the GAP, then write it |
205 | if (from.y > scrMin.y && (DELTA_BIG > (textwidth(buf, 20) + 1.0) * step.x)) |
205 | if (from.y > scrMin.y && (DELTA_BIG > (textwidth(buf, 20) + 1.0) * step.x)) |
206 | { |
206 | { |
207 | setcolor(BIGFONTCOLOR); |
207 | setcolor(BIGFONTCOLOR); |
208 | outtextxy_d(from.x - textwidth(buf, 20) / 2.0, to.y - textheight(buf, 20), buf, 20); |
208 | outtextxy_d(from.x - textwidth(buf, 20) / 2.0, to.y - textheight(buf, 20), buf, 20); |
209 | } |
209 | } |
210 | } |
210 | } |
211 | } |
211 | } |
212 | } |
212 | } |
213 | //rtlDebugOutString("big marks x painted\n"); |
213 | //rtlDebugOutString("big marks x painted\n"); |
214 | 214 | ||
215 | // big marks on Y |
215 | // big marks on Y |
216 | if (DELTA_BIG / step.y > THREE) |
216 | if (DELTA_BIG / step.y > THREE) |
217 | { |
217 | { |
218 | for (i = ymin; i <= mMax.y; i += DELTA_BIG) |
218 | for (i = ymin; i <= mMax.y; i += DELTA_BIG) |
219 | { |
219 | { |
220 | if (i != 0.0) |
220 | if (i != 0.0) |
221 | { |
221 | { |
222 | from.y = i; |
222 | from.y = i; |
223 | to.y = from.y; |
223 | to.y = from.y; |
224 | from.x = -BIG_HEIGHT * step.x; |
224 | from.x = -BIG_HEIGHT * step.x; |
225 | to.x = BIG_HEIGHT * step.x; |
225 | to.x = BIG_HEIGHT * step.x; |
226 | from = mat2Graf(from, scrMin, scrMax, mMin, mMax); |
226 | from = mat2Graf(from, scrMin, scrMax, mMin, mMax); |
227 | to = mat2Graf(to, scrMin, scrMax, mMin, mMax); |
227 | to = mat2Graf(to, scrMin, scrMax, mMin, mMax); |
228 | setcolor(BLACK); |
228 | setcolor(BLACK); |
229 | line_d(from.x, from.y, to.x, to.y); |
229 | line_d(from.x, from.y, to.x, to.y); |
230 | format(buf, 30, FORMAT, i); |
230 | format(buf, 30, FORMAT, i); |
231 | if (from.x > scrMin.x && (DELTA_BIG > textheight(buf, 20) * step.y)) |
231 | if (from.x > scrMin.x && (DELTA_BIG > textheight(buf, 20) * step.y)) |
232 | { |
232 | { |
233 | setcolor(BIGFONTCOLOR); |
233 | setcolor(BIGFONTCOLOR); |
234 | outtextxy_d(from.x + TEXT_X, to.y - textheight(buf, 20) / 2.0, buf, 20); |
234 | outtextxy_d(from.x + TEXT_X, to.y - textheight(buf, 20) / 2.0, buf, 20); |
235 | } |
235 | } |
236 | } |
236 | } |
237 | } |
237 | } |
238 | } |
238 | } |
239 | 239 | ||
240 | xmin2 = id(di(mMin.x / DELTA_SMALL)) * DELTA_SMALL; |
240 | xmin2 = id(di(mMin.x / DELTA_SMALL)) * DELTA_SMALL; |
241 | ymin2 = id(di(mMin.y / DELTA_SMALL)) * DELTA_SMALL; |
241 | ymin2 = id(di(mMin.y / DELTA_SMALL)) * DELTA_SMALL; |
242 | 242 | ||
243 | if (DELTA_SMALL / step.x > THREE) |
243 | if (DELTA_SMALL / step.x > THREE) |
244 | { |
244 | { |
245 | j = di((( - xmin + xmin2 ) / DELTA_SMALL)); |
245 | j = di((( - xmin + xmin2 ) / DELTA_SMALL)); |
246 | for (i = xmin2; i <= mMax.x; i += DELTA_SMALL, j++) |
246 | for (i = xmin2; i <= mMax.x; i += DELTA_SMALL, j++) |
247 | { |
247 | { |
248 | if (j % 10 == 0) |
248 | if (j % 10 == 0) |
249 | { |
249 | { |
250 | // we need to skip every tenth mark, to avoid overwriting big marks |
250 | // we need to skip every tenth mark, to avoid overwriting big marks |
251 | j = 0; |
251 | j = 0; |
252 | continue; |
252 | continue; |
253 | } |
253 | } |
254 | from.x = i; |
254 | from.x = i; |
255 | to.x = from.x; |
255 | to.x = from.x; |
256 | from.y = -SMALL_HEIGHT * step.y; |
256 | from.y = -SMALL_HEIGHT * step.y; |
257 | to.y = SMALL_HEIGHT * step.y; |
257 | to.y = SMALL_HEIGHT * step.y; |
258 | from = mat2Graf(from, scrMin, scrMax, mMin, mMax); |
258 | from = mat2Graf(from, scrMin, scrMax, mMin, mMax); |
259 | to = mat2Graf(to, scrMin, scrMax, mMin, mMax); |
259 | to = mat2Graf(to, scrMin, scrMax, mMin, mMax); |
260 | setcolor(BLACK); |
260 | setcolor(BLACK); |
261 | line_d(from.x, from.y, to.x, to.y); |
261 | line_d(from.x, from.y, to.x, to.y); |
262 | format(buf, 30, FORMAT, i); |
262 | format(buf, 30, FORMAT, i); |
263 | 263 | ||
264 | if (from.y > scrMin.y && (DELTA_SMALL > textwidth(buf, 20) * step.x)) |
264 | if (from.y > scrMin.y && (DELTA_SMALL > textwidth(buf, 20) * step.x)) |
265 | { |
265 | { |
266 | setcolor(SMALLFONTCOLOR); |
266 | setcolor(SMALLFONTCOLOR); |
267 | outtextxy_d(from.x - textwidth(buf, 20) / 2.0, to.y - textheight(buf, 20), buf, 20); |
267 | outtextxy_d(from.x - textwidth(buf, 20) / 2.0, to.y - textheight(buf, 20), buf, 20); |
268 | } |
268 | } |
269 | 269 | ||
270 | 270 | ||
271 | } |
271 | } |
272 | 272 | ||
273 | } |
273 | } |
274 | 274 | ||
275 | // finally small marks on Y |
275 | // finally small marks on Y |
276 | if (DELTA_SMALL / step.y > THREE) |
276 | if (DELTA_SMALL / step.y > THREE) |
277 | { |
277 | { |
278 | //rtlDebugOutString("really small marks y painted\n"); |
278 | //rtlDebugOutString("really small marks y painted\n"); |
279 | j = di((( - ymin + ymin2) / DELTA_SMALL)); |
279 | j = di((( - ymin + ymin2) / DELTA_SMALL)); |
280 | for (i = ymin2; i <= mMax.y; i += DELTA_SMALL, j++) |
280 | for (i = ymin2; i <= mMax.y; i += DELTA_SMALL, j++) |
281 | { |
281 | { |
282 | if (j % 10 == 0) |
282 | if (j % 10 == 0) |
283 | { |
283 | { |
284 | // we need to skip every tenth, to avoid overwriting |
284 | // we need to skip every tenth, to avoid overwriting |
285 | j = 0; |
285 | j = 0; |
286 | continue; |
286 | continue; |
287 | } |
287 | } |
288 | from.y = i; |
288 | from.y = i; |
289 | to.y = from.y; |
289 | to.y = from.y; |
290 | from.x = -SMALL_HEIGHT * step.x; |
290 | from.x = -SMALL_HEIGHT * step.x; |
291 | to.x = SMALL_HEIGHT * step.x; |
291 | to.x = SMALL_HEIGHT * step.x; |
292 | from = mat2Graf(from, scrMin, scrMax, mMin, mMax); |
292 | from = mat2Graf(from, scrMin, scrMax, mMin, mMax); |
293 | to = mat2Graf(to, scrMin, scrMax, mMin, mMax); |
293 | to = mat2Graf(to, scrMin, scrMax, mMin, mMax); |
294 | setcolor(BLACK); |
294 | setcolor(BLACK); |
295 | line_d(from.x, from.y, to.x, to.y); |
295 | line_d(from.x, from.y, to.x, to.y); |
296 | format(buf, 30, FORMAT, i); |
296 | format(buf, 30, FORMAT, i); |
297 | if (from.x > scrMin.x && (DELTA_SMALL > textheight(buf, 20) * step.y)) |
297 | if (from.x > scrMin.x && (DELTA_SMALL > textheight(buf, 20) * step.y)) |
298 | { |
298 | { |
299 | setcolor(SMALLFONTCOLOR); |
299 | setcolor(SMALLFONTCOLOR); |
300 | outtextxy_d(from.x + TEXT_X, from.y - textheight(buf, 20) / 2.0, buf, 20); |
300 | outtextxy_d(from.x + TEXT_X, from.y - textheight(buf, 20) / 2.0, buf, 20); |
301 | } |
301 | } |
302 | } |
302 | } |
303 | } |
303 | } |
304 | 304 | ||
305 | } |
305 | } |
306 | 306 | ||
307 | /* |
307 | /* |
308 | ends fucking piece of shit |
308 | ends fucking piece of shit |
309 | */ |
309 | */ |
310 | 310 | ||
311 | void drawFunction( function_t fi, TCoord scrMin, TCoord scrMax, |
311 | void drawFunction( function_t fi, TCoord scrMin, TCoord scrMax, |
312 | TCoord mMin, TCoord mMax, DWORD color) |
312 | TCoord mMin, TCoord mMax, DWORD color) |
313 | { |
313 | { |
314 | double x; |
314 | double x; |
315 | double y; |
315 | double y; |
316 | int firstPoint = 1; |
316 | int firstPoint = 1; |
317 | TCoord p, p0 = {0.0, 0.0}, step; |
317 | TCoord p, p0 = {0.0, 0.0}, step; |
318 | 318 | ||
319 | drawAxis(scrMin, scrMax, mMin, mMax); |
319 | drawAxis(scrMin, scrMax, mMin, mMax); |
320 | 320 | ||
321 | setcolor(color); |
321 | setcolor(color); |
322 | step.x = (mMax.x - mMin.x) / (scrMax.x - scrMin.x); |
322 | step.x = (mMax.x - mMin.x) / (scrMax.x - scrMin.x); |
323 | 323 | ||
324 | for (x = mMin.x; x < mMax.x; x += step.x) |
324 | for (x = mMin.x; x < mMax.x; x += step.x) |
325 | { |
325 | { |
326 | y = fi(x); |
326 | y = fi(x); |
327 | // function is defined here and gets in the range |
327 | // function is defined here and gets in the range |
328 | if (1) // òóò áûëî óñëîâèå, ÷òî ôóíêöèÿ ïðàâèëüíî âû÷èñëåíà |
328 | if (1) // òóò áûëî óñëîâèå, ÷òî ôóíêöèÿ ïðàâèëüíî âû÷èñëåíà |
329 | { |
329 | { |
330 | if ((y > mMin.y) && (y < mMax.y)) |
330 | if ((y > mMin.y) && (y < mMax.y)) |
331 | { |
331 | { |
332 | p = mat2Graf(coord(x, y), scrMin, scrMax, mMin, mMax); |
332 | p = mat2Graf(coord(x, y), scrMin, scrMax, mMin, mMax); |
333 | // if it's our first point, only remember its coords |
333 | // if it's our first point, only remember its coords |
334 | // otherwise, draw a line_d from prev to current |
334 | // otherwise, draw a line_d from prev to current |
335 | if (firstPoint == 0) |
335 | if (firstPoint == 0) |
336 | { |
336 | { |
337 | line_d(p0.x, p0.y, p.x, p.y); |
337 | line_d(p0.x, p0.y, p.x, p.y); |
338 | } |
338 | } |
339 | else |
339 | else |
340 | firstPoint = 0; |
340 | firstPoint = 0; |
341 | 341 | ||
342 | p0 = p; |
342 | p0 = p; |
343 | } |
343 | } |
344 | else // too big/small |
344 | else // too big/small |
345 | { |
345 | { |
346 | firstPoint = 1; |
346 | firstPoint = 1; |
347 | } |
347 | } |
348 | } |
348 | } |
349 | else // no value |
349 | else // no value |
350 | { |
350 | { |
351 | firstPoint = 1; |
351 | firstPoint = 1; |
352 | } |
352 | } |
353 | } |
353 | } |
354 | 354 | ||
355 | } |
355 | } |
356 | 356 | ||
357 | struct kosBDVK |
357 | struct kosBDVK |
358 | { |
358 | { |
359 | Dword attrib; |
359 | Dword attrib; |
360 | Dword name_type; |
360 | Dword name_type; |
361 | Dword create_time; |
361 | Dword create_time; |
362 | Dword create_date; |
362 | Dword create_date; |
363 | Dword access_time; |
363 | Dword access_time; |
364 | Dword access_date; |
364 | Dword access_date; |
365 | Dword modify_time; |
365 | Dword modify_time; |
366 | Dword modify_date; |
366 | Dword modify_date; |
367 | Dword size_low; |
367 | Dword size_low; |
368 | Dword size_high; |
368 | Dword size_high; |
369 | }; |
369 | }; |
370 | 370 | ||
371 | // èòîãîâàÿ âåðñèÿ ÷èòàëêè òåêñòîâûõ ôàéëîâ |
371 | // èòîãîâàÿ âåðñèÿ ÷èòàëêè òåêñòîâûõ ôàéëîâ |
372 | int load_points3() |
372 | int load_points3() |
373 | { |
373 | { |
374 | kosFileInfo fileInfo; |
374 | kosFileInfo fileInfo; |
375 | kosBDVK bdvk; |
375 | kosBDVK bdvk; |
376 | int filePointer = 0; |
376 | int filePointer = 0; |
377 | 377 | ||
378 | int i,j,k; |
378 | int i,j,k; |
379 | double d; |
379 | double d; |
380 | Dword filesize, num_number; |
380 | Dword filesize, num_number; |
381 | 381 | ||
382 | double *p2=0; |
382 | double *p2=0; |
383 | 383 | ||
384 | // get file size |
384 | // get file size |
385 | strcpy(fileInfo.fileURL,edit_path); |
385 | strcpy(fileInfo.fileURL,edit_path); |
386 | fileInfo.OffsetLow = 0; |
386 | fileInfo.OffsetLow = 0; |
387 | fileInfo.OffsetHigh = 0; |
387 | fileInfo.OffsetHigh = 0; |
388 | fileInfo.dataCount = 0; |
388 | fileInfo.dataCount = 0; |
389 | fileInfo.rwMode = 5; |
389 | fileInfo.rwMode = 5; |
390 | fileInfo.bufferPtr = (Byte *)&bdvk; |
390 | fileInfo.bufferPtr = (Byte *)&bdvk; |
391 | Dword rr = kos_FileSystemAccess( &(fileInfo) ); // â CKosFile íåò îïðåäåëåíèÿ ðàçìåðà |
391 | Dword rr = kos_FileSystemAccess( &(fileInfo) ); // â CKosFile íåò îïðåäåëåíèÿ ðàçìåðà |
392 | sprintf(debuf, "getsize: %U\n", rr); |
392 | sprintf(debuf, "getsize: %U\n", rr); |
393 | rtlDebugOutString(debuf); |
393 | rtlDebugOutString(debuf); |
394 | if (rr != 0) |
394 | if (rr != 0) |
395 | { |
395 | { |
396 | kos_WriteTextToWindow(10,10,0x90,0xFF0000,(char*)er_file_not_found,strlen(er_file_not_found)); |
396 | kos_WriteTextToWindow(10,10,0x90,0xFF0000,(char*)er_file_not_found,strlen(er_file_not_found)); |
397 | return 0; |
397 | return 0; |
398 | } |
398 | } |
399 | 399 | ||
400 | filesize = bdvk.size_low; |
400 | filesize = bdvk.size_low; |
401 | num_number = filesize / 2; |
401 | num_number = filesize / 2; |
402 | 402 | ||
403 | HugeBuf = (char *)allocmem(filesize + 1); // ðàçáèðàåì êàê ñòðîêó, îòñþäà òåðìèíàòîð \0 |
403 | HugeBuf = (char *)allocmem(filesize + 1); // ðàçáèðàåì êàê ñòðîêó, îòñþäà òåðìèíàòîð \0 |
404 | 404 | ||
405 | for (i=0;i |
405 | for (i=0;i |
406 | HugeBuf[i] = 0; |
406 | HugeBuf[i] = 0; |
407 | 407 | ||
408 | strcpy(fileInfo.fileURL,edit_path); |
408 | strcpy(fileInfo.fileURL,edit_path); |
409 | fileInfo.OffsetLow = 0; |
409 | fileInfo.OffsetLow = 0; |
410 | 410 | ||
411 | fileInfo.OffsetHigh = 0; |
411 | fileInfo.OffsetHigh = 0; |
412 | fileInfo.dataCount = filesize; |
412 | fileInfo.dataCount = filesize; |
413 | fileInfo.rwMode = 0; |
413 | fileInfo.rwMode = 0; |
414 | fileInfo.bufferPtr = (Byte *)HugeBuf; |
414 | fileInfo.bufferPtr = (Byte *)HugeBuf; |
415 | rr = kos_FileSystemAccess( &(fileInfo) ); // êàêàÿ-òî ïðîáëåìà ñ hands.dll, CKosFile íå ðàáîòàë |
415 | rr = kos_FileSystemAccess( &(fileInfo) ); // êàêàÿ-òî ïðîáëåìà ñ hands.dll, CKosFile íå ðàáîòàë |
416 | 416 | ||
417 | sprintf(debuf, "read3: %U\n", rr); |
417 | sprintf(debuf, "read3: %U\n", rr); |
418 | rtlDebugOutString(debuf); |
418 | rtlDebugOutString(debuf); |
419 | 419 | ||
420 | strcpy(full_head, header); |
420 | strcpy(full_head, header); |
421 | strcpy(full_head+strlen(full_head), " - "); |
421 | strcpy(full_head+strlen(full_head), " - "); |
422 | strcpy(full_head+strlen(full_head), edit_path); // bad code |
422 | strcpy(full_head+strlen(full_head), edit_path); // bad code |
423 | 423 | ||
424 | // à òåïåðü ðàçîáðàòüñÿ â ýòîì |
424 | // à òåïåðü ðàçîáðàòüñÿ â ýòîì |
425 | 425 | ||
426 | i=0; |
426 | i=0; |
427 | k=0; |
427 | k=0; |
428 | while (i < filesize) |
428 | while (i < filesize) |
429 | { |
429 | { |
430 | 430 | ||
431 | while (isalpha(HugeBuf[i]) && i |
431 | while (isalpha(HugeBuf[i]) && i |
432 | if (i == filesize) break; |
432 | if (i == filesize) break; |
433 | if (k==4 && HugeBuf[i] == '=') |
433 | if (k==4 && HugeBuf[i] == '=') |
434 | { |
434 | { |
435 | //sprintf(debuf,"function: %S",HugeBuf + i); |
435 | //sprintf(debuf,"function: %S",HugeBuf + i); |
436 | //rtlDebugOutString(debuf); |
436 | //rtlDebugOutString(debuf); |
437 | // we have a function here |
437 | // we have a function here |
438 | //HugeBuf[0] = ' '; |
438 | //HugeBuf[0] = ' '; |
439 | funct = HugeBuf + i + 1; |
439 | funct = HugeBuf + i + 1; |
440 | strcpy(full_head+strlen(full_head), ". Function y="); |
440 | strcpy(full_head+strlen(full_head), ". Function y="); |
441 | strcpy(full_head+strlen(full_head), funct); |
441 | strcpy(full_head+strlen(full_head), funct); |
442 | return 1; |
442 | return 1; |
443 | } |
443 | } |
444 | 444 | ||
445 | d = convert(HugeBuf+i, &j); |
445 | d = convert(HugeBuf+i, &j); |
446 | if (d == ERROR) |
446 | if (d == ERROR) |
447 | { |
447 | { |
448 | sprintf(debuf, "Error in input file, byte %U, count %U\n", i, k); |
448 | sprintf(debuf, "Error in input file, byte %U, count %U\n", i, k); |
449 | rtlDebugOutString(debuf); |
449 | rtlDebugOutString(debuf); |
450 | kos_WriteTextToWindow(10, 10, 0, 0x00, (char*)debuf, strlen(debuf)); |
450 | kos_WriteTextToWindow(10, 10, 0, 0x00, (char*)debuf, strlen(debuf)); |
451 | return 0; |
451 | return 0; |
452 | } |
452 | } |
453 | if (d == ERROR_END) |
453 | if (d == ERROR_END) |
454 | { |
454 | { |
455 | rtlDebugOutString("EOF :)!\n"); |
455 | rtlDebugOutString("EOF :)!\n"); |
456 | break; |
456 | break; |
457 | } |
457 | } |
458 | 458 | ||
459 | i+=j; |
459 | i+=j; |
460 | switch (k) |
460 | switch (k) |
461 | { |
461 | { |
462 | case 0: |
462 | case 0: |
463 | x1=d; |
463 | x1=d; |
464 | break; |
464 | break; |
465 | case 1: |
465 | case 1: |
466 | x2=d; |
466 | x2=d; |
467 | break; |
467 | break; |
468 | case 2: |
468 | case 2: |
469 | y1=d; |
469 | y1=d; |
470 | break; |
470 | break; |
471 | case 3: |
471 | case 3: |
472 | y2=d; |
472 | y2=d; |
473 | break; |
473 | break; |
474 | default: |
474 | default: |
475 | { |
475 | { |
476 | if (p2 == NULL) |
476 | if (p2 == NULL) |
477 | p2 = (double *)allocmem(num_number * 8); |
477 | p2 = (double *)allocmem(num_number * 8); |
478 | p2[k-4]=d; |
478 | p2[k-4]=d; |
479 | } |
479 | } |
480 | } |
480 | } |
481 | k++; |
481 | k++; |
482 | } |
482 | } |
483 | // format(debuf, 30, "(%f,%f)-(%f,%f)",x1,y1,x2,y2); |
483 | // format(debuf, 30, "(%f,%f)-(%f,%f)",x1,y1,x2,y2); |
484 | // rtlDebugOutString(debuf); |
484 | // rtlDebugOutString(debuf); |
485 | point_count=(k - 4)/2; |
485 | point_count=(k - 4)/2; |
486 | 486 | ||
487 | // |
487 | // |
488 | points = (double *)allocmem(point_count * 2 * 8); |
488 | points = (double *)allocmem(point_count * 2 * 8); |
489 | for (i = 0; i < point_count * 2; i++) |
489 | for (i = 0; i < point_count * 2; i++) |
490 | points[i] = p2[i]; |
490 | points[i] = p2[i]; |
491 | freemem(p2); |
491 | freemem(p2); |
492 | // sprintf(debuf, "count: %U\n", point_count); |
492 | // sprintf(debuf, "count: %U\n", point_count); |
493 | // rtlDebugOutString(debuf); |
493 | // rtlDebugOutString(debuf); |
494 | sprintf(debuf, ". Number of points: %U.", point_count); |
494 | sprintf(debuf, ". Number of points: %U.", point_count); |
495 | strcpy(full_head+strlen(full_head), debuf); |
495 | strcpy(full_head+strlen(full_head), debuf); |
496 | freemem(HugeBuf); |
496 | freemem(HugeBuf); |
497 | HugeBuf = NULL; |
497 | HugeBuf = NULL; |
498 | return 1; |
498 | return 1; |
499 | } |
499 | } |
500 | 500 | ||
501 | void LaunchTinypad() |
501 | void LaunchTinypad() |
502 | { |
502 | { |
503 | kosFileInfo fileInfo; |
503 | kosFileInfo fileInfo; |
504 | 504 | ||
505 | strcpy(fileInfo.fileURL,"/sys/tinypad"); |
505 | strcpy(fileInfo.fileURL,"/sys/tinypad"); |
506 | fileInfo.OffsetLow = 0; |
506 | fileInfo.OffsetLow = 0; |
507 | fileInfo.OffsetHigh = (Dword)edit_path; |
507 | fileInfo.OffsetHigh = (Dword)edit_path; |
508 | fileInfo.rwMode = 7; // launch |
508 | fileInfo.rwMode = 7; // launch |
509 | kos_FileSystemAccess(&fileInfo); |
509 | kos_FileSystemAccess(&fileInfo); |
510 | 510 | ||
511 | } |
511 | } |
512 | 512 | ||
513 | // âû÷èñëèòü çàäàííóþ ôóíêöèþ èëè êóñî÷íî-ëèíåéíóþ ìåæäó òî÷êàìè |
513 | // âû÷èñëèòü çàäàííóþ ôóíêöèþ èëè êóñî÷íî-ëèíåéíóþ ìåæäó òî÷êàìè |
514 | double fu(double x) |
514 | double fu(double x) |
515 | { |
515 | { |
516 | int i; |
516 | int i; |
517 | double res; |
517 | double res; |
518 | 518 | ||
519 | 519 | ||
520 | if (funct) |
520 | if (funct) |
521 | { |
521 | { |
522 | set_exp(funct,x); |
522 | set_exp(funct,x); |
523 | get_exp(&res); // ïàðñèòü äëÿ êàæäîãî çíà÷åíèÿ õ? äà ÿ ñ óìà ñîøåë. |
523 | get_exp(&res); // ïàðñèòü äëÿ êàæäîãî çíà÷åíèÿ õ? äà ÿ ñ óìà ñîøåë. |
524 | return res; |
524 | return res; |
525 | } |
525 | } |
526 | 526 | ||
527 | if (point_count == 0) |
527 | if (point_count == 0) |
528 | { |
528 | { |
529 | return 0.0; |
529 | return 0.0; |
530 | } |
530 | } |
531 | 531 | ||
532 | if (x <= points[0]) |
532 | if (x <= points[0]) |
533 | return points[1]; |
533 | return points[1]; |
534 | if (x >= points[(point_count-1) * 2]) |
534 | if (x >= points[(point_count-1) * 2]) |
535 | return points[(point_count-1) * 2 + 1]; |
535 | return points[(point_count-1) * 2 + 1]; |
536 | 536 | ||
537 | for (i = 0; i < point_count; i++) |
537 | for (i = 0; i < point_count; i++) |
538 | { |
538 | { |
539 | if ((x >= points[2 * i]) && (x < points[2 * (i + 1)])) |
539 | if ((x >= points[2 * i]) && (x < points[2 * (i + 1)])) |
540 | break; |
540 | break; |
541 | } |
541 | } |
542 | 542 | ||
543 | return (x - points[2 * i]) / (points[2 * (i + 1)] - points[2 * i]) |
543 | return (x - points[2 * i]) / (points[2 * (i + 1)] - points[2 * i]) |
544 | * (points[2 * (i + 1) + 1] - points[2 * i + 1]) + points[2 * i + 1]; |
544 | * (points[2 * (i + 1) + 1] - points[2 * i + 1]) + points[2 * i + 1]; |
545 | 545 | ||
546 | } |
546 | } |
547 | 547 | ||
548 | void draw_window(void) |
548 | void draw_window(void) |
549 | { |
549 | { |
550 | double xx0=0.0, yy0=0.0; |
550 | double xx0=0.0, yy0=0.0; |
551 | 551 | ||
552 | kos_WindowRedrawStatus(1); |
552 | kos_WindowRedrawStatus(1); |
553 | kos_DefineAndDrawWindow(100,80,WND_W,WND_H, 0x33,0xFFFFFF,0,0,(Dword)full_head); |
553 | kos_DefineAndDrawWindow(100,80,WND_W,WND_H, 0x33,0xFFFFFF,0,0,(Dword)full_head); |
554 | kos_WindowRedrawStatus(2); |
554 | kos_WindowRedrawStatus(2); |
555 | 555 | ||
556 | sProcessInfo info; |
556 | sProcessInfo info; |
557 | kos_ProcessInfo(&info, 0xFFFFFFFF); |
557 | kos_ProcessInfo(&info, 0xFFFFFFFF); |
558 | int cWidth = info.processInfo.width - 9; |
558 | int cWidth = info.processInfo.width - 9; |
559 | int cHeight = info.processInfo.height - kos_GetSkinHeight() - 4; |
559 | int cHeight = info.processInfo.height - kos_GetSkinHeight() - 4; |
560 | 560 | ||
561 | mybox.top = cHeight - 50; |
561 | mybox.top = cHeight - 50; |
562 | mybox.width = cWidth - mybox.left - 80; |
562 | mybox.width = cWidth - mybox.left - 80; |
563 | 563 | ||
564 | if (info.processInfo.status_window&0x04) return; //draw nothing if window is rolled-up |
564 | if (info.processInfo.status_window&0x04) return; //draw nothing if window is rolled-up |
565 | 565 | ||
566 | if (point_count == 0 && funct == NULL) |
566 | if (point_count == 0 && funct == NULL) |
567 | { |
567 | { |
568 | kos_WriteTextToWindow((cWidth - 8 * strlen(empty_text))/2,cHeight/2-25,0x90, |
568 | kos_WriteTextToWindow((cWidth - 8 * strlen(empty_text))/2,cHeight/2-25,0x90, |
569 | 0x000000,(char *)empty_text,strlen(empty_text)); |
569 | 0x000000,(char *)empty_text,strlen(empty_text)); |
570 | } |
570 | } |
571 | else |
571 | else |
572 | { |
572 | { |
573 | drawFunction(&fu, coord(10, 20), coord(id(cWidth - 20), id(cHeight - 70)), |
573 | drawFunction(&fu, coord(10, 20), coord(id(cWidth - 20), id(cHeight - 70)), |
574 | coord(x1,y1), coord(x2,y2), 0x00ff0000); |
574 | coord(x1,y1), coord(x2,y2), 0x00ff0000); |
575 | 575 | ||
576 | } |
576 | } |
577 | 577 | ||
578 | kos_WriteTextToWindow(15, mybox.top + 4, 0x90, 0x000000, (char*)str_filename, strlen(str_filename)); |
578 | kos_WriteTextToWindow(15, mybox.top + 4, 0x90, 0x000000, (char*)str_filename, strlen(str_filename)); |
579 | 579 | ||
580 | edit_box_draw((DWORD)&mybox); |
580 | edit_box_draw((DWORD)&mybox); |
581 | 581 | ||
582 | kos_DefineButton(cWidth - 70, mybox.top, 50, 21, 5, 0xc0c0c0); |
582 | kos_DefineButton(cWidth - 70, mybox.top, 50, 21, 5, 0xc0c0c0); |
583 | kos_WriteTextToWindow(cWidth - 60, mybox.top + 4, 0x90, 0x000000, (char*)str_editfile,0); |
583 | kos_WriteTextToWindow(cWidth - 60, mybox.top + 4, 0x90, 0x000000, (char*)str_editfile,0); |
584 | } |
584 | } |
585 | 585 | ||
586 | void kos_Main() |
586 | void kos_Main() |
587 | { |
587 | { |
588 | kos_InitHeap(); |
588 | kos_InitHeap(); |
589 | full_head = (char*)allocmem(300); |
589 | full_head = (char*)allocmem(300); |
590 | strcpy(full_head, "Graph"); |
590 | strcpy(full_head, "Graph"); |
591 | load_edit_box(); |
591 | load_edit_box(); |
592 | if (params[0]) // fuck[0] for debug |
592 | if (params[0]) // fuck[0] for debug |
593 | { |
593 | { |
594 | rtlDebugOutString("launched with params"); |
594 | rtlDebugOutString("launched with params"); |
595 | rtlDebugOutString((char*)params); |
595 | rtlDebugOutString((char*)params); |
596 | strcpy(edit_path, params); |
596 | strcpy(edit_path, params); |
597 | mybox.size=mybox.pos=strlen(edit_path); |
597 | mybox.size=mybox.pos=strlen(edit_path); |
598 | //rtlDebugOutString((char*)edit_path); |
598 | //rtlDebugOutString((char*)edit_path); |
599 | load_points3(); |
599 | load_points3(); |
600 | } |
600 | } |
601 | rtlDebugOutString("data loaded.\n"); |
601 | rtlDebugOutString("data loaded.\n"); |
602 | draw_window(); |
602 | draw_window(); |
603 | for (;;) |
603 | for (;;) |
604 | { |
604 | { |
605 | edit_box_mouse((dword)&mybox); |
605 | edit_box_mouse((dword)&mybox); |
606 | switch (kos_WaitForEvent()) |
606 | switch (kos_WaitForEvent()) |
607 | { |
607 | { |
608 | case 1: |
608 | case 1: |
609 | draw_window(); |
609 | draw_window(); |
610 | break; |
610 | break; |
611 | case 2: |
611 | case 2: |
612 | // key pressed, read it |
612 | // key pressed, read it |
613 | Byte keyCode; |
613 | Byte keyCode; |
614 | kos_GetKey(keyCode); |
614 | kos_GetKey(keyCode); |
615 | 615 | ||
616 | switch (keyCode) |
616 | switch (keyCode) |
617 | { |
617 | { |
618 | case 0x0D: |
618 | case 0x0D: |
619 | if (HugeBuf!=NULL) |
619 | if (HugeBuf!=NULL) |
620 | { |
620 | { |
621 | //sprintf(debuf, "freemem: HugeBuf = %X", HugeBuf); |
621 | //sprintf(debuf, "freemem: HugeBuf = %X", HugeBuf); |
622 | //rtlDebugOutString(debuf); |
622 | //rtlDebugOutString(debuf); |
623 | freemem((void*)HugeBuf); // ÷òî çà áàã - ïîíÿòü íå ìîãó. |
623 | freemem((void*)HugeBuf); // ÷òî çà áàã - ïîíÿòü íå ìîãó. |
624 | HugeBuf = NULL; |
624 | HugeBuf = NULL; |
625 | funct = NULL; |
625 | funct = NULL; |
626 | } |
626 | } |
627 | if (points!=NULL) |
627 | if (points!=NULL) |
628 | { |
628 | { |
629 | //sprintf(debuf, "freemem: points = %X", points); |
629 | //sprintf(debuf, "freemem: points = %X", points); |
630 | //rtlDebugOutString(debuf); |
630 | //rtlDebugOutString(debuf); |
631 | freemem((void*)points); // è òóò. íó íå îáðàùàþñü ÿ ê ýòîìó óêàçàòåëþ, òîëüêî ïàìÿòü â íåãî |
631 | freemem((void*)points); // è òóò. íó íå îáðàùàþñü ÿ ê ýòîìó óêàçàòåëþ, òîëüêî ïàìÿòü â íåãî |
632 | // ïîòîì ñíîâà âûäåëÿþ |
632 | // ïîòîì ñíîâà âûäåëÿþ |
633 | points = NULL; |
633 | points = NULL; |
634 | } |
634 | } |
635 | point_count = 0; |
635 | point_count = 0; |
636 | kos_DrawBar(10,10,200,20,0xFFFFFF); // ôîí äëÿ ñîîáùåíèé îá îøèáêàõ |
636 | kos_DrawBar(10,10,200,20,0xFFFFFF); // ôîí äëÿ ñîîáùåíèé îá îøèáêàõ |
637 | if (load_points3()) |
637 | if (load_points3()) |
638 | draw_window(); |
638 | draw_window(); |
639 | break; |
639 | break; |
640 | default: |
640 | default: |
641 | { |
641 | { |
642 | __asm |
642 | __asm |
643 | { |
643 | { |
644 | mov ah, keyCode |
644 | mov ah, keyCode |
645 | } |
645 | } |
646 | edit_box_key((dword)&mybox); |
646 | edit_box_key((dword)&mybox); |
647 | } |
647 | } |
648 | } |
648 | } |
649 | break; |
649 | break; |
650 | 650 | ||
651 | 651 | ||
652 | case 3: |
652 | case 3: |
653 | // button pressed; we have only one button, close |
653 | // button pressed; we have only one button, close |
654 | Dword button; |
654 | Dword button; |
655 | kos_GetButtonID(button); |
655 | kos_GetButtonID(button); |
656 | if (button == 1) |
656 | if (button == 1) |
657 | kos_ExitApp(); |
657 | kos_ExitApp(); |
658 | if (button == 5) |
658 | if (button == 5) |
659 | LaunchTinypad(); |
659 | LaunchTinypad(); |
660 | } |
660 | } |
661 | } |
661 | } |
662 | }>>=>>> |
662 | }>>=>>> |
663 | >>>=>=>=>=>=>=>>> |
663 | >>>=>=>=>=>=>=>>> |