Jump to content



1

Playfield Bytes As Variables?


4 replies to this topic

#1 MausGames OFFLINE  

MausGames

    Dragonstomper

  • 851 posts
  • Location:MO, USA

Posted Mon Mar 3, 2008 9:54 AM

"If you do run out of variables, you can use four bytes from the playfield if you're not scrolling it"
This is from the bB 1.0 manual; Can anyone explain what it means? I always run out of variables, and four more would help some.

Anyone have any other tips on how to get more than the standard 26? I'm using the standard kernel, with pfheights as the only option.

Edited by MausGames, Mon Mar 3, 2008 9:56 AM.


#2 potatohead OFFLINE  

potatohead

    River Patroller

  • 3,655 posts
  • Location:Portland, Oregon

Posted Mon Mar 3, 2008 10:52 AM

You can use some of the temp variables. I think it's temp2,3,4, if you are not scrolling.


How are you using the standard 26?

Are some of them holding smaller values?

If so, you can pack things in to get better use of the standard ones.

One real savings is true / false variables. So you use a whole 8 bit variable to indicate something is either gonna happen or not. Well, that can be done with just one bit of that variable, turning it into 8 true / false variables. Go and look through the manual for the bit operators. You can test, set and reset individual bits.

Another pretty good savings is breaking a variable into two. So, you've got some values that range from 0 to 15. That's 4 bits. You can pack two of those values into one 8 bit variable as well.

Finally, go through and look hard at your variable usage. Are there things that you could double up on, such as counters?

Maybe one variable would actually work, if you change the logic a bit.

#3 s0c7 OFFLINE  

s0c7

    Dragonstomper

  • 556 posts

Posted Mon Mar 3, 2008 11:13 AM

The more you decrease the resolution of the playfield, the more variables you get back.

In Cold War, I set pfres to 9 which gave me var0 through var11.

#4 MausGames OFFLINE  

MausGames

    Dragonstomper

  • 851 posts
  • Location:MO, USA

Posted Mon Mar 3, 2008 8:50 PM

View Posts0c7, on Mon Mar 3, 2008 12:13 PM, said:

The more you decrease the resolution of the playfield, the more variables you get back.

In Cold War, I set pfres to 9 which gave me var0 through var11.

That explains it, thank you.

#5 MausGames OFFLINE  

MausGames

    Dragonstomper

  • 851 posts
  • Location:MO, USA

Posted Mon Mar 3, 2008 8:52 PM

View Postpotatohead, on Mon Mar 3, 2008 11:52 AM, said:

Another pretty good savings is breaking a variable into two. So, you've got some values that range from 0 to 15. That's 4 bits. You can pack two of those values into one 8 bit variable as well.

There are many times when I use variables to always hold values of 15 or less, so that would be useful. Not sure how to implement that though.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users