Welcome to Commodore 64 Basic Playground!

The Commodore 64 Basic Playground series continues with this article. We will continue to enhance the program we were working on earlier last week, which involved a simple store that accepted data from an INPUT statement.

However this week we are going to take a few jumps forward. Stay with it as it may seem intense, but the idea is to help you get more commands under your belt, while working on a somewhat quality program. In time it will get better. Soon you will follow along as if reading a book. I’m confident in that!

In the last video, we setup a loop to show the results of an item total after that are purchased at the INPUT prompt each time. However, the program I found in VICE appeared to be incorrect. It was not providing an correct totals and showing the first transaction of a deduction from the total balance account of 1 million dollars from our Alien commander.

As  a member of the Commodore 64 Basic Playground, you will have direct access to the files that are being presented each week, along with other informative articles. I appreciate your subscription to c64brain.com!

Feel free to reach out and contact me from either the Contact page or using the Chat message at the bottom. Please allow around 24-48 hours for a response.

Listed below are the files for this week, including the files from Part One and Part Two.

Enhancing the Commodore 64 Basic program

One of the first goals I wanted to achieve tonight was setting up options that could be selected among the choices of Blood, Human, and Bugs. This new feature in the Commodore 64 Basic Playground series will allow us to make a selection and perform some action with it. Type in the new line below.

112 CV$=VAL(BU$)

This line returns the numeric value of the characters in the string CV$. The reason for this conversion is so we can translate the string BU$ to be used as a number, since essentially BU$ is not currently setup to be used with math.

The next thing to do was to remove line 130 which essentially was initializing the value of DO to 1000000 (which represents the million dollars are Alien currently has in the bank). When left this way, the program will always reset DO back to 1000000 and we could not do any deductions with it other than just one time only.

So type in the new line below since we are relocating it

44 PN=2000:HU=20000:BU=5:DO=1000000

Now let’s look at the new program with the new changes added.

10 REM BASIC PLAYGROUND 2
20 :
30 PRINTCHR$(147)
40 POKE53280,2:POKE53281,0
42 DIMTB(3),AC(100)
44 PN=2000:HU=20000:BU=5:DO=1000000
50 PRINT: POKE 646,7
60 PRINT”MOSQUITOS R US”
70 PRINT
75 POKE646,13
80 PRINT”BLOOD”,PN
90 PRINT”HUMAN”,HU
100 PRINT”BUGS”,BU
110 INPUT”WHAT DID YOU WANT TO BUY TODAY”;BU$
112 CV=VAL(BU$)
120 PRINT
140 CT=DO-CV
142 AC(TT)=CT
144 TT=TT+1
150 REM REMAINING CHANGE
160 PRINT”YOU MONEY LEFT IS”;CT
162 PRINT
163 FORL=1TO3
164 PRINT”TODAY YOU PURCHASED “;AC(LL)
166 NEXT
170 FORDL=1TO2000:NEXT
180 PRINTCHR$(147):GOTO60

Next I decided to relocate the totals at line 144 to line 167. First remove line 144. Then add the new line below.

167 TT=TT+1

Debugging the Program

So now we will get our hands dirty and working on an error in our logic1. Now keep in mind that the program is not stopping on us (known as a crash), but rather it is not doing what we need it to do. However, it is not giving the correct totals.

When it is working perfectly with the Commodore 64 Basic Playground, it will add any value selected from the INPUT prompt, such as 2000, 20000, or the 5. Then this value will be added to our array AC(TT). Finally we increment the value in the array to point to our new one. This will allow us to save each array in sequence. Here is a visual example:

AC(0) = 2000
AC(1) = 5
AC(2) = 20000

Discovering the Answer

The solution discovered was to decrease the value each time from our account instead of storing the CT variable at line to subtract one time only. Append to line 140 our new change.

140 CT=DO-CV:DO=DO-CV

The results are finally being deducted from the main balance variable of DO and being placed into the array pockets to be used for later.

Building a Checking Account

Now I wanted to create a bank account system that simulates a live, online banking account as known in the real world. Type in the new lines below.

800 REM ALIEN’S BANK ACCOUNT
810 PRINTCHR$(147)
820 PRINT”{control a}{36 – shift c}{shift b}”
830 PRINT”{shift b} CHECKING NAME: BIG BAD BOSS ALIEN{2 spaces}{shift b}”
840 PRINT”{control a}{36 – shift c}{shift b}”
850 PRINT”{shift b} {reverse on}LOGOUT{reverse off}{13 spaces}{14 spaces}{shift b}”
860 PRINT”{shift b}{23 shift q}{space}{12 shift q}”
870 PRINT”{shift b}{23 minus}{space}{12 minus}”
880 PRINT”{shift b}{21 spaces}{14 spaces}{shift b}”
890 PRINT”{shift b}{36 shift c}{shift b}”

Working on the Display

Next I wanted to get an idea of what the account screen would look like so I created the code below (as seen in the screenshot).

1000 REM 1. BLOOD
1010 IT$(TT)=”BLOOD PUR”
1020 AC(TT)=DO-2000
1030 TT=TT+1
1040 RETURN

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