Subversion Repositories Kolibri OS

Rev

Rev 4886 | Rev 4889 | 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
1014
        xor     ecx, ecx
1015
 
1016
    @@:
1017
        mov     edx, aColon
1018
        xor     esi, esi
1019
        inc     esi
1020
        mov     ecx, COLOR_TXT_INACTIVE
1021
        ;mov    ebx, (registers_x_pos+10)*10000h + registers_y_pos+122
1022
        ; draw a text string in the window, color in ecx
1023
        mcall   4, (registers_x_pos+10)*10000h+registers_y_pos+122
1024
        mov     edx, flags
1025
 
1026
    @@:
1027
        add     ebx, 2*6*10000h
1028
        call    draw_flag
1029
        inc     edx
1030
        cmp     dl, flags_bits and 0xFF
1031
        jnz     @b
1032
        ret
1033
 
1034
;-----------------------------------------------------------------------------
1035
;                  Draw SSE registers set
1036
 
1037
draw_sse_registers:
4888 hidnplayr 1038
 
4591 hidnplayr 1039
        ret
1040
 
1041
;-----------------------------------------------------------------------------
1042
;                  Draw AVX registers set
1043
 
1044
draw_avx_registers:
4888 hidnplayr 1045
 
4591 hidnplayr 1046
        ret
1047
 
1048
;-----------------------------------------------------------------------------
1049
;                 Draw all registers sets
1050
draw_registers:
4888 hidnplayr 1051
 
1052
        ; draw container rectangle/box with COLOR_BG_NORMAL
1053
        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 1054
        call    draw_reg_title
4888 hidnplayr 1055
 
1056
    .redraw:
4591 hidnplayr 1057
        cmp     [reg_mode], REG_MODE_CPU
1058
        jnz     @f
1059
        call    draw_main_registers
1060
        ret
1061
 
1062
    @@:
1063
        cmp     [reg_mode], REG_MODE_SSE
1064
        jnz     @f
1065
        call    draw_sse_registers
1066
        ret
1067
 
1068
    @@:
1069
        call    draw_avx_registers
1070
        ret
1071
 
1072
;-----------------------------------------------------------------------------
1073
;                     Display memory dump
1074
 
1075
draw_dump:
1076
        ; draw container rectangle/box in the window
1077
        mcall   13, data_x_pos*10000h+data_x_size, dump_y_pos*10000h+dump_y_size, COLOR_BG_NORMAL
1078
 
1079
    .redraw:
4888 hidnplayr 1080
        ; addresses
4591 hidnplayr 1081
        mov     ebx, 80100h
1082
        mov     edx, data_x_pos*10000h + dump_y_pos
1083
        mov     ecx, [dumppos]
1084
        mov     edi, COLOR_BG_NORMAL
1085
        mov     esi, (COLOR_TXT_INACTIVE or 0x40000000)
1086
        cmp     [debuggee_pid], 0
1087
        jz      @f
1088
        cmp     [bSuspended], 0
1089
        jz      @f
1090
        mov     esi, (COLOR_TXT_NORMAL or 0x40000000)
1091
    @@:
4888 hidnplayr 1092
        ; draw a number in the window
4591 hidnplayr 1093
        mcall   47
1094
        add     ecx, 10h
1095
        add     edx, 10
1096
        cmp     dl, dump_y_pos + dump_y_size
1097
        jb      @b
4888 hidnplayr 1098
        ; hex dump of data
4591 hidnplayr 1099
        mov     ecx, dumpdata
1100
        push    ecx
1101
        xor     ebx, ebx
1102
        mov     edx, (data_x_pos+12*6)*10000h + dump_y_pos
1103
        cmp     [dumpread], ebx
1104
        jz      .hexdumpdone1
1105
 
1106
    .hexdumploop1:
1107
        push    ebx
1108
        mov     ebx, 20101h
4888 hidnplayr 1109
        ; draw a number in the window
4591 hidnplayr 1110
        mcall
1111
        pop     ebx
1112
        add     edx, 3*6*10000h
1113
        inc     ecx
1114
        inc     ebx
1115
        test    bl, 15
1116
        jz      .16
1117
        test    bl, 7
1118
        jnz     @f
1119
        add     edx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h
1120
 
1121
    .16:
1122
        add     edx, 10 - 6*(3*10h+2)*10000h
1123
 
1124
    @@:
1125
        cmp     ebx, [dumpread]
1126
        jb      .hexdumploop1
1127
 
1128
    .hexdumpdone1:
1129
        mov     al, 4
1130
        ; copy color value from esi to ecx
1131
        ; to draw text string with 'mcall 4'
1132
        mov     ecx, esi
1133
        xchg    ebx, edx
1134
        push    2
1135
        pop     esi
1136
 
1137
    .hexdumploop2:
1138
        cmp     edx, dump_height*10h
1139
        jae     .hexdumpdone2
1140
        push    edx
1141
        mov     edx, aQuests
1142
        ; draw text string with color in ecx, copied from esi
1143
        mcall
1144
        pop     edx
1145
        add     ebx, 3*6*10000h
1146
        inc     edx
1147
        test    dl, 15
1148
        jz      .16x
1149
        test    dl, 7
1150
        jnz     .hexdumploop2
1151
        add     ebx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h
1152
 
1153
    .16x:
1154
        add     ebx, 10 - 6*(3*10h+2)*10000h
1155
        jmp     .hexdumploop2
1156
 
1157
    .hexdumpdone2:
1158
        dec     esi
1159
    ; colon, minus signs
1160
        mov     ebx, (data_x_pos+8*6)*10000h + dump_y_pos
1161
        mov     edx, aColon
1162
 
1163
    @@:
1164
        mcall
1165
        add     ebx, 10
1166
        cmp     bl, dump_y_pos+dump_height*10
1167
        jb      @b
1168
        mov     ebx, (data_x_pos+(12+3*8)*6)*10000h + dump_y_pos
1169
        mov     edx, aMinus
1170
 
1171
    @@:
1172
        mcall
1173
        add     ebx, 10
1174
        cmp     bl, dump_y_pos+dump_height*10
1175
        jb      @b
1176
    ; ASCII data
1177
        mov     ebx, (data_x_pos+(12+3*10h+2+2)*6)*10000h + dump_y_pos
1178
        pop     edx
1179
        push    dump_height*10h
1180
 
1181
    .asciiloop:
1182
        push    edx
1183
        cmp     byte [edx], 20h
1184
        jae     @f
1185
        mov     edx, aPoint
1186
 
1187
    @@:
1188
        ; draw a text string in the window, color in ecx
1189
        mcall
1190
        pop     edx
1191
        inc     edx
1192
        add     ebx, 6*10000h
1193
        dec     dword [esp]
1194
        jz      .asciidone
1195
        test    byte [esp], 15
1196
        jnz     .asciiloop
1197
        add     ebx, 10 - 6*10h*10000h
1198
        jmp     .asciiloop
1199
 
1200
    .asciidone:
1201
        pop     ecx
1202
        ret
1203
 
1204
;-----------------------------------------------------------------------------
1205
;                   Display disassembled code
1206
 
1207
; @@@@@ WAS:
1208
; redraw_disasm:
1209
;       push    13
1210
;       pop     eax
1211
;       mov     edx, 0xFFFFFF
1212
;       mov     ebx, data_x_pos*10000h + data_x_size
1213
;       mov     ecx, (disasm_y_pos-1)*10000h + (disasm_y_size+1)
1214
;       mcall
1215
;
1216
; @@@@@ NOW:
1217
draw_disasm:
1218
 
1219
    .redraw:
1220
        mov     eax, [disasm_start_pos]
1221
        mov     [disasm_cur_pos], eax
1222
        and     [disasm_cur_str], 0
1223
 
1224
    .loop:
1225
        mov     eax, [disasm_cur_pos]
1226
        call    find_symbol
1227
        jc      .nosymb
1228
        mov     ebx, [disasm_cur_str]
1229
        imul    ebx, 10
1230
        push    ebx
1231
        lea     ecx, [ebx+disasm_y_pos-1]
1232
        shl     ecx, 16
1233
        mov     cl, 11
1234
        ; setting up background color for disassembled text
1235
        mov     edx, COLOR_BG_NORMAL
1236
        ;mov    ebx, data_x_pos*10000h + data_x_size
1237
        ;push   13
1238
        ;pop    eax
1239
        ; draw container rectangle/box with color COLOR_BG_NORMAL (was 0xFFFFFF - white)
1240
        mcall   13, data_x_pos*10000h+data_x_size
1241
        pop     ebx
1242
        ; copy color value from edx (COLOR_BG_NORMAL)
1243
        mov     edi, edx
1244
        add     ebx, (data_x_pos+6*2)*10000h+disasm_y_pos
1245
        mov     edx, esi
1246
 
1247
    @@:
1248
        lodsb
1249
        test    al, al
1250
        jnz     @b
1251
        mov     byte [esi-1], ':'
1252
        sub     esi, edx
