I don't know MSX turbo R very well.
I just checked my sample program on OpenMSX using Panasonic FS-A1GT and anything work well.
I haven't looked at how to activate the R800 mode yet but if you're interested, I can take look. It will allow me to start turbo R support for my game library (I was planning to do it later but I can start looking).
OK, I used the BIOS command to switch R800 mode ON.
Here is the result:
The main difference is R800 R register seem to be incremented on a 8-bits base instead of 7-bits for Z80.
The Z80 and R800 handle refresh a bit differently. The R register on the Z80 increases by 1 for every M1 cycle (~every instruction), and refresh happens in the second half of every M1 cycle. Whereas on the R800 it increases every ~210 cycles, refresh occurs in bursts which pause the CPU processing.
A faster uniform generator for 7 bit numbers should be :
rand: ld a,r ld b,a ld a,(old_rnd) xor b ld (old_rnd),a ret
IMHO seems even more uniform than the first one posted at the beginning of this tread...
Anyone willing confirm my impression?
A "little" late reply, but I have included this version in my test program for the distribution of pseudo-random number generators and the results are very good.
I'm using a fairly close version that I thought was better quality, but in the end I feel like they have the same entropy and the result changes a bit depending on the changes I make in my program (since the R register value depends on the code).
Here is the heatmap for 32765 draws:
You can find other RNG algorithms heatmaps on the MSXVillage (I wanted to put the other images here, but I can't post them on this forum without copying them in a https :-/) : http://msxvillage.fr/forum/topic.php?pt=2&id=1524#m89122
It seems quite uniform to be that simple, very good. Actually a lot of its random behaviour is due to the code around the called function, as R on Z80 is just counting the memory accesses
It seems quite uniform to be that simple, very good. Actually a lot of its random behaviour is due to the code around the called function, as R on Z80 is just counting the memory accesses
Yet, I am in one of the worst cases because I am doing two draws in a row for the X and Y axes.
Some other algorithms fail because of this.
The only "issue" I found with this algorithm is that the results are consistent within a build, but not between builds (if the code has changed between calls).
It makes debugging a bit more complex, but the algorithm has such a high speed/efficiency ratio that it's worth it. ^^
The only "issue" I found with this algorithm is that the results are consistent within a build, but not between builds (if the code has changed between calls).
It makes debugging a bit more complex, but the algorithm has such a high speed/efficiency ratio that it's worth it. ^^
I remember I had a similar debugging problem when I was working on XSpelunker, since the random number generator I was using also depended on the R register. What I ended up doing is to have an alternative version of the generator that was deterministic, and I used for debugging, and then I switched to the one using R only when I was not debugging.