diff --git a/data/dynos_bin_geo.cpp b/data/dynos_bin_geo.cpp index 1f71a3feb..a91835b03 100644 --- a/data/dynos_bin_geo.cpp +++ b/data/dynos_bin_geo.cpp @@ -17,21 +17,9 @@ extern "C" { #define GEO_LAYOUT_SIZE_PER_TOKEN 4 #define geo_constant(x) if (_Arg == #x) { return (s64) (x); } -static s64 ParseGeoSymbolArg(GfxData* aGfxData, DataNode* aNode, u64& aTokenIndex) { - const String& _Arg = aNode->mTokens[aTokenIndex++]; - // Integers - bool integerFound = false; - s64 integerValue = DynOS_Misc_ParseInteger(_Arg, &integerFound); - if (integerFound) { - return integerValue; - } - - // Built-in functions - const void *_FunctionPtr = DynOS_Builtin_Func_GetFromName(_Arg.begin()); - if (_FunctionPtr != NULL) { - return (s64) _FunctionPtr; - } +static s64 DynOS_Geo_ParseConstants(const String& _Arg, bool* found) { + *found = true; // Layer constants geo_constant(LAYER_FORCE); @@ -102,6 +90,33 @@ static s64 ParseGeoSymbolArg(GfxData* aGfxData, DataNode* aNode, u64& geo_constant(SCREEN_WIDTH/2); geo_constant(SCREEN_HEIGHT/2); + *found = false; + return 0; +} + +static s64 ParseGeoSymbolArg(GfxData* aGfxData, DataNode* aNode, u64& aTokenIndex) { + const String& _Arg = aNode->mTokens[aTokenIndex++]; + + // Integers + bool integerFound = false; + s64 integerValue = DynOS_Misc_ParseInteger(_Arg, &integerFound); + if (integerFound) { + return integerValue; + } + + // Built-in functions + const void *_FunctionPtr = DynOS_Builtin_Func_GetFromName(_Arg.begin()); + if (_FunctionPtr != NULL) { + return (s64) _FunctionPtr; + } + + // Constants + bool constantFound = false; + s64 constantValue = DynOS_Geo_ParseConstants(_Arg, &constantFound); + if (constantFound) { + return constantValue; + } + // Display lists for (auto& _Node : aGfxData->mDisplayLists) { if (_Arg == _Node->mName) { @@ -125,6 +140,13 @@ static s64 ParseGeoSymbolArg(GfxData* aGfxData, DataNode* aNode, u64& return PAINTING_ID(a, b); } + // Recursive descent parsing + bool rdSuccess = false; + s64 rdValue = DynOS_RecursiveDescent_Parse(_Arg.begin(), &rdSuccess, DynOS_Geo_ParseConstants); + if (rdSuccess) { + return rdValue; + } + // Unknown PrintError(" ERROR: Unknown geo arg: %s", _Arg.begin()); return 0; diff --git a/mods/arena/actors/arena_ball/geo.inc.c b/mods/arena/actors/arena_ball/geo.inc.c index a22a1f8c9..5125a4928 100644 --- a/mods/arena/actors/arena_ball/geo.inc.c +++ b/mods/arena/actors/arena_ball/geo.inc.c @@ -3,8 +3,7 @@ const GeoLayout arena_ball_geo[] = { GEO_OPEN_NODE(), GEO_SCALE(0x00, 170393), GEO_OPEN_NODE(), - GEO_ASM(0, geo_mario_set_player_colors), - GEO_ASM(1, geo_mario_set_player_colors), + GEO_ASM(LAYER_TRANSPARENT + 3, geo_mario_set_player_colors), GEO_DISPLAY_LIST(LAYER_TRANSPARENT, arena_ball_gfx), GEO_CLOSE_NODE(), GEO_CLOSE_NODE(), diff --git a/mods/arena/actors/arena_ball_geo.bin b/mods/arena/actors/arena_ball_geo.bin index ec0577514..82c2e9fdb 100644 Binary files a/mods/arena/actors/arena_ball_geo.bin and b/mods/arena/actors/arena_ball_geo.bin differ diff --git a/mods/arena/actors/koth_active/geo.inc.c b/mods/arena/actors/koth_active/geo.inc.c index 65f414f9d..009183f5f 100644 --- a/mods/arena/actors/koth_active/geo.inc.c +++ b/mods/arena/actors/koth_active/geo.inc.c @@ -1,11 +1,11 @@ #include "src/game/envfx_snow.h" const GeoLayout koth_active_geo[] = { - GEO_NODE_START(), - GEO_OPEN_NODE(), - GEO_ASM(1, geo_mario_set_player_colors), - GEO_DISPLAY_LIST(LAYER_ALPHA, koth_active_Cylinder_mesh_layer_4), - GEO_DISPLAY_LIST(LAYER_ALPHA, koth_active_material_revert_render_settings), - GEO_CLOSE_NODE(), - GEO_END(), + GEO_NODE_START(), + GEO_OPEN_NODE(), + GEO_ASM(LAYER_ALPHA + 3, geo_mario_set_player_colors), + GEO_DISPLAY_LIST(LAYER_ALPHA, koth_active_Cylinder_mesh_layer_4), + GEO_DISPLAY_LIST(LAYER_ALPHA, koth_active_material_revert_render_settings), + GEO_CLOSE_NODE(), + GEO_END(), }; diff --git a/mods/arena/actors/koth_active_geo.bin b/mods/arena/actors/koth_active_geo.bin index 6346d227e..316f13616 100644 Binary files a/mods/arena/actors/koth_active_geo.bin and b/mods/arena/actors/koth_active_geo.bin differ diff --git a/src/game/mario_misc.c b/src/game/mario_misc.c index c87acab87..77d78e306 100644 --- a/src/game/mario_misc.c +++ b/src/game/mario_misc.c @@ -843,13 +843,15 @@ Gfx* geo_mario_set_player_colors(s32 callContext, struct GraphNode* node, UNUSED gSPLight(gfx + 3, &gPlayerColors[colorIndex].shirt.a, 6); gSPEndDisplayList(gfx + 4); u32 layer = LAYER_OPAQUE; - if (asGenerated->parameter == 1) { + if (asGenerated->parameter == 0) { + // put on transparent layer if vanish effect, opaque otherwise + layer = ((bodyState->modelState >> 8) & 1) ? LAYER_TRANSPARENT : LAYER_OPAQUE; + } else if (asGenerated->parameter == 1) { layer = LAYER_OPAQUE; } else if (asGenerated->parameter == 2) { layer = LAYER_TRANSPARENT; - } else { - // put on transparent layer if vanish effect, opaque otherwise - layer = ((bodyState->modelState >> 8) & 1) ? LAYER_TRANSPARENT : LAYER_OPAQUE; + } else if (asGenerated->parameter >= 3) { + layer = asGenerated->parameter - 3; } asGenerated->fnNode.node.flags = (asGenerated->fnNode.node.flags & 0xFF) | (layer << 8); }