Input char 255 from the keyboard

By Eugeny_Brychkov

Paragon (1073)

Eugeny_Brychkov's picture

13-04-2018, 02:35

Is there any specific combination(s) of keys on the keyboard in BASIC so that pressing it displays character 255 (cursor image)? The purpose is that I need to know if there's any circumstance under normal machine operation for keyboard buffer containing byte 0xff.

Login or register to post comments

By ghost_jp

Master (132)

ghost_jp's picture

13-04-2018, 03:15

I don't know it is acutually what you hoped...

KEY1, CHR$(255)

After executing this command, you can input character 255 by pushing F1 key.

By gdx

Prophet (2704)

gdx's picture

13-04-2018, 11:43

Maybe one of these two solutions:

1/ Using system variables + a escape code
POKE&HFCA9h,0 ; No cursor (when PRINT)
POKE&HFCA9h,1: POKE&HFCAAh,0 ; Full size cursor
POKE&HFCA9h,1: POKE&HFCAAh,1 ; Half size cursor
CHR$(27)+CHR$(108) -> Erase current line

For example:

10 SCREEN0:C=0
20 POKE&HFCAA,0 '1=half cursor
30 POKE&HFCA9,C '1=enable cursor display, 0=disable
40 LOCATE 1,1: PRINT CHR$(27)+CHR$(108);C;
50 IF STRIG(0) THEN C=C XOR 1: FOR I=0 TO 300: NEXT: BEEP: GOTO30
60 GOTO 50

2/ Using escape codes
CHR$(27)+CHR$(120)+CHR$(53) -> Remove the cursor
CHR$(27)+CHR$(121)+CHR$(53) -> Show the cursor

For example:

10 SCREEN0:C=121
20 LOCATE 1,1: PRINT CHR$(27)+CHR$(C)+CHR$(53);
30 IF STRIG(0) THEN C=C XOR 1: FOR I=0 TO 300: NEXT: BEEP: GOTO20
40 GOTO 30

By Pencioner

Paladin (893)

Pencioner's picture

13-04-2018, 15:53

Hmmm... those are all hacks. I'm sure Eugeny is asking if there's a regular way to have this character in keyboard buffer. If i understood correctly. And the answer then is 'no', the code 255 shouldn't get into keyboard buffer with normal usage.

By Eugeny_Brychkov

Paragon (1073)

Eugeny_Brychkov's picture

13-04-2018, 17:36

Pencioner wrote:

I'm sure Eugeny is asking if there's a regular way to have this character in keyboard buffer.

Absolutely. Let me explain. I have to somehow differentiate pressing CTRL+] combination and and cursor left key using CHGET. Even more, I need to know if CTRL was pressed during the cursor left key press.

So I came to the following solution: I set my keyboard decoder handler at HKYEA, where I check for scancode, and if I see it is 044h, I put the sequence of bytes into the keyboard buffer: first byte is 0ffh (the control byte indicating special sequence follows), second byte is just value of (FBEB) at the tine of logging (where bit 1 is state of CTRL key) and then I pass back to keyboard handler where it will convert scan code of 044h to 01dh. Therefore at the end keyboard buffer is having sequence of (for example) 0ffh, 0fdh, 01dh which means that I had arrow left and CTRL pressed.

I may have used 2 bytes only, and would prefer using only 2 bytes, using two control codes, e.g. 0ffh and 0feh, but I am afraid there's key combination to place 254 into the keyboard buffer!

Pencioner wrote:

If i understood correctly. And the answer then is 'no', the code 255 shouldn't get into keyboard buffer with normal usage.

Thank you!