- abydos

ANSI graphics

ANSI art is an art form that became popular through DOS based BBSes. ANSI referes to the ANSI (American National Standards Institute) standard X3.64 which specifies control sequenses for changing color and moving the cursor. Specifically the DOS ansi.sys dialect (see below). It uses, IBM code page 437, and assumes rendering on VGA text modeexternal link using the CGA paletteexternal link.

The CGA palette.

The files often have a SAUCE tag which might contains additional information about the way the file should be rendered.

Rendering

Displaying ANSI art is not as easy as it would seem. Doing it correctrly requires a little bit of hardware emulation. Something that many viewer applications overlook in their way of rendering ANSI art.

The Naive Way

The screen is 80 characters wide and 25 high. Each character is 8 pixels wide and 16 pixels high. That should give and image 640 pixels wide and 400 pixels high. Knowing it's intended for 4:3 monitor it gives a pixel aspect ratio of 5:6, which might be considered close enough to square pixels. However this misses an important feature of the VGA text mode. Each row of characters are rendered with a one pixel space between them. Supposedly to increase readablility, but it alsa enabled a certain effect used by many ANSI artists. If the file has a SAUCE tag it may contain a setting to disable this feature.

The Semi-Naive Way

Taking the space between the characters into acount however will give a pixel perfect image, effectively 720 pixels wide. The problem now is thet the pixel aspect ratio becomes 20/27, which is quite far from square pixels. Some artists these days draws this way (because with most software there is no other option on modern hardware). It also gives wider images, closer to an HD aspect ratio. If the file has a SAUCE tag it may contain a setting to assume square pixels.

Special Font

A good solution is using a special font with 8x18 pixels. Either by just repeating two selected rows of each character, or better yet, use a specially crafted font. That gives an effective resolution of 720x450 and again a pixel aspect ratio of 5:6. It generally looks very for the usual blocks graphics. But for some characters it's not as easy to come up with a stretched out version that doesn't look weird.

Scaling

The other option, which is utilized by abydos, is scaling the image to a perfect aspect ratio. Of course it has the downside of making the pixels slightly blurred. But the higher the resulution the less visible it becomes. With a high enough resolution (as least 14400x10800 to be exact) it would be possible to view pixel perfect ANSI art with perfect aspect ratio.

Blinking

By default the hardware only uses 3 bits for for the background color (meaning only half of the palette can be used), the forth bit is used for foreground color blinking. This can be turned off in hardware. In this case the blink attribute is instead used to enable a full set of 16 background colors to choose from, which is refered to as ICE color. If the file has a sauce tag it will be consulted regarding the desired setting.

The blinking rate is dependant on the monitor refresh rate. Currently there is no way to influence which refresh rate to emulate so abydos always emulates the blink rate of a 60Hz monitor.

Interpretation

ANSI art is encoded to be interpreted by DOS ansi.sys. This is slightly different from how usual terminals and terminal emulators interpret the control sequences. For example clear screen also homes the cursor (which it doesn't for most implementations). And most importantly, then the line is full ansi.sys moves the cursor to the beginning of the next line (scrolling the screen if neccessary), which isn't the case for most implementation. These are reasons it doesn't work to pipe ANSI art through iconv to a normal (actually ANSI compatible) terminal.

The BBS software PCBoardexternal link tried to be more compatible and used a hack to counter this problem. It simply left out the last character on every line (effectively making the screen just 79 characters wide) to eliminate the ambiguity. Since this had the effect of ANSI art being cropped, the popular program ACID Draw uses a counter hack in all files it creates. By using ANSI codes for moving the cursor around, it fools PC Board from detecting the actual line width (and again made it dependant on ansi.sys compatible terminals).

Read more about ANSI art on Wikipediaexternal link.

Alternative formats

Avatar/0

An equivalent but more compact encoding. Has a few codes ... scrolling the screen left and right. It could be used for some fancy animation, but I have never seen it ih the wild.

There is also a level 1 one the Avatar standard which supports overlaying frames. But it's of more use for interactive terminals than for encoding graphics.

Binary text (BIN)

Raw dump of the text screen memory (b800:0000). The format is often used for storing images wider than the actual screen. But since the format just contains a raw dump, the width cannot not always be easily determined. It's only reliable to tell if the file has a SAUCE tag.

XBIN

XBINexternal link is like BIN but with added information. It can contain an altered palette and an altered font.

This is what a rendition looks like with the current version of abydos.

snisurset.netContact the author.

Last edited Wed, 10 Apr 2019 01:01:09