Subversion Repositories Kolibri OS

Rev

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

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