Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
2811 leency 1
//CODED by Veliant, Leency, Nable. 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;
12
dword  I_Param      = #param;
13
dword  I_Path       = #program_path;
14
char param[4096];
15
char program_path[4096];
16
 
17
//Events
18
#define evMouse   6
19
#define evButton  3
20
#define evKey     2
21
#define evReDraw  1
22
 
23
#define OLD      -1
24
#define true      1
25
#define false     0
26
 
27
//Button options
28
#define BT_DEL      0x80000000
29
#define BT_HIDE     0x40000000
30
#define BT_NOFRAME  0x20000000
31
 
32
//-------------------------------------------------------------------------
33
 
34
struct mouse
35
{
36
	dword x,y,lkm,pkm,hor,vert;
37
	void get();
38
};
39
 
40
void mouse::get()
41
{
42
	EAX = 37;
43
	EBX = 1;
44
	$int	0x40
45
	$mov	ebx, eax
46
	$shr	eax, 16
47
	$and	ebx,0x0000FFFF
48
	x = EAX;
49
	y = EBX;
50
	EAX = 37;
51
	EBX = 2;
52
	$int	0x40
53
	$mov	ebx, eax
54
	$and	eax, 0x00000001
55
	$shr	ebx, 1
56
	$and	ebx, 0x00000001
57
	lkm = EAX;
58
	pkm = EBX;
59
	EAX = 37; //скролл
60
	EBX = 7;
61
	$int	0x40
62
	$mov	ebx, eax
63
	$shr	eax, 16
64
	$and	ebx,0x0000FFFF
65
	//hor = EAX;
66
	vert = EBX;
67
}
68
 
69
 
70
struct system_colors
71
{
72
	dword frame,grab,grab_button,grab_button_text,grab_text,work,work_button,work_button_text,work_text,work_graph;
73
	void get();
74
};
75
 
76
void system_colors::get()
77
{
78
	EAX = 48;
79
	EBX = 3;
80
	ECX = #frame;
81
	EDX = 40;
82
	$int 0x40
83
}
84
 
85
//------------------------------------------------------------------------------
86
 
87
inline fastcall dword WaitEvent()
88
{
89
	$mov eax,10
90
	$int 0x40
91
}
92
 
93
inline fastcall dword CheckEvent()
94
{
95
	$mov eax,11
96
	$int 0x40
97
}
98
 
99
inline fastcall dword WaitEventTimeout( EBX)
100
{
101
	$mov eax,23
102
	$int 0x40
103
}
104
 
105
inline fastcall SetEventMask( EBX)
106
{
107
	$mov eax,40
108
	$int 0x40
109
}
110
 
111
inline fastcall ScancodesGeting(){
112
	$mov eax,66
113
	$mov ebx,1
114
	$mov ecx,1 //сканкоды
115
	$int 0x40
116
}
117
 
118
 
119
inline fastcall word GetKey()  //+Gluk fix
120
{
121
		$push edx
122
@getkey:
123
		$mov  eax,2
124
		$int  0x40
125
		$cmp eax,1
126
		$jne getkeyi
127
		$mov ah,dh
128
		$jmp getkeyii //jz?
129
@getkeyi:
130
		$mov dh,ah
131
		$jmp getkey
132
@getkeyii:
133
		$pop edx
134
		$shr eax,8
135
}
136
 
137
 
138
inline fastcall Pause( EBX)
139
{
140
	$mov eax, 5
141
	$int 0x40
142
}
143
 
144
inline fastcall word GetButtonID()
145
{
146
	$mov eax,17
147
	$int  0x40
148
	$shr eax,8
149
}
150
 
151
struct proc_info
152
{
153
	#define SelfInfo -1
154
	dword	use_cpu;
155
	word	pos_in_stack,num_slot,rezerv1;
156
	char	name[11];
157
	char	rezerv2;
158
	dword	adress,use_memory,ID,left,top,width,height;
159
	word	status_slot,rezerv3;
160
	dword	work_left,work_top,work_width,work_height;
161
	char	status_window;
162
	void	GetInfo( ECX);
163
	byte    reserved[1024-71];
164
};
165
 
