@roondar:
okay, your example was quick and dirty
But your example is more expressive than my writings
You can optimize a lot in your example:
If this is run in a loop, you can put all constants to free data registers and save 8 cycles.
Anoter approach is, you could avoid a lookup tables, if the collision map width is a power of 2, e.g. use a map-width of 64 instead of 40 or 32 instead of 20. And use instead a single shift instruction. Yes, this will also consume a lot of time.
We are going d'accord that for a single player object it is not beeing worth. On the other side you may have many bullets, that also need a collision detection with background and enemies. And depending on the design enemies could also interact with other objects or background. Then you have to do the calculation to a screen map anyways.