📄 hal_draw.c
字号:
BytesPerScanline = seGetBytesPerScanline();
if (x1 > x2)
{
_Swap(&x1, &x2);
_Swap(&y1, &y2);
}
/*
** Switch based on the pixel depth (BPP)
*/
BitsPerPixel = seGetBitsPerPixel();
if (BitsPerPixel == 15)
BitsPerPixel = 16;
// Adjust for ROTATE90 and ROTATE270
if (seReadRegByte(REG_DISPLAY_MODE) & 0x40)
LinearAddress = _DispLinearAddress + (_ActiveImageSurface->OffsetAddress / 1024);
else
LinearAddress = _ActiveImageSurface->LinearAddress;
#ifdef INTEL_DOS
if (LinearAddress == -1)
{
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
return;
}
#else
if (LinearAddress == 0)
{
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
return;
}
#endif
/*
** Diagonal lines
*/
switch (BitsPerPixel)
{
case 4:
_Line(LinearAddress, BytesPerScanline, x1, y1, x2, y2, color, _Pixel4bpp);
break;
case 8:
_Line(LinearAddress, BytesPerScanline, x1, y1, x2, y2, color, _Pixel8bpp);
break;
case 15:
case 16:
_Line(LinearAddress, BytesPerScanline, x1, y1, x2, y2, color, _Pixel16bpp);
break;
}
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
}
/*-------------------------------------------------------------------------*/
void seDrawLcdRect(long x1, long y1, long x2, long y2, DWORD color, BOOL SolidFill)
{
unsigned BytesPerScanline;
unsigned BitsPerPixel;
DWORD LinearAddress;
void (*linefn)(DWORD,int,long,long,long,long,DWORD);
long y;
if (y1 > y2)
{
y = y2;
y2 = y1;
y1 = y;
}
BytesPerScanline = seGetLcdBytesPerScanline();
BitsPerPixel = seGetLcdBitsPerPixel();
if (BitsPerPixel == 15)
BitsPerPixel = 16;
// Adjust for ROTATE90 and ROTATE270
if (seReadRegByte(REG_DISPLAY_MODE) & 0x40)
LinearAddress = _DispLinearAddress + (_LcdSurface.OffsetAddress / 1024);
else
LinearAddress = _LcdSurface.LinearAddress;
#ifdef INTEL_DOS
if (LinearAddress == -1)
return;
#else
if (LinearAddress == 0)
return;
#endif
switch (BitsPerPixel)
{
case 4:
linefn = _Line4bpp;
break;
case 8:
default:
linefn = _Line8bpp;
break;
case 15:
case 16:
linefn = _Line16bpp;
break;
}
if (SolidFill)
{
for (y = y1; y <= y2; y++)
(*linefn)(LinearAddress, BytesPerScanline, x1, y, x2, y, color);
}
else
{
(*linefn)(LinearAddress, BytesPerScanline, x1, y1, x2, y1, color);
(*linefn)(LinearAddress, BytesPerScanline, x1, y2, x2, y2, color);
(*linefn)(LinearAddress, BytesPerScanline, x1, y1, x1, y2, color);
(*linefn)(LinearAddress, BytesPerScanline, x2, y1, x2, y2, color);
}
}
/*-------------------------------------------------------------------------*/
void seDrawCrtRect(long x1, long y1, long x2, long y2, DWORD color, BOOL SolidFill)
{
unsigned BytesPerScanline;
unsigned BitsPerPixel;
DWORD LinearAddress;
void (*linefn)(DWORD,int,long,long,long,long,DWORD);
long y;
unsigned regDisplayMode;
// If in rotate90 mode, get into landscape mode
regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode & ~0x40);
if (y1 > y2)
{
y = y2;
y2 = y1;
y1 = y;
}
BytesPerScanline = seGetCrtBytesPerScanline();
BitsPerPixel = seGetCrtBitsPerPixel();
if (BitsPerPixel == 15)
BitsPerPixel = 16;
// Adjust for ROTATE90 and ROTATE270
LinearAddress = _CrtTvSurface.LinearAddress;
#ifdef INTEL_DOS
if (LinearAddress == -1)
{
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
return;
}
#else
if (LinearAddress == 0)
{
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
return;
}
#endif
switch (BitsPerPixel)
{
case 4:
linefn = _Line4bpp;
break;
case 8:
default:
linefn = _Line8bpp;
break;
case 15:
case 16:
linefn = _Line16bpp;
break;
}
if (SolidFill)
{
for (y = y1; y <= y2; y++)
(*linefn)(LinearAddress, BytesPerScanline, x1, y, x2, y, color);
}
else
{
(*linefn)(LinearAddress, BytesPerScanline, x1, y1, x2, y1, color);
(*linefn)(LinearAddress, BytesPerScanline, x1, y2, x2, y2, color);
(*linefn)(LinearAddress, BytesPerScanline, x1, y1, x1, y2, color);
(*linefn)(LinearAddress, BytesPerScanline, x2, y1, x2, y2, color);
}
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
}
/*-------------------------------------------------------------------------*/
void seDrawTvRect(long x1, long y1, long x2, long y2, DWORD color, BOOL SolidFill)
{
seDrawCrtRect(x1, y1, x2, y2, color, SolidFill);
}
/*-------------------------------------------------------------------------*/
void seDrawRect(long x1, long y1, long x2, long y2, DWORD color, BOOL SolidFill)
{
unsigned BytesPerScanline;
unsigned BitsPerPixel;
unsigned regDisplayMode;
DWORD LinearAddress;
void (*linefn)(DWORD,int,long,long,long,long,DWORD);
long y;
// If in rotate90 mode for CRT/TV, get into landscape mode
regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);
if (_ActiveImageSurface->DisplayMode & (CRT | TV))
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode & ~0x40);
if (y1 > y2)
{
y = y2;
y2 = y1;
y1 = y;
}
BytesPerScanline = seGetBytesPerScanline();
BitsPerPixel = seGetBitsPerPixel();
if (BitsPerPixel == 15)
BitsPerPixel = 16;
// Adjust for ROTATE90 and ROTATE270
if (seReadRegByte(REG_DISPLAY_MODE) & 0x40)
LinearAddress = _DispLinearAddress + (_ActiveImageSurface->OffsetAddress / 1024);
else
LinearAddress = _ActiveImageSurface->LinearAddress;
#ifdef INTEL_DOS
if (LinearAddress == -1)
{
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
return;
}
#else
if (LinearAddress == 0)
{
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
return;
}
#endif
switch (BitsPerPixel)
{
case 4:
linefn = _Line4bpp;
break;
case 8:
default:
linefn = _Line8bpp;
break;
case 15:
case 16:
linefn = _Line16bpp;
break;
}
if (SolidFill)
{
for (y = y1; y <= y2; y++)
(*linefn)(LinearAddress, BytesPerScanline, x1, y, x2, y, color);
}
else
{
(*linefn)(LinearAddress, BytesPerScanline, x1, y1, x2, y1, color);
(*linefn)(LinearAddress, BytesPerScanline, x1, y2, x2, y2, color);
(*linefn)(LinearAddress, BytesPerScanline, x1, y1, x1, y2, color);
(*linefn)(LinearAddress, BytesPerScanline, x2, y1, x2, y2, color);
}
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
}
/*-------------------------------------------------------------------------*/
void seDrawLcdEllipse(long xc, long yc, long xr, long yr, DWORD color)
{
unsigned BytesPerScanline;
unsigned BitsPerPixel;
DWORD LinearAddress;
BytesPerScanline = seGetLcdBytesPerScanline();
BitsPerPixel = seGetLcdBitsPerPixel();
if (BitsPerPixel == 15)
BitsPerPixel = 16;
// Adjust for ROTATE90 and ROTATE270
if (seReadRegByte(REG_DISPLAY_MODE) & 0x40)
LinearAddress = _DispLinearAddress + (_LcdSurface.OffsetAddress / 1024);
else
LinearAddress = _LcdSurface.LinearAddress;
#ifdef INTEL_DOS
if (LinearAddress == -1)
return;
#else
if (LinearAddress == 0)
return;
#endif
switch (BitsPerPixel)
{
case 4:
_Ellipse(LinearAddress, BytesPerScanline, xc, yc, xr, yr, color, _Pixel4bpp);
break;
case 8:
_Ellipse(LinearAddress, BytesPerScanline, xc, yc, xr, yr, color, _Pixel8bpp);
break;
case 15:
case 16:
_Ellipse(LinearAddress, BytesPerScanline, xc, yc, xr, yr, color, _Pixel16bpp);
break;
}
}
/*-------------------------------------------------------------------------*/
void seDrawCrtEllipse(long xc, long yc, long xr, long yr, DWORD color)
{
unsigned BytesPerScanline;
unsigned BitsPerPixel;
unsigned regDisplayMode;
DWORD LinearAddress;
// If in rotate90 mode, get into landscape mode
regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode & ~0x40);
BytesPerScanline = seGetBytesPerScanline();
BitsPerPixel = seGetBitsPerPixel();
if (BitsPerPixel == 15)
BitsPerPixel = 16;
// Adjust for ROTATE90 and ROTATE270
LinearAddress = _CrtTvSurface.LinearAddress;
#ifdef INTEL_DOS
if (LinearAddress == -1)
{
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
return;
}
#else
if (LinearAddress == 0)
{
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
return;
}
#endif
switch (BitsPerPixel)
{
case 4:
_Ellipse(LinearAddress, BytesPerScanline, xc, yc, xr, yr, color, _Pixel4bpp);
break;
case 8:
_Ellipse(LinearAddress, BytesPerScanline, xc, yc, xr, yr, color, _Pixel8bpp);
break;
case 15:
case 16:
_Ellipse(LinearAddress, BytesPerScanline, xc, yc, xr, yr, color, _Pixel16bpp);
break;
}
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
}
/*-------------------------------------------------------------------------*/
void seDrawTvEllipse(long xc, long yc, long xr, long yr, DWORD color)
{
seDrawCrtEllipse(xc, yc, xr, yr, color);
}
/*-------------------------------------------------------------------------*/
void seDrawEllipse(long xc, long yc, long xr, long yr, DWORD color)
{
unsigned BytesPerScanline;
unsigned BitsPerPixel;
unsigned regDisplayMode;
DWORD LinearAddress;
// If in rotate90 mode for CRT/TV, get into landscape mode
regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);
if (_ActiveImageSurface->DisplayMode & (CRT | TV))
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode & ~0x40);
BytesPerScanline = seGetBytesPerScanline();
BitsPerPixel = seGetBitsPerPixel();
if (BitsPerPixel == 15)
BitsPerPixel = 16;
// Adjust for ROTATE90 and ROTATE270
if (seReadRegByte(REG_DISPLAY_MODE) & 0x40)
LinearAddress = _DispLinearAddress + (_ActiveImageSurface->OffsetAddress / 1024);
else
LinearAddress = _ActiveImageSurface->LinearAddress;
#ifdef INTEL_DOS
if (LinearAddress == -1)
{
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
return;
}
#else
if (LinearAddress == 0)
{
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
return;
}
#endif
switch (BitsPerPixel)
{
case 4:
_Ellipse(LinearAddress, BytesPerScanline, xc, yc, xr, yr, color, _Pixel4bpp);
break;
case 8:
_Ellipse(LinearAddress, BytesPerScanline, xc, yc, xr, yr, color, _Pixel8bpp);
break;
case 15:
case 16:
_Ellipse(LinearAddress, BytesPerScanline, xc, yc, xr, yr, color, _Pixel16bpp);
break;
}
// Restore previous mode (rotate90 or landscape)
seWriteRegByte(REG_DISPLAY_MODE, regDisplayMode);
}
/*-------------------------------------------------------------------------*/
void seDrawLcdCircle(long xCenter, long yCenter, long radius, DWORD color)
{
seDrawLcdEllipse(xCenter, yCenter, radius, radius, color);
}
/*-------------------------------------------------------------------------*/
void seDrawCrtCircle(long xCenter, long yCenter, long radius, DWORD color)
{
seDrawCrtEllipse(xCenter, yCenter, radius, radius, color);
}
/*-------------------------------------------------------------------------*/
void seDrawTvCircle(long xCenter, long yCenter, long radius, DWORD color)
{
seDrawTvEllipse(xCenter, yCenter, radius, radius, color);
}
/*-------------------------------------------------------------------------*/
void seDrawCircle(long xCenter, long yCenter, long radius, DWORD color)
{
seDrawEllipse(xCenter, yCenter, radius, radius, color);
}
/*-------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -