Rev 4801 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4784 | eAndrew | 1 | use32 |
2 | org 0 |
||
3 | db 'MENUET01' |
||
4 | dd 1, @entry, @end, @memory, @stack, @params, 0 |
||
5 | |||
6 | include "../../macros.inc" |
||
7 | include "../../proc32.inc" |
||
8 | include "../../dll.inc" |
||
9 | |||
10 | macro cmpe a, b, c { |
||
11 | cmp a, b |
||
12 | je c } |
||
13 | |||
14 | macro cmpl a, b, c { |
||
15 | cmp a, b |
||
16 | jl c } |
||
17 | |||
18 | macro cmpne a, b, c { |
||
19 | cmp a, b |
||
20 | jne c } |
||
21 | |||
22 | macro cmple a, b, c { |
||
23 | cmp a, b |
||
24 | jle c } |
||
25 | |||
26 | macro cmpge a, b, c { |
||
27 | cmp a, b |
||
28 | jge c } |
||
29 | |||
30 | LINEH equ 12 |
||
4809 | eAndrew | 31 | ICONS equ 12 |
4784 | eAndrew | 32 | |
33 | ;===================================================================== |
||
34 | |||
35 | @entry: |
||
36 | |||
37 | mcall 40, 101b |
||
38 | |||
39 | ;---------------------------- |
||
40 | |||
41 | ;; CHECK FOR PARAMS |
||
42 | cmpne [@params], byte 0, parse |
||
43 | mov eax, @params |
||
44 | mov ebx, sz_std |
||
45 | @@: |
||
46 | mov cl, [ebx] |
||
47 | mov [eax], cl |
||
48 | inc eax |
||
49 | inc ebx |
||
50 | cmpne [ebx - 1], byte 0, @b |
||
51 | |||
52 | ;; TEXT |
||
53 | |||
54 | parse: |
||
55 | mov [text.lines], dword 1 |
||
56 | mov [text.max_len], dword 1 |
||
57 | |||
58 | mov eax, @params |
||
59 | mov ebx, text.buffer |
||
60 | mov edx, 0 |
||
61 | mov esi, 0 |
||
62 | |||
63 | cmpne [eax], byte "'", @f |
||
64 | mov dl, "'" |
||
65 | mov eax, @params + 1 |
||
66 | jmp .text |
||
67 | |||
68 | @@: |
||
69 | cmpne [eax], byte '"', .text |
||
70 | mov dl, '"' |
||
71 | mov eax, @params + 1 |
||
72 | |||
73 | .text: |
||
74 | cmpe [eax], dl, .text.end |
||
75 | cmpe [eax], byte 0, .text.end |
||
76 | mov cl, [eax] |
||
77 | |||
78 | cmpe cl, "\", .char |
||
4801 | eAndrew | 79 | cmpne cl, 10, .copy |
80 | cmple esi, dword [text.max_len], @f |
||
81 | mov [text.max_len], esi |
||
82 | @@: |
||
83 | mov esi, 0 |
||
84 | mov cl, 0 |
||
85 | inc dword [text.lines] |
||
4784 | eAndrew | 86 | jmp .copy |
87 | |||
88 | .char: |
||
89 | cmpe [eax + 1], byte "n", .newline |
||
90 | cmpe [eax + 1], dl, .quote |
||
91 | jmp .copy |
||
92 | |||
93 | .newline: |
||
94 | cmple esi, dword [text.max_len], @f |
||
95 | mov [text.max_len], esi |
||
96 | @@: |
||
97 | mov esi, 0 |
||
98 | mov cl, 0 |
||
99 | inc dword [text.lines] |
||
100 | inc eax |
||
101 | jmp .copy |
||
102 | |||
103 | .quote: |
||
104 | mov cl, dl |
||
105 | inc eax |
||
106 | |||
107 | .copy: |
||
108 | mov [ebx], cl |
||
109 | inc eax |
||
110 | inc ebx |
||
111 | inc esi |
||
112 | jmp .text |
||
113 | .text.end: |
||
114 | |||
115 | cmple esi, dword [text.max_len], @f |
||
116 | mov [text.max_len], esi |
||
117 | @@: |
||
118 | |||
119 | mov [ebx], byte 0 |
||
120 | |||
121 | cmpge [text.max_len], dword 25, @f |
||
122 | mov [text.max_len], dword 25 |
||
123 | @@: |
||
124 | |||
125 | ;; PARAMS |
||
126 | |||
127 | .params: |
||
128 | cmpe [eax], byte 0, .params.end |
||
129 | cmpe [eax], byte "d", .set_atcl |
||
130 | cmpe [eax], byte "t", .set_title |
||
131 | mov ebx, 1 |
||
132 | cmpe [eax], byte "A", .set_icon |
||
4809 | eAndrew | 133 | inc ebx |
4784 | eAndrew | 134 | cmpe [eax], byte "E", .set_icon |
4809 | eAndrew | 135 | inc ebx |
4784 | eAndrew | 136 | cmpe [eax], byte "W", .set_icon |
4809 | eAndrew | 137 | inc ebx |
4784 | eAndrew | 138 | cmpe [eax], byte "O", .set_icon |
4809 | eAndrew | 139 | inc ebx |
4784 | eAndrew | 140 | cmpe [eax], byte "N", .set_icon |
4809 | eAndrew | 141 | inc ebx |
4784 | eAndrew | 142 | cmpe [eax], byte "I", .set_icon |
4809 | eAndrew | 143 | inc ebx |
4784 | eAndrew | 144 | cmpe [eax], byte "F", .set_icon |
4809 | eAndrew | 145 | inc ebx |
4784 | eAndrew | 146 | cmpe [eax], byte "C", .set_icon |
4809 | eAndrew | 147 | inc ebx |
148 | cmpe [eax], byte "M", .set_icon |
||
149 | inc ebx |
||
150 | cmpe [eax], byte "D", .set_icon |
||
151 | inc ebx |
||
152 | cmpe [eax], byte "H", .set_icon |
||
153 | inc ebx |
||
154 | cmpe [eax], byte "P", .set_icon |
||
4784 | eAndrew | 155 | |
156 | jmp .next_char |
||
157 | |||
158 | .set_atcl: |
||
159 | mov [params.atcl], byte 1 |
||
160 | jmp .next_char |
||
161 | |||
162 | .set_title: |
||
163 | mov [params.title], byte 1 |
||
164 | jmp .next_char |
||
165 | |||
166 | .set_icon: |
||
167 | mov [params.icon], ebx |
||
168 | |||
169 | .next_char: |
||
170 | inc eax |
||
171 | jmp .params |
||
172 | |||
173 | .params.end: |
||
174 | |||
175 | ;---------------------------- |
||
176 | |||
177 | mcall 68, 11 |
||
178 | stdcall dll.Load, @imports |
||
179 | |||
180 | mov dword [fi + 00], 5 |
||
181 | mov dword [fi + 16], buffer |
||
182 | mov dword [fi + 21], sz_ifile |
||
183 | mcall 70, fi |
||
184 | |||
185 | mov edx, dword [buffer + 32] |
||
4809 | eAndrew | 186 | shl edx, 2 |
4784 | eAndrew | 187 | stdcall mem.Alloc, edx |
188 | mov [img_data.rgb_obj], eax |
||
189 | |||
190 | mov dword [fi + 00], 0 |
||
191 | mov dword [fi + 12], edx |
||
192 | m2m dword [fi + 16], [img_data.rgb_obj] |
||
193 | mov dword [fi + 21], sz_ifile |
||
194 | mcall 70, fi |
||
195 | |||
196 | stdcall dword [img.decode], dword [img_data.rgb_obj], ebx, 0 |
||
197 | mov dword [img_data.obj], eax |
||
198 | |||
199 | ;; alpha |
||
200 | add eax, 24 |
||
201 | mov eax, [eax] ;; eax - data [argb] |
||
202 | |||
4809 | eAndrew | 203 | mov ecx, 24 * 24 * ICONS |
4784 | eAndrew | 204 | alpha: |
205 | mov ebx, [eax] |
||
206 | shr ebx, 24 |
||
207 | cmpne bl, 0x00, @f |
||
208 | mov [eax], dword 0x222222 |
||
209 | |||
210 | @@: |
||
211 | add eax, 4 |
||
212 | loop alpha |
||
213 | |||
214 | ;; end alpha |
||
215 | |||
216 | stdcall dword [img.to_rgb], dword [img_data.obj], dword [img_data.rgb_obj] |
||
217 | stdcall dword [img.destroy], dword [img_data.obj] |
||
218 | |||
219 | ;---------------------------- |
||
220 | |||
221 | mov [text.offset], LINEH |
||
222 | |||
223 | mov eax, [text.lines] |
||
224 | add eax, 2 |
||
225 | imul eax, LINEH |
||
226 | mov [window.height], eax |
||
227 | |||
228 | mov eax, [text.max_len] |
||
229 | imul eax, 6 |
||
230 | add eax, LINEH * 2 |
||
231 | cmpe [params.icon], dword 0, @f |
||
232 | add eax, 24 + LINEH |
||
233 | add [text.offset], 24 + LINEH |
||
234 | @@: |
||
235 | mov [window.width], eax |
||
236 | |||
237 | mcall 14 |
||
238 | mov ebx, eax |
||
239 | and ebx, 0xFFFF |
||
240 | mov [scr.height], ebx |
||
241 | shr eax, 16 |
||
242 | mov [scr.width], eax |
||
243 | sub eax, [window.width] |
||
244 | sub eax, LINEH |
||
245 | mov [window.x], eax |
||
246 | |||
247 | ;; CALC WINDOW.Y |
||
248 | |||
4809 | eAndrew | 249 | mcall 68, 22, sz_shname, 256 + 512, 4 + 1 ;OPEN_ALWAYS and WRITE |
250 | add eax, 512 |
||
4784 | eAndrew | 251 | mov [shm], eax |
252 | |||
253 | s_search: |
||
254 | mov eax, [shm] |
||
255 | |||
256 | mov ebx, 0 |
||
257 | mov ecx, [text.lines] |
||
258 | add ecx, 3 |
||
259 | |||
260 | push eax ebx |
||
261 | |||
262 | mov eax, [scr.height] |
||
263 | mov edx, 0 |
||
264 | mov ebx, LINEH |
||
265 | div ebx |
||
266 | mov edx, eax |
||
267 | add edx, [shm] |
||
268 | sub edx, ecx |
||
269 | inc edx |
||
270 | |||
271 | pop ebx eax |
||
272 | |||
273 | s_area: |
||
274 | cmpe [eax], byte 1, .is_1 |
||
275 | |||
276 | .is_0: |
||
277 | inc ebx |
||
278 | cmpe ebx, ecx, s_ok |
||
279 | jmp .next |
||
280 | |||
281 | .is_1: |
||
282 | mov ebx, 0 |
||
283 | |||
284 | .next: |
||
285 | inc eax |
||
286 | cmple eax, edx, s_area |
||
287 | |||
288 | mcall 5, 10 |
||
289 | jmp s_search |
||
290 | |||
291 | s_ok: |
||
292 | sub eax, ecx |
||
293 | inc eax |
||
294 | mov [shm.our], eax |
||
295 | |||
296 | mov edx, eax |
||
297 | sub edx, [shm] |
||
298 | inc edx |
||
299 | imul edx, LINEH |
||
300 | mov [window.y], edx |
||
301 | |||
302 | @@: |
||
303 | mov [eax], byte 1 |
||
304 | inc eax |
||
305 | loop @b |
||
306 | |||
307 | ;---------------------------- |
||
308 | |||
309 | mov eax, 60 |
||
310 | imul eax, [text.lines] |
||
311 | mov [timer], eax |
||
312 | |||
313 | mov [timer.step], dword 1 |
||
314 | cmpne [params.atcl], byte 1, @f |
||
315 | mov [timer.step], dword 0 |
||
316 | @@: |
||
317 | |||
318 | ;---------------------------- |
||
319 | |||
320 | update: |
||
321 | mcall 23, 10 |
||
322 | cmpe al, EV_REDRAW, redraw |
||
323 | cmpe al, EV_BUTTON, exit |
||
324 | |||
325 | mov eax, [timer.step] |
||
326 | sub [timer], eax |
||
327 | cmpne [timer], dword 0, update |
||
328 | |||
329 | ;---------------------------- |
||
330 | |||
331 | exit: |
||
332 | mov eax, [shm.our] |
||
333 | mov ecx, [text.lines] |
||
334 | add ecx, 3 |
||
335 | @@: |
||
336 | mov [eax], byte 0 |
||
337 | inc eax |
||
338 | loop @b |
||
339 | |||
340 | mcall 68, 23, sz_shname |
||
341 | |||
342 | mcall -1 |
||
343 | |||
344 | ;---------------------------- |
||
345 | |||
346 | redraw: |
||
347 | call draw_window |
||
348 | call draw_text |
||
349 | |||
350 | jmp update |
||
351 | |||
352 | ;---------------------------- |
||
353 | |||
354 | draw_window: |
||
355 | dec dword [window.width] |
||
356 | dec dword [window.height] |
||
357 | mcall 0, <[window.x], [window.width]>, <[window.y], [window.height]>, 0x61000000 |
||
358 | inc dword [window.width] |
||
359 | inc dword [window.height] |
||
360 | |||
361 | and ebx, 0xFFFF |
||
362 | and ecx, 0xFFFF |
||
363 | inc ebx |
||
364 | inc ecx |
||
365 | mcall 8, , , 0x61000001 |
||
366 | |||
367 | mov eax, 13 |
||
368 | mov ebx, [window.width] |
||
369 | mov edx, 0x222222 |
||
370 | cmpe [first_draw], byte 1, .draw_full |
||
371 | mov [first_draw], byte 1 |
||
372 | mov esi, [window.height] |
||
4801 | eAndrew | 373 | mov ecx, LINEH |
4784 | eAndrew | 374 | @@: |
375 | mcall |
||
4801 | eAndrew | 376 | add ecx, LINEH shl 16 |
377 | sub esi, LINEH |
||
4784 | eAndrew | 378 | push eax ebx |
379 | mcall 5, 1 |
||
380 | pop ebx eax |
||
381 | cmpne esi, 0, @b |
||
382 | .draw_full: |
||
383 | mcall |
||
384 | |||
385 | mcall , , 1, 0x121212 |
||
386 | |||
387 | mov ecx, [window.height] |
||
388 | dec ecx |
||
389 | shl ecx, 16 |
||
390 | inc ecx |
||
391 | mcall |
||
392 | |||
393 | mcall , 1, [window.width] |
||
394 | |||
395 | mov ebx, [window.width] |
||
396 | dec ebx |
||
397 | shl ebx, 16 |
||
398 | inc ebx |
||
399 | mcall |
||
400 | |||
401 | mcall 1, 1, 1 |
||
402 | mov ebx, [window.width] |
||
403 | sub ebx, 2 |
||
404 | mcall |
||
405 | mov ecx, [window.height] |
||
406 | sub ecx, 2 |
||
407 | mcall |
||
408 | mov ebx, 1 |
||
409 | mcall |
||
410 | |||
411 | ;----- |
||
412 | |||
413 | mov ecx, [scr.width] |
||
414 | inc ecx |
||
415 | |||
416 | mov eax, 35 |
||
417 | mov ebx, ecx |
||
418 | imul ebx, [window.y] |
||
419 | add ebx, [window.x] |
||
420 | dec ebx |
||
421 | mcall |
||
422 | push eax |
||
423 | |||
424 | mov eax, 35 |
||
425 | add ebx, [window.width] |
||
426 | add ebx, 2 |
||
427 | mcall |
||
428 | push eax |
||
429 | |||
430 | mov eax, 35 |
||
431 | mov edx, ecx |
||
432 | mov esi, [window.height] |
||
433 | dec esi |
||
434 | imul edx, esi |
||
435 | add ebx, edx |
||
436 | mcall |
||
437 | push eax |
||
438 | |||
439 | mov eax, 35 |
||
440 | sub ebx, [window.width] |
||
441 | sub ebx, 2 |
||
442 | mcall |
||
443 | push eax |
||
444 | |||
445 | ;----- |
||
446 | |||
447 | mov eax, 1 |
||
448 | |||
449 | pop edx |
||
450 | mov ecx, [window.height] |
||
451 | dec ecx |
||
452 | mcall , 0 |
||
453 | |||
454 | pop edx |
||
455 | mov ebx, [window.width] |
||
456 | dec ebx |
||
457 | mcall |
||
458 | |||
459 | pop edx |
||
460 | mcall , , 0 |
||
461 | |||
462 | pop edx |
||
463 | mcall , 0 |
||
464 | |||
465 | ;----- |
||
466 | |||
467 | cmpe [params.icon], dword 0, @f |
||
468 | |||
469 | mov ebx, [params.icon] |
||
470 | dec ebx |
||
471 | imul ebx, 24 * 24 * 3 |
||
472 | add ebx, [img_data.rgb_obj] |
||
473 | |||
474 | mov edx, [window.height] |
||
475 | shr edx, 1 |
||
476 | sub edx, 12 |
||
477 | add edx, LINEH shl 16 |
||
478 | |||
479 | mcall 7, , <24, 24> |
||
480 | |||
481 | @@: |
||
482 | |||
483 | ret |
||
484 | |||
485 | ;---------------------------- |
||
486 | |||
487 | draw_text: |
||
488 | mov esi, [text.lines] |
||
489 | |||
490 | mov eax, 4 |
||
491 | mov ebx, [text.offset] |
||
492 | shl ebx, 16 |
||
493 | add ebx, LINEH + (LINEH - 6) / 2 |
||
494 | mov edx, text.buffer |
||
495 | |||
496 | .draw_lines: |
||
497 | mov ecx, 0x80111111 |
||
498 | |||
499 | add ebx, 0x00010000 |
||
500 | dec ebx |
||
501 | mcall |
||
502 | add ebx, 2 |
||
503 | mcall |
||
504 | sub ebx, 0x00020000 |
||
505 | mcall |
||
506 | sub ebx, 2 |
||
507 | mcall |
||
508 | |||
509 | add ebx, 0x00010001 |
||
510 | mov ecx, 0x80D0D0D0 |
||
511 | mcall |
||
512 | |||
513 | add ebx, LINEH |
||
514 | dec esi |
||
515 | cmpe esi, 0, .draw_lines.end |
||
516 | |||
517 | inc edx |
||
518 | @@: |
||
519 | cmpe [edx], byte 0, @f |
||
520 | inc edx |
||
521 | jmp @b |
||
522 | @@: |
||
523 | inc edx |
||
524 | jmp .draw_lines |
||
525 | |||
526 | .draw_lines.end: |
||
527 | |||
528 | cmpne [params.title], byte 1, @f |
||
529 | mov edx, text.buffer |
||
530 | mov ecx, 0x80111111 |
||
531 | and ebx, 0xFFFF0000 |
||
532 | add ebx, 1 shl 16 + LINEH + (LINEH - 6) / 2 |
||
533 | mcall |
||
534 | |||
535 | mov ecx, 0x80FFFFFF |
||
536 | sub ebx, 0x00010000 |
||
537 | mcall |
||
538 | @@: |
||
539 | |||
540 | ret |
||
541 | ;---------------------------- |
||
542 | |||
543 | @imports: |
||
544 | library img, "libimg.obj" |
||
545 | import img, img.init, "lib_init", \ |
||
546 | img.to_rgb, "img_to_rgb2", \ |
||
547 | img.decode, "img_decode", \ |
||
548 | img.destroy, "img_destroy" |
||
549 | |||
550 | ;---------------------------- |
||
551 | |||
4801 | eAndrew | 552 | sz_ifile db "/sys/notify3.png", 0 |
4784 | eAndrew | 553 | sz_shname db "notify-mem-v01", 0 |
4809 | eAndrew | 554 | sz_std db "'NOTIFY 3\n", \ |
4784 | eAndrew | 555 | "d - disable auto-closing\n", \ |
4809 | eAndrew | 556 | "t - title\n", \ |
557 | "A - application\n", \ |
||
558 | "E - error\n", \ |
||
559 | "W - warning\n", \ |
||
560 | "O - ok\n", \ |
||
561 | "N - network\n", \ |
||
562 | "I - info\n", \ |
||
563 | "F - folder\n", \ |
||
564 | "C - component\n", \ |
||
565 | "M - mail\n", \ |
||
566 | "D - download\n", \ |
||
567 | "H - hard disk\n", \ |
||
568 | "P - audio player", \ |
||
4784 | eAndrew | 569 | "' -td", 0 |
570 | |||
571 | ;---------------------------- |
||
572 | |||
573 | @end: |
||
574 | |||
575 | ;===================================================================== |
||
576 | |||
577 | window: |
||
578 | .x rd 1 |
||
579 | .y rd 1 |
||
580 | .width rd 1 |
||
581 | .height rd 1 |
||
582 | |||
583 | scr: |
||
584 | .width rd 1 |
||
585 | .height rd 1 |
||
586 | |||
587 | text: |
||
588 | .buffer rb 256 |
||
589 | .lines rd 1 |
||
590 | .max_len rd 1 |
||
591 | .offset rd 1 |
||
592 | |||
593 | params: |
||
594 | .atcl rb 1 |
||
595 | .title rb 1 |
||
596 | .icon rd 1 |
||
597 | |||
598 | img_data: |
||
599 | .rgb_obj rd 1 |
||
600 | .obj rd 1 |
||
601 | |||
602 | timer: |
||
603 | .value rd 1 |
||
604 | .step rd 1 |
||
605 | |||
606 | shm: |
||
607 | .addr rd 1 |
||
608 | .our rd 1 |
||
609 | |||
610 | fi rb 26 |
||
611 | buffer rb 1024 |
||
612 | first_draw rb 1 |
||
613 | |||
614 | ;===================================================================== |
||
615 | rb 2048 |
||
616 | @stack: |
||
617 | @params rb 256 |
||
618 | |||
619 | @memory:24,>[window.y],>[window.x],> |