Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
903 leency 1
//CODED by Veliant, Leency. 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;
10
dword  alloc_mem    = 0x00100000;
11
dword  x86esp_reg   = 0x00100000;   // 0x0007fff0;
12
dword  I_Param      = #param;
13
dword  I_Icon       = 0x0;
935 leency 14
dword  skin_width;
903 leency 15
char param[256]="";
16
 
17
//Events
935 leency 18
#define evMouse		6
903 leency 19
#define evButton	3
20
#define evKey		2
21
#define evReDraw	1
22
 
23
//Button options
24
#define BT_DEL		0x80000000
25
#define BT_HIDE		0x40000000
26
#define BT_NOFRAME	0x20000000
27
 
28
#define OLD			-1
29
#define true		1
30
#define false		0
31
 
32
 
33
 
34
int vert;
35
struct mouse{
937 leency 36
 int x,y,lkm,pkm;
903 leency 37
 void get();
38
};
39
 
40
void mouse::get()
41
{
42
	EAX = 37;
43
	EBX = 1;
44
	$int	0x40
45
	$mov	ebx, eax
46
	$shr	eax, 16
47
	$and	ebx,0x0000FFFF
48
	x = EAX;
975 leency 49
	y = EBX;
903 leency 50
	EAX = 37;
51
	EBX = 2;
52
	$int	0x40
53
	$mov	ebx, eax
54
	$and	eax, 0x00000001
55
	$shr	ebx, 1
56
	$and	ebx, 0x00000001
57
	lkm = EAX;
58
	pkm = EBX;
59
	EAX = 37; //скролл
60
	EBX = 7;
61
	$int	0x40
62
	$mov	ebx, eax
63
	$shr	eax, 16
64
	$and	ebx,0x0000FFFF
65
	//hor = EAX;
66
	vert = EBX;
67
}
68
 
69
//---------------------------------------------------------------------------
70
struct proc_info{
71
	dword	use_cpu;
72
	word	pos_in_stack,num_slot,rezerv1;
73
	char	name[11];
74
	char	rezerv2;
75
	dword	adress,use_memory,ID,left,top,width,height;
76
	word	status_slot,rezerv3;
77
	dword	work_left,work_top,work_width,work_height;
78
	char	status_window;
937 leency 79
	void	GetInfo(dword ECX);
80
#define SelfInfo -1
903 leency 81
};
82
 
937 leency 83
void proc_info::GetInfo(dword ECX)
903 leency 84
{
85
	EAX = 9;
86
	EBX = #use_cpu;
937 leency 87
	$int  0x40
903 leency 88
}
89
//-------------------------------------------------------------------------------
90
 
91
inline fastcall dword WaitEvent(){
92
 EAX = 10;              // wait here for event
93
 $int 0x40
94
}
95
 
944 leency 96
inline fastcall void SetEventMask(dword EBX)
937 leency 97
{
98
 EAX = 40;
99
 $int 0x40
944 leency 100
}
903 leency 101
 
102
inline fastcall word GetKey(){
103
 EAX = 2;              // just read this key from buffer
104
 $int  0x40
105
 EAX = EAX >> 8;
106
}
107
 
108
inline fastcall word GetButtonID(){
109
 EAX = 17;            // Get ID
110
 $int  0x40
111
 EAX = EAX >> 8;
112
}
113
 
935 leency 114
inline fastcall void ExitProcess(){
115
 EAX = -1;            // close this program
116
 $int 0x40
117
}
903 leency 118
 
937 leency 119
void Pause(dword EBX){
120
	$mov eax, 5       //Пауза, в сотых долях секунды
935 leency 121
	$int 0x40
937 leency 122
}
935 leency 123
 
124
//------------------------------------------------------------------------------
125
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword
126
	mainAreaColor,byte headerType,dword headerColor,EDI)
903 leency 127
{
935 leency 128
	EBX = x << 16 + sizeX;
129
	ECX = y << 16 + sizeY;
130
	EDX = mainAreaType << 24 | mainAreaColor;
131
	ESI = headerType << 24 | headerColor;
132
	$xor eax,eax
133
	$int 0x40
134
}
135
 
