Rev 2496 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2496 | leency | 1 | //CODED by Veliant, Leency 2008-2012. GNU GPL licence. |
1722 | Rock_mania | 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; |
||
10 | dword alloc_mem = 0x00100000; |
||
11 | dword x86esp_reg = 0x00100000; // 0x0007fff0; |
||
12 | dword I_Param = #param; |
||
2054 | leency | 13 | dword I_Path = #program_path; |
2266 | leency | 14 | |
2054 | leency | 15 | char param[4096]=""; |
16 | char program_path[4096]=""; |
||
1722 | Rock_mania | 17 | |
2054 | leency | 18 | |
1722 | Rock_mania | 19 | //Events |
20 | #define evMouse 6 |
||
21 | #define evButton 3 |
||
22 | #define evKey 2 |
||
23 | #define evReDraw 1 |
||
24 | |||
25 | //Button options |
||
26 | #define BT_DEL 0x80000000 |
||
27 | #define BT_HIDE 0x40000000 |
||
28 | #define BT_NOFRAME 0x20000000 |
||
29 | |||
30 | #define OLD -1 |
||
31 | #define true 1 |
||
32 | #define false 0 |
||
33 | |||
34 | |||
35 | |||
36 | struct mouse{ |
||
2134 | leency | 37 | unsigned int x,y,lkm,pkm,hor,vert; |
38 | void get(); |
||
1722 | Rock_mania | 39 | }; |
40 | |||
2266 | leency | 41 | inline fastcall int TestBit(EAX, CL) |
2134 | leency | 42 | { |
43 | $shr eax,cl |
||
44 | $and eax,1 |
||
45 | } |
||
46 | |||
1722 | Rock_mania | 47 | void mouse::get() |
48 | { |
||
49 | EAX = 37; |
||
50 | EBX = 1; |
||
51 | $int 0x40 |
||
52 | $mov ebx, eax |
||
53 | $shr eax, 16 |
||
54 | $and ebx,0x0000FFFF |
||
55 | x = EAX; |
||
56 | y = EBX; |
||
2134 | leency | 57 | |
1722 | Rock_mania | 58 | EAX = 37; |
59 | EBX = 2; |
||
60 | $int 0x40 |
||
61 | $mov ebx, eax |
||
62 | $and eax, 0x00000001 |
||
63 | $shr ebx, 1 |
||
64 | $and ebx, 0x00000001 |
||
65 | lkm = EAX; |
||
66 | pkm = EBX; |
||
2134 | leency | 67 | |
68 | EAX = 37; //scroll |
||
1722 | Rock_mania | 69 | EBX = 7; |
70 | $int 0x40 |
||
71 | $mov ebx, eax |
||
72 | $shr eax, 16 |
||
73 | $and ebx,0x0000FFFF |
||
74 | //hor = EAX; |
||
75 | vert = EBX; |
||
76 | } |
||
77 | |||
78 | //--------------------------------------------------------------------------- |
||
79 | struct proc_info{ |
||
80 | dword use_cpu; |
||
81 | word pos_in_stack,num_slot,rezerv1; |
||
82 | char name[11]; |
||
83 | char rezerv2; |
||
84 | dword adress,use_memory,ID,left,top,width,height; |
||
85 | word status_slot,rezerv3; |
||
86 | dword work_left,work_top,work_width,work_height; |
||
87 | char status_window; |
||
88 | void GetInfo(dword ECX); |
||
89 | byte reserved[1024-71]; |
||
90 | #define SelfInfo -1 |
||
91 | }; |
||
92 | |||
2134 | leency | 93 | void proc_info::GetInfo(dword EBX, ECX) |
1722 | Rock_mania | 94 | { |
95 | EAX = 9; |
||
96 | $int 0x40 |
||
97 | } |
||
2134 | leency | 98 | |
2266 | leency | 99 | inline fastcall int GetSlot(dword ECX) |
2134 | leency | 100 | { |
101 | EAX = 18; |
||
102 | EBX = 21; |
||
103 | $int 0x40 |
||
104 | } |
||
105 | |||
2266 | leency | 106 | inline fastcall int ActiveProcess() |
2134 | leency | 107 | { |
108 | EAX = 18; |
||
109 | EBX = 7; |
||
110 | $int 0x40 |
||
111 | } |
||
112 | |||
1722 | Rock_mania | 113 | //------------------------------------------------------------------------------- |
114 | |||
115 | inline fastcall dword WaitEvent(){ |
||
2134 | leency | 116 | EAX = 10; // wait here for event |
117 | $int 0x40 |
||
1722 | Rock_mania | 118 | } |
119 | |||
120 | inline fastcall void SetEventMask(dword EBX) |
||
121 | { |
||
2134 | leency | 122 | EAX = 40; |
123 | $int 0x40 |
||
1722 | Rock_mania | 124 | } |
125 | |||
2134 | leency | 126 | inline fastcall word GetKey(){ //Gluk fix |
127 | $push edx |
||
128 | @getkey: |
||
129 | $mov eax,2 |
||
130 | $int 0x40 |
||
131 | $cmp eax,1 |
||
132 | $jne getkeyi |
||
133 | $mov ah,dh |
||
134 | $jmp getkeyii //jz? |
||
135 | @getkeyi: |
||
136 | $mov dh,ah |
||
137 | $jmp getkey |
||
138 | @getkeyii: |
||
139 | $pop edx |
||
140 | EAX = EAX >> 8; |
||
1722 | Rock_mania | 141 | } |
142 | |||
143 | inline fastcall word GetButtonID(){ |
||
2134 | leency | 144 | EAX = 17; // Get ID |
145 | $int 0x40 |
||
146 | EAX = EAX >> 8; |
||
1722 | Rock_mania | 147 | } |
148 | |||
149 | inline fastcall void ExitProcess(){ |
||
2134 | leency | 150 | EAX = -1; // close this program |
151 | $int 0x40 |
||
1722 | Rock_mania | 152 | } |
153 | |||
154 | inline fastcall void Pause(dword EBX){ |
||
155 | $mov eax, 5 //Пауза, в сотых долях секунды |
||
156 | $int 0x40 |
||
157 | } |
||
158 | |||
159 | //------------------------------------------------------------------------------ |
||
2266 | leency | 160 | void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType, |
161 | dword mainAreaColour,byte headerType,dword headerColour,EDI) |
||
1722 | Rock_mania | 162 | { |
2266 | leency | 163 | EAX = 12; // function 12:tell os about windowdraw |
2242 | leency | 164 | EBX = 1; |
165 | $int 0x40 |
||
2241 | leency | 166 | |
1722 | Rock_mania | 167 | EBX = x << 16 + sizeX; |
168 | ECX = y << 16 + sizeY; |
||
2266 | leency | 169 | EDX = mainAreaType << 24 | mainAreaColour; |
170 | ESI = headerType << 24 | headerColour; |
||
1722 | Rock_mania | 171 | $xor eax,eax |
172 | $int 0x40 |
||
2266 | leency | 173 | |
174 | EAX = 12; // function 12:tell os about windowdraw |
||
2242 | leency | 175 | EBX = 2; |
176 | $int 0x40 |
||
1722 | Rock_mania | 177 | } |
178 | |||
179 | inline fastcall void CreateThread(dword ECX,EDX) |
||
180 | { |
||
181 | EAX = 51; |
||
182 | EBX = 1; |
||
183 | $int 0x40 |
||
184 | } |
||
185 | |||
186 | inline fastcall void DrawTitle(dword ECX){ |
||
187 | EAX = 71; |
||
188 | EBX = 1; |
||
189 | $int 0x40; |
||
190 | } |
||
191 | |||
192 | inline fastcall dword GetSkinWidth(){ |
||
193 | EAX = 48; |
||
194 | EBX = 4; |
||
195 | $int 0x40 |
||
196 | } |
||
197 | |||
198 | inline fastcall void MoveSize(dword EBX,ECX,EDX,ESI){ |
||
199 | EAX = 67; |
||
200 | $int 0x40 |
||
201 | } |
||
202 | |||
203 | //------------------------------------------------------------------------------ |
||
204 | |||
205 | inline fastcall dword strlen(EDI){ |
||
206 | asm { |
||
207 | xor ecx, ecx |
||
208 | xor eax, eax |
||
209 | dec ecx |
||
210 | repne scasb |
||
211 | sub eax, 2 |
||
212 | sub eax, ecx |
||
213 | } |
||
214 | } |
||
215 | |||
216 | |||
217 | inline fastcall copystr(dword ESI,EDI) |
||
218 | { |
||
219 | $cld |
||
220 | l1: |
||
221 | $lodsb |
||
222 | $stosb |
||
223 | $test al,al |
||
224 | $jnz l1 |
||
225 | } |
||
226 | |||
227 | char buffer[11]=""; |
||
228 | inline fastcall dword IntToStr(dword ESI) |
||
229 | { |
||
230 | $mov edi, #buffer |
||
231 | $mov ecx, 10 |
||
232 | $test esi, esi |
||
233 | $jns f1 |
||
234 | $mov al, '-' |
||
235 | $stosb |
||
236 | $neg esi |
||
237 | f1: |
||
238 | $mov eax, esi |
||
239 | $push -'0' |
||
240 | f2: |
||
241 | $xor edx, edx |
||
242 | $div ecx |
||
243 | $push edx |
||
244 | $test eax, eax |
||
245 | $jnz f2 |
||
246 | f3: |
||
247 | $pop eax |
||
248 | $add al, '0' |
||
249 | $stosb |
||
250 | $jnz f3 |
||
251 | $mov eax, #buffer |
||
252 | $ret |
||
253 | } |
||
254 | |||
255 | inline fastcall int strcmp(ESI, EDI) |
||
256 | { |
||
257 | loop() |
||
258 | { |
||
259 | IF (DSBYTE[ESI] |
||
260 | IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1; |
||
261 | IF (DSBYTE[ESI]=='\0') RETURN 0; |
||
262 | ESI++; |
||
263 | EDI++; |
||
264 | } |
||
265 | } |
||
266 | |||
267 | |||
268 | inline fastcall unsigned int find_symbol(ESI,BL) |
||
269 | { |
||
270 | int jj=0, last=-1; |
||
271 | do{ |
||
272 | jj++; |
||
273 | $lodsb |
||
274 | IF(AL==BL) last=jj; |
||
275 | } while(AL!=0); |
||
276 | return last; |
||
277 | } |
||
278 | |||
279 | |||
280 | inline fastcall ChangeCase(dword EDX) |
||
281 | { |
||
282 | AL=DSBYTE[EDX]; |
||
283 | IF(AL>='a')&&(AL<='z')DSBYTE[EDX]=AL&0x5f; |
||
284 | IF (AL>=160) && (AL<=175) DSBYTE[EDX] = AL - 32; //р-я |
||
285 | IF (AL>=224) && (AL<=239) DSBYTE[EDX] = AL - 80; //р-я |
||
286 | do{ |
||
287 | EDX++; |
||
288 | AL=DSBYTE[EDX]; |
||
2054 | leency | 289 | IF(AL>='A')&&(AL<='Z'){DSBYTE[EDX]=AL|0x20; CONTINUE;} |
1722 | Rock_mania | 290 | IF(AL>='А')&&(AL<='П')DSBYTE[EDX]=AL|0x20; //а-п |
291 | IF (AL>=144) && (AL<=159) DSBYTE[EDX] = AL + 80; //р-я |
||
292 | }while(AL!=0); |
||
293 | } |
||
294 | |||
295 | |||
296 | //------------------------------------------------------------------------------ |
||
297 | inline fastcall void PutPixel(dword EBX,ECX,EDX){ |
||
298 | EAX=1; |
||
299 | $int 0x40 |
||
300 | } |
||
301 | |||
2528 | leency | 302 | void DefineButton(dword x,y,w,h,EDX,ESI) |
303 | { |
||
304 | EAX = 8; |
||
305 | $push edx |
||
306 | EDX += BT_DEL; //тэрўрых єфры хь ъэюяє ё ¤Єш шф, яюЄюь ёючфр╕ь |
||
307 | $int 0x40; |
||
1722 | Rock_mania | 308 | EBX = x<<16+w; |
309 | ECX = y<<16+h; |
||
2528 | leency | 310 | $pop edx |
1722 | Rock_mania | 311 | $int 0x40 |
312 | } |
||
313 | |||
314 | inline fastcall void DeleteButton(dword EDX) |
||
315 | { |
||
316 | EAX = 8; |
||
317 | EDX += BT_DEL; |
||
318 | $int 0x40; |
||
319 | } |
||
320 | |||
321 | void WriteText(dword x,y,byte fontType, dword color, EDX, ESI) |
||
322 | { |
||
323 | EAX = 4; |
||
324 | EBX = x<<16+y; |
||
325 | ECX = fontType<<24+color; |
||
326 | $int 0x40; |
||
327 | } |
||
328 | |||
329 | void DrawBar(dword x,y,w,h,EDX) |
||
330 | { |
||
331 | #speed |
||
332 | EAX = 13; |
||
333 | EBX = x<<16+w; |
||
334 | ECX = y<<16+h; |
||
335 | $int 0x40 |
||
336 | #codesize |
||
337 | } |
||
338 | |||
339 | void DrawRegion_3D(dword x,y,width,height,color1,color2) |
||
340 | { |
||
341 | DrawBar(x,y,width+1,1,color1); //полоса гор сверху |
||
342 | DrawBar(x,y+1,1,height-1,color1); //полоса слева |
||
343 | DrawBar(x+width,y+1,1,height,color2); //полоса справа |
||
344 | DrawBar(x,y+height,width,1,color2); //полоса гор снизу |
||
345 | } |
||
346 | |||
347 | void DrawFlatButton(dword x,y,width,height,id,color,text) |
||
348 | { |
||
349 | DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE); |
||
350 | DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7); |
||
351 | DrawBar(x+2,y+2,width-3,height-3,color); //заливка |
||
2134 | leency | 352 | IF (id<>0) DefineButton(x+1,y+1,width-2,height-2,id+BT_HIDE,0xEFEBEF); //кнопка |
1722 | Rock_mania | 353 | WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0); |
354 | } |
||
355 | |||
2134 | leency | 356 | void PutPaletteImage(dword EBX,w,h,x,y, EDI) |
1722 | Rock_mania | 357 | { |
2134 | leency | 358 | EAX = 65; |
1722 | Rock_mania | 359 | ECX = w<<16+h; |
360 | EDX = x<<16+y; |
||
2134 | leency | 361 | ESI = 8; |
362 | EBP = 0; |
||
1722 | Rock_mania | 363 | $int 0x40 |
2134 | leency | 364 | } |
1722 | Rock_mania | 365 | |
2134 | leency | 366 | void PutImage(dword EBX,w,h,x,y) |
1722 | Rock_mania | 367 | { |
2134 | leency | 368 | EAX = 7; |
1722 | Rock_mania | 369 | ECX = w<<16+h; |
370 | EDX = x<<16+y; |
||
371 | $int 0x40 |
||
2134 | leency | 372 | } |
1722 | Rock_mania | 373 | |
374 | //------------------------------------------------------------------------------ |
||
2266 | leency | 375 | inline fastcall void WriteDebug(dword EDX) |
1722 | Rock_mania | 376 | { |
377 | $mov eax, 63 |
||
378 | $mov ebx, 1 |
||
379 | next_char: |
||
380 | $mov ecx, DSDWORD[edx] |
||
381 | $or cl, cl |
||
382 | $jz done |
||
383 | $int 0x40 |
||
384 | $inc edx |
||
385 | $jmp next_char |
||
386 | done: |
||
387 | $mov cl, 13 |
||
388 | $int 0x40 |
||
389 | $mov cl, 10 |
||
390 | $int 0x40 |
||
391 | } |
||
2134 | leency | 392 | |
393 | inline fastcall void WriteFullDebug(dword ESI) |
||
394 | { |
||
395 | WriteDebug(""); |
||
396 | WriteDebug(ESI); |
||
397 | |||
398 | WriteDebug("Number of files:"); |
||
399 | WriteDebug(IntToStr(count)); |
||
400 | |||
401 | WriteDebug("but_num:"); |
||
402 | WriteDebug(IntToStr(but_num)); |
||
403 | |||
404 | WriteDebug("curbtn"); |
||
405 | WriteDebug(IntToStr(curbtn)); |
||
406 | |||
407 | WriteDebug("ra_kadrom:"); |
||
408 | WriteDebug(IntToStr(za_kadrom)); |
||
409 | |||
410 | Pause(200); |
||
2266 | leency | 411 | }16+y; |