Subversion Repositories Kolibri OS

Rev

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

Rev 7089 Rev 7160
1
//CODED by Veliant, Leency, Nable, Pavelyakov. GNU GPL licence.
1
//CODED by Veliant, Leency, Nable, Pavelyakov. GNU GPL licence.
2
 
2
 
3
#ifndef INCLUDE_KOLIBRI_H
3
#ifndef INCLUDE_KOLIBRI_H
4
#define INCLUDE_KOLIBRI_H
4
#define INCLUDE_KOLIBRI_H
5
 
5
 
6
#pragma option OST
6
#pragma option OST
7
#pragma option ON
7
#pragma option ON
8
#pragma option cri-
8
#pragma option cri-
9
#pragma option -CPA
9
#pragma option -CPA
10
#initallvar 0
10
#initallvar 0
11
#jumptomain FALSE
11
#jumptomain FALSE
12
 
12
 
13
#startaddress 0
13
#startaddress 0
14
 
14
 
15
#code32 TRUE
15
#code32 TRUE
16
 
16
 
17
char   os_name[8]   = {'M','E','N','U','E','T','0','1'};
17
char   os_name[8]   = {'M','E','N','U','E','T','0','1'};
18
dword  os_version   = 0x00000001;
18
dword  os_version   = 0x00000001;
19
dword  start_addr   = #______INIT______;
19
dword  start_addr   = #______INIT______;
20
dword  final_addr   = #______STOP______+32;
20
dword  final_addr   = #______STOP______+32;
21
dword  alloc_mem    = MEMSIZE;
21
dword  alloc_mem    = MEMSIZE;
22
dword  x86esp_reg   = MEMSIZE;
22
dword  x86esp_reg   = MEMSIZE;
23
dword  I_Param      = #param;
23
dword  I_Param      = #param;
24
dword  I_Path       = #program_path;
24
dword  I_Path       = #program_path;
25
char param[4096];
25
char param[4096];
26
char program_path[4096];
26
char program_path[4096];
27
 
27
 
28
#define bool      int
28
#define bool      int
29
 
29
 
30
#define NULL      0
30
#define NULL      0
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
//Process Events
35
//Process Events
36
#define evReDraw  1
36
#define evReDraw  1
37
#define evKey     2
37
#define evKey     2
38
#define evButton  3
38
#define evButton  3
39
#define evExit    4
39
#define evExit    4
40
#define evDesktop 5
40
#define evDesktop 5
41
#define evMouse   6
41
#define evMouse   6
42
#define evIPC     7
42
#define evIPC     7
43
#define evNetwork 8
43
#define evNetwork 8
44
#define evDebug   9
44
#define evDebug   9
45
 
45
 
46
//Event mask bits for function 40
46
//Event mask bits for function 40
47
#define EVM_REDRAW                1b
47
#define EVM_REDRAW                1b
48
#define EVM_KEY                  10b
48
#define EVM_KEY                  10b
49
#define EVM_BUTTON              100b
49
#define EVM_BUTTON              100b
50
#define EVM_EXIT               1000b
50
#define EVM_EXIT               1000b
51
#define EVM_BACKGROUND        10000b
51
#define EVM_BACKGROUND        10000b
52
#define EVM_MOUSE            100000b
52
#define EVM_MOUSE            100000b
53
#define EVM_IPC             1000000b
53
#define EVM_IPC             1000000b
54
#define EVM_STACK          10000000b
54
#define EVM_STACK          10000000b
55
#define EVM_DEBUG         100000000b
55
#define EVM_DEBUG         100000000b
56
#define EVM_STACK2       1000000000b
56
#define EVM_STACK2       1000000000b
57
#define EVM_MOUSE_FILTER  0x80000000
57
#define EVM_MOUSE_FILTER  0x80000000
58
#define EVM_CURSOR_FILTER 0x40000000
58
#define EVM_CURSOR_FILTER 0x40000000
59
 
59
 
60
//Button options
60
//Button options
61
#define BT_DEL      0x80000000
61
#define BT_DEL      0x80000000
62
#define BT_HIDE     0x40000000
62
#define BT_HIDE     0x40000000
63
#define BT_NOFRAME  0x20000000
63
#define BT_NOFRAME  0x20000000
64
 
64
 
65
#define CLOSE_BTN 1
65
#define CLOSE_BTN 1
66
 
66
 
67
//-------------------------------------------------------------------------
67
//-------------------------------------------------------------------------
68
 
68
 
69
#include "../lib/system.h"
69
#include "../lib/system.h"
70
#include "../lib/mouse.h"
70
#include "../lib/mouse.h"
71
#include "../lib/keyboard.h"
71
#include "../lib/keyboard.h"
72
 
72
 
73
inline fastcall dword calc(EAX) { return EAX; }
73
inline fastcall dword calc(EAX) { return EAX; }
74
 
74
 
75
:struct raw_image {
75
:struct raw_image {
76
	dword w, h, data;
76
	dword w, h, data;
77
};
77
};
78
 
78
 
79
//------------------------------------------------------------------------------
79
//------------------------------------------------------------------------------
80
:dword wait_event_code;
80
:dword wait_event_code;
81
inline fastcall dword WaitEvent()
81
inline fastcall dword WaitEvent()
82
{
82
{
83
	$mov eax,10
83
	$mov eax,10
84
	$int 0x40
84
	$int 0x40
85
	wait_event_code = EAX;
85
	wait_event_code = EAX;
86
	//if(wait_event_code==evMouse) MOUSE.get();
86
	//if(wait_event_code==evMouse) MOUSE.get();
87
	//return wait_event_code;
87
	//return wait_event_code;
88
}
88
}
89
 
