mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-12-02 05:54:14 +01:00
Crossplatform work continues
This commit is contained in:
parent
6571715cb2
commit
c80403a2e0
@ -1,4 +1,3 @@
|
|||||||
#define WITHWINDOWS // just for VK_SPACE
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include "General.h"
|
#include "General.h"
|
||||||
@ -416,7 +415,7 @@ CCutsceneMgr::Update(void)
|
|||||||
|| (CGame::playingIntro && CPad::GetPad(0)->GetStartJustDown())
|
|| (CGame::playingIntro && CPad::GetPad(0)->GetStartJustDown())
|
||||||
|| CPad::GetPad(0)->GetLeftMouseJustDown()
|
|| CPad::GetPad(0)->GetLeftMouseJustDown()
|
||||||
|| CPad::GetPad(0)->GetEnterJustDown()
|
|| CPad::GetPad(0)->GetEnterJustDown()
|
||||||
|| CPad::GetPad(0)->GetCharJustDown(VK_SPACE))
|
|| CPad::GetPad(0)->GetCharJustDown(' '))
|
||||||
FinishCutscene();
|
FinishCutscene();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "sampman.h"
|
#include "sampman.h"
|
||||||
#include "AudioManager.h"
|
#include "AudioManager.h"
|
||||||
#include "MusicManager.h"
|
#include "MusicManager.h"
|
||||||
#include "Frontend.h"
|
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#define WITHWINDOWS // for our script loading hack
|
#define WITHWINDOWS // for our script loading hack
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
|
||||||
#include "Script.h"
|
#include "Script.h"
|
||||||
#include "ScriptCommands.h"
|
#include "ScriptCommands.h"
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <windows.h>
|
#define WITHWINDOWS
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include "CdStream.h"
|
#include "CdStream.h"
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#pragma warning( push )
|
#pragma warning( push )
|
||||||
#pragma warning( disable : 4005)
|
#pragma warning( disable : 4005)
|
||||||
#define DIRECTINPUT_VERSION 0x0800
|
|
||||||
#include <dinput.h>
|
|
||||||
#pragma warning( pop )
|
#pragma warning( pop )
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "win.h"
|
#include "win.h"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <windows.h>
|
#define WITHWINDOWS
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include "DMAudio.h"
|
#include "DMAudio.h"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
#include <windows.h>
|
#define WITHWINDOWS
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "patcher.h"
|
#include "patcher.h"
|
||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
#pragma warning( push )
|
#pragma warning( push )
|
||||||
#pragma warning( disable : 4005)
|
#pragma warning( disable : 4005)
|
||||||
#define DIRECTINPUT_VERSION 0x0800
|
|
||||||
#include <dinput.h>
|
|
||||||
#pragma warning( pop )
|
#pragma warning( pop )
|
||||||
#define WITHWINDOWS
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "win.h"
|
#include "win.h"
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#define WITHWINDOWS
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#define USEALTERNATIVEWINFUNCS
|
||||||
|
#include "crossplatform.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#include "AudioScriptObject.h"
|
#include "AudioScriptObject.h"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#define WITHWINDOWS
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#define USEALTERNATIVEWINFUNCS
|
||||||
|
#include "crossplatform.h"
|
||||||
|
|
||||||
#include "FileMgr.h"
|
#include "FileMgr.h"
|
||||||
#include "GenericGameStorage.h"
|
#include "GenericGameStorage.h"
|
||||||
@ -94,7 +95,7 @@ C_PcSave::PopulateSlotInfo()
|
|||||||
struct {
|
struct {
|
||||||
int size;
|
int size;
|
||||||
wchar FileName[24];
|
wchar FileName[24];
|
||||||
_SYSTEMTIME SaveDateTime;
|
SYSTEMTIME SaveDateTime;
|
||||||
} header;
|
} header;
|
||||||
sprintf(savename, "%s%i%s", DefaultPCSaveFileName, i + 1, ".b");
|
sprintf(savename, "%s%i%s", DefaultPCSaveFileName, i + 1, ".b");
|
||||||
int file = CFileMgr::OpenFile(savename, "rb");
|
int file = CFileMgr::OpenFile(savename, "rb");
|
||||||
@ -110,8 +111,8 @@ C_PcSave::PopulateSlotInfo()
|
|||||||
}
|
}
|
||||||
if (Slots[i + 1] == SLOT_OK) {
|
if (Slots[i + 1] == SLOT_OK) {
|
||||||
if (CheckDataNotCorrupt(i, savename)) {
|
if (CheckDataNotCorrupt(i, savename)) {
|
||||||
_SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
memcpy(&st, &header.SaveDateTime, sizeof(_SYSTEMTIME));
|
memcpy(&st, &header.SaveDateTime, sizeof(SYSTEMTIME));
|
||||||
const char *month;
|
const char *month;
|
||||||
switch (st.wMonth)
|
switch (st.wMonth)
|
||||||
{
|
{
|
||||||
|
81
src/skel/crossplatform.cpp
Normal file
81
src/skel/crossplatform.cpp
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
#include "common.h"
|
||||||
|
#define USEALTERNATIVEWINFUNCS
|
||||||
|
#include "crossplatform.h"
|
||||||
|
|
||||||
|
// For internal use
|
||||||
|
// wMilliseconds is not needed
|
||||||
|
void tmToSystemTime(const tm *tm, SYSTEMTIME *out) {
|
||||||
|
out->wYear = tm->tm_year + 1900;
|
||||||
|
out->wMonth = tm->tm_mon + 1;
|
||||||
|
out->wDayOfWeek = tm->tm_wday;
|
||||||
|
out->wDay = tm->tm_mday;
|
||||||
|
out->wHour = tm->tm_hour;
|
||||||
|
out->wMinute = tm->tm_min;
|
||||||
|
out->wSecond = tm->tm_sec;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetLocalTime_CP(SYSTEMTIME *out) {
|
||||||
|
time_t timestamp = time(nil);
|
||||||
|
tm *localTm = localtime(×tamp);
|
||||||
|
tmToSystemTime(localTm, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined _WIN32 || defined __MINGW32__
|
||||||
|
HANDLE FindFirstFile(const char* pathname, WIN32_FIND_DATA* firstfile) {
|
||||||
|
char newpathname[32];
|
||||||
|
strncpy(newpathname, pathname, 32);
|
||||||
|
char* path = strtok(newpathname, "\\*");
|
||||||
|
strncpy(firstfile->folder, path, sizeof(firstfile->folder));
|
||||||
|
|
||||||
|
// Both w/ extension and w/o extension is ok
|
||||||
|
if (strlen(path) + 2 != strlen(pathname))
|
||||||
|
strncpy(firstfile->extension, strtok(NULL, "\\*"), sizeof(firstfile->extension));
|
||||||
|
else
|
||||||
|
strncpy(firstfile->extension, "", sizeof(firstfile->extension));
|
||||||
|
|
||||||
|
HANDLE d;
|
||||||
|
if ((d = opendir(path)) == NULL || !FindNextFile(d, firstfile))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FindNextFile(HANDLE d, WIN32_FIND_DATA* finddata) {
|
||||||
|
dirent *file;
|
||||||
|
static struct stat fileStats;
|
||||||
|
static char path[PATH_MAX], relativepath[NAME_MAX + sizeof(finddata->folder) + 1];
|
||||||
|
int extensionLen = strlen(finddata->extension);
|
||||||
|
while ((file = readdir(d)) != NULL) {
|
||||||
|
|
||||||
|
// We only want "DT_REG"ular Files, but reportedly some FS and OSes gives DT_UNKNOWN as type.
|
||||||
|
if ((file->d_type == DT_UNKNOWN || file->d_type == DT_REG) &&
|
||||||
|
(extensionLen == 0 || strncmp(&file->d_name[strlen(file->d_name) - extensionLen], finddata->extension, extensionLen) == 0)) {
|
||||||
|
|
||||||
|
sprintf(relativepath, "%s/%s", finddata->folder, file->d_name);
|
||||||
|
realpath(relativepath, path);
|
||||||
|
stat(path, &fileStats);
|
||||||
|
strncpy(finddata->cFileName, file->d_name, sizeof(finddata->cFileName));
|
||||||
|
finddata->ftLastWriteTime = fileStats.st_mtime;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetDateFormat(int unused1, int unused2, SYSTEMTIME* in, int unused3, char* out, int size) {
|
||||||
|
tm linuxTime;
|
||||||
|
linuxTime.tm_year = in->wYear - 1900;
|
||||||
|
linuxTime.tm_mon = in->wMonth - 1;
|
||||||
|
linuxTime.tm_wday = in->wDayOfWeek;
|
||||||
|
linuxTime.tm_mday = in->wDay;
|
||||||
|
linuxTime.tm_hour = in->wHour;
|
||||||
|
linuxTime.tm_min = in->wMinute;
|
||||||
|
linuxTime.tm_sec = in->wSecond;
|
||||||
|
strftime(out, size, nl_langinfo(D_FMT), &linuxTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileTimeToSystemTime(time_t* writeTime, SYSTEMTIME* out) {
|
||||||
|
tm *ptm = gmtime(writeTime);
|
||||||
|
tmToSystemTime(ptm, out);
|
||||||
|
}
|
||||||
|
#endif
|
65
src/skel/crossplatform.h
Normal file
65
src/skel/crossplatform.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#ifndef MAX_PATH
|
||||||
|
#if !defined _WIN32 || defined __MINGW32__
|
||||||
|
#define MAX_PATH PATH_MAX
|
||||||
|
#else
|
||||||
|
#define MAX_PATH 260
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Mostly wrappers around Windows functions
|
||||||
|
|
||||||
|
// TODO: Remove USEALTERNATIVEWINFUNCS and don't use it anywhere when re3 becomes fully cross-platform, this is for testing
|
||||||
|
// Codes compatible with Windows and Linux
|
||||||
|
#if defined USEALTERNATIVEWINFUNCS || !defined _WIN32 || defined __MINGW32__
|
||||||
|
#define DeleteFile unlink
|
||||||
|
|
||||||
|
// Needed for save games
|
||||||
|
struct SYSTEMTIME {
|
||||||
|
uint16 wYear;
|
||||||
|
uint16 wMonth;
|
||||||
|
uint16 wDayOfWeek;
|
||||||
|
uint16 wDay;
|
||||||
|
uint16 wHour;
|
||||||
|
uint16 wMinute;
|
||||||
|
uint16 wSecond;
|
||||||
|
uint16 wMilliseconds;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define GetLocalTime GetLocalTime_CP
|
||||||
|
#else
|
||||||
|
#include <Windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void GetLocalTime_CP(SYSTEMTIME* out);
|
||||||
|
|
||||||
|
|
||||||
|
// Only runs on GNU/POSIX/etc.
|
||||||
|
#if !defined _WIN32 || defined __MINGW32__
|
||||||
|
#define OutputDebugString(s) re3_debug("[DBG-2]: " s "\n")
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <langinfo.h>
|
||||||
|
|
||||||
|
typedef DIR* HANDLE;
|
||||||
|
#define INVALID_HANDLE_VALUE NULL
|
||||||
|
#define FindClose closedir
|
||||||
|
#define LOCALE_USER_DEFAULT 0
|
||||||
|
#define DATE_SHORTDATE 0
|
||||||
|
|
||||||
|
struct WIN32_FIND_DATA {
|
||||||
|
char extension[32]; // for searching
|
||||||
|
char folder[32]; // for searching
|
||||||
|
char cFileName[256]; // because tSkinInfo has it 256
|
||||||
|
time_t ftLastWriteTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
HANDLE FindFirstFile(char*, WIN32_FIND_DATA*);
|
||||||
|
bool FindNextFile(HANDLE, WIN32_FIND_DATA*);
|
||||||
|
void FileTimeToSystemTime(time_t*, SYSTEMTIME*);
|
||||||
|
void GetDateFormat(int, int, SYSTEMTIME*, int, char*, int);
|
||||||
|
#endif
|
@ -2,18 +2,12 @@
|
|||||||
#include "skeleton.h"
|
#include "skeleton.h"
|
||||||
#include "events.h"
|
#include "events.h"
|
||||||
|
|
||||||
//#include "main.h"
|
|
||||||
#define DIRECTINPUT_VERSION 0x0800
|
|
||||||
#include <dinput.h>
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "Pad.h"
|
#include "Pad.h"
|
||||||
#include "ControllerConfig.h"
|
#include "ControllerConfig.h"
|
||||||
#include "Frontend.h"
|
#include "Frontend.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
@ -1986,7 +1986,7 @@ WinMain(HINSTANCE instance,
|
|||||||
++gGameState;
|
++gGameState;
|
||||||
else if ( CPad::GetPad(0)->GetEnterJustDown() )
|
else if ( CPad::GetPad(0)->GetEnterJustDown() )
|
||||||
++gGameState;
|
++gGameState;
|
||||||
else if ( CPad::GetPad(0)->GetCharJustDown(VK_SPACE) )
|
else if ( CPad::GetPad(0)->GetCharJustDown(' ') )
|
||||||
++gGameState;
|
++gGameState;
|
||||||
else if ( CPad::GetPad(0)->GetAltJustDown() )
|
else if ( CPad::GetPad(0)->GetAltJustDown() )
|
||||||
++gGameState;
|
++gGameState;
|
||||||
@ -2022,7 +2022,7 @@ WinMain(HINSTANCE instance,
|
|||||||
++gGameState;
|
++gGameState;
|
||||||
else if ( CPad::GetPad(0)->GetEnterJustDown() )
|
else if ( CPad::GetPad(0)->GetEnterJustDown() )
|
||||||
++gGameState;
|
++gGameState;
|
||||||
else if ( CPad::GetPad(0)->GetCharJustDown(VK_SPACE) )
|
else if ( CPad::GetPad(0)->GetCharJustDown(' ') )
|
||||||
++gGameState;
|
++gGameState;
|
||||||
else if ( CPad::GetPad(0)->GetAltJustDown() )
|
else if ( CPad::GetPad(0)->GetAltJustDown() )
|
||||||
++gGameState;
|
++gGameState;
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
#define RSREGSETBREAKALLOC(_name) /* No op */
|
#define RSREGSETBREAKALLOC(_name) /* No op */
|
||||||
#endif /* (!defined(RSREGSETBREAKALLOC)) */
|
#endif /* (!defined(RSREGSETBREAKALLOC)) */
|
||||||
|
|
||||||
|
#ifndef _INC_WINDOWS
|
||||||
|
#define _X86_
|
||||||
|
#include <windef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
enum eGameState
|
enum eGameState
|
||||||
{
|
{
|
||||||
GS_START_UP = 0,
|
GS_START_UP = 0,
|
||||||
@ -17,7 +22,9 @@ enum eGameState
|
|||||||
GS_FRONTEND,
|
GS_FRONTEND,
|
||||||
GS_INIT_PLAYING_GAME,
|
GS_INIT_PLAYING_GAME,
|
||||||
GS_PLAYING_GAME,
|
GS_PLAYING_GAME,
|
||||||
|
#ifndef MASTER
|
||||||
GS_ANIMVIEWER,
|
GS_ANIMVIEWER,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
enum eWinVersion
|
enum eWinVersion
|
||||||
@ -33,6 +40,7 @@ extern DWORD _dwOperatingSystemVersion;
|
|||||||
|
|
||||||
extern RwUInt32 gGameState;
|
extern RwUInt32 gGameState;
|
||||||
|
|
||||||
|
#ifdef __DINPUT_INCLUDED__
|
||||||
/* platform specfic global data */
|
/* platform specfic global data */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -86,6 +94,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern CJoySticks AllValidWinJoys;
|
extern CJoySticks AllValidWinJoys;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
@ -97,6 +106,7 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam);
|
|||||||
|
|
||||||
RwBool IsForegroundApp();
|
RwBool IsForegroundApp();
|
||||||
|
|
||||||
|
#ifdef __DINPUT_INCLUDED__
|
||||||
HRESULT _InputInitialise();
|
HRESULT _InputInitialise();
|
||||||
HRESULT _InputInitialiseMouse();
|
HRESULT _InputInitialiseMouse();
|
||||||
HRESULT CapturePad(RwInt32 padID);
|
HRESULT CapturePad(RwInt32 padID);
|
||||||
@ -110,6 +120,7 @@ BOOL _InputTranslateKey(RsKeyCodes *rs, UINT flag, UINT key);
|
|||||||
void _InputTranslateShiftKeyUpDown(RsKeyCodes *rs);;
|
void _InputTranslateShiftKeyUpDown(RsKeyCodes *rs);;
|
||||||
BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, BOOLEAN bDown);
|
BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, BOOLEAN bDown);
|
||||||
BOOL _InputIsExtended(INT flag);
|
BOOL _InputIsExtended(INT flag);
|
||||||
|
#endif
|
||||||
|
|
||||||
void InitialiseLanguage();
|
void InitialiseLanguage();
|
||||||
RwBool _psSetVideoMode(RwInt32 subSystem, RwInt32 videoMode);
|
RwBool _psSetVideoMode(RwInt32 subSystem, RwInt32 videoMode);
|
||||||
|
Loading…
Reference in New Issue
Block a user