Subversion Repositories Kolibri OS

Rev

Rev 6761 | Rev 6773 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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