SCMonitor has a nice table in RAM to patch in extension to various system routines; it is the "kJumpTab" based in RAM starting from 0xFE00. It is a collection of jumps to internal routines among them is JpConOut at 0xFE1B. So to patch in VGA extension for console output, it is a matter of saving where JpConOut jumped to and replace with VGA routine that jumps to the original JpConOut after VGA output is done.
The attached code shows the VGA output extension. It first clears the screen, installs font tables, and replace the original JpConOut destination with VGA extension. In principle, VGA routine manages a cursor and outputs whatever data meant for serial port out to screen as pointed by the cursor and then return the program back to the original JpConOut so the serial data is also displayed on the terminal console. Simple, huh?
Well, the devil is always in the detail; the VGA extension needs to deal with certain functions that's automatically done in VT52 terminal such as cursor, carriage return, line feed, and scrolling. These are just the basic functions, there are escape sequences that are above and beyond my simple VGA extension. And one more problem: VGARC is only 64-character wide, what to do with a line of more than 64 characters?
Currently my solution is this:
* Cursor is a inverse video of the space character. <-- I think inverse video of existing character may be better solution, it is something to work on.
* Carriage return moves cursor to beginning of a line, but don't write out the cursor symbol so not to erase the first character of a line when the subsequent linefeed is executed.
* Linefeed moves the cursor vertical down one line. However, if cursor is already at the bottom line, this will cause screen to scroll.
* Scrolling is done with the hardware scroll register followed by blanking out the bottom-most line. I struggled with the algorithm because it is...strange...but it is working, but I can see myself looking at it a year from now and wonder what I was thinking?
* How to fit 80-column line in 64-column? Right now I'm just trucating the character after 64th. I suppose I should provide an option to wrap the extra characters to next line and have to deal with scrolling again.
Pic is the VGA monitor displays SCMonitor commands "help", "dir", "m0" and "basic". The same screen content is also displayed on my TeraTerm serial terminal except lines greater than 64 characters are not truncated. BASIC is working because it also uses the jump tables, kJumpTab, for basic I/O.
There are some minor tweaks needed, but I'm charging ahead to PS2 keyboard extension for SCMonitor.
Bill