/*
* This function displays a 4-bit bitmap described by the
* BitmapData structure. It will display the bitmap by
* writing the data directly to RAM that can then be
* read by the YGV601B controller.
*
* VRAM_BASE is defined as the address in video-RAM of
* the top left pixel of the display.
*
* DISPLAY_BYTE_WIDTH is the number of bytes wide the
display is.
* For a 4-bits per pixel screen, the DISPLAY_BYTE_WIDTH is
* half of the width of the display.
*
* It has two restrictions.
* 1. The bitmap must be an even number of pixels wide.
* 2. The left value passed in must be an even number.
*
* Removing the second restriction would make the routine
* more general, but a lot slower.
*
* left, top is the location of the upper left dot
* of the bitmap on the display.
*/
void imageRenderForYGV(const BitmapData * imagePtr, int left, int top)
{
/*
* x and y will track the location we are
* drawing within the bitmap.
*/
unsigned int x,y;
/*
* index tracks our location within the array of bytes
* that represent the image.
*/
long index;
unsigned char *imageOffset;
/*
* The
imageOffset is the location in video-RAM where
* we want to display the top left dot of the bitmap.
*/
imageOffset = VRAM_BASE + top*DISPLAY_BYTE_WIDTH + left/2;
/*
* Bitmaps must start on an even boundary to allow a byte for byte
* mapping.
*/
assert(left%2 == 0);
/*
* Make sure that the bitmap does not go outside of the display.
*/
assert(top + imagePtr->height
<
= DISPLAY_FULL_HEIGHT);
assert(left + imagePtr->width
<
= DISPLAY_FULL_WIDTH);
index = 0;
for (y = 0; y
<
imagePtr->height; y++)
{
/*
* x will step forward 2 at a time, since each
* byte contains 2 pixels
*/
for (x = 0; x
<
imagePtr->width; x += 2)
{
/*
* The left hand side of this assignment is the location
* in video memory where the next one byte (two dots) are
* to be displayed.
*/
*(imageOffset + (y*DISPLAY_BYTE_WIDTH) + x/2) = imagePtr->raw[index];
index++;
}
}
}