source: buchla-68k/rom/romp.c@ 0c834c5

Last change on this file since 0c834c5 was 0c834c5, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Prototypes for global function pointers. Consistent global types.

  • Property mode set to 100644
File size: 70.1 KB
Line 
1/*
2 ============================================================================
3 romp.c -- ROMP debug monitor
4 (c) Copyright 1987,1988 -- D.N. Lynx Crowe
5
6 See ROMPVER, below, for version number and date.
7
8 CAUTION: This code is designed to live in PROM, so initialized
9 variables are PERMANENTLY initialized, since the compiler assigns
10 initialized variables to the data segment, which ends up in PROM.
11
12 Un-initialized variables go into the bss segment, which ends up in RAM.
13
14 Set ON_B700 non-zero to get a Buchla 700 PROM,
15 or zero to get a NASA 3D Helmet Display PROM.
16 ============================================================================
17*/
18
19#define ROMPVER "22.00 -- 1988-06-20"
20
21#define TINYMSG 0 /* 1 for short messages, 0 for normal ones */
22
23#define ON_B700 1 /* 1 for Buchla 700, 0 for NASA */
24#define ONEMEG 1 /* 1 if 1024K, 0 if 512K RAM space (Buchla 700) */
25
26#include "ascii.h"
27#include "biosdefs.h"
28#include "ctype.h"
29#include "errdefs.h"
30#include "hwdefs.h"
31#include "memory.h"
32#include "rawio.h"
33#include "regs.h"
34#include "setjmp.h"
35#include "stddefs.h"
36#include "strings.h"
37#include "vsdd.h"
38
39#if ON_B700
40#include "graphdef.h"
41#include "vsddsw.h"
42#include "vsddvars.h"
43#endif
44
45typedef unsigned short UWORD16; /* unsigned 16 bit word */
46
47/*
48
49*/
50
51#if ON_B700
52#define USER_RAM 0x00010000L /* Start of user RAM (TPA) */
53#if ONEMEG
54#define RAM_TOP 0x000FFFFEL /* Default top word of memory */
55#define ISTACK 0x000FFFFEL /* Default initial stack */
56#else
57#define RAM_TOP 0x0007FFFEL /* Default top word of memory */
58#define ISTACK 0x0007FFFEL /* Default initial stack */
59#endif
60#define KB_EI 2 /* Enable level for panel */
61#define DEFIPL 2 /* Default internal processor level */
62#define INITSR 0x2200 /* Default initial status register */
63#define BOOTFILE "midas.abs" /* Boot file name */
64#define BOOTKEY 39 /* Boot panel key */
65#define ROMPKEY 40 /* ROMP panel key */
66#define FIFOLIM 60000 /* FIFO clear limit */
67#define I_TABX 53 /* Tablet X */
68#define I_TABY 54 /* Tablet Y */
69#define I_CURX 55 /* Cursor X */
70#define I_CURY 56 /* Cursor Y */
71#define I_LONGL 57 /* LongPot Left */
72#define I_LONGR 58 /* LongPot Right */
73#define I_SCROLL 59 /* Scroll */
74#define I_TEMPO 73 /* Tempo Multiplier */
75#define I_TIME 74 /* Time Scaling */
76#define I_TUNE 75 /* Fine Tuning */
77#define I_LEVEL 76 /* Amplitude */
78#define BARBASE 5120L /* Base of bars in VSDD RAM */
79#define SWBASE 38400L /* Base of switches in VSDD RAM */
80#define MARGIN 4 /* Offset from left edge of screen */
81#else
82#define DEFIPL 3
83#define USER_RAM 0x00008000L
84#define RAM_TOP 0x0001FFFEL
85#define ISTACK 0x0001FFFEL
86#define INITSR 0x2300
87#endif
88
89#define ROMADDR 0x00100000L
90
91#define MAXFNLN 13 /* xxxxxxxx.xxx + CR */
92#define MAXARGLN 80 /* maximum argument length */
93#define MAXCMDLN 128 /* maximum command line length */
94#define MAXHS 80 /* maximum help string length */
95#define MAXID 90 /* maximum ID string length */
96
97#define PDATELN 14
98#define PRM_DATE 0x0100008L
99#define PRM_VERS 0x0100002L
100
101#define BPINST 0x4E4F /* breakpoint instruction */
102
103#define CRLF "\r\n"
104
105#define TACK "K\r" /* good response from load command */
106#define NACK "?\r" /* bad response from load command */
107
108#define SREC9 "04000000FB" /* tail of a type 9 Motorola S-Record */
109
110#define MON_C 1 /* monitor character code */
111#define MON_S 2 /* monitor short code */
112#define MON_L 4 /* monitor long code */
113
114/*
115
116*/
117
118/*
119 ============================================================================
120 external functions and forward references
121 ============================================================================
122*/
123
124extern unsigned setipl(unsigned arg);
125
126extern void rjumpto(void *addr);
127extern void halt(void);
128extern int getln(int unit, int nb, char *buf);
129extern void sjumpto(void *addr, void *stack);
130extern void trap15(void);
131extern void xtrap15(void);
132
133#if ON_B700
134extern void hdvini(void);
135extern short booter(char *fn, long textadr);
136extern void vsndpal(short pp[16][3]);
137#endif
138
139/* external variables */
140
141extern short wzcrsh, *crshpc, *crshsp, *crshus, crshst[16];
142
143#if ON_B700
144extern short B_log_s;
145extern short B_dbg_s;
146extern char *B_buf_a;
147extern int _bpbin;
148extern short dfltpal[16][3];
149#endif
150
151extern UWORD16 crshsr;
152extern long crshrg[16];
153extern char crshvc[4];
154
155/* forward references */
156
157int cp_dump(void);
158int cp_fill(void);
159int cp_copy(void);
160int cp_null(void);
161int cp_ilev(void);
162int cp_ldmp(void);
163int cp_go(void);
164int cp_read(void);
165int cp_mset(void);
166int cp_rset(void);
167int cp_wset(void);
168int cp_mtst(void);
169int cp_wdmp(void);
170int cp_wfil(void);
171int cp_vrst(void);
172int cp_monc(void);
173int cp_mons(void);
174int cp_monl(void);
175int cp_chek(void);
176
177#if ON_B700
178int cx_dini(void);
179int cx_mlod(void);
180int cp_boot(void);
181int cx_boot(void);
182int cx_adsp(void);
183#endif
184
185int cx_dump(void);
186int cx_fill(void);
187int cx_copy(void);
188int cx_rset(void);
189int cx_load(void);
190int cx_go(void);
191int cx_read(void);
192int cx_help(void);
193void cx_exit(void);
194int cx_writ(void);
195int cx_regs(void);
196int cx_mset(void);
197int cx_bpb(void);
198int cx_wset(void);
199int cx_wdmp(void);
200int cx_wfil(void);
201void cx_rest(void);
202int cx_vrst(void);
203int cx_vreg(void);
204int cx_mon(void);
205int cx_next(void);
206int cx_ilev(void);
207int do_srec(char *line);
208int cx_crsh(void);
209int cx_mtst(void);
210void cx_zap(void);
211int cx_ldmp(void);
212int cx_omap(void);
213int cx_chek(void);
214
215char hs_mtst[];
216
217/*
218
219*/
220
221/*
222 ============================================================================
223 error message string definitions
224 ============================================================================
225*/
226
227#define EMSG1 "\r\n** Command error **\r\n"
228#define EMSG2 "\r\n** Invalid parameter **\r\n"
229#define EMSG3 "\r\n** Unrecognized command **\r\n"
230
231#define EMSG5 "\r\n** Command not repeatable **\r\n"
232#define EMSG6 "\r\n** Invalid line terminator **\r\n"
233#define EMSG7 "\r\n** do_cmd() switch failed **\r\n"
234
235#define CANNED "\r\n----- Cancelled -----\r\n"
236
237/*
238
239*/
240
241/*
242 ============================================================================
243 initialized variables (These end up in the data segment in PROM)
244 ============================================================================
245*/
246
247struct cmdent { /* command table entry */
248
249 char *cname; /* command name pointer */
250 int (*cp)(); /* command parser function pointer */
251 int (*cx)(); /* command execution function pointer */
252 char *hstr; /* help string pointer */
253};
254
255struct cmdent cmtab[] = {
256
257#if ON_B700
258 {"adisp", cp_null, cx_adsp, ""},
259 {"boot", cp_boot, cx_boot, ""},
260 {"bpb", cp_null, cx_bpb, ""},
261#endif
262
263 {"check", cp_chek, cx_chek, "start,end"},
264 {"copy", cp_copy, cx_copy, "from,to,len"},
265
266#if ON_B700
267 {"crash", cp_null, cx_crsh, ""},
268 {"dinit", cp_null, cx_dini, ""},
269#endif
270
271 {"dump", cp_dump, cx_dump, "from[,[to=from][,width=16]]"},
272 {"exit", cp_null, cx_exit, ""},
273 {"fill", cp_fill, cx_fill, "loc,count,byte"},
274 {"go", cp_go, cx_go, "[addr][,[brk1][,brk2]]"},
275 {"help", cp_null, cx_help, ""},
276 {"ipl", cp_ilev, cx_ilev, "level"},
277 {"ldump", cp_ldmp, cx_ldmp, "from[,[to=from][,width=4]]"},
278 {"load", cp_null, cx_load, ""},
279
280#if ON_B700
281 {"midas", cp_null, cx_mlod, ""},
282#endif
283
284 {"monc", cp_monc, cx_mon, "addr"},
285 {"mons", cp_mons, cx_mon, "addr"},
286 {"monl", cp_monl, cx_mon, "addr"},
287 {"mset", cp_mset, cx_mset, "addr,b1[,...,bn]"},
288 {"mtest", cp_mtst, cx_mtst, hs_mtst},
289 {"next", cp_null, cx_next, ""},
290 {"obmap", cp_null, cx_omap, ""},
291
292#if ON_B700
293 {"read", cp_read, cx_read, "sector,buffer,count"},
294#endif
295
296 {"regs", cp_null, cx_regs, ""},
297 {"reset", cp_null, cx_rest, ""},
298 {"rset", cp_rset, cx_rset, "register,value"},
299 {"vregs", cp_null, cx_vreg, ""},
300 {"vrset", cp_vrst, cx_vrst, "register,value"},
301 {"wdump", cp_wdmp, cx_wdmp, "from[,[to=from][,width=8]]"},
302 {"wfill", cp_wfil, cx_wfil, "loc,count,word"},
303
304#if ON_B700
305 {"write", cp_read, cx_writ, "sector,buffer,count"},
306#endif
307
308 {"wset", cp_wset, cx_wset, "addr,w1[,...,wn]"},
309 {"zap", cp_null, cx_zap, ""}
310};
311
312#define NCMDS ((sizeof cmtab) / (sizeof cmtab[0]))
313
314/*
315
316*/
317
318char ahex[] = "0123456789abcdefABCDEF";
319
320char *rlist[] = { /* register name list */
321
322 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
323 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
324 "sr", "pc", "sp",
325 (char *)0
326};
327
328char *vrlist[] = { /* video register name list */
329
330 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
331 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
332 "h0", "h1", "h2", "h3", "v0", "v1", "v2", "v3",
333 (char *)0
334};
335
336#if ON_B700
337int sigadr[] = { /* display offsets for signals */
338
339 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, /* keys */
340 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
341 4, 4, 4, 4,
342 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, /* sliders */
343 9, 9, 9, 9,
344 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, /* switches */
345 14, 14, 14, 14,
346 17, 17, /* tablet */
347 20, 20, /* cursor */
348 23, 23, /* longpot */
349 26, /* scrollpot */
350 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, /* digits */
351 32, 32, 32, /* x, e, m */
352 35, 35, 35, 35, /* pots */
353 37, 37, /* pedals */
354 39, 39, 39, 39 /* analog in */
355};
356#endif
357
358/*
359
360*/
361
362/*
363 ============================================================================
364 un-initialized variables (These end up in the bss segment in RAM)
365 ============================================================================
366*/
367
368char argsep; /* argument separator */
369
370char *aptr, /* argument pointer */
371 *monptr, /* monitored variable pointer */
372 *d_cur, /* dump current from */
373 *d_next, /* dump next from */
374 *d_last, /* dump next to */
375 *p_end, /* end parameter */
376 *p_from, /* from parameter */
377 *p_goto, /* goto parameter */
378 *p_to, /* to parameter */
379 *sptr; /* string scan pointer */
380
381short argln, /* argument length */
382 b0flag, /* breakpoint 0 flag */
383 b1flag, /* breakpoint 1 flag */
384 cmdunit, /* command unit */
385 dflag, /* dump limit flag */
386 exflag, /* exit do_cmd flag */
387 first1, /* first time flag */
388 goflag, /* pc set flag */
389 ilast, /* index of last command */
390 inext, /* command index for "next" command */
391 iplev, /* ROMP IPL level */
392 monsw, /* monitor switch */
393 redo, /* re-doable command flag */
394 rnum, /* register number */
395 vrnum; /* video register number */
396
397/*
398
399*/
400
401#if ON_B700
402short asig, /* signal number */
403 aval, /* signal value */
404 astat, /* signal status */
405 aflag, /* signal activity flag */
406 baseled, /* base LED for scan */
407 ledcntr; /* LED scan counter */
408
409short sigtab[128][2]; /* signal table */
410
411long afi, /* analog FIFO input */
412 ftimer; /* analog FIFO clear timer */
413
414unsigned baron, /* bar 'on' color */
415 baroff, /* bar 'off' color */
416 swon, /* switch 'on' color */
417 swoff, /* switch 'off' color */
418 *obj0; /* object pointer */
419#endif
420
421UWORD16 *tba0, /* breakpoint 0 temporary */
422 *tba1; /* breakpoint 1 temporary */
423
424UWORD16 p_bv0, /* breakpoint 0 value */
425 p_bv1; /* breakpoint 1 value */
426
427UWORD16 *p_ba0, /* breakpoint 0 address */
428 *p_ba1; /* breakpoint 1 address */
429
430jmp_buf restart; /* jmp environment */
431
432long p_len, /* length parameter */
433 p_value, /* value parameter */
434 p_width; /* width parameter */
435
436struct regs *regptr; /* register save area pointer */
437
438char argstr[MAXARGLN+1], /* argument string */
439 cmdline[MAXCMDLN+1], /* command line */
440 bfname[MAXFNLN+1], /* boot file name */
441 hs_mtst[MAXHS+1], /* mtest help string */
442 idbuf[MAXID+1], /* ID string */
443 promdate[PDATELN+1]; /* PROM date area */
444
445/*
446
447*/
448
449/*
450 ============================================================================
451 cx_exit -- restart ROMP
452 ============================================================================
453*/
454
455void cx_exit(void)
456{
457 longjmp(&restart, 1); /* restart ROMP */
458}
459
460/*
461 ============================================================================
462 cx_rest -- execute the reset command
463 ============================================================================
464*/
465
466void cx_rest(void)
467{
468 rjumpto(ROMADDR);
469}
470
471/*
472 ============================================================================
473 cx_mlod() -- execute the midas command
474 ============================================================================
475*/
476
477int cx_mlod(void)
478{
479 register short i;
480
481 B_log_s = TRUE;
482 B_dbg_s = FALSE;
483 redo = FALSE;
484
485 hdvini();
486 _bpbin = FALSE;
487
488 if (booter("midas.abs", 0L)) {
489
490 return(FALSE);
491
492 } else {
493
494 for (i = 0; i < 8; i++) /* clear d0..d7 */
495 regptr->d_reg[i] = 0L;
496
497 for (i = 0; i < 7; i++) /* clear a0..a6 */
498 regptr->a_reg[i] = (char *)0L;
499
500 regptr->a_reg[7] = ISTACK; /* setup initial stack */
501
502 regptr->reg_sr = INITSR; /* setup sr */
503 regptr->reg_pc = B_buf_a; /* setup pc */
504
505 return(TRUE);
506 }
507}
508
509/*
510
511*/
512
513/*
514 ============================================================================
515 cp_boot() -- parse boot command
516 ============================================================================
517*/
518
519int cp_boot(void)
520{
521 register int i;
522 register char endc;
523
524 redo = FALSE;
525
526 for (;;) {
527
528 writeln(cmdunit, "File name: ");
529 endc = getln(cmdunit, MAXFNLN+1, bfname);
530 writeln(cmdunit, CRLF);
531
532 if (endc EQ A_CR)
533 break;
534
535 if (endc EQ CTL('X')) {
536
537 writeln(cmdunit, CANNED);
538 return(FALSE);
539 }
540
541 if (endc EQ ERR01)
542 writeln(cmdunit, EMSG2);
543 }
544
545 for (i = 0; i < MAXFNLN+1; i++)
546 if (bfname[i] EQ A_CR)
547 bfname[i] = '\0';
548
549 return(TRUE);
550}
551
552/*
553
554*/
555
556/*
557 ============================================================================
558 cx_boot() -- execute boot command
559 ============================================================================
560*/
561
562int cx_boot(void)
563{
564 register short i;
565
566 B_log_s = TRUE;
567 B_dbg_s = FALSE;
568
569 hdvini();
570 _bpbin = FALSE;
571
572 if (booter(bfname, 0L)) {
573
574 return(FALSE);
575
576 } else {
577
578 for (i = 0; i < 8; i++) /* clear d0..d7 */
579 regptr->d_reg[i] = 0L;
580
581 for (i = 0; i < 7; i++) /* clear a0..a6 */
582 regptr->a_reg[i] = (char *)0L;
583
584 regptr->a_reg[7] = ISTACK; /* setup initial stack */
585
586 regptr->reg_sr = INITSR; /* setup sr */
587 regptr->reg_pc = B_buf_a; /* setup pc */
588
589 return(TRUE);
590 }
591}
592
593/*
594
595*/
596
597/*
598 =============================================================================
599 dobar(nb, bv) -- draw bar 'nb' with value 'bv'
600 =============================================================================
601*/
602
603void dobar(int nb, int bv)
604{
605 register unsigned *bp;
606 register int i;
607
608 if ((nb LT 1) OR (nb GT 82))
609 return;
610
611 --nb;
612 bp = obj0 + BARBASE + (long)(sigadr[nb] + MARGIN + nb);
613
614 for (i = 127; i GE 0; --i) {
615
616 if (i GT bv) {
617
618 *bp = baroff;
619 bp += 128L;
620 *bp = baroff;
621
622 } else {
623
624 *bp = baron;
625 bp += 128L;
626 *bp = baron;
627 }
628
629 bp += 128L;
630 }
631}
632
633/*
634
635*/
636
637/*
638 =============================================================================
639 dosw(nb, sv) -- display value 'sv' of switch 'nb'
640 =============================================================================
641*/
642
643void dosw(int nb, int sv)
644{
645 register unsigned *bp;
646 register int i, j;
647
648 if ((nb LT 1) OR (nb GT 82))
649 return;
650
651 --nb;
652 bp = obj0 + SWBASE + (long)(sigadr[nb] + MARGIN + nb);
653
654 if (sv)
655 j = swon;
656 else
657 j = swoff;
658
659 for (i = 0; i < 8; i++) {
660
661 *bp = j;
662 bp += 128L;
663 }
664}
665
666/*
667
668*/
669
670/*
671 =============================================================================
672 exp_c() -- expand a 4 bit color into a 16 bit word
673 =============================================================================
674*/
675
676unsigned exp_c(unsigned c)
677{
678 c &= 0x000F;
679 c |= c << 4;
680 c |= c << 8;
681
682 return(c);
683}
684
685/*
686
687*/
688
689/*
690 =============================================================================
691 cx_adsp() -- display values of analog processor variables as a bar graph
692 =============================================================================
693*/
694
695int cx_adsp(void)
696{
697 register int xasig, xastat, xaval;
698 register long xafi;
699 register long lc;
700 register unsigned *bp;
701 int i, j, k;
702 int oldi;
703
704 memsetw(sigtab, 0, sizeof sigtab / 2);
705
706 VHinit();
707 VSinit();
708 vsndpal(dfltpal);
709
710 obj0 = 0x200400L;
711
712 SetObj(0, 0, 0, obj0, 512, 350, 0, 0, (V_RES3 | V_TDE), -1);
713
714 bp = obj0;
715
716 for (lc = 0; lc < 44800; lc++)
717 *bp++ = 0x0000;
718
719 baron = 0x0FFF & exp_c(P_WHT);
720 baroff = 0x0FFF & exp_c(P_DKGRY);
721 swon = 0x0FFF & exp_c(P_YEL);
722 swoff = 0x0FFF & exp_c(P_DKGRY);
723
724 SetPri(0, 7);
725
726 for (i = 1; i < 83; i++) {
727
728 dobar(i, 0);
729 dosw(i, 0);
730 }
731
732 oldi = setipl(2);
733
734/*
735
736*/
737
738 while (0L EQ BIOS(B_RDAV, CON_DEV)) {
739
740 if (-1L NE (xafi = XBIOS(X_ANALOG))) {
741
742 xasig = 0x007F & (xafi >> 8);
743 xastat = 0x0001 & (xafi >> 7);
744 xaval = 0x007F & xafi;
745
746 if (xasig) {
747
748 sigtab[xasig][0] = xaval;
749 sigtab[xasig][1] = xastat;
750
751 if (xasig LT 83) {
752
753 dobar(xasig, xaval);
754 dosw(xasig, xastat);
755 }
756
757 } else {
758
759 for (i = 0; i < 83; i++)
760 sigtab[i][1] = 0;
761 }
762 }
763 }
764
765/*
766
767*/
768
769 BIOS(B_GETC, CON_DEV);
770
771 for (j = 1; j < 83; j++) {
772
773 dobar(j, sigtab[j][0]);
774 dosw(j, sigtab[j][1]);
775 }
776
777 k = 0;
778
779 printf("\n");
780 printf(" x0 x1 x2 x3 x4 x5 x6 x7 x8 x9\r\n");
781 printf(" ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\r\n");
782
783 for (i = 0; i < 9; i++ ) {
784
785 printf("%01dx ", k/10);
786
787 for (j = 0; j < 10; j++) {
788
789 if (k)
790 printf("%1d:%3d ", sigtab[k][1], sigtab[k][0]);
791 else
792 printf(" ");
793
794 if (++k EQ 83)
795 goto outofit;
796 }
797
798 printf("\n");
799 }
800
801outofit:
802
803 printf("\nTempo = %3d, Time = %3d, Tuning = %3d, Level = %3d\n",
804 sigtab[I_TEMPO][0], sigtab[I_TIME][0],
805 sigtab[I_TUNE][0], sigtab[I_LEVEL][0]);
806
807 printf("LongPot L = %3d, LongPot R = %3d, Scroll = %3d\n",
808 sigtab[I_LONGL][0], sigtab[I_LONGR][0],
809 sigtab[I_SCROLL][0]);
810
811 printf("Tablet X = %3d, Tablet Y = %3d\n",
812 sigtab[I_TABX][0], sigtab[I_TABY][0]);
813
814 printf("Cursor X = %3d, Cursor Y = %3d\n",
815 sigtab[I_CURX][0], sigtab[I_CURY][0]);
816
817 setipl(oldi);
818 return(TRUE);
819}
820
821/*
822
823*/
824
825/*
826 =============================================================================
827 waitcr() -- wait for a CR from CON_DEV
828 Returns: 0 = continue
829 1 = ^G hit - abort
830 =============================================================================
831*/
832
833int waitcr(void)
834{
835 char c;
836
837 BIOS(B_PUTC, CON_DEV, '\007');
838
839 while ('\r' NE (c = (0x7F & BIOS(B_GETC, CON_DEV)))) {
840
841 if (c EQ '\007')
842 return(1);
843 }
844
845 return(0);
846}
847
848/*
849
850*/
851
852/*
853 ============================================================================
854 xdtoi -- convert hex ASCII to an int digit
855 ============================================================================
856*/
857
858int xdtoi(int c)
859{
860 register int i;
861 register char *ap = &ahex[0];
862
863 for (i = 0; i < 22; i++)
864 if (c EQ *ap++)
865 if (i >15)
866 return(i - 6);
867 else
868 return(i);
869
870 return(-1);
871}
872
873/*
874
875*/
876
877/*
878 ============================================================================
879 getcmd -- parse command from input line
880 ============================================================================
881*/
882
883int getcmd(void)
884{
885 register int c;
886
887 sptr = cmdline;
888 argln = 0;
889 aptr = argstr;
890 memset(argstr, 0, MAXARGLN+1);
891
892 do {
893
894 switch (c = 0x00FF & *sptr) {
895
896 case '\0':
897 case A_CR:
898 case A_LF:
899
900 argsep = c;
901 return(argln);
902
903 case ' ':
904
905 ++sptr;
906
907 while (*sptr EQ ' ')
908 ++sptr;
909
910 if (*sptr EQ A_CR OR *sptr EQ A_LF OR *sptr EQ '\0')
911 c = 0x00FF & *sptr;
912
913 argsep = c;
914 return(argln);
915
916/*
917
918*/
919
920 default:
921
922 if (isupper(c))
923 c = _tolower(c);
924
925 *aptr++ = c;
926 ++sptr;
927 ++argln;
928 }
929
930 } while (*sptr);
931
932 argsep = 0;
933 return(argln);
934}
935
936/*
937
938*/
939
940/*
941 ============================================================================
942 getarg -- parse out an argument to analyze
943 ============================================================================
944*/
945
946int getarg(void)
947{
948 register int c;
949
950 argln = 0;
951 aptr = argstr;
952 memset(argstr, 0, MAXARGLN+1);
953
954 do {
955
956 switch (c = 0x00FF & *sptr) {
957
958 case '\0':
959 case A_CR:
960 case A_LF:
961
962 argsep = c;
963 return(argln);
964
965 case ' ':
966
967 ++sptr;
968
969 while (*sptr EQ ' ')
970 ++sptr;
971
972 if (*sptr EQ A_CR OR *sptr EQ A_LF OR *sptr EQ '\0')
973 c = 0x00FF & *sptr;
974
975 argsep = c;
976 return(argln);
977
978 case ',':
979
980 ++sptr;
981 argsep = c;
982 return(argln);
983
984/*
985
986*/
987
988 default:
989
990 *aptr++ = c;
991 ++sptr;
992 ++argln;
993 }
994
995 } while (*sptr);
996
997 argsep = 0;
998 return(argln);
999}
1000
1001/*
1002
1003*/
1004
1005/*
1006 ============================================================================
1007 getlong -- get a long integer (either hex or decimal)
1008 ============================================================================
1009*/
1010
1011int getlong(long *var)
1012{
1013 register long temp = 0L;
1014 register int csw = FALSE,
1015 c;
1016
1017 if (*aptr EQ '$') {
1018
1019 ++aptr;
1020
1021 while (isxdigit(c = *aptr++)) {
1022
1023 temp = (temp << 4) + xdtoi(c);
1024 csw = TRUE;
1025 }
1026
1027 } else {
1028
1029 while (isdigit(c = *aptr++)) {
1030
1031 temp = (temp * 10) + (c - '0');
1032 csw = TRUE;
1033 }
1034 }
1035
1036 if (csw)
1037 *var = temp;
1038
1039 return(c);
1040}
1041
1042/*
1043
1044*/
1045
1046/*
1047 ============================================================================
1048 setvar -- parse an expression and set a long variable
1049 ============================================================================
1050*/
1051
1052int setvar(long *var, long deflt)
1053{
1054 int rc;
1055 long temp;
1056
1057 *var = deflt;
1058 aptr = argstr;
1059
1060 rc = getlong(var);
1061
1062 if (rc) {
1063
1064 do {
1065
1066 switch (rc) {
1067
1068 case '+':
1069
1070 temp = 0L;
1071 rc = getlong(&temp);
1072 *var = *var + temp;
1073 continue;
1074
1075 case '-':
1076
1077 temp = 0L;
1078 rc = getlong(&temp);
1079 *var = *var - temp;
1080 continue;
1081
1082 default:
1083
1084 *var = deflt;
1085 return(FALSE);
1086 }
1087
1088 } while (rc);
1089
1090 return(TRUE);
1091 }
1092
1093 return(TRUE);
1094}
1095
1096/*
1097
1098*/
1099
1100/*
1101 ============================================================================
1102 putn -- output a decimal number
1103 ============================================================================
1104*/
1105
1106void putn(long num, int cw, int unit)
1107{
1108 register int d;
1109
1110 if (!cw)
1111 return;
1112
1113 putn(num/10, cw-1, unit);
1114
1115 d = num % 10;
1116
1117 BIOS(B_PUTC, unit, (d + '0'));
1118
1119 return;
1120}
1121
1122/*
1123
1124*/
1125
1126/*
1127 ============================================================================
1128 puthn -- output a hex number
1129 ============================================================================
1130*/
1131
1132void puthn(long num, int cw, int unit)
1133{
1134 register int d;
1135
1136 if (!cw)
1137 return;
1138
1139 puthn(num >> 4, cw-1, unit);
1140
1141 d = 0x0F & num;
1142
1143 if (d > 9)
1144 BIOS(B_PUTC, unit, (d - 10 + 'A'));
1145 else
1146 BIOS(B_PUTC, unit, (d + '0'));
1147
1148 return;
1149}
1150
1151/*
1152
1153*/
1154
1155/*
1156 ============================================================================
1157 ddump -- do the hex portion of a dump
1158 ============================================================================
1159*/
1160
1161int ddump(char *loc, char *lastloc, int nwide, int unit)
1162{
1163 while (nwide--) {
1164
1165 puthn((long)(0xFF & *loc), 2, unit);
1166 BIOS(B_PUTC, unit, ' ');
1167
1168 if (BIOS(B_RDAV, unit)) {
1169
1170 BIOS(B_GETC, unit);
1171 return(TRUE);
1172 }
1173
1174 if (loc EQ lastloc) {
1175
1176 dflag = TRUE;
1177 return(FALSE);
1178 }
1179
1180 ++loc;
1181 }
1182
1183
1184 return(FALSE);
1185}
1186
1187/*
1188
1189*/
1190
1191/*
1192 ============================================================================
1193 padr -- print dump address
1194 ============================================================================
1195*/
1196
1197void padr(long adr, int unit)
1198{
1199 puthn(adr, 8, unit);
1200 BIOS(B_PUTC, unit, ' ');
1201 BIOS(B_PUTC, unit, '-');
1202 BIOS(B_PUTC, unit, ' ');
1203}
1204
1205/*
1206
1207*/
1208
1209/*
1210 ============================================================================
1211 dtext -- do the text portion of a dump
1212 ============================================================================
1213*/
1214
1215int dtext(char *loc, char *lastloc, int nwide, int unit)
1216{
1217 register int c;
1218
1219 BIOS(B_PUTC, unit, ' ');
1220 BIOS(B_PUTC, unit, '|');
1221
1222 while (nwide--) {
1223
1224 c = 0xFF & *loc;
1225
1226 if (isascii(c) AND isprint(c))
1227 BIOS(B_PUTC, unit, c);
1228 else
1229 BIOS(B_PUTC, unit, '.');
1230
1231 if (BIOS(B_RDAV, unit)) {
1232
1233 BIOS(B_GETC, unit);
1234 BIOS(B_PUTC, unit, '|');
1235 return(TRUE);
1236 }
1237
1238 if (loc EQ lastloc) {
1239
1240 BIOS(B_PUTC, unit, '|');
1241 return(FALSE);
1242 }
1243
1244 ++loc;
1245 }
1246
1247 BIOS(B_PUTC, unit, '|');
1248 return(FALSE);
1249}
1250
1251/*
1252
1253*/
1254
1255/*
1256 ============================================================================
1257 cp_mset -- parse parameters for mset command
1258 ============================================================================
1259*/
1260
1261int cp_mset(void)
1262{
1263 redo = FALSE;
1264
1265 if (0 EQ getarg())
1266 return(FALSE);
1267
1268 if (argsep NE ',')
1269 return(FALSE);
1270
1271 if (setvar(&p_from, p_from) EQ FALSE)
1272 return(FALSE);
1273
1274 return(TRUE);
1275}
1276
1277/*
1278 ============================================================================
1279 cx_mset -- execute the mset command
1280 ============================================================================
1281*/
1282
1283int cx_mset(void)
1284{
1285 while (TRUE) {
1286
1287 if (getarg())
1288 if (setvar(&p_value, p_value) EQ FALSE)
1289 return(FALSE);
1290
1291 if (p_value & ~0xFFL)
1292 return(FALSE);
1293
1294 *p_from++ = 0xFF & p_value;
1295
1296 if (argsep EQ A_CR)
1297 return(TRUE);
1298 }
1299}
1300/*
1301
1302*/
1303
1304/*
1305 ============================================================================
1306 cp_wset -- parse parameters for wset command
1307 ============================================================================
1308*/
1309
1310int cp_wset(void)
1311{
1312 redo = FALSE;
1313
1314 if (0 EQ getarg())
1315 return(FALSE);
1316
1317 if (argsep NE ',')
1318 return(FALSE);
1319
1320 if (setvar(&p_from, p_from) EQ FALSE)
1321 return(FALSE);
1322
1323 if ((long)p_from & 1L)
1324 return(FALSE);
1325
1326 return(TRUE);
1327}
1328
1329/*
1330
1331*/
1332
1333/*
1334 ============================================================================
1335 cx_wset -- execute the wset command
1336 ============================================================================
1337*/
1338
1339int cx_wset(void)
1340{
1341 UWORD16 *p_uint;
1342
1343 p_uint = (UWORD16 *)p_from;
1344
1345 while (TRUE) {
1346
1347 if (getarg())
1348 if (setvar(&p_value, p_value) EQ FALSE)
1349 return(FALSE);
1350
1351 if (p_value & ~0xFFFFL)
1352 return(FALSE);
1353
1354 *p_uint++ = 0xFFFF & p_value;
1355
1356 if (argsep EQ A_CR)
1357 return(TRUE);
1358 }
1359}
1360
1361/*
1362
1363*/
1364
1365/*
1366 ============================================================================
1367 cp_mtst -- parse mtest command arguments
1368 ============================================================================
1369*/
1370
1371int cp_mtst(void)
1372{
1373 inext = ilast;
1374
1375 if (argsep EQ A_CR OR argsep EQ '\0') {
1376
1377 p_from = (char *)0x00000008L;
1378 p_to = (char *)USER_RAM - 2L;
1379 return(TRUE);
1380 }
1381
1382 if (getarg())
1383 if (setvar(&p_from, USER_RAM) EQ FALSE)
1384 return(FALSE);
1385
1386 if (argsep NE ',')
1387 return(FALSE);
1388
1389 if (getarg())
1390 if (setvar(&p_to, RAM_TOP) EQ FALSE)
1391 return(FALSE);
1392
1393 if ((long)p_from & 1L)
1394 return(FALSE);
1395
1396 if ((long)p_to & 1L)
1397 return(FALSE);
1398
1399 if (p_from GT p_to)
1400 return(FALSE);
1401
1402 return(TRUE);
1403}
1404
1405/*
1406
1407*/
1408
1409/*
1410 ============================================================================
1411 cx_mtst -- execute the mtest command
1412 ============================================================================
1413*/
1414
1415int cx_mtst(void)
1416{
1417 register short mask, was, *loc, *eloc, *oldloc;
1418
1419 mask = 0x0001;
1420 loc = (short *)p_from;
1421 eloc = (short *)p_to;
1422 oldloc = loc;
1423
1424 if (p_from LT (char *)USER_RAM)
1425 setipl(7);
1426
1427 do {
1428
1429 while (mask) {
1430
1431 *loc = mask;
1432
1433 if (mask NE (was = *loc))
1434 if (p_from LT (char *)USER_RAM)
1435 halt();
1436 else
1437 printf("%08lX was %04X, expected %04X\r\n",
1438 loc, was, mask);
1439
1440 *loc = ~mask;
1441
1442 if (~mask NE (was = *loc))
1443 if (p_from LT (char *)USER_RAM)
1444 halt();
1445 else
1446 printf("%08lX was %04X, expected %04X\r\n",
1447 loc, was, ~mask);
1448
1449 mask <<= 1;
1450 }
1451
1452 mask = 0x0001;
1453 loc++;
1454
1455 } while (loc LE eloc);
1456
1457 if (oldloc LT (short *)USER_RAM)
1458 rjumpto((long)ROMADDR);
1459
1460 return(TRUE);
1461}
1462
1463/*
1464
1465*/
1466
1467/*
1468 ============================================================================
1469 cp_go -- parse parameters for go command
1470 ============================================================================
1471*/
1472
1473int cp_go(void)
1474{
1475 redo = FALSE;
1476 b0flag = FALSE;
1477 b1flag = FALSE;
1478 goflag = FALSE;
1479
1480 if (getarg()) {
1481
1482 if (setvar(&p_goto, p_goto) EQ FALSE)
1483 return(FALSE);
1484
1485 if (1L & (long)p_goto)
1486 return(FALSE);
1487
1488 goflag = TRUE;
1489
1490 }
1491
1492 if (getarg()) {
1493
1494 if (setvar(&tba0, 0L) EQ FALSE)
1495 return(FALSE);
1496
1497 if (1L & (long)tba0)
1498 return(FALSE);
1499
1500 b0flag = TRUE;
1501 }
1502
1503 if (getarg()) {
1504
1505 if (setvar(&tba1, 0L) EQ FALSE)
1506 return(FALSE);
1507
1508 if (1L & (long)tba1)
1509 return(FALSE);
1510
1511 b1flag = TRUE;
1512 }
1513
1514 return(TRUE);
1515}
1516
1517/*
1518
1519*/
1520
1521#if ON_B700
1522
1523/*
1524 ============================================================================
1525 cx_dini() -- execute the dinit command
1526 ============================================================================
1527*/
1528
1529int cx_dini(void)
1530{
1531 redo = TRUE;
1532 hdvini();
1533 return(TRUE);
1534}
1535
1536#endif
1537
1538/*
1539 ============================================================================
1540 cx_zap -- execute the zap command
1541 ============================================================================
1542*/
1543
1544void cx_zap(void)
1545{
1546 register short *p, *q;
1547
1548 p = (short *)USER_RAM;
1549 q = (short *)RAM_TOP;
1550
1551 setipl(7);
1552
1553 while (p LE q)
1554 *p++ = 0;
1555
1556 rjumpto(ROMADDR);
1557}
1558
1559/*
1560
1561*/
1562
1563/*
1564 ============================================================================
1565 cx_omap() -- execute the omap command
1566 ============================================================================
1567*/
1568
1569int cx_omap(void)
1570{
1571 register short i, width, xloc;
1572
1573 printf("Pr B/C Locn Wd Xloc Flags\r\n");
1574
1575 for (i = 0; i < 16; i++) {
1576
1577 xloc = v_odtab[i][1] & 0x03FF;
1578
1579 if (xloc & 0x0200) /* sign extend xloc */
1580 xloc |= 0xFC00;
1581
1582 width = (v_odtab[i][1] >> 10) & 0x003F;
1583
1584 printf("%2d %s ",
1585 i, ((v_odtab[i][0] & V_CBS) ? "Chr" : "Bit"));
1586
1587 printf("$%08lX %2d %4d ",
1588 ((long)v_odtab[i][2] << 1), width, xloc);
1589
1590 printf("$%04X\r\n", v_odtab[i][0]);
1591 }
1592
1593 return(TRUE);
1594}
1595
1596/*
1597
1598*/
1599
1600/*
1601 ============================================================================
1602 cx_help -- execute the help command
1603 ============================================================================
1604*/
1605
1606int cx_help(void)
1607{
1608 int i, j;
1609
1610 j = 0;
1611
1612 writeln(cmdunit, CRLF);
1613
1614 for (i = 0; i < NCMDS; i++) {
1615
1616 if (j++ EQ 22) {
1617
1618 j = 0;
1619
1620 if (waitcr())
1621 return(TRUE);
1622 }
1623
1624 writeln(cmdunit, " ");
1625 writeln(cmdunit, cmtab[i].cname);
1626 writeln(cmdunit, " ");
1627 writeln(cmdunit, cmtab[i].hstr);
1628 writeln(cmdunit, CRLF);
1629 }
1630
1631 writeln(cmdunit, CRLF);
1632 return(TRUE);
1633}
1634
1635/*
1636
1637* /
1638
1639/*
1640 ============================================================================
1641 cx_bpb -- execute bpb command
1642 ============================================================================
1643*/
1644
1645int cx_bpb(void)
1646{
1647 register struct bpb *bpp;
1648
1649 if (0L EQ (bpp = (struct bpb *)BIOS(B_GBPB, 0) ) ) {
1650
1651 writeln(cmdunit, "\r\n\nERROR -- Unable to read BPB\r\n\n");
1652 return(FALSE);
1653
1654 } else {
1655
1656 writeln(cmdunit, "\r\n\nBPB values:\r\n");
1657 writeln(cmdunit, "\r\n recsiz ");
1658 putn((long)bpp->recsiz, 5, cmdunit);
1659 writeln(cmdunit, "\r\n clsiz ");
1660 putn((long)bpp->clsiz, 4, cmdunit);
1661 writeln(cmdunit, "\r\n clsizb ");
1662 putn((long)bpp->clsizb, 5, cmdunit);
1663 writeln(cmdunit, "\r\n rdlen ");
1664 putn((long)bpp->rdlen, 4, cmdunit);
1665 writeln(cmdunit, "\r\n fsiz ");
1666 putn((long)bpp->fsiz, 4, cmdunit);
1667 writeln(cmdunit, "\r\n fatrec ");
1668 putn((long)bpp->fatrec, 5, cmdunit);
1669 writeln(cmdunit, "\r\n datrec ");
1670 putn((long)bpp->datrec, 5, cmdunit);
1671 writeln(cmdunit, "\r\n numcl ");
1672 putn((long)bpp->numcl, 5, cmdunit);
1673 writeln(cmdunit, "\r\n bflags ");
1674 puthn((long)bpp->bflags, 4, cmdunit);
1675 writeln(cmdunit, "\r\n ntracks ");
1676 putn((long)bpp->ntracks, 4, cmdunit);
1677 writeln(cmdunit, "\r\n nsides ");
1678 putn((long)bpp->nsides, 4, cmdunit);
1679 writeln(cmdunit, "\r\n sec/cyl ");
1680 putn((long)bpp->dspc, 5, cmdunit);
1681 writeln(cmdunit, "\r\n sec/trk ");
1682 putn((long)bpp->dspt, 5, cmdunit);
1683 writeln(cmdunit, "\r\n hidden ");
1684 putn((long)bpp->hidden, 4, cmdunit);
1685 writeln(cmdunit, "\r\n\n");
1686 return(TRUE);
1687 }
1688}
1689
1690/*
1691
1692*/
1693
1694/*
1695 ============================================================================
1696 cx_go -- execute the go command
1697 ============================================================================
1698*/
1699
1700int cx_go(void)
1701{
1702 redo = FALSE;
1703 exflag = TRUE;
1704 wzcrsh = FALSE;
1705
1706 if (goflag)
1707 regptr->reg_pc = p_goto;
1708
1709 if (b0flag ) {
1710
1711 if (p_ba0) {
1712
1713 if (*p_ba0 NE (UWORD16)BPINST) {
1714
1715 writeln(cmdunit, "\r\n\n** Breakpoint 0 at ");
1716 puthn((long)p_ba0, 8, cmdunit);
1717 writeln(cmdunit, " was ");
1718 puthn(0xFFFFL & (long)(*p_ba0), 4, cmdunit);
1719 writeln(cmdunit, " instead of ");
1720 puthn(0xFFFFL & (long)BPINST, 4, cmdunit);
1721 writeln(cmdunit, " **\r\n\n");
1722 }
1723
1724 *p_ba0 = p_bv0;
1725 }
1726
1727 p_ba0 = tba0;
1728 p_bv0 = *p_ba0;
1729 *p_ba0 = (UWORD16)BPINST;
1730 }
1731
1732/*
1733
1734*/
1735
1736 if (b1flag ) {
1737
1738 if (p_ba1) {
1739
1740 if (*p_ba1 NE (UWORD16)BPINST) {
1741
1742 writeln(cmdunit, "\r\n\n** Breakpoint 1 at ");
1743 puthn((long)p_ba1, 8, cmdunit);
1744 writeln(cmdunit, " was ");
1745 puthn(0xFFFFL & (long)(*p_ba1), 4, cmdunit);
1746 writeln(cmdunit, " instead of ");
1747 puthn(0xFFFFL & (long)BPINST, 4, cmdunit);
1748 writeln(cmdunit, " **\r\n\n");
1749 }
1750
1751 *p_ba1 = p_bv1;
1752 }
1753
1754 p_ba1 = tba1;
1755 p_bv1 = *p_ba1;
1756 *p_ba1 = (UWORD16)BPINST;
1757 }
1758
1759 return(TRUE);
1760}
1761
1762/*
1763
1764*/
1765
1766/*
1767 ============================================================================
1768 cp_dump -- parse dump parameters
1769 ============================================================================
1770*/
1771
1772int cp_dump(void)
1773{
1774 inext = ilast;
1775
1776 if (getarg())
1777 if (setvar(&p_from, p_from) EQ FALSE) {
1778
1779 redo = FALSE;
1780 return(FALSE);
1781 }
1782
1783 if (argsep EQ A_CR OR argsep EQ '\0') {
1784
1785 p_to = p_from;
1786 p_width = 16L;
1787 redo = TRUE;
1788 return(TRUE);
1789 }
1790
1791 if (getarg())
1792 if (setvar(&p_to, p_to) EQ FALSE) {
1793
1794 redo = FALSE;
1795 return(FALSE);
1796 }
1797
1798 if (argsep EQ A_CR OR argsep EQ '\0') {
1799
1800 p_width = 16L;
1801 redo = TRUE;
1802 return(TRUE);
1803 }
1804
1805 if (getarg())
1806 if (setvar(&p_width, p_width) EQ FALSE) {
1807
1808 redo = FALSE;
1809 return(FALSE);
1810 }
1811
1812 if ((p_width LE 0L) OR (p_width GT 16L)) {
1813
1814 p_width = 16L;
1815 redo = FALSE;
1816 return(FALSE);
1817 }
1818
1819 redo = TRUE;
1820 return(TRUE);
1821}
1822
1823/*
1824
1825*/
1826
1827/*
1828 ============================================================================
1829 cp_fill -- parse parameters for fill command
1830 ============================================================================
1831*/
1832
1833int cp_fill(void)
1834{
1835 redo = FALSE;
1836
1837 if (getarg())
1838 if (setvar(&p_from, p_from) EQ FALSE)
1839 return(FALSE);
1840
1841 if (getarg())
1842 if (setvar(&p_len, p_len) EQ FALSE)
1843 return(FALSE);
1844
1845 if (getarg())
1846 if (setvar(&p_value, p_value) EQ FALSE)
1847 return(FALSE);
1848
1849 if (p_value & ~0xFFL)
1850 return(FALSE);
1851
1852 return(TRUE);
1853}
1854
1855/*
1856
1857*/
1858
1859/*
1860 ============================================================================
1861 cp_wfil -- parse parameters for wfill command
1862 ============================================================================
1863*/
1864
1865int cp_wfil(void)
1866{
1867 redo = FALSE;
1868
1869 if (getarg())
1870 if (setvar(&p_from, p_from) EQ FALSE)
1871 return(FALSE);
1872
1873 if (getarg())
1874 if (setvar(&p_len, p_len) EQ FALSE)
1875 return(FALSE);
1876
1877 if (getarg())
1878 if (setvar(&p_value, p_value) EQ FALSE)
1879 return(FALSE);
1880
1881 if ((long)p_from & 1L)
1882 return(FALSE);
1883
1884 if (p_value & ~0xFFFFL)
1885 return(FALSE);
1886
1887 return(TRUE);
1888}
1889
1890/*
1891
1892*/
1893
1894/*
1895 ============================================================================
1896 cp_copy -- parse parameters for copy command
1897 ============================================================================
1898*/
1899
1900int cp_copy(void)
1901{
1902 redo = FALSE;
1903
1904 if (getarg())
1905 if (setvar(&p_from, p_from) EQ FALSE)
1906 return(FALSE);
1907
1908 if (getarg())
1909 if (setvar(&p_to, p_to) EQ FALSE)
1910 return(FALSE);
1911
1912 if (getarg())
1913 if (setvar(&p_len, p_len) EQ FALSE)
1914 return(FALSE);
1915
1916 return(TRUE);
1917}
1918/*
1919
1920*/
1921
1922/*
1923 ============================================================================
1924 cp_chek -- parse parameters for chek command
1925 ============================================================================
1926*/
1927
1928int cp_chek(void)
1929{
1930 redo = FALSE;
1931
1932 if (getarg())
1933 if (setvar(&p_from, p_from) EQ FALSE)
1934 return(FALSE);
1935
1936 if (getarg())
1937 if (setvar(&p_to, p_to) EQ FALSE)
1938 return(FALSE);
1939
1940 return(TRUE);
1941}
1942
1943/*
1944
1945*/
1946
1947/*
1948 ============================================================================
1949 cp_read -- parse parameters for read command
1950 ============================================================================
1951*/
1952
1953int cp_read(void)
1954{
1955 redo = FALSE;
1956
1957 if (getarg())
1958 if (setvar(&p_from, p_from) EQ FALSE)
1959 return(FALSE);
1960
1961 if (getarg())
1962 if (setvar(&p_to, p_to) EQ FALSE)
1963 return(FALSE);
1964
1965 if (getarg())
1966 if (setvar(&p_len, p_len) EQ FALSE)
1967 return(FALSE);
1968
1969 if ((~0x7FFFL) & p_len)
1970 return(FALSE);
1971
1972 if ((~0xFFFFL) & (long)p_from)
1973 return(FALSE);
1974
1975 return(TRUE);
1976}
1977
1978/*
1979 ============================================================================
1980 cp_null -- parse null parameter line
1981 ============================================================================
1982*/
1983
1984int cp_null(void)
1985{
1986 return(TRUE);
1987}
1988
1989/*
1990
1991*/
1992
1993/*
1994 ============================================================================
1995 cp_rset -- parse rset command parameters
1996 ============================================================================
1997*/
1998
1999int cp_rset(void)
2000{
2001 int rc;
2002
2003 rc = 0;
2004 redo = FALSE;
2005
2006 if (0 EQ getarg())
2007 return(FALSE);
2008
2009 str2lc(argstr);
2010
2011 if (0 EQ (rc = strlcmp(argstr, rlist)))
2012 return(FALSE);
2013
2014 if (0 EQ getarg())
2015 return(FALSE);
2016
2017 if (FALSE EQ setvar(&p_value, 0L))
2018 return(FALSE);
2019
2020 rnum = rc;
2021 return(TRUE);
2022}
2023
2024/*
2025
2026*/
2027/*
2028 ============================================================================
2029 cx_chek -- process chek command
2030 ============================================================================
2031*/
2032
2033int cx_chek(void)
2034{
2035 register long csum;
2036 register char *cp;
2037
2038 redo = FALSE;
2039 csum = 0L;
2040
2041 for (cp = p_from; cp LE p_to; cp++)
2042 csum += 0x000000FFL & *cp;
2043
2044 printf("Checksum = 0x%08lX\r\n", csum);
2045
2046 return(TRUE);
2047}
2048
2049/*
2050
2051*/
2052
2053/*
2054 ============================================================================
2055 cx_rset -- process rset command
2056 ============================================================================
2057*/
2058
2059int cx_rset(void)
2060{
2061 redo = FALSE;
2062
2063 if (rnum < 1)
2064 return(FALSE);
2065
2066 if (rnum < 9) { /* d0..d7 -- data register */
2067
2068 regptr->d_reg[rnum-1] = p_value;
2069 return(TRUE);
2070 }
2071
2072 if (rnum < 17) { /* a0..a7 -- address register */
2073
2074 regptr->a_reg[rnum-9] = (char *)p_value;
2075 return(TRUE);
2076 }
2077
2078/*
2079
2080*/
2081
2082 if (rnum EQ 17) { /* sr -- status register */
2083
2084 if ((~0xFFFFL) & p_value)
2085 return(FALSE);
2086
2087 regptr->reg_sr = (UWORD16)p_value;
2088 return(TRUE);
2089 }
2090
2091 if (rnum EQ 18) { /* pc -- program counter */
2092
2093 if (1L & p_value)
2094 return(FALSE);
2095
2096 regptr->reg_pc = (char *)p_value;
2097 return(TRUE);
2098 }
2099
2100 if (rnum EQ 19) { /* sp -- stack pointer */
2101
2102 if (1L & p_value)
2103 return(FALSE);
2104
2105 regptr->a_reg[7] = (char *)p_value;
2106 return(TRUE);
2107 }
2108
2109 return(FALSE);
2110}
2111
2112/*
2113
2114*/
2115
2116/*
2117 ============================================================================
2118 cp_vrst -- parse vrset command parameters
2119 ============================================================================
2120*/
2121
2122int cp_vrst(void)
2123{
2124 int rc;
2125
2126 rc = 0;
2127 redo = FALSE;
2128
2129 if (0 EQ getarg())
2130 return(FALSE);
2131
2132 str2lc(argstr);
2133
2134 if (0 EQ (rc = strlcmp(argstr, vrlist)))
2135 return(FALSE);
2136
2137 if (0 EQ getarg())
2138 return(FALSE);
2139
2140 if (FALSE EQ setvar(&p_value, 0L))
2141 return(FALSE);
2142
2143 if (vrnum < 17) { /* complete register */
2144
2145 vrnum = rc;
2146 return(TRUE);
2147 }
2148
2149 if (vrnum < 21) { /* horizontal register */
2150
2151 if (p_value & ~0x003F)
2152 return(FALSE);
2153
2154 vrnum = rc;
2155 return(TRUE);
2156 }
2157
2158 if (vrnum < 25) { /* vertical register */
2159
2160 if (p_value & ~0x03FF)
2161 return(FALSE);
2162
2163 vrnum = rc;
2164 return(TRUE);
2165 }
2166
2167 return(FALSE);
2168}
2169
2170/*
2171
2172*/
2173
2174/*
2175 ============================================================================
2176 cx_vrst -- process vrset command
2177 ============================================================================
2178*/
2179
2180int cx_vrst(void)
2181{
2182 redo = FALSE;
2183
2184 if (vrnum < 1)
2185 return(FALSE);
2186
2187 if (vrnum < 17) { /* 1..16 -- r0..r15 -- complete register */
2188
2189 v_regs[vrnum-1] = p_value;
2190 return(TRUE);
2191 }
2192
2193 if (vrnum < 21) { /* 17..20 -- h0..h3 -- horizontal register */
2194
2195 v_regs[vrnum-5] = (v_regs[vrnum-5] & 0x03FF) |
2196 ((p_value << 10) & 0xFC00);
2197 return(TRUE);
2198 }
2199
2200 if (vrnum < 25) { /* 21..24 -- v0..v3 -- vertical register */
2201
2202 v_regs[vrnum-9] = (v_regs[vrnum-9] & 0xFC00) | p_value;
2203 return(TRUE);
2204 }
2205
2206 return(FALSE);
2207}
2208
2209/*
2210
2211*/
2212
2213/*
2214 ============================================================================
2215 cx_vreg -- process vregs command
2216 ============================================================================
2217*/
2218
2219int cx_vreg(void)
2220{
2221 register int i, j, k, l;
2222 register unsigned *rp;
2223
2224 rp = &v_regs[0];
2225 l = 0;
2226
2227 for (i = 0; i < 2; i++) {
2228
2229 for (j = 0; j < 2; j++) {
2230
2231 for (k = 0; k < 4; k++) {
2232
2233 writeln(cmdunit, " ");
2234 putn((long)l++, 2, cmdunit);
2235 writeln(cmdunit, ":");
2236 puthn((long)*rp++, 4, cmdunit);
2237 }
2238
2239 writeln(cmdunit, " ");
2240 }
2241
2242 writeln(cmdunit, "\r\n");
2243 }
2244
2245 return(TRUE);
2246}
2247
2248/*
2249
2250*/
2251
2252/*
2253 ============================================================================
2254 do_srec -- load a Motorola S record
2255 ============================================================================
2256*/
2257
2258int do_srec(char *line)
2259{
2260 register char *ldadr;
2261 register int c, csum, i, len;
2262 register unsigned val;
2263
2264 if ('S' NE (c = *line++))
2265 return(-1); /* error 1 = missing initial S */
2266
2267 switch (c = *line++) {
2268
2269 case '2':
2270
2271 csum = 0;
2272
2273 if (isxdigit(c = *line++))
2274 len = xdtoi(c);
2275 else
2276 return(-2); /* error 2 = bad length byte */
2277
2278 if (isxdigit(c = *line++))
2279 len = (len << 4) + xdtoi(c);
2280 else
2281 return(-2);
2282
2283 csum += (len & 0xFF);
2284 ldadr = (char *)0;
2285 len -= 4;
2286
2287 for (i = 0; i < 3; i++) {
2288
2289 if (isxdigit(c = *line++))
2290 val = xdtoi(c);
2291 else
2292 return(-3); /* error 3 = bad address byte */
2293
2294 if (isxdigit(c = *line++))
2295 val = (val << 4) + xdtoi(c);
2296 else
2297 return(-3);
2298
2299 ldadr = (char *)(((long)ldadr << 8) + (long)val);
2300 csum += (val & 0xFF);
2301 }
2302
2303 for (i = 0; i < len; i++) {
2304
2305 if (isxdigit(c = *line++))
2306 val = xdtoi(c);
2307 else
2308 return(-4); /* error 4 = bad data byte */
2309
2310 if (isxdigit(c = *line++))
2311 val = (val << 4) + xdtoi(c);
2312 else
2313 return(-4);
2314
2315 csum += (val & 0xFF);
2316 *ldadr = val & 0xFF;
2317
2318 if ((*ldadr & 0xFF) NE (val & 0xFF))
2319 return(-5); /* error 5 = store failed */
2320
2321 ldadr++;
2322 }
2323
2324 csum = 0xFF & ~csum;
2325
2326 if (isxdigit(c = *line++))
2327 val = xdtoi(c);
2328 else
2329 return(-6); /* error 6 = bad checksum byte */
2330
2331 if (isxdigit(c = *line++))
2332 val = (val << 4) + xdtoi(c);
2333 else
2334 return(-6);
2335
2336 if (csum NE (val & 0xFF))
2337 return(-7); /* error 7 = bad checksum */
2338
2339 return(1);
2340
2341 case '9':
2342
2343 if (memcmpu(line, SREC9, 10) EQ 0)
2344 return(0);
2345 else
2346 return(-8); /* error 8 = bad end record */
2347
2348 default:
2349
2350 return(-9); /* error 9 = unknown s type */
2351 }
2352
2353 return(-10); /* error 10 = switch failed */
2354}
2355
2356/*
2357
2358*/
2359
2360/*
2361 ============================================================================
2362 cx_load -- process load command
2363 ============================================================================
2364*/
2365
2366int cx_load(void)
2367{
2368 register int rc;
2369
2370 do {
2371
2372 rc = getrln(cmdunit, MAXCMDLN, cmdline);
2373
2374 switch (rc) {
2375
2376 case A_CR:
2377
2378 rc = do_srec(cmdline);
2379
2380 if (rc LT 0) {
2381
2382 rc = -rc;
2383 writeln(cmdunit, NACK);
2384 writeln(cmdunit, "** Load error ");
2385 putn((long)rc, 3, cmdunit);
2386 writeln(cmdunit, " **\r\n\n");
2387 return(FALSE);
2388
2389 } else {
2390
2391 writeln(cmdunit, TACK);
2392 }
2393
2394 continue;
2395
2396 case CTL('X'):
2397
2398 rc = 1;
2399 writeln(cmdunit, TACK);
2400 continue;
2401
2402/*
2403
2404*/
2405
2406 default:
2407
2408 writeln(cmdunit, NACK);
2409 writeln(cmdunit, "** Load aborted on ");
2410 puthn(rc, 2, cmdunit);
2411 writeln(cmdunit, " **\r\n\n");
2412 return(FALSE);
2413 }
2414
2415 } while (rc);
2416
2417 return(TRUE);
2418}
2419
2420/*
2421
2422*/
2423
2424/*
2425 ============================================================================
2426 cx_fill -- execute the fill command
2427 ============================================================================
2428*/
2429
2430int cx_fill(void)
2431{
2432 register char *cp = p_from;
2433 register long count;
2434
2435 redo = FALSE;
2436
2437 for (count = p_len; count > 0L; count--) {
2438
2439 *cp = (char)(0xFFL & p_value);
2440
2441 if (*cp NE (char)(0xFFL & p_value)) {
2442
2443 writeln(cmdunit, "\r\n** FILL failed at ");
2444 puthn((long)cp, 8, cmdunit);
2445 writeln(cmdunit, " **\r\n");
2446 return(FALSE);
2447 }
2448
2449 ++cp;
2450 }
2451
2452 return(TRUE);
2453}
2454
2455/*
2456
2457*/
2458
2459/*
2460 ============================================================================
2461 cx_wfill -- execute the wfill command
2462 ============================================================================
2463*/
2464
2465int cx_wfil(void)
2466{
2467 register UWORD16 *cp = (UWORD16 *)p_from;
2468 register long count;
2469
2470 redo = FALSE;
2471
2472 for (count = p_len; count > 0L; count--)
2473 *cp++ = (UWORD16)(0xFFFFL & p_value);
2474
2475 return(TRUE);
2476}
2477
2478/*
2479
2480*/
2481
2482/*
2483 ============================================================================
2484 cx_copy -- execute the copy command
2485 ============================================================================
2486*/
2487
2488int cx_copy(void)
2489{
2490 register char *from = p_from,
2491 *to = p_to;
2492 register long count = p_len;
2493
2494 redo = FALSE;
2495
2496 if (to GT from) {
2497
2498 from = from + count;
2499 to = to + count;
2500
2501 while (count--) {
2502
2503 --from;
2504 --to;
2505 *to = *from;
2506
2507 if (*from NE *to) {
2508
2509 writeln(cmdunit, "\r\n** COPY failed from ");
2510 puthn((long)from, 8, cmdunit);
2511 writeln(cmdunit, " to ");
2512 puthn((long)to, 8, cmdunit);
2513 writeln(cmdunit, " with (from) = ");
2514 puthn((long)(*from), 2, cmdunit);
2515 writeln(cmdunit, " and (to) = ");
2516 puthn((long)(*to), 2, cmdunit);
2517 writeln(cmdunit, " **\r\n");
2518 return(FALSE);
2519 }
2520 }
2521
2522/*
2523
2524*/
2525
2526 } else {
2527
2528 while (count--) {
2529
2530 *to = *from;
2531
2532 if (*from NE *to) {
2533
2534 writeln(cmdunit, "\r\n** COPY failed from ");
2535 puthn((long)from, 8, cmdunit);
2536 writeln(cmdunit, " to ");
2537 puthn((long)to, 8, cmdunit);
2538 writeln(cmdunit, " with (from) = ");
2539 puthn((long)(*from), 2, cmdunit);
2540 writeln(cmdunit, " and (to) = ");
2541 puthn((long)(*to), 2, cmdunit);
2542 writeln(cmdunit, " **\r\n");
2543 return(FALSE);
2544 }
2545
2546 ++from;
2547 ++to;
2548 }
2549 }
2550
2551 return(TRUE);
2552}
2553
2554/*
2555
2556*/
2557
2558/*
2559 ============================================================================
2560 cx_dump -- execute the dump command
2561 ============================================================================
2562*/
2563
2564int cx_dump(void)
2565{
2566 register int nw, rc;
2567
2568 redo= TRUE;
2569 d_cur = p_from;
2570 d_next = p_to + 1;
2571 d_last = ((long)p_to - (long)p_from) + d_next;
2572 nw = p_width;
2573 rc = TRUE;
2574
2575 do {
2576
2577 writeln(cmdunit, CRLF);
2578 padr(p_from, cmdunit);
2579
2580 dflag = FALSE;
2581
2582 if (ddump(p_from, p_to, nw, cmdunit))
2583 rc = FALSE;
2584
2585 if (rc)
2586 if (dtext(p_from, p_to, nw, cmdunit))
2587 rc = FALSE;
2588
2589 p_from = p_from + p_width;
2590
2591 if (dflag)
2592 rc = FALSE;
2593
2594 } while (rc);
2595
2596 p_from = d_cur;
2597
2598 writeln(cmdunit, CRLF);
2599 writeln(cmdunit, CRLF);
2600
2601 return(TRUE);
2602}
2603
2604/*
2605
2606*/
2607
2608/*
2609 ============================================================================
2610 wdump -- dump words in hex (no ASCII)
2611 ============================================================================
2612*/
2613
2614int wdump(UWORD16 *loc, UWORD16 *lastloc, int nwide, int unit)
2615{
2616 while (nwide--) {
2617
2618 puthn((long)(0xFFFFL & *loc), 4, unit);
2619 BIOS(B_PUTC,unit, ' ');
2620
2621 if (BIOS(B_RDAV, unit))
2622 return(TRUE);
2623
2624 if (loc EQ lastloc) {
2625
2626 dflag = TRUE;
2627 return(FALSE);
2628 }
2629
2630 ++loc;
2631 }
2632
2633 return(FALSE);
2634}
2635
2636/*
2637
2638*/
2639
2640/*
2641 ============================================================================
2642 ldump -- dump longs in hex (no ASCII)
2643 ============================================================================
2644*/
2645
2646int ldump(long *loc, long *lastloc, int nwide, int unit)
2647{
2648 while (nwide--) {
2649
2650 puthn(*loc, 8, unit);
2651 BIOS(B_PUTC,unit, ' ');
2652
2653 if (BIOS(B_RDAV, unit))
2654 return(TRUE);
2655
2656 if (loc EQ lastloc) {
2657
2658 dflag = TRUE;
2659 return(FALSE);
2660 }
2661
2662 ++loc;
2663 }
2664
2665 return(FALSE);
2666}
2667
2668/*
2669
2670*/
2671
2672/*
2673 ============================================================================
2674 cp_wdmp -- process parameters for wdump command
2675 ============================================================================
2676*/
2677
2678int cp_wdmp(void)
2679{
2680 inext = ilast;
2681
2682 if (getarg())
2683 if (setvar(&p_from, p_from) EQ FALSE) {
2684
2685 redo = FALSE;
2686 return(FALSE);
2687 }
2688
2689 if ((long)p_from & 1L) {
2690
2691 redo = FALSE;
2692 return(FALSE);
2693 }
2694
2695 if (argsep EQ A_CR OR argsep EQ '\0') {
2696
2697 p_to = p_from;
2698 p_width = 8;
2699 redo = TRUE;
2700 return(TRUE);
2701 }
2702
2703 if (getarg())
2704 if (setvar(&p_to, p_to) EQ FALSE) {
2705
2706 redo = FALSE;
2707 return(FALSE);
2708 }
2709
2710 if ((long)p_to & 1L) {
2711
2712 redo = FALSE;
2713 return(FALSE);
2714 }
2715
2716 if (argsep EQ A_CR OR argsep EQ '\0') {
2717
2718 p_width = 8;
2719 redo = TRUE;
2720 return(TRUE);
2721 }
2722
2723 if (getarg())
2724 if (setvar(&p_width, p_width) EQ FALSE) {
2725
2726 redo = FALSE;
2727 return(FALSE);
2728 }
2729
2730 redo = TRUE;
2731 return(TRUE);
2732}
2733
2734/*
2735
2736*/
2737
2738/*
2739 ============================================================================
2740 cp_ldmp -- process parameters for ldump command
2741 ============================================================================
2742*/
2743
2744int cp_ldmp(void)
2745{
2746 inext = ilast;
2747
2748 if (getarg())
2749 if (setvar(&p_from, p_from) EQ FALSE) {
2750
2751 redo = FALSE;
2752 return(FALSE);
2753 }
2754
2755 if ((long)p_from & 1L) {
2756
2757 redo = FALSE;
2758 return(FALSE);
2759 }
2760
2761 if (argsep EQ A_CR OR argsep EQ '\0') {
2762
2763 p_to = p_from;
2764 p_width = 4;
2765 redo = TRUE;
2766 return(TRUE);
2767 }
2768
2769 if (getarg())
2770 if (setvar(&p_to, p_to) EQ FALSE) {
2771
2772 redo = FALSE;
2773 return(FALSE);
2774 }
2775
2776 if ((long)p_to & 1L) {
2777
2778 redo = FALSE;
2779 return(FALSE);
2780 }
2781
2782 if (argsep EQ A_CR OR argsep EQ '\0') {
2783
2784 p_width = 4;
2785 redo = TRUE;
2786 return(TRUE);
2787 }
2788
2789 if (getarg())
2790 if (setvar(&p_width, p_width) EQ FALSE) {
2791
2792 redo = FALSE;
2793 return(FALSE);
2794 }
2795
2796 redo = TRUE;
2797 return(TRUE);
2798}
2799
2800/*
2801
2802*/
2803
2804/*
2805 ============================================================================
2806 cp_ilev -- parse the ipl command
2807 ============================================================================
2808*/
2809
2810int cp_ilev(void)
2811{
2812 long iplevl;
2813
2814 if (argsep EQ A_CR OR argsep EQ '\0')
2815 return(TRUE);
2816
2817 if (getarg())
2818 if (setvar(&iplevl, iplevl) EQ FALSE)
2819 return(FALSE);
2820
2821 if (iplevl GT 7)
2822 return(FALSE);
2823
2824 iplev = iplevl;
2825
2826 return(TRUE);
2827}
2828
2829/*
2830 ============================================================================
2831 cx_ilev -- execute ipl command
2832 ============================================================================
2833*/
2834
2835int cx_ilev(void)
2836{
2837 if (-1 EQ setipl(iplev)) {
2838
2839 printf("ERROR -- Could not set IPL to %d\r\n", iplev);
2840 return(FALSE);
2841 } else
2842 printf("ROMP IPL now set to %d\r\n", iplev);
2843
2844 return(TRUE);
2845}
2846
2847/*
2848
2849*/
2850
2851/*
2852 ============================================================================
2853 cp_monc() -- parse the monc command
2854 ============================================================================
2855*/
2856
2857int cp_monc(void)
2858{
2859 if (getarg())
2860 if (setvar(&monptr, monptr) EQ FALSE)
2861 return(FALSE);
2862
2863 monsw = MON_C;
2864 redo = TRUE;
2865 return(TRUE);
2866}
2867
2868/*
2869 ============================================================================
2870 cp_mons() -- parse the mons command
2871 ============================================================================
2872*/
2873
2874int cp_mons(void)
2875{
2876 if (getarg())
2877 if (setvar(&monptr, monptr) EQ FALSE)
2878 return(FALSE);
2879
2880 monsw = MON_S;
2881 redo = TRUE;
2882 return(TRUE);
2883}
2884
2885/*
2886
2887*/
2888
2889/*
2890 ============================================================================
2891 cp_monl() -- parse the monl command
2892 ============================================================================
2893*/
2894
2895int cp_monl(void)
2896{
2897 if (getarg())
2898 if (setvar(&monptr, monptr) EQ FALSE)
2899 return(FALSE);
2900
2901 monsw = MON_L;
2902 redo = TRUE;
2903 return(TRUE);
2904}
2905
2906/*
2907
2908*/
2909
2910/*
2911 ============================================================================
2912 cx_mon() -- process the mon commands
2913 ============================================================================
2914*/
2915
2916int cx_mon(void)
2917{
2918 register char vc, vcc;
2919 register short vs, vss, *vsp;
2920 register long vl, vll, *vlp;
2921
2922 switch (monsw) {
2923
2924 case MON_C:
2925
2926 vc = *monptr & 0x0FF;
2927 puthn((long)vc, 2, cmdunit);
2928 writeln(cmdunit, "\r\n");
2929
2930 while (!(0xFFFFL & BIOS(B_RDAV, CON_DEV))) {
2931
2932 vcc = *monptr & 0x0FF;
2933
2934 if (vc NE vcc) {
2935
2936 vc = vcc;
2937 puthn((long)vc, 2, cmdunit);
2938 writeln(cmdunit, "\r\n");
2939 }
2940 }
2941
2942 BIOS(B_GETC, CON_DEV);
2943 return(TRUE);
2944
2945 case MON_S:
2946
2947 vsp = (short *)monptr;
2948 vs = *vsp;
2949 puthn((long)vs, 4, cmdunit);
2950 writeln(cmdunit, "\r\n");
2951
2952 while (!(0xFFFFL & BIOS(B_RDAV, CON_DEV))) {
2953
2954 vss = *vsp;
2955
2956 if (vs NE vss) {
2957
2958 vs = vss;
2959 puthn((long)vs, 4, cmdunit);
2960 writeln(cmdunit, "\r\n");
2961 }
2962 }
2963
2964 BIOS(B_GETC, CON_DEV);
2965 return(TRUE);
2966
2967/*
2968
2969*/
2970 case MON_L:
2971
2972 vlp = (long *)monptr;
2973 vl = *vlp;
2974 puthn(vl, 8, cmdunit);
2975 writeln(cmdunit, "\r\n");
2976
2977 while (!(0xFFFFL & BIOS(B_RDAV, CON_DEV))) {
2978
2979 vll = *vlp;
2980
2981 if (vl NE vll) {
2982
2983 vl = vll;
2984 puthn(vl, 8, cmdunit);
2985 writeln(cmdunit, "\r\n");
2986 }
2987 }
2988
2989 BIOS(B_GETC, CON_DEV);
2990 return(TRUE);
2991
2992 default:
2993 return(FALSE);
2994 }
2995}
2996
2997/*
2998
2999*/
3000
3001/*
3002 ============================================================================
3003 cx_wdmp -- process wdump command
3004 ============================================================================
3005*/
3006
3007int cx_wdmp(void)
3008{
3009 int nw, rc;
3010
3011 d_cur = p_from;
3012 d_next = p_to + 2;
3013 d_last = ((long)p_to - (long)p_from) + d_next;
3014 nw = p_width;
3015 rc = TRUE;
3016
3017 do {
3018
3019 writeln(cmdunit, CRLF);
3020 padr(p_from, cmdunit);
3021 dflag = FALSE;
3022
3023 if (wdump(p_from, p_to, nw, cmdunit))
3024 rc = FALSE;
3025
3026 p_from = p_from + (p_width << 1);
3027
3028 if (dflag)
3029 rc = FALSE;
3030
3031 } while (rc);
3032
3033 p_from = d_cur;
3034
3035 writeln(cmdunit, CRLF);
3036 writeln(cmdunit, CRLF);
3037 return(TRUE);
3038}
3039
3040/*
3041
3042*/
3043
3044/*
3045 ============================================================================
3046 cx_ldmp -- process ldump command
3047 ============================================================================
3048*/
3049
3050int cx_ldmp(void)
3051{
3052 int nw, rc;
3053
3054 d_cur = p_from;
3055 d_next = p_to + 4;
3056 d_last = ((long)p_to - (long)p_from) + d_next;
3057 nw = p_width;
3058 rc = TRUE;
3059
3060 do {
3061
3062 writeln(cmdunit, CRLF);
3063 padr(p_from, cmdunit);
3064 dflag = FALSE;
3065
3066 if (ldump(p_from, p_to, nw, cmdunit))
3067 rc = FALSE;
3068
3069 p_from = p_from + (p_width << 2);
3070
3071 if (dflag)
3072 rc = FALSE;
3073
3074 } while (rc);
3075
3076 p_from = d_cur;
3077
3078 writeln(cmdunit, CRLF);
3079 writeln(cmdunit, CRLF);
3080 return(TRUE);
3081}
3082
3083/*
3084
3085*/
3086
3087/*
3088 ============================================================================
3089 do_cmd -- process a command line
3090 ============================================================================
3091*/
3092
3093void do_cmd(void)
3094{
3095 int rc, i;
3096
3097 /* prompt for a command line */
3098
3099#if TINYMSG
3100 writeln(cmdunit, "R: ");
3101#else
3102 writeln(cmdunit, "ROMP: ");
3103#endif
3104
3105 /* get a command line */
3106
3107 rc = getln(cmdunit, MAXCMDLN, cmdline);
3108
3109/*
3110
3111*/
3112
3113 /* dispatch based on rc */
3114
3115 switch (rc) {
3116
3117 case A_CR:
3118
3119 writeln(cmdunit, CRLF);
3120
3121 if (getcmd()) {
3122
3123 for (i = 0; i < NCMDS; i++) {
3124
3125 if (0 EQ strcmp(argstr, cmtab[i].cname)) {
3126
3127 ilast = i;
3128
3129 if ((*cmtab[i].cp)()) {
3130
3131 if (FALSE EQ (*cmtab[i].cx)())
3132 writeln(cmdunit, EMSG1);
3133
3134 } else {
3135
3136 writeln(cmdunit, EMSG2);
3137 }
3138
3139 return;
3140 }
3141 }
3142
3143 writeln(cmdunit, EMSG3);
3144 return;
3145
3146 } else {
3147
3148/*
3149
3150*/
3151
3152 if (redo) {
3153
3154 if (FALSE EQ (*cmtab[ilast].cx)())
3155 writeln(cmdunit, EMSG1);
3156
3157 } else {
3158
3159 writeln(cmdunit, EMSG5);
3160 }
3161
3162 return;
3163 }
3164
3165 case CTL('X'):
3166
3167 writeln(cmdunit, CANNED);
3168 return;
3169
3170 default:
3171
3172 writeln(cmdunit, EMSG6);
3173 return;
3174 }
3175
3176 writeln(cmdunit, EMSG7);
3177 return;
3178}
3179
3180/*
3181
3182*/
3183
3184/*
3185 ============================================================================
3186 cx_next -- process the next command
3187 ============================================================================
3188*/
3189
3190int cx_next(void)
3191{
3192 p_to = d_last;
3193 p_from = d_next;
3194 return((*cmtab[inext].cx)());
3195}
3196
3197/*
3198
3199*/
3200
3201/*
3202 ============================================================================
3203 cx_read() -- process the read command
3204 ============================================================================
3205*/
3206
3207int cx_read(void)
3208{
3209 long rc;
3210 int ns, recno;
3211
3212 ns = p_len & 0x7FFFL;
3213 recno = (long)p_from & 0xFFFFL;
3214
3215 rc = BIOS(B_RDWR, 2, p_to, ns, recno, 0);
3216
3217 if (rc & 0xFFFFL) {
3218
3219 writeln(cmdunit, "\r\nERROR reading disk: ");
3220 puthn(rc, 8, cmdunit);
3221 writeln(cmdunit, "\r\n\n");
3222 return(FALSE);
3223
3224 } else {
3225
3226 return(TRUE);
3227 }
3228}
3229
3230/*
3231
3232*/
3233
3234/*
3235 ============================================================================
3236 cx_writ() -- process the write command
3237 ============================================================================
3238*/
3239
3240int cx_writ(void)
3241{
3242 long rc;
3243 int ns, recno;
3244
3245 ns = p_len & 0x7FFFL;
3246 recno = (long)p_from & 0xFFFFL;
3247
3248 rc = BIOS(B_RDWR, 3, p_to, ns, recno, 0);
3249
3250 if (rc & 0xFFFFL) {
3251
3252 writeln(cmdunit, "\r\nERROR writing disk: ");
3253 puthn(rc, 8, cmdunit);
3254 writeln(cmdunit, "\r\n\n");
3255 return(FALSE);
3256
3257 } else {
3258
3259 return(TRUE);
3260 }
3261}
3262
3263/*
3264
3265*/
3266
3267/*
3268 ============================================================================
3269 showrs() -- show registers
3270 ============================================================================
3271*/
3272
3273void showrs(struct regs *rp)
3274{
3275 int i;
3276 UWORD16 srtemp;
3277
3278 writeln(cmdunit, " ");
3279
3280 for (i = 0; i < 8; i++) {
3281
3282 BIOS(B_PUTC, cmdunit, ' ');
3283 BIOS(B_PUTC, cmdunit, '0'+i);
3284 writeln(cmdunit, "_______");
3285 }
3286
3287 writeln(cmdunit, "\r\nd0..d7 ");
3288
3289 for (i = 0; i < 8; i++) {
3290
3291 BIOS(B_PUTC, cmdunit, ' ');
3292 puthn(rp->d_reg[i], 8, cmdunit);
3293 }
3294
3295 writeln(cmdunit, "\r\na0..a7 ");
3296
3297 for (i = 0; i < 8; i++) {
3298
3299 BIOS(B_PUTC, cmdunit, ' ');
3300 puthn(rp->a_reg[i], 8, cmdunit);
3301 }
3302
3303 writeln(cmdunit, "\r\nPC = ");
3304 puthn((long)rp->reg_pc, 8, cmdunit);
3305
3306 srtemp = rp->reg_sr;
3307 writeln(cmdunit, ", SR = ");
3308 puthn( (long)srtemp & 0xFFFFL, 4, cmdunit);
3309
3310/*
3311
3312*/
3313
3314 writeln(cmdunit, " (IPL = ");
3315 puthn( (long)(srtemp >> 8) & 0x7L, 1, cmdunit);
3316 writeln(cmdunit, ", ");
3317
3318 if (srtemp & 0x8000)
3319 BIOS(B_PUTC, cmdunit, 'T');
3320 else
3321 BIOS(B_PUTC, cmdunit, '-');
3322
3323 if (srtemp & 0x2000)
3324 BIOS(B_PUTC, cmdunit, 'S');
3325 else
3326 BIOS(B_PUTC, cmdunit, '-');
3327
3328 BIOS(B_PUTC, cmdunit, ' ');
3329
3330 if (srtemp & 0x10)
3331 BIOS(B_PUTC, cmdunit, 'X');
3332 else
3333 BIOS(B_PUTC, cmdunit, '-');
3334
3335 if (srtemp & 0x8)
3336 BIOS(B_PUTC, cmdunit, 'N');
3337 else
3338 BIOS(B_PUTC, cmdunit, '-');
3339
3340 if (srtemp & 0x4)
3341 BIOS(B_PUTC, cmdunit, 'Z');
3342 else
3343 BIOS(B_PUTC, cmdunit, '-');
3344
3345 if (srtemp & 0x2)
3346 BIOS(B_PUTC, cmdunit, 'V');
3347 else
3348 BIOS(B_PUTC, cmdunit, '-');
3349
3350 if (srtemp & 0x1)
3351 BIOS(B_PUTC, cmdunit, 'C');
3352 else
3353 BIOS(B_PUTC, cmdunit, '-');
3354
3355 writeln(cmdunit, " )\r\n");
3356}
3357
3358/*
3359
3360*/
3361
3362/*
3363 ============================================================================
3364 showcr() -- show crash registers
3365 ============================================================================
3366*/
3367
3368void showcr(void)
3369{
3370 register int i;
3371 register char *cause;
3372 register UWORD16 srtemp;
3373
3374 writeln(cmdunit, "BIOS Crash Area Dump\r\n");
3375 writeln(cmdunit, " ");
3376
3377 for (i = 0; i < 8; i++) {
3378
3379 BIOS(B_PUTC, cmdunit, ' ');
3380 BIOS(B_PUTC, cmdunit, '0'+i);
3381 writeln(cmdunit, "_______");
3382 }
3383
3384 writeln(cmdunit, "\r\nd0..d7 ");
3385
3386 for (i = 0; i < 8; i++) {
3387
3388 BIOS(B_PUTC, cmdunit, ' ');
3389 puthn(crshrg[i], 8, cmdunit);
3390 }
3391
3392 writeln(cmdunit, "\r\na0..a7 ");
3393
3394 for (i = 8; i < 16; i++) {
3395
3396 BIOS(B_PUTC, cmdunit, ' ');
3397 puthn(crshrg[i], 8, cmdunit);
3398 }
3399
3400 writeln(cmdunit, "\r\n\nPC = ");
3401 puthn((long)crshpc, 8, cmdunit);
3402
3403 srtemp = crshsr;
3404 writeln(cmdunit, ", SR = ");
3405 puthn((long)srtemp & 0xFFFFL, 4, cmdunit);
3406
3407/*
3408
3409*/
3410
3411 writeln(cmdunit, " (IPL = ");
3412 puthn((long)(srtemp >> 8) & 0x7L, 1, cmdunit);
3413 writeln(cmdunit, ", ");
3414
3415 if (srtemp & 0x8000)
3416 BIOS(B_PUTC, cmdunit, 'T');
3417 else
3418 BIOS(B_PUTC, cmdunit, '-');
3419
3420 if (srtemp & 0x2000)
3421 BIOS(B_PUTC, cmdunit, 'S');
3422 else
3423 BIOS(B_PUTC, cmdunit, '-');
3424
3425 BIOS(B_PUTC, cmdunit, ' ');
3426
3427 if (srtemp & 0x10)
3428 BIOS(B_PUTC, cmdunit, 'X');
3429 else
3430 BIOS(B_PUTC, cmdunit, '-');
3431
3432 if (srtemp & 0x8)
3433 BIOS(B_PUTC, cmdunit, 'N');
3434 else
3435 BIOS(B_PUTC, cmdunit, '-');
3436
3437 if (srtemp & 0x4)
3438 BIOS(B_PUTC, cmdunit, 'Z');
3439 else
3440 BIOS(B_PUTC, cmdunit, '-');
3441
3442 if (srtemp & 0x2)
3443 BIOS(B_PUTC, cmdunit, 'V');
3444 else
3445 BIOS(B_PUTC, cmdunit, '-');
3446
3447 if (srtemp & 0x1)
3448 BIOS(B_PUTC, cmdunit, 'C');
3449 else
3450 BIOS(B_PUTC, cmdunit, '-');
3451
3452 writeln(cmdunit, " )\r\n");
3453
3454/*
3455
3456*/
3457 writeln(cmdunit, "TRAP vector number = ");
3458 putn((long)crshvc[0], 2, cmdunit);
3459
3460 cause = " (no handler for interrupt)";
3461
3462 switch (crshvc[0] & 0xFF) {
3463
3464 case 2: /* 2: bus error */
3465
3466 cause = " (Bus error)";
3467 break;
3468
3469 case 3: /* 3: address error */
3470
3471 cause = " (Address error)";
3472 break;
3473
3474 case 4: /* 4: illegal instruction */
3475
3476 cause = " (Illegal instruction)";
3477 break;
3478
3479 case 5: /* 5: zero divide */
3480
3481 cause = " (Zero divide)";
3482 break;
3483
3484 case 6: /* 6: CHK instruction */
3485
3486 cause = " (CHK instruction)";
3487 break;
3488
3489 case 7: /* 7: TRAPV instruction */
3490
3491 cause = " (TRAPV instruction)";
3492 break;
3493
3494 case 8: /* 8: privilege violation */
3495
3496 cause = " (Privilege violation)";
3497 break;
3498
3499 case 9: /* 9: trace */
3500
3501 cause = " (Trace -- not implemented)";
3502 break;
3503
3504 case 10: /* 10: line 1010 emulator */
3505
3506 cause = " (Line 1010 Emulator -- not implemented)";
3507 break;
3508
3509 case 11: /* 11: line 1111 emulator */
3510
3511 cause = " (Line 1111 Emulator -- not implemented";
3512 break;
3513
3514 case 15: /* 15: uninitialized interrupt vector */
3515
3516 cause = " (Uninitialized interrupt)";
3517 break;
3518
3519 case 24: /* 24: spurious interrupt */
3520
3521 cause = " (Spurious interrupt)";
3522 break;
3523
3524 case 25: /* 25: Autovector Level 1*/
3525
3526 cause = " (Level 1 Interrupt -- unimplmented)";
3527 break;
3528
3529 case 26: /* 26: Autovector Level 2 */
3530
3531 cause = " (Level 2 Interrupt -- unimplmented)";
3532 break;
3533
3534 case 27: /* 27: Autovector Level 3 */
3535
3536 cause = " (Level 3 Interrupt -- unimplmented)";
3537 break;
3538
3539 case 28: /* 28: Autovector Level 4 */
3540
3541 cause = " (Level 4 Interrupt -- unimplmented)";
3542 break;
3543
3544 case 29: /* 29: Autovector Level 5 */
3545
3546 cause = " (Level 5 Interrupt -- unimplmented)";
3547 break;
3548
3549 case 30: /* 30: Autovector Level 6 */
3550
3551 cause = " (Level 6 Interrupt -- unimplmented)";
3552 break;
3553
3554 case 31: /* 31: Autovector Level 7 */
3555
3556 cause = " (Level 7 Interrupt -- unimplmented)";
3557 break;
3558
3559 }
3560
3561 writeln(cmdunit, cause);
3562 writeln(cmdunit, "\r\n");
3563}
3564
3565/*
3566
3567*/
3568
3569/*
3570 ============================================================================
3571 cx_crsh -- process the crash command
3572 ============================================================================
3573*/
3574
3575int cx_crsh(void)
3576{
3577 if (!wzcrsh)
3578 printf("** Crash switch NOT set **\r\n");
3579
3580 redo = FALSE;
3581 showcr();
3582 return(TRUE);
3583}
3584
3585/*
3586
3587*/
3588
3589/*
3590 ============================================================================
3591 bphit -- clear breakpoints, see if any were hit
3592 ============================================================================
3593*/
3594
3595int bphit(void)
3596{
3597 int rc;
3598
3599 rc = FALSE;
3600
3601 if ((char *)p_ba0 EQ regptr->reg_pc) {
3602
3603 if (*p_ba0 EQ BPINST) {
3604
3605 *p_ba0 = p_bv0;
3606 p_ba0 = 0L;
3607 p_bv0 = BPINST;
3608 rc = TRUE;
3609
3610 } else {
3611
3612 writeln(cmdunit, "** Breakpoint word at ");
3613 puthn(p_ba0, 8 , cmdunit);
3614 writeln(cmdunit, " was ");
3615 puthn(0xFFFFL & (long)(*p_ba0), 4, cmdunit);
3616 writeln(cmdunit, " instead of ");
3617 puthn((long)BPINST, 4, cmdunit);
3618 writeln(cmdunit, " **\r\n\n");
3619 rc = TRUE;
3620 }
3621 }
3622
3623/*
3624
3625*/
3626
3627 if ((char *)p_ba1 EQ regptr->reg_pc) {
3628
3629 if (*p_ba1 EQ BPINST) {
3630
3631 *p_ba1 = p_bv1;
3632 p_ba1 = 0L;
3633 p_bv1 = BPINST;
3634 rc = TRUE;
3635
3636 } else {
3637
3638 writeln(cmdunit, "** Breakpoint word at ");
3639 puthn((long)p_ba0, 8 , cmdunit);
3640 writeln(cmdunit, " was ");
3641 puthn(0xFFFFL & (long)(*p_ba1), 4, cmdunit);
3642 writeln(cmdunit, " instead of ");
3643 puthn((long)BPINST, 4, cmdunit);
3644 writeln(cmdunit, " **\r\n\n");
3645 rc = TRUE;
3646 }
3647 }
3648/*
3649
3650*/
3651 if (p_ba0) {
3652
3653 if (*p_ba0 EQ BPINST) {
3654
3655 *p_ba0 = p_bv0;
3656 p_ba0 = 0L;
3657 p_bv0 = BPINST;
3658 rc = TRUE;
3659
3660 } else {
3661
3662 writeln(cmdunit, "** Breakpoint word at ");
3663 puthn(p_ba0, 8 , cmdunit);
3664 writeln(cmdunit, " was ");
3665 puthn(0xFFFFL & (long)(*p_ba0), 4, cmdunit);
3666 writeln(cmdunit, " instead of ");
3667 puthn((long)BPINST, 4, cmdunit);
3668 writeln(cmdunit, " **\r\n\n");
3669 rc = TRUE;
3670 }
3671 }
3672
3673/*
3674
3675*/
3676
3677 if (p_ba1) {
3678
3679 if (*p_ba1 EQ BPINST) {
3680
3681 *p_ba1 = p_bv1;
3682 p_ba1 = 0L;
3683 p_bv1 = BPINST;
3684 rc = TRUE;
3685
3686 } else {
3687
3688 writeln(cmdunit, "** Breakpoint word at ");
3689 puthn((long)p_ba0, 8 , cmdunit);
3690 writeln(cmdunit, " was ");
3691 puthn(0xFFFFL & (long)(*p_ba1), 4, cmdunit);
3692 writeln(cmdunit, " instead of ");
3693 puthn((long)BPINST, 4, cmdunit);
3694 writeln(cmdunit, " **\r\n\n");
3695 rc = TRUE;
3696 }
3697 }
3698
3699 if (rc)
3700 return(rc);
3701
3702 writeln(cmdunit, "\r\n** Program invoked ROMP trap **\r\n");
3703 return(FALSE);
3704}
3705
3706/*
3707
3708*/
3709
3710/*
3711 ============================================================================
3712 cx_regs() -- process the regs command
3713 ============================================================================
3714*/
3715
3716int cx_regs(void)
3717{
3718 showrs(regptr);
3719 return(TRUE);
3720}
3721
3722/*
3723
3724*/
3725
3726/*
3727 ============================================================================
3728 rompbp() -- process a breakpoint for ROMP
3729 ============================================================================
3730*/
3731
3732void rompbp(long d0, long d1, long d2, long d3, long d4, long d5, long d6, long d7, char *a0, char *a1, char *a2, char *a3, char *a4, char *a5, char *a6, char *a7, char *pc, UWORD16 sr0, UWORD16 sr)
3733{
3734 register int i;
3735
3736 regptr = (struct regs *)&d0; /* make registers accessable */
3737 pc -= 2L; /* adjust pc */
3738
3739 if (-1 EQ setipl(iplev)) /* enable interrupts */
3740 writeln(cmdunit, "\r\n\n***** setipl() failed *****\r\n\n");
3741
3742 if (first1) { /* initial entry from xtrap15() */
3743
3744 for (i = 0; i < 8; i++) /* clear d0..d7 */
3745 regptr->d_reg[i] = 0L;
3746
3747 for (i = 0; i < 7; i++) /* clear a0..a6 */
3748 regptr->a_reg[i] = (char *)0L;
3749
3750 regptr->a_reg[7] = ISTACK; /* setup initial stack */
3751
3752 sr = INITSR; /* setup sr */
3753 pc += 2L; /* adjust pc past TRAP 15 */
3754
3755 } else { /* breakpoint */
3756
3757 writeln(cmdunit, "\r\n\n** ROMP Breakpoint TRAP **\r\n");
3758
3759 showrs(regptr); /* show registers */
3760
3761 if (bphit() EQ FALSE) /* fixup breakpoints */
3762 pc += 2L; /* and maybe the pc */
3763
3764 }
3765
3766 first1 = FALSE; /* not first time any more */
3767 exflag = FALSE; /* clear exit flag */
3768
3769 do {
3770
3771 do_cmd(); /* process commands ... */
3772
3773 } while (!exflag); /* ... until exit flag is set */
3774
3775 return; /* return to xtrap15 */
3776}
3777
3778/*
3779
3780*/
3781
3782/*
3783 ============================================================================
3784 progid() -- identify the program
3785 ============================================================================
3786*/
3787
3788void progid(void)
3789{
3790 register char *pcptr;
3791
3792#if TINYMSG
3793
3794#if ON_B700
3795 writeln(cmdunit, "\r\n\nB\r\n");
3796#else
3797 writeln(cmdunit, "\r\n\nN\r\n");
3798#endif
3799
3800#else
3801
3802#if ON_B700
3803 writeln(cmdunit, "\r\n\nBuchla 700 BIOS / Debug PROM\r\n");
3804#else
3805 writeln(cmdunit, "\r\n\nNASA 3D Helmet Display BIOS / Debug PROM\r\n");
3806#endif
3807
3808 writeln(cmdunit, " ROMP Version ");
3809 writeln(cmdunit, ROMPVER);
3810
3811 writeln(cmdunit, "\r\n BIOS Version ");
3812 pcptr = (char *)PRM_VERS;
3813 putn((long)*pcptr++, 2, cmdunit);
3814 BIOS(B_PUTC, cmdunit, '.');
3815 putn((long)*pcptr++, 2, cmdunit);
3816 writeln(cmdunit, promdate);
3817
3818#endif
3819}
3820
3821/*
3822
3823*/
3824
3825#if ON_B700
3826
3827
3828/*
3829 ============================================================================
3830 pclr() -- clear the panel FIFO
3831 ============================================================================
3832*/
3833
3834short pclr(void)
3835{
3836 register short i;
3837
3838 ftimer = FIFOLIM;
3839
3840 while (-1L NE (afi = XBIOS(X_ANALOG))) { /* check panel inputs */
3841
3842 asig = 0x007F & (afi >> 8); /* signal number */
3843
3844 if (0 EQ asig) {
3845
3846 /* all keys up */
3847
3848 for (i = 0; i < 128; i++) {
3849
3850 sigtab[i][0] = 0;
3851 sigtab[i][1] = 0;
3852 }
3853
3854 break;
3855 }
3856
3857 if (ftimer-- < 0)
3858 return(FAILURE);
3859 }
3860
3861 return(SUCCESS);
3862}
3863
3864/*
3865
3866*/
3867
3868/*
3869 ============================================================================
3870 pscan() -- scan the panel and maybe even load a program from diskette
3871 ============================================================================
3872*/
3873
3874short pscan(void)
3875{
3876 register short i, c;
3877
3878 if (0 EQ ledcntr--) {
3879
3880 if ((baseled + 3) > 23) /* turn on a LED */
3881 io_leds = baseled - 21;
3882 else
3883 io_leds = baseled + 3;
3884
3885 io_leds = 0x80 + baseled; /* turn off a LED */
3886
3887 if (++baseled > 23) /* update LED number */
3888 baseled = 0;
3889
3890 ledcntr = 200;
3891 }
3892
3893 aflag = FALSE;
3894
3895 if (-1L NE (afi = XBIOS(X_ANALOG))) { /* check panel inputs */
3896
3897 asig = 0x007F & (afi >> 8); /* signal number */
3898 astat = 0x0001 & (afi >> 7); /* status */
3899 aval = 0x007F & afi; /* value */
3900
3901 if (asig) { /* active signal */
3902
3903 aflag = TRUE;
3904
3905 sigtab[asig][0] = aval;
3906 sigtab[asig][1] = astat;
3907
3908 } else { /* all keys up */
3909
3910 aflag = FALSE;
3911
3912 for (i = 0; i < 128; i++)
3913 sigtab[i][1] = 0;
3914 }
3915 }
3916/*
3917
3918*/
3919 if (aflag) { /* anything changed ? */
3920
3921 if (astat AND (asig EQ BOOTKEY)) { /* BOOT key */
3922
3923 for (i = 0; i < 24; i++) /* turn off LEDs */
3924 io_leds = 0x80 + i;
3925
3926 io_leds = 0x1F; /* turn off LCD lamp */
3927
3928 /* load and run BOOTFILE */
3929
3930 B_log_s = FALSE;
3931 B_dbg_s = FALSE;
3932
3933 hdvini();
3934 _bpbin = FALSE;
3935
3936 if (booter(BOOTFILE, 0L))
3937 return(FALSE);
3938 else
3939 sjumpto(B_buf_a, ISTACK);
3940
3941 } else if (astat AND (asig EQ ROMPKEY)) { /* ROMP key */
3942
3943 for (i = 0; i < 24; i++) /* turn off LEDs */
3944 io_leds = 0x80 + i;
3945
3946 return(TRUE);
3947 }
3948 }
3949
3950/*
3951
3952*/
3953
3954 if (BIOS(B_RDAV, CON_DEV)) {
3955
3956 c = 0x007F & BIOS(B_GETC, CON_DEV);
3957
3958 if ((c EQ 'r') OR (c EQ 'R'))
3959 return(TRUE);
3960 }
3961
3962 return(FALSE);
3963}
3964#endif
3965
3966/*
3967
3968*/
3969
3970/*
3971 ============================================================================
3972 romp main routine
3973 ============================================================================
3974*/
3975
3976void main(void)
3977{
3978 register short i;
3979 register char *pdptr, *pcptr;
3980
3981 /* unpack PROM date */
3982
3983 pcptr = (char *)PRM_DATE; /* prom date: yyyymmdd */
3984 pdptr = promdate; /* -- yyyy-mm-dd */
3985 *pdptr++ = ' ';
3986 *pdptr++ = '-';
3987 *pdptr++ = '-';
3988 *pdptr++ = ' ';
3989 *pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
3990 *pdptr++ = (*pcptr++ & 0x0F) + '0';
3991 *pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
3992 *pdptr++ = (*pcptr++ & 0x0F) + '0';
3993 *pdptr++ = '-';
3994 *pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
3995 *pdptr++ = (*pcptr++ & 0x0F) + '0';
3996 *pdptr++ = '-';
3997 *pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
3998 *pdptr++ = (*pcptr++ & 0x0F) + '0';
3999 *pdptr++ = '\0';
4000
4001 /* initialize variables */
4002
4003 sprintf(hs_mtst, "[[start=$%lX],[end=$%lx]] (or $8..$%lX)",
4004 USER_RAM, RAM_TOP, (USER_RAM - 2L));
4005
4006 cmdunit = CON_DEV;
4007
4008 ilast = 0;
4009 inext = 0;
4010 iplev = DEFIPL;
4011
4012 dflag = FALSE;
4013 exflag = FALSE;
4014 redo = FALSE;
4015 goflag = FALSE;
4016 b0flag = FALSE;
4017 b1flag = FALSE;
4018
4019 p_goto = (char *)ROMADDR;
4020 p_len = 0L;
4021 p_width = 16L;
4022 p_value = 0L;
4023
4024 p_ba0 = 0L;
4025 p_bv0 = BPINST;
4026
4027 p_ba1 = 0L;
4028 p_bv1 = BPINST;
4029
4030 tba0 = 0L;
4031 tba1 = 0L;
4032
4033 inext = 0;
4034
4035 tsetup(); /* patch the timer interrupt code */
4036
4037#if ON_B700
4038 baseled = 21; /* setup LED scan */
4039 ledcntr = 0; /* ... */
4040 io_leds = 0x9F; /* turn on LCD lamp */
4041 GLCinit(); /* reset LCD display */
4042
4043 GLCtext(0, 1, "Load GoTo");
4044 GLCtext(1, 1, "Disk ROMP");
4045
4046 GLCtext(3, 15, "Buchla 700 -- BIOS/ROMP Firmware by D.N. Lynx Crowe");
4047
4048 sprintf(idbuf, "BIOS Version %02d.%02d%s",
4049 *(char *)PRM_VERS, *(char *)(PRM_VERS+1), promdate);
4050 GLCtext(5, 30, idbuf);
4051
4052 sprintf(idbuf, "ROMP Version %s", ROMPVER);
4053 GLCtext(6, 30, idbuf);
4054 GLCcrc(0, 0);
4055
4056 (char *)BIOS(B_SETV, 47, trap15); /* set ROMP trap vec */
4057
4058 for (i = 0; i < 128; i++) {
4059
4060 sigtab[i][0] = 0;
4061 sigtab[i][1] = 0;
4062 }
4063
4064 XBIOS(X_CLRAFI); /* clear the panel FIFO */
4065 setipl(KB_EI); /* enable interrupts */
4066 pclr(); /* empty the panel FIFO */
4067 XBIOS(X_CLRAFI); /* clear the panel FIFO */
4068
4069 while (FALSE EQ pscan()) ; /* do the panel scan */
4070#endif
4071
4072/*
4073
4074*/
4075 if (setjmp(&restart)) /* setup restart point */
4076 writeln(cmdunit, "\r\n***** ROMP Re-starting *****\r\n\n");
4077
4078 tsetup(); /* patch the timer interrupt code */
4079 progid(); /* identify the program */
4080
4081 (char *)BIOS(B_SETV, 47, trap15); /* set ROMP trap vec */
4082 writeln(cmdunit, "\r\n\n");
4083
4084 /* process commands */
4085
4086 first1 = TRUE; /* set break init flag */
4087
4088 while (TRUE) {
4089
4090 xtrap15(); /* trap into ROMP bp processor */
4091 writeln(cmdunit, "\r\n** xtrap15() returned to ROMP **\r\n\n");
4092 }
4093}
Note: See TracBrowser for help on using the repository browser.