don't click here

Valley Bell's SMPS Research

Discussion in 'Technical Discussion' started by ValleyBell, Dec 31, 2013.

  1. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    As the readme says, you need to press 'V' to turn VGM logging on/off. It doesn't start logging immediately though, but it begins when you play the next song.
    Each VGM will be named after the SMPS file that is logged.
     
  2. Herm the Germ

    Herm the Germ

    Hmm, not bad. Well done, doctor! Member
    1,482
    0
    0
    Dresden, Saxony, Germany
    MIDI-to-SMPS-conversions, mostly. Takin' requests, too.
    So here's a bit of an odd question - after the advent of Z80-exclusive SMPS being run, was there any reason why some games opted to use 68k SMPS, anyhow? (even some 32X games) Far as my limited understanding goes, leaving the audio processing to the audio co-processor would free up cycles for the main to do other fancy stuff, wouldn't it?
     
  3. Clownacy

    Clownacy

    Tech Member
    1,053
    581
    93
    Why'd Sonic 1 opt for SMPS 68k? Ristar had a pretty good reason: freeing the Z80 so it can do some advanced DAC work, but Sonic 2 showed that Sonic 1 had nothing to lose but DAC playback quality, which it didn't seem to prioritise in the first place.
     
  4. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    Back when Sonic 1 was developed, SMPS 68k was the only way to have SMPS with DAC drums.
    Sonic 1 was released 1991-06-23, the first SMPS Z80 game with support for DAC drums was Alien Storm, released 1991-06-28. (Though "Mercs" actually looks like it uses an earlier version of SMPS Z80 DAC code-wise.)

    For the later games, I'd say SMPS 68k vs. Z80 is a pure design choice.
    SMPS 68k has the advantage of cleaner DAC samples though. Most SMPS 68k drivers are programmed so that they have minimal Z80 stops. (Stopping the Z80 during DMA operations makes up for it though, I guess.)
    The DAC driver that is used with most SMPS 68k games also allows you to have tons of samples using a few simple tricks. Games like Crayon Shin-Chan used those a lot. (97 voice samples, about 700 KB, and they sound pretty clean during the cutscenes)
     
  5. ICEknight

    ICEknight

    Researcher Researcher
    I have a few questions regarding the current SMPS releases and SMPSPlay:

    -Any clues on why some of the ESWAT music tracks don't make the loop count go up even when they're clearly looping? Do they have a hidden Totaka-ish easter egg play at a certain crazy number of loops or something?
    -Why do a few games like Moonwalker not play the digitized samples? Is it just a bug in the current version of SMPSPlay?
    -Are there any plans for making any "full" releases with the sound effects included as well?
    -Is there a way to prevent the "dumps" folder from being created when SMPSPlay is run?
    -The "automatic progressing" option is a pretty neat thing as it sometimes seems to create a "Sonic-esque" seamless medley of songs. Would it be possible to have an option for automatically activating it from the ini file?
    -Also, having an ini option (and in-program key toggle) for fading out right when the "automatic progressing" kicks in would be a cool addition for "regular" listenings, I guess. Okay, that wasn't a question. =|
    -I was wondering, since the SGC music dumps are also direct rips, would it be technically possible to convert them to a format that could be played in SMPSPlay and vice versa?

    I think Kevtris said he ripped the music in all of those 300+ SMS/GG/Coleco games automatically so he may have used a similar tool to yours, perhaps you guys could join forces on this or something. =P
     
  6. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    I think the drum track has a weird loop that doesn't match the other tracks. This is the case for BGM2.
    Because there is no explicit "loop start" flag, the loop detection can sometimes go wrong, especially when the F6 jump ends up at a byte that's also used by F7 loops.

    That's because due to the way it works in SMPS 68k. The SMPS file adds a certain Sound ID to the sound queue (indicated by SMPSPlay showing "Queued Sound ID xx on Channel yy at zzzz"). It's done in the same manner as the game requests the sound driver to play music and sound effects.
    In order to make them work, I'd need to create a Sound ID -> song/SFX/DAC map.

    No, I don't have plans to include SFX except for cases where I get requests for them. SFX pointers are included, so ripping the sound effects should be easy.
    Also I still haven't added an SFX-mode to SMPSPlay v2.

    No, there isn't at the moment. I maybe should create it when dumping the first VGM/WAV.

    I'll add that.

    I might add that.

    Ripping stuff for SGC is easier than for SMPSPlay, because you just need to identify the 16 KB ROM bank that contains the SMPS driver and all its data and copy that into the SGC. (And you need to find the "UpdateSound" routine, but that should be easy to find.)
    SMPSPlay does high level emulation, so I need to analyze the sound driver (the devs loved to change coordination flags) and extract the songs into separate files.
     
  7. PsychoMMS

    PsychoMMS

    Member
    2
    0
    0
    Argentina
    Sonic 1 Minus and Sonic 1 Plasmatic Emperors
    How to use a smpsconv exe?i don't understand why close the exe.
    Can you help me how to configure the exe aplication?
    And i got a question.Did you know about zyrinx sound driver and gems sound driver?
    Thanks for reading and i wait your answer,thanks.
    PsychoMMS
     
  8. Herm the Germ

    Herm the Germ

    Hmm, not bad. Well done, doctor! Member
    1,482
    0
    0
    Dresden, Saxony, Germany
    MIDI-to-SMPS-conversions, mostly. Takin' requests, too.
  9. PsychoMMS

    PsychoMMS

    Member
    2
    0
    0
    Argentina
    Sonic 1 Minus and Sonic 1 Plasmatic Emperors
    All right,I'm newbie on the forum,I'm working in a great project in smps music hacking anyway i will try read the link that you left me.
    Good Morning and thanks.
     
  10. evilhamwizard

    evilhamwizard

    Researcher
    1,392
    455
    63
    Hey ValleyBell, quick question.

    I looked at the early Revenge of Shinobi prototype and noticed that nothing seems to use PSG. Can the sound driver actually interpret the byte code in the sequence data to play it back?

    The reason I ask is that despite not using it at all, there are some bytes that go untouched during playback but it seems to be related to the PSG channel. For example:

    [68k]ROM:00075252 dc.b $F1, $34, $15, $15; 0
    ROM:00075252 dc.b $15, $E, $15, $15; 4
    ROM:00075252 dc.b $F3, 8, $F5, 7; 8
    ROM:00075252 dc.b 0, $10, $40, $90; $C
    ROM:00075252 dc.b $F6, $2F, $30, 6; $10
    ROM:00075252 dc.b 0, $F5, $2B, 0; $14
    ROM:00075252 dc.b $F5, $F, 0, $10; $18
    ROM:00075252 dc.b $40, $90, $10, $40; $1C
    ROM:00075252 dc.b $90, $10, $40, $10; $20
    ROM:00075252 dc.b $40, $A0, $F6, 2; $24
    ROM:00075252 dc.b 2, $E, 0, $F5; $28
    ROM:00075252 dc.b $10, 0, 8, $40; $2C
    ROM:00075252 dc.b $88, 8, $40, 8; $30
    ROM:00075252 dc.b $40, $90, 8, $40; $34
    ROM:00075252 dc.b 8, $40, $F6, 4; $38
    ROM:00075252 dc.b 4, $F, 0, $F6; $3C
    ROM:00075252 dc.b 3, 3, $2A, 0; $40
    ROM:00075252 dc.b 0, $F0, $A, $F1; $44[/68k]

    This seems to be data for "Terrible Beat". If the byte code is similar to the final, I do see PSG loop starts (F5s) and loop ends (F6s).

    There's a ton more like this as well, but most of it seems related to the lack of PSG playback...
     
  11. Clownacy

    Clownacy

    Tech Member
    1,053
    581
    93
    Speaking a little early, since this is my first time digging into this driver (it's a weird one, looks like SMPS 68k Type 1a, but modified), but it seems like the PSG code, while still there, is vestigial. Notably, while the FM and drum code specify that the coordination flags start at $F0 (which is correct), the PSG code still uses the original SMPS standard of $E0, so theoretically PSG coord. flag support is completely broken. The PSG's volume envelope list is also completely empty.

    ...And I just noticed, in the core PSG bytecode parser, what should be a simple call to TickMultipl_PSG instead branches straight into the middle of the FM bytecode parser (?!), so attempting to play anything on the PSG should make the driver blow up.

    Looking at them side by side, this actually looks like a bizarre missing link between SMPS 68k 1a and PreSMPS. I guess I shouldn't be surprised PSG isn't working; the thing's a mess. Even now, I'm noticing dead branches that used to be part of the now-removed pitch sliding mode. DAC support ain't great either: samples seem to be played via the first coord flag rather than by notes.
     
  12. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    I haven't looked at the prototype, but the final version of Revenge of Shinobi was intersting, as it isn't just somewhere between preSMPS and early SMPS 68k, but it was also modified to process Yuzo Koshiro's Mucom88 format (except with SMPS 68k-style header).
    That it plays Mucom also explains why the DAC stuff works the way it does. I assume it originates from the way the YM2608's ADPCM B channel is used - you set the sample via a command and the note defines the pitch. Streets of Rage (another SMPS 68k driver patched to play Mucom data) also handles DAC samples that way, btw.

    It's pretty interesting that at that time it wasn't too uncommon to hack the SMPS driver to play other formats. The games I know about are: Revenge of Shinobi, Streets of Rage, A Ressha de Ikou MD (uses SoR sound driver), Strider and Ghouls 'n' Ghosts.
     
  13. Kurausukun

    Kurausukun

    Member
    15
    0
    0
    Is it possible to use the SMPS Research Pack/SMPSPlay to edit the existing files in the pack? Specifically, I want to edit the file for S&K Sky Sanctuary very slightly--all I want is for the last note before the loop to continue on for a while instead of looping back--would this be feasible? I took a brief look at the SMPS format/commands, but to be honest I had a hard time matching the commands I saw on the page to the hex I was looking at from the .s3k file in the pack. Am I going about this wrong, or would it really be not trivial?
     
  14. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,735
    334
    63
    SonLVL
    It might be easier to edit the song in ASM format, although if you want to use it with SMPSPlay afterward, you'd have to assemble the song to binary format.
     
  15. Kurausukun

    Kurausukun

    Member
    15
    0
    0
    Thanks for the suggestion, that definitely looks a lot more friendly than working with hex. Two questions:

    1. Is there a guide on how to convert the ASM back to binary so it's usable? Or just a way of playing the audio; I don't actually need this to work ingame, I just need to get an audio dump of it.

    2. Is there a reference for SMPS ASM? I don't know what all of the commands mean; some of them seem obvious enough, but I'm not sure what all the hex values are for or what dc.b means for example. It would also be easier to test and find out myself if there were some way to reassemble them to binary.
     
  16. Kurausukun

    Kurausukun

    Member
    15
    0
    0
    Sorry for the double post (though it has been a while), but I have a new question--it seems like Icecap Zone Act 1 from S3K is inaccurate; those effects that play specifically in the left and right channel at the start of the song are supposed to play each time that part of the music plays, but it only plays correctly the first time. The second time, only the left side plays, and subsequent times, neither of them play. I tried different versions of SMPSPlay, but they all have the same issue, so maybe the problem is with the file? Has anyone brought this up before, or am I doing something wrong?
     
  17. Orangy Tang

    Orangy Tang

    Member
    15
    0
    0
    This is a really awesome resource, but I'm having problems understanding it all.

    I'm looking through the Gunstar Heroes rip (which seems to use SMPS68k/Type2b). I believe this also uses the generic z80 DAC driver. I've managed to extract the z80 binary myself, but is there a disassembled version of the generic DAC driver out there? There's game-specific DACs in the archive but I couldn't spot a generic one.

    The other thing is what's the difference between the 'DAC' and 'DAC_Voice' binary files? I'm guessing the DAC files are actually part of the z80 rom (eg. Rips/68k/Gunstar Heroes/DAC/DAC_81.bin). I assume the dac_voice and music files must exist in the main ROM since there's not enough space in the z80 rom for those as well.

    Thanks.
     
  18. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    Disassembled sound drivers are in "part 2" (DriverDisasm.7z). The generic DAC drivers can be found in Drivers/DACDrv/68k_DACDrv/GenericSMPS68k/. Disassemblies are game-specific, but if you look at them, they are all very similar.

    You are right about the "DAC" and "DAC_Voice" folders. DAC drums usually fit within the Z80's 8 KB of RAM. DAC voices and sound effects are a bit larger and read directly from the ROM.


    Thanks for reporting that! I checked what goes wrong and it turns out I made a mistake when porting the volume clipping code from S3K's sound driver. (Volume clipping is unique to S3K only, that's why I didn't notice it when listening to all the other SMPS stuff.)
    It will be fixed in the next release. (It's fixed by this Git commit.)

    (Sorry for the late response, but I wanted to check the issue before replying and kept forgetting to do so.)


    About SMPS ASM - you turn them back into binary files using an assembler. Basically you take the AS assembler from the S2/S3K disassembly and make it assemble a minimal Main.asm file that just includes some macros, the smps2asm include file and the ASM'ed SMPS file itself. It's been a while since I did this though.

    If you want to know what sorts of commands you can use in SMPS, you should check SCHG:Music_Hacking/DAC_Samples,_Coordination_Flags,_Game_Specifics,_and_Real-Time_Music_Editing, section "Coordination flags". The names for all commands are listed in the smps2asm include file.
     
  19. Orangy Tang

    Orangy Tang

    Member
    15
    0
    0
    Yeah, I found that eventually after I confused myself a few times. I've managed to decompile the Gunstar Heroes Z80 rom using the existing ones for reference, so thanks. :)

    Can I ask how you extracted the DAC banks from the z80 rom? Gunstar Heroes has DAC banks 81 to 88 (but missing 85 for some reason). How did you figure out where the boundaries between these are and what their ids are?

    .
     
  20. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    I extracted the DAC samples with SMPSExtract. It scans the complete game ROM for some magic bytes in order to locate the code that reads (or sets up) the DAC tables. (It also decompresses the Z80 driver where possible and scans that as well.)

    The trick there is, that samples which are stored in Z80 RAM have their own sample table (also in Z80 RAM) and begin with ID 81. Missing IDs in the file names indicate invalid samples OR that the ID reuses a previous sample (i.e. same file offset/length). The latter is the case for Gunstar Heroes' DAC 85. Just look at DAC.ini and it will become obvious.
    DAC voices have their own sample table(s) - one in every Z80 ROM bank (32 KB block of the main ROM) that contains DAC voices. The format of the file name for those is "DAC_BankID-SoundID.bin". (SoundID begins with 0 for each bank.)
    Getting the actual internal ID for DAC voices requires you to look at the DAC driver's Z80 code, but they often begin at ID 88.