Subversion Repositories Kolibri OS

Rev

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