Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
3067 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
#define NULL      0
28
 
29
//Button options
30
#define BT_DEL      0x80000000
31
#define BT_HIDE     0x40000000
32
#define BT_NOFRAME  0x20000000
33
 
34
//-------------------------------------------------------------------------
35
 
36
struct mouse
37
{
3107 leency 38
	signed int x,y,lkm,pkm,hor,vert;
3067 leency 39
	void get();
40
};
41
 
42
void mouse::get()
43
{
44
	EAX = 37;
45
	EBX = 1;
46
	$int	0x40
47
	$mov	ebx, eax
48
	$shr	eax, 16
49
	$and	ebx,0x0000FFFF
50
	x = EAX;
51
	y = EBX;
52
	EAX = 37;
53
	EBX = 2;
54
	$int	0x40
55
	$mov	ebx, eax
56
	$and	eax, 0x00000001
57
	$shr	ebx, 1
58
	$and	ebx, 0x00000001
59
	lkm = EAX;
60
	pkm = EBX;
61
	EAX = 37; //бЄа®««
62
	EBX = 7;
63
	$int	0x40
64
	$mov	ebx, eax
65
	$shr	eax, 16
66
	$and	ebx,0x0000FFFF
67
	//hor = EAX;
68
	vert = EBX;
69
}
70
 
71
 
72
struct system_colors
73
{
74
	dword frame,grab,grab_button,grab_button_text,grab_text,
75
	      work,work_button,work_button_text,work_text,work_graph;
76
	void get();
77
};
78
 
79
void system_colors::get()
80
{
81
	EAX = 48;
82
	EBX = 3;
83
	ECX = #frame;
84
	EDX = 40;
85
	$int 0x40
86
}
87
 
88
//------------------------------------------------------------------------------
89
 
90
inline fastcall dword WaitEvent()
91
{
92
	$mov eax,10
93
	$int 0x40
94
}
95
 
96
inline fastcall dword CheckEvent()
97
{
98
	$mov eax,11
99
	$int 0x40
100
}
101
 
102
inline fastcall dword WaitEventTimeout( EBX)
103
{
104
	$mov eax,23
105
	$int 0x40
106
}
107
 
108
inline fastcall SetEventMask( EBX)
109
{
110
	$mov eax,40
111
	$int 0x40
112
}
113
 
114
inline fastcall ScancodesGeting(){
115
	$mov eax,66
116
	$mov ebx,1
117
	$mov ecx,1 //бЄ ­Є®¤л
118
	$int 0x40
119
}
120
 
121
inline fastcall word GetKey()  //+Gluk fix
122
{
123
		$push edx
3107 leency 124
GETKEY:
3067 leency 125
		$mov  eax,2
126
		$int  0x40
127
		$cmp eax,1
3107 leency 128
		$jne GETKEYI
3067 leency 129
		$mov ah,dh
3107 leency 130
		$jmp GETKEYII //jz?
131
GETKEYI:
3067 leency 132
		$mov dh,ah
3107 leency 133
		$jmp GETKEY
134
GETKEYII:
3067 leency 135
		$pop edx
136
		$shr eax,8
137
}
138
 
139
 
3076 leency 140
inline fastcall pause( EBX)
3067 leency 141
{
142
	$mov eax, 5
143
	$int 0x40
144
}
145
 
146
inline fastcall word GetButtonID()
147
{
148
	$mov eax,17
149
	$int  0x40
150
	$shr eax,8
151
}
152
 
153
//----------------------------------------
154
 
155
inline fastcall dword GetFreeRAM()
156
{
157
	$mov eax, 18
158
	$mov ebx, 16
159
	$int 0x40
160
	//return eax = размер свободной памяти в килобайтах
161
}
162
 
163
inline fastcall dword LoadDriver( ECX) //ECX - имя драйвера
164
{
165
	$mov eax, 68
166
	$mov ebx, 16
167
	$int 0x40
168
	//return 0 - неудача, иначе eax = хэндл драйвера
169
}
170
 
171
inline fastcall dword RuleDriver( ECX) //указатель на управляющую структуру
172
{
173
	$mov eax, 68
174
	$mov ebx, 17
175
	$int 0x40
176
	//return eax = определяется драйвером
177
}
178
 
179
struct proc_info
180
{
181
	#define SelfInfo -1
182
	dword	use_cpu;
183
	word	pos_in_stack,num_slot,rezerv1;
184
	char	name[11];
185
	char	rezerv2;
186
	dword	adress,use_memory,ID,left,top,width,height;
187
	word	status_slot,rezerv3;
188
	dword	work_left,work_top,work_width,work_height;
189
	char	status_window;
3107 leency 190
	dword   cwidth,cheight;
191
	byte    reserved[1024-71-8];
3067 leency 192
};
193
 
