...First, remove the B=BUTTON(), it's useless. Next, remove all the GOTOs! Things like X=X+1 should go in the IF statement, and the VSYNC 1 should go in the main loop... Talking of main loop, why do you enter it with a GOSUB? Remove that thing, too.