Bregalad wrote:
Something that immediately comes in my mind is to divide by 16 by shifting it right 4 times, then correct the thing to be divided by 15 instead of 16 by doing some trick to multiply the result by the fraction 16/15 in some tricky way that could be done in a table.
I thought of that too, and tried to find a way to do it for hours... without success, I posted the question here! =)
Quote:
Something else is repeated substraction by 15, but I don't think it's fast.
Yeah, that'd be too slow...
dvdmth wrote:
For example, if you want your level map to wrap vertically (instead of having hard boundaries at the top and bottom), you would normally have to restrict the vertical map size to a multiple of 15 blocks.
You have a good point, but that's not necessarily true... The level wrapping should not be related to the destination address of metatiles, but to the source address. In my design at least, it'd be no problem to, say, after vertical screen number 11 is processed, read screen 0 again as if it were screen 12. It would keep rendering just fine. I think this is just a matter of how you read/decode the level map.
Keeping a separate Y coordinate for the camera means using annoying compares to see if it falls into the "forbidden zone" that are the attribute tables, and fixing the value if it does. And as I see it, having two different variables with information that is extremely correlated could result in serious bugs if their updating isn't perfectly synchronized to each other.
I think I'd rather maintain only one variable, and have whatever is related to it calculated on the fly from it, as long as this does not impose a big performance penalty, which I don't think is the case.
I'm sure that having 2 variables is a valid way to go about this (as you said, it was used in commercial games with success before), but I'm feeling more comfortable with the other method.