194
inline fastcall void GetProcessInfo( EBX, ECX)
195
{
196
	$mov eax,9;
197
	$int  0x40
3107 leency 198
	DSDWORD[EBX+71] = DSDWORD[EBX+42] - 9; //set cwidth
199
	DSDWORD[EBX+75] = DSDWORD[EBX+46] - GetSkinHeight() - 4; //set cheight
3067 leency 200
}
201
 
202
inline fastcall int GetPointOwner( EBX, ECX) //ebx=m.x, ecx=m.y
203
{
204
	$mov eax,34
205
	$int 0x40
206
}
207
 
208
inline fastcall int GetProcessSlot( ECX)
209
{
210
	EAX = 18;
211
	EBX = 21;
212
	$int 0x40
213
}
214
 
215
inline fastcall int GetActiveProcess()
216
{
217
	EAX = 18;
218
	EBX = 7;
219
	$int 0x40
220
}
221
 
3114 leency 222
inline fastcall void ActivateWindow( ECX)
223
{
224
	EAX = 18;
225
	EBX = 3;
226
	$int 0x40
227
}
228
 
3067 leency 229
inline fastcall int CreateThread( ECX,EDX)
230
{
231
	$mov eax,51
232
	$mov ebx,1
233
	$int 0x40
234
}
235
 
236
inline fastcall void SwitchToAnotherThread()
237
{
238
	$mov eax,68
239
	$mov ebx,1
240
	$int 0x40
241
}
242
 
243
inline fastcall int KillProcess( ECX)
244
{
245
	$mov eax,18;
246
	$mov ebx,18;
247
	$int 0x40
248
}
249
 
250
#define TURN_OFF 2
251
#define REBOOT 3
252
#define KERNEL 4
253
inline fastcall int ExitSystem( ECX)
254
{
255
	$mov eax, 18
256
	$mov ebx, 9
257
	$int 0x40
258
}
259
 
260
inline fastcall ExitProcess()
261
{
262
	$mov eax,-1;
263
	$int 0x40
264
}
265
 
266
//------------------------------------------------------------------------------
267
 
268
//eax = язык системы (1=eng, 2=fi, 3=ger, 4=rus)
269
inline fastcall int GetSystemLanguage()
270
{
271
	EAX = 26;
272
	EBX = 5;
273
	$int 0x40
274
}
275
 
276
inline fastcall GetSkinHeight()
277
{
278
	$push ebx
279
	$mov  eax,48
280
	$mov  ebx,4
281
	$int 0x40
282
	$pop  ebx
283
}
284
 
285
inline fastcall void SetSystemSkin( ECX)
286
{
287
	EAX = 48;
288
	EBX = 8;
289
	$int 0x40
290
}
291
 
292
inline fastcall int GetScreenWidth()
293
{
294
	$mov eax, 14
295
	$int 0x40
296
	$shr eax, 16
297
}
298
 
299
inline fastcall int GetScreenHeight()
300
{
301
	$mov eax, 14
302
	$int 0x40
303
	$and eax,0x0000FFFF
304
}
305
 
306
inline fastcall dword LoadLibrary( ECX)
307
{
308
	$mov eax, 68
309
	$mov ebx, 19
310
	$int  0x40
311
}
312
 
313
inline fastcall int TestBit( EAX, CL)
314
{
315
	$shr eax,cl
316
	$and eax,1
317
}
318
 
319
inline fastcall int PlaySpeaker( ESI)
320
{
321
	$mov eax, 55
322
	$mov ebx, 55
323
	$int 0x40
324
}
325
 
326
inline fastcall void debug( EDX)
327
{
3128 leency 328
	$push eax
3067 leency 329
	$push ebx
330
	$push ecx
331
	$mov eax, 63
332
	$mov ebx, 1
3107 leency 333
NEXT_CHAR:
3067 leency 334
	$mov ecx, DSDWORD[edx]
335
	$or	 cl, cl
3107 leency 336
	$jz  DONE
3067 leency 337
	$int 0x40
338
	$inc edx
3107 leency 339
	$jmp NEXT_CHAR
340
DONE:
3067 leency 341
	$mov cl, 13
342
	$int 0x40
343
	$mov cl, 10
344
	$int 0x40
345
	$pop ecx
346
	$pop ebx
3128 leency 347
	$pop eax
3067 leency 348
}
3081 leency 349
 
