Essentially, right now I have a 32 column area. I have a 16 bit camera position, which I can compare to an object's 16 bit position to know whether or not to give the object a draw status. This generally works, but I get the occasional edge case where the draw state flips on when the object should be firmly in the opposite nametable (one less in the high byte tan the camera position).
I also attempted to trying things with turning an object's position into a value out of 32, for a direct comparison with the camera's column. After a lot of edge case scenarios, this gave me similar unexpected false writes.
What methods do you guys use for things like this? How would you keep objects within a camera view? The 16bit idea above would be the most logical, wouldn't it?
It was hard for me to understand , but I spent much time rereading tepples' post over and over and then experimenting with my code trying to grasp his valid_left and visible_left. There was an end to my struggles, thankfully, after being blessed with fully grasping and implementing everything he talked about. Hope his post can help you too; tepples is so wise.
edit: Sorry, you are talking about objects... um I still haven't solved the only edge case reading problem that I still have... but, so far, the simplest way of checking an object's collision, that I've found, is to do something like this (labels beginning with + work in asm6... +skip can be changed to whatever type of label you want ):
Code: Select all
;if you are comparing two 16 bit values: lda column+0 eor objectX+0 bne +skip lda column+1 eor objectX+1 bne +skip ;code to run if the two 16bit values are equal +skip
0 xor 0 = 0
0 xor 1 = 1
1 xor 0 = 1
1 xor 1 = 0
Notice that the only results of 0 are when both bits are the same.
edit2: Sorry. Fixed misspellings from "lable" to "label". Also noticed that my code example didn't make any sense... why would we ever check object's location with camera's position... so those variable names have been updated so that it becomes helpful, I hope.
final edit: It doesn't make sense, to me, that the column should be 16bit... so I created two other variables columnLo and columnHi... and there are two translate functions that run depending on if the player is pressing left or right... each translate the column # to be drawn to columnLo and columnHi. They aren't posted here because they are very specific to our game.
There is no standard, there is no "this is the way it is done", there is no I'm doing this what am I doing wrong. It is 100% abstract and is what ever rules and maths you have come up with, we can't help you with anything specific unless we see ALL of your code, and I mean all of it. Typically when I stuff something like this up, I stuff up the easy part I assume is right and get all the hard maths correct. Due to spaces being collinear with each other, you can get the case where it is actually 100% wrong, but just so happens to look right 95% of the time.