📄 splt.c
字号:
/*
//===========================================================================
// SPLT.C - Utility program to test the 13505 line compare register.
//---------------------------------------------------------------------------
// Copyright (c) 1997, 2001 Epson Research and Development, Inc.
// All Rights Reserved.
//===========================================================================
*/
#include <stdlib.h>
#include "hal.h"
#include "appcfg.h"
#include "splt.h"
#ifdef INTEL
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#include <time.h>
#endif
/*-------------------------------------------------------------------------*/
/*********************************/
const char szVersion[] = "1.06";
/*********************************/
int gDevID;
/* 14 back spaces */
char BS14[] = { BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, 0 };
/*-------------------------------------------------------------------------*/
int main( int argc, char *argv[] )
{
int nBPPArray[] = { 16, 15, 8, 4, 2, 1 };
int nBppIdx = -1;
int nTestMode = MANUAL;
gDevID = 0;
DisplayCopyright();
while (argc > 1)
{
char * ptr = argv[argc - 1];
if (('/' == *ptr) || ('-' == *ptr))
{
switch( toupper(*(ptr + 1)))
{
case 'A':
nTestMode = AUTO;
break;
default:
DisplayUsage();
return 0;
}
}
argc--;
}
/*
** Register with the HAL and initialize the 13505.
*/
switch (seRegisterDevice( &HalInfo, &gDevID ))
{
case ERR_OK:
break;
case ERR_UNKNOWN_DEVICE:
printf( "\nERROR: Did not find a 13505 device." );
return 1;
break;
case ERR_TOOMANY_DEVS:
printf( "\nERROR: Too many devices registered." );
return 1;
break;
default:
printf( "\nERROR: Could not register S1D13505FOA device." );
return 1;
break;
}
if (ERR_OK != seSetInit( gDevID ))
exit( 2 );
/*
** Do the actual testing. Loop here forever - or until ESC is pressed.
*/
do
{
nBppIdx++;
if (nBppIdx == (sizeof( nBPPArray ) / sizeof( nBPPArray[0] )))
break;
} while (TRUE == TestMode( nBPPArray[nBppIdx], nTestMode ));
return 0;
}
/*-----------------------------------------------------------------------*/
void DisplayCopyright( void )
{
const char *szHALVer;
const char *szHALStatus;
const char *szHALRevision;
char str[50];
int ver;
if (seGetLibseVersion(&ver) == ERR_OK)
sprintf(str, "[LIBSE %d]", ver);
else
str[0] = 0;
seGetHalVersion( &szHALVer, &szHALStatus, &szHALRevision );
printf( "\n13505SPLT.EXE - Line Compare Test Utility - Version %s [HAL %s%s%s] %s",
szVersion, szHALVer, szHALStatus, szHALRevision, str );
printf( "\nCopyright (c) 1997, 2001 Epson Research and Development, Inc.");
printf( "\nAll Rights Reserved.");
printf( "\n" );
/*
printf( "\n>>>>>>>>>>>>>> BETA - FOR INTERNAL USE ONLY <<<<<<<<<<<<<<" );
printf( "\n>>>>>>>>>>>>>> DO NOT DISTRIBUTE <<<<<<<<<<<<<<" );
printf( "\n" );
*/
}
/*-----------------------------------------------------------------------*/
void DisplayUsage( void )
{
printf( "\nUsage: 13505SPLT [/a] [/?]" );
printf( "\n" );
printf( "\nWhere: /a - Automatic mode" );
printf( "\n /? - Display help message" );
printf( "\n" );
printf( "\nIn manual mode: Arrow keys increase/decrease line compare" );
printf( "\n HOME sets line compare to zero (show only screen2)" );
printf( "\n END sets line compare to maximum (show only screen1)" );
printf( "\n" );
printf( "\nIn automatic mode: Pressing any key will change direction" );
printf( "\n" );
printf( "\nIn both modes: ESC quits the program" );
printf( "\n 'B' changes the color depth (bit-per-pixel)" );
printf( "\n" );
}
/*-----------------------------------------------------------------------*/
BOOL TestMode( int nBPP, int nHandlerType )
{
DWORD dwScreen2;
UINT nBytesPerScanline;
UINT x, y;
/*
** Set the video mode and init the color tables.
*/
seDisplayFifo( gDevID, OFF );
if (ERR_OK != seSetBitsPerPixel( gDevID, nBPP ))
{
printf( "\nERROR: Could not set %d bit-per-pixel display mode.", nBPP);
exit( 2 );
}
/*
** Setup for split screen operation.
*/
seGetScreenSize( gDevID, &x, &y );
seGetBytesPerScanline( gDevID, &nBytesPerScanline );
dwScreen2 = (DWORD) nBytesPerScanline * y;
seSplitInit( gDevID, 0, dwScreen2 );
printf( "\nFilling %2d BPP", nBPP );
FillDisplayMem( nBPP, HORIZONTAL, 0 );
FillDisplayMem( nBPP, VERTICAL, y );
seDisplayFifo( gDevID, ON );
printf( "%s %s", BS14, BS14 );
printf( "%d BPP", nBPP );
return KbdHandler( nHandlerType );
}
/*-------------------------------------------------------------------------*/
void FillDisplayMem( int nBPP, int nVertOrHorz, int nLine )
{
UINT nRow, nCol;
UINT width, height;
UINT nMaxRow;
WORD wColor = 0;
UINT nBytesPerScanline;
DWORD LastByte;
UINT lastCol;
seGetScreenSize( gDevID, &width, &height );
seGetBytesPerScanline( gDevID, &nBytesPerScanline );
seGetLastUsableByte( gDevID, &LastByte );
nMaxRow = (int)(LastByte / nBytesPerScanline);
if (nMaxRow > height * 2)
nMaxRow = height * 2;
if (HORIZONTAL == nVertOrHorz)
{
for (nRow = nLine; nRow < height; nRow += PAT_HEIGHT)
{
seDrawRect( gDevID, 0, nRow, width, nRow + PAT_HEIGHT, wColor, TRUE );
wColor = GetNextColor( nBPP, wColor );
}
}
else
{
for (nCol = 0; nCol < width; nCol += PAT_WIDTH)
{
lastCol = nCol + PAT_WIDTH;
if (lastCol >= width)
lastCol = width - 1;
seDrawRect( gDevID, nCol, nLine, lastCol, nLine+height, wColor, TRUE );
wColor = GetNextColor( nBPP, wColor );
}
}
}
/*-----------------------------------------------------------------------*/
/*
** GetNextColor()
**
** This routine is optimized for 13505SPLT in that the return color
** is replicated across the byte for color depths less than 8bpp.
*/
WORD GetNextColor( int nBPP, WORD Color )
{
switch (nBPP)
{
case 1:
return (0xFF - Color);
break;
case 2:
Color++;
Color &= 0x03;
return Color |= Color << 2 | Color << 4 | Color << 6;
break;
case 4:
Color++;
Color &= 0x0F;
return Color | Color << 4;
break;
case 8:
return ++Color;
break;
case 15:
if (!(Color & 0x7fe0)) /* red and green not used, so show blue */
{
Color += 4; /* inc blue */
}
else if (!(Color & 0x7c1f)) /* red and blue not used, so show green */
{
Color &= ~0x60; /* remove first two bits of green */
Color += 0x80; /* inc green */
}
else
{
Color &= ~0xc00; /* remove first two bits of red */
Color += 0x1000; /* inc red */
}
Color &= ~0x8000; /* remove unused bit */
return Color;
break;
case 16:
if (!(Color & 0xffe0)) /* red and green not used, so show blue */
{
Color += 4; /* inc blue */
}
else if (!(Color & 0xf81f)) /* red and blue not used, so show green */
{
Color &= ~0x60; /* remove first two bits of green */
Color += 0x80; /* inc green */
}
else
{
Color &= ~0x1800; /* remove first two bits of red */
Color += 0x2000; /* inc red */
}
return Color;
break;
default:
DPF( "We should never get here" );
break;
}
return Color;
}
/*-----------------------------------------------------------------------*/
BOOL KbdHandler( BOOL bAutoMode )
{
int nKbd;
int nDirection;
UINT nMaxY, nMaxX;
int y;
seGetScreenSize( gDevID, &nMaxX, &nMaxY );
nMaxY--;
if (bAutoMode)
y = nMaxY;
else
y = nMaxY/2;
seSplitScreen( gDevID, SCREEN1, y );
nDirection = UP;
while (1)
{
if (bAutoMode)
{
/*
** seDelay( gDevID, 1 );
*/
#ifdef INTEL
if (kbhit())
{
nKbd = seGetChar();
if ((0 == nKbd) || (0xE0 == nKbd)) /* We have an extended keystroke */
nKbd = seGetChar();
switch (toupper( nKbd ))
{
case ESC:
return FALSE;
break;
case 'B':
return TRUE;
break;
default: /* Other keystroke - change direction. */
if (UP == nDirection)
nDirection = DOWN;
else
nDirection = UP;
break;
}
}
#endif
}
else /* Manual mode */
{
nKbd = seGetChar();
if ((0 == nKbd) || (0xE0 == nKbd)) /* We have an extended keystroke. */
nKbd = seGetChar();
nDirection = nKbd;
}
switch ( nKbd )
{
case ESC:
return FALSE;
break;
case 'b':
case 'B':
return TRUE;
break;
default:
switch (nDirection)
{
case LEFT:
case UP:
case 'U':
if (bAutoMode)
{
if (y == 0)
{
nDirection = DOWN;
break;
}
}
if (y > 0)
y--;
break;
case RIGHT:
case DOWN:
case 'D':
if (bAutoMode)
{
if ((UINT) y >= nMaxY)
return TRUE;
}
if (y < (int) nMaxY)
y++;
break;
case CTRL_UP:
case CTRL_LEFT:
if (y > 16)
y -= PAT_HEIGHT;
else
y = 0;
break;
case CTRL_DOWN:
case CTRL_RIGHT:
if (y < (int) nMaxY)
y += PAT_HEIGHT;
else
y = nMaxY;
break;
case HOME:
y = 0;
break;
case END:
y = nMaxY;
break;
default:
break;
}
}
seSplitScreen( gDevID, SCREEN1, y );
}
}
/*-------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -