Posted: Fri Jul 10, 2020 10:39 am
Sometimes, you don't want any of those properties. That's why Crazy Dream 10 got an optional alternative random number generator, which is used in some caves. Speed should be very similar. If you want to analyze that as well, here is the code, which shouldn't be too hard to implement in any existing Boulder Dash engine, if you wish to experiment with it:
And this is the original Boulder Dash random number generator:
I set the seed with:
Of course, random_seed3 and random_seed4 don't have to be initialized with original C64 random, but since there is no need to have a separate initiator for them, I used that for both.
The bne is only there because I realized that the random numbers don't work when all bytes are zero, but I already had designed some caves by then, which would be all different without that bne.
Code: Select all
get_predictable_random_number_32_bit:
lda random_seed2
asl
asl
eor random_seed2
asl
eor random_seed2
asl
asl
eor random_seed2
asl
rol random_seed1
rol random_seed2
lda random_seed4
asl
eor random_seed4
asl
asl
ror random_seed3
rol random_seed4
lda random_seed1
eor random_seed3
rts
Code: Select all
get_predictable_random_number_c64:
lda random_seed2
ror
ror
and #$80
sta random_seed3
lda random_seed1
ror
and #$7f
sta random_seed4
lda random_seed1
ror
ror
and #$80
clc
adc random_seed1
adc #$13
sta random_seed1
lda random_seed2
adc random_seed3
adc random_seed4
sta random_seed2
rts
Code: Select all
set_seeds:
sta random_seed1
sta random_seed3
sta random_seed4
bne :+
inc random_seed3
: lda #$00
sta random_seed2
rts
The bne is only there because I realized that the random numbers don't work when all bytes are zero, but I already had designed some caves by then, which would be all different without that bne.







