mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
Formatting changes to jmact
git-svn-id: https://svn.eduke32.com/eduke32@809 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
2fa3153a84
commit
3c51265878
8 changed files with 1322 additions and 1185 deletions
|
@ -51,11 +51,11 @@ static boolean Anim_Started = false;
|
|||
//
|
||||
//****************************************************************************
|
||||
|
||||
static void CheckAnimStarted ( char * funcname )
|
||||
{
|
||||
if (!Anim_Started)
|
||||
Error("ANIMLIB_%s: Anim has not been initialized\n",funcname);
|
||||
}
|
||||
static void CheckAnimStarted(char * funcname)
|
||||
{
|
||||
if (!Anim_Started)
|
||||
Error("ANIMLIB_%s: Anim has not been initialized\n",funcname);
|
||||
}
|
||||
//****************************************************************************
|
||||
//
|
||||
// findpage ()
|
||||
|
@ -63,22 +63,22 @@ static void CheckAnimStarted ( char * funcname )
|
|||
//
|
||||
//****************************************************************************
|
||||
|
||||
uint16 findpage (uint16 framenumber)
|
||||
{
|
||||
uint16 i;
|
||||
uint16 findpage(uint16 framenumber)
|
||||
{
|
||||
uint16 i;
|
||||
|
||||
CheckAnimStarted ( "findpage" );
|
||||
for(i=0; i<anim->lpheader.nLps; i++)
|
||||
{
|
||||
if
|
||||
(
|
||||
anim->LpArray[i].baseRecord <= framenumber &&
|
||||
anim->LpArray[i].baseRecord + anim->LpArray[i].nRecords > framenumber
|
||||
)
|
||||
return(i);
|
||||
}
|
||||
return(i);
|
||||
}
|
||||
CheckAnimStarted("findpage");
|
||||
for (i=0; i<anim->lpheader.nLps; i++)
|
||||
{
|
||||
if
|
||||
(
|
||||
anim->LpArray[i].baseRecord <= framenumber &&
|
||||
anim->LpArray[i].baseRecord + anim->LpArray[i].nRecords > framenumber
|
||||
)
|
||||
return(i);
|
||||
}
|
||||
return(i);
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
|
@ -88,32 +88,32 @@ uint16 findpage (uint16 framenumber)
|
|||
//
|
||||
//****************************************************************************
|
||||
|
||||
void loadpage (uint16 pagenumber, uint16 *pagepointer)
|
||||
{
|
||||
int32 size;
|
||||
byte * buffer;
|
||||
void loadpage(uint16 pagenumber, uint16 *pagepointer)
|
||||
{
|
||||
int32 size;
|
||||
byte * buffer;
|
||||
|
||||
CheckAnimStarted ( "loadpage" );
|
||||
buffer = anim->buffer;
|
||||
if (anim->curlpnum != pagenumber)
|
||||
{
|
||||
anim->curlpnum = pagenumber;
|
||||
buffer += 0xb00 + (pagenumber*0x10000);
|
||||
size = sizeof(lp_descriptor);
|
||||
/*
|
||||
Bmemcpy(&anim->curlp,buffer,size);
|
||||
CheckAnimStarted("loadpage");
|
||||
buffer = anim->buffer;
|
||||
if (anim->curlpnum != pagenumber)
|
||||
{
|
||||
anim->curlpnum = pagenumber;
|
||||
buffer += 0xb00 + (pagenumber*0x10000);
|
||||
size = sizeof(lp_descriptor);
|
||||
/*
|
||||
Bmemcpy(&anim->curlp,buffer,size);
|
||||
|
||||
// JBF: why didn't this get read from the LpArray[] table?
|
||||
anim->curlp.baseRecord = B_LITTLE16(anim->curlp.baseRecord);
|
||||
anim->curlp.nRecords = B_LITTLE16(anim->curlp.nRecords);
|
||||
anim->curlp.nBytes = B_LITTLE16(anim->curlp.nBytes);
|
||||
*/
|
||||
Bmemcpy(&anim->curlp, &anim->LpArray[pagenumber], size);
|
||||
// JBF: why didn't this get read from the LpArray[] table?
|
||||
anim->curlp.baseRecord = B_LITTLE16(anim->curlp.baseRecord);
|
||||
anim->curlp.nRecords = B_LITTLE16(anim->curlp.nRecords);
|
||||
anim->curlp.nBytes = B_LITTLE16(anim->curlp.nBytes);
|
||||
*/
|
||||
Bmemcpy(&anim->curlp, &anim->LpArray[pagenumber], size);
|
||||
|
||||
buffer += size + sizeof(uint16);
|
||||
Bmemcpy(pagepointer,buffer,anim->curlp.nBytes+(anim->curlp.nRecords*2));
|
||||
}
|
||||
}
|
||||
buffer += size + sizeof(uint16);
|
||||
Bmemcpy(pagepointer,buffer,anim->curlp.nBytes+(anim->curlp.nRecords*2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
|
@ -123,76 +123,80 @@ void loadpage (uint16 pagenumber, uint16 *pagepointer)
|
|||
//
|
||||
//****************************************************************************
|
||||
|
||||
void CPlayRunSkipDump (char *srcP, char *dstP)
|
||||
{
|
||||
signed char cnt;
|
||||
uint16 wordCnt;
|
||||
byte pixel;
|
||||
void CPlayRunSkipDump(char *srcP, char *dstP)
|
||||
{
|
||||
signed char cnt;
|
||||
uint16 wordCnt;
|
||||
byte pixel;
|
||||
|
||||
|
||||
nextOp:
|
||||
cnt = (signed char) *srcP++;
|
||||
if (cnt > 0)
|
||||
goto dump;
|
||||
if (cnt == 0)
|
||||
goto run;
|
||||
cnt -= 0x80;
|
||||
if (cnt == 0)
|
||||
goto longOp;
|
||||
/* shortSkip */
|
||||
dstP += cnt; /* adding 7-bit count to 32-bit pointer */
|
||||
goto nextOp;
|
||||
cnt = (signed char) *srcP++;
|
||||
if (cnt > 0)
|
||||
goto dump;
|
||||
if (cnt == 0)
|
||||
goto run;
|
||||
cnt -= 0x80;
|
||||
if (cnt == 0)
|
||||
goto longOp;
|
||||
/* shortSkip */
|
||||
dstP += cnt; /* adding 7-bit count to 32-bit pointer */
|
||||
goto nextOp;
|
||||
dump:
|
||||
do
|
||||
{
|
||||
*dstP++ = *srcP++;
|
||||
} while (--cnt);
|
||||
goto nextOp;
|
||||
do
|
||||
{
|
||||
*dstP++ = *srcP++;
|
||||
}
|
||||
while (--cnt);
|
||||
goto nextOp;
|
||||
run:
|
||||
wordCnt = (byte)*srcP++; /* 8-bit unsigned count */
|
||||
pixel = *srcP++;
|
||||
do
|
||||
{
|
||||
*dstP++ = pixel;
|
||||
} while (--wordCnt);
|
||||
wordCnt = (byte)*srcP++; /* 8-bit unsigned count */
|
||||
pixel = *srcP++;
|
||||
do
|
||||
{
|
||||
*dstP++ = pixel;
|
||||
}
|
||||
while (--wordCnt);
|
||||
|
||||
goto nextOp;
|
||||
goto nextOp;
|
||||
longOp:
|
||||
wordCnt = B_LITTLE16(*((uint16 *)srcP));
|
||||
srcP += sizeof(uint16);
|
||||
if ((int16)wordCnt <= 0)
|
||||
goto notLongSkip; /* Do SIGNED test. */
|
||||
wordCnt = B_LITTLE16(*((uint16 *)srcP));
|
||||
srcP += sizeof(uint16);
|
||||
if ((int16)wordCnt <= 0)
|
||||
goto notLongSkip; /* Do SIGNED test. */
|
||||
|
||||
/* longSkip. */
|
||||
dstP += wordCnt;
|
||||
goto nextOp;
|
||||
/* longSkip. */
|
||||
dstP += wordCnt;
|
||||
goto nextOp;
|
||||
|
||||
notLongSkip:
|
||||
if (wordCnt == 0)
|
||||
goto stop;
|
||||
wordCnt -= 0x8000; /* Remove sign bit. */
|
||||
if (wordCnt >= 0x4000)
|
||||
goto longRun;
|
||||
if (wordCnt == 0)
|
||||
goto stop;
|
||||
wordCnt -= 0x8000; /* Remove sign bit. */
|
||||
if (wordCnt >= 0x4000)
|
||||
goto longRun;
|
||||
|
||||
/* longDump. */
|
||||
do
|
||||
{
|
||||
*dstP++ = *srcP++;
|
||||
} while (--wordCnt);
|
||||
goto nextOp;
|
||||
/* longDump. */
|
||||
do
|
||||
{
|
||||
*dstP++ = *srcP++;
|
||||
}
|
||||
while (--wordCnt);
|
||||
goto nextOp;
|
||||
|
||||
longRun:
|
||||
wordCnt -= 0x4000; /* Clear "longRun" bit. */
|
||||
pixel = *srcP++;
|
||||
do
|
||||
{
|
||||
*dstP++ = pixel;
|
||||
} while (--wordCnt);
|
||||
goto nextOp;
|
||||
wordCnt -= 0x4000; /* Clear "longRun" bit. */
|
||||
pixel = *srcP++;
|
||||
do
|
||||
{
|
||||
*dstP++ = pixel;
|
||||
}
|
||||
while (--wordCnt);
|
||||
goto nextOp;
|
||||
|
||||
stop: /* all done */
|
||||
;
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -203,34 +207,34 @@ stop: /* all done */
|
|||
//
|
||||
//****************************************************************************
|
||||
|
||||
void renderframe (uint16 framenumber, uint16 *pagepointer)
|
||||
{
|
||||
uint16 offset=0;
|
||||
uint16 i;
|
||||
uint16 destframe;
|
||||
byte *ppointer;
|
||||
void renderframe(uint16 framenumber, uint16 *pagepointer)
|
||||
{
|
||||
uint16 offset=0;
|
||||
uint16 i;
|
||||
uint16 destframe;
|
||||
byte *ppointer;
|
||||
|
||||
CheckAnimStarted ( "renderframe" );
|
||||
destframe = framenumber - anim->curlp.baseRecord;
|
||||
CheckAnimStarted("renderframe");
|
||||
destframe = framenumber - anim->curlp.baseRecord;
|
||||
|
||||
for(i = 0; i < destframe; i++)
|
||||
{
|
||||
offset += B_LITTLE16(pagepointer[i]);
|
||||
}
|
||||
ppointer = (byte *)pagepointer;
|
||||
for (i = 0; i < destframe; i++)
|
||||
{
|
||||
offset += B_LITTLE16(pagepointer[i]);
|
||||
}
|
||||
ppointer = (byte *)pagepointer;
|
||||
|
||||
ppointer+=anim->curlp.nRecords*2+offset;
|
||||
if(ppointer[1])
|
||||
{
|
||||
ppointer += (4 + B_LITTLE16(((uint16 *)ppointer)[1]) + (B_LITTLE16(((uint16 *)ppointer)[1]) & 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
ppointer+=4;
|
||||
}
|
||||
ppointer+=anim->curlp.nRecords*2+offset;
|
||||
if (ppointer[1])
|
||||
{
|
||||
ppointer += (4 + B_LITTLE16(((uint16 *)ppointer)[1]) + (B_LITTLE16(((uint16 *)ppointer)[1]) & 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
ppointer+=4;
|
||||
}
|
||||
|
||||
CPlayRunSkipDump ((char *)ppointer, (char *)anim->imagebuffer);
|
||||
}
|
||||
CPlayRunSkipDump((char *)ppointer, (char *)anim->imagebuffer);
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
|
@ -240,12 +244,12 @@ void renderframe (uint16 framenumber, uint16 *pagepointer)
|
|||
//
|
||||
//****************************************************************************
|
||||
|
||||
void drawframe (uint16 framenumber)
|
||||
{
|
||||
CheckAnimStarted ( "drawframe" );
|
||||
loadpage(findpage(framenumber), anim->thepage);
|
||||
renderframe(framenumber, anim->thepage);
|
||||
}
|
||||
void drawframe(uint16 framenumber)
|
||||
{
|
||||
CheckAnimStarted("drawframe");
|
||||
loadpage(findpage(framenumber), anim->thepage);
|
||||
renderframe(framenumber, anim->thepage);
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
|
@ -254,54 +258,55 @@ void drawframe (uint16 framenumber)
|
|||
//
|
||||
//****************************************************************************
|
||||
|
||||
void ANIM_LoadAnim (char * buffer)
|
||||
{
|
||||
uint16 i;
|
||||
int32 size;
|
||||
void ANIM_LoadAnim(char * buffer)
|
||||
{
|
||||
uint16 i;
|
||||
int32 size;
|
||||
|
||||
if (!Anim_Started) {
|
||||
anim = SafeMalloc(sizeof(anim_t));
|
||||
Anim_Started = true;
|
||||
}
|
||||
if (!Anim_Started)
|
||||
{
|
||||
anim = SafeMalloc(sizeof(anim_t));
|
||||
Anim_Started = true;
|
||||
}
|
||||
|
||||
anim->buffer = (unsigned char *)buffer;
|
||||
anim->curlpnum = 0xffff;
|
||||
anim->currentframe = -1;
|
||||
size = sizeof(lpfileheader);
|
||||
Bmemcpy(&anim->lpheader, buffer, size );
|
||||
anim->buffer = (unsigned char *)buffer;
|
||||
anim->curlpnum = 0xffff;
|
||||
anim->currentframe = -1;
|
||||
size = sizeof(lpfileheader);
|
||||
Bmemcpy(&anim->lpheader, buffer, size);
|
||||
|
||||
anim->lpheader.id = B_LITTLE32(anim->lpheader.id);
|
||||
anim->lpheader.maxLps = B_LITTLE16(anim->lpheader.maxLps);
|
||||
anim->lpheader.nLps = B_LITTLE16(anim->lpheader.nLps);
|
||||
anim->lpheader.nRecords = B_LITTLE32(anim->lpheader.nRecords);
|
||||
anim->lpheader.maxRecsPerLp = B_LITTLE16(anim->lpheader.maxRecsPerLp);
|
||||
anim->lpheader.lpfTableOffset = B_LITTLE16(anim->lpheader.lpfTableOffset);
|
||||
anim->lpheader.contentType = B_LITTLE32(anim->lpheader.contentType);
|
||||
anim->lpheader.width = B_LITTLE16(anim->lpheader.width);
|
||||
anim->lpheader.height = B_LITTLE16(anim->lpheader.height);
|
||||
anim->lpheader.nFrames = B_LITTLE32(anim->lpheader.nFrames);
|
||||
anim->lpheader.framesPerSecond = B_LITTLE16(anim->lpheader.framesPerSecond);
|
||||
|
||||
buffer += size+128;
|
||||
// load the color palette
|
||||
for (i = 0; i < 768; i += 3)
|
||||
{
|
||||
anim->pal[i+2] = *buffer++;
|
||||
anim->pal[i+1] = *buffer++;
|
||||
anim->pal[i] = *buffer++;
|
||||
buffer++;
|
||||
}
|
||||
// read in large page descriptors
|
||||
size = sizeof(anim->LpArray);
|
||||
Bmemcpy(&anim->LpArray,buffer,size);
|
||||
anim->lpheader.id = B_LITTLE32(anim->lpheader.id);
|
||||
anim->lpheader.maxLps = B_LITTLE16(anim->lpheader.maxLps);
|
||||
anim->lpheader.nLps = B_LITTLE16(anim->lpheader.nLps);
|
||||
anim->lpheader.nRecords = B_LITTLE32(anim->lpheader.nRecords);
|
||||
anim->lpheader.maxRecsPerLp = B_LITTLE16(anim->lpheader.maxRecsPerLp);
|
||||
anim->lpheader.lpfTableOffset = B_LITTLE16(anim->lpheader.lpfTableOffset);
|
||||
anim->lpheader.contentType = B_LITTLE32(anim->lpheader.contentType);
|
||||
anim->lpheader.width = B_LITTLE16(anim->lpheader.width);
|
||||
anim->lpheader.height = B_LITTLE16(anim->lpheader.height);
|
||||
anim->lpheader.nFrames = B_LITTLE32(anim->lpheader.nFrames);
|
||||
anim->lpheader.framesPerSecond = B_LITTLE16(anim->lpheader.framesPerSecond);
|
||||
|
||||
for (i = 0; i < size/sizeof(lp_descriptor); i++)
|
||||
{
|
||||
anim->LpArray[i].baseRecord = B_LITTLE16(anim->LpArray[i].baseRecord);
|
||||
anim->LpArray[i].nRecords = B_LITTLE16(anim->LpArray[i].nRecords);
|
||||
anim->LpArray[i].nBytes = B_LITTLE16(anim->LpArray[i].nBytes);
|
||||
}
|
||||
}
|
||||
buffer += size+128;
|
||||
// load the color palette
|
||||
for (i = 0; i < 768; i += 3)
|
||||
{
|
||||
anim->pal[i+2] = *buffer++;
|
||||
anim->pal[i+1] = *buffer++;
|
||||
anim->pal[i] = *buffer++;
|
||||
buffer++;
|
||||
}
|
||||
// read in large page descriptors
|
||||
size = sizeof(anim->LpArray);
|
||||
Bmemcpy(&anim->LpArray,buffer,size);
|
||||
|
||||
for (i = 0; i < size/sizeof(lp_descriptor); i++)
|
||||
{
|
||||
anim->LpArray[i].baseRecord = B_LITTLE16(anim->LpArray[i].baseRecord);
|
||||
anim->LpArray[i].nRecords = B_LITTLE16(anim->LpArray[i].nRecords);
|
||||
anim->LpArray[i].nBytes = B_LITTLE16(anim->LpArray[i].nBytes);
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
//
|
||||
|
@ -309,14 +314,14 @@ void ANIM_LoadAnim (char * buffer)
|
|||
//
|
||||
//****************************************************************************
|
||||
|
||||
void ANIM_FreeAnim ( void )
|
||||
{
|
||||
if (Anim_Started)
|
||||
{
|
||||
SafeFree(anim);
|
||||
Anim_Started = false;
|
||||
}
|
||||
}
|
||||
void ANIM_FreeAnim(void)
|
||||
{
|
||||
if (Anim_Started)
|
||||
{
|
||||
SafeFree(anim);
|
||||
Anim_Started = false;
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
//
|
||||
|
@ -324,11 +329,11 @@ void ANIM_FreeAnim ( void )
|
|||
//
|
||||
//****************************************************************************
|
||||
|
||||
int32 ANIM_NumFrames ( void )
|
||||
{
|
||||
CheckAnimStarted ( "NumFrames" );
|
||||
return anim->lpheader.nRecords;
|
||||
}
|
||||
int32 ANIM_NumFrames(void)
|
||||
{
|
||||
CheckAnimStarted("NumFrames");
|
||||
return anim->lpheader.nRecords;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
//
|
||||
|
@ -336,24 +341,24 @@ int32 ANIM_NumFrames ( void )
|
|||
//
|
||||
//****************************************************************************
|
||||
|
||||
byte * ANIM_DrawFrame (int32 framenumber)
|
||||
{
|
||||
int32 cnt;
|
||||
byte * ANIM_DrawFrame(int32 framenumber)
|
||||
{
|
||||
int32 cnt;
|
||||
|
||||
CheckAnimStarted ( "DrawFrame" );
|
||||
if ((anim->currentframe != -1) && (anim->currentframe<=framenumber))
|
||||
{
|
||||
for (cnt = anim->currentframe; cnt < framenumber; cnt++)
|
||||
drawframe (cnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (cnt = 0; cnt < framenumber; cnt++)
|
||||
drawframe (cnt);
|
||||
}
|
||||
anim->currentframe = framenumber;
|
||||
return anim->imagebuffer;
|
||||
}
|
||||
CheckAnimStarted("DrawFrame");
|
||||
if ((anim->currentframe != -1) && (anim->currentframe<=framenumber))
|
||||
{
|
||||
for (cnt = anim->currentframe; cnt < framenumber; cnt++)
|
||||
drawframe(cnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (cnt = 0; cnt < framenumber; cnt++)
|
||||
drawframe(cnt);
|
||||
}
|
||||
anim->currentframe = framenumber;
|
||||
return anim->imagebuffer;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
//
|
||||
|
@ -361,8 +366,8 @@ byte * ANIM_DrawFrame (int32 framenumber)
|
|||
//
|
||||
//****************************************************************************
|
||||
|
||||
byte * ANIM_GetPalette ( void )
|
||||
{
|
||||
CheckAnimStarted ( "GetPalette" );
|
||||
return anim->pal;
|
||||
}
|
||||
byte * ANIM_GetPalette(void)
|
||||
{
|
||||
CheckAnimStarted("GetPalette");
|
||||
return anim->pal;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* control.c
|
||||
* MACT library controller handling
|
||||
*
|
||||
*
|
||||
* Derived from MACT386.LIB disassembly by Jonathon Fowler
|
||||
*
|
||||
*/
|
||||
|
@ -50,7 +50,7 @@ static boolean CONTROL_MouseButtonClickedState[MAXMOUSEBUTTONS], CONTROL_JoyButt
|
|||
static boolean CONTROL_MouseButtonClicked[MAXMOUSEBUTTONS], CONTROL_JoyButtonClicked[MAXJOYBUTTONS];
|
||||
static byte CONTROL_MouseButtonClickedCount[MAXMOUSEBUTTONS], CONTROL_JoyButtonClickedCount[MAXJOYBUTTONS];
|
||||
static boolean CONTROL_UserInputCleared[3];
|
||||
static int32 (*GetTime)(void);
|
||||
static int32(*GetTime)(void);
|
||||
static boolean CONTROL_Started = false;
|
||||
static int32 ticrate;
|
||||
static int32 CONTROL_DoubleClickSpeed;
|
||||
|
@ -92,7 +92,7 @@ boolean CONTROL_StartMouse(void)
|
|||
return MOUSE_Init();
|
||||
}
|
||||
|
||||
void CONTROL_GetJoyAbs( void )
|
||||
void CONTROL_GetJoyAbs(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ void CONTROL_FilterJoyDelta(void)
|
|||
{
|
||||
}
|
||||
|
||||
void CONTROL_GetJoyDelta( void )
|
||||
void CONTROL_GetJoyDelta(void)
|
||||
{
|
||||
int32 i;
|
||||
|
||||
|
@ -139,12 +139,18 @@ void CONTROL_SetFlag(int32 which, boolean active)
|
|||
{
|
||||
if (CONTROL_CheckRange(which)) return;
|
||||
|
||||
if (CONTROL_Flags[which].toggle == INSTANT_ONOFF) {
|
||||
if (CONTROL_Flags[which].toggle == INSTANT_ONOFF)
|
||||
{
|
||||
CONTROL_Flags[which].active = active;
|
||||
} else {
|
||||
if (active) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
CONTROL_Flags[which].buttonheld = false;
|
||||
} else if (CONTROL_Flags[which].buttonheld == false) {
|
||||
}
|
||||
else if (CONTROL_Flags[which].buttonheld == false)
|
||||
{
|
||||
CONTROL_Flags[which].buttonheld = true;
|
||||
CONTROL_Flags[which].active = (CONTROL_Flags[which].active ? false : true);
|
||||
}
|
||||
|
@ -181,7 +187,7 @@ void CONTROL_ClearKeyboardFunction(int32 which)
|
|||
KB_KeyDown[ CONTROL_KeyMapping[which].key2 ] = 0;
|
||||
}
|
||||
|
||||
void CONTROL_DefineFlag( int32 which, boolean toggle )
|
||||
void CONTROL_DefineFlag(int32 which, boolean toggle)
|
||||
{
|
||||
if (CONTROL_CheckRange(which)) return;
|
||||
|
||||
|
@ -192,14 +198,14 @@ void CONTROL_DefineFlag( int32 which, boolean toggle )
|
|||
CONTROL_Flags[which].cleared = 0;
|
||||
}
|
||||
|
||||
boolean CONTROL_FlagActive( int32 which )
|
||||
boolean CONTROL_FlagActive(int32 which)
|
||||
{
|
||||
if (CONTROL_CheckRange(which)) return false;
|
||||
|
||||
return CONTROL_Flags[which].used;
|
||||
}
|
||||
|
||||
void CONTROL_MapKey( int32 which, kb_scancode key1, kb_scancode key2 )
|
||||
void CONTROL_MapKey(int32 which, kb_scancode key1, kb_scancode key2)
|
||||
{
|
||||
if (CONTROL_CheckRange(which)) return;
|
||||
|
||||
|
@ -211,7 +217,8 @@ void CONTROL_PrintKeyMap(void)
|
|||
{
|
||||
int32 i;
|
||||
|
||||
for (i=0;i<CONTROL_NUM_FLAGS;i++) {
|
||||
for (i=0;i<CONTROL_NUM_FLAGS;i++)
|
||||
{
|
||||
initprintf("function %2ld key1=%3x key2=%3x\n",
|
||||
i, CONTROL_KeyMapping[i].key1, CONTROL_KeyMapping[i].key2);
|
||||
}
|
||||
|
@ -230,29 +237,33 @@ void CONTROL_PrintAxes(void)
|
|||
int32 i;
|
||||
|
||||
initprintf("nummouseaxes=%d\n", CONTROL_NumMouseAxes);
|
||||
for (i=0;i<CONTROL_NumMouseAxes;i++) {
|
||||
for (i=0;i<CONTROL_NumMouseAxes;i++)
|
||||
{
|
||||
initprintf("axis=%d analog=%d digital1=%d digital2=%d\n",
|
||||
i, CONTROL_MouseAxesMap[i].analogmap,
|
||||
CONTROL_MouseAxesMap[i].minmap, CONTROL_MouseAxesMap[i].maxmap);
|
||||
}
|
||||
|
||||
initprintf("numjoyaxes=%d\n", CONTROL_NumJoyAxes);
|
||||
for (i=0;i<CONTROL_NumJoyAxes;i++) {
|
||||
for (i=0;i<CONTROL_NumJoyAxes;i++)
|
||||
{
|
||||
initprintf("axis=%d analog=%d digital1=%d digital2=%d\n",
|
||||
i, CONTROL_JoyAxesMap[i].analogmap,
|
||||
CONTROL_JoyAxesMap[i].minmap, CONTROL_JoyAxesMap[i].maxmap);
|
||||
}
|
||||
}
|
||||
|
||||
void CONTROL_MapButton( int32 whichfunction, int32 whichbutton, boolean doubleclicked, controldevice device )
|
||||
void CONTROL_MapButton(int32 whichfunction, int32 whichbutton, boolean doubleclicked, controldevice device)
|
||||
{
|
||||
controlbuttontype *set;
|
||||
|
||||
if (CONTROL_CheckRange(whichfunction)) whichfunction = BUTTONUNDEFINED;
|
||||
|
||||
switch (device) {
|
||||
switch (device)
|
||||
{
|
||||
case controldevice_mouse:
|
||||
if ((uint32)whichbutton >= (uint32)MAXMOUSEBUTTONS) {
|
||||
if ((uint32)whichbutton >= (uint32)MAXMOUSEBUTTONS)
|
||||
{
|
||||
//Error("CONTROL_MapButton: button %d out of valid range for %d mouse buttons.",
|
||||
// whichbutton, CONTROL_NumMouseButtons);
|
||||
return;
|
||||
|
@ -261,7 +272,8 @@ void CONTROL_MapButton( int32 whichfunction, int32 whichbutton, boolean doublecl
|
|||
break;
|
||||
|
||||
case controldevice_joystick:
|
||||
if ((uint32)whichbutton >= (uint32)MAXJOYBUTTONS) {
|
||||
if ((uint32)whichbutton >= (uint32)MAXJOYBUTTONS)
|
||||
{
|
||||
//Error("CONTROL_MapButton: button %d out of valid range for %d joystick buttons.",
|
||||
// whichbutton, CONTROL_NumJoyButtons);
|
||||
return;
|
||||
|
@ -280,19 +292,22 @@ void CONTROL_MapButton( int32 whichfunction, int32 whichbutton, boolean doublecl
|
|||
set[whichbutton].singleclicked = whichfunction;
|
||||
}
|
||||
|
||||
void CONTROL_MapAnalogAxis( int32 whichaxis, int32 whichanalog, controldevice device )
|
||||
void CONTROL_MapAnalogAxis(int32 whichaxis, int32 whichanalog, controldevice device)
|
||||
{
|
||||
controlaxismaptype *set;
|
||||
|
||||
if ((uint32)whichanalog >= (uint32)analog_maxtype) {
|
||||
if ((uint32)whichanalog >= (uint32)analog_maxtype)
|
||||
{
|
||||
//Error("CONTROL_MapAnalogAxis: analog function %d out of valid range for %d analog functions.",
|
||||
// whichanalog, analog_maxtype);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (device) {
|
||||
switch (device)
|
||||
{
|
||||
case controldevice_mouse:
|
||||
if ((uint32)whichaxis >= (uint32)MAXMOUSEAXES) {
|
||||
if ((uint32)whichaxis >= (uint32)MAXMOUSEAXES)
|
||||
{
|
||||
//Error("CONTROL_MapAnalogAxis: axis %d out of valid range for %d mouse axes.",
|
||||
// whichaxis, MAXMOUSEAXES);
|
||||
return;
|
||||
|
@ -302,7 +317,8 @@ void CONTROL_MapAnalogAxis( int32 whichaxis, int32 whichanalog, controldevice de
|
|||
break;
|
||||
|
||||
case controldevice_joystick:
|
||||
if ((uint32)whichaxis >= (uint32)MAXJOYAXES) {
|
||||
if ((uint32)whichaxis >= (uint32)MAXJOYAXES)
|
||||
{
|
||||
//Error("CONTROL_MapAnalogAxis: axis %d out of valid range for %d joystick axes.",
|
||||
// whichaxis, MAXJOYAXES);
|
||||
return;
|
||||
|
@ -319,13 +335,15 @@ void CONTROL_MapAnalogAxis( int32 whichaxis, int32 whichanalog, controldevice de
|
|||
set[whichaxis].analogmap = whichanalog;
|
||||
}
|
||||
|
||||
void CONTROL_SetAnalogAxisScale( int32 whichaxis, int32 axisscale, controldevice device )
|
||||
void CONTROL_SetAnalogAxisScale(int32 whichaxis, int32 axisscale, controldevice device)
|
||||
{
|
||||
int32 *set;
|
||||
|
||||
switch (device) {
|
||||
switch (device)
|
||||
{
|
||||
case controldevice_mouse:
|
||||
if ((uint32)whichaxis >= (uint32)MAXMOUSEAXES) {
|
||||
if ((uint32)whichaxis >= (uint32)MAXMOUSEAXES)
|
||||
{
|
||||
//Error("CONTROL_SetAnalogAxisScale: axis %d out of valid range for %d mouse axes.",
|
||||
// whichaxis, MAXMOUSEAXES);
|
||||
return;
|
||||
|
@ -335,7 +353,8 @@ void CONTROL_SetAnalogAxisScale( int32 whichaxis, int32 axisscale, controldevice
|
|||
break;
|
||||
|
||||
case controldevice_joystick:
|
||||
if ((uint32)whichaxis >= (uint32)MAXJOYAXES) {
|
||||
if ((uint32)whichaxis >= (uint32)MAXJOYAXES)
|
||||
{
|
||||
//Error("CONTROL_SetAnalogAxisScale: axis %d out of valid range for %d joystick axes.",
|
||||
// whichaxis, MAXJOYAXES);
|
||||
return;
|
||||
|
@ -352,15 +371,17 @@ void CONTROL_SetAnalogAxisScale( int32 whichaxis, int32 axisscale, controldevice
|
|||
set[whichaxis] = axisscale;
|
||||
}
|
||||
|
||||
void CONTROL_MapDigitalAxis( int32 whichaxis, int32 whichfunction, int32 direction, controldevice device )
|
||||
void CONTROL_MapDigitalAxis(int32 whichaxis, int32 whichfunction, int32 direction, controldevice device)
|
||||
{
|
||||
controlaxismaptype *set;
|
||||
|
||||
if (CONTROL_CheckRange(whichfunction)) whichfunction = AXISUNDEFINED;
|
||||
|
||||
switch (device) {
|
||||
switch (device)
|
||||
{
|
||||
case controldevice_mouse:
|
||||
if ((uint32)whichaxis >= (uint32)MAXMOUSEAXES) {
|
||||
if ((uint32)whichaxis >= (uint32)MAXMOUSEAXES)
|
||||
{
|
||||
//Error("CONTROL_MapDigitalAxis: axis %d out of valid range for %d mouse axes.",
|
||||
// whichaxis, MAXMOUSEAXES);
|
||||
return;
|
||||
|
@ -370,7 +391,8 @@ void CONTROL_MapDigitalAxis( int32 whichaxis, int32 whichfunction, int32 directi
|
|||
break;
|
||||
|
||||
case controldevice_joystick:
|
||||
if ((uint32)whichaxis >= (uint32)MAXJOYAXES) {
|
||||
if ((uint32)whichaxis >= (uint32)MAXJOYAXES)
|
||||
{
|
||||
//Error("CONTROL_MapDigitalAxis: axis %d out of valid range for %d joystick axes.",
|
||||
// whichaxis, MAXJOYAXES);
|
||||
return;
|
||||
|
@ -384,7 +406,8 @@ void CONTROL_MapDigitalAxis( int32 whichaxis, int32 whichfunction, int32 directi
|
|||
return;
|
||||
}
|
||||
|
||||
switch (direction) { // JBF: this is all very much a guess. The ASM puzzles me.
|
||||
switch (direction) // JBF: this is all very much a guess. The ASM puzzles me.
|
||||
{
|
||||
case axis_up:
|
||||
case axis_left:
|
||||
set[whichaxis].minmap = whichfunction;
|
||||
|
@ -406,7 +429,7 @@ void CONTROL_ClearFlags(void)
|
|||
CONTROL_Flags[i].used = false;
|
||||
}
|
||||
|
||||
void CONTROL_ClearAssignments( void )
|
||||
void CONTROL_ClearAssignments(void)
|
||||
{
|
||||
int32 i;
|
||||
|
||||
|
@ -433,33 +456,42 @@ static void DoGetDeviceButtons(
|
|||
boolean *ButtonClickedState,
|
||||
boolean *ButtonClicked,
|
||||
byte *ButtonClickedCount
|
||||
) {
|
||||
)
|
||||
{
|
||||
int32 i, bs;
|
||||
|
||||
for (i=0;i<NumButtons;i++) {
|
||||
for (i=0;i<NumButtons;i++)
|
||||
{
|
||||
bs = (buttons >> i) & 1;
|
||||
|
||||
DeviceButtonState[i] = bs;
|
||||
ButtonClickedState[i] = false;
|
||||
|
||||
if (bs) {
|
||||
if (ButtonClicked[i] == false) {
|
||||
if (bs)
|
||||
{
|
||||
if (ButtonClicked[i] == false)
|
||||
{
|
||||
ButtonClicked[i] = true;
|
||||
|
||||
if (ButtonClickedCount[i] == 0 || tm > ButtonClickedTime[i]) {
|
||||
if (ButtonClickedCount[i] == 0 || tm > ButtonClickedTime[i])
|
||||
{
|
||||
ButtonClickedTime[i] = tm + CONTROL_DoubleClickSpeed;
|
||||
ButtonClickedCount[i] = 1;
|
||||
}
|
||||
else if (tm < ButtonClickedTime[i]) {
|
||||
else if (tm < ButtonClickedTime[i])
|
||||
{
|
||||
ButtonClickedState[i] = true;
|
||||
ButtonClickedTime[i] = 0;
|
||||
ButtonClickedCount[i] = 2;
|
||||
}
|
||||
}
|
||||
else if (ButtonClickedCount[i] == 2) {
|
||||
else if (ButtonClickedCount[i] == 2)
|
||||
{
|
||||
ButtonClickedState[i] = true;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ButtonClickedCount[i] == 2)
|
||||
ButtonClickedCount[i] = 0;
|
||||
|
||||
|
@ -474,7 +506,8 @@ void CONTROL_GetDeviceButtons(void)
|
|||
|
||||
t = GetTime();
|
||||
|
||||
if (CONTROL_MouseEnabled) {
|
||||
if (CONTROL_MouseEnabled)
|
||||
{
|
||||
DoGetDeviceButtons(
|
||||
MOUSE_GetButtons(), t,
|
||||
CONTROL_NumMouseButtons,
|
||||
|
@ -486,9 +519,11 @@ void CONTROL_GetDeviceButtons(void)
|
|||
);
|
||||
}
|
||||
|
||||
if (CONTROL_JoystickEnabled) {
|
||||
if (CONTROL_JoystickEnabled)
|
||||
{
|
||||
int32 buttons = joyb;
|
||||
if (joynumhats > 0 && joyhat[0] != -1) {
|
||||
if (joynumhats > 0 && joyhat[0] != -1)
|
||||
{
|
||||
static int32 hatstate[] = { 1, 1|2, 2, 2|4, 4, 4|8, 8, 8|1 };
|
||||
int val;
|
||||
|
||||
|
@ -513,7 +548,8 @@ void CONTROL_DigitizeAxis(int32 axis, controldevice device)
|
|||
{
|
||||
controlaxistype *set, *lastset;
|
||||
|
||||
switch (device) {
|
||||
switch (device)
|
||||
{
|
||||
case controldevice_mouse:
|
||||
set = CONTROL_MouseAxes;
|
||||
lastset = CONTROL_LastMouseAxes;
|
||||
|
@ -527,20 +563,31 @@ void CONTROL_DigitizeAxis(int32 axis, controldevice device)
|
|||
default: return;
|
||||
}
|
||||
|
||||
if (set[axis].analog > 0) {
|
||||
if (set[axis].analog > THRESHOLD) { // if very much in one direction,
|
||||
if (set[axis].analog > 0)
|
||||
{
|
||||
if (set[axis].analog > THRESHOLD) // if very much in one direction,
|
||||
{
|
||||
set[axis].digital = 1; // set affirmative
|
||||
} else {
|
||||
if (set[axis].analog > MINTHRESHOLD) { // if hanging in limbo,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (set[axis].analog > MINTHRESHOLD) // if hanging in limbo,
|
||||
{
|
||||
if (lastset[axis].digital == 1) // set if in same direction as last time
|
||||
set[axis].digital = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (set[axis].analog < -THRESHOLD) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (set[axis].analog < -THRESHOLD)
|
||||
{
|
||||
set[axis].digital = -1;
|
||||
} else {
|
||||
if (set[axis].analog < -MINTHRESHOLD) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (set[axis].analog < -MINTHRESHOLD)
|
||||
{
|
||||
if (lastset[axis].digital == -1)
|
||||
set[axis].digital = -1;
|
||||
}
|
||||
|
@ -553,7 +600,8 @@ void CONTROL_ScaleAxis(int32 axis, controldevice device)
|
|||
controlaxistype *set;
|
||||
int32 *scale;
|
||||
|
||||
switch (device) {
|
||||
switch (device)
|
||||
{
|
||||
case controldevice_mouse:
|
||||
set = CONTROL_MouseAxes;
|
||||
scale = CONTROL_MouseAxesScale;
|
||||
|
@ -575,7 +623,8 @@ void CONTROL_ApplyAxis(int32 axis, ControlInfo *info, controldevice device)
|
|||
controlaxistype *set;
|
||||
controlaxismaptype *map;
|
||||
|
||||
switch (device) {
|
||||
switch (device)
|
||||
{
|
||||
case controldevice_mouse:
|
||||
set = CONTROL_MouseAxes;
|
||||
map = CONTROL_MouseAxesMap;
|
||||
|
@ -589,7 +638,8 @@ void CONTROL_ApplyAxis(int32 axis, ControlInfo *info, controldevice device)
|
|||
default: return;
|
||||
}
|
||||
|
||||
switch (map[axis].analogmap) {
|
||||
switch (map[axis].analogmap)
|
||||
{
|
||||
case analog_turning: info->dyaw += set[axis].analog; break;
|
||||
case analog_strafing: info->dx += set[axis].analog; break;
|
||||
case analog_lookingupanddown: info->dpitch += set[axis].analog; break;
|
||||
|
@ -611,24 +661,28 @@ void CONTROL_PollDevices(ControlInfo *info)
|
|||
memset(CONTROL_JoyAxes, 0, sizeof(CONTROL_JoyAxes));
|
||||
memset(info, 0, sizeof(ControlInfo));
|
||||
|
||||
if (CONTROL_MouseEnabled) {
|
||||
if (CONTROL_MouseEnabled)
|
||||
{
|
||||
CONTROL_GetMouseDelta();
|
||||
|
||||
for (i=0; i<MAXMOUSEAXES; i++) {
|
||||
for (i=0; i<MAXMOUSEAXES; i++)
|
||||
{
|
||||
CONTROL_DigitizeAxis(i, controldevice_mouse);
|
||||
CONTROL_ScaleAxis(i, controldevice_mouse);
|
||||
LIMITCONTROL(&CONTROL_MouseAxes[i].analog);
|
||||
CONTROL_ApplyAxis(i, info, controldevice_mouse);
|
||||
}
|
||||
}
|
||||
if (CONTROL_JoystickEnabled) {
|
||||
if (CONTROL_JoystickEnabled)
|
||||
{
|
||||
CONTROL_GetJoyDelta();
|
||||
|
||||
// Why?
|
||||
//CONTROL_Axes[0].analog /= 2;
|
||||
//CONTROL_Axes[2].analog /= 2;
|
||||
|
||||
for (i=0; i<MAXJOYAXES; i++) {
|
||||
for (i=0; i<MAXJOYAXES; i++)
|
||||
{
|
||||
CONTROL_DigitizeAxis(i, controldevice_joystick);
|
||||
CONTROL_ScaleAxis(i, controldevice_joystick);
|
||||
LIMITCONTROL(&CONTROL_JoyAxes[i].analog);
|
||||
|
@ -643,7 +697,8 @@ void CONTROL_AxisFunctionState(int32 *p1)
|
|||
{
|
||||
int32 i, j;
|
||||
|
||||
for (i=0; i<CONTROL_NumMouseAxes; i++) {
|
||||
for (i=0; i<CONTROL_NumMouseAxes; i++)
|
||||
{
|
||||
if (!CONTROL_MouseAxes[i].digital) continue;
|
||||
|
||||
if (CONTROL_MouseAxes[i].digital < 0)
|
||||
|
@ -655,7 +710,8 @@ void CONTROL_AxisFunctionState(int32 *p1)
|
|||
p1[j] = 1;
|
||||
}
|
||||
|
||||
for (i=0; i<CONTROL_NumJoyAxes; i++) {
|
||||
for (i=0; i<CONTROL_NumJoyAxes; i++)
|
||||
{
|
||||
if (!CONTROL_JoyAxes[i].digital) continue;
|
||||
|
||||
if (CONTROL_JoyAxes[i].digital < 0)
|
||||
|
@ -668,11 +724,12 @@ void CONTROL_AxisFunctionState(int32 *p1)
|
|||
}
|
||||
}
|
||||
|
||||
void CONTROL_ButtonFunctionState( int32 *p1 )
|
||||
void CONTROL_ButtonFunctionState(int32 *p1)
|
||||
{
|
||||
int32 i, j;
|
||||
|
||||
for (i=0; i<CONTROL_NumMouseButtons; i++) {
|
||||
for (i=0; i<CONTROL_NumMouseButtons; i++)
|
||||
{
|
||||
j = CONTROL_MouseButtonMapping[i].doubleclicked;
|
||||
if (j != KEYUNDEFINED)
|
||||
p1[j] |= CONTROL_MouseButtonClickedState[i];
|
||||
|
@ -682,7 +739,8 @@ void CONTROL_ButtonFunctionState( int32 *p1 )
|
|||
p1[j] |= CONTROL_MouseButtonState[i];
|
||||
}
|
||||
|
||||
for (i=0; i<CONTROL_NumJoyButtons; i++) {
|
||||
for (i=0; i<CONTROL_NumJoyButtons; i++)
|
||||
{
|
||||
j = CONTROL_JoyButtonMapping[i].doubleclicked;
|
||||
if (j != KEYUNDEFINED)
|
||||
p1[j] |= CONTROL_JoyButtonClickedState[i];
|
||||
|
@ -779,10 +837,10 @@ void CONTROL_ClearUserInput( UserInput *info )
|
|||
if (info->button1) CONTROL_UserInputCleared[2] = true;
|
||||
}
|
||||
*/
|
||||
void CONTROL_ClearButton( int32 whichbutton )
|
||||
void CONTROL_ClearButton(int32 whichbutton)
|
||||
{
|
||||
if (CONTROL_CheckRange( whichbutton )) return;
|
||||
BUTTONCLEAR( whichbutton );
|
||||
if (CONTROL_CheckRange(whichbutton)) return;
|
||||
BUTTONCLEAR(whichbutton);
|
||||
CONTROL_Flags[whichbutton].cleared = true;
|
||||
}
|
||||
|
||||
|
@ -797,7 +855,7 @@ void CONTROL_ProcessBinds(void)
|
|||
{
|
||||
if (boundkeys[i].name[0] && KB_KeyPressed(i))
|
||||
{
|
||||
if (boundkeys[i].repeat || (boundkeys[i].laststate == 0))
|
||||
if (boundkeys[i].repeat || (boundkeys[i].laststate == 0))
|
||||
OSD_Dispatch(boundkeys[i].name);
|
||||
// if (!boundkeys[i].repeat)
|
||||
// KB_ClearKeyDown(i);
|
||||
|
@ -807,11 +865,11 @@ void CONTROL_ProcessBinds(void)
|
|||
}
|
||||
|
||||
|
||||
void CONTROL_GetInput( ControlInfo *info )
|
||||
void CONTROL_GetInput(ControlInfo *info)
|
||||
{
|
||||
int32 i, periphs[CONTROL_NUM_FLAGS];
|
||||
|
||||
CONTROL_PollDevices( info );
|
||||
CONTROL_PollDevices(info);
|
||||
|
||||
memset(periphs, 0, sizeof(periphs));
|
||||
CONTROL_ButtonFunctionState(periphs);
|
||||
|
@ -823,7 +881,8 @@ void CONTROL_GetInput( ControlInfo *info )
|
|||
|
||||
CONTROL_ProcessBinds();
|
||||
|
||||
for (i=0; i<CONTROL_NUM_FLAGS; i++) {
|
||||
for (i=0; i<CONTROL_NUM_FLAGS; i++)
|
||||
{
|
||||
CONTROL_SetFlag(i, CONTROL_KeyboardFunctionPressed(i) | periphs[i] | extinput[i]);
|
||||
|
||||
if (CONTROL_Flags[i].cleared == false) BUTTONSET(i, CONTROL_Flags[i].active);
|
||||
|
@ -832,15 +891,15 @@ void CONTROL_GetInput( ControlInfo *info )
|
|||
memset(extinput, 0, sizeof(extinput));
|
||||
}
|
||||
|
||||
void CONTROL_WaitRelease( void )
|
||||
void CONTROL_WaitRelease(void)
|
||||
{
|
||||
}
|
||||
|
||||
void CONTROL_Ack( void )
|
||||
void CONTROL_Ack(void)
|
||||
{
|
||||
}
|
||||
|
||||
boolean CONTROL_Startup(controltype which, int32 ( *TimeFunction )( void ), int32 ticspersecond)
|
||||
boolean CONTROL_Startup(controltype which, int32(*TimeFunction)(void), int32 ticspersecond)
|
||||
{
|
||||
int32 i;
|
||||
|
||||
|
|
|
@ -58,75 +58,80 @@ static char *FileNames[MaxFiles];
|
|||
|
||||
int32 SafeOpen(const char *filename, int32 mode, int32 sharemode)
|
||||
{
|
||||
int32 h;
|
||||
int32 h;
|
||||
|
||||
h = openfrompath(filename, mode, sharemode);
|
||||
if (h < 0) Error("Error opening %s: %s", filename, strerror(errno));
|
||||
h = openfrompath(filename, mode, sharemode);
|
||||
if (h < 0) Error("Error opening %s: %s", filename, strerror(errno));
|
||||
|
||||
if (h < MaxFiles) {
|
||||
if (FileNames[h]) SafeFree(FileNames[h]);
|
||||
FileNames[h] = (char*)SafeMalloc(strlen(filename)+1);
|
||||
if (FileNames[h]) strcpy(FileNames[h], filename);
|
||||
}
|
||||
if (h < MaxFiles)
|
||||
{
|
||||
if (FileNames[h]) SafeFree(FileNames[h]);
|
||||
FileNames[h] = (char*)SafeMalloc(strlen(filename)+1);
|
||||
if (FileNames[h]) strcpy(FileNames[h], filename);
|
||||
}
|
||||
|
||||
return h;
|
||||
return h;
|
||||
}
|
||||
|
||||
int32 SafeOpenRead(const char *filename, int32 filetype)
|
||||
{
|
||||
switch (filetype) {
|
||||
case filetype_binary:
|
||||
return SafeOpen(filename, O_RDONLY|O_BINARY, S_IREAD);
|
||||
case filetype_text:
|
||||
return SafeOpen(filename, O_RDONLY|O_TEXT, S_IREAD);
|
||||
default:
|
||||
Error("SafeOpenRead: Illegal filetype specified");
|
||||
return -1;
|
||||
}
|
||||
switch (filetype)
|
||||
{
|
||||
case filetype_binary:
|
||||
return SafeOpen(filename, O_RDONLY|O_BINARY, S_IREAD);
|
||||
case filetype_text:
|
||||
return SafeOpen(filename, O_RDONLY|O_TEXT, S_IREAD);
|
||||
default:
|
||||
Error("SafeOpenRead: Illegal filetype specified");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void SafeClose ( int32 handle )
|
||||
void SafeClose(int32 handle)
|
||||
{
|
||||
if (handle < 0) return;
|
||||
if (close(handle) < 0) {
|
||||
if (handle < MaxFiles)
|
||||
Error("Unable to close file %s", FileNames[handle]);
|
||||
else
|
||||
Error("Unable to close file");
|
||||
}
|
||||
if (handle < 0) return;
|
||||
if (close(handle) < 0)
|
||||
{
|
||||
if (handle < MaxFiles)
|
||||
Error("Unable to close file %s", FileNames[handle]);
|
||||
else
|
||||
Error("Unable to close file");
|
||||
}
|
||||
|
||||
if (handle < MaxFiles && FileNames[handle]) {
|
||||
SafeFree(FileNames[handle]);
|
||||
FileNames[handle] = NULL;
|
||||
}
|
||||
if (handle < MaxFiles && FileNames[handle])
|
||||
{
|
||||
SafeFree(FileNames[handle]);
|
||||
FileNames[handle] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
boolean SafeFileExists(const char *filename)
|
||||
{
|
||||
if (!access(filename, F_OK)) return true;
|
||||
return false;
|
||||
if (!access(filename, F_OK)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 SafeFileLength ( int32 handle )
|
||||
int32 SafeFileLength(int32 handle)
|
||||
{
|
||||
if (handle < 0) return -1;
|
||||
return Bfilelength(handle);
|
||||
if (handle < 0) return -1;
|
||||
return Bfilelength(handle);
|
||||
}
|
||||
|
||||
void SafeRead(int32 handle, void *buffer, int32 count)
|
||||
{
|
||||
int32 b;
|
||||
int32 b;
|
||||
|
||||
b = read(handle, buffer, count);
|
||||
if (b != count) {
|
||||
close(handle);
|
||||
if (handle < MaxFiles)
|
||||
Error("File read failure %s reading %d bytes from file %s.",
|
||||
strerror(errno), count, FileNames[handle]);
|
||||
else
|
||||
Error("File read failure %s reading %d bytes.",
|
||||
strerror(errno), count);
|
||||
}
|
||||
b = read(handle, buffer, count);
|
||||
if (b != count)
|
||||
{
|
||||
close(handle);
|
||||
if (handle < MaxFiles)
|
||||
Error("File read failure %s reading %d bytes from file %s.",
|
||||
strerror(errno), count, FileNames[handle]);
|
||||
else
|
||||
Error("File read failure %s reading %d bytes.",
|
||||
strerror(errno), count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* keyboard.c
|
||||
* MACT library -to- JonoF's Build Port Keyboard Glue
|
||||
*
|
||||
*
|
||||
* by Jonathon Fowler
|
||||
*
|
||||
* Since we don't have the source to the MACT library I've had to
|
||||
|
@ -43,111 +43,113 @@ kb_scancode KB_LastScan;
|
|||
static boolean numpad = 0;
|
||||
|
||||
// translation table for taking key names to scancodes and back again
|
||||
static struct {
|
||||
char *key;
|
||||
kb_scancode sc;
|
||||
} sctokeylut[] = {
|
||||
{ "Escape", 0x1 },
|
||||
{ "1", 0x2 },
|
||||
{ "2", 0x3 },
|
||||
{ "3", 0x4 },
|
||||
{ "4", 0x5 },
|
||||
{ "5", 0x6 },
|
||||
{ "6", 0x7 },
|
||||
{ "7", 0x8 },
|
||||
{ "8", 0x9 },
|
||||
{ "9", 0xa },
|
||||
{ "0", 0xb },
|
||||
{ "-", 0xc },
|
||||
{ "=", 0xd },
|
||||
{ "BakSpc", 0xe },
|
||||
{ "Tab", 0xf },
|
||||
{ "Q", 0x10 },
|
||||
{ "W", 0x11 },
|
||||
{ "E", 0x12 },
|
||||
{ "R", 0x13 },
|
||||
{ "T", 0x14 },
|
||||
{ "Y", 0x15 },
|
||||
{ "U", 0x16 },
|
||||
{ "I", 0x17 },
|
||||
{ "O", 0x18 },
|
||||
{ "P", 0x19 },
|
||||
{ "[", 0x1a },
|
||||
{ "]", 0x1b },
|
||||
{ "Enter", 0x1c },
|
||||
{ "LCtrl", 0x1d },
|
||||
{ "A", 0x1e },
|
||||
{ "S", 0x1f },
|
||||
{ "D", 0x20 },
|
||||
{ "F", 0x21 },
|
||||
{ "G", 0x22 },
|
||||
{ "H", 0x23 },
|
||||
{ "J", 0x24 },
|
||||
{ "K", 0x25 },
|
||||
{ "L", 0x26 },
|
||||
{ ";", 0x27 },
|
||||
{ "'", 0x28 },
|
||||
{ "`", 0x29 },
|
||||
{ "LShift", 0x2a },
|
||||
{ "\\", 0x2b },
|
||||
{ "Z", 0x2c },
|
||||
{ "X", 0x2d },
|
||||
{ "C", 0x2e },
|
||||
{ "V", 0x2f },
|
||||
{ "B", 0x30 },
|
||||
{ "N", 0x31 },
|
||||
{ "M", 0x32 },
|
||||
{ ",", 0x33 },
|
||||
{ ".", 0x34 },
|
||||
{ "/", 0x35 },
|
||||
{ "RShift", 0x36 },
|
||||
{ "Kpad*", 0x37 },
|
||||
{ "LAlt", 0x38 },
|
||||
{ "Space", 0x39 },
|
||||
{ "CapLck", 0x3a },
|
||||
{ "F1", 0x3b },
|
||||
{ "F2", 0x3c },
|
||||
{ "F3", 0x3d },
|
||||
{ "F4", 0x3e },
|
||||
{ "F5", 0x3f },
|
||||
{ "F6", 0x40 },
|
||||
{ "F7", 0x41 },
|
||||
{ "F8", 0x42 },
|
||||
{ "F9", 0x43 },
|
||||
{ "F10", 0x44 },
|
||||
{ "NumLck", 0x45 },
|
||||
{ "ScrLck", 0x46 },
|
||||
{ "Kpad7", 0x47 },
|
||||
{ "Kpad8", 0x48 },
|
||||
{ "Kpad9", 0x49 },
|
||||
{ "Kpad-", 0x4a },
|
||||
{ "Kpad4", 0x4b },
|
||||
{ "Kpad5", 0x4c },
|
||||
{ "Kpad6", 0x4d },
|
||||
{ "Kpad+", 0x4e },
|
||||
{ "Kpad1", 0x4f },
|
||||
{ "Kpad2", 0x50 },
|
||||
{ "Kpad3", 0x51 },
|
||||
{ "Kpad0", 0x52 },
|
||||
{ "Kpad.", 0x53 },
|
||||
{ "F11", 0x57 },
|
||||
{ "F12", 0x58 },
|
||||
{ "KpdEnt", 0x9c },
|
||||
{ "RCtrl", 0x9d },
|
||||
{ "Kpad/", 0xb5 },
|
||||
{ "RAlt", 0xb8 },
|
||||
{ "PrtScn", 0xb7 },
|
||||
{ "Pause", 0xc5 },
|
||||
{ "Home", 0xc7 },
|
||||
{ "Up", 0xc8 },
|
||||
{ "PgUp", 0xc9 },
|
||||
{ "Left", 0xcb },
|
||||
{ "Right", 0xcd },
|
||||
{ "End", 0xcf },
|
||||
{ "Down", 0xd0 },
|
||||
{ "PgDn", 0xd1 },
|
||||
{ "Insert", 0xd2 },
|
||||
{ "Delete", 0xd3 },
|
||||
static struct
|
||||
{
|
||||
char *key;
|
||||
kb_scancode sc;
|
||||
} sctokeylut[] =
|
||||
{
|
||||
{ "Escape", 0x1 },
|
||||
{ "1", 0x2 },
|
||||
{ "2", 0x3 },
|
||||
{ "3", 0x4 },
|
||||
{ "4", 0x5 },
|
||||
{ "5", 0x6 },
|
||||
{ "6", 0x7 },
|
||||
{ "7", 0x8 },
|
||||
{ "8", 0x9 },
|
||||
{ "9", 0xa },
|
||||
{ "0", 0xb },
|
||||
{ "-", 0xc },
|
||||
{ "=", 0xd },
|
||||
{ "BakSpc", 0xe },
|
||||
{ "Tab", 0xf },
|
||||
{ "Q", 0x10 },
|
||||
{ "W", 0x11 },
|
||||
{ "E", 0x12 },
|
||||
{ "R", 0x13 },
|
||||
{ "T", 0x14 },
|
||||
{ "Y", 0x15 },
|
||||
{ "U", 0x16 },
|
||||
{ "I", 0x17 },
|
||||
{ "O", 0x18 },
|
||||
{ "P", 0x19 },
|
||||
{ "[", 0x1a },
|
||||
{ "]", 0x1b },
|
||||
{ "Enter", 0x1c },
|
||||
{ "LCtrl", 0x1d },
|
||||
{ "A", 0x1e },
|
||||
{ "S", 0x1f },
|
||||
{ "D", 0x20 },
|
||||
{ "F", 0x21 },
|
||||
{ "G", 0x22 },
|
||||
{ "H", 0x23 },
|
||||
{ "J", 0x24 },
|
||||
{ "K", 0x25 },
|
||||
{ "L", 0x26 },
|
||||
{ ";", 0x27 },
|
||||
{ "'", 0x28 },
|
||||
{ "`", 0x29 },
|
||||
{ "LShift", 0x2a },
|
||||
{ "\\", 0x2b },
|
||||
{ "Z", 0x2c },
|
||||
{ "X", 0x2d },
|
||||
{ "C", 0x2e },
|
||||
{ "V", 0x2f },
|
||||
{ "B", 0x30 },
|
||||
{ "N", 0x31 },
|
||||
{ "M", 0x32 },
|
||||
{ ",", 0x33 },
|
||||
{ ".", 0x34 },
|
||||
{ "/", 0x35 },
|
||||
{ "RShift", 0x36 },
|
||||
{ "Kpad*", 0x37 },
|
||||
{ "LAlt", 0x38 },
|
||||
{ "Space", 0x39 },
|
||||
{ "CapLck", 0x3a },
|
||||
{ "F1", 0x3b },
|
||||
{ "F2", 0x3c },
|
||||
{ "F3", 0x3d },
|
||||
{ "F4", 0x3e },
|
||||
{ "F5", 0x3f },
|
||||
{ "F6", 0x40 },
|
||||
{ "F7", 0x41 },
|
||||
{ "F8", 0x42 },
|
||||
{ "F9", 0x43 },
|
||||
{ "F10", 0x44 },
|
||||
{ "NumLck", 0x45 },
|
||||
{ "ScrLck", 0x46 },
|
||||
{ "Kpad7", 0x47 },
|
||||
{ "Kpad8", 0x48 },
|
||||
{ "Kpad9", 0x49 },
|
||||
{ "Kpad-", 0x4a },
|
||||
{ "Kpad4", 0x4b },
|
||||
{ "Kpad5", 0x4c },
|
||||
{ "Kpad6", 0x4d },
|
||||
{ "Kpad+", 0x4e },
|
||||
{ "Kpad1", 0x4f },
|
||||
{ "Kpad2", 0x50 },
|
||||
{ "Kpad3", 0x51 },
|
||||
{ "Kpad0", 0x52 },
|
||||
{ "Kpad.", 0x53 },
|
||||
{ "F11", 0x57 },
|
||||
{ "F12", 0x58 },
|
||||
{ "KpdEnt", 0x9c },
|
||||
{ "RCtrl", 0x9d },
|
||||
{ "Kpad/", 0xb5 },
|
||||
{ "RAlt", 0xb8 },
|
||||
{ "PrtScn", 0xb7 },
|
||||
{ "Pause", 0xc5 },
|
||||
{ "Home", 0xc7 },
|
||||
{ "Up", 0xc8 },
|
||||
{ "PgUp", 0xc9 },
|
||||
{ "Left", 0xcb },
|
||||
{ "Right", 0xcd },
|
||||
{ "End", 0xcf },
|
||||
{ "Down", 0xd0 },
|
||||
{ "PgDn", 0xd1 },
|
||||
{ "Insert", 0xd2 },
|
||||
{ "Delete", 0xd3 },
|
||||
};
|
||||
|
||||
// translation table for turning scancode into ascii characters
|
||||
|
@ -194,91 +196,91 @@ static char sctoasc[2][256] = {
|
|||
};
|
||||
*/
|
||||
|
||||
boolean KB_KeyWaiting( void )
|
||||
boolean KB_KeyWaiting(void)
|
||||
{
|
||||
return bkbhit();
|
||||
return bkbhit();
|
||||
// return (keyfifoplc != keyfifoend);
|
||||
}
|
||||
|
||||
char KB_Getch( void )
|
||||
char KB_Getch(void)
|
||||
{
|
||||
/*
|
||||
unsigned char ch;
|
||||
char shifted;
|
||||
if (keyfifoplc == keyfifoend) return 0;
|
||||
ch = keyfifo[keyfifoplc];
|
||||
keyfifoplc = ((keyfifoplc+2)&(KEYFIFOSIZ-1));
|
||||
/*
|
||||
unsigned char ch;
|
||||
char shifted;
|
||||
if (keyfifoplc == keyfifoend) return 0;
|
||||
ch = keyfifo[keyfifoplc];
|
||||
keyfifoplc = ((keyfifoplc+2)&(KEYFIFOSIZ-1));
|
||||
|
||||
shifted = ((keystatus[0x2a]!=0)||(keystatus[0x36]!=0));
|
||||
if (ch >= 0x47 && ch <= 0x52) shifted = numpad;
|
||||
|
||||
return sctoasc[shifted][ch];
|
||||
*/
|
||||
return (char)bgetchar();
|
||||
shifted = ((keystatus[0x2a]!=0)||(keystatus[0x36]!=0));
|
||||
if (ch >= 0x47 && ch <= 0x52) shifted = numpad;
|
||||
|
||||
return sctoasc[shifted][ch];
|
||||
*/
|
||||
return (char)bgetchar();
|
||||
}
|
||||
|
||||
void KB_FlushKeyboardQueue( void )
|
||||
void KB_FlushKeyboardQueue(void)
|
||||
{
|
||||
//keyfifoplc = keyfifoend = 0;
|
||||
bflushchars();
|
||||
//keyfifoplc = keyfifoend = 0;
|
||||
bflushchars();
|
||||
}
|
||||
|
||||
void KB_ClearKeysDown( void )
|
||||
void KB_ClearKeysDown(void)
|
||||
{
|
||||
KB_LastScan = 0;
|
||||
memset(keystatus, 0, sizeof(keystatus));
|
||||
//keyfifoplc = keyfifoend = 0;
|
||||
//bflushchars();
|
||||
KB_LastScan = 0;
|
||||
memset(keystatus, 0, sizeof(keystatus));
|
||||
//keyfifoplc = keyfifoend = 0;
|
||||
//bflushchars();
|
||||
}
|
||||
|
||||
char *KB_ScanCodeToString( kb_scancode scancode )
|
||||
char *KB_ScanCodeToString(kb_scancode scancode)
|
||||
{
|
||||
unsigned s;
|
||||
unsigned s;
|
||||
|
||||
for (s=0; s < (sizeof(sctokeylut)/sizeof(sctokeylut[0])); s++)
|
||||
if (sctokeylut[s].sc == scancode) return sctokeylut[s].key;
|
||||
|
||||
return "";
|
||||
for (s=0; s < (sizeof(sctokeylut)/sizeof(sctokeylut[0])); s++)
|
||||
if (sctokeylut[s].sc == scancode) return sctokeylut[s].key;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
kb_scancode KB_StringToScanCode( char * string )
|
||||
kb_scancode KB_StringToScanCode(char * string)
|
||||
{
|
||||
unsigned s;
|
||||
|
||||
for (s=0; s < (sizeof(sctokeylut)/sizeof(sctokeylut[0])); s++)
|
||||
if (!Bstrcasecmp(sctokeylut[s].key, string)) return sctokeylut[s].sc;
|
||||
unsigned s;
|
||||
|
||||
return 0;
|
||||
for (s=0; s < (sizeof(sctokeylut)/sizeof(sctokeylut[0])); s++)
|
||||
if (!Bstrcasecmp(sctokeylut[s].key, string)) return sctokeylut[s].sc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void KB_TurnKeypadOn( void )
|
||||
void KB_TurnKeypadOn(void)
|
||||
{
|
||||
numpad = 1;
|
||||
numpad = 1;
|
||||
}
|
||||
|
||||
void KB_TurnKeypadOff( void )
|
||||
void KB_TurnKeypadOff(void)
|
||||
{
|
||||
numpad = 0;
|
||||
numpad = 0;
|
||||
}
|
||||
|
||||
boolean KB_KeypadActive( void )
|
||||
boolean KB_KeypadActive(void)
|
||||
{
|
||||
return numpad;
|
||||
return numpad;
|
||||
}
|
||||
|
||||
static void KB_KeyEvent( int scancode, int keypressed )
|
||||
static void KB_KeyEvent(int scancode, int keypressed)
|
||||
{
|
||||
if (keypressed) KB_LastScan = scancode;
|
||||
if (keypressed) KB_LastScan = scancode;
|
||||
}
|
||||
|
||||
void KB_Startup( void )
|
||||
void KB_Startup(void)
|
||||
{
|
||||
numpad = 0;
|
||||
setkeypresscallback(KB_KeyEvent);
|
||||
numpad = 0;
|
||||
setkeypresscallback(KB_KeyEvent);
|
||||
}
|
||||
|
||||
void KB_Shutdown( void )
|
||||
void KB_Shutdown(void)
|
||||
{
|
||||
setkeypresscallback((void(*)(int,int))NULL);
|
||||
setkeypresscallback((void(*)(int,int))NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,14 +37,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
// Ken's reverse-engineering job
|
||||
int32 FindDistance2D(int32 x, int32 y)
|
||||
{
|
||||
int32 i;
|
||||
x = labs(x);
|
||||
y = labs(y);
|
||||
if (!x) return(y);
|
||||
if (!y) return(x);
|
||||
if (y < x) { i = x; x = y; y = i; } //swap x, y
|
||||
x += (x>>1);
|
||||
return ((x>>6)+(x>>2)+y-(y>>5)-(y>>7)); //handle 1 octant
|
||||
int32 i;
|
||||
x = labs(x);
|
||||
y = labs(y);
|
||||
if (!x) return(y);
|
||||
if (!y) return(x);
|
||||
if (y < x) { i = x; x = y; y = i; } //swap x, y
|
||||
x += (x>>1);
|
||||
return ((x>>6)+(x>>2)+y-(y>>5)-(y>>7)); //handle 1 octant
|
||||
}
|
||||
|
||||
// My abomination
|
||||
|
@ -59,7 +59,7 @@ int32 FindDistance2D(int32 dx, int32 dy)
|
|||
int32 FindDistance3D(int32 dx, int32 dy, int32 dz)
|
||||
{
|
||||
// return (int32)floor(sqrt((double)(sqr(dx)+sqr(dy)+sqr(dz))));
|
||||
return ksqrt(square(dx)+square(dy)+square(dz));
|
||||
return ksqrt(square(dx)+square(dy)+square(dz));
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -77,36 +77,36 @@ int32 FindDistance3D(int32 dx, int32 dy, int32 dz)
|
|||
|
||||
int32 FindDistance2D(int32 x, int32 y)
|
||||
{
|
||||
int32 t;
|
||||
int32 t;
|
||||
|
||||
x= abs(x); /* absolute values */
|
||||
y= abs(y);
|
||||
x= abs(x); /* absolute values */
|
||||
y= abs(y);
|
||||
|
||||
if (x<y)
|
||||
SWAP(x,y);
|
||||
if (x<y)
|
||||
SWAP(x,y);
|
||||
|
||||
t = y + (y>>1);
|
||||
t = y + (y>>1);
|
||||
|
||||
return (x - (x>>5) - (x>>7) + (t>>2) + (t>>6));
|
||||
return (x - (x>>5) - (x>>7) + (t>>2) + (t>>6));
|
||||
}
|
||||
|
||||
|
||||
int32 FindDistance3D(int32 x, int32 y, int32 z)
|
||||
{
|
||||
int32 t;
|
||||
{
|
||||
int32 t;
|
||||
|
||||
x= abs(x); /* absolute values */
|
||||
y= abs(y);
|
||||
z= abs(z);
|
||||
x= abs(x); /* absolute values */
|
||||
y= abs(y);
|
||||
z= abs(z);
|
||||
|
||||
if (x<y)
|
||||
SWAP(x,y);
|
||||
if (x<y)
|
||||
SWAP(x,y);
|
||||
|
||||
if (x<z)
|
||||
SWAP(x,z);
|
||||
if (x<z)
|
||||
SWAP(x,z);
|
||||
|
||||
t = y + z;
|
||||
t = y + z;
|
||||
|
||||
return (x - (x>>4) + (t>>2) + (t>>3));
|
||||
}
|
||||
return (x - (x>>4) + (t>>2) + (t>>3));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* mouse.c
|
||||
* MACT library -to- JonoF's Build Port Mouse Glue
|
||||
*
|
||||
*
|
||||
* by Jonathon Fowler
|
||||
*
|
||||
* Since we don't have the source to the MACT library I've had to
|
||||
|
@ -38,46 +38,46 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "baselayer.h"
|
||||
|
||||
|
||||
boolean MOUSE_Init( void )
|
||||
boolean MOUSE_Init(void)
|
||||
{
|
||||
initmouse();
|
||||
return ((inputdevices & 2) == 2);
|
||||
initmouse();
|
||||
return ((inputdevices & 2) == 2);
|
||||
}
|
||||
|
||||
|
||||
void MOUSE_Shutdown( void )
|
||||
void MOUSE_Shutdown(void)
|
||||
{
|
||||
uninitmouse();
|
||||
uninitmouse();
|
||||
}
|
||||
|
||||
|
||||
void MOUSE_ShowCursor( void )
|
||||
void MOUSE_ShowCursor(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void MOUSE_HideCursor( void )
|
||||
void MOUSE_HideCursor(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int32 MOUSE_GetButtons( void )
|
||||
int32 MOUSE_GetButtons(void)
|
||||
{
|
||||
int32 buttons;
|
||||
readmousebstatus(&buttons);
|
||||
return buttons;
|
||||
int32 buttons;
|
||||
readmousebstatus(&buttons);
|
||||
return buttons;
|
||||
}
|
||||
|
||||
|
||||
int32 MOUSE_ClearButton( int32 b )
|
||||
int32 MOUSE_ClearButton(int32 b)
|
||||
{
|
||||
return (mouseb &= ~b);
|
||||
return (mouseb &= ~b);
|
||||
}
|
||||
|
||||
|
||||
void MOUSE_GetDelta( int32*x, int32*y )
|
||||
void MOUSE_GetDelta(int32*x, int32*y)
|
||||
{
|
||||
readmousexy(x,y);
|
||||
readmousexy(x,y);
|
||||
}
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -42,112 +42,114 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
static void (*ShutDown)(void) = NULL; // this is defined by whoever links us
|
||||
|
||||
|
||||
void RegisterShutdownFunction( void (* sh) (void) )
|
||||
void RegisterShutdownFunction(void (* sh)(void))
|
||||
{
|
||||
ShutDown = sh;
|
||||
ShutDown = sh;
|
||||
}
|
||||
|
||||
#ifndef RENDERTYPEWIN
|
||||
void Error(char *error, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_list va;
|
||||
|
||||
if (ShutDown) ShutDown();
|
||||
if (ShutDown) ShutDown();
|
||||
|
||||
if (error) {
|
||||
va_start(va, error);
|
||||
vprintf(error, va);
|
||||
va_end(va);
|
||||
printf("\n\n");
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
va_start(va, error);
|
||||
vprintf(error, va);
|
||||
va_end(va);
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
exit((error != NULL));
|
||||
exit((error != NULL));
|
||||
}
|
||||
#endif
|
||||
|
||||
char CheckParm(char *check)
|
||||
{
|
||||
int c;
|
||||
int c;
|
||||
|
||||
for (c=1;c<_buildargc;c++) {
|
||||
if (_buildargv[c][0] == '/' || _buildargv[c][0] == '-')
|
||||
if (!Bstrcasecmp(&_buildargv[c][1], check)) return c;
|
||||
}
|
||||
for (c=1;c<_buildargc;c++)
|
||||
{
|
||||
if (_buildargv[c][0] == '/' || _buildargv[c][0] == '-')
|
||||
if (!Bstrcasecmp(&_buildargv[c][1], check)) return c;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *SafeMalloc (int32 size)
|
||||
void *SafeMalloc(int32 size)
|
||||
{
|
||||
void *p;
|
||||
void *p;
|
||||
|
||||
p = malloc(size);
|
||||
if (!p) Error("SafeMalloc failure for %d bytes",size);
|
||||
p = malloc(size);
|
||||
if (!p) Error("SafeMalloc failure for %d bytes",size);
|
||||
|
||||
return p;
|
||||
return p;
|
||||
}
|
||||
|
||||
void SafeFree (void * ptr)
|
||||
void SafeFree(void * ptr)
|
||||
{
|
||||
if (!ptr) Error("Tried to deallocate NULL pointer.");
|
||||
free(ptr);
|
||||
if (!ptr) Error("Tried to deallocate NULL pointer.");
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void SafeRealloc (void ** ptr, int32 newsize)
|
||||
void SafeRealloc(void ** ptr, int32 newsize)
|
||||
{
|
||||
void *p;
|
||||
void *p;
|
||||
|
||||
p = realloc(*ptr, newsize);
|
||||
if (!p) Error("SafeRealloc failure for %d bytes",newsize);
|
||||
p = realloc(*ptr, newsize);
|
||||
if (!p) Error("SafeRealloc failure for %d bytes",newsize);
|
||||
|
||||
*ptr = p;
|
||||
*ptr = p;
|
||||
}
|
||||
|
||||
int32 ParseHex (char *hex)
|
||||
int32 ParseHex(char *hex)
|
||||
{
|
||||
return strtol(hex, NULL, 16);
|
||||
return strtol(hex, NULL, 16);
|
||||
}
|
||||
|
||||
int32 ParseNum (char *str)
|
||||
int32 ParseNum(char *str)
|
||||
{
|
||||
return strtol(str, NULL, 10);
|
||||
return strtol(str, NULL, 10);
|
||||
}
|
||||
|
||||
int16 MotoShort (int16 l)
|
||||
int16 MotoShort(int16 l)
|
||||
{
|
||||
#if B_LITTLE_ENDIAN != 0
|
||||
return l;
|
||||
return l;
|
||||
#else
|
||||
return ((l & 0x00ff) << 8) | ((l & 0xff00) >> 8);
|
||||
return ((l & 0x00ff) << 8) | ((l & 0xff00) >> 8);
|
||||
#endif
|
||||
}
|
||||
|
||||
int16 IntelShort (int16 l)
|
||||
int16 IntelShort(int16 l)
|
||||
{
|
||||
#if B_BIG_ENDIAN != 0
|
||||
return ((l & 0x00ff) << 8) | ((l & 0xff00) >> 8);
|
||||
return ((l & 0x00ff) << 8) | ((l & 0xff00) >> 8);
|
||||
#else
|
||||
return l;
|
||||
return l;
|
||||
#endif
|
||||
}
|
||||
|
||||
int32 MotoLong (int32 l)
|
||||
int32 MotoLong(int32 l)
|
||||
{
|
||||
#if B_LITTLE_ENDIAN != 0
|
||||
return l;
|
||||
return l;
|
||||
#else
|
||||
int32 t = ((l & 0x00ff00ffl) << 8) | ((l & 0xff00ff00l) >> 8);
|
||||
return ((t & 0x0000ffffl) << 16) | ((t & 0xffff0000l) >> 16);
|
||||
int32 t = ((l & 0x00ff00ffl) << 8) | ((l & 0xff00ff00l) >> 8);
|
||||
return ((t & 0x0000ffffl) << 16) | ((t & 0xffff0000l) >> 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32 IntelLong (int32 l)
|
||||
int32 IntelLong(int32 l)
|
||||
{
|
||||
#if B_BIG_ENDIAN != 0
|
||||
int32 t = ((l & 0x00ff00ffl) << 8) | ((l & 0xff00ff00l) >> 8);
|
||||
return ((t & 0x0000ffffl) << 16) | ((t & 0xffff0000l) >> 16);
|
||||
int32 t = ((l & 0x00ff00ffl) << 8) | ((l & 0xff00ff00l) >> 8);
|
||||
return ((t & 0x0000ffffl) << 16) | ((t & 0xffff0000l) >> 16);
|
||||
#else
|
||||
return l;
|
||||
return l;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue