Rev 7988 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4812 | eAndrew | 1 | use32 |
2 | org 0 |
||
10017 | Doczom | 3 | db 'MENUET01' |
4 | dd 1, @ENTRY, @end, @memory, @stack |
||
5 | M01header.params: |
||
6 | dd @params, 0 |
||
4812 | eAndrew | 7 | |
8 | include "../../macros.inc" |
||
9 | include "../../proc32.inc" |
||
10 | include "../../dll.inc" |
||
5889 | eAndrew | 11 | ; include "../../debug.inc" |
5892 | eAndrew | 12 | include "../../string.inc" |
7785 | leency | 13 | |
14 | include "notify.inc" |
||
4812 | eAndrew | 15 | |
10017 | Doczom | 16 | LINEH equ 12 |
5892 | eAndrew | 17 | MARGIN equ 12 |
10017 | Doczom | 18 | ICONS equ 11 |
4812 | eAndrew | 19 | |
5892 | eAndrew | 20 | ;------------------------------------------------------------------------------- |
4812 | eAndrew | 21 | |
5892 | eAndrew | 22 | @ENTRY: |
23 | ;; INIT HEAP |
||
24 | mcall 68, 11 |
||
4812 | eAndrew | 25 | |
5892 | eAndrew | 26 | ;; SAVE FOCUSED WINDOW |
5868 | eAndrew | 27 | mcall 18, 7 |
28 | mov ecx, eax |
||
29 | mcall 9, buffer |
||
5892 | eAndrew | 30 | m2m dword [prev_pid], dword [buffer + 30] |
5868 | eAndrew | 31 | |
5892 | eAndrew | 32 | ;; MAKE IT ALWAYS ON TOP |
5868 | eAndrew | 33 | mcall 18, 25, 2, -1, 1 |
34 | |||
5892 | eAndrew | 35 | ;; SET STD PARAMS, IF IT NEEDS |
10017 | Doczom | 36 | mov eax, [M01header.params] |
37 | cmpne byte [eax], 0, @f |
||
5889 | eAndrew | 38 | mov eax, sz_std |
4812 | eAndrew | 39 | @@: |
5892 | eAndrew | 40 | mov [params.source], eax |
4812 | eAndrew | 41 | |
5892 | eAndrew | 42 | ;; PARSE ARGUMENTS |
43 | mov esi, 0 |
||
5889 | eAndrew | 44 | call parse_text |
5892 | eAndrew | 45 | call parse_flags |
46 | movzx ebx, [params.icon] |
||
4812 | eAndrew | 47 | |
5892 | eAndrew | 48 | ;; GET PID |
49 | mcall 9, buffer, -1 |
||
50 | mov eax, dword [buffer + 30] |
||
4812 | eAndrew | 51 | |
5892 | eAndrew | 52 | ;; CONVERT PID TO STR |
53 | mov ebx, 10 |
||
54 | mov ecx, 0 |
||
55 | @@: |
||
56 | mov edx, 0 |
||
57 | div ebx |
||
58 | push edx |
||
59 | inc ecx |
||
60 | cmpne eax, 0, @b |
||
5868 | eAndrew | 61 | |
5892 | eAndrew | 62 | mov ebx, ctrl.name |
5868 | eAndrew | 63 | @@: |
5892 | eAndrew | 64 | pop eax |
65 | add al, "0" |
||
66 | mov [ebx], al |
||
4812 | eAndrew | 67 | inc ebx |
5892 | eAndrew | 68 | loop @b |
4812 | eAndrew | 69 | |
5892 | eAndrew | 70 | mov dword [ebx + 0], "-NOT" |
71 | mov dword [ebx + 4], "IFY" |
||
4812 | eAndrew | 72 | |
5892 | eAndrew | 73 | ;; LOAD LIBRARIES |
4812 | eAndrew | 74 | stdcall dll.Load, @imports |
75 | |||
5892 | eAndrew | 76 | ;; GET SIZE OF ICONS |
4812 | eAndrew | 77 | mcall 70, fi |
78 | mov edx, dword [buffer + 32] |
||
79 | shl edx, 2 |
||
5892 | eAndrew | 80 | |
81 | ;; ALLOCATE MEMORY FOR THIS |
||
4812 | eAndrew | 82 | stdcall mem.Alloc, edx |
7988 | leency | 83 | mov [img_data.file], eax |
4812 | eAndrew | 84 | |
5892 | eAndrew | 85 | ;; READ ICONS |
4812 | eAndrew | 86 | mov dword [fi + 00], 0 |
87 | mov dword [fi + 12], edx |
||
5892 | eAndrew | 88 | mov dword [fi + 16], eax |
4812 | eAndrew | 89 | mcall 70, fi |
90 | |||
5892 | eAndrew | 91 | ;; DECODE ICONS |
7988 | leency | 92 | stdcall dword [img.decode], dword [img_data.file], ebx, 0 |
4812 | eAndrew | 93 | mov dword [img_data.obj], eax |
94 | |||
5892 | eAndrew | 95 | ;; CALC HEIGHT |
4812 | eAndrew | 96 | mov eax, [text.lines] |
97 | add eax, 2 |
||
98 | imul eax, LINEH |
||
99 | mov [window.height], eax |
||
100 | |||
5892 | eAndrew | 101 | ;; CALC OFFSET OF TEXT |
102 | mov dword [text.offset], MARGIN |
||
103 | cmpe byte [params.icon], 0, @f |
||
104 | add dword [text.offset], MARGIN + 24 |
||
105 | @@: |
||
106 | |||
107 | ;; CALC WIDTH |
||
4812 | eAndrew | 108 | mov eax, [text.max_len] |
109 | imul eax, 6 |
||
5892 | eAndrew | 110 | add eax, MARGIN |
111 | add eax, [text.offset] |
||
4812 | eAndrew | 112 | mov [window.width], eax |
113 | |||
114 | mcall 14 |
||
115 | mov ebx, eax |
||
5892 | eAndrew | 116 | movzx ebx, bx |
4812 | eAndrew | 117 | mov [scr.height], ebx |
118 | shr eax, 16 |
||
119 | mov [scr.width], eax |
||
120 | sub eax, [window.width] |
||
121 | sub eax, LINEH |
||
122 | mov [window.x], eax |
||
123 | |||
5900 | eAndrew | 124 | ;; CALC PBAR |
125 | mov eax, [window.width] |
||
126 | sub eax, [text.offset] |
||
127 | sub eax, MARGIN |
||
128 | mov [pbar.width], eax |
||
129 | |||
5892 | eAndrew | 130 | ;; CALC Y |
131 | mcall 68, 22, sz_shname, 256 + 512, 4 + 1 ;OPEN_ALWAYS AND WRITE |
||
4812 | eAndrew | 132 | add eax, 512 |
133 | mov [shm], eax |
||
134 | |||
135 | s_search: |
||
136 | mov eax, [shm] |
||
137 | |||
138 | mov ebx, 0 |
||
139 | mov ecx, [text.lines] |
||
140 | add ecx, 3 |
||
141 | |||
142 | push eax ebx |
||
143 | |||
144 | mov eax, [scr.height] |
||
145 | mov edx, 0 |
||
146 | mov ebx, LINEH |
||
147 | div ebx |
||
148 | mov edx, eax |
||
149 | add edx, [shm] |
||
150 | sub edx, ecx |
||
151 | inc edx |
||
152 | |||
153 | pop ebx eax |
||
154 | |||
155 | s_area: |
||
156 | cmpe [eax], byte 1, .is_1 |
||
157 | |||
5892 | eAndrew | 158 | .is_0: |
4812 | eAndrew | 159 | inc ebx |
160 | cmpe ebx, ecx, s_ok |
||
161 | jmp .next |
||
162 | |||
5892 | eAndrew | 163 | .is_1: |
4812 | eAndrew | 164 | mov ebx, 0 |
165 | |||
5892 | eAndrew | 166 | .next: |
4812 | eAndrew | 167 | inc eax |
168 | cmple eax, edx, s_area |
||
169 | |||
170 | mcall 5, 10 |
||
171 | jmp s_search |
||
172 | |||
173 | s_ok: |
||
174 | sub eax, ecx |
||
175 | inc eax |
||
176 | mov [shm.our], eax |
||
177 | |||
178 | mov edx, eax |
||
179 | sub edx, [shm] |
||
180 | inc edx |
||
181 | imul edx, LINEH |
||
182 | mov [window.y], edx |
||
183 | |||
4877 | eAndrew | 184 | push eax ebx |
185 | mcall 48, 5 |
||
186 | shr ebx, 16 |
||
187 | add [window.y], ebx |
||
188 | pop ebx eax |
||
189 | |||
4812 | eAndrew | 190 | @@: |
191 | mov [eax], byte 1 |
||
192 | inc eax |
||
193 | loop @b |
||
194 | |||
195 | ;---------------------------- |
||
196 | |||
5892 | eAndrew | 197 | ;; SET EVENT MASK |
198 | mcall 40, 101b |
||
199 | |||
200 | ;; INIT TIMER |
||
4812 | eAndrew | 201 | mov eax, 60 |
202 | imul eax, [text.lines] |
||
203 | mov [timer], eax |
||
5892 | eAndrew | 204 | mov dword [timer.step], 1 |
205 | cmpne byte [params.atcl], 1, @f |
||
206 | mov dword [timer.step], 0 |
||
4812 | eAndrew | 207 | @@: |
208 | |||
5892 | eAndrew | 209 | ;; INIT WINDOW |
5868 | eAndrew | 210 | call init_window |
211 | |||
5892 | eAndrew | 212 | ;; RESTORE FOCUS |
5868 | eAndrew | 213 | mcall 18, 21, [prev_pid] |
214 | mov ecx, eax |
||
215 | mcall 18, 3 |
||
216 | |||
217 | jmp redraw |
||
218 | |||
219 | ;---------------------------- |
||
220 | |||
4812 | eAndrew | 221 | update: |
222 | mcall 23, 10 |
||
223 | cmpe al, EV_REDRAW, redraw |
||
5892 | eAndrew | 224 | cmpe al, EV_BUTTON, button |
4812 | eAndrew | 225 | |
5892 | eAndrew | 226 | mov edi, update |
227 | |||
228 | ;; TRY OPEN CONTROLLER |
||
229 | cmpe byte [params.ctrl], 1, .fail_controller_open |
||
230 | mcall 68, 22, ctrl.name, , 0x01 |
||
231 | cmpe eax, 0, .fail_controller_open |
||
232 | mov byte [params.ctrl], 1 |
||
233 | mov [ctrl.addr], eax |
||
234 | |||
235 | ;; COPY TEXT TO CTRL |
||
236 | add eax, NTCTRL_TEXT |
||
237 | mov ebx, text.buffer |
||
5900 | eAndrew | 238 | |
5892 | eAndrew | 239 | mov ecx, [text.lines] |
5900 | eAndrew | 240 | cmpne byte [params.pbar], 1, @f |
241 | dec ecx |
||
242 | @@: |
||
243 | |||
5892 | eAndrew | 244 | .copy_start: |
245 | cmpe ecx, 0, .copy_end |
||
246 | mov dl, [ebx] |
||
247 | cmpne dl, 0, @f |
||
5900 | eAndrew | 248 | mov dl, 10 |
5892 | eAndrew | 249 | dec ecx |
250 | @@: |
||
251 | mov [eax], dl |
||
252 | inc eax |
||
253 | inc ebx |
||
254 | jmp .copy_start |
||
255 | .copy_end: |
||
256 | mov byte [eax - 1], 0 |
||
257 | |||
258 | ;; COPY FLAGS TO CTRL |
||
259 | mov eax, [ctrl.addr] |
||
260 | add eax, NTCTRL_ICON |
||
261 | mov dl, [params.icon] |
||
262 | mov [eax], dl |
||
263 | |||
264 | mov eax, [ctrl.addr] |
||
265 | add eax, NTCTRL_TITLE |
||
266 | mov dl, [params.title] |
||
267 | mov [eax], dl |
||
268 | |||
269 | ;; SET CONTROLLER READY |
||
270 | mov eax, [ctrl.addr] |
||
271 | add eax, NTCTRL_READY |
||
272 | mov byte [eax], 1 |
||
273 | .fail_controller_open: |
||
274 | |||
275 | |||
276 | cmpe [params.ctrl], 0, .no_ctrl |
||
277 | ;; TEST TEXT |
||
278 | mov eax, [ctrl.addr] |
||
279 | add eax, NTCTRL_APPLY_TEXT |
||
280 | cmpne byte [eax], 1, @f |
||
281 | mov byte [eax], 0 |
||
5900 | eAndrew | 282 | |
5892 | eAndrew | 283 | mov eax, [ctrl.addr] |
284 | add eax, NTCTRL_TEXT |
||
285 | mov esi, 1 |
||
286 | call parse_text |
||
5900 | eAndrew | 287 | |
5892 | eAndrew | 288 | mov edi, redraw |
289 | @@: |
||
290 | |||
291 | ;; TEST ICON |
||
292 | mov eax, [ctrl.addr] |
||
293 | add eax, NTCTRL_APPLY_ICON |
||
294 | cmpne byte [eax], 1, @f |
||
5900 | eAndrew | 295 | mov byte [eax], 0 |
296 | |||
5892 | eAndrew | 297 | mov eax, [ctrl.addr] |
298 | add eax, NTCTRL_ICON |
||
299 | mov dl, [eax] |
||
300 | mov [params.icon], dl |
||
5900 | eAndrew | 301 | |
302 | mov edi, redraw |
||
5892 | eAndrew | 303 | @@: |
304 | |||
305 | ;; TEST TITLE |
||
306 | mov eax, [ctrl.addr] |
||
307 | add eax, NTCTRL_APPLY_TITLE |
||
308 | cmpne byte [eax], 1, @f |
||
5900 | eAndrew | 309 | mov byte [eax], 0 |
310 | |||
5892 | eAndrew | 311 | mov eax, [ctrl.addr] |
312 | add eax, NTCTRL_TITLE |
||
313 | mov dl, [eax] |
||
314 | mov [params.title], dl |
||
5900 | eAndrew | 315 | |
316 | mov edi, redraw |
||
5892 | eAndrew | 317 | @@: |
318 | |||
5900 | eAndrew | 319 | ;; TEST PBAR |
320 | mov eax, [ctrl.addr] |
||
321 | add eax, NTCTRL_APPLY_PBAR |
||
322 | cmpne byte [eax], 1, @f |
||
323 | mov byte [eax], 0 |
||
324 | |||
325 | mov eax, [ctrl.addr] |
||
326 | add eax, NTCTRL_PBAR_CUR |
||
327 | mov edx, [eax] |
||
328 | mov [pbar.cur_val], edx |
||
329 | |||
330 | mov eax, [ctrl.addr] |
||
331 | add eax, NTCTRL_PBAR_MAX |
||
332 | mov edx, [eax] |
||
333 | mov [pbar.max_val], edx |
||
334 | |||
335 | call calc_fill_width |
||
336 | |||
337 | mov edi, redraw |
||
338 | @@: |
||
339 | |||
5892 | eAndrew | 340 | ;; TEST CLOSE |
341 | mov eax, [ctrl.addr] |
||
342 | add eax, NTCTRL_CLOSE |
||
343 | cmpe byte [eax], 1, exit |
||
344 | |||
345 | .no_ctrl: |
||
346 | |||
4812 | eAndrew | 347 | mov eax, [timer.step] |
348 | sub [timer], eax |
||
5892 | eAndrew | 349 | cmpe [timer], dword 0, exit |
350 | jmp edi |
||
4812 | eAndrew | 351 | |
352 | ;---------------------------- |
||
353 | |||
354 | exit: |
||
355 | mov eax, [shm.our] |
||
356 | mov ecx, [text.lines] |
||
357 | add ecx, 3 |
||
358 | @@: |
||
359 | mov [eax], byte 0 |
||
360 | inc eax |
||
361 | loop @b |
||
362 | |||
363 | mcall 68, 23, sz_shname |
||
364 | |||
365 | mcall -1 |
||
366 | |||
367 | ;---------------------------- |
||
368 | |||
5892 | eAndrew | 369 | button: |
370 | mcall 17 |
||
371 | cmpe byte [params.clcl], 0, exit |
||
372 | jmp update |
||
5476 | eAndrew | 373 | |
374 | ;---------------------------- |
||
375 | |||
4812 | eAndrew | 376 | redraw: |
377 | call draw_window |
||
378 | call draw_text |
||
5900 | eAndrew | 379 | call draw_pbar |
4812 | eAndrew | 380 | |
381 | jmp update |
||
382 | |||
383 | ;---------------------------- |
||
384 | |||
385 | draw_window: |
||
5868 | eAndrew | 386 | call init_window |
4812 | eAndrew | 387 | |
5892 | eAndrew | 388 | movzx ebx, bx |
389 | movzx ecx, cx |
||
4812 | eAndrew | 390 | inc ebx |
391 | inc ecx |
||
392 | mcall 8, , , 0x61000001 |
||
393 | |||
394 | mov eax, 13 |
||
395 | mov ebx, [window.width] |
||
396 | mov edx, 0x222222 |
||
5868 | eAndrew | 397 | |
4812 | eAndrew | 398 | cmpe [first_draw], byte 1, .draw_full |
399 | mov [first_draw], byte 1 |
||
400 | mov esi, [window.height] |
||
401 | mov ecx, LINEH |
||
402 | @@: |
||
403 | mcall |
||
404 | add ecx, LINEH shl 16 |
||
405 | sub esi, LINEH |
||
406 | push eax ebx |
||
407 | mcall 5, 1 |
||
408 | pop ebx eax |
||
409 | cmpne esi, 0, @b |
||
5868 | eAndrew | 410 | |
5892 | eAndrew | 411 | .draw_full: |
4812 | eAndrew | 412 | mcall |
413 | |||
414 | mcall , , 1, 0x121212 |
||
415 | |||
416 | mov ecx, [window.height] |
||
417 | dec ecx |
||
418 | shl ecx, 16 |
||
419 | inc ecx |
||
420 | mcall |
||
421 | |||
422 | mcall , 1, [window.width] |
||
423 | |||
424 | mov ebx, [window.width] |
||
425 | dec ebx |
||
426 | shl ebx, 16 |
||
427 | inc ebx |
||
428 | mcall |
||
429 | |||
430 | mcall 1, 1, 1 |
||
431 | mov ebx, [window.width] |
||
432 | sub ebx, 2 |
||
433 | mcall |
||
434 | mov ecx, [window.height] |
||
435 | sub ecx, 2 |
||
436 | mcall |
||
437 | mov ebx, 1 |
||
438 | mcall |
||
439 | |||
440 | ;----- |
||
441 | |||
442 | mov ecx, [scr.width] |
||
443 | inc ecx |
||
444 | |||
445 | mov eax, 35 |
||
446 | mov ebx, ecx |
||
447 | imul ebx, [window.y] |
||
448 | add ebx, [window.x] |
||
449 | dec ebx |
||
450 | mcall |
||
451 | push eax |
||
452 | |||
453 | mov eax, 35 |
||
454 | add ebx, [window.width] |
||
455 | add ebx, 2 |
||
456 | mcall |
||
457 | push eax |
||
458 | |||
459 | mov eax, 35 |
||
460 | mov edx, ecx |
||
461 | mov esi, [window.height] |
||
462 | dec esi |
||
463 | imul edx, esi |
||
464 | add ebx, edx |
||
465 | mcall |
||
466 | push eax |
||
467 | |||
468 | mov eax, 35 |
||
469 | sub ebx, [window.width] |
||
470 | sub ebx, 2 |
||
471 | mcall |
||
472 | push eax |
||
473 | |||
474 | ;----- |
||
475 | |||
476 | mov eax, 1 |
||
477 | |||
478 | pop edx |
||
479 | mov ecx, [window.height] |
||
480 | dec ecx |
||
481 | mcall , 0 |
||
482 | |||
483 | pop edx |
||
484 | mov ebx, [window.width] |
||
485 | dec ebx |
||
486 | mcall |
||
487 | |||
488 | pop edx |
||
489 | mcall , , 0 |
||
490 | |||
491 | pop edx |
||
492 | mcall , 0 |
||
493 | |||
494 | ;----- |
||
495 | |||
5892 | eAndrew | 496 | cmpe byte [params.icon], 0, @f |
497 | movzx ebx, byte [params.icon] |
||
4812 | eAndrew | 498 | dec ebx |
7988 | leency | 499 | imul ebx, 24 |
4812 | eAndrew | 500 | |
501 | mov edx, [window.height] |
||
502 | shr edx, 1 |
||
503 | sub edx, 12 |
||
10017 | Doczom | 504 | |
505 | stdcall dword [img.draw], dword [img_data.obj], 12, edx, 24, 24, 0, ebx |
||
4812 | eAndrew | 506 | @@: |
507 | |||
508 | ret |
||
509 | |||
510 | ;---------------------------- |
||
511 | |||
512 | draw_text: |
||
513 | mov esi, [text.lines] |
||
514 | |||
5900 | eAndrew | 515 | cmpne byte [params.pbar], 1, @f |
516 | dec esi |
||
517 | @@: |
||
518 | |||
4812 | eAndrew | 519 | mov eax, 4 |
520 | mov ebx, [text.offset] |
||
521 | shl ebx, 16 |
||
522 | add ebx, LINEH + (LINEH - 6) / 2 |
||
523 | mov edx, text.buffer |
||
524 | |||
5892 | eAndrew | 525 | .draw_lines: |
4812 | eAndrew | 526 | mov ecx, 0x80111111 |
527 | |||
528 | add ebx, 0x00010000 |
||
529 | dec ebx |
||
530 | mcall |
||
531 | add ebx, 2 |
||
532 | mcall |
||
533 | sub ebx, 0x00020000 |
||
534 | mcall |
||
535 | sub ebx, 2 |
||
536 | mcall |
||
537 | |||
538 | add ebx, 0x00010001 |
||
539 | mov ecx, 0x80D0D0D0 |
||
540 | mcall |
||
541 | |||
542 | add ebx, LINEH |
||
543 | dec esi |
||
544 | cmpe esi, 0, .draw_lines.end |
||
545 | |||
546 | inc edx |
||
547 | @@: |
||
548 | cmpe [edx], byte 0, @f |
||
549 | inc edx |
||
550 | jmp @b |
||
551 | @@: |
||
552 | inc edx |
||
553 | jmp .draw_lines |
||
554 | |||
5892 | eAndrew | 555 | .draw_lines.end: |
4812 | eAndrew | 556 | |
5892 | eAndrew | 557 | cmpne byte [params.title], 1, @f |
4812 | eAndrew | 558 | mov edx, text.buffer |
559 | mov ecx, 0x80111111 |
||
560 | and ebx, 0xFFFF0000 |
||
561 | add ebx, 1 shl 16 + LINEH + (LINEH - 6) / 2 |
||
562 | mcall |
||
563 | |||
564 | mov ecx, 0x80FFFFFF |
||
565 | sub ebx, 0x00010000 |
||
566 | mcall |
||
567 | @@: |
||
568 | |||
569 | ret |
||
5868 | eAndrew | 570 | |
4812 | eAndrew | 571 | ;---------------------------- |
572 | |||
5900 | eAndrew | 573 | draw_pbar: |
574 | cmpne byte [params.pbar], 1, .exit |
||
575 | mov esi, 0xFF0000 |
||
576 | mov ecx, LINEH |
||
577 | imul ecx, [text.lines] |
||
578 | shl ecx, 16 |
||
579 | add ecx, (LINEH / 2) shl 16 + 8 |
||
580 | mcall 13, <[text.offset], [pbar.width]>, , 0x555555 |
||
581 | |||
582 | sub ecx, -(1 shl 16) + 2 |
||
583 | |||
584 | mov bx, word [pbar.f_width] |
||
585 | add ebx, 1 shl 16 |
||
586 | |||
587 | mcall , , , 0x999999 |
||
588 | mov cx, 1 |
||
589 | mcall , , , 0xAAAAAA |
||
590 | mov cx, 6 |
||
591 | mov bx, 1 |
||
592 | mcall |
||
593 | .exit: |
||
594 | ret |
||
595 | |||
596 | ;---------------------------- |
||
597 | |||
5868 | eAndrew | 598 | init_window: |
599 | dec dword [window.width] |
||
600 | dec dword [window.height] |
||
601 | mcall 0, <[window.x], [window.width]>, <[window.y], [window.height]>, 0x61000000 |
||
602 | inc dword [window.width] |
||
603 | inc dword [window.height] |
||
604 | |||
605 | ret |
||
606 | |||
607 | ;---------------------------- |
||
608 | |||
5889 | eAndrew | 609 | parse_text: |
5900 | eAndrew | 610 | mov dword [text.lines], 1 |
611 | cmpne byte [params.pbar], 1, @f |
||
612 | inc dword [text.lines] |
||
613 | @@: |
||
614 | |||
5889 | eAndrew | 615 | mov dword [text.max_len], 0 |
616 | mov ebx, text.buffer |
||
617 | mov ecx, 0 |
||
618 | mov dl, 0 |
||
619 | mov dh, 0 |
||
620 | |||
5892 | eAndrew | 621 | cmpe esi, 1, .parse_loop |
5889 | eAndrew | 622 | cmpne byte [eax], "'", @f |
623 | mov dl, "'" |
||
624 | mov dh, 1 |
||
625 | @@: |
||
626 | cmpne byte [eax], '"', @f |
||
627 | mov dl, '"' |
||
628 | mov dh, 1 |
||
629 | @@: |
||
630 | cmpne dh, 1, @f |
||
631 | inc eax |
||
632 | @@: |
||
633 | |||
5892 | eAndrew | 634 | .parse_loop: |
5889 | eAndrew | 635 | cmpe byte [eax], 0, .parse_loop.end |
636 | cmpe byte [eax], dl, .parse_loop.end |
||
637 | |||
638 | cmpe byte [eax], 10, .newline |
||
5892 | eAndrew | 639 | cmpe esi, 1, .next_set_char |
640 | cmpne byte [eax], "\", @f |
||
641 | cmpe byte [eax + 1], dl, .quote |
||
642 | cmpe byte [eax + 1], "n", .newline_esc |
||
643 | jmp @f |
||
5889 | eAndrew | 644 | |
5892 | eAndrew | 645 | .quote: |
5889 | eAndrew | 646 | inc eax |
5892 | eAndrew | 647 | jmp .next_set_char |
5889 | eAndrew | 648 | |
5892 | eAndrew | 649 | .newline_esc: |
650 | inc eax |
||
651 | |||
652 | .newline: |
||
5889 | eAndrew | 653 | mov byte [ebx], 0 |
654 | cmple ecx, dword [text.max_len], .skip_max_len |
||
655 | mov dword [text.max_len], ecx |
||
5892 | eAndrew | 656 | .skip_max_len: |
5889 | eAndrew | 657 | mov ecx, 0 |
658 | inc dword [text.lines] |
||
659 | jmp .next |
||
660 | @@: |
||
661 | |||
5892 | eAndrew | 662 | .next_set_char: |
663 | mov dh, [eax] |
||
5889 | eAndrew | 664 | mov [ebx], dh |
665 | |||
5892 | eAndrew | 666 | .next: |
5889 | eAndrew | 667 | inc eax |
668 | inc ebx |
||
669 | inc ecx |
||
670 | jmp .parse_loop |
||
5892 | eAndrew | 671 | .parse_loop.end: |
5889 | eAndrew | 672 | |
673 | cmple ecx, dword [text.max_len], @f |
||
674 | mov dword [text.max_len], ecx |
||
675 | @@: |
||
676 | |||
677 | cmpge [text.max_len], dword 25, @f |
||
678 | mov [text.max_len], dword 25 |
||
679 | @@: |
||
680 | |||
681 | mov [ebx], byte 0 |
||
682 | |||
683 | ret |
||
684 | |||
685 | ;---------------------------- |
||
686 | |||
5892 | eAndrew | 687 | parse_flags: |
688 | mov byte [params.atcl], 0 |
||
689 | mov byte [params.title], 0 |
||
690 | mov byte [params.icon], 0 |
||
691 | |||
692 | .loop: |
||
693 | mov dl, [eax] |
||
694 | |||
695 | cmpe dl, 0, .exit |
||
696 | cmpe dl, "d", .set_atcl |
||
697 | cmpe dl, "c", .set_clcl |
||
698 | cmpe dl, "t", .set_title |
||
5900 | eAndrew | 699 | cmpe dl, "p", .set_pbar |
5892 | eAndrew | 700 | |
701 | mov bl, 1 |
||
702 | mov ecx, sz_icons |
||
703 | @@: |
||
704 | cmpe dl, [ecx], .set_icon |
||
705 | inc bl |
||
706 | inc ecx |
||
707 | cmpne [ecx], byte 0, @b |
||
708 | jmp .next_char |
||
709 | |||
710 | .set_atcl: |
||
711 | mov byte [params.atcl], 1 |
||
712 | jmp .next_char |
||
713 | |||
714 | .set_clcl: |
||
715 | mov byte [params.clcl], 1 |
||
716 | jmp .next_char |
||
717 | |||
718 | .set_title: |
||
719 | mov byte [params.title], 1 |
||
720 | jmp .next_char |
||
721 | |||
5900 | eAndrew | 722 | .set_pbar: |
723 | mov byte [params.pbar], 1 |
||
724 | inc dword [text.lines] |
||
725 | jmp .next_char |
||
726 | |||
5892 | eAndrew | 727 | .set_icon: |
728 | mov [params.icon], bl |
||
729 | |||
730 | .next_char: |
||
731 | inc eax |
||
732 | jmp .loop |
||
733 | |||
734 | .exit: |
||
735 | ret |
||
736 | |||
737 | ;---------------------------- |
||
738 | |||
5900 | eAndrew | 739 | calc_fill_width: |
740 | mov eax, [pbar.cur_val] |
||
741 | cmpng eax, [pbar.max_val], @f |
||
742 | mov eax, [pbar.max_val] |
||
743 | @@: |
||
744 | cmpnl eax, 0, @f |
||
745 | mov eax, 0 |
||
746 | @@: |
||
747 | |||
748 | mov ebx, [pbar.width] |
||
749 | sub ebx, 2 |
||
750 | imul eax, ebx |
||
751 | mov edx, 0 |
||
752 | mov ebx, [pbar.max_val] |
||
753 | div ebx |
||
754 | mov [pbar.f_width], eax |
||
755 | ret |
||
756 | |||
757 | ;---------------------------- |
||
758 | |||
4812 | eAndrew | 759 | @imports: |
760 | library img, "libimg.obj" |
||
5892 | eAndrew | 761 | import img, img.to_rgb, "img_to_rgb2", \ |
10017 | Doczom | 762 | img.decode, "img_decode", \ |
763 | img.draw, "img_draw" |
||
4812 | eAndrew | 764 | |
765 | ;---------------------------- |
||
766 | |||
5868 | eAndrew | 767 | sz_icons db "AEWONIFCMDS", 0 |
4812 | eAndrew | 768 | sz_ifile db "/sys/notify3.png", 0 |
769 | sz_shname db "notify-mem-v01", 0 |
||
5892 | eAndrew | 770 | sz_std db "'NOTIFY 3\n", \ |
10017 | Doczom | 771 | "d - disable auto-closing\n", \ |
772 | "c - disable click-closing\n", \ |
||
773 | "p - use progressbar\n", \ |
||
774 | "t - title\n", \ |
||
775 | " \n", \ |
||
776 | "ICONS:\n", \ |
||
777 | "A - application\n", \ |
||
778 | "E - error\n", \ |
||
779 | "W - warning\n", \ |
||
780 | "O - ok\n", \ |
||
781 | "N - network\n", \ |
||
782 | "I - info\n", \ |
||
783 | "F - folder\n", \ |
||
784 | "C - component\n", \ |
||
785 | "M - mail\n", \ |
||
786 | "D - download\n", \ |
||
787 | "S - audio player", \ |
||
788 | "' -td", 0 |
||
4812 | eAndrew | 789 | |
5892 | eAndrew | 790 | fi: |
10017 | Doczom | 791 | dd 5 |
792 | dd 0, 0, 0 |
||
793 | dd buffer |
||
794 | db 0 |
||
795 | dd sz_ifile |
||
5892 | eAndrew | 796 | |
4812 | eAndrew | 797 | ;---------------------------- |
798 | |||
799 | @end: |
||
800 | |||
801 | ;===================================================================== |
||
802 | |||
803 | window: |
||
10017 | Doczom | 804 | .x rd 1 |
805 | .y rd 1 |
||
5892 | eAndrew | 806 | .width rd 1 |
807 | .height rd 1 |
||
4812 | eAndrew | 808 | |
809 | scr: |
||
5892 | eAndrew | 810 | .width rd 1 |
811 | .height rd 1 |
||
4812 | eAndrew | 812 | |
813 | text: |
||
5892 | eAndrew | 814 | .buffer rb 2048 |
815 | .lines rd 1 |
||
816 | .max_len rd 1 |
||
817 | .offset rd 1 |
||
4812 | eAndrew | 818 | |
819 | params: |
||
5892 | eAndrew | 820 | .source rd 1 |
10017 | Doczom | 821 | .atcl rb 1 |
822 | .clcl rb 1 |
||
5892 | eAndrew | 823 | .title rb 1 |
10017 | Doczom | 824 | .pbar rb 1 |
825 | .icon rb 1 |
||
826 | .ctrl rb 1 |
||
4812 | eAndrew | 827 | |
828 | img_data: |
||
7988 | leency | 829 | .file rd 1 |
10017 | Doczom | 830 | .obj rd 1 |
4812 | eAndrew | 831 | |
832 | timer: |
||
5892 | eAndrew | 833 | .value rd 1 |
10017 | Doczom | 834 | .step rd 1 |
4812 | eAndrew | 835 | |
836 | shm: |
||
10017 | Doczom | 837 | .addr rd 1 |
838 | .our rd 1 |
||
4812 | eAndrew | 839 | |
5892 | eAndrew | 840 | ctrl: |
10017 | Doczom | 841 | .name rb 31 |
842 | .addr rd 1 |
||
5892 | eAndrew | 843 | |
5900 | eAndrew | 844 | pbar: |
845 | .width rd 1 |
||
846 | .cur_val rd 1 |
||
847 | .max_val rd 1 |
||
848 | .f_width rd 1 |
||
849 | |||
4812 | eAndrew | 850 | buffer rb 1024 |
851 | first_draw rb 1 |
||
5868 | eAndrew | 852 | prev_pid rd 1 |
4812 | eAndrew | 853 | |
854 | ;===================================================================== |
||
10017 | Doczom | 855 | rb 2048 |
4812 | eAndrew | 856 | @stack: |
10017 | Doczom | 857 | @params rb 256 |
4812 | eAndrew | 858 | |
859 | @memory:[window.y],>[window.x],>[text.offset],> |