mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Revert "duplicate every instance of a display list"
This reverts commit 4ebb8fe2cb.
This commit is contained in:
parent
4ebb8fe2cb
commit
26dd81d5cb
4 changed files with 8 additions and 58 deletions
|
|
@ -11,8 +11,6 @@
|
|||
#include "include/geo_commands.h"
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
static struct DynamicPool *sDisplayListDupPool = NULL;
|
||||
|
||||
// unused Mtx(s)
|
||||
s16 identityMtx[4][4] = { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } };
|
||||
s16 zeroMtx[4][4] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } };
|
||||
|
|
@ -22,50 +20,6 @@ Vec3s gVec3sZero = { 0, 0, 0 };
|
|||
Vec3f gVec3fOne = { 1.0f, 1.0f, 1.0f };
|
||||
UNUSED Vec3s gVec3sOne = { 1, 1, 1 };
|
||||
|
||||
#define C0(cmd, pos, width) (((cmd)->words.w0 >> (pos)) & ((1U << width) - 1))
|
||||
|
||||
// Get the size of a display list by iterating
|
||||
// until gsSPEndDisplayList or gsSPBranchList is found
|
||||
u32 gfx_get_size(const Gfx* gfx) {
|
||||
for (u16 i = 0;;) {
|
||||
u32 op = (gfx + i)->words.w0 >> 24;
|
||||
u8 cmdSize = 1;
|
||||
switch (op) {
|
||||
case G_DL:
|
||||
if (C0(gfx + i, 16, 1) == G_DL_NOPUSH) { return i + 1; } // For displaylists that end with branches (jumps)
|
||||
break;
|
||||
case G_ENDDL:
|
||||
return i + 1;
|
||||
case G_TEXRECT:
|
||||
case G_TEXRECTFLIP:
|
||||
cmdSize = 3;
|
||||
break;
|
||||
case G_FILLRECT:
|
||||
cmdSize = 2;
|
||||
break;
|
||||
}
|
||||
i += cmdSize;
|
||||
}
|
||||
}
|
||||
|
||||
// Display lists need to be duplicated so they can be modified by mods
|
||||
// also to prevent trying to write to read only memory for vanilla display lists
|
||||
Gfx *gfx_dup_display_list(const Gfx *gfx) {
|
||||
if (!gfx) { return NULL; }
|
||||
if (!sDisplayListDupPool) { sDisplayListDupPool = dynamic_pool_init(); }
|
||||
|
||||
u32 size = gfx_get_size(gfx) * sizeof(Gfx);
|
||||
void *mem = dynamic_pool_alloc(sDisplayListDupPool, size);
|
||||
memcpy(mem, gfx, size);
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
void gfx_displaylist_dup_pool_reset() {
|
||||
dynamic_pool_free_pool(sDisplayListDupPool);
|
||||
sDisplayListDupPool = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a geo node with a given type. Sets all links such that there
|
||||
* are no siblings, parent or children for this node.
|
||||
|
|
@ -281,7 +235,7 @@ init_graph_node_translation_rotation(struct DynamicPool *pool,
|
|||
vec3s_copy(graphNode->translation, translation);
|
||||
vec3s_copy(graphNode->rotation, rotation);
|
||||
graphNode->node.flags = (drawingLayer << 8) | (graphNode->node.flags & 0xFF);
|
||||
graphNode->displayList = gfx_dup_display_list(displayList);
|
||||
graphNode->displayList = displayList;
|
||||
}
|
||||
|
||||
return graphNode;
|
||||
|
|
@ -303,7 +257,7 @@ struct GraphNodeTranslation *init_graph_node_translation(struct DynamicPool *poo
|
|||
|
||||
vec3s_copy(graphNode->translation, translation);
|
||||
graphNode->node.flags = (drawingLayer << 8) | (graphNode->node.flags & 0xFF);
|
||||
graphNode->displayList = gfx_dup_display_list(displayList);
|
||||
graphNode->displayList = displayList;
|
||||
}
|
||||
|
||||
return graphNode;
|
||||
|
|
@ -324,7 +278,7 @@ struct GraphNodeRotation *init_graph_node_rotation(struct DynamicPool *pool,
|
|||
init_scene_graph_node_links(&graphNode->node, GRAPH_NODE_TYPE_ROTATION);
|
||||
vec3s_copy(graphNode->rotation, rotation);
|
||||
graphNode->node.flags = (drawingLayer << 8) | (graphNode->node.flags & 0xFF);
|
||||
graphNode->displayList = gfx_dup_display_list(displayList);
|
||||
graphNode->displayList = displayList;
|
||||
}
|
||||
|
||||
return graphNode;
|
||||
|
|
@ -345,7 +299,7 @@ struct GraphNodeScale *init_graph_node_scale(struct DynamicPool *pool,
|
|||
graphNode->node.flags = (drawingLayer << 8) | (graphNode->node.flags & 0xFF);
|
||||
graphNode->scale = scale;
|
||||
graphNode->prevScale = scale;
|
||||
graphNode->displayList = gfx_dup_display_list(displayList);
|
||||
graphNode->displayList = displayList;
|
||||
}
|
||||
|
||||
return graphNode;
|
||||
|
|
@ -415,7 +369,7 @@ struct GraphNodeAnimatedPart *init_graph_node_animated_part(struct DynamicPool *
|
|||
init_scene_graph_node_links(&graphNode->node, GRAPH_NODE_TYPE_ANIMATED_PART);
|
||||
vec3s_copy(graphNode->translation, translation);
|
||||
graphNode->node.flags = (drawingLayer << 8) | (graphNode->node.flags & 0xFF);
|
||||
graphNode->displayList = gfx_dup_display_list(displayList);
|
||||
graphNode->displayList = displayList;
|
||||
}
|
||||
|
||||
return graphNode;
|
||||
|
|
@ -436,7 +390,7 @@ struct GraphNodeBillboard *init_graph_node_billboard(struct DynamicPool *pool,
|
|||
init_scene_graph_node_links(&graphNode->node, GRAPH_NODE_TYPE_BILLBOARD);
|
||||
vec3s_copy(graphNode->translation, translation);
|
||||
graphNode->node.flags = (drawingLayer << 8) | (graphNode->node.flags & 0xFF);
|
||||
graphNode->displayList = gfx_dup_display_list(displayList);
|
||||
graphNode->displayList = displayList;
|
||||
}
|
||||
|
||||
return graphNode;
|
||||
|
|
@ -455,7 +409,7 @@ struct GraphNodeDisplayList *init_graph_node_display_list(struct DynamicPool *po
|
|||
if (graphNode != NULL) {
|
||||
init_scene_graph_node_links(&graphNode->node, GRAPH_NODE_TYPE_DISPLAY_LIST);
|
||||
graphNode->node.flags = (drawingLayer << 8) | (graphNode->node.flags & 0xFF);
|
||||
graphNode->displayList = gfx_dup_display_list(displayList);
|
||||
graphNode->displayList = displayList;
|
||||
}
|
||||
|
||||
return graphNode;
|
||||
|
|
|
|||
|
|
@ -385,8 +385,6 @@ extern Vec3s gVec3sZero;
|
|||
extern Vec3f gVec3fOne;
|
||||
extern Vec3s gVec3sOne;
|
||||
|
||||
void gfx_displaylist_dup_pool_reset();
|
||||
|
||||
void init_scene_graph_node_links(struct GraphNode *graphNode, s32 type);
|
||||
|
||||
struct GraphNodeRoot *init_graph_node_root(struct DynamicPool *pool, struct GraphNodeRoot *graphNode,
|
||||
|
|
|
|||
|
|
@ -363,8 +363,6 @@ static void level_cmd_clear_level(void) {
|
|||
}
|
||||
|
||||
static void level_reset_globals(void) {
|
||||
gfx_displaylist_dup_pool_reset();
|
||||
|
||||
// free previous level pool
|
||||
if (gLevelPool != NULL) {
|
||||
dynamic_pool_free_pool(gLevelPool);
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ void gfx_parse(Gfx* cmd, LuaFunction func) {
|
|||
u32 op = cmd->words.w0 >> 24;
|
||||
switch (op) {
|
||||
case G_DL:
|
||||
if (C0(16, 1) == G_DL_PUSH) {
|
||||
if (C0(16, 1) == 0) {
|
||||
gfx_parse((Gfx *) cmd->words.w1, func);
|
||||
} else {
|
||||
cmd = (Gfx *) cmd->words.w1;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue