Sunday, July 21, 2019

Of Bytes and Borders

There is more to the screen than those pixels or tiles which a graphics programmer had the ability to manipulate into graphical images.  In many vintage consoles and home computers, their display hardware could sometimes display color outside the active display area.  In this blog post we will review some of these devices, try to identify the size of the borders and any special purposes to which they may have been put.

A CRT was not defined by pixel counts.  Its scanning electron raster beam did not correspond 1:1 with a particular cluster of RGB phosphors.  As the beam travels across the screen, the change in the voltage levels of the R, G and B guns would energize their respective phosphors to generate color.  A CRT scans from left to right, and at some point the guns have to turn off to allow the beam to be positioned to the next line down.  The scanline can be divided into two parts, the active display period and the horizontal blanking period.

For this discussion, we need to break down the horizontal blanking period further.  During the horizontal blanking interval (hblank), which begins after the CRT finishes drawing the line, the beam ordinarily no longer produces a visible image.  This is called the front porch.  Once the front porch is passed, the beam will shift down and left to the next line.  After the beam arrives back on the far left, the video signal will contain a sync pulse indicating to the CRT that it is time to begin drawing the next line.  After the sync pulse comes the back porch, a period of time when the display is not being actively being drawn.  If the signal is a composite signal, the colorburst will be sent to the CRT during the back porch.  Once the back porch finishes drawing, then the active display can begin again.

This sequence of sync pulse, back porch, active display, front porch, officially occurs 262.5 times per frame on a standard NTSC television or 312.5 times per frame on a standard PAL television.  However, no device draws an active display on the first and last few lines of the frame because they would be blocked by the CRT's bezel on most displays.  For NTSC, typical active line counts are 192, 224, 239, 240 and in progressive scan mode, most devices output 261, 262, 263 scanlines, making sure not to output a half scanline to avoid interlacing.  However, even though the video may not be displaying graphics, until the vertical blanking interval where the beam goes back to the top of the screen to draw a new frame and from then onward to the active display, there may be several lines on top and bottom of the screen.

With that general overview, let's look at some devices.  This won't be a truly comprehensive look at every device that could display border colors but we'll see what we can find out. Information can be rather difficult to find.

Commodore VIC-20 & 64

Let's start with one of the first devices to offer a border color, the MOS 6560 VIC found in the Commodore VIC-20.  The default resolution of this device is 176x184, using a (redefinable) tile-based display of 22x23 8x8 cells.  But on the vertical axis this device must put out something close to 262.5 lines to ensure compatibility with displays.  The VIC will output 261 lines in a VIC-20.  Thus with the default resolution, the 6560 will give us 79 lines of vertical border.  49 will be on top, 29 on bottom.  The VIC also puts out 520 pixels of active color, so the left-most 40 pixels will be the left border, the active display will take up the next 184 pixels and the right border is a huge 128 pixels.  The default resolution can be increased horizontally and vertically quite a bit but this is not supported in BASIC, so the ability to increase the resolution was seldom used.

The Commodore 64's MOS 6569 VIC-II operates similarly, but it uses the larger default active display of 320x200.  The most common revisions of the 6569 will display 263 lines and have a horizontal pixel count of 520 pixels.  However, of those lines, only 253 are visible and of those pixels, only 420 can show color.  Thus the borders will be 53 pixels vertically.  Horizontally, in addition  to 320 active pixels, there are 98 pixels of border on the left and right sides of the screen.  Two more pixel columns should show a horizontal sync pulse line.  Thus for each horizontal line, there are 56 pixels of left border, 320 pixels of active display and 44 pixels of right border.  Each frame will have a top vertical border of 29 lines, 200 active display lines and a bottom border of 24 lines.

Atari 8-bit Computers, 5200 & XEGS

The Atari 8-bit computers can show a universal background color that extends into the area outside the active display area encompassed by the playfield.  The ANTIC video co-processor inside these machines typically outputs an active display area of 160 or 320 pixels by 192 lines.  160 pixel modes are stretched to fill the same space as a 320 mode.  The ANTIC can output a narrow playfield of 256 pixels or wide playfield of 384 pixels.  The 256 pixel playfield will have larger borders than the 320 or 384 pixel playfield.  However, the maximum number of color pixels the ANTIC can show on a line is 356 pixels, but the four right-most pixels will show garbage.  The rest is obscured by hblank.  ANTIC can show a maximum of 240 lines with color on them.

Loading Bars

Most European home computers of the 1980s had borders.  The ZX Spectrum had a routine in its ROM which would flash alternating bands of color rapidly in the border to inform the user of the progress of a cassette tape loading.  Red and cyan bands meant the ROM was seeking a loader on the tape, blue and yellow bands indicated that the ROM was loading the program into memory.  Many cassette programs for the Commodore 64 and Amstrad 8-bit computers did the same thing with the borders on those machines when loading.  Atari ST piracy scene disks also did it often to decompress games found on scene release disks.  This video, where I got most of this information from, explains it very well :

