Mallard Games Posted June 28, 2019 Share Posted June 28, 2019 (edited) I am having a small issue with my code. I am trying to get the duck to stop when it reaches the top after hitting the flyaway state. However no matter what I try the code gets ignored. Source Code Relevant section Any of you experts have any ideas on what's going on? Edited June 28, 2019 by Mallard Games Quote Link to comment Share on other sites More sharing options...
NoLand Posted June 29, 2019 Share Posted June 29, 2019 (edited) Near label "SkipReverseDuckXVelocity" you are missing a "#", what you mean is probably: ldx DuckState cpx #STATE_DUCK_FLYAWAY ... As is (cpx STATE_DUCK_FLYAWAY), you are comparing DuckState to the contents of address $02, which happens to be the collision register CXP0FB. Edit: This is really a common error and hard to spot, especially in your own code (this is a bit like proof reading your own text). As you are already using upper-case constants for those values, setting up a regular expression search in your text editor to find any of those missing "#" may be a good idea. E.g., \sSTATE_\w* meaning, we are searching for any words starting with "STATE_" and headed by a white-space character (like a blank). Any hit should indicate one of those hard to catch errors. (Alternatively, instead of using a regular expression, just search for " STATE_" [mind the blank!] with word-matching disabled. The regular expression is essentially the same, but matches both heading blanks and tabs. Moreover, you may extend it to match any of your constants at once, like \s(STATE|VALUE|POS)\w* ...) Edited June 29, 2019 by NoLand 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.