1253
        ; normal color
1254
        ; was 0x40000000
4886 hidnplayr 1255
        mov     ecx, (COLOR_TXT_LABEL or 0x40000000)
4591 hidnplayr 1256
        mov     al, 4
1257
        ; draw a text string in the window with color COLOR_TXT_NORMAL in ecx
1258
        mcall
1259
        mov     byte [esi+edx-1], 0
1260
        lea     esi, [esi*3]
1261
        movzx   ecx, bx
1262
        shr     ebx, 16
1263
        lea     ebx, [ebx+esi*2]
1264
        shl     ecx, 16
1265
        mov     cl, 10
1266
        imul    ebx, 10001h
1267
        sub     bx, data_x_pos+data_x_size
1268
        neg     bx
1269
        mov     al, 13
1270
        ; copy color value from edi
1271
        mov     edx, edi
1272
        ; draw container rectangle/box for disassembled text, color in edx
1273
        mcall
1274
        inc     [disasm_cur_str]
1275
        cmp     [disasm_cur_str], disasm_height
1276
        jae     .loopend
1277
 
1278
    .nosymb:
1279
        push    [disasm_cur_pos]
1280
        call    disasm_instr
1281
        pop     ebp
1282
        jc      .loopend
4886 hidnplayr 1283
        mov     edx, COLOR_BG_NORMAL
4591 hidnplayr 1284
        mov     esi, COLOR_TXT_NORMAL
1285
        mov     ebx, data_x_pos*10000h + data_x_size
1286
        mov     ecx, [disasm_cur_str]
1287
        imul    ecx, 10*10000h
1288
        add     ecx, (disasm_y_pos-1)*10000h + 10
1289
        mov     eax, ebp
1290
        pushad
1291
        call    find_enabled_breakpoint
1292
        popad
4886 hidnplayr 1293
        jnz     .nobp
4591 hidnplayr 1294
        mov     edx, COLOR_BG_BREAKPOINT
4886 hidnplayr 1295
        mov     esi, COLOR_TXT_BREAKPOINT
1296
    .nobp:
4591 hidnplayr 1297
 
1298
        mov     eax, [_eip]
1299
        cmp     eax, ebp
4886 hidnplayr 1300
        jnz     .notcurrent
4591 hidnplayr 1301
        mov     edx, COLOR_BG_SELECTED
1302
        mov     esi, COLOR_TXT_SELECTED
4886 hidnplayr 1303
    .notcurrent:
1304
        push    esi     ; Save color value for disassembled text
4591 hidnplayr 1305
 
1306
        ; draw container rectangle/box for disassembled text
1307
        ; color in edx
1308
        mcall   13
1309
        ;mov    al, 47
1310
        ;mov    ebx, 80100h
1311
        mov     edx, [disasm_cur_str]
1312
        imul    edx, 10
1313
        add     edx, data_x_pos*10000h + disasm_y_pos
1314
        ;mov    ecx, ebp
1315
        ; draw a number in the window, color in esi
1316
        mcall   47, 80100h, ebp
1317
        ;mov    al, 4
1318
        lea     ebx, [edx+8*6*10000h]
4886 hidnplayr 1319
        mov     ecx, esi    ; text color
4591 hidnplayr 1320
        push    2
1321
        pop     esi
1322
        mov     edx, aColon
4886 hidnplayr 1323
        ; draw the colon
4591 hidnplayr 1324
        mcall   4
1325
        push    9
1326
        pop     edi
1327
        lea     edx, [ebx+2*6*10000h]
1328
        mov     ecx, ebp
1329
        sub     ecx, [disasm_start_pos]
1330
        add     ecx, disasm_buffer
1331
 
4888 hidnplayr 1332
        mov     esi, COLOR_TXT_HEX
4886 hidnplayr 1333
        mov     eax, [_eip]
1334
        cmp     eax, ebp
1335
        jnz     @f
1336
        mov     esi, COLOR_TXT_SELECTED
1337
  @@:
4591 hidnplayr 1338
    .drawhex:
1339
        ; draw a number in the window, color in esi
1340
        mcall   47, 20101h
1341
        add     edx, 6*3*10000h
1342
        inc     ecx
1343
        inc     ebp
1344
        cmp     ebp, [disasm_cur_pos]
1345
        jae     .hexdone
1346
        dec     edi
1347
        jnz     .drawhex
1348
        push    esi
1349
        mov     esi, [disasm_cur_pos]
1350
        dec     esi
1351
        cmp     esi, ebp
1352
        pop     esi
1353
        jbe     .drawhex