89
 
90
inline fastcall dword CheckEvent()
90
inline fastcall dword CheckEvent()
91
{
91
{
92
	$mov eax,11
92
	$mov eax,11
93
	$int 0x40
93
	$int 0x40
94
}
94
}
95
 
95
 
96
inline fastcall dword WaitEventTimeout(EBX)
96
inline fastcall dword WaitEventTimeout(EBX)
97
{
97
{
98
	$mov eax,23
98
	$mov eax,23
99
	$int 0x40
99
	$int 0x40
100
} 
100
} 
101
 
101
 
102
inline fastcall dword SetEventMask(EBX)
102
inline fastcall dword SetEventMask(EBX)
103
{
103
{
104
	$mov eax,40
104
	$mov eax,40
105
	$int 0x40
105
	$int 0x40
106
}
106
}
107
 
107
 
108
 
108
 
109
inline fastcall pause(EBX)
109
inline fastcall pause(EBX)
110
{
110
{
111
	$mov eax, 5
111
	$mov eax, 5
112
	$int 0x40
112
	$int 0x40
113
}
113
}
114
 
114
 
115
inline fastcall word GetButtonID()
115
inline fastcall word GetButtonID()
116
{
116
{
117
	$mov eax,17
117
	$mov eax,17
118
	$int  0x40
118
	$int  0x40
119
	$shr eax,8
119
	$shr eax,8
120
}
120
}
121
 
121
 
122
inline fastcall dword GetFreeRAM()
122
inline fastcall dword GetFreeRAM()
123
{
123
{
124
	$mov eax, 18
124
	$mov eax, 18
125
	$mov ebx, 16
125
	$mov ebx, 16
126
	$int 0x40
126
	$int 0x40
127
	//return eax = free RAM in Kb
127
	//return eax = free RAM in Kb
128
}
128
}
129
 
129
 
130
inline fastcall dword LoadDriver(ECX) //ECX - èìÿ äðàéâåðà
130
inline fastcall dword LoadDriver(ECX) //ECX - èìÿ äðàéâåðà
131
{
131
{
132
	$mov eax, 68
132
	$mov eax, 68
133
	$mov ebx, 16
133
	$mov ebx, 16
134
	$int 0x40
134
	$int 0x40
135
	//return 0 - íåóäà÷à, èíà÷å eax = õýíäë äðàéâåðà 
135
	//return 0 - íåóäà÷à, èíà÷å eax = õýíäë äðàéâåðà 
136
}
136
}
137
 
137
 
138
inline fastcall dword RuleDriver(ECX) //óêàçàòåëü íà óïðàâëÿþùóþ ñòðóêòóðó
138
inline fastcall dword RuleDriver(ECX) //óêàçàòåëü íà óïðàâëÿþùóþ ñòðóêòóðó
139
{
139
{
140
	$mov eax, 68
140
	$mov eax, 68
141
	$mov ebx, 17
141
	$mov ebx, 17
142
	$int 0x40
142
	$int 0x40
143
	//return eax = îïðåäåëÿåòñÿ äðàéâåðîì
143
	//return eax = îïðåäåëÿåòñÿ äðàéâåðîì
144
}
144
}
145
 
145
 
146
struct proc_info
146
struct proc_info
147
{
147
{
148
	#define SelfInfo -1
148
	#define SelfInfo -1
149
	dword	use_cpu;
149
	dword	use_cpu;
150
	word	pos_in_stack,num_slot,rezerv1;
150
	word	pos_in_stack,num_slot,rezerv1;
151
	unsigned char name[11];
151
	unsigned char name[11];
152
	char	rezerv2;
152
	char	rezerv2;
153
	dword	adress,use_memory,ID,left,top,width,height;
153
	dword	adress,use_memory,ID,left,top,width,height;
154
	word	status_slot,rezerv3;
154
	word	status_slot,rezerv3;
155
	dword	work_left,work_top,work_width,work_height;
155
	dword	work_left,work_top,work_width,work_height;
156
	char	status_window;
156
	char	status_window;
157
	dword   cwidth,cheight;
157
	dword   cwidth,cheight;
158
	byte    reserved[1024-71-8];
158
	byte    reserved[1024-71-8];
159
};
159
};
160
 
160
 
161
inline fastcall void GetProcessInfo(EBX, ECX)
161
inline fastcall void GetProcessInfo(EBX, ECX)
162
{
162
{
163
	$mov eax,9;
163
	$mov eax,9;
164
	$int  0x40
164
	$int  0x40
165
	DSDWORD[EBX+71] = DSDWORD[EBX+42] - 9; //set cwidth
165
	DSDWORD[EBX+71] = DSDWORD[EBX+42] - 9; //set cwidth
166
	DSDWORD[EBX+75] = DSDWORD[EBX+46] - skin_height - 4; //set cheight
166
	DSDWORD[EBX+75] = DSDWORD[EBX+46] - skin_height - 4; //set cheight
167
}
167
}
168
 
168
 
169
inline fastcall int GetPointOwner( EBX, ECX) //ebx=m.x, ecx=m.y
169
inline fastcall int GetPointOwner( EBX, ECX) //ebx=m.x, ecx=m.y
170
{
170
{
171
	$mov eax,34
171
	$mov eax,34
172
	$int 0x40
172
	$int 0x40
173
}
173
}
174
 
174
 
175
inline fastcall int GetProcessSlot( ECX)
175
inline fastcall int GetProcessSlot( ECX)
176
{
176
{
177
	EAX = 18;
177
	EAX = 18;
178
	EBX = 21;
178
	EBX = 21;
179
	$int 0x40
179
	$int 0x40
180
}
180
}
181
 
181
 
182
inline fastcall int GetActiveProcess()
182
inline fastcall int GetActiveProcess()
183
{
183
{
184
	EAX = 18;
184
	EAX = 18;
185
	EBX = 7;
185
	EBX = 7;
186
	$int 0x40
186
	$int 0x40
187
}
187
}
188
 
188
 
189
:int CheckActiveProcess(int Form_ID)
189
:int CheckActiveProcess(int Form_ID)
190
{
190
{
191
	int id9=GetProcessSlot(Form_ID);
191
	int id9=GetProcessSlot(Form_ID);
192
	if (id9==GetActiveProcess()) return 1;
192
	if (id9==GetActiveProcess()) return 1;
193
	return 0;
193
	return 0;
194
}
194
}
195
 
195
 
196
inline fastcall void ActivateWindow( ECX)
196
inline fastcall void ActivateWindow( ECX)
197
{
197
{
198
	EAX = 18;
198
	EAX = 18;
199
	EBX = 3;
199
	EBX = 3;
200
	$int 0x40
200
	$int 0x40
201
}
201
}
202
 
202
 
203
inline fastcall int MinimizeWindow()
203
inline fastcall int MinimizeWindow()
204
{
204
{
205
	EAX = 18;
205
	EAX = 18;
206
	EBX = 10;
206
	EBX = 10;
207
	$int 0x40
207
	$int 0x40
208
}
208
}
209
 
209
 
210
inline fastcall int CreateThread(ECX,EDX)
210
inline fastcall int CreateThread(ECX,EDX)
211
{
211
{
212
	$mov eax,51
212
	$mov eax,51
213
	$mov ebx,1
213
	$mov ebx,1
214
	$int 0x40
214
	$int 0x40
215
}
215
}
216
 
216
 
217
inline fastcall void SwitchToAnotherThread()
217
inline fastcall void SwitchToAnotherThread()
218
{
218
{
219
	$mov eax,68
219
	$mov eax,68
220
	$mov ebx,1
220
	$mov ebx,1
221
	$int 0x40
221
	$int 0x40
222
}
222
}
223
 
223
 
224
inline fastcall int SendWindowMessage( ECX, EDX)
224
inline fastcall int SendWindowMessage( ECX, EDX)
225
{
225
{
226
	$mov eax, 72
226
	$mov eax, 72
227
	$mov ebx, 1
227
	$mov ebx, 1
228
	$int 0x40
228
	$int 0x40
229
}
229
}
230
 
230
 
231
inline fastcall int KillProcess( ECX)
231
inline fastcall int KillProcess( ECX)
232
{
232
{
233
	$mov eax,18;
233
	$mov eax,18;
234
	$mov ebx,18;
234
	$mov ebx,18;
235
	$int 0x40
235
	$int 0x40
236
}
236
}
237
 
237
 
238
#define TURN_OFF 2
238
#define TURN_OFF 2
239
#define REBOOT 3
239
#define REBOOT 3
240
#define KERNEL 4
240
#define KERNEL 4
241
inline fastcall int ExitSystem( ECX)
241
inline fastcall int ExitSystem( ECX)
242
{
242
{
243
	$mov eax, 18
243
	$mov eax, 18
244
	$mov ebx, 9
244
	$mov ebx, 9
245
	$int 0x40
245
	$int 0x40
246
}
246
}
247
 
247
 
248
inline fastcall ExitProcess()
248
inline fastcall ExitProcess()
249
{
249
{
250
	$mov eax,-1;
250
	$mov eax,-1;
251
	$int 0x40
251
	$int 0x40
252
}
252
}
253
 
253
 
254
//------------------------------------------------------------------------------
254
//------------------------------------------------------------------------------
255
 
255
 
256
inline fastcall void SetCurDir( ECX)
256
inline fastcall void SetCurDir( ECX)
257
{
257
{
258
  EAX=30;
258
  EAX=30;
259
  EBX=1;
259
  EBX=1;
260
  $int 0x40
260
  $int 0x40
261
}
261
}
262
 
262
 
263
 
263
 
264
//eax = ÿçûê ñèñòåìû (1=eng, 2=fi, 3=ger, 4=rus)
264
//eax = ÿçûê ñèñòåìû (1=eng, 2=fi, 3=ger, 4=rus)
265
#define SYS_LANG_ENG 1
265
#define SYS_LANG_ENG 1
266
#define SYS_LANG_FIN 2
266
#define SYS_LANG_FIN 2
267
#define SYS_LANG_GER 3
267
#define SYS_LANG_GER 3
268
#define SYS_LANG_RUS 4
268
#define SYS_LANG_RUS 4
269
inline fastcall int GetSystemLanguage()
269
inline fastcall int GetSystemLanguage()
270
{
270
{
271
	EAX = 26;
271
	EAX = 26;
272
	EBX = 5;
272
	EBX = 5;
273
	$int 0x40
273
	$int 0x40
274
}
274
}
275
 
275
 
276
inline fastcall GetSkinHeight()
276
inline fastcall GetSkinHeight()
277
{
277
{
278
	$push ebx
278
	$push ebx
279
	$mov  eax,48
279
	$mov  eax,48
280
	$mov  ebx,4
280
	$mov  ebx,4
281
	$int 0x40
281
	$int 0x40
282
	$pop  ebx
282
	$pop  ebx
283
}
283
}
284
 
284
 
