Subversion Repositories Kolibri OS

Rev

Rev 4739 | Rev 4888 | 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
4886 hidnplayr 32
        COLOR_TXT_ADDR            = 0xec9300
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
4886 hidnplayr 46
        COLOR_TXT_ADDR            = COLOR_TXT_NORMAL
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
4886 hidnplayr 60
        COLOR_TXT_ADDR            = COLOR_TXT_NORMAL
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
        ;push   38
559
        ;pop    eax
560
        mov     ecx, cmdline_y_pos*10001h+cmdline_y_size-1
561
        mov     ebx, [cmdline_pos]
562
        imul    ebx, 6
563
        add     ebx, cmdline_x_pos
564
        mov     edx, ebx
565
        shl     ebx, 16
566
        or      ebx, edx
567
        ; setting line color
568
        ; was 'xor     edx, edx' - black
569
        mov     edx, COLOR_LINE
570
        ; draw line, color in edx
571
        mcall   38
572
        ret
573
 
574
hide_cursor:
575
        mov     ebx, [cmdline_pos]
576
        ;push   13
577
        ;pop    eax
578
        imul    ebx, 6
579
        add     ebx, cmdline_x_pos
580
        shl     ebx, 16
581
        inc     ebx
582
        mov     ecx, cmdline_y_pos*10000h + cmdline_y_size
583
        ; setting up rectangle color
584
        ; was 0xFFFFFF
585
        mov     edx, COLOR_BG_NORMAL
586
        ; draw container rectangle/box
587
        mcall   13
588
        mov     ebx, [cmdline_pos]
589
        cmp     ebx, [cmdline_len]
590
        jae     .ret
591
        ;mov    al, 4
592
        ; setting up text color scheme and attributes
593
        ;was 'xor     ecx, ecx'
594
        mov     ecx, COLOR_TXT_NORMAL
595
        lea     edx, [cmdline+ebx]
596
        imul    ebx, 6
597
        add     ebx, cmdline_x_pos
598
        shl     ebx, 16
599
        or      ebx, cmdline_y_pos+1
600
        push    1
601
        pop     esi
602
        ; draw text string in the window
603
        mcall   4
604
 
605
    .ret:
606
        ret
607
 
608
;-----------------------------------------------------------------------------
609
;                       Draw program window title
610
 
611
; FIXME: something wrong here
612
redraw_title:
613
        ;push   13
614
        ;pop    eax
615
        ;mov    edx, 0xFFFFFF
616
        ;mov    ebx, title_x_pos*10000h + data_x_pos+data_x_size-title_x_pos
617
        ;mov    ecx, title_y_pos*10000h + title_y_size
618
        ; draw container rectangle/box
619
        ; color was 0xFFFFFF
620
        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
621
 
622
draw_title:
623
        ;mov    al, 38
624
        ;mov    ebx, (data_x_pos-2)*10000h + title_x_pos-5
625
        ;mov    ecx, (title_y_pos+5)*10001h
626
        ; draw line with COLOR_LINE (in edx)
627
        mcall   38, (data_x_pos-2)*10000h+title_x_pos-5, (title_y_pos+5)*10001h, COLOR_LINE
628
        push    NoPrgLoaded_len
629
        pop     esi
630
        cmp     [debuggee_pid], 0
631
        jz      @f
632
        mov     esi, [prgname_len]
633
 
634
    @@:
635
        imul    ebx, esi, 6
636
        add     ebx, title_x_pos+4
637
        shl     ebx, 16
638
        mov     bx, data_x_pos+data_x_size-10-5-6*7
639
        cmp     [bSuspended], 0
640
        jz      @f
641
        add     ebx, 6
642
 
643
    @@:
644
        ; draw line with COLOR_LINE (in edx)
645
        mcall
646
        mov     ebx, (data_x_pos+data_x_size-10+4)*0x10000 + data_x_pos+data_x_size+2
647
        ; draw line with COLOR_LINE (in edx)
648
        mcall
649
        mov     al, 4
650
        mov     ebx, title_x_pos*10000h+title_y_pos
651
        ; setting up text color scheme and attributes
652
        mov     ecx, COLOR_TXT_NORMAL
653
        mov     edx, NoPrgLoaded_str
654
        cmp     [debuggee_pid], 0
655
        jz      @f
656
        mov     edx, [prgname_ptr]
657
 
658
    @@:
659
        ; draw text string in the window
660
        mcall
661
        cmp     [debuggee_pid], 0
662
        jz      .nodebuggee
663
        mov     ebx, (data_x_pos+data_x_size-10-6*7)*10000h + title_y_pos
664
        mov     edx, aRunning
665
        push    7
666
        pop     esi
667
        cmp     [bSuspended], 0
668
        jz      @f
669
        add     ebx, 6*10000h
670
        mov     edx, aPaused
671
        dec     esi
672
 
673
    @@:
674
        ; draw line with COLOR_LINE (in edx) in one case
675
        ; and draw text string with color COLOR_TXT_NORMAL (in ecx) in another
676
        mcall
677
        ret
678
 
679
    .nodebuggee:
680
        mov     al, 38
681
        mov     ebx, (data_x_pos+data_x_size-10-6*7-5)*0x10000 + data_x_pos+data_x_size+2
682
        mov     ecx, (title_y_pos+5)*10001h
683
        mov     edx, COLOR_LINE
684
        jmp     @b
685
 
686
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
687
;;;;;;;;;;;;;;;;;;; REGISTERS PANEL ;;;;;;;;;;;;;;;;;;;;;;;;;;
688
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
689
 
690
;-----------------------------------------------------------------------------
691
;                      Display common register content
692
 
693
; TODO: add format support (e.g. numerical value, or address offset/pointer)
694
 
695
; in: esi->value, edx->string, ecx = string length, ebx = coord
696
draw_register:
697
        push    edx
698
        push    ecx
699
        push    esi
700
        mov     eax, esi
701
        mov     esi, ecx
702
    ; setting up registers colors
703
    ; can be usual, inactive and changed
704
        ; inactive color
705
        ; was 0x40808080 - grey
706
        mov     ecx, (COLOR_TXT_INACTIVE or 0x40000000)
707
        cmp     [debuggee_pid], 0
708
        jz      .cd
709
        cmp     [bSuspended], 0
710
        jz      .cd
711
        ; normal color
712
        ; was 0x40000000 - black
713
        mov     ecx, (COLOR_TXT_NORMAL or 0x40000000)
714
        push    edi
715
        mov     edi, [eax]
716
        cmp     dword [eax+oldcontext-context], edi
717
        pop     edi
718
        jz      .cd
719
        ; changed register color
720
        ; was 0x4000AA00 - green
721
        mov     ecx, (COLOR_TXT_CHANGED or 0x40000000)
722
 
723
    .cd:
724
        ;push   4
725
        ;pop    eax
726
        ; draw a text string in the window
727
        mcall   4
728
        imul    esi, 60000h
729
        lea     edx, [ebx+esi]
730
        ;mov    al, 47
731
        ;mov    ebx, 80101h
732
        mov     esi, ecx
733
        pop     ecx
734
        ; draw a number in the window
735
        ; color in the esi (same value as for usual text)
736
        mcall   47, 80101h
737
        lea     ebx, [edx+60000h*18]
738
        mov     esi, ecx
739
        pop     ecx
740
        pop     edx
741
        add     edx, ecx
742
        ret
743
 
744
;-----------------------------------------------------------------------------
745
;                  Display FPU register (ST0 - ST7) content
746
;
747
; in: esi->value, edx->string, ecx = string length, ebx = coord
748
draw_fpu_register:
749
        push    edx
750
        push    ecx
751
        push    esi
752
        mov     eax, esi
753
        mov     esi, ecx
754
    ; setting up registers color
755
    ; can be usual, inactive and changed
756
        ; inactive color
757
        ; was 0x40808080 - grey
758
        mov     ecx, (COLOR_TXT_INACTIVE or 0x40000000)
759
        cmp     [debuggee_pid], 0
760
        jz      .cd
761
        cmp     [bSuspended], 0
762
        jz      .cd
763
        ; normal color
764
        ; was 0x40000000 - black
765
        mov     ecx, (COLOR_TXT_NORMAL or 0x40000000)
766
        push    edi
767
        mov     edi, [eax]
768
        cmp     dword [eax+oldcontext-context], edi
769
        pop     edi
770
        jnz     .scol
771
        push    edi
772
        mov     edi, [eax+4]
773
        cmp     dword [eax+oldcontext-context+4], edi
774
        pop     edi
775
        jz      .cd
776
 
777
    .scol:
778
        ; changed register color
779
        ; was 0x4000AA00 - green
780
        mov     ecx, (COLOR_TXT_CHANGED or 0x40000000)
781
 
782
    .cd:
783
        ;push   4
784
        ;pop    eax
785
        ; draw a text string in the window
786
        mcall   4
787
        imul    esi, 60000h
788
        lea     edx, [ebx+esi]
789
        ;mov    al, 47
790
        ;mov    ebx, 40100101h ; [20] show 16 chars set [30] bit - qword
791
        mov     esi, ecx
792
        pop     ecx
793
        ; draw a number in the window
794
        ; color is the same as for previous text draw function
795
        ; ebx : [20] show 16 chars set [30] bit - qword
796
        mcall   47, 40100101h
797
        lea     ebx, [edx+60000h*18]
798
        mov     esi, ecx
799
        pop     ecx
800
        pop     edx
801
        add     edx, ecx
802
        ret
803
 
804
;-----------------------------------------------------------------------------
805
;                      Show FPU MMX register content
806
;
807
; in: esi->value, edx->string, ecx = string length, ebx = coord
808
draw_mmx_register:
809
        push    edx
810
        push    ecx
811
        push    esi
812
        mov     eax, esi
813
        mov     esi, ecx
814
    ; setting up registers color
815
    ; can be usual, inactive and changed
816
        ; inactive color
817
        ; was 0x40808080 - grey
818
        mov     ecx, (COLOR_TXT_INACTIVE or 0x40000000)
819
        cmp     [debuggee_pid], 0
820
        jz      .cd
821
        cmp     [bSuspended], 0
822
        jz      .cd
823
        ; normal color
824
        ; was 0x40000000 - black
825
        mov     ecx, (COLOR_TXT_NORMAL or 0x40000000)
826
        push    edi
827
        mov     edi, [eax]
828
        cmp     dword [eax+oldcontext-context], edi
