Subversion Repositories Kolibri OS

Rev

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