Moonblaster file format doubts

Por jepmsx

Master (137)

Imagen del jepmsx

27-12-2021, 18:11

Hi!

I'm trying to understand the file format of a Moonblaster file. I've found that there is a wiki explaining the format (https://www.msx.org/wiki/index.php?title=Moonblaster_file_fo...). I've also created files with few notes to make it easier to understand the format, for example with only one note, with two notes, etc.

I have several questions:
1 - What does snglen mean? Is it song length? How many bytes is it made of? In my simple example, it takes the value 0xFF, which are the steps of the first pattern, but where is the information of the amount of patterns? And the order of these?
2 - And hipat*2? What does it stand for?
3 - what does 001-096 Note (data/12=octave, rest is note) mean? Are the the notes for each channel?

I have created one file with only a c2-note in first channel and another file with c2 in second channel. Both files are the same except for bytes 0x244 to 0x2dd where c2 has the values 0xea02, 0xfa02, 0x0a03 and the second file is the same adding 1 for the first byte 0xeb02, 0xfb02, 0x0b03, ...

I'm really lost oO . Any hint will be welcome

Login sesión o register para postear comentarios

Por Manuel

Ascended (18794)

Imagen del Manuel

27-12-2021, 21:13

As for 3, I guess it means 1 is the lowest note possible and 96 the highest note. There are 12 notes per octave, so apparently it supports 8 octaves.

Song Length is what you can see in the editor right?

Also note that there is a User format and another format. Make sure to save in User format to get the same file as described on that wiki article.

What are you going to do with the format?

Por ToriHino

Paladin (767)

Imagen del ToriHino

27-12-2021, 21:49

If it helps, you can take a look at the source code of RoboPlay (in the players folder there is a player for the MBM format (User and Edit mode): mbm.c and mbm.h).

Point 3 is indeed the note number per octave of 12 notes (so 1 is first note of first octave, 13 is first note of second octave, ...). Numbers above 96 stand for the various commands possible (See also mbm.h).

Por jepmsx

Master (137)

Imagen del jepmsx

28-12-2021, 07:15

I want to play Moonblaster songs for OPLL using Fusion-C, thus I can use it in my applications developed using sdcc.

I've used roboplay to try to understand how to play a mbm file. It is a great source because it does what I want to do but for the OPL4 and it is very well programmed. Unfortunately I haven't been able to fully understand it.

As it is explained in the Readme.md of the project, the players have to implement different interfaces to be used with roboplay. The ones that I'm interested in are load and update. In the load function the file is loaded and the header is charged, taking the values from the file. Then update is used for every next step in the player. In update there is the variable g_step_buffer that has the next line to be deciphered. The main problems that I have now are:
- Why is the length of g_step_buffer[13] (is it because there are 13 columns in moonblaster)?
- In which position of the file does it start?
I had hoped that comparing simple mbm files would shed some light, but I haven't succeeded. My first guess was that g_step_buffer would start after the header, but comparing the two simple files I've seen that they are the same until 0x244 and I haven't been able to match these addresses in the mbm file format explained in the Wiki.

I hope that after being able to know where this buffer starts, I would only need to follow the events that are done in the update and do the same for the OPLL registers: note_on_event, instrument_change_event, etc. And I think that these events correspond to the lines in the mbm file format that are described below the line Case: Pattern data, Music channels

Thanks Manuel for your explanation of that line, now I understand it, 001=C0, 002=C0#, 003=D0, ... , 013=C1, 014=C1#, 015=D1 ...

Por ToriHino

Paladin (767)

Imagen del ToriHino

28-12-2021, 11:02

Some anwers (hopefully Smile ):
- The length of g_step_buffer is 13 because this contains one fully decoded line:
9 FM channels followed by freq, volume and sample number and finally the command (like tempo, transpose, etc)
- It starts right after the header information, where the patterns are stored (filled in g_patterns). Based on these pattern numbers the correct parts of the song are selected. (Note that in EDIT mode the length of the pattern table is always fixed size, regardless the actual number of patterns used).
- The function next_song_position fetches the start location of a pattern which is decrunched into g_step_buffer (where g_step is the line number in the pattern).

Por jepmsx

Master (137)

Imagen del jepmsx

28-12-2021, 17:06

Thanks for your comments ToriHino. With yours and Manuel's hints I've investigated with new light the file format.

Comparing two files, I've seen that in my case (in edit mode) the notes start at position 0x2DA, that it corresponds to Case: Pattern data, Music channels and that the following bytes are the instructions for the first channel. In Moonblaster I have for the first channel C2-;-;-C3-;-;-OFF-;-;-;-;-C2-;-;-;-; (where I have written ; to indicate that there is nothing in that step of the 16 steps in the pattern) that it is translated in bytes in the code as 0DFE-FF-FF-19FE-FF-FF-61FE-FF-FF-FF-FF-0DFE. After observing this, I guess that after any command, it follows the byte FE. Am I right?

Now I see that in position 0x178 is the song length, so it indicates the number of patterns that the song is made of. Because I'm in edit mode, the length of the pattern table is fixed to 201 bytes. This is position 0x178+201 = 0x241. I assume that from 0x241 to 0x2DA is the space for the Pattern Address Table. Is it right?

Now I understand the 13 columns of g_step_buffer, roboplay is passing from a sequential data per channel to a sequential data per instant. Thus roboplay fills g_step_buffer with the right information per instant.