I started off this session discussing some popular RPG games that were made in the past. While I was still a college student, I spent a considerable amount of time engrossed in an RPG on the MS DOS computer system that was called “The Adventures of Maddog Williams”. This was made somewhere in the early to late 90’s. Although it’s not a Commodore 64, I liked the design structure, story-line, and graphics and couldn’t resist including it in as a review.

C64 Gaming Marathon Example

About the same time, a company by the name of Sierra Online made their entrance in the game industry. After releasing many titles, they finally designed a game that adapted 3D elements from a 2D perspective. This game was quite interesting because of how each screen connected to the maps. I plan to keep this in mind when we start to expand our maps beyond one screen.

The next game I added to our review list for the C64 Gaming Marathon was the famous Ultima IV: Quest of the Avatar made in 1996. This one represents a style very close to what I desire to create. I like the built in text parser, enemy engagement (sometimes with talking dialogue), animation, and miniaturized view-port for the screen.

Commodore 64 Gaming Marathon Display

For the Basic program C64 Gaming Marathon example, I wanted to show the style of the technique used for this lesson. The first section shows the game stats in a stacked display down the screen from strength, level, experience, a threat meter, gold, and monster strength.

Then it shows the environment your player is positioned at. As an example of the C64 Gaming Marathon, the video show the message ‘YOU HAVE ARRIVED AT A CLEARING’. This will change each time the game is run since it’s based off a random display, which we will learn about later in this session.

Eventually I hope to add multiple types of commands that will be accepted at a user prompt. For now though, this game can understand the command ‘FIGHT’. This will then provoke a subroutine that summons a monster within range. It will also track how much strength this opponent has at the moment.

Then a simple message displays afterward, ‘YOU DRAW YOUR SWORD AND PREPARE TO FIGHT! After this, you will be presented with several different messages, depending on what the random number generator recorded. So taking into consideration that you are fighting the Wizard, you must see any of the following on the display.

THE WIZARD HAS RECEIVED 119 IN DAMAGE
YOU MISSED …
THE WIZARD MISSED
YOU HAVE BEEN HIT. THE DAMAGE IS 140

Commodore 64 String Variables

Now it’s time to review the code for the C64 Gaming Marathon and see what makes this possible. When writing a Basic program, you can store values in memory areas called string variables (also known as string arrays). These are pretty effective since you can stuff a lot of data and pull them off by number. Let’s examine a few lines to make sense of this.

10 REM MONSTER BATTLE SUBROUTINE
20 :
30 FORX=1TO8:READMO$(X):NEXT
40 FORX=1TO7:READEN$(X):NEXT

Reading Commodore 64 Data

So before we continue with the lines below we are going to jump down and examine where the FOR loops at lines 30 and 40 are reading data into our string arrays for MO$ and EN$. The C64 Gaming Marathon program will scan through the lines until it locates a DATA statment then it will use the READ statement and record it to an area of memory.

7030 DATA THIEF,BAT,SNAKE,WITCH,WIZARD,ORC,TROLL,DRAGON
7040 DATACLEARING,FOREST ENTRY,DARK TUNNEL,BRIDGE,DEEP CAVE,OPEN FIELD,VALLEY

The program now understands that line 30 will start READing from line 7030 and record this into each array from 1-8 pockets. Look at the example below to understand this better.

MO$(1)=”THIEF”
MO$(2)=”BAT”
MO$(3)=”SNAKE”
MO$(4)=”WITCH”
MO$(5)=”WIZARD”
MO$(6)=”ORC”
MO$(7)=”TROLL”
MO$(8)=”DRAGON”

Next we are going to read variables for our game statistics just like we have been doing all along. Line 40 takes care of this for us. In preview, the values are MS (Monster Strength), HS (Human Strength), EX (Experience), GD (Gold), and LV (Level). These will likely change as the series continues to evolve.

Line 50 executes a GOSUB 2204. This tells the C64 Gaming Marathon program to jump to line 2204 and wait until a RETURN to come back where it left off. Let’s examine line 2204 and beyond.

2204 MN=1+INT(RND(0)*7)
2205 EN=1+INT(RND(0)*7)
2207 MT$=”NONE”
2280 RETURN

Therefore, the lines above create 3 variables. The variable MN represents which monster we will be fighting. It will pick a number between 1 to 7 to show that assailant on the screen.

The next line creates a variable called EN. This is used to setup which environment our player will be placed in when the game is first run. Finally we see a variable called MT$. This will later keep track of a threat meter for the player.

C64 Gaming Marathon Stats

We now are back at line 55 of our C64 Gaming Marathon example since we encountered the RETURN at line 2280. Very simply line 55 will clear the screen with a PRINT CHR$(147) and change the border color to red, and the background screen color to black. Then we arrive at another statement that says GOSUB 3003 that will send us to that line for further exploration.

55 PRINTCHR$(147):POKE53280,2:POKE53281,0 Save
56 GOSUB 3003:REM MONSTER DAMAGE?

Let’s get a printed display of our new lines below.

3003 POKE646,1
3004 PRINT”YOUR STRENGTH:”HS
3005 PRINT”LEVEL:”LV
3006 PRINT”EXPERIENCE:”EX
3007 PRINT”THREAT METER:”MT$
3008 PRINT”GOLD:”GD
3010 IFMS<1THENRETURN
3015 PRINT”MONSTER STRENGTH:”MS
3020 PRINT
3100 RETURN

The lines above are pretty straight forward. They print our game statistics on the screen. Yet take special note of line 3010. This is a flag I used to RETURN the program if the monster is not present on the screen standing before our player. When the monster is in view, the program will jump to line 3015 to show the monster’s strength.

We return to our new line at 57 since we reached a RETURN at line 3100. Let’s examine this by going to line 6030.

57 GOSUB 6030:REM ARRIVED AT

The new lines for our subroutine are listed here.

6030 PRINT”YOU HAVE ARRIVED AT A “EN$(EN)
6035 IFMP<1THENRETURN
6040 PRINT:PRINT”{cyan}SUDDENLY YOU SEE A “MO$(MN)
6045 MT$=MO$(MN)
6060 PRINT”IT POSSESSES”MS”STRENGTH.”
6100 RETURN

Upon observation of these lines, we show the location we are at in line 6030 regarding the C64 Gaming Marathon. Then we check if a monster has arrived by reviewing a flag called MP on line 6035. If no monster has entered our space then the program will be sent back with a RETURN.

Otherwise, line 6040 takes over. So if we see an ORC then it display, ‘SUDDENLY YOU SEE A ORC’. Line 6045 record our threat meter for the monster seen on the screen. This will be inserted into the threat meter so we can see the monster that is attacking us.

Then we see the monster’s strength at line 6060. Finally the program is sent back to it’s destination since it received the instruction to RETURN.

Let’s write out the new lines below as usual.

60 INPUTCM$:BA$=LEFT$(CM$,3)
1000 IFBA$<>”FIG”THEN1150
1010 MA=100+INT(RND(0)*8)
1020 DM=10+INT(RND(0)*100)
1030 DA=100+INT(RND(0)*50)
1035 IFMS<1THENMS=1100 1038 IFDA>100ANDDA<115THENBL=4 1040 IFDA>114ANDDA<=140THENBL=1 1045 IFDA>141ANDDA<=165THENBL=3 1050 IFDA>165ANDDA<=200THENBL=2
1060 HD=10+INT(RND(0)*100)

Line 60 will wait for the user to type something at the command prompt (also known as the parser). The variable BA$ will read only the first three letters starting at the LEFT going to the right and store the data for later.

After this a condition at line 1000 checks the variable BA$ to see if the user entered the command “FIG” (short for ‘FIGHT’). If the value was not found then it skips over the lines below and goes to line 1150.

For now let’s assume the the user typed the correct command in our C64 Gaming Marathon example. Several variables, MA, DM, DA, and HD are being stored in the following lines above. MA stands for Monster attack and will deduct health from the monster when we have struck it successfully with our weapon.

