gbennett0321 Posted February 9, 2018 Share Posted February 9, 2018 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 Quote Link to comment Share on other sites More sharing options...
Mountain King Posted February 9, 2018 Share Posted February 9, 2018 (edited) 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 February 9, 2018 by Mountain King Quote Link to comment Share on other sites More sharing options...
bogax Posted February 9, 2018 Share Posted February 9, 2018 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 Quote Link to comment Share on other sites More sharing options...
gbennett0321 Posted February 9, 2018 Author Share Posted February 9, 2018 (edited) 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 February 9, 2018 by gbennett0321 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.