Skip to content

Commit

Permalink
Randomize seed if hard reset
Browse files Browse the repository at this point in the history
  • Loading branch information
tonioni committed Nov 18, 2023
1 parent 6a790fb commit dd69a5c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/uae.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ extern void fetch_videopath(TCHAR *out, int size);
extern uae_u32 uaerand(void);
extern uae_u32 uaesetrandseed(uae_u32 seed);
extern uae_u32 uaerandgetseed(void);
extern void uaerandomizeseed(void);

/* the following prototypes should probably be moved somewhere else */

Expand Down
17 changes: 11 additions & 6 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ uae_u32 uaerandgetseed(void)
return randseed;
}

void uaerandomizeseed(void)
{
if (currprefs.seed == 0) {
uae_u32 t = getlocaltime();
uaesetrandseed(t);
} else {
uaesetrandseed(currprefs.seed);
}
}

uae_u32 uaesetrandseed(uae_u32 seed)
{
if (!seed) {
Expand Down Expand Up @@ -1208,12 +1218,7 @@ static int real_main2 (int argc, TCHAR **argv)
#ifdef RETROPLATFORM
rp_fixup_options (&currprefs);
#endif
if (currprefs.seed == 0) {
uae_u32 t = getlocaltime();
uaesetrandseed(t);
} else {
uaesetrandseed(currprefs.seed);
}
uaerandomizeseed();
copy_prefs(&currprefs, &changed_prefs);
target_run ();
/* force sound settings change */
Expand Down
1 change: 1 addition & 0 deletions newcpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6633,6 +6633,7 @@ void m68k_go (int may_quit)
unset_special(SPCFLAG_MODE_CHANGE);

if (!restored && hardboot) {
uaerandomizeseed();
uae_u32 s = uaerandgetseed();
uaesetrandseed(s);
write_log("rndseed = %08x (%u)\n", s, s);
Expand Down

0 comments on commit dd69a5c

Please sign in to comment.