Subversion Repositories Kolibri OS

Rev

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

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