![]() |
![]() |
![]() |
#21 | |
Defendit numerus
![]() Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 50
Posts: 3,124
|
Quote:
On real Amiga is relatively easy to get it: something related to MFMpos on floppy, or timers/beampos in the other cases. |
|
![]() |
![]() |
#22 |
Registered User
![]() Join Date: Sep 2019
Location: Essen/Germany
Age: 52
Posts: 376
|
I downloaded this list of 32 bit prime numbers and picked one at random.
http://www.umopit.ru/CompLab/primes32eng.htm |
![]() |
![]() |
#23 |
Registered User
![]() Join Date: Jul 2015
Location: The Netherlands
Posts: 2,647
|
Thanks, both of those might be a good options
![]() |
![]() |
![]() |
#24 | |
Defendit numerus
![]() Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 50
Posts: 3,124
|
Quote:
So a way to get a random seed every time ![]() (or at least to generate the sequence from 'enough' seeds, which then explodes into thousands of pseudo-random numbers) With WinUAE I failed ![]() |
|
![]() |
![]() |
#25 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 48
Posts: 4,142
|
Here is the one i'm using :
Code:
lea $dff000,a2 ; custom chips lea $dc0000,a3 ; clock (if there is one) moveq #15,d7 move.w (a2),d0 swap d0 move.w d1,d0 ; d1 is dos bptr upon program entry .loop rol.l #5,d0 add.w (a3),d0 addq.l #4,a3 dbf d7,.loop add.l $a(a2),d0 rol.l #7,d0 add.l $12(a2),d0 move.l d0,seed Not good enough as a random generator by itself, but nevertheless a satisfying seed. |
![]() |
![]() |
#26 |
Defendit numerus
![]() Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 50
Posts: 3,124
|
Yep, good, but problematic if custom chip state is deterministic (UAE), clock unavailable and location absolute
![]() |
![]() |
![]() |
#27 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 48
Posts: 4,142
|
That's too iffy for its intended use case, which is under OS.
There, not only the user will take indefinite amount of time to run the program ; there is also host disk i/o that will add some random time and thus custom chip state ceases to be deterministic. Anyway, you *have* to find a source of entropy somewhere. If there is none, the task is simply impossible ! In all cases however, the user can give you some. Wait for some mouse/keyboard/joystick input, and measure the time it took. You could do that not only at startup but permanently, updating your seed. Also it might be eventually possible to execute native code from winuae (i just don't know how). |
![]() |
![]() |
#28 | |||
Defendit numerus
![]() Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 50
Posts: 3,124
|
Quote:
Quote:
Quote:
Adding up all these questions/answers there is therefore a possibility: make sure that UAE set the floppy head on a random position when a load for the very first track from floppy is requested ![]() On real machines this is "automatic": when you boot the machine and start DMA for the firsts floppy load you sure are in a random position with the head (which cascades propagates to the execution of the code that generates the seed based on a state at that point definitely random). Same for HDD load. I had talked about it with Toni and he had explained to me why it is not so, I don't remember anymore, but it were certainly good reasons ![]() |
|||
![]() |
![]() |
#29 | ||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 48
Posts: 4,142
|
You're looking for trouble
![]() Stop using floppies, use the OS, and it will work fine ![]() Quote:
![]() Quote:
Ya better ask for some winuae backdoor to grab random data. |
||
![]() |
![]() |
#30 | ||
Defendit numerus
![]() Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 50
Posts: 3,124
|
Quote:
And in any case I would like to use a simple way in my code (for example the x position of the video beam) to generate a simple seed and I can't do that on all existing emulated machine (I'm talking about my particular case histories as a patcher of old games) ![]() Quote:
|
||
![]() |
![]() |
#31 |
Registered User
![]() Join Date: Dec 2016
Location: Finland
Posts: 123
|
One simple and good way of testing the randomness of the pseudornd generator is to randomize some small number, e.g. 1-10, and add these numbers together and make a histogram of the results. For 1 number you should get a uniform distribution, for 2 added numbers a triangular, and 3 added numbers a parabolic distribution. The distribution should approach a gaussian distribution for many added numbers.
I remember some bad simple rnd generators couldn't ever produce a lot of same outcomes in succession so the tails were missing in the distribution of added numbers. Of course you need to collect a lot of statistics to see the tails. |
![]() |
![]() |
#32 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 962
|
There are many, many tests in the references I gave. The spetral test is the most important one, but there are many more.
|
![]() |
![]() |
#33 |
old bearded fool
![]() Join Date: Jan 2010
Location: Bangkok
Age: 53
Posts: 538
|
Hardware random generators are better, make it a fun project, Amiga parallel port uses 5V which should be fine for the bus interface, some examples:
https://makezine.com/projects/really...ber-generator/ |
![]() |
![]() |
#34 | |
ex. demoscener "Bigmama"
![]() Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,215
|
Quote:
![]() |
|
![]() |
![]() |
#35 |
Lemon. / Core Design
![]() Join Date: Mar 2016
Location: Tier 5
Posts: 887
|
Best to avoid a multiply of divide where possible.
I use a RNG that uses just a swap and a couple of adds, and it works great. I use it to generate noise maps etc, with no issues. More important is seeding it well. |
![]() |
![]() |
#36 | |
OCS forever!
![]() Join Date: Mar 2019
Location: Birmingham, UK
Posts: 345
|
Quote:
![]() Dan mentioned a quick one involving a swap and a couple of adds. I wonder if it's this one that uses this idea: https://www.flipcode.com/archives/07-15-2002.shtml . I found a snippet on the atari forum that used it like: Code:
lea .rand(pc),a0 lea 4(a0),a1 move.l (a0),d0 ; AB move.l (a1),d1 ; CD swap d1 ; DC add.l d1,(a0) ; AB + DC add.l d0,(a1) ; CD + AB .rand: dc.l $3E50B28C dc.l $D461A7F9 ![]() ![]() Code:
***************************************************************************** * Generates a number of words of noise into a buffer. * *http://www.flipcode.com/archives/07-15-2002.shtml * * IN: d0.w, number of words * d1.l/d2.l seeds * a0, buffer * OUT: d1.l/d2.l new seeds * TRASHED: d0-d2/a0 ***************************************************************************** xdef LIB_GenNoise_W LIB_GenNoise_W: move.l d3,-(sp) lsr.w #1,d0 ;number of words to longs bcc.s .firstlong .firstword: move.l d2,d3 swap d3 add.l d1,d2 add.l d3,d1 move.w d3,(a0)+ ;write out just word .firstlong subq.w #1,d0 ;-1 for dbf bmi.s .done .loop: move.l d2,d3 swap d3 add.l d1,d2 add.l d3,d1 move.l d3,(a0)+ ;write out entire long dbf d0,.loop .done: move.l (sp)+,d3 rts Last edited by Antiriad_UK; 23 November 2020 at 19:48. |
|
![]() |
![]() |
#37 |
Defendit numerus
![]() Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 50
Posts: 3,124
|
I remember writing some code to generate a noise screen and it seemed to work very well (in fact it was not a screen but a face of a glenz polygonal object with a random changing stencil inside).
I picked up the code and it was just this: Code:
random_generator: move.w #$880/4-1,d1 lea random,a0 move.l #$bada55a0,d0 .lr addq.l #5,d0 rol.l d0,d0 move.l d0,(a0)+ dbf d1,.lr ![]() Last edited by ross; 23 November 2020 at 21:51. |
![]() |
![]() |
#38 | |
Registered User
![]() Join Date: Jun 2016
Location: europe
Posts: 298
|
Quote:
![]() I tried it with this seed (literally 2x faceroll): 25434<<16+16514. Plugged that in and repeated 320*256/16 times. It's important to use words when writing to bitplane (e.g. move.w d7,(ax)+)!! Looked pretty ok-ish. Then I increased the accuracy and replaced swap d7 with rol.l #1,d7 (+6 cycles) and it looked noticably better. I guess the problem was using longwords, that won't work good. IIRC, I mentioned I was generating 16-bit numbers. If not, my bad for not being more specific. |
|
![]() |
![]() |
#39 | |
Lemon. / Core Design
![]() Join Date: Mar 2016
Location: Tier 5
Posts: 887
|
Quote:
![]() ![]() Of course, the random screen noise we (or at least a lot of us) used back in the day (ie in the credits of Madness 2), was generated by drawing a couple of blitter lines from y = 0 to y = 255, with random x coordinates, then blitter filling the buffer.. and repeat that each frame without clearing the buffer... that generated a really good and convincing noise effect. It got me thinking recently if that method could be used to generate (for example) a 256 byte random number table each frame |
|
![]() |
![]() |
#40 |
OCS forever!
![]() Join Date: Mar 2019
Location: Birmingham, UK
Posts: 345
|
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Serial Numbers vs QC numbers question | 005AGIMA | support.Other | 1 | 05 January 2020 14:53 |
Fast floating-point random numbers | Leffmann | Coders. Tutorials | 27 | 25 August 2016 02:59 |
Help needed!!Random octal numbers generator(asm) | sheryn88 | Coders. General | 6 | 01 August 2010 08:19 |
A nice quick small random numbers routine? | Photon | Coders. General | 2 | 20 December 2004 22:56 |
IP numbers | Squonk | project.WinUAE - Kaillera | 0 | 24 September 2003 14:12 |
|
|