Subversion Repositories Kolibri OS

Rev

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

Rev 7225 Rev 7227
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
:void GetProcessInfo(dword _process_struct_pointer, _process_id)
161
:void GetProcessInfo(dword _process_struct_pointer, _process_id)
162
{
162
{
163
	skin_height = GetSkinHeight();
163
	skin_height = GetSkinHeight();
164
	EAX = 9;
164
	EAX = 9;
165
	EBX = _process_struct_pointer;
165
	EBX = _process_struct_pointer;
166
	ECX = _process_id;
166
	ECX = _process_id;
167
	$int  0x40
167
	$int  0x40
168
	DSDWORD[EBX+71] = DSDWORD[EBX+42] - 9; //set cwidth
168
	DSDWORD[EBX+71] = DSDWORD[EBX+42] - 9; //set cwidth
169
	DSDWORD[EBX+75] = DSDWORD[EBX+46] - skin_height - 4; //set cheight
169
	DSDWORD[EBX+75] = DSDWORD[EBX+46] - skin_height - 4; //set cheight
170
}
170
}
171
 
171
 
172
inline fastcall int GetPointOwner( EBX, ECX) //ebx=m.x, ecx=m.y
172
inline fastcall int GetPointOwner( EBX, ECX) //ebx=m.x, ecx=m.y
173
{
173
{
174
	$mov eax,34
174
	$mov eax,34
175
	$int 0x40
175
	$int 0x40
176
}
176
}
177
 
177
 
178
inline fastcall int GetProcessSlot( ECX)
178
inline fastcall int GetProcessSlot( ECX)
179
{
179
{
180
	EAX = 18;
180
	EAX = 18;
181
	EBX = 21;
181
	EBX = 21;
182
	$int 0x40
182
	$int 0x40
183
}
183
}
184
 
184
 
185
inline fastcall int GetActiveProcess()
185
inline fastcall int GetActiveProcess()
186
{
186
{
187
	EAX = 18;
187
	EAX = 18;
188
	EBX = 7;
188
	EBX = 7;
189
	$int 0x40
189
	$int 0x40
190
}
190
}
191
 
191
 
192
:int CheckActiveProcess(int Form_ID)
192
:int CheckActiveProcess(int Form_ID)
193
{
193
{
194
	int id9=GetProcessSlot(Form_ID);
194
	int id9=GetProcessSlot(Form_ID);
195
	if (id9==GetActiveProcess()) return 1;
195
	if (id9==GetActiveProcess()) return 1;
196
	return 0;
196
	return 0;
197
}
197
}
198
 
198
 
199
inline fastcall void ActivateWindow( ECX)
199
inline fastcall void ActivateWindow( ECX)
200
{
200
{
201
	EAX = 18;
201
	EAX = 18;
202
	EBX = 3;
202
	EBX = 3;
203
	$int 0x40
203
	$int 0x40
204
}
204
}
205
 
205
 
206
inline fastcall int MinimizeWindow()
206
inline fastcall int MinimizeWindow()
207
{
207
{
208
	EAX = 18;
208
	EAX = 18;
209
	EBX = 10;
209
	EBX = 10;
210
	$int 0x40
210
	$int 0x40
211
}
211
}
212
 
212
 
213
inline fastcall int CreateThread(ECX,EDX)
213
inline fastcall int CreateThread(ECX,EDX)
214
{
214
{
215
	$mov eax,51
215
	$mov eax,51
216
	$mov ebx,1
216
	$mov ebx,1
217
	$int 0x40
217
	$int 0x40
218
}
218
}
219
 
219
 
220
inline fastcall void SwitchToAnotherThread()
220
inline fastcall void SwitchToAnotherThread()
221
{
221
{
222
	$mov eax,68
222
	$mov eax,68
223
	$mov ebx,1
223
	$mov ebx,1
224
	$int 0x40
224
	$int 0x40
225
}
225
}
226
 
226
 
227
inline fastcall int SendWindowMessage( ECX, EDX)
227
inline fastcall int SendWindowMessage( ECX, EDX)
228
{
228
{
229
	$mov eax, 72
229
	$mov eax, 72
230
	$mov ebx, 1
230
	$mov ebx, 1
231
	$int 0x40
231
	$int 0x40
232
}
232
}
233
 
233
 
234
inline fastcall int KillProcess( ECX)
234
inline fastcall int KillProcess( ECX)
235
{
235
{
236
	$mov eax,18;
236
	$mov eax,18;
237
	$mov ebx,18;
237
	$mov ebx,18;
238
	$int 0x40
238
	$int 0x40
239
}
239
}
240
 
