Smooth horizontal Scrolling on the STE by The Paranoid / Paradox

From Atari Wiki
Jump to navigation Jump to search

The following file can be found in https://alive.atari.org/alive12/ste_hwsc.php.

        The Atari STE was the first 16/32-Bit computer of the 
        series to feature horizontal and vertical fine-scrolling.
        While vertical fine scrolling merely requires the ability
        to set the low-byte of the screen address accordingly, the
        horizontal fine-scrolling requires the ability to have
        lines larger than the current resolution and to make the
        graphics chip to skip a certain amount of pixels at the
        beginning of each line.
        In other words, a few extensions with regard to the simple
        ST were required. First, the video base address was given
        a low-byte which the ST lacked, making up three registers
        in total:

        $FFFF8201    0 0 X X  X X X X    Address bits 16 to 21
        $FFFF8203    X X X X  X X X X    Address bits  8 to 15
        $FFFF820D    X X X X  X X X 0    Address bits  7 to  1

        Please mind that the address bit 0 is always treated as "0"
        so that the screen must start at an even address.
        To also allow horizontal fine-scrolling, the STE has been
        given a register nicknamed "Pixel-Skip", which is located
        and defined as follows:

        $FFFF8265    0 0 0 0  X X X X    Number of pixels to skip

        These registers allow the STE to scroll horizontally and
        vertically with basically just setting the registers above.
        However, when skipping a few pixels at the beginning of a
        line, that would imply "missing" some pixels because the
        Shifter always displays 320 pixels per line. Therefore,
        the Shifter allows to ignore a given number of pixels
        after having drawn 320 pixels per line. This means, there
        are more pixels per line in memory than the shifter
        actually displays. Then, of course, the Shifter needs to
        be told how many pixels to skip after having drawn a line.
        This is given in number of words (16 bits) in the following
        register, called line offset register:

        $FFFF820F    X X X X  X X X X    Number of words to ignore

        To also gain more flexibility in between the lines, the
        video address counter, which was read-only on the ST, is
        now a read/write register and located at

        $FFFF8205    0 0 X X  X X X X    Counter bits 16 to 21
        $FFFF8207    X X X X  X X X X    Counter bits  8 to 15
        $FFFF8209    X X X X  X X X 0    Counter bits  7 to  1


        To have horizontal fine-scrolling on the STE, it now
        seems that only the video base address registers, the
        Pixel skip and the line offset during the VBL.
        Unfortunately, the result will be a corrupted screen
        every now and then. How come ? Atari's official state-
        ment looked a bit like this:

          "Setting the Video Base Address Pixel Offset during
           the VBL from unequal to zero to zero might result
           in corrupted display."

        As a result - and so it is explained in the STE-FAQ as
        well - this register should be treated in a HBL-Interrupt
        rather than the VBL to avoid resetting it during the VBL.
        However, for many programs, this means the introduction
        of the HBL-interrupt as an additional interrupt source
        and might mix up timing with music/digi-sounds etc.
        Therefore, the HBL-Interrupt is not desired.

        Often enough in magazines and on webpages a solution
        without requiring the HBL-Interrupt is debated, but so
        far, only fragments of a working routine have been
        presented and the results were not very satisfactory.
        Nevertheless, a simple solution is available even
        during the VBL and even better, it works on the STE,
        the Falcon VGA and RGB and even on the TT.

        The procedure is quite simple. During the VBL, you
        first write the screen base address (mind the order):

        move.b adr_high,$FFFF8201.w  ;High Byte
        move.b  adr_mid,$FFFF8203.w  ;Mid Byte
        move.b  adr_low,$FFFF820D.W  ;Low Byte

        Now write the new pixel skip and line offset in no
        special order

        move.b line_ofs,$FFFF820F.w  ;Offset between lines
        move.b pxl_skip,$FFFF8265.w  ;Pixel Skip (0-15)

        This might actually lead to the Shifter interpreting
        the following lines in the wrong way and therefore
        doing corrupted screen display. Funny enough, the
        Shifter will always perform correct display when
        writing the address counters by hand:

        move.b adr_high,$FFFF8205.w  ;High Byte
        move.b  adr_mid,$FFFF8207.w  ;Mid Byte
        move.b  adr_low,$FFFF8209.w  ;Low Byte

        Once these values have been loaded directly into the
        screen address counters, the Shifter seems to correct
        its faulty line interpretation and will correctly
        display the next frame.

        Tested on STE, MegaSTE, Falcon on both RGB and VGA and
        on TT (Colour) and found working on all these machines.
        Some of the previous articles state that this concept
        seems to work only in low resolutions.
        This cannot be affirmed so far, the concept seems to
        work in any resolution at least on the MegaSTE, but
        there are restrictions anyhow:

        1.) The Falcon cannot scroll in monochrome resolution

        2.) The TT can only scroll in 16- and 256-colours

        The Paranoid /  Paradox
        Alive on a dead machine
        ... That's  Paradox ...