-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom.vb
46 lines (36 loc) · 1.02 KB
/
random.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
' Random number generator in Firebasic
' nokiiaa, 2022
Const NULL As Void* = 0
Declare Function Lib "user32.dll" MessageBoxA(hWnd as Void*, lpText as Char*, lpCaption as Char*, uType as UInteger) As Integer
Function Rand(state As UInteger*) As UInteger
Dim x As UInteger = *state
x = x Xor (x << 13)
x = x Xor (x >> 17)
x = x Xor (x << 5)
*state = x
return x
End Function
Sub Itoa(n As Integer, output As Char*)
Dim digits As Integer = 0
Dim i As Integer = 0
Dim number As Integer = n
While number
digits += 1
number /= 10
End While
output(digits) = 0
While n
i += 1
output(digits - i) = n Mod 10 + 0x30
n /= 10
End While
End Sub
Function Main As Integer
Dim state As UInteger = 244
Dim message As Char* = "Your random number: __________."
While True
Itoa(Rand(&state) Mod 1000, message + 20)
MessageBoxA(NULL, message, "Here it is! (wow)", 0)
End While
Return 0
End Function