Subversion Repositories Kolibri OS

Rev

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