Subversion Repositories Kolibri OS

Rev

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