C
WORD ExternalMemoryCallback( GFX_EXTDATA * memory, LONG offset, WORD nCount, void * buffer );
Overview
This function must be implemented in the application. The library will call this function each time when the external memory data will be required. The application must copy requested bytes quantity into the buffer provided. Data start address in external memory is a sum of the address in GFX_EXTDATA structure and offset.
Input Parameters
Input Parameters |
Description |
GFX_EXTDATA * memory |
Pointer to the external memory bitmap or font structures (FONT_EXTERNAL or BITMAP_EXTERNAL). |
LONG offset |
Data offset. |
WORD nCount |
Number of bytes to be transferred into the buffer. |
void * buffer |
Pointer to the buffer. |
Returns
Returns the number of bytes were transferred.
Side Effects
none
Example
// If there are several memories in the system they can be selected by IDs. // In this example, ID for memory device used is assumed to be 0. #define X_MEMORY 0 WORD ExternalMemoryCallback(GFX_EXTDATA* memory, LONG offset, WORD nCount, void* buffer) { int i; long address; // Address of the requested data is a start address of the object referred by GFX_EXTDATA structure plus offset address = memory->address+offset; if(memory->ID == X_MEMORY){ // MemoryXReadByte() is some function implemented to access external memory. // Implementation will be specific to the memory used. In this example // it reads byte each time it is called. i = 0; while (i < nCount) { (BYTE*)buffer = MemoryXReadByte(address++); i++; } } // return the actual number of bytes retrieved return (i); }