diff --git a/VortexEngine/src/Colors/Colorset.cpp b/VortexEngine/src/Colors/Colorset.cpp index b90d95ea35..c5ebfafa7f 100644 --- a/VortexEngine/src/Colors/Colorset.cpp +++ b/VortexEngine/src/Colors/Colorset.cpp @@ -228,7 +228,14 @@ void Colorset::randomize(Random &ctx, uint8_t numColors) ValueStyle valStyle = (ValueStyle)ctx.next8(0, VAL_STYLE_COUNT); for (uint8_t i = 0; i < numColors; ++i) { - addColorWithValueStyle(ctx, ctx.next8(), ctx.next8(), valStyle, numColors, i); + // call next8 explicitly in this order because the order they + // are called is undefined when called as parameters to another function. + // ex: f(a,b,c) may call in the order a,b,c or c,b,a depending on compiler. + // So different compilers may produce different results, + // but like this it is explicit + uint8_t sat = ctx.next8(); + uint8_t hue = ctx.next8(); + addColorWithValueStyle(ctx, hue, sat, valStyle, numColors, i); } } diff --git a/VortexEngine/src/Menus/MenuList/Randomizer.cpp b/VortexEngine/src/Menus/MenuList/Randomizer.cpp index d741d3eb71..c3614f96e3 100644 --- a/VortexEngine/src/Menus/MenuList/Randomizer.cpp +++ b/VortexEngine/src/Menus/MenuList/Randomizer.cpp @@ -230,40 +230,56 @@ bool Randomizer::rollPattern(Random &ctx, Mode *pMode, LedPos pos) void Randomizer::traditionalPattern(Random &ctx, PatternArgs &outArgs) { - outArgs.init( - ctx.next8(1, 20), // on duration 1 -> 20 - ctx.next8(8, 60) // off duration 0 -> 60 - ); + // call next8 explicitly in this order because the order they + // are called is undefined when called as parameters to another function. + // ex: f(a,b,c) may call in the order a,b,c or c,b,a depending on compiler. + // So different compilers may produce different results, + // but like this it is explicit + uint8_t off = ctx.next8(8, 60); // off duration 0 -> 60 + uint8_t on = ctx.next8(1, 20); // on duration 1 -> 20 + outArgs.init(on, off); } void Randomizer::gapPattern(Random &ctx, PatternArgs &outArgs) { - outArgs.init( - ctx.next8(1, 10), // on duration 1 -> 10 - ctx.next8(0, 6), // off duration 0 -> 6 - ctx.next8(40, 100) // gap duration 40 -> 100 - ); + // call next8 explicitly in this order because the order they + // are called is undefined when called as parameters to another function. + // ex: f(a,b,c) may call in the order a,b,c or c,b,a depending on compiler. + // So different compilers may produce different results, + // but like this it is explicit + uint8_t gap = ctx.next8(40, 100); // gap duration 40 -> 100 + uint8_t off = ctx.next8(0, 6); // off duration 0 -> 6 + uint8_t on = ctx.next8(1, 10); // on duration 1 -> 10 + outArgs.init(on, off, gap); } void Randomizer::dashPattern(Random &ctx, PatternArgs &outArgs) { - outArgs.init( - ctx.next8(1, 10), // on duration 1 -> 10 - ctx.next8(0, 10), // off duration 0 -> 10 - ctx.next8(20, 30), // need gap 20 -> 30 - ctx.next8(20, 30) // dash duration 20 -> 30 - ); + // call next8 explicitly in this order because the order they + // are called is undefined when called as parameters to another function. + // ex: f(a,b,c) may call in the order a,b,c or c,b,a depending on compiler. + // So different compilers may produce different results, + // but like this it is explicit + uint8_t dash = ctx.next8(20, 30); // dash duration 20 -> 30 + uint8_t gap = ctx.next8(20, 30); // need gap 20 -> 30 + uint8_t off = ctx.next8(0, 10); // off duration 0 -> 10 + uint8_t on = ctx.next8(1, 10); // on duration 1 -> 10 + outArgs.init(on, off, gap, dash); } void Randomizer::crushPattern(Random &ctx, PatternArgs &outArgs) { - outArgs.init( - ctx.next8(1, 10), // on duration 1 -> 10 - ctx.next8(0, 10), // off duration 0 -> 5 - ctx.next8(20, 40), // need gap 20 -> 40 - 0, // dash 0 - ctx.next8(0, 8) // groupsize 0 to 8 - ); + // call next8 explicitly in this order because the order they + // are called is undefined when called as parameters to another function. + // ex: f(a,b,c) may call in the order a,b,c or c,b,a depending on compiler. + // So different compilers may produce different results, + // but like this it is explicit + uint8_t group = ctx.next8(0, 8); // groupsize 0 to 8 + uint8_t dash = 0; // dash 0 + uint8_t gap = ctx.next8(20, 40); // need gap 20 -> 40 + uint8_t off = ctx.next8(0, 10); // off duration 0 -> 5 + uint8_t on = ctx.next8(1, 10); // on duration 1 -> 10 + outArgs.init(on, off, gap, dash, group); } PatternID Randomizer::rollPatternID(Random &ctx)