Skip to content

Commit

Permalink
SCUMM: Fix random number generation in SCUMM6
Browse files Browse the repository at this point in the history
Now it matches disassembly and particularly fixes RNG in
Backyard Sports games.
  • Loading branch information
sev- committed Jun 8, 2022
1 parent 59170ae commit c73af63
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions engines/scumm/script_v6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,8 +1345,8 @@ void ScummEngine_v6::o6_loadRoomWithEgo() {
}

void ScummEngine_v6::o6_getRandomNumber() {
int rnd;
rnd = _rnd.getRandomNumber(ABS(pop()));
int rnd = _rnd.getRandomNumber(0x7fff);
rnd = rnd % (pop() + 1);
if (VAR_RANDOM_NR != 0xFF)
VAR(VAR_RANDOM_NR) = rnd;
push(rnd);
Expand All @@ -1355,7 +1355,8 @@ void ScummEngine_v6::o6_getRandomNumber() {
void ScummEngine_v6::o6_getRandomNumberRange() {
int max = pop();
int min = pop();
int rnd = _rnd.getRandomNumberRng(min, max);
int rnd = _rnd.getRandomNumber(0x7fff);
rnd = min + (rnd % (max - min + 1));
if (VAR_RANDOM_NR != 0xFF)
VAR(VAR_RANDOM_NR) = rnd;
push(rnd);
Expand Down Expand Up @@ -2901,10 +2902,10 @@ void ScummEngine_v6::o6_delayFrames() {
// WORKAROUND: At startup, Moonbase Commander will pause for 20 frames before
// showing the Infogrames logo. The purpose of this break is to give time for the
// GameSpy Arcade application to fill with the Online game infomation.
//
//
// [0000] (84) localvar2 = max(readConfigFile.number(":var263:","user","wait-for-gamespy"),10)
// [0029] (08) delayFrames((localvar2 * 2))
//
//
// But since we don't support GameSpy and have our own Online support, this break
// has become redundant and only wastes time.
if (_game.id == GID_MOONBASE && vm.slot[_currentScript].number == 69) {
Expand Down

0 comments on commit c73af63

Please sign in to comment.