Allow set_mario_colors on any layer, add recursive descent to geo parsing, fix color flashing in Arena

This commit is contained in:
MysterD 2022-05-28 01:26:40 -07:00
parent 32e0c9eda2
commit 867cc65605
6 changed files with 50 additions and 27 deletions

View File

@ -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<GeoLayout>* 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<GeoLayout>* aNode, u64&
geo_constant(SCREEN_WIDTH/2);
geo_constant(SCREEN_HEIGHT/2);
*found = false;
return 0;
}
static s64 ParseGeoSymbolArg(GfxData* aGfxData, DataNode<GeoLayout>* 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<GeoLayout>* 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;

View File

@ -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(),

Binary file not shown.

View File

@ -3,7 +3,7 @@
const GeoLayout koth_active_geo[] = {
GEO_NODE_START(),
GEO_OPEN_NODE(),
GEO_ASM(1, geo_mario_set_player_colors),
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(),

View File

@ -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);
}