Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
6021 leency 1
//CODED by Veliant, Leency, Nable, Pavelyakov. GNU GPL licence.
2
 
5598 pavelyakov 3
#ifndef INCLUDE_KOLIBRI_H
5582 pavelyakov 4
#define INCLUDE_KOLIBRI_H
5676 pavelyakov 5
#print "[include ]\n"
5576 pavelyakov 6
 
5676 pavelyakov 7
#pragma option OST
8
#pragma option ON
9
#pragma option cri-
10
#pragma option -CPA
11
#initallvar 0
12
#jumptomain FALSE
13
 
3067 leency 14
#startaddress 0
5676 pavelyakov 15
 
3067 leency 16
#code32 TRUE
5676 pavelyakov 17
 
3067 leency 18
char   os_name[8]   = {'M','E','N','U','E','T','0','1'};
19
dword  os_version   = 0x00000001;
5648 pavelyakov 20
dword  start_addr   = #______INIT______;
21
dword  final_addr   = #______STOP______+32;
3363 leency 22
dword  alloc_mem    = MEMSIZE;
23
dword  x86esp_reg   = MEMSIZE;
3067 leency 24
dword  I_Param      = #param;
25
dword  I_Path       = #program_path;
26
char param[4096];
27
char program_path[4096];
28
 
6039 leency 29
#define bool      char
5883 pavelyakov 30
 
3363 leency 31
#define NULL      0
32
#define OLD      -1
33
#define true      1
34
#define false     0
35
 
6039 leency 36
//Process Events
4536 leency 37
#define evReDraw  1
38
#define evKey     2
39
#define evButton  3
5576 pavelyakov 40
#define evDesktop 5
3067 leency 41
#define evMouse   6
5576 pavelyakov 42
#define evIPC     7
4536 leency 43
#define evNetwork 8
5576 pavelyakov 44
#define evDebug   9
3067 leency 45
 
46
//Button options
47
#define BT_DEL      0x80000000
48
#define BT_HIDE     0x40000000
49
#define BT_NOFRAME  0x20000000
50
 
5576 pavelyakov 51
//allow event mask
52
#define EVENT_MASK_REDRAW   000000001b
53
#define EVENT_MASK_KEYBOARD 000000010b
54
#define EVENT_MASK_BUTTONS  000000100b
55
#define EVENT_MASK_DESKTOP  000010000b
56
#define EVENT_MASK_MOUSE    000100000b
57
#define EVENT_MASK_IPC      001000000b
58
#define EVENT_MASK_NETWORK  010000000b
59
#define EVENT_MASK_DEBUG    100000000b
5465 leency 60
 
5576 pavelyakov 61
//ARGS FUNCTION
62
#define END_ARGS 0xFF00FF
3067 leency 63
//-------------------------------------------------------------------------
64
 
5674 pavelyakov 65
#include "../lib/system.h"
66
#include "../lib/mouse.h"
6285 leency 67
#include "../lib/keyboard.h"
5674 pavelyakov 68
 
5477 leency 69
:struct raw_image {
70
	dword w, h, data;
71
};
72
 
3067 leency 73
//------------------------------------------------------------------------------
5582 pavelyakov 74
:dword wait_event_code;
3067 leency 75
inline fastcall dword WaitEvent()
76
{
77
	$mov eax,10
78
	$int 0x40
5576 pavelyakov 79
	wait_event_code = EAX;
5591 pavelyakov 80
	//if(wait_event_code==evMouse) MOUSE.get();
81
	//return wait_event_code;
3067 leency 82
}
83
 
84
inline fastcall dword CheckEvent()
85
{
86
	$mov eax,11
87
	$int 0x40
88
}
89
 
5576 pavelyakov 90
inline fastcall dword WaitEventTimeout(EBX)
3067 leency 91
{
92
	$mov eax,23
93
	$int 0x40
94
}
95
 
5576 pavelyakov 96
inline fastcall SetEventMask(EBX)
3067 leency 97
{
98
	$mov eax,40
99
	$int 0x40
100
}
101
 
102
 
5576 pavelyakov 103
inline fastcall pause(EBX)
3067 leency 104
{
105
	$mov eax, 5
106
	$int 0x40
107
}
108
 
