⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wndo0.c

📁 nucleus 文件系统,内核和彩色图形系统,在小系统上非常好用
💻 C
字号:
/*************************************************************************/
/*                                                                       */
/*         Copyright (c) 1997 - 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          */
/*                                                                       */
/*      WNDO0.c                                          1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the StubIDV, nuDefFont and InitGraphics       */
/* functions.                                                            */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      Robert G. Burrill, Accelerated Technology, Inc.                  */
/*                                                                       */
/* DATA STRUCTURES                                                       */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* FUNCTIONS                                                             */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* DEPENDENCIES                                                          */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         NAME            DATE                    REMARKS               */
/*                                                                       */
/*         BobB          11/16/99    Got rid of ANSI compiler warnings   */
/*                                                                       */
/*************************************************************************/

#include "meta_wnd.h"
#include "metconst.h"    /* MetaWINDOW Constant & Stucture Definitions */
#include "metports.h"    /* MetaWINDOW Port & Bitmap Definitions */
#include "grafdata.h"
#include "file.h"


/* Function nuDefFont is an internal routine used to find, allocate, and load
the system font associated with the default ports device class. If the font
can not be loaded, the imbedded system font will be used in place. */

void nuDefFont(void)
{
	/* template for system font resource name */
	const char SysfntName[15] = "system__.fnt";
	char fntNameBuf[15];	/* font file name buffer */
	dirRec fntDirRec;	/* font directory buffer */
	int i;
	short grafErrValue;
	int ResrcQuery(char *rscname, dirRec *dirBuff, int argCount);
	int ResrcLoad(char *rscname, void *buffer, int size);
	void *GrafAlloc(int memSize);

	/* make a name out of the device class code */

	/* copy over the template name string to temp buffer */
	for (i = 0; i < 15; i++)
	{
		fntNameBuf[i] = SysfntName[i];
	}
	i = defGrafMap.devClass & 0xF8;	/*ignore planes or bits/pix */
	fntNameBuf[6] = (i / 10) + 0x30;	/* convert to ascii */
	fntNameBuf[7] = (i % 10) + 0x30;

	/* find size of resource */
	if (ResrcQuery(&fntNameBuf[0], &fntDirRec, 1) == 1)
	{	/* get memory to load it */
		defFont = (char *) GrafAlloc(fntDirRec.fSize);
		if (defFont != NULL)
		{	/* load resource */
			if (ResrcLoad(&fntNameBuf[0], defFont, fntDirRec.fSize) >= 0)
				return;
		}
	}

	/* if we get here we can't load a default font, use the imbeded font */
	defFont = imbFnt;
	grafErrValue = c_InitGraf + c_FileErr; /* post an error */
	nuGrafErr(grafErrValue);
	return;
}


/* Function InitGraphics initializes the system, and a default metaport and
grafMap.

It also allocates memory using the GrafAlloc function for:
	1) a driver and rowtables (via InitBitmap() ).
	2) the memory pool.
	3) load a default font.

argDEVICE defines the graphics display type. */

