mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-23 01:21:57 -05:00
PSP/3DS: Less stack usage and more appropriate stack size for new threads
This commit is contained in:
parent
51505f7ef3
commit
362fce5b0c
5 changed files with 42 additions and 6 deletions
11
src/Bitmap.h
11
src/Bitmap.h
|
@ -47,9 +47,6 @@ BitmapCol BitmapColor_Scale(BitmapCol a, float t);
|
|||
|
||||
/* A 2D array of BitmapCol pixels */
|
||||
struct Bitmap { BitmapCol* scan0; int width, height; };
|
||||
#define PNG_MAX_DIMS 0x8000
|
||||
#define PNG_SIG_SIZE 8
|
||||
|
||||
/* Returns number of bytes a bitmap consumes. */
|
||||
#define Bitmap_DataSize(width, height) ((cc_uint32)(width) * (cc_uint32)(height) * 4)
|
||||
/* Gets the yth row of the given bitmap. */
|
||||
|
@ -76,6 +73,14 @@ void Bitmap_TryAllocate(struct Bitmap* bmp, int width, int height);
|
|||
CC_API void Bitmap_Scale(struct Bitmap* dst, struct Bitmap* src,
|
||||
int srcX, int srcY, int srcWidth, int srcHeight);
|
||||
|
||||
#define PNG_SIG_SIZE 8
|
||||
#if defined CC_BUILD_PSP || defined CC_BUILD_3DS
|
||||
/* No point supporting > 1K x 1K bitmaps when system has less than 64 MB of RAM anyways */
|
||||
#define PNG_MAX_DIMS 1024
|
||||
#else
|
||||
#define PNG_MAX_DIMS 0x8000
|
||||
#endif
|
||||
|
||||
/* Whether data starts with PNG format signature/identifier. */
|
||||
cc_bool Png_Detect(const cc_uint8* data, cc_uint32 len);
|
||||
typedef BitmapCol* (*Png_RowGetter)(struct Bitmap* bmp, int row);
|
||||
|
|
|
@ -1388,4 +1388,35 @@ static int Font_SysTextWidth(struct DrawTextArgs* args) {
|
|||
static void Font_SysTextDraw(struct DrawTextArgs* args, struct Bitmap* bmp, int x, int y, cc_bool shadow) {
|
||||
interop_SysTextDraw(args, bmp, x, y, shadow);
|
||||
}
|
||||
#elif defined CC_BUILD_PSP || defined CC_BUILD_3DS
|
||||
void SysFonts_Register(const cc_string* path) { }
|
||||
|
||||
const cc_string* SysFonts_UNSAFE_GetDefault(void) { return &String_Empty; }
|
||||
|
||||
void SysFonts_GetNames(struct StringsBuffer* buffer) { }
|
||||
|
||||
cc_result SysFont_Make(struct FontDesc* desc, const cc_string* fontName, int size, int flags) {
|
||||
desc->size = size;
|
||||
desc->flags = flags;
|
||||
desc->height = Drawer2D_AdjHeight(size);
|
||||
|
||||
desc->handle = (void*)1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SysFont_MakeDefault(struct FontDesc* desc, int size, int flags) {
|
||||
SysFont_Make(desc, NULL, size, flags);
|
||||
}
|
||||
|
||||
void Font_Free(struct FontDesc* desc) {
|
||||
desc->size = 0;
|
||||
desc->handle = NULL;
|
||||
}
|
||||
|
||||
static int Font_SysTextWidth(struct DrawTextArgs* args) {
|
||||
return 10;
|
||||
}
|
||||
|
||||
static void Font_SysTextDraw(struct DrawTextArgs* args, struct Bitmap* bmp, int x, int y, cc_bool shadow) {
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
// https://gbatemp.net/threads/homebrew-development.360646/page-245
|
||||
// 3DS defaults to stack size of *32 KB*.. way too small
|
||||
unsigned int __stacksize__ = 512 * 1024;
|
||||
unsigned int __stacksize__ = 256 * 1024;
|
||||
|
||||
/*########################################################################################################################*
|
||||
*---------------------------------------------------------General---------------------------------------------------------*
|
||||
|
|
|
@ -235,7 +235,7 @@ static void Exec3DSThread(void* param) {
|
|||
|
||||
void* Thread_Create(Thread_StartFunc func) {
|
||||
//TODO: Not quite correct, but eh
|
||||
return threadCreate(Exec3DSThread, (void*)func, 512 * 1024, 0x3f, -2, false);
|
||||
return threadCreate(Exec3DSThread, (void*)func, 128 * 1024, 0x3f, -2, false);
|
||||
}
|
||||
|
||||
void Thread_Start2(void* handle, Thread_StartFunc func) {
|
||||
|
|
|
@ -234,7 +234,7 @@ static int ExecThread(unsigned int argc, void *argv) {
|
|||
|
||||
void* Thread_Create(Thread_StartFunc func) {
|
||||
#define CC_THREAD_PRIORITY 17 // TODO: 18?
|
||||
#define CC_THREAD_STACKSIZE 0x8000
|
||||
#define CC_THREAD_STACKSIZE 128 * 1024
|
||||
#define CC_THREAD_ATTRS 0 // TODO PSP_THREAD_ATTR_VFPU?
|
||||
|
||||
return (void*)sceKernelCreateThread("CC thread", ExecThread, CC_THREAD_PRIORITY,
|
||||
|
|
Loading…
Reference in a new issue