diff --git a/src/games/wumpus.100 b/src/games/wumpus.100 new file mode 100644 index 00000000..f4d3ca50 --- /dev/null +++ b/src/games/wumpus.100 @@ -0,0 +1,527 @@ +;WUMPUS.MID;2 04-SEP-77 08:55:35 TECO'd by MRC +.SYMTAB 3500. +TITLE WUMPUS + +.DECSAV + +T=11 +T1=12 +ROOM=13 +ME=14 +CNT=15 +P=17 + +WORLD: BLOCK 21. ;Holds the world +NTABLE: BLOCK 21. ;Random table of numbers + +X0: BLOCK 1 ;Random # gen seed +RCOUNT: BLOCK 1 ;Random # gen counter +RANDP: BLOCK 1 ;Random # gen pointer +ARROWS: BLOCK 1 ;Number of arrows allowed + +PDL: BLOCK 200 ;Push down list + +DEFINE SENSE PROOM,HAZARD,ORWORD + LDB ROOM,PROOM + LDB T,HAZARD + IORM T,ORWORD +TERMIN + +DEFINE SENSE3 HAZARD,ORWORD + PUSH P,ROOM + SENSE PROOM1,HAZARD,ORWORD + MOVE ROOM,(P) + SENSE PROOM2,HAZARD,ORWORD + MOVE ROOM,(P) + SENSE PROOM3,HAZARD,ORWORD + POP P, ROOM +TERMIN + ;Do NOT change the order of these byte pointers: + +PROOM1: 360600,,WORLD(ROOM) ;Byte pointer to first tunnel +PROOM2: 300600,,WORLD(ROOM) ;Second tunnel +PROOM3: 220600,,WORLD(ROOM) ;Third tunnel +PWUMP: 210100,,WORLD(ROOM) ;Byte pointer to wumpus bit +PBAT: 200100,,WORLD(ROOM) ;Bat bit +PPIT: 170100,,WORLD(ROOM) ;Pit bit + +CRLF: ASCIZ/ +/ +EXPL: ASCIZ/ + You are a famous hunter descending down into the caves of darkness, +lair of the famous man-eating wumpus. You are equiped with five +bent arrows, and all your senses. There are twenty caves connected +by tunnels, and there are two other kinds of hazards (three each): + a) Super-bats which if you stumble into their room will pick + you up and drop you in some random room in the network. + b) Pits, which are bottomless, and fatal to fall into. +Both are immovable. + + If you end up in the same room as the wumpus, you lose. +Normally the wumpus does not move (having gorged himself upon a +previous hunter). Two things wake him up: + 1) Walking into his room, + 2) Shooting an arrow anywhere in the network. + + If he wakes there is a 50-50 chance he will be offended by +the intrusion and leave in disgust. If he is really riled he +will eat you. He is too big to be picked up by bats, and has +sucker feet, so he doesn't fall into the pits. + + You can smell the wumpus from one or two rooms away. You +can hear bats one room away, and feel drafts (from bottomless +pits) from one room away (and taste the fear...). + + To shoot type S (with no carriage return) instead of a +move, and then specify a legal path of five caves for the +arrow to follow. If you guess and lose the arrow takes a +random path. Paths can be truncated by typing carriage return +instead of a room number. + + Good luck hunting!! + +/ + BEG: RESET ;The beginning + MOVEI P, PDL + HRROI 1,[ASCIZ/Directions? (Y or N) /] ;Does he want the expl? + PSOUT + PBIN + CAIE 1,"y + CAIN 1,"Y ;Did he say yes? + JRST [HRROI 1,EXPL + PSOUT + JRST .+1] + HRROI 1,CRLF + PSOUT + PUSHJ P,NAMEF ;Fiddle with name + GTAD + HRRZM 1,X0 ;For random # gen + HRREI T,-5 + MOVEM T,ARROWS ;Set up five bent arrows + SETZM RCOUNT + SETZM WORLD ;Restart the world + MOVE T,[XWD WORLD,WORLD+1] + BLT T,WORLD+20. + PUSHJ P,SETNTB ;Set up ntable + PUSHJ P,RANDOM + PUSHJ P,RANDOM + IMULI T,3 + PUSH P,T + PUSHJ P,SHUFFL ;Shuffle ntable + SOSLE (P) + JRST .-2 + POP P,T + MOVE T,NTABLE+20. ;Make ntable a ring + MOVEM T,NTABLE + PUSHJ P,FIRST2 ;First two tunnels per room + PUSHJ P,LAST1 ;Last one + PUSHJ P,SHUFFL ;Shuffle ntable + PUSHJ P,SHUFFL + PUSHJ P,IHZRDS ;Add hazards and me + JRST CIRCLE + NAMEF: HRROI 1,[ASCIZ/Here's the famous Wumpus hunter Major /] + PSOUT + GJINF + MOVE 2,1 + MOVEI 1,101 + DIRST + JRST 4,.-1 + HRROI 1,[ASCIZ/ descending +into the "Caves of Darkness", lair of the deadly man-eating Wumpus. +/] + PSOUT + MOVEI 1,1000. + DISMS + HRROI 1,[ASCIZ/ Down... +/] + PSOUT + MOVEI 1,1500. + DISMS + HRROI 1,[ASCIZ/ Down... +/] + PSOUT + MOVEI 1,2000. + DISMS + HRROI 1,[ASCIZ/ Down... +/] + PSOUT + MOVEI 1,2500. + DISMS + POPJ P, + SETNTB: SETZ T, ;Set up NTABLE with 1-20 +SETNT1: ADDI T,1 + MOVEM T,NTABLE(T) + CAIGE T,20. + JRST SETNT1 + POPJ P, + +SHUFFL: MOVEI ME,1 ;Shuffle NTABLE once +SHUFF1: PUSHJ P,RANDOM ;Get random number + CAME T,ME ;If same, only two swaps + EXCH P,NTABLE(T) ;Swap NTABLE (T) with NTABLE (ME) + EXCH P,NTABLE(ME) + EXCH P,NTABLE(T) + ADDI ME,1 + CAIG ME,20. + JRST SHUFF1 + POPJ P, + +FIRST2: MOVEI T1,1 ;Put first two tunnels in each room +FIRSTA: MOVE ROOM,NTABLE(T1) ;Get ring entry + MOVE T,NTABLE-1(T1) ;Get previous entry + DPB T,PROOM1 ;Put in one direction + EXCH T,ROOM + DPB T,PROOM2 ;Put in other + ADDI T1,1 + CAIG T1,20. + JRST FIRSTA + POPJ P, + LAST1: HRREI T,-500. ;500 trys or else!! + PUSH P,T +LASTA: PUSHJ P,SHUFFL ;Shuffle NTABLE + MOVEI ROOM,1 + SETZ T, +LASTA1: DPB T,PROOM3 ;Zero third tunnels + ADDI ROOM,1 + CAIG ROOM,20. + JRST LASTA1 + MOVEI T1,1 ;Index to NTABLE +LASTB: MOVE ROOM,NTABLE(T1) + LDB T,PROOM3 + JUMPN T,LASTC1 ;If NTABLE(T1) has 3rd rm, get next t1 + MOVEI ROOM,1 ;Index to world +LASTC: LDB T,PROOM3 + JUMPN T,LASTD ;If third room full, next! + CAMN ROOM,NTABLE(T1) ;Is room same as NTABLE entry? + JRST LASTD ;Yep, next room + LDB T,PROOM1 + CAMN T,NTABLE(T1) ;NTABLE(T1) = tunnel #1? + JRST LASTD ;Yep, next room + LDB T,PROOM2 + CAMN T,NTABLE(T1) ;NTABLE(T1) = tunnel #2? + JRST LASTD ;Yep, next room + MOVE T,NTABLE(T1) ;Get room number + DPB T,PROOM3 ;Put it in world + EXCH T,ROOM + DPB T,PROOM3 ;Put in other direction +LASTC1: ADDI T1,1 + CAIG T1,20. ;End of NTABLE? + JRST LASTB ;Nope, go back + POP P,T ;Get rid of counter + POPJ P, + +LASTD: ADDI ROOM,1 ;Look at next room + CAIG ROOM,20. ;Looked at all? + JRST LASTC ;Nope, go back + AOSGE (P) ;Yep, count shuffles + JRST LASTA ;Shuffle and try again + HRROI 1,[ASCIZ/Can't finish tunnels. Foo!/] + ESOUT + HALTF + JRST .-1 + IHZRDS: PUSHJ P,SHUFFL ;Set up hazards and me + PUSHJ P,SHUFFL + SETO T, ;Bit for marking world + MOVE ROOM,NTABLE+1 ;Wumpus goes in first room + DPB T,PWUMP + HRREI T1,-2 ;Three bats and pits +IHZRDL: MOVE ROOM,NTABLE+4(T1) + DPB T,PPIT + MOVE ROOM,NTABLE+7(T1) + DPB T,PBAT + AOJLE T1,IHZRDL + MOVE ME,NTABLE+10 ;Me + SETZ T, +MWUMP: PUSH P,ROOM ;Move the Wumpus (50% chance) + PUSH P,T ;Transparent to AC'S + PUSH P,T1 + MOVEI ROOM,1 +MWUMP1: LDB T,PWUMP ;Find the Wumpus first + JUMPN T,MWUMP2 ;Got him + ADDI ROOM,1 + CAIG ROOM,20. + JRST MWUMP1 + HRROI 1,[ASCIZ/Error @ MWUMP1/] + ESOUT + HALTF + JRST .-1 + +MWUMP2: PUSHJ P,RANDOM + CAILE T,10. ;50% chance of moving! + JRST MWUMPX ;Not this time + IDIVI T,3 + SETZ T, + DPB T,PWUMP ;Get rid of wumpus + LDB ROOM,PROOM1 (T1) ;Get random room + SETO T, + DPB T,PWUMP ;Put Wumpus there +MWUMPX: POP P,T1 + POP P,T + POP P,ROOM + POPJ P, + CIRCLE: HRROI 1,[ASCIZ/You are in room /] ;Master loop + PSOUT + MOVE T,ME + PUSHJ P,DECPNT + HRROI 1,CRLF + PSOUT + MOVE ROOM,ME + LDB T,PWUMP ;Get Wumpus bit + JUMPE T,CIRCL1 ;No Wumpus, go on + PUSHJ P,MWUMP ;He's there, to move or not to move? +CIRCLF: MOVE ROOM,ME + LDB T,PWUMP + JUMPE T,CIRCL1 ;He moved, you're safe... + HRROI 1,[ASCIZ/You were eaten by the Wumpus. You lose./] + PSOUT + HALTF + JRST .-1 + +CIRCL1: LDB T,PBAT + JUMPE T,CIRCL2 ;No bats, go on + HRROI 1,[ASCIZ/Bats in your room! +/] + PSOUT + PUSHJ P,RANDOM + MOVE ME,T ;Put me somewhere random. + JRST CIRCLE + +CIRCL2: LDB T,PPIT + JUMPE T,CIRCL3 ;No pits, go on + HRROI 1,[ASCIZ/You fell into a pit. You lose!/] + PSOUT + HALTF + JRST .-1 + +CIRCL3: SETZ T1, ;Sense all around. T1 is OR-WORD + PUSHJ P,WSENSE + JRST CIRCL4 +WSENSE: SENSE3 PWUMP,T1 ;Sense the world!! + POPJ P, + CIRCL4: LDB ROOM,PROOM1 + PUSHJ P,WSENSE + MOVE ROOM,ME + LDB ROOM,PROOM2 + PUSHJ P,WSENSE + MOVE ROOM,ME + LDB ROOM,PROOM3 + PUSHJ P,WSENSE + JUMPE T1,CIRCL5 ;No smell of Wumpus, go on + HRROI 1,[ASCIZ/I smell a Wumpus. +/] + PSOUT +CIRCL5: SETZ T1, ;Clear IOR bit + MOVE ROOM,ME + SENSE3 PBAT,T1 ;Sense bats + JUMPE T1,CIRCL6 ;No bats, go on + HRROI 1,[ASCIZ/I hear squeeking. +/] + PSOUT +CIRCL6: SETZ T1, ;Clear IOR bit for pits + MOVE ROOM,ME + SENSE3 PPIT,T1 + JUMPE T1,MOVE0 ;No bats, let him move. + HRROI 1,[ASCIZ/I feel a draft. +/] + PSOUT + +;Move Routine: Does work related to user move. + +MOVE0: HRROI 1,[ASCIZ/Tunnels to /] + PSOUT + MOVE ROOM,ME + LDB T,PROOM1 + PUSHJ P,DECPNT + MOVEI 1,<" > + PBOUT + LDB T,PROOM2 + PUSHJ P,DECPNT + MOVEI 1,<" > + PBOUT + LDB T,PROOM3 + PUSHJ P,DECPNT + HRROI 1,CRLF + PSOUT +MOVE1: HRROI 1,[ASCIZ/Move? /] ;Demand move + PSOUT + PUSHJ P,DECIN + JRST MOVE2 ;Non-number, go check. + JUMPLE T,WHAT + CAILE T,20. ;Between 1-20? + JRST WHAT ;Nope. + MOVE T1,ME + PUSHJ P,LEGAL ;Legal move? (from T1 to T) + JRST NOTPOS ;Nope, not possible + MOVE ME,T ;Yep, make it + JRST CIRCLE ;Go back + MOVE2: CAIE T,"s + CAIN T,"S ;Only non-number is S + JRST SHOOT ;To shoot arrow. +WHAT: CAIN T,1000 + JRST MOVE1 + HRROI 1,[ASCIZ/What??/] ;Non-recognizable char + SKIPA +NOTPOS: HRROI 1,[ASCIZ/Not Possible!/] ;... + PSOUT + HRROI 1,CRLF + PSOUT + JRST CIRCLE + +;Routine to determine if a tunnel exists tween T and T1 +;SKIP RETURN = YES. Transparent to AC'S + +LEGAL: PUSH P,ROOM + MOVE ROOM,T + LDB T,PROOM1 + CAMN T,T1 + JRST SLEGAL + LDB T,PROOM2 + CAMN T,T1 + JRST SLEGAL + LDB T,PROOM3 + CAMN T,T1 +SLEGAL: AOS -1(P) ;Yep, 's legal + MOVE T,ROOM ;Restore AC'S + POP P,ROOM + POPJ P, + ;Shoot routine to handle shooting arrows. + +SHOOT: HRROI 1,[ASCIZ/hoot! +/] + PSOUT + AOSLE ARROWS ;Arrows left? + JRST LOSE1 ;Nope + HRROI 1,[ASCIZ/Finish with CR. +/] + PSOUT + MOVE ROOM,ME ;Arrow starts at me + SETZM NTABLE ;To check 180 deg bounces + HRREI CNT,-5 ;Five rooms +SHOOT1: HRROI 1,[ASCIZ/Room: /] ;Get room number + PSOUT + PUSHJ P,DECIN + JRST SHOOTX ;Unrecognizable input = EXIT + JUMPE T,SHOOTX + CAILE T,20. + JRST SHOOTX ;Out of bounds = EXIT + MOVE T1,ROOM + PUSHJ P,LEGAL ;Tunnel tween T and T1? + JRST BOUNCE ;Nope, he's fishing, get him + CAMN T,NTABLE ;Does he want to do a 180? + JRST BOUNCE ;Yep, get him + MOVEM ROOM,NTABLE ;Arrow just leaving (ROOM) + PUSHJ P,MEWUMP ;Kill me or Wumpus?? + AOJL CNT,SHOOT1 ;No, more arrows = go back +SHOOTX: PUSHJ P,MWUMP ;Finished, move Wumpus + JRST CIRCLF ;Go back, see if Wumpus kills, dont let + ;Him move again. +BOUNCE: HRROI 1,[ASCIZ/Bounce +/] ;He tried to fool us, random arrow path. + PSOUT + PUSHJ P,RANDOM + IDIVI T,3 + LDB T,PROOM1(T1) ;Get random tunnel + PUSHJ P,MEWUMP ;Kill anyone? + AOJL CNT,BOUNCE ;Continue bouncing + JRST CIRCLE +MEWUMP: CAMN ME,T ;Kill me or Wumpus? + JRST LOSE ;Yep, me + MOVE ROOM,T + LDB T,PWUMP ;Kill Wumpus? + JUMPN T,WIN ;Yep + POPJ P, + +LOSE1: HRROI 1,[ASCIZ/No more arrows. You lose by default./] + PSOUT + HALTF + JRST .-1 + +LOSE: HRROI 1,[ASCIZ/You shot yourself./] + PSOUT + HALTF + JRST .-1 + +WIN: HRROI 1,[ASCIZ/You slew the Wumpus. Congratulations!!!/] + PSOUT + HALTF + JRST .-1 + ;DECIN inputs a decimal number. It must be terminated +;with a cr. First char if non-number gets returned with POPJ. +;Normal return is skip. Answer in T. + +DECIN: MOVEI 1,100 + MOVEI 3,10. + NIN + JRST [ MOVEI 1,100 + BKJFN + JFCL + PBIN + CAIN 1,15 + PBIN + CAIE 1,12 + CAIN 1,37 + JRST [MOVEI T,1000 + POPJ P,] + MOVE T,1 + POPJ P,] ; No number + MOVE T,2 + MOVEI 1,100 + BKJFN + JFCL + PBIN + CAIN 1,15 + PBIN + CAIE 1,12 + CAIN 1,37 + CAIA + JRST DWHAT +CPOPJ1: AOS (P) +CPOPJ: POPJ P, + +DWHAT: HRROI 1,[ASCIZ/What?? +/] + PSOUT + JRST DECIN + +;Decimal print routine. Takes argument in T + +DECPNT: MOVEI 1,101 + MOVE 2,T + MOVEI 3,10. + NOUT + JRST 4,.-1 + POPJ P, + ;Random number generator: uses formula: +; X[N+1] = ( A*X[N] + C )TAKEN MOD(M) + +RANDOM: SKIPE RCOUNT ;Random # GEN (RANGE = 1-20) + JRST RAND1 + AOS RCOUNT + MOVE T,X0 + IMUL T,MA + ADD T,MC + IDIV T,MM + MOVEM T,X0 + MOVE T,[360600,,X0] + MOVEM T,RANDP +RANDX: LDB T,RANDP + IDIVI T,20. + MOVE T,T1 + ADDI T,1 + POPJ P, + +RAND1: AOS RCOUNT + MOVEI T,6 + CAMN T,RCOUNT + SETZM RCOUNT + IBP RANDP + JRST RANDX + +MA: 32768.-19. ;Random # gen constants +MC: 262144.-11. +MM: -23. +X0SAVD: 5 + +CONSTA + +END BEG ;Game over!!!!!