Subversion Repositories Kolibri OS

Rev

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