I have a use for an algo of this type, I want it for one of my editors so I can select a series of lines of text, call the DLL from the menu and have it randomise the lines and write them back to the editor in the same place.
This is the array randomising algorithm. It calls the API GetTickCount, converts it to string, reverses the string, chops of the tail 6 bytes and converts it back to a number to use as a random seed. Normally the right side of the string changes the fastest so you get a wider distribution of numbers from it by taking the right hand side in reverse.
' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
DECLARE FUNCTION Tick_Count LIB "KERNEL32.DLL" ALIAS "GetTickCount" () AS DWORD
SUB arr_rand(arr() as STRING)
#REGISTER NONE
LOCAL parr as DWORD ' array pointer
LOCAL acnt as DWORD ' array member count
LOCAL lbnd as DWORD ' lower bound of array
LOCAL lcnt as DWORD
LOCAL seed as LONG
seed = val(left$(strreverse$(str$(Tick_Count)),6))
cout sstr(seed)
lbnd = Lbound(arr()) ' get lowest array index
parr = VarPtr(arr(lbnd)) ' get address of 1st array member
acnt = ArrayAttr(arr(),4) ' get the array member count
! mov edi, acnt
! mov esi, parr
! xor ebx, ebx
! mov lcnt, edi
#align 4
stlp:
! mov eax, seed
! test eax, &H80000000
! jz nxt
! add eax, &H7FFFFFFF
nxt:
! xor edx, edx
! mov ecx, 127773
! div ecx
! mov ecx, eax
! mov eax, 16807
! mul edx
! mov edx, ecx
! mov ecx, eax
! mov eax, 2836
! mul edx
! sub ecx, eax
! xor edx, edx
! mov eax, ecx
! mov seed, ecx
! div lcnt
! mov eax, edx
! mov ecx, [esi+ebx*4] ' get the incremental pointer
! mov edx, [esi+eax*4] ' get the random pointer
! mov [esi+ebx*4], edx ' write random pointer back to incremental location
! mov [esi+eax*4], ecx ' write incremental pointer back to random location
! add ebx, 1 ' increment the original pointer
! sub edi, 1 ' decrement the loop counter
! jnz stlp
END SUB
' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