Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1722 Rock_mania 1
//CODED by Veliant, Leency. 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    = 0x00100000;
11
dword  x86esp_reg   = 0x00100000;   // 0x0007fff0;
12
dword  I_Param      = #param;
2054 leency 13
dword  I_Path       = #program_path;
2266 leency 14
 
2054 leency 15
char param[4096]="";
16
char program_path[4096]="";
1722 Rock_mania 17
 
2054 leency 18
 
1722 Rock_mania 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{
2134 leency 37
	unsigned int x,y,lkm,pkm,hor,vert;
38
	void get();
1722 Rock_mania 39
};
40
 
2266 leency 41
inline fastcall int TestBit(EAX, CL)
2134 leency 42
{
43
	$shr eax,cl
44
	$and eax,1
45
}
46
 
1722 Rock_mania 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;
2134 leency 57
 
1722 Rock_mania 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;
2134 leency 67
 
68
	EAX = 37; //scroll
1722 Rock_mania 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
 
2134 leency 93
void proc_info::GetInfo(dword EBX, ECX)
1722 Rock_mania 94
{
95
	EAX = 9;
96
	$int  0x40
97
}
2134 leency 98
 
2266 leency 99
inline fastcall int GetSlot(dword ECX)
2134 leency 100
{
101
	EAX = 18;
102
	EBX = 21;
103
	$int 0x40
104
}
105
 
2266 leency 106
inline fastcall int ActiveProcess()
2134 leency 107
{
108
	EAX = 18;
109
	EBX = 7;
110
	$int 0x40
111
}
112
 
1722 Rock_mania 113
//-------------------------------------------------------------------------------
114
 
115
inline fastcall dword WaitEvent(){
2134 leency 116
	EAX = 10;              // wait here for event
117
	$int 0x40
1722 Rock_mania 118
}
119
 
120
inline fastcall void SetEventMask(dword EBX)
121
{
2134 leency 122
	EAX = 40;
123
	$int 0x40
1722 Rock_mania 124
}
125
 
2134 leency 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;
1722 Rock_mania 141
}
142
 
143
inline fastcall word GetButtonID(){
2134 leency 144
	EAX = 17;            // Get ID
145
	$int  0x40
146
	EAX = EAX >> 8;
1722 Rock_mania 147
}
148
 
149
inline fastcall void ExitProcess(){
2134 leency 150
	EAX = -1;            // close this program
151
	$int 0x40
1722 Rock_mania 152
}
153
 
154
inline fastcall void Pause(dword EBX){
155
	$mov eax, 5       //Пауза, в сотых долях секунды
156
	$int 0x40
157
}
158
 