285
inline fastcall void SetSystemSkin( ECX)
285
inline fastcall void SetSystemSkin( ECX)
286
{
286
{
287
	EAX = 48;
287
	EAX = 48;
288
	EBX = 8;
288
	EBX = 8;
289
	$int 0x40
289
	$int 0x40
290
}
290
}
291
 
291
 
292
inline fastcall int GetScreenWidth()
292
inline fastcall int GetScreenWidth()
293
{
293
{
294
	$mov eax, 14
294
	$mov eax, 14
295
	$int 0x40
295
	$int 0x40
296
	$shr eax, 16
296
	$shr eax, 16
297
}
297
}
298
 
298
 
299
inline fastcall int GetScreenHeight()
299
inline fastcall int GetScreenHeight()
300
{
300
{
301
	$mov eax, 14
301
	$mov eax, 14
302
	$int 0x40
302
	$int 0x40
303
	$and eax,0x0000FFFF
303
	$and eax,0x0000FFFF
304
}
304
}
305
 
305
 
306
inline fastcall int GetClientTop()
306
inline fastcall int GetClientTop()
307
{
307
{
308
	$mov eax, 48
308
	$mov eax, 48
309
	$mov ebx, 5
309
	$mov ebx, 5
310
	$int 0x40
310
	$int 0x40
311
	$mov eax, ebx
311
	$mov eax, ebx
312
	$shr eax, 16
312
	$shr eax, 16
313
}
313
}
314
 
314
 
315
inline fastcall int GetClientHeight()
315
inline fastcall int GetClientHeight()
316
{
316
{
317
	$mov eax, 48
317
	$mov eax, 48
318
	$mov ebx, 5
318
	$mov ebx, 5
319
	$int 0x40
319
	$int 0x40
320
	$mov eax, ebx
320
	$mov eax, ebx
321
}
321
}
322
 
322
 
323
inline fastcall dword LoadLibrary( ECX)
323
inline fastcall dword LoadLibrary( ECX)
324
{
324
{
325
	$mov eax, 68 
325
	$mov eax, 68 
326
	$mov ebx, 19
326
	$mov ebx, 19
327
	$int  0x40
327
	$int  0x40
328
}
328
}
329
 
329
 
330
inline fastcall int TestBit( EAX, CL)
330
inline fastcall int TestBit( EAX, CL)
331
{
331
{
332
	$shr eax,cl
332
	$shr eax,cl
333
	$and eax,1
333
	$and eax,1
334
}
334
}
335
 
335
 
336
//------------------------------------------------------------------------------
336
//------------------------------------------------------------------------------
337
 
337
 
338
:void DefineAndDrawWindow(dword _x, _y, _w, _h, _window_type, _bgcolor, _title, _flags)
338
:void DefineAndDrawWindow(dword _x, _y, _w, _h, _window_type, _bgcolor, _title, _flags)
339
{
339
{
340
	EAX = 12;              // function 12:tell os about windowdraw
340
	EAX = 12;              // function 12:tell os about windowdraw
341
	EBX = 1;
341
	EBX = 1;
342
	$int 0x40
342
	$int 0x40
343
	
343
	
344
	$xor EAX,EAX
344
	$xor EAX,EAX
345
	EBX = _x << 16 + _w; 
345
	EBX = _x << 16 + _w; 
346
	ECX = _y << 16 + _h;
346
	ECX = _y << 16 + _h;
347
	EDX = _window_type << 24 | _bgcolor;
347
	EDX = _window_type << 24 | _bgcolor;
348
	EDI = _title;
348
	EDI = _title;
349
	ESI = _flags;
349
	ESI = _flags;
350
	$int 0x40
350
	$int 0x40
351
 
351
 
352
 
352
 
353
	EAX = 12;              // function 12:tell os about windowdraw
353
	EAX = 12;              // function 12:tell os about windowdraw
354
	EBX = 2;
354
	EBX = 2;
355
	$int 0x40
355
	$int 0x40
356
}
356
}
357
 
357
 
358
inline fastcall MoveSize( EBX,ECX,EDX,ESI)
358
inline fastcall MoveSize( EBX,ECX,EDX,ESI)
359
{
359
{
360
	$mov eax, 67
360
	$mov eax, 67
361
	$int 0x40
361
	$int 0x40
362
}
362
}
363
 
363
 
364
inline fastcall void DrawTitle( ECX)
364
inline fastcall void DrawTitle( ECX)
365
{
365
{
366
	EAX = 71;
366
	EAX = 71;
367
	EBX = 1;
367
	EBX = 1;
368
	$int 0x40;
368
	$int 0x40;
369
}
369
}
370
 
370
 
371
// @EDX is a process id, -1 for self
371
// @EDX is a process id, -1 for self
372
// @ESI is a new LayerBehaviour
372
// @ESI is a new LayerBehaviour
373
// @RETURN: EAX, 0 is fail, 1 is success
373
// @RETURN: EAX, 0 is fail, 1 is success
374
#define ZPOS_DESKTOP     -2
374
#define ZPOS_DESKTOP     -2
375
#define ZPOS_ALWAYS_BACK -1
375
#define ZPOS_ALWAYS_BACK -1
376
#define ZPOS_NORMAL      0
376
#define ZPOS_NORMAL      0
377
#define ZPOS_ALWAYS_TOP  1
377
#define ZPOS_ALWAYS_TOP  1
378
inline fastcall dword SetWindowLayerBehaviour(EDX, ESI)
378
inline fastcall dword SetWindowLayerBehaviour(EDX, ESI)
379
{
379
{
380
	EAX = 18;
380
	EAX = 18;
381
	EBX = 25;
381
	EBX = 25;
382
	ECX = 2;
382
	ECX = 2;
383
	$int 64
383
	$int 64
384
}
384
}
385
 
385
 
386
:void WriteTextB(dword x,y,byte fontType, dword color, str_offset)
386
:void WriteTextB(dword x,y,byte fontType, dword color, str_offset)
387
{
387
{
388
	EAX = 4;
388
	EAX = 4;
389
	EBX = x<<16+y;
389
	EBX = x<<16+y;
390
	ECX = fontType<<24+color;
390
	ECX = fontType<<24+color;
391
	EDX = str_offset;
391
	EDX = str_offset;
392
	ESI = 0;
392
	ESI = 0;
393
	$int 0x40;
393
	$int 0x40;
394
	$add ebx, 1<<16
394
	$add ebx, 1<<16
395
	$int 0x40
395
	$int 0x40
396
}
396
}
397
 
397
 
398
:void WriteText(dword x,y,byte fontType, dword color, str_offset)
398
:void WriteText(dword x,y,byte fontType, dword color, str_offset)
399
{
399
{
400
	EAX = 4;
400
	EAX = 4;
401
	EBX = x<<16+y;
401
	EBX = x<<16+y;
402
	ECX = fontType<<24+color;
402
	ECX = fontType<<24+color;
403
	EDX = str_offset;
403
	EDX = str_offset;
404
	$int 0x40;
404
	$int 0x40;
405
}
405
}
406
 
406
 
407
:dword WriteBufText(dword x,y,byte fontType, dword color, str_offset, buf_offset)
407
:dword WriteBufText(dword x,y,byte fontType, dword color, str_offset, buf_offset)
408
{
408
{
409
	EAX = 4;
409
	EAX = 4;
410
	EBX = x<<16+y;
410
	EBX = x<<16+y;
411
	ECX = fontType<<24+color;
411
	ECX = fontType<<24+color;
412
	EDX = str_offset;
412
	EDX = str_offset;
413
	EDI = buf_offset;
413
	EDI = buf_offset;
414
	$int 0x40;
414
	$int 0x40;
415
}
415
}
416
 
416
 
417
:void WriteNumber(dword x,y,byte fontType, dword color, count, number_or_offset)
417
:void WriteNumber(dword x,y,byte fontType, dword color, count, number_or_offset)
418
{
418
{
419
	EAX = 47;
419
	EAX = 47;
420
	EBX = count<<16;
420
	EBX = count<<16;
421
	ECX = number_or_offset;
421
	ECX = number_or_offset;
422
	EDX = x<<16+y;
422
	EDX = x<<16+y;
423
	ESI = fontType<<24+color;
423
	ESI = fontType<<24+color;
424
	$int 0x40;
424
	$int 0x40;
425
}
425
}
426
 
426
 
427
:void CopyScreen(dword dst_offset, x, y, w, h)
427
:void CopyScreen(dword dst_offset, x, y, w, h)
428
{
428
{
429
  EAX = 36;
429
  EAX = 36;
430
  EBX = dst_offset;
430
  EBX = dst_offset;
431
  ECX = w << 16 + h;
431
  ECX = w << 16 + h;
432
  EDX = x << 16 + y;
432
  EDX = x << 16 + y;
433
  $int  0x40;
433
  $int  0x40;
434
}
434
}
435
 
435
 
436
:dword GetPixelColorFromScreen(dword _x, _y)
436
:dword GetPixelColorFromScreen(dword _x, _y)
437
{
437
{
438
	EAX = 35;
438
	EAX = 35;
439
	EBX = _y * screen.width + _x;
439
	EBX = _y * screen.width + _x;
440
	$int 64
440
	$int 64
441
}
441
}
442
 
442
 
443
#define DRAW_DESKTOP_BG_TILE 1
443
#define DRAW_DESKTOP_BG_TILE 1
444
#define DRAW_DESKTOP_BG_STRETCH 2
444
#define DRAW_DESKTOP_BG_STRETCH 2
445
void SetBackgroundImage(dword w,h, image, mode)
445
:void SetBackgroundImage(dword w,h, image, mode)
446
{
446
{
447
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
447
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
448
	$mov     ebx,4       // SSF_MODE_BG 4 - set drawing mode for the background
448
	$mov     ebx,4       // SSF_MODE_BG 4 - set drawing mode for the background
449
	$mov     ecx,mode    // drawing mode - tile (1), stretch (2)
449
	$mov     ecx,mode    // drawing mode - tile (1), stretch (2)
450
	$int     64
450
	$int     64
451
 
451
 
452
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
452
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
453
	$mov     ebx,1       // SSF_SIZE_BG=1 - set a size of the background image
453
	$mov     ebx,1       // SSF_SIZE_BG=1 - set a size of the background image
454
	$mov     ecx,w       // width
454
	$mov     ecx,w       // width
455
	$mov     edx,h       // height
455
	$mov     edx,h       // height
456
	$int     64
456
	$int     64
457
 
457
 
458
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
458
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
459
	$mov     ebx,5       // SSF_IMAGE_BG=5 - put block of pixels on the background image
459
	$mov     ebx,5       // SSF_IMAGE_BG=5 - put block of pixels on the background image
460
	$mov     ecx,image   // pointer to the data in the format BBGGRRBBGGRR...
460
	$mov     ecx,image   // pointer to the data in the format BBGGRRBBGGRR...
461
	$mov     edx,0       // offset in data of the background image
461
	$mov     edx,0       // offset in data of the background image
462
	ESI      = 3*w*h;    // size of data in bytes = 3 * number of pixels
462
	ESI      = 3*w*h;    // size of data in bytes = 3 * number of pixels
463
	$int     64
463
	$int     64
464
 
464
 
465
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
465
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
466
	$mov     ebx,3       // SSF_REDRAW_BG=3 - redraw background
466
	$mov     ebx,3       // SSF_REDRAW_BG=3 - redraw background
467
	$int     64
467
	$int     64
468
}
468
}
469
 
469
 
470
:void _PutImage(dword x,y, w,h, data_offset)
470
:void _PutImage(dword x,y, w,h, data_offset)
471
{
471
{
472
	EAX = 7;
472
	EAX = 7;
473
	EBX = data_offset;
473
	EBX = data_offset;
474
	ECX = w<<16+h;
474
	ECX = w<<16+h;
475
	EDX = x<<16+y;
475
	EDX = x<<16+y;
476
	$int 0x40
476
	$int 0x40
477
}
477
}
478
 
478
 
479
void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
479
void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
480
{
480
{
481
	EAX = 65;
481
	EAX = 65;
482
	ECX = w<<16+h;
482
	ECX = w<<16+h;
483
	EDX = x<<16+y;
483
	EDX = x<<16+y;
484
	EBP = 0;
484
	EBP = 0;
485
	$int 0x40
485
	$int 0x40
486
}
486
}
487
 
487
 
488
inline fastcall void PutPixel( EBX,ECX,EDX)
488
inline fastcall void PutPixel( EBX,ECX,EDX)
489
{
489
{
490
  EAX=1;
490
  EAX=1;
491
  $int 0x40
491
  $int 0x40
492
}
492
}
493
 
493
 
494
:void DrawBar(dword x,y,w,h,color)
494
:void DrawBar(dword x,y,w,h,color)
495
{
495
{
496
	if (h<=0) || (h>60000) || (w<=0) || (w>60000) return; //bad boy :)
496
	if (h<=0) || (h>60000) || (w<=0) || (w>60000) return; //bad boy :)
497
	EAX = 13;
497
	EAX = 13;
498
	EBX = x<<16+w;
498
	EBX = x<<16+w;
499
	ECX = y<<16+h;
499
	ECX = y<<16+h;
500
	EDX = color;
500
	EDX = color;
501
	$int 0x40
501
	$int 0x40
502
}
502
}
503
 
503
 
504
void DefineButton(dword x,y,w,h,EDX,ESI)
504
void DefineButton(dword x,y,w,h,EDX,ESI)
505
{
505
{
506
	EAX = 8;
506
	EAX = 8;
507
	$push edx
507
	$push edx
508
	EDX += BT_DEL;
508
	EDX += BT_DEL;
509
	$int 0x40;
509
	$int 0x40;
510
	$pop edx
510
	$pop edx
511
	EBX = x<<16+w;
511
	EBX = x<<16+w;
512
	ECX = y<<16+h;
512
	ECX = y<<16+h;
513
	$int 0x40
513
	$int 0x40
514
}
514
}
515
 
515
 
516
inline RefreshWindow(dword ID_REFRESH,ID_ACTIVE)
516
inline RefreshWindow(dword ID_REFRESH,ID_ACTIVE)
517
{
517
{
518
	EAX = 18;
518
	EAX = 18;
519
	EBX = 22;
519
	EBX = 22;
520
	ECX = 3;
520
	ECX = 3;
521
	EDX = ID_REFRESH;
521
	EDX = ID_REFRESH;
522
	$int 0x40
522
	$int 0x40
523
	EAX = 18;
523
	EAX = 18;
524
	EBX = 3;
524
	EBX = 3;
525
	EDX = ID_ACTIVE;
525
	EDX = ID_ACTIVE;
526
	$int 0x40
526
	$int 0x40
527
}
527
}
528
 
528
 
529
:void UnsafeDefineButton(dword x,y,w,h,id,color)
529
:void UnsafeDefineButton(dword x,y,w,h,id,color)
530
{
530
{
531
	EAX = 8;
531
	EAX = 8;
532
	EBX = x<<16+w;
532
	EBX = x<<16+w;
533
	ECX = y<<16+h;
533
	ECX = y<<16+h;
534
	EDX = id;
534
	EDX = id;
535
	ESI = color;
535
	ESI = color;
536
	$int 0x40
536
	$int 0x40
537
}
537
}
538
 
538
 
539
void DefineDragableWindow(dword _x, _y, _w, _h)
539
:void DefineDragableWindow(dword _x, _y, _w, _h)
540
{
540
{
541
	DefineAndDrawWindow(_x, _y, _w, _h, 0x41,0x000000,NULL,0b);
541
	DefineAndDrawWindow(_x, _y, _w, _h, 0x41,0x000000,NULL,0b);
542
}
542
}
543
 
543
 