1354
        ;mov    al, 4
1355
        lea     ebx, [edx-6*10000h]
1356
        ; copy color value from esi
1357
        mov     ecx, esi
1358
        push    3
1359
        pop     esi
1360
        mov     edx, aDots
1361
        ; draw a text string in the window, color in ecx
1362
        mcall   4
1363
 
1364
    .hexdone:
4886 hidnplayr 1365
        pop     esi
4591 hidnplayr 1366
        xor     eax, eax
1367
        mov     edi, disasm_string
1368
        mov     edx, edi
1369
        or      ecx, -1
1370
        repnz scasb
1371
        not     ecx
1372
        dec     ecx
1373
        xchg    ecx, esi
1374
        mov     ebx, [disasm_cur_str]
1375
        imul    ebx, 10
1376
        add     ebx, (data_x_pos+6*40)*10000h+disasm_y_pos
1377
        ;mov    al, 4
1378
        ; draw a text string in the window, color in ecx
1379
        mcall   4
1380
        inc     [disasm_cur_str]
1381
        cmp     [disasm_cur_str], disasm_height
1382
        jb      .loop
1383
 
1384
    .loopend:
1385
        mov     ecx, disasm_height
1386
        sub     ecx, [disasm_cur_str]
1387
        jz      @f
1388
        imul    ecx, 10
1389
        inc     ecx
1390
        mov     eax, disasm_y_pos + disasm_y_size
1391
        sub     eax, ecx
1392
        shl     eax, 16
1393
        add     ecx, eax
1394
        ;push   13
1395
        ;pop    eax
1396
        ;mov    ebx, data_x_pos*65536 + data_x_size
1397
        ; set backroung color for disassembly container
1398
        ; was 0xFFFFFF - white
1399
        mov     edx, COLOR_BG_NORMAL
1400
        ; draw container rectangle/box with color COLOR_BG_NORMAL (in edx)
1401
        mcall   13, data_x_pos*65536+data_x_size
1402
 
1403
    @@:
1404
        ret
1405
 
1406
;-----------------------------------------------------------------------------
1407
 
1408
; TODO: cleanup of this function, make some global labels local
1409
update_disasm_eip:
1410
; test if instruction at eip is showed
1411
        mov     ecx, disasm_height
1412
        mov     eax, [disasm_start_pos]
1413
        mov     [disasm_cur_pos], eax
1414
 
1415
    .l:
1416
        mov     eax, [disasm_cur_pos]
1417
        call    find_symbol
1418
        jc      @f
1419
        dec     ecx
1420
        jz      .m
1421
 
1422
    @@:
1423
        cmp     [_eip], eax
1424
        jz      draw_disasm.redraw
1425
        push    ecx
1426
        call    disasm_instr
1427
        pop     ecx
1428
        jc      .m
1429
        loop    .l
1430
 
1431
    .m:
1432
 
1433
update_disasm_eip_force:
1434
        mov     eax, [_eip]
1435
        mov     [disasm_start_pos], eax
1436
 
1437
update_disasm:
1438
        cmp     [debuggee_pid], 0
1439
        jz      .no
1440
        ;push   69
1441
        ;pop    eax
1442
        ;push   6
1443
        ;pop    ebx
1444
        ;mov    ecx, [debuggee_pid]
1445
        ;mov    edi, disasm_buffer
1446
        ;mov    edx, 256
1447
        ;mov    esi, [disasm_start_pos]
1448
        mcall   69, 6, [debuggee_pid], 256, [disasm_start_pos], disasm_buffer
1449
        cmp     eax, -1
1450
        jnz     @f
1451
        mov     esi, read_mem_err
1452
        call    put_message
1453
 
1454
    .no:
1455
        xor     eax, eax
1456
 
1457
    @@:
1458
        mov     [disasm_buf_size], eax
1459
        call    restore_from_breaks
1460
        jmp     draw_disasm.redraw
1461
 
1462
 
1463
;-----------------------------------------------------------------------------
1464
;                               Draw main window
1465
 
1466
draw_window:
1467
    ; start window redraw
1468
        mcall   12, 1
1469
 
1470
    ; define window
4594 hidnplayr 1471
        mcall   0, wnd_x_size, wnd_y_size, (COLOR_BG_NORMAL or 0x54000000), , caption_str
4591 hidnplayr 1472
 
1473
    ; clear unused areas
1474
        ; get window skin height
1475
        mcall   48, 4
1476
        cmp     eax, title_y_pos
1477
        jb      @f
1478
        push    registers_y_pos
1479
        pop     eax