166
void GetProcessInfo( EBX, ECX)
167
{
168
	$mov eax,9;
169
	$int  0x40
170
}
171
 
2825 leency 172
inline fastcall int GetProcessSlot( ECX)
2811 leency 173
{
174
	EAX = 18;
175
	EBX = 21;
2825 leency 176
	$int 0x40
2811 leency 177
}
178
 
2825 leency 179
inline fastcall int GetActiveProcess()
2811 leency 180
{
181
	EAX = 18;
182
	EBX = 7;
183
	$int 0x40
184
}
185
 
186
 
187
inline fastcall ExitProcess()
188
{
189
	$mov eax,-1;
190
	$int 0x40
191
}
192
 
193
inline fastcall int KillProcess( ECX)
194
{
195
	$mov eax,18;
196
	$mov ebx,18;
197
	$int 0x40
198
}
199
 
200
//------------------------------------------------------------------------------
201
 
202
//eax =  ч√ъ ёшёЄхь√ (1=eng, 2=fi, 3=ger, 4=rus)
203
inline fastcall int GetSystemLanguage()
204
{
205
	EAX = 26;
206
	EBX = 5;
207
	$int 0x40
208
}
209
 
210
inline fastcall dword GetSkinWidth()
211
{
212
	$push ebx
213
	$mov  eax,48
214
	$mov  ebx,4
215
	$int 0x40
216
	$pop  ebx
217
}
218
 
2825 leency 219
inline fastcall void SetSystemSkin( ECX)
220
{
2811 leency 221
	EAX = 48;
222
	EBX = 8;
223
	$int 0x40
224
}
225
 
226
inline fastcall dword GetScreenWidth()
227
{
228
	EAX = 14;
229
	EBX = 4;
230
	$int 0x40
231
	$shr eax, 16
232
	$and eax,0x0000FFFF
233
}
234
 
235
inline fastcall dword LoadLibrary( ECX)
236
{
237
	$mov eax, 68
238
	$mov ebx, 19
239
	$int  0x40
240
}
241
 
242
byte fastcall TestBit( EAX, CL)
243
{
244
	$shr eax,cl
245
	$and eax,1
246
}
247
 
2825 leency 248
 
2811 leency 249
//------------------------------------------------------------------------------
250
 
251
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI)
252
{
253
	EAX = 12;              // function 12:tell os about windowdraw
254
	EBX = 1;
255
	$int 0x40
256
 
257
	EBX = x << 16 + sizeX;
258
	ECX = y << 16 + sizeY;
259
	EDX = mainAreaType << 24 | mainAreaColour;
260
	ESI = headerType << 24 | headerColour;
261
	$xor eax,eax
262
	$int 0x40
263
 
264
	EAX = 12;              // function 12:tell os about windowdraw
265
	EBX = 2;
266
	$int 0x40
267
}
268
 
2825 leency 269
inline fastcall MoveSize( EBX,ECX,EDX,ESI)
2811 leency 270
{
2825 leency 271
	EAX = 67;
2811 leency 272
	$int 0x40
273
}
274
 
2825 leency 275
inline fastcall void DrawTitle( ECX)
2811 leency 276
{
2825 leency 277
	EAX = 71;
278
	EBX = 1;
279
	$int 0x40;
2811 leency 280
}
281
 
2825 leency 282
inline fastcall int CreateThread( ECX,EDX)
2811 leency 283
{
2825 leency 284
	EAX = 51;
285
	EBX = 1;
2811 leency 286
	$int 0x40
287
}
288
 
289
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
290
{
291
	EAX = 4;
292
	EBX = x<<16+y;
293
	ECX = fontType<<24+color;
294
	$int 0x40;
295
}
296
 
