Free remaining global allocs
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
default: lib
|
default: lib
|
||||||
|
|
||||||
CC := cc
|
CC := cc
|
||||||
CFLAGS := -g -Wall -fPIC
|
CFLAGS := -g -Wall -fPIC -DSM64_LIB_EXPORT
|
||||||
LDFLAGS := -lm -shared
|
LDFLAGS := -lm -shared
|
||||||
|
|
||||||
SRC_DIRS := src src/decomp src/decomp/engine src/decomp/game src/decomp/mario src/decomp/tools
|
SRC_DIRS := src src/decomp src/decomp/engine src/decomp/game src/decomp/mario src/decomp/tools
|
||||||
@@ -26,7 +26,6 @@ TEST_OBJS := $(foreach file,$(TEST_SRCS),$(BUILD_DIR)/$(file:.c=.o))
|
|||||||
|
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
LIB_FILE := $(DIST_DIR)/sm64.dll
|
LIB_FILE := $(DIST_DIR)/sm64.dll
|
||||||
CFLAGS := $(CFLAGS) -DBUILDING_SM64_DLL
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
DUMMY != mkdir -p $(ALL_DIRS) build/test src/decomp/mario $(DIST_DIR)/include
|
DUMMY != mkdir -p $(ALL_DIRS) build/test src/decomp/mario $(DIST_DIR)/include
|
||||||
|
|||||||
@@ -61,44 +61,11 @@ static Vec3f gVec3fZero = { 0.0f, 0.0f, 0.0f };
|
|||||||
static Vec3s gVec3sZero = { 0, 0, 0 };
|
static Vec3s gVec3sZero = { 0, 0, 0 };
|
||||||
static Vec3f gVec3fOne = { 1.0f, 1.0f, 1.0f };
|
static Vec3f gVec3fOne = { 1.0f, 1.0f, 1.0f };
|
||||||
|
|
||||||
static struct GraphNodeObject *init_graph_node_object( Vec3f pos, Vec3s angle, Vec3f scale) {
|
|
||||||
struct GraphNodeObject *graphNode = malloc(sizeof(struct GraphNodeObject));
|
|
||||||
|
|
||||||
//init_scene_graph_node_links(&graphNode->node, GRAPH_NODE_TYPE_OBJECT);
|
|
||||||
|
|
||||||
graphNode->node.type = GRAPH_NODE_TYPE_OBJECT;
|
|
||||||
graphNode->node.flags = GRAPH_RENDER_ACTIVE;
|
|
||||||
graphNode->node.prev = &graphNode->node;
|
|
||||||
graphNode->node.next = &graphNode->node;
|
|
||||||
graphNode->node.parent = NULL;
|
|
||||||
graphNode->node.children = NULL;
|
|
||||||
|
|
||||||
vec3f_copy(graphNode->pos, pos);
|
|
||||||
vec3f_copy(graphNode->scale, scale);
|
|
||||||
vec3s_copy(graphNode->angle, angle);
|
|
||||||
vec3f_copy(graphNode->cameraToObject, gVec3fZero);
|
|
||||||
|
|
||||||
graphNode->sharedChild = NULL;
|
|
||||||
graphNode->throwMatrix = NULL;
|
|
||||||
graphNode->animInfo.animID = 0;
|
|
||||||
graphNode->animInfo.curAnim = NULL;
|
|
||||||
graphNode->animInfo.animFrame = 0;
|
|
||||||
graphNode->animInfo.animFrameAccelAssist = 0;
|
|
||||||
graphNode->animInfo.animAccel = 0x10000;
|
|
||||||
graphNode->animInfo.animTimer = 0;
|
|
||||||
graphNode->node.flags |= GRAPH_RENDER_HAS_ANIMATION;
|
|
||||||
|
|
||||||
return graphNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct Object *try_allocate_object(void) {
|
static struct Object *try_allocate_object(void) {
|
||||||
struct ObjectNode *nextObj;
|
struct ObjectNode *nextObj;
|
||||||
nextObj = (struct ObjectNode *) malloc(sizeof(struct Object));
|
nextObj = (struct ObjectNode *) malloc(sizeof(struct Object));
|
||||||
nextObj->prev = NULL;
|
nextObj->prev = NULL;
|
||||||
nextObj->next = NULL;
|
nextObj->next = NULL;
|
||||||
|
|
||||||
init_graph_node_object(gVec3fZero, gVec3sZero, gVec3fOne);
|
|
||||||
|
|
||||||
return (struct Object *) nextObj;
|
return (struct Object *) nextObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +158,6 @@ static struct Object *spawn_object_at_origin(void) {
|
|||||||
obj->parentObj = NULL;
|
obj->parentObj = NULL;
|
||||||
obj->header.gfx.areaIndex = 0;
|
obj->header.gfx.areaIndex = 0;
|
||||||
obj->header.gfx.activeAreaIndex = 0;
|
obj->header.gfx.activeAreaIndex = 0;
|
||||||
// geo_obj_init((struct GraphNodeObject *) &obj->header.gfx, gLoadedGraphNodes[model], gVec3fZero, gVec3sZero);
|
|
||||||
geo_obj_init((struct GraphNodeObject *) &obj->header.gfx, NULL, gVec3fZero, gVec3sZero);
|
geo_obj_init((struct GraphNodeObject *) &obj->header.gfx, NULL, gVec3fZero, gVec3sZero);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
|||||||
+16
-32
@@ -1,7 +1,7 @@
|
|||||||
#include <stdio.h>
|
#define SM64_LIB_EXPORT
|
||||||
|
|
||||||
#include "libsm64.h"
|
#include "libsm64.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@@ -50,38 +50,22 @@ static void update_button( bool on, u16 button )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct Camera *hack_build_camera( void )
|
static struct Area *allocate_area( void )
|
||||||
{
|
{
|
||||||
struct Camera *result = malloc( sizeof( struct Camera ));
|
struct Area *result = malloc( sizeof( struct Area ));
|
||||||
memset( result, 0, sizeof( struct Camera ));
|
memset( result, 0, sizeof( struct Area ));
|
||||||
|
|
||||||
|
result->flags = 1;
|
||||||
|
result->camera = malloc( sizeof( struct Camera ));
|
||||||
|
memset( result->camera, 0, sizeof( struct Camera ));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct Area *hack_build_area( void )
|
static void free_area( struct Area *area )
|
||||||
{
|
{
|
||||||
struct Area *result = malloc( sizeof( struct Area ));
|
free( area->camera );
|
||||||
|
free( area );
|
||||||
result->index = 0;
|
|
||||||
result->flags = 1;
|
|
||||||
result->terrainType = TERRAIN_GRASS;
|
|
||||||
result->unk04 = NULL;
|
|
||||||
result->terrainData = NULL;
|
|
||||||
result->surfaceRooms = NULL;
|
|
||||||
result->macroObjects = NULL;
|
|
||||||
result->warpNodes = NULL;
|
|
||||||
result->paintingWarpNodes = NULL;
|
|
||||||
result->instantWarps = NULL;
|
|
||||||
result->objectSpawnInfos = NULL;
|
|
||||||
result->camera = hack_build_camera();
|
|
||||||
result->unused28 = NULL;
|
|
||||||
result->whirlpools[0] = NULL;
|
|
||||||
result->whirlpools[1] = NULL;
|
|
||||||
result->dialog[0] = 0;
|
|
||||||
result->dialog[1] = 0;
|
|
||||||
result->musicParam = 0;
|
|
||||||
result->musicParam2 = 0;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture, SM64DebugPrintFunctionPtr debugPrintFunction )
|
SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture, SM64DebugPrintFunctionPtr debugPrintFunction )
|
||||||
@@ -98,7 +82,7 @@ SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture, SM64DebugP
|
|||||||
|
|
||||||
gCurrSaveFileNum = 1;
|
gCurrSaveFileNum = 1;
|
||||||
gMarioObject = hack_allocate_mario();
|
gMarioObject = hack_allocate_mario();
|
||||||
gCurrentArea = hack_build_area();
|
gCurrentArea = allocate_area();
|
||||||
gCurrentObject = gMarioObject;
|
gCurrentObject = gMarioObject;
|
||||||
|
|
||||||
s_mario_geo_pool = alloc_only_pool_init();
|
s_mario_geo_pool = alloc_only_pool_init();
|
||||||
@@ -186,8 +170,8 @@ SM64_LIB_FN void sm64_mario_tick( const struct SM64MarioInputs *inputs, struct S
|
|||||||
|
|
||||||
SM64_LIB_FN void sm64_global_terminate( void )
|
SM64_LIB_FN void sm64_global_terminate( void )
|
||||||
{
|
{
|
||||||
//deallocate area,
|
free( gMarioObject );
|
||||||
//deallocate mario object and graph node
|
free_area( gCurrentArea );
|
||||||
|
|
||||||
global_state_bind( NULL );
|
global_state_bind( NULL );
|
||||||
global_state_destroy( s_global_state );
|
global_state_destroy( s_global_state );
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifdef BUILDING_SM64_DLL
|
#ifdef SM64_LIB_EXPORT
|
||||||
#define SM64_LIB_FN __declspec(dllexport)
|
#define SM64_LIB_FN __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define SM64_LIB_FN __declspec(dllimport)
|
#define SM64_LIB_FN __declspec(dllimport)
|
||||||
|
|||||||
Reference in New Issue
Block a user