Subversion Repositories Kolibri OS

Rev

Rev 937 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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