wiiu: merge fixes and other polishing

This commit is contained in:
GaryOderNichts 2020-12-26 03:23:42 +01:00
parent 7e860c5c53
commit 676f71e2d1
9 changed files with 157 additions and 142 deletions

View File

@ -24,9 +24,13 @@ SOURCES := src \
src/audio \ src/audio \
src/audio/oal \ src/audio/oal \
src/audio/eax \ src/audio/eax \
src/buildings \
src/collision \
src/control \ src/control \
src/core \ src/core \
src/entities \ src/entities \
src/extras \
src/fakerw \
src/math \ src/math \
src/modelinfo \ src/modelinfo \
src/objects \ src/objects \
@ -39,9 +43,7 @@ SOURCES := src \
src/skel/wiiu/debug \ src/skel/wiiu/debug \
src/text \ src/text \
src/vehicles \ src/vehicles \
src/weapons \ src/weapons
src/extras \
src/fakerw
DATA := data DATA := data
INCLUDES := $(SOURCES) \ INCLUDES := $(SOURCES) \
vendor/librw \ vendor/librw \

View File

@ -11,7 +11,9 @@ void EFX_Set(ALuint effect, const EAXLISTENERPROPERTIES *props);
void EAX3_SetReverbMix(ALuint filter, float mix); void EAX3_SetReverbMix(ALuint filter, float mix);
void SetEffectsLevel(ALuint uiFilter, float level); void SetEffectsLevel(ALuint uiFilter, float level);
#ifndef __WIIU__
namespace re3_openal { namespace re3_openal {
#endif
extern LPALGENEFFECTS alGenEffects; extern LPALGENEFFECTS alGenEffects;
extern LPALDELETEEFFECTS alDeleteEffects; extern LPALDELETEEFFECTS alDeleteEffects;
@ -47,8 +49,10 @@ extern LPALGETFILTERIV alGetFilteriv;
extern LPALGETFILTERF alGetFilterf; extern LPALGETFILTERF alGetFilterf;
extern LPALGETFILTERFV alGetFilterfv; extern LPALGETFILTERFV alGetFilterfv;
#ifndef __WIIU__
} }
using namespace re3_openal; using namespace re3_openal;
#endif
#endif #endif

View File

@ -47,6 +47,8 @@
#include <direct.h> #include <direct.h>
#include <shobjidl.h> #include <shobjidl.h>
#include <shlguid.h> #include <shlguid.h>
#elif defined __WIIU__
extern "C" char *_getcwd (char *__buf, size_t __size);
#else #else
#define _getcwd getcwd #define _getcwd getcwd
#endif #endif
@ -501,6 +503,8 @@ _ResolveLink(char const *path, char *out)
psl->Release(); psl->Release();
} }
return false;
#elif defined __WIIU__
return false; return false;
#else #else
struct stat sb; struct stat sb;
@ -542,7 +546,7 @@ _FindMP3s(void)
int total_ms; int total_ms;
WIN32_FIND_DATA fd; WIN32_FIND_DATA fd;
if (getcwd(_mp3DirectoryPath, MAX_PATH) == NULL) { if (_getcwd(_mp3DirectoryPath, MAX_PATH) == NULL) {
perror("getcwd: "); perror("getcwd: ");
return; return;
} }

View File