829
        pop     edi
830
        jnz     .scol
831
        push    edi
832
        mov     edi, [eax+4]
833
        cmp     dword [eax+oldcontext-context+4], edi
834
        pop     edi
835
        jz      .cd
836
 
837
    .scol:
838
        ; changed color
839
        ; was 0x4000AA00 - green
840
        mov     ecx, (COLOR_TXT_CHANGED or 0x40000000)
841
 
842
    .cd:
843
        ;push   4
844
        ;pop    eax
845
        ; draw a text string in the window
846
        mcall   4
847
        imul    esi, 60000h
848
        lea     edx, [ebx+esi]
849
        ;mov    al, 47
850
        ;mov    ebx, 40100101h ; [20] show 16 chars set [30] bit - qword
851
        mov     esi, ecx
852
        pop     ecx
853
        ; draw a number in the window
854
        ; color is the same as for previous draw text function
855
        ; ebx : [20] show 16 chars set [30] bit - qword
856
        mcall   47, 40100101h
857
        lea     ebx, [edx+60000h*18]
858
        mov     esi, ecx
859
        pop     ecx
860
        pop     edx
861
        add     edx, ecx
862
        ret
863
 
864
; TODO add SSE registers
865
; TODO add AVX registers
866
 
867
;-----------------------------------------------------------------------------
868
;                   Display contents of EFLAGS register
869
draw_flag:
870
        movzx   edi, byte [edx+7]
871
        bt      [_eflags], edi
872
        jc      .on
873
        or      byte [edx], 20h
874
        jmp     .onoff
875
 
876
    .on:
877
        and     byte [edx], not 20h
878
 
879
    .onoff:
880
    ; setting up registers colors
881
    ; can be usual, inactive and changed
882
        ; inactive color
883
        ; was 0x40808080 - grey
884
        mov     ecx, (COLOR_TXT_INACTIVE or 0x40000000)
885
        cmp     [debuggee_pid], 0
886
        jz      .doit
887
        cmp     [bSuspended], 0
888
        jz      .doit
889
        ; normal color
890
        ; was 0x40000000 - black
891
        mov     ecx, (COLOR_TXT_NORMAL or 0x40000000)
892
        bt      [_eflags], edi
893
        lahf
894
        bt      dword [_eflags + oldcontext - context], edi
895
        rcl     ah, 1
896
        test    ah, 3
897
        jp      .doit
898
        ; changed color
899
        ; was 0x4000AA00 - green
900
        mov     ecx, (COLOR_TXT_CHANGED or 0x40000000)
901
 
902
    .doit:
903
        mov     ah, 0
904
        ; background color for text string or number
905
        ; was 0xFFFFFF - white
906
        mov     edi, COLOR_BG_NORMAL
907
        ; draw a text string in the window in one case
908
        ; and a number in another
909
        ; color scheme same as for previously called function (was in ecx)
910
        mcall
911
        ret
912
 
913
;-----------------------------------------------------------------------------
914
;                      Draw registers frame title
915
 
916
; Also show current register set (common + MMX, SSE or AVX)
917
draw_reg_title:
918
        ;push   4
919
        ;pop    eax
920
    ; setting up text backround color
921
        ; was 0xFFFFFF - white
922
        mov     edi, COLOR_BG_NORMAL
923
    ; setting up text color
924
    ; can be usual and inactive
925
        ; normal color
926
        ; was 0x40000000 - black
927
        mov     ecx, (COLOR_TXT_NORMAL or 0x40000000)
928
        mov     esi, 7
929
        cmp     [reg_mode], REG_MODE_CPU
930
        jz      @f
931
        ; inactive color
932
        ; was 0x40808080 - grey
933
        mov     ecx, (COLOR_TXT_INACTIVE or 0x40000000)
934
 
935
    @@:
936
        mov     edx, aMain
937
        ;mov    ebx, (registers_x_pos+4)*10000h + registers_y_pos+2
938
        ; draw a text string in the window
939
        mcall   4, (registers_x_pos+4)*10000h+registers_y_pos+2
940
        cmp     [reg_mode], REG_MODE_SSE
941
        jz      @f
942
        ; inactive color
943
        ; was 0x40808080 - grey
944
        mov     ecx, (COLOR_TXT_INACTIVE or 0x40000000)
945
 
946
    @@:
947
        mov     edx, aSSE
948
        ;mov        ebx, (registers_x_pos+46)*10000h + registers_y_pos+2
949
        ; draw a text string in the window
950
        mcall   4, (registers_x_pos+46)*10000h+registers_y_pos+2
951
        cmp     [reg_mode], REG_MODE_AVX
952
        jz      @f
953
        ; inactive color
954
        ; was 0x40808080 - grey
955
        mov     ecx, (COLOR_TXT_INACTIVE or 0x40000000)
956
 
957
    @@:
958
        mov     edx, aAVX
959
        ;mov    ebx, (registers_x_pos+88)*10000h + registers_y_pos+2
960
        ; draw a text string in the window
961
        mcall   4, (registers_x_pos+88)*10000h+registers_y_pos+2
962
        ret
963
 
964
;-----------------------------------------------------------------------------
965
;                Display common registers set + MMX + FPU
966
 
967
draw_main_registers:
968
        ;push    13
