Subversion Repositories Kolibri OS

Rev

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

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