The engine uses 3 screen-sized buffers for rendering purposes. They will be called Front, Back and Aux. Watch out, these names are misleading, as there is no obvious multiple-buffering implementation going on.
The buffers are used in different ways when rendering game scenes, menu, and introduction.
A pristine copy of the background bitmap is not kept. Rather, the Aux buffer holds the background patched with sprites for activable items and doors. The patches may come from GET and DOOR zones found in location scripts: in this case, a backup of the rectangular background area is kept for each patch. Other patches can be applied in-game as a result of PUT instructions from action scripts: in this case no backup is retained [that means whatever is PUT can't be removed unless something else is drawn on top of it]. The resulting Aux buffer is used to restore background whenever an animation needs to be deleted or moved. When one of the GET/DOOR zones is activated, its backup is used to modify Aux.
The loading routines don't affect the Aux buffer directly, rather they draw on the Back buffer instead. Anyway, Aux receives a full blit as soon as loading is over, and works as specified from then on.
Scenes are rendered on the Back buffer. In detail, Back buffer is the recipient for the following operations:
- masked blitting of animation frames
- masked blitting of labels (zone descriptions)
- masked/unmasked blitting of item backups from Aux buffer
- blitting of inventory
Moreover, whenever Aux is modified, the Back buffer immediately receives a full copy.
The Front buffer is always a composition of the Back buffer and the following:
- character faces (in dialogues and examining)
- balloons (in dialogues, examining and location entry)
- item detail (when examining)
- characther head (when examining)
The Front buffer is always blitted on screen whenever it changes. The Back buffer is very often used to provide a starting point for rendering.
TODO: add detail to the following points and some consideration on improving/simplifying this scheme