Subversion Repositories Kolibri OS

Rev

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