Allen Nelson
Member
OK, now I get it. You are looking for "shuffle" logic to re-order 12 different "cards".
One possible method:
Start with a set of 12 registers containing the numbers 1 through 12 in some order ("OLD ORDER"), and a second set of 12 registers that are empty (NEW ORDER).
After having run through the sequence, generate a random number between 0 and 4095 (i.e, 2[super]12[/super]). Seqence through the bit pattern of the random number. If the first bit is set, move the first number in the OLD ORDER stack to the top of NEW ORDER stack. If the random number bit is not set, do nothing. If the second bit is set, move the second number in the OLD ORDER to the NEW ORDER, and so on.
Once all 12 bits have been checked, repeat the proccess, checking to see of the random number bit is NOT set. At the end, you will have 12 unique numbers in NEW ORDER, but in a different order than in OLD ORDER.
Block move all of NEW ORDER into OLD ORDER. Repeat the "shuffle" process, generating a new random number, until the START button is pressed again. The START button runs whatever sequence happens to be present in the OLD ORDER.
This logic would word best with for-next looping and indirect addressing, or pointer functions, but could be hard-coded if needed.
One possible method:
Start with a set of 12 registers containing the numbers 1 through 12 in some order ("OLD ORDER"), and a second set of 12 registers that are empty (NEW ORDER).
After having run through the sequence, generate a random number between 0 and 4095 (i.e, 2[super]12[/super]). Seqence through the bit pattern of the random number. If the first bit is set, move the first number in the OLD ORDER stack to the top of NEW ORDER stack. If the random number bit is not set, do nothing. If the second bit is set, move the second number in the OLD ORDER to the NEW ORDER, and so on.
Once all 12 bits have been checked, repeat the proccess, checking to see of the random number bit is NOT set. At the end, you will have 12 unique numbers in NEW ORDER, but in a different order than in OLD ORDER.
Block move all of NEW ORDER into OLD ORDER. Repeat the "shuffle" process, generating a new random number, until the START button is pressed again. The START button runs whatever sequence happens to be present in the OLD ORDER.
This logic would word best with for-next looping and indirect addressing, or pointer functions, but could be hard-coded if needed.