Subversion Repositories Kolibri OS

Rev

Rev 2825 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2811 leency 1
//CODED by Veliant, Leency, Nable. GNU GPL licence.
2
 
3
#startaddress 0
4
#code32 TRUE
5
 
6
char   os_name[8]   = {'M','E','N','U','E','T','0','1'};
7
dword  os_version   = 0x00000001;
8
dword  start_addr   = #main;
9
dword  final_addr   = #stop+32;
10
dword  alloc_mem    = #0x00100000;
11
dword  x86esp_reg   = #0x00100000;
12
dword  I_Param      = #param;
13
dword  I_Path       = #program_path;
14
char param[4096];
15
char program_path[4096];
16
 
17
//Events
18
#define evMouse   6
19
#define evButton  3
20
#define evKey     2
21
#define evReDraw  1
22
 
23
#define OLD      -1
24
#define true      1
25
#define false     0
26
 
27
//Button options
28
#define BT_DEL      0x80000000
29
#define BT_HIDE     0x40000000
30
#define BT_NOFRAME  0x20000000
31
 
32
//-------------------------------------------------------------------------
33
 
34
struct mouse
35
{
36
	dword x,y,lkm,pkm,hor,vert;
37
	void get();
38
};
39
 
40
void mouse::get()
41
{
42
	EAX = 37;
43
	EBX = 1;
44
	$int	0x40
45
	$mov	ebx, eax
46
	$shr	eax, 16
47
	$and	ebx,0x0000FFFF
48
	x = EAX;
49
	y = EBX;
50
	EAX = 37;
51
	EBX = 2;
52
	$int	0x40
53
	$mov	ebx, eax
54
	$and	eax, 0x00000001
55
	$shr	ebx, 1
56
	$and	ebx, 0x00000001
57
	lkm = EAX;
58
	pkm = EBX;
59
	EAX = 37; //скролл
60
	EBX = 7;
61
	$int	0x40
62
	$mov	ebx, eax
63
	$shr	eax, 16
64
	$and	ebx,0x0000FFFF
65
	//hor = EAX;
66
	vert = EBX;
67
}
68
 
69
 
70
struct system_colors
71
{
72
	dword frame,grab,grab_button,grab_button_text,grab_text,work,work_button,work_button_text,work_text,work_graph;
73
	void get();
74
};
75
 
76
void system_colors::get()
77
{
78
	EAX = 48;
79
	EBX = 3;
80
	ECX = #frame;
81
	EDX = 40;
82
	$int 0x40
83
}
84
 
85
//------------------------------------------------------------------------------
86
 
87
inline fastcall dword WaitEvent()
88
{
89
	$mov eax,10
90
	$int 0x40
91
}
92
 
93
inline fastcall dword CheckEvent()
94
{
95
	$mov eax,11
96
	$int 0x40
97
}
98
 
99
inline fastcall dword WaitEventTimeout( EBX)
100
{
101
	$mov eax,23
102
	$int 0x40
103
}
104
 
105
inline fastcall SetEventMask( EBX)
106
{
107
	$mov eax,40
108
	$int 0x40
109
}
110
 
111
inline fastcall ScancodesGeting(){
112
	$mov eax,66
113
	$mov ebx,1
114
	$mov ecx,1 //сканкоды
115
	$int 0x40
116
}
117
 
118
 
119
inline fastcall word GetKey()  //+Gluk fix
120
{
121
		$push edx
122
@getkey:
123
		$mov  eax,2
124
		$int  0x40
125
		$cmp eax,1
126
		$jne getkeyi
127
		$mov ah,dh
128
		$jmp getkeyii //jz?
129
@getkeyi:
130
		$mov dh,ah
131
		$jmp getkey
132
@getkeyii:
133
		$pop edx
134
		$shr eax,8
135
}
136
 
137
 
138
inline fastcall Pause( EBX)
139
{
140
	$mov eax, 5
141
	$int 0x40
142
}
143
 
144
inline fastcall word GetButtonID()
145
{
146
	$mov eax,17
147
	$int  0x40
148
	$shr eax,8
149
}
150
 
2839 leency 151
//----------------------------------------
152
 
