BASIC course episode 9: MSX BASIC

Read in: IT 🇮🇹   EN 🇺🇸

In questa puntata del video corso sul linguaggio BASIC dei retro computer, introduciamo l'MSX BASIC. E' un linguaggio potentissimo, con tanti comandi. Nello stesso video, vediamo come salvare e caricare il programma in BASIC su nastro.

Subscribe my YouTube channel ValorosoIT. Retro technology, vintage audio, retro computers, experiments and tests. Retroprogramming, Basic. Commodore, IBM, Atari, Apple, Texas Instruments, Amstrad, MSX.

Non avete un computer MSX? Provate l'emulatore!

Se non possedete un computer MSX, ma volete ugualmente provare a programmare in BASIC con l'MSX BASIC, è possibile scaricare gratuitamente, cercandolo su internet, l'emulatore fMSX. Lo so, non è la stessa cosa che possedere un vero computer MSX! Nel video, vediamo in funzione il computer Philips VG 8020, ma il programma può essere realizzato su qualsiasi computer MSX.

Vintage computer MSX Philips VG 8020, recorder NMS 1520, BASIC, MSX BASIC version 1.0, Copyright 1983 by Microsoft, 28815 bytes free, Ok

Se non possedete il computer vintage, tramite l'emulatore fMSX, da installare su PC Windows (ci sono emulatori anche per gli altri sistemi operativi), è possibile caricare giochi e programmi MSX su un computer moderno!

Emulator for MSX computers on Windows PC, fMSX, Philips Phonola BASIC, load save CAS STA PAL CHT FNT MIDI

We draw a circle, calculate area and circumference, with MSX BASIC

Il programma che analizziamo consente di capire immediatamente le enormi capacità dell'MSX BASIC. Con pochissimi comandi, tracciamo a monitor un cerchio e calcoliamo l'area e il perimetro.

BASIC course, Basic program listing, circle drawing, area, circumference

The program listing consists of just a few lines of code. In total there are only 8.

10 INPUT "R";R
20 SCREEN 2
30 CIRCLE (128,96),R
40 IF INKEY$="" THEN GOTO 40
50 SCREEN 0
60 PRINT "R=" R
70 PRINT "A=" 3.1415*R^2
80 PRINT "C=" 2*3.1415*R

We have already deepened the instructions INPUT and PRINT in the first episode of the BASIC language course.

On line 10, the computer asks for the radius of the circle and inserts it into the variable R. The number R must be an integer, greater than 0 and less than 100, otherwise the circle is not drawn, or it would be too large to be displayed on the monitor.

Come esercizio, potete creare voi una riga 15, dove includete un controllo per evitare che l'utente inserisca un raggio inferiore a 0 oppure superiore a 100. Per farlo, potete prendere spunto nella second episode del corso sul linguaggio BASIC, studiando l'istruzione condizionale IF... THEN.

Alla riga 20, con l'istruzione SCREEN 2, we enter graphic mode.

Follow me on Instagram channel. Retro technology, Commodore, vintage audio, retro computers, experiments and tests. Retroprogramming, Basic. Commodore, IBM, Atari, Apple, Texas Instruments, Amstrad, MSX.

We draw a circle by:

CIRCLE (X,Y),R

The center of the circle is located at coordinates 128, 96, about halfway through the screen, both horizontally and vertically. The circle has radius R.

Draw a Circle with MSX BASIC CIRCLE command

At line 40, the computer waits until a key is pressed on the keyboard. Inkey $ represents the key pressed on the keyboard. If you don't press anything, Inkey $ is empty, i.e. INKEY$="" (it is equal to nothing). If you press a key, Inkey $ contains the corresponding character, so INKEY$<>"" (it's different from nothing).

At line 50, we return to text mode, exiting the graphics and erasing the previously drawn circle.

From line 60 to 80, we write:

  • the radius of the circle, R
  • l'area del cerchio A = pi_greco * R^2 (pi_greco * R * R)
  • the circumference C = 2 * Pi * R

Pi is approximated to 3.1415.

Calculating Circle Area and Circumference with MSX BASIC

Avete visto com'è potente il linguaggio di programmazione MSX BASIC?

Saving and Loading the MSX BASIC Program to Tape

We continue the programming course on the MSX BASIC language with the saving and loading of the program on tape. There are several commands to save and load a program in BASIC on tape. We use SAVE and LOAD.

To save the program to tape:

SAVE "CAS:file_name"

Substituting file_name the name of the file we want to assign to the program.

Saving Program in MSX BASIC, SAVE CAS on tape cassette

Press simultaneously SAVE and START/LOAD on the recorder. Next, to start saving, press RETURN on the computer keyboard, after writing the command SAVE, as previously specified.

Obviously, the tape must be positioned correctly, at the location where you want to save the program.

Follow me on Instagram channel. Retro technology, Commodore, vintage audio, retro computers, experiments and tests. Retroprogramming, Basic. Commodore, IBM, Atari, Apple, Texas Instruments, Amstrad, MSX.

To load a program from tape, you use the command:

LOAD "CAS:"
Loading MSX BASIC program, CAS load, Philips NMS 1520 tape cassette

Before you press RETURN to start loading, make sure to place the tape at the correct position and press START/LOAD on the recorder.

If all goes well (hopefully!), first the computer finds the file and writes the name to the screen.

Poi l'MSX carica il programma.

Course programming language BASIC, MSX BASIC, program listing

Interested in vintage computers? Subscribe to the YouTube channel!

Subscribe my YouTube channel ValorosoIT. Retro technology, vintage audio, retro computers, experiments and tests. Retroprogramming, Basic. Commodore, IBM, Atari, Apple, Texas Instruments, Amstrad, MSX.

Posted in Retro Computer, Retro Technology and Vintage Electronics, All articles.

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *