An attempt to cobble together a console text stream from VGA text screen grabs #1392
chschnell
started this conversation in
Show and tell
Replies: 1 comment
-
I've moved this script to repository Changes:
VGA text capturing now fails in only two cases:
Both cases can be worked around, the first for example by using Other than that, it's working nicely now! The script still expects to find |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
My slightly wacky goal here is to connect text-based guest OSes directly to the local terminal without using a serial connection, yet it should behave like a serial connection as closely as possible.
It's a hack with a lot of assumptions, but so far it works well enough for a quick Show & Tell. Here's a demo where I boot up FreeDOS 1.4 interactively from a Linux console:
putty_vga_console.mp4
Note the green cursor is the terminal's cursor. Since it all goes a bit fast, my interactions in this demo after starting the demo
vga_console.js
are:dir\n
type fdauto.bat\n
(actuallytype fda
+ TAB + ENTER)dir /s\n
(recursiveDIR
)vga_console.js
and scroll back in the terminal windowHere's the full content of the terminal window's scrollback buffer from the above video (useful for debugging and automation):
Full terminal window scrollback buffer
Strategy
Sending keyboard input (STDIN) to the guest is managable.
However, getting the console output from the guest in the form of a text stream (STDOUT) is a challenge, I think this can only be approximated. My approach takes two steps:
In the first step, we need a way to get stable screen grabs from the 2-dimensional VGA text buffer, that means to grab the VGA screen content only after the guest has stopped writing to it (as opposed to when it is in the middle of scrolling the screen, for example). For that I collect modifications to the VGA buffer in the background and check in short intervals for this busy-to-idle transition which is when the modifications become applied.
It's easiest to just look at the sequence of screen grabs that gets produced this way, here the full list of consecutive screen grabs from a session very similar to the one from the video above:
Sample VGA screen grabs
Now in the second step, for each pair of consecutive screen grabs we must detect and extract the new lines that were added in the newer screen grab compared to the older one. Also there is a special case where only the bottom-most line was modified which is assumed to be interactive user input and needs to be handled a bit differently. There are more details to this algorithm and it's not done yet, see below for its current source code.
Source code and FreeDOS image
The source file is a single nodejs file, it should be installed in a sibling directory to the v86 directory (or change the paths yourself).
vga_console.js
EDIT: Updated source code of
vga_console.js
, cleanup and bugfixes.The FreeDOS image file: FreeDOS14-20m-en.img.gz.
Beta Was this translation helpful? Give feedback.
All reactions