hal_curs.c
来自「epson 13506 driver code」· C语言 代码 · 共 1,102 行 · 第 1/2 页
C
1,102 行
unsigned regInkCursorStartAddress;
/*
** Determine start address of cursor.
*/
if (_ActiveImageSurface->DisplayMode & LCD)
regInkCursorStartAddress = seReadRegByte(REG_LCD_INK_CURS_START_ADDR);
else if (_ActiveImageSurface->DisplayMode & (CRT | TV))
regInkCursorStartAddress = seReadRegByte(REG_CRTTV_INK_CURS_START_ADDR);
else // Assume LCD
regInkCursorStartAddress = seReadRegByte(REG_LCD_INK_CURS_START_ADDR);
if (regInkCursorStartAddress == 0)
return _MemorySize - CURSOR_SIZE;
else
return _MemorySize - (regInkCursorStartAddress * 8192L);
}
/*-------------------------------------------------------------------------*/
void seMoveLcdCursor(long x, long y)
{
long abs_x, abs_y, tmp;
unsigned sign_x, sign_y;
unsigned width, height;
seGetLcdResolution(&width, &height);
switch (seGetLcdOrientation())
{
case ROTATE180:
x = width - x - 64;
y = height - y - 64;
break;
case ROTATE90:
tmp = x;
x = y;
y = tmp;
x = height - x - 64;
break;
case ROTATE270:
tmp = x;
x = y;
y = tmp;
y = width - y - 64;
break;
}
if (x < 0)
{
abs_x = -x;
sign_x = 0x8000;
}
else
{
abs_x = x;
sign_x = 0;
}
if (y < 0)
{
abs_y = -y;
sign_y = 0x8000;
}
else
{
abs_y = y;
sign_y = 0;
}
seWriteRegWord(REG_LCD_CURSOR_X_POS0, (abs_x & 0x7fff) | sign_x);
seWriteRegWord(REG_LCD_CURSOR_Y_POS0, (abs_y & 0x7fff) | sign_y);
}
/*-------------------------------------------------------------------------*/
void seMoveCrtCursor(long x, long y)
{
long abs_x, abs_y;
unsigned sign_x, sign_y;
unsigned width, height;
seGetCrtResolution(&width, &height);
if (x < 0)
{
abs_x = -x;
sign_x = 0x8000;
}
else
{
abs_x = x;
sign_x = 0;
}
if (y < 0)
{
abs_y = -y;
sign_y = 0x8000;
}
else
{
abs_y = y;
sign_y = 0;
}
seWriteRegWord(REG_CRTTV_CURSOR_X_POS0, (abs_x & 0x7fff) | sign_x);
seWriteRegWord(REG_CRTTV_CURSOR_Y_POS0, (abs_y & 0x7fff) | sign_y);
}
/*-------------------------------------------------------------------------*/
void seMoveTvCursor(long x, long y)
{
seMoveCrtCursor(x, y);
}
/*-------------------------------------------------------------------------*/
void seMoveCursor(long x, long y)
{
long abs_x, abs_y, tmp;
unsigned sign_x, sign_y;
unsigned width, height;
unsigned DisplayMode;
unsigned orientation;
seGetResolution(&width, &height);
DisplayMode = _ActiveImageSurface->DisplayMode;
if ((DisplayMode & LCD) && !(DisplayMode & (CRT | TV)))
orientation = seGetLcdOrientation();
else
orientation = LANDSCAPE;
switch (orientation)
{
case ROTATE180:
x = width - x - 64;
y = height - y - 64;
break;
case ROTATE90:
tmp = x;
x = y;
y = tmp;
x = height - x - 64;
break;
case ROTATE270:
tmp = x;
x = y;
y = tmp;
y = width - y - 64;
break;
}
if (x < 0)
{
abs_x = -x;
sign_x = 0x8000;
}
else
{
abs_x = x;
sign_x = 0;
}
if (y < 0)
{
abs_y = -y;
sign_y = 0x8000;
}
else
{
abs_y = y;
sign_y = 0;
}
if (_ActiveImageSurface->DisplayMode & LCD)
{
seWriteRegWord(REG_LCD_CURSOR_X_POS0, (abs_x & 0x7fff) | sign_x);
seWriteRegWord(REG_LCD_CURSOR_Y_POS0, (abs_y & 0x7fff) | sign_y);
}
if (_ActiveImageSurface->DisplayMode & (CRT | TV))
{
seWriteRegWord(REG_CRTTV_CURSOR_X_POS0, (abs_x & 0x7fff) | sign_x);
seWriteRegWord(REG_CRTTV_CURSOR_Y_POS0, (abs_y & 0x7fff) | sign_y);
}
}
/*-------------------------------------------------------------------------*/
void seSetLcdCursorColor(int index, DWORD color)
{
switch (index)
{
case 0:
seWriteRegDword(REG_LCD_INK_CURS_BLUE0, color);
break;
case 1:
seWriteRegDword(REG_LCD_INK_CURS_BLUE1, color);
break;
}
}
/*-------------------------------------------------------------------------*/
void seSetCrtCursorColor(int index, DWORD color)
{
switch (index)
{
case 0:
seWriteRegDword(REG_CRTTV_INK_CURS_BLUE0, color);
break;
case 1:
seWriteRegDword(REG_CRTTV_INK_CURS_BLUE1, color);
break;
}
}
/*-------------------------------------------------------------------------*/
void seSetTvCursorColor(int index, DWORD color)
{
seSetCrtCursorColor(index, color);
}
/*-------------------------------------------------------------------------*/
void seSetCursorColor(int index, DWORD color)
{
if (_ActiveImageSurface->DisplayMode & LCD)
seSetLcdCursorColor(index, color);
if (_ActiveImageSurface->DisplayMode & (CRT | TV))
seSetCrtCursorColor(index, color);
}
/*-------------------------------------------------------------------------*/
void seSetLcdCursorPixel(long x, long y, DWORD color)
{
DWORD StartLinearAddress;
unsigned regDisplayMode;
StartLinearAddress = seGetLcdCursorLinearAddress();
/*
** If in rotate90 mode, get out of rotate90 mode.
*/
regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode & ~0x40);
/*
** Each line in the cursor has 64 pixels. Since the cursor
** is in 2 bpp mode, there are 16 bytes per line.
*/
_Pixel2bpp(StartLinearAddress, 16, x, y, color);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
}
/*-------------------------------------------------------------------------*/
void seSetCrtCursorPixel(long x, long y, DWORD color)
{
DWORD StartLinearAddress;
unsigned regDisplayMode;
StartLinearAddress = seGetCrtCursorLinearAddress();
/*
** If in rotate90 mode, get out of rotate90 mode.
*/
regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode & ~0x40);
/*
** Each line in the cursor has 64 pixels. Since the cursor
** is in 2 bpp mode, there are 16 bytes per line.
*/
_Pixel2bpp(StartLinearAddress, 16, x, y, color);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
}
/*-------------------------------------------------------------------------*/
void seSetTvCursorPixel(long x, long y, DWORD color)
{
seSetCrtCursorPixel(x, y, color);
}
/*-------------------------------------------------------------------------*/
void seSetCursorPixel(long x, long y, DWORD color)
{
DWORD StartLinearAddress;
unsigned regDisplayMode;
StartLinearAddress = seGetCursorLinearAddress();
/*
** If in rotate90 mode, get out of rotate90 mode.
*/
regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode & ~0x40);
/*
** Each line in the cursor has 64 pixels. Since the cursor
** is in 2 bpp mode, there are 16 bytes per line.
*/
_Pixel2bpp(StartLinearAddress, 16, x, y, color);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
}
/*-------------------------------------------------------------------------*/
void seDrawLcdCursorLine(long x1, long y1, long x2, long y2, DWORD color)
{
DWORD StartLinearAddress;
unsigned regDisplayMode;
StartLinearAddress = seGetLcdCursorLinearAddress();
/*
** If in rotate90 mode, get out of rotate90 mode.
*/
regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode & ~0x40);
if (x1 > x2)
{
_Swap(&x1, &x2);
_Swap(&y1, &y2);
}
/*
** Each line in the cursor has 64 pixels. Since the cursor
** is in 2 bpp mode, there are 16 bytes per line.
*/
_Line(StartLinearAddress, 16, x1, y1, x2, y2, color, _Pixel2bpp);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
}
/*-------------------------------------------------------------------------*/
void seDrawCrtCursorLine(long x1, long y1, long x2, long y2, DWORD color)
{
DWORD StartLinearAddress;
unsigned regDisplayMode;
StartLinearAddress = seGetCrtCursorLinearAddress();
/*
** If in rotate90 mode, get out of rotate90 mode.
*/
regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode & ~0x40);
if (x1 > x2)
{
_Swap(&x1, &x2);
_Swap(&y1, &y2);
}
/*
** Each line in the cursor has 64 pixels. Since the cursor
** is in 2 bpp mode, there are 16 bytes per line.
*/
_Line(StartLinearAddress, 16, x1, y1, x2, y2, color, _Pixel2bpp);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
}
/*-------------------------------------------------------------------------*/
void seDrawTvCursorLine(long x1, long y1, long x2, long y2, DWORD color)
{
seDrawCrtCursorLine(x1, y1, x2, y2, color);
}
/*-------------------------------------------------------------------------*/
void seDrawCursorLine(long x1, long y1, long x2, long y2, DWORD color)
{
DWORD StartLinearAddress;
unsigned regDisplayMode;
StartLinearAddress = seGetCursorLinearAddress();
/*
** If in rotate90 mode, get out of rotate90 mode.
*/
regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode & ~0x40);
if (x1 > x2)
{
_Swap(&x1, &x2);
_Swap(&y1, &y2);
}
/*
** Each line in the cursor has 64 pixels. Since the cursor
** is in 2 bpp mode, there are 16 bytes per line.
*/
_Line(StartLinearAddress, 16, x1, y1, x2, y2, color, _Pixel2bpp);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
}
/*-------------------------------------------------------------------------*/
void seDrawLcdCursorRect(long x1, long y1, long x2, long y2, DWORD color, BOOL SolidFill)
{
DWORD StartLinearAddress;
void (*linefn)(DWORD,int,long,long,long,long,DWORD);
long y;
unsigned regDisplayMode;
StartLinearAddress = seGetLcdCursorLinearAddress();
/*
** If in rotate90 mode, get out of rotate90 mode.
*/
regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode & ~0x40);
if (y1 > y2)
{
y = y2;
y2 = y1;
y1 = y;
}
linefn = _Line2bpp;
/*
** Each line in the cursor has 64 pixels. Since the cursor
** is in 2 bpp mode, there are 16 bytes per line.
*/
if (SolidFill)
{
for (y = y1; y <= y2; y++)
(*linefn)(StartLinearAddress, 16, x1, y, x2, y, color);
}
else
{
(*linefn)(StartLinearAddress, 16, x1, y1, x2, y1, color);
(*linefn)(StartLinearAddress, 16, x1, y2, x2, y2, color);
(*linefn)(StartLinearAddress, 16, x1, y1, x1, y2, color);
(*linefn)(StartLinearAddress, 16, x2, y1, x2, y2, color);
}
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
}
/*-------------------------------------------------------------------------*/
void seDrawCrtCursorRect(long x1, long y1, long x2, long y2, DWORD color, BOOL SolidFill)
{
DWORD StartLinearAddress;
void (*linefn)(DWORD,int,long,long,long,long,DWORD);
long y;
unsigned regDisplayMode;
StartLinearAddress = seGetCrtCursorLinearAddress();
/*
** If in rotate90 mode, get out of rotate90 mode.
*/
regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode & ~0x40);
if (y1 > y2)
{
y = y2;
y2 = y1;
y1 = y;
}
linefn = _Line2bpp;
/*
** Each line in the cursor has 64 pixels. Since the cursor
** is in 2 bpp mode, there are 16 bytes per line.
*/
if (SolidFill)
{
for (y = y1; y <= y2; y++)
(*linefn)(StartLinearAddress, 16, x1, y, x2, y, color);
}
else
{
(*linefn)(StartLinearAddress, 16, x1, y1, x2, y1, color);
(*linefn)(StartLinearAddress, 16, x1, y2, x2, y2, color);
(*linefn)(StartLinearAddress, 16, x1, y1, x1, y2, color);
(*linefn)(StartLinearAddress, 16, x2, y1, x2, y2, color);
}
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
}
/*-------------------------------------------------------------------------*/
void seDrawTvCursorRect(long x1, long y1, long x2, long y2, DWORD color, BOOL SolidFill)
{
seDrawCrtCursorRect(x1, y1, x2, y2, color, SolidFill);
}
/*-------------------------------------------------------------------------*/
void seDrawCursorRect(long x1, long y1, long x2, long y2, DWORD color, BOOL SolidFill)
{
if (_ActiveImageSurface->DisplayMode & LCD)
seDrawLcdCursorRect(x1, y1, x2, y2, color, SolidFill);
if (_ActiveImageSurface->DisplayMode & (CRT | TV))
seDrawCrtCursorRect(x1, y1, x2, y2, color, SolidFill);
}
/*-------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?