Subversion Repositories Kolibri OS

Rev

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