/*****************************************************************************
* Module for Microchip Graphics Library
* Densitron HIT1270 controller driver
* Landscape orientation
*****************************************************************************
* FileName: HIT1270.c
* Dependencies: Graphics.h
* Processor: PIC24
* Compiler: MPLAB C30
* Linker: MPLAB LINK30
* Company: Microchip Technology Incorporated
*
* Software License Agreement
*
* Copyright © 2008 Microchip Technology Inc. All rights reserved.
* Microchip licenses to you the right to use, modify, copy and distribute
* Software only when embedded on a Microchip microcontroller or digital
* signal controller, which is integrated into your product or third party
* product (pursuant to the sublicense terms in the accompanying license
* agreement).
*
* You should refer to the license agreement accompanying this Software
* for additional information regarding your rights and obligations.
*
* SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY
* OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR
* PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR
* OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION,
* BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT
* DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL,
* INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
* COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY
* CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF),
* OR OTHER SIMILAR COSTS.
*
* Author Date Comment
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Anton Alkhimenok 11/12/07 Version 1.0 release
*****************************************************************************/
#include "Graphics\Graphics.h"
// Color
WORD_VAL _color;
// Clipping region control
SHORT _clipRgn;
// Clipping region borders
SHORT _clipLeft;
SHORT _clipTop;
SHORT _clipRight;
SHORT _clipBottom;
/////////////////////// LOCAL FUNCTIONS PROTOTYPES ////////////////////////////
void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch);
void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch);
void PutImage8BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch);
void PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch);
void PutImage1BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch);
void PutImage4BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch);
void PutImage8BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch);
void PutImage16BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch);
/*********************************************************************
* Function: SetAddress(addr2,addr1,addr0)
*
* PreCondition: none
*
* Input: addr0,addr1,addr2 - address bytes
*
* Output: none
*
* Side Effects: none
*
* Overview: writes S6D0129 address pointer
*
* Note: none
*
********************************************************************/
inline void SetAddress(DWORD address)
{
DeviceSetCommand();
DeviceWrite(SET_DATA_POINTER);
DeviceSetData();
DeviceWrite(((DWORD_VAL)address).v[0]);
DeviceWrite(((DWORD_VAL)address).v[1]);
DeviceWrite(((DWORD_VAL)address).v[2]);
}
/*********************************************************************
* Function: void ResetDevice()
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: resets LCD, initializes PMP
*
* Note: none
*
********************************************************************/
void ResetDevice(void)
{
// Initialize the device
DeviceInit();
// Enable LCD
DeviceSelect();
DelayMs(10);
// Clear text layer
SetAddress(0);
for(counter = 0; counter < 0x4b0; counter++)
{
DeviceWrite(0x07);
DeviceWrite(0x07);
}
// Disable LCD
DeviceDeselect();
DelayMs(20);
}
/*********************************************************************
* Function: void SetColor(WORD color)
*
* PreCondition: none
*
* Input: color coded in format:
* bits 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
* color R R R R R G G G G G G B B B B B
*
* Output: none
*
* Side Effects: none
*
* Overview: sets current color
*
* Note: none
*
********************************************************************/
void SetColor(WORD color)
{
_color.v[0] = ((WORD_VAL) color).v[0] & 0x1c;
_color.v[1] = (((WORD_VAL) color).v[1] >> 1) & 0x73;
}
/*********************************************************************
* Function: void PutPixel(SHORT x, SHORT y)
*
* PreCondition: none
*
* Input: x,y - pixel coordinates
*
* Output: none
*
* Side Effects: none
*
* Overview: puts pixel
*
* Note: none
*
********************************************************************/
void PutPixel(SHORT x, SHORT y)
{
DWORD address;
if(_clipRgn)
{
if(x < _clipLeft)
return;
if(x > _clipRight)
return;
if(y < _clipTop)
return;
if(y > _clipBottom)
return;
}
DeviceSelect();
address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * y + x;
SetAddress(address);
DeviceWrite(_color.v[0]);
DeviceWrite(_color.v[1]);
DeviceDeselect();
}
/*********************************************************************
* Function: WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom)
*
* PreCondition: none
*
* Input: left,top - top left corner coordinates,
* right,bottom - bottom right corner coordinates
*
* Output: For NON-Blocking configuration:
* - Returns 0 when device is busy and the shape is not yet completely drawn.
* - Returns 1 when the shape is completely drawn.
* For Blocking configuration:
* - Always return 1.
*
* Side Effects: none
*
* Overview: draws rectangle filled with current color
*
* Note: none
*
********************************************************************/
WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom)
{
DWORD address;
register SHORT x, y;
#ifndef USE_NONBLOCKING_CONFIG
while(IsDeviceBusy() != 0);
/* Ready */
#else
if(IsDeviceBusy() != 0)
return (0);
#endif
if(_clipRgn)
{
if(left < _clipLeft)
left = _clipLeft;
if(right > _clipRight)
right = _clipRight;
if(top < _clipTop)
top = _clipTop;
if(bottom > _clipBottom)
bottom = _clipBottom;
}
address = BUF_MEM_OFFSET + (DWORD) LINE_MEM_PITCH * top + left;
DeviceSelect();
for(y = top; y < bottom + 1; y++)
{
SetAddress(address);
for(x = left; x < right + 1; x++)
{
DeviceWrite(_color.v[1]);
DeviceWrite(_color.v[0]);
}
address += LINE_MEM_PITCH;
}
DeviceDeselect();
return (1);
}
/*********************************************************************
* Function: void ClearDevice(void)
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: clears screen with current color
*
* Note: none
*
********************************************************************/
void ClearDevice(void)
{
DWORD counter;
DeviceSelect();
SetAddress(0x018000);
for(counter = 0; counter < (DWORD) (GetMaxX() + 1) * (GetMaxY() + 1); counter++)
{
DeviceWrite(_color.v[1]);
DeviceWrite(_color.v[0]);
}
DeviceDeselect();
MoveTo(0, 0);
}
/*********************************************************************
* Function: WORD PutImage(SHORT left, SHORT top, void* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
* stretch - image stretch factor
*
* Output: For NON-Blocking configuration:
* - Returns 0 when device is busy and the image is not yet completely drawn.
* - Returns 1 when the image is completely drawn.
* For Blocking configuration:
* - Always return 1.
*
* Side Effects: none
*
* Overview: outputs image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
WORD PutImage(SHORT left, SHORT top, void *bitmap, BYTE stretch)
{
FLASH_BYTE *flashAddress;
BYTE colorDepth;
WORD colorTemp;
#ifndef USE_NONBLOCKING_CONFIG
while(IsDeviceBusy() != 0);
/* Ready */
#else
if(IsDeviceBusy() != 0)
return (0);
#endif
// Save current color
colorTemp = _color.Val;
switch(*((SHORT *)bitmap))
{
#ifdef USE_BITMAP_FLASH
case FLASH:
// Image address
flashAddress = ((BITMAP_FLASH *)bitmap)->address;
// Read color depth
colorDepth = *(flashAddress + 1);
// Draw picture
switch(colorDepth)
{
case 1: PutImage1BPP(left, top, flashAddress, stretch); break;
case 4: PutImage4BPP(left, top, flashAddress, stretch); break;
case 8: PutImage8BPP(left, top, flashAddress, stretch); break;
case 16: PutImage16BPP(left, top, flashAddress, stretch); break;
}
break;
#endif
#ifdef USE_BITMAP_EXTERNAL
case EXTERNAL:
// Get color depth
ExternalMemoryCallback(bitmap, 1, 1, &colorDepth);
// Draw picture
switch(colorDepth)
{
case 1: PutImage1BPPExt(left, top, bitmap, stretch); break;
case 4: PutImage4BPPExt(left, top, bitmap, stretch); break;
case 8: PutImage8BPPExt(left, top, bitmap, stretch); break;
case 16: PutImage16BPPExt(left, top, bitmap, stretch); break;
default: break;
}
break;
#endif
default:
break;
}
// Restore current color
_color.Val = colorTemp;
return (1);
}
#ifdef USE_BITMAP_FLASH
/*********************************************************************
* Function: void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
* stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs monochrome image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch)
{
register FLASH_BYTE *flashAddress;
register FLASH_BYTE *tempFlashAddress;
register DWORD address;
BYTE temp;
register WORD sizeX, sizeY;
WORD x, y;
register BYTE stretchX, stretchY;
WORD pallete[2];
BYTE mask;
// Move pointer to size information
flashAddress = bitmap + 2;
// Set start address
address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;
// Read image size
sizeY = *((FLASH_WORD *)flashAddress);
flashAddress += 2;
sizeX = *((FLASH_WORD *)flashAddress);
flashAddress += 2;
pallete[0] = *((FLASH_WORD *)flashAddress);
flashAddress += 2;
pallete[1] = *((FLASH_WORD *)flashAddress);
flashAddress += 2;
for(y = 0; y < sizeY; y++)
{
tempFlashAddress = flashAddress;
DeviceSelect();
for(stretchY = 0; stretchY < stretch; stretchY++)
{
flashAddress = tempFlashAddress;
SetAddress(address);
mask = 0;
for(x = 0; x < sizeX; x++)
{
// Read 8 pixels from flash
if(mask == 0)
{
temp = *flashAddress;
flashAddress++;
mask = 0x80;
}
// Set color
if(mask & temp)
{
SetColor(pallete[1]);
}
else
{
SetColor(pallete[0]);
}
// Write pixel to screen
for(stretchX = 0; stretchX < stretch; stretchX++)
{
DeviceWrite(_color.v[1]);
DeviceWrite(_color.v[0]);
}
// Shift to the next pixel
mask >>= 1;
}
address += LINE_MEM_PITCH;
}
}
DeviceDeselect();
}
/*********************************************************************
* Function: void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
* stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs 16 color image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch)
{
register DWORD address;
register FLASH_BYTE *flashAddress;
register FLASH_BYTE *tempFlashAddress;
WORD sizeX, sizeY;
register WORD x, y;
BYTE temp;
register BYTE stretchX, stretchY;
WORD pallete[16];
WORD counter;
// Move pointer to size information
flashAddress = bitmap + 2;
// Set start address
address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;
// Read image size
sizeY = *((FLASH_WORD *)flashAddress);
flashAddress += 2;
sizeX = *((FLASH_WORD *)flashAddress);
flashAddress += 2;
// Read pallete
for(counter = 0; counter < 16; counter++)
{
pallete[counter] = *((FLASH_WORD *)flashAddress);
flashAddress += 2;
}
for(y = 0; y < sizeY; y++)
{
tempFlashAddress = flashAddress;
for(stretchY = 0; stretchY < stretch; stretchY++)
{
DeviceSelect();
flashAddress = tempFlashAddress;
SetAddress(address);
for(x = 0; x < sizeX; x++)
{
// Read 2 pixels from flash
if((x & 0x0001) == 0)
{
temp = *flashAddress;
flashAddress++;
}
// Set color
SetColor(pallete[temp & 0x0f]);
// Write pixel to screen
for(stretchX = 0; stretchX < stretch; stretchX++)
{
DeviceWrite(_color.v[1]);
DeviceWrite(_color.v[0]);
}
// Shift to the next pixel
temp >>= 4;
}
address += LINE_MEM_PITCH;
DeviceDeselect();
}
}
}
/*********************************************************************
* Function: void PutImage8BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
* stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs 256 color image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage8BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch)
{
register DWORD address;
register FLASH_BYTE *flashAddress;
register FLASH_BYTE *tempFlashAddress;
WORD sizeX, sizeY;
register WORD x, y;
BYTE temp;
register BYTE stretchX, stretchY;
WORD pallete[256];
WORD counter;
// Move pointer to size information
flashAddress = bitmap + 2;
// Set start address
address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;
// Read image size
sizeY = *((FLASH_WORD *)flashAddress);
flashAddress += 2;
sizeX = *((FLASH_WORD *)flashAddress);
flashAddress += 2;
// Read pallete
for(counter = 0; counter < 256; counter++)
{
pallete[counter] = *((FLASH_WORD *)flashAddress);
flashAddress += 2;
}
DeviceSelect();
for(y = 0; y < sizeY; y++)
{
tempFlashAddress = flashAddress;
for(stretchY = 0; stretchY < stretch; stretchY++)
{
flashAddress = tempFlashAddress;
SetAddress(address);
for(x = 0; x < sizeX; x++)
{
// Read pixels from flash
temp = *flashAddress;
flashAddress++;
// Set color
SetColor(pallete[temp]);
// Write pixel to screen
for(stretchX = 0; stretchX < stretch; stretchX++)
{
DeviceWrite(_color.v[1]);
DeviceWrite(_color.v[0]);
}
}
address += LINE_MEM_PITCH;
}
}
DeviceDeselect();
}
/*********************************************************************
* Function: void PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
* stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs hicolor image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch)
{
register DWORD address;
register FLASH_WORD *flashAddress;
register FLASH_WORD *tempFlashAddress;
WORD sizeX, sizeY;
register WORD x, y;
WORD temp;
register BYTE stretchX, stretchY;
// Move pointer to size information
flashAddress = (FLASH_WORD *)bitmap + 1;
// Set start address
address.Val = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;
// Read image size
sizeY = *flashAddress;
flashAddress++;
sizeX = *flashAddress;
flashAddress++;
DeviceSelect();
for(y = 0; y < sizeY; y++)
{
tempFlashAddress = flashAddress;
for(stretchY = 0; stretchY < stretch; stretchY++)
{
flashAddress = tempFlashAddress;
SetAddress(address);
for(x = 0; x < sizeX; x++)
{
// Read pixels from flash
temp = *flashAddress;
flashAddress++;
// Set color
SetColor(temp);
// Write pixel to screen
for(stretchX = 0; stretchX < stretch; stretchX++)
{
DeviceWrite(_color.v[1]);
DeviceWrite(_color.v[0]);
}
}
address += LINE_MEM_PITCH;
}
}
DeviceDeselect();
}
#endif
#ifdef USE_BITMAP_EXTERNAL
/*********************************************************************
* Function: void PutImage1BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
* stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs monochrome image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage1BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch)
{
register DWORD address;
register DWORD memOffset;
BITMAP_HEADER bmp;
WORD pallete[2];
BYTE lineBuffer[320 / 8];
BYTE *pData;
SHORT byteWidth;
BYTE temp;
BYTE mask;
WORD sizeX, sizeY;
WORD x, y;
BYTE stretchX, stretchY;
// Set start address
address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;
// Get bitmap header
ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp);
// Get pallete (2 entries)
ExternalMemoryCallback(bitmap, sizeof(BITMAP_HEADER), 2 * sizeof(WORD), pallete);
// Set offset to the image data
memOffset = sizeof(BITMAP_HEADER) + 2 * sizeof(WORD);
// Line width in bytes
byteWidth = bmp.width >> 3;
if(bmp.width & 0x0007)
byteWidth++;
// Get size
sizeX = bmp.width;
sizeY = bmp.height;
DeviceSelect();
for(y = 0; y < sizeY; y++)
{
// Get line
ExternalMemoryCallback(bitmap, memOffset, byteWidth, lineBuffer);
memOffset += byteWidth;
for(stretchY = 0; stretchY < stretch; stretchY++)
{
pData = lineBuffer;
SetAddress(address);
mask = 0;
for(x = 0; x < sizeX; x++)
{
// Read 8 pixels from flash
if(mask == 0)
{
temp = *pData++;
mask = 0x80;
}
// Set color
if(mask & temp)
{
SetColor(pallete[1]);
}
else
{
SetColor(pallete[0]);
}
// Write pixel to screen
for(stretchX = 0; stretchX < stretch; stretchX++)
{
DeviceWrite(_color.v[1]);
DeviceWrite(_color.v[0]);
}
// Shift to the next pixel
mask >>= 1;
}
address += LINE_MEM_PITCH;
}
}
DeviceDeselect();
}
/*********************************************************************
* Function: void PutImage4BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
* stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs monochrome image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage4BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch)
{
register DWORD address;
register DWORD memOffset;
BITMAP_HEADER bmp;
WORD pallete[16];
BYTE lineBuffer[320 / 2];
BYTE *pData;
SHORT byteWidth;
BYTE temp;
WORD sizeX, sizeY;
WORD x, y;
BYTE stretchX, stretchY;
// Set start address
address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;
// Get bitmap header
ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp);
// Get pallete (16 entries)
ExternalMemoryCallback(bitmap, sizeof(BITMAP_HEADER), 16 * sizeof(WORD), pallete);
// Set offset to the image data
memOffset = sizeof(BITMAP_HEADER) + 16 * sizeof(WORD);
// Line width in bytes
byteWidth = bmp.width >> 1;
if(bmp.width & 0x0001)
byteWidth++;
// Get size
sizeX = bmp.width;
sizeY = bmp.height;
for(y = 0; y < sizeY; y++)
{
// Get line
ExternalMemoryCallback(bitmap, memOffset, byteWidth, lineBuffer);
memOffset += byteWidth;
DeviceSelect();
for(stretchY = 0; stretchY < stretch; stretchY++)
{
pData = lineBuffer;
SetAddress(address);
for(x = 0; x < sizeX; x++)
{
// Read 2 pixels from flash
if(x & 0x0001)
{
// second pixel in byte
SetColor(pallete[temp & 0x0f]);
}
else
{
temp = *pData++;
// first pixel in byte
SetColor(pallete[temp >> 4]);
}
// Write pixel to screen
for(stretchX = 0; stretchX < stretch; stretchX++)
{
DeviceWrite(_color.v[1]);
DeviceWrite(_color.v[0]);
}
}
address += LINE_MEM_PITCH;
}
DeviceDeselect();
}
}
/*********************************************************************
* Function: void PutImage8BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
* stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs monochrome image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage8BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch)
{
register DWORD address;
register DWORD memOffset;
BITMAP_HEADER bmp;
WORD pallete[256];
BYTE lineBuffer[320];
BYTE *pData;
BYTE temp;
WORD sizeX, sizeY;
WORD x, y;
BYTE stretchX, stretchY;
// Set start address
address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;
// Get bitmap header
ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp);
// Get pallete (256 entries)
ExternalMemoryCallback(bitmap, sizeof(BITMAP_HEADER), 256 * sizeof(WORD), pallete);
// Set offset to the image data
memOffset = sizeof(BITMAP_HEADER) + 256 * sizeof(WORD);
// Get size
sizeX = bmp.width;
sizeY = bmp.height;
for(y = 0; y < sizeY; y++)
{
// Get line
ExternalMemoryCallback(bitmap, memOffset, sizeX, lineBuffer);
memOffset += sizeX;
DeviceSelect();
for(stretchY = 0; stretchY < stretch; stretchY++)
{
pData = lineBuffer;
SetAddress(address);
for(x = 0; x < sizeX; x++)
{
temp = *pData++;
SetColor(pallete[temp]);
// Write pixel to screen
for(stretchX = 0; stretchX < stretch; stretchX++)
{
DeviceWrite(_color.v[1]);
DeviceWrite(_color.v[0]);
}
}
address += LINE_MEM_PITCH;
}
DeviceDeselect();
}
}
/*********************************************************************
* Function: void PutImage8BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
* stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs monochrome image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage16BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch)
{
register DWORD address;
register DWORD memOffset;
BITMAP_HEADER bmp;
WORD lineBuffer[320];
WORD *pData;
WORD byteWidth;
WORD temp;
WORD sizeX, sizeY;
WORD x, y;
BYTE stretchX, stretchY;
// Set start address
address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;
// Get bitmap header
ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp);
// Set offset to the image data
memOffset = sizeof(BITMAP_HEADER);
// Get size
sizeX = bmp.width;
sizeY = bmp.height;
byteWidth = sizeX << 1;
for(y = 0; y < sizeY; y++)
{
// Get line
ExternalMemoryCallback(bitmap, memOffset, byteWidth, lineBuffer);
memOffset += byteWidth;
DeviceSelect();
for(stretchY = 0; stretchY < stretch; stretchY++)
{
pData = lineBuffer;
SetAddress(address);
for(x = 0; x < sizeX; x++)
{
temp = *pData++;
SetColor(temp);
// Write pixel to screen
for(stretchX = 0; stretchX < stretch; stretchX++)
{
DeviceWrite(_color.v[1]);
DeviceWrite(_color.v[0]);
}
}
address += LINE_MEM_PITCH;
}
DeviceDeselect();
}
}
#endif
|