It's about time we got to the first 30 lines of the program.
In case of error...
0 ONERR GOTO 4
1 REM
Reset input / output
4 PR # 0: IN # 0
Set HIMEM to $BFFF (which I guess would effectively remove DOS)
5 HIMEM: 49151
Clear all variables and GOSUB to the Character Creation routine.
7 CLEAR : GOSUB 60000
Get a random number based on the player's lucky number.
8 ZZ = RND ( - ABS (LN))
Can't fine where a variable LE
is used anywhere.
9 LEVEL = 0
Switch to text mode and print the welcome message:
10 TEXT : HOME : NORMAL : VTAB (12): PRINT " WELCOME TO AKALABETH, WORLD OF DOOM!"
Initialize the arrays:
20 DIM DN%(10,10),TE%(20,20),XX%(10),YY%(10),PER%(10,3),LD%(10,5),CD%(10,3),FT%(10,5),LAD%(10,3)
DN%(10,10)
is for dungeon level mapsTE%(20,20)
is for terrain mapXX%(10)
unknownYY%(10)
unknownPER%(10,3)
unknownLD%(10,5)
unknownCD%(10,3)
unknownFT%(10,5)
unknownLAD%(10,3)
unknownGiven we haven't seen any of the unknown ones anywhere else yet, they must be related to drawing the dungeon images.
Set the outsides to mountains:
30 FOR X = 0 TO 20:TE%(X,0) = 1:TE%(0,X) = 1:TE%(X,20) = 1:TE%(20,X) = 1: NEXT
Warn the player that this next bit could take a while...
35 : VTAB (23): PRINT " (PLEASE WAIT)";
Completely randomize the inside 19 x 19 terrain tiles (except for Lord British's Castle). I'm still not sure what the ; 5 * 4.5
in the INT
would do:
40 FOR X = 1 TO 19: FOR Y = 1 TO 19:TE%(X,Y) = INT ( RND (1) ; 5 * 4.5)
However, if we roll a town/shop, there's a 50% chance it will be changed to empty land:
41 IF TE%(X,Y) = 3 AND RND (1) > .5 THEN TE%(X,Y) = 0
42 NEXT : PRINT ".";: NEXT
We pick one place to put Lord British's Castle. We then randomly pick a starting location and make that position a town/shop.
50 TE%( INT ( RND (1) * 19 + 1), INT ( RND (1) * 19 + 1)) = 5:TX = INT ( RND (1) * 19 + 1):TY = INT ( RND (1) * 19 + 1):TE%(TX,TY) = 3
I guess that makes it possible (1 in 361 chance) that there'll be no Lord British in a game because the starting location (and hence the starting town) overwrote Lord British's Castle.
Lines 51–62 seem to be initializing some lookup tables for the dungeon drawing so we'll get to those in a bit. The rest of the initialization code is...
Clear the screen and set the graphics color to white:
68 HOME : HCOLOR= 3
Then set the top edge and the width of the text area to be 20 and 29 and go to the top of that area:
69 POKE 34,20: POKE 33,29: HOME
Finally we draw the surrounding terrain and go to the command loop:
70 GOSUB 100: GOTO 1000