159
//------------------------------------------------------------------------------
2266 leency 160
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,
161
dword mainAreaColour,byte headerType,dword headerColour,EDI)
1722 Rock_mania 162
{
2266 leency 163
	EAX = 12;              // function 12:tell os about windowdraw
2242 leency 164
	EBX = 1;
165
	$int 0x40
2241 leency 166
 
1722 Rock_mania 167
	EBX = x << 16 + sizeX;
168
	ECX = y << 16 + sizeY;
2266 leency 169
	EDX = mainAreaType << 24 | mainAreaColour;
170
	ESI = headerType << 24 | headerColour;
1722 Rock_mania 171
	$xor eax,eax
172
	$int 0x40
2266 leency 173
 
174
	EAX = 12;              // function 12:tell os about windowdraw
2242 leency 175
	EBX = 2;
176
	$int 0x40
1722 Rock_mania 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 int strcmp(ESI, EDI)
256
{
257
	loop()
258
	{
259
		IF (DSBYTE[ESI]
260
		IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1;
261
		IF (DSBYTE[ESI]=='\0') RETURN 0;
262
		ESI++;
263
		EDI++;
264
	}
265
}
266
 
267
 
268
inline fastcall unsigned int find_symbol(ESI,BL)
269
{
270
	int jj=0, last=-1;
271
	do{
272
		jj++;
273
		$lodsb
274
		IF(AL==BL) last=jj;
275
	} while(AL!=0);
276
	return last;
277
}
278
 
279
 
280
inline fastcall ChangeCase(dword EDX)
281
{
282
	AL=DSBYTE[EDX];
283
	IF(AL>='a')&&(AL<='z')DSBYTE[EDX]=AL&0x5f;
284
	IF (AL>=160) && (AL<=175) DSBYTE[EDX] = AL - 32;	//р-я
285
	IF (AL>=224) && (AL<=239) DSBYTE[EDX] = AL - 80;	//р-я
286
	do{
287
		EDX++;
288
		AL=DSBYTE[EDX];
2054 leency 289
		IF(AL>='A')&&(AL<='Z'){DSBYTE[EDX]=AL|0x20; CONTINUE;}
1722 Rock_mania 290
		IF(AL>='А')&&(AL<='П')DSBYTE[EDX]=AL|0x20; //а-п
291
		IF (AL>=144) && (AL<=159) DSBYTE[EDX] = AL + 80;	//р-я
292
	}while(AL!=0);
293
}
294
 
295
 
296
//------------------------------------------------------------------------------
297
inline fastcall void PutPixel(dword EBX,ECX,EDX){
298
  EAX=1;
299
  $int 0x40
300
}
301
 
302
void DefineButton(dword x,y,w,h,EDX,ESI){
303
	EAX = 8;
304
	EBX = x<<16+w;
305
	ECX = y<<16+h;
306
	$int 0x40
307
}
308
 
309
inline fastcall void DeleteButton(dword EDX)
310
{
311
	EAX = 8;
312
	EDX += BT_DEL;
313
	$int 0x40;
314
}
315
 
316
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
317
{
318
	EAX = 4;
319
	EBX = x<<16+y;
320
	ECX = fontType<<24+color;
321
	$int 0x40;
322
}
323
 
324
void DrawBar(dword x,y,w,h,EDX)
325
{
326
	#speed
327
	EAX = 13;
328
	EBX = x<<16+w;
329
	ECX = y<<16+h;
330
 	$int 0x40
331
	#codesize
332
}
333
 
334
void DrawRegion_3D(dword x,y,width,height,color1,color2)
335
{
336
	DrawBar(x,y,width+1,1,color1); //полоса гор сверху
337
	DrawBar(x,y+1,1,height-1,color1); //полоса слева
338
	DrawBar(x+width,y+1,1,height,color2); //полоса справа
339
	DrawBar(x,y+height,width,1,color2); //полоса гор снизу
340
}
341
 
342
void DrawFlatButton(dword x,y,width,height,id,color,text)
343
{
344
	DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
345
	DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
346
	DrawBar(x+2,y+2,width-3,height-3,color); //заливка
2134 leency 347
	IF (id<>0)	DefineButton(x+1,y+1,width-2,height-2,id+BT_HIDE,0xEFEBEF); //кнопка
1722 Rock_mania 348
	WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
349
}
350
 
2134 leency 351
void PutPaletteImage(dword EBX,w,h,x,y, EDI)
1722 Rock_mania 352
{
2134 leency 353
	EAX = 65;
1722 Rock_mania 354
	ECX = w<<16+h;
355
	EDX = x<<16+y;
2134 leency 356
	ESI = 8;
357
	EBP = 0;
1722 Rock_mania 358
	$int 0x40
2134 leency 359
}
1722 Rock_mania 360
 
2134 leency 361
void PutImage(dword EBX,w,h,x,y)
1722 Rock_mania 362
{
2134 leency 363
	EAX = 7;
1722 Rock_mania 364
	ECX = w<<16+h;
365
	EDX = x<<16+y;
366
	$int 0x40
2134 leency 367
}
1722 Rock_mania 368
 
369
//------------------------------------------------------------------------------
2266 leency 370
inline fastcall void WriteDebug(dword EDX)
1722 Rock_mania 371
{
372
	$mov eax, 63
373
	$mov ebx, 1
374
next_char:
375
	$mov ecx, DSDWORD[edx]
376
	$or	 cl, cl
377
	$jz  done
378
	$int 0x40
379
	$inc edx
380
	$jmp next_char
381
done:
382
	$mov cl, 13
383
	$int 0x40
384
	$mov cl, 10
385
	$int 0x40
386
}
2134 leency 387
 
388
inline fastcall void WriteFullDebug(dword ESI)
389
{
390
	WriteDebug("");
391
	WriteDebug(ESI);
392
 
393
	WriteDebug("Number of files:");
394
	WriteDebug(IntToStr(count));
395
 
396
	WriteDebug("but_num:");
397
	WriteDebug(IntToStr(but_num));
398
 
399
	WriteDebug("curbtn");
400
	WriteDebug(IntToStr(curbtn));
401
 
402
	WriteDebug("ra_kadrom:");
403
	WriteDebug(IntToStr(za_kadrom));
404
 
405
	Pause(200);
2266 leency 406
}