More Memory Secrets


Remember when we calculated the memory requirements of the various modes? The Atari manual chart gives numbers a little larger than the ones we calculated. For example, in graphics 0, we need only 960 bytes to store the character numbers (40 X 24 characters = 960), yet the manual said 993 bytes. The remaining bytes are the display list memory area. Let's recalculate the graphics 0 display memory and display list requirements.

A graphics 0 display list, as we will shortly see in real life, looks like this:

3 bytes which instruct ANTIC to leave the top of the screen blank.

3 bytes which instruct ANTIC where to find display memory.

24 bytes which instruct ANTIC that there are 24 graphics 0 display blocks.

3 bytes which instruct ANTIC to wait for the next refresh to begin, then go to the top of the display list and start all over again.

This totals 33 bytes.

Add these 33 bytes to the 960 bytes of the graphics 0 display memory, and you will have 993 bytes, which is what the Basic manual says. You can carry out this same calculation for other graphics modes.

Depending on the graphics mode, we have a variable number of colors available to color a given character or dot on the screen.

There are 16 colors available, numbered 0-15. There are also 8 different luminances available, numbered 0-15. Each consecutive pair of luminance values, 0 and 1, 2 and 3, and so on generate the same luminance, so there are only 8, not 16 luminances. All this color and luminance information takes 4 bits to save color information and 4 bits to save luminance information. This totals 8 bits, or one byte, to save the color and luminance for one point.

A competitive computer to the Atari stores one byte of color and luminance information for each dot in memory. We would use 320 x 192 bytes, or 61,440 bytes. Since 65,535 bytes is all of memory, we would be using nearly all of it for display! So we need to come up with a better approach.

The Atari has five "color registers" instead. These color registers are 8 bits long, and save color information in the first four bits, with luminance information in the last four. In memory when we want to specify a color, we instead specify the number of a color register that contains the color we want to have the data displayed in.

When CTIA, busily plotting data from ANTIC, looks to a graphics point and sees "01" as its color, it does not plot the point in color 1, but looks to color register 1, gets whatever color is stored in there, and plots the point in that color. A lot of memory is saved this way.

Graphics 0 and 8 do not have color information saved in their memory data. That is why it is easy to calculate their memory needs. Modes 1 and 2 actually use the top 2 bits of each character number to save a color register number. The graphics modes other than 8 work in one of two ways. They reserve either one or two bits per pixel, and use those 1 or 2 to "point to" color registers.

With 1 bit, we can specify 2 colors (0 or 1).

With 2 bits, we can specify 4 colors (00, 01, 10, 11).

Hence, if we use a 2-bit mode, we can specify a pixel to be in one of four colors, and if we use a 1 bit mode, we can specify one of two colors. In your Basic manual's graphics section, it mentions that modes 3, 5 and 7 are "four color modes", and modes 4 and 6 are "two color modes". You have just learned why. Modes 4 and 6 use less memory than their 4 color counterparts at the same resolution, for they use only 1 bit per pixel, not 2.

A typical graphics 7 (2 bits four color) display block is 2 scan lines high and has 160 points across (2 dots per pixel horizontally and 2 scan lines per pixel vertically). Since there are 160 points, and 2 bits per point to save color information, that is 320 bits, or 40 bytes of information per block. The information is stored 4 pixels per byte, all packed in together. If we had a graphics 7 display block at the top of the screen, the first byte would contain the data for the first four points. The first point on the screen would have its color data in the first two bits of the first byte (bits 8 and 7), the second point in bits 6 and 5, and so on. If there is 00 specified as the color information, the point is not plotted. Rather, background color and luminance are used in plotting that pixel.

Below is a handy table of the various graphics modes, how they are mapped in memory, and the memory requirements.

If we store 8 points per byte, we are only using 1 bit to determine color. If we store 4 points per byte, we are using 2 bits and have a 4 color mode.

We add 9 to each display list length to handle the overhead instructions in the display list (see the previous example). These instructions are the same in each display list, hence the constant length.

The total RAM requirements will match the back of your Basic manual. The only difference will be in graphics 8, which has bytes that are unaccounted for; these are extra display list instructions made necessary by the length of display memory.


Graphics
X
Y
Lines/
# Bits/
Pts/
D Mem
D List
RAM req'd
RAM /1

Mode

Pts

Pts

DB

Point

Byte

Length

Length

(DM+DL)

Disp B1

0
40
24
8
8
1
960 +
24
(+9) =
993
40
1
20
24
8
(8)
1
480+
24
(+9) =
513
20
2
20
12
16
(8)
1
240+
12
(+9) =
261
20
3
40
24
8
2
4
240+
24
(+9) =
273
10
4
80
48
4
1
8
480+
48
(+9) =
537
10
5
80
48
4
2
4
960+
48
(+9) =
1017
20
6
160
96
2
1
8
1920+
96
(+9) =
2025
20
7
160
96
2
2
4
3840+
96
(+9) =
3945
40
8
320
192
1
1
8
7680+
192
(+9) =
7891
40

Table of Contents
Previous Section: ANTIC and CTIA
Next Section: Examining the Display List