source: buchla-68k/orig/RAM/STMPROC.C@ 9bf0f86

Last change on this file since 9bf0f86 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 22.9 KB
RevLine 
[3ae31e9]1/*
2 =============================================================================
3 stmproc.c -- MIDAS-VII Patch facility support functions
4 Version 33 -- 1988-12-06 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define DEBUGDP 0
9#define DEBUGEP 0
10#define DEBUGFD 0
11#define DEBUGFP 0
12#define DEBUGSR 0
13
14#define PATCHDEF /* so patch.h gets it right */
15
16#include "stddefs.h"
17#include "graphdef.h"
18#include "hwdefs.h"
19#include "patch.h"
20#include "vsdd.h"
21#include "wordq.h"
22
23#include "midas.h"
24#include "ptdisp.h"
25
26extern short ptegood, ptedfok, ptestok, ptedsok, ptedtok;
27
28extern short ptedef, ptestm, ptespec, ptesuba, ptedat1;
29
30extern short pteset;
31
32extern short ptecpos, ptepred, ptesucc;
33
34extern struct patch ptebuf;
35
36extern char ptdebuf[];
37
38#if DEBUGDP
39short debugdp = 1;
40#endif
41
42#if DEBUGEP
43short debugep = 0;
44short snapep = 1;
45#endif
46
47#if DEBUGFD
48short debugfd = 0;
49#endif
50
51#if DEBUGFP
52short debugfp = 1;
53#endif
54
55#if DEBUGSR
56short debugsr = 1;
57short snapsr = 1;
58#endif
59
60#if (DEBUGDP|DEBUGEP|DEBUGFD|DEBUGFP|DEBUGSR)
61extern short debugsw;
62#endif
63
64unsigned short dtfree; /* defent free list index */
65unsigned short ptfree; /* patch free list index */
66
67unsigned short dpepred; /* defent predecessor index */
68unsigned short dpecpos; /* current defent index */
69unsigned short dpesucc; /* defent successor index */
70
71char ptdsbuf[50]; /* patch display build buffer */
72
73char defptr[NDEFSTMS]; /* definition index table */
74char stmptr[NDEFSTMS]; /* stimulus index table */
75
76struct defent defents[RAWDEFS]; /* definition control table */
77
78struct patch patches[MAXPATCH]; /* patch table */
79
80struct wordq ptefifo; /* patch trigger fifo header */
81
82unsigned short ptewrds[NPTEQELS]; /* patch trigger fifo entries */
83
84char dmatch[] = { /* addat1 match tags */
85
86 0, 0, 0, 0, 0, 0, 0, 0, /* 0 .. 7 */
87 0, 0, 0, 1, 0, 0, 0, 0, /* 8 .. 15 */
88 1, 1, 1, 1, 1, 1, 1, 1, /* 16 .. 23 */
89 1, 1, 1 /* 24 .. 26 */
90};
91
92/*
93
94*/
95
96/*
97 =============================================================================
98 initpt() -- initialize patch table data structure
99 =============================================================================
100*/
101
102initpt()
103{
104 register unsigned short i;
105
106 /* initialize the trigger fifo */
107
108 setwq(&ptefifo, ptewrds, NPTEQELS, NPTEQHI, NPTEQLO);
109
110 /* clear DEF / STM index tables */
111
112 memset(defptr, 0, sizeof defptr);
113 memset(stmptr, 0, sizeof stmptr);
114
115 /* setup patch free chain */
116
117 memset(patches, 0, sizeof patches);
118
119 for (i = 1; i < 255; i++)
120 patches[i].nextstm = 1 + i;
121
122 ptfree = 1;
123
124 /* setup defent free chain */
125
126 memset(defents, 0, sizeof defents);
127
128 for (i = 1; i < 255; i++)
129 defents[i].nextdef = 1 + i;
130
131 dtfree = 1;
132}
133
134/*
135
136*/
137
138/*
139 =============================================================================
140 pt_alc() -- allocate a patch table entry from the free list
141 =============================================================================
142*/
143
144unsigned short
145pt_alc()
146{
147 register unsigned short pe;
148
149 if (0 NE (pe = ptfree))
150 ptfree = patches[pe].nextstm;
151
152 return(pe);
153}
154
155/*
156 =============================================================================
157 pt_del() -- return a patch table entry to the free list
158 =============================================================================
159*/
160
161pt_del(pe)
162register unsigned short pe;
163{
164 patches[pe].nextstm = ptfree;
165 ptfree = pe;
166}
167
168/*
169
170*/
171
172/*
173 =============================================================================
174 dt_alc() -- allocate a def table entry from the free list
175 =============================================================================
176*/
177
178unsigned short
179dt_alc()
180{
181 register unsigned short de;
182
183 if (0 NE (de = dtfree))
184 dtfree = defents[de].nextdef;
185
186 return(de);
187}
188
189/*
190 =============================================================================
191 dt_del() -- return a def table entry to the free list
192 =============================================================================
193*/
194
195dt_del(de)
196register unsigned short de;
197{
198 defents[de].nextdef = dtfree;
199 dtfree = de;
200}
201
202/*
203
204*/
205
206/*
207 =============================================================================
208 cprdpe() -- compare patch buffer to def table entry
209
210 Returns:
211 -1 = buffer < table entry
212 0 = buffer EQ table entry
213 +1 = buffer > table entry
214 =============================================================================
215*/
216
217short
218cprdpe(np)
219unsigned short np;
220{
221 register unsigned short ca, cb, ct;
222 register struct defent *pp;
223
224 pp = &defents[np];
225
226 if ((cb = ptestm) < (ct = pp->stm))
227 return(-1);
228
229 if (cb > ct)
230 return(1);
231
232 if ((ca = (PE_SPEC & ptespec)) < (ct = (PE_SPEC & pp->adspec)))
233 return(-1);
234
235 if (ca > ct)
236 return(1);
237
238 if ((cb = ptesuba) < (ct = pp->adsuba))
239 return(-1);
240
241 if (cb > ct)
242 return(1);
243/*
244
245*/
246 /* check for extended destinations -- they need further testing */
247
248 if (dmatch[ca]) { /* check destination type */
249
250 if ((cb = ptedat1) < (ct = pp->addat1))
251 return(-1);
252
253 if (cb > ct)
254 return(1);
255 else
256 return(0);
257
258 } else {
259
260 return(0);
261 }
262}
263
264/*
265
266*/
267
268/*
269 =============================================================================
270 finddpe() -- find def table entry
271
272 Returns: +1 = new def -- no DEF entry yet
273 0 = old def -- entry found in DEF chain
274 -1 = new def -- entry not in DEF chain
275
276 Sets: dpepred predecessor index, or 0 if none exists
277 dpecpos def table index, or 0 if none exists
278 dpesucc successor index, or 0 if none exists
279 =============================================================================
280*/
281
282short
283finddpe()
284{
285 register unsigned short c, idef;
286
287 dpepred = 0; /* initialize dpepred = 0 (no predecessor) */
288 dpecpos = 0; /* initialize dpecpos = 0 (no current defent */
289 dpesucc = 0; /* initialize dpesucc = 0 (no successor) */
290
291#if DEBUGFD
292 if (debugsw AND debugfd) {
293
294 printf("finddpe(): entry\n");
295
296 printf(" ptb $%04.4X $%04.4X $%04.4X $%04.4X $%04.4X $%04.4X\n",
297 ptebuf.defnum, ptebuf.stmnum, ptebuf.paspec,
298 ptebuf.pasuba, ptebuf.padat1, ptebuf.padat2);
299 }
300#endif
301
302 /* try to find the DEF chain index for the defent in defptr[] */
303
304 if (0 EQ (idef = defptr[TRG_MASK & ptebuf.defnum])) {
305
306#if DEBUGFD
307 if (debugsw AND debugfd) {
308
309 printf("finddpe(): 1 -- NO DEF -- ");
310 printf("dpe pred: %3d cpos: %3d succ: %3d\n",
311 dpepred, dpecpos, dpesucc);
312 }
313#endif
314
315 return(1); /* +1 = new defent -- no DEF entry yet */
316 }
317
318/*
319
320*/
321
322 while (idef) { /* search the DEF chain */
323
324 /* compare ptebuf to defents[idef] */
325
326 if (1 NE (c = cprdpe(idef))) {
327
328 if (c EQ 0) { /* if we find the defent ... */
329
330 dpecpos = idef; /* ... point at it */
331 dpesucc = defents[idef].nextdef;
332
333 }
334
335#if DEBUGFD
336 if (debugsw AND debugfd) {
337
338 printf("finddpe(): %d -- %s -- ", c,
339 c ? "NOT FOUND (>)" : "FOUND");
340
341 printf("dpe pred: %3d cpos: %3d succ: %3d\n",
342 dpepred, dpecpos, dpesucc);
343 }
344#endif
345 return(c); /* return search result */
346 }
347
348 dpepred = idef; /* point at next entry in DEF chain */
349 idef = defents[idef].nextdef;
350 }
351
352#if DEBUGFD
353 if (debugsw AND debugfd) {
354
355 printf("finddpe(): -1 -- NOT FOUND (<) -- ");
356 printf("dpe pred: %3d cpos: %3d succ: %3d\n",
357 dpepred, dpecpos, dpesucc);
358 }
359#endif
360
361 return(-1); /* -1 = new defent -- entry not in DEF chain */
362}
363
364/*
365
366*/
367
368/*
369 =============================================================================
370 cprpte() -- compare patch buffer to patch table entry
371
372 Returns:
373 -1 = buffer < table entry
374 0 = buffer EQ table entry
375 +1 = buffer > table entry
376 =============================================================================
377*/
378
379short
380cprpte(np)
381unsigned short np;
382{
383 register unsigned short ca, cb, ct;
384 register struct patch *pb, *pp;
385
386 pb = &ptebuf;
387 pp = &patches[np];
388
389 if ((cb = pb->stmnum) < (ct = pp->stmnum))
390 return(-1);
391
392 if (cb > ct)
393 return(1);
394
395 if ((cb = pb->defnum) < (ct = pp->defnum))
396 return(-1);
397
398 if (cb > ct)
399 return(1);
400
401 if ((ca = (PE_SPEC & pb->paspec)) < (ct = (PE_SPEC & pp->paspec)))
402 return(-1);
403
404 if (ca > ct)
405 return(1);
406
407 if ((cb = pb->pasuba) < (ct = pp->pasuba))
408 return(-1);
409
410 if (cb > ct)
411 return(1);
412/*
413
414*/
415 /* check for extended destinations -- they need further testing */
416
417 if (dmatch[ca]) { /* check destination type */
418
419 if ((cb = pb->padat1) < (ct = pp->padat1))
420 return(-1);
421
422 if (cb > ct)
423 return(1);
424 else
425 return(0);
426
427 } else {
428
429 return(0);
430 }
431}
432
433/*
434
435*/
436
437/*
438 =============================================================================
439 findpte() -- find patch table entry
440
441 Returns: +1 = new patch -- no STM entry yet
442 0 = old patch -- entry found in STM chain
443 -1 = new patch -- entry not in STM chain
444
445 Sets: ptepred predecessor index, or 0 if none exists
446 ptecpos patch table index, or 0 if none exists
447 ptesucc successor index, or 0 if none exists
448 =============================================================================
449*/
450
451short
452findpte()
453{
454 register unsigned short c, istim;
455
456 ptepred = 0; /* initialize ptepred = 0 (no predecessor) */
457 ptecpos = 0; /* initialize ptecpos = 0 (no current patch */
458 ptesucc = 0; /* initialize ptesucc = 0 (no successor) */
459
460#if DEBUGFP
461 if (debugsw AND debugfp) {
462
463 printf("findpte(): entry\n");
464
465 printf(" ptb $%04.4X $%04.4X $%04.4X $%04.4X $%04.4X $%04.4X\n",
466 ptebuf.defnum, ptebuf.stmnum, ptebuf.paspec,
467 ptebuf.pasuba, ptebuf.padat1, ptebuf.padat2);
468 }
469#endif
470
471 /* try to find the STM chain index for the patch in stmptr[] */
472
473 if (0 EQ (istim = stmptr[TRG_MASK & ptebuf.stmnum])) {
474
475#if DEBUGFP
476 if (debugsw AND debugfp) {
477
478 printf("findpte(): 1 -- NO STM -- ");
479 printf("pte pred: %3d cpos: %3d succ: %3d\n",
480 ptepred, ptecpos, ptesucc);
481 }
482#endif
483
484 return(1); /* +1 = new patch -- no STM entry yet */
485 }
486
487/*
488
489*/
490
491 while (istim) { /* search the STM chain */
492
493 /* compare ptebuf to patches[istim] */
494
495 if (1 NE (c = cprpte(istim))) {
496
497 if (c EQ 0) { /* if we find the patch ... */
498
499 ptecpos = istim; /* ... point at it */
500 ptesucc = patches[istim].nextstm;
501
502 }
503
504#if DEBUGFP
505 if (debugsw AND debugfp) {
506
507 printf("findpte(): %d -- %s -- ", c,
508 c ? "NOT FOUND (>)" : "FOUND");
509
510 printf("pte pred: %3d cpos: %3d succ: %3d\n",
511 ptepred, ptecpos, ptesucc);
512 }
513#endif
514 return(c); /* return search result */
515 }
516
517 ptepred = istim; /* point at next entry in STM chain */
518 istim = patches[istim].nextstm;
519 }
520
521#if DEBUGFP
522 if (debugsw AND debugfp) {
523
524 printf("findpte(): -1 -- NOT FOUND (<) -- ");
525 printf("pte pred: %3d cpos: %3d succ: %3d\n",
526 ptepred, ptecpos, ptesucc);
527 }
528#endif
529
530 return(-1); /* -1 = new patch -- entry not in STM chain */
531}
532
533/*
534
535*/
536
537/*
538 =============================================================================
539 entrpte() -- enter or update a patch table entry
540 =============================================================================
541*/
542
543entrpte()
544{
545 register short c;
546 register unsigned short np, stim;
547
548 ptegood = ptedfok AND ptestok AND ptedsok AND ptedtok;
549
550 if (ptegood) {
551
552 buf2pte();
553
554 c = findpte();
555
556 if (c EQ 0) { /* old patch -- just update it */
557
558 memcpyw(&patches[ptecpos].defnum, &ptebuf.defnum, 6);
559
560 patches[ptecpos].paspec |= PE_TBIT; /* define it */
561
562#if DEBUGEP
563 if (debugsw AND debugep) {
564
565 if (snapep)
566 SnapPTV("entrpte");
567
568 printf("entrpte(): UPDATED\n");
569 }
570#endif
571
572 return;
573 }
574/*
575
576*/
577 /* allocate a patch entry and fill it in */
578
579 if (0 EQ (ptecpos = pt_alc())) {
580
581#if DEBUGEP
582 if (debugsw AND debugep)
583 printf("entrpte(): patch table FULL\n");
584#endif
585 return; /* no patch entries left */
586 }
587
588 memcpyw(&patches[ptecpos].defnum, &ptebuf.defnum, 6);
589 patches[ptecpos].paspec |= PE_TBIT; /* define it */
590 stim = TRG_MASK & ptebuf.stmnum;
591
592 if (c EQ 1) { /* new patch -- no STM entry yet */
593
594 ptepred = 0;
595 stmptr[stim] = ptecpos;
596 }
597/*
598
599*/
600 /* put patch in STM chain */
601
602 if (ptepred) { /* predecessor exits */
603
604 ptesucc = patches[ptepred].nextstm;
605
606 patches[ptecpos].nextstm = ptesucc;
607 patches[ptecpos].prevstm = ptepred;
608
609 patches[ptepred].nextstm = ptecpos;
610
611 if (ptesucc)
612 patches[ptesucc].prevstm = ptecpos;
613
614 } else { /* no predecessor */
615
616 patches[ptecpos].prevstm = 0;
617
618 if (c EQ -1) {
619
620 ptesucc = stmptr[stim];
621
622 patches[ptecpos].nextstm = ptesucc;
623
624 patches[ptesucc].prevstm = ptecpos;
625
626 stmptr[stim] = ptecpos;
627
628 } else {
629
630 patches[ptecpos].nextstm = 0;
631 }
632 }
633/*
634
635*/
636 /* update DEF table */
637
638 if (0 EQ (c = finddpe())) {
639
640#if DEBUGEP
641 if (debugsw AND debugep)
642 printf("entrpte(): defent already exists\n");
643#endif
644 return; /* defent already exists */
645 }
646
647 if (0 EQ (dpecpos = dt_alc())) {
648
649#if DEBUGEP
650 if (debugsw AND debugep)
651 printf("entrpte(): defent table FULL\n");
652#endif
653 return; /* no defents left */
654 }
655
656 defents[dpecpos].nextdef = 0;
657 defents[dpecpos].stm = ptestm;
658 defents[dpecpos].adspec = ptespec;
659 defents[dpecpos].adsuba = ptesuba;
660 defents[dpecpos].addat1 = ptedat1;
661
662 np = TRG_MASK & ptebuf.defnum;
663
664 if (c EQ 1) {
665
666 dpepred = 0;
667 defptr[np] = dpecpos;
668 }
669
670 if (dpepred) {
671
672 dpesucc = defents[dpepred].nextdef;
673 defents[dpecpos].nextdef = dpesucc;
674 defents[dpepred].nextdef = dpecpos;
675
676 } else {
677
678 if (c EQ -1) {
679
680 dpesucc = defptr[np];
681 defents[dpecpos].nextdef = dpesucc;
682 defptr[np] = dpecpos;
683
684 } else {
685
686 defents[dpecpos].nextdef = 0;
687 }
688 }
689
690#if DEBUGEP
691 if (debugsw AND debugep) {
692
693 if (snapep)
694 SnapPTV("entrpte");
695
696 printf("entrpte(): ENTERED\n");
697 }
698#endif
699 return;
700 }
701
702#if DEBUGEP
703 if (debugsw AND debugep) {
704
705 if (snapep)
706 SnapPTV("entrpte");
707
708 printf("entrpte(): INVALID\n");
709 }
710#endif
711}
712
713/*
714
715*/
716
717/*
718 =============================================================================
719 find1st() -- find the first patch in the patch table
720 =============================================================================
721*/
722
723short
724find1st()
725{
726 register short cp, pp;
727
728 for (cp = 0; cp < NDEFSTMS; cp++)
729 if (0 NE (pp = ADR_MASK & stmptr[cp]))
730 return(pp);
731
732 return(0);
733}
734
735/*
736 =============================================================================
737 findnxt() -- find the next patch in the patch table
738 =============================================================================
739*/
740
741short
742findnxt(cp)
743short cp;
744{
745 register short np, stim;
746
747 if (0 NE (np = patches[cp].nextstm))
748 return(np);
749
750 stim = TRG_MASK & patches[cp].stmnum;
751
752 while (++stim < NDEFSTMS)
753 if (0 NE (np = ADR_MASK & stmptr[stim]))
754 return(np);
755
756 return(0);
757}
758
759/*
760
761*/
762
763/*
764 =============================================================================
765 findprv() -- find the previous patch in the patch table
766 =============================================================================
767*/
768
769short
770findprv(cp)
771short cp;
772{
773 register short np, pp, stim;
774
775 if (0 NE (np = patches[cp].prevstm)) /* return prevstm if set */
776 return(np);
777
778 stim = TRG_MASK & patches[cp].stmnum; /* extract the stimulus */
779
780 while (--stim GE 0) { /* back up one stimulus if we can */
781
782 if (0 NE (np = ADR_MASK & stmptr[stim])) { /* any there ? */
783
784 /* find the end of the chain for the stimulus */
785
786 while (pp = patches[np].nextstm)
787 np = pp;
788
789 return(np);
790 }
791 }
792
793 return(0); /* backed up to the start of the table */
794}
795
796/*
797
798*/
799
800/*
801 =============================================================================
802 dpte() -- display a patch at a given line on the screen
803 =============================================================================
804*/
805
806dpte(pe, row, atr)
807register short pe, row, atr;
808{
809 register short i;
810
811 memset(ptdsbuf, ' ', 50);
812
813 if (pe) {
814
815 dspdfst(&ptdsbuf[ 2], patches[pe].defnum);
816 dspdfst(&ptdsbuf[15], patches[pe].stmnum);
817 dspdest(&ptdsbuf[28], &patches[pe]);
818
819 for (i = 0; i < 50; i++)
820 if (ptdsbuf[i] EQ '\0')
821 ptdsbuf[i] = ' ';
822
823 ptdsbuf[48] = '\0';
824 }
825
826 UpdVid(row, 0, "\260 ", PTBATR);
827 UpdVid(row, 1, &ptdsbuf[1], atr);
828}
829
830/*
831
832*/
833
834/*
835 =============================================================================
836 dptw() -- display window around current patch at ptecpos
837 =============================================================================
838*/
839
840dptw()
841{
842 register short cp, r, row, pp;
843
844#if DEBUGDP
845 if (debugsw AND debugdp)
846 printf("dptw(): ENTRY ptecpos = %d\n", ptecpos);
847#endif
848
849 if (ptecpos) {
850
851 /* search back from ptecpos for predecessors */
852
853 row = 7;
854 pp = ptecpos;
855
856 while (0 NE (cp = findprv(pp))) {
857
858 pp = cp;
859
860 if (--row EQ 0)
861 break;
862 }
863
864#if DEBUGDP
865 if (debugsw AND debugdp)
866 printf("dptw(): backed up to row = %d pp = %d\n", row, pp);
867#endif
868
869 if (row) { /* blank any unused lines (rows 0..6) */
870
871 for (r = 0; r < row; r++)
872 dpte(0, r, PTPATR);
873 }
874
875 while (row < 7) { /* display predecessors (rows 0..6) */
876
877 dpte(pp, row++, PTPATR);
878 pp = findnxt(pp);
879 }
880/*
881
882*/
883 /* display ptecpos at the center (row 7) */
884
885#if DEBUGDP
886 if (debugsw AND debugdp)
887 printf("dptw(): row = %d pp = %d ptecpos = %d\n",
888 row, pp, ptecpos);
889#endif
890
891 dpte(pp, row++, PTEATR);
892
893 /* display forward from ptecpos (rows 8..15) */
894
895 while (0 NE (pp = findnxt(pp))) {
896
897 dpte(pp, row++, PTPATR);
898
899 if (row > 15)
900 break;
901 }
902
903 /* blank any unused display lines (rows 8..15) */
904 while (row < 16)
905 dpte(0, row++, PTPATR);
906/*
907
908*/
909 } else {
910
911 if (0 NE (ptecpos = find1st())) {
912
913#if DEBUGDP
914 if (debugsw AND debugdp)
915 printf("dptw(): found 1st at %d\n", ptecpos);
916#endif
917
918 /* clear lines above the center (rows 0..6) */
919
920 for (row = 0; row < 7; ++row)
921 dpte(0, row, PTPATR);
922
923 /* display ptecpos at the center (row 7) */
924
925 dpte(pp = ptecpos, row++, PTEATR);
926
927 /* display forward from ptecpos (rows 8..15) */
928
929 while (0 NE (pp = findnxt(pp))) {
930
931 dpte(pp, row++, PTPATR);
932
933 if (row > 15)
934 break;
935 }
936
937 /* blank any unused display lines (rows 8..15) */
938
939 while (row < 16)
940 dpte(0, row++, PTPATR);
941/*
942
943*/
944 } else {
945
946#if DEBUGDP
947 if (debugsw AND debugdp)
948 printf("dptw(): no patches to display\n");
949#endif
950
951 /* clear the patch display */
952
953 for (row = 0; row < 16; ++row)
954 dpte(0, row, (row EQ 7) ? PTEATR : PTPATR);
955 }
956 }
957
958 if (ptecpos) {
959
960 memcpyw(&ptebuf.defnum, &patches[ptecpos].defnum, 6);
961 pteset = TRUE;
962 pte2buf();
963
964#if DEBUGDP
965 if (debugsw AND debugdp)
966 printf("dptw(): EXIT -- LOADED buffer, ptecpos = %d\n",
967 ptecpos);
968#endif
969
970 } else {
971
972 pteset = FALSE;
973 voidpb();
974
975#if DEBUGDP
976 if (debugsw AND debugdp)
977 printf("dptw(): EXIT -- VOIDED buffer, ptecpos = %d\n",
978 ptecpos);
979#endif
980
981
982 }
983}
984
985/*
986
987*/
988
989/*
990 =============================================================================
991 srdspte() -- search for and display patch table entry
992 =============================================================================
993*/
994
995srdspte()
996{
997 short oldcpos, oldpred, oldsucc;
998#if DEBUGSR
999 register short i;
1000 char dbuf[50];
1001#endif
1002
1003 ptegood = ptedfok AND ptestok AND ptedsok AND ptedtok;
1004
1005#if DEBUGSR
1006 if (debugsw AND debugsr) {
1007
1008 printf("srdspte(): ENTRY pte good=%d dfok=%d stok=%d dsok=%d dtok=%d\n",
1009 ptegood, ptedfok, ptestok, ptedsok, ptedtok);
1010
1011 memcpy(dbuf, ptdebuf, 48);
1012
1013 for (i = 0; i < 48; i++)
1014 if (dbuf[i] EQ '\0')
1015 dbuf[i] = ' ';
1016 else if (dbuf[i] & 0x0080)
1017 dbuf[i] = '~';
1018
1019 dbuf[48] = '\0';
1020
1021 printf(" ptdebuf = \"%s\"\n", dbuf);
1022 }
1023#endif
1024
1025 if (ptegood) {
1026
1027 oldcpos = ptecpos; /* save patch pointers */
1028 oldpred = ptepred;
1029 oldsucc = ptesucc;
1030
1031 buf2pte();
1032
1033 if (0 EQ findpte()) {
1034
1035#if DEBUGSR
1036 if (debugsw AND debugsr)
1037 printf("srdspte(): FOUND patch at ptecpos = %d\n", ptecpos);
1038#endif
1039
1040 memcpyw(&ptebuf.defnum, &patches[ptecpos].defnum, 6);
1041 pteset = TRUE;
1042 pte2buf();
1043 dptw();
1044
1045 } else {
1046
1047 ptecpos = oldcpos; /* restore patch pointers */
1048 ptepred = oldpred;
1049 ptesucc = oldsucc;
1050
1051#if DEBUGSR
1052 if (debugsw AND debugsr) {
1053
1054 printf("srdspte(): patch not found\n");
1055
1056 if (snapsr)
1057 SnapPTV("srdspte");
1058
1059 }
1060#endif
1061
1062 }
1063 }
1064
1065#if DEBUGSR
1066 if (debugsw AND debugsr)
1067 printf("srdspte(): EXIT -- ptecpos = %d\n", ptecpos);
1068#endif
1069
1070}
1071
1072/*
1073
1074*/
1075
1076/*
1077 =============================================================================
1078 stmproc() -- process a trigger as a definer and a stimulus
1079 =============================================================================
1080*/
1081
1082stmproc(trg)
1083register unsigned short trg;
1084{
1085 register struct defent *nextdef;
1086 register struct patch *nextpch;
1087 register unsigned short adspec, adsuba, np, stim;
1088 unsigned short addat1, adrtag;
1089
1090 /* ***** DEFINER PROCESSING PHASE ***** */
1091
1092 np = ADR_MASK & defptr[TRG_MASK & trg];
1093 nextdef = np ? &defents[np] : (struct defent *)NULL; /* point at DEF chain */
1094
1095/*
1096
1097*/
1098 while ((struct defent *)NULL NE nextdef) { /* process DEF chain */
1099
1100 /* setup search criteria */
1101
1102 adspec = nextdef->adspec;
1103 adsuba = nextdef->adsuba;
1104 addat1 = nextdef->addat1;
1105 stim = nextdef->stm;
1106 adrtag = dmatch[adspec];
1107
1108 /* point at the start of the STM chain */
1109
1110 np = ADR_MASK & stmptr[TRG_MASK & stim];
1111 nextpch = np ? &patches[np] : (struct patch *)NULL;
1112
1113 while ((struct patch *)NULL NE nextpch) { /* process STM chain */
1114
1115 /* if this patch matches our search criteria ... */
1116
1117 if ((stim EQ nextpch->stmnum) AND
1118 (adspec EQ (nextpch->paspec & PE_SPEC)) AND
1119 (adsuba EQ nextpch->pasuba)) {
1120
1121 if ((NOT adrtag) OR
1122 (adrtag AND addat1 EQ nextpch->padat1)) {
1123
1124 if (nextpch->defnum EQ trg)
1125 nextpch->paspec |= PE_TBIT; /* define */
1126 else
1127 nextpch->paspec &= ~PE_TBIT; /* undefine */
1128 }
1129 }
1130
1131 /* point at the next patch in the STM chain */
1132
1133 np = nextpch->nextstm;
1134 nextpch = np ? &patches[np] : (struct patch *)NULL;
1135 }
1136
1137 /* point at the next DEF entry */
1138
1139 np = nextdef->nextdef;
1140 nextdef = np ? &defents[np] : (struct defent *)NULL;
1141 }
1142/*
1143
1144*/
1145
1146 /* ***** STIMULUS PROCESSING PHASE ***** */
1147
1148 /* setup initial STM chain pointer */
1149
1150 np = ADR_MASK & stmptr[TRG_MASK & trg];
1151 nextpch = np ? &patches[np] : (struct patch *)NULL;
1152
1153 /* process the STM chain */
1154
1155 while ((struct patch *)NULL NE nextpch) { /* for each patch .. */
1156
1157 if ((nextpch->paspec & PE_TBIT) AND /* if it's defined ... */
1158 (nextpch->stmnum EQ trg)) /* ... and stm matches */
1159 dopatch(nextpch); /* ... do the patch */
1160
1161 /* point at the next patch */
1162
1163 np = nextpch->nextstm;
1164 nextpch = np ? &patches[np] : (struct patch *)NULL;
1165 }
1166}
Note: See TracBrowser for help on using the repository browser.