|
Using ANSI color and cursor controls with your S-T Z80 Computer Most of you are probably using Hyperterminal in Windows for connecting your Z80 to the world, you are probably pretty well used to seeing black text against a white background. You can change this to include a little color if you like, but it requires some code to reside on your Z80. Back in the TTY data-terminal days, (there are still a few systems and applications that have these hanging on), some brilliant mind came up with the idea that if we could send some codes to the data terminal or emulating program that would be invisible to the user, changes in cursor position and colors could be sent to the VDT, and some factors about the VDT could be returned to the hosting computer. These were standardized for any data terminals or programs wishing to adhere to the new standard. These codes became part of the American National Standards Institute. In fact, many early PC's CONFIG.SYS files included the line device=ANSI.SYS without ever utilizing it's function. Eventually a few idle minds devised some interesting sequences that would turn your DOS cursor into a Texas flag, blinking this or that, and so forth, but by and large the ANSI sequences were not understood by the masses. Interestingly enough, the people who created Hyperterminal realized that some people would be using this program to dial into various old mainframes and other such electronic feldergarb, and might actually NEED these ANSI controls in order to correctly connect up. So there are settings to emulate various VT models of terminal, as well as some good old generic ANSI and ANSI/W emulations. You will need to set your program to handle ANSI if you dare wander further into this forrest. The primary entry portion of these ANSI sequences is something called the Control Sequence Introducer or CSI for short. This is a sequence of characters sent by the host to the VDT and could then be followed by other characters as needed to control things on the screen. The CSI consists of the two characters ESC ($1B) followed by a left bracket "[" ($5B). This would proceed parameters and would sometimes be followed by a terminating character, like "m" ($6D). In order to use these codes, you will need to create Z80 assembly routines that send these sequences from the Z80 to the host program. Here is the basic ANSI table of codes: These are only the primary codes, there are a large number of other ones out there; a little internet research on your part will reveal a bunch. Here is a link to some more VT / ANSI controls: Here is the test program I wrote for using these codes: IMPORTANT: If you execute a CR,LF after a color change command, and don't print any characters in the new desired color first (before the end-of-line terminators), the colors won't change from the previous setting. Here's a screen shot after the program has run: I am fumbling with the idea of incorporating these into my new monitor ROM, I think they would look a good deal better with some good colors in the mix. Just out of curiosity sake, I tried some 'undefined' color codes i.e. $39, $3A, $3B, etc. - they simply don't work, evidently no "Easter Eggs" in the software here to exploit. Just stick with the basic colors, I'm sure you'll be happy. If you have BASIC (either mine or some variant) on your Z80 board, you can use it to send the ANSI CSI and control codes as well. Good luck! Click HERE if you do not see a menu frame to the left.
All information contained herein that is generated by J.Owens ©2006. |