969
        ;pop     eax
970
        ;mov     edx, 0xFFFFFF
971
        ;mov     ebx, (registers_x_pos-1)*10000h + (registers_x_size+2)
972
        ;mov     ecx, (registers_y_pos-1)*10000h + (registers_y_size+2)
973
        ; draw container rectangle/box with COLOR_BG_NORMAL
974
        ; color in edx, was 0xFFFFFF - white
975
        mcall   13, (registers_x_pos-1)*10000h+(registers_x_size+2), (registers_y_pos-1)*10000h+(registers_y_size+2), COLOR_BG_NORMAL
976
 
977
    ; TODO: add support for FPU ST0-ST7 registers
978
    .redraw:
979
        ; setting up background color for text and numbers output
980
        ; was 0xFFFFFF - white
981
        mov     edi, COLOR_BG_NORMAL
982
        mov     esi, _eax
983
        push    4
984
        pop     ecx
985
        mov     edx, regs_strs
986
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+22
987
        call    draw_register
988
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+32
989
        add     esi, _ebx-_eax
990
        call    draw_register
991
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+42
992
        add     esi, _ecx-_ebx
993
        call    draw_register
994
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+52
995
        add     esi, _edx-_ecx
996
        call    draw_register
997
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+62
998
        add     esi, _esi-_edx
999
        call    draw_register
1000
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+72
1001
        add     esi, _edi-_esi
1002
        call    draw_register
1003
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+82
1004
        add     esi, _ebp-_edi
1005
        call    draw_register
1006
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+92
1007
        add     esi, _esp-_ebp
1008
        call    draw_register
1009
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+102
1010
        add     esi, _eip-_esp
1011
        call    draw_register
1012
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+112
1013
        push    cx
1014
        mov     cl, 7
1015
        add     esi, _eflags-_eip
1016
        call    draw_register
1017
        pop     cx
1018
 
1019
    ; MMX registers
1020
        mov     edx, mmx_strs
1021
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+142
1022
        mov     esi, _mm0
1023
        call    draw_mmx_register
1024
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+152
1025
        add     esi, _mm1-_mm0
1026
        call    draw_mmx_register
1027
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+162
1028
        add     esi, _mm2-_mm1
1029
        call    draw_mmx_register
1030
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+172
1031
        add     esi, _mm3-_mm2
1032
        call    draw_mmx_register
1033
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+182
1034
        add     esi, _mm4-_mm3
1035
        call    draw_mmx_register
1036
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+192
1037
        add     esi, _mm5-_mm4
1038
        call    draw_mmx_register
1039
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+202
1040
        add     esi, _mm6-_mm5
1041
        call    draw_mmx_register
1042
        mov     ebx, (registers_x_pos+2)*10000h+registers_y_pos+212
1043
        add     esi, _mm7-_mm6
1044
        call    draw_mmx_register
1045
        ;mov    al, 4
1046
        ; setting up text color
1047
        ; inactive color
1048
        ; was 0x808080 - grey
1049
        mov     ecx, COLOR_TXT_INACTIVE
1050
        cmp     [debuggee_pid], 0
1051
        jz      @f
1052
        cmp     [bSuspended], 0
1053
        jz      @f
1054
        xor     ecx, ecx
1055
 
1056
    @@:
1057
        mov     edx, aColon
1058
        xor     esi, esi
1059
        inc     esi
1060
        mov     ecx, COLOR_TXT_INACTIVE
1061
        ;mov    ebx, (registers_x_pos+10)*10000h + registers_y_pos+122
1062
        ; draw a text string in the window, color in ecx
1063
        mcall   4, (registers_x_pos+10)*10000h+registers_y_pos+122
1064
        mov     edx, flags
1065
 
1066
    @@:
1067
        add     ebx, 2*6*10000h
1068
        call    draw_flag
1069
        inc     edx
1070
        cmp     dl, flags_bits and 0xFF
1071
        jnz     @b
1072
        ret
1073
 
1074
;-----------------------------------------------------------------------------
1075
;                  Draw SSE registers set
1076
 
1077
draw_sse_registers:
1078
    .redraw:
1079
        ret
1080
 
1081
;-----------------------------------------------------------------------------
1082
;                  Draw AVX registers set
1083
 
1084
draw_avx_registers:
1085
    .redraw:
1086
        ret
1087
 
1088
;-----------------------------------------------------------------------------
1089
;                 Draw all registers sets
1090
draw_registers:
1091
        call    draw_reg_title
1092
        cmp     [reg_mode], REG_MODE_CPU
1093
        jnz     @f
1094
        call    draw_main_registers
1095
        ret
1096
 
1097
    @@:
1098
        cmp     [reg_mode], REG_MODE_SSE
1099
        jnz     @f
1100
        call    draw_sse_registers
1101
        ret
1102
 
1103
    @@:
1104
        call    draw_avx_registers
1105
        ret
1106
 
1107
    .redraw:
1108
        call    draw_reg_title
1109
        cmp     [reg_mode], REG_MODE_CPU
1110
        jnz     @f
1111
        call    draw_main_registers.redraw
1112
        ret
1113
 
1114
    @@:
1115
        cmp     [reg_mode], REG_MODE_SSE
1116
        jnz     @f
1117
        call    draw_sse_registers.redraw
1118
        ret
1119
 
1120
    @@:
1121
        call    draw_avx_registers.redraw
1122
        ret
1123
 
1124
;-----------------------------------------------------------------------------
1125
;                     Display memory dump
1126
 
1127
draw_dump:
1128
        ;push    13
1129
        ;pop     eax
1130
        ;mov     edx, 0xFFFFFF
1131
        ;mov     ebx, data_x_pos*10000h + data_x_size
1132
        ;mov     ecx, dump_y_pos*10000h + dump_y_size
1133
        ; draw container rectangle/box in the window
1134
        ; with color in COLOR_BG_NORMAL (was 0xFFFFFF - white)
1135
        mcall   13, data_x_pos*10000h+data_x_size, dump_y_pos*10000h+dump_y_size, COLOR_BG_NORMAL
1136
 
1137
    .redraw:
1138
    ; addresses
1139
        ;mov    al, 47
1140
        mov     ebx, 80100h
1141
        mov     edx, data_x_pos*10000h + dump_y_pos
1142
        mov     ecx, [dumppos]
1143
        ; background color for text string
1144
        ; was 0xFFFFFF - white
1145
        mov     edi, COLOR_BG_NORMAL
1146
        ; inactive color
1147
        ; was 0x40808080 - grey
1148
        mov     esi, (COLOR_TXT_INACTIVE or 0x40000000)
1149
        cmp     [debuggee_pid], 0
1150
        jz      @f
1151
        cmp     [bSuspended], 0
1152
        jz      @f
1153
        ; normal color
1154
        ; was 0x40000000 - black
1155
        mov     esi, (COLOR_TXT_NORMAL or 0x40000000)
1156
 
1157
    @@:
1158
        ; draw a number in the window, color in esi
1159
        mcall   47
1160
        add     ecx, 10h
1161
        add     edx, 10
1162
        cmp     dl, dump_y_pos + dump_y_size
1163
        jb      @b
1164
    ; hex dump of data
1165
        mov     ecx, dumpdata
1166
        push    ecx
1167
        xor     ebx, ebx
1168
        mov     edx, (data_x_pos+12*6)*10000h + dump_y_pos
1169
        cmp     [dumpread], ebx
1170
        jz      .hexdumpdone1
1171
 
1172
    .hexdumploop1:
1173
        push    ebx
1174
        mov     ebx, 20101h
1175
        ; draw a number in the window, color in esi
1176
        mcall
1177
        pop     ebx
1178
        add     edx, 3*6*10000h
1179
        inc     ecx
1180
        inc     ebx
1181
        test    bl, 15
1182
        jz      .16
1183
        test    bl, 7
1184
        jnz     @f
1185
        add     edx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h
1186
 
1187
    .16:
1188
        add     edx, 10 - 6*(3*10h+2)*10000h
1189
 
1190
    @@:
1191
        cmp     ebx, [dumpread]
1192
        jb      .hexdumploop1
1193
 
1194
    .hexdumpdone1:
1195
        mov     al, 4
1196
        ; copy color value from esi to ecx
1197
        ; to draw text string with 'mcall 4'
1198
        mov     ecx, esi
1199
        xchg    ebx, edx
1200
        push    2
1201
        pop     esi
1202
 
1203
    .hexdumploop2:
1204
        cmp     edx, dump_height*10h
1205
        jae     .hexdumpdone2
1206
        push    edx
1207
        mov     edx, aQuests
1208
        ; draw text string with color in ecx, copied from esi
1209
        mcall
1210
        pop     edx
1211
        add     ebx, 3*6*10000h
1212
        inc     edx
1213
        test    dl, 15
1214
        jz      .16x
1215
        test    dl, 7
1216
        jnz     .hexdumploop2
1217
        add     ebx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h
1218
 
1219
    .16x:
1220
        add     ebx, 10 - 6*(3*10h+2)*10000h
1221
        jmp     .hexdumploop2
1222
 
1223
    .hexdumpdone2:
1224
        dec     esi
1225
    ; colon, minus signs
1226
        mov     ebx, (data_x_pos+8*6)*10000h + dump_y_pos
1227
        mov     edx, aColon
1228
 
1229
    @@:
1230
        mcall
1231
        add     ebx, 10
1232
        cmp     bl, dump_y_pos+dump_height*10
1233
        jb      @b
1234
        mov     ebx, (data_x_pos+(12+3*8)*6)*10000h + dump_y_pos
1235
        mov     edx, aMinus
1236
 
1237
    @@:
1238
        mcall
1239
        add     ebx, 10
1240
        cmp     bl, dump_y_pos+dump_height*10
1241
        jb      @b
1242
    ; ASCII data
1243
        mov     ebx, (data_x_pos+(12+3*10h+2+2)*6)*10000h + dump_y_pos
1244
        pop     edx
1245
        push    dump_height*10h
1246
 
1247
    .asciiloop:
1248
        push    edx
1249
        cmp     byte [edx], 20h
1250
        jae     @f
1251
        mov     edx, aPoint
1252
 
1253
    @@:
1254
        ; draw a text string in the window, color in ecx
1255
        mcall
1256
        pop     edx
1257
        inc     edx
1258
        add     ebx, 6*10000h
1259
        dec     dword [esp]
1260
        jz      .asciidone
1261
        test    byte [esp], 15
1262
        jnz     .asciiloop
1263
        add     ebx, 10 - 6*10h*10000h
1264
        jmp     .asciiloop
1265
 
1266
    .asciidone:
1267
        pop     ecx
1268
        ret
1269
 
1270
;-----------------------------------------------------------------------------
1271
;                   Display disassembled code
1272
 
1273
; @@@@@ WAS:
1274
; redraw_disasm:
1275
;       push    13
1276
;       pop     eax
1277
;       mov     edx, 0xFFFFFF
1278
;       mov     ebx, data_x_pos*10000h + data_x_size
1279
;       mov     ecx, (disasm_y_pos-1)*10000h + (disasm_y_size+1)
1280
;       mcall
1281
;
1282
; @@@@@ NOW:
1283
draw_disasm:
1284
 
1285
    .redraw:
1286
        mov     eax, [disasm_start_pos]
1287
        mov     [disasm_cur_pos], eax
1288
        and     [disasm_cur_str], 0
1289
 
1290
    .loop:
1291
        mov     eax, [disasm_cur_pos]
1292
        call    find_symbol
1293
        jc      .nosymb
1294
        mov     ebx, [disasm_cur_str]
1295
        imul    ebx, 10
1296
        push    ebx
1297
        lea     ecx, [ebx+disasm_y_pos-1]
1298
        shl     ecx, 16
1299
        mov     cl, 11
1300
        ; setting up background color for disassembled text
1301
        mov     edx, COLOR_BG_NORMAL
1302
        ;mov    ebx, data_x_pos*10000h + data_x_size
1303
        ;push   13
1304
        ;pop    eax
1305
        ; draw container rectangle/box with color COLOR_BG_NORMAL (was 0xFFFFFF - white)
1306
        mcall   13, data_x_pos*10000h+data_x_size
1307
        pop     ebx
1308
        ; copy color value from edx (COLOR_BG_NORMAL)
1309
        mov     edi, edx
1310
        add     ebx, (data_x_pos+6*2)*10000h+disasm_y_pos
1311
        mov     edx, esi
1312
 
1313
    @@:
1314
        lodsb
1315
        test    al, al
1316
        jnz     @b
1317
        mov     byte [esi-1], ':'
1318
        sub     esi, edx
1319
        ; normal color
1320
        ; was 0x40000000
4886 hidnplayr 1321
        mov     ecx, (COLOR_TXT_LABEL or 0x40000000)
4591 hidnplayr 1322
        mov     al, 4
1323
        ; draw a text string in the window with color COLOR_TXT_NORMAL in ecx
1324
        mcall
1325
        mov     byte [esi+edx-1], 0
1326
        lea     esi, [esi*3]
1327
        movzx   ecx, bx
1328
        shr     ebx, 16
1329
        lea     ebx, [ebx+esi*2]
1330
        shl     ecx, 16
1331
        mov     cl, 10
1332
        imul    ebx, 10001h
1333
        sub     bx, data_x_pos+data_x_size
1334
        neg     bx
1335
        mov     al, 13
1336
        ; copy color value from edi
1337
        mov     edx, edi
1338
        ; draw container rectangle/box for disassembled text, color in edx
1339
        mcall
1340
        inc     [disasm_cur_str]
1341
        cmp     [disasm_cur_str], disasm_height
1342
        jae     .loopend
1343
 
1344
    .nosymb:
1345
        push    [disasm_cur_pos]
1346
        call    disasm_instr
1347
        pop     ebp
1348
        jc      .loopend
4886 hidnplayr 1349
        mov     edx, COLOR_BG_NORMAL
4591 hidnplayr 1350
        mov     esi, COLOR_TXT_NORMAL
1351
        mov     ebx, data_x_pos*10000h + data_x_size
1352
        mov     ecx, [disasm_cur_str]
1353
        imul    ecx, 10*10000h
1354
        add     ecx, (disasm_y_pos-1)*10000h + 10
1355
        mov     eax, ebp
1356
        pushad
1357
        call    find_enabled_breakpoint
1358
        popad
4886 hidnplayr 1359
        jnz     .nobp
4591 hidnplayr 1360
        mov     edx, COLOR_BG_BREAKPOINT
4886 hidnplayr 1361
        mov     esi, COLOR_TXT_BREAKPOINT
1362
    .nobp:
4591 hidnplayr 1363
 
1364
        mov     eax, [_eip]
1365
        cmp     eax, ebp
4886 hidnplayr 1366
        jnz     .notcurrent
4591 hidnplayr 1367
        mov     edx, COLOR_BG_SELECTED
1368
        mov     esi, COLOR_TXT_SELECTED
4886 hidnplayr 1369
    .notcurrent:
1370
        push    esi     ; Save color value for disassembled text
4591 hidnplayr 1371
 
1372
        ; draw container rectangle/box for disassembled text
1373
        ; color in edx
1374
        mcall   13
1375
        ;mov    al, 47
1376
        ;mov    ebx, 80100h
1377
        mov     edx, [disasm_cur_str]
1378
        imul    edx, 10
1379
        add     edx, data_x_pos*10000h + disasm_y_pos
1380
        ;mov    ecx, ebp
1381
        ; draw a number in the window, color in esi
1382
        mcall   47, 80100h, ebp