544
:void EventDragWindow()
544
:void EventDragWindow()
545
{
545
{
546
	dword tmp_x,tmp_y;
546
	dword tmp_x,tmp_y;
547
	dword z1,z2;
547
	dword z1,z2;
548
	tmp_x = mouse.x;
548
	tmp_x = mouse.x;
549
	tmp_y = mouse.y;
549
	tmp_y = mouse.y;
550
	do {
550
	do {
551
		mouse.get();
551
		mouse.get();
552
		if (tmp_x!=mouse.x) || (tmp_y!=mouse.y) 
552
		if (tmp_x!=mouse.x) || (tmp_y!=mouse.y) 
553
		{
553
		{
554
			z1 = Form.left + mouse.x - tmp_x;
554
			z1 = Form.left + mouse.x - tmp_x;
555
			z2 = Form.top + mouse.y - tmp_y;
555
			z2 = Form.top + mouse.y - tmp_y;
556
			if(z1<=10) || (z1>20000) z1=0; else if(z1>screen.width-Form.width-10)z1=screen.width-Form.width;
556
			if(z1<=10) || (z1>20000) z1=0; else if(z1>screen.width-Form.width-10)z1=screen.width-Form.width;
557
			if(z2<=10) || (z2>20000) z2=0; else if(z2>screen.height-Form.height-10)z2=screen.height-Form.height;
557
			if(z2<=10) || (z2>20000) z2=0; else if(z2>screen.height-Form.height-10)z2=screen.height-Form.height;
558
			MoveSize(z1 , z2, OLD, OLD);
558
			MoveSize(z1 , z2, OLD, OLD);
559
			draw_window();
559
			draw_window();
560
		}
560
		}
561
		pause(1);
561
		pause(1);
562
	} while (mouse.lkm);
562
	} while (mouse.lkm);
563
}
563
}
564
 
564
 
565
:void DefineHiddenButton(dword _x, _y, _w, _h, _id)
565
:void DefineHiddenButton(dword _x, _y, _w, _h, _id)
566
{
566
{
567
	DefineButton(_x, _y, _w, _h, _id + BT_HIDE, 0);
567
	DefineButton(_x, _y, _w, _h, _id + BT_HIDE, 0);
568
}
568
}
569
 
569
 
570
inline fastcall void DeleteButton( EDX)
570
inline fastcall void DeleteButton( EDX)
571
{
571
{
572
	EAX = 8;
572
	EAX = 8;
573
	EDX += BT_DEL;
573
	EDX += BT_DEL;
574
	$int 0x40
574
	$int 0x40
575
}
575
}
576
 
576
 
577
inline fastcall dword GetStartTime()
577
inline fastcall dword GetStartTime()
578
{
578
{
579
	$mov eax,26
579
	$mov eax,26
580
	$mov ebx,9
580
	$mov ebx,9
581
	$int 0x40
581
	$int 0x40
582
}
582
}
583
 
583
 