The next variable called DM keeps track of damage incurred.

A variable setup called DA is used to record the damage you inflicted on the monster.

Finally the variable called HD is used to subtract points when a monster successfully attacks you.

Conditional statements

The lines between 1035-1050 are used to represent a condition. This occurs whenever the program needs to make a decision.

Line 1035 checks if the monster’s strength is less than 1 and restores it to 1100. This is necessary since at the beginning the monster’s strength is zero (MS=0). So when we are ready to attack a monster, it starts with a strength of 1100.

Lines 1038-1050 are simply checking for the damage the monster received from your attack. This also is used to manage flags for the blows (BL) incurred, much later in the program. Let’s examine the next lines.

1070 POKE646,8
1090 GOSUB6040:PRINT”{cyan}YOU DRAW YOUR SWORD AND PREPARE TO FIGHT!”

Commodore 64 Damage Conditions

Our C64 Gaming Marathon program has just been informed to change the screen color to orange and jump to line 6040 which we examined earlier to keep track of the monster approaching the player. Then it prints a short message for the player. Time to check out the new lines.

1100 IFBL=1THENPRINT:PRINT “THE “MO$(MN)” HAS RECEIVED”DA”IN DAMAGE.”:MS=MS-MA
1105 IFBL=2THENPRINT:PRINT”THE “MO$(MN)” MISSED…”
1110 IFBL=3THENPRINT:PRINT “YOU HAVE BEEN HIT. THE DAMAGE IS”HD”.”:HS=HS-HD-MN+2
1115 IFBL=4THENPRINT:PRINT”YOU MISSED…”
1120 GOSUB4000:BL=0

So if you recall the variable BL for blow earlier we are now utilizing it in lines 1100-1115. The blows are tracking whether or not we struck the monster, missed, watched the monster missed their swing, or if we took a nasty blow from the monster.

Each condition tracks the variables MS (monster) and HS (human – player) to remove points when a hit has been inflicted. Line 1110 if used to remove extra health from the player depending on the type of monster the player is up against. This makes for more interesting and challenging game.

Now we going to jump to line 4000 with our GOSUB at line 1120. The lines below are just checking to see if we pressed the space bar. The CHR$(32) represents the character for the sapce bar. If we did not then the C64 Gaming Marathon program will halt until we have satisfied this request. Then it will RETURN back where it came from.

4000 GETKY$:IFKY$<>CHR$(32)THEN4000
4010 RETURN

After we have returned to line 1120 the variable for BL is set to zero. This is clearing the blows received and misses to reset for a new monster.

Check for Commodore 64 Game Over

The next lines in sequence are used to show what happens if the player’s health drops to zero or below, which will end the game simply for now.

1125 IFHS>0THEN1140
1130 PRINT:PRINT”MISSION IS LOST. YOU HAVE BEEN KILLED.”
1132 PRINT:INPUT”PLAY AGAIN Y/N”;PL$
1135 IFPL$=”YES”THENCLR:GOTO30
1138 END

The lines above check if the player’s health is above zero and will skip over this section if that equates to true. Otherwise the ending game message is seen and the Basic program waits for the user to type YES to continue, or otherwise it will exit the program.

Let’s see our new lines now.

5000 PRINT”THE “MO$(MN)” IS KILLED.”
5010 EX=EX+HD:HS=600+EX*2*LV
5012 REM INCREASE LEVEL ENTRY SK+4
5015 SK=SK+1:IFSK/4=INT(SK/4)THENLV=LV+1
5020 HD=0:MS=0:MT$=”NONE”
5030 GD=GD+10*EX
5035 PRINT”YOU RECEIVED”GD”GOLD COINS.”
5040 GOSUB2204

(Explains lines 5000-5040)

Check if we are still alive

1140 IFMS<1THENPRINT:GOSUB5000
1150 IFBA$<>”EAS”THEN2190
1160 MP=MP+1
2190 GOTO55

Get Connected!
Come and join our community. Expand your network and get to know new people!
No posts found.
No posts found.