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

📄 auxcow.c

📁 [随书类]Dos6.0源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*** 
*VOID FAR PASCAL FreePpv (sb, ppv)
*Purpose:
*	Free a handle to near memory.
*
*Entry:
*	sb		Unused parameter.
*	ppv		Pointer to pointer to memory in bd.
*
*Exit:
*	None.
*
*Exceptions:
*	None.
*******************************************************************************/
VOID FAR PASCAL
FreePpv (sb, ppv)
/*
  -- free local block (return NULL)
*/
WORD sb;
VOID ** ppv;
{
    bd *pbd = (bd *) (ppv - 1);

    Unreferenced (sb);

    BdFree (pbd);
}


	//[41] If we don't want to have to shrink help down, we must
	//[41] increase MAX_GLOBAL to have 18 extra bdl's for help slop
	//[41] instead of the 11 we have given it.  Doing the compression
	//[41] saves 56 bytes of DGROUP that isn't really needed.
#define MAX_GLOBAL	(3 * 2) + 3 + 3 + 9 + 2		//[41]
			//[41] 3 list boxes at a time @ 2 allocs/box
			//[41] + 3 help file names
			//[41] + 3 help engine FDB's
			//[41] + 9 more for help system (can't always compress)
			//[41] + 2 slop

bdl bdlglobal[MAX_GLOBAL];

/*** 
*HANDLE FAR PASCAL GlobalAlloc (flags, cb)
*Purpose:
*	Allocate a handle to far memory.
*
*	This doesn't return a REAL handle, but GlobalHandle is called to
*	get the segment, so we do the translation ourselves.
*
*Entry:
*	flags		Unused parameter.
*	cb		Number of bytes to allocate.
*
*Exit:
*	Return pointer to bdl's seg.
*
*Exceptions:
*	None.
*******************************************************************************/
HANDLE FAR PASCAL
GlobalAlloc (flags, cb)
WORD flags;
DWORD cb;
{
    int i;
    bdl *pbdl = NULL;

    Unreferenced (flags);

    if (!fBdlInit) {			//[41]
	fBdlInit = TRUE;		//[41]
	for (i = 0; i < MAX_GLOBAL; i++) {
	    bdlglobal[i].seg = NOT_OWNER;
	}
    }
    if (cGlobalAlloc >= MAX_GLOBAL-2)	//[41] if getting close to being full
	ShrinkHelp();			//[41] reduce # of help entries
	//[41] The 2 above is the magic # of items that HelpDecomp allocates
	//[41] Since ShrinkHelp doesn't do anything when called from HelpDecomp,
	//[41] we need to have 2 handles in reserve.

    for (i = 0; i < MAX_GLOBAL; i++) {
	if (bdlglobal[i].seg == NOT_OWNER) {
	    pbdl = &bdlglobal[i];
	    break;
	}
    }
    DbAssert (pbdl != NULL);	//[4] NOTE: when you get this, bump MAX_GLOBAL
    if (!BdlAlloc (pbdl, (WORD) cb))
	return (NULL);

    cGlobalAlloc++;			//[41] one more allocated
    return ((HANDLE) &pbdl->seg);
}

/*** 
*HANDLE FAR PASCAL GlobalFree (hmem)
*Purpose:
*	Free a handle to far memory.
*
*Entry:
*	hmem		Handle to far memory.
*
*Exit:
*	None.
*
*Exceptions:
*	None.
*******************************************************************************/
HANDLE FAR PASCAL
GlobalFree (hmem)
HANDLE hmem;
{
    REG1 WORD *h = (WORD *) ((WORD) hmem);
    bdl *pbdl = (bdl *) (h - 1);

    BdlFree (pbdl);

    cGlobalAlloc--;			//[41] one less allocated
    DbAssert (cGlobalAlloc >= 0)	//[41] GlobalFree w/o GlobalAlloc

    return ((HANDLE) NULL);
}


/*** 
*DWORD FAR PASCAL GlobalHandle (hmem)
*Purpose:
*	Called by CW to convert a handle into a DWORD, each WORD of which
*	contains the handle's segment.
*
*Entry:
*	hmem		Handle to far memory.
*
*Exit:
*	Return handle's segment.
*
*Exceptions:
*	None.
*******************************************************************************/
DWORD FAR PASCAL
GlobalHandle (hmem)
HANDLE hmem;
{
    REG1 WORD *h = (WORD *) ((WORD) hmem);
    return ((DWORD) MAKELONG (GETSEG(*h), GETSEG(*h)));
}

/*** 
*HANDLE FAR PASCAL GlobalRealloc (hmem, cb, flags)
*Purpose:
*	Realloc a handle to far memory.
*
*Entry:
*	hmem		Handle to far memory.
*	cb		Number of bytes to reallocate to.
*	flags		Unused parameter.
*
*Exit:
*	Returns reallocated handle.
*
*Exceptions:
*	None.
*******************************************************************************/
HANDLE FAR PASCAL
GlobalRealloc (hmem, cb, flags)
HANDLE hmem;
DWORD cb;
WORD flags;
{
    REG1 WORD *h = (WORD *) ((WORD) hmem);
    bdl *pbdl = (bdl *) (h - 1);

    Unreferenced (flags);

    if (!BdlRealloc (pbdl, (WORD) cb))
	return (NULL);
    return ((HANDLE) &pbdl->seg);
}

