Hello Again,
I want to make a demo where a ball bounces back and forth up and down through the screen randomly. Would i use sprite 0 hit to make the ball change directions once it has reached the screen borders or use Y and X cordinates with branches.
Thanks
EL
No
Sprite 0 Hit is typically used for raster effects, like knowing when the screen is rendering a certain scanline so you can split it. This is a more advanced area than you're ready for.
So no, you would not use Sprite 0 hit for that. For that, you would just check the ball's X,Y position and change it's direction when it got too large/small.
Not even if you wanted would you be able to use the sprite hit flag for that. As the name says, it's just a flag: sprite hit background or sprite didn't hit background (hit means that a solid pixel from the sprite and a solid pixel from the background trying to be displayed at the same screen pixel - doesn't matter who wins, wich depends on the priority of the sprite).
The only way to use that in your favour is if you draw a border around the screen using only solid colors (colors 1, 2 or 3) and keep a big rectangle in the middle of the screen using color 0, so that when you detect a hit you know the sprite hit the border. But you still wouldn't know wich border (there are 4 of them, right?), wich means you wouldn't know whether you have to change the horizontal or vertical movement of the object. For that you'd have to check it's coordinates anyway, wich means it's much better to do it only by checking the coordinates. This is not what the hit flag is for.
Also, if you don't use sprite hits for this, you can draw a nice background behind the moving object, something you couldn't if using sprite hits.
Compare sprite coordinates to the border X/Y, check the C flag with BCS/BCC and you can use that as a greater-than/less-than check, like it shows here:
http://www.6502.org/tutorials/compare_instructions.html