wonx/WWLCDPanel.c
Hiroaki Sakai d3f3c6903d Corresponding to colorization. Added XColorGC class for GC management. (It diverted from XFireworks)
Corresponding to colorization, transparent (transparent color) judgment processing from the WWPalette class
I moved to the WWDisplay class.

Changed the pixel of WWLCDPanel to unsigned short int *.  (Color correspondence)

Change the storage format of text fonts.  (WWTextFonts.c)

In text display, when displaying WWDisplay_GetForegroundColor (),
Fix to copy by looking at WWDisplay_GetBackgroundColor ().  (WWText.c)
(It is no longer necessary to reserve an array of WWCharacter in the WWText class,
Which to delete)

Added palette of border color to WWDisplay class.

We made correspondence to colorization, and added other various corrections.
(Character data storage method, text display, border color processing etc)

With display_control (), display_status (), the bit shift of the border color
Fixed a bug that was 7.  (Fixed to 8)

Key input such as F1 is also accepted during loop waiting for interrupt in while (1) {/ * none * /}
Fixed as.  (WonXSystem.c's timer interrupt callback function
Add WonXDisplay_PrintData () to WonXTimer_Callback ())

Added fcntl_attention.h, filesys.h, indirect.h, oswork.h, process.h.
(Just include the contents or include appropriate files)

In wonx_configure.h,
Fixed a bug that was supposed to be.

Version 2.0 - from wonx-2.0.tar.gz
2018-03-07 23:07:10 +00:00

143 lines
4.4 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#include "WWLCDPanelP.h"
#include "WonX.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); }
int WWLCDPanel_ResetCurrent(WWLCDPanel p)
{
return (p->current = 0);
}
int WWLCDPanel_ReverseCurrent(WWLCDPanel p)
{
return (p->current = 1 - p->current);
}
int WWLCDPanel_ResetAllDraw(WWLCDPanel p) { return (p->all_draw = 0); }
int WWLCDPanel_SetAllDraw(WWLCDPanel p) { return (p->all_draw = 1); }
int WWLCDPanel_IsAllDraw(WWLCDPanel p) { return (p->all_draw); }
unsigned short int * WWLCDPanel_GetPixelMap(WWLCDPanel p)
{
return (p->pixel[p->current]);
}
/* LCDはピクセル4096色(12ビット必要) */
static unsigned short int WWLCDPanel_GetPixelByCurrent(WWLCDPanel lcd_panel,
int current,
int x, int y)
{
unsigned short int pixel;
if ( (x < 0) || (x > WWLCDPanel_GetWidth( lcd_panel) - 1) ||
(y < 0) || (y > WWLCDPanel_GetHeight(lcd_panel) - 1) )
return (-1);
pixel = lcd_panel->pixel[current][y * WWLCDPanel_GetWidth(lcd_panel) + x];
return ((int)pixel);
}
static unsigned short int WWLCDPanel_GetOldPixel(WWLCDPanel lcd_panel,
int x, int y)
{
return (WWLCDPanel_GetPixelByCurrent(lcd_panel,
1 - lcd_panel->current, x, y));
}
unsigned short int WWLCDPanel_GetPixel(WWLCDPanel lcd_panel, int x, int y)
{
return (WWLCDPanel_GetPixelByCurrent(lcd_panel, lcd_panel->current, x, y));
}
unsigned short int WWLCDPanel_SetPixel(WWLCDPanel lcd_panel, int x, int y,
unsigned short int pixel)
{
unsigned short int p;
int n;
if ( (x < 0) || (x > WWLCDPanel_GetWidth( lcd_panel) - 1) ||
(y < 0) || (y > WWLCDPanel_GetHeight(lcd_panel) - 1) )
return (-1);
p = pixel & 0x0fff;
n = y * WWLCDPanel_GetWidth(lcd_panel) + x;
lcd_panel->pixel[lcd_panel->current][n] = p;
return (p);
}
int WWLCDPanel_IsPixelChanged(WWLCDPanel lcd_panel, int x, int y)
{
unsigned short int old_pixel;
unsigned short int current_pixel;
if (WWLCDPanel_IsAllDraw(lcd_panel)) return (1);
old_pixel = WWLCDPanel_GetOldPixel(lcd_panel, x, y);
current_pixel = WWLCDPanel_GetPixel(lcd_panel, x, y);
return (!(old_pixel == current_pixel));
}
WWLCDPanel WWLCDPanel_Create(int width, int height)
{
WWLCDPanel lcd_panel;
int x, y, i;
unsigned short int * p;
lcd_panel = (WWLCDPanel)malloc(sizeof(_WWLCDPanel));
if (lcd_panel == NULL)
WonX_Error("WWLCDPanel_Create", "Cannot allocate memory.");
WWLCDPanel_SetWidth( lcd_panel, width);
WWLCDPanel_SetHeight(lcd_panel, height);
for (i = 0; i < 2; i++) {
p = (unsigned short int *)malloc(sizeof(unsigned short int) *
WWLCDPanel_GetWidth(lcd_panel) *
WWLCDPanel_GetHeight(lcd_panel));
if (p == NULL) WonX_Error("WWLCDPanel_Create", "Cannot allocate memory.");
lcd_panel->pixel[i] = p;
}
for (y = 0; y < lcd_panel->height; y++) {
for (x = 0; x < lcd_panel->width / 2; x++) {
WWLCDPanel_SetPixel(lcd_panel, x, y, 0);
}
}
WWLCDPanel_ResetCurrent(lcd_panel);
WWLCDPanel_SetAllDraw(lcd_panel); /* 初回は全画面を描画する */
return (lcd_panel);
}
WWLCDPanel WWLCDPanel_Destroy(WWLCDPanel lcd_panel)
{
int i;
if (lcd_panel == NULL) return (NULL);
for (i = 0; i < 2; i++) {
if (lcd_panel->pixel[i]) free(lcd_panel->pixel[i]);
}
free(lcd_panel);
return (NULL);
}
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/