Subversion Repositories Kolibri OS

Rev

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

Rev 3150 Rev 3151
1
//CODED by Veliant, Leency 2008-2012. GNU GPL licence.
1
//CODED by Veliant, Leency 2008-2012. GNU GPL licence.
2
 
2
 
3
#startaddress 0
3
#startaddress 0
4
#code32 TRUE
4
#code32 TRUE
5
 
5
 
6
byte   os_name[8]   = {'M','E','N','U','E','T','0','1'};
6
byte   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    = 0x000b0000;
10
dword  alloc_mem    = 0x000f0000;
11
dword  x86esp_reg   = 0x000b0000;
11
dword  x86esp_reg   = 0x000f0000;
12
dword  I_Param      = #param;
12
dword  I_Param      = #param;
13
dword  I_Path       = #program_path;
13
dword  I_Path       = #program_path;
14
 
14
 
15
char param[4096];
15
char param[4096];
16
char program_path[4096];
16
char program_path[4096];
17
 
17
 
18
#include "lib\strings.h"
18
#include "lib\strings.h"
19
 
19
 
20
//Events
20
//Events
21
#define evMouse		6
21
#define evMouse		6
22
#define evButton	3
22
#define evButton	3
23
#define evKey		2
23
#define evKey		2
24
#define evReDraw	1
24
#define evReDraw	1
25
 
25
 
26
//Button options
26
//Button options
27
#define BT_DEL		0x80000000
27
#define BT_DEL		0x80000000
28
#define BT_HIDE		0x40000000
28
#define BT_HIDE		0x40000000
29
#define BT_NOFRAME	0x20000000
29
#define BT_NOFRAME	0x20000000
30
 
30
 
31
#define OLD			-1
31
#define OLD			-1
32
#define true		1
32
#define true		1
33
#define false		0
33
#define false		0
34
 
34
 
35
#define NULL		0
35
#define NULL		0
36
 
36
 
37
 
37
 
38
struct mouse
38
struct mouse
39
{
39
{
40
	unsigned int x,y,lkm,pkm,hor,vert;
40
	unsigned int x,y,lkm,pkm,hor,vert;
41
	void get();
41
	void get();
42
};
42
};
43
 
43
 
44
inline fastcall int TestBit(EAX, CL)
44
inline fastcall int TestBit(EAX, CL)
45
{
45
{
46
	$shr eax,cl
46
	$shr eax,cl
47
	$and eax,1
47
	$and eax,1
48
}
48
}
49
 
49
 
50
void mouse::get()
50
void mouse::get()
51
{
51
{
52
	EAX = 37;
52
	EAX = 37;
53
	EBX = 1;
53
	EBX = 1;
54
	$int	0x40
54
	$int	0x40
55
	$mov	ebx, eax
55
	$mov	ebx, eax
56
	$shr	eax, 16
56
	$shr	eax, 16
57
	$and	ebx,0x0000FFFF
57
	$and	ebx,0x0000FFFF
58
	x = EAX;
58
	x = EAX;
59
	y = EBX;
59
	y = EBX;
60
	
60
	
61
	EAX = 37;
61
	EAX = 37;
62
	EBX = 2;
62
	EBX = 2;
63
	$int	0x40
63
	$int	0x40
64
	$mov	ebx, eax
64
	$mov	ebx, eax
65
	$and	eax, 0x00000001
65
	$and	eax, 0x00000001
66
	$shr	ebx, 1
66
	$shr	ebx, 1
67
	$and	ebx, 0x00000001
67
	$and	ebx, 0x00000001
68
	lkm = EAX;
68
	lkm = EAX;
69
	pkm = EBX;
69
	pkm = EBX;
70
	
70
	
71
	EAX = 37; //scroll
71
	EAX = 37; //scroll
72
	EBX = 7;
72
	EBX = 7;
73
	$int	0x40
73
	$int	0x40
74
	$mov	ebx, eax
74
	$mov	ebx, eax
75
	$shr	eax, 16
75
	$shr	eax, 16
76
	$and	ebx,0x0000FFFF
76
	$and	ebx,0x0000FFFF
77
	//hor = EAX;
77
	//hor = EAX;
78
	vert = EBX;
78
	vert = EBX;
79
}
79
}
80
 
80
 
