MSX BASIC – MSX key table

da | Nov 20, 2023 | MSX BASIC | 0 comments

“MSX BASIC” COLUMN by Orazio Cacciola (bonus)

MSX key table

I insert the table in the explanation to make it better understood.

It is a matrix table that starts from the address &HFBE5 up to &HFBEF i.e. 11X8, but in some bits there are 2 keys inserted so we can say that it could be an 11×16. To get the second entry of the key where it is shown, you must add the appropriate key to execute it. 
To make you understand better, if we want to use the F1 key just press it, but if we instead want to use the F6 key we must combine the SHIFT + F1 keys.
To do this we call the address where the key is shown and set the bit used to zero. The bits go from 0 to 7 starting from right to left. We always take into consideration the F1 key located at the address &HFBEB in the fifth bit. First of all we create a variable and to make everything easier we use binary numbers: A=&B11011111, we set the 5th bit to zero, which is the F1 key, then using PEEK to read the location concerned we compare it with the variable, if the button is pressed they will be the same.
I'll give you an example of a small program to help you understand better:

10 SCREEN 0: KEYOFF: DEFINT AZ
20 A=&B11011111: IF(PEEK(&HFBEB)OR A)=A THEN PRINT "F1"
30 A=&B11111101: IF(PEEK(&HFBEB)OR A)=A THEN PRINT "CTRL"
40 A=&B01111111: IF(PEEK(&HFBEC)OR A)=A THEN PRINT "ENTER"
50 A=&B11111011: IF(PEEK(&HFBEC)OR A)=A THEN PRINT "ESC": END
60 GOTO 20

Try it and you will see that by pressing the keys used it will print them on the screen, while ESC will close the program as well as printing it.
If instead we want to use the second bit of the matrix address we will do this:

10 SCREEN 0: KEYOFF: DEFINT AZ
20 A=&B11011111:B=&B11111110: IF(PEEK(&HFBEB)OR A)=A AND
(PEEK(&HFBEB)OR B)=B
THEN PRINT "F6"
30 GOTO 20

Let's check the pressure of the 2 keys at the same time, if this is true it will print the sentence F6, if not the program will run infinitely
without printing anything.
I tried to simplify by making the explanation very simple.

Let me know if anything is unclear

0 Comments

Submit a Comment

Your email address will not be published. I campi obbligatori sono contrassegnati *

LEZIONE 26 – INTERVAL ON, RND ED ALTRI

LESSON 26 – INTERVAL ON, RND AND OTHERS

Good morning everyone, In this episode I will talk about an important interrupt, especially for games, when we want to make an enemy suddenly appear or a useful object, but also to create a stopwatch or a clock and many other things. The COMMAND exploits the...

LEZIONE 26 – INTERVAL ON, RND ED ALTRI

LESSON 24 – THE DATA MANAGED BY THE MSX (PART 3)

Kind regards to everyone. Today we will close this topic, I will talk about direct or random access files. But first, as I mentioned in the last episode, I will give a small explanation about the program. First of all, the first thing to say is that I used a command which...