/*** 
*VOID NEAR PASCAL DumpScreen ()
*Purpose:
*	Dump the entire screen to disk.
*
*Entry:
*	Description of each formal parameter.
*	Any important global variables used as parameters (implied parameters).
*
*Exit:
*	None.
*
*Exceptions:
*	None.
*******************************************************************************/
VOID NEAR PASCAL
DumpScreen ()
{
    register AY ay;
    WORD pwBuff[80];
    static WORD fdScreen = UNDEFINED;
    static char header[4] = { 2, 0, 0 };
    RRC rrc;

    rrc.rxLeft = 0;
    rrc.rxRight = axMac;
    if (fdScreen == UNDEFINED) {
	fdScreen = CreateFile("screen");
	if (fdScreen == UNDEFINED)
	    return;
	header[3] = ayMac;
	WriteFile (fdScreen, header, 4 );
    }

    for (ay=0; ay < ayMac; ay++) {
	rrc.ryTop = ay;
	rrc.ryBottom = ay+1;
	DbAssert (CwSizeRrc (&rrc) <= 80);
	SaveRrc (NULL, &rrc, (BYTE *) pwBuff);
	WriteFile (fdScreen, (char *) pwBuff, 80 * sizeof (WORD));
    }

    /* Make sure buffer gets flushed right away */
    FlushFile (fdScreen);
}


/*** 
*BOOL FAR PASCAL PlayBackMsg (pmsg)
*Purpose:
*	Try to read input message from playback file.
*
*Entry:
*	pmsg		pointer to structure to contain message read in.
*
*	fRecord 	global flag is TRUE if QB was started with the /rcd
*			flag, and we haven't opened any playback file.
*	fPlayback	global flag is TRUE if we have opened a playback file.
*	fPlaybackInit	static flag is TRUE if we have tried to open a
*			playback file.
*	fdPlayBack	static file descriptor for PlayBackMsg.
*Exit:
*	Returns TRUE if there was a message to be read, otherwise FALSE.
*
*Exceptions:
*	None.
*******************************************************************************/
BOOL FAR PASCAL
PlayBackMsg (pmsg)
MSG *pmsg;
{
    static WORD fdPlayBack = UNDEFINED;

    if (fPlaybackInit) {			//[41]
	fPlaybackInit = FALSE;			//[41]
	if (fRecord) {
	    fdPlayBack = OpenFile ("playback");
	    if (fdPlayBack != UNDEFINED) {
		fPlayBack = TRUE;
		fRecord = FALSE;
	    }
	}
    }

    if (fPlayBack) {
	if (ReadFile (fdPlayBack, (char *) pmsg, sizeof (MSG)) == sizeof (MSG)) {
	    pmsg->time = ClockTicks ();
	    /* [2] Check for VK_SCRLOCK in PlayBackMsg as well as RecordMsg */
	    if (pmsg->message == WM_CHAR && pmsg->wParam == VK_SCRLOCK) {
		DumpScreen ();
	    }
	}
	else {
	    fPlayBack = FALSE;
	    CloseFileNear (fdPlayBack); //[24]
	}
    }

    return (fPlayBack);
}

#define FKeyMsg(x) (((x) >= WM_KEYFIRST) && ((x) <= WM_KEYLAST))
#define FMouseMsg(x) (((x) >= WM_MOUSEFIRST) && ((x) <= WM_MOUSELAST))

/*** 
*VOID NEAR PASCAL RecordMsg (pmsg)
*Purpose:
*	Write the message in pmsg to the record file.
*
*Entry:
*	pmsg		pmsg is a pointer to a message structure to save in
*			the record file.
*
*	fRecord 	global flag is TRUE if QB was started with the /rcd
*			flag, and we haven't opened any playback file.
*	fdRecord	static file descriptor for the record file.
*
*Exit:
*	None.
*
*Exceptions:
*	None.
*******************************************************************************/
void FAR PASCAL
RecordMsg(pmsg)
MSG *pmsg;
{
    static WORD fdRecord = UNDEFINED;

    if (fRecord) {
	if (fdRecord == 0xffff)
	    fdRecord = CreateFile ("record");
	if (fdRecord != 0xffff &&
	    (FMouseMsg (pmsg->message) || FKeyMsg (pmsg->message))) {
		/* [2] VK_OEM_SCROLL -> VK_SCRLOCK */
		if (pmsg->message == WM_CHAR && pmsg->wParam == VK_SCRLOCK) {
		    DumpScreen ();
		}
		WriteFile( fdRecord, (char *) pmsg, sizeof(MSG) );
		/* Make sure buffer gets flushed right away */
		FlushFile (fdRecord);
	}
    }
}

⌨️ 快捷键说明

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