Skip to content

Commit

Permalink
Saturn: Try to fix chunk building insta crashing the game
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed May 9, 2024
1 parent 3ee1b1e commit 5bd2d68
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion misc/saturn/Makefile
Expand Up @@ -16,7 +16,7 @@ SH_CFLAGS+= -Os -I. -DPLAT_SATURN
SH_LDFLAGS+=

IP_VERSION:= V1.000
IP_RELEASE_DATE:= 20160101
IP_RELEASE_DATE:= 20230101
IP_AREAS:= JTUBKAEL
IP_PERIPHERALS:= JAMKST
IP_TITLE:= ClassiCube
Expand Down
11 changes: 11 additions & 0 deletions src/Builder.c
Expand Up @@ -360,9 +360,16 @@ static void OutputChunkPartsMeta(int x, int y, int z, struct ChunkInfo* info) {
}

void Builder_MakeChunk(struct ChunkInfo* info) {
#ifdef CC_BUILD_SATURN
/* The Saturn build only has 16 kb stack, not large enough */
static BlockID chunk[EXTCHUNK_SIZE_3];
static cc_uint8 counts[CHUNK_SIZE_3 * FACE_COUNT];
static int bitFlags[1];
#else
BlockID chunk[EXTCHUNK_SIZE_3];
cc_uint8 counts[CHUNK_SIZE_3 * FACE_COUNT];
int bitFlags[EXTCHUNK_SIZE_3];
#endif

cc_bool allAir, allSolid, onBorder;
int xMax, yMax, zMax, totalVerts;
Expand Down Expand Up @@ -761,6 +768,7 @@ static void NormalBuilder_SetActive(void) {
/*########################################################################################################################*
*-------------------------------------------------Advanced mesh builder---------------------------------------------------*
*#########################################################################################################################*/
#ifdef CC_BUILD_ADVLIGHTING
static Vec3 adv_minBB, adv_maxBB;
static int adv_initBitFlags, adv_baseOffset;
static int* adv_bitFlags;
Expand Down Expand Up @@ -1259,6 +1267,9 @@ static void AdvBuilder_SetActive(void) {
Builder_RenderBlock = Adv_RenderBlock;
Builder_PrePrepareChunk = Adv_PrePrepareChunk;
}
#else
static void AdvBuilder_SetActive(void) { NormalBuilder_SetActive(); }
#endif


/*########################################################################################################################*
Expand Down
4 changes: 4 additions & 0 deletions src/Core.h
Expand Up @@ -124,6 +124,7 @@ typedef cc_uint8 cc_bool;
#define CC_BUILD_PLUGINS
#define CC_BUILD_ANIMATIONS
#define CC_BUILD_FILESYSTEM
#define CC_BUILD_ADVLIGHTING
/*#define CC_BUILD_GL11*/

#ifndef CC_BUILD_MANUAL
Expand Down Expand Up @@ -345,6 +346,7 @@ typedef cc_uint8 cc_bool;
#define CC_BUILD_TOUCH
#undef CC_BUILD_RESOURCES
#undef CC_BUILD_ANIMATIONS /* Very costly in FPU less system */
#undef CC_BUILD_ADVLIGHTING
#elif defined __WIIU__
#define CC_BUILD_WIIU
#define CC_BUILD_CONSOLE
Expand Down Expand Up @@ -374,6 +376,7 @@ typedef cc_uint8 cc_bool;
#undef CC_BUILD_RESOURCES
#undef CC_BUILD_NETWORKING
#undef CC_BUILD_ANIMATIONS /* Very costly in FPU less system */
#undef CC_BUILD_ADVLIGHTING
#undef CC_BUILD_FILESYSTEM
#elif defined OS2
#define CC_BUILD_OS2
Expand All @@ -392,6 +395,7 @@ typedef cc_uint8 cc_bool;
#undef CC_BUILD_RESOURCES
#undef CC_BUILD_NETWORKING
#undef CC_BUILD_ANIMATIONS /* Very costly in FPU less system */
#undef CC_BUILD_ADVLIGHTING
#undef CC_BUILD_FILESYSTEM
#endif
#endif
Expand Down

0 comments on commit 5bd2d68

Please sign in to comment.