Subversion Repositories Kolibri OS

Rev

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