Changed method of storing WWLCDPanel data. (I made 1 byte allocated with 1 pixel as 1 byte with 2 pixels) (For speeding up, thought about future color correspondence (241 colors?)) Added WonxDisplay_Sync (). Reduced wasteful drawing in functions of get type. Implement sprite window function. (Not tested) Implement time related functions. (timer.c) Fix sprite priority. (I modified "Priority is given to younger one") Version 0.0.4 alpha - from wonx-a04.tar.gz
87 lines
2.9 KiB
C
87 lines
2.9 KiB
C
/*****************************************************************************/
|
||
/* ここから */
|
||
/*****************************************************************************/
|
||
|
||
#include "WWLCDPanelP.h"
|
||
|
||
/*****************************************************************************/
|
||
/* メンバ関数の定義 */
|
||
/*****************************************************************************/
|
||
|
||
int WWLCDPanel_GetWidth( WWLCDPanel p) { return (p->width ); }
|
||
int WWLCDPanel_GetHeight(WWLCDPanel p) { return (p->height); }
|
||
int WWLCDPanel_SetWidth( WWLCDPanel p, int n) { return (p->width = n); }
|
||
int WWLCDPanel_SetHeight(WWLCDPanel p, int n) { return (p->height = n); }
|
||
|
||
unsigned char * WWLCDPanel_GetPixelMap(WWLCDPanel p) { return (p->pixel); }
|
||
|
||
/* LCDは1ピクセル16色(4ビット必要) */
|
||
int WWLCDPanel_GetPixel(WWLCDPanel lcd_panel, int x, int y)
|
||
{
|
||
unsigned char pixel;
|
||
|
||
if ( (x < 0) || (x > WWLCDPanel_GetWidth(lcd_panel) - 1) ||
|
||
(y < 0) || (y > WWLCDPanel_GetHeight(lcd_panel) - 1) )
|
||
return (-1);
|
||
|
||
pixel = lcd_panel->pixel[y * WWLCDPanel_GetWidth(lcd_panel) + x];
|
||
pixel &= 0x0f;
|
||
return ((int)pixel);
|
||
}
|
||
|
||
int WWLCDPanel_SetPixel(WWLCDPanel lcd_panel, int x, int y, int pixel)
|
||
{
|
||
unsigned char p;
|
||
int n;
|
||
|
||
if ( (x < 0) || (x > WWLCDPanel_GetWidth(lcd_panel) - 1) ||
|
||
(y < 0) || (y > WWLCDPanel_GetHeight(lcd_panel) - 1) )
|
||
return (-1);
|
||
|
||
p = ((unsigned char)pixel) & 0x0f;
|
||
n = y * WWLCDPanel_GetWidth(lcd_panel) + x;
|
||
lcd_panel->pixel[n] = p;
|
||
|
||
return (pixel);
|
||
}
|
||
|
||
WWLCDPanel WWLCDPanel_Create(int width, int height)
|
||
{
|
||
WWLCDPanel lcd_panel;
|
||
int x, y;
|
||
|
||
lcd_panel = (WWLCDPanel)malloc(sizeof(_WWLCDPanel));
|
||
if (lcd_panel == NULL) Error("WWLCDPanel_Create", "Cannot allocate memory.");
|
||
|
||
WWLCDPanel_SetWidth( lcd_panel, width);
|
||
WWLCDPanel_SetHeight(lcd_panel, height);
|
||
lcd_panel->pixel =
|
||
(unsigned char *)malloc(sizeof(unsigned char) *
|
||
WWLCDPanel_GetWidth(lcd_panel) *
|
||
WWLCDPanel_GetHeight(lcd_panel));
|
||
|
||
for (y = 0; y < lcd_panel->height; y++) {
|
||
for (x = 0; x < lcd_panel->width / 2; x++) {
|
||
WWLCDPanel_SetPixel(lcd_panel, x, y, 0x00);
|
||
}
|
||
}
|
||
|
||
return (lcd_panel);
|
||
}
|
||
|
||
WWLCDPanel WWLCDPanel_Destroy(WWLCDPanel lcd_panel)
|
||
{
|
||
if (lcd_panel == NULL) return (NULL);
|
||
if (lcd_panel->pixel) free(lcd_panel->pixel);
|
||
free(lcd_panel);
|
||
return (NULL);
|
||
}
|
||
|
||
/*****************************************************************************/
|
||
/* ここまで */
|
||
/*****************************************************************************/
|
||
|
||
/*****************************************************************************/
|
||
/* End of File. */
|
||
/*****************************************************************************/
|