Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
2568 leency 1
//CODED by Veliant, Leency 2008-2012. GNU GPL licence.
2
 
3
#startaddress 0
4
#code32 TRUE
5
 
6
byte   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    = 0x00070000;
11
dword  x86esp_reg   = 0x00070000;   // 0x0007fff0;
12
dword  I_Param      = #param;
13
dword  I_Path       = #program_path;
14
 
15
char param[4096];
16
char program_path[4096];
17
 
18
 
19
//Events
20
#define evMouse		6
21
#define evButton	3
22
#define evKey		2
23
#define evReDraw	1
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
struct mouse{
37
	unsigned int x,y,lkm,pkm,hor,vert;
38
	void get();
39
};
40
 
41
inline fastcall int TestBit(EAX, CL)
42
{
43
	$shr eax,cl
44
	$and eax,1
45
}
46
 
47
void mouse::get()
48
{
49
	EAX = 37;
50
	EBX = 1;
51
	$int	0x40
52
	$mov	ebx, eax
53
	$shr	eax, 16
54
	$and	ebx,0x0000FFFF
55
	x = EAX;
56
	y = EBX;
57
 
58
	EAX = 37;
59
	EBX = 2;
60
	$int	0x40
61
	$mov	ebx, eax
62
	$and	eax, 0x00000001
63
	$shr	ebx, 1
64
	$and	ebx, 0x00000001
65
	lkm = EAX;
66
	pkm = EBX;
67
 
68
	EAX = 37; //scroll
69
	EBX = 7;
70
	$int	0x40
71
	$mov	ebx, eax
72
	$shr	eax, 16
73
	$and	ebx,0x0000FFFF
74
	//hor = EAX;
75
	vert = EBX;
76
}
77
 
78
//---------------------------------------------------------------------------
79
struct proc_info{
80
	dword	use_cpu;
81
	word	pos_in_stack,num_slot,rezerv1;
82
	char	name[11];
83
	char	rezerv2;
84
	dword	adress,use_memory,ID,left,top,width,height;
85
	word	status_slot,rezerv3;
86
	dword	work_left,work_top,work_width,work_height;
87
	char	status_window;
88
	void	GetInfo(dword ECX);
89
	byte    reserved[1024-71];
90
#define SelfInfo -1
91
};
92
 
93
void proc_info::GetInfo(dword EBX, ECX)
94
{
95
	EAX = 9;
96
	$int  0x40
97
}
98
 
99
inline fastcall int GetSlot(dword ECX)
100
{
101
	EAX = 18;
102
	EBX = 21;
103
	$int 0x40
104
}
105
 
106
inline fastcall int ActiveProcess()
107
{
108
	EAX = 18;
109
	EBX = 7;
110
	$int 0x40
111
}
112
 
113
//-------------------------------------------------------------------------------
114
 
115
inline fastcall dword WaitEvent(){
116
	EAX = 10;              // wait here for event
117
	$int 0x40
118
}
119
 
120
inline fastcall void SetEventMask(dword EBX)
121
{
122
	EAX = 40;
123
	$int 0x40
124
}
125
 
126
inline fastcall word GetKey(){ //Gluk fix
127
		$push edx
128
@getkey:
129
		$mov  eax,2
130
		$int  0x40
131
		$cmp eax,1
132
		$jne getkeyi
133
		$mov ah,dh
134
		$jmp getkeyii //jz?
135
@getkeyi:
136
		$mov dh,ah
137
		$jmp getkey
138
@getkeyii:
139
		$pop edx
140
		EAX = EAX >> 8;
141
}
142
 
143
inline fastcall word GetButtonID(){
144
	EAX = 17;            // Get ID
145
	$int  0x40
146
	EAX = EAX >> 8;
147
}
148
 
149
inline fastcall void ExitProcess(){
150
	EAX = -1;            // close this program
151
	$int 0x40
152
}
153
 
154
inline fastcall void Pause(dword EBX){
155
	$mov eax, 5       //Пауза, в сотых долях секунды
156
	$int 0x40
157
}
158
 
