Translate

Thursday, April 5, 2018

Some Basics 4 MSX Basic ( part 1)

And here is part 1 of my programming tips and trick, in the serie Some Basics 4 MSX Basic. 

Problem: Checking firebuttons

Solution: Using IF THEN and GOTO, instead of ON STRIG GOSUB and STRIG ON
 
Example:
 
10 PRINT "Press FIRE"
20 IF STRIG(0) OR STRIG (1) THEN 40
30 GOTO 20
40 PRINT "FIRE !!!!"
50 END

This solution is easier than using ON STRIG, but if you use this routine more than once, 
you must insert a short sleep routine, like:
50 FOR T=1 TO 200: NEXT

Just to make sure it also wait the 2nd time for the fire button, otherwise it will skip the 2nd test and go on.
I use this trick often in the last posted 112 MSX Basic games, cause I wanted to play those games without pressing any key on the keyboard.

The routine checks only the spacebar (0) and firebutton 1 of joystick 1 (1), which is mostly
enough for all single player games.

No comments:

Post a Comment