Subversion Repositories Kolibri OS

Rev

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

Rev 2842 Rev 6167
1
//CODED by Veliant, Leency, Nable. GNU GPL licence.
1
//CODED by Veliant, Leency, Nable. 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    = #0x00010000;
10
dword  alloc_mem    = #0x00010000;
11
dword  x86esp_reg   = #0x00010000;
11
dword  x86esp_reg   = #0x00010000;
12
dword  I_Param      = 0;
12
dword  I_Param      = 0;
13
dword  I_Path       = 0;
13
dword  I_Path       = 0;
14
 
14
 
15
//Events
15
//Events
16
#define evButton    3
16
#define evButton    3
17
#define evKey       2
17
#define evKey       2
18
#define evReDraw    1
18
#define evReDraw    1
19
 
19
 
20
//Button options
20
//Button options
21
#define BT_DEL		0x80000000
21
#define BT_DEL		0x80000000
22
#define BT_HIDE		0x40000000
22
#define BT_HIDE		0x40000000
23
#define BT_NOFRAME	0x20000000
23
#define BT_NOFRAME	0x20000000
24
 
24
 
25
//-------------------------------------------------------------------------
25
//-------------------------------------------------------------------------
26
 
26
 
27
 
27
 
28
struct proc_info{
28
struct proc_info{
29
	dword	use_cpu;
29
	dword	use_cpu;
30
	word	pos_in_stack,num_slot,rezerv1;
30
	word	pos_in_stack,num_slot,rezerv1;
31
	char	name[11];
31
	char	name[11];
32
	char	rezerv2;
32
	char	rezerv2;
33
	dword	adress,use_memory,ID,left,top,width,height;
33
	dword	adress,use_memory,ID,left,top,width,height;
34
	word	status_slot,rezerv3;
34
	word	status_slot,rezerv3;
35
	dword	work_left,work_top,work_width,work_height;
35
	dword	work_left,work_top,work_width,work_height;
36
	char	status_window;
36
	char	status_window;
37
	void	GetInfo(dword ECX);
37
	void	GetInfo(dword ECX);
38
	byte    reserved[1024-71];
38
	byte    reserved[1024-71];
39
#define SelfInfo -1
39
#define SelfInfo -1
40
};
40
};
41
 
41
 
42
inline fastcall void GetProcessInfo(dword EBX, ECX)
42
inline fastcall void GetProcessInfo(dword EBX, ECX)
43
{
43
{
44
	EAX = 9;
44
	EAX = 9;
45
	$int  0x40
45
	$int  0x40
46
}
46
}
47
 
47
 
48
struct system_colors{
48
struct system_colors {
-
 
49
dword
-
 
50
	nonset1,
-
 
51
	nonset2,
-
 
52
	work_light,
-
 
53
	work_dark,
-
 
54
	nonset3,
-
 
55
	work,
-
 
56
	work_button,
49
	dword frame,grab,grab_button,grab_button_text,grab_text,work,work_button,work_button_text,work_text,work_graph;
57
	work_button_text,
-
 
58
	work_text,
-
 
59
	work_graph;
50
	void get();
60
	void get();
51
};
61
};
52
 
62
 
53
void system_colors::get()
63
void system_colors::get()
54
{
64
{
55
	$push ecx
65
	$push ecx
56
	EAX = 48;
66
	EAX = 48;
57
	EBX = 3;
67
	EBX = 3;
58
	ECX = #frame;
68
	ECX = #nonset1;
59
	EDX = 40;
69
	EDX = 40;
60
	$int 0x40
70
	$int 0x40
61
	$pop ecx
71
	$pop ecx
62
}
72
}
63
 
73
 
64
//------------------------------------------------------------------------------
74
//------------------------------------------------------------------------------
65
 
75
 
66
inline fastcall dword WaitEvent(){
76
inline fastcall dword WaitEvent(){
67
 EAX = 10;
77
 EAX = 10;
68
 $int 0x40
78
 $int 0x40
69
}
79
}
-
 
80
 
70
 
81
int GetKeyScancode()
71
 
82
{
72
inline fastcall word GetKey(){
-
 
73
 EAX = 2;              // just read it key from buffer
83
	$mov  eax,2
-
 
84
	$int  0x40
74
 $int  0x40
85
	$shr  eax,16
75
 EAX = EAX >> 8;	 
86
	return AL;
76
}
87
}
77
 
88
 
78
inline fastcall word GetButtonID(){
89
inline fastcall word GetButtonID(){
79
 EAX = 17;
90
 EAX = 17;
80
 $int  0x40
91
 $int  0x40
81
 EAX = EAX >> 8;
92
 EAX = EAX >> 8;
82
}
93
}
83
 
94
 
