English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 20 December 2004, 21:34   #1
Photon
Moderator

Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 4,908
A nice quick small random numbers routine?

Hi!

Wrote a routine to generate random numbers (0-65535). I start with a weird number for seed, I eor that with another weird number that changes for each time. Then I save the new seed, take it, divide by a weird number and take the modulo. I thought that would confuse it enough to make nice random numbers, but when I plot them a pattern shows up (the same number comes up several times in the number table).

Anybody have a nice little Really Random Number Generator (in 68000 Assembler of course)?

In that case, please share thy knowledge!
Photon is offline  
Old 20 December 2004, 22:07   #2
Codetapper
2 contact me: email only!

Codetapper's Avatar
 
Join Date: May 2001
Location: Auckland / New Zealand
Posts: 3,165
Post Worth a try

Dunno how random this code is but I've seen it (or variants of it) in quite a few Amiga programs. Give it a try anyway:

Code:
_RandomWord	bsr	_RandomByte
		rol.w   #8,d0
_RandomByte	move.b  $dff007,d0
		move.b  $bfd800,d1
		eor.b   d1,d0
		rts
Obviously d0 contains the "random" word after it's finished, d1 is destroyed.

Last edited by Codetapper; 20 December 2004 at 22:14.
Codetapper is offline  
Old 20 December 2004, 22:56   #3
lloyd
Mehh :D
lloyd's Avatar
 
Join Date: Nov 2004
Location: Bristol, SW UK
Age: 58
Posts: 242
May be able to supply something in Z80.... Is it easy to convert Z80 assembler to 68K? Never tried 68K so wouldn't know.
lloyd is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed!!Random octal numbers generator(asm) sheryn88 Coders. General 6 01 August 2010 08:19
Need help coding small routine kipper2k Coders. General 5 19 May 2009 17:02
small but nice platform games s2325 Retrogaming General Discussion 6 30 August 2007 08:04
Keyboard routine BippyM Coders. General 2 15 July 2007 13:15
Looking for some routine code Akira Coders. General 4 18 December 2003 00:51

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 13:36.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.06122 seconds with 13 queries