Jump to content



1

using variables as part of another variable


4 replies to this topic

#1 atari2600land OFFLINE  

atari2600land

    Quadrunner

  • 6,496 posts
  • All hail the zyzzyva!
  • Location:Salem, Oregon

Posted Sat Oct 15, 2011 1:50 AM

why can't I do this:
 p=(player0x-57)/4
 if o{1} && k>9 && a{p} then k=0 : l=0 : m=0 : n=0

and what is a workaround to it?

#2 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 20,923 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Sat Oct 15, 2011 3:53 AM

I thought curly brackets could only have 0 through 7 in them, representing the 8 bits?

#3 atari2600land OFFLINE  

atari2600land

    Quadrunner

  • 6,496 posts
  • All hail the zyzzyva!
  • Location:Salem, Oregon

Posted Sat Oct 15, 2011 3:59 AM

But what if, in my example, I make it so p can't be higher than 7?

#4 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 20,923 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Sat Oct 15, 2011 4:31 AM

View Postatari2600land, on Sat Oct 15, 2011 3:59 AM, said:

But what if, in my example, I make it so p can't be higher than 7?
This seems familiar. There is a possibility that SeaGtGruff or RevEng talked about this subject before.

#5 RevEng OFFLINE  

RevEng

    River Patroller

  • 2,011 posts
  • bit shoveler
  • Location:Canada

Posted Sat Oct 15, 2011 7:10 AM

View PostRandom Terrain, on Sat Oct 15, 2011 4:31 AM, said:

This seems familiar. There is a possibility that SeaGtGruff or RevEng talked about this subject before.
It might have been SeaGtGruff or batari... I don't think it was me.

The reason a variable doesn't work in a bit position check is that bB creates different assembly code lines depending on which bit position you've selected, in order to use the most efficient approach.

As a work-around you need to write your own more-flexible/less-efficient code to check the bits.

atari2600land, here's your original example with a flexible check...

  p=(player0x-57)/4
  temp1=bits[p]&a
  if o{1} && k>9 && temp1<>0 then k=0 : l=0 : m=0 : n=0
 
  data bits
  %00000001, %00000010, %00000100, %00001000
  %00010000, %00100000, %01000000, %10000000
end





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users