After my initial success, I added a second song to the rom. To my surprise, it didn't work.
I added testflute.esf (it came from the Echo sample data, along with testpiano.esf) but then when I tried to play testpiano the testflute music would play instead. Really weird.
Just to make sure I wasn't crazy, I looked at the rom.nm file. Testpiano and testflute had different addresses, which was expected. Also double checked by printing their addresses at runtime. Their sizes are different and their data is different. So there's nothing obviously wrong there.
Then instead of making .o out automatically out of the esf, I created .c files manually using bintoc. The c code looked normal.
For example, testflute.esf converted to:
Code: Select all
extern const u8 testflute[0x0031];
const u8 testflute[0x0031] = {
0xFD, 0x40, 0x0C, 0x20, 0x00, 0xF0, 0xC0, 0x00, 0xA1, 0x4B, 0x11, 0x2B, 0x00, 0x0B, 0x04, 0xFE,
0x78, 0x10, 0x00, 0xA5, 0x1B, 0x0B, 0x04, 0xFE, 0x78, 0x10, 0x00, 0xAB, 0x1B, 0x0B, 0x04, 0xFE,
0x3C, 0x10, 0x00, 0xA9, 0xFE, 0x3C, 0x10, 0x00, 0xA5, 0x1B, 0x0B, 0x04, 0xFE, 0x78, 0x10, 0x1B,
0xFC,
};
It has the right size. I can only guess if the data is good, but I think it is.
This is how I do playback. I don't think it's anything out of the ordinary.
Code: Select all
echo_init(instrumentList);
echo_play_bgm(testpiano);
The only thing I can think of is that there's a problem with uploading the song to the Z80, but I can't really tell if that's the case.
Looking at the rom.nm file again, my Echo types have these addresses in the rom.
Code: Select all
00015f94 0000001d T piano
00015fb1 00000031 T testflute
00015fe2 00000148 T testpiano
Should Echo be able to access that data even if their addresses are over 64k?
Does esf data require any kind of alignment?
I'm starting to doubt that my initial successful playback was actually correct or if it was just a fluke. Thinking about it, the playback would glitch with static at the beginning, be silent for about fifteen seconds and then play. I'm thinking the data Echo was pointing to was wrong but accidentally stumbled upon valid song data going through memory. Just a guess, though.
EDIT: Additional information. Checking the status at the start of playback give me:
Code: Select all
*******************goplanes
Message : 0000000000032768 // this status means Echo is busy parsing the play music command
Message : 0000000000032768
Message : 0000000000032768
Message : 0000000000032768
Message : 0000000000032768
Message : 0000000000032768
Message : 0000000000000002 // this means Echo is playing a sound effect, which is weird since we said to play a music.
Message : 0000000000000002
Message : 0000000000000002
Message : 0000000000000002
Message : 0000000000000002
Message : 0000000000000002
Calling echo_play_sfx gives a status of 1. The states and the defines appear to be backwards.