Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
773 gluk 1
#startaddress 0
2
#code32 TRUE
3
 
4
char   os_name[8]   = {'M','E','N','U','E','T','0','1'};
5
dword  os_version   = 0x00000001;
6
dword  start_addr   = #main;
7
dword  final_addr   = #stop+32;
8
dword  alloc_mem    = 0x00100000;
9
dword  x86esp_reg   = 0x0007fff0;
10
dword  I_Param      = 0x0;
11
dword  I_Icon       = 0x0;
12
dword			skin_width;
13
 
14
// KeyCode constant
15
#define UP_KEY     130+48
16
#define DOWN_KEY   129+48
17
#define LEFT_KEY   128+48
18
#define RIGHT_KEY  131+48
19
#define RETURN_KEY 13
20
 
21
// Color constant
22
#define clWhite 0x00ffffff
23
#define clBlack 0x00000000
24
#define clRed   0x00ff0000
25
#define clGreen 0x0000ff00
26
#define clBlue  0x000000ff
27
 
28
#define evButton  3
29
#define evKey     2
30
#define evReDraw  1
31
#define evNet	  8
32
 
33
#define BT_DEL		0x80000000
34
#define BT_HIDE		0x40000000
35
#define BT_NOFRAME	0x20000000
36
 
37
#define OLD			-1
38
 
39
struct FileInfo{
40
 dword read, firstBlock, qnBlockRead, retPtr, Work;
41
 byte  filedir;
42
};
43
//-------------------------------------------------------------------------
44
struct system_colors{
45
	dword frame,grab,grab_button,grab_button_text,grab_text,work,work_button,work_button_text,work_text,work_graph;
46
	void get();
47
};
48
void system_colors::get()
49
{
50
	EAX = 48;
51
	EBX = 3;
52
	ECX = #frame;
53
	EDX = 40;
54
	$int	0x40
55
}
56
 
57
struct mouse{
58
 dword x,y,lkm,pkm;
59
 void get();
60
};
61
 
62
void mouse::get()
63
{
64
	EAX = 37;
65
	EBX = 1;
66
	$int	0x40
67
	$mov	ebx, eax
68
	$shr	eax, 16
69
	$and	ebx,0x0000FFFF
70
	x = EAX;
71
	y = EBX;
72
	EAX = 37;
73
	EBX = 2;
74
	$int	0x40
75
	$mov	ebx, eax
76
	$and	eax, 0x00000001
77
	$shr	ebx, 1
78
	$and	ebx, 0x00000001
79
	lkm = EAX;
80
	pkm = EBX;
81
 
82
}
83
//---------------------------------------------------------------------------
84
struct f70{
85
	dword	func;
86
	dword	param1;
87
	dword	param2;
88
	dword	param3;
89
	dword	param4;
90
	char	rezerv;
91
	dword	name;
92
};
93
//---------------------------------------------------------------------------
94
struct BDVK{
95
	dword	attr;
96
	byte	type_name;
97
	byte	rez1, rez2, rez3;
98
	dword	timecreate;
99
	dword	datecreate;
100
	dword	timelastaccess;
101
	dword	datelastaccess;
102
	dword	timelastedit;
103
	dword	datelastedit;
104
	dword	sizelo;
105
	dword	sizehi;
106
	char	name[518];
107
};
108
//---------------------------------------------------------------------------
109
struct proc_info{
110
	dword	use_cpu;
111
	word	pos_in_stack,num_slot,rezerv1;
112
	char	name[11];
113
	char	rezerv2;
114
	dword	adress,use_memory,ID,left,top,width,height;
115
	word	status_slot,rezerv3;
116
	dword	work_left,work_top,work_width,work_height;
117
	char	status_window;
118
	void	getme();
119
};
120
 
121
void proc_info::getme()
122
{
123
	EAX = 9;
124
	EBX = #use_cpu;
125
	ECX = -1;
126
	$int	0x40
127
}
128
//-------------------------------------------------------------------------------
129
 
