www.pudn.com > uCGUI3.24-MemDev-for-3.90a.rar > GUIDEV_CmpWithLCD.c
/*! @file GUIDEV_CmpWithLCD.c * Implementation of Checking for memory devices * * @author hiber modified * @author Copyleft (C) 1981-2006, All Rights Givenup * @date 04/18/2006 * @version * * @note * @attention * @warning * @bug * * @todo * @example* @see */ #include #include "GUI_Private.h" #include "GUIDebug.h" #if GUI_SUPPORT_MEMDEV extern void * _GUI_ALLOC_h2p_Lock(GUI_HMEM hMem); #define GUI_ALLOC_H2P(h) _GUI_ALLOC_h2p_Lock(h) #define GUI_ALLOC_FREE(handle) GUI_ALLOC_Free(handle) #define GUI_ALLOC_LOCK(handle) _GUI_ALLOC_h2p_Lock(handle) #define GUI_ALLOC_UNLOCK(handle) #ifdef GUI_USAGE_H2P #undef GUI_USAGE_H2P #define GUI_USAGE_H2P(h) ((GUI_USAGE*)_GUI_ALLOC_h2p_Lock(h)) #endif #ifdef GUI_MEMDEV_H2P #undef GUI_MEMDEV_H2P #define GUI_MEMDEV_H2P _GUI_ALLOC_h2p_Lock #endif ////////////////////////////////////////////////////////////////////////// //! 将存储设备数据和LCD的数据进行比较 int GUI_MEMDEV_CompareWithLCD(GUI_MEMDEV_Handle hMem, int *px, int *py, int *pExp, int *pAct) { /* Make sure memory handle is valid */ if (!hMem) { hMem = GUI_Context.hDevData; } if (!hMem) { return 1; } // 大括号... { GUI_MEMDEV *pDevData = (GUI_MEMDEV*)GUI_ALLOC_LOCK(hMem); /* Convert to pointer */ int y = pDevData->y0; int x0 = pDevData->x0; int XMax = pDevData->XSize + x0; int YMax = pDevData->YSize + y; int Max; int MagX = LCD_GetXMag(); int MagY = LCD_GetYMag(); /* Calculate limits */ if (y < 0) { y = 0; } if (x0 < 0) { x0 = 0; } Max = LCD_GET_YSIZE(); if (YMax > Max) { YMax = Max; } Max = LCD_GET_XSIZE(); if (XMax > Max) { XMax = Max; } for (; y < YMax; y++) { int x = x0; LCD_PIXELINDEX *pData = (LCD_PIXELINDEX *)GUI_MEMDEV__XY2PTR(x, y); for (x = x0; x < XMax; x++) { int Exp = *pData++; int Act = LCD_L0_GetPixelIndex(x *MagX, y *MagY); if (Act != Exp) { *px = x; *py = y; *pAct = Act; *pExp = Exp; return 1; } } } } GUI_ALLOC_UNLOCK(hMem); return 0; } void GUIDEV_CmpWithLCD(void) { // do nothing... } #else void GUIDEV_CmpWithLCD(void) { /* avoid empty object files */ } #endif /* GUI_SUPPORT_MEMDEV */