;Jim Piotrowski, Sarah Rovito, Neal Heinrich ;HTW 4/21 10:38 AM ;This is the submitted version 0000: .org 0h 0000: .equ marker, 40h; points to first square in mem start: 0000: 75 81 07 mov SP, #07h; needed to fix glitch in J51 sim - ini 0003: 75 89 20 mov TMOD, #20h ; set timer 1 for auto reload 0006: 75 88 41 mov TCON, #41h ; run counter 1 edge trig 0009: 75 8D FD mov TH1, #0FDh ; 9600 baud 000C: 75 98 50 mov SCON,#50h ; 8-bit data mode 1 000F: 90 06 47 mov dptr, #openingscreen 0012: 12 02 C3 lcall puts 0015: 12 02 B9 lcall outputcr 0018: 12 02 9B lcall getchar init: 001B: 78 40 mov R0, #marker 001D: 74 10 mov A, #16 001F: 7B 04 mov R3, #4 ;R3 is the number of arrows folder ; note R6 holds the random number asgnmk: ;fill board with zeroes 0021: 76 00 mov @r0, #0 0023: 08 inc r0 0024: 14 dec a 0025: 70 FA jnz asgnmk setplayer: ;set player's spot 0027: 12 04 A6 lcall rand8 002A: 54 0F anl a, #15 002C: 24 40 add a, #marker 002E: F8 mov R0, a 002F: 76 55 mov @r0, #'U' setwumpus: ;set wumpus's spot 0031: 12 04 A6 lcall rand8 0034: 54 0F anl a, #15 0036: 24 40 add a, #marker 0038: F8 mov R0, a 0039: E6 mov a, @r0 003A: B4 00 F4 cjne a, #0, setwumpus ;get new position if already 003D: 76 57 mov @r0, #'W' setpit: ; set the pit 003F: 12 04 A6 lcall rand8 0042: 54 0F anl a, #15 0044: 24 40 add a, #marker 0046: F8 mov R0, a 0047: E6 mov a, @r0 0048: B4 00 F4 cjne a, #0, setpit ;get new position if already ta 004B: 76 50 mov @r0, #'P' setbats: ; set the bats 004D: 12 04 A6 lcall rand8 0050: 54 0F anl a, #15 0052: 24 40 add a, #marker 0054: F8 mov R0, a 0055: E6 mov a, @r0 0056: B4 00 F4 cjne a, #0, setbats ;get new position if already t 0059: 76 42 mov @r0, #'B' 005B: 12 04 A6 lcall rand8 005E: 54 0F anl a, #15 0060: 24 40 add a, #marker 0062: F8 mov R0, a 0063: E6 mov a, @r0 0064: B4 00 E6 cjne a, #0, setbats ;get new position if already t 0067: 76 42 mov @r0, #'B' actprog: ;the actual game loop 0069: 12 00 8E lcall showboard ;show the board 006C: 12 01 D6 lcall status ;show text for surroundings 006F: 12 00 C0 lcall moveplayer ;function for moving player 0072: 12 03 53 lcall movehandler ;function for handling player mov 0075: B4 02 03 cjne a, #2, notbat 0078: 12 04 78 lcall batmove ;if player enters bat space notbat: 007B: 12 03 B6 lcall movewumpus ;move the wumpus 007E: 60 E9 jz actprog ;if 0 is in acc, program is in a non-te ;and needs to run game loop again 0080: 90 07 B7 mov dptr, #nothergame ;game has ended, show messag 0083: 12 02 B9 lcall outputcr 0086: 12 02 C3 lcall puts 0089: 12 02 9B lcall getchar 008C: 80 8D sjmp init showboard: ;show the board 008E: 79 10 mov r1, #16 0090: 78 40 mov r0, #marker brdloop: 0092: E9 mov a, r1 0093: 54 03 anl a, #3h; is a mult of 4? for cr's for drawing b 0095: 70 05 jnz putspot 0097: 74 0A mov a, #10 0099: 12 02 93 lcall outputa putspot: 009C: 74 7C mov a, #'|' 009E: 12 02 93 lcall outputa 00A1: E6 mov a, @r0 00A2: C3 clr c 00A3: 94 55 subb a, #'U' 00A5: B4 00 08 cjne a, #0, notU 00A8: 74 55 mov a, #'U' 00AA: 12 02 93 lcall outputa 00AD: 02 00 B5 ljmp afterUcheck notU: 00B0: 74 00 mov a, #0 00B2: 12 02 93 lcall outputa afterUcheck: 00B5: 08 inc r0 00B6: 19 dec r1 00B7: E9 mov a, r1 00B8: 70 D8 jnz brdloop 00BA: 74 0A mov a, #10 00BC: 12 02 93 lcall outputa 00BF: 22 ret moveplayer: ;move the player 00C0: 12 02 B9 lcall outputcr 00C3: 12 02 B9 lcall outputcr 00C6: 90 04 E5 mov dptr, #choosemsg 00C9: 12 02 C3 lcall puts 00CC: 12 02 B9 lcall outputcr getmove: ;get the move 00CF: 12 02 9B lcall charin 00D2: B4 61 07 cjne a, #'a', notleft 00D5: 12 02 D2 lcall moveleft 00D8: 78 FF mov r0, #0xFFh 00DA: 80 24 sjmp moved notleft: 00DC: B4 64 07 cjne a, #'d', notright 00DF: 12 02 E9 lcall moveright 00E2: 78 FF mov r0, #0xFFh ;mark that movement has been done 00E4: 80 1A sjmp moved notright: 00E6: B4 77 07 cjne a, #'w', notup 00E9: 12 03 02 lcall moveup 00EC: 78 FF mov r0, #0xFFh ;mark that movement has been done 00EE: 80 10 sjmp moved notup: 00F0: B4 73 07 cjne a, #'s', notdown 00F3: 12 03 31 lcall movedown 00F6: 78 FF mov r0, #0xFFh ;mark that movement has been done 00F8: 80 06 sjmp moved notdown: 00FA: B4 66 03 cjne a, #'f', notfire 00FD: 12 01 07 lcall firearrow ;function sets r0 to FF if action h notfire: moved: 0100: 12 02 B9 lcall outputcr 0103: B8 FF C9 cjne r0, #0xFFh, getmove 0106: 22 ret firearrow: ;if f is pushed to fire an arrow 0107: EB mov a, r3 0108: 70 11 jnz hasarrows ;check for arrows in R3 010A: 12 02 B9 lcall outputcr 010D: 90 07 78 mov dptr, #noarrows ;no arrows branch 0110: 12 02 C3 lcall puts 0113: 12 02 B9 lcall outputcr 0116: 74 01 mov a, #1 0118: 78 FF mov r0, #0xFFh 011A: 22 ret hasarrows: ;fire arrows 011B: 1B dec r3 011C: 12 03 8C lcall playerpos 011F: 90 05 A1 mov dptr, #firemsg 0122: 12 02 C3 lcall puts 0125: 12 02 9B lcall charin 0128: B4 64 0B cjne a, #'d', notfireright 012B: E9 mov a, r1 012C: 54 03 anl a, #3 012E: 94 03 subb a, #3 0130: 60 30 jz invalidfire 0132: 12 01 66 lcall fireright ;will set r0 to correct marker 0135: 22 ret notfireright: 0136: B4 61 09 cjne a, #'a', notfireleft 0139: E9 mov a, r1 013A: 54 03 anl a, #3 013C: 60 24 jz invalidfire 013E: 12 01 79 lcall fireleft ;will set r0 to correct marker 0141: 22 ret notfireleft: 0142: B4 73 0E cjne a, #'s', notfiredown 0145: E9 mov a, r1 0146: C3 clr c 0147: 13 rrc a 0148: C3 clr c 0149: 13 rrc a 014A: C3 clr c 014B: 94 03 subb a, #3 014D: 60 13 jz invalidfire 014F: 12 01 8C lcall firedown 0152: 22 ret notfiredown: 0153: B4 77 0C cjne a, #'w', notfireup 0156: E9 mov a, r1 0157: C3 clr c 0158: 13 rrc a 0159: C3 clr c 015A: 13 rrc a 015B: C3 clr c 015C: 60 04 jz invalidfire 015E: 12 01 A0 lcall fireup 0161: 22 ret notfireup: invalidfire: 0162: 12 01 C5 lcall missedshot 0165: 22 ret fireright: 0166: E9 mov a, r1 0167: 04 inc a 0168: 24 40 add a, #marker 016A: F8 mov r0, a 016B: E6 mov a, @r0 016C: C3 clr c 016D: 94 57 subb a, #'W' 016F: 70 04 jnz missedright 0171: 12 01 B4 lcall killedwumpus 0174: 22 ret missedright: 0175: 12 01 C5 lcall missedshot 0178: 22 ret fireleft: 0179: E9 mov a, r1 017A: 14 dec a 017B: 24 40 add a, #marker 017D: F8 mov r0, a 017E: E6 mov a, @r0 017F: C3 clr c 0180: 94 57 subb a, #'W' 0182: 70 04 jnz missedleft 0184: 12 01 B4 lcall killedwumpus 0187: 22 ret missedleft: 0188: 12 01 C5 lcall missedshot 018B: 22 ret firedown: 018C: E9 mov a, r1 018D: 24 04 add a, #4 018F: 24 40 add a, #marker 0191: F8 mov r0, a 0192: E6 mov a, @r0 0193: C3 clr c 0194: 94 57 subb a, #'W' 0196: 70 04 jnz misseddown 0198: 12 01 B4 lcall killedwumpus 019B: 22 ret misseddown: 019C: 12 01 C5 lcall missedshot 019F: 22 ret fireup: 01A0: E9 mov a, r1 01A1: 94 04 subb a, #4 01A3: 24 40 add a, #marker 01A5: F8 mov r0, a 01A6: E6 mov a, @r0 01A7: C3 clr c 01A8: 94 57 subb a, #'W' 01AA: 70 04 jnz missedup 01AC: 12 01 B4 lcall killedwumpus 01AF: 22 ret missedup: 01B0: 12 01 C5 lcall missedshot 01B3: 22 ret killedwumpus: 01B4: 90 05 E1 mov dptr, #shothit 01B7: 12 02 B9 lcall outputcr 01BA: 12 02 C3 lcall puts 01BD: 12 02 B9 lcall outputcr 01C0: 78 FF mov r0, #0xFFh 01C2: 74 05 mov a, #5 01C4: 22 ret missedshot: 01C5: 90 05 D5 mov dptr, #shotmissed 01C8: 12 02 B9 lcall outputcr 01CB: 12 02 C3 lcall puts 01CE: 12 02 B9 lcall outputcr 01D1: 78 FF mov r0, #0xFFh 01D3: 74 01 mov a, #1 01D5: 22 ret status: ;get the status of the 4 surrounding spaces 01D6: 78 40 mov r0, #marker 01D8: 79 00 mov r1, #0 statloop: 01DA: C3 clr c 01DB: E6 mov a, @r0 01DC: 94 55 subb a, #'U' 01DE: 60 04 jz text; r1 holds position, # 0-15 01E0: 09 inc r1 01E1: 08 inc r0 01E2: 80 F6 sjmp statloop text: 01E4: E9 mov a, r1 01E5: 54 03 anl a, #3 01E7: 60 03 jz afterlookleft 01E9: 12 02 24 lcall lookleft afterlookleft: ;the next calls use logic of the grid to de 01EC: 94 03 subb a, #3 01EE: 60 03 jz afterlookright 01F0: 12 02 30 lcall lookright afterlookright: 01F3: E9 mov a, r1 01F4: C3 clr c ;divide by 4 01F5: 13 rrc a 01F6: C3 clr c 01F7: 13 rrc a 01F8: C3 clr c 01F9: 60 03 jz afterlookup 01FB: 12 02 3C lcall lookup afterlookup: 01FE: 94 03 subb a, #3 0200: 60 03 jz afterlookdown 0202: 12 02 49 lcall lookdown afterlookdown: 0205: 12 02 09 lcall arrowdisp ;display arrow inventory 0208: 22 ret arrowdisp: 0209: FF mov r7, a 020A: 90 07 A5 mov dptr, #arwbegin 020D: 12 02 C3 lcall puts 0210: EB mov a, r3 0211: 24 30 add a, #'0' 0213: 12 02 93 lcall outputa 0216: 90 07 AF mov dptr, #arwend 0219: 12 02 C3 lcall puts 021C: 12 02 B9 lcall outputcr 021F: 12 02 B9 lcall outputcr 0222: EF mov a, r7 0223: 22 ret ;handling functions for each direction lookleft: 0224: FF mov r7, a 0225: E9 mov a, r1 0226: 24 40 add a, #marker 0228: F8 mov r0,a 0229: 18 dec r0 022A: E6 mov a, @r0 022B: 12 02 56 lcall checkresult 022E: EF mov a, r7 022F: 22 ret lookright: 0230: FF mov r7, a 0231: E9 mov a, r1 0232: 24 40 add a, #marker 0234: F8 mov r0,a 0235: 08 inc r0 0236: E6 mov a, @r0 0237: 12 02 56 lcall checkresult 023A: EF mov a, r7 023B: 22 ret lookup: 023C: FF mov r7, a 023D: E9 mov a, r1 023E: 24 40 add a, #marker 0240: 94 04 subb a, #4 0242: F8 mov r0,a 0243: E6 mov a, @r0 0244: 12 02 56 lcall checkresult 0247: EF mov a, r7 0248: 22 ret lookdown: 0249: FF mov r7, a 024A: E9 mov a, r1 024B: 24 40 add a, #marker 024D: 24 04 add a, #4 024F: F8 mov r0,a 0250: E6 mov a, @r0 0251: 12 02 56 lcall checkresult 0254: EF mov a, r7 0255: 22 ret checkresult: ;function that handles what's in surrounding s 0256: 60 3A jz returncheckresult; nothing there, no report 0258: E6 mov a, @r0 0259: B4 57 06 cjne a, #'W', pitcheck 025C: 12 02 A4 lcall nearwumpus 025F: 12 02 B9 lcall outputcr pitcheck: 0262: B4 50 06 cjne a, #'P', batcheck 0265: 12 02 AB lcall nearpit 0268: 12 02 B9 lcall outputcr batcheck: 026B: B4 42 06 cjne a, #'B', wumpusandpitcheck 026E: 12 02 B2 lcall nearbats 0271: 12 02 B9 lcall outputcr wumpusandpitcheck: 0274: B4 51 0C cjne a, #'Q', wumpusandbatcheck 0277: 12 02 A4 lcall nearwumpus 027A: 12 02 B9 lcall outputcr 027D: 12 02 AB lcall nearpit 0280: 12 02 B9 lcall outputcr wumpusandbatcheck: 0283: B4 43 0C cjne a, #'C', returncheckresult ;SHOULD never jump 0286: 12 02 A4 lcall nearwumpus 0289: 12 02 B9 lcall outputcr 028C: 12 02 B2 lcall nearbats 028F: 12 02 B9 lcall outputcr returncheckresult: 0292: 22 ret outputa: ;display what's in accumulator 0293: C2 99 clr TI 0295: F5 99 mov SBuF, a charout: 0297: 30 99 FD jnb TI, charout 029A: 22 ret getchar: ;get a char from the user charin: 029B: 0E inc R6 029C: 30 98 FC jnb RI, charin 029F: C2 98 clr RI 02A1: E5 99 mov a, SBUF 02A3: 22 ret ;display functions for status nearwumpus: 02A4: 90 04 C1 mov dptr, #wummsg 02A7: 12 02 C3 lcall puts 02AA: 22 ret nearpit: 02AB: 90 04 D4 mov dptr, #pitmsg 02AE: 12 02 C3 lcall puts 02B1: 22 ret nearbats: 02B2: 90 04 B3 mov dptr, #batmsg 02B5: 12 02 C3 lcall puts 02B8: 22 ret outputcr: ;display a carriage return 02B9: F5 F0 mov b, a 02BB: 74 0A mov a,#10 02BD: 12 02 93 lcall outputa 02C0: E5 F0 mov a, b 02C2: 22 ret puts: ;put a string(stolen from hello world) 02C3: E4 clr a 02C4: 93 movc a,@a+dptr 02C5: 60 0A jz putret 02C7: C2 99 clr TI 02C9: F5 99 mov SBUF, A 02CB: 30 99 FD puts1: jnb TI,puts1 02CE: A3 inc dptr 02CF: 80 F2 sjmp puts 02D1: 22 putret: ret ;move functions for moving the player moveleft: 02D2: 12 03 8C lcall playerpos 02D5: E9 mov a, r1 ;check if left is possible by modding r1 02D6: 54 03 anl a, #3 02D8: 70 03 jnz leftexists 02DA: 74 01 mov a, #1 ;might want to mark error later 02DC: 22 ret leftexists: 02DD: 18 dec r0 02DE: E6 mov a, @r0 02DF: 70 41 jnz hazard 02E1: 76 55 mov @r0, #'U' 02E3: 08 inc r0 02E4: 76 00 mov @r0, #0 02E6: 74 01 mov a, #1 02E8: 22 ret moveright: 02E9: 12 03 8C lcall playerpos 02EC: E9 mov a, r1 ;check if right is possible by modding r 02ED: 54 03 anl a, #3 02EF: 94 03 subb a, #3 02F1: 70 03 jnz rightexists 02F3: 74 01 mov a, #1 ;might want to mark out of bounds error l 02F5: 22 ret rightexists: 02F6: 08 inc r0 02F7: E6 mov a, @r0 02F8: 70 28 jnz hazard 02FA: 76 55 mov @r0, #'U' 02FC: 18 dec r0 02FD: 76 00 mov @r0, #0 02FF: 74 01 mov a, #1 ;might want to mark out of bounds error l 0301: 22 ret moveup: 0302: 12 03 8C lcall playerpos 0305: E9 mov a, r1 ;check if right is possible by modding r 0306: C3 clr c ;divide by 4 0307: 13 rrc a 0308: C3 clr c 0309: 13 rrc a 030A: C3 clr c 030B: 70 03 jnz upexists 030D: 74 01 mov a, #1 ;might want to mark out of bounds error l 030F: 22 ret upexists: 0310: E8 mov a, r0 0311: 94 04 subb a, #4 0313: F8 mov r0, a 0314: E6 mov a, @r0 0315: 70 0B jnz hazard 0317: 76 55 mov @r0, #'U' 0319: E8 mov a, r0 031A: 24 04 add a, #4 031C: F8 mov r0, a 031D: 76 00 mov @r0, #0 031F: 74 01 mov a, #1 0321: 22 ret ;put in middle for memory jumping range purposes hazard: 0322: B4 42 03 cjne a, #'B', bathazard 0325: 74 03 mov a, #3 ;batted 0327: 22 ret bathazard: 0328: B4 50 03 cjne a, #'P', pithazard 032B: 74 02 mov a, #2 ;pitted 032D: 22 ret pithazard: 032E: 74 04 mov a, #4 ;wumpus by elimination 0330: 22 ret movedown: 0331: 12 03 8C lcall playerpos 0334: E9 mov a, r1 ;check if down is possible by dividing b 0335: C3 clr c ;divide by 4 0336: 13 rrc a 0337: C3 clr c 0338: 13 rrc a 0339: C3 clr c 033A: 94 03 subb a, #3 033C: 70 03 jnz downexists 033E: 74 01 mov a, #1 ;might want to mark out of bounds error l 0340: 22 ret downexists: 0341: E8 mov a, r0 0342: 24 04 add a, #4 0344: F8 mov r0, a 0345: E6 mov a, @r0 0346: 70 DA jnz hazard 0348: 76 55 mov @r0, #'U' 034A: E8 mov a, r0 034B: 94 04 subb a, #4 034D: F8 mov r0, a 034E: 76 00 mov @r0, #0 0350: 74 01 mov a, #1 ;might want to mark out of bounds error l 0352: 22 ret movehandler: 0353: B4 01 06 cjne a, #1, isterminal 0356: 74 00 mov a, #0 0358: 12 04 8F lcall addarrow 035B: 22 ret isterminal: 035C: B4 02 0C cjne a, #2, pasthandpit 035F: 90 05 21 mov dptr, #pitdeath 0362: 12 02 C3 lcall puts 0365: 12 02 B9 lcall outputcr 0368: 74 01 mov a, #1 036A: 22 ret pasthandpit: ;past pitdeath 036B: B4 03 0C cjne a, #3, pasthandbat 036E: 90 05 4E mov dptr, #batmovemsg 0371: 12 02 C3 lcall puts 0374: 12 02 B9 lcall outputcr 0377: 74 02 mov a, #2 0379: 22 ret pasthandbat: 037A: B4 04 0C cjne a, #4, pastwumpusfood 037D: 90 05 7B mov dptr, #wumpusdeath 0380: 12 02 C3 lcall puts 0383: 12 02 B9 lcall outputcr 0386: 74 01 mov a ,#1 0388: 22 ret pastwumpusfood: 0389: 74 01 mov a, #1 038B: 22 ret playerpos: ;put player location in r1 038C: 79 00 mov r1, #0 038E: 78 40 mov r0, #marker iterateloc: 0390: C3 clr c ;first, is move legal? - find player pos 0391: E6 mov a, @r0 0392: 94 55 subb a, #'U' 0394: 60 04 jz doneiterate; r1 holds position, # 0-15 0396: 09 inc r1 0397: 08 inc r0 0398: 80 F6 sjmp iterateloc doneiterate: 039A: 22 ret wumpuspos: ;put wumpus location in r1 039B: 79 00 mov r1, #0 039D: 78 40 mov r0, #marker iteratewloc: 039F: C3 clr c 03A0: E6 mov a, @r0 03A1: 94 57 subb a, #'W' 03A3: 60 10 jz donewiterate 03A5: C3 clr c 03A6: E6 mov a, @r0 03A7: 94 51 subb a, #'Q' 03A9: 60 0A jz donewiterate 03AB: C3 clr c 03AC: E6 mov a, @r0 03AD: 94 43 subb a, #'C' 03AF: 60 04 jz donewiterate 03B1: 09 inc r1 03B2: 08 inc r0 03B3: 80 EA sjmp iteratewloc donewiterate: 03B5: 22 ret movewumpus: ;function for moving the wumpus 03B6: 60 01 jz isneeded 03B8: 22 ret isneeded: 03B9: FF mov r7, a 03BA: 12 04 A6 lcall rand8 03BD: 54 03 anl a, #3 ;want a 1 in 4 of wumpus staying still 03BF: 04 inc a ;make 3 = 4 03C0: C3 clr c 03C1: 13 rrc a ;shift right twice 03C2: C3 clr c 03C3: 13 rrc a 03C4: C3 clr c 03C5: B4 00 28 cjne a, #0, wmoved ;can only equal 1 or 0, jump if invalidwmove: 03C8: 12 03 9B lcall wumpuspos 03CB: 12 04 A6 lcall rand8 03CE: 54 07 anl a, #7 03D0: C3 clr c 03D1: 13 rrc a 03D2: C3 clr c 03D3: B4 00 05 cjne a, #0, skipzero 03D6: 12 03 F4 lcall movewup 03D9: 80 15 sjmp wmoved skipzero: 03DB: B4 01 05 cjne a, #1, skipone 03DE: 12 04 21 lcall movewdown 03E1: 80 0D sjmp wmoved skipone: 03E3: B4 02 05 cjne a, #2, skiptwo 03E6: 12 04 4F lcall movewright 03E9: 80 05 sjmp wmoved skiptwo: 03EB: 12 04 3D lcall movewleft 03EE: 80 00 sjmp wmoved wmoved: 03F0: 60 D6 jz invalidwmove 03F2: EF mov a, r7 03F3: 22 ret movewup: 03F4: E9 mov a, r1 03F5: 60 7E jz nowspace 03F7: 14 dec a 03F8: 60 7B jz nowspace 03FA: 14 dec a 03FB: 60 78 jz nowspace 03FD: 14 dec a 03FE: 60 75 jz nowspace 0400: 14 dec a 0401: 24 40 add a, #marker 0403: F8 mov r0, a 0404: E6 mov a, @r0 0405: B4 00 04 cjne a, #0, wblocked;is pit or bat in wumpus's move 0408: 76 57 mov @r0, #'W' 040A: 80 57 sjmp wcleanup wblocked: 040C: B4 55 0E cjne a, #'U', notplayer 040F: 90 06 04 mov dptr, #wumpuscaught ;the wumpus moved into the 0412: 12 02 B9 lcall outputcr 0415: 12 02 C3 lcall puts 0418: 7F 01 mov R7, #1 041A: 74 01 mov a, #1 041C: 22 ret notplayer: 041D: 04 inc a ;since pit and bat's occupied letters are one 041E: F6 mov @r0, a 041F: 80 42 sjmp wcleanup movewdown: 0421: E9 mov a, r1 0422: 94 10 subb a, #16 ;so that a hits zero and jumps if a > 1 0424: 04 inc a 0425: 60 4E jz nowspace 0427: 04 inc a 0428: 60 4B jz nowspace 042A: 04 inc a 042B: 60 48 jz nowspace 042D: 04 inc a 042E: 60 45 jz nowspace 0430: 24 10 add a, #16 ;restore a so that it's a valid location 0432: 24 40 add a, #marker 0434: F8 mov r0, a 0435: E6 mov a, @r0 0436: B4 00 D3 cjne a, #0, wblocked;is pit or bat in wumpus's move 0439: 76 57 mov @r0, #'W' 043B: 80 26 sjmp wcleanup movewleft: 043D: E9 mov a, r1 043E: 54 03 anl a, #3 0440: 60 33 jz nowspace 0442: E9 mov a, r1 0443: 14 dec a 0444: 24 40 add a, #marker 0446: F8 mov r0, a 0447: E6 mov a, @r0 0448: B4 00 C1 cjne a, #0, wblocked;is pit or bat in wumpus's move 044B: 76 57 mov @r0, #'W' 044D: 80 14 sjmp wcleanup movewright: 044F: E9 mov a, r1 0450: 54 03 anl a, #3 0452: 94 03 subb a, #3 0454: 60 1F jz nowspace 0456: E9 mov a, r1 0457: 04 inc a 0458: 24 40 add a, #marker 045A: F8 mov r0, a 045B: E6 mov a, @r0 045C: B4 00 AD cjne a, #0, wblocked;is pit or bat in wumpus's move 045F: 76 57 mov @r0, #'W' 0461: 80 00 sjmp wcleanup wcleanup: 0463: E9 mov a, r1 0464: 24 40 add a, #marker 0466: F8 mov r0, a 0467: E6 mov a, @r0 0468: B4 57 05 cjne a, #'W', notclear 046B: 76 00 mov @r0, #0 046D: 74 01 mov a, #1 ;nonzero value so that movewumpus doesn't 046F: 22 ret notclear: 0470: 14 dec a 0471: F6 mov @r0, a 0472: 74 01 mov a, #1 ;nonzero value so that movewumpus doesn't 0474: 22 ret nowspace: 0475: 74 00 mov a, #0 ;force movewumpus to loop 0477: 22 ret batmove: ;player jumped into a bat space 0478: 12 03 8C lcall playerpos 047B: E9 mov a, r1 047C: 24 40 add a, #marker 047E: F8 mov r0, a 047F: 76 00 mov @r0, #0 moveplr: 0481: 12 04 A6 lcall rand8 0484: 54 0F anl a, #15 0486: 24 40 add a, #marker 0488: F8 mov r0, a 0489: E6 mov a, @r0 048A: 70 F5 jnz moveplr 048C: 76 55 mov @r0, #'U' 048E: 22 ret addarrow: 048F: FF mov r7, a 0490: EB mov a, r3 0491: 94 09 subb a, #9 0493: 60 0F jz nonewarrow 0495: 12 04 A6 lcall rand8 0498: 54 07 anl a, #7 049A: B4 05 07 cjne a, #5, nonewarrow 049D: 90 07 E1 mov dptr, #foundarrow 04A0: 12 02 C3 lcall puts 04A3: 0B inc r3 nonewarrow: 04A4: EF mov a, r7 04A5: 22 ret rand8: ;RNG, is linear congruential with the form 221*x + 5 ;is seeded by counting cycles while waiting for inp 04A6: EE mov a, r6 04A7: B4 00 01 cjne a, #0, notzero 04AA: 04 inc a notzero: 04AB: 75 F0 DD mov b, #221 04AE: A4 mul AB 04AF: 24 35 add a, #53 04B1: FE mov r6, a 04B2: 22 ret batmsg: 04B3: 59 6F 75 20 68 65 61 72 20 62 61 74 73 00 .byte 'Y','o','u',' ','h','e','a','r',' ','b','a',' wummsg: 04C1: 59 6F 75 20 73 6D 65 6C 6C 20 61 20 77 75 6D 70 75 73 00 .byte 'Y','o','u',' ','s','m','e','l','l',' ','a',' pitmsg: 04D4: 59 6F 75 20 66 65 65 6C 20 61 20 64 72 61 66 74 00 .byte 'Y','o','u',' ','f','e','e','l',' ','a',' ',' choosemsg: 04E5: 50 6C 65 61 73 65 20 70 72 65 73 73 20 77 2C 61 2C 73 2C 6F 72 20 64 20 66 6F 72 20 61 20 64 69 72 65 63 74 69 6F 6E 20 6F 72 20 70 72 65 73 73 20 66 20 74 6F 20 66 69 72 65 2E .byte "Please press w,a,s,or d for a direction or p 0520: 00 .byte 0 pitdeath: 0521: 59 6F 75 20 66 65 6C 6C 20 69 6E 74 6F 20 61 20 70 69 74 2E 20 20 48 61 76 65 20 61 20 6E 69 63 65 20 61 66 74 65 72 6C 69 66 65 2E .byte "You fell into a pit. Have a nice afterlife. 054D: 00 .byte 0 batmovemsg: 054E: 54 68 65 20 62 61 74 73 20 68 61 76 65 20 63 61 72 72 69 65 64 20 79 6F 75 20 74 6F 20 61 20 72 61 6E 64 6F 6D 20 73 70 61 63 65 21 .byte "The bats have carried you to a random space! 057A: 00 .byte 0 wumpusdeath: 057B: 43 6F 6E 67 72 61 74 75 6C 61 74 69 6F 6E 73 21 20 20 59 6F 75 27 72 65 20 77 75 6D 70 75 73 20 66 6F 6F 64 21 .byte "Congratulations! You're wumpus food!" 05A0: 00 .byte 0 firemsg: 05A1: 50 6C 65 61 73 65 20 75 73 65 20 77 2C 61 2C 73 2C 6F 72 20 64 20 74 6F 20 63 68 6F 6F 73 65 20 61 20 64 69 72 65 63 74 69 6F 6E 20 6F 66 20 66 69 72 65 .byte "Please use w,a,s,or d to choose a direction 05D4: 00 .byte 0 shotmissed: 05D5: 59 6F 75 20 6D 69 73 73 65 64 21 .byte "You missed!" 05E0: 00 .byte 0 shothit: 05E1: 59 6F 75 20 6B 69 6C 6C 65 64 20 74 68 65 20 77 75 6D 70 75 73 2E 2E 2E 6E 69 63 65 20 77 6F 72 6B 21 .byte "You killed the wumpus...nice work!" 0603: 00 .byte 0 wumpuscaught: 0604: 54 68 65 20 77 75 6D 70 75 73 20 66 6F 75 6E 64 20 79 6F 75 21 21 20 20 48 6F 70 65 20 79 6F 75 27 72 65 20 66 75 6C 6C 20 6F 66 20 76 69 74 61 6D 69 6E 73 20 61 6E 64 20 6D 69 6E 65 72 61 6C 73 21 .byte "The wumpus found you!! Hope you're full of 0646: 00 .byte 0 openingscreen: 0647: 57 65 6C 63 6F 6D 65 20 74 6F 20 48 75 6E 74 20 74 68 65 20 57 75 6D 70 75 73 2C 20 77 68 65 72 65 20 79 6F 75 20 68 75 6E 74 20 74 68 65 20 6D 6F 73 74 20 64 61 6E 67 65 72 6F 75 73 20 6F 66 0A 61 6E 79 20 61 6E 69 6D 61 6C 20 .byte "Welcome to Hunt the Wumpus, where you hunt t 0693: 74 68 61 74 20 68 61 73 20 65 76 65 72 20 77 61 6C 6B 65 64 20 74 68 65 20 65 61 72 74 68 21 20 20 59 6F 75 72 20 6F 6E 6C 79 20 66 72 69 65 6E 64 20 69 73 20 79 6F 75 72 20 74 72 75 73 74 79 0A 62 6F 77 20 61 6E 64 20 .byte "that has ever walked the earth! Your only f 06DC: 61 72 72 6F 77 2E 20 20 49 6E 20 74 68 65 20 63 61 76 65 73 20 61 72 65 20 70 69 74 73 20 74 68 61 74 20 64 72 6F 70 20 79 6F 75 20 74 6F 20 79 6F 75 72 20 64 65 61 74 68 20 61 6E 64 20 62 61 74 73 0A 74 68 61 74 20 .byte "arrow. In the caves are pits that drop you 0724: 70 69 63 6B 20 79 6F 75 20 75 70 20 61 6E 64 20 6D 6F 76 65 20 79 6F 75 20 74 6F 20 72 61 6E 64 6F 6D 20 70 6C 61 63 65 73 2E 20 20 47 6F 6F 64 20 48 75 6E 74 69 6E 67 21 0A .byte "pick you up and move you to random places. 075E: 50 72 65 73 73 20 61 20 6B 65 79 20 74 6F 20 63 6F 6E 74 69 6E 75 65 21 0A .byte "Press a key to continue!\n" 0777: 00 .byte 0 noarrows: 0778: 59 6F 75 20 68 61 76 65 20 6E 6F 20 61 72 72 6F 77 73 2E 2E 2E 62 65 74 74 65 72 20 74 72 79 20 74 6F 20 66 69 6E 64 20 6F 6E 65 21 .byte "You have no arrows...better try to find one! 07A4: 00 .byte 0 arwbegin: 07A5: 59 6F 75 20 68 61 76 65 20 .byte "You have " 07AE: 00 .byte 0 arwend: 07AF: 20 61 72 72 6F 77 73 .byte " arrows" 07B6: 00 .byte 0 nothergame: 07B7: 50 6C 65 61 73 65 20 70 72 65 73 73 20 61 20 6B 65 79 20 74 6F 20 70 6C 61 79 20 61 6E 6F 74 68 65 72 20 67 61 6D 65 21 0A .byte "Please press a key to play another game!\n" 07E0: 00 .byte 0 foundarrow: 07E1: 0A 0A 59 6F 75 20 66 6F 75 6E 64 20 61 6E 20 61 72 72 6F 77 21 0A 0A .byte "\n\nYou found an arrow!\n\n" 07F8: 00 .byte 0