troglobit / adventure

Classic Colossal Cave Adventure
The Unlicense
71 stars 12 forks source link

Is the hint implementation missing? #3

Open patricksurry opened 7 months ago

patricksurry commented 7 months ago

I've been having fun porting this to a 6502 forth and noticed that altho advent.h defines the HINTx conditions these don't seem to be referenced in the code. The hint messages are present in advent4.h (e.g. #63) but I can't find any equivalent of the checkhints routine from the open-adventure code.

advent.h:#define HINTC       16
advent.h:#define HINTB       32
advent.h:#define HINTS       64
advent.h:#define HINTM       128
advent.h:#define HINT        240

also doc/advent.txt mentions the feature, but maybe disappeared again later?

J) Hint feature restored with original messages
           (exact original algorithm unknown)

I'd be happy to try and restore if you have any traces of the original code.

patricksurry commented 7 months ago

the open-adventure source tree starts from some horrible f2c version where main.c includes references like below, so maybe I can reconstruct? score.c also has some deductions if you take hints.

/*  CHECK IF THIS LOC IS ELIGIBLE FOR ANY HINTS.  IF BEEN HERE LONG ENOUGH,
 *  BRANCH TO HELP SECTION (ON LATER PAGE).  HINTS ALL COME BACK HERE EVENTUALLY
 *  TO FINISH THE LOOP.  IGNORE "HINTS" < 4 (SPECIAL STUFF, SEE DATABASE NOTES).
        */

L2600:  if(COND[LOC] < CONDS) goto L2603;
    /* 2602 */ for (HINT=1; HINT<=HNTMAX; HINT++) {
    if(HINTED[HINT]) goto L2602;
    if(!CNDBIT(LOC,HINT+10))HINTLC[HINT]= -1;
    HINTLC[HINT]=HINTLC[HINT]+1;
    if(HINTLC[HINT] >= HINTS[HINT][1]) goto L40000;
L2602:  /*etc*/ ;
    } /* end loop */

...

/*  HINTS */

/*  COME HERE IF HE'S BEEN LONG ENOUGH AT REQUIRED LOC(S) FOR SOME UNUSED HINT.
 *  HINT NUMBER IS IN VARIABLE "HINT".  BRANCH TO QUICK TEST FOR ADDITIONAL
 *  CONDITIONS, THEN COME BACK TO DO NEAT STUFF.  GOTO 40010 IF CONDITIONS ARE
 *  MET AND WE WANT TO OFFER THE HINT.  GOTO 40020 TO CLEAR HINTLC BACK TO ZERO,
 *  40030 TO TAKE NO ACTION YET. */

L40000:    switch (HINT-1) { case 0: goto L40100; case 1: goto L40200; case 2: goto
        L40300; case 3: goto L40400; case 4: goto L40500; case 5: goto
        L40600; case 6: goto L40700; case 7: goto L40800; case 8: goto
        L40900; case 9: goto L41000; }
/*      CAVE  BIRD  SNAKE MAZE  DARK  WITT  URN   WOODS OGRE
 *      JADE */
    BUG(27);

L40010: HINTLC[HINT]=0;
    if(!YES(HINTS[HINT][3],0,54)) goto L2602;
    SETPRM(1,HINTS[HINT][2],HINTS[HINT][2]);
    RSPEAK(261);
    HINTED[HINT]=YES(175,HINTS[HINT][4],54);
    if(HINTED[HINT] && LIMIT > 30)LIMIT=LIMIT+30*HINTS[HINT][2];
L40020: HINTLC[HINT]=0;
L40030:  goto L2602;

/*  NOW FOR THE QUICK TESTS.  SEE DATABASE DESCRIPTION FOR ONE-LINE NOTES. */

L40100: if(PROP[GRATE] == 0 && !HERE(KEYS)) goto L40010;
     goto L40020;

L40200: if(PLACE[BIRD] == LOC && TOTING(ROD) && OLDOBJ == BIRD) goto L40010;
     goto L40030;

L40300: if(HERE(SNAKE) && !HERE(BIRD)) goto L40010;
     goto L40020;

L40400: if(ATLOC[LOC] == 0 && ATLOC[OLDLOC] == 0 && ATLOC[OLDLC2] == 0 && HOLDNG >
        1) goto L40010;
     goto L40020;

L40500: if(PROP[EMRALD] != -1 && PROP[PYRAM] == -1) goto L40010;
     goto L40020;

L40600:  goto L40010;

L40700: if(DFLAG == 0) goto L40010;
     goto L40020;

L40800: if(ATLOC[LOC] == 0 && ATLOC[OLDLOC] == 0 && ATLOC[OLDLC2] == 0) goto
        L40010;
     goto L40030;

L40900: I=ATDWRF(LOC);
    if(I < 0) goto L40020;
    if(HERE(OGRE) && I == 0) goto L40010;
     goto L40030;

L41000: if(TALLY == 1 && PROP[JADE] < 0) goto L40010;
     goto L40020;