2811 leency 153
struct proc_info
154
{
155
	#define SelfInfo -1
156
	dword	use_cpu;
157
	word	pos_in_stack,num_slot,rezerv1;
158
	char	name[11];
159
	char	rezerv2;
160
	dword	adress,use_memory,ID,left,top,width,height;
161
	word	status_slot,rezerv3;
162
	dword	work_left,work_top,work_width,work_height;
163
	char	status_window;
164
	void	GetInfo( ECX);
165
	byte    reserved[1024-71];
166
};
167
 
168
void GetProcessInfo( EBX, ECX)
169
{
170
	$mov eax,9;
171
	$int  0x40
172
}
173
 
2839 leency 174
inline fastcall int GetPointOwner( EBX, ECX) //ebx=m.x, ecx=m.y
175
{
176
	$mov eax,34
177
	$int 0x40
178
}
179
 
2825 leency 180
inline fastcall int GetProcessSlot( ECX)
2811 leency 181
{
182
	EAX = 18;
183
	EBX = 21;
2825 leency 184
	$int 0x40
2811 leency 185
}
186
 
2825 leency 187
inline fastcall int GetActiveProcess()
2811 leency 188
{
189
	EAX = 18;
190
	EBX = 7;
191
	$int 0x40
192
}
193
 
2839 leency 194
inline fastcall int CreateThread( ECX,EDX)
195
{
196
	$mov eax,51
197
	$mov ebx,1
198
	$int 0x40
199
}
2811 leency 200
 
2839 leency 201
inline fastcall void SwitchToAnotherThread()
202
{
203
	$mov eax,68
204
	$mov ebx,1
205
	$int 0x40
206
}
207
 
2811 leency 208
inline fastcall ExitProcess()
209
{
210
	$mov eax,-1;
211
	$int 0x40
212
}
213
 
214
inline fastcall int KillProcess( ECX)
215
{
216
	$mov eax,18;
217
	$mov ebx,18;
218
	$int 0x40
219
}
220
 
221
//------------------------------------------------------------------------------
222
 
223
//eax =  ч√ъ ёшёЄхь√ (1=eng, 2=fi, 3=ger, 4=rus)
224
inline fastcall int GetSystemLanguage()
225
{
226
	EAX = 26;
227
	EBX = 5;
228
	$int 0x40
229
}
230
 
231
inline fastcall dword GetSkinWidth()
232
{
233
	$push ebx
234
	$mov  eax,48
235
	$mov  ebx,4
236
	$int 0x40
237
	$pop  ebx
238
}
239
 
2825 leency 240
inline fastcall void SetSystemSkin( ECX)
241
{
2811 leency 242
	EAX = 48;
243
	EBX = 8;
244
	$int 0x40
245
}
246
 
247
inline fastcall dword GetScreenWidth()
248
{
249
	EAX = 14;
250
	EBX = 4;
251
	$int 0x40
252
	$shr eax, 16
253
	$and eax,0x0000FFFF
254
}
255
 
256
inline fastcall dword LoadLibrary( ECX)
257
{
258
	$mov eax, 68
259
	$mov ebx, 19
260
	$int  0x40
261
}
262
 
263
byte fastcall TestBit( EAX, CL)
264
{
265
	$shr eax,cl
266
	$and eax,1
267
}
268
 
2825 leency 269
 
2811 leency 270
//------------------------------------------------------------------------------
271
 
272
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI)
273
{
274
	EAX = 12;              // function 12:tell os about windowdraw
275
	EBX = 1;
276
	$int 0x40
277
 
278
	EBX = x << 16 + sizeX;
279
	ECX = y << 16 + sizeY;
280
	EDX = mainAreaType << 24 | mainAreaColour;
281
	ESI = headerType << 24 | headerColour;
282
	$xor eax,eax
283
	$int 0x40
284
 
285
	EAX = 12;              // function 12:tell os about windowdraw
286
	EBX = 2;
287
	$int 0x40
288
}
289
 
2825 leency 290
inline fastcall MoveSize( EBX,ECX,EDX,ESI)
2811 leency 291
{
2825 leency 292
	EAX = 67;
2811 leency 293
	$int 0x40
294
}
295
 
