📄 auxcow.c
字号:
/***
*auxcow.c - CW auxiliary code
*
* Copyright <C> 1985-1988, Microsoft Corporation
*
*Purpose:
* Support code for CW.
*
*******************************************************************************/
#include <version.h>
/* Next, include COW's interface headers */
#include <cw/version.h>
#include <cw/windows.h>
#include <cw/edityp.h>
#include <cw/color.h>
#include <uiext.h>
/* and the dialog headers */
#include <cw/dlg.h>
/* Next, include QBI's headers */
#ifndef QBIMSGS_H
#include <qbimsgs.h>
#endif
#ifndef UI_H
#include <ui.h>
#endif
#ifndef UIINT_H
#include <uiint.h>
#endif
#define UE_COLORS FALSE //[16] set this switch to get color sets
//[16] for user ed screen shots.
/* these must be exported */
VOID FAR PASCAL OutOfMemory(void);
VOID * FAR PASCAL PbAllocWork(WORD);
VOID FAR PASCAL FreeWork(VOID *);
/* Fake LMEM */
VOID ** FAR PASCAL PpvAllocCb(WORD, WORD);
VOID FAR PASCAL FreePpv(WORD, VOID **);
VOID FARPUBLIC UpdateShiftKk (WORD, WORD);
VOID FARPUBLIC UpdateShiftKj (WORD, WORD); // [44]
DWORD FAR PASCAL GlobalHandle (HANDLE);
HANDLE FAR PASCAL GlobalRealloc (HANDLE, DWORD, WORD);
BOOL FAR PASCAL PlayBackMsg(MSG *);
void FAR PASCAL RecordMsg(MSG *);
void NEAR PASCAL DumpScreen(void);
VOID FAR PASCAL BackToCow (WORD); // [22]
VOID FAR PASCAL ShrinkHelp (VOID); //[41]
char cGlobalAlloc = 0; //[41] Net # BDL's GlobalAlloc allocated
BYTE fPlayBack = FALSE, fRecord = FALSE;
BYTE fPlaybackInit = TRUE; //[41]
BYTE fBdlInit = FALSE; //[41]
extern BOOL fCapLock, fNumLock;
extern boolean fAccelCmd;
extern BYTE fMono; //[26] Must have own monochrome flag
extern AX axMouse; // [45]
extern AY ayMouse; // [45]
extern SA PASCAL rgsa[];
/***
*VOID FARPUBLIC UpdateShiftKk (kkNew, kkOld)
*Purpose:
* Set Userinterface flags for CAPLOCK and NUMLOCK shift states so that
* DrawToggles reflects this status properly, and make sure that
* SCRLOCK changes get a synthesize character to make playback/record
* screen dumps work properly.
*
*Entry:
* kkNew New KK_ shift states.
* kkOld Old KK_ shift states.
*
* fCapLock flag telling current user interface CAPLOCK status.
* fNumLock flag telling current user interface NUMLOCK status.
*
*Exit:
* fCapLock and fNumLock are set to reflect the shift states in kkNew.
*
*Exceptions:
* None.
*******************************************************************************/
VOID FARPUBLIC
UpdateShiftKk (kkNew, kkOld)
WORD kkNew, kkOld;
{
fCapLock = kkNew & KK_CAPLOCK;
fNumLock = kkNew & KK_NUMLOCK;
DrawToggles ();
/* [2] Synthesize VK_SCRLOCK if the shift state changes, so
* [2] we get screen dumps properly
*/
kkNew &= KK_SCRLOCK; /* [4] */
kkOld &= KK_SCRLOCK; /* [4] */
if (kkNew ^ kkOld)
SynthesizeShiftKeys (kkNew, kkOld);
}
/* [5] Global variable defining the mode we start up in */
WORD iModeCurrent = 0;
/***
*void NEAR CwInit ()
*Purpose:
* Set up screen mode for CW, and initialize window structure.
*
*Entry:
* None.
*
*Exit:
* None.
*
*Exceptions:
* None.
*******************************************************************************/
void NEAR CwInit ()
{
REG1 short i;
AY ay = 0;
INST inst;
extern BYTE fWaitRetrace; // [23]
ayMouse = 0; //[45]
axMouse = 0; //[45]
iModeCurrent = ImodeGuessCurrent (); /* [5] */
// [12] If the mode is unknown, or we have a flag to get the highest possible
// [12] mode, then loop until we find it.
if (cmdSwitches & CMD_SW_HIR) { // [12]
for (i = 0; FQueryInst (&inst, i); i++) { // [12]
if (inst.finst & finstAvailable) {
if ((inst.ayMac > ay) || // [20]
(inst.ayMac == ay && !(inst.finst & finstMonochrome))) { // [20]
ay = inst.ayMac; // [12]
iModeCurrent = i; // [12]
}
} // [12]
} // [12]
} // [12]
if (iModeCurrent == imodeUnknown) { // [20]
ay = 255; // [26] Set it to be MAXay at start
for (i = 0; FQueryInst (&inst, i); i++) { // [20]
if (inst.finst & finstAvailable) { // [20]
if ((inst.ayMac < ay) || // [20]
(inst.ayMac == ay && !(inst.finst & finstMonochrome))) { // [20]
ay = inst.ayMac; // [20]
iModeCurrent = i; // [20]
} // [20]
} // [20]
} // [20]
} // [20]
DbAssert (iModeCurrent != imodeUnknown);
EnableVidsMonitor (TRUE); // [38] [39]
SaveUserScreen ();
if (!FQueryInst (&inst, iModeCurrent))
DbAssert (FALSE);
if (!FInitScreen (&inst))
DbAssert (FALSE);
DrawDebugScr ();
fDebugScr = TRUE;
if ((inst.finst & finstQuestionable) && // [23]
!(cmdSwitches & CMD_SW_GLT)) // [23]
fWaitRetrace = TRUE; // [23]
fInitColorTable (); // [20]
// [26] This must follow CwReInit (so fMonochrome is set)
fMono = (BYTE) (fMonochrome || (cmdSwitches & CMD_SW_MNO));
// [47] Check for /Editor switch
if (cmdSwitches & CMD_SW_ED) {
extern char szWildDefault[];
extern short iMsgStatusLine;
strcpy(szWildDefault, "*"); // Default is *.TXT for QEDIT
iMsgStatusLine = MSG_StatusQEdit;
}
WndInit ();
}
/***
*void NEAR CwHook ()
*Purpose:
* Make sure that CW is hooked back in. This is called when we re-enter
* the user interface.
*
*Entry:
* None.
*
*Exit:
* None.
*
*Exceptions:
* None.
*******************************************************************************/
void NEAR CwHook ()
{
BackToCow (TRUE); // [22]
EnableKeyboard(TRUE); // [40]Enable keyboard
}
/***
*void NEAR CwUnHook ()
*Purpose:
* Make sure that CW is unhooked. This is called when we exit the user
* interface.
*
*Entry:
* None.
*
*Exit:
* None.
*
*Exceptions:
* None.
*******************************************************************************/
void NEAR CwUnHook ()
{
LeaveCow (FALSE);
}
/***
*void NEAR CwTerm ()
*Purpose:
* Terminate CW. This is called when we are ending the program, or when
* we shell out.
*
*Entry:
* None.
*
*Exit:
* None.
*
*Exceptions:
* None.
*******************************************************************************/
void NEAR CwTerm ()
{
EnableVidsMonitor (FALSE); // [38]
LeaveCow (FALSE);
}
/***
*VOID FAR PASCAL OutOfMemory ()
*Purpose:
* This is called by CW to indicate an out of memory condition.
*
*Entry:
* None.
*
*Exit:
* None.
*
*Exceptions:
* None.
*******************************************************************************/
VOID FAR PASCAL
OutOfMemory()
{
SetUiErrOm ();
}
#define MAX_LOCAL 10 + 2 //[41] Options/Paths + Slop
bd bdlocal[MAX_LOCAL];
/***
*VOID ** FAR PASCAL PpvAllocCb (sb, cb)
*Purpose:
* Return handle to a near memory allocation.
*
*Entry:
* sb Unused parameter.
* cb Number of bytes to allocate.
*
* bdlocal is an array of bd's to use to allocate the near memory.
*
*Exit:
* Returns pointer to bd's pointer to data.
*
*Exceptions:
* None.
*******************************************************************************/
VOID ** FAR PASCAL
PpvAllocCb (sb, cb)
WORD sb; /* ignored */
WORD cb; /* size of block */
{
bd *pbd = NULL;
int i;
Unreferenced (sb);
for (i = 0; i < MAX_LOCAL; i++) {
if (bdlocal[i].pb == NULL) {
pbd = &bdlocal[i];
break;
}
}
DbAssert (pbd != NULL); //[4] NOTE: when you get this, bump MAX_LOCAL
if (!BdAlloc (pbd, cb, IT_NO_OWNERS))
return (NULL);
return (&(pbd->pb));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -