Subversion Repositories Kolibri OS

Rev

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

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