1480
 
1481
    @@:
1482
        push    registers_y_pos
1483
        pop     ecx
1484
        push    eax
1485
        sub     ecx, eax
1486
        shl     eax, 16
1487
        add     ecx, eax
1488
        mov     ebx, 5*10000h + (wnd_x_size-9)
1489
        mov     edx, COLOR_BG_NORMAL
1490
        ; draw container rectangle/box for registers information region
1491
        mcall   13
1492
        mov     ecx, (dump_y_pos+dump_y_size)*10000h + (disasm_y_pos-dump_y_pos-dump_y_size)
1493
        ; draw container rectangle/box for dump memory region
1494
        mcall
1495
        mov     ecx, (disasm_y_pos-1+disasm_y_size)*10000h + (messages_y_pos-disasm_y_pos+1-disasm_y_size)
1496
        ; draw container rectangle/box for disassembled code region
1497
        mcall
1498
        mov     ecx, (messages_y_pos+messages_y_size)*10000h + (wnd_y_size-messages_y_pos-messages_y_size-4)
1499
        ; draw container rectangle/box for messages window region
1500
        mcall
1501
        mov     ebx, 5*10000h + (data_x_pos-5)
1502
        pop     ecx
1503
        imul    ecx, 10001h
1504
        sub     cx, wnd_y_size-4
1505
        neg     cx
1506
        ; draw container rectangle/box
1507
        mcall
1508
        mov     ebx, (data_x_pos+data_x_size)*10000h + (wnd_x_size-data_x_pos-data_x_size-4)
1509
        ; draw container rectangle/box
1510
        mcall
1511
        mov     ebx, 5*10000h + title_x_pos - 5
1512
        mov     ecx, (title_y_pos)*10000h + (title_y_size)
1513
        ; draw container rectangle/box for dump memory region title
1514
        mcall
1515
 
1516
    ; messages frame
1517
        mov     ebx, (messages_x_pos-2)*10000h + (messages_x_pos+messages_x_size+2)
1518
        push    ebx
1519
        mov     ecx, (messages_y_pos-2)*10001h
1520
        mov     edx, COLOR_LINE
1521
        mcall   38
1522
        mov     ecx, (messages_y_pos+messages_y_size+2)*10001h
1523
        mcall
1524
        mov     ebx, (messages_x_pos-2)*10001h
1525
        push    ebx
1526
        mov     ecx, (messages_y_pos-2)*10000h + (messages_y_pos+messages_y_size+2)
1527
        mcall
1528
        mov     ebx, (messages_x_pos+messages_x_size+2)*10001h
1529
        push    ebx
1530
        mcall
1531
 
1532
    ; command line frame
1533
        mov     ecx, (cmdline_y_pos-2)*10000h + (cmdline_y_pos+cmdline_y_size+2)
1534
        pop     ebx
1535
        mcall
1536
        pop     ebx
1537
        mcall
1538
        pop     ebx
1539
        mov     ecx, (cmdline_y_pos+cmdline_y_size+2)*10001h
1540
        mcall
1541
        mov     ecx, (cmdline_y_pos-2)*10001h
1542
        mcall
1543
 
1544
    ; registers frame
4888 hidnplayr 1545
        DrawRectangle (registers_x_pos-2), (registers_y_pos-2), (registers_x_size+3), (registers_y_size+3), COLOR_LINE
1546
    ; draw container rectangle/box for registers information window region
4591 hidnplayr 1547
 
1548
    ; messages
1549
        call    draw_messages
1550
 
1551
    ; command line & cursor
1552
        call    draw_cmdline
1553
        call    draw_cursor
1554
 
1555
    ; title & registers & dump & disasm
1556
        mov     ebx, (data_x_pos-2)*10001h
1557
        mov     ecx, (title_y_pos+5)*10000h + (messages_y_pos-2)
1558
        mov     edx, COLOR_LINE
1559
        mcall   38
1560
        mov     ebx, (data_x_pos+data_x_size+2)*10001h
1561
        mcall
1562
        mov     ebx, (data_x_pos-2)*10000h + (data_x_pos+data_x_size+2)
1563
        mov     ecx, (disasm_y_pos-4)*10001h
1564
        mcall
1565
 
1566
    ; redraw whole window again
1567
        call    redraw_title
1568
        call    draw_registers
1569
        call    draw_dump
1570
        call    draw_disasm.redraw
1571
 
1572
    ; end of window redraw
1573
        mcall   12, 2
1574
        ret
1575
 
1576
; vim: ft=fasm tabstop=4
1577