Subversion Repositories Kolibri OS

Rev

Rev 903 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
903 leency 1
//CODED by Veliant, Leency. 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;   // 0x0007fff0;
12
dword  I_Param      = #param;
13
dword  I_Icon       = 0x0;
935 leency 14
dword  skin_width;
903 leency 15
char param[256]="";
16
 
17
//Events
935 leency 18
#define evMouse		6
903 leency 19
#define evButton	3
20
#define evKey		2
21
#define evReDraw	1
22
#define evNet		8
23
 
24
//Button options
25
#define BT_DEL		0x80000000
26
#define BT_HIDE		0x40000000
27
#define BT_NOFRAME	0x20000000
28
 
29
#define OLD			-1
30
#define true		1
31
#define false		0
32
 
33
 
34
 
35
int vert;
36
struct mouse{
37
 dword x,y,lkm,pkm;
38
 void get();
39
};
40
 
41
void mouse::get()
42
{
43
	EAX = 37;
44
	EBX = 1;
45
	$int	0x40
46
	$mov	ebx, eax
47
	$shr	eax, 16
48
	$and	ebx,0x0000FFFF
49
	x = EAX;
50
	y = EBX;
51
	EAX = 37;
52
	EBX = 2;
53
	$int	0x40
54
	$mov	ebx, eax
55
	$and	eax, 0x00000001
56
	$shr	ebx, 1
57
	$and	ebx, 0x00000001
58
	lkm = EAX;
59
	pkm = EBX;
60
	EAX = 37; //скролл
61
	EBX = 7;
62
	$int	0x40
63
	$mov	ebx, eax
64
	$shr	eax, 16
65
	$and	ebx,0x0000FFFF
66
	//hor = EAX;
67
	vert = EBX;
68
}
69
 
70
 
71
//---------------------------------------------------------------------------
72
struct f70{
73
	dword	func;
74
	dword	param1;
75
	dword	param2;
76
	dword	param3;
77
	dword	param4;
78
	char	rezerv;
79
	dword	name;
80
};
81
//---------------------------------------------------------------------------
82
struct BDVK{
83
	dword	attr;
84
	byte	type_name;
85
	byte	rez1, rez2, rez3;
86
	dword	timecreate;
87
	dword	datecreate;
88
	dword	timelastaccess;
89
	dword	datelastaccess;
90
	dword	timelastedit;
91
	dword	datelastedit;
92
	dword	sizelo;
93
	dword	sizehi;
94
	char	name[518];
95
};
96
//---------------------------------------------------------------------------
97
struct proc_info{
98
	dword	use_cpu;
99
	word	pos_in_stack,num_slot,rezerv1;
100
	char	name[11];
101
	char	rezerv2;
102
	dword	adress,use_memory,ID,left,top,width,height;
103
	word	status_slot,rezerv3;
104
	dword	work_left,work_top,work_width,work_height;
105
	char	status_window;
106
	void	getme();
107
};
108
 
109
void proc_info::getme()
110
{
111
	EAX = 9;
112
	EBX = #use_cpu;
113
	ECX = -1;
114
	$int	0x40
115
}
116
//-------------------------------------------------------------------------------
117
 
118
inline fastcall dword WaitEvent(){
119
 EAX = 10;              // wait here for event
120
 $int 0x40
121
}
122
 
935 leency 123
/*inline fastcall void SetEventMask(dword EBX){
124
	$mov eax,40
125
	//$mov ebx,100111b
126
	$int 0x40
127
}*/
903 leency 128
 
129
inline fastcall word GetKey(){
130
 EAX = 2;              // just read this key from buffer
131
 $int  0x40
132
 EAX = EAX >> 8;
133
}
134
 
135
inline fastcall word GetButtonID(){
136
 EAX = 17;            // Get ID
137
 $int  0x40
138
 EAX = EAX >> 8;
139
}
140
 
935 leency 141
inline fastcall void ExitProcess(){
142
 EAX = -1;            // close this program
143
 $int 0x40
144
}
903 leency 145
 
935 leency 146
/*void Pause(dword EBX)
147
{					//Пауза, в сотых долях секунды EBX = value
148
	$mov eax, 5
149
	$int 0x40
150
}*/
151
 
