I am using the AppleWin emulator, setup as an Apple IIe, Apple DOS 3.3 with Applesoft. My goal is to make a simple game.
This simple GET program works fine at the ]
prompt (I am not sure, but I think it's called the monitor).
10 GET V$
20 PRINT V$
It prints the pressed key as expected
Then I start Applesoft using LOAD APPLESOFT
. I tried writing the same simple program than at the ]
prompt. But this time when I type the first line 10 GET V$
I get as output *** SYNTAX ERR
.
I think it's not a supported feature, but in the ApplesoftII Basic Programming Reference Manual they list get a reserved keyword.
I could update to a higher version of Applesoft, then which version of Applebasic would support it? I can also use another method of getting a key press without the user needing to press enter afterwards.
After continuing to research my issue, I have found the location of memory for the keyboard buffer.
The keyboard buffer is -16384
and the way to reset that value of that address is to access -16368
.
If the value in -16384
is larger than 128 then a key has been pressed.
So, I can use PEEK -16384
to read the value. To get an ASCII code you need to subtract 128 to that value.
Example code:
KEY= PEEK(-16384)
IF KEY>=128 THEN PRINT KEY-128
To tell the system you dealt with the key press and reset the value, you need to access the value in -16368
. By using PEEK or POKE
.
Example code:
POKE -16368,0
Or can also be PEEKed
PRINT PEEK -16368