Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1971 lev 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;
2085 leency 13
dword  I_Path       = #program_path;
2566 leency 14
char param[4096];
15
char program_path[4096];
1971 lev 16
 
17
//Events
18
#define evMouse	6
19
#define evButton	3
20
#define evKey		2
21
#define evReDraw	1
22
 
23
//Button options
24
#define BT_DEL		0x80000000
25
#define BT_HIDE		0x40000000
26
#define BT_NOFRAME	0x20000000
27
 
28
#define OLD		-1
29
#define true		1
30
#define false		0
31
//-------------------------------------------------------------------------
32
 
33
struct mouse{
34
 dword x,y,lkm,pkm,hor,vert;
35
 void get();
36
};
37
 
38
void mouse::get()
39
{
40
	EAX = 37;
41
	EBX = 1;
42
	$int	0x40
43
	$mov	ebx, eax
44
	$shr	eax, 16
45
	$and	ebx,0x0000FFFF
46
	x = EAX;
47
	y = EBX;
48
	EAX = 37;
49
	EBX = 2;
50
	$int	0x40
51
	$mov	ebx, eax
52
	$and	eax, 0x00000001
53
	$shr	ebx, 1
54
	$and	ebx, 0x00000001
55
	lkm = EAX;
56
	pkm = EBX;
57
	EAX = 37; //скролл
58
	EBX = 7;
59
	$int	0x40
60
	$mov	ebx, eax
61
	$shr	eax, 16
62
	$and	ebx,0x0000FFFF
63
	//hor = EAX;
64
	vert = EBX;
65
}
66
 
67
 
68
struct system_colors{
69
	dword frame,grab,grab_button,grab_button_text,grab_text,work,work_button,work_button_text,work_text,work_graph;
70
	void get();
71
};
72
void system_colors::get()
73
{
74
	EAX = 48;
75
	EBX = 3;
76
	ECX = #frame;
77
	EDX = 40;
78
	$int 0x40
79
}
80
 
81
//------------------------------------------------------------------------------
82
 
83
inline fastcall dword WaitEvent(){
2765 leency 84
	$mov eax,10
85
	$int 0x40
1971 lev 86
}
87
 
2765 leency 88
inline fastcall dword CheckEvent(){
89
	$mov eax,11
90
	$int 0x40
91
}
92
 
1971 lev 93
inline fastcall dword WaitEventTimeout(dword EBX){
2765 leency 94
	$mov eax,23
95
	$int 0x40
1971 lev 96
}
97
 
98
inline fastcall SetEventMask(dword EBX)
99
{
2765 leency 100
	$mov eax,40
101
	$int 0x40
1971 lev 102
}
103
 
104
inline fastcall ScancodesGeting(){
2765 leency 105
	$mov eax,66
106
	$mov ebx,1
107
	$mov ecx,1 //сканкоды
1971 lev 108
	$int 0x40
109
}
110
 
2085 leency 111
 
112
inline fastcall word GetKey(){ //Gluk fix
113
		$push edx
114
@getkey:
115
		$mov  eax,2
116
		$int  0x40
117
		$cmp eax,1
118
		$jne getkeyi
119
		$mov ah,dh
120
		$jmp getkeyii //jz?
121
@getkeyi:
122
		$mov dh,ah
123
		$jmp getkey
124
@getkeyii:
125
		$pop edx
2765 leency 126
		$shr eax,8
1971 lev 127
}
128
 
2416 leency 129
 
130
inline fastcall Pause(dword EBX)
131
{					//Пауза, в сотых долях секунды EBX = value
132
	$mov eax, 5
133
	$int 0x40
134
}
135
 
136
//==================================================================
137
 
1971 lev 138
inline fastcall word GetButtonID(){
2765 leency 139
	$mov eax,17
140
	$int  0x40
141
	$shr eax,8
1971 lev 142
}
143
 
2416 leency 144
struct proc_info{
145
	dword	use_cpu;
146
	word	pos_in_stack,num_slot,rezerv1;
147
	char	name[11];
148
	char	rezerv2;
149
	dword	adress,use_memory,ID,left,top,width,height;
150
	word	status_slot,rezerv3;
151
	dword	work_left,work_top,work_width,work_height;
152
	char	status_window;
153
	void	GetInfo(dword ECX);
154
	byte    reserved[1024-71];
155
#define SelfInfo -1
156
};
157
 
158
void GetProcessInfo(dword EBX, ECX)
159
{
2765 leency 160
	$mov eax,9;
2416 leency 161
	$int  0x40
162
}
163
 
164
int GetProcessSlot(ECX) //ECX = process ID
165
{
166
	EAX = 18;
167
	EBX = 21;
168
	$int 0x40;
169
}
170
 
2763 leency 171
inline fastcall int ActiveProcess()
172
{
173
	EAX = 18;
174
	EBX = 7;
175
	$int 0x40
176
}
177
 
178
 
1971 lev 179
inline fastcall ExitProcess(){
2765 leency 180
	$mov eax,-1;
181
	$int 0x40
1971 lev 182
}
183
 
2803 leency 184
inline fastcall int KillProcess(dword ECX){
2416 leency 185
	$mov eax,18;
186
	$mov ebx,18;
1971 lev 187
	$int 0x40
188
}
189
 
2416 leency 190
//==================================================================
1971 lev 191
 
2252 leency 192
//eax =  ч√ъ ёшёЄхь√ (1=eng, 2=fi, 3=ger, 4=rus)
193
inline fastcall int GetSystemLanguage(){
194
 EAX = 26;
195
 EBX = 5;
196
 $int 0x40
197
 RETURN EAX;
198
}
199
 
1971 lev 200
inline fastcall void DrawTitle(dword ECX)
201
{
202
	EAX = 71;
203
	EBX = 1;
204
	$int 0x40;
205
}
206
 
207
inline fastcall dword GetSkinWidth()
208
{
2803 leency 209
	$push ebx
210
	$mov  eax,48
211
	$mov  ebx,4
1971 lev 212
	$int 0x40
2803 leency 213
	$pop  ebx
1971 lev 214
}
215
 
2495 leency 216
inline fastcall void SetSystemSkin(ECX){
1971 lev 217
	EAX = 48;
218
	EBX = 8;
219
	$int 0x40
220
}
221
 
222
inline fastcall dword GetScreenWidth()
223
{
224
	EAX = 14;
225
	EBX = 4;
226
	$int 0x40
227
	$shr eax, 16
228
	$and eax,0x0000FFFF
229
}
230
 
231
inline fastcall MoveSize(dword EBX,ECX,EDX,ESI)
232
{
233
	EAX = 67;
234
	$int 0x40
235
}
236
 
237
inline fastcall dword LoadLibrary(dword ECX)
238
{
239
	$mov eax, 68
240
	$mov ebx, 19
241
	$int  0x40
242
}
243
 
244
//------------------------------------------------------------------------------
245
inline fastcall dword strlen(dword EDI){
246
	EAX=0;
247
	ECX=-1;
248
	$REPNE $SCASB
249
	EAX-=2+ECX;
250
}
251
 
252
inline fastcall copystr(dword ESI,EDI)
253
{
254
	$cld
255
l1:
256
	$lodsb
257
	$stosb
258
	$test al,al
259
	$jnz l1
260
}
261
 
2252 leency 262
 
1971 lev 263
byte fastcall TestBit(EAX, CL)
264
{
265
	$shr eax,cl
266
	$and eax,1
267
}
268
 
269
char buffer[11]="";
270
inline fastcall dword IntToStr(dword ESI)
271
{
272
     $mov     edi, #buffer
273
     $mov     ecx, 10
274
     $test     esi, esi
275
     $jns     f1
276
     $mov     al, '-'
277
     $stosb
278
     $neg     esi
279
f1:
280
     $mov     eax, esi
281
     $push     -'0'
282
f2:
283
     $xor     edx, edx
284
     $div     ecx
285
     $push     edx
286
     $test     eax, eax
287
     $jnz     f2
288
f3:
289
     $pop     eax
290
     $add     al, '0'
291
     $stosb
292
     $jnz     f3
293
     $mov     eax, #buffer
294
     $ret
295
}
296
 
297
 
298
inline fastcall dword StrToInt()
299
{
300
	ESI=EDI=EAX;
301
	IF(DSBYTE[ESI]=='-')ESI++;
302
	EAX=0;
303
	BH=AL;
304
	do{
305
		BL=DSBYTE[ESI]-'0';
306
		EAX=EAX*10+EBX;
307
		ESI++;
308
	}while(DSBYTE[ESI]>0);
309
	IF(DSBYTE[EDI]=='-') -EAX;
310
}
311
 
312
 
313
inline fastcall int strcmp(ESI, EDI)
314
{
315
	loop()
316
	{
317
		IF (DSBYTE[ESI]
318
		IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1;
319
		IF (DSBYTE[ESI]=='\0') RETURN 0;
320
		ESI++;
321
		EDI++;
322
	}
323
}
324
 
325
inline fastcall unsigned int find_symbol(ESI,BL)
326
{
327
	int jj=0, last=-1;
328
	do{
329
		jj++;
330
		$lodsb
331
		IF(AL==BL) last=jj;
332
	} while(AL!=0);
333
	return last;
334
}
335
 
336
 
337
inline fastcall dword upcase(dword ESI)
338
{
339
	do{
340
		AL=DSBYTE[ESI];
341
		IF(AL>='a')IF(AL<='z')DSBYTE[ESI]=AL&0x5f;
342
 		ESI++;
343
	}while(AL!=0);
344
}
345
 
346
inline fastcall lowcase(ESI)
347
{
348
	do{
349
		$LODSB
350
		IF(AL>='A')&&(AL<='Z'){
351
			AL+=0x20;
352
			DSBYTE[ESI-1]=AL;
353
			CONTINUE;
354
		}
355
	}while(AL!=0);
356
}
357
 
358
 
2416 leency 359
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI)
1971 lev 360
{
361
	EAX = 12;              // function 12:tell os about windowdraw
2416 leency 362
	EBX = 1;
1971 lev 363
	$int 0x40
2416 leency 364
 
1971 lev 365
	EBX = x << 16 + sizeX;
366
	ECX = y << 16 + sizeY;
367
	EDX = mainAreaType << 24 | mainAreaColour;
368
	ESI = headerType << 24 | headerColour;
369
	$xor eax,eax
370
	$int 0x40
371
 
2416 leency 372
	EAX = 12;              // function 12:tell os about windowdraw
373
	EBX = 2;
374
	$int 0x40
375
}
376
 
