vgmrips

The forum about vgm files
It is currently 2017-04-30, 5:13:55

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: DOSBox-VGM
PostPosted: 2017-01-05, 3:51:28 

Contributors Contributors
Offline

Joined: 2016-12-27, 3:21:40
Posts: 39
Attached find my patch to DOSBox which directly logs to .VGM files instead of .DRO files. The program logs writes to the Tandy 1000/PCjr's SN76496 chip, the Game Blaster (SAA1099), the OPL2/Dual OPL2/OPL3 chip, the PC speaker (via an AY-3-8910), and the Sound Blaster and Tandy SL/TL/RL DACs (via an YM2612). DAC and PC speaker are only logged if "capturepcm" and "capturespeaker" in the [dosbox] section of DOSBox.conf are set to "true", respectively; they are "false" by default, and can only be changed from the config file, not within a DOSBox session from the command line. I have only added PC speaker support for that one game (4D Boxing) that uses it as a fourth PSG channel, but theoretically one could also use it to create a .VGM pack of scratchy sound effects from Commander Keen episodes 1-3. Similarly, I have added DAC logging only for the few games that use it for drums; therefore, it only works with single-cycle 8-bit transfers when the whole sample in memory at the time that the DMA transfer is started (i.e. no double-buffering).

The source code diff also incorporates my correction to the Game Blaster base clock, my patch adding support for Tandy 1000 direct DAC writes, and my patch correcting the interpretation of SN76496 frequency register value 0. As mentioned in one of these discussion threads, when using the Tandy DAC, "sbtype=" should be set to "none" in the [sblaster] section of DOSBox.conf. The source code diff is against SVN r4000, as revisions r4002 and r4003 from two days ago made some changes to the mixer code that break my Tandy DAC code. Just download SVN r4003 and replace mixer.cpp and mixer.h with those from r4000. As I am using a few C++14 features, before compiling, you need to re-run "configure" with the CPPFLAGS="-std=gnu++14" option, e.g.
Code:
./configure --enable-core-inline LDFLAGS="-static-libgcc -static-libstdc++ -s" CPPFLAGS="-std=gnu++14"


The default key to start capturing is still Ctrl+Alt+F7; even the name in the key bindings ("mapper") file is still "hand_caprawopl", so I wouldn't have to change my key binding file. I tried to start logging in the middle of a 4-OP FM song, and the playback still seemed correct, so I hope I did the register cache business correctly, and I have taken care that no OPL register writes are filtered (i.e. no implicit vgm_cmp).


Attachments:
File comment: Win32 build of DOSBox-VGM
DOSBox-VGM build.zip [1.57 MiB]
Downloaded 69 times
File comment: Source diff against DOSBox SVN r4000
r4000-vgmcapture.zip [15.45 KiB]
Downloaded 39 times
Top
 Profile  
 
 Post subject:
PostPosted: 2017-01-06, 6:51:14 

Musicians Musicians
Contributors Contributors
Offline

Joined: 2012-09-29, 11:45:48
Posts: 205
Location: Australia
beastly work. i will have a look at this when i have some free time to do some tests. :) thanks for your efforts!

_________________
-dj.tuBIG/MaliceX


Top
 Profile  
 
 Post subject:
PostPosted: 2017-01-07, 18:13:43 
Offline

Joined: 2011-11-30, 17:26:44
Posts: 454
Location: Italy
Awesome work, now we only need someone to rip the Tandy version of Thexder's main music so I'll have something to listen on infinite loop.

I still think the PC Speaker should be logged properly into a separate chip with dedicated commands instead of using a workaround, though, just like I'm not sure if using the YM2612 only for its DAC is a good idea, how hard would it be to add a generic "PCM stream" chip to be used in such cases?

_________________
My webhost decided to shut down most of my webspace without a warning. If you find any broken Digilander link in any of my posts (basically all of them should be), please inform me.


Top
 Profile  
 
 Post subject:
PostPosted: 2017-01-07, 20:18:55 

