Here are some little tips & tricks to mainly speed-up MSX-BASIC programs execution:
Try to use variable names of one character length.
Delete blank spaces between commands. The code will turn a mess; but it'll execute much faster.
Join as many BASIC commands in the same line.
Always use IF ... THEN [line number] or IF ... GOTO [line number] (fastest!). Never IF ... THEN GOTO [line number].
The most commonly used subroutines must be placed in the first lines of the program.
GOTO command will be preferably jumping forwards and not backwards.
Always use INT variables. You can declare a INT variable using DEFINT A-Z at the beginning of the program. Sometimes, if you directly specify the variable as INT using the % notator, although is not always true, you can try in your own program.
Always use NEXT instead NEXT [variable name]. Is at least twice faster!.
Try to use VPOKE instead PUT SPRITE. This way you can modify only the changed attributes (position if you are only moving the sprite).
Using the Text+SC2 mode, you can get the quality of Screen 2 graphics and the speed of text screens. To enter this mode you only need to add these commands:
Y en español:
Usar siempre que sea posible variables de un sólo caracter.
Nada de blancos redundantes. El código será ilegible; pero se ejecutará más rápido.
Meter todos los comandos BASIC que se puedan en una sola línea.
Usar siempre IF ... THEN [línea] o IF ... GOTO [línea] (la más rápida). Nunca IF ... THEN GOTO [línea].
Las subrutinas más usadas deben de estar al comienzo del programa.
Preferiblemente los GOTO se harán hacia delante y no hacia atrás.
Usar siempre que se pueda variables INT declarando DEFINT a-Z al comienzo del programa. A veces da mejores resultados el usar el caracter % para identificar a una variable como INT, es cuestión de probar en cada caso en particular, cual funciona mejor.
Usar NEXT en lugar de NEXT [variable]. Es casi el doble de rápida.
Usar siempre VPOKE en lugar de PUT SPRITE. Eso permite modificar únicamente el atributo que se quiere cambiar, no todos.
Si lo anterior lo unimos al modo híbrido texto+SC2, podremos hacer juegos en alta resolución con velocidad de uno en modo texto.