159
//------------------------------------------------------------------------------
160
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,
161
dword mainAreaColour,byte headerType,dword headerColour,EDI)
162
{
163
	EAX = 12;              // function 12:tell os about windowdraw
164
	EBX = 1;
165
	$int 0x40
166
 
167
	EBX = x << 16 + sizeX;
168
	ECX = y << 16 + sizeY;
169
	EDX = mainAreaType << 24 | mainAreaColour;
170
	ESI = headerType << 24 | headerColour;
171
	$xor eax,eax
172
	$int 0x40
173
 
174
	EAX = 12;              // function 12:tell os about windowdraw
175
	EBX = 2;
176
	$int 0x40
177
}
178
 
179
inline fastcall void CreateThread(dword ECX,EDX)
180
{
181
	EAX = 51;
182
	EBX = 1;
183
	$int 0x40
184
}
185
 
186
inline fastcall void DrawTitle(dword ECX){
187
	EAX = 71;
188
	EBX = 1;
189
	$int 0x40;
190
}
191
 
192
inline fastcall dword GetSkinWidth(){
193
	EAX = 48;
194
	EBX = 4;
195
	$int 0x40
196
}
197
 
198
inline fastcall void MoveSize(dword EBX,ECX,EDX,ESI){
199
	EAX = 67;
200
	$int 0x40
201
}
202
 
203
//------------------------------------------------------------------------------
204
 
205
inline fastcall dword strlen(EDI){
206
	asm {
207
	  xor ecx, ecx
208
	  xor eax, eax
209
	  dec ecx
210
	  repne scasb
211
	  sub eax, 2
212
	  sub eax, ecx
213
	}
214
}
215
 
216
 
217
inline fastcall copystr(dword ESI,EDI)
218
{
219
	$cld
220
l1:
221
	$lodsb
222
	$stosb
223
	$test al,al
224
	$jnz l1
225
}
226
 
227
char buffer[11];
228
inline fastcall dword IntToStr(dword ESI)
229
{
230
     $mov     edi, #buffer
231
     $mov     ecx, 10
232
     $test     esi, esi
233
     $jns     f1
234
     $mov     al, '-'
235
     $stosb
236
     $neg     esi
237
f1:
238
     $mov     eax, esi
239
     $push     -'0'
240
f2:
241
     $xor     edx, edx
242
     $div     ecx
243
     $push     edx
244
     $test     eax, eax
245
     $jnz     f2
246
f3:
247
     $pop     eax
248
     $add     al, '0'
249
     $stosb
250
     $jnz     f3
251
     $mov     eax, #buffer
252
     $ret
253
}
254
 
255
inline fastcall dword StrToInt()
256
{
257
	ESI=EDI=EAX;
258
	IF(DSBYTE[ESI]=='-')ESI++;
259
	EAX=0;
260
	BH=AL;
261
	do{
262
		BL=DSBYTE[ESI]-'0';
263
		EAX=EAX*10+EBX;
264
		ESI++;
265
	}while(DSBYTE[ESI]>0);
266
	IF(DSBYTE[EDI]=='-') -EAX;
267
}
268
 
269
dword StrToCol(char* htmlcolor)
270
{
271
  dword j, color=0;
272
  char ch=0x00;
273
 
274
  FOR (j=0; j<6; j++)
275
  {
276
    ch=ESBYTE[htmlcolor+j];
277
    IF ((ch>='0') && (ch<='9')) ch -= '0';
278
    IF ((ch>='A') && (ch<='F')) ch -= 'A'-10;
279
    IF ((ch>='a') && (ch<='f')) ch -= 'a'-10;
280
    color = color*0x10 + ch;
281
  }
282
 
283
  return color;
284
}
285
 
286
inline fastcall int strcmp(ESI, EDI)
287
{
288
	loop()
289
	{
290
		IF (DSBYTE[ESI]
291
		IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1;
292
		IF (DSBYTE[ESI]=='\0') RETURN 0;
293
		ESI++;
294
		EDI++;
295
	}
296
}
297
 
298
 
299
inline fastcall unsigned int find_symbol(ESI,BL)
300
{
301
	int jj=0, last=-1;
302
	do{
303
		jj++;
304
		$lodsb
305
		IF(AL==BL) last=jj;
306
	} while(AL!=0);
307
	return last;
308
}
309
 
310
 
311
inline fastcall ChangeCase(dword EDX)
312
{
313
	AL=DSBYTE[EDX];
314
	IF(AL>='a')&&(AL<='z')DSBYTE[EDX]=AL&0x5f;
315
	IF (AL>=160) && (AL<=175) DSBYTE[EDX] = AL - 32;	//р-я
316
	IF (AL>=224) && (AL<=239) DSBYTE[EDX] = AL - 80;	//р-я
317
	do{
318
		EDX++;
319
		AL=DSBYTE[EDX];
320
		IF(AL>='A')&&(AL<='Z'){DSBYTE[EDX]=AL|0x20; CONTINUE;}
321
		IF(AL>='А')&&(AL<='П')DSBYTE[EDX]=AL|0x20; //а-п
322
		IF (AL>=144) && (AL<=159) DSBYTE[EDX] = AL + 80;	//р-я
323
	}while(AL!=0);
324
}
325
 
326
 
327
//------------------------------------------------------------------------------
328
inline fastcall void PutPixel(dword EBX,ECX,EDX){
329
  EAX=1;
330
  $int 0x40
331
}
332
 
333
void DefineButton(dword x,y,w,h,EDX,ESI)
334
{
335
 	EAX = 8;
336
	$push edx
337
	EDX += BT_DEL; //тэрўрых єфры хь ъэюяє ё ¤Єш шф, яюЄюь ёючфр╕ь
338
	$int 0x40;
339
	EBX = x<<16+w;
340
	ECX = y<<16+h;
341
 	$pop edx
342
	$int 0x40
343
}
344
 
345
inline fastcall void DeleteButton(dword EDX)
346
{
347
	EAX = 8;
348
	EDX += BT_DEL;
349
	$int 0x40;
350
}
351
 
352
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
353
{
354
	EAX = 4;
355
	EBX = x<<16+y;
356
	ECX = fontType<<24+color;
357
	$int 0x40;
358
}
359
 
360
void DrawBar(dword x,y,w,h,EDX)
361
{
362
	#speed
363
	EAX = 13;
364
	EBX = x<<16+w;
365
	ECX = y<<16+h;
366
 	$int 0x40
367
	#codesize
368
}
369
 
370
void DrawRegion_3D(dword x,y,width,height,color1,color2)
371
{
372
	DrawBar(x,y,width+1,1,color1); //полоса гор сверху
373
	DrawBar(x,y+1,1,height-1,color1); //полоса слева
374
	DrawBar(x+width,y+1,1,height,color2); //полоса справа
375
	DrawBar(x,y+height,width,1,color2); //полоса гор снизу
376
}
377
 
378
void DrawFlatButton(dword x,y,width,height,id,color,text)
379
{
380
	DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
381
	DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
382
	DrawBar(x+2,y+2,width-3,height-3,color); //заливка
383
	IF (id<>0)	DefineButton(x+1,y+1,width-2,height-2,id+BT_HIDE,0xEFEBEF); //кнопка
384
	WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
385
}
386
 
387
void PutPaletteImage(dword EBX,w,h,x,y, EDI)
388
{
389
	EAX = 65;
390
	ECX = w<<16+h;
391
	EDX = x<<16+y;
392
	ESI = 8;
393
	EBP = 0;
394
	$int 0x40
395
}
396
 
397
void PutImage(dword EBX,w,h,x,y)
398
{
399
	EAX = 7;
400
	ECX = w<<16+h;
401
	EDX = x<<16+y;
402
	$int 0x40
403
}
404
 
405
//------------------------------------------------------------------------------
406
inline fastcall void WriteDebug(dword EDX)
407
{
408
	$mov eax, 63
409
	$mov ebx, 1
410
next_char:
411
	$mov ecx, DSDWORD[edx]
412
	$or	 cl, cl
413
	$jz  done
414
	$int 0x40
415
	$inc edx
416
	$jmp next_char
417
done:
418
	$mov cl, 13
419
	$int 0x40
420
	$mov cl, 10
421
	$int 0x40
422
}
423
 
424
inline fastcall void WriteFullDebug(dword ESI)
425
{
426
	WriteDebug("");
427
	WriteDebug(ESI);
428
 
429
	WriteDebug("Number of files:");
430
	WriteDebug(IntToStr(count));
431
 
432
	WriteDebug("but_num:");
433
	WriteDebug(IntToStr(but_num));
434
 
435
	WriteDebug("curbtn");
436
	WriteDebug(IntToStr(curbtn));
437
 
438
	WriteDebug("ra_kadrom:");
439
	WriteDebug(IntToStr(za_kadrom));
440
 
441
	Pause(200);
442
}