Subversion Repositories Kolibri OS

Rev

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