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