WinSim

This is a quick and dirty port of Udo Munk's z80pack to Windows. The original can be found here. It runs in a console window and relies upon Windows services that are only available in Windows 2000 or better, so you '98 folks won't be able to run it.

I've included binaries of the program and various utilities it relies upon, but to rebuild it from sources you will need OpenWatcom C and it needs to be unpacked alongsize z80pack-1.13, resulting in a directory structure kind of like:

--+--> z80pack-1.13
  |
  +--> WinSim --+--> winasm = port of z80asm, Udo Munk's assembler.
                |
                +--> winboot = Z80 boot code used by WinSim.
                |
                +--> winsim = Sources for WinSim
                |
                +--> winutils = Miscellaneous utilities.
                |
                +--> disks = some disk images

as the build procedures go spelunking in the z80pack-1.13 to find the sources to z80pack.

To rebuild WinSim from the sources, unpack it next to a distribution of z80pack-1.13 and execute the BUILD.BAT command procedure in the WinSim directory.


I/O DEVICES

At the moment, support is limited to a console terminal and disks. The disk controller code is lifted directly from Udo Monk's source code, so it works the same as vanilla z80pack. It is capable of running CP/M 2 using Udo Munk's BIOS, but not anything more advanced than that.

CONSOLE TERMINAL

WinSim assumes it is running in a console window. It resizes that window to 80x24 and offers some simple cursor control sequences to allow a CP/M program to manipulate the screen. It does not emulate anything; the sequences were entirely made up by me. Most CP/M programs are flexible enough to run with a variety of terminals, so this shouldn't be a problem. The control sequences are a mix of the original ones I pulled out of my nether regions, VT-52 sequences, enough H-19 sequences to handle WordStar 4.0, and a couple of miscellaneous sequences I've encountered over the years.

The cursor no longer wraps when it goes off the right edge of the window. This is for compatibility with the VT-52 and H19, which also do not wrap.

The following table describes the implemented display control sequences. the ones marked as being sourced by "Unique" are the ones I pulled out of my nethers.

SequenceSourceSummary
^A x y Unique Move the cursor to colum x, row y. The coordinates are given in binary with no offset. The leftmost edge of the window is column 0. The top of the window is row zero. Consquently, the cursor can be moved to the home position using ^A ^@ ^@.
^B Unique Clear from the current cursor position to the end of the the current line. The character under the cursor is cleared.
^C Unique Clear from the current cursor position to the end of the window. The character under the cursor is cleared.
^H VT-52 Move the cursor one space to the right. If the cursor is at the left edge of the window, it is not moved.
^J VT-52 Move the cursor down one line. If the cursor is on the bottom line of the window, the contents of the window are scrolled up.
^M VT-52 Move the cursor to the beginning of the current line.
^N Unique Display subsequent characters in normal video. Normal video is the display attributes that were in effect when WinSim was started.
^O Unique Display subsequent characters in reverse video. Reverse video involves swapping the foreground and background colors in the display attributes that were in effect when WinSim was started.
ESC A VT-52 Move the cursor up one line. If the cursor is at the top of the window, it is not moved.
ESC B VT-52 Move the cursor down one line. If the cursor is at the bottom of the window, it is not moved.
ESC C VT-52 Move the cursor right one position. If the cursor is at the right edge of the window, it is not moved.
ESC D VT-52 Move the cursor left one position. If the cursor is at the left edge of the window, it is not moved.
ESC H VT-52 Home the cursor. The cursor is moved to the top left position in the window.
ESC I VT-52 Reverse index. The cursor is moved up one line. If the cursor is at the top of the window, the window is scrolled down one line. The top line is filled with normal video spaces, where "normal video" means the video attributes in effect when WinSim was started.
ESC J VT-52 Clear to end of screen. Characters are cleared from the current cursor position to the end of the window. The character under the cursor is cleared.
ESC K VT-52 Clear to end of line. Characters are cleared from the current cursor position to the end of the line. The character under the cursor is cleared.
ESC L H19 Insert line. The portion of the screen from the current line to the end of the window is scrolled down. The current line is filled with normal video blanks, where "normal video" means the video attributes in effect when WinSim was started. The cursor is moved to the beginning of the current (freshly blanked) line.
ESC M H19 Delete line. The line containing the cursor is deleted; the portion of the screen below the cursor is scrolled up one line. The bottom line of the window is filled with normal video blanks, where "normal video" means the video attributes in effect when WinSim was started. The cursor is moved to the beginning of the line.

The H19 manual does not specify what happens to the cursor position when a line is deleted and I do not have an H19 available to try it out on. I suspect that the H19 does not move the cursor, so this may be a difference between WinSim and the H19.

ESC T Unique Reverse video. Subsequent characters are displayed in reverse video, where "reverse video" involves swapping the foreground and background colors of the video attributes that were in effect when WinSim was started.

RT-11 K52 uses this escape sequence for highlighting. I discovered this back when PC-DOS KERMIT's VT-52 emulation was not very good. I actually don't know whether K52 expects highlighting to start or end when this sequence is sent. Since an actual VT-52 cannot highlight, it ignores this sequence.