Contributors Contributors
Offline

Joined: 2016-12-27, 3:21:40
Posts: 39
Tom wrote:
Awesome work, now we only need someone to rip the Tandy version of Thexder's main music so I'll have something to listen on infinite loop.
Done.
Tom wrote:
I still think the PC Speaker should be logged properly into a separate chip with dedicated commands instead of using a workaround,
For PC speaker logging, that would require the following commands for writing period and mode to Programmable Interval Timer counters 0 and 2 (command numbers are hypothetical):
  • 0x30 xx: Write byte xx to 8254 Programmable Interval Timer (PIT) Counter 0 Register (I/O address 0x40)
  • 0x31 xx: Write byte xx to 8255 Programmable Peripherial Interface (PPI) System Control Port (I/O address 0x61, only bits 0 and 1 are relevant)
  • 0x32 xx: Write byte xx to 8254 Programmable Interval Timer (PIT) Counter 2 Register (I/O address 0x42)
  • 0x33 xx: Write byte xx to 8254 Programmable Interval Timer (PIT) Control Word Register (I/O address 0x43)
Counter 0 is necessary when a program uses the PC speaker for sample playback using Pulse Width Modulation.

The bigger problem is that for programs that do Pulse Width Modulation manually without the PIT by waiting for a small number of CPU cycles between I/O address 0x61 writes (Ultima II Sierra On-Line version), one would need to have sub-sample timing accuracy. Another solution for that issue would be to indeed just add a generic PCM command as you proposed, including one for generic 16 bit PCM, and then I could simply use Blip_Buffer to convert those high-frequency PC Speaker writes directly into samples. I had done that at one point, but removed it since any gain in quality compared to the current code was lost by reducing the result to 8 bits for the YM2612 DAC. How about (command numbers are hypothetical):
  • 0x3F xx: Generic 8-bit unsigned PCM write
  • 0x40 ll mm: Generic 16-bit signed PCM write (ll: LSB, mm: MSB)


Top
 Profile  
 
 Post subject:
PostPosted: 2017-03-06, 10:03:35 
Offline
User avatar

Joined: 2015-06-08, 20:42:22
Posts: 26
Location: Argentina
Thank you so much for this! I'll give it a try!

By the way, would it be too much trouble to give the user the option to log PC speaker notes into standard OPL2 MIDI-like notes, like the Life & Death II - The Brain music pack?
(Although I'm not sure if that one had an OPL2 mode already in the game as opposed to being 'converted' from PC speaker to FM...)


Top
 Profile  
 
 Post subject:
PostPosted: 2017-03-09, 20:06:05 

Contributors Contributors
Offline

Joined: 2016-12-27, 3:21:40
Posts: 39
The game plays Adlib music that just sounds like PC speaker music.

VGM, as I understand it, is supposed to play back music as it originally sounded. By that standard, OPL2 cannot be used to capture PC speaker sounds because it has no square waveform.


Top
 Profile  
 
 Post subject:
PostPosted: 2017-03-16, 1:02:24 
Offline
User avatar

Joined: 2015-06-08, 20:42:22
Posts: 26
Location: Argentina
That's why I suggested transcribing the notes to like a standard piano-like instrument or something of the sort... I didn't mean having the PC speaker square waves play on the OPL2.


Top
 Profile  
 
 Post subject:
PostPosted: 2017-03-16, 19:06:26 

Contributors Contributors
Offline

Joined: 2016-12-27, 3:21:40
Posts: 39
DOSBox-VGM captures. It does not transcribe. If transcription/conversion from one chip to another is desired, it should be done by an external utility, not by a VGM-producing emulator.


Top
 Profile  
 
 Post subject:
PostPosted: 2017-04-01, 4:42:59 
Offline
User avatar

Joined: 2015-06-08, 20:42:22
Posts: 26
Location: Argentina
Okay, got it. I'll add this to my list of things to code for when I can program competently. :P Thanks for the feedback!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group