EgonOlsen71 / basicv2

A Commodore (CBM) BASIC V2 interpreter/compiler written in Java
https://egonolsen71.github.io/basicv2/
The Unlicense
84 stars 15 forks source link

INPUT BUG: Workaround with SHIFT+SPACE and Controlcodes for Cursor movement doesn't work #56

Closed viteisele closed 1 year ago

viteisele commented 1 year ago

Background: BASIC 4.0 for PET has a bug, that a program is stopped after a INPUT command without input. There exists several workarounds (see https://www.youtube.com/watch?v=M1leqcEyYT8). They are not necessary for C64, but they still works and are a good test for basic compatibility.

One possibility is to use SHIFT+TAB and Controlcodes for Cursor movement (10:02 in video). There are several problems.

Compiler: Using a PRG-Files is no problem. But is there a easy way for editing a text file, so that following control codes can be used ? CTRL-160 SHIFT+SPACE CTRL-157 CURSOR LEFT CTRL-145 CURSOR UP For a text file I used following modification of the program: 1 s$=chr$(160): l$=chr$(157): u$=chr$(145) 10 print "answer:"s$s$s$s$l$l$l$;: input a$ 20 if asc(a$)=160 then print u$;: goto 10 30 print a$

Console support (run_gui.cmd): The controlcodes works, but the evaluation with SHIFT+SPACE doesn't work

BasicShell: The controlcodes are not working. The evaluation with SHIFT+SPACE couldn't be tested because of problems with controlcodes, but probably it also doesn't work.

EgonOlsen71 commented 1 year ago

You should be able to use placeholders for those in the text file. Either by using

{shift-space} {left} and {up}

or by using the codes directly like so:

{160} {157} {145}

EgonOlsen71 commented 1 year ago

Regarding the other two parts of the issue:

Console support: Should be able to handle SHIFT+SPACE now

BasicShell: Control codes can't work in this one, because it's a Java text area in disguise and not a proper C64 console at all.

viteisele commented 1 year ago

Test console with the program: the trick is not working: when there is no inut (return without any inut is pressed), then a PET or C64 reads a SHIFT+SPACE from screen. But with console support it seems that A$ is empty in this case and there is a illegal quantity error in line 20.

Regarding BasicShell: I must admit that I don't know the text area component, but I believe you that the handling different code tables is terrible. Is changing the position in this component really so difficult ...

EgonOlsen71 commented 1 year ago

The SHIFT-SPACE hack can't work in the console, because it's just an output device. Input is read from the keyboard, not like on the C64 from the screen. So "preloading" the input value won't work.

About the text area: It's meant to be used as a compontent for the user to type/edit some text. Just like a text area on a HTML page. The fact that the shell uses it for both, input and output is already stretching it beyond what it's supposed to do. You can set the cursor programmatically, it just doesn't work in the way it's supposed to to emulate control codes. That's why CLEAR/HOME works, but HOME doesn't, for example.

viteisele commented 1 year ago

Frankly spoken I was surpised that the message came so fast, that the problem with SHIFT+SPACE is fixed. I assumed more effort and my assumption was correct.

The SHIFT+SPACE has minor priority, but the cursor movement would be nice. Perhaps you will have a good idea after you made your last integer optimization ;-)