h4. Overview VDU save areas allow for the state of the VDU to be preserved while certain operations are performed, for example when screen output is redirected to a sprite via [[OS_SpriteOp 60]]. The basic steps for using a save area are as follows: # Use [[OS_SpriteOp 62]] to determine the required size of the save area # Allocate a word-aligned block of memory to store the area, and initialise the first word to zero # Pass the pointer to the save area to [[OS_SpriteOp 60]] or similar. This will register the save area with the VDU, making it active. # Perform your desired task (e.g. use the VDU to render to your sprite) # Restore the previous screen output by calling OS_SpriteOp with the R0-R3 values that were returned by OS_SpriteOp 60 # Release the memory you allocated for the save area During step 5 the kernel will save the current VDU state to your save area. If you were to redirect output to your sprite again, using the same save area, then the corresponding VDU state will be restored. This can be useful if you want to split lengthy tasks up into smaller chunks, e.g. for multitasking in the Wimp. There's another important function that save areas enable. If, during step 4, another piece of code was to attempt to redirect output to a sprite, then the kernel will save the VDU state to your save area. When the other code has finished and restores the previous screen output, the contents of your save area will be automatically restored. This makes the use of screen redirection by the other code completely transparent to your code. Conversely, if you'd failed to set up a save area in steps 1-3, then the VDU state would have been reset to default, potentially resulting in your code corrupting the graphics it was producing. This is the reason why it's recommended to always use save areas when you're given the opportunity to do so. h4. Saved state VDU save areas store the following state: * The [[*Spool]] file handle * The [[Output Stream Status]] * The current contents of the VDU queue (i.e. any partial VDU byte sequence) * Graphics foreground & background colours and actions * Graphics window coordinates, origin * Graphics plot position history (as necessary for e.g. polygon rendering VDU sequences) * Text foreground & background colours * Text window coordinates * Text input and output cursor coordinates * Misc VDU status flags * Cursor display settings * ECF patterns and offsets * Dot-dash line pattern * Graphics character size * Clipping box h4. See also * [[OS_SpriteOp 60]] * [[OS_SpriteOp 61]] * [[OS_SpriteOp 62]]