81
//---------------------------------------------------------------------------
81
//---------------------------------------------------------------------------
82
struct proc_info
82
struct proc_info
83
{
83
{
84
	#define SelfInfo -1
84
	#define SelfInfo -1
85
	dword	use_cpu;
85
	dword	use_cpu;
86
	word	pos_in_stack,num_slot,rezerv1;
86
	word	pos_in_stack,num_slot,rezerv1;
87
	char	name[11];
87
	char	name[11];
88
	char	rezerv2;
88
	char	rezerv2;
89
	dword	adress,use_memory,ID,left,top,width,height;
89
	dword	adress,use_memory,ID,left,top,width,height;
90
	word	status_slot,rezerv3;
90
	word	status_slot,rezerv3;
91
	dword	work_left,work_top,work_width,work_height;
91
	dword	work_left,work_top,work_width,work_height;
92
	char	status_window;
92
	char	status_window;
93
	dword   cwidth,cheight;
93
	dword   cwidth,cheight;
94
	byte    reserved[1024-71-8];
94
	byte    reserved[1024-71-8];
95
};
95
};
96
 
96
 
97
inline fastcall void GetProcessInfo( EBX, ECX)
97
inline fastcall void GetProcessInfo( EBX, ECX)
98
{
98
{
99
	$mov eax,9;
99
	$mov eax,9;
100
	$int  0x40
100
	$int  0x40
101
	DSDWORD[EBX+71] = DSDWORD[EBX+42] - 9; //set cwidth
101
	DSDWORD[EBX+71] = DSDWORD[EBX+42] - 9; //set cwidth
102
	DSDWORD[EBX+75] = DSDWORD[EBX+46] - GetSkinHeight() - 4; //set cheight
102
	DSDWORD[EBX+75] = DSDWORD[EBX+46] - GetSkinHeight() - 4; //set cheight
103
}
103
}
104
 
104
 
105
inline fastcall int GetSlot( ECX)
105
inline fastcall int GetSlot( ECX)
106
{
106
{
107
	$mov eax,18;
107
	$mov eax,18;
108
	$mov ebx,21;
108
	$mov ebx,21;
109
	$int 0x40
109
	$int 0x40
110
}
110
}
111
 
111
 
112
inline fastcall int GetActiveProcess()
112
inline fastcall int GetActiveProcess()
113
{
113
{
114
	$mov eax,18;
114
	$mov eax,18;
115
	$mov ebx,7;
115
	$mov ebx,7;
116
	$int 0x40
116
	$int 0x40
117
}
117
}
118
 
118
 
119
inline fastcall void ActivateWindow( ECX)
119
inline fastcall void ActivateWindow( ECX)
120
{
120
{
121
	EAX = 18;
121
	EAX = 18;
122
	EBX = 3;
122
	EBX = 3;
123
	$int 0x40
123
	$int 0x40
124
}
124
}
125
 
125
 
126
//-------------------------------------------------------------------------------
126
//-------------------------------------------------------------------------------
127
 
127
 
128
inline fastcall dword WaitEvent(){
128
inline fastcall dword WaitEvent(){
129
	$mov eax,10;
129
	$mov eax,10;
130
	$int 0x40
130
	$int 0x40
131
}
131
}
132
 
132
 
133
inline fastcall void SetEventMask( EBX)
133
inline fastcall void SetEventMask( EBX)
134
{
134
{
135
	EAX = 40;
135
	EAX = 40;
136
	$int 0x40
136
	$int 0x40
137
}
137
}
138
 
138
 
139
inline fastcall word GetKey(){ //+Gluk fix
139
inline fastcall word GetKey(){ //+Gluk fix
140
		$push edx
140
		$push edx
141
GETKEY:
141
GETKEY:
142
		$mov  eax,2
142
		$mov  eax,2
143
		$int  0x40
143
		$int  0x40
144
		$cmp eax,1
144
		$cmp eax,1
145
		$jne GETKEYI
145
		$jne GETKEYI
146
		$mov ah,dh
146
		$mov ah,dh
147
		$jmp GETKEYII //jz?
147
		$jmp GETKEYII //jz?
148
GETKEYI:
148
GETKEYI:
149
		$mov dh,ah
149
		$mov dh,ah
150
		$jmp GETKEY
150
		$jmp GETKEY
151
GETKEYII:
151
GETKEYII:
152
		$pop edx
152
		$pop edx
153
		EAX = EAX >> 8;		 
153
		EAX = EAX >> 8;		 
154
}
154
}
155
 
155
 
156
inline fastcall word GetButtonID(){
156
inline fastcall word GetButtonID(){
157
	EAX = 17;            // Get ID
157
	EAX = 17;            // Get ID
158
	$int  0x40
158
	$int  0x40
159
	EAX = EAX >> 8;
159
	EAX = EAX >> 8;
160
}
160
}
161
 
161
 
162
inline fastcall void ExitProcess(){
162
inline fastcall void ExitProcess(){
163
	EAX = -1;            // close this program
163
	EAX = -1;            // close this program
164
	$int 0x40
164
	$int 0x40
165
}
165
}
166
 