240
 
241
#define TURN_OFF 2
241
#define TURN_OFF 2
242
#define REBOOT 3
242
#define REBOOT 3
243
#define KERNEL 4
243
#define KERNEL 4
244
inline fastcall int ExitSystem( ECX)
244
inline fastcall int ExitSystem( ECX)
245
{
245
{
246
	$mov eax, 18
246
	$mov eax, 18
247
	$mov ebx, 9
247
	$mov ebx, 9
248
	$int 0x40
248
	$int 0x40
249
}
249
}
250
 
250
 
251
inline fastcall ExitProcess()
251
inline fastcall ExitProcess()
252
{
252
{
253
	$mov eax,-1;
253
	$mov eax,-1;
254
	$int 0x40
254
	$int 0x40
255
}
255
}
256
 
256
 
257
//------------------------------------------------------------------------------
257
//------------------------------------------------------------------------------
258
 
258
 
259
inline fastcall void SetCurDir( ECX)
259
inline fastcall void SetCurDir( ECX)
260
{
260
{
261
  EAX=30;
261
  EAX=30;
262
  EBX=1;
262
  EBX=1;
263
  $int 0x40
263
  $int 0x40
264
}
264
}
265
 
265
 
266
 
266
 
267
//eax = ÿçûê ñèñòåìû (1=eng, 2=fi, 3=ger, 4=rus)
267
//eax = ÿçûê ñèñòåìû (1=eng, 2=fi, 3=ger, 4=rus)
268
#define SYS_LANG_ENG 1
268
#define SYS_LANG_ENG 1
269
#define SYS_LANG_FIN 2
269
#define SYS_LANG_FIN 2
270
#define SYS_LANG_GER 3
270
#define SYS_LANG_GER 3
271
#define SYS_LANG_RUS 4
271
#define SYS_LANG_RUS 4
272
inline fastcall int GetSystemLanguage()
272
inline fastcall int GetSystemLanguage()
273
{
273
{
274
	EAX = 26;
274
	EAX = 26;
275
	EBX = 5;
275
	EBX = 5;
276
	$int 0x40
276
	$int 0x40
277
}
277
}
278
 
278
 
279
inline fastcall GetSkinHeight()
279
inline fastcall GetSkinHeight()
280
{
280
{
281
	$push ebx
281
	$push ebx
282
	$mov  eax,48
282
	$mov  eax,48
283
	$mov  ebx,4
283
	$mov  ebx,4
284
	$int 0x40
284
	$int 0x40
285
	$pop  ebx
285
	$pop  ebx
286
}
286
}
287
 
287
 
288
inline fastcall void SetSystemSkin( ECX)
288
inline fastcall void SetSystemSkin( ECX)
289
{
289
{
290
	EAX = 48;
290
	EAX = 48;
291
	EBX = 8;
291
	EBX = 8;
292
	$int 0x40
292
	$int 0x40
293
}
293
}
294
 
294
 
295
inline fastcall int GetScreenWidth()
295
inline fastcall int GetScreenWidth()
296
{
296
{
297
	$mov eax, 14
297
	$mov eax, 14
298
	$int 0x40
298
	$int 0x40
299
	$shr eax, 16
299
	$shr eax, 16
300
}
300
}
301
 
301
 
302
inline fastcall int GetScreenHeight()
302
inline fastcall int GetScreenHeight()
303
{
303
{
304
	$mov eax, 14
304
	$mov eax, 14
305
	$int 0x40
305
	$int 0x40
306
	$and eax,0x0000FFFF
306
	$and eax,0x0000FFFF
307
}
307
}
308
 
308
 
309
inline fastcall int GetClientTop()
309
inline fastcall int GetClientTop()
310
{
310
{
311
	$mov eax, 48
311
	$mov eax, 48
312
	$mov ebx, 5
312
	$mov ebx, 5
313
	$int 0x40
313
	$int 0x40
314
	$mov eax, ebx
314
	$mov eax, ebx
315
	$shr eax, 16
315
	$shr eax, 16
316
}
316
}
317
 
317
 
318
inline fastcall int GetClientHeight()
318
inline fastcall int GetClientHeight()
319
{
319
{
320
	$mov eax, 48
320
	$mov eax, 48
321
	$mov ebx, 5
321
	$mov ebx, 5
322
	$int 0x40
322
	$int 0x40
323
	$mov eax, ebx
323
	$mov eax, ebx
324
}
324
}
325
 
325
 
