Subversion Repositories Kolibri OS

Rev

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

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GUI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4.  
  5. ;-----------------------------------------------------------------------------
  6. ;                             Color scheme
  7.  
  8. ;                         format - 0xRRGGBB
  9. COLOR_BG_NORMAL           equ 0x101010 ; was 0xFFFFFF white
  10. COLOR_BG_BREAKPOINT       equ 0xFF0000 ; red
  11. COLOR_BG_SELECTED         equ 0x0000FF ; blue
  12. COLOR_LINE                equ 0xFFFFFF ; was 0x000000 black
  13. COLOR_TXT_NORMAL          equ 0xFFFFFF ; was 0x000000 black
  14. COLOR_TXT_INACTIVE        equ 0x808080 ; grey
  15. COLOR_TXT_CHANGED         equ 0x00AA00 ; green
  16. COLOR_TXT_SELECTED        equ 0xFFFFFF ; white
  17.  
  18. ;-----------------------------------------------------------------------------
  19.  
  20. data_width equ 80
  21. data_x_pos equ 12
  22. data_x_size equ data_width*6
  23.  
  24. title_x_pos equ 30
  25. title_y_pos equ 32
  26. title_y_size equ 10
  27.  
  28. ;dump_y_pos equ (registers_y_pos + registers_y_size + 5)
  29. dump_y_pos equ (title_y_pos + title_y_size)
  30. dump_height equ 6
  31. dump_y_size equ (dump_height*10)
  32.  
  33. disasm_y_pos equ (dump_y_pos + dump_y_size + 4)
  34. disasm_height equ 18
  35. disasm_y_size equ (disasm_height*10)
  36.  
  37. messages_width equ data_width
  38. messages_height equ 8
  39. messages_x_pos equ data_x_pos
  40. messages_y_pos equ (disasm_y_pos + disasm_y_size + 4)
  41. messages_x_size equ messages_width*6
  42. messages_y_size equ messages_height*10
  43.  
  44. cmdline_width equ data_width
  45. cmdline_x_pos equ data_x_pos
  46. cmdline_y_pos equ (messages_y_pos + messages_y_size + 4)
  47. cmdline_x_size equ messages_x_size
  48. cmdline_y_size equ 10
  49.  
  50. registers_x_pos equ (data_x_pos + messages_x_size + 4)
  51. registers_y_pos equ (title_y_pos + title_y_size - 3)
  52. registers_x_size equ 134
  53. registers_y_size equ (cmdline_y_pos + cmdline_y_size - registers_y_pos+1)
  54.  
  55. wnd_x_size equ (data_x_pos + messages_x_size + data_x_pos + registers_x_size+3)
  56. wnd_y_size equ (cmdline_y_pos + cmdline_y_size + data_x_pos)
  57.  
  58. ;-----------------------------------------------------------------------------
  59. ;                          Entry point
  60.  
  61. ; TODO: split all gui part in independent function, move entry point into mtdbg.asm
  62.  
  63. start:
  64.     ; initialize process heap
  65.         mcall   68, 11
  66.         mov     edi, messages
  67.         mov     ecx, messages_width*messages_height
  68.         mov     al, ' '
  69.         rep stosb
  70.         xor     eax, eax
  71.         mov     [messages_pos], eax
  72.         mov     [cmdline_len], eax
  73.         mov     [cmdline_pos], eax
  74.         mov     edi, needzerostart
  75.         mov     ecx, (needzeroend-needzerostart+3)/4
  76.         rep stosd
  77.         mov     esi, begin_str
  78.         call    put_message_nodraw
  79.     ; set event mask - default events and debugging events
  80.         ;push   40
  81.         ;pop    eax
  82.         ;mov    ebx, 0x107
  83.         mcall   40, 0x107
  84.     ; set debug messages buffer
  85.         mov     ecx, dbgbufsize
  86.         mov     dword [ecx], 256
  87.         xor     ebx, ebx
  88.         mov     [ecx+4], ebx
  89.         mov     al, 69
  90.         mcall
  91.         mov     esi, i_param
  92.         call    get_arg.skip_spaces
  93.         test    al, al
  94.         jz      dodraw
  95.         push    esi
  96.         call    draw_window
  97.         pop     esi
  98.         call    OnLoadInit
  99.         jmp     waitevent
  100.  
  101. dodraw:
  102.         call    draw_window
  103.  
  104. waitevent:
  105.         ;push   10
  106.         ;pop    eax
  107.         mcall   10
  108.         cmp     al, 9
  109.         jz      debugmsg
  110.         dec     eax
  111.         jz      dodraw
  112.         dec     eax
  113.         jz      keypressed
  114.         dec     eax
  115.         jnz     waitevent
  116.     ; button pressed - we have only one button (close)
  117.         ;push   -1
  118.         ;pop    eax
  119.         mcall   -1
  120.  
  121. ; TODO: split in more independent function
  122. keypressed:
  123.         mov     al, 2
  124.         mcall
  125.         shr     eax, 8
  126.         cmp     al, 8
  127.         jz      .backspace
  128.         cmp     al, 0xB0
  129.         jz      .left
  130.         cmp     al, 0xB3
  131.         jz      .right
  132.         cmp     al, 0x0D
  133.         jz      .enter
  134.         cmp     al, 0xB6
  135.         jz      .del
  136.         cmp     al, 0xB4
  137.         jz      .home
  138.         cmp     al, 0xB5
  139.         jz      .end
  140.         cmp     al, 0xB1
  141.         jz      .down
  142.         cmp     al, 0xB2
  143.         jz      .up
  144.         cmp     al, 0xD8
  145.         jz      CtrlF7
  146.         cmp     al, 0xD9
  147.         jz      CtrlF8
  148.         cmp     [cmdline_len], cmdline_width
  149.         jae     waitevent
  150.         push    eax
  151.         call    clear_cmdline_end
  152.         pop     eax
  153.         mov     edi, cmdline
  154.         mov     ecx, [cmdline_len]
  155.         add     edi, ecx
  156.         lea     esi, [edi-1]
  157.         sub     ecx, [cmdline_pos]
  158.         std
  159.         rep movsb
  160.         cld
  161.         stosb
  162.         inc     [cmdline_len]
  163.         call    draw_cmdline_end
  164.         inc     [cmdline_pos]
  165.         call    draw_cursor
  166.         jmp     waitevent
  167.  
  168.     .backspace:
  169.         cmp     [cmdline_pos], 0
  170.         jz      waitevent
  171.         dec     [cmdline_pos]
  172.  
  173.     .delchar:
  174.         call    clear_cmdline_end
  175.         mov     edi, [cmdline_pos]
  176.         dec     [cmdline_len]
  177.         mov     ecx, [cmdline_len]
  178.         sub     ecx, edi
  179.         add     edi, cmdline
  180.         lea     esi, [edi+1]
  181.         rep movsb
  182.         call    draw_cmdline_end
  183.         call    draw_cursor
  184.         jmp     waitevent
  185.  
  186.     .del:
  187.         mov     eax, [cmdline_pos]
  188.         cmp     eax, [cmdline_len]
  189.         jae     waitevent
  190.         jmp     .delchar
  191.  
  192.     .left:
  193.         cmp     [cmdline_pos], 0
  194.         jz      waitevent
  195.         call    hide_cursor
  196.         dec     [cmdline_pos]
  197.         call    draw_cursor
  198.         jmp     waitevent
  199.  
  200.     .right:
  201.         mov     eax, [cmdline_pos]
  202.         cmp     eax, [cmdline_len]
  203.         jae     waitevent
  204.         call    hide_cursor
  205.         inc     [cmdline_pos]
  206.         call    draw_cursor
  207.         jmp     waitevent
  208.  
  209.     .home:
  210.         call    hide_cursor
  211.         and     [cmdline_pos], 0
  212.         call    draw_cursor
  213.         jmp     waitevent
  214.  
  215.     .end:
  216.         call    hide_cursor
  217.         mov     eax, [cmdline_len]
  218.         mov     [cmdline_pos], eax
  219.         call    draw_cursor
  220.  
  221.     .up:
  222.     .down:
  223.         jmp     waitevent
  224.  
  225.     ; We also trying to execute previous command, if empty command_line
  226.     .enter:
  227.         mov     ecx, [cmdline_len]
  228.         test    ecx, ecx
  229.         jnz     .exec_cur
  230.         mov     cl, byte [cmdline_prev]
  231.         cmp     cl, 0
  232.         jz      waitevent
  233.  
  234.     .exec_prev:
  235.         mov     esi, cmdline_prev
  236.         jmp     .exec
  237.  
  238.     .exec_cur:
  239.         mov     esi, cmdline
  240.  
  241.     .exec:
  242.         mov     byte [esi+ecx], 0
  243.         and     [cmdline_pos], 0
  244.         push    esi
  245.         call    clear_cmdline_end
  246.         call    draw_cursor
  247.         pop     esi
  248.         and     [cmdline_len], 0
  249.     ; skip leading spaces
  250.         call    get_arg.skip_spaces
  251.         cmp     al, 0
  252.         jz      waitevent
  253.     ; now esi points to command
  254.         push    esi
  255.         mov     esi, prompt
  256.         call    put_message_nodraw
  257.         pop     esi
  258.         push    esi
  259.         call    put_message_nodraw
  260.  
  261. ; TODO: add meaningful name
  262. z1:
  263.         mov     esi, newline
  264.         call    put_message
  265.         pop     esi
  266.         push    esi
  267.         call    get_arg
  268.         mov     [curarg], esi
  269.         pop     edi
  270.         mov     esi, commands
  271.         call    find_cmd
  272.         mov     eax, aUnknownCommand
  273.         jc      .x11
  274.  
  275.     ; check command requirements
  276.     ; flags field:
  277.     ; &1: command may be called without parameters
  278.     ; &2: command may be called with parameters
  279.     ; &4: command may be called without loaded program
  280.     ; &8: command may be called with loaded program
  281.         mov     eax, [esi+8]
  282.         mov     ecx, [curarg]
  283.         cmp     byte [ecx], 0
  284.         jz      .noargs
  285.         test    byte [esi+16], 2
  286.         jz      .x11
  287.         jmp     @f
  288.  
  289.     .noargs:
  290.         test    byte [esi+16], 1
  291.         jz      .x11
  292.  
  293.     @@:
  294.         cmp     [debuggee_pid], 0
  295.         jz      .nodebuggee
  296.         mov     eax, aAlreadyLoaded
  297.         test    byte [esi+16], 8
  298.         jz      .x11
  299.         jmp     .x9
  300.  
  301.     .nodebuggee:
  302.         mov     eax, need_debuggee
  303.         test    byte [esi+16], 4
  304.         jnz     .x9
  305.  
  306.     .x11:
  307.         xchg    esi, eax
  308.         call    put_message
  309.  
  310.     ; store cmdline for repeating
  311.     .x10:
  312.         mov     esi, cmdline
  313.         mov     ecx, [cmdline_len]
  314.  
  315.     @@:
  316.         cmp     ecx, 0
  317.         jle     .we
  318.         mov     al, [esi + ecx]
  319.         mov     [cmdline_prev + ecx], al
  320.         dec     ecx
  321.         jmp     @b
  322.  
  323.     .we:
  324.         mov     [cmdline_len], 0
  325.         jmp     waitevent
  326.  
  327.     .x9:
  328.         call    dword [esi+4]
  329.         jmp     .x10
  330.  
  331. ;-----------------------------------------------------------------------------
  332. ;                            Cmdline handling
  333.  
  334. clear_cmdline_end:
  335.         mov     ebx, [cmdline_pos]
  336.         mov     ecx, [cmdline_len]
  337.         sub     ecx, ebx
  338.         ;push   13
  339.         ;pop    eax
  340.         imul    ebx, 6
  341.         imul    ecx, 6
  342.         inc     ecx
  343.         add     ebx, cmdline_x_pos
  344.         shl     ebx, 16
  345.         or      ebx, ecx
  346.         mov     ecx, cmdline_y_pos*10000h + cmdline_y_size
  347.         ; setting up container color scheme
  348.         ; COLOR_BG_NORMAL was 0xFFFFFF
  349.         mov     edx, COLOR_BG_NORMAL
  350.         ; draw container rectangle/box for cmdline
  351.         mcall   13
  352.         ret
  353.  
  354. draw_cmdline:
  355.         xor     ebx, ebx
  356.         jmp     @f
  357.  
  358. ; TODO: make it local
  359. draw_cmdline_end:
  360.         mov     ebx, [cmdline_pos]
  361.  
  362.     @@:
  363.         mov     esi, [cmdline_len]
  364.         sub     esi, ebx
  365.         ;push   4
  366.         ;pop    eax
  367.         ; setting up text color scheme and attributes
  368.         ; was 'xor     ecx, ecx'
  369.         mov     ecx, COLOR_TXT_NORMAL
  370.         lea     edx, [cmdline+ebx]
  371.         imul    ebx, 6
  372.         add     ebx, cmdline_x_pos
  373.         shl     ebx, 16
  374.         or      ebx, cmdline_y_pos+1
  375.         ; draw a text string in the window, color in ecx
  376.         mcall   4
  377.         ret
  378.  
  379. ;-----------------------------------------------------------------------------
  380. ;                        Working with messages
  381. ; in: esi->ASCIIZ message
  382. put_message_nodraw:
  383.         mov     edx, [messages_pos]
  384.  
  385.     .m:
  386.         lea     edi, [messages+edx]
  387.  
  388.     .l:
  389.         lodsb
  390.         cmp     al, 0
  391.         jz      .done
  392.         call    test_scroll
  393.         cmp     al, 10
  394.         jz      .newline
  395.         cmp     al, '%'
  396.         jnz     @f
  397.         cmp     dword [esp], z1
  398.         jnz     .format
  399.  
  400.     @@:
  401.         stosb
  402.         inc     edx
  403.         jmp     .l
  404.  
  405.     .newline:
  406.         push    edx
  407.         mov     ecx, messages_width
  408.         xor     eax, eax
  409.         xchg    eax, edx
  410.         div     ecx
  411.         xchg    eax, edx
  412.         pop     edx
  413.         test    eax, eax
  414.         jz      .m
  415.         sub     edx, eax
  416.         add     edx, ecx
  417.         jmp     .m
  418.  
  419.     .done:
  420.         mov     [messages_pos], edx
  421.         ret
  422.  
  423.     ; at this moment all format specs must be %<digit>X
  424.     .format:
  425.         lodsb   ; get <digit>
  426.         sub     al, '0'
  427.         movzx   ecx, al
  428.         lodsb
  429.         pop     eax
  430.         pop     ebp
  431.         push    eax
  432.     ; write number in ebp with ecx digits
  433.         dec     ecx
  434.         shl     ecx, 2
  435.  
  436.     .writenibble:
  437.         push    ecx
  438.         call    test_scroll
  439.         pop     ecx
  440.         mov     eax, ebp
  441.         shr     eax, cl
  442.         and     al, 0xF
  443.         cmp     al, 10
  444.         sbb     al, 69h
  445.         das
  446.         stosb
  447.         inc     edx
  448.         sub     ecx, 4
  449.         jns     .writenibble
  450.         jmp     .l
  451.  
  452. test_scroll:
  453.         cmp     edx, messages_width*messages_height
  454.         jnz     .ret
  455.         push    esi
  456.         mov     edi, messages
  457.         lea     esi, [edi+messages_width]
  458.         mov     ecx, (messages_height-1)*messages_width/4
  459.         rep movsd
  460.         push    eax
  461.         mov     al, ' '
  462.         push    edi
  463.         push    messages_width
  464.         pop     ecx
  465.         sub     edx, ecx
  466.         rep stosb
  467.         pop     edi
  468.         pop     eax
  469.         pop     esi
  470.  
  471.     .ret:
  472.         ret
  473.  
  474. ;-----------------------------------------------------------------------------
  475.  
  476. put_message:
  477.         call    put_message_nodraw
  478.  
  479. draw_messages:
  480.         ;push   13
  481.         ;pop    eax
  482.         ;mov    edx, 0xFFFFFF
  483.         ;mov    ebx, messages_x_pos*10000h+messages_x_size
  484.         ;mov    ecx, messages_y_pos*10000h+messages_y_size
  485.         ; draw container rectanle/box
  486.         ; COLOR_BG_NORMAL was 0xFFFFFF
  487.         mcall   13, messages_x_pos*10000h+messages_x_size, messages_y_pos*10000h+messages_y_size, COLOR_BG_NORMAL
  488.         mov     edx, messages
  489.         push    messages_width
  490.         pop     esi
  491.         ; setting up text color scheme/attributes
  492.         ; was 'xor     ecx, ecx'
  493.         mov     ecx, COLOR_TXT_NORMAL
  494.         ;mov    al, 4
  495.         mov     ebx, messages_x_pos*10000h+messages_y_pos
  496.  
  497.     @@:
  498.         ; display text string in the window
  499.         mcall   4
  500.         add     edx, esi
  501.         add     ebx, 10
  502.         cmp     edx, messages+messages_width*messages_height
  503.         jb      @b
  504.         ret
  505.  
  506. ;-----------------------------------------------------------------------------
  507. ;                     Show/hide cursor in command line
  508.  
  509. ; TODO: make it cursor.draw and cursor.hide ???
  510. draw_cursor:
  511.         ;push   38
  512.         ;pop    eax
  513.         mov     ecx, cmdline_y_pos*10001h+cmdline_y_size-1
  514.         mov     ebx, [cmdline_pos]
  515.         imul    ebx, 6
  516.         add     ebx, cmdline_x_pos
  517.         mov     edx, ebx
  518.         shl     ebx, 16
  519.         or      ebx, edx
  520.         ; setting line color
  521.         ; was 'xor     edx, edx' - black
  522.         mov     edx, COLOR_LINE
  523.         ; draw line, color in edx
  524.         mcall   38
  525.         ret
  526.  
  527. hide_cursor:
  528.         mov     ebx, [cmdline_pos]
  529.         ;push   13
  530.         ;pop    eax
  531.         imul    ebx, 6
  532.         add     ebx, cmdline_x_pos
  533.         shl     ebx, 16
  534.         inc     ebx
  535.         mov     ecx, cmdline_y_pos*10000h + cmdline_y_size
  536.         ; setting up rectangle color
  537.         ; was 0xFFFFFF
  538.         mov     edx, COLOR_BG_NORMAL
  539.         ; draw container rectangle/box
  540.         mcall   13
  541.         mov     ebx, [cmdline_pos]
  542.         cmp     ebx, [cmdline_len]
  543.         jae     .ret
  544.         ;mov    al, 4
  545.         ; setting up text color scheme and attributes
  546.         ;was 'xor     ecx, ecx'
  547.         mov     ecx, COLOR_TXT_NORMAL
  548.         lea     edx, [cmdline+ebx]
  549.         imul    ebx, 6
  550.         add     ebx, cmdline_x_pos
  551.         shl     ebx, 16
  552.         or      ebx, cmdline_y_pos+1
  553.         push    1
  554.         pop     esi
  555.         ; draw text string in the window
  556.         mcall   4
  557.  
  558.     .ret:
  559.         ret
  560.  
  561. ;-----------------------------------------------------------------------------
  562. ;                       Draw program window title
  563.  
  564. ; FIXME: something wrong here
  565. redraw_title:
  566.         ;push   13
  567.         ;pop    eax
  568.         ;mov    edx, 0xFFFFFF
  569.         ;mov    ebx, title_x_pos*10000h + data_x_pos+data_x_size-title_x_pos
  570.         ;mov    ecx, title_y_pos*10000h + title_y_size
  571.         ; draw container rectangle/box
  572.         ; color was 0xFFFFFF
  573.         mcall   13, title_x_pos*10000h+data_x_pos+data_x_size-title_x_pos, title_y_pos*10000h+title_y_size, COLOR_BG_NORMAL
  574.  
  575. draw_title:
  576.         ;mov    al, 38
  577.         ;mov    ebx, (data_x_pos-2)*10000h + title_x_pos-5
  578.         ;mov    ecx, (title_y_pos+5)*10001h
  579.         ; draw line with COLOR_LINE (in edx)
  580.         ; was 'xor     edx, edx'
  581.         mcall   38, (data_x_pos-2)*10000h+title_x_pos-5, (title_y_pos+5)*10001h, COLOR_LINE
  582.         push    NoPrgLoaded_len
  583.         pop     esi
  584.         cmp     [debuggee_pid], 0
  585.         jz      @f
  586.         mov     esi, [prgname_len]
  587.  
  588.     @@:
  589.         imul    ebx, esi, 6
  590.         add     ebx, title_x_pos+4
  591.         shl     ebx, 16
  592.         mov     bx, data_x_pos+data_x_size-10-5-6*7
  593.         cmp     [bSuspended], 0
  594.         jz      @f
  595.         add     ebx, 6
  596.  
  597.     @@:
  598.         ; draw line with COLOR_LINE (in edx)
  599.         mcall
  600.         mov     ebx, (data_x_pos+data_x_size-10+4)*0x10000 + data_x_pos+data_x_size+2
  601.         ; draw line with COLOR_LINE (in edx)
  602.         mcall
  603.         mov     al, 4
  604.         mov     ebx, title_x_pos*10000h+title_y_pos
  605.         ; setting up text color scheme and attributes
  606.         ; was 'xor     ecx, ecx'
  607.         mov     ecx, COLOR_TXT_NORMAL
  608.         mov     edx, NoPrgLoaded_str
  609.         cmp     [debuggee_pid], 0
  610.         jz      @f
  611.         mov     edx, [prgname_ptr]
  612.  
  613.     @@:
  614.         ; draw text string in the window
  615.         mcall
  616.         cmp     [debuggee_pid], 0
  617.         jz      .nodebuggee
  618.         mov     ebx, (data_x_pos+data_x_size-10-6*7)*10000h + title_y_pos
  619.         mov     edx, aRunning
  620.         push    7
  621.         pop     esi
  622.         cmp     [bSuspended], 0
  623.         jz      @f
  624.         add     ebx, 6*10000h
  625.         mov     edx, aPaused
  626.         dec     esi
  627.  
  628.     @@:
  629.         ; draw line with COLOR_LINE (in edx) in one case
  630.         ; and draw text string with color COLOR_TXT_NORMAL (in ecx) in another
  631.         mcall
  632.         ret
  633.  
  634.     .nodebuggee:
  635.         mov     al, 38
  636.         mov     ebx, (data_x_pos+data_x_size-10-6*7-5)*0x10000 + data_x_pos+data_x_size+2
  637.         mov     ecx, (title_y_pos+5)*10001h
  638.         ; setting up line color scheme
  639.         ; was 'xor     edx, edx'
  640.         mov     edx, COLOR_LINE
  641.         jmp     @b
  642.  
  643. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  644. ;;;;;;;;;;;;;;;;;;; REGISTERS PANEL ;;;;;;;;;;;;;;;;;;;;;;;;;;
  645. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  646.  
  647. ;-----------------------------------------------------------------------------
  648. ;                      Display common register content
  649.  
  650. ; TODO: add format support (e.g. numerical value, or address offset/pointer)
  651.  
  652. ; in: esi->value, edx->string, ecx = string length, ebx = coord
  653. draw_register:
  654.         push    edx
  655.         push    ecx
  656.         push    esi
  657.         mov     eax, esi
  658.         mov     esi, ecx
  659.     ; setting up registers colors
  660.     ; can be usual, inactive and changed
  661.         ; inactive color
  662.         ; was 0x40808080 - grey
  663.         mov     ecx, (COLOR_TXT_INACTIVE or 0x40000000)
  664.         cmp     [debuggee_pid], 0
  665.         jz      .cd
  666.         cmp     [bSuspended], 0
  667.         jz      .cd
  668.         ; normal color
  669.         ; was 0x40000000 - black
  670.         mov     ecx, (COLOR_TXT_NORMAL or 0x40000000)
  671.         push    edi
  672.         mov     edi, [eax]
  673.         cmp     dword [eax+oldcontext-context], edi
  674.         pop     edi
  675.         jz      .cd
  676.         ; changed register color
  677.         ; was 0x4000AA00 - green
  678.         mov     ecx, (COLOR_TXT_CHANGED or 0x40000000)
  679.  
  680.     .cd:
  681.         ;push   4
  682.         ;pop    eax
  683.         ; draw a text string in the window
  684.         mcall   4
  685.         imul    esi, 60000h
  686.         lea     edx, [ebx+esi]
  687.         ;mov    al, 47
  688.         ;mov    ebx, 80101h
  689.         mov     esi, ecx
  690.         pop     ecx
  691.         ; draw a number in the window
  692.         ; color in the esi (same value as for usual text)
  693.         mcall   47, 80101h
  694.         lea     ebx, [edx+60000h*18]
  695.         mov     esi, ecx
  696.         pop     ecx
  697.         pop     edx
  698.         add     edx, ecx
  699.         ret
  700.  
  701. ;-----------------------------------------------------------------------------
  702. ;                  Display FPU register (ST0 - ST7) content
  703. ;
  704. ; in: esi->value, edx->string, ecx = string length, ebx = coord
  705. draw_fpu_register:
  706.         push    edx
  707.         push    ecx
  708.         push    esi
  709.         mov     eax, esi
  710.         mov     esi, ecx
  711.     ; setting up registers color
  712.     ; can be usual, inactive and changed
  713.         ; inactive color
  714.         ; was 0x40808080 - grey
  715.         mov     ecx, (COLOR_TXT_INACTIVE or 0x40000000)
  716.         cmp     [debuggee_pid], 0
  717.         jz      .cd
  718.         cmp     [bSuspended], 0
  719.         jz      .cd
  720.         ; normal color
  721.         ; was 0x40000000 - black
  722.         mov     ecx, (COLOR_TXT_NORMAL or 0x40000000)
  723.         push    edi
  724.         mov     edi, [eax]
  725.         cmp     dword [eax+oldcontext-context], edi
  726.         pop     edi
  727.         jnz     .scol
  728.         push    edi
  729.         mov     edi, [eax+4]
  730.         cmp     dword [eax+oldcontext-context+4], edi
  731.         pop     edi
  732.         jz      .cd
  733.  
  734.     .scol:
  735.         ; changed register color
  736.         ; was 0x4000AA00 - green
  737.         mov     ecx, (COLOR_TXT_CHANGED or 0x40000000)
  738.  
  739.     .cd:
  740.         ;push   4
  741.         ;pop    eax
  742.         ; draw a text string in the window
  743.         mcall   4
  744.         imul    esi, 60000h
  745.         lea     edx, [ebx+esi]
  746.         ;mov    al, 47
  747.         ;mov    ebx, 40100101h ; [20] show 16 chars set [30] bit - qword
  748.         mov     esi, ecx
  749.         pop     ecx
  750.         ; draw a number in the window
  751.         ; color is the same as for previous text draw function
  752.         ; ebx : [20] show 16 chars set [30] bit - qword
  753.         mcall   47, 40100101h
  754.         lea     ebx, [edx+60000h*18]
  755.         mov     esi, ecx
  756.         pop     ecx
  757.         pop     edx
  758.         add     edx, ecx
  759.         ret
  760.  
  761. ;-----------------------------------------------------------------------------
  762. ;                      Show FPU MMX register content
  763. ;
  764. ; in: esi->value, edx->string, ecx = string length, ebx = coord
  765. draw_mmx_register:
  766.         push    edx
  767.         push    ecx
  768.         push    esi
  769.         mov     eax, esi
  770.         mov     esi, ecx
  771.     ; setting up registers color
  772.     ; can be usual, inactive and changed
  773.         ; inactive color
  774.         ; was 0x40808080 - grey
  775.         mov     ecx, (COLOR_TXT_INACTIVE or 0x40000000)
  776.         cmp     [debuggee_pid], 0
  777.         jz      .cd
  778.         cmp     [bSuspended], 0
  779.         jz      .cd
  780.         ; normal color
  781.         ; was 0x40000000 - black
  782.         mov     ecx, (COLOR_TXT_NORMAL or 0x40000000)
  783.         push    edi
  784.         mov     edi, [eax]
  785.         cmp     dword [eax+oldcontext-context], edi
  786.         pop     edi
  787.         jnz     .scol
  788.         push    edi
  789.         mov     edi, [eax+4]
  790.         cmp     dword [eax+oldcontext-context+4], edi
  791.         pop     edi
  792.         jz      .cd
  793.  
  794.     .scol:
  795.         ; changed color
  796.         ; was 0x4000AA00 - green
  797.         mov     ecx, (COLOR_TXT_CHANGED or 0x40000000)
  798.  
  799.     .cd:
  800.         ;push   4
  801.         ;pop    eax
  802.         ; draw a text string in the window
  803.         mcall   4
  804.         imul    esi, 60000h
  805.         lea     edx, [ebx+esi]
  806.         ;mov    al, 47
  807.         ;mov    ebx, 40100101h ; [20] show 16 chars set [30] bit - qword
  808.         mov     esi, ecx
  809.         pop     ecx
  810.         ; draw a number in the window
  811.         ; color is the same as for previous draw text function
  812.         ; ebx : [20] show 16 chars set [30] bit - qword
  813.         mcall   47, 40100101h
  814.         lea     ebx, [edx+60000h*18]
  815.         mov     esi, ecx
  816.         pop     ecx
  817.         pop     edx
  818.         add     edx, ecx
  819.         ret
  820.  
  821. ; TODO add SSE registers
  822. ; TODO add AVX registers
  823.  
  824. ;-----------------------------------------------------------------------------
  825. ;                   Display contents of EFLAGS register
  826. draw_flag:
  827.         movzx   edi, byte [edx+7]
  828.         bt      [_eflags], edi
  829.         jc      .on
  830.         or      byte [edx], 20h
  831.         jmp     .onoff
  832.  
  833.     .on:
  834.         and     byte [edx], not 20h
  835.  
  836.     .onoff:
  837.     ; setting up registers colors
  838.     ; can be usual, inactive and changed
  839.         ; inactive color
  840.         ; was 0x40808080 - grey
  841.         mov     ecx, (COLOR_TXT_INACTIVE or 0x40000000)
  842.         cmp     [debuggee_pid], 0
  843.         jz      .doit
  844.         cmp     [bSuspended], 0
  845.         jz      .doit
  846.         ; normal color
  847.         ; was 0x40000000 - black
  848.         mov     ecx, (COLOR_TXT_NORMAL or 0x40000000)
  849.         bt      [_eflags], edi
  850.         lahf
  851.         bt      dword [_eflags + oldcontext - context], edi
  852.         rcl     ah, 1
  853.         test    ah, 3
  854.         jp      .doit
  855.         ; changed color
  856.         ; was 0x4000AA00 - green
  857.         mov     ecx, (COLOR_TXT_CHANGED or 0x40000000)
  858.  
  859.     .doit:
  860.         mov     ah, 0
  861.         ; background color for text string or number
  862.         ; was 0xFFFFFF - white
  863.         mov     edi, COLOR_BG_NORMAL
  864.         ; draw a text string in the window in one case
  865.         ; and a number in another
  866.         ; color scheme same as for previously called function (was in ecx)
  867.         mcall
  868.         ret
  869.  
  870. ;-----------------------------------------------------------------------------
  871. ;                      Draw registers frame title
  872.  
  873. ; Also show current register set (common + MMX, SSE or AVX)
  874. draw_reg_title:
  875.         ;push   4
  876.         ;pop    eax
  877.     ; setting up text backround color
  878.         ; was 0xFFFFFF - white
  879.         mov     edi, COLOR_BG_NORMAL
  880.     ; setting up text color
  881.     ; can be usual and inactive
  882.         ; normal color
  883.         ; was 0x40000000 - black
  884.         mov     ecx, (COLOR_TXT_NORMAL or 0x40000000)
  885.         mov     esi, 7
  886.         cmp     [reg_mode], REG_MODE_CPU
  887.         jz      @f
  888.         ; inactive color
  889.         ; was 0x40808080 - grey
  890.         mov     ecx, (COLOR_TXT_INACTIVE or 0x40000000)
  891.  
  892.     @@:
  893.         mov     edx, aMain
  894.         ;mov    ebx, (registers_x_pos+4)*10000h + registers_y_pos+2
  895.         ; draw a text string in the window
  896.         mcall   4, (registers_x_pos+4)*10000h+registers_y_pos+2
  897.         cmp     [reg_mode], REG_MODE_SSE
  898.         jz      @f
  899.         ; inactive color
  900.         ; was 0x40808080 - grey
  901.         mov     ecx, (COLOR_TXT_INACTIVE or 0x40000000)
  902.  
  903.     @@:
  904.         mov     edx, aSSE
  905.         ;mov        ebx, (registers_x_pos+46)*10000h + registers_y_pos+2
  906.         ; draw a text string in the window
  907.         mcall   4, (registers_x_pos+46)*10000h+registers_y_pos+2
  908.         cmp     [reg_mode], REG_MODE_AVX
  909.         jz      @f
  910.         ; inactive color
  911.         ; was 0x40808080 - grey
  912.         mov     ecx, (COLOR_TXT_INACTIVE or 0x40000000)
  913.  
  914.     @@:
  915.         mov     edx, aAVX
  916.         ;mov    ebx, (registers_x_pos+88)*10000h + registers_y_pos+2
  917.         ; draw a text string in the window
  918.         mcall   4, (registers_x_pos+88)*10000h+registers_y_pos+2
  919.         ret
  920.  
  921. ;-----------------------------------------------------------------------------
  922. ;                Display common registers set + MMX + FPU
  923.  
  924. draw_main_registers:
  925.         ;push    13
  926.         ;pop     eax
  927.         ;mov     edx, 0xFFFFFF
  928.         ;mov     ebx, (registers_x_pos-1)*10000h + (registers_x_size+2)
  929.         ;mov     ecx, (registers_y_pos-1)*10000h + (registers_y_size+2)
  930.         ; draw container rectangle/box with COLOR_BG_NORMAL
  931.         ; color in edx, was 0xFFFFFF - white
  932.         mcall   13, (registers_x_pos-1)*10000h+(registers_x_size+2), (registers_y_pos-1)*10000h+(registers_y_size+2), COLOR_BG_NORMAL
  933.  
  934.     ; TODO: add support for FPU ST0-ST7 registers
  935.     .redraw:
  936.         ; setting up background color for text and numbers output
  937.         ; was 0xFFFFFF - white
  938.         mov     edi, COLOR_BG_NORMAL
  939.         mov     esi, _eax
  940.         push    4
  941.         pop     ecx
  942.         mov     edx, regs_strs
  943.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+22
  944.         call    draw_register
  945.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+32
  946.         add     esi, _ebx-_eax
  947.         call    draw_register
  948.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+42
  949.         add     esi, _ecx-_ebx
  950.         call    draw_register
  951.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+52
  952.         add     esi, _edx-_ecx
  953.         call    draw_register
  954.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+62
  955.         add     esi, _esi-_edx
  956.         call    draw_register
  957.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+72
  958.         add     esi, _edi-_esi
  959.         call    draw_register
  960.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+82
  961.         add     esi, _ebp-_edi
  962.         call    draw_register
  963.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+92
  964.         add     esi, _esp-_ebp
  965.         call    draw_register
  966.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+102
  967.         add     esi, _eip-_esp
  968.         call    draw_register
  969.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+112
  970.         push    cx
  971.         mov     cl, 7
  972.         add     esi, _eflags-_eip
  973.         call    draw_register
  974.         pop     cx
  975.  
  976.     ; MMX registers
  977.         mov     edx, mmx_strs
  978.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+142
  979.         mov     esi, _mm0
  980.         call    draw_mmx_register
  981.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+152
  982.         add     esi, _mm1-_mm0
  983.         call    draw_mmx_register
  984.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+162
  985.         add     esi, _mm2-_mm1
  986.         call    draw_mmx_register
  987.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+172
  988.         add     esi, _mm3-_mm2
  989.         call    draw_mmx_register
  990.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+182
  991.         add     esi, _mm4-_mm3
  992.         call    draw_mmx_register
  993.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+192
  994.         add     esi, _mm5-_mm4
  995.         call    draw_mmx_register
  996.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+202
  997.         add     esi, _mm6-_mm5
  998.         call    draw_mmx_register
  999.         mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+212
  1000.         add     esi, _mm7-_mm6
  1001.         call    draw_mmx_register
  1002.         ;mov    al, 4
  1003.         ; setting up text color
  1004.         ; inactive color
  1005.         ; was 0x808080 - grey
  1006.         mov     ecx, COLOR_TXT_INACTIVE
  1007.         cmp     [debuggee_pid], 0
  1008.         jz      @f
  1009.         cmp     [bSuspended], 0
  1010.         jz      @f
  1011.         xor     ecx, ecx
  1012.  
  1013.     @@:
  1014.         mov     edx, aColon
  1015.         xor     esi, esi
  1016.         inc     esi
  1017.         ;mov    ebx, (registers_x_pos+10)*10000h + registers_y_pos+122
  1018.         ; draw a text string in the window, color in ecx
  1019.         mcall   4, (registers_x_pos+10)*10000h+registers_y_pos+122
  1020.         mov     edx, flags
  1021.  
  1022.     @@:
  1023.         add     ebx, 2*6*10000h
  1024.         call    draw_flag
  1025.         inc     edx
  1026.         cmp     dl, flags_bits and 0xFF
  1027.         jnz     @b
  1028.         ret
  1029.  
  1030. ;-----------------------------------------------------------------------------
  1031. ;                  Draw SSE registers set
  1032.  
  1033. draw_sse_registers:
  1034.     .redraw:
  1035.         ret
  1036.  
  1037. ;-----------------------------------------------------------------------------
  1038. ;                  Draw AVX registers set
  1039.  
  1040. draw_avx_registers:
  1041.     .redraw:
  1042.         ret
  1043.  
  1044. ;-----------------------------------------------------------------------------
  1045. ;                 Draw all registers sets
  1046. draw_registers:
  1047.         call    draw_reg_title
  1048.         cmp     [reg_mode], REG_MODE_CPU
  1049.         jnz     @f
  1050.         call    draw_main_registers
  1051.         ret
  1052.  
  1053.     @@:
  1054.         cmp     [reg_mode], REG_MODE_SSE
  1055.         jnz     @f
  1056.         call    draw_sse_registers
  1057.         ret
  1058.  
  1059.     @@:
  1060.         call    draw_avx_registers
  1061.         ret
  1062.  
  1063.     .redraw:
  1064.         call    draw_reg_title
  1065.         cmp     [reg_mode], REG_MODE_CPU
  1066.         jnz     @f
  1067.         call    draw_main_registers.redraw
  1068.         ret
  1069.  
  1070.     @@:
  1071.         cmp     [reg_mode], REG_MODE_SSE
  1072.         jnz     @f
  1073.         call    draw_sse_registers.redraw
  1074.         ret
  1075.  
  1076.     @@:
  1077.         call    draw_avx_registers.redraw
  1078.         ret
  1079.  
  1080. ;-----------------------------------------------------------------------------
  1081. ;                     Display memory dump
  1082.  
  1083. draw_dump:
  1084.         ;push    13
  1085.         ;pop     eax
  1086.         ;mov     edx, 0xFFFFFF
  1087.         ;mov     ebx, data_x_pos*10000h + data_x_size
  1088.         ;mov     ecx, dump_y_pos*10000h + dump_y_size
  1089.         ; draw container rectangle/box in the window
  1090.         ; with color in COLOR_BG_NORMAL (was 0xFFFFFF - white)
  1091.         mcall   13, data_x_pos*10000h+data_x_size, dump_y_pos*10000h+dump_y_size, COLOR_BG_NORMAL
  1092.  
  1093.     .redraw:
  1094.     ; addresses
  1095.         ;mov    al, 47
  1096.         mov     ebx, 80100h
  1097.         mov     edx, data_x_pos*10000h + dump_y_pos
  1098.         mov     ecx, [dumppos]
  1099.         ; background color for text string
  1100.         ; was 0xFFFFFF - white
  1101.         mov     edi, COLOR_BG_NORMAL
  1102.         ; inactive color
  1103.         ; was 0x40808080 - grey
  1104.         mov     esi, (COLOR_TXT_INACTIVE or 0x40000000)
  1105.         cmp     [debuggee_pid], 0
  1106.         jz      @f
  1107.         cmp     [bSuspended], 0
  1108.         jz      @f
  1109.         ; normal color
  1110.         ; was 0x40000000 - black
  1111.         mov     esi, (COLOR_TXT_NORMAL or 0x40000000)
  1112.  
  1113.     @@:
  1114.         ; draw a number in the window, color in esi
  1115.         mcall   47
  1116.         add     ecx, 10h
  1117.         add     edx, 10
  1118.         cmp     dl, dump_y_pos + dump_y_size
  1119.         jb      @b
  1120.     ; hex dump of data
  1121.         mov     ecx, dumpdata
  1122.         push    ecx
  1123.         xor     ebx, ebx
  1124.         mov     edx, (data_x_pos+12*6)*10000h + dump_y_pos
  1125.         cmp     [dumpread], ebx
  1126.         jz      .hexdumpdone1
  1127.  
  1128.     .hexdumploop1:
  1129.         push    ebx
  1130.         mov     ebx, 20101h
  1131.         ; draw a number in the window, color in esi
  1132.         mcall
  1133.         pop     ebx
  1134.         add     edx, 3*6*10000h
  1135.         inc     ecx
  1136.         inc     ebx
  1137.         test    bl, 15
  1138.         jz      .16
  1139.         test    bl, 7
  1140.         jnz     @f
  1141.         add     edx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h
  1142.  
  1143.     .16:
  1144.         add     edx, 10 - 6*(3*10h+2)*10000h
  1145.  
  1146.     @@:
  1147.         cmp     ebx, [dumpread]
  1148.         jb      .hexdumploop1
  1149.  
  1150.     .hexdumpdone1:
  1151.         mov     al, 4
  1152.         ; copy color value from esi to ecx
  1153.         ; to draw text string with 'mcall 4'
  1154.         mov     ecx, esi
  1155.         xchg    ebx, edx
  1156.         push    2
  1157.         pop     esi
  1158.  
  1159.     .hexdumploop2:
  1160.         cmp     edx, dump_height*10h
  1161.         jae     .hexdumpdone2
  1162.         push    edx
  1163.         mov     edx, aQuests
  1164.         ; draw text string with color in ecx, copied from esi
  1165.         mcall
  1166.         pop     edx
  1167.         add     ebx, 3*6*10000h
  1168.         inc     edx
  1169.         test    dl, 15
  1170.         jz      .16x
  1171.         test    dl, 7
  1172.         jnz     .hexdumploop2
  1173.         add     ebx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h
  1174.  
  1175.     .16x:
  1176.         add     ebx, 10 - 6*(3*10h+2)*10000h
  1177.         jmp     .hexdumploop2
  1178.  
  1179.     .hexdumpdone2:
  1180.         dec     esi
  1181.     ; colon, minus signs
  1182.         mov     ebx, (data_x_pos+8*6)*10000h + dump_y_pos
  1183.         mov     edx, aColon
  1184.  
  1185.     @@:
  1186.         mcall
  1187.         add     ebx, 10
  1188.         cmp     bl, dump_y_pos+dump_height*10
  1189.         jb      @b
  1190.         mov     ebx, (data_x_pos+(12+3*8)*6)*10000h + dump_y_pos
  1191.         mov     edx, aMinus
  1192.  
  1193.     @@:
  1194.         mcall
  1195.         add     ebx, 10
  1196.         cmp     bl, dump_y_pos+dump_height*10
  1197.         jb      @b
  1198.     ; ASCII data
  1199.         mov     ebx, (data_x_pos+(12+3*10h+2+2)*6)*10000h + dump_y_pos
  1200.         pop     edx
  1201.         push    dump_height*10h
  1202.  
  1203.     .asciiloop:
  1204.         push    edx
  1205.         cmp     byte [edx], 20h
  1206.         jae     @f
  1207.         mov     edx, aPoint
  1208.  
  1209.     @@:
  1210.         ; draw a text string in the window, color in ecx
  1211.         mcall
  1212.         pop     edx
  1213.         inc     edx
  1214.         add     ebx, 6*10000h
  1215.         dec     dword [esp]
  1216.         jz      .asciidone
  1217.         test    byte [esp], 15
  1218.         jnz     .asciiloop
  1219.         add     ebx, 10 - 6*10h*10000h
  1220.         jmp     .asciiloop
  1221.  
  1222.     .asciidone:
  1223.         pop     ecx
  1224.         ret
  1225.  
  1226. ;-----------------------------------------------------------------------------
  1227. ;                   Display disassembled code
  1228.  
  1229. ; @@@@@ WAS:
  1230. ; redraw_disasm:
  1231. ;       push    13
  1232. ;       pop     eax
  1233. ;       mov     edx, 0xFFFFFF
  1234. ;       mov     ebx, data_x_pos*10000h + data_x_size
  1235. ;       mov     ecx, (disasm_y_pos-1)*10000h + (disasm_y_size+1)
  1236. ;       mcall
  1237. ;
  1238. ; @@@@@ NOW:
  1239. draw_disasm:
  1240.  
  1241.     .redraw:
  1242.         mov     eax, [disasm_start_pos]
  1243.         mov     [disasm_cur_pos], eax
  1244.         and     [disasm_cur_str], 0
  1245.  
  1246.     .loop:
  1247.         mov     eax, [disasm_cur_pos]
  1248.         call    find_symbol
  1249.         jc      .nosymb
  1250.         mov     ebx, [disasm_cur_str]
  1251.         imul    ebx, 10
  1252.         push    ebx
  1253.         lea     ecx, [ebx+disasm_y_pos-1]
  1254.         shl     ecx, 16
  1255.         mov     cl, 11
  1256.         ; setting up background color for disassembled text
  1257.         mov     edx, COLOR_BG_NORMAL
  1258.         ;mov    ebx, data_x_pos*10000h + data_x_size
  1259.         ;push   13
  1260.         ;pop    eax
  1261.         ; draw container rectangle/box with color COLOR_BG_NORMAL (was 0xFFFFFF - white)
  1262.         mcall   13, data_x_pos*10000h+data_x_size
  1263.         pop     ebx
  1264.         ; copy color value from edx (COLOR_BG_NORMAL)
  1265.         mov     edi, edx
  1266.         add     ebx, (data_x_pos+6*2)*10000h+disasm_y_pos
  1267.         mov     edx, esi
  1268.  
  1269.     @@:
  1270.         lodsb
  1271.         test    al, al
  1272.         jnz     @b
  1273.         mov     byte [esi-1], ':'
  1274.         sub     esi, edx
  1275.         ; normal color
  1276.         ; was 0x40000000
  1277.         mov     ecx, (COLOR_TXT_NORMAL or 0x40000000)
  1278.         mov     al, 4
  1279.         ; draw a text string in the window with color COLOR_TXT_NORMAL in ecx
  1280.         mcall
  1281.         mov     byte [esi+edx-1], 0
  1282.         lea     esi, [esi*3]
  1283.         movzx   ecx, bx
  1284.         shr     ebx, 16
  1285.         lea     ebx, [ebx+esi*2]
  1286.         shl     ecx, 16
  1287.         mov     cl, 10
  1288.         imul    ebx, 10001h
  1289.         sub     bx, data_x_pos+data_x_size
  1290.         neg     bx
  1291.         mov     al, 13
  1292.         ; copy color value from edi
  1293.         mov     edx, edi
  1294.         ; draw container rectangle/box for disassembled text, color in edx
  1295.         mcall
  1296.         inc     [disasm_cur_str]
  1297.         cmp     [disasm_cur_str], disasm_height
  1298.         jae     .loopend
  1299.  
  1300.     .nosymb:
  1301.         push    [disasm_cur_pos]
  1302.         call    disasm_instr
  1303.         pop     ebp
  1304.         jc      .loopend
  1305.         ; setting up colors
  1306.         ; was 'xor     esi, esi' - default color: black
  1307.         mov     esi, COLOR_TXT_NORMAL
  1308.         ; was 0xFFFFFF - default background: white
  1309.         mov     edx, COLOR_BG_NORMAL
  1310.         mov     ebx, data_x_pos*10000h + data_x_size
  1311.         mov     ecx, [disasm_cur_str]
  1312.         imul    ecx, 10*10000h
  1313.         add     ecx, (disasm_y_pos-1)*10000h + 10
  1314.         mov     eax, ebp
  1315.         pushad
  1316.         call    find_enabled_breakpoint
  1317.         popad
  1318.         jnz     .nored
  1319.         ; setting up background color for breakpoint
  1320.         ; was 0xFF0000 - red
  1321.         mov     edx, COLOR_BG_BREAKPOINT
  1322.  
  1323.     .nored:
  1324.         mov     eax, [_eip]
  1325.         cmp     eax, ebp
  1326.         jnz     .noblue
  1327.         ; setting up background color for selected text
  1328.         ; (current running instruction)
  1329.         ; was 0x0000FF - blue
  1330.         mov     edx, COLOR_BG_SELECTED
  1331.         ; setting up selected text color
  1332.         ; (current running  instruction)
  1333.         ; was 0xFFFFFF - white
  1334.         mov     esi, COLOR_TXT_SELECTED
  1335.  
  1336.     .noblue:
  1337.         ;push   13
  1338.         ;pop    eax
  1339.         ; draw container rectangle/box for disassembled text
  1340.         ; color in edx
  1341.         mcall   13
  1342.         ;mov    al, 47
  1343.         ;mov    ebx, 80100h
  1344.         mov     edx, [disasm_cur_str]
  1345.         imul    edx, 10
  1346.         add     edx, data_x_pos*10000h + disasm_y_pos
  1347.         ;mov    ecx, ebp
  1348.         ; draw a number in the window, color in esi
  1349.         mcall   47, 80100h, ebp
  1350.         ;mov    al, 4
  1351.         lea     ebx, [edx+8*6*10000h]
  1352.         ; copy color value from esi
  1353.         mov     ecx, esi
  1354.         push    2
  1355.         pop     esi
  1356.         mov     edx, aColon
  1357.         ; draw a text string in the window, color in ecx
  1358.         mcall   4
  1359.         push    9
  1360.         pop     edi
  1361.         lea     edx, [ebx+2*6*10000h]
  1362.         mov     esi, ecx
  1363.         mov     ecx, ebp
  1364.         sub     ecx, [disasm_start_pos]
  1365.         add     ecx, disasm_buffer
  1366.  
  1367.     .drawhex:
  1368.         ;mov    al, 47
  1369.         ;mov    ebx, 20101h
  1370.         ; draw a number in the window, color in esi
  1371.         mcall   47, 20101h
  1372.         add     edx, 6*3*10000h
  1373.         inc     ecx
  1374.         inc     ebp
  1375.         cmp     ebp, [disasm_cur_pos]
  1376.         jae     .hexdone
  1377.         dec     edi
  1378.         jnz     .drawhex
  1379.         push    esi
  1380.         mov     esi, [disasm_cur_pos]
  1381.         dec     esi
  1382.         cmp     esi, ebp
  1383.         pop     esi
  1384.         jbe     .drawhex
  1385.         ;mov    al, 4
  1386.         lea     ebx, [edx-6*10000h]
  1387.         ; copy color value from esi
  1388.         mov     ecx, esi
  1389.         push    3
  1390.         pop     esi
  1391.         mov     edx, aDots
  1392.         ; draw a text string in the window, color in ecx
  1393.         mcall   4
  1394.         ; copy color value from ecx
  1395.         mov     esi, ecx
  1396.  
  1397.     .hexdone:
  1398.         xor     eax, eax
  1399.         mov     edi, disasm_string
  1400.         mov     edx, edi
  1401.         or      ecx, -1
  1402.         repnz scasb
  1403.         not     ecx
  1404.         dec     ecx
  1405.         xchg    ecx, esi
  1406.         mov     ebx, [disasm_cur_str]
  1407.         imul    ebx, 10
  1408.         add     ebx, (data_x_pos+6*40)*10000h+disasm_y_pos
  1409.         ;mov    al, 4
  1410.         ; draw a text string in the window, color in ecx
  1411.         mcall   4
  1412.         inc     [disasm_cur_str]
  1413.         cmp     [disasm_cur_str], disasm_height
  1414.         jb      .loop
  1415.  
  1416.     .loopend:
  1417.         mov     ecx, disasm_height
  1418.         sub     ecx, [disasm_cur_str]
  1419.         jz      @f
  1420.         imul    ecx, 10
  1421.         inc     ecx
  1422.         mov     eax, disasm_y_pos + disasm_y_size
  1423.         sub     eax, ecx
  1424.         shl     eax, 16
  1425.         add     ecx, eax
  1426.         ;push   13
  1427.         ;pop    eax
  1428.         ;mov    ebx, data_x_pos*65536 + data_x_size
  1429.         ; set backroung color for disassembly container
  1430.         ; was 0xFFFFFF - white
  1431.         mov     edx, COLOR_BG_NORMAL
  1432.         ; draw container rectangle/box with color COLOR_BG_NORMAL (in edx)
  1433.         mcall   13, data_x_pos*65536+data_x_size
  1434.  
  1435.     @@:
  1436.         ret
  1437.  
  1438. ;-----------------------------------------------------------------------------
  1439.  
  1440. ; TODO: cleanup of this function, make some global labels local
  1441. update_disasm_eip:
  1442. ; test if instruction at eip is showed
  1443.         mov     ecx, disasm_height
  1444.         mov     eax, [disasm_start_pos]
  1445.         mov     [disasm_cur_pos], eax
  1446.  
  1447.     .l:
  1448.         mov     eax, [disasm_cur_pos]
  1449.         call    find_symbol
  1450.         jc      @f
  1451.         dec     ecx
  1452.         jz      .m
  1453.  
  1454.     @@:
  1455.         cmp     [_eip], eax
  1456.         jz      draw_disasm.redraw
  1457.         push    ecx
  1458.         call    disasm_instr
  1459.         pop     ecx
  1460.         jc      .m
  1461.         loop    .l
  1462.  
  1463.     .m:
  1464.  
  1465. update_disasm_eip_force:
  1466.         mov     eax, [_eip]
  1467.         mov     [disasm_start_pos], eax
  1468.  
  1469. update_disasm:
  1470.         cmp     [debuggee_pid], 0
  1471.         jz      .no
  1472.         ;push   69
  1473.         ;pop    eax
  1474.         ;push   6
  1475.         ;pop    ebx
  1476.         ;mov    ecx, [debuggee_pid]
  1477.         ;mov    edi, disasm_buffer
  1478.         ;mov    edx, 256
  1479.         ;mov    esi, [disasm_start_pos]
  1480.         mcall   69, 6, [debuggee_pid], 256, [disasm_start_pos], disasm_buffer
  1481.         cmp     eax, -1
  1482.         jnz     @f
  1483.         mov     esi, read_mem_err
  1484.         call    put_message
  1485.  
  1486.     .no:
  1487.         xor     eax, eax
  1488.  
  1489.     @@:
  1490.         mov     [disasm_buf_size], eax
  1491.         call    restore_from_breaks
  1492.         jmp     draw_disasm.redraw
  1493.  
  1494.  
  1495. ;-----------------------------------------------------------------------------
  1496. ;                               Draw main window
  1497.  
  1498. draw_window:
  1499.     ; start window redraw
  1500.         ;push   12
  1501.         ;pop    eax
  1502.         ;push   1
  1503.         ;pop    ebx
  1504.         mcall   12, 1
  1505.  
  1506.     ; define window
  1507.         ;xor    eax, eax
  1508.         ;mov    ebx, wnd_x_size
  1509.         ;mov    ecx, wnd_y_size
  1510.         ;mov    edx, 54FFFFFFh
  1511.         mov     edi, caption_str
  1512.         ; draw window with color in edx
  1513.         ; was 0x54FFFFFF - white background
  1514.         mcall   0, wnd_x_size, wnd_y_size, (COLOR_BG_NORMAL or 0x54000000)
  1515.  
  1516.     ; clear unused areas
  1517.         ;mov    al, 48
  1518.         ;push   4
  1519.         ;pop    ebx
  1520.         ; get window skin height
  1521.         mcall   48, 4
  1522.         cmp     eax, title_y_pos
  1523.         jb      @f
  1524.         push    registers_y_pos
  1525.         pop     eax
  1526.  
  1527.     @@:
  1528.         push    registers_y_pos
  1529.         pop     ecx
  1530.         push    eax
  1531.         sub     ecx, eax
  1532.         shl     eax, 16
  1533.         add     ecx, eax
  1534.         mov     ebx, 5*10000h + (wnd_x_size-9)
  1535.         ;push   13
  1536.         ;pop    eax
  1537.         ; color in edx for all rectangles (COLOR_BG_NORMAL)
  1538.         ; draw container rectangle/box for registers information region
  1539.         mcall   13
  1540.         mov     ecx, (dump_y_pos+dump_y_size)*10000h + (disasm_y_pos-dump_y_pos-dump_y_size)
  1541.         ; draw container rectangle/box for dump memory region
  1542.         mcall
  1543.         mov     ecx, (disasm_y_pos-1+disasm_y_size)*10000h + (messages_y_pos-disasm_y_pos+1-disasm_y_size)
  1544.         ; draw container rectangle/box for disassembled code region
  1545.         mcall
  1546.         mov     ecx, (messages_y_pos+messages_y_size)*10000h + (wnd_y_size-messages_y_pos-messages_y_size-4)
  1547.         ; draw container rectangle/box for messages window region
  1548.         mcall
  1549.         mov     ebx, 5*10000h + (data_x_pos-5)
  1550.         pop     ecx
  1551.         imul    ecx, 10001h
  1552.         sub     cx, wnd_y_size-4
  1553.         neg     cx
  1554.         ; draw container rectangle/box
  1555.         mcall
  1556.         mov     ebx, (data_x_pos+data_x_size)*10000h + (wnd_x_size-data_x_pos-data_x_size-4)
  1557.         ; draw container rectangle/box
  1558.         mcall
  1559.  
  1560.     ; messages frame
  1561.         ;mov    al, 38
  1562.         mov     ebx, (messages_x_pos-2)*10000h + (messages_x_pos+messages_x_size+2)
  1563.         push    ebx
  1564.         mov     ecx, (messages_y_pos-2)*10001h
  1565.         ; setting up lines color
  1566.         ; was 'xor     edx, edx' - black
  1567.         mov     edx, COLOR_LINE
  1568.         ; draw line, color in edx
  1569.         mcall   38
  1570.         mov     ecx, (messages_y_pos+messages_y_size+2)*10001h
  1571.         ; draw line, color in edx
  1572.         mcall
  1573.         mov     ebx, (messages_x_pos-2)*10001h
  1574.         push    ebx
  1575.         mov     ecx, (messages_y_pos-2)*10000h + (messages_y_pos+messages_y_size+2)
  1576.         ; draw line, color in edx
  1577.         mcall
  1578.         mov     ebx, (messages_x_pos+messages_x_size+2)*10001h
  1579.         push    ebx
  1580.         ; draw line, color in edx
  1581.         mcall
  1582.  
  1583.     ; command line frame
  1584.         mov     ecx, (cmdline_y_pos-2)*10000h + (cmdline_y_pos+cmdline_y_size+2)
  1585.         pop     ebx
  1586.         ; draw line, color in edx
  1587.         mcall
  1588.         pop     ebx
  1589.         ; draw line, color in edx
  1590.         mcall
  1591.         pop     ebx
  1592.         mov     ecx, (cmdline_y_pos+cmdline_y_size+2)*10001h
  1593.         ; draw line, color in edx
  1594.         mcall
  1595.         mov     ecx, (cmdline_y_pos-2)*10001h
  1596.         ; draw line, color in edx
  1597.         mcall
  1598.  
  1599.     ; registers frame
  1600.         ;push   13
  1601.         ;pop    eax
  1602.         mov     ebx, (registers_x_pos-2)*10000h + (registers_x_size+4)
  1603.         mov     ecx, (registers_y_pos-2)*10000h + (registers_y_size+4)
  1604.         ; draw container rectangle/box for registers information window region
  1605.         ; color in edx
  1606.         mcall   13
  1607.  
  1608.     ; messages
  1609.         call    draw_messages
  1610.  
  1611.     ; command line & cursor
  1612.         call    draw_cmdline
  1613.         call    draw_cursor
  1614.  
  1615.     ; title & registers & dump & disasm
  1616.         ;mov    al, 38
  1617.         mov     ebx, (data_x_pos-2)*10001h
  1618.         mov     ecx, (title_y_pos+5)*10000h + (messages_y_pos-2)
  1619.         ; draw line, color in edx
  1620.         mcall   38
  1621.         mov     ebx, (data_x_pos+data_x_size+2)*10001h
  1622.         ; draw line, color in edx
  1623.         mcall
  1624.         mov     ebx, (data_x_pos-2)*10000h + (data_x_pos+data_x_size+2)
  1625.         mov     ecx, (dump_y_pos-3)*10001h
  1626.         ; draw line, color in edx
  1627.         mcall
  1628.         mov     ecx, (disasm_y_pos-4)*10001h
  1629.         ; draw line, color in edx
  1630.         mcall
  1631.  
  1632.     ; redraw whole window again
  1633.         call    redraw_title
  1634.         call    draw_registers
  1635.         call    draw_dump
  1636.         call    draw_disasm.redraw
  1637.  
  1638.     ; end of window redraw
  1639.         ;push   12
  1640.         ;pop    eax
  1641.         ;push   2
  1642.         ;pop    ebx
  1643.         mcall   12, 2
  1644.         ret
  1645.  
  1646. ; vim: ft=fasm tabstop=4
  1647.  
  1648.