@ -42,7 +42,7 @@ static int wiiu_thread_create(OSThread *thread, const void *attr, void *(*start_
{ {
OSThread *handle = (OSThread *)memalign(16, sizeof(OSThread)); OSThread *handle = (OSThread *)memalign(16, sizeof(OSThread));
unsigned int stackSize = 0x8000; unsigned int stackSize = 0x8000;
void *stackTop = memalign(16, stackSize) + stackSize; void *stackTop = (uint8*) memalign(16, stackSize) + stackSize;
if (!OSCreateThread(handle, if (!OSCreateThread(handle,
(OSThreadEntryPointFn)start_routine, (OSThreadEntryPointFn)start_routine,
@ -85,7 +85,11 @@ struct CdReadInfo
pthread_t pChannelThread; pthread_t pChannelThread;
sem_t *pStartSemaphore; sem_t *pStartSemaphore;
#endif #endif
#ifdef __WIIU__
OSSemaphore pDoneSemaphore;
#else
sem_t *pDoneSemaphore; // used for CdStreamSync sem_t *pDoneSemaphore; // used for CdStreamSync
#endif
int32 hFile; int32 hFile;
}; };
@ -103,10 +107,10 @@ OSSemaphore gCdStreamSema;
#else #else
pthread_t _gCdStreamThread; pthread_t _gCdStreamThread;
sem_t *gCdStreamSema; // released when we have new thing to read(so channel is set) sem_t *gCdStreamSema; // released when we have new thing to read(so channel is set)
#endif
int8 gCdStreamThreadStatus; // 0: created 1:priority set up 2:abort now int8 gCdStreamThreadStatus; // 0: created 1:priority set up 2:abort now
Queue gChannelRequestQ; Queue gChannelRequestQ;
bool _gbCdStreamOverlapped; bool _gbCdStreamOverlapped;
#endif
CdReadInfo *gpReadInfo; CdReadInfo *gpReadInfo;
@ -127,6 +131,9 @@ CdStreamInitThread(void)
gChannelRequestQ.tail = 0; gChannelRequestQ.tail = 0;
gChannelRequestQ.size = gNumChannels + 1; gChannelRequestQ.size = gNumChannels + 1;
ASSERT(gChannelRequestQ.items != nil ); ASSERT(gChannelRequestQ.items != nil );
#ifdef __WIIU__
OSInitSemaphore(&gCdStreamSema, 0);
#else
gCdStreamSema = sem_open("/semaphore_cd_stream", O_CREAT, 0644, 1); gCdStreamSema = sem_open("/semaphore_cd_stream", O_CREAT, 0644, 1);
@ -135,12 +142,16 @@ CdStreamInitThread(void)
ASSERT(0); ASSERT(0);
return; return;
} }
#endif
#endif #endif
if ( gNumChannels > 0 ) if ( gNumChannels > 0 )
{ {
for ( int32 i = 0; i < gNumChannels; i++ ) for ( int32 i = 0; i < gNumChannels; i++ )
{ {
#ifdef __WIIU__
OSInitSemaphore(&gpReadInfo[i].pDoneSemaphore, 0);
#else
sprintf(semName,"/semaphore_done%d",i); sprintf(semName,"/semaphore_done%d",i);
gpReadInfo[i].pDoneSemaphore = sem_open(semName, O_CREAT, 0644, 1); gpReadInfo[i].pDoneSemaphore = sem_open(semName, O_CREAT, 0644, 1);
@ -150,6 +161,7 @@ CdStreamInitThread(void)
ASSERT(0); ASSERT(0);
return; return;
} }
#endif
#ifdef ONE_THREAD_PER_CHANNEL #ifdef ONE_THREAD_PER_CHANNEL
sprintf(semName,"/semaphore_start%d",i); sprintf(semName,"/semaphore_start%d",i);
gpReadInfo[i].pStartSemaphore = sem_open(semName, O_CREAT, 0644, 1); gpReadInfo[i].pStartSemaphore = sem_open(semName, O_CREAT, 0644, 1);
@ -178,6 +190,9 @@ CdStreamInitThread(void)
#ifndef ONE_THREAD_PER_CHANNEL #ifndef ONE_THREAD_PER_CHANNEL
debug("Using one streaming thread for all channels\n"); debug("Using one streaming thread for all channels\n");
gCdStreamThreadStatus = 0; gCdStreamThreadStatus = 0;
#ifdef __WIIU__
wiiu_thread_create(&_gCdStreamThread, NULL, CdStreamThread, nil);
#else
status = pthread_create(&_gCdStreamThread, NULL, CdStreamThread, nil); status = pthread_create(&_gCdStreamThread, NULL, CdStreamThread, nil);
if (status == -1) if (status == -1)
@ -186,6 +201,7 @@ CdStreamInitThread(void)
ASSERT(0); ASSERT(0);
return; return;
} }
#endif
#else #else
debug("Using separate streaming threads for each channel\n"); debug("Using separate streaming threads for each channel\n");
#endif #endif
@ -194,6 +210,7 @@ CdStreamInitThread(void)
void void
CdStreamInit(int32 numChannels) CdStreamInit(int32 numChannels)
{ {
#ifndef __WIIU__
struct statvfs fsInfo; struct statvfs fsInfo;
if((statvfs("models/gta3.img", &fsInfo)) < 0) if((statvfs("models/gta3.img", &fsInfo)) < 0)
@ -216,6 +233,11 @@ CdStreamInit(int32 numChannels)
} }
*/ */
void *pBuffer = (void *)RwMallocAlign(CDSTREAM_SECTOR_SIZE, (RwUInt32)fsInfo.f_bsize); void *pBuffer = (void *)RwMallocAlign(CDSTREAM_SECTOR_SIZE, (RwUInt32)fsInfo.f_bsize);
#else
// statvfs doesn't work properly on wiiu
void *pBuffer = (void *)RwMallocAlign(CDSTREAM_SECTOR_SIZE, CDSTREAM_SECTOR_SIZE);
#endif
ASSERT( pBuffer != nil ); ASSERT( pBuffer != nil );
gNumImages = 0; gNumImages = 0;
@ -266,8 +288,14 @@ CdStreamShutdown(void)
// Destroying semaphores and free(gpReadInfo) will be done at threads // Destroying semaphores and free(gpReadInfo) will be done at threads
#ifndef ONE_THREAD_PER_CHANNEL #ifndef ONE_THREAD_PER_CHANNEL
gCdStreamThreadStatus = 2; gCdStreamThreadStatus = 2;
#ifdef __WIIU__
OSSignalSemaphore(&gCdStreamSema);
// softlocks
// OSJoinThread(&_gCdStreamThread, NULL);
#else
sem_post(gCdStreamSema); sem_post(gCdStreamSema);
pthread_join(_gCdStreamThread, nil); pthread_join(_gCdStreamThread, nil);
#endif
#else #else
for ( int32 i = 0; i < gNumChannels; i++ ) { for ( int32 i = 0; i < gNumChannels; i++ ) {
gpReadInfo[i].nThreadStatus = 2; gpReadInfo[i].nThreadStatus = 2;
@ -311,8 +339,12 @@ CdStreamRead(int32 channel, void *buffer, uint32 offset, uint32 size)
#ifndef ONE_THREAD_PER_CHANNEL #ifndef ONE_THREAD_PER_CHANNEL
AddToQueue(&gChannelRequestQ, channel); AddToQueue(&gChannelRequestQ, channel);
#ifdef __WIIU__
OSSignalSemaphore(&gCdStreamSema);
#else
if ( sem_post(gCdStreamSema) != 0 ) if ( sem_post(gCdStreamSema) != 0 )
printf("Signal Sema Error\n"); printf("Signal Sema Error\n");
#endif
#else #else
if ( sem_post(pChannel->pStartSemaphore) != 0 ) if ( sem_post(pChannel->pStartSemaphore) != 0 )
printf("Signal Sema Error\n"); printf("Signal Sema Error\n");
@ -380,9 +412,15 @@ CdStreamSync(int32 channel)
pChannel->nSectorsToRead = 0; pChannel->nSectorsToRead = 0;
if (pChannel->bReading) { if (pChannel->bReading) {
pChannel->bLocked = true; pChannel->bLocked = true;
#ifdef __WIIU__
OSCancelThread(&_gCdStreamThread);
while (pChannel->bLocked)
OSWaitSemaphore(&pChannel->pDoneSemaphore);
#else
pthread_kill(_gCdStreamThread, SIGUSR1); pthread_kill(_gCdStreamThread, SIGUSR1);
while (pChannel->bLocked) while (pChannel->bLocked)
sem_wait(pChannel->pDoneSemaphore); sem_wait(pChannel->pDoneSemaphore);
#endif
} }
#endif #endif
pChannel->bReading = false; pChannel->bReading = false;
@ -394,7 +432,11 @@ CdStreamSync(int32 channel)
{ {
pChannel->bLocked = true; pChannel->bLocked = true;
while (pChannel->bLocked) while (pChannel->bLocked)
#ifdef __WIIU__
OSWaitSemaphore(&pChannel->pDoneSemaphore);
#else
sem_wait(pChannel->pDoneSemaphore); sem_wait(pChannel->pDoneSemaphore);
#endif
} }
pChannel->bReading = false; pChannel->bReading = false;
@ -445,7 +487,11 @@ void *CdStreamThread(void *param)
#ifndef ONE_THREAD_PER_CHANNEL #ifndef ONE_THREAD_PER_CHANNEL
while (gCdStreamThreadStatus != 2) { while (gCdStreamThreadStatus != 2) {
#ifdef __WIIU__
OSWaitSemaphore(&gCdStreamSema);
#else
sem_wait(gCdStreamSema); sem_wait(gCdStreamSema);
#endif
int32 channel = GetFirstInQueue(&gChannelRequestQ); int32 channel = GetFirstInQueue(&gChannelRequestQ);
#else #else
int channel = *((int*)param); int channel = *((int*)param);
@ -498,12 +544,17 @@ void *CdStreamThread(void *param)
if ( pChannel->bLocked ) if ( pChannel->bLocked )
{ {
pChannel->bLocked = 0; pChannel->bLocked = 0;
#ifdef __WIIU__
OSSignalSemaphore(&pChannel->pDoneSemaphore);
#else
sem_post(pChannel->pDoneSemaphore); sem_post(pChannel->pDoneSemaphore);
#endif
} }
pChannel->bReading = false; pChannel->bReading = false;
} }
char semName[20]; char semName[20];
#ifndef ONE_THREAD_PER_CHANNEL #ifndef ONE_THREAD_PER_CHANNEL
#ifndef __WIIU__
for ( int32 i = 0; i < gNumChannels; i++ ) for ( int32 i = 0; i < gNumChannels; i++ )
{ {
sem_close(gpReadInfo[i].pDoneSemaphore); sem_close(gpReadInfo[i].pDoneSemaphore);
@ -512,6 +563,7 @@ void *CdStreamThread(void *param)
} }
sem_close(gCdStreamSema); sem_close(gCdStreamSema);
sem_unlink("/semaphore_cd_stream"); sem_unlink("/semaphore_cd_stream");
#endif
free(gChannelRequestQ.items); free(gChannelRequestQ.items);
#else #else
sem_close(gpReadInfo[channel].pStartSemaphore); sem_close(gpReadInfo[channel].pStartSemaphore);
@ -525,8 +577,13 @@ void *CdStreamThread(void *param)
if (gpReadInfo) if (gpReadInfo)
free(gpReadInfo); free(gpReadInfo);
gpReadInfo = nil; gpReadInfo = nil;
#ifdef __WIIU__
//OSExitThread(0);
return 0;
#else
pthread_exit(nil); pthread_exit(nil);
#endif #endif
#endif
} }
bool bool

View File

@ -213,7 +213,11 @@ CFileLoader::LoadCollisionFile(const char *filename)
fd = CFileMgr::OpenFile(filename, "rb"); fd = CFileMgr::OpenFile(filename, "rb");
while(CFileMgr::Read(fd, (char*)&header, sizeof(header))){ while(CFileMgr::Read(fd, (char*)&header, sizeof(header))){
assert(strncmp(header.ident, "COLL", 4) == 0); #ifdef BIGENDIAN
assert(header.ident == 'COLL');
#else
assert(header.ident == 'LLOC');
#endif
#ifdef BIGENDIAN #ifdef BIGENDIAN
header.size = BSWAP32(header.size); header.size = BSWAP32(header.size);
#endif #endif

View File

@ -269,7 +269,7 @@ enum Config {
#if !defined(RW_GL3) && defined(_WIN32) #if !defined(RW_GL3) && defined(_WIN32)
#define XINPUT #define XINPUT
#endif #endif
#if !defined(_WIN32) && !defined(__SWITCH__) #if !defined(_WIN32) && !defined(__SWITCH__) && !defined(__WIIU__)
#define DONT_TRUST_RECOGNIZED_JOYSTICKS // Then we'll only rely on GLFW gamepad DB, and expect user to enter Controller->Detect joysticks if his joystick isn't on that list. #define DONT_TRUST_RECOGNIZED_JOYSTICKS // Then we'll only rely on GLFW gamepad DB, and expect user to enter Controller->Detect joysticks if his joystick isn't on that list.
#endif #endif
#define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m #define DETECT_PAD_INPUT_SWITCH // Adds automatic switch of pad related stuff between controller and kb/m
@ -305,7 +305,9 @@ enum Config {
# define GRAPHICS_MENU_OPTIONS // otherwise Display settings will be scrollable # define GRAPHICS_MENU_OPTIONS // otherwise Display settings will be scrollable
# define NO_ISLAND_LOADING // disable loadscreen between islands via loading all island data at once, consumes more memory and CPU # define NO_ISLAND_LOADING // disable loadscreen between islands via loading all island data at once, consumes more memory and CPU
# define CUTSCENE_BORDERS_SWITCH # define CUTSCENE_BORDERS_SWITCH
# define MULTISAMPLING // adds MSAA option # ifndef __WIIU__ // not supported in gx2 librw
# define MULTISAMPLING // adds MSAA option
# endif
# define INVERT_LOOK_FOR_PAD // add bInvertLook4Pad from VC # define INVERT_LOOK_FOR_PAD // add bInvertLook4Pad from VC
# endif # endif
#endif #endif

View File

@ -41,14 +41,14 @@
#include <stdarg.h> #include <stdarg.h>
#endif #endif
#ifdef __WIIU__
#include <coreinit/debug.h> #include <coreinit/debug.h>
#include <whb/log.h> #include <whb/log.h>
#endif #endif
#include <list>
#ifdef RWLIBS #ifdef RWLIBS
extern "C" int vsprintf(char* const _Buffer, char const* const _Format, va_list _ArgList);
#endif
#ifdef USE_PS2_RAND #ifdef USE_PS2_RAND
unsigned long long myrand_seed = 1; unsigned long long myrand_seed = 1;

View File

@ -38,7 +38,7 @@ HANDLE FindFirstFile(const char* pathname, WIN32_FIND_DATA* firstfile) {
// Case-sensitivity and backslashes... // Case-sensitivity and backslashes...
// Will be freed at the bottom // Will be freed at the bottom
char *realFolder = casepath(folder); char *realFolder = casepath(folder, false);
if (realFolder) { if (realFolder) {
folder = realFolder; folder = realFolder;
} }

View File

@ -34,6 +34,7 @@
#include "Sprite2d.h" #include "Sprite2d.h"
#include "AnimViewer.h" #include "AnimViewer.h"
#include "Font.h" #include "Font.h"
#include "MemoryMgr.h"
#include <stddef.h> #include <stddef.h>
#include <locale.h> #include <locale.h>
@ -74,7 +75,7 @@ void _psCreateFolder(const char *path)
char fullpath[PATH_MAX]; char fullpath[PATH_MAX];
realpath(path, fullpath); realpath(path, fullpath);
if (lstat(fullpath, &info) != 0) { if (stat(fullpath, &info) != 0) {
if (errno == ENOENT || (errno != EACCES && !S_ISDIR(info.st_mode))) { if (errno == ENOENT || (errno != EACCES && !S_ISDIR(info.st_mode))) {
mkdir(fullpath, 0755); mkdir(fullpath, 0755);
} }
@ -168,7 +169,11 @@ psMouseSetPos(RwV2d *pos)
RwMemoryFunctions* RwMemoryFunctions*
psGetMemoryFunctions(void) psGetMemoryFunctions(void)
{ {
#ifdef USE_CUSTOM_ALLOCATOR
return &memFuncs;
#else
return nil; return nil;
#endif
} }
/* /*
@ -196,8 +201,6 @@ psNativeTextureSupport(void)
RwBool RwBool
psInitialize(void) psInitialize(void)
{ {
WHBLogPrintf("psInitialize");
PsGlobal.lastMousePos.x = PsGlobal.lastMousePos.y = 0.0f; PsGlobal.lastMousePos.x = PsGlobal.lastMousePos.y = 0.0f;
RsGlobal.ps = &PsGlobal; RsGlobal.ps = &PsGlobal;
@ -208,7 +211,6 @@ psInitialize(void)
PsGlobal.joy1id = -1; PsGlobal.joy1id = -1;
PsGlobal.joy2id = -1; PsGlobal.joy2id = -1;
WHBLogPrintf("Initializing CFileMgr");
CFileMgr::Initialise(); CFileMgr::Initialise();
#ifdef PS2_MENU #ifdef PS2_MENU
@ -261,36 +263,31 @@ psInitialize(void)
TheMemoryCard.Init(); TheMemoryCard.Init();
#else #else
WHBLogPrintf("Setting save dir");
C_PcSave::SetSaveDirectory(_psGetUserFilesFolder()); C_PcSave::SetSaveDirectory(_psGetUserFilesFolder());
WHBLogPrintf("Initializing language");
InitialiseLanguage(); InitialiseLanguage();
#ifndef GTA3_1_1_PATCH #if GTA_VERSION < GTA3_PC_11
FrontEndMenuManager.LoadSettings(); FrontEndMenuManager.LoadSettings();
#endif #endif
#endif #endif
WHBLogPrintf("gGameState = GS_START_UP");
gGameState = GS_START_UP; gGameState = GS_START_UP;
TRACE("gGameState = GS_START_UP"); TRACE("gGameState = GS_START_UP");
_dwOperatingSystemVersion = OS_WINXP;
#ifndef PS2_MENU #ifndef PS2_MENU
#ifdef GTA3_1_1_PATCH #if GTA_VERSION < GTA3_PC_11
FrontEndMenuManager.LoadSettings(); FrontEndMenuManager.LoadSettings();
#endif #endif
#endif #endif
// TODO: Is there a way to get free ram on wiiu?
_dwMemAvailPhys = 1024*1024*170; //systemInfo.freeram; // memory required to have all vehicles loaded
_dwOperatingSystemVersion = OS_WINXP; // To fool other classes _dwMemAvailPhys = 1024*1024*170;
// debug("Physical memory size %u\n", systemInfo.totalram);
// debug("Available physical memory %u\n", systemInfo.freeram);
TheText.Unload(); TheText.Unload();
@ -414,18 +411,15 @@ psSelectDevice()
RwVideoMode vm; RwVideoMode vm;
RwInt32 subSysNum; RwInt32 subSysNum;
RwInt32 AutoRenderer = 0; RwInt32 AutoRenderer = 0;
WHBLogPrintf("psSelectDevice");
RwBool modeFound = FALSE; RwBool modeFound = FALSE;
if ( !useDefault ) if ( !useDefault )
{ {
WHBLogPrintf("Not using default");
GnumSubSystems = RwEngineGetNumSubSystems(); GnumSubSystems = RwEngineGetNumSubSystems();
if ( !GnumSubSystems ) if ( !GnumSubSystems )
{ {
WHBLogPrintf("no subsystems");
return FALSE; return FALSE;
} }
@ -438,7 +432,6 @@ psSelectDevice()
RwEngineGetSubSystemInfo(&GsubSysInfo[subSysNum], subSysNum); RwEngineGetSubSystemInfo(&GsubSysInfo[subSysNum], subSysNum);
} }
WHBLogPrintf("RwEngineGetCurrentSubSystem");
/* Get the default selection */ /* Get the default selection */
GcurSel = RwEngineGetCurrentSubSystem(); GcurSel = RwEngineGetCurrentSubSystem();
#ifdef IMPROVED_VIDEOMODE #ifdef IMPROVED_VIDEOMODE
@ -450,7 +443,6 @@ psSelectDevice()
/* Set the driver to use the correct sub system */ /* Set the driver to use the correct sub system */
if (!RwEngineSetSubSystem(GcurSel)) if (!RwEngineSetSubSystem(GcurSel))
{ {
WHBLogPrintf("cannot set subsystem %d", GcurSel);
return FALSE; return FALSE;
} }
@ -575,7 +567,6 @@ psSelectDevice()
* dimensions to match */ * dimensions to match */
if (!RwEngineSetVideoMode(GcurSelVM)) if (!RwEngineSetVideoMode(GcurSelVM))
{ {
WHBLogPrintf("Cannot set video mode");
return FALSE; return FALSE;
} }
/* /*
@ -630,24 +621,9 @@ long _InputInitialiseMouse()
void psPostRWinit(void) void psPostRWinit(void)
{ {
RwVideoMode vm;
RwEngineGetVideoModeInfo(&vm, GcurSelVM);
// TODO: wiiu
// glfwSetKeyCallback(PSGLOBAL(window), keypressCB);
// glfwSetWindowSizeCallback(PSGLOBAL(window), resizeCB);
// glfwSetScrollCallback(PSGLOBAL(window), scrollCB);
// glfwSetCursorPosCallback(PSGLOBAL(window), cursorCB);
// glfwSetCursorEnterCallback(PSGLOBAL(window), cursorEnterCB);
// glfwSetJoystickCallback(joysChangeCB);
_InputInitialiseJoys(); _InputInitialiseJoys();
_InputInitialiseMouse(); _InputInitialiseMouse();
// if(!(vm.flags & rwVIDEOMODEEXCLUSIVE))
// glfwSetWindowSize(PSGLOBAL(window), RsGlobal.maximumWidth, RsGlobal.maximumHeight);
// Make sure all keys are released // Make sure all keys are released
CPad::GetPad(0)->Clear(true); CPad::GetPad(0)->Clear(true);
CPad::GetPad(1)->Clear(true); CPad::GetPad(1)->Clear(true);
@ -693,7 +669,7 @@ RwBool _psSetVideoMode(RwInt32 subSystem, RwInt32 videoMode)
void InitialiseLanguage() void InitialiseLanguage()
{ {
// TODO: wiiu get system language // TODO: wiiu get system language
// Mandatory for Linux(Unix? Posix?) to set lang. to environment lang. // Mandatory for Linux(Unix? Posix?) to set lang. to environment lang.
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
@ -875,9 +851,12 @@ main(int argc, char *argv[])
RwV2d pos; RwV2d pos;
RwInt32 i; RwInt32 i;
WHBProcInit(); #ifdef USE_CUSTOM_ALLOCATOR
InitMemoryMgr();
#endif
WHBProcInit();
WHBInitCrashHandler(); WHBInitCrashHandler();
WHBMountSdCard();
WHBLogUdpInit(); WHBLogUdpInit();
@ -899,7 +878,6 @@ main(int argc, char *argv[])
return FALSE; return FALSE;
} }
WHBLogPrintf("RE3 Wii U initialized");
// for(i=1; i<argc; i++) // for(i=1; i<argc; i++)
// { // {
@ -913,8 +891,8 @@ main(int argc, char *argv[])
openParams.width = RsGlobal.maximumWidth; openParams.width = RsGlobal.maximumWidth;
openParams.height = RsGlobal.maximumHeight; openParams.height = RsGlobal.maximumHeight;
openParams.windowtitle = RsGlobal.appName; openParams.windowtitle = RsGlobal.appName;
// TODO wiiu openParams.window = &PSGLOBAL(window); openParams.window = nil;
ControlsManager.MakeControllerActionsBlank(); ControlsManager.MakeControllerActionsBlank();
ControlsManager.InitDefaultControlConfiguration(); ControlsManager.InitDefaultControlConfiguration();
@ -924,32 +902,18 @@ main(int argc, char *argv[])
if( rsEVENTERROR == RsEventHandler(rsRWINITIALIZE, &openParams) ) if( rsEVENTERROR == RsEventHandler(rsRWINITIALIZE, &openParams) )
{ {
RsEventHandler(rsTERMINATE, nil); RsEventHandler(rsTERMINATE, nil);
WHBLogPrintf("Cannot initialize RenderWare\n"); WHBLogPrintf("Cannot initialize RenderWare");
WHBProcShutdown(); WHBProcShutdown();
return 0; return 0;
} }
WHBLogPrintf("RenderWare Initialized");
psPostRWinit(); psPostRWinit();
WHBLogPrintf("Renderware post init done");
ControlsManager.InitDefaultControlConfigMouse(MousePointerStateHelper.GetMouseSetUp()); ControlsManager.InitDefaultControlConfigMouse(MousePointerStateHelper.GetMouseSetUp());
WHBLogPrintf("mouse initialized");
// TODO Wii U
// glfwSetWindowPos(PSGLOBAL(window), 0, 0);
// /*
// * Parse command line parameters (except program name) one at
// * a time AFTER RenderWare initialization...
// */
// for(i=1; i<argc; i++)
// {
// RsEventHandler(rsCOMMANDLINE, argv[i]);
// }
/* /*
* Force a camera resize event... * Force a camera resize event...
@ -965,7 +929,6 @@ main(int argc, char *argv[])
RsEventHandler(rsCAMERASIZE, &r); RsEventHandler(rsCAMERASIZE, &r);
} }
WHBLogPrintf("camera resized");
{ {
CFileMgr::SetDirMyDocuments(); CFileMgr::SetDirMyDocuments();
@ -981,7 +944,6 @@ main(int argc, char *argv[])
CFileMgr::SetDir(""); CFileMgr::SetDir("");
} }
WHBLogPrintf("set loaded");
#ifdef PS2_MENU #ifdef PS2_MENU
int32 r = TheMemoryCard.CheckCardStateAtGameStartUp(CARD_ONE); int32 r = TheMemoryCard.CheckCardStateAtGameStartUp(CARD_ONE);
@ -999,21 +961,8 @@ main(int argc, char *argv[])
} }
#endif #endif
if (TurnOnAnimViewer)
{
#ifndef MASTER
CAnimViewer::Initialise();
#ifndef PS2_MENU
FrontEndMenuManager.m_bGameNotLoaded = false;
#endif
gGameState = GS_ANIMVIEWER;
TurnOnAnimViewer = false;
#endif
}
WHBLogPrintf("animviewer initialized"); // main loop
// main loop
while ( TRUE ) while ( TRUE )
{ {
RwInitialised = TRUE; RwInitialised = TRUE;
@ -1030,6 +979,18 @@ main(int argc, char *argv[])
* Enter the message processing loop... * Enter the message processing loop...
*/ */
#ifndef MASTER
if (gbModelViewer) {
// This is TheModelViewer in LCS, but not compiled on III Mobile.
LoadingScreen("Loading the ModelViewer", NULL, GetRandomSplashScreen());
CAnimViewer::Initialise();
CTimer::Update();
#ifndef PS2_MENU
FrontEndMenuManager.m_bGameNotLoaded = false;
#endif
}
#endif
#ifdef PS2_MENU #ifdef PS2_MENU
if (TheMemoryCard.m_bWantToLoad) if (TheMemoryCard.m_bWantToLoad)
LoadSplash(GetLevelSplashScreen(CGame::currLevel)); LoadSplash(GetLevelSplashScreen(CGame::currLevel));
@ -1043,13 +1004,18 @@ main(int argc, char *argv[])
while( !RsGlobal.quit && !FrontEndMenuManager.m_bWantToRestart && WHBProcIsRunning()) while( !RsGlobal.quit && !FrontEndMenuManager.m_bWantToRestart && WHBProcIsRunning())
#endif #endif
{ {
if( ForegroundApp ) #ifndef MASTER
if (gbModelViewer) {
// This is TheModelViewerCore in LCS, but TheModelViewer on other state-machine III-VCs.
TheModelViewer();
} else
#endif
if ( ForegroundApp )
{ {
switch ( gGameState ) switch ( gGameState )
{ {
case GS_START_UP: case GS_START_UP:
{ {
WHBLogPrintf("GS_START_UP");
#ifdef NO_MOVIES #ifdef NO_MOVIES
gGameState = GS_INIT_ONCE; gGameState = GS_INIT_ONCE;
#else #else
@ -1059,23 +1025,21 @@ main(int argc, char *argv[])
break; break;
} }
case GS_INIT_LOGO_MPEG: case GS_INIT_LOGO_MPEG:
{ {
WHBLogPrintf("GS_INIT_LOGO_MPEG"); //if (!startupDeactivate)
//if (!startupDeactivate)
// PlayMovieInWindow(cmdShow, "movies\\Logo.mpg"); // PlayMovieInWindow(cmdShow, "movies\\Logo.mpg");
gGameState = GS_LOGO_MPEG; gGameState = GS_LOGO_MPEG;
TRACE("gGameState = GS_LOGO_MPEG;"); TRACE("gGameState = GS_LOGO_MPEG;");
break; break;
} }
case GS_LOGO_MPEG: case GS_LOGO_MPEG:
{ {
WHBLogPrintf("GS_LOGO_MPEG");
// CPad::UpdatePads(); // CPad::UpdatePads();
// if (startupDeactivate || ControlsManager.GetJoyButtonJustDown() != 0) // if (startupDeactivate || ControlsManager.GetJoyButtonJustDown() != 0)
++gGameState; ++gGameState;
// else if (CPad::GetPad(0)->GetLeftMouseJustDown()) // else if (CPad::GetPad(0)->GetLeftMouseJustDown())
// ++gGameState; // ++gGameState;
// else if (CPad::GetPad(0)->GetEnterJustDown()) // else if (CPad::GetPad(0)->GetEnterJustDown())
@ -1087,12 +1051,11 @@ main(int argc, char *argv[])
// else if (CPad::GetPad(0)->GetTabJustDown()) // else if (CPad::GetPad(0)->GetTabJustDown())
// ++gGameState; // ++gGameState;
break; break;
} }
case GS_INIT_INTRO_MPEG: case GS_INIT_INTRO_MPEG:
{ {
WHBLogPrintf("GS_INIT_INTRO_MPEG");
//#ifndef NO_MOVIES //#ifndef NO_MOVIES
// CloseClip(); // CloseClip();
// CoUninitialize(); // CoUninitialize();
@ -1103,18 +1066,17 @@ main(int argc, char *argv[])
// else // else
// PlayMovieInWindow(cmdShow, "movies\\GTAtitles.mpg"); // PlayMovieInWindow(cmdShow, "movies\\GTAtitles.mpg");
gGameState = GS_INTRO_MPEG; gGameState = GS_INTRO_MPEG;
TRACE("gGameState = GS_INTRO_MPEG;"); TRACE("gGameState = GS_INTRO_MPEG;");
break; break;
} }
case GS_INTRO_MPEG: case GS_INTRO_MPEG:
{ {
WHBLogPrintf("GS_INTRO_MPEG");
// CPad::UpdatePads(); // CPad::UpdatePads();
// //
// if (startupDeactivate || ControlsManager.GetJoyButtonJustDown() != 0) // if (startupDeactivate || ControlsManager.GetJoyButtonJustDown() != 0)
++gGameState; ++gGameState;
// else if (CPad::GetPad(0)->GetLeftMouseJustDown()) // else if (CPad::GetPad(0)->GetLeftMouseJustDown())
// ++gGameState; // ++gGameState;
// else if (CPad::GetPad(0)->GetEnterJustDown()) // else if (CPad::GetPad(0)->GetEnterJustDown())
@ -1126,12 +1088,11 @@ main(int argc, char *argv[])
// else if (CPad::GetPad(0)->GetTabJustDown()) // else if (CPad::GetPad(0)->GetTabJustDown())
// ++gGameState; // ++gGameState;
break; break;
} }
case GS_INIT_ONCE: case GS_INIT_ONCE:
{ {
WHBLogPrintf("GS_INIT_ONCE");
//CoUninitialize(); //CoUninitialize();
#ifdef PS2_MENU #ifdef PS2_MENU
@ -1143,10 +1104,8 @@ main(int argc, char *argv[])
printf("Into TheGame!!!\n"); printf("Into TheGame!!!\n");
#else #else
WHBLogPrintf("loadsc0");
LoadingScreen(nil, nil, "loadsc0"); LoadingScreen(nil, nil, "loadsc0");
#endif #endif
WHBLogPrintf("InitialiseOnceAfterRW");
if ( !CGame::InitialiseOnceAfterRW() ) if ( !CGame::InitialiseOnceAfterRW() )
RsGlobal.quit = TRUE; RsGlobal.quit = TRUE;
@ -1162,20 +1121,12 @@ main(int argc, char *argv[])
#ifndef PS2_MENU #ifndef PS2_MENU
case GS_INIT_FRONTEND: case GS_INIT_FRONTEND:
{ {
WHBLogPrintf("GS_INIT_FRONTEND");
LoadingScreen(nil, nil, "loadsc0"); LoadingScreen(nil, nil, "loadsc0");
FrontEndMenuManager.m_bGameNotLoaded = true; FrontEndMenuManager.m_bGameNotLoaded = true;
CMenuManager::m_bStartUpFrontEndRequested = true; CMenuManager::m_bStartUpFrontEndRequested = true;
// TODO: wiiu
// if ( defaultFullscreenRes )
// {
// defaultFullscreenRes = FALSE;
// FrontEndMenuManager.m_nPrefsVideoMode = GcurSelVM;
// FrontEndMenuManager.m_nDisplayVideoMode = GcurSelVM;
// }
gGameState = GS_FRONTEND; gGameState = GS_FRONTEND;
TRACE("gGameState = GS_FRONTEND;"); TRACE("gGameState = GS_FRONTEND;");
@ -1213,7 +1164,6 @@ main(int argc, char *argv[])
case GS_INIT_PLAYING_GAME: case GS_INIT_PLAYING_GAME:
{ {
WHBLogPrintf("GS_INIT_PLAYING_GAME");
#ifdef PS2_MENU #ifdef PS2_MENU
CGame::Initialise("DATA\\GTA3.DAT"); CGame::Initialise("DATA\\GTA3.DAT");
@ -1248,7 +1198,6 @@ main(int argc, char *argv[])
case GS_PLAYING_GAME: case GS_PLAYING_GAME:
{ {
WHBLogPrintf("GS_PLAYING_GAME");
float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond(); float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();
if ( RwInitialised ) if ( RwInitialised )
{ {
@ -1257,19 +1206,6 @@ main(int argc, char *argv[])
} }
break; break;
} }
#ifndef MASTER
case GS_ANIMVIEWER:
{
WHBLogPrintf("GS_ANIMVIEWER");
float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();
if (RwInitialised)
{
if (!CMenuManager::m_PrefsFrameLimiter || (1000.0f / (float)RsGlobal.maxFPS) < ms)
RsEventHandler(rsANIMVIEWER, (void*)TRUE);
}
break;
}
#endif
} }
} }
else else
@ -1344,9 +1280,12 @@ main(int argc, char *argv[])
if ( gGameState == GS_PLAYING_GAME ) if ( gGameState == GS_PLAYING_GAME )
CGame::ShutDown(); CGame::ShutDown();
#ifndef MASTER #ifndef MASTER
else if ( gGameState == GS_ANIMVIEWER ) if ( gbModelViewer )
CAnimViewer::Shutdown(); CAnimViewer::Shutdown();
else
#endif #endif
if ( gGameState == GS_PLAYING_GAME )
CGame::ShutDown();
CTimer::Stop(); CTimer::Stop();
@ -1371,9 +1310,12 @@ main(int argc, char *argv[])
if ( gGameState == GS_PLAYING_GAME ) if ( gGameState == GS_PLAYING_GAME )
CGame::ShutDown(); CGame::ShutDown();
#ifndef MASTER #ifndef MASTER
else if ( gGameState == GS_ANIMVIEWER ) if ( gbModelViewer )
CAnimViewer::Shutdown(); CAnimViewer::Shutdown();
else
#endif #endif
if ( gGameState == GS_PLAYING_GAME )
CGame::ShutDown();
DMAudio.Terminate(); DMAudio.Terminate();
@ -1390,8 +1332,8 @@ main(int argc, char *argv[])
*/ */
RsEventHandler(rsTERMINATE, nil); RsEventHandler(rsTERMINATE, nil);
WHBUnmountSdCard(); WHBUnmountSdCard();
WHBProcShutdown(); WHBProcShutdown();
return 0; return 0;
} }