1383
        ;mov    al, 4
1384
        lea     ebx, [edx+8*6*10000h]
4886 hidnplayr 1385
        mov     ecx, esi    ; text color
4591 hidnplayr 1386
        push    2
1387
        pop     esi
1388
        mov     edx, aColon
4886 hidnplayr 1389
        ; draw the colon
4591 hidnplayr 1390
        mcall   4
1391
        push    9
1392
        pop     edi
1393
        lea     edx, [ebx+2*6*10000h]
1394
        mov     ecx, ebp
1395
        sub     ecx, [disasm_start_pos]
1396
        add     ecx, disasm_buffer
1397
 
4886 hidnplayr 1398
        mov     esi, COLOR_TXT_ADDR
1399
        mov     eax, [_eip]
1400
        cmp     eax, ebp
1401
        jnz     @f
1402
        mov     esi, COLOR_TXT_SELECTED
1403
  @@:
4591 hidnplayr 1404
    .drawhex:
1405
        ; draw a number in the window, color in esi
1406
        mcall   47, 20101h
1407
        add     edx, 6*3*10000h
1408
        inc     ecx
1409
        inc     ebp
1410
        cmp     ebp, [disasm_cur_pos]
1411
        jae     .hexdone
1412
        dec     edi
1413
        jnz     .drawhex
1414
        push    esi
1415
        mov     esi, [disasm_cur_pos]
1416
        dec     esi
1417
        cmp     esi, ebp
1418
        pop     esi
1419
        jbe     .drawhex
1420
        ;mov    al, 4
1421
        lea     ebx, [edx-6*10000h]
1422
        ; copy color value from esi
1423
        mov     ecx, esi
1424
        push    3
1425
        pop     esi
1426
        mov     edx, aDots
1427
        ; draw a text string in the window, color in ecx
1428
        mcall   4
1429
 
1430
    .hexdone:
4886 hidnplayr 1431
        pop     esi
4591 hidnplayr 1432
        xor     eax, eax
1433
        mov     edi, disasm_string
1434
        mov     edx, edi
1435
        or      ecx, -1
1436
        repnz scasb
1437
        not     ecx
1438
        dec     ecx
1439
        xchg    ecx, esi
1440
        mov     ebx, [disasm_cur_str]
1441
        imul    ebx, 10
1442
        add     ebx, (data_x_pos+6*40)*10000h+disasm_y_pos
1443
        ;mov    al, 4
1444
        ; draw a text string in the window, color in ecx
1445
        mcall   4
1446
        inc     [disasm_cur_str]
1447
        cmp     [disasm_cur_str], disasm_height
1448
        jb      .loop
1449
 
1450
    .loopend:
1451
        mov     ecx, disasm_height
1452
        sub     ecx, [disasm_cur_str]
1453
        jz      @f
1454
        imul    ecx, 10
1455
        inc     ecx
1456
        mov     eax, disasm_y_pos + disasm_y_size
1457
        sub     eax, ecx
1458
        shl     eax, 16
1459
        add     ecx, eax
1460
        ;push   13
1461
        ;pop    eax
1462
        ;mov    ebx, data_x_pos*65536 + data_x_size
1463
        ; set backroung color for disassembly container
1464
        ; was 0xFFFFFF - white
1465
        mov     edx, COLOR_BG_NORMAL
1466
        ; draw container rectangle/box with color COLOR_BG_NORMAL (in edx)
1467
        mcall   13, data_x_pos*65536+data_x_size
1468
 
1469
    @@:
1470
        ret
1471
 
1472
;-----------------------------------------------------------------------------
1473
 
1474
; TODO: cleanup of this function, make some global labels local
1475
update_disasm_eip:
1476
; test if instruction at eip is showed
1477
        mov     ecx, disasm_height
1478
        mov     eax, [disasm_start_pos]
1479
        mov     [disasm_cur_pos], eax
1480
 
1481
    .l:
1482
        mov     eax, [disasm_cur_pos]
1483
        call    find_symbol
1484
        jc      @f
1485
        dec     ecx
1486
        jz      .m
1487
 
1488
    @@:
1489
        cmp     [_eip], eax
1490
        jz      draw_disasm.redraw
1491
        push    ecx
1492
        call    disasm_instr
1493
        pop     ecx
1494
        jc      .m
1495
        loop    .l
1496
 
1497
    .m:
1498
 
1499
update_disasm_eip_force:
1500
        mov     eax, [_eip]
1501
        mov     [disasm_start_pos], eax
1502
 
1503
update_disasm:
1504
        cmp     [debuggee_pid], 0
1505
        jz      .no
1506
        ;push   69
1507
        ;pop    eax
1508
        ;push   6
1509
        ;pop    ebx
1510
        ;mov    ecx, [debuggee_pid]
1511
        ;mov    edi, disasm_buffer
1512
        ;mov    edx, 256
1513
        ;mov    esi, [disasm_start_pos]
1514
        mcall   69, 6, [debuggee_pid], 256, [disasm_start_pos], disasm_buffer
1515
        cmp     eax, -1
1516
        jnz     @f
1517
        mov     esi, read_mem_err
1518
        call    put_message
1519
 
1520
    .no:
1521
        xor     eax, eax
1522
 
1523
    @@:
1524
        mov     [disasm_buf_size], eax
