📄 lcd_dvc.c
字号:
argGRAFMAP->devClass = devTblPtr->pixDev;
argGRAFMAP->devTech = devTblPtr->dvTech;
argGRAFMAP->pixWidth = devTblPtr->pixWth;
argGRAFMAP->pixHeight = devTblPtr->pixHgt;
argGRAFMAP->pixBits = devTblPtr->pixBit;
argGRAFMAP->pixPlanes = devTblPtr->pixPln;
argGRAFMAP->pixBytes = devTblPtr->rowByte;
argGRAFMAP->pixResX = devTblPtr->pixRsX;
argGRAFMAP->pixResY = devTblPtr->pixRsY;
/* Allocate display memory if LCD */
if(argDEVICE & cLCD)
{
/* BobB 10/14/99 - correct for 64K boundary problem
devTblPtr->baseAdr[0] = (long) GrafAlloc(argGRAFMAP->pixBytes *
argGRAFMAP->pixHeight * argGRAFMAP->pixPlanes); */
dispSize = (long) (argGRAFMAP->pixBytes * argGRAFMAP->pixHeight *
argGRAFMAP->pixPlanes);
devTblPtr->baseAdr[0] = (long) GrafAlloc(dispSize);
if(devTblPtr->baseAdr[0] == 0)
{
rtnCode = -3; /* say out of memory */
goto doNoDevice; /* do null device */
}
/* BobB 10/14/99 - correct for 64K boundary problem */
if(((devTblPtr->baseAdr[0] + dispSize) & 0xffff) < dispSize)
{ /* Must go above boundary */
tempPtr = (long *) devTblPtr->baseAdr[0]; /* save old start */
devTblPtr->baseAdr[0] = (long) GrafAlloc(dispSize); /* alloc new */
GrafFree(tempPtr); /* free old */
}
}
LoadDriver:
/* initialize primitives */
if (InitGrafDriver(argGRAFMAP) != 0)
{ /* error initialinzing the device */
rtnCode = -6;
goto doNoDevice; /* do null device */
}
/* issue devMgr call to wake-up device - this could modify fields
in the grafMap if it wanted to */
if (argGRAFMAP->mapDevMgr(argGRAFMAP, 0, devTblPtr->baseAdr[0]) != 0)
{ /* error - won't wake up */
#ifdef ErrChecks
grafErrValue = c_InitBitm + c_InvDevFunc;
nuGrafErr(grafErrValue);
#endif
rtnCode = -5;
}
/* Initialize the rowtable(s) & mapTable pointers
Note: mapWinScans must be set correctly at this point */
if ((argDEVICE == cUSER) || (argDEVICE == cNODEVICE)) goto FinishUp;
argGRAFMAP->mapTable[0] = 0; /* null out first mapTable pointer */
argGRAFMAP->pixHeight++;
rtSize = argGRAFMAP->pixHeight << 2; /* size of a rowtable */
for (plns = 0; plns < argGRAFMAP->pixPlanes; plns++)
{ /* build a rowtable for each plane */
argGRAFMAP->mapTable[plns] = (long **) GrafAlloc(rtSize);
if (argGRAFMAP->mapTable[plns] == 0) /* check for null returned */
{
rtnCode = -3;
goto doNoDevice; /* do null device */
}
/* map physical video memory to logical address */
if (nuMapPhysAdr(&devTblPtr->baseAdr[plns], 2,
argGRAFMAP->mapTable[plns]) != 0)
{ /* can't map it in! */
rtnCode = -4;
goto doNoDevice; /* do null device */
}
if (devTblPtr->initFlags & inFldRT) /* is the fold rowtables flag on? */
{ /* yes, point all four mapTable entries to the one rowtable */
argGRAFMAP->mapTable[1] = argGRAFMAP->mapTable[0];
argGRAFMAP->mapTable[2] = argGRAFMAP->mapTable[0];
argGRAFMAP->mapTable[3] = argGRAFMAP->mapTable[0];
break;
}
}
/* Now, all the planes have Rowtables, the address of the rowtables are
placed into grafMap.mapTable[n], and the address of each raster line in
the bitmap is in grafMap.mapTable[n]->rowtable[0].
Now we can fill out the rest of the rowtable entries */
InitRowTable(argGRAFMAP, devTblPtr->interLeave, devTblPtr->interSeg,
devTblPtr->interOff);
argGRAFMAP->pixHeight--; /* put back to normal */
FinishUp1:
FinishUp:
argGRAFMAP->mapNextSel = dllSeg; /* put dll seg and fixup in grafMap */
tempPtr = (long *) &argGRAFMAP->mapAltMgr;
*tempPtr = dllFixup;
if (argGRAFMAP->mapWinType == 0) return(rtnCode); /* done if mapWinType = 0 */
argGRAFMAP->mapFlags |= mfBankMgr; /* Initialize for bank management */
if (argGRAFMAP->pixPlanes > 1)
argGRAFMAP->mapFlags |= mfPlaneMgr; /* requires plane management */
argGRAFMAP->mapWinYmin[0] = -1; /* invalidate bank (no active bank) */
argGRAFMAP->mapWinYmin[1] = -1;
argGRAFMAP->mapWinYmax[0] = -1;
argGRAFMAP->mapWinYmax[1] = -1;
return(rtnCode);
}
/* Function SetBitmap modifies the passed bitmap in the following ways:
if argPAGE = PGALL: replaces the bitmaps rowtable with one to
address all pages
else: modifies the bitmaps existing rowtable to address the graphics
page enumerated by the lower 8 bits of argPAGE.
NOTE!! These routines assume that the planes are all folded to one rowtable.
This is the case for all hardware that this function looks up in its
supported table. */
void SetBitmap(int argPAGE, grafMap *argGMAP)
{
#define PGALL 255
#define pageCur mapTable[4]
#define pageMax mapTable[5]
#define pageScans mapTable[6]
#define numDev2Pg 1
word dev2Pg[numDev2Pg][3]; /* Device IDs and offsets to second page bitmap */
word pg1Offset;
short maxPages;
long pageSize;
long baseAdr;
long **rowAdr;
long **oldAdr;
long pageOffset;
short devCode;
int i;
int j;
short grafErrValue;
devCode = (short) argGMAP->devMode;
for (i = 0; i < numDev2Pg; i++)
{ /* look up device code in second page table */
if (devCode == dev2Pg[i][0]) goto FoundIt;
}
grafErrValue = c_SetGrafM + c_InvDevFunc;
nuGrafErr(grafErrValue); /* post error */
return;
FoundIt:
pg1Offset = dev2Pg[i][1]; /* offset to next page */
maxPages = dev2Pg[i][2]; /* max number of pages */
/* what function are we doing? */
if (argPAGE == PGALL)
{ /* replace current rowtable with one large enough to access
all pages of the display */
pageSize = ((maxPages * argGMAP->pixHeight) + 1) << 2;
rowAdr = (long **) GrafAlloc(pageSize);
if (rowAdr == 0) /* check for null returned */
{
grafErrValue = c_SetGrafM + c_OutofMem;
nuGrafErr(grafErrValue); /* post error */
return;
}
oldAdr = argGMAP->mapTable[0];
#ifdef FIXUP386
/* unfixup the old dll relative maptable pointer to be ds relative */
oldAdr -= dllFixup;
#endif
/* replace all 4 maptable entries with with new table */
argGMAP->mapTable[0] = rowAdr;
argGMAP->mapTable[1] = rowAdr;
argGMAP->mapTable[2] = rowAdr;
argGMAP->mapTable[3] = rowAdr;
baseAdr = (long) *oldAdr; /* get original base address */
GrafFree(oldAdr); /* chuck old rowtable */
/* init rowtable sections for each page */
for (j = 0; j < maxPages; j++)
{
for (i = 0; i < argGMAP->pixHeight; i++)
{
*rowAdr = (long *) (baseAdr + i * argGMAP->pixBytes);
rowAdr++;
}
baseAdr += pg1Offset; /* add offset for next time */
}
argGMAP->pixHeight *= maxPages; /* update pixHeight */
#ifdef FIXUP386
/* fixup the ds relative maptable pointers to be dll relative */
argGMAP->mapTable[0] += dllFixup;
argGMAP->mapTable[1] += dllFixup;
argGMAP->mapTable[2] += dllFixup;
argGMAP->mapTable[3] += dllFixup;
#endif
}
else
{ /* adjust current rowtable to point to requested page */
rowAdr = argGMAP->mapTable[0]; /* get the grafMaps rowtable 0 pointer */
#ifdef FIXUP386
/* unfixup the dll relative maptable pointer to be ds relative */
rowAdr -= dllFixup;
#endif
argPAGE &= 0xFF; /* mask all but low 8 bits */
if (argPAGE >= maxPages) /* check for valid page request */
{
nuGrafErr(c_InvDevFunc); /* post error */
return;
}
/* compute signed offset from current page to requested page
'fifth' planes maptable pointer holds current page */
pageOffset = (argPAGE - (long) argGMAP->pageCur) * pg1Offset;
if (pageOffset != 0)
{ /* offset the (one and only) rowtable to new page */
for (i = 0; i < argGMAP->pixHeight; i++)
{
*rowAdr += pageOffset;
rowAdr++;
}
argGMAP->pageCur = (long **) argPAGE; /* update current 'page' */
}
}
return;
}
/* Function InitGrafDriver initializes the passed grafMap primitive pointers
using internal data associated with the passed grafMaps devTech field. It
also inits bank manager and device manager using internal data associated
with the passed grafMaps devMode field.
Returns: 0 = OK, -1 = can't resolve driver. */
int InitGrafDriver(grafMap *argGRAFMAP)
{
void InitBankMgr(grafMap *argGRAFMAP);
void InitDevMgr(grafMap *argGRAFMAP);
short grafErrValue;
int retCode = 0;
/* Device primitives function prototypes */
void PrimErr();
int iPrimErr();
long lPrimErr();
void mwFL2_4B();
void mwPBSS2_4B();
void mwPB1S2_4B();
void mwRDIM2_4B();
void mwWRIM2_4B();
void mwLI2_4B();
void mwSP2_4B();
long mwGP2_4B();
void mwFL1Bit();
void mwPBSS1Bit();
void mwPBMS1Bit();
void mwRDIM1Bit();
void mwWRIM1Bit();
void mwLI1Bit();
void mwSP1Bit();
long mwGP1Bit();
void mwFLA0();
void mwPBAAA();
void mwPBMAB();
void mwRDIMA();
void mwWRIMA();
void mwLIA();
void mwSPA();
long mwGPA();
/* check that the devTech is in range */
if (argGRAFMAP->devTech > 8)
{ /* error */
grafErrValue = c_InitBitm + c_BadDevTech;
nuGrafErr(grafErrValue);
retCode = -1;
}
switch (argGRAFMAP->devTech)
{
case 0: /* 8-bit LCD */
argGRAFMAP->mapBankMgr = iPrimErr; /* Ptr to bank manager function */
argGRAFMAP->mapPlaneMgr = PrimErr; /* Ptr to plane manager function */
argGRAFMAP->mapAltMgr = PrimErr; /* Ptr to alt manager function */
argGRAFMAP->mapDevMgr = iPrimErr; /* Ptr to device manager list */
argGRAFMAP->prFill = mwFLA0; /* primitive vector for fills */
argGRAFMAP->prBlitSS = mwPBAAA; /* primitive vector for self-self blits */
argGRAFMAP->prBlit1S = mwPBMAB; /* primitive vector for mono-self blits */
argGRAFMAP->prBlitMS = mwPBAAA; /* primitive vector for mem-self blits */
argGRAFMAP->prBlitSM = mwPBAAA; /* primitive vector for self-mem blits */
argGRAFMAP->prRdImg = mwRDIMA; /* primitive vector for read image */
argGRAFMAP->prWrImg = mwWRIMA; /* primitive vector for write image */
argGRAFMAP->prLine = mwLIA; /* primitive vector for thin lines */
argGRAFMAP->prSetPx = mwSPA; /* primitive vector for set pixel */
argGRAFMAP->prGetPx = mwGPA; /* primitive vector for get pixel */
break;
case 1: /* 1-bit LCD/Memory */
argGRAFMAP->mapBankMgr = iPrimErr; /* Ptr to bank manager function */
argGRAFMAP->mapPlaneMgr = PrimErr; /* Ptr to plane manager function */
argGRAFMAP->mapAltMgr = PrimErr; /* Ptr to alt manager function */
argGRAFMAP->mapDevMgr = iPrimErr; /* Ptr to device manager list */
argGRAFMAP->prFill = mwFL1Bit; /* primitive vector for fills */
argGRAFMAP->prBlitSS = mwPBSS1Bit; /* primitive vector for self-self blits */
argGRAFMAP->prBlit1S = mwPBMS1Bit; /* primitive vector for mono-self blits */
argGRAFMAP->prBlitMS = mwPBSS1Bit; /* primitive vector for mem-self blits */
argGRAFMAP->prBlitSM = mwPBSS1Bit; /* primitive vector for self-mem blits */
argGRAFMAP->prRdImg = mwRDIM1Bit; /* primitive vector for read image */
argGRAFMAP->prWrImg = mwWRIM1Bit; /* primitive vector for write image */
argGRAFMAP->prLine = mwLI1Bit; /* primitive vector for thin lines */
argGRAFMAP->prSetPx = mwSP1Bit; /* primitive vector for set pixel */
argGRAFMAP->prGetPx = mwGP1Bit; /* primitive vector for get pixel */
break;
case 2: /* 2/4-bit LCD/Memory */
argGRAFMAP->mapBankMgr = iPrimErr; /* Ptr to bank manager function */
argGRAFMAP->mapPlaneMgr = PrimErr; /* Ptr to plane manager function */
argGRAFMAP->mapAltMgr = PrimErr; /* Ptr to alt manager function */
argGRAFMAP->mapDevMgr = iPrimErr; /* Ptr to device manager list */
argGRAFMAP->prFill = mwFL2_4B; /* primitive vector for fills */
argGRAFMAP->prBlitSS = mwPBSS2_4B; /* primitive vector for self-self blits */
argGRAFMAP->prBlit1S = mwPB1S2_4B; /* primitive vector for mono-self blits */
argGRAFMAP->prBlitMS = mwPBSS2_4B; /* primitive vector for mem-self blits */
argGRAFMAP->prBlitSM = mwPBSS2_4B; /* primitive vector for self-mem blits */
argGRAFMAP->prRdImg = mwRDIM2_4B; /* primitive vector for read image */
argGRAFMAP->prWrImg = mwWRIM2_4B; /* primitive vector for write image */
argGRAFMAP->prLine = mwLI2_4B; /* primitive vector for thin lines */
argGRAFMAP->prSetPx = mwSP2_4B; /* primitive vector for set pixel */
argGRAFMAP->prGetPx = mwGP2_4B; /* primitive vector for get pixel */
break;
case 8: /* 8-Bit */
argGRAFMAP->mapBankMgr = iPrimErr; /* Ptr to bank manager function */
argGRAFMAP->mapPlaneMgr = PrimErr; /* Ptr to plane manager function */
argGRAFMAP->mapAltMgr = PrimErr; /* Ptr to alt manager function */
argGRAFMAP->mapDevMgr = iPrimErr; /* Ptr to device manager list */
argGRAFMAP->prFill = mwFLA0; /* primitive vector for fills */
argGRAFMAP->prBlitSS = mwPBAAA; /* primitive vector for self-self blits */
argGRAFMAP->prBlit1S = mwPBMAB; /* primitive vector for mono-self blits */
argGRAFMAP->prBlitMS = mwPBAAA; /* primitive vector for mem-self blits */
argGRAFMAP->prBlitSM = mwPBAAA; /* primitive vector for self-mem blits */
argGRAFMAP->prRdImg = mwRDIMA; /* primitive vector for read image */
argGRAFMAP->prWrImg = mwWRIMA; /* primitive vector for write image */
argGRAFMAP->prLine = mwLIA; /* primitive vector for thin lines */
argGRAFMAP->prSetPx = mwSPA; /* primitive vector for set pixel */
argGRAFMAP->prGetPx = mwGPA; /* primitive vector for get pixel */
break;
default:/* Null */
argGRAFMAP->mapBankMgr = iPrimErr; /* Ptr to bank manager function */
argGRAFMAP->mapPlaneMgr = PrimErr; /* Ptr to plane manager function */
argGRAFMAP->mapAltMgr = PrimErr; /* Ptr to alt manager function */
argGRAFMAP->mapDevMgr = iPrimErr; /* Ptr to device manager list */
argGRAFMAP->prFill = PrimErr; /* primitive vector for fills */
argGRAFMAP->prBlitSS = PrimErr; /* primitive vector for self-self blits */
argGRAFMAP->prBlit1S = PrimErr; /* primitive vector for mono-self blits */
argGRAFMAP->prBlitMS = PrimErr; /* primitive vector for mem-self blits */
argGRAFMAP->prBlitSM = PrimErr; /* primitive vector for self-mem blits */
argGRAFMAP->prRdImg = PrimErr; /* primitive vector for read image */
argGRAFMAP->prWrImg = PrimErr; /* primitive vector for write image */
argGRAFMAP->prLine = PrimErr; /* primitive vector for thin lines */
argGRAFMAP->prSetPx = PrimErr; /* primitive vector for set pixel */
argGRAFMAP->prGetPx = lPrimErr; /* primitive vector for get pixel */
}
/* init the bank and device managers from internal tables */
InitBankMgr(argGRAFMAP);
InitDevMgr(argGRAFMAP);
return(retCode);
}
/* Function CloseGrafDriver frees the display memory allocation */
int CloseGrafDriver(grafMap *argGRAFMAP)
{
argGRAFMAP->mapDevMgr(argGRAFMAP, DMSHUTDOWN, 0);
return(0);
}
/* Function InitBankMgr initializes the passed grafMaps bank/plane
managers and map fields using internal data associated with the grafMaps
devMode code. If a device has no entry, BankStub and PlaneStub are used.
BankStub posts an error, as it should never be called. PlaneStub is a
null routine, it justs updates mapWinPlane. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -