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