GDSetTexImgPtr, etc.

C Specification

#include <revolution/gd.h>
void GDSetTexImgPtr    ( GXTexMapID id, void *image_ptr );
void GDSetTexImgPtrRaw ( GXTexMapID id, u32 image_ptr_raw );
void GDPatchTexImgPtr  ( void *image_ptr );

Arguments

id The hardware texture map ID to change.
image_ptr A pointer to the texture data in Revolution main memory. This pointer will be converted from a cached to a physical pointer.
image_ptr_raw A U24 value to be inserted in place of image_ptr. This value will be inserted unchanged into the command output.

Return Values

None.

Description

GDSetTexImgPtr is used to set the image pointer for a specified hardware texture map ID. Unlike the GX library, which uses texture objects, GD functions set the hardware registers directly.

GDSetTexImgPtr takes a Revolution main memory pointer as an argument. This function is used to write to the display list. Because the desired address is unknown when the display list is created, additional functions are available to simplify patching the display list. 

The GDSetTexImgPtrRaw function allows a raw (U24) data value to be written in place of the texture data pointer. The GDSetTexImgPtr function converts the logical address into a physical address. The raw version of the function omits this process.

GDPatchTexImgPtr writes out a converted address only. To properly use this function, you must first save the correct patch location (when the display list was created), and then reset the current offset to this patch location before calling GDPatchTexImgPtr. Finally, the newly written data is flushed back into main memory. The following code illustrates the correct operation sequence.

Display list creation:

savedOffset[0] = GDGetCurrOffset() + BP_DATA_OFFSET;  // save the necessary offset
GDSetTexImgPtrRaw( GX_TEXMAP0, 0 );

Display list patching:

GDSetCurrOffset(savedOffset[0]);  // set the offset
cp = GDGetCurrPointer();          // save ptr for flushing later
GDPatchTexImgPtr(tp);             // patch in the base address ptr
DCStoreRange(cp, BP_DATA_LENGTH); // flush to main memory

Because the GDSetTexImgPtr function issues a BP command, BP_DATA_OFFSET and BP_DATA_LENGTH are used in the above code segments.

See Also

GXInitTexObj

GDSetTexLookupMode
GDSetTexImgAttr

Revision History

03/01/2006 Initial version.