The ZX Spectrum has equally sized left and right borders of 48 pixels to complement the active display of 256 pixels.  It also nicely has 56 top and bottom lines of border and 192 active lines.  It displays 312 lines, no fractions.  Ideally, ZX Spectrum screenshots should use a 352x312 resolution.


Micro Machines NES Boarders
The NES also displays border colors.  If you've ever wondered why there are colored borders on the left and right edges of the screen in a Youtube video capture taken from original hardware, this is the reason why.  The NES has 256 active pixels per line, but the NTSC PPU can show color for 283 pixels.  There is one grey sync pulse pixel, 15 left pixels of border, 256 active pixels and 11 pixels of right border.  The NTSC NES can display 242 lines worth of color, but only the bottom two lines are border lines.  They have one pixel for the horizontal sync pulse and 282 pixels of border color.  The border color is the same as the universal background color and changes with it.  The PAL NES does not show colored borders.


With IBM PC graphics adapters, we are blessed by the openness of the hardware.  These either use the Motorolla 6845 CRTC or are based off it.  We know that for graphics modes and 40-column text, 320 pixels are displayed.  This is reflected in the 6845's Horizontal Total register.  The Horizontal Displayed register tells us (when we add one to the value) that CGA outputs 456 pixels per line.  With 80-column text and 640 pixel graphics, this pixel count is doubled to 912 pixels by referencing the same registers.  Tandy, PCjr. function identically here.

Round 42 - CGA Borders
 For the vertical, we know that CGA and PCjr. only display 200 lines.  This is reflected in the Vertical Displayed register, although for graphics modes the 6845 is not designed for many vertical rows, so the memory ends up being interleaved to get to 200 lines instead of 25 text cell rows.  The Vertical Total plus the Vertical Adjust values give us 262 total lines.  The Tandys default to 225 displayed lines in text mode, but are otherwise identical to the IBM standards.

King's Quest I - CGA 4-color Borders
EGA functions identically to CGA with 200-line modes, but for 350-line modes, things are different.  In text modes, the borders are thinner for 8x14 text compared to 8x8 test of the 200-line modes.  Thus for these modes we really only have 376 or 744 active pixels, including borders.  The 744 pixel count also holds true for the 640x350x16 mode.  The total line count is 260 and 364 for 200 and 350-line modes, respectively.  I do not believe EGA is setup to show vertical borders by default in its 350-line modes.

Commander Keen 1 - EGA Boarders
VGA also can display colored borders in most modes, however, unlike its predecessors, its borders are remarkably thin.  Only a few pixels on each side can be colored in typical 320x200 graphics modes or text modes.  With a Datapath E1s, I find I can capture all vertical borders of a 320x200 double-scanned mode with a 670x414 input resolution, which should give you a good idea of the thinness of the borders on VGA.

Commander Keen 1 - VGA Borders
ColecoVision, SMS and Genesis

The ColecoVision uses the TMS-9918A and the SMS VDP functions identically in terms of clocking.  The active display is always 256x192, but with border pixels the display is 283x243.  The Genesis and the SMS VDP in PAL mode has identical horizontal borders in its 256x224 mode.  In the Genesis' 320x224 mode, the width of a line with border is 347 pixels.  NTSC can show 243 lines and PAL can show 294 lines of border color.  The Titan OverDrive 2 demo showed a trick where all 347x294 pixels can show proper tiles instead of single-color border.

Ecco the Dolphin - 320x224 Borders
Wonder Boy in Monster World - Genesis 256x224 Borders 
Alex Kidd in Miracle World - SMS 256x224 Borders
TiTan OverDrive 2 Demo - PAL Borders (only 240 vertical pixels shown)


  1. The Apple IIgs supported border colors as well. The user can set it to whatever color they want but a few demos (most notably the "Split Demo" from FTA's XMAS Demo) put actual graphics and scroll text in the border area. KEGS based emulators can mostly reproduce these effects with glitches, but you need the real hardware to see them 100% as intended.

  2. Thanks for this great article. I was somehow hoping for an explanation why PC CRT monitors see every one of the CGA/EGA/VGA resolutions as 720x400@70Hz. Maybe you can shed some light on that in a follow-up article?

    This is interesting to me, because I believe this to be the culprit why these old resolutions always look crap when scaled to fit modern TFT's native res. Albeit most TFTs will scale them with their correct aspect-ratio, the result always looks sub-par when compared to for example having the picture scaled in Gimp or Photoshop. EGA games like the Cmdr. Keen series are good examples for this behavior as unevenly scaled pixels (some wider than others) usually show up.

    1. The HSync and VSync frequencies are identical for all of these. In an analog video signal for CRTs however you have a theoretically infinite resolution horizontally. All that changes is how they are divided up on the scanlines. Whether it's divided up into 720 or 640 pixels is irrelevant for a CRT video signal. Which is why it can look so good for both on CRTs. Horizontal resolution is really a "best guess" by the monitor. It only knows the sync frequencies and number of scanlines. As for 400 vs 200 vertical resolution? Scanlines are simply repeated once to bring everything up to 400 lines. Stuff that isn't 400 lines @ 70 hz will have very different timing and easily discernable by the monitor.

  3. changing the border colour in vga was a good way to do a visual FPS when developing stuff.