The MOS now provides a facility for determining which areas of the 'screen' have changed over calls to the VDU drivers. When this feature is enabled, the MOS maintains the coordinates of a rectangle which completely encloses any areas that have changed since the last time the rectangle was reset.

This is particularly useful for applications which switch output to sprites, and then want to repaint the sprite onto the screen after performing VDU operations on the sprite. The application can make significant speed improvements by only repainting the section of the sprite which corresponds to the changed box.

SWI OS_ChangedBox (&5A)


in: R0 = 0 => disable changed box calculations
R0 = 1 => enable changed box calculations
R0 = 2 => reset changed box to null rectangle
        R0 = -1 => do nothing (just read address of changed box info)
out: R0 = old enable state in bit 0 (0 => disabled, 1 => enabled)
R1 points to a fixed block of 5 words, containing the following info
[R1, #0] = disable/enable flag (in bit 0)
[R1, #4] = x-coordinate of left edge of box
[R1, #8] = y-coordinate of bottom edge of box
[R1, #12] = x-coordinate of right edge of box
         [R1, #16] = y-coordinate of top edge of box

All coordinates are measured in pixels from the bottom left of the screen. If a module provides extensions to the VDU drivers, it should read the address of this block on initialisation, and update the coordinates as appropriate. If an exact calculation of which areas have been modified is difficult, then the module should extend the rectangle to include the whole of the graphics window (or indeed the whole screen, if the operation can affect areas outside the graphics window).

Note that the disable/enable flag at offset 0 in the block is for information only - it must not be modified directly, as the MOS holds the master copy of this flag.

Changed box calculations are disabled on a mode change. However, the disable/enable state and the coordinates of the rectangle form part of the information held in save areas when output is switched between the screen and sprites.