Subversion Repositories Kolibri OS

Rev

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