Subversion Repositories Kolibri OS

Rev

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