Jump to content
IGNORED

Rand problem in multibank programs


jbs30000

Recommended Posts

I seem to be running into a problem using rand in a multibank game. In the first Tron, in the grid spiders game, I had 6 grid spiders that moved around using rand, yet, when I integrated the game into the main Tron game, which uses 14K, all of a sudden rand didn't work any more and the spiders just stayed in the same location.

 

In my second version of Tron that I'm working on, so far using 8k, I'm trying to use rand when the timer in the main screen runs out to choose a game for the player. However, every time I test this out, the same game allways gets chosen.

 

Is this a known bug or something? It doesn't make any difference if I use set optimization inlinerand either.

Link to comment
Share on other sites

I seem to be running into a problem using rand in a multibank game. In the first Tron, in the grid spiders game, I had 6 grid spiders that moved around using rand, yet, when I integrated the game into the main Tron game, which uses 14K, all of a sudden rand didn't work any more and the spiders just stayed in the same location.

 

In my second version of Tron that I'm working on, so far using 8k, I'm trying to use rand when the timer in the main screen runs out to choose a game for the player. However, every time I test this out, the same game allways gets chosen.

 

Is this a known bug or something? It doesn't make any difference if I use set optimization inlinerand either.

If I understand it correctly, the initial value of rand is always the same when you play a game on an emulator, but it will be different when you play a game on a real 2600. A way to get around this is to call the rand function once on every frame during your title/menu screen, so that when the player chooses a game, the rand variable will contain a different value.

 

As for using rand in a bankswitched game, it shouldn't make any difference, although it depends on how you're using rand. For example, I posted a "get_rand" function that can be added into a game to return a random value within a specified range-- e.g., "x = get_rand(1,6)" to get a random value between 1 and 6 inclusive-- but if you're going to call that function from different banks, you'll need to specifiy the bank, but I'm not sure how that should be done-- e.g., "x = get_rand(1,6) bank2"?

 

Michael

Link to comment
Share on other sites

atari2600land basically I use a timer to count down from 9 to 0 and then jump to a sub that uses rand to choose a game. The code for the routine is:

TimerChoose

b = rand

if b <= 64 then goto ChooseUp

if b <= 128 then goto ChooseDown

if b <= 191 then goto ChooseLeft

if b <= 255 then goto ChooseRight

 

SeaGtGruff That's very interesting, and good to know. Since I only use an emulator I will do multiple instances of rand. Thanks.

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...