📄 show.c
字号:
printf("%s", str);
#ifndef INTEL_DOS
if (gnContinualScrnRead)
{
dwStartPtr = (DWORD *) seGetSurfaceLinearAddress();
printf("Continual DWORD read from %08lXh...\n", (DWORD) dwPtr);
}
seDelay(1);
seBeginHighPriority();
while (gnContinualScrnRead)
{
dwPtr = dwStartPtr;
for (count = 0; count < 100; ++count, ++dwPtr)
dwVal = *dwPtr;
}
seEndHighPriority();
#else
while (gnContinualScrnRead)
{
for (addr = 0; addr < lSize; addr += 4)
dwVal = seReadDisplayDword(addr);
}
#endif
if (gnContinualScrnWrite)
{
addr = seGetAvailableMemorySize();
if (addr > 2)
addr -= 2;
addr &= ~0x01; // word align
printf("Continually writing 0x1234 to %06lX...\n", addr);
}
seBeginHighPriority();
while (gnContinualScrnWrite)
seWriteDisplayWords(addr, 0x1234, 1);
seEndHighPriority();
return ERR_OK;
}
/*-------------------------------------------------------------------------*/
void UpdateScreen( unsigned BitsPerPixel )
{
int RepeatC;
int x, y, i, j;
long x_step, y_step;
int Cx1, Cx2, Cy1, Cy2;
int Last_Cx2, Last_Cy2;
unsigned Color, White, Black;
int DisplayMode, count;
#define BPP_FACTOR ( 1000000L )
#define BPP_ROUNDUP ( BPP_FACTOR/2 )
Color = 0x00;
White = 0xFFFF;
Black = 0x0000;
DisplayMode = GetSurfaceDisplayMode(GetActiveSurfaceNumber());
count = 0;
if (DisplayMode & LCD)
{
printf("LCD");
++count;
}
if (DisplayMode & TV)
{
if (count > 0)
printf(", ");
printf("TV");
}
else if (DisplayMode & CRT)
{
if (count > 0)
printf(", ");
printf("CRT");
}
seGetResolution((unsigned *) &x, (unsigned *) &y);
printf( ": %d * %d * %d Bpp\n", x, y, BitsPerPixel );
if ( gnUseVertical )
{
RepeatC = 8 / BitsPerPixel + 1;
for (i = 0; i < x; i++)
{
seDrawLine(i, 1, i, y-1, Color);
if (i % RepeatC == 0 )
Color = GetNextColor( Color, BitsPerPixel );
}
}
else
{
switch (BitsPerPixel)
{
case 4:
x_step = ((x - 2) * BPP_FACTOR) /4;
y_step = ((y - 2) * BPP_FACTOR) /4;
Cy2 = Last_Cy2 = 0;
for ( i = 0; i < 4; i++ )
{
Last_Cx2 = 0;
for ( j = 0; j < 4; j++ )
{
Cx1 = (int)(((j * x_step) / BPP_FACTOR) + 1);
Cx2 = (int)((((j + 1) * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy1 = (int)(((i * y_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy2 = (int)((((i + 1) * y_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
/*
** Don't display on borders.
*/
if (Cx2 >= x-1)
--Cx2;
if (Cy2 >= y-1)
--Cy2;
/*
** Prevent the boxes from overwriting each other.
*/
if (Last_Cx2 >= Cx1)
Cx1 = Last_Cx2+1;
Last_Cx2 = Cx2;
if (Last_Cy2 >= Cy1)
Cy1 = Last_Cy2+1;
seDrawRect(Cx1, Cy1, Cx2, Cy2, Color, 1);
Color = GetNextColor( Color, BitsPerPixel );
}
Last_Cy2 = Cy2;
}
break;
case 8:
x_step = ((x - 2) * BPP_FACTOR ) /32;
y_step = ((y - 2) * BPP_FACTOR ) /8;
Cy2 = Last_Cy2 = 0;
for (i = 0; i < 8; i++)
{
Last_Cx2 = 0;
for (j = 0; j < 32; j++)
{
Cx1 = (int)(((j * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cx2 = (int)((((j + 1) * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy1 = (int)(((i * y_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy2 = (int)((((i + 1) * y_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
/*
** Don't display on borders.
*/
if (Cx2 >= x-1)
--Cx2;
if (Cy2 >= y-1)
--Cy2;
/*
** Prevent the boxes from overwriting each other.
*/
if (Last_Cx2 >= Cx1)
Cx1 = Last_Cx2+1;
Last_Cx2 = Cx2;
if (Last_Cy2 >= Cy1)
Cy1 = Last_Cy2+1;
seDrawRect(Cx1, Cy1, Cx2, Cy2, Color, 1);
Color = GetNextColor( Color, BitsPerPixel );
}
Last_Cy2 = Cy2;
}
break;
case 15:
/*
* Subtract 2 from x and y so that I don't overwrite
* the borders. Multiply by BPP_FACTOR for more digits of
* precision. Add BPP_ROUNDUP to round up from the
* give number of digits of precision.
*/
/*
* Subtract 2 from x and y so that I don't overwrite
* the borders. Multiply by 1000 for three digits of precision.
* Add 500 to round up from the three digits of precision.
*/
Color = 0x20;
x_step = ((x-2) * BPP_FACTOR) /32;
y_step = ((y-2) * BPP_FACTOR) /3;
Cy2 = Last_Cy2 = 0;
for (i = 0; i < 3; i++)
{
Last_Cx2 = 0;
for (j = 0; j < 32; j++)
{
Cx1 = (int) (((j * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cx2 = (int) ((((j + 1) * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy1 = (int) (((i * y_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy2 = (int) ((((i + 1) * y_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
/*
** Don't display on borders.
*/
if (Cx2 >= x-1)
--Cx2;
if (Cy2 >= y-1)
--Cy2;
/*
** Prevent the boxes from overwriting each other.
*/
if (Last_Cx2 >= Cx1)
Cx1 = Last_Cx2+1;
Last_Cx2 = Cx2;
if (Last_Cy2 >= Cy1)
Cy1 = Last_Cy2+1;
if (!j)
seDrawRect(Cx1,Cy1,Cx2,Cy2,0,1);
else
{
seDrawRect(Cx1,Cy1,Cx2,Cy2,Color,1);
Color = GetNextColor(Color,BitsPerPixel);
}
}
Last_Cy2 = Cy2;
}
break;
case 16:
/*
* Subtract 2 from x and y so that I don't overwrite
* the borders. Multiply by BPP_FACTOR for more digits of
* precision. Add BPP_ROUNDUP to round up from the
* give number of digits of precision.
*/
/*green*/
Color = 0x20;
x_step = ((x-2) * BPP_FACTOR) /64;
y_step = ((y-2) * BPP_FACTOR) /3;
Color = 0;
Cx2 = 0;
Cy2 = 0;
for (j = 0; j < 64; j++)
{
Cx1 = (int) (((j * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cx2 = (int) ((((j + 1) * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy1 = 1;
Cy2 = (int) ((y_step / BPP_FACTOR) + 1);
/*
** Don't display on borders.
*/
if (Cx2 >= x-1)
--Cx2;
if (Cy2 >= y-1)
--Cy2;
seDrawRect(Cx1,Cy1,Cx2,Cy2,Color,1);
Color = GetNextColor(Color,BitsPerPixel);
}
Last_Cy2 = Cy2;
/* blue */
x_step = ((x-2)*BPP_FACTOR)/32; /* keep one digit of precision */
Color = 0;
Cx2 = 0;
for (j = 0; j < 32; j++)
{
Cx1 = (int) (((j * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cx2 = (int) ((((j + 1) * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy1 = (int) ((y_step / BPP_FACTOR) + 1);
Cy2 = (int) (((y_step * 2 + BPP_ROUNDUP) / BPP_FACTOR) + 1);
if (j == 1)
Color = 0x0001;
/*
** Don't display on borders.
*/
if (Cx2 >= x-1)
--Cx2;
if (Cy2 >= y-1)
--Cy2;
/*
** Prevent the boxes from overwriting each other.
*/
if (Last_Cy2 >= Cy1)
Cy1 = Last_Cy2+1;
seDrawRect(Cx1,Cy1,Cx2,Cy2,(DWORD) Color,1);
Color = GetNextColor(Color,BitsPerPixel);
}
/*red*/
Color = 0;
Cx2 = 0;
Last_Cy2 = Cy2;
for (j = 0; j < 32; j++)
{
Cx1 = (int) (((j * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cx2 = (int) ((((j + 1) * x_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
Cy1 = (int) ((2 * y_step + BPP_ROUNDUP)/BPP_FACTOR + 1);
Cy2 = (int) (((3 * y_step + BPP_ROUNDUP) / BPP_FACTOR) + 1);
if (j == 1)
Color = 0x0800;
/*
** Don't display on borders.
*/
if (Cx2 >= x-1)
--Cx2;
if (Cy2 >= y-1)
--Cy2;
/*
** Prevent the boxes from overwriting each other.
*/
if (Last_Cy2 >= Cy1)
Cy1 = Last_Cy2+1;
seDrawRect(Cx1,Cy1,Cx2,Cy2,Color,1);
Color = GetNextColor(Color,BitsPerPixel);
}
break;
}
}
/*
** Draw border
*/
seDrawRect(0, 0, x-1, y-1, White, FALSE);
if (gnShowGrid)
{
/*
** Draw vertical lines
*/
for (Cx1 = 0; Cx1 < x; Cx1 += 20)
seDrawLine(Cx1, 0, Cx1, y-1, White);
/*
** Draw horizontal lines
*/
for (Cy1 = 0; Cy1 < y; Cy1 += 20)
seDrawLine(0, Cy1, x-1, Cy1, White);
}
/* Arrow pointing to top of screen */
if (BitsPerPixel == 8)
{
// In 8 bpp, the arrow goes across white and black color bars.
// Consequently the arrow must be black on the white bar, and
// white on the black bar to be visible.
seDrawLine(x/2, 0, (x/2)-10, 10, Black);
seDrawLine((x/2)+1, 1, (x/2)+10, 10, White);
seDrawLine((x/2)-10, 10, x/2, 10, Black);
seDrawLine((x/2)+1, 10, (x/2)+10, 10, White);
}
else
{
seDrawLine(x/2, 0, (x/2)-10, 10, White);
seDrawLine(x/2, 0, (x/2)+10, 10, White);
seDrawLine((x/2)-10, 10, (x/2)+10, 10, White);
}
}
/*-------------------------------------------------------------------------*/
unsigned GetNextColor( unsigned Color, unsigned BPP )
{
unsigned NewColor;
unsigned Red,Green,Blue;
switch (BPP)
{
case 4:
return ((++Color) & 0x0F);
break;
default:
case 8:
return ((++Color) & 0xFF);
break;
case 15:
if (!Color)
NewColor = Color + 0x20;
else
{
Red = Color & 0x7c00;
Green = Color & 0x03e0;
Blue = Color & 0x1f;
if (Red)
{
Red = (Red + 0x0400) & 0x7c00;
if (!Red)
Green += 0x20;
}
else if (Green)
{
Green = (Green + 0x20) & 0x3e0;
if (!Green)
Blue += 1;
}
else if (Blue)
{
Blue = (Blue + 1) & 0x1f;
if (!Blue)
Red +=0x0400;
}
NewColor = Red | Green | Blue;
}
return NewColor;
case 16:
if (!Color)
NewColor = Color + 0x20;
else
{
Red = Color & 0xf800;
Green = Color & 0x07e0;
Blue = Color & 0x1f;
if (Red)
{
Red = (Red + 0x0800) & 0xf800;
if (!Red)
Green += 0x20;
}
else if (Green)
{
Green = (Green + 0x20) & 0x07e0;
if (!Green)
Blue += 1;
}
else if (Blue)
{
Blue = (Blue + 1) & 0x1f;
if (!Blue)
Red +=0x0800;
}
NewColor = Red | Green | Blue;
}
return NewColor;
}
}
/*-------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -