Subversion Repositories Kolibri OS

Rev

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