152
//------------------------------------------------------------------------------
153
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword
154
	mainAreaColor,byte headerType,dword headerColor,EDI)
903 leency 155
{
935 leency 156
	EBX = x << 16 + sizeX;
157
	ECX = y << 16 + sizeY;
158
	EDX = mainAreaType << 24 | mainAreaColor;
159
	ESI = headerType << 24 | headerColor;
160
	$xor eax,eax
161
	$int 0x40
162
}
163
 
164
inline fastcall void DrawTitle(dword ECX){
903 leency 165
	EAX = 71;
166
	EBX = 1;
167
	$int 0x40;
168
}
169
 
935 leency 170
 
171
inline fastcall void WindowRedrawStatus(dword EBX){
172
	EAX = 12;              //tell os about windowdraw
173
	$int 0x40
174
}
175
 
176
inline fastcall dword GetSkinWidth(){
903 leency 177
	EAX = 48;
178
	EBX = 4;
179
	$int 0x40
180
}
181
 
935 leency 182
inline fastcall dword MoveSize(dword EBX,ECX,EDX,ESI){
183
	EAX = 67;
184
	$int 0x40
903 leency 185
}
186
 
935 leency 187
//------------------------------------------------------------------------------
903 leency 188
 
935 leency 189
inline fastcall dword strlen(dword EDI){
903 leency 190
	ECX=EAX=0;
191
	ECX--;
192
	$REPNE $SCASB
935 leency 193
	EAX-=2+ECX;
903 leency 194
}
195
 
196
 
935 leency 197
inline fastcall copystr(dword ESI,EDI)
198
{
199
	$cld
200
l1:
201
	$lodsb
202
	$stosb
203
	$test al,al
204
	$jnz l1
205
}
206
 
207
 
208
char buffer[11]="";
209
inline fastcall dword IntToStr(dword ESI)
210
{
211
     $mov     edi, #buffer
212
     $mov     ecx, 10
213
     $test     esi, esi
214
     $jns     f1
215
     $mov     al, '-'
216
     $stosb
217
     $neg     esi
218
f1:
219
     $mov     eax, esi
220
     $push     -'0'
221
f2:
222
     $xor     edx, edx
223
     $div     ecx
224
     $push     edx
225
     $test     eax, eax
226
     $jnz     f2
227
f3:
228
     $pop     eax
229
     $add     al, '0'
230
     $stosb
231
     $jnz     f3
232
     $mov     eax, #buffer
233
     $ret
234
}
235
 
236
 
903 leency 237
inline fastcall int strcmp(dword EAX,EBX)
238
{
935 leency 239
	#speed
903 leency 240
	ESI=EAX;
241
	EBX--;
242
TOP:
243
	EBX++;
244
	$LODSB
245
	$CMP AL,0
246
	$JE HERE
247
	$CMP DSBYTE[EBX],AL
248
	$JE TOP
249
HERE:
250
	AL-=DSBYTE[EBX];
251
	return AL;
935 leency 252
	#codesize
903 leency 253
}
254
 
255
 
256
inline fastcall dword ChangeCase(dword EDX)
257
{
935 leency 258
	#speed
903 leency 259
	AL=DSBYTE[EDX];
260
	IF(AL>='a')&&(AL<='z')DSBYTE[EDX]=AL&0x5f;
261
	EDX++;
262
	do{
263
		AL=DSBYTE[EDX];
264
		IF(AL>='A')&&(AL<='Z')DSBYTE[EDX]=AL|0x20;
265
		EDX++;
266
	}while(AL!=0);
935 leency 267
	#codesize
903 leency 268
}
269
 
935 leency 270
//------------------------------------------------------------------------------
271
inline fastcall void PutPixel(dword EBX,ECX,EDX){
272
  EAX=1;
273
  ECX+=skin_width;
274
  $int 0x40
903 leency 275
}
276
 
935 leency 277
void DefineButton(dword x,y,w,h,EDX,ESI){
278
	EAX = 8;
279
	EBX = x<<16+w;
280
	ECX = skin_width+y<<16+h;
903 leency 281
	$int 0x40
282
}
283
 
935 leency 284
inline fastcall void DeleteButton(dword EDX)
903 leency 285
{
286
	EAX = 8;
935 leency 287
	EDX += BT_DEL;
288
	$int 0x40;
903 leency 289
}
290
 
291
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
292
{
293
	EAX = 4;
294
	EBX = x<<16+skin_width+y;
295
	ECX = fontType<<24+color;
296
	$int 0x40;
297
}
298
 
299
void DrawBar(dword x,y,w,h,EDX)
300
{
935 leency 301
	#speed
903 leency 302
	EAX = 13;
303
	EBX = x<<16+w;
304
	ECX = skin_width+y<<16+h;
305
 	$int 0x40
935 leency 306
	#codesize
903 leency 307
}
308
 
309
void DrawRegion(dword x,y,width,height,color1)
310
{
311
	DrawBar(x,y,width,1,color1); //полоса гор сверху
312
	DrawBar(x,y+height,width,1,color1); //полоса гор снизу
313
	DrawBar(x,y,1,height,color1); //полоса верху слева
314
	DrawBar(x+width,y,1,height+1,color1); //полоса верху справа
315
}
316
 
317
void DrawFlatButton(dword x,y,width,height,id,color,text)
318
{
319
	DrawRegion(x,y,width,height,0x94AECE);
320
	DrawBar(x+1,y+1,width-1,1,0xFFFFFF); //полоса гор белая
321
	DrawBar(x+1,y+height-1,width-2,1,0xC7C7C7); //венм верв
322
	DrawBar(x+1,y+1,1,height-1,0xFFFFFF); //полоса верв белап
323
	DrawBar(x+width-1,y+2,1,height-2,0xC7C7C7); //венм верв
324
	DrawBar(x+2,y+2,width-3,height-3,color); //заливка
935 leency 325
	IF (id<>0)	DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //кнопка
903 leency 326
	WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
327
}
328
 
329
void PutImage(dword EBX,w,h,x,y)
330
{
331
	EAX = 7;
332
	ECX = w<<16+h;
333
	EDX = x<<16+y+skin_width;
334
	$int 0x40
335
}
336
 
935 leency 337
void PutPaletteImage(dword EBX,w,h,x,y, EDI)
903 leency 338
{
935 leency 339
	EAX = 65;
340
	ECX = w<<16+h;
341
	EDX = x<<16+y+skin_width;
342
	ESI = 8;
343
	EBP = 0;
903 leency 344
	$int 0x40
935 leency 345
}
903 leency 346
 
935 leency 347
//------------------------------------------------------------------------------
903 leency 348
 
349
f70	CopyFile_f;
350
BDVK CopyFile_atr;
351
inline fastcall dword CopyFile(dword EBX,ECX)
352
{
353
	dword s=EBX, d=ECX, cBufer=0;
354
	CopyFile_f.func = 5;
355
	CopyFile_f.param1 = 0;
356
	CopyFile_f.param2 = 0;
357
	CopyFile_f.param3 = 0;
358
	CopyFile_f.param4 = #CopyFile_atr;
359
	CopyFile_f.rezerv = 0;
360
	CopyFile_f.name = s;
361
	$mov	eax, 70
362
	$mov	ebx, #CopyFile_f
363
	$int	0x40
364
 
935 leency 365
	if (!EAX)
903 leency 366
	{
367
		cBufer = malloc(CopyFile_atr.sizelo);
368
		CopyFile_f.func = 0;
369
		CopyFile_f.param1 = 0;
370
		CopyFile_f.param2 = 0;
371
		CopyFile_f.param3 = CopyFile_atr.sizelo;
372
		CopyFile_f.param4 = cBufer;
373
		CopyFile_f.rezerv = 0;
374
		CopyFile_f.name = s;
375
		$mov	eax, 70
376
		$mov	ebx, #CopyFile_f
377
		$int	0x40
378
 
935 leency 379
		IF (!EAX)
903 leency 380
		{
381
			CopyFile_f.func = 2;
382
			CopyFile_f.param1 = 0;
383
			CopyFile_f.param2 = 0;
384
			CopyFile_f.param3 = CopyFile_atr.sizelo;
385
			CopyFile_f.param4 = cBufer;
386
			CopyFile_f.rezerv = 0;
387
			CopyFile_f.name = d;
388
			$mov	eax, 70
389
			$mov	ebx, #CopyFile_f
390
			$int	0x40
391
		}
392
	}
393
 
394
}