hal_curs.c
来自「epson 13506 driver code」· C语言 代码 · 共 1,102 行 · 第 1/2 页
C
1,102 行
/*
**===========================================================================
** HAL_CURS.C - Hardware cursor support.
**---------------------------------------------------------------------------
** Copyright (c) 1998, 2001 Epson Research and Development, Inc.
** All Rights Reserved.
**===========================================================================
*/
#include "hal.h"
#include "assert.h"
#include "nonsefns.h"
/*-------------------------------------------------------------------------*/
static const char Revision[] = "HAL_CURS.C=$Revision: 17 $";
/*-------------------------------------------------------------------------*/
/*
** The cursor takes up 1024 bytes
*/
#define CURSOR_SIZE 1024
/*-------------------------------------------------------------------------*/
DWORD _InitLcdInkCursorAddress(DWORD InkCursorSize, int SelectInkCursor)
{
unsigned regInkCursorAddress;
/*
** Unallocate memory
*/
regInkCursorAddress = seReadRegByte(REG_LCD_INK_CURS_START_ADDR);
if (regInkCursorAddress == 0)
_LcdInkCursor.OffsetAddress = seGetInstalledMemorySize() - 1024;
else
_LcdInkCursor.OffsetAddress = seGetInstalledMemorySize() - (regInkCursorAddress * 8192L);
if (_LcdInkCursor.LinearAddress == _LcdInkCursor.OffsetAddress + _DispLinearAddress)
seVmemFree(_LcdInkCursor.LinearAddress);
_LcdInkCursor.LinearAddress = 0;
_LcdInkCursor.OffsetAddress = 0;
/*
** Calculate starting address of hardware cursor.
*/
if (SelectInkCursor == INK_LAYER)
{
_LcdInkCursor.LinearAddress = seVmemAllocInk(InkCursorSize);
#ifdef INTEL_DOS
if (_LcdInkCursor.LinearAddress == -1)
return -1;
#else
if (_LcdInkCursor.LinearAddress == 0)
return 0;
#endif
_LcdInkCursor.OffsetAddress = _LcdInkCursor.LinearAddress - _DispLinearAddress;
}
else
{
_LcdInkCursor.LinearAddress = seVmemAllocCursor();
#ifdef INTEL_DOS
if (_LcdInkCursor.LinearAddress == -1)
return -1;
#else
if (_LcdInkCursor.LinearAddress == 0)
return 0;
#endif
_LcdInkCursor.OffsetAddress = _LcdInkCursor.LinearAddress - _DispLinearAddress;
}
if (_MemorySize - 1024 == _LcdInkCursor.OffsetAddress)
regInkCursorAddress = 0;
else
regInkCursorAddress = (_MemorySize - _LcdInkCursor.OffsetAddress) / 8192L;
seWriteRegByte(REG_LCD_INK_CURS_START_ADDR, regInkCursorAddress);
return _LcdInkCursor.LinearAddress;
}
/*-------------------------------------------------------------------------*/
DWORD _InitCrtInkCursorAddress(DWORD InkCursorSize, int SelectInkCursor)
{
unsigned regInkCursorAddress;
/*
** Unallocate memory
*/
regInkCursorAddress = seReadRegByte(REG_CRTTV_INK_CURS_START_ADDR);
if (regInkCursorAddress == 0)
_CrtTvInkCursor.OffsetAddress = seGetInstalledMemorySize() - 1024;
else
_CrtTvInkCursor.OffsetAddress = seGetInstalledMemorySize() - (regInkCursorAddress * 8192L);
if (_CrtTvInkCursor.LinearAddress == _CrtTvInkCursor.OffsetAddress + _DispLinearAddress)
seVmemFree(_CrtTvInkCursor.LinearAddress);
_CrtTvInkCursor.LinearAddress = 0;
_CrtTvInkCursor.OffsetAddress = 0;
/*
** Calculate starting address of hardware cursor.
*/
if (SelectInkCursor == INK_LAYER)
{
_CrtTvInkCursor.LinearAddress = seVmemAllocInk(InkCursorSize);
#ifdef INTEL_DOS
if (_CrtTvInkCursor.LinearAddress == -1)
return -1;
#else
if (_CrtTvInkCursor.LinearAddress == 0)
return 0;
#endif
_CrtTvInkCursor.OffsetAddress = _CrtTvInkCursor.LinearAddress - _DispLinearAddress;
}
else
{
_CrtTvInkCursor.LinearAddress = seVmemAllocCursor();
#ifdef INTEL_DOS
if (_CrtTvInkCursor.LinearAddress == -1)
return -1;
#else
if (_CrtTvInkCursor.LinearAddress == 0)
return 0;
#endif
_CrtTvInkCursor.OffsetAddress = _CrtTvInkCursor.LinearAddress - _DispLinearAddress;
}
if (_MemorySize - 1024 == _CrtTvInkCursor.OffsetAddress)
regInkCursorAddress = 0;
else
regInkCursorAddress = (_MemorySize - _CrtTvInkCursor.OffsetAddress) / 8192L;
seWriteRegByte(REG_CRTTV_INK_CURS_START_ADDR, regInkCursorAddress);
return _CrtTvInkCursor.LinearAddress;
}
/*-------------------------------------------------------------------------*/
DWORD _InitTvInkCursorAddress(DWORD InkCursorSize, int SelectInkCursor)
{
return _InitCrtInkCursorAddress(InkCursorSize, SelectInkCursor);
}
/*-------------------------------------------------------------------------*/
/*
** SelectInkCursor == CURSOR or INK_LAYER
*/
DWORD _InitInkCursorAddress(DWORD InkCursorSize, int SelectInkCursor)
{
DWORD LinearAddr, OffsetAddr;
unsigned regInkCursorAddress;
/*
** Unallocate memory
*/
if (_ActiveImageSurface->DisplayMode & LCD)
{
seVmemFree(_LcdInkCursor.LinearAddress);
_LcdInkCursor.LinearAddress = 0;
_LcdInkCursor.OffsetAddress = 0;
}
if (_ActiveImageSurface->DisplayMode & (CRT | TV))
{
seVmemFree(_CrtTvInkCursor.LinearAddress);
_CrtTvInkCursor.LinearAddress = 0;
_CrtTvInkCursor.OffsetAddress = 0;
}
/*
** Calculate starting address of hardware cursor.
*/
if (SelectInkCursor == INK_LAYER)
{
LinearAddr = seVmemAllocInk(InkCursorSize);
#ifdef INTEL_DOS
if (LinearAddr == -1)
return -1;
#else
if (LinearAddr == 0)
return 0;
#endif
OffsetAddr = LinearAddr - _DispLinearAddress;
}
else
{
LinearAddr = seVmemAllocCursor();
#ifdef INTEL_DOS
if (LinearAddr == -1)
return -1;
#else
if (LinearAddr == 0)
return 0;
#endif
OffsetAddr = LinearAddr - _DispLinearAddress;
}
if (_MemorySize - 1024 == OffsetAddr)
regInkCursorAddress = 0;
else
regInkCursorAddress = (_MemorySize - OffsetAddr) / 8192L;
if (_ActiveImageSurface->DisplayMode & LCD)
{
_LcdInkCursor.LinearAddress = LinearAddr;
_LcdInkCursor.OffsetAddress = OffsetAddr;
seWriteRegByte(REG_LCD_INK_CURS_START_ADDR, regInkCursorAddress);
}
if (_ActiveImageSurface->DisplayMode & (CRT | TV))
{
_CrtTvInkCursor.LinearAddress = LinearAddr;
_CrtTvInkCursor.OffsetAddress = OffsetAddr;
seWriteRegByte(REG_CRTTV_INK_CURS_START_ADDR, regInkCursorAddress);
}
return LinearAddr;
}
/*-------------------------------------------------------------------------*/
DWORD seInitLcdCursor(void)
{
DWORD addr;
addr = _InitLcdInkCursorAddress(CURSOR_SIZE, CURSOR);
#ifdef INTEL_DOS
if (addr == -1)
return -1;
#else
if (addr == 0)
return 0;
#endif
/*
** Fill cursor with transparent color.
*/
seDrawLcdCursorRect(0, 0, 63, 63, 0xaa, 1);
seEnableLcdCursor(TRUE);
return addr;
}
/*-------------------------------------------------------------------------*/
DWORD seInitCrtCursor(void)
{
DWORD addr;
addr = _InitCrtInkCursorAddress(CURSOR_SIZE, CURSOR);
#ifdef INTEL_DOS
if (addr == -1)
return -1;
#else
if (addr == 0)
return 0;
#endif
/*
** Fill cursor with transparent color.
*/
seDrawCrtCursorRect(0, 0, 63, 63, 0xaa, 1);
seEnableCrtCursor(TRUE);
return addr;
}
/*-------------------------------------------------------------------------*/
DWORD seInitTvCursor(void)
{
return seInitCrtCursor();
}
/*-------------------------------------------------------------------------*/
DWORD seInitCursor(void)
{
DWORD addr;
addr = _InitInkCursorAddress(CURSOR_SIZE, CURSOR);
#ifdef INTEL_DOS
if (addr == -1)
return -1;
#else
if (addr == 0)
return 0;
#endif
/*
** Fill cursor with transparent color.
*/
seDrawCursorRect(0, 0, 63, 63, 0xaa, 1);
seEnableCursor(TRUE);
return addr;
}
/*-------------------------------------------------------------------------*/
void seFreeLcdCursor(void)
{
#ifdef INTEL_DOS
seVmemFree(_LcdInkCursor.LinearAddress);
_LcdInkCursor.LinearAddress = 0;
_LcdInkCursor.OffsetAddress = 0;
#else
if (_LcdInkCursor.LinearAddress > 0)
{
seVmemFree(_LcdInkCursor.LinearAddress);
_LcdInkCursor.LinearAddress = 0;
_LcdInkCursor.OffsetAddress = 0;
}
#endif
}
/*-------------------------------------------------------------------------*/
void seFreeCrtCursor(void)
{
#ifdef INTEL_DOS
seVmemFree(_CrtTvInkCursor.LinearAddress);
_CrtTvInkCursor.LinearAddress = 0;
_CrtTvInkCursor.OffsetAddress = 0;
#else
if (_CrtTvInkCursor.LinearAddress > 0)
{
seVmemFree(_CrtTvInkCursor.LinearAddress);
_CrtTvInkCursor.LinearAddress = 0;
_CrtTvInkCursor.OffsetAddress = 0;
}
#endif
}
/*-------------------------------------------------------------------------*/
void seFreeTvCursor(void)
{
seFreeCrtCursor();
}
/*-------------------------------------------------------------------------*/
void seFreeCursor(void)
{
if (_ActiveImageSurface->DisplayMode & LCD)
{
seVmemFree(_LcdInkCursor.LinearAddress);
_LcdInkCursor.LinearAddress = 0;
_LcdInkCursor.OffsetAddress = 0;
}
if (_ActiveImageSurface->DisplayMode & (CRT | TV))
{
seVmemFree(_CrtTvInkCursor.LinearAddress);
_CrtTvInkCursor.LinearAddress = 0;
_CrtTvInkCursor.OffsetAddress = 0;
}
}
/*-------------------------------------------------------------------------*/
void seEnableLcdCursor(int enable)
{
unsigned regLcdInkCursorCtrl;
if (enable)
{
regLcdInkCursorCtrl = seReadRegByte(REG_LCD_INK_CURS_CTRL);
regLcdInkCursorCtrl &= ~0x03;
regLcdInkCursorCtrl |= 0x01;
seWriteRegByte(REG_LCD_INK_CURS_CTRL, regLcdInkCursorCtrl);
}
else
{
regLcdInkCursorCtrl = seReadRegByte(REG_LCD_INK_CURS_CTRL);
regLcdInkCursorCtrl &= ~0x03;
seWriteRegByte(REG_LCD_INK_CURS_CTRL, regLcdInkCursorCtrl);
}
}
/*-------------------------------------------------------------------------*/
void seEnableCrtCursor(int enable)
{
unsigned regCrtTvInkCursorCtrl;
if (enable)
{
regCrtTvInkCursorCtrl = seReadRegByte(REG_CRTTV_INK_CURS_CTRL);
regCrtTvInkCursorCtrl &= ~0x03;
regCrtTvInkCursorCtrl |= 0x01;
seWriteRegByte(REG_CRTTV_INK_CURS_CTRL, regCrtTvInkCursorCtrl);
}
else
{
regCrtTvInkCursorCtrl = seReadRegByte(REG_CRTTV_INK_CURS_CTRL);
regCrtTvInkCursorCtrl &= ~0x03;
seWriteRegByte(REG_CRTTV_INK_CURS_CTRL, regCrtTvInkCursorCtrl);
}
}
/*-------------------------------------------------------------------------*/
void seEnableTvCursor(int enable)
{
seEnableCrtCursor(enable);
}
/*-------------------------------------------------------------------------*/
void seEnableCursor(int enable)
{
if (enable)
{
/*
** Turn on cursor
*/
if (_ActiveImageSurface->DisplayMode & LCD)
seEnableLcdCursor(enable);
if (_ActiveImageSurface->DisplayMode & (CRT | TV))
seEnableCrtCursor(enable);
}
else
{
if (_ActiveImageSurface->DisplayMode & LCD)
seEnableLcdCursor(enable);
if (_ActiveImageSurface->DisplayMode & (CRT | TV))
seEnableCrtCursor(enable);
}
}
/*-------------------------------------------------------------------------*/
DWORD seGetLcdCursorLinearAddress(void)
{
return seGetLcdCursorOffsetAddress() + _DispLinearAddress;
}
/*-------------------------------------------------------------------------*/
DWORD seGetCrtCursorLinearAddress(void)
{
return seGetCrtCursorOffsetAddress() + _DispLinearAddress;
}
/*-------------------------------------------------------------------------*/
DWORD seGetTvCursorLinearAddress(void)
{
return seGetTvCursorOffsetAddress() + _DispLinearAddress;
}
/*-------------------------------------------------------------------------*/
DWORD seGetCursorLinearAddress(void)
{
return seGetCursorOffsetAddress() + _DispLinearAddress;
}
/*-------------------------------------------------------------------------*/
DWORD seGetLcdCursorOffsetAddress(void)
{
DWORD addr;
unsigned regInkCursorStartAddress;
/*
** Determine start address of cursor.
*/
regInkCursorStartAddress = seReadRegByte(REG_LCD_INK_CURS_START_ADDR);
if (regInkCursorStartAddress == 0)
addr = _MemorySize - CURSOR_SIZE;
else
addr = _MemorySize - (regInkCursorStartAddress * 8192L);
return addr;
}
/*-------------------------------------------------------------------------*/
DWORD seGetCrtCursorOffsetAddress(void)
{
DWORD addr;
unsigned regInkCursorStartAddress;
/*
** Determine start address of cursor.
*/
regInkCursorStartAddress = seReadRegByte(REG_CRTTV_INK_CURS_START_ADDR);
if (regInkCursorStartAddress == 0)
addr = _MemorySize - CURSOR_SIZE;
else
addr = _MemorySize - (regInkCursorStartAddress * 8192L);
return addr;
}
/*-------------------------------------------------------------------------*/
DWORD seGetTvCursorOffsetAddress(void)
{
return seGetCrtCursorOffsetAddress();
}
/*-------------------------------------------------------------------------*/
DWORD seGetCursorOffsetAddress(void)
{
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?