Yeah the time it takes has no meaning, it is not thought to be used on an interpreter.
The point is that code made in plain BASIC is most widely understood.
The only feature used is INP and OUT, it is easy to get the 9990 in all the kun, pascal, C.
Once the gosubs are ported the rest of the whole game goes without OUT.
It almost takes a minute... drawing that first object takes a lot of time.
About 4 seconds when using MSX-BASIC-kun... (after adding the variable names after "NEXT").
Anyway, you can easily try this in openMSX, e.g. with Boosted MSX2 EN, it has Video9000/GFX9000 included. Just run the program in it.
I bet there's a lot of time being wasted because the FOR loops variables are being treated by BASIC as Double precision numbers when they only needed to be integers. its a matter of one "DEFINT A-Z" on the top of the program to get a slight but perceptive increase of speed.
DEFINT A-Z only gets slight extra speed? In my experience, it works wonders.
Yes @JohnHassink, when there are FOR loops with lots of repetitions, a simple DEFINT A-Z works wonders... But you actually have to be dealing with integer numbers being stored as double precision numbers to it works. One thing I often do is write BASIC programs that draw graphics using trigonometric functions... DEFINT A-Z won't help getting any speed here, and there's no words to express how slow those programs are.
tvalenca, please excuse me if this is a dumb question, but is there any circumstance in coding a game (for MSX/8-bit) that requires using double precision or "floating points" at all? I always thought those types were only meant to make "serious" programs.
Not that I'm aware of. But, and there's always a "but", you may want some NPC (or screen object) to move not on a straight line. this would lead to a quadratic or trigonometric function.
anyway, I just got used to add a "DEFINTA-Z" whenever I'm starting a BASIC program. Feels odd to not do this.
You can almost always use integers as fixed point if you want to avoid floating point. Although due to the lack of shift operators in Basic, I guess having to use divisions and multiplications in stead to change between integer and fixed point is a bit suboptimal.
DEFNIT A-Z on turbobasic makes real wanders.
It does not only accelerate the FOR loops but all mathematical calculations as long as those are done with integers.
This is why I try to find solutions with integer calculations as much as I can.
Anyway, if you need a non-integer variable in particular, you can DEFINTA-Y and you can use Z as you wish.
The times I gave were including the calculation and drawing of the shape. The actual copying is quite fast. Just try it to see for yourself.
I am on it