1525
        call    restore_from_breaks
1526
        jmp     draw_disasm.redraw
1527
 
1528
 
1529
;-----------------------------------------------------------------------------
1530
;                               Draw main window
1531
 
1532
draw_window:
1533
    ; start window redraw
1534
        mcall   12, 1
1535
 
1536
    ; define window
4594 hidnplayr 1537
        mcall   0, wnd_x_size, wnd_y_size, (COLOR_BG_NORMAL or 0x54000000), , caption_str
4591 hidnplayr 1538
 
1539
    ; clear unused areas
1540
        ; get window skin height
1541
        mcall   48, 4
1542
        cmp     eax, title_y_pos
1543
        jb      @f
1544
        push    registers_y_pos
1545
        pop     eax
1546
 
1547
    @@:
1548
        push    registers_y_pos
1549
        pop     ecx
1550
        push    eax
1551
        sub     ecx, eax
1552
        shl     eax, 16
1553
        add     ecx, eax
1554
        mov     ebx, 5*10000h + (wnd_x_size-9)
1555
        mov     edx, COLOR_BG_NORMAL
1556
        ; draw container rectangle/box for registers information region
1557
        mcall   13
1558
        mov     ecx, (dump_y_pos+dump_y_size)*10000h + (disasm_y_pos-dump_y_pos-dump_y_size)
1559
        ; draw container rectangle/box for dump memory region
1560
        mcall
1561
        mov     ecx, (disasm_y_pos-1+disasm_y_size)*10000h + (messages_y_pos-disasm_y_pos+1-disasm_y_size)
1562
        ; draw container rectangle/box for disassembled code region
1563
        mcall
1564
        mov     ecx, (messages_y_pos+messages_y_size)*10000h + (wnd_y_size-messages_y_pos-messages_y_size-4)
1565
        ; draw container rectangle/box for messages window region
1566
        mcall
1567
        mov     ebx, 5*10000h + (data_x_pos-5)
1568
        pop     ecx
1569
        imul    ecx, 10001h
1570
        sub     cx, wnd_y_size-4
1571
        neg     cx
1572
        ; draw container rectangle/box
1573
        mcall
1574
        mov     ebx, (data_x_pos+data_x_size)*10000h + (wnd_x_size-data_x_pos-data_x_size-4)
1575
        ; draw container rectangle/box
1576
        mcall
1577
        mov     ebx, 5*10000h + title_x_pos - 5
1578
        mov     ecx, (title_y_pos)*10000h + (title_y_size)
1579
        ; draw container rectangle/box for dump memory region title
1580
        mcall
1581
 
1582
    ; messages frame
1583
        mov     ebx, (messages_x_pos-2)*10000h + (messages_x_pos+messages_x_size+2)
1584
        push    ebx
1585
        mov     ecx, (messages_y_pos-2)*10001h
1586
        mov     edx, COLOR_LINE
1587
        mcall   38
1588
        mov     ecx, (messages_y_pos+messages_y_size+2)*10001h
1589
        mcall
1590
        mov     ebx, (messages_x_pos-2)*10001h
1591
        push    ebx
1592
        mov     ecx, (messages_y_pos-2)*10000h + (messages_y_pos+messages_y_size+2)
1593
        mcall
1594
        mov     ebx, (messages_x_pos+messages_x_size+2)*10001h
1595
        push    ebx
1596
        mcall
1597
 
1598
    ; command line frame
1599
        mov     ecx, (cmdline_y_pos-2)*10000h + (cmdline_y_pos+cmdline_y_size+2)
1600
        pop     ebx
1601
        mcall
1602
        pop     ebx
1603
        mcall
1604
        pop     ebx
1605
        mov     ecx, (cmdline_y_pos+cmdline_y_size+2)*10001h
1606
        mcall
1607
        mov     ecx, (cmdline_y_pos-2)*10001h
1608
        mcall
1609
 
1610
    ; registers frame
4886 hidnplayr 1611
                DrawRectangle (registers_x_pos-2), (registers_y_pos-2), (registers_x_size+3), (registers_y_size+3), COLOR_LINE
4591 hidnplayr 1612
        ; draw container rectangle/box for registers information window region
1613
 
1614
    ; messages
1615
        call    draw_messages
1616
 
1617
    ; command line & cursor
1618
        call    draw_cmdline
1619
        call    draw_cursor
1620
 
1621
    ; title & registers & dump & disasm
1622
        mov     ebx, (data_x_pos-2)*10001h
1623
        mov     ecx, (title_y_pos+5)*10000h + (messages_y_pos-2)
1624
        mov     edx, COLOR_LINE
1625
        mcall   38
1626
        mov     ebx, (data_x_pos+data_x_size+2)*10001h
1627
        mcall
1628
        mov     ebx, (data_x_pos-2)*10000h + (data_x_pos+data_x_size+2)
1629
        mov     ecx, (disasm_y_pos-4)*10001h
1630
        mcall
1631
 
1632
    ; redraw whole window again
1633
        call    redraw_title
1634
        call    draw_registers
1635
        call    draw_dump
1636
        call    draw_disasm.redraw
1637
 
1638
    ; end of window redraw
1639
        mcall   12, 2
1640
        ret
1641
 
1642
; vim: ft=fasm tabstop=4
1643