Subversion Repositories Kolibri OS

Rev

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