Subversion Repositories Kolibri OS

Rev

Rev 5476 | Rev 5889 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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