975 leency 136
inline fastcall dword CreateThread(dword ECX,EDX)
137
{
138
	EAX = 51;
139
	EBX = 1;
140
	$int 0x40
141
}
142
 
935 leency 143
inline fastcall void DrawTitle(dword ECX){
903 leency 144
	EAX = 71;
145
	EBX = 1;
146
	$int 0x40;
147
}
148
 
935 leency 149
 
150
inline fastcall void WindowRedrawStatus(dword EBX){
151
	EAX = 12;              //tell os about windowdraw
152
	$int 0x40
153
}
154
 
155
inline fastcall dword GetSkinWidth(){
903 leency 156
	EAX = 48;
157
	EBX = 4;
158
	$int 0x40
159
}
160
 
935 leency 161
inline fastcall dword MoveSize(dword EBX,ECX,EDX,ESI){
162
	EAX = 67;
163
	$int 0x40
903 leency 164
}
165
 
935 leency 166
//------------------------------------------------------------------------------
903 leency 167
 
935 leency 168
inline fastcall dword strlen(dword EDI){
903 leency 169
	ECX=EAX=0;
170
	ECX--;
171
	$REPNE $SCASB
935 leency 172
	EAX-=2+ECX;
903 leency 173
}
174
 
175
 
935 leency 176
inline fastcall copystr(dword ESI,EDI)
177
{
178
	$cld
179
l1:
180
	$lodsb
181
	$stosb
182
	$test al,al
183
	$jnz l1
184
}
185
 
186
 
187
char buffer[11]="";
188
inline fastcall dword IntToStr(dword ESI)
189
{
190
     $mov     edi, #buffer
191
     $mov     ecx, 10
192
     $test     esi, esi
193
     $jns     f1
194
     $mov     al, '-'
195
     $stosb
196
     $neg     esi
197
f1:
198
     $mov     eax, esi
199
     $push     -'0'
200
f2:
201
     $xor     edx, edx
202
     $div     ecx
203
     $push     edx
204
     $test     eax, eax
205
     $jnz     f2
206
f3:
207
     $pop     eax
208
     $add     al, '0'
209
     $stosb
210
     $jnz     f3
211
     $mov     eax, #buffer
212
     $ret
213
}
214
 
215
 
