You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// create game of life struct to hold cells and future cells
5165
-
structgameOfLife {
5166
-
uint8_t* cells;
5167
-
uint8_t* futureCells;
5168
-
uint8_t gliderLength;
5169
-
uint16_t oscillatorCRC;
5170
-
uint16_t spaceshipCRC;
5171
-
};
5164
+
5172
5165
uint16_tmode_2Dgameoflife(void) { // Written by Ewoud Wijma, inspired by https://natureofcode.com/book/chapter-7-cellular-automata/
5173
5166
// and https://github.com/DougHaber/nlife-color , Modified By: Brandon Butler
5174
5167
if (!strip.isMatrix) returnmode_static(); // not a 2D set-up
5175
5168
5176
5169
constuint16_t cols = SEGMENT.virtualWidth();
5177
5170
constuint16_t rows = SEGMENT.virtualHeight();
5178
-
constsize_t dataSize = (SEGMENT.length() / 8) + (((SEGMENT.length() %8) != 0) ? 1 : 0); //add one byte when extra bits needed (length not a multiple of 8)
if (!cellChanged || crc == gol->oscillatorCRC || crc == gol->spaceshipCRC) repetition = true; //check if cell changed this gen and compare previous stored crc values
5312
+
if (!cellChanged || crc == *oscillatorCRC || crc == *spaceshipCRC) repetition = true; //check if cell changed this gen and compare previous stored crc values
5321
5313
if (repetition) {
5322
5314
generation = 0; // reset on next call
5323
5315
pauseFrames = 50;
5324
5316
return FRAMETIME;
5325
5317
}
5326
5318
// Update CRC values
5327
-
if (generation % 16 == 0) gol->oscillatorCRC = crc;
5328
-
if (generation % gol->gliderLength == 0) gol->spaceshipCRC = crc;
5319
+
if (generation % 16 == 0) *oscillatorCRC = crc;
5320
+
if (generation % *gliderLength == 0) *spaceshipCRC = crc;
0 commit comments