From 867cc656056fd98d01be572dd4557ab1d01f94e5 Mon Sep 17 00:00:00 2001 From: MysterD Date: Sat, 28 May 2022 01:26:40 -0700 Subject: [PATCH] Allow set_mario_colors on any layer, add recursive descent to geo parsing, fix color flashing in Arena --- data/dynos_bin_geo.cpp | 50 +++++++++++++++++------- mods/arena/actors/arena_ball/geo.inc.c | 3 +- mods/arena/actors/arena_ball_geo.bin | Bin 662 -> 650 bytes mods/arena/actors/koth_active/geo.inc.c | 14 +++---- mods/arena/actors/koth_active_geo.bin | Bin 1857 -> 1857 bytes src/game/mario_misc.c | 10 +++-- 6 files changed, 50 insertions(+), 27 deletions(-) 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 ec0577514e9c800970d128f16d73c7cfafc642f6..82c2e9fdbf9ce33b34225d976b38363269c8c9a7 100644 GIT binary patch delta 19 acmbQn+QquTnu(EjvJI0gBgf=4CIbL3-2_Mg delta 31 mcmeBToyNMsnu(ErvJI0gF9U;HsGqYT0|SEu1LNcparameter == 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); }