Jump to content

Photo

Comparing variables to each other


2 replies to this topic

#1 atari2600land OFFLINE  

atari2600land

    Channel F Viewer

  • 11,301 posts
  • Location:Salem, Oregon

Posted Wed Dec 6, 2017 3:32 AM

I want to see if a variable has reached the value of another variable. How do I do this? This code won't work:

        ldy TongueYMoving
        iny
        sty TongueYMoving

        ldx ScreenDrawing
        cpx #TongueYMoving
        beq DisableBall


#2 carlsson ONLINE  

carlsson

    Metagalactic Mule

  • 7,128 posts
  • Location:Västerås, Sweden

Posted Wed Dec 6, 2017 5:01 AM

Skip the # as it indicates an immediate value, not a memory location.

 

  inc TongueYMoving
  ldx ScreenDrawing
  cpx TongueYMoving
  beq DisableBall ; branch if the two are equal

 

You might want another branch instruction depending on which circumstances the branch should occur.



#3 atari2600land OFFLINE  

atari2600land

    Channel F Viewer

  • Topic Starter
  • 11,301 posts
  • Location:Salem, Oregon

Posted Wed Dec 6, 2017 5:46 AM

OK. Thank you. I was about to say it didn't work, but then I got the other surrounding code changed and it does what I want it to now.






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users