int InitGraphics(int argDEVICE)
{
	/* return codes */
#define AlreadyInitd	 1	/* InitGraphics has already been called */
#define NoShell			-1	/* The Metagraphics Driver ( METASHEL.EXE ) is not installed */
#define Bad_DEV			-2	/* Passed value is not a known device */
#define RowTblERR		-3	/* Error allocating rowtables */
#define MapError		-4	/* Can't map in device's physical memory */
#define SleepyDev		-5	/* Device won't respond */

	int rtnCode;	/* place to keep error code */
	short aeSegInfo;
	short beSegInfo;
	short dsSegInfo;
	int i;
	int InitBitmap(int argDEVICE, grafMap *argGRAFMAP);
	void *GrafAlloc(int memSize);
	void InitPort(metaPort *argPORT);
	void nuSegInfo(short *aePtr, short *bePtr, short *dsPtr);
	void StubIDV();
	int StubIDVI();

	/* set some GRAFIX_DATA globals to zero */
	if (gFlags & gfGrafInit)	/* have we already been here? */
		return(AlreadyInitd);	/* yes, leave with error returned */

	NU_InitGrafVars();	/* Initialize certain graphics variables */

	grafError = 0;
	LocX = 0;
	LocY = 0;

	/* set cursor defaults */
	CursorNumbr = 0;	/* cursor style 0 */
	CursBackColor = 0;	/* cursor back color = black */
	CursForeColor = -1;	/* cursor fore color = white */
	CursorLevel = -1;	/* cursor is not visible */

	/* disable protect rect, force off grafMap */
	CursProtXmin = 0x7FFF;
	ProtXmin = 0x7F00;	/* leave some calulation range */

	curInput = &defMouse;	/* set default input device record */
	eventMask = mPRESS + mREL + mKEYDN;	/* set default event mask */

	/* Set blitRcd vars */
	grafBlit.blitFlags = bfClipRect;	/* rectangular clipping */
	grafBlit.blitCnt = 1;
	grafBlit.blitClip = &ViewClip;
	grafBlit.blitList = (long) &grafBlist;
	grafBlit.blitAlloc = 2 * sizeof(rect);

	/* Clear any notion of loaded driver resources */
	for (i = 0; i < NUMDLTBL; i++)
	{
		DLTable[i].DLnum = -1;
	}

	/* Clear out all the indirect vector pointers */
	QueueIDV = (long) &StubIDV;
	lineExecIDV = (long) &StubIDV;
	lineThinIDV = (long) &StubIDV;
	lineDashIDV = (long) &StubIDV;	
	linePattIDV = (long) &StubIDV;
	lineOvalIDV = (long) &StubIDV;
	lineOvPolyIDV = (long) &StubIDV;
	lineSqPolyIDV = (long) &StubIDV;
	TrackIDV = StubIDV;
	MovCursIDV = StubIDV;
	txtAlnIDV = StubIDV;
	txtDrwIDV = StubIDV;
	txtAPPIDV = StubIDV;
	txtStrokeIDV = StubIDV;
	stpEventIDV = StubIDV;
	stpMouseIDV = StubIDVI;

	/* Clear out memory pool pointers */
  	mpWorkSpace = 0;
 	mpWorkEnd = 0;
	mpRowTblSz = 0;

	/* Fetch the hugeSelAdd word value from the OS and store it in grafdata
	Also fill in biosSeg word val with whats required to access BIOS area */
	nuSegInfo(&aeSegInfo, &beSegInfo, &dsSegInfo);
	biosSeg = aeSegInfo;
#ifdef CPU386
	hugeSelAdd = dsSegInfo;	/* save ds here for Borland DOS32 */
	dllSeg = dsSegInfo;	/* set defaults for dll seg and fixup */
	dllFixup = 0;
#else
	hugeSelAdd = beSegInfo;
#endif

	/* initialize the default structures */

	rtnCode = InitBitmap(argDEVICE, &defGrafMap);	/* initialize the Default
							grafMap, use memory alloc for driver and rowtables */
	nuDefFont();	/* load a default font - use memory alloc */
	mpWorkSpace = (byte *) GrafAlloc(mpSize);	/* allocate pool memory */
	if (mpWorkSpace != NULL)
		mpWorkEnd = (byte *)((unsigned)mpWorkSpace + mpSize);

	/* make the cursor grafMap = the default grafMap */
	cursBlit.blitDmap = &defGrafMap;

	/* place default cursor position on grafMap */
	CursorX = (defGrafMap.pixWidth >> 1);	/* use half-way point */
	CursorY = (defGrafMap.pixHeight >> 1);

	InitPort(&defPort);	/* Initialize the Default Port */

#ifdef FIXUP386
	/* fixup pattern list pointers */
	for (i = 0; i < 32; i++)
	{
		patTable.patPtr[i] = (pattern *)(((long) patTable.patPtr[i])
			+ dllFixup);
	}
#endif

	gFlags = gfGrafInit;	/* reset and mark as been inited */
	return(rtnCode);
}

/* Function StubIDV is a stub routine placed in all indirect vectors
just in case they get called inadvertantly */
void StubIDV(void)
{
	nuGrafErr(c_IDVectNotSet);
	return;
}

int StubIDVI(void)
{
	nuGrafErr(c_IDVectNotSet);
	return(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -