Skip to content

FM Towns emulation and VGM logging

Technical discussion about the VGM format, and all the software you need to handle VGM files.

Moderator: Staff

  • User avatar
  • MaliceX Offline
  • Posts: 226
  • Joined: 2012-09-29, 11:45:48
  • Location: Australia
  • Contact:

FM Towns emulation and VGM logging

Post by MaliceX »

I've been thinking lately. Given there hasn't been any rips for FM Towns games (or ports rather :P) uploaded as of yet due to a number of reasons including experimental emulation, a few things did not make sense to me.

Some points:
  • UNZ is currently the best emulator (albeit not open source) for playing games on this platform.
  • Sound emulation appears to be correct (at least as far as clock frequency is concerned) in UNZ
  • Other than flaky compatibility, MESS sound emulation for this platform is played at a slower clock speed
On closer investigation, we know YM2612 (and by extension YM3438) is commonly associated with the Sega MegaDrive/Genesis, which uses the chip at a clock speed of ~7.67MHz. But it's been noted that other systems supposedly used this and related chips on other platforms at a clock speed of ~8MHz (or ~7.97MHz, apparently this has been the case for PC-88 and PC-98 platforms.)

With this thought, seeing MESS VGM Mod log FMTowns chip registers at 7.67MHz seemed peculiar to me, yet everything seemed to play OK. (still not sure about speed stability but that's to be investigated further, comparing with UNZ due to lack of an actual physical unit).

2 minutes in a hex editor later, changed the YM2612 clock to 7987200Hz (~8MHz), and we get the following:

Before: https://dl.dropboxusercontent.com/u/128 ... arty_0.vgm (using ~7.67MHz)
After: https://dl.dropboxusercontent.com/u/128 ... xclock.vgm (using ~8MHz)

Other than the fact that many FMTowns games share the same music data as their PC98 counterparts (they ARE using very similar architecture IIRC. Some hoot entries even re-use PC-98 sound drivers to play the FM-TOWNS music data at 8MHz clock, which sounds largely correct), I'm just wondering if there are any other issues besides playability that is stopping FMTowns games from being uploaded here.

Any thoughts? Please contribute!

Thanks
-dj.tuBIG/MaliceX
  • User avatar
  • 2ch-H Offline
  • Posts: 280
  • Joined: 2012-01-03, 2:10:28

Post by 2ch-H »

I changed the clock of MESS of FM Towns.
MESS 0.156 FM Towns clock 8Mhz (Not vgm mod, I don't know how to vgm mod)
https://www.dropbox.com/s/j0fpcjymaloimv2/mess.7z

Example:
Unz recording Asuka 120% opening
https://www.dropbox.com/s/me8elhjvrlk0vo1/asukaunz.wav

Mess (8Mhz) recording Asuka 120% opening (Maybe correct clock and tempo)
https://www.dropbox.com/s/0hlkmiwm3awsdz4/asukamess.wav

Mess (7.67MHz) recording Asuka 120% opening (The wrong clock, slow tempo)
https://www.dropbox.com/s/pkcr77aaw8ljy ... amesso.wav

I think 8Mhz is correct.

Source Changes
mame\misc\mame\src\mess\drivers\fmtowns.c

Code: Select all

	/* sound hardware */
	MCFG_SPEAKER_STANDARD_MONO("mono")
	MCFG_SOUND_ADD("fm", YM3438, 56000000 / 7) // actual clock speed unknown
	MCFG_YM2612_IRQ_HANDLER(WRITELINE(towns_state, towns_fm_irq))
	MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)

	MCFG_RF5C68_ADD("pcm", 56000000 / 7)  // actual clock speed unknown
	MCFG_RF5C68_SAMPLE_END_CB(towns_state, towns_pcm_irq)
	MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.50)
	MCFG_SOUND_ADD("cdda",CDDA,0)
	MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
	MCFG_SOUND_ADD("speaker", SPEAKER_SOUND,0)
	MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