297
void CopyScreen(dword EBX, x, y, sizeX, sizeY)
298
{
299
  EAX = 36;
300
  ECX = sizeX << 16 + sizeY;
301
  EDX = x << 16 + y;
302
  $int  0x40;
303
}
304
 
305
void PutImage(dword EBX,w,h,x,y)
306
{
307
	EAX = 7;
308
	ECX = w<<16+h;
309
	EDX = x<<16+y;
310
	$int 0x40
311
}
312
 
313
void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
314
{
315
	EAX = 65;
316
	ECX = w<<16+h;
317
	EDX = x<<16+y;
318
	EBP = 0;
319
	$int 0x40
320
}
321
 
322
inline fastcall void PutPixel( EBX,ECX,EDX)
323
{
324
  EAX=1;
325
  $int 0x40
326
}
327
 
328
void DrawBar(dword x,y,w,h,EDX)
329
{
330
	EAX = 13;
331
	EBX = x<<16+w;
332
	ECX = y<<16+h;
333
 	$int 0x40
334
}
335
 
336
void DefineButton(dword x,y,w,h,EDX,ESI)
337
{
338
 	EAX = 8;
339
	EBX = x<<16+w;
340
	ECX = y<<16+h;
341
	$int 0x40
342
}
343
 
344
inline fastcall void DeleteButton( EDX)
345
{
346
	EAX = 8;
347
	EDX += BT_DEL;
348
	$int 0x40;
349
}
350
 
2825 leency 351
 
352
//------------------------------------------------------------------------------
353
 
354
void DrawRegion(dword x,y,width,height,color1)
2811 leency 355
{
356
	DrawBar(x,y,width,1,color1); //полоса гор сверху
357
	DrawBar(x,y+height,width,1,color1); //полоса гор снизу
358
	DrawBar(x,y,1,height,color1); //полоса верху слева
359
	DrawBar(x+width,y,1,height+1,color1); //полоса верху справа
360
}
361
 
2825 leency 362
void DrawRegion_3D(dword x,y,width,height,color1,color2)
2811 leency 363
{
364
	DrawBar(x,y,width+1,1,color1); //полоса гор сверху
365
	DrawBar(x,y+1,1,height-1,color1); //полоса слева
366
	DrawBar(x+width,y+1,1,height,color2); //полоса справа
367
	DrawBar(x,y+height,width,1,color2); //полоса гор снизу
368
}
369
 
370
void DrawFlatButton(dword x,y,width,height,id,color,text)
371
{
372
	DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
373
	DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
374
	DrawBar(x+2,y+2,width-3,height-3,color); //заливка
375
	IF (id<>0)	DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //кнопка
2825 leency 376
	//WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
377
	WriteText(width/2+x+1,height/2-3+y,0x80,0,text,0);
2811 leency 378
}
379
 
2825 leency 380
void DrawCircle(int x, y, r)
2811 leency 381
{
2825 leency 382
	int i;
383
	float px=0, py=r, ii = r * 3.1415926 * 2;
2811 leency 384
	FOR (i = 0; i < ii; i++)
385
	{
386
        PutPixel(px + x, y - py, 0);
387
        px = py / r + px;
388
        py = -px / r + py;
389
	}
390
}
391
 
392
//------------------------------------------------------------------------------
393
 
394
inline fastcall void debug( EDX)
395
{
396
	$push ebx
397
	$push ecx
398
	$mov eax, 63
399
	$mov ebx, 1
400
next_char:
401
	$mov ecx, DSDWORD[edx]
402
	$or	 cl, cl
403
	$jz  done
404
	$int 0x40
405
	$inc edx
406
	$jmp next_char
407
done:
408
	$mov cl, 13
409
	$int 0x40
410
	$mov cl, 10
411
	$int 0x40
412
	$pop ecx
413
	$pop ebx
414
}