2825 leency 296
inline fastcall void DrawTitle( ECX)
2811 leency 297
{
2825 leency 298
	EAX = 71;
299
	EBX = 1;
300
	$int 0x40;
2811 leency 301
}
302
 
303
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
304
{
305
	EAX = 4;
306
	EBX = x<<16+y;
307
	ECX = fontType<<24+color;
308
	$int 0x40;
309
}
310
 
311
void CopyScreen(dword EBX, x, y, sizeX, sizeY)
312
{
313
  EAX = 36;
314
  ECX = sizeX << 16 + sizeY;
315
  EDX = x << 16 + y;
316
  $int  0x40;
317
}
318
 
319
void PutImage(dword EBX,w,h,x,y)
320
{
321
	EAX = 7;
322
	ECX = w<<16+h;
323
	EDX = x<<16+y;
324
	$int 0x40
325
}
326
 
327
void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
328
{
329
	EAX = 65;
330
	ECX = w<<16+h;
331
	EDX = x<<16+y;
332
	EBP = 0;
333
	$int 0x40
334
}
335
 
336
inline fastcall void PutPixel( EBX,ECX,EDX)
337
{
338
  EAX=1;
339
  $int 0x40
340
}
341
 
342
void DrawBar(dword x,y,w,h,EDX)
343
{
344
	EAX = 13;
345
	EBX = x<<16+w;
346
	ECX = y<<16+h;
347
 	$int 0x40
348
}
349
 
350
void DefineButton(dword x,y,w,h,EDX,ESI)
351
{
352
 	EAX = 8;
353
	EBX = x<<16+w;
354
	ECX = y<<16+h;
355
	$int 0x40
356
}
357
 
358
inline fastcall void DeleteButton( EDX)
359
{
360
	EAX = 8;
361
	EDX += BT_DEL;
362
	$int 0x40;
363
}
364
 
2825 leency 365
 
366
//------------------------------------------------------------------------------
367
 
368
void DrawRegion(dword x,y,width,height,color1)
2811 leency 369
{
370
	DrawBar(x,y,width,1,color1); //полоса гор сверху
371
	DrawBar(x,y+height,width,1,color1); //полоса гор снизу
372
	DrawBar(x,y,1,height,color1); //полоса верху слева
373
	DrawBar(x+width,y,1,height+1,color1); //полоса верху справа
374
}
375
 
2825 leency 376
void DrawRegion_3D(dword x,y,width,height,color1,color2)
2811 leency 377
{
378
	DrawBar(x,y,width+1,1,color1); //полоса гор сверху
379
	DrawBar(x,y+1,1,height-1,color1); //полоса слева
380
	DrawBar(x+width,y+1,1,height,color2); //полоса справа
381
	DrawBar(x,y+height,width,1,color2); //полоса гор снизу
382
}
383
 
384
void DrawFlatButton(dword x,y,width,height,id,color,text)
385
{
386
	DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
387
	DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
388
	DrawBar(x+2,y+2,width-3,height-3,color); //заливка
389
	IF (id<>0)	DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //кнопка
2825 leency 390
	//WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
391
	WriteText(width/2+x+1,height/2-3+y,0x80,0,text,0);
2811 leency 392
}
393
 
2825 leency 394
void DrawCircle(int x, y, r)
2811 leency 395
{
2825 leency 396
	int i;
397
	float px=0, py=r, ii = r * 3.1415926 * 2;
2811 leency 398
	FOR (i = 0; i < ii; i++)
399
	{
400
        PutPixel(px + x, y - py, 0);
401
        px = py / r + px;
402
        py = -px / r + py;
403
	}
404
}
405
 
406
//------------------------------------------------------------------------------
407
 
408
inline fastcall void debug( EDX)
409
{
410
	$push ebx
411
	$push ecx
412
	$mov eax, 63
413
	$mov ebx, 1
414
next_char:
415
	$mov ecx, DSDWORD[edx]
416
	$or	 cl, cl
417
	$jz  done
418
	$int 0x40
419
	$inc edx
420
	$jmp next_char
421
done:
422
	$mov cl, 13
423
	$int 0x40
424
	$mov cl, 10
425
	$int 0x40
426
	$pop ecx
427
	$pop ebx
428
}