Subversion Repositories Kolibri OS

Rev

Rev 3467 | Rev 3958 | 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;
3363 leency 10
dword  alloc_mem    = MEMSIZE;
11
dword  x86esp_reg   = MEMSIZE;
3067 leency 12
dword  I_Param      = #param;
13
dword  I_Path       = #program_path;
14
char param[4096];
15
char program_path[4096];
16
 
3363 leency 17
#define NULL      0
18
#define OLD      -1
19
#define true      1
20
#define false     0
21
 
3067 leency 22
//Events
23
#define evMouse   6
24
#define evButton  3
25
#define evKey     2
26
#define evReDraw  1
27
 
28
//Button options
29
#define BT_DEL      0x80000000
30
#define BT_HIDE     0x40000000
31
#define BT_NOFRAME  0x20000000
32
 
33
//-------------------------------------------------------------------------
34
 
35
struct mouse
36
{
3107 leency 37
	signed int x,y,lkm,pkm,hor,vert;
3067 leency 38
	void get();
39
};
40
 
41
void mouse::get()
42
{
43
	EAX = 37;
44
	EBX = 1;
45
	$int	0x40
46
	$mov	ebx, eax
47
	$shr	eax, 16
48
	$and	ebx,0x0000FFFF
49
	x = EAX;
50
	y = EBX;
51
	EAX = 37;
52
	EBX = 2;
53
	$int	0x40
54
	$mov	ebx, eax
55
	$and	eax, 0x00000001
56
	$shr	ebx, 1
57
	$and	ebx, 0x00000001
58
	lkm = EAX;
59
	pkm = EBX;
60
	EAX = 37; //бЄа®««
61
	EBX = 7;
62
	$int	0x40
63
	$mov	ebx, eax
64
	$shr	eax, 16
65
	$and	ebx,0x0000FFFF
66
	//hor = EAX;
67
	vert = EBX;
3434 leency 68
	if (y>6000) y=0;
3067 leency 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
 
3877 leency 155
/* ecx = point to structure
156
          sysdir_name     rb 64
157
          sysdir_path     rb 64
158
Пример:
159
dir_name1       db 'addappl',0
160
dir_path1       db 'HD0/1',0
161
*/
162
inline fastcall int SetAddApplDir( ECX)
163
{
164
	EAX = 30;
165
	EBX = 3;
166
	$int 0x40
167
}
168
 
3067 leency 169
inline fastcall dword GetFreeRAM()
170
{
171
	$mov eax, 18
172
	$mov ebx, 16
173
	$int 0x40
174
	//return eax = размер свободной памяти в килобайтах
175
}
176
 
177
inline fastcall dword LoadDriver( ECX) //ECX - имя драйвера
178
{
179
	$mov eax, 68
180
	$mov ebx, 16
181
	$int 0x40
182
	//return 0 - неудача, иначе eax = хэндл драйвера
183
}
184
 
185
inline fastcall dword RuleDriver( ECX) //указатель на управляющую структуру
186
{
187
	$mov eax, 68
188
	$mov ebx, 17
189
	$int 0x40
190
	//return eax = определяется драйвером
191
}
192
 
193
struct proc_info
194
{
195
	#define SelfInfo -1
196
	dword	use_cpu;
197
	word	pos_in_stack,num_slot,rezerv1;
198
	char	name[11];
199
	char	rezerv2;
200
	dword	adress,use_memory,ID,left,top,width,height;
201
	word	status_slot,rezerv3;
202
	dword	work_left,work_top,work_width,work_height;
203
	char	status_window;
3107 leency 204
	dword   cwidth,cheight;
205
	byte    reserved[1024-71-8];
3067 leency 206
};
207
 
208
inline fastcall void GetProcessInfo( EBX, ECX)
209
{
210
	$mov eax,9;
211
	$int  0x40
3107 leency 212
	DSDWORD[EBX+71] = DSDWORD[EBX+42] - 9; //set cwidth
213
	DSDWORD[EBX+75] = DSDWORD[EBX+46] - GetSkinHeight() - 4; //set cheight
3067 leency 214
}
215
 
216
inline fastcall int GetPointOwner( EBX, ECX) //ebx=m.x, ecx=m.y
217
{
218
	$mov eax,34
219
	$int 0x40
220
}
221
 
222
inline fastcall int GetProcessSlot( ECX)
223
{
224
	EAX = 18;
225
	EBX = 21;
226
	$int 0x40
227
}
228
 
229
inline fastcall int GetActiveProcess()
230
{
231
	EAX = 18;
232
	EBX = 7;
233
	$int 0x40
234
}
235
 
3114 leency 236
inline fastcall void ActivateWindow( ECX)
237
{
238
	EAX = 18;
239
	EBX = 3;
240
	$int 0x40
241
}
242
 
3067 leency 243
inline fastcall int CreateThread( ECX,EDX)
244
{
245
	$mov eax,51
246
	$mov ebx,1
247
	$int 0x40
248
}
249
 
250
inline fastcall void SwitchToAnotherThread()
251
{
252
	$mov eax,68
253
	$mov ebx,1
254
	$int 0x40
255
}
256
 
3458 leency 257
inline fastcall int SendWindowMessage( ECX, EDX)
3444 leency 258
{
259
	$mov eax, 72
260
	$mov ebx, 1
261
	$int 0x40
262
}
263
 
3067 leency 264
inline fastcall int KillProcess( ECX)
265
{
266
	$mov eax,18;
267
	$mov ebx,18;
268
	$int 0x40
269
}
270
 
271
#define TURN_OFF 2
272
#define REBOOT 3
273
#define KERNEL 4
274
inline fastcall int ExitSystem( ECX)
275
{
276
	$mov eax, 18
277
	$mov ebx, 9
278
	$int 0x40
279
}
280
 
281
inline fastcall ExitProcess()
282
{
283
	$mov eax,-1;
284
	$int 0x40
285
}
286
 
287
//------------------------------------------------------------------------------
288
 
289
//eax = язык системы (1=eng, 2=fi, 3=ger, 4=rus)
290
inline fastcall int GetSystemLanguage()
291
{
292
	EAX = 26;
293
	EBX = 5;
294
	$int 0x40
295
}
296
 
297
inline fastcall GetSkinHeight()
298
{
299
	$push ebx
300
	$mov  eax,48
301
	$mov  ebx,4
302
	$int 0x40
303
	$pop  ebx
304
}
305
 
306
inline fastcall void SetSystemSkin( ECX)
307
{
308
	EAX = 48;
309
	EBX = 8;
310
	$int 0x40
311
}
312
 
313
inline fastcall int GetScreenWidth()
314
{
315
	$mov eax, 14
316
	$int 0x40
317
	$shr eax, 16
318
}
319
 
320
inline fastcall int GetScreenHeight()
321
{
322
	$mov eax, 14
323
	$int 0x40
324
	$and eax,0x0000FFFF
325
}
326
 
327
inline fastcall dword LoadLibrary( ECX)
328
{
329
	$mov eax, 68
330
	$mov ebx, 19
331
	$int  0x40
332
}
333
 
334
inline fastcall int TestBit( EAX, CL)
335
{
336
	$shr eax,cl
337
	$and eax,1
338
}
339
 
340
inline fastcall int PlaySpeaker( ESI)
341
{
342
	$mov eax, 55
343
	$mov ebx, 55
344
	$int 0x40
345
}
346
 
347
inline fastcall void debug( EDX)
348
{
3128 leency 349
	$push eax
3067 leency 350
	$push ebx
351
	$push ecx
352
	$mov eax, 63
353
	$mov ebx, 1
3107 leency 354
NEXT_CHAR:
3067 leency 355
	$mov ecx, DSDWORD[edx]
356
	$or	 cl, cl
3107 leency 357
	$jz  DONE
3067 leency 358
	$int 0x40
359
	$inc edx
3107 leency 360
	$jmp NEXT_CHAR
361
DONE:
3067 leency 362
	$mov cl, 13
363
	$int 0x40
364
	$mov cl, 10
365
	$int 0x40
366
	$pop ecx
367
	$pop ebx
3128 leency 368
	$pop eax
3067 leency 369
}
3081 leency 370
 
3363 leency 371
 
3081 leency 372
inline fastcall void debugch( ECX)
373
{
3128 leency 374
	$push eax
375
	$push ebx
3081 leency 376
	$mov eax,63
377
	$mov ebx,1
378
	$int 0x40
3128 leency 379
	$pop ebx
380
	$pop eax
3081 leency 381
}
3067 leency 382
//------------------------------------------------------------------------------
383
 
384
void DefineAndDrawWindow(dword x,y, sizeX,sizeY, byte WindowType,dword WindowAreaColor, EDI, ESI)
385
{
386
	EAX = 12;              // function 12:tell os about windowdraw
387
	EBX = 1;
388
	$int 0x40
389
 
390
	EAX = 0;
391
	EBX = x << 16 + sizeX;
392
	ECX = y << 16 + sizeY;
393
	EDX = WindowType << 24 | WindowAreaColor;
394
	$int 0x40
395
 
396
	EAX = 12;              // function 12:tell os about windowdraw
397
	EBX = 2;
398
	$int 0x40
399
}
400
 
401
inline fastcall MoveSize( EBX,ECX,EDX,ESI)
402
{
403
	$mov eax, 67
404
	$int 0x40
405
}
406
 
407
inline fastcall void DrawTitle( ECX)
408
{
409
	EAX = 71;
410
	EBX = 1;
411
	$int 0x40;
412
}
413
 
3107 leency 414
void WriteTextB(dword x,y,byte fontType, dword color, EDX)
3067 leency 415
{
416
	EAX = 4;
417
	EBX = x<<16+y;
418
	ECX = fontType<<24+color;
3363 leency 419
	ESI = 0;
3067 leency 420
	$int 0x40;
3107 leency 421
	$add ebx, 1<<16
422
	$int 0x40
3067 leency 423
}
424
 
3107 leency 425
void WriteText(dword x,y,byte fontType, dword color, EDX)
426
{
427
	EAX = 4;
428
	EBX = x<<16+y;
429
	ECX = fontType<<24+color;
430
	$int 0x40;
431
}
432
 
3467 leency 433
dword WriteBufText(dword x,y,byte fontType, dword color, EDX, EDI)
434
{
435
	EAX = 4;
436
	EBX = x<<16+y;
437
	ECX = fontType<<24+color;
438
	$int 0x40;
439
}
440
 
3067 leency 441
void WriteNumber(dword x,y,byte fontType, dword color, count, ECX)
442
{
443
	EAX = 47;
444
	EBX = count<<16;
445
	EDX = x<<16+y;
446
	ESI = fontType<<24+color;
447
	$int 0x40;
448
}
449
 
3363 leency 450
void CopyScreen(dword EBX, x, y, w, h)
3067 leency 451
{
452
  EAX = 36;
3363 leency 453
  ECX = w << 16 + h;
3067 leency 454
  EDX = x << 16 + y;
455
  $int  0x40;
456
}
457
 
3467 leency 458
:dword GetPixelColor(dword x, x_size, y)
3067 leency 459
{
460
	$mov eax, 35
461
	EBX= y*x_size+x;
462
	$int 0x40
463
}
464
 
465
 
466
void _PutImage(dword x,y, w,h, EBX)
467
{
468
	EAX = 7;
469
	ECX = w<<16+h;
470
	EDX = x<<16+y;
471
	$int 0x40
472
}
473
 
474
void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
475
{
476
	EAX = 65;
477
	ECX = w<<16+h;
478
	EDX = x<<16+y;
479
	EBP = 0;
480
	$int 0x40
481
}
482
 
483
inline fastcall void PutPixel( EBX,ECX,EDX)
484
{
485
  EAX=1;
486
  $int 0x40
487
}
488
 
489
void DrawBar(dword x,y,w,h,EDX)
490
{
3225 leency 491
	if (h<=0) || (h>60000) || (w<=0) || (w>60000) return; //bad boy :)
3067 leency 492
	EAX = 13;
493
	EBX = x<<16+w;
494
	ECX = y<<16+h;
495
 	$int 0x40
496
}
497
 
498
void DefineButton(dword x,y,w,h,EDX,ESI)
499
{
3107 leency 500
	EAX = 8;
501
	$push edx
502
	EDX += BT_DEL;
503
	$int 0x40;
504
	$pop edx
3067 leency 505
	EBX = x<<16+w;
506
	ECX = y<<16+h;
507
	$int 0x40
508
}
509
 
3107 leency 510
void UnsafeDefineButton(dword x,y,w,h,EDX,ESI)
511
{
512
	EAX = 8;
513
	EBX = x<<16+w;
514
	ECX = y<<16+h;
515
	$int 0x40
516
}
517
 
3067 leency 518
inline fastcall void DeleteButton( EDX)
519
{
520
	EAX = 8;
521
	EDX += BT_DEL;
522
	$int 0x40;
3363 leency 523
}