Managed to get some sound. Here's how I got there.
Assets:
I assumed the test-piano.esf song was using the piano.eif instrument. Not much of a stretch, I know. I hoped that it only used one instrument. I have no idea what happens if you specify the wrong number of instruments (too many or too few) when attempting to play a song.
SGDK:
- To add those files to the project compilation, I added these parts to SGDK's makefile.gen. Should be obvious where to add them in the file.
Code: Select all
RES_EIF= $(wildcard *.eif)
RES_EIF+= $(wildcard $(RES)/*.eif)
RES_ESF= $(wildcard *.esf)
RES_ESF+= $(wildcard $(RES)/*.esf)
...
OBJ+= $(RES_EIF:.eif=.o)
OBJ+= $(RES_ESF:.esf=.o)
...
%.s: %.esf
$(BINTOS) -align 32768 $<
%.s: %.eif
$(BINTOS) -align 256 $<
As for the alignments, they're guesses based on the other types of resources in the makefile. If they require other/better values, let me know.
- SGDK's bintoc/bintos blindly take the filename and create type names with it. I had to rename the test-piano.esf to testpiano.esf because "test-piano" isn't a valid variable name.
Code:
- SGDK's makefile.gen only looks for a few spots for code. I wanted to keep Echo's code separate, but I had to bring it into the same folder as my project. No biggie.
- SGDK does not support <stdint.h> and uses its own types. Had to typedef the types that Echo required. If the SGDK had a define to identify itself (#define SGDK ?), Echo could simply check for it and adjust its types accordingly.
- The ECHO_LIST_* macros don't work, giving errors like:
main.c:67: warning: initializer element is not computable at load time
main.c:67: error: initializer element is not computable at load time
From what I could find, some versions of C support it while some don't. The version specified by default in SGDK does not.
So I had to build the array manually.
Code: Select all
unsigned char instrumentList[4];
instrumentList[0] = (((u32)piano >> 8) & 0x7F) | 0x80;
instrumentList[1] = (u32)piano & 0xFF;
instrumentList[2] = (((u32)piano >> 15) & 0x7F) | (((u32)piano >> 16) & 0x80);
instrumentList[3] = 0x00;
- echo_init has an infinite loop when it tries to copy the echo_blob. The "count" variable never gets decremented.
- Just to repeat, the echo_init function decleration isn't in the header file.
Running:
- The music plays in Gens and on hardware. Quite happy about that.
- The music plays even during scene transitions where I reload a fair bit of data. Also quite happy about that. SGDK's TFM playback required calling a function every frame and scene transitions were too slow to keep the music from stuttering.
- The initialization of Echo creates a short burst of static noise on both emulator and hardware. Unsure if that's normal. I'd say not.
Next Steps:
To create original music.
- If I understood correctly, Echo can play music on both the genesis and master system sound hardware at the same time. How do I setup tracks in OpenMPT to do that? Are there any example files I can look at? I've tried searching for mod/xm/whatever files that would be specific to the genesis, and formatted so that they can be used for Echo, but I have not found any.