Subversion Repositories Kolibri OS

Rev

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