[Contents] [index] [Help] [Retrace] [browse <] [Browse >]

For double-buffering, a place must be provided for the system to store the
extra information it needs.  The system maintains these data, and does not
expect the application to change them.  The dbufpacket structure consists
of the following members:

bufy, bufx  lets the system keep track of where the object was located
            in the last frame (as compared to the bob structure
            members called oldy and oldx that tell where the object
            was two frames ago).  BufY and BufX provide for correct
            restoration of the background within the currently active
            drawing buffer.

bufpath     assures that the system restores the backgrounds in the
            correct sequence; it relates to the vsprite members
            drawpath and clearpath.

bufbuffer   this field must be set to point to a buffer the same size
            as the Bob's savebuffer.  this buffer is used to store the
            background for later restoration when the system moves the
            object.  This buffer must be allocated from Chip memory.

To create a double-buffered Bob, execute a code sequence similar to the
following:

    struct Bob        myBob = {0};
    struct DBufPacket myDBufPacket = {0};

    /* Allocate a DBufPacket for myBob same size as previous example */
    if (NULL != (myDBufPacket.BufBuffer = AllocRaster(48, 20 * 5)))
        {
        /* tell Bob about its double buff status */
        myBob.DBuffer = myDBufPacket;
        }

The example routines makebob() and freebob() in the animtools.c listing at
the end of this chapter show how to correctly allocate and free a
double-buffered Bob.