975 leency 216
inline fastcall int strcmp(ESI, EDI)
903 leency 217
{
975 leency 218
	loop()
219
	{
220
		IF (DSBYTE[ESI]
221
		IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1;
222
		IF (DSBYTE[ESI]=='\0') RETURN 0;
223
		ESI++;
224
		EDI++;
225
	}
903 leency 226
}
227
 
228
 
975 leency 229
inline fastcall unsigned int find_symbol(ESI,BL)
230
{
231
	int jj=0, last=-1;
232
	do{
233
		jj++;
234
		$lodsb
235
		IF(AL==BL) last=jj;
236
	} while(AL!=0);
237
	return last;
238
}
239
 
240
 
241
inline fastcall memmov( EDI, ESI, ECX)
242
{
243
  asm {
244
    MOV EAX, ECX
245
    CMP EDI, ESI
246
    JG L1
247
    JE L2
248
    SAR ECX, 2
249
    JS L2
250
    REP MOVSD
251
    MOV ECX, EAX
252
    AND ECX, 3
253
    REP MOVSB
254
    JMP SHORT L2
255
L1: LEA ESI, DSDWORD[ ESI+ECX-4]
256
    LEA EDI, DSDWORD[ EDI+ECX-4]
257
    SAR ECX, 2
258
    JS L2
259
    STD
260
    REP MOVSD
261
    MOV ECX, EAX
262
    AND ECX, 3
263
    ADD ESI, 3
264
    ADD EDI, 3
265
    REP MOVSB
266
    CLD
267
L2:
268
  }
269
}
270
 
271
 
903 leency 272
inline fastcall dword ChangeCase(dword EDX)
273
{
274
	AL=DSBYTE[EDX];
275
	IF(AL>='a')&&(AL<='z')DSBYTE[EDX]=AL&0x5f;
975 leency 276
	IF (AL>=160) && (AL<=175) DSBYTE[EDX] = AL - 32;	//р-я
277
	IF (AL>=224) && (AL<=239) DSBYTE[EDX] = AL - 80;	//р-я
903 leency 278
	do{
975 leency 279
		EDX++;
903 leency 280
		AL=DSBYTE[EDX];
975 leency 281
		IF(AL>='A')&&(AL<='Z'){DSBYTE[EDX]=AL|0x20; continue;}
282
		IF(AL>='А')&&(AL<='П')DSBYTE[EDX]=AL|0x20; //а-п
283
		IF (AL>=144) && (AL<=159) DSBYTE[EDX] = AL + 80;	//р-я
903 leency 284
	}while(AL!=0);
285
}
286
 
975 leency 287
 
935 leency 288
//------------------------------------------------------------------------------
289
inline fastcall void PutPixel(dword EBX,ECX,EDX){
290
  EAX=1;
291
  $int 0x40
903 leency 292
}
293
 
935 leency 294
void DefineButton(dword x,y,w,h,EDX,ESI){
295
	EAX = 8;
296
	EBX = x<<16+w;
975 leency 297
	ECX = y<<16+h;
903 leency 298
	$int 0x40
299
}
300
 
935 leency 301
inline fastcall void DeleteButton(dword EDX)
903 leency 302
{
303
	EAX = 8;
935 leency 304
	EDX += BT_DEL;
305
	$int 0x40;
903 leency 306
}
307
 
308
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
309
{
310
	EAX = 4;
975 leency 311
	EBX = x<<16+y;
903 leency 312
	ECX = fontType<<24+color;
313
	$int 0x40;
314
}
315
 
316
void DrawBar(dword x,y,w,h,EDX)
317
{
935 leency 318
	#speed
903 leency 319
	EAX = 13;
320
	EBX = x<<16+w;
975 leency 321
	ECX = y<<16+h;
903 leency 322
 	$int 0x40
935 leency 323
	#codesize
903 leency 324
}
325
 
975 leency 326
void DrawRegion_3D(dword x,y,width,height,color1,color2)
903 leency 327
{
975 leency 328
	DrawBar(x,y,width+1,1,color1); //полоса гор сверху
329
	DrawBar(x,y+1,1,height-1,color1); //полоса слева
330
	DrawBar(x+width,y+1,1,height,color2); //полоса справа
331
	DrawBar(x,y+height,width,1,color2); //полоса гор снизу
903 leency 332
}
333
 
334
void DrawFlatButton(dword x,y,width,height,id,color,text)
335
{
975 leency 336
	DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
337
	DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
903 leency 338
	DrawBar(x+2,y+2,width-3,height-3,color); //заливка
935 leency 339
	IF (id<>0)	DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //кнопка
903 leency 340
	WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
341
}
342
 
343
void PutImage(dword EBX,w,h,x,y)
344
{
345
	EAX = 7;
346
	ECX = w<<16+h;
975 leency 347
	EDX = x<<16+y;
903 leency 348
	$int 0x40
349
}
350
 
935 leency 351
void PutPaletteImage(dword EBX,w,h,x,y, EDI)
903 leency 352
{
935 leency 353
	EAX = 65;
354
	ECX = w<<16+h;
975 leency 355
	EDX = x<<16+y;
935 leency 356
	ESI = 8;
357
	EBP = 0;
903 leency 358
	$int 0x40
935 leency 359
}
903 leency 360
 
944 leency 361
//------------------------------------------------------------------------------
362
inline fastcall dword WriteDebug(dword EDX)
363
{
364
	$push ebx
365
	$push ecx
366
	$mov eax, 63
367
	$mov ebx, 1
368
next_char:
369
	$mov ecx, DSDWORD[edx]
370
	$or	 cl, cl
371
	$jz  done
372
	$int 0x40
373
	$inc edx
374
	$jmp next_char
375
done:
376
	$mov cl, 13
377
	$int 0x40
378
	$mov cl, 10
379
	$int 0x40
380
	$pop ecx
381
	$pop ebx
382
}