mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-11 08:36:38 -04:00
Move common platform console to _PlatformConsole.h
This commit is contained in:
parent
b5acd75c3e
commit
ffee69ffa1
@ -441,6 +441,7 @@
|
|||||||
<ClInclude Include="_GraphicsBase.h" />
|
<ClInclude Include="_GraphicsBase.h" />
|
||||||
<ClInclude Include="_HttpBase.h" />
|
<ClInclude Include="_HttpBase.h" />
|
||||||
<ClInclude Include="_PlatformBase.h" />
|
<ClInclude Include="_PlatformBase.h" />
|
||||||
|
<ClInclude Include="_PlatformConsole.h" />
|
||||||
<ClInclude Include="_WindowBase.h" />
|
<ClInclude Include="_WindowBase.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -339,6 +339,9 @@
|
|||||||
<ClInclude Include="SSL.h">
|
<ClInclude Include="SSL.h">
|
||||||
<Filter>Header Files\Network</Filter>
|
<Filter>Header Files\Network</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="_PlatformConsole.h">
|
||||||
|
<Filter>Header Files\Platform</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="String.c">
|
<ClCompile Include="String.c">
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#if defined CC_BUILD_3DS
|
#if defined CC_BUILD_3DS
|
||||||
|
|
||||||
#include "_PlatformBase.h"
|
#include "_PlatformBase.h"
|
||||||
#include "Stream.h"
|
#include "Stream.h"
|
||||||
#include "ExtMath.h"
|
#include "ExtMath.h"
|
||||||
@ -9,6 +8,7 @@
|
|||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
#include "PackedCol.h"
|
#include "PackedCol.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -27,6 +27,7 @@
|
|||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
#include <citro3d.h>
|
#include <citro3d.h>
|
||||||
|
#include "_PlatformConsole.h"
|
||||||
|
|
||||||
#define US_PER_SEC 1000000LL
|
#define US_PER_SEC 1000000LL
|
||||||
#define NS_PER_MS 1000000LL
|
#define NS_PER_MS 1000000LL
|
||||||
@ -43,31 +44,6 @@ const char* Platform_AppNameSuffix = " 3DS";
|
|||||||
unsigned int __stacksize__ = 256 * 1024;
|
unsigned int __stacksize__ = 256 * 1024;
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*---------------------------------------------------------Memory----------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
void Mem_Set(void* dst, cc_uint8 value, cc_uint32 numBytes) { memset(dst, value, numBytes); }
|
|
||||||
void Mem_Copy(void* dst, const void* src, cc_uint32 numBytes) { memcpy(dst, src, numBytes); }
|
|
||||||
|
|
||||||
void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
|
||||||
return size ? malloc(size) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* Mem_TryAllocCleared(cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
return calloc(numElems, elemsSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* Mem_TryRealloc(void* mem, cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
|
||||||
return size ? realloc(mem, size) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mem_Free(void* mem) {
|
|
||||||
if (mem) free(mem);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------Logging/Time-------------------------------------------------------*
|
*------------------------------------------------------Logging/Time-------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
@ -120,7 +96,6 @@ cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
void Directory_GetCachePath(cc_string* path) { }
|
|
||||||
static const cc_string root_path = String_FromConst("sdmc:/3ds/ClassiCube/");
|
static const cc_string root_path = String_FromConst("sdmc:/3ds/ClassiCube/");
|
||||||
|
|
||||||
static void GetNativePath(char* str, const cc_string* path) {
|
static void GetNativePath(char* str, const cc_string* path) {
|
||||||
@ -422,59 +397,10 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) {
|
|||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Process/Module------------------------------------------------------*
|
*--------------------------------------------------------Platform---------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static char gameArgs[GAME_MAX_CMDARGS][STRING_SIZE];
|
#define SOC_CTX_ALIGN 0x1000
|
||||||
static int gameNumArgs;
|
#define SOC_CTX_SIZE 0x1000 * 128
|
||||||
static cc_bool gameHasArgs;
|
|
||||||
|
|
||||||
cc_result Process_StartGame2(const cc_string* args, int numArgs) {
|
|
||||||
for (int i = 0; i < numArgs; i++)
|
|
||||||
{
|
|
||||||
String_CopyToRawArray(gameArgs[i], &args[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Platform_LogConst("START GAME");
|
|
||||||
gameHasArgs = true;
|
|
||||||
gameNumArgs = numArgs;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int GetGameArgs(cc_string* args) {
|
|
||||||
int count = gameNumArgs;
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
args[i] = String_FromRawArray(gameArgs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear arguments so after game is closed, launcher is started
|
|
||||||
gameNumArgs = 0;
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* args) {
|
|
||||||
if (gameHasArgs) return GetGameArgs(args);
|
|
||||||
// 3DS *sometimes* doesn't use argv[0] for program name and so argc will be 0
|
|
||||||
// (e.g. when running from Citra)
|
|
||||||
if (!argc) return 0;
|
|
||||||
|
|
||||||
argc--; argv++; // skip executable path argument
|
|
||||||
|
|
||||||
int count = min(argc, GAME_MAX_CMDARGS);
|
|
||||||
Platform_Log1("ARGS: %i", &count);
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
args[i] = String_FromReadonly(argv[i]);
|
|
||||||
Platform_Log2(" ARG %i = %c", &i, argv[i]);
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Process_Exit(cc_result code) { exit(code); }
|
|
||||||
|
|
||||||
cc_result Process_StartOpen(const cc_string* args) {
|
cc_result Process_StartOpen(const cc_string* args) {
|
||||||
char url[NATIVE_STR_LEN];
|
char url[NATIVE_STR_LEN];
|
||||||
@ -486,46 +412,6 @@ cc_result Process_StartOpen(const cc_string* args) {
|
|||||||
// len + 1 for null terminator
|
// len + 1 for null terminator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*--------------------------------------------------------Updater----------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
const char* const Updater_D3D9 = NULL;
|
|
||||||
cc_bool Updater_Clean(void) { return true; }
|
|
||||||
|
|
||||||
const struct UpdaterInfo Updater_Info = { "&eCompile latest source code to update", 0 };
|
|
||||||
|
|
||||||
cc_result Updater_Start(const char** action) { *action = "Starting"; return ERR_NOT_SUPPORTED; }
|
|
||||||
|
|
||||||
cc_result Updater_GetBuildTime(cc_uint64* timestamp) { return ERR_NOT_SUPPORTED; }
|
|
||||||
|
|
||||||
cc_result Updater_MarkExecutable(void) { return ERR_NOT_SUPPORTED; }
|
|
||||||
|
|
||||||
cc_result Updater_SetNewBuildTime(cc_uint64 timestamp) { return ERR_NOT_SUPPORTED; }
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*-------------------------------------------------------Dynamic lib-------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
|
|
||||||
const cc_string DynamicLib_Ext = String_FromConst(".so");
|
|
||||||
|
|
||||||
void* DynamicLib_Load2(const cc_string* path) { return NULL; }
|
|
||||||
|
|
||||||
void* DynamicLib_Get2(void* lib, const char* name) { return NULL; }
|
|
||||||
|
|
||||||
cc_bool DynamicLib_DescribeError(cc_string* dst) {
|
|
||||||
String_AppendConst(dst, "Dynamic linking unsupported");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*--------------------------------------------------------Platform---------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
#define SOC_CTX_ALIGN 0x1000
|
|
||||||
#define SOC_CTX_SIZE 0x1000 * 128
|
|
||||||
|
|
||||||
static void CreateRootDirectory(const char* path) {
|
static void CreateRootDirectory(const char* path) {
|
||||||
// create root directories (no permissions anyways)
|
// create root directories (no permissions anyways)
|
||||||
int res = mkdir(path, 0666);
|
int res = mkdir(path, 0666);
|
||||||
@ -536,8 +422,6 @@ static void CreateRootDirectory(const char* path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Platform_Init(void) {
|
void Platform_Init(void) {
|
||||||
Platform_SingleProcess = true;
|
|
||||||
|
|
||||||
// create root directories (no permissions anyways)
|
// create root directories (no permissions anyways)
|
||||||
CreateRootDirectory("sdmc:/3ds");
|
CreateRootDirectory("sdmc:/3ds");
|
||||||
CreateRootDirectory("sdmc:/3ds/ClassiCube");
|
CreateRootDirectory("sdmc:/3ds/ClassiCube");
|
||||||
@ -580,7 +464,8 @@ cc_bool Platform_DescribeError(cc_result res, cc_string* dst) {
|
|||||||
cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) {
|
cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
|
cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#if defined CC_BUILD_DREAMCAST
|
#if defined CC_BUILD_DREAMCAST
|
||||||
|
|
||||||
#include "_PlatformBase.h"
|
#include "_PlatformBase.h"
|
||||||
#include "Stream.h"
|
#include "Stream.h"
|
||||||
#include "ExtMath.h"
|
#include "ExtMath.h"
|
||||||
@ -8,6 +7,7 @@
|
|||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -18,6 +18,7 @@
|
|||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <kos.h>
|
#include <kos.h>
|
||||||
|
#include "_PlatformConsole.h"
|
||||||
|
|
||||||
const cc_result ReturnCode_FileShareViolation = 1000000000; // not used
|
const cc_result ReturnCode_FileShareViolation = 1000000000; // not used
|
||||||
const cc_result ReturnCode_FileNotFound = ENOENT;
|
const cc_result ReturnCode_FileNotFound = ENOENT;
|
||||||
@ -27,31 +28,6 @@ const cc_result ReturnCode_DirectoryExists = EEXIST;
|
|||||||
const char* Platform_AppNameSuffix = " Dreamcast";
|
const char* Platform_AppNameSuffix = " Dreamcast";
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*---------------------------------------------------------Memory----------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
void Mem_Set(void* dst, cc_uint8 value, cc_uint32 numBytes) { memset(dst, value, numBytes); }
|
|
||||||
void Mem_Copy(void* dst, const void* src, cc_uint32 numBytes) { memcpy(dst, src, numBytes); }
|
|
||||||
|
|
||||||
void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
|
||||||
return size ? malloc(size) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* Mem_TryAllocCleared(cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
return calloc(numElems, elemsSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* Mem_TryRealloc(void* mem, cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
|
||||||
return size ? realloc(mem, size) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mem_Free(void* mem) {
|
|
||||||
if (mem) free(mem);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------Logging/Time-------------------------------------------------------*
|
*------------------------------------------------------Logging/Time-------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
@ -95,13 +71,8 @@ void DateTime_CurrentLocal(struct DateTime* t) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
void Directory_GetCachePath(cc_string* path) { }
|
|
||||||
|
|
||||||
extern int __path_absolute(const char *in, char *out, int len);
|
|
||||||
static void GetNativePath(char* str, const cc_string* path) {
|
static void GetNativePath(char* str, const cc_string* path) {
|
||||||
//char tmp[NATIVE_STR_LEN + 1];
|
|
||||||
String_EncodeUtf8(str, path);
|
String_EncodeUtf8(str, path);
|
||||||
//__path_absolute(tmp, str, NATIVE_STR_LEN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(const cc_string* path) {
|
||||||
@ -437,111 +408,13 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) {
|
|||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Process/Module------------------------------------------------------*
|
*--------------------------------------------------------Platform---------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static char gameArgs[GAME_MAX_CMDARGS][STRING_SIZE];
|
|
||||||
static int gameNumArgs;
|
|
||||||
static cc_bool gameHasArgs;
|
|
||||||
|
|
||||||
cc_result Process_StartGame2(const cc_string* args, int numArgs) {
|
|
||||||
for (int i = 0; i < numArgs; i++)
|
|
||||||
{
|
|
||||||
String_CopyToRawArray(gameArgs[i], &args[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Platform_LogConst("START GAME");
|
|
||||||
gameHasArgs = true;
|
|
||||||
gameNumArgs = numArgs;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int GetGameArgs(cc_string* args) {
|
|
||||||
int count = gameNumArgs;
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
args[i] = String_FromRawArray(gameArgs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear arguments so after game is closed, launcher is started
|
|
||||||
gameNumArgs = 0;
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* args) {
|
|
||||||
if (gameHasArgs) return GetGameArgs(args);
|
|
||||||
// PSP *sometimes* doesn't use argv[0] for program name and so argc will be 0
|
|
||||||
if (!argc) return 0;
|
|
||||||
|
|
||||||
argc--; argv++; // skip executable path argument
|
|
||||||
|
|
||||||
int count = min(argc, GAME_MAX_CMDARGS);
|
|
||||||
Platform_Log1("ARGS: %i", &count);
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
args[i] = String_FromReadonly(argv[i]);
|
|
||||||
Platform_Log2(" ARG %i = %c", &i, argv[i]);
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
|
|
||||||
return 0; // TODO switch to RomFS ??
|
|
||||||
}
|
|
||||||
|
|
||||||
void Process_Exit(cc_result code) { exit(code); }
|
|
||||||
|
|
||||||
cc_result Process_StartOpen(const cc_string* args) {
|
cc_result Process_StartOpen(const cc_string* args) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*--------------------------------------------------------Updater----------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
const char* const Updater_D3D9 = NULL;
|
|
||||||
cc_bool Updater_Clean(void) { return true; }
|
|
||||||
|
|
||||||
const struct UpdaterInfo Updater_Info = { "&eCompile latest source code to update", 0 };
|
|
||||||
|
|
||||||
cc_result Updater_Start(const char** action) {
|
|
||||||
*action = "Starting game";
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Updater_GetBuildTime(cc_uint64* timestamp) {
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Updater_MarkExecutable(void) {
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Updater_SetNewBuildTime(cc_uint64 timestamp) {
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*-------------------------------------------------------Dynamic lib-------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
/* TODO can this actually be supported somehow */
|
|
||||||
const cc_string DynamicLib_Ext = String_FromConst(".so");
|
|
||||||
|
|
||||||
void* DynamicLib_Load2(const cc_string* path) { return NULL; }
|
|
||||||
void* DynamicLib_Get2(void* lib, const char* name) { return NULL; }
|
|
||||||
|
|
||||||
cc_bool DynamicLib_DescribeError(cc_string* dst) {
|
|
||||||
String_AppendConst(dst, "Dynamic linking unsupported");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*--------------------------------------------------------Platform---------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
void Platform_Init(void) {
|
void Platform_Init(void) {
|
||||||
Platform_SingleProcess = true;
|
|
||||||
/*pspDebugSioInit();*/
|
/*pspDebugSioInit();*/
|
||||||
|
|
||||||
char cwd[600] = { 0 };
|
char cwd[600] = { 0 };
|
||||||
@ -577,4 +450,4 @@ cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) {
|
|||||||
cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
|
cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
#include "PackedCol.h"
|
#include "PackedCol.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -24,6 +25,7 @@
|
|||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
#include <ogc/wiilaunch.h>
|
#include <ogc/wiilaunch.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include "_PlatformConsole.h"
|
||||||
|
|
||||||
const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */
|
const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */
|
||||||
const cc_result ReturnCode_FileNotFound = ENOENT;
|
const cc_result ReturnCode_FileNotFound = ENOENT;
|
||||||
@ -37,31 +39,6 @@ const char* Platform_AppNameSuffix = " GameCube";
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*---------------------------------------------------------Memory----------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
void Mem_Set(void* dst, cc_uint8 value, cc_uint32 numBytes) { memset(dst, value, numBytes); }
|
|
||||||
void Mem_Copy(void* dst, const void* src, cc_uint32 numBytes) { memcpy(dst, src, numBytes); }
|
|
||||||
|
|
||||||
void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
|
||||||
return size ? malloc(size) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* Mem_TryAllocCleared(cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
return calloc(numElems, elemsSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* Mem_TryRealloc(void* mem, cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
|
||||||
return size ? realloc(mem, size) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mem_Free(void* mem) {
|
|
||||||
if (mem) free(mem);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------Logging/Time-------------------------------------------------------*
|
*------------------------------------------------------Logging/Time-------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
@ -118,7 +95,6 @@ cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
void Directory_GetCachePath(cc_string* path) { }
|
|
||||||
static char root_buffer[NATIVE_STR_LEN];
|
static char root_buffer[NATIVE_STR_LEN];
|
||||||
static cc_string root_path = String_FromArray(root_buffer);
|
static cc_string root_path = String_FromArray(root_buffer);
|
||||||
|
|
||||||
@ -381,12 +357,6 @@ void Waitable_WaitFor(void* handle, cc_uint32 milliseconds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*--------------------------------------------------------Font/Text--------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
void Platform_LoadSysFonts(void) { }
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------------Socket----------------------------------------------------------*
|
*---------------------------------------------------------Socket----------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
@ -534,57 +504,8 @@ static void InitSockets(void) {
|
|||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Process/Module------------------------------------------------------*
|
*--------------------------------------------------------Platform---------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static char gameArgs[GAME_MAX_CMDARGS][STRING_SIZE];
|
|
||||||
static int gameNumArgs;
|
|
||||||
static cc_bool gameHasArgs;
|
|
||||||
cc_result Process_StartGame2(const cc_string* args, int numArgs) {
|
|
||||||
for (int i = 0; i < numArgs; i++)
|
|
||||||
{
|
|
||||||
String_CopyToRawArray(gameArgs[i], &args[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Platform_LogConst("START GAME");
|
|
||||||
gameHasArgs = true;
|
|
||||||
gameNumArgs = numArgs;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
static int GetGameArgs(cc_string* args) {
|
|
||||||
int count = gameNumArgs;
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
args[i] = String_FromRawArray(gameArgs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear arguments so after game is closed, launcher is started
|
|
||||||
gameNumArgs = 0;
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* args) {
|
|
||||||
if (gameHasArgs) return GetGameArgs(args);
|
|
||||||
// GC/WII *sometimes* doesn't use argv[0] for program name and so argc will be 0
|
|
||||||
if (!argc) return 0;
|
|
||||||
|
|
||||||
// at least The Homebrew Channel loader uses argv[0] for executable filename
|
|
||||||
// see strcpy(result->args, filename); in loader_load in loader.c
|
|
||||||
// https://github.com/fail0verflow/hbc/blob/master/channel/channelapp/source/loader.c#L912
|
|
||||||
argc--; argv++;
|
|
||||||
|
|
||||||
int count = min(argc, GAME_MAX_CMDARGS);
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
args[i] = String_FromReadonly(argv[i]);
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Process_Exit(cc_result code) { exit(code); }
|
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
cc_result Process_StartOpen(const cc_string* args) {
|
cc_result Process_StartOpen(const cc_string* args) {
|
||||||
char url[NATIVE_STR_LEN];
|
char url[NATIVE_STR_LEN];
|
||||||
@ -599,56 +520,9 @@ cc_result Process_StartOpen(const cc_string* args) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*--------------------------------------------------------Updater----------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
const char* const Updater_D3D9 = NULL;
|
|
||||||
cc_bool Updater_Clean(void) { return true; }
|
|
||||||
|
|
||||||
const struct UpdaterInfo Updater_Info = { "&eCompile latest source code to update", 0 };
|
|
||||||
|
|
||||||
cc_result Updater_Start(const char** action) {
|
|
||||||
*action = "Starting game";
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Updater_GetBuildTime(cc_uint64* timestamp) {
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Updater_MarkExecutable(void) {
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Updater_SetNewBuildTime(cc_uint64 timestamp) {
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*-------------------------------------------------------Dynamic lib-------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
/* TODO can this actually be supported somehow */
|
|
||||||
const cc_string DynamicLib_Ext = String_FromConst(".so");
|
|
||||||
|
|
||||||
void* DynamicLib_Load2(const cc_string* path) { return NULL; }
|
|
||||||
void* DynamicLib_Get2(void* lib, const char* name) { return NULL; }
|
|
||||||
|
|
||||||
cc_bool DynamicLib_DescribeError(cc_string* dst) {
|
|
||||||
String_AppendConst(dst, "Dynamic linking unsupported");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*--------------------------------------------------------Platform---------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
static void AppendDevice(cc_string* path, char* cwd) {
|
static void AppendDevice(cc_string* path, char* cwd) {
|
||||||
// try to find device FAT mounted on, otherwise default to SD card
|
// try to find device FAT mounted on, otherwise default to SD card
|
||||||
if (!cwd) {
|
if (!cwd) { String_AppendConst(path, "sd"); return; }
|
||||||
String_AppendConst(path, "sd"); return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Platform_Log1("CWD: %c", cwd);
|
Platform_Log1("CWD: %c", cwd);
|
||||||
cc_string cwd_ = String_FromReadonly(cwd);
|
cc_string cwd_ = String_FromReadonly(cwd);
|
||||||
@ -682,8 +556,6 @@ static void CreateRootDirectory(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Platform_Init(void) {
|
void Platform_Init(void) {
|
||||||
Platform_SingleProcess = true;
|
|
||||||
|
|
||||||
fat_available = fatInitDefault();
|
fat_available = fatInitDefault();
|
||||||
FindRootDirectory();
|
FindRootDirectory();
|
||||||
CreateRootDirectory();
|
CreateRootDirectory();
|
||||||
@ -716,7 +588,8 @@ cc_bool Platform_DescribeError(cc_result res, cc_string* dst) {
|
|||||||
cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) {
|
cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
|
cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#if defined CC_BUILD_PSP
|
#if defined CC_BUILD_PSP
|
||||||
|
|
||||||
#include "_PlatformBase.h"
|
#include "_PlatformBase.h"
|
||||||
#include "Stream.h"
|
#include "Stream.h"
|
||||||
#include "ExtMath.h"
|
#include "ExtMath.h"
|
||||||
@ -8,6 +7,7 @@
|
|||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -16,6 +16,7 @@
|
|||||||
#include <pspnet_inet.h>
|
#include <pspnet_inet.h>
|
||||||
#include <pspnet_resolver.h>
|
#include <pspnet_resolver.h>
|
||||||
#include <psprtc.h>
|
#include <psprtc.h>
|
||||||
|
#include "_PlatformConsole.h"
|
||||||
|
|
||||||
const cc_result ReturnCode_FileShareViolation = 1000000000; // not used
|
const cc_result ReturnCode_FileShareViolation = 1000000000; // not used
|
||||||
const cc_result ReturnCode_FileNotFound = ENOENT;
|
const cc_result ReturnCode_FileNotFound = ENOENT;
|
||||||
@ -30,31 +31,6 @@ PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
|
|||||||
PSP_DISABLE_AUTOSTART_PTHREAD() // reduces .elf size by 140 kb
|
PSP_DISABLE_AUTOSTART_PTHREAD() // reduces .elf size by 140 kb
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*---------------------------------------------------------Memory----------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
void Mem_Set(void* dst, cc_uint8 value, cc_uint32 numBytes) { memset(dst, value, numBytes); }
|
|
||||||
void Mem_Copy(void* dst, const void* src, cc_uint32 numBytes) { memcpy(dst, src, numBytes); }
|
|
||||||
|
|
||||||
void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
|
||||||
return size ? malloc(size) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* Mem_TryAllocCleared(cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
return calloc(numElems, elemsSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* Mem_TryRealloc(void* mem, cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
|
||||||
return size ? realloc(mem, size) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mem_Free(void* mem) {
|
|
||||||
if (mem) free(mem);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------Logging/Time-------------------------------------------------------*
|
*------------------------------------------------------Logging/Time-------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
@ -106,8 +82,6 @@ cc_uint64 Stopwatch_Measure(void) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
void Directory_GetCachePath(cc_string* path) { }
|
|
||||||
|
|
||||||
extern int __path_absolute(const char *in, char *out, int len);
|
extern int __path_absolute(const char *in, char *out, int len);
|
||||||
static void GetNativePath(char* str, const cc_string* path) {
|
static void GetNativePath(char* str, const cc_string* path) {
|
||||||
char tmp[NATIVE_STR_LEN + 1];
|
char tmp[NATIVE_STR_LEN + 1];
|
||||||
@ -430,111 +404,13 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) {
|
|||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Process/Module------------------------------------------------------*
|
*--------------------------------------------------------Platform---------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static char gameArgs[GAME_MAX_CMDARGS][STRING_SIZE];
|
|
||||||
static int gameNumArgs;
|
|
||||||
static cc_bool gameHasArgs;
|
|
||||||
|
|
||||||
cc_result Process_StartGame2(const cc_string* args, int numArgs) {
|
|
||||||
for (int i = 0; i < numArgs; i++)
|
|
||||||
{
|
|
||||||
String_CopyToRawArray(gameArgs[i], &args[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Platform_LogConst("START GAME");
|
|
||||||
gameHasArgs = true;
|
|
||||||
gameNumArgs = numArgs;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int GetGameArgs(cc_string* args) {
|
|
||||||
int count = gameNumArgs;
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
args[i] = String_FromRawArray(gameArgs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear arguments so after game is closed, launcher is started
|
|
||||||
gameNumArgs = 0;
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* args) {
|
|
||||||
if (gameHasArgs) return GetGameArgs(args);
|
|
||||||
// PSP *sometimes* doesn't use argv[0] for program name and so argc will be 0
|
|
||||||
if (!argc) return 0;
|
|
||||||
|
|
||||||
argc--; argv++; // skip executable path argument
|
|
||||||
|
|
||||||
int count = min(argc, GAME_MAX_CMDARGS);
|
|
||||||
Platform_Log1("ARGS: %i", &count);
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
args[i] = String_FromReadonly(argv[i]);
|
|
||||||
Platform_Log2(" ARG %i = %c", &i, argv[i]);
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
|
|
||||||
return 0; // TODO switch to RomFS ??
|
|
||||||
}
|
|
||||||
|
|
||||||
void Process_Exit(cc_result code) { exit(code); }
|
|
||||||
|
|
||||||
cc_result Process_StartOpen(const cc_string* args) {
|
cc_result Process_StartOpen(const cc_string* args) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*--------------------------------------------------------Updater----------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
const char* const Updater_D3D9 = NULL;
|
|
||||||
cc_bool Updater_Clean(void) { return true; }
|
|
||||||
|
|
||||||
const struct UpdaterInfo Updater_Info = { "&eCompile latest source code to update", 0 };
|
|
||||||
|
|
||||||
cc_result Updater_Start(const char** action) {
|
|
||||||
*action = "Starting game";
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Updater_GetBuildTime(cc_uint64* timestamp) {
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Updater_MarkExecutable(void) {
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Updater_SetNewBuildTime(cc_uint64 timestamp) {
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*-------------------------------------------------------Dynamic lib-------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
/* TODO can this actually be supported somehow */
|
|
||||||
const cc_string DynamicLib_Ext = String_FromConst(".so");
|
|
||||||
|
|
||||||
void* DynamicLib_Load2(const cc_string* path) { return NULL; }
|
|
||||||
void* DynamicLib_Get2(void* lib, const char* name) { return NULL; }
|
|
||||||
|
|
||||||
cc_bool DynamicLib_DescribeError(cc_string* dst) {
|
|
||||||
String_AppendConst(dst, "Dynamic linking unsupported");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*--------------------------------------------------------Platform---------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
void Platform_Init(void) {
|
void Platform_Init(void) {
|
||||||
Platform_SingleProcess = true;
|
|
||||||
/*pspDebugSioInit();*/
|
/*pspDebugSioInit();*/
|
||||||
}
|
}
|
||||||
void Platform_Free(void) { }
|
void Platform_Free(void) { }
|
||||||
@ -563,6 +439,7 @@ cc_bool Platform_DescribeError(cc_result res, cc_string* dst) {
|
|||||||
cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) {
|
cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
|
cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "Core.h"
|
#include "Core.h"
|
||||||
#if defined CC_BUILD_PSVITA
|
#if defined CC_BUILD_PSVITA
|
||||||
|
|
||||||
#include "_PlatformBase.h"
|
#include "_PlatformBase.h"
|
||||||
#include "Stream.h"
|
#include "Stream.h"
|
||||||
#include "ExtMath.h"
|
#include "ExtMath.h"
|
||||||
@ -8,10 +7,12 @@
|
|||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <vitasdk.h>
|
#include <vitasdk.h>
|
||||||
|
#include "_PlatformConsole.h"
|
||||||
|
|
||||||
const cc_result ReturnCode_FileShareViolation = 1000000000; // not used
|
const cc_result ReturnCode_FileShareViolation = 1000000000; // not used
|
||||||
const cc_result ReturnCode_FileNotFound = ENOENT;
|
const cc_result ReturnCode_FileNotFound = ENOENT;
|
||||||
@ -22,31 +23,6 @@ const char* Platform_AppNameSuffix = " PS Vita";
|
|||||||
static int epoll_id;
|
static int epoll_id;
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*---------------------------------------------------------Memory----------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
void Mem_Set(void* dst, cc_uint8 value, cc_uint32 numBytes) { memset(dst, value, numBytes); }
|
|
||||||
void Mem_Copy(void* dst, const void* src, cc_uint32 numBytes) { memcpy(dst, src, numBytes); }
|
|
||||||
|
|
||||||
void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
|
||||||
return size ? malloc(size) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* Mem_TryAllocCleared(cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
return calloc(numElems, elemsSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* Mem_TryRealloc(void* mem, cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
|
||||||
return size ? realloc(mem, size) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mem_Free(void* mem) {
|
|
||||||
if (mem) free(mem);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------Logging/Time-------------------------------------------------------*
|
*------------------------------------------------------Logging/Time-------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
@ -98,13 +74,11 @@ cc_uint64 Stopwatch_Measure(void) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
void Directory_GetCachePath(cc_string* path) { }
|
static const cc_string root_path = String_FromConst("ux0:data/ClassiCube/");
|
||||||
|
|
||||||
extern int __path_absolute(const char *in, char *out, int len);
|
|
||||||
static void GetNativePath(char* str, const cc_string* path) {
|
static void GetNativePath(char* str, const cc_string* path) {
|
||||||
static const char root_path[20] = "ux0:data/ClassiCube/";
|
Mem_Copy(str, root_path.buffer, root_path.length);
|
||||||
Mem_Copy(str, root_path, sizeof(root_path));
|
str += root_path.length;
|
||||||
str += sizeof(root_path);
|
|
||||||
String_EncodeUtf8(str, path);
|
String_EncodeUtf8(str, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,111 +390,13 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) {
|
|||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Process/Module------------------------------------------------------*
|
*--------------------------------------------------------Platform---------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static char gameArgs[GAME_MAX_CMDARGS][STRING_SIZE];
|
|
||||||
static int gameNumArgs;
|
|
||||||
static cc_bool gameHasArgs;
|
|
||||||
|
|
||||||
cc_result Process_StartGame2(const cc_string* args, int numArgs) {
|
|
||||||
for (int i = 0; i < numArgs; i++)
|
|
||||||
{
|
|
||||||
String_CopyToRawArray(gameArgs[i], &args[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Platform_LogConst("START GAME");
|
|
||||||
gameHasArgs = true;
|
|
||||||
gameNumArgs = numArgs;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int GetGameArgs(cc_string* args) {
|
|
||||||
int count = gameNumArgs;
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
args[i] = String_FromRawArray(gameArgs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear arguments so after game is closed, launcher is started
|
|
||||||
gameNumArgs = 0;
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* args) {
|
|
||||||
if (gameHasArgs) return GetGameArgs(args);
|
|
||||||
// PS VITA *sometimes* doesn't use argv[0] for program name and so argc will be 0
|
|
||||||
if (!argc) return 0;
|
|
||||||
|
|
||||||
argc--; argv++; // skip executable path argument
|
|
||||||
|
|
||||||
int count = min(argc, GAME_MAX_CMDARGS);
|
|
||||||
Platform_Log1("ARGS: %i", &count);
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
args[i] = String_FromReadonly(argv[i]);
|
|
||||||
Platform_Log2(" ARG %i = %c", &i, argv[i]);
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
|
|
||||||
return 0; // TODO switch to RomFS ??
|
|
||||||
}
|
|
||||||
|
|
||||||
void Process_Exit(cc_result code) { exit(code); }
|
|
||||||
|
|
||||||
cc_result Process_StartOpen(const cc_string* args) {
|
cc_result Process_StartOpen(const cc_string* args) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*--------------------------------------------------------Updater----------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
const char* const Updater_D3D9 = NULL;
|
|
||||||
cc_bool Updater_Clean(void) { return true; }
|
|
||||||
|
|
||||||
const struct UpdaterInfo Updater_Info = { "&eCompile latest source code to update", 0 };
|
|
||||||
|
|
||||||
cc_result Updater_Start(const char** action) {
|
|
||||||
*action = "Starting game";
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Updater_GetBuildTime(cc_uint64* timestamp) {
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Updater_MarkExecutable(void) {
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Updater_SetNewBuildTime(cc_uint64 timestamp) {
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*-------------------------------------------------------Dynamic lib-------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
/* TODO can this actually be supported somehow */
|
|
||||||
const cc_string DynamicLib_Ext = String_FromConst(".so");
|
|
||||||
|
|
||||||
void* DynamicLib_Load2(const cc_string* path) { return NULL; }
|
|
||||||
void* DynamicLib_Get2(void* lib, const char* name) { return NULL; }
|
|
||||||
|
|
||||||
cc_bool DynamicLib_DescribeError(cc_string* dst) {
|
|
||||||
String_AppendConst(dst, "Dynamic linking unsupported");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*--------------------------------------------------------Platform---------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
void Platform_Init(void) {
|
void Platform_Init(void) {
|
||||||
Platform_SingleProcess = true;
|
|
||||||
/*pspDebugSioInit();*/
|
/*pspDebugSioInit();*/
|
||||||
// TODO: sceNetInit();
|
// TODO: sceNetInit();
|
||||||
epoll_id = sceNetEpollCreate("CC poll", 0);
|
epoll_id = sceNetEpollCreate("CC poll", 0);
|
||||||
@ -551,6 +427,7 @@ cc_bool Platform_DescribeError(cc_result res, cc_string* dst) {
|
|||||||
cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) {
|
cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
|
cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ const char* Platform_AppNameSuffix = " iOS alpha";
|
|||||||
#else
|
#else
|
||||||
const char* Platform_AppNameSuffix = "";
|
const char* Platform_AppNameSuffix = "";
|
||||||
#endif
|
#endif
|
||||||
|
cc_bool Platform_SingleProcess;
|
||||||
|
|
||||||
/* Operating system specific include files */
|
/* Operating system specific include files */
|
||||||
#if defined CC_BUILD_DARWIN
|
#if defined CC_BUILD_DARWIN
|
||||||
|
@ -37,6 +37,7 @@ const cc_result ReturnCode_SocketInProgess = _EINPROGRESS;
|
|||||||
const cc_result ReturnCode_SocketWouldBlock = _EAGAIN;
|
const cc_result ReturnCode_SocketWouldBlock = _EAGAIN;
|
||||||
const cc_result ReturnCode_DirectoryExists = _EEXIST;
|
const cc_result ReturnCode_DirectoryExists = _EEXIST;
|
||||||
const char* Platform_AppNameSuffix = "";
|
const char* Platform_AppNameSuffix = "";
|
||||||
|
cc_bool Platform_SingleProcess;
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
|
@ -38,6 +38,7 @@ const cc_result ReturnCode_SocketInProgess = WSAEINPROGRESS;
|
|||||||
const cc_result ReturnCode_SocketWouldBlock = WSAEWOULDBLOCK;
|
const cc_result ReturnCode_SocketWouldBlock = WSAEWOULDBLOCK;
|
||||||
const cc_result ReturnCode_DirectoryExists = ERROR_ALREADY_EXISTS;
|
const cc_result ReturnCode_DirectoryExists = ERROR_ALREADY_EXISTS;
|
||||||
const char* Platform_AppNameSuffix = "";
|
const char* Platform_AppNameSuffix = "";
|
||||||
|
cc_bool Platform_SingleProcess;
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------------Memory----------------------------------------------------------*
|
*---------------------------------------------------------Memory----------------------------------------------------------*
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <lwip/netdb.h>
|
#include <lwip/netdb.h>
|
||||||
#include <lwip/sockets.h>
|
#include <lwip/sockets.h>
|
||||||
#include <nxdk/net.h>
|
#include <nxdk/net.h>
|
||||||
|
#include "_PlatformConsole.h"
|
||||||
|
|
||||||
static HANDLE heap;
|
static HANDLE heap;
|
||||||
const cc_result ReturnCode_FileShareViolation = ERROR_SHARING_VIOLATION;
|
const cc_result ReturnCode_FileShareViolation = ERROR_SHARING_VIOLATION;
|
||||||
@ -23,30 +24,6 @@ const cc_result ReturnCode_SocketWouldBlock = WSAEWOULDBLOCK;
|
|||||||
const cc_result ReturnCode_DirectoryExists = ERROR_ALREADY_EXISTS;
|
const cc_result ReturnCode_DirectoryExists = ERROR_ALREADY_EXISTS;
|
||||||
const char* Platform_AppNameSuffix = " XBox";
|
const char* Platform_AppNameSuffix = " XBox";
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*---------------------------------------------------------Memory----------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
void Mem_Set(void* dst, cc_uint8 value, cc_uint32 numBytes) { memset(dst, value, numBytes); }
|
|
||||||
void Mem_Copy(void* dst, const void* src, cc_uint32 numBytes) { memcpy(dst, src, numBytes); }
|
|
||||||
|
|
||||||
void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
|
||||||
return size ? malloc(size) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* Mem_TryAllocCleared(cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
return calloc(numElems, elemsSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* Mem_TryRealloc(void* mem, cc_uint32 numElems, cc_uint32 elemsSize) {
|
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
|
||||||
return size ? realloc(mem, size) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mem_Free(void* mem) {
|
|
||||||
if (mem) free(mem);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------Logging/Time-------------------------------------------------------*
|
*------------------------------------------------------Logging/Time-------------------------------------------------------*
|
||||||
@ -95,7 +72,7 @@ cc_uint64 Stopwatch_Measure(void) {
|
|||||||
return KeQueryPerformanceCounter();
|
return KeQueryPerformanceCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Platform_InitStopwatch(void) {
|
static void Stopwatch_Init(void) {
|
||||||
ULONGLONG freq = KeQueryPerformanceFrequency();
|
ULONGLONG freq = KeQueryPerformanceFrequency();
|
||||||
|
|
||||||
sw_freqMul = 1000 * 1000;
|
sw_freqMul = 1000 * 1000;
|
||||||
@ -106,11 +83,7 @@ static void Platform_InitStopwatch(void) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
void Directory_GetCachePath(cc_string* path) { }
|
|
||||||
|
|
||||||
static void GetNativePath(char* str, const cc_string* src) {
|
static void GetNativePath(char* str, const cc_string* src) {
|
||||||
if (src->length > FILENAME_SIZE) Logger_Abort("String too long to expand");
|
|
||||||
|
|
||||||
for (int i = 0; i < src->length; i++)
|
for (int i = 0; i < src->length; i++)
|
||||||
{
|
{
|
||||||
*str++ = (char)src->buffer[i];
|
*str++ = (char)src->buffer[i];
|
||||||
@ -301,12 +274,6 @@ void Waitable_WaitFor(void* handle, cc_uint32 milliseconds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*--------------------------------------------------------Font/Text--------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
void Platform_LoadSysFonts(void) { }
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------------Socket----------------------------------------------------------*
|
*---------------------------------------------------------Socket----------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
@ -425,103 +392,14 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) {
|
|||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Process/Module------------------------------------------------------*
|
*--------------------------------------------------------Platform---------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static char gameArgs[GAME_MAX_CMDARGS][STRING_SIZE];
|
|
||||||
static int gameNumArgs;
|
|
||||||
static cc_bool gameHasArgs;
|
|
||||||
|
|
||||||
cc_result Process_StartGame2(const cc_string* args, int numArgs) {
|
|
||||||
for (int i = 0; i < numArgs; i++)
|
|
||||||
{
|
|
||||||
String_CopyToRawArray(gameArgs[i], &args[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Platform_LogConst("START GAME");
|
|
||||||
gameHasArgs = true;
|
|
||||||
gameNumArgs = numArgs;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int GetGameArgs(cc_string* args) {
|
|
||||||
int count = gameNumArgs;
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
args[i] = String_FromRawArray(gameArgs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear arguments so after game is closed, launcher is started
|
|
||||||
gameNumArgs = 0;
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* args) {
|
|
||||||
if (gameHasArgs) return GetGameArgs(args);
|
|
||||||
// 3DS *sometimes* doesn't use argv[0] for program name and so argc will be 0
|
|
||||||
// (e.g. when running from Citra)
|
|
||||||
if (!argc) return 0;
|
|
||||||
|
|
||||||
argc--; argv++; // skip executable path argument
|
|
||||||
|
|
||||||
int count = min(argc, GAME_MAX_CMDARGS);
|
|
||||||
Platform_Log1("ARGS: %i", &count);
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
args[i] = String_FromReadonly(argv[i]);
|
|
||||||
Platform_Log2(" ARG %i = %c", &i, argv[i]);
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Process_Exit(cc_result code) { exit(code); }
|
|
||||||
|
|
||||||
cc_result Process_StartOpen(const cc_string* args) {
|
cc_result Process_StartOpen(const cc_string* args) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*--------------------------------------------------------Updater----------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
const char* const Updater_D3D9 = NULL;
|
|
||||||
cc_bool Updater_Clean(void) { return true; }
|
|
||||||
|
|
||||||
const struct UpdaterInfo Updater_Info = { "&eCompile latest source code to update", 0 };
|
|
||||||
|
|
||||||
cc_result Updater_Start(const char** action) { *action = "Starting"; return ERR_NOT_SUPPORTED; }
|
|
||||||
|
|
||||||
cc_result Updater_GetBuildTime(cc_uint64* timestamp) { return ERR_NOT_SUPPORTED; }
|
|
||||||
|
|
||||||
cc_result Updater_MarkExecutable(void) { return ERR_NOT_SUPPORTED; }
|
|
||||||
|
|
||||||
cc_result Updater_SetNewBuildTime(cc_uint64 timestamp) { return ERR_NOT_SUPPORTED; }
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*-------------------------------------------------------Dynamic lib-------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
const cc_string DynamicLib_Ext = String_FromConst(".so");
|
|
||||||
|
|
||||||
void* DynamicLib_Load2(const cc_string* path) { return NULL; }
|
|
||||||
|
|
||||||
void* DynamicLib_Get2(void* lib, const char* name) { return NULL; }
|
|
||||||
|
|
||||||
cc_bool DynamicLib_DescribeError(cc_string* dst) {
|
|
||||||
String_AppendConst(dst, "Dynamic linking unsupported");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*--------------------------------------------------------Platform---------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
void Platform_Init(void) {
|
void Platform_Init(void) {
|
||||||
Platform_SingleProcess = true;
|
Stopwatch_Init();
|
||||||
Platform_InitStopwatch();
|
|
||||||
nxNetInit(NULL);
|
nxNetInit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,12 @@
|
|||||||
#define SCREEN_HEIGHT 272
|
#define SCREEN_HEIGHT 272
|
||||||
static cc_bool launcherMode;
|
static cc_bool launcherMode;
|
||||||
|
|
||||||
|
struct _DisplayData DisplayInfo;
|
||||||
|
struct _WinData WindowInfo;
|
||||||
|
// no DPI scaling on Wii/GameCube
|
||||||
|
int Display_ScaleX(int x) { return x; }
|
||||||
|
int Display_ScaleY(int y) { return y; }
|
||||||
|
|
||||||
void Window_Init(void) {
|
void Window_Init(void) {
|
||||||
DisplayInfo.Width = SCREEN_WIDTH;
|
DisplayInfo.Width = SCREEN_WIDTH;
|
||||||
DisplayInfo.Height = SCREEN_HEIGHT;
|
DisplayInfo.Height = SCREEN_HEIGHT;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include "String.h"
|
#include "String.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
cc_bool Platform_SingleProcess;
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------------Memory----------------------------------------------------------*
|
*---------------------------------------------------------Memory----------------------------------------------------------*
|
||||||
|
124
src/_PlatformConsole.h
Normal file
124
src/_PlatformConsole.h
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
cc_bool Platform_SingleProcess = true;
|
||||||
|
|
||||||
|
|
||||||
|
/*########################################################################################################################*
|
||||||
|
*---------------------------------------------------------Memory----------------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
|
void Mem_Set(void* dst, cc_uint8 value, cc_uint32 numBytes) { memset(dst, value, numBytes); }
|
||||||
|
void Mem_Copy(void* dst, const void* src, cc_uint32 numBytes) { memcpy(dst, src, numBytes); }
|
||||||
|
|
||||||
|
void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) {
|
||||||
|
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
||||||
|
return size ? malloc(size) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* Mem_TryAllocCleared(cc_uint32 numElems, cc_uint32 elemsSize) {
|
||||||
|
return calloc(numElems, elemsSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* Mem_TryRealloc(void* mem, cc_uint32 numElems, cc_uint32 elemsSize) {
|
||||||
|
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
||||||
|
return size ? realloc(mem, size) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mem_Free(void* mem) {
|
||||||
|
if (mem) free(mem);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*########################################################################################################################*
|
||||||
|
*-----------------------------------------------------Directory/File------------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
|
void Directory_GetCachePath(cc_string* path) { }
|
||||||
|
|
||||||
|
|
||||||
|
/*########################################################################################################################*
|
||||||
|
*-----------------------------------------------------Process/Module------------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
|
static char gameArgs[GAME_MAX_CMDARGS][STRING_SIZE];
|
||||||
|
static int gameNumArgs;
|
||||||
|
static cc_bool gameHasArgs;
|
||||||
|
|
||||||
|
cc_result Process_StartGame2(const cc_string* args, int numArgs) {
|
||||||
|
for (int i = 0; i < numArgs; i++)
|
||||||
|
{
|
||||||
|
String_CopyToRawArray(gameArgs[i], &args[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Platform_LogConst("START GAME");
|
||||||
|
gameHasArgs = true;
|
||||||
|
gameNumArgs = numArgs;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int GetGameArgs(cc_string* args) {
|
||||||
|
int count = gameNumArgs;
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
args[i] = String_FromRawArray(gameArgs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// clear arguments so after game is closed, launcher is started
|
||||||
|
gameNumArgs = 0;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* args) {
|
||||||
|
if (gameHasArgs) return GetGameArgs(args);
|
||||||
|
// Consoles *sometimes* doesn't use argv[0] for program name and so argc will be 0
|
||||||
|
// (e.g. when running via some emulators)
|
||||||
|
if (!argc) return 0;
|
||||||
|
|
||||||
|
argc--; argv++; // skip executable path argument
|
||||||
|
|
||||||
|
int count = min(argc, GAME_MAX_CMDARGS);
|
||||||
|
Platform_Log1("ARGS: %i", &count);
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
args[i] = String_FromReadonly(argv[i]);
|
||||||
|
Platform_Log2(" ARG %i = %c", &i, argv[i]);
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Process_Exit(cc_result code) { exit(code); }
|
||||||
|
|
||||||
|
|
||||||
|
/*########################################################################################################################*
|
||||||
|
*--------------------------------------------------------Updater----------------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
|
const char* const Updater_D3D9 = NULL;
|
||||||
|
cc_bool Updater_Clean(void) { return true; }
|
||||||
|
|
||||||
|
const struct UpdaterInfo Updater_Info = { "&eCompile latest source code to update", 0 };
|
||||||
|
|
||||||
|
cc_result Updater_Start(const char** action) {
|
||||||
|
*action = "Starting game";
|
||||||
|
return ERR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_result Updater_GetBuildTime(cc_uint64* timestamp) { return ERR_NOT_SUPPORTED; }
|
||||||
|
|
||||||
|
cc_result Updater_MarkExecutable(void) { return ERR_NOT_SUPPORTED; }
|
||||||
|
|
||||||
|
cc_result Updater_SetNewBuildTime(cc_uint64 timestamp) { return ERR_NOT_SUPPORTED; }
|
||||||
|
|
||||||
|
|
||||||
|
/*########################################################################################################################*
|
||||||
|
*-------------------------------------------------------Dynamic lib-------------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
|
/* TODO can this actually be supported somehow */
|
||||||
|
const cc_string DynamicLib_Ext = String_FromConst(".so");
|
||||||
|
|
||||||
|
void* DynamicLib_Load2(const cc_string* path) { return NULL; }
|
||||||
|
void* DynamicLib_Get2(void* lib, const char* name) { return NULL; }
|
||||||
|
|
||||||
|
cc_bool DynamicLib_DescribeError(cc_string* dst) {
|
||||||
|
String_AppendConst(dst, "Dynamic linking unsupported");
|
||||||
|
return true;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user