ESC U Unique Normal video. Subsequent characters are displayed in normal video, where "normal video" means the video attributes that were in effect when WinSim was started.

RT-11 K52 uses this escape sequence for highlighting. I discovered this back when PC-DOS KERMIT's VT-52 emulation was not very good. I actually don't know whether K52 expects highlighting to start or end when this sequence is sent. Since an actual VT-52 cannot highlight, it ignores this sequence.

ESC Y col+32 row+32 VT-52 Cursor addressing. The cursor is moved to the specified column and row.

When calculating the cursor position, WinSim subtracts the 32 modulo 256; a col+32 byte of zero therefore refers to column 223 rather than column -32.

If a coordinate is beyond the edge of the screen, the cursor is not moved in that axis. Movement still occurs in the other axis, if that coordinate is within range. RT-11 K52 relies upon this behavior, a fact I discovered back when PC-DOS KERMIT's VT-52 emulation wasn't very good.

ESC Z VT-52 Identify. WinSim returns the character sequence ESC / K in order to claim to be a VT-52 without a copier.
ESC a Unique Interrogate video attributes. WinSim returns an escape sequence of the form ESC b attributes, where attributes describes the colors currently in use for displaying characters. See ESC b for a description of the attributes byte.
ESC b attributes Unique Set video attributes. Subsequent characters will be displayed using the foreground and background colors indicated by attributes. This byte has the following format:
 7 6 5 4 3 2 1 0
+-+-+-+-+-+-+-+-+
| | | | | | | | |
+-+-+-+-+-+-+-+-+
 ^ ^ ^ ^ ^ ^ ^ ^
 | | | | | | | |
 | | | | | | | +-- Foreground Blue
 | | | | | | +-- Foreground Green
 | | | | | +-- Foreground Red
 | | | | +-- Foreground Intensity
 | | | +-- Background Blue
 | | +-- Background Green
 | +-- Background Red
 +-- Background Intensity

Where a bit is set to indicate that its associated attribute should be included in the displayed character.

This escape sequence does not change WinSim's idea of "normal" and "reverse" video. Normal video is always the display attributes that were in effect when WinSim was started. Reverse video always swaps the foreground and background colors of normal video.

ESC c Unique Report size of console window. Returns an escape sequence of the form ESC Y col+32 row+32 that moves the cursor to the bottom left corner of the window.

Note that the 32 should be subtracted modulo 256; a col+32 byte of 0 refers to column 223 rather than column -32.

ESC d col+32 row+32 Unique Resize console window. The size of the console window is resized such that the given coordinates will be those of the bottom left character in the window.

WinSim calculates the size of the window by subtracting the 32 modulo 256. That is, ESC d ^@ ^@ will attempt to resize the window to 223x223 rather than -32x-32.

ESC p H19 Reverse video. Subsequent characters are displayed in reverse video, where "reverse video" involves swapping the foreground and background colors of the video attributes that were in effect when WinSim was started.
ESC q H19 Normal video. Subsequent characters are displayed in normal video, where "normal video" means the video attributes that were in effect when WinSim was started.
ESC z H19 Reset terminal. The console window is resized to 80x24. The cursor is moved to the top left character position. The window is cleared. Subsequent characters will be displayed in normal video, where "normal video" means the video attributes that were in effect when WinSim was started.

WinSim provides no support for alternate keypad mode. However, the arrow keys do send the escape sequences sent by a VT-52; this is required for proper operation of programs such as Multiplan and Supercalc.

Special keys other than the arrow keys are not processed by WinSim; the key codes are sent directly to CP/M. OpenWatcom deals with these keys by sending a two-character sequence consisting of a NUL followed by a character indicating which key was hit. With the exception of the arrow keys, these sequences are passed on to CP/M.

DISKS

The disk controller code is stolen directly from Udo Munk's source code. It expects to find at least one file, /disks/drivea.cpm, that is to be used for CP/M drive A. That drive is expected to be an image of an 8" SSSD diskette.

I've supplied a few disk images for you to play with. The stuff on these disks either came from Udo Munk's distribution or from Retroarchive. Each disk contains a system image extracted from Udo Munk's archive. The disks are:

PRINTER

Not supported. The I/O ports exist to keep Udo Munk's BIOS happy, but they don't do anything.

READER

Not supported. The I/O ports exist to keep Udo Munk's BIOS happy, but they don't do anything.

PUNCH

Not supported. The I/O ports exist to keep Udo Munk's BIOS happy, but they don't do anything.


UPDATE 2007-05-12

This version adds VT-52 emulation sprinkled with enough H19 emulation to run WordStar 4.0. I've added disk images containing Multiplan and SuperCalc installed for the VT-52.


UPDATE 2007-04-23

In this version, I've reworked the build files to compile with signed chars. This is the /j option to the Watcom compiler.

I've also fixed an oops in the WordStar 3 terminal name patch that caused it to display ERROR in the middle of the terminal name string.

This version only supports my initial set of console controls. They are:


[home] [e-mail]