Subversion Repositories Kolibri OS

Rev

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