mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
GBA/32x: Increase free RAM by 18 kb and reduce binary size by 45/66 kb by going straight in-game rather than via the launcher
This commit is contained in:
parent
af6cbc9b9e
commit
dc44cab8be
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../_PlatformConsole.h"
|
|
||||||
|
|
||||||
#include "../../misc/32x/32x.h"
|
#include "../../misc/32x/32x.h"
|
||||||
#include "../../misc/32x/hw_32x.h"
|
#include "../../misc/32x/hw_32x.h"
|
||||||
@ -30,24 +29,43 @@ const cc_result ReturnCode_SocketDropped = -1;
|
|||||||
|
|
||||||
const char* Platform_AppNameSuffix = " 32x";
|
const char* Platform_AppNameSuffix = " 32x";
|
||||||
cc_bool Platform_ReadonlyFilesystem = true;
|
cc_bool Platform_ReadonlyFilesystem = true;
|
||||||
|
cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT;
|
||||||
|
|
||||||
|
|
||||||
|
/*########################################################################################################################*
|
||||||
|
*-----------------------------------------------------Main entrypoint-----------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
|
#include "../main_impl.h"
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
SetupProgram(argc, argv);
|
||||||
|
while (Window_Main.Exists) {
|
||||||
|
RunGame();
|
||||||
|
}
|
||||||
|
|
||||||
|
Window_Free();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------------Memory----------------------------------------------------------*
|
*---------------------------------------------------------Memory----------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
|
void* Mem_Set(void* dst, cc_uint8 value, unsigned numBytes) { return memset( dst, value, numBytes); }
|
||||||
|
void* Mem_Copy(void* dst, const void* src, unsigned numBytes) { return memcpy( dst, src, numBytes); }
|
||||||
|
void* Mem_Move(void* dst, const void* src, unsigned numBytes) { return memmove(dst, src, numBytes); }
|
||||||
|
|
||||||
void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) {
|
void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) {
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
||||||
Platform_Log1(" MALLOC: %i", &size);
|
|
||||||
void* ptr = size ? ta_alloc(size) : NULL;
|
void* ptr = size ? ta_alloc(size) : NULL;
|
||||||
Platform_Log1("MALLOCED: %x", &ptr);
|
Platform_Log2("MALLOCED: %x (%i bytes)", &ptr, &size);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mem_TryAllocCleared(cc_uint32 numElems, cc_uint32 elemsSize) {
|
void* Mem_TryAllocCleared(cc_uint32 numElems, cc_uint32 elemsSize) {
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
||||||
Platform_Log1(" CALLOC: %i", &size);
|
|
||||||
void* ptr = size ? ta_alloc(size) : NULL;
|
void* ptr = size ? ta_alloc(size) : NULL;
|
||||||
Platform_Log1("CALLOCED: %x", &ptr);
|
Platform_Log2("CALLOCED: %x (%i bytes)", &ptr, &size);
|
||||||
|
|
||||||
if (ptr) Mem_Set(ptr, 0, size);
|
if (ptr) Mem_Set(ptr, 0, size);
|
||||||
return ptr;
|
return ptr;
|
||||||
@ -304,3 +322,21 @@ cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
|
|||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*########################################################################################################################*
|
||||||
|
*-----------------------------------------------------Process/Module------------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
|
cc_result Process_StartGame2(const cc_string* args, int numArgs) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* args) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Process_Exit(cc_result code) { _exit(code); }
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ static char gameArgs[GAME_MAX_CMDARGS][STRING_SIZE];
|
|||||||
static int gameNumArgs;
|
static int gameNumArgs;
|
||||||
static cc_bool gameHasArgs;
|
static cc_bool gameHasArgs;
|
||||||
|
|
||||||
static cc_result SetGameArgs(const cc_string* args, int numArgs) {
|
static CC_INLINE cc_result SetGameArgs(const cc_string* args, int numArgs) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < numArgs; i++)
|
for (i = 0; i < numArgs; i++)
|
||||||
{
|
{
|
||||||
@ -114,7 +114,7 @@ static cc_result SetGameArgs(const cc_string* args, int numArgs) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetGameArgs(cc_string* args) {
|
static CC_INLINE int GetGameArgs(cc_string* args) {
|
||||||
int i, count = gameNumArgs;
|
int i, count = gameNumArgs;
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -16,9 +16,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "gbadefs.h"
|
#include "gbadefs.h"
|
||||||
|
|
||||||
#define OVERRIDE_MEM_FUNCTIONS
|
|
||||||
#include "../_PlatformConsole.h"
|
|
||||||
|
|
||||||
#include "../../third_party/tinyalloc/tinyalloc.c"
|
#include "../../third_party/tinyalloc/tinyalloc.c"
|
||||||
|
|
||||||
typedef volatile uint8_t vu8;
|
typedef volatile uint8_t vu8;
|
||||||
@ -34,24 +31,42 @@ const cc_result ReturnCode_SocketDropped = -1;
|
|||||||
|
|
||||||
const char* Platform_AppNameSuffix = " GBA";
|
const char* Platform_AppNameSuffix = " GBA";
|
||||||
cc_bool Platform_ReadonlyFilesystem;
|
cc_bool Platform_ReadonlyFilesystem;
|
||||||
|
cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT;
|
||||||
|
|
||||||
|
|
||||||
|
/*########################################################################################################################*
|
||||||
|
*-----------------------------------------------------Main entrypoint-----------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
|
#include "../main_impl.h"
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
SetupProgram(argc, argv);
|
||||||
|
while (Window_Main.Exists) {
|
||||||
|
RunGame();
|
||||||
|
}
|
||||||
|
|
||||||
|
Window_Free();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------------Memory----------------------------------------------------------*
|
*---------------------------------------------------------Memory----------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
|
void* Mem_Set(void* dst, cc_uint8 value, unsigned numBytes) { return memset( dst, value, numBytes); }
|
||||||
|
void* Mem_Copy(void* dst, const void* src, unsigned numBytes) { return memcpy( dst, src, numBytes); }
|
||||||
|
void* Mem_Move(void* dst, const void* src, unsigned numBytes) { return memmove(dst, src, numBytes); }
|
||||||
|
|
||||||
void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) {
|
void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) {
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
||||||
Platform_Log1(" MALLOC: %i", &size);
|
|
||||||
void* ptr = size ? ta_alloc(size) : NULL;
|
void* ptr = size ? ta_alloc(size) : NULL;
|
||||||
Platform_Log1("MALLOCED: %x", &ptr);
|
Platform_Log2("MALLOCED: %x (%i bytes)", &ptr, &size);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Mem_TryAllocCleared(cc_uint32 numElems, cc_uint32 elemsSize) {
|
void* Mem_TryAllocCleared(cc_uint32 numElems, cc_uint32 elemsSize) {
|
||||||
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
cc_uint32 size = CalcMemSize(numElems, elemsSize);
|
||||||
Platform_Log1(" CALLOC: %i", &size);
|
|
||||||
void* ptr = size ? ta_alloc(size) : NULL;
|
void* ptr = size ? ta_alloc(size) : NULL;
|
||||||
Platform_Log1("CALLOCED: %x", &ptr);
|
Platform_Log2("CALLOCED: %x (%i bytes)", &ptr, &size);
|
||||||
|
|
||||||
if (ptr) Mem_Set(ptr, 0, size);
|
if (ptr) Mem_Set(ptr, 0, size);
|
||||||
return ptr;
|
return ptr;
|
||||||
@ -354,3 +369,21 @@ cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
|
|||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*########################################################################################################################*
|
||||||
|
*-----------------------------------------------------Process/Module------------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
|
cc_result Process_StartGame2(const cc_string* args, int numArgs) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* args) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Process_Exit(cc_result code) { _exit(code); }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user