326
inline fastcall dword LoadLibrary( ECX)
326
inline fastcall dword LoadLibrary( ECX)
327
{
327
{
328
	$mov eax, 68 
328
	$mov eax, 68 
329
	$mov ebx, 19
329
	$mov ebx, 19
330
	$int  0x40
330
	$int  0x40
331
}
331
}
332
 
332
 
333
inline fastcall int TestBit( EAX, CL)
333
inline fastcall int TestBit( EAX, CL)
334
{
334
{
335
	$shr eax,cl
335
	$shr eax,cl
336
	$and eax,1
336
	$and eax,1
337
}
337
}
338
 
338
 
339
:void SetClientScreenArea(dword _left, _right, _top, _bottom)
339
:void SetClientScreenArea(dword _left, _right, _top, _bottom)
340
{
340
{
341
	EAX = 48;
341
	EAX = 48;
342
	EBX = 6;
342
	EBX = 6;
343
	ECX = _left * 65536 + _right;
343
	ECX = _left * 65536 + _right;
344
	EDX = _top * 65536 + _bottom;
344
	EDX = _top * 65536 + _bottom;
345
	$int 64;
345
	$int 64;
346
}
346
}
347
 
347
 
348
//------------------------------------------------------------------------------
348
//------------------------------------------------------------------------------
349
 
349
 
350
:void DefineAndDrawWindow(dword _x, _y, _w, _h, _window_type, _bgcolor, _title, _flags)
350
:void DefineAndDrawWindow(dword _x, _y, _w, _h, _window_type, _bgcolor, _title, _flags)
351
{
351
{
352
	EAX = 12;              // function 12:tell os about windowdraw
352
	EAX = 12;              // function 12:tell os about windowdraw
353
	EBX = 1;
353
	EBX = 1;
354
	$int 0x40
354
	$int 0x40
355
	
355
	
356
	$xor EAX,EAX
356
	$xor EAX,EAX
357
	EBX = _x << 16 + _w; 
357
	EBX = _x << 16 + _w; 
358
	ECX = _y << 16 + _h;
358
	ECX = _y << 16 + _h;
359
	EDX = _window_type << 24 | _bgcolor;
359
	EDX = _window_type << 24 | _bgcolor;
360
	EDI = _title;
360
	EDI = _title;
361
	ESI = _flags;
361
	ESI = _flags;
362
	$int 0x40
362
	$int 0x40
363
 
363
 
364
 
364
 
365
	EAX = 12;              // function 12:tell os about windowdraw
365
	EAX = 12;              // function 12:tell os about windowdraw
366
	EBX = 2;
366
	EBX = 2;
367
	$int 0x40
367
	$int 0x40
368
}
368
}
369
 
369
 
370
inline fastcall MoveSize( EBX,ECX,EDX,ESI)
370
inline fastcall MoveSize( EBX,ECX,EDX,ESI)
371
{
371
{
372
	$mov eax, 67
372
	$mov eax, 67
373
	$int 0x40
373
	$int 0x40
374
}
374
}
375
 
375
 
376
inline fastcall void DrawTitle( ECX)
376
inline fastcall void DrawTitle( ECX)
377
{
377
{
378
	EAX = 71;
378
	EAX = 71;
379
	EBX = 1;
379
	EBX = 1;
380
	$int 0x40;
380
	$int 0x40;
381
}
381
}
382
 
382
 
383
// @EDX is a process id, -1 for self
383
// @EDX is a process id, -1 for self
384
// @ESI is a new LayerBehaviour
384
// @ESI is a new LayerBehaviour
385
// @RETURN: EAX, 0 is fail, 1 is success
385
// @RETURN: EAX, 0 is fail, 1 is success
386
#define ZPOS_DESKTOP     -2
386
#define ZPOS_DESKTOP     -2
387
#define ZPOS_ALWAYS_BACK -1
387
#define ZPOS_ALWAYS_BACK -1
388
#define ZPOS_NORMAL      0
388
#define ZPOS_NORMAL      0
389
#define ZPOS_ALWAYS_TOP  1
389
#define ZPOS_ALWAYS_TOP  1
390
inline fastcall dword SetWindowLayerBehaviour(EDX, ESI)
390
inline fastcall dword SetWindowLayerBehaviour(EDX, ESI)
391
{
391
{
392
	EAX = 18;
392
	EAX = 18;
393
	EBX = 25;
393
	EBX = 25;
394
	ECX = 2;
394
	ECX = 2;
395
	$int 64
395
	$int 64
396
}
396
}
397
 