584
:dword X_EventRedrawWindow,Y_EventRedrawWindow;
584
:dword X_EventRedrawWindow,Y_EventRedrawWindow;
585
:void _EventRedrawWindow()
585
:void _EventRedrawWindow()
586
{
586
{
587
	loop()switch(WaitEvent())
587
	loop()switch(WaitEvent())
588
	{
588
	{
589
		case evReDraw:
589
		case evReDraw:
590
			DefineAndDrawWindow(X_EventRedrawWindow,Y_EventRedrawWindow,100,1,0x34,0xFFFFFF,NULL,0);
590
			DefineAndDrawWindow(X_EventRedrawWindow,Y_EventRedrawWindow,100,1,0x34,0xFFFFFF,NULL,0);
591
			pause(10);
591
			pause(10);
592
			ExitProcess();
592
			ExitProcess();
593
			break;
593
			break;
594
	}
594
	}
595
}
595
}
596
:char REDRAW_BUFF_EVENT_[4096];
596
:char REDRAW_BUFF_EVENT_[4096];
597
:void EventRedrawWindow(dword x,y)
597
:void EventRedrawWindow(dword x,y)
598
{
598
{
599
	X_EventRedrawWindow = x;
599
	X_EventRedrawWindow = x;
600
	Y_EventRedrawWindow = y;
600
	Y_EventRedrawWindow = y;
601
	CreateThread(#_EventRedrawWindow,#REDRAW_BUFF_EVENT_+4092);
601
	CreateThread(#_EventRedrawWindow,#REDRAW_BUFF_EVENT_+4092);
602
}
602
}
603
 
603
 
604
:struct rect
604
:struct rect
605
{
605
{
606
	dword x,y,w,h;
606
	dword x,y,w,h;
607
	void set_size();
607
	void set_size();
608
};
608
};
609
 
609
 
610
:void rect::set_size(dword _x, _y, _w, _h)
610
:void rect::set_size(dword _x, _y, _w, _h)
611
{
611
{
612
	x=_x; 
612
	x=_x; 
613
	y=_y;
613
	y=_y;
614
	w=_w;
614
	w=_w;
615
	h=_h;
615
	h=_h;
616
}
616
}
617
 
617
 
618
:struct _screen
618
:struct _screen
619
{
619
{
620
	dword width,height;
620
	dword width,height;
621
} screen;
621
} screen;
622
 
622
 
623
:byte skin_height;
623
:byte skin_height;
624
 
624
 
625
:void DrawDate(dword x, y, color, in_date)
625
:void DrawDate(dword x, y, color, in_date)
626
{
626
{
627
	EDI = in_date;
627
	EDI = in_date;
628
	EAX = 47;
628
	EAX = 47;
629
	EBX = 2<<16;
629
	EBX = 2<<16;
630
	EDX = x<<16+y;
630
	EDX = x<<16+y;
631
	ESI = 0x90<<24+color;
631
	ESI = 0x90<<24+color;
632
	ECX = EDI.date.day;
632
	ECX = EDI.date.day;
633
	$int 0x40;
633
	$int 0x40;
634
	EDX += 20<<16;
634
	EDX += 20<<16;
635
	ECX = EDI.date.month;
635
	ECX = EDI.date.month;
636
	$int 0x40;
636
	$int 0x40;
637
	EDX += 20<<16;
637
	EDX += 20<<16;
638
	EBX = 4<<16;
638
	EBX = 4<<16;
639
	ECX = EDI.date.year;
639
	ECX = EDI.date.year;
640
	$int 0x40;
640
	$int 0x40;
641
	DrawBar(x+17,y+10,2,2,color);
641
	DrawBar(x+17,y+10,2,2,color);
642
	DrawBar(x+37,y+10,2,2,color);
642
	DrawBar(x+37,y+10,2,2,color);
643
}
643
}
644
 
644
 
645
:void __path_name__(dword BUF,PATH)
645
:void __path_name__(dword BUF,PATH)
646
{
646
{
647
	dword beg = PATH;
647
	dword beg = PATH;
648
	dword pos = PATH;
648
	dword pos = PATH;
649
	dword sav = PATH;
649
	dword sav = PATH;
650
	dword i;
650
	dword i;
651
	while(DSBYTE[pos])
651
	while(DSBYTE[pos])
652
	{
652
	{
653
		if(DSBYTE[pos]=='/')sav = pos;
653
		if(DSBYTE[pos]=='/')sav = pos;
654
		pos++;
654
		pos++;
655
	}
655
	}
656
	i = sav-beg;
656
	i = sav-beg;
657
	while(i)
657
	while(i)
658
	{
658
	{
659
		DSBYTE[BUF] = DSBYTE[beg];
659
		DSBYTE[BUF] = DSBYTE[beg];
660
		beg++;
660
		beg++;
661
		BUF++;
661
		BUF++;
662
		i--;
662
		i--;
663
	}
663
	}
664
	/*while(DSBYTE[beg])
664
	/*while(DSBYTE[beg])
665
	{
665
	{
666
		DSBYTE[BUF1] = DSBYTE[beg];
666
		DSBYTE[BUF1] = DSBYTE[beg];
667
		beg++;
667
		beg++;
668
		BUF1++;
668
		BUF1++;
669
	}*/
669
	}*/
670
	//DSBYTE[BUF1] = 0;
670
	//DSBYTE[BUF1] = 0;
671
	DSBYTE[BUF] = 0;
671
	DSBYTE[BUF] = 0;
672
}
672
}
673
char __BUF_DIR__[4096];
673
char __BUF_DIR__[4096];
674
:struct SELF
674
:struct SELF
675
{
675
{
676
	dword dir;
676
	dword dir;
677
	dword file;
677
	dword file;
678
	dword path;
678
	dword path;
679
} self;
679
} self;
680
 
680
 
681
dword __generator;  // random number generator - äëÿ ãåíåðàöèè ñëó÷àéíûõ ÷èñåë
681
dword __generator;  // random number generator - äëÿ ãåíåðàöèè ñëó÷àéíûõ ÷èñåë
682
 
682
 
683
:dword program_path_length;
683
:dword program_path_length;
684
 
684
 
685
//The initialization of the initial data before running
685
//The initialization of the initial data before running
686
void ______INIT______()
686
void ______INIT______()
687
{
687
{
688
	//if (program_path[0]!='/') I_Path++;
688
	//if (program_path[0]!='/') I_Path++;
689
	
689
	
690
	self.dir = #__BUF_DIR__;
690
	self.dir = #__BUF_DIR__;
691
	self.file = 0;
691
	self.file = 0;
692
	self.path = I_Path;
692
	self.path = I_Path;
693
	__path_name__(#__BUF_DIR__,I_Path);
693
	__path_name__(#__BUF_DIR__,I_Path);
694
	
694
	
695
	skin_height   = GetSkinHeight();
695
	skin_height   = GetSkinHeight();
696
	screen.width  = GetScreenWidth()+1;
696
	screen.width  = GetScreenWidth()+1;
697
	screen.height = GetScreenHeight()+1;
697
	screen.height = GetScreenHeight()+1;
698
	
698
	
699
	DOUBLE_CLICK_DELAY = GetMouseDoubleClickDelay();
699
	DOUBLE_CLICK_DELAY = GetMouseDoubleClickDelay();
700
	__generator = GetStartTime();
700
	__generator = GetStartTime();
701
	
701
	
702
	mem_init();
702
	mem_init();
703
 
703
 
704
 
704
 
705
	main();
705
	main();
706
	ExitProcess();
706
	ExitProcess();
707
}
707
}
708
______STOP______:
708
______STOP______:
709
#endif
709
#endif
710
 
710
 
711
#ifndef INCLUDE_MEM_H
711
#ifndef INCLUDE_MEM_H
712
#include "../lib/mem.h"
712
#include "../lib/mem.h"
713
#endif
713
#endif
714
 
714
 
715
#ifndef INCLUDE_DEBUG_H
715
#ifndef INCLUDE_DEBUG_H
716
#include "../lib/debug.h"
716
#include "../lib/debug.h"
717
#endif
717
#endif
718
>
718
>
719
>
719
>
720
>
720
>
721
>
721
>
722
>
722
>
723
>
723
>
724
>
724
>
725
>
725
>
726
>
726
>
727
>
727
>
728
>
728
>
729
>
729
>
730
>
730
>
731
>
731
>
732
>
732
>
733
>
733
>
734
>
734
>
735
>
735
>
736
>
736
>
737
>
737
>
738
>
738
>
739
>
739
>
740
>
740
>
741
>
741
>
742
>
742
>
743
>
743
>
744
>
744
>
745
>
745
>
746
>
746
>
747
>
747
>
748
>
748
>
749
>
749
>
750
>
750
>
751
>
751
>
752
>
752
>
753
>
753
>
754
>
754
>
755
>
755
>
756
>
756
>
757
>
757
>
758
>
758
>
759
>
759
>
760
>
760
>
761
>
761
>
762
>
762
>
763
>
763
>
764
>
764
>
765
>
765
>
766
>
766
>
767
>
767
>
768
>
768
>
769
>
769
>