I changed the "53693100 / 7" to "56000000 / 7".
  • User avatar
  • MaliceX Offline
  • Posts: 226
  • Joined: 2012-09-29, 11:45:48
  • Location: Australia
  • Contact:

Post by MaliceX »

2ch-H wrote:I think 8Mhz is correct.

Source Changes
mame\misc\mame\src\mess\drivers\fmtowns.c

Code: Select all

	/* sound hardware */
	MCFG_SPEAKER_STANDARD_MONO("mono")
	MCFG_SOUND_ADD("fm", YM3438, 56000000 / 7) // actual clock speed unknown
	MCFG_YM2612_IRQ_HANDLER(WRITELINE(towns_state, towns_fm_irq))
	MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)

	MCFG_RF5C68_ADD("pcm", 56000000 / 7)  // actual clock speed unknown
	MCFG_RF5C68_SAMPLE_END_CB(towns_state, towns_pcm_irq)
	MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.50)
	MCFG_SOUND_ADD("cdda",CDDA,0)
	MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
	MCFG_SOUND_ADD("speaker", SPEAKER_SOUND,0)
	MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
I changed the "53693100 / 7" to "56000000 / 7".
Ha. "actual clock speed unknown". No wonder it's wrong! That means they just ported over the Sega MegaDrive init routines for ym2612, which explains why the clock was ~7.67MHz.

By the way, the tempo DOES sound like it's fixed with those changes in the code. :O That might be the best alternative we have actually! Nice.
-dj.tuBIG/MaliceX

Post by Kaminari »

For reference :

Asuka 120% Opening (PC Engine)

The speed and tempo is nearly identical to MESS 8 MHz.
  • User avatar
  • MaliceX Offline
  • Posts: 226
  • Joined: 2012-09-29, 11:45:48
  • Location: Australia
  • Contact:

Post by MaliceX »

Until there's someone out there can confirm technical clock details about the FM Towns sound hardware, it's still a better guesstimate than what's currently there, and I'm inclined to believe Japanese contributors more than anything on this topic. So far, searches on the topic are correlating the CPU clock speed which would make sense if sound chip was synchronized in some way with the main CPU. (MESS source also currently uses 16MHz which nicely fits with 8MHz by a factor of two cycles).

It just doesn't make sense if the clocks are not in sync by design.
-dj.tuBIG/MaliceX

Post by vampirefrog »

Luke Morse has an FM towns machine (or more?), I'll ask him on his facebook what the frequency on the crystal is.

Edit: he says it's packed and it's hard to get at for now.

Post by 1983parrothead »

The BGM is in the wrong places.
  • User avatar
  • MaliceX Offline
  • Posts: 226
  • Joined: 2012-09-29, 11:45:48
  • Location: Australia
  • Contact:

Post by MaliceX »

1983parrothead wrote:The BGM is in the wrong places.
Please elaborate on what you mean.

Also just for an FYI for anyone that doesn't read the IRC, ValleyBell's recent vgm mod release for MAME/MESS 0.156 incorporates the 8MHz fix for FMTowns YM2612/3438. Some games would rely on the chip timer commands, so tempo should be fixed as well as pitch.
-dj.tuBIG/MaliceX

Post by 1983parrothead »

For instance, Megumi's Theme plays during Kumi's stage.

Post by Kaminari »

What version are you talking about? I checked the X68000 and FM-Towns packs with my PC Engine version, and all themes have their proper names.

Check the official soundtrack at Project Egg.

[Edit] Ah yeah, I just saw your post at Tokugawa. Well, the themes are in the right places -- it's the FM-Towns port that is wrong ;)

Post by 1983parrothead »

FM Towns version is the initially released version, not a port. For some reason, it's probably been rushed out, but quietly cancelled for the sometimes-superior Sharp X68000 port.

Hacking it and tweaking it is the only way.
Post Reply