FM register log

Page 2/2
1 |

By iamweasel2

Paladin (667)

iamweasel2's picture

29-11-2020, 18:29

I was wondering, this type of replayer (where you keep reading the register and the data to be sent to the register in a loop), of course you need more space to store the data (if you don't compress it), but is it too ineficient to be used in a game, for instance? What would be the best way (in terms of CPU cycles spent) to play music in a game?

By Grauw

Ascended (9490)

Grauw's picture

30-11-2020, 01:17

I would say this type of replayer (stream of register write commands) is the most efficient in terms of speed, however inefficient in terms of space. Space efficiency is improved if you compress the data.

I think for a 32K game with PSG music that isn’t too lengthy, you could use it if the game itself is not too tight on space and if it really needs the extra performance. Otherwise, probably an MML-based or tracker-based format will probably be a better choice.

For a MegaROM game, I think space is not an issue.

For a disk game, disk space itself is not an issue, but since it typically needs to fit in RAM together with level data and gameplay code, it’s somewhere in the middle between the two. It’s not a perfect fit but not a terrible one either.

Aside from speed there are other advantages, for example because of the generic nature of the format you can make music in any way you want, regardless of whether a replayer is available.

I’ve recently investigated compression by adding “subroutines” to the sound data for repeating sections. The idea is to automate the optimisation done in MML or a tracker by hand. It does not need RAM to decompress to. The compression seems pretty good, but it’s hard to give exact predictions because it depends on how much repetition the sound data has. You can see in the percentages on that link that it varies a lot. The sound data I tested is quite short so has limited repetition, suggesting that greater gains can be made, but is also not very complex, suggesting that it is quite optimisable.

I should probably do a comparison with the equivalent tracker or MML sound data. Also, in my code I do the compression on the whole sound data. Possibly the effectiveness of the compression could be increased by having a separate stream per channel. However this would reduce the performance.

Page 2/2
1 |