Subversion Repositories Kolibri OS

Rev

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