Is there a way to maximize the MSX speed?

By litwr

Resident (53)

litwr's picture

25-06-2020, 19:12

Is there some magic poke which allows us to get higher processor performance? For example, some of the 6502 based systems run faster when screen is off. Maybe changing the v-sync frequency in the MSX 2 affects the performance? Thank you

Login or register to post comments

By thegeps

Paragon (1122)

thegeps's picture

25-06-2020, 21:12

also on msx turning off the screen results in more speed. Changing vsync speed allow a faster screen refresh (but you have less time to do things every frame)

By syn

Prophet (2105)

syn's picture

25-06-2020, 21:48

depends on what kind of speed you have in mind.
afaik turning off screen gives you faster blitter copies but wont affect cpu time at all.

By Manuel

Ascended (19053)

Manuel's picture

25-06-2020, 22:52

On MSX the CPU doesn't have to share access to main RAM with the video processor. (On the other hand, it does have to share VRAM access with the video processor.)

By litwr

Resident (53)

litwr's picture

26-06-2020, 21:41

Thanks for some hints but is it possible to get some code which help maximizing the Z80 performance in the MSX? I just need to perform some math calculation as soon as possible.

By thegeps

Paragon (1122)

thegeps's picture

26-06-2020, 22:33

What do you mean? You need more speed using basic or assembly? Explain us your needs. You need to improve math speed in basic? There are some tricks, but you have to tell us what do you really need...

By pgimeno

Champion (322)

pgimeno's picture

26-06-2020, 23:25

Make your program for turbo-R, enable the R800. Or work on your algorithms so they are faster.

By bore

Master (147)

bore's picture

26-06-2020, 23:29

For pure calculations the thing that sets MSX2 apart from many other 8-bit platforms is that you have a lot of memory.
So if your code can run faster by using large tables then that is probably the way to go.
Apart from that there isn't really anything you can to more than optimizing your code.
At most you can turn off the vblank interrupt to save some cycles.

By ducasp

Hero (606)

ducasp's picture

27-06-2020, 01:49

litwr wrote:

Thanks for some hints but is it possible to get some code which help maximizing the Z80 performance in the MSX? I just need to perform some math calculation as soon as possible.

There are basically two things you can do:

- Disable Interrupts, if your code runs for long periods, might shave off a few time... But let's be realistic, not much, there 60 (or 50) interruptions on a second, even though not really fast, it will not save a lot of time
- Optimize your math code a lot... z80 ALU is not fast (it seems it is internally a 4 bits ALU), so, the basics, use the lowest count of bytes that you need, avoid multiplication and division like hell, if you can use look up tables or similar tricks to accelerate calculation, do it...
- Optimize your ASM code a lot as well... Sometimes you need to sit down with an opcode table and check if the advantage of using indexation is worth the extra cycles those instructions take... Try to use registers as much as you can... sometimes a JP is faster than a JR if the condition is usually met at the first time (JP always takes 11 cycles, no matter what, JR takes 13 cycles if condition is met and 8 if it is not met), it takes an extra byte of memory space though, but if the condition usually is met in the first check, it is 2 cycles.... Also it is wise to make the code in a path that it doesn't branch a lot in the happy day scenario... Branchings should be the exception, not the rule.

But, again, it is difficult to figure out how much you will be able to speed up your code, it will depend upon how optimized it already is, and how much more optimization can be done, but, one thing needs to be said, z80 is not the fastest 8 bit kid around to do math (probably Motorola 6811 is the fastest one)... If you can lower the precision and use look-up tables / pre calculation, that is the best way to speed up things... I remember trying several ways to do CRC routines and for 1024 bytes it was not exactly acceptable in my book, unless using lookup tables... Smile