397
 
398
:void WriteTextB(dword x,y,byte fontType, dword color, str_offset)
398
:void WriteTextB(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
	ESI = 0;
404
	ESI = 0;
405
	$int 0x40;
405
	$int 0x40;
406
	$add ebx, 1<<16
406
	$add ebx, 1<<16
407
	$int 0x40
407
	$int 0x40
408
}
408
}
409
 
409
 
410
:void WriteText(dword x,y,byte fontType, dword color, str_offset)
410
:void WriteText(dword x,y,byte fontType, dword color, str_offset)
411
{
411
{
412
	EAX = 4;
412
	EAX = 4;
413
	EBX = x<<16+y;
413
	EBX = x<<16+y;
414
	ECX = fontType<<24+color;
414
	ECX = fontType<<24+color;
415
	EDX = str_offset;
415
	EDX = str_offset;
416
	$int 0x40;
416
	$int 0x40;
417
}
417
}
418
 
418
 
419
:dword WriteBufText(dword x,y,byte fontType, dword color, str_offset, buf_offset)
419
:dword WriteBufText(dword x,y,byte fontType, dword color, str_offset, buf_offset)
420
{
420
{
421
	EAX = 4;
421
	EAX = 4;
422
	EBX = x<<16+y;
422
	EBX = x<<16+y;
423
	ECX = fontType<<24+color;
423
	ECX = fontType<<24+color;
424
	EDX = str_offset;
424
	EDX = str_offset;
425
	EDI = buf_offset;
425
	EDI = buf_offset;
426
	$int 0x40;
426
	$int 0x40;
427
}
427
}
428
 
428
 
429
:void WriteNumber(dword x,y,byte fontType, dword color, count, number_or_offset)
429
:void WriteNumber(dword x,y,byte fontType, dword color, count, number_or_offset)
430
{
430
{
431
	EAX = 47;
431
	EAX = 47;
432
	EBX = count<<16;
432
	EBX = count<<16;
433
	ECX = number_or_offset;
433
	ECX = number_or_offset;
434
	EDX = x<<16+y;
434
	EDX = x<<16+y;
435
	ESI = fontType<<24+color;
435
	ESI = fontType<<24+color;
436
	$int 0x40;
436
	$int 0x40;
437
}
437
}
438
 
438
 
439
:void CopyScreen(dword dst_offset, x, y, w, h)
439
:void CopyScreen(dword dst_offset, x, y, w, h)
440
{
440
{
441
  EAX = 36;
441
  EAX = 36;
442
  EBX = dst_offset;
442
  EBX = dst_offset;
443
  ECX = w << 16 + h;
443
  ECX = w << 16 + h;
444
  EDX = x << 16 + y;
444
  EDX = x << 16 + y;
445
  $int  0x40;
445
  $int  0x40;
446
}
446
}
447
 
447
 
448
:dword GetPixelColorFromScreen(dword _x, _y)
448
:dword GetPixelColorFromScreen(dword _x, _y)
449
{
449
{
450
	EAX = 35;
450
	EAX = 35;
451
	EBX = _y * screen.width + _x;
451
	EBX = _y * screen.width + _x;
452
	$int 64
452
	$int 64
453
}
453
}
454
 
454
 
455
#define DRAW_DESKTOP_BG_TILE 1
455
#define DRAW_DESKTOP_BG_TILE 1
456
#define DRAW_DESKTOP_BG_STRETCH 2
456
#define DRAW_DESKTOP_BG_STRETCH 2
457
:void SetBackgroundImage(dword w,h, image, mode)
457
:void SetBackgroundImage(dword w,h, image, mode)
458
{
458
{
459
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
459
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
460
	$mov     ebx,4       // SSF_MODE_BG 4 - set drawing mode for the background
460
	$mov     ebx,4       // SSF_MODE_BG 4 - set drawing mode for the background
461
	$mov     ecx,mode    // drawing mode - tile (1), stretch (2)
461
	$mov     ecx,mode    // drawing mode - tile (1), stretch (2)
462
	$int     64
462
	$int     64
463
 
463
 
464
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
464
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
465
	$mov     ebx,1       // SSF_SIZE_BG=1 - set a size of the background image
465
	$mov     ebx,1       // SSF_SIZE_BG=1 - set a size of the background image
466
	$mov     ecx,w       // width
466
	$mov     ecx,w       // width
467
	$mov     edx,h       // height
467
	$mov     edx,h       // height
468
	$int     64
468
	$int     64
469
 
469
 
470
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
470
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
471
	$mov     ebx,5       // SSF_IMAGE_BG=5 - put block of pixels on the background image
471
	$mov     ebx,5       // SSF_IMAGE_BG=5 - put block of pixels on the background image
472
	$mov     ecx,image   // pointer to the data in the format BBGGRRBBGGRR...
472
	$mov     ecx,image   // pointer to the data in the format BBGGRRBBGGRR...
473
	$mov     edx,0       // offset in data of the background image
473
	$mov     edx,0       // offset in data of the background image
474
	ESI      = 3*w*h;    // size of data in bytes = 3 * number of pixels
474
	ESI      = 3*w*h;    // size of data in bytes = 3 * number of pixels
475
	$int     64
475
	$int     64
476
 
476
 
477
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
477
	$mov     eax,15      // SF_BACKGROUND_SET 15 - work with desktop background graphics
478
	$mov     ebx,3       // SSF_REDRAW_BG=3 - redraw background
478
	$mov     ebx,3       // SSF_REDRAW_BG=3 - redraw background
479
	$int     64
479
	$int     64
480
}
480
}
481
 
481
 
482
:void _PutImage(dword x,y, w,h, data_offset)
482
:void _PutImage(dword x,y, w,h, data_offset)
483
{
483
{
484
	EAX = 7;
484
	EAX = 7;
485
	EBX = data_offset;
485
	EBX = data_offset;
486
	ECX = w<<16+h;
486
	ECX = w<<16+h;
487
	EDX = x<<16+y;
487
	EDX = x<<16+y;
488
	$int 0x40
488
	$int 0x40
489
}
489
}
490
 
490
 
491
:void PutPaletteImage(dword inbuf,w,h,x,y,bits,pal)
491
:void PutPaletteImage(dword inbuf,w,h,x,y,bits,pal)
492
{
492
{
493
	EAX = 65;
493
	EAX = 65;
494
	EBX = inbuf;
494
	EBX = inbuf;
495
	ECX = w<<16+h;
495
	ECX = w<<16+h;
496
	EDX = x<<16+y;
496
	EDX = x<<16+y;
497
	ESI = bits;
497
	ESI = bits;
498
	EDI = pal;
498
	EDI = pal;
499
	EBP = 0;
499
	EBP = 0;
500
	$int 0x40
500
	$int 0x40
501
}
501
}
502
 
502
 
503
inline fastcall void PutPixel( EBX,ECX,EDX)
503
inline fastcall void PutPixel( EBX,ECX,EDX)
504
{
504
{
505
  EAX=1;
505
  EAX=1;
506
  $int 0x40
506
  $int 0x40
507
}
507
}
508
 
508
 
509
:void DrawBar(dword x,y,w,h,color)
509
:void DrawBar(dword x,y,w,h,color)
510
{
510
{
511
	if (h<=0) || (h>60000) || (w<=0) || (w>60000) return; //bad boy :)
511
	if (h<=0) || (h>60000) || (w<=0) || (w>60000) return; //bad boy :)
512
	EAX = 13;
512
	EAX = 13;
513
	EBX = x<<16+w;
513
	EBX = x<<16+w;
514
	ECX = y<<16+h;
514
	ECX = y<<16+h;
515
	EDX = color;
515
	EDX = color;
516
	$int 0x40
516
	$int 0x40
517
}
517
}
518
 
518
 
519
:void DefineButton(dword x,y,w,h,id,color)
519
:void DefineButton(dword x,y,w,h,id,color)
520
{
520
{
521
	EAX = 8;
521
	EAX = 8;
522
	EDX = id + BT_DEL;
522
	EDX = id + BT_DEL;
523
	$int 0x40;
523
	$int 0x40;
524
	EDX = id;
524
	EDX = id;
525
	ESI = color;
525
	ESI = color;
526
	EBX = x<<16+w;
526
	EBX = x<<16+w;
527
	ECX = y<<16+h;
527
	ECX = y<<16+h;
528
	$int 0x40
528
	$int 0x40
529
}
529
}
530
 
530
 
531
inline RefreshWindow(dword ID_REFRESH,ID_ACTIVE)
531
inline RefreshWindow(dword ID_REFRESH,ID_ACTIVE)
532
{
532
{
533
	EAX = 18;
533
	EAX = 18;
534
	EBX = 22;
534
	EBX = 22;
535
	ECX = 3;
535
	ECX = 3;
536
	EDX = ID_REFRESH;
536
	EDX = ID_REFRESH;
537
	$int 0x40
537
	$int 0x40
538
	EAX = 18;
538
	EAX = 18;
539
	EBX = 3;
539
	EBX = 3;
540
	EDX = ID_ACTIVE;
540
	EDX = ID_ACTIVE;
541
	$int 0x40
541
	$int 0x40
542
}
542
}
543
 
543
 
544
:void UnsafeDefineButton(dword x,y,w,h,id,color)
544
:void UnsafeDefineButton(dword x,y,w,h,id,color)
545
{
545
{
546
	EAX = 8;
546
	EAX = 8;
547
	EBX = x<<16+w;
547
	EBX = x<<16+w;
548
	ECX = y<<16+h;
548
	ECX = y<<16+h;
549
	EDX = id;
549
	EDX = id;
550
	ESI = color;
550
	ESI = color;
551
	$int 0x40
551
	$int 0x40
552
}
552
}
553
 
553
 
554
:void DefineDragableWindow(dword _x, _y, _w, _h)
554
:void DefineDragableWindow(dword _x, _y, _w, _h)
555
{
555
{
556
	DefineAndDrawWindow(_x, _y, _w, _h, 0x41,0x000000,NULL,0b);
556
	DefineAndDrawWindow(_x, _y, _w, _h, 0x41,0x000000,NULL,0b);
557
}
557
}
558
 
558
 
559
:void DefineUnDragableWindow(dword _x, _y, _w, _h)
559
:void DefineUnDragableWindow(dword _x, _y, _w, _h)
560
{
560
{
561
	DefineAndDrawWindow(_x, _y, _w, _h, 0x01, 0, 0, 0x01fffFFF);
561
	DefineAndDrawWindow(_x, _y, _w, _h, 0x01, 0, 0, 0x01fffFFF);
562
}
562
}
563
 
563
 
564
:void EventDragWindow()
564
:void EventDragWindow()
565
{
565
{
566
	dword tmp_x,tmp_y;
566
	dword tmp_x,tmp_y;
567
	dword z1,z2;
567
	dword z1,z2;
568
	tmp_x = mouse.x;
568
	tmp_x = mouse.x;
569
	tmp_y = mouse.y;
569
	tmp_y = mouse.y;
570
	do {
570
	do {
571
		mouse.get();
571
		mouse.get();
572
		if (tmp_x!=mouse.x) || (tmp_y!=mouse.y) 
572
		if (tmp_x!=mouse.x) || (tmp_y!=mouse.y) 
573
		{
573
		{
574
			z1 = Form.left + mouse.x - tmp_x;
574
			z1 = Form.left + mouse.x - tmp_x;
575
			z2 = Form.top + mouse.y - tmp_y;
575
			z2 = Form.top + mouse.y - tmp_y;
576
			if(z1<=10) || (z1>20000) z1=0; else if(z1>screen.width-Form.width-10)z1=screen.width-Form.width;
576
			if(z1<=10) || (z1>20000) z1=0; else if(z1>screen.width-Form.width-10)z1=screen.width-Form.width;
577
			if(z2<=10) || (z2>20000) z2=0; else if(z2>screen.height-Form.height-10)z2=screen.height-Form.height;
577
			if(z2<=10) || (z2>20000) z2=0; else if(z2>screen.height-Form.height-10)z2=screen.height-Form.height;
578
			MoveSize(z1 , z2, OLD, OLD);
578
			MoveSize(z1 , z2, OLD, OLD);
579
			draw_window();
579
			draw_window();
580
		}
580
		}
581
		pause(1);
581
		pause(1);
582
	} while (mouse.lkm);
582
	} while (mouse.lkm);
583
}
583
}
584
 
584
 
585
:void DefineHiddenButton(dword _x, _y, _w, _h, _id)
585
:void DefineHiddenButton(dword _x, _y, _w, _h, _id)
586
{
586
{
587
	DefineButton(_x, _y, _w, _h, _id + BT_HIDE, 0);
587
	DefineButton(_x, _y, _w, _h, _id + BT_HIDE, 0);
588
}
588
}
589
 
589
 
590
inline fastcall void DeleteButton( EDX)
590
inline fastcall void DeleteButton( EDX)
591
{
591
{
592
	EAX = 8;
592
	EAX = 8;
593
	EDX += BT_DEL;
593
	EDX += BT_DEL;
594
	$int 0x40
594
	$int 0x40
595
}
595
}
596
 
596
 
597
inline fastcall dword GetStartTime()
597
inline fastcall dword GetStartTime()
598
{
598
{
599
	$mov eax,26
599
	$mov eax,26
600
	$mov ebx,9
600
	$mov ebx,9
601
	$int 0x40
601
	$int 0x40
602
}
602
}
603
 
