1 /************************************************************************/
2 /* */
3 /* ��˥����⡼�� */
4 /* */
5 /************************************************************************/
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <ctype.h>
11 #include <signal.h>
12
13 #include "quasi88.h"
14 #include "initval.h"
15 #include "monitor.h"
16
17 #include "pc88cpu.h"
18 #include "pc88main.h"
19 #include "pc88sub.h"
20 #include "crtcdmac.h"
21 #include "memory.h"
22 #include "graph.h"
23 #include "intr.h"
24 #include "keyboard.h"
25 #include "pio.h"
26 #include "soundbd.h"
27 #include "screen.h"
28 #include "fdc.h"
29
30 #include "emu.h"
31 #include "drive.h"
32 #include "image.h"
33 #include "file-op.h"
34 #include "status.h"
35 #include "menu.h"
36 #include "pause.h"
37 #include "snddrv.h"
38 #include "wait.h"
39 #include "suspend.h"
40 #include "snapshot.h"
41 #include "event.h"
42
43 #include "basic.h"
44
45
46 #ifdef USE_GNU_READLINE
47 #include <readline/readline.h>
48 #include <readline/history.h>
49 #endif
50
51 #ifdef USE_LOCALE
52 #include <locale.h>
53 #include <langinfo.h>
54 #endif /* USE_LOCALE */
55
56
57
58 /************************************************************************/
59 /* SIGINTȯ���� (Ctrl-C) ����˥����⡼�ɤ����ܤ���褦������ */
60 /* ��ư���� -debug ���ץ���������Τߡ�̤������Ͻ�λ���롣 */
61 /************************************************************************/
62
63 int debug_mode = FALSE; /* �ǥХå���ǽ(��˥���) */
64
65 char alt_char = 'X'; /* ����ʸ�� */
66
67
68
69 /* ��˥����⡼�ɰʳ��λ��� SIGINT(Ctrl-C)�������ä����˥����⡼�ɤ˰ܹ� */
70
sigint_handler(int dummy)71 static void sigint_handler(int dummy)
72 {
73 quasi88_monitor();
74 signal(SIGINT, sigint_handler);
75 }
76
77 /* SIGTERM ������Ȥä��顢��λ���� */
78
sigterm_handler(int dummy)79 static void sigterm_handler(int dummy)
80 {
81 quasi88_quit();
82 z80main_cpu.icount = 0;
83 z80sub_cpu.icount = 0;
84 }
85
86 /*-------- ���������� -------- */
87
set_signal(void)88 void set_signal(void)
89 {
90 if (debug_mode) {
91 signal(SIGINT, sigint_handler);
92 signal(SIGTERM, sigterm_handler);
93 } else {
94 signal(SIGINT, sigterm_handler);
95 signal(SIGTERM, sigterm_handler);
96 }
97 }
98
99
100 /************************************************************************/
101 /* */
102 /************************************************************************/
103
104 #ifdef USE_MONITOR
105
106
107
108 enum MonitorJob
109 {
110 MONITOR_LINE_INPUT,
111
112 MONITOR_HELP,
113 MONITOR_MENU,
114 MONITOR_QUIT,
115
116 MONITOR_GO,
117 MONITOR_TRACE,
118 MONITOR_STEP,
119 MONITOR_STEPALL,
120 MONITOR_BREAK,
121
122 MONITOR_READ,
123 MONITOR_WRITE,
124 MONITOR_DUMP,
125 MONITOR_DUMPEXT,
126 MONITOR_FILL,
127 MONITOR_MOVE,
128 MONITOR_SEARCH,
129 MONITOR_IN,
130 MONITOR_OUT,
131 MONITOR_LOADMEM,
132 MONITOR_SAVEMEM,
133
134 MONITOR_RESET,
135 MONITOR_REG,
136 MONITOR_DISASM,
137
138 MONITOR_SET,
139 MONITOR_SHOW,
140 MONITOR_REDRAW,
141 MONITOR_RESIZE,
142 MONITOR_DRIVE,
143 MONITOR_FILE,
144
145 MONITOR_STATESAVE,
146 MONITOR_STATELOAD,
147 MONITOR_SNAPSHOT,
148 MONITOR_LOADFONT,
149 MONITOR_SAVEFONT,
150
151 MONITOR_MISC,
152
153 MONITOR_FBREAK,
154 MONITOR_TEXTSCR,
155 MONITOR_LOADBAS,
156 MONITOR_SAVEBAS,
157
158 MONITOR_TAPELOAD,
159 MONITOR_TAPESAVE,
160 MONITOR_PRINTER,
161 MONITOR_SERIALIN,
162 MONITOR_SERIALOUT,
163
164 EndofMONITOR
165 };
166
167
168
169 /****************************************************************/
170 /* �إ�ץ�å�����ɽ���ؿ� */
171 /****************************************************************/
help_help(void)172 static void help_help(void)
173 {
174 printf
175 (
176 " help [<cmd>]\n"
177 " print help\n"
178 " <cmd> ... command for help\n"
179 " [omit]... print short help for all commands.\n"
180 );
181 }
help_menu(void)182 static void help_menu(void)
183 {
184 printf
185 (
186 " menu\n"
187 " enter menu-mode.\n"
188 );
189 }
help_quit(void)190 static void help_quit(void)
191 {
192 printf
193 (
194 " quit\n"
195 " quit QUASI88.\n"
196 );
197 }
help_go(void)198 static void help_go(void)
199 {
200 printf
201 (
202 " go\n"
203 " execute MAIN and|or SUB program\n"
204 );
205 }
help_trace(void)206 static void help_trace(void)
207 {
208 printf
209 (
210 " trace [#<steps>|<steps>|change]\n"
211 " execute MAIN ane|or SUB program specityes times\n"
212 " [all omit] ... trace some steps (previous steps)\n"
213 " #<steps>, <steps> ... step counts of trace ( you can omit '#' )\n"
214 " change ... trace while change CPU job. ( main<->sub )\n"
215 " this is work under condition -cpu 0 or -cpu 1\n"
216 );
217 }
help_step(void)218 static void help_step(void)
219 {
220 printf
221 (
222 " step [call][jp][rep]\n"
223 " execute MAIN and|or SUB program 1 time\n"
224 " [all omit] ... execute 1 step\n"
225 " call ... not trace CALL instruction\n"
226 " jp ... not trace DJNZ instruction\n"
227 " rep ... not trace LD*R/CP*R/IN*R/OT*R instruction\n"
228 " CAUTION)\n"
229 " call/jp/rep are work under condition -cpu 0 or -cpu 1\n"
230 " call/jp/rep are use break-point #10.\n"
231 );
232 }
help_stepall(void)233 static void help_stepall(void)
234 {
235 printf
236 (
237 " S\n"
238 " mean 'step all' (see. step)\n"
239 );
240 }
help_break(void)241 static void help_break(void)
242 {
243 printf
244 (
245 " break [<cpu>] [<action>] <addr|port> [#<No>]\n"
246 " break [<cpu>] CLEAR [#<No>]\n"
247 " break\n"
248 " set break point\n"
249 " [all omit] ... show all break points\n"
250 " <cpu> ... CPU select MAIN|SUB\n"
251 " [omit]... select MAIN\n"
252 " <action> ... set action of conditon PC|READ|WRITE|IN|OUT or CLEAR\n"
253 " PC ... break if PC reach addr\n"
254 " READ ... break if data is read\n"
255 " WRITE ... break if data is written\n"
256 " IN ... break if data is input\n"
257 " OUT ... break if data is output\n"
258 " CLEAR ... clear all break point\n"
259 " [omit]... select PC\n"
260 " <addr|port> ... specify address or port\n"
261 " if <action> is CLEAR, this argument is invalid\n"
262 " #<No> ... number of break point. (#1..#10)\n"
263 " #0 ... all break point when <action> is CLEAR\n"
264 " [omit]... select #1\n"
265 " CAUTION).. #10 is used by system\n"
266 );
267 }
268
269
270
help_read(void)271 static void help_read(void)
272 {
273 printf
274 (
275 " read [<bank>] <addr>\n"
276 " read memory.\n"
277 " <bank> ... memory bank ROM|RAM|N|EXT0|EXT1|EXT2|EXT3|B|R|G|HIGH|SUB\n"
278 " [omit]... current memory bank of MAIN.\n"
279 " <addr> ... specify address\n");
280 }
help_write(void)281 static void help_write(void)
282 {
283 printf
284 (
285 " write [<bank>] <addr> <data>\n"
286 " write memory.\n"
287 " <bank> ... memory bank ROM|RAM|N|EXT0|EXT1|EXT2|EXT3|B|R|G|HIGH|SUB\n"
288 " [omit]... current memory bank of MAIN.\n"
289 " <addr> ... specify address\n"
290 " <data> ... write data\n"
291 );
292 }
help_dump(void)293 static void help_dump(void)
294 {
295 printf
296 (
297 " dump [<bank>] <start-addr> [<end-addr>]\n"
298 " dump [<bank>] <start-addr> [#<size>]\n"
299 " dump memory.\n"
300 " <bank> ... memory bank ROM|RAM|N|EXT0|EXT1|EXT2|EXT3|B|R|G|HIGH|SUB\n"
301 " [omit]... current memory bank of MAIN.\n"
302 " <start-addr> ... dump start address\n"
303 " <end-addr> ... dump end address\n"
304 " [omit]... <start-address>+256\n"
305 " #<size> ... dump size\n"
306 " [omit]... 256 byte\n"
307 );
308 }
help_dumpext(void)309 static void help_dumpext(void)
310 {
311 printf
312 (
313 " dumpext [<bank>] [#<board>] <start-addr> [<end-addr>]\n"
314 " dumpext [<bank>] [#<board>] <start-addr> [#<size>]\n"
315 " dump external ram memory.\n"
316 " <bank> ... memory bank EXT0|EXT1|EXT2|EXT3\n"
317 " [omit]... current memory bank of EXT0.\n"
318 " #<board> ... board number (1..16).\n"
319 " [omit]... board #1.\n"
320 " <start-addr> ... dump start address(0x0000..0x7fff)\n"
321 " <end-addr> ... dump end address(0x0000..0x7fff)\n"
322 " [omit]... <start-address>+256\n"
323 " #<size> ... dump size\n"
324 " [omit]... 256 byte\n"
325 );
326 }
help_fill(void)327 static void help_fill(void)
328 {
329 printf
330 (
331 " fill [<bank>] <start-addr> <end-addr> <value>\n"
332 " fill [<bank>] <start-addr> #<size> <value>\n"
333 " fill memory by specify value. \n"
334 " <bank> ... memory bank ROM|RAM|N|EXT0|EXT1|EXT2|EXT3|B|R|G|HIGH|SUB\n"
335 " [omit]... current memory bank of MAIN.\n"
336 " <start-addr> ... fill start address\n"
337 " <end-addr> ... fill end address\n"
338 " #<size> ... fill size\n"
339 " <value> ... fill value\n"
340 );
341 }
help_move(void)342 static void help_move(void)
343 {
344 printf
345 (
346 " move [<src-bank>] <src-addr> <end-addr> [<dist-bank>] <dist-addr>\n"
347 " move [<src-bank>] <src-addr> #<size> [<dist-bank>] <dist-addr>\n"
348 " move memory. \n"
349 " <src-bank> ... memory bank ROM|RAM|N|EXT0|EXT1|EXT2|EXT3|B|R|G|HIGH|SUB\n"
350 " [omit]... current memory bank of MAIN.\n"
351 " <src-addr> ... move source start address\n"
352 " <end-addr> ... move source end address\n"
353 " #<size> ... move size\n"
354 " <dist-bank> ... memory bank\n"
355 " [omit]... same as <src-bank>\n"
356 " <dist-addr> ... move distination address\n"
357 );
358 }
help_search(void)359 static void help_search(void)
360 {
361 printf
362 (
363 " search [<value> [[<bank>] <start-addr> <end-addr>]]\n"
364 " search memory. \n"
365 " <value> ... search value\n"
366 " <bank> ... memory bank ROM|RAM|N|EXT0|EXT1|EXT2|EXT3|B|R|G|HIGH|SUB\n"
367 " [omit]... current memory bank of MAIN.\n"
368 " <start-addr> ... search start address\n"
369 " <end-addr> ... search end address\n"
370 " [omit-all] ... search previous value\n"
371 );
372 }
help_in(void)373 static void help_in(void)
374 {
375 printf
376 (
377 " in [<cpu>] <port>\n"
378 " input I/O port.\n"
379 " <cpu> ... CPU select MAIN|SUB\n"
380 " [omit]... select MAIN\n"
381 " <port> ... in port address\n"
382 );
383 }
help_out(void)384 static void help_out(void)
385 {
386 printf
387 (
388 " out [<cpu>] <port> <data>\n"
389 " output I/O port.\n"
390 " <cpu> ... CPU select MAIN|SUB\n"
391 " [omit]... select MAIN\n"
392 " <port> ... out port address\n"
393 " <data> ... output data\n"
394 );
395 }
help_loadmem(void)396 static void help_loadmem(void)
397 {
398 printf
399 (
400 " loadmem <filename> <bank> <start-addr> [<end-addr>]\n"
401 " loadmem <filename> <bank> <start-addr> [#<size>]\n"
402 " load memory from binary file.\n"
403 " <filename> ... binary filename.\n"
404 " <bank> ... memory bank ROM|RAM|N|EXT0|EXT1|EXT2|EXT3|B|R|G|HIGH|SUB\n"
405 " <start-addr> ... load start addr\n"
406 " <end-addr> ... load end addr\n"
407 " #<size> ... load size\n"
408 " [omit] set filesize as binary size\n"
409 );
410 }
help_savemem(void)411 static void help_savemem(void)
412 {
413 printf
414 (
415 " savemem <filename> <bank> <start-addr> <end-addr>\n"
416 " savemem <filename> <bank> <start-addr> #<size>\n"
417 " save memory image to file.\n"
418 " <filename> ... filename.\n"
419 " <bank> ... memory bank ROM|RAM|N|EXT0|EXT1|EXT2|EXT3|B|R|G|HIGH|SUB\n"
420 " <start-addr> ... save start addr\n"
421 " <end-addr> ... save end addr\n"
422 " #<size> ... save size\n"
423 );
424 }
help_reset(void)425 static void help_reset(void)
426 {
427 printf
428 (
429 " reset [<basic-mode>] [<clock-mode>] [<sound-board>] [<dipsw>]\n"
430 " reset PC8800 (not execute)\n"
431 " <basic-mode> ... BASIC mode N|V1S|V1H|V2\n"
432 " [omit] select current BASIC mode\n"
433 " <clock-mode> ... CPU Clock 4MHZ|8MHZ\n"
434 " [omit] select current CLOCK mode\n"
435 " <sound-board> ... sound-board type SD|SD2\n"
436 " [omit] select current sound-board\n"
437 " <dipsw> ... dip-switch setting \n"
438 " [omit] select current dip-switch setting\n"
439 );
440 }
help_reg(void)441 static void help_reg(void)
442 {
443 printf
444 (
445 " reg [[<cpu>] [<name> <value>]]\n"
446 " show & set register.\n"
447 " [all omit] ... show all register (MAIN and|or SUB).\n"
448 " <cpu> ... CPU select MAIN|SUB\n"
449 " [omit]... select MAIN\n"
450 " <name> ... specity register name.\n"
451 " AF|BC|DE|HL|AF'|BC'|DE'|HL'|IX|IY|SP|PC|I|R|IFF|IM\n"
452 " <value> ... set value\n"
453 " [omit]... show value of register\n"
454 );
455 }
help_disasm(void)456 static void help_disasm(void)
457 {
458 printf
459 (
460 " disasm [[<cpu>] [<start-addr>][#<steps>]]\n"
461 " disassemble.\n"
462 " [all omit] ... disasmble 16 steps from MAIN CPU PC address.\n"
463 " <cpu> ... CPU select MAIN|SUB\n"
464 " [omit]... select MAIN\n"
465 " <start-addr> ... disassemble start address\n"
466 " [omit]... reg PC address\n"
467 " #<steps> ... disassemble steps\n"
468 " [omit]... 16 steps\n"
469 );
470 }
help_set(void)471 static void help_set(void)
472 {
473 printf
474 (
475 " set [[<variabe-name> [<value>]]]\n"
476 " show & set variables.\n"
477 " [all omit] ... show all variable.\n"
478 " <variabe-name> ... specify variable name.\n"
479 " <value> ... set value\n"
480 " [omit]... show value of variable\n"
481 );
482 }
help_show(void)483 static void help_show(void)
484 {
485 printf
486 (
487 " show [<variabe-name>]\n"
488 " show variables.\n"
489 " [all omit] ... show all variable.\n"
490 " <variabe-name> ... specify variable name.\n"
491 );
492 }
help_redraw(void)493 static void help_redraw(void)
494 {
495 printf
496 (
497 " redraw\n"
498 " redraw QUASI88 screen.\n"
499 );
500 }
help_resize(void)501 static void help_resize(void)
502 {
503 printf
504 (
505 " resize [<screen-size>]\n"
506 " resize screen.\n"
507 #ifdef SUPPORT_DOUBLE
508 " <screen_size> ... screen size FULL|HALF|DOUBLE|FULLSCREEN|WINDOW\n"
509 " [omit]... change screen size HALF,FULL,DOUBLE...\n"
510 #else
511 " <screen_size> ... screen size FULL|HALF|FULLSCREEN|WINDOW\n"
512 " [omit]... change screen size HALF<->FULL\n"
513 #endif
514 );
515 }
help_drive(void)516 static void help_drive(void)
517 {
518 printf
519 (
520 " drive\n"
521 " drive show\n"
522 " drive empty [<drive_no>]\n"
523 " drive eject [<drive_no>]\n"
524 " drive set <drive_no> <filename> [<image_no>]\n"
525 " Show drive information, Eject Disk, Set Disk.\n"
526 " drive [show] ... Show now drive information.\n"
527 " drive empty ... Set/Unset drive <drive_no> empty.\n"
528 " drive eject ... Eject disk from drive <drive_no>\n"
529 " <drive_no> omit, eject all disk.\n"
530 " drive set ... Eject disk and insert new disk\n"
531 " <drive_no> ... 1 | 2 mean DRIVE 1: | DRIVE 2:\n"
532 " <filename> ... if filename is '-' , disk not change\n"
533 " <image_no> ... image number (1..%d max)\n"
534 " <image_no> omit, set image number 1.\n"
535 , MAX_NR_IMAGE
536 );
537 }
help_file(void)538 static void help_file(void)
539 {
540 printf
541 (
542 " file show <filename>\n"
543 " file create <filename>\n"
544 " file protect <filename> <image_no>\n"
545 " file unprotect <filename> <image_no>\n"
546 " file format <filename> <image_no>\n"
547 " file unformat <filename> <image_no>\n"
548 " file rename <filename> <image_no> <image_name>\n"
549 " Disk image file utility.\n"
550 " file show ... Show file information.\n"
551 " file create ... Create / Append blank disk image in file.\n"
552 " file protect ... Set protect.\n"
553 " file unprotect ... Unset protect.\n"
554 " file format ... format image by N88DISK-BASIC DATA DISK format.\n"
555 " file unformat ... Unformat image.\n"
556 " file rename ... Rename disk image.\n"
557 " <filename> ... filename\n"
558 " <image_no> ... image number (1..%d max)\n"
559 " <image_name> ... image name (MAX 16chars)\n"
560 , MAX_NR_IMAGE
561 );
562 }
563
help_statesave(void)564 static void help_statesave(void)
565 {
566 printf
567 (
568 " statesave [<filename>]\n"
569 " statesave QUASI88\n"
570 " <filename> ... specify state-file filename.\n"
571 " omit, default filename\n"
572 );
573 }
574
help_stateload(void)575 static void help_stateload(void)
576 {
577 printf
578 (
579 " stateload [<filename>]\n"
580 " stateload QUASI88\n"
581 " <filename> ... specify state-file filename.\n"
582 " omit, default filename\n"
583 );
584 }
585
help_snapshot(void)586 static void help_snapshot(void)
587 {
588 printf
589 (
590 " snapshot [<format>]\n"
591 " save screen snapshot\n"
592 " <format> ... select format \"BMP\", \"PPM\", \"RAW\".\n"
593 " omit, current format\n"
594 );
595 }
596
help_loadfont(void)597 static void help_loadfont(void)
598 {
599 printf
600 (
601 " loadfont <filename> <format> <type>\n"
602 " load text-font file\n"
603 " <filename> ... specify text-font-file filename.\n"
604 " <format> ... select format\n"
605 " 0 ... ROM-image\n"
606 " 1 ... bitmap format (horizontal)\n"
607 " 2 ... bitmap format (vertical)\n"
608 " <type> ... select font kind\n"
609 " 0 ... PCG font\n"
610 " 1 ... Standard font\n"
611 " 2 ... 2nd font (usually hiragana-font)\n"
612 " 3 ... 3rd font (usually transparent-font)\n"
613 );
614 }
615
help_savefont(void)616 static void help_savefont(void)
617 {
618 printf
619 (
620 " savefont <filename> <format> <type>\n"
621 " save text-font file\n"
622 " <filename> ... specify text-font-file filename.\n"
623 " <format> ... select format\n"
624 " 0 ... ROM-image\n"
625 " 1 ... bitmap format (horizontal)\n"
626 " 2 ... bitmap format (vertical)\n"
627 " <type> ... select font kind\n"
628 " 0 ... PCG font\n"
629 " 1 ... Standard font\n"
630 " 2 ... 2nd font (usually hiragana-font)\n"
631 " 3 ... 3rd font (usually transparent-font)\n"
632 );
633 }
634
help_fbreak(void)635 static void help_fbreak(void)
636 {
637 printf
638 (
639 " fbreak [<action>] <drive> <track> [<sector>] [#<No>]\n"
640 " fbreak CLEAR [#<No>]\n"
641 " fbreak\n"
642 " set fdc break point\n"
643 " [all omit] ... show all break points\n"
644 " <action> ... set action of conditon READ|WRITE|DIAG or CLEAR\n"
645 " READ ... break if fdc command is read\n"
646 " WRITE ... break if fdc command is write\n"
647 " DIAG ... break if fdc command is diag\n"
648 " CLEAR ... clear all break point\n"
649 " [omit]... select READ\n"
650 " <drive> ... specify drive (1 or 2)\n"
651 " if <action> is CLEAR, this argument is invalid\n"
652 " <track> ... specify track (0...)\n"
653 " <sector> ... specify sector (1...)\n"
654 " [omit]... select all sector\n"
655 " #<No> ... number of break point. (#1..#10)\n"
656 " #0 ... all break point when <action> is CLEAR\n"
657 " [omit]... select #1\n"
658 );
659 }
660
help_textscr(void)661 static void help_textscr(void)
662 {
663 printf
664 (
665 " textscr [<char>]\n"
666 " print text screen in the console screen\n"
667 " <char> ... alternative character to unprintable one.\n"
668 " [omit] ... use 'X'\n"
669 );
670 }
671
help_loadbas(void)672 static void help_loadbas(void)
673 {
674 printf
675 (
676 " loadbas <filename> [<type>]\n"
677 " load basic list\n"
678 " <filename> ... filename of basic list.\n"
679 " <type> ... set type of basic list ASCII or BINARY\n"
680 " ASCII ... load as text list\n"
681 " BINARY ... load as intermediate code\n"
682 " [omit] ... select ASCII\n"
683 );
684 }
685
help_savebas(void)686 static void help_savebas(void)
687 {
688 printf
689 (
690 " savebas [<filename> [<type>]]\n"
691 " print or save basic list\n"
692 " <filename> ... filename of basic list.\n"
693 " <type> ... set type of basic list ASCII or BINARY\n"
694 " ASCII ... save as text list\n"
695 " BINARY ... save as intermediate code\n"
696 " [omit] ... select ASCII\n"
697 );
698 }
699
help_tapeload(void)700 static void help_tapeload(void)
701 {
702 printf
703 (
704 " tapeload <filename>\n"
705 " set tape-image-file as load\n"
706 " <filename> ... specify tape-image-file filename.\n"
707 " filename \"-\" mean \'unset image\'\n"
708 );
709 }
710
help_tapesave(void)711 static void help_tapesave(void)
712 {
713 printf
714 (
715 " tapesave <filename>\n"
716 " set tape-image-file as save\n"
717 " <filename> ... specify tape-image-file filename.\n"
718 " filename \"-\" mean \'unset image\'\n"
719 );
720 }
721
help_printer(void)722 static void help_printer(void)
723 {
724 printf
725 (
726 " printer <filename>\n"
727 " set printout-image-file\n"
728 " <filename> ... specify printout-image-file filename.\n"
729 " filename \"-\" mean \'unset image\'\n"
730 );
731 }
732
help_serialin(void)733 static void help_serialin(void)
734 {
735 printf
736 (
737 " serialin <filename>\n"
738 " set serial-in-image-file\n"
739 " <filename> ... specify serial-in-image-file filename.\n"
740 " filename \"-\" mean \'unset image\'\n"
741 );
742 }
743
help_serialout(void)744 static void help_serialout(void)
745 {
746 printf
747 (
748 " serialout <filename>\n"
749 " set serial-out-image-file\n"
750 " <filename> ... specify serial-out-image-file filename.\n"
751 " filename \"-\" mean \'unset image\'\n"
752 );
753 }
754
help_misc(void)755 static void help_misc(void)
756 {
757 printf
758 (
759 " misc ... this is for debug. don't mind!\n"
760 );
761 }
762
763
764 /****************************************************************/
765 /* ̿��μ���Ƚ��ơ��֥� */
766 /****************************************************************/
767 static struct {
768 int job;
769 char *cmd;
770 void (*help)(void);
771 char *help_mes;
772 } monitor_cmd[]=
773 {
774 { MONITOR_HELP, "help", help_help, "print help", },
775 { MONITOR_HELP, "?", help_help, " '' ", },
776 { MONITOR_MENU, "menu", help_menu, "enter menu-mode", },
777 { MONITOR_MENU, "m", help_menu, " '' ", },
778 { MONITOR_QUIT, "quit", help_quit, "quit quasi88", },
779 { MONITOR_QUIT, "q", help_quit, " '' ", },
780 { MONITOR_GO, "go", help_go, "exec emu", },
781 { MONITOR_GO, "g", help_go, " '' ", },
782 { MONITOR_TRACE, "trace", help_trace, "trace emu", },
783 { MONITOR_TRACE, "t", help_trace, " '' ", },
784 { MONITOR_STEP, "step", help_step, "step emu", },
785 { MONITOR_STEP, "s", help_step, " '' ", },
786 { MONITOR_STEPALL, "S", help_stepall, " '' ", },
787 { MONITOR_BREAK, "break", help_break, "set break point", },
788 { MONITOR_READ, "read", help_read, "read memory", },
789 { MONITOR_WRITE, "write", help_write, "write memory ", },
790 { MONITOR_DUMP, "dump", help_dump, "dump memory", },
791 { MONITOR_DUMPEXT, "dumpext", help_dumpext, "dump external ram memory", },
792 { MONITOR_FILL, "fill", help_fill, "fill memory", },
793 { MONITOR_MOVE, "move", help_move, "move memory", },
794 { MONITOR_SEARCH, "search", help_search, "search memory", },
795 { MONITOR_IN, "in", help_in, "input port", },
796 { MONITOR_OUT, "out", help_out, "output port", },
797 { MONITOR_LOADMEM, "loadmem", help_loadmem, "load memory from file", },
798 { MONITOR_SAVEMEM, "savemem", help_savemem, "save memory to file", },
799 { MONITOR_RESET, "reset", help_reset, "reset PC8800 system", },
800 { MONITOR_REG, "reg", help_reg, "show/set CPU register", },
801 { MONITOR_DISASM, "disasm", help_disasm, "disassemble", },
802 { MONITOR_SET, "set", help_set, "show variable", },
803 { MONITOR_SHOW, "show", help_show, "show/set variable", },
804 { MONITOR_REDRAW, "redraw", help_redraw, "redraw screen", },
805 { MONITOR_RESIZE, "resize", help_resize, "resize screen", },
806 { MONITOR_DRIVE, "drive", help_drive, "operate disk drive", },
807 { MONITOR_FILE, "file", help_file, "disk image file utility", },
808 { MONITOR_STATESAVE,"statesave",help_statesave,"state-save QUASI88", },
809 { MONITOR_STATELOAD,"stateload",help_stateload,"state-load QUASI88", },
810 { MONITOR_SNAPSHOT, "snapshot", help_snapshot, "save screen snapshot", },
811 { MONITOR_LOADFONT, "loadfont", help_loadfont, "load text-font file", },
812 { MONITOR_SAVEFONT, "savefont", help_savefont, "save text-font file", },
813 { MONITOR_MISC, "misc", help_misc, "for debug", },
814 { MONITOR_FBREAK, "fbreak", help_fbreak, "set fdc break point", },
815 { MONITOR_TEXTSCR, "textscr", help_textscr, "print text screen", },
816 { MONITOR_LOADBAS, "loadbas", help_loadbas, "load basic list", },
817 { MONITOR_SAVEBAS, "savebas", help_savebas, "save basic list", },
818 { MONITOR_TAPELOAD, "tapeload", help_tapeload, "set tape-image as load", },
819 { MONITOR_TAPESAVE, "tapesave", help_tapesave, "set tape-image as save", },
820 { MONITOR_PRINTER, "printer", help_printer, "set printout-image-file", },
821 { MONITOR_SERIALIN, "serialin", help_serialin, "set serial-in-image-file", },
822 { MONITOR_SERIALOUT,"serialout",help_serialout,"set serial-out-image-file",},
823 };
824
825
826
827 /****************************************************************/
828 /* �����μ���Ƚ��ơ��֥� */
829 /****************************************************************/
830
831 enum ArgvType {
832 ARGV_END = 0x0000000,
833 ARGV_STR = 0x0000001, /* strings */
834 ARGV_PORT = 0x0000002, /* 0��0xff */
835 ARGV_ADDR = 0x0000004, /* 0��0xffff */
836 ARGV_NUM = 0x0000008, /* 0��0x7fffffff */
837 ARGV_INT = 0x0000010, /* -0x7fffffff��0x7fffffff */
838 ARGV_DRV = 0x0000020, /* 1��2 */
839 ARGV_IMG = 0x0000040, /* 1��MAX_NR_IMAGE */
840 ARGV_SIZE = 0x0000080, /* #1��#0x7fffffff */
841 ARGV_CPU = 0x0000100, /* CpuName */
842 ARGV_BANK = 0x0000200, /* MemoryName */
843 ARGV_REG = 0x0000400, /* RegisterName */
844 ARGV_BREAK = 0x0000800, /* BreakAction */
845 ARGV_BASMODE = 0x0001000, /* ResetCommand */
846 ARGV_CKMODE = 0x0002000, /* ResetCommand */
847 ARGV_SDMODE = 0x0004000, /* ResetCommand */
848 ARGV_CHANGE = 0x0008000, /* TraceCommand */
849 ARGV_STEP = 0x0010000, /* StepCommand */
850 ARGV_ALL = 0x0020000, /* RegCommand */
851 ARGV_RESIZE = 0x0040000, /* ResizeCommand */
852 ARGV_FILE = 0x0080000, /* FileCommand */
853 ARGV_DRIVE = 0x0100000, /* DriveCommand */
854 ARGV_FBREAK = 0x0200000, /* FBreakAction */
855 ARGV_BASIC = 0x0400000, /* BasicCodeType */
856 ARGV_SNAPSHOT= 0x0800000, /* SnapshotFormatType */
857
858 EndofArgvType
859 };
860
861 enum ArgvName {
862
863 ARG_MAIN, /* <cpu> */
864 ARG_SUB,
865
866 /*ARG_MAIN,*/ /* <bank> */
867 ARG_ROM, ARG_RAM, ARG_N, ARG_HIGH,
868 ARG_EXT0, ARG_EXT1, ARG_EXT2, ARG_EXT3,
869 ARG_B, ARG_R, ARG_G, ARG_PCG,
870 /*ARG_SUB*/
871
872 ARG_AF, ARG_BC, ARG_DE, ARG_HL, /* <reg> */
873 ARG_IX, ARG_IY, ARG_SP, ARG_PC,
874 ARG_AF1, ARG_BC1, ARG_DE1, ARG_HL1,
875 ARG_I, /*ARG_R,*/
876 ARG_IFF, ARG_IM, ARG_HALT,
877
878 /*ARG_PC,*/ ARG_READ, ARG_WRITE, ARG_IN, /* <action>*/
879 ARG_OUT, ARG_DIAG, ARG_CLEAR,
880
881 ARG_V2, ARG_V1H, ARG_V1S, /*ARG_N,*/ /* <mode> */
882 ARG_8MHZ, ARG_4MHZ, ARG_SD, ARG_SD2,
883
884 ARG_CHANGE, /* trace change */
885
886 /*ARG_ALL*/
887 ARG_CALL, ARG_JP, ARG_REP, /* step <cmd> */
888
889 ARG_ALL, /* reg all */
890
891 ARG_FULL, ARG_HALF, ARG_DOUBLE, /* resize <arg> */
892 ARG_FULLSCREEN,ARG_WINDOW,
893
894 ARG_SHOW, ARG_EJECT, /* drive <cmd> */
895 ARG_EMPTY, ARG_SET,
896
897 /*ARG_SHOW,*/ /* file <cmd> */
898 ARG_CREATE, ARG_RENAME,
899 ARG_PROTECT, ARG_UNPROTECT,
900 ARG_FORMAT, ARG_UNFORMAT,
901
902 ARG_BINARY, ARG_ASCII, /* savebas <type> */
903
904 ARG_BMP, ARG_PPM, ARG_RAW, /* snapshot <fmt> */
905
906 EndofArgName
907 };
908
909
910 static struct {
911 char *str;
912 int type;
913 int val;
914 } monitor_argv[]=
915 {
916 { "MAIN", ARGV_CPU, ARG_MAIN, }, /* <cpu> */
917 { "SUB", ARGV_CPU, ARG_SUB, },
918
919 { "MAIN", ARGV_BANK, ARG_MAIN, }, /* <bank> */
920 { "ROM", ARGV_BANK, ARG_ROM, },
921 { "RAM", ARGV_BANK, ARG_RAM, },
922 { "N", ARGV_BANK, ARG_N, },
923 { "HIGH", ARGV_BANK, ARG_HIGH, },
924 { "EXT0", ARGV_BANK, ARG_EXT0, },
925 { "EXT1", ARGV_BANK, ARG_EXT1, },
926 { "EXT2", ARGV_BANK, ARG_EXT2, },
927 { "EXT3", ARGV_BANK, ARG_EXT3, },
928 { "B", ARGV_BANK, ARG_B, },
929 { "R", ARGV_BANK, ARG_R, },
930 { "G", ARGV_BANK, ARG_G, },
931 { "SUB", ARGV_BANK, ARG_SUB, },
932 { "PCG", ARGV_BANK, ARG_PCG, },
933
934 { "AF", ARGV_REG, ARG_AF, }, /* <reg> */
935 { "BC", ARGV_REG, ARG_BC, },
936 { "DE", ARGV_REG, ARG_DE, },
937 { "HL", ARGV_REG, ARG_HL, },
938 { "IX", ARGV_REG, ARG_IX, },
939 { "IY", ARGV_REG, ARG_IY, },
940 { "SP", ARGV_REG, ARG_SP, },
941 { "PC", ARGV_REG, ARG_PC, },
942 { "AF'", ARGV_REG, ARG_AF1, },
943 { "BC'", ARGV_REG, ARG_BC1, },
944 { "DE'", ARGV_REG, ARG_DE1, },
945 { "HL'", ARGV_REG, ARG_HL1, },
946 { "I", ARGV_REG, ARG_I, },
947 { "R", ARGV_REG, ARG_R, },
948 { "IFF", ARGV_REG, ARG_IFF, },
949 { "IM", ARGV_REG, ARG_IM, },
950 { "HALT", ARGV_REG, ARG_HALT, },
951
952 { "PC", ARGV_BREAK, ARG_PC, }, /*<action>*/
953 { "READ", ARGV_BREAK, ARG_READ, },
954 { "WRITE", ARGV_BREAK, ARG_WRITE, },
955 { "IN", ARGV_BREAK, ARG_IN, },
956 { "OUT", ARGV_BREAK, ARG_OUT, },
957 { "CLEAR", ARGV_BREAK, ARG_CLEAR, },
958
959 { "READ", ARGV_FBREAK, ARG_READ, }, /*<action>*/
960 { "WRITE", ARGV_FBREAK, ARG_WRITE, },
961 { "DIAG", ARGV_FBREAK, ARG_DIAG, },
962 { "CLEAR", ARGV_FBREAK, ARG_CLEAR, },
963
964 { "V2", ARGV_BASMODE, ARG_V2, }, /* <basic-mode> */
965 { "V1H", ARGV_BASMODE, ARG_V1H, },
966 { "V1S", ARGV_BASMODE, ARG_V1S, },
967 { "N", ARGV_BASMODE, ARG_N, },
968 { "8MHZ", ARGV_CKMODE, ARG_8MHZ, }, /* <clock-mode> */
969 { "4MHZ", ARGV_CKMODE, ARG_4MHZ, },
970 { "SD", ARGV_SDMODE, ARG_SD, }, /* <sound-board> */
971 { "SD2", ARGV_SDMODE, ARG_SD2, },
972
973 { "CHANGE", ARGV_CHANGE, ARG_CHANGE, }, /* trace */
974
975 { "CALL", ARGV_STEP, ARG_CALL, }, /* step */
976 { "JP", ARGV_STEP, ARG_JP, },
977 { "REP", ARGV_STEP, ARG_REP, },
978 { "ALL", ARGV_STEP, ARG_ALL, },
979
980 { "ALL", ARGV_ALL, ARG_ALL, }, /* reg */
981
982 { "FULL", ARGV_RESIZE, ARG_FULL, }, /* resize*/
983 { "HALF", ARGV_RESIZE, ARG_HALF, },
984 #ifdef SUPPORT_DOUBLE
985 { "DOUBLE", ARGV_RESIZE, ARG_DOUBLE, },
986 #endif
987 { "FULLSCREEN", ARGV_RESIZE, ARG_FULLSCREEN, },
988 { "WINDOW", ARGV_RESIZE, ARG_WINDOW, },
989
990 { "SHOW", ARGV_DRIVE, ARG_SHOW, }, /* drive */
991 { "EJECT", ARGV_DRIVE, ARG_EJECT, },
992 { "EMPTY", ARGV_DRIVE, ARG_EMPTY, },
993 { "SET", ARGV_DRIVE, ARG_SET, },
994
995 { "SHOW", ARGV_FILE, ARG_SHOW, }, /* file */
996 { "CREATE", ARGV_FILE, ARG_CREATE, },
997 { "RENAME", ARGV_FILE, ARG_RENAME, },
998 { "PROTECT", ARGV_FILE, ARG_PROTECT, },
999 { "UNPROTECT", ARGV_FILE, ARG_UNPROTECT, },
1000 { "FORMAT", ARGV_FILE, ARG_FORMAT, },
1001 { "UNFORMAT", ARGV_FILE, ARG_UNFORMAT, },
1002
1003 { "BINARY", ARGV_BASIC, ARG_BINARY, }, /*savebas*/
1004 { "ASCII", ARGV_BASIC, ARG_ASCII, },
1005
1006 { "BMP", ARGV_SNAPSHOT, ARG_BMP, }, /*snapshot*/
1007 { "PPM", ARGV_SNAPSHOT, ARG_PPM, },
1008 { "RAW", ARGV_SNAPSHOT, ARG_RAW, },
1009 };
1010
1011
1012
1013 enum SetType
1014 {
1015 MTYPE_NEWLINE,
1016 MTYPE_INT, MTYPE_BYTE, MTYPE_WORD, MTYPE_DOUBLE,
1017 MTYPE_INT_C, MTYPE_BYTE_C, MTYPE_WORD_C, MTYPE_DOUBLE_C,
1018 MTYPE_KEY, MTYPE_PALETTE, MTYPE_CRTC, MTYPE_PIO,
1019 MTYPE_MEM, MTYPE_FONT, MTYPE_FRAMESKIP,MTYPE_INTERLACE,
1020 MTYPE_INTERP, MTYPE_CLOCK, MTYPE_BEEP,
1021 MTYPE_VOLUME, MTYPE_FMMIXER, MTYPE_PSGMIXER, MTYPE_BEEPMIXER,
1022 MTYPE_RHYTHMMIXER, MTYPE_ADPCMMIXER, MTYPE_FMGENMIXER,
1023 MTYPE_SAMPLEMIXER, MTYPE_MIXER,
1024 EndofTYPE
1025 };
1026 static struct {
1027 char *var_name;
1028 char *port_mes;
1029 int var_type;
1030 void *var_ptr;
1031 } monitor_variable[]=
1032 {
1033 { "boot_dipsw", "(boot:3031)", MTYPE_INT_C, &boot_dipsw, },
1034 { "boot_from_rom", "(boot:40>>3)", MTYPE_INT_C, &boot_from_rom, },
1035 { "boot_clock_4mhz", "(boot:6E>>7)", MTYPE_INT_C, &boot_clock_4mhz, },
1036 { "boot_basic", "(boot:3031)", MTYPE_INT_C, &boot_basic, },
1037 { "sound_board", "(-sd/-sd2)", MTYPE_INT_C, &sound_board, },
1038 { "use_extram", "(-extram)", MTYPE_INT_C, &use_extram, },
1039 { "use_jisho_rom", "(-jisho)", MTYPE_INT_C, &use_jisho_rom, },
1040 { "", "", MTYPE_NEWLINE, NULL, },
1041
1042 { "sys_ctrl", "(OUT:30)", MTYPE_BYTE_C, &sys_ctrl, },
1043 { "grph_ctrl", "(OUT:31)", MTYPE_BYTE_C, &grph_ctrl, },
1044 { "misc_ctrl", "(I/O:32)", MTYPE_BYTE_C, &misc_ctrl, },
1045 { "ALU1_ctrl", "(OUT:34)", MTYPE_BYTE, &ALU1_ctrl, },
1046 { "ALU2_ctrl", "(OUT:35)", MTYPE_BYTE_C, &ALU2_ctrl, },
1047 { "ctrl_signal", "(OUT:40)", MTYPE_BYTE_C, &ctrl_signal, },
1048 { "grph_pile", "(OUT:53)", MTYPE_BYTE_C, &grph_pile, },
1049 { "intr_level", "(OUT:E4&07)", MTYPE_INT_C, &intr_level, },
1050 { "intr_priority", "(OUT:E4&08)", MTYPE_INT_C, &intr_priority, },
1051 { "intr_sio_enable", "(OUT:E6&04)", MTYPE_INT_C, &intr_sio_enable, },
1052 { "intr_vsync_enable", "(OUT:E6&02)", MTYPE_INT_C, &intr_vsync_enable, },
1053 { "intr_rtc_enable", "(OUT:E6&01)", MTYPE_INT_C, &intr_rtc_enable, },
1054 { "intr_sound_enable", "(IO:~32AA&80)",MTYPE_INT_C, &intr_sound_enable, },
1055 { "sound_ENABLE_A", "(sd[27])", MTYPE_INT, &sound_ENABLE_A, },
1056 { "sound_ENABLE_B", "(sd[27])", MTYPE_INT, &sound_ENABLE_B, },
1057 { "sound_LOAD_A", "(sd[27])", MTYPE_INT, &sound_LOAD_A, },
1058 { "sound_LOAD_B", "(sd[27])", MTYPE_INT, &sound_LOAD_B, },
1059 { "sound_FLAG_A", "(IN:44)", MTYPE_INT, &sound_FLAG_A, },
1060 { "sound_FLAG_B", "(IN:44)", MTYPE_INT, &sound_FLAG_B, },
1061 { "sound_TIMER_A", "(sd[24]-[25])",MTYPE_INT, &sound_TIMER_A, },
1062 { "sound_TIMER_B", "(sd[26])", MTYPE_INT, &sound_TIMER_B, },
1063 { "sound_prescaler", "(sd[2D]-[2F])",MTYPE_INT, &sound_prescaler, },
1064 { "sound_reg[27]", "(sd[27])", MTYPE_BYTE, &sound_reg[0x27], },
1065 { "sound2_EN_EOS", "(sd[29])", MTYPE_INT, &sound2_EN_EOS, },
1066 { "sound2_EN_BRDY", "(sd[29])", MTYPE_INT, &sound2_EN_BRDY, },
1067 { "sound2_EN_ZERO", "(sd[29])", MTYPE_INT, &sound2_EN_ZERO, },
1068 { "use_cmdsing", "", MTYPE_BEEP, &use_cmdsing, },
1069 { "", "", MTYPE_NEWLINE, NULL, },
1070 { "RS232C_flag", "", MTYPE_INT, &RS232C_flag, },
1071 { "VSYNC_flag", "", MTYPE_INT, &VSYNC_flag, },
1072 { "ctrl_vrtc", "", MTYPE_INT, &ctrl_vrtc, },
1073 { "RTC_flag", "", MTYPE_INT, &RTC_flag, },
1074 { "SOUND_flag", "", MTYPE_INT, &SOUND_flag, },
1075 { "", "", MTYPE_NEWLINE, NULL, },
1076
1077 { "mem", "", MTYPE_MEM, NULL, },
1078 { "", "", MTYPE_NEWLINE, NULL, },
1079 { "key", "(IN:00..0F)", MTYPE_KEY, NULL, },
1080 { "", "", MTYPE_NEWLINE, NULL, },
1081 { "palette", "(OUT:5254..5B)",MTYPE_PALETTE, NULL, },
1082 { "", "", MTYPE_NEWLINE, NULL, },
1083 { "crtc", "", MTYPE_CRTC, NULL, },
1084 { "", "", MTYPE_NEWLINE, NULL, },
1085 { "pio", "(IO:FC..FF)", MTYPE_PIO, NULL, },
1086 { "", "", MTYPE_NEWLINE, NULL, },
1087
1088 #ifdef USE_SOUND
1089 { "volume", "(-vol)", MTYPE_VOLUME, NULL, },
1090 { "fm-mixer", "(-fmvol)", MTYPE_FMMIXER, NULL, },
1091 { "psg-mixer", "(-psgvol)", MTYPE_PSGMIXER, NULL, },
1092 { "beep-mixer", "(-beepvol)", MTYPE_BEEPMIXER, NULL, },
1093 { "rhythm-mixer", "(-rhythmvol)", MTYPE_RHYTHMMIXER, NULL, },
1094 { "adpcm-mixer", "(-adpcmvol)", MTYPE_ADPCMMIXER, NULL, },
1095 #ifdef USE_FMGEN
1096 { "fmgen-mixer", "(-fmgenvol)", MTYPE_FMGENMIXER, NULL, },
1097 #endif
1098 { "sample-mixer", "(-samplevol)", MTYPE_SAMPLEMIXER, NULL, },
1099 { "", "", MTYPE_MIXER, NULL, },
1100 { "", "", MTYPE_NEWLINE, NULL, },
1101 #endif
1102
1103 { "cpu_timing", "(-cpu)", MTYPE_INT, &cpu_timing, },
1104 { "select_main_cpu", "", MTYPE_INT, &select_main_cpu, },
1105 { "dual_cpu_count", "", MTYPE_INT, &dual_cpu_count, },
1106 { "CPU_1_COUNT", "", MTYPE_INT, &CPU_1_COUNT, },
1107 { "cpu_slice_us", "(-cpu2us)", MTYPE_INT, &cpu_slice_us, },
1108 { "calendar_stop", "(-timestop)", MTYPE_INT, &calendar_stop, },
1109 { "cmt_speed", "(-cmt_speed)", MTYPE_INT, &cmt_speed, },
1110 { "cmt_intr", "(-cmt_intr)", MTYPE_INT, &cmt_intr, },
1111 { "cmt_wait", "(-cmt_wait)", MTYPE_INT, &cmt_wait, },
1112 { "highspeed_mode", "(-hsbasic)", MTYPE_INT, &highspeed_mode, },
1113 { "monitor_15k", "(-15k)", MTYPE_INT, &monitor_15k, },
1114 { "use_pcg", "(-pcg)", MTYPE_FONT, &use_pcg, },
1115 { "font_type", "", MTYPE_FONT, &font_type, },
1116 { "memory_wait", "(-mem_wait)", MTYPE_INT, &memory_wait, },
1117 { "sub_load_rate", "(-subload)", MTYPE_INT, &sub_load_rate, },
1118 { "disk_exchange", "(-exchange)", MTYPE_INT, &disk_exchange, },
1119 { "fdc_debug_mode", "(-fdcdebug)", MTYPE_INT, &fdc_debug_mode, },
1120 { "fdc_ignore_readonly","(-ignore_ro)", MTYPE_INT, &fdc_ignore_readonly},
1121 { "fdc_wait", "(-fdc_wait)", MTYPE_INT, &fdc_wait, },
1122 { "frameskip_rate", "(-frameskip)", MTYPE_FRAMESKIP,&frameskip_rate, },
1123 { "monitor_analog", "(-analog)", MTYPE_INT, &monitor_analog, },
1124 { "use_auto_skip", "(-autoskip)", MTYPE_INT, &use_auto_skip, },
1125 { "use_interlace", "(-interlace)", MTYPE_INTERLACE,&use_interlace, },
1126 { "use_half_interp", "(-interp)", MTYPE_INTERP, &use_half_interp, },
1127 { "mon_aspect", "(-aspect)", MTYPE_DOUBLE, &mon_aspect, },
1128 { "hide_mouse", "(-hide_mouse)",MTYPE_INT, &hide_mouse, },
1129 { "grab_mouse", "(-grab_mouse)",MTYPE_INT, &grab_mouse, },
1130 { "mouse_mode", "(-mouse)", MTYPE_INT, &mouse_mode, },
1131 { "mouse_swap_button", "(-mouseswap)", MTYPE_INT, &mouse_swap_button, },
1132 { "mouse_sensitivity", "(-mousespeed)",MTYPE_INT, &mouse_sensitivity, },
1133 { "joy_key_mode", "(-joykey)", MTYPE_INT, &joy_key_mode, },
1134 { "joy_swap_button", "(-joyswap)", MTYPE_INT, &joy_swap_button, },
1135 { "joy2_key_mode", "", MTYPE_INT, &joy2_key_mode, },
1136 { "joy2_swap_button", "", MTYPE_INT, &joy2_swap_button, },
1137 { "tenkey_emu", "(-tenkey)", MTYPE_INT, &tenkey_emu, },
1138 { "numlock_emu", "(-numlock)", MTYPE_INT, &numlock_emu, },
1139 { "function_f[1]", "", MTYPE_INT, &function_f[1], },
1140 { "function_f[2]", "", MTYPE_INT, &function_f[2], },
1141 { "function_f[3]", "", MTYPE_INT, &function_f[3], },
1142 { "function_f[4]", "", MTYPE_INT, &function_f[4], },
1143 { "function_f[5]", "", MTYPE_INT, &function_f[5], },
1144 { "function_f[6]", "(-f6)", MTYPE_INT, &function_f[6], },
1145 { "function_f[7]", "(-f7)", MTYPE_INT, &function_f[7], },
1146 { "function_f[8]", "(-f8)", MTYPE_INT, &function_f[8], },
1147 { "function_f[9]", "(-f9)", MTYPE_INT, &function_f[9], },
1148 { "function_f[10]", "(-f10)", MTYPE_INT, &function_f[10], },
1149 { "function_f[11]", "", MTYPE_INT, &function_f[11], },
1150 { "function_f[12]", "", MTYPE_INT, &function_f[12], },
1151 { "function_f[13]", "", MTYPE_INT, &function_f[13], },
1152 { "function_f[14]", "", MTYPE_INT, &function_f[14], },
1153 { "function_f[15]", "", MTYPE_INT, &function_f[15], },
1154 { "function_f[16]", "", MTYPE_INT, &function_f[16], },
1155 { "function_f[17]", "", MTYPE_INT, &function_f[17], },
1156 { "function_f[18]", "", MTYPE_INT, &function_f[18], },
1157 { "function_f[19]", "", MTYPE_INT, &function_f[19], },
1158 { "function_f[20]", "", MTYPE_INT, &function_f[20], },
1159 { "romaji_type", "(-romaji)", MTYPE_INT, &romaji_type, },
1160 { "need_focus", "(-focus)", MTYPE_INT, &need_focus, },
1161 { "cpu_clock_mhz", "(-clock)", MTYPE_CLOCK, &cpu_clock_mhz, },
1162 { "sound_clock_mhz", "(-soundclock)",MTYPE_CLOCK, &sound_clock_mhz, },
1163 { "vsync_freq_hz", "(-vsync)", MTYPE_CLOCK, &vsync_freq_hz, },
1164 { "wait_rate", "(-speed)", MTYPE_INT, &wait_rate, },
1165 { "wait_by_sleep", "(-sleep)", MTYPE_INT, &wait_by_sleep, },
1166 { "no_wait", "(-nowait)", MTYPE_INT, &no_wait, },
1167 /*{ "boost", "(-boost)", MTYPE_BOOST, &boost, },*/
1168 /*{ "wait_sleep_min_us", "(-sleepparm)", MTYPE_INT, &wait_sleep_min_us, },*/
1169 { "status_imagename", "(-statusimage)",MTYPE_INT, &status_imagename, },
1170 { "menu_lang", "(-english)", MTYPE_INT, &menu_lang, },
1171 { "menu_readonly", "(-ro)", MTYPE_INT, &menu_readonly, },
1172 { "menu_swapdrv", "(-swapdrv)", MTYPE_INT, &menu_swapdrv, },
1173 { "file_coding", "(-euc/-sjis)", MTYPE_INT, &file_coding, },
1174 { "filename_synchronize","", MTYPE_INT, &filename_synchronize},
1175 { "verbose_proc", "(-verbose&01)",MTYPE_INT, &verbose_proc, },
1176 { "verbose_z80", "(-verbose&02)",MTYPE_INT, &verbose_z80, },
1177 { "verbose_io", "(-verbose&04)",MTYPE_INT, &verbose_io, },
1178 { "verbose_pio", "(-verbose&08)",MTYPE_INT, &verbose_pio, },
1179 { "verbose_fdc", "(-verbose&10)",MTYPE_INT, &verbose_fdc, },
1180 { "verbose_wait", "(-verbose&20)",MTYPE_INT, &verbose_wait, },
1181 { "verbose_suspend", "(-verbose&40)",MTYPE_INT, &verbose_suspend, },
1182 { "verbose_snd", "(-verbose&80)",MTYPE_INT, &verbose_snd, },
1183 { "", "", MTYPE_NEWLINE, NULL, },
1184
1185 #ifdef PROFILER
1186 { "debug_profiler", "for debug", MTYPE_INT, &debug_profiler, },
1187 #endif
1188 #ifdef DEBUGLOG
1189 { "pio_debug", "for debug", MTYPE_INT, &pio_debug, },
1190 { "fdc_debug", "for debug", MTYPE_INT, &fdc_debug, },
1191 { "main_debug", "for debug", MTYPE_INT, &main_debug, },
1192 { "sub_debug", "for debug", MTYPE_INT, &sub_debug, },
1193 #endif
1194
1195 };
1196
1197 static struct {
1198 char *block_name;
1199 int start;
1200 int end;
1201 } monitor_variable_block[] =
1202 {
1203 { "boot", 0, 0 },
1204 { "main", 1, 2 },
1205 { "intr", 2, 2 },
1206 #ifdef USE_SOUND
1207 { "vol", 8, 8 },
1208 { "emu", 9, 10 },
1209 #else
1210 { "emu", 8, 9 },
1211 #endif
1212 };
1213
1214
1215
1216 /*--------------------------------------------------------------*/
1217 /* ���� READ/WRITE �ؿ� */
1218 /*--------------------------------------------------------------*/
peek_memory(int bank,word addr)1219 static byte peek_memory( int bank, word addr )
1220 {
1221 int verbose_save;
1222 byte wk;
1223
1224 switch( bank ){
1225 case ARG_MAIN:
1226 return main_mem_read(addr);
1227 case ARG_ROM:
1228 if( addr<0x8000 ) return main_rom[addr];
1229 else return main_mem_read(addr);
1230 case ARG_RAM:
1231 if( 0xf000<=addr && high_mode ) return main_high_ram[addr-0xf000];
1232 else return main_ram[addr];
1233 case ARG_N:
1234 if( addr<0x8000 ) return main_rom_n[addr];
1235 else return main_mem_read(addr);
1236 case ARG_EXT0:
1237 if( 0x6000<=addr && addr<0x8000 ) return main_rom_ext[0][addr-0x6000];
1238 else return main_mem_read(addr);
1239 case ARG_EXT1:
1240 if( 0x6000<=addr && addr<0x8000 ) return main_rom_ext[1][addr-0x6000];
1241 else return main_mem_read(addr);
1242 case ARG_EXT2:
1243 if( 0x6000<=addr && addr<0x8000 ) return main_rom_ext[2][addr-0x6000];
1244 else return main_mem_read(addr);
1245 case ARG_EXT3:
1246 if( 0x6000<=addr && addr<0x8000 ) return main_rom_ext[3][addr-0x6000];
1247 else return main_mem_read(addr);
1248 case ARG_B:
1249 if( 0xc000<=addr ) return main_vram[addr-0xc000][0];
1250 else return main_mem_read(addr);
1251 case ARG_R:
1252 if( 0xc000<=addr ) return main_vram[addr-0xc000][1];
1253 else return main_mem_read(addr);
1254 case ARG_G:
1255 if( 0xc000<=addr ) return main_vram[addr-0xc000][2];
1256 else return main_mem_read(addr);
1257 case ARG_HIGH:
1258 if( 0xf000<=addr ){
1259 if( high_mode ) return main_ram[addr];
1260 else return main_high_ram[addr-0xf000];
1261 }else return main_mem_read(addr);
1262 case ARG_SUB:
1263 verbose_save = verbose_io;
1264 verbose_io = 0;
1265 wk = sub_mem_read(addr);
1266 verbose_io = verbose_save;
1267 return wk;
1268 case ARG_PCG:
1269 if( addr<8*256*2 ) return font_pcg[addr];
1270 else return 0xff;
1271 }
1272 return 0xff;
1273 }
poke_memory(int bank,word addr,byte data)1274 static void poke_memory( int bank, word addr, byte data )
1275 {
1276 int verbose_save;
1277
1278 switch( bank ){
1279 case ARG_MAIN:
1280 main_mem_write(addr,data);
1281 return;
1282 case ARG_ROM:
1283 if( addr<0x8000 ) main_rom[addr] = data;
1284 else main_mem_write(addr,data);
1285 return;
1286 case ARG_RAM:
1287 if( 0xf000<=addr && high_mode ) main_high_ram[addr-0xf000] = data;
1288 else main_ram[addr] = data;
1289 return;
1290 case ARG_N:
1291 if( addr<0x8000 ) main_rom_n[addr] = data;
1292 else main_mem_write(addr,data);
1293 return;
1294 case ARG_EXT0:
1295 if( 0x6000<=addr && addr<0x8000 ) main_rom_ext[0][addr-0x6000] = data;
1296 else main_mem_write(addr,data);
1297 return;
1298 case ARG_EXT1:
1299 if( 0x6000<=addr && addr<0x8000 ) main_rom_ext[1][addr-0x6000] = data;
1300 else main_mem_write(addr,data);
1301 return;
1302 case ARG_EXT2:
1303 if( 0x6000<=addr && addr<0x8000 ) main_rom_ext[2][addr-0x6000] = data;
1304 else main_mem_write(addr,data);
1305 return;
1306 case ARG_EXT3:
1307 if( 0x6000<=addr && addr<0x8000 ) main_rom_ext[3][addr-0x6000] = data;
1308 else main_mem_write(addr,data);
1309 return;
1310 case ARG_B:
1311 if( 0xc000<=addr ) main_vram[addr-0xc000][0] = data;
1312 else main_mem_write(addr,data);
1313 return;
1314 case ARG_R:
1315 if( 0xc000<=addr ) main_vram[addr-0xc000][1] = data;
1316 else main_mem_write(addr,data);
1317 return;
1318 case ARG_G:
1319 if( 0xc000<=addr ) main_vram[addr-0xc000][2] = data;
1320 else main_mem_write(addr,data);
1321 return;
1322 case ARG_HIGH:
1323 if( 0xf000<=addr ){
1324 if( high_mode ) main_ram[addr] = data;
1325 else main_high_ram[addr-0xf000] = data;
1326 }else main_mem_write(addr,data);
1327 return;
1328 case ARG_SUB:
1329 verbose_save = verbose_io;
1330 verbose_io = 0;
1331 sub_mem_write(addr,data);
1332 verbose_io = verbose_save;
1333 return;
1334 case ARG_PCG:
1335 if( addr<8*256*2 ) font_pcg[addr] = data;
1336 return;
1337 }
1338 }
1339
1340
1341
1342
1343
1344
1345
1346
1347 /*==============================================================*/
1348 /* �������� */
1349 /*==============================================================*/
1350
1351 /*
1352 * buf[] ��ʸ���顢ñ�����Ф������ڤ�ϡ�SPC �� TAB��
1353 * ���Ф�����ñ�����Ƭ���ɥ쥹����*d_argv[] �˳�Ǽ����롣
1354 * ñ��Ϻ��� MAX_ARGS �ļ��Ф���ñ��ο��ϡ�d_argc �˥��åȡ�
1355 * ñ��ο��� MAX_ARGS ����¿�����ϡ�d_argc �� MAX_ARGS+1 �åȡ�
1356 * ���λ���MAX_ARGS �ĤޤǤϡ�*d_argv[] ����Ǽ����Ƥ��롣
1357 */
1358
1359 #define MAX_ARGS (8)
1360 #define MAX_CHRS (256)
1361
1362 static char buf[MAX_CHRS];
1363 static int d_argc;
1364 static char *d_argv[MAX_ARGS];
1365
1366 static int argv_counter;
1367
getarg(void)1368 static void getarg(void)
1369 {
1370 char *p = &buf[0];
1371
1372 argv_counter = 1;
1373
1374 d_argc = 0;
1375 for (;;) {
1376
1377 for (;;) {
1378 if (*p == '\n' || *p == '\0') return;
1379 else if (*p == ' ' || *p == '\t') p++;
1380 else {
1381 if (d_argc == MAX_ARGS) { d_argc++; return; }
1382 else { d_argv[ d_argc++ ] = p; break; }
1383 }
1384 }
1385 for (;;) {
1386 if (*p == '\n' || *p == '\0') { *p = '\0'; return; }
1387 else if (*p == ' ' || *p == '\t') { *p++ = '\0'; break; }
1388 else { p++; }
1389 }
1390
1391 }
1392
1393 return;
1394 }
1395
1396
1397 /*
1398 * getarg() �ˤ�ꡢmain()�ΰ�����Ʊ���褦�ʷ����ǡ�int d_argc, char *d_argv[]
1399 * �����ꤵ��뤬�������⤦������ñ�˽����������Τǡ�shift() �ؿ����Ѱդ�����
1400 *
1401 * shift() �ؿ���Ƥ֤ȡ����ֺǽ�ΰ��������Ϥ��졢���η�̤� argv �����
1402 * ��Ǽ����롣���θ�ǡ�argv.type ������å�����С����ΰ����μ��ब��
1403 * argv.val ������å�����С����ΰ������ͤ��狼�롣
1404 *
1405 * shift() �ؿ��ˤ�ꡢ���������������Ĥ������ˤ���Ƥ�����
1406 * �椨�ˡ�shift() �ؿ���Ϣ³���ƸƤ٤С���˼��ΰ��������Ϥ���롣
1407 *
1408 * shift();
1409 * if( argv.type == XXX ){ ����() };
1410 * shift();
1411 * if( argv.type == YYY ){ ����() };
1412 * ...
1413 */
1414
1415 static struct {
1416 int type; /* ������� ARGV_xxx */
1417 int val; /* �������� ARG_xxx �ޤ��ϡ��� */
1418 char *str; /* ������ʸ���� d_argv[xxx]��Ʊ�� */
1419 } argv;
1420
1421
shift(void)1422 static void shift(void)
1423 {
1424 int i, size = FALSE;
1425 char *p, *chk;
1426
1427
1428 if (argv_counter > MAX_ARGS || /* ����ʾ������̵�� */
1429 argv_counter >= d_argc) {
1430
1431 argv.type = ARGV_END;
1432
1433 } else { /* �ޤ�����������ΤDz��� */
1434
1435 p = d_argv[ argv_counter ];
1436 if (*p == '#') { size = TRUE; p++; }
1437
1438 argv.type = 0;
1439 argv.val = strtol(p, &chk, 0);
1440 argv.str = d_argv[ argv_counter ];
1441
1442 if (p != chk && *chk == '\0') { /* ���ͤξ�� */
1443
1444 if (size) { /* #�ǻϤޤ� */
1445 if (argv.val <= 0) argv.type = ARGV_STR;
1446 else argv.type = ARGV_SIZE;
1447 } else { /*���ǻϤޤ� */
1448 argv.type |= ARGV_INT;
1449 if (argv.val >= 0) argv.type |= ARGV_NUM;
1450 if (argv.val <= 0xff) argv.type |= ARGV_PORT;
1451 if (argv.val <= 0xffff) argv.type |= ARGV_ADDR;
1452 if (BETWEEN(1, argv.val, NR_DRIVE)) argv.type |= ARGV_DRV;
1453 if (BETWEEN(1, argv.val, MAX_NR_IMAGE)) argv.type |= ARGV_IMG;
1454 }
1455
1456 } else { /* ʸ����ξ�� */
1457
1458 if (size) { /* #�ǻϤޤ� */
1459 argv.type = ARGV_STR;
1460 } else { /*���ǻϤޤ� */
1461 for (i=0; i<COUNTOF(monitor_argv); i++) {
1462 if (my_strcmp(p, monitor_argv[i].str) == 0) {
1463 argv.type |= monitor_argv[i].type;
1464 argv.val = monitor_argv[i].val;
1465 }
1466 }
1467 if (argv.type == 0) argv.type = ARGV_STR;
1468 }
1469
1470 }
1471
1472 argv_counter ++;
1473
1474 }
1475 }
1476
1477
1478 /* shift() ������̡����������ꤵ�줿���ɤ���������å� */
1479
1480 #define exist_argv() (argv.type)
1481
1482 /* shift() ������̡��������줿�����μ��������å� */
1483
1484 #define argv_is(x) (argv.type & (x))
1485
1486
1487 /* �������� (ARG_xxx) ���顢������ʸ���� (��ʸ��) ������ */
1488
argv2str(int argv_val)1489 static char *argv2str(int argv_val)
1490 {
1491 int i;
1492
1493 for (i=0; i<COUNTOF(monitor_argv); i++) {
1494 if (argv_val == monitor_argv[i].val) return monitor_argv[i].str;
1495 }
1496 return "";
1497 }
1498
1499
1500
1501
1502 /*==============================================================*/
1503 /* ���顼��Ϣ */
1504 /*==============================================================*/
1505 #define error() \
1506 do { \
1507 printf("Invalid argument (arg %d)\n",argv_counter); \
1508 return; \
1509 } while(0)
1510
1511
1512
1513
1514 /*==============================================================*/
1515 /* �ƥ����ȥ�������Ϣ by peach */
1516 /*==============================================================*/
1517 #define PUT_JIS_IN(fp) fprintf(fp, "%c%c%c", 0x1b, 0x28, 0x49);
1518 #define PUT_JIS_OUT(fp) fprintf(fp, "%c%c%c", 0x1b, 0x28, 0x42);
1519
1520 enum { LANG_EUC, LANG_JIS, LANG_SJIS };
1521
1522 static int lang = -1;
1523
set_lang(void)1524 static void set_lang(void)
1525 {
1526 /*char *p;*/
1527
1528 if (lang >= 0) return;
1529
1530 #ifdef USE_LOCALE
1531 setlocale(LC_ALL, "");
1532 p = nl_langinfo(CODESET);
1533 if (strncmp(p, "JIS_", 4) == 0) {
1534 lang = LANG_JIS;
1535 } else if (strncmp(p, "SHIFT_JIS", 9) == 0) {
1536 lang = LANG_SJIS;
1537 } else { /* EUC_JP (default)*/
1538 lang = LANG_EUC;
1539 }
1540 #else
1541 lang = LANG_EUC;
1542 #endif
1543 }
1544
print_hankaku(FILE * fp,Uchar * str,char ach)1545 void print_hankaku(FILE *fp, Uchar *str, char ach)
1546 {
1547 Uchar *ptr;
1548
1549 /* ɸ����Ϥ���ʤ��ʤ餽�Τޤ� */
1550 if (fp != stdout) {
1551 fprintf(fp, "%s", str);
1552 return;
1553 }
1554
1555 ptr = str;
1556 set_lang();
1557
1558 if (lang == LANG_JIS) PUT_JIS_IN(fp);
1559 while (*ptr != '\0') {
1560 if (*ptr == '\n') {
1561 if (lang == LANG_JIS) {
1562 PUT_JIS_OUT(fp);
1563 fputc('\n', fp);
1564 PUT_JIS_IN(fp);
1565 } else {
1566 fputc('\n', fp);
1567 }
1568 } else if (0xa1u <= *ptr && *ptr <= 0xdfu) {
1569 switch (lang) {
1570 case LANG_EUC:
1571 fputc(0x8eu, fp); fputc(*ptr, fp); break;
1572 case LANG_JIS:
1573 fputc(*ptr - 0x80u, fp); break;
1574 case LANG_SJIS:
1575 fputc(*ptr, fp); break;
1576 }
1577 } else if (isprint(*ptr)) {
1578 fputc(*ptr, fp);
1579 } else { /* ɽ����ǽ */
1580 fputc(ach, fp);
1581 /*fprintf(fp, "0x%x", *ptr);*/
1582 }
1583 ptr++;
1584 }
1585 if (lang == LANG_JIS) PUT_JIS_OUT(fp);
1586 }
1587
1588
1589 /****************************************************************/
1590 /* ̿���̽��� */
1591 /****************************************************************/
1592
1593 /*--------------------------------------------------------------*/
1594 /* help [<cmd>] */
1595 /* �إ�פ�ɽ������ */
1596 /*--------------------------------------------------------------*/
monitor_help(void)1597 static void monitor_help(void)
1598 {
1599 int i;
1600 char *cmd = NULL;
1601
1602 if (exist_argv()) { /* [cmd] */
1603 cmd = argv.str;
1604 shift();
1605 }
1606 if (exist_argv()) error();
1607
1608
1609
1610 if (cmd == NULL) { /* �����ʤ������إ��ɽ�� */
1611
1612 printf("help\n");
1613 for (i=0; i<COUNTOF(monitor_cmd); i++) {
1614 printf(" %-10s %s\n", monitor_cmd[i].cmd,
1615 monitor_cmd[i].help_mes);
1616 }
1617 printf(" Note: type \"help <command-name>\" for more details.\n");
1618
1619 } else { /* �����Υ��ޥ�ɤΥإ��ɽ�� */
1620
1621 for (i=0; i<COUNTOF(monitor_cmd); i++) {
1622 if (strcmp(cmd, monitor_cmd[i].cmd) == 0) break;
1623 }
1624 if (i == COUNTOF(monitor_cmd)) error();
1625 (monitor_cmd[i].help)();
1626
1627 }
1628
1629 }
1630
1631
1632 /*--------------------------------------------------------------*/
1633 /* dump [<bank>] <start-addr> [<end-addr>] */
1634 /* dump [<bank>] <start-addr> [#<size>] */
1635 /* �������פ�ɽ������ */
1636 /*--------------------------------------------------------------*/
1637 static int save_dump_addr = -1;
1638 static int save_dump_bank = ARG_MAIN;
monitor_dump(void)1639 static void monitor_dump( void )
1640 {
1641 int i, j;
1642 byte c;
1643 int bank = save_dump_bank;
1644 int start = save_dump_addr;
1645 int size = 256;
1646
1647
1648 if( !exist_argv() ){
1649 if( save_dump_addr == -1 ) error();
1650 /* else skip */
1651 }else{
1652
1653 if( argv_is( ARGV_BANK ) ){ /* [<bank>] */
1654 bank = argv.val;
1655 shift();
1656 }
1657
1658 if( !argv_is( ARGV_ADDR ) ) error(); /* <addr> */
1659 start = argv.val;
1660 shift();
1661
1662 if ( !exist_argv() ) /* skip */; /* [<addr|#size>] */
1663 else if( argv_is( ARGV_SIZE ) ) size = argv.val;
1664 else if( argv_is( ARGV_ADDR ) ) size = argv.val - start +1;
1665 else error();
1666 shift();
1667 }
1668
1669 if( exist_argv() ) error();
1670
1671
1672 /*================*/
1673
1674 save_dump_addr = start + size; /* ������פ������ɥ쥹�� */
1675 save_dump_bank = bank; /* �Ф��Ƥ��� (Ϣ³�������)*/
1676
1677 size = ( size+15 ) /16;
1678
1679 printf("addr : +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F\n");
1680 printf("---- : -----------------------------------------------\n");
1681 for( i=0; i<size; i++ ){
1682 printf("%04X : ",(start+i*16)&0xffff);
1683 for( j=0; j<16; j++ ){
1684 printf("%02X ", peek_memory( bank, start+i*16+j ) );
1685 }
1686 printf("|");
1687 for( j=0; j<16; j++ ){
1688 c = peek_memory( bank, start+i*16+j );
1689 if( !isprint( c ) ) c = '.';
1690 printf("%c", c );
1691 }
1692 printf("|\n");
1693 }
1694 printf("\n");
1695
1696 return;
1697 }
1698
1699 /*----------------------------------------------------------------------*/
1700 /* dumpext [<bank>] [#<board>] <start-addr> [<end-addr>] */
1701 /* dumpext [<bank>] [#<board>] <start-addr> [#<size>] */
1702 /* ��ĥRAM�Υ������פ�ɽ������ */
1703 /* ���ε�ǽ�� peach��ˤ���������ޤ��� */
1704 /*----------------------------------------------------------------------*/
1705 static int save_dumpext_addr = -1;
1706 static int save_dumpext_bank = ARG_EXT0;
1707 static int save_dumpext_board = 1;
monitor_dumpext(void)1708 static void monitor_dumpext( void )
1709 {
1710 int i, j;
1711 byte c;
1712 int bank = save_dumpext_bank;
1713 int start = save_dumpext_addr;
1714 int board = save_dumpext_board;
1715 int size = 256;
1716
1717
1718 if( !exist_argv() ){
1719 if( save_dumpext_addr == -1 ) error();
1720 /* else skip */
1721 }else{
1722
1723 if( argv_is( ARGV_BANK ) ){ /* [<bank>] */
1724 bank = argv.val;
1725 if ( bank < ARG_EXT0 || ARG_EXT3 < bank ) error();
1726 shift();
1727 }
1728
1729 if( argv_is( ARGV_SIZE ) ) { /* [#<board>] */
1730 board = argv.val;
1731 if ( board < 1 || use_extram < board ) error();
1732 shift();
1733 }
1734
1735 if( !argv_is( ARGV_ADDR ) ) error(); /* <addr> */
1736 start = argv.val;
1737 if ( start >= 0x8000 ) error();
1738 shift();
1739
1740 if ( !exist_argv() ) /* skip */; /* [<addr|#size>] */
1741 else if( argv_is( ARGV_SIZE ) ) size = argv.val;
1742 else if( argv_is( ARGV_ADDR ) ) size = argv.val - start +1;
1743 else error();
1744 if ( start + size >= 0x8000 ) error();
1745 shift();
1746 }
1747
1748 if( exist_argv() ) error();
1749
1750
1751 /*================*/
1752
1753 save_dumpext_addr = start + size; /* ������פ������ɥ쥹�� */
1754 save_dumpext_bank = bank; /* �Ф��Ƥ��� (Ϣ³�������)*/
1755 save_dumpext_board = board;
1756
1757 size = ( size+15 ) /16;
1758 bank = bank - ARG_EXT0 + (board - 1) * 4;
1759
1760 printf("addr : +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F\n");
1761 printf("---- : -----------------------------------------------\n");
1762 for( i=0; i<size; i++ ){
1763 printf("%04X : ",(start+i*16)&0xffff);
1764 for( j=0; j<16; j++ ){
1765 printf("%02X ", ext_ram[bank][start+i*16+j]) ;
1766 }
1767 printf("|");
1768 for( j=0; j<16; j++ ){
1769 c = ext_ram[bank][start+i*16+j];
1770 if( !isprint( c ) ) c = '.';
1771 printf("%c", c );
1772 }
1773 printf("|\n");
1774 }
1775 printf("\n");
1776
1777 return;
1778 }
1779
1780
1781
1782 /*--------------------------------------------------------------*/
1783 /* fill [<bank>] <start-addr> <end-addr> <value> */
1784 /* fill [<bank>] <start-addr> #<size> <value> */
1785 /* ��������� */
1786 /*--------------------------------------------------------------*/
monitor_fill(void)1787 static void monitor_fill( void )
1788 {
1789 int i;
1790 int bank = ARG_MAIN;
1791 int start, size, value;
1792
1793
1794 if( !exist_argv() ) error();
1795
1796 if( argv_is( ARGV_BANK ) ){ /* [<bank>] */
1797 bank = argv.val;
1798 shift();
1799 }
1800
1801 if( !argv_is( ARGV_ADDR ) ) error(); /* <addr> */
1802 start = argv.val;
1803 shift();
1804
1805 if ( argv_is( ARGV_SIZE ) ) size = argv.val; /* [<addr|#size>] */
1806 else if( argv_is( ARGV_ADDR ) ) size = argv.val - start +1;
1807 else error();
1808 shift();
1809
1810 if( !argv_is( ARGV_INT )) error(); /* <data> */
1811 value = argv.val;
1812 shift();
1813
1814 if( exist_argv() ) error();
1815
1816
1817 /*================*/
1818
1819 for( i=0; i<size; i++ ){
1820 poke_memory( bank, start+i, value );
1821 }
1822
1823 return;
1824 }
1825
1826
1827
1828 /*--------------------------------------------------------------*/
1829 /* move [<bank>] <src-addr> <end-addr> [<bank>] <dist-addr> */
1830 /* move [<bank>] <src-addr> #size [<bank>] <dist-addr> */
1831 /* ����ž�� */
1832 /*--------------------------------------------------------------*/
monitor_move(void)1833 static void monitor_move( void )
1834 {
1835 int i;
1836 int s_bank = ARG_MAIN;
1837 int d_bank = ARG_MAIN;
1838 int start, size, dist;
1839 byte data;
1840
1841
1842 if( !exist_argv() ) error();
1843
1844 if( argv_is( ARGV_BANK ) ){ /* [<bank>] */
1845 s_bank = argv.val;
1846 d_bank = s_bank;
1847 shift();
1848 }
1849
1850 if( !argv_is( ARGV_ADDR ) ) error(); /* <addr> */
1851 start = argv.val;
1852 shift();
1853
1854 if ( argv_is( ARGV_SIZE ) ) size = argv.val; /* [<addr|#size>] */
1855 else if( argv_is( ARGV_ADDR ) ) size = argv.val - start +1;
1856 else error();
1857 shift();
1858
1859 if( argv_is( ARGV_BANK ) ){ /* [<bank>] */
1860 d_bank = argv.val;
1861 shift();
1862 }
1863
1864 if( !argv_is( ARGV_ADDR ) ) error(); /* <addr> */
1865 dist = argv.val;
1866 shift();
1867
1868 if( exist_argv() ) error();
1869
1870
1871 /*================*/
1872
1873 if( start+size <= dist ){ /* ž����-ž���褬 �Ťʤ�ʤ�*/
1874 for( i=0; i<size; i++ ){
1875 data = peek_memory( s_bank, start+i );
1876 poke_memory( d_bank, dist+i, data );
1877 }
1878 }else{ /* ž����-ž���褬 �Ťʤ� */
1879 for( i=size-1; i>=0; i-- ){
1880 data = peek_memory( s_bank, start+i );
1881 poke_memory( d_bank, dist+i, data );
1882 }
1883 }
1884
1885 return;
1886 }
1887
1888
1889
1890 /*--------------------------------------------------------------*/
1891 /* search [<value> [[<bank>] <start-addr> <end-addr>]] */
1892 /* �������� (1����) ���� */
1893 /*--------------------------------------------------------------*/
1894 static int save_search_addr = -1;
1895 static int save_search_size = -1;
1896 static int save_search_bank = ARG_MAIN;
1897 static byte save_search_data;
monitor_search(void)1898 static void monitor_search( void )
1899 {
1900 int i, j;
1901
1902 if( !exist_argv() ){
1903 if( save_search_addr == -1 ) error();
1904 /* else skip */
1905 }else{
1906
1907 if( !argv_is( ARGV_INT )) error(); /* <value> */
1908 save_search_data = argv.val;
1909 shift();
1910
1911 if( !exist_argv() ){
1912 if( save_search_addr == -1 ) error();
1913 /* else skip */
1914 }else{
1915
1916 if( argv_is( ARGV_BANK ) ){ /* [<bank>] */
1917 save_search_bank = argv.val;
1918 shift();
1919 }
1920
1921 if( !argv_is( ARGV_ADDR ) ) error(); /* <addr> */
1922 save_search_addr = argv.val;
1923 shift();
1924
1925 if ( argv_is( ARGV_SIZE ) ) /* <end-addr|#size>*/
1926 save_search_size = argv.val;
1927 else if( argv_is( ARGV_ADDR ) )
1928 save_search_size = argv.val - save_search_addr +1;
1929 else error();
1930 shift();
1931 }
1932
1933 }
1934
1935 if( exist_argv() ) error();
1936
1937
1938 /*================*/
1939
1940 j=0; /* ���פ������ɥ쥹����� */
1941 for( i=0; i<save_search_size; i++ ){
1942 if( peek_memory( save_search_bank, save_search_addr+i )
1943 == save_search_data ){
1944 printf("[%04X] ",save_search_addr+i);
1945 if( ++j == 11 ){ printf("\n"); j=0; }
1946 }
1947 }
1948 if( j!=0 ) printf("\n");
1949
1950 return;
1951 }
1952
1953
1954
1955 /*--------------------------------------------------------------*/
1956 /* read [<bank>] <addr> */
1957 /* ����Υ��ɥ쥹���� */
1958 /*--------------------------------------------------------------*/
monitor_read(void)1959 static void monitor_read( void )
1960 {
1961 int i, j;
1962 int addr;
1963 byte data;
1964 int bank = ARG_MAIN;
1965
1966
1967
1968 if( !exist_argv() ) error();
1969
1970 if( argv_is( ARGV_BANK )){ /* [<bank>] */
1971 bank = argv.val;
1972 shift();
1973 }
1974
1975 if( !argv_is( ARGV_ADDR )) error(); /* <addr> */
1976 addr = argv.val;
1977 shift();
1978
1979 if( exist_argv() ) error();
1980
1981
1982 /*================*/
1983
1984 data = peek_memory( bank, addr );
1985
1986 printf("READ memory %s[ %04XH ] -> %02X (= %d | %+d | ",argv2str(bank),
1987 addr,(Uint)data,(Uint)data,(int)((char)data));
1988 for( i=0, j=0x80; i<8; i++, j>>=1 ){
1989 printf("%d", (data & j) ? 1 : 0 );
1990 }
1991 printf("B )\n");
1992
1993 return;
1994 }
1995 /*--------------------------------------------------------------*/
1996 /* write [<bank>] <addr> <data> */
1997 /* ����Υ��ɥ쥹�˥饤�� */
1998 /*--------------------------------------------------------------*/
monitor_write(void)1999 static void monitor_write( void )
2000 {
2001 int i, j;
2002 int addr;
2003 byte data;
2004 int bank = ARG_MAIN;
2005
2006
2007 if( !exist_argv() ) error();
2008
2009 if( argv_is( ARGV_BANK )){ /* [<bank>] */
2010 bank = argv.val;
2011 shift();
2012 }
2013
2014 if( !argv_is( ARGV_ADDR )) error(); /* <addr> */
2015 addr = argv.val;
2016 shift();
2017
2018 if( !argv_is( ARGV_INT )) error(); /* <data> */
2019 data = argv.val;
2020 shift();
2021
2022 if( exist_argv() ) error();
2023
2024
2025 /*================*/
2026
2027 poke_memory( bank, addr, data );
2028
2029 printf("WRITE memory %s[ %04XH ] <- %02X (= %d | %+d | ",argv2str(bank),
2030 addr,(Uint)data,(Uint)data,(int)((char)data));
2031 for( i=0, j=0x80; i<8; i++, j>>=1 ){
2032 printf("%d", (data & j) ? 1 : 0 );
2033 }
2034 printf("B )\n");
2035
2036 return;
2037 }
2038
2039
2040
2041 /*--------------------------------------------------------------*/
2042 /* in [<cpu>] <port> */
2043 /* ����Υݡ��Ȥ������� */
2044 /*--------------------------------------------------------------*/
monitor_in(void)2045 static void monitor_in( void )
2046 {
2047 int i, j;
2048 int cpu = ARG_MAIN, port;
2049 byte data;
2050
2051
2052 if( !exist_argv() ) error();
2053
2054 if( argv_is( ARGV_CPU )){ /* [<cpu>] */
2055 cpu = argv.val;
2056 shift();
2057 }
2058
2059 if( !argv_is( ARGV_PORT )) error(); /* <port> */
2060 port = argv.val;
2061 shift();
2062
2063 if( exist_argv() ) error();
2064
2065
2066 /*================*/
2067
2068 if( cpu==ARG_MAIN ) data = main_io_in(port) & 0xff;
2069 else data = sub_io_in(port) & 0xff;
2070
2071 printf("IN port %s[ %02X ] -> %02X (",argv2str(cpu),port,data);
2072 for( i=0, j=0x80; i<8; i++, j>>=1 ){
2073 printf("%d", (data & j) ? 1 : 0 );
2074 }
2075 printf(")\n");
2076
2077 return;
2078 }
2079
2080
2081
2082 /*--------------------------------------------------------------*/
2083 /* out [<cpu>] <port> <data> */
2084 /* ����Υݡ��Ȥ˽��� */
2085 /*--------------------------------------------------------------*/
monitor_out(void)2086 static void monitor_out( void )
2087 {
2088 int i, j;
2089 int cpu = ARG_MAIN, port;
2090 byte data;
2091
2092
2093 if( !exist_argv() ) error();
2094
2095 if( argv_is( ARGV_CPU )){ /* [<cpu>] */
2096 cpu = argv.val;
2097 shift();
2098 }
2099
2100 if( !argv_is( ARGV_PORT )) error(); /* <port> */
2101 port = argv.val;
2102 shift();
2103
2104 if( !argv_is( ARGV_INT )) error(); /* <data> */
2105 data = argv.val & 0xff;
2106 shift();
2107
2108 if( exist_argv() ) error();
2109
2110
2111 /*================*/
2112
2113 if( cpu==ARG_MAIN ) main_io_out(port,data);
2114 else sub_io_out(port,data);
2115
2116 printf("OUT port %s[ %02X ] <- %02X (",argv2str(cpu),port,data);
2117 for( i=0, j=0x80; i<8; i++, j>>=1 ){
2118 printf("%d", (data & j) ? 1 : 0 );
2119 }
2120 printf(")\n");
2121
2122 return;
2123 }
2124
2125
2126 /*--------------------------------------------------------------*/
2127 /* reset [<bas-mode>] [<clock-mode>] [<sound-board>] [<dipsw>] */
2128 /* �ꥻ�åȡ��⡼�ɤȥ�����ɥܡ��ɤȥǥ��åפ�����Ǥ��� */
2129 /*--------------------------------------------------------------*/
monitor_reset(void)2130 static void monitor_reset(void)
2131 {
2132 T_RESET_CFG cfg;
2133 int dipsw = -1, bas_mode = -1, ck_mode = -1, sd_mode = -1;
2134
2135
2136 while (exist_argv()) {
2137 if (argv_is(ARGV_BASMODE)) {
2138 if (bas_mode != -1) error(); /* <bas-mode> */
2139 bas_mode = argv.val;
2140 shift();
2141 } else if (argv_is(ARGV_CKMODE)) {
2142 if (ck_mode != -1) error(); /* <ck-mode> */
2143 ck_mode = argv.val;
2144 shift();
2145 } else if (argv_is(ARGV_SDMODE)) {
2146 if (sd_mode != -1) error(); /* <sound-board> */
2147 sd_mode = argv.val;
2148 shift();
2149 } else if (argv_is(ARGV_NUM)) { /* <dipsw> */
2150 if (dipsw != -1) error();
2151 dipsw = argv.val & 0xffff;
2152 shift();
2153 } else {
2154 error();
2155 }
2156 }
2157
2158 if (exist_argv()) error();
2159
2160
2161 /*================*/
2162 quasi88_get_reset_cfg(&cfg);
2163
2164 switch (bas_mode) {
2165 case ARG_N: cfg.boot_basic = BASIC_N; break;
2166 case ARG_V1S: cfg.boot_basic = BASIC_V1S; break;
2167 case ARG_V1H: cfg.boot_basic = BASIC_V1H; break;
2168 case ARG_V2: cfg.boot_basic = BASIC_V2; break;
2169 }
2170
2171 switch (ck_mode) {
2172 case ARG_8MHZ: cfg.boot_clock_4mhz = FALSE; break;
2173 case ARG_4MHZ: cfg.boot_clock_4mhz = TRUE; break;
2174 }
2175
2176 switch (sd_mode) {
2177 case ARG_SD: cfg.sound_board = SOUND_I; break;
2178 case ARG_SD2: cfg.sound_board = SOUND_II; break;
2179 }
2180
2181 if (dipsw != -1) cfg.boot_dipsw = dipsw;
2182
2183 quasi88_reset(&cfg);
2184
2185 /* quasi88_exec(); */
2186 /* go �Ϥ��ʤ��� reset-go �Ȥ������ޥ�ɤ������������ */
2187 }
2188
2189 /*--------------------------------------------------------------*/
2190 /* reg [[<cpu>] [<name> <value>]] */
2191 /* reg all */
2192 /* �쥸���������Ƥ�ɽ�����ѹ� */
2193 /*--------------------------------------------------------------*/
monitor_reg(void)2194 static void monitor_reg( void )
2195 {
2196 int all = FALSE;
2197 int cpu = -1, reg = -1, value=0;
2198 z80arch *z80;
2199
2200
2201 if( exist_argv() ){
2202
2203 if( argv_is( ARGV_ALL )){ /* all */
2204 all = TRUE;
2205 shift();
2206 }else{
2207
2208 if( argv_is( ARGV_CPU )){ /* [<cpu>] */
2209 cpu = argv.val;
2210 shift();
2211 }
2212
2213 if( exist_argv() ){
2214 if( !argv_is( ARGV_REG )) error(); /* [<name>] */
2215 reg = argv.val;
2216 shift();
2217 if( !argv_is( ARGV_INT )) error(); /* [<value>] */
2218 value = argv.val;
2219 shift();
2220 }
2221 }
2222 }
2223
2224 if( exist_argv() ) error();
2225
2226
2227 /*================*/
2228
2229 if( reg==-1 ){ /* �쥸����ɽ�� */
2230 if( !all && cpu==-1 ){
2231 if( cpu_timing >= 2 ) all = TRUE;
2232 else{
2233 if( select_main_cpu ) cpu = ARG_MAIN;
2234 else cpu = ARG_SUB;
2235 }
2236 }
2237 if( all ){
2238 z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
2239 z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
2240 }else{
2241 if( cpu==ARG_MAIN ) z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
2242 else z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
2243 }
2244 return;
2245 }
2246
2247 /* �쥸�������� */
2248 if( cpu==-1 ){
2249 if( cpu_timing >= 2 ){
2250 cpu = ARG_MAIN;
2251 }else{
2252 if( select_main_cpu ) cpu = ARG_MAIN;
2253 else cpu = ARG_SUB;
2254 }
2255 }
2256
2257 if( cpu==ARG_MAIN ) z80 = &z80main_cpu;
2258 else z80 = &z80sub_cpu;
2259
2260 switch( reg ){
2261 case ARG_AF: z80->AF.W = value; break;
2262 case ARG_BC: z80->BC.W = value; break;
2263 case ARG_DE: z80->DE.W = value; break;
2264 case ARG_HL: z80->HL.W = value; break;
2265 case ARG_IX: z80->IX.W = value; break;
2266 case ARG_IY: z80->IY.W = value; break;
2267 case ARG_SP: z80->SP.W = value; break;
2268 case ARG_PC: z80->PC.W = value; break;
2269 case ARG_AF1: z80->AF1.W = value; break;
2270 case ARG_BC1: z80->BC1.W = value; break;
2271 case ARG_DE1: z80->DE1.W = value; break;
2272 case ARG_HL1: z80->HL1.W = value; break;
2273 case ARG_I: value &= 0xff; z80->I = value; break;
2274 case ARG_R: value &= 0xff; z80->R = value; break;
2275 case ARG_IFF: if(value) value=1; z80->IFF = value; break;
2276 case ARG_IM: if(value>3)value=2; z80->IM = value; break;
2277 case ARG_HALT:if(value) value=1; z80->HALT = value; break;
2278 }
2279
2280 printf("[%s] reg %s <- %04X\n",argv2str(cpu),argv2str(reg),value);
2281 }
2282
2283
2284
2285 /*--------------------------------------------------------------*/
2286 /* disasm [[<cpu>][<start-addr>][#<steps>]] */
2287 /* �ե�����֥� */
2288 /*--------------------------------------------------------------*/
2289 static int save_disasm_cpu = -1;
2290 static int save_disasm_addr[2] = { -1, -1 };
monitor_disasm(void)2291 static void monitor_disasm( void )
2292 {
2293 int i, pc;
2294 int addr = -1;
2295 int cpu = -1;
2296 int step = 16;
2297 z80arch *z80;
2298
2299
2300 if( exist_argv() ){
2301
2302 if( argv_is( ARGV_CPU )){ /* [<cpu>] */
2303 cpu = argv.val;
2304 shift();
2305 }
2306
2307 if( argv_is( ARGV_ADDR )){ /* [<addr>] */
2308 addr = argv.val;
2309 shift();
2310 }
2311
2312 if( argv_is( ARGV_SIZE )){ /* [#<step>] */
2313 step = argv.val;
2314 shift();
2315
2316 }else if( argv_is( ARGV_STR ) && strcmp( argv.str, "#" )==0 ){
2317 if( cpu == -1 ){
2318 save_disasm_cpu = -1;
2319 save_disasm_addr[0] = -1;
2320 save_disasm_addr[1] = -1;
2321 printf( "disasm all reset\n" );
2322 }else{
2323 save_disasm_addr[cpu] = -1;
2324 printf( "disasm addr reset\n" );
2325 }
2326 return;
2327 }
2328
2329 }
2330 if( exist_argv() ) error();
2331
2332
2333 /*================*/
2334
2335 if( cpu == -1 ){ /* CPU ̤����� */
2336 cpu = save_disasm_cpu;
2337 if( cpu == -1 ){
2338 if( cpu_timing >= 2 ){
2339 cpu = ARG_MAIN;
2340 }else{
2341 if( select_main_cpu ) cpu = ARG_MAIN;
2342 else cpu = ARG_SUB;
2343 }
2344 }
2345 }
2346
2347 if( cpu==ARG_MAIN ) z80 = &z80main_cpu;
2348 else z80 = &z80sub_cpu;
2349
2350 if( addr == -1 ){ /* ADDR ̤����� */
2351 addr = save_disasm_addr[ cpu ];
2352 if( addr == -1 ) addr = z80->PC.W;
2353 }
2354
2355
2356 pc = 0;
2357 for( i=0; i<step; i++ ){
2358 pc += z80_line_disasm( z80, addr+pc );
2359 printf("\n");
2360 }
2361
2362 save_disasm_cpu = cpu;
2363 save_disasm_addr[cpu] = ( addr + pc ) & 0xffff;
2364 }
2365
2366
2367 /*--------------------------------------------------------------*/
2368 /* go */
2369 /* �¹� */
2370 /*--------------------------------------------------------------*/
monitor_go(void)2371 static void monitor_go( void )
2372 {
2373 if( exist_argv() ) error();
2374
2375 quasi88_exec();
2376 }
2377
2378
2379
2380 /*--------------------------------------------------------------*/
2381 /* trace <step> */
2382 /* trace #<step> */
2383 /* trace change */
2384 /* ���ꤷ�����ƥå�ʬ�ޤ���CPU�������Ѥ��ޤǡ��¹� */
2385 /*--------------------------------------------------------------*/
2386 static int save_trace_change = FALSE;
monitor_trace(void)2387 static void monitor_trace( void )
2388 {
2389 int change = FALSE, step = trace_counter;
2390
2391 if( exist_argv() ){
2392
2393 if ( argv_is( ARGV_CHANGE )) change = TRUE; /* [change] */
2394 else if( argv_is( ARGV_SIZE ) ) step = argv.val; /* [<step>] */
2395 else if( argv_is( ARGV_NUM ) ) step = argv.val; /* [#<step>] */
2396 else error();
2397 shift();
2398
2399 }else{
2400
2401 if( save_trace_change ) change = TRUE;
2402 else change = FALSE;
2403
2404 }
2405
2406 if( exist_argv() ) error();
2407
2408
2409 /*================*/
2410
2411 if( change ){
2412 save_trace_change = TRUE;
2413 quasi88_exec_trace_change();
2414
2415 }else {
2416 save_trace_change = FALSE;
2417 trace_counter = step;
2418 quasi88_exec_trace();
2419 }
2420 }
2421
2422
2423
2424
2425 /*--------------------------------------------------------------*/
2426 /* step */
2427 /* step [call] [jp] [rep] [all] */
2428 /* 1���ƥåס��¹� */
2429 /* CALL��DJNZ��LDIR etc �Υ����åפ������ǽ */
2430 /*--------------------------------------------------------------*/
monitor_step(void)2431 static void monitor_step( void )
2432 {
2433 int call = FALSE, jp = FALSE, rep = FALSE;
2434 int flag = FALSE;
2435 int cpu;
2436 byte code;
2437 word addr;
2438
2439 while( exist_argv() ){
2440 if( argv_is( ARGV_STEP )){
2441 if( argv.val==ARG_CALL ) call = TRUE;
2442 if( argv.val==ARG_JP ) jp = TRUE;
2443 if( argv.val==ARG_REP ) rep = TRUE;
2444 if( argv.val==ARG_ALL ){ call = jp = rep = TRUE; }
2445 shift();
2446 }else{
2447 error();
2448 }
2449 }
2450
2451 if( exist_argv() ) error();
2452
2453
2454 /*================*/
2455
2456 if( cpu_timing >= 2 ){
2457
2458 quasi88_exec_step();
2459 return;
2460
2461 }else{
2462
2463 if( select_main_cpu ){
2464 cpu = BP_MAIN;
2465 addr = z80main_cpu.PC.W;
2466 code = main_mem_read( addr );
2467 }else{
2468 cpu = BP_SUB;
2469 addr = z80sub_cpu.PC.W;
2470 code = sub_mem_read( addr );
2471 }
2472
2473 if( call ){
2474 if( code == 0xcd || /* CALL nn = 11001101B */
2475 (code&0xc7) == 0xc4 ){ /* CALL cc,nn = 11ccc100B */
2476 addr += 3;
2477 flag = TRUE;
2478 }
2479 }
2480 if( jp ){
2481 if( code == 0x10 ){ /* DJNZ e = 00010000B */
2482 addr += 2;
2483 flag = TRUE;
2484 }
2485 }
2486 if( rep ){
2487 if( code == 0xed ){ /* LDIR/LDDR/CPIR/CPDR etc */
2488 if( select_main_cpu ) code = main_mem_read( addr+1 );
2489 else code = sub_mem_read( addr+1 );
2490 if( (code&0xf4) == 0xb0 ){
2491 addr += 2;
2492 flag = TRUE;
2493 }
2494 }
2495 }
2496
2497 if( flag ){
2498 break_point[cpu][BP_NUM_FOR_SYSTEM].type = BP_PC;
2499 break_point[cpu][BP_NUM_FOR_SYSTEM].addr = addr;
2500 quasi88_exec();
2501 }else{
2502 break_point[cpu][BP_NUM_FOR_SYSTEM].type = BP_NONE;
2503 quasi88_exec_step();
2504 }
2505 }
2506 }
2507
2508
2509
2510 /*--------------------------------------------------------------*/
2511 /* S */
2512 /* step all ��Ʊ�� */
2513 /*--------------------------------------------------------------*/
monitor_stepall(void)2514 static void monitor_stepall( void )
2515 {
2516 int flag = FALSE;
2517 int cpu;
2518 byte code;
2519 word addr;
2520
2521 if( exist_argv() ) error();
2522
2523
2524 /*================*/
2525
2526 if( cpu_timing >= 2 ){
2527 quasi88_exec_step();
2528 return;
2529 }else{
2530 if( select_main_cpu ){
2531 cpu = BP_MAIN;
2532 addr = z80main_cpu.PC.W;
2533 code = main_mem_read( addr );
2534 }else{
2535 cpu = BP_SUB;
2536 addr = z80sub_cpu.PC.W;
2537 code = sub_mem_read( addr );
2538 }
2539 if( code == 0xcd || /* CALL nn = 11001101B */
2540 (code&0xc7) == 0xc4 ){ /* CALL cc,nn = 11ccc100B */
2541 addr += 3;
2542 flag = TRUE;
2543 }
2544 if( code == 0x10 ){ /* DJNZ e = 00010000B */
2545 addr += 2;
2546 flag = TRUE;
2547 }
2548 if( code == 0xed ){ /* LDIR/LDDR/CPIR/CPDR etc */
2549 if( select_main_cpu ) code = main_mem_read( addr+1 );
2550 else code = sub_mem_read( addr+1 );
2551 if( (code&0xf4) == 0xb0 ){
2552 addr += 2;
2553 flag = TRUE;
2554 }
2555 }
2556 if( code == 0x76 || /* HALT / RST XXH */
2557 code == 0xc7 || code == 0xcf || code == 0xd7 || code == 0xdf ||
2558 code == 0xe7 || code == 0xef || code == 0xf7 || code == 0xff ){
2559 addr += 1;
2560 flag = TRUE;
2561 }
2562 if( flag ){
2563 break_point[cpu][BP_NUM_FOR_SYSTEM].type = BP_PC;
2564 break_point[cpu][BP_NUM_FOR_SYSTEM].addr = addr;
2565 quasi88_exec();
2566 }else{
2567 break_point[cpu][BP_NUM_FOR_SYSTEM].type = BP_NONE;
2568 quasi88_exec_step();
2569 }
2570 }
2571
2572 }
2573
2574
2575
2576 /*--------------------------------------------------------------*/
2577 /* break [<cpu>] [PC|READ|WRITE|IN|OUT] <addr|port> [#<No>] */
2578 /* break [<cpu>] CLEAR [#<No>] */
2579 /* break */
2580 /* �֥졼���ݥ���Ȥ���������ɽ�� */
2581 /*--------------------------------------------------------------*/
monitor_break(void)2582 static void monitor_break( void )
2583 {
2584 int show = FALSE, i, j;
2585 char *s=NULL;
2586 int cpu = BP_MAIN, action = ARG_PC, addr=0, number = 0;
2587
2588
2589 if( exist_argv() ){
2590
2591 if( argv_is( ARGV_CPU )){ /* [<cpu>] */
2592 if( argv.val==ARG_MAIN ) cpu = BP_MAIN;
2593 else cpu = BP_SUB;
2594 shift();
2595 }
2596
2597 if( argv_is( ARGV_BREAK ) ){ /* <action> */
2598 action = argv.val;
2599 shift();
2600 }
2601
2602 switch( action ){ /* <addr|port> */
2603 case ARG_IN: case ARG_OUT:
2604 if( !argv_is( ARGV_PORT )) error();
2605 addr = argv.val;
2606 shift();
2607 break;
2608 case ARG_PC: case ARG_READ: case ARG_WRITE:
2609 if( !argv_is( ARGV_ADDR )) error();
2610 addr = argv.val;
2611 shift();
2612 break;
2613 }
2614
2615 if( exist_argv() ){ /* [#<No>] */
2616 if( argv.val < 0 || argv.val > NR_BP ||
2617 (action != ARG_CLEAR && argv.val < 1) ) error();
2618 number = argv.val -1;
2619 shift();
2620 }
2621
2622 }else{
2623
2624 show = TRUE;
2625
2626 }
2627
2628 if( exist_argv() ) error();
2629
2630
2631 /*================*/
2632
2633 if( show ){
2634 for( j=0; j<2; j++ ){
2635 printf( " %s:\n", (j==0)?"MAIN":"SUB" );
2636 for( i=0; i<NR_BP; i++ ){
2637 printf( " #%d ", i+1 );
2638 if (i < 9) printf(" "); /* ���䤹�� by peach */
2639 addr = break_point[j][i].addr;
2640 switch( break_point[j][i].type ){
2641 case BP_NONE: printf("-- none --\n"); break;
2642 case BP_PC: printf("PC reach %04XH\n",addr&0xffff); break;
2643 case BP_READ: printf("READ from %04XH\n",addr&0xffff); break;
2644 case BP_WRITE: printf("WRITE to %04XH\n",addr&0xffff); break;
2645 case BP_IN: printf("INPUT from %02XH\n",addr&0xff); break;
2646 case BP_OUT: printf("OUTPUT to %04XH\n",addr&0xff); break;
2647 }
2648 }
2649 }
2650 }else{
2651 if( action==ARG_CLEAR ){
2652 if ( number<0 ) {
2653 for ( i=0; i<9; i++ ) break_point[cpu][i].type = BP_NONE;
2654 printf( "clear break point %s - all\n",(cpu==0)?"MAIN":"SUB" );
2655 } else {
2656 break_point[cpu][number].type = BP_NONE;
2657 printf( "clear break point %s - #%d\n",(cpu==0)?"MAIN":"SUB",number+1 );
2658 }
2659 }else{
2660 switch( action ){
2661 case ARG_PC:
2662 break_point[cpu][number].type = BP_PC;
2663 s = "PC : %04XH";
2664 break;
2665 case ARG_READ:
2666 break_point[cpu][number].type = BP_READ;
2667 s = "READ : %04XH";
2668 break;
2669 case ARG_WRITE:
2670 break_point[cpu][number].type = BP_WRITE;
2671 s = "WRITE : %04XH";
2672 break;
2673 case ARG_IN:
2674 break_point[cpu][number].type = BP_IN;
2675 s = "IN : %02XH";
2676 break;
2677 case ARG_OUT:
2678 break_point[cpu][number].type = BP_OUT;
2679 s = "OUT : %02XH";
2680 break;
2681 }
2682 break_point[cpu][number].addr = addr;
2683 printf( "set break point %s - #%d [ ",(cpu==0)?"MAIN":"SUB",number+1 );
2684 printf( s, addr );
2685 printf( " ]\n" );
2686 }
2687 if( cpu==BP_MAIN ) pc88main_bus_setup();
2688 else pc88sub_bus_setup();
2689 }
2690
2691 }
2692
2693
2694
2695
2696 /*--------------------------------------------------------------*/
2697 /* loadmem <filename> <bank> <start-addr> [<end-addr>] */
2698 /* loadmem <filename> <bank> <start-addr> [#<size>] */
2699 /* �ե����뤫�����˥��� */
2700 /*--------------------------------------------------------------*/
monitor_loadmem(void)2701 static void monitor_loadmem( void )
2702 {
2703 int addr, size, bank;
2704 char *filename;
2705 FILE *fp;
2706 int c, i;
2707
2708 if( !exist_argv() ) error(); /* <filename> */
2709 filename = argv.str;
2710 shift();
2711
2712 if( !argv_is( ARGV_BANK ) ) error(); /* <bank> */
2713 bank = argv.val;
2714 shift();
2715
2716 if( !argv_is( ARGV_ADDR ) ) error(); /* <start-addr> */
2717 addr = argv.val;
2718 shift();
2719
2720 if ( argv_is( ARGV_SIZE ) ){ /* #<size>|<end-addr>*/
2721 size = argv.val;
2722 shift();
2723 }else if( argv_is( ARGV_ADDR ) ){
2724 size = argv.val - addr +1;
2725 shift();
2726 }else{
2727 size = -1;
2728 }
2729
2730 if( exist_argv() ) error();
2731
2732
2733 /*================*/
2734
2735 if( (fp=fopen( filename,"rb")) ){
2736 if( size<0 ){
2737 #if 0
2738 struct stat filestats;
2739
2740 if(fstat(fileno(fp), &filestats)) size = 0;
2741 else size = filestats.st_size;
2742 #else
2743 if( fseek( fp, 0, SEEK_END )==0 ){
2744 size = ftell( fp );
2745 if( size < 0 ) size = 0;
2746 }
2747 fseek( fp, 0, SEEK_SET );
2748 #endif
2749 }
2750 for( i=0; i<size; i++ ){
2751 if( (c=getc(fp)) == EOF ){
2752 printf("Warning : loadmem : file size too short (<%d)\n",size);
2753 break;
2754 }
2755 poke_memory( bank, addr+i, c );
2756 }
2757 fclose(fp);
2758 printf("Load [%s] -> %s (size %d )\n",filename,argv2str(bank),i);
2759 }else{
2760 printf("file [%s] can't open\n",filename);
2761 }
2762 }
2763
2764
2765
2766 /*--------------------------------------------------------------*/
2767 /* savemem <filename> <bank> <start-addr> <end-addr> */
2768 /* savemem <filename> <bank> <start-addr> #<size> */
2769 /* �����ե�����˥����� */
2770 /*--------------------------------------------------------------*/
monitor_savemem(void)2771 static void monitor_savemem( void )
2772 {
2773 int addr, size, bank;
2774 char *filename;
2775 FILE *fp;
2776 int c, i;
2777
2778 if( !exist_argv() ) error(); /* <filename> */
2779 filename = argv.str;
2780 shift();
2781
2782 if( !argv_is( ARGV_BANK ) ) error(); /* <bank> */
2783 bank = argv.val;
2784 shift();
2785
2786 if( !argv_is( ARGV_ADDR ) ) error(); /* <start-addr> */
2787 addr = argv.val;
2788 shift();
2789
2790 if ( argv_is( ARGV_SIZE ) ) size = argv.val; /* #<size>|<end-addr>*/
2791 else if( argv_is( ARGV_ADDR ) ) size = argv.val - addr +1;
2792 else error();
2793 shift();
2794
2795 if( exist_argv() ) error();
2796
2797
2798 /*================*/
2799
2800 if( (fp=fopen( filename,"wb")) ){
2801 for( i=0; i<size; i++ ){
2802 c = peek_memory( bank, addr+i );
2803 if( putc(c, fp) == EOF ){
2804 printf("Warning : savemem : file write failed\n");
2805 break;
2806 }
2807 }
2808 fclose(fp);
2809 printf("Save [%s] -> %s (size %d )\n",filename,argv2str(bank),i);
2810 }else{
2811 printf("file [%s] can't open\n",filename);
2812 }
2813 }
2814
2815
2816
2817 /*----------------------------------------------------------------------*/
2818 /* fbreak [<cpu>] [READ|WRITE|DIAG] <drive> <track> [<sector>] [#<No>] */
2819 /* fbreak [<cpu>] CLEAR [#<No>] */
2820 /* fbreak */
2821 /* FDC �֥졼���ݥ���Ȥ���������ɽ�� */
2822 /* ���ε�ǽ�� peach��ˤ���������ޤ��� */
2823 /*----------------------------------------------------------------------*/
monitor_fbreak(void)2824 static void monitor_fbreak(void)
2825 {
2826 int show = FALSE, i;
2827 char *s = NULL;
2828 int action = ARG_READ, number = 0;
2829 int drive = -1, track = -1, sector = -1;
2830
2831 if(exist_argv()){
2832 if (argv_is(ARGV_FBREAK)) { /* <action> */
2833 action = argv.val;
2834 shift();
2835 }
2836
2837 if (action == ARG_READ || action == ARG_WRITE || action == ARG_DIAG) {
2838 if (! argv_is(ARGV_DRV)) error();
2839 drive = argv.val;
2840 shift();
2841 if (! argv_is(ARGV_NUM) || argv.val < 0 || argv.val > 163) error();
2842 track = argv.val;
2843 shift();
2844 if (exist_argv() && ! argv_is(ARGV_SIZE)) {
2845 if (! argv_is(ARGV_NUM) || argv.val < 0) error();
2846 sector = argv.val;
2847 shift();
2848 }
2849 }
2850
2851 if (exist_argv()) { /* [#<No>] */
2852 if (argv.val < 0 || argv.val > NR_BP ||
2853 (action != ARG_CLEAR && argv.val < 1)) error();
2854 number = argv.val -1;
2855 shift();
2856 }
2857 } else {
2858 show = TRUE;
2859 }
2860
2861 if (exist_argv()) error();
2862
2863 if (show) {
2864 printf(" %s:\n", "FDC");
2865 for (i=0; i<NR_BP; i++) {
2866 /*if (break_point_fdc[i].type == BP_NONE) continue;*/
2867 printf(" #%d ", i+1);
2868 if (i < 9) printf(" ");
2869 drive = break_point_fdc[i].drive;
2870 track = break_point_fdc[i].track;
2871 sector = break_point_fdc[i].sector;
2872 if (break_point_fdc[i].type == BP_NONE) {
2873 printf("-- none --\n");
2874 } else {
2875 switch (break_point_fdc[i].type) {
2876 case BP_READ: printf("FDC READ from "); break;
2877 case BP_WRITE: printf("FDC WRITE to "); break;
2878 case BP_DIAG: printf("FDC DIAG in "); break;
2879 }
2880 printf("D:%d T:%d", drive, track);
2881 if (sector >= 0) printf(" S:%d", sector);
2882 printf("\n");
2883 }
2884 }
2885 } else {
2886 if (action == ARG_CLEAR) {
2887 if (number < 0) {
2888 for (i=0; i<9; i++) break_point_fdc[i].type = BP_NONE;
2889 printf("clear break point %s - all\n", "FDC");
2890 } else {
2891 break_point_fdc[number].type = BP_NONE;
2892 printf("clear break point %s - #%d\n", "FDC", number + 1);
2893 }
2894 } else {
2895 switch (action) {
2896 case ARG_READ:
2897 break_point_fdc[number].type = BP_READ;
2898 s = "READ";
2899 break;
2900 case ARG_WRITE:
2901 break_point_fdc[number].type = BP_WRITE;
2902 s = "WRITE";
2903 break;
2904 case ARG_DIAG:
2905 break_point_fdc[number].type = BP_DIAG;
2906 s = "DIAG";
2907 break;
2908 }
2909 break_point_fdc[number].drive = drive;
2910 break_point_fdc[number].track = track;
2911 break_point_fdc[number].sector = sector;
2912 printf("set break point - #%d [ %s : D:%d T:%d ",
2913 number + 1, s, drive, track);
2914 if (sector >= 0) printf("S:%d ", sector);
2915 printf("]\n");
2916 }
2917 }
2918
2919 pc88fdc_break_point();
2920 }
2921
2922 /*----------------------------------------------------------------------*/
2923 /* textscr */
2924 /* �ƥ����Ȳ��̤����ɽ�� */
2925 /* ���ε�ǽ�� peach��ˤ���������ޤ��� */
2926 /*----------------------------------------------------------------------*/
print_text_screen(void)2927 static void print_text_screen(void)
2928 {
2929 /*FILE *fp;*/
2930 int i, j;
2931 int line;
2932 int width;
2933 int end;
2934 Uchar text_buf[82]; /* 80ʸ�� + '\n' + '\0' */
2935
2936 if (grph_ctrl & 0x20) line = 25;
2937 else line = 20;
2938
2939 if (sys_ctrl & 0x01) width = 80;
2940 else width = 40;
2941
2942 for (i = 0, end = 0; i < line; i++) {
2943 for (j = 0; j < width; j++) {
2944 if (width == 80) {
2945 text_buf[j] =
2946 text_attr_buf[ text_attr_flipflop ][i * 80 + j] >> 8;
2947 } else {
2948 text_buf[j] =
2949 text_attr_buf[ text_attr_flipflop ][i * 80 + j * 2] >> 8;
2950 }
2951 if (text_buf[j] == 0) text_buf[j] = ' ';
2952 else end = j;
2953 }
2954 /* ��ü�ޤǤζ��������ʤ� */
2955 text_buf[end + 1] = '\n';
2956 text_buf[end + 2] = '\0';
2957 print_hankaku(stdout, text_buf, alt_char);
2958 }
2959 }
2960
monitor_textscr(void)2961 static void monitor_textscr(void)
2962 {
2963 if (exist_argv()) { /* <char> */
2964 alt_char = argv.str[0];
2965 shift();
2966 }
2967
2968 print_text_screen();
2969 }
2970
2971 /*--------------------------------------------------------------*/
2972 /* loadbas <filename> [<type>] */
2973 /* BASIC LIST ���ɤ߹��� */
2974 /*--------------------------------------------------------------*/
2975 #if 1 /* experimental by peach */
monitor_loadbas(void)2976 static void monitor_loadbas(void)
2977 {
2978 char *filename;
2979 int size;
2980 int type = ARG_ASCII;
2981 FILE *fp;
2982
2983 if (! exist_argv()) error(); /* <filename> */
2984 filename = argv.str;
2985 shift();
2986
2987 if (exist_argv()) { /* <type> */
2988 if (! argv_is(ARGV_BASIC)) error();
2989 type = argv.val;
2990 shift();
2991 }
2992
2993 if (exist_argv()) error();
2994
2995 if ((fp = fopen(filename, "r"))) {
2996 if (type == ARG_ASCII) {
2997 size = basic_encode_list(fp);
2998 } else {
2999 size = basic_load_intermediate_code(fp);
3000 }
3001 fclose(fp);
3002 if (size > 0) printf("Load [%s] (size %d)\n", filename, size);
3003 } else {
3004 printf("file [%s] can't open\n",filename);
3005 }
3006 }
3007 #else
monitor_loadbas(void)3008 static void monitor_loadbas(void) { printf("sorry, not support\n"); }
3009 #endif
3010 /*--------------------------------------------------------------*/
3011 /* savebas [<filename> [<type>]] */
3012 /* BASIC LIST ����� */
3013 /*--------------------------------------------------------------*/
3014 #if 1 /* experimental by peach */
monitor_savebas(void)3015 static void monitor_savebas(void)
3016 {
3017 char *filename;
3018 int size;
3019 int type = ARG_ASCII;
3020 FILE *fp;
3021
3022 if (exist_argv()) { /* <filename> */
3023 filename = argv.str;
3024 shift();
3025 if (exist_argv()) { /* <type> */
3026 if (! argv_is(ARGV_BASIC)) error();
3027 type = argv.val;
3028 shift();
3029 }
3030 } else {
3031 filename = NULL;
3032 }
3033
3034 if (exist_argv()) error();
3035
3036 if (filename == NULL) {
3037 basic_decode_list(stdout);
3038 } else if ((fp = fopen(filename, "w"))) {
3039 if (type == ARG_ASCII) {
3040 size = basic_decode_list(fp);
3041 } else {
3042 size = basic_save_intermediate_code(fp);
3043 }
3044 fclose(fp);
3045 if (size > 0) printf("Save [%s] (size %d)\n", filename, size);
3046 } else {
3047 printf("file [%s] can't open\n",filename);
3048 }
3049 }
3050 #else
monitor_savebas(void)3051 static void monitor_savebas(void) { printf("sorry, not support\n"); }
3052 #endif
3053
3054 /*--------------------------------------------------------------*/
3055 /* set [<variable> [<value>] ] */
3056 /* show [<variable> ] */
3057 /* �����ѿ���ɽ�����ѹ� */
3058 /*--------------------------------------------------------------*/
monitor_set_mem_printf(void)3059 static void monitor_set_mem_printf(void) /*** set mem ***/
3060 {
3061 const char *r0000, *r6000, *r8000, *r8400, *rC000, *rF000;
3062 const char *w0000, *w6000, *w8000, *w8400, *wC000, *wF000;
3063
3064 if (grph_ctrl & GRPH_CTRL_64RAM) { /* 64KB RAM mode */
3065 r0000 =
3066 r6000 = "MAIN RAM";
3067 } else { /* ROM/RAM mode */
3068 if (grph_ctrl & GRPH_CTRL_N) { /* N BASIC */
3069 r0000 =
3070 r6000 = "N ROM";
3071 } else { /*N88 BASIC*/
3072 r0000 = "MAIN ROM";
3073 if (ext_rom_bank & EXT_ROM_NOT) { /* �̾�ROM */
3074 r6000 = "MAIN ROM";
3075 } else { /* ��ĥROM */
3076 r6000 = "EXT ROM"; /*misc_ctrl & MISC_CTRL_EBANK*/
3077 }
3078 }
3079 }
3080 w0000 =
3081 w6000 = "MAIN_RAM";
3082 if (ext_ram_ctrl & 0x01) { /* ��ĥRAM R�� */
3083 if (ext_ram_bank < use_extram * 4) {
3084 r0000 =
3085 r6000 = "EXT RAM"; /*ext_ram_bank*/
3086 }
3087 }
3088 if (ext_ram_ctrl & 0x10) { /* ��ĥRAM W�� */
3089 if (ext_ram_bank < use_extram * 4) {
3090 w0000 =
3091 w6000 = "EXT RAM"; /*ext_ram_bank*/
3092 }
3093 }
3094
3095 if (grph_ctrl & (GRPH_CTRL_64RAM | GRPH_CTRL_N)) {
3096 r8000 =
3097 w8000 = "MAIN RAM";
3098 } else {
3099 r8000 =
3100 w8000 = "WINDOW"; /*window_offset*/
3101 }
3102
3103 r8400 =
3104 w8400 = "MAIN RAM";
3105
3106 if ((misc_ctrl & MISC_CTRL_EVRAM) && /* ��ĥ���������⡼�� */
3107 (ALU2_ctrl & ALU2_CTRL_VACCESS)) { /* VRAM��ĥ�������� */
3108 rC000 =
3109 rF000 =
3110 wC000 =
3111 wF000 = "VRAM Ext-Acc.";
3112 } else if (! (misc_ctrl & MISC_CTRL_EVRAM) && /* ��Ω���������⡼��*/
3113 (memory_bank != MEMORY_BANK_MAIN)) { /* �ᥤ��BANK�Ǥʤ� */
3114 rC000 =
3115 rF000 =
3116 wC000 =
3117 wF000 = (memory_bank == 0) ? "VRAM B"
3118 : ((memory_bank == 1) ?"VRAM R" :"VRAM G");
3119 } else {
3120 rC000 =
3121 wC000 = "MAIN RAM";
3122 if (high_mode &&
3123 (misc_ctrl & MISC_CTRL_TEXT_MAIN) == 0) { /*��®RAM*/
3124 rF000 =
3125 wF000 = "HIGH RAM";
3126 } else {
3127 rF000 =
3128 wF000 = "MAIN RAM";
3129 }
3130 if (jisho_rom_ctrl == FALSE) { /*����ROM*/
3131 rC000 =
3132 rF000 = "JISHO ROM"; /*jisho_rom_bank*/
3133 }
3134 }
3135
3136 printf(" Memory mapping\n");
3137
3138 printf(" %-12s%-12s%-12s ", "Addr.", "Read","Write");
3139 printf("Bank-Status\n");
3140
3141 printf(" %-12s%-12s%-12s ", "0000-5FFF", r0000, w0000);
3142 printf("Ext. Ram Bank(0-%d) = %d\n", use_extram * 4, ext_ram_bank);
3143
3144 printf(" %-12s%-12s%-12s ", "6000-7FFF", r6000, w6000);
3145 printf("Ext. Rom Bank(0-3) = %d\n", misc_ctrl & MISC_CTRL_EBANK);
3146
3147 printf(" %-12s%-12s%-12s ", "8000-83FF", r8000, w8000);
3148 printf("Window offset = %04XH\n", window_offset);
3149
3150 printf(" %-12s%-12s%-12s ", "8400-BFFF", r8400, w8400);
3151 printf("\n");
3152
3153 printf(" %-12s%-12s%-12s ", "C000-EFFF", rC000, wC000);
3154 printf("JishoRom Bank(0-31) = %d\n", jisho_rom_bank);
3155
3156 printf(" %-12s%-12s%-12s ", "F000-FFFF", rF000, wF000);
3157 printf("\n");
3158 }
monitor_set_key_printf(void)3159 static void monitor_set_key_printf(void) /*** set key ***/
3160 {
3161 int j;
3162 printf(" %-23s %-15s","key_scan[0]-[15]","(IN:00..0F)");
3163 for (j=0; j<0x8; j++) printf("%02X ", key_scan[j]);
3164 printf("\n");
3165 printf(" %-23s %-15s","","");
3166 for ( ; j<0x10; j++) printf("%02X ", key_scan[j]);
3167 printf("\n");
3168 }
monitor_set_palette_printf(void)3169 static void monitor_set_palette_printf(void) /*** set palette ***/
3170 {
3171 int j;
3172 const char *now = " [Pal-mode is ]";
3173 const char *pal = (misc_ctrl & MISC_CTRL_ANALOG)
3174 ? " [ *Analog*]"
3175 : " [ *Digital*]";
3176
3177 printf(" %-23s %-15sG:R:B = %01X:%01X:%01X\n",
3178 "vram_bg_palette",
3179 "(OUT:52/54)",
3180 vram_bg_palette.green,
3181 vram_bg_palette.red ,
3182 vram_bg_palette.blue);
3183
3184 for (j=0; j<8; j++) {
3185 printf(" %-23s (OUT:%02X) G:R:B = %01X:%01X:%01X\n",
3186 (j == 0) ? "vram_palette"
3187 : ((j == 2) ? now
3188 : ((j == 3) ? pal : "")),
3189 j + 0x54,
3190 vram_palette[j].green,
3191 vram_palette[j].red ,
3192 vram_palette[j].blue);
3193 }
3194 }
monitor_set_crtc_printf(void)3195 static void monitor_set_crtc_printf(void) /*** set crtc ***/
3196 {
3197 int j;
3198 const char *dmamode[] = { "(burst)", "(character)" };
3199 const char *blinktime[] = { "(x3)", "(x1.5)", "(x1)", "(x0.75)" };
3200 const char *skipline[] = { "(normal)", "(skip)" };
3201 const char *cursortype[] = { "(noblink, underline)", "(blink, underline)",
3202 "(noblink, block)", "(blink, block)" };
3203 const char *lineschar[] = { "(forbid)","(forbid)","","","","","",
3204 "(200line, 25row)","","(200line, 20row)","","","",
3205 "","","(400line, 25row)","","","","(400line, 20row)",
3206 "","","","","","","","","","","","",};
3207 const char *vwide[] = { "", "(400line, 20row)", "(400line, 25row)", "",
3208 "", "(200line, 20row)", "(200line, 25row)", "" };
3209 const char *hwide[] = { "(forbid)", "(forbid)", "(forbid)", "(forbid)","",
3210 "","","","","","","","","","","","","","","","","","",
3211 "","(400line)","","","","","","(200line)","",};
3212 const char *attr[] = { "(mono, sepatare, o)","(no-attr, x)",
3213 "(color, sepatare, o)","(forbid)","(mono, mixed, o)",
3214 "(mono, mixed, x)","(forbid)","(forbid)" };
3215
3216 printf(" CRTC & DMAC internal variable\n");
3217
3218 printf(" %-38s%s\n",
3219 "CRTC active", (crtc_active) ? "Yes" : "No");
3220 printf(" %-38s%02x\n",
3221 "Interrupt mask", crtc_intr_mask);
3222 printf(" %-38s%s\n",
3223 "Reverse", (crtc_reverse_display) ? "Yes" : "No");
3224 printf(" %-38s%s\n",
3225 "Line Skip", (crtc_skip_line) ? "Yes" : "No");
3226 printf(" %-38s%02XH(%d) , %02XH(%d)\n",
3227 "Cursor position[X,Y]",
3228 crtc_cursor[0], crtc_cursor[0], crtc_cursor[1], crtc_cursor[1]);
3229
3230
3231 printf(" Format[0] %02XH ", crtc_format[0]);
3232 j = crtc_format[0] >> 7;
3233 printf("C-------:DMA mode %2d %s\n", j, dmamode[ j ]);
3234 printf(" ");
3235 j = (crtc_format[0] & 0x7f) + 2;
3236 printf("-HHHHHHH:chars/line %2d\n", j);
3237
3238 printf(" Format[1] %02XH ", crtc_format[1]);
3239 j = crtc_format[1] >> 6;
3240 printf("BB------:blink time %2d %s\n", j, blinktime[ j ]);
3241 printf(" ");
3242 j = (crtc_format[1] & 0x3f) + 1;
3243 printf("--LLLLLL:lines/screen %2d\n", j);
3244
3245 printf(" Format[2] %02XH ", crtc_format[2]);
3246 j = crtc_format[2] >> 7;
3247 printf("S-------:skip line %2d %s\n", j, skipline[ j ]);
3248 printf(" ");
3249 j = (crtc_format[2] >> 5) & 0x03;
3250 printf("-CC-----:cursor type %2d %s\n", j, cursortype[ j ]);
3251 printf(" ");
3252 j = (crtc_format[2] & 0x1f) + 1;
3253 printf("---RRRRR:lines/char %2d\n", j);
3254
3255 printf(" Format[3] %02XH ", crtc_format[3]);
3256 j = (crtc_format[3] >> 5);
3257 printf("VVV-----:v wide(line) %2d %s\n", j+1, vwide[ j ]);
3258 printf(" ");
3259 j = (crtc_format[3] & 0x1f);
3260 printf("---ZZZZZ:h wide(char) %2d %s\n", j+2, hwide[ j ]);
3261
3262 printf(" Format[4] %02XH ", crtc_format[4]);
3263 j = (crtc_format[4] >> 5);
3264 printf("TTT-----:attr type %2d %s\n", j, attr[ j ]);
3265 printf(" ");
3266 j = (crtc_format[4] & 0x1f) + 1;
3267 printf("---AAAAA:attr size %2d\n", j);
3268
3269 for (j=0; j<4; j++) {
3270 printf(" %-23s Ch.%d%-11s %04XH .. +%04XH, %s\n",
3271 (j==0)?" DMAC addr/cntr/mode":"", j,"",
3272 dmac_address[j].W, dmac_counter[j].W & 0x3fff,
3273 ((dmac_counter[j].W & 0xc000) == 0x0000) ? "Verify":
3274 (((dmac_counter[j].W & 0xc000) == 0x4000) ? "Write":
3275 (((dmac_counter[j].W & 0xc000) == 0x8000) ? "Read":"BAD"))
3276 );
3277 }
3278 printf(" %-23s %-15s %02X (%X%X%X%X%X%X%X%X)\n",
3279 "", "Mode",
3280 dmac_mode,
3281 (dmac_mode >> 7) & 0x01, (dmac_mode >> 6) & 0x01,
3282 (dmac_mode >> 5) & 0x01, (dmac_mode >> 4) & 0x01,
3283 (dmac_mode >> 3) & 0x01, (dmac_mode >> 2) & 0x01,
3284 (dmac_mode >> 1) & 0x01, (dmac_mode >> 0) & 0x01
3285 );
3286 printf(" %-23s %-15s %s\n",
3287 " text_display", "",
3288 (text_display == TEXT_DISABLE) ? "TEXT_DISABLE"
3289 :((text_display == TEXT_ENABLE) ? "TEXT_ENABLE"
3290 :"TEXT_ATTR_ONLY"));
3291 }
monitor_set_pio_printf(void)3292 static void monitor_set_pio_printf(void) /*** set pio ***/
3293 {
3294 printf(
3295 " pio_AB[0][0].type %s ___ ___ %s pio_AB[1][0].type\n",
3296 (pio_AB[0][0].type == PIO_READ) ? "R" : "W",
3297 (pio_AB[1][0].type == PIO_READ) ? "R" : "W");
3298
3299 printf(
3300 " .exist %s \\ / %s .exist\n",
3301 (pio_AB[0][0].exist == PIO_EXIST) ? "*" : "-",
3302 (pio_AB[1][0].exist == PIO_EXIST) ? "*" : "-");
3303
3304 printf(
3305 " .data %02XH \\/ %02XH .data\n",
3306 (pio_AB[0][0].data),
3307 (pio_AB[1][0].data));
3308
3309 printf(" /\\\n");
3310
3311 printf(
3312 " pio_AB[0][1].type %s ___/ \\___ %s pio_AB[1][1].type\n",
3313 (pio_AB[0][1].type == PIO_READ) ? "R" : "W",
3314 (pio_AB[1][1].type == PIO_READ) ? "R" : "W");
3315
3316 printf(
3317 " .exist %s %s .exist\n",
3318 (pio_AB[0][1].exist == PIO_EXIST) ? "*" : "-",
3319 (pio_AB[1][1].exist == PIO_EXIST) ? "*" : "-");
3320
3321 printf(
3322 " .data %02XH %02XH .data\n",
3323 (pio_AB[0][1].data),
3324 (pio_AB[1][1].data));
3325
3326 printf(
3327 " \n");
3328
3329 printf(" \n");
3330
3331 printf(
3332 " pio_C[0][0].type %s ___ ___ %s pio_C[1][0].type\n",
3333 (pio_C[0][0].type == PIO_READ) ? "R" : "W",
3334 (pio_C[1][0].type == PIO_READ) ? "R" : "W");
3335
3336 printf(
3337 " .data %02XH \\ / %02XH .data\n",
3338 (pio_C[0][0].data),
3339 (pio_C[1][0].data));
3340
3341 printf(
3342 " .cont_f % 2d \\/ % 2d .cont_f\n",
3343 (pio_C[0][0].cont_f),
3344 (pio_C[1][0].cont_f));
3345
3346 printf(" /\\\n");
3347
3348 printf(
3349 " pio_C[0][1].type %s ___/ \\___ %s pio_C[1][1].type\n",
3350 (pio_C[0][1].type == PIO_READ) ? "R" : "W",
3351 (pio_C[1][1].type == PIO_READ) ? "R" : "W");
3352
3353 printf(
3354 " .data %02XH %02XH .data\n",
3355 (pio_C[0][1].data),
3356 (pio_C[1][1].data));
3357
3358 printf(
3359 " .cont_f % 2d % 2d .cont_f\n",
3360 (pio_C[0][1].cont_f),
3361 (pio_C[1][1].cont_f));
3362 }
3363
3364
3365 #ifdef USE_SOUND
monitor_set_volume_printf(int index)3366 static void monitor_set_volume_printf(int index)
3367 {
3368 if (xmame_has_mastervolume()) {
3369 printf(" %-23s %-15s %d\n",
3370 monitor_variable[index].var_name,
3371 monitor_variable[index].port_mes,
3372 xmame_cfg_get_mastervolume());
3373 } else {
3374 printf(" %-23s %-15s --\n",
3375 monitor_variable[index].var_name, "");
3376 }
3377 }
monitor_set_fmmixer_printf(int index)3378 static void monitor_set_fmmixer_printf(int index)
3379 {
3380 printf(" %-23s %-15s %d\n",
3381 monitor_variable[index].var_name,
3382 monitor_variable[index].port_mes,
3383 xmame_cfg_get_mixer_volume(XMAME_MIXER_FM));
3384 }
monitor_set_psgmixer_printf(int index)3385 static void monitor_set_psgmixer_printf(int index)
3386 {
3387 printf(" %-23s %-15s %d\n",
3388 monitor_variable[index].var_name,
3389 monitor_variable[index].port_mes,
3390 xmame_cfg_get_mixer_volume(XMAME_MIXER_PSG));
3391 }
monitor_set_beepmixer_printf(int index)3392 static void monitor_set_beepmixer_printf(int index)
3393 {
3394 printf(" %-23s %-15s %d\n",
3395 monitor_variable[index].var_name,
3396 monitor_variable[index].port_mes,
3397 xmame_cfg_get_mixer_volume(XMAME_MIXER_BEEP));
3398 }
monitor_set_rhythmmixer_printf(int index)3399 static void monitor_set_rhythmmixer_printf(int index)
3400 {
3401 printf(" %-23s %-15s %d\n",
3402 monitor_variable[index].var_name,
3403 monitor_variable[index].port_mes,
3404 xmame_cfg_get_mixer_volume(XMAME_MIXER_RHYTHM));
3405 }
monitor_set_adpcmmixer_printf(int index)3406 static void monitor_set_adpcmmixer_printf(int index)
3407 {
3408 printf(" %-23s %-15s %d\n",
3409 monitor_variable[index].var_name,
3410 monitor_variable[index].port_mes,
3411 xmame_cfg_get_mixer_volume(XMAME_MIXER_ADPCM));
3412 }
3413 #ifdef USE_FMGEN
monitor_set_fmgenmixer_printf(int index)3414 static void monitor_set_fmgenmixer_printf(int index)
3415 {
3416 printf(" %-23s %-15s %d\n",
3417 monitor_variable[index].var_name,
3418 monitor_variable[index].port_mes,
3419 xmame_cfg_get_mixer_volume(XMAME_MIXER_FMGEN));
3420 }
3421 #endif
monitor_set_samplemixer_printf(int index)3422 static void monitor_set_samplemixer_printf(int index)
3423 {
3424 printf(" %-23s %-15s %d\n",
3425 monitor_variable[index].var_name,
3426 monitor_variable[index].port_mes,
3427 xmame_cfg_get_mixer_volume(XMAME_MIXER_SAMPLE));
3428 }
monitor_set_mixer_printf(void)3429 static void monitor_set_mixer_printf(void)
3430 {
3431 if (xmame_has_sound()) {
3432 printf("\n Following is mixing level of xmame-sound-driver.\n");
3433 xmame_cfg_set_mixer_volume(-1, -1);
3434 }
3435 }
3436
monitor_set_volume(int vol)3437 static void monitor_set_volume(int vol)
3438 {
3439 xmame_cfg_set_mastervolume(vol);
3440 }
monitor_set_fmmixer(int vol)3441 static void monitor_set_fmmixer(int vol)
3442 {
3443 xmame_cfg_set_mixer_volume(XMAME_MIXER_FM, vol);
3444 }
monitor_set_psgmixer(int vol)3445 static void monitor_set_psgmixer(int vol)
3446 {
3447 xmame_cfg_set_mixer_volume(XMAME_MIXER_PSG, vol);
3448 }
monitor_set_beepmixer(int vol)3449 static void monitor_set_beepmixer(int vol)
3450 {
3451 xmame_cfg_set_mixer_volume(XMAME_MIXER_BEEP, vol);
3452 }
monitor_set_rhythmmixer(int vol)3453 static void monitor_set_rhythmmixer(int vol)
3454 {
3455 xmame_cfg_set_mixer_volume(XMAME_MIXER_RHYTHM, vol);
3456 }
monitor_set_adpcmmixer(int vol)3457 static void monitor_set_adpcmmixer(int vol)
3458 {
3459 xmame_cfg_set_mixer_volume(XMAME_MIXER_ADPCM, vol);
3460 }
3461 #ifdef USE_FMGEN
monitor_set_fmgenmixer(int vol)3462 static void monitor_set_fmgenmixer(int vol)
3463 {
3464 xmame_cfg_set_mixer_volume(XMAME_MIXER_FMGEN, vol);
3465 }
3466 #endif
monitor_set_samplemixer(int vol)3467 static void monitor_set_samplemixer(int vol)
3468 {
3469 xmame_cfg_set_mixer_volume(XMAME_MIXER_SAMPLE, vol);
3470 }
3471 #endif /* USE_SOUND */
3472
monitor_set_show_printf(int index)3473 static void monitor_set_show_printf(int index) /*** set (print) ***/
3474 {
3475 int val;
3476
3477 switch (monitor_variable[index].var_type) {
3478
3479 case MTYPE_INT:
3480 case MTYPE_INT_C:
3481 case MTYPE_FONT:
3482 case MTYPE_FRAMESKIP:
3483 case MTYPE_INTERLACE:
3484 case MTYPE_INTERP:
3485 case MTYPE_BEEP:
3486 val = *((int *)monitor_variable[index].var_ptr);
3487 goto MTYPE_numeric_variable;
3488
3489 case MTYPE_BYTE:
3490 case MTYPE_BYTE_C:
3491 val = *((byte *)monitor_variable[index].var_ptr);
3492 goto MTYPE_numeric_variable;
3493
3494 case MTYPE_WORD:
3495 case MTYPE_WORD_C:
3496 val = *((word *)monitor_variable[index].var_ptr);
3497 goto MTYPE_numeric_variable;
3498
3499 MTYPE_numeric_variable:;
3500 printf(" %-23s %-15s %08XH (%d)\n",
3501 monitor_variable[index].var_name,
3502 monitor_variable[index].port_mes, val, val);
3503 break;
3504
3505 case MTYPE_DOUBLE:
3506 case MTYPE_DOUBLE_C:
3507 case MTYPE_CLOCK:
3508 printf(" %-23s %-15s %8.4f\n",
3509 monitor_variable[index].var_name,
3510 monitor_variable[index].port_mes,
3511 *((double *)monitor_variable[index].var_ptr));
3512 break;
3513
3514 case MTYPE_MEM:
3515 monitor_set_mem_printf();
3516 break;
3517 case MTYPE_KEY:
3518 monitor_set_key_printf();
3519 break;
3520 case MTYPE_PALETTE:
3521 monitor_set_palette_printf();
3522 break;
3523 case MTYPE_CRTC:
3524 monitor_set_crtc_printf();
3525 break;
3526 case MTYPE_PIO:
3527 monitor_set_pio_printf();
3528 break;
3529
3530 #ifdef USE_SOUND
3531 case MTYPE_VOLUME:
3532 monitor_set_volume_printf(index);
3533 break;
3534 case MTYPE_FMMIXER:
3535 monitor_set_fmmixer_printf(index);
3536 break;
3537 case MTYPE_PSGMIXER:
3538 monitor_set_psgmixer_printf(index);
3539 break;
3540 case MTYPE_BEEPMIXER:
3541 monitor_set_beepmixer_printf(index);
3542 break;
3543 case MTYPE_RHYTHMMIXER:
3544 monitor_set_rhythmmixer_printf(index);
3545 break;
3546 case MTYPE_ADPCMMIXER:
3547 monitor_set_adpcmmixer_printf(index);
3548 break;
3549 #ifdef USE_FMGEN
3550 case MTYPE_FMGENMIXER:
3551 monitor_set_fmgenmixer_printf(index);
3552 break;
3553 #endif
3554 case MTYPE_SAMPLEMIXER:
3555 monitor_set_samplemixer_printf(index);
3556 break;
3557 case MTYPE_MIXER:
3558 monitor_set_mixer_printf();
3559 break;
3560 #endif
3561
3562 case MTYPE_NEWLINE:
3563 printf("\n");
3564 break;
3565 }
3566 }
3567
3568
3569
3570
3571
3572
monitor_set(void)3573 static void monitor_set(void)
3574 {
3575 void *var_ptr;
3576 int set_type, index=0, value=0, i, block = 0;
3577 double dvalue = 0.0;
3578 int key_flag = 0;
3579
3580 set_type = 0;
3581 if (exist_argv()) {
3582
3583 for (index = 0; index < COUNTOF(monitor_variable_block); index++) {
3584 if (strcmp(argv.str, monitor_variable_block[index].block_name)==0)
3585 break;
3586 }
3587 if (index < COUNTOF(monitor_variable_block)) {
3588 block = TRUE;
3589 set_type = index;
3590 shift();
3591 } else {
3592
3593 for (index = 0; index < COUNTOF(monitor_variable); index++) {
3594 if (strcmp(argv.str, monitor_variable[index].var_name) == 0)
3595 break;
3596 }
3597 if (index == COUNTOF(monitor_variable)) error();
3598 shift();
3599 set_type = 1;
3600 if (exist_argv()) {
3601 if (argv_is(ARGV_INT)) {
3602 value = argv.val;
3603 dvalue = (double)argv.val;
3604 } else if (argv_is(ARGV_STR)) {
3605 if (monitor_variable[index].var_type != MTYPE_KEY) {
3606 char *chk;
3607 dvalue = strtod(argv.str, &chk);
3608 if (*chk != '\0') error();
3609 } else {
3610 if (argv.str[0] != '~') {
3611 error();
3612 }
3613 key_flag = 1;
3614 }
3615 } else {
3616 error();
3617 }
3618 shift();
3619 set_type = 2;
3620 }
3621 }
3622 }
3623
3624 if (exist_argv()) error();
3625
3626
3627 /*================*/
3628
3629 if (block) {
3630 index = 0;
3631 block = 0;
3632 for ( ; index < COUNTOF(monitor_variable); index++) {
3633 if (monitor_variable_block[set_type].start <= block &&
3634 block <= monitor_variable_block[set_type].end) {
3635 monitor_set_show_printf(index);
3636 }
3637 if (monitor_variable[index].var_type == MTYPE_NEWLINE) {
3638 block ++;
3639 }
3640 }
3641 return;
3642 }
3643
3644 switch (set_type) {
3645 case 0:
3646 for (index = 0; index < COUNTOF(monitor_variable); index++) {
3647 monitor_set_show_printf(index);
3648 }
3649 break;
3650
3651 case 1:
3652 monitor_set_show_printf(index);
3653 break;
3654
3655 case 2:
3656 var_ptr = monitor_variable[index].var_ptr;
3657 switch (monitor_variable[index].var_type) {
3658
3659 case MTYPE_INT_C:
3660 case MTYPE_BYTE_C:
3661 case MTYPE_WORD_C:
3662 case MTYPE_DOUBLE_C:
3663 printf("Sorry! This variable can't set value. \n");
3664 break;
3665
3666 case MTYPE_INT: *((int *)var_ptr) = value; break;
3667 case MTYPE_BYTE: *((byte *)var_ptr) = value; break;
3668 case MTYPE_WORD: *((word *)var_ptr) = value; break;
3669 case MTYPE_DOUBLE: *((double *)var_ptr) = dvalue; break;
3670
3671 case MTYPE_FONT:
3672 *((int *)var_ptr) = value;
3673 memory_set_font();
3674 screen_update_immidiate();
3675 break;
3676 case MTYPE_FRAMESKIP:
3677 quasi88_cfg_set_frameskip_rate(value);
3678 break;
3679 case MTYPE_INTERLACE:
3680 quasi88_cfg_set_interlace(value);
3681 screen_update_immidiate();
3682 break;
3683 case MTYPE_INTERP:
3684 quasi88_cfg_set_interp(value);
3685 screen_update_immidiate();
3686 break;
3687
3688 case MTYPE_CLOCK:
3689 *((double *)var_ptr) = dvalue;
3690 interval_work_init_all();
3691 break;
3692
3693 case MTYPE_BEEP:
3694 *((int *)var_ptr) = value;
3695 #ifdef USE_SOUND
3696 xmame_dev_beep_cmd_sing((byte) use_cmdsing);
3697 #endif
3698 break;
3699
3700
3701 case MTYPE_KEY:
3702 if (key_flag == 0) {
3703 for (i = 0; i < 0x10; i++) key_scan[i] = value;
3704 printf(" key_scan[0..15] = %d\n",value);
3705 } else {
3706 char c_new[16];
3707 char *p = &argv.str[1];
3708 int i, j, x;
3709 for (i = 0; i < (int)sizeof(c_new) && *p; i++) {
3710 for (j = 0; j < 2; j++) {
3711 x = -1;
3712 if ('0' <= *p && *p <= '9') x = *p - '0';
3713 else if ('a' <= *p && *p <= 'f') x = *p - 'a' + 10;
3714 else if ('A' <= *p && *p <= 'F') x = *p - 'A' + 10;
3715 p++;
3716 if ((*p == '\0' && j == 0) || x < 0) {
3717 goto set_key_break;
3718 }
3719 if (j == 0) c_new[i] = x * 16;
3720 else c_new[i] = (c_new[i] + x);
3721 }
3722 }
3723 if (*p) goto set_key_break;
3724
3725 for (j = 0; j < i; j++) {
3726 key_scan[j] = ~c_new[j];
3727 }
3728 monitor_set_show_printf(index);
3729 }
3730 break;
3731
3732 set_key_break:
3733 printf("Invalid parameter %s.\n", argv.str);
3734 break;
3735
3736 case MTYPE_MEM:
3737 case MTYPE_PALETTE:
3738 case MTYPE_CRTC:
3739 case MTYPE_PIO:
3740 printf("Sorry! This variable can't set value. "
3741 "(palette,crtc,pio, and so on)\n");
3742 break;
3743
3744 #ifdef USE_SOUND
3745 case MTYPE_VOLUME:
3746 monitor_set_volume(value);
3747 break;
3748 case MTYPE_FMMIXER:
3749 monitor_set_fmmixer(value);
3750 break;
3751 case MTYPE_PSGMIXER:
3752 monitor_set_psgmixer(value);
3753 break;
3754 case MTYPE_BEEPMIXER:
3755 monitor_set_beepmixer(value);
3756 break;
3757 case MTYPE_RHYTHMMIXER:
3758 monitor_set_rhythmmixer(value);
3759 break;
3760 case MTYPE_ADPCMMIXER:
3761 monitor_set_adpcmmixer(value);
3762 break;
3763 #ifdef USE_FMGEN
3764 case MTYPE_FMGENMIXER:
3765 monitor_set_fmgenmixer(value);
3766 break;
3767 #endif
3768 case MTYPE_SAMPLEMIXER:
3769 monitor_set_samplemixer(value);
3770 break;
3771 case MTYPE_MIXER:
3772 break;
3773 #endif
3774
3775 }
3776 break;
3777
3778 }
3779 }
3780
monitor_show(void)3781 static void monitor_show(void)
3782 {
3783 int set_type, index=0;
3784
3785 set_type = 0;
3786 if (exist_argv()) {
3787 for (index = 0; index < COUNTOF(monitor_variable); index++) {
3788 if (strcmp(argv.str, monitor_variable[index].var_name) == 0) break;
3789 }
3790 if (index == COUNTOF(monitor_variable)) error();
3791 shift();
3792 set_type = 1;
3793 }
3794
3795 if (exist_argv()) error();
3796
3797
3798 switch (set_type) {
3799 case 0:
3800 for (index = 0; index < COUNTOF(monitor_variable); index++) {
3801 monitor_set_show_printf(index);
3802 }
3803 break;
3804
3805 case 1:
3806 monitor_set_show_printf(index);
3807 break;
3808 }
3809 }
3810
3811
3812
3813
3814
3815 /*--------------------------------------------------------------*/
3816 /* resize <screen_size> */
3817 /* ���̥��������ѹ� */
3818 /*--------------------------------------------------------------*/
monitor_resize(void)3819 static void monitor_resize(void)
3820 {
3821 int command = -1;
3822
3823 if (exist_argv()) {
3824 if (! argv_is(ARGV_RESIZE)) error();
3825 command = argv.val;
3826 shift();
3827 }
3828
3829 if (exist_argv()) error();
3830
3831
3832 /*================*/
3833
3834 switch (command) {
3835 case -1: /* resize */
3836 quasi88_cfg_set_size_large();
3837 break;
3838 case ARG_FULL: /* resize full */
3839 quasi88_cfg_set_size(SCREEN_SIZE_FULL);
3840 break;
3841 case ARG_HALF: /* resize half */
3842 quasi88_cfg_set_size(SCREEN_SIZE_HALF);
3843 break;
3844 case ARG_DOUBLE: /* resize double */
3845 #ifdef SUPPORT_DOUBLE
3846 quasi88_cfg_set_size(SCREEN_SIZE_DOUBLE);
3847 #endif
3848 break;
3849 case ARG_FULLSCREEN: /* resize fullscreen */
3850 if (quasi88_cfg_can_fullscreen()) {
3851 quasi88_cfg_set_fullscreen(TRUE);
3852 }
3853 break;
3854 case ARG_WINDOW: /* resize window */
3855 if (quasi88_cfg_now_fullscreen()) {
3856 quasi88_cfg_set_fullscreen(FALSE);
3857 }
3858 break;
3859 }
3860
3861 screen_update_immidiate();
3862
3863 return;
3864 }
3865
3866
3867
3868
3869
3870 /*--------------------------------------------------------------*/
3871 /* drive [show] */
3872 /* drive eject [<drive_no>] */
3873 /* drive empty <drive_no> */
3874 /* drive set <drive_no> <filename > */
3875 /* �ɥ饤�ִ�Ϣ���� */
3876 /* �ɥ饤�֤����ꤵ�줿�ե�����ξ��֤� */
3877 /* �ɥ饤�֤���ˤ��� */
3878 /* �ɥ饤�֤���Ū�˶��ˤ��� */
3879 /* �ɥ饤�֤˥ե�����å�(��) */
3880 /*--------------------------------------------------------------*/
monitor_drive(void)3881 static void monitor_drive(void)
3882 {
3883 int i, j, command, drv = -1, img = 0;
3884 char *filename = NULL;
3885
3886 if (! exist_argv()) {
3887 command = ARG_SHOW;
3888 } else {
3889
3890 if (! argv_is(ARGV_DRIVE)) error(); /* <command> */
3891 command = argv.val;
3892 shift();
3893
3894 switch (command) {
3895 case ARG_SHOW: /* show */
3896 break;
3897 case ARG_EJECT: /* eject */
3898 if (exist_argv()) {
3899 if (! argv_is(ARGV_DRV)) error(); /* [<drive_no>] */
3900 drv = argv.val-1;
3901 shift();
3902 }
3903 break;
3904 case ARG_EMPTY: /* empty */
3905 if (! argv_is(ARGV_DRV)) error(); /* <drive_no> */
3906 drv = argv.val-1;
3907 shift();
3908 break;
3909 case ARG_SET: /* set */
3910 if (! argv_is(ARGV_DRV)) error(); /* <drive_no> */
3911 drv = argv.val-1;
3912 shift();
3913 if (! exist_argv()) error(); /* <filename> */
3914 filename = argv.str;
3915 shift();
3916 if (exist_argv()) {
3917 if (! argv_is(ARGV_IMG)) error(); /* [<image_no>] */
3918 img = argv.val-1;
3919 shift();
3920 }
3921 break;
3922 }
3923
3924 }
3925 if (exist_argv()) error();
3926
3927
3928 /*================*/
3929
3930 switch (command) {
3931 case ARG_SHOW: /* drive show */
3932 for (i = 0; i < NR_DRIVE; i++) {
3933 printf("DRIVE %d: lamp[ %s ]%s\n",
3934 i + 1, get_drive_ready(i) ? " " : "#",
3935 (drive[i].fp && drive[i].empty) ? " ..... *** Empty ***"
3936 : "");
3937 if (disk_image_exist(i)) {
3938 /*printf(" filename = %s\n", drive[i].filename);*/
3939 printf(" filename = %s\n", filename_get_disk(i));
3940 printf(" FILE *fp = %p : read only? = %s\n",
3941 (void *)drive[i].fp,
3942 (drive[i].read_only) ? "Read Only" : "Read Write");
3943 printf(" Selected image No = %d/%d%s : protect = %s : media = %s\n",
3944 drive[i].selected_image + 1,
3945 drive[i].image_nr,
3946 (drive[i].detect_broken_image) ? " + broken"
3947 : ((drive[i].over_image) ? " + alpha "
3948 : " "),
3949 (drive[i].protect == DISK_PROTECT_TRUE) ? "RO" : "RW",
3950 (drive[i].type == DISK_TYPE_2HD) ? "2HD"
3951 : ((drive[i].type == DISK_TYPE_2DD) ? "2DD"
3952 : "2D"));
3953 printf(" ------------------------------------------\n");
3954 for (j = 0; j < drive[i].image_nr; j++) {
3955 printf(" %s% 3d %-17s %s %s %ld\n",
3956 (j == drive[i].selected_image) ? "*" : " ",
3957 j + 1,
3958 drive[i].image[j].name,
3959 (drive[i].image[j].protect
3960 == DISK_PROTECT_TRUE) ? "RO"
3961 : ((drive[i].image[j].protect
3962 == DISK_PROTECT_FALSE) ? "RW"
3963 : "??"),
3964 (drive[i].image[j].type
3965 == DISK_TYPE_2D) ? "2D "
3966 : ((drive[i].image[j].type
3967 == DISK_TYPE_2DD) ? "2DD"
3968 : ((drive[i].image[j].type
3969 == DISK_TYPE_2HD) ? "2HD"
3970 : "???")),
3971 drive[i].image[j].size);
3972 }
3973 }
3974 printf("\n");
3975 }
3976 break;
3977 case ARG_EMPTY: /* drive empty n */
3978 if (disk_image_exist(drv)) {
3979 drive_change_empty(drv);
3980 if (drive_check_empty(drv))
3981 printf("** Set DRIVE %d: Empty **\n", drv + 1);
3982 else
3983 printf("** Unset DRIVE %d: Empty **\n", drv + 1);
3984 }
3985 break;
3986 case ARG_EJECT:
3987 switch (drv) {
3988 case 0: /* drive eject 0 */
3989 case 1: /* drive eject 1 */
3990 if (disk_image_exist(drv)) {
3991 quasi88_disk_eject(drv);
3992 printf("-- Disk Eject from DRIVE %d: --\n", drv + 1);
3993 }
3994 break;
3995 default: /* drive eject */
3996 for (i = 0; i < 2; i++) {
3997 if (disk_image_exist(i)) {
3998 quasi88_disk_eject(i);
3999 printf("-- Disk Eject from DRIVE %d: --\n", i + 1);
4000 }
4001 }
4002 break;
4003 }
4004 break;
4005 case ARG_SET: /* drive set x yyy z */
4006 if (strcmp(filename, "-") == 0) {
4007 switch (disk_change_image(drv, img)) {
4008 case 0: /* OK */
4009 printf("== Image change in DRIVE %d: ==\n", drv + 1);
4010 printf(" image number ->[%d]\n", img + 1);
4011 break;
4012 case 1: /* no disk */
4013 printf("** Disk not exist in DRIVE:%d **\n", drv + 1);
4014 break;
4015 case 2: /* no image */
4016 printf("** Image number %d is not exist in DRIVE:%d **\n",
4017 img + 1, drv + 1);
4018 break;
4019 }
4020 } else {
4021 if (disk_image_exist(drv)) {
4022 quasi88_disk_eject(drv);
4023 printf("-- Disk Eject from DRIVE %d: --\n", drv + 1);
4024 }
4025 if (quasi88_disk_insert(drv, filename, img, FALSE)) { /* Success */
4026 printf("== Disk insert to DRIVE %d: ==\n", drv + 1);
4027 printf(" file ->[%s] image number ->[%d]\n",
4028 filename, img + 1);
4029 } else { /* Failed */
4030 printf("** Disk %s can't insert **\n", filename);
4031 }
4032 }
4033 break;
4034 }
4035
4036
4037 return;
4038 }
4039
4040
4041
4042 /*--------------------------------------------------------------*/
4043 /* file show <filename> */
4044 /* file create <filename> */
4045 /* file protect <filename> <image_no> */
4046 /* file unprotect <filename> <image_no> */
4047 /* file format <filename> <image_no> */
4048 /* file unformat <filename> <image_no> */
4049 /* file rename <filename> <image_no> <image_name> */
4050 /* �ե������Ϣ���� */
4051 /* �ե������ */
4052 /* �֥�������ե�������ɲ�(����) */
4053 /* ������Υ饤�ȥץ�ƥ��Ȥ����� */
4054 /* ������Υ饤�ȥץ�ƥ��Ȥ��� */
4055 /* �������ե����ޥå� */
4056 /* �������ե����ޥå� */
4057 /* �����̾���ѹ� */
4058 /*--------------------------------------------------------------*/
monitor_file(void)4059 static void monitor_file(void)
4060 {
4061 int command, num, drv, img = 0, result = -1, ro = FALSE;
4062 char *filename, *imagename = NULL;
4063 long offset;
4064 OSD_FILE *fp;
4065 Uchar c[32];
4066 char *s = NULL;
4067
4068
4069
4070 if (! argv_is(ARGV_FILE)) error(); /* <command> */
4071 command = argv.val;
4072 shift();
4073
4074 if (! exist_argv()) error(); /* <filename> */
4075 filename = argv.str;
4076 shift();
4077
4078 switch (command) {
4079 case ARG_SHOW: /* show */
4080 case ARG_CREATE: /* create */
4081 break;
4082 case ARG_PROTECT: /* protect */
4083 case ARG_UNPROTECT: /* unprotect */
4084 case ARG_FORMAT: /* format */
4085 case ARG_UNFORMAT: /* unformat */
4086 if (! argv_is(ARGV_IMG)) error(); /* <image_no> */
4087 img = argv.val - 1;
4088 shift();
4089 break;
4090 case ARG_RENAME: /* rename */
4091 if (! argv_is(ARGV_IMG)) error(); /* <image_no> */
4092 img = argv.val - 1;
4093 shift();
4094 if (! exist_argv()) error();
4095 imagename = argv.str; /* <imagename> */
4096 shift();
4097 break;
4098 }
4099
4100 if (exist_argv()) error();
4101
4102
4103 /*================*/
4104
4105 switch (command) {
4106 case ARG_SHOW:
4107 if ((fp = osd_fopen(FTYPE_DISK, filename, "rb")) == NULL) {
4108 if ((fp = osd_fopen(FTYPE_DISK, filename, "r+b")) == NULL) {
4109 printf("Open error! %s\n", filename);
4110 break;
4111 }
4112 }
4113
4114 offset = -1;
4115 if (osd_fseek(fp, 0, SEEK_END) == 0) {
4116 offset = osd_ftell(fp);
4117 }
4118
4119 printf("filename = %s size = %ld\n", filename, offset);
4120 printf(" -No------Name-----------R/W-Type---Size--\n");
4121 offset = 0;
4122 num = 0;
4123 while ((result = d88_read_header(fp, offset, c)) == 0) {
4124 c[16] = '\0';
4125 printf(" % 3d %-17s %s %s %ld\n",
4126 num + 1,
4127 c,
4128 (c[DISK_PROTECT] == DISK_PROTECT_TRUE) ? "RO"
4129 : ((c[DISK_PROTECT] == DISK_PROTECT_FALSE) ? "RW"
4130 : "??"),
4131 (c[DISK_TYPE] == DISK_TYPE_2D) ? "2D "
4132 : ((c[DISK_TYPE] == DISK_TYPE_2DD) ? "2DD"
4133 : ((c[DISK_TYPE] == DISK_TYPE_2HD) ? "2HD"
4134 : "???")),
4135 READ_SIZE_IN_HEADER(c));
4136 offset += READ_SIZE_IN_HEADER(c);
4137 num++;
4138 if (num > 255) { result = -1; break; }
4139 }
4140 printf("\n");
4141 switch (result) {
4142 case -1: printf("Image number too many (over 255)\n");break;
4143 case D88_SUCCESS: break;
4144 case D88_NO_IMAGE: break;
4145 case D88_BAD_IMAGE:printf("Image No. %d is broken\n", num + 1); break;
4146 case D88_ERR_SEEK: printf("Seek Error\n"); break;
4147 case D88_ERR_READ: printf("Read Error\n"); break;
4148 default: printf("Internal Error\n");
4149 }
4150 if (drive[0].fp != fp && drive[1].fp != fp) osd_fclose(fp);
4151 break;
4152
4153
4154 case ARG_CREATE:
4155 case ARG_PROTECT:
4156 case ARG_UNPROTECT:
4157 case ARG_FORMAT:
4158 case ARG_UNFORMAT:
4159 case ARG_RENAME:
4160
4161 /* �ե������ */
4162 fp = osd_fopen(FTYPE_DISK, c, "r+b"); /* "r+b" �ǥ����ץ� */
4163 if (fp == NULL) {
4164 fp = osd_fopen(FTYPE_DISK, c, "rb"); /* "rb" �ǥ����ץ� */
4165 ro = TRUE;
4166 }
4167
4168 if (fp) { /* �����ץ�Ǥ����� */
4169 if (fp == drive[ 0 ].fp) drv = 0; /* ���Ǥ˥ɥ饤�֤� */
4170 else if (fp == drive[ 1 ].fp) drv = 1; /* �����Ƥʤ����� */
4171 else drv = -1; /* ��������� */
4172 }
4173
4174
4175 if (fp == NULL) { /* �����ץ��� */
4176 printf("Open error! %s\n", filename);
4177 break;
4178 }
4179 else if (ro) { /* ��ɥ����ʤΤǽ����Բ� */
4180 if (drv < 0) osd_fclose(fp);
4181 printf("File %s is read only", filename);
4182 if (drv < 0) printf("\n");
4183 else printf("(in DRIVE %d:)\n", drv + 1);
4184 break;
4185 }
4186 else if (drv >= 0 && /* ���줿��������ޤޤ��Τ��Բ� */
4187 drive[ drv ].detect_broken_image) {
4188 printf("Warning! File %s maybe be broken!"
4189 " ..... continued, but not update drive status.\n",
4190 filename);
4191 }
4192
4193
4194 /* ���ޥ���̽��� */
4195 switch (command) {
4196 case ARG_CREATE:
4197 result = d88_append_blank(fp, drv);
4198 s = "Create blank image";
4199 break;
4200 case ARG_PROTECT:
4201 c[0] = DISK_PROTECT_TRUE;
4202 result = d88_write_protect(fp, drv, img, (char*)c);
4203 s = "Set Protect";
4204 break;
4205 case ARG_UNPROTECT:
4206 c[0] = DISK_PROTECT_FALSE;
4207 result = d88_write_protect(fp, drv, img, (char*)c);
4208 s = "Unset Protect";
4209 break;
4210 case ARG_FORMAT:
4211 result = d88_write_format(fp, drv, img);
4212 s = "Format";
4213 break;
4214 case ARG_UNFORMAT:
4215 result = d88_write_unformat(fp, drv, img);
4216 s = "Unformat";
4217 break;
4218 case ARG_RENAME:
4219 strncpy((char *)c, imagename, 17);
4220 result = d88_write_name(fp, drv, img, (char*)c);
4221 s = "Rename image";
4222 break;
4223 }
4224 /* ���顼ɽ�� */
4225 switch (result) {
4226 case D88_SUCCESS: printf("%s complete.\n", s); break;
4227 case D88_NO_IMAGE: printf("Image No. %d not exist.\n", img + 1);break;
4228 case D88_BAD_IMAGE: printf("Image No. %d is broken.\n", img + 1);break;
4229 case D88_MANY_IMAGE:printf("Image number over\n"); break;
4230 case D88_ERR_SEEK: printf("Seek Error\n"); break;
4231 case D88_ERR_WRITE: printf("Write error\n"); break;
4232 case D88_ERR_READ: printf("Read error\n"); break;
4233 case D88_ERR: printf("Internal error\n"); break;
4234 }
4235
4236 /* ����� */
4237 if (drv < 0) {
4238 osd_fclose(fp);
4239 } else {
4240 if (result != D88_SUCCESS) {
4241 printf("Fatal error in File %s ( in DRIVE %d: )\n",
4242 filename, drv + 1);
4243 printf("File %s maybe be broken.\n", filename);
4244 }
4245 }
4246 break;
4247 }
4248
4249 return;
4250 }
4251
4252
4253
4254 /*--------------------------------------------------------------*/
4255 /* statesave [<filename>] */
4256 /* ���ơ��ȥ����� */
4257 /*--------------------------------------------------------------*/
monitor_statesave(void)4258 static void monitor_statesave(void)
4259 {
4260 char *filename = NULL;
4261
4262 if (exist_argv()) {
4263 filename = argv.str;
4264 shift();
4265 if (exist_argv()) error();
4266 } else {
4267 filename = NULL;
4268 }
4269
4270 if (filename) {
4271 if (strlen(filename) >= QUASI88_MAX_FILENAME) {
4272 printf("filename too long\n");
4273 return;
4274 }
4275 filename_set_state(filename);
4276 }
4277
4278 if (quasi88_statesave(-1)) {
4279 printf("statesave succsess\n"
4280 " state-file = %s\n", filename_get_state());
4281 } else {
4282 printf("statesave failed\n");
4283 }
4284 return;
4285 }
4286
4287
4288
4289 /*--------------------------------------------------------------*/
4290 /* stateload [<filename>] */
4291 /* ���ơ��ȥ��� */
4292 /*--------------------------------------------------------------*/
monitor_stateload(void)4293 static void monitor_stateload(void)
4294 {
4295 char *filename = NULL;
4296
4297 if (exist_argv()) {
4298 filename = argv.str;
4299 shift();
4300 if (exist_argv()) error();
4301 } else {
4302 filename = NULL;
4303 }
4304
4305 if (filename) {
4306 if (strlen(filename) >= QUASI88_MAX_FILENAME) {
4307 printf("filename too long\n");
4308 return;
4309 }
4310 filename_set_state(filename);
4311 }
4312
4313 if (stateload_check_file_exist() == FALSE) {
4314 printf("state-file \"%s\" not exist or broken\n",
4315 filename_get_state());
4316 } else {
4317 if (quasi88_stateload(-1)) {
4318 printf("stateload succsess\n"
4319 " state-file = %s\n", filename_get_state());
4320 quasi88_exec();
4321 } else {
4322 printf("stateload failed\n");
4323 }
4324 }
4325 return;
4326 }
4327
4328
4329
4330 /*--------------------------------------------------------------*/
4331 /* snapshot */
4332 /* ������ʥåץ���åȤ���¸ */
4333 /*--------------------------------------------------------------*/
monitor_snapshot(void)4334 static void monitor_snapshot(void)
4335 {
4336 int format = -1;
4337
4338 if (exist_argv()) {
4339 if (! argv_is(ARGV_SNAPSHOT)) error();
4340 format = argv.val;
4341 shift();
4342 if (exist_argv()) error();
4343 } else {
4344 format = -1;
4345 }
4346
4347 switch (format) {
4348 case ARG_BMP: snapshot_format = 0; break;
4349 case ARG_PPM: snapshot_format = 1; break;
4350 case ARG_RAW: snapshot_format = 2; break;
4351 }
4352
4353 if (screen_snapshot_save() == 0) {
4354 printf("save-snapshot failed\n");
4355 }
4356 return;
4357 }
4358
4359
4360
4361 /*--------------------------------------------------------------*/
4362 /* loadfont <filename> <format> <type> */
4363 /* �ե���ȥե�����Υ��� */
4364 /*--------------------------------------------------------------*/
monitor_loadfont(void)4365 static void monitor_loadfont(void)
4366 {
4367 char *filename = NULL;
4368 int format = 0;
4369 int type = 0;
4370
4371 if (! exist_argv()) error(); /* <filename> */
4372 filename = argv.str;
4373 shift();
4374
4375 if (! exist_argv() || /* <format> */
4376 ! argv_is(ARGV_INT)) error();
4377 format = argv.val;
4378 if (! BETWEEN(0, format, 2)) error();
4379 shift();
4380
4381 if (! exist_argv() || /* <type> */
4382 ! argv_is(ARGV_INT)) error();
4383 type = argv.val;
4384 if (! BETWEEN(0, type, 3)) error();
4385 shift();
4386
4387 if (exist_argv()) error();
4388
4389
4390 {
4391 static const int rev[] = { 0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe,
4392 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf };
4393 int c, i, j, k, l, n;
4394 int result;
4395 FILE *fp;
4396 bit8 *font;
4397
4398 if (type == 1) font = font_mem;
4399 else if (type == 2) font = font_mem2;
4400 else if (type == 3) font = font_mem3;
4401 else font = font_pcg;
4402
4403 fp = fopen(filename, (format == 0) ? "rb" : "r");
4404
4405 if (fp) {
4406
4407 if (format == 0) {
4408
4409 if (fread(font, sizeof(byte), 8*256, fp) != 8 * 256) {
4410 printf("file [%s] read error\n", filename);
4411 }
4412
4413 } else {
4414 /* #define font_width 128 */
4415 result = fscanf(fp, "#define %*s %d\n", &c);
4416 if (result != 1 || c != 128) goto ERR;
4417 /* #define font_height 128 */
4418 result = fscanf(fp, "#define %*s %d\n", &c);
4419 if (result != 1 || c != 128) goto ERR;
4420 /* static unsigned char font_bits[] = { */
4421 result = fscanf(fp, "%*[^]]%*[^=]%*[^{]{");
4422 if (result != 0) goto ERR;
4423
4424 l = 0;
4425 for (k = 0; k < 16; k++) {
4426 for (j = 0; j < 8; j++) {
4427 for (i = 0; i < 16; i++) {
4428
4429 result = fscanf(fp, "%i", &c); /* 0xnn */
4430 if (result != 1) goto ERR;
4431
4432 c = ((rev[ c & 0xf ]) << 4) | (rev[ c >> 4 ]);
4433 if (format == 1) n = (k * 16 + i) * 8 + j;
4434 else n = (i * 16 + k) * 8 + j;
4435 font[ n ] = c & 0xff;
4436
4437 if (l < 8 * 256) {
4438 result = fscanf(fp, "%*[^1234567890]"); /* , */
4439 if (result != 0) goto ERR;
4440 }
4441 l++;
4442 }
4443 }
4444 }
4445 }
4446
4447 fclose(fp);
4448 screen_update_immidiate();
4449
4450 } else {
4451 printf("file [%s] can't open\n", filename);
4452 }
4453
4454 return;
4455
4456 ERR:
4457 printf("file [%s] read error\n", filename);
4458 fclose(fp);
4459 screen_update_immidiate();
4460 }
4461
4462 return;
4463 }
4464
4465
4466
4467 /*--------------------------------------------------------------*/
4468 /* savefont <filename> <format> <type> */
4469 /* �ե���ȥե�����Υ����� */
4470 /*--------------------------------------------------------------*/
monitor_savefont(void)4471 static void monitor_savefont(void)
4472 {
4473 char *filename = NULL;
4474 int format = 0;
4475 int type = 0;
4476
4477 if (! exist_argv()) error(); /* <filename> */
4478 filename = argv.str;
4479 shift();
4480
4481 if (! exist_argv() || /* <format> */
4482 ! argv_is(ARGV_INT)) error();
4483 format = argv.val;
4484 if (! BETWEEN(0, format, 2)) error();
4485 shift();
4486
4487 if (! exist_argv() || /* <type> */
4488 ! argv_is(ARGV_INT)) error();
4489 type = argv.val;
4490 if (! BETWEEN(0, type, 3)) error();
4491 shift();
4492
4493 if (exist_argv()) error();
4494
4495
4496 {
4497 static const int rev[] = { 0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe,
4498 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf };
4499 int c, i, j, k, l, n;
4500 FILE *fp;
4501 bit8 *font;
4502
4503 if (type == 1) font = font_mem;
4504 else if (type == 2) font = font_mem2;
4505 else if (type == 3) font = font_mem3;
4506 else font = font_pcg;
4507
4508 fp = fopen(filename, (format == 0) ? "wb" : "w");
4509
4510 if (fp) {
4511
4512 if (format == 0) {
4513
4514 if (fwrite(font, sizeof(byte), 8 * 256, fp) != 8 * 256) {
4515 printf("file [%s] write error\n", filename);
4516 }
4517
4518 } else {
4519
4520 fprintf(fp, "#define font_width 128\n");
4521 fprintf(fp, "#define font_height 128\n");
4522 fprintf(fp, "static unsigned char font_bits[] = {\n");
4523
4524 l = 0;
4525 for (k = 0; k < 16; k++) {
4526 for (j = 0; j < 8; j++) {
4527 for (i = 0; i < 16; i++) {
4528
4529 if (format == 1) n = (k * 16 + i) * 8 + j;
4530 else n = (i * 16 + k) * 8 + j;
4531 c = (font[ n ]) & 0xff;
4532 c = ((rev[ c & 0xf ]) << 4) | (rev[ c >> 4 ]);
4533
4534 if ((l % 12) == 0) fprintf(fp, " ");
4535 fprintf(fp, " 0x%02x", c & 0xff);
4536 if (l == 8 * 256 - 1) fprintf(fp, "};\n");
4537 else if ((l % 12) == 11) fprintf(fp, ",\n");
4538 else fprintf(fp, ",");
4539 l++;
4540 }
4541 }
4542 }
4543
4544 }
4545
4546 fclose(fp);
4547
4548 } else {
4549 printf("file [%s] can't open\n", filename);
4550 }
4551 }
4552
4553 return;
4554 }
4555
4556
4557
4558 /*--------------------------------------------------------------*/
4559 /* tapeload [<filename>] */
4560 /* �����ѥơ��ץ�����ե�����Υ��å� */
4561 /*--------------------------------------------------------------*/
monitor_tapeload(void)4562 static void monitor_tapeload(void)
4563 {
4564 char *filename = NULL;
4565
4566 if (exist_argv()) {
4567 filename = argv.str;
4568 shift();
4569 if (exist_argv()) error();
4570 } else {
4571 const char *filename = filename_get_tape(CLOAD);
4572 if (filename)
4573 printf(" Tape load image is -> %s\n", filename);
4574 else
4575 printf(" Tape load image is NOT set\n");
4576 return;
4577 }
4578
4579 if (strcmp(filename, "-") == 0) {
4580 quasi88_load_tape_eject();
4581 printf(" Tape load image is NOT set\n");
4582 } else {
4583 if (quasi88_load_tape_insert(filename)) {
4584 printf("-- Tape set as load --\n");
4585 printf(" file ->[%s] \n", filename);
4586 } else {
4587 printf("** Tape %s can't set **\n", filename);
4588 }
4589 }
4590 return;
4591 }
4592
4593
4594
4595 /*--------------------------------------------------------------*/
4596 /* tapesave [<filename>] */
4597 /* �������ѥơ��ץ�����ե�����Υ��å� */
4598 /*--------------------------------------------------------------*/
monitor_tapesave(void)4599 static void monitor_tapesave(void)
4600 {
4601 char *filename = NULL;
4602
4603 if (exist_argv()) {
4604 filename = argv.str;
4605 shift();
4606 if (exist_argv()) error();
4607 } else {
4608 const char *filename = filename_get_tape(CSAVE);
4609 if (filename)
4610 printf(" Tape save image is -> %s\n", filename);
4611 else
4612 printf(" Tape save image is NOT set\n");
4613 return;
4614 }
4615
4616 if (strcmp(filename, "-") == 0) {
4617 quasi88_save_tape_eject();
4618 printf(" Tape save image is NOT set\n");
4619 } else {
4620 if (quasi88_save_tape_insert(filename)) {
4621 printf("-- Tape set as save --\n");
4622 printf(" file ->[%s] \n", filename);
4623 } else {
4624 printf("** Tape %s can't set **\n", filename);
4625 }
4626 }
4627 return;
4628 }
4629
4630
4631
4632 /*--------------------------------------------------------------*/
4633 /* printer [<filename>] */
4634 /* �ץ��ȥ������ѥ�����ե�����Υ��å� */
4635 /*--------------------------------------------------------------*/
monitor_printer(void)4636 static void monitor_printer(void)
4637 {
4638 char *filename = NULL;
4639
4640 if (exist_argv()) {
4641 filename = argv.str;
4642 shift();
4643 if (exist_argv()) error();
4644 } else {
4645 const char *filename = filename_get_prn();
4646 if (filename) printf(" Printout image is -> %s\n", filename);
4647 else printf(" Printout image is NOT set\n");
4648 return;
4649 }
4650
4651 if (strcmp(filename, "-") == 0) {
4652 quasi88_printer_remove();
4653 printf(" Printout image is NOT set\n");
4654 } else {
4655 if (quasi88_printer_connect(filename)) {
4656 printf("-- Printout image set --\n");
4657 printf(" file ->[%s] \n", filename);
4658 } else {
4659 printf("** Printout image %s can't set **\n", filename);
4660 }
4661 }
4662 return;
4663 }
4664
4665
4666
4667 /*--------------------------------------------------------------*/
4668 /* serialin [<filename>] */
4669 /* ���ꥢ�������ѥ�����ե�����Υ��å� */
4670 /*--------------------------------------------------------------*/
monitor_serialin(void)4671 static void monitor_serialin(void)
4672 {
4673 char *filename = NULL;
4674
4675 if (exist_argv()) {
4676 filename = argv.str;
4677 shift();
4678 if (exist_argv()) error();
4679 } else {
4680
4681 char buf[16];
4682 long cur, end;
4683 const char *filename = filename_get_sin();
4684 buf[0] = '\0';
4685 if (filename) {
4686 if (sio_com_pos(&cur, &end)) {
4687 if (end == 0) sprintf(buf, " (END)");
4688 else sprintf(buf, " (%3ld%%)", cur * 100 / end);
4689 }
4690 }
4691
4692 if (filename) printf(" Serial-In image is -> %s%s\n", filename, buf);
4693 else printf(" Serial-In image is NOT set\n");
4694 return;
4695 }
4696
4697 if (strcmp(filename, "-") == 0) {
4698 quasi88_serial_in_remove();
4699 printf(" Serial-In image is NOT set\n");
4700 } else {
4701 if (quasi88_serial_in_connect(filename)) {
4702 printf("-- Serial-In image set --\n");
4703 printf(" file ->[%s] \n", filename);
4704 } else {
4705 printf("** Serial-In image %s can't set **\n", filename);
4706 }
4707 }
4708 return;
4709 }
4710
4711
4712
4713 /*--------------------------------------------------------------*/
4714 /* serialout <filename> */
4715 /* ���ꥢ������ѥ�����ե�����Υ��å� */
4716 /*--------------------------------------------------------------*/
monitor_serialout(void)4717 static void monitor_serialout(void)
4718 {
4719 char *filename = NULL;
4720
4721 if (exist_argv()) {
4722 filename = argv.str;
4723 shift();
4724 if (exist_argv()) error();
4725 } else {
4726 const char *filename = filename_get_sout();
4727 if (filename) printf(" Serial-Out image is -> %s\n", filename);
4728 else printf(" Serial-Out image is NOT set\n");
4729 return;
4730 }
4731
4732 if (strcmp(filename, "-") == 0) {
4733 quasi88_serial_out_remove();
4734 printf(" Serial-Out image is NOT set\n");
4735 } else {
4736 if (quasi88_serial_out_connect(filename)) {
4737 printf("-- Serial-Out image set --\n");
4738 printf(" file ->[%s] \n", filename);
4739 } else {
4740 printf("** Serial-Out image %s can't set **\n", filename);
4741 }
4742 }
4743 return;
4744 }
4745
4746
4747
4748
4749
4750 /*----------------------------------*/
monitor_misc(void)4751 static void monitor_misc(void)
4752 {
4753 /*
4754 int ch;
4755 extern const char *mixer_get_name(int ch);
4756 extern mixer_get_mixing_level(int ch);
4757 for( ch=0; ch<16 ; ch++ ){
4758 const char *name = mixer_get_name(ch);
4759 if(name) printf( "%d[ch] %s\t:%d\n", ch,name,mixer_get_mixing_level(ch));
4760 }
4761 */
4762 #if 0
4763 FILE *fp;
4764 fp = fopen( "log.main","wb");
4765 fwrite( main_ram, sizeof(byte), 0x0f000, fp );
4766 fwrite( main_high_ram, sizeof(byte), 0x01000, fp );
4767 fclose(fp);
4768
4769 fp = fopen( "log.high","wb");
4770 fwrite( &main_ram[0xf000], sizeof(byte), 0x1000, fp );
4771 fclose(fp);
4772
4773 fp = fopen( "log.sub","wb");
4774 fwrite( &sub_romram[0x4000], sizeof(byte), 0x4000, fp );
4775 fclose(fp);
4776
4777 fp = fopen( "log.vram","wb");
4778 fwrite( main_vram, sizeof(byte), 4*0x4000, fp );
4779 fclose(fp);
4780 #endif
4781
4782 /*
4783 extern void monitor_fdc(void);
4784 monitor_fdc();
4785 */
4786 /*
4787 int line = 0;
4788 if( exist_argv() ){
4789 line = argv.val;
4790 shift();
4791 }
4792 printf( "line=%d\n",line );
4793 attr_misc(line);
4794 */
4795
4796 if (quasi88_cfg_can_showstatus()) {
4797 int now = quasi88_cfg_now_showstatus();
4798 int next = (now) ? FALSE : TRUE;
4799 quasi88_cfg_set_showstatus(next);
4800 }
4801 }
4802
4803
4804
4805
4806
4807 #ifdef USE_GNU_READLINE
4808
4809 /*--------------------------------------------------------------*/
4810 /* readline ��ȤäƤߤ褦�� */
4811 /*--------------------------------------------------------------*/
4812
4813 char *command_generator( char *text, int state );
4814 char *set_arg_generator( char *text, int state );
4815 char **fileman_completion( char *text, int start, int end );
4816
initialize_readline(void)4817 static void initialize_readline( void )
4818 {
4819 rl_readline_name = "QUASI88"; /*�褯�狼��� ~/.inputrc �˴ط�����餷��*/
4820 rl_attempted_completion_function = (CPPFunction *)fileman_completion;
4821 }
4822
fileman_completion(char * text,int start,int end)4823 char **fileman_completion( char *text, int start, int end )
4824 {
4825 char **matches = NULL;
4826
4827 int i=0;
4828 char c; /* "set " �����Ϥ��줿��� */
4829 while( (c = rl_line_buffer[i]) ){
4830 if( c==' ' || c=='\t' ){ i++; continue; }
4831 else break;
4832 }
4833 if (strncmp( &rl_line_buffer[i], "set", 3) == 0 && start > (i+3) )
4834 #ifdef RL_READLINE_VERSION /* ? */
4835 matches = rl_completion_matches( text, (rl_compentry_func_t *)set_arg_generator );
4836 #else
4837 matches = completion_matches( text, set_arg_generator );
4838 #endif
4839 else
4840
4841 if (start == 0) /* ��Ƭ�Ǥ����Ϥξ�� */
4842 #ifdef RL_READLINE_VERSION /* ? */
4843 matches = rl_completion_matches( text, (rl_compentry_func_t *)command_generator );
4844 #else
4845 matches = completion_matches( text, command_generator );
4846 #endif
4847
4848 return matches;
4849 }
4850
command_generator(char * text,int state)4851 char *command_generator( char *text, int state )
4852 {
4853 static int count, len;
4854 char *name;
4855
4856 if( state == 0 ){ /* ���δؿ����ǽ�� state=0 �ǸƤӽФ���� */
4857 count = 0; /* �餷���Τǡ����λ����ѿ����������롣 */
4858 len = strlen (text);
4859 }
4860
4861 while( count < COUNTOF(monitor_cmd) ){ /* ���ޥ��̾�� */
4862
4863 name = monitor_cmd[count].cmd;
4864 count ++;
4865
4866 if( strncmp( name, text, len ) == 0 ){
4867 char *p = malloc( strlen(name) + 1 );
4868 if (p){
4869 strcpy( p, name );
4870 }
4871 return p;
4872 }
4873 }
4874
4875 return NULL;
4876 }
4877
set_arg_generator(char * text,int state)4878 char *set_arg_generator( char *text, int state )
4879 {
4880 static int count, len; /* set ���ޥ�ɤ����ϺѤߤξ�� */
4881 char *name;
4882
4883 if( state == 0 ){
4884 count = 0;
4885 len = strlen (text);
4886 }
4887
4888 while( count < COUNTOF(monitor_variable) ){ /* �ѿ�̾�� */
4889
4890 name = monitor_variable[count].var_name;
4891 count ++;
4892
4893 if( strcmp( name, "" )==0 ) continue;
4894
4895 if( strncmp( name, text, len ) == 0 ){
4896 char *p = malloc( strlen(name) + 1 );
4897 if (p){
4898 strcpy( p, name );
4899 }
4900 return p;
4901 }
4902 }
4903
4904 return NULL;
4905 }
4906 #endif
4907
4908
4909
4910 /****************************************************************/
4911 /* �ǥХå� �ᥤ����� */
4912 /****************************************************************/
4913
4914 static int monitor_job = 0;
4915
monitor_init(void)4916 void monitor_init( void )
4917 {
4918 monitor_job = 0;
4919
4920 save_dump_addr = -1;
4921 save_dump_bank = ARG_MAIN;
4922 save_dumpext_addr = -1;
4923 save_dumpext_bank = ARG_EXT0;
4924 save_dumpext_board = 1;
4925 save_disasm_cpu = -1;
4926 save_disasm_addr[0] = -1;
4927 save_disasm_addr[1] = -1;
4928
4929
4930 {
4931 /* ���ֺǽ�˥�˥����⡼�ɤ����ä����ϡ���å�������ɽ�� */
4932
4933 static int enter_monitor_mode_first = TRUE;
4934 if( enter_monitor_mode_first ){
4935 printf("\n"
4936 "*******************************************************************************\n"
4937 "* QUASI88 - monitor mode - *\n"
4938 "* *\n"
4939 "* Enter go or g : Return to emulator *\n"
4940 "* Enter menu or m : Enter menu mode *\n"
4941 "* Enter quit or q : Quit QUASI88 *\n"
4942 "* *\n"
4943 "* Enter help or ? : Display help *\n"
4944 "*******************************************************************************\n"
4945 "\n" );
4946
4947 enter_monitor_mode_first = FALSE;
4948
4949 #ifdef USE_GNU_READLINE
4950 initialize_readline();
4951 #endif
4952 }
4953 }
4954
4955 fflush(NULL);
4956
4957 if (quasi88_event_flags & EVENT_DEBUG) {
4958 quasi88_event_flags &= ~EVENT_DEBUG;
4959
4960 /* �֥졼���������ϡ��쥸����ɽ�� */
4961 switch( cpu_timing ){
4962 case 0:
4963 if( select_main_cpu ) z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
4964 else z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
4965 break;
4966
4967 case 1:
4968 z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
4969 if( dual_cpu_count ) z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
4970 break;
4971
4972 case 2:
4973 z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
4974 z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
4975 break;
4976 }
4977 }
4978
4979 status_message_default(0, " MONITOR ");
4980 status_message_default(1, NULL);
4981 status_message_default(2, NULL);
4982
4983 screen_update_immidiate();
4984 }
4985
4986
4987
monitor_main(void)4988 void monitor_main( void )
4989 {
4990 int i;
4991
4992
4993 /* �⡼�ɤ��ڤ��ؤ��ޤǡ�������³�� */
4994 while ((quasi88_event_flags & EVENT_MODE_CHANGED) == 0) {
4995
4996 switch( monitor_job ){
4997
4998 case MONITOR_LINE_INPUT:
4999
5000 #ifndef USE_GNU_READLINE
5001
5002 printf("QUASI88> ");
5003 if( fgets( buf, MAX_CHRS, stdin ) == NULL ){ /* ^D �����Ϥ��줿�� */
5004 #ifndef IGNORE_CTRL_D /* ����Ū�˽�λ�� */
5005 quasi88_quit(); /* ������ˡ���狼���*/
5006 #else
5007 quasi88_monitor(); /* IRIX/AIX�������? */
5008 #endif
5009 break;
5010 }
5011
5012 #else
5013 {
5014 char *p, *chk;
5015 HIST_ENTRY *ph;
5016 p = readline( "QUASI88> " ); /* GNU readline �� */
5017 if( p==NULL ){ /* ���ͤ����ޤ��� */
5018 printf( "\n" ); /* �狼��� */
5019 break; /* man �ǼФ��ɤ� */
5020 }else{ /* ���Ƥߤ������Ѹ� */
5021 /* ������������ */
5022 ph = previous_history();
5023 if ( *p=='\0' && ph != NULL) { /* �������ľ���� */
5024 strncpy( buf, ph->line, MAX_CHRS-1 ); /*���ޥ�ɤ�¹� */
5025 } else strncpy( buf, p, MAX_CHRS-1 );
5026 buf[ MAX_CHRS-1 ] = '\0';
5027
5028 chk = p; /* ���Ԥ���ʤ��������˻Ĥ� */
5029 while( *chk ){
5030 if( *chk==' ' || *chk=='\t' ){ chk++; continue; }
5031 /* Ʊ�����ޥ�ɤ�����˻Ĥ��ʤ� */
5032 else if (ph != NULL && strcmp(chk, ph->line) == 0) break;
5033 else { add_history( chk ); break; }
5034 }
5035 }
5036 free( p );
5037 /* ���Τ�����ν����ϡ�peach����ˤ����ɤ���ޤ��� */
5038 }
5039 #endif
5040
5041 getarg(); /* ������ʬ�� */
5042
5043 if( d_argc==0 ){ /* ���Ԥξ�� */
5044 monitor_job = 0;
5045 }else{
5046 for( i=0; i<COUNTOF(monitor_cmd); i++ ){
5047 if( strcmp( d_argv[0], monitor_cmd[i].cmd )==0 ) break;
5048 }
5049 if( i==COUNTOF(monitor_cmd) ){ /* ̵��̿��ξ�� */
5050 printf("Invalid command : %s\n",d_argv[0]);
5051 monitor_job = 0;
5052 }else{ /* ������ ? �� */
5053 if( d_argc==2 && strcmp( d_argv[1], "?" )==0 ){
5054 (monitor_cmd[i].help)();
5055 monitor_job = 0;
5056 }else{ /* �̾��̿��ξ�� */
5057 monitor_job = monitor_cmd[i].job;
5058 shift();
5059 fflush(NULL);
5060 }
5061 }
5062 }
5063 break;
5064
5065
5066
5067 case MONITOR_HELP:
5068 monitor_job=0;
5069 monitor_help();
5070 break;
5071 case MONITOR_MENU:
5072 quasi88_menu();
5073 break;
5074 case MONITOR_QUIT:
5075 quasi88_quit();
5076 break;
5077
5078 case MONITOR_GO:
5079 monitor_job=0;
5080 monitor_go();
5081 break;
5082 case MONITOR_TRACE:
5083 monitor_job=0;
5084 monitor_trace();
5085 break;
5086 case MONITOR_STEP:
5087 monitor_job=0;
5088 monitor_step();
5089 break;
5090 case MONITOR_STEPALL:
5091 monitor_job=0;
5092 monitor_stepall();
5093 break;
5094 case MONITOR_BREAK:
5095 monitor_job=0;
5096 monitor_break();
5097 break;
5098
5099
5100 case MONITOR_READ:
5101 monitor_job=0;
5102 monitor_read();
5103 break;
5104 case MONITOR_WRITE:
5105 monitor_job=0;
5106 monitor_write();
5107 break;
5108 case MONITOR_DUMP:
5109 monitor_job=0;
5110 monitor_dump();
5111 break;
5112 case MONITOR_DUMPEXT:
5113 monitor_job=0;
5114 monitor_dumpext();
5115 break;
5116 case MONITOR_FILL:
5117 monitor_job=0;
5118 monitor_fill();
5119 break;
5120 case MONITOR_MOVE:
5121 monitor_job=0;
5122 monitor_move();
5123 break;
5124 case MONITOR_SEARCH:
5125 monitor_job=0;
5126 monitor_search();
5127 break;
5128 case MONITOR_IN:
5129 monitor_job=0;
5130 monitor_in();
5131 break;
5132 case MONITOR_OUT:
5133 monitor_job=0;
5134 monitor_out();
5135 break;
5136 case MONITOR_LOADMEM:
5137 monitor_job=0;
5138 monitor_loadmem();
5139 break;
5140 case MONITOR_SAVEMEM:
5141 monitor_job=0;
5142 monitor_savemem();
5143 break;
5144
5145 case MONITOR_RESET:
5146 monitor_job=0;
5147 monitor_reset();
5148 break;
5149 case MONITOR_REG:
5150 monitor_job=0;
5151 monitor_reg();
5152 break;
5153 case MONITOR_DISASM:
5154 monitor_job=0;
5155 monitor_disasm();
5156 break;
5157
5158 case MONITOR_SET:
5159 monitor_job=0;
5160 monitor_set();
5161 break;
5162 case MONITOR_SHOW:
5163 monitor_job=0;
5164 monitor_show();
5165 break;
5166 case MONITOR_REDRAW:
5167 monitor_job=0;
5168 screen_update_immidiate();
5169 break;
5170 case MONITOR_RESIZE:
5171 monitor_job=0;
5172 monitor_resize();
5173 break;
5174 case MONITOR_DRIVE:
5175 monitor_job=0;
5176 monitor_drive();
5177 break;
5178 case MONITOR_FILE:
5179 monitor_job=0;
5180 monitor_file();
5181 break;
5182 case MONITOR_STATESAVE:
5183 monitor_job=0;
5184 monitor_statesave();
5185 break;
5186 case MONITOR_STATELOAD:
5187 monitor_job=0;
5188 monitor_stateload();
5189 break;
5190 case MONITOR_SNAPSHOT:
5191 monitor_job=0;
5192 monitor_snapshot();
5193 break;
5194 case MONITOR_LOADFONT:
5195 monitor_job=0;
5196 monitor_loadfont();
5197 break;
5198 case MONITOR_SAVEFONT:
5199 monitor_job=0;
5200 monitor_savefont();
5201 break;
5202 case MONITOR_TAPELOAD:
5203 monitor_job=0;
5204 monitor_tapeload();
5205 break;
5206 case MONITOR_TAPESAVE:
5207 monitor_job=0;
5208 monitor_tapesave();
5209 break;
5210 case MONITOR_PRINTER:
5211 monitor_job=0;
5212 monitor_printer();
5213 break;
5214 case MONITOR_SERIALIN:
5215 monitor_job=0;
5216 monitor_serialin();
5217 break;
5218 case MONITOR_SERIALOUT:
5219 monitor_job=0;
5220 monitor_serialout();
5221 break;
5222
5223 case MONITOR_MISC:
5224 monitor_job=0;
5225 monitor_misc();
5226 break;
5227
5228 case MONITOR_FBREAK:
5229 monitor_job=0;
5230 monitor_fbreak();
5231 break;
5232 case MONITOR_TEXTSCR:
5233 monitor_job=0;
5234 monitor_textscr();
5235 break;
5236 case MONITOR_LOADBAS:
5237 monitor_job=0;
5238 monitor_loadbas();
5239 break;
5240 case MONITOR_SAVEBAS:
5241 monitor_job=0;
5242 monitor_savebas();
5243 break;
5244
5245
5246 default:
5247 monitor_job=0;
5248 printf("Internal Error\n");
5249 break;
5250 }
5251
5252 }
5253
5254 }
5255
5256
5257
5258 #endif /* USE_MONITOR */
5259