Subversion Repositories Kolibri OS

Rev

Rev 2839 | 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
{
2874 leency 36
	int x,y,lkm,pkm,hor,vert;
2811 leency 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
 
2839 leency 151
//----------------------------------------
152
 
2811 leency 153
struct proc_info
154
{
155
	#define SelfInfo -1
156
	dword	use_cpu;
157
	word	pos_in_stack,num_slot,rezerv1;
158
	char	name[11];
159
	char	rezerv2;
160
	dword	adress,use_memory,ID,left,top,width,height;
161
	word	status_slot,rezerv3;
162
	dword	work_left,work_top,work_width,work_height;
163
	char	status_window;
164
	void	GetInfo( ECX);
165
	byte    reserved[1024-71];
166
};
167
 
2874 leency 168
inline fastcall void GetProcessInfo( EBX, ECX)
2811 leency 169
{
170
	$mov eax,9;
171
	$int  0x40
172
}
173
 
2839 leency 174
inline fastcall int GetPointOwner( EBX, ECX) //ebx=m.x, ecx=m.y
175
{
176
	$mov eax,34
177
	$int 0x40
178
}
179
 
2825 leency 180
inline fastcall int GetProcessSlot( ECX)
2811 leency 181
{
182
	EAX = 18;
183
	EBX = 21;
2825 leency 184
	$int 0x40
2811 leency 185
}
186
 
2825 leency 187
inline fastcall int GetActiveProcess()
2811 leency 188
{
189
	EAX = 18;
190
	EBX = 7;
191
	$int 0x40
192
}
193
 
2839 leency 194
inline fastcall int CreateThread( ECX,EDX)
195
{
196
	$mov eax,51
197
	$mov ebx,1
198
	$int 0x40
199
}
2811 leency 200
 
2839 leency 201
inline fastcall void SwitchToAnotherThread()
202
{
203
	$mov eax,68
204
	$mov ebx,1
205
	$int 0x40
206
}
207
 
2874 leency 208
inline fastcall int KillProcess( ECX)
2811 leency 209
{
2874 leency 210
	$mov eax,18;
211
	$mov ebx,18;
2811 leency 212
	$int 0x40
213
}
214
 
2874 leency 215
inline fastcall int ExitSystem( ECX)
2811 leency 216
{
2874 leency 217
	#define TURN_OFF 2
218
	#define REBOOT 3
219
	#define KERNEL 4
220
 
221
	$mov eax, 18
222
	$mov ebx, 9
2811 leency 223
	$int 0x40
224
}
225
 
2874 leency 226
inline fastcall ExitProcess()
227
{
228
	$mov eax,-1;
229
	$int 0x40
230
}
231
 
2811 leency 232
//------------------------------------------------------------------------------
233
 
234
//eax =  ч√ъ ёшёЄхь√ (1=eng, 2=fi, 3=ger, 4=rus)
235
inline fastcall int GetSystemLanguage()
236
{
237
	EAX = 26;
238
	EBX = 5;
239
	$int 0x40
240
}
241
 
2874 leency 242
inline fastcall dword GetSkinHeight()
2811 leency 243
{
244
	$push ebx
245
	$mov  eax,48
246
	$mov  ebx,4
247
	$int 0x40
248
	$pop  ebx
249
}
250
 
2825 leency 251
inline fastcall void SetSystemSkin( ECX)
252
{
2811 leency 253
	EAX = 48;
254
	EBX = 8;
255
	$int 0x40
256
}
257
 
2874 leency 258
inline fastcall int GetScreenWidth()
2811 leency 259
{
2874 leency 260
	$mov eax, 14
2811 leency 261
	$int 0x40
262
	$shr eax, 16
2874 leency 263
}
264
 
265
inline fastcall int GetScreenHeight()
266
{
267
	$mov eax, 14
268
	$int 0x40
2811 leency 269
	$and eax,0x0000FFFF
270
}
271
 
272
inline fastcall dword LoadLibrary( ECX)
273
{
274
	$mov eax, 68
275
	$mov ebx, 19
276
	$int  0x40
277
}
278
 
2874 leency 279
inline fastcall int TestBit( EAX, CL)
2811 leency 280
{
281
	$shr eax,cl
282
	$and eax,1
283
}
284
 
2825 leency 285
 
2811 leency 286
//------------------------------------------------------------------------------
287
 
2874 leency 288
void DefineAndDrawWindow(dword x,y, sizeX,sizeY, byte WindowType,dword WindowAreaColor, EDI)
2811 leency 289
{
290
	EAX = 12;              // function 12:tell os about windowdraw
291
	EBX = 1;
292
	$int 0x40
293
 
2874 leency 294
	EAX = 0;
2811 leency 295
	EBX = x << 16 + sizeX;
296
	ECX = y << 16 + sizeY;
2874 leency 297
	EDX = WindowType << 24 | WindowAreaColor;
2811 leency 298
	$int 0x40
299
 
300
	EAX = 12;              // function 12:tell os about windowdraw
301
	EBX = 2;
302
	$int 0x40
303
}
304
 
2825 leency 305
inline fastcall MoveSize( EBX,ECX,EDX,ESI)
2811 leency 306
{
2874 leency 307
	$mov eax, 67
2811 leency 308
	$int 0x40
309
}
310
 
2825 leency 311
inline fastcall void DrawTitle( ECX)
2811 leency 312
{
2825 leency 313
	EAX = 71;
314
	EBX = 1;
315
	$int 0x40;
2811 leency 316
}
317
 
318
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
319
{
320
	EAX = 4;
321
	EBX = x<<16+y;
322
	ECX = fontType<<24+color;
323
	$int 0x40;
324
}
325
 
326
void CopyScreen(dword EBX, x, y, sizeX, sizeY)
327
{
328
  EAX = 36;
329
  ECX = sizeX << 16 + sizeY;
330
  EDX = x << 16 + y;
331
  $int  0x40;
332
}
333
 
2874 leency 334
dword GetPixelColor(dword x, x_size, y)
335
{
336
	$mov eax, 35
337
	EBX= y*x_size+x;
338
	$int 0x40
339
}
340
 
2811 leency 341
void PutImage(dword EBX,w,h,x,y)
342
{
343
	EAX = 7;
344
	ECX = w<<16+h;
345
	EDX = x<<16+y;
346
	$int 0x40
347
}
348
 
349
void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
350
{
351
	EAX = 65;
352
	ECX = w<<16+h;
353
	EDX = x<<16+y;
354
	EBP = 0;
355
	$int 0x40
356
}
357
 
358
inline fastcall void PutPixel( EBX,ECX,EDX)
359
{
360
  EAX=1;
361
  $int 0x40
362
}
363
 
364
void DrawBar(dword x,y,w,h,EDX)
365
{
366
	EAX = 13;
367
	EBX = x<<16+w;
368
	ECX = y<<16+h;
369
 	$int 0x40
370
}
371
 
372
void DefineButton(dword x,y,w,h,EDX,ESI)
373
{
374
 	EAX = 8;
375
	EBX = x<<16+w;
376
	ECX = y<<16+h;
377
	$int 0x40
378
}
379
 
380
inline fastcall void DeleteButton( EDX)
381
{
382
	EAX = 8;
383
	EDX += BT_DEL;
384
	$int 0x40;
385
}
386
 
2825 leency 387
 
388
//------------------------------------------------------------------------------
389
 
2874 leency 390
:void DrawRegion(dword x,y,width,height,color1)
2811 leency 391
{
392
	DrawBar(x,y,width,1,color1); //полоса гор сверху
393
	DrawBar(x,y+height,width,1,color1); //полоса гор снизу
394
	DrawBar(x,y,1,height,color1); //полоса верху слева
395
	DrawBar(x+width,y,1,height+1,color1); //полоса верху справа
396
}
397
 
2874 leency 398
:void DrawRegion_3D(dword x,y,width,height,color1,color2)
2811 leency 399
{
400
	DrawBar(x,y,width+1,1,color1); //полоса гор сверху
401
	DrawBar(x,y+1,1,height-1,color1); //полоса слева
402
	DrawBar(x+width,y+1,1,height,color2); //полоса справа
403
	DrawBar(x,y+height,width,1,color2); //полоса гор снизу
404
}
405
 
2874 leency 406
:void DrawFlatButton(dword x,y,width,height,id,color,text)
2811 leency 407
{
408
	DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
409
	DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
410
	DrawBar(x+2,y+2,width-3,height-3,color); //заливка
411
	IF (id<>0)	DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //кнопка
2825 leency 412
	//WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
413
	WriteText(width/2+x+1,height/2-3+y,0x80,0,text,0);
2811 leency 414
}
415
 
2874 leency 416
:void DrawCircle(int x, y, r)
2811 leency 417
{
2825 leency 418
	int i;
419
	float px=0, py=r, ii = r * 3.1415926 * 2;
2811 leency 420
	FOR (i = 0; i < ii; i++)
421
	{
422
        PutPixel(px + x, y - py, 0);
423
        px = py / r + px;
424
        py = -px / r + py;
425
	}
426
}
427
 
428
//------------------------------------------------------------------------------
429
 
430
inline fastcall void debug( EDX)
431
{
432
	$push ebx
433
	$push ecx
434
	$mov eax, 63
435
	$mov ebx, 1
436
next_char:
437
	$mov ecx, DSDWORD[edx]
438
	$or	 cl, cl
439
	$jz  done
440
	$int 0x40
441
	$inc edx
442
	$jmp next_char
443
done:
444
	$mov cl, 13
445
	$int 0x40
446
	$mov cl, 10
447
	$int 0x40
448
	$pop ecx
449
	$pop ebx
450
}