Subversion Repositories Kolibri OS

Rev

Rev 3043 | 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
 
110
inline fastcall int ActiveProcess()
111
{
2814 leency 112
	$mov eax,18;
113
	$mov ebx,7;
2568 leency 114
	$int 0x40
115
}
116
 
117
//-------------------------------------------------------------------------------
118
 
119
inline fastcall dword WaitEvent(){
2814 leency 120
	$mov eax,10;
2568 leency 121
	$int 0x40
122
}
123
 
2814 leency 124
inline fastcall void SetEventMask( EBX)
2568 leency 125
{
126
	EAX = 40;
127
	$int 0x40
128
}
129
 
2814 leency 130
inline fastcall word GetKey(){ //+Gluk fix
2568 leency 131
		$push edx
132
@getkey:
133
		$mov  eax,2
134
		$int  0x40
135
		$cmp eax,1
136
		$jne getkeyi
137
		$mov ah,dh
138
		$jmp getkeyii //jz?
139
@getkeyi:
140
		$mov dh,ah
141
		$jmp getkey
142
@getkeyii:
143
		$pop edx
144
		EAX = EAX >> 8;
145
}
146
 
147
inline fastcall word GetButtonID(){
148
	EAX = 17;            // Get ID
149
	$int  0x40
150
	EAX = EAX >> 8;
151
}
152
 
153
inline fastcall void ExitProcess(){
154
	EAX = -1;            // close this program
155
	$int 0x40
156
}
157
 
2875 leency 158
inline fastcall void Pause( EBX){
2814 leency 159
	$mov eax, 5
2568 leency 160
	$int 0x40
161
}
162
 
163
//------------------------------------------------------------------------------
2875 leency 164
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType, dword mainAreaColour, EDI)
2568 leency 165
{
166
	EAX = 12;              // function 12:tell os about windowdraw
167
	EBX = 1;
168
	$int 0x40
169
 
170
	EBX = x << 16 + sizeX;
171
	ECX = y << 16 + sizeY;
172
	EDX = mainAreaType << 24 | mainAreaColour;
173
	$xor eax,eax
174
	$int 0x40
175
 
176
	EAX = 12;              // function 12:tell os about windowdraw
177
	EBX = 2;
178
	$int 0x40
179
}
180
 
2814 leency 181
inline fastcall void CreateThread( ECX,EDX)
2568 leency 182
{
183
	EAX = 51;
184
	EBX = 1;
185
	$int 0x40
186
}
187
 
2814 leency 188
inline fastcall void DrawTitle( ECX){
2568 leency 189
	EAX = 71;
190
	EBX = 1;
191
	$int 0x40;
192
}
193
 
2875 leency 194
inline fastcall dword GetSkinHeight()
195
{
196
	$push ebx
197
	$mov  eax,48
198
	$mov  ebx,4
2568 leency 199
	$int 0x40
2875 leency 200
	$pop  ebx
2568 leency 201
}
202
 
2661 leency 203
inline fastcall dword GetScreenHeight()
204
{
205
	EAX = 14;
206
	$int 0x40
207
	$and eax,0x0000FFFF
208
}
209
 
2814 leency 210
inline fastcall void MoveSize( EBX,ECX,EDX,ESI){
211
	$mov eax,67;
2568 leency 212
	$int 0x40
213
}
214
 
215
//------------------------------------------------------------------------------
2814 leency 216
inline fastcall void PutPixel( EBX,ECX,EDX)
217
{
2568 leency 218
  EAX=1;
219
  $int 0x40
220
}
221
 
222
void DefineButton(dword x,y,w,h,EDX,ESI)
223
{
224
 	EAX = 8;
225
	$push edx
226
	EDX += BT_DEL; //вначале удаляем кнопу с эти ид, потом создаём
227
	$int 0x40;
228
	EBX = x<<16+w;
229
	ECX = y<<16+h;
230
 	$pop edx
231
	$int 0x40
232
}
233
 
2814 leency 234
inline fastcall void DeleteButton( EDX)
2568 leency 235
{
236
	EAX = 8;
237
	EDX += BT_DEL;
238
	$int 0x40;
239
}
240
 
241
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
242
{
243
	EAX = 4;
244
	EBX = x<<16+y;
245
	ECX = fontType<<24+color;
246
	$int 0x40;
247
}
248
 
249
void DrawBar(dword x,y,w,h,EDX)
250
{
251
	EAX = 13;
252
	EBX = x<<16+w;
253
	ECX = y<<16+h;
254
 	$int 0x40
255
}
256
 
257
void DrawRegion_3D(dword x,y,width,height,color1,color2)
258
{
2814 leency 259
	DrawBar(x,y,width+1,1,color1);
260
	DrawBar(x,y+1,1,height-1,color1);
261
	DrawBar(x+width,y+1,1,height,color2);
262
	DrawBar(x,y+height,width,1,color2);
2568 leency 263
}
264
 
265
void DrawFlatButton(dword x,y,width,height,id,color,text)
266
{
267
	DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
268
	DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
2814 leency 269
	DrawBar(x+2,y+2,width-3,height-3,color);
270
	IF (id<>0)	DefineButton(x+1,y+1,width-2,height-2,id+BT_HIDE,0xEFEBEF);
2568 leency 271
	WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
272
}
273
 
274
void PutPaletteImage(dword EBX,w,h,x,y, EDI)
275
{
276
	EAX = 65;
277
	ECX = w<<16+h;
278
	EDX = x<<16+y;
279
	ESI = 8;
280
	EBP = 0;
281
	$int 0x40
282
}
283
 
284
void PutImage(dword EBX,w,h,x,y)
285
{
286
	EAX = 7;
287
	ECX = w<<16+h;
288
	EDX = x<<16+y;
289
	$int 0x40
290
}
291
 
292
//------------------------------------------------------------------------------
2814 leency 293
inline fastcall void debug( EDX)
2568 leency 294
{
295
	$mov eax, 63
296
	$mov ebx, 1
297
next_char:
298
	$mov ecx, DSDWORD[edx]
299
	$or	 cl, cl
300
	$jz  done
301
	$int 0x40
302
	$inc edx
303
	$jmp next_char
304
done:
305
	$mov cl, 13
306
	$int 0x40
307
	$mov cl, 10
308
	$int 0x40
309
}