Subversion Repositories Kolibri OS

Rev

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

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