Subversion Repositories Kolibri OS

Rev

Rev 4594 | Rev 4739 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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