Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
716 | lvd | 1 | #include "std.h" |
2 | |||
3 | #include "resource.h" |
||
4 | #include "emul.h" |
||
5 | #include "vars.h" |
||
6 | #include "debug.h" |
||
7 | #include "dbgpaint.h" |
||
8 | #include "util.h" |
||
9 | |||
10 | namespace z80dbg |
||
11 | { |
||
12 | __int64 __cdecl delta() |
||
13 | { |
||
14 | return comp.t_states + cpu.t - cpu.debug_last_t; |
||
15 | } |
||
16 | } |
||
17 | |||
18 | void show_time() |
||
19 | { |
||
20 | Z80 &cpu = CpuMgr.Cpu(); |
||
21 | tprint(time_x, time_y, "time delta:", W_OTHEROFF); |
||
22 | char text[32]; |
||
23 | sprintf(text, "%14I64d", cpu.Delta()); |
||
24 | tprint(time_x+11, time_y, text, W_OTHER); |
||
25 | tprint(time_x+25, time_y, "t", W_OTHEROFF); |
||
26 | frame(time_x, time_y, 26, 1, FRAME); |
||
27 | } |
||
28 | |||
29 | static void wtline(const char *name, unsigned ptr, unsigned y) |
||
30 | { |
||
31 | char line[40]; |
||
32 | if(name) |
||
33 | sprintf(line, "%3s: ", name); |
||
34 | else |
||
35 | sprintf(line, "%04X ", ptr); |
||
36 | |||
37 | Z80 &cpu = CpuMgr.Cpu(); |
||
38 | for (unsigned dx = 0; dx < 8; dx++) |
||
39 | { |
||
40 | unsigned char c = cpu.DirectRm(ptr++); |
||
41 | sprintf(line+5+3*dx, "%02X", c); |
||
42 | line[7+3*dx] = ' '; |
||
43 | line[29+dx] = c ? c : '.'; |
||
44 | } |
||
45 | |||
46 | line[37] = 0; |
||
47 | tprint(wat_x, wat_y+y, line, W_OTHER); |
||
48 | } |
||
49 | |||
50 | void showwatch() |
||
51 | { |
||
52 | if (show_scrshot) |
||
53 | { |
||
54 | for (unsigned y = 0; y < wat_sz; y++) |
||
55 | for (unsigned x = 0; x < 37; x++) |
||
56 | txtscr[80*30 + (wat_y+y)*80 + (wat_x+x)] = 0xFF; |
||
57 | } |
||
58 | else |
||
59 | { |
||
60 | Z80 &cpu = CpuMgr.Cpu(); |
||
61 | wtline("PC", cpu.pc, 0); |
||
62 | wtline("SP", cpu.sp, 1); |
||
63 | wtline("BC", cpu.bc, 2); |
||
64 | wtline("DE", cpu.de, 3); |
||
65 | wtline("HL", cpu.hl, 4); |
||
66 | wtline("IX", cpu.ix, 5); |
||
67 | wtline("IY", cpu.iy, 6); |
||
68 | wtline("BC'", cpu.alt.bc, 7); |
||
69 | wtline("DE'", cpu.alt.de, 8); |
||
70 | wtline("HL'", cpu.alt.hl, 9); |
||
71 | wtline(0, user_watches[0], 10); |
||
72 | wtline(0, user_watches[1], 11); |
||
73 | wtline(0, user_watches[2], 12); |
||
74 | } |
||
75 | const char *text = "watches"; |
||
76 | if (show_scrshot == 1) text = "screen memory"; |
||
77 | if (show_scrshot == 2) text = "ray-painted"; |
||
78 | tprint(wat_x, wat_y-1, text, W_TITLE); |
||
79 | if(comp.flags & CF_DOSPORTS) |
||
80 | tprint(wat_x+34, wat_y-1, "DOS", W_DOS); |
||
81 | frame(wat_x,wat_y,37,wat_sz,FRAME); |
||
82 | } |
||
83 | |||
84 | void mon_setwatch() |
||
85 | { |
||
86 | if (show_scrshot) show_scrshot = 0; |
||
87 | for (unsigned i = 0; i < 3; i++) { |
||
88 | debugscr(); |
||
89 | unsigned addr = input4(wat_x, wat_y+wat_sz-3+i, user_watches[i]); |
||
90 | if (addr == -1) return; |
||
91 | user_watches[i] = addr; |
||
92 | } |
||
93 | } |
||
94 | |||
95 | void showstack() |
||
96 | { |
||
97 | Z80 &cpu = CpuMgr.Cpu(); |
||
98 | for (unsigned i = 0; i < stack_size; i++) |
||
99 | { |
||
100 | char xx[10]; //-2:1234 |
||
101 | //SP:1234 |
||
102 | //+2: |
||
103 | if (!i) *(unsigned*)xx = WORD2('-','2'); |
||
104 | else if (i==1) *(unsigned*)xx = WORD2('S','P'); |
||
105 | else sprintf(xx, (i > 8) ? "%X" : "+%X", (i-1)*2); |
||
106 | sprintf(xx+2, ":%02X%02X", cpu.DirectRm(cpu.sp+(i-1)*2+1), cpu.DirectRm(cpu.sp+(i-1)*2)); |
||
107 | tprint(stack_x, stack_y+i, xx, W_OTHER); |
||
108 | } |
||
109 | tprint(stack_x, stack_y-1, "stack", W_TITLE); |
||
110 | frame(stack_x, stack_y, 7, stack_size, FRAME); |
||
111 | } |
||
112 | |||
113 | void show_ay() |
||
114 | { |
||
115 | if (!conf.sound.ay_scheme) return; |
||
116 | const char *ayn = comp.active_ay ? "AY1" : "AY0"; |
||
117 | if (conf.sound.ay_scheme < AY_SCHEME_QUADRO) ayn = "AY:", comp.active_ay = 0; |
||
118 | tprint(ay_x-3, ay_y, ayn, W_TITLE); |
||
119 | SNDCHIP *chip = &ay[comp.active_ay]; |
||
120 | char line[32]; |
||
121 | for (int i = 0; i < 16; i++) { |
||
122 | line[0] = "0123456789ABCDEF"[i]; line[1] = 0; |
||
123 | tprint(ay_x + i*3, ay_y, line, W_AYNUM); |
||
124 | sprintf(line, "%02X", chip->get_reg(i)); |
||
125 | tprint(ay_x + i*3 + 1, ay_y, line, i == (chip->get_activereg()) ? W_AYON : W_AYOFF); |
||
126 | } |
||
127 | frame(ay_x, ay_y, 48, 1, FRAME); |
||
128 | } |
||
129 | |||
130 | void mon_switchay() |
||
131 | { |
||
132 | comp.active_ay ^= 1; |
||
133 | } |
||
134 | |||
135 | void __cdecl BankNames(int i, char *Name) |
||
136 | { |
||
137 | unsigned rom_bank; |
||
138 | unsigned ram_bank; |
||
139 | |||
140 | bool IsRam = (RAM_BASE_M <= bankr[i]) && (bankr[i] < RAM_BASE_M + PAGE * MAX_RAM_PAGES); |
||
141 | bool IsRom = (ROM_BASE_M <= bankr[i]) && (bankr[i] < ROM_BASE_M + PAGE * MAX_ROM_PAGES); |
||
142 | |||
143 | if(IsRam) |
||
144 | ram_bank = ULONG((bankr[i] - RAM_BASE_M)/PAGE); |
||
145 | |||
146 | if(IsRom) |
||
147 | rom_bank = ULONG((bankr[i] - ROM_BASE_M)/PAGE); |
||
148 | |||
149 | if (IsRam) |
||
150 | sprintf(Name, "RAM%2X", ram_bank); |
||
151 | |||
152 | if (IsRom) |
||
153 | sprintf(Name, "ROM%2X", rom_bank); |
||
154 | |||
155 | if (bankr[i] == base_sos_rom) |
||
156 | strcpy(Name, "BASIC"); |
||
157 | if (bankr[i] == base_dos_rom) |
||
158 | strcpy(Name, "TRDOS"); |
||
159 | if (bankr[i] == base_128_rom) |
||
160 | strcpy(Name, "B128K"); |
||
161 | if (bankr[i] == base_sys_rom && (conf.mem_model == MM_PROFSCORP || conf.mem_model == MM_SCORP)) |
||
162 | strcpy(Name, "SVM "); |
||
163 | if ((conf.mem_model == MM_PROFSCORP || conf.mem_model == MM_SCORP) && IsRom && rom_bank > 3) |
||
164 | sprintf(Name, "ROM%2X", rom_bank); |
||
165 | |||
166 | if (bankr[i] == CACHE_M) |
||
167 | strcpy(Name, (conf.cache!=32)?"CACHE":"CACH0"); |
||
168 | if (bankr[i] == CACHE_M+PAGE) |
||
169 | strcpy(Name, "CACH1"); |
||
170 | } |
||
171 | |||
172 | void showbanks() |
||
173 | { |
||
174 | Z80 &cpu = CpuMgr.Cpu(); |
||
175 | for (int i = 0; i < 4; i++) |
||
176 | { |
||
177 | char ln[64]; sprintf(ln, "%d:", i); |
||
178 | tprint(banks_x, banks_y+i+1, ln, W_OTHEROFF); |
||
179 | strcpy(ln, "?????"); |
||
180 | cpu.BankNames(i, ln); |
||
181 | tprint(banks_x+2, banks_y+i+1, ln, bankr[i]!=bankw[i] ? W_BANKRO : W_BANK); |
||
182 | } |
||
183 | frame(banks_x, banks_y+1, 7, 4, FRAME); |
||
184 | tprint(banks_x, banks_y, "pages", W_TITLE); |
||
185 | } |
||
186 | |||
187 | void showports() |
||
188 | { |
||
189 | char ln[64]; |
||
190 | sprintf(ln, " FE:%02X", comp.pFE); |
||
191 | tprint(ports_x, ports_y, ln, W_OTHER); |
||
192 | sprintf(ln, "7FFD:%02X", comp.p7FFD); |
||
193 | tprint(ports_x, ports_y+1, ln, (comp.p7FFD & 0x20) && |
||
194 | !((conf.mem_model == MM_PENTAGON && conf.ramsize == 1024) || |
||
195 | (conf.mem_model == MM_PROFI && (comp.pDFFD & 0x10))) ? W_48K : W_OTHER); |
||
196 | |||
197 | switch (conf.mem_model) |
||
198 | { |
||
199 | case MM_KAY: |
||
200 | case MM_SCORP: |
||
201 | case MM_PROFSCORP: |
||
202 | case MM_PLUS3: |
||
203 | dbg_extport = 0x1FFD; dgb_extval = comp.p1FFD; |
||
204 | break; |
||
205 | case MM_PROFI: |
||
206 | dbg_extport = 0xDFFD; dgb_extval = comp.pDFFD; |
||
207 | break; |
||
208 | case MM_ATM450: |
||
209 | dbg_extport = 0xFDFD; dgb_extval = comp.pFDFD; |
||
210 | break; |
||
211 | case MM_ATM710: |
||
212 | case MM_ATM3: |
||
213 | dbg_extport = (comp.aFF77 & 0xFFFF); |
||
214 | dgb_extval = comp.pFF77; |
||
215 | break; |
||
216 | case MM_QUORUM: |
||
217 | dbg_extport = 0x0000; dgb_extval = comp.p00; |
||
218 | break; |
||
219 | default: |
||
220 | dbg_extport = -1; |
||
221 | } |
||
222 | if (dbg_extport != -1) |
||
223 | sprintf(ln, "%04X:%02X", dbg_extport, dgb_extval); |
||
224 | else |
||
225 | sprintf(ln, "cmos:%02X", comp.cmos_addr); |
||
226 | tprint(ports_x, ports_y+2, ln, W_OTHER); |
||
227 | |||
228 | sprintf(ln, "EFF7:%02X", comp.pEFF7); |
||
229 | tprint(ports_x, ports_y+3, ln, W_OTHER); |
||
230 | frame(ports_x, ports_y, 7, 4, FRAME); |
||
231 | tprint(ports_x, ports_y-1, "ports", W_TITLE); |
||
232 | } |
||
233 | |||
234 | void showdos() |
||
235 | { |
||
236 | // CD:802E |
||
237 | // STAT:24 |
||
238 | // SECT:00 |
||
239 | // T:00/01 |
||
240 | // S:00/00 |
||
241 | //[vv] if (conf.trdos_present) comp.wd.process(); |
||
242 | char ln[64]; unsigned char atr = conf.trdos_present ? W_OTHER : W_OTHEROFF; |
||
243 | sprintf(ln, "CD:%02X%02X", comp.wd.cmd, comp.wd.data); |
||
244 | tprint(dos_x, dos_y, ln, atr); |
||
245 | sprintf(ln, "STAT:%02X", comp.wd.RdStatus()); |
||
246 | tprint(dos_x, dos_y+1, ln, atr); |
||
247 | sprintf(ln, "SECT:%02X", comp.wd.sector); |
||
248 | tprint(dos_x, dos_y+2, ln, atr); |
||
249 | sprintf(ln, "T:%02X/%02X", comp.wd.seldrive->track, comp.wd.track); |
||
250 | tprint(dos_x, dos_y+3, ln, atr); |
||
251 | sprintf(ln, "S:%02X/%02X", comp.wd.system, comp.wd.rqs); |
||
252 | tprint(dos_x, dos_y+4, ln, atr); |
||
253 | frame(dos_x, dos_y, 7, 5, FRAME); |
||
254 | #if 1 |
||
255 | tprint(dos_x, dos_y-1, "beta128", W_TITLE); |
||
256 | #else |
||
257 | sprintf(ln, "%X-%X %d", comp.wd.state, comp.wd.state2, comp.wd.seldrive->track); |
||
258 | tprint(dos_x,dos_y-1, ln, atr); |
||
259 | #endif |
||
260 | /* |
||
261 | // STAT:00101010 |
||
262 | // CMD:80,STA:2A |
||
263 | // DAT:22,SYS:EE |
||
264 | // TRK:31,SEC:01 |
||
265 | // DISK:A,SIDE:0 |
||
266 | |||
267 | char ln[64]; unsigned char atr = conf.trdos_present ? 0x20 : 0x27; |
||
268 | sprintf(ln, "STAT:00000000"); unsigned char stat = in_trdos(0x1F); |
||
269 | for (int i = 0; i < 7; i++) ln[i+5] = (stat & (0x80 >> i)) ? '1':'0'; |
||
270 | tprint(dos_x, dos_y+1, ln, atr); |
||
271 | sprintf(ln, "CMD:%02X,STA:%02X", comp.trdos.cmd, stat); |
||
272 | tprint(dos_x, dos_y+2, ln, atr); |
||
273 | sprintf(ln, "DAT:%02X,SYS:%02X", comp.trdos.data, in_trdos(0xFF)); |
||
274 | tprint(dos_x, dos_y+3, ln, atr); |
||
275 | sprintf(ln, "TRK:%02X,SEC:%02X", comp.trdos.track, comp.trdos.sector); |
||
276 | tprint(dos_x, dos_y+4, ln, atr); |
||
277 | sprintf(ln, "DISK:%c,SIDE:%c", 'A'+(comp.trdos.system & 3), (comp.trdos.system & 0x10) ? '0':'1'); |
||
278 | tprint(dos_x, dos_y+5, ln, atr); |
||
279 | frame(dos_x, dos_y+1, 13, 5, FRAME); |
||
280 | tprint(dos_x, dos_y, "beta128", 0x83); |
||
281 | */ |
||
282 | } |
||
283 | |||
284 | #ifdef MOD_GSBASS |
||
285 | INT_PTR CALLBACK gsdlg(HWND dlg, UINT msg, WPARAM wp, LPARAM lp) |
||
286 | { |
||
287 | char tmp[0x200]; |
||
288 | unsigned i; //Alone Coder 0.36.7 |
||
289 | if (msg == WM_INITDIALOG) { |
||
290 | repaint: |
||
291 | while (SendDlgItemMessage(dlg, IDC_GSLIST, LB_GETCOUNT, 0, 0)) |
||
292 | SendDlgItemMessage(dlg, IDC_GSLIST, LB_DELETESTRING, 0, 0); |
||
293 | if (gs.modsize) { |
||
294 | sprintf(tmp, "%-.20s (%s)", gs.mod, gs.mod_playing ? "playing" : "stopped"); |
||
295 | SendDlgItemMessage(dlg, IDC_GSLIST, LB_ADDSTRING, 0, (LPARAM)tmp); |
||
296 | } |
||
297 | for (/*unsigned*/ i = 1; i < gs.total_fx; i++) { |
||
298 | sprintf(tmp, "%csmp %d: v=%d, n=%d, %d%s", |
||
299 | gs.cur_fx == i ? '*':' ', i, |
||
300 | gs.sample[i].volume, gs.sample[i].note, gs.sample[i].end, |
||
301 | gs.sample[i].loop < gs.sample[i].end ? " (L)":nil); |
||
302 | SendDlgItemMessage(dlg, IDC_GSLIST, LB_ADDSTRING, 0, (LPARAM)tmp); |
||
303 | } |
||
304 | *tmp = 0; for (i = 0; i < 0x100; i++) { |
||
305 | if (gs.badgs[i]) sprintf(tmp+strlen(tmp), "%02X ", i); |
||
306 | } |
||
307 | SendDlgItemMessage(dlg, IDE_GS, WM_SETTEXT, 0, (LPARAM)tmp); |
||
308 | return 1; |
||
309 | } |
||
310 | if (msg == WM_SYSCOMMAND && (wp & 0xFFF0) == SC_CLOSE) EndDialog(dlg, 0); |
||
311 | if (msg != WM_COMMAND) return 0; |
||
312 | unsigned id = LOWORD(wp); |
||
313 | if (id == IDCANCEL || id == IDOK) EndDialog(dlg, 0); |
||
314 | if (id == IDB_GS_CLEAR) { memset(gs.badgs, 0, sizeof gs.badgs); SendDlgItemMessage(dlg, IDE_GS, WM_SETTEXT, 0, 0); } |
||
315 | if (id == IDB_GS_RESET) { gs.reset(); goto repaint; } |
||
316 | if (id == IDB_GS_PLAY || (id == IDC_GSLIST && HIWORD(wp) == LBN_DBLCLK)) { |
||
317 | unsigned i = SendDlgItemMessage(dlg, IDC_GSLIST, LB_GETCURSEL, 0, 0); |
||
318 | if (i > 0x100) return 1; |
||
319 | if (!i && gs.modsize) { |
||
320 | gs.mod_playing ^= 1; |
||
321 | if (gs.mod_playing) gs.restart_mod(0,0); else gs.stop_mod(); |
||
322 | goto repaint; |
||
323 | } |
||
324 | if (!gs.modsize) i++; |
||
325 | gs.debug_note(i); |
||
326 | } |
||
327 | return 0; |
||
328 | } |
||
329 | |||
330 | void mon_gsdialog() |
||
331 | { |
||
332 | if (conf.gs_type == 2) |
||
333 | DialogBox(hIn, MAKEINTRESOURCE(IDD_GS), wnd, gsdlg); |
||
334 | else MessageBox(wnd, "high-level GS emulation\nis not initialized", 0, MB_OK | MB_ICONERROR); |
||
335 | } |
||
336 | #else |
||
337 | void mon_gsdialog() {} |
||
338 | #endif |