603
 
604
:dword X_EventRedrawWindow,Y_EventRedrawWindow;
604
:dword X_EventRedrawWindow,Y_EventRedrawWindow;
605
:void _EventRedrawWindow()
605
:void _EventRedrawWindow()
606
{
606
{
607
	loop()switch(WaitEvent())
607
	loop()switch(WaitEvent())
608
	{
608
	{
609
		case evReDraw:
609
		case evReDraw:
610
			DefineAndDrawWindow(X_EventRedrawWindow,Y_EventRedrawWindow,100,1,0x34,0xFFFFFF,NULL,0);
610
			DefineAndDrawWindow(X_EventRedrawWindow,Y_EventRedrawWindow,100,1,0x34,0xFFFFFF,NULL,0);
611
			pause(10);
611
			pause(10);
612
			ExitProcess();
612
			ExitProcess();
613
			break;
613
			break;
614
	}
614
	}
615
}
615
}
616
:char REDRAW_BUFF_EVENT_[4096];
616
:char REDRAW_BUFF_EVENT_[4096];
617
:void EventRedrawWindow(dword x,y)
617
:void EventRedrawWindow(dword x,y)
618
{
618
{
619
	X_EventRedrawWindow = x;
619
	X_EventRedrawWindow = x;
620
	Y_EventRedrawWindow = y;
620
	Y_EventRedrawWindow = y;
621
	CreateThread(#_EventRedrawWindow,#REDRAW_BUFF_EVENT_+4092);
621
	CreateThread(#_EventRedrawWindow,#REDRAW_BUFF_EVENT_+4092);
622
}
622
}
623
 
-
 
624
:struct rect
-
 
625
{
-
 
626
	dword x,y,w,h;
-
 
627
	void set_size();
-
 
628
};
-
 
629
 
-
 
630
:void rect::set_size(dword _x, _y, _w, _h)
-
 
631
{
-
 
632
	x=_x; 
-
 
633
	y=_y;
-
 
634
	w=_w;
-
 
635
	h=_h;
-
 
636
}
-
 
637
 
623
 
638
:struct _screen
624
:struct _screen
639
{
625
{
640
	dword width,height;
626
	dword width,height;
641
} screen;
627
} screen;
642
 
628
 
643
:byte skin_height;
629
:byte skin_height;
644
 
630
 
645
:void DrawDate(dword x, y, color, in_date)
631
:void DrawDate(dword x, y, color, in_date)
646
{
632
{
647
	EDI = in_date;
633
	EDI = in_date;
648
	EAX = 47;
634
	EAX = 47;
649
	EBX = 2<<16;
635
	EBX = 2<<16;
650
	EDX = x<<16+y;
636
	EDX = x<<16+y;
651
	ESI = 0x90<<24+color;
637
	ESI = 0x90<<24+color;
652
	ECX = EDI.date.day;
638
	ECX = EDI.date.day;
653
	$int 0x40;
639
	$int 0x40;
654
	EDX += 20<<16;
640
	EDX += 20<<16;
655
	ECX = EDI.date.month;
641
	ECX = EDI.date.month;
656
	$int 0x40;
642
	$int 0x40;
657
	EDX += 20<<16;
643
	EDX += 20<<16;
658
	EBX = 4<<16;
644
	EBX = 4<<16;
659
	ECX = EDI.date.year;
645
	ECX = EDI.date.year;
660
	$int 0x40;
646
	$int 0x40;
661
	DrawBar(x+17,y+10,2,2,color);
647
	DrawBar(x+17,y+10,2,2,color);
662
	DrawBar(x+37,y+10,2,2,color);
648
	DrawBar(x+37,y+10,2,2,color);
663
}
649
}
664
 
650
 
665
:void __path_name__(dword BUF,PATH)
651
:void __path_name__(dword BUF,PATH)
666
{
652
{
667
	dword beg = PATH;
653
	dword beg = PATH;
668
	dword pos = PATH;
654
	dword pos = PATH;
669
	dword sav = PATH;
655
	dword sav = PATH;
670
	dword i;
656
	dword i;
671
	while(DSBYTE[pos])
657
	while(DSBYTE[pos])
672
	{
658
	{
673
		if(DSBYTE[pos]=='/')sav = pos;
659
		if(DSBYTE[pos]=='/')sav = pos;
674
		pos++;
660
		pos++;
675
	}
661
	}
676
	i = sav-beg;
662
	i = sav-beg;
677
	while(i)
663
	while(i)
678
	{
664
	{
679
		DSBYTE[BUF] = DSBYTE[beg];
665
		DSBYTE[BUF] = DSBYTE[beg];
680
		beg++;
666
		beg++;
681
		BUF++;
667
		BUF++;
682
		i--;
668
		i--;
683
	}
669
	}
684
	/*while(DSBYTE[beg])
670
	/*while(DSBYTE[beg])
685
	{
671
	{
686
		DSBYTE[BUF1] = DSBYTE[beg];
672
		DSBYTE[BUF1] = DSBYTE[beg];
687
		beg++;
673
		beg++;
688
		BUF1++;
674
		BUF1++;
689
	}*/
675
	}*/
690
	//DSBYTE[BUF1] = 0;
676
	//DSBYTE[BUF1] = 0;
691
	DSBYTE[BUF] = 0;
677
	DSBYTE[BUF] = 0;
692
}
678
}
693
char __BUF_DIR__[4096];
679
char __BUF_DIR__[4096];
694
:struct SELF
680
:struct SELF
695
{
681
{
696
	dword dir;
682
	dword dir;
697
	dword file;
683
	dword file;
698
	dword path;
684
	dword path;
699
} self;
685
} self;
700
 
686
 
701
dword __generator;  // random number generator - äëÿ ãåíåðàöèè ñëó÷àéíûõ ÷èñåë
687
dword __generator;  // random number generator - äëÿ ãåíåðàöèè ñëó÷àéíûõ ÷èñåë
702
 
688
 
703
:dword program_path_length;
689
:dword program_path_length;
704
 
690
 
705
//The initialization of the initial data before running
691
//The initialization of the initial data before running
706
void ______INIT______()
692
void ______INIT______()
707
{
693
{
708
	//if (program_path[0]!='/') I_Path++;
694
	//if (program_path[0]!='/') I_Path++;
709
	
695
	
710
	self.dir = #__BUF_DIR__;
696
	self.dir = #__BUF_DIR__;
711
	self.file = 0;
697
	self.file = 0;
712
	self.path = I_Path;
698
	self.path = I_Path;
713
	__path_name__(#__BUF_DIR__,I_Path);
699
	__path_name__(#__BUF_DIR__,I_Path);
714
	
700
	
715
	skin_height   = GetSkinHeight();
701
	skin_height   = GetSkinHeight();
716
	screen.width  = GetScreenWidth()+1;
702
	screen.width  = GetScreenWidth()+1;
717
	screen.height = GetScreenHeight()+1;
703
	screen.height = GetScreenHeight()+1;
718
	
704
	
719
	__generator = GetStartTime();
705
	__generator = GetStartTime();
720
	
706
	
721
	mem_init();
707
	mem_init();
722
 
708
 
723
 
709
 
724
	main();
710
	main();
725
	ExitProcess();
711
	ExitProcess();
726
}
712
}
727
______STOP______:
713
______STOP______:
728
#endif
714
#endif
729
 
715
 
730
#ifndef INCLUDE_MEM_H
716
#ifndef INCLUDE_MEM_H
731
#include "../lib/mem.h"
717
#include "../lib/mem.h"
732
#endif
718
#endif
733
 
719
 
734
#ifndef INCLUDE_DEBUG_H
720
#ifndef INCLUDE_DEBUG_H
735
#include "../lib/debug.h"
721
#include "../lib/debug.h"
736
#endif
722
#endif
737
>
723
>
738
>
724
>
739
>
725
>
740
>
726
>
741
>
727
>
742
>
728
>
743
>
729
>
744
>
730
>
745
>
731
>
746
>
732
>
747
>
733
>
748
>
734
>
749
>
735
>
750
>
736
>
751
>
737
>
752
>
738
>
753
>
739
>
754
>
740
>
755
>
741
>
756
>
742
>
757
>
743
>
758
>
744
>
759
>
745
>
760
>
746
>
761
>
747
>
762
>
748
>
763
>
749
>
764
>
750
>
765
>
751
>
766
>
752
>
767
>
753
>
768
>
754
>
769
>
755
>
770
>
756
>
771
>
757
>
772
>
758
>
773
>
759
>
774
>
760
>
775
>
761
>
776
>
762
>
777
>
763
>
778
>
764
>
779
>
765
>
780
>
766
>
781
>
767
>
782
>
768
>
783
>
769
>
784
>
770
>
785
>
771
>
786
>
772
>
787
>
773
>
788
>
774
>