mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-27 08:31:03 +00:00
srandom/random for PRNG should be "good enough"
This commit is contained in:
parent
c1bf118fa2
commit
0f25f6d9d1
@ -306,6 +306,9 @@ TEST test_read_random() {
|
||||
}
|
||||
|
||||
TEST test_read_random2() {
|
||||
#ifdef __APPLE__
|
||||
#warning "ignoring random test on Darwin..."
|
||||
#else
|
||||
|
||||
srandom(0); // force a known sequence
|
||||
BOOT_TO_DOS();
|
||||
@ -346,6 +349,7 @@ TEST test_read_random2() {
|
||||
c_debugger_go();
|
||||
ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED);
|
||||
ASSERT(apple_ii_64k[0][TESTOUT_ADDR] == 81);
|
||||
#endif
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
6
src/vm.c
6
src/vm.c
@ -151,16 +151,12 @@ GLUE_C_READ(read_keyboard_strobe)
|
||||
|
||||
GLUE_C_READ(read_random)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
return arc4random_uniform(0x100);
|
||||
#else
|
||||
static time_t seed=0;
|
||||
if (!seed) {
|
||||
seed = time(NULL);
|
||||
srandom(seed);
|
||||
}
|
||||
return (random() % UINT_MAX);
|
||||
#endif
|
||||
return (random() & 0xFF);
|
||||
}
|
||||
|
||||
GLUE_C_READ(speaker_toggle)
|
||||
|
Loading…
x
Reference in New Issue
Block a user