File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ' ----------------------------------------------------------------
2+ ' This file is released under the MIT License
3+ '
4+ ' Copyleft (k) 2025
5+ ' by Jose Rodriguez-Rosa (a.k.a. Boriel) <http://www.boriel.com>
6+ ' ----------------------------------------------------------------
7+
8+ #pragma once
9+ #pragma push(case_insensitive)
10+ #pragma case_insensitive = TRUE
11+
12+ function fastcall randInt() as ULong ' Returns a random ULong
13+ asm
14+ push namespace core
15+ call RAND
16+ pop namespace
17+ end asm
18+ end function
19+
20+
21+ Function fastcall randFixed() as Fixed ' Returns a random Fixed
22+ Asm
23+ push namespace core
24+ call RAND
25+ pop namespace
26+ End Asm
27+ End Function
28+
29+
30+ Function fastcall randomLimit(limit as uByte) as uByte
31+ Asm
32+ push namespace core
33+ PROC
34+ and a
35+ ret z ; Input zero, output zero.
36+ ld b, a ; Save A
37+ ld c, 255
38+ 1 :
39+ rla
40+ jr c, 2f
41+ rr c
42+ jp 1 b ; loop back until we find a bit.
43+ 2 :
44+ push bc
45+ call RAND
46+ pop bc
47+ and c
48+ cp b
49+ ret z
50+ jr nc, 2 b
51+ ENDP
52+ pop namespace
53+ End Asm
54+ End Function
55+
56+ #pragma pop(case_insensitive)
57+ #require "random.asm"
Original file line number Diff line number Diff line change 1+ ' ----------------------------------------------------------------
2+ ' This file is released under the MIT License
3+ '
4+ ' Copyleft (k) 2025
5+ ' by Jose Rodriguez-Rosa (a.k.a. Boriel) <http://www.boriel.com>
6+ ' ----------------------------------------------------------------
7+
8+ #pragma once
9+ #pragma push(case_insensitive)
10+ #pragma case_insensitive = TRUE
11+
12+ function fastcall randInt() as ULong ' Returns a random ULong
13+ asm
14+ push namespace core
15+ call RAND
16+ pop namespace
17+ end asm
18+ end function
19+
20+
21+ Function fastcall randFixed() as Fixed ' Returns a random Fixed
22+ Asm
23+ push namespace core
24+ call RAND
25+ pop namespace
26+ End Asm
27+ End Function
28+
29+
30+ Function fastcall randomLimit(limit as uByte) as uByte
31+ Asm
32+ push namespace core
33+ PROC
34+ and a
35+ ret z ; Input zero, output zero.
36+ ld b, a ; Save A
37+ ld c, 255
38+ 1 :
39+ rla
40+ jr c, 2f
41+ rr c
42+ jp 1 b ; loop back until we find a bit.
43+ 2 :
44+ push bc
45+ call RAND
46+ pop bc
47+ and c
48+ cp b
49+ ret z
50+ jr nc, 2 b
51+ ENDP
52+ pop namespace
53+ End Asm
54+ End Function
55+
56+ #pragma pop(case_insensitive)
57+ #require "random.asm"
You can’t perform that action at this time.
0 commit comments