Every game can generate random numbers in different ways. For example, it is well known that in Pac-Man , the random number generator is not really random, allowing patterns to be developed that can be played exactly the same each time.
In Donkey Kong, the routine to generate a random number does so by adding up the seed and 2 different timers which results in a number that is pretty damn random. These timers both run at different speeds.
Code:
Donkey Kong Z80 disassembly follows: ; this subroutine generates a random number which is saved into the seed address #6018 and returned in the A register as well.
0057 3A1860 LD A,(#6018) ; load A with seed 005A 211A60 LD HL,#601A ; load HL with timer address 005D 86 ADD A,(HL) ; add timer to seed 005E 211960 LD HL,#6019 ; load HL with another timer address 0061 86 ADD A,(HL) ; add to seed 0062 321860 LD (#6018),A ; store seed 0065 C9 RET ; return
So, as long as MAME is emulating the timing of this game correctly, I suppose that the random numbers generated here will come out the same way as an actual DK machine.
In Ms. Pac-Man, random numbers are generated simply by loading the value from the R (refresh) register, which is updated every machine cycle and will give an extremely random number whenever it is read.
Let me know if you want me to look at other game's random number generators.
Don Hodges
Edited by Phantom DJ (09/24/10 09:01 PM)
|