109
inline fastcall word GetButtonID()
110
{
111
	$mov eax,17
112
	$int  0x40
113
	$shr eax,8
114
}
115
 
116
inline fastcall dword GetFreeRAM()
117
{
118
	$mov eax, 18
119
	$mov ebx, 16
120
	$int 0x40
121
	//return eax = размер свободной памяти в килобайтах
122
}
123
 
5576 pavelyakov 124
inline fastcall dword LoadDriver(ECX) //ECX - имя драйвера
3067 leency 125
{
126
	$mov eax, 68
127
	$mov ebx, 16
128
	$int 0x40
129
	//return 0 - неудача, иначе eax = хэндл драйвера
130
}
131
 
5576 pavelyakov 132
inline fastcall dword RuleDriver(ECX) //указатель на управляющую структуру
3067 leency 133
{
134
	$mov eax, 68
135
	$mov ebx, 17
136
	$int 0x40
137
	//return eax = определяется драйвером
138
}
139
 
140
struct proc_info
141
{
142
	#define SelfInfo -1
143
	dword	use_cpu;
144
	word	pos_in_stack,num_slot,rezerv1;
4137 leency 145
	unsigned char name[11];
3067 leency 146
	char	rezerv2;
147
	dword	adress,use_memory,ID,left,top,width,height;
148
	word	status_slot,rezerv3;
149
	dword	work_left,work_top,work_width,work_height;
150
	char	status_window;
3107 leency 151
	dword   cwidth,cheight;
152
	byte    reserved[1024-71-8];
3067 leency 153
};
154
 
5576 pavelyakov 155
inline fastcall void GetProcessInfo(EBX, ECX)
3067 leency 156
{
157
	$mov eax,9;
158
	$int  0x40
3107 leency 159
	DSDWORD[EBX+71] = DSDWORD[EBX+42] - 9; //set cwidth
160
	DSDWORD[EBX+75] = DSDWORD[EBX+46] - GetSkinHeight() - 4; //set cheight
3067 leency 161
}
162
 
163
inline fastcall int GetPointOwner( EBX, ECX) //ebx=m.x, ecx=m.y
164
{
165
	$mov eax,34
166
	$int 0x40
167
}
168
 
169
inline fastcall int GetProcessSlot( ECX)
170
{
171
	EAX = 18;
172
	EBX = 21;
173
	$int 0x40
174
}
175
 
176
inline fastcall int GetActiveProcess()
177
{
178
	EAX = 18;
179
	EBX = 7;
180
	$int 0x40
181
}
182
 
4081 leency 183
:int CheckActiveProcess(int Form_ID)
184
{
4166 leency 185
	int id9=GetProcessSlot(Form_ID);
186
	if (id9==GetActiveProcess()) return 1;
4081 leency 187
	return 0;
188
}
189
 
3114 leency 190
inline fastcall void ActivateWindow( ECX)
191
{
192
	EAX = 18;
193
	EBX = 3;
194
	$int 0x40
195
}
196
 
5421 leency 197
inline fastcall int MinimizeWindow()
198
{
199
	EAX = 18;
200
	EBX = 10;
201
	$int 0x40
202
}
203
 
5576 pavelyakov 204
inline fastcall int CreateThread(ECX,EDX)
3067 leency 205
{
206
	$mov eax,51
207
	$mov ebx,1
208
	$int 0x40
209
}
210
 
211
inline fastcall void SwitchToAnotherThread()
212
{
213
	$mov eax,68
214
	$mov ebx,1
215
	$int 0x40
216
}
217
 
3458 leency 218
inline fastcall int SendWindowMessage( ECX, EDX)
3444 leency 219
{
220
	$mov eax, 72
221
	$mov ebx, 1
222
	$int 0x40
223
}
224
 
3067 leency 225
inline fastcall int KillProcess( ECX)
226
{
227
	$mov eax,18;
228
	$mov ebx,18;
229
	$int 0x40
230
}
231
 
232
#define TURN_OFF 2
233
#define REBOOT 3
234
#define KERNEL 4
235
inline fastcall int ExitSystem( ECX)
236
{
237
	$mov eax, 18
238
	$mov ebx, 9
239
	$int 0x40
240
}
241
 
242
inline fastcall ExitProcess()
243
{
244
	$mov eax,-1;
245
	$int 0x40
246
}
247
 
248
//------------------------------------------------------------------------------
249
 
250
//eax = язык системы (1=eng, 2=fi, 3=ger, 4=rus)
251
inline fastcall int GetSystemLanguage()
252
{
253
	EAX = 26;
254
	EBX = 5;
255
	$int 0x40
256
}
257
 
258
inline fastcall GetSkinHeight()
259
{
260
	$push ebx
261
	$mov  eax,48
262
	$mov  ebx,4
263
	$int 0x40
264
	$pop  ebx
265
}
266
 
267
inline fastcall void SetSystemSkin( ECX)
268
{
269
	EAX = 48;
270
	EBX = 8;
271
	$int 0x40
272
}
273
 
274
inline fastcall int GetScreenWidth()
275
{
276
	$mov eax, 14
277
	$int 0x40
278
	$shr eax, 16
279
}
280
 
281
inline fastcall int GetScreenHeight()
282
{
283
	$mov eax, 14
284
	$int 0x40
285
	$and eax,0x0000FFFF
286
}
287
 
5421 leency 288
inline fastcall int GetClientTop()
289
{
290
	$mov eax, 48
291
	$mov ebx, 5
292
	$int 0x40
6058 leency 293
	$mov eax, ebx
294
	$shr eax, 16
5421 leency 295
}
296
 
297
inline fastcall int GetClientHeight()
298
{
299
	$mov eax, 48
300
	$mov ebx, 5
301
	$int 0x40
6058 leency 302
	$mov eax, ebx
5421 leency 303
}
304
 
3067 leency 305
inline fastcall dword LoadLibrary( ECX)
306
{
307
	$mov eax, 68
308
	$mov ebx, 19
309
	$int  0x40
310
}
311
 
312
inline fastcall int TestBit( EAX, CL)
313
{
314
	$shr eax,cl
315
	$and eax,1
316
}
317
 
318
//------------------------------------------------------------------------------
319
 
3958 leency 320
void DefineAndDrawWindow(dword x, y, size_w, size_h, byte WindowType,dword WindowAreaColor, EDI, ESI)
3067 leency 321
{
322
	EAX = 12;              // function 12:tell os about windowdraw
323
	EBX = 1;
324
	$int 0x40
325
 
5576 pavelyakov 326
	$xor EAX,EAX
3958 leency 327
	EBX = x << 16 + size_w;
328
	ECX = y << 16 + size_h;
5576 pavelyakov 329
 
3067 leency 330
	EDX = WindowType << 24 | WindowAreaColor;
331
	$int 0x40
332
 
333
	EAX = 12;              // function 12:tell os about windowdraw
334
	EBX = 2;
335
	$int 0x40
336
}
337
 
338
inline fastcall MoveSize( EBX,ECX,EDX,ESI)
339
{
340
	$mov eax, 67
341
	$int 0x40
342
}
343
 
344
inline fastcall void DrawTitle( ECX)
345
{
346
	EAX = 71;
347
	EBX = 1;
348
	$int 0x40;
349
}
350
 
3107 leency 351
void WriteTextB(dword x,y,byte fontType, dword color, EDX)
3067 leency 352
{
353
	EAX = 4;
354
	EBX = x<<16+y;
355
	ECX = fontType<<24+color;
3363 leency 356
	ESI = 0;
3067 leency 357
	$int 0x40;
3107 leency 358
	$add ebx, 1<<16
359
	$int 0x40
3067 leency 360
}
361
 
3107 leency 362
void WriteText(dword x,y,byte fontType, dword color, EDX)
363
{
364
	EAX = 4;
365
	EBX = x<<16+y;
366
	ECX = fontType<<24+color;
367
	$int 0x40;
368
}
369
 
3467 leency 370
dword WriteBufText(dword x,y,byte fontType, dword color, EDX, EDI)
371
{
372
	EAX = 4;
373
	EBX = x<<16+y;
374
	ECX = fontType<<24+color;
375
	$int 0x40;
376
}
377
 
3067 leency 378
void WriteNumber(dword x,y,byte fontType, dword color, count, ECX)
379
{
380
	EAX = 47;
381
	EBX = count<<16;
382
	EDX = x<<16+y;
383
	ESI = fontType<<24+color;
384
	$int 0x40;
385
}
386
 
3363 leency 387
void CopyScreen(dword EBX, x, y, w, h)
3067 leency 388
{
389
  EAX = 36;
3363 leency 390
  ECX = w << 16 + h;
3067 leency 391
  EDX = x << 16 + y;
392
  $int  0x40;
393
}
394
 
3467 leency 395
:dword GetPixelColor(dword x, x_size, y)
3067 leency 396
{
397
	$mov eax, 35
398
	EBX= y*x_size+x;
399
	$int 0x40
400
}
401
 
402
 
403
void _PutImage(dword x,y, w,h, EBX)
404
{
405
	EAX = 7;
406
	ECX = w<<16+h;
407
	EDX = x<<16+y;
408
	$int 0x40
409
}
410
 
411
void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
412
{
413
	EAX = 65;
414
	ECX = w<<16+h;
415
	EDX = x<<16+y;
416
	EBP = 0;
417
	$int 0x40
418
}
419
 
420
inline fastcall void PutPixel( EBX,ECX,EDX)
421
{
422
  EAX=1;
423
  $int 0x40
424
}
425
 
426
void DrawBar(dword x,y,w,h,EDX)
427
{
3225 leency 428
	if (h<=0) || (h>60000) || (w<=0) || (w>60000) return; //bad boy :)
3067 leency 429
	EAX = 13;
430
	EBX = x<<16+w;
431
	ECX = y<<16+h;
6058 leency 432
	$int 0x40
3067 leency 433
}
434
 
435
void DefineButton(dword x,y,w,h,EDX,ESI)
436
{
3107 leency 437
	EAX = 8;
438
	$push edx
439
	EDX += BT_DEL;
440
	$int 0x40;
441
	$pop edx
3067 leency 442
	EBX = x<<16+w;
443
	ECX = y<<16+h;
444
	$int 0x40
445
}
446
 
5582 pavelyakov 447
inline RefreshWindow(dword ID_REFRESH,ID_ACTIVE)
448
{
449
	EAX = 18;
450
	EBX = 22;
451
	ECX = 3;
452
	EDX = ID_REFRESH;
453
	$int 0x40
454
	EAX = 18;
455
	EBX = 3;
456
	EDX = ID_ACTIVE;
457
	$int 0x40
458
}
459
 
3107 leency 460
void UnsafeDefineButton(dword x,y,w,h,EDX,ESI)
461
{
462
	EAX = 8;
463
	EBX = x<<16+w;
464
	ECX = y<<16+h;
465
	$int 0x40
466
}
467
 
3067 leency 468
inline fastcall void DeleteButton( EDX)
469
{
470
	EAX = 8;
471
	EDX += BT_DEL;
5630 leency 472
	$int 0x40
5548 leency 473
}
474
 
475
inline fastcall dword GetStartTime()
476
{
477
	$mov eax,26
478
	$mov ebx,9
479
	$int 0x40
5575 pavelyakov 480
}
481
 
5606 pavelyakov 482
:dword X_EventRedrawWindow,Y_EventRedrawWindow;
483
:void _EventRedrawWindow()
484
{
485
	loop()switch(WaitEvent())
486
	{
487
		case evReDraw:
488
			DefineAndDrawWindow(X_EventRedrawWindow,Y_EventRedrawWindow,100,1,1,0x34,0xFFFFFF,"");
489
			pause(10);
490
			ExitProcess();
491
			break;
492
	}
493
}
5760 pavelyakov 494
:char REDRAW_BUFF_EVENT_[4096];
5606 pavelyakov 495
:void EventRedrawWindow(dword x,y)
496
{
497
	X_EventRedrawWindow = x;
498
	Y_EventRedrawWindow = y;
5760 pavelyakov 499
	CreateThread(#_EventRedrawWindow,#REDRAW_BUFF_EVENT_+4092);
5606 pavelyakov 500
}
501
 
6285 leency 502
:struct obj
5576 pavelyakov 503
{
6285 leency 504
	dword x,y,w,h;
505
	void size();
506
};
507
 
508
:void obj::size(dword _x, _y, _w, _h)
5576 pavelyakov 509
{
6285 leency 510
	x=_x;
511
	y=_y;
512
	w=_w;
513
	h=_h;
5576 pavelyakov 514
}
515
 
5582 pavelyakov 516
:struct _screen
517
{
518
	dword width,height;
519
} screen;
520
 
6041 leency 521
:byte skin_height;
5582 pavelyakov 522
 
5640 pavelyakov 523
:void DrawDate(dword x, y, color, in_date)
524
{
525
	EDI = in_date;
526
	EAX = 47;
527
	EBX = 2<<16;
528
	EDX = x<<16+y;
6280 punk_joker 529
	ESI = 0x90<<24+color;
5640 pavelyakov 530
	ECX = EDI.date.day;
531
	$int 0x40;
6285 leency 532
	EDX += 20<<16;
5640 pavelyakov 533
	ECX = EDI.date.month;
534
	$int 0x40;
6285 leency 535
	EDX += 20<<16;
5640 pavelyakov 536
	EBX = 4<<16;
537
	ECX = EDI.date.year;
538
	$int 0x40;
6285 leency 539
	DrawBar(x+17,y+10,2,2,color);
540
	DrawBar(x+37,y+10,2,2,color);
5640 pavelyakov 541
}
542
 
5646 pavelyakov 543
:void __path_name__(dword BUF,PATH)
544
{
545
	dword beg = PATH;
546
	dword pos = PATH;
547
	dword sav = PATH;
548
	dword i;
549
	while(DSBYTE[pos])
550
	{
551
		if(DSBYTE[pos]=='/')sav = pos;
552
		pos++;
553
	}
554
	i = sav-beg;
555
	while(i)
556
	{
557
		DSBYTE[BUF] = DSBYTE[beg];
558
		beg++;
559
		BUF++;
560
		i--;
561
	}
562
	/*while(DSBYTE[beg])
563
	{
564
		DSBYTE[BUF1] = DSBYTE[beg];
565
		beg++;
566
		BUF1++;
567
	}*/
568
	//DSBYTE[BUF1] = 0;
569
	DSBYTE[BUF] = 0;
570
}
5648 pavelyakov 571
char __BUF_DIR__[4096];
572
:struct SELF
573
{
574
	dword dir;
575
	dword file;
576
	dword path;
577
} self;
5646 pavelyakov 578
 
5575 pavelyakov 579
dword __generator;  // random number generator - для генерации случайных чисел
580
 
5582 pavelyakov 581
:dword program_path_length;
5576 pavelyakov 582
 
5575 pavelyakov 583
//The initialization of the initial data before running
5648 pavelyakov 584
void ______INIT______()
5575 pavelyakov 585
{
5648 pavelyakov 586
	self.dir = #__BUF_DIR__;
587
	self.file = 0;
588
	self.path = I_Path;
589
	__path_name__(#__BUF_DIR__,I_Path);
5646 pavelyakov 590
 
6041 leency 591
	skin_height   = GetSkinHeight();
5582 pavelyakov 592
	screen.width  = GetScreenWidth();
593
	screen.height = GetScreenHeight();
594
 
595
	//program_path_length = strlen(I_Path);
5996 leency 596
	DOUBLE_CLICK_DELAY = GetMouseDoubleClickDelay();
5575 pavelyakov 597
	__generator = GetStartTime();
5651 pavelyakov 598
 
6021 leency 599
	mem_init();
5651 pavelyakov 600
 
5575 pavelyakov 601
	main();
5933 pavelyakov 602
	ExitProcess();
5598 pavelyakov 603
}
5648 pavelyakov 604
______STOP______:
6021 leency 605
#endif
606
 
607
#ifndef INCLUDE_MEM_H
608
#include "../lib/mem.h"
609
#endif
6058 leency 610
 
611
#ifndef INCLUDE_DEBUG_H
612
#include "../lib/debug.h"
613
#endif