1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-18 06:27:46 +00:00
re3/src/skel/skeleton.cpp

431 lines
7.3 KiB
C++
Raw Normal View History

2019-05-31 17:02:26 +00:00
#include "common.h"
2020-04-17 13:31:11 +00:00
2019-05-31 17:02:26 +00:00
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include "rwcore.h"
#include "skeleton.h"
#include "platform.h"
static RwBool DefaultVideoMode = TRUE;
2019-08-15 14:51:39 +00:00
bool TurnOnAnimViewer = false;
2020-04-17 05:54:14 +00:00
RsGlobalType RsGlobal;
2019-05-31 17:02:26 +00:00
2020-05-11 02:55:57 +00:00
#ifdef _WIN32
RwUInt32
#else
double
#endif
2019-05-31 17:02:26 +00:00
RsTimer(void)
{
return psTimer();
2019-05-31 17:02:26 +00:00
}
/*
*****************************************************************************
*/
void
RsCameraShowRaster(RwCamera * camera)
{
psCameraShowRaster(camera);
2019-05-31 17:02:26 +00:00
return;
2019-05-31 17:02:26 +00:00
}
/*
*****************************************************************************
*/
RwBool
RsCameraBeginUpdate(RwCamera * camera)
{
return psCameraBeginUpdate(camera);
}
2020-08-14 15:57:23 +00:00
/*
*****************************************************************************
*/
RwImage*
RsGrabScreen(RwCamera *camera)
{
return psGrabScreen(camera);
}
2019-05-31 17:02:26 +00:00
/*
*****************************************************************************
*/
RwBool
RsRegisterImageLoader(void)
{
return TRUE;
2019-05-31 17:02:26 +00:00
}
/*
*****************************************************************************
*/
static RwBool
RsSetDebug(void)
{
return TRUE;
2019-05-31 17:02:26 +00:00
}
/*
*****************************************************************************
*/
void
RsMouseSetPos(RwV2d * pos)
{
psMouseSetPos(pos);
2019-05-31 17:02:26 +00:00
return;
2019-05-31 17:02:26 +00:00
}
/*
*****************************************************************************
*/
RwBool
RsSelectDevice(void)
{
return psSelectDevice();
2019-05-31 17:02:26 +00:00
}
/*
*****************************************************************************
*/
RwBool
RsInputDeviceAttach(RsInputDeviceType inputDevice,
RsInputEventHandler inputEventHandler)
2019-05-31 17:02:26 +00:00
{
switch (inputDevice)
{
case rsKEYBOARD:
{
RsGlobal.keyboard.inputEventHandler = inputEventHandler;
RsGlobal.keyboard.used = TRUE;
break;
}
case rsMOUSE:
{
RsGlobal.mouse.inputEventHandler = inputEventHandler;
RsGlobal.mouse.used = TRUE;
break;
}
case rsPAD:
{
RsGlobal.pad.inputEventHandler = inputEventHandler;
RsGlobal.pad.used = TRUE;
break;
}
default:
{
return FALSE;
}
}
return TRUE;
2019-05-31 17:02:26 +00:00
}
/*
*****************************************************************************
*/
static RwBool
rsCommandLine(RwChar *arg)
{
RsEventHandler(rsFILELOAD, arg);
2019-05-31 17:02:26 +00:00
return TRUE;
2019-05-31 17:02:26 +00:00
}
/*
*****************************************************************************
*/
static RwBool
rsPreInitCommandLine(RwChar *arg)
{
if( !strcmp(arg, RWSTRING("-vms")) )
{
DefaultVideoMode = FALSE;
2019-05-31 17:02:26 +00:00
return TRUE;
}
2019-08-15 14:51:39 +00:00
#ifndef MASTER
if (!strcmp(arg, RWSTRING("-animviewer")))
{
TurnOnAnimViewer = TRUE;
2019-05-31 17:02:26 +00:00
2019-08-15 14:51:39 +00:00
return TRUE;
}
#endif
return FALSE;
2019-05-31 17:02:26 +00:00
}
/*
*****************************************************************************
*/
RsEventStatus
RsKeyboardEventHandler(RsEvent event, void *param)
{
if (RsGlobal.keyboard.used)
{
return RsGlobal.keyboard.inputEventHandler(event, param);
}
2019-05-31 17:02:26 +00:00
return rsEVENTNOTPROCESSED;
2019-05-31 17:02:26 +00:00
}
/*
*****************************************************************************
*/
RsEventStatus
RsPadEventHandler(RsEvent event, void *param)
{
if (RsGlobal.pad.used)
{
return RsGlobal.pad.inputEventHandler(event, param);
}
2019-05-31 17:02:26 +00:00
return rsEVENTNOTPROCESSED;
2019-05-31 17:02:26 +00:00
}
/*
*****************************************************************************
*/
RsEventStatus
RsEventHandler(RsEvent event, void *param)
{
RsEventStatus result;
RsEventStatus es;
2019-05-31 17:02:26 +00:00
/*
* Give the application an opportunity to override any events...
*/
es = AppEventHandler(event, param);
/*
* We never allow the app to replace the quit behaviour,
* only to intercept...
*/
if (event == rsQUITAPP)
{
/*
* Set the flag which causes the event loop to exit...
*/
RsGlobal.quit = TRUE;
}
if (es == rsEVENTNOTPROCESSED)
{
switch (event)
{
case rsSELECTDEVICE:
result =
(RsSelectDevice()? rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsCOMMANDLINE:
result = (rsCommandLine((RwChar *) param) ?
rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsPREINITCOMMANDLINE:
result = (rsPreInitCommandLine((RwChar *) param) ?
rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsINITDEBUG:
result =
(RsSetDebug()? rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsREGISTERIMAGELOADER:
result = (RsRegisterImageLoader()?
rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsRWTERMINATE:
RsRwTerminate();
result = (rsEVENTPROCESSED);
break;
2020-05-23 09:34:22 +00:00
case rsRWINITIALIZE:
result = (RsRwInitialize(param) ?
rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsTERMINATE:
RsTerminate();
result = (rsEVENTPROCESSED);
break;
2020-05-23 09:34:22 +00:00
case rsINITIALIZE:
result =
2020-05-23 09:34:22 +00:00
(RsInitialize()? rsEVENTPROCESSED : rsEVENTERROR);
break;
default:
result = (es);
break;
}
}
else
{
result = (es);
}
return result;
2019-05-31 17:02:26 +00:00
}
/*
*****************************************************************************
*/
void
RsRwTerminate(void)
{
/* Close RenderWare */
2019-05-31 17:02:26 +00:00
RwEngineStop();
RwEngineClose();
RwEngineTerm();
2019-05-31 17:02:26 +00:00
return;
2019-05-31 17:02:26 +00:00
}
/*
*****************************************************************************
*/
RwBool
2020-05-23 09:34:22 +00:00
RsRwInitialize(void *displayID)
2019-05-31 17:02:26 +00:00
{
RwEngineOpenParams openParams;
2020-04-26 10:25:03 +00:00
/*
* Start RenderWare...
*/
2019-05-31 17:02:26 +00:00
if (!RwEngineInit(psGetMemoryFunctions(), 0, rsRESOURCESDEFAULTARENASIZE))
{
return (FALSE);
}
/*
* Install any platform specific file systems...
*/
psInstallFileSystem();
2019-05-31 17:02:26 +00:00
/*
* Initialize debug message handling...
*/
2019-06-30 10:53:39 +00:00
RsEventHandler(rsINITDEBUG, nil);
/*
* Attach all plugins...
*/
2019-06-30 10:53:39 +00:00
if (RsEventHandler(rsPLUGINATTACH, nil) == rsEVENTERROR)
{
return (FALSE);
}
/*
* Attach input devices...
*/
2019-06-30 10:53:39 +00:00
if (RsEventHandler(rsINPUTDEVICEATTACH, nil) == rsEVENTERROR)
{
return (FALSE);
}
2019-05-31 17:02:26 +00:00
openParams.displayID = displayID;
if (!RwEngineOpen(&openParams))
{
RwEngineTerm();
return (FALSE);
}
2019-05-31 17:02:26 +00:00
if (RsEventHandler(rsSELECTDEVICE, displayID) == rsEVENTERROR)
{
RwEngineClose();
RwEngineTerm();
return (FALSE);
}
2019-05-31 17:02:26 +00:00
if (!RwEngineStart())
{
RwEngineClose();
RwEngineTerm();
return (FALSE);
}
2019-05-31 17:02:26 +00:00
/*
* Register loaders for an image with a particular file extension...
*/
2019-06-30 10:53:39 +00:00
RsEventHandler(rsREGISTERIMAGELOADER, nil);
2019-05-31 17:02:26 +00:00
psNativeTextureSupport();
2019-05-31 17:02:26 +00:00
RwTextureSetMipmapping(FALSE);
2019-05-31 17:02:26 +00:00
RwTextureSetAutoMipmapping(FALSE);
return TRUE;
2019-05-31 17:02:26 +00:00
}
/*
*****************************************************************************
*/
void
RsTerminate(void)
{
psTerminate();
2019-05-31 17:02:26 +00:00
return;
2019-05-31 17:02:26 +00:00
}
/*
*****************************************************************************
*/
RwBool
2020-05-23 09:34:22 +00:00
RsInitialize(void)
2019-05-31 17:02:26 +00:00
{
/*
* Initialize Platform independent data...
*/
RwBool result;
2019-05-31 17:02:26 +00:00
2020-05-23 09:34:22 +00:00
RsGlobal.appName = RWSTRING("GTA: Vice City");
RsGlobal.maximumWidth = DEFAULT_SCREEN_WIDTH;
2019-05-31 17:02:26 +00:00
RsGlobal.maximumHeight = DEFAULT_SCREEN_HEIGHT;
RsGlobal.width = DEFAULT_SCREEN_WIDTH;
RsGlobal.height = DEFAULT_SCREEN_HEIGHT;
2019-05-31 17:02:26 +00:00
RsGlobal.maxFPS = 30;
RsGlobal.quit = FALSE;
2019-05-31 17:02:26 +00:00
/* setup the keyboard */
RsGlobal.keyboard.inputDeviceType = rsKEYBOARD;
2019-06-30 10:53:39 +00:00
RsGlobal.keyboard.inputEventHandler = nil;
RsGlobal.keyboard.used = FALSE;
2019-05-31 17:02:26 +00:00
/* setup the mouse */
RsGlobal.mouse.inputDeviceType = rsMOUSE;
2019-06-30 10:53:39 +00:00
RsGlobal.mouse.inputEventHandler = nil;
RsGlobal.mouse.used = FALSE;
2019-05-31 17:02:26 +00:00
/* setup the pad */
RsGlobal.pad.inputDeviceType = rsPAD;
2019-06-30 10:53:39 +00:00
RsGlobal.pad.inputEventHandler = nil;
RsGlobal.pad.used = FALSE;
2019-05-31 17:02:26 +00:00
2020-05-23 09:34:22 +00:00
result = psInitialize();
2019-05-31 17:02:26 +00:00
return result;
2019-05-31 17:02:26 +00:00
}