Akalabeth Main Game File

31 thoughts
last posted April 5, 2014, 6 a.m.

27 earlier thoughts

0

Initialization

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 maps
  • TE%(20,20) is for terrain map
  • XX%(10) unknown
  • YY%(10) unknown
  • PER%(10,3) unknown
  • LD%(10,5) unknown
  • CD%(10,3) unknown
  • FT%(10,5) unknown
  • LAD%(10,3) unknown

Given we haven't seen any of the unknown ones anywhere else yet, they must be related to drawing the dungeon images.

Randomize the Terrain Map

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

3 later thoughts