Subversion Repositories Kolibri OS

Rev

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