Subversion Repositories Kolibri OS

Rev

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

  1. ; int __stdcall GenericBox(DLGTEMPLATE* dlg, void* DlgProc);
  2. ;       int __stdcall DlgProc(DLGTEMPLATE* dlg, int msg, int param1, int param2);
  3.  
  4. virtual at 0
  5. dlgtemplate:
  6. .flags          dd      ?
  7. .x              dd      ?
  8. .y              dd      ?
  9. .width          dd      ?
  10. .height         dd      ?
  11. .border_size_x  dd      ?
  12. .border_size_y  dd      ?
  13. .title          dd      ?
  14. .main_color     db      ?
  15. .border_color   db      ?
  16. .header_color   db      ?
  17.                 db      ?       ; align
  18. .size = $
  19. end virtual
  20.  
  21. GenericBox:
  22.         pushad
  23.         mov     ebx, [esp+20h+4]
  24. ; center window if required
  25.         cmp     [ebx+dlgtemplate.x], -1
  26.         jnz     @f
  27.         mov     eax, [cur_width]
  28.         sub     eax, [ebx+dlgtemplate.width]
  29.         shr     eax, 1
  30.         mov     [ebx+dlgtemplate.x], eax
  31. @@:
  32.         cmp     [ebx+dlgtemplate.y], -1
  33.         jnz     @f
  34.         mov     eax, [cur_height]
  35.         sub     eax, [ebx+dlgtemplate.height]
  36.         shr     eax, 1
  37.         mov     [ebx+dlgtemplate.y], eax
  38. @@:
  39. ; some checks
  40.         mov     eax, [ebx+dlgtemplate.x]
  41.         cmp     eax, 1
  42.         jl      .sizeerr
  43.         add     eax, [ebx+dlgtemplate.width]
  44.         cmp     eax, [cur_width]
  45.         jge     .sizeerr
  46.         mov     eax, [ebx+dlgtemplate.y]
  47.         cmp     eax, 1
  48.         jl      .sizeerr
  49.         add     eax, [ebx+dlgtemplate.height]
  50.         cmp     eax, [cur_height]
  51.         jge     .sizeerr
  52.         cmp     [ebx+dlgtemplate.border_size_x], 1
  53.         jl      .sizeerr
  54.         cmp     [ebx+dlgtemplate.border_size_y], 1
  55.         jge     .sizeok
  56. .sizeerr:
  57.         popad
  58.         or      eax, -1
  59.         ret     8
  60. .sizeok:
  61. ; allocate memory for data under dialog
  62.         mov     eax, [ebx+dlgtemplate.width]
  63.         add     eax, [ebx+dlgtemplate.border_size_x]
  64.         add     eax, [ebx+dlgtemplate.border_size_x]
  65.         inc     eax
  66.         inc     eax
  67.         mov     edx, [ebx+dlgtemplate.height]
  68.         add     edx, [ebx+dlgtemplate.border_size_y]
  69.         add     edx, [ebx+dlgtemplate.border_size_y]
  70.         inc     edx
  71.         mul     edx
  72.         add     eax, eax
  73.         call    mf_alloc
  74.         test    eax, eax
  75.         jnz     @f
  76. ; TODO: add error message
  77.         popad
  78.         or      eax, -1
  79.         ret     8
  80. @@:
  81.         mov     ebp, eax
  82. ; save data
  83.         mov     eax, [ebx+dlgtemplate.y]
  84.         add     eax, [ebx+dlgtemplate.height]
  85.         add     eax, [ebx+dlgtemplate.border_size_y]
  86.         inc     eax
  87.         push    eax
  88.         mov     eax, [ebx+dlgtemplate.x]
  89.         add     eax, [ebx+dlgtemplate.width]
  90.         add     eax, [ebx+dlgtemplate.border_size_x]
  91.         inc     eax
  92.         inc     eax
  93.         push    eax
  94.         mov     eax, [ebx+dlgtemplate.y]
  95.         sub     eax, [ebx+dlgtemplate.border_size_y]
  96.         push    eax
  97.         mov     eax, [ebx+dlgtemplate.x]
  98.         sub     eax, [ebx+dlgtemplate.border_size_x]
  99.         push    eax
  100.         call    save_console_data
  101. ; draw shadow
  102.         mov     eax, [ebx+dlgtemplate.x]
  103.         sub     eax, [ebx+dlgtemplate.border_size_x]
  104.         ja      @f
  105.         xor     eax, eax
  106. @@:
  107.         push    eax     ; save real window left
  108.         inc     eax
  109.         inc     eax
  110.         mov     edx, [ebx+dlgtemplate.y]
  111.         sub     edx, [ebx+dlgtemplate.border_size_y]
  112.         ja      @f
  113.         xor     edx, edx
  114. @@:
  115.         push    edx     ; save real window top
  116.         inc     edx
  117.         call    get_console_ptr
  118.         mov     ecx, [ebx+dlgtemplate.y]
  119.         add     ecx, [ebx+dlgtemplate.height]
  120.         add     ecx, [ebx+dlgtemplate.border_size_y]
  121.         inc     ecx
  122.         cmp     ecx, [cur_height]
  123.         jb      @f
  124.         mov     ecx, [cur_height]
  125. @@:
  126.         sub     ecx, edx
  127.         mov     edx, ecx
  128.         mov     ecx, [ebx+dlgtemplate.x]
  129.         add     ecx, [ebx+dlgtemplate.width]
  130.         add     ecx, [ebx+dlgtemplate.border_size_x]
  131.         inc     ecx
  132.         inc     ecx
  133.         cmp     ecx, [cur_width]
  134.         jb      @f
  135.         mov     ecx, [cur_width]
  136. @@:
  137.         sub     ecx, eax
  138.         mov     eax, ecx
  139. .shadow_loop:
  140.         mov     ecx, eax
  141.         push    edi
  142. .sl1:
  143.         inc     edi
  144.         test    byte [edi], 0x0F
  145.         jnz     @f
  146.         or      byte [edi], 8
  147. @@:
  148.         and     byte [edi], 0x0F
  149.         inc     edi
  150.         loop    .sl1
  151.         pop     edi
  152.         add     edi, [cur_width]
  153.         add     edi, [cur_width]
  154.         dec     edx
  155.         jnz     .shadow_loop
  156. ; draw area background
  157.         pop     edx
  158.         pop     eax
  159.         call    get_console_ptr
  160.         mov     ecx, [ebx+dlgtemplate.x]
  161.         add     ecx, [ebx+dlgtemplate.width]
  162.         add     ecx, [ebx+dlgtemplate.border_size_x]
  163.         cmp     ecx, [cur_width]
  164.         jb      @f
  165.         mov     ecx, [cur_width]
  166. @@:
  167.         sub     ecx, eax
  168.         mov     esi, ecx
  169.         mov     ecx, [ebx+dlgtemplate.y]
  170.         add     ecx, [ebx+dlgtemplate.height]
  171.         add     ecx, [ebx+dlgtemplate.border_size_y]
  172.         cmp     ecx, [cur_height]
  173.         jb      @f
  174.         mov     ecx, [cur_height]
  175. @@:
  176.         sub     ecx, edx
  177.         mov     edx, ecx
  178.         mov     al, ' '
  179.         mov     ah, [ebx+dlgtemplate.border_color]
  180. .1:
  181.         mov     ecx, esi
  182.         push    edi
  183.         rep     stosw
  184.         pop     edi
  185.         add     edi, [cur_width]
  186.         add     edi, [cur_width]
  187.         dec     edx
  188.         jnz     .1
  189. ; draw border
  190.         mov     eax, [ebx+dlgtemplate.x]
  191.         dec     eax
  192.         mov     edx, [ebx+dlgtemplate.y]
  193.         dec     edx
  194.         call    get_console_ptr
  195.         mov     edx, [ebx+dlgtemplate.height]
  196.         inc     edx
  197.         inc     edx
  198.         mov     ah, [ebx+dlgtemplate.border_color]
  199.         push    ebx
  200.         mov     ebx, [ebx+dlgtemplate.width]
  201.         inc     ebx
  202.         inc     ebx
  203.         call    draw_border
  204.         pop     ebx
  205. ; draw header
  206.         mov     esi, [ebx+dlgtemplate.title]
  207.         test    esi, esi
  208.         jz      .noheader
  209.         cmp     byte [esi], 0
  210.         jz      .noheader
  211.         push    esi
  212. @@:     lodsb
  213.         test    al, al
  214.         jnz     @b
  215.         mov     eax, esi
  216.         pop     esi
  217.         sub     eax, esi
  218.         inc     eax     ; eax = ¤«¨­  § £®«®¢ª  + 2
  219.         mov     ecx, [ebx+dlgtemplate.width]
  220.         cmp     eax, ecx
  221.         jbe     .fullhea
  222.         sub     ecx, 5
  223.         jb      .noheader
  224.         xor     edx, edx
  225.         jmp     .drawhea
  226. .fullhea:
  227.         mov     edx, ecx
  228.         sub     edx, eax
  229.         shr     edx, 1
  230. .drawhea:
  231.         mov     eax, [ebx+dlgtemplate.x]
  232.         add     eax, edx
  233.         mov     edx, [ebx+dlgtemplate.y]
  234.         dec     edx
  235.         call    get_console_ptr
  236.         mov     ah, [ebx+dlgtemplate.header_color]
  237.         mov     al, ' '
  238.         stosw
  239. .2:
  240.         dec     ecx
  241.         jz      .3
  242.         lodsb
  243.         test    al, al
  244.         jz      .4
  245.         stosw
  246.         jmp     .2
  247. .3:
  248.         mov     al, '.'
  249.         stosw
  250.         stosw
  251.         stosw
  252. .4:
  253.         mov     al, ' '
  254.         stosw
  255. .noheader:
  256. ; draw window background
  257.         mov     eax, [ebx+dlgtemplate.x]
  258.         mov     edx, [ebx+dlgtemplate.y]
  259.         call    get_console_ptr
  260.         mov     ah, [ebx+dlgtemplate.main_color]
  261.         mov     al, ' '
  262.         mov     edx, [ebx+dlgtemplate.height]
  263. @@:
  264.         mov     ecx, [ebx+dlgtemplate.width]
  265.         push    edi
  266.         rep     stosw
  267.         pop     edi
  268.         add     edi, [cur_width]
  269.         add     edi, [cur_width]
  270.         dec     edx
  271.         jnz     @b
  272. ; send redraw message
  273.         mov     eax, [esp+20h+8]
  274.         push    ebx ebp
  275.         push    0
  276.         push    0
  277.         push    1
  278.         push    ebx
  279.         call    eax
  280.         call    draw_image
  281.         pop     ebp ebx
  282. ; message loop
  283. .event:
  284.         push    10
  285.         pop     eax
  286.         int     40h
  287.         dec     eax
  288.         jz      .redraw
  289.         dec     eax
  290.         jz      .key
  291.         or      eax, -1
  292.         int     40h
  293. .redraw:
  294.         push    ebx ebp
  295.         call    draw_window
  296.         pop     ebp ebx
  297.         jmp     .event
  298. .key:
  299.         mov     al, 2
  300.         int     40h
  301.         shr     eax, 8
  302.         cmp     al, 0xE0
  303.         jnz     @f
  304.         mov     [bWasE0], 1
  305.         jmp     .event
  306. @@:
  307.         xchg    ah, [bWasE0]
  308.         cmp     al, 0x1D
  309.         jz      .ctrl_down
  310.         cmp     al, 0x9D
  311.         jz      .ctrl_up
  312.         cmp     al, 0x2A
  313.         jz      .lshift_down
  314.         cmp     al, 0xAA
  315.         jz      .lshift_up
  316.         cmp     al, 0x36
  317.         jz      .rshift_down
  318.         cmp     al, 0xB6
  319.         jz      .rshift_up
  320.         cmp     al, 0x38
  321.         jz      .alt_down
  322.         cmp     al, 0xB8
  323.         jz      .alt_up
  324.         mov     ecx, [esp+20h+8]
  325.         push    ebx ebp
  326.         push    0
  327.         push    eax
  328.         push    2
  329.         push    ebx
  330.         call    ecx
  331.         pop     ebp ebx
  332.         test    eax, eax
  333.         jz      .event
  334.         mov     [esp+28], eax
  335.         jmp     .exit
  336. .ctrl_down:
  337.         test    ah, ah
  338.         jnz     .rctrl_down
  339.         or      [ctrlstate], 4
  340.         jmp     .event
  341. .rctrl_down:
  342.         or      [ctrlstate], 8
  343.         jmp     .event
  344. .ctrl_up:
  345.         test    ah, ah
  346.         jnz     .rctrl_up
  347.         and     [ctrlstate], not 4
  348.         jmp     .event
  349. .rctrl_up:
  350.         and     [ctrlstate], not 8
  351.         jmp     .event
  352. .lshift_down:
  353.         test    ah, ah
  354.         jnz     @f
  355.         or      [ctrlstate], 1
  356. @@:     jmp     .event
  357. .lshift_up:
  358.         test    ah, ah
  359.         jnz     @b
  360.         and     [ctrlstate], not 1
  361.         jmp     @b
  362. .rshift_down:
  363.         or      [ctrlstate], 2
  364.         jmp     .event
  365. .rshift_up:
  366.         and     [ctrlstate], not 2
  367.         jmp     .event
  368. .alt_down:
  369.         test    ah, ah
  370.         jnz     .ralt_down
  371.         or      [ctrlstate], 0x10
  372.         jmp     .event
  373. .ralt_down:
  374.         or      [ctrlstate], 0x20
  375.         jmp     .event
  376. .alt_up:
  377.         test    ah, ah
  378.         jnz     .ralt_up
  379.         and     [ctrlstate], not 0x10
  380.         jmp     .event
  381. .ralt_up:
  382.         and     [ctrlstate], not 0x20
  383.         jmp     .event
  384. .exit:
  385. ; restore data
  386.         mov     eax, [ebx+dlgtemplate.y]
  387.         add     eax, [ebx+dlgtemplate.height]
  388.         add     eax, [ebx+dlgtemplate.border_size_y]
  389.         inc     eax
  390.         push    eax
  391.         mov     eax, [ebx+dlgtemplate.x]
  392.         add     eax, [ebx+dlgtemplate.width]
  393.         add     eax, [ebx+dlgtemplate.border_size_x]
  394.         inc     eax
  395.         inc     eax
  396.         push    eax
  397.         mov     eax, [ebx+dlgtemplate.y]
  398.         sub     eax, [ebx+dlgtemplate.border_size_y]
  399.         push    eax
  400.         mov     eax, [ebx+dlgtemplate.x]
  401.         sub     eax, [ebx+dlgtemplate.border_size_x]
  402.         push    eax
  403.         call    restore_console_data
  404.         call    draw_keybar
  405.         mov     eax, ebp
  406.         call    mf_free
  407.         or      [cursor_x], -1
  408.         or      [cursor_y], -1
  409.         call    draw_image
  410.         popad
  411.         ret     8
  412.  
  413. save_console_data:
  414.         cmp     dword [esp+4], 0
  415.         jge     @f
  416.         and     dword [esp+4], 0
  417. @@:
  418.         cmp     dword [esp+8], 0
  419.         jge     @f
  420.         and     dword [esp+8], 0
  421. @@:
  422.         mov     eax, [esp+12]
  423.         cmp     eax, [cur_width]
  424.         jbe     @f
  425.         mov     eax, [cur_width]
  426. @@:
  427.         sub     eax, [esp+4]
  428.         ja      @f
  429.         ret     16
  430. @@:
  431.         mov     [esp+12], eax
  432.         mov     eax, [esp+16]
  433.         cmp     eax, [cur_height]
  434.         jbe     @f
  435.         mov     eax, [cur_height]
  436. @@:
  437.         sub     eax, [esp+8]
  438.         ja      @f
  439.         ret     16
  440. @@:
  441.         mov     [esp+16], eax
  442.         mov     eax, [esp+4]
  443.         mov     edx, [esp+8]
  444.         call    get_console_ptr
  445.         mov     esi, edi
  446.         mov     edi, ebp
  447. .l:
  448.         mov     ecx, [esp+12]
  449.         push    esi
  450.         shr     ecx, 1
  451.         rep     movsd
  452.         adc     ecx, ecx
  453.         rep     movsw
  454.         pop     esi
  455.         add     esi, [cur_width]
  456.         add     esi, [cur_width]
  457.         dec     dword [esp+16]
  458.         jnz     .l
  459.         ret     16
  460.  
  461. restore_console_data:
  462.         cmp     dword [esp+4], 0
  463.         jge     @f
  464.         and     dword [esp+4], 0
  465. @@:
  466.         cmp     dword [esp+8], 0
  467.         jge     @f
  468.         and     dword [esp+8], 0
  469. @@:
  470.         mov     eax, [esp+12]
  471.         cmp     eax, [cur_width]
  472.         jbe     @f
  473.         mov     eax, [cur_width]
  474. @@:
  475.         sub     eax, [esp+4]
  476.         ja      @f
  477.         ret     16
  478. @@:
  479.         mov     [esp+12], eax
  480.         mov     eax, [esp+16]
  481.         cmp     eax, [cur_height]
  482.         jbe     @f
  483.         mov     eax, [cur_height]
  484. @@:
  485.         sub     eax, [esp+8]
  486.         ja      @f
  487.         ret     16
  488. @@:
  489.         mov     [esp+16], eax
  490.         mov     eax, [esp+4]
  491.         mov     edx, [esp+8]
  492.         call    get_console_ptr
  493.         mov     esi, ebp
  494. .l:
  495.         mov     ecx, [esp+12]
  496.         push    edi
  497.         shr     ecx, 1
  498.         rep     movsd
  499.         adc     ecx, ecx
  500.         rep     movsw
  501.         pop     edi
  502.         add     edi, [cur_width]
  503.         add     edi, [cur_width]
  504.         dec     dword [esp+16]
  505.         jnz     .l
  506.         ret     16
  507.  
  508. ; int __stdcall menu(void* variants, const char* title, unsigned flags);
  509. ; variants 㪠§ë¢ ¥â ­  ⥪ã騩 í«¥¬¥­â ¢ ¤¢ãá¢ï§­®¬ «¨­¥©­®¬ ᯨ᪥
  510. menu:
  511.         pop     eax
  512.         push    [cur_height]
  513.         push    [cur_width]
  514.         push    0
  515.         push    0
  516.         push    eax
  517.  
  518. ; int __stdcall menu_centered_in(unsigned left, unsigned top, unsigned width, unsigned height,
  519. ;       void* variants, const char* title, unsigned flags);
  520. menu_centered_in:
  521.         pushad
  522.         mov     eax, 56
  523. ; 36 bytes for dlgtemplate + additional:
  524. ; +36: dd cur_variant
  525. ; +40: dd num_variants
  526. ; +44: dd begin_variant
  527. ; +48: dd end_variant
  528. ; +52: dd cur_variant_idx
  529.         call    mf_alloc
  530.         test    eax, eax
  531.         jnz     @f
  532. .ret_bad:
  533.         popad
  534.         or      eax, -1
  535.         ret     28
  536. @@:
  537.         mov     ebx, eax
  538.         mov     eax, 1
  539.         test    byte [esp+20h+28], 1
  540.         jz      @f
  541.         mov     al, 3
  542. @@:
  543.         mov     [ebx+dlgtemplate.border_size_x], eax
  544.         inc     eax
  545.         shr     eax, 1
  546.         mov     [ebx+dlgtemplate.border_size_y], eax
  547. ;  å®¤¨¬ è¨à¨­ã ¨ ¢ëá®âã ®ª­ 
  548.         xor     eax, eax
  549.         xor     ecx, ecx
  550.         mov     esi, [esp+20h+20]
  551.         mov     [ebx+36], esi
  552.         and     dword [ebx+52], 0
  553. @@:
  554.         cmp     dword [esi+4], 0
  555.         jz      .find_width
  556.         mov     esi, [esi+4]
  557.         inc     dword [ebx+52]
  558.         jmp     @b
  559. .find_width:
  560.         mov     [ebx+44], esi
  561.         add     esi, 8
  562.         push    esi
  563.         xor     edx, edx
  564. .fw1:
  565.         cmp     byte [esi], '&'
  566.         jnz     @f
  567.         mov     dl, 1
  568. @@:
  569.         inc     esi
  570.         cmp     byte [esi-1], 0
  571.         jnz     .fw1
  572.         sub     esi, [esp]
  573.         sub     esi, edx
  574.         dec     esi
  575.         cmp     eax, esi
  576.         ja      @f
  577.         mov     eax, esi
  578. @@:
  579.         inc     ecx
  580.         pop     esi
  581.         mov     esi, [esi-8]
  582.         test    esi, esi
  583.         jnz     .find_width
  584.         add     eax, 3
  585.         add     eax, [ebx+dlgtemplate.border_size_x]
  586.         add     eax, [ebx+dlgtemplate.border_size_x]
  587.         cmp     eax, [cur_width]
  588.         jb      @f
  589.         mov     eax, [cur_width]
  590. @@:
  591.         sub     eax, [ebx+dlgtemplate.border_size_x]
  592.         sub     eax, [ebx+dlgtemplate.border_size_x]
  593.         mov     [ebx+dlgtemplate.width], eax
  594.         mov     [ebx+dlgtemplate.height], ecx
  595.         mov     [ebx+40], ecx
  596.         sub     eax, [esp+20h+12]
  597.         neg     eax
  598.         sar     eax, 1
  599.         add     eax, [esp+20h+4]
  600.         cmp     eax, [ebx+dlgtemplate.border_size_x]
  601.         jge     @f
  602.         mov     eax, [ebx+dlgtemplate.border_size_x]
  603. @@:
  604.         push    eax
  605.         add     eax, [ebx+dlgtemplate.width]
  606.         add     eax, [ebx+dlgtemplate.border_size_x]
  607.         cmp     eax, [cur_width]
  608.         jbe     @f
  609.         pop     eax
  610.         mov     eax, [cur_width]
  611.         sub     eax, [ebx+dlgtemplate.width]
  612.         sub     eax, [ebx+dlgtemplate.border_size_x]
  613.         push    eax
  614. @@:
  615.         pop     [ebx+dlgtemplate.x]
  616.         sub     ecx, [esp+20h+16]
  617.         neg     ecx
  618.         sar     ecx, 1
  619.         add     ecx, [esp+20h+8]
  620.         cmp     ecx, [ebx+dlgtemplate.border_size_y]
  621.         jge     @f
  622.         mov     ecx, [ebx+dlgtemplate.border_size_y]
  623. @@:
  624.         push    ecx
  625.         add     ecx, [ebx+dlgtemplate.height]
  626.         add     ecx, [ebx+dlgtemplate.border_size_y]
  627.         cmp     ecx, [cur_height]
  628.         jbe     @f
  629.         pop     ecx
  630.         mov     ecx, [cur_height]
  631.         sub     ecx, [ebx+dlgtemplate.height]
  632.         sub     ecx, [ebx+dlgtemplate.border_size_y]
  633.         push    ecx
  634. @@:
  635.         pop     [ebx+dlgtemplate.y]
  636.         mov     eax, [cur_height]
  637.         sub     eax, 6
  638.         cmp     [ebx+dlgtemplate.height], eax
  639.         jbe     .small_height
  640.         mov     [ebx+dlgtemplate.height], eax
  641.         mov     [ebx+dlgtemplate.y], 3
  642. .small_height:
  643.         mov     ecx, [ebx+dlgtemplate.height]
  644.         mov     eax, [ebx+36]
  645.         mov     [ebx+44], eax
  646.         dec     ecx
  647.         jz      .skip
  648.         push    ecx
  649. @@:
  650.         cmp     dword [eax+4], 0
  651.         jz      @f
  652.         mov     eax, [eax+4]
  653.         loop    @b
  654. @@:
  655.         mov     [ebx+44], eax
  656.         pop     ecx
  657. .loop:
  658.         mov     eax, [eax]
  659.         loop    .loop
  660. .skip:
  661.         mov     [ebx+48], eax
  662.         mov     eax, [esp+20h+24]
  663.         mov     [ebx+dlgtemplate.title], eax
  664.         mov     al, [menu_normal_color]
  665.         mov     [ebx+dlgtemplate.main_color], al
  666.         mov     al, [menu_border_color]
  667.         mov     [ebx+dlgtemplate.border_color], al
  668.         mov     al, [menu_header_color]
  669.         mov     [ebx+dlgtemplate.header_color], al
  670.         push    MenuDlgProc
  671.         push    ebx
  672.         call    GenericBox
  673.         mov     [esp+28], eax
  674.         mov     eax, ebx
  675.         call    mf_free
  676.         popad
  677.         ret     28
  678.  
  679. MenuDlgProc:
  680.         mov     eax, [esp+8]
  681.         cmp     al, 1
  682.         jz      .draw
  683.         cmp     al, 2
  684.         jz      .key
  685.         ret     16
  686. .draw:
  687.         call    .dodraw
  688.         ret     16
  689. .key:
  690.         mov     al, [esp+12]
  691.         cmp     al, 0x48
  692.         jz      .prev
  693.         cmp     al, 0x4B
  694.         jz      .prev
  695.         cmp     al, 0x4D
  696.         jz      .next
  697.         cmp     al, 0x50
  698.         jz      .next
  699.         cmp     al, 0x1C
  700.         jz      .enter
  701.         cmp     al, 1
  702.         jz      .esc
  703.         cmp     al, 0x47
  704.         jz      .home
  705.         cmp     al, 0x4F
  706.         jz      .end
  707.         cmp     al, 0x51
  708.         jz      .pgdn
  709.         cmp     al, 0x49
  710.         jz      .pgup
  711.         mov     edx, [ebx+36]
  712. @@:
  713.         cmp     dword [edx+4], 0
  714.         jz      @f
  715.         mov     edx, [edx+4]
  716.         jmp     @b
  717. @@:
  718. .l:
  719.         lea     esi, [edx+7]
  720. @@:
  721.         inc     esi
  722.         cmp     byte [esi], 0
  723.         jz      .n
  724.         cmp     byte [esi], '&'
  725.         jnz     @b
  726.         movzx   ecx, byte [esi+1]
  727.         cmp     [ascii2scan+ecx], al
  728.         jnz     .n
  729.         mov     eax, edx
  730.         ret     16
  731. .n:
  732.         mov     edx, [edx]
  733.         test    edx, edx
  734.         jnz     .l
  735. .ret:
  736.         xor     eax, eax
  737.         ret     16
  738. .pgup:
  739.         mov     eax, [ebx+36]
  740.         mov     ecx, [ebx+dlgtemplate.height]
  741. .pgupl:
  742.         cmp     dword [eax+4], 0
  743.         jz      .posret
  744.         call    .line_prev
  745.         loop    .pgupl
  746.         jmp     .posret
  747. .prev:
  748.         mov     eax, [ebx+36]
  749.         cmp     dword [eax+4], 0
  750.         jz      .end
  751.         call    .line_prev
  752. .posret:
  753.         mov     [ebx+36], eax
  754. .redraw:
  755.         call    .dodraw
  756.         call    draw_image
  757.         xor     eax, eax
  758.         ret     16
  759. .next:
  760.         mov     eax, [ebx+36]
  761.         cmp     dword [eax], 0
  762.         jz      .home
  763.         call    .line_next
  764.         jmp     .posret
  765. .pgdn:
  766.         mov     eax, [ebx+36]
  767.         mov     ecx, [ebx+dlgtemplate.height]
  768. .pgdnl:
  769.         cmp     dword [eax], 0
  770.         jz      .posret
  771.         call    .line_next
  772.         loop    .pgdnl
  773.         jmp     .posret
  774. .home:
  775.         mov     eax, [ebx+36]
  776. @@:
  777.         cmp     dword [eax+4], 0
  778.         jz      @f
  779.         mov     eax, [eax+4]
  780.         jmp     @b
  781. @@:
  782.         mov     [ebx+44], eax
  783.         push    eax
  784.         mov     ecx, [ebx+dlgtemplate.height]
  785.         dec     ecx
  786.         jz      .h1
  787. .h2:
  788.         mov     eax, [eax]
  789.         loop    .h2
  790. .h1:
  791.         mov     [ebx+48], eax
  792.         pop     eax
  793.         and     dword [ebx+52], 0
  794.         jmp     .posret
  795. .end:
  796.         mov     eax, [ebx+36]
  797. @@:
  798.         cmp     dword [eax], 0
  799.         jz      @f
  800.         mov     eax, [eax]
  801.         jmp     @b
  802. @@:
  803.         mov     [ebx+48], eax
  804.         push    eax
  805.         mov     ecx, [ebx+dlgtemplate.height]
  806.         dec     ecx
  807.         jz      .e1
  808. .e2:
  809.         mov     eax, [eax+4]
  810.         loop    .e2
  811. .e1:
  812.         mov     [ebx+44], eax
  813.         mov     eax, [ebx+40]
  814.         dec     eax
  815.         mov     [ebx+52], eax
  816.         pop     eax
  817.         jmp     .posret
  818. .esc:
  819.         or      eax, -1
  820.         ret     16
  821. .enter:
  822.         mov     eax, [ebx+36]
  823.         ret     16
  824.  
  825. .line_prev:
  826.         cmp     eax, [ebx+44]
  827.         jnz     @f
  828.         mov     edx, [ebx+44]
  829.         mov     edx, [edx+4]
  830.         mov     [ebx+44], edx
  831.         mov     edx, [ebx+48]
  832.         mov     edx, [edx+4]
  833.         mov     [ebx+48], edx
  834. @@:
  835.         mov     eax, [eax+4]
  836.         dec     dword [ebx+52]
  837.         ret
  838. .line_next:
  839.         cmp     eax, [ebx+48]
  840.         jnz     @f
  841.         mov     edx, [ebx+44]
  842.         mov     edx, [edx]
  843.         mov     [ebx+44], edx
  844.         mov     edx, [ebx+48]
  845.         mov     edx, [edx]
  846.         mov     [ebx+48], edx
  847. @@:
  848.         mov     eax, [eax]
  849.         inc     dword [ebx+52]
  850.         ret
  851.  
  852. .dodraw:
  853.         mov     eax, [ebx+dlgtemplate.x]
  854.         mov     edx, [ebx+dlgtemplate.y]
  855.         call    get_console_ptr
  856.         mov     esi, [ebx+44]
  857. .0:
  858.         xor     edx, edx
  859.         mov     ah, [menu_selected_color]
  860.         cmp     esi, [ebx+36]
  861.         jz      @f
  862.         mov     ah, [menu_normal_color]
  863. @@:
  864.         push    edi
  865.         mov     ecx, [ebx+dlgtemplate.width]
  866.         mov     al, ' '
  867.         stosw
  868.         dec     ecx
  869.         stosw
  870.         dec     ecx
  871.         dec     ecx
  872.         push    esi
  873.         add     esi, 8
  874. @@:
  875.         lodsb
  876.         test    al, al
  877.         jz      @f
  878.         cmp     al, '&'
  879.         jnz     .noamp
  880.         test    dl, dl
  881.         jnz     .noamp
  882.         mov     dl, 1
  883.         lodsb
  884.         push    eax
  885.         mov     ah, [menu_selected_highlight_color]
  886.         push    ecx
  887.         mov     ecx, [esp+8]
  888.         cmp     ecx, [ebx+36]
  889.         pop     ecx
  890.         jz      .amp1
  891.         mov     ah, [menu_highlight_color]
  892. .amp1:
  893.         stosw
  894.         pop     eax
  895.         jmp     .amp2
  896. .noamp:
  897.         stosw
  898. .amp2:
  899.         loop    @b
  900.         mov     al, ' '
  901.         cmp     byte [esi], 0
  902.         jnz     .1
  903.         lodsb
  904.         jmp     .1
  905. @@:
  906.         mov     al, ' '
  907. .1:
  908.         stosw
  909.         mov     al, ' '
  910.         rep     stosw
  911.         pop     esi edi
  912.         add     edi, [cur_width]
  913.         add     edi, [cur_width]
  914.         cmp     esi, [ebx+48]
  915.         jz      @f
  916.         mov     esi, [esi]
  917.         test    esi, esi
  918.         jnz     .0
  919. @@:
  920. ; ‹¨­¥©ª  ¯à®ªàã⪨
  921.         mov     ecx, [ebx+dlgtemplate.height]
  922.         cmp     ecx, [ebx+40]
  923.         jz      .noscrollbar
  924.         sub     ecx, 2
  925.         jbe     .noscrollbar
  926.         mov     eax, [ebx+52]
  927.         mul     ecx
  928.         div     dword [ebx+40]
  929.         push    eax
  930.         mov     eax, [ebx+dlgtemplate.x]
  931.         add     eax, [ebx+dlgtemplate.width]
  932.         mov     edx, [ebx+dlgtemplate.y]
  933.         call    get_console_ptr
  934.         pop     edx
  935.         inc     edx
  936.         mov     al, 0x1E
  937.         mov     ah, [menu_scrollbar_color]
  938.         mov     [edi], ax
  939.         add     edi, [cur_width]
  940.         add     edi, [cur_width]
  941. .2:
  942.         mov     al, 0xB2
  943.         dec     edx
  944.         jz      @f
  945.         mov     al, 0xB0
  946. @@:
  947.         mov     [edi], ax
  948.         add     edi, [cur_width]
  949.         add     edi, [cur_width]
  950.         loop    .2
  951.         mov     al, 0x1F
  952.         stosw
  953. .noscrollbar:
  954.         ret
  955.  
  956. virtual at 0
  957. dlgitemtemplate:
  958. ; «¥¬¥­âë:
  959. ;       1 = áâ â¨ç¥áª¨© ⥪áâ
  960. ;       2 = ª­®¯ª 
  961. ;       3 = ¯®«¥ । ªâ¨à®¢ ­¨ï
  962. .type           dd      ?
  963. .x1             dd      ?
  964. .y1             dd      ?
  965. .x2             dd      ?
  966. .y2             dd      ?
  967. ; „ ­­ë¥:
  968. ; ¤«ï ⥪áâ : const char* data - ASCIIZ-áâப 
  969. ; ¤«ï ª­®¯ª¨: const char* data - § £®«®¢®ª
  970. ; ¤«ï । ªâ®à : struct {unsigned maxlength; unsigned pos; unsigned start;
  971. ;                        char data[maxlength+1];}* data;
  972. .data           dd      ?
  973. .flags          dd      ?
  974. ; ”« £¨:
  975. ;       0 = ¢ëà ¢­¨¢ ­¨¥ ¢«¥¢®
  976. ;       1 = ¢ëà ¢­¨¢ ­¨¥ ¯® 業âàã
  977. ;       2 = ¢ëà ¢­¨¢ ­¨¥ ¢¯à ¢®
  978. ;       4 = í«¥¬¥­â ¨¬¥¥â 䮪ãá ¢¢®¤ 
  979. ;       8 = í«¥¬¥­â ¬®¦¥â ¨¬¥âì 䮪ãá ¢¢®¤ 
  980. ;       10h: ¤«ï ª­®¯ª¨ = ª­®¯ª  ¯® 㬮«ç ­¨î (Enter ­  ­¥-ª­®¯ª¥)
  981. ;            ¤«ï ¯®«ï ¢¢®¤  = ¤ ­­ë¥ ¡ë«¨ ¬®¤¨ä¨æ¨à®¢ ­ë
  982. .size = $
  983. end virtual
  984. ;       struct DLGDATA
  985. ;       {
  986. ;               DLGTEMPLATE dialog;     /* window description */
  987. ;               void* DlgProc;          /* dialog procedure */
  988. ; /* int __stdcall DlgProc(DLGDATA* dlg, int msg, int param1, int param2); */
  989. ;               void* user_data;        /* arbitrary user data */
  990. ;               unsigned num_items;     /* number of items in the following array */
  991. ;               DLGITEMTEMPLATE items[]; /* array of dialog items */
  992. ;       }
  993. ; int __stdcall DialogBox(DLGDATA* dlg);
  994. DialogBox:
  995.         push    ManagerDlgProc
  996.         push    dword [esp+8]
  997.         call    GenericBox
  998.         ret     8
  999.  
  1000. ManagerDlgProc:
  1001.         mov     eax, [esp+8]
  1002.         dec     eax
  1003.         jz      .draw
  1004.         dec     eax
  1005.         jz      .key
  1006.         xor     eax, eax
  1007.         ret     16
  1008. .draw:
  1009.         call    .dodraw
  1010.         ret     16
  1011. .key:
  1012. ; find item with focus
  1013.         add     ebx, dlgtemplate.size+12
  1014.         mov     ecx, [ebx-4]
  1015.         jecxz   .nobtns
  1016. @@:
  1017.         test    [ebx+dlgitemtemplate.flags], 4
  1018.         jnz     @f
  1019.         add     ebx, dlgitemtemplate.size
  1020.         loop    @b
  1021. @@:
  1022. .nobtns:
  1023.         mov     al, [esp+12]
  1024.         cmp     al, 1
  1025.         jz      .esc
  1026.         cmp     al, 0x1C
  1027.         jz      .enter
  1028.         cmp     al, 0xF
  1029.         jz      .tab
  1030.         cmp     al, 0x48
  1031.         jz      .up
  1032.         cmp     al, 0x50
  1033.         jz      .down
  1034.         jecxz   @f
  1035.         cmp     [ebx+dlgitemtemplate.type], 3
  1036.         jz      .key_edit
  1037. @@:
  1038.         cmp     al, 0x4B
  1039.         jz      .left
  1040.         cmp     al, 0x4D
  1041.         jz      .right
  1042. .ret0:
  1043.         xor     eax, eax
  1044.         ret     16
  1045. .esc:
  1046.         or      eax, -1
  1047.         ret     16
  1048. .enter:
  1049.         cmp     [ebx+dlgitemtemplate.type], 2
  1050.         jnz     @f
  1051. .enter_found:
  1052.         mov     eax, ebx
  1053.         ret     16
  1054. @@:
  1055.         mov     ebx, [esp+4]
  1056.         add     ebx, dlgtemplate.size+12
  1057. .enter_find:
  1058.         cmp     [ebx+dlgitemtemplate.type], 2
  1059.         jnz     @f
  1060.         test    [ebx+dlgitemtemplate.flags], 0x10
  1061.         jnz     .enter_found
  1062. @@:
  1063.         add     ebx, dlgitemtemplate.size
  1064.         jmp     .enter_find
  1065. .tab:
  1066.         test    [ctrlstate], 3
  1067.         jnz     .shift_tab
  1068. .right:
  1069. .down:
  1070.         jecxz   .ret0
  1071.         and     byte [ebx+dlgitemtemplate.flags], not 4
  1072.         dec     ecx
  1073.         jz      .find_first_btn
  1074. @@:
  1075.         add     ebx, dlgitemtemplate.size
  1076.         test    [ebx+dlgitemtemplate.flags], 8
  1077.         jnz     .btn_found
  1078.         loop    @b
  1079. .find_first_btn:
  1080.         mov     ebx, [esp+4]
  1081.         add     ebx, dlgtemplate.size+12
  1082. @@:
  1083.         test    [ebx+dlgitemtemplate.flags], 8
  1084.         jnz     .btn_found
  1085.         add     ebx, dlgitemtemplate.size
  1086.         jmp     @b
  1087. .btn_found:
  1088.         or      byte [ebx+dlgitemtemplate.flags], 4
  1089. .ret_draw:
  1090.         mov     ebx, [esp+4]
  1091.         call    .dodraw
  1092.         call    draw_image
  1093.         xor     eax, eax
  1094.         ret     16
  1095. .shift_tab:
  1096. .left:
  1097. .up:
  1098.         jecxz   .ret0
  1099.         and     byte [ebx+dlgitemtemplate.flags], not 4
  1100.         mov     eax, [esp+4]
  1101.         sub     ecx, [eax+dlgtemplate.size+8]
  1102.         neg     ecx
  1103.         jz      .find_last_btn
  1104. @@:
  1105.         sub     ebx, dlgitemtemplate.size
  1106.         test    [ebx+dlgitemtemplate.flags], 8
  1107.         loopz   @b
  1108.         jnz     .btn_found
  1109. .find_last_btn:
  1110.         mov     ebx, [eax+dlgtemplate.size+8]
  1111.         imul    ebx, dlgitemtemplate.size
  1112.         lea     ebx, [ebx+eax+dlgtemplate.size+12]
  1113. @@:
  1114.         sub     ebx, dlgitemtemplate.size
  1115.         test    [ebx+dlgitemtemplate.flags], 8
  1116.         jz      @b
  1117.         jmp     .btn_found
  1118. .key_edit:
  1119. ; ®¡à ¡®âª  ª« ¢¨è ¢ ¯®«¥ ¢¢®¤ 
  1120.         test    al, 0x80
  1121.         jnz     .ret0
  1122.         or      [ebx+dlgitemtemplate.flags], 0x10
  1123.         mov     edx, [ebx+dlgitemtemplate.data]
  1124.         cmp     al, 0x4B
  1125.         jz      .editor_left
  1126.         cmp     al, 0x4D
  1127.         jz      .editor_right
  1128.         cmp     al, 0x47
  1129.         jz      .editor_home
  1130.         cmp     al, 0x4F
  1131.         jz      .editor_end
  1132.         cmp     al, 0x0E
  1133.         jz      .editor_backspace
  1134.         cmp     al, 0x53
  1135.         jz      .editor_del
  1136.         test    [ctrlstate], 0x3C
  1137.         jnz     .ret_draw
  1138. ; query keyboard layout
  1139.         pushad
  1140.         push    26
  1141.         pop     eax
  1142.         push    2
  1143.         pop     ebx
  1144.         xor     ecx, ecx
  1145.         cmp     [ctrlstate], 1
  1146.         sbb     ecx, -2
  1147.         mov     edx, layout
  1148.         int     0x40
  1149.         popad
  1150. ; translate scancode to ASCII
  1151.         movzx   eax, al
  1152.         movzx   eax, byte [layout+eax]
  1153.         push    eax
  1154. ; insert entered symbol
  1155.         xor     eax, eax
  1156.         lea     edi, [edx+12]
  1157.         or      ecx, -1
  1158.         repnz   scasb
  1159.         not     ecx
  1160.         pop     eax
  1161.         cmp     ecx, [edx]
  1162.         ja      .ret_test       ; buffer capacity exceeded
  1163.         lea     edi, [edx+ecx+12-1]
  1164.         mov     esi, [edx+4]
  1165.         lea     esi, [edx+esi+12]
  1166. @@:
  1167.         mov     cl, [edi]
  1168.         mov     [edi+1], cl
  1169.         dec     edi
  1170.         cmp     edi, esi
  1171.         jae     @b
  1172.         mov     [esi], al
  1173.         inc     dword [edx+4]
  1174. @@:     jmp     .ret_test
  1175. .editor_left:
  1176.         mov     ecx, [edx+4]
  1177.         jecxz   @f
  1178.         dec     dword [edx+4]
  1179. @@:     jmp     .ret_test
  1180. .editor_right:
  1181.         mov     ecx, [edx+4]
  1182.         cmp     byte [edx+ecx+12], 0
  1183.         jz      @b
  1184.         inc     dword [edx+4]
  1185.         jmp     @b
  1186. .editor_home:
  1187.         and     dword [edx+4], 0
  1188.         jmp     @b
  1189. .editor_end:
  1190.         lea     edi, [edx+12]
  1191.         xor     eax, eax
  1192.         or      ecx, -1
  1193.         repnz   scasb
  1194.         not     ecx
  1195.         dec     ecx
  1196.         mov     [edx+4], ecx
  1197. .ret_test:
  1198.         mov     eax, [edx+4]
  1199.         cmp     [edx+8], eax
  1200.         jl      .ret_test.l1
  1201.         mov     [edx+8], eax
  1202.         jmp     .ret_test.l2
  1203. .ret_test.l1:
  1204.         add     eax, [ebx+dlgitemtemplate.x1]
  1205.         sub     eax, [ebx+dlgitemtemplate.x2]
  1206.         cmp     [edx+8], eax
  1207.         jge     .ret_test.l2
  1208.         mov     [edx+8], eax
  1209. .ret_test.l2:
  1210.         jmp     .ret_draw
  1211. .editor_backspace:
  1212.         mov     ecx, [edx+4]
  1213.         jecxz   .ret_test
  1214.         dec     dword [edx+4]
  1215.         lea     esi, [edx+ecx+12]
  1216.         lea     edi, [esi-1]
  1217. .copy_and_ret_test:
  1218. @@:
  1219.         lodsb
  1220.         stosb
  1221.         test    al, al
  1222.         jnz     @b
  1223.         jmp     .ret_test
  1224. .editor_del:
  1225.         mov     ecx, [edx+4]
  1226.         lea     edi, [ecx+edx+12]
  1227.         lea     esi, [edi+1]
  1228.         cmp     byte [edi], 0
  1229.         jz      .ret_test
  1230.         jmp     .copy_and_ret_test
  1231.  
  1232. .dodraw:
  1233.         or      [cursor_x], -1
  1234.         or      [cursor_y], -1
  1235.         add     ebx, dlgtemplate.size+8
  1236.         mov     ecx, [ebx]
  1237.         add     ebx, 4
  1238.         jecxz   .done_draw
  1239. .draw_loop:
  1240.         push    ecx
  1241.         mov     eax, [ebx+dlgitemtemplate.type]
  1242.         dec     eax
  1243.         jz      .draw_text
  1244.         dec     eax
  1245.         jz      .draw_button
  1246.         dec     eax
  1247.         jnz     .draw_loop_continue
  1248.         call    draw_editbox
  1249.         jmp     .draw_loop_continue
  1250. .draw_button:
  1251.         call    draw_button
  1252.         jmp     .draw_loop_continue
  1253. .draw_text:
  1254.         call    draw_static_text
  1255. .draw_loop_continue:
  1256.         pop     ecx
  1257.         add     ebx, dlgitemtemplate.size
  1258.         loop    .draw_loop
  1259. .done_draw:
  1260.         ret
  1261.  
  1262. draw_static_text:
  1263. ; à¨á㥬 áâ â¨ç¥áª¨© ⥪áâ
  1264.         mov     ah, [dialog_main_color]
  1265. draw_text:
  1266. ; ®¯à¥¤¥«ï¥¬ ¤«¨­ã áâப¨
  1267.         mov     esi, [ebx+dlgitemtemplate.data]
  1268. draw_text_esi:
  1269.         test    esi, esi
  1270.         jz      .ret
  1271.         or      ecx, -1
  1272. @@:
  1273.         inc     ecx
  1274.         cmp     byte [ecx+esi], 0
  1275.         jnz     @b
  1276. ; ¢ ecx ¤«¨­  áâப¨
  1277.         push    eax
  1278.         xor     eax, eax
  1279.         mov     edx, [ebx+dlgitemtemplate.x2]
  1280.         sub     edx, [ebx+dlgitemtemplate.x1]
  1281.         inc     edx
  1282.         cmp     ecx, edx
  1283.         jae     .text_draw
  1284.         mov     al, byte [ebx+dlgitemtemplate.flags]
  1285.         and     al, 3
  1286.         jz      .text_align_left
  1287.         cmp     al, 1
  1288.         jz      .text_align_center
  1289. ; ⥪áâ ¢ë஢­¥­ ¢¯à ¢®
  1290.         mov     eax, edx
  1291.         sub     eax, ecx
  1292.         jmp     .text_draw
  1293. .text_align_center:
  1294.         mov     eax, edx
  1295.         sub     eax, ecx
  1296.         shr     eax, 1
  1297.         jmp     .text_draw
  1298. .text_align_left:
  1299.         xor     eax, eax
  1300. .text_draw:
  1301.         push    ecx
  1302.         mov     ecx, [esp+24]
  1303.         push    eax
  1304.         mov     eax, [ebx+dlgitemtemplate.x1]
  1305.         add     eax, [ecx+dlgtemplate.x]
  1306.         push    edx
  1307.         mov     edx, [ebx+dlgitemtemplate.y1]
  1308.         add     edx, [ecx+dlgtemplate.y]
  1309.         call    get_console_ptr
  1310.         pop     edx
  1311.         pop     ecx
  1312.         mov     ah, [esp+5]
  1313.         mov     al, ' '
  1314.         rep     stosw
  1315.         pop     ecx
  1316.         cmp     ecx, edx
  1317.         jbe     .text_copy
  1318.         cmp     [ebx+dlgitemtemplate.type], 3
  1319.         jnz     @f
  1320.         mov     ecx, edx
  1321.         jmp     .text_copy
  1322. @@:
  1323.         cmp     edx, 3
  1324.         jb      .ret
  1325.         mov     al, '.'
  1326.         stosw
  1327.         stosw
  1328.         stosw
  1329.         add     esi, ecx
  1330.         mov     ecx, edx
  1331.         sub     ecx, 3
  1332.         sub     esi, ecx
  1333. .text_copy:
  1334.         jecxz   .ret
  1335. @@:
  1336.         lodsb
  1337.         stosw
  1338.         loop    @b
  1339. .ret:
  1340.         mov     ecx, [esp+20]
  1341.         mov     eax, [ecx+dlgtemplate.x]
  1342.         mov     edx, [ecx+dlgtemplate.y]
  1343.         add     eax, [ebx+dlgitemtemplate.x2]
  1344.         inc     eax
  1345.         add     edx, [ebx+dlgitemtemplate.y1]
  1346.         mov     ecx, edi
  1347.         call    get_console_ptr
  1348.         xchg    ecx, edi
  1349.         sub     ecx, edi
  1350.         shr     ecx, 1
  1351.         pop     eax
  1352.         mov     al, ' '
  1353.         rep     stosw
  1354.         ret
  1355.  
  1356. draw_button:
  1357.         mov     ah, [dialog_normal_btn_color]
  1358.         test    [ebx+dlgitemtemplate.flags], 4
  1359.         jz      @f
  1360.         mov     ah, [dialog_selected_btn_color]
  1361. @@:
  1362.         jmp     draw_text
  1363.  
  1364. draw_editbox:
  1365.         mov     edx, [ebx+dlgitemtemplate.data]
  1366.         test    [ebx+dlgitemtemplate.flags], 4
  1367.         jz      @f
  1368.         mov     eax, [ebx+dlgitemtemplate.x1]
  1369.         add     eax, [edx+4]
  1370.         sub     eax, [edx+8]
  1371.         mov     ecx, [esp+16]
  1372.         add     eax, [ecx+dlgtemplate.x]
  1373.         mov     [cursor_x], eax
  1374.         mov     eax, [ebx+dlgitemtemplate.y1]
  1375.         add     eax, [ecx+dlgtemplate.y]
  1376.         mov     [cursor_y], eax
  1377. @@:
  1378.         mov     ah, [dialog_edit_color]
  1379.         test    [ebx+dlgitemtemplate.flags], 10h
  1380.         jnz     @f
  1381.         mov     ah, [dialog_unmodified_edit_color]
  1382. @@:
  1383.         mov     esi, [ebx+dlgitemtemplate.data]
  1384.         add     esi, [edx+8]
  1385.         add     esi, 12
  1386.         jmp     draw_text_esi
  1387.