350
inline fastcall void debugch( ECX)
351
{
3128 leency 352
	$push eax
353
	$push ebx
3081 leency 354
	$mov eax,63
355
	$mov ebx,1
356
	$int 0x40
3128 leency 357
	$pop ebx
358
	$pop eax
3081 leency 359
}
3067 leency 360
//------------------------------------------------------------------------------
361
 
362
void DefineAndDrawWindow(dword x,y, sizeX,sizeY, byte WindowType,dword WindowAreaColor, EDI, ESI)
363
{
364
	EAX = 12;              // function 12:tell os about windowdraw
365
	EBX = 1;
366
	$int 0x40
367
 
368
	EAX = 0;
369
	EBX = x << 16 + sizeX;
370
	ECX = y << 16 + sizeY;
371
	EDX = WindowType << 24 | WindowAreaColor;
372
	$int 0x40
373
 
374
	EAX = 12;              // function 12:tell os about windowdraw
375
	EBX = 2;
376
	$int 0x40
377
}
378
 
379
inline fastcall MoveSize( EBX,ECX,EDX,ESI)
380
{
381
	$mov eax, 67
382
	$int 0x40
383
}
384
 
385
inline fastcall void DrawTitle( ECX)
386
{
387
	EAX = 71;
388
	EBX = 1;
389
	$int 0x40;
390
}
391
 
3107 leency 392
void WriteTextB(dword x,y,byte fontType, dword color, EDX)
3067 leency 393
{
394
	EAX = 4;
395
	EBX = x<<16+y;
396
	ECX = fontType<<24+color;
397
	$int 0x40;
3107 leency 398
	$add ebx, 1<<16
399
	$int 0x40
3067 leency 400
}
401
 
3107 leency 402
void WriteText(dword x,y,byte fontType, dword color, EDX)
403
{
404
	EAX = 4;
405
	EBX = x<<16+y;
406
	ECX = fontType<<24+color;
407
	$xor esi, esi
408
	$int 0x40;
409
}
410
 
3067 leency 411
void WriteNumber(dword x,y,byte fontType, dword color, count, ECX)
412
{
413
	EAX = 47;
414
	EBX = count<<16;
415
	EDX = x<<16+y;
416
	ESI = fontType<<24+color;
417
	$int 0x40;
418
}
419
 
420
void CopyScreen(dword EBX, x, y, sizeX, sizeY)
421
{
422
  EAX = 36;
423
  ECX = sizeX << 16 + sizeY;
424
  EDX = x << 16 + y;
425
  $int  0x40;
426
}
427
 
428
dword GetPixelColor(dword x, x_size, y)
429
{
430
	$mov eax, 35
431
	EBX= y*x_size+x;
432
	$int 0x40
433
}
434
 
435
void PutImage(dword EBX,w,h,x,y)
436
{
437
	EAX = 7;
438
	ECX = w<<16+h;
439
	EDX = x<<16+y;
440
	$int 0x40
441
}
442
 
443
void _PutImage(dword x,y, w,h, EBX)
444
{
445
	EAX = 7;
446
	ECX = w<<16+h;
447
	EDX = x<<16+y;
448
	$int 0x40
449
}
450
 
451
void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
452
{
453
	EAX = 65;
454
	ECX = w<<16+h;
455
	EDX = x<<16+y;
456
	EBP = 0;
457
	$int 0x40
458
}
459
 
460
inline fastcall void PutPixel( EBX,ECX,EDX)
461
{
462
  EAX=1;
463
  $int 0x40
464
}
465
 
466
void DrawBar(dword x,y,w,h,EDX)
467
{
3225 leency 468
	if (h<=0) || (h>60000) || (w<=0) || (w>60000) return; //bad boy :)
3067 leency 469
	EAX = 13;
470
	EBX = x<<16+w;
471
	ECX = y<<16+h;
472
 	$int 0x40
473
}
474
 
475
void DefineButton(dword x,y,w,h,EDX,ESI)
476
{
3107 leency 477
	EAX = 8;
478
	$push edx
479
	EDX += BT_DEL;
480
	$int 0x40;
481
	$pop edx
3067 leency 482
	EBX = x<<16+w;
483
	ECX = y<<16+h;
484
	$int 0x40
485
}
486
 
3107 leency 487
void UnsafeDefineButton(dword x,y,w,h,EDX,ESI)
488
{
489
	EAX = 8;
490
	EBX = x<<16+w;
491
	ECX = y<<16+h;
492
	$int 0x40
493
}
494
 
3067 leency 495
inline fastcall void DeleteButton( EDX)
496
{
497
	EAX = 8;
498
	EDX += BT_DEL;
499
	$int 0x40;
3081 leency 500
}