377
 
2803 leency 378
inline fastcall int CreateThread(dword ECX,EDX)
1971 lev 379
{
380
	EAX = 51;
381
	EBX = 1;
382
	$int 0x40
383
}
384
 
2495 leency 385
inline fastcall int GetSlot(dword ECX)
386
{
387
	EAX = 18;
388
	EBX = 21;
389
	$int 0x40
390
}
391
 
392
inline fastcall int GetActiveProcess()
393
{
394
	EAX = 18;
395
	EBX = 7;
396
	$int 0x40
397
}
398
 
399
 
1971 lev 400
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
401
{
402
	EAX = 4;
403
	EBX = x<<16+y;
404
	ECX = fontType<<24+color;
405
	$int 0x40;
406
}
407
 
2444 leency 408
void CopyScreen(dword EBX, x, y, sizeX, sizeY)
409
{
410
  EAX = 36;
411
  ECX = sizeX << 16 + sizeY;
412
  EDX = x << 16 + y;
413
  $int  0x40;
414
}
415
 
1971 lev 416
void PutImage(dword EBX,w,h,x,y)
417
{
418
	EAX = 7;
419
	ECX = w<<16+h;
420
	EDX = x<<16+y;
421
	$int 0x40
422
}
423
 
424
void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
425
{
426
	EAX = 65;
427
	ECX = w<<16+h;
428
	EDX = x<<16+y;
429
	EBP = 0;
430
	$int 0x40
431
}
432
 
433
inline fastcall void PutPixel(dword EBX,ECX,EDX){
434
  EAX=1;
435
  $int 0x40
436
}
437
 
438
void DrawBar(dword x,y,w,h,EDX)
439
{
440
	EAX = 13;
441
	EBX = x<<16+w;
442
	ECX = y<<16+h;
443
 	$int 0x40
444
}
445
 
446
void DefineButton(dword x,y,w,h,EDX,ESI)
447
{
448
 	EAX = 8;
2528 leency 449
	$push edx
450
	EDX += BT_DEL; //тэрўрых єфры хь ъэюяє ё ¤Єш шф, яюЄюь ёючфр╕ь
451
	$int 0x40;
1971 lev 452
	EBX = x<<16+w;
453
	ECX = y<<16+h;
2528 leency 454
 	$pop edx
455
	$int 0x40
1971 lev 456
}
457
 
458
inline fastcall void DeleteButton(dword EDX)
459
{
460
	EAX = 8;
461
	EDX += BT_DEL;
462
	$int 0x40;
463
}
464
 
2252 leency 465
:void DrawRegion(dword x,y,width,height,color1)
1971 lev 466
{
467
	DrawBar(x,y,width,1,color1); //полоса гор сверху
468
	DrawBar(x,y+height,width,1,color1); //полоса гор снизу
469
	DrawBar(x,y,1,height,color1); //полоса верху слева
470
	DrawBar(x+width,y,1,height+1,color1); //полоса верху справа
471
}
472
 
2252 leency 473
:void DrawRegion_3D(dword x,y,width,height,color1,color2)
1971 lev 474
{
475
	DrawBar(x,y,width+1,1,color1); //полоса гор сверху
476
	DrawBar(x,y+1,1,height-1,color1); //полоса слева
477
	DrawBar(x+width,y+1,1,height,color2); //полоса справа
478
	DrawBar(x,y+height,width,1,color2); //полоса гор снизу
479
}
480
 
481
void DrawFlatButton(dword x,y,width,height,id,color,text)
482
{
483
	DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
484
	DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
485
	DrawBar(x+2,y+2,width-3,height-3,color); //заливка
486
	IF (id<>0)	DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //кнопка
487
	WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
488
}
489
 
2252 leency 490
:void DrawCircle(int x, y, r)
1971 lev 491
{
492
	int i; float px=0, py=r, ii = r * 3.1415926 * 2;
1974 yogev_ezra 493
	FOR (i = 0; i < ii; i++)
1971 lev 494
	{
495
        PutPixel(px + x, y - py, 0);
496
        px = py / r + px;
497
        py = -px / r + py;
498
	}
499
}
500
 
501
//------------------------------------------------------------------------------
502
 
2803 leency 503
inline fastcall void debug(dword EDX)
1971 lev 504
{
505
	$push ebx
506
	$push ecx
507
	$mov eax, 63
508
	$mov ebx, 1
509
next_char:
510
	$mov ecx, DSDWORD[edx]
511
	$or	 cl, cl
512
	$jz  done
513
	$int 0x40
514
	$inc edx
515
	$jmp next_char
516
done:
517
	$mov cl, 13
518
	$int 0x40
519
	$mov cl, 10
520
	$int 0x40
521
	$pop ecx
522
	$pop ebx
523
}