📄 lcd_dvc.c
字号:
/*************************************************************************/
/* */
/* Copyright (c) 1999 Accelerated Technology, Inc. */
/* */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the */
/* subject matter of this material. All manufacturing, reproduction, */
/* use, and sales rights pertaining to this subject matter are governed */
/* by the license agreement. The recipient of this software implicitly */
/* accepts the terms of the license. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* lcd_dvc.c 1.3 */
/* */
/* COMPONENT */
/* */
/* All */
/* */
/* DESCRIPTION */
/* */
/* This file contains the LCD device specific functions. */
/* */
/* AUTHOR */
/* */
/* Robert G. Burrill, Accelerated Technology, Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* None */
/* */
/* DEPENDENCIES */
/* */
/* None */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* */
/*************************************************************************/
#include "meta_wnd.h"
#include "metconst.h" /* MetaWINDOW Constant & Stucture Definitions */
#include "metports.h" /* MetaWINDOW Port & Bitmap Definitions */
#include "grafdata.h"
#include "wndo.h"
#include "metmacs3.h"
#include "devc.h"
#include "lcd_dvc.h"
/* Local functions */
void *GrafAlloc();
void GrafFree();
int nuMapPhysAdr();
void InitRowTable();
int mwIMEM();
int InitGrafDriver();
DspDevc displayTable[numDisplays];
/*-------- Device Bank and Plane Parameter Tables start here --------*/
DBPstruc tLCD; /* Generic LCD */
DBPstruc tLCD1; /* 1-bit LCD */
DBPstruc tLCD2; /* 2-bit LCD */
DBPstruc tLCD4; /* 4-bit LCD */
/* Internal Input Device Managers */
long mwIdevTbl[16];
/* Function InitDevcTbls initializes the device tables */
void InitDevcTbls(void)
{
int i = 0;
int LCDDevMgr();
/* initialize display driver table */
displayTable[i].devcName = cLCD; /* 8-bit LCD */
displayTable[i].bnkTblPtr = NULL;
displayTable[i++].devTblPtr = &LCDDevMgr;
displayTable[i].devcName = cLCD1; /* 1-bit LCD */
displayTable[i].bnkTblPtr = NULL;
displayTable[i++].devTblPtr = &LCDDevMgr;
displayTable[i].devcName = cLCD2; /* 2-bit LCD */
displayTable[i].bnkTblPtr = NULL;
displayTable[i++].devTblPtr = &LCDDevMgr;
displayTable[i].devcName = cLCD4; /* 4-bit LCD */
displayTable[i].bnkTblPtr = NULL;
displayTable[i++].devTblPtr = &LCDDevMgr;
displayTable[i].devcName = -1; /* set end value */
/* Initialize bank manager structures */
/*--------------------LCD -----------------------*/
tLCD.wnType = 0;
tLCD.wnSize = 320;
tLCD.wnOff = 0;
tLCD.bnkMgr = &BankStub;
tLCD.plnMgr = &PlaneStub;
tLCD1.wnType = 0;
tLCD1.wnSize = 320;
tLCD1.wnOff = 0;
tLCD1.bnkMgr = &BankStub;
tLCD1.plnMgr = &PlaneStub;
tLCD2.wnType = 0;
tLCD2.wnSize = 320;
tLCD2.wnOff = 0;
tLCD2.bnkMgr = &BankStub;
tLCD2.plnMgr = &PlaneStub;
tLCD4.wnType = 0;
tLCD4.wnSize = 320;
tLCD4.wnOff = 0;
tLCD4.bnkMgr = &BankStub;
tLCD4.plnMgr = &PlaneStub;
/* Initialize Input Device Managers */
mwIdevTbl[0] = cMSDRIVER;
mwIdevTbl[1] = (long) &BankStub;
mwIdevTbl[2] = 0xffff;
return;
}
/* Function nuResume catches up the cursor tracking when the updating was
held off by the grafMap being busy. This routine is called when a
primitive operation increments the grafMaps mapLock semaphore to zero,
and the grafMaps mfPending flag has been set. It is also called if the
semaphore somehow is incremented greater than 0. */
void nuResume(grafMap *argGRAFMAP)
{
/* check if we were called because of lock level problems */
if (argGRAFMAP->mapLock > 0)
{ /* yes */
argGRAFMAP->mapLock = 0; /* reset on error */
nuGrafErr(c_CursLevel); /* post error */
return;
}
argGRAFMAP->mapLock--; /* lock grafMap */
do{
argGRAFMAP->mapFlags &= ~mfPending; /* clear defered flag */
/* get the current input device X,Y */
MovCursIDV(curInput->mrEvent.evntX, curInput->mrEvent.evntY);
} while (argGRAFMAP->mapFlags & mfPending); /* loop if deferred flag went on
while we were updating */
argGRAFMAP->mapLock++; /* unlock grafMap */
return;
}
/* Function InitBitmap initializes the passed grafMap using internal data
associated with the passed device code. For the 'virtual' devices MEM, EMS,
XMS, or DISK, the grafMaps size items must be set as requested. For the
'USER' device the grafMaps size items as well as mapFlags, and devTech must
be set as requested. RowTables are not allocated.
Primitives/managers will be registered (or allocated and loaded). Rowtables
will be allocated and initialized (unless cUSER). The device manager will
be called for wake up.
This module also obtains the pointer to access screen memory.
Returns: 0 = ok
-1 = (reserved for no TSR shell present)
-2 = Unknown device
-3 = Can't alloc rowtables or other (out of memory)
-4 = can't map in devices physical memory (protected mode)
-5 = device doesn't respond
-6 = can't load driver
*/
int InitBitmap(int argDEVICE, grafMap *argGRAFMAP)
{
typedef struct _DSPstruc{ /* Display Parameter Structure */
byte initFlags; /* initgrafix flags */
short rowByte; /* Bytes per scan line/row */
short dvTech; /* Device technology */
short interLeave; /* Scan line interleave factor */
short pixDev; /* Device code & font # */
short pixWth; /* Pixel width */
short pixHgt; /* Pixel height */
short pixRsX; /* Pixel resolution horz. */
short pixRsY; /* Pixel resolution vert. */
byte pixBit; /* Color bits per pixel */
byte pixPln; /* Color planes per pixel */
short interOff; /* Interleave offset */
short interSeg; /* Interleave segment */
long baseAdr[4]; /* Base address (4 planes max) */
} DSPstruc;
/* initFlags bits */
#define inFldRT 1 /* fold rowtables into one */
#define inXRow 2 /* add extra row for off-screen cursor routines */
#define inLinear 4 /* rowtable is linear */
#define inVgaHw 8 /* can do VGA chain-4 mode */
#define in565 16 /* use 5:6:5 hicolor format */
int rtnCode; /* return value */
int plns; /* Number of planes to process */
int rtSize; /* size in bytes of rowtable */
DSPstruc *devTblPtr; /* pointer to device table */
short grafErrValue; /* GrafError error value */
long *tempPtr;
int dispSize;
/* Display Parameter Tables */
/* A Note About Pixel Resolution: Referencing MS windows documentation;
Size resX resY
320x200 34 28
640x200 68 28
640x350 68 50
640x480 68 68 (SQ PIXELS)
800x600 85 85 (SQ PIXELS)
1024x768 108 108 (SQ PIXELS) */
DSPstruc tMEM1x1 = { /* Worlds smallest bitmap */
inLinear, /*initFlags */
1, /*rowByte - Bytes/Scan */
dtUser, /*dvTech - Device technology */
1, /*interLeave - */
0, /*pixDev - Device code */
1, /*pixWth - Pixel width */
1, /*pixHgt - Pixel height */
100, /*pixRsX - Pixel resolution horz. */
100, /*PixRsY - Pixel resolution vert. */
1, /*pixBit - Bits per pixel */
1, /*pixPln - Planes per pixel */
0, /*interOff - Interleave offset */
0, /*interSeg - Interleave segment */
0}; /*baseAdr0 - none */
DSPstruc dtLCD = { /*Generic LCD - 320x240 256-Color */
inLinear, /*initFlags */
320, /*rowByte - Bytes/Scan */
0, /*dvTech - Device technology */
1, /*InterLeave - */
0, /*pixDev - Device code */
320, /*pixWth - Pixel width */
240, /*pixHgt - Pixel height */
34, /*pixRsX - Pixel resolution horz. */
34, /*PixRsY - Pixel resolution vert. */
8, /*pixBit - Bits per pixel */
1, /*pixPln - Planes per pixel */
0, /*interOff - Interleave offset */
0, /*interSeg - Interleave segment */
LCDBASE}; /*baseAdr0 - Base address 0 */
DSPstruc dtLCD1 = { /* Generic LCD - 160x240 Monocolor */
inLinear, /*initFlags */
20, /*rowByte - Bytes/Scan */
dtMono, /*dvTech - Device technology */
1, /*InterLeave - */
0, /*pixDev - Device code */
160, /*pixWth - Pixel width */
240, /*pixHgt - Pixel height */
34, /*pixRsX - Pixel resolution horz. */
34, /*PixRsY - Pixel resolution vert. */
1, /*pixBit - Bits per pixel */
1, /*pixPln - Planes per pixel */
0, /*interOff - Interleave offset */
0, /*interSeg - Interleave segment */
LCDBASE}; /*baseAdr0 - Base address 0 */
DSPstruc dtLCD2 = { /* LCD - 160x240 4-Color */
inLinear, /*initFlags */
40, /*rowByte - Bytes/Scan */
dtBits, /*dvTech - Device technology */
1, /*InterLeave - */
0, /*pixDev - Device code */
160, /*pixWth - Pixel width */
240, /*pixHgt - Pixel height */
34, /*pixRsX - Pixel resolution horz. */
34, /*PixRsY - Pixel resolution vert. */
2, /*pixBit - Bits per pixel */
1, /*pixPln - Planes per pixel */
0, /*interOff - Interleave offset */
0, /*interSeg - Interleave segment */
LCDBASE}; /*baseAdr0 - Base address 0 */
DSPstruc dtLCD4 = { /* LCD - 160x240 16-Color */
inLinear, /*initFlags */
80, /*rowByte - Bytes/Scan */
dtBits, /*dvTech - Device technology */
1, /*InterLeave - */
0, /*pixDev - Device code */
160, /*pixWth - Pixel width */
240, /*pixHgt - Pixel height */
34, /*pixRsX - Pixel resolution horz. */
34, /*PixRsY - Pixel resolution vert. */
4, /*pixBit - Bits per pixel */
1, /*pixPln - Planes per pixel */
0, /*interOff - Interleave offset */
0, /*interSeg - Interleave segment */
LCDBASE}; /*baseAdr0 - Base address 0 */
rtnCode = 0; /* start with good return code */
/* first set fields that all types of grafMap must have set */
argGRAFMAP->cbSyncFunc = nuResume; /* call back to cursor resync function */
argGRAFMAP->cbPostErr = nuGrafErr; /* call back to post an error */
argGRAFMAP->mapLock = -1; /* start grafMap busy semaphore locked */
argGRAFMAP->mapFlags = 0; /* clear mapFlags */
argGRAFMAP->devClass = 0; /* clear device class */
/* clear bank management fields */
argGRAFMAP->mapWinType = 0;
argGRAFMAP->mapWinPlane = 0;
argGRAFMAP->mapWinYmin[0] = 0;
argGRAFMAP->mapWinYmin[1] = 0;
argGRAFMAP->mapWinScans = -2;
argGRAFMAP->mapWinYmax[0] = -2;
argGRAFMAP->mapWinYmax[1] = -2;
argGRAFMAP->devMode = argDEVICE; /* set device code */
/* is this a real device or one of our 'virtual' types? */
switch (argDEVICE)
{
case cUSER: /* User bitmap? */
devTblPtr = &tMEM1x1;
goto LoadDriver;
case cMEMORY: /* memory bitmap? */
rtnCode = mwIMEM(argGRAFMAP); /* init a memory bitmap */
if (rtnCode != 0) /* problems? */
{
if (rtnCode == c_OutofMem)
{
rtnCode = -3; /* say out of memory */
}
else
{
if (rtnCode == -1)
{
rtnCode = -6; /* say can't load driver */
}
else
{
rtnCode = -5; /* say device doesn't respond */
}
}
}
goto FinishUp1;
/* ok, it's not one of ours, look up device code in Graphics Device Table */
case cLCD: /* Generic LCD */
devTblPtr = &dtLCD;
break;
case cLCD1: /* 1-bit LCD */
devTblPtr = &dtLCD1;
break;
case cLCD2: /* 2-bit LCD */
devTblPtr = &dtLCD2;
break;
case cLCD4: /* 4-bit LCD */
devTblPtr = &dtLCD4;
break;
case cNODEVICE: /* no device required */
devTblPtr = &tMEM1x1;
break;
default: /* can't find that device code */
rtnCode = -2;
grafErrValue = c_InitBitm + c_BadDev;
nuGrafErr(grafErrValue);
doNoDevice:
argDEVICE = cNODEVICE;
argGRAFMAP->devMode = argDEVICE;
devTblPtr = &tMEM1x1;
}
/* Initialize the passed GrafMap */
if (devTblPtr->initFlags & inLinear)
argGRAFMAP->mapFlags |= mfRowTabl; /* in linear mode? */
if (devTblPtr->initFlags & inVgaHw)
argGRAFMAP->mapFlags |= mfVgaHw; /* in VGA mode? */
if (devTblPtr->initFlags & in565)
argGRAFMAP->mapFlags |= mf565; /* hicolor format? */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -