📄 hal_graphics.c
字号:
/***************************************************************
* Copyright(C) 2003--2006
* Epson Electronic Technology Development (ShenZhen) co., LTD
* All rights reserved.
*
* File name: Graphics.c
* Author: Eric Ding
* Dept: Electronic Enginerring Department
* Date: 03/19/2003
* Descriptions:the Graphic processing module
* Notes:
* Modified:
***************************************************************/
static unsigned long gUseIndirectMode = FALSE;
static unsigned long gStride = 0; //
static unsigned long gAddr = 0; //
static unsigned long gOffset = 0; //
static unsigned long gBitsPerPixel =0; //
static void (*gpfnPixel)(long ,long ,unsigned long );
static void (*gpfnLine)(long ,long ,long ,long ,unsigned long );
static const char aCharSet8[] = // This is the ASCII table
{
'\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', // (SPACE)
'\x30', '\x78', '\x78', '\x30', '\x30', '\x00', '\x30', '\x00', // !
'\x6C', '\x6C', '\x6C', '\x00', '\x00', '\x00', '\x00', '\x00', // "
'\x6C', '\x6C', '\xFE', '\x6C', '\xFE', '\x6C', '\x6C', '\x00', // #
'\x30', '\x7C', '\xC0', '\x78', '\x0C', '\xF8', '\x30', '\x00', // $
'\x00', '\xC6', '\xCC', '\x18', '\x30', '\x66', '\xC6', '\x00', // %
'\x38', '\x6C', '\x38', '\x76', '\xDC', '\xCC', '\x76', '\x00', // &
'\x60', '\x60', '\xC0', '\x00', '\x00', '\x00', '\x00', '\x00', // '
'\x18', '\x30', '\x60', '\x60', '\x60', '\x30', '\x18', '\x00', // (
'\x60', '\x30', '\x18', '\x18', '\x18', '\x30', '\x60', '\x00', // )
'\x00', '\x66', '\x3C', '\xFF', '\x3C', '\x66', '\x00', '\x00', // *
'\x00', '\x30', '\x30', '\xFC', '\x30', '\x30', '\x00', '\x00', // +
'\x00', '\x00', '\x00', '\x00', '\x00', '\x30', '\x30', '\x60', // ',
'\x00', '\x00', '\x00', '\xFC', '\x00', '\x00', '\x00', '\x00', // -
'\x00', '\x00', '\x00', '\x00', '\x00', '\x30', '\x30', '\x00', // .
'\x06', '\x0C', '\x18', '\x30', '\x60', '\xC0', '\x80', '\x00', // /
'\x7C', '\xC6', '\xCE', '\xDE', '\xF6', '\xE6', '\x7C', '\x00', // 0
'\x30', '\x70', '\x30', '\x30', '\x30', '\x30', '\xFC', '\x00', // 1
'\x78', '\xCC', '\x0C', '\x38', '\x60', '\xCC', '\xFC', '\x00', // 2
'\x78', '\xCC', '\x0C', '\x38', '\x0C', '\xCC', '\x78', '\x00', // 3
'\x1C', '\x3C', '\x6C', '\xCC', '\xFE', '\x0C', '\x1E', '\x00', // 4
'\xFC', '\xC0', '\xF8', '\x0C', '\x0C', '\xCC', '\x78', '\x00', // 5
'\x38', '\x60', '\xC0', '\xF8', '\xCC', '\xCC', '\x78', '\x00', // 6
'\xFC', '\xCC', '\x0C', '\x18', '\x30', '\x30', '\x30', '\x00', // 7
'\x78', '\xCC', '\xCC', '\x78', '\xCC', '\xCC', '\x78', '\x00', // 8
'\x78', '\xCC', '\xCC', '\x7C', '\x0C', '\x18', '\x70', '\x00', // 9
'\x00', '\x30', '\x30', '\x00', '\x00', '\x30', '\x30', '\x00', // :
'\x00', '\x30', '\x30', '\x00', '\x00', '\x30', '\x30', '\x60', // ;
'\x18', '\x30', '\x60', '\xC0', '\x60', '\x30', '\x18', '\x00', // <
'\x00', '\x00', '\xFC', '\x00', '\x00', '\xFC', '\x00', '\x00', // =
'\x60', '\x30', '\x18', '\x0C', '\x18', '\x30', '\x60', '\x00', // >
'\x78', '\xCC', '\x0C', '\x18', '\x30', '\x00', '\x30', '\x00', // ?
'\x7C', '\xC6', '\xDE', '\xDE', '\xDE', '\xC0', '\x78', '\x00', // @
'\x30', '\x78', '\xCC', '\xCC', '\xFC', '\xCC', '\xCC', '\x00', // A
'\xFC', '\x66', '\x66', '\x7C', '\x66', '\x66', '\xFC', '\x00', // B
'\x3C', '\x66', '\xC0', '\xC0', '\xC0', '\x66', '\x3C', '\x00', // C
'\xF8', '\x6C', '\x66', '\x66', '\x66', '\x6C', '\xF8', '\x00', // D
'\xFE', '\x62', '\x68', '\x78', '\x68', '\x62', '\xFE', '\x00', // E
'\xFE', '\x62', '\x68', '\x78', '\x68', '\x60', '\xF0', '\x00', // F
'\x3C', '\x66', '\xC0', '\xC0', '\xCE', '\x66', '\x3E', '\x00', // G
'\xCC', '\xCC', '\xCC', '\xFC', '\xCC', '\xCC', '\xCC', '\x00', // H
'\x78', '\x30', '\x30', '\x30', '\x30', '\x30', '\x78', '\x00', // I
'\x1E', '\x0C', '\x0C', '\x0C', '\xCC', '\xCC', '\x78', '\x00', // J
'\xE6', '\x66', '\x6C', '\x78', '\x6C', '\x66', '\xE6', '\x00', // K
'\xF0', '\x60', '\x60', '\x60', '\x62', '\x66', '\xFE', '\x00', // L
'\xC6', '\xEE', '\xFE', '\xFE', '\xD6', '\xC6', '\xC6', '\x00', // M
'\xC6', '\xE6', '\xF6', '\xDE', '\xCE', '\xC6', '\xC6', '\x00', // N
'\x38', '\x6C', '\xC6', '\xC6', '\xC6', '\x6C', '\x38', '\x00', // O
'\xFC', '\x66', '\x66', '\x7C', '\x60', '\x60', '\xF0', '\x00', // P
'\x78', '\xCC', '\xCC', '\xCC', '\xDC', '\x78', '\x1C', '\x00', // Q
'\xFC', '\x66', '\x66', '\x7C', '\x6C', '\x66', '\xE6', '\x00', // R
'\x78', '\xCC', '\xE0', '\x70', '\x1C', '\xCC', '\x78', '\x00', // S
'\xFC', '\xB4', '\x30', '\x30', '\x30', '\x30', '\x78', '\x00', // T
'\xCC', '\xCC', '\xCC', '\xCC', '\xCC', '\xCC', '\xFC', '\x00', // U
'\xCC', '\xCC', '\xCC', '\xCC', '\xCC', '\x78', '\x30', '\x00', // V
'\xC6', '\xC6', '\xC6', '\xD6', '\xFE', '\xEE', '\xC6', '\x00', // W
'\xC6', '\xC6', '\x6C', '\x38', '\x38', '\x6C', '\xC6', '\x00', // X
'\xCC', '\xCC', '\xCC', '\x78', '\x30', '\x30', '\x78', '\x00', // Y
'\xFE', '\xC6', '\x8C', '\x18', '\x32', '\x66', '\xFE', '\x00', // Z
'\x78', '\x60', '\x60', '\x60', '\x60', '\x60', '\x78', '\x00', // [
'\xC0', '\x60', '\x30', '\x18', '\x0C', '\x06', '\x02', '\x00', // \
'\x78', '\x18', '\x18', '\x18', '\x18', '\x18', '\x78', '\x00', // ]
'\x10', '\x38', '\x6C', '\xC6', '\x00', '\x00', '\x00', '\x00', // ^
'\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\xFF', // _
'\x30', '\x30', '\x18', '\x00', '\x00', '\x00', '\x00', '\x00', // `
'\x00', '\x00', '\x78', '\x0C', '\x7C', '\xCC', '\x76', '\x00', // a
'\xE0', '\x60', '\x60', '\x7C', '\x66', '\x66', '\xDC', '\x00', // b
'\x00', '\x00', '\x78', '\xCC', '\xC0', '\xCC', '\x78', '\x00', // c
'\x1C', '\x0C', '\x0C', '\x7C', '\xCC', '\xCC', '\x76', '\x00', // d
'\x00', '\x00', '\x78', '\xCC', '\xFC', '\xC0', '\x78', '\x00', // e
'\x38', '\x6C', '\x60', '\xF0', '\x60', '\x60', '\xF0', '\x00', // f
'\x00', '\x00', '\x76', '\xCC', '\xCC', '\x7C', '\x0C', '\xF8', // g
'\xE0', '\x60', '\x6C', '\x76', '\x66', '\x66', '\xE6', '\x00', // h
'\x30', '\x00', '\x70', '\x30', '\x30', '\x30', '\x78', '\x00', // i
'\x0C', '\x00', '\x0C', '\x0C', '\x0C', '\xCC', '\xCC', '\x78', // j
'\xE0', '\x60', '\x66', '\x6C', '\x78', '\x6C', '\xE6', '\x00', // k
'\x70', '\x30', '\x30', '\x30', '\x30', '\x30', '\x78', '\x00', // l
'\x00', '\x00', '\xCC', '\xFE', '\xFE', '\xD6', '\xC6', '\x00', // m
'\x00', '\x00', '\xF8', '\xCC', '\xCC', '\xCC', '\xCC', '\x00', // n
'\x00', '\x00', '\x78', '\xCC', '\xCC', '\xCC', '\x78', '\x00', // o
'\x00', '\x00', '\xDC', '\x66', '\x66', '\x7C', '\x60', '\xF0', // p
'\x00', '\x00', '\x76', '\xCC', '\xCC', '\x7C', '\x0C', '\x1E', // q
'\x00', '\x00', '\xDC', '\x76', '\x66', '\x60', '\xF0', '\x00', // r
'\x00', '\x00', '\x7C', '\xC0', '\x78', '\x0C', '\xF8', '\x00', // s
'\x10', '\x30', '\x7C', '\x30', '\x30', '\x34', '\x18', '\x00', // t
'\x00', '\x00', '\xCC', '\xCC', '\xCC', '\xCC', '\x76', '\x00', // u
'\x00', '\x00', '\xCC', '\xCC', '\xCC', '\x78', '\x30', '\x00', // v
'\x00', '\x00', '\xC6', '\xD6', '\xFE', '\xFE', '\x6C', '\x00', // w
'\x00', '\x00', '\xC6', '\x6C', '\x38', '\x6C', '\xC6', '\x00', // x
'\x00', '\x00', '\xCC', '\xCC', '\xCC', '\x7C', '\x0C', '\xF8', // y
'\x00', '\x00', '\xFC', '\x98', '\x30', '\x64', '\xFC', '\x00', // z
'\x1C', '\x30', '\x30', '\xE0', '\x30', '\x30', '\x1C', '\x00', // {
'\x18', '\x18', '\x18', '\x00', '\x18', '\x18', '\x18', '\x00', // |
'\xE0', '\x30', '\x30', '\x1C', '\x30', '\x30', '\xE0', '\x00', // }
'\x76', '\xDC', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', // ~
'\xFF', '\xFF', '\xFF', '\xFF', '\xFF', '\xFF', '\xFF', '\xFF' // (SOLID BOX)
};
/***************************************************************************************/
/***************************************************************************************/
static void _vramPixel8bpp(long x, long y, unsigned long color32)
{
unsigned long offset;
offset = gOffset + (y * gStride) + x;
halWriteDisplay8(offset, (UCHAR)(color32 & 0xff));
}
static void _Pixel8bpp(long x, long y, unsigned long color32)
{
VOLATILE UCHAR * bpt;
bpt = (VOLATILE UCHAR *) (gAddr + y * gStride + x);
*bpt = (UCHAR) (color32 & 0xff);
}
static void _vramLine8bpp(long x1, long y1, long x2, long y2, unsigned long color32)
{
long x,y;
UCHAR color8 = (UCHAR) (color32 & 0xff);
unsigned long offset = 0;
offset = gOffset + (y1 * gStride) + x1;
if (y1 == y2) // horiz. line
for(x=x1;x<x2;x++)
halWriteDisplay8(offset, color8);
else if (x1 == x2) // vert. line
for (y = y1; y <= y2; y++, offset += gStride)
halWriteDisplay8(offset, color8);
}
static void _Line8bpp(long x1, long y1, long x2, long y2, unsigned long color32)
{
long x, y;
UCHAR color8 = (UCHAR) (color32 & 0xff);
VOLATILE UCHAR * bpt = 0;
bpt = (VOLATILE UCHAR *) (gAddr + (y1 * gStride) + x1);
if (y1 == y2) // horiz. line
for (x = x1; x <= x2; x++)
*bpt++ = color8;
else if (x1 == x2) // vert. line
for (y = y1; y <= y2; y++, bpt += gStride)
*bpt = color8;
}
static void _vramPixel16bpp(long x, long y, unsigned long color32)
{
unsigned long offset;
offset = gOffset + (y * gStride) + (x * 2);
halWriteDisplay16(offset, (USHORT) (color32 & 0xffff));
}
static void _Pixel16bpp(long x, long y, unsigned long color32)
{
VOLATILE USHORT * wpt;
wpt = (VOLATILE USHORT *) (gAddr + (y * gStride) + (x * 2));
*wpt = (USHORT) (color32 & 0xffff);
}
static void _vramLine16bpp(long x1, long y1, long x2, long y2, unsigned long color32)
{
long x,y;
USHORT color16 = (USHORT) (color32 & 0xffff);
unsigned long offset = 0;
offset = gOffset + (y1 * gStride) + (x1 * 2);
if (y1 == y2) // horiz. line
for (x = x1; x <= x2; x++)
halWriteDisplay16(offset, color16);
else if (x1 == x2) // vert. line
for (y = y1; y <= y2; y++, offset += gStride)
halWriteDisplay16(offset, color16);
}
static void _Line16bpp(long x1, long y1, long x2, long y2, unsigned long color32)
{
long x, y;
unsigned long WordsPerScanline = gStride / 2;
USHORT color16 = (USHORT) (color32 & 0xffff);
VOLATILE USHORT * wpt = 0;
wpt = (VOLATILE USHORT *) (gAddr + (y1 * gStride) + (x1 * 2));
if (y1 == y2) // horiz. line
for (x = x1; x <= x2; x++)
*wpt++ = color16;
else if (x1 == x2) // vert. line
for (y = y1; y <= y2; y++, wpt += WordsPerScanline)
*wpt = color16;
}
static void _vramPixel32bpp(long x, long y, unsigned long color32)
{
unsigned long offset;
offset = gOffset + (y*gStride) + (x*4);
halWriteDisplay32(offset, color32);
}
static void _Pixel32bpp(long x, long y, unsigned long color32)
{
VOLATILE unsigned long * dpt;
dpt = (VOLATILE unsigned long *) (gAddr + (y*gStride) + (x*4));
*dpt = color32;
}
static void _vramLine32bpp(long x1, long y1, long x2, long y2, unsigned long color32)
{
long x,y;
unsigned long offset = 0;
offset = gOffset + (y1 * gStride) + (x1 * 4);
if (y1 == y2) // horiz. line
for (x = x1; x <= x2; x++)
halWriteDisplay32(offset, color32);
else if (x1 == x2) // vert. line
for (y = y1; y <= y2; y++, offset += gStride)
halWriteDisplay32(offset, color32);
}
static void _Line32bpp(long x1, long y1, long x2, long y2, unsigned long color32)
{
long x, y;
unsigned long DwordsPerScanline = gStride / 4;
VOLATILE unsigned long * dpt = 0;
dpt = (VOLATILE unsigned long *) (gAddr + (y1 * gStride) + (x1 * 4));
if (y1 == y2) // horiz. line
for (x = x1; x <= x2; x++)
*dpt++ = color32;
else if (x1 == x2) // vert. line
for (y = y1; y <= y2; y++, dpt += DwordsPerScanline)
*dpt = color32;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -