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
void DefineButton(dword x,y,w,h,id,color)
457
{
458
	DrawButton(x<<16+w, skin_width+y<<16+h, id, color);
459
}
460
void WriteText(dword x,y,byte fontType, dword color, text, len)
461
{
462
	EBX = x<<16+skin_width+y;
463
	ECX = fontType<<24+color;
464
	EDX = text;
465
	ESI = len;
466
	EAX = 4;
467
	$int 0x40;
468
}
469
void DrawBar(dword x,y,w,h,color)
470
{
471
	kos_DrawBar(x<<16+w,skin_width+y<<16+h,color);
472
}
473
 
474
void DrawRegion(dword x,y,width,height,color1)
475
{
476
	DrawBar(x,y,width,1,color1); //полоса гор сверху
477
	DrawBar(x,y+height,width,1,color1); //полоса гор снизу
478
	DrawBar(x,y,1,height,color1); //полоса верт слева
479
	DrawBar(x+width,y,1,height+1,color1); //полоса верт справа
480
}
481
 
482
void DrawFlatButton(dword x,y,width,height,id,color)
483
{
484
	DrawRegion(x,y,width,height,0x94AECE);
485
	DrawBar(x+1,y+1,width-1,1,0xFFFFFF); //полоса гор белая
486
	DrawBar(x+1,y+height-1,width-2,1,0xC7C7C7); //тень верт
487
	DrawBar(x+1,y+1,1,height-1,0xFFFFFF); //полоса верт белая
488
	DrawBar(x+width-1,y+2,1,height-2,0xC7C7C7); //тень верт
489
	DrawBar(x+2,y+2,width-3,height-3,color); //заливка
490
	if (id<>0)
491
	{
492
	DefineButton(x,y,width,height,id+BT_DEL,0xEFEBEF); //удаляем кнопку
493
	DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //определяем кнопку
494
	}
495
}
496
 
497
void PutImage(dword buf,w,h,x,y)
498
{
499
	int i,r,g,b;
500
	EDI=buf;
501
	EAX = 7;
502
	EBX = buf;
503
	ECX = w<<16+h;
504
	EDX = x<<16+y+skin_width;
505
	$int 0x40
506
}
507
 
508
void copystr(dword s,d)
509
{
510
	ECX=strlen(d);//очищаем старое
511
	$mov edi,d
512
	$xor al,al
513
	$cld
514
	$rep $stosb
515
 
516
	ECX=strlen(s);//копируем
517
	$mov esi,s
518
	$mov edi,d
519
	$cld
520
	$rep $movsb
521
}
522
int		pos,razr,backup,j=0;
523
char	buffer[11]="";
524
int		chislo;
525
inline fastcall dword IntToStr(dword ESI)
526
{
527
#speed
528
	chislo=ESI;
529
	ECX=12;
530
	$push edi
531
	$mov edi,#buffer
532
	$xor al,al
533
	$cld
534
	$rep $stosb
535
	pos=razr=backup=j=0;
536
	if (chislo<0)
537
	{
538
		buffer[pos]='-';
539
		chislo=-1*chislo;
540
		pos++;
541
	}
542
	backup=chislo;
543
	do
544
	{
545
		backup=backup/10;
546
		razr++;
547
	}
548
	while (backup!=0);
549
	razr--;
550
	for (j=razr+pos;j>pos-1;j--)
551
	{
552
		backup=chislo/10;
553
		backup=backup*10;
554
		buffer[j]=chislo-backup+48;
555
		chislo=chislo/10;
556
	}
557
	//return #buffer;
558
	$pop edi;
559
	EAX = #buffer;
560
#codesize
561
}
562
 
563
inline fastcall dword MoveSize(dword EBX,ECX,EDX,ESI)
564
{
565
#speed
566
	EAX = 67;
567
	$int 0x40
568
#codesize
569
}
570
 
571
f70	CopyFile_f;
572
BDVK CopyFile_atr;
573
inline fastcall dword CopyFile(dword EBX,ECX)
574
{
575
#speed
576
	dword s, d, buf;
577
	s = EBX;
578
	d = ECX;
579
 
580
	CopyFile_f.func = 5;
581
	CopyFile_f.param1 = 0;
582
	CopyFile_f.param2 = 0;
583
	CopyFile_f.param3 = 0;
584
	CopyFile_f.param4 = #CopyFile_atr;
585
	CopyFile_f.rezerv = 0;
586
	CopyFile_f.name = s;
587
	$mov	eax, 70
588
	$mov	ebx, #CopyFile_f
589
	$int	0x40
590
 
591
	if (EAX == 0)
592
	{
593
		buf = malloc(CopyFile_atr.sizelo);
594
		CopyFile_f.func = 0;
595
		CopyFile_f.param1 = 0;
596
		CopyFile_f.param2 = 0;
597
		CopyFile_f.param3 = CopyFile_atr.sizelo;
598
		CopyFile_f.param4 = buf;
599
		CopyFile_f.rezerv = 0;
600
		CopyFile_f.name = s;
601
		$mov	eax, 70
602
		$mov	ebx, #CopyFile_f
603
		$int	0x40
604
 
605
		if (EAX == 0)
606
		{
607
			CopyFile_f.func = 2;
608
			CopyFile_f.param1 = 0;
609
			CopyFile_f.param2 = 0;
610
			CopyFile_f.param3 = CopyFile_atr.sizelo;
611
			CopyFile_f.param4 = buf;
612
			CopyFile_f.rezerv = 0;
613
			CopyFile_f.name = d;
614
			$mov	eax, 70
615
			$mov	ebx, #CopyFile_f
616
			$int	0x40
617
		}
618
	}
619
#codesize
620
}