166
 
167
inline fastcall void Pause( EBX){				
167
inline fastcall void Pause( EBX){				
168
	$mov eax, 5
168
	$mov eax, 5
169
	$int 0x40
169
	$int 0x40
170
}
170
}
171
 
171
 
172
//------------------------------------------------------------------------------
172
//------------------------------------------------------------------------------
173
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType, dword mainAreaColour, EDI)
173
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType, dword mainAreaColour, EDI)
174
{
174
{
175
	EAX = 12;              // function 12:tell os about windowdraw
175
	EAX = 12;              // function 12:tell os about windowdraw
176
	EBX = 1;
176
	EBX = 1;
177
	$int 0x40
177
	$int 0x40
178
	
178
	
179
	EBX = x << 16 + sizeX;
179
	EBX = x << 16 + sizeX;
180
	ECX = y << 16 + sizeY;
180
	ECX = y << 16 + sizeY;
181
	EDX = mainAreaType << 24 | mainAreaColour;
181
	EDX = mainAreaType << 24 | mainAreaColour;
182
	$xor eax,eax
182
	$xor eax,eax
183
	$int 0x40
183
	$int 0x40
184
 
184
 
185
	EAX = 12;              // function 12:tell os about windowdraw
185
	EAX = 12;              // function 12:tell os about windowdraw
186
	EBX = 2;
186
	EBX = 2;
187
	$int 0x40
187
	$int 0x40
188
}
188
}
189
 
189
 
190
inline fastcall void CreateThread( ECX,EDX)
190
inline fastcall void CreateThread( ECX,EDX)
191
{
191
{
192
	EAX = 51;
192
	EAX = 51;
193
	EBX = 1;
193
	EBX = 1;
194
	$int 0x40
194
	$int 0x40
195
}
195
}
196
 
196
 
197
inline fastcall void DrawTitle( ECX){
197
inline fastcall void DrawTitle( ECX){
198
	EAX = 71;
198
	EAX = 71;
199
	EBX = 1;
199
	EBX = 1;
200
	$int 0x40;
200
	$int 0x40;
201
}
201
}
202
 
202
 
203
inline fastcall dword GetSkinHeight()
203
inline fastcall dword GetSkinHeight()
204
{
204
{
205
	$push ebx
205
	$push ebx
206
	$mov  eax,48
206
	$mov  eax,48
207
	$mov  ebx,4
207
	$mov  ebx,4
208
	$int 0x40
208
	$int 0x40
209
	$pop  ebx
209
	$pop  ebx
210
}
210
}
211
 
211
 
212
inline fastcall dword GetScreenHeight()
212
inline fastcall dword GetScreenHeight()
213
{
213
{
214
	EAX = 14;
214
	EAX = 14;
215
	$int 0x40
215
	$int 0x40
216
	$and eax,0x0000FFFF
216
	$and eax,0x0000FFFF
217
}
217
}
218
 
218
 
219
inline fastcall dword GetScreenWidth()
219
inline fastcall dword GetScreenWidth()
220
{
220
{
221
	$mov eax, 14
221
	$mov eax, 14
222
	$int 0x40
222
	$int 0x40
223
	$shr eax, 16
223
	$shr eax, 16
224
}
224
}
225
 
225
 
226
inline fastcall void MoveSize( EBX,ECX,EDX,ESI){
226
inline fastcall void MoveSize( EBX,ECX,EDX,ESI){
227
	$mov eax,67;
227
	$mov eax,67;
228
	$int 0x40
228
	$int 0x40
229
}
229
}
230
 
230
 
231
//------------------------------------------------------------------------------
231
//------------------------------------------------------------------------------
232
inline fastcall void PutPixel( EBX,ECX,EDX)
232
inline fastcall void PutPixel( EBX,ECX,EDX)
233
{
233
{
234
  EAX=1;
234
  EAX=1;
235
  $int 0x40
235
  $int 0x40
236
}
236
}
237
 
237
 
238
void DefineButton(dword x,y,w,h,EDX,ESI)
238
void DefineButton(dword x,y,w,h,EDX,ESI)
239
{
239
{
240
 	EAX = 8;
240
 	EAX = 8;
241
	$push edx
241
	$push edx
242
	EDX += BT_DEL; //âíà÷àëå óäàëÿåì êíîïó ñ ýòè èä, ïîòîì ñîçäà¸ì
242
	EDX += BT_DEL; //âíà÷àëå óäàëÿåì êíîïó ñ ýòè èä, ïîòîì ñîçäà¸ì
243
	$int 0x40;
243
	$int 0x40;
244
	EBX = x<<16+w;
244
	EBX = x<<16+w;
245
	ECX = y<<16+h;
245
	ECX = y<<16+h;
246
 	$pop edx
246
 	$pop edx
247
	$int 0x40
247
	$int 0x40
248
}
248
}
249
 
249
 
250
inline fastcall void DeleteButton( EDX)
250
inline fastcall void DeleteButton( EDX)
251
{
251
{
252
	EAX = 8;
252
	EAX = 8;
253
	EDX += BT_DEL;
253
	EDX += BT_DEL;
254
	$int 0x40;
254
	$int 0x40;
255
}
255
}
256
 
256
 
257
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
257
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
258
{
258
{
259
	EAX = 4;
259
	EAX = 4;
260
	EBX = x<<16+y;
260
	EBX = x<<16+y;
261
	ECX = fontType<<24+color;
261
	ECX = fontType<<24+color;
262
	$int 0x40;
262
	$int 0x40;
263
}
263
}
264
 
264
 
265
void DrawBar(dword x,y,w,h,EDX)
265
void DrawBar(dword x,y,w,h,EDX)
266
{
266
{
267
	if (h<0) || (h>8000) return;
267
	if (h<0) || (h>8000) return;
268
	EAX = 13;
268
	EAX = 13;
269
	EBX = x<<16+w;
269
	EBX = x<<16+w;
270
	ECX = y<<16+h;
270
	ECX = y<<16+h;
271
 	$int 0x40
271
 	$int 0x40
272
}
272
}
273
 
273
 
274
void DrawRegion_3D(dword x,y,width,height,color1,color2)
274
void DrawRegion_3D(dword x,y,width,height,color1,color2)
275
{
275
{
276
	DrawBar(x,y,width+1,1,color1);
276
	DrawBar(x,y,width+1,1,color1);
277
	DrawBar(x,y+1,1,height-1,color1);
277
	DrawBar(x,y+1,1,height-1,color1);
278
	DrawBar(x+width,y+1,1,height,color2);
278
	DrawBar(x+width,y+1,1,height,color2);
279
	DrawBar(x,y+height,width,1,color2);
279
	DrawBar(x,y+height,width,1,color2);
280
}
280
}
281
 
281
 
282
void PutPaletteImage(dword EBX,w,h,x,y, EDI)
282
void PutPaletteImage(dword EBX,w,h,x,y, EDI)
283
{
283
{
284
	EAX = 65;
284
	EAX = 65;
285
	ECX = w<<16+h;
285
	ECX = w<<16+h;
286
	EDX = x<<16+y;
286
	EDX = x<<16+y;
287
	ESI = 8;
287
	ESI = 8;
288
	EBP = 0;
288
	EBP = 0;
289
	$int 0x40
289
	$int 0x40
290
} 
290
} 
291
 
291
 
292
void PutImage(dword EBX,w,h,x,y)
292
void PutImage(dword EBX,w,h,x,y)
293
{
293
{
294
	EAX = 7;
294
	EAX = 7;
295
	ECX = w<<16+h;
295
	ECX = w<<16+h;
296
	EDX = x<<16+y;
296
	EDX = x<<16+y;
297
	$int 0x40
297
	$int 0x40
298
}
298
}
299
 
299
 
300
//------------------------------------------------------------------------------
300
//------------------------------------------------------------------------------
301
inline fastcall void debug( EDX)
301
inline fastcall void debug( EDX)
302
{
302
{
303
	$mov eax, 63
303
	$mov eax, 63
304
	$mov ebx, 1
304
	$mov ebx, 1
305
NEXT_CHAR:
305
NEXT_CHAR:
306
	$mov ecx, DSDWORD[edx]
306
	$mov ecx, DSDWORD[edx]
307
	$or	 cl, cl
307
	$or	 cl, cl
308
	$jz  DONE
308
	$jz  DONE
309
	$int 0x40
309
	$int 0x40
310
	$inc edx
310
	$inc edx
311
	$jmp NEXT_CHAR
311
	$jmp NEXT_CHAR
312
DONE:
312
DONE:
313
	$mov cl, 13
313
	$mov cl, 13
314
	$int 0x40
314
	$int 0x40
315
	$mov cl, 10
315
	$mov cl, 10
316
	$int 0x40
316
	$int 0x40
317
}
317
}
318
>
318
>
319
>
319
>
320
>
320
>
321
>
321
>
322
>
322
>
323
>
323
>
324
>
324
>
325
>
325
>
326
>
326
>
327
>
327
>
328
>
328
>
329
>
329
>
330
>
330
>
331
>
331
>
332
>
332
>
333
>
333
>
334
>
334
>
335
>
335
>
336
>
336
>
337
>
337
>