I love basics
Yes pretty much that's what is needed: Initialize, Load, Play, Stop, Destroy - as you you have done it
Well if this is going to be use in an editor, I assume you'll need a way to swap out chunks of memory, too. So I'll have to work that in.
- what type is spc param?
It's just a generic pointer. It is returned from spc_initialize. Internally it holds the state of the SPC player. You can think of it as an instantiation of the player.
I assume Pascal has a way to hold generic pointers. If not, you should be able to treat it as a 4-byte integer and it'd work the same:
spcplayer := spc_initialize(100)
- isnt it PASCAL defined already? and yes it is simply __stdcall
It is not defined in the C/C++ language. It's only defined by certain headers (notably <Windows.h>).
You don't have to manually define it if you include one of those headers -- but I don't like making assumptions when writing libraries.
- Can I use that DLL (after tests) for: this project
I added an updated version to the github which allows for basic volume control (since normal playback volume seems a bit quiet).
100 = normal volume
200 = 2x volume
50 = half volume
Now that I've done that, I'd like to start looking at FF4 specific stuff in particular to see if I can figure out what needs to get loaded into the SPC unit for proper playback. Since you're making an editor, I assume you have information on where some of this info is stored in the ROM.
Can I get you to share your notes with me? Any information you have would be helpful.
By examining and tinkering with the SPC files, I think I've figured out how the game partitions SPC memory:
RAM locations, add $100 for file offsets:
$0000-07FF = workspace RAM
$0800-1DFF = music engine code
$1E00-1EFF = Instrument pointer table A
$1F00-1FFF = Instrument pointer table B (changes per song?)
$2000-2FFF = Score Data
$3000-9BFF = Instrument Data B
$9C00-B2FF = ??? (more space for instrument data B?)
$B300-CA6F = ??? no idea, but seems to be fixed/unchanging between songs
$CA70-CFFF = Instrument Data A
$D000-F7FF = Echo buffer
$F800-FFFF = Some kind of data used by the engine (there's a lookup table that points to it)
The game seems to have 2 sets of instruments. "Set A" seems to be instruments that are common to all songs (trumpet, strings, etc), whereas "Set B" seems to change between songs and I would guess also includes sound effects.
I'll look at the music engine later to see if I can find a stable entry point. If I can find one, playing songs will just be a matter of filling in instrument data, score data, and hitting play.