Jump to content



1

comparing switches


5 replies to this topic

#1 Pioneer4x4 OFFLINE  

Pioneer4x4

    Stargunner

  • 1,724 posts
  • Atari + R.O.B. = Completed
  • Location:PA

Posted Wed Nov 30, 2011 7:40 AM

I want to change if my R.O.B. program uses Joysticks or Keyboard/Kids/Touchpad/Keypad controllers based on difficulty switches. One of my pet peeves is not knowing how they should be used, especially when different systems have different labels on them. So what I decided is if they are the same, use Joystick, if they are different, use keyboard. I will probably make switches un-needed anyway, but I wanted to ask about this code.




It seems I cannot use this code (or any variant I can come up with).


if switchrightb = switchleftb then (goto routine)

--- Unresolved Symbol List
0.switchleftb 0000 ???? (R )

but if I do this

if switchleftb then if !switchrightb then (goto routine)

if !switchleftb then if switchrightb then (goto routine)
It compiles and works.


I am ok, just curious if I missed somthing in the documentation.

#2 jbs30000 OFFLINE  

jbs30000

    Moonsweeper

  • 459 posts

Posted Wed Nov 30, 2011 7:52 PM

Just a guess, but I'm guessing that switchleftb and switchrightb are bits, or at least they're acting like working with bits.

What I mean is, you can't go if a{1}=b{1} for example, but you can go if a{1} then if !b{1}.

#3 Pioneer4x4 OFFLINE  

Pioneer4x4

    Stargunner

  • 1,724 posts
  • Atari + R.O.B. = Completed
  • Location:PA

Posted Wed Nov 30, 2011 8:36 PM

I guess that is what is happening. And that is what I did to get around it. (I had to check each way).

#4 RevEng ONLINE  

RevEng

    River Patroller

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

Posted Wed Nov 30, 2011 9:04 PM

switchleftb and switchrightb aren't real variables, even though they look like they are.

When bB sees them in a simple if-then command, it creates some conditional logic that tests bits in the 2600 SWCHB hardware register. But if you try to use them in other ways bB doesn't even try to catch it, and your code winds up referencing them as variables that don't exist.

If you want to check if both difficulty switches are the same, you can check the top two bits of SWCHB yourself. Something like the following should work...

temp1=SWCHB&%11000000
if temp1=%11000000 || temp1=%00000000 then (goto routine)


#5 Pioneer4x4 OFFLINE  

Pioneer4x4

    Stargunner

  • 1,724 posts
  • Atari + R.O.B. = Completed
  • Location:PA

Posted Wed Nov 30, 2011 9:50 PM

View PostRevEng, on Wed Nov 30, 2011 9:04 PM, said:

switchleftb and switchrightb aren't real variables, even though they look like they are.

When bB sees them in a simple if-then command, it creates some conditional logic that tests bits in the 2600 SWCHB hardware register. But if you try to use them in other ways bB doesn't even try to catch it, and your code winds up referencing them as variables that don't exist.

If you want to check if both difficulty switches are the same, you can check the top two bits of SWCHB yourself. Something like the following should work...

temp1=SWCHB&%11000000
if temp1=%11000000 || temp1=%00000000 then (goto routine)
Sounds good, thanks. I may try that if I clean it up for extra space. I'm down to about 200 bytes and it doesn't do much other than flash and update playfields ;-) (But it does work!)

#6 bogax OFFLINE  

bogax

    Star Raider

  • 61 posts

Posted Sun Dec 4, 2011 2:37 PM

Similar thread

http://www.atariage....-are-different/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users