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