Source:BaseFix

From Eamon Wiki
Jump to navigation Jump to search
This page is a verbatim reproduction of original source material and should not be edited except for maintenance.
Description

The Applesoft BASIC source code of the Eamon utility program BaseFix.

Source

Eamon Utilities IV

Date

November 1981

Author

Robert Plamondon

License

The use of this item is permitted on the grounds that it's free or in the public domain.

2  REM ALTERS BASE DUNGEON PGM
4  REM FOR GREATER SPEED,
6  REM BETTER OUTPUT FORMAT,
8  REM AND MORE CONSISTANT LOGIC.
10  REM 
12  REM  BY ROBERT PLAMONDON,
14  REM  NOVEMBER,  1981
16  REM 
18  REM TO USE, LOAD BASE PROGRAM
20  REM  FOR AN ADVENTURE,
22  REM  THE TYPE 'EXEC BASEMOD'
24  REM 
26  REM THEN RESAVE THE BASE
28  REM PROGRAM.
30  REM 
32  HOME : VTAB 3: HTAB 17: INVERSE : PRINT "BASEFIX": NORMAL : VTAB 6
34  PRINT "   THIS PROGRAM ALTERS THE BASE DUNGEON": PRINT "PROGRAM FOR EAMON ADVENTURES."
36  PRINT "   IT SPEEDS UP THE MAIN LOOP, ADDS": PRINT "AN ERROR-RECOVERY ROUTINE, CLEANS UP": PRINT "THE FORMAT, AND ELIMINATES A NUMBER OF": PRINT "MINOR BUGS IN THE BASE DUNGEON PROGRAM."
38  PRINT : PRINT "   WHEN THIS PROGRAM IS RUN, IT MAKES": PRINT "A TEXT FILE NAMED ";: INVERSE : PRINT "BASEMOD";: NORMAL : PRINT ", WHICH IS"
40  PRINT "USED AS AN EXEC FILE TO ALTER THE BASE": PRINT "PROGRAM.  THE PROCEDURE IS AS FOLLOWS:"
41  PRINT : INVERSE : PRINT "DO NOT USE THIS PROGRAM ON THE TEMPLE": PRINT "OF NGURCT OR THE BEGINNERS CAVE.": NORMAL 
42  PRINT : PRINT  TAB( 7);"(HIT ANY KEY TO CONTINUE)";: GET A$: HOME 
44  PRINT : PRINT "1.  LOAD THE BASE PROGRAM FOR THE": PRINT "    ADVENTURE YOU WANT TO UPDATE."
46  PRINT : PRINT "2.  LOOK AT LINES 130-210 FOR SPECIAL": PRINT "    FEATURES, SUCH AS TELEPORTATION": PRINT "    OR DEMON SUMMONING. THESE FEATURES"
48  PRINT "    WILL PROBABLY BE FOULED UP BY THIS": PRINT "    PROGRAM, SO YOU'LL HAVE TO PATCH": PRINT "    THINGS UP LATER TO GET THE FEATURES": PRINT "    BACK."
50  PRINT : PRINT "3.  IF DEAD BODIES DO NOT APPEAR WHEN": PRINT "    CREATURES DIE, DELETE LINE 7704."
52  PRINT : PRINT "4.  MAKE SURE THERE ISN'T ANYTHING IN": PRINT "    LINES 59000-60000, SINCE THAT'S": PRINT "    WHERE WE'RE PUTTING THE ERROR-": PRINT "    HANDLING ROUTINES."
54  PRINT : PRINT  TAB( 7);"(HIT ANY KEY TO CONTINUE)";: GET A$: HOME 
56  PRINT : PRINT "5.  WITH THE BASE PROGRAM STILL IN MEM-": PRINT "    ORY, PUT IN THE DISK WITH BASEMOD,": PRINT "    AND TYPE, 'EXEC BASEMOD.'  THIS": PRINT "    WILL ADD THE LINES BETWEEN 100"
58  PRINT "    AND 59999 IN THIS PROGRAM TO THE": PRINT "    BASE PROGRAM IN MEMORY."
60  PRINT : PRINT "6.  UNLOCK THE OLD BASE PROGRAM, AND": PRINT "    RENAME IT 'OLD BASE,' OR SOMETHING."
62  PRINT : PRINT "7.  SAVE THE ALTERED PROGRAM, USING": PRINT "    THE ORIGINAL NAME OF THE BASE PRO-": PRINT "    GRAM (USUALLY MAIN PGM OR MAIN PRG)."
64  PRINT : PRINT "8.  DEBUG.  MOST EAMON ADVENTURES WILL": PRINT "    RUN FINE WITHOUT FURTHER ALTER-": PRINT "    ATION, BUT SOME WON'T."
66  PRINT : PRINT "TYPE Q TO QUIT, OR HIT ANY OTHER KEY": PRINT "TO CREATE BASEMOD (THE EXEC FILE)";
68  GET A$: IF A$ = "Q" THEN  END 
70  PRINT 
72  GOTO 60000
74  END 
105  SPEED= 255
130  IF V%(ROOM) THEN  PRINT "YOU ARE": PRINT " ";RN$(ROOM): GOTO 150
140  PRINT DK$;"READ EAMON.DESC,R";ROOM: INPUT A$: PRINT DK$: PRINT A$: PRINT :V%(ROOM) = 1
150  FOR M = 1 TO NM: IF MD%(M,5) <  > ROOM THEN  NEXT : GOTO 170
155  IF MD%(M,15) THEN  PRINT "   >> ";MN$(M);" IS HERE.": NEXT : GOTO 170
160  PRINT DK$;"READ EAMON.DESC,R";M + 300: INPUT A$: PRINT DK$:MD%(M,15) = 1: IF A$ <  > "" THEN  PRINT A$: PRINT : NEXT 
170  FOR A = 1 TO NZ: IF AD%(A,4) <  > ROOM THEN  NEXT : GOTO 190
175  IF AD%(A,9) THEN  PRINT "   -- YOU SEE ";AN$(A): NEXT : GOTO 190
180  PRINT DK$;"READ EAMON.DESC,R";A + 100: INPUT A$: PRINT DK$: PRINT A$:AD%(A,9) = 1: PRINT : NEXT 
190  FOR A = A TO NA: IF AD%(A,4) = ROOM THEN  PRINT "   -> YOUR ";AN$(A);" IS HERE."
210  INVERSE : PRINT "YOUR COMMAND?";: NORMAL : INPUT " ";A$
285  SPEED= 200
330 M2 = MD%(M,14) - (MD%(M,14) = 2):MR = 100 * FD%(M2) / TD%(M2) +  INT (41 *  RND (1) - 20) - 20 * (MD%(M,9) =  - 1)
340  IF MD%(M,4) < MR THEN  INVERSE : PRINT MN$(M);" FLEES OUT AN EXIT.": NORMAL : GOSUB 8500:MD%(M,5) = R2:M2 = MD%(M,14):TD%(M2) = TD%(M2) - MD%(M,1):FD%(MD) = FD%(M2) - MD%(M,13): GOTO 490
1057  PRINT DK$;"NOMONC,I,O"
1058  POKE 33,40
1200  DIM ED%(NR,6)
1210  FOR X = 1 TO NR: PRINT DK$;"READ EAMON.ROOMS,R";X: FOR Y = 1 TO 6: INPUT ED%(X,Y): NEXT Y,X
1230  DIM RN$(NR)
1250  FOR X = 1 TO NR: PRINT DK$;"READ EAMON.ROOM NAMES,R";X: INPUT RN$(X): NEXT 
1300  DEF  FN R(X) =  INT ( RND (1) * 100 + 1)
1350  ONERR  GOTO 59000
2005  SPEED= 255
3030 R2 = ED%(ROOM,D)
7525  INVERSE : PRINT "A FUMBLE!": NORMAL :FR =  FN R(X)
7527  IF FR < 35 + 40 * ( NOT MD%(OF,9)) THEN  PRINT "   FUMBLE RECOVERED.": PRINT : RETURN 
7532  IF MD%(OF,9) = 0 GOTO 7550
7535  IF FR > 95 THEN 7550
7536  REM  //WEAPONS WITH HIGH COMPLEXITY BREAK LESS OFTEN:
7537  IF AD%(MD%(OF,9),5) * 3 <  FN R(X) THEN  PRINT "   FUMBLE RECOVERED.": PRINT : RETURN 
7610  INVERSE : PRINT "A CRITICAL HIT!": NORMAL :R2 =  FN R(X): IF R2 < 51 THEN A = 0: GOTO 7635
7655  PRINT " IS IN GOOD SHAPE.": RETURN 
7660  PRINT " IS LIGHTLY INJURED.": RETURN 
7665  PRINT " IS BADLY INJURED.": RETURN 
7670  PRINT " IS VERY BADLY INJURED.": RETURN 
7675  PRINT " IS AT DEATH'S DOOR,": PRINT "   KNOCKING LOUDLY.": RETURN 
7700  FLASH : PRINT MN$(DF);" IS DEAD!": NORMAL 
7702 A = MD%(DF,14):FD%(A) = FD%(A) + MD%(DF,1) - MD%(DF,13) + D2:MD%(DF,5) = 0
7703  REM ///PUT DEAD BODY IN ROOM
7704 A2 = DF + NZ - NM:AD%(A2,4) = ROOM
7705  REM //DROP WEAPONS,DISARM,REDUCE COURAGE (IN CASE MONSTER GETS RESURRECTED)
7706  IF MD%(DF,9) > 0 THEN AD%(MD%(DF,9),4) = ROOM:MD%(DF,10) = MD%(DF,10) - AD%(MD%(DF,9),5):MD%(DF,9) =  - 1:MD%(DF,4) = MD%(DF,4) / 2
8500 K1 = 0: FOR D = 1 TO 6:K = ED%(ROOM,D):DR$ = DR$ +  STR$ (K): IF K > 0 THEN K1 = K1 + 1:DR%(K1) = K
8510  NEXT :RR =  RND (1) * K1 + 1:R2 = DR%(RR)
11500 SUC = 0: IF SA%(S) THEN RL =  FN R(X):SUC = (((RL < S2%(S)) OR (RL < 6)) AND (RL < 96))
11510  IF SUC THEN 11520
11512  IF  FN R(X) = 1 THEN  GOSUB 11600: RETURN 
11514  PRINT "  NOTHING HAPPENS.": RETURN 
59000  REM ////ERROR HANDLING ROUTINE
59001  POKE 768,104: POKE 769,168: POKE 770,104: POKE 771,166: POKE 772,223: POKE 773,154: POKE 774,72: POKE 775,152: POKE 776,72: POKE 777,96: CALL 768
59005  NORMAL 
59010 CODE =  PEEK (222):LN =  PEEK (218) + 256 *  PEEK (219)
59020  PRINT  CHR$ (7);"**** ERROR #";CODE;" IN LINE ";LN
59030  IF  NOT CODE THEN  PRINT "(NEXT WITHOUT FOR)"
59050  IF CODE = 16 THEN  PRINT "(SYNTAX)"
59060  IF CODE = 22 THEN  PRINT "(RETURN WITHOUT GOSUB)"
59070  IF CODE = 42 THEN  PRINT "(OUT OF DATA)"
59080  IF CODE = 53 THEN  PRINT "ILLEGAL QUANTITY)"
59090  IF CODE = 77 THEN  PRINT "(OUT OF MEMORY)"
59100  IF CODE = 90 THEN  PRINT "(UNDEFINED STATEMENT)"
59110  IF CODE = 107 THEN  PRINT "(BAD SUBSCRIPT)"
59120  IF CODE = 163 THEN  PRINT "(TYPE MISMATCH)"
59130  IF CODE = 255 THEN  PRINT "(CTRL-C INTERRUPT ATTEMPTED)": PRINT "TO STOP THIS PROGRAM, HIT 'RESET'"
59199  PRINT 
59200  PRINT "*** ATTEMPTING TO RECOVER ***": PRINT : GOTO 100
59999  END 
60000 D$ =  CHR$ (4)
60002  HOME 
60005  PRINT D$;"MONC,I,O"
60010  PRINT D$;"OPEN BASEMOD"
60012  PRINT D$;"DELETE BASEMOD"
60014  PRINT D$;"OPEN BASEMOD"
60020  PRINT D$;"WRITE BASEMOD"
60022  PRINT "MONCIO"
60030  POKE 33,33: LIST 100 - 59999: POKE 33,40
60040  PRINT D$;"CLOSE"