MakeCCBRelative

Creates a CCB relative address.

Synopsis

int32 MakeCCBRelative (field, linkObject)

Description

MakeCCBRelative() allows you to turn the absolute address of an object into the sort of relative address needed by the cel engine. The first argument is a pointer to the field to receive the relative address and the second argument is a pointer to the object to be referenced. This macro does the math required to create a correct relative offset, which is not simply the difference between the two addresses. For example, to create a relative pointer to a "next cel" you would use these arguments:

 cel->ccb_Next Ptr=(CCB*)CCB_Relative(&cel->ccb_Next Ptr,&Next Cel();

To make sure the cel indicates it has a relative pointer to the next cel, explicitly clear the control flag:

 Clear Flag(cel->ccb_Flags,CCB_NPABS);

This macro is required because the cel engine uses pipelined prefetch techniques that keep the cel engine's internal addressing ahead of the internal logic that processes the addresses and data in the cel control block.

Arguments

field
The address of the object that receives the relative link to the other object. The object can be the next CCB, cel data, or the PLUT. This argument is any value that can be coerced to an int32.
linkObject
The address to the object that will be linked. The object can be the next CCB, cel data, or the PLUT. This argument is any value that can be coerced to an int32.

Return Value

The macro returns an int32 value that is the relative offset between the two addresses corrected (offset) as required by the cel engine.

Implementation

Macro implemented in graphics.h V20.

Associated File

graphics.h