130
inline fastcall void begin_paint(){
131
#speed
132
 EAX = 12;              // function 12:tell os about windowdraw
133
 EBX = 1;               // 1, start of draw
134
 $int 0x40
135
#codesize
136
}
137
 
138
inline fastcall void end_paint(){
139
#speed
140
 EAX = 12;              // function 12:tell os about windowdraw
141
 EBX = 2;               // 1, start of draw
142
 $int 0x40
143
#codesize
144
}
145
 
146
/*
147
 ЋваЁб®ўЄ  ®Є­ 
148
  {x_start|y_start}, {x_size|y_size}, color_back, color_title, color_frames
149
 
150
 DrawWindow(
151
             EBX = [x_start][x_size]
152
             ECX = [y_start][y_size]
153
             EDX, ESI, EDI = [00RRGGBB]
154
           )
155
*/
156
 
157
inline fastcall void DrawWindow(dword EBX, ECX, EDX, ESI, EDI){
158
#speed
159
 EAX = 0;               // function 0 : define and draw window
160
 $int 0x40
161
#codesize
162
}
163
 
164
inline fastcall void DrawButton(dword EBX, ECX, EDX, ESI){
165
#speed
166
 EAX = 8;
167
 $int 0x40
168
#codesize
169
}
170
 
171
inline fastcall dword WaitEvent(){
172
#speed
173
 EAX = 10;              // wait here for event
174
 $int 0x40
175
#codesize
176
}
177
 
178
inline fastcall void ExitProcess(){
179
#speed
180
 EAX = -1;              // close this program
181
 $int 0x40
182
#codesize
183
}
184
 
185
/*
186
02 = GET KEY
187
 
188
     ret: al 0 successful -> ah = key
189
          al 1 no key in buffer
190
*/
191
inline fastcall word GetKey(){
192
#speed
193
 EAX = 2;              // just read it key from buffer
194
 $int  0x40
195
 EAX = EAX >> 8;
196
#codesize
197
}
198
 
199
/*
200
17 = GET PRESSED BUTTON ID
201
 
202
     ret: al 0 successful -> ah = id number
203
          al 1 no key in buffer
204
*/
205
inline fastcall word GetButtonID(){
206
#speed
207
 EAX = 17;            // Get ID
208
 $int  0x40
209
 EAX = EAX >> 8;
210
#codesize
211
}
212
 
213
/*
214
58 = SYSTEM TREE ACCESS
215
 
216
     ebx    pointer to fileinfo block
217
 
218
     fileinfo:
219
 
220
     dd   0x0                  ; 0=read (/write/delete/append)
221
     dd   0x0                  ; 512 block to read 0+
222
     dd   0x1                  ; blocks to read (/bytes to write/append)
223
     dd   0x20000              ; return data pointer
224
     dd   0x10000              ; work area for os - 16384 bytes
225
     db   '/RAMDISK/FIRST/KERNEL.ASM',0  ; ASCIIZ dir & filename
226
*/
227
inline fastcall void AccessSystemTree(dword EBX){
228
#speed
229
 EAX = 58;
230
 $int 0x40
231
#codesize
232
}
233
 
234
/*
235
04 = WRITE TEXT TO WINDOW
236
 
237
     ebx [x start]*65536 + [y start]
238
     ecx text color 0x00RRGGBB
239
     edx pointer to text beginning
240
     esi text length
241
     ret: nothing changed
242
*/
243
inline fastcall void WriteTextXY(dword EBX, ECX, EDX, ESI){
244
#speed
245
 EAX = 4;
246
 $int 0x40;
247
#codesize
248
}
249
 
250
/*
251
13 = DRAW BAR
252
 
253
     ebx [x start]*65536 + [x size]
254
     ecx [y start]*65536 + [y size]
255
     edx color 0x00RRGGBB
256
     ret: nothing changed
257
*/
258
inline fastcall void kos_DrawBar(dword EBX, ECX, EDX){
259
#speed
260
 EAX = 13;
261
 $int 0x40
262
#codesize
263
}
264
 