84
inline fastcall ExitProcess(){
95
inline fastcall ExitProcess(){
85
 EAX = -1;              // close this program
96
 EAX = -1;              // close this program
86
 $int 0x40
97
 $int 0x40
87
}
98
}
88
 
99
 
89
inline fastcall Pause(dword EBX)
100
inline fastcall Pause(dword EBX)
90
{					//EBX = value in milisec
101
{					//EBX = value in milisec
91
	$mov eax, 5
102
	$mov eax, 5
92
	$int 0x40
103
	$int 0x40
93
}
104
}
94
 
105
 
95
//------------------------------------------------------------------------------
106
//------------------------------------------------------------------------------
96
 
107
 
97
char buffer[11];
108
char buffer[11];
98
inline fastcall dword IntToStr(dword ESI)
109
inline fastcall dword IntToStr(dword ESI)
99
{
110
{
100
     $mov     edi, #buffer
111
     $mov     edi, #buffer
101
     $mov     ecx, 10
112
     $mov     ecx, 10
102
     $test     esi, esi
113
     $test     esi, esi
103
     $jns     f1
114
     $jns     f1
104
     $mov     al, '-'
115
     $mov     al, '-'
105
     $stosb
116
     $stosb
106
     $neg     esi
117
     $neg     esi
107
f1:
118
f1:
108
     $mov     eax, esi
119
     $mov     eax, esi
109
     $push     -'0'
120
     $push     -'0'
110
f2:
121
f2:
111
     $xor     edx, edx
122
     $xor     edx, edx
112
     $div     ecx
123
     $div     ecx
113
     $push     edx
124
     $push     edx
114
     $test     eax, eax
125
     $test     eax, eax
115
     $jnz     f2
126
     $jnz     f2
116
f3:
127
f3:
117
     $pop     eax
128
     $pop     eax
118
     $add     al, '0'
129
     $add     al, '0'
119
     $stosb
130
     $stosb
120
     $jnz     f3
131
     $jnz     f3
121
     $mov     eax, #buffer
132
     $mov     eax, #buffer
122
     $ret
133
     $ret
123
} 
134
} 
124
 
135
 
125
inline fastcall copystr(dword ESI,EDI)
136
inline fastcall copystr(dword ESI,EDI)
126
{
137
{
127
	$cld
138
	$cld
128
l1:
139
l1:
129
	$lodsb
140
	$lodsb
130
	$stosb
141
	$stosb
131
	$test al,al
142
	$test al,al
132
	$jnz l1
143
	$jnz l1
133
}
144
}
134
 
145
 
135
inline fastcall dword strlen(dword EDI){
146
inline fastcall dword strlen(dword EDI){
136
	EAX=0;
147
	EAX=0;
137
	ECX=-1;
148
	ECX=-1;
138
	$REPNE $SCASB
149
	$REPNE $SCASB
139
	EAX-=2+ECX;
150
	EAX-=2+ECX;
140
}
151
}
141
//------------------------------------------------------------------------------
152
//------------------------------------------------------------------------------
142
 
153
 
143
 
154
 
144
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI)
155
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI)
145
{
156
{
146
	EAX = 12;              // function 12:tell os about windowdraw
157
	EAX = 12;              // function 12:tell os about windowdraw
147
	EBX = 1;
158
	EBX = 1;
148
	$int 0x40
159
	$int 0x40
149
	
160
	
150
	EBX = x << 16 + sizeX;
161
	EBX = x << 16 + sizeX;
151
	ECX = y << 16 + sizeY;
162
	ECX = y << 16 + sizeY;
152
	EDX = mainAreaType << 24 | mainAreaColour;
163
	EDX = mainAreaType << 24 | mainAreaColour;
153
	ESI = headerType << 24 | headerColour;
164
	ESI = headerType << 24 | headerColour;
154
	$xor eax,eax
165
	$xor eax,eax
155
	$int 0x40
166
	$int 0x40
156
 
167
 
157
	EAX = 12;              // function 12:tell os about windowdraw
168
	EAX = 12;              // function 12:tell os about windowdraw
158
	EBX = 2;
169
	EBX = 2;
159
	$int 0x40
170
	$int 0x40
160
}
171
}
161
 
172
 
162
inline fastcall MoveSize(int EBX,ECX,EDX,ESI)
173
inline fastcall MoveSize(int EBX,ECX,EDX,ESI)
163
{
174
{
164
	EAX = 67;
175
	EAX = 67;
165
	$int 0x40
176
	$int 0x40
166
}
177
}
167
 
178
 
168
 
179
 
169
inline fastcall dword GetSkinWidth()
180
inline fastcall dword GetSkinWidth()
170
{
181
{
171
	$push ebx
182
	$push ebx
172
	$mov  eax, 48
183
	$mov  eax, 48
173
	$mov  ebx, 4
184
	$mov  ebx, 4
174
	$int  0x40
185
	$int  0x40
175
	$pop  ebx
186
	$pop  ebx
176
}
187
}
177
 
