Is that routine used by the random generator (so I can have it "for free" now...)?Dbug wrote:As a benefit now we also have a 32 bit multiplication routine in the osdk.
Mordoric
What routine did you use (that did not work)? Just curious. I used several different ones.Nox wrote:Well, of course it's a bit unfair to compare the size of a function with another one that does NOT work...
One is here: http://forum.defence-force.org/viewtopic.php?t=214
In skool daze I am using this small one:
Code: Select all
randseed .word $dead ; Will it be dead again?
randgen
.(
lda randseed ; get old lsb of seed.
ora $308 ; lsb of VIA T2L-L/T2C-L.
rol ; this is even, but the carry fixes this.
adc $304 ; lsb of VIA TK-L/T1C-L. This is taken mod 256.
sta randseed ; random enough yet.
sbc randseed+1 ; minus the hsb of seed...
rol ; same comment than before. Carry is fairly random.
sta randseed+1 ; we are set.
rts ; see you later alligator.
.)
- coco.oric
- Squad Leader
- Posts: 720
- Joined: Tue Aug 11, 2009 9:50 am
- Location: North of France
- Contact:
I've done a research about that routines 1 at 2 years ago.
Several statistical formulas have been listed in ceomag.
The code is in my repository :
http://miniserve.defence-force.org/svn/ ... t_divers.s
It's quite the same process that 4Kong but a little bit quicker.
Several statistical formulas have been listed in ceomag.
The code is in my repository :
http://miniserve.defence-force.org/svn/ ... t_divers.s
It's quite the same process that 4Kong but a little bit quicker.
; ----------------------------------------------------
; _GetRandomize()
; Generate a somewhat random repeating sequence. I use
; a typical linear congruential algorithm
; I(n+1) = (I(n)*a + c) mod m
; with m=65536, a=5, and c=13841 ($3611). c was chosen
; to be a prime number near (1/2 - 1/6 sqrt(3))*m.
;
; Note that in general the higher bits are "more random"
; than the lower bits, so for instance in this program
; since only small integers (0..15, 0..39, etc.) are desired,
; they should be taken from the high byte _Random+1, which
; is returned in A.
; -----------------------------------------------------
coco.oric as DidierV, CEO Member
Historic owner of Oric, Apple II, Atari ST, Amiga
Historic owner of Oric, Apple II, Atari ST, Amiga
Yes, it's a part of the formula of the rand routine.Nox wrote:Well, of course it's a bit unfair to compare the size of a function with another one that does NOT work...
Is that routine used by the random generator (so I can have it "for free" now...)?Dbug wrote:As a benefit now we also have a 32 bit multiplication routine in the osdk.
Anything can be faster than 4KKong, I was trying to make a small game, not a fast onecoco.oric wrote:t's quite the same process that 4Kong but a little bit quicker.
Chema wrote:What routine did you use (that did not work)? Just curious. I used several different ones.
I used the "short version" from this page
http://6502.org/source/integers/random/random.html
It's also a "a=a*b+c mod d"-type function.
I tried several start-seeds, but after 10-20 iterations it starts returning the same number again and again.
- coco.oric
- Squad Leader
- Posts: 720
- Joined: Tue Aug 11, 2009 9:50 am
- Location: North of France
- Contact:
I didn't try to make it faster.Anything can be faster than 4KKong, I was trying to make a small game, not a fast one
Simply, researching the random formulas, i found the way of determine the 3 parameters of the random routine and using 5 to multiplicate is easier to code than other better parameters.
coco.oric as DidierV, CEO Member
Historic owner of Oric, Apple II, Atari ST, Amiga
Historic owner of Oric, Apple II, Atari ST, Amiga
mordoric.tap V0.3 21.01.2012
Store 99% done, Character creation 95% done.
Spent much time on content, but not feeling very creative currently...
Noticed that sometimes it takes less bytes to just store information uncompressed, wasting a few bits here and there,
but saving all those shifts and ands to get the needed value.
Still a few things to do before I can create some monsters and put all those fine hand-crafted weapons to work...
Store 99% done, Character creation 95% done.
Spent much time on content, but not feeling very creative currently...
Noticed that sometimes it takes less bytes to just store information uncompressed, wasting a few bits here and there,
but saving all those shifts and ands to get the needed value.
Still a few things to do before I can create some monsters and put all those fine hand-crafted weapons to work...