source: buchla-68k/ram/stmproc.c@ 0580615

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

Point of no return.

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