Akalabeth Main Game File

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

26 earlier thoughts

0

Drawing Terrain

The terrain drawing routine appears to be lines 100–190.

As we've already seen, the terrain is stored in TER%() and we know from the outside movement commands that TX and TY store the location of the player.

We further more know that the values of TER%() are:

  • 1 = MOUNTAINS
  • 3 = TOWN (SHOP)
  • 4 = DUNGEON
  • 5 = LORD BRITISH'S CASTLE

I presume therefore that 2 must be the little squares (never knew what they were supposed to be).

We switch to hires graphics mode and loop over [-1, 0, 1] x [-1, 0, 1] to draw the terrain tile the player is on and the eight surrounding.

100  HGR : FOR Y =  - 1 TO 1: FOR X =  - 1 TO 1

We next draw the crosshairs indicated the player's location:

105 HPLOT 138,75 TO 142,75: HPLOT 140,73 TO 140,77

We retrieve the terrain type and put it in ZZ then work out the top left corner of the tile to draw. The tiles are 50 x 50 and start at (65, 0).

110 ZZ = TER%(TX + X,TY + Y):X1 = 65 + (X + 1) * 50:Y1 = (Y + 1) * 50

"Little Square" (2)

120  IF ZZ = 2 THEN  HPLOT X1 + 20,Y1 + 20 TO X1 + 30,Y1 + 20 TO X1 + 30,Y1 + 30 TO X1 + 20,Y1 + 30 TO X1 + 20,Y1 + 20

Town/Shop (3)

130  IF ZZ = 3 THEN  HPLOT X1 + 10,Y1 + 10 TO X1 + 20,Y1 + 10 TO X1 + 20,Y1 + 40 TO X1 + 10,Y1 + 40 TO X1 + 10,Y1 + 30 TO X1 + 40,Y1 + 30 TO X1 + 40,Y1 + 40 TO X1 + 30,Y1 + 40 TO X1 + 30,Y1 + 10 TO X1 + 40,Y1 + 10 TO X1 + 40,Y1 + 20 TO X1 + 10,Y1 + 20 TO X1 + 10,Y1 + 10

Dungeon (4)

140  IF ZZ = 4 THEN  HPLOT X1 + 20,Y1 + 20 TO X1 + 30,Y1 + 30: HPLOT X1 + 20,Y1 + 30 TO X1 + 30,Y1 + 20

Lord British's Castle (5)

150  IF ZZ = 5 THEN  HPLOT X1,Y1 TO X1 + 50,Y1 TO X1 + 50,Y1 + 50 TO X1,Y1 + 50 TO X1,Y1: HPLOT X1 + 10,Y1 + 10 TO X1 + 10,Y1 + 40 TO X1 + 40,Y1 + 40 TO X1 + 40,Y1 + 10 TO X1 + 10,Y1 + 10 TO X1 + 40,Y1 + 40: HPLOT X1 + 10,Y1 + 40 TO X1 + 40,Y1 + 10

Mountains (1)

160  IF ZZ = 1 THEN  HPLOT X1 + 10,Y1 + 50 TO X1 + 10,Y1 + 40 TO X1 + 20,Y1 + 30 TO X1 + 40,Y1 + 30 TO X1 + 40,Y1 + 50: HPLOT X1,Y1 + 10 TO X1 + 10,Y1 + 10: HPLOT X1 + 50,Y1 + 10 TO X1 + 40,Y1 + 10: HPLOT X1,Y1 + 40 TO X1 + 10,Y1 + 40: HPLOT X1 + 40,Y1 + 40 TO X1 + 50,Y1 + 40
170  IF ZZ = 1 THEN  HPLOT X1 + 10,Y1 TO X1 + 10,Y1 + 20 TO X1 + 20,Y1 + 20 TO X1 + 20,Y1 + 30 TO X1 + 30,Y1 + 30 TO X1 + 30,Y1 + 10 TO X1 + 40,Y1 + 10 TO X1 + 40,Y1

Then we loop back for the next tile and then return when all 9 are done:

190  NEXT : NEXT : RETURN

4 later thoughts