265
//CODED by Veliant
266
/*eax = 38 - номер функции
267
ebx = [координата начала по оси x]*65536 + [координата конца по оси x]
268
ecx = [координата начала по оси y]*65536 + [координата конца по оси y]
269
edx = 0x00RRGGBB - цвет
270
edx = 0x01xxxxxx - рисовать инверсный отрезок (младшие 24 бита игнорируются) */
271
inline fastcall void DrawLine(dword EBX, ECX, EDX){
272
#speed
273
 EAX = 38;
274
 $int 0x40
275
#codesize
276
}
277
 
278
inline fastcall void DrawTitle(dword ECX)
279
{
280
#speed
281
	EAX = 71;
282
	EBX = 1;
283
	$int 0x40;
284
#codesize
285
}
286
 
287
inline fastcall dword GetSkinWidth()
288
{
289
#speed
290
	EAX = 48;
291
	EBX = 4;
292
	$int 0x40
293
#codesize
294
}
295
 
296
inline fastcall dword GetScreenWidth()
297
{
298
#speed
299
	EAX = 14;
300
	EBX = 4;
301
	$int 0x40
302
	$shr eax, 16
303
	$and eax,0x0000FFFF
304
#codesize
305
}
306
 
307
inline fastcall void DeleteButton(dword EDX)
308
{
309
#speed
310
	EAX = 8;
311
	EDX = EDX + BT_DEL;
312
	$int 0x40;
313
#codesize
314
}
315
 
316
inline fastcall dword LoadLibrary(dword ECX)
317
{
318
#speed
319
	$mov eax, 68
320
	$mov ebx, 19
321
	$int  0x40
322
#codesize
323
}
324
 
325
//function GetProcAdress(hLib:integer; name:string):integer;
326
inline fastcall dword GetProcAdress(dword ECX, EAX)
327
{
328
#speed
329
#codesize
330
}
331
 
332
inline fastcall dword strlen(dword ESI)
333
{
334
#speed
335
	int len=0;
336
	while (AL=ESBYTE[ESI])
337
	{
338
		len++;
339
		ESI++;
340
	}
341
	EAX=len;
342
#codesize
343
}
344
 
