From 99ad09cfd37ddbea6a1bc362219c15f3ce68d8ac Mon Sep 17 00:00:00 2001 From: David Joslin Date: Thu, 26 Oct 2023 16:09:36 -0700 Subject: [PATCH] Force broken romhack port missing skyboxes to BACKGROUND_HAUNTED --- src/engine/geo_layout.c | 6 +++--- src/engine/graph_node.c | 12 ++++++++---- src/engine/graph_node.h | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/engine/geo_layout.c b/src/engine/geo_layout.c index 09f7501a..d97966cb 100644 --- a/src/engine/geo_layout.c +++ b/src/engine/geo_layout.c @@ -692,10 +692,10 @@ void geo_layout_cmd_node_generated(void) { */ void geo_layout_cmd_node_background(void) { struct GraphNodeBackground *graphNode; - + s16 backgroundIdOrColor = cur_geo_cmd_s16(0x02); graphNode = init_graph_node_background( gGraphNodePool, NULL, - cur_geo_cmd_s16(0x02), // background ID, or RGBA5551 color if asm function is null + backgroundIdOrColor, // background ID, or RGBA5551 color if asm function is null (GraphNodeFunc) cur_geo_cmd_ptr(0x04), // asm function 0); @@ -783,7 +783,7 @@ void geo_layout_cmd_node_background_ext(void) { gGraphNodePool, NULL, BACKGROUND_CUSTOM, // background ID, or RGBA5551 color if asm function is null (GraphNodeFunc) cur_geo_cmd_ptr(0x08), // asm function - 0); + 1); register_scene_graph_node(&graphNode->fnNode.node); diff --git a/src/engine/graph_node.c b/src/engine/graph_node.c index 1cc9dce9..0da10f3c 100644 --- a/src/engine/graph_node.c +++ b/src/engine/graph_node.c @@ -482,7 +482,7 @@ struct GraphNodeGenerated *init_graph_node_generated(struct DynamicPool *pool, struct GraphNodeBackground *init_graph_node_background(struct DynamicPool *pool, struct GraphNodeBackground *graphNode, u16 background, GraphNodeFunc backgroundFunc, - s32 zero) { + u8 extended) { if (pool != NULL) { graphNode = dynamic_pool_alloc(pool, sizeof(struct GraphNodeBackground)); } @@ -490,14 +490,18 @@ struct GraphNodeBackground *init_graph_node_background(struct DynamicPool *pool, if (graphNode != NULL) { init_scene_graph_node_links(&graphNode->fnNode.node, GRAPH_NODE_TYPE_BACKGROUND); - if (backgroundFunc && background > BACKGROUND_CUSTOM) { + bool invalidBackground = (extended) + ? (backgroundFunc && background > BACKGROUND_CUSTOM) + : (backgroundFunc && background >= BACKGROUND_CUSTOM); + + if (invalidBackground) { LOG_ERROR("invalid background id"); - background = BACKGROUND_OCEAN_SKY; + background = BACKGROUND_HAUNTED; } graphNode->background = (background << 16) | background; graphNode->fnNode.func = backgroundFunc; - graphNode->unused = zero; // always 0, unused + graphNode->unused = 0; // always 0, unused if (backgroundFunc != NULL) { backgroundFunc(GEO_CONTEXT_CREATE, &graphNode->fnNode.node, pool); diff --git a/src/engine/graph_node.h b/src/engine/graph_node.h index becd9290..c4c5f5cf 100644 --- a/src/engine/graph_node.h +++ b/src/engine/graph_node.h @@ -423,7 +423,7 @@ struct GraphNodeObjectParent *init_graph_node_object_parent(struct DynamicPool * struct GraphNodeGenerated *init_graph_node_generated(struct DynamicPool *pool, struct GraphNodeGenerated *sp1c, GraphNodeFunc gfxFunc, s32 parameter); struct GraphNodeBackground *init_graph_node_background(struct DynamicPool *pool, struct GraphNodeBackground *sp1c, - u16 background, GraphNodeFunc backgroundFunc, s32 zero); + u16 background, GraphNodeFunc backgroundFunc, u8 extended); struct GraphNodeHeldObject *init_graph_node_held_object(struct DynamicPool *pool, struct GraphNodeHeldObject *sp1c, struct Object *objNode, Vec3s translation, GraphNodeFunc nodeFunc, s32 playerIndex);