188
 
178
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
189
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
179
{
190
{
180
	EAX = 4;
191
	EAX = 4;
181
	EBX = x<<16+y;
192
	EBX = x<<16+y;
182
	ECX = fontType<<24+color;
193
	ECX = fontType<<24+color;
183
	$int 0x40;
194
	$int 0x40;
184
}
195
}
185
 
196
 
186
void DrawBar(dword x,y,w,h,EDX)
197
void DrawBar(dword x,y,w,h,EDX)
187
{
198
{
188
	EAX = 13;
199
	EAX = 13;
189
	EBX = x<<16+w;
200
	EBX = x<<16+w;
190
	ECX = y<<16+h;
201
	ECX = y<<16+h;
191
 	$int 0x40
202
 	$int 0x40
192
}
203
}
193
 
204
 
194
void DefineButton(dword x,y,w,h,EDX,ESI)
205
void DefineButton(dword x,y,w,h,EDX,ESI)
195
{
206
{
196
 	EAX = 8;
207
 	EAX = 8;
197
	EBX = x<<16+w;
208
	EBX = x<<16+w;
198
	ECX = y<<16+h;
209
	ECX = y<<16+h;
199
 	$int 0x40
210
 	$int 0x40
200
}
211
}
201
 
212
 
202
inline fastcall void DeleteButton(dword EDX)
213
inline fastcall void DeleteButton(dword EDX)
203
{
214
{
204
	EAX = 8;
215
	EAX = 8;
205
	EDX += BT_DEL;
216
	EDX += BT_DEL;
206
	$int 0x40;
217
	$int 0x40;
207
}
218
}
208
 
219
 
209
 
220
 
210
void DrawRegion_3D(dword x,y,width,height,color1,color2)
221
void DrawRegion_3D(dword x,y,width,height,color1,color2)
211
{
222
{
212
	DrawBar(x,y,width+1,1,color1);
223
	DrawBar(x,y,width+1,1,color1);
213
	DrawBar(x,y+1,1,height-1,color1);
224
	DrawBar(x,y+1,1,height-1,color1);
214
	DrawBar(x+width,y+1,1,height,color2);
225
	DrawBar(x+width,y+1,1,height,color2);
215
	DrawBar(x,y+height,width,1,color2);
226
	DrawBar(x,y+height,width,1,color2);
216
}
227
}
217
 
228
 
218
void PutImage(dword EBX,w,h,x,y)
229
void PutImage(dword EBX,w,h,x,y)
219
{
230
{
220
	EAX = 7;
231
	EAX = 7;
221
	ECX = w<<16+h;
232
	ECX = w<<16+h;
222
	EDX = x<<16+y;
233
	EDX = x<<16+y;
223
	$int 0x40
234
	$int 0x40
224
}
235
}
225
 
236
 
226
inline fastcall dword debug(dword EDX)
237
inline fastcall dword debug(dword EDX)
227
{
238
{
228
	$push ebx
239
	$push ebx
229
	$push ecx
240
	$push ecx
230
	$mov eax, 63
241
	$mov eax, 63
231
	$mov ebx, 1
242
	$mov ebx, 1
232
next_char:
243
next_char:
233
	$mov ecx, DSDWORD[edx]
244
	$mov ecx, DSDWORD[edx]
234
	$or	 cl, cl
245
	$or	 cl, cl
235
	$jz  done
246
	$jz  done
236
	$int 0x40
247
	$int 0x40
237
	$inc edx
248
	$inc edx
238
	$jmp next_char
249
	$jmp next_char
239
done:
250
done:
240
	$mov cl, 13
251
	$mov cl, 13
241
	$int 0x40
252
	$int 0x40
242
	$mov cl, 10
253
	$mov cl, 10
243
	$int 0x40
254
	$int 0x40
244
	$pop ecx
255
	$pop ecx
245
	$pop ebx
256
	$pop ebx
246
}
257
}
247
>
258
 
-
 
259
void DrawCaptButton(dword x,y,w,h,id,color_b, color_t,text)
-
 
260
{
-
 
261
	if (id>0) DefineButton(x,y,w,h,id,color_b);
-
 
262
	WriteText(-strlen(text)*6+w/2+x+1,h/2-3+y,0x80,color_t,text);
-
 
263
}
-
 
264
>
-
 
265
>
-
 
266
>
248
>
267
>
249
>
268
>
250
>
269
>
251
>
270
>
252
>
271
>
253
>
272
>
254
>
273
>
255
>
274
>
256
>
275
>
257
>
276
>
258
>
277
>
259
>
278
>
260
>
279
>
261
>
-
 
262
>
-