AgonConsole8 / agon-vdp

Official Firmware for the Agon Console8: ESP32 VDP
MIT License
40 stars 17 forks source link

Enhanced terminal mode keyboard (VDP protocol) support #223

Open stevesims opened 4 months ago

stevesims commented 4 months ago

Currently the command to turn on the terminal mode is binary - you can turn on terminal mode. From that point on, the VDP assumes that the program running on the eZ80 is an application expecting the VDP to work as a pure terminal device and thus essentially stops all normal VDP operation. From that point on, keyboard info is no longer sent back to the eZ80 using the VDP protocol but instead is captured on the VDP and ASCII bytes sent over to the eZ80.

It would be useful to allow for a different mode of operation for the terminal where the VDP protocol is allowed to continue, and for keyboard input (and other information, such as mouse data packets) to be sent.

It is suggested that the "enable terminal mode" command, which currently works as a "binary" on/off could accept different "enable" values to allow for the VDP protocol to continue operating. This would allow for instance a BASIC program to use terminal mode for its output, but still allow its INPUT and GET$ keywords to operate.

stevesims commented 3 months ago

upon investigation this idea has several problems associated with it

the terminal emulator inside vdp-gl has its own keyboard handling - some of this may need some de-coupling. further investigation would be needed to work out exactly how the terminal emulator's keyboard handling may interact with the rest of the system.

as for allowing BASIC's INPUT keyword to work, it makes use of the MOS line editor, and that not only relies on the MOS VDP protocol's keyboard information packets to be sent, it will also perform other VDU commands to facilitate its operation. as the VDU command processing isn't enabled, this doesn't work. using INPUT from BASIC results in a spurious character being made visible on-screen, and the input will not work as expected

testing shows that GET$ also does not work

experimenting shows that the interaction for keyboard handling and the terminal mode is complex. the existing support for suspending the terminal is done such that it just stops forwarding bytes from the eZ80 to the terminal emulator, and instead allow the VDP to process commands - VDP protocol keyboard handling is explicitly not properly resumed. attempting to do so does not work - a BASIC program that enables terminal mode, prints some things out, and then suspends the terminal and attempts to perform an INPUT does not get all the key-presses.

the manner in which agon-vdp uses the Terminal is slightly odd - it connects the serial port to the terminal, but then also does its own out-of-bounds serial comms, including its own keyboard handling, which presumably replicates at least some of the internal behaviour of the terminal. when the serial channel is not connected to the terminal, suspending the terminal from a BASIC program does allow the INPUT statement to work correctly