I am having difficulty mapping screen coordinates to nametable addresses (only the currently visible one). I have read http://forums.nesdev.com/viewtopic.php?f=10&t=14788 which is going the other way, but I am missing something apparently. Here is what I am currently trying. Ideas or psuedo-code are welcome!

Thanks Dwedit. Your response has helped me get closer to a solution. It seems that there is a bug in my implementation where when given the screen pixel coords (10, 145) I calculate the address as 0x2221 when it should be 0x2201. However, calculating the name-table address for (10, 161) and (10, 113) works as expected so its not a simple remove-an-ASL. Anyone spot something I am missing here; other than it being un-optimized?

Thanks for the reply. Yeah, for some reason the results are a little more correct without the extra ASL. However, either way the gap remains. The first screenshot has the correct number of ASLs and the second with one less. The goal is for the top left of each of the first three crystals to have an 'A'.

What is this "add" opcode you're using? Unless it's an alias/macro for CLC + ADC, the fact that the code works for some coordinates but not others could be because the shifts sometimes put ones into the carry, resulting in wrong values after the additions. ORA is still a better option than adding in this case, like dougeff said.

What is this "add" opcode you're using? Unless it's an alias/macro for CLC + ADC, the fact that the code works for some coordinates but not others could be because the shifts sometimes put ones into the carry, resulting in wrong values after the additions. ORA is still a better option than adding in this case, like dougeff said.

The add macro is from the cc65 macpack generic and is indeed CLC + ADC. I have done some more debugging and it might be a one off error in my collision checking; although, it is bizarre because the collision checks with solid blocks have been fine (using the same screen coords), but with crystals I am getting one off errors. Thanks for the reply!

Who is online

Users browsing this forum: No registered users and 4 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum