Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1971 | lev | 1 | //CODED by Veliant, Leency, Nable. GNU GPL licence. |
2 | |||
3 | #startaddress 0 |
||
4 | #code32 TRUE |
||
5 | |||
6 | char 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; |
||
10 | dword alloc_mem = #0x00100000; |
||
11 | dword x86esp_reg = #0x00100000; |
||
12 | dword I_Param = #param; |
||
13 | dword I_Icon = 0x0; |
||
14 | char param[256]=""; |
||
15 | |||
16 | //Events |
||
17 | #define evMouse 6 |
||
18 | #define evButton 3 |
||
19 | #define evKey 2 |
||
20 | #define evReDraw 1 |
||
21 | |||
22 | //Button options |
||
23 | #define BT_DEL 0x80000000 |
||
24 | #define BT_HIDE 0x40000000 |
||
25 | #define BT_NOFRAME 0x20000000 |
||
26 | |||
27 | #define OLD -1 |
||
28 | #define true 1 |
||
29 | #define false 0 |
||
30 | //------------------------------------------------------------------------- |
||
31 | |||
32 | struct mouse{ |
||
33 | dword x,y,lkm,pkm,hor,vert; |
||
34 | void get(); |
||
35 | }; |
||
36 | |||
37 | void mouse::get() |
||
38 | { |
||
39 | EAX = 37; |
||
40 | EBX = 1; |
||
41 | $int 0x40 |
||
42 | $mov ebx, eax |
||
43 | $shr eax, 16 |
||
44 | $and ebx,0x0000FFFF |
||
45 | x = EAX; |
||
46 | y = EBX; |
||
47 | EAX = 37; |
||
48 | EBX = 2; |
||
49 | $int 0x40 |
||
50 | $mov ebx, eax |
||
51 | $and eax, 0x00000001 |
||
52 | $shr ebx, 1 |
||
53 | $and ebx, 0x00000001 |
||
54 | lkm = EAX; |
||
55 | pkm = EBX; |
||
56 | EAX = 37; //скролл |
||
57 | EBX = 7; |
||
58 | $int 0x40 |
||
59 | $mov ebx, eax |
||
60 | $shr eax, 16 |
||
61 | $and ebx,0x0000FFFF |
||
62 | //hor = EAX; |
||
63 | vert = EBX; |
||
64 | } |
||
65 | |||
66 | struct proc_info{ |
||
67 | dword use_cpu; |
||
68 | word pos_in_stack,num_slot,rezerv1; |
||
69 | char name[11]; |
||
70 | char rezerv2; |
||
71 | dword adress,use_memory,ID,left,top,width,height; |
||
72 | word status_slot,rezerv3; |
||
73 | dword work_left,work_top,work_width,work_height; |
||
74 | char status_window; |
||
75 | void GetInfo(dword ECX); |
||
76 | #define SelfInfo -1 |
||
77 | }; |
||
78 | |||
79 | void proc_info::GetInfo(dword ECX) |
||
80 | { |
||
81 | EAX = 9; |
||
82 | EBX = #use_cpu; |
||
83 | $int 0x40 |
||
84 | } |
||
85 | |||
86 | struct system_colors{ |
||
87 | dword frame,grab,grab_button,grab_button_text,grab_text,work,work_button,work_button_text,work_text,work_graph; |
||
88 | void get(); |
||
89 | }; |
||
90 | void system_colors::get() |
||
91 | { |
||
92 | EAX = 48; |
||
93 | EBX = 3; |
||
94 | ECX = #frame; |
||
95 | EDX = 40; |
||
96 | $int 0x40 |
||
97 | } |
||
98 | |||
99 | //------------------------------------------------------------------------------ |
||
100 | |||
101 | inline fastcall dword WaitEvent(){ |
||
102 | EAX = 10; |
||
103 | $int 0x40 |
||
104 | } |
||
105 | |||
106 | inline fastcall dword WaitEventTimeout(dword EBX){ |
||
107 | EAX = 23; |
||
108 | $int 0x40 |
||
109 | } |
||
110 | |||
111 | inline fastcall SetEventMask(dword EBX) |
||
112 | { |
||
113 | EAX = 40; |
||
114 | $int 0x40 |
||
115 | } |
||
116 | |||
117 | inline fastcall ScancodesGeting(){ |
||
118 | $mov eax,66; |
||
119 | $mov ebx,1; |
||
120 | $mov ecx,1; //сканкоды |
||
121 | $int 0x40 |
||
122 | } |
||
123 | |||
124 | inline fastcall word GetKey(){ |
||
125 | EAX = 2; // just read this key from buffer |
||
126 | $int 0x40 |
||
127 | EAX = EAX >> 8; |
||
128 | } |
||
129 | |||
130 | inline fastcall word GetButtonID(){ |
||
131 | EAX = 17; |
||
132 | $int 0x40 |
||
133 | EAX = EAX >> 8; |
||
134 | } |
||
135 | |||
136 | inline fastcall ExitProcess(){ |
||
137 | EAX = -1; // close this program |
||
138 | $int 0x40 |
||
139 | } |
||
140 | |||
141 | inline fastcall Pause(dword EBX) |
||
142 | { //Пауза, в сотых долях секунды EBX = value |
||
143 | $mov eax, 5 |
||
144 | $int 0x40 |
||
145 | } |
||
146 | |||
147 | //------------------------------------------------------------------------------ |
||
148 | |||
149 | inline fastcall void DrawTitle(dword ECX) |
||
150 | { |
||
151 | EAX = 71; |
||
152 | EBX = 1; |
||
153 | $int 0x40; |
||
154 | } |
||
155 | |||
156 | inline fastcall dword GetSkinWidth() |
||
157 | { |
||
158 | EAX = 48; |
||
159 | EBX = 4; |
||
160 | $int 0x40 |
||
161 | } |
||
162 | |||
163 | inline fastcall void ChangeSkin(ECX){ |
||
164 | EAX = 48; |
||
165 | EBX = 8; |
||
166 | $int 0x40 |
||
167 | } |
||
168 | |||
169 | inline fastcall dword GetScreenWidth() |
||
170 | { |
||
171 | EAX = 14; |
||
172 | EBX = 4; |
||
173 | $int 0x40 |
||
174 | $shr eax, 16 |
||
175 | $and eax,0x0000FFFF |
||
176 | } |
||
177 | |||
178 | inline fastcall MoveSize(dword EBX,ECX,EDX,ESI) |
||
179 | { |
||
180 | EAX = 67; |
||
181 | $int 0x40 |
||
182 | } |
||
183 | |||
184 | inline fastcall dword LoadLibrary(dword ECX) |
||
185 | { |
||
186 | $mov eax, 68 |
||
187 | $mov ebx, 19 |
||
188 | $int 0x40 |
||
189 | } |
||
190 | |||
191 | //------------------------------------------------------------------------------ |
||
192 | inline fastcall dword strlen(dword EDI){ |
||
193 | EAX=0; |
||
194 | ECX=-1; |
||
195 | $REPNE $SCASB |
||
196 | EAX-=2+ECX; |
||
197 | } |
||
198 | |||
199 | inline fastcall copystr(dword ESI,EDI) |
||
200 | { |
||
201 | $cld |
||
202 | l1: |
||
203 | $lodsb |
||
204 | $stosb |
||
205 | $test al,al |
||
206 | $jnz l1 |
||
207 | } |
||
208 | |||
209 | byte fastcall TestBit(EAX, CL) |
||
210 | { |
||
211 | $shr eax,cl |
||
212 | $and eax,1 |
||
213 | } |
||
214 | |||
215 | char buffer[11]=""; |
||
216 | inline fastcall dword IntToStr(dword ESI) |
||
217 | { |
||
218 | $mov edi, #buffer |
||
219 | $mov ecx, 10 |
||
220 | $test esi, esi |
||
221 | $jns f1 |
||
222 | $mov al, '-' |
||
223 | $stosb |
||
224 | $neg esi |
||
225 | f1: |
||
226 | $mov eax, esi |
||
227 | $push -'0' |
||
228 | f2: |
||
229 | $xor edx, edx |
||
230 | $div ecx |
||
231 | $push edx |
||
232 | $test eax, eax |
||
233 | $jnz f2 |
||
234 | f3: |
||
235 | $pop eax |
||
236 | $add al, '0' |
||
237 | $stosb |
||
238 | $jnz f3 |
||
239 | $mov eax, #buffer |
||
240 | $ret |
||
241 | } |
||
242 | |||
243 | |||
244 | inline fastcall dword StrToInt() |
||
245 | { |
||
246 | ESI=EDI=EAX; |
||
247 | IF(DSBYTE[ESI]=='-')ESI++; |
||
248 | EAX=0; |
||
249 | BH=AL; |
||
250 | do{ |
||
251 | BL=DSBYTE[ESI]-'0'; |
||
252 | EAX=EAX*10+EBX; |
||
253 | ESI++; |
||
254 | }while(DSBYTE[ESI]>0); |
||
255 | IF(DSBYTE[EDI]=='-') -EAX; |
||
256 | } |
||
257 | |||
258 | |||
259 | /*int strcmp(char* string1, char* string2) |
||
260 | { |
||
261 | loop () |
||
262 | { |
||
263 | IF (*string1<*string2) RETURN -1; |
||
264 | IF (*string1>*string2) RETURN 1; |
||
265 | IF (*string1=='\0') RETURN 0; |
||
266 | string1++; |
||
267 | string2++; |
||
268 | } |
||
269 | }*/ |
||
270 | |||
271 | |||
272 | inline fastcall int strcmp(ESI, EDI) |
||
273 | { |
||
274 | loop() |
||
275 | { |
||
276 | IF (DSBYTE[ESI] |
||
277 | IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1; |
||
278 | IF (DSBYTE[ESI]=='\0') RETURN 0; |
||
279 | ESI++; |
||
280 | EDI++; |
||
281 | } |
||
282 | } |
||
283 | |||
284 | inline fastcall unsigned int find_symbol(ESI,BL) |
||
285 | { |
||
286 | int jj=0, last=-1; |
||
287 | do{ |
||
288 | jj++; |
||
289 | $lodsb |
||
290 | IF(AL==BL) last=jj; |
||
291 | } while(AL!=0); |
||
292 | return last; |
||
293 | } |
||
294 | |||
295 | |||
296 | dword StrToCol(char* htmlcolor) |
||
297 | { |
||
298 | dword j=1, color=0; char ch=0x00; |
||
299 | IF (ESBYTE[htmlcolor]<>'#') RETURN; |
||
300 | FOR (;j<7;j++) |
||
301 | { |
||
302 | ch=ESBYTE[htmlcolor+j]; |
||
303 | IF ((ch>='0') && (ch<='9')) ch -= '0'; |
||
304 | IF ((ch>='A') && (ch<='F')) ch -= 'A'-10; |
||
305 | IF ((ch>='a') && (ch<='f')) ch -= 'a'-10; |
||
306 | color = color*0x10 + ch; |
||
307 | } |
||
308 | EAX=color; |
||
309 | } |
||
310 | |||
311 | inline fastcall dword upcase(dword ESI) |
||
312 | { |
||
313 | do{ |
||
314 | AL=DSBYTE[ESI]; |
||
315 | IF(AL>='a')IF(AL<='z')DSBYTE[ESI]=AL&0x5f; |
||
316 | ESI++; |
||
317 | }while(AL!=0); |
||
318 | } |
||
319 | |||
320 | /*inline fastcall void lowcase(ESI) |
||
321 | { |
||
322 | do{ |
||
323 | $LODSB |
||
324 | IF(AL>='A')&&(AL<='Z'){ |
||
325 | AL+=0x20; |
||
326 | DSBYTE[ESI-1]=AL; |
||
327 | CONTINUE; |
||
328 | } |
||
329 | }while(AL!=0); |
||
330 | }*/ |
||
331 | |||
332 | inline fastcall lowcase(ESI) |
||
333 | { |
||
334 | do{ |
||
335 | $LODSB |
||
336 | IF(AL>='A')&&(AL<='Z'){ |
||
337 | AL+=0x20; |
||
338 | DSBYTE[ESI-1]=AL; |
||
339 | CONTINUE; |
||
340 | } |
||
341 | }while(AL!=0); |
||
342 | } |
||
343 | |||
344 | |||
345 | inline fastcall wintodos (dword ESI) |
||
346 | { |
||
347 | while (BL=ESBYTE[ESI]) |
||
348 | { |
||
349 | IF (BL>=192) |
||
350 | { |
||
351 | IF (BL>=240) ESBYTE[ESI] = BL - 16; |
||
352 | ELSE ESBYTE[ESI] = BL - 64; |
||
353 | } |
||
354 | ELSE |
||
355 | { |
||
356 | IF (BL==178) ESBYTE[ESI] = 73; //I |
||
357 | IF (BL==179) ESBYTE[ESI] = 105; //i |
||
358 | IF (BL==175) ESBYTE[ESI] = 244; //J |
||
359 | IF (BL==191) ESBYTE[ESI] = 245; //j |
||
360 | IF (BL==170) ESBYTE[ESI] = 242; //E |
||
361 | IF (BL==186) ESBYTE[ESI] = 243; //e |
||
362 | IF (BL==168) ESBYTE[ESI] = 240; //Ё |
||
363 | IF (BL==184) ESBYTE[ESI] = 'e'; //e |
||
364 | IF ((BL==147) || (BL==148) || (BL==171) || (BL==187)) ESBYTE[ESI] = 34; |
||
365 | IF ((BL==150) || (BL==151)) ESBYTE[ESI] = 45; |
||
366 | } |
||
367 | ESI++; |
||
368 | } |
||
369 | } |
||
370 | |||
371 | |||
372 | dword Hex2Symb(char* htmlcolor) |
||
373 | { |
||
374 | dword j=0, symbol=0; |
||
375 | char ch=0x00; |
||
376 | FOR (;j<2;j++) |
||
377 | { |
||
378 | ch=ESBYTE[htmlcolor+j]; |
||
379 | IF (ch==0x0d) || (ch=='\9') return ''; |
||
380 | IF ((ch>='0') && (ch<='9')) ch -= '0'; |
||
381 | IF ((ch>='A') && (ch<='F')) ch -= 'A'-10; |
||
382 | IF ((ch>='a') && (ch<='f')) ch -= 'a'-10; |
||
383 | symbol = symbol*0x10 + ch; |
||
384 | } |
||
385 | wintodos(#symbol); |
||
386 | AL=symbol; |
||
387 | } |
||
388 | |||
389 | byte mas[66] = "юабцдефгхийклмнопярстужвьызшэщчъЮАБЦДЕФГХИЙКЛМНОПЯРСТУЖВЬЫЗШЭЩЧЪ"; |
||
390 | inline fastcall void koitodos(dword EDI) |
||
391 | { |
||
392 | WHILE (BL=ESBYTE[EDI]) |
||
393 | { |
||
394 | IF (BL >= 0xC0) |
||
395 | { |
||
396 | BL -= 0xC0; |
||
397 | ESBYTE[EDI] = mas[BL]; |
||
398 | } |
||
399 | //IF (ESBYTE[EDI]=='\244') ESBYTE[EDI]='i'; |
||
400 | EDI++; |
||
401 | } |
||
402 | } |
||
403 | |||
404 | |||
405 | //Asper |
||
406 | //uncomplete |
||
407 | inline fastcall int utf8rutodos(dword ESI) //- |
||
408 | { |
||
409 | EDI=ESI; |
||
410 | while (BL=ESBYTE[ESI]) |
||
411 | { |
||
412 | IF (BL == 0xD0) || (BL == 0xD1) EDI--; |
||
413 | else IF (BL == 0x81) && (ESBYTE[ESI-1]==0xD0) ESBYTE[EDI] = 0xF0; //ш |
||
414 | else IF (BL == 0x91) && (ESBYTE[ESI-1]==0xD1) ESBYTE[EDI] = 0xF1; //м |
||
415 | else IF (BL == 0xE2) && (ESBYTE[ESI+1]==0x80) && (ESBYTE[ESI+2]==0x94) //long defis |
||
416 | { |
||
417 | ESBYTE[EDI] = '-'; |
||
418 | ESI+=2; |
||
419 | } |
||
420 | else IF (BL == 0xE2) && (ESBYTE[ESI+1]==0x80) && (ESBYTE[ESI+2]==0xA2) //central point |
||
421 | { |
||
422 | ESBYTE[EDI] = '*'; |
||
423 | ESI+=2; |
||
424 | } |
||
425 | else IF (BL == 0xC2) && (ESBYTE[ESI+1]==0xA9) // (c) |
||
426 | { |
||
427 | ESBYTE[EDI] = '('; |
||
428 | ESBYTE[EDI+1] = 'c'; |
||
429 | ESBYTE[EDI+2] = ')'; |
||
430 | EDI+=2; |
||
431 | ESI++; |
||
432 | } |
||
433 | else IF (BL == 0xC2) && ((ESBYTE[ESI+1]==0xAB) || (ESBYTE[ESI+1]==0xBB)) // " |
||
434 | { |
||
435 | ESBYTE[EDI] = '\"'; |
||
436 | ESI++; |
||
437 | } |
||
438 | else IF (BL == 0xC2) && (ESBYTE[ESI+1]==0xB7) // _ |
||
439 | { |
||
440 | ESBYTE[EDI] = '_'; |
||
441 | ESI++; |
||
442 | } |
||
443 | else IF (BL >= 0x90) && (BL <= 0xAF) |
||
444 | { |
||
445 | BL -= 0x10; |
||
446 | ESBYTE[EDI] = BL; |
||
447 | } |
||
448 | else IF (BL >= 0x80) && (BL <= 0x8F) |
||
449 | { |
||
450 | BL += 0x60; |
||
451 | ESBYTE[EDI] = BL; |
||
452 | } |
||
453 | else IF (BL >= 0xB0) && (BL <= 0xBF) |
||
454 | { |
||
455 | BL -= 0x10; |
||
456 | ESBYTE[EDI] = BL; |
||
457 | } |
||
458 | else ESBYTE[EDI] = BL; |
||
459 | ESI++; |
||
460 | EDI++; |
||
461 | } |
||
462 | WHILE (EDI |
||
463 | { |
||
464 | ESBYTE[EDI] = ' '; |
||
465 | EDI++; |
||
466 | } |
||
467 | } |
||
468 | |||
469 | //------------------------------------------------------------------------------ |
||
470 | |||
471 | byte WindowRePaint=0; |
||
472 | inline fastcall void WindowRedrawStatus(dword EBX) |
||
473 | { |
||
474 | EAX = 12; // function 12:tell os about windowdraw |
||
475 | $int 0x40 |
||
476 | IF (EBX==1) WindowRePaint=1; ELSE WindowRePaint=0; |
||
477 | } |
||
478 | |||
479 | void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI) |
||
480 | { |
||
481 | EBX = x << 16 + sizeX; |
||
482 | ECX = y << 16 + sizeY; |
||
483 | EDX = mainAreaType << 24 | mainAreaColour; |
||
484 | ESI = headerType << 24 | headerColour; |
||
485 | $xor eax,eax |
||
486 | $int 0x40 |
||
487 | } |
||
488 | |||
489 | inline fastcall dword CreateThread(dword ECX,EDX) |
||
490 | { |
||
491 | EAX = 51; |
||
492 | EBX = 1; |
||
493 | $int 0x40 |
||
494 | } |
||
495 | |||
496 | void WriteText(dword x,y,byte fontType, dword color, EDX, ESI) |
||
497 | { |
||
498 | EAX = 4; |
||
499 | EBX = x<<16+y; |
||
500 | ECX = fontType<<24+color; |
||
501 | $int 0x40; |
||
502 | } |
||
503 | |||
504 | void PutImage(dword EBX,w,h,x,y) |
||
505 | { |
||
506 | EAX = 7; |
||
507 | ECX = w<<16+h; |
||
508 | EDX = x<<16+y; |
||
509 | $int 0x40 |
||
510 | } |
||
511 | |||
512 | void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI) |
||
513 | { |
||
514 | EAX = 65; |
||
515 | ECX = w<<16+h; |
||
516 | EDX = x<<16+y; |
||
517 | EBP = 0; |
||
518 | $int 0x40 |
||
519 | } |
||
520 | |||
521 | inline fastcall void PutPixel(dword EBX,ECX,EDX){ |
||
522 | EAX=1; |
||
523 | $int 0x40 |
||
524 | } |
||
525 | |||
526 | void DrawBar(dword x,y,w,h,EDX) |
||
527 | { |
||
528 | EAX = 13; |
||
529 | EBX = x<<16+w; |
||
530 | ECX = y<<16+h; |
||
531 | $int 0x40 |
||
532 | } |
||
533 | |||
534 | void DefineButton(dword x,y,w,h,EDX,ESI) |
||
535 | { |
||
536 | EAX = 8; |
||
537 | EBX = x<<16+w; |
||
538 | ECX = y<<16+h; |
||
539 | $int 0x40 |
||
540 | } |
||
541 | |||
542 | inline fastcall void DeleteButton(dword EDX) |
||
543 | { |
||
544 | EAX = 8; |
||
545 | EDX += BT_DEL; |
||
546 | $int 0x40; |
||
547 | } |
||
548 | |||
549 | void DrawRegion(dword x,y,width,height,color1) |
||
550 | { |
||
551 | DrawBar(x,y,width,1,color1); //полоса гор сверху |
||
552 | DrawBar(x,y+height,width,1,color1); //полоса гор снизу |
||
553 | DrawBar(x,y,1,height,color1); //полоса верху слева |
||
554 | DrawBar(x+width,y,1,height+1,color1); //полоса верху справа |
||
555 | } |
||
556 | |||
557 | void DrawRegion_3D(dword x,y,width,height,color1,color2) |
||
558 | { |
||
559 | DrawBar(x,y,width+1,1,color1); //полоса гор сверху |
||
560 | DrawBar(x,y+1,1,height-1,color1); //полоса слева |
||
561 | DrawBar(x+width,y+1,1,height,color2); //полоса справа |
||
562 | DrawBar(x,y+height,width,1,color2); //полоса гор снизу |
||
563 | } |
||
564 | |||
565 | void DrawFlatButton(dword x,y,width,height,id,color,text) |
||
566 | { |
||
567 | DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE); |
||
568 | DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7); |
||
569 | DrawBar(x+2,y+2,width-3,height-3,color); //заливка |
||
570 | IF (id<>0) DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //кнопка |
||
571 | WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0); |
||
572 | } |
||
573 | |||
574 | void DrawCircle(int x, y, r) |
||
575 | { |
||
576 | int i; float px=0, py=r, ii = r * 3.1415926 * 2; |
||
577 | for (i = 0; i < ii; i++) |
||
578 | { |
||
579 | PutPixel(px + x, y - py, 0); |
||
580 | px = py / r + px; |
||
581 | py = -px / r + py; |
||
582 | //Pause(1); |
||
583 | } |
||
584 | } |
||
585 | |||
586 | //------------------------------------------------------------------------------ |
||
587 | |||
588 | inline fastcall dword WriteDebug(dword EDX) |
||
589 | { |
||
590 | $push ebx |
||
591 | $push ecx |
||
592 | $mov eax, 63 |
||
593 | $mov ebx, 1 |
||
594 | next_char: |
||
595 | $mov ecx, DSDWORD[edx] |
||
596 | $or cl, cl |
||
597 | $jz done |
||
598 | $int 0x40 |
||
599 | $inc edx |
||
600 | $jmp next_char |
||
601 | done: |
||
602 | $mov cl, 13 |
||
603 | $int 0x40 |
||
604 | $mov cl, 10 |
||
605 | $int 0x40 |
||
606 | $pop ecx |
||
607 | $pop ebx |
||
608 | }>>16+h; |