void tests (void) { unsigned int res; unsigned char n; clrscr(); revers(1); //0123456789012345678901234567890123456789 cprintf("testing... press any key to abort. "); revers(0); n = 0; while (testinfo[n].generator) { testinfo[n].result = 0; if (((cpu_type == testinfo[n].cpu_type) || (testinfo[n].cpu_type == CPU_6502)) && (ram_banks >= testinfo[n].ram_banks)) { printinfo(n, 0); } ++n; } while(1) { n = 0; while (testinfo[n].generator) { if (((cpu_type == testinfo[n].cpu_type) || (testinfo[n].cpu_type == CPU_6502)) && (ram_banks >= testinfo[n].ram_banks)) { gotoxy(39,n + 1); cputc('*'); teststart(); testinfo[n].generator(); testend(); res = (0xffff - 29) - dotest(); testinfo[n].result = res; printrating(); printinfo(n, res); } ++n; if (kbhit()) { break; } } delay_200ms(); if (kbhit()) { break; } } while (kbhit()) { cgetc(); } }
/* ECONTEXT: Determine whether the current element can be ended, or whether non-optional tokens remain at the current level or higher. Returns 1 if element can be ended, or 0 if tokens remain. On entry, STATUS==RCEND if there are no tokens left; if not, pos points to the next model token to be tested. TO DO: Support a "query" mode (what is required now?) by working with a copy of pos. */ int econtext(struct thdr mod[], /* Model of current open element. */ struct mpos pos[], /* Position in open element's model. */ UNCH *statuspt) /* Token status: RCHIT RCMISS RCEND RCREQ RCNREQ*/ { unsigned next; /* Position in AND group of next testable token.*/ Tstart = T; TRACEEND("ECONT", mod, pos, 0, 0, Tstart); if (P<=1) {nextetd = 0; return(TOKENHIT || BITON(TOCC, TOPT));} nextetd = TTYPE == TTETD ? TOKEN.tu.thetd : 0; while (STATUS!=RCMISS && STATUS!=RCEND) { STATUS = (UNCH)testend(mod, pos, 0, 0); TRACEEND("ECONTEND", mod, pos, 0, 0, Tstart); nextetd = P<=1 || TTYPE != TTETD ? 0 : TOKEN.tu.thetd; if (STATUS==RCEND) return(1); if (P<=1) return(TOKENHIT || BITON(TOCC, TOPT)); if (STATUS==RCMISS) { if (BITON(TOCC, TOPT)) nextetd = 0; return(0); } if (!tokenopt(mod, pos)) return(0); STATUS = RCNREQ; if (GTYPE!=TTAND) ++T; /* T!=GNUM or group would have ended. */ else T = (UNCH)(((next = (UNS)offbit(H, (int)T, GNUM))!=0) ? next : offbit(H, 0, GNUM)); M = G + grpsz(&GHDR, (int)T-1) + 1; TRACEEND("ECONTNEW", mod, pos, 0, 0, Tstart); } if (STATUS==RCMISS) { if (BITON(TOCC, TOPT)) nextetd = 0; return(0); } return(1); /* STATUS==RCEND */ }
/* NEWTOKEN: Find the next token to test. Set STATUS to indicate results: RCEND if element has ended (no more tokens to test); RCREQ if required new token was found; RCNREQ if non-required new token was found; RCHIT if a hit token was repeated (now non-required); and RCMISS if a new token can't be found because current token (which was not hit) was neither unconditionally required nor optional. */ VOID newtoken(struct thdr mod[], /* Model of current open element. */ struct mpos pos[], /* Position in open element's model. */ UNCH *statuspt) /* Token status: RCHIT RCMISS RCEND RCREQ RCNREQ*/ { unsigned nextand = 0; /* Position in AND group of next testable token.*/ int currhit = (STATUS==RCHIT); /* 1=current GI hit; 0=not. */ /* If the GI was a hit, turn on the hit bit and set the status to assume that the token to be tested against the next GI will be non-required. If the current token is repeatable, exit so it will stand as the next token to test. */ if (STATUS==RCHIT) { HITSET(H, T); STATUS = RCNREQ; if (BITON(TOCC, TREP)) return; } /* At this point, we must determine the next token to test: either against the next GI, if this one was a hit, or against the same GI if conditions permit a retry. To find the next token, we must first end the current group, if possible, and any we can that contain it. If the outermost group was a hit and is repeatable, or if the element has ended, we exit now. If it hasn't ended, or was optional and ended with a miss, we can retry the GI against the next token. */ if ((STATUS = (UNCH)testend(mod, pos, 1, 1))!=RCNREQ) return; /* At this point, the "current token" is either the original one, or the token for the highest level unhit group that it ended. We will retry a missed GI, by testing it against the next token, if the current token: 1. Is optional; 2. Was hit (i.e., because it is repeatable and was hit by a previous GI or because it is a hit group that just ended); 3. Is in an AND or OR group and is not the last testable token. It will be the next sequential one (unhit one, in an AND group); if there are none left, use the first unhit token in the group. In either case, set M to correspond to the new T. */ retest: TRACEEND("RETEST", mod, pos, (int)nextand, 1, Tstart); if (GTYPE==TTAND) { nextand = offbit(H, (int)T, GNUM); if (!nextand) nextand = offbit(H, 0, GNUM); } if ( BITON(TOCC, TOPT) || TOKENHIT || GTYPE==TTOR /* T!=GNUM or group would have ended. */ || nextand ) { if (GTYPE!=TTAND) ++T; /* T!=GNUM or group would have ended. */ else T = nextand; M = G + grpsz(&GHDR, (int)T-1) + 1; if (GTYPE==TTAND) { /* If AND group wrapped, it can end if all non-optionals were hit. */ if (T==Tstart && !currhit) { UNCH Psave = P; int rc = testend(mod, pos, 0, 1); if (Psave!=P) {if ((STATUS = (UNCH)rc)==RCNREQ) goto retest;} else STATUS = RCMISS; } /* We only test unhit tokens, so we must use an unhit token as Tstart (which is used to detect when the AND group has wrapped). */ else if (HITON(H,Tstart)) Tstart = T; } } else STATUS = RCMISS; TRACEEND("NEWTOKEN", mod, pos, (int)nextand, 1, Tstart); }