Jump to content
IGNORED

Help with seeding rand values in DPC+


gbennett0321

Recommended Posts

I am working on a DPC+ BB game, and would like to seed the random number generator so I can reproduce the same ordered sequence of random numbers. If I set (seed) the standard 'rand' variable in a non-DPC+ kernel, the 'rand' call always return the same ordered random results as predicted. However, when seeding the 'rand16' variable I was unable to generate a predictable random sequence.

 

Now that I have moved to the DPC+ kernel, I have no idea how to seed its 32-bit rand value (or if it is even possible). I tried assigning rand to a seed value, but it doesn't appear to have any effect on the random sequence.

Does anyone know how to seed the DPC+ rand variable to generate a predictable random sequence?

 

If I can't seed the DPC+ rand value, is it somehow possible to use the standard 'rand' call in a DPC+ build (which does appear to work as expected)?

 

Any help would be appreciated.

 

GB

Link to comment
Share on other sites

I sequenced my trees in The Terrible blizzard of firn by calling an empty data table.

 

h=otree[p]

 

p was the screen counter.

 

Then otree looked like this.

 

data otree

end

 

I found it would populate the same values in the same order every time.

 

I'm not sure if that helps you, but that's how I did it.

Edited by Mountain King
Link to comment
Share on other sites

from the DPCplus.h file

 

;----------------------------------------
; Random Number Initialization
;----------------------------------------
; The random number generate defaults to a value that spells out DPC+.
; Store any value to RRESET to set the random number back to DPC+, or you
; can use RWRITE0-3 to change the 32 bit value to anything you desire.
;
; reset random number
; LDA #0
; STA RRESET
;
; set a specific random number (spells out 2600)
; LDA #$32
; STA RWRITE0
; LDA #$36
; STA RWRITE1
; LDA #$30
; STA RWRITE2
; STA RWRITE3
;
; NOTE: do not set all 4 bytes to 0, as that will disable the generator.
;----------------------------------------
RRESET DS 1 ; $70
RWRITE0 DS 1 ; $71
RWRITE1 DS 1 ; $72
RWRITE2 DS 1 ; $73
RWRITE3 DS 1 ; $74
Link to comment
Share on other sites

 

from the DPCplus.h file

 

;----------------------------------------
; Random Number Initialization
;----------------------------------------
; The random number generate defaults to a value that spells out DPC+.
; Store any value to RRESET to set the random number back to DPC+, or you
; can use RWRITE0-3 to change the 32 bit value to anything you desire.
;
; reset random number
; LDA #0
; STA RRESET
;
; set a specific random number (spells out 2600)
; LDA #$32
; STA RWRITE0
; LDA #$36
; STA RWRITE1
; LDA #$30
; STA RWRITE2
; STA RWRITE3
;
; NOTE: do not set all 4 bytes to 0, as that will disable the generator.
;----------------------------------------
RRESET DS 1 ; $70
RWRITE0 DS 1 ; $71
RWRITE1 DS 1 ; $72
RWRITE2 DS 1 ; $73
RWRITE3 DS 1 ; $74

 

Thanks, that's exactly what I need. I stupidly didn't even bother to look at the assembly code.

 

GB

Edited by gbennett0321
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...