345
//-1 - не равны
346
// 0 - равны
347
inline fastcall dword strcmp(dword ESI,EDI)
348
{
349
#speed
350
	dword strcmp_i,ret,len1,len2,sovpadenij,str1,str2;
351
	str1=ESI;
352
	str2=EDI;
353
	ret=-1;
354
	sovpadenij=0;
355
	len1=strlen(str1);
356
	len2=strlen(str2);
357
	if (len1==len2)
358
	{
359
		for (strcmp_i=0;strcmp_i
360
		{
361
			EAX = str1+strcmp_i;
362
			EAX = ESBYTE[EAX];
363
			EBX = str2+strcmp_i;
364
			EBX = ESBYTE[EBX];
365
			if (EAX==EBX) sovpadenij++;
366
		}
367
		if (sovpadenij==len1) ret=0;
368
	}
369
	else ret=-1;
370
	EAX = ret;
371
#codesize
372
}
373
 
374
inline fastcall dword upcase(dword ESI)
375
{
376
#speed
377
	dword str, i;
378
	str = ESI;
379
	for (i=0;i
380
	{
381
		EAX = str+i;
382
		EDX = ESBYTE[EAX];
383
		if (EDX>=97) && (EDX<=122) ESBYTE[str+i] = DL - 32;	//a-z
384
		if (EDX>=160) && (EDX<=175) ESBYTE[str+i] = DL - 32;	//а-п
385
		if (EDX>=224) && (EDX<=239) ESBYTE[str+i] = DL - 80;	//р-я
386
		if (EDX == 241) ESBYTE[EAX] = 240;					//ё
387
	}
388
	EAX = str;
389
	//EAX = ESDWORD[EAX];
390
	//if (EAX != 0x5249443C) $int 3;
391
#codesize
392
}
393
 
394
inline fastcall dword lowcase(dword ESI)
395
{
396
#speed
397
	dword str, i;
398
	str = ESI;
399
	for (i=0;i
400
	{
401
		EAX = str+i;
402
		EDX = ESBYTE[EAX];
403
		if (EDX>=65) && (EDX<=90) ESBYTE[str+i] = DL + 32;	//a-z
404
		if (EDX>=128) && (EDX<=143) ESBYTE[str+i] = DL + 32;	//а-п
405
		if (EDX>=144) && (EDX<=159) ESBYTE[str+i] = DL + 80;	//р-я
406
		if (EDX == 240) ESBYTE[EAX] = 241;					//ё
407
	}
408
	EAX = str;
409
	//EAX = ESDWORD[EAX];
410
	//if (EAX != 0x5249443C) $int 3;
411
#codesize
412
}
413
 
414
inline fastcall void dostowin (dword ESI)
415
{
416
#speed
417
	dword stroka,dlina;
418
	stroka = ESI;
419
	while (BL=ESBYTE[ESI])
420
	{
421
		if (BL>128)
422
			if (BL>=240)
423
				ESBYTE[ESI] = BL - 16;
424
			else
425
				ESBYTE[ESI] = BL - 64;
426
		ESI++;
427
	}
428
#codesize
429
}
430
 
431
void WindowRedrawStatus(dword i)
432
{
433
	EAX = 12;              // function 12:tell os about windowdraw
434
	EBX = i;               // 1, start of draw
435
	$int 0x40
436
}
437
 
438
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,borderColour)
439
{
440
	dword arg1, arg2, arg3, arg4;
441
 
442
	//
443
	arg1 = x << 16 + sizeX;
444
	arg2 = y << 16 + sizeY;
445
	arg3 = mainAreaType << 24 | mainAreaColour;
446
	arg4 = headerType << 24 | headerColour;
447
	//
448
	$mov eax, 0
449
	$mov ebx, arg1
450
	$mov ecx, arg2
451
	$mov edx, arg3
452
	$mov esi, arg4
453
	$mov edi, borderColour
454
	$int 0x40
455
}
456
 
457
void DefineButton(dword x,y,w,h,id,color)
458
{
459
	DrawButton(x<<16+w, skin_width+y<<16+h, id, color);
460
}
461
 
462
void WriteText(dword x,y,byte fontType, dword color, text, len)
463
{
464
	EBX = x<<16+skin_width+y;
465
	ECX = fontType<<24+color;
466
	EDX = text;
467
	ESI = len;
468
	EAX = 4;
469
	$int 0x40;
470
}
471
 
472
inline fastcall void PutPixel(dword EBX,ECX,EDX) //Coded by Leency :D
473
{
474
  EAX=1;
475
  $int 0x40
476
}
477
 
478
void DrawBar(dword x,y,w,h,color)
479
{
480
	kos_DrawBar(x<<16+w,skin_width+y<<16+h,color);
481
}
482
 
483
void DrawRegion(dword x,y,width,height,color1)
484
{
485
	DrawBar(x,y,width,1,color1); //полоса гор сверху
486
	DrawBar(x,y+height,width,1,color1); //полоса гор снизу
487
	DrawBar(x,y,1,height,color1); //полоса верт слева
488
	DrawBar(x+width,y,1,height+1,color1); //полоса верт справа
489
}
490
 
491
void DrawFlatButton(dword x,y,width,height,id,color)
492
{
493
	DrawRegion(x,y,width,height,0x94AECE);
494
	DrawBar(x+1,y+1,width-1,1,0xFFFFFF); //полоса гор белая
495
	DrawBar(x+1,y+height-1,width-2,1,0xC7C7C7); //тень верт
496
	DrawBar(x+1,y+1,1,height-1,0xFFFFFF); //полоса верт белая
497
	DrawBar(x+width-1,y+2,1,height-2,0xC7C7C7); //тень верт
498
	DrawBar(x+2,y+2,width-3,height-3,color); //заливка
499
	if (id<>0)
500
	{
501
	DefineButton(x,y,width,height,id+BT_DEL,0xEFEBEF); //удаляем кнопку
502
	DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //определяем кнопку
503
	}
504
}
505
 
506
void PutImage(dword buf,w,h,x,y)
507
{
508
	int i,r,g,b;
509
	EDI=buf;
510
	EAX = 7;
511
	EBX = buf;
512
	ECX = w<<16+h;
513
	EDX = x<<16+y+skin_width;
514
	$int 0x40
515
}
516
 
517
void copystr(dword s,d)
518
{
519
	ECX=strlen(d);//очищаем старое
520
	$mov edi,d
521
	$xor al,al
522
	$cld
523
	$rep $stosb
524
 
525
	ECX=strlen(s);//копируем
526
	$mov esi,s
527
	$mov edi,d
528
	$cld
529
	$rep $movsb
530
}
531
int		pos,razr,backup,j=0;
532
char	buffer[11]="";
533
int		chislo;
534
inline fastcall dword IntToStr(dword ESI)
535
{
536
#speed
537
	chislo=ESI;
538
	ECX=12;
539
	$push edi
540
	$mov edi,#buffer
541
	$xor al,al
542
	$cld
543
	$rep $stosb
544
	pos=razr=backup=j=0;
545
	if (chislo<0)
546
	{
547
		buffer[pos]='-';
548
		chislo=-1*chislo;
549
		pos++;
550
	}
551
	backup=chislo;
552
	do
553
	{
554
		backup=backup/10;
555
		razr++;
556
	}
557
	while (backup!=0);
558
	razr--;
559
	for (j=razr+pos;j>pos-1;j--)
560
	{
561
		backup=chislo/10;
562
		backup=backup*10;
563
		buffer[j]=chislo-backup+48;
564
		chislo=chislo/10;
565
	}
566
	//return #buffer;
567
	$pop edi;
568
	EAX = #buffer;
569
#codesize
570
}
571
 
572
inline fastcall dword MoveSize(dword EBX,ECX,EDX,ESI)
573
{
574
#speed
575
	EAX = 67;
576
	$int 0x40
577
#codesize
578
}
579
 
580
f70	CopyFile_f;
581
BDVK CopyFile_atr;
582
inline fastcall dword CopyFile(dword EBX,ECX)
583
{
584
#speed
585
	dword s, d, buf;
586
	s = EBX;
587
	d = ECX;
588
 
589
	CopyFile_f.func = 5;
590
	CopyFile_f.param1 = 0;
591
	CopyFile_f.param2 = 0;
592
	CopyFile_f.param3 = 0;
593
	CopyFile_f.param4 = #CopyFile_atr;
594
	CopyFile_f.rezerv = 0;
595
	CopyFile_f.name = s;
596
	$mov	eax, 70
597
	$mov	ebx, #CopyFile_f
598
	$int	0x40
599
 
600
	if (EAX == 0)
601
	{
602
		buf = malloc(CopyFile_atr.sizelo);
603
		CopyFile_f.func = 0;
604
		CopyFile_f.param1 = 0;
605
		CopyFile_f.param2 = 0;
606
		CopyFile_f.param3 = CopyFile_atr.sizelo;
607
		CopyFile_f.param4 = buf;
608
		CopyFile_f.rezerv = 0;
609
		CopyFile_f.name = s;
610
		$mov	eax, 70
611
		$mov	ebx, #CopyFile_f
612
		$int	0x40
613
 
614
		if (EAX == 0)
615
		{
616
			CopyFile_f.func = 2;
617
			CopyFile_f.param1 = 0;
618
			CopyFile_f.param2 = 0;
619
			CopyFile_f.param3 = CopyFile_atr.sizelo;
620
			CopyFile_f.param4 = buf;
621
			CopyFile_f.rezerv = 0;
622
			CopyFile_f.name = d;
623
			$mov	eax, 70
624
			$mov	ebx, #CopyFile_f
625
			$int	0x40
626
		}
627
	}
628
#codesize
629
}