From 'Atari 400/800 Hardware Manual' Section II, page 20. (c) 1982, Atari, Inc. The entire 'Technical Reference Notes' are probably available from B & C Computervisions. (about 4 lbs avoirdupois, maybe 1000 pages) Cycle counting: As explained previously, the atari 800 6502 microprocessor runs at a rate of 114 machine cyles per TV line (1.79 mhz). There are 262 lines per TV frame and 60 frames per second on the NTSC (US) system. (PAL different, see end.) Eace machine cycle is equivalent in length to 2 color clocks. There are 228 color clocks on a TV line. The highest resolution graphics modes have a pixel size of 1/2 color clock by 1 TV line. Horizontal blank takes 40 machine cycles. This is when the beam returns to the left edge of the screen in preparation for displaying the next TV line. A wait for Sync (WSYNC) instruction stops the 6502. The processor is restarted exactly 7 machine cycles before the beginning of the next TV line. The program can thus change graphics or colors during horizontal blank in preparation for the next line. The ANTIC chip steals cycles from the 6502 in order to do memory refresh and fetch graphics data when needed. The gereral rule to remember is that each byte fetched from memory requires one machine cycle. If a display list memory map instruction extends over several lines then the data is only fetched on the first line. Memory refresh takes 9 cycles out of every line, unless pre-empted by a high-resolution graphics mode. Memory refresh continues during vertical blank. Missile DMA takes one cycle per line in the one-line resolution mode and one cycle every other line in the two line resolution mode. Missle DMA can be enabled without doing player DMA. However, if player DMA is enabled the missile DMA will also be done (see DMACTL, GRACTL bits). Player DMA requires 4 cycles every one or two lines, depending on the resolution used. Each fetch of a display list byte takes one cycle, so three cycles are required for a three byte instruction. Player/missile and display list instruction fetch DMA take place during horizontal blank, if they are required for the next line. In memory map modes, the graphics data is fetched as needed throughout the first line of the display list instruction, then saved by ANTIC for use in succeeding lines. In character modes, the character codes are fetched during the first line of each row of characters, along with the graphics data needed for that line. On the next lines, only the graphics data is fetched, since ANTIC remembers the character codes. In the 40 x 24 character mode, with a standard screen width, most of the cycles during the top line of each row of characters are required to fetch the character codes and data, so there is only time for one memory refresh cycle instead of the usual nine. Less DMA is required with a narrow screen width so two memory refresh cycles would occur in this case. The memory refresh is done fast enough to make up for the lost cycles in the high resolution modes. Once memory refresh starts on a line, it occurs every four cycles unless pre-empted by DMA. All interrupts reach the 65020 near the end of horzontal blank. With standard or narrow screen widths, refresh DMA starts after the end of horizontal blank. The time at which ANTIC does cycle stealing is deterministic, but depends on the graphics mode, screen width and whether or not horizontal scrolling is enabled. Horizontal scrolling requires extra graphics data: see HSCROL. ANTIC does horizontal scrolling of an even nember of color clocks by delaying the time at wich it DMA's the data. To do an odd number of color clocks (which involves half of a machine cycle), ANTIC has a one color clock internal delay. Theoretically, it is possible to write a program which changes graphics or colors "on the fly", i.e. during the middle of a TV line. However, with all the DMA going on, the cycle counting gets to be quite complicated., and is beyond the scope of this manual. There are a number of delays associated with the display of graphics. These occur in the ANTIC and the CTIA. The ANTIC sends data to the CTIA which adds in the color information. Thus the timing for changing colors on the fly is different from that for changing graphics on the fly. When DMA is enabled, cycles are stolen at the times shown below. | End of | | |< previous ----->|<----horizontal blank-------->| | line | | 20 machine cycles (40 color clocks) | 5 | 4 | 1 | 1 | 4 | 2 | 8 1-9 refresh cycles. | ^ ^ ^ ^ ^ char. and graphics | | | | | | data DMA (depends on | | | | | | graphic mode) | | | | | | WSYNC | | | | |________ Interrupt | | | |______________ Address DMA (3-byte DLI) | | |____________________ Player | |__________________________ DLI fetch DMA |________________________________ Missile DMA CYCLE COUNTING EXAMPLE: This example uses the 40 character by 24 line display list given on pg. II.24 (70, 70, 70, 42, 40, 7C, 2, 2, 2, ...(23 mode 2 instructions), 2, 2, 2, 41, 20, 7C, (graphics 0 DL, I think). This DL is 32 bytes long so display list DMA takes 32 machine cycles. It takes 960 cycles to DMA the characters and 8*960 to DMA the character data. The refresh DMA takes 9 cycles for each of 262 lines, except for the 24 lines where the characters are read, where only 1 refresh cycle occurs. DMA description Machine cycles display list -------------------- 32 characters -------------------- 40x24 = 960 character data ------------------ 960x8 = 7680 refresh ------------------------ 262x9-24x8 = 2166 total 10838 Thus the total DMA per frame is 10838 machine cycles. One frame is 262 lines with 114 machine cycles per line for a total of 29868 machine cycles per frame. The 36% of each frame is required for DMA in OS graphics mode 0. NTSC vs. PAL Systems: There are two versions of the ATARI 800: the NTSSC and PAL. The PAL system has been designed so that most programs will run without being modified. However, some differences may be noticeable. There is a hardware register (PAL) which a program can read to determine which type of system it is running on and adjust accordingly. PAL TV has a slower fram rate (50 hz instead of 60 hz) so games will be slower unless an adjust ment is made. PAL has more TV lines per frame (312 instead of 262). The Atari 800 hardware compensates for this by adding extra lines at the beginning of vertical blank. Display lists do not have to be altered. However, their actual vertical height will be shorter. PAL Atari 800 colors are similar to NTSC because of a hardware modification.